2015-05-02 20:01:37 +00:00
|
|
|
|
open nat
|
|
|
|
|
|
|
|
|
|
inductive vector (A : Type) : nat → Type :=
|
|
|
|
|
| nil {} : vector A zero
|
|
|
|
|
| cons : Π {n}, A → vector A n → vector A (succ n)
|
|
|
|
|
|
|
|
|
|
open vector
|
|
|
|
|
notation a :: b := cons a b
|
|
|
|
|
notation `[` l:(foldr `,` (h t, cons h t) nil `]`) := l
|
|
|
|
|
|
2015-05-01 19:45:21 +00:00
|
|
|
|
|
|
|
|
|
example (a b : nat) : succ a = succ b → a + 2 = b + 2 :=
|
|
|
|
|
begin
|
|
|
|
|
intro H,
|
2015-12-09 05:11:11 +00:00
|
|
|
|
injection H with p,
|
|
|
|
|
rewrite p
|
2015-05-01 19:45:21 +00:00
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
example (A : Type) (n : nat) (v w : vector A n) (a : A) (b : A) :
|
|
|
|
|
a :: v = b :: w → b = a :=
|
|
|
|
|
begin
|
2015-05-02 20:01:37 +00:00
|
|
|
|
intro H, injection H with neqn aeqb beqw,
|
2015-05-01 19:45:21 +00:00
|
|
|
|
rewrite aeqb
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
open prod
|
|
|
|
|
|
|
|
|
|
example (A : Type) (a₁ a₂ a₃ b₁ b₂ b₃ : A) : (a₁, a₂, a₃) = (b₁, b₂, b₃) → b₁ = a₁ :=
|
|
|
|
|
begin
|
2015-05-01 22:47:15 +00:00
|
|
|
|
intro H, injection H with a₁b₁ a₂b₂ a₃b₃,
|
2015-05-01 19:45:21 +00:00
|
|
|
|
rewrite a₁b₁
|
|
|
|
|
end
|
2015-05-01 22:47:15 +00:00
|
|
|
|
|
|
|
|
|
example (a₁ a₂ a₃ b₁ b₂ b₃ : nat) : (a₁+2, a₂+3, a₃+1) = (b₁+2, b₂+2, b₃+2) → b₁ = a₁ × a₃ = b₃+1 :=
|
|
|
|
|
begin
|
|
|
|
|
intro H, injection H with a₁b₁ sa₂b₂ a₃sb₃,
|
|
|
|
|
esimp at *,
|
|
|
|
|
rewrite [a₁b₁, a₃sb₃], split,
|
|
|
|
|
repeat trivial
|
|
|
|
|
end
|