我正在尝试使用“护航模式”来保留 3 个变量(两个参数和返回值)之间的依赖关系:
Require Import Vector.
(* "sparse" vector type *)
Notation svector A n := (Vector.t (option A) n).
Fixpoint svector_is_dense {A} {n} (v:svector A n) : Prop :=
match v with
| Vector.nil => True
| Vector.cons (None) _ _ => False
| Vector.cons (Some _) _ xs => svector_is_dense xs
end.
Lemma svector_tl_dense {A} {n} {v: svector A (S n)}:
svector_is_dense v -> svector_is_dense (Vector.tl v).
Admitted.
Lemma svector_hd {A} {n} (v:svector A (S n)): svector_is_dense v -> A.
Admitted.
Fixpoint vector_from_svector {A} {n} {v:svector A n} (D:svector_is_dense v): Vector.t A n :=
match n return (svector A n) -> (svector_is_dense v) -> (Vector.t A n) with
| O => fun _ _ => @Vector.nil A
| (S p) => fun v0 D0 => Vector.cons
(svector_hd v0 D0)
(vector_from_svector (Vector.tl v) (svector_tl_dense D))
end v D.
问题出现在最后一个定义中。有什么建议为什么它不起作用?