import MyNat.Definition
import MyNat.Addition -- add_zero
import AdvancedAdditionWorld.Level6 -- add_left_cancel
namespace MyNat
open MyNat
Advanced Addition World
Level 8: eq_zero_of_add_right_eq_self
The lemma you're about to prove will be useful when we want to prove that ≤
is antisymmetric.
There are some wrong paths that you can take with this one.
Lemma
If a
and b
are natural numbers such that
a + b = a,
then b = 0
.
lemmaeq_zero_of_add_right_eq_self {eq_zero_of_add_right_eq_self: ∀ {a b : MyNat}, a + b = a → b = 0aa: MyNatb :b: MyNatMyNat} :MyNat: Typea +a: MyNatb =b: MyNata →a: MyNatb =b: MyNat0 :=0: MyNata, b: MyNata + b = a → b = 0a, b: MyNat
h: a + b = ab = 0a, b: MyNat
h: a + b = a
aa + b = a + 0a, b: MyNat
h: a + b = a
aa + b = a + 0a, b: MyNat
h: a + b = a
aa = a + 0a, b: MyNat
h: a + b = a
aa = a + 0a, b: MyNat
h: a + b = a
aa = a + 0a, b: MyNat
h: a + b = a
aa = aGoals accomplished! 🐙
Remember from FunctionWorld Level 4../FunctonWorld/Level4.lean.md) that the
apply
tactic is can construct the path backwards? Well when we use it with
add_left_cancel a
it results in the opposite of cancellation, it
results in adding a to both sides changing the goal from ⊢ b = 0
to ⊢ a + b = a + 0
. This then allows us to use our hypothesis h : a + b = a
in rw
to complete the proof.
Next up Level 9