Zulip Chat Archive

Stream: new members

Topic: One-line proof


Bhavik Mehta (Nov 20 2019 at 18:25):

What's the one-line proof that I'm missing:

example {α β : Type} {x : α} {y z : β} (h : (x, y) = (x, z)) : y = z :=
begin
  sorry -- simp [h]
end

Bhavik Mehta (Nov 20 2019 at 18:27):

I guess revert h, simp works...

Mario Carneiro (Nov 20 2019 at 18:48):

cases h; refl

Rob Lewis (Nov 20 2019 at 19:13):

Or injection h

Bhavik Mehta (Nov 20 2019 at 19:18):

Ah, injection is what I was looking for. I don't get what cases is doing in that line, and why that works

Bhavik Mehta (Nov 20 2019 at 19:22):

Out of interest, how would I prove this in term mode

Marc Huisinga (Nov 20 2019 at 19:39):

example {α β : Type} {x : α} {y z : β} (h : (x, y) = (x, z)) : y = z := (prod.mk.inj h).2

prod.mk.inj uses prod.no_confusion which afaik you get for all inductive types that are not propositions

Andrew Ashworth (Nov 20 2019 at 19:40):

yes, it's auto-generated afaik

example {α β : Type} {x : α} {y z : β} (h : (x, y) = (x, z)) : y = z := prod.no_confusion h (λ _, id)

Chris B (Nov 20 2019 at 22:51):

Yeah, no_confusion is what you want when you'd like to show that a constructor is injective and/or disjoint. The sources below have some more detailed info. FWIW no_confusion is defined in terms of another definition called no_confusion_type which I find easier on the eyes.

https://github.com/leanprover/tutorial/blob/master/06_Inductive_Types.org
https://xenaproject.wordpress.com/2018/03/24/no-confusion-over-no_confusion/

Mario Carneiro (Nov 20 2019 at 23:10):

Here's a proof directly from axioms:

example {α β : Type} {x : α} {y z : β} : (x, y) = (x, z)  y = z :=
@congr_arg _ β (x, y) (x, z) (@prod.rec _ β (λ _, β) (λ a b, b))

Mario Carneiro (Nov 20 2019 at 23:10):

or more simply

example {α β : Type} {x : α} {y z : β} : (x, y) = (x, z)  y = z :=
congr_arg prod.snd

Last updated: Dec 20 2023 at 11:08 UTC