【发布时间】:2021-03-31 03:31:43
【问题描述】:
考虑以下 Coq 程序:
Inductive foo : nat -> Type :=
| nil : foo 0
| succ{n:nat} : foo n -> foo n.
Fixpoint bar {n:nat}(A:foo n)(B:foo n) : Prop :=
match B with
| nil => False
| succ C => bar A C
end.
Coq 抱怨bar 的定义:
In environment
bar : forall n : nat, foo n -> foo n -> Prop
n : nat
A : foo n
B : foo n
n0 : nat
C : foo n0
The term "C" has type "foo n0" while it is expected to have type "foo n".
但要使B : foo n 成为succ C,C 也必须是foo n。为什么 Coq 不能推断这一点,我该如何修复 bar 的定义?
【问题讨论】: