Coq:为什么我需要手动展开一个值,即使它上面有“提示展开”呢?

Coq:为什么我需要手动展开一个值,即使它上面有“提示展开”呢?,coq,coq-tactic,Coq,Coq Tactic,我想出了以下玩具证明脚本: Inductive myType : Type := | c : unit -> myType. Inductive myProp : myType -> Type := | d : forall t, myProp (c t). Hint Constructors myProp. Definition myValue : myType := c tt. Hint Unfold myValue. Example test: myProp myValu

我想出了以下玩具证明脚本:

Inductive myType : Type :=
| c : unit -> myType.

Inductive myProp : myType -> Type :=
| d : forall t, myProp (c t).
Hint Constructors myProp.

Definition myValue : myType := c tt.
Hint Unfold myValue.

Example test: myProp myValue.
Proof.
  auto 1000. (* does nothing *)
  unfold myValue.
  trivial.
Qed.
为什么需要在此处手动展开
myValue
?提示不够吗?

那是因为(请参阅)

此[
Hint Unfold
]将策略
Unfold qualid
添加到提示列表中,该列表仅在目标的head常量为ident时使用

目标
myProp myValue
在头部位置有
myProp
,而不是
myValue

有几种处理方法:

Hint Extern 4 => constructor.   (* change 4 with a cost of your choice *)

甚至

Hint Extern 1 =>
  match goal with
  | [ |- context [myValue]] => unfold myValue
  end.

@安东特鲁诺夫关于为什么不在这里使用的解释是正确的。还有一种替代方法,可以使应用程序对某些特定常数按模增量工作。它似乎还不受和的支持,但受的支持如下所示:

Inductive myType : Type :=
| c : unit -> myType.

Inductive myProp : myType -> Type :=
| d : forall t, myProp (c t).
Hint Constructors myProp.

Definition myValue : myType := c tt.
Hint Transparent myValue.

Example test: myProp myValue.
Proof.
  eauto.
Qed.
Inductive myType : Type :=
| c : unit -> myType.

Inductive myProp : myType -> Type :=
| d : forall t, myProp (c t).
Hint Constructors myProp.

Definition myValue : myType := c tt.
Hint Transparent myValue.

Example test: myProp myValue.
Proof.
  eauto.
Qed.