2015-02-05 22:09:07 +00:00
|
|
|
|
import data.nat
|
2015-10-14 19:27:09 +00:00
|
|
|
|
open nat algebra
|
2015-02-05 22:09:07 +00:00
|
|
|
|
|
|
|
|
|
section
|
|
|
|
|
variables (a b c d e : nat)
|
|
|
|
|
|
|
|
|
|
theorem T (H1 : a = b) (H2 : b = c + 1) (H3 : c = d) (H4 : e = 1 + d) : a = e :=
|
2015-03-28 00:26:06 +00:00
|
|
|
|
by rewrite [H1, H2, H3, add.comm, -H4]
|
2015-02-05 22:09:07 +00:00
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
example (x y : ℕ) : (x + y) * (x + y) = x * x + y * x + x * y + y * y :=
|
2015-10-14 19:27:09 +00:00
|
|
|
|
by rewrite [*left_distrib, *right_distrib, -add.assoc]
|
2015-02-05 22:09:07 +00:00
|
|
|
|
|
2015-07-06 22:05:01 +00:00
|
|
|
|
namespace tst
|
2015-02-05 22:09:07 +00:00
|
|
|
|
definition even (a : nat) := ∃b, a = 2*b
|
|
|
|
|
|
|
|
|
|
theorem even_plus_even {a b : nat} (H1 : even a) (H2 : even b) : even (a + b) :=
|
|
|
|
|
exists.elim H1 (fun (w1 : nat) (Hw1 : a = 2*w1),
|
|
|
|
|
exists.elim H2 (fun (w2 : nat) (Hw2 : b = 2*w2),
|
|
|
|
|
exists.intro (w1 + w2)
|
|
|
|
|
begin
|
2015-10-14 19:27:09 +00:00
|
|
|
|
rewrite [Hw1, Hw2, left_distrib]
|
2015-02-05 22:09:07 +00:00
|
|
|
|
end))
|
|
|
|
|
|
|
|
|
|
theorem T2 (a b c : nat) (H1 : a = b) (H2 : b = c + 1) : a ≠ 0 :=
|
|
|
|
|
calc
|
2015-03-28 00:26:06 +00:00
|
|
|
|
a = succ c : by rewrite [H1, H2, add_one]
|
2015-02-05 22:09:07 +00:00
|
|
|
|
... ≠ 0 : succ_ne_zero c
|
2015-07-06 22:05:01 +00:00
|
|
|
|
|
|
|
|
|
end tst
|