2015-02-05 03:19:46 +00:00
|
|
|
import data.nat
|
|
|
|
open algebra
|
|
|
|
|
|
|
|
constant f {A : Type} : A → A → A
|
|
|
|
|
|
|
|
theorem test1 {A : Type} [s : comm_ring A] (a b c : A) : f (a + 0) (f (a + 0) (a + 0)) = f a (f (0 + a) a) :=
|
|
|
|
begin
|
2015-02-06 18:26:06 +00:00
|
|
|
rewrite [add_zero at {1, 3}, -- rewrite 1st and 3rd occurrences
|
2015-02-05 04:16:24 +00:00
|
|
|
{0 + _}add.comm] -- apply commutativity to (0 + _)
|
2015-02-05 03:19:46 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
check @mul_zero
|
|
|
|
|
|
|
|
axiom Ax {A : Type} [s₁ : has_mul A] [s₂ : has_zero A] (a : A) : f (a * 0) (a * 0) = 0
|
|
|
|
|
2015-05-18 22:45:23 +00:00
|
|
|
theorem test2 {A : Type} [s : comm_ring A] (a b c : A) : f 0 0 = (0:A) :=
|
2015-02-05 03:19:46 +00:00
|
|
|
begin
|
2015-02-05 04:16:24 +00:00
|
|
|
rewrite [
|
2015-02-06 18:26:06 +00:00
|
|
|
-(mul_zero a) at {1, 2}, -- - means apply symmetry, rewrite 0 ==> a * 0 at 1st and 2nd occurrences
|
2015-02-05 04:16:24 +00:00
|
|
|
Ax] -- use Ax as rewrite rule
|
2015-02-05 03:19:46 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
theorem test3 {A : Type} [s : comm_ring A] (a b c : A) : a * 0 + 0 * b + c * 0 + 0 * a = 0 :=
|
|
|
|
begin
|
2015-02-05 04:16:24 +00:00
|
|
|
rewrite [+mul_zero, +zero_mul, +add_zero] -- in rewrite rules, + is notation for one or more
|
2015-02-05 03:19:46 +00:00
|
|
|
end
|
|
|
|
|
2015-05-09 03:54:16 +00:00
|
|
|
reveal test3
|
2015-02-05 03:19:46 +00:00
|
|
|
print definition test3
|
|
|
|
|
|
|
|
theorem test4 {A : Type} [s : comm_ring A] (a b c : A) : a * 0 + 0 * b + c * 0 + 0 * a = 0 :=
|
|
|
|
begin
|
2015-02-05 04:16:24 +00:00
|
|
|
rewrite [*mul_zero, *zero_mul, *add_zero, *zero_add] -- in rewrite rules, * is notation for zero or more
|
2015-02-05 03:19:46 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
theorem test5 {A : Type} [s : comm_ring A] (a b c : A) : a * 0 + 0 * b + c * 0 + 0 * a = 0 :=
|
|
|
|
begin
|
2015-02-05 04:16:24 +00:00
|
|
|
rewrite [
|
|
|
|
2 mul_zero, -- apply mul_zero exactly twice
|
|
|
|
2 zero_mul, -- apply zero_mul exactly twice
|
|
|
|
5>add_zero] -- apply add_zero at most 5 times
|
2015-02-05 03:19:46 +00:00
|
|
|
end
|