如何在Coq中展开类实例?似乎只有在实例不包含证明或其他内容时才有可能.考虑一下:
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.
Run Code Online (Sandbox Code Playgroud)
thm1证明了,但我无法证明thm2; 它在unfold C2_nat步骤中抱怨Error: Cannot coerce C2_nat to an evaluable reference..
这是怎么回事?我如何得到C2_nat定义v2?
你结束了C2_natwith 的定义Qed.以[ Qedopaque] 结尾的定义无法展开.写下以下内容
Instance C2_nat: C2 nat:= {v2:=4}.
trivial.
Defined.
Run Code Online (Sandbox Code Playgroud)
并且你的证明没有问题.
| 归档时间: |
|
| 查看次数: |
592 次 |
| 最近记录: |