EDIT : I have made the example more minimal by introducing a structure that augments an element by carrying a proof of the membership of the said element to a set:
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 <:].
However, I need to apply this transformation to any given set, and I cannot seem to do it either :
Lemma equip_set_with_Helin {ft : finType} (s : {set ft}) : {set (elem_and_in_proof s)}.
Proof.
Admitted.
Since equip_set_with_Helin allows me to write the uniq_cons function, any help with either this or the original question would be greatly appreciated. Thanks!
I have a type dbranch consisting of a sequence over a finite type ft and a proof of uniq of this sequence. I want to be able, given an element t of type ft and a finset over dbranch to return the same set, where all dbranches have been "cons-ed" with t.
I needed to write a cons function for branches that takes as argument the hypothesis that the given element is not already part of the branch. I did not know how to write it as a usual function, so I approached it as a proof.
I then wrote uniq_cons, which tries to lift dcons to a set of dbranches. However, the application of its argument H requires a proof of b \in t (that's the placeholder in my code).
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].
The fact that b is in t should be obvious as it appears directly in the comprehensive notation. However, I could not find in finset.v a way to "extract" or use that information, and Coq is not able to do it by itself. Thank you in advance for your help.
答案 0 :(得分:1)
要回答您的修订问题,您可以执行以下操作:
9
序列3.14
枚举集合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
强制转换为sT : subType P
的子类型T
。假设P
的所有元素都按定义位于x
中,则此函数的行为就如同enum A
一样。最后,A
将部分函数映射到序列上,并丢弃所有Some
的结果。