Coq: unfolding class instances

送分小仙女□ 提交于 2019-12-10 13:56:59

问题


How do I unfold class instances in Coq? It seems to be possible only when the instance doesn't include a proof, or something. Consider this:

Class C1 (t:Type) := {v1:t}.
Class C2 (t:Type) := {v2:t;c2:v2=v2}.

Instance C1_nat: C1 nat:= {v1:=4}.

Instance C2_nat: C2 nat:= {v2:=4}.
trivial.
Qed.

Theorem thm1 : v1=4.
unfold v1.
unfold C1_nat.
trivial.
Qed.

Theorem thm2 : v2=4.
unfold v2.
unfold C2_nat.
trivial.
Qed.

thm1 is proved, but I can't prove thm2; it complains at the unfold C2_nat step with Error: Cannot coerce C2_nat to an evaluable reference..

What's going on? How do I get to C2_nat's definition of v2?


回答1:


You ended the definition of C2_nat with Qed. Definitions ending with Qed are opaque and cannot be unfolded. Write the following instead

Instance C2_nat: C2 nat:= {v2:=4}.
  trivial.
Defined.

and your proof finishes without problems.



来源:https://stackoverflow.com/questions/24111816/coq-unfolding-class-instances

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!