导出coq中记录的管状结构(ssreflect)
鉴于以下假设:导出coq中记录的管状结构(ssreflect),coq,ssreflect,Coq,Ssreflect,鉴于以下假设: Variable A : finType. Variable B : finType. Variable C : finType. 以及定义为以下内容的记录: Record example := Example { example_A : A; example_B : B; example_C : C; }. 直观地看,这个例子似乎也必须是finType 查看其他代码库,我看到人们使用表单的构造为只有一个非证明项的记录派生finTyp
Variable A : finType.
Variable B : finType.
Variable C : finType.
以及定义为以下内容的记录:
Record example := Example {
example_A : A;
example_B : B;
example_C : C;
}.
直观地看,这个例子似乎也必须是finType
查看其他代码库,我看到人们使用表单的构造为只有一个非证明项的记录派生finType
Definition <record>_subType := Eval hnf in [subtype for <record-accessor>].
Definition <record>_finMixin := Eval hnf in [finMixin of <record> by <:].
Definition\u subType:=Eval hnf in[subType for]。
定义_finMixin:=Eval hnf in[finMixin of by数学组件中的许多接口实现可以通过显示您的类型是实现该接口的其他类型的缩回来派生。在您的示例中,我们只需将记录转换为元组
From mathcomp Require Import
ssreflect ssrfun ssrbool ssrnat eqtype seq choice fintype.
Variables A B C : finType.
Record example := Example {
example_A : A;
example_B : B;
example_C : C
}.
Definition prod_of_example e :=
let: Example a b c := e in (a, b, c).
Definition example_of_prod p :=
let: (a, b, c) := p in Example a b c.
Lemma prod_of_exampleK : cancel prod_of_example example_of_prod.
Proof. by case. Qed.
Definition example_eqMixin :=
CanEqMixin prod_of_exampleK.
Canonical example_eqType :=
Eval hnf in EqType example example_eqMixin.
Definition example_choiceMixin :=
CanChoiceMixin prod_of_exampleK.
Canonical example_choiceType :=
Eval hnf in ChoiceType example example_choiceMixin.
Definition example_countMixin :=
CanCountMixin prod_of_exampleK.
Canonical example_countType :=
Eval hnf in CountType example example_countMixin.
Definition example_finMixin :=
CanFinMixin prod_of_exampleK.
Canonical example_finType :=
Eval hnf in FinType example example_finMixin.
在这段代码的末尾,示例
被声明为finType
(请注意,eqType
、choiceType
等的所有其他声明也是必需的,因为finType
是这些声明的一个子类。)