import MyNat.Addition
import MyNat.Multiplication
import AdditionWorld.Level1 -- zero_add
import AdditionWorld.Level2 -- add_assoc
namespace MyNat
open MyNat
Multiplication World
Level 4: mul_add
Where are we going? Well we want to prove mul_comm
and mul_assoc
, i.e. that a * b = b * a
and
(a * b) * c = a * (b * c)
. But we also want to
establish the way multiplication interacts with addition,
i.e. we want to prove that we can "expand out the brackets"
and show a * (b + c) = (a * b) + (a * c)
.
The technical term for this is "left distributivity of
multiplication over addition" (there is also right distributivity,
which we'll get to later).
Note the name of this proof -- mul_add
. And note the left
hand side -- a * (b + c)
, a multiplication and then an addition.
I think mul_add
is much easier to remember than "left_distrib",
an alternative name for the proof of this lemma.
Lemma
Multiplication is distributive over addition.
In other words, for all natural numbers a
, b
and t
, we have
t(a + b) = ta + tb.
lemmamul_add (mul_add: ∀ (t a b : MyNat), t * (a + b) = t * a + t * btt: MyNataa: MyNatb :b: MyNatMyNat) :MyNat: Typet * (t: MyNata +a: MyNatb) =b: MyNatt *t: MyNata +a: MyNatt *t: MyNatb :=b: MyNatt, a, b: MyNatt * (a + b) = t * a + t * bt, a, b: MyNatt * (a + b) = t * a + t * bt, a: MyNat
zerot * (a + zero) = t * a + t * zerot, a: MyNat
zerot * (a + zero) = t * a + t * zerot, a: MyNat
zerot * (a + 0) = t * a + t * 0t, a: MyNat
zerot * a = t * a + t * 0t, a: MyNat
zerot * a = t * a + 0t, a: MyNat
zerot * a = t * aGoals accomplished! 🐙t, a, b: MyNat
ih: t * (a + b) = t * a + t * b
succt * (a + succ b) = t * a + t * succ bt, a, b: MyNat
ih: t * (a + b) = t * a + t * b
succt * (a + succ b) = t * a + t * succ bt, a, b: MyNat
ih: t * (a + b) = t * a + t * b
succt * succ (a + b) = t * a + t * succ bt, a, b: MyNat
ih: t * (a + b) = t * a + t * b
succt * succ (a + b) = t * a + t * succ bt, a, b: MyNat
ih: t * (a + b) = t * a + t * b
succt * succ (a + b) = t * a + t * succ bt, a, b: MyNat
ih: t * (a + b) = t * a + t * b
succt * (a + b) + t = t * a + t * succ bt, a, b: MyNat
ih: t * (a + b) = t * a + t * b
succt * (a + b) + t = t * a + t * succ bt, a, b: MyNat
ih: t * (a + b) = t * a + t * b
succt * (a + b) + t = t * a + t * succ bt, a, b: MyNat
ih: t * (a + b) = t * a + t * b
succt * a + t * b + t = t * a + t * succ bt, a, b: MyNat
ih: t * (a + b) = t * a + t * b
succt * a + t * b + t = t * a + t * succ bt, a, b: MyNat
ih: t * (a + b) = t * a + t * b
succt * a + t * b + t = t * a + t * succ bt, a, b: MyNat
ih: t * (a + b) = t * a + t * b
succt * a + t * b + t = t * a + (t * b + t)t, a, b: MyNat
ih: t * (a + b) = t * a + t * b
succt * a + t * b + t = t * a + (t * b + t)t, a, b: MyNat
ih: t * (a + b) = t * a + t * b
succt * a + t * b + t = t * a + (t * b + t)t, a, b: MyNat
ih: t * (a + b) = t * a + t * b
succt * a + (t * b + t) = t * a + (t * b + t)defGoals accomplished! 🐙left_distrib :=left_distrib: ∀ (t a b : MyNat), t * (a + b) = t * a + t * bmul_add -- the "proper" name for this lemmamul_add: ∀ (t a b : MyNat), t * (a + b) = t * a + t * b
Next up is Multiplication Level 5.