Zulip Chat Archive

Stream: general

Topic: groups


Michael Melesse (Oct 10 2021 at 01:01):

Hey everyone, I just finished the Naturals number game. It was great. Does anyone know if there are any resources on working with groups in lean.

Yury G. Kudryashov (Oct 10 2021 at 01:02):

Math library has docs#group and many other definitions/theorems.

Michael Melesse (Oct 10 2021 at 01:07):

Got it thank you. I will take a look.

Michael Melesse (Oct 10 2021 at 01:11):

Would you know where I can find an example of some one proving something simple about groups using lean.

Michael Melesse (Oct 10 2021 at 01:30):

nvm, just found https://cocalc.com/share/public_paths/f014cd1885a22e8665a728be825e563fc79b7e1f/README.md

Yury G. Kudryashov (Oct 10 2021 at 02:29):

https://github.com/leanprover-community/mathlib/tree/master/src/algebra/group

Yury G. Kudryashov (Oct 10 2021 at 02:29):

and https://github.com/leanprover-community/mathlib/tree/master/src/group_theory

Kevin Buzzard (Oct 10 2021 at 08:37):

These links to mathlib are not really useful here -- the mathlib proofs are incomprehensible to someone who has only played NNG

Kevin Buzzard (Oct 10 2021 at 08:39):

Here's a link to a workshop I ran about group theory for lean beginners: https://xenaproject.wordpress.com/2021/01/28/formalising-mathematics-workshop-2/

Yaël Dillies (Oct 10 2021 at 08:41):

For having learnt Lean using this, I can attest of this workshop's quality.

Kevin Buzzard (Oct 10 2021 at 08:48):

The mathlib links on the other hand do give you some kind of feeling as to "how far we have got" in group theory. For example the names of the files indicate what is covered and the module docstrings (the text at the top of each file) explains what definitions are made and what theorems are proved in the files

Michael Melesse (Oct 11 2021 at 04:39):

Thank you all. Looking forward to going through the workshop

Michael Melesse (Oct 13 2021 at 19:07):

How would I go about defining a custom group in lean? For example if I wanted to define a group on a subset of the reals and a custom op.

Yaël Dillies (Oct 13 2021 at 19:09):

Fill those in :smile:

def my_group (S : set ) : group S :=
{ mul := _,
  mul_assoc := _,
  one := _,
  one_mul := _,
  mul_one := _,
  inv := _,
  mul_left_inv := _ }

Yaël Dillies (Oct 13 2021 at 19:10):

To quickly get this list of fields, you can do

def my_group (S : set ) : group S :=
{!!}

and click on the lightbulb.

Adam Topaz (Oct 13 2021 at 19:12):

Yaël Dillies said:

Fill those in :smile:

def my_group (S : set ) : group S :=

This won't work -- this will ask you to define a group structure on any given set S of reals. I assume you have a specific set Sin mind?

Yaël Dillies (Oct 13 2021 at 19:13):

Yeah of course, I don't know what Michael wants.

Michael Melesse (Oct 13 2021 at 19:14):

Yes, I was hoping to define on ℝ\{-1}

Adam Topaz (Oct 13 2021 at 19:14):

what's the operation?

Yaël Dillies (Oct 13 2021 at 19:15):

Then replace S with {x : ℝ // x ≠ -1}.

Michael Melesse (Oct 13 2021 at 19:17):

The op is a*b :=(a+b)^2 where a,b are in the set ℝ\{-1}

Michael Melesse (Oct 13 2021 at 19:17):

Thank you both

Eric Rodriguez (Oct 13 2021 at 19:19):

Yaël Dillies said:

Fill those in :smile:

def my_group (S : set ) : group S :=
{ mul := _,
  mul_assoc := _,
  one := _,
  one_mul := _,
  mul_one := _,
  inv := _,
  div := _,
  div_eq_mul_inv := _,
  mul_left_inv := _ }

Div and Div eq mul inv are impl details right?

Yaël Dillies (Oct 13 2021 at 19:19):

Whoops, yeah

Bolton Bailey (Oct 13 2021 at 19:22):

Michael Melesse said:

The op is a*b :=(a+b)^2 where a,b are in the set ℝ\{-1}

I don't actually see how this operation defines a group. Is there any identity element e such that a = (a + e)^2 for all a in your set?

Michael Melesse (Oct 13 2021 at 19:23):

oops this is the op, ab + a + b

Yaël Dillies (Oct 13 2021 at 19:23):

Aah, makes more sense

Yaël Dillies (Oct 13 2021 at 19:24):

You can also instead define a group_with_zero ℝ. That'll probably be more pleasant.

Mario Carneiro (Oct 13 2021 at 19:27):

The nicest way to prove that is to prove that a -> a - 1 is a bijection from units ℝ to ℝ\{-1} such that the image of * under the bijection is a,b -> ab+a+b

Michael Melesse (Oct 14 2021 at 18:01):

@Yaël Dillies When you say replace S with {x : ℝ // x ≠ -1}. Do you mean define a variable? Just plugging it in doesnot seem to work

Yaël Dillies (Oct 14 2021 at 18:02):

I mean

def my_group : group {x :  // x  -1} := ...

Michael Melesse (Oct 14 2021 at 18:07):

Got it. Thanks.

Michael Melesse (Oct 14 2021 at 18:08):

When I define the mul like this mul := ∀(a b:{x : ℝ // x ≠ -1}), a+a*b+b, I get an error about the addition

Michael Melesse (Oct 14 2021 at 18:08):

failed to synthesize type class instance for
a b : {x // x ≠ -1}
⊢ has_add {x // x ≠ -1}

Michael Melesse (Oct 14 2021 at 18:09):

I cannot seem to define an add op. The group structure doesnot have it to overwrite

Michael Melesse (Oct 14 2021 at 18:10):

looking through docs non of the flavors have add and mul at the same time

Yaël Dillies (Oct 14 2021 at 18:12):

Welcome to subtyping hell. :smiling_devil: Enjoy you stay.

Yaël Dillies (Oct 14 2021 at 18:14):

{x : ℝ // x ≠ -1} is an entirely new type, so Lean doesn't know anything about it besides its definition. And it certainly doesn't know the inexistent addition you're trying to define: -1/2 : {x : ℝ // x ≠ -1} but you cannot make -1/2 + -1/2 have the meaningful value -1 as it's not in the type!

Yaël Dillies (Oct 14 2021 at 18:16):

The answer is to define your operations through and show they preserve ≠ -1. An element of {x : ℝ // x ≠ -1} is ⟨an element of ℝ, a proof that it's ≠ -1⟩.

Yaël Dillies (Oct 14 2021 at 18:17):

So your operation will look like λ a b, ⟨(a : ℝ) * b + a + b, some_proof⟩.

Yaël Dillies (Oct 14 2021 at 18:17):

(a : ℝ) telling Lean to consider a as a real.

Yaël Dillies (Oct 14 2021 at 18:18):

You probably start getting why we use group_with_zero. Removing 0 to provide a group structure is simply too much of a pain.

Eric Wieser (Oct 14 2021 at 18:23):

I'm not sure this really counts as subtyping hell; this seems like exactly what you would expect to have to do on paper.


Last updated: Dec 20 2023 at 11:08 UTC