Skip to content

Commit 3d1cf1d

Browse files
committed
try to favor function application instead of \in when set's are
involved, replace hull_mem and hull_mem' by the sole subset_hull, mem_hull_setU_left is then rendered useless, hullI rendered useless by declaring hull_is_convex as a canonical structure, minor cleaning
1 parent 839c56c commit 3d1cf1d

File tree

3 files changed

+116
-141
lines changed

3 files changed

+116
-141
lines changed

probability/convex_choice.v

+78-96
Original file line numberDiff line numberDiff line change
@@ -759,30 +759,27 @@ Local Open Scope classical_set_scope.
759759
Variable A : convType.
760760

761761
Definition is_convex_set (D : set A) : bool :=
762-
`[<forall x y t, x \in D -> y \in D -> x <| t |> y \in D>].
762+
`[<forall x y t, D x -> D y -> D (x <| t |> y)>].
763763

764764
Lemma is_convex_set0 : is_convex_set set0.
765-
Proof. apply/asboolP => x y p; by rewrite in_setE. Qed.
765+
Proof. exact/asboolP. Qed.
766766

767767
Lemma is_convex_set1 a : is_convex_set [set a].
768-
Proof.
769-
apply/asboolP => x y p; rewrite 2!in_setE /= => -> ->.
770-
by rewrite convmm in_setE.
771-
Qed.
768+
Proof. by apply/asboolP => x y p /= => -> ->; rewrite convmm. Qed.
772769

773770
Lemma is_convex_setT : is_convex_set setT.
774-
Proof. apply/asboolP => ? ? ? _ _; by rewrite in_setE. Qed.
771+
Proof. exact/asboolP. Qed.
775772

776773
Definition is_convex_set_n (X : set A) : bool :=
777-
`[< forall n (g : 'I_n -> A) (d : {fdist 'I_n}), g @` setT `<=` X -> \Conv_d g \in X >].
774+
`[< forall n (g : 'I_n -> A) (d : {fdist 'I_n}), g @` setT `<=` X -> X (\Conv_d g) >].
778775

