2015-02-05 22:09:07 +00:00
|
|
|
|
import data.nat
|
|
|
|
|
open nat
|
|
|
|
|
|
|
|
|
|
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-03-28 00:26:06 +00:00
|
|
|
|
by rewrite [*mul.left_distrib, *mul.right_distrib, -add.assoc]
|
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-03-28 00:26:06 +00:00
|
|
|
|
rewrite [Hw1, Hw2, mul.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
|