import MyNat.Definition
import AdditionWorld.Level4 -- add_comm
import AdvancedAdditionWorld.Level5 -- add_right_cancel
namespace MyNat
open MyNat
Advanced Addition World
Level 7: add_right_cancel_iff
It's sometimes convenient to have the "if and only if" version
of theorems like add_right_cancel
. Remember that you can use constructor
to split an ↔
goal into the →
goal and the ←
goal.
Pro tip:
Notice exact add_right_cancel _ _ _
means "let Lean figure out the missing inputs"
so we don't have to spell it out like we did in Level 6.
Theorem
For all naturals a
, b
and t
, a + t = b + t ↔ a = b.
theoremadd_right_cancel_iff (add_right_cancel_iff: ∀ (t a b : MyNat), a + t = b + t ↔ a = btt: MyNataa: MyNatb :b: MyNatMyNat) :MyNat: Typea +a: MyNatt =t: MyNatb +b: MyNatt ↔t: MyNata =a: MyNatb :=b: MyNatt, a, b: MyNata + t = b + t ↔ a = bt, a, b: MyNat
mpa + t = b + t → a = bt, a, b: MyNata = b → a + t = b + tt, a, b: MyNat
mpra = b → a + t = b + tt, a, b: MyNat
h: a = b
mpra + t = b + tt, a, b: MyNat
h: a = b
mpra + t = b + tt, a, b: MyNat
h: a = b
mprb + t = b + tGoals accomplished! 🐙
Next up Level 8