Zulip Chat Archive

Stream: new members

Topic: Proving a trivial lemma about homomorphisms.


Jan Matula (Aug 07 2023 at 14:12):

Hello, I was wondering how a I might prove this lemma:

lemma equate_hom {X Y : Magma} :
 f g : Hom X Y, f.func = g.func    f = g

where Hom is defined like this:

class hom {X Y : Magma} (f : X  Y) :=
  (resp_op :  x y : X,
    f (X.op x y) = Y.op (f x) (f y) )

structure Hom (X Y : Magma) :=
  (func : X  Y) (hom_func : hom func)

Somehow I can't seem to do this, though it should probably be quite simple.

Jan Matula (Aug 07 2023 at 14:13):

the full example online

Eric Wieser (Aug 07 2023 at 14:14):

Note it's usually best to paste the full code directly here rather than link to the web editor; Zulip adds an "open in web editor" link automatically.

Jan Matula (Aug 07 2023 at 14:16):

No problem, this is the full code:

universe u

/-
magmas:
-/

structure Magma :=
  (carrier : Type u)
  (op : carrier  carrier  carrier)

instance Magma_to_sort :
has_coe_to_sort Magma (Type u) :=
   Magma.carrier 

/-
homomorphisms:
-/

class hom {X Y : Magma} (f : X  Y) :=
  (resp_op :  x y : X,
    f (X.op x y) = Y.op (f x) (f y) )

structure Hom (X Y : Magma) :=
  (func : X  Y) (hom_func : hom func)

instance Hom.to_fun {X Y : Magma} :
has_coe_to_fun (Hom X Y) (λ _, X  Y) :=
   Hom.func 

-- how do I prove this?
lemma equate_hom {X Y : Magma} :
 f g : Hom X Y, f.func = g.func    f = g :=
  sorry

Eric Wieser (Aug 07 2023 at 14:18):

You will have a better time if you change

class hom {X Y : Magma} (f : X  Y) :=

to

class hom {X Y : Magma} (f : X  Y) : Prop :=

Patrick Massot (Aug 07 2023 at 14:18):

The most important answer is: you shouldn't be using Lean 3 which is fully deprecated.

Patrick Massot (Aug 07 2023 at 14:18):

And then indeed the second answer is what Eric wrote.

Eric Rodriguez (Aug 07 2023 at 14:19):

Eric Wieser said:

You will have a better time if you change

class hom {X Y : Magma} (f : X  Y) :=

to

class hom {X Y : Magma} (f : X  Y) : Prop :=

and then the @[ext] attribute can help you make these lemmas automatically

Eric Wieser (Aug 07 2023 at 14:19):

Which to be clear, goes on structure Hom not class hom

Patrick Massot (Aug 07 2023 at 14:20):

To be clear: the fact that this : Prop is required is clearly a bug, but it will never be fixed in Lean 3 which is completely frozen forever.

Eric Wieser (Aug 07 2023 at 14:20):

I don't know if we opened a Lean4 issue about it yet...

Patrick Massot (Aug 07 2023 at 14:20):

And the @[ext] attribute will require some import (probably from mathlib).

Mario Carneiro (Aug 07 2023 at 14:21):

it's in std

Eric Rodriguez (Aug 07 2023 at 14:21):

Is this goal proable without : Prop? It should still be a subsingleton, right? Just not definitionalyl

Eric Wieser (Aug 07 2023 at 14:21):

Yeah, but you get an annoying HEq for the hom field

Patrick Massot (Aug 07 2023 at 14:22):

Mario, I was answering the Lean 3 question, but indeed in Lean 4 it is in std.

Jan Matula (Aug 07 2023 at 14:22):

Patrick Massot said:

The most important answer is: you shouldn't be using Lean 3 which is fully deprecated.

Somehow I was under the impression that Lean 3 was the stable one, while Lean 4 is work in progress.

Ruben Van de Velde (Aug 07 2023 at 14:29):

You're a few weeks out of date :)

Kevin Buzzard (Aug 07 2023 at 16:05):

Mathlib 3 is no longer accepting PRs and mathlib 4 is fully up and running! And yeah this is a recent event.


Last updated: Dec 20 2023 at 11:08 UTC