2014-10-27 01:23:30 +00:00
|
|
|
import logic data.nat.basic
|
|
|
|
open nat
|
|
|
|
|
|
|
|
inductive vector (A : Type) : nat → Type :=
|
2015-02-26 01:00:10 +00:00
|
|
|
| vnil : vector A zero
|
|
|
|
| vcons : Π {n : nat}, A → vector A n → vector A (succ n)
|
2014-10-27 01:23:30 +00:00
|
|
|
|
|
|
|
namespace vector
|
2015-02-11 20:49:27 +00:00
|
|
|
definition no_confusion2 {A : Type} {n : nat} {P : Type} {v₁ v₂ : vector A n} : v₁ = v₂ → vector.no_confusion_type P v₁ v₂ :=
|
2014-10-27 01:23:30 +00:00
|
|
|
assume H₁₂ : v₁ = v₂,
|
|
|
|
begin
|
2015-02-11 20:49:27 +00:00
|
|
|
show vector.no_confusion_type P v₁ v₂, from
|
|
|
|
have aux : v₁ = v₁ → vector.no_confusion_type P v₁ v₁, from
|
2014-10-27 01:23:30 +00:00
|
|
|
take H₁₁,
|
|
|
|
begin
|
2015-02-11 20:49:27 +00:00
|
|
|
apply (vector.cases_on v₁),
|
2014-10-27 01:23:30 +00:00
|
|
|
exact (assume h : P, h),
|
|
|
|
|
|
|
|
intros (n, a, v, h),
|
|
|
|
apply (h rfl),
|
2014-11-08 23:20:19 +00:00
|
|
|
repeat (apply rfl),
|
|
|
|
repeat (apply heq.refl)
|
2014-10-27 01:23:30 +00:00
|
|
|
end,
|
|
|
|
eq.rec_on H₁₂ aux H₁₂
|
|
|
|
end
|
|
|
|
|
|
|
|
theorem vcons.inj₁ {A : Type} {n : nat} (a₁ a₂ : A) (v₁ v₂ : vector A n) : vcons a₁ v₁ = vcons a₂ v₂ → a₁ = a₂ :=
|
|
|
|
begin
|
2015-02-11 20:49:27 +00:00
|
|
|
intro h, apply (vector.no_confusion h), intros, assumption
|
2014-10-27 01:23:30 +00:00
|
|
|
end
|
|
|
|
|
2014-11-08 23:20:19 +00:00
|
|
|
theorem vcons.inj₂ {A : Type} {n : nat} (a₁ a₂ : A) (v₁ v₂ : vector A n) : vcons a₁ v₁ = vcons a₂ v₂ → v₁ == v₂ :=
|
2014-10-27 01:23:30 +00:00
|
|
|
begin
|
2015-02-11 20:49:27 +00:00
|
|
|
intro h, apply (vector.no_confusion h), intros, eassumption
|
2014-10-27 01:23:30 +00:00
|
|
|
end
|
|
|
|
end vector
|