forked from leanprover-community/mathlib
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gromov_hausdorff.lean
1309 lines (1197 loc) · 71.6 KB
/
gromov_hausdorff.lean
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
/-
Copyright (c) 2018 Sébastien Gouëzel. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Author: Sébastien Gouëzel
The Gromov-Hausdorff distance on nonempty compact spaces.
We introduces the space of all nonempty compact spaces, up to isometry,
called `GH_space`, and endow it with a metric space structure. The distance,
known as the Gromov-Hausdorff distance, is defined as follows: given two
nonempty compact spaces X and Y, their distance is the minimum Hausdorff distance
between all possible isometric embeddings of X and Y in all metric spaces.
To define properly the Gromov-Hausdorff space, we consider the non-empty
compact subsets of ℓ^∞(ℝ) up to isometry, which is a well-defined type,
and define the distance as the infimum of the Hausdorff distance over all
embeddings in ℓ^∞(ℝ). We prove that this coincides with the previous description,
as all separable metric spaces embed isometrically into ℓ^∞(ℝ), through an
embedding called the Kuratowski embedding.
To prove that we have a distance, we should show that if spaces can be coupled
to be arbitrarily close, then they are isometric. More generally, the Gromov-Hausdorff
distance is realized, i.e., there is a coupling for which the Hausdorff distance
is exactly the Gromov-Hausdorff distance. This follows from a compactness
argument, essentially following from Arzela-Ascoli.
-/
import topology.bounded_continuous_function topology.metric_space.hausdorff_distance
tactic.tidy
noncomputable theory
local attribute [instance, priority 0] classical.prop_decidable
universes u v w
open classical lattice set function topological_space filter metric quotient bounded_continuous_function
open sum (inl inr)
set_option class.instance_max_depth 60
@[reducible] def l_infty_ℝ : Type := bounded_continuous_function ℕ ℝ
local attribute [instance] metric_space_sum
namespace Gromov_Hausdorff
section Gromov_Hausdorff_realized
/- Preliminary 1 : construction of the optimal coupling.
This section contains preliminaries to show that the Gromov-Hausdorff distance
is realized. For this, we consider candidate distances on the disjoint union
α ⊕ β of two compact nonempty spaces, almost realizing the Gromov-Hausdorff
distance, and show that they form a compact family by applying Arzela-Ascoli
theorem. The existence of a minimizer follows. -/
section definitions
variables (α : Type u) (β : Type v)
[metric_space α] [compact_space α] [nonempty α]
[metric_space β] [compact_space β] [nonempty β]
@[reducible] private def prod_space_fun : Type* := ((α ⊕ β) × (α ⊕ β)) → ℝ
@[reducible] private def Cb : Type* := bounded_continuous_function ((α ⊕ β) × (α ⊕ β)) ℝ
private def max_var : ℝ := 2 * diam (univ : set α) + 1 + 2 * diam (univ : set β)
private lemma one_le_max_var : 1 ≤ max_var α β := calc
(1 : real) = 2 * 0 + 1 + 2 * 0 : by simp
... ≤ 2 * diam (univ : set α) + 1 + 2 * diam (univ : set β) :
begin
apply_rules [add_le_add, mul_le_mul_of_nonneg_left, diam_nonneg, diam_nonneg],
norm_num, norm_num, norm_num
end
/-- The set of functions on α ⊕ β that are candidates distances to realize the
minimum of the Hausdorff distances between α and β in a coupling -/
private def candidates : set (prod_space_fun α β) :=
{f | (((((∀x y : α, f (sum.inl x, sum.inl y) = dist x y)
∧ (∀x y : β, f (sum.inr x, sum.inr y) = dist x y))
∧ (∀x y, f (x, y) = f (y, x)))
∧ (∀x y z, f (x, z) ≤ f (x, y) + f (y, z)))
∧ (∀x, f (x, x) = 0))
∧ (∀x y, f (x, y) ≤ max_var α β) }
/-- Version of the set of candidates in bounded_continuous_functions, to apply
Arzela-Ascoli -/
private def candidates_b : set (Cb α β) := {f : Cb α β | f.val ∈ candidates α β}
end definitions --section
section constructions
variables {α : Type u} {β : Type v}
variables [metric_space α] [compact_space α] [nonempty α] [metric_space β] [compact_space β] [nonempty β]
variables {f : prod_space_fun α β} {x y z t : α ⊕ β}
local attribute [instance, priority 0] inhabited_of_nonempty'
private lemma max_var_bound : dist x y ≤ max_var α β := calc
dist x y ≤ diam (univ : set (α ⊕ β)) :
dist_le_diam_of_mem (bounded_of_compact compact_univ) (mem_univ _) (mem_univ _)
... = diam (inl '' (univ : set α) ∪ inr '' (univ : set β)) :
by apply congr_arg; ext x y z; cases x; simp [mem_univ, mem_range_self]
... ≤ diam (inl '' (univ : set α)) + dist (inl (default α)) (inr (default β)) + diam (inr '' (univ : set β)) :
diam_union (mem_image_of_mem _ (mem_univ _)) (mem_image_of_mem _ (mem_univ _))
... = diam (univ : set α) + (dist (default α) (default α) + 1 + dist (default β) (default β)) + diam (univ : set β) :
by rw [diam_image_of_isometry isometry_on_inl, diam_image_of_isometry isometry_on_inr];
[refl, by apply_instance, by apply_instance]
... = 1 * diam (univ : set α) + 1 + 1 * diam (univ : set β) : by simp
... ≤ 2 * diam (univ : set α) + 1 + 2 * diam (univ : set β) :
begin
apply_rules [add_le_add, mul_le_mul_of_nonneg_right, diam_nonneg, diam_nonneg, le_refl],
norm_num, norm_num
end
private lemma candidates_symm (fA : f ∈ candidates α β) : f (x, y) = f (y ,x) :=
by rw candidates at fA; exact fA.1.1.1.2 x y
private lemma candidates_triangle (fA : f ∈ candidates α β) : f (x, z) ≤ f (x, y) + f (y, z) :=
by rw candidates at fA; exact fA.1.1.2 x y z
private lemma candidates_refl (fA : f ∈ candidates α β) : f (x, x) = 0 :=
by rw candidates at fA; exact fA.1.2 x
private lemma candidates_nonneg (fA : f ∈ candidates α β) : 0 ≤ f (x, y) :=
begin
have : 0 ≤ 2 * f (x, y) := calc
0 = f (x, x) : (candidates_refl fA).symm
... ≤ f (x, y) + f (y, x) : candidates_triangle fA
... = f (x, y) + f (x, y) : by rw [candidates_symm fA]
... = 2 * f (x, y) : by ring,
by linarith
end
private lemma candidates_dist_inl (fA : f ∈ candidates α β) (x y: α) : f (inl x, inl y) = dist x y :=
by rw candidates at fA; exact fA.1.1.1.1.1 x y
private lemma candidates_dist_inr (fA : f ∈ candidates α β) (x y : β) : f (inr x, inr y) = dist x y :=
by rw candidates at fA; exact fA.1.1.1.1.2 x y
private lemma candidates_le_max_var (fA : f ∈ candidates α β) : f (x, y) ≤ max_var α β :=
by rw candidates at fA; exact fA.2 x y
/-- candidates are bounded by max_var α β -/
private lemma candidates_dist_bound (fA : f ∈ candidates α β) :
∀ {x y : α ⊕ β}, f (x, y) ≤ max_var α β * dist x y
| (inl x) (inl y) := calc
f (inl x, inl y) = dist x y : candidates_dist_inl fA x y
... = dist (inl x) (inl y) : begin rw @sum.dist_eq α β; refl end
... = 1 * dist (inl x) (inl y) : by simp
... ≤ max_var α β * dist (inl x) (inl y) :
mul_le_mul_of_nonneg_right (one_le_max_var α β) dist_nonneg
| (inl x) (inr y) := calc
f (inl x, inr y) ≤ max_var α β : candidates_le_max_var fA
... = max_var α β * 1 : by simp
... ≤ max_var α β * dist (inl x) (inr y) :
mul_le_mul_of_nonneg_left sum.one_dist_le (le_trans (zero_le_one) (one_le_max_var α β))
| (inr x) (inl y) := calc
f (inr x, inl y) ≤ max_var α β : candidates_le_max_var fA
... = max_var α β * 1 : by simp
... ≤ max_var α β * dist (inl x) (inr y) :
mul_le_mul_of_nonneg_left sum.one_dist_le (le_trans (zero_le_one) (one_le_max_var α β))
| (inr x) (inr y) := calc
f (inr x, inr y) = dist x y : candidates_dist_inr fA x y
... = dist (inr x) (inr y) : by rw @sum.dist_eq α β; refl
... = 1 * dist (inr x) (inr y) : by simp
... ≤ max_var α β * dist (inr x) (inr y) :
mul_le_mul_of_nonneg_right (one_le_max_var α β) dist_nonneg
/-- Technical lemma to prove that candidates are Lipschitz -/
private lemma candidates_lipschitz_aux (fA : f ∈ candidates α β) : f (x, y) - f (z, t) ≤ 2 * max_var α β * dist (x, y) (z, t) :=
calc
f (x, y) - f(z, t) ≤ f (x, t) + f (t, y) - f (z, t) : add_le_add_right (candidates_triangle fA) _
... ≤ (f (x, z) + f (z, t) + f(t, y)) - f (z, t) :
add_le_add_right (add_le_add_right (candidates_triangle fA) _ ) _
... = f (x, z) + f (t, y) : by simp
... ≤ max_var α β * dist x z + max_var α β * dist t y :
add_le_add (candidates_dist_bound fA) (candidates_dist_bound fA)
... ≤ max_var α β * max (dist x z) (dist t y) + max_var α β * max (dist x z) (dist t y) :
begin
apply add_le_add,
apply mul_le_mul_of_nonneg_left (le_max_left (dist x z) (dist t y)) (le_trans zero_le_one (one_le_max_var α β)),
apply mul_le_mul_of_nonneg_left (le_max_right (dist x z) (dist t y)) (le_trans zero_le_one (one_le_max_var α β)),
end
... = 2 * max_var α β * max (dist x z) (dist y t) :
by simp [dist_comm]; ring
... = 2 * max_var α β * dist (x, y) (z, t) : by refl
/-- Candidates are Lipschitz -/
private lemma candidates_lipschitz (fA : f ∈ candidates α β) (p q : (α ⊕ β) × (α ⊕ β)) :
dist (f p) (f q) ≤ 2 * max_var α β * dist p q :=
begin
rcases p with ⟨x, y⟩,
rcases q with ⟨z, t⟩,
rw real.dist_eq,
apply abs_le_of_le_of_neg_le,
{ exact candidates_lipschitz_aux fA },
{ have : -(f (x, y) - f (z, t)) = f (z, t) - f (x, y) := by ring,
rw [this, dist_comm],
exact candidates_lipschitz_aux fA }
end
/-- candidates give rise to elements of bounded_continuous_functions -/
private def candidates_b_of_candidates (f : prod_space_fun α β) (fA : f ∈ candidates α β) : Cb α β :=
bounded_continuous_function.mk_of_compact f (continuous_of_lipschitz (candidates_lipschitz fA))
private lemma candidates_b_of_candidates_mem (f : prod_space_fun α β) (fA : f ∈ candidates α β) :
candidates_b_of_candidates f fA ∈ candidates_b α β := fA
/-- The distance on α ⊕ β is a candidate -/
private lemma dist_mem_candidates : (λp : (α ⊕ β) × (α ⊕ β), dist p.1 p.2) ∈ candidates α β :=
begin
simp only [candidates, dist_comm, forall_const, and_true, add_comm, eq_self_iff_true,
and_self, sum.forall, set.mem_set_of_eq, dist_self],
repeat { split
<|> exact (λa y z, dist_triangle_left _ _ _)
<|> exact (λx y, by refl)
<|> exact (λx y, max_var_bound) }
end
private def candidates_b_dist (α : Type u) (β : Type v) [metric_space α] [compact_space α] [inhabited α]
[metric_space β] [compact_space β] [inhabited β] : Cb α β := candidates_b_of_candidates _ dist_mem_candidates
private lemma candidates_b_dist_mem_candidates_b : candidates_b_dist α β ∈ candidates_b α β :=
candidates_b_of_candidates_mem _ _
private lemma candidates_b_ne_empty : candidates_b α β ≠ ∅ :=
ne_empty_of_mem candidates_b_dist_mem_candidates_b
/-- To apply Arzela-Ascoli, we need to check that the set of candidates is closed and equicontinuous.
Equicontinuity follows from the Lipschitz control, we check closedness -/
private lemma closed_candidates_b : is_closed (candidates_b α β) :=
begin
have I1 : ∀x y, is_closed {f : Cb α β | f (inl x, inl y) = dist x y} :=
λx y, is_closed_eq continuous_evalx continuous_const,
have I2 : ∀x y, is_closed {f : Cb α β | f (inr x, inr y) = dist x y } :=
λx y, is_closed_eq continuous_evalx continuous_const,
have I3 : ∀x y, is_closed {f : Cb α β | f (x, y) = f (y, x)} :=
λx y, is_closed_eq continuous_evalx continuous_evalx,
have I4 : ∀x y z, is_closed {f : Cb α β | f (x, z) ≤ f (x, y) + f (y, z)} :=
λx y z, is_closed_le continuous_evalx (continuous_add continuous_evalx continuous_evalx),
have I5 : ∀x, is_closed {f : Cb α β | f (x, x) = 0} :=
λx, is_closed_eq continuous_evalx continuous_const,
have I6 : ∀x y, is_closed {f : Cb α β | f (x, y) ≤ max_var α β} :=
λx y, is_closed_le continuous_evalx continuous_const,
have : candidates_b α β = (⋂x y, {f : Cb α β | f ((@inl α β x), (@inl α β y)) = dist x y})
∩ (⋂x y, {f : Cb α β | f ((@inr α β x), (@inr α β y)) = dist x y})
∩ (⋂x y, {f : Cb α β | f (x, y) = f (y, x)})
∩ (⋂x y z, {f : Cb α β | f (x, z) ≤ f (x, y) + f (y, z)})
∩ (⋂x, {f : Cb α β | f (x, x) = 0})
∩ (⋂x y, {f : Cb α β | f (x, y) ≤ max_var α β}) :=
begin ext, unfold candidates_b, unfold candidates, simp [-sum.forall], refl end,
rw this,
repeat { apply is_closed_inter _ _
<|> apply is_closed_Inter _
<|> apply I1 _ _
<|> apply I2 _ _
<|> apply I3 _ _
<|> apply I4 _ _ _
<|> apply I5 _
<|> apply I6 _ _
<|> assume x },
end
/-- Compactness of candidates (in bounded_continuous_functions) follows -/
private lemma compact_candidates_b : compact (candidates_b α β) :=
begin
refine arzela_ascoli₂ (Icc 0 (max_var α β)) compact_Icc (candidates_b α β) closed_candidates_b _ _,
{ rintros f ⟨x1, x2⟩ hf,
simp only [set.mem_Icc],
exact ⟨candidates_nonneg hf, candidates_le_max_var hf⟩ },
{ refine equicontinuous_of_continuity_modulus (λt, 2 * max_var α β * t) _ _ _,
{ have : tendsto (λ (t : ℝ), 2 * max_var α β * t) (nhds 0) (nhds (2 * max_var α β * 0)) :=
tendsto_mul tendsto_const_nhds tendsto_id,
simpa using this },
{ assume x y f hf,
exact candidates_lipschitz hf _ _ }}
end
/-- We will then choose the candidate minimizing the Hausdorff distance. Except that we are not
in a metric space setting, so we need to define our custom version of Hausdorff distance,
called HD, and prove its basic properties. -/
private def HD (f : Cb α β) := max (supr (λx:α, infi (λy:β, f (inl x, inr y))))
(supr (λy:β, infi (λx:α, f (inl x, inr y))))
/- We will show that HD is continuous on bounded_continuous_functions, to deduce that its
minimum on the compact set candidates_b is attained. Since it is defined in terms of
infimum and supremum on ℝ, which is only conditionnally complete, we will need all the time
to check that the defining sets are bounded below or above. This is done in the next few
technical lemmas -/
private lemma HD_below_aux1 {f : Cb α β} (C : ℝ) {x : α} : bdd_below (range (λ (y : β), f (inl x, inr y) + C)) :=
let ⟨cf, hcf⟩ := (real.bounded_iff_bdd_below_bdd_above.1 bounded_range).1 in
⟨cf + C, forall_range_iff.2 (λi, add_le_add_right ((λx, hcf (f x) (mem_range_self _)) _) _)⟩
private lemma HD_bound_aux1 (f : Cb α β) (C : ℝ) : bdd_above (range (λ (x : α), infi (λy:β, f (inl x, inr y) + C))) :=
begin
rcases (real.bounded_iff_bdd_below_bdd_above.1 bounded_range).2 with ⟨Cf, hCf⟩,
refine ⟨Cf + C, forall_range_iff.2 (λx, _)⟩,
calc infi (λy:β, f (inl x, inr y) + C) ≤ f (inl x, inr (default β)) + C :
cinfi_le (HD_below_aux1 C)
... ≤ Cf + C : add_le_add ((λx, hCf (f x) (mem_range_self _)) _) (le_refl _)
end
private lemma HD_below_aux2 {f : Cb α β} (C : ℝ) {y : β} : bdd_below (range (λ (x : α), f (inl x, inr y) + C)) :=
let ⟨cf, hcf⟩ := (real.bounded_iff_bdd_below_bdd_above.1 bounded_range).1 in
⟨cf + C, forall_range_iff.2 (λi, add_le_add_right ((λx, hcf (f x) (mem_range_self _)) _) _)⟩
private lemma HD_bound_aux2 (f : Cb α β) (C : ℝ) : bdd_above (range (λ (y : β), infi (λx:α, f (inl x, inr y) + C))) :=
begin
rcases (real.bounded_iff_bdd_below_bdd_above.1 bounded_range).2 with ⟨Cf, hCf⟩,
refine ⟨Cf + C, forall_range_iff.2 (λy, _)⟩,
calc infi (λx:α, f (inl x, inr y) + C) ≤ f (inl (default α), inr y) + C :
cinfi_le (HD_below_aux2 C)
... ≤ Cf + C : add_le_add ((λx, hCf (f x) (mem_range_self _)) _) (le_refl _)
end
/-- Explicit bound on HD (dist). This means that when looking for minimizers it will
be sufficient to look for functions with HD(f) bounded by this bound. -/
private lemma HD_candidates_b_dist_le : HD (candidates_b_dist α β) ≤ diam (univ : set α) + 1 + diam (univ : set β) :=
begin
refine max_le (csupr_le (λx, _)) (csupr_le (λy, _)),
{ have A : infi (λy:β, candidates_b_dist α β (inl x, inr y)) ≤ candidates_b_dist α β (inl x, inr (default β)) :=
cinfi_le (by simpa using HD_below_aux1 0),
have B : dist (inl x) (inr (default β)) ≤ diam (univ : set α) + 1 + diam (univ : set β) := calc
dist (inl x) (inr (default β)) = dist x (default α) + 1 + dist (default β) (default β) : rfl
... ≤ diam (univ : set α) + 1 + diam (univ : set β) :
begin
apply add_le_add (add_le_add _ (le_refl _)),
exact dist_le_diam_of_mem (bounded_of_compact (compact_univ)) (mem_univ _) (mem_univ _),
exact dist_le_diam_of_mem (bounded_of_compact (compact_univ)) (mem_univ _) (mem_univ _)
end,
exact le_trans A B },
{ have A : infi (λx:α, candidates_b_dist α β (inl x, inr y)) ≤ candidates_b_dist α β (inl (default α), inr y) :=
cinfi_le (by simpa using HD_below_aux2 0),
have B : dist (inl (default α)) (inr y) ≤ diam (univ : set α) + 1 + diam (univ : set β) := calc
dist (inl (default α)) (inr y) = dist (default α) (default α) + 1 + dist (default β) y : rfl
... ≤ diam (univ : set α) + 1 + diam (univ : set β) :
begin
apply add_le_add (add_le_add _ (le_refl _)),
exact dist_le_diam_of_mem (bounded_of_compact (compact_univ)) (mem_univ _) (mem_univ _),
exact dist_le_diam_of_mem (bounded_of_compact (compact_univ)) (mem_univ _) (mem_univ _)
end,
exact le_trans A B },
end
/- To check that HD is continuous, we check that it is Lipschitz. As HD is a max, we
prove separately inequalities controlling the two terms (relying too heavily on copy-paste...) -/
private lemma HD_lipschitz_aux1 (f g : Cb α β) :
supr (λx:α, infi (λy:β, f (inl x, inr y))) ≤ supr (λx:α, infi (λy:β, g (inl x, inr y))) + dist f g :=
begin
rcases (real.bounded_iff_bdd_below_bdd_above.1 bounded_range).1 with ⟨cg, hcg⟩,
have Hcg : ∀x, cg ≤ g x := λx, hcg (g x) (mem_range_self _),
rcases (real.bounded_iff_bdd_below_bdd_above.1 bounded_range).1 with ⟨cf, hcf⟩,
have Hcf : ∀x, cf ≤ f x := λx, hcf (f x) (mem_range_self _),
-- prove the inequality but with `dist f g` inside, by using inequalities comparing
-- supr to supr and infi to infi
have Z : supr (λx:α, infi (λy:β, f (inl x, inr y))) ≤ supr (λx:α, infi (λy:β, g (inl x, inr y) + dist f g)) :=
csupr_le_csupr (HD_bound_aux1 _ (dist f g))
(λx, cinfi_le_cinfi ⟨cf, forall_range_iff.2(λi, Hcf _)⟩ (λy, coe_le_coe_add_dist)),
-- move the `dist f g` out of the infimum and the supremum, arguing that continuous monotone maps
-- (here the addition of `dist f g`) preserve infimum and supremum
have E1 : ∀x, infi (λy:β, g (inl x, inr y)) + dist f g =
infi ((λz, z + dist f g) ∘ (λy:β, (g (inl x, inr y)))),
{ assume x,
refine cinfi_of_cinfi_of_monotone_of_continuous (_ : continuous (λ (z : ℝ), z + dist f g)) _ _,
{ exact continuous_add continuous_id continuous_const },
{ assume x y hx, simpa },
{ show bdd_below (range (λ (y : β), g (inl x, inr y))),
from ⟨cg, forall_range_iff.2(λi, Hcg _)⟩ }},
have E2 : supr (λx:α, infi (λy:β, g (inl x, inr y))) + dist f g =
supr ((λz, z + dist f g) ∘ (λx:α, infi (λy:β, g (inl x, inr y)))),
{ refine csupr_of_csupr_of_monotone_of_continuous (_ : continuous (λ (z : ℝ), z + dist f g)) _ _,
{ exact continuous_add continuous_id continuous_const },
{ assume x y hx, simpa },
{ by simpa using HD_bound_aux1 _ 0 }},
-- deduce the result from the above two steps
simp only [add_comm] at Z,
simpa [E2, E1, function.comp]
end
private lemma HD_lipschitz_aux2 (f g : Cb α β) :
supr (λy:β, infi (λx:α, f (inl x, inr y))) ≤ supr (λy:β, infi (λx:α, g (inl x, inr y))) + dist f g :=
begin
rcases (real.bounded_iff_bdd_below_bdd_above.1 bounded_range).1 with ⟨cg, hcg⟩,
have Hcg : ∀x, cg ≤ g x := λx, hcg (g x) (mem_range_self _),
rcases (real.bounded_iff_bdd_below_bdd_above.1 bounded_range).1 with ⟨cf, hcf⟩,
have Hcf : ∀x, cf ≤ f x := λx, hcf (f x) (mem_range_self _),
-- prove the inequality but with `dist f g` inside, by using inequalities comparing
-- supr to supr and infi to infi
have Z : supr (λy:β, infi (λx:α, f (inl x, inr y))) ≤ supr (λy:β, infi (λx:α, g (inl x, inr y) + dist f g)) :=
csupr_le_csupr (HD_bound_aux2 _ (dist f g))
(λy, cinfi_le_cinfi ⟨cf, forall_range_iff.2(λi, Hcf _)⟩ (λy, coe_le_coe_add_dist)),
-- move the `dist f g` out of the infimum and the supremum, arguing that continuous monotone maps
-- (here the addition of `dist f g`) preserve infimum and supremum
have E1 : ∀y, infi (λx:α, g (inl x, inr y)) + dist f g =
infi ((λz, z + dist f g) ∘ (λx:α, (g (inl x, inr y)))),
{ assume y,
refine cinfi_of_cinfi_of_monotone_of_continuous (_ : continuous (λ (z : ℝ), z + dist f g)) _ _,
{ exact continuous_add continuous_id continuous_const },
{ assume x y hx, simpa },
{ show bdd_below (range (λx:α, g (inl x, inr y))),
from ⟨cg, forall_range_iff.2(λi, Hcg _)⟩ }},
have E2 : supr (λy:β, infi (λx:α, g (inl x, inr y))) + dist f g =
supr ((λz, z + dist f g) ∘ (λy:β, infi (λx:α, g (inl x, inr y)))),
{ refine csupr_of_csupr_of_monotone_of_continuous (_ : continuous (λ (z : ℝ), z + dist f g)) _ _,
{ exact continuous_add continuous_id continuous_const },
{ assume x y hx, simpa },
{ by simpa using HD_bound_aux2 _ 0 }},
-- deduce the result from the above two steps
simp only [add_comm] at Z,
simpa [E2, E1, function.comp]
end
private lemma HD_lipschitz_aux3 (f g : Cb α β) : HD f ≤ HD g + dist f g :=
max_le (le_trans (HD_lipschitz_aux1 f g) (add_le_add_right (le_max_left _ _) _))
(le_trans (HD_lipschitz_aux2 f g) (add_le_add_right (le_max_right _ _) _))
/-- Conclude that HD, being Lipschitz, is continuous -/
private lemma HD_continuous : continuous (HD : Cb α β → ℝ) :=
uniform_continuous.continuous $ uniform_continuous_of_le_add 1 $
λf g, begin simp, exact HD_lipschitz_aux3 _ _ end
end constructions --section
section consequences
variables (α : Type u) (β : Type v) [metric_space α] [compact_space α] [nonempty α] [metric_space β] [compact_space β] [nonempty β]
/- Now that we have proved that the set of candidates is compact, and that HD is continuous,
we can finally select a candidate minimizing HD. This will be the candidate realizing the
optimal coupling. -/
private lemma exists_minimizer : ∃f ∈ candidates_b α β, ∀g ∈ candidates_b α β, HD f ≤ HD g :=
exists_forall_le_of_compact_of_continuous _ HD_continuous _ compact_candidates_b candidates_b_ne_empty
private definition optimal_GH_dist : Cb α β := classical.some (exists_minimizer α β)
private lemma optimal_GH_dist_mem_candidates_b : optimal_GH_dist α β ∈ candidates_b α β :=
by cases (classical.some_spec (exists_minimizer α β)); assumption
private lemma HD_optimal_GH_dist_le (g : Cb α β) (hg : g ∈ candidates_b α β) : HD (optimal_GH_dist α β) ≤ HD g :=
let ⟨Z1, Z2⟩ := classical.some_spec (exists_minimizer α β) in Z2 g hg
/-- With the optimal candidate, construct a premetric space structure on α ⊕ β, on which the
predistance is given by the candidate. Then, we will identify points at 0 predistance
to obtain a genuine metric space -/
def premetric_optimal_GH_dist : premetric_space (α ⊕ β) :=
{ dist := λp q, optimal_GH_dist α β (p, q),
dist_self := λx, candidates_refl (optimal_GH_dist_mem_candidates_b α β),
dist_comm := λx y, candidates_symm (optimal_GH_dist_mem_candidates_b α β),
dist_triangle := λx y z, candidates_triangle (optimal_GH_dist_mem_candidates_b α β) }
local attribute [instance] premetric_optimal_GH_dist
/-- A metric space which realizes the optimal coupling between α and β -/
@[reducible] definition optimal_GH_coupling : Type* :=
metric_quot (α ⊕ β)
instance : metric_space (optimal_GH_coupling α β) := by apply_instance
private lemma optimal_GH_dist.dist_eq (p q : α ⊕ β) : dist ⟦p⟧ ⟦q⟧ = (optimal_GH_dist α β).val (p, q) := rfl
/-- Injection of α in the optimal coupling between α and β -/
def optimal_GH_injl (x : α) : optimal_GH_coupling α β := ⟦inl x⟧
/-- The injection of α in the optimal coupling between α and β is an isometry. -/
lemma isometry_optimal_GH_injl : isometry_on (optimal_GH_injl α β) univ :=
begin
assume x y hx hy,
change dist ⟦inl x⟧ ⟦inl y⟧ = dist x y,
rw [optimal_GH_dist.dist_eq α β],
exact candidates_dist_inl (optimal_GH_dist_mem_candidates_b α β) _ _,
end
/-- Injection of β in the optimal coupling between α and β -/
def optimal_GH_injr (y : β) : optimal_GH_coupling α β := ⟦inr y⟧
/-- The injection of β in the optimal coupling between α and β is an isometry. -/
lemma isometry_optimal_GH_injr : isometry_on (optimal_GH_injr α β) univ :=
begin
assume x y hx hy,
change dist ⟦inr x⟧ ⟦inr y⟧ = dist x y,
rw [optimal_GH_dist.dist_eq α β],
exact candidates_dist_inr (optimal_GH_dist_mem_candidates_b α β) _ _,
end
/-- The optimal coupling between two compact spaces α and β is still a compact space -/
instance compact_space_optimal_GH_coupling : compact_space (optimal_GH_coupling α β) :=
⟨begin
have : (univ : set (optimal_GH_coupling α β)) = (optimal_GH_injl α β '' univ) ∪ (optimal_GH_injr α β '' univ),
{ refine subset.antisymm (λxc hxc, _) (subset_univ _),
rcases quotient.exists_rep xc with ⟨x, hx⟩,
cases x; rw ← hx,
{ have : ⟦inl x⟧ = optimal_GH_injl α β x := rfl,
rw this,
exact mem_union_left _ (mem_image_of_mem _ (mem_univ _)) },
{ have : ⟦inr x⟧ = optimal_GH_injr α β x := rfl,
rw this,
exact mem_union_right _ (mem_image_of_mem _ (mem_univ _)) }},
rw this,
exact compact_union_of_compact
(compact_image (compact_univ) (continuous_of_isometry (isometry_optimal_GH_injl α β)))
(compact_image (compact_univ) (continuous_of_isometry (isometry_optimal_GH_injr α β)))
end⟩
/-- For any candidate f, HD(f) is larger than or equal to the Hausdorff distance in the
optimal coupling. This follows from the fact that HD of the optimal candidate is exactly
the Hausdorff distance in the optimal coupling, although we only prove here the inequality
we need. -/
private lemma Hausdorff_dist_optimal_le_HD {f} (h : f ∈ candidates_b α β) :
Hausdorff_dist (range (optimal_GH_injl α β)) (range (optimal_GH_injr α β)) ≤ HD f :=
begin
refine le_trans (le_of_forall_le_of_dense (λr hr, _)) (HD_optimal_GH_dist_le α β f h),
have A : ∀ x ∈ range (optimal_GH_injl α β), ∃ y ∈ range (optimal_GH_injr α β), dist x y ≤ r,
{ assume x hx,
rcases mem_range.1 hx with ⟨z, hz⟩,
rw ← hz,
have I1 : supr (λx:α, infi (λy:β, optimal_GH_dist α β (inl x, inr y))) < r :=
lt_of_le_of_lt (le_max_left _ _) hr,
have I2 : infi (λy:β, optimal_GH_dist α β (inl z, inr y)) ≤ supr (λx:α, infi (λy:β, optimal_GH_dist α β (inl x, inr y))) :=
le_cSup (by simpa using HD_bound_aux1 _ 0) (mem_range_self _),
have I : infi (λy:β, optimal_GH_dist α β (inl z, inr y)) < r := lt_of_le_of_lt I2 I1,
rcases exists_lt_of_cInf_lt (by simpa) I with ⟨r', r'range, hr'⟩,
rcases mem_range.1 r'range with ⟨z', hz'⟩,
existsi [optimal_GH_injr α β z', mem_range_self _],
have : (optimal_GH_dist α β) (inl z, inr z') ≤ r := begin rw hz', exact le_of_lt hr' end,
exact this },
refine Hausdorff_dist.le_of_mem_dist_le_of_mem_dist_le _ _ _,
{ rcases exists_mem_of_nonempty α with ⟨xα, _⟩,
have : optimal_GH_injl α β xα ∈ range (optimal_GH_injl α β) := mem_range_self _,
rcases A _ this with ⟨y, yrange, hy⟩,
exact le_trans dist_nonneg hy },
{ exact A },
{ assume y hy,
rcases mem_range.1 hy with ⟨z, hz⟩,
rw ← hz,
have I1 : supr (λy:β, infi (λx:α, optimal_GH_dist α β (inl x, inr y))) < r :=
lt_of_le_of_lt (le_max_right _ _) hr,
have I2 : infi (λx:α, optimal_GH_dist α β (inl x, inr z)) ≤ supr (λy:β, infi (λx:α, optimal_GH_dist α β (inl x, inr y))) :=
le_cSup (by simpa using HD_bound_aux2 _ 0) (mem_range_self _),
have I : infi (λx:α, optimal_GH_dist α β (inl x, inr z)) < r := lt_of_le_of_lt I2 I1,
rcases exists_lt_of_cInf_lt (by simpa) I with ⟨r', r'range, hr'⟩,
rcases mem_range.1 r'range with ⟨z', hz'⟩,
existsi [optimal_GH_injl α β z', mem_range_self _],
have : (optimal_GH_dist α β) (inl z', inr z) ≤ r := begin rw hz', exact le_of_lt hr' end,
rw dist_comm,
exact this }
end
end consequences
/- We are done with the construction of the optimal coupling, prerequisiste number 1-/
end Gromov_Hausdorff_realized --section
section Kuratowski_embedding
variables {α : Type u} {f g : l_infty_ℝ} {n : nat} {C : real} [metric_space α] (x : ℕ → α) (a b : α)
/-- A metric space can be embedded in `l^∞_ℝ` via the distances to points in
a fixed countable set, if this set is dense. This map is given in the next definition,
without density assumptions. -/
def embedding_of_subset : l_infty_ℝ :=
of_normed_group_discrete (λn, dist a (x n) - dist (x 0) (x n)) (dist a (x 0)) (λ_, abs_dist_sub_le _ _ _)
lemma embedding_of_subset_coe : embedding_of_subset x a n = dist a (x n) - dist (x 0) (x n) := rfl
/-- The embedding map is always a semi-contraction. -/
lemma embedding_of_subset_dist_le (a b : α) : dist (embedding_of_subset x a) (embedding_of_subset x b) ≤ dist a b :=
begin
refine (dist_le dist_nonneg).2 (λn, _),
have A : dist a (x n) + (dist (x 0) (x n) + (-dist b (x n) + -dist (x 0) (x n))) = dist a (x n) - dist b (x n) := by ring,
simp only [embedding_of_subset_coe, real.dist_eq, A, add_comm, neg_add_rev, _root_.neg_neg, sub_eq_add_neg, add_left_comm],
exact abs_dist_sub_le _ _ _
end
/-- When the reference set is dense, the embedding map is an isometry on its image. -/
lemma embedding_of_subset_isometry (H : closure (range x) = univ) : isometry_on (embedding_of_subset x) univ :=
begin
assume a b _ _,
refine le_antisymm (embedding_of_subset_dist_le x a b) (real.le_of_forall_epsilon_le (λe epos, _)),
/- First step: find n with dist a (x n) < e -/
have A : a ∈ closure (range x) := by have B := mem_univ a; rwa [← H] at B,
rcases mem_closure_iff'.1 A (e/2) (half_pos epos) with ⟨d, ⟨drange, hd⟩⟩,
cases drange with n dn,
rw [← dn] at hd,
/- Second step: use the norm control at index n to conclude -/
have C : dist b (x n) - dist a (x n) = embedding_of_subset x b n - embedding_of_subset x a n :=
by simp [embedding_of_subset_coe]; ring,
have := calc
dist a b ≤ dist a (x n) + dist (x n) b : dist_triangle _ _ _
... = 2 * dist a (x n) + (dist b (x n) - dist a (x n)) : by simp [dist_comm]; ring
... ≤ 2 * dist a (x n) + abs (dist b (x n) - dist a (x n)) :
by apply_rules [add_le_add_left, le_abs_self]
... ≤ 2 * (e/2) + abs (embedding_of_subset x b n - embedding_of_subset x a n) :
begin rw [C], apply_rules [add_le_add, mul_le_mul_of_nonneg_left, le_of_lt hd, le_refl], norm_num end
... ≤ 2 * (e/2) + dist (embedding_of_subset x b) (embedding_of_subset x a) :
begin rw [← coe_diff], apply add_le_add_left, rw [coe_diff, ←real.dist_eq], apply dist_coe_le_dist end
... = dist (embedding_of_subset x b) (embedding_of_subset x a) + e : by ring,
simpa [dist_comm] using this
end
/-- Every separable metric space embeds isometrically in l_infty_ℝ. -/
theorem exists_isometric_embedding (α : Type u) [metric_space α] [separable_space α] :
∃(f : α → l_infty_ℝ), isometry_on f univ :=
begin
by_cases h : (univ : set α) = ∅,
{ simp [isometry_on_empty, h] },
{ /- We construct a map x : ℕ → α with dense image -/
rcases exists_mem_of_ne_empty h with basepoint,
haveI : inhabited α := ⟨basepoint⟩,
have : ∃s:set α, countable s ∧ closure s = univ := separable_space.exists_countable_closure_eq_univ _,
rcases this with ⟨S, ⟨S_countable, S_dense⟩⟩,
rcases countable_iff_exists_surjective.1 S_countable with ⟨x, x_range⟩,
have : closure (range x) = univ := univ_subset_iff.1 (by rw [← S_dense]; apply closure_mono; assumption),
/- Use embedding_of_subset to construct the desired isometry -/
exact ⟨embedding_of_subset x, embedding_of_subset_isometry x this⟩ }
end
/-- The Kuratowski embedding is an isometric embedding of a separable metric space in ℓ^∞(ℝ) -/
def Kuratowski_embedding (α : Type u) [metric_space α] [separable_space α] : α → l_infty_ℝ :=
classical.some (exists_isometric_embedding α)
/-- The Kuratowski embedding is an isometry -/
lemma Kuratowski_embedding_isometry {α : Type u} [metric_space α] [separable_space α] :
isometry_on (Kuratowski_embedding α) univ :=
classical.some_spec (exists_isometric_embedding α)
/-- Version of the Kuratowski embedding for nonempty compacts -/
def nonempty_compacts.Kuratowski_embedding (α : Type u) [metric_space α] [compact_space α] [i : nonempty α] :
nonempty_compacts l_infty_ℝ :=
⟨range (Kuratowski_embedding α),
begin
split,
{ rcases exists_mem_of_nonempty α with ⟨x, hx⟩,
have A : Kuratowski_embedding α x ∈ range (Kuratowski_embedding α) := ⟨x, by simp⟩,
apply ne_empty_of_mem A },
{ rw ← image_univ,
exact compact_image compact_univ (continuous_of_isometry Kuratowski_embedding_isometry) },
end⟩
end Kuratowski_embedding
section GH_space
/- In this section, we define the Gromov-Hausdorff space, denoted `GH_space` as the quotient
of nonempty compact subsets of ℓ^∞(ℝ) identifying isometric sets.
Using the Kuratwoski embedding, we get a canonical map `to_GH_space` mapping any nonempty
compact type to GH_space. -/
/-- Equivalence relation identifying two nonempty compact sets which are isometric -/
private definition isometry_rel : nonempty_compacts l_infty_ℝ → nonempty_compacts l_infty_ℝ → Prop :=
λx y, ∃Φ : l_infty_ℝ → l_infty_ℝ, isometry_on Φ x.val ∧ Φ '' x.val = y.val
/-- This is indeed an equivalence relation -/
private lemma is_equivalence_isometry_rel : equivalence isometry_rel :=
begin
repeat { split },
{ exact λx, ⟨id, ⟨λx y hx hy, by simp, by ext; simp⟩⟩ },
{ rintros x y ⟨Φ, ⟨isomΦ, imΦ⟩⟩,
existsi (inv_fun_on Φ x.val),
split,
{ rw ← imΦ,
apply isometry_on_inv_fun_on isomΦ },
{ rw ← imΦ,
apply inv_fun_on_image (inj_on_of_isometry_on isomΦ) (subset.refl _) }},
{ rintros x y z ⟨Φ, ⟨isomΦ, imΦ⟩⟩ ⟨Ψ, ⟨isomΨ, imΨ⟩⟩,
existsi (Ψ ∘ Φ),
split,
{ apply isometry_on_comp _ isomΨ isomΦ,
rw [maps_to', imΦ] },
{ rw [image_comp, imΦ, imΨ] }}
end
/-- setoid instance identifying two isometric nonempty compact subspaces of ℓ^∞(ℝ) -/
instance isometry_rel.setoid : setoid (nonempty_compacts l_infty_ℝ) :=
setoid.mk isometry_rel is_equivalence_isometry_rel
/-- The Gromov-Hausdorff space -/
definition GH_space : Type := quotient (isometry_rel.setoid)
/-- Map any nonempty compact type to GH_space -/
definition to_GH_space (α : Type u) [metric_space α] [compact_space α] [nonempty α] : GH_space :=
⟦nonempty_compacts.Kuratowski_embedding α⟧
definition rep_GH_space (p : GH_space) : Type := (some (quot.exists_rep p)).val
lemma eq_to_GH_space_iff {α : Type u} [metric_space α] [compact_space α] [nonempty α] {p : nonempty_compacts l_infty_ℝ} :
⟦p⟧ = to_GH_space α ↔ ∃Ψ : α → l_infty_ℝ, isometry_on Ψ univ ∧ range Ψ = p.val :=
begin
simp only [to_GH_space, quotient.eq],
split,
{ assume h,
have h' := setoid.symm h,
change ∃Φ : l_infty_ℝ → l_infty_ℝ, isometry_on Φ (range (Kuratowski_embedding α))
∧ Φ '' (range (Kuratowski_embedding α)) = p.val at h',
rcases h' with ⟨Φ, ⟨Φisom, Φrange⟩⟩,
existsi (Φ ∘ (Kuratowski_embedding α)),
split,
{ exact isometry_on_comp (maps_to_range _ _) Φisom Kuratowski_embedding_isometry },
{ by rwa range_comp }},
{ rintros ⟨Ψ, ⟨isomΨ, rangeΨ⟩⟩,
letI : inhabited α := classical.inhabited_of_nonempty (by assumption),
change (∃Φ : l_infty_ℝ → l_infty_ℝ, isometry_on Φ p.val ∧ Φ '' p.val = range (Kuratowski_embedding α)),
existsi (Kuratowski_embedding α) ∘ (inv_fun_on Ψ univ),
split,
{ apply isometry_on_comp (maps_to_univ _ _) Kuratowski_embedding_isometry,
rw [← rangeΨ, ← image_univ],
apply isometry_on_inv_fun_on isomΨ },
{ rw [← rangeΨ, ← image_univ, image_comp, inv_fun_on_image, image_univ],
{ exact inj_on_of_isometry_on isomΨ },
{exact subset.refl _ }}}
end
lemma eq_to_GH_space {p : nonempty_compacts l_infty_ℝ} : ⟦p⟧ = to_GH_space p.val :=
eq_to_GH_space_iff.2 ⟨((λx, x) : p.val → l_infty_ℝ), isometry_on_subtype.val, subtype_val_range⟩
section
local attribute [reducible] rep_GH_space
instance rep_GH_space_metric_space {p : GH_space} : metric_space (rep_GH_space p) :=
by apply_instance
instance rep_GH_space_compact_space {p : GH_space} : compact_space (rep_GH_space p) :=
by apply_instance
instance rep_GH_space_nonempty {p : GH_space} : nonempty (rep_GH_space p) :=
by apply_instance
end
lemma to_GH_space_rep_GH_space (p : GH_space) : to_GH_space (rep_GH_space p) = p :=
begin
change to_GH_space ((some (quot.exists_rep p)).val) = p,
rw ← eq_to_GH_space,
exact some_spec ((quot.exists_rep p))
end
/-- Two nonempty compact spaces have the same image in GH_space if and only if they are isometric -/
lemma to_GH_space_eq_to_GH_space_iff_isometric {α : Type u} [metric_space α] [compact_space α] [nonempty α]
{β : Type u} [metric_space β] [compact_space β] [nonempty β] :
to_GH_space α = to_GH_space β ↔ ∃Φ : α → β, isometry_on Φ univ ∧ range Φ = univ :=
⟨begin
assume h,
rcases eq_to_GH_space_iff.1 h with ⟨Ψ, ⟨Ψisom, Ψrange⟩⟩,
let Φ := Kuratowski_embedding α,
have Ψrange' : range Ψ = range Φ := Ψrange,
letI : inhabited β := inhabited_of_nonempty',
existsi ((inv_fun_on Ψ univ) ∘ Φ),
split,
{ apply isometry_on_comp (maps_to_range _ univ) _ Kuratowski_embedding_isometry,
rw [← Ψrange', ← image_univ],
exact isometry_on_inv_fun_on Ψisom },
{ rw [← image_univ, image_comp, image_univ, ← Ψrange', ← image_univ],
apply inv_fun_on_image (inj_on_of_isometry_on Ψisom) (subset_univ _) }
end,
begin
rintros ⟨Φ, ⟨Φisom, Φrange⟩⟩,
apply eq.symm,
erw [eq_to_GH_space_iff],
let Ψ := Kuratowski_embedding β,
existsi (Ψ ∘ Φ),
split,
{ exact isometry_on_comp (maps_to_univ _ _) Kuratowski_embedding_isometry Φisom },
{ rw [← image_univ, image_comp, image_univ, Φrange, image_univ], refl }
end⟩
/-- Distance on GH_space : the distance between two nonempty compact spaces is the infimum
Hausdorff distance between isometric copies of the two spaces in a metric space. For the definition,
we only consider embeddings in ℓ^∞(ℝ), but we will prove below that it works for all spaces. -/
instance : has_dist (GH_space) :=
{ dist := λx y, Inf ((λp : nonempty_compacts l_infty_ℝ × nonempty_compacts l_infty_ℝ, Hausdorff_dist p.1.val p.2.val) ''
(set.prod {a | ⟦a⟧ = x} {b | ⟦b⟧ = y})) }
def GH_dist (α : Type u) (β : Type v) [metric_space α] [nonempty α] [compact_space α]
[metric_space β] [nonempty β] [compact_space β] : ℝ := dist (to_GH_space α) (to_GH_space β)
lemma dist_GH_dist (p q : GH_space) : dist p q = GH_dist (rep_GH_space p) (rep_GH_space q) :=
by rw [GH_dist, to_GH_space_rep_GH_space, to_GH_space_rep_GH_space]
/-- The Gromov-Hausdorff distance between two spaces is bounded by the Hausdorff distance
of isometric copies of the spaces, in any metric space. -/
theorem GH_dist_le_Hausdorff_dist {α : Type u} [metric_space α] [compact_space α] [nonempty α]
{β : Type v} [metric_space β] [compact_space β] [nonempty β]
{γ : Type w} [metric_space γ] {Φ : α → γ} {Ψ : β → γ} (ha : isometry_on Φ univ) (hb : isometry_on Ψ univ) :
GH_dist α β ≤ Hausdorff_dist (range Φ) (range Ψ) :=
begin
/- For the proof, we want to embed γ in ℓ^∞(ℝ), to say that the Hausdorff distance is realized
in ℓ^∞(ℝ) and therefore bounded below by the Gromov-Hausdorff-distance. However, γ is not
separable in general. We restrict to the union of the images of α and β in γ, which is
separable and therefore embeddable in ℓ^∞(ℝ). -/
rcases exists_mem_of_nonempty α with ⟨xα, _⟩,
letI : inhabited α := ⟨xα⟩,
letI : inhabited β := classical.inhabited_of_nonempty (by assumption),
let s : set γ := (range Φ) ∪ (range Ψ),
let Φ' : α → subtype s := λy, ⟨Φ y, mem_union_left _ (mem_range_self _)⟩,
let Ψ' : β → subtype s := λy, ⟨Ψ y, mem_union_right _ (mem_range_self _)⟩,
have : isometry_on Φ' univ := λx y hx hy, ha hx hy,
have : isometry_on Ψ' univ := λx y hx hy, hb hx hy,
have : compact s,
{ apply compact_union_of_compact,
{ rw ← image_univ,
apply compact_image (compact_univ) (continuous_of_isometry ha) },
{ rw ← image_univ,
apply compact_image (compact_univ) (continuous_of_isometry hb) }},
letI : metric_space (subtype s) := by apply_instance,
haveI : compact_space (subtype s) := ⟨compact_iff_compact_univ.1 ‹compact s›⟩,
haveI : nonempty (subtype s) := ⟨Φ' xα⟩,
have ΦΦ' : Φ = subtype.val ∘ Φ' := by funext; refl,
have ΨΨ' : Ψ = subtype.val ∘ Ψ' := by funext; refl,
have : Hausdorff_dist (range Φ) (range Ψ) = Hausdorff_dist (range Φ') (range Ψ'),
{ rw [ΦΦ', ΨΨ', range_comp, range_comp],
exact Hausdorff_dist.image (subset_univ _) (subset_univ _) (isometry_on_subtype.val) },
rw this,
-- Embed s in ℓ^∞(ℝ) through its Kuratowski embedding
let F := Kuratowski_embedding (subtype s),
have : Hausdorff_dist (F '' (range Φ')) (F '' (range Ψ')) = Hausdorff_dist (range Φ') (range Ψ') :=
Hausdorff_dist.image (subset_univ _) (subset_univ _) Kuratowski_embedding_isometry,
rw ← this,
-- Let A and B be the images of α and β under this embedding. They are in ℓ^∞(ℝ), and
-- their Hausdorff distance is the same as in the original space.
let A : nonempty_compacts l_infty_ℝ := ⟨F '' (range Φ'), ⟨by simp, begin
rw [← range_comp, ← image_univ],
exact compact_image compact_univ
(continuous.comp (continuous_of_isometry ‹isometry_on Φ' univ›) (continuous_of_isometry Kuratowski_embedding_isometry)),
end⟩⟩,
let B : nonempty_compacts l_infty_ℝ := ⟨F '' (range Ψ'), ⟨by simp, begin
rw [← range_comp, ← image_univ],
exact compact_image compact_univ
(continuous.comp (continuous_of_isometry ‹isometry_on Ψ' univ›) (continuous_of_isometry Kuratowski_embedding_isometry)),
end⟩⟩,
have Aα : ⟦A⟧ = to_GH_space α,
{ rw [to_GH_space, quotient.eq],
change ∃G : l_infty_ℝ → l_infty_ℝ, isometry_on G (F '' (range Φ')) ∧ G '' (F '' (range Φ')) = range (Kuratowski_embedding α),
existsi (Kuratowski_embedding α) ∘ (inv_fun_on (F ∘ Φ') (univ : set α)),
split,
{ apply isometry_on_comp (maps_to_univ _ _) Kuratowski_embedding_isometry,
rw [← range_comp, ← image_univ],
exact isometry_on_inv_fun_on (isometry_on_comp (maps_to_univ _ _) Kuratowski_embedding_isometry ‹isometry_on Φ' univ›) },
{ rw [← range_comp, image_comp, ← image_univ, inv_fun_on_image _ (subset.refl _), image_univ],
exact inj_on_of_isometry_on (isometry_on_comp (maps_to_univ _ _) Kuratowski_embedding_isometry ‹isometry_on Φ' univ›) }},
have Bβ : ⟦B⟧ = to_GH_space β,
{ rw [to_GH_space, quotient.eq],
change ∃G : l_infty_ℝ → l_infty_ℝ, isometry_on G (F '' (range Ψ')) ∧ G '' (F '' (range Ψ')) = range (Kuratowski_embedding β),
existsi (Kuratowski_embedding β) ∘ (inv_fun_on (F ∘ Ψ') (univ : set β)),
split,
{ apply isometry_on_comp (maps_to_univ _ _) Kuratowski_embedding_isometry,
rw [← range_comp, ← image_univ],
exact isometry_on_inv_fun_on (isometry_on_comp (maps_to_univ _ _) Kuratowski_embedding_isometry ‹isometry_on Ψ' univ›) },
{ rw [← range_comp, image_comp, ← image_univ, inv_fun_on_image _ (subset.refl _), image_univ],
exact inj_on_of_isometry_on (isometry_on_comp (maps_to_univ _ _) Kuratowski_embedding_isometry ‹isometry_on Ψ' univ›) }},
refine cInf_le ⟨0, begin simp, assume t _ _ _ _ ht, rw ← ht, exact Hausdorff_dist.nonneg end⟩ _,
apply (mem_image _ _ _).2,
existsi (⟨A, B⟩ : nonempty_compacts l_infty_ℝ × nonempty_compacts l_infty_ℝ),
simp [Aα, Bβ],
end
local attribute [instance, priority 0] inhabited_of_nonempty'
/-- The optimal coupling constructed above realizes exactly the Gromov-Hausdorff distance,
essentially by design. -/
lemma Hausdorff_dist_optimal {α : Type u} [metric_space α] [compact_space α] [nonempty α]
{β : Type v} [metric_space β] [compact_space β] [nonempty β] :
Hausdorff_dist (range (optimal_GH_injl α β)) (range (optimal_GH_injr α β)) = GH_dist α β :=
begin
/- we only need to check the inequality ≤, as the other one follows from the previous lemma.
As the Gromov-Hausdorff distance is an infimum, we need to check that the Hausdorff distance
in the optimal coupling is smaller than the Hausdorff distance of any coupling.
First, we check this for couplings which already have small Hausdorff distance: in this
case, the induced "distance" on α ⊕ β belongs to the candidates family introduced in the
definition of the optimal coupling, and the conclusion follows from the optimality
of the optimal coupling within this family.
-/
have A : ∀p q : nonempty_compacts (l_infty_ℝ), ⟦p⟧ = to_GH_space α → ⟦q⟧ = to_GH_space β →
Hausdorff_dist (p.val) (q.val) < diam (univ : set α) + 1 + diam (univ : set β) →
Hausdorff_dist (range (optimal_GH_injl α β)) (range (optimal_GH_injr α β)) ≤ Hausdorff_dist (p.val) (q.val),
{ assume p q hp hq bound,
rcases eq_to_GH_space_iff.1 hp with ⟨Φ, ⟨Φisom, Φrange⟩⟩,
rcases eq_to_GH_space_iff.1 hq with ⟨Ψ, ⟨Ψisom, Ψrange⟩⟩,
have I : diam (range Φ ∪ range Ψ) ≤ 2 * diam (univ : set α) + 1 + 2 * diam (univ : set β),
{ rcases exists_mem_of_nonempty α with ⟨xα, _⟩,
have : ∃y ∈ range Ψ, dist (Φ xα) y < diam (univ : set α) + 1 + diam (univ : set β),
{ rw Ψrange,
have : Φ xα ∈ p.val := begin rw ← Φrange, exact mem_range_self _ end,
exact exists_dist_lt_of_Hausdorff_dist_lt this bound
(Hausdorff_edist_ne_top_of_bounded_of_ne_empty p.2.1 q.2.1 (bounded_of_compact p.2.2) (bounded_of_compact q.2.2)) },
rcases this with ⟨y, hy, dy⟩,
rcases mem_range.1 hy with ⟨z, hzy⟩,
rw ← hzy at dy,
have DΦ : diam (range Φ) = diam (univ : set α) :=
begin rw [← image_univ], apply diam_image_of_isometry Φisom end,
have DΨ : diam (range Ψ) = diam (univ : set β) :=
begin rw [← image_univ], apply diam_image_of_isometry Ψisom end,
calc
diam (range Φ ∪ range Ψ) ≤ diam (range Φ) + dist (Φ xα) (Ψ z) + diam (range Ψ) :
diam_union (mem_range_self _) (mem_range_self _)
... ≤ diam (univ : set α) + (diam (univ : set α) + 1 + diam (univ : set β)) + diam (univ : set β) :
by rw [DΦ, DΨ]; apply add_le_add (add_le_add (le_refl _) (le_of_lt dy)) (le_refl _)
... = 2 * diam (univ : set α) + 1 + 2 * diam (univ : set β) : by ring },
let f : α ⊕ β → l_infty_ℝ := λx, match x with | inl y := Φ y | inr z := Ψ z end,
let F : (α ⊕ β) × (α ⊕ β) → ℝ := λp, dist (f p.1) (f p.2),
-- check that the induced "distance" is a candidate
have Fgood : F ∈ candidates α β,
{ simp only [candidates, forall_const, and_true, add_comm, eq_self_iff_true, dist_eq_zero,
and_self, set.mem_set_of_eq],
repeat {split},
{ exact λx y, calc
F (inl x, inl y) = dist (Φ x) (Φ y) : rfl
... = dist x y : Φisom (mem_univ _) (mem_univ _) },
{ exact λx y, calc
F (inr x, inr y) = dist (Ψ x) (Ψ y) : rfl
... = dist x y : Ψisom (mem_univ _) (mem_univ _) },
{ exact λx y, dist_comm _ _ },
{ exact λx y z, dist_triangle _ _ _ },
{ exact λx y, calc
F (x, y) ≤ diam (range Φ ∪ range Ψ) :
begin
have A : ∀z : α ⊕ β, f z ∈ range Φ ∪ range Ψ,
{ assume z,
cases z,
{ apply mem_union_left, apply mem_range_self },
{ apply mem_union_right, apply mem_range_self }},
refine dist_le_diam_of_mem _ (A _) (A _),
rw [Φrange, Ψrange],
exact bounded_of_compact (compact_union_of_compact p.2.2 q.2.2),
end
... ≤ 2 * diam (univ : set α) + 1 + 2 * diam (univ : set β) : I }},
let Fb := candidates_b_of_candidates F Fgood,
have : Hausdorff_dist (range (optimal_GH_injl α β)) (range (optimal_GH_injr α β)) ≤ HD Fb :=
Hausdorff_dist_optimal_le_HD _ _ (candidates_b_of_candidates_mem F Fgood),
refine le_trans this (le_of_forall_le_of_dense (λr hr, _)),
have I1 : ∀x : α, infi (λy:β, Fb (inl x, inr y)) ≤ r,
{ assume x,
have : f (inl x) ∈ p.val := by rw [← Φrange]; apply mem_range_self,
rcases exists_dist_lt_of_Hausdorff_dist_lt this hr
(Hausdorff_edist_ne_top_of_bounded_of_ne_empty p.2.1 q.2.1 (bounded_of_compact p.2.2) (bounded_of_compact q.2.2))
with ⟨z, zq, hz⟩,
have : z ∈ range Ψ := by rwa [← Ψrange] at zq,
rcases mem_range.1 this with ⟨y, hy⟩,
calc infi (λy:β, Fb (inl x, inr y)) ≤ Fb (inl x, inr y) :
cinfi_le (by simpa using HD_below_aux1 0)
... = dist (Φ x) (Ψ y) : rfl
... = dist (f (inl x)) z : by rw hy
... ≤ r : le_of_lt hz },
have I2 : ∀y : β, infi (λx:α, Fb (inl x, inr y)) ≤ r,
{ assume y,
have : f (inr y) ∈ q.val := by rw [← Ψrange]; apply mem_range_self,
rcases exists_dist_lt_of_Hausdorff_dist_lt' this hr
(Hausdorff_edist_ne_top_of_bounded_of_ne_empty p.2.1 q.2.1 (bounded_of_compact p.2.2) (bounded_of_compact q.2.2))
with ⟨z, zq, hz⟩,
have : z ∈ range Φ := by rwa [← Φrange] at zq,
rcases mem_range.1 this with ⟨x, hx⟩,
calc infi (λx:α, Fb (inl x, inr y)) ≤ Fb (inl x, inr y) :
cinfi_le (by simpa using HD_below_aux2 0)
... = dist (Φ x) (Ψ y) : rfl
... = dist z (f (inr y)) : by rw hx
... ≤ r : le_of_lt hz },
simp [HD, csupr_le I1, csupr_le I2] },
/- Get the same inequality for any coupling. If the coupling is quite good, the desired
inequality has been proved above. If it is bad, then the inequality is obvious. -/
have B : ∀p q : nonempty_compacts (l_infty_ℝ), ⟦p⟧ = to_GH_space α → ⟦q⟧ = to_GH_space β →
Hausdorff_dist (range (optimal_GH_injl α β)) (range (optimal_GH_injr α β)) ≤ Hausdorff_dist (p.val) (q.val),
{ assume p q hp hq,
by_cases h : Hausdorff_dist (p.val) (q.val) < diam (univ : set α) + 1 + diam (univ : set β),
{ exact A p q hp hq h },
{ calc Hausdorff_dist (range (optimal_GH_injl α β)) (range (optimal_GH_injr α β)) ≤ HD (candidates_b_dist α β) :
Hausdorff_dist_optimal_le_HD _ _ (candidates_b_dist_mem_candidates_b)
... ≤ diam (univ : set α) + 1 + diam (univ : set β) : HD_candidates_b_dist_le
... ≤ Hausdorff_dist (p.val) (q.val) : not_lt.1 h }},
refine le_antisymm _ _,
{ apply le_cInf,
{ rw ne_empty_iff_exists_mem,
simp only [set.mem_image, nonempty_of_inhabited, set.mem_set_of_eq, prod.exists],
existsi [Hausdorff_dist (nonempty_compacts.Kuratowski_embedding α).val (nonempty_compacts.Kuratowski_embedding β).val,
nonempty_compacts.Kuratowski_embedding α, nonempty_compacts.Kuratowski_embedding β],
simp [to_GH_space, -quotient.eq] },
{ rintro b ⟨⟨p, q⟩, ⟨hp, hq⟩, rfl⟩,
exact B p q hp hq }},
{ exact GH_dist_le_Hausdorff_dist (isometry_optimal_GH_injl α β) (isometry_optimal_GH_injr α β) }
end
/-- The Gromov-Hausdorff distance can also be realized by a coupling in ℓ^∞(ℝ), by embedding
the optimal coupling through its Kuratowski embedding. -/
theorem GH_dist_eq_Hausdorff_dist (α : Type u) [metric_space α] [compact_space α] [nonempty α]
(β : Type v) [metric_space β] [compact_space β] [nonempty β] :
∃Φ : α → l_infty_ℝ, ∃Ψ : β → l_infty_ℝ, isometry_on Φ univ ∧ isometry_on Ψ univ ∧
GH_dist α β = Hausdorff_dist (range Φ) (range Ψ) :=
begin
let F := Kuratowski_embedding (optimal_GH_coupling α β),
let Φ := F ∘ optimal_GH_injl α β,
let Ψ := F ∘ optimal_GH_injr α β,
refine ⟨Φ, Ψ, _, _, _⟩,
{ exact isometry_on_comp (maps_to_univ _ _) Kuratowski_embedding_isometry (isometry_optimal_GH_injl α β) },
{ exact isometry_on_comp (maps_to_univ _ _) Kuratowski_embedding_isometry (isometry_optimal_GH_injr α β) },
{ rw [← image_univ, ← image_univ, image_comp F, image_univ, image_comp F (optimal_GH_injr α β),
image_univ, ← Hausdorff_dist_optimal],
exact (Hausdorff_dist.image (subset_univ _) (subset_univ _) Kuratowski_embedding_isometry).symm },
end
-- without the next two lines, { exact closed_of_compact (range Φ) hΦ } in the next
-- proof is very slow, as the t2_space instance is very hard to find
local attribute [instance, priority 0] orderable_topology.t2_space
local attribute [instance, priority 0] ordered_topology.to_t2_space
/-- The Gromov-Hausdorff distance defines a genuine distance on the Gromov-Hausdorff space. -/
instance GH_space_metric_space : metric_space GH_space :=
{ dist_self := λx, begin
rcases exists_rep x with ⟨y, hy⟩,