Debian Codegraph @

reals/stdlib/CMTcast.v

raw
1 (*
2 Copyright © 2020 Vincent Semeria
3
4 Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
5
6 The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
7
8 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
9 *)
10
11
12 (** Cast of constructive reals inside an integration space.
13 Because two instances of constructive reals are isomorphic,
14 so are their integrations spaces. *)
15
16 Require Import QArith_base.
17 Require Import List.
18 Require Import ConstructiveReals.
19 Require Import ConstructiveRealsMorphisms.
20 Require Import ConstructiveAbs.
21 Require Import ConstructiveMinMax.
22 Require Import ConstructiveSum.
23 Require Import ConstructiveLimits.
24 Require Import ConstructivePartialFunctions.
25 Require Import CMTbase.
26 Require Import CMTIntegrableFunctions.
27 Require Import CMTIntegrableSets.
28 Require Import CMTFullSets.
29
30 Local Open Scope ConstructiveReals.
31
32 Definition CRcast {R1 R2 : ConstructiveReals} : CRcarrier R1 -> CRcarrier R2
33 := CRmorph (@SlowConstructiveRealsMorphism R1 R2).
34
35 Definition PartialFunctionCast {R1 R2 : ConstructiveReals} {X : Set}
36 (f : @PartialFunction R1 X) : @PartialFunction R2 X.
37 Proof.
38 apply (Build_PartialFunctionXY
39 X (CRcarrier R2) (CReq R2) (Domain f)
40 (fun x xD => CRcast (partialApply f x xD))).
41 intros. apply CRmorph_proper. apply DomainProp.
42 Defined.
43
44 Definition FunctionRieszSpaceCast {R : ConstructiveReals}
45 : FunctionRieszSpace -> FunctionRieszSpace.
46 Proof.
47 intro el.
48 apply (Build_FunctionRieszSpace
49 (X el) R (fun f => L el (@PartialFunctionCast R _ (X el) f))).
50 - intros. destruct el.
51 apply (Lext (PartialFunctionCast f)). 2: exact X.
52 destruct H, p.
53 split. split.
54 intros x xD. exact (d x xD).
55 intros x xD. exact (d0 x xD).
56 intros. apply CRmorph_proper, c.
57 - intros. destruct el.
58 apply (Lext (Xplus (PartialFunctionCast f) (PartialFunctionCast g))).
59 split. split.
60 intros x xD. exact xD.
61 intros x xD. exact xD.
62 intros. destruct xD, xG. simpl.
63 unfold CRcast. rewrite <- CRmorph_plus. apply CRmorph_proper.
64 apply CRplus_morph; apply DomainProp.
65 apply LplusStable; assumption.
66 - intros. destruct el.
67 apply (Lext (Xabs (PartialFunctionCast f))).
68 split. split.
69 intros x xD. exact xD.
70 intros x xD. exact xD.
71 intros. simpl.
72 unfold CRcast. rewrite CRmorph_abs. apply CRmorph_proper.
73 apply CRabs_morph, DomainProp. apply LabsStable, X.
74 - intros. destruct el.
75 apply (Lext (XminConst (PartialFunctionCast f) 1)).
76 split. split.
77 intros x xD. exact xD.
78 intros x xD. exact xD.
79 intros. simpl. unfold CRcast.
80 rewrite CRmorph_min. apply CRmin_morph.
81 apply CRmorph_proper, DomainProp.
82 symmetry. apply CRmorph_one. apply LminOneStable, X.
83 - intros. destruct el.
84 apply (Lext (Xscale (CRcast a) (PartialFunctionCast f))).
85 split. split.
86 intros x xD. exact xD.
87 intros x xD. exact xD.
88 intros. simpl. unfold CRcast. rewrite <- CRmorph_mult.
89 apply CRmorph_proper. apply CRmult_morph. reflexivity. apply DomainProp.
90 apply LscaleStable, X.
91 Defined.
92
93
94 Lemma IadditiveCast
95 : forall (IS : IntegrationSpace) {R : ConstructiveReals}
96 (f g : PartialFunction (X (FunctionRieszSpaceCast (ElemFunc IS))))
97 (fL : L (FunctionRieszSpaceCast (ElemFunc IS)) f)
98 (gL : L (FunctionRieszSpaceCast (ElemFunc IS)) g),
99 CRcast (I IS (PartialFunctionCast (Xplus f g))
100 (LplusStable (@FunctionRieszSpaceCast R (ElemFunc IS)) f g fL gL)) ==
101 CRcast (I IS (PartialFunctionCast f) fL) +
102 @CRcast (RealT (ElemFunc IS)) R (I IS (PartialFunctionCast g) gL).
103 Proof.
104 intros. unfold CRcast.
105 rewrite <- CRmorph_plus. apply CRmorph_proper.
106 rewrite <- (Iadditive IS). apply IExtensional.
107 intros. simpl. destruct xF, y.
108 unfold CRcast. rewrite <- CRmorph_plus. apply CRmorph_proper.
109 apply CRplus_morph; apply DomainProp.
110 Qed.
111
112 Lemma IhomogeneousCast
113 : forall (IS : IntegrationSpace) {R : ConstructiveReals}
114 (a : CRcarrier (RealT (FunctionRieszSpaceCast (ElemFunc IS))))
115 (f : PartialFunction (X (FunctionRieszSpaceCast (ElemFunc IS))))
116 (fL : L (FunctionRieszSpaceCast (ElemFunc IS)) f),
117 CRcast (I IS (PartialFunctionCast (Xscale a f))
118 (LscaleStable (@FunctionRieszSpaceCast R (ElemFunc IS)) a f fL))
119 == a * CRcast (I IS (PartialFunctionCast f) fL).
120 Proof.
121 intros. unfold CRcast.
122 rewrite (CRmorph_proper
123 _
124 (I IS (PartialFunctionCast (Xscale a f))
125 (LscaleStable (FunctionRieszSpaceCast (ElemFunc IS)) a f fL))
126 (CRcast a * I IS (PartialFunctionCast f) fL)).
127 rewrite CRmorph_mult. apply CRmult_morph.
128 unfold CRcast.
129 simpl in a.
130 transitivity (CRmorph (CRmorph_compose
131 (@SlowConstructiveRealsMorphism (RealT (FunctionRieszSpaceCast (ElemFunc IS)))
132 (RealT (ElemFunc IS)))
133 (@SlowConstructiveRealsMorphism (RealT (ElemFunc IS)) R)
134 ) a).
135 unfold CRmorph_compose, CRmorph. reflexivity.
136 apply Endomorph_id.
137 reflexivity. rewrite <- (Ihomogeneous IS).
138 apply IExtensional. intros. simpl.
139 unfold CRcast. rewrite <- CRmorph_mult. apply CRmorph_proper.
140 apply CRmult_morph. reflexivity. apply DomainProp.
141 Qed.
142
143 Lemma LElemFuncCastReverse : forall (E : FunctionRieszSpace) {R : ConstructiveReals}
144 (f : PartialFunction (X E)),
145 L E f
146 -> L (@FunctionRieszSpaceCast R E) (PartialFunctionCast f).
147 Proof.
148 intros E R f fL. simpl.
149 apply (Lext _ f). split. split.
150 intros x xD. exact xD.
151 intros x xD. exact xD.
152 intros. simpl. unfold CRcast.
153 transitivity (CRmorph (CRmorph_compose
154 (@SlowConstructiveRealsMorphism (RealT E) R)
155 (@SlowConstructiveRealsMorphism (RealT (FunctionRieszSpaceCast E))
156 (RealT E))
157 ) (partialApply f x xG)).
158 rewrite Endomorph_id. apply DomainProp. reflexivity.
159 apply fL.
160 Qed.
161
162 Lemma IcontinuousCast : forall (IS : IntegrationSpace) {R : ConstructiveReals},
163 ElemIntegralContinuous
164 (fun (f : PartialFunction (X (FunctionRieszSpaceCast (ElemFunc IS))))
165 (fL : L (@FunctionRieszSpaceCast R (ElemFunc IS)) f) =>
166 CRcast (I IS (PartialFunctionCast f) fL)).
167 Proof.
168 intros IS R f fn fL fnL fnPos [l [lcv lmaj]].
169 destruct (Icontinuous
170 IS (PartialFunctionCast f) (fun n => PartialFunctionCast (fn n))
171 fL fnL).
172 - intros n x xdf. simpl. unfold CRcast.
173 rewrite <- (CRmorph_zero (@SlowConstructiveRealsMorphism R (RealT (ElemFunc IS)))).
174 apply CRmorph_le, fnPos.
175 - exists (CRcast l). split.
176 apply (series_cv_eq
177 (fun n => (CRmorph (CRmorph_compose
178 (@SlowConstructiveRealsMorphism (RealT (ElemFunc IS)) R)
179 (@SlowConstructiveRealsMorphism (RealT (FunctionRieszSpaceCast (ElemFunc IS)))
180 (RealT (ElemFunc IS)))
181 ) (I IS (PartialFunctionCast (fn n)) (fnL n))))).
182 intro n. apply Endomorph_id.
183 unfold CRmorph_compose, CRmorph. apply CRmorph_series_cv, lcv.
184 rewrite <- (Endomorph_id
185 (CRmorph_compose
186 (@SlowConstructiveRealsMorphism (RealT (ElemFunc IS)) R)
187 (@SlowConstructiveRealsMorphism (RealT (FunctionRieszSpaceCast (ElemFunc IS)))
188 (RealT (ElemFunc IS)))
189 )
190 (I IS (PartialFunctionCast f) fL)).
191 unfold CRcast. unfold CRmorph_compose, CRmorph.
192 apply CRmorph_increasing. exact lmaj.
193 - destruct x. simpl in s.
194 exists (Build_CommonPointFunSeq _ _ f fn cpx cpxF cpxFn).
195 simpl. destruct s. exists (CRcast x). split.
196 apply (series_cv_eq
197 (fun n => (CRmorph (CRmorph_compose
198 (@SlowConstructiveRealsMorphism (RealT (FunctionRieszSpaceCast (ElemFunc IS)))
199 (RealT (ElemFunc IS)))
200 (@SlowConstructiveRealsMorphism (RealT (ElemFunc IS)) R)
201 ) (partialApply (fn n) cpx (cpxFn n))))).
202 intro n. apply Endomorph_id.
203 unfold CRmorph_compose, CRmorph. apply CRmorph_series_cv, p.
204 rewrite <- (Endomorph_id
205 (CRmorph_compose
206 (@SlowConstructiveRealsMorphism (RealT (FunctionRieszSpaceCast (ElemFunc IS)))
207 (RealT (ElemFunc IS)))
208 (@SlowConstructiveRealsMorphism (RealT (ElemFunc IS)) R)
209 )
210 (partialApply f cpx cpxF)).
211 unfold CRcast. unfold CRmorph_compose, CRmorph.
212 apply CRmorph_increasing. apply p.
213 Qed.
214
215 Definition IntegrationSpaceCast {R : ConstructiveReals}
216 : IntegrationSpace -> IntegrationSpace.
217 Proof.
218 intro IS.
219 apply (Build_IntegrationSpace
220 (@FunctionRieszSpaceCast R (ElemFunc IS))
221 (fun f fL => CRcast (I IS (PartialFunctionCast f) fL))
222 (IadditiveCast IS) (IhomogeneousCast IS)
223 (@PartialFunctionCast _ R _ (Ione IS))
224 (LElemFuncCastReverse _ _ (IoneL IS))).
225 - unfold CRcast.
226 rewrite (CRmorph_proper _ (I IS (PartialFunctionCast (PartialFunctionCast (Ione IS))) (LElemFuncCastReverse _ _ (IoneL IS))) 1).
227 apply CRmorph_one.
228 rewrite <- IoneInt. apply IExtensional. intros.
229 simpl.
230 transitivity (CRmorph (CRmorph_compose
231 (@SlowConstructiveRealsMorphism (RealT (ElemFunc IS)) R)
232 (@SlowConstructiveRealsMorphism (RealT (FunctionRieszSpaceCast (ElemFunc IS)))
233 (RealT (ElemFunc IS)))
234 ) (partialApply (Ione IS) x xF)).
235 unfold CRmorph_compose, CRmorph; reflexivity.
236 rewrite Endomorph_id. apply DomainProp.
237 - exact (IcontinuousCast IS).
238 - intros.
239 pose proof (Ilimit IS (PartialFunctionCast f) fL) as [H H0].
240 split. clear H0. apply CRmorph_cv.
241 simpl. simpl in H. simpl in fL, f.
242 apply (CR_cv_eq _ (fun n : nat =>
243 I IS (XminConst (PartialFunctionCast f) (INR n))
244 (LminIntStable n (PartialFunctionCast f) fL))).
245 2: exact H.
246 intro n. apply IExtensional. intros.
247 simpl. unfold CRcast. rewrite CRmorph_min. apply CRmin_morph.
248 apply CRmorph_proper, DomainProp. rewrite CRmorph_INR. reflexivity.
249 apply (CR_cv_proper _ (@CRcast (RealT (ElemFunc IS)) R 0) 0).
250 2: apply CRmorph_zero.
251 apply CRmorph_cv.
252 apply (CR_cv_eq _ (fun n : nat =>
253 I IS
254 (XminConst (Xabs (PartialFunctionCast f))
255 (CR_of_Q (RealT (ElemFunc IS)) (1 # Pos.of_nat (S n))))
256 (LminConstStable (CR_of_Q (RealT (ElemFunc IS)) (1 # Pos.of_nat (S n)))
257 (Xabs (PartialFunctionCast f)) (invSuccRealPositive n)
258 (LabsStable (ElemFunc IS) (PartialFunctionCast f) fL)))).
259 2: exact H0.
260 intro n. apply IExtensional. intros. simpl.
261 unfold CRcast. rewrite CRmorph_min. apply CRmin_morph.
262 rewrite CRmorph_abs. apply CRmorph_proper, CRabs_morph, DomainProp.
263 symmetry. apply CRmorph_rat.
264 Defined.
265
266 Definition IntegrableFunctionCast {IS : IntegrationSpace} {R : ConstructiveReals}
267 (f : PartialFunction (X (ElemFunc IS)))
268 : IntegrableFunction f
269 -> @IntegrableFunction (@IntegrationSpaceCast R IS)
270 (@PartialFunctionCast (RealT (ElemFunc IS)) R _ f).
271 Proof.
272 intros fInt. destruct fInt, x.
273 assert (series_cv
274 (fun k : nat =>
275 @Iabs (@IntegrationSpaceCast R IS)
276 (@PartialFunctionCast _ R _ (IntFn k))
277 (LElemFuncCastReverse (ElemFunc IS) (IntFn k) (IntFnL k)))
278 (CRcast IntAbsSum)).
279 { apply CRmorph_series_cv.
280 apply (series_cv_eq (fun k : nat => Iabs (IntFn k) (IntFnL k))).
281 2: exact IntAbsSumCv. intro n. apply IExtensional.
282 intros. simpl. unfold CRcast. rewrite <- CRmorph_abs.
283 apply CRabs_morph.
284 transitivity (CRmorph
285 (CRmorph_compose
286 (@SlowConstructiveRealsMorphism (RealT (ElemFunc IS)) R)
287 (@SlowConstructiveRealsMorphism (RealT (FunctionRieszSpaceCast (ElemFunc IS)))
288 (RealT (ElemFunc IS))))
289 (partialApply (IntFn n) x y)).
290 rewrite Endomorph_id. apply DomainProp. reflexivity. }
291 exists (Build_IntegralRepresentation
292 (@IntegrationSpaceCast R IS)
293 (fun n => @PartialFunctionCast (RealT (ElemFunc IS)) R _ (IntFn n))
294 (fun n => LElemFuncCastReverse _ _ (IntFnL n))
295 (CRcast IntAbsSum) H).
296 simpl. simpl in p.
297 assert (@DomainInclusion R _
298 (XinfiniteSumAbs (fun n : nat => PartialFunctionCast (IntFn n)))
299 (PartialFunctionCast (XinfiniteSumAbs IntFn)))
300 as incCast.
301 { intros y ydf. simpl. simpl in ydf.
302 destruct ydf. exists x. unfold CRcast in c.
303 apply (CRmorph_cauchy_reverse
304 (@SlowConstructiveRealsMorphism (RealT (ElemFunc IS)) R)).
305 apply (CR_cauchy_eq (CRsum
306 (fun n : nat =>
307 CRabs R
308 (CRmorph (@SlowConstructiveRealsMorphism (RealT (ElemFunc IS)) R)
309 (partialApply (IntFn n) y (x n)))))).
310 2: exact c. intro n.
311 rewrite CRmorph_sum. apply CRsum_eq.
312 intros. rewrite CRmorph_abs. reflexivity. }
313 split. simpl.
314 - intros y ydf. simpl. specialize (incCast y). destruct p.
315 apply d. apply incCast. exact ydf.
316 - intros. destruct p.
317 specialize (c x (incCast x xD) xG).
318 simpl. apply applyInfiniteSumAbs in c.
319 destruct xD. symmetry. apply series_cv_abs_eq.
320 apply CRmorph_series_cv.
321 apply (series_cv_eq (fun n : nat =>
322 partialApply (IntFn n) x
323 (domainInfiniteSumAbsIncReverse IntFn x
324 (incCast x
325 (existT _ x0 c0)) n))).
326 2: exact c. intro n. apply DomainProp.
327 Defined.
328
329 Lemma IntegralFunctionCast
330 : forall {IS : IntegrationSpace} {R : ConstructiveReals}
331 (f : PartialFunction (X (ElemFunc IS)))
332 (fInt : IntegrableFunction f),
333 Integral (@IntegrableFunctionCast IS R f fInt)
334 == CRcast (Integral fInt).
335 Proof.
336 intros. unfold Integral.
337 apply (series_cv_unique _ _ _ (IntegralCv
338 (let (i, _) := IntegrableFunctionCast f fInt in i))).
339 apply CRmorph_series_cv.
340 apply (series_cv_eq (fun n : nat =>
341 I IS (IntFn (let (i, _) := fInt in i) n) (IntFnL (let (i, _) := fInt in i) n))).
342 2: exact (IntegralCv (let (i, _) := fInt in i)). intro n.
343 apply IExtensional. intros. destruct fInt, x0.
344 unfold IntegrableFunctionCast, CMTIntegrableFunctions.IntFn.
345 simpl. unfold CRcast.
346 transitivity (CRmorph
347 (CRmorph_compose
348 (@SlowConstructiveRealsMorphism (RealT (ElemFunc IS)) R)
349 (@SlowConstructiveRealsMorphism (RealT (FunctionRieszSpaceCast (ElemFunc IS)))
350 (RealT (ElemFunc IS))))
351 (partialApply (IntFn n) x y)).
352 rewrite Endomorph_id. apply DomainProp. reflexivity.
353 Qed.