我试图在Pierce的“软件基础”中运用一些关于ng-style="{width: widthArray[$index]}"
策略的简单例子。
似乎书中的例子对我不起作用:
apply ... with ...
Theorem trans_eq: forall (X: Type) (n m o: Type),
n = m -> m = o -> n = o.
Proof.
intros X n m o eq1 eq2. rewrite -> eq1. rewrite -> eq2. reflexivity.
Qed.
Example trans_eq_example' : forall (a b c d e f : nat),
[a;b] = [c;d] ->
[c;d] = [e;f] ->
[a;b] = [e;f].
Proof.
intros a b c d e f eq1 eq2.
(* If we simply tell Coq apply trans_eq at this point,
it can tell (by matching the goal against the
conclusion of the lemma) that it should instantiate X
with [nat], n with [a,b], and o with [e,f].
However, the matching process doesn't determine an
instantiation for m: we have to supply one explicitly
by adding with (m:=[c,d]) to the invocation of
apply. *)
apply trans_eq with (m:=[c;d]). apply eq1. apply eq2. Qed.
因错误而失败:
trans_eq_example'
有关Coq版本的其他信息:
trans_eq_example' < apply trans_eq with (m:=[c;d]).
Toplevel input, characters 6-30:
> apply trans_eq with (m:=[c;d]).
> ^^^^^^^^^^^^^^^^^^^^^^^^
Error: Impossible to unify "?1707 = ?1709" with "[a; b] = [e; f]".
如何解决此错误?
答案 0 :(得分:3)
问题不是apply
,而是您之前代码中的拼写错误。 trans_eq
的定义应为:
Theorem trans_eq: forall (X:Type) (n m o: X), n = m -> m = o -> n = o.
请注意,n m o
的类型应为X
,而不是Type
。