Add lean source and binary files (part 57)
Browse filesThis view is limited to 50 files because it contains too many changes. See raw diff
- lean/OAI/Combinatorics/SparsestCut/CubeGeometry.lean +165 -0
- lean/OAI/Combinatorics/SparsestCut/CubePoincare.lean +133 -0
- lean/OAI/Combinatorics/SparsestCut/CubeTransfer.lean +145 -0
- lean/OAI/Combinatorics/SparsestCut/CutDuality.lean +134 -0
- lean/OAI/Combinatorics/SparsestCut/CutSums.lean +165 -0
- lean/OAI/Combinatorics/SparsestCut/DirectionAsymptotics.lean +217 -0
- lean/OAI/Combinatorics/SparsestCut/DirectionFamily.lean +201 -0
- lean/OAI/Combinatorics/SparsestCut/DirectionInterpolation.lean +152 -0
- lean/OAI/Combinatorics/SparsestCut/Directions.lean +291 -0
- lean/OAI/Combinatorics/SparsestCut/EuclideanCells.lean +164 -0
- lean/OAI/Combinatorics/SparsestCut/FiniteDuality.lean +214 -0
- lean/OAI/Combinatorics/SparsestCut/FiniteGraph.lean +128 -0
- lean/OAI/Combinatorics/SparsestCut/FiniteNets.lean +122 -0
- lean/OAI/Combinatorics/SparsestCut/FiniteWeights.lean +168 -0
- lean/OAI/Combinatorics/SparsestCut/GapEstimates.lean +57 -0
- lean/OAI/Combinatorics/SparsestCut/GapReduction.lean +192 -0
- lean/OAI/Combinatorics/SparsestCut/GaussianCDF.lean +144 -0
- lean/OAI/Combinatorics/SparsestCut/GaussianNonparallel.lean +116 -0
- lean/OAI/Combinatorics/SparsestCut/GaussianPoincare.lean +155 -0
- lean/OAI/Combinatorics/SparsestCut/GaussianTools.lean +514 -0
- lean/OAI/Combinatorics/SparsestCut/GradientBudget.lean +267 -0
- lean/OAI/Combinatorics/SparsestCut/InterfaceStep.lean +582 -0
- lean/OAI/Combinatorics/SparsestCut/KernelApprox.lean +184 -0
- lean/OAI/Combinatorics/SparsestCut/LabelCount.lean +129 -0
- lean/OAI/Combinatorics/SparsestCut/LatticeDensity.lean +125 -0
- lean/OAI/Combinatorics/SparsestCut/Logarithms.lean +84 -0
- lean/OAI/Combinatorics/SparsestCut/Main.lean +60 -0
- lean/OAI/Combinatorics/SparsestCut/Metric.lean +155 -0
- lean/OAI/Combinatorics/SparsestCut/MetricKernel.lean +218 -0
- lean/OAI/Combinatorics/SparsestCut/Model.lean +38 -0
- lean/OAI/Combinatorics/SparsestCut/Mollifier.lean +156 -0
- lean/OAI/Combinatorics/SparsestCut/Parameters.lean +211 -0
- lean/OAI/Combinatorics/SparsestCut/PivotFamily.lean +211 -0
- lean/OAI/Combinatorics/SparsestCut/PositiveKernels.lean +164 -0
- lean/OAI/Combinatorics/SparsestCut/ProductSlice.lean +135 -0
- lean/OAI/Combinatorics/SparsestCut/Profiles.lean +348 -0
- lean/OAI/Combinatorics/SparsestCut/Replication.lean +172 -0
- lean/OAI/Combinatorics/SparsestCut/RoundedCharts.lean +321 -0
- lean/OAI/Combinatorics/SparsestCut/Semimetrics.lean +193 -0
- lean/OAI/Combinatorics/SparsestCut/SliceCoefficients.lean +137 -0
- lean/OAI/Combinatorics/SparsestCut/SliceIntegration.lean +98 -0
- lean/OAI/Combinatorics/SparsestCut/Smoothing.lean +128 -0
- lean/OAI/Combinatorics/SparsestCut/TriangleRepair.lean +473 -0
- lean/OAI/Combinatorics/SparsestCut/UniformMetric.lean +89 -0
- lean/OAI/Combinatorics/SparsestCut/UniformReplication.lean +78 -0
- lean/OAI/Combinatorics/SparsestCut/VertexCount.lean +75 -0
- lean/OAI/Combinatorics/SparsestCut/VertexMeasure.lean +96 -0
- lean/OAI/Combinatorics/SparsestCut/WeightNormalization.lean +79 -0
- lean/OAI/Combinatorics/SparsestCut/WeightReplacement.lean +171 -0
- lean/OAI/Combinatorics/SparsestCut/WeightReplication.lean +133 -0
lean/OAI/Combinatorics/SparsestCut/CubeGeometry.lean
ADDED
|
@@ -0,0 +1,165 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import OAI.Combinatorics.SparsestCut.CubePoincare
|
| 2 |
+
|
| 3 |
+
namespace OAI
|
| 4 |
+
|
| 5 |
+
open scoped BigOperators Topology NNReal RealInnerProductSpace InnerProductSpace Matrix ContDiff ENNReal
|
| 6 |
+
open MeasureTheory ProbabilityTheory Set Filter Matrix
|
| 7 |
+
|
| 8 |
+
noncomputable section
|
| 9 |
+
|
| 10 |
+
namespace UniformSparsestCut.CubeGeometry
|
| 11 |
+
open MeasureTheory ProbabilityTheory Set Filter
|
| 12 |
+
open scoped BigOperators ENNReal
|
| 13 |
+
noncomputable section
|
| 14 |
+
variable {m : ℕ}
|
| 15 |
+
local notation "E" => EuclideanSpace ℝ (Fin m)
|
| 16 |
+
local notation "μ" => CubePoincare.cube (m := m)
|
| 17 |
+
|
| 18 |
+
lemma pi_uniform : Measure.pi (fun _ : Fin m => GaussianCDF.uniform)=
|
| 19 |
+
(2:ℝ≥0∞)⁻¹^m • (volume : Measure (Fin m → ℝ)).restrict
|
| 20 |
+
(univ.pi (fun _ => Ioo (-1:ℝ) 1)) := by
|
| 21 |
+
apply Measure.pi_eq
|
| 22 |
+
intro s hs
|
| 23 |
+
change (2:ℝ≥0∞)⁻¹^m * ((Measure.pi (fun _ : Fin m => (volume : Measure ℝ))).restrict (univ.pi (fun _ => Ioo (-1:ℝ) 1))) (univ.pi s)=_
|
| 24 |
+
rw [Measure.restrict_pi_pi,Measure.pi_pi]
|
| 25 |
+
simp only [GaussianCDF.uniform,Measure.smul_apply,smul_eq_mul,Finset.prod_mul_distrib,
|
| 26 |
+
Finset.prod_const,Finset.card_univ,Fintype.card_fin]
|
| 27 |
+
|
| 28 |
+
lemma cube_ac : μ ≪ (volume : Measure E) := by
|
| 29 |
+
have h : Measure.pi (fun _ : Fin m => GaussianCDF.uniform) ≪ (volume : Measure (Fin m → ℝ)) := by
|
| 30 |
+
rw [pi_uniform]
|
| 31 |
+
exact (Measure.restrict_le_self.absolutelyContinuous).smul_left _
|
| 32 |
+
have hh := h.map (show Measurable (WithLp.toLp 2 : (Fin m → ℝ) → E) by fun_prop)
|
| 33 |
+
rw [(PiLp.volume_preserving_toLp (Fin m)).map_eq] at hh
|
| 34 |
+
exact hh
|
| 35 |
+
|
| 36 |
+
lemma uniform_mem : ∀ᵐ t ∂GaussianCDF.uniform, t∈Ioo (-1:ℝ) 1 := by
|
| 37 |
+
have h : GaussianCDF.uniform ≪ volume.restrict (Ioo (-1:ℝ) 1) :=
|
| 38 |
+
(Measure.AbsolutelyContinuous.refl _).smul_left _
|
| 39 |
+
exact h.ae_le (ae_restrict_mem measurableSet_Ioo)
|
| 40 |
+
|
| 41 |
+
lemma cube_mem : ∀ᵐ x ∂μ, ∀ j, |x j|<1 := by
|
| 42 |
+
apply (ae_map_iff (by fun_prop) (by measurability)).mpr
|
| 43 |
+
apply ae_all_iff.mpr
|
| 44 |
+
intro j
|
| 45 |
+
have h := (measurePreserving_eval (fun _ : Fin m => GaussianCDF.uniform) j).quasiMeasurePreserving.ae uniform_mem
|
| 46 |
+
filter_upwards [h] with x hx
|
| 47 |
+
exact abs_lt.mpr hx
|
| 48 |
+
|
| 49 |
+
lemma uniform_pow (k : ℕ) : (∫ t, t^k ∂GaussianCDF.uniform)=
|
| 50 |
+
(1-(-1:ℝ)^(k+1))/(2*(k+1)) := by
|
| 51 |
+
rw [GaussianCDF.uniform,integral_smul_measure,restrict_Ioo_eq_restrict_Ioc,
|
| 52 |
+
← intervalIntegral.integral_of_le (by norm_num : (-1:ℝ)≤1),integral_pow]
|
| 53 |
+
simp only [ENNReal.toReal_inv,ENNReal.toReal_ofNat,smul_eq_mul,one_pow]
|
| 54 |
+
field_simp
|
| 55 |
+
|
| 56 |
+
lemma uniform_pow_integrable (k : ℕ) : Integrable (fun t : ℝ => t^k) GaussianCDF.uniform := by
|
| 57 |
+
apply (integrable_const (1:ℝ)).mono' (by fun_prop)
|
| 58 |
+
filter_upwards [uniform_mem] with t ht
|
| 59 |
+
rw [Real.norm_eq_abs,abs_pow]
|
| 60 |
+
exact (pow_le_pow_left₀ (abs_nonneg t) (abs_lt.mpr ht).le k).trans_eq (one_pow k)
|
| 61 |
+
|
| 62 |
+
lemma coordinate_preserving (j : Fin m) : MeasurePreserving (fun x : E => x j) μ GaussianCDF.uniform := by
|
| 63 |
+
refine ⟨by fun_prop,?_⟩
|
| 64 |
+
rw [CubePoincare.cube,Measure.map_map (by fun_prop) (by fun_prop)]
|
| 65 |
+
exact (measurePreserving_eval (fun _ : Fin m => GaussianCDF.uniform) j).map_eq
|
| 66 |
+
|
| 67 |
+
lemma coordinate_pow (j : Fin m) (k : ℕ) : (∫ x : E, (x j)^k ∂μ)=
|
| 68 |
+
(1-(-1:ℝ)^(k+1))/(2*(k+1)) := by
|
| 69 |
+
rw [← uniform_pow k,← (coordinate_preserving j).map_eq]
|
| 70 |
+
exact (integral_map (by fun_prop) (continuous_id.pow k).aestronglyMeasurable).symm
|
| 71 |
+
|
| 72 |
+
lemma coordinate_pow_integrable (j : Fin m) (k : ℕ) : Integrable (fun x : E => (x j)^k) μ :=
|
| 73 |
+
((coordinate_preserving j).integrable_comp (continuous_id.pow k).aestronglyMeasurable).mpr (uniform_pow_integrable k)
|
| 74 |
+
|
| 75 |
+
lemma cube_norm : ∀ᵐ x : E ∂μ, ‖x‖≤Real.sqrt m := by
|
| 76 |
+
filter_upwards [cube_mem] with x hx
|
| 77 |
+
have h : ‖x‖^2≤(m:ℝ) := by
|
| 78 |
+
rw [EuclideanSpace.norm_sq_eq]
|
| 79 |
+
calc
|
| 80 |
+
_ ≤ ∑ _j : Fin m, (1:ℝ) := by
|
| 81 |
+
apply Finset.sum_le_sum; intro j _
|
| 82 |
+
rw [Real.norm_eq_abs,sq_abs]
|
| 83 |
+
nlinarith [abs_lt.mp (hx j)]
|
| 84 |
+
_ = _ := by simp
|
| 85 |
+
nlinarith [Real.sq_sqrt (Nat.cast_nonneg (α := ℝ) m),norm_nonneg x,Real.sqrt_nonneg (m:ℝ)]
|
| 86 |
+
|
| 87 |
+
lemma bounded_integrable {f : E → ℝ} (hf : AEStronglyMeasurable f μ) {B : ℝ}
|
| 88 |
+
(hb : ∀ᵐ x ∂μ, |f x|≤B) : Integrable f μ :=
|
| 89 |
+
(integrable_const B).mono' hf (by simpa only [Real.norm_eq_abs] using hb)
|
| 90 |
+
|
| 91 |
+
lemma pair_norm_bound : ∀ᵐ z : E × E ∂(μ).prod μ, ‖z.1-z.2‖≤2*Real.sqrt m := by
|
| 92 |
+
have hp : ∀ᵐ z : E × E ∂(μ).prod μ, ‖z.1‖≤Real.sqrt m ∧ ‖z.2‖≤Real.sqrt m := by
|
| 93 |
+
apply (Measure.ae_prod_iff_ae_ae (by measurability)).mpr
|
| 94 |
+
filter_upwards [cube_norm (m := m)] with x hx
|
| 95 |
+
filter_upwards [cube_norm (m := m)] with y hy
|
| 96 |
+
exact ⟨hx,hy⟩
|
| 97 |
+
filter_upwards [hp] with z hz
|
| 98 |
+
exact (norm_sub_le _ _).trans (by linarith [hz.1,hz.2])
|
| 99 |
+
|
| 100 |
+
lemma pair_norm_integrable : Integrable (fun z : E × E => ‖z.1-z.2‖) ((μ).prod μ) := by
|
| 101 |
+
apply (integrable_const (2*Real.sqrt m)).mono' (by fun_prop)
|
| 102 |
+
simpa only [Real.norm_eq_abs,abs_norm] using pair_norm_bound (m := m)
|
| 103 |
+
|
| 104 |
+
lemma coordinate_difference_sq (j : Fin m) :
|
| 105 |
+
(∫ z : E × E, (z.1 j-z.2 j)^2 ∂(μ).prod μ)=2/3 := by
|
| 106 |
+
have h1 : Integrable (fun x : E => x j) μ := by simpa using coordinate_pow_integrable j 1
|
| 107 |
+
have h2 := coordinate_pow_integrable j 2
|
| 108 |
+
have he : (fun z : E × E => (z.1 j-z.2 j)^2) =
|
| 109 |
+
(fun z => (z.1 j)^2+(z.2 j)^2-2*(z.1 j*z.2 j)) := by funext z; ring
|
| 110 |
+
rw [he]
|
| 111 |
+
have hsub := integral_sub ((h2.comp_fst μ).add (h2.comp_snd μ)) ((h1.mul_prod h1).const_mul 2)
|
| 112 |
+
simp only [Pi.add_apply] at hsub
|
| 113 |
+
rw [hsub]
|
| 114 |
+
have hadd := integral_add (h2.comp_fst μ) (h2.comp_snd μ)
|
| 115 |
+
rw [hadd,integral_const_mul,integral_prod_mul (fun x : E => x j) (fun x : E => x j)]
|
| 116 |
+
have he0 : (∫ x : E, x j ∂μ)=0 := by simpa using coordinate_pow j 1
|
| 117 |
+
have he2 : (∫ x : E, (x j)^2 ∂μ)=1/3 := by
|
| 118 |
+
have hh := coordinate_pow j 2
|
| 119 |
+
norm_num at hh ⊢
|
| 120 |
+
exact hh
|
| 121 |
+
rw [integral_fun_fst (fun x : E => (x j)^2),integral_fun_snd (fun x : E => (x j)^2)]
|
| 122 |
+
simp [he0,he2]
|
| 123 |
+
norm_num
|
| 124 |
+
|
| 125 |
+
lemma coordinate_difference_sq_integrable (j : Fin m) :
|
| 126 |
+
Integrable (fun z : E × E => (z.1 j-z.2 j)^2) ((μ).prod μ) := by
|
| 127 |
+
have h1 : Integrable (fun x : E => x j) μ := by simpa using coordinate_pow_integrable j 1
|
| 128 |
+
have h2 := coordinate_pow_integrable j 2
|
| 129 |
+
convert ((h2.comp_fst μ).add (h2.comp_snd μ)).sub ((h1.mul_prod h1).const_mul 2) using 1
|
| 130 |
+
ext z
|
| 131 |
+
simp only [Pi.add_apply,Pi.sub_apply]
|
| 132 |
+
ring
|
| 133 |
+
|
| 134 |
+
lemma pair_norm_sq_integral : (∫ z : E × E, ‖z.1-z.2‖^2 ∂(μ).prod μ)=2*(m:ℝ)/3 := by
|
| 135 |
+
have hnorm (z : E × E) : ‖z.1-z.2‖^2=∑ j, (z.1 j-z.2 j)^2 := by
|
| 136 |
+
rw [EuclideanSpace.norm_sq_eq]
|
| 137 |
+
congr 1
|
| 138 |
+
funext j
|
| 139 |
+
simp only [PiLp.sub_apply,Real.norm_eq_abs,sq_abs]
|
| 140 |
+
simp_rw [hnorm]
|
| 141 |
+
rw [integral_finsetSum _ (fun j _ => coordinate_difference_sq_integrable j)]
|
| 142 |
+
simp only [coordinate_difference_sq,Finset.sum_const,Finset.card_univ,Fintype.card_fin,nsmul_eq_mul]
|
| 143 |
+
ring
|
| 144 |
+
|
| 145 |
+
lemma pair_norm_average (hm : 0 < m) :
|
| 146 |
+
Real.sqrt m/3≤∫ z : E × E, ‖z.1-z.2‖ ∂(μ).prod μ := by
|
| 147 |
+
have hsq : Integrable (fun z : E × E => ‖z.1-z.2‖^2) ((μ).prod μ) := by
|
| 148 |
+
apply (integrable_const ((2*Real.sqrt m)^2)).mono' (by fun_prop)
|
| 149 |
+
filter_upwards [pair_norm_bound (m := m)] with z hz
|
| 150 |
+
rw [Real.norm_eq_abs,abs_of_nonneg (sq_nonneg _)]
|
| 151 |
+
exact pow_le_pow_left₀ (norm_nonneg _) hz 2
|
| 152 |
+
have hh := integral_mono_ae hsq (pair_norm_integrable.const_mul (2*Real.sqrt m)) (by
|
| 153 |
+
filter_upwards [pair_norm_bound (m := m)] with z hz
|
| 154 |
+
exact (show ‖z.1-z.2‖^2≤2*Real.sqrt m*‖z.1-z.2‖ by nlinarith [norm_nonneg (z.1-z.2)]))
|
| 155 |
+
rw [pair_norm_sq_integral,integral_const_mul] at hh
|
| 156 |
+
have hp : 0<Real.sqrt (m:ℝ) := Real.sqrt_pos.mpr (by exact_mod_cast hm)
|
| 157 |
+
have hs := Real.sq_sqrt (Nat.cast_nonneg (α := ℝ) m)
|
| 158 |
+
nlinarith
|
| 159 |
+
|
| 160 |
+
end
|
| 161 |
+
end UniformSparsestCut.CubeGeometry
|
| 162 |
+
|
| 163 |
+
end
|
| 164 |
+
|
| 165 |
+
end OAI
|
lean/OAI/Combinatorics/SparsestCut/CubePoincare.lean
ADDED
|
@@ -0,0 +1,133 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import OAI.Combinatorics.SparsestCut.GaussianCDF
|
| 2 |
+
|
| 3 |
+
namespace OAI
|
| 4 |
+
|
| 5 |
+
open scoped BigOperators Topology NNReal RealInnerProductSpace InnerProductSpace Matrix ContDiff ENNReal
|
| 6 |
+
open MeasureTheory ProbabilityTheory Set Filter Matrix
|
| 7 |
+
|
| 8 |
+
noncomputable section
|
| 9 |
+
|
| 10 |
+
namespace UniformSparsestCut.CubePoincare
|
| 11 |
+
open MeasureTheory ProbabilityTheory Set
|
| 12 |
+
open scoped Topology ContDiff ENNReal BigOperators
|
| 13 |
+
variable {m : ℕ}
|
| 14 |
+
local notation "E" => EuclideanSpace ℝ (Fin m)
|
| 15 |
+
|
| 16 |
+
def Ψ (x : E) : E := WithLp.toLp 2 (fun i => GaussianCDF.ψ (x i))
|
| 17 |
+
def cube : Measure E := (Measure.pi (fun _ : Fin m => GaussianCDF.uniform)).map (WithLp.toLp 2)
|
| 18 |
+
|
| 19 |
+
instance cube_probability : IsProbabilityMeasure (cube (m := m)) := by
|
| 20 |
+
unfold cube
|
| 21 |
+
infer_instance
|
| 22 |
+
|
| 23 |
+
def coordinate (i : Fin m) : E →L[ℝ] ℝ :=
|
| 24 |
+
(ContinuousLinearMap.proj i).comp (EuclideanSpace.equiv (Fin m) ℝ).toContinuousLinearMap
|
| 25 |
+
|
| 26 |
+
@[simp] lemma coordinate_apply (i : Fin m) (x : E) : coordinate i x = x i := rfl
|
| 27 |
+
|
| 28 |
+
def derivative (x : E) : E →L[ℝ] E :=
|
| 29 |
+
(EuclideanSpace.equiv (Fin m) ℝ).symm.toContinuousLinearMap.comp
|
| 30 |
+
(ContinuousLinearMap.pi (fun i => (2*GaussianCDF.φ (x i)) • coordinate i))
|
| 31 |
+
|
| 32 |
+
@[simp] lemma derivative_apply (x v : E) (i : Fin m) : derivative x v i = 2*GaussianCDF.φ (x i)*v i := rfl
|
| 33 |
+
|
| 34 |
+
lemma Ψ_hasFDeriv (x : E) : HasFDerivAt Ψ (derivative x) x := by
|
| 35 |
+
have hi (i : Fin m) := (GaussianCDF.ψ_hasDeriv (x i)).comp_hasFDerivAt x (coordinate i).hasFDerivAt
|
| 36 |
+
have hp := hasFDerivAt_pi.mpr hi
|
| 37 |
+
have h := (EuclideanSpace.equiv (Fin m) ℝ).symm.toContinuousLinearMap.hasFDerivAt.comp x hp
|
| 38 |
+
convert h using 1 <;> rfl
|
| 39 |
+
|
| 40 |
+
lemma Ψ_contDiff : ContDiff ℝ 1 (Ψ (m := m)) := by
|
| 41 |
+
have h : ContDiff ℝ 1 (fun x : E => fun i => GaussianCDF.ψ (x i)) :=
|
| 42 |
+
contDiff_pi.mpr (fun i => GaussianCDF.ψ_contDiff.comp (coordinate i).contDiff)
|
| 43 |
+
exact (EuclideanSpace.equiv (Fin m) ℝ).symm.toContinuousLinearMap.contDiff.comp h
|
| 44 |
+
|
| 45 |
+
lemma Ψ_norm (x : E) : ‖Ψ x‖ ≤ Real.sqrt m := by
|
| 46 |
+
have h : ‖Ψ x‖^2 ≤ (m:ℝ) := by
|
| 47 |
+
rw [EuclideanSpace.norm_sq_eq]
|
| 48 |
+
calc
|
| 49 |
+
_ ≤ ∑ _i : Fin m, (1:ℝ) := by
|
| 50 |
+
apply Finset.sum_le_sum
|
| 51 |
+
intro i _
|
| 52 |
+
have hi := GaussianCDF.ψ_mem (x i)
|
| 53 |
+
change ‖GaussianCDF.ψ (x i)‖^2 ≤ 1
|
| 54 |
+
rw [Real.norm_eq_abs, sq_abs]
|
| 55 |
+
nlinarith [hi.1,hi.2]
|
| 56 |
+
_ = _ := by simp
|
| 57 |
+
nlinarith [Real.sq_sqrt (Nat.cast_nonneg (α := ℝ) m), Real.sqrt_nonneg (m:ℝ), norm_nonneg (Ψ x)]
|
| 58 |
+
|
| 59 |
+
lemma derivative_norm (x : E) : ‖derivative x‖ ≤ 1 := by
|
| 60 |
+
apply (derivative x).opNorm_le_bound (by norm_num)
|
| 61 |
+
intro v
|
| 62 |
+
simp only [one_mul]
|
| 63 |
+
have h : ‖derivative x v‖^2 ≤ ‖v‖^2 := by
|
| 64 |
+
simp only [EuclideanSpace.norm_sq_eq]
|
| 65 |
+
apply Finset.sum_le_sum
|
| 66 |
+
intro i _
|
| 67 |
+
change ‖2*GaussianCDF.φ (x i)*v i‖^2 ≤ ‖v i‖^2
|
| 68 |
+
rw [norm_mul, mul_pow]
|
| 69 |
+
have hi := GaussianCDF.ψ_deriv_bound (x i)
|
| 70 |
+
have hh : ‖2*GaussianCDF.φ (x i)‖^2 ≤ 1 := by
|
| 71 |
+
rw [Real.norm_eq_abs]
|
| 72 |
+
nlinarith [abs_nonneg (2*GaussianCDF.φ (x i))]
|
| 73 |
+
nlinarith [sq_nonneg ‖v i‖]
|
| 74 |
+
nlinarith [norm_nonneg (derivative x v), norm_nonneg v]
|
| 75 |
+
|
| 76 |
+
lemma Ψ_map : (stdGaussian E).map Ψ = cube := by
|
| 77 |
+
rw [← map_pi_eq_stdGaussian, Measure.map_map Ψ_contDiff.continuous.measurable (by fun_prop)]
|
| 78 |
+
have he : (Ψ (m := m)) ∘ WithLp.toLp 2 = WithLp.toLp 2 ∘
|
| 79 |
+
(fun x : Fin m → ℝ => fun i => GaussianCDF.ψ (x i)) := rfl
|
| 80 |
+
have hmeas : Measurable (fun x : Fin m → ℝ => fun i => GaussianCDF.ψ (x i)) :=
|
| 81 |
+
Measurable.of_eval (fun i => GaussianCDF.ψ_contDiff.continuous.measurable.comp (measurable_pi_apply i))
|
| 82 |
+
rw [he, ← Measure.map_map (by fun_prop) hmeas, Measure.pi_map_pi]
|
| 83 |
+
· simp_rw [GaussianCDF.ψ_map]
|
| 84 |
+
rfl
|
| 85 |
+
· intro i
|
| 86 |
+
exact GaussianCDF.ψ_contDiff.continuous.measurable.aemeasurable
|
| 87 |
+
|
| 88 |
+
lemma cube_first_moment (h : E → ℝ) (hh : ContDiff ℝ 1 h) :
|
| 89 |
+
(∫ z : E × E, |h z.1-h z.2| ∂((cube (m := m)).prod cube)) ≤
|
| 90 |
+
(Real.pi/2)*(∫ x : E, ‖fderiv ℝ h x‖ ∂cube) := by
|
| 91 |
+
let μ := stdGaussian E
|
| 92 |
+
let H : E → ℝ := h ∘ Ψ
|
| 93 |
+
have hH : ContDiff ℝ 1 H := hh.comp Ψ_contDiff
|
| 94 |
+
have hcompact := isCompact_closedBall (0:E) (Real.sqrt m)
|
| 95 |
+
obtain ⟨B,hB⟩ := hcompact.exists_bound_of_continuousOn hh.continuous.continuousOn
|
| 96 |
+
obtain ⟨M,hM⟩ := hcompact.exists_bound_of_continuousOn (hh.continuous_fderiv (by norm_num)).continuousOn
|
| 97 |
+
have hmem (x : E) : Ψ x ∈ Metric.closedBall 0 (Real.sqrt m) := by simpa using Ψ_norm x
|
| 98 |
+
have hB' (x : E) : ‖H x‖ ≤ max B 0 := (hB _ (hmem x)).trans (le_max_left _ _)
|
| 99 |
+
have hcomp (x : E) : fderiv ℝ H x = (fderiv ℝ h (Ψ x)).comp (derivative x) :=
|
| 100 |
+
((hh.differentiable (by norm_num) (Ψ x)).hasFDerivAt.comp x (Ψ_hasFDeriv x)).fderiv
|
| 101 |
+
have hnorm (x : E) : ‖fderiv ℝ H x‖ ≤ ‖fderiv ℝ h (Ψ x)‖ := by
|
| 102 |
+
rw [hcomp]
|
| 103 |
+
exact ContinuousLinearMap.opNorm_comp_le _ _ |>.trans
|
| 104 |
+
((mul_le_mul_of_nonneg_left (derivative_norm x) (norm_nonneg _)).trans_eq (mul_one _))
|
| 105 |
+
have hdB (x : E) : ‖fderiv ℝ H x‖ ≤ max M 0 :=
|
| 106 |
+
(hnorm x).trans ((hM _ (hmem x)).trans (le_max_left _ _))
|
| 107 |
+
have hint : Integrable (fun x : E => ‖fderiv ℝ h (Ψ x)‖) μ := by
|
| 108 |
+
apply (integrable_const (max M 0)).mono' ((hh.continuous_fderiv (by norm_num)).comp Ψ_contDiff.continuous |>.norm.aestronglyMeasurable)
|
| 109 |
+
filter_upwards with x
|
| 110 |
+
simpa only [norm_norm, Function.comp_apply] using (hM _ (hmem x)).trans (le_max_left _ _)
|
| 111 |
+
have hintH : Integrable (fun x : E => ‖fderiv ℝ H x‖) μ := by
|
| 112 |
+
apply hint.mono' (by have hc := hH.continuous_fderiv (by norm_num); fun_prop)
|
| 113 |
+
filter_upwards with x
|
| 114 |
+
simpa only [norm_norm] using hnorm x
|
| 115 |
+
have hp := GaussianPoincare.rotation_first_moment H hH (le_max_right M 0) hdB hB'
|
| 116 |
+
have hmeasure : MeasurePreserving Ψ μ cube := ⟨Ψ_contDiff.continuous.measurable, Ψ_map⟩
|
| 117 |
+
have hprod := hmeasure.prod hmeasure
|
| 118 |
+
have heL : (∫ z : E × E, |H z.1-H z.2| ∂μ.prod μ) =
|
| 119 |
+
∫ z : E × E, |h z.1-h z.2| ∂((cube (m := m)).prod cube) := by
|
| 120 |
+
rw [← hprod.map_eq]
|
| 121 |
+
exact (integral_map (f := fun z : E × E => |h z.1-h z.2|) hprod.measurable.aemeasurable (by fun_prop)).symm
|
| 122 |
+
have heR : (∫ x : E, ‖fderiv ℝ h (Ψ x)‖ ∂μ) = ∫ x : E, ‖fderiv ℝ h x‖ ∂cube := by
|
| 123 |
+
rw [← hmeasure.map_eq]
|
| 124 |
+
exact (integral_map (f := fun x : E => ‖fderiv ℝ h x‖) hmeasure.measurable.aemeasurable
|
| 125 |
+
(by have hc := hh.continuous_fderiv (by norm_num); fun_prop)).symm
|
| 126 |
+
rw [← heL, ← heR]
|
| 127 |
+
exact hp.trans (mul_le_mul_of_nonneg_left (integral_mono hintH hint hnorm) (by positivity))
|
| 128 |
+
|
| 129 |
+
end UniformSparsestCut.CubePoincare
|
| 130 |
+
|
| 131 |
+
end
|
| 132 |
+
|
| 133 |
+
end OAI
|
lean/OAI/Combinatorics/SparsestCut/CubeTransfer.lean
ADDED
|
@@ -0,0 +1,145 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import OAI.Combinatorics.SparsestCut.CubeGeometry
|
| 2 |
+
|
| 3 |
+
namespace OAI
|
| 4 |
+
|
| 5 |
+
universe u1 u2
|
| 6 |
+
|
| 7 |
+
open scoped BigOperators Topology NNReal RealInnerProductSpace InnerProductSpace Matrix ContDiff ENNReal
|
| 8 |
+
open MeasureTheory ProbabilityTheory Set Filter Matrix
|
| 9 |
+
|
| 10 |
+
noncomputable section
|
| 11 |
+
|
| 12 |
+
namespace UniformSparsestCut.CubeTransfer
|
| 13 |
+
open MeasureTheory Set Filter
|
| 14 |
+
open scoped BigOperators
|
| 15 |
+
noncomputable section
|
| 16 |
+
variable {m : ℕ} {A : Type u1} [Fintype A]
|
| 17 |
+
local notation "E" => EuclideanSpace ℝ (Fin m)
|
| 18 |
+
local notation "μ" => CubePoincare.cube (m := m)
|
| 19 |
+
lemma continuous_integrable (f : E → ℝ) (hf : Continuous f) : Integrable f μ := by
|
| 20 |
+
obtain ⟨B,hB⟩ := (isCompact_closedBall (0:E) (Real.sqrt m)).exists_bound_of_continuousOn hf.continuousOn
|
| 21 |
+
apply CubeGeometry.bounded_integrable hf.aestronglyMeasurable
|
| 22 |
+
filter_upwards [CubeGeometry.cube_norm (m := m)] with x hx
|
| 23 |
+
simpa only [Real.norm_eq_abs] using hB x (by simpa using hx)
|
| 24 |
+
lemma pair_continuous_integrable (f : E × E → ℝ) (hf : Continuous f) : Integrable f ((μ).prod μ) := by
|
| 25 |
+
let K : Set E := Metric.closedBall 0 (Real.sqrt m)
|
| 26 |
+
have hK : IsCompact K := isCompact_closedBall _ _
|
| 27 |
+
obtain ⟨B,hB⟩ := (hK.prod hK).exists_bound_of_continuousOn hf.continuousOn
|
| 28 |
+
have hm : ∀ᵐ x : E ∂μ, x∈K := by simpa only [K,Metric.mem_closedBall,dist_zero_right] using CubeGeometry.cube_norm (m := m)
|
| 29 |
+
have hp : ∀ᵐ z : E × E ∂(μ).prod μ, z∈K ×ˢ K := by
|
| 30 |
+
apply (Measure.ae_prod_iff_ae_ae (hK.measurableSet.prod hK.measurableSet)).mpr
|
| 31 |
+
filter_upwards [hm] with x hx
|
| 32 |
+
filter_upwards [hm] with y hy
|
| 33 |
+
exact ⟨hx,hy⟩
|
| 34 |
+
apply (integrable_const B).mono' hf.aestronglyMeasurable
|
| 35 |
+
filter_upwards [hp] with z hz
|
| 36 |
+
exact hB z hz
|
| 37 |
+
|
| 38 |
+
lemma average_from_gradient (f H : A → E → ℝ) {M B K : ℝ}
|
| 39 |
+
(hf : ∀ a, Measurable (f a)) (hM : ∀ a x, |f a x|≤M)
|
| 40 |
+
(hH : ∀ a, ContDiff ℝ 1 (H a))
|
| 41 |
+
(he : ∀ᵐ x : E ∂μ, ∑ a, |H a x-f a x|≤B)
|
| 42 |
+
(hg : ∀ᵐ x : E ∂μ, ∑ a, ‖fderiv ℝ (H a) x‖≤K) :
|
| 43 |
+
(∫ z : E × E, ∑ a, |f a z.1-f a z.2| ∂(μ).prod μ)≤2*B+(Real.pi/2)*K := by
|
| 44 |
+
classical
|
| 45 |
+
have hfi (a : A) : Integrable (f a) μ :=
|
| 46 |
+
CubeGeometry.bounded_integrable (hf a).aestronglyMeasurable (Eventually.of_forall (hM a))
|
| 47 |
+
have hfdi (a : A) : Integrable (fun z : E × E => |f a z.1-f a z.2|) ((μ).prod μ) :=
|
| 48 |
+
((hfi a).comp_fst μ |>.sub ((hfi a).comp_snd μ)).abs
|
| 49 |
+
have hHd (a : A) : Integrable (fun z : E × E => |H a z.1-H a z.2|) ((μ).prod μ) :=
|
| 50 |
+
pair_continuous_integrable _ (by have hh := (hH a).continuous; fun_prop)
|
| 51 |
+
have hDi (a : A) : Integrable (fun x : E => ‖fderiv ℝ (H a) x‖) μ :=
|
| 52 |
+
continuous_integrable _ (by exact ((hH a).continuous_fderiv (by norm_num)).norm)
|
| 53 |
+
have hgb : (∫ z : E × E, ∑ a, |H a z.1-H a z.2| ∂(μ).prod μ)≤(Real.pi/2)*K := by
|
| 54 |
+
rw [integral_finsetSum _ (fun a _ => hHd a)]
|
| 55 |
+
calc
|
| 56 |
+
_ ≤ ∑ a, (Real.pi/2)*(∫ x : E, ‖fderiv ℝ (H a) x‖ ∂μ) :=
|
| 57 |
+
Finset.sum_le_sum (fun a _ => CubePoincare.cube_first_moment (H a) (hH a))
|
| 58 |
+
_ = (Real.pi/2)*(∫ x : E, ∑ a, ‖fderiv ℝ (H a) x‖ ∂μ) := by
|
| 59 |
+
rw [integral_finsetSum _ (fun a _ => hDi a),Finset.mul_sum]
|
| 60 |
+
_ ≤ (Real.pi/2)*K := by
|
| 61 |
+
apply mul_le_mul_of_nonneg_left _ (by positivity)
|
| 62 |
+
calc
|
| 63 |
+
_ ≤ ∫ _x : E, K ∂μ := integral_mono_ae (integrable_finsetSum _ (fun a _ => hDi a)) (integrable_const K) hg
|
| 64 |
+
_ = _ := by simp
|
| 65 |
+
have hep : ∀ᵐ z : E × E ∂(μ).prod μ,
|
| 66 |
+
(∑ a, |H a z.1-f a z.1|≤B) ∧ (∑ a, |H a z.2-f a z.2|≤B) := by
|
| 67 |
+
have hem : Measurable (fun x : E => ∑ a, |H a x-f a x|) :=
|
| 68 |
+
Finset.measurable_sum _ (fun a _ => ((hH a).continuous.measurable.sub (hf a)).abs)
|
| 69 |
+
apply (Measure.ae_prod_iff_ae_ae
|
| 70 |
+
((measurableSet_le (hem.comp measurable_fst) measurable_const).inter
|
| 71 |
+
(measurableSet_le (hem.comp measurable_snd) measurable_const))).mpr
|
| 72 |
+
filter_upwards [he] with x hx
|
| 73 |
+
filter_upwards [he] with y hy
|
| 74 |
+
exact ⟨hx,hy⟩
|
| 75 |
+
have hpoint : ∀ᵐ z : E × E ∂(μ).prod μ, (∑ a, |f a z.1-f a z.2|)≤2*B+∑ a, |H a z.1-H a z.2| := by
|
| 76 |
+
filter_upwards [hep] with z hz
|
| 77 |
+
have hle (a : A) : |f a z.1-f a z.2|≤|H a z.1-f a z.1|+|H a z.1-H a z.2|+|H a z.2-f a z.2| := by
|
| 78 |
+
calc
|
| 79 |
+
_ = |-(H a z.1-f a z.1)+(H a z.1-H a z.2)+(H a z.2-f a z.2)| := by congr 1; ring
|
| 80 |
+
_ ≤ _ := by simpa only [abs_neg] using (abs_add_three (-(H a z.1-f a z.1)) (H a z.1-H a z.2) (H a z.2-f a z.2))
|
| 81 |
+
have hh := Finset.sum_le_sum (fun a (_ : a∈(Finset.univ : Finset A)) => hle a)
|
| 82 |
+
simp only [Finset.sum_add_distrib] at hh
|
| 83 |
+
linarith [hz.1,hz.2]
|
| 84 |
+
have hfinal := integral_mono_ae (integrable_finsetSum _ (fun a _ => hfdi a))
|
| 85 |
+
((integrable_const (2*B)).add (integrable_finsetSum _ (fun a _ => hHd a))) hpoint
|
| 86 |
+
simp only [Pi.add_apply] at hfinal
|
| 87 |
+
have hadd := integral_add (show Integrable (fun _ : E × E => 2*B) ((μ).prod μ) from integrable_const _)
|
| 88 |
+
(integrable_finsetSum Finset.univ (fun a _ => hHd a))
|
| 89 |
+
rw [hadd] at hfinal
|
| 90 |
+
simpa using hfinal.trans (add_le_add le_rfl hgb)
|
| 91 |
+
end
|
| 92 |
+
end UniformSparsestCut.CubeTransfer
|
| 93 |
+
|
| 94 |
+
namespace UniformSparsestCut.ContractionAverage
|
| 95 |
+
open MeasureTheory Set Filter
|
| 96 |
+
open scoped BigOperators RealInnerProductSpace
|
| 97 |
+
noncomputable section
|
| 98 |
+
variable {m N S : ℕ} {A : Type u2} [Fintype A]
|
| 99 |
+
local notation "E" => EuclideanSpace ℝ (Fin (m+1))
|
| 100 |
+
local notation "μ" => CubePoincare.cube (m := m+1)
|
| 101 |
+
open ContractionCore
|
| 102 |
+
|
| 103 |
+
lemma average (u : Fin S → Fin N → E) (hu : ∀ s i, u s i 0≠0)
|
| 104 |
+
(hnp : ∀ s i j, i≠j → ∀ t : ℝ, u s i≠t • u s j) (hn : ∀ s i, ‖u s i‖≤2)
|
| 105 |
+
{τ lam δ R J G : ℝ} (hτ : 0<τ) (hlam : 0<lam) (hlam1 : lam<1)
|
| 106 |
+
(hδ : 0≤δ) (hJ : 0≤J) (hG : 0≤G)
|
| 107 |
+
(F : RoundedCharts.Vertex u τ → A → ℝ) {M : ℝ} (hM : 0≤M) (hbound : ∀ v a, |F v a|≤M)
|
| 108 |
+
(hclose : ∀ s t x (hx : x∈RoundedCharts.cube 2)
|
| 109 |
+
(hs : RoundedCharts.regular (u s) τ x) (ht : RoundedCharts.regular (u t) τ x),
|
| 110 |
+
∑ a, |F (vertex u τ s x hx hs) a-F (vertex u τ t x hx ht) a|≤R)
|
| 111 |
+
(hmacro : ∀ s x y (hx : x∈RoundedCharts.cube 2) (hy : y∈RoundedCharts.cube 2)
|
| 112 |
+
(hs : RoundedCharts.regular (u s) τ x) (ht : RoundedCharts.regular (u s) τ y),
|
| 113 |
+
∑ a, |F (vertex u τ s x hx hs) a-F (vertex u τ s y hy ht) a|≤G*‖x-y‖+R)
|
| 114 |
+
(hjump : ∀ (vp vm : RoundedCharts.Vertex u τ) (i : Fin N), vp.val.1=vm.val.1 →
|
| 115 |
+
vp.val.2 i=vm.val.2 i+1 → (∀ j, j≠i → vp.val.2 j=vm.val.2 j) → ∑ a, |F vp a-F vm a|≤J)
|
| 116 |
+
(hsmall : ∀ s i, τ/|u s i 0| *KernelGeometry.L lam≤1)
|
| 117 |
+
(hgood : ∀ D : StrongDual ℝ E, ∃ good : Finset (Fin S), (S:ℝ)/2≤good.card ∧
|
| 118 |
+
∀ s∈good, ∀ i, |D (u s i)|≤δ*‖D‖)
|
| 119 |
+
(s0 : Fin S) :
|
| 120 |
+
(∫ z : E × E, ∑ a, |ConcreteCells.function u hu τ F s0 a z.1-
|
| 121 |
+
ConcreteCells.function u hu τ F s0 a z.2| ∂(μ).prod μ)≤
|
| 122 |
+
2*(G*(lam*Real.sqrt (m+1:ℕ))+R)+Real.pi*(δ*((N:ℝ)*(2*J/τ))+(m+1:ℕ)*R*KernelGeometry.L lam) := by
|
| 123 |
+
let f : A → E → ℝ := ConcreteCells.function u hu τ F s0
|
| 124 |
+
let H : A → E → ℝ := fun a => ConvolutionBounds.smooth (KernelGeometry.κ lam) (f a) volume
|
| 125 |
+
have hc (a : A) : ContDiff ℝ 1 (H a) := by
|
| 126 |
+
exact (KernelGeometry.compact hlam).contDiff_convolution_left (ContinuousLinearMap.mul ℝ ℝ)
|
| 127 |
+
((KernelGeometry.smooth lam).of_le (by simp)) (ConcreteCells.function_integrable u hu τ F hM hbound s0 a)
|
| 128 |
+
have he : ∀ᵐ x : E ∂μ, (∑ a, |H a x-f a x|)≤G*(lam*Real.sqrt (m+1:ℕ))+R := by
|
| 129 |
+
have hr := CubeGeometry.cube_ac.ae_le (RoundedCharts.ae_regular (u s0) τ (by
|
| 130 |
+
intro i h; exact hu s0 i (by rw [h]; rfl)))
|
| 131 |
+
filter_upwards [CubeGeometry.cube_mem (m := m+1),hr] with x hx hrx
|
| 132 |
+
exact smoothing_error u hu hτ hlam hlam1 hn hG F hM hbound hmacro s0 x (fun j => (hx j).le) hrx
|
| 133 |
+
have hg : ∀ᵐ x : E ∂μ, (∑ a, ‖fderiv ℝ (H a) x‖)≤
|
| 134 |
+
2*(δ*((N:ℝ)*(2*J/τ))+(m+1:ℕ)*R*KernelGeometry.L lam) := by
|
| 135 |
+
filter_upwards [CubeGeometry.cube_mem (m := m+1)] with x hx
|
| 136 |
+
exact gradient_bound u hu hnp hn hτ hlam hlam1 hδ hJ F hM hbound hclose hjump hsmall hgood s0 x (fun j => (hx j).le)
|
| 137 |
+
have h := CubeTransfer.average_from_gradient f H (fun a => ConcreteCells.function_measurable u hu τ F s0 a)
|
| 138 |
+
(fun a x => ConcreteCells.function_bounded u hu τ F hM hbound s0 a x) hc he hg
|
| 139 |
+
convert h using 1 ; ring
|
| 140 |
+
end
|
| 141 |
+
end UniformSparsestCut.ContractionAverage
|
| 142 |
+
|
| 143 |
+
end
|
| 144 |
+
|
| 145 |
+
end OAI
|
lean/OAI/Combinatorics/SparsestCut/CutDuality.lean
ADDED
|
@@ -0,0 +1,134 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import OAI.Combinatorics.SparsestCut.Semimetrics
|
| 2 |
+
import OAI.Combinatorics.SparsestCut.FiniteDuality
|
| 3 |
+
|
| 4 |
+
namespace OAI
|
| 5 |
+
|
| 6 |
+
universe u1
|
| 7 |
+
|
| 8 |
+
open scoped BigOperators Topology NNReal RealInnerProductSpace InnerProductSpace Matrix ContDiff ENNReal
|
| 9 |
+
open MeasureTheory ProbabilityTheory Set Filter Matrix
|
| 10 |
+
|
| 11 |
+
noncomputable section
|
| 12 |
+
|
| 13 |
+
namespace UniformSparsestCut
|
| 14 |
+
|
| 15 |
+
section CutConeDuality
|
| 16 |
+
variable {n : ℕ}
|
| 17 |
+
|
| 18 |
+
lemma pairSum_sum {K : Type u1} [Fintype K] (f : K → Fin n → Fin n → ℝ) :
|
| 19 |
+
pairSum (fun i j => ∑ k, f k i j) = ∑ k, pairSum (f k) := by
|
| 20 |
+
classical
|
| 21 |
+
unfold pairSum
|
| 22 |
+
have hh (i j : Fin n) : (if i < j then ∑ k, f k i j else 0) =
|
| 23 |
+
∑ k, if i < j then f k i j else 0 := by
|
| 24 |
+
split_ifs <;> simp_all
|
| 25 |
+
simp_rw [hh]
|
| 26 |
+
conv_lhs => arg 2; intro i; rw [Finset.sum_comm]
|
| 27 |
+
rw [Finset.sum_comm]
|
| 28 |
+
|
| 29 |
+
noncomputable def symmetrizeCapacity (c : (Fin n × Fin n) → ℝ)
|
| 30 |
+
(hc : ∀ e, 0 ≤ c e) : Capacity n where
|
| 31 |
+
cap i j := if i = j then 0 else c (i,j) + c (j,i)
|
| 32 |
+
nonneg i j := by split_ifs; exact le_rfl; exact add_nonneg (hc _) (hc _)
|
| 33 |
+
symm i j := by by_cases h : i = j <;> simp [h, eq_comm, add_comm]
|
| 34 |
+
diagonal i := by simp
|
| 35 |
+
|
| 36 |
+
lemma symmetrize_objective (c : (Fin n × Fin n) → ℝ) (hc : ∀ e, 0 ≤ c e)
|
| 37 |
+
(d : Fin n → Fin n → ℝ) (hs : ∀ i j, d i j = d j i) (hd : ∀ i, d i i = 0) :
|
| 38 |
+
pairSum (fun i j => (symmetrizeCapacity c hc).cap i j * d i j) =
|
| 39 |
+
∑ e, c e * d e.1 e.2 := by
|
| 40 |
+
have hfun : (fun i j => (symmetrizeCapacity c hc).cap i j * d i j) =
|
| 41 |
+
(fun i j => c (i,j) * d i j + c (j,i) * d j i) := by
|
| 42 |
+
funext i j
|
| 43 |
+
by_cases h : i = j
|
| 44 |
+
· subst j; simp [hd]
|
| 45 |
+
· simp [symmetrizeCapacity, h, hs j i, add_mul]
|
| 46 |
+
rw [hfun, pairSum_add, pairSum_swap _ (fun i => by simp [hd])]
|
| 47 |
+
exact (Fintype.sum_prod_type (fun e : Fin n × Fin n => c e * d e.1 e.2)).symm
|
| 48 |
+
|
| 49 |
+
theorem cut_cone_duality (hn : 2 ≤ n) (d : Fin n → Fin n → ℝ)
|
| 50 |
+
(hd : NegativeType d) {a b : ℝ} (ha : 0 < a) (hb : 0 < b)
|
| 51 |
+
(havg : (n : ℝ)^2 * a ≤ ∑ i, ∑ j, d i j)
|
| 52 |
+
(hcon : ∀ (K : Type) [Fintype K] (F : Fin n → K → ℝ),
|
| 53 |
+
(∀ i j, (∑ k, |F i k - F j k|) ≤ d i j) →
|
| 54 |
+
(∑ i, ∑ j, ∑ k, |F i k - F j k|) ≤ (n : ℝ)^2 * b) :
|
| 55 |
+
∃ C : Capacity n, 1 ≤ OPT C ∧ 0 < glValue C ∧ glValue C ≤ b / a := by
|
| 56 |
+
classical
|
| 57 |
+
have hsemi := hd.semimetric
|
| 58 |
+
let A : (Fin n × Fin n) → Cut n → ℝ := fun e B => cutDist B.1 e.1 e.2
|
| 59 |
+
let w : Cut n → ℝ := fun B => cutDemand B.1
|
| 60 |
+
have hcol (B : Cut n) : 0 < ∑ e, A e B := by
|
| 61 |
+
change 0 < ∑ e : Fin n × Fin n, cutDist B.1 e.1 e.2
|
| 62 |
+
rw [Fintype.sum_prod_type, orderedSum_eq_two_pairSum _ (cutDist_symm _) (cutDist_self _), pairSum_cut]
|
| 63 |
+
exact mul_pos (by norm_num) (cutDemand_pos B)
|
| 64 |
+
have hbound (t : Cut n → ℝ) (ht : ∀ B, 0 ≤ t B)
|
| 65 |
+
(htd : ∀ e, ∑ B, A e B * t B ≤ d e.1 e.2) :
|
| 66 |
+
(∑ B, w B * t B) ≤ (n : ℝ)^2 * b / 2 := by
|
| 67 |
+
let F : Fin n → Cut n → ℝ := fun i B => t B * cutIndicator B.1 i
|
| 68 |
+
have hFd (i j : Fin n) : (∑ B, |F i B - F j B|) = ∑ B, t B * cutDist B.1 i j := by
|
| 69 |
+
apply Finset.sum_congr rfl
|
| 70 |
+
intro B hB
|
| 71 |
+
simp [F, cutDist, ← mul_sub, abs_mul, abs_of_nonneg (ht B)]
|
| 72 |
+
have hcontract (i j : Fin n) : (∑ B, |F i B - F j B|) ≤ d i j := by
|
| 73 |
+
rw [hFd]
|
| 74 |
+
simpa only [A, mul_comm] using htd (i,j)
|
| 75 |
+
have htavg := hcon (Cut n) F hcontract
|
| 76 |
+
simp_rw [hFd] at htavg
|
| 77 |
+
have hsym (i j : Fin n) : (∑ B, t B * cutDist B.1 i j) =
|
| 78 |
+
∑ B, t B * cutDist B.1 j i := by simp_rw [cutDist_symm _ i j]
|
| 79 |
+
rw [orderedSum_eq_two_pairSum _ hsym (fun i => by simp), pairSum_sum] at htavg
|
| 80 |
+
simp_rw [pairSum_smul, pairSum_cut] at htavg
|
| 81 |
+
have he : (∑ B, w B * t B) = ∑ B, t B * cutDemand B.1 := by
|
| 82 |
+
unfold w; simp_rw [mul_comm]
|
| 83 |
+
rw [he]
|
| 84 |
+
linarith
|
| 85 |
+
let W : ℝ := ∑ B : Cut n, w B
|
| 86 |
+
have hw0 (B : Cut n) : 0 ≤ w B := (cutDemand_pos B).le
|
| 87 |
+
obtain ⟨c,hc,hcover,hobj⟩ := FiniteDuality.packing_duality A w
|
| 88 |
+
(fun e B => cutDist_binary B.1 e.1 e.2) hcol
|
| 89 |
+
(fun e => d e.1 e.2) (fun e => hsemi.1 _ _)
|
| 90 |
+
(show 0 ≤ (n : ℝ)^2 * b / 2 by positivity)
|
| 91 |
+
(show 0 ≤ W from Finset.sum_nonneg (fun B hB => hw0 B))
|
| 92 |
+
(fun B => Finset.single_le_sum (fun B hB => hw0 B) (Finset.mem_univ B)) hbound
|
| 93 |
+
let C := symmetrizeCapacity c hc
|
| 94 |
+
have hC (B : Cut n) : cutDemand B.1 ≤ ∑ i ∈ B.1, ∑ j ∈ B.1ᶜ, C.cap i j := by
|
| 95 |
+
rw [← cut_capacity_pair, symmetrize_objective c hc _ (cutDist_symm _) (cutDist_self _)]
|
| 96 |
+
simpa only [A, w, mul_comm] using hcover B
|
| 97 |
+
refine ⟨C, OPT_ge_one_of_cuts C hn hC, glValue_pos_of_cuts C hn hC, ?_⟩
|
| 98 |
+
let D := pairSum d
|
| 99 |
+
have havg' : (n : ℝ)^2 * a ≤ 2 * D := by
|
| 100 |
+
simpa only [orderedSum_eq_two_pairSum d hsemi.2.1 hsemi.2.2.1] using havg
|
| 101 |
+
have hn0 : 0 < (n : ℝ) := by exact_mod_cast (show 0 < n by omega)
|
| 102 |
+
have hD : 0 < D := by nlinarith [mul_pos (sq_pos_of_pos hn0) ha]
|
| 103 |
+
let d' := fun i j => D⁻¹ * d i j
|
| 104 |
+
have hd' : Feasible d' := by
|
| 105 |
+
refine ⟨hd.scale (inv_nonneg.mpr hD.le), ?_⟩
|
| 106 |
+
change pairSum (fun i j => D��¹ * d i j) = 1
|
| 107 |
+
rw [pairSum_smul, inv_mul_cancel₀ hD.ne']
|
| 108 |
+
have hbdd : BddBelow {r | ∃ d : Fin n → Fin n → ℝ, Feasible d ∧
|
| 109 |
+
r = pairSum (fun i j => C.cap i j * d i j)} := by
|
| 110 |
+
refine ⟨0, ?_⟩
|
| 111 |
+
rintro r ⟨d,hd,rfl⟩
|
| 112 |
+
exact objective_nonneg C hd.1.semimetric
|
| 113 |
+
have hgl : glValue C ≤ pairSum (fun i j => C.cap i j * d' i j) :=
|
| 114 |
+
csInf_le hbdd ⟨d',hd',rfl⟩
|
| 115 |
+
apply hgl.trans
|
| 116 |
+
have hscale : pairSum (fun i j => C.cap i j * d' i j) =
|
| 117 |
+
(pairSum (fun i j => C.cap i j * d i j)) / D := by
|
| 118 |
+
simp only [d', div_eq_mul_inv]
|
| 119 |
+
rw [mul_comm _ D⁻¹, ← pairSum_smul D⁻¹]
|
| 120 |
+
congr 1
|
| 121 |
+
funext i j; ring
|
| 122 |
+
rw [hscale, symmetrize_objective c hc d hsemi.2.1 hsemi.2.2.1,
|
| 123 |
+
div_le_div_iff₀ hD ha]
|
| 124 |
+
have hh1 := mul_le_mul_of_nonneg_right hobj ha.le
|
| 125 |
+
have hh2 := mul_le_mul_of_nonneg_right havg' hb.le
|
| 126 |
+
nlinarith
|
| 127 |
+
|
| 128 |
+
end CutConeDuality
|
| 129 |
+
|
| 130 |
+
end UniformSparsestCut
|
| 131 |
+
|
| 132 |
+
end
|
| 133 |
+
|
| 134 |
+
end OAI
|
lean/OAI/Combinatorics/SparsestCut/CutSums.lean
ADDED
|
@@ -0,0 +1,165 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import OAI.Combinatorics.SparsestCut.FiniteDuality
|
| 2 |
+
|
| 3 |
+
namespace OAI
|
| 4 |
+
|
| 5 |
+
open scoped BigOperators Topology NNReal RealInnerProductSpace InnerProductSpace Matrix ContDiff ENNReal
|
| 6 |
+
open MeasureTheory ProbabilityTheory Set Filter Matrix
|
| 7 |
+
|
| 8 |
+
noncomputable section
|
| 9 |
+
|
| 10 |
+
namespace UniformSparsestCut
|
| 11 |
+
|
| 12 |
+
section CutSums
|
| 13 |
+
|
| 14 |
+
variable {n : ℕ}
|
| 15 |
+
|
| 16 |
+
lemma pairSum_nonneg {f : Fin n → Fin n → ℝ} (hf : ∀ i j, 0 ≤ f i j) :
|
| 17 |
+
0 ≤ pairSum f := by
|
| 18 |
+
apply Finset.sum_nonneg
|
| 19 |
+
intro i hi
|
| 20 |
+
apply Finset.sum_nonneg
|
| 21 |
+
intro j hj
|
| 22 |
+
split_ifs
|
| 23 |
+
· exact hf _ _
|
| 24 |
+
· exact le_rfl
|
| 25 |
+
|
| 26 |
+
lemma pairSum_add (f g : Fin n → Fin n → ℝ) :
|
| 27 |
+
pairSum (fun i j => f i j + g i j) = pairSum f + pairSum g := by
|
| 28 |
+
simp only [pairSum, ← Finset.sum_add_distrib]
|
| 29 |
+
apply Finset.sum_congr rfl
|
| 30 |
+
intro i hi
|
| 31 |
+
apply Finset.sum_congr rfl
|
| 32 |
+
intro j hj
|
| 33 |
+
split_ifs <;> ring
|
| 34 |
+
|
| 35 |
+
lemma pairSum_smul (a : ℝ) (f : Fin n → Fin n → ℝ) :
|
| 36 |
+
pairSum (fun i j => a * f i j) = a * pairSum f := by
|
| 37 |
+
simp only [pairSum, Finset.mul_sum]
|
| 38 |
+
apply Finset.sum_congr rfl
|
| 39 |
+
intro i hi
|
| 40 |
+
apply Finset.sum_congr rfl
|
| 41 |
+
intro j hj
|
| 42 |
+
split_ifs <;> ring
|
| 43 |
+
|
| 44 |
+
lemma pairSum_swap (f : Fin n → Fin n → ℝ) (hd : ∀ i, f i i = 0) :
|
| 45 |
+
pairSum f + pairSum (fun i j => f j i) = ∑ i, ∑ j, f i j := by
|
| 46 |
+
unfold pairSum
|
| 47 |
+
conv_lhs => rhs; rw [Finset.sum_comm]
|
| 48 |
+
rw [← Finset.sum_add_distrib]
|
| 49 |
+
apply Finset.sum_congr rfl
|
| 50 |
+
intro i hi
|
| 51 |
+
rw [← Finset.sum_add_distrib]
|
| 52 |
+
apply Finset.sum_congr rfl
|
| 53 |
+
intro j hj
|
| 54 |
+
rcases lt_trichotomy i j with h | h | h
|
| 55 |
+
· simp [h, not_lt.mpr h.le]
|
| 56 |
+
· subst j; simp [hd]
|
| 57 |
+
· simp [h, not_lt.mpr h.le]
|
| 58 |
+
|
| 59 |
+
lemma orderedSum_eq_two_pairSum (f : Fin n → Fin n → ℝ)
|
| 60 |
+
(hs : ∀ i j, f i j = f j i) (hd : ∀ i, f i i = 0) :
|
| 61 |
+
(∑ i, ∑ j, f i j) = 2 * pairSum f := by
|
| 62 |
+
have he : (fun i j => f j i) = f := funext (fun i => funext (fun j => hs j i))
|
| 63 |
+
simpa [he, two_mul] using (pairSum_swap f hd).symm
|
| 64 |
+
|
| 65 |
+
lemma le_pairSum {f : Fin n → Fin n → ℝ} (hf : ∀ i j, 0 ≤ f i j)
|
| 66 |
+
{i j : Fin n} (hij : i < j) : f i j ≤ pairSum f := by
|
| 67 |
+
calc
|
| 68 |
+
f i j ≤ ∑ k, if i < k then f i k else 0 := by
|
| 69 |
+
have := Finset.single_le_sum (s := Finset.univ)
|
| 70 |
+
(f := fun k => if i < k then f i k else 0)
|
| 71 |
+
(fun k hk => by split_ifs; exact hf _ _; exact le_rfl) (Finset.mem_univ j)
|
| 72 |
+
simpa [hij] using this
|
| 73 |
+
_ ≤ pairSum f := by
|
| 74 |
+
unfold pairSum
|
| 75 |
+
apply Finset.single_le_sum (f := fun k => ∑ l, if k < l then f k l else 0) (a := i)
|
| 76 |
+
· intro k hk
|
| 77 |
+
apply Finset.sum_nonneg
|
| 78 |
+
intro l hl
|
| 79 |
+
split_ifs
|
| 80 |
+
· exact hf _ _
|
| 81 |
+
· exact le_rfl
|
| 82 |
+
· exact Finset.mem_univ i
|
| 83 |
+
|
| 84 |
+
noncomputable def cutIndicator (B : Finset (Fin n)) (i : Fin n) : ℝ := if i ∈ B then 1 else 0
|
| 85 |
+
noncomputable def cutDist (B : Finset (Fin n)) (i j : Fin n) : ℝ :=
|
| 86 |
+
|cutIndicator B i - cutIndicator B j|
|
| 87 |
+
noncomputable def cutDemand (B : Finset (Fin n)) : ℝ := (B.card : ℝ) * (Bᶜ.card : ℝ)
|
| 88 |
+
|
| 89 |
+
def Cut (n : ℕ) := {B : Finset (Fin n) // B.Nonempty ∧ B ≠ Finset.univ}
|
| 90 |
+
|
| 91 |
+
noncomputable instance : Fintype (Cut n) := by unfold Cut; exact Fintype.ofFinite _
|
| 92 |
+
|
| 93 |
+
lemma cutDist_nonneg (B : Finset (Fin n)) (i j : Fin n) : 0 ≤ cutDist B i j := abs_nonneg _
|
| 94 |
+
lemma cutDist_symm (B : Finset (Fin n)) (i j : Fin n) : cutDist B i j = cutDist B j i :=
|
| 95 |
+
abs_sub_comm _ _
|
| 96 |
+
@[simp] lemma cutDist_self (B : Finset (Fin n)) (i : Fin n) : cutDist B i i = 0 := by
|
| 97 |
+
simp [cutDist]
|
| 98 |
+
|
| 99 |
+
lemma cutDist_binary (B : Finset (Fin n)) (i j : Fin n) :
|
| 100 |
+
cutDist B i j = 0 ∨ cutDist B i j = 1 := by
|
| 101 |
+
classical
|
| 102 |
+
unfold cutDist cutIndicator
|
| 103 |
+
split_ifs <;> norm_num
|
| 104 |
+
|
| 105 |
+
lemma cutDist_triangle (B : Finset (Fin n)) (i j k : Fin n) :
|
| 106 |
+
cutDist B i k ≤ cutDist B i j + cutDist B j k := abs_sub_le _ _ _
|
| 107 |
+
|
| 108 |
+
lemma cutDemand_eq (B : Finset (Fin n)) :
|
| 109 |
+
cutDemand B = (B.card : ℝ) * ((n : ℝ) - B.card) := by
|
| 110 |
+
unfold cutDemand
|
| 111 |
+
rw [Finset.card_compl, Fintype.card_fin, Nat.cast_sub (show B.card ≤ n by simpa using B.card_le_univ)]
|
| 112 |
+
|
| 113 |
+
lemma cutDemand_pos (B : Cut n) : 0 < cutDemand B.1 := by
|
| 114 |
+
unfold cutDemand
|
| 115 |
+
apply mul_pos
|
| 116 |
+
· exact_mod_cast Finset.card_pos.mpr B.2.1
|
| 117 |
+
· exact_mod_cast Finset.card_pos.mpr (by simpa [Finset.nonempty_iff_ne_empty] using B.2.2)
|
| 118 |
+
|
| 119 |
+
lemma ordered_cut_sum (B : Finset (Fin n)) (f : Fin n → Fin n → ℝ) :
|
| 120 |
+
(∑ i, ∑ j, f i j * cutDist B i j) =
|
| 121 |
+
(∑ i ∈ B, ∑ j ∈ Bᶜ, f i j) + (∑ i ∈ Bᶜ, ∑ j ∈ B, f i j) := by
|
| 122 |
+
classical
|
| 123 |
+
have hp (i j : Fin n) : f i j * cutDist B i j =
|
| 124 |
+
(if i ∈ B then if j ∈ Bᶜ then f i j else 0 else 0) +
|
| 125 |
+
(if i ∈ Bᶜ then if j ∈ B then f i j else 0 else 0) := by
|
| 126 |
+
unfold cutDist cutIndicator
|
| 127 |
+
by_cases hi : i ∈ B <;> by_cases hj : j ∈ B <;> simp [hi, hj]
|
| 128 |
+
simp_rw [hp]
|
| 129 |
+
simp only [Finset.sum_add_distrib, Finset.sum_ite_irrel,
|
| 130 |
+
Finset.sum_const_zero, Finset.sum_ite_mem, Finset.univ_inter]
|
| 131 |
+
|
| 132 |
+
lemma ordered_cut_sum_symm (B : Finset (Fin n)) (f : Fin n → Fin n → ℝ)
|
| 133 |
+
(hs : ∀ i j, f i j = f j i) :
|
| 134 |
+
(∑ i, ∑ j, f i j * cutDist B i j) = 2 * (∑ i �� B, ∑ j ∈ Bᶜ, f i j) := by
|
| 135 |
+
rw [ordered_cut_sum, two_mul]
|
| 136 |
+
congr 1
|
| 137 |
+
rw [Finset.sum_comm]
|
| 138 |
+
apply Finset.sum_congr rfl
|
| 139 |
+
intro i hi
|
| 140 |
+
apply Finset.sum_congr rfl
|
| 141 |
+
intro j hj
|
| 142 |
+
exact hs j i
|
| 143 |
+
|
| 144 |
+
lemma pairSum_cut (B : Finset (Fin n)) : pairSum (cutDist B) = cutDemand B := by
|
| 145 |
+
have h := ordered_cut_sum_symm B (fun _ _ => 1) (fun _ _ => rfl)
|
| 146 |
+
simp only [one_mul, Finset.sum_const, nsmul_eq_mul, mul_one] at h
|
| 147 |
+
rw [orderedSum_eq_two_pairSum _ (cutDist_symm B) (cutDist_self B)] at h
|
| 148 |
+
unfold cutDemand
|
| 149 |
+
nlinarith
|
| 150 |
+
|
| 151 |
+
lemma cut_capacity_pair (C : Capacity n) (B : Finset (Fin n)) :
|
| 152 |
+
pairSum (fun i j => C.cap i j * cutDist B i j) =
|
| 153 |
+
∑ i ∈ B, ∑ j ∈ Bᶜ, C.cap i j := by
|
| 154 |
+
have h := ordered_cut_sum_symm B C.cap C.symm
|
| 155 |
+
rw [orderedSum_eq_two_pairSum _ (fun i j => by rw [C.symm i j, cutDist_symm B i j])
|
| 156 |
+
(fun i => by simp)] at h
|
| 157 |
+
linarith
|
| 158 |
+
|
| 159 |
+
end CutSums
|
| 160 |
+
|
| 161 |
+
end UniformSparsestCut
|
| 162 |
+
|
| 163 |
+
end
|
| 164 |
+
|
| 165 |
+
end OAI
|
lean/OAI/Combinatorics/SparsestCut/DirectionAsymptotics.lean
ADDED
|
@@ -0,0 +1,217 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import OAI.Combinatorics.SparsestCut.DirectionInterpolation
|
| 2 |
+
|
| 3 |
+
namespace OAI
|
| 4 |
+
|
| 5 |
+
open scoped BigOperators Topology NNReal RealInnerProductSpace InnerProductSpace Matrix ContDiff ENNReal
|
| 6 |
+
open MeasureTheory ProbabilityTheory Set Filter Matrix
|
| 7 |
+
|
| 8 |
+
noncomputable section
|
| 9 |
+
|
| 10 |
+
namespace UniformSparsestCut.DirectionAsymptotics
|
| 11 |
+
open Filter
|
| 12 |
+
open scoped Topology
|
| 13 |
+
|
| 14 |
+
lemma grid_card_bound (m k : ℕ) (hm : 2 ≤ m) :
|
| 15 |
+
(((2*m^k+1)^m : ℕ) : ℝ) ≤ Real.exp (((k : ℝ)+2)*(m : ℝ)^2) := by
|
| 16 |
+
have hm' : (2 : ℝ) ≤ m := by exact_mod_cast hm
|
| 17 |
+
have hp : (1 : ℝ) ≤ (m : ℝ)^k := one_le_pow₀ (by linarith)
|
| 18 |
+
have he : (m : ℝ) ≤ Real.exp m := by linarith [Real.add_one_le_exp (m : ℝ)]
|
| 19 |
+
have h3 : (3 : ℝ) ≤ Real.exp m := by linarith [Real.add_one_le_exp (m : ℝ)]
|
| 20 |
+
have hb : (2 : ℝ)*(m : ℝ)^k+1 ≤ Real.exp ((k+1 : ℕ)*(m : ℝ)) := by
|
| 21 |
+
calc
|
| 22 |
+
_ ≤ 3*(m : ℝ)^k := by linarith
|
| 23 |
+
_ ≤ Real.exp m * (Real.exp m)^k := by gcongr
|
| 24 |
+
_ = _ := by rw [← Real.exp_nat_mul]; rw [← Real.exp_add]; congr 1; push_cast; ring
|
| 25 |
+
push_cast
|
| 26 |
+
calc
|
| 27 |
+
_ ≤ (Real.exp ((k+1 : ℕ)*(m : ℝ)))^m := pow_le_pow_left₀ (by positivity) hb _
|
| 28 |
+
_ = Real.exp (((k : ℝ)+1)*(m : ℝ)^2) := by rw [← Real.exp_nat_mul]; congr 1; push_cast; ring
|
| 29 |
+
_ ≤ _ := by apply Real.exp_le_exp.mpr; nlinarith [sq_nonneg (m : ℝ)]
|
| 30 |
+
|
| 31 |
+
lemma polynomial_exp_tendsto_zero (k : ℕ) {c : ℝ} (hc : 0 < c) :
|
| 32 |
+
Tendsto (fun m : ℕ => (m : ℝ)^k * Real.exp (-c*(m : ℝ))) atTop (𝓝 0) := by
|
| 33 |
+
have h := (tendsto_rpow_mul_exp_neg_mul_atTop_nhds_zero (k : ℝ) c hc).comp
|
| 34 |
+
tendsto_natCast_atTop_atTop
|
| 35 |
+
simpa only [Real.rpow_natCast, Function.comp_def] using h
|
| 36 |
+
|
| 37 |
+
lemma large_fourier_exponent (x : ℝ) (hx : 1000000 ≤ x) :
|
| 38 |
+
54*x^2 - x^4/2048 ≤ -x := by
|
| 39 |
+
have hx0 : 0 ≤ x := by linarith
|
| 40 |
+
have hx2 : 1000000^2 ≤ x^2 := by nlinarith
|
| 41 |
+
have hprod := mul_nonneg (show 1000000^2 - (54*2048+2048 : ℝ) ≥ 0 by norm_num) (sq_nonneg x)
|
| 42 |
+
have hx4 : (1000000 : ℝ)^2*x^2 ≤ x^4 := by nlinarith [mul_le_mul_of_nonneg_right hx2 (sq_nonneg x)]
|
| 43 |
+
have hxx : x ≤ x^2 := by nlinarith
|
| 44 |
+
nlinarith
|
| 45 |
+
|
| 46 |
+
lemma large_chart_exponent (x : ℝ) (hx : 1000000 ≤ x) :
|
| 47 |
+
6*x^2 - x^3/32 ≤ -x := by
|
| 48 |
+
have hh : 1000000*x^2 ≤ x^3 := by nlinarith [mul_le_mul_of_nonneg_right hx (sq_nonneg x)]
|
| 49 |
+
have hxx : x ≤ x^2 := by nlinarith
|
| 50 |
+
nlinarith
|
| 51 |
+
|
| 52 |
+
lemma selection_majorant_tendsto :
|
| 53 |
+
Tendsto (fun m : ℕ => 2*(m : ℝ)^9*Real.exp (-(m : ℝ)/8) +
|
| 54 |
+
6*(m : ℝ)^3*Real.exp (-(m : ℝ))) atTop (𝓝 0) := by
|
| 55 |
+
have h1 := (polynomial_exp_tendsto_zero 9 (c := 1/8) (by norm_num)).const_mul 2
|
| 56 |
+
have h2 := (polynomial_exp_tendsto_zero 3 (c := 1) (by norm_num)).const_mul 6
|
| 57 |
+
convert h1.add h2 using 1
|
| 58 |
+
· funext m
|
| 59 |
+
simp only [show -(1/8 : ℝ)*(m : ℝ) = -(m : ℝ)/8 by ring,
|
| 60 |
+
show -(1 : ℝ)*(m : ℝ) = -(m : ℝ) by ring]
|
| 61 |
+
ring
|
| 62 |
+
· norm_num
|
| 63 |
+
|
| 64 |
+
lemma eventual_selection_majorant : ∀ᶠ m : ℕ in atTop,
|
| 65 |
+
2*(m : ℝ)^9*Real.exp (-(m : ℝ)/8) +
|
| 66 |
+
6*(m : ℝ)^3*Real.exp (-(m : ℝ)) < 1 :=
|
| 67 |
+
selection_majorant_tendsto.eventually (gt_mem_nhds (by norm_num))
|
| 68 |
+
|
| 69 |
+
lemma normalized_fourier_exponent {m : ℕ} (hm : 0 < m) :
|
| 70 |
+
-(m : ℝ)^6*(1/(2*Real.sqrt m))^2/(2*(2*Real.sqrt m)^2) = -(m : ℝ)^4/32 := by
|
| 71 |
+
have hm0 : (m : ℝ) ≠ 0 := by exact_mod_cast hm.ne'
|
| 72 |
+
have hs : (2*Real.sqrt m)^2 = 4*(m : ℝ) := by
|
| 73 |
+
nlinarith [Real.sq_sqrt (Nat.cast_nonneg (α := ℝ) m)]
|
| 74 |
+
rw [_root_.one_div_pow, hs]
|
| 75 |
+
field_simp
|
| 76 |
+
ring
|
| 77 |
+
|
| 78 |
+
lemma normalized_covariance_exponent (m : ℕ) (hm : 0 < m) :
|
| 79 |
+
-(m : ℝ)^6*(1/8)^2/(2*(4*(m : ℝ))^2) = -(m : ℝ)^4/2048 := by
|
| 80 |
+
have hm0 : (m : ℝ) ≠ 0 := by exact_mod_cast hm.ne'
|
| 81 |
+
field_simp
|
| 82 |
+
ring
|
| 83 |
+
|
| 84 |
+
lemma probability_majorization {m : ℕ} (hm : 1000000 ≤ m) {A B : ℝ}
|
| 85 |
+
(_hA0 : 0 ≤ A) (hB0 : 0 ≤ B)
|
| 86 |
+
(hA : A ≤ Real.exp (6*(m : ℝ)^2)) (hB : B ≤ Real.exp (48*(m : ℝ)^2)) :
|
| 87 |
+
(m : ℝ)^3*((m : ℝ)^6*(2*Real.exp (-(m : ℝ)/8)) +
|
| 88 |
+
A*B*(2*Real.exp (-(m : ℝ)^4/32)) + A*(2*Real.exp (-(m : ℝ)^4/2048))) +
|
| 89 |
+
A*(2*Real.exp (-(m : ℝ)^3/32)) ≤
|
| 90 |
+
2*(m : ℝ)^9*Real.exp (-(m : ℝ)/8) + 6*(m : ℝ)^3*Real.exp (-(m : ℝ)) := by
|
| 91 |
+
have hm' : (1000000 : ℝ) ≤ m := by exact_mod_cast hm
|
| 92 |
+
have hpow : (1 : ℝ) ≤ (m : ℝ)^3 := one_le_pow₀ (by linarith)
|
| 93 |
+
have hf : A*B*(2*Real.exp (-(m : ℝ)^4/32)) ≤ 2*Real.exp (-(m : ℝ)) := by
|
| 94 |
+
calc
|
| 95 |
+
_ ≤ Real.exp (6*(m : ℝ)^2)*Real.exp (48*(m : ℝ)^2)*
|
| 96 |
+
(2*Real.exp (-(m : ℝ)^4/32)) := by gcongr
|
| 97 |
+
_ = 2*Real.exp (54*(m : ℝ)^2-(m : ℝ)^4/32) := by
|
| 98 |
+
rw [show 54*(m : ℝ)^2-(m : ℝ)^4/32 =
|
| 99 |
+
(6*(m : ℝ)^2+48*(m : ℝ)^2)+(-(m : ℝ)^4/32) by ring, Real.exp_add, Real.exp_add]
|
| 100 |
+
ring
|
| 101 |
+
_ ≤ _ := by
|
| 102 |
+
apply mul_le_mul_of_nonneg_left (Real.exp_le_exp.mpr ?_) (by norm_num)
|
| 103 |
+
have := large_fourier_exponent (m : ℝ) hm'
|
| 104 |
+
nlinarith [pow_nonneg (Nat.cast_nonneg (α := ℝ) m) 4]
|
| 105 |
+
have hc : A*(2*Real.exp (-(m : ℝ)^4/2048)) ≤ 2*Real.exp (-(m : ℝ)) := by
|
| 106 |
+
calc
|
| 107 |
+
_ ≤ Real.exp (6*(m : ℝ)^2)*(2*Real.exp (-(m : ℝ)^4/2048)) := by gcongr
|
| 108 |
+
_ = 2*Real.exp (6*(m : ℝ)^2-(m : ℝ)^4/2048) := by simp only [Real.exp_sub, neg_div, Real.exp_neg]; ring
|
| 109 |
+
_ ≤ _ := by
|
| 110 |
+
apply mul_le_mul_of_nonneg_left (Real.exp_le_exp.mpr ?_) (by norm_num)
|
| 111 |
+
have := large_fourier_exponent (m : ℝ) hm'
|
| 112 |
+
nlinarith [sq_nonneg (m : ℝ)]
|
| 113 |
+
have hg : A*(2*Real.exp (-(m : ℝ)^3/32)) ≤ 2*Real.exp (-(m : ℝ)) := by
|
| 114 |
+
calc
|
| 115 |
+
_ ≤ Real.exp (6*(m : ℝ)^2)*(2*Real.exp (-(m : ℝ)^3/32)) := by gcongr
|
| 116 |
+
_ = 2*Real.exp (6*(m : ℝ)^2-(m : ℝ)^3/32) := by simp only [Real.exp_sub, neg_div, Real.exp_neg]; ring
|
| 117 |
+
_ ≤ _ := mul_le_mul_of_nonneg_left (Real.exp_le_exp.mpr (large_chart_exponent _ hm')) (by norm_num)
|
| 118 |
+
have hs := mul_le_mul_of_nonneg_left (add_le_add (add_le_add (le_refl
|
| 119 |
+
((m : ℝ)^6*(2*Real.exp (-(m : ℝ)/8)))) hf) hc) (pow_nonneg (Nat.cast_nonneg m) 3)
|
| 120 |
+
have he := mul_le_mul_of_nonneg_right hpow (Real.exp_pos (-(m : ℝ))).le
|
| 121 |
+
have hid : (m : ℝ)^3*((m : ℝ)^6*(2*Real.exp (-(m : ℝ)/8))) =
|
| 122 |
+
2*(m : ℝ)^9*Real.exp (-(m : ℝ)/8) := by ring
|
| 123 |
+
nlinarith
|
| 124 |
+
|
| 125 |
+
lemma projection_failure_bound {m : ℕ} (hm : 2 ≤ m) (hlog : 0 ≤ Real.log m) :
|
| 126 |
+
(m : ℝ)^6*(2*Real.exp (-(10*Real.sqrt (Real.log m))^2/2)) ≤ 1/4 := by
|
| 127 |
+
have hm' : (2 : ℝ) ≤ m := by exact_mod_cast hm
|
| 128 |
+
have hm0 : (0 : ℝ) < m := by linarith
|
| 129 |
+
have hs : -(10*Real.sqrt (Real.log m))^2/2 = -((50 : ℕ) * Real.log m) := by
|
| 130 |
+
nlinarith [Real.sq_sqrt hlog]
|
| 131 |
+
rw [hs, Real.exp_neg, Real.exp_nat_mul, Real.exp_log hm0]
|
| 132 |
+
have hpow : (8 : ℝ) ≤ (m : ℝ)^44 := by
|
| 133 |
+
have hh : (2 : ℝ)^44 ≤ (m : ℝ)^44 := pow_le_pow_left₀ (by norm_num) hm' _
|
| 134 |
+
norm_num at hh ⊢ ; linarith
|
| 135 |
+
have hid : (m : ℝ)^6*(2*((m : ℝ)^50)⁻¹) = 2/(m : ℝ)^44 := by
|
| 136 |
+
field_simp
|
| 137 |
+
rw [hid]
|
| 138 |
+
apply (div_le_iff₀ (pow_pos hm0 _)).mpr
|
| 139 |
+
linarith
|
| 140 |
+
|
| 141 |
+
lemma eventual_bias_bound : ∀ᶠ m : ℕ in atTop,
|
| 142 |
+
0 < m ∧ 16*Real.exp (-(m : ℝ)/12) ≤ 1/(8*(m : ℝ)) := by
|
| 143 |
+
have ht := (polynomial_exp_tendsto_zero 1 (c := 1/12) (by norm_num)).const_mul 128
|
| 144 |
+
have hsmall : ∀ᶠ m : ℕ in atTop,
|
| 145 |
+
128*((m : ℝ)*Real.exp (-(m : ℝ)/12)) < 1 := by
|
| 146 |
+
simpa only [pow_one, mul_zero, neg_mul, one_div_mul_eq_div, neg_div] using
|
| 147 |
+
ht.eventually (gt_mem_nhds (by norm_num : (128 : ℝ)*0 < 1))
|
| 148 |
+
filter_upwards [hsmall, eventually_ge_atTop 1] with m hs hm
|
| 149 |
+
have hm' : (0 : ℝ) < m := by exact_mod_cast (show 0 < m by omega)
|
| 150 |
+
refine ⟨by omega, (le_div_iff₀ (by positivity : (0 : ℝ) < 8*(m : ℝ))).mpr ?_⟩
|
| 151 |
+
nlinarith
|
| 152 |
+
|
| 153 |
+
lemma scalar_net_error {m : ℕ} (hm : 1000 ≤ m)
|
| 154 |
+
(hb : 16*Real.exp (-(m : ℝ)/12) ≤ 1/(8*(m : ℝ))) :
|
| 155 |
+
(1/(2*Real.sqrt m) + 16*Real.exp (-(m : ℝ)/12))/(1-1/(m : ℝ)^3) +
|
| 156 |
+
(5*(m : ℝ))*(1/(m : ℝ)^3) ≤ 2/Real.sqrt m := by
|
| 157 |
+
have hx : (1000 : ℝ) ≤ m := by exact_mod_cast hm
|
| 158 |
+
have hx0 : (0 : ℝ) < m := by linarith
|
| 159 |
+
have ht : 0 < Real.sqrt m := Real.sqrt_pos.mpr hx0
|
| 160 |
+
have ht2 := Real.sq_sqrt hx0.le
|
| 161 |
+
have htm : Real.sqrt m ≤ (m : ℝ) := by nlinarith
|
| 162 |
+
have hp3 : (8 : ℝ) ≤ (m : ℝ)^3 := by nlinarith [pow_le_pow_left₀ (by norm_num : (0 : ℝ) ≤ 2) (show (2 : ℝ) ≤ m by linarith) 3]
|
| 163 |
+
have hr : 1/(m : ℝ)^3 ≤ 1/8 := (div_le_div_iff₀ (by positivity) (by norm_num)).mpr (by linarith)
|
| 164 |
+
have hd : (7/8 : ℝ) ≤ 1-1/(m : ℝ)^3 := by linarith
|
| 165 |
+
have hsmall : 1/(8*(m : ℝ)) ≤ 1/(8*Real.sqrt m) :=
|
| 166 |
+
one_div_le_one_div_of_le (by positivity) (by linarith)
|
| 167 |
+
have hbs : 1/(2*Real.sqrt m) + 16*Real.exp (-(m : ℝ)/12) ≤ (5/8)/Real.sqrt m := by
|
| 168 |
+
have he : 1/(2*Real.sqrt m) + 1/(8*Real.sqrt m) = (5/8)/Real.sqrt m := by ring
|
| 169 |
+
linarith
|
| 170 |
+
have hfirst : (1/(2*Real.sqrt m) + 16*Real.exp (-(m : ℝ)/12))/(1-1/(m : ℝ)^3) ≤
|
| 171 |
+
(5/7)/Real.sqrt m := by
|
| 172 |
+
calc
|
| 173 |
+
_ ≤ ((5/8)/Real.sqrt m)/(7/8) := div_le_div₀ (by positivity) hbs (by norm_num) hd
|
| 174 |
+
_ = _ := by ring
|
| 175 |
+
have hlast : (5*(m : ℝ))*(1/(m : ℝ)^3) ≤ 1/Real.sqrt m := by
|
| 176 |
+
rw [show (5*(m : ℝ))*(1/(m : ℝ)^3) = 5/(m : ℝ)^2 by field_simp ]
|
| 177 |
+
apply (div_le_div_iff₀ (by positivity) ht).mpr
|
| 178 |
+
nlinarith
|
| 179 |
+
have hrest : (5/7)/Real.sqrt m + 1/Real.sqrt m ≤ 2/Real.sqrt m := by
|
| 180 |
+
rw [← add_div]
|
| 181 |
+
exact div_le_div_of_nonneg_right (by norm_num) ht.le
|
| 182 |
+
linarith
|
| 183 |
+
|
| 184 |
+
lemma covariance_net_error {m : ℕ} (hm : 1000 ≤ m)
|
| 185 |
+
(hb : 16*Real.exp (-(m : ℝ)/12) ≤ 1/(8*(m : ℝ))) :
|
| 186 |
+
1/8 + 16*Real.exp (-(m : ℝ)/12) + 8*(m : ℝ)*(1/(m : ℝ)^3) ≤ 1/2 := by
|
| 187 |
+
have hx : (1000 : ℝ) ≤ m := by exact_mod_cast hm
|
| 188 |
+
have hx0 : (0 : ℝ) < m := by linarith
|
| 189 |
+
have hsm : 1/(8*(m : ℝ)) ≤ 1/8 := one_div_le_one_div_of_le (by norm_num) (by linarith)
|
| 190 |
+
have hh : 8*(m : ℝ)*(1/(m : ℝ)^3) ≤ 1/4 := by
|
| 191 |
+
rw [show 8*(m : ℝ)*(1/(m : ℝ)^3) = 8/(m : ℝ)^2 by field_simp ]
|
| 192 |
+
apply (div_le_iff₀ (by positivity)).mpr
|
| 193 |
+
nlinarith
|
| 194 |
+
linarith
|
| 195 |
+
|
| 196 |
+
lemma projection_net_error {m : ℕ} (hm : 1000 ≤ m) (hl : 1 ≤ Real.log m) :
|
| 197 |
+
10*Real.sqrt (Real.log m) + 2*Real.sqrt m*(1/(m : ℝ)^3) ≤
|
| 198 |
+
11*Real.sqrt (Real.log m) := by
|
| 199 |
+
have hx : (1000 : ℝ) ≤ m := by exact_mod_cast hm
|
| 200 |
+
have hx0 : (0 : ℝ) < m := by linarith
|
| 201 |
+
have ht := Real.sq_sqrt hx0.le
|
| 202 |
+
have htm : Real.sqrt m ≤ (m : ℝ) := by nlinarith [Real.sqrt_nonneg (m : ℝ)]
|
| 203 |
+
have hs : 1 ≤ Real.sqrt (Real.log m) := by
|
| 204 |
+
nlinarith [Real.sq_sqrt (show 0 ≤ Real.log m by linarith), Real.sqrt_nonneg (Real.log m)]
|
| 205 |
+
have hg : 2*Real.sqrt m*(1/(m : ℝ)^3) ≤ 1 := by
|
| 206 |
+
rw [mul_one_div]
|
| 207 |
+
apply (div_le_iff₀ (by positivity)).mpr
|
| 208 |
+
have hp : (m : ℝ)^2 ≤ (m : ℝ)^3 := by
|
| 209 |
+
nlinarith [mul_le_mul_of_nonneg_right (show (1 : ℝ) ≤ m by linarith) (sq_nonneg (m : ℝ))]
|
| 210 |
+
nlinarith
|
| 211 |
+
linarith
|
| 212 |
+
|
| 213 |
+
end UniformSparsestCut.DirectionAsymptotics
|
| 214 |
+
|
| 215 |
+
end
|
| 216 |
+
|
| 217 |
+
end OAI
|
lean/OAI/Combinatorics/SparsestCut/DirectionFamily.lean
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import OAI.Combinatorics.SparsestCut.DirectionAsymptotics
|
| 2 |
+
|
| 3 |
+
namespace OAI
|
| 4 |
+
|
| 5 |
+
open scoped BigOperators Topology NNReal RealInnerProductSpace InnerProductSpace Matrix ContDiff ENNReal
|
| 6 |
+
open MeasureTheory ProbabilityTheory Set Filter Matrix
|
| 7 |
+
|
| 8 |
+
noncomputable section
|
| 9 |
+
|
| 10 |
+
namespace UniformSparsestCut.DirectionFamily
|
| 11 |
+
open Directions DirectionInterpolation DirectionAsymptotics GaussianTools FiniteNets
|
| 12 |
+
open MeasureTheory ProbabilityTheory Set Filter
|
| 13 |
+
open scoped BigOperators Topology
|
| 14 |
+
|
| 15 |
+
variable {m N S : ℕ}
|
| 16 |
+
local notation "E" => EuclideanSpace ℝ (Fin m)
|
| 17 |
+
|
| 18 |
+
lemma normBounds_of_not_bad {g : Fin N → E} (hg : g ∉ normBad) (i : Fin N) :
|
| 19 |
+
(m : ℝ)/4 ≤ ‖g i‖^2 ∧ ‖g i‖^2 ≤ 4*(m : ℝ) := by
|
| 20 |
+
constructor
|
| 21 |
+
· by_contra h; exact hg ⟨i, Or.inl (lt_of_not_ge h)⟩
|
| 22 |
+
· by_contra h; exact hg ⟨i, Or.inr (lt_of_not_ge h)⟩
|
| 23 |
+
|
| 24 |
+
lemma inner_empiricalSin (g : Fin N → E) (v w : E) :
|
| 25 |
+
inner ℝ (empiricalSin g w - Real.exp (-‖w‖^2/2) • w) v =
|
| 26 |
+
(∑ i, inner ℝ (g i) v * Real.sin (inner ℝ (g i) w))/(N : ℝ) -
|
| 27 |
+
inner ℝ w v * Real.exp (-‖w‖^2/2) := by
|
| 28 |
+
simp only [empiricalSin, inner_sub_left, inner_smul_left, conj_trivial,
|
| 29 |
+
sum_inner, div_eq_mul_inv]
|
| 30 |
+
congr 1
|
| 31 |
+
· rw [Finset.mul_sum, Finset.sum_mul]
|
| 32 |
+
apply Finset.sum_congr rfl
|
| 33 |
+
intro i _
|
| 34 |
+
ring
|
| 35 |
+
· ring
|
| 36 |
+
|
| 37 |
+
lemma net_fourier_scalar (hm : 0 < m) {g : Fin N → E} (hg : g ∉ normBad)
|
| 38 |
+
{u : ℝ} (v w : E) (hv : ‖v‖ = 1) (hf : g ∉ fourierBad u v w) :
|
| 39 |
+
|inner ℝ (empiricalSin g w - Real.exp (-‖w‖^2/2) • w) v| ≤
|
| 40 |
+
u + 16*Real.exp (-(m : ℝ)/12) := by
|
| 41 |
+
have hsample (i : Fin N) : fourierSummand v w (g i) =
|
| 42 |
+
inner ℝ (g i) v * Real.sin (inner ℝ (g i) w) := by
|
| 43 |
+
dsimp only [fourierSummand, covarianceSummand, truncate]
|
| 44 |
+
exact Set.indicator_of_mem (show g i ∈ {z : E | ‖z‖^2 ≤ 4*(m : ℝ)} from
|
| 45 |
+
(normBounds_of_not_bad hg i).2) _
|
| 46 |
+
have hdev : |(∑ i, fourierSummand v w (g i))/(N : ℝ) -
|
| 47 |
+
∫ z, fourierSummand v w z ∂stdGaussian E| ≤ u := le_of_not_gt hf
|
| 48 |
+
simp_rw [hsample] at hdev
|
| 49 |
+
rw [inner_empiricalSin]
|
| 50 |
+
have hb := truncation_fourier_bias (show 1 ≤ m by omega) v w hv
|
| 51 |
+
exact (abs_sub_le _ (∫ z, fourierSummand v w z ∂stdGaussian E) _).trans (add_le_add hdev hb)
|
| 52 |
+
|
| 53 |
+
lemma net_covariance_scalar {g : Fin N → E} (hg : g ∉ normBad)
|
| 54 |
+
(v : E) (hv : ‖v‖ = 1) (hf : g ∉ covarianceBad v) :
|
| 55 |
+
|empiricalCov g v - 1| ≤ 1/8 + 16*Real.exp (-(m : ℝ)/12) := by
|
| 56 |
+
have hsample (i : Fin N) : covarianceSummand v (g i) = (inner ℝ v (g i))^2 := by
|
| 57 |
+
dsimp only [fourierSummand, covarianceSummand, truncate]
|
| 58 |
+
exact Set.indicator_of_mem (show g i ∈ {z : E | ‖z‖^2 ≤ 4*(m : ℝ)} from
|
| 59 |
+
(normBounds_of_not_bad hg i).2) _
|
| 60 |
+
have hdev : |(∑ i, covarianceSummand v (g i))/(N : ℝ) -
|
| 61 |
+
∫ z, covarianceSummand v z ∂stdGaussian E| ≤ 1/8 := le_of_not_gt hf
|
| 62 |
+
simp_rw [hsample] at hdev
|
| 63 |
+
exact (abs_sub_le _ (∫ z, covarianceSummand v z ∂stdGaussian E) _).trans
|
| 64 |
+
(add_le_add hdev (truncation_covariance_bias v hv))
|
| 65 |
+
|
| 66 |
+
lemma source_nets (hm : 2 ≤ m) : ∃ V W : Finset E,
|
| 67 |
+
(∀ v ∈ V, ‖v‖ = 1) ∧
|
| 68 |
+
(V.card : ℝ) ≤ Real.exp (6*(m : ℝ)^2) ∧
|
| 69 |
+
(W.card : ℝ) ≤ Real.exp (48*(m : ℝ)^2) ∧
|
| 70 |
+
(∀ v : E, ‖v‖ = 1 → ∃ v' ∈ V, ‖v-v'‖ ≤ 1/(m : ℝ)^3) ∧
|
| 71 |
+
(∀ w : E, ‖w‖ ≤ (m : ℝ)^42 → ∃ w' ∈ W, ‖w-w'‖ ≤ 1/(m : ℝ)^3) := by
|
| 72 |
+
have hm0 : (0 : ℝ) < m := by exact_mod_cast (show 0 < m by omega)
|
| 73 |
+
have hδ : (0 : ℝ) < 1/(m : ℝ)^4 := by positivity
|
| 74 |
+
have hid : (m : ℝ) * (1/(m : ℝ)^4) = 1/(m : ℝ)^3 := by field_simp
|
| 75 |
+
obtain ⟨V,hV,hVc,hVnet⟩ := exists_coordinate_net (K := m^4) hδ {v : E | ‖v‖ = 1} (by
|
| 76 |
+
intro v hv
|
| 77 |
+
change ‖v‖ = 1 at hv
|
| 78 |
+
rw [hv, Nat.cast_pow]
|
| 79 |
+
simp [hm0.ne'])
|
| 80 |
+
obtain ⟨W,hW,hWc,hWnet⟩ := exists_coordinate_net (K := m^46) hδ {w : E | ‖w‖ ≤ (m : ℝ)^42} (by
|
| 81 |
+
intro w hw
|
| 82 |
+
change ‖w‖ ≤ (m : ℝ)^42 at hw
|
| 83 |
+
have he : (((m^46 : ℕ) : ℝ))*(1/(m : ℝ)^4) = (m : ℝ)^42 := by push_cast; field_simp
|
| 84 |
+
rwa [he])
|
| 85 |
+
refine ⟨V,W,hV,?_,?_,?_,?_⟩
|
| 86 |
+
· exact (Nat.cast_le.mpr hVc).trans (by simpa only [Nat.cast_pow, Nat.cast_add, Nat.cast_mul, Nat.cast_ofNat, show (4+2 : ℝ) = 6 by norm_num] using grid_card_bound m 4 hm)
|
| 87 |
+
· exact (Nat.cast_le.mpr hWc).trans (by simpa only [Nat.cast_pow, Nat.cast_add, Nat.cast_mul, Nat.cast_ofNat, show (46+2 : ℝ) = 48 by norm_num] using grid_card_bound m 46 hm)
|
| 88 |
+
· intro v hv; simpa only [hid] using hVnet v hv
|
| 89 |
+
· intro w hw; simpa only [hid] using hWnet w hw
|
| 90 |
+
|
| 91 |
+
lemma select_source_nets (hm : 1000000 ≤ m) (hlog : 1 ≤ Real.log m)
|
| 92 |
+
(hmajor : 2*(m : ℝ)^9*Real.exp (-(m : ℝ)/8) +
|
| 93 |
+
6*(m : ℝ)^3*Real.exp (-(m : ℝ)) < 1)
|
| 94 |
+
(V W : Finset E) (hV : ∀ v ∈ V, ‖v‖ = 1)
|
| 95 |
+
(hVc : (V.card : ℝ) ≤ Real.exp (6*(m : ℝ)^2))
|
| 96 |
+
(hWc : (W.card : ℝ) ≤ Real.exp (48*(m : ℝ)^2)) :
|
| 97 |
+
∃ g : Fin (m^3) → Fin (m^6) → E,
|
| 98 |
+
(∀ s a b, a ≠ b → ∀ t : ℝ, g s a ≠ t • g s b) ∧
|
| 99 |
+
(��� s, g s ∉ normBad) ∧
|
| 100 |
+
(∀ s, ∀ v ∈ V, ∀ w ∈ W, g s ∉ fourierBad (1/(2*Real.sqrt m)) v w) ∧
|
| 101 |
+
(∀ s, ∀ v ∈ V, g s ∉ covarianceBad v) ∧
|
| 102 |
+
(∀ v ∈ V, (badCount (projectionBad (10*Real.sqrt (Real.log m)) v) g : ℝ) ≤
|
| 103 |
+
((m^3 : ℕ) : ℝ)/2) := by
|
| 104 |
+
have hm0 : 0 < m := by omega
|
| 105 |
+
apply select_on_nets hm0 (pow_pos hm0 _) (pow_pos hm0 _) V W hV
|
| 106 |
+
(by positivity) (by positivity)
|
| 107 |
+
· simpa only [Nat.cast_pow] using projection_failure_bound (show 2 ≤ m by omega)
|
| 108 |
+
(show 0 ≤ Real.log m by linarith)
|
| 109 |
+
· exact GaussianNonparallel.charts_pairwise_nonparallel (show 2 ≤ m by omega)
|
| 110 |
+
· simp only [Nat.cast_pow]
|
| 111 |
+
rw [normalized_fourier_exponent hm0, normalized_covariance_exponent m hm0]
|
| 112 |
+
exact (probability_majorization hm (Nat.cast_nonneg _) (Nat.cast_nonneg _) hVc hWc).trans_lt hmajor
|
| 113 |
+
|
| 114 |
+
lemma badCount_le_of_imp {A B : Set (Fin N → E)} (g : Fin S → Fin N → E)
|
| 115 |
+
(h : ∀ s, g s ∈ A → g s ∈ B) : badCount A g ≤ badCount B g := by
|
| 116 |
+
classical
|
| 117 |
+
apply Finset.card_le_card
|
| 118 |
+
intro s hs
|
| 119 |
+
simp only [Finset.mem_filter, Finset.mem_univ, true_and] at hs ⊢
|
| 120 |
+
exact h s hs
|
| 121 |
+
|
| 122 |
+
lemma good_chart_interpolation {N S : ℕ} (g : Fin S → Fin N → E)
|
| 123 |
+
(hg : ∀ s, g s ∉ normBad) {v v' : E} {ρ q q' : ℝ}
|
| 124 |
+
(hd : ‖v-v'‖ ≤ ρ) (hq : q+2*Real.sqrt m*ρ ≤ q') :
|
| 125 |
+
badCount (projectionBad q' v) g ≤ badCount (projectionBad q v') g := by
|
| 126 |
+
apply badCount_le_of_imp g
|
| 127 |
+
intro s hs
|
| 128 |
+
by_contra hn
|
| 129 |
+
obtain ⟨i,hi⟩ := hs
|
| 130 |
+
have hp : |inner ℝ v' (g s i)| ≤ q := by
|
| 131 |
+
by_contra h; exact hn ⟨i,lt_of_not_ge h⟩
|
| 132 |
+
have hgn : ‖g s i‖ ≤ 2*Real.sqrt m := by
|
| 133 |
+
have := (normBounds_of_not_bad (hg s) i).2
|
| 134 |
+
nlinarith [Real.sq_sqrt (Nat.cast_nonneg (α := ℝ) m), Real.sqrt_nonneg (m : ℝ), norm_nonneg (g s i)]
|
| 135 |
+
have hh := (projection_interpolate hgn (by positivity) hd hp).trans hq
|
| 136 |
+
exact not_lt_of_ge hh hi
|
| 137 |
+
|
| 138 |
+
structure Family (m : ℕ) where
|
| 139 |
+
g : Fin (m^3) → Fin (m^6) → EuclideanSpace ℝ (Fin m)
|
| 140 |
+
norms : ∀ s i, Real.sqrt m/2 ≤ ‖g s i‖ ∧ ‖g s i‖ ≤ 2*Real.sqrt m
|
| 141 |
+
nonparallel : ∀ s a b, a ≠ b → ∀ t : ℝ, g s a ≠ t • g s b
|
| 142 |
+
covariance : ∀ s v, ‖v‖ = 1 → 1/2 ≤ empiricalCov (g s) v ∧ empiricalCov (g s) v ≤ 2
|
| 143 |
+
fourier : ∀ s w, ‖w‖ ≤ (m : ℝ)^42 →
|
| 144 |
+
‖empiricalSin (g s) w - Real.exp (-‖w‖^2/2) • w‖ ≤ 2/Real.sqrt m
|
| 145 |
+
good : ∀ v, ‖v‖ = 1 →
|
| 146 |
+
(badCount (projectionBad (11*Real.sqrt (Real.log m)) v) g : ℝ) ≤ ((m^3 : ℕ) : ℝ)/2
|
| 147 |
+
|
| 148 |
+
lemma family_at_large (hm : 1000000 ≤ m) (hlog : 1 ≤ Real.log m)
|
| 149 |
+
(hbias : 16*Real.exp (-(m : ℝ)/12) ≤ 1/(8*(m : ℝ)))
|
| 150 |
+
(hmajor : 2*(m : ℝ)^9*Real.exp (-(m : ℝ)/8) +
|
| 151 |
+
6*(m : ℝ)^3*Real.exp (-(m : ℝ)) < 1) : Nonempty (Family m) := by
|
| 152 |
+
classical
|
| 153 |
+
obtain ⟨V,W,hV,hVc,hWc,hVnet,hWnet⟩ := source_nets (show 2 ≤ m by omega)
|
| 154 |
+
obtain ⟨g,hpar,hg,hfour,hcov,hgood⟩ := select_source_nets hm hlog hmajor V W hV hVc hWc
|
| 155 |
+
have hm0 : 0 < m := by omega
|
| 156 |
+
have hm0' : (0 : ℝ) < m := by exact_mod_cast hm0
|
| 157 |
+
have hn : 0 < m^6 := pow_pos hm0 _
|
| 158 |
+
have hu (s : Fin (m^3)) (i : Fin (m^6)) : ‖g s i‖^2 ≤ 4*(m : ℝ) :=
|
| 159 |
+
(normBounds_of_not_bad (hg s) i).2
|
| 160 |
+
refine ⟨{ g := g, norms := ?_, nonparallel := hpar, covariance := ?_, fourier := ?_, good := ?_ }⟩
|
| 161 |
+
· intro s i
|
| 162 |
+
have h := normBounds_of_not_bad (hg s) i
|
| 163 |
+
have hs := Real.sq_sqrt hm0'.le
|
| 164 |
+
constructor <;> nlinarith [Real.sqrt_nonneg (m : ℝ), norm_nonneg (g s i)]
|
| 165 |
+
· intro s v hv
|
| 166 |
+
have hh := covariance_net_bound hn (g s) (hu s) (by positivity) V hV hVnet
|
| 167 |
+
(fun v hv => net_covariance_scalar (hg s) v (hV v hv) (hcov s v hv)) v hv
|
| 168 |
+
have herr := covariance_net_error (show 1000 ≤ m by omega) hbias
|
| 169 |
+
have heq : 2*(4*(m : ℝ))*(1/(m : ℝ)^3) = 8*(m : ℝ)*(1/(m : ℝ)^3) := by ring
|
| 170 |
+
rw [heq] at hh
|
| 171 |
+
have hab := abs_le.mp (hh.trans herr)
|
| 172 |
+
constructor <;> linarith
|
| 173 |
+
· intro s w hw
|
| 174 |
+
have hρ : 1/(m : ℝ)^3 < 1 := by
|
| 175 |
+
apply (div_lt_one (by positivity)).mpr
|
| 176 |
+
have hx : (2 : ℝ) ≤ m := by exact_mod_cast (show 2 ≤ m by omega)
|
| 177 |
+
have hh := pow_le_pow_left₀ (by norm_num : (0 : ℝ) ≤ 2) hx 3
|
| 178 |
+
norm_num at hh; linarith
|
| 179 |
+
have hh := fourier_net_bound hn (g s) (hu s) (by positivity) (by positivity) hρ V W
|
| 180 |
+
hVnet hWnet (fun v hv w hw => net_fourier_scalar hm0 (hg s) v w (hV v hv) (hfour s v hv w hw)) w hw
|
| 181 |
+
have herr := scalar_net_error (show 1000 ≤ m by omega) hbias
|
| 182 |
+
have heq : 4*(m : ℝ)+(m : ℝ) = 5*(m : ℝ) := by ring
|
| 183 |
+
rw [heq] at hh
|
| 184 |
+
exact hh.trans herr
|
| 185 |
+
· intro v hv
|
| 186 |
+
obtain ⟨v',hv',hd⟩ := hVnet v hv
|
| 187 |
+
have hh := good_chart_interpolation g hg hd (projection_net_error (show 1000 ≤ m by omega) hlog)
|
| 188 |
+
exact (Nat.cast_le.mpr hh).trans (hgood v' hv')
|
| 189 |
+
|
| 190 |
+
theorem directions_exist : ∀ᶠ m : ℕ in atTop, Nonempty (Family m) := by
|
| 191 |
+
have hlog : ∀ᶠ m : ℕ in atTop, 1 ≤ Real.log m :=
|
| 192 |
+
(Real.tendsto_log_atTop.comp tendsto_natCast_atTop_atTop).eventually (eventually_ge_atTop 1)
|
| 193 |
+
filter_upwards [eventually_ge_atTop 1000000, hlog, eventual_bias_bound,
|
| 194 |
+
eventual_selection_majorant] with m hm hl hb hp
|
| 195 |
+
exact family_at_large hm hl hb.2 hp
|
| 196 |
+
|
| 197 |
+
end UniformSparsestCut.DirectionFamily
|
| 198 |
+
|
| 199 |
+
end
|
| 200 |
+
|
| 201 |
+
end OAI
|
lean/OAI/Combinatorics/SparsestCut/DirectionInterpolation.lean
ADDED
|
@@ -0,0 +1,152 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import OAI.Combinatorics.SparsestCut.GaussianNonparallel
|
| 2 |
+
|
| 3 |
+
namespace OAI
|
| 4 |
+
|
| 5 |
+
open scoped BigOperators Topology NNReal RealInnerProductSpace InnerProductSpace Matrix ContDiff ENNReal
|
| 6 |
+
open MeasureTheory ProbabilityTheory Set Filter Matrix
|
| 7 |
+
|
| 8 |
+
noncomputable section
|
| 9 |
+
|
| 10 |
+
namespace UniformSparsestCut.DirectionInterpolation
|
| 11 |
+
open GaussianTools FiniteNets MeasureTheory ProbabilityTheory
|
| 12 |
+
open scoped BigOperators Topology
|
| 13 |
+
|
| 14 |
+
variable {m N : ℕ}
|
| 15 |
+
local notation "E" => EuclideanSpace ℝ (Fin m)
|
| 16 |
+
noncomputable def empiricalSin (g : Fin N → E) (w : E) : E :=
|
| 17 |
+
(N : ℝ)⁻¹ • ∑ i, Real.sin (inner ℝ (g i) w) • g i
|
| 18 |
+
noncomputable def empiricalCov (g : Fin N → E) (v : E) : ℝ :=
|
| 19 |
+
(∑ i, (inner ℝ v (g i))^2)/(N : ℝ)
|
| 20 |
+
|
| 21 |
+
lemma sin_vector_lipschitz (g w w' : E) :
|
| 22 |
+
‖Real.sin (inner ℝ g w) • g - Real.sin (inner ℝ g w') • g‖ ≤
|
| 23 |
+
‖g‖^2 * ‖w-w'‖ := by
|
| 24 |
+
rw [← sub_smul, norm_smul, Real.norm_eq_abs]
|
| 25 |
+
have hs : |Real.sin (inner ℝ g w) - Real.sin (inner ℝ g w')| ≤
|
| 26 |
+
|inner ℝ g (w-w')| := by
|
| 27 |
+
simpa only [Real.dist_eq, dist_eq_norm, Real.norm_eq_abs, inner_sub_right, NNReal.coe_one, one_mul] using
|
| 28 |
+
Real.lipschitzWith_sin.dist_le_mul (inner ℝ g w) (inner ℝ g w')
|
| 29 |
+
calc
|
| 30 |
+
_ ≤ |inner ℝ g (w-w')| * ‖g‖ := mul_le_mul_of_nonneg_right hs (norm_nonneg _)
|
| 31 |
+
_ ≤ (‖g‖*‖w-w'‖)*‖g‖ := mul_le_mul_of_nonneg_right (abs_real_inner_le_norm _ _) (norm_nonneg _)
|
| 32 |
+
_ = _ := by ring
|
| 33 |
+
|
| 34 |
+
lemma empiricalSin_lipschitz (hN : 0 < N) (g : Fin N → E) {B : ℝ}
|
| 35 |
+
(hB : ∀ i, ‖g i‖^2 ≤ B) (w w' : E) :
|
| 36 |
+
‖empiricalSin g w - empiricalSin g w'‖ ≤ B*‖w-w'‖ := by
|
| 37 |
+
have hn : (0 : ℝ) < N := by exact_mod_cast hN
|
| 38 |
+
rw [empiricalSin, empiricalSin, ← smul_sub, ← Finset.sum_sub_distrib, norm_smul,
|
| 39 |
+
Real.norm_eq_abs, abs_of_pos (inv_pos.mpr hn)]
|
| 40 |
+
calc
|
| 41 |
+
_ ≤ (N : ℝ)⁻¹ * ∑ i, ‖Real.sin (inner ℝ (g i) w) • g i -
|
| 42 |
+
Real.sin (inner ℝ (g i) w') • g i‖ :=
|
| 43 |
+
mul_le_mul_of_nonneg_left (norm_sum_le _ _) (inv_nonneg.mpr hn.le)
|
| 44 |
+
_ ≤ (N : ℝ)⁻¹ * ∑ _ : Fin N, B * ‖w-w'‖ := by
|
| 45 |
+
gcongr with i
|
| 46 |
+
exact (sin_vector_lipschitz _ _ _).trans (mul_le_mul_of_nonneg_right (hB i) (norm_nonneg _))
|
| 47 |
+
_ = _ := by simp [hn.ne']
|
| 48 |
+
|
| 49 |
+
lemma gaussian_norm_sq_mean : (∫ g : E, ‖g‖^2 ∂stdGaussian E) = m := by
|
| 50 |
+
have hid (g : E) : ‖g‖^2 = ∑ i : Fin m, (inner ℝ (EuclideanSpace.single i 1) g)^2 := by
|
| 51 |
+
simp only [EuclideanSpace.norm_sq_eq, EuclideanSpace.inner_single_left, conj_trivial, one_mul,
|
| 52 |
+
Real.norm_eq_abs, sq_abs]
|
| 53 |
+
simp_rw [hid]
|
| 54 |
+
rw [integral_finsetSum _ (fun i _ => inner_sq_integrable _)]
|
| 55 |
+
simp_rw [gaussian_inner_sq]
|
| 56 |
+
simp
|
| 57 |
+
|
| 58 |
+
lemma gaussianTransform_lipschitz (w w' : E) :
|
| 59 |
+
‖Real.exp (-‖w‖^2/2) • w - Real.exp (-‖w'‖^2/2) • w'‖ ≤ (m : ℝ)*‖w-w'‖ := by
|
| 60 |
+
rw [← gaussian_vector_sin w, ← gaussian_vector_sin w',
|
| 61 |
+
← integral_sub (gaussian_vector_sin_integrable w) (gaussian_vector_sin_integrable w')]
|
| 62 |
+
calc
|
| 63 |
+
_ ≤ ∫ g : E, ‖Real.sin (inner ℝ g w) • g - Real.sin (inner ℝ g w') • g‖ ∂stdGaussian E :=
|
| 64 |
+
norm_integral_le_integral_norm _
|
| 65 |
+
_ ≤ ∫ g : E, ‖g‖^2 * ‖w-w'‖ ∂stdGaussian E := by
|
| 66 |
+
apply integral_mono ((gaussian_vector_sin_integrable w).sub (gaussian_vector_sin_integrable w')).norm
|
| 67 |
+
(gaussian_norm_sq_integrable.mul_const ‖w-w'‖)
|
| 68 |
+
exact fun g => sin_vector_lipschitz g w w'
|
| 69 |
+
_ = _ := by rw [integral_mul_const, gaussian_norm_sq_mean]
|
| 70 |
+
|
| 71 |
+
lemma covariance_lipschitz (hN : 0 < N) (g : Fin N → E) {B : ℝ}
|
| 72 |
+
(hg : ∀ i, ‖g i‖^2 ≤ B) {v v' : E} (hv : ‖v‖ = 1) (hv' : ‖v'‖ = 1) :
|
| 73 |
+
|empiricalCov g v - empiricalCov g v'| ≤ 2*B*‖v-v'‖ := by
|
| 74 |
+
have hn : (0 : ℝ) < N := by exact_mod_cast hN
|
| 75 |
+
have hterm (i : Fin N) : |(inner ℝ v (g i))^2 - (inner ℝ v' (g i))^2| ≤
|
| 76 |
+
2*B*‖v-v'‖ := by
|
| 77 |
+
rw [sq_sub_sq, abs_mul, mul_comm]
|
| 78 |
+
have ha : |inner ℝ v (g i)| ≤ ‖g i‖ := by simpa [hv] using abs_real_inner_le_norm v (g i)
|
| 79 |
+
have hb : |inner ℝ v' (g i)| ≤ ‖g i‖ := by simpa [hv'] using abs_real_inner_le_norm v' (g i)
|
| 80 |
+
have hd : |inner ℝ v (g i) - inner ℝ v' (g i)| ≤ ‖v-v'‖*‖g i‖ := by
|
| 81 |
+
simpa only [inner_sub_left] using abs_real_inner_le_norm (v-v') (g i)
|
| 82 |
+
calc
|
| 83 |
+
_ ≤ (‖v-v'‖*‖g i‖)*(2*‖g i‖) :=
|
| 84 |
+
mul_le_mul hd ((abs_add_le _ _).trans (by linarith)) (abs_nonneg _) (by positivity)
|
| 85 |
+
_ = 2*‖g i‖^2*‖v-v'‖ := by ring
|
| 86 |
+
_ ≤ 2*B*‖v-v'‖ := by gcongr; exact hg i
|
| 87 |
+
rw [empiricalCov, empiricalCov, ← sub_div, abs_div, abs_of_pos hn, ← Finset.sum_sub_distrib]
|
| 88 |
+
apply (div_le_iff₀ hn).mpr
|
| 89 |
+
calc
|
| 90 |
+
_ ≤ ∑ i : Fin N, |(inner ℝ v (g i))^2 - (inner ℝ v' (g i))^2| := Finset.abs_sum_le_sum_abs _ _
|
| 91 |
+
_ ≤ ∑ _ : Fin N, 2*B*‖v-v'‖ := Finset.sum_le_sum (fun i _ => hterm i)
|
| 92 |
+
_ = _ := by simp [mul_comm]
|
| 93 |
+
|
| 94 |
+
lemma covariance_net_bound (hN : 0 < N) (g : Fin N → E) {B b ρ : ℝ}
|
| 95 |
+
(hg : ∀ i, ‖g i‖^2 ≤ B) (hB : 0 ≤ B) (V : Finset E)
|
| 96 |
+
(hV : ∀ v ∈ V, ‖v‖ = 1)
|
| 97 |
+
(hnet : ∀ x : E, ‖x‖ = 1 → ∃ v ∈ V, ‖x-v‖ ≤ ρ)
|
| 98 |
+
(hdev : ∀ v ∈ V, |empiricalCov g v - 1| ≤ b)
|
| 99 |
+
(x : E) (hx : ‖x‖ = 1) : |empiricalCov g x - 1| ≤ b + 2*B*ρ := by
|
| 100 |
+
obtain ⟨v,hv,hd⟩ := hnet x hx
|
| 101 |
+
calc
|
| 102 |
+
_ ≤ |empiricalCov g x - empiricalCov g v| + |empiricalCov g v - 1| := abs_sub_le _ _ _
|
| 103 |
+
_ ≤ 2*B*‖x-v‖ + b := add_le_add (covariance_lipschitz hN g hg hx (hV v hv)) (hdev v hv)
|
| 104 |
+
_ ≤ b + 2*B*ρ := by nlinarith
|
| 105 |
+
|
| 106 |
+
lemma fourier_net_bound (hN : 0 < N) (g : Fin N → E) {B b ρ δ R : ℝ}
|
| 107 |
+
(hg : ∀ i, ‖g i‖^2 ≤ B) (hB : 0 ≤ B) (hb : 0 ≤ b) (hρ : ρ < 1)
|
| 108 |
+
(V W : Finset E)
|
| 109 |
+
(hV : ∀ x : E, ‖x‖ = 1 → ∃ v ∈ V, ‖x-v‖ ≤ ρ)
|
| 110 |
+
(hW : ∀ w : E, ‖w‖ ≤ R → ∃ w' ∈ W, ‖w-w'‖ ≤ δ)
|
| 111 |
+
(hdev : ∀ v ∈ V, ∀ w ∈ W,
|
| 112 |
+
|inner ℝ (empiricalSin g w - Real.exp (-‖w‖^2/2) • w) v| ≤ b)
|
| 113 |
+
(w : E) (hw : ‖w‖ ≤ R) :
|
| 114 |
+
‖empiricalSin g w - Real.exp (-‖w‖^2/2) • w‖ ≤ b/(1-ρ) + (B+(m : ℝ))*δ := by
|
| 115 |
+
obtain ⟨w',hw',hd⟩ := hW w hw
|
| 116 |
+
have hn : ‖empiricalSin g w' - Real.exp (-‖w'‖^2/2) • w'‖ ≤ b/(1-ρ) := by
|
| 117 |
+
apply (le_div_iff₀ (by linarith : 0 < 1-ρ)).mpr
|
| 118 |
+
nlinarith [sphere_net_norm_bound hV (fun v hv => hdev v hv w' hw') hb]
|
| 119 |
+
calc
|
| 120 |
+
_ ≤ ‖empiricalSin g w - empiricalSin g w'‖ +
|
| 121 |
+
‖empiricalSin g w' - Real.exp (-‖w'‖^2/2) • w'‖ +
|
| 122 |
+
‖Real.exp (-‖w'‖^2/2) • w' - Real.exp (-‖w‖^2/2) • w‖ :=
|
| 123 |
+
by
|
| 124 |
+
have hid : empiricalSin g w - Real.exp (-‖w‖^2/2) • w =
|
| 125 |
+
(empiricalSin g w - empiricalSin g w') +
|
| 126 |
+
(empiricalSin g w' - Real.exp (-‖w'‖^2/2) • w') +
|
| 127 |
+
(Real.exp (-‖w'‖^2/2) • w' - Real.exp (-‖w‖^2/2) • w) := by abel
|
| 128 |
+
rw [hid]
|
| 129 |
+
exact (norm_add_le _ _).trans (add_le_add (norm_add_le _ _) (le_refl _))
|
| 130 |
+
_ ≤ B*‖w-w'‖ + b/(1-ρ) + (m : ℝ)*‖w-w'‖ := by
|
| 131 |
+
apply add_le_add (add_le_add (empiricalSin_lipschitz hN g hg w w') hn)
|
| 132 |
+
simpa only [norm_sub_rev] using gaussianTransform_lipschitz w' w
|
| 133 |
+
_ ≤ b/(1-ρ) + (B+(m : ℝ))*δ := by
|
| 134 |
+
have hm : (0 : ℝ) ≤ m := Nat.cast_nonneg m
|
| 135 |
+
nlinarith
|
| 136 |
+
|
| 137 |
+
lemma projection_interpolate {g v v' : E} {q K ρ : ℝ}
|
| 138 |
+
(hg : ‖g‖ ≤ K) (_hK : 0 ≤ K) (hd : ‖v-v'‖ ≤ ρ)
|
| 139 |
+
(hp : |inner ℝ v' g| ≤ q) : |inner ℝ v g| ≤ q + K*ρ := by
|
| 140 |
+
have hi : inner ℝ v g = inner ℝ v' g + inner ℝ (v-v') g := by rw [inner_sub_left]; ring
|
| 141 |
+
calc
|
| 142 |
+
_ ≤ |inner ℝ v' g| + |inner ℝ (v-v') g| := by rw [hi]; exact abs_add_le _ _
|
| 143 |
+
_ ≤ q + ‖v-v'‖*‖g‖ := add_le_add hp (abs_real_inner_le_norm _ _)
|
| 144 |
+
_ ≤ q + K*ρ := by
|
| 145 |
+
have hρ : 0 ≤ ρ := (norm_nonneg _).trans hd
|
| 146 |
+
nlinarith [mul_le_mul hd hg (norm_nonneg _) hρ]
|
| 147 |
+
|
| 148 |
+
end UniformSparsestCut.DirectionInterpolation
|
| 149 |
+
|
| 150 |
+
end
|
| 151 |
+
|
| 152 |
+
end OAI
|
lean/OAI/Combinatorics/SparsestCut/Directions.lean
ADDED
|
@@ -0,0 +1,291 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import OAI.Combinatorics.SparsestCut.FiniteNets
|
| 2 |
+
|
| 3 |
+
namespace OAI
|
| 4 |
+
|
| 5 |
+
universe u1 u2 u3 u4 u5
|
| 6 |
+
|
| 7 |
+
open scoped BigOperators Topology NNReal RealInnerProductSpace InnerProductSpace Matrix ContDiff ENNReal
|
| 8 |
+
open MeasureTheory ProbabilityTheory Set Filter Matrix
|
| 9 |
+
|
| 10 |
+
noncomputable section
|
| 11 |
+
|
| 12 |
+
namespace UniformSparsestCut.Directions
|
| 13 |
+
open GaussianTools FiniteNets MeasureTheory ProbabilityTheory Set Filter
|
| 14 |
+
open scoped BigOperators NNReal Topology
|
| 15 |
+
|
| 16 |
+
section ProductMeasures
|
| 17 |
+
variable {E : Type u1} [MeasurableSpace E] {μ : Measure E} [IsProbabilityMeasure μ]
|
| 18 |
+
|
| 19 |
+
lemma integral_eval {n : ℕ} {f : E → ℝ} (hf : Measurable f) (i : Fin n) :
|
| 20 |
+
(∫ x : Fin n → E, f (x i) ∂Measure.pi (fun _ => μ)) = ∫ x, f x ∂μ := by
|
| 21 |
+
have hp := measurePreserving_eval (fun _ : Fin n => μ) i
|
| 22 |
+
have hh := integral_map hp.aemeasurable (hf.aestronglyMeasurable :
|
| 23 |
+
AEStronglyMeasurable f ((Measure.pi (fun _ : Fin n => μ)).map (Function.eval i)))
|
| 24 |
+
rw [hp.map_eq] at hh
|
| 25 |
+
exact hh.symm
|
| 26 |
+
|
| 27 |
+
lemma real_measure_eval {n : ℕ} {A : Set E} (hA : MeasurableSet A) (i : Fin n) :
|
| 28 |
+
(Measure.pi (fun _ : Fin n => μ)).real {x | x i ∈ A} = μ.real A := by
|
| 29 |
+
have hp := (measurePreserving_eval (fun _ : Fin n => μ) i).measure_preimage hA.nullMeasurableSet
|
| 30 |
+
exact congrArg ENNReal.toReal hp
|
| 31 |
+
|
| 32 |
+
lemma iid_bounded_concentration {n : ℕ} (hn : 0 < n) {f : E → ℝ}
|
| 33 |
+
(hf : Measurable f) {B : ℝ} (hB : 0 < B) (hfB : ∀ x, |f x| ≤ B)
|
| 34 |
+
{u : ℝ} (hu : 0 ≤ u) :
|
| 35 |
+
(Measure.pi (fun _ : Fin n => μ)).real
|
| 36 |
+
{x | u < |(∑ i, f (x i)) / (n : ℝ) - ∫ z, f z ∂μ|} ≤
|
| 37 |
+
2 * Real.exp (-(n : ℝ)*u^2/(2*B^2)) := by
|
| 38 |
+
have h := bounded_concentration hn (fun i (x : Fin n → E) => f (x i))
|
| 39 |
+
(fun i => (hf.comp (measurable_pi_apply i)).aemeasurable)
|
| 40 |
+
(iIndepFun_pi (μ := fun _ : Fin n => μ) (fun _ => hf.aemeasurable)) hB
|
| 41 |
+
(fun i => ae_of_all _ (fun x => hfB (x i))) hu
|
| 42 |
+
have hn0 : (n : ℝ) ≠ 0 := by exact_mod_cast hn.ne'
|
| 43 |
+
have heq (x : Fin n → E) :
|
| 44 |
+
(∑ i, (f (x i) - ∫ z : Fin n → E, f (z i) ∂Measure.pi (fun _ => μ))) / (n : ℝ) =
|
| 45 |
+
(∑ i, f (x i)) / (n : ℝ) - ∫ z, f z ∂μ := by
|
| 46 |
+
simp_rw [integral_eval hf]
|
| 47 |
+
rw [Finset.sum_sub_distrib]
|
| 48 |
+
simp only [Finset.sum_const, Finset.card_univ, Fintype.card_fin, nsmul_eq_mul]
|
| 49 |
+
field_simp
|
| 50 |
+
simpa only [heq] using h
|
| 51 |
+
|
| 52 |
+
lemma real_measure_exists_le {n : ℕ} (A : Fin n → Set E) (hA : ∀ i, MeasurableSet (A i))
|
| 53 |
+
{p : ℝ} (hp : ∀ i, μ.real (A i) ≤ p) :
|
| 54 |
+
(Measure.pi (fun _ : Fin n => μ)).real {x | ∃ i, x i ∈ A i} ≤ (n : ℝ)*p := by
|
| 55 |
+
calc
|
| 56 |
+
_ = (Measure.pi (fun _ : Fin n => μ)).real (⋃ i : Fin n, {x | x i ∈ A i}) := by
|
| 57 |
+
congr 1; ext x; simp
|
| 58 |
+
_ ≤ ∑ i : Fin n, (Measure.pi (fun _ : Fin n => μ)).real {x | x i ∈ A i} :=
|
| 59 |
+
measureReal_iUnion_fintype_le _
|
| 60 |
+
_ = ∑ i : Fin n, μ.real (A i) := by simp_rw [real_measure_eval (hA _)]
|
| 61 |
+
_ ≤ ∑ _ : Fin n, p := Finset.sum_le_sum (fun i _ => hp i)
|
| 62 |
+
_ = _ := by simp
|
| 63 |
+
|
| 64 |
+
noncomputable def badCount {S : ℕ} (A : Set E) (x : Fin S → E) : ℕ := by
|
| 65 |
+
classical
|
| 66 |
+
exact (Finset.univ.filter (fun s => x s ∈ A)).card
|
| 67 |
+
|
| 68 |
+
lemma bad_chart_fraction {S : ℕ} (hS : 0 < S) {A : Set E} (hA : MeasurableSet A)
|
| 69 |
+
(hp : μ.real A ≤ 1/4) :
|
| 70 |
+
(Measure.pi (fun _ : Fin S => μ)).real
|
| 71 |
+
{x | (S : ℝ)/2 < (badCount A x : ℝ)} ≤
|
| 72 |
+
2 * Real.exp (-(S : ℝ)/32) := by
|
| 73 |
+
classical
|
| 74 |
+
let f : E → ℝ := A.indicator (fun _ => 1)
|
| 75 |
+
have hf : Measurable f := measurable_const.indicator hA
|
| 76 |
+
have hbound (x : E) : |f x| ≤ 1 := by
|
| 77 |
+
by_cases hx : x ∈ A <;> simp [f, hx]
|
| 78 |
+
have hmean : (∫ x, f x ∂μ) = μ.real A := integral_indicator_one hA
|
| 79 |
+
have h := iid_bounded_concentration (μ := μ) hS hf (by norm_num : (0 : ℝ) < 1) hbound
|
| 80 |
+
(u := 1/4) (by norm_num)
|
| 81 |
+
have hcount (x : Fin S → E) : (∑ s : Fin S, f (x s)) =
|
| 82 |
+
(badCount A x : ℝ) := by
|
| 83 |
+
dsimp [badCount]
|
| 84 |
+
simp only [f, Set.indicator]
|
| 85 |
+
rw [← Finset.sum_filter]
|
| 86 |
+
simp
|
| 87 |
+
have hspos : (0 : ℝ) < S := by exact_mod_cast hS
|
| 88 |
+
have hsub : {x : Fin S → E | (S : ℝ)/2 < (badCount A x : ℝ)} ⊆
|
| 89 |
+
{x | (1/4 : ℝ) < |(∑ s, f (x s))/(S : ℝ) - ∫ z, f z ∂μ|} := by
|
| 90 |
+
intro x hx
|
| 91 |
+
change (S : ℝ)/2 < (badCount A x : ℝ) at hx
|
| 92 |
+
change (1/4 : ℝ) < |(∑ s, f (x s))/(S : ℝ) - ∫ z, f z ∂μ|
|
| 93 |
+
rw [hcount, hmean]
|
| 94 |
+
apply (lt_abs.mpr (Or.inl ?_))
|
| 95 |
+
have hh : (1/2 : ℝ) < (badCount A x : ℝ)/(S : ℝ) :=
|
| 96 |
+
(lt_div_iff₀ hspos).mpr (by linarith)
|
| 97 |
+
linarith
|
| 98 |
+
calc
|
| 99 |
+
_ ≤ _ := measureReal_mono hsub
|
| 100 |
+
_ ≤ 2 * Real.exp (-(S : ℝ) * (1/4)^2 / (2*1^2)) := h
|
| 101 |
+
_ = _ := by congr 2; ring
|
| 102 |
+
|
| 103 |
+
lemma exists_outside_of_real_lt_one {Ω : Type u2} [MeasurableSpace Ω]
|
| 104 |
+
{ν : Measure Ω} [IsProbabilityMeasure ν] {A : Set Ω} (hA : (ν).real A < 1) :
|
| 105 |
+
∃ x, x ∉ A := by
|
| 106 |
+
by_contra h
|
| 107 |
+
push Not at h
|
| 108 |
+
have heq : A = Set.univ := Set.eq_univ_of_forall h
|
| 109 |
+
simp [heq, measureReal_def] at hA
|
| 110 |
+
|
| 111 |
+
lemma exists_outside_with_ae {Ω : Type u3} [MeasurableSpace Ω]
|
| 112 |
+
{ν : Measure Ω} [IsProbabilityMeasure ν] {A : Set Ω} (hA : (ν).real A < 1)
|
| 113 |
+
{P : Ω → Prop} (hP : ∀ᵐ x ∂ν, P x) : ∃ x, x ∉ A ∧ P x := by
|
| 114 |
+
have hnull : (ν).real {x | ¬ P x} = 0 := by
|
| 115 |
+
rw [measureReal_def, ae_iff.mp hP, ENNReal.toReal_zero]
|
| 116 |
+
have hlt : (ν).real (A ∪ {x | ¬ P x}) < 1 :=
|
| 117 |
+
((measureReal_union_le _ _).trans_eq (by rw [hnull, add_zero])).trans_lt hA
|
| 118 |
+
obtain ⟨x,hx⟩ := exists_outside_of_real_lt_one hlt
|
| 119 |
+
exact ⟨x, fun ha => hx (Or.inl ha), by_contra (fun hn => hx (Or.inr hn))⟩
|
| 120 |
+
|
| 121 |
+
end ProductMeasures
|
| 122 |
+
|
| 123 |
+
lemma finite_union_bound {Ω : Type u4} {I : Type u5} [MeasurableSpace Ω] [Fintype I]
|
| 124 |
+
{ν : Measure Ω} [IsProbabilityMeasure ν] (A : I → Set Ω) {p : ℝ}
|
| 125 |
+
(hA : ∀ i, (ν).real (A i) ≤ p) :
|
| 126 |
+
(ν).real {x | ∃ i, x ∈ A i} ≤ (Fintype.card I : ℝ)*p := by
|
| 127 |
+
calc
|
| 128 |
+
_ = (ν).real (⋃ i, A i) := by congr 1; ext; simp
|
| 129 |
+
_ ≤ ∑ i, (ν).real (A i) := measureReal_iUnion_fintype_le _
|
| 130 |
+
_ ≤ ∑ _ : I, p := Finset.sum_le_sum (fun i _ => hA i)
|
| 131 |
+
_ = _ := by simp
|
| 132 |
+
|
| 133 |
+
section GaussianSelection
|
| 134 |
+
variable {m N S : ℕ}
|
| 135 |
+
local notation "E" => EuclideanSpace ℝ (Fin m)
|
| 136 |
+
local notation "μ" => stdGaussian E
|
| 137 |
+
local notation "ν" => Measure.pi (fun _ : Fin N => μ)
|
| 138 |
+
local notation "π" => Measure.pi (fun _ : Fin S => ν)
|
| 139 |
+
|
| 140 |
+
noncomputable def fourierSummand (v w : E) : E → ℝ :=
|
| 141 |
+
truncate m (fun g => inner ℝ g v * Real.sin (inner ℝ g w))
|
| 142 |
+
noncomputable def covarianceSummand (v : E) : E → ℝ :=
|
| 143 |
+
truncate m (fun g => (inner ℝ v g)^2)
|
| 144 |
+
|
| 145 |
+
def normBad : Set (Fin N → E) :=
|
| 146 |
+
{x | ∃ i, ‖x i‖^2 < (m : ℝ)/4 ∨ 4*(m : ℝ) < ‖x i‖^2}
|
| 147 |
+
noncomputable def fourierBad (u : ℝ) (v w : E) : Set (Fin N → E) :=
|
| 148 |
+
{x | u < |(∑ i, fourierSummand v w (x i))/(N : ℝ) - ∫ g, fourierSummand v w g ∂μ|}
|
| 149 |
+
noncomputable def covarianceBad (v : E) : Set (Fin N → E) :=
|
| 150 |
+
{x | (1/8 : ℝ) < |(∑ i, covarianceSummand v (x i))/(N : ℝ) - ∫ g, covarianceSummand v g ∂μ|}
|
| 151 |
+
def projectionBad (q : ℝ) (v : E) : Set (Fin N → E) :=
|
| 152 |
+
{x | ∃ i, q < |inner ℝ v (x i)|}
|
| 153 |
+
|
| 154 |
+
lemma fourierSummand_measurable (v w : E) : Measurable (fourierSummand v w) :=
|
| 155 |
+
(by fun_prop : Measurable (fun g : E => inner ℝ g v * Real.sin (inner ℝ g w))).indicator
|
| 156 |
+
measurable_truncation_set
|
| 157 |
+
lemma covarianceSummand_measurable (v : E) : Measurable (covarianceSummand v) :=
|
| 158 |
+
(by fun_prop : Measurable (fun g : E => (inner ℝ v g)^2)).indicator measurable_truncation_set
|
| 159 |
+
lemma normBad_measurable : MeasurableSet (normBad (m := m) (N := N)) := by
|
| 160 |
+
unfold normBad; measurability
|
| 161 |
+
lemma fourierBad_measurable (u : ℝ) (v w : E) : MeasurableSet (fourierBad (N := N) u v w) := by
|
| 162 |
+
unfold fourierBad
|
| 163 |
+
have hf (i : Fin N) : Measurable (fun x : Fin N → E => fourierSummand v w (x i)) :=
|
| 164 |
+
(fourierSummand_measurable v w).comp (measurable_pi_apply i)
|
| 165 |
+
measurability
|
| 166 |
+
lemma covarianceBad_measurable (v : E) : MeasurableSet (covarianceBad (N := N) v) := by
|
| 167 |
+
unfold covarianceBad
|
| 168 |
+
have hf (i : Fin N) : Measurable (fun x : Fin N → E => covarianceSummand v (x i)) :=
|
| 169 |
+
(covarianceSummand_measurable v).comp (measurable_pi_apply i)
|
| 170 |
+
measurability
|
| 171 |
+
lemma projectionBad_measurable (q : ℝ) (v : E) : MeasurableSet (projectionBad (N := N) q v) := by
|
| 172 |
+
unfold projectionBad; measurability
|
| 173 |
+
|
| 174 |
+
lemma normBad_bound : (ν).real (normBad (m := m) (N := N)) ≤
|
| 175 |
+
(N : ℝ)* (2*Real.exp (-(m : ℝ)/8)) :=
|
| 176 |
+
real_measure_exists_le (fun _ => {g : E | ‖g‖^2 < (m : ℝ)/4 ∨ 4*(m : ℝ) < ‖g‖^2})
|
| 177 |
+
(fun _ => by measurability) (fun _ => by
|
| 178 |
+
have h := (measureReal_union_le
|
| 179 |
+
{g : E | ‖g‖^2 < (m : ℝ)/4} {g : E | 4*(m : ℝ) < ‖g‖^2}).trans
|
| 180 |
+
(add_le_add (gaussian_norm_lower (n := m)) (gaussian_norm_upper (n := m)))
|
| 181 |
+
have he : Real.exp (-(m : ℝ)/2) ≤ Real.exp (-(m : ℝ)/8) :=
|
| 182 |
+
Real.exp_le_exp.mpr (by have := Nat.cast_nonneg (α := ℝ) m; linarith)
|
| 183 |
+
exact h.trans (by linarith))
|
| 184 |
+
|
| 185 |
+
lemma fourierBad_bound (hm : 0 < m) (hN : 0 < N) {u : ℝ} (hu : 0 ≤ u)
|
| 186 |
+
(v w : E) (hv : ‖v‖ = 1) :
|
| 187 |
+
(ν).real (fourierBad (N := N) u v w) ≤
|
| 188 |
+
2*Real.exp (-(N : ℝ)*u^2/(2*(2*Real.sqrt m)^2)) := by
|
| 189 |
+
exact iid_bounded_concentration hN (fourierSummand_measurable v w)
|
| 190 |
+
(by positivity) (truncate_fourier_bound v w hv) hu
|
| 191 |
+
lemma covarianceBad_bound (hm : 0 < m) (hN : 0 < N) (v : E) (hv : ‖v‖ = 1) :
|
| 192 |
+
(ν).real (covarianceBad (N := N) v) ≤
|
| 193 |
+
2*Real.exp (-(N : ℝ)*(1/8)^2/(2*(4*(m : ℝ))^2)) := by
|
| 194 |
+
exact iid_bounded_concentration hN (covarianceSummand_measurable v)
|
| 195 |
+
(by positivity) (truncate_covariance_bound v hv) (by norm_num)
|
| 196 |
+
lemma projectionBad_bound {q : ℝ} (hq : 0 ≤ q) (v : E) (hv : ‖v‖ = 1) :
|
| 197 |
+
(ν).real (projectionBad (N := N) q v) ≤ (N : ℝ)*(2*Real.exp (-q^2/2)) :=
|
| 198 |
+
real_measure_exists_le (fun _ => {g : E | q < |inner ℝ v g|})
|
| 199 |
+
(fun _ => by measurability) (fun _ => gaussian_inner_tail v hv hq)
|
| 200 |
+
|
| 201 |
+
noncomputable def chartBad (V W : Finset E) (u : ℝ) : Set (Fin N → E) :=
|
| 202 |
+
normBad ∪ {x | ∃ z : V × W, x ∈ fourierBad u z.1 z.2} ∪
|
| 203 |
+
{x | ∃ v : V, x ∈ covarianceBad v}
|
| 204 |
+
|
| 205 |
+
lemma chartBad_measurable (V W : Finset E) (u : ℝ) :
|
| 206 |
+
MeasurableSet (chartBad (N := N) V W u) := by
|
| 207 |
+
classical
|
| 208 |
+
have hFm : MeasurableSet {x : Fin N → E | ∃ z : V × W, x ∈ fourierBad u z.1 z.2} := by
|
| 209 |
+
rw [show {x : Fin N → E | ∃ z : V × W, x ∈ fourierBad u z.1 z.2} =
|
| 210 |
+
⋃ z : V × W, fourierBad (N := N) u z.1 z.2 by ext x; simp]
|
| 211 |
+
exact MeasurableSet.iUnion (fun z : V × W => fourierBad_measurable (m := m) (N := N) u z.1 z.2)
|
| 212 |
+
have hCm : MeasurableSet {x : Fin N → E | ∃ v : V, x ∈ covarianceBad v} := by
|
| 213 |
+
rw [show {x : Fin N → E | ∃ v : V, x ∈ covarianceBad v} =
|
| 214 |
+
⋃ v : V, covarianceBad (N := N) v by ext x; simp]
|
| 215 |
+
exact MeasurableSet.iUnion (fun v : V => covarianceBad_measurable (m := m) (N := N) v)
|
| 216 |
+
exact (normBad_measurable.union hFm).union hCm
|
| 217 |
+
|
| 218 |
+
lemma chartBad_bound (hm : 0 < m) (hN : 0 < N) (V W : Finset E)
|
| 219 |
+
(hV : ∀ v ∈ V, ‖v‖ = 1) {u : ℝ} (hu : 0 ≤ u) :
|
| 220 |
+
(ν).real (chartBad (N := N) V W u) ≤ (N : ℝ)*(2*Real.exp (-(m : ℝ)/8)) +
|
| 221 |
+
(V.card : ℝ)*(W.card : ℝ)*(2*Real.exp (-(N : ℝ)*u^2/(2*(2*Real.sqrt m)^2))) +
|
| 222 |
+
(V.card : ℝ)*(2*Real.exp (-(N : ℝ)*(1/8)^2/(2*(4*(m : ℝ))^2))) := by
|
| 223 |
+
classical
|
| 224 |
+
have h1 := finite_union_bound («ν» := ν) (fun z : V × W => fourierBad u z.1 z.2)
|
| 225 |
+
(fun z => fourierBad_bound hm hN hu z.1 z.2 (hV z.1 z.1.property))
|
| 226 |
+
have h2 := finite_union_bound («ν» := ν) (fun v : V => covarianceBad v)
|
| 227 |
+
(fun v => covarianceBad_bound hm hN v (hV v v.property))
|
| 228 |
+
simp only [Fintype.card_prod, Fintype.card_coe, Nat.cast_mul] at h1 h2
|
| 229 |
+
exact (measureReal_union_le _ _).trans
|
| 230 |
+
(add_le_add ((measureReal_union_le _ _).trans (add_le_add normBad_bound h1)) h2)
|
| 231 |
+
|
| 232 |
+
lemma projection_chart_fraction (hS : 0 < S) (v : E) (hv : ‖v‖ = 1)
|
| 233 |
+
{q : ℝ} (hq : 0 ≤ q) (hqprob : (N : ℝ)*(2*Real.exp (-q^2/2)) ≤ 1/4) :
|
| 234 |
+
(π).real {g | (S : ℝ)/2 < (badCount (projectionBad q v) g : ℝ)} ≤
|
| 235 |
+
2*Real.exp (-(S : ℝ)/32) := by
|
| 236 |
+
have hmeas : MeasurableSet (projectionBad (N := N) q v) := projectionBad_measurable q v
|
| 237 |
+
have hbound : (ν).real (projectionBad (N := N) q v) ≤ 1/4 :=
|
| 238 |
+
(projectionBad_bound hq v hv).trans hqprob
|
| 239 |
+
exact bad_chart_fraction hS hmeas hbound
|
| 240 |
+
|
| 241 |
+
lemma goodBad_bound (hS : 0 < S) (V : Finset E) (hV : ∀ v ∈ V, ‖v‖ = 1)
|
| 242 |
+
{q : ℝ} (hq : 0 ≤ q) (hqprob : (N : ℝ)*(2*Real.exp (-q^2/2)) ≤ 1/4) :
|
| 243 |
+
(π).real {g | ∃ v : V, (S : ℝ)/2 < (badCount (projectionBad q v) g : ℝ)} ≤
|
| 244 |
+
(V.card : ℝ)*(2*Real.exp (-(S : ℝ)/32)) := by
|
| 245 |
+
classical
|
| 246 |
+
have h := finite_union_bound («ν» := π)
|
| 247 |
+
(fun v : V => {g | (S : ℝ)/2 < (badCount (projectionBad q v) g : ℝ)})
|
| 248 |
+
(fun v => projection_chart_fraction hS (v : E) (hV v v.property) hq hqprob)
|
| 249 |
+
simpa only [Fintype.card_coe, Set.mem_ofPred_eq] using h
|
| 250 |
+
|
| 251 |
+
theorem select_on_nets (hm : 0 < m) (hN : 0 < N) (hS : 0 < S)
|
| 252 |
+
(V W : Finset E) (hV : ∀ v ∈ V, ‖v‖ = 1)
|
| 253 |
+
{u q : ℝ} (hu : 0 ≤ u) (hq : 0 ≤ q)
|
| 254 |
+
(hqprob : (N : ℝ)*(2*Real.exp (-q^2/2)) ≤ 1/4)
|
| 255 |
+
{P : (Fin S → Fin N → E) → Prop} (hP : ∀ᵐ g ∂π, P g)
|
| 256 |
+
(hprob : (S : ℝ) * ((N : ℝ)*(2*Real.exp (-(m : ℝ)/8)) +
|
| 257 |
+
(V.card : ℝ)*(W.card : ℝ)*(2*Real.exp (-(N : ℝ)*u^2/(2*(2*Real.sqrt m)^2))) +
|
| 258 |
+
(V.card : ℝ)*(2*Real.exp (-(N : ℝ)*(1/8)^2/(2*(4*(m : ℝ))^2)))) +
|
| 259 |
+
(V.card : ℝ)*(2*Real.exp (-(S : ℝ)/32)) < 1) :
|
| 260 |
+
∃ g : Fin S → Fin N → E, P g ∧
|
| 261 |
+
(∀ s, g s ∉ normBad) ∧
|
| 262 |
+
(∀ s, ∀ v ∈ V, ∀ w ∈ W, g s ∉ fourierBad u v w) ∧
|
| 263 |
+
(∀ s, ∀ v ∈ V, g s ∉ covarianceBad v) ∧
|
| 264 |
+
(∀ v ∈ V, (badCount (projectionBad q v) g : ℝ) ≤ (S : ℝ)/2) := by
|
| 265 |
+
classical
|
| 266 |
+
let A := chartBad (N := N) V W u
|
| 267 |
+
let B : Set (Fin S → Fin N → E) := {g | ∃ s, g s ∈ A}
|
| 268 |
+
let C : Set (Fin S → Fin N → E) :=
|
| 269 |
+
{g | ∃ v : V, (S : ℝ)/2 < (badCount (projectionBad q v) g : ℝ)}
|
| 270 |
+
have hBbound := real_measure_exists_le (fun _ : Fin S => A)
|
| 271 |
+
(fun _ => chartBad_measurable V W u) (fun _ => chartBad_bound hm hN V W hV hu)
|
| 272 |
+
have hCbound := goodBad_bound hS V hV hq hqprob
|
| 273 |
+
have hBC : (π).real (B ∪ C) < 1 :=
|
| 274 |
+
((measureReal_union_le B C).trans (add_le_add hBbound hCbound)).trans_lt hprob
|
| 275 |
+
obtain ⟨g, hg, hgP⟩ := exists_outside_with_ae hBC hP
|
| 276 |
+
have hgB : ∀ s, g s ∉ A := by
|
| 277 |
+
intro s hs; exact hg (Or.inl ⟨s, hs⟩)
|
| 278 |
+
refine ⟨g, hgP, ?_, ?_, ?_, ?_⟩
|
| 279 |
+
· intro s hs; exact hgB s (Or.inl (Or.inl hs))
|
| 280 |
+
· intro s v hv w hw hs; exact hgB s (Or.inl (Or.inr ⟨(⟨v,hv⟩,⟨w,hw⟩), hs⟩))
|
| 281 |
+
· intro s v hv hs; exact hgB s (Or.inr ⟨⟨v,hv⟩, hs⟩)
|
| 282 |
+
· intro v hv; by_contra h
|
| 283 |
+
exact hg (Or.inr ⟨⟨v,hv⟩, lt_of_not_ge h⟩)
|
| 284 |
+
|
| 285 |
+
end GaussianSelection
|
| 286 |
+
|
| 287 |
+
end UniformSparsestCut.Directions
|
| 288 |
+
|
| 289 |
+
end
|
| 290 |
+
|
| 291 |
+
end OAI
|
lean/OAI/Combinatorics/SparsestCut/EuclideanCells.lean
ADDED
|
@@ -0,0 +1,164 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import OAI.Combinatorics.SparsestCut.CoordinateSplit
|
| 2 |
+
|
| 3 |
+
namespace OAI
|
| 4 |
+
|
| 5 |
+
universe u1 u2
|
| 6 |
+
|
| 7 |
+
open scoped BigOperators Topology NNReal RealInnerProductSpace InnerProductSpace Matrix ContDiff ENNReal
|
| 8 |
+
open MeasureTheory ProbabilityTheory Set Filter Matrix
|
| 9 |
+
|
| 10 |
+
noncomputable section
|
| 11 |
+
|
| 12 |
+
namespace UniformSparsestCut.EuclideanCells
|
| 13 |
+
open MeasureTheory Set ProductSlice CellInterface CoordinateSplit
|
| 14 |
+
open scoped BigOperators RealInnerProductSpace
|
| 15 |
+
noncomputable section
|
| 16 |
+
variable {m : ℕ} {I : Type u1} {A : Type u2} [Fintype I] [Fintype A] [DecidableEq I]
|
| 17 |
+
local notation "E" => EuclideanSpace ℝ (Fin (m+1))
|
| 18 |
+
local notation "Z" => EuclideanSpace ℝ (Fin m)
|
| 19 |
+
|
| 20 |
+
def B (u : I → E) : I → Z →L[ℝ] ℝ := fun i => slope (u i)
|
| 21 |
+
def pivot (u : I → E) (i : I) : ℝ := u i 0
|
| 22 |
+
|
| 23 |
+
def values (u : I → E) (τ : ℝ) (s : Finset ℤ) (U : Set (ℝ × Z))
|
| 24 |
+
(F : LabelVertex (ell (B u) (pivot u)) τ U → A → ℝ) : Finset (I × s) → A → ℝ :=
|
| 25 |
+
extension (ell (B u) (pivot u)) (pivot u) τ s U F
|
| 26 |
+
|
| 27 |
+
def chartFunction (u : I → E) (τ : ℝ) (s : Finset ℤ) (U : Set (ℝ × Z))
|
| 28 |
+
(F : LabelVertex (ell (B u) (pivot u)) τ U → A → ℝ) (a : A) : E → ℝ :=
|
| 29 |
+
(cell (B u) (fun i (k : s) => -((k:ℤ)*τ/pivot u i)) (fun P => values u τ s U F P a)) ∘ split
|
| 30 |
+
|
| 31 |
+
lemma form_comp (u : E) (hu : u 0≠0) :
|
| 32 |
+
(form (slope u)).comp split.toContinuousLinearMap=(u 0)⁻¹ • InnerProductSpace.toDual ℝ E u := by
|
| 33 |
+
ext x
|
| 34 |
+
have hh := normalized_form u hu x
|
| 35 |
+
change (split x).1-slope u (split x).2=(u 0)⁻¹*inner ℝ u x
|
| 36 |
+
rw [← hh,div_eq_mul_inv,mul_comm]
|
| 37 |
+
|
| 38 |
+
lemma kernel_split (φ : ℝ → ℝ) :
|
| 39 |
+
(ProductMollifier.kernel (m := m+1) φ) ∘ split.symm =
|
| 40 |
+
(fun p : ℝ × Z => φ p.1*ProductMollifier.kernel φ p.2) := by
|
| 41 |
+
funext p
|
| 42 |
+
simp [ProductMollifier.kernel,Fin.prod_univ_succ]
|
| 43 |
+
|
| 44 |
+
omit [Fintype A] [DecidableEq I] in
|
| 45 |
+
lemma chartFunction_eq (u : I → E) (hu : ∀ i, u i 0≠0)
|
| 46 |
+
{τ : ℝ} (hτ : 0<τ) (s : Finset ℤ) (U : Set (ℝ × Z))
|
| 47 |
+
(hb : ∀ x∈U, regular (ell (B u) (pivot u)) τ x → ∀ i, label (ell (B u) (pivot u)) τ x i∈s)
|
| 48 |
+
(F : LabelVertex (ell (B u) (pivot u)) τ U → A → ℝ)
|
| 49 |
+
(x : E) (hx : split x∈U) (hr : regular (ell (B u) (pivot u)) τ (split x)) (a : A) :
|
| 50 |
+
chartFunction u τ s U F a x=F (vertex (ell (B u) (pivot u)) τ (split x) hx hr) a := by
|
| 51 |
+
change cell (B u) (fun i (k : s) => -((k:ℤ)*τ/pivot u i)) (fun P => extension (ell (B u) (pivot u)) (pivot u) τ s U F P a) (split x)=_
|
| 52 |
+
rw [cell_eq_extension (B u) (pivot u) hu (F := F)]
|
| 53 |
+
exact congrFun (extension_eq (ell (B u) (pivot u)) (pivot u) hu hτ s U hb F _ hx hr) a
|
| 54 |
+
|
| 55 |
+
omit [Fintype A] in
|
| 56 |
+
lemma chartFunction_measurable (u : I → E) (τ : ℝ) (s : Finset ℤ) (U : Set (ℝ × Z))
|
| 57 |
+
(F : LabelVertex (ell (B u) (pivot u)) τ U → A → ℝ) (a : A) :
|
| 58 |
+
Measurable (chartFunction u τ s U F a) :=
|
| 59 |
+
(cell_measurable _ _ _).comp split.continuous.measurable
|
| 60 |
+
|
| 61 |
+
omit [Fintype A] in
|
| 62 |
+
lemma chartFunction_integrable (u : I → E) (τ : ℝ) (s : Finset ℤ) (U : Set (ℝ × Z))
|
| 63 |
+
(F : LabelVertex (ell (B u) (pivot u)) τ U → A → ℝ) {M : ℝ} (hM : 0≤M)
|
| 64 |
+
(hF : ∀ v a, |F v a|≤M) (a : A) : LocallyIntegrable (chartFunction u τ s U F a) := by
|
| 65 |
+
apply (locallyIntegrable_const M).mono (chartFunction_measurable _ _ _ _ _ _).aestronglyMeasurable
|
| 66 |
+
filter_upwards with x
|
| 67 |
+
simpa only [chartFunction,Function.comp_apply,cell,values,Real.norm_eq_abs,abs_of_nonneg hM] using extension_bounded _ _ _ _ _ F hM hF _ a
|
| 68 |
+
|
| 69 |
+
lemma coefficients (u : I → E) (hu : ∀ i, u i 0≠0)
|
| 70 |
+
(hnp : ∀ i j, i≠j → ∀ t : ℝ, u i≠t • u j)
|
| 71 |
+
{τ lam : ℝ} (hτ : 0<τ) (hlam : 0<lam) (s : Finset ℤ)
|
| 72 |
+
{U : Set (ℝ × Z)} (hU : IsOpen U)
|
| 73 |
+
(hb : ∀ x∈U, regular (ell (B u) (pivot u)) τ x → ∀ i, label (ell (B u) (pivot u)) τ x i∈s)
|
| 74 |
+
(F : LabelVertex (ell (B u) (pivot u)) τ U → A → ℝ) {M J : ℝ}
|
| 75 |
+
(hM : 0≤M) (hJ : 0≤J) (hbound : ∀ v a, |F v a|≤M)
|
| 76 |
+
(hF : ∀ (vp vm : LabelVertex (ell (B u) (pivot u)) τ U) (i : I), vp.val i=vm.val i+1 →
|
| 77 |
+
(∀ j, j≠i → vp.val j=vm.val j) → ∑ a, |F vp a-F vm a|≤J)
|
| 78 |
+
(θ : E)
|
| 79 |
+
(hsupp : ∀ᵐ z ∂law (ProductMollifier.kernel (m := m) (ProductMollifier.density lam)) volume,
|
| 80 |
+
∀ t : ℝ, |t|<lam → split θ-(t,z)∈U)
|
| 81 |
+
(hsmall : ∀ i, τ/|pivot u i| *(lam⁻¹*(∫ t, |deriv ProductMollifier.rho t|))≤1) :
|
| 82 |
+
∃ β : I → A → ℝ,
|
| 83 |
+
(∀ a, HasFDerivAt (convolution (ProductMollifier.kernel (m := m+1) (ProductMollifier.density lam))
|
| 84 |
+
(chartFunction u τ s U F a) (ContinuousLinearMap.mul ℝ ℝ) volume)
|
| 85 |
+
(∑ i, β i a • InnerProductSpace.toDual ℝ E (u i)) θ) ∧
|
| 86 |
+
(∀ i, ∑ a, |β i a|≤2*J/τ) := by
|
| 87 |
+
let φ := ProductMollifier.density lam
|
| 88 |
+
let ψ : Z → ℝ := ProductMollifier.kernel φ
|
| 89 |
+
let Ξ := values u τ s U F
|
| 90 |
+
let q (i : I) (k : s) := -((k:ℤ)*τ/pivot u i)
|
| 91 |
+
have hBij := slope_injective u hu hnp
|
| 92 |
+
have hq (i : I) : Function.Injective (q i) := by
|
| 93 |
+
intro k l he
|
| 94 |
+
apply Subtype.ext
|
| 95 |
+
have he' : (k.val:ℝ)=(l.val:ℝ) := by
|
| 96 |
+
dsimp only [q] at he
|
| 97 |
+
exact (mul_left_inj' hτ.ne').mp ((div_left_inj' (show pivot u i≠0 from hu i)).mp (neg_injective he))
|
| 98 |
+
exact_mod_cast he'
|
| 99 |
+
have hcφ := (ProductMollifier.density_smooth lam).continuous
|
| 100 |
+
have hiφ := ProductMollifier.density_integrable hlam
|
| 101 |
+
have hcompφ := ProductMollifier.density_compact hlam
|
| 102 |
+
have hdφ (t : ℝ) : HasDerivAt φ (deriv φ t) t :=
|
| 103 |
+
((ProductMollifier.density_smooth lam).differentiable (by simp) t).hasDerivAt
|
| 104 |
+
have hiφ' : Integrable (deriv φ) :=
|
| 105 |
+
((ProductMollifier.density_smooth lam).continuous_deriv (by simp)).integrable_of_hasCompactSupport hcompφ.deriv
|
| 106 |
+
have hnφ := ProductMollifier.density_nonneg hlam.le
|
| 107 |
+
have hcψ := ProductMollifier.kernel_smooth (m := m) φ (ProductMollifier.density_smooth lam)
|
| 108 |
+
have hcompψ := ProductMollifier.kernel_compact (m := m) hlam.le (fun t ht => (ProductMollifier.density_support hlam ht).le)
|
| 109 |
+
have hiψ : Integrable ψ := hcψ.continuous.integrable_of_hasCompactSupport hcompψ
|
| 110 |
+
have hnψ := ProductMollifier.kernel_nonneg (m := m) hnφ
|
| 111 |
+
have hψ1 : ∫ z, ψ z=1 := by rw [ProductMollifier.kernel_integral,ProductMollifier.density_integral hlam,one_pow]
|
| 112 |
+
obtain ⟨C,hC⟩ := hcφ.bounded_above_of_compact_support hcompφ
|
| 113 |
+
have hC0 : 0≤C := (norm_nonneg (φ 0)).trans (hC 0)
|
| 114 |
+
have hΞ : ∀ P a, |Ξ P a|≤M := extension_bounded _ _ _ _ _ F hM hbound
|
| 115 |
+
let d (i : I) (a : A) : ℝ := ∑ k : s, ∫ z,
|
| 116 |
+
-(φ (form (B u i) (split θ)+B u i z-(k:ℤ)*τ/pivot u i)*
|
| 117 |
+
jump (B u) q Ξ (split θ) i k z a) ∂law ψ volume
|
| 118 |
+
refine ⟨fun i a => (pivot u i)⁻¹*d i a,?_,?_⟩
|
| 119 |
+
· intro a
|
| 120 |
+
have hd := convolution_derivative (B u) hBij q hq (fun P => Ξ P a) hM hC0 (fun P => hΞ P a)
|
| 121 |
+
hiφ hcφ hC hcψ.continuous.measurable hnψ hiψ hψ1 (split θ)
|
| 122 |
+
have he : convolution (ProductMollifier.kernel (m := m+1) φ) (chartFunction u τ s U F a)
|
| 123 |
+
(ContinuousLinearMap.mul ℝ ℝ) volume =
|
| 124 |
+
(convolution (fun p : ℝ × Z => φ p.1*ψ p.2) (cell (B u) q (fun P => Ξ P a))
|
| 125 |
+
(ContinuousLinearMap.mul ℝ ℝ) volume) ∘ split := by
|
| 126 |
+
funext x
|
| 127 |
+
rw [chartFunction,convolution_split,kernel_split]
|
| 128 |
+
rfl
|
| 129 |
+
rw [he]
|
| 130 |
+
have hd' : HasFDerivAt
|
| 131 |
+
(convolution (fun p : ℝ × Z => φ p.1*ψ p.2) (cell (B u) q (fun P => Ξ P a))
|
| 132 |
+
(ContinuousLinearMap.mul ℝ ℝ) volume)
|
| 133 |
+
(∑ i, d i a • form (B u i)) (split θ) := by
|
| 134 |
+
simpa only [d,jump,q,sub_eq_add_neg] using hd
|
| 135 |
+
have ht := derivative_transport _ _ θ hd'
|
| 136 |
+
have hL : (∑ i, d i a • form (B u i)).comp split.toContinuousLinearMap =
|
| 137 |
+
∑ i, ((pivot u i)⁻¹*d i a) • InnerProductSpace.toDual ℝ E (u i) := by
|
| 138 |
+
ext x
|
| 139 |
+
simp only [ContinuousLinearMap.comp_apply,_root_.sum_apply,_root_.smul_apply,smul_eq_mul]
|
| 140 |
+
apply Finset.sum_congr rfl
|
| 141 |
+
intro i _
|
| 142 |
+
have hi := congrArg (fun L : E →L[ℝ] ℝ => L x) (form_comp (u i) (hu i))
|
| 143 |
+
change form (B u i) (split x)=(pivot u i)⁻¹*inner ℝ (u i) x at hi
|
| 144 |
+
change d i a * form (B u i) (split x)=((pivot u i)⁻¹*d i a)*inner ℝ (u i) x
|
| 145 |
+
rw [hi]
|
| 146 |
+
ring
|
| 147 |
+
rw [hL] at ht
|
| 148 |
+
exact ht
|
| 149 |
+
· intro i
|
| 150 |
+
have hj := actual_jump_budget (B u) hBij (pivot u) hu hτ s hU hb F hF φ ψ (split θ) i (by
|
| 151 |
+
filter_upwards [hsupp] with z hz k hk
|
| 152 |
+
exact hz _ (ProductMollifier.density_support hlam hk))
|
| 153 |
+
have hh := common_coefficient_budget (B u) s (pivot u) hu hτ Ξ hM hC0 hJ hΞ
|
| 154 |
+
hdφ hnφ hiφ hiφ' (ProductMollifier.density_integral hlam) hC
|
| 155 |
+
hcψ.continuous.measurable hnψ hiψ hψ1 (split θ) i hj (by
|
| 156 |
+
rw [ProductMollifier.density_deriv_integral hlam]
|
| 157 |
+
exact hsmall i)
|
| 158 |
+
exact hh
|
| 159 |
+
end
|
| 160 |
+
end UniformSparsestCut.EuclideanCells
|
| 161 |
+
|
| 162 |
+
end
|
| 163 |
+
|
| 164 |
+
end OAI
|
lean/OAI/Combinatorics/SparsestCut/FiniteDuality.lean
ADDED
|
@@ -0,0 +1,214 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import OAI.Combinatorics.SparsestCut.Model
|
| 2 |
+
|
| 3 |
+
namespace OAI
|
| 4 |
+
|
| 5 |
+
universe u1 u2
|
| 6 |
+
|
| 7 |
+
open scoped BigOperators Topology NNReal RealInnerProductSpace InnerProductSpace Matrix ContDiff ENNReal
|
| 8 |
+
open MeasureTheory ProbabilityTheory Set Filter Matrix
|
| 9 |
+
|
| 10 |
+
noncomputable section
|
| 11 |
+
|
| 12 |
+
namespace UniformSparsestCut
|
| 13 |
+
|
| 14 |
+
namespace FiniteDuality
|
| 15 |
+
|
| 16 |
+
variable {E : Type u1} {K : Type u2} [Fintype E] [Fintype K]
|
| 17 |
+
|
| 18 |
+
def packingCone (A : E → K → ℝ) (w : K → ℝ) : Set ((E → ℝ) × ℝ) :=
|
| 19 |
+
{y | ∃ t : K → ℝ, (∀ k, 0 ≤ t k) ∧
|
| 20 |
+
(∀ e, ∑ k, A e k * t k ≤ y.1 e) ∧ y.2 ≤ ∑ k, w k * t k}
|
| 21 |
+
|
| 22 |
+
lemma packingCone_closed (A : E → K → ℝ) (w : K → ℝ)
|
| 23 |
+
(hA : ∀ e k, 0 ≤ A e k) (hcol : ∀ k, 0 < ∑ e, A e k) :
|
| 24 |
+
IsClosed (packingCone A w) := by
|
| 25 |
+
classical
|
| 26 |
+
apply isSeqClosed_iff_isClosed.mp
|
| 27 |
+
intro y b hy hyb
|
| 28 |
+
choose t ht0 htA htw using hy
|
| 29 |
+
have hsum : Tendsto (fun n => ∑ e, (y n).1 e) atTop (𝓝 (∑ e, b.1 e)) :=
|
| 30 |
+
tendsto_finsetSum _ (fun e he => (tendsto_pi_nhds.mp hyb.fst_nhds) e)
|
| 31 |
+
obtain ⟨B, hB⟩ := hsum.bddAbove_range
|
| 32 |
+
have hbound (n : ℕ) (k : K) : t n k ≤ B / (∑ e, A e k) := by
|
| 33 |
+
apply (le_div_iff₀ (hcol k)).mpr
|
| 34 |
+
calc
|
| 35 |
+
t n k * ∑ e, A e k = ∑ e, A e k * t n k := by
|
| 36 |
+
rw [Finset.mul_sum]; apply Finset.sum_congr rfl; intros; ring
|
| 37 |
+
_ ≤ ∑ e, ∑ j, A e j * t n j := by
|
| 38 |
+
apply Finset.sum_le_sum
|
| 39 |
+
intro e he
|
| 40 |
+
exact Finset.single_le_sum (fun j hj => mul_nonneg (hA e j) (ht0 n j))
|
| 41 |
+
(Finset.mem_univ k)
|
| 42 |
+
_ ≤ ∑ e, (y n).1 e := Finset.sum_le_sum (fun e he => htA n e)
|
| 43 |
+
_ ≤ B := hB (Set.mem_range_self n)
|
| 44 |
+
obtain ⟨u, hu, φ, hφ, htend⟩ :=
|
| 45 |
+
(isCompact_Icc : IsCompact (Icc (0 : K → ℝ) (fun k => B / (∑ e, A e k)))).tendsto_subseq
|
| 46 |
+
(fun n => ⟨ht0 n, hbound n⟩)
|
| 47 |
+
refine ⟨u, hu.1, ?_, ?_⟩
|
| 48 |
+
· intro e
|
| 49 |
+
apply le_of_tendsto_of_tendsto
|
| 50 |
+
(tendsto_finsetSum _ (fun k hk =>
|
| 51 |
+
tendsto_const_nhds.mul ((tendsto_pi_nhds.mp htend) k)))
|
| 52 |
+
(((tendsto_pi_nhds.mp hyb.fst_nhds) e).comp hφ.tendsto_atTop)
|
| 53 |
+
exact Eventually.of_forall (fun n => htA (φ n) e)
|
| 54 |
+
· apply le_of_tendsto_of_tendsto (hyb.snd_nhds.comp hφ.tendsto_atTop)
|
| 55 |
+
(tendsto_finsetSum _ (fun k hk =>
|
| 56 |
+
tendsto_const_nhds.mul ((tendsto_pi_nhds.mp htend) k)))
|
| 57 |
+
exact Eventually.of_forall (fun n => htw (φ n))
|
| 58 |
+
|
| 59 |
+
noncomputable def packingProperCone (A : E → K → ℝ) (w : K → ℝ)
|
| 60 |
+
(hA : ∀ e k, 0 ≤ A e k) (hcol : ∀ k, 0 < ∑ e, A e k) :
|
| 61 |
+
ProperCone ℝ ((E → ℝ) × ℝ) where
|
| 62 |
+
carrier := packingCone A w
|
| 63 |
+
zero_mem' := by
|
| 64 |
+
refine ⟨0, by simp, ?_, ?_⟩ <;> simp
|
| 65 |
+
add_mem' := by
|
| 66 |
+
rintro x y ⟨s, hs0, hsA, hsw⟩ ⟨t, ht0, htA, htw⟩
|
| 67 |
+
refine ⟨s+t, fun k => add_nonneg (hs0 k) (ht0 k), ?_, ?_⟩
|
| 68 |
+
· intro e
|
| 69 |
+
simpa [mul_add, Finset.sum_add_distrib] using add_le_add (hsA e) (htA e)
|
| 70 |
+
· simpa [mul_add, Finset.sum_add_distrib] using add_le_add hsw htw
|
| 71 |
+
smul_mem' := by
|
| 72 |
+
rintro ⟨a, ha⟩ x ⟨t, ht0, htA, htw⟩
|
| 73 |
+
refine ⟨a • t, fun k => mul_nonneg ha (ht0 k), ?_, ?_⟩
|
| 74 |
+
· intro e
|
| 75 |
+
change (∑ k, A e k * (a * t k)) ≤ a * x.1 e
|
| 76 |
+
simpa [← Finset.mul_sum, mul_left_comm] using
|
| 77 |
+
mul_le_mul_of_nonneg_left (htA e) ha
|
| 78 |
+
· change a * x.2 ≤ ∑ k, w k * (a * t k)
|
| 79 |
+
simpa [← Finset.mul_sum, mul_left_comm] using
|
| 80 |
+
mul_le_mul_of_nonneg_left htw ha
|
| 81 |
+
isClosed' := packingCone_closed A w hA hcol
|
| 82 |
+
|
| 83 |
+
lemma dual_functional (f : ((E → ℝ) × ℝ) →L[ℝ] ℝ) :
|
| 84 |
+
∃ c : E → ℝ, ∃ q : ℝ, ∀ x : (E → ℝ) × ℝ,
|
| 85 |
+
f x = (∑ e, c e * x.1 e) + q * x.2 := by
|
| 86 |
+
classical
|
| 87 |
+
refine ⟨fun e => f (Pi.single e 1, 0), f (0, 1), ?_⟩
|
| 88 |
+
rintro ⟨x,y⟩
|
| 89 |
+
have heq : (x,y) = (∑ e, x e • (Pi.single e 1, (0 : ℝ))) + y • (0, (1 : ℝ)) := by
|
| 90 |
+
ext e <;> simp [Prod.fst_sum, Prod.snd_sum, ← Pi.single_smul,
|
| 91 |
+
Finset.univ_sum_single]
|
| 92 |
+
calc
|
| 93 |
+
f (x,y) = f ((∑ e, x e • (Pi.single e 1, (0 : ℝ))) + y • (0, (1 : ℝ))) :=
|
| 94 |
+
congrArg f heq
|
| 95 |
+
_ = (∑ e, f (Pi.single e 1, 0) * x e) + f (0, 1) * y := by
|
| 96 |
+
simp only [map_add, map_sum, map_smul, smul_eq_mul, mul_comm]
|
| 97 |
+
|
| 98 |
+
theorem packing_duality_strict (A : E → K → ℝ) (w : K → ℝ)
|
| 99 |
+
(hA : ∀ e k, 0 ≤ A e k) (hcol : ∀ k, 0 < ∑ e, A e k)
|
| 100 |
+
(d : E → ℝ) (hd : ∀ e, 0 ≤ d e) {β : ℝ} (hβ : 0 < β)
|
| 101 |
+
(hbound : ∀ t : K → ℝ, (∀ k, 0 ≤ t k) →
|
| 102 |
+
(∀ e, ∑ k, A e k * t k ≤ d e) → (∑ k, w k * t k) < β) :
|
| 103 |
+
∃ c : E → ℝ, (∀ e, 0 ≤ c e) ∧
|
| 104 |
+
(∀ k, w k ≤ ∑ e, A e k * c e) ∧ (∑ e, c e * d e) < β := by
|
| 105 |
+
classical
|
| 106 |
+
let C := packingProperCone A w hA hcol
|
| 107 |
+
have hnot : (d,β) ∉ C := by
|
| 108 |
+
rintro ⟨t, ht0, htA, htw⟩
|
| 109 |
+
exact (hbound t ht0 htA).not_ge htw
|
| 110 |
+
obtain ⟨f, hf, hfb⟩ := C.hyperplane_separation_point hnot
|
| 111 |
+
obtain ⟨c,q,hform⟩ := dual_functional f
|
| 112 |
+
have hc (e : E) : 0 ≤ c e := by
|
| 113 |
+
have hx : (Pi.single e 1, (0 : ℝ)) ∈ C := by
|
| 114 |
+
refine ⟨0, by simp, ?_, ?_⟩
|
| 115 |
+
· intro j; simp only [Pi.zero_apply, mul_zero, Finset.sum_const_zero]
|
| 116 |
+
simp [Pi.single_apply]; split_ifs <;> norm_num
|
| 117 |
+
· simp
|
| 118 |
+
simpa [hform, Pi.single_apply, mul_ite] using hf _ hx
|
| 119 |
+
have hq : q < 0 := by
|
| 120 |
+
rw [hform] at hfb
|
| 121 |
+
have hcd : 0 ≤ ∑ e, c e * d e :=
|
| 122 |
+
Finset.sum_nonneg (fun e he => mul_nonneg (hc e) (hd e))
|
| 123 |
+
nlinarith
|
| 124 |
+
have hcoldual (k : K) : 0 ≤ (∑ e, c e * A e k) + q * w k := by
|
| 125 |
+
have hx : ((fun e => A e k), w k) ∈ C := by
|
| 126 |
+
refine ⟨Pi.single k 1, ?_, ?_, ?_⟩
|
| 127 |
+
· intro j; simp [Pi.single_apply]; split_ifs <;> norm_num
|
| 128 |
+
· intro e; simp [Pi.single_apply, mul_ite]
|
| 129 |
+
· simp [Pi.single_apply, mul_ite]
|
| 130 |
+
simpa [hform, Pi.single_apply, mul_ite] using hf _ hx
|
| 131 |
+
refine ⟨fun e => c e / (-q), fun e => div_nonneg (hc e) (neg_pos.mpr hq).le, ?_, ?_⟩
|
| 132 |
+
· intro k
|
| 133 |
+
simp only [← mul_div_assoc, ← Finset.sum_div]
|
| 134 |
+
apply (le_div_iff₀ (neg_pos.mpr hq)).mpr
|
| 135 |
+
have := hcoldual k
|
| 136 |
+
have hsum : (∑ e, A e k * c e) = ∑ e, c e * A e k := by
|
| 137 |
+
apply Finset.sum_congr rfl; intros; ring
|
| 138 |
+
rw [hsum]
|
| 139 |
+
nlinarith
|
| 140 |
+
· simp only [div_mul_eq_mul_div, ← Finset.sum_div]
|
| 141 |
+
apply (div_lt_iff₀ (neg_pos.mpr hq)).mpr
|
| 142 |
+
rw [hform] at hfb
|
| 143 |
+
nlinarith
|
| 144 |
+
|
| 145 |
+
omit [Fintype K] in
|
| 146 |
+
|
| 147 |
+
lemma cap_covering (A : E → K → ℝ) (w : K → ℝ)
|
| 148 |
+
(hA : ∀ e k, A e k = 0 ∨ A e k = 1) {W : ℝ} (hW : 0 ≤ W)
|
| 149 |
+
(hw : ∀ k, w k ≤ W) (c : E → ℝ) (hc : ∀ e, 0 ≤ c e)
|
| 150 |
+
(hcover : ∀ k, w k ≤ ∑ e, A e k * c e) :
|
| 151 |
+
∀ k, w k ≤ ∑ e, A e k * min (c e) W := by
|
| 152 |
+
classical
|
| 153 |
+
intro k
|
| 154 |
+
by_cases hb : ∃ e, A e k = 1 ∧ W < c e
|
| 155 |
+
· obtain ⟨e, he, hce⟩ := hb
|
| 156 |
+
calc
|
| 157 |
+
w k ≤ W := hw k
|
| 158 |
+
_ = A e k * min (c e) W := by rw [he, min_eq_right hce.le]; ring
|
| 159 |
+
_ ≤ ∑ j, A j k * min (c j) W :=
|
| 160 |
+
Finset.single_le_sum (fun j hj => mul_nonneg
|
| 161 |
+
(show 0 ≤ A j k from by rcases hA j k with h | h <;> rw [h] ; norm_num)
|
| 162 |
+
(le_min (hc j) hW)) (Finset.mem_univ e)
|
| 163 |
+
· convert hcover k using 1
|
| 164 |
+
apply Finset.sum_congr rfl
|
| 165 |
+
intro e he
|
| 166 |
+
rcases hA e k with hz | ho
|
| 167 |
+
· simp [hz]
|
| 168 |
+
· have hcW : c e ≤ W := le_of_not_gt (fun h => hb ⟨e, ho, h⟩)
|
| 169 |
+
rw [min_eq_left hcW]
|
| 170 |
+
|
| 171 |
+
theorem packing_duality (A : E → K → ℝ) (w : K → ℝ)
|
| 172 |
+
(hA : ∀ e k, A e k = 0 ∨ A e k = 1) (hcol : ∀ k, 0 < ∑ e, A e k)
|
| 173 |
+
(d : E → ℝ) (hd : ∀ e, 0 ≤ d e) {β W : ℝ} (hβ : 0 ≤ β) (hW : 0 ≤ W)
|
| 174 |
+
(hw : ∀ k, w k ≤ W)
|
| 175 |
+
(hbound : ∀ t : K → ℝ, (∀ k, 0 ≤ t k) →
|
| 176 |
+
(∀ e, ∑ k, A e k * t k ≤ d e) → (∑ k, w k * t k) ≤ β) :
|
| 177 |
+
∃ c : E → ℝ, (∀ e, 0 ≤ c e) ∧
|
| 178 |
+
(∀ k, w k ≤ ∑ e, A e k * c e) ∧ (∑ e, c e * d e) ≤ β := by
|
| 179 |
+
classical
|
| 180 |
+
have hA0 : ∀ e k, 0 ≤ A e k := by
|
| 181 |
+
intro e k; rcases hA e k with h | h <;> rw [h] ; norm_num
|
| 182 |
+
let T : Set (E → ℝ) := Icc 0 (fun _ => W) ∩ {c | ∀ k, w k ≤ ∑ e, A e k * c e}
|
| 183 |
+
have hTc : IsCompact T := by
|
| 184 |
+
refine isCompact_Icc.inter_right ?_
|
| 185 |
+
simp only [ofPred_forall]
|
| 186 |
+
apply isClosed_iInter
|
| 187 |
+
intro k
|
| 188 |
+
apply isClosed_le continuous_const
|
| 189 |
+
exact continuous_finsetSum _ (fun e he => continuous_const.mul (continuous_apply e))
|
| 190 |
+
have hcapped : ∀ γ, β < γ → ∃ c ∈ T, (∑ e, c e * d e) < γ := by
|
| 191 |
+
intro γ hγ
|
| 192 |
+
obtain ⟨c, hc0, hcA, hcd⟩ := packing_duality_strict A w hA0 hcol d hd
|
| 193 |
+
(hβ.trans_lt hγ) (fun t ht htA => (hbound t ht htA).trans_lt hγ)
|
| 194 |
+
refine ⟨fun e => min (c e) W, ⟨⟨?_, ?_⟩, cap_covering A w hA hW hw c hc0 hcA⟩, ?_⟩
|
| 195 |
+
· exact fun e => le_min (hc0 e) hW
|
| 196 |
+
· exact fun e => min_le_right _ _
|
| 197 |
+
· exact lt_of_le_of_lt (Finset.sum_le_sum (fun e he =>
|
| 198 |
+
mul_le_mul_of_nonneg_right (min_le_left _ _) (hd e))) hcd
|
| 199 |
+
obtain ⟨c0, hc0, _⟩ := hcapped (β+1) (by linarith)
|
| 200 |
+
have hobj : Continuous (fun c : E → ℝ => ∑ e, c e * d e) :=
|
| 201 |
+
continuous_finsetSum _ (fun e he => (continuous_apply e).mul continuous_const)
|
| 202 |
+
obtain ⟨c, hc, hmin⟩ := hTc.exists_isMinOn ⟨c0,hc0⟩ hobj.continuousOn
|
| 203 |
+
refine ⟨c, hc.1.1, hc.2, ?_⟩
|
| 204 |
+
by_contra! hstrict
|
| 205 |
+
obtain ⟨c', hc', hlt⟩ := hcapped (∑ e, c e * d e) hstrict
|
| 206 |
+
exact hlt.not_ge (hmin hc')
|
| 207 |
+
|
| 208 |
+
end FiniteDuality
|
| 209 |
+
|
| 210 |
+
end UniformSparsestCut
|
| 211 |
+
|
| 212 |
+
end
|
| 213 |
+
|
| 214 |
+
end OAI
|
lean/OAI/Combinatorics/SparsestCut/FiniteGraph.lean
ADDED
|
@@ -0,0 +1,128 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import Mathlib.Algebra.Order.BigOperators.Group.Finset
|
| 2 |
+
import Mathlib.Algebra.Order.Field.Rat
|
| 3 |
+
import Mathlib.Data.Finset.Max
|
| 4 |
+
import Mathlib.Data.Fintype.Powerset
|
| 5 |
+
import Mathlib.Tactic.Positivity
|
| 6 |
+
|
| 7 |
+
namespace OAI
|
| 8 |
+
|
| 9 |
+
/-!
|
| 10 |
+
# Finite uniform sparsest cut
|
| 11 |
+
|
| 12 |
+
The rational-capacity objective and its unit-demand denominator follow the introduction of
|
| 13 |
+
*Constant-factor hardness of uniform sparsest cut* by OpenAI.
|
| 14 |
+
-/
|
| 15 |
+
|
| 16 |
+
open scoped BigOperators
|
| 17 |
+
|
| 18 |
+
namespace UniformSparsestCut
|
| 19 |
+
|
| 20 |
+
|
| 21 |
+
/-- An undirected rational-capacity graph. Zero capacities encode absent edges.
|
| 22 |
+
There are no input demand weights: all distinct pairs have demand one. -/
|
| 23 |
+
structure Graph where
|
| 24 |
+
n : ℕ
|
| 25 |
+
two_le : 2 ≤ n
|
| 26 |
+
capacity : Fin n → Fin n → ℚ
|
| 27 |
+
nonnegative : ∀ i j, 0 ≤ capacity i j
|
| 28 |
+
symmetric : ∀ i j, capacity i j = capacity j i
|
| 29 |
+
diagonal : ∀ i, capacity i i = 0
|
| 30 |
+
|
| 31 |
+
/-- Demand is fixed, not chosen by the reduction. -/
|
| 32 |
+
def Graph.demand (G : Graph) (i j : Fin G.n) : ℕ := if i = j then 0 else 1
|
| 33 |
+
|
| 34 |
+
@[simp] theorem Graph.demand_self (G : Graph) (i : Fin G.n) : G.demand i i = 0 := by
|
| 35 |
+
simp [Graph.demand]
|
| 36 |
+
|
| 37 |
+
theorem Graph.demand_of_ne (G : Graph) {i j : Fin G.n} (h : i ≠ j) :
|
| 38 |
+
G.demand i j = 1 := by
|
| 39 |
+
simp [Graph.demand, h]
|
| 40 |
+
|
| 41 |
+
/-- A nonempty proper subset of the vertices. -/
|
| 42 |
+
def IsCut {n : ℕ} (S : Finset (Fin n)) : Prop := 0 < S.card ∧ S.card < n
|
| 43 |
+
|
| 44 |
+
instance {n : ℕ} (S : Finset (Fin n)) : Decidable (IsCut S) :=
|
| 45 |
+
inferInstanceAs (Decidable (0 < S.card ∧ S.card < n))
|
| 46 |
+
|
| 47 |
+
def cuts (n : ℕ) : Finset (Finset (Fin n)) := Finset.univ.filter IsCut
|
| 48 |
+
|
| 49 |
+
@[simp] theorem mem_cuts {n : ℕ} {S : Finset (Fin n)} : S ∈ cuts n ↔ IsCut S := by
|
| 50 |
+
simp [cuts]
|
| 51 |
+
|
| 52 |
+
theorem cuts_nonempty (G : Graph) : (cuts G.n).Nonempty := by
|
| 53 |
+
have hn : 0 < G.n := lt_of_lt_of_le (by decide : 0 < 2) G.two_le
|
| 54 |
+
refine ⟨{⟨0, hn⟩}, mem_cuts.mpr ?_⟩
|
| 55 |
+
simpa [IsCut] using (show 0 < 1 ∧ 1 < G.n from ⟨by decide, by have := G.two_le; omega⟩)
|
| 56 |
+
|
| 57 |
+
/-- Each unordered separated pair occurs once, with its endpoint in `S` first. -/
|
| 58 |
+
def Graph.cutCapacity (G : Graph) (S : Finset (Fin G.n)) : ℚ :=
|
| 59 |
+
∑ i ∈ S, ∑ j ∈ Finset.univ \ S, G.capacity i j
|
| 60 |
+
|
| 61 |
+
def Graph.cutRatio (G : Graph) (S : Finset (Fin G.n)) : ℚ :=
|
| 62 |
+
G.cutCapacity S / ((S.card : ℚ) * (G.n - S.card : ℕ))
|
| 63 |
+
|
| 64 |
+
/-- The actual minimum over all nonempty proper cuts, not a relaxation. -/
|
| 65 |
+
def Graph.phi (G : Graph) : ℚ :=
|
| 66 |
+
((cuts G.n).image G.cutRatio).min' ((cuts_nonempty G).image _)
|
| 67 |
+
|
| 68 |
+
theorem cut_card_le (G : Graph) (S : Finset (Fin G.n)) : S.card ≤ G.n := by
|
| 69 |
+
simpa using Finset.card_le_card (Finset.subset_univ S)
|
| 70 |
+
|
| 71 |
+
theorem cut_denominator_pos (G : Graph) {S : Finset (Fin G.n)} (hS : IsCut S) :
|
| 72 |
+
(0 : ℚ) < (S.card : ℚ) * (G.n - S.card : ℕ) := by
|
| 73 |
+
exact mul_pos (Nat.cast_pos.mpr hS.1) (Nat.cast_pos.mpr (Nat.sub_pos_of_lt hS.2))
|
| 74 |
+
|
| 75 |
+
theorem Graph.cutCapacity_nonneg (G : Graph) (S : Finset (Fin G.n)) :
|
| 76 |
+
0 ≤ G.cutCapacity S := by
|
| 77 |
+
exact Finset.sum_nonneg (fun i _ => Finset.sum_nonneg (fun j _ => G.nonnegative i j))
|
| 78 |
+
|
| 79 |
+
theorem Graph.cutRatio_nonneg (G : Graph) (S : Finset (Fin G.n)) :
|
| 80 |
+
0 ≤ G.cutRatio S := by
|
| 81 |
+
exact div_nonneg (G.cutCapacity_nonneg S) (by positivity)
|
| 82 |
+
|
| 83 |
+
theorem Graph.phi_le_cutRatio (G : Graph) {S : Finset (Fin G.n)} (hS : IsCut S) :
|
| 84 |
+
G.phi ≤ G.cutRatio S := by
|
| 85 |
+
exact Finset.min'_le _ _ (Finset.mem_image.mpr ⟨S, mem_cuts.mpr hS, rfl⟩)
|
| 86 |
+
|
| 87 |
+
theorem Graph.exists_minimizing_cut (G : Graph) :
|
| 88 |
+
∃ S : Finset (Fin G.n), IsCut S ∧ G.cutRatio S = G.phi := by
|
| 89 |
+
obtain ⟨S, hS, hv⟩ := Finset.mem_image.mp
|
| 90 |
+
(Finset.min'_mem ((cuts G.n).image G.cutRatio) ((cuts_nonempty G).image _))
|
| 91 |
+
exact ⟨S, mem_cuts.mp hS, hv⟩
|
| 92 |
+
|
| 93 |
+
theorem Graph.phi_nonneg (G : Graph) : 0 ≤ G.phi := by
|
| 94 |
+
obtain ⟨S, _, hS⟩ := G.exists_minimizing_cut
|
| 95 |
+
rw [← hS]
|
| 96 |
+
exact G.cutRatio_nonneg S
|
| 97 |
+
|
| 98 |
+
/-- In particular, strict soundness for every cut implies strict soundness for the minimum. -/
|
| 99 |
+
theorem Graph.lt_phi_iff (G : Graph) (r : ℚ) :
|
| 100 |
+
r < G.phi ↔ ∀ S : Finset (Fin G.n), IsCut S → r < G.cutRatio S := by
|
| 101 |
+
constructor
|
| 102 |
+
· intro hr S hS
|
| 103 |
+
exact hr.trans_le (G.phi_le_cutRatio hS)
|
| 104 |
+
· intro h
|
| 105 |
+
obtain ⟨S, hS, heq⟩ := G.exists_minimizing_cut
|
| 106 |
+
simpa [heq] using h S hS
|
| 107 |
+
|
| 108 |
+
/-- Summing the exactly-unit demands gives precisely the denominator in the source. -/
|
| 109 |
+
theorem Graph.separated_demand (G : Graph) (S : Finset (Fin G.n)) :
|
| 110 |
+
(∑ i ∈ S, ∑ j ∈ Finset.univ \ S, G.demand i j) = S.card * (G.n - S.card) := by
|
| 111 |
+
have hne (i : Fin G.n) (hi : i ∈ S) (j : Fin G.n) (hj : j ∈ Finset.univ \ S) :
|
| 112 |
+
i ≠ j := by
|
| 113 |
+
intro hij
|
| 114 |
+
exact (Finset.mem_sdiff.mp hj).2 (hij ▸ hi)
|
| 115 |
+
have hc : (Finset.univ \ S).card = G.n - S.card := by
|
| 116 |
+
simp [Finset.card_sdiff]
|
| 117 |
+
calc
|
| 118 |
+
_ = ∑ _i ∈ S, ∑ _j ∈ Finset.univ \ S, (1 : ℕ) := by
|
| 119 |
+
apply Finset.sum_congr rfl
|
| 120 |
+
intro i hi
|
| 121 |
+
apply Finset.sum_congr rfl
|
| 122 |
+
intro j hj
|
| 123 |
+
exact G.demand_of_ne (hne i hi j hj)
|
| 124 |
+
_ = _ := by simp [hc]
|
| 125 |
+
|
| 126 |
+
end UniformSparsestCut
|
| 127 |
+
|
| 128 |
+
end OAI
|
lean/OAI/Combinatorics/SparsestCut/FiniteNets.lean
ADDED
|
@@ -0,0 +1,122 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import OAI.Combinatorics.SparsestCut.GaussianTools
|
| 2 |
+
|
| 3 |
+
namespace OAI
|
| 4 |
+
|
| 5 |
+
universe u1
|
| 6 |
+
|
| 7 |
+
open scoped BigOperators Topology NNReal RealInnerProductSpace InnerProductSpace Matrix ContDiff ENNReal
|
| 8 |
+
open MeasureTheory ProbabilityTheory Set Filter Matrix
|
| 9 |
+
|
| 10 |
+
noncomputable section
|
| 11 |
+
|
| 12 |
+
namespace UniformSparsestCut.FiniteNets
|
| 13 |
+
|
| 14 |
+
lemma euclidean_norm_le_sum_abs {n : ℕ} (x : EuclideanSpace ℝ (Fin n)) :
|
| 15 |
+
‖x‖ ≤ ∑ i, |x i| := by
|
| 16 |
+
classical
|
| 17 |
+
have heq : x = ∑ i : Fin n, (PiLp.single 2 i (x i) : EuclideanSpace ℝ (Fin n)) := by
|
| 18 |
+
ext j
|
| 19 |
+
simp
|
| 20 |
+
calc
|
| 21 |
+
_ = ‖∑ i : Fin n, (PiLp.single 2 i (x i) : EuclideanSpace ℝ (Fin n))‖ := congrArg norm heq
|
| 22 |
+
_ ≤ ∑ i : Fin n, ‖(PiLp.single 2 i (x i) : EuclideanSpace ℝ (Fin n))‖ := norm_sum_le _ _
|
| 23 |
+
_ = _ := by simp [PiLp.norm_single, Real.norm_eq_abs]
|
| 24 |
+
|
| 25 |
+
lemma floor_coordinate_bound {n K : ℕ} {δ : ℝ} (hδ : 0 < δ)
|
| 26 |
+
{x : EuclideanSpace ℝ (Fin n)} (hx : ‖x‖ ≤ (K : ℝ) * δ) (i : Fin n) :
|
| 27 |
+
⌊x i / δ⌋ ∈ Finset.Icc (-(K : ℤ)) (K : ℤ) := by
|
| 28 |
+
have hcoord : |x i| ≤ ‖x‖ := by simpa using PiLp.norm_apply_le x i
|
| 29 |
+
have hi : |x i| ≤ (K : ℝ) * δ := hcoord.trans hx
|
| 30 |
+
rw [Finset.mem_Icc]
|
| 31 |
+
constructor
|
| 32 |
+
· apply Int.le_floor.mpr
|
| 33 |
+
push_cast
|
| 34 |
+
apply (le_div_iff₀ hδ).mpr
|
| 35 |
+
linarith [neg_abs_le (x i)]
|
| 36 |
+
· have hh : x i / δ ≤ (K : ℝ) := (div_le_iff₀ hδ).mpr ((le_abs_self _).trans hi)
|
| 37 |
+
have h := Int.floor_mono hh
|
| 38 |
+
simpa using h
|
| 39 |
+
|
| 40 |
+
lemma same_floor_distance {n : ℕ} {δ : ℝ} (hδ : 0 < δ)
|
| 41 |
+
{x y : EuclideanSpace ℝ (Fin n)} (hxy : ∀ i, ⌊x i / δ⌋ = ⌊y i / δ⌋) :
|
| 42 |
+
‖x - y‖ ≤ (n : ℝ) * δ := by
|
| 43 |
+
have hc (i : Fin n) : |x i - y i| ≤ δ := by
|
| 44 |
+
have hx1 := Int.floor_le (x i / δ)
|
| 45 |
+
have hx2 := Int.lt_floor_add_one (x i / δ)
|
| 46 |
+
have hy1 := Int.floor_le (y i / δ)
|
| 47 |
+
have hy2 := Int.lt_floor_add_one (y i / δ)
|
| 48 |
+
rw [hxy i] at hx1 hx2
|
| 49 |
+
apply abs_le.mpr
|
| 50 |
+
constructor
|
| 51 |
+
· have hh : -1 ≤ (x i - y i) / δ := by rw [sub_div]; linarith
|
| 52 |
+
have := (le_div_iff₀ hδ).mp hh
|
| 53 |
+
linarith
|
| 54 |
+
· have hh : (x i - y i) / δ ≤ 1 := by rw [sub_div]; linarith
|
| 55 |
+
have := (div_le_iff₀ hδ).mp hh
|
| 56 |
+
linarith
|
| 57 |
+
calc
|
| 58 |
+
‖x-y‖ ≤ ∑ i, |(x-y) i| := euclidean_norm_le_sum_abs _
|
| 59 |
+
_ ≤ ∑ _ : Fin n, δ := Finset.sum_le_sum (fun i _ => hc i)
|
| 60 |
+
_ = _ := by simp
|
| 61 |
+
|
| 62 |
+
theorem exists_coordinate_net {n K : ℕ} {δ : ℝ} (hδ : 0 < δ)
|
| 63 |
+
(A : Set (EuclideanSpace ℝ (Fin n)))
|
| 64 |
+
(hA : ∀ x ∈ A, ‖x‖ ≤ (K : ℝ) * δ) :
|
| 65 |
+
∃ V : Finset (EuclideanSpace ℝ (Fin n)),
|
| 66 |
+
(∀ v ∈ V, v ∈ A) ∧ V.card ≤ (2*K+1)^n ∧
|
| 67 |
+
∀ x ∈ A, ∃ v ∈ V, ‖x-v‖ ≤ (n : ℝ)*δ := by
|
| 68 |
+
classical
|
| 69 |
+
let G := Fin n → ↥(Finset.Icc (-(K : ℤ)) (K : ℤ))
|
| 70 |
+
let represented : G → Prop := fun g => ∃ x ∈ A, ∀ i, ⌊x i / δ⌋ = (g i).val
|
| 71 |
+
let point : G → EuclideanSpace ℝ (Fin n) := fun g =>
|
| 72 |
+
if h : represented g then h.choose else 0
|
| 73 |
+
have hpoint (g : G) (hg : represented g) :
|
| 74 |
+
point g ∈ A ∧ ∀ i, ⌊point g i / δ⌋ = (g i).val := by
|
| 75 |
+
simpa [point, hg] using hg.choose_spec
|
| 76 |
+
let V := (Finset.univ.filter represented).image point
|
| 77 |
+
refine ⟨V, ?_, ?_, ?_⟩
|
| 78 |
+
· intro v hv
|
| 79 |
+
obtain ⟨g, hg, rfl⟩ := Finset.mem_image.mp hv
|
| 80 |
+
exact (hpoint g (Finset.mem_filter.mp hg).2).1
|
| 81 |
+
· calc
|
| 82 |
+
V.card ≤ (Finset.univ.filter represented).card := Finset.card_image_le
|
| 83 |
+
_ ≤ Fintype.card G := (Finset.card_filter_le _ _).trans_eq (Finset.card_univ)
|
| 84 |
+
_ = (2*K+1)^n := by
|
| 85 |
+
simp only [G, Fintype.card_fun, Fintype.card_coe, Int.card_Icc, Fintype.card_fin]
|
| 86 |
+
congr 1
|
| 87 |
+
omega
|
| 88 |
+
· intro x hx
|
| 89 |
+
let g : G := fun i => ⟨⌊x i / δ⌋, floor_coordinate_bound hδ (hA x hx) i⟩
|
| 90 |
+
have hg : represented g := ⟨x, hx, fun _ => rfl⟩
|
| 91 |
+
refine ⟨point g, Finset.mem_image.mpr ⟨g, Finset.mem_filter.mpr ⟨Finset.mem_univ _, hg⟩, rfl⟩, ?_⟩
|
| 92 |
+
exact same_floor_distance hδ (fun i => ((hpoint g hg).2 i).symm)
|
| 93 |
+
|
| 94 |
+
lemma sphere_net_norm_bound {E : Type u1} [NormedAddCommGroup E] [InnerProductSpace ℝ E]
|
| 95 |
+
{V : Finset E} {ρ B : ℝ}
|
| 96 |
+
(hnet : ∀ x : E, ‖x‖ = 1 → ∃ v ∈ V, ‖x-v‖ ≤ ρ)
|
| 97 |
+
{z : E} (hz : ∀ v ∈ V, |inner ℝ z v| ≤ B) (hB : 0 ≤ B) :
|
| 98 |
+
(1-ρ)*‖z‖ ≤ B := by
|
| 99 |
+
by_cases hzero : z = 0
|
| 100 |
+
· simpa [hzero] using hB
|
| 101 |
+
have hn : 0 < ‖z‖ := norm_pos_iff.mpr hzero
|
| 102 |
+
let x := ‖z‖⁻¹ • z
|
| 103 |
+
have hx : ‖x‖ = 1 := by simp [x, norm_smul, hn.ne']
|
| 104 |
+
obtain ⟨v, hv, hdist⟩ := hnet x hx
|
| 105 |
+
have hinner : inner ℝ z x = ‖z‖ := by
|
| 106 |
+
simp [x, inner_smul_right, sq, hn.ne']
|
| 107 |
+
have heq : inner ℝ z x = inner ℝ z v + inner ℝ z (x-v) := by
|
| 108 |
+
rw [inner_sub_right]
|
| 109 |
+
ring
|
| 110 |
+
have hbound : ‖z‖ ≤ B + ‖z‖ * ρ := by
|
| 111 |
+
calc
|
| 112 |
+
‖z‖ = |inner ℝ z x| := by rw [hinner, abs_of_nonneg (norm_nonneg _)]
|
| 113 |
+
_ ≤ |inner ℝ z v| + |inner ℝ z (x-v)| := by rw [heq]; exact abs_add_le _ _
|
| 114 |
+
_ ≤ B + ‖z‖ * ρ := add_le_add (hz v hv)
|
| 115 |
+
((abs_real_inner_le_norm _ _).trans (mul_le_mul_of_nonneg_left hdist (norm_nonneg _)))
|
| 116 |
+
nlinarith
|
| 117 |
+
|
| 118 |
+
end UniformSparsestCut.FiniteNets
|
| 119 |
+
|
| 120 |
+
end
|
| 121 |
+
|
| 122 |
+
end OAI
|
lean/OAI/Combinatorics/SparsestCut/FiniteWeights.lean
ADDED
|
@@ -0,0 +1,168 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/-
|
| 2 |
+
Copyright (c) 2026 OpenAI. All rights reserved.
|
| 3 |
+
Authors: OpenAI
|
| 4 |
+
-/
|
| 5 |
+
import Mathlib.Algebra.Order.BigOperators.Ring.Finset
|
| 6 |
+
import Mathlib.Basic.Real.Basic
|
| 7 |
+
import Mathlib.Tactic.Linarith
|
| 8 |
+
|
| 9 |
+
namespace OAI
|
| 10 |
+
|
| 11 |
+
/-!
|
| 12 |
+
# Finite Boolean weights and variances
|
| 13 |
+
|
| 14 |
+
Finite weighted laws support Boolean event masses, complementary masses, and the disagreement
|
| 15 |
+
of independent draws. The variance estimates give scalar ingredients for the finite graph
|
| 16 |
+
construction in Section 7 of *Constant-factor hardness of uniform sparsest cut*.
|
| 17 |
+
-/
|
| 18 |
+
|
| 19 |
+
open scoped BigOperators
|
| 20 |
+
|
| 21 |
+
namespace UniformSparsestCut.FiniteWeights
|
| 22 |
+
|
| 23 |
+
variable {ι : Type*} [Fintype ι]
|
| 24 |
+
|
| 25 |
+
def indicator (b : Bool) : ℝ := if b then 1 else 0
|
| 26 |
+
|
| 27 |
+
def disagree (b c : Bool) : ℝ := if b = c then 0 else 1
|
| 28 |
+
|
| 29 |
+
def total (w : ι → ℝ) : ℝ := ∑ i, w i
|
| 30 |
+
|
| 31 |
+
def mass (w : ι → ℝ) (h : ι → Bool) : ℝ := ∑ i, w i * indicator (h i)
|
| 32 |
+
|
| 33 |
+
def variance (w : ι → ℝ) (h : ι → Bool) : ℝ := mass w h * (1 - mass w h)
|
| 34 |
+
|
| 35 |
+
/-- The weight of a disagreement for two independent draws (not necessarily normalized). -/
|
| 36 |
+
def disagreement (w u : ι → ℝ) (h : ι → Bool) : ℝ :=
|
| 37 |
+
∑ i, w i * ∑ j, u j * disagree (h i) (h j)
|
| 38 |
+
|
| 39 |
+
theorem indicator_nonneg (b : Bool) : 0 ≤ indicator b := by
|
| 40 |
+
cases b <;> simp [indicator]
|
| 41 |
+
|
| 42 |
+
theorem indicator_le_one (b : Bool) : indicator b ≤ 1 := by
|
| 43 |
+
cases b <;> simp [indicator]
|
| 44 |
+
|
| 45 |
+
theorem indicator_not (b : Bool) : indicator (!b) = 1 - indicator b := by
|
| 46 |
+
cases b <;> simp [indicator]
|
| 47 |
+
|
| 48 |
+
theorem disagree_nonneg (b c : Bool) : 0 ≤ disagree b c := by
|
| 49 |
+
cases b <;> cases c <;> simp [disagree]
|
| 50 |
+
|
| 51 |
+
theorem disagree_eq (b c : Bool) :
|
| 52 |
+
disagree b c = indicator b * (1 - indicator c) + (1 - indicator b) * indicator c := by
|
| 53 |
+
cases b <;> cases c <;> simp [disagree, indicator]
|
| 54 |
+
|
| 55 |
+
theorem total_nonneg {w : ι → ℝ} (hw : ∀ i, 0 ≤ w i) : 0 ≤ total w :=
|
| 56 |
+
Finset.sum_nonneg (fun i _ => hw i)
|
| 57 |
+
|
| 58 |
+
theorem total_mono {w u : ι → ℝ} (hwu : ∀ i, w i ≤ u i) : total w ≤ total u :=
|
| 59 |
+
Finset.sum_le_sum (fun i _ => hwu i)
|
| 60 |
+
|
| 61 |
+
theorem total_add (w u : ι → ℝ) : total (fun i => w i + u i) = total w + total u := by
|
| 62 |
+
simp [total, Finset.sum_add_distrib]
|
| 63 |
+
|
| 64 |
+
theorem total_smul (a : ℝ) (w : ι → ℝ) : total (fun i => a * w i) = a * total w := by
|
| 65 |
+
simp [total, Finset.mul_sum]
|
| 66 |
+
|
| 67 |
+
theorem mass_nonneg {w : ι → ℝ} (hw : ∀ i, 0 ≤ w i) (h : ι → Bool) : 0 ≤ mass w h :=
|
| 68 |
+
Finset.sum_nonneg (fun i _ => mul_nonneg (hw i) (indicator_nonneg (h i)))
|
| 69 |
+
|
| 70 |
+
theorem mass_le_total {w : ι → ℝ} (hw : ∀ i, 0 ≤ w i) (h : ι → Bool) :
|
| 71 |
+
mass w h ≤ total w := by
|
| 72 |
+
apply Finset.sum_le_sum
|
| 73 |
+
intro i _
|
| 74 |
+
simpa using mul_le_mul_of_nonneg_left (indicator_le_one (h i)) (hw i)
|
| 75 |
+
|
| 76 |
+
theorem mass_mono {w u : ι → ℝ} (hwu : ∀ i, w i ≤ u i) (h : ι → Bool) :
|
| 77 |
+
mass w h ≤ mass u h := by
|
| 78 |
+
exact Finset.sum_le_sum (fun i _ =>
|
| 79 |
+
mul_le_mul_of_nonneg_right (hwu i) (indicator_nonneg (h i)))
|
| 80 |
+
|
| 81 |
+
theorem mass_add (w u : ι → ℝ) (h : ι → Bool) :
|
| 82 |
+
mass (fun i => w i + u i) h = mass w h + mass u h := by
|
| 83 |
+
simp [mass, add_mul, Finset.sum_add_distrib]
|
| 84 |
+
|
| 85 |
+
theorem mass_smul (a : ℝ) (w : ι → ℝ) (h : ι → Bool) :
|
| 86 |
+
mass (fun i => a * w i) h = a * mass w h := by
|
| 87 |
+
simp [mass, mul_assoc, Finset.mul_sum]
|
| 88 |
+
|
| 89 |
+
theorem mass_compl (w : ι → ℝ) (h : ι → Bool) :
|
| 90 |
+
mass w (fun i => !(h i)) = total w - mass w h := by
|
| 91 |
+
simp [mass, indicator_not, mul_sub, Finset.sum_sub_distrib, total]
|
| 92 |
+
|
| 93 |
+
theorem variance_nonneg {w : ι → ℝ} (hw : ∀ i, 0 ≤ w i) (hw₁ : total w = 1)
|
| 94 |
+
(h : ι → Bool) : 0 ≤ variance w h := by
|
| 95 |
+
exact mul_nonneg (mass_nonneg hw h) (sub_nonneg.mpr (hw₁ ▸ mass_le_total hw h))
|
| 96 |
+
|
| 97 |
+
theorem inner_disagreement (u : ι → ℝ) (h : ι → Bool) (b : Bool) :
|
| 98 |
+
(∑ j, u j * disagree b (h j)) =
|
| 99 |
+
indicator b * (total u - mass u h) + (1 - indicator b) * mass u h := by
|
| 100 |
+
calc
|
| 101 |
+
_ = ∑ j, (indicator b * (u j - u j * indicator (h j)) +
|
| 102 |
+
(1 - indicator b) * (u j * indicator (h j))) := by
|
| 103 |
+
apply Finset.sum_congr rfl
|
| 104 |
+
intro j _
|
| 105 |
+
rw [disagree_eq]
|
| 106 |
+
ring
|
| 107 |
+
_ = _ := by
|
| 108 |
+
simp only [Finset.sum_add_distrib, ← Finset.mul_sum, Finset.sum_sub_distrib,
|
| 109 |
+
total, mass]
|
| 110 |
+
|
| 111 |
+
theorem disagreement_eq (w u : ι → ℝ) (h : ι → Bool) :
|
| 112 |
+
disagreement w u h = mass w h * (total u - mass u h) +
|
| 113 |
+
(total w - mass w h) * mass u h := by
|
| 114 |
+
unfold disagreement
|
| 115 |
+
simp_rw [inner_disagreement]
|
| 116 |
+
calc
|
| 117 |
+
_ = ∑ i, ((w i * indicator (h i)) * (total u - mass u h) +
|
| 118 |
+
(w i - w i * indicator (h i)) * mass u h) := by
|
| 119 |
+
apply Finset.sum_congr rfl
|
| 120 |
+
intro i _
|
| 121 |
+
ring
|
| 122 |
+
_ = _ := by
|
| 123 |
+
simp only [Finset.sum_add_distrib, ← Finset.sum_mul, Finset.sum_sub_distrib,
|
| 124 |
+
total, mass]
|
| 125 |
+
|
| 126 |
+
theorem disagreement_self (w : ι → ℝ) (hw : total w = 1) (h : ι → Bool) :
|
| 127 |
+
disagreement w w h = 2 * variance w h := by
|
| 128 |
+
rw [disagreement_eq, hw]
|
| 129 |
+
unfold variance
|
| 130 |
+
ring
|
| 131 |
+
|
| 132 |
+
theorem disagreement_nonneg {w u : ι → ℝ} (hw : ∀ i, 0 ≤ w i)
|
| 133 |
+
(hu : ∀ i, 0 ≤ u i) (h : ι → Bool) : 0 ≤ disagreement w u h := by
|
| 134 |
+
unfold disagreement
|
| 135 |
+
exact Finset.sum_nonneg (fun i _ => mul_nonneg (hw i)
|
| 136 |
+
(Finset.sum_nonneg (fun j _ => mul_nonneg (hu j) (disagree_nonneg _ _))))
|
| 137 |
+
|
| 138 |
+
/-- Product domination: the constant is squared, since the two draws are independent. -/
|
| 139 |
+
theorem variance_domination {w u : ι → ℝ} {A : ℝ}
|
| 140 |
+
(hw : ∀ i, 0 ≤ w i) (hu : ∀ i, 0 ≤ u i)
|
| 141 |
+
(hw₁ : total w = 1) (hu₁ : total u = 1) (hA : 0 ≤ A)
|
| 142 |
+
(hdom : ∀ i, w i ≤ A * u i) (h : ι → Bool) :
|
| 143 |
+
variance w h ≤ A ^ 2 * variance u h := by
|
| 144 |
+
have hm : mass w h ≤ A * mass u h := by
|
| 145 |
+
simpa [mass_smul] using mass_mono hdom h
|
| 146 |
+
have hc : 1 - mass w h ≤ A * (1 - mass u h) := by
|
| 147 |
+
simpa [mass_smul, mass_compl, total_smul, hw₁, hu₁, mul_sub] using
|
| 148 |
+
mass_mono hdom (fun i => !(h i))
|
| 149 |
+
have hc₀ : 0 ≤ 1 - mass w h := sub_nonneg.mpr (hw₁ ▸ mass_le_total hw h)
|
| 150 |
+
have hm₀ : 0 ≤ A * mass u h := mul_nonneg hA (mass_nonneg hu h)
|
| 151 |
+
have hh := mul_le_mul hm hc hc₀ hm₀
|
| 152 |
+
unfold variance
|
| 153 |
+
nlinarith only [hh]
|
| 154 |
+
|
| 155 |
+
/-- A change of color with probability at most `L` changes Boolean variance by at most `L`.
|
| 156 |
+
This scalar estimate also follows by coupling two independent draws and a union bound. -/
|
| 157 |
+
theorem variance_change {z r L : ℝ} (hz₀ : 0 ≤ z) (hz₁ : z ≤ 1)
|
| 158 |
+
(hr₀ : 0 ≤ r) (hr₁ : r ≤ 1) (h₁ : z - r ≤ L) (h₂ : r - z ≤ L) :
|
| 159 |
+
z * (1 - z) ≤ r * (1 - r) + L := by
|
| 160 |
+
rcases le_total z r with hzr | hrz
|
| 161 |
+
· have hh := mul_nonneg (sub_nonneg.mpr hzr) (show 0 ≤ 2 - z - r by linarith)
|
| 162 |
+
nlinarith only [hh, h₂]
|
| 163 |
+
· have hh := mul_nonneg (sub_nonneg.mpr hrz) (add_nonneg hz₀ hr₀)
|
| 164 |
+
nlinarith only [hh, h₁]
|
| 165 |
+
|
| 166 |
+
end UniformSparsestCut.FiniteWeights
|
| 167 |
+
|
| 168 |
+
end OAI
|
lean/OAI/Combinatorics/SparsestCut/GapEstimates.lean
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import Mathlib.Basic.Real.Basic
|
| 2 |
+
import Mathlib.Tactic.Linarith
|
| 3 |
+
|
| 4 |
+
namespace OAI
|
| 5 |
+
|
| 6 |
+
/-!
|
| 7 |
+
# Numerical estimates for the finite sparsest-cut graph
|
| 8 |
+
|
| 9 |
+
These are the final completeness and soundness inequalities in Section 7 of
|
| 10 |
+
*Constant-factor hardness of uniform sparsest cut* by OpenAI.
|
| 11 |
+
-/
|
| 12 |
+
|
| 13 |
+
namespace UniformSparsestCut
|
| 14 |
+
|
| 15 |
+
/-- A cut of capacity at most `22` whose two sides have counting mass at least
|
| 16 |
+
`1 / 40000` lies below the completeness threshold. -/
|
| 17 |
+
theorem completeness_ratio {N z T : ℝ} (hN : 0 < N)
|
| 18 |
+
(hz : (1 : ℝ) / 40000 ≤ z) (hz' : (1 : ℝ) / 40000 ≤ 1 - z)
|
| 19 |
+
(hT : T ≤ 22) : T / (N ^ 2 * (z * (1 - z))) < 10 ^ 12 / N ^ 2 := by
|
| 20 |
+
have hz₀ : 0 < z := by linarith
|
| 21 |
+
have hz₁ : 0 < 1 - z := by linarith
|
| 22 |
+
have hvar : (1 / 40000 : ℝ) ^ 2 ≤ z * (1 - z) := by
|
| 23 |
+
simpa only [pow_two] using
|
| 24 |
+
mul_le_mul hz hz' (by norm_num : (0 : ℝ) ≤ 1 / 40000) hz₀.le
|
| 25 |
+
have hgap : T < (10 : ℝ) ^ 12 * (z * (1 - z)) := by nlinarith
|
| 26 |
+
have hvpos := mul_pos hz₀ hz₁
|
| 27 |
+
have hdiv : T / (z * (1 - z)) < (10 : ℝ) ^ 12 := (div_lt_iff₀ hvpos).mpr hgap
|
| 28 |
+
have hN₂ : 0 < N ^ 2 := sq_pos_of_pos hN
|
| 29 |
+
calc
|
| 30 |
+
_ = (T / (z * (1 - z))) / N ^ 2 := by rw [div_div, mul_comm]
|
| 31 |
+
_ < _ := (div_lt_div_iff_of_pos_right hN₂).mpr hdiv
|
| 32 |
+
|
| 33 |
+
/-- Variance transfer and the tether bound contradict the comparison gap for a
|
| 34 |
+
nontrivial monochromatic-cluster cut. -/
|
| 35 |
+
theorem soundness_contradiction {κ z ν T L D : ℝ}
|
| 36 |
+
(hκ : 0 < κ) (hz₀ : 0 < z) (hz₁ : z < 1) (hν : 0 ≤ ν) (hL : 0 ≤ L)
|
| 37 |
+
(hsmall : T ≤ κ * (z * (1 - z)))
|
| 38 |
+
(htether : 2 * κ * L ≤ T) (htransfer : z * (1 - z) ≤ 36 * ν + L)
|
| 39 |
+
(hraw : D ≤ T) (hgap : 0 < ν → 100 * κ * ν < D) : False := by
|
| 40 |
+
have ht : T ≤ κ * (36 * ν + L) :=
|
| 41 |
+
hsmall.trans (mul_le_mul_of_nonneg_left htransfer hκ.le)
|
| 42 |
+
have ht72 : T ≤ 72 * κ * ν := by nlinarith only [ht, htether]
|
| 43 |
+
have hνpos : 0 < ν := by
|
| 44 |
+
by_contra hn
|
| 45 |
+
have hνzero : ν = 0 := le_antisymm (le_of_not_gt hn) hν
|
| 46 |
+
rw [hνzero] at ht72 htransfer
|
| 47 |
+
have hT : T ≤ 0 := by simpa using ht72
|
| 48 |
+
have hLzero : L = 0 := by nlinarith [mul_pos hκ (show (0 : ℝ) < 2 by norm_num)]
|
| 49 |
+
have hvarpos : 0 < z * (1 - z) := mul_pos hz₀ (sub_pos.mpr hz₁)
|
| 50 |
+
nlinarith only [htransfer, hLzero, hvarpos]
|
| 51 |
+
have hpositive := mul_pos hκ hνpos
|
| 52 |
+
have hno := hgap hνpos
|
| 53 |
+
nlinarith only [ht72, hraw, hno, hpositive]
|
| 54 |
+
|
| 55 |
+
end UniformSparsestCut
|
| 56 |
+
|
| 57 |
+
end OAI
|
lean/OAI/Combinatorics/SparsestCut/GapReduction.lean
ADDED
|
@@ -0,0 +1,192 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import OAI.Combinatorics.SparsestCut.FiniteGraph
|
| 2 |
+
import Mathlib.Computability.TuringMachine.Computable
|
| 3 |
+
import Mathlib.Data.List.OfFn
|
| 4 |
+
import Mathlib.Basic.Real.Basic
|
| 5 |
+
import Mathlib.Tactic.Linarith
|
| 6 |
+
|
| 7 |
+
namespace OAI
|
| 8 |
+
|
| 9 |
+
/-!
|
| 10 |
+
# Encodings and reductions for uniform sparsest cut
|
| 11 |
+
|
| 12 |
+
These definitions express the polynomial-time reduction and approximation search problem in
|
| 13 |
+
*Constant-factor hardness of uniform sparsest cut* by OpenAI. The last semantic implication
|
| 14 |
+
uses rational threshold comparison.
|
| 15 |
+
-/
|
| 16 |
+
|
| 17 |
+
namespace UniformSparsestCut
|
| 18 |
+
|
| 19 |
+
abbrev BitString := List Bool
|
| 20 |
+
|
| 21 |
+
/-- A self-delimiting binary block: unary length, terminator, then the bits. -/
|
| 22 |
+
def block (s : BitString) : BitString := List.replicate s.length true ++ false :: s
|
| 23 |
+
|
| 24 |
+
/-- Binary, not unary, representation of a natural number, with a length prefix. -/
|
| 25 |
+
def encodeNat (n : ℕ) : BitString := block (Computability.encodeNat n)
|
| 26 |
+
|
| 27 |
+
/-- Signed numerator and positive denominator, both in binary. -/
|
| 28 |
+
def encodeRat (q : ℚ) : BitString :=
|
| 29 |
+
decide (q.num < 0) :: (encodeNat q.num.natAbs ++ encodeNat q.den)
|
| 30 |
+
|
| 31 |
+
def encodePair (p : BitString × BitString) : BitString := block p.1 ++ p.2
|
| 32 |
+
|
| 33 |
+
def encodeBool (b : Bool) : BitString := [b]
|
| 34 |
+
|
| 35 |
+
/-- A finite-stack, finite-alphabet Turing machine with a polynomial step bound.
|
| 36 |
+
|
| 37 |
+
Mathlib's `FinTM2` only supplies alphabet finiteness for the input stack. The
|
| 38 |
+
extra condition here requires *every* stack alphabet to be finite. Thus one
|
| 39 |
+
cannot store an arbitrary natural number or a function in a single stack symbol.
|
| 40 |
+
-/
|
| 41 |
+
def Polytime {α β : Type} (ea : α → BitString) (eb : β → BitString)
|
| 42 |
+
(f : α → β) : Prop :=
|
| 43 |
+
∃ M : Turing.TM2ComputableInPolyTime ea eb f, ∀ k, Finite (M.tm.Γ k)
|
| 44 |
+
|
| 45 |
+
/-! ## 3CNF formulas -/
|
| 46 |
+
|
| 47 |
+
structure Literal where
|
| 48 |
+
index : ℕ
|
| 49 |
+
positive : Bool
|
| 50 |
+
deriving DecidableEq
|
| 51 |
+
|
| 52 |
+
structure Clause where
|
| 53 |
+
first : Literal
|
| 54 |
+
second : Literal
|
| 55 |
+
third : Literal
|
| 56 |
+
deriving DecidableEq
|
| 57 |
+
|
| 58 |
+
/-- Exactly three literals per clause; repetitions are permitted. -/
|
| 59 |
+
abbrev Formula := List Clause
|
| 60 |
+
|
| 61 |
+
def Literal.eval (v : ℕ → Bool) (l : Literal) : Bool :=
|
| 62 |
+
if l.positive then v l.index else !(v l.index)
|
| 63 |
+
|
| 64 |
+
def Clause.eval (v : ℕ → Bool) (c : Clause) : Bool :=
|
| 65 |
+
c.first.eval v || c.second.eval v || c.third.eval v
|
| 66 |
+
|
| 67 |
+
def Satisfiable (F : Formula) : Prop :=
|
| 68 |
+
∃ v : ℕ → Bool, ∀ c ∈ F, c.eval v = true
|
| 69 |
+
|
| 70 |
+
def Literal.encode (l : Literal) : BitString := l.positive :: encodeNat l.index
|
| 71 |
+
|
| 72 |
+
def Clause.encode (c : Clause) : BitString :=
|
| 73 |
+
c.first.encode ++ c.second.encode ++ c.third.encode
|
| 74 |
+
|
| 75 |
+
def encodeFormula (F : Formula) : BitString :=
|
| 76 |
+
encodeNat F.length ++ F.flatMap Clause.encode
|
| 77 |
+
|
| 78 |
+
def formulaSize (F : Formula) : ℕ := (encodeFormula F).length
|
| 79 |
+
|
| 80 |
+
def encodeGraph (G : Graph) : BitString :=
|
| 81 |
+
encodeNat G.n ++ (List.finRange G.n).flatMap (fun i =>
|
| 82 |
+
(List.finRange G.n).flatMap (fun j => encodeRat (G.capacity i j)))
|
| 83 |
+
|
| 84 |
+
/-- The rational threshold is additional to the graph. -/
|
| 85 |
+
structure Instance where
|
| 86 |
+
graph : Graph
|
| 87 |
+
threshold : ℚ
|
| 88 |
+
threshold_pos : 0 < threshold
|
| 89 |
+
|
| 90 |
+
def encodeInstance (I : Instance) : BitString :=
|
| 91 |
+
block (encodeGraph I.graph) ++ encodeRat I.threshold
|
| 92 |
+
|
| 93 |
+
/-- This records graph size, every numeric bit length, and total output length.
|
| 94 |
+
The polynomial is quantified *inside* the choice of the fixed factor. -/
|
| 95 |
+
def OutputBound (R : Formula → Instance) (p : Polynomial ℕ) : Prop :=
|
| 96 |
+
∀ F, let I := R F
|
| 97 |
+
I.graph.n + I.graph.n ^ 2 ≤ p.eval (formulaSize F) ∧
|
| 98 |
+
(∀ i j, (encodeRat (I.graph.capacity i j)).length ≤ p.eval (formulaSize F)) ∧
|
| 99 |
+
(encodeRat I.threshold).length ≤ p.eval (formulaSize F) ∧
|
| 100 |
+
(encodeInstance I).length ≤ p.eval (formulaSize F)
|
| 101 |
+
|
| 102 |
+
/-- Polynomial-time gap reduction for the specific objective above. -/
|
| 103 |
+
def HasGapReduction (C : ℝ) : Prop :=
|
| 104 |
+
∃ R : Formula → Instance,
|
| 105 |
+
Polytime encodeFormula encodeInstance R ∧
|
| 106 |
+
(∃ p : Polynomial ℕ, OutputBound R p) ∧
|
| 107 |
+
(∀ F, Satisfiable F → (R F).graph.phi ≤ (R F).threshold) ∧
|
| 108 |
+
(∀ F, ¬ Satisfiable F → C * ((R F).threshold : ℝ) < ((R F).graph.phi : ℝ))
|
| 109 |
+
|
| 110 |
+
/-! ## The approximation search problem and NP-hardness -/
|
| 111 |
+
|
| 112 |
+
/-- A cut is returned as one bit per vertex, in vertex order. -/
|
| 113 |
+
def cutOfBits (G : Graph) (s : BitString) : Finset (Fin G.n) :=
|
| 114 |
+
Finset.univ.filter (fun i => s[i.val]?.getD false = true)
|
| 115 |
+
|
| 116 |
+
/-- The approximation algorithm must return a feasible cut, not just an estimated value. -/
|
| 117 |
+
def ApproxAnswer (C : ℝ) (G : Graph) (s : BitString) : Prop :=
|
| 118 |
+
s.length = G.n ∧ IsCut (cutOfBits G s) ∧
|
| 119 |
+
(G.cutRatio (cutOfBits G s) : ℝ) ≤ C * (G.phi : ℝ)
|
| 120 |
+
|
| 121 |
+
abbrev Language := BitString → Prop
|
| 122 |
+
|
| 123 |
+
/-- NP via a deterministic polynomial-time verifier and a polynomial-length certificate. -/
|
| 124 |
+
def InNP (L : Language) : Prop :=
|
| 125 |
+
∃ (V : BitString × BitString → Bool) (p : Polynomial ℕ),
|
| 126 |
+
Polytime encodePair encodeBool V ∧
|
| 127 |
+
∀ x, L x ↔ ∃ w, w.length ≤ p.eval x.length ∧ V (x, w) = true
|
| 128 |
+
|
| 129 |
+
/-- NP-hardness of the factor-`C` search problem, under one-call polynomial-time
|
| 130 |
+
oracle reductions. The postprocessor must work for *every* valid approximate
|
| 131 |
+
answer, not just for a helpful choice of answer. -/
|
| 132 |
+
def ApproximationNPHard (C : ℝ) : Prop :=
|
| 133 |
+
∀ L : Language, InNP L →
|
| 134 |
+
∃ (query : BitString → Graph) (decideAnswer : BitString × BitString → Bool),
|
| 135 |
+
Polytime id encodeGraph query ∧
|
| 136 |
+
Polytime encodePair encodeBool decideAnswer ∧
|
| 137 |
+
∀ x s, ApproxAnswer C (query x) s → (decideAnswer (x, s) = true ↔ L x)
|
| 138 |
+
|
| 139 |
+
def bitsOfCut (G : Graph) (S : Finset (Fin G.n)) : BitString :=
|
| 140 |
+
List.ofFn (fun i : Fin G.n => decide (i ∈ S))
|
| 141 |
+
|
| 142 |
+
@[simp] theorem bitsOfCut_length (G : Graph) (S : Finset (Fin G.n)) :
|
| 143 |
+
(bitsOfCut G S).length = G.n := by simp [bitsOfCut]
|
| 144 |
+
|
| 145 |
+
@[simp] theorem cutOfBits_bitsOfCut (G : Graph) (S : Finset (Fin G.n)) :
|
| 146 |
+
cutOfBits G (bitsOfCut G S) = S := by
|
| 147 |
+
ext i
|
| 148 |
+
simp [cutOfBits, bitsOfCut]
|
| 149 |
+
|
| 150 |
+
/-- Every graph has a factor-`C` approximation when `C ≥ 1`. -/
|
| 151 |
+
theorem exists_approximation_answer (G : Graph) {C : ℝ} (hC : 1 ≤ C) :
|
| 152 |
+
∃ s, ApproxAnswer C G s := by
|
| 153 |
+
obtain ⟨S, hS, hmin⟩ := G.exists_minimizing_cut
|
| 154 |
+
refine ⟨bitsOfCut G S, bitsOfCut_length G S, ?_, ?_⟩
|
| 155 |
+
· simpa using hS
|
| 156 |
+
· rw [cutOfBits_bitsOfCut, hmin]
|
| 157 |
+
have hp : (0 : ℝ) ≤ G.phi := by exact_mod_cast G.phi_nonneg
|
| 158 |
+
simpa using mul_le_mul_of_nonneg_right hC hp
|
| 159 |
+
|
| 160 |
+
/-- Rational comparison of the returned cut with a fixed rational factor `B`.
|
| 161 |
+
No real-number oracle is used by this predicate. -/
|
| 162 |
+
def decideGap (B : ℚ) (I : Instance) (s : BitString) : Bool :=
|
| 163 |
+
decide (I.graph.cutRatio (cutOfBits I.graph s) ≤ B * I.threshold)
|
| 164 |
+
|
| 165 |
+
/-- A gap for a larger rational factor decides satisfiability from every valid
|
| 166 |
+
approximation at the target real factor. -/
|
| 167 |
+
theorem gap_decision_correct {F : Formula} {I : Instance} {C : ℝ} {B : ℚ}
|
| 168 |
+
(hC : 0 ≤ C) (hCB : C ≤ (B : ℝ))
|
| 169 |
+
(hyes : Satisfiable F → I.graph.phi ≤ I.threshold)
|
| 170 |
+
(hno : ¬ Satisfiable F → (B : ℝ) * I.threshold < I.graph.phi)
|
| 171 |
+
{s : BitString} (hs : ApproxAnswer C I.graph s) :
|
| 172 |
+
decideGap B I s = true ↔ Satisfiable F := by
|
| 173 |
+
simp only [decideGap, decide_eq_true_eq]
|
| 174 |
+
constructor
|
| 175 |
+
· intro hratio
|
| 176 |
+
by_contra hunsat
|
| 177 |
+
have hno' := hno hunsat
|
| 178 |
+
have hp : (I.graph.phi : ℝ) ≤ I.graph.cutRatio (cutOfBits I.graph s) := by
|
| 179 |
+
exact_mod_cast I.graph.phi_le_cutRatio hs.2.1
|
| 180 |
+
have hr : (I.graph.cutRatio (cutOfBits I.graph s) : ℝ) ≤ (B : ℝ) * I.threshold := by
|
| 181 |
+
exact_mod_cast hratio
|
| 182 |
+
linarith only [hno', hp, hr]
|
| 183 |
+
· intro hsat
|
| 184 |
+
have hp : (I.graph.phi : ℝ) ≤ I.threshold := by exact_mod_cast hyes hsat
|
| 185 |
+
have ha : (0 : ℝ) ≤ I.threshold := by exact_mod_cast I.threshold_pos.le
|
| 186 |
+
have hbound := hs.2.2.trans (mul_le_mul_of_nonneg_left hp hC)
|
| 187 |
+
have hbound' := hbound.trans (mul_le_mul_of_nonneg_right hCB ha)
|
| 188 |
+
exact_mod_cast hbound'
|
| 189 |
+
|
| 190 |
+
end UniformSparsestCut
|
| 191 |
+
|
| 192 |
+
end OAI
|
lean/OAI/Combinatorics/SparsestCut/GaussianCDF.lean
ADDED
|
@@ -0,0 +1,144 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import OAI.Combinatorics.SparsestCut.GaussianPoincare
|
| 2 |
+
|
| 3 |
+
namespace OAI
|
| 4 |
+
|
| 5 |
+
open scoped BigOperators Topology NNReal RealInnerProductSpace InnerProductSpace Matrix ContDiff ENNReal
|
| 6 |
+
open MeasureTheory ProbabilityTheory Set Filter Matrix
|
| 7 |
+
|
| 8 |
+
noncomputable section
|
| 9 |
+
|
| 10 |
+
namespace UniformSparsestCut.GaussianCDF
|
| 11 |
+
local notation "μ" => gaussianReal 0 1
|
| 12 |
+
def Φ (x : ℝ) : ℝ := cdf μ x
|
| 13 |
+
def φ (x : ℝ) : ℝ := gaussianPDFReal 0 1 x
|
| 14 |
+
|
| 15 |
+
lemma φ_pos (x : ℝ) : 0 < φ x := gaussianPDFReal_pos _ _ _ (by norm_num)
|
| 16 |
+
lemma φ_contDiff : ContDiff ℝ ∞ φ := by unfold φ gaussianPDFReal; fun_prop
|
| 17 |
+
lemma φ_integrable : Integrable φ := integrable_gaussianPDFReal _ _
|
| 18 |
+
lemma Φ_integral (x : ℝ) : Φ x = ∫ t in Iic x, φ t := by
|
| 19 |
+
rw [Φ, cdf_eq_real, measureReal_def, gaussianReal_apply_eq_integral _ (by norm_num)]
|
| 20 |
+
exact ENNReal.toReal_ofReal (integral_nonneg (fun t => gaussianPDFReal_nonneg (0:ℝ) 1 t))
|
| 21 |
+
|
| 22 |
+
lemma Φ_primitive (x : ℝ) : Φ x = Φ 0 + ∫ t in (0:ℝ)..x, φ t := by
|
| 23 |
+
rw [Φ_integral, Φ_integral]
|
| 24 |
+
have h := intervalIntegral.integral_Iic_sub_Iic
|
| 25 |
+
(φ_integrable.integrableOn (s := Iic 0)) (φ_integrable.integrableOn (s := Iic x))
|
| 26 |
+
linarith
|
| 27 |
+
|
| 28 |
+
lemma Φ_hasDeriv (x : ℝ) : HasDerivAt Φ (φ x) x := by
|
| 29 |
+
have h := intervalIntegral.integral_hasDerivAt_right
|
| 30 |
+
(φ_contDiff.continuous.intervalIntegrable (0:ℝ) x)
|
| 31 |
+
φ_contDiff.continuous.stronglyMeasurable.stronglyMeasurableAtFilter
|
| 32 |
+
φ_contDiff.continuous.continuousAt
|
| 33 |
+
have h' := h.const_add (Φ 0)
|
| 34 |
+
convert h' using 1
|
| 35 |
+
first | rfl | exact funext Φ_primitive
|
| 36 |
+
|
| 37 |
+
lemma Φ_continuous : Continuous Φ := continuous_iff_continuousAt.mpr (fun x => (Φ_hasDeriv x).continuousAt)
|
| 38 |
+
lemma Φ_strictMono : StrictMono Φ := strictMono_of_deriv_pos (fun x => by rw [(Φ_hasDeriv x).deriv]; exact φ_pos x)
|
| 39 |
+
lemma Φ_mem (x : ℝ) : Φ x ∈ Ioo (0:ℝ) 1 := by
|
| 40 |
+
constructor
|
| 41 |
+
· exact (cdf_nonneg μ (x-1)).trans_lt (Φ_strictMono (by linarith))
|
| 42 |
+
· exact (Φ_strictMono (show x < x+1 by linarith)).trans_le (cdf_le_one μ (x+1))
|
| 43 |
+
|
| 44 |
+
lemma Φ_surj {y : ℝ} (hy : y ∈ Ioo (0:ℝ) 1) : ∃ x, Φ x = y := by
|
| 45 |
+
apply intermediate_value_univ₂_eventually₂ (l₁ := atBot) (l₂ := atTop) Φ_continuous continuous_const
|
| 46 |
+
· exact (tendsto_cdf_atBot μ).eventually (eventually_le_nhds hy.1)
|
| 47 |
+
· exact (tendsto_cdf_atTop μ).eventually (eventually_ge_nhds hy.2)
|
| 48 |
+
|
| 49 |
+
lemma Φ_map : (μ).map Φ = volume.restrict (Ioo (0:ℝ) 1) := by
|
| 50 |
+
apply Measure.ext_of_Iic
|
| 51 |
+
intro y
|
| 52 |
+
rw [Measure.map_apply Φ_continuous.measurable measurableSet_Iic,
|
| 53 |
+
Measure.restrict_apply measurableSet_Iic]
|
| 54 |
+
by_cases h0 : y ≤ 0
|
| 55 |
+
· have he : Φ ⁻¹' Iic y = ∅ := by
|
| 56 |
+
ext x; simp only [mem_preimage, mem_Iic, mem_empty_iff_false, iff_false]
|
| 57 |
+
exact not_le.mpr (h0.trans_lt (Φ_mem x).1)
|
| 58 |
+
have he' : Iic y ∩ Ioo (0:ℝ) 1 = ∅ := by ext x; simp only [mem_inter_iff, mem_Iic, mem_Ioo, mem_empty_iff_false, iff_false]; grind
|
| 59 |
+
rw [he, he', measure_empty, measure_empty]
|
| 60 |
+
by_cases h1 : 1 ≤ y
|
| 61 |
+
· have he : Φ ⁻¹' Iic y = univ := by ext x; simp only [mem_preimage, mem_Iic, mem_univ, iff_true]; exact (Φ_mem x).2.le.trans h1
|
| 62 |
+
have he' : Iic y ∩ Ioo (0:ℝ) 1 = Ioo (0:ℝ) 1 := by ext x; simp only [mem_inter_iff, mem_Iic, mem_Ioo]; constructor <;> grind
|
| 63 |
+
rw [he, he', measure_univ, Real.volume_Ioo]; norm_num
|
| 64 |
+
obtain ⟨x,hx⟩ := Φ_surj ⟨lt_of_not_ge h0, lt_of_not_ge h1⟩
|
| 65 |
+
have he : Φ ⁻¹' Iic y = Iic x := by ext z; simpa only [mem_preimage, mem_Iic, ← hx] using Φ_strictMono.le_iff_le
|
| 66 |
+
have he' : Iic y ∩ Ioo (0:ℝ) 1 = Ioc (0:ℝ) y := by
|
| 67 |
+
ext z; simp only [mem_inter_iff, mem_Iic, mem_Ioo, mem_Ioc]; grind
|
| 68 |
+
rw [he, he', ← ofReal_cdf μ x, Real.volume_Ioc, sub_zero, ← hx]
|
| 69 |
+
rfl
|
| 70 |
+
|
| 71 |
+
def ψ (x : ℝ) : ℝ := 2*Φ x-1
|
| 72 |
+
lemma ψ_hasDeriv (x : ℝ) : HasDerivAt ψ (2*φ x) x := (Φ_hasDeriv x).const_mul 2 |>.sub_const 1
|
| 73 |
+
lemma ψ_mem (x : ℝ) : ψ x ∈ Ioo (-1:ℝ) 1 := by
|
| 74 |
+
have h := Φ_mem x
|
| 75 |
+
dsimp [ψ]; constructor <;> linarith [h.1,h.2]
|
| 76 |
+
|
| 77 |
+
lemma ψ_contDiff : ContDiff ℝ 1 ψ := by
|
| 78 |
+
apply contDiff_one_iff_deriv.mpr
|
| 79 |
+
constructor
|
| 80 |
+
· exact fun x => (ψ_hasDeriv x).differentiableAt
|
| 81 |
+
· have he : deriv ψ = fun x => 2*φ x := funext (fun x => (ψ_hasDeriv x).deriv)
|
| 82 |
+
rw [he]
|
| 83 |
+
exact continuous_const.mul φ_contDiff.continuous
|
| 84 |
+
|
| 85 |
+
lemma ψ_deriv_bound (x : ℝ) : |2*φ x| ≤ 1 := by
|
| 86 |
+
have hs : 0 < Real.sqrt (2*Real.pi) := Real.sqrt_pos.mpr (by positivity)
|
| 87 |
+
have hs2 := Real.sq_sqrt (show 0 ≤ 2*Real.pi by positivity)
|
| 88 |
+
have hge : 2 ≤ Real.sqrt (2*Real.pi) := by nlinarith [Real.pi_gt_three]
|
| 89 |
+
have he : Real.exp (-x^2/2) ≤ 1 := Real.exp_le_one_iff.mpr (by nlinarith [sq_nonneg x])
|
| 90 |
+
have he0 : 0 ≤ Real.exp (-x^2/2) := (Real.exp_pos _).le
|
| 91 |
+
rw [abs_of_pos (mul_pos (by norm_num : (0:ℝ)<2) (φ_pos x))]
|
| 92 |
+
change 2*((Real.sqrt (2*Real.pi*1))⁻¹*Real.exp (-(x-0)^2/(2*1))) ≤ 1
|
| 93 |
+
simp only [mul_one, sub_zero]
|
| 94 |
+
calc
|
| 95 |
+
_ = (Real.sqrt (2*Real.pi))⁻¹*(2*Real.exp (-x^2/2)) := by ring
|
| 96 |
+
_ ≤ 1 := (inv_mul_le_iff₀ hs).mpr (by nlinarith)
|
| 97 |
+
|
| 98 |
+
def uniform : Measure ℝ := (2:ℝ��0∞)⁻¹ • volume.restrict (Ioo (-1:ℝ) 1)
|
| 99 |
+
|
| 100 |
+
lemma ψ_map : (μ).map ψ = uniform := by
|
| 101 |
+
apply Measure.ext_of_Iic
|
| 102 |
+
intro y
|
| 103 |
+
rw [Measure.map_apply ψ_contDiff.continuous.measurable measurableSet_Iic]
|
| 104 |
+
change μ (ψ ⁻¹' Iic y) = (2:ℝ≥0∞)⁻¹ * (volume.restrict (Ioo (-1:ℝ) 1)) (Iic y)
|
| 105 |
+
rw [Measure.restrict_apply measurableSet_Iic]
|
| 106 |
+
by_cases h0 : y ≤ -1
|
| 107 |
+
· have he : ψ ⁻¹' Iic y = ∅ := by
|
| 108 |
+
ext x; simp only [mem_preimage, mem_Iic, mem_empty_iff_false, iff_false]
|
| 109 |
+
exact not_le.mpr (h0.trans_lt (ψ_mem x).1)
|
| 110 |
+
have he' : Iic y ∩ Ioo (-1:ℝ) 1 = ∅ := by
|
| 111 |
+
ext x; simp only [mem_inter_iff, mem_Iic, mem_Ioo, mem_empty_iff_false, iff_false]; grind
|
| 112 |
+
simp [he,he']
|
| 113 |
+
by_cases h1 : 1 ≤ y
|
| 114 |
+
· have he : ψ ⁻¹' Iic y = univ := by
|
| 115 |
+
ext x; simp only [mem_preimage, mem_Iic, mem_univ, iff_true]
|
| 116 |
+
exact (ψ_mem x).2.le.trans h1
|
| 117 |
+
have he' : Iic y ∩ Ioo (-1:ℝ) 1 = Ioo (-1:ℝ) 1 := by
|
| 118 |
+
ext x; simp only [mem_inter_iff, mem_Iic, mem_Ioo]; constructor <;> grind
|
| 119 |
+
rw [he,he',measure_univ,Real.volume_Ioo]; norm_num;
|
| 120 |
+
exact (ENNReal.inv_mul_cancel (by norm_num) (by norm_num)).symm
|
| 121 |
+
have hy : (y+1)/2 ∈ Ioo (0:ℝ) 1 := by constructor <;> linarith
|
| 122 |
+
obtain ⟨x,hx⟩ := Φ_surj hy
|
| 123 |
+
have he : ψ ⁻¹' Iic y = Iic x := by
|
| 124 |
+
ext z
|
| 125 |
+
simp only [mem_preimage, mem_Iic, ψ]
|
| 126 |
+
rw [show y = 2*Φ x-1 by linarith]
|
| 127 |
+
rw [show 2*Φ z-1 ≤ 2*Φ x-1 ↔ Φ z ≤ Φ x by constructor <;> intro hn <;> linarith]
|
| 128 |
+
exact Φ_strictMono.le_iff_le
|
| 129 |
+
have he' : Iic y ∩ Ioo (-1:ℝ) 1 = Ioc (-1:ℝ) y := by
|
| 130 |
+
ext z; simp only [mem_inter_iff, mem_Iic, mem_Ioo, mem_Ioc]; grind
|
| 131 |
+
rw [he,he',← ofReal_cdf μ x,Real.volume_Ioc]
|
| 132 |
+
change ENNReal.ofReal (Φ x) = (2:ℝ≥0∞)⁻¹ * ENNReal.ofReal (y- -1)
|
| 133 |
+
rw [hx,show y- -1 = y+1 by ring,ENNReal.ofReal_div_of_pos (by norm_num : (0:ℝ)<2)]
|
| 134 |
+
simp [div_eq_mul_inv,mul_comm]
|
| 135 |
+
|
| 136 |
+
instance uniform_probability : IsProbabilityMeasure uniform := by
|
| 137 |
+
rw [← ψ_map]
|
| 138 |
+
infer_instance
|
| 139 |
+
|
| 140 |
+
end UniformSparsestCut.GaussianCDF
|
| 141 |
+
|
| 142 |
+
end
|
| 143 |
+
|
| 144 |
+
end OAI
|
lean/OAI/Combinatorics/SparsestCut/GaussianNonparallel.lean
ADDED
|
@@ -0,0 +1,116 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import OAI.Combinatorics.SparsestCut.Directions
|
| 2 |
+
|
| 3 |
+
namespace OAI
|
| 4 |
+
|
| 5 |
+
open scoped BigOperators Topology NNReal RealInnerProductSpace InnerProductSpace Matrix ContDiff ENNReal
|
| 6 |
+
open MeasureTheory ProbabilityTheory Set Filter Matrix
|
| 7 |
+
|
| 8 |
+
noncomputable section
|
| 9 |
+
|
| 10 |
+
namespace UniformSparsestCut.GaussianNonparallel
|
| 11 |
+
|
| 12 |
+
variable {m : ℕ}
|
| 13 |
+
local notation "E" => EuclideanSpace ℝ (Fin m)
|
| 14 |
+
local notation "μ" => stdGaussian E
|
| 15 |
+
|
| 16 |
+
lemma gaussian_inner_zero_measure (v : E) (hv : v ≠ 0) :
|
| 17 |
+
(stdGaussian E) {x | inner ℝ v x = 0} = 0 := by
|
| 18 |
+
let c : ℝ≥0 := ⟨‖v‖^2, sq_nonneg _⟩
|
| 19 |
+
have hc : c ≠ 0 := by
|
| 20 |
+
intro h
|
| 21 |
+
have := congrArg (fun x : ℝ≥0 => (x : ℝ)) h
|
| 22 |
+
change ‖v‖^2 = 0 at this
|
| 23 |
+
exact hv (norm_eq_zero.mp (sq_eq_zero_iff.mp this))
|
| 24 |
+
let := nullSingletonClass_gaussianReal («μ» := 0) hc
|
| 25 |
+
have hmap : (stdGaussian E).map (fun x => inner ℝ v x) = gaussianReal 0 c := by
|
| 26 |
+
have h := IsGaussian.map_eq_gaussianReal («μ» := stdGaussian E) (innerSL ℝ v)
|
| 27 |
+
simp only [integral_strongDual_stdGaussian, variance_dual_stdGaussian,
|
| 28 |
+
innerSL_apply_norm] at h
|
| 29 |
+
convert h using 2
|
| 30 |
+
· rfl
|
| 31 |
+
· apply NNReal.eq
|
| 32 |
+
change ‖v‖^2 = ((‖v‖^2).toNNReal : ℝ)
|
| 33 |
+
simp
|
| 34 |
+
have h := congrArg (fun ν : Measure ℝ => ν {0}) hmap
|
| 35 |
+
rw [Measure.map_apply (by fun_prop) (measurableSet_singleton _), measure_singleton] at h
|
| 36 |
+
exact h
|
| 37 |
+
|
| 38 |
+
lemma gaussian_coordinate_ne (i : Fin m) : ∀ᵐ x : E ∂μ, x i ≠ 0 := by
|
| 39 |
+
have hv : (EuclideanSpace.single i 1 : E) ≠ 0 := by
|
| 40 |
+
intro h
|
| 41 |
+
have hh := congrArg (fun x : E => x i) h
|
| 42 |
+
simp at hh
|
| 43 |
+
have h := gaussian_inner_zero_measure (EuclideanSpace.single i 1) hv
|
| 44 |
+
apply ae_iff.mpr
|
| 45 |
+
simpa [EuclideanSpace.inner_single_left] using h
|
| 46 |
+
|
| 47 |
+
def cross (i j : Fin m) (x y : E) : ℝ := x i * y j - x j * y i
|
| 48 |
+
|
| 49 |
+
lemma gaussian_cross_zero_measure (i j : Fin m) (hij : i ≠ j) :
|
| 50 |
+
((μ).prod μ) {z : E × E | cross i j z.1 z.2 = 0} = 0 := by
|
| 51 |
+
rw [Measure.prod_apply (by unfold cross; measurability)]
|
| 52 |
+
apply lintegral_eq_zero_of_ae_eq_zero
|
| 53 |
+
filter_upwards [gaussian_coordinate_ne i] with x hx
|
| 54 |
+
let v : E := EuclideanSpace.single j (x i) - EuclideanSpace.single i (x j)
|
| 55 |
+
have hv : v ≠ 0 := by
|
| 56 |
+
intro h
|
| 57 |
+
have hh := congrArg (fun x : E => x j) h
|
| 58 |
+
have hh' : x i = 0 := by simpa [v, PiLp.single_apply, hij, Ne.symm hij] using hh
|
| 59 |
+
exact hx hh'
|
| 60 |
+
have hid (y : E) : inner ℝ v y = cross i j x y := by
|
| 61 |
+
simp [v, cross, inner_sub_left, EuclideanSpace.inner_single_left]
|
| 62 |
+
simpa only [preimage_ofPred_eq, hid, Pi.zero_apply] using gaussian_inner_zero_measure v hv
|
| 63 |
+
|
| 64 |
+
lemma ae_cross_ne (i j : Fin m) (hij : i ≠ j) :
|
| 65 |
+
∀ᵐ z : E × E ∂(μ).prod μ, cross i j z.1 z.2 ≠ 0 := by
|
| 66 |
+
apply ae_iff.mpr
|
| 67 |
+
simpa only [not_not] using gaussian_cross_zero_measure i j hij
|
| 68 |
+
|
| 69 |
+
lemma iid_cross_ne {N : ℕ} (i j : Fin m) (hij : i ≠ j) (a b : Fin N) (hab : a ≠ b) :
|
| 70 |
+
∀ᵐ g : Fin N → E ∂Measure.pi (fun _ => μ), cross i j (g a) (g b) ≠ 0 := by
|
| 71 |
+
let ν := Measure.pi (fun _ : Fin N => μ)
|
| 72 |
+
have hind : iIndepFun (fun k (g : Fin N → E) => g k) ν :=
|
| 73 |
+
iIndepFun_pi («μ» := fun _ : Fin N => μ) (fun _ => aemeasurable_id)
|
| 74 |
+
have hmap := (hind.indepFun hab).map_prod_eq_prod_map_map
|
| 75 |
+
(measurable_pi_apply a).aemeasurable (measurable_pi_apply b).aemeasurable
|
| 76 |
+
rw [(measurePreserving_eval (fun _ : Fin N => μ) a).map_eq,
|
| 77 |
+
(measurePreserving_eval (fun _ : Fin N => μ) b).map_eq] at hmap
|
| 78 |
+
have hh := congrArg (fun ν : Measure (E × E) => ν {z | cross i j z.1 z.2 = 0}) hmap
|
| 79 |
+
rw [Measure.map_apply (by fun_prop) (by unfold cross; measurability),
|
| 80 |
+
gaussian_cross_zero_measure i j hij] at hh
|
| 81 |
+
apply ae_iff.mpr
|
| 82 |
+
simpa only [ν, preimage_ofPred_eq, not_not] using hh
|
| 83 |
+
|
| 84 |
+
lemma iid_pairwise_nonparallel {N : ℕ} (hm : 2 ≤ m) :
|
| 85 |
+
∀ᵐ g : Fin N → E ∂Measure.pi (fun _ => μ),
|
| 86 |
+
∀ a b, a ≠ b → ∀ t : ℝ, g a ≠ t • g b := by
|
| 87 |
+
let i : Fin m := ⟨0, by omega⟩
|
| 88 |
+
let j : Fin m := ⟨1, by omega⟩
|
| 89 |
+
have hij : i ≠ j := by intro h; have := congrArg Fin.val h; simp [i,j] at this
|
| 90 |
+
have hh : ∀ a b : Fin N, ∀ᵐ g : Fin N → E ∂Measure.pi (fun _ => μ),
|
| 91 |
+
a ≠ b → cross i j (g a) (g b) ≠ 0 := by
|
| 92 |
+
intro a b
|
| 93 |
+
by_cases hab : a = b
|
| 94 |
+
· exact ae_of_all _ (fun _ hn => (hn hab).elim)
|
| 95 |
+
· filter_upwards [iid_cross_ne i j hij a b hab] with g hg using fun _ => hg
|
| 96 |
+
have hall := (ae_all_iff.mpr (fun a => ae_all_iff.mpr (hh a)))
|
| 97 |
+
filter_upwards [hall] with g hg
|
| 98 |
+
intro a b hab t h
|
| 99 |
+
apply hg a b hab
|
| 100 |
+
rw [h]
|
| 101 |
+
simp [cross]
|
| 102 |
+
ring
|
| 103 |
+
|
| 104 |
+
lemma charts_pairwise_nonparallel {N S : ℕ} (hm : 2 ≤ m) :
|
| 105 |
+
∀ᵐ g : Fin S → Fin N → E ∂Measure.pi (fun _ => Measure.pi (fun _ => μ)),
|
| 106 |
+
∀ s a b, a ≠ b → ∀ t : ℝ, g s a ≠ t • g s b := by
|
| 107 |
+
apply ae_all_iff.mpr
|
| 108 |
+
intro s
|
| 109 |
+
exact (measurePreserving_eval (fun _ : Fin S => Measure.pi (fun _ : Fin N => μ)) s).quasiMeasurePreserving.ae
|
| 110 |
+
(iid_pairwise_nonparallel hm)
|
| 111 |
+
|
| 112 |
+
end UniformSparsestCut.GaussianNonparallel
|
| 113 |
+
|
| 114 |
+
end
|
| 115 |
+
|
| 116 |
+
end OAI
|
lean/OAI/Combinatorics/SparsestCut/GaussianPoincare.lean
ADDED
|
@@ -0,0 +1,155 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import OAI.Combinatorics.SparsestCut.ContractionCore
|
| 2 |
+
|
| 3 |
+
namespace OAI
|
| 4 |
+
|
| 5 |
+
universe u1
|
| 6 |
+
|
| 7 |
+
open scoped BigOperators Topology NNReal RealInnerProductSpace InnerProductSpace Matrix ContDiff ENNReal
|
| 8 |
+
open MeasureTheory ProbabilityTheory Set Filter Matrix
|
| 9 |
+
|
| 10 |
+
noncomputable section
|
| 11 |
+
|
| 12 |
+
namespace UniformSparsestCut.GaussianPoincare
|
| 13 |
+
variable {E : Type u1} [NormedAddCommGroup E] [InnerProductSpace ℝ E]
|
| 14 |
+
[FiniteDimensional ℝ E] [MeasurableSpace E] [BorelSpace E]
|
| 15 |
+
local notation "μ" => stdGaussian E
|
| 16 |
+
|
| 17 |
+
lemma gaussian_dual_sq (L : StrongDual ℝ E) : ∫ x, (L x)^2 ∂μ = ‖L‖^2 := by
|
| 18 |
+
have h := variance_dual_stdGaussian L
|
| 19 |
+
rw [variance_eq_integral (by fun_prop), integral_strongDual_stdGaussian] at h
|
| 20 |
+
simpa only [sub_zero] using h
|
| 21 |
+
|
| 22 |
+
lemma gaussian_dual_abs (L : StrongDual ℝ E) : ∫ x, |L x| ∂μ ≤ ‖L‖ := by
|
| 23 |
+
by_cases hz : L = 0
|
| 24 |
+
· simp [hz]
|
| 25 |
+
have h0 : 0 < ‖L‖ := norm_pos_iff.mpr hz
|
| 26 |
+
have hL : MemLp (fun x => L x) 2 μ := IsGaussian.memLp_dual _ _ _ (by norm_num)
|
| 27 |
+
have hi : Integrable (fun x => (|L x|-‖L‖)^2) μ := by
|
| 28 |
+
simpa using (hL.norm.sub (memLp_const ‖L‖)).integrable_sq
|
| 29 |
+
have hn : 0 ≤ ∫ x, (|L x|-‖L‖)^2 ∂μ := integral_nonneg (fun _ => sq_nonneg _)
|
| 30 |
+
have he : (∫ x, (|L x|-‖L‖)^2 ∂μ) = 2*‖L‖^2-2*‖L‖*(∫ x, |L x| ∂μ) := by
|
| 31 |
+
simp_rw [sub_sq, sq_abs]
|
| 32 |
+
have hc := ((hL.integrable (by norm_num)).abs.const_mul 2).mul_const ‖L‖
|
| 33 |
+
rw [integral_add (f := fun x => L x^2-2*|L x| *‖L‖)
|
| 34 |
+
(g := fun _ => ‖L‖^2) (hL.integrable_sq.sub hc) (integrable_const _),
|
| 35 |
+
integral_sub (f := fun x => L x^2) (g := fun x => 2*|L x| *‖L‖) hL.integrable_sq hc]
|
| 36 |
+
rw [gaussian_dual_sq]
|
| 37 |
+
simp only [integral_const, measureReal_def, measure_univ, ENNReal.toReal_one, smul_eq_mul, one_mul]
|
| 38 |
+
rw [integral_mul_const, integral_const_mul]
|
| 39 |
+
ring
|
| 40 |
+
rw [he] at hn
|
| 41 |
+
nlinarith
|
| 42 |
+
|
| 43 |
+
noncomputable def path (t : ℝ) (z : E × E) : E := Real.cos t • z.1 + Real.sin t • z.2
|
| 44 |
+
noncomputable def tangent (t : ℝ) (z : E × E) : E := -Real.sin t • z.1 + Real.cos t • z.2
|
| 45 |
+
|
| 46 |
+
omit [FiniteDimensional ℝ E] [MeasurableSpace E] [BorelSpace E] in
|
| 47 |
+
lemma path_hasDeriv (t : ℝ) (z : E × E) : HasDerivAt (fun u => path u z) (tangent t z) t := by
|
| 48 |
+
exact ((Real.hasDerivAt_cos t).smul_const z.1).add ((Real.hasDerivAt_sin t).smul_const z.2)
|
| 49 |
+
|
| 50 |
+
omit [FiniteDimensional ℝ E] [MeasurableSpace E] [BorelSpace E] in
|
| 51 |
+
lemma tangent_norm_le (t : ℝ) (z : E × E) : ‖tangent t z‖ ≤ ‖z.1‖ + ‖z.2‖ := by
|
| 52 |
+
calc
|
| 53 |
+
_ ≤ ‖-Real.sin t • z.1‖ + ‖Real.cos t • z.2‖ := norm_add_le _ _
|
| 54 |
+
_ = |Real.sin t| *‖z.1‖ + |Real.cos t| *‖z.2‖ := by simp [norm_smul, Real.norm_eq_abs]
|
| 55 |
+
_ ≤ 1*‖z.1‖ + 1*‖z.2‖ := add_le_add (mul_le_mul_of_nonneg_right (Real.abs_sin_le_one _) (norm_nonneg _))
|
| 56 |
+
(mul_le_mul_of_nonneg_right (Real.abs_cos_le_one _) (norm_nonneg _))
|
| 57 |
+
_ = _ := by ring
|
| 58 |
+
|
| 59 |
+
lemma integral_rotation (f : E × E → ℝ) (hf : AEStronglyMeasurable f ((μ).prod μ)) (t : ℝ) :
|
| 60 |
+
∫ z, f (path t z, tangent t z) ∂((μ).prod μ) = ∫ z, f z ∂((μ).prod μ) := by
|
| 61 |
+
have hr := IsGaussian.map_rotation_eq_self (integral_id_stdGaussian (E := E)) t
|
| 62 |
+
have hm : AEMeasurable (ContinuousLinearMap.rotation (E := E) t) ((μ).prod μ) := by fun_prop
|
| 63 |
+
have h := integral_map hm (hr ▸ hf)
|
| 64 |
+
exact h.symm.trans (congrArg (fun ν => ∫ z, f z ∂ν) hr)
|
| 65 |
+
|
| 66 |
+
lemma derivative_integrable (h : E → ℝ) (hh : ContDiff ℝ 1 h) {M : ℝ} (_hM : 0 ≤ M)
|
| 67 |
+
(hb : ∀ x, ‖fderiv ℝ h x‖ ≤ M) :
|
| 68 |
+
Integrable (fun z : E × E => |fderiv ℝ h z.1 z.2|) ((μ).prod μ) := by
|
| 69 |
+
have hi : Integrable (fun z : E × E => M*‖z.2‖) ((μ).prod μ) :=
|
| 70 |
+
((IsGaussian.integrable_id («μ» := μ)).norm.comp_snd μ).const_mul M
|
| 71 |
+
apply hi.mono' (by have hc := hh.continuous_fderiv (by norm_num); fun_prop)
|
| 72 |
+
filter_upwards with z
|
| 73 |
+
simp only [Real.norm_eq_abs, abs_abs]
|
| 74 |
+
exact (ContinuousLinearMap.le_opNorm _ _).trans (mul_le_mul_of_nonneg_right (hb _) (norm_nonneg _))
|
| 75 |
+
|
| 76 |
+
lemma derivative_average_bound (h : E → ℝ) (hh : ContDiff ℝ 1 h) {M : ℝ} (hM : 0 ≤ M)
|
| 77 |
+
(hb : ∀ x, ‖fderiv ℝ h x‖ ≤ M) :
|
| 78 |
+
(∫ z : E × E, |fderiv ℝ h z.1 z.2| ∂((μ).prod μ)) ≤ ∫ x, ‖fderiv ℝ h x‖ ∂μ := by
|
| 79 |
+
rw [integral_prod _ (derivative_integrable h hh hM hb)]
|
| 80 |
+
refine integral_mono_ae (derivative_integrable h hh hM hb).integral_prod_left ?_ ?_
|
| 81 |
+
· exact (integrable_const M).mono' (by have hc := hh.continuous_fderiv (by norm_num); fun_prop)
|
| 82 |
+
(ae_of_all _ fun x => by simpa using hb x)
|
| 83 |
+
· filter_upwards with x using gaussian_dual_abs (fderiv ℝ h x)
|
| 84 |
+
|
| 85 |
+
omit [FiniteDimensional ℝ E] [MeasurableSpace E] [BorelSpace E] in
|
| 86 |
+
lemma endpoint_bound (h : E → ℝ) (hh : ContDiff ℝ 1 h) (z : E × E) :
|
| 87 |
+
|h z.1-h z.2| ≤ ∫ t in (0 : ℝ)..(Real.pi/2),
|
| 88 |
+
|fderiv ℝ h (path t z) (tangent t z)| := by
|
| 89 |
+
have hd (t : ℝ) : HasDerivAt (fun t => h (path t z))
|
| 90 |
+
(fderiv ℝ h (path t z) (tangent t z)) t :=
|
| 91 |
+
((hh.differentiable (by norm_num) _).hasFDerivAt).comp_hasDerivAt t (path_hasDeriv t z)
|
| 92 |
+
have hc : Continuous (fun t => fderiv ℝ h (path t z) (tangent t z)) := by
|
| 93 |
+
have hD := hh.continuous_fderiv (by norm_num)
|
| 94 |
+
unfold path tangent
|
| 95 |
+
fun_prop
|
| 96 |
+
have he := intervalIntegral.integral_eq_sub_of_hasDerivAt (fun t _ => hd t)
|
| 97 |
+
(hc.intervalIntegrable 0 (Real.pi/2))
|
| 98 |
+
have hn := intervalIntegral.abs_integral_le_integral_abs («μ» := volume)
|
| 99 |
+
(f := fun t => fderiv ℝ h (path t z) (tangent t z))
|
| 100 |
+
(by positivity : (0 : ℝ) ≤ Real.pi/2)
|
| 101 |
+
rw [he] at hn
|
| 102 |
+
simpa [path, abs_sub_comm] using hn
|
| 103 |
+
|
| 104 |
+
lemma rotation_first_moment (h : E → ℝ) (hh : ContDiff ℝ 1 h)
|
| 105 |
+
{M B : ℝ} (hM : 0 ≤ M) (hb : ∀ x, ‖fderiv ℝ h x‖ ≤ M)
|
| 106 |
+
(hB : ∀ x, ‖h x‖ ≤ B) :
|
| 107 |
+
(∫ z : E × E, |h z.1-h z.2| ∂((μ).prod μ)) ≤
|
| 108 |
+
(Real.pi/2) * ∫ x, ‖fderiv ℝ h x‖ ∂μ := by
|
| 109 |
+
let b : ℝ := Real.pi/2
|
| 110 |
+
have hb0 : 0 ≤ b := by dsimp [b]; positivity
|
| 111 |
+
let ν := volume.restrict (Ioc (0 : ℝ) b)
|
| 112 |
+
have : IsFiniteMeasure ν := by dsimp [ν]; infer_instance
|
| 113 |
+
let g (t : ℝ) (z : E × E) := |fderiv ℝ h (path t z) (tangent t z)|
|
| 114 |
+
have hc : Continuous (Function.uncurry g) := by
|
| 115 |
+
have hD := hh.continuous_fderiv (by norm_num)
|
| 116 |
+
dsimp [g, Function.uncurry, path, tangent]
|
| 117 |
+
fun_prop
|
| 118 |
+
have hnorm : Integrable (fun z : E × E => ‖z.1‖+‖z.2‖) ((μ).prod μ) :=
|
| 119 |
+
((IsGaussian.integrable_id («μ» := stdGaussian E)).norm.comp_fst _).add
|
| 120 |
+
((IsGaussian.integrable_id («μ» := stdGaussian E)).norm.comp_snd _)
|
| 121 |
+
have hI : Integrable (Function.uncurry g) (ν.prod ((μ).prod μ)) := by
|
| 122 |
+
apply ((hnorm.const_mul M).comp_snd ν).mono' hc.aestronglyMeasurable
|
| 123 |
+
filter_upwards with x
|
| 124 |
+
dsimp [g, Function.uncurry]
|
| 125 |
+
simp only [ abs_abs]
|
| 126 |
+
exact (ContinuousLinearMap.le_opNorm _ _).trans
|
| 127 |
+
((mul_le_mul_of_nonneg_right (hb _) (norm_nonneg _)).trans
|
| 128 |
+
(mul_le_mul_of_nonneg_left (tangent_norm_le _ _) hM))
|
| 129 |
+
have hInt : Integrable (fun z => ∫ t in (0 : ℝ)..b, g t z) ((μ).prod μ) := by
|
| 130 |
+
simpa only [intervalIntegral.integral_of_le hb0, ν, Function.uncurry_apply_pair] using hI.integral_prod_right
|
| 131 |
+
have hLeft : Integrable (fun z : E × E => |h z.1-h z.2|) ((μ).prod μ) := by
|
| 132 |
+
apply (integrable_const (2*B)).mono' (by fun_prop)
|
| 133 |
+
filter_upwards with z
|
| 134 |
+
simpa only [Real.norm_eq_abs, abs_abs] using
|
| 135 |
+
(norm_sub_le (h z.1) (h z.2)).trans (by linarith [hB z.1,hB z.2])
|
| 136 |
+
have hrotate (t : ℝ) : (∫ z, g t z ∂((μ).prod μ)) =
|
| 137 |
+
∫ z : E × E, |fderiv ℝ h z.1 z.2| ∂((μ).prod μ) := by
|
| 138 |
+
exact integral_rotation _ (derivative_integrable h hh hM hb).aestronglyMeasurable t
|
| 139 |
+
calc
|
| 140 |
+
_ ≤ ∫ z : E × E, (∫ t in (0 : ℝ)..b, g t z) ∂((μ).prod μ) :=
|
| 141 |
+
integral_mono hLeft hInt (endpoint_bound h hh)
|
| 142 |
+
_ = ∫ t in (0 : ℝ)..b, ∫ z, g t z ∂((μ).prod μ) := by
|
| 143 |
+
symm
|
| 144 |
+
apply intervalIntegral_integral_swap
|
| 145 |
+
simpa only [uIoc_of_le hb0] using hI
|
| 146 |
+
_ = b * ∫ z : E × E, |fderiv ℝ h z.1 z.2| ∂((μ).prod μ) := by
|
| 147 |
+
simp_rw [hrotate]
|
| 148 |
+
simp [intervalIntegral.integral_const, smul_eq_mul]
|
| 149 |
+
_ ≤ _ := mul_le_mul_of_nonneg_left (derivative_average_bound h hh hM hb) hb0
|
| 150 |
+
|
| 151 |
+
end UniformSparsestCut.GaussianPoincare
|
| 152 |
+
|
| 153 |
+
end
|
| 154 |
+
|
| 155 |
+
end OAI
|
lean/OAI/Combinatorics/SparsestCut/GaussianTools.lean
ADDED
|
@@ -0,0 +1,514 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import OAI.Combinatorics.SparsestCut.Model
|
| 2 |
+
|
| 3 |
+
namespace OAI
|
| 4 |
+
|
| 5 |
+
universe u1 u2
|
| 6 |
+
|
| 7 |
+
open scoped BigOperators Topology NNReal RealInnerProductSpace InnerProductSpace Matrix ContDiff ENNReal
|
| 8 |
+
open MeasureTheory ProbabilityTheory Set Filter Matrix
|
| 9 |
+
|
| 10 |
+
noncomputable section
|
| 11 |
+
|
| 12 |
+
namespace UniformSparsestCut.GaussianTools
|
| 13 |
+
|
| 14 |
+
section Concentration
|
| 15 |
+
variable {Ω : Type u1} [MeasurableSpace Ω] {μ : Measure Ω} [IsProbabilityMeasure μ]
|
| 16 |
+
|
| 17 |
+
lemma subgaussian_abs_tail {X : Ω → ℝ} {c : ℝ≥0}
|
| 18 |
+
(hX : HasSubgaussianMGF X c μ) {u : ℝ} (hu : 0 ≤ u) :
|
| 19 |
+
μ.real {sample | u < |X sample|} ≤ 2 * Real.exp (-u^2 / (2 * c)) := by
|
| 20 |
+
have hsub : {sample | u < |X sample|} ⊆ {sample | u ≤ X sample} ∪ {sample | u ≤ -X sample} := by
|
| 21 |
+
intro sample hω
|
| 22 |
+
change u < |X sample| at hω
|
| 23 |
+
rcases lt_abs.mp hω with h | h
|
| 24 |
+
· exact Or.inl h.le
|
| 25 |
+
· exact Or.inr h.le
|
| 26 |
+
calc
|
| 27 |
+
_ ≤ μ.real ({sample | u ≤ X sample} ∪ {sample | u ≤ -X sample}) := measureReal_mono hsub
|
| 28 |
+
_ ≤ μ.real {sample | u ≤ X sample} + μ.real {sample | u ≤ -X sample} := measureReal_union_le _ _
|
| 29 |
+
_ ≤ Real.exp (-u^2 / (2 * c)) + Real.exp (-u^2 / (2 * c)) :=
|
| 30 |
+
add_le_add (hX.measure_ge_le hu) (hX.neg.measure_ge_le hu)
|
| 31 |
+
_ = _ := by ring
|
| 32 |
+
|
| 33 |
+
theorem bounded_concentration {n : ℕ} (hn : 0 < n) (X : Fin n → Ω → ℝ)
|
| 34 |
+
(hmeas : ∀ i, AEMeasurable (X i) μ) (hind : iIndepFun X μ)
|
| 35 |
+
{B : ℝ} (hB : 0 < B) (hbound : ∀ i, ∀ᵐ sample ∂μ, |X i sample| ≤ B)
|
| 36 |
+
{u : ℝ} (hu : 0 ≤ u) :
|
| 37 |
+
μ.real {sample | u < |(∑ i, (X i sample - ∫ z, X i z ∂μ)) / (n : ℝ)|} ≤
|
| 38 |
+
2 * Real.exp (-(n : ℝ) * u^2 / (2 * B^2)) := by
|
| 39 |
+
classical
|
| 40 |
+
let Y : Fin n → Ω → ℝ := fun i sample => X i sample - ∫ z, X i z ∂μ
|
| 41 |
+
have hY (i : Fin n) : HasSubgaussianMGF (Y i) ⟨B^2, sq_nonneg B⟩ μ := by
|
| 42 |
+
have hh := hasSubgaussianMGF_of_mem_Icc (hmeas i)
|
| 43 |
+
(show ∀ᵐ sample ∂μ, X i sample ∈ Icc (-B) B by
|
| 44 |
+
filter_upwards [hbound i] with sample hω using abs_le.mp hω)
|
| 45 |
+
have hc : ((‖B - -B‖₊ / 2) ^ 2) = (⟨B^2, sq_nonneg B⟩ : ℝ≥0) := by
|
| 46 |
+
ext
|
| 47 |
+
change (‖B - -B‖ / 2) ^ 2 = B ^ 2
|
| 48 |
+
rw [Real.norm_eq_abs]
|
| 49 |
+
rw [abs_of_nonneg (by linarith : 0 ≤ B - -B)]
|
| 50 |
+
ring
|
| 51 |
+
exact (congrArg (fun variance : ℝ≥0 => HasSubgaussianMGF (Y i) variance μ) hc).mp hh
|
| 52 |
+
have hYi : iIndepFun Y μ := hind.comp (fun i z => z - ∫ z, X i z ∂μ) (fun i => by fun_prop)
|
| 53 |
+
have hsum := HasSubgaussianMGF.sum_of_iIndepFun hYi
|
| 54 |
+
(s := Finset.univ) (fun i hi => hY i)
|
| 55 |
+
have havg := hsum.const_mul ((n : ℝ)⁻¹)
|
| 56 |
+
have htail := subgaussian_abs_tail havg hu
|
| 57 |
+
have hn0 : (n : ℝ) ≠ 0 := by exact_mod_cast hn.ne'
|
| 58 |
+
convert htail using 1
|
| 59 |
+
· congr 1; ext sample
|
| 60 |
+
simp only [Y, div_eq_mul_inv, mul_comm]
|
| 61 |
+
· congr 2
|
| 62 |
+
have hc : ((⟨(n : ℝ)⁻¹ ^ 2, sq_nonneg _⟩ : ℝ≥0) *
|
| 63 |
+
∑ _ : Fin n, (⟨B^2, sq_nonneg _⟩ : ℝ≥0) : ℝ≥0) =
|
| 64 |
+
(⟨B^2 / n, div_nonneg (sq_nonneg _) (by positivity)⟩ : ℝ≥0) := by
|
| 65 |
+
apply NNReal.eq
|
| 66 |
+
change (n : ℝ)⁻¹ ^ 2 * ↑(∑ _ : Fin n, (⟨B^2, sq_nonneg _⟩ : ℝ≥0)) = B^2 / n
|
| 67 |
+
simp only [Finset.sum_const, Finset.card_univ, Fintype.card_fin]
|
| 68 |
+
change (n : ℝ)⁻¹ ^ 2 * ↑(n • (⟨B^2, sq_nonneg _⟩ : ℝ≥0)) = B^2 / n
|
| 69 |
+
simp only [nsmul_eq_mul]
|
| 70 |
+
change (n : ℝ)⁻¹ ^ 2 * ((n : ℝ) * B^2) = B^2 / n
|
| 71 |
+
field_simp
|
| 72 |
+
|
| 73 |
+
change -(n : ℝ) * u^2 / (2 * B^2) =
|
| 74 |
+
-u^2 / (2 * (((⟨(n : ℝ)⁻¹ ^ 2, sq_nonneg _⟩ : ℝ≥0) *
|
| 75 |
+
∑ _ : Fin n, (⟨B^2, sq_nonneg _⟩ : ℝ≥0) : ℝ≥0) : ℝ))
|
| 76 |
+
rw [hc]
|
| 77 |
+
change -(n : ℝ) * u^2 / (2 * B^2) = -u^2 / (2 * (B^2 / n))
|
| 78 |
+
field_simp
|
| 79 |
+
|
| 80 |
+
end Concentration
|
| 81 |
+
|
| 82 |
+
section Fourier
|
| 83 |
+
variable {E : Type u2} [NormedAddCommGroup E] [InnerProductSpace ℝ E]
|
| 84 |
+
[FiniteDimensional ℝ E] [MeasurableSpace E] [BorelSpace E]
|
| 85 |
+
|
| 86 |
+
lemma gaussian_cos_integrable (w : E) :
|
| 87 |
+
Integrable (fun g : E => Real.cos (inner ℝ g w)) (stdGaussian E) := by
|
| 88 |
+
apply Integrable.mono' (integrable_const (1 : ℝ))
|
| 89 |
+
· exact (by fun_prop : Continuous (fun g : E => Real.cos (inner ℝ g w))).aestronglyMeasurable
|
| 90 |
+
· exact ae_of_all _ (fun g => by simpa only [Real.norm_eq_abs] using Real.abs_cos_le_one _)
|
| 91 |
+
|
| 92 |
+
lemma gaussian_cos (w : E) :
|
| 93 |
+
(∫ g : E, Real.cos (inner ℝ g w) ∂stdGaussian E) =
|
| 94 |
+
Real.exp (-‖w‖^2 / 2) := by
|
| 95 |
+
have hh := congrArg Complex.re (charFun_stdGaussian w)
|
| 96 |
+
rw [charFun_apply] at hh
|
| 97 |
+
have hf : Integrable (fun g : E => Complex.exp ((inner ℝ g w : ℂ) * Complex.I))
|
| 98 |
+
(stdGaussian E) := by
|
| 99 |
+
apply Integrable.mono' (integrable_const (1 : ℝ))
|
| 100 |
+
· exact (by fun_prop : Continuous (fun g : E => Complex.exp ((inner ℝ g w : ℂ) * Complex.I))).aestronglyMeasurable
|
| 101 |
+
· exact ae_of_all _ (fun g => by simp)
|
| 102 |
+
have hi := Complex.reCLM.integral_comp_comm hf
|
| 103 |
+
change (∫ g : E, (Complex.exp ((inner ℝ g w : ℂ) * Complex.I)).re ∂stdGaussian E) =
|
| 104 |
+
(∫ g : E, Complex.exp ((inner ℝ g w : ℂ) * Complex.I) ∂stdGaussian E).re at hi
|
| 105 |
+
rw [← hi] at hh
|
| 106 |
+
simpa [Complex.exp_re, pow_two, Complex.mul_re, Complex.mul_im] using hh
|
| 107 |
+
|
| 108 |
+
lemma gaussian_linear_sin_integrable (w v : E) :
|
| 109 |
+
Integrable (fun g : E => inner ℝ g v * Real.sin (inner ℝ g w)) (stdGaussian E) := by
|
| 110 |
+
apply Integrable.mono' ((IsGaussian.integrable_id (μ := stdGaussian E)).norm.mul_const ‖v‖)
|
| 111 |
+
· exact (by fun_prop : Continuous (fun g : E => inner ℝ g v * Real.sin (inner ℝ g w))).aestronglyMeasurable
|
| 112 |
+
· filter_upwards [] with g
|
| 113 |
+
simp only [Real.norm_eq_abs, abs_mul]
|
| 114 |
+
calc
|
| 115 |
+
_ ≤ |inner ℝ g v| * 1 := mul_le_mul_of_nonneg_left (Real.abs_sin_le_one _) (abs_nonneg _)
|
| 116 |
+
_ ≤ ‖g‖ * ‖v‖ := by simpa using abs_real_inner_le_norm g v
|
| 117 |
+
|
| 118 |
+
lemma gaussian_linear_sin (w v : E) :
|
| 119 |
+
(∫ g : E, inner ℝ g v * Real.sin (inner ℝ g w) ∂stdGaussian E) =
|
| 120 |
+
inner ℝ w v * Real.exp (-‖w‖^2 / 2) := by
|
| 121 |
+
let F : ℝ → E → ℝ := fun t g => Real.cos (inner ℝ g (w + t • v))
|
| 122 |
+
let F' : ℝ → E → ℝ := fun t g => -Real.sin (inner ℝ g (w + t • v)) * inner ℝ g v
|
| 123 |
+
have hd (g : E) (t : ℝ) : HasDerivAt (fun t => F t g) (F' t g) t := by
|
| 124 |
+
have h := ((hasDerivAt_const t w).add ((hasDerivAt_id t).smul_const v))
|
| 125 |
+
have hh := ((hasDerivAt_const t g).inner ℝ h).cos
|
| 126 |
+
simpa [F, F'] using hh
|
| 127 |
+
have hbound (g : E) (t : ℝ) : ‖F' t g‖ ≤ ‖g‖ * ‖v‖ := by
|
| 128 |
+
simp only [F', Real.norm_eq_abs, abs_mul, abs_neg]
|
| 129 |
+
calc
|
| 130 |
+
_ ≤ 1 * |inner ℝ g v| := mul_le_mul_of_nonneg_right (Real.abs_sin_le_one _) (abs_nonneg _)
|
| 131 |
+
_ ≤ ‖g‖ * ‖v‖ := by simpa using abs_real_inner_le_norm g v
|
| 132 |
+
have hi := hasDerivAt_integral_of_dominated_loc_of_deriv_le
|
| 133 |
+
(μ := stdGaussian E) (F := F) (F' := F') (bound := fun g => ‖g‖ * ‖v‖)
|
| 134 |
+
(s := Set.univ) (x₀ := (0 : ℝ)) (Filter.univ_mem)
|
| 135 |
+
(Filter.Eventually.of_forall (fun t =>
|
| 136 |
+
(show Continuous (F t) by dsimp [F]; fun_prop).aestronglyMeasurable))
|
| 137 |
+
(by simpa [F] using gaussian_cos_integrable w)
|
| 138 |
+
(show AEStronglyMeasurable (F' 0) (stdGaussian E) from
|
| 139 |
+
(show Continuous (F' 0) by dsimp [F']; fun_prop).aestronglyMeasurable)
|
| 140 |
+
(ae_of_all _ (fun g t _ => hbound g t))
|
| 141 |
+
((IsGaussian.integrable_id (μ := stdGaussian E)).norm.mul_const ‖v‖)
|
| 142 |
+
(ae_of_all _ (fun g t _ => hd g t))
|
| 143 |
+
have ht := (((hasDerivAt_const (0 : ℝ) w).add
|
| 144 |
+
((hasDerivAt_id (0 : ℝ)).smul_const v)).norm_sq.neg.div_const 2).exp
|
| 145 |
+
have heq : (fun t => ∫ g : E, F t g ∂stdGaussian E) =
|
| 146 |
+
(fun t : ℝ => Real.exp (-‖w + t • v‖^2 / 2)) := by
|
| 147 |
+
funext t
|
| 148 |
+
exact gaussian_cos _
|
| 149 |
+
rw [heq] at hi
|
| 150 |
+
have huniq := hi.2.unique ht
|
| 151 |
+
simp only [F', zero_smul, add_zero, one_smul, zero_add] at huniq
|
| 152 |
+
have hneg : (∫ g : E, -Real.sin (inner ℝ g w) * inner ℝ g v ∂stdGaussian E) =
|
| 153 |
+
-(∫ g : E, inner ℝ g v * Real.sin (inner ℝ g w) ∂stdGaussian E) := by
|
| 154 |
+
rw [← integral_neg]
|
| 155 |
+
congr 1
|
| 156 |
+
funext g
|
| 157 |
+
ring
|
| 158 |
+
rw [hneg] at huniq
|
| 159 |
+
dsimp at huniq
|
| 160 |
+
simp only [zero_smul, add_zero] at huniq
|
| 161 |
+
nlinarith
|
| 162 |
+
|
| 163 |
+
lemma gaussian_vector_sin_integrable (w : E) :
|
| 164 |
+
Integrable (fun g : E => Real.sin (inner ℝ g w) • g) (stdGaussian E) := by
|
| 165 |
+
exact (IsGaussian.integrable_id (μ := stdGaussian E)).bdd_smul 1
|
| 166 |
+
(by fun_prop) (ae_of_all _ (fun g => by simpa using Real.abs_sin_le_one (inner ℝ g w)))
|
| 167 |
+
|
| 168 |
+
lemma gaussian_vector_sin (w : E) :
|
| 169 |
+
(∫ g : E, Real.sin (inner ℝ g w) • g ∂stdGaussian E) =
|
| 170 |
+
Real.exp (-‖w‖^2 / 2) • w := by
|
| 171 |
+
apply ext_inner_left ℝ
|
| 172 |
+
intro v
|
| 173 |
+
rw [← integral_inner (gaussian_vector_sin_integrable w), inner_smul_right]
|
| 174 |
+
simp only [inner_smul_right]
|
| 175 |
+
simpa only [real_inner_comm, mul_comm] using gaussian_linear_sin w v
|
| 176 |
+
|
| 177 |
+
lemma gaussian_inner_law (v : E) :
|
| 178 |
+
(stdGaussian E).map (fun g => inner ℝ v g) =
|
| 179 |
+
gaussianReal 0 (⟨‖v‖^2, sq_nonneg _⟩ : ℝ≥0) := by
|
| 180 |
+
have h := IsGaussian.map_eq_gaussianReal (μ := stdGaussian E) (innerSL ℝ v)
|
| 181 |
+
simp only [integral_strongDual_stdGaussian, variance_dual_stdGaussian,
|
| 182 |
+
innerSL_apply_norm] at h
|
| 183 |
+
have hvariance : (‖v‖^2).toNNReal = (⟨‖v‖^2, sq_nonneg _⟩ : ℝ≥0) :=
|
| 184 |
+
Real.toNNReal_of_nonneg (sq_nonneg _)
|
| 185 |
+
exact h.trans (congrArg (gaussianReal 0) hvariance)
|
| 186 |
+
|
| 187 |
+
lemma gaussian_inner_sq (v : E) :
|
| 188 |
+
(∫ g : E, (inner ℝ v g)^2 ∂stdGaussian E) = ‖v‖^2 := by
|
| 189 |
+
have h := variance_dual_stdGaussian (innerSL ℝ v)
|
| 190 |
+
rw [variance_eq_integral (by fun_prop), integral_strongDual_stdGaussian] at h
|
| 191 |
+
simpa only [sub_zero, innerSL_apply_norm, innerSL_apply_apply] using h
|
| 192 |
+
|
| 193 |
+
lemma gaussian_inner_subgaussian (v : E) :
|
| 194 |
+
HasSubgaussianMGF (fun g => inner ℝ v g) (⟨‖v‖^2, sq_nonneg _⟩ : ℝ≥0) (stdGaussian E) where
|
| 195 |
+
integrable_exp_mul t := by
|
| 196 |
+
have h := integrable_exp_mul_gaussianReal (μ := 0)
|
| 197 |
+
(v := (⟨‖v‖^2, sq_nonneg _⟩ : ℝ≥0)) t
|
| 198 |
+
rw [← gaussian_inner_law v] at h
|
| 199 |
+
exact (integrable_map_measure h.aestronglyMeasurable (by fun_prop)).mp h
|
| 200 |
+
mgf_le t := by
|
| 201 |
+
rw [mgf_gaussianReal ⟨by fun_prop, gaussian_inner_law v⟩]
|
| 202 |
+
simp
|
| 203 |
+
|
| 204 |
+
lemma gaussian_inner_tail (v : E) (hv : ‖v‖ = 1) {u : ℝ} (hu : 0 ≤ u) :
|
| 205 |
+
(stdGaussian E).real {g | u < |inner ℝ v g|} ≤ 2 * Real.exp (-u^2 / 2) := by
|
| 206 |
+
have h := subgaussian_abs_tail (gaussian_inner_subgaussian v) hu
|
| 207 |
+
change _ ≤ 2 * Real.exp (-u^2 / (2 * ‖v‖^2)) at h
|
| 208 |
+
simpa [hv] using h
|
| 209 |
+
|
| 210 |
+
end Fourier
|
| 211 |
+
section NormTails
|
| 212 |
+
|
| 213 |
+
lemma gaussian_real_exp_sq (t : ℝ) (ht : t < 1/2) :
|
| 214 |
+
(∫ x : ℝ, Real.exp (t * x^2) ∂gaussianReal 0 1) =
|
| 215 |
+
Real.exp (-(1/2 : ℝ) * Real.log (1 - 2*t)) := by
|
| 216 |
+
rw [integral_gaussianReal_eq_integral_smul (by norm_num : (1 : ℝ≥0) ≠ 0)]
|
| 217 |
+
have heq (x : ℝ) : gaussianPDFReal 0 1 x * Real.exp (t * x^2) =
|
| 218 |
+
(Real.sqrt (2 * Real.pi))⁻¹ * Real.exp (-(1/2-t) * x^2) := by
|
| 219 |
+
simp only [gaussianPDFReal, NNReal.coe_one, mul_one, sub_zero]
|
| 220 |
+
rw [mul_assoc, ← Real.exp_add]
|
| 221 |
+
congr 2
|
| 222 |
+
ring
|
| 223 |
+
simp_rw [smul_eq_mul, heq]
|
| 224 |
+
rw [integral_const_mul, integral_gaussian]
|
| 225 |
+
have hpos : 0 < 1 - 2*t := by linarith
|
| 226 |
+
have hhalf : 0 < 1/2-t := by linarith
|
| 227 |
+
have hpi := Real.pi_pos
|
| 228 |
+
have heq2 : (Real.sqrt (2 * Real.pi))⁻¹ * Real.sqrt (Real.pi / (1/2-t)) =
|
| 229 |
+
Real.sqrt ((1 - 2*t)⁻¹) := by
|
| 230 |
+
rw [← Real.sqrt_inv, ← Real.sqrt_mul (inv_nonneg.mpr (by positivity))]
|
| 231 |
+
congr 1
|
| 232 |
+
field_simp
|
| 233 |
+
|
| 234 |
+
rw [heq2, Real.sqrt_eq_rpow, Real.rpow_def_of_pos (inv_pos.mpr hpos), Real.log_inv]
|
| 235 |
+
congr 1
|
| 236 |
+
ring
|
| 237 |
+
|
| 238 |
+
lemma gaussian_real_exp_sq_integrable (t : ℝ) (ht : t < 1/2) :
|
| 239 |
+
Integrable (fun x : ℝ => Real.exp (t * x^2)) (gaussianReal 0 1) := by
|
| 240 |
+
by_contra h
|
| 241 |
+
have hh := gaussian_real_exp_sq t ht
|
| 242 |
+
rw [integral_undef h] at hh
|
| 243 |
+
exact (Real.exp_ne_zero _).symm hh
|
| 244 |
+
|
| 245 |
+
lemma gaussian_exp_norm_sq {n : ℕ} (t : ℝ) (ht : t < 1/2) :
|
| 246 |
+
(∫ g : EuclideanSpace ℝ (Fin n), Real.exp (t * ‖g‖^2)
|
| 247 |
+
∂stdGaussian (EuclideanSpace ℝ (Fin n))) =
|
| 248 |
+
Real.exp (-(n : ℝ)/2 * Real.log (1-2*t)) := by
|
| 249 |
+
rw [← map_pi_eq_stdGaussian]
|
| 250 |
+
rw [integral_map (by fun_prop) (by fun_prop)]
|
| 251 |
+
have heq (g : Fin n → ℝ) : Real.exp (t * ‖WithLp.toLp 2 g‖^2) =
|
| 252 |
+
∏ i, Real.exp (t * (g i)^2) := by
|
| 253 |
+
rw [EuclideanSpace.real_norm_sq_eq, Finset.mul_sum, Real.exp_sum]
|
| 254 |
+
simp_rw [heq]
|
| 255 |
+
have hp := integral_fintype_prod_eq_pow (ι := Fin n) (μ := gaussianReal 0 1)
|
| 256 |
+
(fun x : ℝ => Real.exp (t * x^2))
|
| 257 |
+
rw [Fintype.card_fin] at hp
|
| 258 |
+
change (∫ x : Fin n → ℝ, ∏ i, Real.exp (t * x i ^ 2) ∂Measure.pi (fun _ => gaussianReal 0 1)) =
|
| 259 |
+
(∫ x : ℝ, Real.exp (t * x^2) ∂gaussianReal 0 1) ^ n at hp
|
| 260 |
+
rw [hp, gaussian_real_exp_sq t ht, ← Real.exp_nat_mul]
|
| 261 |
+
congr 1
|
| 262 |
+
ring
|
| 263 |
+
|
| 264 |
+
lemma gaussian_exp_norm_sq_integrable {n : ℕ} (t : ℝ) (ht : t < 1/2) :
|
| 265 |
+
Integrable (fun g : EuclideanSpace ℝ (Fin n) => Real.exp (t * ‖g‖^2))
|
| 266 |
+
(stdGaussian (EuclideanSpace ℝ (Fin n))) := by
|
| 267 |
+
by_contra h
|
| 268 |
+
have hh := gaussian_exp_norm_sq (n := n) t ht
|
| 269 |
+
rw [integral_undef h] at hh
|
| 270 |
+
exact (Real.exp_ne_zero _).symm hh
|
| 271 |
+
|
| 272 |
+
lemma gaussian_norm_upper {n : ℕ} :
|
| 273 |
+
(stdGaussian (EuclideanSpace ℝ (Fin n))).real
|
| 274 |
+
{g | 4 * (n : ℝ) < ‖g‖^2} ≤ Real.exp (-(n : ℝ)/2) := by
|
| 275 |
+
let μ := stdGaussian (EuclideanSpace ℝ (Fin n))
|
| 276 |
+
have hmark := mul_meas_ge_le_integral_of_nonneg (μ := μ)
|
| 277 |
+
(f := fun g => Real.exp ((1/4 : ℝ) * ‖g‖^2))
|
| 278 |
+
(ae_of_all _ (fun _ => (Real.exp_pos _).le))
|
| 279 |
+
(gaussian_exp_norm_sq_integrable (1/4) (by norm_num)) (Real.exp n)
|
| 280 |
+
rw [gaussian_exp_norm_sq (1/4) (by norm_num)] at hmark
|
| 281 |
+
have hs : {g : EuclideanSpace ℝ (Fin n) | 4 * (n : ℝ) < ‖g‖^2} ⊆
|
| 282 |
+
{g | Real.exp n ≤ Real.exp ((1/4 : ℝ) * ‖g‖^2)} := by
|
| 283 |
+
intro g hg
|
| 284 |
+
apply Real.exp_le_exp.mpr
|
| 285 |
+
change 4 * (n : ℝ) < ‖g‖^2 at hg
|
| 286 |
+
linarith
|
| 287 |
+
have hn : (0 : ℝ) ≤ n := Nat.cast_nonneg _
|
| 288 |
+
calc
|
| 289 |
+
_ ≤ μ.real {g | Real.exp n ≤ Real.exp ((1/4 : ℝ) * ‖g‖^2)} := measureReal_mono hs
|
| 290 |
+
_ ≤ Real.exp (-(n : ℝ)/2 * Real.log (1-2*(1/4 : ℝ))) / Real.exp n :=
|
| 291 |
+
(le_div_iff₀ (Real.exp_pos _)).mpr (by simpa [mul_comm] using hmark)
|
| 292 |
+
_ ≤ Real.exp (-(n : ℝ)/2) := by
|
| 293 |
+
rw [← Real.exp_sub]
|
| 294 |
+
apply Real.exp_le_exp.mpr
|
| 295 |
+
have hh := Real.log_le_sub_one_of_pos (by norm_num : (0 : ℝ) < 2)
|
| 296 |
+
have hl : Real.log (1-2*(1/4 : ℝ)) = -Real.log 2 := by
|
| 297 |
+
norm_num
|
| 298 |
+
rw [show (1/2 : ℝ) = (2 : ℝ)⁻¹ by norm_num, Real.log_inv]
|
| 299 |
+
rw [hl]
|
| 300 |
+
nlinarith
|
| 301 |
+
|
| 302 |
+
lemma gaussian_norm_lower {n : ℕ} :
|
| 303 |
+
(stdGaussian (EuclideanSpace ℝ (Fin n))).real
|
| 304 |
+
{g | ‖g‖^2 < (n : ℝ)/4} ≤ Real.exp (-(n : ℝ)/8) := by
|
| 305 |
+
let μ := stdGaussian (EuclideanSpace ℝ (Fin n))
|
| 306 |
+
have hmark := mul_meas_ge_le_integral_of_nonneg (μ := μ)
|
| 307 |
+
(f := fun g => Real.exp ((-1/2 : ℝ) * ‖g‖^2))
|
| 308 |
+
(ae_of_all _ (fun _ => (Real.exp_pos _).le))
|
| 309 |
+
(gaussian_exp_norm_sq_integrable (-1/2) (by norm_num)) (Real.exp (-(n : ℝ)/8))
|
| 310 |
+
rw [gaussian_exp_norm_sq (-1/2) (by norm_num)] at hmark
|
| 311 |
+
have hs : {g : EuclideanSpace ℝ (Fin n) | ‖g‖^2 < (n : ℝ)/4} ⊆
|
| 312 |
+
{g | Real.exp (-(n : ℝ)/8) ≤ Real.exp ((-1/2 : ℝ) * ‖g‖^2)} := by
|
| 313 |
+
intro g hg
|
| 314 |
+
apply Real.exp_le_exp.mpr
|
| 315 |
+
change ‖g‖^2 < (n : ℝ)/4 at hg
|
| 316 |
+
linarith
|
| 317 |
+
have hn : (0 : ℝ) ≤ n := Nat.cast_nonneg _
|
| 318 |
+
calc
|
| 319 |
+
_ ≤ μ.real {g | Real.exp (-(n : ℝ)/8) ≤ Real.exp ((-1/2 : ℝ) * ‖g‖^2)} := measureReal_mono hs
|
| 320 |
+
_ ≤ Real.exp (-(n : ℝ)/2 * Real.log (1-2*(-1/2 : ℝ))) / Real.exp (-(n : ℝ)/8) :=
|
| 321 |
+
(le_div_iff₀ (Real.exp_pos _)).mpr (by simpa [mul_comm] using hmark)
|
| 322 |
+
_ ≤ Real.exp (-(n : ℝ)/8) := by
|
| 323 |
+
rw [← Real.exp_sub]
|
| 324 |
+
apply Real.exp_le_exp.mpr
|
| 325 |
+
norm_num only at *
|
| 326 |
+
have hh := Real.one_sub_inv_le_log_of_pos (by norm_num : (0 : ℝ) < 2)
|
| 327 |
+
norm_num at hh ⊢
|
| 328 |
+
nlinarith
|
| 329 |
+
|
| 330 |
+
lemma gaussian_norm_tail {n : ℕ} :
|
| 331 |
+
(stdGaussian (EuclideanSpace ℝ (Fin n))).real
|
| 332 |
+
{g | ‖g‖ ∉ Icc (Real.sqrt n / 2) (2 * Real.sqrt n)} ≤
|
| 333 |
+
2 * Real.exp (-(n : ℝ)/8) := by
|
| 334 |
+
have hs : {g : EuclideanSpace ℝ (Fin n) | ‖g‖ ∉ Icc (Real.sqrt n / 2) (2 * Real.sqrt n)} ⊆
|
| 335 |
+
{g | ‖g‖^2 < (n : ℝ)/4} ∪ {g | 4 * (n : ℝ) < ‖g‖^2} := by
|
| 336 |
+
intro g hg
|
| 337 |
+
change ¬(Real.sqrt n / 2 ≤ ‖g‖ ∧ ‖g‖ ≤ 2 * Real.sqrt n) at hg
|
| 338 |
+
have hsq := Real.sq_sqrt (Nat.cast_nonneg n)
|
| 339 |
+
have hsqrt := Real.sqrt_nonneg (n : ℝ)
|
| 340 |
+
have hnorm := norm_nonneg g
|
| 341 |
+
rcases not_and_or.mp hg with h | h
|
| 342 |
+
· exact Or.inl (by simp only [mem_ofPred_eq]; nlinarith [lt_of_not_ge h])
|
| 343 |
+
· exact Or.inr (by simp only [mem_ofPred_eq]; nlinarith [lt_of_not_ge h])
|
| 344 |
+
calc
|
| 345 |
+
_ ≤ _ := measureReal_mono hs
|
| 346 |
+
_ ≤ _ := measureReal_union_le _ _
|
| 347 |
+
_ ≤ Real.exp (-(n : ℝ)/8) + Real.exp (-(n : ℝ)/2) :=
|
| 348 |
+
add_le_add gaussian_norm_lower gaussian_norm_upper
|
| 349 |
+
_ ≤ 2 * Real.exp (-(n : ℝ)/8) := by
|
| 350 |
+
have hh : Real.exp (-(n : ℝ)/2) ≤ Real.exp (-(n : ℝ)/8) :=
|
| 351 |
+
Real.exp_le_exp.mpr (by have := Nat.cast_nonneg (α := ℝ) n; linarith)
|
| 352 |
+
linarith
|
| 353 |
+
|
| 354 |
+
lemma gaussian_truncated_sq_bound {n : ℕ} :
|
| 355 |
+
(∫ g : EuclideanSpace ℝ (Fin n),
|
| 356 |
+
({g | 4*(n : ℝ) < ‖g‖^2} : Set (EuclideanSpace ℝ (Fin n))).indicator
|
| 357 |
+
(fun g => ‖g‖^2) g ∂stdGaussian (EuclideanSpace ℝ (Fin n))) ≤
|
| 358 |
+
16 * Real.exp (-(n : ℝ)/12) := by
|
| 359 |
+
let μ := stdGaussian (EuclideanSpace ℝ (Fin n))
|
| 360 |
+
have hm (g : EuclideanSpace ℝ (Fin n)) :
|
| 361 |
+
({g | 4*(n : ℝ) < ‖g‖^2} : Set (EuclideanSpace ℝ (Fin n))).indicator
|
| 362 |
+
(fun g => ‖g‖^2) g ≤
|
| 363 |
+
(16 * Real.exp (-(n : ℝ)/4)) * Real.exp ((1/8 : ℝ) * ‖g‖^2) := by
|
| 364 |
+
by_cases hg : 4*(n : ℝ) < ‖g‖^2
|
| 365 |
+
· simp only [Set.indicator, Set.mem_ofPred_eq, hg, ↓reduceIte]
|
| 366 |
+
have he := Real.add_one_le_exp (‖g‖^2/16)
|
| 367 |
+
have hh : Real.exp (‖g‖^2/16) ≤
|
| 368 |
+
Real.exp (-(n : ℝ)/4) * Real.exp ((1/8 : ℝ) * ‖g‖^2) := by
|
| 369 |
+
rw [← Real.exp_add]
|
| 370 |
+
apply Real.exp_le_exp.mpr
|
| 371 |
+
linarith
|
| 372 |
+
nlinarith
|
| 373 |
+
· simp only [Set.indicator, Set.mem_ofPred_eq, hg, ↓reduceIte]
|
| 374 |
+
positivity
|
| 375 |
+
have hi := (gaussian_exp_norm_sq_integrable (n := n) (1/8) (by norm_num)).const_mul
|
| 376 |
+
(16 * Real.exp (-(n : ℝ)/4))
|
| 377 |
+
calc
|
| 378 |
+
_ ≤ ∫ g : EuclideanSpace ℝ (Fin n),
|
| 379 |
+
(16 * Real.exp (-(n : ℝ)/4)) * Real.exp ((1/8 : ℝ) * ‖g‖^2) ∂μ := by
|
| 380 |
+
apply integral_mono_of_nonneg
|
| 381 |
+
· exact ae_of_all _ (fun g => Set.indicator_nonneg (fun g _ => sq_nonneg ‖g‖) g)
|
| 382 |
+
· exact hi
|
| 383 |
+
· exact ae_of_all _ hm
|
| 384 |
+
_ = 16 * Real.exp (-(n : ℝ)/4 - (n : ℝ)/2 * Real.log (1-2*(1/8 : ℝ))) := by
|
| 385 |
+
rw [integral_const_mul, gaussian_exp_norm_sq (1/8) (by norm_num), mul_assoc, ← Real.exp_add]
|
| 386 |
+
congr 2
|
| 387 |
+
ring
|
| 388 |
+
_ ≤ 16 * Real.exp (-(n : ℝ)/12) := by
|
| 389 |
+
gcongr
|
| 390 |
+
have hl : Real.log (1-2*(1/8 : ℝ)) = -Real.log (4/3) := by
|
| 391 |
+
norm_num
|
| 392 |
+
rw [show (3/4 : ℝ) = (4/3 : ℝ)⁻¹ by norm_num, Real.log_inv]
|
| 393 |
+
rw [hl]
|
| 394 |
+
have hh := Real.log_le_sub_one_of_pos (by norm_num : (0 : ℝ) < 4/3)
|
| 395 |
+
have hn := Nat.cast_nonneg (α := ℝ) n
|
| 396 |
+
nlinarith
|
| 397 |
+
|
| 398 |
+
lemma gaussian_norm_sq_integrable {n : ℕ} :
|
| 399 |
+
Integrable (fun g : EuclideanSpace ℝ (Fin n) => ‖g‖^2)
|
| 400 |
+
(stdGaussian (EuclideanSpace ℝ (Fin n))) := by
|
| 401 |
+
apply Integrable.mono' ((gaussian_exp_norm_sq_integrable (n := n) (1/4) (by norm_num)).const_mul 4)
|
| 402 |
+
· fun_prop
|
| 403 |
+
· filter_upwards [] with g
|
| 404 |
+
rw [Real.norm_eq_abs, abs_of_nonneg (sq_nonneg _)]
|
| 405 |
+
have := Real.add_one_le_exp ((1/4 : ℝ) * ‖g‖^2)
|
| 406 |
+
linarith
|
| 407 |
+
|
| 408 |
+
end NormTails
|
| 409 |
+
|
| 410 |
+
section Truncation
|
| 411 |
+
variable {n : ℕ}
|
| 412 |
+
local notation "E" => EuclideanSpace ℝ (Fin n)
|
| 413 |
+
local notation "μ" => stdGaussian E
|
| 414 |
+
|
| 415 |
+
noncomputable def truncate (n : ℕ) (f : EuclideanSpace ℝ (Fin n) → ℝ) :
|
| 416 |
+
EuclideanSpace ℝ (Fin n) → ℝ :=
|
| 417 |
+
{g | ‖g‖^2 ≤ 4*(n : ℝ)}.indicator f
|
| 418 |
+
|
| 419 |
+
lemma measurable_truncation_set : MeasurableSet {g : E | ‖g‖^2 ≤ 4*(n : ℝ)} := by
|
| 420 |
+
measurability
|
| 421 |
+
|
| 422 |
+
lemma measurable_tail_set : MeasurableSet {g : E | 4*(n : ℝ) < ‖g‖^2} := by
|
| 423 |
+
measurability
|
| 424 |
+
|
| 425 |
+
lemma integrable_truncate {f : E → ℝ} (hf : Integrable f μ) :
|
| 426 |
+
Integrable (truncate n f) μ := hf.indicator measurable_truncation_set
|
| 427 |
+
|
| 428 |
+
lemma truncation_bias {f : E → ℝ} (hf : Integrable f μ)
|
| 429 |
+
(hb : ∀ g, 4*(n : ℝ) < ‖g‖^2 → |f g| ≤ ‖g‖^2) :
|
| 430 |
+
|(∫ g, truncate n f g ∂μ) - ∫ g, f g ∂μ| ≤
|
| 431 |
+
16 * Real.exp (-(n : ℝ)/12) := by
|
| 432 |
+
let T : Set E := {g | 4*(n : ℝ) < ‖g‖^2}
|
| 433 |
+
have hT : MeasurableSet T := measurable_tail_set
|
| 434 |
+
have hid (g : E) : truncate n f g - f g = -T.indicator f g := by
|
| 435 |
+
by_cases h : ‖g‖^2 ≤ 4*(n : ℝ)
|
| 436 |
+
· simp [truncate, T, h, not_lt.mpr h]
|
| 437 |
+
· simp [truncate, T, h, lt_of_not_ge h]
|
| 438 |
+
rw [← integral_sub (integrable_truncate hf) hf]
|
| 439 |
+
simp_rw [hid]
|
| 440 |
+
rw [integral_neg, abs_neg]
|
| 441 |
+
calc
|
| 442 |
+
|∫ g, T.indicator f g ∂μ| ≤ ∫ g, |T.indicator f g| ∂μ := abs_integral_le_integral_abs
|
| 443 |
+
_ ≤ ∫ g, T.indicator (fun g => ‖g‖^2) g ∂μ := by
|
| 444 |
+
apply integral_mono ((hf.indicator hT).abs) (gaussian_norm_sq_integrable.indicator hT)
|
| 445 |
+
intro g
|
| 446 |
+
by_cases hg : g ∈ T
|
| 447 |
+
· simpa [Set.indicator_of_mem hg] using hb g hg
|
| 448 |
+
· simp [Set.indicator_of_notMem hg]
|
| 449 |
+
_ ≤ _ := gaussian_truncated_sq_bound
|
| 450 |
+
|
| 451 |
+
lemma inner_sq_integrable (v : E) : Integrable (fun g => (inner ℝ v g)^2) μ := by
|
| 452 |
+
apply Integrable.mono' (gaussian_norm_sq_integrable.const_mul (‖v‖^2))
|
| 453 |
+
· fun_prop
|
| 454 |
+
· filter_upwards [] with g
|
| 455 |
+
simp only [Real.norm_eq_abs, abs_sq]
|
| 456 |
+
have h := abs_real_inner_le_norm v g
|
| 457 |
+
simpa only [sq_abs, mul_pow] using pow_le_pow_left₀ (abs_nonneg _) h 2
|
| 458 |
+
|
| 459 |
+
lemma truncation_covariance_bias (v : E) (hv : ‖v‖ = 1) :
|
| 460 |
+
|(∫ g, truncate n (fun g => (inner ℝ v g)^2) g ∂μ) - 1| ≤
|
| 461 |
+
16 * Real.exp (-(n : ℝ)/12) := by
|
| 462 |
+
have h := truncation_bias (inner_sq_integrable v) (fun g hg => by
|
| 463 |
+
have hh := abs_real_inner_le_norm v g
|
| 464 |
+
rw [hv, one_mul] at hh
|
| 465 |
+
simpa only [abs_sq, sq_abs] using pow_le_pow_left₀ (abs_nonneg _) hh 2)
|
| 466 |
+
simpa [gaussian_inner_sq, hv] using h
|
| 467 |
+
|
| 468 |
+
lemma truncation_fourier_bias (hn : 1 ≤ n) (v w : E) (hv : ‖v‖ = 1) :
|
| 469 |
+
|(∫ g, truncate n (fun g => inner ℝ g v * Real.sin (inner ℝ g w)) g ∂μ) -
|
| 470 |
+
inner ℝ w v * Real.exp (-‖w‖^2/2)| ≤
|
| 471 |
+
16 * Real.exp (-(n : ℝ)/12) := by
|
| 472 |
+
have h := truncation_bias (gaussian_linear_sin_integrable w v) (fun g hg => by
|
| 473 |
+
have hn' : (1 : ℝ) ≤ n := by exact_mod_cast hn
|
| 474 |
+
have hh := abs_real_inner_le_norm g v
|
| 475 |
+
rw [hv, mul_one] at hh
|
| 476 |
+
have hn1 : 1 ≤ ‖g‖ := by nlinarith [norm_nonneg g]
|
| 477 |
+
calc
|
| 478 |
+
|inner ℝ g v * Real.sin (inner ℝ g w)| ≤ |inner ℝ g v| * 1 := by
|
| 479 |
+
rw [abs_mul]; exact mul_le_mul_of_nonneg_left (Real.abs_sin_le_one _) (abs_nonneg _)
|
| 480 |
+
_ ≤ ‖g‖^2 := by nlinarith)
|
| 481 |
+
simpa only [gaussian_linear_sin] using h
|
| 482 |
+
|
| 483 |
+
lemma truncate_fourier_bound (v w : E) (hv : ‖v‖ = 1) (g : E) :
|
| 484 |
+
|truncate n (fun g => inner ℝ g v * Real.sin (inner ℝ g w)) g| ≤ 2*Real.sqrt n := by
|
| 485 |
+
by_cases hg : ‖g‖^2 ≤ 4*(n : ℝ)
|
| 486 |
+
· have hh := abs_real_inner_le_norm g v
|
| 487 |
+
rw [hv, mul_one] at hh
|
| 488 |
+
have hs := Real.sq_sqrt (Nat.cast_nonneg (α := ℝ) n)
|
| 489 |
+
have hb : ‖g‖ ≤ 2*Real.sqrt n := by nlinarith [Real.sqrt_nonneg (n : ℝ), norm_nonneg g]
|
| 490 |
+
simp only [truncate, Set.indicator, Set.mem_ofPred_eq, hg, ↓reduceIte, abs_mul]
|
| 491 |
+
calc
|
| 492 |
+
_ ≤ |inner ℝ g v| * 1 := mul_le_mul_of_nonneg_left (Real.abs_sin_le_one _) (abs_nonneg _)
|
| 493 |
+
_ ≤ _ := by linarith
|
| 494 |
+
· simp only [truncate, Set.indicator, Set.mem_ofPred_eq, hg, ↓reduceIte, abs_zero]
|
| 495 |
+
positivity
|
| 496 |
+
|
| 497 |
+
lemma truncate_covariance_bound (v : E) (hv : ‖v‖ = 1) (g : E) :
|
| 498 |
+
|truncate n (fun g => (inner ℝ v g)^2) g| ≤ 4*(n : ℝ) := by
|
| 499 |
+
by_cases hg : ‖g‖^2 ≤ 4*(n : ℝ)
|
| 500 |
+
· have hh := abs_real_inner_le_norm v g
|
| 501 |
+
rw [hv, one_mul] at hh
|
| 502 |
+
have hb := pow_le_pow_left₀ (abs_nonneg _) hh 2
|
| 503 |
+
rw [sq_abs] at hb
|
| 504 |
+
simp only [truncate, Set.indicator, Set.mem_ofPred_eq, hg, ↓reduceIte, abs_sq]
|
| 505 |
+
nlinarith
|
| 506 |
+
· simp only [truncate, Set.indicator, Set.mem_ofPred_eq, hg, ↓reduceIte, abs_zero]
|
| 507 |
+
positivity
|
| 508 |
+
end Truncation
|
| 509 |
+
|
| 510 |
+
end UniformSparsestCut.GaussianTools
|
| 511 |
+
|
| 512 |
+
end
|
| 513 |
+
|
| 514 |
+
end OAI
|
lean/OAI/Combinatorics/SparsestCut/GradientBudget.lean
ADDED
|
@@ -0,0 +1,267 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import OAI.Combinatorics.SparsestCut.ConcreteCells
|
| 2 |
+
|
| 3 |
+
namespace OAI
|
| 4 |
+
|
| 5 |
+
universe u1 u2 u3 u4 u5 u6 u7 u8 u9
|
| 6 |
+
|
| 7 |
+
open scoped BigOperators Topology NNReal RealInnerProductSpace InnerProductSpace Matrix ContDiff ENNReal
|
| 8 |
+
open MeasureTheory ProbabilityTheory Set Filter Matrix
|
| 9 |
+
|
| 10 |
+
noncomputable section
|
| 11 |
+
|
| 12 |
+
namespace UniformSparsestCut.GradientBudget
|
| 13 |
+
variable {E : Type u1} {S : Type u2} {I : Type u3} {A : Type u4} [NormedAddCommGroup E] [InnerProductSpace ℝ E]
|
| 14 |
+
[Fintype S] [Fintype I] [Fintype A] [DecidableEq S]
|
| 15 |
+
|
| 16 |
+
lemma directional_control (u : I → E) (β : I → ℝ) (a e : E) {δ : ℝ}
|
| 17 |
+
(hδ : 0 ≤ δ) (ha : a+e=∑ i, β i • u i)
|
| 18 |
+
(hu : ∀ i, |inner ℝ (u i) a| ≤ δ*‖a‖) :
|
| 19 |
+
‖a‖ ≤ δ*∑ i, |β i|+‖e‖ := by
|
| 20 |
+
by_cases hz : a=0
|
| 21 |
+
· simp only [hz,norm_zero]; positivity
|
| 22 |
+
have hn : 0 < ‖a‖ := norm_pos_iff.mpr hz
|
| 23 |
+
have hs : |inner ℝ (∑ i, β i • u i) a| ≤ δ*‖a‖*∑ i, |β i| := by
|
| 24 |
+
rw [sum_inner]
|
| 25 |
+
calc
|
| 26 |
+
_ ≤ ∑ i, |inner ℝ (β i • u i) a| := Finset.abs_sum_le_sum_abs _ _
|
| 27 |
+
_ ≤ ∑ i, |β i| * (δ*‖a‖) := by
|
| 28 |
+
apply Finset.sum_le_sum; intro i _
|
| 29 |
+
rw [real_inner_smul_left,abs_mul]
|
| 30 |
+
exact mul_le_mul_of_nonneg_left (hu i) (abs_nonneg _)
|
| 31 |
+
_ = _ := by rw [← Finset.sum_mul]; ring
|
| 32 |
+
have hip : ‖a‖^2 ≤ |inner ℝ (∑ i, β i • u i) a|+‖e‖*‖a‖ := by
|
| 33 |
+
rw [← ha,inner_add_left]
|
| 34 |
+
have h := abs_real_inner_le_norm e a
|
| 35 |
+
rw [real_inner_self_eq_norm_sq]
|
| 36 |
+
have hab := le_abs_self (‖a‖^2+inner ℝ e a)
|
| 37 |
+
have hab' := neg_le_abs (inner ℝ e a)
|
| 38 |
+
nlinarith
|
| 39 |
+
have hmul : ‖a‖*‖a‖ ≤ (δ*∑ i, |β i|+‖e‖)*‖a‖ := by nlinarith
|
| 40 |
+
nlinarith
|
| 41 |
+
|
| 42 |
+
omit [DecidableEq S] in
|
| 43 |
+
lemma good_chart_average (u : S → I → E) (β : S → I → ℝ) (a : E) (e : S → E)
|
| 44 |
+
{δ : ℝ} (hδ : 0 ≤ δ)
|
| 45 |
+
(ha : ∀ s, a+e s=∑ i, β s i • u s i)
|
| 46 |
+
(good : Finset S) (hgood : (Fintype.card S : ℝ)/2 ≤ good.card)
|
| 47 |
+
(hu : ∀ s ∈ good, ∀ i, |inner ℝ (u s i) a| ≤ δ*‖a‖) :
|
| 48 |
+
(Fintype.card S : ℝ)*‖a‖ ≤ 2*∑ s, (δ*∑ i, |β s i|+‖e s‖) := by
|
| 49 |
+
have hg : (good.card:ℝ)*‖a‖ ≤ ∑ s ∈ good, (δ*∑ i, |β s i|+‖e s‖) := by
|
| 50 |
+
calc
|
| 51 |
+
_ = ∑ _s ∈ good, ‖a‖ := by simp
|
| 52 |
+
_ ≤ _ := Finset.sum_le_sum (fun s hs => directional_control (u s) (β s) a (e s) hδ (ha s) (hu s hs))
|
| 53 |
+
have hsub : (∑ s ∈ good, (δ*∑ i, |β s i|+‖e s‖)) ≤ ∑ s, (δ*∑ i, |β s i|+‖e s‖) := by
|
| 54 |
+
apply Finset.sum_le_sum_of_subset_of_nonneg (Finset.subset_univ _)
|
| 55 |
+
intro s _ _; positivity
|
| 56 |
+
have hmult := mul_le_mul_of_nonneg_right hgood (norm_nonneg a)
|
| 57 |
+
linarith
|
| 58 |
+
|
| 59 |
+
omit [DecidableEq S] in
|
| 60 |
+
lemma total_gradient (u : S → I → E) (β : S → I → A → ℝ) (a : A → E) (e : S → A → E)
|
| 61 |
+
{δ B R : ℝ} (hδ : 0 ≤ δ)
|
| 62 |
+
(ha : ∀ s α, a α+e s α=∑ i, β s i α • u s i)
|
| 63 |
+
(hg : ∀ α, ∃ good : Finset S, (Fintype.card S : ℝ)/2 ≤ good.card ∧
|
| 64 |
+
∀ s ∈ good, ∀ i, |inner ℝ (u s i) (a α)| ≤ δ*‖a α‖)
|
| 65 |
+
(hβ : ∀ s, ∑ i, ∑ α, |β s i α| ≤ B)
|
| 66 |
+
(he : ∀ s, ∑ α, ‖e s α‖ ≤ R) (hS : 0 < Fintype.card S) :
|
| 67 |
+
∑ α, ‖a α‖ ≤ 2*(δ*B+R) := by
|
| 68 |
+
have hcomp (α : A) : (Fintype.card S : ℝ)*‖a α‖ ≤
|
| 69 |
+
2*∑ s, (δ*∑ i, |β s i α|+‖e s α‖) := by
|
| 70 |
+
obtain ⟨good,hgood,hu⟩ := hg α
|
| 71 |
+
exact good_chart_average u (fun s i => β s i α) (a α) (fun s => e s α) hδ
|
| 72 |
+
(fun s => ha s α) good hgood hu
|
| 73 |
+
have hs := Finset.sum_le_sum (s := Finset.univ) (fun α _ => hcomp α)
|
| 74 |
+
rw [← Finset.mul_sum, ← Finset.mul_sum, Finset.sum_comm] at hs
|
| 75 |
+
have hb (s : S) : (∑ α, (δ*∑ i, |β s i α|+‖e s α‖)) ≤ δ*B+R := by
|
| 76 |
+
rw [Finset.sum_add_distrib,← Finset.mul_sum,Finset.sum_comm]
|
| 77 |
+
exact add_le_add (mul_le_mul_of_nonneg_left (hβ s) hδ) (he s)
|
| 78 |
+
have hsum := Finset.sum_le_sum (s := Finset.univ) (fun s _ => hb s)
|
| 79 |
+
simp only [Finset.sum_const,Finset.card_univ,nsmul_eq_mul] at hsum
|
| 80 |
+
have hcard : (0:ℝ) < Fintype.card S := by exact_mod_cast hS
|
| 81 |
+
nlinarith
|
| 82 |
+
|
| 83 |
+
end UniformSparsestCut.GradientBudget
|
| 84 |
+
|
| 85 |
+
namespace UniformSparsestCut.ConvolutionBounds
|
| 86 |
+
open MeasureTheory Set
|
| 87 |
+
open scoped BigOperators
|
| 88 |
+
variable {G : Type u5} {A : Type u6} [NormedAddCommGroup G] [NormedSpace ℝ G]
|
| 89 |
+
[MeasurableSpace G] [BorelSpace G] [Fintype A]
|
| 90 |
+
{μ : Measure G} [SFinite μ] [μ.IsAddLeftInvariant] [μ.IsNegInvariant]
|
| 91 |
+
|
| 92 |
+
def smooth (κ f : G → ℝ) (μ : Measure G) : G → ℝ :=
|
| 93 |
+
convolution κ f (ContinuousLinearMap.mul ℝ ℝ) μ
|
| 94 |
+
|
| 95 |
+
omit [NormedSpace ℝ G] [BorelSpace G] [SFinite μ] [μ.IsAddLeftInvariant] [μ.IsNegInvariant] in
|
| 96 |
+
lemma smooth_eq (κ f : G → ℝ) (x : G) :
|
| 97 |
+
smooth κ f μ x = ∫ z, κ z*f (x-z) ∂μ := rfl
|
| 98 |
+
|
| 99 |
+
lemma smooth_deriv {κ f : G → ℝ} (hk : HasCompactSupport κ)
|
| 100 |
+
(hc : ContDiff ℝ 1 κ) (hf : LocallyIntegrable f μ) (x h : G) :
|
| 101 |
+
fderiv ℝ (smooth κ f μ) x h = ∫ z, (fderiv ℝ κ z h)*f (x-z) ∂μ := by
|
| 102 |
+
unfold smooth
|
| 103 |
+
rw [(hk.hasFDerivAt_convolution_left (ContinuousLinearMap.mul ℝ ℝ) hc hf x).fderiv]
|
| 104 |
+
have hi := (hk.fderiv ℝ).convolutionExists_left
|
| 105 |
+
((ContinuousLinearMap.mul ℝ ℝ).precompL G) (hc.continuous_fderiv (by norm_num)) hf x
|
| 106 |
+
exact ContinuousLinearMap.integral_apply hi h
|
| 107 |
+
|
| 108 |
+
omit [SFinite μ] in
|
| 109 |
+
lemma smooth_deriv_integrable {κ f : G → ℝ} (hk : HasCompactSupport κ)
|
| 110 |
+
(hc : ContDiff ℝ 1 κ) (hf : LocallyIntegrable f μ) (x h : G) :
|
| 111 |
+
Integrable (fun z => (fderiv ℝ κ z h)*f (x-z)) μ := by
|
| 112 |
+
have hi := (hk.fderiv ℝ).convolutionExists_left
|
| 113 |
+
((ContinuousLinearMap.mul ℝ ℝ).precompL G) (hc.continuous_fderiv (by norm_num)) hf x
|
| 114 |
+
exact hi.apply_continuousLinearMap h
|
| 115 |
+
|
| 116 |
+
omit [NormedAddCommGroup G] [NormedSpace ℝ G] [BorelSpace G] [SFinite μ] [μ.IsAddLeftInvariant] [μ.IsNegInvariant] in
|
| 117 |
+
|
| 118 |
+
lemma integral_l1_bound (f : A → G → ℝ) (hf : ∀ a, Integrable (f a) μ)
|
| 119 |
+
{B : G → ℝ} (hB : Integrable B μ) (hb : ∀ᵐ z ∂μ, ∑ a, |f a z| ≤ B z) :
|
| 120 |
+
(∑ a, |∫ z, f a z ∂μ|) ≤ ∫ z, B z ∂μ := by
|
| 121 |
+
calc
|
| 122 |
+
_ ≤ ∑ a, ∫ z, |f a z| ∂μ := Finset.sum_le_sum (fun a _ => by
|
| 123 |
+
simpa only [Real.norm_eq_abs] using norm_integral_le_integral_norm (f a))
|
| 124 |
+
_ = ∫ z, ∑ a, |f a z| ∂μ := (integral_finsetSum _ (fun a _ => (hf a).abs)).symm
|
| 125 |
+
_ ≤ _ := integral_mono_ae (integrable_finsetSum _ (fun a _ => (hf a).abs)) hB hb
|
| 126 |
+
|
| 127 |
+
lemma mismatch {κ : G → ℝ} (hk : HasCompactSupport κ) (hc : ContDiff ℝ 1 κ)
|
| 128 |
+
(f g : A → G → ℝ) (hf : ∀ a, LocallyIntegrable (f a) μ)
|
| 129 |
+
(hg : ∀ a, LocallyIntegrable (g a) μ) (x h : G) {B : ℝ}
|
| 130 |
+
(hki : Integrable (fun z => |fderiv ℝ κ z h|) μ)
|
| 131 |
+
(hb : ∀ᵐ z ∂μ, fderiv ℝ κ z h ≠ 0 → ∑ a, |f a (x-z)-g a (x-z)| ≤ B) :
|
| 132 |
+
(∑ a, |fderiv ℝ (smooth κ (f a) μ) x h-fderiv ℝ (smooth κ (g a) μ) x h|) ≤
|
| 133 |
+
B*(∫ z, |fderiv ℝ κ z h| ∂μ) := by
|
| 134 |
+
simp_rw [smooth_deriv hk hc (hf _),smooth_deriv hk hc (hg _)]
|
| 135 |
+
have hi (a : A) : Integrable (fun z => fderiv ℝ κ z h*(f a (x-z)-g a (x-z))) μ := by
|
| 136 |
+
convert! (smooth_deriv_integrable hk hc (hf a) x h).sub
|
| 137 |
+
(smooth_deriv_integrable hk hc (hg a) x h) using 1
|
| 138 |
+
ext z
|
| 139 |
+
simp only [Pi.sub_apply,mul_sub]
|
| 140 |
+
have he (a : A) : (∫ z, fderiv ℝ κ z h*f a (x-z) ∂μ)-
|
| 141 |
+
(∫ z, fderiv ℝ κ z h*g a (x-z) ∂μ) =
|
| 142 |
+
∫ z, fderiv ℝ κ z h*(f a (x-z)-g a (x-z)) ∂μ := by
|
| 143 |
+
simp only [mul_sub]
|
| 144 |
+
exact (integral_sub (smooth_deriv_integrable hk hc (hf a) x h)
|
| 145 |
+
(smooth_deriv_integrable hk hc (hg a) x h)).symm
|
| 146 |
+
simp_rw [he]
|
| 147 |
+
rw [← integral_const_mul]
|
| 148 |
+
apply integral_l1_bound _ hi (hki.const_mul B)
|
| 149 |
+
filter_upwards [hb] with z hz
|
| 150 |
+
by_cases hn : fderiv ℝ κ z h=0
|
| 151 |
+
· simp [hn]
|
| 152 |
+
· simp_rw [abs_mul,← Finset.mul_sum]
|
| 153 |
+
simpa only [mul_comm] using mul_le_mul_of_nonneg_left (hz hn) (abs_nonneg (fderiv ℝ κ z h))
|
| 154 |
+
|
| 155 |
+
omit [NormedSpace ℝ G] [SFinite μ] in
|
| 156 |
+
|
| 157 |
+
lemma error {κ : G → ℝ} (hk : HasCompactSupport κ) (hc : Continuous κ)
|
| 158 |
+
(hki : Integrable κ μ) (hkn : ∀ z, 0 ≤ κ z) (hk1 : ∫ z, κ z ∂μ=1)
|
| 159 |
+
(f : A → G → ℝ) (hf : ∀ a, LocallyIntegrable (f a) μ) (x : G) {B : ℝ}
|
| 160 |
+
(hb : ∀ᵐ z ∂μ, κ z ≠ 0 → ∑ a, |f a (x-z)-f a x| ≤ B) :
|
| 161 |
+
(∑ a, |smooth κ (f a) μ x-f a x|) ≤ B := by
|
| 162 |
+
have hi0 (a : A) : Integrable (fun z => κ z*f a (x-z)) μ :=
|
| 163 |
+
hk.convolutionExists_left (ContinuousLinearMap.mul ℝ ℝ) hc (hf a) x
|
| 164 |
+
have hi (a : A) : Integrable (fun z => κ z*(f a (x-z)-f a x)) μ := by
|
| 165 |
+
convert! (hi0 a).sub (hki.mul_const (f a x)) using 1
|
| 166 |
+
ext z
|
| 167 |
+
simp only [Pi.sub_apply,mul_sub]
|
| 168 |
+
have he (a : A) : smooth κ (f a) μ x-f a x = ∫ z, κ z*(f a (x-z)-f a x) ∂μ := by
|
| 169 |
+
rw [smooth_eq]
|
| 170 |
+
simp only [mul_sub]
|
| 171 |
+
rw [integral_sub (hi0 a)
|
| 172 |
+
(hki.mul_const (f a x)),integral_mul_const,hk1,one_mul]
|
| 173 |
+
simp_rw [he]
|
| 174 |
+
have hres := integral_l1_bound (μ := μ) _ hi (hki.const_mul B) (by
|
| 175 |
+
filter_upwards [hb] with z hz
|
| 176 |
+
by_cases hn : κ z=0
|
| 177 |
+
· simp [hn]
|
| 178 |
+
· simp_rw [abs_mul,abs_of_nonneg (hkn z),← Finset.mul_sum]
|
| 179 |
+
simpa only [mul_comm] using mul_le_mul_of_nonneg_left (hz hn) (hkn z))
|
| 180 |
+
simpa only [integral_const_mul,hk1,mul_one] using hres
|
| 181 |
+
|
| 182 |
+
end UniformSparsestCut.ConvolutionBounds
|
| 183 |
+
|
| 184 |
+
namespace UniformSparsestCut.GradientCalculus
|
| 185 |
+
open MeasureTheory Set
|
| 186 |
+
open scoped BigOperators RealInnerProductSpace
|
| 187 |
+
noncomputable section
|
| 188 |
+
variable {m : ℕ} {A : Type u7} {S : Type u8} {I : Type u9} [Fintype A] [Fintype S] [Fintype I] [DecidableEq S]
|
| 189 |
+
local notation "E" => EuclideanSpace ℝ (Fin m)
|
| 190 |
+
|
| 191 |
+
def vector (D : StrongDual ℝ E) : E := (InnerProductSpace.toDual ℝ E).symm D
|
| 192 |
+
@[simp] lemma vector_norm (D : StrongDual ℝ E) : ‖vector D‖=‖D‖ :=
|
| 193 |
+
(InnerProductSpace.toDual ℝ E).symm.norm_map D
|
| 194 |
+
@[simp] lemma vector_inner (D : StrongDual ℝ E) (x : E) : inner ℝ (vector D) x=D x :=
|
| 195 |
+
InnerProductSpace.toDual_symm_apply
|
| 196 |
+
lemma vector_coordinate (D : StrongDual ℝ E) (j : Fin m) :
|
| 197 |
+
vector D j=D (EuclideanSpace.single j 1) := by
|
| 198 |
+
have h := vector_inner D (EuclideanSpace.single j 1)
|
| 199 |
+
simpa [PiLp.inner_apply,PiLp.single_apply] using h
|
| 200 |
+
lemma norm_le_partials (D : StrongDual ℝ E) : ‖D‖≤∑ j, |D (EuclideanSpace.single j 1)| := by
|
| 201 |
+
rw [← vector_norm]
|
| 202 |
+
have he : vector D=∑ j, EuclideanSpace.single j (vector D j) := by
|
| 203 |
+
ext i
|
| 204 |
+
simp
|
| 205 |
+
calc
|
| 206 |
+
_ = ‖∑ j, EuclideanSpace.single j (vector D j)‖ := congrArg norm he
|
| 207 |
+
_ ≤ ∑ j, ‖EuclideanSpace.single j (vector D j)‖ := norm_sum_le _ _
|
| 208 |
+
_ = _ := by simp only [PiLp.norm_single,Real.norm_eq_abs,vector_coordinate]
|
| 209 |
+
lemma vector_representation (D : StrongDual ℝ E) (u : I → E) (β : I → ℝ)
|
| 210 |
+
(hd : D=∑ i, β i • InnerProductSpace.toDual ℝ E (u i)) :
|
| 211 |
+
vector D=∑ i, β i • u i := by
|
| 212 |
+
apply (InnerProductSpace.toDual ℝ E).injective
|
| 213 |
+
simp only [vector,LinearIsometryEquiv.apply_symm_apply,map_sum,map_smul,hd]
|
| 214 |
+
|
| 215 |
+
lemma gradient_mismatch {κ : E → ℝ} (hk : HasCompactSupport κ) (hc : ContDiff ℝ 1 κ)
|
| 216 |
+
(f g : A → E → ℝ) (hf : ∀ a, LocallyIntegrable (f a))
|
| 217 |
+
(hg : ∀ a, LocallyIntegrable (g a)) (x : E) {B L : ℝ}
|
| 218 |
+
(hki : ∀ j : Fin m, Integrable (fun z => |fderiv ℝ κ z (EuclideanSpace.single j 1)|))
|
| 219 |
+
(hL : ∀ j : Fin m, ∫ z, |fderiv ℝ κ z (EuclideanSpace.single j 1)| = L)
|
| 220 |
+
(hb : ∀ᵐ z, (∃ j : Fin m, fderiv ℝ κ z (EuclideanSpace.single j 1)≠0) →
|
| 221 |
+
∑ a, |f a (x-z)-g a (x-z)|≤B) :
|
| 222 |
+
(∑ a, ‖fderiv ℝ (ConvolutionBounds.smooth κ (f a) volume) x-
|
| 223 |
+
fderiv ℝ (ConvolutionBounds.smooth κ (g a) volume) x‖)≤(m:ℝ)*B*L := by
|
| 224 |
+
calc
|
| 225 |
+
_ ≤ ∑ a, ∑ j : Fin m, |fderiv ℝ (ConvolutionBounds.smooth κ (f a) volume) x (EuclideanSpace.single j 1)-
|
| 226 |
+
fderiv ℝ (ConvolutionBounds.smooth κ (g a) volume) x (EuclideanSpace.single j 1)| := by
|
| 227 |
+
apply Finset.sum_le_sum; intro a _
|
| 228 |
+
exact norm_le_partials _
|
| 229 |
+
_ = ∑ j : Fin m, ∑ a, |fderiv ℝ (ConvolutionBounds.smooth κ (f a) volume) x (EuclideanSpace.single j 1)-
|
| 230 |
+
fderiv ℝ (ConvolutionBounds.smooth κ (g a) volume) x (EuclideanSpace.single j 1)| := Finset.sum_comm
|
| 231 |
+
_ ≤ ∑ _j : Fin m, B*L := by
|
| 232 |
+
apply Finset.sum_le_sum; intro j _
|
| 233 |
+
rw [← hL j]
|
| 234 |
+
apply ConvolutionBounds.mismatch hk hc f g hf hg x _ (hki j)
|
| 235 |
+
filter_upwards [hb] with z hz hj using hz ⟨j,hj⟩
|
| 236 |
+
_ = _ := by simp; ring
|
| 237 |
+
|
| 238 |
+
omit [DecidableEq S] in
|
| 239 |
+
lemma gradient_budget (u : S → I → E) (β : S → I → A → ℝ)
|
| 240 |
+
(D : S → A → StrongDual ℝ E) (base : A → StrongDual ℝ E)
|
| 241 |
+
{δ B R : ℝ} (hδ : 0≤δ)
|
| 242 |
+
(hd : ∀ s a, D s a=∑ i, β s i a • InnerProductSpace.toDual ℝ E (u s i))
|
| 243 |
+
(hgood : ∀ a, ∃ good : Finset S, (Fintype.card S:ℝ)/2≤good.card ∧
|
| 244 |
+
∀ s∈good, ∀ i, |base a (u s i)|≤δ*‖base a‖)
|
| 245 |
+
(hβ : ∀ s, ∑ i, ∑ a, |β s i a|≤B)
|
| 246 |
+
(he : ∀ s, ∑ a, ‖D s a-base a‖≤R) (hS : 0<Fintype.card S) :
|
| 247 |
+
∑ a, ‖base a‖≤2*(δ*B+R) := by
|
| 248 |
+
have hvec (s : S) (a : A) : vector (base a)+vector (D s a-base a)=∑ i, β s i a • u s i := by
|
| 249 |
+
change (InnerProductSpace.toDual ℝ E).symm (base a)+(InnerProductSpace.toDual ℝ E).symm (D s a-base a)=_
|
| 250 |
+
rw [← map_add,add_sub_cancel]
|
| 251 |
+
exact vector_representation _ _ _ (hd s a)
|
| 252 |
+
have hg (a : A) : ∃ good : Finset S, (Fintype.card S:ℝ)/2≤good.card ∧
|
| 253 |
+
∀ s∈good, ∀ i, |inner ℝ (u s i) (vector (base a))|≤δ*‖vector (base a)‖ := by
|
| 254 |
+
obtain ⟨good,hc,hg⟩ := hgood a
|
| 255 |
+
refine ⟨good,hc,?_⟩
|
| 256 |
+
intro s hs i
|
| 257 |
+
rw [real_inner_comm,vector_inner,vector_norm]
|
| 258 |
+
exact hg s hs i
|
| 259 |
+
simpa only [vector_norm] using GradientBudget.total_gradient u β (fun a => vector (base a))
|
| 260 |
+
(fun s a => vector (D s a-base a)) hδ hvec hg hβ
|
| 261 |
+
(by intro s; simpa only [vector_norm] using he s) hS
|
| 262 |
+
end
|
| 263 |
+
end UniformSparsestCut.GradientCalculus
|
| 264 |
+
|
| 265 |
+
end
|
| 266 |
+
|
| 267 |
+
end OAI
|
lean/OAI/Combinatorics/SparsestCut/InterfaceStep.lean
ADDED
|
@@ -0,0 +1,582 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import OAI.Combinatorics.SparsestCut.ContractionBounds
|
| 2 |
+
|
| 3 |
+
namespace OAI
|
| 4 |
+
|
| 5 |
+
universe u1 u2 u3 u4 u5 u6 u7 u8 u9 u10
|
| 6 |
+
|
| 7 |
+
open scoped BigOperators Topology NNReal RealInnerProductSpace InnerProductSpace Matrix ContDiff ENNReal
|
| 8 |
+
open MeasureTheory ProbabilityTheory Set Filter Matrix
|
| 9 |
+
|
| 10 |
+
noncomputable section
|
| 11 |
+
|
| 12 |
+
namespace UniformSparsestCut.InterfaceStep
|
| 13 |
+
variable {ι : Type u1} {V : Type u2} [DecidableEq ι] [AddCommGroup V]
|
| 14 |
+
|
| 15 |
+
lemma telescoping_events (s : Finset ι) (t : ι → ℝ) (ht : Set.InjOn t s)
|
| 16 |
+
(F : Finset ι → V) :
|
| 17 |
+
(∑ i ∈ s, (F (s.filter (fun j => t j ≤ t i))-F (s.filter (fun j => t j < t i)))) =
|
| 18 |
+
F s-F ∅ := by
|
| 19 |
+
revert ht
|
| 20 |
+
induction s using Finset.strongInductionOn with
|
| 21 |
+
| _ s ih =>
|
| 22 |
+
intro ht
|
| 23 |
+
by_cases hs : s.Nonempty
|
| 24 |
+
· obtain ⟨a,ha,hmax⟩ := s.exists_max_image t hs
|
| 25 |
+
let r := s.erase a
|
| 26 |
+
have hr : r ⊂ s := Finset.erase_ssubset ha
|
| 27 |
+
have htr : Set.InjOn t (↑r : Set ι) := ht.mono (by intro i hi; exact Finset.mem_of_mem_erase hi)
|
| 28 |
+
have hind := ih r hr htr
|
| 29 |
+
have hle : s.filter (fun j => t j ≤ t a) = s := by
|
| 30 |
+
apply Finset.filter_eq_self.mpr; intro j hj; exact hmax j hj
|
| 31 |
+
have hlt : s.filter (fun j => t j < t a) = r := by
|
| 32 |
+
ext j
|
| 33 |
+
simp only [Finset.mem_filter, r, Finset.mem_erase]
|
| 34 |
+
constructor
|
| 35 |
+
· rintro ⟨hj,h⟩; exact ⟨fun he => by simp [he] at h,hj⟩
|
| 36 |
+
· rintro ⟨hne,hj⟩
|
| 37 |
+
exact ⟨hj,lt_of_le_of_ne (hmax j hj) (fun he => hne (ht hj ha he))⟩
|
| 38 |
+
have hfilters (i : ι) (hi : i ∈ r) :
|
| 39 |
+
s.filter (fun j => t j ≤ t i) = r.filter (fun j => t j ≤ t i) ∧
|
| 40 |
+
s.filter (fun j => t j < t i) = r.filter (fun j => t j < t i) := by
|
| 41 |
+
have hia : t i < t a := (Finset.mem_filter.mp (show i ∈ s.filter (fun j => t j < t a) by rw [hlt]; exact hi)).2
|
| 42 |
+
constructor <;> (ext j; simp only [Finset.mem_filter, r, Finset.mem_erase]; constructor)
|
| 43 |
+
· rintro ⟨hj,hji⟩
|
| 44 |
+
exact ⟨⟨fun he => by subst j; linarith,hj⟩,hji⟩
|
| 45 |
+
· rintro ⟨⟨_,hj⟩,hji⟩; exact ⟨hj,hji⟩
|
| 46 |
+
· rintro ⟨hj,hji⟩
|
| 47 |
+
exact ⟨⟨fun he => by subst j; linarith,hj⟩,hji⟩
|
| 48 |
+
· rintro ⟨⟨_,hj⟩,hji⟩; exact ⟨hj,hji⟩
|
| 49 |
+
rw [← Finset.sum_erase_add _ _ ha, hle,hlt]
|
| 50 |
+
change (∑ i ∈ r, _) + (F s-F r) = _
|
| 51 |
+
have he : (∑ i ∈ r, (F (s.filter (fun j => t j ≤ t i))-F (s.filter (fun j => t j < t i)))) =
|
| 52 |
+
∑ i ∈ r, (F (r.filter (fun j => t j ≤ t i))-F (r.filter (fun j => t j < t i))) := by
|
| 53 |
+
apply Finset.sum_congr rfl; intro i hi; rw [(hfilters i hi).1,(hfilters i hi).2]
|
| 54 |
+
rw [he,hind]
|
| 55 |
+
abel
|
| 56 |
+
· simp [Finset.not_nonempty_iff_eq_empty.mp hs]
|
| 57 |
+
|
| 58 |
+
lemma threshold_decomposition (s : Finset ι) (t : ι → ℝ) (ht : Set.InjOn t s)
|
| 59 |
+
(F : Finset ι → V) (x : ℝ) :
|
| 60 |
+
F (s.filter (fun i => t i < x)) = F ∅+
|
| 61 |
+
∑ i ∈ s, if t i < x then
|
| 62 |
+
F (s.filter (fun j => t j ≤ t i))-F (s.filter (fun j => t j < t i)) else 0 := by
|
| 63 |
+
let r := s.filter (fun i => t i < x)
|
| 64 |
+
have htr : Set.InjOn t (↑r : Set ι) := ht.mono (by intro i hi; exact (Finset.mem_filter.mp hi).1)
|
| 65 |
+
have h := telescoping_events r t htr F
|
| 66 |
+
have hfilters (i : ι) (hi : i ∈ r) :
|
| 67 |
+
r.filter (fun j => t j ≤ t i) = s.filter (fun j => t j ≤ t i) ∧
|
| 68 |
+
r.filter (fun j => t j < t i) = s.filter (fun j => t j < t i) := by
|
| 69 |
+
have hix : t i < x := (Finset.mem_filter.mp hi).2
|
| 70 |
+
constructor <;> (ext j; simp only [r,Finset.mem_filter]; constructor)
|
| 71 |
+
· rintro ⟨⟨hj,_⟩,hji⟩; exact ⟨hj,hji⟩
|
| 72 |
+
· rintro ⟨hj,hji⟩; exact ⟨⟨hj,lt_of_le_of_lt hji hix⟩,hji⟩
|
| 73 |
+
· rintro ⟨⟨hj,_⟩,hji⟩; exact ⟨hj,hji⟩
|
| 74 |
+
· rintro ⟨hj,hji⟩; exact ⟨⟨hj,hji.trans hix⟩,hji⟩
|
| 75 |
+
have he : (∑ i ∈ r, (F (r.filter (fun j => t j ≤ t i))-F (r.filter (fun j => t j < t i)))) =
|
| 76 |
+
∑ i ∈ r, (F (s.filter (fun j => t j ≤ t i))-F (s.filter (fun j => t j < t i))) := by
|
| 77 |
+
apply Finset.sum_congr rfl; intro i hi; rw [(hfilters i hi).1,(hfilters i hi).2]
|
| 78 |
+
rw [he] at h
|
| 79 |
+
rw [← Finset.sum_filter]
|
| 80 |
+
change F r = F ∅+_
|
| 81 |
+
rw [h]
|
| 82 |
+
abel
|
| 83 |
+
|
| 84 |
+
section Integral
|
| 85 |
+
variable {W : Type u3} [NormedAddCommGroup W] [NormedSpace ℝ W] [CompleteSpace W]
|
| 86 |
+
|
| 87 |
+
lemma integral_deriv_eq_zero {φ : ℝ → ℝ} (hφ : ContDiff ℝ 1 φ)
|
| 88 |
+
(hc : HasCompactSupport φ) : ∫ x, deriv φ x = 0 := by
|
| 89 |
+
apply integral_eq_zero_of_hasDerivAt_of_integrable
|
| 90 |
+
(fun x => (hφ.differentiable one_ne_zero x).hasDerivAt)
|
| 91 |
+
· exact (hφ.continuous_deriv le_rfl).integrable_of_hasCompactSupport hc.deriv
|
| 92 |
+
· exact hφ.continuous.integrable_of_hasCompactSupport hc
|
| 93 |
+
|
| 94 |
+
lemma threshold_integral_deriv (s : Finset ι) (t : ι → ℝ) (ht : Set.InjOn t s)
|
| 95 |
+
(F : Finset ι → W) {φ : ℝ → ℝ} (hφ : ContDiff ℝ 1 φ)
|
| 96 |
+
(hc : HasCompactSupport φ) :
|
| 97 |
+
(∫ x, deriv φ x • F (s.filter (fun i => t i < x))) =
|
| 98 |
+
-∑ i ∈ s, φ (t i) •
|
| 99 |
+
(F (s.filter (fun j => t j ≤ t i))-F (s.filter (fun j => t j < t i))) := by
|
| 100 |
+
let Δ := fun i => F (s.filter (fun j => t j ≤ t i))-F (s.filter (fun j => t j < t i))
|
| 101 |
+
have hd : Integrable (deriv φ) :=
|
| 102 |
+
(hφ.continuous_deriv le_rfl).integrable_of_hasCompactSupport hc.deriv
|
| 103 |
+
have hi (i : ι) : Integrable (fun x => deriv φ x • (if t i < x then Δ i else 0)) := by
|
| 104 |
+
have he : (fun x => deriv φ x • (if t i < x then Δ i else 0)) =
|
| 105 |
+
(Ioi (t i)).indicator (fun x => deriv φ x • Δ i) := by
|
| 106 |
+
funext x; by_cases hx : t i < x <;> simp [hx]
|
| 107 |
+
rw [he]
|
| 108 |
+
exact (hd.smul_const _).indicator measurableSet_Ioi
|
| 109 |
+
have he (x : ℝ) : deriv φ x • F (s.filter (fun i => t i < x)) =
|
| 110 |
+
deriv φ x • F ∅ + ∑ i ∈ s, deriv φ x • (if t i < x then Δ i else 0) := by
|
| 111 |
+
rw [threshold_decomposition s t ht F x, smul_add, Finset.smul_sum]
|
| 112 |
+
simp_rw [he]
|
| 113 |
+
rw [integral_add (hd.smul_const _) (integrable_finsetSum _ (fun i _ => hi i)),
|
| 114 |
+
integral_smul_const, integral_deriv_eq_zero hφ hc, zero_smul, zero_add,
|
| 115 |
+
integral_finsetSum _ (fun i _ => hi i), ← Finset.sum_neg_distrib]
|
| 116 |
+
apply Finset.sum_congr rfl
|
| 117 |
+
intro i hi'
|
| 118 |
+
have he : (fun x => deriv φ x • (if t i < x then Δ i else 0)) =
|
| 119 |
+
(Ioi (t i)).indicator (fun x => deriv φ x • Δ i) := by
|
| 120 |
+
funext x; by_cases hx : t i < x <;> simp [hx]
|
| 121 |
+
rw [he, integral_indicator measurableSet_Ioi, integral_smul_const,
|
| 122 |
+
hc.integral_Ioi_deriv_eq hφ, neg_smul]
|
| 123 |
+
end Integral
|
| 124 |
+
|
| 125 |
+
section MovingEvents
|
| 126 |
+
variable {X : Type u4} [MeasurableSpace X]
|
| 127 |
+
|
| 128 |
+
lemma measurable_filter_apply (s : Finset ι) (P : ι → X → Prop)
|
| 129 |
+
[∀ i, DecidablePred (P i)] (hP : ∀ i, MeasurableSet {x | P i x})
|
| 130 |
+
(F : Finset ι → ℝ) : Measurable (fun x => F (s.filter (fun i => P i x))) := by
|
| 131 |
+
classical
|
| 132 |
+
induction s using Finset.induction_on generalizing F with
|
| 133 |
+
| empty => simp
|
| 134 |
+
| @insert i s hi ih =>
|
| 135 |
+
have h₁ := ih (fun a => F (insert i a))
|
| 136 |
+
have h₂ := ih F
|
| 137 |
+
have h : Measurable (fun x => if P i x then F (insert i (s.filter (fun j => P j x))) else F (s.filter (fun j => P j x))) := Measurable.ite (hP i) h₁ h₂
|
| 138 |
+
convert h using 1
|
| 139 |
+
funext x
|
| 140 |
+
by_cases hx : P i x <;> simp [Finset.filter_insert, hx]
|
| 141 |
+
|
| 142 |
+
end MovingEvents
|
| 143 |
+
|
| 144 |
+
section ContinuousEvents
|
| 145 |
+
variable [Fintype ι] {X : Type u5} [TopologicalSpace X] [FirstCountableTopology X]
|
| 146 |
+
|
| 147 |
+
omit [DecidableEq ι] [Fintype ι] [FirstCountableTopology X] in
|
| 148 |
+
lemma eventually_threshold_eq (s : Finset ι) (t : ι → X → ℝ) {y : X} {x : ℝ}
|
| 149 |
+
(ht : ∀ i ∈ s, ContinuousAt (t i) y) (hx : ∀ i ∈ s, x ≠ t i y) :
|
| 150 |
+
∀ᶠ z in 𝓝 y, s.filter (fun i => t i z < x) = s.filter (fun i => t i y < x) := by
|
| 151 |
+
have hi (i : ι) (hi : i ∈ s) : ∀ᶠ z in 𝓝 y, (t i z < x ↔ t i y < x) := by
|
| 152 |
+
rcases lt_or_gt_of_ne (hx i hi) with h | h
|
| 153 |
+
· filter_upwards [(ht i hi).eventually (lt_mem_nhds h)] with z hz
|
| 154 |
+
exact iff_of_false (not_lt.mpr hz.le) (not_lt.mpr h.le)
|
| 155 |
+
· filter_upwards [(ht i hi).eventually (gt_mem_nhds h)] with z hz
|
| 156 |
+
exact iff_of_true hz h
|
| 157 |
+
filter_upwards [s.eventually_all.mpr hi] with z hz
|
| 158 |
+
ext i
|
| 159 |
+
simp only [Finset.mem_filter]
|
| 160 |
+
exact and_congr_right (fun hi => hz i hi)
|
| 161 |
+
|
| 162 |
+
lemma continuousAt_threshold_integral (s : Finset ι) (t : ι → X → ℝ) (F : Finset ι → ℝ)
|
| 163 |
+
{y : X} (ht : ∀ i ∈ s, ContinuousAt (t i) y) {φ : ℝ → ℝ} (hφ : Integrable φ) :
|
| 164 |
+
ContinuousAt (fun z => ∫ x, φ x * F (s.filter (fun i => t i z < x))) y := by
|
| 165 |
+
let M : ℝ := ∑ a : Finset ι, |F a|
|
| 166 |
+
have hM (a : Finset ι) : |F a| ≤ M := by
|
| 167 |
+
exact Finset.single_le_sum (f := fun a : Finset ι => |F a|) (fun _ _ => abs_nonneg _) (Finset.mem_univ a)
|
| 168 |
+
apply continuousAt_of_dominated (bound := fun x => |φ x| * M)
|
| 169 |
+
· apply Filter.Eventually.of_forall
|
| 170 |
+
intro z
|
| 171 |
+
exact hφ.aestronglyMeasurable.mul ((measurable_filter_apply s
|
| 172 |
+
(fun i x => t i z < x) (fun _ => measurableSet_Ioi) F).aestronglyMeasurable)
|
| 173 |
+
· exact Filter.Eventually.of_forall (fun z => ae_of_all _ (fun x => by
|
| 174 |
+
simp only [Real.norm_eq_abs, abs_mul]
|
| 175 |
+
exact mul_le_mul_of_nonneg_left (hM _) (abs_nonneg _)))
|
| 176 |
+
· exact hφ.abs.mul_const M
|
| 177 |
+
· have hn : ∀ᵐ x : ℝ, ∀ i : ι, x ≠ t i y := ae_all_iff.mpr (fun i => volume.ae_ne (t i y))
|
| 178 |
+
filter_upwards [hn] with x hx
|
| 179 |
+
have he := eventually_threshold_eq s t ht (fun i _ => hx i)
|
| 180 |
+
apply ContinuousAt.congr_of_eventuallyEq (by fun_prop : ContinuousAt (fun _ : X => φ x * F (s.filter (fun i => t i y < x))) y)
|
| 181 |
+
filter_upwards [he] with z hz
|
| 182 |
+
rw [hz]
|
| 183 |
+
|
| 184 |
+
omit [Fintype ι] in
|
| 185 |
+
lemma threshold_integral (s : Finset ι) (t : ι → ℝ) (ht : Set.InjOn t s)
|
| 186 |
+
(F : Finset ι → ℝ) {φ : ℝ → ℝ} (hφ : Integrable φ) :
|
| 187 |
+
(∫ x, φ x * F (s.filter (fun i => t i < x))) =
|
| 188 |
+
(∫ x, φ x)*F ∅ + ∑ i ∈ s, (∫ x in Ioi (t i), φ x) *
|
| 189 |
+
(F (s.filter (fun j => t j ≤ t i))-F (s.filter (fun j => t j < t i))) := by
|
| 190 |
+
let Δ := fun i => F (s.filter (fun j => t j ≤ t i))-F (s.filter (fun j => t j < t i))
|
| 191 |
+
have hi (i : ι) : Integrable (fun x => φ x * (if t i < x then Δ i else 0)) := by
|
| 192 |
+
have he : (fun x => φ x * (if t i < x then Δ i else 0)) =
|
| 193 |
+
(Ioi (t i)).indicator (fun x => φ x * Δ i) := by
|
| 194 |
+
funext x; by_cases hx : t i < x <;> simp [hx]
|
| 195 |
+
rw [he]
|
| 196 |
+
exact (hφ.mul_const _).indicator measurableSet_Ioi
|
| 197 |
+
have he (x : ℝ) : φ x * F (s.filter (fun i => t i < x)) =
|
| 198 |
+
φ x * F ∅ + ∑ i ∈ s, φ x * (if t i < x then Δ i else 0) := by
|
| 199 |
+
rw [threshold_decomposition s t ht F x, mul_add, Finset.mul_sum]
|
| 200 |
+
simp_rw [he]
|
| 201 |
+
rw [integral_add (hφ.mul_const _) (integrable_finsetSum _ (fun i _ => hi i)),
|
| 202 |
+
integral_mul_const, integral_finsetSum _ (fun i _ => hi i)]
|
| 203 |
+
congr 1
|
| 204 |
+
apply Finset.sum_congr rfl
|
| 205 |
+
intro i hi'
|
| 206 |
+
have he : (fun x => φ x * (if t i < x then Δ i else 0)) =
|
| 207 |
+
(Ioi (t i)).indicator (fun x => φ x * Δ i) := by
|
| 208 |
+
funext x; by_cases hx : t i < x <;> simp [hx]
|
| 209 |
+
rw [he, integral_indicator measurableSet_Ioi, integral_mul_const]
|
| 210 |
+
|
| 211 |
+
lemma tail_integral_hasDerivAt {φ : ℝ → ℝ} (hφ : Integrable φ) (hc : Continuous φ) (x : ℝ) :
|
| 212 |
+
HasDerivAt (fun t => ∫ z in Ioi t, φ z) (-φ x) x := by
|
| 213 |
+
have he (t : ℝ) : (∫ z in Ioi t, φ z) = (∫ z in Ioi (0:ℝ), φ z)-(∫ z in (0:ℝ)..t, φ z) := by
|
| 214 |
+
rw [← intervalIntegral.integral_Ioi_sub_Ioi' hφ.integrableOn hφ.integrableOn]
|
| 215 |
+
ring
|
| 216 |
+
rw [show (fun t => ∫ z in Ioi t, φ z) = (fun t => (∫ z in Ioi (0:ℝ), φ z)-(∫ z in (0:ℝ)..t, φ z)) from funext he]
|
| 217 |
+
exact (intervalIntegral.integral_hasDerivAt_right (hφ.intervalIntegrable) hc.stronglyMeasurable.stronglyMeasurableAtFilter hc.continuousAt).const_sub _
|
| 218 |
+
end ContinuousEvents
|
| 219 |
+
|
| 220 |
+
section Slope
|
| 221 |
+
variable [Fintype ι]
|
| 222 |
+
|
| 223 |
+
omit [Fintype ι] in
|
| 224 |
+
lemma eventually_order_eq {X : Type u6} [TopologicalSpace X] (s : Finset ι) (t : ι → X → ℝ) {y : X}
|
| 225 |
+
(ht : ∀ i ∈ s, ContinuousAt (t i) y) (hi : Set.InjOn (fun i => t i y) s) :
|
| 226 |
+
∀ᶠ z in 𝓝 y, Set.InjOn (fun i => t i z) s ∧
|
| 227 |
+
∀ i ∈ s, s.filter (fun j => t j z ≤ t i z) = s.filter (fun j => t j y ≤ t i y) ∧
|
| 228 |
+
s.filter (fun j => t j z < t i z) = s.filter (fun j => t j y < t i y) := by
|
| 229 |
+
have hp (i : ι) (his : i ∈ s) (j : ι) (hjs : j ∈ s) :
|
| 230 |
+
∀ᶠ z in 𝓝 y, (t i z < t j z ↔ t i y < t j y) := by
|
| 231 |
+
by_cases hij : i = j
|
| 232 |
+
· subst j; simp
|
| 233 |
+
have hne : t i y ≠ t j y := fun he => hij (hi his hjs he)
|
| 234 |
+
rcases hne.lt_or_gt with h | h
|
| 235 |
+
· filter_upwards [(ht i his).eventually_lt (ht j hjs) h] with z hz
|
| 236 |
+
exact iff_of_true hz h
|
| 237 |
+
· filter_upwards [(ht j hjs).eventually_lt (ht i his) h] with z hz
|
| 238 |
+
exact iff_of_false (not_lt.mpr hz.le) (not_lt.mpr h.le)
|
| 239 |
+
have hall : ∀ᶠ z in 𝓝 y, ∀ i ∈ s, ∀ j ∈ s, (t i z < t j z ↔ t i y < t j y) :=
|
| 240 |
+
s.eventually_all.mpr (fun i his => s.eventually_all.mpr (fun j hjs => hp i his j hjs))
|
| 241 |
+
filter_upwards [hall] with z hz
|
| 242 |
+
refine ⟨?_,?_⟩
|
| 243 |
+
· intro i his j hjs he
|
| 244 |
+
change t i z=t j z at he
|
| 245 |
+
apply hi his hjs
|
| 246 |
+
apply le_antisymm
|
| 247 |
+
· apply not_lt.mp
|
| 248 |
+
intro h
|
| 249 |
+
have := (hz j hjs i his).mpr h
|
| 250 |
+
rw [he] at this
|
| 251 |
+
exact (lt_irrefl _ this)
|
| 252 |
+
· apply not_lt.mp
|
| 253 |
+
intro h
|
| 254 |
+
have := (hz i his j hjs).mpr h
|
| 255 |
+
rw [he] at this
|
| 256 |
+
exact (lt_irrefl _ this)
|
| 257 |
+
· intro i his
|
| 258 |
+
constructor <;> ext j <;> simp only [Finset.mem_filter]
|
| 259 |
+
· apply and_congr_right
|
| 260 |
+
intro hjs
|
| 261 |
+
simp only [← not_lt, hz i his j hjs]
|
| 262 |
+
· exact and_congr_right (fun hjs => hz j hjs i his)
|
| 263 |
+
|
| 264 |
+
omit [Fintype ι] in
|
| 265 |
+
lemma moving_threshold_integral_hasDerivAt (s : Finset ι) (t : ι → ℝ → ℝ)
|
| 266 |
+
(F : Finset ι → ℝ) {y : ℝ} (t' : ι → ℝ)
|
| 267 |
+
(ht : ∀ i ∈ s, HasDerivAt (t i) (t' i) y) (hi : Set.InjOn (fun i => t i y) s)
|
| 268 |
+
{φ : ℝ → ℝ} (hφ : Integrable φ) (hc : Continuous φ) :
|
| 269 |
+
HasDerivAt (fun z => ∫ x, φ x * F (s.filter (fun i => t i z < x)))
|
| 270 |
+
(-∑ i ∈ s, t' i * φ (t i y) *
|
| 271 |
+
(F (s.filter (fun j => t j y ≤ t i y))-F (s.filter (fun j => t j y < t i y)))) y := by
|
| 272 |
+
let Δ := fun i => F (s.filter (fun j => t j y ≤ t i y))-F (s.filter (fun j => t j y < t i y))
|
| 273 |
+
have he : (fun z => ∫ x, φ x * F (s.filter (fun i => t i z < x))) =ᶠ[𝓝 y]
|
| 274 |
+
(fun z => (∫ x, φ x)*F ∅ + ∑ i ∈ s, (∫ x in Ioi (t i z), φ x)*Δ i) := by
|
| 275 |
+
filter_upwards [eventually_order_eq s t (fun i his => (ht i his).continuousAt) hi] with z hz
|
| 276 |
+
rw [threshold_integral s (fun i => t i z) hz.1 F hφ]
|
| 277 |
+
congr 1
|
| 278 |
+
apply Finset.sum_congr rfl
|
| 279 |
+
intro i his
|
| 280 |
+
rw [(hz.2 i his).1,(hz.2 i his).2]
|
| 281 |
+
have hd (i : ι) (his : i ∈ s) : HasDerivAt (fun z => (∫ x in Ioi (t i z), φ x)*Δ i)
|
| 282 |
+
(-(t' i * φ (t i y)*Δ i)) y := by
|
| 283 |
+
convert ((tail_integral_hasDerivAt hφ hc (t i y)).comp y (ht i his)).mul_const (Δ i) using 1 <;> try rfl
|
| 284 |
+
ring
|
| 285 |
+
have hs := (HasDerivAt.sum (fun i his => hd i his)).const_add ((∫ x, φ x)*F ∅)
|
| 286 |
+
simp only [Finset.sum_neg_distrib, Finset.sum_apply] at hs
|
| 287 |
+
exact hs.congr_of_eventuallyEq he
|
| 288 |
+
|
| 289 |
+
end Slope
|
| 290 |
+
|
| 291 |
+
section Weak
|
| 292 |
+
variable [Fintype ι]
|
| 293 |
+
|
| 294 |
+
lemma integral_deriv_zero_off_countable {f f' : ℝ → ℝ}
|
| 295 |
+
(hf : Continuous f) (hs : HasCompactSupport f) (hs' : HasCompactSupport f')
|
| 296 |
+
(hi : Integrable f') {bad : Set ℝ} (hb : bad.Countable)
|
| 297 |
+
(hd : ∀ x ∉ bad, HasDerivAt f (f' x) x) : ∫ x, f' x = 0 := by
|
| 298 |
+
obtain ⟨R,hR,hbound⟩ := (hs.isCompact.union hs'.isCompact).isBounded.exists_pos_norm_lt
|
| 299 |
+
have hf0 {x : ℝ} (hx : R ≤ |x|) : f x=0 := by
|
| 300 |
+
apply image_eq_zero_of_notMem_tsupport
|
| 301 |
+
intro hm
|
| 302 |
+
have := hbound x (Or.inl hm)
|
| 303 |
+
simpa only [Real.norm_eq_abs] using not_lt.mpr hx this
|
| 304 |
+
have hf'0 {x : ℝ} (hx : R ≤ |x|) : f' x=0 := by
|
| 305 |
+
apply image_eq_zero_of_notMem_tsupport
|
| 306 |
+
intro hm
|
| 307 |
+
have := hbound x (Or.inr hm)
|
| 308 |
+
simpa only [Real.norm_eq_abs] using not_lt.mpr hx this
|
| 309 |
+
have hI := integral_eq_of_hasDerivAt_off_countable_of_le f f' (by linarith : -R ≤ R)
|
| 310 |
+
hb hf.continuousOn (fun x hx => hd x hx.2) hi.intervalIntegrable
|
| 311 |
+
rw [hf0 (by rw [abs_of_pos hR]), hf0 (by rw [abs_neg,abs_of_pos hR]),sub_self,
|
| 312 |
+
intervalIntegral.integral_of_le (by linarith)] at hI
|
| 313 |
+
rw [setIntegral_eq_integral_of_forall_compl_eq_zero (fun x hx => hf'0 (by
|
| 314 |
+
simp only [mem_Ioc,not_and_or,not_lt,not_le] at hx
|
| 315 |
+
rcases hx with hx | hx
|
| 316 |
+
· exact (neg_le_abs x).trans' (by linarith)
|
| 317 |
+
· exact (le_abs_self x).trans' hx.le))] at hI
|
| 318 |
+
exact hI
|
| 319 |
+
|
| 320 |
+
omit [DecidableEq ι] in
|
| 321 |
+
lemma affine_collisions_countable (s : Finset ι) (a b : ι → ℝ)
|
| 322 |
+
(hab : ∀ i ∈ s, ∀ j ∈ s, i ≠ j → a i ≠ a j ∨ b i ≠ b j) :
|
| 323 |
+
{y : ℝ | ¬ Set.InjOn (fun i => a i*y+b i) s}.Countable := by
|
| 324 |
+
classical
|
| 325 |
+
have hp (i j : ι) : {y : ℝ | i ∈ s ∧ j ∈ s ∧ i ≠ j ∧ a i*y+b i=a j*y+b j}.Subsingleton := by
|
| 326 |
+
intro x hx y hy
|
| 327 |
+
have h := hab i hx.1 j hx.2.1 hx.2.2.1
|
| 328 |
+
rcases h with h | h
|
| 329 |
+
· have he : (a i-a j)*(x-y)=0 := by nlinarith [hx.2.2.2,hy.2.2.2]
|
| 330 |
+
exact sub_eq_zero.mp ((mul_eq_zero.mp he).resolve_left (sub_ne_zero.mpr h))
|
| 331 |
+
· by_cases ha : a i=a j
|
| 332 |
+
· exfalso; apply h; have he := hx.2.2.2; rw [ha] at he; linarith
|
| 333 |
+
· have he : (a i-a j)*(x-y)=0 := by nlinarith [hx.2.2.2,hy.2.2.2]
|
| 334 |
+
exact sub_eq_zero.mp ((mul_eq_zero.mp he).resolve_left (sub_ne_zero.mpr ha))
|
| 335 |
+
apply (countable_iUnion (fun i => countable_iUnion (fun j => (hp i j).countable))).mono
|
| 336 |
+
intro y hy
|
| 337 |
+
simp only [mem_ofPred_eq,Set.InjOn,not_forall] at hy
|
| 338 |
+
obtain ⟨i,hi,j,hj,he,hne⟩ := hy
|
| 339 |
+
exact mem_iUnion.mpr ⟨i,mem_iUnion.mpr ⟨j,hi,hj,hne,he⟩⟩
|
| 340 |
+
|
| 341 |
+
lemma moving_threshold_weak (s : Finset ι) (a b : ι → ℝ)
|
| 342 |
+
(hab : ∀ i ∈ s, ∀ j ∈ s, i ≠ j → a i ≠ a j ∨ b i ≠ b j)
|
| 343 |
+
(F : Finset ι → ℝ) {φ χ χ' : ℝ → ℝ}
|
| 344 |
+
(hφ : Integrable φ) (hcφ : Continuous φ) (hcχ : Continuous χ)
|
| 345 |
+
(hsχ : HasCompactSupport χ) (hsχ' : HasCompactSupport χ')
|
| 346 |
+
(hdχ : ∀ y, HasDerivAt χ (χ' y) y)
|
| 347 |
+
(hi₁ : Integrable (fun y => χ' y * ∫ x, φ x * F (s.filter (fun i => a i*y+b i < x))))
|
| 348 |
+
(hi₂ : Integrable (fun y => χ y * ∑ i ∈ s, a i * φ (a i*y+b i) *
|
| 349 |
+
(F (s.filter (fun j => a j*y+b j ≤ a i*y+b i))-F (s.filter (fun j => a j*y+b j < a i*y+b i))))) :
|
| 350 |
+
(∫ y, χ' y * ∫ x, φ x * F (s.filter (fun i => a i*y+b i < x))) =
|
| 351 |
+
∫ y, χ y * ∑ i ∈ s, a i * φ (a i*y+b i) *
|
| 352 |
+
(F (s.filter (fun j => a j*y+b j ≤ a i*y+b i))-F (s.filter (fun j => a j*y+b j < a i*y+b i))) := by
|
| 353 |
+
let H := fun y => ∫ x, φ x * F (s.filter (fun i => a i*y+b i < x))
|
| 354 |
+
let D := fun y => ∑ i ∈ s, a i * φ (a i*y+b i) *
|
| 355 |
+
(F (s.filter (fun j => a j*y+b j ≤ a i*y+b i))-F (s.filter (fun j => a j*y+b j < a i*y+b i)))
|
| 356 |
+
have hH : Continuous H := continuous_iff_continuousAt.mpr (fun y =>
|
| 357 |
+
continuousAt_threshold_integral s (fun i y => a i*y+b i) F (fun _ _ => by fun_prop) hφ)
|
| 358 |
+
have hprod : HasCompactSupport (fun y => χ y * H y) := hsχ.mul_right
|
| 359 |
+
have hder : HasCompactSupport (fun y => χ' y * H y-χ y * D y) :=
|
| 360 |
+
hsχ'.mul_right.sub hsχ.mul_right
|
| 361 |
+
have hzero := integral_deriv_zero_off_countable (hcχ.mul hH) hprod hder (hi₁.sub hi₂)
|
| 362 |
+
(affine_collisions_countable s a b hab) (fun y hy => by
|
| 363 |
+
have hdy := moving_threshold_integral_hasDerivAt s (fun i y => a i*y+b i) F a
|
| 364 |
+
(fun i _ => by simpa using ((hasDerivAt_id y).const_mul (a i)).add_const (b i))
|
| 365 |
+
(not_not.mp hy) hφ hcφ
|
| 366 |
+
convert (hdχ y).mul hdy using 1
|
| 367 |
+
dsimp [D]
|
| 368 |
+
ring)
|
| 369 |
+
rw [integral_sub hi₁ hi₂,sub_eq_zero] at hzero
|
| 370 |
+
exact hzero
|
| 371 |
+
|
| 372 |
+
end Weak
|
| 373 |
+
|
| 374 |
+
section Lipschitz
|
| 375 |
+
variable [Fintype ι]
|
| 376 |
+
|
| 377 |
+
lemma threshold_integrable (s : Finset ι) (t : ι → ℝ) (F : Finset ι → ℝ)
|
| 378 |
+
{φ : ℝ → ℝ} (hφ : Integrable φ) :
|
| 379 |
+
Integrable (fun x => φ x * F (s.filter (fun i => t i < x))) := by
|
| 380 |
+
classical
|
| 381 |
+
let M := ∑ a : Finset ι, |F a|
|
| 382 |
+
apply hφ.mul_bdd (measurable_filter_apply s (fun i x => t i < x)
|
| 383 |
+
(fun _ => measurableSet_Ioi) F).aestronglyMeasurable
|
| 384 |
+
apply ae_of_all
|
| 385 |
+
intro x
|
| 386 |
+
exact Finset.single_le_sum (f := fun a : Finset ι => |F a|) (fun _ _ => abs_nonneg _) (Finset.mem_univ _)
|
| 387 |
+
|
| 388 |
+
lemma threshold_pointwise_bound (s : Finset ι) (t u : ι → ℝ) (F : Finset ι → ℝ)
|
| 389 |
+
{M : ℝ} (hM0 : 0 ≤ M) (hM : ∀ a, |F a| ≤ M) (x : ℝ) :
|
| 390 |
+
|F (s.filter (fun i => t i < x))-F (s.filter (fun i => u i < x))| ≤
|
| 391 |
+
2*M*∑ i ∈ s, (uIoc (t i) (u i)).indicator (fun _ => (1:ℝ)) x := by
|
| 392 |
+
classical
|
| 393 |
+
have hn (i : ι) : 0 ≤ (uIoc (t i) (u i)).indicator (fun _ => (1:ℝ)) x := by
|
| 394 |
+
by_cases hx : x ∈ uIoc (t i) (u i) <;> simp [hx]
|
| 395 |
+
by_cases he : ∀ i ∈ s, t i < x ↔ u i < x
|
| 396 |
+
· have he' : s.filter (fun i => t i < x) = s.filter (fun i => u i < x) := by
|
| 397 |
+
ext i; simp only [Finset.mem_filter]; exact and_congr_right (he i)
|
| 398 |
+
rw [he',sub_self,abs_zero]
|
| 399 |
+
exact mul_nonneg (by positivity) (Finset.sum_nonneg (fun i _ => hn i))
|
| 400 |
+
· simp only [not_forall] at he
|
| 401 |
+
obtain ⟨i,his,hi⟩ := he
|
| 402 |
+
have hx : x ∈ uIoc (t i) (u i) := by
|
| 403 |
+
change min (t i) (u i) < x ∧ x ≤ max (t i) (u i)
|
| 404 |
+
rcases lt_or_ge (t i) x with ht | ht <;> rcases lt_or_ge (u i) x with hu | hu
|
| 405 |
+
· exact False.elim (hi (iff_of_true ht hu))
|
| 406 |
+
· exact ⟨(min_le_left _ _).trans_lt ht,hu.trans (le_max_right _ _)⟩
|
| 407 |
+
· exact ⟨(min_le_right _ _).trans_lt hu,ht.trans (le_max_left _ _)⟩
|
| 408 |
+
· exact False.elim (hi (iff_of_false (not_lt.mpr ht) (not_lt.mpr hu)))
|
| 409 |
+
have hs : 1 ≤ ∑ i ∈ s, (uIoc (t i) (u i)).indicator (fun _ => (1:ℝ)) x := by
|
| 410 |
+
have hh := Finset.single_le_sum (fun j _ => hn j) his
|
| 411 |
+
simpa [hx] using hh
|
| 412 |
+
calc
|
| 413 |
+
_ ≤ |F (s.filter (fun i => t i < x))|+|F (s.filter (fun i => u i < x))| := abs_sub _ _
|
| 414 |
+
_ ≤ 2*M := by linarith [hM (s.filter (fun i => t i < x)),hM (s.filter (fun i => u i < x))]
|
| 415 |
+
_ ≤ _ := le_mul_of_one_le_right (by positivity) hs
|
| 416 |
+
|
| 417 |
+
lemma threshold_integral_diff_bound (s : Finset ι) (t u : ι → ℝ) (F : Finset ι → ℝ)
|
| 418 |
+
{φ : ℝ → ℝ} (hφ : Integrable φ) {M C : ℝ} (hM0 : 0 ≤ M) (hC : 0 ≤ C)
|
| 419 |
+
(hM : ∀ a, |F a| ≤ M) (hφC : ∀ x, |φ x| ≤ C) :
|
| 420 |
+
|(∫ x, φ x * F (s.filter (fun i => t i < x)))-
|
| 421 |
+
(∫ x, φ x * F (s.filter (fun i => u i < x)))| ≤
|
| 422 |
+
2*M*C*∑ i ∈ s, |u i-t i| := by
|
| 423 |
+
classical
|
| 424 |
+
let I := fun i x => (uIoc (t i) (u i)).indicator (fun _ => (1:ℝ)) x
|
| 425 |
+
have hi (i : ι) : Integrable (I i) := by
|
| 426 |
+
exact (integrable_indicator_iff measurableSet_uIoc).mpr (integrableOn_const (μ := volume) (s := uIoc (t i) (u i)) (C := (1:ℝ)) (by rw [Real.volume_uIoc]; exact ENNReal.ofReal_ne_top))
|
| 427 |
+
have hiS : Integrable (fun x => 2*M*C*∑ i ∈ s, I i x) :=
|
| 428 |
+
(integrable_finsetSum s (fun i _ => hi i)).const_mul _
|
| 429 |
+
have hbound (x : ℝ) : ‖φ x*(F (s.filter (fun i => t i < x))-F (s.filter (fun i => u i < x)))‖ ≤
|
| 430 |
+
2*M*C*∑ i ∈ s, I i x := by
|
| 431 |
+
rw [Real.norm_eq_abs,abs_mul]
|
| 432 |
+
have hp := mul_le_mul (hφC x) (threshold_pointwise_bound s t u F hM0 hM x) (abs_nonneg _) hC
|
| 433 |
+
dsimp [I]
|
| 434 |
+
convert hp using 1
|
| 435 |
+
first | rfl | ring
|
| 436 |
+
rw [← integral_sub (threshold_integrable s t F hφ) (threshold_integrable s u F hφ)]
|
| 437 |
+
simp_rw [← mul_sub]
|
| 438 |
+
calc
|
| 439 |
+
_ ≤ ∫ x, 2*M*C*∑ i ∈ s, I i x := by
|
| 440 |
+
simpa only [Real.norm_eq_abs] using norm_integral_le_of_norm_le hiS (ae_of_all _ hbound)
|
| 441 |
+
_ = 2*M*C*∑ i ∈ s, |u i-t i| := by
|
| 442 |
+
rw [integral_const_mul,integral_finsetSum s (fun i _ => hi i)]
|
| 443 |
+
congr 1
|
| 444 |
+
apply Finset.sum_congr rfl
|
| 445 |
+
intro i _
|
| 446 |
+
dsimp [I]
|
| 447 |
+
change (∫ x, (uIoc (t i) (u i)).indicator (1 : ℝ → ℝ) x) = _
|
| 448 |
+
rw [integral_indicator_one measurableSet_uIoc,measureReal_def,Real.volume_uIoc,ENNReal.toReal_ofReal (abs_nonneg _)]
|
| 449 |
+
|
| 450 |
+
end Lipschitz
|
| 451 |
+
|
| 452 |
+
section FDeriv
|
| 453 |
+
variable [Fintype ι]
|
| 454 |
+
variable {X : Type u7} [NormedAddCommGroup X] [NormedSpace ℝ X]
|
| 455 |
+
|
| 456 |
+
omit [Fintype ι] in
|
| 457 |
+
lemma moving_threshold_integral_hasFDerivAt (s : Finset ι) (t : ι → X → ℝ)
|
| 458 |
+
(F : Finset ι → ℝ) {y : X} (t' : ι → X →L[ℝ] ℝ)
|
| 459 |
+
(ht : ∀ i ∈ s, HasFDerivAt (t i) (t' i) y) (hi : Set.InjOn (fun i => t i y) s)
|
| 460 |
+
{φ : ℝ → ℝ} (hφ : Integrable φ) (hc : Continuous φ) :
|
| 461 |
+
HasFDerivAt (fun z => ∫ x, φ x * F (s.filter (fun i => t i z < x)))
|
| 462 |
+
(∑ i ∈ s, (-(φ (t i y) *
|
| 463 |
+
(F (s.filter (fun j => t j y ≤ t i y))-F (s.filter (fun j => t j y < t i y))))) • t' i) y := by
|
| 464 |
+
let Δ := fun i => F (s.filter (fun j => t j y ≤ t i y))-F (s.filter (fun j => t j y < t i y))
|
| 465 |
+
have he : (fun z => ∫ x, φ x * F (s.filter (fun i => t i z < x))) =ᶠ[𝓝 y]
|
| 466 |
+
(fun z => (∫ x, φ x)*F ∅ + ∑ i ∈ s, (∫ x in Ioi (t i z), φ x)*Δ i) := by
|
| 467 |
+
filter_upwards [eventually_order_eq s t (fun i his => (ht i his).continuousAt) hi] with z hz
|
| 468 |
+
rw [threshold_integral s (fun i => t i z) hz.1 F hφ]
|
| 469 |
+
congr 1
|
| 470 |
+
apply Finset.sum_congr rfl
|
| 471 |
+
intro i his
|
| 472 |
+
rw [(hz.2 i his).1,(hz.2 i his).2]
|
| 473 |
+
have hd (i : ι) (his : i ∈ s) : HasFDerivAt (fun z => (∫ x in Ioi (t i z), φ x)*Δ i)
|
| 474 |
+
(-(φ (t i y)*Δ i) • t' i) y := by
|
| 475 |
+
convert ((tail_integral_hasDerivAt hφ hc (t i y)).comp_hasFDerivAt y (ht i his)).mul_const (Δ i) using 1 <;> try rfl
|
| 476 |
+
simp only [smul_smul]
|
| 477 |
+
congr 1; ring
|
| 478 |
+
have hs := (HasFDerivAt.sum (fun i his => hd i his)).const_add ((∫ x, φ x)*F ∅)
|
| 479 |
+
simp only [Finset.sum_apply] at hs
|
| 480 |
+
exact hs.congr_of_eventuallyEq he
|
| 481 |
+
|
| 482 |
+
lemma affine_threshold_lipschitz (s : Finset ι) (L : ι → X →L[ℝ] ℝ) (b : ι → ℝ)
|
| 483 |
+
(F : Finset ι → ℝ) {φ : ℝ → ℝ} (hφ : Integrable φ)
|
| 484 |
+
{M C : ℝ} (hM0 : 0 ≤ M) (hC : 0 ≤ C) (hM : ∀ a, |F a| ≤ M) (hφC : ∀ x, |φ x| ≤ C) :
|
| 485 |
+
LipschitzWith (Real.nnabs (2*M*C*∑ i ∈ s, ‖L i‖))
|
| 486 |
+
(fun y => ∫ x, φ x * F (s.filter (fun i => L i y+b i < x))) := by
|
| 487 |
+
apply LipschitzWith.of_dist_le_mul
|
| 488 |
+
intro y z
|
| 489 |
+
simp only [dist_eq_norm]
|
| 490 |
+
have hb := threshold_integral_diff_bound s (fun i => L i y+b i) (fun i => L i z+b i) F hφ hM0 hC hM hφC
|
| 491 |
+
simp only [Real.norm_eq_abs] at ⊢
|
| 492 |
+
refine hb.trans ?_
|
| 493 |
+
have hs : (∑ i ∈ s, |L i z+b i-(L i y+b i)|) ≤ (∑ i ∈ s, ‖L i‖)*‖y-z‖ := by
|
| 494 |
+
rw [Finset.sum_mul]
|
| 495 |
+
apply Finset.sum_le_sum
|
| 496 |
+
intro i _
|
| 497 |
+
have ht := (L i).le_opNorm (z-y)
|
| 498 |
+
simpa only [map_sub, Real.norm_eq_abs, add_sub_add_right_eq_sub, norm_sub_rev z y] using ht
|
| 499 |
+
exact mul_le_mul_of_nonneg_left hs (by positivity) |>.trans_eq (by simp only [Real.coe_nnabs, abs_of_nonneg (show 0 ≤ 2*M*C*∑ i ∈ s, ‖L i‖ by positivity)]; ring)
|
| 500 |
+
|
| 501 |
+
end FDeriv
|
| 502 |
+
|
| 503 |
+
end UniformSparsestCut.InterfaceStep
|
| 504 |
+
|
| 505 |
+
namespace UniformSparsestCut.InterfaceStep
|
| 506 |
+
open MeasureTheory Set
|
| 507 |
+
open scoped BigOperators Topology
|
| 508 |
+
variable {ι : Type u8} {X : Type u9} {Z : Type u10} [DecidableEq ι] [Fintype ι]
|
| 509 |
+
[NormedAddCommGroup X] [NormedSpace ℝ X] [MeasurableSpace Z]
|
| 510 |
+
|
| 511 |
+
lemma averaged_threshold_derivative (s : Finset ι) (L : ι → X →L[ℝ] ℝ)
|
| 512 |
+
(b : ι → Z → ℝ) (hb : ∀ i, Measurable (b i)) (F : Finset ι → ℝ)
|
| 513 |
+
{φ : ℝ → ℝ} (hφ : Integrable φ) (hc : Continuous φ)
|
| 514 |
+
{M C : ℝ} (hM0 : 0 ≤ M) (hC : 0 ≤ C) (hM : ∀ a, |F a| ≤ M) (hφC : ∀ x, |φ x| ≤ C)
|
| 515 |
+
(μ : Measure Z) [IsFiniteMeasure μ] (y : X)
|
| 516 |
+
(hi : ∀ᵐ z ∂μ, Set.InjOn (fun i => L i y+b i z) s) :
|
| 517 |
+
HasFDerivAt (fun y => ∫ z, (∫ x, φ x * F (s.filter (fun i => L i y+b i z < x))) ∂μ)
|
| 518 |
+
(∑ i ∈ s, (∫ z, -(φ (L i y+b i z) *
|
| 519 |
+
(F (s.filter (fun j => L j y+b j z ≤ L i y+b i z))-
|
| 520 |
+
F (s.filter (fun j => L j y+b j z < L i y+b i z)))) ∂μ) • L i) y := by
|
| 521 |
+
let H : X → Z → ℝ := fun y z => ∫ x, φ x * F (s.filter (fun i => L i y+b i z < x))
|
| 522 |
+
let c : ι → Z → ℝ := fun i z => -(φ (L i y+b i z) *
|
| 523 |
+
(F (s.filter (fun j => L j y+b j z ≤ L i y+b i z))-
|
| 524 |
+
F (s.filter (fun j => L j y+b j z < L i y+b i z))))
|
| 525 |
+
have hmH (y : X) : StronglyMeasurable (H y) := by
|
| 526 |
+
apply StronglyMeasurable.integral_prod_right
|
| 527 |
+
apply Measurable.stronglyMeasurable
|
| 528 |
+
exact (hc.measurable.comp measurable_snd).mul (measurable_filter_apply s
|
| 529 |
+
(fun i (p : Z × ℝ) => L i y+b i p.1 < p.2)
|
| 530 |
+
(fun i => measurableSet_lt ((measurable_const.add ((hb i).comp measurable_fst))) measurable_snd) F)
|
| 531 |
+
have hmC (i : ι) : Measurable (c i) := by
|
| 532 |
+
apply Measurable.neg
|
| 533 |
+
apply Measurable.mul (hc.measurable.comp (measurable_const.add (hb i)))
|
| 534 |
+
exact (measurable_filter_apply s (fun j z => L j y+b j z ≤ L i y+b i z)
|
| 535 |
+
(fun j => measurableSet_le (measurable_const.add (hb j)) (measurable_const.add (hb i))) F).sub
|
| 536 |
+
(measurable_filter_apply s (fun j z => L j y+b j z < L i y+b i z)
|
| 537 |
+
(fun j => measurableSet_lt (measurable_const.add (hb j)) (measurable_const.add (hb i))) F)
|
| 538 |
+
have hcB (i : ι) (z : Z) : ‖c i z‖ ≤ C*(2*M) := by
|
| 539 |
+
dsimp [c]
|
| 540 |
+
simp only [abs_neg,abs_mul]
|
| 541 |
+
have hd := abs_sub_le (F (s.filter (fun j => L j y+b j z ≤ L i y+b i z))) 0
|
| 542 |
+
(F (s.filter (fun j => L j y+b j z < L i y+b i z)))
|
| 543 |
+
simp only [sub_zero,zero_sub,abs_neg] at hd
|
| 544 |
+
apply mul_le_mul (hφC _) _ (abs_nonneg _) hC
|
| 545 |
+
linarith [hM (s.filter (fun j => L j y+b j z ≤ L i y+b i z)),
|
| 546 |
+
hM (s.filter (fun j => L j y+b j z < L i y+b i z))]
|
| 547 |
+
have hiC (i : ι) : Integrable (c i) μ :=
|
| 548 |
+
(integrable_const (C*(2*M))).mono' (hmC i).aestronglyMeasurable (ae_of_all _ (hcB i))
|
| 549 |
+
have hiH : Integrable (H y) μ := by
|
| 550 |
+
apply (integrable_const (∫ x, |φ x| * M)).mono' (hmH y).aestronglyMeasurable
|
| 551 |
+
filter_upwards with z
|
| 552 |
+
apply norm_integral_le_of_norm_le (hφ.abs.mul_const M)
|
| 553 |
+
filter_upwards with x
|
| 554 |
+
rw [Real.norm_eq_abs,abs_mul]
|
| 555 |
+
exact mul_le_mul_of_nonneg_left (hM _) (abs_nonneg _)
|
| 556 |
+
let K : NNReal := Real.nnabs (2*M*C*∑ i ∈ s, ‖L i‖)
|
| 557 |
+
have hLip (z : Z) : LipschitzWith K (fun y => H y z) :=
|
| 558 |
+
affine_threshold_lipschitz s L (fun i => b i z) F hφ hM0 hC hM hφC
|
| 559 |
+
have hD : ∀ᵐ z ∂μ, HasFDerivAt (fun y => H y z) (∑ i ∈ s, c i z • L i) y := by
|
| 560 |
+
filter_upwards [hi] with z hz
|
| 561 |
+
exact moving_threshold_integral_hasFDerivAt s (fun i y => L i y+b i z) F L
|
| 562 |
+
(fun i _ => (L i).hasFDerivAt.add_const _) hz hφ hc
|
| 563 |
+
have hres := hasFDerivAt_integral_of_dominated_loc_of_lip (μ := μ) (F := H)
|
| 564 |
+
(s := Set.univ) (bound := fun _ => (K : ℝ)) (F' := fun z => ∑ i ∈ s, c i z • L i)
|
| 565 |
+
(Filter.univ_mem) (Filter.Eventually.of_forall (fun x => (hmH x).aestronglyMeasurable)) hiH
|
| 566 |
+
(by
|
| 567 |
+
have hm := (Finset.stronglyMeasurable_sum s (fun i _ => (hmC i).stronglyMeasurable.smul_const (L i))).aestronglyMeasurable (μ := μ)
|
| 568 |
+
have he : (∑ i ∈ s, (fun z => c i z • L i)) = (fun z => ∑ i ∈ s, c i z • L i) := by
|
| 569 |
+
funext z; exact Finset.sum_apply z s _
|
| 570 |
+
rw [he] at hm
|
| 571 |
+
exact hm)
|
| 572 |
+
(ae_of_all _ (fun z => by simpa using (hLip z).lipschitzOnWith (s := Set.univ)))
|
| 573 |
+
(integrable_const _) hD
|
| 574 |
+
rw [integral_finsetSum s (fun i _ => (hiC i).smul_const (L i))] at hres
|
| 575 |
+
simp only [integral_smul_const] at hres
|
| 576 |
+
exact hres.2
|
| 577 |
+
|
| 578 |
+
end UniformSparsestCut.InterfaceStep
|
| 579 |
+
|
| 580 |
+
end
|
| 581 |
+
|
| 582 |
+
end OAI
|
lean/OAI/Combinatorics/SparsestCut/KernelApprox.lean
ADDED
|
@@ -0,0 +1,184 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import OAI.Combinatorics.SparsestCut.PositiveKernels
|
| 2 |
+
|
| 3 |
+
namespace OAI
|
| 4 |
+
|
| 5 |
+
open scoped BigOperators Topology NNReal RealInnerProductSpace InnerProductSpace Matrix ContDiff ENNReal
|
| 6 |
+
open MeasureTheory ProbabilityTheory Set Filter Matrix
|
| 7 |
+
|
| 8 |
+
noncomputable section
|
| 9 |
+
|
| 10 |
+
namespace UniformSparsestCut.KernelApprox
|
| 11 |
+
|
| 12 |
+
def profile (t : ℝ) : ℝ := 1 - Real.exp (-1/(2*t^2))
|
| 13 |
+
|
| 14 |
+
lemma profile_nonneg (t : ℝ) : 0 ≤ profile t := by
|
| 15 |
+
unfold profile
|
| 16 |
+
have h : -1/(2*t^2) ≤ 0 := div_nonpos_of_nonpos_of_nonneg (by norm_num) (by positivity)
|
| 17 |
+
linarith [Real.exp_le_one_iff.mpr h]
|
| 18 |
+
|
| 19 |
+
lemma profile_le_one (t : ℝ) : profile t ≤ 1 := by
|
| 20 |
+
unfold profile
|
| 21 |
+
linarith [Real.exp_pos (-1/(2*t^2))]
|
| 22 |
+
|
| 23 |
+
lemma profile_le_inv_sq (t : ℝ) : profile t ≤ 1/(2*t^2) := by
|
| 24 |
+
have h := Real.add_one_le_exp (-1/(2*t^2))
|
| 25 |
+
unfold profile
|
| 26 |
+
rw [neg_div] at h ⊢
|
| 27 |
+
linarith
|
| 28 |
+
|
| 29 |
+
lemma profile_pos {t : ℝ} (ht : t ≠ 0) : 0 < profile t := by
|
| 30 |
+
unfold profile
|
| 31 |
+
have h : -1/(2*t^2) < 0 := div_neg_of_neg_of_pos (by norm_num) (by positivity)
|
| 32 |
+
linarith [Real.exp_lt_one_iff.mpr h]
|
| 33 |
+
|
| 34 |
+
lemma profile_measurable : Measurable profile := by unfold profile; fun_prop
|
| 35 |
+
|
| 36 |
+
lemma profile_integrable_lower : IntegrableOn profile (Ioc 0 1) := by
|
| 37 |
+
apply (integrableOn_const (C := (1 : ℝ)) (s := Ioc (0 : ℝ) 1) (by simp)).mono'
|
| 38 |
+
profile_measurable.aestronglyMeasurable
|
| 39 |
+
filter_upwards with t
|
| 40 |
+
simpa only [Real.norm_eq_abs, abs_of_nonneg (profile_nonneg t)] using profile_le_one t
|
| 41 |
+
|
| 42 |
+
lemma profile_integrable_upper : IntegrableOn profile (Ioi 1) := by
|
| 43 |
+
have hi := (integrableOn_Ioi_rpow_of_lt (by norm_num : (-2 : ℝ) < -1)
|
| 44 |
+
(by norm_num : (0 : ℝ) < 1)).const_mul (1/2 : ℝ)
|
| 45 |
+
apply hi.mono' profile_measurable.aestronglyMeasurable
|
| 46 |
+
filter_upwards [ae_restrict_mem measurableSet_Ioi] with t ht
|
| 47 |
+
change 1 < t at ht
|
| 48 |
+
have he : (1/2 : ℝ)*t^(-2 : ℝ) = 1/(2*t^2) := by
|
| 49 |
+
rw [Real.rpow_neg (by linarith : 0 ≤ t), Real.rpow_two]
|
| 50 |
+
ring
|
| 51 |
+
simpa only [Real.norm_eq_abs, abs_of_nonneg (profile_nonneg t), he] using profile_le_inv_sq t
|
| 52 |
+
|
| 53 |
+
lemma profile_integrable : IntegrableOn profile (Ioi 0) := by
|
| 54 |
+
have h := profile_integrable_lower.union profile_integrable_upper
|
| 55 |
+
simpa only [Ioc_union_Ioi_eq_Ioi (by norm_num : (0 : ℝ) ≤ 1)] using h
|
| 56 |
+
|
| 57 |
+
noncomputable def cstar : ℝ := 2 * ∫ t in Ioi (0 : ℝ), profile t
|
| 58 |
+
|
| 59 |
+
lemma cstar_pos : 0 < cstar := by
|
| 60 |
+
have hp : 0 < ∫ t in Ioi (0 : ℝ), profile t := by
|
| 61 |
+
apply (integral_pos_iff_support_of_nonneg_ae _ profile_integrable).mpr
|
| 62 |
+
· have hs : Ioi (0 : ℝ) ⊆ Function.support profile := by
|
| 63 |
+
intro t ht
|
| 64 |
+
exact ne_of_gt (profile_pos (ne_of_gt ht))
|
| 65 |
+
have hc : (volume.restrict (Ioi (0 : ℝ))) (Ioi (0 : ℝ)) ≠ 0 := by simp
|
| 66 |
+
exact bot_lt_iff_ne_bot.mpr (ne_bot_of_le_ne_bot hc (measure_mono hs))
|
| 67 |
+
· filter_upwards with t using profile_nonneg t
|
| 68 |
+
exact mul_pos (by norm_num) hp
|
| 69 |
+
|
| 70 |
+
def scaled (r t : ℝ) : ℝ := 1-Real.exp (-r^2/(2*t^2))
|
| 71 |
+
|
| 72 |
+
lemma scaled_eq_profile (r t : ℝ) : scaled r t = profile (t/r) := by
|
| 73 |
+
by_cases hr : r = 0
|
| 74 |
+
· simp [hr, scaled, profile]
|
| 75 |
+
by_cases ht : t = 0
|
| 76 |
+
· simp [ht, scaled, profile]
|
| 77 |
+
unfold scaled profile
|
| 78 |
+
congr 2
|
| 79 |
+
field_simp
|
| 80 |
+
|
| 81 |
+
lemma scaled_nonneg (r t : ℝ) : 0 ≤ scaled r t := by
|
| 82 |
+
rw [scaled_eq_profile]; exact profile_nonneg _
|
| 83 |
+
|
| 84 |
+
lemma scaled_le_one (r t : ℝ) : scaled r t ≤ 1 := by
|
| 85 |
+
rw [scaled_eq_profile]; exact profile_le_one _
|
| 86 |
+
|
| 87 |
+
lemma scaled_le_tail (r t : ℝ) : scaled r t ≤ r^2/(2*t^2) := by
|
| 88 |
+
have h := Real.add_one_le_exp (-r^2/(2*t^2))
|
| 89 |
+
unfold scaled
|
| 90 |
+
rw [neg_div] at h ⊢
|
| 91 |
+
linarith
|
| 92 |
+
|
| 93 |
+
lemma scaled_measurable (r : ℝ) : Measurable (scaled r) := by unfold scaled; fun_prop
|
| 94 |
+
|
| 95 |
+
lemma scaled_integrable_lower (r : ℝ) {a : ℝ} (_ha : 0 ≤ a) :
|
| 96 |
+
IntegrableOn (scaled r) (Ioc 0 a) := by
|
| 97 |
+
apply (integrableOn_const (C := (1 : ℝ)) (s := Ioc (0 : ℝ) a) (by simp)).mono'
|
| 98 |
+
(scaled_measurable r).aestronglyMeasurable
|
| 99 |
+
filter_upwards with t
|
| 100 |
+
simpa only [Real.norm_eq_abs, abs_of_nonneg (scaled_nonneg r t)] using scaled_le_one r t
|
| 101 |
+
|
| 102 |
+
lemma scaled_integrable_upper (r : ℝ) {a : ℝ} (ha : 0 < a) :
|
| 103 |
+
IntegrableOn (scaled r) (Ioi a) := by
|
| 104 |
+
have hi := (integrableOn_Ioi_rpow_of_lt (by norm_num : (-2 : ℝ) < -1) ha).const_mul (r^2/2)
|
| 105 |
+
apply hi.mono' (scaled_measurable r).aestronglyMeasurable
|
| 106 |
+
filter_upwards [ae_restrict_mem measurableSet_Ioi] with t ht
|
| 107 |
+
change a < t at ht
|
| 108 |
+
have he : (r^2/2)*t^(-2 : ℝ) = r^2/(2*t^2) := by
|
| 109 |
+
rw [Real.rpow_neg (by linarith : 0 ≤ t), Real.rpow_two]
|
| 110 |
+
ring
|
| 111 |
+
simpa only [Real.norm_eq_abs, abs_of_nonneg (scaled_nonneg r t), he] using scaled_le_tail r t
|
| 112 |
+
|
| 113 |
+
lemma scaled_integrable (r : ℝ) : IntegrableOn (scaled r) (Ioi 0) := by
|
| 114 |
+
have h := (scaled_integrable_lower r (by norm_num : (0 : ℝ) ≤ 1)).union
|
| 115 |
+
(scaled_integrable_upper r (by norm_num : (0 : ℝ) < 1))
|
| 116 |
+
simpa only [Ioc_union_Ioi_eq_Ioi (by norm_num : (0 : ℝ) ≤ 1)] using h
|
| 117 |
+
|
| 118 |
+
lemma full_integral {r : ℝ} (hr : 0 ≤ r) :
|
| 119 |
+
2 * (∫ t in Ioi (0 : ℝ), scaled r t) = cstar*r := by
|
| 120 |
+
rcases eq_or_lt_of_le hr with hz | hr
|
| 121 |
+
· simp [← hz, scaled]
|
| 122 |
+
simp_rw [scaled_eq_profile, div_eq_inv_mul]
|
| 123 |
+
rw [integral_comp_mul_left_Ioi profile 0 (inv_pos.mpr hr)]
|
| 124 |
+
simp only [mul_zero, inv_inv, smul_eq_mul, cstar]
|
| 125 |
+
ring
|
| 126 |
+
|
| 127 |
+
lemma lower_tail_bound (r : ℝ) {a : ℝ} (ha : 0 ≤ a) :
|
| 128 |
+
(∫ t in Ioc (0 : ℝ) a, scaled r t) ≤ a := by
|
| 129 |
+
have h := integral_mono (scaled_integrable_lower r ha)
|
| 130 |
+
(integrableOn_const (C := (1 : ℝ)) (s := Ioc (0 : ℝ) a) (by simp))
|
| 131 |
+
(fun t => scaled_le_one r t)
|
| 132 |
+
simpa [integral_const, Real.volume_real_Ioc, ha] using h
|
| 133 |
+
|
| 134 |
+
lemma upper_tail_bound (r : ℝ) {b : ℝ} (hb : 0 < b) :
|
| 135 |
+
(∫ t in Ioi b, scaled r t) ≤ r^2/(2*b) := by
|
| 136 |
+
have hi := (integrableOn_Ioi_rpow_of_lt (by norm_num : (-2 : ℝ) < -1) hb).const_mul (r^2/2)
|
| 137 |
+
calc
|
| 138 |
+
_ ≤ ∫ t in Ioi b, (r^2/2)*t^(-2 : ℝ) := by
|
| 139 |
+
apply integral_mono_ae (scaled_integrable_upper r hb) hi
|
| 140 |
+
filter_upwards [ae_restrict_mem measurableSet_Ioi] with t ht
|
| 141 |
+
change b < t at ht
|
| 142 |
+
rw [Real.rpow_neg (by linarith : 0 ≤ t), Real.rpow_two]
|
| 143 |
+
exact (scaled_le_tail r t).trans_eq (by ring)
|
| 144 |
+
_ = _ := by
|
| 145 |
+
rw [integral_const_mul, integral_Ioi_rpow_of_lt (by norm_num : (-2 : ℝ) < -1) hb]
|
| 146 |
+
norm_num
|
| 147 |
+
rw [Real.rpow_neg_one]
|
| 148 |
+
ring
|
| 149 |
+
|
| 150 |
+
lemma truncated_error {r a b : ℝ} (hr : 0 ≤ r) (ha : 0 < a) (hab : a ≤ b) :
|
| 151 |
+
|2 * (∫ t in Ioc a b, scaled r t) - cstar*r| ≤ 2*a + r^2/b := by
|
| 152 |
+
have hb : 0 < b := ha.trans_le hab
|
| 153 |
+
have hi1 := scaled_integrable_lower r ha.le
|
| 154 |
+
have hi2 : IntegrableOn (scaled r) (Ioc a b) :=
|
| 155 |
+
(scaled_integrable r).mono_set (fun t ht => ha.trans ht.1)
|
| 156 |
+
have hi3 := scaled_integrable_upper r hb
|
| 157 |
+
have he : (∫ t in Ioi (0 : ℝ), scaled r t) =
|
| 158 |
+
(∫ t in Ioc (0 : ℝ) a, scaled r t) + (∫ t in Ioc a b, scaled r t) +
|
| 159 |
+
∫ t in Ioi b, scaled r t := by
|
| 160 |
+
rw [← Ioc_union_Ioi_eq_Ioi hb.le, setIntegral_union]
|
| 161 |
+
· rw [← Ioc_union_Ioc_eq_Ioc ha.le hab, setIntegral_union]
|
| 162 |
+
· exact Ioc_disjoint_Ioc_of_le le_rfl
|
| 163 |
+
· exact measurableSet_Ioc
|
| 164 |
+
· exact hi1
|
| 165 |
+
· exact hi2
|
| 166 |
+
· exact Ioc_disjoint_Ioi_same
|
| 167 |
+
· exact measurableSet_Ioi
|
| 168 |
+
· exact scaled_integrable_lower r hb.le
|
| 169 |
+
· exact hi3
|
| 170 |
+
have hx := full_integral hr
|
| 171 |
+
rw [he] at hx
|
| 172 |
+
have hn1 : 0 ≤ ∫ t in Ioc (0 : ℝ) a, scaled r t := integral_nonneg (fun _ => scaled_nonneg _ _)
|
| 173 |
+
have hn3 : 0 ≤ ∫ t in Ioi b, scaled r t := integral_nonneg (fun _ => scaled_nonneg _ _)
|
| 174 |
+
have hu1 := lower_tail_bound r ha.le
|
| 175 |
+
have hu3 := upper_tail_bound r hb
|
| 176 |
+
have he' : r^2/b = 2*(r^2/(2*b)) := by ring
|
| 177 |
+
rw [abs_of_nonpos (by linarith), he']
|
| 178 |
+
linarith
|
| 179 |
+
|
| 180 |
+
end UniformSparsestCut.KernelApprox
|
| 181 |
+
|
| 182 |
+
end
|
| 183 |
+
|
| 184 |
+
end OAI
|
lean/OAI/Combinatorics/SparsestCut/LabelCount.lean
ADDED
|
@@ -0,0 +1,129 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import OAI.Combinatorics.SparsestCut.WeightedMetric
|
| 2 |
+
|
| 3 |
+
namespace OAI
|
| 4 |
+
|
| 5 |
+
open scoped BigOperators Topology NNReal RealInnerProductSpace InnerProductSpace Matrix ContDiff ENNReal
|
| 6 |
+
open MeasureTheory ProbabilityTheory Set Filter Matrix
|
| 7 |
+
|
| 8 |
+
noncomputable section
|
| 9 |
+
|
| 10 |
+
namespace UniformSparsestCut.LabelCount
|
| 11 |
+
open scoped BigOperators RealInnerProductSpace
|
| 12 |
+
open UniformSparsestCut
|
| 13 |
+
variable {m N : ℕ}
|
| 14 |
+
local notation "E" => EuclideanSpace ℝ (Fin m)
|
| 15 |
+
|
| 16 |
+
def signature (B : ℤ) (l : Fin N → ℤ) : Finset (Fin N × ↥(Finset.Icc (-B) B)) :=
|
| 17 |
+
Finset.univ.filter (fun p => p.2.val ≤ l p.1)
|
| 18 |
+
|
| 19 |
+
lemma signature_injective (B : ℤ) (A : Finset (Fin N → ℤ))
|
| 20 |
+
(hA : ∀ l ∈ A, ∀ i, l i ∈ Finset.Icc (-B) B) :
|
| 21 |
+
Set.InjOn (signature B) (↑A : Set (Fin N → ℤ)) := by
|
| 22 |
+
intro l hl k hk he
|
| 23 |
+
funext i
|
| 24 |
+
apply le_antisymm
|
| 25 |
+
· have hm : (i,⟨l i,hA l hl i⟩) ∈ signature B l := by simp [signature]
|
| 26 |
+
rw [he] at hm
|
| 27 |
+
simpa [signature] using hm
|
| 28 |
+
· have hm : (i,⟨k i,hA k hk i⟩) ∈ signature B k := by simp [signature]
|
| 29 |
+
rw [← he] at hm
|
| 30 |
+
simpa [signature] using hm
|
| 31 |
+
|
| 32 |
+
lemma regular_floor_iff (u : Fin N → E) {τ : ℝ} (hτ : 0 < τ)
|
| 33 |
+
{θ : E} (hθ : RoundedCharts.regular u τ θ) (i : Fin N) (k : ℤ) :
|
| 34 |
+
k ≤ RoundedCharts.integerLabel u τ θ i ↔ (k:ℝ)*τ < inner ℝ (u i) θ := by
|
| 35 |
+
rw [RoundedCharts.integerLabel, Int.le_floor]
|
| 36 |
+
rw [le_div_iff₀ hτ]
|
| 37 |
+
exact ⟨fun h => lt_of_le_of_ne h (Ne.symm (hθ i k)), le_of_lt⟩
|
| 38 |
+
|
| 39 |
+
def affineForm (u : Fin N → E) (τ : ℝ) (B : ℤ)
|
| 40 |
+
(p : Fin N × ↥(Finset.Icc (-B) B)) : E × ℝ →ₗ[ℝ] ℝ :=
|
| 41 |
+
(innerSL ℝ (u p.1)).toLinearMap.comp (LinearMap.fst ℝ E ℝ) -
|
| 42 |
+
((p.2.val:ℝ)*τ) • LinearMap.snd ℝ E ℝ
|
| 43 |
+
|
| 44 |
+
lemma label_count (u : Fin N → E) {τ : ℝ} (hτ : 0 < τ) (B : ℤ)
|
| 45 |
+
(A : Finset (Fin N → ℤ))
|
| 46 |
+
(hb : ∀ l ∈ A, ∀ i, l i ∈ Finset.Icc (-B) B)
|
| 47 |
+
(hA : ∀ l ∈ A, ∃ θ : E, RoundedCharts.regular u τ θ ∧ RoundedCharts.integerLabel u τ θ = l) :
|
| 48 |
+
A.card ≤ ∑ j ∈ Finset.Iic (m+1), (N*(Finset.Icc (-B) B).card).choose j := by
|
| 49 |
+
let P := A.image (signature B)
|
| 50 |
+
have hP : ∀ p ∈ P, ∃ θ : E × ℝ, ∀ i,
|
| 51 |
+
affineForm u τ B i θ ≠ 0 ∧ (0 < affineForm u τ B i θ ↔ i ∈ p) := by
|
| 52 |
+
intro p hp
|
| 53 |
+
obtain ⟨l,hl,rfl⟩ := Finset.mem_image.mp hp
|
| 54 |
+
obtain ⟨θ,hr,hθ⟩ := hA l hl
|
| 55 |
+
refine ⟨(θ,1),?_⟩
|
| 56 |
+
intro i
|
| 57 |
+
have he : affineForm u τ B i (θ,1) = inner ℝ (u i.1) θ-(i.2.val:ℝ)*τ := by
|
| 58 |
+
simp [affineForm]
|
| 59 |
+
rw [he]
|
| 60 |
+
refine ⟨sub_ne_zero.mpr (hr _ _),?_⟩
|
| 61 |
+
rw [sub_pos, ← regular_floor_iff u hτ hr,hθ]
|
| 62 |
+
simp [signature]
|
| 63 |
+
have hc := HyperplaneCount.sign_patterns_bound (affineForm u τ B) P hP
|
| 64 |
+
have hdim : Module.finrank ℝ (E × ℝ) = m+1 := by simp [Module.finrank_prod]
|
| 65 |
+
have hcard : Fintype.card (Fin N × ↥(Finset.Icc (-B) B)) = N*(Finset.Icc (-B) B).card := by simp
|
| 66 |
+
rw [hdim,hcard] at hc
|
| 67 |
+
rwa [Finset.card_image_of_injOn (signature_injective B A hb)] at hc
|
| 68 |
+
|
| 69 |
+
end UniformSparsestCut.LabelCount
|
| 70 |
+
|
| 71 |
+
namespace UniformSparsestCut.LabelCount
|
| 72 |
+
open scoped BigOperators
|
| 73 |
+
noncomputable section
|
| 74 |
+
lemma power_sum_le (H d : ℕ) : (∑ j∈Finset.range (d+1), H^j)≤(H+1)^d := by
|
| 75 |
+
induction d with
|
| 76 |
+
| zero => simp
|
| 77 |
+
| succ d ih =>
|
| 78 |
+
rw [Finset.sum_range_succ]
|
| 79 |
+
calc
|
| 80 |
+
_ ≤ (H+1)^d+H^(d+1) := Nat.add_le_add_right ih _
|
| 81 |
+
_ ≤ (H+1)^d+(H+1)^d*H := by
|
| 82 |
+
rw [pow_succ]
|
| 83 |
+
gcongr
|
| 84 |
+
omega
|
| 85 |
+
_ = (H+1)^(d+1) := by ring
|
| 86 |
+
lemma binomial_sum_le (H d : ℕ) : (∑ j∈Finset.Iic d, H.choose j)≤(H+1)^d := by
|
| 87 |
+
have he : Finset.Iic d=Finset.range (d+1) := by ext j; simp
|
| 88 |
+
rw [he]
|
| 89 |
+
exact (Finset.sum_le_sum (fun j _ => Nat.choose_le_pow H j)).trans (power_sum_le H d)
|
| 90 |
+
variable {m N S : ℕ}
|
| 91 |
+
local notation "E" => EuclideanSpace ℝ (Fin m)
|
| 92 |
+
lemma vertex_count (u : Fin S → Fin N → E) {τ : ℝ} (hτ : 0<τ)
|
| 93 |
+
[Fintype (RoundedCharts.Vertex u τ)] (B : ℤ)
|
| 94 |
+
(hb : ∀ v : RoundedCharts.Vertex u τ, ∀ i, v.val.2 i∈Finset.Icc (-B) B) :
|
| 95 |
+
Fintype.card (RoundedCharts.Vertex u τ)≤S*(N*(Finset.Icc (-B) B).card+1)^(m+1) := by
|
| 96 |
+
classical
|
| 97 |
+
let T (s : Fin S) := Finset.univ.filter (fun v : RoundedCharts.Vertex u τ => v.val.1=s)
|
| 98 |
+
let A (s : Fin S) := (T s).image (fun v => v.val.2)
|
| 99 |
+
have hcard (s : Fin S) : (T s).card=(A s).card := by
|
| 100 |
+
apply (Finset.card_image_of_injOn _).symm
|
| 101 |
+
intro v hv w hw h
|
| 102 |
+
apply Subtype.ext
|
| 103 |
+
apply Prod.ext
|
| 104 |
+
· exact (Finset.mem_filter.mp hv).2.trans (Finset.mem_filter.mp hw).2.symm
|
| 105 |
+
· exact h
|
| 106 |
+
have hs (s : Fin S) : (T s).card≤(N*(Finset.Icc (-B) B).card+1)^(m+1) := by
|
| 107 |
+
rw [hcard]
|
| 108 |
+
apply (label_count (u s) hτ B (A s) ?_ ?_).trans (binomial_sum_le _ _)
|
| 109 |
+
· intro l hl i
|
| 110 |
+
obtain ⟨v,hv,rfl⟩ := Finset.mem_image.mp hl
|
| 111 |
+
exact hb v i
|
| 112 |
+
· intro l hl
|
| 113 |
+
obtain ⟨v,hv,rfl⟩ := Finset.mem_image.mp hl
|
| 114 |
+
obtain ⟨θ,hθ,hr,hl⟩ := v.property
|
| 115 |
+
have he : v.val.1=s := (Finset.mem_filter.mp hv).2
|
| 116 |
+
exact ⟨θ,by simpa only [← he] using hr,by simpa only [�� he] using hl⟩
|
| 117 |
+
calc
|
| 118 |
+
_ = ∑ s, (T s).card := by
|
| 119 |
+
simpa only [Finset.card_univ] using (Finset.card_eq_sum_card_fiberwise
|
| 120 |
+
(f := fun v : RoundedCharts.Vertex u τ => v.val.1)
|
| 121 |
+
(s := Finset.univ) (t := Finset.univ) (fun _ _ => Finset.mem_univ _))
|
| 122 |
+
_ ≤ ∑ _s : Fin S, (N*(Finset.Icc (-B) B).card+1)^(m+1) := Finset.sum_le_sum (fun s _ => hs s)
|
| 123 |
+
_ = _ := by simp
|
| 124 |
+
end
|
| 125 |
+
end UniformSparsestCut.LabelCount
|
| 126 |
+
|
| 127 |
+
end
|
| 128 |
+
|
| 129 |
+
end OAI
|
lean/OAI/Combinatorics/SparsestCut/LatticeDensity.lean
ADDED
|
@@ -0,0 +1,125 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import OAI.Combinatorics.SparsestCut.ProductSlice
|
| 2 |
+
|
| 3 |
+
namespace OAI
|
| 4 |
+
|
| 5 |
+
open scoped BigOperators Topology NNReal RealInnerProductSpace InnerProductSpace Matrix ContDiff ENNReal
|
| 6 |
+
open MeasureTheory ProbabilityTheory Set Filter Matrix
|
| 7 |
+
|
| 8 |
+
noncomputable section
|
| 9 |
+
|
| 10 |
+
namespace UniformSparsestCut.LatticeDensity
|
| 11 |
+
|
| 12 |
+
lemma cell_bound {h h' : ℝ → ℝ} {a b : ℝ} (hab : a ≤ b)
|
| 13 |
+
(hd : ∀ t, HasDerivAt h (h' t) t) (hi : IntervalIntegrable h' volume a b) :
|
| 14 |
+
(b-a)*h a ≤ (∫ t in a..b, h t)+(b-a)*(∫ t in a..b, |h' t|) := by
|
| 15 |
+
have hc : Continuous h := continuous_iff_continuousAt.mpr (fun t => (hd t).continuousAt)
|
| 16 |
+
have hh : ∀ t ∈ Icc a b, h a ≤ h t+∫ x in a..b, |h' x| := by
|
| 17 |
+
intro t ht
|
| 18 |
+
have hid : IntervalIntegrable h' volume a t := hi.mono_set (by
|
| 19 |
+
rw [uIcc_of_le ht.1, uIcc_of_le hab]
|
| 20 |
+
exact Icc_subset_Icc le_rfl ht.2)
|
| 21 |
+
have he := intervalIntegral.integral_eq_sub_of_hasDerivAt (fun x _ => hd x) hid
|
| 22 |
+
have hm : (∫ x in a..t, |h' x|) ≤ ∫ x in a..b, |h' x| := by
|
| 23 |
+
apply intervalIntegral.integral_mono_interval le_rfl ht.1 ht.2
|
| 24 |
+
· filter_upwards with x using abs_nonneg (h' x)
|
| 25 |
+
· exact hi.abs
|
| 26 |
+
have hn := intervalIntegral.abs_integral_le_integral_abs (f := h') (μ := volume) ht.1
|
| 27 |
+
rw [he] at hn
|
| 28 |
+
have habs : h a-h t ≤ |h t-h a| := by rw [abs_sub_comm]; exact le_abs_self _
|
| 29 |
+
linarith
|
| 30 |
+
have h := intervalIntegral.integral_mono_on (μ := volume) hab intervalIntegrable_const
|
| 31 |
+
((hc.intervalIntegrable a b).add intervalIntegrable_const) hh
|
| 32 |
+
rw [intervalIntegral.integral_const, intervalIntegral.integral_add (hc.intervalIntegrable a b) intervalIntegrable_const,
|
| 33 |
+
intervalIntegral.integral_const] at h
|
| 34 |
+
simpa only [smul_eq_mul] using h
|
| 35 |
+
|
| 36 |
+
lemma lattice_intervals_disjoint {τ : ℝ} (hτ : 0 < τ) :
|
| 37 |
+
∀ k l : ℤ, k ≠ l → Disjoint (Ioc ((k:ℝ)*τ) (((k:ℝ)+1)*τ))
|
| 38 |
+
(Ioc ((l:ℝ)*τ) (((l:ℝ)+1)*τ)) := by
|
| 39 |
+
intro k l hkl
|
| 40 |
+
rcases lt_or_gt_of_ne hkl with h | h
|
| 41 |
+
· apply Set.disjoint_left.mpr
|
| 42 |
+
intro x hx hy
|
| 43 |
+
have hkl' : (k:ℝ)+1 ≤ l := by exact_mod_cast (Int.add_one_le_iff.mpr h)
|
| 44 |
+
have hz := mul_le_mul_of_nonneg_right hkl' hτ.le
|
| 45 |
+
linarith [hx.2, hy.1]
|
| 46 |
+
· apply Set.disjoint_left.mpr
|
| 47 |
+
intro x hx hy
|
| 48 |
+
have hkl' : (l:ℝ)+1 ≤ k := by exact_mod_cast (Int.add_one_le_iff.mpr h)
|
| 49 |
+
have hz := mul_le_mul_of_nonneg_right hkl' hτ.le
|
| 50 |
+
linarith [hy.2, hx.1]
|
| 51 |
+
|
| 52 |
+
lemma lattice_bound {h h' : ℝ → ℝ} {τ : ℝ} (hτ : 0 < τ)
|
| 53 |
+
(hd : ∀ t, HasDerivAt h (h' t) t) (hh : ∀ t, 0 ≤ h t)
|
| 54 |
+
(hi : Integrable h) (hi' : Integrable h') (s : Finset ℤ) :
|
| 55 |
+
τ*(∑ k ∈ s, h ((k:ℝ)*τ)) ≤ (∫ t, h t)+τ*(∫ t, |h' t|) := by
|
| 56 |
+
let U := ⋃ k ∈ s, Ioc ((k:ℝ)*τ) (((k:ℝ)+1)*τ)
|
| 57 |
+
have hle (k : ℤ) : (k:ℝ)*τ ≤ ((k:ℝ)+1)*τ := by linarith
|
| 58 |
+
have hs (f : ℝ → ℝ) (hf : Integrable f) :
|
| 59 |
+
(∑ k ∈ s, ∫ t in ((k:ℝ)*τ)..(((k:ℝ)+1)*τ), f t) = ∫ t in U, f t := by
|
| 60 |
+
simp_rw [intervalIntegral.integral_of_le (hle _)]
|
| 61 |
+
exact (integral_biUnion_finset s (fun _ _ => measurableSet_Ioc)
|
| 62 |
+
(fun k _ l _ hkl => lattice_intervals_disjoint hτ k l hkl)
|
| 63 |
+
(fun _ _ => hf.integrableOn)).symm
|
| 64 |
+
have he (k : ℤ) : (((k:ℝ)+1)*τ-(k:ℝ)*τ) = τ := by ring
|
| 65 |
+
have hb (k : ℤ) : τ*h ((k:ℝ)*τ) ≤
|
| 66 |
+
(∫ t in ((k:ℝ)*τ)..(((k:ℝ)+1)*τ), h t)+
|
| 67 |
+
τ*(∫ t in ((k:ℝ)*τ)..(((k:ℝ)+1)*τ), |h' t|) := by
|
| 68 |
+
simpa only [he] using cell_bound (a := (k:ℝ)*τ) (b := ((k:ℝ)+1)*τ)
|
| 69 |
+
(by linarith) hd hi'.intervalIntegrable
|
| 70 |
+
calc
|
| 71 |
+
_ = ∑ k ∈ s, τ*h ((k:ℝ)*τ) := Finset.mul_sum ..
|
| 72 |
+
_ ≤ ∑ k ∈ s, ((∫ t in ((k:ℝ)*τ)..(((k:ℝ)+1)*τ), h t)+
|
| 73 |
+
τ*(∫ t in ((k:ℝ)*τ)..(((k:ℝ)+1)*τ), |h' t|)) := Finset.sum_le_sum (fun k _ => hb k)
|
| 74 |
+
_ = (∫ t in U, h t)+τ*(∫ t in U, |h' t|) := by
|
| 75 |
+
rw [Finset.sum_add_distrib, ← Finset.mul_sum, hs h hi, hs (fun t => |h' t|) hi'.abs]
|
| 76 |
+
_ ≤ _ := add_le_add
|
| 77 |
+
(integral_mono_measure Measure.restrict_le_self (by filter_upwards with t using hh t) hi)
|
| 78 |
+
(mul_le_mul_of_nonneg_left
|
| 79 |
+
(integral_mono_measure Measure.restrict_le_self (by filter_upwards with t using abs_nonneg (h' t)) hi'.abs) hτ.le)
|
| 80 |
+
|
| 81 |
+
end UniformSparsestCut.LatticeDensity
|
| 82 |
+
|
| 83 |
+
namespace UniformSparsestCut.LatticeDensity
|
| 84 |
+
open MeasureTheory Set
|
| 85 |
+
open scoped BigOperators
|
| 86 |
+
|
| 87 |
+
lemma affine_integral (f : ℝ → ℝ) (c a : ℝ) :
|
| 88 |
+
(∫ t, f (c-t/a)) = |a| *(∫ t, f t) := by
|
| 89 |
+
rw [Measure.integral_comp_div (fun x => f (c-x)),smul_eq_mul,integral_sub_left_eq_self]
|
| 90 |
+
|
| 91 |
+
lemma affine_integrable {f : ℝ → ℝ} (hf : Integrable f) (c : ℝ) {a : ℝ} (ha : a ≠ 0) :
|
| 92 |
+
Integrable (fun t => f (c-t/a)) :=
|
| 93 |
+
((integrable_comp_sub_left f c).mpr hf).comp_div ha
|
| 94 |
+
|
| 95 |
+
lemma affine_lattice_bound {φ φ' : ℝ → ℝ} (hd : ∀ t, HasDerivAt φ (φ' t) t)
|
| 96 |
+
(hn : ∀ t, 0 ≤ φ t) (hi : Integrable φ) (hi' : Integrable φ')
|
| 97 |
+
(h1 : ∫ t, φ t=1) {τ a : ℝ} (hτ : 0 < τ) (ha : a ≠ 0) (c : ℝ) (s : Finset ℤ) :
|
| 98 |
+
τ/|a| *(∑ k ∈ s, φ (c-(k:ℝ)*τ/a)) ≤ 1+τ/|a| *(�� t, |φ' t|) := by
|
| 99 |
+
let h : ℝ → ℝ := fun t => φ (c-t/a)/|a|
|
| 100 |
+
let h' : ℝ → ℝ := fun t => -(φ' (c-t/a)/a)/|a|
|
| 101 |
+
have ha' : 0 < |a| := abs_pos.mpr ha
|
| 102 |
+
have hD (t : ℝ) : HasDerivAt h (h' t) t := by
|
| 103 |
+
convert! ((hd (c-t/a)).comp t (((hasDerivAt_id t).div_const a).const_sub c)).div_const |a| using 1
|
| 104 |
+
dsimp [h']
|
| 105 |
+
ring
|
| 106 |
+
have hint : (∫ t, h t)=1 := by
|
| 107 |
+
dsimp [h]
|
| 108 |
+
rw [integral_div,affine_integral,h1,mul_one,div_self ha'.ne']
|
| 109 |
+
have h'int : (∫ t, |h' t|)=(∫ t, |φ' t|)/|a| := by
|
| 110 |
+
dsimp [h']
|
| 111 |
+
simp only [abs_div,abs_neg,abs_abs]
|
| 112 |
+
rw [integral_div,integral_div,affine_integral (fun t => |φ' t|)]
|
| 113 |
+
field_simp
|
| 114 |
+
have hb := lattice_bound hτ hD (fun t => div_nonneg (hn _) (abs_nonneg _))
|
| 115 |
+
((affine_integrable hi c ha).div_const _) (((affine_integrable hi' c ha).div_const a).neg.div_const _) s
|
| 116 |
+
rw [hint,h'int] at hb
|
| 117 |
+
dsimp [h] at hb
|
| 118 |
+
rw [← Finset.sum_div] at hb
|
| 119 |
+
convert hb using 1 <;> ring
|
| 120 |
+
|
| 121 |
+
end UniformSparsestCut.LatticeDensity
|
| 122 |
+
|
| 123 |
+
end
|
| 124 |
+
|
| 125 |
+
end OAI
|
lean/OAI/Combinatorics/SparsestCut/Logarithms.lean
ADDED
|
@@ -0,0 +1,84 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import OAI.Combinatorics.SparsestCut.UniformMetric
|
| 2 |
+
|
| 3 |
+
namespace OAI
|
| 4 |
+
|
| 5 |
+
open scoped BigOperators Topology NNReal RealInnerProductSpace InnerProductSpace Matrix ContDiff ENNReal
|
| 6 |
+
open MeasureTheory ProbabilityTheory Set Filter Matrix
|
| 7 |
+
|
| 8 |
+
noncomputable section
|
| 9 |
+
|
| 10 |
+
namespace UniformSparsestCut.RateComparison
|
| 11 |
+
open Filter
|
| 12 |
+
noncomputable section
|
| 13 |
+
def weight (x : ℝ) : ℝ := Real.sqrt x*(Real.log x)^2*Real.sqrt (Real.log x)
|
| 14 |
+
lemma weight_pos {d : ℕ} (hd : 0<d) (hl : 1≤Real.log d) : 0<weight d := by
|
| 15 |
+
have hd' : (0:ℝ)<d := by exact_mod_cast hd
|
| 16 |
+
have hl' : 0<Real.log d := by linarith
|
| 17 |
+
unfold weight
|
| 18 |
+
positivity
|
| 19 |
+
lemma logarithms {d n : ℕ} (hd : 0<d) (hl : 1≤Real.log d)
|
| 20 |
+
(hnlo : d^d≤n) (hnhi : n≤d^(4030*d)) :
|
| 21 |
+
0<Real.log n ∧ Real.log d≤Real.log (Real.log n) ∧
|
| 22 |
+
Real.log n≤4030*(d:ℝ)*Real.log d := by
|
| 23 |
+
have hx : (0:ℝ)<d := by exact_mod_cast hd
|
| 24 |
+
have hlo : (d:ℝ)*Real.log d≤Real.log n := by
|
| 25 |
+
calc
|
| 26 |
+
_ = Real.log ((d:ℝ)^d) := (Real.log_pow _ _).symm
|
| 27 |
+
_ ≤ _ := Real.log_le_log (by positivity) (by exact_mod_cast hnlo)
|
| 28 |
+
have hdn : (d:ℝ)≤Real.log n := (le_mul_of_one_le_right hx.le hl).trans hlo
|
| 29 |
+
have hn0 : 0<n := (pow_pos hd _).trans_le hnlo
|
| 30 |
+
have hn0' : (0:ℝ)<n := by exact_mod_cast hn0
|
| 31 |
+
refine ⟨hx.trans_le hdn,Real.log_le_log hx hdn,?_⟩
|
| 32 |
+
calc
|
| 33 |
+
_ ≤ Real.log ((d:ℝ)^(4030*d)) := Real.log_le_log hn0' (by exact_mod_cast hnhi)
|
| 34 |
+
_ = _ := by rw [Real.log_pow]; push_cast; ring
|
| 35 |
+
lemma bound {d n : ℕ} (hd : 0<d) (hl : 1≤Real.log d)
|
| 36 |
+
(hnlo : d^d≤n) (hnhi : n≤d^(4030*d)) :
|
| 37 |
+
Real.sqrt (Real.log n)/(Real.log (Real.log n))^3≤Real.sqrt 4030*(d:ℝ)/weight d := by
|
| 38 |
+
have hx : (0:ℝ)<d := by exact_mod_cast hd
|
| 39 |
+
have hℓ : 0<Real.log d := by linarith
|
| 40 |
+
obtain ⟨hn0,hll,hln⟩ := logarithms hd hl hnlo hnhi
|
| 41 |
+
have hll0 : 0<Real.log (Real.log n) := hℓ.trans_le hll
|
| 42 |
+
have hs : Real.sqrt (Real.log n)≤Real.sqrt 4030*Real.sqrt d*Real.sqrt (Real.log d) := by
|
| 43 |
+
calc
|
| 44 |
+
_ ≤ Real.sqrt (4030*(d:ℝ)*Real.log d) := Real.sqrt_le_sqrt hln
|
| 45 |
+
_ = _ := by rw [Real.sqrt_mul (by positivity),Real.sqrt_mul (by norm_num)]
|
| 46 |
+
apply (div_le_div_iff₀ (pow_pos hll0 _) (weight_pos hd hl)).mpr
|
| 47 |
+
have hlim := mul_le_mul_of_nonneg_left (pow_le_pow_left₀ hℓ.le hll 3)
|
| 48 |
+
(mul_nonneg (Real.sqrt_nonneg 4030) hx.le)
|
| 49 |
+
calc
|
| 50 |
+
_ ≤ (Real.sqrt 4030*Real.sqrt d*Real.sqrt (Real.log d))*weight d :=
|
| 51 |
+
mul_le_mul_of_nonneg_right hs (weight_pos hd hl).le
|
| 52 |
+
_ = Real.sqrt 4030*(d:ℝ)*(Real.log d)^3 := by
|
| 53 |
+
unfold weight
|
| 54 |
+
calc
|
| 55 |
+
_ = Real.sqrt 4030*(Real.sqrt d)^2*(Real.sqrt (Real.log d))^2*(Real.log d)^2 := by ring
|
| 56 |
+
_ = _ := by rw [Real.sq_sqrt hx.le,Real.sq_sqrt hℓ.le]; ring
|
| 57 |
+
_ ≤ _ := hlim
|
| 58 |
+
lemma gap_of_gl {d n : ℕ} (hd : 0<d) (hl : 1≤Real.log d)
|
| 59 |
+
(hnlo : d^d≤n) (hnhi : n≤d^(4030*d))
|
| 60 |
+
{α β opt gl : ℝ} (hα : 0<α) (hβ : 0<β) (hopt : 1≤opt) (hgl : 0<gl)
|
| 61 |
+
(hbound : gl≤β*weight d/(α*(d:ℝ))) :
|
| 62 |
+
(α/(β*Real.sqrt 4030))*Real.sqrt (Real.log n)/(Real.log (Real.log n))^3≤opt/gl := by
|
| 63 |
+
have hx : (0:ℝ)<d := by exact_mod_cast hd
|
| 64 |
+
have hw := weight_pos hd hl
|
| 65 |
+
have hs : (0:ℝ)<Real.sqrt 4030 := by positivity
|
| 66 |
+
have hr := bound hd hl hnlo hnhi
|
| 67 |
+
have hconst : 0<α/(β*Real.sqrt 4030) := by positivity
|
| 68 |
+
have hratio : α*(d:ℝ)/(β*weight d)≤opt/gl := by
|
| 69 |
+
apply (div_le_div_iff₀ (mul_pos hβ hw) hgl).mpr
|
| 70 |
+
have h := (le_div_iff₀ (mul_pos hα hx)).mp hbound
|
| 71 |
+
have h' := mul_le_mul_of_nonneg_right hopt (mul_pos hβ hw).le
|
| 72 |
+
nlinarith only [h,h']
|
| 73 |
+
calc
|
| 74 |
+
_ = (α/(β*Real.sqrt 4030))*(Real.sqrt (Real.log n)/(Real.log (Real.log n))^3) := by ring
|
| 75 |
+
_ ≤ (α/(β*Real.sqrt 4030))*(Real.sqrt 4030*(d:ℝ)/weight d) :=
|
| 76 |
+
mul_le_mul_of_nonneg_left hr hconst.le
|
| 77 |
+
_ = α*(d:ℝ)/(β*weight d) := by field_simp
|
| 78 |
+
_ ≤ _ := hratio
|
| 79 |
+
end
|
| 80 |
+
end UniformSparsestCut.RateComparison
|
| 81 |
+
|
| 82 |
+
end
|
| 83 |
+
|
| 84 |
+
end OAI
|
lean/OAI/Combinatorics/SparsestCut/Main.lean
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import OAI.Combinatorics.SparsestCut.Logarithms
|
| 2 |
+
|
| 3 |
+
namespace OAI
|
| 4 |
+
|
| 5 |
+
open scoped BigOperators Topology NNReal RealInnerProductSpace InnerProductSpace Matrix ContDiff ENNReal
|
| 6 |
+
open MeasureTheory ProbabilityTheory Set Filter Matrix
|
| 7 |
+
|
| 8 |
+
noncomputable section
|
| 9 |
+
|
| 10 |
+
namespace UniformSparsestCut
|
| 11 |
+
open Filter
|
| 12 |
+
noncomputable section
|
| 13 |
+
|
| 14 |
+
theorem mainGap :
|
| 15 |
+
∃ c : ℝ, 0 < c ∧
|
| 16 |
+
∃ n : ℕ → ℕ, ∃ C : (j : ℕ) → Capacity (n j),
|
| 17 |
+
(∀ j, 2 ≤ n j) ∧
|
| 18 |
+
Tendsto n atTop atTop ∧
|
| 19 |
+
(∀ j, 0 < glValue (C j)) ∧
|
| 20 |
+
∀ᶠ j in atTop,
|
| 21 |
+
c * Real.sqrt (Real.log (n j : ℝ)) / (Real.log (Real.log (n j : ℝ))) ^ 3 ≤
|
| 22 |
+
OPT (C j) / glValue (C j) := by
|
| 23 |
+
classical
|
| 24 |
+
let α : ℝ := KernelApprox.cstar/6
|
| 25 |
+
let β : ℝ := SourceContraction.C+1
|
| 26 |
+
have hα : 0<α := div_pos KernelApprox.cstar_pos (by norm_num)
|
| 27 |
+
have hβ : 0<β := by have hc := SourceContraction.C_pos; dsimp [β]; linarith
|
| 28 |
+
have hcast : Tendsto (fun d : ℕ => (d:ℝ)) atTop atTop := tendsto_natCast_atTop_atTop
|
| 29 |
+
have hevent : ∀ᶠ d : ℕ in atTop, Nonempty (PivotFamily.PFamily d) ∧
|
| 30 |
+
3000≤d ∧ 1≤Real.log d ∧ SourceContraction.H≤(d:ℝ) ∧
|
| 31 |
+
4*SourceWeighted.D≤(d:ℝ) ∧ SourceMetric.C₀+1≤α*(d:ℝ) := by
|
| 32 |
+
filter_upwards [PivotFamily.pivot_directions_exist,eventually_ge_atTop 3000,
|
| 33 |
+
(Real.tendsto_log_atTop.comp hcast).eventually (eventually_ge_atTop 1),
|
| 34 |
+
hcast.eventually (eventually_ge_atTop SourceContraction.H),
|
| 35 |
+
hcast.eventually (eventually_ge_atTop (4*SourceWeighted.D)),
|
| 36 |
+
hcast.eventually (eventually_ge_atTop ((SourceMetric.C₀+1)/α))] with d hf hd hl hH hD ha
|
| 37 |
+
exact ⟨hf,hd,hl,hH,hD,by simpa only [mul_comm] using (div_le_iff₀ hα).mp ha⟩
|
| 38 |
+
obtain ⟨N,hN⟩ := eventually_atTop.mp hevent
|
| 39 |
+
have hex : ∀ j : ℕ, ∃ (n : ℕ) (C : Capacity n),
|
| 40 |
+
(j+N+1)^(j+N+1)≤n ∧ n≤(j+N+1)^(4030*(j+N+1)) ∧
|
| 41 |
+
2≤n ∧ 1≤OPT C ∧ 0<glValue C ∧ glValue C≤β*RateComparison.weight (j+N+1:ℕ)/(α*(j+N+1:ℕ)) := by
|
| 42 |
+
intro j
|
| 43 |
+
obtain ⟨⟨f⟩,hd,hl,hH,hD,ha⟩ := hN (j+N+1) (by omega)
|
| 44 |
+
exact SourceUniform.instance_exists f hd hl hH hD ha
|
| 45 |
+
choose n C hlo hhi hn hopt hgl hbound using hex
|
| 46 |
+
refine ⟨α/(β*Real.sqrt 4030),by positivity,n,C,hn,?_,hgl,?_⟩
|
| 47 |
+
· apply tendsto_atTop_mono (fun j => ?_) tendsto_id
|
| 48 |
+
have hd1 : 1≤j+N+1 := by omega
|
| 49 |
+
have hp : j+N+1≤(j+N+1)^(j+N+1) := by
|
| 50 |
+
simpa using (Nat.pow_le_pow_right hd1 hd1 : (j+N+1)^1≤(j+N+1)^(j+N+1))
|
| 51 |
+
exact (show j≤j+N+1 by omega).trans (hp.trans (hlo j))
|
| 52 |
+
· exact Filter.Eventually.of_forall (fun j => RateComparison.gap_of_gl
|
| 53 |
+
(by omega : 0<j+N+1) (hN (j+N+1) (by omega)).2.2.1
|
| 54 |
+
(hlo j) (hhi j) hα hβ (hopt j) (hgl j) (hbound j))
|
| 55 |
+
end
|
| 56 |
+
end UniformSparsestCut
|
| 57 |
+
|
| 58 |
+
end
|
| 59 |
+
|
| 60 |
+
end OAI
|
lean/OAI/Combinatorics/SparsestCut/Metric.lean
ADDED
|
@@ -0,0 +1,155 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import OAI.Combinatorics.SparsestCut.Parameters
|
| 2 |
+
|
| 3 |
+
namespace OAI
|
| 4 |
+
|
| 5 |
+
open scoped BigOperators Topology NNReal RealInnerProductSpace InnerProductSpace Matrix ContDiff ENNReal
|
| 6 |
+
open MeasureTheory ProbabilityTheory Set Filter Matrix
|
| 7 |
+
|
| 8 |
+
noncomputable section
|
| 9 |
+
|
| 10 |
+
namespace UniformSparsestCut.SourceMetric
|
| 11 |
+
open scoped BigOperators RealInnerProductSpace
|
| 12 |
+
open SourceParameters SourceCharts
|
| 13 |
+
noncomputable section
|
| 14 |
+
variable {m : ℕ} (f : PivotFamily.PFamily m)
|
| 15 |
+
local notation "E" => EuclideanSpace ℝ (Fin m)
|
| 16 |
+
abbrev V := RoundedCharts.Vertex (u f) (p m 2000)
|
| 17 |
+
noncomputable instance vertexFintype [NeZero m] : Fintype (V f) := by
|
| 18 |
+
letI := RoundedCharts.vertex_finite (u f) (τ := p m 2000) (p_pos (by exact_mod_cast NeZero.pos m) _) (fun s i => (u_norm f (NeZero.pos m) s i).2)
|
| 19 |
+
exact Fintype.ofFinite _
|
| 20 |
+
def L : ℝ := GramMetric.localCost (m^6) (m^3) (Real.sqrt m) (p m 5) (p m 200)
|
| 21 |
+
(p m 40) ((m:ℝ)^40) (p m 1997) (2/Real.sqrt m)
|
| 22 |
+
def err : ℝ := GramMetric.macroCost (m^6) (m^3) (Real.sqrt m) (p m 5) (p m 200)
|
| 23 |
+
(p m 40) ((m:ℝ)^40) (p m 1997) (3*Real.sqrt m) 0
|
| 24 |
+
lemma realization [NeZero m] (hm : 3000 ≤ m) (hl : 1≤Real.log m) :
|
| 25 |
+
∃ Z : V f → EuclideanSpace ℝ (V f),
|
| 26 |
+
(∀ v w z, ‖Z v-Z z‖^2≤‖Z v-Z w‖^2+‖Z w-Z z‖^2) ∧
|
| 27 |
+
(∀ v w, |‖Z v-Z w‖^2-KernelApprox.cstar*Real.sqrt m*
|
| 28 |
+
‖B f (NeZero.pos m) v.val.1 (RoundedCharts.coordinate (u f) (p m 2000) v)-
|
| 29 |
+
B f (NeZero.pos m) w.val.1 (RoundedCharts.coordinate (u f) (p m 2000) w)‖|≤err (m:=m)+8*p m 8) ∧
|
| 30 |
+
(∀ v w, v.val.1=w.val.1 → (∑ i, |RoundedCharts.coordinate (u f) (p m 2000) v i-
|
| 31 |
+
RoundedCharts.coordinate (u f) (p m 2000) w i|)=p m 2000 →
|
| 32 |
+
‖Z v-Z w‖^2≤50000000*p m 2000*p m 5*(Real.log m)^2) := by
|
| 33 |
+
have hm0 := NeZero.pos m
|
| 34 |
+
have hm1 : 1 ≤ m := by omega
|
| 35 |
+
have hm2 : 2 ≤ m := by omega
|
| 36 |
+
have hx : (1:ℝ) ≤ m := by exact_mod_cast hm1
|
| 37 |
+
have hx0 : (0:ℝ) < m := by exact_mod_cast hm0
|
| 38 |
+
have hτ := p_pos hx0 2000
|
| 39 |
+
let c : V f → Fin (m^3) := fun v => v.val.1
|
| 40 |
+
let x := RoundedCharts.coordinate (u f) (p m 2000)
|
| 41 |
+
let θ : V f → E := fun v => B f hm0 (c v) (x v)
|
| 42 |
+
have hhab : p m 40≤(m:ℝ)^40 := (p_one_le hx _).trans (one_le_pow₀ hx)
|
| 43 |
+
have hb (s : Fin (m^3)) (i : Fin (m^6)) : ‖B f hm0 s (EuclideanSpace.single i 1)‖≤4*p m 5 := by
|
| 44 |
+
have h := B_column f hm0 s i
|
| 45 |
+
convert h using 1
|
| 46 |
+
unfold p; field_simp
|
| 47 |
+
have hFourier (s : Fin (m^3)) (w : E) (hw : ‖w‖≤2*(3*Real.sqrt m)/p m 40) :
|
| 48 |
+
‖Real.exp (-‖w‖^2/2) • w-((m^6:ℕ):ℝ)⁻¹ • ∑ i, Real.sin (inner ℝ (f.g s i) w) • f.g s i‖≤2/Real.sqrt m := by
|
| 49 |
+
rw [norm_sub_rev]
|
| 50 |
+
exact f.fourier s w (hw.trans (fourier_radius (show 6 ≤ m by omega)))
|
| 51 |
+
have hB (v : V f) : ‖B f hm0 (c v) (x v)‖≤3*Real.sqrt m := by
|
| 52 |
+
have h := vertex_B_bound f hm0 hm2 hτ v
|
| 53 |
+
rw [rounded_radius hm0] at h
|
| 54 |
+
exact h.trans (by linarith [radius_le_sqrt hm1])
|
| 55 |
+
have hres (v : V f) :
|
| 56 |
+
‖ChartKernel.residual (FrameCharts.chart (fun i => (Real.sqrt m)⁻¹ • f.g (c v) i)) (B f hm0 (c v)) (x v)‖≤p m 1997 := by
|
| 57 |
+
have h := vertex_residual_bound f hm0 hτ v
|
| 58 |
+
rw [rounded_radius hm0] at h
|
| 59 |
+
exact h
|
| 60 |
+
have he := (macro_bounds hm1).1
|
| 61 |
+
have her : 3*err (m:=m)/2≤p m 8 := by
|
| 62 |
+
have hsmall := macro_small hm
|
| 63 |
+
change err (m:=m)≤p m 8/2 at hsmall
|
| 64 |
+
nlinarith [p_nonneg hx0.le 8]
|
| 65 |
+
obtain ⟨Z,htri,hmac,hloc,hzero⟩ := GramMetric.realization f.g (B f hm0) c x θ
|
| 66 |
+
(q:=Real.sqrt m) (k:=p m 5) (ε:=p m 200) (a:=p m 40) (b:=(m:ℝ)^40)
|
| 67 |
+
(R:=p m 1997) (T:=3*Real.sqrt m) (Rpos:=0) (γ:=2/Real.sqrt m) (r:=p m 8)
|
| 68 |
+
(Real.sqrt_pos.mpr hx0) (p_nonneg hx0.le 5) (p_one_le hx 5) (p_pos hx0 200) (p_pos hx0 40) hhab
|
| 69 |
+
(p_nonneg hx0.le 1997) (by positivity) (by positivity)
|
| 70 |
+
(by simpa only [Nat.cast_pow] using k_eq hx0)
|
| 71 |
+
(fun s i => (f.norms s i).2) hb hFourier hB hres
|
| 72 |
+
(fun v => by simp [θ]) he (p_pos hx0 8) her
|
| 73 |
+
refine ⟨Z,htri,hmac,?_⟩
|
| 74 |
+
intro v w hc hsum
|
| 75 |
+
have hh := local_tau hm hl
|
| 76 |
+
have h := hloc v w hc (by rw [hsum]; exact hh.1) (by rw [hsum]; exact hh.2.1)
|
| 77 |
+
rw [hsum] at h
|
| 78 |
+
exact h.trans hh.2.2
|
| 79 |
+
end
|
| 80 |
+
end UniformSparsestCut.SourceMetric
|
| 81 |
+
|
| 82 |
+
namespace UniformSparsestCut.SourceMetric
|
| 83 |
+
open scoped BigOperators RealInnerProductSpace
|
| 84 |
+
open SourceParameters SourceCharts
|
| 85 |
+
noncomputable section
|
| 86 |
+
variable {m : ℕ} (f : PivotFamily.PFamily m) [NeZero m]
|
| 87 |
+
local notation "E" => EuclideanSpace ℝ (Fin m)
|
| 88 |
+
def C₀ : ℝ := 9+2*KernelApprox.cstar
|
| 89 |
+
lemma C₀_pos : 0<C₀ := by unfold C₀; linarith [KernelApprox.cstar_pos]
|
| 90 |
+
def vertex (s : Fin (m^3)) (θ : E) (hθ : θ∈RoundedCharts.cube 2)
|
| 91 |
+
(hs : RoundedCharts.regular (u f s) (p m 2000) θ) : V f :=
|
| 92 |
+
⟨(s,RoundedCharts.integerLabel (u f s) (p m 2000) θ),θ,hθ,hs,rfl⟩
|
| 93 |
+
omit [NeZero m] in
|
| 94 |
+
lemma near_norm (hm : 3000 ≤ m) : Real.sqrt m*p m 1997≤p m 8 := by
|
| 95 |
+
have hx : (1:ℝ) ≤ m := by exact_mod_cast (show 1 ≤ m by omega)
|
| 96 |
+
calc
|
| 97 |
+
_ ≤ (m:ℝ)*p m 1997 := mul_le_mul_of_nonneg_right (sqrt_le hx) (p_nonneg (by positivity) _)
|
| 98 |
+
_ = p m 1996 := p_succ (by positivity : (m:ℝ)≠0) 1996
|
| 99 |
+
_ ≤ _ := p_le hx (by norm_num)
|
| 100 |
+
lemma macro_bound (hm : 3000 ≤ m) (Z : V f → EuclideanSpace ℝ (V f))
|
| 101 |
+
(hmac : ∀ v w, |‖Z v-Z w‖^2-KernelApprox.cstar*Real.sqrt m*
|
| 102 |
+
‖B f (NeZero.pos m) v.val.1 (RoundedCharts.coordinate (u f) (p m 2000) v)-
|
| 103 |
+
B f (NeZero.pos m) w.val.1 (RoundedCharts.coordinate (u f) (p m 2000) w)‖|≤err (m:=m)+8*p m 8)
|
| 104 |
+
(s t : Fin (m^3)) (θ η : E) (hθ : θ∈RoundedCharts.cube 2) (hη : η∈RoundedCharts.cube 2)
|
| 105 |
+
(hs : RoundedCharts.regular (u f s) (p m 2000) θ)
|
| 106 |
+
(ht : RoundedCharts.regular (u f t) (p m 2000) η) :
|
| 107 |
+
|‖Z (vertex f s θ hθ hs)-Z (vertex f t η hη ht)‖^2-KernelApprox.cstar*Real.sqrt m*‖θ-η‖|≤C₀*p m 8 := by
|
| 108 |
+
let v := vertex f s θ hθ hs
|
| 109 |
+
let w := vertex f t η hη ht
|
| 110 |
+
let X := B f (NeZero.pos m) s (RoundedCharts.rounded (u f s) (p m 2000) θ)
|
| 111 |
+
let Y := B f (NeZero.pos m) t (RoundedCharts.rounded (u f t) (p m 2000) η)
|
| 112 |
+
have hτ : 0<p m 2000 := p_pos (by exact_mod_cast NeZero.pos m) _
|
| 113 |
+
have hx : ‖X-θ‖≤p m 1997 := by
|
| 114 |
+
simpa only [rounded_radius (NeZero.pos m)] using rounded_B_error f (NeZero.pos m) (show 2 ≤ m by omega) hτ s θ
|
| 115 |
+
have hy : ‖Y-η‖≤p m 1997 := by
|
| 116 |
+
simpa only [rounded_radius (NeZero.pos m)] using rounded_B_error f (NeZero.pos m) (show 2 ≤ m by omega) hτ t η
|
| 117 |
+
have hnorm : |‖X-Y‖-‖θ-η‖|≤2*p m 1997 := by
|
| 118 |
+
calc
|
| 119 |
+
_ ≤ ‖(X-Y)-(θ-η)‖ := abs_norm_sub_norm_le _ _
|
| 120 |
+
_ = ‖(X-θ)-(Y-η)‖ := by congr 1; abel
|
| 121 |
+
_ ≤ ‖X-θ‖+‖Y-η‖ := norm_sub_le _ _
|
| 122 |
+
_ ≤ _ := by linarith
|
| 123 |
+
have hM := hmac v w
|
| 124 |
+
change |‖Z v-Z w‖^2-KernelApprox.cstar*Real.sqrt m*‖X-Y‖|≤err (m:=m)+8*p m 8 at hM
|
| 125 |
+
have hq : 0≤KernelApprox.cstar*Real.sqrt m := mul_nonneg KernelApprox.cstar_pos.le (Real.sqrt_nonneg _)
|
| 126 |
+
have hh := mul_le_mul_of_nonneg_left (near_norm (m:=m) hm) (mul_nonneg (by norm_num : (0:ℝ)≤2) KernelApprox.cstar_pos.le)
|
| 127 |
+
have he := macro_small hm
|
| 128 |
+
change err (m:=m)≤p m 8/2 at he
|
| 129 |
+
have hM' := abs_le.mp hM
|
| 130 |
+
have hn' := abs_le.mp hnorm
|
| 131 |
+
have hn1 := mul_le_mul_of_nonneg_left hn'.1 hq
|
| 132 |
+
have hn2 := mul_le_mul_of_nonneg_left hn'.2 hq
|
| 133 |
+
change |‖Z v-Z w‖^2-KernelApprox.cstar*Real.sqrt m*‖θ-η‖|≤_
|
| 134 |
+
rw [abs_le]; unfold C₀
|
| 135 |
+
constructor <;> nlinarith [p_nonneg (by positivity : (0:ℝ) ≤ m) 8]
|
| 136 |
+
lemma one_step (vp vm : V f) (i : Fin (m^6))
|
| 137 |
+
(hi : vp.val.2 i=vm.val.2 i+1) (hj : ∀ j, j≠i → vp.val.2 j=vm.val.2 j) :
|
| 138 |
+
(∑ j, |RoundedCharts.coordinate (u f) (p m 2000) vp j-
|
| 139 |
+
RoundedCharts.coordinate (u f) (p m 2000) vm j|)=p m 2000 := by
|
| 140 |
+
classical
|
| 141 |
+
rw [Finset.sum_eq_single i]
|
| 142 |
+
· change |p m 2000*(vp.val.2 i:ℝ)-p m 2000*(vm.val.2 i:ℝ)|=_
|
| 143 |
+
rw [hi,Int.cast_add,Int.cast_one]
|
| 144 |
+
have h : p m 2000*((vm.val.2 i:ℝ)+1)-p m 2000*(vm.val.2 i:ℝ)=p m 2000 := by ring
|
| 145 |
+
rw [h,abs_of_pos (p_pos (by exact_mod_cast NeZero.pos m) _)]
|
| 146 |
+
· intro j hmem hji
|
| 147 |
+
change |p m 2000*(vp.val.2 j:ℝ)-p m 2000*(vm.val.2 j:ℝ)|=0
|
| 148 |
+
rw [hj j hji,sub_self,abs_zero]
|
| 149 |
+
· simp
|
| 150 |
+
end
|
| 151 |
+
end UniformSparsestCut.SourceMetric
|
| 152 |
+
|
| 153 |
+
end
|
| 154 |
+
|
| 155 |
+
end OAI
|
lean/OAI/Combinatorics/SparsestCut/MetricKernel.lean
ADDED
|
@@ -0,0 +1,218 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import OAI.Combinatorics.SparsestCut.Profiles
|
| 2 |
+
|
| 3 |
+
namespace OAI
|
| 4 |
+
|
| 5 |
+
universe u1 u2 u3 u4 u5 u6
|
| 6 |
+
|
| 7 |
+
open scoped BigOperators Topology NNReal RealInnerProductSpace InnerProductSpace Matrix ContDiff ENNReal
|
| 8 |
+
open MeasureTheory ProbabilityTheory Set Filter Matrix
|
| 9 |
+
|
| 10 |
+
noncomputable section
|
| 11 |
+
|
| 12 |
+
namespace UniformSparsestCut.MetricKernel
|
| 13 |
+
open MeasureTheory Set
|
| 14 |
+
open scoped RealInnerProductSpace BigOperators
|
| 15 |
+
variable {E : Type u1} [NormedAddCommGroup E] [InnerProductSpace ℝ E]
|
| 16 |
+
variable {ι : Type u2} {κ : Type u3} [Fintype ι] [Fintype κ]
|
| 17 |
+
|
| 18 |
+
omit [Fintype ι] in
|
| 19 |
+
lemma gram_eq_kernel (g : κ → E) (θ : ι → E) (α : ι → κ → ℝ)
|
| 20 |
+
(q ε : ℝ) {a b : ℝ} (ha : 0 < a) (hab : a ≤ b) (v w : ι) :
|
| 21 |
+
CommonKernel.gram g θ α q ε a b v w =
|
| 22 |
+
Profile.kernel g q ε a b (θ v) (θ w) (α v) (α w) := by
|
| 23 |
+
have hf (k : κ) := CommonKernel.circle_integrable g θ α ha hab v w k
|
| 24 |
+
have hi := CommonKernel.gaussian_integrable θ ha hab v w
|
| 25 |
+
have hiS : IntervalIntegrable (fun σ => ∑ i, inner ℝ
|
| 26 |
+
(CommonKernel.circle (inner ℝ (g i) (θ v)/σ) (α v i))
|
| 27 |
+
(CommonKernel.circle (inner ℝ (g i) (θ w)/σ) (α w i))/σ) volume a b := by
|
| 28 |
+
convert IntervalIntegrable.sum Finset.univ (fun i _ => hf i) using 1
|
| 29 |
+
funext σ
|
| 30 |
+
simp only [Finset.sum_apply]
|
| 31 |
+
unfold CommonKernel.gram Profile.kernel Profile.pairing
|
| 32 |
+
rw [← intervalIntegral.integral_const_mul, ← intervalIntegral.integral_finsetSum (fun k _ => hf k),
|
| 33 |
+
← intervalIntegral.integral_const_mul, ← intervalIntegral.integral_add (hi.const_mul q)
|
| 34 |
+
(hiS.const_mul ε)]
|
| 35 |
+
apply intervalIntegral.integral_congr
|
| 36 |
+
intro σ hσ
|
| 37 |
+
rw [norm_sub_rev (θ w) (θ v)]
|
| 38 |
+
|
| 39 |
+
simp only [CommonKernel.circle_inner, inner_sub_right, sub_div, ← Finset.sum_div]
|
| 40 |
+
ring
|
| 41 |
+
|
| 42 |
+
lemma kernel_psd (g : κ → E) (θ : ι → E) (α : ι → κ → ℝ)
|
| 43 |
+
{q ε a b : ℝ} (hq : 0 ≤ q) (hε : 0 ≤ ε) (ha : 0 < a) (hab : a ≤ b) :
|
| 44 |
+
Matrix.PosSemidef (fun v w => Profile.kernel g q ε a b (θ v) (θ w) (α v) (α w)) := by
|
| 45 |
+
have he : (fun v w => Profile.kernel g q ε a b (θ v) (θ w) (α v) (α w)) =
|
| 46 |
+
CommonKernel.gram g θ α q ε a b := by
|
| 47 |
+
funext v w; exact (gram_eq_kernel g θ α q ε ha hab v w).symm
|
| 48 |
+
rw [he]
|
| 49 |
+
exact CommonKernel.gram_posSemidef g θ α hq hε ha hab
|
| 50 |
+
|
| 51 |
+
lemma base_pairing (g : κ → E) (q ε σ : ℝ) (θ η : E) :
|
| 52 |
+
Profile.pairing g q ε σ θ θ 0 0 + Profile.pairing g q ε σ η η 0 0 -
|
| 53 |
+
2*Profile.pairing g q ε σ θ η 0 0 =
|
| 54 |
+
2*q*KernelApprox.scaled ‖η-θ‖ σ +
|
| 55 |
+
2*ε/σ*∑ i, (1-Real.cos (inner ℝ (g i) (η-θ)/σ)) := by
|
| 56 |
+
simp only [Profile.pairing, Pi.zero_apply, mul_zero, zero_mul, add_zero,
|
| 57 |
+
sub_self, norm_zero, zero_pow (by decide : (2:ℕ) ≠ 0), neg_zero,
|
| 58 |
+
zero_div, Real.exp_zero, inner_zero_right, Real.cos_zero, Real.sin_zero, one_mul,
|
| 59 |
+
Finset.sum_const, nsmul_eq_mul, mul_one, Finset.sum_sub_distrib, KernelApprox.scaled]
|
| 60 |
+
ring
|
| 61 |
+
|
| 62 |
+
omit [InnerProductSpace ℝ E] in
|
| 63 |
+
lemma gaussian_scaled_integrable (θ η : E) {a b : ℝ} (ha : 0 < a) (hab : a ≤ b) :
|
| 64 |
+
IntervalIntegrable (KernelApprox.scaled ‖η-θ‖) volume a b := by
|
| 65 |
+
apply ContinuousOn.intervalIntegrable
|
| 66 |
+
rw [uIcc_of_le hab]
|
| 67 |
+
unfold KernelApprox.scaled
|
| 68 |
+
apply continuousOn_const.sub
|
| 69 |
+
apply Real.continuous_exp.comp_continuousOn
|
| 70 |
+
exact continuousOn_const.div (by fun_prop) (fun σ hσ => by have := ha.trans_le hσ.1; positivity)
|
| 71 |
+
|
| 72 |
+
omit [Fintype κ] in
|
| 73 |
+
lemma cos_integrable (g : κ → E) (θ η : E) {a b : ℝ} (ha : 0 < a) (hab : a ≤ b) (i : κ) :
|
| 74 |
+
IntervalIntegrable (fun σ => (1-Real.cos (inner ℝ (g i) (η-θ)/σ))/σ) volume a b := by
|
| 75 |
+
apply ContinuousOn.intervalIntegrable
|
| 76 |
+
rw [uIcc_of_le hab]
|
| 77 |
+
have hn : ∀ σ ∈ Icc a b, σ ≠ 0 := fun σ hσ => (ha.trans_le hσ.1).ne'
|
| 78 |
+
exact (continuousOn_const.sub (Real.continuous_cos.comp_continuousOn
|
| 79 |
+
(continuousOn_const.div continuousOn_id hn))).div continuousOn_id hn
|
| 80 |
+
|
| 81 |
+
omit [Fintype κ] in
|
| 82 |
+
lemma cos_integral_bound (g : κ → E) (θ η : E) {a b : ℝ} (ha : 0 < a) (hab : a ≤ b) (i : κ) :
|
| 83 |
+
|∫ σ in a..b, (1-Real.cos (inner ℝ (g i) (η-θ)/σ))/σ| ≤ 2*Real.log (b/a) := by
|
| 84 |
+
have hi := cos_integrable g θ η ha hab i
|
| 85 |
+
have hii : IntervalIntegrable (fun σ : ℝ => σ⁻¹) volume a b := by
|
| 86 |
+
apply ContinuousOn.intervalIntegrable
|
| 87 |
+
rw [uIcc_of_le hab]
|
| 88 |
+
exact continuousOn_id.inv₀ (fun σ hσ => (ha.trans_le hσ.1).ne')
|
| 89 |
+
have hn : 0 ≤ ∫ σ in a..b, (1-Real.cos (inner ℝ (g i) (η-θ)/σ))/σ := by
|
| 90 |
+
apply intervalIntegral.integral_nonneg hab
|
| 91 |
+
intro σ hσ
|
| 92 |
+
exact div_nonneg (sub_nonneg.mpr (Real.cos_le_one _)) (ha.trans_le hσ.1).le
|
| 93 |
+
rw [abs_of_nonneg hn]
|
| 94 |
+
calc
|
| 95 |
+
_ ≤ ∫ σ in a..b, 2*σ⁻¹ := by
|
| 96 |
+
apply intervalIntegral.integral_mono_on hab hi (hii.const_mul 2)
|
| 97 |
+
intro σ hσ
|
| 98 |
+
rw [← div_eq_mul_inv]
|
| 99 |
+
apply div_le_div_of_nonneg_right _ (ha.trans_le hσ.1).le
|
| 100 |
+
linarith [Real.neg_one_le_cos (inner ℝ (g i) (η-θ)/σ)]
|
| 101 |
+
_ = _ := by rw [intervalIntegral.integral_const_mul, integral_inv_of_pos ha (ha.trans_le hab)]
|
| 102 |
+
|
| 103 |
+
lemma base_distance_error (g : κ → E) {q ε a b : ℝ} (hq : 0 ≤ q) (hε : 0 ≤ ε)
|
| 104 |
+
(ha : 0 < a) (hab : a ≤ b) (θ η : E) :
|
| 105 |
+
|Profile.kernel g q ε a b θ θ 0 0 + Profile.kernel g q ε a b η η 0 0 -
|
| 106 |
+
2*Profile.kernel g q ε a b θ η 0 0 - KernelApprox.cstar*q*‖η-θ‖| ≤
|
| 107 |
+
q*(2*a+‖η-θ‖^2/b)+4*ε*(Fintype.card κ : ℝ)*Real.log (b/a) := by
|
| 108 |
+
have hi1 := Profile.pairing_integrable g q ε θ θ 0 0 ha hab
|
| 109 |
+
have hi2 := Profile.pairing_integrable g q ε η η 0 0 ha hab
|
| 110 |
+
have hi3 := Profile.pairing_integrable g q ε θ η 0 0 ha hab
|
| 111 |
+
have hic (i : κ) := cos_integrable g θ η ha hab i
|
| 112 |
+
have hig := gaussian_scaled_integrable θ η ha hab
|
| 113 |
+
have hiS : IntervalIntegrable (fun σ => ∑ i, (1-Real.cos (inner ℝ (g i) (η-θ)/σ))/σ) volume a b := by
|
| 114 |
+
convert IntervalIntegrable.sum Finset.univ (fun i _ => hic i) using 1
|
| 115 |
+
funext σ
|
| 116 |
+
simp only [Finset.sum_apply]
|
| 117 |
+
have he : Profile.kernel g q ε a b θ θ 0 0 + Profile.kernel g q ε a b η η 0 0 -
|
| 118 |
+
2*Profile.kernel g q ε a b θ η 0 0 =
|
| 119 |
+
2*q*(∫ σ in a..b, KernelApprox.scaled ‖η-θ‖ σ) +
|
| 120 |
+
2*ε*(∑ i, ∫ σ in a..b, (1-Real.cos (inner ℝ (g i) (η-θ)/σ))/σ) := by
|
| 121 |
+
unfold Profile.kernel
|
| 122 |
+
rw [← intervalIntegral.integral_add hi1 hi2, ← intervalIntegral.integral_const_mul,
|
| 123 |
+
← intervalIntegral.integral_sub (hi1.add hi2) (hi3.const_mul 2)]
|
| 124 |
+
have hi : (fun σ => Profile.pairing g q ε σ θ θ 0 0 + Profile.pairing g q ε σ η η 0 0 -
|
| 125 |
+
2*Profile.pairing g q ε σ θ η 0 0) =
|
| 126 |
+
(fun σ => 2*q*KernelApprox.scaled ‖η-θ‖ σ +
|
| 127 |
+
2*ε*∑ i, (1-Real.cos (inner ℝ (g i) (η-θ)/σ))/σ) := by
|
| 128 |
+
funext σ; rw [base_pairing]; simp only [← Finset.sum_div]; ring
|
| 129 |
+
rw [hi, intervalIntegral.integral_add (hig.const_mul _) (hiS.const_mul _),
|
| 130 |
+
intervalIntegral.integral_const_mul, intervalIntegral.integral_const_mul,
|
| 131 |
+
intervalIntegral.integral_finsetSum (fun i _ => hic i)]
|
| 132 |
+
rw [he]
|
| 133 |
+
have ht := KernelApprox.truncated_error (norm_nonneg (η-θ)) ha hab
|
| 134 |
+
rw [← intervalIntegral.integral_of_le hab] at ht
|
| 135 |
+
have hs : |∑ i, ∫ σ in a..b, (1-Real.cos (inner ℝ (g i) (η-θ)/σ))/σ| ≤
|
| 136 |
+
(Fintype.card κ : ℝ)*(2*Real.log (b/a)) := by
|
| 137 |
+
calc
|
| 138 |
+
_ ≤ ∑ i, |∫ σ in a..b, (1-Real.cos (inner ℝ (g i) (η-θ)/σ))/σ| := Finset.abs_sum_le_sum_abs _ _
|
| 139 |
+
_ ≤ ∑ _i : κ, 2*Real.log (b/a) := Finset.sum_le_sum (fun i _ => cos_integral_bound g θ η ha hab i)
|
| 140 |
+
_ = _ := by simp
|
| 141 |
+
have hsplit : 2*q*(∫ σ in a..b, KernelApprox.scaled ‖η-θ‖ σ) +
|
| 142 |
+
2*ε*(∑ i, ∫ σ in a..b, (1-Real.cos (inner ℝ (g i) (η-θ)/σ))/σ) -
|
| 143 |
+
KernelApprox.cstar*q*‖η-θ‖ =
|
| 144 |
+
q*(2*(∫ σ in a..b, KernelApprox.scaled ‖η-θ‖ σ)-KernelApprox.cstar*‖η-θ‖)+
|
| 145 |
+
2*ε*(∑ i, ∫ σ in a..b, (1-Real.cos (inner ℝ (g i) (η-θ)/σ))/σ) := by ring
|
| 146 |
+
rw [hsplit]
|
| 147 |
+
calc
|
| 148 |
+
_ ≤ |q*(2*(∫ σ in a..b, KernelApprox.scaled ‖η-θ‖ σ)-KernelApprox.cstar*‖η-θ‖)|+
|
| 149 |
+
|2*ε*(∑ i, ∫ σ in a..b, (1-Real.cos (inner ℝ (g i) (η-θ)/σ))/σ)| := abs_add_le ..
|
| 150 |
+
_ ≤ q*(2*a+‖η-θ‖^2/b)+2*ε*((Fintype.card κ : ℝ)*(2*Real.log (b/a))) := by
|
| 151 |
+
simp only [abs_mul, abs_of_nonneg hq, abs_of_nonneg (mul_nonneg (by norm_num : (0:ℝ) ≤ 2) hε)]
|
| 152 |
+
exact add_le_add (mul_le_mul_of_nonneg_left ht hq) (mul_le_mul_of_nonneg_left hs (by positivity))
|
| 153 |
+
_ = _ := by ring
|
| 154 |
+
|
| 155 |
+
end UniformSparsestCut.MetricKernel
|
| 156 |
+
|
| 157 |
+
namespace UniformSparsestCut.MetricKernel
|
| 158 |
+
open MeasureTheory Set
|
| 159 |
+
open scoped BigOperators RealInnerProductSpace
|
| 160 |
+
variable {E : Type u4} [NormedAddCommGroup E] [InnerProductSpace ℝ E]
|
| 161 |
+
variable {S : Type u5} {N : Type u6} [Fintype S] [Fintype N] [DecidableEq S]
|
| 162 |
+
|
| 163 |
+
lemma full_differential_bound (g : S → N → E) (s : S)
|
| 164 |
+
{q ε σ k γ G A V H D₀ : ℝ} (θ η v : E) (h : N → ℝ) (α β : S × N → ℝ)
|
| 165 |
+
(hq : 0 < q) (hε : 0 < ε) (hσ : 0 < σ) (hk : k = q^2/(Fintype.card N : ℝ))
|
| 166 |
+
(hG : 0 ≤ G) (hA : 0 ≤ A) (hV : 0 ≤ V) (hH : 0 ≤ H) (hD : 0 ≤ D₀) (hγ : 0 ≤ γ)
|
| 167 |
+
(hg : ∀ s i, ‖g s i‖ ≤ G) (hv : ‖v‖ ≤ V*H) (hh : ∑ i, |h i| ≤ H)
|
| 168 |
+
(hα : ∀ i, |α i| ≤ A) (hβ : ∀ i, |β i| ≤ A)
|
| 169 |
+
(hδ : ∀ i : S × N, |(if i.1 = s then k/ε*(h i.2-inner ℝ (g i.1 i.2) v/q) else 0)| ≤ D₀*H)
|
| 170 |
+
(hf : ‖Real.exp (-‖(σ⁻¹:ℝ) • (η-θ)‖^2/2) • ((σ⁻¹:ℝ) • (η-θ)) -
|
| 171 |
+
((Fintype.card N : ℝ)⁻¹) • ∑ i, Real.sin (inner ℝ (g s i) (η-θ)/σ) • g s i‖ ≤ γ) :
|
| 172 |
+
|Profile.differential (fun j : S × N => g j.1 j.2) q ε σ θ η v α β
|
| 173 |
+
(fun j => if j.1 = s then k/ε*(h j.2-inner ℝ (g j.1 j.2) v/q) else 0)| ≤
|
| 174 |
+
((k+q*γ*V+ε*((Fintype.card S : ℝ)*(Fintype.card N : ℝ))*D₀*A)*H)/σ +
|
| 175 |
+
(ε*((Fintype.card S : ℝ)*(Fintype.card N : ℝ))*G*V*(1+A^2+2*A)*H)/σ^2 := by
|
| 176 |
+
let δ : S × N → ℝ := fun j => if j.1 = s then k/ε*(h j.2-inner ℝ (g j.1 j.2) v/q) else 0
|
| 177 |
+
let c : ℝ := (Fintype.card S : ℝ)*(Fintype.card N : ℝ)
|
| 178 |
+
have hc : 0 ≤ c := by dsimp [c]; positivity
|
| 179 |
+
have hk0 : 0 ≤ k := by rw [hk]; positivity
|
| 180 |
+
have hg0 := Profile.active_bound g s θ η v h hq hε hσ hk hg hf
|
| 181 |
+
have hcorr := Profile.differential_correction (q := q) (fun j : S × N => g j.1 j.2) hε.le hσ θ η v α β δ
|
| 182 |
+
have hc' : (∑ i : S × N, (|δ i| *|β i|+|inner ℝ (g i.1 i.2) v|/σ*
|
| 183 |
+
(|α i| *|β i|+|α i|+|β i|))) ≤ c*(D₀*H*A+G*(V*H)/σ*(A^2+2*A)) := by
|
| 184 |
+
calc
|
| 185 |
+
_ ≤ ∑ _i : S × N, (D₀*H*A+G*(V*H)/σ*(A^2+2*A)) := by
|
| 186 |
+
apply Finset.sum_le_sum; intro i _
|
| 187 |
+
apply add_le_add
|
| 188 |
+
· exact mul_le_mul (hδ i) (hβ i) (abs_nonneg _) (mul_nonneg hD hH)
|
| 189 |
+
· apply mul_le_mul
|
| 190 |
+
· apply div_le_div_of_nonneg_right _ hσ.le
|
| 191 |
+
exact (abs_real_inner_le_norm _ v).trans (mul_le_mul (hg i.1 i.2) hv (norm_nonneg v) hG)
|
| 192 |
+
· have hp := mul_le_mul (hα i) (hβ i) (abs_nonneg _) hA
|
| 193 |
+
nlinarith [hα i,hβ i]
|
| 194 |
+
· positivity
|
| 195 |
+
· positivity
|
| 196 |
+
_ = _ := by simp [c,Fintype.card_prod]; ring
|
| 197 |
+
have hb0 : k/σ*(∑ i, |h i|) + q*γ/σ*‖v‖ + ε/σ^2*(c*G)*‖v‖ ≤
|
| 198 |
+
k/σ*H+q*γ/σ*(V*H)+ε/σ^2*(c*G)*(V*H) := by
|
| 199 |
+
exact add_le_add (add_le_add (mul_le_mul_of_nonneg_left hh (by positivity))
|
| 200 |
+
(mul_le_mul_of_nonneg_left hv (by positivity))) (mul_le_mul_of_nonneg_left hv (by positivity))
|
| 201 |
+
calc
|
| 202 |
+
_ ≤ |Profile.differential (fun j : S × N => g j.1 j.2) q ε σ θ η v 0 0 δ|+
|
| 203 |
+
|Profile.differential (fun j : S × N => g j.1 j.2) q ε σ θ η v α β δ -
|
| 204 |
+
Profile.differential (fun j : S × N => g j.1 j.2) q ε σ θ η v 0 0 δ| := by
|
| 205 |
+
simpa only [add_sub_cancel] using abs_add_le
|
| 206 |
+
(Profile.differential (fun j : S × N => g j.1 j.2) q ε σ θ η v 0 0 δ)
|
| 207 |
+
(Profile.differential (fun j : S × N => g j.1 j.2) q ε σ θ η v α β δ-
|
| 208 |
+
Profile.differential (fun j : S × N => g j.1 j.2) q ε σ θ η v 0 0 δ)
|
| 209 |
+
_ ≤ (k/σ*H+q*γ/σ*(V*H)+ε/σ^2*(c*G)*(V*H))+
|
| 210 |
+
ε/σ*(c*(D₀*H*A+G*(V*H)/σ*(A^2+2*A))) :=
|
| 211 |
+
add_le_add (hg0.trans hb0) (hcorr.trans (mul_le_mul_of_nonneg_left hc' (by positivity)))
|
| 212 |
+
_ = _ := by dsimp [c]; field_simp; ring
|
| 213 |
+
|
| 214 |
+
end UniformSparsestCut.MetricKernel
|
| 215 |
+
|
| 216 |
+
end
|
| 217 |
+
|
| 218 |
+
end OAI
|
lean/OAI/Combinatorics/SparsestCut/Model.lean
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import Mathlib
|
| 2 |
+
|
| 3 |
+
namespace OAI
|
| 4 |
+
|
| 5 |
+
open scoped BigOperators
|
| 6 |
+
|
| 7 |
+
namespace UniformSparsestCut
|
| 8 |
+
|
| 9 |
+
structure Capacity (n : ℕ) where
|
| 10 |
+
cap : Fin n → Fin n → ℝ
|
| 11 |
+
nonneg : ∀ i j, 0 ≤ cap i j
|
| 12 |
+
symm : ∀ i j, cap i j = cap j i
|
| 13 |
+
diagonal : ∀ i, cap i i = 0
|
| 14 |
+
|
| 15 |
+
def pairSum {n : ℕ} (f : Fin n → Fin n → ℝ) : ℝ :=
|
| 16 |
+
∑ i, ∑ j, if i < j then f i j else 0
|
| 17 |
+
|
| 18 |
+
noncomputable def cutRatio {n : ℕ} (C : Capacity n) (B : Finset (Fin n)) : ℝ :=
|
| 19 |
+
(∑ i ∈ B, ∑ j ∈ Bᶜ, C.cap i j) /
|
| 20 |
+
((B.card : ℝ) * ((n : ℝ) - (B.card : ℝ)))
|
| 21 |
+
|
| 22 |
+
noncomputable def OPT {n : ℕ} (C : Capacity n) : ℝ :=
|
| 23 |
+
sInf {r | ∃ B : Finset (Fin n), B.Nonempty ∧ B ≠ Finset.univ ∧ r = cutRatio C B}
|
| 24 |
+
|
| 25 |
+
def NegativeType {n : ℕ} (d : Fin n → Fin n → ℝ) : Prop :=
|
| 26 |
+
(∃ x : Fin n → EuclideanSpace ℝ (Fin n), ∀ i j, d i j = ‖x i - x j‖ ^ 2) ∧
|
| 27 |
+
∀ i j k, d i k ≤ d i j + d j k
|
| 28 |
+
|
| 29 |
+
def Feasible {n : ℕ} (d : Fin n → Fin n → ℝ) : Prop :=
|
| 30 |
+
NegativeType d ∧ pairSum d = 1
|
| 31 |
+
|
| 32 |
+
noncomputable def glValue {n : ℕ} (C : Capacity n) : ℝ :=
|
| 33 |
+
sInf {r | ∃ d : Fin n → Fin n → ℝ, Feasible d ∧
|
| 34 |
+
r = pairSum (fun i j => C.cap i j * d i j)}
|
| 35 |
+
|
| 36 |
+
end UniformSparsestCut
|
| 37 |
+
|
| 38 |
+
end OAI
|
lean/OAI/Combinatorics/SparsestCut/Mollifier.lean
ADDED
|
@@ -0,0 +1,156 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import OAI.Combinatorics.SparsestCut.Metric
|
| 2 |
+
|
| 3 |
+
namespace OAI
|
| 4 |
+
|
| 5 |
+
open scoped BigOperators Topology NNReal RealInnerProductSpace InnerProductSpace Matrix ContDiff ENNReal
|
| 6 |
+
open MeasureTheory ProbabilityTheory Set Filter Matrix
|
| 7 |
+
|
| 8 |
+
noncomputable section
|
| 9 |
+
|
| 10 |
+
namespace UniformSparsestCut.ProductMollifier
|
| 11 |
+
|
| 12 |
+
def bump : ContDiffBump (0:ℝ) := ⟨1/2,1,by norm_num,by norm_num⟩
|
| 13 |
+
def rho : ℝ → ℝ := bump.normed volume
|
| 14 |
+
lemma rho_nonneg (x : ℝ) : 0 ≤ rho x := bump.nonneg_normed x
|
| 15 |
+
lemma rho_integral : ∫ x, rho x = 1 := bump.integral_normed
|
| 16 |
+
lemma rho_integrable : Integrable rho := bump.integrable_normed
|
| 17 |
+
lemma rho_smooth : ContDiff ℝ (⊤:ℕ∞) rho := bump.contDiff_normed
|
| 18 |
+
lemma rho_compact : HasCompactSupport rho := bump.hasCompactSupport_normed
|
| 19 |
+
lemma rho_even (x : ℝ) : rho (-x) = rho x := bump.normed_neg x
|
| 20 |
+
lemma rho_support {x : ℝ} (hx : rho x ≠ 0) : |x| < 1 := by
|
| 21 |
+
have h : x ∈ Function.support rho := hx
|
| 22 |
+
rw [rho,bump.support_normed_eq] at h
|
| 23 |
+
simpa [bump,Metric.mem_ball,dist_eq_norm] using h
|
| 24 |
+
lemma rho_deriv_integrable : Integrable (deriv rho) :=
|
| 25 |
+
(rho_smooth.continuous_deriv (by simp)).integrable_of_hasCompactSupport rho_compact.deriv
|
| 26 |
+
|
| 27 |
+
def density (ell : ℝ) (x : ℝ) : ℝ := ell⁻¹*rho (x/ell)
|
| 28 |
+
lemma density_nonneg {ell : ℝ} (hell : 0 ≤ ell) (x : ℝ) : 0 ≤ density ell x := by
|
| 29 |
+
exact mul_nonneg (inv_nonneg.mpr hell) (rho_nonneg _)
|
| 30 |
+
lemma density_smooth (ell : ℝ) : ContDiff ℝ (⊤:ℕ∞) (density ell) := by
|
| 31 |
+
unfold density
|
| 32 |
+
exact contDiff_const.mul (rho_smooth.comp (contDiff_id.div_const ell))
|
| 33 |
+
lemma density_integral {ell : ℝ} (hell : 0 < ell) : ∫ x, density ell x = 1 := by
|
| 34 |
+
unfold density
|
| 35 |
+
rw [integral_const_mul,Measure.integral_comp_div,rho_integral,smul_eq_mul,abs_of_pos hell]
|
| 36 |
+
simp [hell.ne']
|
| 37 |
+
lemma density_support {ell x : ℝ} (hell : 0 < ell) (hx : density ell x ≠ 0) : |x| < ell := by
|
| 38 |
+
have hρ : rho (x/ell) ≠ 0 := by intro he; exact hx (by simp [density,he])
|
| 39 |
+
have h := rho_support hρ
|
| 40 |
+
rwa [abs_div,abs_of_pos hell,div_lt_one hell] at h
|
| 41 |
+
lemma density_compact {ell : ℝ} (hell : 0 < ell) : HasCompactSupport (density ell) := by
|
| 42 |
+
apply HasCompactSupport.intro (isCompact_Icc (a := -ell) (b := ell))
|
| 43 |
+
intro x hx
|
| 44 |
+
by_contra hn
|
| 45 |
+
exact hx (abs_le.mp (density_support hell hn).le)
|
| 46 |
+
lemma density_integrable {ell : ℝ} (hell : 0 < ell) : Integrable (density ell) :=
|
| 47 |
+
(density_smooth ell).continuous.integrable_of_hasCompactSupport (density_compact hell)
|
| 48 |
+
lemma density_hasDeriv {ell : ℝ} (x : ℝ) : HasDerivAt (density ell)
|
| 49 |
+
(ell⁻¹/ell*deriv rho (x/ell)) x := by
|
| 50 |
+
have hd := ((rho_smooth.differentiable (by simp) (x/ell)).hasDerivAt.comp x
|
| 51 |
+
((hasDerivAt_id x).div_const ell)).const_mul (ell⁻¹)
|
| 52 |
+
convert hd using 1 <;> try rfl
|
| 53 |
+
ring
|
| 54 |
+
lemma density_deriv_integral {ell : ℝ} (hell : 0 < ell) :
|
| 55 |
+
(∫ x, |deriv (density ell) x|) = ell⁻¹*(∫ x, |deriv rho x|) := by
|
| 56 |
+
simp_rw [(density_hasDeriv (ell := ell) _).deriv,abs_mul,abs_of_pos (div_pos (inv_pos.mpr hell) hell)]
|
| 57 |
+
rw [integral_const_mul]
|
| 58 |
+
rw [Measure.integral_comp_div (fun t => |deriv rho t|),smul_eq_mul,abs_of_pos hell]
|
| 59 |
+
field_simp
|
| 60 |
+
|
| 61 |
+
variable {m : ℕ}
|
| 62 |
+
local notation "E" => EuclideanSpace ℝ (Fin m)
|
| 63 |
+
def coordinate (i : Fin m) : E →L[ℝ] ℝ :=
|
| 64 |
+
(ContinuousLinearMap.proj i).comp (EuclideanSpace.equiv (Fin m) ℝ).toContinuousLinearMap
|
| 65 |
+
@[simp] lemma coordinate_apply (i : Fin m) (x : E) : coordinate i x = x i := rfl
|
| 66 |
+
|
| 67 |
+
def kernel (φ : ℝ → ℝ) (x : E) : ℝ := ∏ i, φ (x i)
|
| 68 |
+
lemma kernel_smooth (φ : ℝ → ℝ) {n : ℕ∞} (hc : ContDiff ℝ n φ) : ContDiff ℝ n (kernel (m := m) φ) := by
|
| 69 |
+
unfold kernel
|
| 70 |
+
apply contDiff_prod
|
| 71 |
+
intro i _
|
| 72 |
+
exact hc.comp (coordinate i).contDiff
|
| 73 |
+
lemma kernel_nonneg {φ : ℝ → ℝ} (hn : ∀ t, 0 ≤ φ t) (x : E) : 0 ≤ kernel φ x :=
|
| 74 |
+
Finset.prod_nonneg (fun _i _ => hn _)
|
| 75 |
+
lemma kernel_integral (φ : ℝ → ℝ) : (∫ x : E, kernel φ x) = (∫ t, φ t)^m := by
|
| 76 |
+
rw [← (PiLp.volume_preserving_toLp (Fin m)).integral_comp (MeasurableEquiv.measurableEmbedding (MeasurableEquiv.toLp 2 _))]
|
| 77 |
+
simpa only [kernel,Fintype.card_fin] using integral_fintype_prod_volume_eq_pow (ι := Fin m) φ
|
| 78 |
+
lemma kernel_integrable {φ : ℝ → ℝ} (hi : Integrable φ) : Integrable (kernel (m := m) φ) := by
|
| 79 |
+
rw [← (PiLp.volume_preserving_toLp (Fin m)).integrable_comp_emb (MeasurableEquiv.measurableEmbedding (MeasurableEquiv.toLp 2 _))]
|
| 80 |
+
exact Integrable.fintype_prod (fun _ : Fin m => hi)
|
| 81 |
+
|
| 82 |
+
lemma coordinate_norm_bound {R : ℝ} (hR : 0 ≤ R) (x : E) (hx : ∀ j, |x j| ≤ R) :
|
| 83 |
+
‖x‖ ≤ R*Real.sqrt m := by
|
| 84 |
+
have hs : ‖x‖^2 ≤ (m:ℝ)*R^2 := by
|
| 85 |
+
rw [EuclideanSpace.norm_sq_eq]
|
| 86 |
+
calc
|
| 87 |
+
_ ≤ ∑ _j : Fin m, R^2 := by
|
| 88 |
+
apply Finset.sum_le_sum; intro j _
|
| 89 |
+
rw [Real.norm_eq_abs]
|
| 90 |
+
exact pow_le_pow_left₀ (abs_nonneg _) (hx j) _
|
| 91 |
+
_ = _ := by simp
|
| 92 |
+
have hroot := Real.sq_sqrt (Nat.cast_nonneg m)
|
| 93 |
+
have hp : 0 ≤ R*Real.sqrt m := mul_nonneg hR (Real.sqrt_nonneg _)
|
| 94 |
+
have he : (R*Real.sqrt m)^2 = (m:ℝ)*R^2 := by rw [mul_pow,hroot]; ring
|
| 95 |
+
nlinarith [norm_nonneg x]
|
| 96 |
+
|
| 97 |
+
lemma kernel_support_bound {φ : ℝ → ℝ} {R : ℝ} (hR : 0 ≤ R)
|
| 98 |
+
(hφ : ∀ t, φ t ≠ 0 → |t| ≤ R) {x : E} (hx : kernel φ x ≠ 0) : ‖x‖ ≤ R*Real.sqrt m := by
|
| 99 |
+
apply coordinate_norm_bound hR x
|
| 100 |
+
intro j
|
| 101 |
+
apply hφ _
|
| 102 |
+
intro hj
|
| 103 |
+
exact hx (Finset.prod_eq_zero (Finset.mem_univ j) hj)
|
| 104 |
+
|
| 105 |
+
lemma kernel_compact {φ : ℝ → ℝ} {R : ℝ} (hR : 0 ≤ R)
|
| 106 |
+
(hφ : ∀ t, φ t ≠ 0 → |t| ≤ R) : HasCompactSupport (kernel (m := m) φ) := by
|
| 107 |
+
apply HasCompactSupport.intro (isCompact_closedBall (0:E) (R*Real.sqrt m))
|
| 108 |
+
intro x hx
|
| 109 |
+
by_contra hn
|
| 110 |
+
exact hx (by simpa using kernel_support_bound hR hφ hn)
|
| 111 |
+
|
| 112 |
+
lemma kernel_hasFDeriv {φ φ' : ℝ → ℝ} (hd : ∀ t, HasDerivAt φ (φ' t) t) (x : E) :
|
| 113 |
+
HasFDerivAt (kernel φ)
|
| 114 |
+
(∑ i, ((∏ j ∈ Finset.univ.erase i, φ (x j))*φ' (x i)) • coordinate i) x := by
|
| 115 |
+
have h (i : Fin m) : HasFDerivAt (fun x : E => φ (x i)) (φ' (x i) • coordinate i) x :=
|
| 116 |
+
(hd (x i)).comp_hasFDerivAt x (coordinate i).hasFDerivAt
|
| 117 |
+
convert! HasFDerivAt.finsetProd (u := Finset.univ) (fun i _ => h i) using 1
|
| 118 |
+
simp only [smul_smul]
|
| 119 |
+
|
| 120 |
+
lemma kernel_partial {φ φ' : ℝ → ℝ} (hd : ∀ t, HasDerivAt φ (φ' t) t) (x : E) (i : Fin m) :
|
| 121 |
+
fderiv ℝ (kernel φ) x (EuclideanSpace.single i 1) =
|
| 122 |
+
φ' (x i)*(∏ j ∈ Finset.univ.erase i, φ (x j)) := by
|
| 123 |
+
rw [(kernel_hasFDeriv hd x).fderiv]
|
| 124 |
+
simp [coordinate,mul_comm]
|
| 125 |
+
|
| 126 |
+
lemma kernel_partial_integral {φ φ' : ℝ → ℝ} (hd : ∀ t, HasDerivAt φ (φ' t) t)
|
| 127 |
+
(hn : ∀ t, 0 ≤ φ t) (h1 : ∫ t, φ t = 1) (i : Fin m) :
|
| 128 |
+
(∫ x : E, |fderiv ℝ (kernel φ) x (EuclideanSpace.single i 1)|) = ∫ t, |φ' t| := by
|
| 129 |
+
classical
|
| 130 |
+
simp_rw [kernel_partial hd,abs_mul,abs_of_nonneg (Finset.prod_nonneg (fun j _ => hn _))]
|
| 131 |
+
let f : Fin m → ℝ → ℝ := fun j t => if j=i then |φ' t| else φ t
|
| 132 |
+
have he (x : E) : |φ' (x i)| *(∏ j ∈ Finset.univ.erase i, φ (x j)) = ∏ j, f j (x j) := by
|
| 133 |
+
rw [← Finset.mul_prod_erase (s := Finset.univ) (fun j => f j (x j)) (Finset.mem_univ i)]
|
| 134 |
+
simp only [f,ite_eq_left rfl]
|
| 135 |
+
congr 1
|
| 136 |
+
apply Finset.prod_congr rfl
|
| 137 |
+
intro j hj
|
| 138 |
+
simp only [Finset.mem_erase,Finset.mem_univ,and_true] at hj
|
| 139 |
+
simp [hj]
|
| 140 |
+
simp_rw [he]
|
| 141 |
+
rw [← (PiLp.volume_preserving_toLp (Fin m)).integral_comp (MeasurableEquiv.measurableEmbedding (MeasurableEquiv.toLp 2 _))]
|
| 142 |
+
rw [integral_fintype_prod_volume_eq_prod]
|
| 143 |
+
rw [← Finset.mul_prod_erase (s := Finset.univ) (fun j => ∫ t, f j t) (Finset.mem_univ i)]
|
| 144 |
+
simp only [f,ite_eq_left rfl]
|
| 145 |
+
have ho : (∏ j ∈ Finset.univ.erase i, ∫ t, if j=i then |φ' t| else φ t) = 1 := by
|
| 146 |
+
apply Finset.prod_eq_one
|
| 147 |
+
intro j hj
|
| 148 |
+
simp only [Finset.mem_erase,Finset.mem_univ,and_true] at hj
|
| 149 |
+
simpa [hj] using h1
|
| 150 |
+
rw [ho,mul_one]
|
| 151 |
+
|
| 152 |
+
end UniformSparsestCut.ProductMollifier
|
| 153 |
+
|
| 154 |
+
end
|
| 155 |
+
|
| 156 |
+
end OAI
|
lean/OAI/Combinatorics/SparsestCut/Parameters.lean
ADDED
|
@@ -0,0 +1,211 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import OAI.Combinatorics.SparsestCut.ChartMetric
|
| 2 |
+
|
| 3 |
+
namespace OAI
|
| 4 |
+
|
| 5 |
+
open scoped BigOperators Topology NNReal RealInnerProductSpace InnerProductSpace Matrix ContDiff ENNReal
|
| 6 |
+
open MeasureTheory ProbabilityTheory Set Filter Matrix
|
| 7 |
+
|
| 8 |
+
noncomputable section
|
| 9 |
+
|
| 10 |
+
namespace UniformSparsestCut.SourceParameters
|
| 11 |
+
open Filter
|
| 12 |
+
noncomputable section
|
| 13 |
+
|
| 14 |
+
def p (x : ℝ) (n : ℕ) : ℝ := 1/x^n
|
| 15 |
+
lemma p_nonneg {x : ℝ} (hx : 0≤x) (n : ℕ) : 0≤p x n := by unfold p; positivity
|
| 16 |
+
lemma p_pos {x : ℝ} (hx : 0<x) (n : ℕ) : 0<p x n := by unfold p; positivity
|
| 17 |
+
lemma p_mul {x : ℝ} (hx : x≠0) (a b : ℕ) : p x a*p x b=p x (a+b) := by
|
| 18 |
+
simp only [p,pow_add]; field_simp
|
| 19 |
+
lemma p_le {x : ℝ} (hx : 1≤x) {a b : ℕ} (hab : a≤b) : p x b≤p x a := by
|
| 20 |
+
unfold p
|
| 21 |
+
exact one_div_le_one_div_of_le (by positivity) (pow_le_pow_right₀ hx hab)
|
| 22 |
+
lemma p_one_le {x : ℝ} (hx : 1≤x) (a : ℕ) : p x a≤1 := by
|
| 23 |
+
simpa [p] using p_le hx (Nat.zero_le a)
|
| 24 |
+
lemma p_succ {x : ℝ} (hx : x≠0) (a : ℕ) : x*p x (a+1)=p x a := by
|
| 25 |
+
unfold p; rw [pow_succ]; field_simp
|
| 26 |
+
lemma log_ratio {x : ℝ} (hx : 0<x) : Real.log (x^40/(p x 40))=80*Real.log x := by
|
| 27 |
+
rw [Real.log_div (pow_ne_zero _ hx.ne') (ne_of_gt (p_pos hx 40))]
|
| 28 |
+
simp [p,Real.log_pow]; ring
|
| 29 |
+
lemma k_eq {x : ℝ} (hx : 0<x) : p x 5=(Real.sqrt x)^2/x^6 := by
|
| 30 |
+
rw [Real.sq_sqrt hx.le]; unfold p; field_simp
|
| 31 |
+
lemma local_formula {m : ℕ} (hm : 0 < m) :
|
| 32 |
+
GramMetric.localCost (m^6) (m^3) (Real.sqrt m) (p m 5) (p m 200)
|
| 33 |
+
(p m 40) ((m:ℝ)^40) (p m 1997) (2/Real.sqrt m)=
|
| 34 |
+
1440*p m 5*Real.log m+1440*p m 1798*Real.log m+
|
| 35 |
+
16*Real.sqrt m*p m 156*(1+p m 1802)^2 := by
|
| 36 |
+
have hm0 : (0:ℝ) < m := by exact_mod_cast hm
|
| 37 |
+
have hq := ne_of_gt (Real.sqrt_pos.mpr hm0)
|
| 38 |
+
unfold GramMetric.localCost
|
| 39 |
+
rw [log_ratio hm0]
|
| 40 |
+
simp only [p,Nat.cast_pow]
|
| 41 |
+
field_simp
|
| 42 |
+
ring
|
| 43 |
+
lemma macro_formula {m : ℕ} (hm : 0 < m) :
|
| 44 |
+
GramMetric.macroCost (m^6) (m^3) (Real.sqrt m) (p m 5) (p m 200)
|
| 45 |
+
(p m 40) ((m:ℝ)^40) (p m 1997) (3*Real.sqrt m) 0=
|
| 46 |
+
2*Real.sqrt m*p m 40+36*Real.sqrt m*p m 39+
|
| 47 |
+
320*p m 191*Real.log m*(1+p m 1802)^2 := by
|
| 48 |
+
have hm0 : (0:ℝ) < m := by exact_mod_cast hm
|
| 49 |
+
unfold GramMetric.macroCost
|
| 50 |
+
rw [log_ratio hm0]
|
| 51 |
+
simp only [p,Nat.cast_pow,mul_zero,add_zero]
|
| 52 |
+
simp only [mul_pow,Real.sq_sqrt hm0.le]
|
| 53 |
+
field_simp
|
| 54 |
+
ring
|
| 55 |
+
end
|
| 56 |
+
end UniformSparsestCut.SourceParameters
|
| 57 |
+
|
| 58 |
+
namespace UniformSparsestCut.SourceParameters
|
| 59 |
+
open Filter
|
| 60 |
+
noncomputable section
|
| 61 |
+
lemma sqrt_le {x : ℝ} (hx : 1≤x) : Real.sqrt x≤x := by
|
| 62 |
+
have h := Real.sq_sqrt (by linarith : 0≤x)
|
| 63 |
+
have hx0 : 0≤x := by linarith
|
| 64 |
+
nlinarith [Real.sqrt_nonneg x]
|
| 65 |
+
lemma correction_le {x : ℝ} (hx : 1≤x) : (1+p x 1802)^2≤4 := by
|
| 66 |
+
have h0 := p_nonneg (by linarith : 0≤x) 1802
|
| 67 |
+
have h1 := p_one_le hx 1802
|
| 68 |
+
nlinarith
|
| 69 |
+
lemma local_bounds {m : ℕ} (hm1 : 1 ≤ m) (hl : 1≤Real.log m) :
|
| 70 |
+
p m 5≤GramMetric.localCost (m^6) (m^3) (Real.sqrt m) (p m 5) (p m 200)
|
| 71 |
+
(p m 40) ((m:ℝ)^40) (p m 1997) (2/Real.sqrt m) ∧
|
| 72 |
+
GramMetric.localCost (m^6) (m^3) (Real.sqrt m) (p m 5) (p m 200)
|
| 73 |
+
(p m 40) ((m:ℝ)^40) (p m 1997) (2/Real.sqrt m)≤3000*p m 5*Real.log m := by
|
| 74 |
+
have hm0 : 0 < m := by omega
|
| 75 |
+
have hx : (1:ℝ) ≤ m := by exact_mod_cast hm1
|
| 76 |
+
have hn : (0:ℝ) ≤ m := by positivity
|
| 77 |
+
rw [local_formula hm0]
|
| 78 |
+
have hp5 := p_nonneg hn 5
|
| 79 |
+
have hl0 : 0≤Real.log m := by linarith
|
| 80 |
+
have hextra1 : 1440*p m 1798*Real.log m≤1440*p m 5*Real.log m := by
|
| 81 |
+
gcongr
|
| 82 |
+
exact p_le hx (by norm_num)
|
| 83 |
+
have hextra2 : 16*Real.sqrt m*p m 156*(1+p m 1802)^2≤64*p m 5*Real.log m := by
|
| 84 |
+
calc
|
| 85 |
+
_ ≤ 16*(m:ℝ)*p m 156*4 := by
|
| 86 |
+
gcongr <;> first | exact sqrt_le hx | exact correction_le hx | (unfold p; positivity)
|
| 87 |
+
_ = 64*p m 155 := by
|
| 88 |
+
have hh := p_succ (by positivity : (m:ℝ)≠0) 155
|
| 89 |
+
nlinarith
|
| 90 |
+
_ ≤ 64*p m 5*Real.log m := by
|
| 91 |
+
have hh := p_le hx (show 5≤155 by norm_num)
|
| 92 |
+
nlinarith
|
| 93 |
+
constructor
|
| 94 |
+
· have hmain : p m 5≤1440*p m 5*Real.log m := by nlinarith
|
| 95 |
+
linarith [show 0≤1440*p m 1798*Real.log m by unfold p; positivity,
|
| 96 |
+
show 0≤16*Real.sqrt m*p m 156*(1+p m 1802)^2 by unfold p; positivity]
|
| 97 |
+
· nlinarith [mul_nonneg hp5 hl0]
|
| 98 |
+
lemma macro_bounds {m : ℕ} (hm1 : 1 ≤ m) :
|
| 99 |
+
0≤GramMetric.macroCost (m^6) (m^3) (Real.sqrt m) (p m 5) (p m 200)
|
| 100 |
+
(p m 40) ((m:ℝ)^40) (p m 1997) (3*Real.sqrt m) 0 ∧
|
| 101 |
+
GramMetric.macroCost (m^6) (m^3) (Real.sqrt m) (p m 5) (p m 200)
|
| 102 |
+
(p m 40) ((m:ℝ)^40) (p m 1997) (3*Real.sqrt m) 0≤1318*p m 38 := by
|
| 103 |
+
have hm0 : 0 < m := by omega
|
| 104 |
+
have hx : (1:ℝ) ≤ m := by exact_mod_cast hm1
|
| 105 |
+
have hn : (0:ℝ) ≤ m := by positivity
|
| 106 |
+
have hl0 := Real.log_nonneg hx
|
| 107 |
+
have hl1 : Real.log m≤(m:ℝ) := (Real.log_le_sub_one_of_pos (by positivity)).trans (by linarith)
|
| 108 |
+
rw [macro_formula hm0]
|
| 109 |
+
constructor
|
| 110 |
+
· unfold p; positivity
|
| 111 |
+
· have h1 : 2*Real.sqrt m*p m 40≤2*p m 38 := by
|
| 112 |
+
calc
|
| 113 |
+
_ ≤ 2*(m:ℝ)*p m 40 := by gcongr <;> first | exact sqrt_le hx | (unfold p; positivity)
|
| 114 |
+
_ = 2*p m 39 := by nlinarith [p_succ (by positivity : (m:ℝ)≠0) 39]
|
| 115 |
+
_ ≤ _ := by gcongr; exact p_le hx (by norm_num)
|
| 116 |
+
have h2 : 36*Real.sqrt m*p m 39≤36*p m 38 := by
|
| 117 |
+
calc
|
| 118 |
+
_ ≤ 36*(m:ℝ)*p m 39 := by gcongr <;> first | exact sqrt_le hx | (unfold p; positivity)
|
| 119 |
+
_ = _ := by nlinarith [p_succ (by positivity : (m:ℝ)≠0) 38]
|
| 120 |
+
have h3 : 320*p m 191*Real.log m*(1+p m 1802)^2≤1280*p m 38 := by
|
| 121 |
+
calc
|
| 122 |
+
_ ≤ 320*p m 191*(m:ℝ)*4 := by gcongr <;> first | exact correction_le hx | exact hl1 | (unfold p; positivity)
|
| 123 |
+
_ = 1280*p m 190 := by nlinarith [p_succ (by positivity : (m:ℝ)≠0) 190]
|
| 124 |
+
_ ≤ _ := by gcongr; exact p_le hx (by norm_num)
|
| 125 |
+
linarith
|
| 126 |
+
lemma macro_small {m : ℕ} (hm : 3000 ≤ m) :
|
| 127 |
+
GramMetric.macroCost (m^6) (m^3) (Real.sqrt m) (p m 5) (p m 200)
|
| 128 |
+
(p m 40) ((m:ℝ)^40) (p m 1997) (3*Real.sqrt m) 0≤p m 8/2 := by
|
| 129 |
+
have hx : (1:ℝ) ≤ m := by exact_mod_cast (show 1 ≤ m by omega)
|
| 130 |
+
have hp : (2636:ℝ)≤(m:ℝ)^30 := by
|
| 131 |
+
have hh := pow_le_pow_right₀ hx (show 1≤30 by norm_num)
|
| 132 |
+
simp only [pow_one] at hh
|
| 133 |
+
have hm' : (3000:ℝ) ≤ m := by exact_mod_cast hm
|
| 134 |
+
linarith
|
| 135 |
+
calc
|
| 136 |
+
_ ≤ 1318*p m 38 := (macro_bounds (show 1 ≤ m by omega)).2
|
| 137 |
+
_ ≤ p m 8/2 := by
|
| 138 |
+
have hm0 : (0:ℝ) < m := by positivity
|
| 139 |
+
unfold p
|
| 140 |
+
rw [show (m:ℝ)^38=(m:ℝ)^8*(m:ℝ)^30 by ring]
|
| 141 |
+
apply (le_div_iff₀ (by norm_num : (0:ℝ)<2)).mpr
|
| 142 |
+
field_simp
|
| 143 |
+
nlinarith
|
| 144 |
+
end
|
| 145 |
+
end UniformSparsestCut.SourceParameters
|
| 146 |
+
|
| 147 |
+
namespace UniformSparsestCut.SourceParameters
|
| 148 |
+
open scoped BigOperators
|
| 149 |
+
noncomputable section
|
| 150 |
+
lemma sqrt_m6 (m : ℕ) : Real.sqrt (m^6:ℕ)=(m:ℝ)^3 := by
|
| 151 |
+
rw [Nat.cast_pow,show (m:ℝ)^6=((m:ℝ)^3)^2 by ring,Real.sqrt_sq (by positivity)]
|
| 152 |
+
lemma rounded_radius {m : ℕ} (hm : 0 < m) : Real.sqrt (m^6:ℕ)*p m 2000=p m 1997 := by
|
| 153 |
+
rw [sqrt_m6]; unfold p; field_simp
|
| 154 |
+
lemma radius_le_sqrt {m : ℕ} (hm : 1 ≤ m) : p m 1997≤Real.sqrt m := by
|
| 155 |
+
have hx : (1:ℝ) ≤ m := by exact_mod_cast hm
|
| 156 |
+
exact (p_one_le hx _).trans (Real.one_le_sqrt.mpr hx)
|
| 157 |
+
lemma fourier_radius {m : ℕ} (hm : 6 ≤ m) : 2*(3*Real.sqrt m)/p m 40≤(m:ℝ)^42 := by
|
| 158 |
+
have hx : (6:ℝ) ≤ m := by exact_mod_cast hm
|
| 159 |
+
have hx1 : (1:ℝ) ≤ m := by linarith
|
| 160 |
+
calc
|
| 161 |
+
_ = 6*Real.sqrt m*(m:ℝ)^40 := by unfold p; field_simp ; ring
|
| 162 |
+
_ ≤ (m:ℝ)*(m:ℝ)*(m:ℝ)^40 := by gcongr; exact sqrt_le hx1
|
| 163 |
+
_ = _ := by ring
|
| 164 |
+
lemma local_tau {m : ℕ} (hm : 3000 ≤ m) (hl : 1≤Real.log m) :
|
| 165 |
+
let L := GramMetric.localCost (m^6) (m^3) (Real.sqrt m) (p m 5) (p m 200)
|
| 166 |
+
(p m 40) ((m:ℝ)^40) (p m 1997) (2/Real.sqrt m)
|
| 167 |
+
0<L*p m 2000 ∧ L*p m 2000≤p m 8 ∧
|
| 168 |
+
L*p m 2000*(9+8*Real.log (p m 8/(L*p m 2000)))≤
|
| 169 |
+
50000000*p m 2000*p m 5*(Real.log m)^2 := by
|
| 170 |
+
dsimp only
|
| 171 |
+
let L := GramMetric.localCost (m^6) (m^3) (Real.sqrt m) (p m 5) (p m 200)
|
| 172 |
+
(p m 40) ((m:ℝ)^40) (p m 1997) (2/Real.sqrt m)
|
| 173 |
+
change 0<L*p m 2000 ∧ L*p m 2000≤p m 8 ∧ _
|
| 174 |
+
have hx : (3000:ℝ) ≤ m := by exact_mod_cast hm
|
| 175 |
+
have hx1 : (1:ℝ) ≤ m := by linarith
|
| 176 |
+
have hx0 : (0:ℝ) < m := by linarith
|
| 177 |
+
have hτ := p_pos hx0 2000
|
| 178 |
+
have hp5 := p_pos hx0 5
|
| 179 |
+
have hp8 := p_pos hx0 8
|
| 180 |
+
have hL := local_bounds (show 1 ≤ m by omega) hl
|
| 181 |
+
change p m 5≤L ∧ L≤3000*p m 5*Real.log m at hL
|
| 182 |
+
have hδ : 0<L*p m 2000 := mul_pos (hp5.trans_le hL.1) hτ
|
| 183 |
+
have hδ0 : p m 5*p m 2000≤L*p m 2000 := mul_le_mul_of_nonneg_right hL.1 hτ.le
|
| 184 |
+
have hδ1 : L*p m 2000≤3000*p m 2000*p m 5*Real.log m := by nlinarith [mul_le_mul_of_nonneg_right hL.2 hτ.le]
|
| 185 |
+
have hlx : Real.log m≤(m:ℝ) := (Real.log_le_sub_one_of_pos hx0).trans (by linarith)
|
| 186 |
+
have hs : L*p m 2000≤p m 8 := by
|
| 187 |
+
calc
|
| 188 |
+
_ ≤ 3000*p m 2000*p m 5*(m:ℝ) := hδ1.trans (mul_le_mul_of_nonneg_left hlx (by unfold p; positivity))
|
| 189 |
+
_ = 3000*p m 2004 := by rw [mul_assoc (3000:ℝ),p_mul hx0.ne']; norm_num; nlinarith [p_succ hx0.ne' 2004]
|
| 190 |
+
_ ≤ 3000*p m 9 := mul_le_mul_of_nonneg_left (p_le hx1 (by norm_num)) (by norm_num)
|
| 191 |
+
_ ≤ (m:ℝ)*p m 9 := mul_le_mul_of_nonneg_right hx (p_nonneg hx0.le _)
|
| 192 |
+
_ = p m 8 := p_succ hx0.ne' 8
|
| 193 |
+
have he : p m 8/(p m 5*p m 2000)=(m:ℝ)^1997 := by unfold p; field_simp
|
| 194 |
+
have hlog : Real.log (p m 8/(L*p m 2000))≤1997*Real.log m := by
|
| 195 |
+
calc
|
| 196 |
+
_ ≤ Real.log (p m 8/(p m 5*p m 2000)) :=
|
| 197 |
+
Real.log_le_log (div_pos hp8 hδ) (div_le_div_of_nonneg_left hp8.le (mul_pos hp5 hτ) hδ0)
|
| 198 |
+
_ = _ := by rw [he,Real.log_pow]; norm_num
|
| 199 |
+
have hlog0 : 0≤Real.log (p m 8/(L*p m 2000)) := Real.log_nonneg ((one_le_div hδ).mpr hs)
|
| 200 |
+
refine ⟨hδ,hs,?_⟩
|
| 201 |
+
change L*p m 2000*(9+8*Real.log (p m 8/(L*p m 2000)))≤_
|
| 202 |
+
calc
|
| 203 |
+
_ ≤ (3000*p m 2000*p m 5*Real.log m)*(15985*Real.log m) := by
|
| 204 |
+
apply mul_le_mul hδ1 (by linarith) (by positivity) (by unfold p; positivity)
|
| 205 |
+
_ ≤ _ := by nlinarith [show 0≤p m 2000*p m 5*(Real.log m)^2 by unfold p; positivity]
|
| 206 |
+
end
|
| 207 |
+
end UniformSparsestCut.SourceParameters
|
| 208 |
+
|
| 209 |
+
end
|
| 210 |
+
|
| 211 |
+
end OAI
|
lean/OAI/Combinatorics/SparsestCut/PivotFamily.lean
ADDED
|
@@ -0,0 +1,211 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import OAI.Combinatorics.SparsestCut.DirectionFamily
|
| 2 |
+
|
| 3 |
+
namespace OAI
|
| 4 |
+
|
| 5 |
+
open scoped BigOperators Topology NNReal RealInnerProductSpace InnerProductSpace Matrix ContDiff ENNReal
|
| 6 |
+
open MeasureTheory ProbabilityTheory Set Filter Matrix
|
| 7 |
+
|
| 8 |
+
noncomputable section
|
| 9 |
+
|
| 10 |
+
namespace UniformSparsestCut.PivotFamily
|
| 11 |
+
open UniformSparsestCut.GaussianTools UniformSparsestCut.Directions
|
| 12 |
+
open UniformSparsestCut.DirectionFamily UniformSparsestCut.DirectionAsymptotics
|
| 13 |
+
open UniformSparsestCut.DirectionInterpolation
|
| 14 |
+
open scoped NNReal
|
| 15 |
+
|
| 16 |
+
lemma standard_density_le_one (x : ℝ) : gaussianPDFReal 0 1 x ≤ 1 := by
|
| 17 |
+
rw [gaussianPDFReal]
|
| 18 |
+
simp only [NNReal.coe_one,mul_one,sub_zero]
|
| 19 |
+
have hs : 1 ≤ Real.sqrt (2*Real.pi) := (Real.le_sqrt (by norm_num) (by positivity)).mpr (by nlinarith [Real.pi_gt_three])
|
| 20 |
+
have hex : Real.exp (-x^2/2) ≤ 1 := Real.exp_le_one_iff.mpr (by nlinarith [sq_nonneg x])
|
| 21 |
+
have hi : (√(2*Real.pi))⁻¹ ≤ 1 := inv_le_one_of_one_le₀ hs
|
| 22 |
+
simpa using mul_le_mul hi hex (Real.exp_nonneg _) (by norm_num : (0:ℝ) ≤ 1)
|
| 23 |
+
|
| 24 |
+
lemma standard_small_ball {a : ℝ} (ha : 0 ≤ a) :
|
| 25 |
+
(gaussianReal 0 1).real {x | |x| ≤ a} ≤ 2*a := by
|
| 26 |
+
have hs : {x : ℝ | |x| ≤ a} = Icc (-a) a := by ext (x : ℝ); exact (abs_le : |x| ≤ a ↔ -a ≤ x ∧ x ≤ a)
|
| 27 |
+
rw [hs,measureReal_def,gaussianReal_apply_eq_integral 0 (by norm_num)]
|
| 28 |
+
rw [ENNReal.toReal_ofReal (integral_nonneg (fun x => gaussianPDFReal_nonneg 0 1 x))]
|
| 29 |
+
calc
|
| 30 |
+
_ ≤ ∫ x in Icc (-a) a, (1:ℝ) := by
|
| 31 |
+
apply integral_mono (integrable_gaussianPDFReal 0 1).integrableOn (integrableOn_const (by rw [Real.volume_Icc]; exact ENNReal.ofReal_ne_top))
|
| 32 |
+
exact standard_density_le_one
|
| 33 |
+
_ = 2*a := by
|
| 34 |
+
rw [integral_const,measureReal_def,Measure.restrict_apply MeasurableSet.univ,Set.univ_inter,Real.volume_Icc,ENNReal.toReal_ofReal (by linarith : 0 ≤ a-(-a))]
|
| 35 |
+
simp only [smul_eq_mul,mul_one]; ring
|
| 36 |
+
|
| 37 |
+
lemma coordinate_small_ball {m : ℕ} (j : Fin m) {a : ℝ} (ha : 0 ≤ a) :
|
| 38 |
+
(stdGaussian (EuclideanSpace ℝ (Fin m))).real {x | |x j| ≤ a} ≤ 2*a := by
|
| 39 |
+
have hmap : (stdGaussian (EuclideanSpace ℝ (Fin m))).map (fun x => x j) = gaussianReal 0 1 := by
|
| 40 |
+
have h := gaussian_inner_law (EuclideanSpace.single j 1 : EuclideanSpace ℝ (Fin m))
|
| 41 |
+
have he : (⟨‖(EuclideanSpace.single j 1 : EuclideanSpace ℝ (Fin m))‖^2, sq_nonneg _⟩ : NNReal) = 1 := by
|
| 42 |
+
apply Subtype.ext
|
| 43 |
+
simp
|
| 44 |
+
rw [he] at h
|
| 45 |
+
simp only [EuclideanSpace.inner_single_left, map_one, one_mul] at h
|
| 46 |
+
exact h
|
| 47 |
+
have h := congrArg (fun μ : Measure ℝ => μ.real {x | |x| ≤ a}) hmap
|
| 48 |
+
simp only [measureReal_def] at h
|
| 49 |
+
rw [Measure.map_apply_of_aemeasurable (by fun_prop) (by measurability)] at h
|
| 50 |
+
exact h.le.trans (standard_small_ball ha)
|
| 51 |
+
|
| 52 |
+
lemma all_coordinate_small_ball {m N S : ℕ} {a : ℝ} (ha : 0 ≤ a) :
|
| 53 |
+
(Measure.pi (fun _ : Fin S => Measure.pi (fun _ : Fin N => stdGaussian (EuclideanSpace ℝ (Fin m))))).real
|
| 54 |
+
{g | ∃ s i j, |g s i j| ≤ a} ≤ (S:ℝ)*((N:ℝ)*((m:ℝ)*(2*a))) := by
|
| 55 |
+
have hcol : (stdGaussian (EuclideanSpace ℝ (Fin m))).real {x | ∃ j, |x j| ≤ a} ≤ (m:ℝ)*(2*a) := by
|
| 56 |
+
simpa only [Fintype.card_fin,Set.mem_ofPred_eq] using finite_union_bound (fun j : Fin m => {x : EuclideanSpace ℝ (Fin m) | |x j| ≤ a}) (fun j => coordinate_small_ball j ha)
|
| 57 |
+
have hchart := real_measure_exists_le (μ := stdGaussian (EuclideanSpace ℝ (Fin m)))
|
| 58 |
+
(fun _ : Fin N => {x : EuclideanSpace ℝ (Fin m) | ∃ j, |x j| ≤ a}) (fun _ => by measurability) (fun _ => hcol)
|
| 59 |
+
exact real_measure_exists_le
|
| 60 |
+
(fun _ : Fin S => {g : Fin N → EuclideanSpace ℝ (Fin m) | ∃ i j, |g i j| ≤ a})
|
| 61 |
+
(fun _ => by measurability) (fun _ => hchart)
|
| 62 |
+
|
| 63 |
+
section ExtraSelection
|
| 64 |
+
variable {m N S : ℕ}
|
| 65 |
+
local notation "E" => EuclideanSpace ℝ (Fin m)
|
| 66 |
+
local notation "μ" => stdGaussian E
|
| 67 |
+
local notation "ν" => Measure.pi (fun _ : Fin N => μ)
|
| 68 |
+
local notation "π" => Measure.pi (fun _ : Fin S => ν)
|
| 69 |
+
theorem select_on_nets_extra (hm : 0 < m) (hN : 0 < N) (hS : 0 < S)
|
| 70 |
+
(V W : Finset E) (hV : ∀ v ∈ V, ‖v‖ = 1)
|
| 71 |
+
{u q : ℝ} (hu : 0 ≤ u) (hq : 0 ≤ q)
|
| 72 |
+
(hqprob : (N : ℝ)*(2*Real.exp (-q^2/2)) ≤ 1/4)
|
| 73 |
+
{P : (Fin S → Fin N → E) → Prop} (hP : ∀ᵐ g ∂π, P g)
|
| 74 |
+
(Q : Set (Fin S → Fin N → E)) {p : ℝ} (hQ : (π).real Q ≤ p)
|
| 75 |
+
(hprob : (S : ℝ) * ((N : ℝ)*(2*Real.exp (-(m : ℝ)/8)) +
|
| 76 |
+
(V.card : ℝ)*(W.card : ℝ)*(2*Real.exp (-(N : ℝ)*u^2/(2*(2*Real.sqrt m)^2))) +
|
| 77 |
+
(V.card : ℝ)*(2*Real.exp (-(N : ℝ)*(1/8)^2/(2*(4*(m : ℝ))^2)))) +
|
| 78 |
+
(V.card : ℝ)*(2*Real.exp (-(S : ℝ)/32)) + p < 1) :
|
| 79 |
+
∃ g : Fin S → Fin N → E, P g ∧ g ∉ Q ∧
|
| 80 |
+
(∀ s, g s ∉ normBad) ∧
|
| 81 |
+
(∀ s, ∀ v ∈ V, ∀ w ∈ W, g s ∉ fourierBad u v w) ∧
|
| 82 |
+
(∀ s, ∀ v ∈ V, g s ∉ covarianceBad v) ∧
|
| 83 |
+
(∀ v ∈ V, (badCount (projectionBad q v) g : ℝ) ≤ (S : ℝ)/2) := by
|
| 84 |
+
classical
|
| 85 |
+
let A := chartBad (N := N) V W u
|
| 86 |
+
let B : Set (Fin S → Fin N → E) := {g | ∃ s, g s ∈ A}
|
| 87 |
+
let C : Set (Fin S → Fin N → E) :=
|
| 88 |
+
{g | ∃ v : V, (S : ℝ)/2 < (badCount (projectionBad q v) g : ℝ)}
|
| 89 |
+
have hBbound := real_measure_exists_le (fun _ : Fin S => A)
|
| 90 |
+
(fun _ => chartBad_measurable V W u) (fun _ => chartBad_bound hm hN V W hV hu)
|
| 91 |
+
have hCbound := goodBad_bound hS V hV hq hqprob
|
| 92 |
+
have hBC : (π).real ((B ∪ C) ∪ Q) < 1 :=
|
| 93 |
+
((measureReal_union_le (B ∪ C) Q).trans
|
| 94 |
+
(add_le_add ((measureReal_union_le B C).trans (add_le_add hBbound hCbound)) hQ)).trans_lt hprob
|
| 95 |
+
obtain ⟨g, hg0, hgP⟩ := exists_outside_with_ae hBC hP
|
| 96 |
+
have hg : g ∉ B ∪ C := fun h => hg0 (Or.inl h)
|
| 97 |
+
have hgQ : g ∉ Q := fun h => hg0 (Or.inr h)
|
| 98 |
+
have hgB : ∀ s, g s ∉ A := by
|
| 99 |
+
intro s hs; exact hg (Or.inl ⟨s, hs⟩)
|
| 100 |
+
refine ⟨g, hgP, hgQ, ?_, ?_, ?_, ?_⟩
|
| 101 |
+
· intro s hs; exact hgB s (Or.inl (Or.inl hs))
|
| 102 |
+
· intro s v hv w hw hs; exact hgB s (Or.inl (Or.inr ⟨(⟨v,hv⟩,⟨w,hw⟩), hs⟩))
|
| 103 |
+
· intro s v hv hs; exact hgB s (Or.inr ⟨⟨v,hv⟩, hs⟩)
|
| 104 |
+
· intro v hv; by_contra h
|
| 105 |
+
exact hg (Or.inr ⟨⟨v,hv⟩, lt_of_not_ge h⟩)
|
| 106 |
+
|
| 107 |
+
end ExtraSelection
|
| 108 |
+
|
| 109 |
+
variable {m : ℕ}
|
| 110 |
+
local notation "E" => EuclideanSpace ℝ (Fin m)
|
| 111 |
+
|
| 112 |
+
lemma select_source_nets_pivot (hm : 1000000 ≤ m) (hlog : 1 ≤ Real.log m)
|
| 113 |
+
(hmajor : 2*(m : ℝ)^9*Real.exp (-(m : ℝ)/8) +
|
| 114 |
+
6*(m : ℝ)^3*Real.exp (-(m : ℝ)) + 2/(m:ℝ)^20 < 1)
|
| 115 |
+
(V W : Finset E) (hV : ∀ v ∈ V, ‖v‖ = 1)
|
| 116 |
+
(hVc : (V.card : ℝ) ≤ Real.exp (6*(m : ℝ)^2))
|
| 117 |
+
(hWc : (W.card : ℝ) ≤ Real.exp (48*(m : ℝ)^2)) :
|
| 118 |
+
∃ g : Fin (m^3) → Fin (m^6) → E,
|
| 119 |
+
(∀ s a b, a ≠ b → ∀ t : ℝ, g s a ≠ t • g s b) ∧
|
| 120 |
+
(∀ s i j, 1/(m:ℝ)^30 < |g s i j|) ∧
|
| 121 |
+
(∀ s, g s ∉ normBad) ∧
|
| 122 |
+
(∀ s, ∀ v ∈ V, ∀ w ∈ W, g s ∉ fourierBad (1/(2*Real.sqrt m)) v w) ∧
|
| 123 |
+
(∀ s, ∀ v ∈ V, g s ∉ covarianceBad v) ∧
|
| 124 |
+
(∀ v ∈ V, (badCount (projectionBad (10*Real.sqrt (Real.log m)) v) g : ℝ) ≤
|
| 125 |
+
((m^3 : ℕ) : ℝ)/2) := by
|
| 126 |
+
have hm0 : 0 < m := by omega
|
| 127 |
+
have hsmall := all_coordinate_small_ball (m := m) (N := m^6) (S := m^3) (by positivity : (0:ℝ) ≤ 1/(m:ℝ)^30)
|
| 128 |
+
have hp : ((m^3:ℕ):ℝ)*(((m^6:ℕ):ℝ)*((m:ℝ)*(2*(1/(m:ℝ)^30)))) = 2/(m:ℝ)^20 := by
|
| 129 |
+
push_cast; field_simp
|
| 130 |
+
rw [hp] at hsmall
|
| 131 |
+
obtain ⟨g,hg,hQ,hrest⟩ := select_on_nets_extra (N := m^6) (S := m^3) hm0 (pow_pos hm0 _) (pow_pos hm0 _)
|
| 132 |
+
V W hV (by positivity : (0:ℝ) ≤ 1/(2*Real.sqrt m))
|
| 133 |
+
(by positivity : (0:ℝ) ≤ 10*Real.sqrt (Real.log m))
|
| 134 |
+
(by
|
| 135 |
+
simpa only [Nat.cast_pow] using (projection_failure_bound (show 2 ≤ m by omega)
|
| 136 |
+
(show 0 ≤ Real.log m by linarith)))
|
| 137 |
+
(GaussianNonparallel.charts_pairwise_nonparallel (show 2 ≤ m by omega))
|
| 138 |
+
{g | ∃ s i j, |g s i j| ≤ 1/(m:ℝ)^30} hsmall (by
|
| 139 |
+
simp only [Nat.cast_pow]
|
| 140 |
+
rw [normalized_fourier_exponent hm0, normalized_covariance_exponent m hm0]
|
| 141 |
+
exact (add_le_add_left (probability_majorization hm (Nat.cast_nonneg _) (Nat.cast_nonneg _) hVc hWc) _).trans_lt hmajor)
|
| 142 |
+
refine ⟨g,hg,?_,hrest⟩
|
| 143 |
+
intro s i j
|
| 144 |
+
exact lt_of_not_ge (fun h => hQ ⟨s,i,j,h⟩)
|
| 145 |
+
|
| 146 |
+
structure PFamily (m : ℕ) extends Family m where
|
| 147 |
+
pivot : ∀ s i j, 1/(m:ℝ)^30 < |g s i j|
|
| 148 |
+
|
| 149 |
+
lemma pivot_family_at_large (hm : 1000000 ≤ m) (hlog : 1 ≤ Real.log m)
|
| 150 |
+
(hbias : 16*Real.exp (-(m : ℝ)/12) ≤ 1/(8*(m : ℝ)))
|
| 151 |
+
(hmajor : 2*(m : ℝ)^9*Real.exp (-(m : ℝ)/8) +
|
| 152 |
+
6*(m : ℝ)^3*Real.exp (-(m : ℝ)) + 2/(m:ℝ)^20 < 1) : Nonempty (PFamily m) := by
|
| 153 |
+
classical
|
| 154 |
+
obtain ⟨V,W,hV,hVc,hWc,hVnet,hWnet⟩ := source_nets (show 2 ≤ m by omega)
|
| 155 |
+
obtain ⟨g,hpar,hpivot,hg,hfour,hcov,hgood⟩ := select_source_nets_pivot hm hlog hmajor V W hV hVc hWc
|
| 156 |
+
have hm0 : 0 < m := by omega
|
| 157 |
+
have hm0' : (0 : ℝ) < m := by exact_mod_cast hm0
|
| 158 |
+
have hn : 0 < m^6 := pow_pos hm0 _
|
| 159 |
+
have hu (s : Fin (m^3)) (i : Fin (m^6)) : ‖g s i‖^2 ≤ 4*(m : ℝ) :=
|
| 160 |
+
(normBounds_of_not_bad (hg s) i).2
|
| 161 |
+
refine ⟨{ g := g, norms := ?_, nonparallel := hpar, covariance := ?_, fourier := ?_, good := ?_, pivot := hpivot }⟩
|
| 162 |
+
· intro s i
|
| 163 |
+
have h := normBounds_of_not_bad (hg s) i
|
| 164 |
+
have hs := Real.sq_sqrt hm0'.le
|
| 165 |
+
constructor <;> nlinarith [Real.sqrt_nonneg (m : ℝ), norm_nonneg (g s i)]
|
| 166 |
+
· intro s v hv
|
| 167 |
+
have hh := covariance_net_bound hn (g s) (hu s) (by positivity) V hV hVnet
|
| 168 |
+
(fun v hv => net_covariance_scalar (hg s) v (hV v hv) (hcov s v hv)) v hv
|
| 169 |
+
have herr := covariance_net_error (show 1000 ≤ m by omega) hbias
|
| 170 |
+
have heq : 2*(4*(m : ℝ))*(1/(m : ℝ)^3) = 8*(m : ℝ)*(1/(m : ℝ)^3) := by ring
|
| 171 |
+
rw [heq] at hh
|
| 172 |
+
have hab := abs_le.mp (hh.trans herr)
|
| 173 |
+
constructor <;> linarith
|
| 174 |
+
· intro s w hw
|
| 175 |
+
have hρ : 1/(m : ℝ)^3 < 1 := by
|
| 176 |
+
apply (div_lt_one (by positivity)).mpr
|
| 177 |
+
have hx : (2 : ℝ) ≤ m := by exact_mod_cast (show 2 ≤ m by omega)
|
| 178 |
+
have hh := pow_le_pow_left₀ (by norm_num : (0 : ℝ) ≤ 2) hx 3
|
| 179 |
+
norm_num at hh; linarith
|
| 180 |
+
have hh := fourier_net_bound hn (g s) (hu s) (by positivity) (by positivity) hρ V W
|
| 181 |
+
hVnet hWnet (fun v hv w hw => net_fourier_scalar hm0 (hg s) v w (hV v hv) (hfour s v hv w hw)) w hw
|
| 182 |
+
have herr := scalar_net_error (show 1000 ≤ m by omega) hbias
|
| 183 |
+
have heq : 4*(m : ℝ)+(m : ℝ) = 5*(m : ℝ) := by ring
|
| 184 |
+
rw [heq] at hh
|
| 185 |
+
exact hh.trans herr
|
| 186 |
+
· intro v hv
|
| 187 |
+
obtain ⟨v',hv',hd⟩ := hVnet v hv
|
| 188 |
+
have hh := good_chart_interpolation g hg hd (projection_net_error (show 1000 ≤ m by omega) hlog)
|
| 189 |
+
exact (Nat.cast_le.mpr hh).trans (hgood v' hv')
|
| 190 |
+
|
| 191 |
+
lemma pivot_majorant_tendsto :
|
| 192 |
+
Tendsto (fun m : ℕ => 2*(m : ℝ)^9*Real.exp (-(m : ℝ)/8) +
|
| 193 |
+
6*(m : ℝ)^3*Real.exp (-(m : ℝ)) + 2/(m:ℝ)^20) atTop (𝓝 0) := by
|
| 194 |
+
have hi : Tendsto (fun m : ℕ => (m:ℝ)⁻¹) atTop (𝓝 0) :=
|
| 195 |
+
tendsto_inv_atTop_zero.comp tendsto_natCast_atTop_atTop
|
| 196 |
+
have hh := (hi.pow 20).const_mul 2
|
| 197 |
+
have h := selection_majorant_tendsto.add hh
|
| 198 |
+
simpa [div_eq_mul_inv,inv_pow] using h
|
| 199 |
+
|
| 200 |
+
theorem pivot_directions_exist : ∀ᶠ m : ℕ in atTop, Nonempty (PFamily m) := by
|
| 201 |
+
have hlog : ∀ᶠ m : ℕ in atTop, 1 ≤ Real.log m :=
|
| 202 |
+
(Real.tendsto_log_atTop.comp tendsto_natCast_atTop_atTop).eventually (eventually_ge_atTop 1)
|
| 203 |
+
have hmajor := pivot_majorant_tendsto.eventually (gt_mem_nhds (by norm_num : (0:ℝ) < 1))
|
| 204 |
+
filter_upwards [eventually_ge_atTop 1000000,hlog,eventual_bias_bound,hmajor] with m hm hl hb hp
|
| 205 |
+
exact pivot_family_at_large hm hl hb.2 hp
|
| 206 |
+
|
| 207 |
+
end UniformSparsestCut.PivotFamily
|
| 208 |
+
|
| 209 |
+
end
|
| 210 |
+
|
| 211 |
+
end OAI
|
lean/OAI/Combinatorics/SparsestCut/PositiveKernels.lean
ADDED
|
@@ -0,0 +1,164 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import OAI.Combinatorics.SparsestCut.RoundedCharts
|
| 2 |
+
|
| 3 |
+
namespace OAI
|
| 4 |
+
|
| 5 |
+
universe u1 u2 u3 u4
|
| 6 |
+
|
| 7 |
+
open scoped BigOperators Topology NNReal RealInnerProductSpace InnerProductSpace Matrix ContDiff ENNReal
|
| 8 |
+
open MeasureTheory ProbabilityTheory Set Filter Matrix
|
| 9 |
+
|
| 10 |
+
noncomputable section
|
| 11 |
+
|
| 12 |
+
namespace UniformSparsestCut
|
| 13 |
+
namespace TriangleRepair
|
| 14 |
+
|
| 15 |
+
variable {ι : Type u1} [Fintype ι]
|
| 16 |
+
|
| 17 |
+
lemma gram_posSemidef {H : Type u2} [NormedAddCommGroup H] [InnerProductSpace ℝ H]
|
| 18 |
+
(x : ι → H) : (Matrix.of (fun i j => ⟪x i, x j⟫_ℝ)).PosSemidef := by
|
| 19 |
+
apply Matrix.PosSemidef.of_dotProduct_mulVec_nonneg
|
| 20 |
+
· apply Matrix.IsHermitian.ext
|
| 21 |
+
intro i j
|
| 22 |
+
simp [real_inner_comm]
|
| 23 |
+
· intro c
|
| 24 |
+
have h := real_inner_self_nonneg (x := ∑ i, c i • x i)
|
| 25 |
+
simp only [sum_inner, inner_sum, real_inner_smul_left, real_inner_smul_right] at h
|
| 26 |
+
simp only [Matrix.mulVec, Matrix.of_apply, dotProduct, Finset.mul_sum, Pi.star_apply,
|
| 27 |
+
star_trivial]
|
| 28 |
+
convert h using 1
|
| 29 |
+
try rfl
|
| 30 |
+
apply Finset.sum_congr rfl
|
| 31 |
+
intro i hi
|
| 32 |
+
apply Finset.sum_congr rfl
|
| 33 |
+
intro j hj
|
| 34 |
+
rw [real_inner_comm (x j) (x i)]
|
| 35 |
+
ring
|
| 36 |
+
|
| 37 |
+
lemma ones_posSemidef : (Matrix.of (fun _ _ : ι => (1 : ℝ))).PosSemidef := by
|
| 38 |
+
convert Matrix.posSemidef_vecMulVec_self_star (fun _ : ι => (1 : ℝ)) using 1
|
| 39 |
+
ext i j
|
| 40 |
+
change (1 : ℝ) = 1 * 1
|
| 41 |
+
ring
|
| 42 |
+
|
| 43 |
+
lemma entrywise_pow_posSemidef {A : Matrix ι ι ℝ} (hA : A.PosSemidef) (k : ℕ) :
|
| 44 |
+
Matrix.PosSemidef (fun i j => (A i j) ^ k) := by
|
| 45 |
+
induction k with
|
| 46 |
+
| zero => convert (ones_posSemidef (ι := ι)) using 1; rfl
|
| 47 |
+
| succ k hk => convert hk.hadamard hA using 1; rfl
|
| 48 |
+
|
| 49 |
+
omit [Fintype ι] in
|
| 50 |
+
lemma sum_posSemidef {κ : Type u3} (s : Finset κ) (A : κ → Matrix ι ι ℝ)
|
| 51 |
+
(hA : ∀ k ∈ s, (A k).PosSemidef) : (∑ k ∈ s, A k).PosSemidef := by
|
| 52 |
+
classical
|
| 53 |
+
induction s using Finset.induction_on with
|
| 54 |
+
| empty => simpa using (Matrix.PosSemidef.zero : (0 : Matrix ι ι ℝ).PosSemidef)
|
| 55 |
+
| @insert a s ha hs =>
|
| 56 |
+
rw [Finset.sum_insert ha]
|
| 57 |
+
exact (hA a (Finset.mem_insert_self a s)).add
|
| 58 |
+
(hs (fun k hk => hA k (Finset.mem_insert_of_mem hk)))
|
| 59 |
+
|
| 60 |
+
lemma posSemidef_of_tendsto {A : ℕ → Matrix ι ι ℝ} {B : Matrix ι ι ℝ}
|
| 61 |
+
(ha : ∀ k, (A k).PosSemidef)
|
| 62 |
+
(hab : ∀ i j, Tendsto (fun k => A k i j) atTop (nhds (B i j))) : B.PosSemidef := by
|
| 63 |
+
apply Matrix.PosSemidef.of_dotProduct_mulVec_nonneg
|
| 64 |
+
· apply Matrix.IsHermitian.ext
|
| 65 |
+
intro i j
|
| 66 |
+
simp only [star_trivial]
|
| 67 |
+
apply tendsto_nhds_unique (hab j i)
|
| 68 |
+
have heq : (fun k => A k j i) = (fun k => A k i j) := by
|
| 69 |
+
funext k
|
| 70 |
+
simpa using (ha k).isHermitian.apply i j
|
| 71 |
+
simpa [heq] using hab i j
|
| 72 |
+
· intro c
|
| 73 |
+
have ht : Tendsto (fun k => star c ⬝ᵥ (A k *ᵥ c)) atTop
|
| 74 |
+
(nhds (star c ⬝ᵥ (B *ᵥ c))) := by
|
| 75 |
+
simp only [dotProduct, Matrix.mulVec]
|
| 76 |
+
exact tendsto_finsetSum _ fun i _ => tendsto_const_nhds.mul
|
| 77 |
+
(tendsto_finsetSum _ fun j _ => (hab i j).mul tendsto_const_nhds)
|
| 78 |
+
exact ge_of_tendsto' ht (fun k => (ha k).dotProduct_mulVec_nonneg c)
|
| 79 |
+
|
| 80 |
+
lemma entrywise_exp_posSemidef {A : Matrix ι ι ℝ} (hA : A.PosSemidef) :
|
| 81 |
+
Matrix.PosSemidef (fun i j => Real.exp (A i j)) := by
|
| 82 |
+
let P (k : ℕ) : Matrix ι ι ℝ := fun i j => A i j ^ k / (k.factorial : ℝ)
|
| 83 |
+
have hp (k : ℕ) : (P k).PosSemidef := by
|
| 84 |
+
have h := (entrywise_pow_posSemidef hA k).smul
|
| 85 |
+
(inv_nonneg.mpr (Nat.cast_nonneg (α := ℝ) k.factorial))
|
| 86 |
+
convert h using 1
|
| 87 |
+
ext i j
|
| 88 |
+
change A i j ^ k / (k.factorial : ℝ) = (k.factorial : ℝ)⁻¹ * A i j ^ k
|
| 89 |
+
exact div_eq_inv_mul _ _
|
| 90 |
+
apply posSemidef_of_tendsto (A := fun k => ∑ l ∈ Finset.range k, P l)
|
| 91 |
+
(fun k => sum_posSemidef _ _ (fun l _ => hp l))
|
| 92 |
+
intro i j
|
| 93 |
+
have h := (NormedSpace.expSeries_div_hasSum_exp (A i j)).tendsto_sum_nat
|
| 94 |
+
convert h using 1
|
| 95 |
+
· funext k
|
| 96 |
+
exact Matrix.sum_apply i j (Finset.range k) P
|
| 97 |
+
· rw [Real.exp_eq_exp_ℝ]
|
| 98 |
+
|
| 99 |
+
lemma gaussian_posSemidef {H : Type u4} [NormedAddCommGroup H] [InnerProductSpace ℝ H]
|
| 100 |
+
(x : ι → H) {l : ℝ} (hl : 0 < l) :
|
| 101 |
+
Matrix.PosSemidef (fun i j => Real.exp (-‖x i - x j‖ ^ 2 / l)) := by
|
| 102 |
+
let a : ι → ℝ := fun i => Real.exp (-‖x i‖ ^ 2 / l)
|
| 103 |
+
have hgram := (gram_posSemidef x).smul (show 0 ≤ 2 / l by positivity)
|
| 104 |
+
have hexp := entrywise_exp_posSemidef hgram
|
| 105 |
+
have hrank := Matrix.posSemidef_vecMulVec_self_star a
|
| 106 |
+
have heq : (fun i j => Real.exp (-‖x i - x j‖ ^ 2 / l) : Matrix ι ι ℝ) =
|
| 107 |
+
Matrix.vecMulVec a (star a) ⊙ (fun i j => Real.exp ((2 / l) * ⟪x i, x j⟫_ℝ)) := by
|
| 108 |
+
ext i j
|
| 109 |
+
change Real.exp (-‖x i - x j‖ ^ 2 / l) =
|
| 110 |
+
(a i * a j) * Real.exp ((2 / l) * ⟪x i, x j⟫_ℝ)
|
| 111 |
+
simp only [a, ← Real.exp_add]
|
| 112 |
+
congr 1
|
| 113 |
+
rw [norm_sub_sq_real]
|
| 114 |
+
ring
|
| 115 |
+
rw [heq]
|
| 116 |
+
convert hrank.hadamard hexp using 1
|
| 117 |
+
rfl
|
| 118 |
+
|
| 119 |
+
open MeasureTheory
|
| 120 |
+
|
| 121 |
+
lemma integral_posSemidef (K : ℝ → Matrix ι ι ℝ) {r : ℝ} (hr : 0 ≤ r)
|
| 122 |
+
(hK : ∀ l ∈ Set.Icc 0 r, (K l).PosSemidef)
|
| 123 |
+
(hi : ∀ i j, IntervalIntegrable (fun l => K l i j) volume 0 r) :
|
| 124 |
+
Matrix.PosSemidef (fun i j => ∫ l in (0 : ℝ)..r, K l i j) := by
|
| 125 |
+
apply Matrix.PosSemidef.of_dotProduct_mulVec_nonneg
|
| 126 |
+
· apply Matrix.IsHermitian.ext
|
| 127 |
+
intro i j
|
| 128 |
+
simp only [star_trivial]
|
| 129 |
+
apply intervalIntegral.integral_congr
|
| 130 |
+
intro l hl
|
| 131 |
+
simpa using (hK l (by simpa [Set.uIcc_of_le hr] using hl)).isHermitian.apply i j
|
| 132 |
+
· intro c
|
| 133 |
+
have h : 0 ≤ ∫ l in (0 : ℝ)..r, star c ⬝ᵥ (K l *ᵥ c) :=
|
| 134 |
+
intervalIntegral.integral_nonneg hr (fun l hl => (hK l hl).dotProduct_mulVec_nonneg c)
|
| 135 |
+
simp only [dotProduct, Matrix.mulVec, Pi.star_apply, star_trivial] at h ⊢
|
| 136 |
+
have hrow (i : ι) : IntervalIntegrable
|
| 137 |
+
(fun l => ∑ j, K l i j * c j) volume 0 r := by
|
| 138 |
+
convert IntervalIntegrable.sum Finset.univ (fun j _ => (hi i j).mul_const (c j)) using 1
|
| 139 |
+
try rfl
|
| 140 |
+
funext l
|
| 141 |
+
simp only [Finset.sum_apply]
|
| 142 |
+
rw [intervalIntegral.integral_finsetSum (fun i _ => (hrow i).const_mul (c i))] at h
|
| 143 |
+
simp_rw [intervalIntegral.integral_const_mul] at h
|
| 144 |
+
simp_rw [intervalIntegral.integral_finsetSum (fun j _ => (hi _ j).mul_const (c j)),
|
| 145 |
+
intervalIntegral.integral_mul_const] at h
|
| 146 |
+
exact h
|
| 147 |
+
|
| 148 |
+
open scoped MatrixOrder in
|
| 149 |
+
|
| 150 |
+
lemma exists_gram {A : Matrix ι ι ℝ} (hA : A.PosSemidef) :
|
| 151 |
+
∃ q : ι → EuclideanSpace ℝ ι, ∀ i j, ⟪q i, q j⟫_ℝ = A i j := by
|
| 152 |
+
classical
|
| 153 |
+
obtain ⟨B, hB⟩ := CStarAlgebra.nonneg_iff_eq_star_mul_self.mp hA.nonneg
|
| 154 |
+
refine ⟨fun i => WithLp.toLp 2 (fun k => B k i), ?_⟩
|
| 155 |
+
intro i j
|
| 156 |
+
rw [hB]
|
| 157 |
+
simp [PiLp.inner_apply, Matrix.mul_apply, Matrix.star_eq_conjTranspose, mul_comm]
|
| 158 |
+
|
| 159 |
+
end TriangleRepair
|
| 160 |
+
end UniformSparsestCut
|
| 161 |
+
|
| 162 |
+
end
|
| 163 |
+
|
| 164 |
+
end OAI
|
lean/OAI/Combinatorics/SparsestCut/ProductSlice.lean
ADDED
|
@@ -0,0 +1,135 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import OAI.Combinatorics.SparsestCut.SliceCoefficients
|
| 2 |
+
|
| 3 |
+
namespace OAI
|
| 4 |
+
|
| 5 |
+
universe u1 u2 u3
|
| 6 |
+
|
| 7 |
+
open scoped BigOperators Topology NNReal RealInnerProductSpace InnerProductSpace Matrix ContDiff ENNReal
|
| 8 |
+
open MeasureTheory ProbabilityTheory Set Filter Matrix
|
| 9 |
+
|
| 10 |
+
noncomputable section
|
| 11 |
+
|
| 12 |
+
namespace UniformSparsestCut.ProductSlice
|
| 13 |
+
open MeasureTheory Set
|
| 14 |
+
open scoped BigOperators
|
| 15 |
+
noncomputable section
|
| 16 |
+
variable {Z : Type u1} {I : Type u2} {K : Type u3} [NormedAddCommGroup Z] [NormedSpace ℝ Z]
|
| 17 |
+
[FiniteDimensional ℝ Z] [MeasureSpace Z] [BorelSpace Z] [(volume : Measure Z).IsAddHaarMeasure]
|
| 18 |
+
[Fintype I] [Fintype K] [DecidableEq I] [DecidableEq K]
|
| 19 |
+
|
| 20 |
+
def form (B : Z →L[ℝ] ℝ) : (ℝ × Z) →L[ℝ] ℝ :=
|
| 21 |
+
ContinuousLinearMap.fst ℝ ℝ Z-B.comp (ContinuousLinearMap.snd ℝ ℝ Z)
|
| 22 |
+
omit [FiniteDimensional ℝ Z] [MeasureSpace Z] [BorelSpace Z] [(volume : Measure Z).IsAddHaarMeasure] in
|
| 23 |
+
@[simp] lemma form_apply (B : Z →L[ℝ] ℝ) (x : ℝ × Z) : form B x=x.1-B x.2 := rfl
|
| 24 |
+
|
| 25 |
+
def cell (B : I → Z →L[ℝ] ℝ) (q : I → K → ℝ) (F : Finset (I × K) → ℝ) (x : ℝ × Z) : ℝ :=
|
| 26 |
+
F (Finset.univ.filter (fun p => form (B p.1) x+q p.1 p.2<0))
|
| 27 |
+
omit [(volume : Measure Z).IsAddHaarMeasure] in
|
| 28 |
+
lemma cell_measurable (B : I → Z →L[ℝ] ℝ) (q : I → K → ℝ) (F : Finset (I × K) → ℝ) :
|
| 29 |
+
Measurable (cell B q F) := by
|
| 30 |
+
unfold cell
|
| 31 |
+
apply InterfaceStep.measurable_filter_apply
|
| 32 |
+
intro p
|
| 33 |
+
exact measurableSet_lt ((form (B p.1)).measurable.add_const (q p.1 p.2)) measurable_const
|
| 34 |
+
|
| 35 |
+
omit [(volume : Measure Z).IsAddHaarMeasure] in
|
| 36 |
+
lemma cell_locallyIntegrable (B : I → Z →L[ℝ] ℝ) (q : I → K → ℝ)
|
| 37 |
+
(F : Finset (I × K) → ℝ) {M : ℝ} (hM : ∀ a, |F a|≤M)
|
| 38 |
+
(ν : Measure (ℝ × Z)) [IsLocallyFiniteMeasure ν] : LocallyIntegrable (cell B q F) ν := by
|
| 39 |
+
apply (continuous_const (y := M)).locallyIntegrable.mono (cell_measurable B q F).aestronglyMeasurable
|
| 40 |
+
filter_upwards with x
|
| 41 |
+
exact (show |cell B q F x|≤M from hM _).trans (le_abs_self M)
|
| 42 |
+
|
| 43 |
+
omit [FiniteDimensional ℝ Z] [MeasureSpace Z] [BorelSpace Z] [(volume : Measure Z).IsAddHaarMeasure] [DecidableEq I] [DecidableEq K] in
|
| 44 |
+
lemma cell_translate (B : I → Z →L[ℝ] ℝ) (q : I → K → ℝ)
|
| 45 |
+
(F : Finset (I × K) → ℝ) (θ : ℝ × Z) (x : ℝ) (z : Z) :
|
| 46 |
+
cell B q F (θ-(x,z)) =
|
| 47 |
+
F (Finset.univ.filter (fun p => form (B p.1) θ+B p.1 z+q p.1 p.2<x)) := by
|
| 48 |
+
unfold cell
|
| 49 |
+
congr 1
|
| 50 |
+
apply Finset.filter_congr
|
| 51 |
+
intro p _
|
| 52 |
+
change (θ.1-x-B p.1 (θ.2-z)+q p.1 p.2<0) ↔
|
| 53 |
+
(θ.1-B p.1 θ.2+B p.1 z+q p.1 p.2<x)
|
| 54 |
+
rw [map_sub]
|
| 55 |
+
constructor <;> intro hp <;> linarith
|
| 56 |
+
|
| 57 |
+
def law (ψ : Z → ℝ) (ν : Measure Z) : Measure Z := ν.withDensity (fun z => ENNReal.ofReal (ψ z))
|
| 58 |
+
omit [NormedAddCommGroup Z] [NormedSpace ℝ Z] [FiniteDimensional ℝ Z] [BorelSpace Z] [(volume : Measure Z).IsAddHaarMeasure] in
|
| 59 |
+
lemma law_ac (ψ : Z → ℝ) (ν : Measure Z) : law ψ ν ≪ ν := withDensity_absolutelyContinuous _ _
|
| 60 |
+
omit [NormedAddCommGroup Z] [NormedSpace ℝ Z] [FiniteDimensional ℝ Z] [BorelSpace Z] [(volume : Measure Z).IsAddHaarMeasure] in
|
| 61 |
+
lemma law_integral {ψ : Z → ℝ} (hm : Measurable ψ) (hn : ∀ z, 0≤ψ z)
|
| 62 |
+
(ν : Measure Z) (f : Z → ℝ) :
|
| 63 |
+
(∫ z, f z ∂law ψ ν) = ∫ z, ψ z*f z ∂ν := by
|
| 64 |
+
rw [law,integral_withDensity_eq_integral_toReal_smul (hm.ennreal_ofReal)
|
| 65 |
+
(ae_of_all _ (fun _ => ENNReal.ofReal_lt_top))]
|
| 66 |
+
simp only [ENNReal.toReal_ofReal (hn _),smul_eq_mul]
|
| 67 |
+
omit [NormedAddCommGroup Z] [NormedSpace ℝ Z] [FiniteDimensional ℝ Z] [BorelSpace Z] [(volume : Measure Z).IsAddHaarMeasure] in
|
| 68 |
+
lemma law_probability {ψ : Z → ℝ} (_hm : Measurable ψ) (hn : ∀ z, 0≤ψ z)
|
| 69 |
+
(ν : Measure Z) (hi : Integrable ψ ν) (h1 : ∫ z, ψ z ∂ν=1) :
|
| 70 |
+
IsProbabilityMeasure (law ψ ν) := by
|
| 71 |
+
refine ⟨?_⟩
|
| 72 |
+
change (ν.withDensity (fun z => ENNReal.ofReal (ψ z))) Set.univ = 1
|
| 73 |
+
rw [withDensity_apply _ MeasurableSet.univ,Measure.restrict_univ]
|
| 74 |
+
rw [← ofReal_integral_eq_lintegral_ofReal hi (ae_of_all _ hn),h1]
|
| 75 |
+
simp
|
| 76 |
+
|
| 77 |
+
lemma convolution_slice (B : I → Z →L[ℝ] ℝ) (q : I → K → ℝ)
|
| 78 |
+
(F : Finset (I × K) → ℝ) {M : ℝ} (_hM0 : 0 ≤ M) (hM : ∀ a, |F a| ≤ M)
|
| 79 |
+
{φ : ℝ → ℝ} {ψ : Z → ℝ} (hmφ : Measurable φ) (hmψ : Measurable ψ)
|
| 80 |
+
(hφ : Integrable φ) (hψ : Integrable ψ) (hnψ : ∀ z, 0≤ψ z) (θ : ℝ × Z) :
|
| 81 |
+
convolution (fun p : ℝ × Z => φ p.1*ψ p.2) (cell B q F)
|
| 82 |
+
(ContinuousLinearMap.mul ℝ ℝ) volume θ =
|
| 83 |
+
∫ z, (∫ x, φ x*F (Finset.univ.filter
|
| 84 |
+
(fun p => form (B p.1) θ+B p.1 z+q p.1 p.2<x))) ∂law ψ volume := by
|
| 85 |
+
have hi : Integrable (fun p : ℝ × Z => (φ p.1*ψ p.2)*cell B q F (θ-p)) := by
|
| 86 |
+
apply (((hφ.abs).mul_prod hψ.abs).mul_const M).mono'
|
| 87 |
+
(((hmφ.comp measurable_fst).mul (hmψ.comp measurable_snd)).mul
|
| 88 |
+
((cell_measurable B q F).comp (measurable_const.sub measurable_id))).aestronglyMeasurable
|
| 89 |
+
filter_upwards with p
|
| 90 |
+
change |φ p.1*ψ p.2*cell B q F (θ-p)| ≤ |φ p.1| * |ψ p.2| * M
|
| 91 |
+
simp only [abs_mul]
|
| 92 |
+
exact mul_le_mul_of_nonneg_left (hM _) (mul_nonneg (abs_nonneg _) (abs_nonneg _))
|
| 93 |
+
change (∫ p : ℝ × Z, (φ p.1*ψ p.2)*cell B q F (θ-p) ∂(volume : Measure ℝ).prod (volume : Measure Z)) = _
|
| 94 |
+
rw [integral_prod_symm _ hi,law_integral hmψ hnψ]
|
| 95 |
+
apply integral_congr_ae
|
| 96 |
+
filter_upwards with z
|
| 97 |
+
rw [← integral_const_mul]
|
| 98 |
+
apply integral_congr_ae
|
| 99 |
+
filter_upwards with x
|
| 100 |
+
rw [cell_translate]
|
| 101 |
+
ring
|
| 102 |
+
|
| 103 |
+
lemma convolution_derivative (B : I → Z →L[ℝ] ℝ) (hB : Function.Injective B)
|
| 104 |
+
(q : I → K → ℝ) (hq : ∀ i, Function.Injective (q i))
|
| 105 |
+
(F : Finset (I × K) → ℝ) {M C : ℝ} (hM0 : 0≤M) (hC : 0≤C)
|
| 106 |
+
(hM : ∀ a, |F a|≤M) {φ : ℝ → ℝ} {ψ : Z → ℝ}
|
| 107 |
+
(hφ : Integrable φ) (hcφ : Continuous φ) (hφC : ∀ t, |φ t|≤C)
|
| 108 |
+
(hmψ : Measurable ψ) (hnψ : ∀ z, 0≤ψ z) (hψ : Integrable ψ) (hψ1 : ∫ z, ψ z=1)
|
| 109 |
+
(θ : ℝ × Z) :
|
| 110 |
+
HasFDerivAt (convolution (fun p : ℝ × Z => φ p.1*ψ p.2) (cell B q F)
|
| 111 |
+
(ContinuousLinearMap.mul ℝ ℝ) volume)
|
| 112 |
+
(∑ i, (∑ k, ∫ z, -(φ (form (B i) θ+B i z+q i k)*
|
| 113 |
+
(F (Finset.univ.filter (fun p => form (B p.1) θ+B p.1 z+q p.1 p.2 ≤ form (B i) θ+B i z+q i k))-
|
| 114 |
+
F (Finset.univ.filter (fun p => form (B p.1) θ+B p.1 z+q p.1 p.2 < form (B i) θ+B i z+q i k))))
|
| 115 |
+
∂law ψ volume) • form (B i)) θ := by
|
| 116 |
+
let := law_probability hmψ hnψ volume hψ hψ1
|
| 117 |
+
have he : convolution (fun p : ℝ × Z => φ p.1*ψ p.2) (cell B q F)
|
| 118 |
+
(ContinuousLinearMap.mul ℝ ℝ) volume =
|
| 119 |
+
(fun θ => ∫ z, (∫ x, φ x*F (Finset.univ.filter
|
| 120 |
+
(fun p => form (B p.1) θ+B p.1 z+q p.1 p.2<x))) ∂law ψ volume) :=
|
| 121 |
+
funext (convolution_slice B q F hM0 hM hcφ.measurable hmψ hφ hψ hnψ)
|
| 122 |
+
rw [he]
|
| 123 |
+
have hi : ∀ᵐ z ∂law ψ volume, Function.Injective
|
| 124 |
+
(fun p : I × K => form (B p.1) θ+(B p.1 z+q p.1 p.2)) := by
|
| 125 |
+
simpa only [add_assoc] using SliceCoefficients.thresholds_injective_ae
|
| 126 |
+
(fun i => form (B i)) B q hq hB volume (law ψ volume) (law_ac ψ volume) θ
|
| 127 |
+
simpa only [add_assoc] using SliceCoefficients.family_derivative (fun i => form (B i))
|
| 128 |
+
(fun p z => B p.1 z+q p.1 p.2) (fun p => (B p.1).measurable.add_const _) F
|
| 129 |
+
hφ hcφ hM0 hC hM hφC (law ψ volume) θ hi
|
| 130 |
+
end
|
| 131 |
+
end UniformSparsestCut.ProductSlice
|
| 132 |
+
|
| 133 |
+
end
|
| 134 |
+
|
| 135 |
+
end OAI
|
lean/OAI/Combinatorics/SparsestCut/Profiles.lean
ADDED
|
@@ -0,0 +1,348 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import OAI.Combinatorics.SparsestCut.CommonKernel
|
| 2 |
+
|
| 3 |
+
namespace OAI
|
| 4 |
+
|
| 5 |
+
universe u1 u2 u3 u4 u5 u6 u7
|
| 6 |
+
|
| 7 |
+
open scoped BigOperators Topology NNReal RealInnerProductSpace InnerProductSpace Matrix ContDiff ENNReal
|
| 8 |
+
open MeasureTheory ProbabilityTheory Set Filter Matrix
|
| 9 |
+
|
| 10 |
+
noncomputable section
|
| 11 |
+
|
| 12 |
+
namespace UniformSparsestCut.Profile
|
| 13 |
+
variable {E : Type u1} [NormedAddCommGroup E] [InnerProductSpace ℝ E]
|
| 14 |
+
variable {ι : Type u2} [Fintype ι]
|
| 15 |
+
|
| 16 |
+
def pairing (g : ι → E) (q ε σ : ℝ) (θ η : E) (α β : ι → ℝ) : ℝ :=
|
| 17 |
+
q*Real.exp (-‖η-θ‖^2/(2*σ^2)) + ε/σ*(∑ i, (
|
| 18 |
+
(1+α i*β i)*Real.cos (inner ℝ (g i) (η-θ)/σ) +
|
| 19 |
+
(α i-β i)*Real.sin (inner ℝ (g i) (η-θ)/σ)))
|
| 20 |
+
|
| 21 |
+
def differential (g : ι → E) (q ε σ : ℝ) (θ η v : E)
|
| 22 |
+
(α β δ : ι → ℝ) : ℝ :=
|
| 23 |
+
q/σ*(inner ℝ ((σ⁻¹:ℝ) • (η-θ)) v)*Real.exp (-‖η-θ‖^2/(2*σ^2)) +
|
| 24 |
+
ε/σ*(∑ i, (δ i*(β i*Real.cos (inner ℝ (g i) (η-θ)/σ)+Real.sin (inner ℝ (g i) (η-θ)/σ)) +
|
| 25 |
+
(inner ℝ (g i) v/σ)*((1+α i*β i)*Real.sin (inner ℝ (g i) (η-θ)/σ)-
|
| 26 |
+
(α i-β i)*Real.cos (inner ℝ (g i) (η-θ)/σ))))
|
| 27 |
+
|
| 28 |
+
lemma pairing_hasDeriv (g : ι → E) (q ε σ : ℝ) (θ η v : E)
|
| 29 |
+
(α β δ : ι → ℝ) (t : ℝ) :
|
| 30 |
+
HasDerivAt (fun t => pairing g q ε σ (θ+t • v) η (fun i => α i+t*δ i) β)
|
| 31 |
+
(differential g q ε σ (θ+t • v) η v (fun i => α i+t*δ i) β δ) t := by
|
| 32 |
+
have hx : HasDerivAt (fun t : ℝ => η-(θ+t • v)) (-v) t :=
|
| 33 |
+
by simpa using (((hasDerivAt_id t).smul_const v).const_add θ).const_sub η
|
| 34 |
+
have hn := hx.norm_sq.neg.div_const (2*σ^2)
|
| 35 |
+
have he := hn.exp.const_mul q
|
| 36 |
+
have hi (i : ι) : HasDerivAt (fun t : ℝ => inner ℝ (g i) (η-(θ+t • v))/σ)
|
| 37 |
+
(-inner ℝ (g i) v/σ) t := by
|
| 38 |
+
convert ((innerSL ℝ (g i)).hasFDerivAt.comp_hasDerivAt t hx).div_const σ using 1 <;> try rfl
|
| 39 |
+
simp only [innerSL_apply_apply, inner_neg_right]
|
| 40 |
+
have hd (i : ι) : HasDerivAt (fun t : ℝ => α i+t*δ i) (δ i) t := by
|
| 41 |
+
simpa using ((hasDerivAt_id t).mul_const (δ i)).const_add (α i)
|
| 42 |
+
have hs (i : ι) := ((((hd i).mul_const (β i)).const_add 1).mul (hi i).cos).add
|
| 43 |
+
(((hd i).sub_const (β i)).mul (hi i).sin)
|
| 44 |
+
have hsum := (HasDerivAt.sum (u := Finset.univ) (fun i _ => hs i)).const_mul (ε/σ)
|
| 45 |
+
convert he.add hsum using 1 <;> try rfl
|
| 46 |
+
· funext z; simp [pairing, Finset.sum_apply]
|
| 47 |
+
· simp only [differential, real_inner_smul_left, inner_neg_right, Pi.neg_apply]
|
| 48 |
+
congr 1
|
| 49 |
+
· ring
|
| 50 |
+
· congr 1; apply Finset.sum_congr rfl; intro i _; ring
|
| 51 |
+
|
| 52 |
+
lemma differential_correction (g : ι → E) {q ε σ : ℝ} (hε : 0 ≤ ε) (hσ : 0 < σ)
|
| 53 |
+
(θ η v : E) (α β δ : ι → ℝ) :
|
| 54 |
+
|differential g q ε σ θ η v α β δ - differential g q ε σ θ η v 0 0 δ| ≤
|
| 55 |
+
ε/σ*(∑ i, (|δ i| * |β i| + |inner ℝ (g i) v|/σ*(|α i| * |β i| + |α i| + |β i|))) := by
|
| 56 |
+
have heq : differential g q ε σ θ η v α β δ - differential g q ε σ θ η v 0 0 δ =
|
| 57 |
+
ε/σ*(∑ i, (δ i*β i*Real.cos (inner ℝ (g i) (η-θ)/σ) +
|
| 58 |
+
(inner ℝ (g i) v/σ)*(α i*β i*Real.sin (inner ℝ (g i) (η-θ)/σ)-
|
| 59 |
+
α i*Real.cos (inner ℝ (g i) (η-θ)/σ)+β i*Real.cos (inner ℝ (g i) (η-θ)/σ)))) := by
|
| 60 |
+
unfold differential
|
| 61 |
+
simp only [Pi.zero_apply, mul_zero, zero_mul, add_zero, sub_zero]
|
| 62 |
+
rw [show ∀ a b c : ℝ, (a+b)-(a+c)=b-c by intros; ring]
|
| 63 |
+
rw [← mul_sub, ← Finset.sum_sub_distrib]
|
| 64 |
+
congr 1
|
| 65 |
+
apply Finset.sum_congr rfl
|
| 66 |
+
intro i _; ring
|
| 67 |
+
rw [heq, abs_mul, abs_of_nonneg (div_nonneg hε hσ.le)]
|
| 68 |
+
apply mul_le_mul_of_nonneg_left _ (div_nonneg hε hσ.le)
|
| 69 |
+
refine (Finset.abs_sum_le_sum_abs _ _).trans (Finset.sum_le_sum fun i _ => ?_)
|
| 70 |
+
let t := inner ℝ (g i) (η-θ)/σ
|
| 71 |
+
have hc : |Real.cos t| ≤ 1 := Real.abs_cos_le_one t
|
| 72 |
+
have hs : |Real.sin t| ≤ 1 := Real.abs_sin_le_one t
|
| 73 |
+
have hp : |α i*β i*Real.sin t-α i*Real.cos t+β i*Real.cos t| ≤
|
| 74 |
+
|α i| * |β i| + |α i| + |β i| := by
|
| 75 |
+
calc
|
| 76 |
+
_ ≤ |α i*β i*Real.sin t| + |α i*Real.cos t| + |β i*Real.cos t| :=
|
| 77 |
+
(abs_add_le _ _).trans (add_le_add (abs_sub _ _) le_rfl)
|
| 78 |
+
_ ≤ _ := by
|
| 79 |
+
simp only [abs_mul]
|
| 80 |
+
exact add_le_add (add_le_add
|
| 81 |
+
(mul_le_of_le_one_right (mul_nonneg (abs_nonneg _) (abs_nonneg _)) hs)
|
| 82 |
+
(mul_le_of_le_one_right (abs_nonneg _) hc))
|
| 83 |
+
(mul_le_of_le_one_right (abs_nonneg _) hc)
|
| 84 |
+
calc
|
| 85 |
+
_ ≤ |δ i*β i*Real.cos t| + |(inner ℝ (g i) v/σ)*
|
| 86 |
+
(α i*β i*Real.sin t-α i*Real.cos t+β i*Real.cos t)| := abs_add_le _ _
|
| 87 |
+
_ = |δ i| * |β i| * |Real.cos t| + |inner ℝ (g i) v|/σ*
|
| 88 |
+
|α i*β i*Real.sin t-α i*Real.cos t+β i*Real.cos t| := by
|
| 89 |
+
simp only [abs_mul, abs_div, abs_of_pos hσ]
|
| 90 |
+
_ ≤ _ := add_le_add
|
| 91 |
+
(mul_le_of_le_one_right (mul_nonneg (abs_nonneg _) (abs_nonneg _)) hc)
|
| 92 |
+
(mul_le_mul_of_nonneg_left hp (div_nonneg (abs_nonneg _) hσ.le))
|
| 93 |
+
|
| 94 |
+
lemma cancellation (g : ι → E) (q ε σ k : ℝ) (θ η v : E) (h : ι → ℝ)
|
| 95 |
+
(hq : q ≠ 0) (hσ : σ ≠ 0) (hk : k = q^2/(Fintype.card ι : ℝ))
|
| 96 |
+
(hε : ε ≠ 0) :
|
| 97 |
+
differential g q ε σ θ η v 0 0
|
| 98 |
+
(fun i => k/ε*(h i-inner ℝ (g i) v/q)) =
|
| 99 |
+
k/σ*(∑ i, h i*Real.sin (inner ℝ (g i) (η-θ)/σ)) +
|
| 100 |
+
q/σ*inner ℝ
|
| 101 |
+
(Real.exp (-‖(σ⁻¹:ℝ) • (η-θ)‖^2/2) • ((σ⁻¹:ℝ) • (η-θ)) -
|
| 102 |
+
((Fintype.card ι : ℝ)⁻¹) • ∑ i, Real.sin (inner ℝ (g i) (η-θ)/σ) • g i) v +
|
| 103 |
+
ε/σ^2*(∑ i, inner ℝ (g i) v*Real.sin (inner ℝ (g i) (η-θ)/σ)) := by
|
| 104 |
+
have hn : ‖(σ⁻¹:ℝ) • (η-θ)‖^2 = ‖η-θ‖^2/σ^2 := by
|
| 105 |
+
rw [norm_smul, mul_pow, Real.norm_eq_abs, sq_abs, inv_pow]; ring
|
| 106 |
+
simp only [differential, Pi.zero_apply, mul_zero, zero_mul, add_zero, sub_zero,
|
| 107 |
+
zero_add, one_mul, inner_sub_left, real_inner_smul_left, sum_inner, hn]
|
| 108 |
+
have he : - (‖η-θ‖^2/σ^2)/2 = -‖η-θ‖^2/(2*σ^2) := by ring
|
| 109 |
+
rw [he]
|
| 110 |
+
simp only [Finset.mul_sum]
|
| 111 |
+
have hterm (i : ι) : ε/σ * (k/ε*(h i-inner ℝ (g i) v/q)*Real.sin (inner ℝ (g i) (η-θ)/σ) +
|
| 112 |
+
(inner ℝ (g i) v/σ)*Real.sin (inner ℝ (g i) (η-θ)/σ)) =
|
| 113 |
+
k/σ*(h i*Real.sin (inner ℝ (g i) (η-θ)/σ)) -
|
| 114 |
+
q/σ*((Fintype.card ι : ℝ)⁻¹)*(Real.sin (inner ℝ (g i) (η-θ)/σ)*inner ℝ (g i) v) +
|
| 115 |
+
ε/σ^2*(inner ℝ (g i) v*Real.sin (inner ℝ (g i) (η-θ)/σ)) := by
|
| 116 |
+
rw [hk]
|
| 117 |
+
field_simp
|
| 118 |
+
|
| 119 |
+
simp_rw [hterm]
|
| 120 |
+
simp only [Finset.sum_add_distrib, Finset.sum_sub_distrib, ← Finset.mul_sum]
|
| 121 |
+
ring
|
| 122 |
+
|
| 123 |
+
end UniformSparsestCut.Profile
|
| 124 |
+
|
| 125 |
+
namespace UniformSparsestCut.Profile
|
| 126 |
+
variable {E : Type u3} [NormedAddCommGroup E] [InnerProductSpace ℝ E]
|
| 127 |
+
variable {S : Type u4} {N : Type u5} [Fintype S] [DecidableEq S] [Fintype N]
|
| 128 |
+
|
| 129 |
+
lemma active_cancellation (g : S → N → E) (s : S) (q ε σ k : ℝ)
|
| 130 |
+
(θ η v : E) (h : N → ℝ) (hq : q ≠ 0) (hσ : σ ≠ 0)
|
| 131 |
+
(hk : k = q^2/(Fintype.card N : ℝ)) (hε : ε ≠ 0) :
|
| 132 |
+
differential (fun j : S × N => g j.1 j.2) q ε σ θ η v 0 0
|
| 133 |
+
(fun j => if j.1 = s then k/ε*(h j.2-inner ℝ (g j.1 j.2) v/q) else 0) =
|
| 134 |
+
k/σ*(∑ i, h i*Real.sin (inner ℝ (g s i) (η-θ)/σ)) +
|
| 135 |
+
q/σ*inner ℝ
|
| 136 |
+
(Real.exp (-‖(σ⁻¹:ℝ) • (η-θ)‖^2/2) • ((σ⁻¹:ℝ) • (η-θ)) -
|
| 137 |
+
((Fintype.card N : ℝ)⁻¹) • ∑ i, Real.sin (inner ℝ (g s i) (η-θ)/σ) • g s i) v +
|
| 138 |
+
ε/σ^2*(∑ j : S × N, inner ℝ (g j.1 j.2) v*Real.sin (inner ℝ (g j.1 j.2) (η-θ)/σ)) := by
|
| 139 |
+
have hn : ‖(σ⁻¹:ℝ) • (η-θ)‖^2 = ‖η-θ‖^2/σ^2 := by
|
| 140 |
+
rw [norm_smul, mul_pow, Real.norm_eq_abs, sq_abs, inv_pow]; ring
|
| 141 |
+
have he : -(‖η-θ‖^2/σ^2)/2 = -‖η-θ‖^2/(2*σ^2) := by ring
|
| 142 |
+
simp only [differential, Pi.zero_apply, mul_zero, zero_mul, add_zero,
|
| 143 |
+
sub_zero, zero_add, one_mul, Finset.sum_add_distrib]
|
| 144 |
+
have hd : (∑ j : S × N, (if j.1 = s then k/ε*(h j.2-inner ℝ (g j.1 j.2) v/q) else 0) *
|
| 145 |
+
Real.sin (inner ℝ (g j.1 j.2) (η-θ)/σ)) =
|
| 146 |
+
k/ε*∑ i, (h i-inner ℝ (g s i) v/q)*Real.sin (inner ℝ (g s i) (η-θ)/σ) := by
|
| 147 |
+
simp only [Fintype.sum_prod_type, ite_mul, zero_mul]
|
| 148 |
+
simp only [Finset.sum_ite_irrel, Finset.sum_const_zero, Finset.sum_ite_eq', Finset.mem_univ, ite_true]
|
| 149 |
+
rw [Finset.mul_sum]; apply Finset.sum_congr rfl; intros; ring
|
| 150 |
+
rw [hd]
|
| 151 |
+
simp only [inner_sub_left, real_inner_smul_left, sum_inner, hn, he]
|
| 152 |
+
simp only [sub_mul, Finset.sum_sub_distrib, div_mul_eq_mul_div,
|
| 153 |
+
← Finset.sum_div]
|
| 154 |
+
have hs : (∑ i, Real.sin (inner ℝ (g s i) (η-θ)/σ)*inner ℝ (g s i) v) =
|
| 155 |
+
∑ i, inner ℝ (g s i) v*Real.sin (inner ℝ (g s i) (η-θ)/σ) := by
|
| 156 |
+
apply Finset.sum_congr rfl; intros; ring
|
| 157 |
+
rw [hs, hk]
|
| 158 |
+
field_simp
|
| 159 |
+
ring
|
| 160 |
+
|
| 161 |
+
lemma active_bound (g : S → N → E) (s : S) {q ε σ k γ G : ℝ}
|
| 162 |
+
(θ η v : E) (h : N → ℝ) (hq : 0 < q) (hε : 0 < ε) (hσ : 0 < σ)
|
| 163 |
+
(hk : k = q^2/(Fintype.card N : ℝ)) (hg : ∀ s i, ‖g s i‖ ≤ G)
|
| 164 |
+
(hf : ‖Real.exp (-‖(σ⁻¹:ℝ) • (η-θ)‖^2/2) • ((σ⁻¹:ℝ) • (η-θ)) -
|
| 165 |
+
((Fintype.card N : ℝ)⁻¹) • ∑ i, Real.sin (inner ℝ (g s i) (η-θ)/σ) • g s i‖ ≤ γ) :
|
| 166 |
+
|differential (fun j : S × N => g j.1 j.2) q ε σ θ η v 0 0
|
| 167 |
+
(fun j => if j.1 = s then k/ε*(h j.2-inner ℝ (g j.1 j.2) v/q) else 0)| ≤
|
| 168 |
+
k/σ*(∑ i, |h i|) + q*γ/σ*‖v‖ +
|
| 169 |
+
ε/σ^2*((Fintype.card S : ℝ)*(Fintype.card N : ℝ)*G)*‖v‖ := by
|
| 170 |
+
have hk0 : 0 ≤ k := by rw [hk]; positivity
|
| 171 |
+
rw [active_cancellation g s q ε σ k θ η v h hq.ne' hσ.ne' hk hε.ne']
|
| 172 |
+
have hsum : |∑ i, h i*Real.sin (inner ℝ (g s i) (η-θ)/σ)| ≤ ∑ i, |h i| := by
|
| 173 |
+
refine (Finset.abs_sum_le_sum_abs _ _).trans (Finset.sum_le_sum fun i _ => ?_)
|
| 174 |
+
rw [abs_mul]; exact mul_le_of_le_one_right (abs_nonneg _) (Real.abs_sin_le_one _)
|
| 175 |
+
have hfour := (abs_real_inner_le_norm _ v).trans (mul_le_mul_of_nonneg_right hf (norm_nonneg v))
|
| 176 |
+
have hglobal : |∑ j : S × N, inner ℝ (g j.1 j.2) v*Real.sin (inner ℝ (g j.1 j.2) (η-θ)/σ)| ≤
|
| 177 |
+
(Fintype.card S : ℝ)*(Fintype.card N : ℝ)*G*‖v‖ := by
|
| 178 |
+
calc
|
| 179 |
+
_ ≤ ∑ j : S × N, |inner ℝ (g j.1 j.2) v*Real.sin (inner ℝ (g j.1 j.2) (η-θ)/σ)| :=
|
| 180 |
+
Finset.abs_sum_le_sum_abs _ _
|
| 181 |
+
_ ≤ ∑ _j : S × N, G*‖v‖ := by
|
| 182 |
+
apply Finset.sum_le_sum; intro j _
|
| 183 |
+
rw [abs_mul]
|
| 184 |
+
exact (mul_le_of_le_one_right (abs_nonneg _) (Real.abs_sin_le_one _)).trans
|
| 185 |
+
((abs_real_inner_le_norm _ _).trans (mul_le_mul_of_nonneg_right (hg j.1 j.2) (norm_nonneg v)))
|
| 186 |
+
_ = _ := by simp [Fintype.card_prod]; ring
|
| 187 |
+
calc
|
| 188 |
+
_ ≤ |k/σ*(∑ i, h i*Real.sin (inner ℝ (g s i) (η-θ)/σ))| +
|
| 189 |
+
|q/σ*inner ℝ (Real.exp (-‖(σ⁻¹:ℝ) • (η-θ)‖^2/2) • ((σ⁻¹:ℝ) • (η-θ)) -
|
| 190 |
+
((Fintype.card N : ℝ)⁻¹) • ∑ i, Real.sin (inner ℝ (g s i) (η-θ)/σ) • g s i) v| +
|
| 191 |
+
|ε/σ^2*(∑ j : S × N, inner ℝ (g j.1 j.2) v*Real.sin (inner ℝ (g j.1 j.2) (η-θ)/σ))| :=
|
| 192 |
+
(abs_add_le _ _).trans (add_le_add (abs_add_le _ _) le_rfl)
|
| 193 |
+
_ ≤ k/σ*(∑ i, |h i|) + q/σ*(γ*‖v‖) +
|
| 194 |
+
ε/σ^2*((Fintype.card S : ℝ)*(Fintype.card N : ℝ)*G*‖v‖) := by
|
| 195 |
+
simp only [abs_mul, abs_of_nonneg (div_nonneg hk0 hσ.le),
|
| 196 |
+
abs_of_pos (div_pos hq hσ), abs_of_pos (div_pos hε (sq_pos_of_pos hσ))]
|
| 197 |
+
exact add_le_add (add_le_add (mul_le_mul_of_nonneg_left hsum (div_nonneg hk0 hσ.le))
|
| 198 |
+
(mul_le_mul_of_nonneg_left hfour (div_nonneg hq.le hσ.le)))
|
| 199 |
+
(mul_le_mul_of_nonneg_left hglobal (div_nonneg hε.le (sq_nonneg σ)))
|
| 200 |
+
_ = _ := by ring
|
| 201 |
+
|
| 202 |
+
end UniformSparsestCut.Profile
|
| 203 |
+
|
| 204 |
+
namespace UniformSparsestCut.Profile
|
| 205 |
+
variable {E : Type u6} [NormedAddCommGroup E] [InnerProductSpace ℝ E]
|
| 206 |
+
variable {ι : Type u7} [Fintype ι]
|
| 207 |
+
|
| 208 |
+
def kernel (g : ι → E) (q ε a b : ℝ) (θ η : E) (α β : ι → ℝ) : ℝ :=
|
| 209 |
+
∫ σ in a..b, pairing g q ε σ θ η α β
|
| 210 |
+
|
| 211 |
+
lemma pairing_continuousOn (g : ι → E) (q ε : ℝ) (θ η : E) (α β : ι → ℝ)
|
| 212 |
+
{a b : ℝ} (ha : 0 < a) : ContinuousOn (fun σ => pairing g q ε σ θ η α β) (Icc a b) := by
|
| 213 |
+
have hn : ∀ σ ∈ Icc a b, σ ≠ 0 := fun σ h => (ha.trans_le h.1).ne'
|
| 214 |
+
have hnp : ∀ σ ∈ Icc a b, 2*σ^2 ≠ 0 := fun σ h => mul_ne_zero (by norm_num) (pow_ne_zero _ (hn σ h))
|
| 215 |
+
unfold pairing
|
| 216 |
+
refine (continuousOn_const.mul (Real.continuous_exp.comp_continuousOn
|
| 217 |
+
(continuousOn_const.div (by fun_prop) hnp))).add ?_
|
| 218 |
+
apply (continuousOn_const.div continuousOn_id hn).mul
|
| 219 |
+
apply continuousOn_finsetSum
|
| 220 |
+
intro i _
|
| 221 |
+
have hc := continuousOn_const.div continuousOn_id hn (f := fun _ : ℝ => inner ℝ (g i) (η-θ))
|
| 222 |
+
exact (continuousOn_const.mul (Real.continuous_cos.comp_continuousOn hc)).add
|
| 223 |
+
(continuousOn_const.mul (Real.continuous_sin.comp_continuousOn hc))
|
| 224 |
+
|
| 225 |
+
lemma pairing_integrable (g : ι → E) (q ε : ℝ) (θ η : E) (α β : ι → ℝ)
|
| 226 |
+
{a b : ℝ} (ha : 0 < a) (hab : a ≤ b) :
|
| 227 |
+
IntervalIntegrable (fun σ => pairing g q ε σ θ η α β) volume a b := by
|
| 228 |
+
apply ContinuousOn.intervalIntegrable
|
| 229 |
+
rw [uIcc_of_le hab]
|
| 230 |
+
exact pairing_continuousOn g q ε θ η α β ha
|
| 231 |
+
|
| 232 |
+
lemma pairing_correction (g : ι → E) {q ε σ : ℝ} (hε : 0 ≤ ε) (hσ : 0 < σ)
|
| 233 |
+
(θ η : E) (α β : ι → ℝ) :
|
| 234 |
+
|pairing g q ε σ θ η α β - pairing g q ε σ θ η 0 0| ≤
|
| 235 |
+
ε/σ*∑ i, (|α i| * |β i|+|α i|+|β i|) := by
|
| 236 |
+
have he : pairing g q ε σ θ η α β - pairing g q ε σ θ η 0 0 =
|
| 237 |
+
ε/σ*∑ i, (α i*β i*Real.cos (inner ℝ (g i) (η-θ)/σ) +
|
| 238 |
+
α i*Real.sin (inner ℝ (g i) (η-θ)/σ)-β i*Real.sin (inner ℝ (g i) (η-θ)/σ)) := by
|
| 239 |
+
unfold pairing
|
| 240 |
+
simp only [Pi.zero_apply, mul_zero, add_zero, zero_mul, sub_zero, one_mul]
|
| 241 |
+
rw [show ∀ c d e : ℝ, (c+d)-(c+e)=d-e by intros; ring, ← mul_sub, ← Finset.sum_sub_distrib]
|
| 242 |
+
congr 1; apply Finset.sum_congr rfl; intro i _; ring
|
| 243 |
+
rw [he, abs_mul, abs_of_nonneg (div_nonneg hε hσ.le)]
|
| 244 |
+
apply mul_le_mul_of_nonneg_left _ (div_nonneg hε hσ.le)
|
| 245 |
+
refine (Finset.abs_sum_le_sum_abs _ _).trans (Finset.sum_le_sum fun i _ => ?_)
|
| 246 |
+
calc
|
| 247 |
+
_ ≤ |α i*β i*Real.cos (inner ℝ (g i) (η-θ)/σ)| +
|
| 248 |
+
|α i*Real.sin (inner ℝ (g i) (η-θ)/σ)|+|β i*Real.sin (inner ℝ (g i) (η-θ)/σ)| :=
|
| 249 |
+
(abs_sub _ _).trans (add_le_add (abs_add_le _ _) le_rfl)
|
| 250 |
+
_ ≤ _ := by
|
| 251 |
+
simp only [abs_mul]
|
| 252 |
+
exact add_le_add (add_le_add
|
| 253 |
+
(mul_le_of_le_one_right (mul_nonneg (abs_nonneg _) (abs_nonneg _)) (Real.abs_cos_le_one _))
|
| 254 |
+
(mul_le_of_le_one_right (abs_nonneg _) (Real.abs_sin_le_one _)))
|
| 255 |
+
(mul_le_of_le_one_right (abs_nonneg _) (Real.abs_sin_le_one _))
|
| 256 |
+
|
| 257 |
+
lemma kernel_correction (g : ι → E) {q ε a b A : ℝ}
|
| 258 |
+
(hε : 0 ≤ ε) (ha : 0 < a) (hab : a ≤ b) (hA : 0 ≤ A)
|
| 259 |
+
(θ η : E) (α β : ι → ℝ) (hα : ∀ i, |α i| ≤ A) (hβ : ∀ i, |β i| ≤ A) :
|
| 260 |
+
|kernel g q ε a b θ η α β - kernel g q ε a b θ η 0 0| ≤
|
| 261 |
+
ε*(Fintype.card ι : ℝ)*(A^2+2*A)*Real.log (b/a) := by
|
| 262 |
+
have hip := pairing_integrable g q ε θ η α β ha hab
|
| 263 |
+
have hiz := pairing_integrable g q ε θ η 0 0 ha hab
|
| 264 |
+
have hiinv : IntervalIntegrable (fun σ : ℝ => σ⁻¹) volume a b := by
|
| 265 |
+
apply ContinuousOn.intervalIntegrable
|
| 266 |
+
rw [uIcc_of_le hab]
|
| 267 |
+
exact continuousOn_id.inv₀ (fun σ h => (ha.trans_le h.1).ne')
|
| 268 |
+
have hi := hiinv.const_mul (ε*(Fintype.card ι : ℝ)*(A^2+2*A))
|
| 269 |
+
unfold kernel
|
| 270 |
+
rw [← intervalIntegral.integral_sub hip hiz]
|
| 271 |
+
calc
|
| 272 |
+
_ ≤ ∫ σ in a..b, |pairing g q ε σ θ η α β-pairing g q ε σ θ η 0 0| :=
|
| 273 |
+
intervalIntegral.abs_integral_le_integral_abs hab
|
| 274 |
+
_ ≤ ∫ σ in a..b, ε*(Fintype.card ι : ℝ)*(A^2+2*A)*σ⁻¹ := by
|
| 275 |
+
apply intervalIntegral.integral_mono_on hab (hip.sub hiz).abs hi
|
| 276 |
+
intro σ hσ
|
| 277 |
+
have hp := ha.trans_le hσ.1
|
| 278 |
+
have hs : (∑ i, (|α i| * |β i|+|α i|+|β i|)) ≤ (Fintype.card ι : ℝ)*(A^2+2*A) := by
|
| 279 |
+
calc
|
| 280 |
+
_ ≤ ∑ _i : ι, (A^2+2*A) := by
|
| 281 |
+
apply Finset.sum_le_sum; intro i _
|
| 282 |
+
have hm := mul_le_mul (hα i) (hβ i) (abs_nonneg _) hA
|
| 283 |
+
nlinarith [hα i, hβ i]
|
| 284 |
+
_ = _ := by simp; ring
|
| 285 |
+
calc
|
| 286 |
+
_ ≤ ε/σ*∑ i, (|α i| * |β i|+|α i|+|β i|) := pairing_correction g hε hp θ η α β
|
| 287 |
+
_ ≤ ε/σ*((Fintype.card ι : ℝ)*(A^2+2*A)) := mul_le_mul_of_nonneg_left hs (div_nonneg hε hp.le)
|
| 288 |
+
_ = _ := by ring
|
| 289 |
+
_ = _ := by rw [intervalIntegral.integral_const_mul, integral_inv_of_pos ha (ha.trans_le hab)]
|
| 290 |
+
|
| 291 |
+
lemma integral_inv_sq {a b : ℝ} (ha : 0 < a) (hab : a ≤ b) :
|
| 292 |
+
(∫ σ in a..b, (σ^2)⁻¹) = a⁻¹-b⁻¹ := by
|
| 293 |
+
have hd (σ : ℝ) (hσ : σ ∈ Icc a b) : HasDerivAt (fun σ : ℝ => -σ⁻¹) ((σ^2)⁻¹) σ := by
|
| 294 |
+
convert ((hasDerivAt_id σ).inv (ha.trans_le hσ.1).ne').neg using 1 <;> try rfl
|
| 295 |
+
simp; ring
|
| 296 |
+
have hi : IntervalIntegrable (fun σ : ℝ => (σ^2)⁻¹) volume a b := by
|
| 297 |
+
apply ContinuousOn.intervalIntegrable
|
| 298 |
+
rw [uIcc_of_le hab]
|
| 299 |
+
exact (continuousOn_id.pow 2).inv₀ (fun σ h => pow_ne_zero _ (ha.trans_le h.1).ne')
|
| 300 |
+
have h := intervalIntegral.integral_eq_sub_of_hasDerivAt
|
| 301 |
+
(fun σ hσ => hd σ (by simpa only [uIcc_of_le hab] using hσ)) hi
|
| 302 |
+
convert h using 1 ; ring
|
| 303 |
+
|
| 304 |
+
lemma kernel_segment_bound (g : ι → E) {q ε a b C D : ℝ} (ha : 0 < a) (hab : a ≤ b)
|
| 305 |
+
(hD : 0 ≤ D) (θ η v : E) (α β δ : ι → ℝ)
|
| 306 |
+
(hd : ∀ t ∈ Icc (0 : ℝ) 1, ∀ σ ∈ Icc a b,
|
| 307 |
+
|differential g q ε σ (θ+t • v) η v (fun i => α i+t*δ i) β δ| ≤ C/σ+D/σ^2) :
|
| 308 |
+
|kernel g q ε a b (θ+v) η (fun i => α i+δ i) β-kernel g q ε a b θ η α β| ≤
|
| 309 |
+
C*Real.log (b/a)+D/a := by
|
| 310 |
+
have hip := pairing_integrable g q ε (θ+v) η (fun i => α i+δ i) β ha hab
|
| 311 |
+
have hiz := pairing_integrable g q ε θ η α β ha hab
|
| 312 |
+
have hii : IntervalIntegrable (fun σ : ℝ => σ⁻¹) volume a b := by
|
| 313 |
+
apply ContinuousOn.intervalIntegrable
|
| 314 |
+
rw [uIcc_of_le hab]
|
| 315 |
+
exact continuousOn_id.inv₀ (fun σ h => (ha.trans_le h.1).ne')
|
| 316 |
+
have hiis : IntervalIntegrable (fun σ : ℝ => (σ^2)⁻¹) volume a b := by
|
| 317 |
+
apply ContinuousOn.intervalIntegrable
|
| 318 |
+
rw [uIcc_of_le hab]
|
| 319 |
+
exact (continuousOn_id.pow 2).inv₀ (fun σ h => pow_ne_zero _ (ha.trans_le h.1).ne')
|
| 320 |
+
have hi := (hii.const_mul C).add (hiis.const_mul D)
|
| 321 |
+
have hbound (σ : ℝ) (hσ : σ ∈ Icc a b) :
|
| 322 |
+
|pairing g q ε σ (θ+v) η (fun i => α i+δ i) β-pairing g q ε σ θ η α β| ≤ C/σ+D/σ^2 := by
|
| 323 |
+
have h := norm_image_sub_le_of_norm_deriv_le_segment_01'
|
| 324 |
+
(fun t ht => (pairing_hasDeriv g q ε σ θ η v α β δ t).hasDerivWithinAt)
|
| 325 |
+
(fun t ht => by simpa only [Real.norm_eq_abs] using hd t ⟨ht.1, ht.2.le⟩ σ hσ)
|
| 326 |
+
simpa only [one_smul, one_mul, zero_smul, add_zero, zero_mul, Real.norm_eq_abs] using h
|
| 327 |
+
unfold kernel
|
| 328 |
+
rw [← intervalIntegral.integral_sub hip hiz]
|
| 329 |
+
calc
|
| 330 |
+
_ ≤ ∫ σ in a..b, |pairing g q ε σ (θ+v) η (fun i => α i+δ i) β-pairing g q ε σ θ η α β| :=
|
| 331 |
+
intervalIntegral.abs_integral_le_integral_abs hab
|
| 332 |
+
_ ≤ ∫ σ in a..b, C*σ⁻¹+D*(σ^2)⁻¹ := by
|
| 333 |
+
apply intervalIntegral.integral_mono_on hab (hip.sub hiz).abs hi
|
| 334 |
+
intro σ hσ; simpa only [div_eq_mul_inv] using hbound σ hσ
|
| 335 |
+
_ = C*Real.log (b/a)+D*(a⁻¹-b⁻¹) := by
|
| 336 |
+
rw [intervalIntegral.integral_add (hii.const_mul C) (hiis.const_mul D),
|
| 337 |
+
intervalIntegral.integral_const_mul, intervalIntegral.integral_const_mul,
|
| 338 |
+
integral_inv_of_pos ha (ha.trans_le hab), integral_inv_sq ha hab]
|
| 339 |
+
_ ≤ _ := by
|
| 340 |
+
simp only [div_eq_mul_inv]
|
| 341 |
+
have := mul_nonneg hD (inv_nonneg.mpr (ha.trans_le hab).le)
|
| 342 |
+
nlinarith
|
| 343 |
+
|
| 344 |
+
end UniformSparsestCut.Profile
|
| 345 |
+
|
| 346 |
+
end
|
| 347 |
+
|
| 348 |
+
end OAI
|
lean/OAI/Combinatorics/SparsestCut/Replication.lean
ADDED
|
@@ -0,0 +1,172 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import OAI.Combinatorics.SparsestCut.CutDuality
|
| 2 |
+
|
| 3 |
+
namespace OAI
|
| 4 |
+
|
| 5 |
+
universe u1 u2 u3 u4
|
| 6 |
+
|
| 7 |
+
open scoped BigOperators Topology NNReal RealInnerProductSpace InnerProductSpace Matrix ContDiff ENNReal
|
| 8 |
+
open MeasureTheory ProbabilityTheory Set Filter Matrix
|
| 9 |
+
|
| 10 |
+
noncomputable section
|
| 11 |
+
|
| 12 |
+
namespace UniformSparsestCut.Replication
|
| 13 |
+
variable {V : Type u1} [Fintype V]
|
| 14 |
+
def count (M : ℕ) (w : V → ℝ) (v : V) : ℕ := 1+⌊(M:ℝ)*w v⌋₊
|
| 15 |
+
def Copies (M : ℕ) (w : V → ℝ) := (v : V) × Fin (count M w v)
|
| 16 |
+
instance (M : ℕ) (w : V → ℝ) : Fintype (Copies M w) := inferInstanceAs (Fintype (Sigma _))
|
| 17 |
+
def n (M : ℕ) (w : V → ℝ) : ℕ := Fintype.card (Copies M w)
|
| 18 |
+
def q (M : ℕ) (w : V → ℝ) (v : V) : ℝ := (count M w v:ℝ)/(n M w:ℝ)
|
| 19 |
+
omit [Fintype V] in
|
| 20 |
+
lemma count_pos (M : ℕ) (w : V → ℝ) (v : V) : 0<count M w v := by unfold count; omega
|
| 21 |
+
lemma n_sum (M : ℕ) (w : V → ℝ) : n M w=∑ v, count M w v := by
|
| 22 |
+
change Fintype.card ((v : V) × Fin (count M w v)) = _
|
| 23 |
+
simp [Fintype.card_sigma]
|
| 24 |
+
omit [Fintype V] in
|
| 25 |
+
lemma count_error (M : ℕ) (w : V → ℝ) (hw : ∀ v, 0≤w v) (v : V) :
|
| 26 |
+
0<(count M w v:ℝ)-(M:ℝ)*w v ∧ (count M w v:ℝ)-(M:ℝ)*w v≤1 := by
|
| 27 |
+
have h0 : 0≤(M:ℝ)*w v := mul_nonneg (Nat.cast_nonneg _) (hw v)
|
| 28 |
+
have h1 := Nat.floor_le h0
|
| 29 |
+
have h2 := Nat.lt_floor_add_one ((M:ℝ)*w v)
|
| 30 |
+
simp only [count,Nat.cast_add,Nat.cast_one]
|
| 31 |
+
constructor <;> linarith
|
| 32 |
+
lemma n_bounds (M : ℕ) (w : V → ℝ) (hw : ∀ v, 0≤w v) (hws : ∑ v, w v=1) :
|
| 33 |
+
M≤n M w ∧ n M w≤M+Fintype.card V := by
|
| 34 |
+
have hs : (n M w:ℝ)-(M:ℝ)=∑ v, ((count M w v:ℝ)-(M:ℝ)*w v) := by
|
| 35 |
+
rw [Finset.sum_sub_distrib,← Finset.mul_sum,hws,mul_one,n_sum,Nat.cast_sum]
|
| 36 |
+
have h0 : 0≤(n M w:ℝ)-(M:ℝ) := by rw [hs]; exact Finset.sum_nonneg (fun v _ => (count_error M w hw v).1.le)
|
| 37 |
+
have h1 : (n M w:ℝ)-(M:ℝ)≤Fintype.card V := by
|
| 38 |
+
rw [hs]
|
| 39 |
+
calc
|
| 40 |
+
_ ≤ ∑ _v : V, (1:ℝ) := Finset.sum_le_sum (fun v _ => (count_error M w hw v).2)
|
| 41 |
+
_ = _ := by simp
|
| 42 |
+
constructor
|
| 43 |
+
· exact_mod_cast (show (M:ℝ)≤n M w by linarith)
|
| 44 |
+
· exact_mod_cast (show (n M w:ℝ)≤(M:ℝ)+Fintype.card V by linarith)
|
| 45 |
+
lemma q_nonneg (M : ℕ) (w : V → ℝ) (v : V) : 0≤q M w v := by unfold q; positivity
|
| 46 |
+
lemma q_sum (M : ℕ) (w : V → ℝ) (hn : 0<n M w) : ∑ v, q M w v=1 := by
|
| 47 |
+
simp only [q,← Finset.sum_div,← Nat.cast_sum,← n_sum]
|
| 48 |
+
exact div_self (by exact_mod_cast hn.ne')
|
| 49 |
+
lemma q_l1_bound (M : ℕ) (hM : 0<M) (w : V → ℝ) (hw : ∀ v, 0≤w v) (hws : ∑ v, w v=1) :
|
| 50 |
+
(∑ v, |q M w v-w v|)≤2*(Fintype.card V:ℝ)/M := by
|
| 51 |
+
have hb := n_bounds M w hw hws
|
| 52 |
+
have hMr : (0:ℝ)<M := by exact_mod_cast hM
|
| 53 |
+
have hn : (0:ℝ)<n M w := lt_of_lt_of_le hMr (by exact_mod_cast hb.1)
|
| 54 |
+
have hE : (n M w:ℝ)-(M:ℝ)=∑ v, ((count M w v:ℝ)-(M:ℝ)*w v) := by
|
| 55 |
+
rw [Finset.sum_sub_distrib,← Finset.mul_sum,hws,mul_one,n_sum,Nat.cast_sum]
|
| 56 |
+
have hE0 : 0≤(n M w:ℝ)-(M:ℝ) := by
|
| 57 |
+
have hh : (M:ℝ)≤n M w := by exact_mod_cast hb.1
|
| 58 |
+
linarith
|
| 59 |
+
have he (v : V) : |q M w v-w v|≤
|
| 60 |
+
(((count M w v:ℝ)-(M:ℝ)*w v)+((n M w:ℝ)-(M:ℝ))*w v)/(n M w:ℝ) := by
|
| 61 |
+
have heq : q M w v-w v=
|
| 62 |
+
(((count M w v:ℝ)-(M:ℝ)*w v)-((n M w:ℝ)-(M:ℝ))*w v)/(n M w:ℝ) := by
|
| 63 |
+
unfold q; field_simp; ring
|
| 64 |
+
rw [heq,abs_div,abs_of_pos hn]
|
| 65 |
+
apply div_le_div_of_nonneg_right _ hn.le
|
| 66 |
+
exact (abs_sub _ _).trans_eq (by rw [abs_of_nonneg (count_error M w hw v).1.le,abs_of_nonneg (mul_nonneg hE0 (hw v))])
|
| 67 |
+
calc
|
| 68 |
+
_ ≤ ∑ v, (((count M w v:ℝ)-(M:ℝ)*w v)+((n M w:ℝ)-(M:ℝ))*w v)/(n M w:ℝ) := Finset.sum_le_sum (fun v _ => he v)
|
| 69 |
+
_ = 2*((n M w:ℝ)-(M:ℝ))/(n M w:ℝ) := by
|
| 70 |
+
rw [← Finset.sum_div,Finset.sum_add_distrib,← Finset.mul_sum,hws,mul_one,← hE]; ring
|
| 71 |
+
_ ≤ 2*(Fintype.card V:ℝ)/(n M w:ℝ) := by
|
| 72 |
+
apply div_le_div_of_nonneg_right _ hn.le
|
| 73 |
+
have h : (n M w:ℝ)≤(M:ℝ)+Fintype.card V := by exact_mod_cast hb.2
|
| 74 |
+
linarith
|
| 75 |
+
_ ≤ _ := div_le_div_of_nonneg_left (by positivity) hMr (by exact_mod_cast hb.1)
|
| 76 |
+
|
| 77 |
+
lemma product_expectation_bound (p q : V → ℝ) (hp : ∀ v, 0≤p v) (hq : ∀ v, 0≤q v)
|
| 78 |
+
(hps : ∑ v, p v=1) (hqs : ∑ v, q v=1) (g : V → V → ℝ) {D : ℝ}
|
| 79 |
+
(_hD : 0≤D) (hg : ∀ v z, |g v z|≤D) :
|
| 80 |
+
|(∑ v, ∑ z, p v*p z*g v z)-(∑ v, ∑ z, q v*q z*g v z)|≤
|
| 81 |
+
2*D*(∑ v, |p v-q v|) := by
|
| 82 |
+
have he (v z : V) : p v*p z*g v z-q v*q z*g v z=
|
| 83 |
+
(p v-q v)*p z*g v z+q v*(p z-q z)*g v z := by ring
|
| 84 |
+
calc
|
| 85 |
+
_ = |∑ v, ∑ z, ((p v-q v)*p z*g v z+q v*(p z-q z)*g v z)| := by
|
| 86 |
+
simp only [← Finset.sum_sub_distrib,he]
|
| 87 |
+
_ ≤ ∑ v, ∑ z, |(p v-q v)*p z*g v z+q v*(p z-q z)*g v z| :=
|
| 88 |
+
(Finset.abs_sum_le_sum_abs _ _).trans (Finset.sum_le_sum (fun v _ => Finset.abs_sum_le_sum_abs _ _))
|
| 89 |
+
_ ≤ ∑ v, ∑ z, (|p v-q v| *p z*D+q v*|p z-q z| *D) := by
|
| 90 |
+
apply Finset.sum_le_sum; intro v hv
|
| 91 |
+
apply Finset.sum_le_sum; intro z hz
|
| 92 |
+
calc
|
| 93 |
+
_ ≤ |(p v-q v)*p z*g v z|+|q v*(p z-q z)*g v z| := abs_add_le _ _
|
| 94 |
+
_ ≤ _ := by
|
| 95 |
+
rw [abs_mul,abs_mul,abs_mul,abs_mul,abs_of_nonneg (hp z),abs_of_nonneg (hq v)]
|
| 96 |
+
exact add_le_add (mul_le_mul_of_nonneg_left (hg v z) (mul_nonneg (abs_nonneg _) (hp z)))
|
| 97 |
+
(mul_le_mul_of_nonneg_left (hg v z) (mul_nonneg (hq v) (abs_nonneg _)))
|
| 98 |
+
_ = _ := by
|
| 99 |
+
simp only [Finset.sum_add_distrib,← Finset.sum_mul,← Finset.mul_sum,hps,hqs,mul_one,one_mul]
|
| 100 |
+
ring
|
| 101 |
+
end UniformSparsestCut.Replication
|
| 102 |
+
|
| 103 |
+
namespace UniformSparsestCut.Replication
|
| 104 |
+
open scoped BigOperators RealInnerProductSpace
|
| 105 |
+
noncomputable section
|
| 106 |
+
variable {V : Type u2} [Fintype V]
|
| 107 |
+
def rep (M : ℕ) (w : V → ℝ) (i : Fin (n M w)) : V := ((Fintype.equivFin (Copies M w)).symm i).1
|
| 108 |
+
def representative (M : ℕ) (w : V → ℝ) (v : V) : Fin (n M w) :=
|
| 109 |
+
(Fintype.equivFin (Copies M w)) ⟨v,⟨0,count_pos M w v⟩⟩
|
| 110 |
+
lemma rep_section (M : ℕ) (w : V → ℝ) (v : V) : rep M w (representative M w v)=v := by
|
| 111 |
+
exact congrArg (fun copy : Copies M w => copy.1)
|
| 112 |
+
((Fintype.equivFin (Copies M w)).symm_apply_apply ⟨v, ⟨0, count_pos M w v⟩⟩)
|
| 113 |
+
lemma sum_rep (M : ℕ) (w : V → ℝ) (g : V → ℝ) :
|
| 114 |
+
(∑ i : Fin (n M w), g (rep M w i))=∑ v, (count M w v:ℝ)*g v := by
|
| 115 |
+
classical
|
| 116 |
+
calc
|
| 117 |
+
_ = ∑ c : Copies M w, g (rep M w ((Fintype.equivFin (Copies M w)) c)) :=
|
| 118 |
+
((Fintype.equivFin (Copies M w)).sum_comp (fun i => g (rep M w i))).symm
|
| 119 |
+
_ = ∑ c : Copies M w, g c.1 := Finset.sum_congr rfl (fun copy _ =>
|
| 120 |
+
congrArg (fun copy : Copies M w => g copy.1)
|
| 121 |
+
((Fintype.equivFin (Copies M w)).symm_apply_apply copy))
|
| 122 |
+
_ = _ := by
|
| 123 |
+
change (∑ c : (v : V) × Fin (count M w v), g c.1) = _
|
| 124 |
+
simp [Fintype.sum_sigma]
|
| 125 |
+
lemma ordered_sum (M : ℕ) (w : V → ℝ) (hn : 0 < n M w) (g : V → V → ℝ) :
|
| 126 |
+
(∑ i : Fin (n M w), ∑ j, g (rep M w i) (rep M w j))=
|
| 127 |
+
(n M w:ℝ)^2*(∑ v, ∑ z, q M w v*q M w z*g v z) := by
|
| 128 |
+
have hn0 : (n M w:ℝ)≠0 := by exact_mod_cast hn.ne'
|
| 129 |
+
calc
|
| 130 |
+
_ = ∑ i : Fin (n M w), ∑ z, (count M w z:ℝ)*g (rep M w i) z :=
|
| 131 |
+
Finset.sum_congr rfl (fun i _ => sum_rep M w (g (rep M w i)))
|
| 132 |
+
_ = ∑ v, (count M w v:ℝ)*(∑ z, (count M w z:ℝ)*g v z) :=
|
| 133 |
+
sum_rep M w (fun v => ∑ z, (count M w z:ℝ)*g v z)
|
| 134 |
+
_ = _ := by
|
| 135 |
+
simp only [Finset.mul_sum,q]
|
| 136 |
+
apply Finset.sum_congr rfl
|
| 137 |
+
intro v hv
|
| 138 |
+
apply Finset.sum_congr rfl
|
| 139 |
+
intro z hz
|
| 140 |
+
field_simp
|
| 141 |
+
|
| 142 |
+
lemma collapse (M : ℕ) (w : V → ℝ) (d : V → V → ℝ) (hself : ∀ v, d v v=0)
|
| 143 |
+
{A : Type u3} [Fintype A] (F : Fin (n M w) → A → ℝ)
|
| 144 |
+
(hF : ∀ i j, (∑ a, |F i a-F j a|)≤d (rep M w i) (rep M w j)) (i : Fin (n M w)) (a : A) :
|
| 145 |
+
F i a=F (representative M w (rep M w i)) a := by
|
| 146 |
+
classical
|
| 147 |
+
have h := hF i (representative M w (rep M w i))
|
| 148 |
+
rw [rep_section,hself] at h
|
| 149 |
+
have hh := (Finset.single_le_sum (fun b _ => abs_nonneg (F i b-F (representative M w (rep M w i)) b)) (Finset.mem_univ a)).trans h
|
| 150 |
+
exact sub_eq_zero.mp (abs_nonpos_iff.mp hh)
|
| 151 |
+
lemma descend_contraction (M : ℕ) (w : V → ℝ) (d : V → V → ℝ)
|
| 152 |
+
{A : Type u4} [Fintype A] (F : Fin (n M w) → A → ℝ)
|
| 153 |
+
(hF : ∀ i j, (∑ a, |F i a-F j a|)≤d (rep M w i) (rep M w j)) :
|
| 154 |
+
∀ v z, (∑ a, |F (representative M w v) a-F (representative M w z) a|)≤d v z := by
|
| 155 |
+
intro v z
|
| 156 |
+
simpa only [rep_section] using hF (representative M w v) (representative M w z)
|
| 157 |
+
lemma expectation_error (M : ℕ) (hM : 0 < M) (w : V → ℝ) (hw : ∀ v, 0≤w v) (hws : (∑ v,w v)=1)
|
| 158 |
+
(g : V → V → ℝ) {D : ℝ} (hD : 0≤D) (hg : ∀ v z, |g v z|≤D) :
|
| 159 |
+
|(∑ v, ∑ z, q M w v*q M w z*g v z)-(∑ v, ∑ z, w v*w z*g v z)|≤
|
| 160 |
+
4*D*(Fintype.card V:ℝ)/M := by
|
| 161 |
+
have hn : 0 < n M w := hM.trans_le (n_bounds M w hw hws).1
|
| 162 |
+
have h := product_expectation_bound (q M w) w (q_nonneg M w) hw (q_sum M w hn) hws g hD hg
|
| 163 |
+
calc
|
| 164 |
+
_ ≤ 2*D*(∑ v, |q M w v-w v|) := h
|
| 165 |
+
_ ≤ 2*D*(2*(Fintype.card V:ℝ)/M) := mul_le_mul_of_nonneg_left (q_l1_bound M hM w hw hws) (by positivity)
|
| 166 |
+
_ = _ := by ring
|
| 167 |
+
end
|
| 168 |
+
end UniformSparsestCut.Replication
|
| 169 |
+
|
| 170 |
+
end
|
| 171 |
+
|
| 172 |
+
end OAI
|
lean/OAI/Combinatorics/SparsestCut/RoundedCharts.lean
ADDED
|
@@ -0,0 +1,321 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import OAI.Combinatorics.SparsestCut.ChartLinear
|
| 2 |
+
|
| 3 |
+
namespace OAI
|
| 4 |
+
|
| 5 |
+
universe u1 u2
|
| 6 |
+
|
| 7 |
+
open scoped BigOperators Topology NNReal RealInnerProductSpace InnerProductSpace Matrix ContDiff ENNReal
|
| 8 |
+
open MeasureTheory ProbabilityTheory Set Filter Matrix
|
| 9 |
+
|
| 10 |
+
noncomputable section
|
| 11 |
+
|
| 12 |
+
namespace UniformSparsestCut.SourceCharts
|
| 13 |
+
open scoped BigOperators RealInnerProductSpace
|
| 14 |
+
open Filter Set
|
| 15 |
+
noncomputable section
|
| 16 |
+
variable {m : ℕ} (f : PivotFamily.PFamily m) (hm : 0 < m)
|
| 17 |
+
local notation "E" => EuclideanSpace ℝ (Fin m)
|
| 18 |
+
local notation "F" => EuclideanSpace ℝ (Fin (m^6))
|
| 19 |
+
def u (s : Fin (m^3)) (i : Fin (m^6)) : E := (Real.sqrt m)⁻¹ • f.g s i
|
| 20 |
+
def lower (m : ℕ) : ℝ := (m:ℝ)^6/(2*m)
|
| 21 |
+
include hm
|
| 22 |
+
lemma lower_pos : 0<lower m := by unfold lower; positivity
|
| 23 |
+
lemma energy (s : Fin (m^3)) (x : E) : lower m*‖x‖^2≤‖FrameCharts.chart (u f s) x‖^2 := by
|
| 24 |
+
have hc (v : E) (hv : ‖v‖=1) := f.covariance s v hv
|
| 25 |
+
have h := (FrameCharts.normalized_bounds (f.g s) hm (pow_pos hm _) (by
|
| 26 |
+
intro v hv
|
| 27 |
+
simpa only [DirectionInterpolation.empiricalCov,real_inner_comm,div_eq_mul_inv,mul_comm] using hc v hv) x).1
|
| 28 |
+
change (m:ℝ)^6/(2*m)*‖x‖^2≤‖FrameCharts.chart (fun i => (Real.sqrt m)⁻¹ • f.g s i) x‖^2
|
| 29 |
+
simpa only [Nat.cast_pow] using h
|
| 30 |
+
def B (s : Fin (m^3)) : F →L[ℝ] E :=
|
| 31 |
+
ChartLinear.pseudoInverse (FrameCharts.chart (u f s)) (lower_pos hm) (energy f hm s)
|
| 32 |
+
lemma B_left (s : Fin (m^3)) (x : E) : B f hm s (FrameCharts.chart (u f s) x)=x := by
|
| 33 |
+
have h := ChartLinear.pseudoInverse_comp (FrameCharts.chart (u f s)) (lower_pos hm) (energy f hm s)
|
| 34 |
+
exact congrArg (fun L : E →L[ℝ] E => L x) h
|
| 35 |
+
lemma u_norm (s : Fin (m^3)) (i : Fin (m^6)) : 1/2≤‖u f s i‖ ∧ ‖u f s i‖≤2 :=
|
| 36 |
+
FrameCharts.normalized_norms (f.g s) hm (f.norms s) i
|
| 37 |
+
lemma u_nonzero (s : Fin (m^3)) (i : Fin (m^6)) : u f s i≠0 := by
|
| 38 |
+
have h := (u_norm f hm s i).1
|
| 39 |
+
intro hz; rw [hz,norm_zero] at h; norm_num at h
|
| 40 |
+
lemma u_nonparallel (s : Fin (m^3)) (i j : Fin (m^6)) (hij : i≠j) (t : ℝ) :
|
| 41 |
+
u f s i≠t • u f s j := by
|
| 42 |
+
intro h
|
| 43 |
+
apply f.nonparallel s i j hij t
|
| 44 |
+
have hq : (Real.sqrt m)⁻¹≠0 := inv_ne_zero (ne_of_gt (Real.sqrt_pos.mpr (by exact_mod_cast hm)))
|
| 45 |
+
have he := congrArg (fun x : E => Real.sqrt m • x) h
|
| 46 |
+
have hq0 : Real.sqrt (m:ℝ)≠0 := ne_of_gt (Real.sqrt_pos.mpr (by exact_mod_cast hm))
|
| 47 |
+
have hmul : Real.sqrt (m:ℝ)*(t*(Real.sqrt (m:ℝ))⁻¹)=t := by field_simp
|
| 48 |
+
simpa only [u,smul_smul,mul_inv_cancel₀ hq0,hmul,one_smul] using he
|
| 49 |
+
lemma u_pivot (s : Fin (m^3)) (i : Fin (m^6)) (j : Fin m ) :
|
| 50 |
+
1/((m:ℝ)^30*Real.sqrt m) < |u f s i j| := by
|
| 51 |
+
have hq : 0<Real.sqrt m := Real.sqrt_pos.mpr (by exact_mod_cast hm)
|
| 52 |
+
change _ < |(Real.sqrt m)⁻¹*(f.g s i j)|
|
| 53 |
+
rw [abs_mul,abs_of_pos (inv_pos.mpr hq)]
|
| 54 |
+
simpa only [one_div,mul_inv,mul_comm] using mul_lt_mul_of_pos_left (f.pivot s i j) (inv_pos.mpr hq)
|
| 55 |
+
lemma B_column (s : Fin (m^3)) (i : Fin (m^6)) :
|
| 56 |
+
‖B f hm s (EuclideanSpace.single i 1)‖≤4*((m:ℝ)/(m:ℝ)^6) := by
|
| 57 |
+
have h := ChartLinear.pseudoInverse_column (FrameCharts.chart (u f s)) (lower_pos hm) (energy f hm s) (EuclideanSpace.single i 1)
|
| 58 |
+
rw [FrameCharts.chart_adjoint_single] at h
|
| 59 |
+
calc
|
| 60 |
+
_ ≤ 2/lower m := h.trans (div_le_div_of_nonneg_right (u_norm f hm s i).2 (lower_pos hm).le)
|
| 61 |
+
_ = _ := by unfold lower; field_simp; ring
|
| 62 |
+
lemma B_norm (s : Fin (m^3)) (x : F) : ‖B f hm s x‖≤‖x‖/Real.sqrt (lower m) :=
|
| 63 |
+
ChartLinear.pseudoInverse_norm _ (lower_pos hm) (energy f hm s) x
|
| 64 |
+
lemma residual_norm (s : Fin (m^3)) (x : F) :
|
| 65 |
+
‖x-FrameCharts.chart (u f s) (B f hm s x)‖≤‖x‖ :=
|
| 66 |
+
ChartLinear.residual_norm _ (lower_pos hm) (energy f hm s) x
|
| 67 |
+
end
|
| 68 |
+
end UniformSparsestCut.SourceCharts
|
| 69 |
+
|
| 70 |
+
namespace UniformSparsestCut.HyperplaneCount
|
| 71 |
+
variable {E : Type u1} {ι : Type u2} [AddCommGroup E] [Module ℝ E] [FiniteDimensional ℝ E]
|
| 72 |
+
[Fintype ι] [DecidableEq ι]
|
| 73 |
+
|
| 74 |
+
omit [FiniteDimensional ℝ E] [Fintype ι] in
|
| 75 |
+
lemma shattered_independent (f : ι → E →ₗ[ℝ] ℝ) (A : Finset (Finset ι))
|
| 76 |
+
(hA : ∀ u ∈ A, ∃ x : E, ∀ i, f i x ≠ 0 ∧ (0 < f i x ↔ i ∈ u))
|
| 77 |
+
{s : Finset ι} (hs : A.Shatters s) : LinearIndependent ℝ (fun i : s => f i) := by
|
| 78 |
+
classical
|
| 79 |
+
rw [Fintype.linearIndependent_iff]
|
| 80 |
+
intro c hc j
|
| 81 |
+
by_contra hj
|
| 82 |
+
let t := s.filter (fun i => ∀ hi : i ∈ s, 0 < c ⟨i,hi⟩)
|
| 83 |
+
obtain ⟨u,hu,htu⟩ := hs (t := t) (Finset.filter_subset _ _)
|
| 84 |
+
obtain ⟨x,hx⟩ := hA u hu
|
| 85 |
+
have hsign (i : s) : 0 < f i x ↔ 0 < c i := by
|
| 86 |
+
rw [(hx i).2]
|
| 87 |
+
have he : i.val ∈ s ∩ u ↔ i.val ∈ t := by rw [htu]
|
| 88 |
+
simp only [Finset.mem_inter, i.property, true_and, t, Finset.mem_filter] at he
|
| 89 |
+
exact he.trans ⟨fun h => h trivial, fun h _ => h⟩
|
| 90 |
+
have hprod (i : s) : 0 ≤ c i * f i x := by
|
| 91 |
+
by_cases hp : 0 < c i
|
| 92 |
+
· exact le_of_lt (mul_pos hp ((hsign i).mpr hp))
|
| 93 |
+
· exact mul_nonneg_of_nonpos_of_nonpos (le_of_not_gt hp)
|
| 94 |
+
(le_of_not_gt (mt (hsign i).mp hp))
|
| 95 |
+
have hpj : 0 < c j * f j x := by
|
| 96 |
+
by_cases hp : 0 < c j
|
| 97 |
+
· exact mul_pos hp ((hsign j).mpr hp)
|
| 98 |
+
· have hn : c j < 0 := lt_of_le_of_ne (le_of_not_gt hp) hj
|
| 99 |
+
have hf : f j x < 0 := lt_of_le_of_ne (le_of_not_gt (mt (hsign j).mp hp)) (hx j).1
|
| 100 |
+
exact mul_pos_of_neg_of_neg hn hf
|
| 101 |
+
have hp : 0 < ∑ i : s, c i * f i x :=
|
| 102 |
+
Finset.sum_pos' (fun i _ => hprod i) ⟨j, Finset.mem_univ _, hpj⟩
|
| 103 |
+
have hz := congrArg (fun L : E →ₗ[ℝ] ℝ => L x) hc
|
| 104 |
+
simp only [LinearMap.sum_apply, LinearMap.smul_apply, smul_eq_mul, LinearMap.zero_apply] at hz
|
| 105 |
+
linarith
|
| 106 |
+
|
| 107 |
+
omit [Fintype ι] in
|
| 108 |
+
lemma vcDim_le (f : ι → E →ₗ[ℝ] ℝ) (A : Finset (Finset ι))
|
| 109 |
+
(hA : ∀ u ∈ A, ∃ x : E, ∀ i, f i x ≠ 0 ∧ (0 < f i x ↔ i ∈ u)) :
|
| 110 |
+
A.vcDim ≤ Module.finrank ℝ E := by
|
| 111 |
+
apply Finset.sup_le
|
| 112 |
+
intro s hs
|
| 113 |
+
have h := (shattered_independent f A hA (Finset.mem_shatterer.mp hs)).fintype_card_le_finrank
|
| 114 |
+
simpa using h
|
| 115 |
+
|
| 116 |
+
lemma sign_patterns_bound (f : ι → E →ₗ[ℝ] ℝ) (A : Finset (Finset ι))
|
| 117 |
+
(hA : ∀ u ∈ A, ∃ x : E, ∀ i, f i x ≠ 0 ∧ (0 < f i x ↔ i ∈ u)) :
|
| 118 |
+
A.card ≤ ∑ k ∈ Finset.Iic (Module.finrank ℝ E), (Fintype.card ι).choose k := by
|
| 119 |
+
have hv := vcDim_le f A hA
|
| 120 |
+
exact (Finset.card_le_card_shatterer A).trans
|
| 121 |
+
(Finset.card_shatterer_le_sum_vcDim.trans
|
| 122 |
+
(Finset.sum_le_sum_of_subset (Finset.Iic_subset_Iic.mpr hv)))
|
| 123 |
+
|
| 124 |
+
end UniformSparsestCut.HyperplaneCount
|
| 125 |
+
|
| 126 |
+
namespace UniformSparsestCut.RoundedCharts
|
| 127 |
+
open MeasureTheory Set Filter
|
| 128 |
+
open scoped Topology BigOperators RealInnerProductSpace
|
| 129 |
+
variable {m N S : ℕ}
|
| 130 |
+
local notation "E" => EuclideanSpace ℝ (Fin m)
|
| 131 |
+
local notation "F" => EuclideanSpace ℝ (Fin N)
|
| 132 |
+
|
| 133 |
+
def cube (R : ℝ) : Set E := {θ | ∀ j, |θ j| < R}
|
| 134 |
+
|
| 135 |
+
def regular (u : Fin N → E) (τ : ℝ) (θ : E) : Prop :=
|
| 136 |
+
∀ i (k : ℤ), inner ℝ (u i) θ ≠ (k:ℝ)*τ
|
| 137 |
+
|
| 138 |
+
def integerLabel (u : Fin N → E) (τ : ℝ) (θ : E) (i : Fin N) : ℤ :=
|
| 139 |
+
⌊inner ℝ (u i) θ/τ⌋
|
| 140 |
+
|
| 141 |
+
def rounded (u : Fin N → E) (τ : ℝ) (θ : E) : F :=
|
| 142 |
+
WithLp.toLp 2 (fun i => τ*(integerLabel u τ θ i : ℝ))
|
| 143 |
+
|
| 144 |
+
def Vertex (u : Fin S → Fin N → E) (τ : ℝ) :=
|
| 145 |
+
{p : Fin S × (Fin N → ℤ) // ∃ θ ∈ cube 2, regular (u p.1) τ θ ∧ integerLabel (u p.1) τ θ = p.2}
|
| 146 |
+
|
| 147 |
+
def coordinate (u : Fin S → Fin N → E) (τ : ℝ) (v : Vertex u τ) : F :=
|
| 148 |
+
WithLp.toLp 2 (fun i => τ*(v.val.2 i : ℝ))
|
| 149 |
+
|
| 150 |
+
lemma cube_norm {R : ℝ} (hR : 0 ≤ R) {θ : E} (hθ : θ ∈ cube R) :
|
| 151 |
+
‖θ‖ ≤ R*Real.sqrt m := by
|
| 152 |
+
have hs : ‖θ‖^2 ≤ (m:ℝ)*R^2 := by
|
| 153 |
+
rw [EuclideanSpace.norm_sq_eq]
|
| 154 |
+
calc
|
| 155 |
+
_ ≤ ∑ _j : Fin m, R^2 := by
|
| 156 |
+
apply Finset.sum_le_sum; intro j _
|
| 157 |
+
rw [Real.norm_eq_abs]
|
| 158 |
+
exact pow_le_pow_left₀ (abs_nonneg _) (hθ j).le _
|
| 159 |
+
_ = _ := by simp
|
| 160 |
+
have hroot := Real.sq_sqrt (Nat.cast_nonneg m)
|
| 161 |
+
have hp : 0 ≤ R*Real.sqrt m := mul_nonneg hR (Real.sqrt_nonneg _)
|
| 162 |
+
have he : (R*Real.sqrt m)^2 = (m:ℝ)*R^2 := by rw [mul_pow,hroot]; ring
|
| 163 |
+
nlinarith [norm_nonneg θ]
|
| 164 |
+
|
| 165 |
+
lemma hyperplane_null (u : E) (hu : u ≠ 0) (t : ℝ) :
|
| 166 |
+
volume {x : E | inner ℝ u x = t} = 0 := by
|
| 167 |
+
let H : AffineSubspace ℝ E :=
|
| 168 |
+
{ carrier := {x | inner ℝ u x = t}
|
| 169 |
+
smul_vsub_vadd_mem' := by
|
| 170 |
+
intro c x y z hx hy hz
|
| 171 |
+
change inner ℝ u x = t at hx
|
| 172 |
+
change inner ℝ u y = t at hy
|
| 173 |
+
change inner ℝ u z = t at hz
|
| 174 |
+
change inner ℝ u (c • (x-y)+z) = t
|
| 175 |
+
simp only [inner_add_right, inner_smul_right, inner_sub_right, hx, hy, hz]
|
| 176 |
+
ring }
|
| 177 |
+
have ht : H ≠ ⊤ := by
|
| 178 |
+
intro he
|
| 179 |
+
have hzero : (0:E) ∈ H := by rw [he]; trivial
|
| 180 |
+
have hone : u ∈ H := by rw [he]; trivial
|
| 181 |
+
change inner ℝ u 0 = t at hzero
|
| 182 |
+
change inner ℝ u u = t at hone
|
| 183 |
+
rw [inner_zero_right] at hzero
|
| 184 |
+
have := ((inner_self_eq_zero (𝕜 := ℝ)).mp (hone.trans hzero.symm))
|
| 185 |
+
exact hu this
|
| 186 |
+
exact Measure.addHaar_affineSubspace volume H ht
|
| 187 |
+
|
| 188 |
+
lemma ae_regular (u : Fin N → E) (τ : ℝ) (hu : ∀ i, u i ≠ 0) :
|
| 189 |
+
∀ᵐ θ : E, regular u τ θ := by
|
| 190 |
+
have hi (i : Fin N) (k : ℤ) : ∀ᵐ θ : E, inner ℝ (u i) θ ≠ (k:ℝ)*τ := by
|
| 191 |
+
rw [ae_iff]
|
| 192 |
+
simpa only [not_not] using hyperplane_null (u i) (hu i) ((k:ℝ)*τ)
|
| 193 |
+
have hi' (i : Fin N) : ∀ᵐ θ : E, ∀ k : ℤ, inner ℝ (u i) θ ≠ (k:ℝ)*τ :=
|
| 194 |
+
ae_all_iff.mpr (hi i)
|
| 195 |
+
exact ae_all_iff.mpr hi'
|
| 196 |
+
|
| 197 |
+
lemma rounded_error_coordinate (u : Fin N → E) {τ : ℝ} (hτ : 0 < τ) (θ : E) (i : Fin N) :
|
| 198 |
+
0 ≤ inner ℝ (u i) θ-rounded u τ θ i ∧ inner ℝ (u i) θ-rounded u τ θ i < τ := by
|
| 199 |
+
have hlo := Int.floor_le (inner ℝ (u i) θ/τ)
|
| 200 |
+
have hhi := Int.lt_floor_add_one (inner ℝ (u i) θ/τ)
|
| 201 |
+
have hl := (le_div_iff₀ hτ).mp hlo
|
| 202 |
+
have hh := (div_lt_iff₀ hτ).mp hhi
|
| 203 |
+
change 0 ≤ inner ℝ (u i) θ-τ*(⌊inner ℝ (u i) θ/τ⌋:ℝ) ∧
|
| 204 |
+
inner ℝ (u i) θ-τ*(⌊inner ℝ (u i) θ/τ⌋:ℝ) < τ
|
| 205 |
+
constructor <;> nlinarith
|
| 206 |
+
|
| 207 |
+
lemma rounded_error (u : Fin N → E) {τ : ℝ} (hτ : 0 < τ) (θ : E) :
|
| 208 |
+
‖rounded u τ θ - FrameCharts.chart u θ‖ ≤ Real.sqrt N*τ := by
|
| 209 |
+
have hs : ‖rounded u τ θ - FrameCharts.chart u θ‖^2 ≤ (N:ℝ)*τ^2 := by
|
| 210 |
+
rw [EuclideanSpace.norm_sq_eq]
|
| 211 |
+
calc
|
| 212 |
+
_ ≤ ∑ _i : Fin N, τ^2 := by
|
| 213 |
+
apply Finset.sum_le_sum; intro i _
|
| 214 |
+
simp only [PiLp.sub_apply, FrameCharts.chart_apply, Real.norm_eq_abs, sq_abs]
|
| 215 |
+
have hh := rounded_error_coordinate u hτ θ i
|
| 216 |
+
nlinarith
|
| 217 |
+
_ = _ := by simp
|
| 218 |
+
have hr := Real.sq_sqrt (Nat.cast_nonneg N)
|
| 219 |
+
have hp : 0 ≤ Real.sqrt N*τ := mul_nonneg (Real.sqrt_nonneg _) hτ.le
|
| 220 |
+
have he : (Real.sqrt N*τ)^2 = (N:ℝ)*τ^2 := by rw [mul_pow,hr]
|
| 221 |
+
nlinarith [norm_nonneg (rounded u τ θ-FrameCharts.chart u θ)]
|
| 222 |
+
|
| 223 |
+
lemma integerLabel_bound (u : Fin N → E) {τ : ℝ} (hτ : 0 < τ) (hu : ∀ i, ‖u i‖ ≤ 2)
|
| 224 |
+
{θ : E} (hθ : θ ∈ cube 2) (i : Fin N) :
|
| 225 |
+
|(integerLabel u τ θ i : ℝ)| ≤ 4*Real.sqrt m/τ+1 := by
|
| 226 |
+
have hn := cube_norm (by norm_num : (0:ℝ) ≤ 2) hθ
|
| 227 |
+
have hh : |inner ℝ (u i) θ| ≤ 4*Real.sqrt m := by
|
| 228 |
+
calc
|
| 229 |
+
_ ≤ ‖u i‖*‖θ‖ := abs_real_inner_le_norm _ _
|
| 230 |
+
_ ≤ 2*(2*Real.sqrt m) := mul_le_mul (hu i) hn (norm_nonneg θ) (by norm_num)
|
| 231 |
+
_ = _ := by ring
|
| 232 |
+
have hf := Int.floor_le (inner ℝ (u i) θ/τ)
|
| 233 |
+
have hfl := Int.lt_floor_add_one (inner ℝ (u i) θ/τ)
|
| 234 |
+
have hab : |inner ℝ (u i) θ/τ| ≤ 4*Real.sqrt m/τ := by
|
| 235 |
+
rw [abs_div, abs_of_pos hτ]
|
| 236 |
+
exact div_le_div_of_nonneg_right hh hτ.le
|
| 237 |
+
change |(⌊inner ℝ (u i) θ/τ⌋:ℝ)| ≤ _
|
| 238 |
+
rw [abs_le] at hab ⊢
|
| 239 |
+
constructor <;> linarith
|
| 240 |
+
|
| 241 |
+
lemma vertex_finite (u : Fin S → Fin N → E) {τ : ℝ} (hτ : 0 < τ)
|
| 242 |
+
(hu : ∀ s i, ‖u s i‖ ≤ 2) : Finite (Vertex u τ) := by
|
| 243 |
+
let B : ℤ := ⌈4*Real.sqrt m/τ+1⌉
|
| 244 |
+
let f : Vertex u τ → Fin S × (Fin N → ↥(Finset.Icc (-B) B)) := fun v =>
|
| 245 |
+
(v.val.1, fun i => ⟨v.val.2 i, by
|
| 246 |
+
obtain ⟨θ,hθ,hr,hlabel⟩ := v.property
|
| 247 |
+
have hb := integerLabel_bound (u v.val.1) hτ (hu v.val.1) hθ i
|
| 248 |
+
have hB := Int.le_ceil (4*Real.sqrt m/τ+1)
|
| 249 |
+
have hv : |(v.val.2 i:ℝ)| ≤ (B:ℝ) := by rw [← hlabel]; exact hb.trans hB
|
| 250 |
+
have hlo : -B ≤ v.val.2 i := by exact_mod_cast (abs_le.mp hv).1
|
| 251 |
+
have hhi : v.val.2 i ≤ B := by exact_mod_cast (abs_le.mp hv).2
|
| 252 |
+
exact Finset.mem_Icc.mpr ⟨hlo,hhi⟩⟩)
|
| 253 |
+
apply Finite.of_injective f
|
| 254 |
+
intro v w h
|
| 255 |
+
apply Subtype.ext
|
| 256 |
+
apply Prod.ext
|
| 257 |
+
· exact congrArg (fun z : Fin S × (Fin N → ↥(Finset.Icc (-B) B)) => z.1) h
|
| 258 |
+
· funext i
|
| 259 |
+
exact congrArg (fun z : Fin S × (Fin N → ↥(Finset.Icc (-B) B)) => (z.2 i).val) h
|
| 260 |
+
|
| 261 |
+
lemma representative (u : Fin S → Fin N → E) (τ : ℝ) (v : Vertex u τ) :
|
| 262 |
+
∃ θ ∈ cube 2, regular (u v.val.1) τ θ ∧ coordinate u τ v = rounded (u v.val.1) τ θ := by
|
| 263 |
+
obtain ⟨θ,hθ,hr,hl⟩ := v.property
|
| 264 |
+
refine ⟨θ,hθ,hr,?_⟩
|
| 265 |
+
ext i
|
| 266 |
+
change τ*(v.val.2 i : ℝ) = τ*(integerLabel (u v.val.1) τ θ i : ℝ)
|
| 267 |
+
rw [hl]
|
| 268 |
+
|
| 269 |
+
end UniformSparsestCut.RoundedCharts
|
| 270 |
+
|
| 271 |
+
namespace UniformSparsestCut.SourceCharts
|
| 272 |
+
open scoped BigOperators RealInnerProductSpace
|
| 273 |
+
noncomputable section
|
| 274 |
+
variable {m : ℕ} (f : PivotFamily.PFamily m) (hm : 0 < m)
|
| 275 |
+
local notation "E" => EuclideanSpace ℝ (Fin m)
|
| 276 |
+
local notation "F" => EuclideanSpace ℝ (Fin (m^6))
|
| 277 |
+
lemma lower_ge_one (hm2 : 2 ≤ m) : 1≤lower m := by
|
| 278 |
+
have hx : (2:ℝ) ≤ m := by exact_mod_cast hm2
|
| 279 |
+
have hp := pow_le_pow_right₀ (by linarith : (1:ℝ) ≤ m) (show 2≤6 by norm_num)
|
| 280 |
+
unfold lower
|
| 281 |
+
apply (le_div_iff₀ (by positivity : (0:ℝ)<2*m)).mpr
|
| 282 |
+
nlinarith
|
| 283 |
+
lemma B_norm_le (hm2 : 2 ≤ m) (s : Fin (m^3)) (x : F) : ‖B f hm s x‖≤‖x‖ := by
|
| 284 |
+
exact (B_norm f hm s x).trans (div_le_self (norm_nonneg _) ((Real.one_le_sqrt).mpr (lower_ge_one hm2)))
|
| 285 |
+
lemma rounded_B_error (hm2 : 2 ≤ m) {τ : ℝ} (hτ : 0<τ) (s : Fin (m^3)) (θ : E) :
|
| 286 |
+
‖B f hm s (RoundedCharts.rounded (u f s) τ θ)-θ‖≤Real.sqrt (m^6:ℕ)*τ := by
|
| 287 |
+
have he : B f hm s (RoundedCharts.rounded (u f s) τ θ)-θ=
|
| 288 |
+
B f hm s (RoundedCharts.rounded (u f s) τ θ-FrameCharts.chart (u f s) θ) := by
|
| 289 |
+
rw [map_sub,B_left]
|
| 290 |
+
rw [he]
|
| 291 |
+
exact (B_norm_le f hm hm2 s _).trans (RoundedCharts.rounded_error _ hτ θ)
|
| 292 |
+
lemma rounded_residual_error {τ : ℝ} (hτ : 0<τ) (s : Fin (m^3)) (θ : E) :
|
| 293 |
+
‖RoundedCharts.rounded (u f s) τ θ-FrameCharts.chart (u f s) (B f hm s (RoundedCharts.rounded (u f s) τ θ))‖≤
|
| 294 |
+
Real.sqrt (m^6:ℕ)*τ := by
|
| 295 |
+
let x := RoundedCharts.rounded (u f s) τ θ
|
| 296 |
+
have he : x-FrameCharts.chart (u f s) (B f hm s x)=
|
| 297 |
+
(x-FrameCharts.chart (u f s) θ)-FrameCharts.chart (u f s) (B f hm s (x-FrameCharts.chart (u f s) θ)) := by
|
| 298 |
+
rw [map_sub,B_left,map_sub]
|
| 299 |
+
abel
|
| 300 |
+
change ‖x-FrameCharts.chart (u f s) (B f hm s x)‖≤_
|
| 301 |
+
rw [he]
|
| 302 |
+
exact (residual_norm f hm s _).trans (RoundedCharts.rounded_error _ hτ θ)
|
| 303 |
+
lemma vertex_B_bound (hm2 : 2 ≤ m) {τ : ℝ} (hτ : 0<τ) (v : RoundedCharts.Vertex (u f) τ) :
|
| 304 |
+
‖B f hm v.val.1 (RoundedCharts.coordinate (u f) τ v)‖≤2*Real.sqrt m+Real.sqrt (m^6:ℕ)*τ := by
|
| 305 |
+
obtain ⟨θ,hθ,hr,hx⟩ := RoundedCharts.representative (u f) τ v
|
| 306 |
+
rw [hx]
|
| 307 |
+
have h := rounded_B_error f hm hm2 hτ v.val.1 θ
|
| 308 |
+
have ht := RoundedCharts.cube_norm (by norm_num : (0:ℝ)≤2) hθ
|
| 309 |
+
exact (norm_le_norm_sub_add _ θ).trans (by linarith)
|
| 310 |
+
lemma vertex_residual_bound {τ : ℝ} (hτ : 0<τ) (v : RoundedCharts.Vertex (u f) τ) :
|
| 311 |
+
‖RoundedCharts.coordinate (u f) τ v-FrameCharts.chart (u f v.val.1) (B f hm v.val.1 (RoundedCharts.coordinate (u f) τ v))‖≤
|
| 312 |
+
Real.sqrt (m^6:ℕ)*τ := by
|
| 313 |
+
obtain ⟨θ,hθ,hr,hx⟩ := RoundedCharts.representative (u f) τ v
|
| 314 |
+
rw [hx]
|
| 315 |
+
exact rounded_residual_error f hm hτ v.val.1 θ
|
| 316 |
+
end
|
| 317 |
+
end UniformSparsestCut.SourceCharts
|
| 318 |
+
|
| 319 |
+
end
|
| 320 |
+
|
| 321 |
+
end OAI
|
lean/OAI/Combinatorics/SparsestCut/Semimetrics.lean
ADDED
|
@@ -0,0 +1,193 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import OAI.Combinatorics.SparsestCut.CutSums
|
| 2 |
+
|
| 3 |
+
namespace OAI
|
| 4 |
+
|
| 5 |
+
open scoped BigOperators Topology NNReal RealInnerProductSpace InnerProductSpace Matrix ContDiff ENNReal
|
| 6 |
+
open MeasureTheory ProbabilityTheory Set Filter Matrix
|
| 7 |
+
|
| 8 |
+
noncomputable section
|
| 9 |
+
|
| 10 |
+
namespace UniformSparsestCut
|
| 11 |
+
|
| 12 |
+
section SemimetricBounds
|
| 13 |
+
|
| 14 |
+
variable {n : ℕ}
|
| 15 |
+
|
| 16 |
+
def IsSemimetric (d : Fin n → Fin n → ℝ) : Prop :=
|
| 17 |
+
(∀ i j, 0 ≤ d i j) ∧ (∀ i j, d i j = d j i) ∧
|
| 18 |
+
(∀ i, d i i = 0) ∧ (∀ i j k, d i k ≤ d i j + d j k)
|
| 19 |
+
|
| 20 |
+
lemma NegativeType.semimetric {d : Fin n → Fin n → ℝ} (hd : NegativeType d) :
|
| 21 |
+
IsSemimetric d := by
|
| 22 |
+
obtain ⟨x,hx⟩ := hd.1
|
| 23 |
+
refine ⟨fun i j => by rw [hx]; positivity, ?_, ?_, hd.2⟩
|
| 24 |
+
· intro i j; rw [hx, hx, norm_sub_rev]
|
| 25 |
+
· intro i; simp [hx]
|
| 26 |
+
|
| 27 |
+
lemma NegativeType.scale {d : Fin n → Fin n → ℝ} (hd : NegativeType d)
|
| 28 |
+
{a : ℝ} (ha : 0 ≤ a) : NegativeType (fun i j => a * d i j) := by
|
| 29 |
+
obtain ⟨x,hx⟩ := hd.1
|
| 30 |
+
refine ⟨⟨fun i => Real.sqrt a • x i, ?_⟩, ?_⟩
|
| 31 |
+
· intro i j
|
| 32 |
+
change a * d i j = _
|
| 33 |
+
rw [← smul_sub, norm_smul, mul_pow, Real.norm_eq_abs,
|
| 34 |
+
abs_of_nonneg (Real.sqrt_nonneg a), Real.sq_sqrt ha, hx]
|
| 35 |
+
· intro i j k
|
| 36 |
+
simpa [mul_add] using mul_le_mul_of_nonneg_left (hd.2 i j k) ha
|
| 37 |
+
|
| 38 |
+
lemma cutDist_negativeType (B : Finset (Fin n)) (hn : 0 < n) : NegativeType (cutDist B) := by
|
| 39 |
+
classical
|
| 40 |
+
let i0 : Fin n := ⟨0,hn⟩
|
| 41 |
+
refine ⟨⟨fun i => EuclideanSpace.single i0 (cutIndicator B i), ?_⟩,
|
| 42 |
+
cutDist_triangle B⟩
|
| 43 |
+
intro i j
|
| 44 |
+
change cutDist B i j = ‖PiLp.single (β := fun _ : Fin n => ℝ) 2 i0 (cutIndicator B i) -
|
| 45 |
+
PiLp.single (β := fun _ : Fin n => ℝ) 2 i0 (cutIndicator B j)‖ ^ 2
|
| 46 |
+
rw [← PiLp.single_sub]
|
| 47 |
+
change cutDist B i j = ‖EuclideanSpace.single i0
|
| 48 |
+
(cutIndicator B i - cutIndicator B j)‖ ^ 2
|
| 49 |
+
rw [PiLp.norm_single, Real.norm_eq_abs]
|
| 50 |
+
change cutDist B i j = cutDist B i j ^ 2
|
| 51 |
+
rcases cutDist_binary B i j with h | h <;> rw [h] <;> norm_num
|
| 52 |
+
|
| 53 |
+
lemma cut_nonempty (hn : 2 ≤ n) : Nonempty (Cut n) := by
|
| 54 |
+
classical
|
| 55 |
+
let i : Fin n := ⟨0,by omega⟩
|
| 56 |
+
refine ⟨⟨{i}, Finset.singleton_nonempty i, ?_⟩⟩
|
| 57 |
+
intro he
|
| 58 |
+
have hh := congrArg Finset.card he
|
| 59 |
+
simp only [Finset.card_singleton, Finset.card_univ, Fintype.card_fin] at hh
|
| 60 |
+
omega
|
| 61 |
+
|
| 62 |
+
lemma feasible_nonempty (hn : 2 ≤ n) : ∃ d : Fin n → Fin n → ℝ, Feasible d := by
|
| 63 |
+
classical
|
| 64 |
+
obtain ⟨B⟩ := cut_nonempty hn
|
| 65 |
+
refine ⟨fun i j => (cutDemand B.1)⁻¹ * cutDist B.1 i j, ?_, ?_⟩
|
| 66 |
+
· exact (cutDist_negativeType B.1 (by omega)).scale (inv_nonneg.mpr (cutDemand_pos B).le)
|
| 67 |
+
· rw [pairSum_smul, pairSum_cut, inv_mul_cancel₀ (cutDemand_pos B).ne']
|
| 68 |
+
|
| 69 |
+
lemma normalized_pair_le_one {d : Fin n → Fin n → ℝ} (hd : IsSemimetric d)
|
| 70 |
+
(hD : pairSum d = 1) (i j : Fin n) : d i j ≤ 1 := by
|
| 71 |
+
rcases lt_trichotomy i j with h | h | h
|
| 72 |
+
· simpa [hD] using le_pairSum hd.1 h
|
| 73 |
+
· subst j; rw [hd.2.2.1]; norm_num
|
| 74 |
+
· rw [hd.2.1 i j]; simpa [hD] using le_pairSum hd.1 h
|
| 75 |
+
|
| 76 |
+
lemma continuous_pairSum : Continuous (pairSum (n := n)) := by
|
| 77 |
+
unfold pairSum
|
| 78 |
+
apply continuous_finsetSum
|
| 79 |
+
intro i hi
|
| 80 |
+
apply continuous_finsetSum
|
| 81 |
+
intro j hj
|
| 82 |
+
split_ifs
|
| 83 |
+
· exact (continuous_apply j).comp (continuous_apply i)
|
| 84 |
+
· exact continuous_const
|
| 85 |
+
|
| 86 |
+
lemma semimetric_closed : IsClosed {d : Fin n → Fin n → ℝ | IsSemimetric d} := by
|
| 87 |
+
unfold IsSemimetric
|
| 88 |
+
simp only [ofPred_and, ofPred_forall]
|
| 89 |
+
refine IsClosed.inter ?_ (IsClosed.inter ?_ (IsClosed.inter ?_ ?_))
|
| 90 |
+
· apply isClosed_iInter; intro i; apply isClosed_iInter; intro j
|
| 91 |
+
exact isClosed_le continuous_const ((continuous_apply j).comp (continuous_apply i))
|
| 92 |
+
· apply isClosed_iInter; intro i; apply isClosed_iInter; intro j
|
| 93 |
+
exact isClosed_eq ((continuous_apply j).comp (continuous_apply i))
|
| 94 |
+
((continuous_apply i).comp (continuous_apply j))
|
| 95 |
+
· apply isClosed_iInter; intro i
|
| 96 |
+
exact isClosed_eq ((continuous_apply i).comp (continuous_apply i)) continuous_const
|
| 97 |
+
· apply isClosed_iInter; intro i; apply isClosed_iInter; intro j
|
| 98 |
+
apply isClosed_iInter; intro k
|
| 99 |
+
exact isClosed_le (by fun_prop) (by fun_prop)
|
| 100 |
+
|
| 101 |
+
lemma normalized_semimetric_compact :
|
| 102 |
+
IsCompact {d : Fin n → Fin n → ℝ | IsSemimetric d ∧ pairSum d = 1} := by
|
| 103 |
+
have hclosed : IsClosed {d : Fin n → Fin n → ℝ | IsSemimetric d ∧ pairSum d = 1} :=
|
| 104 |
+
semimetric_closed.inter (isClosed_eq continuous_pairSum continuous_const)
|
| 105 |
+
apply (isCompact_Icc : IsCompact (Icc (0 : Fin n → Fin n → ℝ) (fun _ _ => 1))).of_isClosed_subset hclosed
|
| 106 |
+
intro d hd
|
| 107 |
+
exact ⟨hd.1.1, normalized_pair_le_one hd.1 hd.2⟩
|
| 108 |
+
|
| 109 |
+
lemma objective_nonneg (C : Capacity n) {d : Fin n → Fin n → ℝ} (hd : IsSemimetric d) :
|
| 110 |
+
0 ≤ pairSum (fun i j => C.cap i j * d i j) :=
|
| 111 |
+
pairSum_nonneg (fun i j => mul_nonneg (C.nonneg i j) (hd.1 i j))
|
| 112 |
+
|
| 113 |
+
lemma objective_pos_of_cuts (C : Capacity n)
|
| 114 |
+
(hC : ∀ B : Cut n, cutDemand B.1 ≤ ∑ i ∈ B.1, ∑ j ∈ B.1ᶜ, C.cap i j)
|
| 115 |
+
{d : Fin n → Fin n → ℝ} (hd : IsSemimetric d) (hD : pairSum d = 1) :
|
| 116 |
+
0 < pairSum (fun i j => C.cap i j * d i j) := by
|
| 117 |
+
classical
|
| 118 |
+
have hnonneg := objective_nonneg C hd
|
| 119 |
+
by_contra! hnot
|
| 120 |
+
have hzero := le_antisymm hnot hnonneg
|
| 121 |
+
have hp (i j : Fin n) : C.cap i j * d i j = 0 := by
|
| 122 |
+
have h0 : 0 ≤ C.cap i j * d i j := mul_nonneg (C.nonneg i j) (hd.1 i j)
|
| 123 |
+
rcases lt_trichotomy i j with h | h | h
|
| 124 |
+
· have hh := le_pairSum (fun i j => mul_nonneg (C.nonneg i j) (hd.1 i j)) h
|
| 125 |
+
rw [hzero] at hh
|
| 126 |
+
exact le_antisymm hh h0
|
| 127 |
+
· subst j; simp [C.diagonal]
|
| 128 |
+
· rw [C.symm i j, hd.2.1 i j]
|
| 129 |
+
have hh := le_pairSum (fun i j => mul_nonneg (C.nonneg i j) (hd.1 i j)) h
|
| 130 |
+
rw [hzero] at hh
|
| 131 |
+
exact le_antisymm hh (mul_nonneg (C.nonneg _ _) (hd.1 _ _))
|
| 132 |
+
have hd0 : ∀ i j, d i j = 0 := by
|
| 133 |
+
intro i j
|
| 134 |
+
let B : Finset (Fin n) := Finset.univ.filter (fun k => d i k = 0)
|
| 135 |
+
have hi : i ∈ B := by simp [B, hd.2.2.1]
|
| 136 |
+
have hBall : B = Finset.univ := by
|
| 137 |
+
by_contra hne
|
| 138 |
+
let B' : Cut n := ⟨B, ⟨i,hi⟩, hne⟩
|
| 139 |
+
have hjump (u : Fin n) (hu : u ∈ B) (v : Fin n) (hv : v ∈ Bᶜ) : C.cap u v = 0 := by
|
| 140 |
+
have hu0 : d i u = 0 := (Finset.mem_filter.mp hu).2
|
| 141 |
+
have hv0 : d i v ≠ 0 := by simpa [B] using hv
|
| 142 |
+
have hduv : d u v ≠ 0 := by
|
| 143 |
+
intro huv
|
| 144 |
+
have ht := hd.2.2.2 i u v
|
| 145 |
+
rw [hu0,huv] at ht
|
| 146 |
+
exact hv0 (le_antisymm (by simpa using ht) (hd.1 i v))
|
| 147 |
+
exact (mul_eq_zero.mp (hp u v)).resolve_right hduv
|
| 148 |
+
have hsum : (∑ u ∈ B, ∑ v ∈ Bᶜ, C.cap u v) = 0 := by
|
| 149 |
+
apply Finset.sum_eq_zero
|
| 150 |
+
intro u hu
|
| 151 |
+
exact Finset.sum_eq_zero (fun v hv => hjump u hu v hv)
|
| 152 |
+
have hh := hC B'
|
| 153 |
+
change cutDemand B ≤ _ at hh
|
| 154 |
+
rw [hsum] at hh
|
| 155 |
+
exact (cutDemand_pos B').not_ge hh
|
| 156 |
+
have hj : j ∈ B := by rw [hBall]; exact Finset.mem_univ j
|
| 157 |
+
exact (Finset.mem_filter.mp hj).2
|
| 158 |
+
simp [pairSum,hd0] at hD
|
| 159 |
+
|
| 160 |
+
lemma glValue_pos_of_cuts (C : Capacity n) (hn : 2 ≤ n)
|
| 161 |
+
(hC : ∀ B : Cut n, cutDemand B.1 ≤ ∑ i ∈ B.1, ∑ j ∈ B.1ᶜ, C.cap i j) :
|
| 162 |
+
0 < glValue C := by
|
| 163 |
+
obtain ⟨d0,hd0⟩ := feasible_nonempty hn
|
| 164 |
+
have hobj : Continuous (fun d : Fin n → Fin n → ℝ => pairSum (fun i j => C.cap i j * d i j)) := by
|
| 165 |
+
apply continuous_pairSum.comp
|
| 166 |
+
apply continuous_pi; intro i; apply continuous_pi; intro j
|
| 167 |
+
exact continuous_const.mul ((continuous_apply j).comp (continuous_apply i))
|
| 168 |
+
obtain ⟨d,hd,hmin⟩ := normalized_semimetric_compact.exists_isMinOn
|
| 169 |
+
⟨d0,hd0.1.semimetric,hd0.2⟩ hobj.continuousOn
|
| 170 |
+
apply (objective_pos_of_cuts C hC hd.1 hd.2).trans_le
|
| 171 |
+
apply le_csInf
|
| 172 |
+
· exact ⟨_,d0,hd0,rfl⟩
|
| 173 |
+
· rintro b ⟨d',hd',rfl⟩
|
| 174 |
+
exact hmin ⟨hd'.1.semimetric,hd'.2⟩
|
| 175 |
+
|
| 176 |
+
lemma OPT_ge_one_of_cuts (C : Capacity n) (hn : 2 ≤ n)
|
| 177 |
+
(hC : ∀ B : Cut n, cutDemand B.1 ≤ ∑ i ∈ B.1, ∑ j ∈ B.1ᶜ, C.cap i j) :
|
| 178 |
+
1 ≤ OPT C := by
|
| 179 |
+
obtain ⟨B0⟩ := cut_nonempty hn
|
| 180 |
+
apply le_csInf
|
| 181 |
+
· exact ⟨_,B0.1,B0.2.1,B0.2.2,rfl⟩
|
| 182 |
+
· rintro b ⟨B,hB,hB',rfl⟩
|
| 183 |
+
unfold cutRatio
|
| 184 |
+
rw [← cutDemand_eq]
|
| 185 |
+
exact (one_le_div (cutDemand_pos ⟨B,hB,hB'⟩)).mpr (hC ⟨B,hB,hB'⟩)
|
| 186 |
+
|
| 187 |
+
end SemimetricBounds
|
| 188 |
+
|
| 189 |
+
end UniformSparsestCut
|
| 190 |
+
|
| 191 |
+
end
|
| 192 |
+
|
| 193 |
+
end OAI
|
lean/OAI/Combinatorics/SparsestCut/SliceCoefficients.lean
ADDED
|
@@ -0,0 +1,137 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import OAI.Combinatorics.SparsestCut.InterfaceStep
|
| 2 |
+
|
| 3 |
+
namespace OAI
|
| 4 |
+
|
| 5 |
+
universe u1 u2 u3 u4 u5
|
| 6 |
+
|
| 7 |
+
open scoped BigOperators Topology NNReal RealInnerProductSpace InnerProductSpace Matrix ContDiff ENNReal
|
| 8 |
+
open MeasureTheory ProbabilityTheory Set Filter Matrix
|
| 9 |
+
|
| 10 |
+
noncomputable section
|
| 11 |
+
|
| 12 |
+
namespace UniformSparsestCut.SliceCoefficients
|
| 13 |
+
open MeasureTheory Set
|
| 14 |
+
open scoped BigOperators Topology
|
| 15 |
+
variable {X : Type u1} {Z : Type u2} {I : Type u3} {K : Type u4} {A : Type u5} [NormedAddCommGroup X] [NormedSpace ℝ X]
|
| 16 |
+
[NormedAddCommGroup Z] [NormedSpace ℝ Z] [FiniteDimensional ℝ Z]
|
| 17 |
+
[MeasurableSpace Z] [BorelSpace Z] [Fintype I] [Fintype K] [Fintype A]
|
| 18 |
+
[DecidableEq I] [DecidableEq K]
|
| 19 |
+
|
| 20 |
+
lemma affine_hyperplane_null (L : Z →L[ℝ] ℝ) (hL : L ≠ 0) (t : ℝ)
|
| 21 |
+
(ν : Measure Z) [ν.IsAddHaarMeasure] : ν {z | L z=t}=0 := by
|
| 22 |
+
let H : AffineSubspace ℝ Z :=
|
| 23 |
+
{ carrier := {z | L z=t}
|
| 24 |
+
smul_vsub_vadd_mem' := by
|
| 25 |
+
intro c x y z hx hy hz
|
| 26 |
+
change L x=t at hx
|
| 27 |
+
change L y=t at hy
|
| 28 |
+
change L z=t at hz
|
| 29 |
+
change L (c • (x-y)+z)=t
|
| 30 |
+
simp only [map_add,map_smul,map_sub,smul_eq_mul,hx,hy,hz]
|
| 31 |
+
ring }
|
| 32 |
+
have ht : H ≠ ⊤ := by
|
| 33 |
+
intro he
|
| 34 |
+
have hzero : (0:Z) ∈ H := by rw [he]; trivial
|
| 35 |
+
change L 0=t at hzero
|
| 36 |
+
rw [map_zero] at hzero
|
| 37 |
+
apply hL
|
| 38 |
+
ext x
|
| 39 |
+
have hx : x ∈ H := by rw [he]; trivial
|
| 40 |
+
change L x=t at hx
|
| 41 |
+
simpa [← hzero] using hx
|
| 42 |
+
exact Measure.addHaar_affineSubspace ν H ht
|
| 43 |
+
|
| 44 |
+
lemma thresholds_injective_ae (L : I → X →L[ℝ] ℝ) (B : I → Z →L[ℝ] ℝ)
|
| 45 |
+
(q : I → K → ℝ) (hq : ∀ i, Function.Injective (q i))
|
| 46 |
+
(hB : Function.Injective B) (ν : Measure Z) [ν.IsAddHaarMeasure]
|
| 47 |
+
(μ : Measure Z) (hμ : μ ≪ ν) (y : X) :
|
| 48 |
+
∀ᵐ z ∂μ, Function.Injective (fun p : I × K => L p.1 y+B p.1 z+q p.1 p.2) := by
|
| 49 |
+
have hp (p r : I × K) (hpr : p ≠ r) :
|
| 50 |
+
∀ᵐ z ∂μ, L p.1 y+B p.1 z+q p.1 p.2 ≠ L r.1 y+B r.1 z+q r.1 r.2 := by
|
| 51 |
+
by_cases hi : p.1=r.1
|
| 52 |
+
· filter_upwards with z hz
|
| 53 |
+
have hk : p.2=r.2 := hq p.1 (by rw [← hi] at hz; linarith)
|
| 54 |
+
exact hpr (Prod.ext hi hk)
|
| 55 |
+
· have hn : B p.1-B r.1 ≠ 0 := sub_ne_zero.mpr (fun he => hi (hB he))
|
| 56 |
+
have hnul := affine_hyperplane_null (B p.1-B r.1) hn
|
| 57 |
+
(L r.1 y+q r.1 r.2-(L p.1 y+q p.1 p.2)) ν
|
| 58 |
+
have hae : ∀ᵐ z ∂ν, (B p.1-B r.1) z ≠ L r.1 y+q r.1 r.2-(L p.1 y+q p.1 p.2) := by
|
| 59 |
+
rw [ae_iff]; simpa only [not_not] using hnul
|
| 60 |
+
filter_upwards [hμ.ae_le hae] with z hz he
|
| 61 |
+
apply hz
|
| 62 |
+
simp only [_root_.sub_apply]
|
| 63 |
+
linarith
|
| 64 |
+
have ha (p r : I × K) : ∀ᵐ z ∂μ,
|
| 65 |
+
L p.1 y+B p.1 z+q p.1 p.2 = L r.1 y+B r.1 z+q r.1 r.2 → p=r := by
|
| 66 |
+
by_cases hpr : p=r
|
| 67 |
+
· exact ae_of_all _ (fun _ _ => hpr)
|
| 68 |
+
· filter_upwards [hp p r hpr] with z hz he using (hz he).elim
|
| 69 |
+
exact ae_all_iff.mpr (fun p => ae_all_iff.mpr (ha p))
|
| 70 |
+
|
| 71 |
+
omit [NormedAddCommGroup Z] [NormedSpace ℝ Z] [FiniteDimensional ℝ Z] [BorelSpace Z] in
|
| 72 |
+
|
| 73 |
+
lemma family_derivative (L : I → X →L[ℝ] ℝ) (b : I × K → Z → ℝ)
|
| 74 |
+
(hb : ∀ p, Measurable (b p)) (F : Finset (I × K) → ℝ)
|
| 75 |
+
{φ : ℝ → ℝ} (hφ : Integrable φ) (hc : Continuous φ)
|
| 76 |
+
{M C : ℝ} (hM0 : 0 ≤ M) (hC : 0 ≤ C)
|
| 77 |
+
(hM : ∀ a, |F a| ≤ M) (hφC : ∀ x, |φ x| ≤ C)
|
| 78 |
+
(μ : Measure Z) [IsFiniteMeasure μ] (y : X)
|
| 79 |
+
(hi : ∀ᵐ z ∂μ, Function.Injective (fun p : I × K => L p.1 y+b p z)) :
|
| 80 |
+
HasFDerivAt (fun y => ∫ z, (∫ x, φ x*F (Finset.univ.filter (fun p => L p.1 y+b p z<x))) ∂μ)
|
| 81 |
+
(∑ i, (∑ k, ∫ z, -(φ (L i y+b (i,k) z)*
|
| 82 |
+
(F (Finset.univ.filter (fun p => L p.1 y+b p z ≤ L i y+b (i,k) z))-
|
| 83 |
+
F (Finset.univ.filter (fun p => L p.1 y+b p z < L i y+b (i,k) z)))) ∂μ) • L i) y := by
|
| 84 |
+
have hd := InterfaceStep.averaged_threshold_derivative Finset.univ (fun p : I × K => L p.1)
|
| 85 |
+
b hb F hφ hc hM0 hC hM hφC μ y (hi.mono (fun z hz => hz.injOn))
|
| 86 |
+
rw [Fintype.sum_prod_type] at hd
|
| 87 |
+
simp only [← Finset.sum_smul] at hd
|
| 88 |
+
exact hd
|
| 89 |
+
|
| 90 |
+
omit [NormedAddCommGroup Z] [NormedSpace ℝ Z] [FiniteDimensional ℝ Z] [BorelSpace Z] [DecidableEq K] in
|
| 91 |
+
|
| 92 |
+
lemma coefficient_budget (μ : Measure Z) [IsProbabilityMeasure μ]
|
| 93 |
+
(w : K → Z → ℝ) (Δ : K → Z → A → ℝ) {J B : ℝ}
|
| 94 |
+
(hJ : 0 ≤ J) (hw : ∀ k z, 0 ≤ w k z)
|
| 95 |
+
(_hiw : ∀ k, Integrable (w k) μ)
|
| 96 |
+
(hid : ∀ k a, Integrable (fun z => w k z*Δ k z a) μ)
|
| 97 |
+
(hj : ∀ᵐ z ∂μ, ∀ k, w k z ≠ 0 → ∑ a, |Δ k z a| ≤ J)
|
| 98 |
+
(hs : ∀ᵐ z ∂μ, ∑ k, w k z ≤ B) :
|
| 99 |
+
(∑ a, |∑ k, ∫ z, -(w k z*Δ k z a) ∂μ|) ≤ J*B := by
|
| 100 |
+
have hle (a : A) : |∑ k, ∫ z, -(w k z*Δ k z a) ∂μ| ≤
|
| 101 |
+
∑ k, ∫ z, w k z*|Δ k z a| ∂μ := by
|
| 102 |
+
calc
|
| 103 |
+
_ ≤ ∑ k, |∫ z, -(w k z*Δ k z a) ∂μ| := Finset.abs_sum_le_sum_abs _ _
|
| 104 |
+
_ ≤ _ := Finset.sum_le_sum (fun k _ => by
|
| 105 |
+
simpa only [Real.norm_eq_abs,abs_neg,abs_mul,abs_of_nonneg (hw k _)] using
|
| 106 |
+
norm_integral_le_integral_norm (fun z => -(w k z*Δ k z a)))
|
| 107 |
+
have hia (k : K) (a : A) : Integrable (fun z => w k z*|Δ k z a|) μ := by
|
| 108 |
+
simpa only [abs_mul,abs_of_nonneg (hw k _)] using (hid k a).abs
|
| 109 |
+
have hisum : Integrable (fun z => ∑ k, w k z*(∑ a, |Δ k z a|)) μ := by
|
| 110 |
+
simp_rw [Finset.mul_sum]
|
| 111 |
+
exact integrable_finsetSum _ (fun k _ => integrable_finsetSum _ (fun a _ => hia k a))
|
| 112 |
+
calc
|
| 113 |
+
_ ≤ ∑ a, ∑ k, ∫ z, w k z*|Δ k z a| ∂μ := Finset.sum_le_sum (fun a _ => hle a)
|
| 114 |
+
_ = ∫ z, ∑ k, w k z*(∑ a, |Δ k z a|) ∂μ := by
|
| 115 |
+
rw [Finset.sum_comm]
|
| 116 |
+
simp_rw [Finset.mul_sum]
|
| 117 |
+
rw [integral_finsetSum _ (fun k _ => integrable_finsetSum _ (fun a _ => hia k a))]
|
| 118 |
+
apply Finset.sum_congr rfl
|
| 119 |
+
intro k _
|
| 120 |
+
exact (integral_finsetSum _ (fun a _ => hia k a)).symm
|
| 121 |
+
_ ≤ ∫ z, J*B ∂μ := by
|
| 122 |
+
apply integral_mono_ae hisum (integrable_const _)
|
| 123 |
+
filter_upwards [hj,hs] with z hz hzB
|
| 124 |
+
calc
|
| 125 |
+
_ ≤ ∑ k, w k z*J := Finset.sum_le_sum (fun k _ => by
|
| 126 |
+
by_cases hk : w k z=0
|
| 127 |
+
· simp [hk]
|
| 128 |
+
· exact mul_le_mul_of_nonneg_left (hz k hk) (hw k z))
|
| 129 |
+
_ = J*∑ k, w k z := by rw [← Finset.sum_mul]; ring
|
| 130 |
+
_ ≤ J*B := mul_le_mul_of_nonneg_left hzB hJ
|
| 131 |
+
_ = J*B := by simp
|
| 132 |
+
|
| 133 |
+
end UniformSparsestCut.SliceCoefficients
|
| 134 |
+
|
| 135 |
+
end
|
| 136 |
+
|
| 137 |
+
end OAI
|
lean/OAI/Combinatorics/SparsestCut/SliceIntegration.lean
ADDED
|
@@ -0,0 +1,98 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import OAI.Combinatorics.SparsestCut.LatticeDensity
|
| 2 |
+
|
| 3 |
+
namespace OAI
|
| 4 |
+
|
| 5 |
+
universe u1 u2 u3 u4
|
| 6 |
+
|
| 7 |
+
open scoped BigOperators Topology NNReal RealInnerProductSpace InnerProductSpace Matrix ContDiff ENNReal
|
| 8 |
+
open MeasureTheory ProbabilityTheory Set Filter Matrix
|
| 9 |
+
|
| 10 |
+
noncomputable section
|
| 11 |
+
|
| 12 |
+
namespace UniformSparsestCut.ProductSlice
|
| 13 |
+
open MeasureTheory Set
|
| 14 |
+
open scoped BigOperators
|
| 15 |
+
noncomputable section
|
| 16 |
+
variable {Z : Type u1} {I : Type u2} {K : Type u3} {A : Type u4} [NormedAddCommGroup Z] [NormedSpace ℝ Z]
|
| 17 |
+
[FiniteDimensional ℝ Z] [MeasureSpace Z] [BorelSpace Z] [(volume : Measure Z).IsAddHaarMeasure]
|
| 18 |
+
[Fintype I] [Fintype K] [Fintype A] [DecidableEq I] [DecidableEq K]
|
| 19 |
+
|
| 20 |
+
def jump (B : I → Z →L[ℝ] ℝ) (q : I → K → ℝ) (F : Finset (I × K) → A → ℝ)
|
| 21 |
+
(θ : ℝ × Z) (i : I) (k : K) (z : Z) (α : A) : ℝ :=
|
| 22 |
+
F (Finset.univ.filter (fun p => form (B p.1) θ+B p.1 z+q p.1 p.2 ≤ form (B i) θ+B i z+q i k)) α-
|
| 23 |
+
F (Finset.univ.filter (fun p => form (B p.1) θ+B p.1 z+q p.1 p.2 < form (B i) θ+B i z+q i k)) α
|
| 24 |
+
omit [FiniteDimensional ℝ Z] [(volume : Measure Z).IsAddHaarMeasure] [Fintype A] in
|
| 25 |
+
lemma jump_measurable (B : I → Z →L[ℝ] ℝ) (q : I → K → ℝ) (F : Finset (I × K) → A → ℝ)
|
| 26 |
+
(θ : ℝ × Z) (i : I) (k : K) (α : A) : Measurable (fun z => jump B q F θ i k z α) := by
|
| 27 |
+
unfold jump
|
| 28 |
+
apply Measurable.sub
|
| 29 |
+
· apply InterfaceStep.measurable_filter_apply Finset.univ _ _ (fun a => F a α)
|
| 30 |
+
intro p
|
| 31 |
+
exact measurableSet_le ((measurable_const.add (B p.1).measurable).add_const _)
|
| 32 |
+
((measurable_const.add (B i).measurable).add_const _)
|
| 33 |
+
· apply InterfaceStep.measurable_filter_apply Finset.univ _ _ (fun a => F a α)
|
| 34 |
+
intro p
|
| 35 |
+
exact measurableSet_lt ((measurable_const.add (B p.1).measurable).add_const _)
|
| 36 |
+
((measurable_const.add (B i).measurable).add_const _)
|
| 37 |
+
|
| 38 |
+
omit [FiniteDimensional ℝ Z] [MeasureSpace Z] [BorelSpace Z] [(volume : Measure Z).IsAddHaarMeasure] [Fintype A] [DecidableEq I] [DecidableEq K] in
|
| 39 |
+
lemma jump_bound (B : I → Z →L[ℝ] ℝ) (q : I → K → ℝ) (F : Finset (I × K) → A → ℝ)
|
| 40 |
+
{M : ℝ} (hM : ∀ a α, |F a α|≤M) (θ : ℝ × Z) (i : I) (k : K) (z : Z) (α : A) :
|
| 41 |
+
|jump B q F θ i k z α|≤2*M := by
|
| 42 |
+
unfold jump
|
| 43 |
+
exact (abs_sub _ _).trans (add_le_add (hM _ α) (hM _ α) |>.trans (by ring_nf; rfl))
|
| 44 |
+
|
| 45 |
+
omit [FiniteDimensional ℝ Z] [(volume : Measure Z).IsAddHaarMeasure] in
|
| 46 |
+
|
| 47 |
+
lemma common_coefficient_budget (B : I → Z →L[ℝ] ℝ) (s : Finset ℤ)
|
| 48 |
+
(pivot : I → ℝ) (hp : ∀ i, pivot i≠0) {τ : ℝ} (hτ : 0<τ)
|
| 49 |
+
(F : Finset (I × s) → A → ℝ) {M C J : ℝ}
|
| 50 |
+
(_hM0 : 0≤M) (hC : 0≤C) (hJ : 0≤J) (hM : ∀ a α, |F a α|≤M)
|
| 51 |
+
{φ φ' : ℝ → ℝ} (hd : ∀ t, HasDerivAt φ (φ' t) t) (hn : ∀ t, 0≤φ t)
|
| 52 |
+
(hi : Integrable φ) (hi' : Integrable φ') (h1 : ∫ t, φ t=1) (hφC : ∀ t, |φ t|≤C)
|
| 53 |
+
{ψ : Z → ℝ} (hmψ : Measurable ψ) (hnψ : ∀ z, 0≤ψ z) (hiψ : Integrable ψ) (hψ1 : ∫ z, ψ z=1)
|
| 54 |
+
(θ : ℝ × Z) (i : I)
|
| 55 |
+
(hj : ∀ᵐ z ∂law ψ volume, ∀ k : s,
|
| 56 |
+
φ (form (B i) θ+B i z-(k:ℤ)*τ/pivot i)≠0 →
|
| 57 |
+
(∑ α, |jump B (fun i (k : s) => -((k:ℤ)*τ/pivot i)) F θ i k z α|)≤J)
|
| 58 |
+
(hsmall : τ/|pivot i| *(∫ t, |φ' t|)≤1) :
|
| 59 |
+
(∑ α, |(pivot i)⁻¹ * ∑ k : s, ∫ z,
|
| 60 |
+
-(φ (form (B i) θ+B i z-(k:ℤ)*τ/pivot i)*
|
| 61 |
+
jump B (fun i (k : s) => -((k:ℤ)*τ/pivot i)) F θ i k z α) ∂law ψ volume|) ≤ 2*J/τ := by
|
| 62 |
+
let μ := law ψ volume
|
| 63 |
+
let q : I → s → ℝ := fun i (k : s) => -((k:ℤ)*τ/pivot i)
|
| 64 |
+
let w : s → Z → ℝ := fun k z => φ (form (B i) θ+B i z-(k:ℤ)*τ/pivot i)
|
| 65 |
+
have : IsProbabilityMeasure μ := law_probability hmψ hnψ volume hiψ hψ1
|
| 66 |
+
have hcφ : Continuous φ := continuous_iff_continuousAt.mpr (fun t => (hd t).continuousAt)
|
| 67 |
+
have hw (k : s) : Measurable (w k) :=
|
| 68 |
+
hcφ.measurable.comp ((measurable_const.add (B i).measurable).sub_const _)
|
| 69 |
+
have hiw (k : s) : Integrable (w k) μ :=
|
| 70 |
+
(integrable_const C).mono' (hw k).aestronglyMeasurable (ae_of_all _ (fun z => hφC _))
|
| 71 |
+
have hid (k : s) (α : A) : Integrable (fun z => w k z*jump B q F θ i k z α) μ := by
|
| 72 |
+
apply (integrable_const (C*(2*M))).mono' ((hw k).mul (jump_measurable B q F θ i k α)).aestronglyMeasurable
|
| 73 |
+
filter_upwards with z
|
| 74 |
+
simp only [Pi.mul_apply, Real.norm_eq_abs,abs_mul]
|
| 75 |
+
exact mul_le_mul (hφC _) (jump_bound B q F hM θ i k z α) (abs_nonneg _) hC
|
| 76 |
+
have hs (z : Z) : (∑ k : s, w k z)≤2*|pivot i|/τ := by
|
| 77 |
+
have h := LatticeDensity.affine_lattice_bound hd hn hi hi' h1 hτ (hp i) (form (B i) θ+B i z) s
|
| 78 |
+
rw [← Finset.sum_coe_sort] at h
|
| 79 |
+
have hp0 : 0 < |pivot i| := abs_pos.mpr (hp i)
|
| 80 |
+
have hmul : τ/|pivot i| *(∑ k : s, w k z)≤2 := by exact h.trans (by linarith)
|
| 81 |
+
apply (le_div_iff₀ hτ).mpr
|
| 82 |
+
have hh := mul_le_mul_of_nonneg_right hmul hp0.le
|
| 83 |
+
have he : (τ/|pivot i| *(∑ k : s, w k z))*|pivot i| = (∑ k : s, w k z)*τ := by
|
| 84 |
+
field_simp
|
| 85 |
+
rwa [he] at hh
|
| 86 |
+
have hb := SliceCoefficients.coefficient_budget μ w (jump B q F θ i) hJ
|
| 87 |
+
(fun k z => hn _) hiw hid hj (ae_of_all _ hs)
|
| 88 |
+
simp_rw [abs_mul,abs_inv,← Finset.mul_sum]
|
| 89 |
+
calc
|
| 90 |
+
_ ≤ |pivot i|⁻¹*(J*(2*|pivot i|/τ)) := mul_le_mul_of_nonneg_left hb (inv_nonneg.mpr (abs_nonneg _))
|
| 91 |
+
_ = _ := by field_simp [abs_ne_zero.mpr (hp i)]
|
| 92 |
+
|
| 93 |
+
end
|
| 94 |
+
end UniformSparsestCut.ProductSlice
|
| 95 |
+
|
| 96 |
+
end
|
| 97 |
+
|
| 98 |
+
end OAI
|
lean/OAI/Combinatorics/SparsestCut/Smoothing.lean
ADDED
|
@@ -0,0 +1,128 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import OAI.Combinatorics.SparsestCut.CellInterface
|
| 2 |
+
|
| 3 |
+
namespace OAI
|
| 4 |
+
|
| 5 |
+
universe u1 u2 u3
|
| 6 |
+
|
| 7 |
+
open scoped BigOperators Topology NNReal RealInnerProductSpace InnerProductSpace Matrix ContDiff ENNReal
|
| 8 |
+
open MeasureTheory ProbabilityTheory Set Filter Matrix
|
| 9 |
+
|
| 10 |
+
noncomputable section
|
| 11 |
+
|
| 12 |
+
namespace UniformSparsestCut.ProductSlice
|
| 13 |
+
open MeasureTheory Set CellInterface
|
| 14 |
+
open scoped BigOperators
|
| 15 |
+
noncomputable section
|
| 16 |
+
variable {Z : Type u1} {I : Type u2} {A : Type u3} [NormedAddCommGroup Z] [NormedSpace ℝ Z]
|
| 17 |
+
[FiniteDimensional ℝ Z] [MeasureSpace Z] [BorelSpace Z] [(volume : Measure Z).IsAddHaarMeasure]
|
| 18 |
+
[Fintype I] [Fintype A] [DecidableEq I]
|
| 19 |
+
|
| 20 |
+
def ell (B : I → Z →L[ℝ] ℝ) (pivot : I → ℝ) (i : I) : (ℝ × Z) →L[ℝ] ℝ :=
|
| 21 |
+
pivot i • form (B i)
|
| 22 |
+
omit [FiniteDimensional ℝ Z] [MeasureSpace Z] [BorelSpace Z] [(volume : Measure Z).IsAddHaarMeasure] [Fintype I] [DecidableEq I] in
|
| 23 |
+
@[simp] lemma ell_apply (B : I → Z →L[ℝ] ℝ) (pivot : I → ℝ) (i : I) (x : ℝ × Z) :
|
| 24 |
+
ell B pivot i x=pivot i*(x.1-B i x.2) := rfl
|
| 25 |
+
|
| 26 |
+
omit [FiniteDimensional ℝ Z] [MeasureSpace Z] [BorelSpace Z] [(volume : Measure Z).IsAddHaarMeasure] [Fintype I] [DecidableEq I] in
|
| 27 |
+
lemma normalized_ell (B : I → Z →L[ℝ] ℝ) (pivot : I → ℝ) (hp : ∀ i, pivot i≠0)
|
| 28 |
+
(τ : ℝ) (i : I) (k : ℤ) (x : ℝ × Z) :
|
| 29 |
+
(ell B pivot i x-(k:ℝ)*τ)/pivot i=form (B i) x-(k:ℝ)*τ/pivot i := by
|
| 30 |
+
simp only [ell,_root_.smul_apply,smul_eq_mul,sub_div,mul_div_cancel_left₀ _ (hp i)]
|
| 31 |
+
|
| 32 |
+
omit [Fintype A] [FiniteDimensional ℝ Z] [MeasureSpace Z] [BorelSpace Z] [(volume : Measure Z).IsAddHaarMeasure] [DecidableEq I] in
|
| 33 |
+
lemma cell_eq_extension (B : I → Z →L[ℝ] ℝ) (pivot : I → ℝ) (hp : ∀ i, pivot i≠0)
|
| 34 |
+
(τ : ℝ) (s : Finset ℤ) (U : Set (ℝ × Z)) (F : LabelVertex (ell B pivot) τ U → A → ℝ)
|
| 35 |
+
(x : ℝ × Z) (α : A) :
|
| 36 |
+
cell B (fun i (k : s) => -((k:ℤ)*τ/pivot i))
|
| 37 |
+
(fun P => extension (ell B pivot) pivot τ s U F P α) x =
|
| 38 |
+
extension (ell B pivot) pivot τ s U F (pattern (ell B pivot) pivot τ s x) α := by
|
| 39 |
+
unfold cell pattern
|
| 40 |
+
simp_rw [normalized_ell B pivot hp]
|
| 41 |
+
simp only [sub_eq_add_neg]
|
| 42 |
+
|
| 43 |
+
def eventPoint (B : I → Z →L[ℝ] ℝ) (pivot : I → ℝ) (τ : ℝ)
|
| 44 |
+
(θ : ℝ × Z) (i : I) (k : ℤ) (z : Z) : ℝ × Z :=
|
| 45 |
+
θ-(form (B i) θ+B i z-(k:ℝ)*τ/pivot i,z)
|
| 46 |
+
|
| 47 |
+
omit [FiniteDimensional ℝ Z] [MeasureSpace Z] [BorelSpace Z] [(volume : Measure Z).IsAddHaarMeasure] [Fintype I] [DecidableEq I] in
|
| 48 |
+
lemma event_form (B : I → Z →L[ℝ] ℝ) (pivot : I → ℝ) (τ : ℝ)
|
| 49 |
+
(θ : ℝ × Z) (i : I) (k : ℤ) (z : Z) (j : I) :
|
| 50 |
+
form (B j) (eventPoint B pivot τ θ i k z) =
|
| 51 |
+
form (B j) θ+B j z-(form (B i) θ+B i z-(k:ℝ)*τ/pivot i) := by
|
| 52 |
+
simp only [eventPoint,form_apply,map_sub]
|
| 53 |
+
ring
|
| 54 |
+
omit [FiniteDimensional ℝ Z] [MeasureSpace Z] [BorelSpace Z] [(volume : Measure Z).IsAddHaarMeasure] [Fintype I] [DecidableEq I] in
|
| 55 |
+
lemma event_on_plane (B : I → Z →L[ℝ] ℝ) (pivot : I → ℝ) (hp : ∀ i, pivot i≠0)
|
| 56 |
+
(τ : ℝ) (θ : ℝ × Z) (i : I) (k : ℤ) (z : Z) :
|
| 57 |
+
ell B pivot i (eventPoint B pivot τ θ i k z)=(k:ℝ)*τ := by
|
| 58 |
+
change pivot i*form (B i) _=_
|
| 59 |
+
rw [event_form]
|
| 60 |
+
field_simp [hp i]
|
| 61 |
+
ring
|
| 62 |
+
|
| 63 |
+
lemma event_other_regular (B : I → Z →L[ℝ] ℝ) (hB : Function.Injective B)
|
| 64 |
+
(pivot : I → ℝ) (hp : ∀ i, pivot i≠0) (τ : ℝ) (θ : ℝ × Z) (i : I) (k : ℤ)
|
| 65 |
+
(μ : Measure Z) (hμ : μ ≪ volume) :
|
| 66 |
+
∀ᵐ z ∂μ, ∀ j, j≠i → ∀ l : ℤ, ell B pivot j (eventPoint B pivot τ θ i k z)≠(l:ℝ)*τ := by
|
| 67 |
+
apply ae_all_iff.mpr
|
| 68 |
+
intro j
|
| 69 |
+
by_cases hj : j=i
|
| 70 |
+
· simp [hj]
|
| 71 |
+
have hpair (l : ℤ) : ∀ᵐ z ∂μ, ell B pivot j (eventPoint B pivot τ θ i k z)≠(l:ℝ)*τ := by
|
| 72 |
+
have hn : B j-B i≠0 := sub_ne_zero.mpr (fun he => hj (hB he))
|
| 73 |
+
let t := (l:ℝ)*τ/pivot j-(k:ℝ)*τ/pivot i-form (B j) θ+form (B i) θ
|
| 74 |
+
have hnul := SliceCoefficients.affine_hyperplane_null (B j-B i) hn t volume
|
| 75 |
+
have hae : ∀ᵐ z ∂volume, (B j-B i) z≠t := by rw [ae_iff]; simpa only [not_not] using hnul
|
| 76 |
+
filter_upwards [hμ.ae_le hae] with z hz he
|
| 77 |
+
apply hz
|
| 78 |
+
change pivot j*form (B j) _=_ at he
|
| 79 |
+
rw [event_form] at he
|
| 80 |
+
have he' : form (B j) θ+B j z-(form (B i) θ+B i z-(k:ℝ)*τ/pivot i)=(l:ℝ)*τ/pivot j :=
|
| 81 |
+
(eq_div_iff (hp j)).mpr (by nlinarith [he])
|
| 82 |
+
simp only [_root_.sub_apply]
|
| 83 |
+
dsimp only [t]
|
| 84 |
+
linarith
|
| 85 |
+
filter_upwards [ae_all_iff.mpr hpair] with z hz _ using hz
|
| 86 |
+
|
| 87 |
+
omit [Fintype A] [FiniteDimensional ℝ Z] [MeasureSpace Z] [BorelSpace Z] [(volume : Measure Z).IsAddHaarMeasure] [DecidableEq I] in
|
| 88 |
+
lemma jump_eq_traces (B : I → Z →L[ℝ] ℝ) (pivot : I → ℝ) (hp : ∀ i, pivot i≠0)
|
| 89 |
+
(τ : ℝ) (s : Finset ℤ) (U : Set (ℝ × Z)) (F : LabelVertex (ell B pivot) τ U → A → ℝ)
|
| 90 |
+
(θ : ℝ × Z) (i : I) (k : s) (z : Z) (α : A) :
|
| 91 |
+
jump B (fun i (k : s) => -((k:ℤ)*τ/pivot i))
|
| 92 |
+
(extension (ell B pivot) pivot τ s U F) θ i k z α =
|
| 93 |
+
extension (ell B pivot) pivot τ s U F
|
| 94 |
+
(weakPattern (ell B pivot) pivot τ s (eventPoint B pivot τ θ i k.val z)) α-
|
| 95 |
+
extension (ell B pivot) pivot τ s U F
|
| 96 |
+
(pattern (ell B pivot) pivot τ s (eventPoint B pivot τ θ i k.val z)) α := by
|
| 97 |
+
unfold jump weakPattern pattern
|
| 98 |
+
congr 2 <;> apply Finset.filter_congr <;> intro p _ <;>
|
| 99 |
+
rw [normalized_ell B pivot hp,event_form] <;> constructor <;> intro h <;> linarith
|
| 100 |
+
|
| 101 |
+
lemma actual_jump_budget (B : I → Z →L[ℝ] ℝ) (hB : Function.Injective B)
|
| 102 |
+
(pivot : I → ℝ) (hp : ∀ i, pivot i≠0) {τ : ℝ} (hτ : 0<τ) (s : Finset ℤ)
|
| 103 |
+
{U : Set (ℝ × Z)} (hU : IsOpen U)
|
| 104 |
+
(hb : ∀ x∈U, regular (ell B pivot) τ x → ∀ i, label (ell B pivot) τ x i∈s)
|
| 105 |
+
(F : LabelVertex (ell B pivot) τ U → A → ℝ) {J : ℝ}
|
| 106 |
+
(hF : ∀ (vp vm : LabelVertex (ell B pivot) τ U) (i : I), vp.val i=vm.val i+1 →
|
| 107 |
+
(∀ j, j≠i → vp.val j=vm.val j) → ∑ a, |F vp a-F vm a|≤J)
|
| 108 |
+
(φ : ℝ → ℝ) (ψ : Z → ℝ) (θ : ℝ × Z) (i : I)
|
| 109 |
+
(hsupp : ∀ᵐ z ∂law ψ volume, ∀ k : s,
|
| 110 |
+
φ (form (B i) θ+B i z-(k:ℤ)*τ/pivot i)≠0 → eventPoint B pivot τ θ i k.val z∈U) :
|
| 111 |
+
∀ᵐ z ∂law ψ volume, ∀ k : s,
|
| 112 |
+
φ (form (B i) θ+B i z-(k:ℤ)*τ/pivot i)≠0 →
|
| 113 |
+
∑ a, |jump B (fun i (k : s) => -((k:ℤ)*τ/pivot i))
|
| 114 |
+
(extension (ell B pivot) pivot τ s U F) θ i k z a|≤J := by
|
| 115 |
+
have hae := ae_all_iff.mpr (fun k : s => event_other_regular B hB pivot hp τ θ i k.val _ (law_ac ψ volume))
|
| 116 |
+
filter_upwards [hsupp,hae] with z hz hreg k hk
|
| 117 |
+
simp_rw [jump_eq_traces B pivot hp]
|
| 118 |
+
apply interface_jump_bound (ell B pivot) pivot hp hτ s hU hb F hF (hz k hk) i k.val
|
| 119 |
+
(event_on_plane B pivot hp τ θ i k.val z) (hreg k) (pivot i,0)
|
| 120 |
+
simp only [ell_apply,map_zero,sub_zero]
|
| 121 |
+
exact mul_self_pos.mpr (hp i)
|
| 122 |
+
|
| 123 |
+
end
|
| 124 |
+
end UniformSparsestCut.ProductSlice
|
| 125 |
+
|
| 126 |
+
end
|
| 127 |
+
|
| 128 |
+
end OAI
|
lean/OAI/Combinatorics/SparsestCut/TriangleRepair.lean
ADDED
|
@@ -0,0 +1,473 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import OAI.Combinatorics.SparsestCut.ChartAngles
|
| 2 |
+
|
| 3 |
+
namespace OAI
|
| 4 |
+
|
| 5 |
+
universe u1 u2 u3 u4 u5 u6 u7
|
| 6 |
+
|
| 7 |
+
open scoped BigOperators Topology NNReal RealInnerProductSpace InnerProductSpace Matrix ContDiff ENNReal
|
| 8 |
+
open MeasureTheory ProbabilityTheory Set Filter Matrix
|
| 9 |
+
|
| 10 |
+
noncomputable section
|
| 11 |
+
|
| 12 |
+
namespace UniformSparsestCut.TriangleRepair
|
| 13 |
+
variable {ι : Type u1} [Fintype ι]
|
| 14 |
+
lemma exp_distance_intervalIntegrable {d r : ℝ} (hd : 0 ≤ d) (hr : 0 ≤ r) :
|
| 15 |
+
IntervalIntegrable (fun l => Real.exp (-d / l)) volume 0 r := by
|
| 16 |
+
rw [intervalIntegrable_iff_integrableOn_Ioc_of_le hr]
|
| 17 |
+
apply (integrable_const (1 : ℝ)).mono'
|
| 18 |
+
· exact (Real.measurable_exp.comp (measurable_const.div measurable_id)).aestronglyMeasurable
|
| 19 |
+
· filter_upwards [ae_restrict_mem measurableSet_Ioc] with l hl
|
| 20 |
+
rw [Real.norm_eq_abs, abs_of_pos (Real.exp_pos _)]
|
| 21 |
+
exact Real.exp_le_one_iff.mpr (div_nonpos_of_nonpos_of_nonneg (neg_nonpos.mpr hd) hl.1.le)
|
| 22 |
+
|
| 23 |
+
lemma min_posSemidef (u : ι → ℝ) (hu : ∀ i, 0 ≤ u i) :
|
| 24 |
+
(Matrix.of (fun i j => min (u i) (u j))).PosSemidef := by
|
| 25 |
+
classical
|
| 26 |
+
let R : ℝ := ∑ i, u i
|
| 27 |
+
have hR : 0 ≤ R := Finset.sum_nonneg (fun i _ => hu i)
|
| 28 |
+
have huR (i : ι) : u i ≤ R := Finset.single_le_sum (fun j _ => hu j) (Finset.mem_univ i)
|
| 29 |
+
let K : ℝ → Matrix ι ι ℝ := fun l => Matrix.of fun i j =>
|
| 30 |
+
(if l ≤ u i then 1 else 0) * (if l ≤ u j then 1 else 0)
|
| 31 |
+
have hk (l : ℝ) : (K l).PosSemidef := by
|
| 32 |
+
convert Matrix.posSemidef_vecMulVec_self_star
|
| 33 |
+
(fun i => if l ≤ u i then (1 : ℝ) else 0) using 1 ; try rfl
|
| 34 |
+
have hki (i j : ι) : (fun l => K l i j) =
|
| 35 |
+
(Set.Iic (min (u i) (u j))).indicator (fun _ => (1 : ℝ)) := by
|
| 36 |
+
funext l
|
| 37 |
+
simp only [K, Matrix.of_apply, Set.indicator_apply, Set.mem_Iic, le_min_iff]
|
| 38 |
+
split_ifs <;> norm_num <;> tauto
|
| 39 |
+
have hi (i j : ι) : IntervalIntegrable (fun l => K l i j) volume 0 R := by
|
| 40 |
+
rw [hki]
|
| 41 |
+
exact ⟨(intervalIntegrable_const (a := 0) (b := R) (c := (1 : ℝ))).1.indicator
|
| 42 |
+
measurableSet_Iic,
|
| 43 |
+
(intervalIntegrable_const (a := 0) (b := R) (c := (1 : ℝ))).2.indicator
|
| 44 |
+
measurableSet_Iic⟩
|
| 45 |
+
have h := integral_posSemidef K hR (fun l _ => hk l) hi
|
| 46 |
+
suffices he : Matrix.of (fun i j => min (u i) (u j)) =
|
| 47 |
+
(fun i j => ∫ l in (0 : ℝ)..R, K l i j) by
|
| 48 |
+
rw [he]
|
| 49 |
+
exact h
|
| 50 |
+
ext i j
|
| 51 |
+
rw [hki]
|
| 52 |
+
change min (u i) (u j) =
|
| 53 |
+
∫ l in (0 : ℝ)..R, Set.indicator {l | l ≤ min (u i) (u j)} (fun _ => (1 : ℝ)) l
|
| 54 |
+
rw [intervalIntegral.integral_indicator
|
| 55 |
+
(show min (u i) (u j) ∈ Set.Icc 0 R from
|
| 56 |
+
⟨le_min (hu i) (hu j), (min_le_left _ _).trans (huR i)⟩)]
|
| 57 |
+
simp
|
| 58 |
+
|
| 59 |
+
lemma abs_sub_sq_hilbert (u : ι → ℝ) :
|
| 60 |
+
∃ h : ι → EuclideanSpace ℝ ι, ∀ i j, ‖h i - h j‖ ^ 2 = |u i - u j| := by
|
| 61 |
+
let b : ℝ := ∑ i, |u i|
|
| 62 |
+
have hu (i : ι) : 0 ≤ u i + b := by
|
| 63 |
+
have hb : |u i| ≤ b := Finset.single_le_sum (fun j _ => abs_nonneg (u j))
|
| 64 |
+
(Finset.mem_univ i)
|
| 65 |
+
have := neg_abs_le (u i)
|
| 66 |
+
linarith
|
| 67 |
+
obtain ⟨h, hh⟩ := exists_gram (min_posSemidef (fun i => u i + b) hu)
|
| 68 |
+
refine ⟨h, fun i j => ?_⟩
|
| 69 |
+
rw [norm_sub_sq_real, ← real_inner_self_eq_norm_sq, ← real_inner_self_eq_norm_sq,
|
| 70 |
+
hh, hh, hh]
|
| 71 |
+
simp only [Matrix.of_apply, min_self]
|
| 72 |
+
rcases le_total (u i) (u j) with hij | hji
|
| 73 |
+
· rw [min_eq_left (add_le_add_left hij b), abs_of_nonpos (sub_nonpos.mpr hij)]
|
| 74 |
+
ring
|
| 75 |
+
· rw [min_eq_right (add_le_add_left hji b), abs_of_nonneg (sub_nonneg.mpr hji)]
|
| 76 |
+
ring
|
| 77 |
+
|
| 78 |
+
lemma l1_sq_hilbert {κ : Type u2} [Fintype κ] (x : ι → κ → ℝ) {a : ℝ} (ha : 0 ≤ a) :
|
| 79 |
+
∃ h : ι → EuclideanSpace ℝ (κ × ι),
|
| 80 |
+
∀ i j, ‖h i - h j‖ ^ 2 = a * ∑ k, |x i k - x j k| := by
|
| 81 |
+
classical
|
| 82 |
+
choose h hh using fun k => abs_sub_sq_hilbert (fun i => x i k)
|
| 83 |
+
refine ⟨fun i => WithLp.toLp 2 (fun ki => Real.sqrt a * h ki.1 i ki.2), ?_⟩
|
| 84 |
+
intro i j
|
| 85 |
+
rw [EuclideanSpace.norm_sq_eq]
|
| 86 |
+
simp only [PiLp.sub_apply, Real.norm_eq_abs, sq_abs,
|
| 87 |
+
Fintype.sum_prod_type]
|
| 88 |
+
have hs : ∀ k, ∑ l, (Real.sqrt a * h k i l - Real.sqrt a * h k j l) ^ 2 =
|
| 89 |
+
a * |x i k - x j k| := by
|
| 90 |
+
intro k
|
| 91 |
+
simp_rw [← mul_sub, mul_pow, Real.sq_sqrt ha]
|
| 92 |
+
rw [← Finset.mul_sum, ← hh k i j, EuclideanSpace.norm_sq_eq]
|
| 93 |
+
simp [Real.norm_eq_abs]
|
| 94 |
+
simp_rw [hs]
|
| 95 |
+
exact (Finset.mul_sum _ _ _).symm
|
| 96 |
+
|
| 97 |
+
lemma repair_integral_le {d r : ℝ} (hd : 0 ≤ d) (hr : 0 ≤ r) :
|
| 98 |
+
(∫ l in (0 : ℝ)..r, 1 - Real.exp (-d / l)) ≤ r := by
|
| 99 |
+
have hi := (intervalIntegrable_const (c := (1 : ℝ))).sub (exp_distance_intervalIntegrable hd hr)
|
| 100 |
+
have h := intervalIntegral.integral_mono_on hr hi
|
| 101 |
+
(intervalIntegrable_const (c := (1 : ℝ))) (fun l _ => by
|
| 102 |
+
have := (Real.exp_pos (-d / l)).le
|
| 103 |
+
linarith)
|
| 104 |
+
simpa using h
|
| 105 |
+
|
| 106 |
+
lemma repair_integral_local {d r : ℝ} (hd : 0 < d) (hdr : d ≤ r) :
|
| 107 |
+
(∫ l in (0 : ℝ)..r, 1 - Real.exp (-d / l)) ≤
|
| 108 |
+
d * (1 + Real.log (r / d)) := by
|
| 109 |
+
have hr : 0 ≤ r := hd.le.trans hdr
|
| 110 |
+
have hi := (intervalIntegrable_const (c := (1 : ℝ))).sub (exp_distance_intervalIntegrable hd.le hr)
|
| 111 |
+
have hi₀ := (intervalIntegrable_const (c := (1 : ℝ))).sub (exp_distance_intervalIntegrable hd.le hd.le)
|
| 112 |
+
have hi₁ : IntervalIntegrable (fun l => 1 - Real.exp (-d / l)) volume d r :=
|
| 113 |
+
hi.mono_set (by
|
| 114 |
+
rw [Set.uIcc_of_le hdr, Set.uIcc_of_le hr]
|
| 115 |
+
exact Set.Icc_subset_Icc hd.le le_rfl)
|
| 116 |
+
have hn : 0 ∉ Set.uIcc d r := by
|
| 117 |
+
rw [Set.uIcc_of_le hdr]
|
| 118 |
+
exact fun h => (not_le_of_gt hd) h.1
|
| 119 |
+
have hj : IntervalIntegrable (fun l => d * l⁻¹) volume d r :=
|
| 120 |
+
(intervalIntegrable_inv_iff.mpr (Or.inr hn)).const_mul d
|
| 121 |
+
have hbound := intervalIntegral.integral_mono_on hdr hi₁ hj (fun l hl => by
|
| 122 |
+
have he := Real.one_sub_le_exp_neg (d / l)
|
| 123 |
+
rw [← neg_div] at he
|
| 124 |
+
rw [← div_eq_mul_inv]
|
| 125 |
+
linarith)
|
| 126 |
+
rw [intervalIntegral.integral_const_mul, integral_inv hn] at hbound
|
| 127 |
+
rw [← intervalIntegral.integral_add_adjacent_intervals hi₀ hi₁]
|
| 128 |
+
have hfirst := repair_integral_le hd.le hd.le
|
| 129 |
+
linarith
|
| 130 |
+
|
| 131 |
+
section Charts
|
| 132 |
+
|
| 133 |
+
variable {κ : Type u3} {H : Type u4} [Fintype κ] [DecidableEq κ]
|
| 134 |
+
[NormedAddCommGroup H] [InnerProductSpace ℝ H]
|
| 135 |
+
|
| 136 |
+
noncomputable def chartKernel (c : ι → κ) (h : ι → H) (l : ℝ) : Matrix ι ι ℝ :=
|
| 137 |
+
Matrix.of fun i j => if c i = c j then Real.exp (-‖h i - h j‖ ^ 2 / l) else 0
|
| 138 |
+
|
| 139 |
+
noncomputable def cappedDistance (c : ι → κ) (h : ι → H) (r : ℝ) (i j : ι) : ℝ :=
|
| 140 |
+
if c i = c j then min r (‖h i - h j‖ ^ 2) else r
|
| 141 |
+
|
| 142 |
+
omit [Fintype κ] in
|
| 143 |
+
lemma chartKernel_posSemidef (c : ι → κ) (h : ι → H) {l : ℝ} (hl : 0 ≤ l) :
|
| 144 |
+
(chartKernel c h l).PosSemidef := by
|
| 145 |
+
have hm := (Matrix.PosSemidef.one (n := κ) (R := ℝ)).submatrix c
|
| 146 |
+
rcases hl.eq_or_lt with rfl | hl
|
| 147 |
+
· convert hm using 1
|
| 148 |
+
ext i j
|
| 149 |
+
simp [chartKernel, Matrix.submatrix_apply, Matrix.one_apply]
|
| 150 |
+
· have hg := gaussian_posSemidef h hl
|
| 151 |
+
convert hm.hadamard hg using 1
|
| 152 |
+
ext i j
|
| 153 |
+
change (if c i = c j then _ else 0) =
|
| 154 |
+
(if c i = c j then (1 : ℝ) else 0) * _
|
| 155 |
+
split_ifs <;> simp
|
| 156 |
+
|
| 157 |
+
omit [Fintype ι] [Fintype κ] [InnerProductSpace ℝ H] in
|
| 158 |
+
lemma chartKernel_intervalIntegrable (c : ι → κ) (h : ι → H) {r : ℝ}
|
| 159 |
+
(hr : 0 ≤ r) (i j : ι) :
|
| 160 |
+
IntervalIntegrable (fun l => chartKernel c h l i j) volume 0 r := by
|
| 161 |
+
by_cases hij : c i = c j
|
| 162 |
+
· simpa [chartKernel, hij] using exp_distance_intervalIntegrable (sq_nonneg ‖h i - h j‖) hr
|
| 163 |
+
· simp only [chartKernel, Matrix.of_apply, hij, ite_false]
|
| 164 |
+
exact intervalIntegrable_const
|
| 165 |
+
|
| 166 |
+
omit [Fintype ι] [Fintype κ] [InnerProductSpace ℝ H] in
|
| 167 |
+
lemma chartKernel_nonneg (c : ι → κ) (h : ι → H) (l : ℝ) (i j : ι) :
|
| 168 |
+
0 ≤ chartKernel c h l i j := by
|
| 169 |
+
simp only [chartKernel, Matrix.of_apply]
|
| 170 |
+
split_ifs <;> positivity
|
| 171 |
+
|
| 172 |
+
omit [Fintype ι] [Fintype κ] [InnerProductSpace ℝ H] in
|
| 173 |
+
lemma chartKernel_le_one (c : ι → κ) (h : ι → H) {l : ℝ} (hl : 0 ≤ l) (i j : ι) :
|
| 174 |
+
chartKernel c h l i j ≤ 1 := by
|
| 175 |
+
simp only [chartKernel, Matrix.of_apply]
|
| 176 |
+
split_ifs
|
| 177 |
+
· exact Real.exp_le_one_iff.mpr (div_nonpos_of_nonpos_of_nonneg
|
| 178 |
+
(neg_nonpos.mpr (sq_nonneg _)) hl)
|
| 179 |
+
· norm_num
|
| 180 |
+
|
| 181 |
+
omit [Fintype ι] [Fintype κ] [InnerProductSpace ℝ H] in
|
| 182 |
+
lemma chartKernel_self (c : ι → κ) (h : ι → H) (l : ℝ) (i : ι) :
|
| 183 |
+
chartKernel c h l i i = 1 := by simp [chartKernel]
|
| 184 |
+
|
| 185 |
+
omit [Fintype ι] [Fintype κ] [InnerProductSpace ℝ H] in
|
| 186 |
+
lemma chartKernel_symm (c : ι → κ) (h : ι → H) (l : ℝ) (i j : ι) :
|
| 187 |
+
chartKernel c h l i j = chartKernel c h l j i := by
|
| 188 |
+
simp only [chartKernel, Matrix.of_apply, norm_sub_rev (h j) (h i)]
|
| 189 |
+
by_cases hij : c i = c j <;> simp [hij, eq_comm]
|
| 190 |
+
|
| 191 |
+
omit [Fintype ι] [Fintype κ] [InnerProductSpace ℝ H] in
|
| 192 |
+
lemma cappedDistance_nonneg (c : ι → κ) (h : ι → H) {r : ℝ} (hr : 0 ≤ r) (i j : ι) :
|
| 193 |
+
0 ≤ cappedDistance c h r i j := by
|
| 194 |
+
simp only [cappedDistance]
|
| 195 |
+
split_ifs
|
| 196 |
+
· exact le_min hr (sq_nonneg _)
|
| 197 |
+
· exact hr
|
| 198 |
+
|
| 199 |
+
omit [Fintype ι] [Fintype κ] [InnerProductSpace ℝ H] in
|
| 200 |
+
lemma cappedDistance_le (c : ι → κ) (h : ι → H) (r : ℝ) (i j : ι) :
|
| 201 |
+
cappedDistance c h r i j ≤ r := by
|
| 202 |
+
simp only [cappedDistance]
|
| 203 |
+
split_ifs
|
| 204 |
+
· exact min_le_left _ _
|
| 205 |
+
· rfl
|
| 206 |
+
|
| 207 |
+
def ChartTriangle (c : ι → κ) (h : ι → H) : Prop :=
|
| 208 |
+
∀ i j k, c i = c j → c j = c k →
|
| 209 |
+
‖h i - h k‖ ^ 2 ≤ ‖h i - h j‖ ^ 2 + ‖h j - h k‖ ^ 2
|
| 210 |
+
|
| 211 |
+
omit [Fintype ι] [Fintype κ] [InnerProductSpace ℝ H] in
|
| 212 |
+
lemma chartKernel_mul_le (c : ι → κ) (h : ι → H) (ht : ChartTriangle c h)
|
| 213 |
+
{l : ℝ} (hl : 0 < l) (i j z : ι) :
|
| 214 |
+
chartKernel c h l i z * chartKernel c h l j z ≤ chartKernel c h l i j := by
|
| 215 |
+
by_cases hiz : c i = c z
|
| 216 |
+
· by_cases hjz : c j = c z
|
| 217 |
+
· simp only [chartKernel, Matrix.of_apply, hiz, hjz, ite_true]
|
| 218 |
+
rw [← Real.exp_add]
|
| 219 |
+
apply Real.exp_le_exp.mpr
|
| 220 |
+
rw [← add_div]
|
| 221 |
+
apply div_le_div_of_nonneg_right _ hl.le
|
| 222 |
+
have htri := ht i z j hiz hjz.symm
|
| 223 |
+
rw [norm_sub_rev (h z) (h j)] at htri
|
| 224 |
+
linarith
|
| 225 |
+
· simp only [chartKernel, Matrix.of_apply, hjz, ite_false, mul_zero]
|
| 226 |
+
split_ifs <;> positivity
|
| 227 |
+
· simp only [chartKernel, Matrix.of_apply, hiz, ite_false, zero_mul]
|
| 228 |
+
split_ifs <;> positivity
|
| 229 |
+
|
| 230 |
+
omit [Fintype ι] [Fintype κ] [InnerProductSpace ℝ H] in
|
| 231 |
+
lemma chartKernel_le_half (c : ι → κ) (h : ι → H) {r l : ℝ}
|
| 232 |
+
(hl : 0 < l) (i j : ι) (hle : l ≤ cappedDistance c h r i j) :
|
| 233 |
+
chartKernel c h l i j ≤ 1 / 2 := by
|
| 234 |
+
by_cases hij : c i = c j
|
| 235 |
+
· have hd : l ≤ ‖h i - h j‖ ^ 2 := by
|
| 236 |
+
exact le_trans hle (by simp [cappedDistance, hij])
|
| 237 |
+
simp only [chartKernel, Matrix.of_apply, hij, ite_true]
|
| 238 |
+
calc
|
| 239 |
+
Real.exp (-‖h i - h j‖ ^ 2 / l) ≤ Real.exp (-1) := by
|
| 240 |
+
apply Real.exp_le_exp.mpr
|
| 241 |
+
apply (div_le_iff₀ hl).mpr
|
| 242 |
+
linarith
|
| 243 |
+
_ ≤ 1 / 2 := by
|
| 244 |
+
rw [Real.exp_neg, ← one_div]
|
| 245 |
+
apply one_div_le_one_div_of_le (by norm_num : (0 : ℝ) < 2)
|
| 246 |
+
have := Real.add_one_le_exp (1 : ℝ)
|
| 247 |
+
norm_num at this ⊢
|
| 248 |
+
exact this
|
| 249 |
+
· simp [chartKernel, hij]
|
| 250 |
+
|
| 251 |
+
def IsRepairGram (c : ι → κ) (h : ι → H) (r : ℝ)
|
| 252 |
+
(q : ι → EuclideanSpace ℝ ι) : Prop :=
|
| 253 |
+
∀ i j, ⟪q i, q j⟫_ℝ = 4 * ∫ l in (0 : ℝ)..r, chartKernel c h l i j
|
| 254 |
+
|
| 255 |
+
omit [Fintype κ] in
|
| 256 |
+
lemma exists_repairGram (c : ι → κ) (h : ι → H) {r : ℝ} (hr : 0 ≤ r) :
|
| 257 |
+
∃ q : ι → EuclideanSpace ℝ ι, IsRepairGram c h r q := by
|
| 258 |
+
have hi := integral_posSemidef (chartKernel c h) hr
|
| 259 |
+
(fun l hl => chartKernel_posSemidef c h hl.1) (chartKernel_intervalIntegrable c h hr)
|
| 260 |
+
obtain ⟨q, hq⟩ := exists_gram (hi.smul (by norm_num : (0 : ℝ) ≤ 4))
|
| 261 |
+
exact ⟨q, hq⟩
|
| 262 |
+
|
| 263 |
+
omit [Fintype κ] [InnerProductSpace ℝ H] in
|
| 264 |
+
lemma repairGram_norm_sq (c : ι → κ) (h : ι → H) {r : ℝ}
|
| 265 |
+
{q : ι → EuclideanSpace ℝ ι} (hq : IsRepairGram c h r q) (i : ι) :
|
| 266 |
+
‖q i‖ ^ 2 = 4 * r := by
|
| 267 |
+
rw [← real_inner_self_eq_norm_sq, hq]
|
| 268 |
+
simp_rw [chartKernel_self]
|
| 269 |
+
simp
|
| 270 |
+
|
| 271 |
+
omit [Fintype κ] [InnerProductSpace ℝ H] in
|
| 272 |
+
lemma repairGram_distance (c : ι → κ) (h : ι → H) {r : ℝ} (hr : 0 ≤ r)
|
| 273 |
+
{q : ι → EuclideanSpace ℝ ι} (hq : IsRepairGram c h r q) (i j : ι) :
|
| 274 |
+
‖q i - q j‖ ^ 2 = 8 * ∫ l in (0 : ℝ)..r, 1 - chartKernel c h l i j := by
|
| 275 |
+
rw [norm_sub_sq_real, repairGram_norm_sq c h hq, repairGram_norm_sq c h hq, hq,
|
| 276 |
+
intervalIntegral.integral_sub intervalIntegrable_const
|
| 277 |
+
(chartKernel_intervalIntegrable c h hr i j)]
|
| 278 |
+
simp only [intervalIntegral.integral_const, sub_zero, smul_eq_mul, mul_one]
|
| 279 |
+
ring
|
| 280 |
+
|
| 281 |
+
omit [Fintype κ] [InnerProductSpace ℝ H] in
|
| 282 |
+
lemma repairGram_distance_le (c : ι → κ) (h : ι → H) {r : ℝ} (hr : 0 ≤ r)
|
| 283 |
+
{q : ι → EuclideanSpace ℝ ι} (hq : IsRepairGram c h r q) (i j : ι) :
|
| 284 |
+
‖q i - q j‖ ^ 2 ≤ 8 * r := by
|
| 285 |
+
rw [repairGram_distance c h hr hq]
|
| 286 |
+
have hi := (intervalIntegrable_const (c := (1 : ℝ))).sub
|
| 287 |
+
(chartKernel_intervalIntegrable c h hr i j)
|
| 288 |
+
have hb := intervalIntegral.integral_mono_on hr hi
|
| 289 |
+
(intervalIntegrable_const (c := (1 : ℝ))) (fun l _ => by
|
| 290 |
+
have := chartKernel_nonneg c h l i j
|
| 291 |
+
linarith)
|
| 292 |
+
simp only [intervalIntegral.integral_const, sub_zero, smul_eq_mul, mul_one] at hb
|
| 293 |
+
linarith
|
| 294 |
+
|
| 295 |
+
omit [Fintype κ] [InnerProductSpace ℝ H] in
|
| 296 |
+
lemma repairGram_local (c : ι → κ) (h : ι → H) {r : ℝ}
|
| 297 |
+
{q : ι → EuclideanSpace ℝ ι} (hq : IsRepairGram c h r q) {i j : ι}
|
| 298 |
+
(hij : c i = c j) (hd : 0 < ‖h i - h j‖ ^ 2) (hdr : ‖h i - h j‖ ^ 2 ≤ r) :
|
| 299 |
+
‖q i - q j‖ ^ 2 ≤ 8 * ‖h i - h j‖ ^ 2 *
|
| 300 |
+
(1 + Real.log (r / ‖h i - h j‖ ^ 2)) := by
|
| 301 |
+
rw [repairGram_distance c h (hd.le.trans hdr) hq]
|
| 302 |
+
simp only [chartKernel, Matrix.of_apply, hij, ite_true]
|
| 303 |
+
have := repair_integral_local hd hdr
|
| 304 |
+
nlinarith
|
| 305 |
+
|
| 306 |
+
omit [Fintype κ] [InnerProductSpace ℝ H] in
|
| 307 |
+
lemma repairGram_eq_of_zero (c : ι → κ) (h : ι → H) {r : ℝ} (hr : 0 ≤ r)
|
| 308 |
+
{q : ι → EuclideanSpace ℝ ι} (hq : IsRepairGram c h r q) {i j : ι}
|
| 309 |
+
(hij : c i = c j) (hd : ‖h i - h j‖ ^ 2 = 0) : q i = q j := by
|
| 310 |
+
have hdq := repairGram_distance c h hr hq i j
|
| 311 |
+
simp only [chartKernel, Matrix.of_apply, hij, ite_true, hd, neg_zero, zero_div,
|
| 312 |
+
Real.exp_zero, sub_self, intervalIntegral.integral_zero, mul_zero] at hdq
|
| 313 |
+
exact sub_eq_zero.mp (norm_eq_zero.mp (sq_eq_zero_iff.mp hdq))
|
| 314 |
+
|
| 315 |
+
noncomputable def angleIntegrand (c : ι → κ) (h : ι → H) (i j z : ι) (l : ℝ) : ℝ :=
|
| 316 |
+
1 - chartKernel c h l i z - chartKernel c h l j z + chartKernel c h l i j
|
| 317 |
+
|
| 318 |
+
omit [Fintype ι] [Fintype κ] [InnerProductSpace ℝ H] in
|
| 319 |
+
lemma angleIntegrand_integrable (c : ι → κ) (h : ι → H) {r : ℝ} (hr : 0 ≤ r)
|
| 320 |
+
(i j z : ι) : IntervalIntegrable (angleIntegrand c h i j z) volume 0 r :=
|
| 321 |
+
(((intervalIntegrable_const (c := (1 : ℝ))).sub (chartKernel_intervalIntegrable c h hr i z)).sub
|
| 322 |
+
(chartKernel_intervalIntegrable c h hr j z)).add (chartKernel_intervalIntegrable c h hr i j)
|
| 323 |
+
|
| 324 |
+
omit [Fintype κ] [InnerProductSpace ℝ H] in
|
| 325 |
+
lemma repairGram_angle (c : ι → κ) (h : ι → H) {r : ℝ} (hr : 0 ≤ r)
|
| 326 |
+
{q : ι → EuclideanSpace ℝ ι} (hq : IsRepairGram c h r q) (i j z : ι) :
|
| 327 |
+
⟪q i - q z, q j - q z⟫_ℝ = 4 * ∫ l in (0 : ℝ)..r, angleIntegrand c h i j z l := by
|
| 328 |
+
rw [inner_sub_left, inner_sub_right, inner_sub_right, hq, hq, hq, hq]
|
| 329 |
+
simp_rw [chartKernel_self, chartKernel_symm c h _ z j]
|
| 330 |
+
rw [show (fun l => angleIntegrand c h i j z l) =
|
| 331 |
+
(fun l => 1 - chartKernel c h l i z - chartKernel c h l j z +
|
| 332 |
+
chartKernel c h l i j) from rfl]
|
| 333 |
+
rw [intervalIntegral.integral_add
|
| 334 |
+
(((intervalIntegrable_const (c := (1 : ℝ))).sub
|
| 335 |
+
(chartKernel_intervalIntegrable c h hr i z)).sub
|
| 336 |
+
(chartKernel_intervalIntegrable c h hr j z)) (chartKernel_intervalIntegrable c h hr i j)]
|
| 337 |
+
rw [intervalIntegral.integral_sub
|
| 338 |
+
((intervalIntegrable_const (c := (1 : ℝ))).sub (chartKernel_intervalIntegrable c h hr i z))
|
| 339 |
+
(chartKernel_intervalIntegrable c h hr j z)]
|
| 340 |
+
rw [intervalIntegral.integral_sub intervalIntegrable_const
|
| 341 |
+
(chartKernel_intervalIntegrable c h hr i z)]
|
| 342 |
+
ring
|
| 343 |
+
|
| 344 |
+
omit [Fintype ι] [Fintype κ] [InnerProductSpace ℝ H] in
|
| 345 |
+
lemma angleIntegrand_nonneg (c : ι → κ) (h : ι → H) (ht : ChartTriangle c h)
|
| 346 |
+
{l : ℝ} (hl : 0 < l) (i j z : ι) : 0 ≤ angleIntegrand c h i j z l := by
|
| 347 |
+
have ha := chartKernel_le_one c h hl.le i z
|
| 348 |
+
have hb := chartKernel_le_one c h hl.le j z
|
| 349 |
+
have hc := chartKernel_mul_le c h ht hl i j z
|
| 350 |
+
have hp := mul_nonneg (sub_nonneg.mpr ha) (sub_nonneg.mpr hb)
|
| 351 |
+
dsimp only [angleIntegrand]
|
| 352 |
+
nlinarith
|
| 353 |
+
|
| 354 |
+
omit [Fintype ι] [Fintype κ] [InnerProductSpace ℝ H] in
|
| 355 |
+
lemma angleIntegrand_ge_quarter (c : ι → κ) (h : ι → H) (ht : ChartTriangle c h)
|
| 356 |
+
{r l : ℝ} (hl : 0 < l) (i j z : ι)
|
| 357 |
+
(hli : l ≤ cappedDistance c h r i z) (hlj : l ≤ cappedDistance c h r j z) :
|
| 358 |
+
1 / 4 ≤ angleIntegrand c h i j z l := by
|
| 359 |
+
have ha := chartKernel_le_half c h hl i z hli
|
| 360 |
+
have hb := chartKernel_le_half c h hl j z hlj
|
| 361 |
+
have hc := chartKernel_mul_le c h ht hl i j z
|
| 362 |
+
have hp := mul_le_mul
|
| 363 |
+
(show (1 / 2 : ℝ) ≤ 1 - chartKernel c h l i z by linarith)
|
| 364 |
+
(show (1 / 2 : ℝ) ≤ 1 - chartKernel c h l j z by linarith)
|
| 365 |
+
(by norm_num : (0 : ℝ) ≤ 1 / 2)
|
| 366 |
+
(show 0 ≤ 1 - chartKernel c h l i z by linarith)
|
| 367 |
+
dsimp only [angleIntegrand]
|
| 368 |
+
nlinarith
|
| 369 |
+
|
| 370 |
+
omit [Fintype κ] [InnerProductSpace ℝ H] in
|
| 371 |
+
lemma repairGram_angle_lower (c : ι → κ) (h : ι → H) (ht : ChartTriangle c h)
|
| 372 |
+
{r : ℝ} (hr : 0 ≤ r) {q : ι → EuclideanSpace ℝ ι} (hq : IsRepairGram c h r q)
|
| 373 |
+
(i j z : ι) :
|
| 374 |
+
min (cappedDistance c h r i z) (cappedDistance c h r j z) ≤
|
| 375 |
+
⟪q i - q z, q j - q z⟫_ℝ := by
|
| 376 |
+
let t := min (cappedDistance c h r i z) (cappedDistance c h r j z)
|
| 377 |
+
have ht₀ : 0 ≤ t := le_min (cappedDistance_nonneg c h hr i z)
|
| 378 |
+
(cappedDistance_nonneg c h hr j z)
|
| 379 |
+
have htr : t ≤ r := (min_le_left _ _).trans (cappedDistance_le c h r i z)
|
| 380 |
+
have hf : (0 : ℝ → ℝ) ≤ᵐ[volume.restrict (Set.Ioc 0 r)] angleIntegrand c h i j z := by
|
| 381 |
+
filter_upwards [ae_restrict_mem measurableSet_Ioc] with l hl
|
| 382 |
+
exact angleIntegrand_nonneg c h ht hl.1 i j z
|
| 383 |
+
have hlower := intervalIntegral.integral_mono_ae_restrict ht₀
|
| 384 |
+
(intervalIntegrable_const (c := (1 / 4 : ℝ))) (angleIntegrand_integrable c h ht₀ i j z)
|
| 385 |
+
(show (fun _ => (1 / 4 : ℝ)) ≤ᵐ[volume.restrict (Set.Icc 0 t)]
|
| 386 |
+
angleIntegrand c h i j z from by
|
| 387 |
+
filter_upwards [ae_restrict_mem measurableSet_Icc,
|
| 388 |
+
ae_restrict_of_ae (volume.ae_ne (0 : ℝ))] with l hl hne
|
| 389 |
+
exact angleIntegrand_ge_quarter c h ht (lt_of_le_of_ne hl.1 (Ne.symm hne)) i j z
|
| 390 |
+
(hl.2.trans (min_le_left _ _)) (hl.2.trans (min_le_right _ _)))
|
| 391 |
+
have hmono := intervalIntegral.integral_mono_interval le_rfl ht₀ htr hf
|
| 392 |
+
(angleIntegrand_integrable c h hr i j z)
|
| 393 |
+
rw [repairGram_angle c h hr hq]
|
| 394 |
+
simp only [intervalIntegral.integral_const, sub_zero, smul_eq_mul] at hlower
|
| 395 |
+
dsimp only [t] at *
|
| 396 |
+
linarith
|
| 397 |
+
|
| 398 |
+
omit [Fintype κ] [DecidableEq κ] in
|
| 399 |
+
|
| 400 |
+
lemma chart_l1_sq_hilbert {ξ : Type u5} [Fintype ξ] (c : ι → κ) (x : ι → ξ → ℝ)
|
| 401 |
+
(a : κ → ℝ) (ha : ∀ s, 0 ≤ a s) :
|
| 402 |
+
∃ h : ι → EuclideanSpace ℝ (ξ × ι),
|
| 403 |
+
(∀ i j, c i = c j → ‖h i - h j‖ ^ 2 = a (c i) * ∑ k, |x i k - x j k|) ∧
|
| 404 |
+
ChartTriangle c h := by
|
| 405 |
+
obtain ⟨g, hg⟩ := l1_sq_hilbert x (by norm_num : (0 : ℝ) ≤ 1)
|
| 406 |
+
let h : ι → EuclideanSpace ℝ (ξ × ι) := fun i => Real.sqrt (a (c i)) • g i
|
| 407 |
+
have hh (i j : ι) (hc : c i = c j) :
|
| 408 |
+
‖h i - h j‖ ^ 2 = a (c i) * ∑ k, |x i k - x j k| := by
|
| 409 |
+
dsimp only [h]
|
| 410 |
+
rw [← hc, ← smul_sub, norm_smul, mul_pow, Real.norm_eq_abs, sq_abs,
|
| 411 |
+
Real.sq_sqrt (ha (c i)), hg]
|
| 412 |
+
ring
|
| 413 |
+
refine ⟨h, hh, fun i j k hij hjk => ?_⟩
|
| 414 |
+
rw [hh i k (hij.trans hjk), hh i j hij, hh j k hjk, ← hij, ← mul_add]
|
| 415 |
+
apply mul_le_mul_of_nonneg_left _ (ha (c i))
|
| 416 |
+
rw [← Finset.sum_add_distrib]
|
| 417 |
+
exact Finset.sum_le_sum (fun l _ => abs_sub_le (x i l) (x j l) (x k l))
|
| 418 |
+
|
| 419 |
+
lemma sum_sq_hilbert {E : Type u6} [NormedAddCommGroup E] [InnerProductSpace ℝ E]
|
| 420 |
+
(P : ι → E) (q : ι → H) :
|
| 421 |
+
∃ z : ι → EuclideanSpace ℝ ι, ∀ i j,
|
| 422 |
+
‖z i - z j‖ ^ 2 = ‖P i - P j‖ ^ 2 + ‖q i - q j‖ ^ 2 := by
|
| 423 |
+
obtain ⟨z, hz⟩ := exists_gram ((gram_posSemidef P).add (gram_posSemidef q))
|
| 424 |
+
refine ⟨z, fun i j => ?_⟩
|
| 425 |
+
simp only [norm_sub_sq_real]
|
| 426 |
+
simp only [← real_inner_self_eq_norm_sq, hz, Matrix.add_apply, Matrix.of_apply]
|
| 427 |
+
ring
|
| 428 |
+
|
| 429 |
+
lemma angle_triangle_slack (x y z : H) :
|
| 430 |
+
‖x - y‖ ^ 2 + ‖z - y‖ ^ 2 - ‖x - z‖ ^ 2 = 2 * ⟪x - y, z - y⟫_ℝ := by
|
| 431 |
+
have he : x - z = (x - y) - (z - y) := by abel
|
| 432 |
+
rw [he, norm_sub_sq_real (x - y) (z - y)]
|
| 433 |
+
ring
|
| 434 |
+
|
| 435 |
+
omit [Fintype κ] in
|
| 436 |
+
|
| 437 |
+
theorem triangle_repair {E : Type u7} [NormedAddCommGroup E] [InnerProductSpace ℝ E]
|
| 438 |
+
(c : ι → κ) (h : ι → H) (ht : ChartTriangle c h) {r : ℝ} (hr : 0 < r)
|
| 439 |
+
(P : ι → E)
|
| 440 |
+
(hP : ∀ i j z, -min (cappedDistance c h r i z) (cappedDistance c h r j z) ≤
|
| 441 |
+
⟪P i - P z, P j - P z⟫_ℝ) :
|
| 442 |
+
∃ q z : ι → EuclideanSpace ℝ ι,
|
| 443 |
+
IsRepairGram c h r q ∧
|
| 444 |
+
(∀ i j, ‖z i - z j‖ ^ 2 = ‖P i - P j‖ ^ 2 + ‖q i - q j‖ ^ 2) ∧
|
| 445 |
+
(∀ i j k, ‖z i - z k‖ ^ 2 ≤ ‖z i - z j‖ ^ 2 + ‖z j - z k‖ ^ 2) ∧
|
| 446 |
+
(∀ i j, ‖q i - q j‖ ^ 2 = 8 * ∫ l in (0 : ℝ)..r, 1 - chartKernel c h l i j) ∧
|
| 447 |
+
(∀ i j, ‖q i - q j‖ ^ 2 ≤ 8 * r) ∧
|
| 448 |
+
(∀ i j, c i = c j → 0 < ‖h i - h j‖ ^ 2 → ‖h i - h j‖ ^ 2 ≤ r →
|
| 449 |
+
‖q i - q j‖ ^ 2 ≤ 8 * ‖h i - h j‖ ^ 2 * (1 + Real.log (r / ‖h i - h j‖ ^ 2))) ∧
|
| 450 |
+
(∀ i j, c i = c j → ‖h i - h j‖ ^ 2 = 0 → q i = q j) := by
|
| 451 |
+
obtain ⟨q, hq⟩ := exists_repairGram c h hr.le
|
| 452 |
+
obtain ⟨z, hz⟩ := sum_sq_hilbert P q
|
| 453 |
+
refine ⟨q, z, hq, hz, ?_, repairGram_distance c h hr.le hq,
|
| 454 |
+
repairGram_distance_le c h hr.le hq,
|
| 455 |
+
fun _ _ hc hd hdr => repairGram_local c h hq hc hd hdr,
|
| 456 |
+
fun _ _ hc hd => repairGram_eq_of_zero c h hr.le hq hc hd⟩
|
| 457 |
+
intro i j k
|
| 458 |
+
rw [hz, hz, hz]
|
| 459 |
+
have hp := hP i k j
|
| 460 |
+
have hqangle := repairGram_angle_lower c h ht hr.le hq i k j
|
| 461 |
+
have hpAngle := angle_triangle_slack (P i) (P j) (P k)
|
| 462 |
+
have hqAngle := angle_triangle_slack (q i) (q j) (q k)
|
| 463 |
+
rw [norm_sub_rev (P k) (P j)] at hpAngle
|
| 464 |
+
rw [norm_sub_rev (q k) (q j)] at hqAngle
|
| 465 |
+
linarith
|
| 466 |
+
|
| 467 |
+
end Charts
|
| 468 |
+
|
| 469 |
+
end UniformSparsestCut.TriangleRepair
|
| 470 |
+
|
| 471 |
+
end
|
| 472 |
+
|
| 473 |
+
end OAI
|
lean/OAI/Combinatorics/SparsestCut/UniformMetric.lean
ADDED
|
@@ -0,0 +1,89 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import OAI.Combinatorics.SparsestCut.UniformReplication
|
| 2 |
+
import OAI.Combinatorics.SparsestCut.VertexCount
|
| 3 |
+
|
| 4 |
+
namespace OAI
|
| 5 |
+
|
| 6 |
+
open scoped BigOperators Topology NNReal RealInnerProductSpace InnerProductSpace Matrix ContDiff ENNReal
|
| 7 |
+
open MeasureTheory ProbabilityTheory Set Filter Matrix
|
| 8 |
+
|
| 9 |
+
noncomputable section
|
| 10 |
+
|
| 11 |
+
namespace UniformSparsestCut.SourceUniform
|
| 12 |
+
open scoped BigOperators
|
| 13 |
+
open SourceMetric SourceParameters
|
| 14 |
+
noncomputable section
|
| 15 |
+
lemma size_upper {d v : ℕ} (hd : 3≤d) (hv : v≤d^(4025*d)) :
|
| 16 |
+
d^d+d^2*v+v≤d^(4030*d) := by
|
| 17 |
+
have hd1 : 1≤d := by omega
|
| 18 |
+
have hp : d^d≤d^(4025*d+2) := Nat.pow_le_pow_right hd1 (by omega)
|
| 19 |
+
have hv' : v≤d^(4025*d+2) := hv.trans (Nat.pow_le_pow_right hd1 (by omega))
|
| 20 |
+
have hprod : d^2*v≤d^(4025*d+2) := by
|
| 21 |
+
calc
|
| 22 |
+
_ ≤ d^2*d^(4025*d) := Nat.mul_le_mul_left _ hv
|
| 23 |
+
_ = _ := by rw [←pow_add]; congr 1; omega
|
| 24 |
+
calc
|
| 25 |
+
_ ≤ 3*d^(4025*d+2) := by omega
|
| 26 |
+
_ ≤ d*d^(4025*d+2) := Nat.mul_le_mul_right _ hd
|
| 27 |
+
_ = d^(4025*d+3) := by rw [←pow_succ']
|
| 28 |
+
_ ≤ _ := Nat.pow_le_pow_right hd1 (by omega)
|
| 29 |
+
|
| 30 |
+
lemma instance_exists {m : ℕ} (f : PivotFamily.PFamily (m+1))
|
| 31 |
+
(hm : 3000 ≤ m+1) (hl : 1≤Real.log (m+1:ℕ)) (hH : SourceContraction.H≤(m+1:ℕ))
|
| 32 |
+
(hD : 4*SourceWeighted.D≤(m+1:ℕ))
|
| 33 |
+
(ha : C₀+1≤KernelApprox.cstar/6*(m+1:ℕ)) :
|
| 34 |
+
∃ (n : ℕ) (C : Capacity n), (m+1)^(m+1)≤n ∧ n≤(m+1)^(4030*(m+1)) ∧
|
| 35 |
+
2≤n ∧ 1≤OPT C ∧ 0<glValue C ∧
|
| 36 |
+
glValue C≤(SourceContraction.C+1)*SourceContraction.weight (m+1)/
|
| 37 |
+
(KernelApprox.cstar/6*(m+1:ℕ)) := by
|
| 38 |
+
classical
|
| 39 |
+
let d := m+1
|
| 40 |
+
have hd0 : 0<d := Nat.succ_pos m
|
| 41 |
+
have hx0 : (0:ℝ)<d := by exact_mod_cast hd0
|
| 42 |
+
have hd1 : 1≤d := by omega
|
| 43 |
+
have hx : (1:ℝ)≤d := by exact_mod_cast hd1
|
| 44 |
+
obtain ⟨Z,w,hw,hws,htri,hdiam,havg,hcon⟩ := SourceWeighted.weighted_instance f hm hl hH
|
| 45 |
+
let M := d^d+d^2*Fintype.card (V f)
|
| 46 |
+
have hM : 0<M := lt_of_lt_of_le (pow_pos hd0 _) (Nat.le_add_right _ _)
|
| 47 |
+
let n := Replication.n M w
|
| 48 |
+
let δ := fun i j : Fin n => ‖Z (Replication.rep M w i)-Z (Replication.rep M w j)‖^2
|
| 49 |
+
let ε : ℝ := 4*(SourceWeighted.D*d)*(Fintype.card (V f):ℝ)/M
|
| 50 |
+
have hε : ε≤1 := by
|
| 51 |
+
apply (div_le_one (by exact_mod_cast hM)).mpr
|
| 52 |
+
have hM' : (d:ℝ)^2*(Fintype.card (V f):ℝ)≤M := by
|
| 53 |
+
exact_mod_cast (Nat.le_add_left (d^2*Fintype.card (V f)) (d^d))
|
| 54 |
+
calc
|
| 55 |
+
_ = (4*SourceWeighted.D)*(d:ℝ)*(Fintype.card (V f):ℝ) := by ring
|
| 56 |
+
_ ≤ (d:ℝ)*(d:ℝ)*(Fintype.card (V f):ℝ) :=
|
| 57 |
+
mul_le_mul_of_nonneg_right (mul_le_mul_of_nonneg_right hD hx0.le) (Nat.cast_nonneg _)
|
| 58 |
+
_ = (d:ℝ)^2*(Fintype.card (V f):ℝ) := by ring
|
| 59 |
+
_ ≤ _ := hM'
|
| 60 |
+
have hsize := Replication.n_bounds M w hw hws
|
| 61 |
+
have hlo : d^d≤n := (Nat.le_add_right _ _).trans hsize.1
|
| 62 |
+
have hhi : n≤d^(4030*d) := hsize.2.trans (size_upper (by omega) (SourceCount.card_bound f (by omega)))
|
| 63 |
+
have hn : 2≤n := by
|
| 64 |
+
have hh : d≤d^d := by simpa using (Nat.pow_le_pow_right hd1 hd1 : d^1≤d^d)
|
| 65 |
+
omega
|
| 66 |
+
obtain ⟨hδ,hav,hco⟩ := UniformReplication.estimates M hM w hw hws Z htri
|
| 67 |
+
(mul_nonneg SourceWeighted.D_pos.le hx0.le) hdiam havg hcon
|
| 68 |
+
have ha0 : 0<KernelApprox.cstar/6*(d:ℝ) := mul_pos (div_pos KernelApprox.cstar_pos (by norm_num)) hx0
|
| 69 |
+
have hb0 : 0<(SourceContraction.C+1)*SourceContraction.weight d := by
|
| 70 |
+
have hc := SourceContraction.C_pos
|
| 71 |
+
have hw' := SourceContraction.weight_ge_one hd1 hl
|
| 72 |
+
positivity
|
| 73 |
+
have hlow : KernelApprox.cstar/6*(d:ℝ)≤KernelApprox.cstar/3*(d:ℝ)-C₀*p d 8-ε := by
|
| 74 |
+
have hp : C₀*p d 8≤C₀ := mul_le_of_le_one_right C₀_pos.le (p_one_le hx _)
|
| 75 |
+
linarith only [ha,hp,hε]
|
| 76 |
+
have hupp : SourceContraction.C*SourceContraction.weight d+ε≤
|
| 77 |
+
(SourceContraction.C+1)*SourceContraction.weight d := by
|
| 78 |
+
have hh := SourceContraction.weight_ge_one hd1 hl
|
| 79 |
+
linarith only [hh,hε]
|
| 80 |
+
obtain ⟨C,hopt,hgl,hbound⟩ := cut_cone_duality hn δ hδ ha0 hb0
|
| 81 |
+
((mul_le_mul_of_nonneg_left hlow (sq_nonneg (n:ℝ))).trans hav)
|
| 82 |
+
(fun A hA F hF => (hco A F hF).trans (mul_le_mul_of_nonneg_left hupp (sq_nonneg (n:ℝ))))
|
| 83 |
+
exact ⟨n,C,hlo,hhi,hn,hopt,hgl,hbound⟩
|
| 84 |
+
end
|
| 85 |
+
end UniformSparsestCut.SourceUniform
|
| 86 |
+
|
| 87 |
+
end
|
| 88 |
+
|
| 89 |
+
end OAI
|
lean/OAI/Combinatorics/SparsestCut/UniformReplication.lean
ADDED
|
@@ -0,0 +1,78 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import OAI.Combinatorics.SparsestCut.Replication
|
| 2 |
+
import OAI.Combinatorics.SparsestCut.PositiveKernels
|
| 3 |
+
|
| 4 |
+
namespace OAI
|
| 5 |
+
|
| 6 |
+
universe u1 u2 u3 u4
|
| 7 |
+
|
| 8 |
+
open scoped BigOperators Topology NNReal RealInnerProductSpace InnerProductSpace Matrix ContDiff ENNReal
|
| 9 |
+
open MeasureTheory ProbabilityTheory Set Filter Matrix
|
| 10 |
+
|
| 11 |
+
noncomputable section
|
| 12 |
+
|
| 13 |
+
namespace UniformSparsestCut.UniformReplication
|
| 14 |
+
open scoped BigOperators RealInnerProductSpace
|
| 15 |
+
noncomputable section
|
| 16 |
+
lemma negative_pullback {V : Type u1} {H : Type u2} [NormedAddCommGroup H] [InnerProductSpace ℝ H]
|
| 17 |
+
(Z : V → H) (htri : ∀ v w z, ‖Z v-Z z‖^2 ≤ ‖Z v-Z w‖^2+‖Z w-Z z‖^2)
|
| 18 |
+
{n : ℕ} (r : Fin n → V) : NegativeType (fun i j => ‖Z (r i)-Z (r j)‖^2) := by
|
| 19 |
+
classical
|
| 20 |
+
obtain ⟨Y,hY⟩ := TriangleRepair.exists_gram (TriangleRepair.gram_posSemidef (fun i => Z (r i)))
|
| 21 |
+
refine ⟨⟨Y,?_⟩,fun i j k => htri (r i) (r j) (r k)⟩
|
| 22 |
+
intro i j
|
| 23 |
+
simp only [← real_inner_self_eq_norm_sq, inner_sub_left, inner_sub_right, hY, Matrix.of_apply]
|
| 24 |
+
|
| 25 |
+
variable {V : Type u3} {H : Type u4} [Fintype V] [NormedAddCommGroup H] [InnerProductSpace ℝ H]
|
| 26 |
+
lemma estimates (M : ℕ) (hM : 0<M) (w : V → ℝ) (hw : ∀ v, 0≤w v) (hws : (∑ v,w v)=1)
|
| 27 |
+
(Z : V → H) (htri : ∀ v w z, ‖Z v-Z z‖^2 ≤ ‖Z v-Z w‖^2+‖Z w-Z z‖^2)
|
| 28 |
+
{D a b : ℝ} (hD : 0≤D) (hdiam : ∀ v z, ‖Z v-Z z‖^2≤D)
|
| 29 |
+
(havg : a≤∑ v, ∑ z, w v*w z*‖Z v-Z z‖^2)
|
| 30 |
+
(hcon : ∀ (A : Type) [Fintype A] (F : V → A → ℝ),
|
| 31 |
+
(∀ v z, (∑ k, |F v k-F z k|)≤‖Z v-Z z‖^2) →
|
| 32 |
+
(∑ v, ∑ z, w v*w z*(∑ k, |F v k-F z k|))≤b) :
|
| 33 |
+
let n := Replication.n M w
|
| 34 |
+
let d := fun i j : Fin n => ‖Z (Replication.rep M w i)-Z (Replication.rep M w j)‖^2
|
| 35 |
+
let ε := 4*D*(Fintype.card V:ℝ)/M
|
| 36 |
+
NegativeType d ∧ (n:ℝ)^2*(a-ε)≤∑ i, ∑ j,d i j ∧
|
| 37 |
+
∀ (A : Type) [Fintype A] (F : Fin n → A → ℝ),
|
| 38 |
+
(∀ i j, (∑ k, |F i k-F j k|)≤d i j) →
|
| 39 |
+
(∑ i, ∑ j, ∑ k, |F i k-F j k|)≤(n:ℝ)^2*(b+ε) := by
|
| 40 |
+
dsimp only
|
| 41 |
+
have hn : 0<Replication.n M w := hM.trans_le (Replication.n_bounds M w hw hws).1
|
| 42 |
+
refine ⟨negative_pullback Z htri _,?_,?_⟩
|
| 43 |
+
· rw [Replication.ordered_sum M w hn (fun v z => ‖Z v-Z z‖^2)]
|
| 44 |
+
apply mul_le_mul_of_nonneg_left _ (sq_nonneg _)
|
| 45 |
+
have he := Replication.expectation_error M hM w hw hws
|
| 46 |
+
(fun v z => ‖Z v-Z z‖^2) hD (fun v z => by rw [abs_of_nonneg (sq_nonneg _)]; exact hdiam v z)
|
| 47 |
+
linarith [(abs_le.mp he).1]
|
| 48 |
+
· intro A hA F hF
|
| 49 |
+
let G : V → A → ℝ := fun v k => F (Replication.representative M w v) k
|
| 50 |
+
have hG : ∀ v z, (∑ k, |G v k-G z k|)≤‖Z v-Z z‖^2 :=
|
| 51 |
+
Replication.descend_contraction M w _ F hF
|
| 52 |
+
have he : (∑ i, ∑ j, ∑ k, |F i k-F j k|)=
|
| 53 |
+
∑ i, ∑ j, ∑ k, |G (Replication.rep M w i) k-G (Replication.rep M w j) k| := by
|
| 54 |
+
apply Finset.sum_congr rfl
|
| 55 |
+
intro i hi
|
| 56 |
+
apply Finset.sum_congr rfl
|
| 57 |
+
intro j hj
|
| 58 |
+
apply Finset.sum_congr rfl
|
| 59 |
+
intro k hk
|
| 60 |
+
have h1 := Replication.collapse M w (fun v z => ‖Z v-Z z‖^2) (by simp) F hF i k
|
| 61 |
+
have h2 := Replication.collapse M w (fun v z => ‖Z v-Z z‖^2) (by simp) F hF j k
|
| 62 |
+
change |F i k-F j k|=|F (Replication.representative M w (Replication.rep M w i)) k-
|
| 63 |
+
F (Replication.representative M w (Replication.rep M w j)) k|
|
| 64 |
+
rw [h1,h2]
|
| 65 |
+
rw [he,Replication.ordered_sum M w hn (fun v z => ∑ k, |G v k-G z k|)]
|
| 66 |
+
apply mul_le_mul_of_nonneg_left _ (sq_nonneg _)
|
| 67 |
+
have herr := Replication.expectation_error M hM w hw hws
|
| 68 |
+
(fun v z => ∑ k, |G v k-G z k|) hD (fun v z => by
|
| 69 |
+
rw [abs_of_nonneg (Finset.sum_nonneg (fun k _ => abs_nonneg _))]
|
| 70 |
+
exact (hG v z).trans (hdiam v z))
|
| 71 |
+
have hbound := hcon A G hG
|
| 72 |
+
linarith [(abs_le.mp herr).2]
|
| 73 |
+
end
|
| 74 |
+
end UniformSparsestCut.UniformReplication
|
| 75 |
+
|
| 76 |
+
end
|
| 77 |
+
|
| 78 |
+
end OAI
|
lean/OAI/Combinatorics/SparsestCut/VertexCount.lean
ADDED
|
@@ -0,0 +1,75 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import OAI.Combinatorics.SparsestCut.LabelCount
|
| 2 |
+
|
| 3 |
+
namespace OAI
|
| 4 |
+
|
| 5 |
+
open scoped BigOperators Topology NNReal RealInnerProductSpace InnerProductSpace Matrix ContDiff ENNReal
|
| 6 |
+
open MeasureTheory ProbabilityTheory Set Filter Matrix
|
| 7 |
+
|
| 8 |
+
noncomputable section
|
| 9 |
+
|
| 10 |
+
namespace UniformSparsestCut.SourceCount
|
| 11 |
+
open SourceCharts SourceParameters SourceMetric
|
| 12 |
+
open scoped BigOperators
|
| 13 |
+
noncomputable section
|
| 14 |
+
variable {m : ℕ} (f : PivotFamily.PFamily m) [NeZero m]
|
| 15 |
+
lemma integer_bound (hm : 5 ≤ m) (v : V f) (i : Fin (m^6)) : |(v.val.2 i:ℝ)|≤(m:ℝ)^2003 := by
|
| 16 |
+
have hm0 := NeZero.pos m
|
| 17 |
+
have hx : (1:ℝ) ≤ m := by exact_mod_cast (show 1 ≤ m by omega)
|
| 18 |
+
have hx5 : (5:ℝ) ≤ m := by exact_mod_cast hm
|
| 19 |
+
have hx0 : (0:ℝ)< m := by exact_mod_cast hm0
|
| 20 |
+
obtain ⟨θ,hθ,hr,he⟩ := v.property
|
| 21 |
+
have h := RoundedCharts.integerLabel_bound (u f v.val.1) (p_pos hx0 2000)
|
| 22 |
+
(fun i => (u_norm f hm0 v.val.1 i).2) hθ i
|
| 23 |
+
rw [he] at h
|
| 24 |
+
calc
|
| 25 |
+
_ ≤ 4*Real.sqrt m/p m 2000+1 := h
|
| 26 |
+
_ ≤ 4*(m:ℝ)/p m 2000+1 := by
|
| 27 |
+
apply add_le_add_left
|
| 28 |
+
apply div_le_div_of_nonneg_right _ (p_nonneg hx0.le _)
|
| 29 |
+
exact mul_le_mul_of_nonneg_left (sqrt_le hx) (by norm_num)
|
| 30 |
+
_ = 4*(m:ℝ)^2001+1 := by unfold p; field_simp
|
| 31 |
+
_ ≤ 5*(m:ℝ)^2001 := by nlinarith [one_le_pow₀ hx (n:=2001)]
|
| 32 |
+
_ ≤ (m:ℝ)*(m:ℝ)^2001 := mul_le_mul_of_nonneg_right hx5 (by positivity)
|
| 33 |
+
_ = (m:ℝ)^2002 := by ring
|
| 34 |
+
_ ≤ _ := pow_le_pow_right₀ hx (by norm_num)
|
| 35 |
+
lemma card_bound (hm : 5 ≤ m) : Fintype.card (V f)≤ m^(4025*m) := by
|
| 36 |
+
have hm0 := NeZero.pos m
|
| 37 |
+
have hx0 : (0:ℝ)< m := by exact_mod_cast hm0
|
| 38 |
+
let B : ℤ := (m:ℤ)^2003
|
| 39 |
+
have hB : ∀ v : V f, ∀ i, v.val.2 i∈Finset.Icc (-B) B := by
|
| 40 |
+
intro v i
|
| 41 |
+
have h := integer_bound f hm v i
|
| 42 |
+
have h' : |v.val.2 i|≤B := by exact_mod_cast h
|
| 43 |
+
simpa only [Finset.mem_Icc,abs_le] using h'
|
| 44 |
+
have h := LabelCount.vertex_count (u f) (p_pos hx0 2000) B hB
|
| 45 |
+
have hI : (Finset.Icc (-B) B).card=2*m^2003+1 := by
|
| 46 |
+
rw [Int.card_Icc]
|
| 47 |
+
dsimp [B]
|
| 48 |
+
have he : (m:ℤ)^2003+1-(-(m:ℤ)^2003)=((2*m^2003+1:ℕ):ℤ) := by push_cast; ring
|
| 49 |
+
rw [he,Int.toNat_natCast]
|
| 50 |
+
rw [hI] at h
|
| 51 |
+
have hm1 : 1 ≤ m := by omega
|
| 52 |
+
have hp : 1≤ m^2003 := one_le_pow₀ hm1
|
| 53 |
+
have hI' : 2*m^2003+1≤ m^2004 := by
|
| 54 |
+
calc
|
| 55 |
+
_ ≤ 3*m^2003 := by omega
|
| 56 |
+
_ ≤ m*m^2003 := Nat.mul_le_mul_right _ (by omega)
|
| 57 |
+
_ = _ := by ring
|
| 58 |
+
have hH : m^6*(2*m^2003+1)+1≤ m^2011 := by
|
| 59 |
+
calc
|
| 60 |
+
_ ≤ m^6*m^2004+1 := Nat.add_le_add_right (Nat.mul_le_mul_left _ hI') _
|
| 61 |
+
_ = m^2010+1 := by ring
|
| 62 |
+
_ ≤ 2*m^2010 := by have hh := one_le_pow₀ hm1 (n:=2010); omega
|
| 63 |
+
_ ≤ m*m^2010 := Nat.mul_le_mul_right _ (by omega)
|
| 64 |
+
_ = _ := by ring
|
| 65 |
+
calc
|
| 66 |
+
_ ≤ m^3*(m^6*(2*m^2003+1)+1)^(m+1) := h
|
| 67 |
+
_ ≤ m^3*(m^2011)^(m+1) := Nat.mul_le_mul_left _ (Nat.pow_le_pow_left hH _)
|
| 68 |
+
_ = m^(3+2011*(m+1)) := by rw [← pow_mul,← pow_add]
|
| 69 |
+
_ ≤ _ := Nat.pow_le_pow_right hm1 (by omega)
|
| 70 |
+
end
|
| 71 |
+
end UniformSparsestCut.SourceCount
|
| 72 |
+
|
| 73 |
+
end
|
| 74 |
+
|
| 75 |
+
end OAI
|
lean/OAI/Combinatorics/SparsestCut/VertexMeasure.lean
ADDED
|
@@ -0,0 +1,96 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import OAI.Combinatorics.SparsestCut.ContractionAverage
|
| 2 |
+
|
| 3 |
+
namespace OAI
|
| 4 |
+
|
| 5 |
+
universe u1
|
| 6 |
+
|
| 7 |
+
open scoped BigOperators Topology NNReal RealInnerProductSpace InnerProductSpace Matrix ContDiff ENNReal
|
| 8 |
+
open MeasureTheory ProbabilityTheory Set Filter Matrix
|
| 9 |
+
|
| 10 |
+
noncomputable section
|
| 11 |
+
|
| 12 |
+
namespace UniformSparsestCut.VertexMeasure
|
| 13 |
+
open MeasureTheory Set Filter
|
| 14 |
+
open scoped BigOperators RealInnerProductSpace
|
| 15 |
+
noncomputable section
|
| 16 |
+
variable {m N S : ℕ}
|
| 17 |
+
local notation "E" => EuclideanSpace ℝ (Fin m)
|
| 18 |
+
local notation "μ" => (CubePoincare.cube (m:=m))
|
| 19 |
+
local instance {u : Fin S → Fin N → E} {τ : ℝ} : MeasurableSpace (RoundedCharts.Vertex u τ) := by unfold RoundedCharts.Vertex; infer_instance
|
| 20 |
+
local instance {u : Fin S → Fin N → E} {τ : ℝ} : MeasurableSingletonClass (RoundedCharts.Vertex u τ) := by unfold RoundedCharts.Vertex; infer_instance
|
| 21 |
+
lemma cube_measurable (R : ℝ) : MeasurableSet (RoundedCharts.cube (m:=m) R) := by
|
| 22 |
+
rw [show RoundedCharts.cube (m:=m) R=(⋂ j : Fin m, {x : E | |x j|<R}) by ext x; simp [RoundedCharts.cube]]
|
| 23 |
+
apply MeasurableSet.iInter
|
| 24 |
+
intro j
|
| 25 |
+
exact measurableSet_lt (by fun_prop) measurable_const
|
| 26 |
+
lemma regular_measurable (u : Fin N → E) (τ : ℝ) : MeasurableSet {x | RoundedCharts.regular u τ x} := by
|
| 27 |
+
rw [show {x | RoundedCharts.regular u τ x}=(⋂ i : Fin N, ⋂ k : ℤ, {x : E | inner ℝ (u i) x ≠ (k:ℝ)*τ}) by ext x; simp [RoundedCharts.regular]]
|
| 28 |
+
apply MeasurableSet.iInter
|
| 29 |
+
intro i
|
| 30 |
+
apply MeasurableSet.iInter
|
| 31 |
+
intro k
|
| 32 |
+
exact (isClosed_eq (by fun_prop : Continuous (fun x : E => inner ℝ (u i) x)) continuous_const).measurableSet.compl
|
| 33 |
+
lemma integer_measurable (u : Fin N → E) (τ : ℝ) : Measurable (RoundedCharts.integerLabel u τ) := by
|
| 34 |
+
apply Measurable.of_eval
|
| 35 |
+
intro i
|
| 36 |
+
exact Int.measurable_floor.comp (by fun_prop)
|
| 37 |
+
open Classical in
|
| 38 |
+
def label (u : Fin S → Fin N → E) (τ : ℝ) (s : Fin S) (v₀ : RoundedCharts.Vertex u τ) (x : E) : RoundedCharts.Vertex u τ :=
|
| 39 |
+
if h : x∈RoundedCharts.cube 2 ∧ RoundedCharts.regular (u s) τ x then
|
| 40 |
+
⟨(s,RoundedCharts.integerLabel (u s) τ x),x,h.1,h.2,rfl⟩ else v₀
|
| 41 |
+
lemma label_measurable (u : Fin S → Fin N → E) (τ : ℝ) (s : Fin S) (v₀ : RoundedCharts.Vertex u τ) :
|
| 42 |
+
Measurable (label u τ s v₀) := by
|
| 43 |
+
classical
|
| 44 |
+
have hh : Measurable (fun x : E => if x∈RoundedCharts.cube 2 ∧ RoundedCharts.regular (u s) τ x then
|
| 45 |
+
(s,RoundedCharts.integerLabel (u s) τ x) else v₀.val) :=
|
| 46 |
+
(measurable_const.prodMk (integer_measurable (u s) τ)).ite ((cube_measurable 2).inter (regular_measurable (u s) τ)) measurable_const
|
| 47 |
+
have hval : Measurable (fun x => (label u τ s v₀ x).val) := by
|
| 48 |
+
convert hh using 1
|
| 49 |
+
funext x
|
| 50 |
+
by_cases hgood : x ∈ RoundedCharts.cube 2 ∧ RoundedCharts.regular (u s) τ x <;>
|
| 51 |
+
simp [label, hgood]
|
| 52 |
+
exact hval.subtype_mk
|
| 53 |
+
lemma ae_good (u : Fin N → E) (hu : ∀ i, u i≠0) (τ : ℝ) :
|
| 54 |
+
∀ᵐ x : E ∂μ, x∈RoundedCharts.cube 2 ∧ RoundedCharts.regular u τ x := by
|
| 55 |
+
filter_upwards [CubeGeometry.cube_mem (m:=m), CubeGeometry.cube_ac.ae_le (RoundedCharts.ae_regular u τ hu)] with x hx hr
|
| 56 |
+
exact ⟨fun j => (hx j).trans (by norm_num),hr⟩
|
| 57 |
+
lemma vertex_nonempty (u : Fin S → Fin N → E) (hu : ∀ s i, u s i≠0) (τ : ℝ) (s : Fin S) :
|
| 58 |
+
Nonempty (RoundedCharts.Vertex u τ) := by
|
| 59 |
+
obtain ⟨x,hx,hr⟩ := (ae_good (u s) (hu s) τ).exists
|
| 60 |
+
exact ⟨⟨(s,RoundedCharts.integerLabel (u s) τ x),x,hx,hr,rfl⟩⟩
|
| 61 |
+
def measure (u : Fin S → Fin N → E) (τ : ℝ) (s : Fin S) (v₀ : RoundedCharts.Vertex u τ) : Measure (RoundedCharts.Vertex u τ) :=
|
| 62 |
+
(μ).map (label u τ s v₀)
|
| 63 |
+
instance probability (u : Fin S → Fin N → E) (τ : ℝ) (s : Fin S) (v₀ : RoundedCharts.Vertex u τ) :
|
| 64 |
+
IsProbabilityMeasure (measure u τ s v₀) := by
|
| 65 |
+
change IsProbabilityMeasure ((μ).map (label u τ s v₀))
|
| 66 |
+
infer_instance
|
| 67 |
+
lemma finite_weights {V : Type u1} [Fintype V] [MeasurableSpace V] [MeasurableSingletonClass V]
|
| 68 |
+
(ν : Measure V) [IsProbabilityMeasure ν] : (∑ v, ν.real {v})=1 := by
|
| 69 |
+
have h : (∫ _ : V, (1:ℝ) ∂ν)=∑ v, ν.real {v} • (1:ℝ) := integral_fintype (integrable_const _)
|
| 70 |
+
simp
|
| 71 |
+
lemma pair_average (u : Fin S → Fin N → E) (τ : ℝ) (s : Fin S) (v₀ : RoundedCharts.Vertex u τ)
|
| 72 |
+
[Fintype (RoundedCharts.Vertex u τ)] (d : RoundedCharts.Vertex u τ → RoundedCharts.Vertex u τ → ℝ) :
|
| 73 |
+
(∑ v, ∑ w, (measure u τ s v₀).real {v}*(measure u τ s v₀).real {w}*d v w)=
|
| 74 |
+
∫ z : E × E, d (label u τ s v₀ z.1) (label u τ s v₀ z.2) ∂(μ).prod μ := by
|
| 75 |
+
let ν := measure u τ s v₀
|
| 76 |
+
calc
|
| 77 |
+
_ = ∫ z : RoundedCharts.Vertex u τ × RoundedCharts.Vertex u τ, d z.1 z.2 ∂ν.prod ν := by
|
| 78 |
+
rw [integral_fintype Integrable.of_finite, Fintype.sum_prod_type]
|
| 79 |
+
apply Finset.sum_congr rfl
|
| 80 |
+
intro v hv
|
| 81 |
+
apply Finset.sum_congr rfl
|
| 82 |
+
intro w hw
|
| 83 |
+
rw [show ({(v,w)} : Set (RoundedCharts.Vertex u τ × RoundedCharts.Vertex u τ))={v}×ˢ{w} by ext z; simp]
|
| 84 |
+
rw [measureReal_prod_prod]
|
| 85 |
+
rfl
|
| 86 |
+
_ = _ := by
|
| 87 |
+
change (∫ z, d z.1 z.2 ∂((μ).map (label u τ s v₀)).prod ((μ).map (label u τ s v₀)))=_
|
| 88 |
+
rw [Measure.map_prod_map μ μ (label_measurable u τ s v₀) (label_measurable u τ s v₀)]
|
| 89 |
+
exact integral_map ((label_measurable u τ s v₀).prodMap (label_measurable u τ s v₀)).aemeasurable
|
| 90 |
+
(measurable_of_countable _).aestronglyMeasurable
|
| 91 |
+
end
|
| 92 |
+
end UniformSparsestCut.VertexMeasure
|
| 93 |
+
|
| 94 |
+
end
|
| 95 |
+
|
| 96 |
+
end OAI
|
lean/OAI/Combinatorics/SparsestCut/WeightNormalization.lean
ADDED
|
@@ -0,0 +1,79 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/-
|
| 2 |
+
Copyright (c) 2026 OpenAI. All rights reserved.
|
| 3 |
+
Authors: OpenAI
|
| 4 |
+
-/
|
| 5 |
+
import OAI.Combinatorics.SparsestCut.FiniteWeights
|
| 6 |
+
import Mathlib.Algebra.BigOperators.Field
|
| 7 |
+
|
| 8 |
+
namespace OAI
|
| 9 |
+
|
| 10 |
+
/-!
|
| 11 |
+
# Normalization of finite weights
|
| 12 |
+
|
| 13 |
+
A lower approximation to a probability law retains coordinatewise domination and
|
| 14 |
+
setwise lower bounds after normalization. These are the retained-demand estimates
|
| 15 |
+
in Section 7 of OpenAI's *Constant-factor hardness of uniform sparsest cut*.
|
| 16 |
+
-/
|
| 17 |
+
|
| 18 |
+
open scoped BigOperators
|
| 19 |
+
|
| 20 |
+
namespace UniformSparsestCut.FiniteWeights
|
| 21 |
+
|
| 22 |
+
variable {ι : Type*} [Fintype ι]
|
| 23 |
+
|
| 24 |
+
noncomputable def normalized (l : ι → ℝ) : ι → ℝ := fun i => l i / total l
|
| 25 |
+
|
| 26 |
+
theorem normalized_nonneg {l : ι → ℝ} (hl : ∀ i, 0 ≤ l i) (hL : 0 < total l) :
|
| 27 |
+
∀ i, 0 ≤ normalized l i :=
|
| 28 |
+
fun i => div_nonneg (hl i) hL.le
|
| 29 |
+
|
| 30 |
+
theorem normalized_total {l : ι → ℝ} (hL : 0 < total l) : total (normalized l) = 1 := by
|
| 31 |
+
change (∑ i, l i / total l) = 1
|
| 32 |
+
rw [← Finset.sum_div]
|
| 33 |
+
exact div_self (ne_of_gt hL)
|
| 34 |
+
|
| 35 |
+
theorem normalized_mass (l : ι → ℝ) (h : ι → Bool) :
|
| 36 |
+
mass (normalized l) h = mass l h / total l := by
|
| 37 |
+
change (∑ i, l i / total l * indicator (h i)) = mass l h / total l
|
| 38 |
+
simp_rw [div_mul_eq_mul_div]
|
| 39 |
+
rw [← Finset.sum_div]
|
| 40 |
+
rfl
|
| 41 |
+
|
| 42 |
+
/-- Normalization of a sufficiently large lower approximation increases each weight
|
| 43 |
+
by at most a factor of two. -/
|
| 44 |
+
theorem normalized_le_twice {μ l : ι → ℝ} {ε : ℝ}
|
| 45 |
+
(hμ : ∀ i, 0 ≤ μ i) (hle : ∀ i, l i ≤ μ i)
|
| 46 |
+
(hε : ε ≤ 1 / 2) (hL : 1 - ε ≤ total l) :
|
| 47 |
+
∀ i, normalized l i ≤ 2 * μ i := by
|
| 48 |
+
have hpos : 0 < total l := by linarith
|
| 49 |
+
intro i
|
| 50 |
+
apply (div_le_iff₀ hpos).mpr
|
| 51 |
+
have hh := mul_nonneg (hμ i) (show 0 ≤ 2 * total l - 1 by linarith)
|
| 52 |
+
nlinarith only [hh, hle i]
|
| 53 |
+
|
| 54 |
+
/-- Every finite event loses at most the discarded mass after normalization. -/
|
| 55 |
+
theorem normalized_event_lower {μ l : ι → ℝ} {ε : ℝ}
|
| 56 |
+
(hl : ∀ i, 0 ≤ l i) (hle : ∀ i, l i ≤ μ i) (hμ₁ : total μ = 1)
|
| 57 |
+
(hε : ε ≤ 1 / 2) (hL : 1 - ε ≤ total l) (E : Finset ι) :
|
| 58 |
+
(∑ i ∈ E, μ i) - ε ≤ ∑ i ∈ E, normalized l i := by
|
| 59 |
+
have hpos : 0 < total l := by linarith
|
| 60 |
+
have hL₁ : total l ≤ 1 := by simpa [hμ₁] using total_mono hle
|
| 61 |
+
have herr : (∑ i ∈ E, (μ i - l i)) ≤ 1 - total l := by
|
| 62 |
+
calc
|
| 63 |
+
_ ≤ ∑ i, (μ i - l i) :=
|
| 64 |
+
Finset.sum_le_univ_sum_of_nonneg (fun i => sub_nonneg.mpr (hle i))
|
| 65 |
+
_ = _ := by
|
| 66 |
+
rw [Finset.sum_sub_distrib]
|
| 67 |
+
change total μ - total l = 1 - total l
|
| 68 |
+
rw [hμ₁]
|
| 69 |
+
have hgain : (∑ i ∈ E, l i) ≤ ∑ i ∈ E, normalized l i := by
|
| 70 |
+
apply Finset.sum_le_sum
|
| 71 |
+
intro i _
|
| 72 |
+
apply (le_div_iff₀ hpos).mpr
|
| 73 |
+
simpa using mul_le_mul_of_nonneg_left hL₁ (hl i)
|
| 74 |
+
rw [Finset.sum_sub_distrib] at herr
|
| 75 |
+
linarith
|
| 76 |
+
|
| 77 |
+
end UniformSparsestCut.FiniteWeights
|
| 78 |
+
|
| 79 |
+
end OAI
|
lean/OAI/Combinatorics/SparsestCut/WeightReplacement.lean
ADDED
|
@@ -0,0 +1,171 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import OAI.Combinatorics.SparsestCut.FiniteWeights
|
| 2 |
+
|
| 3 |
+
namespace OAI
|
| 4 |
+
|
| 5 |
+
/-!
|
| 6 |
+
# Replacing vertices of zero retained demand
|
| 7 |
+
|
| 8 |
+
The replacement coupling of Section 7 of OpenAI's
|
| 9 |
+
*Constant-factor hardness of uniform sparsest cut* keeps a draw of positive
|
| 10 |
+
retained demand and replaces every other draw by an independent retained-demand
|
| 11 |
+
draw. Its color-change probability controls the change in Boolean variance.
|
| 12 |
+
-/
|
| 13 |
+
|
| 14 |
+
namespace UniformSparsestCut.FiniteWeights
|
| 15 |
+
|
| 16 |
+
variable {ι : Type*} [Fintype ι]
|
| 17 |
+
|
| 18 |
+
/-- The original law restricted to keys with zero retained demand. -/
|
| 19 |
+
noncomputable def auxiliaryWeights (w retained : ι → ℝ) : ι → ℝ := by
|
| 20 |
+
classical
|
| 21 |
+
exact fun i => if retained i = 0 then w i else 0
|
| 22 |
+
|
| 23 |
+
/-- The original law restricted to keys with nonzero retained demand. -/
|
| 24 |
+
noncomputable def supportedWeights (w retained : ι → ℝ) : ι → ℝ := by
|
| 25 |
+
classical
|
| 26 |
+
exact fun i => if retained i = 0 then 0 else w i
|
| 27 |
+
|
| 28 |
+
/-- Retain supported draws and replace all others by an independent retained-demand draw. -/
|
| 29 |
+
noncomputable def replacementWeights (w retained : ι → ℝ) : ι → ℝ :=
|
| 30 |
+
fun i => supportedWeights w retained i + total (auxiliaryWeights w retained) * retained i
|
| 31 |
+
|
| 32 |
+
omit [Fintype ι] in
|
| 33 |
+
theorem weights_decomposition (w retained : ι → ℝ) (i : ι) :
|
| 34 |
+
supportedWeights w retained i + auxiliaryWeights w retained i = w i := by
|
| 35 |
+
classical
|
| 36 |
+
by_cases hi : retained i = 0 <;> simp [supportedWeights, auxiliaryWeights, hi]
|
| 37 |
+
|
| 38 |
+
theorem total_decomposition (w retained : ι → ℝ) :
|
| 39 |
+
total (supportedWeights w retained) + total (auxiliaryWeights w retained) = total w := by
|
| 40 |
+
rw [← total_add]
|
| 41 |
+
congr 1
|
| 42 |
+
funext i
|
| 43 |
+
exact weights_decomposition w retained i
|
| 44 |
+
|
| 45 |
+
theorem mass_decomposition (w retained : ι → ℝ) (h : ι → Bool) :
|
| 46 |
+
mass (supportedWeights w retained) h + mass (auxiliaryWeights w retained) h = mass w h := by
|
| 47 |
+
rw [← mass_add]
|
| 48 |
+
congr 1
|
| 49 |
+
funext i
|
| 50 |
+
exact weights_decomposition w retained i
|
| 51 |
+
|
| 52 |
+
omit [Fintype ι] in
|
| 53 |
+
theorem auxiliary_nonneg {w : ι → ℝ} (hw : ∀ i, 0 ≤ w i) (retained : ι → ℝ) :
|
| 54 |
+
∀ i, 0 ≤ auxiliaryWeights w retained i := by
|
| 55 |
+
classical
|
| 56 |
+
intro i
|
| 57 |
+
dsimp [auxiliaryWeights]
|
| 58 |
+
split
|
| 59 |
+
· exact hw i
|
| 60 |
+
· exact le_rfl
|
| 61 |
+
|
| 62 |
+
omit [Fintype ι] in
|
| 63 |
+
theorem supported_nonneg {w : ι → ℝ} (hw : ∀ i, 0 ≤ w i) (retained : ι → ℝ) :
|
| 64 |
+
∀ i, 0 ≤ supportedWeights w retained i := by
|
| 65 |
+
classical
|
| 66 |
+
intro i
|
| 67 |
+
dsimp [supportedWeights]
|
| 68 |
+
split
|
| 69 |
+
· exact le_rfl
|
| 70 |
+
· exact hw i
|
| 71 |
+
|
| 72 |
+
omit [Fintype ι] in
|
| 73 |
+
theorem auxiliary_le {w : ι → ℝ} (hw : ∀ i, 0 ≤ w i) (retained : ι → ℝ) :
|
| 74 |
+
∀ i, auxiliaryWeights w retained i ≤ w i := by
|
| 75 |
+
classical
|
| 76 |
+
intro i
|
| 77 |
+
dsimp [auxiliaryWeights]
|
| 78 |
+
split
|
| 79 |
+
· exact le_rfl
|
| 80 |
+
· exact hw i
|
| 81 |
+
|
| 82 |
+
theorem auxiliary_total_le_one {w : ι → ℝ} (hw : ∀ i, 0 ≤ w i)
|
| 83 |
+
(hw₁ : total w = 1) (retained : ι → ℝ) : total (auxiliaryWeights w retained) ≤ 1 := by
|
| 84 |
+
simpa [hw₁] using total_mono (auxiliary_le hw retained)
|
| 85 |
+
|
| 86 |
+
theorem replacement_nonneg {w retained : ι → ℝ} (hw : ∀ i, 0 ≤ w i)
|
| 87 |
+
(hr : ∀ i, 0 ≤ retained i) : ∀ i, 0 ≤ replacementWeights w retained i := by
|
| 88 |
+
intro i
|
| 89 |
+
exact add_nonneg (supported_nonneg hw retained i)
|
| 90 |
+
(mul_nonneg (total_nonneg (auxiliary_nonneg hw retained)) (hr i))
|
| 91 |
+
|
| 92 |
+
theorem replacement_total {w retained : ι → ℝ} (hw₁ : total w = 1)
|
| 93 |
+
(hr₁ : total retained = 1) : total (replacementWeights w retained) = 1 := by
|
| 94 |
+
change total (fun i => supportedWeights w retained i +
|
| 95 |
+
total (auxiliaryWeights w retained) * retained i) = 1
|
| 96 |
+
rw [total_add, total_smul, hr₁, mul_one,
|
| 97 |
+
total_decomposition, hw₁]
|
| 98 |
+
|
| 99 |
+
theorem replacement_mass (w retained : ι → ℝ) (h : ι → Bool) :
|
| 100 |
+
mass (replacementWeights w retained) h = mass (supportedWeights w retained) h +
|
| 101 |
+
total (auxiliaryWeights w retained) * mass retained h := by
|
| 102 |
+
change mass (fun i => supportedWeights w retained i +
|
| 103 |
+
total (auxiliaryWeights w retained) * retained i) h = _
|
| 104 |
+
rw [mass_add, mass_smul]
|
| 105 |
+
|
| 106 |
+
/-- Domination of the replacement law before comparison with the original score law. -/
|
| 107 |
+
theorem replacement_le_three {w retained : ι → ℝ} (hw : ∀ i, 0 ≤ w i)
|
| 108 |
+
(hw₁ : total w = 1) (hr : ∀ i, 0 ≤ retained i)
|
| 109 |
+
(hrep : ∀ i, 0 < retained i → w i ≤ 2 * retained i) :
|
| 110 |
+
∀ i, replacementWeights w retained i ≤ 3 * retained i := by
|
| 111 |
+
classical
|
| 112 |
+
intro i
|
| 113 |
+
have hs : supportedWeights w retained i ≤ 2 * retained i := by
|
| 114 |
+
by_cases hi : retained i = 0
|
| 115 |
+
· simp [supportedWeights, hi]
|
| 116 |
+
· simpa [supportedWeights, hi] using hrep i (lt_of_le_of_ne (hr i) (Ne.symm hi))
|
| 117 |
+
have ha : total (auxiliaryWeights w retained) * retained i ≤ retained i := by
|
| 118 |
+
simpa using mul_le_mul_of_nonneg_right (auxiliary_total_le_one hw hw₁ retained) (hr i)
|
| 119 |
+
dsimp [replacementWeights]
|
| 120 |
+
linarith only [hs, ha]
|
| 121 |
+
|
| 122 |
+
/-- The actual color-change cost of the replacement experiment bounds both signed
|
| 123 |
+
changes in the probability of color one. -/
|
| 124 |
+
theorem replacement_mass_change {w retained : ι → ℝ} (hw : ∀ i, 0 �� w i)
|
| 125 |
+
(hr : ∀ i, 0 ≤ retained i) (hr₁ : total retained = 1) (h : ι → Bool) :
|
| 126 |
+
mass w h - mass (replacementWeights w retained) h ≤
|
| 127 |
+
disagreement (auxiliaryWeights w retained) retained h ∧
|
| 128 |
+
mass (replacementWeights w retained) h - mass w h ≤
|
| 129 |
+
disagreement (auxiliaryWeights w retained) retained h := by
|
| 130 |
+
rw [replacement_mass, disagreement_eq, hr₁]
|
| 131 |
+
have hdec := mass_decomposition w retained h
|
| 132 |
+
have haux := auxiliary_nonneg hw retained
|
| 133 |
+
have ht : 0 ≤ 1 - mass retained h := sub_nonneg.mpr (hr₁ ▸ mass_le_total hr h)
|
| 134 |
+
have hp := mul_nonneg (mass_nonneg haux h) ht
|
| 135 |
+
have hq := mul_nonneg (sub_nonneg.mpr (mass_le_total haux h)) (mass_nonneg hr h)
|
| 136 |
+
constructor <;> nlinarith only [hdec, hp, hq]
|
| 137 |
+
|
| 138 |
+
/-- Variance transfer for the replacement coupling in Section 7 of
|
| 139 |
+
*Constant-factor hardness of uniform sparsest cut*.
|
| 140 |
+
|
| 141 |
+
Here `w` is the counting law on clusters, `μ` the original score demand law, and
|
| 142 |
+
`retained` the normalized retained demand. Zero retained mass is allowed.
|
| 143 |
+
The final term is the probability that replacement changes the color, denoted
|
| 144 |
+
`L_aux` in the paper.
|
| 145 |
+
-/
|
| 146 |
+
theorem variance_transfer {w μ retained : ι → ℝ}
|
| 147 |
+
(hw : ∀ i, 0 ≤ w i) (hμ : ∀ i, 0 ≤ μ i) (hr : ∀ i, 0 ≤ retained i)
|
| 148 |
+
(hw₁ : total w = 1) (hμ₁ : total μ = 1) (hr₁ : total retained = 1)
|
| 149 |
+
(hret : ∀ i, retained i ≤ 2 * μ i)
|
| 150 |
+
(hrep : ∀ i, 0 < retained i → w i ≤ 2 * retained i) (h : ι → Bool) :
|
| 151 |
+
variance w h ≤ 36 * variance μ h + disagreement (auxiliaryWeights w retained) retained h := by
|
| 152 |
+
have hρ := replacement_nonneg hw hr
|
| 153 |
+
have hρ₁ := replacement_total hw₁ hr₁
|
| 154 |
+
have hdom : ∀ i, replacementWeights w retained i ≤ 6 * μ i := by
|
| 155 |
+
intro i
|
| 156 |
+
have hthree := replacement_le_three hw hw₁ hr hrep i
|
| 157 |
+
linarith only [hthree, hret i]
|
| 158 |
+
have hv : variance (replacementWeights w retained) h ≤ 36 * variance μ h := by
|
| 159 |
+
have hv' := variance_domination hρ hμ hρ₁ hμ₁ (by norm_num : (0 : ℝ) ≤ 6) hdom h
|
| 160 |
+
norm_num at hv'
|
| 161 |
+
exact hv'
|
| 162 |
+
have hd := replacement_mass_change hw hr hr₁ h
|
| 163 |
+
have hc : variance w h ≤ variance (replacementWeights w retained) h +
|
| 164 |
+
disagreement (auxiliaryWeights w retained) retained h :=
|
| 165 |
+
variance_change (mass_nonneg hw h) (hw₁ ▸ mass_le_total hw h)
|
| 166 |
+
(mass_nonneg hρ h) (hρ₁ ▸ mass_le_total hρ h) hd.1 hd.2
|
| 167 |
+
exact hc.trans (add_le_add hv le_rfl)
|
| 168 |
+
|
| 169 |
+
end UniformSparsestCut.FiniteWeights
|
| 170 |
+
|
| 171 |
+
end OAI
|
lean/OAI/Combinatorics/SparsestCut/WeightReplication.lean
ADDED
|
@@ -0,0 +1,133 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/-
|
| 2 |
+
Copyright (c) 2026 OpenAI. All rights reserved.
|
| 3 |
+
Authors: OpenAI
|
| 4 |
+
-/
|
| 5 |
+
import OAI.Combinatorics.SparsestCut.WeightReplacement
|
| 6 |
+
import Mathlib.Algebra.BigOperators.Field
|
| 7 |
+
import Mathlib.Algebra.Order.Archimedean.Real.Basic
|
| 8 |
+
import Mathlib.Algebra.Order.Floor.Semiring
|
| 9 |
+
|
| 10 |
+
namespace OAI
|
| 11 |
+
|
| 12 |
+
/-!
|
| 13 |
+
# Replication of finite weights
|
| 14 |
+
|
| 15 |
+
Ceilings produce integer cluster sizes while giving one copy to every key of zero
|
| 16 |
+
weight. The resulting counting law satisfies the multiplicative and auxiliary-mass
|
| 17 |
+
estimates from Section 7 of OpenAI's *Constant-factor hardness of uniform sparsest cut*.
|
| 18 |
+
-/
|
| 19 |
+
|
| 20 |
+
open scoped BigOperators
|
| 21 |
+
|
| 22 |
+
namespace UniformSparsestCut.FiniteWeights
|
| 23 |
+
|
| 24 |
+
variable {ι : Type*} [Fintype ι]
|
| 25 |
+
|
| 26 |
+
noncomputable def copies (K : ℕ) (p : ℝ) : ℕ := if 0 < p then ⌈(K : ℝ) * p⌉₊ else 1
|
| 27 |
+
|
| 28 |
+
noncomputable def population (K : ℕ) (p : ι → ℝ) : ℕ := ∑ i, copies K (p i)
|
| 29 |
+
|
| 30 |
+
noncomputable def countingWeights (K : ℕ) (p : ι → ℝ) : ι → ℝ :=
|
| 31 |
+
fun i => (copies K (p i) : ℝ) / population K p
|
| 32 |
+
|
| 33 |
+
omit [Fintype ι] in
|
| 34 |
+
theorem copies_zero (K : ℕ) : copies K 0 = 1 := by simp [copies]
|
| 35 |
+
|
| 36 |
+
omit [Fintype ι] in
|
| 37 |
+
theorem copies_pos (K : ℕ) (hK : 0 < K) (p : ℝ) : 0 < copies K p := by
|
| 38 |
+
by_cases hp : 0 < p
|
| 39 |
+
· simpa [copies, hp] using Nat.ceil_pos.mpr (mul_pos (Nat.cast_pos.mpr hK) hp)
|
| 40 |
+
· simp [copies, hp]
|
| 41 |
+
|
| 42 |
+
omit [Fintype ι] in
|
| 43 |
+
theorem copies_lower (K : ℕ) {p : ℝ} (hp : 0 ≤ p) : (K : ℝ) * p ≤ copies K p := by
|
| 44 |
+
by_cases hpos : 0 < p
|
| 45 |
+
· simpa [copies, hpos] using Nat.le_ceil ((K : ℝ) * p)
|
| 46 |
+
· have heq : p = 0 := le_antisymm (le_of_not_gt hpos) hp
|
| 47 |
+
simp [heq, copies_zero]
|
| 48 |
+
|
| 49 |
+
omit [Fintype ι] in
|
| 50 |
+
theorem copies_upper (K : ℕ) {p : ℝ} (hp : 0 ≤ p) : (copies K p : ℝ) ≤ (K : ℝ) * p + 1 := by
|
| 51 |
+
by_cases hpos : 0 < p
|
| 52 |
+
· simpa [copies, hpos] using (Nat.ceil_lt_add_one (mul_nonneg (Nat.cast_nonneg K) hp)).le
|
| 53 |
+
· have heq : p = 0 := le_antisymm (le_of_not_gt hpos) hp
|
| 54 |
+
simp [heq, copies_zero]
|
| 55 |
+
|
| 56 |
+
theorem population_eq_total (K : ℕ) (p : ι → ℝ) :
|
| 57 |
+
(population K p : ℝ) = total (fun i => (copies K (p i) : ℝ)) := by
|
| 58 |
+
simp [population, total]
|
| 59 |
+
|
| 60 |
+
theorem population_bounds (K : ℕ) {p : ι → ℝ} (hp : ∀ i, 0 ≤ p i) (hp₁ : total p = 1) :
|
| 61 |
+
(K : ℝ) ≤ population K p ∧ (population K p : ℝ) ≤ K + Fintype.card ι := by
|
| 62 |
+
constructor
|
| 63 |
+
· calc
|
| 64 |
+
(K : ℝ) = total (fun i => (K : ℝ) * p i) := by rw [total_smul, hp₁, mul_one]
|
| 65 |
+
_ ≤ total (fun i => (copies K (p i) : ℝ)) := total_mono (fun i => copies_lower K (hp i))
|
| 66 |
+
_ = _ := (population_eq_total K p).symm
|
| 67 |
+
· calc
|
| 68 |
+
(population K p : ℝ) = total (fun i => (copies K (p i) : ℝ)) := population_eq_total K p
|
| 69 |
+
_ ≤ total (fun i => (K : ℝ) * p i + 1) := total_mono (fun i => copies_upper K (hp i))
|
| 70 |
+
_ = _ := by rw [total_add, total_smul, hp₁, mul_one]; simp [total]
|
| 71 |
+
|
| 72 |
+
theorem population_pos (K : ℕ) (hK : 0 < K) {p : ι → ℝ}
|
| 73 |
+
(hp : ∀ i, 0 ≤ p i) (hp₁ : total p = 1) : (0 : ℝ) < population K p :=
|
| 74 |
+
lt_of_lt_of_le (Nat.cast_pos.mpr hK) (population_bounds K hp hp₁).1
|
| 75 |
+
|
| 76 |
+
theorem counting_nonneg (K : ℕ) (p : ι → ℝ) : ∀ i, 0 ≤ countingWeights K p i := by
|
| 77 |
+
intro i
|
| 78 |
+
exact div_nonneg (Nat.cast_nonneg _) (Nat.cast_nonneg _)
|
| 79 |
+
|
| 80 |
+
theorem counting_total (K : ℕ) (hK : 0 < K) {p : ι → ℝ}
|
| 81 |
+
(hp : ∀ i, 0 ≤ p i) (hp₁ : total p = 1) : total (countingWeights K p) = 1 := by
|
| 82 |
+
change (∑ i, (copies K (p i) : ℝ) / population K p) = 1
|
| 83 |
+
rw [← Finset.sum_div]
|
| 84 |
+
change total (fun i => (copies K (p i) : ℝ)) / population K p = 1
|
| 85 |
+
rw [← population_eq_total]
|
| 86 |
+
exact div_self (ne_of_gt (population_pos K hK hp hp₁))
|
| 87 |
+
|
| 88 |
+
/-- On a key of positive weight, the counting law lies within a factor of two
|
| 89 |
+
of the original probability law. -/
|
| 90 |
+
theorem counting_bounds (K : ℕ) (hK : 0 < K) {p : ι → ℝ}
|
| 91 |
+
(hp : ∀ i, 0 ≤ p i) (hp₁ : total p = 1) (hKm : Fintype.card ι ≤ K)
|
| 92 |
+
(hKp : ∀ i, 0 < p i → 1 ≤ (K : ℝ) * p i) (i : ι) (hpi : 0 < p i) :
|
| 93 |
+
p i / 2 ≤ countingWeights K p i ∧ countingWeights K p i ≤ 2 * p i := by
|
| 94 |
+
have hN₀ := population_pos K hK hp hp₁
|
| 95 |
+
have hN := population_bounds K hp hp₁
|
| 96 |
+
have hKm' : (Fintype.card ι : ℝ) ≤ K := by exact_mod_cast hKm
|
| 97 |
+
have hN₂ : (population K p : ℝ) ≤ 2 * K := by linarith only [hN.2, hKm']
|
| 98 |
+
have hlow := copies_lower K (hp i)
|
| 99 |
+
have hupp := copies_upper K (hp i)
|
| 100 |
+
have hmin := hKp i hpi
|
| 101 |
+
constructor
|
| 102 |
+
· apply (le_div_iff₀ hN₀).mpr
|
| 103 |
+
have hn := mul_le_mul_of_nonneg_right hN₂ (hp i)
|
| 104 |
+
nlinarith only [hn, hlow]
|
| 105 |
+
· apply (div_le_iff₀ hN₀).mpr
|
| 106 |
+
have hn := mul_le_mul_of_nonneg_right hN.1 (hp i)
|
| 107 |
+
nlinarith only [hn, hmin, hupp]
|
| 108 |
+
|
| 109 |
+
/-- The total counting mass of auxiliary (zero-retained-demand) vertices. -/
|
| 110 |
+
theorem auxiliary_counting_bound (K : ℕ) (hK : 0 < K) {p : ι → ℝ} {κ : ℝ}
|
| 111 |
+
(hp : ∀ i, 0 ≤ p i) (hp₁ : total p = 1) (hκ : 0 < κ)
|
| 112 |
+
(hKlarge : 4 * κ * Fintype.card ι ≤ K) :
|
| 113 |
+
total (auxiliaryWeights (countingWeights K p) p) ≤ 1 / (4 * κ) := by
|
| 114 |
+
classical
|
| 115 |
+
have hN₀ := population_pos K hK hp hp₁
|
| 116 |
+
have hN := (population_bounds K hp hp₁).1
|
| 117 |
+
have ha : ∀ i, auxiliaryWeights (countingWeights K p) p i ≤ 1 / population K p := by
|
| 118 |
+
intro i
|
| 119 |
+
by_cases hi : p i = 0
|
| 120 |
+
· simp [auxiliaryWeights, hi, countingWeights, copies_zero]
|
| 121 |
+
· simp [auxiliaryWeights, hi, le_of_lt hN₀]
|
| 122 |
+
have hasum : total (auxiliaryWeights (countingWeights K p) p) ≤
|
| 123 |
+
(Fintype.card ι : ℝ) / population K p := by
|
| 124 |
+
simpa [total, div_eq_mul_inv] using total_mono ha
|
| 125 |
+
have hpop : 4 * κ * Fintype.card ι ≤ (population K p : ℝ) := hKlarge.trans hN
|
| 126 |
+
have hbound : (Fintype.card ι : ℝ) / population K p ≤ 1 / (4 * κ) := by
|
| 127 |
+
apply (div_le_div_iff₀ hN₀ (mul_pos (by norm_num : (0 : ℝ) < 4) hκ)).mpr
|
| 128 |
+
nlinarith only [hpop]
|
| 129 |
+
exact hasum.trans hbound
|
| 130 |
+
|
| 131 |
+
end UniformSparsestCut.FiniteWeights
|
| 132 |
+
|
| 133 |
+
end OAI
|