import MyNat.Definition
import MyNat.Addition
import AdvancedAdditionWorld.Level1 -- succ_inj
namespace MyNat
open MyNat
Advanced Addition World
Level 2: succ_succ_inj
In the below theorem, we need to apply succ_inj
twice. Once to prove
succ (succ a) = succ (succ b) ⟹ succ a = succ b
, and then again to prove succ a = succ b ⟹ a = b
.
However succ a = succ b
is nowhere to be found, it's neither an assumption or a goal when we start
this level. You can make it with have
or you can use apply
.
Theorem : succ_succ_inj
For all naturals a
and b
, if we assume succ (succ a) = succ (succ b)
, then we can
deduce a = b
.
theoremsucc_succ_inj {succ_succ_inj: ∀ {a b : MyNat}, succ (succ a) = succ (succ b) → a = baa: MyNatb :b: MyNatMyNat} (MyNat: Typeh :h: succ (succ a) = succ (succ b)succ (succ: MyNat → MyNatsuccsucc: MyNat → MyNata) =a: MyNatsucc (succ: MyNat → MyNatsuccsucc: MyNat → MyNatb)) :b: MyNata =a: MyNatb :=b: MyNata, b: MyNat
h: succ (succ a) = succ (succ b)a = ba, b: MyNat
h: succ (succ a) = succ (succ b)
asucc a = succ ba, b: MyNat
h: succ (succ a) = succ (succ b)
a.asucc (succ a) = succ (succ b)Goals accomplished! 🐙
Other solutions
Make sure you understand them all. And remember that rw
should not be used
with succ_inj
-- rw
works only with equalities or ↔
statements,
not implications or functions.
example {example: ∀ {a b : MyNat}, succ (succ a) = succ (succ b) → a = baa: MyNatb :b: MyNatMyNat} (MyNat: Typeh :h: succ (succ a) = succ (succ b)succ (succ: MyNat → MyNatsuccsucc: MyNat → MyNata) =a: MyNatsucc (succ: MyNat → MyNatsuccsucc: MyNat → MyNatb)) :b: MyNata =a: MyNatb :=b: MyNata, b: MyNat
h: succ (succ a) = succ (succ b)a = ba, b: MyNat
h: succ (succ a) = succ (succ b)
asucc a = succ bGoals accomplished! 🐙example {example: ∀ {a b : MyNat}, succ (succ a) = succ (succ b) → a = baa: MyNatb :b: MyNatMyNat} (MyNat: Typeh :h: succ (succ a) = succ (succ b)succ (succ: MyNat → MyNatsuccsucc: MyNat → MyNata) =a: MyNatsucc (succ: MyNat → MyNatsuccsucc: MyNat → MyNatb)) :b: MyNata =a: MyNatb :=b: MyNata, b: MyNat
h: succ (succ a) = succ (succ b)a = bGoals accomplished! 🐙
Next up Level 3