Coq 从带有uniq的finType上的seq派生ssreflect finType

Coq 从带有uniq的finType上的seq派生ssreflect finType,coq,ssreflect,Coq,Ssreflect,我有一个由有限类型上的序列组成的结构,以及这个序列的uniq的证明。这应该描述一个显然是有限的类型,但我不知道如何显示它 我想我可以使用UniqFinMixin,但是它需要——如果我理解正确的话——提供该类型所有元素的显式seq,我不知道如何计算。我尝试在有限类型上使用Finite.enum,但它只生成一个包含有限类型所有元素的seq,并且我没有找到一种计算所有子序列/置换的优雅方法 From mathcomp Require Import ssreflect ssrbool ssrfun eq

我有一个由有限类型上的序列组成的结构,以及这个序列的uniq的证明。这应该描述一个显然是有限的类型,但我不知道如何显示它

我想我可以使用UniqFinMixin,但是它需要——如果我理解正确的话——提供该类型所有元素的显式seq,我不知道如何计算。我尝试在有限类型上使用Finite.enum,但它只生成一个包含有限类型所有元素的seq,并且我没有找到一种计算所有子序列/置换的优雅方法

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.
来自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您可以显示,
dbranch
嵌入到另一个
finType
——例如,
ft
的元素列表类型,其大小由
限定

Lemma size_dbranch d : size (branch d) < #|ft|.+1.
Proof.
rewrite ltnS [card]unlock uniq_leq_size ?buniq // => ?.
by rewrite mem_enum.
Qed.

Definition tag_of_dbranch d : {k : 'I_#|ft|.+1 & k.-tuple ft} :=
  @Tagged _ (Sub (size (branch d)) (size_dbranch d))
            (fun k : 'I_#|ft|.+1 => k.-tuple ft)
            (in_tuple (branch d)).

Definition dbranch_of_tag (t : {k : 'I_#|ft|.+1 & k.-tuple ft}) : option dbranch :=
  insub (val (tagged t)).

Lemma tag_of_dbranchK : pcancel tag_of_dbranch dbranch_of_tag.
Proof. by rewrite /tag_of_dbranch /dbranch_of_tag=> x; rewrite valK. Qed.

Definition dbranch_finMixin := PcanFinMixin tag_of_dbranchK.
Canonical dbranch_finType := Eval hnf in FinType dbranch dbranch_finMixin.
Lemma size_dbranch d:size(分支d)<#| ft.+1。
证明。
重写LTN[卡]解锁uniq_leq_大小?buniq/=>?。
通过重写mem_enum。
Qed。
_dbranch d的定义标记_:{k:'I_35; | | ft |.+1&k.-元组ft}:=
@标记的(子(尺寸(分支d))(尺寸(分支d))
(有趣的k:'I_35;|ft.+1=>k.-tuple ft)
(在元组(分支d)中)。
_标记的定义dbranch_(t:{k:'I#|ft |.+1&k.-元组ft}):选项dbranch:=
insub(val(t))。
引理tag_of_dbranck:pcancel tag_of_dbranch dbranch_of_tag。
证明。通过重写/tag_of_dbranch/dbranch_of_tag=>x;重写valK.Qed。
定义dbranch\u finMixin:=PcanFinMixin标签。
规范dbranch_finType:=finType dbranch dbranch_finMixin中的Eval hnf。