2014-01-08 08:38:39 +00:00
|
|
|
import macros -- loads the λ, λ, obtain macros
|
2014-01-07 18:18:31 +00:00
|
|
|
|
|
|
|
using Nat -- using the Nat namespace (it allows us to suppress the Nat:: prefix)
|
|
|
|
|
2014-01-08 08:38:39 +00:00
|
|
|
axiom Induction : ∀ P : Nat → Bool, P 0 → (∀ n, P n → P (n + 1)) → ∀ n, P n.
|
2014-01-07 18:18:31 +00:00
|
|
|
|
|
|
|
-- induction on n
|
|
|
|
|
|
|
|
theorem Comm1 : ∀ n m, n + m = m + n
|
|
|
|
:= Induction
|
2014-01-08 08:38:39 +00:00
|
|
|
_ -- I use a placeholder because I do not want to write the P
|
|
|
|
(λ m, -- Base case
|
2014-01-09 16:33:52 +00:00
|
|
|
calc 0 + m = m : add_zerol m
|
|
|
|
... = m + 0 : symm (add_zeror m))
|
2014-01-08 08:38:39 +00:00
|
|
|
(λ n, -- Inductive case
|
|
|
|
λ (iH : ∀ m, n + m = m + n),
|
|
|
|
λ m,
|
2014-01-09 16:33:52 +00:00
|
|
|
calc n + 1 + m = (n + m) + 1 : add_succl n m
|
2014-01-08 08:38:39 +00:00
|
|
|
... = (m + n) + 1 : { iH m }
|
2014-01-09 16:33:52 +00:00
|
|
|
... = m + (n + 1) : symm (add_succr m n))
|
2014-01-07 18:18:31 +00:00
|
|
|
|
|
|
|
-- indunction on m
|
|
|
|
|
|
|
|
theorem Comm2 : ∀ n m, n + m = m + n
|
2014-01-08 08:38:39 +00:00
|
|
|
:= λ n,
|
2014-01-07 18:18:31 +00:00
|
|
|
Induction
|
2014-01-08 08:38:39 +00:00
|
|
|
_
|
2014-01-09 16:33:52 +00:00
|
|
|
(calc n + 0 = n : add_zeror n
|
|
|
|
... = 0 + n : symm (add_zerol n))
|
2014-01-08 08:38:39 +00:00
|
|
|
(λ m,
|
|
|
|
λ (iH : n + m = m + n),
|
2014-01-09 16:33:52 +00:00
|
|
|
calc n + (m + 1) = (n + m) + 1 : add_succr n m
|
2014-01-07 18:18:31 +00:00
|
|
|
... = (m + n) + 1 : { iH }
|
2014-01-09 16:33:52 +00:00
|
|
|
... = (m + 1) + n : symm (add_succl m n))
|
2014-01-07 18:18:31 +00:00
|
|
|
|
|
|
|
|
|
|
|
print environment 1
|