Class Action (Actor: Type) (Acted: Type) :=
{
act : Actor -> Acted -> Acted;
someProof: forall (a: Actor), a = a;
}.
Instance natListAction: Action nat (list nat) :=
{
act (n: nat) (l: list nat) := cons n l;
}.
Proof.
auto.
Qed.
Lemma natListAction_is_cons: forall (n: nat) (l: list nat),
act n l = cons n l.
Proof.
intros.
unfold act.
(** I cannot unfold it, since I have someProof.
If I remove this, this unfold works **)
unfold natListAction.
Abort.
我真正想要的是:因为我知道act
解析为natListAction
,我知道act = cons
。因此,引理应该通过。
如果我的someProof
课程中没有Action
,那么我可以unfold natListAction
并且其工作正常。但现在,我无法这样做。
但是,如何在这种情况下说服act = cons
的coq?
答案 0 :(得分:0)
我在另一个SO帖子上找到答案:Coq: unfolding typeclass instances。
使用Proof
结束Qed
部分会使其不透明。相反,用Defined
结束证明,它将通过。
为了完整起见,这是最后的证明:
Class Action (Actor: Type) (Acted: Type) :=
{
act : Actor -> Acted -> Acted;
someProof: forall (a: Actor), a = a;
}.
Instance natListAction: Action nat (list nat) :=
{
act (n: nat) (l: list nat) := cons n l;
}.
Proof.
auto.
(** vvv Notice the change! this is now "Defined" vvv **)
Defined.
Lemma natListAction_is_cons: forall (n: nat) (l: list nat),
act n l = cons n l.
Proof.
intros.
unfold act.
unfold natListAction.
reflexivity.
Qed.