Coq 关于在定理中提取的类型类实例的推理?
我真正想要的是:因为我知道Coq 关于在定理中提取的类型类实例的推理?,coq,coq-tactic,Coq,Coq Tactic,我真正想要的是:因为我知道act解析为natListAction,所以我知道act=cons。因此,引理应该通过 如果我的Action类中没有someProof,那么我就可以展开natListAction了。但现在,我不能这样做 但是,在这种情况下,我如何说服coqact=cons?我在另一个SO线程上找到了答案: 用Qed结束Proof部分会使其不透明。相反,用定义的结束证明,证明将通过 为完整起见,以下是最终证明: Class Action (Actor: Type) (Acted: Typ
act
解析为natListAction
,所以我知道act=cons
。因此,引理应该通过
如果我的Action
类中没有someProof
,那么我就可以展开natListAction
了。但现在,我不能这样做
但是,在这种情况下,我如何说服coq
act=cons
?我在另一个SO线程上找到了答案:
用Qed
结束Proof
部分会使其不透明。相反,用定义的结束证明,证明将通过
为完整起见,以下是最终证明:
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.
请注意,自反性
本身就足以证明。啊,很好。因为自反性
简化了事情?正确<代码>自反性
是一种非常复杂的策略。因此,它可以做intros
,其余部分随后是计算,包括展开a.k.a.delta
缩减。从技术上讲,自反性
可以解决这一问题,因为(a)自反性
做intros
,以及(b),术语funl=>eq\u refl
typechecks作为定理的证明。这并不是说自反性
在这里做delta
缩减,而是判断等式是模delta。
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.