2014-07-04 17:10:05 +00:00
|
|
|
import standard
|
|
|
|
using num (num pos_num num_rec pos_num_rec)
|
|
|
|
using tactic
|
|
|
|
|
|
|
|
inductive nat : Type :=
|
2014-08-22 22:46:10 +00:00
|
|
|
zero : nat,
|
|
|
|
succ : nat → nat
|
2014-07-04 17:10:05 +00:00
|
|
|
|
|
|
|
definition add [inline] (a b : nat) : nat
|
|
|
|
:= nat_rec a (λ n r, succ r) b
|
|
|
|
infixl `+`:65 := add
|
|
|
|
|
|
|
|
definition one [inline] := succ zero
|
|
|
|
|
|
|
|
-- Define coercion from num -> nat
|
|
|
|
-- By default the parser converts numerals into a binary representation num
|
|
|
|
definition pos_num_to_nat [inline] (n : pos_num) : nat
|
|
|
|
:= pos_num_rec one (λ n r, r + r) (λ n r, r + r + one) n
|
|
|
|
definition num_to_nat [inline] (n : num) : nat
|
|
|
|
:= num_rec zero (λ n, pos_num_to_nat n) n
|
|
|
|
coercion num_to_nat
|
|
|
|
|
|
|
|
-- Now we can write 2 + 3, the coercion will be applied
|
|
|
|
check 2 + 3
|
|
|
|
|
|
|
|
-- Define an assump as an alias for the eassumption tactic
|
|
|
|
definition assump : tactic := eassumption
|
|
|
|
|
2014-07-22 16:43:18 +00:00
|
|
|
theorem T1 {p : nat → Prop} {a : nat } (H : p (a+2)) : ∃ x, p (succ x)
|
2014-07-04 17:10:05 +00:00
|
|
|
:= by apply exists_intro; assump
|
2014-07-04 17:32:01 +00:00
|
|
|
|
2014-07-05 07:43:10 +00:00
|
|
|
definition is_zero (n : nat)
|
2014-07-04 17:32:01 +00:00
|
|
|
:= nat_rec true (λ n r, false) n
|
|
|
|
|
2014-07-05 22:52:40 +00:00
|
|
|
theorem T2 : ∃ a, (is_zero a) = true
|
|
|
|
:= by apply exists_intro; apply refl
|