2015-01-03 07:18:35 +00:00
|
|
|
open nat
|
|
|
|
|
|
|
|
inductive vector (A : Type) : nat → Type :=
|
|
|
|
nil {} : vector A zero,
|
|
|
|
cons : Π {n}, A → vector A n → vector A (succ n)
|
|
|
|
|
|
|
|
infixr `::` := vector.cons
|
|
|
|
|
2015-02-26 00:20:44 +00:00
|
|
|
definition swap {A : Type} : Π {n}, vector A (succ (succ n)) → vector A (succ (succ n))
|
|
|
|
| swap (a :: b :: vs) := b :: a :: vs
|
2015-01-03 07:18:35 +00:00
|
|
|
|
|
|
|
-- Remark: in the current approach for HoTT, the equation
|
|
|
|
-- swap (a :: b :: v) = b :: a :: v
|
|
|
|
-- holds definitionally only when the index is a closed term.
|
|
|
|
example (a b : num) (v : vector num 5) : swap (a :: b :: v) = b :: a :: v :=
|
|
|
|
rfl
|