import MyNat.Definition
import MyNat.Addition -- add_succ
import MyNat.Multiplication -- mul_succ
import AdvancedAdditionWorld.Level9 -- succ_ne_zero
namespace MyNat
open MyNat
Advanced Multiplication World
Level 1: mul_pos
Recall that if b : MyNat
is a hypothesis and you do cases b with
,
your one goal will split into two goals,
namely the cases b = 0
and b = succ n
. So cases
here is like
a weaker version of induction (you don't get the inductive hypothesis).
Tricks
-
if your goal is
⊢ X ≠ Y
thenintro h
will give youh : X = Y
and a goal of⊢ false
. This is becauseX ≠ Y
means(X = Y) → false
. Conversely if your goal isfalse
and you haveh : X ≠ Y
as a hypothesis thenapply h
will work backwards and turn the goal intoX = Y
. -
if
hab : succ (3 * x + 2 * y + 1) = 0
is a hypothesis and your goal is⊢ false
, thenexact succ_ne_zero _ hab
will solve the goal, because Lean will figure out that_
is supposed to be3 * x + 2 * y + 1
.
Theorem
The product of two non-zero natural numbers is non-zero.
theoremmul_pos (mul_pos: ∀ (a b : MyNat), a ≠ 0 → b ≠ 0 → a * b ≠ 0aa: MyNatb :b: MyNatMyNat) :MyNat: Typea ≠a: MyNat0 →0: MyNatb ≠b: MyNat0 →0: MyNata *a: MyNatb ≠b: MyNat0 :=0: MyNata, b: MyNata ≠ 0 → b ≠ 0 → a * b ≠ 0a, b: MyNat
ha: a ≠ 0
hb: b ≠ 0a * b ≠ 0a, b: MyNat
ha: a ≠ 0
hb: b ≠ 0
hab: a * b = 0Falsea, b: MyNat
ha: a ≠ 0
hb: b ≠ 0
hab: a * b = 0Falsea: MyNat
ha: a ≠ 0
hb: zero ≠ 0
hab: a * zero = 0
zeroFalsea: MyNat
ha: a ≠ 0
hb: zero ≠ 0
hab: a * zero = 0
zerozero = 0Goals accomplished! 🐙a: MyNat
ha: a ≠ 0
b': MyNat
hb: succ b' ≠ 0
hab: a * succ b' = 0
succFalsea: MyNat
ha: a ≠ 0
b': MyNat
hb: succ b' ≠ 0
hab: a * succ b' = 0
succFalsea: MyNat
ha: a ≠ 0
b': MyNat
hb: succ b' ≠ 0
hab: a * b' + a = 0
succFalsea: MyNat
ha: a ≠ 0
b': MyNat
hb: succ b' ≠ 0
hab: a * b' + a = 0
succFalsea: MyNat
ha: a ≠ 0
b': MyNat
hb: succ b' ≠ 0
hab: a * b' + a = 0
succFalsea: MyNat
ha: a ≠ 0
b': MyNat
hb: succ b' ≠ 0
hab: a * b' + a = 0
succa = 0a: MyNat
ha: a ≠ 0
b': MyNat
hb: succ b' ≠ 0
hab: a * b' + a = 0
succa = 0b': MyNat
hb: succ b' ≠ 0
ha: zero ≠ 0
hab: zero * b' + zero = 0
succ.zerozero = 0Goals accomplished! 🐙b': MyNat
hb: succ b' ≠ 0
a': MyNat
ha: succ a' ≠ 0
hab: succ a' * b' + succ a' = 0
succ.succsucc a' = 0b': MyNat
hb: succ b' ≠ 0
a': MyNat
ha: succ a' ≠ 0
hab: succ a' * b' + succ a' = 0
succ.succsucc a' = 0b': MyNat
hb: succ b' ≠ 0
a': MyNat
ha: succ a' ≠ 0
hab: succ (succ a' * b' + a') = 0
succ.succsucc a' = 0b': MyNat
hb: succ b' ≠ 0
a': MyNat
ha: succ a' ≠ 0
hab: succ (succ a' * b' + a') = 0
succ.succsucc a' = 0b': MyNat
hb: succ b' ≠ 0
a': MyNat
ha: succ a' ≠ 0
hab: succ (succ a' * b' + a') = 0
succ.succsucc a' = 0b': MyNat
hb: succ b' ≠ 0
a': MyNat
ha: succ a' ≠ 0
hab: succ (succ a' * b' + a') = 0
succ.succ.hFalseGoals accomplished! 🐙
Next up Level 2