Zulip Chat Archive

Stream: lean4

Topic: equivalence of propositions dependent on equal terms


Bhakti Shah (Jul 10 2023 at 16:23):

slightly dumb question because i've run into this before but i also might be missing something super obvious:
if i have P : A -> Prop and I have a proof of a = b where a, b : A, can I get a proof of P a -> P b in some easy way?
i can provide a concrete example if that makes it easier but I was curious more generally about this situation in lean (if there was a way to easily deal with the whole dependent type shenanigans). Thanks!

Kyle Miller (Jul 10 2023 at 16:35):

Here are some options. The latter ones need to have an expected type available:

example (P : A  Prop) (h : a = b) : P a = P b := congrArg P h

example (P : A  Prop) (h : a = b) : P a  P b := cast (congrArg P h)

example (P : A  Prop) (h : a = b) : P a  P b := (congrArg P h).mp

example (P : A  Prop) (h : a = b) (ha : P a) : P b := h  ha

example (P : A  Prop) (h : a = b) (ha : P a) : P b := Eq.rec ha h

example (P : A  Prop) (h : a = b) : P a  P b := Eq.recOn h

Bhakti Shah (Jul 10 2023 at 16:41):

that is super helpful thank you :)

Scott Morrison (Jul 12 2023 at 04:57):

Don't forget subst h.

Kyle Miller (Jul 12 2023 at 07:15):

Sure, if we want tactic proofs:

example (P : A  Prop) (h : a = b) : P a  P b := by subst h; exact id
example (P : A  Prop) (h : a = b) (ha : P a) : P b := by subst h; exact ha
example (P : A  Prop) (h : a = b) : P a  P b := by cases h; exact id
example (P : A  Prop) (h : a = b) (ha : P a) : P b := by cases h; exact ha
example (P : A  Prop) (h : a = b) (ha : P a) : P b := by subst_vars; exact ha
example (P : A  Prop) (h : a = b) (ha : P a) : P b := by simp_all

Ruben Van de Velde (Jul 12 2023 at 07:20):

Tactic proofs? In this economy?


Last updated: Dec 20 2023 at 11:08 UTC