[英]Software Foundations: apply … with … tactic
我嘗試apply ... with ...
Pierce的“軟件基礎”中的策略在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'
失敗,並出現以下錯誤:
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]".
有關Coq版本的其他信息:
coqtop -v
The Coq Proof Assistant, version 8.4pl4 (July 2014)
compiled on Jul 27 2014 23:12:44 with OCaml 4.01.0
如何解決此錯誤?
問題不是apply
而是您先前代碼中的錯字。 trans_eq
的定義應為:
Theorem trans_eq: forall (X:Type) (n m o: X), n = m -> m = o -> n = o.
請注意, nmo
的類型應為X
,而不是Type
。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.