2014-08-25 02:58:48 +00:00
|
|
|
import logic
|
2014-10-02 00:51:17 +00:00
|
|
|
open eq.ops eq
|
2014-11-23 01:34:05 +00:00
|
|
|
namespace foo
|
2014-07-26 03:55:05 +00:00
|
|
|
inductive nat : Type :=
|
2014-08-22 22:46:10 +00:00
|
|
|
zero : nat,
|
|
|
|
succ : nat → nat
|
2014-07-26 03:55:05 +00:00
|
|
|
|
2014-09-04 23:36:06 +00:00
|
|
|
namespace nat
|
2014-09-04 22:03:59 +00:00
|
|
|
definition add (x y : nat) : nat := nat.rec x (λn r, succ r) y
|
2014-10-21 22:27:45 +00:00
|
|
|
infixl `+` := add
|
2014-09-04 22:03:59 +00:00
|
|
|
definition mul (n m : nat) := nat.rec zero (fun m x, x + n) m
|
2014-10-21 22:27:45 +00:00
|
|
|
infixl `*` := mul
|
2014-07-26 03:55:05 +00:00
|
|
|
|
|
|
|
axiom add_one (n:nat) : n + (succ zero) = succ n
|
|
|
|
axiom mul_zero_right (n : nat) : n * zero = zero
|
|
|
|
axiom add_zero_right (n : nat) : n + zero = n
|
|
|
|
axiom mul_succ_right (n m : nat) : n * succ m = n * m + n
|
|
|
|
axiom add_assoc (n m k : nat) : (n + m) + k = n + (m + k)
|
|
|
|
axiom add_right_comm (n m k : nat) : n + m + k = n + k + m
|
2014-07-26 17:36:21 +00:00
|
|
|
set_option unifier.max_steps 50000
|
2014-07-26 03:55:05 +00:00
|
|
|
theorem mul_add_distr_left (n m k : nat) : (n + m) * k = n * k + m * k
|
|
|
|
:= induction_on k
|
|
|
|
(calc
|
2014-09-04 23:36:06 +00:00
|
|
|
(n + m) * zero = zero : eq.refl _
|
|
|
|
... = n * zero + m * zero : eq.refl _)
|
2014-07-26 03:55:05 +00:00
|
|
|
(take l IH,
|
|
|
|
calc
|
|
|
|
(n + m) * succ l = (n + m) * l + (n + m) : mul_succ_right _ _
|
|
|
|
... = n * l + m * l + (n + m) : {IH}
|
|
|
|
... = n * l + m * l + n + m : symm (add_assoc _ _ _)
|
|
|
|
... = n * l + n + m * l + m : {add_right_comm _ _ _}
|
|
|
|
... = n * l + n + (m * l + m) : add_assoc _ _ _
|
|
|
|
... = n * succ l + (m * l + m) : {symm (mul_succ_right _ _)}
|
|
|
|
... = n * succ l + m * succ l : {symm (mul_succ_right _ _)})
|
2014-09-04 23:36:06 +00:00
|
|
|
end nat
|
2014-11-23 01:34:05 +00:00
|
|
|
end foo
|