Coq 从ssreflect finset中提取/使用成员资格证明

Coq 从ssreflect finset中提取/使用成员资格证明,coq,ssreflect,Coq,Ssreflect,编辑:我引入了一种结构,通过将所述元素的成员资格证明带到集合中来扩充元素,从而使示例变得更简单: Structure elem_and_in_proof {T : finType} (s : {set T}) := {el :> T ; Helin : el \in s}. Canonical eip_subType {T : finType} (s : {set T}) := Eval hnf in [subType for (@el T s)]. Canonical eip_eqTy

编辑:我引入了一种结构,通过将所述元素的成员资格证明带到集合中来扩充元素,从而使示例变得更简单:

Structure elem_and_in_proof {T : finType} (s : {set T}) := {el :> T ; Helin : el \in s}.

Canonical eip_subType {T : finType} (s : {set T}) := Eval hnf in [subType for (@el T s)].
Canonical eip_eqType {T : finType} (s : {set T}) := Eval hnf in EqType _ [eqMixin of (elem_and_in_proof s) by <:].
Canonical eip_choiceType {T : finType} (s : {set T}) := Eval hnf in ChoiceType _ [choiceMixin of (elem_and_in_proof s) by <:].
Canonical eip_countType {T : finType} (s : {set T}) := Eval hnf in CountType _ [countMixin of (elem_and_in_proof s) by <:].
Canonical eip_subCountType {T : finType} (s : {set T}) := Eval hnf in [subCountType of (elem_and_in_proof s)].
Canonical eip_finType {T : finType} (s : {set T}) := Eval hnf in FinType _ [finMixin of (elem_and_in_proof s) by <:].
由于使用_Helin装备_set_可以让我编写uniq_cons函数,因此非常感谢对此或原始问题的任何帮助。谢谢


我有一个由有限型ft上的一个序列组成的dbranch型,以及这个序列的uniq的证明。我希望能够,给定类型为ft的元素t和dbranch上的finset返回相同的集合,其中所有dbranch都被t“cons-ed”

我需要为分支编写一个cons函数,将给定元素不是分支的一部分这一假设作为参数。我不知道如何把它作为一个普通函数来写,所以我把它作为一个证明

然后我写了uniq_cons,它试图将dcon提升到一组数据库。但是,它的参数H的应用需要证明t中的b\n(这是我代码中的占位符)

来自mathcomp的

需要导入ssreflect ssrbool ssrfun eqtype ssrnat seq choice fintype。
来自mathcomp
需要导入元组finfun bigop finset。
变量ft:finType。
结构dbranch:={branch:>seq ft;buniq:uniq branch}。
规范dbranch_子类型:=Eval hnf in[分支的子类型]。

规范dbranch_eqType:=eqType中的Eval hnf[eqMixin of dbranch by要回答您的修订问题,您可以这样做:

From mathcomp
Require Import ssreflect ssrbool ssrfun eqtype ssrnat seq choice fintype finset.

Definition equip (T : finType) (A : {set T}) : {set {x : T | x \in A}} :=
  [set x in pmap insub (enum A)].
序列
enum A
枚举集合
A
的所有元素。
insub:T->option sT
函数将元素
x:T
强制为
T
的子类型
sT:subtype p
,前提是谓词
p
包含
x
。假设
enum A的所有元素ode>位于
A
中,根据定义,此函数的行为与
某些
相同。最后,
pmap
将部分函数映射到序列上,丢弃所有
结果

From mathcomp
Require Import ssreflect ssrbool ssrfun eqtype ssrnat seq choice fintype.
From mathcomp
Require Import tuple finfun bigop finset.

Variable ft : finType.

Structure dbranch := {branch :> seq ft ; buniq : uniq branch}.

Canonical dbranch_subType := Eval hnf in [subType for branch].
Canonical dbranch_eqType := Eval hnf in EqType _ [eqMixin of dbranch by <:].
Canonical dbranch_choiceType := Eval hnf in ChoiceType _ [choiceMixin of dbranch by <:].
Canonical dbranch_countType := Eval hnf in CountType _ [countMixin of dbranch by <:].
Canonical dbranch_subCountType := Eval hnf in [subCountType of dbranch].
Lemma dbranchFin : Finite.mixin_of [eqType of dbranch].
Admitted. 
Canonical dbranch_finType := Eval hnf in FinType _ dbranchFin.

Definition dcons (t : ft) (b : dbranch) (H : t \notin (branch b)) : dbranch.
Proof.
exists (t :: b) ; apply/andP ; split.
  - apply H.
  - apply (buniq b).
Qed.  

Definition uniq_cons (al : ft) (t : {set dbranch}) (H : forall b, (b \in t -> al \notin (branch b))) := 
  [set (dcons al b (H b _)) | b in t].
From mathcomp
Require Import ssreflect ssrbool ssrfun eqtype ssrnat seq choice fintype finset.

Definition equip (T : finType) (A : {set T}) : {set {x : T | x \in A}} :=
  [set x in pmap insub (enum A)].