2014-01-05 20:05:08 +00:00
|
|
|
import cast.
|
|
|
|
import Int.
|
2013-12-24 06:04:19 +00:00
|
|
|
|
2014-01-05 20:05:08 +00:00
|
|
|
variable vector : Type -> Nat -> Type
|
|
|
|
axiom N0 (n : Nat) : n + 0 = n
|
|
|
|
theorem V0 (T : Type) (n : Nat) : (vector T (n + 0)) = (vector T n) :=
|
2013-09-07 01:31:47 +00:00
|
|
|
Congr (Refl (vector T)) (N0 n)
|
2014-01-05 20:05:08 +00:00
|
|
|
variable f (n : Nat) (v : vector Int n) : Int
|
|
|
|
variable m : Nat
|
|
|
|
variable v1 : vector Int (m + 0)
|
2014-01-05 16:52:46 +00:00
|
|
|
-- The following application will fail because (vector Int (m + 0)) and (vector Int m)
|
|
|
|
-- are not definitionally equal.
|
2014-01-05 20:05:08 +00:00
|
|
|
check f m v1
|
2014-01-05 16:52:46 +00:00
|
|
|
-- The next one succeeds using the "casting" operator.
|
|
|
|
-- We can do it, because (V0 Int m) is a proof that
|
|
|
|
-- (vector Int (m + 0)) and (vector Int m) are propositionally equal.
|
|
|
|
-- That is, they have the same interpretation in the lean set theoretic
|
|
|
|
-- semantics.
|
2014-01-05 20:05:08 +00:00
|
|
|
check f m (cast (V0 Int m) v1)
|