Debian Codegraph @

reals/stdlib/CMTProductIntegral.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 (** Product of two integration spaces and Fubini's theorem.
13
14 As a naive approach, we can think of taking linear combinations of
15 products of integrable functions as L-functions, and I linear.
16 However this fails to be stable stability under absolute value.
17 We work around this problem by taking products of integrable
18 characteristic functions, which linear combinations can be split
19 on disjoint rectangles. Then we can take the absolute of those
20 disjoint coefficients. *)
21
22 From Coq Require Import ZArith QArith_base.
23 From Coq Require Import List.
24 From Coq Require Import ConstructiveReals.
25 From Coq Require Import ConstructiveRealsMorphisms.
26 From Coq Require Import ConstructiveAbs.
27 From Coq Require Import ConstructiveSum.
28 From Coq Require Import ConstructiveMinMax.
29 From Coq Require Import ConstructiveLimits.
30 Require Import ConstructivePartialFunctions.
31 Require Import CMTbase.
32 Require Import CMTIntegrableFunctions.
33 Require Import CMTIntegrableSets.
34 Require Import CMTFullSets.
35 Require Import CMTcast.
36 Require Import CMTprofile.
37
38 Local Open Scope ConstructiveReals.
39
40
41
42 (* An element of a product L-function, ie a product of integrable sets,
43 multiplied by a real number. Its elementary integral is the product
44 of measures, multiplied by the real number. *)
45 Record ProdIntegrable {I J : IntegrationSpace} : Type :=
46 { prodint_f : X (ElemFunc I) -> Prop;
47 prodint_g : X (ElemFunc J) -> Prop;
48 prodint_factor : CRcarrier (RealT (ElemFunc I));
49 prodint_fint : IntegrableSet prodint_f;
50 prodint_gint : IntegrableSet prodint_g;
51 }.
52
53 (* Tensor product of prodint_f and prodint_g. *)
54 Definition ProdIntegrableFunc {I J : IntegrationSpace}
55 (fg : @ProdIntegrable I J)
56 : @PartialFunction (RealT (ElemFunc I)) (* Convert in the first real type. *)
57 (prod (X (ElemFunc I)) (X (ElemFunc J))).
58 Proof.
59 apply (Build_PartialFunctionXY
60 (prod (X (ElemFunc I)) (X (ElemFunc J)))
61 (CRcarrier (RealT (ElemFunc I))) (CReq (RealT (ElemFunc I)))
62 (* This domain is smaller than just deciding the rectangle,
63 because we decide both coordinates. It is necessary
64 to subdivide a union of rectangles into a disjoint
65 grid of rectangles. See ProdIntegrableSimplify below. *)
66 (fun xy => prod (Domain (CharacFunc (prodint_f fg)) (fst xy))
67 (Domain (@CharacFunc (RealT (ElemFunc I)) _ (prodint_g fg)) (snd xy)))
68 (fun xy xyD => prodint_factor fg
69 * partialApply _ (fst xy) (fst xyD)
70 * partialApply _ (snd xy) (snd xyD))).
71 intros [x y] p q. destruct p,q; simpl.
72 do 2 rewrite CRmult_assoc. apply CRmult_morph.
73 reflexivity. destruct d,d0,d1,d2; try reflexivity; try contradiction.
74 Defined.
75
76 (* A product L-function, ie a linear combination of ProdIntegrable. *)
77 Definition ProdLFunc {I J : IntegrationSpace}
78 : list (@ProdIntegrable I J)
79 -> PartialFunction (prod (X (ElemFunc I)) (X (ElemFunc J)))
80 := fun l => XsumList (map ProdIntegrableFunc l).
81
82 Definition ProdIntegrableZero (I J : IntegrationSpace)
83 : @ProdIntegrable I J.
84 Proof.
85 apply (Build_ProdIntegrable
86 I J (fun x => False) (fun y => False) 0).
87 - apply (IntegrableFunctionExtensional
88 (Xconst (X (ElemFunc I)) 0)).
89 split.
90 + intros x _. right. intro abs. contradiction.
91 + intros. simpl. destruct xG. contradiction. reflexivity.
92 + apply IntegrableZero.
93 - apply (IntegrableFunctionExtensional
94 (Xconst (X (ElemFunc J)) 0)).
95 split.
96 + intros x _. right. intro abs. contradiction.
97 + intros. simpl. destruct xG. contradiction. reflexivity.
98 + apply IntegrableZero.
99 Defined.
100
101 Lemma DomainProdLFuncInc
102 : forall {I J : IntegrationSpace}
103 (hn : list (@ProdIntegrable I J))
104 (x : X (ElemFunc I)) (y : X (ElemFunc J))
105 (xyS : Domain (ProdLFunc hn) (x,y))
106 (n : nat),
107 lt n (length hn)
108 -> Domain (ProdIntegrableFunc (nth n hn (ProdIntegrableZero I J))) (x,y).
109 Proof.
110 induction hn.
111 - intros. exfalso; inversion H.
112 - intros. simpl in H. destruct n.
113 + apply xyS.
114 + apply le_S_n in H. simpl. apply (IHhn x y).
115 apply xyS. exact H.
116 Qed.
117
118 Lemma DomainProdLFuncIncReverse
119 : forall {I J : IntegrationSpace}
120 (hn : list (@ProdIntegrable I J))
121 (x : X (ElemFunc I)) (y : X (ElemFunc J)),
122 (forall n:nat, lt n (length hn)
123 -> Domain (ProdIntegrableFunc (nth n hn (ProdIntegrableZero I J))) (x,y))
124 -> Domain (ProdLFunc hn) (x,y).
125 Proof.
126 induction hn.
127 - intros. simpl. trivial.
128 - intros x y H. split.
129 + apply (H O). apply le_n_S, Nat.le_0_l.
130 + apply IHhn. intros. apply le_n_S in H0.
131 exact (H (S n) H0).
132 Qed.
133
134 Lemma DomainProdLFuncAppLeft
135 : forall {I J : IntegrationSpace}
136 (l k : list (@ProdIntegrable I J))
137 (x : X (ElemFunc I)) (y : X (ElemFunc J)),
138 Domain (ProdLFunc (l ++ k)) (x,y)
139 -> Domain (ProdLFunc l) (x, y).
140 Proof.
141 induction l.
142 - intros. simpl. trivial.
143 - intros k x y H. destruct H. split. exact d.
144 exact (IHl k x y d0).
145 Qed.
146
147 Lemma DomainProdLFuncAppRight
148 : forall {I J : IntegrationSpace}
149 (l k : list (@ProdIntegrable I J))
150 (x : X (ElemFunc I)) (y : X (ElemFunc J)),
151 Domain (ProdLFunc (l ++ k)) (x,y)
152 -> Domain (ProdLFunc k) (x, y).
153 Proof.
154 induction l.
155 - intros l x y H. exact H.
156 - intros k x y H. destruct H.
157 exact (IHl k x y d0).
158 Qed.
159
160 Lemma ApplyProdLFuncApp
161 : forall {I J : IntegrationSpace}
162 (l k : list (@ProdIntegrable I J))
163 (x : X (ElemFunc I)) (y : X (ElemFunc J))
164 (xyL : Domain (ProdLFunc l) (x,y))
165 (xyK : Domain (ProdLFunc k) (x,y))
166 (xyDS : Domain (ProdLFunc (l ++ k)) (x,y)),
167 partialApply (ProdLFunc (l ++ k)) (x, y) xyDS
168 == partialApply (ProdLFunc l) (x,y) xyL
169 + partialApply (ProdLFunc k) (x,y) xyK.
170 Proof.
171 induction l as [|a l].
172 - intros. simpl (partialApply (ProdLFunc nil) (x, y) xyL).
173 rewrite CRplus_0_l. apply DomainProp.
174 - intros. simpl. destruct xyDS, d, xyL, d2. simpl.
175 rewrite CRplus_assoc. apply CRplus_morph.
176 + destruct d. destruct d2. 2: contradiction.
177 destruct d1. destruct d4. 2: contradiction. reflexivity.
178 destruct d4. contradiction. reflexivity.
179 rewrite CRmult_0_r, CRmult_0_l.
180 destruct d2. contradiction.
181 rewrite CRmult_0_r, CRmult_0_l. reflexivity.
182 + apply IHl.
183 Qed.
184
185
186 (* A product L-function is simple when its sum is on disjoint rectangles.
187 But more convenient to sum on a disjoint grid. *)
188
189 (* Computes a list of size 2^n, of lists of size n,
190 with all possible combinations.
191 Will be used to sum on all subsets later.
192 We could also have used natural numbers to represent subset,
193 with their binary digits as the lists of bool. *)
194 Fixpoint FreeSubsets (n : nat) : list (list bool)
195 := match n with
196 | O => nil :: nil
197 | S p => map (fun l => true :: l) (FreeSubsets p)
198 ++ map (fun l => false :: l) (FreeSubsets p)
199 end.
200
201 Lemma FreeSubsetsNotNil : forall n : nat, FreeSubsets n <> nil.
202 Proof.
203 induction n.
204 - discriminate.
205 - simpl. intro abs. apply app_eq_nil in abs.
206 destruct abs. apply map_eq_nil in H. exact (IHn H).
207 Qed.
208
209 Lemma FreeSubsetsLength : forall (n : nat) (l : list bool),
210 In l (FreeSubsets n) -> length l = n.
211 Proof.
212 induction n.
213 - intros. destruct H. subst l. reflexivity.
214 exfalso; inversion H.
215 - intros. simpl in H. apply in_app_or in H. destruct H.
216 + apply in_map_iff in H. destruct H as [k [H H0]].
217 subst l. simpl. rewrite (IHn k). reflexivity. exact H0.
218 + apply in_map_iff in H. destruct H as [k [H H0]].
219 subst l. simpl. rewrite (IHn k). reflexivity. exact H0.
220 Qed.
221
222 (* Produce a membership proposition in sort Type.
223 This is actually the reading of l as the binary
224 digits of the number k. *)
225 Lemma FreeSubsetsFull : forall l : list bool,
226 { k : nat | lt k (length (FreeSubsets (length l)))
227 /\ nth k (FreeSubsets (length l)) nil = l }.
228 Proof.
229 induction l as [|a l].
230 - exists O. split. apply Nat.le_refl. reflexivity.
231 - simpl. destruct IHl as [k [H H0]]. destruct a.
232 + exists k. split. rewrite app_length, map_length, map_length.
233 apply (Nat.lt_le_trans _ (0+length (FreeSubsets (length l)))).
234 exact H. rewrite <- Nat.add_le_mono_r. apply Nat.le_0_l.
235 rewrite app_nth1.
236 rewrite (nth_indep _ nil (true::nil)), map_nth, H0.
237 reflexivity. rewrite map_length. exact H.
238 rewrite map_length. exact H.
239 + exists (k + length (FreeSubsets (length l)))%nat. split.
240 rewrite app_length, map_length, map_length.
241 rewrite <- Nat.add_lt_mono_r. exact H.
242 rewrite app_nth2. rewrite map_length, Nat.add_sub.
243 rewrite (nth_indep _ nil (false::nil)), map_nth, H0.
244 reflexivity. rewrite map_length. exact H.
245 rewrite map_length.
246 apply (Nat.le_trans _ (0+length (FreeSubsets (length l)))).
247 apply Nat.le_refl. rewrite <- Nat.add_le_mono_r. apply Nat.le_0_l.
248 Qed.
249
250 Lemma FreeSubsetsDifferent : forall (n p q : nat),
251 p <> q
252 -> lt p (length (FreeSubsets n))
253 -> lt q (length (FreeSubsets n))
254 -> nth p (FreeSubsets n) nil <> nth q (FreeSubsets n) nil.
255 Proof.
256 induction n.
257 - intros. exfalso. simpl in H0. simpl in H1.
258 destruct p,q. exact (H eq_refl). apply le_S_n in H1.
259 inversion H1. apply le_S_n in H0. inversion H0.
260 apply le_S_n in H1. inversion H1.
261 - intros. simpl.
262 destruct (le_lt_dec (length (FreeSubsets n)) p),
263 (le_lt_dec (length (FreeSubsets n)) q).
264 + rewrite app_nth2.
265 2: rewrite map_length; exact l.
266 rewrite app_nth2.
267 2: rewrite map_length; exact l0.
268 rewrite map_length.
269 assert (q - length (FreeSubsets n) < length (FreeSubsets n))%nat.
270 { rewrite (Nat.add_lt_mono_r _ _ (length (FreeSubsets n))).
271 rewrite Nat.sub_add. 2: exact l0. simpl in H1.
272 rewrite app_length, map_length, map_length in H1. exact H1. }
273 assert (p - length (FreeSubsets n) < length (FreeSubsets n))%nat.
274 { rewrite (Nat.add_lt_mono_r _ _ (length (FreeSubsets n))).
275 rewrite Nat.sub_add. 2: exact l. simpl in H0.
276 rewrite app_length, map_length, map_length in H0. exact H0. }
277 specialize (IHn (p - length (FreeSubsets n))%nat
278 (q - length (FreeSubsets n))%nat).
279 rewrite (nth_indep _ nil (false::nil)), (nth_indep _ nil (false::nil)).
280 rewrite map_nth, map_nth.
281 2: rewrite map_length; exact H2.
282 2: rewrite map_length; exact H3.
283 intro abs. inversion abs. apply IHn. 2: exact H3. 2: exact H2.
284 2: exact H5.
285 intro abs2.
286 assert ((p - length (FreeSubsets n) + length (FreeSubsets n))%nat
287 = (q - length (FreeSubsets n) + length (FreeSubsets n))%nat).
288 { rewrite abs2. reflexivity. }
289 do 2 rewrite Nat.sub_add in H4. contradiction.
290 exact l0. exact l. exact l.
291 + clear IHn. rewrite app_nth2.
292 2: rewrite map_length; exact l.
293 rewrite app_nth1.
294 2: rewrite map_length; exact l0.
295 rewrite map_length.
296 rewrite (nth_indep _ nil (false::nil)), (nth_indep _ nil (true::nil)).
297 rewrite map_nth, map_nth. intro abs. inversion abs.
298 rewrite map_length. exact l0. rewrite map_length.
299 rewrite (Nat.add_lt_mono_r _ _ (length (FreeSubsets n))).
300 rewrite Nat.sub_add. 2: exact l. simpl in H0.
301 rewrite app_length, map_length, map_length in H0. exact H0.
302 + clear IHn. rewrite app_nth1.
303 2: rewrite map_length; exact l.
304 rewrite app_nth2.
305 2: rewrite map_length; exact l0.
306 rewrite map_length.
307 rewrite (nth_indep _ nil (true::nil)), (nth_indep _ nil (false::nil)).
308 rewrite map_nth, map_nth. intro abs. inversion abs.
309 rewrite map_length.
310 rewrite (Nat.add_lt_mono_r _ _ (length (FreeSubsets n))).
311 rewrite Nat.sub_add. 2: exact l0. simpl in H1.
312 rewrite app_length, map_length, map_length in H1. exact H1.
313 rewrite map_length. exact l.
314 + rewrite app_nth1.
315 2: rewrite map_length; exact l.
316 rewrite app_nth1.
317 2: rewrite map_length; exact l0.
318 rewrite (nth_indep _ nil (true::nil)), (nth_indep _ nil (true::nil)).
319 rewrite map_nth, map_nth.
320 intro abs. inversion abs. apply (IHn p q H l l0). exact H3.
321 rewrite map_length. exact l0.
322 rewrite map_length. exact l.
323 Qed.
324
325 Definition ProdIntegrableDisjoint
326 {I J : IntegrationSpace}
327 (h k : ProdIntegrable) : Prop
328 := forall (x : X (ElemFunc I)) (y : X (ElemFunc J)),
329 ~(prodint_f h x /\ prodint_f k x /\ prodint_g h y /\ prodint_g k y).
330
331 (* Equivalent to forall i,j < length l, i < j -> P (l i) (l j) *)
332 Fixpoint forall_disjoint_pairs { X : Type } (l : list X) (P : X -> X -> Prop) : Prop
333 := match l with
334 | nil => True
335 | h::t => forall_disjoint_pairs t P /\ Forall (P h) t
336 end.
337
338 Lemma forall_disjoint_pairs_equiv
339 : forall { X : Type } (l : list X) (P : X -> X -> Prop) (x : X),
340 (forall i j : nat, lt i j -> lt j (length l)
341 -> P (nth i l x) (nth j l x))
342 -> forall_disjoint_pairs l P.
343 Proof.
344 induction l.
345 - intros. constructor.
346 - intros. split.
347 + apply (IHl P x). intros.
348 apply (H (S i) (S j)). apply le_n_S, H0.
349 apply le_n_S, H1.
350 + clear IHl. apply Forall_forall. intros.
351 apply (In_nth _ _ a) in H0. destruct H0 as [n [H0 H1]].
352 subst x0. specialize (H O (S n)). simpl in H.
353 rewrite (nth_indep _ a x). apply H.
354 apply le_n_S, Nat.le_0_l. apply le_n_S, H0. exact H0.
355 Qed.
356
357 Definition ProdIntegrableSimple
358 {I J : IntegrationSpace}
359 (hn : list (@ProdIntegrable I J)) : Prop
360 := forall_disjoint_pairs hn ProdIntegrableDisjoint.
361
362 Definition SubsetUnion {A : Set}
363 (hn : list (A -> Prop))
364 : A -> Prop
365 := fold_right (fun fg acc x => fg x \/ acc x) (fun x => False) hn.
366
367 Lemma SubsetUnionLeftDec
368 : forall {I J : IntegrationSpace}
369 (hn : list (@ProdIntegrable I J))
370 (x : X (ElemFunc I)) (y : X (ElemFunc J))
371 (xyH : Domain (ProdLFunc hn) (x,y)),
372 (SubsetUnion (map prodint_f hn) x /\ ~Forall (fun fg => ~prodint_f fg x) hn)
373 \/ (Forall (fun fg => ~prodint_f fg x) hn /\ ~SubsetUnion (map prodint_f hn) x).
374 Proof.
375 induction hn.
376 - intros. right. split. apply Forall_nil.
377 intro abs. exact abs.
378 - intros. destruct xyH. destruct (IHhn x y d0).
379 + left. split. right. apply H. intro abs.
380 inversion abs. destruct H. contradiction.
381 + simpl. destruct d, d. left. split. left. exact p.
382 intro abs. inversion abs. destruct H. contradiction.
383 right. split. apply Forall_cons. exact n.
384 apply H. intro abs. destruct abs.
385 contradiction. destruct H. contradiction.
386 Qed.
387
388 (* Intersection of init and hn,
389 inside or outside according to filter. *)
390 Fixpoint SubsetIntersectFilter { A : Set }
391 (hn : list (A -> Prop))
392 (init : A -> Prop)
393 (filter : list bool)
394 : A -> Prop
395 := match filter with
396 | nil => init
397 | b :: sub => match hn with
398 | nil => init
399 | p :: h => if b then
400 fun x => p x /\ SubsetIntersectFilter h init sub x
401 else
402 fun x => SubsetIntersectFilter h init sub x /\ ~p x
403 end
404 end.
405
406 Lemma SubsetIntersectFilterInc
407 : forall { A : Set }
408 (hn : list (A -> Prop))
409 (init biginit : A -> Prop)
410 (filter : list bool) (x : A),
411 (forall y:A, init y -> biginit y)
412 -> SubsetIntersectFilter hn init filter x
413 -> SubsetIntersectFilter hn biginit filter x.
414 Proof.
415 induction hn.
416 - intros. simpl. simpl in H0. destruct filter.
417 apply H, H0. apply H, H0.
418 - intros. destruct filter. simpl. apply H, H0.
419 simpl. simpl in H0. destruct b. split. apply H0.
420 apply (IHhn init). exact H. apply H0.
421 split. apply (IHhn init). exact H. apply H0.
422 intro abs. destruct H0. contradiction.
423 Qed.
424
425 Definition SubsetIntersectLeft
426 {I J : IntegrationSpace}
427 (hn : list (@ProdIntegrable I J))
428 (init : X (ElemFunc I) -> Prop)
429 (filter : list bool)
430 : X (ElemFunc I) -> Prop
431 := SubsetIntersectFilter (map prodint_f hn) init filter.
432
433 Lemma SubsetIntersectFilter_init
434 : forall { A : Set }
435 (hn : list (A -> Prop)) (init : A -> Prop)
436 (filter : list bool) (x : A),
437 SubsetIntersectFilter hn init filter x
438 -> init x.
439 Proof.
440 induction hn.
441 - intros. destruct filter; exact H.
442 - intros. destruct filter. exact H. simpl in H.
443 destruct b; apply (IHhn init filter), H.
444 Qed.
445
446 Lemma SubsetUnionLeftIntegrable
447 : forall {I J : IntegrationSpace}
448 (hn : list (@ProdIntegrable I J)),
449 IntegrableSet (SubsetUnion (map prodint_f hn)).
450 Proof.
451 induction hn.
452 - apply (IntegrableFunctionExtensional
453 (Xconst (X (ElemFunc I)) 0)).
454 split.
455 + intros x _. right. intro abs. contradiction.
456 + intros. simpl. destruct xG. contradiction. reflexivity.
457 + apply IntegrableZero.
458 - apply IntegrableSetUnion. apply a. apply IHhn.
459 Qed.
460
461 Lemma SubsetIntersectLeftIntegrable
462 : forall {I J : IntegrationSpace}
463 (subset : list bool) (init : X (ElemFunc I) -> Prop)
464 (hn : list (@ProdIntegrable I J)),
465 IntegrableSet init
466 -> IntegrableSet (SubsetIntersectLeft hn init subset).
467 Proof.
468 induction subset as [|a subset].
469 - intros init hn initInt. destruct hn; exact initInt.
470 - intros. simpl. destruct hn as [|p hn].
471 exact X. destruct a. apply IntegrableSetIntersect. apply p.
472 apply IHsubset. exact X. apply IntegrableSetDifference.
473 apply IHsubset. exact X. apply p.
474 Qed.
475
476 Lemma SubsetUnionRightDec
477 : forall {I J : IntegrationSpace}
478 (hn : list (@ProdIntegrable I J))
479 (x : X (ElemFunc I)) (y : X (ElemFunc J))
480 (xyH : Domain (ProdLFunc hn) (x,y)),
481 (SubsetUnion (map prodint_g hn) y /\ ~Forall (fun fg => ~prodint_g fg y) hn)
482 \/ (Forall (fun fg => ~prodint_g fg y) hn /\ ~SubsetUnion (map prodint_g hn) y).
483 Proof.
484 induction hn.
485 - intros. right. split. apply Forall_nil.
486 intro abs. exact abs.
487 - intros. destruct xyH. destruct (IHhn x y d0).
488 + left. split. right. apply H.
489 intro abs. inversion abs. destruct H. contradiction.
490 + simpl. destruct d, d1. left. split.
491 left. exact p. intro abs.
492 inversion abs. destruct H. contradiction.
493 right. split. apply Forall_cons. exact n. apply H.
494 intro abs. destruct abs. contradiction. destruct H. contradiction.
495 Qed.
496
497 Definition SubsetIntersectRight
498 {I J : IntegrationSpace}
499 (hn : list (@ProdIntegrable I J))
500 (init : X (ElemFunc J) -> Prop)
501 (filter : list bool)
502 : X (ElemFunc J) -> Prop
503 := SubsetIntersectFilter (map prodint_g hn) init filter.
504
505 Lemma SubsetUnionRightIntegrable
506 : forall {I J : IntegrationSpace}
507 (hn : list (@ProdIntegrable I J)),
508 IntegrableSet (SubsetUnion (map prodint_g hn)).
509 Proof.
510 induction hn.
511 - apply (IntegrableFunctionExtensional
512 (Xconst (X (ElemFunc J)) 0)).
513 split.
514 + intros x _. right. intro abs. contradiction.
515 + intros. simpl. destruct xG. contradiction. reflexivity.
516 + apply IntegrableZero.
517 - apply IntegrableSetUnion. apply a. apply IHhn.
518 Qed.
519
520 Lemma SubsetIntersectRightIntegrable
521 : forall {I J : IntegrationSpace}
522 (subset : list bool) (init : X (ElemFunc J) -> Prop)
523 (hn : list (@ProdIntegrable I J)),
524 IntegrableSet init
525 -> IntegrableSet (SubsetIntersectRight hn init subset).
526 Proof.
527 induction subset as [|a subset].
528 - intros init hn initInt. destruct hn; exact initInt.
529 - intros. simpl. destruct hn as [|p hn].
530 exact X. destruct a. apply IntegrableSetIntersect. apply p.
531 apply IHsubset. exact X. apply IntegrableSetDifference.
532 apply IHsubset. exact X. apply p.
533 Qed.
534
535 (* Sum all factors that are activated by subsetf and subsetg. *)
536 Fixpoint SubsetIntersectFactor
537 {I J : IntegrationSpace}
538 (hn : list (@ProdIntegrable I J))
539 (subsetf subsetg : list bool) {struct subsetf}
540 : CRcarrier (RealT (ElemFunc I))
541 := match subsetf, subsetg, hn with
542 | sf::tf, sg::tg, h::t
543 => SubsetIntersectFactor t tf tg
544 + (if andb sf sg then prodint_factor h else 0)
545 | _, _, _ => 0
546 end.
547
548 (* If subsetf or subsetg is all false, the intersection of the
549 corresponding complements can be not integrable. Bound it
550 by the union of the subsets. *)
551 Definition ProdSubsetIntersect
552 {I J : IntegrationSpace}
553 (hn : list (@ProdIntegrable I J))
554 (subsetf subsetg : list bool)
555 : @ProdIntegrable I J.
556 Proof.
557 (* When the subsets are all false, it means the domain outside
558 all of hn which is not necessarily integrable, but then
559 it is assigned the coefficient zero. *)
560 intros.
561 apply (Build_ProdIntegrable
562 I J
563 (SubsetIntersectLeft hn (SubsetUnion (map prodint_f hn)) subsetf)
564 (SubsetIntersectRight hn (SubsetUnion (map prodint_g hn)) subsetg)
565 (SubsetIntersectFactor hn subsetf subsetg)).
566 apply SubsetIntersectLeftIntegrable.
567 apply SubsetUnionLeftIntegrable.
568 apply SubsetIntersectRightIntegrable.
569 apply SubsetUnionRightIntegrable.
570 Defined.
571
572 Lemma nth_list_prod : forall {A B : Type} (l:list A) (k:list B) (a:A) (b:B) (n:nat),
573 lt n (length l * length k)
574 -> nth n (list_prod l k) (a,b)
575 = (nth (n / length k) l a, nth (n mod (length k)) k b).
576 Proof.
577 induction l.
578 - intros. exfalso; inversion H.
579 - intros. destruct (le_lt_dec (length k) n).
580 + assert (n - length k < length l * length k)%nat.
581 { rewrite (Nat.add_lt_mono_r _ _ (length k)), Nat.sub_add.
582 2: exact l0. rewrite Nat.add_comm. exact H. }
583 specialize (IHl k a0 b (n - length k)%nat H0). clear H.
584 simpl (list_prod (a :: l) k).
585 rewrite app_nth2.
586 2: rewrite map_length; exact l0.
587 rewrite map_length. rewrite IHl.
588 pose proof (Nat.le_exists_sub (length k) n l0) as [i [H _]].
589 subst n. rewrite Nat.add_sub. apply f_equal2.
590 replace ((i + length k) / length k)%nat with (S (i / length k))%nat.
591 reflexivity. replace (i + length k)%nat with (i + 1*length k)%nat.
592 rewrite Nat.div_add. rewrite Nat.add_comm. reflexivity.
593 2: rewrite Nat.mul_1_l; reflexivity.
594 intro abs. rewrite Nat.add_sub, abs, Nat.mul_0_r in H0. inversion H0.
595 replace (i + length k)%nat with (i + 1*length k)%nat.
596 rewrite Nat.mod_add. reflexivity.
597 intro abs. rewrite Nat.add_sub, abs, Nat.mul_0_r in H0. inversion H0.
598 rewrite Nat.mul_1_l. reflexivity.
599 + clear IHl. simpl (list_prod (a :: l) k). rewrite app_nth1.
600 2: rewrite map_length; exact l0.
601 rewrite Nat.div_small, Nat.mod_small. 2: exact l0. 2: exact l0.
602 simpl. rewrite (nth_indep _ (a0,b) (a,b)).
603 rewrite map_nth. reflexivity. rewrite map_length. exact l0.
604 Qed.
605
606 Lemma DomainProdSubsetIntersect
607 : forall {A : Set}
608 (hn : list (A -> Prop))
609 (init : A -> Prop)
610 (l : list bool) (x : A) (n : nat),
611 SubsetIntersectFilter hn init l x
612 -> match nth_error hn n, nth_error l n with
613 | Some fg, Some b
614 => if b then fg x else ~fg x
615 | _, _ => True
616 end.
617 Proof.
618 induction hn.
619 - intros. destruct n; simpl; trivial.
620 - intros. destruct n.
621 + simpl. destruct l as [|b l]. trivial.
622 destruct b; apply H.
623 + simpl. destruct l as [|b l].
624 destruct (nth_error hn n); trivial. apply (IHhn init l).
625 simpl in H. destruct b; apply H.
626 Qed.
627
628 Lemma SubsetsDifferent : forall (h k : list bool),
629 length h = length k
630 -> h <> k
631 -> { n : nat | lt n (length h) /\ nth_error h n <> nth_error k n }.
632 Proof.
633 induction h.
634 - intros. exfalso. destruct k. exact (H0 eq_refl). inversion H.
635 - intros. destruct k. exfalso; inversion H. simpl in H.
636 inversion H. clear H. destruct a, b.
637 + destruct (IHh k H2) as [n [nlen ndiff]].
638 intro abs. subst k. exact (H0 eq_refl).
639 exists (S n). split. apply le_n_S, nlen. exact ndiff.
640 + exists O. split. apply le_n_S, Nat.le_0_l. simpl. discriminate.
641 + exists O. split. apply le_n_S, Nat.le_0_l. simpl. discriminate.
642 + destruct (IHh k H2) as [n [nlen ndiff]].
643 intro abs. subst k. exact (H0 eq_refl).
644 exists (S n). split. apply le_n_S, nlen. exact ndiff.
645 Qed.
646
647 Lemma ProdIntegrableSubsetsDisjoint
648 : forall {A : Set}
649 (hn : list (A -> Prop))
650 (l l0 : list bool)
651 (x : A),
652 length l = length l0
653 -> length l = length hn
654 -> l <> l0
655 -> ~ (SubsetIntersectFilter hn (SubsetUnion hn) l x
656 /\ SubsetIntersectFilter hn (SubsetUnion hn) l0 x).
657 Proof.
658 intros. simpl. intros [H2 H3].
659 pose proof (SubsetsDifferent l l0 H H1) as [n [nlen ndiff]].
660 pose proof (DomainProdSubsetIntersect
661 hn (SubsetUnion hn) l x n H2).
662 pose proof (DomainProdSubsetIntersect
663 hn (SubsetUnion hn) l0 x n H3).
664 destruct (nth_error hn n) eqn:des.
665 destruct (nth_error l n) eqn:desl. destruct (nth_error l0 n) eqn:des0.
666 destruct b. destruct b0. exact (ndiff eq_refl). contradiction.
667 destruct b0. contradiction. exact (ndiff eq_refl).
668 rewrite nth_error_None, <- H in des0.
669 exact (proj1 (Nat.lt_nge _ _) nlen des0).
670 rewrite nth_error_None in desl.
671 exact (proj1 (Nat.lt_nge _ _) nlen desl).
672 rewrite nth_error_None, <- H0 in des.
673 exact (proj1 (Nat.lt_nge _ _) nlen des).
674 Qed.
675
676 Definition ProdIntegrableSimplify
677 {I J : IntegrationSpace}
678 (hn : list (@ProdIntegrable I J))
679 : list (@ProdIntegrable I J)
680 := map (fun xy => ProdSubsetIntersect hn (fst xy) (snd xy))
681 (list_prod (FreeSubsets (length hn)) (FreeSubsets (length hn))).
682
683 Lemma nat_euclid_unique : forall i j q : nat,
684 lt 0 q
685 -> (i / q = j / q)%nat
686 -> i mod q = j mod q
687 -> i = j.
688 Proof.
689 intros. assert (q <> O).
690 { destruct q. exfalso; exact (Nat.lt_irrefl O H). discriminate. }
691 rewrite (Nat.div_mod j q H2), <- H1, <- H0.
692 apply Nat.div_mod, H2.
693 Qed.
694
695 Lemma ProdIntegrableSimplifyDisjoint
696 : forall {I J : IntegrationSpace}
697 (hn : list (@ProdIntegrable I J)),
698 ProdIntegrableSimple (ProdIntegrableSimplify hn).
699 Proof.
700 intros.
701 apply (forall_disjoint_pairs_equiv
702 _ _ (ProdSubsetIntersect hn (fst (nil,@nil bool))
703 (snd (@nil bool, nil)))).
704 intros.
705 unfold ProdIntegrableSimplify in H0. rewrite map_length, prod_length in H0.
706 assert (0 < length (FreeSubsets (length hn)))%nat as lenPos.
707 { destruct (length (FreeSubsets (length hn))).
708 exfalso; inversion H0. apply le_n_S, Nat.le_0_l. }
709 unfold ProdIntegrableSimplify.
710 do 2 rewrite (map_nth (fun xy => ProdSubsetIntersect hn (fst xy) (snd xy))
711 _ (@nil bool, @nil bool)).
712 rewrite (nth_list_prod
713 (FreeSubsets (length hn)) (FreeSubsets (length hn)) nil nil i
714 (Nat.lt_trans _ _ _ H H0)).
715 rewrite (nth_list_prod
716 (FreeSubsets (length hn)) (FreeSubsets (length hn)) nil nil j H0).
717 unfold fst, snd.
718 (* Decompose i,j into product pairs of indices (a,b), (c,d). *)
719 remember (i / length (FreeSubsets (length hn)))%nat as a.
720 remember (i mod (length (FreeSubsets (length hn))))%nat as b.
721 remember (j / length (FreeSubsets (length hn)))%nat as c.
722 remember (j mod (length (FreeSubsets (length hn))))%nat as d.
723 intros x y z. simpl in z. destruct z as [xH [xK [yH yK]]].
724 destruct (Nat.eq_dec a c).
725 - (* If subsets b and d are different, the product on y's is zero. *)
726 assert (b <> d).
727 { intro abs. subst d. subst b. subst c. subst a.
728 rewrite (nat_euclid_unique _ _ _ lenPos e abs) in H.
729 exact (Nat.lt_irrefl j H). }
730 assert (d < length (FreeSubsets (length hn)))%nat as din.
731 { subst d. apply Nat.mod_upper_bound.
732 intro abs. rewrite abs in lenPos. exact (Nat.lt_irrefl _ lenPos). }
733 apply (ProdIntegrableSubsetsDisjoint
734 (map prodint_g hn) (nth d (FreeSubsets (length hn)) nil)
735 (nth b (FreeSubsets (length hn)) nil) y).
736 4: split; assumption.
737 rewrite (FreeSubsetsLength (length hn)).
738 rewrite (FreeSubsetsLength (length hn)). reflexivity.
739 apply nth_In. subst b. apply Nat.mod_upper_bound.
740 intro abs. rewrite abs in lenPos. exact (Nat.lt_irrefl _ lenPos).
741 apply nth_In. exact din.
742 rewrite (FreeSubsetsLength (length hn)).
743 rewrite map_length. reflexivity.
744 apply nth_In. exact din.
745 apply FreeSubsetsDifferent.
746 intro abs. apply H1. symmetry. exact abs. exact din.
747 subst b. apply Nat.mod_upper_bound.
748 intro abs. rewrite abs in lenPos. exact (Nat.lt_irrefl _ lenPos).
749 - (* If subsets a and c are different, the product on x's is zero. *)
750 assert (c < length (FreeSubsets (length hn)))%nat as cin.
751 { subst c.
752 apply Nat.div_lt_upper_bound. intro abs.
753 rewrite abs in lenPos. exact (Nat.lt_irrefl 0 lenPos). exact H0. }
754 apply (ProdIntegrableSubsetsDisjoint
755 (map prodint_f hn) (nth c (FreeSubsets (length hn)) nil)
756 (nth a (FreeSubsets (length hn)) nil) x).
757 4: split; assumption. clear xH xK yH yK.
758 rewrite (FreeSubsetsLength (length hn)).
759 rewrite (FreeSubsetsLength (length hn)). reflexivity.
760 apply nth_In. subst a.
761 apply Nat.div_lt_upper_bound. intro abs.
762 rewrite abs in lenPos. exact (Nat.lt_irrefl 0 lenPos).
763 exact (Nat.lt_trans _ _ _ H H0).
764 apply nth_In. exact cin.
765 rewrite (FreeSubsetsLength (length hn)).
766 rewrite map_length. reflexivity. apply nth_In. exact cin.
767 apply FreeSubsetsDifferent.
768 intro abs. apply n. symmetry. exact abs. exact cin.
769 subst a.
770 apply Nat.div_lt_upper_bound. intro abs.
771 rewrite abs in lenPos. exact (Nat.lt_irrefl 0 lenPos).
772 exact (Nat.lt_trans _ _ _ H H0).
773 Qed.
774
775 Fixpoint ProdIntegrableSubsetLeft
776 {I J : IntegrationSpace}
777 (hn : list (@ProdIntegrable I J))
778 (x : X (ElemFunc I)) (y : X (ElemFunc J))
779 (xyH : Domain (ProdLFunc hn) (x,y)) { struct hn }
780 : list bool.
781 Proof.
782 destruct hn.
783 - exact nil.
784 - destruct xyH, d.
785 exact ((if d then true else false) :: ProdIntegrableSubsetLeft I J hn x y d0).
786 Defined.
787
788 Lemma ProdIntegrableSubsetLeft_length
789 : forall {I J : IntegrationSpace}
790 (hn : list (@ProdIntegrable I J))
791 (x : X (ElemFunc I)) (y : X (ElemFunc J))
792 (xyH : Domain (ProdLFunc hn) (x,y)),
793 length (ProdIntegrableSubsetLeft hn x y xyH) = length hn.
794 Proof.
795 induction hn.
796 - reflexivity.
797 - intros. simpl. destruct xyH, d. simpl.
798 rewrite IHhn. reflexivity.
799 Qed.
800
801 Fixpoint ProdIntegrableSubsetRight
802 {I J : IntegrationSpace}
803 (hn : list (@ProdIntegrable I J))
804 (x : X (ElemFunc I)) (y : X (ElemFunc J))
805 (xyH : Domain (ProdLFunc hn) (x,y)) { struct hn }
806 : list bool.
807 Proof.
808 destruct hn.
809 - exact nil.
810 - destruct xyH, d.
811 exact ((if d1 then true else false) :: ProdIntegrableSubsetRight I J hn x y d0).
812 Defined.
813
814 Lemma ProdIntegrableSubsetRight_length
815 : forall {I J : IntegrationSpace}
816 (hn : list (@ProdIntegrable I J))
817 (x : X (ElemFunc I)) (y : X (ElemFunc J))
818 (xyH : Domain (ProdLFunc hn) (x,y)),
819 length (ProdIntegrableSubsetRight hn x y xyH) = length hn.
820 Proof.
821 induction hn.
822 - reflexivity.
823 - intros. simpl. destruct xyH, d. simpl.
824 rewrite IHhn. reflexivity.
825 Qed.
826
827 (* Application of a list of rectangles, when none is activated. *)
828 Lemma ProdLFuncApplyZero
829 : forall {I J : IntegrationSpace}
830 (hn : list (@ProdIntegrable I J))
831 (x : X (ElemFunc I)) (y : X (ElemFunc J))
832 (xyS : Domain (ProdLFunc hn) (x,y)),
833 (forall (n:nat) (ltnh : lt n (length hn)),
834 partialApply _ _ (DomainProdLFuncInc hn x y xyS n ltnh) == 0)
835 -> partialApply _ _ xyS == 0.
836 Proof.
837 induction hn.
838 - intros. reflexivity.
839 - intros. destruct xyS.
840 transitivity (partialApply _ _ d + partialApply _ _ d0).
841 reflexivity. rewrite IHhn, CRplus_0_r. clear IHhn.
842 assert (O < length (a :: hn))%nat.
843 { apply le_n_S, Nat.le_0_l. }
844 rewrite <- (H O H0). apply DomainProp.
845 clear IHhn. intros.
846 assert (S n < length (a :: hn))%nat.
847 { apply le_n_S, ltnh. }
848 rewrite <- (H (S n) H0). apply DomainProp.
849 Qed.
850
851 (* Application of a list of rectangles, when only one is activated. *)
852 Lemma ProdLFuncApplyUnique
853 : forall {I J : IntegrationSpace}
854 (hn : list (@ProdIntegrable I J))
855 (x : X (ElemFunc I)) (y : X (ElemFunc J))
856 (xyS : Domain (ProdLFunc hn) (x,y))
857 (n : nat) (ltnh : lt n (length hn)),
858 (forall (k:nat) (ltkh : lt k (length hn)),
859 k <> n -> partialApply _ _ (DomainProdLFuncInc hn x y xyS k ltkh) == 0)
860 -> partialApply _ _ xyS
861 == partialApply _ _ (DomainProdLFuncInc hn x y xyS n ltnh).
862 Proof.
863 induction hn.
864 - intros. exfalso; inversion ltnh.
865 - intros. destruct xyS. specialize (IHhn x y d0).
866 transitivity (partialApply _ _ d + partialApply _ _ d0).
867 reflexivity. destruct n.
868 + simpl (nth 0 (a :: hn) (ProdIntegrableZero I J)).
869 rewrite <- (CRplus_0_r (partialApply (ProdIntegrableFunc a) (x, y) (DomainProdLFuncInc (a :: hn) x y (d, d0) 0 ltnh))).
870 apply CRplus_morph. apply DomainProp.
871 apply ProdLFuncApplyZero. intros.
872 assert (S n < length (a :: hn))%nat.
873 { apply le_n_S, ltnh0. }
874 rewrite <- (H (S n) H0). apply DomainProp. discriminate.
875 + assert (n < length hn)%nat.
876 { apply le_S_n. exact ltnh. }
877 specialize (IHhn n H0). rewrite IHhn. clear IHhn.
878 rewrite <- (CRplus_0_l (partialApply (ProdIntegrableFunc (nth (S n) (a :: hn) (ProdIntegrableZero I J)))
879 (x, y) (DomainProdLFuncInc (a :: hn) x y (d, d0) (S n) ltnh))).
880 apply CRplus_morph. 2: apply DomainProp.
881 assert (0 < S (length hn))%nat. apply le_n_S, Nat.le_0_l.
882 specialize (H O H1). unfold nth in H. rewrite <- H.
883 apply DomainProp. discriminate. clear IHhn. intros.
884 assert (S k < length (a :: hn))%nat.
885 { apply le_n_S, ltkh. }
886 specialize (H (S k) H2).
887 simpl (nth (S k) (a :: hn) (ProdIntegrableZero I J)) in H.
888 rewrite <- H. apply DomainProp. intro abs. inversion abs. contradiction.
889 Qed.
890
891 Lemma ProdIntegrableSubsetLeft_match
892 : forall {I J : IntegrationSpace}
893 (hn : list (@ProdIntegrable I J))
894 (x : X (ElemFunc I)) (y : X (ElemFunc J))
895 (xyH : Domain (ProdLFunc hn) (x,y))
896 (init : X (ElemFunc I) -> Prop),
897 init x
898 -> SubsetIntersectLeft hn init (ProdIntegrableSubsetLeft hn x y xyH) x.
899 Proof.
900 induction hn.
901 - intros. exact H.
902 - intros. destruct xyH, d, d; split.
903 exact p. apply IHhn. exact H.
904 apply IHhn. exact H. exact n.
905 Qed.
906
907 Lemma ProdIntegrableSubsetRight_match
908 : forall {I J : IntegrationSpace}
909 (hn : list (@ProdIntegrable I J))
910 (x : X (ElemFunc I)) (y : X (ElemFunc J))
911 (xyH : Domain (ProdLFunc hn) (x,y))
912 (init : X (ElemFunc J) -> Prop),
913 init y
914 -> SubsetIntersectRight hn init (ProdIntegrableSubsetRight hn x y xyH) y.
915 Proof.
916 induction hn.
917 - intros. exact H.
918 - intros. destruct xyH, d, d1; split.
919 exact p. apply IHhn. exact H.
920 apply IHhn. exact H. exact n.
921 Qed.
922
923 Lemma ApplyOutsidePointLeft
924 : forall {I J : IntegrationSpace}
925 (hn : list (@ProdIntegrable I J))
926 (x : X (ElemFunc I)) (y : X (ElemFunc J))
927 (xyH : Domain (ProdLFunc hn) (x,y)),
928 Forall (fun fg : ProdIntegrable => ~ prodint_g fg y) hn
929 -> SubsetIntersectFactor hn (ProdIntegrableSubsetLeft hn x y xyH)
930 (ProdIntegrableSubsetRight hn x y xyH) == 0.
931 Proof.
932 induction hn.
933 - reflexivity.
934 - intros. inversion H. destruct xyH, d. specialize (IHhn x y d0 H3).
935 subst x0. subst l. simpl. destruct d.
936 + destruct d1. contradiction. simpl. rewrite IHhn.
937 apply CRplus_0_l.
938 + simpl. rewrite IHhn. apply CRplus_0_l.
939 Qed.
940
941 Lemma ApplyOutsidePointRight
942 : forall {I J : IntegrationSpace}
943 (hn : list (@ProdIntegrable I J))
944 (x : X (ElemFunc I)) (y : X (ElemFunc J))
945 (xyH : Domain (ProdLFunc hn) (x,y)),
946 Forall (fun fg : ProdIntegrable => ~ prodint_f fg x) hn
947 -> SubsetIntersectFactor hn (ProdIntegrableSubsetLeft hn x y xyH)
948 (ProdIntegrableSubsetRight hn x y xyH) == 0.
949 Proof.
950 induction hn.
951 - reflexivity.
952 - intros. inversion H. destruct xyH, d. specialize (IHhn x y d0 H3).
953 subst x0. subst l. simpl. destruct d.
954 + destruct d1. contradiction. simpl. rewrite IHhn.
955 apply CRplus_0_l.
956 + simpl. rewrite IHhn. apply CRplus_0_l.
957 Qed.
958
959 Lemma list_prod_head : forall { A B : Type } (l : list A) (k : list B)
960 (a : A) (b : B),
961 l <> nil -> k <> nil ->
962 nth 0 (list_prod l k) (a,b)
963 = (nth 0 l a, nth 0 k b).
964 Proof.
965 intros. destruct l,k. reflexivity.
966 contradiction. contradiction. reflexivity.
967 Qed.
968
969 Lemma ProdLFuncDomainLeft
970 : forall {I J : IntegrationSpace}
971 (hn : list (@ProdIntegrable I J))
972 (x : X (ElemFunc I)) (y : X (ElemFunc J)),
973 Domain (ProdLFunc hn) (x,y)
974 -> { n:nat | lt n (length hn) /\ prodint_f (nth n hn (ProdIntegrableZero I J)) x }
975 + { forall n:nat, lt n (length hn) -> ~prodint_f (nth n hn (ProdIntegrableZero I J)) x }.
976 Proof.
977 induction hn.
978 - intros x y H. right. intros. exfalso. inversion H0.
979 - intros x y H. destruct H, d. unfold fst in d. destruct d.
980 + left. exists O. split. apply le_n_S, Nat.le_0_l. exact p.
981 + specialize (IHhn x y d0) as [[k isin] | isout].
982 left. exists (S k). destruct isin. split. apply le_n_S, H. exact H0.
983 right. intros. destruct n0. exact n.
984 apply isout. apply le_S_n, H.
985 Qed.
986
987 Lemma ProdLFuncDomainRight
988 : forall {I J : IntegrationSpace}
989 (hn : list (@ProdIntegrable I J))
990 (x : X (ElemFunc I)) (y : X (ElemFunc J)),
991 Domain (ProdLFunc hn) (x,y)
992 -> { n:nat | lt n (length hn) /\ prodint_g (nth n hn (ProdIntegrableZero I J)) y }
993 + { forall n:nat, lt n (length hn) -> ~prodint_g (nth n hn (ProdIntegrableZero I J)) y }.
994 Proof.
995 induction hn.
996 - intros x y H. right. intros. exfalso. inversion H0.
997 - intros x y H. destruct H, d. unfold snd in d1. destruct d1.
998 + left. exists O. split. apply le_n_S, Nat.le_0_l. exact p.
999 + specialize (IHhn x y d0) as [[k isin] | isout].
1000 left. exists (S k). destruct isin. split. apply le_n_S, H. exact H0.
1001 right. intros. destruct n0. exact n.
1002 apply isout. apply le_S_n, H.
1003 Qed.
1004
1005 Fixpoint ConstFilter (b : bool) (n : nat) : list bool
1006 := match n with
1007 | O => nil
1008 | S p => b :: ConstFilter b p
1009 end.
1010
1011 Lemma ConstFilter_length : forall (b:bool) (n:nat),
1012 length (ConstFilter b n) = n.
1013 Proof.
1014 induction n. reflexivity. simpl. apply f_equal, IHn.
1015 Qed.
1016
1017 Lemma ConstFilter_false : forall {A : Set} (hn : list (A -> Prop)) (x : A)
1018 (init : A -> Prop),
1019 init x
1020 -> Forall (fun h => ~h x) hn
1021 -> SubsetIntersectFilter hn init (ConstFilter false (length hn)) x.
1022 Proof.
1023 induction hn.
1024 - intros. exact H.
1025 - intros. inversion H0. split. 2: exact H3.
1026 exact (IHhn x init H H4).
1027 Qed.
1028
1029 Lemma SubsetIntersectFilterOut
1030 : forall {A : Set}
1031 (hn : list (A -> Prop))
1032 (x : A),
1033 (forall filter : list bool,
1034 length filter = length hn
1035 -> ~SubsetIntersectFilter hn (SubsetUnion hn) filter x)
1036 -> Forall (fun h => ~h x) hn.
1037 Proof.
1038 induction hn.
1039 - intros. apply Forall_nil.
1040 - intros.
1041 assert (a x
1042 -> forall filter : list bool,
1043 length filter = length hn ->
1044 ~ SubsetIntersectFilter hn (SubsetUnion (a :: hn)) filter x).
1045 { intros. intro abs. apply (H (true :: filter)).
1046 simpl. apply f_equal. exact H1. split. exact H0. exact abs. }
1047 assert (a x -> Forall (fun h => ~h x) hn).
1048 { intros. apply IHhn. intros. specialize (H0 H1 filter H2).
1049 intro abs. apply H0.
1050 apply (SubsetIntersectFilterInc hn (SubsetUnion hn) _ filter x).
1051 intros. right. exact H3. exact abs. }
1052 assert (~a x).
1053 { intro abs. apply (H0 abs (ConstFilter false (length hn))).
1054 specialize (H1 abs). apply ConstFilter_length.
1055 apply ConstFilter_false. left. exact abs. exact (H1 abs). }
1056 clear H0. clear H1. apply Forall_cons.
1057 + exact H2.
1058 + apply IHhn. intros. intro abs. apply (H (false :: filter)).
1059 simpl. apply f_equal, H0. split. 2: exact H2.
1060 apply (SubsetIntersectFilterInc hn (SubsetUnion hn) _ filter x).
1061 intros. right. exact H1. exact abs.
1062 Qed.
1063
1064 Lemma DomainProdLFuncSplitCoord
1065 : forall {I J : IntegrationSpace}
1066 (hn : list (@ProdIntegrable I J))
1067 (x : X (ElemFunc I)) (y : X (ElemFunc J)),
1068 (forall n:nat, lt n (length hn)
1069 -> { prodint_f (nth n hn (ProdIntegrableZero I J)) x }
1070 + { ~prodint_f (nth n hn (ProdIntegrableZero I J)) x })
1071 -> (forall n:nat, lt n (length hn)
1072 -> { prodint_g (nth n hn (ProdIntegrableZero I J)) y }
1073 + { ~prodint_g (nth n hn (ProdIntegrableZero I J)) y })
1074 -> Domain (ProdLFunc hn) (x,y).
1075 Proof.
1076 induction hn.
1077 - intros. simpl. trivial.
1078 - intros. split.
1079 + split. apply (H O). apply le_n_S, Nat.le_0_l.
1080 apply (H0 O). apply le_n_S, Nat.le_0_l.
1081 + apply IHhn.
1082 intros. apply le_n_S in H1. exact (H (S n) H1).
1083 intros. apply le_n_S in H1. exact (H0 (S n) H1).
1084 Qed.
1085
1086 Lemma ProdIntegrableSimplifyDomain :
1087 forall {I J : IntegrationSpace}
1088 (hn : list (@ProdIntegrable I J))
1089 (x : X (ElemFunc I)) (y : X (ElemFunc J)),
1090 Domain (ProdLFunc (ProdIntegrableSimplify hn)) (x,y)
1091 -> Domain (ProdLFunc hn) (x,y).
1092 Proof.
1093 intros I J hn x y H.
1094 assert (lt O (length (FreeSubsets (length hn)))) as flen.
1095 { destruct (FreeSubsets (length hn)) eqn:des. exfalso.
1096 exact (FreeSubsetsNotNil _ des). apply le_n_S, Nat.le_0_l. }
1097 apply DomainProdLFuncSplitCoord.
1098 - destruct (ProdLFuncDomainLeft _ x y H) as [[nl isinl] | H0].
1099 + intros. destruct isinl.
1100 unfold ProdIntegrableSimplify in H2.
1101 rewrite (nth_indep _ (ProdIntegrableZero I J)
1102 (ProdSubsetIntersect hn (fst (nil,@nil bool))
1103 (snd (@nil bool, nil)))) in H2.
1104 2: exact H1.
1105 unfold ProdIntegrableSimplify in H1. rewrite map_length, prod_length in H1.
1106 rewrite (map_nth (fun xy : list bool * list bool =>
1107 ProdSubsetIntersect hn (fst xy) (snd xy))) in H2.
1108 simpl in H2. unfold SubsetIntersectLeft in H2.
1109 apply (DomainProdSubsetIntersect
1110 (map prodint_f hn) _ _ _ n) in H2.
1111 destruct (nth_error (map prodint_f hn) n) eqn:des.
1112 apply (nth_error_nth (map prodint_f hn) n
1113 (prodint_f (ProdIntegrableZero I J))) in des.
1114 subst P.
1115 destruct (nth_error
1116 (fst (nth nl (list_prod (FreeSubsets (length hn)) (FreeSubsets (length hn))) (nil, nil))) n)
1117 eqn:des2.
1118 destruct b. left. rewrite map_nth in H2. exact H2.
1119 rewrite map_nth in H2. right. exact H2.
1120 exfalso.
1121 apply nth_error_None in des2.
1122 rewrite nth_list_prod in des2. unfold fst in des2.
1123 rewrite (FreeSubsetsLength
1124 (length hn) (nth (nl / length (FreeSubsets (length hn))) (FreeSubsets (length hn)) nil)) in des2.
1125 exact (proj1 (Nat.lt_nge _ _) H0 des2).
1126 apply nth_In.
1127 apply Nat.div_lt_upper_bound in H1. exact H1.
1128 intro abs. rewrite abs in flen. inversion flen. exact H1.
1129 exfalso. apply nth_error_None in des. rewrite map_length in des.
1130 exact (proj1 (Nat.lt_nge _ _) H0 des).
1131 + assert (Forall (fun h => ~h x) (map prodint_f hn)).
1132 { apply SubsetIntersectFilterOut. intros.
1133 destruct (FreeSubsetsFull filter) as [n [H2 H3]].
1134 specialize (H0 (n * (length (FreeSubsets (length hn))))%nat).
1135 rewrite map_length in H1. intro abs. apply H0.
1136 unfold ProdIntegrableSimplify. rewrite map_length, prod_length.
1137 rewrite <- Nat.mul_lt_mono_pos_r. rewrite <- H1. exact H2.
1138 exact flen. clear H0.
1139 unfold ProdIntegrableSimplify.
1140 rewrite (nth_indep _ (ProdIntegrableZero I J)
1141 (ProdSubsetIntersect hn (fst (nil,@nil bool))
1142 (snd (@nil bool, nil)))).
1143 rewrite (map_nth (fun xy : list bool * list bool =>
1144 ProdSubsetIntersect hn (fst xy) (snd xy))).
1145 simpl. unfold SubsetIntersectLeft.
1146 rewrite (nth_list_prod (FreeSubsets (length hn)) (FreeSubsets (length hn))
1147 nil nil (n * (length (FreeSubsets (length hn))))).
1148 unfold fst. rewrite Nat.div_mul. rewrite <- H1, H3. exact abs.
1149 intro H4. rewrite H4 in flen. inversion flen.
1150 rewrite <- Nat.mul_lt_mono_pos_r. rewrite <- H1. exact H2.
1151 exact flen. rewrite map_length, prod_length.
1152 rewrite <- Nat.mul_lt_mono_pos_r. rewrite <- H1. exact H2. exact flen. }
1153 intros. right. rewrite Forall_forall in H1.
1154 apply (H1 (prodint_f (nth n hn (ProdIntegrableZero I J)))).
1155 apply in_map, nth_In, H2.
1156 - destruct (ProdLFuncDomainRight _ x y H) as [[nl isinl] | H0].
1157 + intros. destruct isinl.
1158 unfold ProdIntegrableSimplify in H2.
1159 rewrite (nth_indep _ (ProdIntegrableZero I J)
1160 (ProdSubsetIntersect hn (fst (nil,@nil bool))
1161 (snd (@nil bool, nil)))) in H2.
1162 2: exact H1.
1163 unfold ProdIntegrableSimplify in H1. rewrite map_length, prod_length in H1.
1164 rewrite (map_nth (fun xy : list bool * list bool =>
1165 ProdSubsetIntersect hn (fst xy) (snd xy))) in H2.
1166 simpl in H2. unfold SubsetIntersectLeft in H2.
1167 apply (DomainProdSubsetIntersect
1168 (map prodint_g hn) _ _ _ n) in H2.
1169 destruct (nth_error (map prodint_g hn) n) eqn:des.
1170 apply (nth_error_nth (map prodint_g hn) n
1171 (prodint_g (ProdIntegrableZero I J))) in des.
1172 subst P.
1173 destruct (nth_error
1174 (snd (nth nl (list_prod (FreeSubsets (length hn)) (FreeSubsets (length hn))) (nil, nil))) n)
1175 eqn:des2.
1176 destruct b. left. rewrite map_nth in H2. exact H2.
1177 rewrite map_nth in H2. right. exact H2.
1178 exfalso.
1179 apply nth_error_None in des2.
1180 rewrite nth_list_prod in des2. unfold snd in des2.
1181 rewrite (FreeSubsetsLength
1182 (length hn) (nth (nl mod length (FreeSubsets (length hn))) (FreeSubsets (length hn)) nil)) in des2.
1183 exact (proj1 (Nat.lt_nge _ _) H0 des2).
1184 apply nth_In. apply Nat.mod_bound_pos. apply Nat.le_0_l.
1185 exact flen. exact H1.
1186 exfalso. apply nth_error_None in des. rewrite map_length in des.
1187 exact (proj1 (Nat.lt_nge _ _) H0 des).
1188 + assert (Forall (fun h => ~h y) (map prodint_g hn)).
1189 { apply SubsetIntersectFilterOut. intros.
1190 destruct (FreeSubsetsFull filter) as [n [H2 H3]].
1191 specialize (H0 n).
1192 rewrite map_length in H1. intro abs. apply H0.
1193 unfold ProdIntegrableSimplify. rewrite map_length, prod_length.
1194 apply (Nat.lt_le_trans _ (1 * length (FreeSubsets (length hn)))).
1195 rewrite Nat.mul_1_l. rewrite <- H1. exact H2.
1196 apply Nat.mul_le_mono_nonneg_r. apply Nat.le_0_l. exact flen.
1197 clear H0.
1198 unfold ProdIntegrableSimplify.
1199 rewrite (nth_indep _ (ProdIntegrableZero I J)
1200 (ProdSubsetIntersect hn (fst (nil,@nil bool))
1201 (snd (@nil bool, nil)))).
1202 rewrite (map_nth (fun xy : list bool * list bool =>
1203 ProdSubsetIntersect hn (fst xy) (snd xy))).
1204 simpl. unfold SubsetIntersectRight.
1205 rewrite (nth_list_prod (FreeSubsets (length hn)) (FreeSubsets (length hn))
1206 nil nil n).
1207 unfold snd. rewrite Nat.mod_small. rewrite <- H1, H3. exact abs.
1208 rewrite <- H1. exact H2.
1209 apply (Nat.lt_le_trans _ (1 * length (FreeSubsets (length hn)))).
1210 rewrite Nat.mul_1_l. rewrite <- H1. exact H2.
1211 apply Nat.mul_le_mono_nonneg_r. apply Nat.le_0_l. exact flen.
1212 rewrite map_length, prod_length.
1213 apply (Nat.lt_le_trans _ (1 * length (FreeSubsets (length hn)))).
1214 rewrite Nat.mul_1_l. rewrite <- H1. exact H2.
1215 apply Nat.mul_le_mono_nonneg_r. apply Nat.le_0_l. exact flen. }
1216 intros. right. rewrite Forall_forall in H1.
1217 apply (H1 (prodint_g (nth n hn (ProdIntegrableZero I J)))).
1218 apply in_map, nth_In, H2.
1219 Qed.
1220
1221 Lemma ProdIntegrableSimplifyApply :
1222 forall {I J : IntegrationSpace}
1223 (hn : list (@ProdIntegrable I J))
1224 (x : X (ElemFunc I)) (y : X (ElemFunc J))
1225 (xyH : Domain (ProdLFunc hn) (x,y))
1226 (xyS : Domain (ProdLFunc (ProdIntegrableSimplify hn)) (x,y)),
1227 partialApply _ _ xyS
1228 == SubsetIntersectFactor
1229 hn (ProdIntegrableSubsetLeft hn x y xyH)
1230 (ProdIntegrableSubsetRight hn x y xyH).
1231 Proof.
1232 intros. destruct (SubsetUnionLeftDec hn x y xyH) as [inunionf|notinunionf].
1233 destruct (SubsetUnionRightDec hn x y xyH) as [inuniong|notinuniong].
1234 pose proof (FreeSubsetsFull (ProdIntegrableSubsetLeft hn x y xyH)) as [kf H].
1235 rewrite ProdIntegrableSubsetLeft_length in H.
1236 pose proof (FreeSubsetsFull (ProdIntegrableSubsetRight hn x y xyH)) as [kg H0].
1237 rewrite ProdIntegrableSubsetRight_length in H0.
1238 assert (kg + kf * (length (FreeSubsets (length hn)))
1239 < length (ProdIntegrableSimplify hn))%nat.
1240 { unfold ProdIntegrableSimplify. rewrite map_length, prod_length.
1241 destruct H.
1242 apply (Nat.lt_le_trans _ (length (FreeSubsets (length hn))
1243 + kf * length (FreeSubsets (length hn)))).
1244 rewrite <- Nat.add_lt_mono_r. apply H0.
1245 apply (Nat.mul_le_mono_nonneg_r (S kf) _ (length (FreeSubsets (length hn)))).
1246 apply Nat.le_0_l. exact H. }
1247 rewrite (ProdLFuncApplyUnique
1248 (ProdIntegrableSimplify hn) x y xyS
1249 (kg + kf * (length (FreeSubsets (length hn)))) H1).
1250 - (* single matching point *)
1251 assert (kg + kf * (length (FreeSubsets (length hn)))
1252 < length (FreeSubsets (length hn)) * length (FreeSubsets (length hn)))%nat.
1253 { unfold ProdIntegrableSimplify in H1
1254 ; rewrite map_length, prod_length in H1. exact H1. }
1255 pose proof (nth_list_prod
1256 (FreeSubsets (length hn)) (FreeSubsets (length hn)) nil nil
1257 (kg + kf * (length (FreeSubsets (length hn)))) H2).
1258 rewrite Nat.div_add, Nat.mod_add, Nat.div_small, Nat.mod_small in H3.
1259 2: apply H0. 2: apply H0.
1260 symmetry. rewrite <- CRmult_1_r.
1261 apply CRmult_morph. rewrite <- CRmult_1_r.
1262 apply CRmult_morph.
1263 + unfold ProdIntegrableSimplify.
1264 rewrite (nth_indep _ (ProdIntegrableZero I J)
1265 (ProdSubsetIntersect hn (fst (nil,@nil bool))
1266 (snd (@nil bool, nil)))).
1267 rewrite (map_nth (fun xy => ProdSubsetIntersect hn (fst xy) (snd xy))), H3.
1268 unfold fst, snd. destruct H, H0. simpl (0 + kf)%nat.
1269 rewrite H4, H5. reflexivity.
1270 rewrite map_length. rewrite prod_length. exact H2.
1271 + destruct (DomainProdLFuncInc (ProdIntegrableSimplify hn) x y xyS
1272 (kg + kf * length (FreeSubsets (length hn))) H1).
1273 destruct d. reflexivity. exfalso. simpl in n. apply n.
1274 unfold ProdIntegrableSimplify.
1275 rewrite (nth_indep _ (ProdIntegrableZero I J)
1276 (ProdSubsetIntersect hn (fst (nil,@nil bool))
1277 (snd (@nil bool, nil)))).
1278 rewrite (map_nth (fun xy => ProdSubsetIntersect hn (fst xy) (snd xy))), H3.
1279 simpl. destruct H. rewrite H4.
1280 apply ProdIntegrableSubsetLeft_match. apply inunionf. exact H1.
1281 + destruct (DomainProdLFuncInc (ProdIntegrableSimplify hn) x y xyS
1282 (kg + kf * length (FreeSubsets (length hn))) H1).
1283 destruct d0. reflexivity. exfalso. simpl in n. apply n.
1284 unfold ProdIntegrableSimplify.
1285 rewrite (nth_indep _ (ProdIntegrableZero I J)
1286 (ProdSubsetIntersect hn (fst (nil,@nil bool))
1287 (snd (@nil bool, nil)))).
1288 rewrite (map_nth (fun xy => ProdSubsetIntersect hn (fst xy) (snd xy))), H3.
1289 simpl. destruct H0. rewrite H4.
1290 apply ProdIntegrableSubsetRight_match. apply inuniong. exact H1.
1291 + intros abs. destruct H. rewrite abs in H. inversion H.
1292 + intros abs. destruct H. rewrite abs in H. inversion H.
1293 - (* Other points evaluate to zero *)
1294 intros. simpl.
1295 rewrite CRmult_assoc. rewrite (CRmult_morph _ _ _ (CReq_refl _) _ 0).
1296 apply CRmult_0_r.
1297 destruct (DomainProdLFuncInc (ProdIntegrableSimplify hn) x y xyS k ltkh).
1298 destruct d. destruct d0.
1299 2: unfold snd; apply CRmult_0_r.
1300 2: unfold fst; apply CRmult_0_l. exfalso.
1301 assert (k < length (FreeSubsets (length hn)) * length (FreeSubsets (length hn)))%nat.
1302 { unfold ProdIntegrableSimplify in ltkh.
1303 rewrite map_length, prod_length in ltkh. exact ltkh. }
1304 pose proof (nth_list_prod
1305 (FreeSubsets (length hn)) (FreeSubsets (length hn)) nil nil
1306 k H3).
1307 unfold fst, ProdIntegrableSimplify in p.
1308 rewrite (nth_indep _ (ProdIntegrableZero I J)
1309 (ProdSubsetIntersect hn (fst (nil,@nil bool))
1310 (snd (@nil bool, nil)))) in p.
1311 rewrite (map_nth (fun xy => ProdSubsetIntersect hn (fst xy) (snd xy))), H4 in p.
1312 unfold fst, snd in p.
1313 unfold fst, ProdIntegrableSimplify in p0.
1314 rewrite (nth_indep _ (ProdIntegrableZero I J)
1315 (ProdSubsetIntersect hn (fst (nil,@nil bool))
1316 (snd (@nil bool, nil)))) in p0.
1317 rewrite (map_nth (fun xy => ProdSubsetIntersect hn (fst xy) (snd xy))), H4 in p0.
1318 unfold fst, snd in p0.
1319 2: rewrite map_length, prod_length; exact H3.
1320 2: rewrite map_length, prod_length; exact H3.
1321 clear H4.
1322 assert (0 < length (FreeSubsets (length hn)))%nat as lenPos.
1323 { apply (Nat.le_lt_trans _ kg _ (Nat.le_0_l _)). apply H0. }
1324 destruct (Nat.eq_dec (k / length (FreeSubsets (length hn))) kf).
1325 + rewrite e in p0. clear p. simpl in p0.
1326 apply (ProdIntegrableSubsetsDisjoint
1327 (map prodint_g hn)
1328 (nth (k mod length (FreeSubsets (length hn))) (FreeSubsets (length hn)) nil)
1329 (ProdIntegrableSubsetRight hn x y xyH) y).
1330 rewrite ProdIntegrableSubsetRight_length.
1331 apply FreeSubsetsLength. apply nth_In.
1332 apply Nat.mod_bound_pos. apply Nat.le_0_l. exact lenPos.
1333 apply FreeSubsetsLength. rewrite map_length. apply nth_In.
1334 apply Nat.mod_bound_pos. apply Nat.le_0_l. exact lenPos.
1335 destruct H0. rewrite <- H4.
1336 apply FreeSubsetsDifferent. intro abs. subst kg. subst kf.
1337 pose proof (Nat.div_mod k (length (FreeSubsets (length hn)))).
1338 rewrite Nat.add_comm, Nat.mul_comm in H5. apply H2, H5.
1339 intro abs. rewrite abs in lenPos. inversion lenPos.
1340 apply Nat.mod_bound_pos. apply Nat.le_0_l. exact lenPos.
1341 exact H0. split. exact p0.
1342 apply ProdIntegrableSubsetRight_match. apply inuniong.
1343 + clear p0. simpl in p.
1344 assert (k / length (FreeSubsets (length hn)) < length (FreeSubsets (length hn)))%nat.
1345 { apply Nat.div_lt_upper_bound in H3. exact H3.
1346 intro abs. rewrite abs in lenPos. inversion lenPos. }
1347 apply (ProdIntegrableSubsetsDisjoint
1348 (map prodint_f hn)
1349 (nth (k / length (FreeSubsets (length hn))) (FreeSubsets (length hn)) nil)
1350 (ProdIntegrableSubsetLeft hn x y xyH) x).
1351 rewrite ProdIntegrableSubsetLeft_length.
1352 apply FreeSubsetsLength. apply nth_In. exact H4.
1353 apply FreeSubsetsLength. rewrite map_length. apply nth_In. exact H4.
1354 destruct H. rewrite <- H5.
1355 apply FreeSubsetsDifferent. exact n. exact H4. exact H.
1356 split. exact p. apply ProdIntegrableSubsetLeft_match. apply inunionf.
1357 - (* If y is in no subsets, then 0 == 0. *)
1358 rewrite ApplyOutsidePointLeft. 2: apply notinuniong.
1359 apply ProdLFuncApplyZero. intros. simpl.
1360 destruct (DomainProdLFuncInc
1361 (ProdIntegrableSimplify hn) x y xyS n ltnh), d0.
1362 2: apply CRmult_0_r. exfalso. clear d. simpl in p.
1363 unfold ProdIntegrableSimplify in p.
1364 rewrite (nth_indep _ (ProdIntegrableZero I J)
1365 (ProdSubsetIntersect hn (fst (nil,@nil bool))
1366 (snd (@nil bool, nil)))) in p.
1367 2: exact ltnh.
1368 rewrite (map_nth (fun xy => ProdSubsetIntersect hn (fst xy) (snd xy))),
1369 nth_list_prod in p.
1370 unfold fst, snd in p. apply SubsetIntersectFilter_init in p.
1371 destruct (SubsetUnionRightDec hn x y xyH).
1372 destruct H, notinuniong. contradiction.
1373 destruct H, notinuniong. contradiction.
1374 unfold ProdIntegrableSimplify in ltnh.
1375 rewrite map_length, prod_length in ltnh. exact ltnh.
1376 - (* If x is in no subsets, then 0 == 0. *)
1377 rewrite ApplyOutsidePointRight. 2: apply notinunionf.
1378 apply ProdLFuncApplyZero. intros. simpl.
1379 destruct (DomainProdLFuncInc
1380 (ProdIntegrableSimplify hn) x y xyS n ltnh), d.
1381 2: rewrite CRmult_0_r; apply CRmult_0_l.
1382 exfalso. clear d0. simpl in p.
1383 unfold ProdIntegrableSimplify in p.
1384 rewrite (nth_indep _ (ProdIntegrableZero I J)
1385 (ProdSubsetIntersect hn (fst (nil,@nil bool))
1386 (snd (@nil bool, nil)))) in p.
1387 2: exact ltnh.
1388 rewrite (map_nth (fun xy => ProdSubsetIntersect hn (fst xy) (snd xy))),
1389 nth_list_prod in p.
1390 unfold fst, snd in p. apply SubsetIntersectFilter_init in p.
1391 destruct (SubsetUnionLeftDec hn x y xyH).
1392 destruct H, notinunionf. contradiction.
1393 destruct H, notinunionf. contradiction.
1394 unfold ProdIntegrableSimplify in ltnh.
1395 rewrite map_length, prod_length in ltnh. exact ltnh.
1396 Qed.
1397
1398 Lemma ApplyIntersectFactor :
1399 forall {I J : IntegrationSpace}
1400 (hn : list (@ProdIntegrable I J))
1401 (x : X (ElemFunc I)) (y : X (ElemFunc J))
1402 (xyH : Domain (ProdLFunc hn) (x,y)),
1403 partialApply (ProdLFunc hn) (x, y) xyH ==
1404 SubsetIntersectFactor hn (ProdIntegrableSubsetLeft hn x y xyH)
1405 (ProdIntegrableSubsetRight hn x y xyH).
1406 Proof.
1407 induction hn.
1408 - reflexivity.
1409 - intros. destruct xyH. specialize (IHhn x y d0).
1410 simpl. rewrite IHhn. clear IHhn. destruct d. simpl.
1411 rewrite CRplus_comm.
1412 apply CRplus_morph. reflexivity. destruct d.
1413 destruct d1. do 2 rewrite CRmult_1_r. reflexivity.
1414 rewrite CRmult_1_r. rewrite CRmult_0_r. reflexivity.
1415 destruct d1. rewrite CRmult_0_r, CRmult_0_l. reflexivity.
1416 rewrite CRmult_0_r. reflexivity.
1417 Qed.
1418
1419 Lemma ProdIntegrableSimplifyEq :
1420 forall {I J : IntegrationSpace}
1421 (hn : list (@ProdIntegrable I J))
1422 (x : X (ElemFunc I)) (y : X (ElemFunc J))
1423 (xyH : Domain (ProdLFunc hn) (x,y))
1424 (xyS : Domain (ProdLFunc (ProdIntegrableSimplify hn)) (x,y)),
1425 partialApply _ _ xyH == partialApply _ _ xyS.
1426 Proof.
1427 (* ProdLFunc hn is the linear combination of hn, so we know
1428 whether x and y belong to each of the components of hn.
1429 That makes a subset which selects only one component of
1430 ProdIntegrableSimplify hn.
1431 The value on that component is SubsetIntersectFactor which
1432 sums all the activated coefficients, as ProdLFunc hn does. *)
1433 intros. rewrite (ProdIntegrableSimplifyApply hn x y xyH).
1434 apply ApplyIntersectFactor.
1435 Qed.
1436
1437 Definition ProdIntegrableMapCoef
1438 {I J : IntegrationSpace}
1439 : (CRcarrier (RealT (ElemFunc I)) -> CRcarrier (RealT (ElemFunc I)))
1440 -> @ProdIntegrable I J -> @ProdIntegrable I J
1441 := fun f P => Build_ProdIntegrable
1442 I J
1443 (prodint_f P) (prodint_g P)
1444 (f (prodint_factor P))
1445 (prodint_fint P) (prodint_gint P).
1446
1447 Lemma DomainProdLFuncMap
1448 : forall {I J : IntegrationSpace}
1449 (l : list (@ProdIntegrable I J))
1450 (x : X (ElemFunc I)) (y : X (ElemFunc J))
1451 (f : CRcarrier (RealT (ElemFunc I)) -> CRcarrier (RealT (ElemFunc I))),
1452 Domain (ProdLFunc (map (ProdIntegrableMapCoef f) l)) (x,y)
1453 -> Domain (ProdLFunc l) (x, y).
1454 Proof.
1455 induction l.
1456 - intros. simpl. trivial.
1457 - intros x y f H. destruct H. split.
1458 + destruct a; split; apply d.
1459 + exact (IHl x y f d0).
1460 Qed.
1461
1462 Lemma ApplyProdLFuncDisjointHead
1463 : forall {I J : IntegrationSpace}
1464 (l : list ProdIntegrable)
1465 (a : @ProdIntegrable I J)
1466 (x : X (ElemFunc I)) (y : X (ElemFunc J))
1467 (xyL : Domain (ProdLFunc l) (x,y)),
1468 ProdIntegrableSimple (a :: l)
1469 -> prodint_f a x
1470 -> prodint_g a y
1471 -> partialApply _ (x,y) xyL == 0.
1472 Proof.
1473 induction l.
1474 - intros. reflexivity.
1475 - intros. simpl. destruct xyL, d. simpl.
1476 assert (ProdIntegrableSimple (a0 :: l)) as simple0.
1477 { destruct H, H. split. exact H. inversion H2. exact H7. }
1478 destruct d.
1479 + destruct d1. exfalso.
1480 simpl in p, p0. destruct H. inversion H2.
1481 apply (H5 x y). repeat split; assumption.
1482 rewrite CRmult_0_r, CRplus_0_l.
1483 apply (IHl a0). exact simple0. exact H0. exact H1.
1484 + rewrite CRmult_0_r, CRmult_0_l, CRplus_0_l.
1485 apply (IHl a0). exact simple0. exact H0. exact H1.
1486 Qed.
1487
1488 Lemma ApplyProdLFuncDisjointHeadMap
1489 : forall {I J : IntegrationSpace}
1490 (l : list ProdIntegrable)
1491 (a : @ProdIntegrable I J)
1492 (x : X (ElemFunc I)) (y : X (ElemFunc J))
1493 (f : CRcarrier (RealT (ElemFunc I)) -> CRcarrier (RealT (ElemFunc I)))
1494 (xyL : Domain (ProdLFunc (map (ProdIntegrableMapCoef f) l)) (x,y)),
1495 ProdIntegrableSimple (a :: l)
1496 -> prodint_f a x
1497 -> prodint_g a y
1498 -> partialApply _ (x,y) xyL == 0.
1499 Proof.
1500 induction l.
1501 - intros. reflexivity.
1502 - intros. simpl. destruct xyL, d. simpl.
1503 assert (ProdIntegrableSimple (a0 :: l)) as simple0.
1504 { destruct H, H. split. exact H. inversion H2. exact H7. }
1505 destruct d.
1506 + destruct d1. exfalso.
1507 simpl in p, p0. destruct H. inversion H2.
1508 apply (H5 x y). repeat split; assumption.
1509 rewrite CRmult_0_r, CRplus_0_l.
1510 apply (IHl a0). exact simple0. exact H0. exact H1.
1511 + rewrite CRmult_0_r, CRmult_0_l, CRplus_0_l.
1512 apply (IHl a0). exact simple0. exact H0. exact H1.
1513 Qed.
1514
1515 (* When a list of rectangles is disjoint, a point (x,y)
1516 is inside at most one rectangle. The sum reduces to one coefficient. *)
1517 Lemma ApplyProdLFuncDisjointAbs
1518 : forall {I J : IntegrationSpace}
1519 (l : list (@ProdIntegrable I J))
1520 (x : X (ElemFunc I)) (y : X (ElemFunc J))
1521 (xyL : Domain (ProdLFunc l) (x,y))
1522 (f : CRcarrier (RealT (ElemFunc I)) -> CRcarrier (RealT (ElemFunc I)))
1523 (xyA : Domain (ProdLFunc (map (ProdIntegrableMapCoef f) l)) (x,y)),
1524 ProdIntegrableSimple l
1525 -> f 0 == 0
1526 -> (forall x y : CRcarrier (RealT (ElemFunc I)),
1527 x == y -> f x == f y)
1528 -> partialApply (ProdLFunc (map (ProdIntegrableMapCoef f) l)) (x,y) xyA
1529 == f (partialApply (ProdLFunc l) (x,y) xyL).
1530 Proof.
1531 induction l as [|a l].
1532 - intros. rewrite H0. reflexivity.
1533 - intros. simpl. destruct xyA, xyL, d.
1534 unfold fst in d. destruct d. unfold snd in d3.
1535 destruct d3.
1536 + (* (x,y) is inside a, stop the sum there. *)
1537 simpl.
1538 rewrite (H1 (prodint_factor a * (if fst d1 then 1 else 0) * (if snd d1 then 1 else 0) +
1539 partialApply
1540 (fold_right Xplus (Xconst (X (ElemFunc I) * X (ElemFunc J)) 0)
1541 (map ProdIntegrableFunc l)) (x, y) d2)
1542 (prodint_factor a)).
1543 rewrite (ApplyProdLFuncDisjointHeadMap l a x y f d0 H p p0).
1544 rewrite CRplus_0_r. do 2 rewrite CRmult_1_r. reflexivity.
1545 destruct d1. simpl.
1546 destruct d. destruct d1.
1547 2: contradiction. 2: contradiction.
1548 do 2 rewrite CRmult_1_r.
1549 rewrite (ApplyProdLFuncDisjointHead l a x y d2 H p p0).
1550 rewrite CRplus_0_r. reflexivity.
1551 + (* (x,y) is outside a, use induction hypothesis. *)
1552 simpl. rewrite CRmult_0_r, CRplus_0_l.
1553 rewrite (H1 (prodint_factor a * (if fst d1 then 1 else 0) * (if snd d1 then 1 else 0) +
1554 partialApply
1555 (fold_right Xplus (Xconst (X (ElemFunc I) * X (ElemFunc J)) 0)
1556 (map ProdIntegrableFunc l)) (x, y) d2)
1557 (partialApply (ProdLFunc l) (x, y) d2)).
1558 apply IHl. apply H. exact H0. exact H1.
1559 destruct d1. unfold snd in d1. simpl.
1560 destruct d. destruct d1. contradiction.
1561 rewrite CRmult_0_r, CRplus_0_l. reflexivity.
1562 rewrite CRmult_0_r, CRmult_0_l, CRplus_0_l. reflexivity.
1563 + (* (x,y) is outside a, use induction hypothesis. *)
1564 simpl. rewrite CRmult_0_r, CRmult_0_l, CRplus_0_l.
1565 destruct d1. simpl.
1566 rewrite (H1 (prodint_factor a * (if d then 1 else 0) * (if d1 then 1 else 0) +
1567 partialApply
1568 (fold_right Xplus (Xconst (X (ElemFunc I) * X (ElemFunc J)) 0)
1569 (map ProdIntegrableFunc l)) (x, y) d2)
1570 (partialApply (ProdLFunc l) (x, y) d2)).
1571 apply IHl. apply H. exact H0. exact H1.
1572 destruct d. destruct d1. contradiction.
1573 rewrite CRmult_0_r, CRplus_0_l. reflexivity.
1574 rewrite CRmult_0_r, CRmult_0_l, CRplus_0_l. reflexivity.
1575 Qed.
1576
1577 Lemma ApplyMapCoef :
1578 forall {I J : IntegrationSpace} (a : CRcarrier (RealT (ElemFunc I)))
1579 (l : list ProdIntegrable)
1580 (x : X (ElemFunc I)) (y : X (ElemFunc J))
1581 (xyDS : Domain (ProdLFunc (map (ProdIntegrableMapCoef (fun x0 : CRcarrier _ => a * x0)) l)) (x,y)),
1582 partialApply _ (x, y) xyDS
1583 == a * partialApply (ProdLFunc l) (x, y) (DomainProdLFuncMap l x y (fun x0 : CRcarrier _ => a * x0) xyDS).
1584 Proof.
1585 induction l.
1586 - intros. simpl. rewrite CRmult_0_r. reflexivity.
1587 - intros. simpl. destruct xyDS. rewrite IHl.
1588 destruct (DomainProdLFuncMap (a0 :: l) x y (fun x0 : CRcarrier _ => a * x0) (d, d0)).
1589 rewrite CRmult_assoc, CRmult_assoc, <- CRmult_plus_distr_l.
1590 apply CRmult_morph. reflexivity.
1591 apply CRplus_morph. 2: apply DomainProp.
1592 destruct d, d1. simpl. destruct d. destruct d1. 2: contradiction.
1593 destruct d3. destruct d4. 2: contradiction.
1594 rewrite CRmult_assoc. reflexivity.
1595 destruct d4. contradiction. rewrite CRmult_assoc. reflexivity.
1596 rewrite CRmult_0_l. destruct d1. contradiction.
1597 rewrite CRmult_0_r, CRmult_0_l. reflexivity.
1598 Qed.
1599
1600 Lemma ProductMinConstStable
1601 : forall {I J : IntegrationSpace}
1602 (l : list (@ProdIntegrable I J))
1603 (a : CRcarrier (RealT (ElemFunc I))) (aPos : 0 < a),
1604 PartialRestriction (ProdLFunc (map (ProdIntegrableMapCoef (fun x => CRmin x a)) (ProdIntegrableSimplify l)))
1605 (XminConst (ProdLFunc l) a).
1606 Proof.
1607 intros I J l.
1608 split.
1609 - intros [x y] H.
1610 apply DomainProdLFuncMap, ProdIntegrableSimplifyDomain in H. exact H.
1611 - intros [x y] xyDS xG. simpl.
1612 rewrite (ApplyProdLFuncDisjointAbs
1613 _ x y (DomainProdLFuncMap
1614 (ProdIntegrableSimplify l) x y (fun x => CRmin x a) xyDS)).
1615 2: apply ProdIntegrableSimplifyDisjoint.
1616 apply CRmin_morph.
1617 rewrite <- (ProdIntegrableSimplifyEq
1618 l x y (ProdIntegrableSimplifyDomain
1619 l x y (DomainProdLFuncMap (ProdIntegrableSimplify l) x y
1620 (fun x => CRmin x a) xyDS))).
1621 apply DomainProp. reflexivity.
1622 rewrite CRmin_left. reflexivity.
1623 apply CRlt_asym, aPos.
1624 intros. rewrite H. reflexivity.
1625 Qed.
1626
1627 (* Product L-functions are linear combinations of products
1628 of integrable functions. *)
1629 Definition ProductFunctionRieszSpace (I J : IntegrationSpace)
1630 : FunctionRieszSpace.
1631 Proof.
1632 apply (Build_FunctionRieszSpace
1633 (prod (X (ElemFunc I)) (X (ElemFunc J)))
1634 (RealT (ElemFunc I))
1635 (* L-functions are functions that extend ProdLFunc.
1636 l empty means f is the zero function defined on
1637 the whole product space. *)
1638 (fun f => { l : list ProdIntegrable
1639 & PartialRestriction (ProdLFunc l) f })).
1640 - (* extensionality of L *)
1641 intros f g H [l res]. exists l.
1642 apply (PartialRestriction_trans _ _ f _ res). destruct H.
1643 split. apply p. exact c.
1644 - (* stability under addition *)
1645 intros f g [l lf] [l0 lf0]. exists (l ++ l0).
1646 intros. split. intros [x y] xD. split.
1647 apply DomainProdLFuncAppLeft in xD. apply lf, xD.
1648 apply DomainProdLFuncAppRight in xD. apply lf0, xD.
1649 intros. destruct x as [x y].
1650 rewrite (ApplyProdLFuncApp
1651 l l0 x y (DomainProdLFuncAppLeft l l0 x y xD)
1652 (DomainProdLFuncAppRight l l0 x y xD) ).
1653 simpl. destruct xG. apply CRplus_morph. apply lf. apply lf0.
1654 - (* Stability under absolute value. Cut the domain into
1655 disjoint rectangles and apply the absolute value on each coefficient. *)
1656 intros f [l lf].
1657 exists (map (ProdIntegrableMapCoef (CRabs _)) (ProdIntegrableSimplify l)).
1658 split. intros [x y] H. destruct lf. apply d.
1659 exact (ProdIntegrableSimplifyDomain
1660 l x y (DomainProdLFuncMap
1661 (ProdIntegrableSimplify l) x y (CRabs _) H)).
1662 intros [x y] xyDS xG. simpl.
1663 rewrite (ApplyProdLFuncDisjointAbs
1664 _ x y (DomainProdLFuncMap
1665 (ProdIntegrableSimplify l) x y (CRabs _) xyDS)).
1666 2: apply ProdIntegrableSimplifyDisjoint.
1667 apply CRabs_morph.
1668 rewrite <- (ProdIntegrableSimplifyEq
1669 l x y (ProdIntegrableSimplifyDomain
1670 l x y (DomainProdLFuncMap
1671 (ProdIntegrableSimplify l) x y (CRabs _) xyDS))).
1672 apply lf.
1673 rewrite CRabs_right. reflexivity. apply CRle_refl.
1674 exact CRabs_morph.
1675 - (* Stability under minimum. Cut the domain into
1676 disjoint rectangles and apply the absolute value on each coefficient. *)
1677 intros f [l lf].
1678 exists (map (ProdIntegrableMapCoef (fun x => CRmin x 1)) (ProdIntegrableSimplify l)).
1679 apply (PartialRestriction_trans _ _ _ _ (ProductMinConstStable l 1 (CRzero_lt_one _))).
1680 split. intros [x y] H. destruct lf. apply d. exact H.
1681 intros [x y] xyDS xG. unfold XminConst, Xop, partialApply.
1682 destruct lf.
1683 rewrite (c _ xyDS xG). reflexivity.
1684 - (* stability under scaling *)
1685 intros a f [l H].
1686 exists (map (ProdIntegrableMapCoef (fun x => a * x)) l).
1687 split. intros [x y] H0. simpl. destruct H. apply d.
1688 exact (DomainProdLFuncMap l x y (fun x => a * x) H0).
1689 intros [x y] xyDS xyD.
1690 simpl. destruct H. rewrite ApplyMapCoef.
1691 apply CRmult_morph. reflexivity.
1692 apply (c (x,y) (DomainProdLFuncMap l x y (fun x => a * x) xyDS)).
1693 Defined.
1694
1695 Definition IElemProduct { I J : IntegrationSpace }
1696 (f : PartialFunction (prod (X (ElemFunc I)) (X (ElemFunc J))))
1697 : L (ProductFunctionRieszSpace I J) f -> CRcarrier (RealT (ElemFunc I))
1698 := fun fL => let (l,_) := fL in
1699 fold_right (CRplus (RealT (ElemFunc I))) 0
1700 (map (fun pi => prodint_factor pi
1701 * MeasureSet (prodint_fint pi)
1702 * CRcast (MeasureSet (prodint_gint pi)))
1703 l).
1704
1705 Definition IntegrableFunctionAE
1706 { I J : IntegrationSpace }
1707 (f : @PartialFunction (RealT (ElemFunc I))
1708 (prod (X (ElemFunc I)) (X (ElemFunc J))))
1709 : Type
1710 := almost_everywhere (fun x : X (ElemFunc I)
1711 (* Shorter than casting the function and
1712 then casting back the integral. *)
1713 => @IntegrableFunction (IntegrationSpaceCast J)
1714 (Xproj1 f x)).
1715
1716 Definition IntegralFst
1717 { I J : IntegrationSpace }
1718 (f : @PartialFunction (RealT (ElemFunc I))
1719 (prod (X (ElemFunc I)) (X (ElemFunc J))))
1720 (fInt : IntegrableFunctionAE f)
1721 : @PartialFunction (RealT (ElemFunc I)) (X (ElemFunc I)).
1722 Proof.
1723 destruct fInt as [h [hint p]].
1724 apply (Build_PartialFunctionXY
1725 (X (ElemFunc I)) (CRcarrier (RealT (ElemFunc I))) (CReq _) (Domain h)
1726 (fun x xD => Integral (p x xD))).
1727 intros. apply (@IntegralExtensional (IntegrationSpaceCast J)).
1728 intros. apply DomainProp.
1729 Defined.
1730
1731 Lemma SumProdIntFIntegrable
1732 : forall { I J : IntegrationSpace }
1733 (l : list (@ProdIntegrable I J)),
1734 IntegrableFunction
1735 (XsumList (map (fun x : ProdIntegrable => CharacFunc (prodint_f x)) l)).
1736 Proof.
1737 induction l.
1738 - simpl. apply IntegrableZero.
1739 - simpl. apply IntegrablePlus. apply a. apply IHl.
1740 Qed.
1741
1742 Lemma Xproj1Restriction
1743 : forall { I J : IntegrationSpace }
1744 (f g : @PartialFunction (RealT (ElemFunc I)) (prod (X (ElemFunc I)) (X (ElemFunc J))))
1745 (x : X (ElemFunc I)),
1746 PartialRestriction f g
1747 -> PartialRestriction (Xproj1 f x) (Xproj1 g x).
1748 Proof.
1749 split.
1750 - intros y H. destruct X. exact (d (x,y) H).
1751 - intros. apply X.
1752 Qed.
1753
1754 Lemma LElemProductIntegrableAEspec
1755 : forall { I J : IntegrationSpace }
1756 (l : list (@ProdIntegrable I J)) (x : X (ElemFunc I)),
1757 Domain (XsumList (map (fun pi => @CharacFunc (RealT (ElemFunc I)) _ (prodint_f pi)) l)) x
1758 -> @IntegrableFunction (IntegrationSpaceCast J) (Xproj1 (ProdLFunc l) x).
1759 Proof.
1760 intros I J l x xDS.
1761 (* x in the domain of sum_i f_i.
1762 Xproj1 f x = sum_i (a_i f_i(x) g_i), integrable as a linear combination
1763 of integrable functions. *)
1764 induction l.
1765 - apply (IntegrableFunctionExtensional (Xconst _ 0)).
1766 split. intros y H0. simpl. trivial.
1767 intros. apply DomainProp. apply IntegrableZero.
1768 - unfold ProdLFunc. simpl.
1769 apply (@IntegrableFunctionExtensional
1770 (IntegrationSpaceCast J)
1771 (Xplus (Xproj1 (ProdIntegrableFunc a) x)
1772 (Xproj1 (XsumList (map ProdIntegrableFunc l)) x))).
1773 split. intros y H0. apply H0.
1774 intros. destruct xD, xG. apply CRplus_morph.
1775 apply CRmult_morph. apply CRmult_morph. reflexivity.
1776 apply DomainProp. apply DomainProp. simpl. apply DomainProp.
1777 apply (@IntegrablePlus (IntegrationSpaceCast J)).
1778 2: apply IHl, xDS. destruct xDS.
1779 apply (@IntegrableFunctionExtensional
1780 (IntegrationSpaceCast J)
1781 (Xscale (prodint_factor a * partialApply _ x d)
1782 (CharacFunc (prodint_g a)))).
1783 split. intros y H. split. exact d. exact H.
1784 intros. apply CRmult_morph. apply CRmult_morph.
1785 reflexivity. apply DomainProp. apply DomainProp.
1786 apply (@IntegrableScale (IntegrationSpaceCast J)).
1787 apply (@IntegrableFunctionExtensional
1788 (IntegrationSpaceCast J)
1789 (@PartialFunctionCast (RealT (ElemFunc J)) (RealT (ElemFunc I))
1790 _ (CharacFunc (prodint_g a)))).
1791 split. intros y ydf. exact ydf. intros. simpl.
1792 destruct xD, xG. apply CRmorph_one.
1793 contradiction. contradiction. apply CRmorph_zero.
1794 exact (@IntegrableFunctionCast
1795 J _ (CharacFunc (prodint_g a)) (prodint_gint a)).
1796 Qed.
1797
1798 Lemma LElemProductIntegrableAE
1799 : forall { I J : IntegrationSpace }
1800 (l : list (@ProdIntegrable I J)),
1801 IntegrableFunctionAE (ProdLFunc l).
1802 Proof.
1803 intros I J l.
1804 exists (XsumList (map (fun x => CharacFunc (prodint_f x)) l)). split.
1805 - apply SumProdIntFIntegrable.
1806 - apply LElemProductIntegrableAEspec.
1807 Defined.
1808
1809 Definition ProdIntegrableFuncIntegrableAE
1810 : forall { I J : IntegrationSpace }
1811 (p : @ProdIntegrable I J),
1812 IntegrableFunctionAE (ProdIntegrableFunc p).
1813 Proof.
1814 (* Maybe redundant. *)
1815 intros. exists (CharacFunc (prodint_f p)).
1816 split. apply p.
1817 intros x xD.
1818 apply (@IntegrableFunctionExtensional
1819 (IntegrationSpaceCast J)
1820 (Xscale (prodint_factor p * partialApply _ x xD)
1821 (CharacFunc (prodint_g p)))).
1822 split. intros y H. split. exact xD. exact H.
1823 intros. apply CRmult_morph. apply CRmult_morph.
1824 reflexivity. apply DomainProp. apply DomainProp.
1825 apply (@IntegrableScale (IntegrationSpaceCast J)).
1826 apply (@IntegrableFunctionExtensional
1827 (IntegrationSpaceCast J)
1828 (@PartialFunctionCast (RealT (ElemFunc J)) (RealT (ElemFunc I))
1829 _ (CharacFunc (prodint_g p)))).
1830 split. intros y ydf. exact ydf. intros. simpl.
1831 destruct xD0, xG. apply CRmorph_one.
1832 contradiction. contradiction. apply CRmorph_zero.
1833 exact (@IntegrableFunctionCast
1834 J _ (CharacFunc (prodint_g p)) (prodint_gint p)).
1835 Defined.
1836
1837 Lemma ProdIntegrableFuncIntegrable
1838 : forall {I J : IntegrationSpace }
1839 (a : ProdIntegrable),
1840 IntegrableFunction (IntegralFst (ProdIntegrableFunc a) (@ProdIntegrableFuncIntegrableAE I J a)).
1841 Proof.
1842 intros.
1843 apply (IntegrableFunctionExtensional
1844 (Xscale (prodint_factor a * CRcast (Integral (prodint_gint a)))
1845 (CharacFunc (prodint_f a)))).
1846 2: apply IntegrableScale, a. split.
1847 intros x xD. exact xD.
1848 intros. simpl in xD, xG.
1849 unfold ProdIntegrableFuncIntegrableAE, IntegralFst, partialApply;
1850 rewrite IntegralRestrict.
1851 rewrite (@IntegralScale (IntegrationSpaceCast J)),
1852 IntegralRestrict, IntegralFunctionCast.
1853 simpl.
1854 destruct xD. destruct xG. 2: contradiction.
1855 do 2 rewrite CRmult_1_r. rewrite CRmult_comm. reflexivity.
1856 destruct xG. contradiction.
1857 do 3 rewrite CRmult_0_r. reflexivity.
1858 Defined.
1859
1860 Lemma LElemProductIntegralFstIntegrable
1861 : forall { I J : IntegrationSpace }
1862 (l : list (@ProdIntegrable I J)),
1863 IntegrableFunction (IntegralFst (ProdLFunc l) (LElemProductIntegrableAE l)).
1864 Proof.
1865 (* Linear combination of integrable functions. *)
1866 induction l.
1867 - (* The zero function defined almost everywhere is integrable. *)
1868 unfold IntegralFst; destruct (LElemProductIntegrableAE nil) as [f p], p.
1869 apply (IntegrableFunctionExtensional (Xscale 0 f)).
1870 split. intros x H; exact H.
1871 intros; unfold Domain in xG. simpl.
1872 rewrite CRmult_0_l.
1873 rewrite (IntegralExtensional _ _ (i0 x xG) IntegrableZero).
1874 symmetry. apply (@IntegralZeroIsZero (IntegrationSpaceCast J)).
1875 intros. reflexivity.
1876 apply IntegrableScale, i.
1877 - apply (IntegrableFunctionExtensional
1878 (Xplus (IntegralFst _ (ProdIntegrableFuncIntegrableAE a))
1879 (IntegralFst (ProdLFunc l) (LElemProductIntegrableAE l)))).
1880 split.
1881 + unfold IntegralFst. unfold LElemProductIntegrableAE.
1882 intros x [d d0]; unfold Domain in d0; simpl in d; split.
1883 exact d. exact d0.
1884 + intros.
1885 unfold IntegralFst.
1886 unfold LElemProductIntegrableAE, Xplus, XbinOp, XbinOpXY, partialApply.
1887 destruct xD.
1888 unfold ProdIntegrableFuncIntegrableAE;
1889 rewrite IntegralRestrict.
1890 rewrite <- (@IntegralPlus (IntegrationSpaceCast J)
1891 _ _ _ (LElemProductIntegrableAEspec l x d0));
1892 apply (@IntegralExtensional (IntegrationSpaceCast J)).
1893 intros. destruct xdf, xdg. unfold ProdLFunc.
1894 apply CRplus_morph.
1895 apply CRmult_morph. apply CRmult_morph.
1896 reflexivity. apply DomainProp. apply DomainProp. simpl. apply DomainProp.
1897 + apply IntegrablePlus. 2: exact IHl. clear IHl.
1898 apply ProdIntegrableFuncIntegrable.
1899 Qed.
1900
1901 Lemma IElemProductFubini
1902 : forall { I J : IntegrationSpace }
1903 (f : PartialFunction (prod (X (ElemFunc I)) (X (ElemFunc J))))
1904 (l : list ProdIntegrable)
1905 (res : PartialRestriction (ProdLFunc l) f),
1906 IElemProduct f (existT _ l res)
1907 == Integral (LElemProductIntegralFstIntegrable l).
1908 Proof.
1909 intros. simpl. clear res f. induction l.
1910 - simpl. rewrite <- (@IntegralZeroIsZero I). apply IntegralExtensional.
1911 simpl. intros.
1912 rewrite (@IntegralExtensional
1913 (IntegrationSpaceCast J)
1914 _ _ (LElemProductIntegrableAEspec nil x xdg) IntegrableZero).
1915 symmetry. apply (@IntegralZeroIsZero (IntegrationSpaceCast J)).
1916 reflexivity.
1917 - simpl. rewrite IHl. clear IHl.
1918 setoid_replace (prodint_factor a * MeasureSet (prodint_fint a)
1919 * CRcast (MeasureSet (prodint_gint a)))
1920 with (Integral (ProdIntegrableFuncIntegrable a)).
1921 + rewrite <- (@IntegralPlus I). apply IntegralExtensional.
1922 intros; simpl in xdf, xdg.
1923 destruct xdf as [s d].
1924 unfold Xplus, XbinOp, XbinOpXY, IntegralFst, partialApply.
1925 unfold ProdIntegrableFuncIntegrableAE.
1926 rewrite IntegralRestrict.
1927 rewrite <- (@IntegralPlus (IntegrationSpaceCast J)
1928 _ _ _ (LElemProductIntegrableAEspec l x d));
1929 apply (@IntegralExtensional (IntegrationSpaceCast J)). intros.
1930 destruct xdf, xdg0, d2. simpl.
1931 apply CRplus_morph. 2: apply DomainProp.
1932 destruct s. destruct d2. 2: contradiction.
1933 destruct d0. destruct d4. reflexivity. contradiction.
1934 destruct d4. contradiction. reflexivity.
1935 destruct d2. contradiction.
1936 rewrite CRmult_0_r, CRmult_0_l, CRmult_0_l. reflexivity.
1937 + unfold ProdIntegrableFuncIntegrable; rewrite IntegralRestrict.
1938 rewrite IntegralScale. rewrite (CRmult_comm (Integral (prodint_fint a))).
1939 do 2 rewrite CRmult_assoc. apply CRmult_morph. reflexivity.
1940 rewrite CRmult_comm. reflexivity.
1941 Qed.
1942
1943 Lemma IElemProductAdditive
1944 : forall { I J : IntegrationSpace }
1945 (f g : PartialFunction (prod (X (ElemFunc I)) (X (ElemFunc J))))
1946 (fL : L (ProductFunctionRieszSpace I J) f)
1947 (gL : L (ProductFunctionRieszSpace I J) g),
1948 IElemProduct (Xplus f g) (LplusStable (ProductFunctionRieszSpace I J) f g fL gL)
1949 == IElemProduct f fL + IElemProduct g gL.
1950 Proof.
1951 intros. simpl; unfold IElemProduct; destruct fL as [fl fL]; destruct gL as [gl gL].
1952 clear gL g fL f. induction fl.
1953 - simpl (fold_right (CRplus (RealT (ElemFunc I))) 0
1954 (map
1955 (fun pi : ProdIntegrable =>
1956 prodint_factor pi * MeasureSet (prodint_fint pi) * MeasureSet (prodint_gint pi)) nil)).
1957 rewrite CRplus_0_l. reflexivity.
1958 - simpl. rewrite IHfl. rewrite CRplus_assoc. reflexivity.
1959 Qed.
1960
1961 Lemma IElemProductHomogeneous
1962 : forall { I J : IntegrationSpace }
1963 (a : CRcarrier (RealT (ElemFunc I)))
1964 (f : PartialFunction (prod (X (ElemFunc I)) (X (ElemFunc J))))
1965 (fL : L (ProductFunctionRieszSpace I J) f),
1966 IElemProduct (Xscale a f) (LscaleStable (ProductFunctionRieszSpace I J) a f fL)
1967 == a * (IElemProduct f fL).
1968 Proof.
1969 intros. simpl; unfold IElemProduct; destruct fL as [l fL].
1970 clear fL f. induction l.
1971 - simpl. rewrite CRmult_0_r. reflexivity.
1972 - simpl. rewrite IHl. do 2 rewrite CRmult_assoc.
1973 rewrite <- CRmult_plus_distr_l. apply CRmult_morph. reflexivity.
1974 rewrite CRmult_assoc. reflexivity.
1975 Qed.
1976
1977 Lemma IElemProductOneL
1978 : forall { I J : IntegrationSpace }
1979 (A : X (ElemFunc I) -> Prop) (B : X (ElemFunc J) -> Prop)
1980 (Aint : IntegrableSet A) (Bint : IntegrableSet B)
1981 (alpha : CRcarrier (RealT (ElemFunc I))),
1982 L (ProductFunctionRieszSpace I J)
1983 (ProdIntegrableFunc
1984 (Build_ProdIntegrable I J A B alpha Aint Bint)).
1985 Proof.
1986 intros. exists ((Build_ProdIntegrable I J A B alpha Aint Bint) :: nil).
1987 split.
1988 - intros [x y] H; apply H.
1989 - intros. simpl in xD, xG. unfold ProdLFunc.
1990 rewrite <- (CRplus_0_r ( partialApply (ProdIntegrableFunc
1991 {|
1992 prodint_f := A;
1993 prodint_g := B;
1994 prodint_factor := alpha;
1995 prodint_fint := Aint;
1996 prodint_gint := Bint |}) x xG)).
1997 destruct xD. apply CRplus_morph.
1998 apply DomainProp. reflexivity.
1999 Defined.
2000
2001 Lemma IntegralFstNonNeg
2002 : forall { I J : IntegrationSpace }
2003 (f : PartialFunction (prod (X (ElemFunc I)) (X (ElemFunc J))))
2004 (fInt : IntegrableFunctionAE f),
2005 nonNegFunc f
2006 -> nonNegFunc (IntegralFst f fInt).
2007 Proof.
2008 intros. intros x xdf.
2009 destruct fInt, p; simpl; simpl in xdf.
2010 apply (@IntegralNonNeg (IntegrationSpaceCast J)). intros y ydf. apply H.
2011 Qed.
2012
2013 Lemma applyIntegralFst
2014 : forall { I J : IntegrationSpace }
2015 (l : list (@ProdIntegrable I J))
2016 (x : X (ElemFunc I))
2017 (lint : @IntegrableFunction (IntegrationSpaceCast J) (Xproj1 (ProdLFunc l) x))
2018 (xD : Domain (IntegralFst (ProdLFunc l) (LElemProductIntegrableAE l)) x),
2019 partialApply _ x xD == Integral lint.
2020 Proof.
2021 intros. apply (@IntegralExtensional (IntegrationSpaceCast J)).
2022 intros. apply DomainProp.
2023 Qed.
2024
2025 Lemma IElemProductExtensional
2026 : forall { I J : IntegrationSpace }
2027 (f : PartialFunction (X (ProductFunctionRieszSpace I J)))
2028 (fl : list (@ProdIntegrable I J))
2029 (fres : PartialRestriction (ProdLFunc fl) f)
2030 (g : PartialFunction (X (ProductFunctionRieszSpace I J)))
2031 (gL : L (ProductFunctionRieszSpace I J) g) ,
2032 (forall x (xD : Domain (ProdLFunc fl) x) (yD : Domain g x),
2033 partialApply _ x xD == partialApply g x yD)
2034 -> IElemProduct f (existT _ fl fres) == IElemProduct g gL.
2035 Proof.
2036 intros I J f fl fres g gL res. destruct gL.
2037 do 2 rewrite IElemProductFubini. apply IntegralExtensional.
2038 intros. simpl. apply (@IntegralExtensional (IntegrationSpaceCast J)).
2039 intros. simpl. destruct p, fres.
2040 rewrite (c _ xdg0 (d _ xdg0)). apply res.
2041 Qed.
2042
2043 Lemma applyProdLFuncBound
2044 : forall { I J : IntegrationSpace }
2045 (l : list (@ProdIntegrable I J))
2046 x (xD : Domain (ProdLFunc l) x),
2047 partialApply _ x xD
2048 <= fold_right (CRplus (RealT (ElemFunc I))) 0 (map (fun a => CRabs _ (prodint_factor a)) l).
2049 Proof.
2050 induction l.
2051 - intros. apply CRle_refl.
2052 - intros. simpl. destruct xD. apply CRplus_le_compat.
2053 destruct d. simpl. destruct d. destruct d1.
2054 do 2 rewrite CRmult_1_r. apply CRle_abs.
2055 rewrite CRmult_0_r. apply CRabs_pos.
2056 rewrite CRmult_0_r, CRmult_0_l. apply CRabs_pos.
2057 apply IHl.
2058 Qed.
2059
2060 Lemma seq_cv_0_bound
2061 : forall {R : ConstructiveReals} (u v : nat -> CRcarrier R),
2062 (forall n:nat, 0 <= u n)
2063 -> (forall n:nat, u n <= v n)
2064 -> CR_cv R v 0
2065 -> CR_cv R u 0.
2066 Proof.
2067 intros. intro p. specialize (H1 p) as [n H1]. exists n.
2068 intros. unfold CRminus. rewrite CRopp_0, CRplus_0_r.
2069 rewrite CRabs_right. specialize (H1 i H2).
2070 unfold CRminus in H1.
2071 rewrite CRopp_0, CRplus_0_r, CRabs_right in H1.
2072 exact (CRle_trans _ (v i) _ (H0 i) H1).
2073 exact (CRle_trans _ (u i) _ (H i) (H0 i)).
2074 exact (H i).
2075 Qed.
2076
2077 Lemma seq_cv_0_mult
2078 : forall {R : ConstructiveReals} (u : nat -> CRcarrier R) (a : CRcarrier R),
2079 CR_cv R u 0
2080 -> CR_cv R (fun n => u n * a) 0.
2081 Proof.
2082 intros R u a H p.
2083 destruct (CRup_nat (CRabs _ a)) as [n nup].
2084 destruct (H (p * Pos.of_nat n)%positive) as [k kmaj].
2085 exists k. intros.
2086 unfold CRminus. rewrite CRopp_0, CRplus_0_r.
2087 specialize (kmaj i H0).
2088 unfold CRminus in kmaj. rewrite CRopp_0, CRplus_0_r in kmaj.
2089 rewrite CRabs_mult.
2090 apply (CRmult_le_compat_r (CR_of_Q R (Z.of_nat n # 1))) in kmaj.
2091 rewrite <- CR_of_Q_mult in kmaj.
2092 setoid_replace ((1 # p * Pos.of_nat n) * (Z.of_nat n # 1))%Q with (1#p)%Q in kmaj.
2093 apply (CRle_trans _ (CRabs _ (u i) * CR_of_Q R (Z.of_nat n # 1))).
2094 apply CRmult_le_compat_l. apply CRabs_pos.
2095 apply CRlt_asym, nup. exact kmaj.
2096 unfold Qmult, Qnum, Qden. rewrite Z.mul_1_l, Pos.mul_1_r.
2097 unfold Qeq, Qnum, Qden. rewrite Z.mul_1_l.
2098 rewrite Pos2Z.inj_mul, Z.mul_comm.
2099 unfold Z.of_nat. simpl. destruct n. exfalso.
2100 simpl in nup. exact (CRabs_pos a nup).
2101 rewrite Pos.of_nat_succ. reflexivity.
2102 apply CR_of_Q_le. unfold Qle, Qnum, Qden. do 2 rewrite Z.mul_1_r.
2103 apply Zle_0_nat.
2104 Qed.
2105
2106 Lemma ProductMinLimitDecr
2107 : forall { I J : IntegrationSpace }
2108 (g : PartialFunction (X (ProductFunctionRieszSpace I J)))
2109 (gL : L (ProductFunctionRieszSpace I J) g),
2110 nonNegFunc g
2111 -> CR_cv _
2112 (fun n : nat =>
2113 IElemProduct (XminConst g (CR_of_Q _ (1 # Pos.of_nat (S n))))
2114 (LminConstStable (CR_of_Q _ (1 # Pos.of_nat (S n))) g (invSuccRealPositive n)
2115 gL)) 0.
2116 Proof.
2117 intros. destruct gL as [l res].
2118 assert (forall n:nat,
2119 IElemProduct (ProdLFunc (map (ProdIntegrableMapCoef (fun x => CRmin x (CR_of_Q _ (1 # Pos.of_nat (S n))))) (ProdIntegrableSimplify l)))
2120 (existT _ (map (ProdIntegrableMapCoef (fun x => CRmin x (CR_of_Q _ (1 # Pos.of_nat (S n))))) (ProdIntegrableSimplify l)) (PartialRestriction_refl _ _))
2121 == IElemProduct (XminConst g (CR_of_Q _ (1 # Pos.of_nat (S n))))
2122 (LminConstStable (CR_of_Q _ (1 # Pos.of_nat (S n))) g (invSuccRealPositive n)
2123 (existT (fun l0 : list ProdIntegrable => PartialRestriction (ProdLFunc l0) g) l res))).
2124 { intro n. apply IElemProductExtensional.
2125 intros.
2126 destruct (ProductMinConstStable
2127 l (CR_of_Q _ (1 # Pos.of_nat (S n))) (invSuccRealPositive n)).
2128 rewrite (c x xD (d x xD)). unfold XminConst, Xop, partialApply.
2129 destruct res.
2130 rewrite (c0 x (d x xD) yD). reflexivity. }
2131 apply (CR_cv_eq
2132 _ (fun n => IElemProduct (ProdLFunc (map (ProdIntegrableMapCoef (fun x => CRmin x (CR_of_Q _ (1 # Pos.of_nat (S n))))) (ProdIntegrableSimplify l)))
2133 (existT _ (map (ProdIntegrableMapCoef (fun x => CRmin x (CR_of_Q _ (1 # Pos.of_nat (S n))))) (ProdIntegrableSimplify l)) (PartialRestriction_refl _ _)))).
2134 exact H0.
2135
2136 apply (seq_cv_0_bound
2137 _ (fun n => CR_of_Q _ (1 # Pos.of_nat (S n))
2138 * fold_right (CRplus (RealT (ElemFunc I))) 0
2139 (map
2140 (fun pi : ProdIntegrable =>
2141 MeasureSet (prodint_fint pi) * CRcast (MeasureSet (prodint_gint pi)))
2142 (ProdIntegrableSimplify l)))).
2143 - intro n. rewrite H0.
2144 destruct (LminConstStable (CR_of_Q _ (1 # Pos.of_nat (S n))) g (invSuccRealPositive n)
2145 (existT (fun l0 : list ProdIntegrable => PartialRestriction (ProdLFunc l0) g) l res)).
2146 rewrite IElemProductFubini. apply IntegralNonNeg.
2147 intros x0 xdf. simpl. apply (@IntegralNonNeg (IntegrationSpaceCast J)).
2148 intros x1 xdf0. simpl. destruct p.
2149 rewrite (c _ xdf0 (d _ xdf0)).
2150 apply CRmin_glb. apply H.
2151 apply CR_of_Q_le. discriminate.
2152 - intro n. generalize (ProdIntegrableSimplify l).
2153 induction l0. simpl (fold_right (CRplus _) 0
2154 (map (fun pi : ProdIntegrable => MeasureSet (prodint_fint pi) * MeasureSet (prodint_gint pi)) nil)).
2155 rewrite CRmult_0_r. apply CRle_refl.
2156 simpl (fold_right (CRplus _) 0
2157 (map (fun pi : ProdIntegrable => MeasureSet (prodint_fint pi)
2158 * CRcast (MeasureSet (prodint_gint pi)))
2159 (a :: l0))).
2160 rewrite CRmult_plus_distr_l. apply CRplus_le_compat. 2: exact IHl0.
2161 destruct a;
2162 unfold prodint_gint, prodint_fint, ProdIntegrableMapCoef,
2163 prodint_factor, prodint_gint, prodint_fint.
2164 rewrite CRmult_assoc.
2165 apply CRmult_le_compat_r.
2166 rewrite <- (CRmult_0_l (CRcast (MeasureSet prodint_gint0))).
2167 apply CRmult_le_compat_r.
2168 unfold CRcast.
2169 rewrite <- (CRmorph_zero (@SlowConstructiveRealsMorphism (RealT (ElemFunc J)) (RealT (ElemFunc I)))).
2170 apply CRmorph_le. apply MeasureNonNeg. apply MeasureNonNeg.
2171 apply CRmin_r.
2172 - apply seq_cv_0_mult.
2173 intro p. exists (Pos.to_nat p). intros.
2174 unfold CRminus. rewrite CRopp_0, CRplus_0_r, CRabs_right.
2175 apply CR_of_Q_le. unfold Qle, Qnum, Qden.
2176 do 2 rewrite Z.mul_1_l. apply Pos2Z.pos_le_pos, Pos2Nat.inj_le.
2177 rewrite Nat2Pos.id. 2: discriminate. apply (Nat.le_trans _ _ _ H1).
2178 apply le_S, Nat.le_refl. apply CR_of_Q_le. discriminate.
2179 Qed.
2180
2181 Lemma ProductMinLimits
2182 : forall { I J : IntegrationSpace }
2183 (f : PartialFunction (X (ProductFunctionRieszSpace I J)))
2184 (fL : L (ProductFunctionRieszSpace I J) f),
2185 CR_cv _
2186 (fun n : nat => IElemProduct (XminConst f (INR n)) (LminIntStable n f fL))
2187 (IElemProduct f fL) *
2188 CR_cv _
2189 (fun n : nat =>
2190 IElemProduct (XminConst (Xabs f) (CR_of_Q _ (1 # Pos.of_nat (S n))))
2191 (LminConstStable (CR_of_Q _ (1 # Pos.of_nat (S n))) (Xabs f) (invSuccRealPositive n)
2192 (LabsStable (ProductFunctionRieszSpace I J) f fL))) 0.
2193 Proof.
2194 intros. split.
2195 - (* A sum of ProdIntegrableFunc is majorated by the sum
2196 of the product factors. *)
2197 destruct fL as [l fL].
2198 destruct (CRup_nat (fold_right (CRplus _) 0 (map (fun a => CRabs _ (prodint_factor a)) l)))
2199 as [n nup].
2200 exists n. intros.
2201 setoid_replace (IElemProduct (XminConst f (INR i))
2202 (LminIntStable i f
2203 (existT (fun l0 : list ProdIntegrable => PartialRestriction (ProdLFunc l0) f) l fL)) -
2204 IElemProduct f (existT (fun l0 : list ProdIntegrable => PartialRestriction (ProdLFunc l0) f) l fL))
2205 with (CR_of_Q (RealT (ElemFunc I)) 0).
2206 rewrite CRabs_right.
2207 apply CR_of_Q_le. discriminate. apply CRle_refl.
2208 rewrite <- (CRplus_opp_r (IElemProduct f (existT (fun l0 : list ProdIntegrable => PartialRestriction (ProdLFunc l0) f) l fL))).
2209 apply CRplus_morph. 2: reflexivity.
2210 symmetry.
2211 apply IElemProductExtensional.
2212 intros. unfold XminConst, Xop, partialApply. rewrite CRmin_left.
2213 destruct fL. rewrite (c x xD (d x xD)). apply DomainProp.
2214 simpl in yD.
2215 destruct fL. rewrite <- (c x xD).
2216 apply (CRle_trans _ _ _ (applyProdLFuncBound l x xD)).
2217 apply (CRle_trans _ (CR_of_Q _ (Z.of_nat n # 1))).
2218 apply CRlt_asym, nup. apply CR_of_Q_le.
2219 unfold Qle, Qnum, Qden. do 2 rewrite Z.mul_1_r.
2220 apply Nat2Z.inj_le, H.
2221 - (* The sequences finishes integrating a constant function. *)
2222 apply ProductMinLimitDecr.
2223 intros x xdf. apply CRabs_pos.
2224 Qed.
2225
2226 Lemma ProductIContinuous { I J : IntegrationSpace }
2227 : @ElemIntegralContinuous
2228 (ProductFunctionRieszSpace I J) IElemProduct.
2229 Proof.
2230 intros f fn fL fnL fnNonNeg cv.
2231 destruct fL as [fl fL].
2232 pose (fun n => let (l,_) := fnL n in l) as ln.
2233 assert (forall n:nat, PartialRestriction (ProdLFunc (ln n)) (fn n)) as resn.
2234 { intro n. unfold ln. destruct (fnL n). exact p. }
2235 destruct (IntegrableContinuous
2236 (IntegralFst (ProdLFunc fl) (LElemProductIntegrableAE fl))
2237 (fun n => IntegralFst (ProdLFunc (ln n)) (LElemProductIntegrableAE (ln n)))
2238 (LElemProductIntegralFstIntegrable fl)
2239 (fun n => LElemProductIntegralFstIntegrable (ln n)))
2240 as [x [limx xcv]].
2241 intro n. apply IntegralFstNonNeg.
2242 intros t tdf. destruct (resn n).
2243 rewrite (c t tdf (d t tdf)). apply fnNonNeg.
2244 destruct cv, p. simpl in x. exists x. split.
2245 apply (series_cv_eq (fun n : nat => IElemProduct (fn n) (fnL n))).
2246 2: exact s. intro n. unfold ln. destruct (fnL n).
2247 rewrite IElemProductFubini. reflexivity.
2248 simpl. rewrite IElemProductFubini in c. exact c.
2249 assert (forall n:nat,
2250 Domain (XsumList (map (fun x : ProdIntegrable => @CharacFunc (RealT (ElemFunc I)) _ (prodint_f x)) (ln n)))
2251 (cpx _ _ _ x)) as H2.
2252 { intro n. apply (cpxFn _ _ _ x n). }
2253 assert (forall n:nat, @IntegrableFunction (IntegrationSpaceCast J)
2254 (Xproj1 (ProdLFunc (ln n)) (cpx _ _ _ x)))
2255 as fnInt.
2256 { intro n. specialize (H2 n). unfold ln. unfold ln in H2.
2257 destruct (fnL n).
2258 apply LElemProductIntegrableAEspec. exact H2. }
2259 destruct (@IntegrableContinuous (IntegrationSpaceCast J)
2260 (Xproj1 (ProdLFunc fl) (cpx _ _ _ x))
2261 (fun n => Xproj1 (ProdLFunc (ln n)) (cpx _ _ _ x))
2262 (LElemProductIntegrableAEspec fl (cpx _ _ _ x) (cpxF _ _ _ x))
2263 fnInt)
2264 as [y ycv].
2265 intro n. intros y ydf.
2266 pose proof (Xproj1Restriction _ _ (cpx _ _ _ x) (resn n)) as [d c].
2267 rewrite (c y ydf (d y ydf)). apply fnNonNeg.
2268 exists limx. destruct xcv. split.
2269 apply (series_cv_eq (fun n : nat =>
2270 partialApply
2271 (IntegralFst (ProdLFunc (ln n)) (LElemProductIntegrableAE (ln n)))
2272 (cpx _ _ _ x)
2273 (cpxFn _ _ _ x n))).
2274 2: exact s. intro n. apply applyIntegralFst.
2275 destruct x. simpl in c. simpl. exact c.
2276 destruct fL.
2277 assert (forall n : nat, DomainInclusion (ProdLFunc (ln n)) (fn n)) as incn.
2278 { intro n. destruct (resn n). exact d0. }
2279 exists (Build_CommonPointFunSeq
2280 _ _ f fn (cpx _ _ _ x, cpx _ _ _ y)
2281 (d (cpx _ _ _ x, cpx _ _ _ y) (cpxF _ _ _ y))
2282 (fun n => incn n (cpx _ _ _ x, cpx _ _ _ y) (cpxFn _ _ _ y n)));
2283 unfold cpx, cpxF, cpxFn. destruct ycv as [y0 [ycv ylt]].
2284 exists y0. split.
2285 apply (series_cv_eq (fun n : nat =>
2286 partialApply
2287 (Xproj1 (ProdLFunc (ln n))
2288 (cpx (X (ElemFunc I)) (IntegralFst (ProdLFunc fl) (LElemProductIntegrableAE fl))
2289 (fun n0 : nat => IntegralFst (ProdLFunc (ln n0)) (LElemProductIntegrableAE (ln n0)))
2290 x))
2291 (cpx _ _ _ y)
2292 (cpxFn _ _ _ y n))).
2293 2: exact ycv. intro n. destruct (resn n). apply c0.
2294 simpl in ylt; rewrite c in ylt; exact ylt.
2295 Qed.
2296
2297 Definition ProductIntegrationSpace
2298 (I J : IntegrationSpace)
2299 : IntegrationSpace.
2300 Proof.
2301 intros.
2302 destruct (PositiveMeasureSubsetExists I) as [A Aint H].
2303 destruct (PositiveMeasureSubsetExists J) as [B Bint H0].
2304 apply (Build_IntegrationSpace
2305 (ProductFunctionRieszSpace I J)
2306 IElemProduct IElemProductAdditive IElemProductHomogeneous
2307 (ProdIntegrableFunc
2308 (Build_ProdIntegrable
2309 I J A B (CRinv _ (MeasureSet Aint) (inr H)
2310 * CRcast (CRinv _ (MeasureSet Bint) (inr H0)))
2311 Aint Bint))
2312 (IElemProductOneL A B Aint Bint _)).
2313 - unfold IElemProduct, IElemProductOneL, map, fold_left, prodint_factor.
2314 unfold prodint_fint, prodint_gint, fold_right.
2315 rewrite CRplus_0_r, CRmult_assoc, (CRmult_comm (MeasureSet Aint)).
2316 rewrite CRmult_assoc.
2317 rewrite <- (CRmult_assoc (CRcast (CRinv (RealT (ElemFunc J)) (MeasureSet Bint) (inr H0)))).
2318 unfold CRcast. rewrite <- CRmorph_mult.
2319 rewrite (CRmorph_proper _ (CRinv (RealT (ElemFunc J)) (MeasureSet Bint) (inr H0) * MeasureSet Bint) 1).
2320 rewrite CRmorph_one, CRmult_1_l. apply CRinv_l. apply CRinv_l.
2321 - apply ProductIContinuous.
2322 - apply ProductMinLimits.
2323 Defined.