-
Notifications
You must be signed in to change notification settings - Fork 49
/
Copy pathnormedtype.v
3800 lines (3281 loc) · 157 KB
/
normedtype.v
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
(* mathcomp analysis (c) 2017 Inria and AIST. License: CeCILL-C. *)
From mathcomp Require Import ssreflect ssrfun ssrbool ssrnat eqtype choice.
From mathcomp Require Import seq fintype bigop order ssralg ssrint ssrnum finmap.
From mathcomp Require Import matrix interval zmodp vector fieldext falgebra.
Require Import boolp ereal reals.
Require Import classical_sets posnum nngnum topology prodnormedzmodule.
(******************************************************************************)
(* This file extends the topological hierarchy with norm-related notions. *)
(* *)
(* ball_ N == balls defined by the norm/absolute value N *)
(* *)
(* * Normed Topological Abelian groups: *)
(* pseudoMetricNormedZmodType R == interface type for a normed topological *)
(* Abelian group equipped with a norm *)
(* PseudoMetricNormedZmodule.Mixin nb == builds the mixin for a normed *)
(* topological Abelian group from the *)
(* compatibility between the norm and *)
(* balls; the carrier type must have a *)
(* normed Zmodule over a numDomainType. *)
(* *)
(* * Normed modules : *)
(* normedModType K == interface type for a normed module *)
(* structure over the numDomainType K. *)
(* NormedModMixin normZ == builds the mixin for a normed module *)
(* from the property of the linearity of *)
(* the norm; the carrier type must have a *)
(* pseudoMetricNormedZmodType structure *)
(* NormedModType K T m == packs the mixin m to build a *)
(* normedModType K; T must have canonical *)
(* pseudoMetricNormedZmodType K and *)
(* pseudoMetricType structures. *)
(* [normedModType K of T for cT] == T-clone of the normedModType K structure *)
(* cT. *)
(* [normedModType K of T] == clone of a canonical normedModType K *)
(* structure on T. *)
(* `|x| == the norm of x (notation from ssrnum). *)
(* ball_norm == balls defined by the norm. *)
(* nbhs_norm == neighborhoods defined by the norm. *)
(* *)
(* * Domination notations: *)
(* dominated_by h k f F == `|f| <= k * `|h|, near F *)
(* bounded_on f F == f is bounded near F *)
(* [bounded f x | x in A] == f is bounded on A, ie F := globally A *)
(* [locally [bounded f x | x in A] == f is locally bounded on A *)
(* bounded_set == set of bounded sets. *)
(* := [set A | [bounded x | x in A]] *)
(* bounded_fun == set of bounded functions. *)
(* := [set f | [bounded f x | x in setT]] *)
(* lipschitz_on f F == f is lipschitz near F *)
(* [lipschitz f x | x in A] == f is lipschitz on A *)
(* [locally [lipschitz f x | x in A] == f is locally lipschitz on A *)
(* k.-lipschitz_on f F == f is k.-lipschitz near F *)
(* k.-lipschitz_A f == f is k.-lipschitz on A *)
(* [locally k.-lipschitz_A f] == f is locally k.-lipschitz on A *)
(* *)
(* is_interval E == the set E is an interval *)
(* Rhull E == the real interval hull of a set *)
(* *)
(* * Complete normed modules : *)
(* completeNormedModType K == interface type for a complete normed *)
(* module structure over a realFieldType *)
(* K. *)
(* [completeNormedModType K of T] == clone of a canonical complete normed *)
(* module structure over K on T. *)
(* *)
(* * Filters : *)
(* at_left x, at_right x == filters on real numbers for predicates *)
(* s.t. nbhs holds on the left/right of x *)
(* *)
(* --> We used these definitions to prove the intermediate value theorem and *)
(* the Heine-Borel theorem, which states that the compact sets of R^n are *)
(* the closed and bounded sets. *)
(* *)
(******************************************************************************)
Set Implicit Arguments.
Unset Strict Implicit.
Unset Printing Implicit Defensive.
Import Order.TTheory GRing.Theory Num.Def Num.Theory.
Local Open Scope ring_scope.
Section add_to_mathcomp.
Lemma ltr_distW (R : realDomainType) (x y e : R) :
`|x - y| < e -> y - e < x.
Proof. by rewrite ltr_distl => /andP[]. Qed.
Lemma ler_distW (R : realDomainType) (x y e : R):
`|x - y| <= e -> y - e <= x.
Proof. by rewrite ler_distl => /andP[]. Qed.
End add_to_mathcomp.
Local Open Scope classical_set_scope.
Definition ball_
(R : numDomainType) (V : zmodType) (norm : V -> R) (x : V) (e : R) :=
[set y | norm (x - y) < e].
Arguments ball_ {R} {V} norm x e%R y /.
Definition pointed_of_zmodule (R : zmodType) : pointedType := PointedType R 0.
Definition filtered_of_normedZmod (K : numDomainType) (R : normedZmodType K)
: filteredType R := Filtered.Pack (Filtered.Class
(@Pointed.class (pointed_of_zmodule R))
(nbhs_ball_ (ball_ (fun x => `|x|)))).
Section pseudoMetric_of_normedDomain.
Variables (K : numDomainType) (R : normedZmodType K).
Lemma ball_norm_center (x : R) (e : K) : 0 < e -> ball_ normr x e x.
Proof. by move=> ? /=; rewrite subrr normr0. Qed.
Lemma ball_norm_symmetric (x y : R) (e : K) :
ball_ normr x e y -> ball_ normr y e x.
Proof. by rewrite /= distrC. Qed.
Lemma ball_norm_triangle (x y z : R) (e1 e2 : K) :
ball_ normr x e1 y -> ball_ normr y e2 z -> ball_ normr x (e1 + e2) z.
Proof.
move=> /= ? ?; rewrite -(subr0 x) -(subrr y) opprD opprK (addrA x _ y) -addrA.
by rewrite (le_lt_trans (ler_norm_add _ _)) // ltr_add.
Qed.
Definition pseudoMetric_of_normedDomain
: PseudoMetric.mixin_of K (@entourage_ K R R (ball_ (fun x => `|x|)))
:= PseudoMetricMixin ball_norm_center ball_norm_symmetric ball_norm_triangle erefl.
Lemma nbhs_ball_normE :
@nbhs_ball_ K R R (ball_ normr) = nbhs_ (entourage_ (ball_ normr)).
Proof.
rewrite /nbhs_ entourage_E predeq2E => x A; split.
move=> [e egt0 sbeA].
by exists [set xy | ball_ normr xy.1 e xy.2] => //; exists e.
by move=> [E [e egt0 sbeE] sEA]; exists e => // ??; apply/sEA/sbeE.
Qed.
End pseudoMetric_of_normedDomain.
Section vecspace_of_numfield. (*NEW*)
(*TODO: put all results on ^o in a separate module (C. Cohen suggestion) *)
(* !! Redundant with ^o *)
(* While there may not be a canonical algebra on each ring, we assume here *)
(* there is a canonical vecspace on each field. We make use of the *)
(* canonical algebraic structures defined on regular algebras in mathcomp *)
Canonical numField_lmodType (K : numFieldType) :=
[lmodType K of K for [lmodType K of K^o]].
Canonical numField_lalgType (K : numFieldType) :=
[lalgType K of K for [lalgType K of K^o]].
Canonical numField_algType (K : numFieldType) :=
[algType K of K for [algType K of K^o]].
Canonical numField_comAlgType (K : numFieldType) := [comAlgType K of K].
Canonical numField_unitAlgType (K : numFieldType) := [unitAlgType K of K].
Canonical numField_comUnitAlgType (K : numFieldType) := [comUnitAlgType K of K].
Canonical numField_vectType (K : numFieldType) :=
[vectType K of K for [vectType K of K^o]].
Canonical numField_falgType (K : numFieldType) := [FalgType K of K].
Canonical numField_fieldExtType (K : numFieldType) :=
[fieldExtType K of K for regular_fieldExtType K].
Canonical numClosedField_lmodType (K : numClosedFieldType) :=
[lmodType K of K for [lmodType K of K^o]].
Canonical numClosedField_lalgType (K : numClosedFieldType) :=
[lalgType K of K for [lalgType K of K^o]].
Canonical numClosedField_algType (K : numClosedFieldType) :=
[algType K of K for [algType K of K^o]].
Canonical numClosedField_comAlgType (K : numClosedFieldType) :=
[comAlgType K of K].
Canonical numClosedField_unitAlgType (K : numClosedFieldType) :=
[unitAlgType K of K].
Canonical numClosedField_comUnitAlgType (K : numClosedFieldType) :=
[comUnitAlgType K of K].
Canonical numClosedField_vectType (K : numClosedFieldType) :=
[vectType K of K for [vectType K of K^o]].
Canonical numClosedField_falgType (K : numClosedFieldType) := [FalgType K of K].
Canonical numClosedField_fieldExtType (K : numClosedFieldType) :=
[fieldExtType K of K for regular_fieldExtType K].
Canonical realField_lmodType (K : realFieldType) :=
[lmodType K of K for [lmodType K of K^o]].
Canonical realField_lalgType (K : realFieldType) :=
[lalgType K of K for [lalgType K of K^o]].
Canonical realField_algType (K : realFieldType) :=
[algType K of K for [algType K of K^o]].
Canonical realField_comAlgType (K : realFieldType) := [comAlgType K of K].
Canonical realField_unitAlgType (K : realFieldType) := [unitAlgType K of K].
Canonical realField_comUnitAlgType (K : realFieldType) :=
[comUnitAlgType K of K].
Canonical realField_vectType (K : realFieldType) :=
[vectType K of K for [vectType K of K^o]].
Canonical realField_falgType (K : realFieldType) := [FalgType K of K].
Canonical realField_fieldExtType (K : realFieldType) :=
[fieldExtType K of K for regular_fieldExtType K].
Canonical archiField_lmodType (K : archiFieldType) :=
[lmodType K of K for [lmodType K of K^o]].
Canonical archiField_lalgType (K : archiFieldType) :=
[lalgType K of K for [lalgType K of K^o]].
Canonical archiField_algType (K : archiFieldType) :=
[algType K of K for [algType K of K^o]].
Canonical archiField_comAlgType (K : archiFieldType) := [comAlgType K of K].
Canonical archiField_unitAlgType (K : archiFieldType) := [unitAlgType K of K].
Canonical archiField_comUnitAlgType (K : archiFieldType) :=
[comUnitAlgType K of K].
Canonical archiField_vectType (K : archiFieldType) :=
[vectType K of K for [vectType K of K^o]].
Canonical archiField_falgType (K : archiFieldType) := [FalgType K of K].
Canonical archiField_fieldExtType (K : archiFieldType) :=
[fieldExtType K of K for regular_fieldExtType K].
Canonical rcf_lmodType (K : rcfType) :=
[lmodType K of K for [lmodType K of K^o]].
Canonical rcf_lalgType (K : rcfType) :=
[lalgType K of K for [lalgType K of K^o]].
Canonical rcf_algType (K : rcfType) := [algType K of K for [algType K of K^o]].
Canonical rcf_comAlgType (K : rcfType) := [comAlgType K of K].
Canonical rcf_unitAlgType (K : rcfType) := [unitAlgType K of K] .
Canonical rcf_comUnitAlgType (K : rcfType) := [comUnitAlgType K of K].
Canonical rcf_vectType (K : rcfType) :=
[vectType K of K for [vectType K of K^o]].
Canonical rcf_falgType (K : rcfType) := [FalgType K of K].
Canonical rcf_fieldExtType (K : rcfType) :=
[fieldExtType K of K for regular_fieldExtType K].
Canonical real_lmodType (K : realType) :=
[lmodType K of K for [lmodType K of K^o]].
Canonical real_lalgType (K : realType) :=
[lalgType K of K for [lalgType K of K^o]].
Canonical real_algType (K : realType) :=
[algType K of K for [algType K of K^o]].
Canonical real_comAlgType (K : realType) := [comAlgType K of K].
Canonical real_unitAlgType (K : realType) := [unitAlgType K of K].
Canonical real_comUnitAlgType (K : realType) := [comUnitAlgType K of K].
Canonical real_vectType (K : realType) :=
[vectType K of K for [vectType K of K^o]].
Canonical real_falgType (K : realType) := [FalgType K of K].
Canonical real_fieldExtType (K : realType) :=
[fieldExtType K of K for regular_fieldExtType K].
Coercion numField_lmodType : numFieldType >-> lmodType.
Coercion numField_lalgType : numFieldType >-> lalgType.
Coercion numField_comAlgType : numFieldType >-> comAlgType. (* ambiguous path *)
Coercion numField_unitAlgType : numFieldType >-> unitAlgType.
Coercion numField_comUnitAlgType : numFieldType >-> comUnitAlgType. (* ambiguous path *)
Coercion numField_vectType : numFieldType >-> vectType.
Coercion numField_falgType : numFieldType >-> FalgType.
Coercion numField_fieldExtType : numFieldType >-> fieldExtType. (* ambiguous path *)
(* TODO : other coercions *)
End vecspace_of_numfield.
(* Section numField_topological. (*New *) *) (** included in topology.v *)
(* (* Variable (R: numFieldType). *) *)
(* (* Canonical numFieldType_pointedType (R: numFieldType) := *) *)
(* (* [pointedType of R for pointed_of_zmodule R]. *) *)
(* (* Canonical numFieldType_filteredType (R: numFieldType) := *) *)
(* (* [filteredType R of R for filtered_of_normedZmod R]. *) *)
(* (* Canonical numFieldType_topologicalType (R: numFieldType) : topologicalType := TopologicalType R *) *)
(* (* (topologyOfEntourageMixin *) *)
(* (* (uniformityOfBallMixin *) *)
(* (* (@nbhs_ball_normE _ [normedZmodType R of R]) *) *)
(* (* (pseudoMetric_of_normedDomain [normedZmodType R of R]))). *) *)
(* (* Canonical numFieldType_uniformType (R: numFieldType) : uniformType := UniformType R *) *)
(* (* (uniformityOfBallMixin (@nbhs_ball_normE _ [normedZmodType R of R]) *) *)
(* (* (pseudoMetric_of_normedDomain [normedZmodType R of R])). *) *)
(* (* Canonical numFieldType_pseudoMetricType (R: numFieldType) *) *)
(* (* := @PseudoMetric.Pack R R (@PseudoMetric.Class R R *) *)
(* (* (Uniform.class (numFieldType_uniformType R)) (@pseudoMetric_of_normedDomain R R)). *) *)
(* (** the previous is included in topology.v **) *)
(* Canonical numClosedFieldType_pointedType (R: numClosedFieldType) := *)
(* [pointedType of R for [pointedType of [numFieldType of R]]]. *)
(* Canonical numClosedFieldType_filteredType (R: numClosedFieldType) := *)
(* [filteredType _ of R for [filteredType _ of [numFieldType of R]]]. *)
(* Canonical numClosedFieldType_topologicalType (R: numClosedFieldType) : topologicalType := *)
(* (* [topologicalType of R for [topologicalType of [numFieldType of R]]]. *) *)
(* (*leads to ambiguous path *) *)
(* TopologicalType R *)
(* (topologyOfEntourageMixin *)
(* (uniformityOfBallMixin *)
(* (@nbhs_ball_normE _ [normedZmodType R of R]) *)
(* (pseudoMetric_of_normedDomain [normedZmodType R of R]))). *)
(* Canonical numClosedFieldType_uniformType (R: numClosedFieldType) : uniformType := UniformType R *)
(* (uniformityOfBallMixin (@nbhs_ball_normE _ [normedZmodType R of R]) *)
(* (pseudoMetric_of_normedDomain [normedZmodType R of R])). *)
(* Canonical numClosedFieldType_pseudoMetricType (R: numClosedFieldType) := *)
(* (* [pseudoMetricType _ of R for [pseudoMetricType _ of [numFieldType of R]]]. *) *)
(* (* leads to ambiguous path *) *)
(* @PseudoMetric.Pack R R (@PseudoMetric.Class R R *)
(* (Uniform.class (numFieldType_uniformType R)) (@pseudoMetric_of_normedDomain R R)). *)
(* Canonical realFieldType_pointedType (R: realFieldType) := *)
(* [pointedType of R for [pointedType of [numFieldType of R]]]. *)
(* Canonical realFieldType_filteredType (R: realFieldType) := *)
(* [filteredType _ of R for [filteredType _ of [numFieldType of R]]]. *)
(* Canonical realFieldType_topologicalType (R: realFieldType) : topologicalType := *)
(* (* [topologicalType of R for [topologicalType of [numFieldType of R]]]. *) *)
(* (*leads to ambiguous path *) *)
(* TopologicalType R *)
(* (topologyOfEntourageMixin *)
(* (uniformityOfBallMixin *)
(* (@nbhs_ball_normE _ [normedZmodType R of R]) *)
(* (pseudoMetric_of_normedDomain [normedZmodType R of R]))). *)
(* Canonical realFieldType_uniformType (R: realFieldType) : uniformType := UniformType R *)
(* (uniformityOfBallMixin (@nbhs_ball_normE _ [normedZmodType R of R]) *)
(* (pseudoMetric_of_normedDomain [normedZmodType R of R])). *)
(* Canonical realFieldType_pseudoMetricType (R: realFieldType) := *)
(* (* [pseudoMetricType _ of R for [pseudoMetricType _ of [numFieldType of R]]]. *) *)
(* (* leads to ambiguous path *) *)
(* @PseudoMetric.Pack R R (@PseudoMetric.Class R R *)
(* (Uniform.class (numFieldType_uniformType R)) (@pseudoMetric_of_normedDomain R R)). *)
(* Canonical archiFieldType_pointedType (R: archiFieldType) := *)
(* [pointedType of R for [pointedType of [numFieldType of R]]]. *)
(* Canonical archiFieldType_filteredType (R: archiFieldType) := *)
(* [filteredType _ of R for [filteredType _ of [numFieldType of R]]]. *)
(* Canonical archiFieldType_topologicalType (R: archiFieldType) : topologicalType := *)
(* (* [topologicalType of R for [topologicalType of [numFieldType of R]]]. *) *)
(* (*leads to ambiguous path *) *)
(* TopologicalType R *)
(* (topologyOfEntourageMixin *)
(* (uniformityOfBallMixin *)
(* (@nbhs_ball_normE _ [normedZmodType R of R]) *)
(* (pseudoMetric_of_normedDomain [normedZmodType R of R]))). *)
(* Canonical archiFieldType_uniformType (R: archiFieldType) : uniformType := UniformType R *)
(* (uniformityOfBallMixin (@nbhs_ball_normE _ [normedZmodType R of R]) *)
(* (pseudoMetric_of_normedDomain [normedZmodType R of R])). *)
(* Canonical archiFieldType_pseudoMetricType (R: archiFieldType):= *)
(* (* [pseudoMetricType _ of R for [pseudoMetricType _ of [numFieldType of R]]]. *) *)
(* (* leads to ambiguous path *) *)
(* @PseudoMetric.Pack R R (@PseudoMetric.Class R R *)
(* (Uniform.class (numFieldType_uniformType R)) (@pseudoMetric_of_normedDomain R R)). *)
(* Canonical rcfType_pointedType (R: rcfType) := *)
(* [pointedType of R for [pointedType of [numFieldType of R]]]. *)
(* Canonical rcfType_filteredType (R: rcfType) := *)
(* [filteredType R of R for filtered_of_normedZmod R]. *)
(* Canonical rcfType_topologicalType (R: rcfType) : topologicalType := *)
(* (* [topologicalType of R for [topologicalType of [numFieldType of R]]]. *) *)
(* (*leads to ambiguous path *) *)
(* TopologicalType R *)
(* (topologyOfEntourageMixin *)
(* (uniformityOfBallMixin *)
(* (@nbhs_ball_normE _ [normedZmodType R of R]) *)
(* (pseudoMetric_of_normedDomain [normedZmodType R of R]))). *)
(* Canonical rcfType_uniformType (R: rcfType) : uniformType := UniformType R *)
(* (uniformityOfBallMixin (@nbhs_ball_normE _ [normedZmodType R of R]) *)
(* (pseudoMetric_of_normedDomain [normedZmodType R of R])). *)
(* Canonical rcfType_pseudoMetricType (R: rcfType) := *)
(* (* [pseudoMetricType _ of R for [pseudoMetricType _ of [numFieldType of R]]]. *) *)
(* (* leads to ambiguous path *) *)
(* @PseudoMetric.Pack R R (@PseudoMetric.Class R R *)
(* (Uniform.class (numFieldType_uniformType R)) (@pseudoMetric_of_normedDomain R R)). *)
(* Canonical realType_pointedType (R: realType) := *)
(* [pointedType of R for [pointedType of [numFieldType of R]]]. *)
(* Canonical realType_filteredType (R: realType) := *)
(* [filteredType _ of R for [filteredType _ of [numFieldType of R]]]. *)
(* Canonical realType_topologicalType (R: realType) : topologicalType := *)
(* (* [topologicalType of R for [topologicalType of [numFieldType of R]]]. *) *)
(* (*leads to ambiguous path *) *)
(* TopologicalType R *)
(* (topologyOfEntourageMixin *)
(* (uniformityOfBallMixin *)
(* (@nbhs_ball_normE _ [normedZmodType R of R]) *)
(* (pseudoMetric_of_normedDomain [normedZmodType R of R]))). *)
(* Canonical realType_uniformType (R: realType) : uniformType := UniformType R *)
(* (uniformityOfBallMixin (@nbhs_ball_normE _ [normedZmodType R of R]) *)
(* (pseudoMetric_of_normedDomain [normedZmodType R of R])). *)
(* Canonical realType_pseudoMetricType (R: realType) := *)
(* (* [pseudoMetricType _ of R for [pseudoMetricType _ of [numFieldType of R]]]. *) *)
(* (* leads to ambiguous path *) *)
(* @PseudoMetric.Pack R R (@PseudoMetric.Class R R *)
(* (Uniform.class (numFieldType_uniformType R)) (@pseudoMetric_of_normedDomain R R)). *)
(* Coercion numFieldType_pointedType : numFieldType >-> pointedType. *)
(* Coercion numFieldType_filteredType : numFieldType >-> filteredType. *)
(* Coercion numFieldType_topologicalType : numFieldType >-> topologicalType. *)
(* Coercion numFieldType_uniformType : numFieldType >-> uniformType. *)
(* Coercion numFieldType_pseudoMetricType : numFieldType >-> pseudoMetricType. *)
(* Coercion numClosedFieldType_pointedType : numClosedFieldType >-> pointedType. *)
(* Coercion numClosedFieldType_filteredType : numClosedFieldType >-> filteredType. *)
(* Coercion numClosedFieldType_topologicalType : numClosedFieldType >-> topologicalType. *)
(* Coercion numClosedFieldType_uniformType : numClosedFieldType >-> uniformType. *)
(* Coercion numClosedFieldType_pseudoMetricType : numClosedFieldType >-> pseudoMetricType. *)
(* Coercion realFieldType_pointedType : realFieldType >-> pointedType. *)
(* Coercion realFieldType_filteredType : realFieldType >-> filteredType. *)
(* Coercion realFieldType_topologicalType : realFieldType >-> topologicalType. *)
(* Coercion realFieldType_uniformType : realFieldType >-> uniformType. *)
(* Coercion realFieldType_pseudoMetricType : realFieldType >-> pseudoMetricType. *)
(* Coercion archiFieldType_pointedType : archiFieldType >-> pointedType. *)
(* Coercion archiFieldType_filteredType : archiFieldType >-> filteredType. *)
(* Coercion archiFieldType_topologicalType : archiFieldType >-> topologicalType. *)
(* Coercion archiFieldType_uniformType : archiFieldType >-> uniformType. *)
(* Coercion archiFieldType_pseudoMetricType : archiFieldType >-> pseudoMetricType. *)
(* Coercion rcfType_pointedType : rcfType >-> pointedType. *)
(* Coercion rcfType_filteredType : rcfType >-> filteredType. *)
(* Coercion rcfType_topologicalType : rcfType >-> topologicalType. *)
(* Coercion rcfType_uniformType : rcfType >-> uniformType. *)
(* Coercion rcfType_pseudoMetricType : rcfType >-> pseudoMetricType. *)
(* Coercion realType_pointedType : realType >-> pointedType. *)
(* Coercion realType_filteredType : realType >-> filteredType. *)
(* Coercion realType_topologicalType : realType >-> topologicalType. *)
(* Coercion realType_uniformType : realType >-> uniformType. *)
(* Coercion realType_pseudoMetricType : realType >-> pseudoMetricType. *)
(* End numField_topological. *)
(* Canonical R_pointedType := [pointedType of *)
(* Rdefinitions.R for pointed_of_zmodule R_ringType]. *)
(* (* NB: similar definition in topology.v *) *)
(* Canonical R_filteredType := [filteredType Rdefinitions.R of *)
(* Rdefinitions.R for filtered_of_normedZmod R_normedZmodType]. *)
(* Canonical R_topologicalType : topologicalType := TopologicalType Rdefinitions.R *)
(* (topologyOfBallMixin (pseudoMetric_of_normedDomain R_normedZmodType)). *)
(* Canonical R_pseudoMetricType : pseudoMetricType R_numDomainType := *)
(* PseudoMetricType Rdefinitions.R (pseudoMetric_of_normedDomain R_normedZmodType). *)
Section numFieldType_regular_canonical. (*Modified *)
(* TODO: specific module *)
Variable R : numFieldType.
(*Canonical topological_of_numFieldType := [numFieldType of R^o].*)
Canonical numFieldType_regular_pointedType :=
[pointedType of R^o for pointed_of_zmodule R].
Canonical numFieldType_regular_filteredType :=
[filteredType R of R^o for filtered_of_normedZmod R].
Canonical numFieldType_regular_topologicalType : topologicalType := TopologicalType R^o
(topologyOfEntourageMixin
(uniformityOfBallMixin
(@nbhs_ball_normE _ [normedZmodType R of R])
(pseudoMetric_of_normedDomain [normedZmodType R of R]))).
Canonical numFieldType_regular_uniformType : uniformType := UniformType R^o
(uniformityOfBallMixin (@nbhs_ball_normE _ [normedZmodType R of R])
(pseudoMetric_of_normedDomain [normedZmodType R of R])).
Canonical numFieldType_regular_pseudoMetricType :=
@PseudoMetric.Pack R R^o (@PseudoMetric.Class R R
(Uniform.class (numFieldType_uniformType R)) (@pseudoMetric_of_normedDomain R R)).
Definition numdFieldType_lalgType : lalgType R := @GRing.regular_lalgType R.
End numFieldType_regular_canonical.
Lemma nbhsN (R : numFieldType) (x : R) :
nbhs (- x) = [set [set - y | y in A] | A in nbhs x].
Proof.
rewrite -!(@filter_from_ballE).
rewrite predeqE => A; split=> [[e egt0 oppxe_A]|[B [e egt0 xe_B] <-]];
last first.
exists e => // y xe_y; exists (- y); last by rewrite opprK.
apply/xe_B.
by rewrite /ball /= opprK -normrN -mulN1r mulrDr !mulN1r.
exists [set - y | y in A]; last first.
rewrite predeqE => y; split=> [[z [t At <- <-]]|Ay]; first by rewrite opprK.
by exists (- y); [exists y|rewrite opprK].
exists e => // y xe_y; exists (- y); last by rewrite opprK.
by apply/oppxe_A; rewrite /ball /= distrC opprK addrC.
Qed.
Lemma openN (R : numFieldType) (A : set R) :
open A -> open [set - x | x in A].
Proof.
move=> Aop; rewrite openE => _ [x /Aop x_A <-].
by rewrite /interior nbhsN; exists A.
Qed.
Lemma closedN (R : numFieldType) (A : set R) :
closed A -> closed [set - x | x in A].
Proof.
move=> Acl x clNAx.
suff /Acl : closure A (- x) by exists (- x)=> //; rewrite opprK.
move=> B oppx_B; have : [set - x | x in A] `&` [set - x | x in B] !=set0.
by apply: clNAx; rewrite -[x]opprK nbhsN; exists B.
move=> [y [[z Az oppzey] [t Bt opptey]]]; exists (- y).
by split; [rewrite -oppzey opprK|rewrite -opptey opprK].
Qed.
Module PseudoMetricNormedZmodule.
Section ClassDef.
Variable R : numDomainType.
Record mixin_of (T : normedZmodType R) (ent : set (set (T * T)))
(m : PseudoMetric.mixin_of R ent) := Mixin {
_ : PseudoMetric.ball m = ball_ (fun x => `| x |) }.
Record class_of (T : Type) := Class {
base : Num.NormedZmodule.class_of R T;
pointed_mixin : Pointed.point_of T ;
nbhs_mixin : Filtered.nbhs_of T T ;
topological_mixin : @Topological.mixin_of T nbhs_mixin ;
uniform_mixin : @Uniform.mixin_of T nbhs_mixin ;
pseudoMetric_mixin :
@PseudoMetric.mixin_of R T (Uniform.entourage uniform_mixin) ;
mixin : @mixin_of (Num.NormedZmodule.Pack _ base) _ pseudoMetric_mixin
}.
Local Coercion base : class_of >-> Num.NormedZmodule.class_of.
Definition base2 T c := @PseudoMetric.Class _ _
(@Uniform.Class _
(@Topological.Class _
(Filtered.Class
(Pointed.Class (@base T c) (pointed_mixin c))
(nbhs_mixin c))
(topological_mixin c))
(uniform_mixin c))
(pseudoMetric_mixin c).
Local Coercion base2 : class_of >-> PseudoMetric.class_of.
(* TODO: base3? *)
Structure type (phR : phant R) :=
Pack { sort; _ : class_of sort }.
Local Coercion sort : type >-> Sortclass.
Variables (phR : phant R) (T : Type) (cT : type phR).
Definition class := let: Pack _ c := cT return class_of cT in c.
Definition clone c of phant_id class c := @Pack phR T c.
Let xT := let: Pack T _ := cT in T.
Notation xclass := (class : class_of xT).
Definition pack (b0 : Num.NormedZmodule.class_of R T) lm0 um0
(m0 : @mixin_of (@Num.NormedZmodule.Pack R (Phant R) T b0) lm0 um0) :=
fun bT (b : Num.NormedZmodule.class_of R T)
& phant_id (@Num.NormedZmodule.class R (Phant R) bT) b =>
fun uT (u : PseudoMetric.class_of R T) & phant_id (@PseudoMetric.class R uT) u =>
fun (m : @mixin_of (Num.NormedZmodule.Pack _ b) _ u) & phant_id m m0 =>
@Pack phR T (@Class T b u u u u u m).
Definition eqType := @Equality.Pack cT xclass.
Definition choiceType := @Choice.Pack cT xclass.
Definition zmodType := @GRing.Zmodule.Pack cT xclass.
Definition normedZmodType := @Num.NormedZmodule.Pack R phR cT xclass.
Definition pointedType := @Pointed.Pack cT xclass.
Definition filteredType := @Filtered.Pack xT cT xclass.
Definition topologicalType := @Topological.Pack cT xclass.
Definition uniformType := @Uniform.Pack cT xclass.
Definition pseudoMetricType := @PseudoMetric.Pack R cT xclass.
Definition pointed_zmodType := @GRing.Zmodule.Pack pointedType xclass.
Definition filtered_zmodType := @GRing.Zmodule.Pack filteredType xclass.
Definition topological_zmodType := @GRing.Zmodule.Pack topologicalType xclass.
Definition uniform_zmodType := @GRing.Zmodule.Pack uniformType xclass.
Definition pseudoMetric_zmodType := @GRing.Zmodule.Pack pseudoMetricType xclass.
Definition pointed_normedZmodType := @Num.NormedZmodule.Pack R phR pointedType xclass.
Definition filtered_normedZmodType := @Num.NormedZmodule.Pack R phR filteredType xclass.
Definition topological_normedZmodType := @Num.NormedZmodule.Pack R phR topologicalType xclass.
Definition uniform_normedZmodType := @Num.NormedZmodule.Pack R phR uniformType xclass.
Definition pseudoMetric_normedZmodType := @Num.NormedZmodule.Pack R phR pseudoMetricType xclass.
End ClassDef.
(*Definition numDomain_normedDomainType (R : numDomainType) : type (Phant R) :=
Pack (Phant R) (@Class R _ _ (NumDomain.normed_mixin (NumDomain.class R))).*)
Module Exports.
Coercion base : class_of >-> Num.NormedZmodule.class_of.
Coercion base2 : class_of >-> PseudoMetric.class_of.
Coercion sort : type >-> Sortclass.
Coercion eqType : type >-> Equality.type.
Canonical eqType.
Coercion choiceType : type >-> Choice.type.
Canonical choiceType.
Coercion zmodType : type >-> GRing.Zmodule.type.
Canonical zmodType.
Coercion normedZmodType : type >-> Num.NormedZmodule.type.
Canonical normedZmodType.
Coercion pointedType : type >-> Pointed.type.
Canonical pointedType.
Coercion filteredType : type >-> Filtered.type.
Canonical filteredType.
Coercion topologicalType : type >-> Topological.type.
Canonical topologicalType.
Coercion uniformType : type >-> Uniform.type.
Canonical uniformType.
Coercion pseudoMetricType : type >-> PseudoMetric.type.
Canonical pseudoMetricType.
Canonical pointed_zmodType.
Canonical filtered_zmodType.
Canonical topological_zmodType.
Canonical uniform_zmodType.
Canonical pseudoMetric_zmodType.
Canonical pointed_normedZmodType.
Canonical filtered_normedZmodType.
Canonical topological_normedZmodType.
Canonical uniform_normedZmodType.
Canonical pseudoMetric_normedZmodType.
Notation pseudoMetricNormedZmodType R := (type (Phant R)).
Notation PseudoMetricNormedZmodType R T m :=
(@pack _ (Phant R) T _ _ _ m _ _ idfun _ _ idfun _ idfun).
Notation "[ 'pseudoMetricNormedZmodType' R 'of' T 'for' cT ]" :=
(@clone _ (Phant R) T cT _ idfun)
(at level 0, format "[ 'pseudoMetricNormedZmodType' R 'of' T 'for' cT ]") :
form_scope.
Notation "[ 'pseudoMetricNormedZmodType' R 'of' T ]" :=
(@clone _ (Phant R) T _ _ idfun)
(at level 0, format "[ 'pseudoMetricNormedZmodType' R 'of' T ]") : form_scope.
End Exports.
End PseudoMetricNormedZmodule.
Export PseudoMetricNormedZmodule.Exports.
Section pseudoMetricnormedzmodule_lemmas.
Context {K : numDomainType} {V : pseudoMetricNormedZmodType K}.
Local Notation ball_norm := (ball_ (@normr K V)).
Lemma ball_normE : ball_norm = ball.
Proof. by case: V => ? [? ? ? ? ? ? []]. Qed.
End pseudoMetricnormedzmodule_lemmas.
Section numFieldType_pseudoMetricNormedZmod. (*modified*)
Lemma R_ball (R : numFieldType) :
@ball _ [pseudoMetricType R of R] = ball_ (fun x => `| x |).
Proof. by []. Qed.
Definition numFieldType_pseudoMetricNormedZmodMixin (R : numFieldType):=
PseudoMetricNormedZmodule.Mixin (R_ball R).
Canonical numFieldType_pseudoMetricNormedZmodType (R : numFieldType) :=
@PseudoMetricNormedZmodType R R (numFieldType_pseudoMetricNormedZmodMixin R).
(*NEW*)
Canonical numClosedFieldType_PseudoMetricNormedZmodule (R: numClosedFieldType) :=
[pseudoMetricNormedZmodType _ of R for
[pseudoMetricNormedZmodType _ of [numFieldType of R]]].
Canonical archiFieldType_PseudoMetricNormedZmodule (R: archiFieldType) :=
[pseudoMetricNormedZmodType _ of R for
[pseudoMetricNormedZmodType _ of [numFieldType of R]]].
Canonical realFieldType_PseudoMetricNormedZmodule (R: realFieldType) :=
[pseudoMetricNormedZmodType _ of R for
[pseudoMetricNormedZmodType _ of [numFieldType of R]]].
Canonical rcfType_PseudoMetricNormedZmodule (R: rcfType) :=
[pseudoMetricNormedZmodType _ of R for
[pseudoMetricNormedZmodType _ of [numFieldType of R]]].
Canonical realType_PseudoMetricNormedZmodule (R: realType) :=
[pseudoMetricNormedZmodType _ of R for
[pseudoMetricNormedZmodType _ of [numFieldType of R]]].
(*end NEW*)
End numFieldType_pseudoMetricNormedZmod.
(** locally *)
Section Nbhs'.
Context {R : numDomainType} {T : pseudoMetricType R}.
Lemma ex_ball_sig (x : T) (P : set T) :
~ (forall eps : {posnum R}, ~ (ball x eps%:num `<=` ~` P)) ->
{d : {posnum R} | ball x d%:num `<=` ~` P}.
Proof.
rewrite forallNE notK => exNP.
pose D := [set d : R | d > 0 /\ ball x d `<=` ~` P].
have [|d_gt0] := @getPex _ D; last by exists (PosNum d_gt0).
by move: exNP => [e eP]; exists e%:num.
Qed.
Lemma nbhsC (x : T) (P : set T) :
~ (forall eps : {posnum R}, ~ (ball x eps%:num `<=` ~` P)) ->
nbhs x (~` P).
Proof. by move=> /ex_ball_sig [e] ?; apply/nbhs_ballP; exists e%:num. Qed.
Lemma nbhsC_ball (x : T) (P : set T) :
nbhs x (~` P) -> {d : {posnum R} | ball x d%:num `<=` ~` P}.
Proof.
move=> /nbhs_ballP xNP; apply: ex_ball_sig.
by have [_ /posnumP[e] eP /(_ _ eP)] := xNP.
Qed.
Lemma nbhs_ex (x : T) (P : T -> Prop) : nbhs x P ->
{d : {posnum R} | forall y, ball x d%:num y -> P y}.
Proof.
move=> /nbhs_ballP xP.
pose D := [set d : R | d > 0 /\ forall y, ball x d y -> P y].
have [|d_gt0 dP] := @getPex _ D; last by exists (PosNum d_gt0).
by move: xP => [e bP]; exists (e : R).
Qed.
End Nbhs'.
Lemma ler_addgt0Pr (R : numFieldType) (x y : R) :
reflect (forall e, e > 0 -> x <= y + e) (x <= y).
Proof.
apply/(iffP idP)=> [lexy _/posnumP[e] | lexye]; first by rewrite ler_paddr.
have [||ltyx]// := comparable_leP.
rewrite (@comparabler_trans _ (y + 1))// /Order.comparable ?lexye//.
by rewrite ler_addl ler01 orbT.
have /midf_lt [_] := ltyx; rewrite le_gtF//.
by rewrite -(@addrK _ y y) addrAC -addrA 2!mulrDl -splitr lexye// divr_gt0//
subr_gt0.
Qed.
Lemma ler_addgt0Pl (R : numFieldType) (x y : R) :
reflect (forall e, e > 0 -> x <= e + y) (x <= y).
Proof.
by apply/(equivP (ler_addgt0Pr x y)); split=> lexy e /lexy; rewrite addrC.
Qed.
Lemma in_segment_addgt0Pr (R : numFieldType) (x y z : R) :
reflect (forall e, e > 0 -> y \in `[(x - e), (z + e)]) (y \in `[x, z]).
Proof.
apply/(iffP idP)=> [xyz _/posnumP[e] | xyz_e].
rewrite inE/=; apply/andP; split; last by rewrite ler_paddr // (itvP xyz).
by rewrite ler_subl_addr ler_paddr // (itvP xyz).
rewrite inE/=; apply/andP.
by split; apply/ler_addgt0Pr => ? /xyz_e /andP /= []; rewrite ler_subl_addr.
Qed.
Lemma in_segment_addgt0Pl (R : numFieldType) (x y z : R) :
reflect (forall e, e > 0 -> y \in `[(- e + x), (e + z)]) (y \in `[x, z]).
Proof.
apply/(equivP (in_segment_addgt0Pr x y z)).
by split=> zxy e /zxy; rewrite [z + _]addrC [_ + x]addrC.
Qed.
Lemma coord_continuous {K : numFieldType} m n i j :
continuous (fun M : 'M[K]_(m.+1, n.+1) => M i j).
Proof.
move=> /= M s /= /(nbhs_ballP (M i j)) [e e0 es].
apply/nbhs_ballP; exists e => //= N MN; exact/es/MN.
Qed.
Global Instance Proper_nbhs'_numFieldType (R : numFieldType) (x : R) :
ProperFilter (nbhs' x).
Proof.
apply: Build_ProperFilter => A /nbhs_ballP[_/posnumP[e] Ae].
exists (x + e%:num / 2); apply: Ae; last first.
by rewrite eq_sym addrC -subr_eq subrr eq_sym.
rewrite /ball /= opprD addrA subrr distrC subr0 ger0_norm //.
by rewrite {2}(splitr e%:num) ltr_spaddl.
Qed.
Global Instance Proper_nbhs'_realType (R : realType) (x : R) :
ProperFilter (nbhs' x).
Proof. exact: Proper_nbhs'_numFieldType. Qed.
(** * Some Topology on [Rbar] *)
Canonical ereal_pointed (R : numDomainType) := PointedType {ereal R} +oo%E.
Section ereal_nbhs.
Context {R : numFieldType}.
Local Open Scope ereal_scope.
Definition ereal_nbhs' (a : {ereal R}) (P : {ereal R} -> Prop) : Prop :=
match a with
| a%:E => nbhs' a (fun x => P x%:E)
| +oo => exists M, M \is Num.real /\ forall x, M%:E < x -> P x
| -oo => exists M, M \is Num.real /\ forall x, x < M%:E -> P x
end.
Definition ereal_nbhs (a : {ereal R}) (P : {ereal R} -> Prop) : Prop :=
match a with
| a%:E => nbhs a (fun x => P x%:E)
| +oo => exists M, M \is Num.real /\ forall x, M%:E < x -> P x
| -oo => exists M, M \is Num.real /\ forall x, x < M%:E -> P x
end.
Canonical ereal_ereal_filter := FilteredType {ereal R} {ereal R} (ereal_nbhs).
End ereal_nbhs.
Lemma ereal_nbhs_pinfty_ge (R : numFieldType) (c : {posnum R}) :
(\forall x \near +oo, (c%:num%:E <= x))%E.
Proof. by exists c%:num; rewrite realE posnum_ge0; split => //; apply: ltW. Qed.
Lemma ereal_nbhs_ninfty_le (R : numFieldType) (c : R) : c < 0 ->
(\forall x \near -oo, (x <= c%:E))%E.
Proof. by exists c; rewrite realE (ltW H) orbT; split => // x /ltW. Qed.
Section ereal_nbhs_instances.
Context {R : numFieldType}.
Global Instance ereal_nbhs'_filter :
forall x : {ereal R}, ProperFilter (ereal_nbhs' x).
Proof.
case=> [x||].
- case: (Proper_nbhs'_numFieldType x) => x0 [//= xT xI xS].
apply Build_ProperFilter' => //=; apply Build_Filter => //=.
move=> P Q lP lQ; exact: xI.
by move=> P Q PQ /xS; apply => y /PQ.
- apply Build_ProperFilter.
move=> P [x [xr xP]] //; exists (x + 1)%:E; apply xP => /=.
by rewrite lte_fin ltr_addl.
split=> /= [|P Q [MP [MPr gtMP]] [MQ [MQr gtMQ]] |P Q sPQ [M [Mr gtM]]].
+ by exists 0; rewrite real0.
+ have [/eqP MP0|MP0] := boolP (MP == 0).
have [/eqP MQ0|MQ0] := boolP (MQ == 0).
by exists 0; rewrite real0; split => // x x0; split;
[apply/gtMP; rewrite MP0 | apply/gtMQ; rewrite MQ0].
exists `|MQ|; rewrite realE normr_ge0; split => // x Hx; split.
by apply gtMP; rewrite (le_lt_trans _ Hx) // MP0 lee_fin.
by apply gtMQ; rewrite (le_lt_trans _ Hx) // lee_fin real_ler_normr // lexx.
have [/eqP MQ0|MQ0] := boolP (MQ == 0).
exists `|MP|; rewrite realE normr_ge0; split => // x MPx; split.
by apply gtMP; rewrite (le_lt_trans _ MPx) // lee_fin real_ler_normr // lexx.
by apply gtMQ; rewrite (le_lt_trans _ MPx) // lee_fin MQ0.
have {}MP0 : 0 < `|MP| by rewrite normr_gt0.
have {}MQ0 : 0 < `|MQ| by rewrite normr_gt0.
exists (Num.max (PosNum MP0) (PosNum MQ0))%:num.
rewrite realE /= posnum_ge0 /=; split => //.
case=> [r| |//].
* rewrite lte_fin/= posnum_max pos_lt_maxl /= => /andP[MPx MQx]; split.
by apply/gtMP; rewrite lte_fin (le_lt_trans _ MPx) // real_ler_normr // lexx.
by apply/gtMQ; rewrite lte_fin (le_lt_trans _ MQx) // real_ler_normr // lexx.
* by move=> _; split; [apply/gtMP | apply/gtMQ].
+ by exists M; split => // ? /gtM /sPQ.
- apply Build_ProperFilter.
+ move=> P [M [Mr ltMP]]; exists (M - 1)%:E.
by apply: ltMP; rewrite lte_fin gtr_addl oppr_lt0.
+ split=> /= [|P Q [MP [MPr ltMP]] [MQ [MQr ltMQ]] |P Q sPQ [M [Mr ltM]]].
* by exists 0; rewrite real0.
* have [/eqP MP0|MP0] := boolP (MP == 0).
have [/eqP MQ0|MQ0] := boolP (MQ == 0).
by exists 0; rewrite real0; split => // x x0; split;
[apply/ltMP; rewrite MP0 | apply/ltMQ; rewrite MQ0].
exists (- `|MQ|); rewrite realN realE normr_ge0; split => // x xMQ; split.
by apply ltMP; rewrite (lt_le_trans xMQ) // lee_fin MP0 ler_oppl oppr0.
apply ltMQ; rewrite (lt_le_trans xMQ) // lee_fin ler_oppl -normrN.
by rewrite real_ler_normr ?realN // lexx.
* have [/eqP MQ0|MQ0] := boolP (MQ == 0).
exists (- `|MP|); rewrite realN realE normr_ge0; split => // x MPx; split.
apply ltMP; rewrite (lt_le_trans MPx) // lee_fin ler_oppl -normrN.
by rewrite real_ler_normr ?realN // lexx.
by apply ltMQ; rewrite (lt_le_trans MPx) // lee_fin MQ0 ler_oppl oppr0.
have {}MP0 : 0 < `|MP| by rewrite normr_gt0.
have {}MQ0 : 0 < `|MQ| by rewrite normr_gt0.
exists (- (Num.max (PosNum MP0) (PosNum MQ0))%:num).
rewrite realN realE /= posnum_ge0 /=; split => //.
case=> [r|//|].
- rewrite lte_fin ltr_oppr posnum_max pos_lt_maxl => /andP[].
rewrite ltr_oppr => MPx; rewrite ltr_oppr => MQx; split.
apply/ltMP; rewrite lte_fin (lt_le_trans MPx) //= ler_oppl -normrN.
by rewrite real_ler_normr ?realN // lexx.
apply/ltMQ; rewrite lte_fin (lt_le_trans MQx) //= ler_oppl -normrN.
by rewrite real_ler_normr ?realN // lexx.
- by move=> _; split; [apply/ltMP | apply/ltMQ].
* by exists M; split => // x /ltM /sPQ.
Qed.
Typeclasses Opaque ereal_nbhs'.
Global Instance ereal_nbhs_filter : forall x, ProperFilter (@ereal_nbhs R x).
Proof.
case=> [x| |].
- case: (ereal_nbhs'_filter x%:E) => x0 [//=nxT xI xS].
apply Build_ProperFilter => //=.
move=> P /nbhs_ballP[r r0 xr]; exists x%:E; apply xr => //=.
by rewrite /ball /= subrr normr0.
apply Build_Filter => //=.
by rewrite nbhsE'.
move=> P Q.
rewrite !nbhsE' => -[xP axP] [xQ axQ]; split => //=.
exact: xI.
move=> P Q PQ; rewrite !nbhsE' => -[xP axP]; split => //=.
apply (xS P) => //=.
exact: PQ.
exact: (ereal_nbhs'_filter +oo).
exact: (ereal_nbhs'_filter -oo).
Qed.
Typeclasses Opaque ereal_nbhs.
End ereal_nbhs_instances.
Section ereal_topologicalType.
Variable R : realFieldType.
Lemma ereal_nbhs_singleton (p : {ereal R}) (A : set {ereal R}) :
ereal_nbhs p A -> A p.
Proof.
move: p => -[p | [M [Mreal MA]] | [M [Mreal MA]]] /=; [|exact: MA | exact: MA].
move=> /nbhs_ballP[_/posnumP[e]]; apply; exact/ballxx.
Qed.
Lemma ereal_nbhs_nbhs (p : {ereal R}) (A : set {ereal R}) :
ereal_nbhs p A -> ereal_nbhs p (ereal_nbhs^~ A).
Proof.
move: p => -[p| [M [Mreal MA]] | [M [Mreal MA]]] //=.
- move=> /nbhs_ballP[_/posnumP[e]] ballA.
apply/nbhs_ballP; exists (e%:num / 2) => //= r per.
apply/nbhs_ballP; exists (e%:num / 2) => //= x rex.
apply/ballA/(@ball_splitl _ _ r) => //; exact/ball_sym.
- exists (M + 1); split; first by rewrite realD // real1.
move=> -[x| _ |] //=.
rewrite lte_fin => M'x /=.
apply/nbhs_ballP; exists 1 => //= y x1y.
apply MA; rewrite lte_fin.
rewrite addrC -ltr_subr_addl in M'x.
rewrite (lt_le_trans M'x) // ler_subl_addl addrC -ler_subl_addl.
rewrite (le_trans _ (ltW x1y)) // real_ler_norm // realB //.
rewrite ltr_subr_addr in M'x.
rewrite -comparabler0 (@comparabler_trans _ (M + 1)) //.
by rewrite /Order.comparable (ltW M'x) orbT.
by rewrite comparabler0 realD // real1.
by rewrite num_real. (* where we really use realFieldType *)
by exists M.
- exists (M - 1); split; first by rewrite realB // real1.
move=> -[x| _ |] //=.
rewrite lte_fin => M'x /=.
apply/nbhs_ballP; exists 1 => //= y x1y.
apply MA; rewrite lte_fin.
rewrite ltr_subr_addl in M'x.
rewrite (le_lt_trans _ M'x) // addrC -ler_subl_addl.
rewrite (le_trans _ (ltW x1y)) // distrC real_ler_norm // realB //.
by rewrite num_real. (* where we really use realFieldType *)
rewrite addrC -ltr_subr_addr in M'x.
rewrite -comparabler0 (@comparabler_trans _ (M - 1)) //.
by rewrite /Order.comparable (ltW M'x).
by rewrite comparabler0 realB // real1.
by exists M.
Qed.
Definition ereal_topologicalMixin : Topological.mixin_of (@ereal_nbhs R) :=
topologyOfFilterMixin _ ereal_nbhs_singleton ereal_nbhs_nbhs.
Canonical ereal_topologicalType := TopologicalType _ ereal_topologicalMixin.
End ereal_topologicalType.
Definition pinfty_nbhs (R : numFieldType) : set (set R) :=
fun P => exists M, M \is Num.real /\ forall x, M < x -> P x.
Arguments pinfty_nbhs R : clear implicits.
Definition ninfty_nbhs (R : numFieldType) : set (set R) :=
fun P => exists M, M \is Num.real /\ forall x, x < M -> P x.
Arguments ninfty_nbhs R : clear implicits.
Notation "+oo" := (pinfty_nbhs _) : ring_scope.
Notation "-oo" := (ninfty_nbhs _) : ring_scope.
Section infty_nbhs_instances.
Context {R : numFieldType}.
Let R_topologicalType := [topologicalType of R].
Global Instance proper_pinfty_nbhs : ProperFilter (pinfty_nbhs R).
Proof.
apply Build_ProperFilter.
by move=> P [M [Mreal MP]]; exists (M + 1); apply MP; rewrite ltr_addl.
split=> /= [|P Q [MP [MPr gtMP]] [MQ [MQr gtMQ]] |P Q sPQ [M [Mr gtM]]].
- by exists 0; rewrite real0.
- have [/eqP MP0|MP0] := boolP (MP == 0).
have [/eqP MQ0|MQ0] := boolP (MQ == 0).
by exists 0; rewrite real0; split => // x x0; split;
[apply/gtMP; rewrite MP0 | apply/gtMQ; rewrite MQ0].
exists `|MQ|; rewrite realE normr_ge0; split => // x Hx; split.
by apply gtMP; rewrite (le_lt_trans _ Hx) // MP0.
by apply gtMQ; rewrite (le_lt_trans _ Hx) // real_ler_normr // lexx.
have [/eqP MQ0|MQ0] := boolP (MQ == 0).
exists `|MP|; rewrite realE normr_ge0; split => // x MPx; split.
by apply gtMP; rewrite (le_lt_trans _ MPx) // real_ler_normr // lexx.
by apply gtMQ; rewrite (le_lt_trans _ MPx) // MQ0.
have {}MP0 : 0 < `|MP| by rewrite normr_gt0.
have {}MQ0 : 0 < `|MQ| by rewrite normr_gt0.
exists (Num.max (PosNum MP0) (PosNum MQ0))%:num.
rewrite realE /= posnum_ge0 /=; split => // x.
rewrite posnum_max pos_lt_maxl /= => /andP[MPx MQx]; split.
by apply/gtMP; rewrite (le_lt_trans _ MPx) // real_ler_normr // lexx.
by apply/gtMQ; rewrite (le_lt_trans _ MQx) // real_ler_normr // lexx.
- by exists M; split => // ? /gtM /sPQ.
Defined.
Typeclasses Opaque proper_pinfty_nbhs.
Global Instance proper_ninfty_nbhs : ProperFilter (ninfty_nbhs R).
Proof.
apply Build_ProperFilter.
- move=> P [M [Mr ltMP]]; exists (M - 1).
by apply: ltMP; rewrite gtr_addl oppr_lt0.
- split=> /= [|P Q [MP [MPr ltMP]] [MQ [MQr ltMQ]] |P Q sPQ [M [Mr ltM]]].
+ by exists 0; rewrite real0.
+ have [/eqP MP0|MP0] := boolP (MP == 0).
have [/eqP MQ0|MQ0] := boolP (MQ == 0).
by exists 0; rewrite real0; split => // x x0; split;
[apply/ltMP; rewrite MP0 | apply/ltMQ; rewrite MQ0].
exists (- `|MQ|); rewrite realN realE normr_ge0; split => // x xMQ; split.
by apply ltMP; rewrite (lt_le_trans xMQ) // MP0 ler_oppl oppr0.
apply ltMQ; rewrite (lt_le_trans xMQ) // ler_oppl -normrN.
by rewrite real_ler_normr ?realN // lexx.
+ have [/eqP MQ0|MQ0] := boolP (MQ == 0).
exists (- `|MP|); rewrite realN realE normr_ge0; split => // x MPx; split.
apply ltMP; rewrite (lt_le_trans MPx) // ler_oppl -normrN.
by rewrite real_ler_normr ?realN // lexx.
by apply ltMQ; rewrite (lt_le_trans MPx) // MQ0 ler_oppl oppr0.
have {}MP0 : 0 < `|MP| by rewrite normr_gt0.
have {}MQ0 : 0 < `|MQ| by rewrite normr_gt0.
exists (- (Num.max (PosNum MP0) (PosNum MQ0))%:num).
rewrite realN realE /= posnum_ge0 /=; split => // x.
rewrite ltr_oppr posnum_max pos_lt_maxl => /andP[].
rewrite ltr_oppr => MPx; rewrite ltr_oppr => MQx; split.
apply/ltMP; rewrite (lt_le_trans MPx) //= ler_oppl -normrN.
by rewrite real_ler_normr ?realN // lexx.
apply/ltMQ; rewrite (lt_le_trans MQx) //= ler_oppl -normrN.
by rewrite real_ler_normr ?realN // lexx.
+ by exists M; split => // x /ltM /sPQ.