1- (* mathcomp analysis (c) 2022 Inria and AIST. License: CeCILL-C. *)
1+ (* mathcomp analysis (c) 2025 Inria and AIST. License: CeCILL-C. *)
22From mathcomp Require Import all_ssreflect ssralg ssrint ssrnum finmap.
33From mathcomp Require Import matrix interval zmodp vector fieldext falgebra.
44From mathcomp Require Import mathcomp_extra unstable boolp classical_sets.
@@ -11,18 +11,23 @@ From HB Require Import structures.
1111(* # Convexity *)
1212(* *)
1313(* This file provides a small account of convexity using convex spaces, to be *)
14- (* completed with material from infotheo . *)
14+ (* completed with material from InfoTheo . *)
1515(* *)
1616(* ``` *)
17- (* isConvexSpace R T == interface for convex spaces *)
18- (* ConvexSpace R == structure of convex space *)
19- (* a <| t |> b == convexity operator *)
17+ (* convex_quasi_associative == quasi-associativity of the operator of *)
18+ (* convex spaces *)
19+ (* isConvexSpace R T == interface for convex spaces with *)
20+ (* R : numDomainType *)
21+ (* The HB class is ConvexSpace. *)
22+ (* a <| t |> b == convexity operator *)
2023(* ``` *)
2124(* *)
22- (* E : lmodType R with R : realDomainType and R : realDomainType are shown to *)
23- (* be convex spaces with the following aliases: *)
24- (* convex_lmodType E == E : lmodType T as a convex spaces *)
25- (* convex_realDomainType R == R : realDomainType as a convex space *)
25+ (* For `R : numDomainType`, `E : lmodType R` and `R` itself are shown to be *)
26+ (* convex spaces with the following aliases: *)
27+ (* ``` *)
28+ (* convex_lmodType E == E : lmodType R as a convex space *)
29+ (* convex_numDomainType R == R : numDomainType as a convex space *)
30+ (* ``` *)
2631(* *)
2732(***************************************************************************** *)
2833
@@ -42,18 +47,70 @@ Import numFieldNormedType.Exports.
4247Declare Scope convex_scope.
4348Local Open Scope convex_scope.
4449
45- HB.mixin Record isConvexSpace (R : realDomainType) T := {
50+ Module ConvexQuasiAssoc.
51+ Section def.
52+ Variables (R : numDomainType) (T : Type) (conv : {i01 R} -> T -> T -> T).
53+
54+ Local Notation "x <| p |> y" := (conv p x y).
55+
56+ Definition law := forall (p q r s : {i01 R}) (a b c : T),
57+ p%:num = r%:num * s%:num ->
58+ `1- (s%:num) = `1- (p%:num) * `1- (q%:num) ->
59+ a <| p |> (b <| q |> c) = (a <| r |> b) <| s |> c.
60+ End def.
61+
62+ (** technical relations between the parameters of the quasi-associativity law *)
63+ Section lemmas.
64+
65+ Lemma pq_sr (R : comRingType) (p q r s : R) :
66+ p = r * s ->
67+ 1 - s = (1 - p) * (1 - q) ->
68+ (1 - p) * q = s * (1 - r).
69+ Proof .
70+ move=> prs spq.
71+ rewrite -[LHS]opprK -mulrN -[X in - X = _](addrK ((1 - p) * 1)).
72+ rewrite -mulrDr (addrC _ 1) -spq mulr1 prs.
73+ by rewrite !opprB addrC subrKA mulrDr mulr1 mulrN mulrC.
74+ Qed .
75+
76+ Lemma sE (R : ringType) (p q s : R) :
77+ 1 - s = (1 - p) * (1 - q) ->
78+ s = 1 - (1 - p) * (1 - q).
79+ Proof . by move/eqP; rewrite subr_eq addrC -subr_eq => /eqP ->. Qed .
80+
81+ Lemma qE (R : comUnitRingType) (p q r s : R) :
82+ 1 - p \is a GRing.unit ->
83+ p = r * s ->
84+ 1 - s = (1 - p) * (1 - q) ->
85+ q = (s * (1 - r)) / (1 - p).
86+ Proof .
87+ move=> p1unit /pq_sr /[apply] /(congr1 ( *%R (1 - p)^-1)).
88+ by rewrite mulrA mulVr// mul1r mulrC.
89+ Qed .
90+
91+ Lemma rE (R : unitRingType) (p r s : R) :
92+ s \is a GRing.unit -> p = r * s -> r = p / s.
93+ Proof .
94+ move=> sunit /(congr1 ( *%R^~ s^-1)) ->.
95+ by rewrite -mulrA divrr// mulr1.
96+ Qed .
97+
98+ End lemmas.
99+
100+ End ConvexQuasiAssoc.
101+
102+ Definition convex_quasi_associative := ConvexQuasiAssoc.law.
103+
104+ HB.mixin Record isConvexSpace (R : numDomainType) T := {
46105 conv : {i01 R} -> T -> T -> T ;
47- conv0 : forall a b, conv 0 %:i01 a b = a ;
106+ conv1 : forall a b, conv 1 %:i01 a b = a ;
48107 convmm : forall (p : {i01 R}) a, conv p a a = a ;
49108 convC : forall (p : {i01 R}) a b, conv p a b = conv (1 - p%:inum)%:i01 b a;
50- convA : forall (p q r : {i01 R}) (a b c : T),
51- p%:inum * (`1-(q%:inum)) = (`1-(p%:inum * q%:inum)) * r%:inum ->
52- conv p a (conv q b c) = conv (p%:inum * q%:inum)%:i01 (conv r a b) c
109+ convA : convex_quasi_associative conv
53110}.
54111
55112#[short(type=convType)]
56- HB.structure Definition ConvexSpace (R : realDomainType ) :=
113+ HB.structure Definition ConvexSpace (R : numDomainType ) :=
57114 {T of isConvexSpace R T & Choice T}.
58115
59116Notation "a <| p |> b" := (conv p a b) : convex_scope.
@@ -62,102 +119,116 @@ Section convex_space_lemmas.
62119Context R (A : convType R).
63120Implicit Types a b : A.
64121
65- Lemma conv1 a b : a <| 1 %:i01 |> b = b.
122+ Lemma conv0 a b : a <| 0 %:i01 |> b = b.
66123Proof .
67- rewrite convC/= [X in _ <| X |> _](_ : _ = 0 %:i01) ?conv0 //.
68- by apply/val_inj => /=; rewrite subrr .
124+ rewrite convC/= [X in _ <| X |> _](_ : _ = 1 %:i01) ?conv1 //.
125+ by apply/val_inj => /=; rewrite subr0 .
69126Qed .
70127
71128End convex_space_lemmas.
72129
73130Local Open Scope convex_scope.
74131
75- Definition convex_lmodType {R : realDomainType } (E : lmodType R) : Type := E.
132+ Definition convex_lmodType {R : numDomainType } (E : lmodType R) : Type := E.
76133
77134Section lmodType_convex_space.
78- Context {R : realDomainType } {E' : lmodType R}.
135+ Context {R : numDomainType } {E' : lmodType R}.
79136Implicit Type p q r : {i01 R}.
80137
81138Let E := convex_lmodType E'.
82139
83- Let avg p (a b : E) := `1-( p%:inum) *: a + p%:inum *: b.
140+ Let avg p (a b : E) := p%:inum *: a + `1-( p%:inum) *: b.
84141
85- Let avg0 a b : avg 0 %:i01 a b = a.
86- Proof . by rewrite /avg/= onem0 scale0r scale1r addr0. Qed .
142+ Let avg1 a b : avg 1 %:i01 a b = a.
143+ Proof . by rewrite /avg/= onem1 scale0r scale1r addr0. Qed .
87144
88145Let avgI p x : avg p x x = x.
89- Proof . by rewrite /avg -scalerDl/= addrC add_onemK scale1r. Qed .
146+ Proof . by rewrite /avg -scalerDl/= add_onemK scale1r. Qed .
90147
91148Let avgC p x y : avg p x y = avg (1 - (p%:inum))%:i01 y x.
92149Proof . by rewrite /avg onemK addrC. Qed .
93150
94- Let avgA p q r (a b c : E) :
95- p%:inum * (`1-(q%:inum)) = (`1-(p%:inum * q%:inum)) * r%:inum ->
96- avg p a (avg q b c) = avg (p%:inum * q%:inum)%:i01 (avg r a b) c.
151+ Let avgA : convex_quasi_associative avg.
97152Proof .
98- move=> pq ; rewrite /avg.
153+ move=> p q r s a b c prs spq ; rewrite /avg.
99154rewrite [in LHS]scalerDr [in LHS]addrA [in RHS]scalerDr; congr (_ + _ + _).
100- - rewrite scalerA; congr (_ *: _) => /=.
101- by rewrite mulrDr mulr1 mulrN -pq mulrBr mulr1 opprB addrA subrK.
102- - by rewrite 2!scalerA; congr (_ *: _).
103- - by rewrite scalerA.
155+ - by rewrite scalerA mulrC prs.
156+ - by rewrite !scalerA; congr *:%R; rewrite (ConvexQuasiAssoc.pq_sr prs).
157+ - by rewrite scalerA spq.
104158Qed .
105159
106160HB.instance Definition _ := Choice.on E.
107161
108162HB.instance Definition _ :=
109- isConvexSpace.Build R E avg0 avgI avgC avgA.
163+ isConvexSpace.Build R E avg1 avgI avgC avgA.
110164
111165End lmodType_convex_space.
112166
113- Definition convex_realDomainType (R : realDomainType ) : Type := R^o.
167+ Definition convex_numDomainType (R : numDomainType ) : Type := R^o.
114168
115- Section realDomainType_convex_space .
116- Context {R : realDomainType }.
169+ Section numDomainType_convex_space .
170+ Context {R : numDomainType }.
117171Implicit Types p q : {i01 R}.
118172
119- Let E := @convex_realDomainType R.
120-
121173Let avg p (a b : convex_lmodType R^o) := a <| p |> b.
122174
123- Let avg0 a b : avg 0 %:i01 a b = a.
124- Proof . by rewrite /avg conv0 . Qed .
175+ Let avg1 a b : avg 1 %:i01 a b = a.
176+ Proof . exact: conv1 . Qed .
125177
126178Let avgI p x : avg p x x = x.
127- Proof . by rewrite /avg convmm. Qed .
179+ Proof . exact: convmm. Qed .
128180
129181Let avgC p x y : avg p x y = avg (1 - (p%:inum))%:i01 y x.
130- Proof . by rewrite /avg convC. Qed .
182+ Proof . exact: convC. Qed .
131183
132- Let avgA p q r (a b c : R) :
133- p%:inum * (`1-(q%:inum)) = (`1-(p%:inum * q%:inum)) * r%:inum ->
134- avg p a (avg q b c) = avg (p%:inum * q%:inum)%:i01 (avg r a b) c.
135- Proof . by move=> h; rewrite /avg (convA _ _ r). Qed .
184+ Let avgA : convex_quasi_associative avg.
185+ Proof . exact: convA. Qed .
136186
137187HB.instance Definition _ := @isConvexSpace.Build R R^o
138- _ avg0 avgI avgC avgA.
188+ _ avg1 avgI avgC avgA.
139189
140- End realDomainType_convex_space .
190+ End numDomainType_convex_space .
141191
142- Section conv_realDomainType .
143- Context {R : realDomainType }.
192+ Section conv_numDomainType .
193+ Context {R : numDomainType }.
144194
145- Lemma conv_gt0 (a b : R^o) (t : {i01 R}) : 0 < a -> 0 < b -> 0 < a <| t |> b.
195+ Lemma convR_gt0 (a b : R^o) (t : {i01 R}) : 0 < a -> 0 < b -> 0 < a <| t |> b.
146196Proof .
147197move=> a0 b0.
148198have [->|t0] := eqVneq t 0%:i01; first by rewrite conv0.
149199have [->|t1] := eqVneq t 1%:i01; first by rewrite conv1.
150- rewrite addr_gt0// mulr_gt0//; last by rewrite lt_neqAle eq_sym t0/= .
151- by rewrite onem_gt0// lt_neqAle t1/= .
200+ rewrite addr_gt0// mulr_gt0//; first by rewrite lt_neqAle eq_sym t0 ge0 .
201+ by rewrite subr_gt0 lt_neqAle t1 le1 .
152202Qed .
153203
154- Lemma convRE (a b : R^o) (t : {i01 R}) : a <| t |> b = `1-(t%:inum) * a + t%:inum * b.
204+ Lemma convRE (a b : R^o) (t : {i01 R}) :
205+ a <| t |> b = t%:inum * a + `1-(t%:inum) * b.
155206Proof . by []. Qed .
156207
157- End conv_realDomainType.
208+ Lemma convR_itv (a b : R^o) (t : {i01 R}) : a <= b -> a <| t |> b \in `[a, b].
209+ Proof .
210+ move=> ab; rewrite convRE in_itv /=.
211+ rewrite -{1}(subrKC a b).
212+ rewrite mulrDr addrA -mulrDl.
213+ rewrite subrKC mul1r.
214+ rewrite lerDl mulr_ge0/=; [|by rewrite subr_ge0 le1|by rewrite subr_ge0].
215+ rewrite -[leRHS](convmm t b) convRE lerD//.
216+ by rewrite ler_wpM2l.
217+ Qed .
218+
219+ Let convRCE (a b : R^o) (t : {i01 R}) :
220+ a <| t |> b = `1-(t%:inum) * b + t%:inum * a.
221+ Proof . by rewrite addrC convRE. Qed .
222+
223+ Lemma convR_line_path (a b : R^o) (t : {i01 R}) :
224+ a <| t |> b = line_path b a t%:num.
225+ Proof . by rewrite convRCE. Qed .
226+
227+ End conv_numDomainType.
158228
159229Definition convex_function (R : realType) (D : set R) (f : R -> R^o) :=
160- forall (t : {i01 R}), {in D &, forall (x y : R^o), (f (x <| t |> y) <= f x <| t |> f y)%R}.
230+ forall (t : {i01 R}),
231+ {in D &, forall (x y : R^o), (f (x <| t |> y) <= f x <| t |> f y)%R}.
161232(* TODO: generalize to convTypes once we have ordered convTypes (mathcomp 2) *)
162233
163234(* ref: http://www.math.wisc.edu/~nagel/convexity.pdf *)
@@ -183,10 +254,10 @@ Qed.
183254Let convexf_ptP : a < b -> (forall x, a <= x <= b -> 0 <= L x - f x) ->
184255 forall t, f (a <| t |> b) <= f a <| t |> f b.
185256Proof .
186- move=> ab h t; set x := a <| t |> b; have /h : a <= x <= b.
187- by rewrite -(conv1 a b) -{1}(conv0 a b) /x !le_line_path//= ge0 /=.
257+ move=> ba h t; set x := a <| t |> b; have /h : a <= x <= b.
258+ by have:= convR_itv t (ltW ba); rewrite in_itv /=.
188259rewrite subr_ge0 => /le_trans; apply.
189- by rewrite LE// /x line_pathK ?lt_eqF// convC line_pathK ?gt_eqF .
260+ by rewrite LE// /x {2}convC 2!convR_line_path !line_pathK//= ?(eq_sym b) lt_eqF .
190261Qed .
191262
192263Hypothesis HDf : {in `]a, b[, forall x, derivable f x 1}.
@@ -210,7 +281,8 @@ have [c2 Ic2 Hc2] : exists2 c2, x < c2 < b & (f b - f x) / (b - x) = 'D_1 f c2.
210281 have derivef z : z \in `]x, b[ -> is_derive z 1 f ('D_1 f z).
211282 by move=> zxb; apply/derivableP/xbf; exact: zxb.
212283 have [|z zxb fbfx] := MVT xb derivef.
213- apply/(derivable_oo_continuous_bnd_within (And3 xbf _ cvg_left))/cvg_at_right_filter.
284+ apply/(derivable_oo_continuous_bnd_within (And3 xbf _ cvg_left)).
285+ apply/cvg_at_right_filter.
214286 have := derivable_within_continuous HDf.
215287 rewrite continuous_open_subspace//.
216288 by apply; rewrite inE/= in_itv/= ax.
@@ -221,7 +293,8 @@ have [c1 Ic1 Hc1] : exists2 c1, a < c1 < x & (f x - f a) / (x - a) = 'D_1 f c1.
221293 have derivef z : z \in `]a, x[ -> is_derive z 1 f ('D_1 f z).
222294 by move=> zax; apply /derivableP/axf.
223295 have [|z zax fxfa] := MVT ax derivef.
224- apply/(derivable_oo_continuous_bnd_within (And3 axf cvg_right _))/cvg_at_left_filter.
296+ apply/(derivable_oo_continuous_bnd_within (And3 axf cvg_right _)).
297+ apply/cvg_at_left_filter.
225298 have := derivable_within_continuous HDf.
226299 rewrite continuous_open_subspace//.
227300 by apply; rewrite inE/= in_itv/= ax.
0 commit comments