Group Theory revision
To all Imperial students — welcome back and good luck in your exams.
I was looking at the axioms for a group in Lean today. If you fire up Lean and type #print group (e.g. by clicking here and then waiting for a few seconds or more until it stops saying “(running…)” at the top), you can see what Lean thinks a group is. There’s the usual notation for a group (it has multiplication a * b, and identity 1 and inverses a⁻¹), and then some axioms:
mul_assoc : ∀ (a b c : G), a * b * c = a * (b * c))
one_mul : ∀ (a : G), 1 * a = a)
mul_one : ∀ (a : G), a * 1 = a)
mul_left_inv : ∀ (a : G), a⁻¹ * a = 1)Now I was lucky enough to be taught group theory by the great J G Thompson, and one of the things he taught me was that you don’t need four axioms to do groups, you can get away with three. I thought this would be fun to check in Lean! Before you read the next couple of paragraphs you might want to spend some time thinking about which of the four axioms you think is implied by the others, if you don’t know already. Feel free to delete one axiom and then try to reprove it from the others. I should perhaps also add that Lean’s group has four axioms because of an artificial consequence of the way it was built from other structures, and it doesn’t matter at all that this fourth axiom is there.
Before I go on, let me tell you an interesting example of something that isn’t a group, which Thompson told us about in his lectures. It’s a set
with more than one element, and equipped with the function
defined by
. We can check (either using pen and paper, or with Lean) that this law is not a group law, but if we define
it does satisfy all but one of the axioms. The axiom it fails to satisfy is one_mul, which must hence be an essential axiom.
The axiom which is implied by the other is actually mul_one. Let me formally explain what I mean by this. Lean already has groups defined and the class of groups is called group. So let me in Lean define a new class group' (note the dash) by removing mul_one and just using the other axioms:
class group' (G : Type) extends has_group_notation G :=
(mul_assoc : ∀ (a b c : G), a * b * c = a * (b * c))
(one_mul : ∀ (a : G), 1 * a = a)
(mul_left_inv : ∀ (a : G), a⁻¹ * a = 1)and now we can try and prove this:
theorem mul_one : ∀ (a : G), a * 1 = a := sorry
The way I was taught to do this was first by proving mul_left_cancel, the fact that you can cancel on the left when doing multiplication:
lemma mul_left_cancel : ∀ (a b c : G), a * b = a * c → b = c :=
λ (a b c : G) (Habac : a * b = a * c), -- got to deduce b = c.
calc b = 1 * b : by rw one_mul
... = (a⁻¹ * a) * b : by rw mul_left_inv
... = a⁻¹ * (a * b) : by rw mul_assoc
... = a⁻¹ * (a * c) : by rw Habac
... = (a⁻¹ * a) * c : by rw mul_assoc
... = 1 * c : by rw mul_left_inv
... = c : by rw one_mulUsing this you can now probably finish the proof yourself:
theorem mul_one : ∀ (a : G), a * 1 = a :=
begin
intro a, -- goal is a * 1 = a
apply mul_left_cancel a⁻¹, -- goal now a⁻¹ * (a * 1) = a⁻¹ * a
exact calc a⁻¹ * (a * 1) = ? : by rw ?
... = ? : by rw ...
...
... = a⁻¹ * a : by rw ?
endJust click here%0A%0Anamespace%20group'%0Avariables%20%7BG%20:%20Type%7D%20%5Bgroup'%20G%5D%20%20%0A%0A--%20We%20prove%20left_mul_cancel%20for%20group'%0A%0Alemma%20mul_left_cancel%20:%20%E2%88%80%20(a%20b%20c%20:%20G),%20a%20*%20b%20=%20a%20*%20c%20%E2%86%92%20b%20=%20c%20:=%20%0A%CE%BB%20(a%20b%20c%20:%20G)%20(Habac%20:%20a%20*%20b%20=%20a%20*%20c),%20--%20got%20to%20deduce%20b%20=%20c.%0A%20calc%20b%20=%201%20*%20b%20%20%20%20%20%20%20%20%20:%20by%20rw%20one_mul%0A%20%20%20%20...%20=%20(a%E2%81%BB%C2%B9%20*%20a)%20*%20b%20:%20by%20rw%20mul_left_inv%0A%20%20%20%20...%20=%20a%E2%81%BB%C2%B9%20*%20(a%20*%20b)%20:%20by%20rw%20mul_assoc%0A%20%20%20%20...%20=%20a%E2%81%BB%C2%B9%20*%20(a%20*%20c)%20:%20by%20rw%20Habac%0A%20%20%20%20...%20=%20(a%E2%81%BB%C2%B9%20*%20a)%20*%20c%20:%20by%20rw%20mul_assoc%0A%20%20%20%20...%20=%201%20*%20c%20%20%20%20%20%20%20%20%20:%20by%20rw%20mul_left_inv%0A%20%20%20%20...%20=%20c%20%20%20%20%20%20%20%20%20%20%20%20%20:%20by%20rw%20one_mul%0A%0A--%20now%20the%20main%20theorem%0A%0Atheorem%20mul_one%20:%20%E2%88%80%20(a%20:%20G),%20a%20*%201%20=%20a%20:=%0Abegin%0Aintro%20a,%20--%20goal%20is%20a%20*%201%20=%20a%0A%20apply%20mul_left_cancel%20a%E2%81%BB%C2%B9,%20--%20goal%20now%20a%E2%81%BB%C2%B9%20*%20(a%20*%201)%20=%20a%E2%81%BB%C2%B9%20*%20a%0A%20exact%20calc%20a%E2%81%BB%C2%B9%20*%20(a%20*%201)%20=%20?%20%20%20%20%20%20%20:%20by%20rw%20?%0A%20%20%20%20%20%20%20%20...%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20=%20?%20%20%20%20%20%20%20:%20by%20rw%20...%0A%20%20%20%20%20%20%20%20...%0A%20%20%20%20%20%20%20%20...%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20=%20a%E2%81%BB%C2%B9%20*%20a%20:%20by%20rw%20?%0A%20end%0A%0Aend%20group') to run a version of Lean in your browser where you can try and finish the job yourself. Alternatively download the source code (and the solutions) at Xena’s github site and run it on your own computer — it’s faster.
Are there any example sheet or exam group theory problems which you are interested in seeing being solved in Lean? Let me know in the comments.