import MyNat.Addition
import MyNat.Multiplication
import MultiplicationWorld.Level1 -- zero_mul
import MultiplicationWorld.Level4 -- mul_add
namespace MyNat
open MyNat
Multiplication World
Level 5: mul_assoc
We now have enough to prove that multiplication is associative.
Random tactic hints
Did you know you can repeat a tactic as many times as necessary to complete the goal?
Lemma
Multiplication is associative.
In other words, for all natural numbers a
, b
and c
, we have
(ab)c = a(bc).
lemmamul_assoc (mul_assoc: ∀ (a b c : MyNat), a * b * c = a * (b * c)aa: MyNatbb: MyNatc :c: MyNatMyNat) : (MyNat: Typea *a: MyNatb) *b: MyNatc =c: MyNata * (a: MyNatb *b: MyNatc) :=c: MyNata, b, c: MyNata * b * c = a * (b * c)a, b, c: MyNata * b * c = a * (b * c)a, b: MyNat
zeroa * b * zero = a * (b * zero)a, b: MyNat
zeroa * b * zero = a * (b * zero)a, b: MyNat
zeroa * b * 0 = a * (b * 0)a, b: MyNat
zeroa * b * 0 = a * (b * 0)a, b: MyNat
zeroa * b * 0 = a * (b * 0)a, b: MyNat
zeroa * b * 0 = a * (b * 0)Goals accomplished! 🐙a, b: MyNat
zero0 = a * 0a, b, c: MyNat
ih: a * b * c = a * (b * c)
succa * b * succ c = a * (b * succ c)a, b, c: MyNat
ih: a * b * c = a * (b * c)
succa * b * succ c = a * (b * succ c)a, b, c: MyNat
ih: a * b * c = a * (b * c)
succa * b * c + a * b = a * (b * succ c)a, b, c: MyNat
ih: a * b * c = a * (b * c)
succa * b * c + a * b = a * (b * succ c)a, b, c: MyNat
ih: a * b * c = a * (b * c)
succa * b * c + a * b = a * (b * succ c)a, b, c: MyNat
ih: a * b * c = a * (b * c)
succa * b * c + a * b = a * (b * c + b)a, b, c: MyNat
ih: a * b * c = a * (b * c)
succa * b * c + a * b = a * (b * c + b)a, b, c: MyNat
ih: a * b * c = a * (b * c)
succa * b * c + a * b = a * (b * c + b)a, b, c: MyNat
ih: a * b * c = a * (b * c)
succa * (b * c) + a * b = a * (b * c + b)a, b, c: MyNat
ih: a * b * c = a * (b * c)
succa * (b * c) + a * b = a * (b * c + b)a, b, c: MyNat
ih: a * b * c = a * (b * c)
succa * (b * c) + a * b = a * (b * c + b)a, b, c: MyNat
ih: a * b * c = a * (b * c)
succa * (b * c) + a * b = a * (b * c) + a * bGoals accomplished! 🐙
A mathematician could now remark that you have proved that the natural numbers form a monoid under multiplication.
-- instance : AddMonoid MyNat where
-- add_zero := add_zero
-- zero_add := zero_add
-- add_assoc := add_assoc
-- nsmul := λ x y => (myNatFromNat x) * y
-- nsmul_zero' := zero_mul
-- nsmul_succ' n x := by
-- simp
-- BUGBUG: complete these instances...
Next up is Multiplication Level 6.