779776
Lemma is_convex_setP (X : set A) : is_convex_set X = is_convex_set_n X.
780777
Proof.
781778
apply/idP/idP => H; apply/asboolP; last first.
782779
move=> x y p xX yX.
783780
case/boolP : (p == `Pr 1) => [/eqP ->|p1]; first by rewrite conv1.
784781
set g : 'I_2 -> A := fun i => if i == ord0 then x else y.
785-
have gX : g @` setT `<=` X by move=> a -[i _ <-]; rewrite -in_setE /g; case: ifPn.
782+
have gX : g @` setT `<=` X by move=> a -[i _ <-]; rewrite /g; case: ifPn.
786783
move/asboolP : H => /(_ _ g (I2FDist.d p) gX).
787784
rewrite convnE; first by rewrite I2FDist.dE eqxx.
788785
move=> p1'.
@@ -792,19 +789,18 @@ apply/idP/idP => H; apply/asboolP; last first.
792789
elim => [g d|n IH g d]; first by move: (fdistI0_False d).
793790
destruct n as [|n] => gX.
794791
rewrite {IH} (@convn_proj _ _ _ _ ord0) //.
795-
rewrite in_setE; exact/gX/classical_sets.imageP.
792+
exact/gX/classical_sets.imageP.
796793
by apply/eqP; rewrite FDist1.dE1 (FDist1.I1 d).
797794
case/boolP : (d ord0 == 1%R) => [/eqP|]d01.
798-
suff -> : \Conv_d g = g ord0 by rewrite in_setE; apply gX; exists ord0.
795+
suff -> : \Conv_d g = g ord0 by apply gX; exists ord0.
799796
by rewrite (@convn_proj _ _ _ _ ord0).
800797
set D : {fdist 'I_n.+1} := DelFDist.d d01.
801798
pose G (i : 'I_n.+1) : A := g (DelFDist.f (@ord0 _) i).
802799
have : G @` setT `<=` X.
803800
by move=> x -[i _ <-{x}]; rewrite /G /DelFDist.f ltn0; apply gX; exists ((lift ord0 i)).
804801
move/(IH _ D) => {IH}IH.
805802
rewrite convnE //.
806-
move/asboolP : H; apply => //.
807-
rewrite in_setE; exact/gX/classical_sets.imageP.
803+
move/asboolP : H; apply => //; exact/gX/classical_sets.imageP.
808804
Qed.
809805
End is_convex_set.
810806

@@ -816,32 +812,30 @@ End hull_def.
816812

817813
Section hull_prop.
818814
Variable A : convType.
819-
Lemma hull_mem (X : set A) x : x \in X -> x \in hull X.
815+
Implicit Types X Y : set A.
816+
Implicit Types a : A.
817+
Lemma subset_hull X : (X `<=` hull X)%classic.
820818
Proof.
821-
move=> xX.
822-
rewrite in_setE /hull.
823-
exists 1, (fun=> x), (FDist1.d ord0); split; last by rewrite convn1E.
824-
move=> d -[i _ <-]; by rewrite -in_setE.
819+
move=> x xX; rewrite /hull; exists 1, (fun=> x), (FDist1.d ord0).
820+
split => [d [i _ <-] //|]; by rewrite convn1E.
825821
Qed.
826822
Lemma hull0 : hull set0 = set0 :> set A.
827823
Proof.
828824
rewrite funeqE => d; rewrite propeqE; split => //.
829-
case=> n [g [e [gX ->{d}]]].
830-
destruct n as [|n].
831-
by move: (fdistI0_False e).
825+
move=> [n [g [e [gX ->{d}]]]].
826+
destruct n as [|n]; first by move: (fdistI0_False e).
832827
exfalso; apply: (gX (g ord0)); exact/imageP.
833828
Qed.
834-
Lemma hull_eq0 (X : set A) : (hull X == set0) = (X == set0).
829+
Lemma hull_eq0 X : (hull X == set0) = (X == set0).
835830
Proof.
836831
apply/idP/idP=> [/eqP abs|]; last by move=> /eqP ->; rewrite hull0.
837-
apply/negPn/negP => /set0P[/= d]; rewrite -in_setE => dX.
832+
apply/negPn/negP => /set0P[/= d] => dX.
838833
move: abs; rewrite funeqE => /(_ d); rewrite propeqE /set0 => -[H _]; apply H.
839-
by rewrite -in_setE; apply: hull_mem.
834+
exact/subset_hull.
840835
Qed.
841-
Lemma mem_hull_setU (x y : set A) (a0 a1 : A) p :
842-
a0 \in x -> a1 \in y -> a0 <| p |> a1 \in hull (x `|` y).
836+
Lemma mem_hull_setU X Y a0 a1 p : X a0 -> Y a1 -> (hull (X `|` Y)) (a0 <| p |> a1).
843837
Proof.
844-
rewrite 3!in_setE => a0x a1y.
838+
move=> a0X a1y.
845839
exists 2, (fun i => if i == ord0 then a0 else a1), (I2FDist.d p); split => /=.
846840
move=> a2.
847841
case => i _ <-{a2} /=.
@@ -857,17 +851,21 @@ move: H'; rewrite DelFDist.dE D1FDist.dE (eq_sym (lift _ _)) (negbTE (neq_lift _
857851
rewrite I2FDist.dE (eq_sym (lift _ _)) (negbTE (neq_lift _ _)) I2FDist.dE eqxx divRR ?eqxx //.
858852
by move: H; rewrite I2FDist.dE eqxx onem_neq0.
859853
Qed.
860-
Lemma mem_hull_setU_left (x y : set A) (a : A) : a \in x -> a \in hull (x `|` y).
861-
Proof. by rewrite in_setE=> ax; apply: hull_mem; rewrite in_setE; left. Qed.
862-
863854
End hull_prop.
864855

865-
(* TODO: same as model.v from monae *)
856+
(* NB: was duplicate in monae_lib.v before *)
857+
Section choice_cast.
858+
866859
Definition equality_mixin_of_Type (T : Type) : Equality.mixin_of T :=
867860
EqMixin (fun x y : T => boolp.asboolP (x = y)).
861+
868862
Definition choice_of_Type (T : Type) : choiceType :=
869863
Choice.Pack (Choice.Class (equality_mixin_of_Type T) boolp.gen_choiceMixin).
870864

865+
Definition choice_of_Object {T} (t : T) : choice_of_Type T := t.
866+
867+
End choice_cast.
868+
871869
Module CSet.
872870
Section cset.
873871
Variable A : convType.
@@ -907,13 +905,17 @@ End CSet_interface.
907905

908906
Section CSet_prop.
909907
Local Open Scope classical_set_scope.
908+
Import ScaledConvex.
910909
Variable A : convType.
911910
Implicit Types X Y : {convex_set A}.
911+
Implicit Types a : A.
912+
Implicit Types x y : scaled_pt A.
912913

913-
Lemma mem_convex_set (x y : A) p X : x \in X -> y \in X -> x <|p|> y \in X.
914+
Lemma mem_convex_set a1 a2 p X : a1 \in X -> a2 \in X -> a1 <|p|> a2 \in X.
914915
Proof.
915916
case: X => X [convX]; move: (convX) => convX_save.
916-
move/asboolP : convX => convX Hx Hy; exact: convX.
917+
move/asboolP : convX => convX Hx Hy.
918+
by rewrite in_setE; apply: convX; rewrite -in_setE.
917919
Qed.
918920

919921
Definition cset0 : {convex_set A} := CSet.Pack (CSet.Class (is_convex_set0 A)).
@@ -930,42 +932,19 @@ rewrite cset0P; case: X => //= x Hx; split; last first.
930932
by case/set0P => /= d dx; exists d.
931933
Qed.
932934

933-
Definition cset1 (a : A) : {convex_set A} :=
934-
CSet.Pack (CSet.Class (is_convex_set1 a)).
935+
Definition cset1 a : {convex_set A} := CSet.Pack (CSet.Class (is_convex_set1 a)).
935936

936-
Lemma cset1_neq0 (a : A) : cset1 a != cset0.
937+
Lemma cset1_neq0 a : cset1 a != cset0.
937938
Proof. by apply/cset0PN; exists a. Qed.
938939

939940
Lemma hull_cset X : hull X = X.
940941
Proof.
941-
rewrite predeqE => d; split.
942-
- move=> -[n [g [e [gX ->{d}]]]].
943-
move: (convex_setP X); rewrite is_convex_setP /is_convex_set_n.
944-
by move=> /asboolP/(_ _ g e gX); rewrite in_setE.
945-
- by rewrite -in_setE => /hull_mem; rewrite in_setE.
942+
rewrite predeqE => d; split; last exact/subset_hull.
943+
move=> -[n [g [e [gX ->{d}]]]].
944+
move: (convex_setP X); rewrite is_convex_setP /is_convex_set_n.
945+
by move=> /asboolP/(_ _ g e gX).
946946
Qed.
947947

948-
Import ScaledConvex.
949-
Definition scaled_set (Z : set A) :=
950-
[set x | if x is p *: a then a \in Z else True].
951-
952-
Lemma addpt_scaled_set X x y :
953-
x \in scaled_set X -> y \in scaled_set X -> addpt x y \in scaled_set X.
954-
Proof.
955-
case: x => [p x|]; case: y => [q y|] //=; rewrite !in_setE /scaled_set.
956-
exact: mem_convex_set.
957-
Qed.
958-
959-
Lemma scalept_scaled_set X r x :
960-
x \in scaled_set X -> scalept r x \in scaled_set X.
961-
Proof.
962-
rewrite /scalept; case: Rlt_dec => //= Hr; by [case: x | rewrite !in_setE].
963-
Qed.
964-
965-
Lemma scaled_set_extract X x (H : (0 < weight _ x)%R) :
966-
x \in scaled_set X -> point H \in X.
967-
Proof. case: x H => [p x|/ltRR] //=; by rewrite in_setE. Qed.
968-
969948
Lemma split_lshift n m (i : 'I_n) : fintype.split (lshift m i) = inl i.
970949
Proof. by rewrite -/(unsplit (inl i)) unsplitK. Qed.
971950
Lemma split_rshift n m (i : 'I_m) : fintype.split (rshift n i) = inr i.
@@ -982,12 +961,9 @@ congr addpt; apply eq_bigr => i _;
982961
by rewrite AddFDist.dE (split_lshift,split_rshift).
983962
Qed.
984963

985-
Lemma convex_hull (Z : set A) : is_convex_set (hull Z).
964+
Lemma hull_is_convex (Z : set A) : is_convex_set (hull Z).
986965
Proof.
987-
apply/asboolP => x y p; rewrite 2!in_setE.
988-
move=> -[n [g [d [gX ->{x}]]]].
989-
move=> -[m [h [e [hX ->{y}]]]].
990-
rewrite in_setE.
966+
apply/asboolP => x y p [n [g [d [gX ->{x}]]]] [m [h [e [hX ->{y}]]]].
991967
exists (n + m).
992968
exists [ffun i => match fintype.split i with inl a => g a | inr a => h a end].
993969
exists (AddFDist.d d e p).
@@ -997,27 +973,35 @@ split.
997973
rewrite AddFDist_conv; congr Conv; apply eq_convn => i //=;
998974
by rewrite ffunE (split_lshift,split_rshift).
999975
Qed.
976+
Canonical hull_is_convex_set (Z : set A) : convex_set A :=
977+
CSet.Pack (CSet.Class (hull_is_convex Z)).
1000978

1001-
Lemma hullI (Z : set A) : hull (hull Z) = hull Z.
979+
Definition scaled_set (Z : set A) :=
980+
[set x | if x is p *: a then Z a else True].
981+
982+
Lemma addpt_scaled_set X x y :
983+
x \in scaled_set X -> y \in scaled_set X -> addpt x y \in scaled_set X.
1002984
Proof.
1003-
rewrite predeqE => d; split.
1004-
- move=> -[n [g [e [gX ->{d}]]]].
1005-
move: (convex_hull Z).
1006-
rewrite is_convex_setP /is_convex_set_n => /asboolP/(_ _ g e gX).
1007-
by rewrite in_setE.
1008-
- by rewrite -in_setE => /hull_mem; rewrite in_setE.
985+
case: x => [p x|]; case: y => [q y|] //=; exact: mem_convex_set.
1009986
Qed.
1010987

1011-
Lemma hull_setU (a : A) X Y : X !=set0 -> Y !=set0 -> a \in hull (X `|` Y) ->
988+
Lemma scalept_scaled_set X r x :
989+
x \in scaled_set X -> scalept r x \in scaled_set X.
990+
Proof.
991+
rewrite /scalept; case: Rlt_dec => //= Hr; by [case: x | rewrite !in_setE].
992+
Qed.
993+
994+
Lemma scaled_set_extract X x (H : (0 < weight _ x)%R) :
995+
x \in scaled_set X -> point H \in X.
996+
Proof. case: x H => [p x|/ltRR] //=; by rewrite in_setE. Qed.
997+
998+
Lemma hull_setU (a : A) X Y : X !=set0 -> Y !=set0 -> (hull (X `|` Y)) a ->
1012999
exists a1, a1 \in X /\ exists a2, a2 \in Y /\ exists p : prob, a = a1 <| p |> a2.
10131000
Proof.
1014-
move=> x0 y0.
1015-
rewrite in_setE.
1001+
move=> [dx dx_x] [dy dy_y].
10161002
case=> n -[g [e [gX Ha]]].
1017-
case: x0 => dx dx_x.
1018-
case: y0 => dy dy_y.
1019-
suff : exists a1, a1 \in scaled_set X /\ exists a2, a2 \in scaled_set Y
1020-
/\ S1 a = addpt a1 a2.
1003+
suff : exists x1, x1 \in scaled_set X /\ exists x2, x2 \in scaled_set Y /\
1004+
S1 a = addpt x1 x2.
10211005
case => -[p a1|] [Ha1] [] [q a2|] /= [Ha2] // [Hpq ->];
10221006
(exists a1; split;
10231007
first by rewrite -(@point_Scaled _ p a1 (Rpos_gt0 _));
@@ -1039,14 +1023,13 @@ exists sa1; split.
10391023
rewrite /sa1; apply big_ind.
10401024
+ by rewrite in_setE.
10411025
+ apply addpt_scaled_set.
1042-
+ move=> i Hi; apply scalept_scaled_set.
1043-
by rewrite in_setE.
1026+
+ move=> i Hi; exact: scalept_scaled_set.
10441027
exists sa2; split.
10451028
rewrite /sa2; apply big_ind.
10461029
+ by rewrite in_setE.
10471030
+ apply addpt_scaled_set.
10481031
+ move=> i Hi; apply scalept_scaled_set.
1049-
rewrite in_setE /= -[_ \in _]orFb -(negbTE Hi).
1032+
rewrite -[_ \in _]orFb -(negbTE Hi).
10501033
apply/orP; rewrite 2!in_setE; exact/gX/imageP.
10511034
by [].
10521035
Qed.
@@ -1656,7 +1639,7 @@ Lemma is_convex_set_image (A B : convType) (f : {affine A -> B})
16561639
(a : convex_set A) : is_convex_set (f @` a).
16571640
Proof.
16581641
rewrite /is_convex_set.
1659-
apply/asboolP => x y p; rewrite 3!in_setE => -[a0 Ha0 <-{x}] [a1 Ha1 <-{y}].
1642+
apply/asboolP => x y p [a0 Ha0 <-{x}] [a1 Ha1 <-{y}].
16601643
exists (a0 <|p|> a1) => //.
16611644
by rewrite -in_setE; apply/mem_convex_set; rewrite in_setE.
16621645
by rewrite (affine_functionP' f).
@@ -1666,8 +1649,7 @@ Lemma is_convex_set_image' (A B : convType) (f : A -> B) (H : affine_function f)
16661649
(a : convex_set A) : is_convex_set (f @` a).
16671650
Proof.
16681651
rewrite /is_convex_set.
1669-
apply/asboolP => x y p; rewrite 3!in_setE => -[a0 Ha0 <-{x}] [a1 Ha1 <-{y}].
1670-
exists (a0 <|p|> a1) => //.
1652+
apply/asboolP => x y p [a0 Ha0 <-{x}] [a1 Ha1 <-{y}]; exists (a0 <|p|> a1) => //.
16711653
by rewrite -in_setE; apply/mem_convex_set; rewrite in_setE.
16721654
by rewrite H.
16731655
Qed.
@@ -1677,7 +1659,10 @@ Local Close Scope classical_set_scope.
16771659
Section R_affine_function_prop.
16781660
Variables (A : convType) (f : A -> R).
16791661
Lemma R_affine_functionN : affine_function f -> affine_function (fun x => - f x)%R.
1680-
Proof. move /affine_functionP => [H1 H2]; rewrite affine_functionP; split => //; [exact/R_convex_functionN|exact/R_concave_functionN]. Qed.
1662+
Proof.
1663+
move/affine_functionP => [H1 H2]; rewrite affine_functionP.
1664+
split => //; [exact/R_convex_functionN|exact/R_concave_functionN].
1665+
Qed.
16811666
End R_affine_function_prop.
16821667

16831668
Section convex_function_in_def.
@@ -1774,24 +1759,22 @@ Section convex_set_R.
17741759

17751760
Lemma Rpos_convex : is_convex_set (fun x => 0 < x)%R.
17761761
Proof.
1777-
apply/asboolP => x y t; rewrite !in_setE => Hx Hy.
1762+
apply/asboolP => x y t Hx Hy.
17781763
case/boolP : (t == `Pr 0) => [/eqP ->| Ht0]; first by rewrite conv0.
17791764
apply addR_gt0wl; first by apply mulR_gt0 => //; exact/prob_gt0.
1780-
apply mulR_ge0; [exact/onem_ge0/prob_le1 | exact: ltRW].
1765+
apply mulR_ge0 => //; exact: ltRW.
17811766
Qed.
17821767

17831768
Definition Rpos_interval := CSet.Pack (CSet.Class Rpos_convex).
17841769

17851770
Lemma Rnonneg_convex : is_convex_set (fun x => 0 <= x)%R.
1786-
Proof.
1787-
apply/asboolP=> x y t; rewrite !in_setE => Hx Hy; apply addR_ge0; exact/mulR_ge0.
1788-
Qed.
1771+
Proof. apply/asboolP=> x y t Hx Hy; apply addR_ge0; exact/mulR_ge0. Qed.
17891772

17901773
Definition Rnonneg_interval := CSet.Pack (CSet.Class Rnonneg_convex).
17911774

17921775
Lemma open_interval_convex a b (Hab : (a < b)%R) : is_convex_set (fun x => a < x < b)%R.
17931776
Proof.
1794-
apply/asboolP => x y t; rewrite !in_setE => -[xa xb] [ya yb].
1777+
apply/asboolP => x y t [xa xb] [ya yb].
17951778
case/boolP : (t == `Pr 0) => [/eqP|]t0; first by rewrite t0 conv0.
17961779
case/boolP : (t == `Pr 1) => [/eqP|]t1; first by rewrite t1 conv1.
17971780
apply conj.
@@ -1891,8 +1874,7 @@ have : (a <= x <= b)%R.
18911874
rewrite -mulRDl addRCA addR_opp subRR addR0 mul1R; exact/leRR.
18921875
case/boolP : (t == `Pr 1) => [/eqP ->|t1].
18931876
rewrite /onem subRR !mul0R !addR0; exact/leRR.
1894-
rewrite leR_add2l; apply leR_wpmul2l; last exact/ltRW.
1895-
exact/onem_ge0/prob_le1.
1877+
rewrite leR_add2l; apply leR_wpmul2l => //; exact/ltRW.
18961878
- apply (@leR_trans (t * b + t.~ * b)); last first.
18971879
rewrite -mulRDl addRCA addR_opp subRR addR0 mul1R; exact/leRR.
18981880
rewrite leR_add2r; apply leR_wpmul2l => //; exact/ltRW.

probability/jensen.v

+1-1
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ have /IH {IH}[IH HDd] : #|fdist_supp d| = n.
6060
by rewrite D1FDist.card_fdist_supp // cardA.
6161
split; last first.
6262
move/asboolP: (convex_setP D) => /(_ (r b) (\sum_(a in fdist_supp d) d a * r a) (probfdist X b)).
63-
exact.
63+
by rewrite classical_sets.in_setE; apply; rewrite -classical_sets.in_setE.
6464
move/leR_trans: (convex_f (probfdist X b) (HDr b) HDd); apply => /=.
6565
by rewrite leR_add2l; apply leR_wpmul2l => //; apply/onem_ge0.
6666
Qed.

0 commit comments

Comments
 (0)