Zulip Chat Archive

Stream: general

Topic: Equality for the ⟨⟩


Kind Bubble (Jan 09 2023 at 03:20):

I'm trying to figure this one out:

variable {X : Type}
variable {x : X}
variable {y : X}
variable {p : x = y}
def q : x, x, x = y,y,y := sorry

I think it should be pretty simple.

David Renshaw (Jan 09 2023 at 03:24):

You need to specify what type you mean for the equality. For example:

variable {X : Type}
variable {x : X}
variable {y : X}
variable {p : x = y}
def q : (⟨x, x, x : X × X × X) = y,y,y := sorry

David Renshaw (Jan 09 2023 at 03:25):

⟨⟩ is "anonymous constructor syntax", and it can construct values of any product-like type.

Kind Bubble (Jan 09 2023 at 03:29):

David Renshaw said:

Ok hmm... here:

variable {X : Type}
variable {x : X}
variable {y : X}
variable {p : x = y}
def q : (⟨x, x, x, Unit.unit : Σ'(_:X), Σ'(_:X),Σ'(_:X),Unit) = y,y,y, Unit.unit := sorry

Now I'm trying to figure out the name of the axiom

David Renshaw (Jan 09 2023 at 03:33):

oh, is this Lean 4?

Kind Bubble (Jan 09 2023 at 03:33):

David Renshaw said:

oh, is this Lean 4?

yeah sorry about that

David Renshaw (Jan 09 2023 at 03:33):

variable {X : Type}
variable {x : X}
variable {y : X}
variable {p : x = y}
def q : (⟨x, x, x, Unit.unit : Σ'(_:X), Σ'(_:X), Σ'(_:X),Unit) = y,y,y, Unit.unit := by congr

Kind Bubble (Jan 09 2023 at 03:33):

What does by do?

David Renshaw (Jan 09 2023 at 03:34):

starts tactic mode. congr is a tactic

Kind Bubble (Jan 09 2023 at 03:35):

David Renshaw said:

starts tactic mode. congr is a tactic

Now suppose I've got some more complex constituent equalities (p:x = y here).

Kind Bubble (Jan 09 2023 at 03:35):

how would I assemble them? would congr automatically know about these demonstrated constituent equalities?

David Renshaw (Jan 09 2023 at 03:37):

I expect congr to break it into simpler subgoals for you

Kind Bubble (Jan 09 2023 at 04:00):

Ok thanks. This is good.

Nonetheless if someone knows a closed form for this involving constituent equalities that would be much appreciated.

Kind Bubble (Jan 09 2023 at 04:23):

Like ??? here:

variable {X : Type}
variable {x : X}
variable {y : X}
variable {p : x = y}
def q : (⟨x, Unit.unit : Σ'(_:X),Unit) = y,Unit.unit := ??? p Eq.refl

Mario Carneiro (Jan 09 2023 at 04:23):

congr applies congruence theorems, which have the form e.g. a = b -> c = d -> (a, c) = (b, d). They are generated on the fly, but you can prove them by using Eq.rec

Mario Carneiro (Jan 09 2023 at 04:24):

congr_arg is a theorem which covers most cases of this

Kind Bubble (Jan 09 2023 at 04:24):

Mario Carneiro said:

congr applies congruence theorems, which have the form e.g. a = b -> c = d -> (a, c) = (b, d). They are generated on the fly, but you can prove them by using Eq.rec

like this?

variable {X : Type}
variable {x : X}
variable {y : X}
variable {p : x = y}
def q : (⟨x, Unit.unit⟩ : Σ'(_:X),Unit) = ⟨y,Unit.unit⟩ := Eq.rec p Eq.refl

Mario Carneiro (Jan 09 2023 at 04:25):

probably p ▸ Eq.refl _ works

Mario Carneiro (Jan 09 2023 at 04:28):

is a wrapper for Eq.rec which is better able to infer the higher order function argument (the "motive") in Eq.rec

Mario Carneiro (Jan 09 2023 at 04:29):

theorem q : (⟨x, Unit.unit : Σ'(_:X),Unit) = y,Unit.unit := p  Eq.refl _
#print q

if you mouse over the in the proof it shows

@Eq.rec X x (fun x_1 h => { fst := x, snd := () } = { fst := x_1, snd := () }) (Eq.refl { fst := x, snd := () }) y p

where fun x_1 h => { fst := x, snd := () } = { fst := x_1, snd := () } is the "motive"

Kind Bubble (Jan 09 2023 at 05:39):

Mario Carneiro said:

theorem q : (⟨x, Unit.unit : Σ'(_:X),Unit) = y,Unit.unit := p  Eq.refl _
#print q

if you mouse over the in the proof it shows

@Eq.rec X x (fun x_1 h => { fst := x, snd := () } = { fst := x_1, snd := () }) (Eq.refl { fst := x, snd := () }) y p

where fun x_1 h => { fst := x, snd := () } = { fst := x_1, snd := () } is the "motive"

hmm wow. ok this is great.


Last updated: Dec 20 2023 at 11:08 UTC