2014-08-01 16:37:23 +00:00
|
|
|
|
import logic
|
2014-07-25 06:43:40 +00:00
|
|
|
|
using decidable
|
|
|
|
|
|
|
|
|
|
inductive nat : Type :=
|
2014-08-22 22:46:10 +00:00
|
|
|
|
zero : nat,
|
|
|
|
|
succ : nat → nat
|
2014-07-25 06:43:40 +00:00
|
|
|
|
|
|
|
|
|
theorem induction_on {P : nat → Prop} (a : nat) (H1 : P zero) (H2 : ∀ (n : nat) (IH : P n), P (succ n)) : P a
|
|
|
|
|
:= nat_rec H1 H2 a
|
|
|
|
|
|
|
|
|
|
definition pred (n : nat) := nat_rec zero (fun m x, m) n
|
|
|
|
|
theorem pred_zero : pred zero = zero := refl _
|
|
|
|
|
theorem pred_succ (n : nat) : pred (succ n) = n := refl _
|
|
|
|
|
|
|
|
|
|
theorem zero_or_succ (n : nat) : n = zero ∨ n = succ (pred n)
|
|
|
|
|
:= induction_on n
|
|
|
|
|
(or_intro_left _ (refl zero))
|
|
|
|
|
(take m IH, or_intro_right _
|
2014-08-20 22:49:44 +00:00
|
|
|
|
(show succ m = succ (pred (succ m)), from congr_arg succ (symm (pred_succ m))))
|
2014-07-25 06:43:40 +00:00
|
|
|
|
|
|
|
|
|
theorem zero_or_succ2 (n : nat) : n = zero ∨ n = succ (pred n)
|
|
|
|
|
:= @induction_on _ n
|
|
|
|
|
(or_intro_left _ (refl zero))
|
|
|
|
|
(take m IH, or_intro_right _
|
2014-08-20 22:49:44 +00:00
|
|
|
|
(show succ m = succ (pred (succ m)), from congr_arg succ (symm (pred_succ m))))
|