diff --git a/lean/OAI/Combinatorics/SparsestCut/CubeGeometry.lean b/lean/OAI/Combinatorics/SparsestCut/CubeGeometry.lean new file mode 100644 index 0000000000000000000000000000000000000000..d63e57df60876a4d01b77d697640260de98d2366 --- /dev/null +++ b/lean/OAI/Combinatorics/SparsestCut/CubeGeometry.lean @@ -0,0 +1,165 @@ +import OAI.Combinatorics.SparsestCut.CubePoincare + +namespace OAI + +open scoped BigOperators Topology NNReal RealInnerProductSpace InnerProductSpace Matrix ContDiff ENNReal +open MeasureTheory ProbabilityTheory Set Filter Matrix + +noncomputable section + +namespace UniformSparsestCut.CubeGeometry +open MeasureTheory ProbabilityTheory Set Filter +open scoped BigOperators ENNReal +noncomputable section +variable {m : ℕ} +local notation "E" => EuclideanSpace ℝ (Fin m) +local notation "μ" => CubePoincare.cube (m := m) + +lemma pi_uniform : Measure.pi (fun _ : Fin m => GaussianCDF.uniform)= + (2:ℝ≥0∞)⁻¹^m • (volume : Measure (Fin m → ℝ)).restrict + (univ.pi (fun _ => Ioo (-1:ℝ) 1)) := by + apply Measure.pi_eq + intro s hs + change (2:ℝ≥0∞)⁻¹^m * ((Measure.pi (fun _ : Fin m => (volume : Measure ℝ))).restrict (univ.pi (fun _ => Ioo (-1:ℝ) 1))) (univ.pi s)=_ + rw [Measure.restrict_pi_pi,Measure.pi_pi] + simp only [GaussianCDF.uniform,Measure.smul_apply,smul_eq_mul,Finset.prod_mul_distrib, + Finset.prod_const,Finset.card_univ,Fintype.card_fin] + +lemma cube_ac : μ ≪ (volume : Measure E) := by + have h : Measure.pi (fun _ : Fin m => GaussianCDF.uniform) ≪ (volume : Measure (Fin m → ℝ)) := by + rw [pi_uniform] + exact (Measure.restrict_le_self.absolutelyContinuous).smul_left _ + have hh := h.map (show Measurable (WithLp.toLp 2 : (Fin m → ℝ) → E) by fun_prop) + rw [(PiLp.volume_preserving_toLp (Fin m)).map_eq] at hh + exact hh + +lemma uniform_mem : ∀ᵐ t ∂GaussianCDF.uniform, t∈Ioo (-1:ℝ) 1 := by + have h : GaussianCDF.uniform ≪ volume.restrict (Ioo (-1:ℝ) 1) := + (Measure.AbsolutelyContinuous.refl _).smul_left _ + exact h.ae_le (ae_restrict_mem measurableSet_Ioo) + +lemma cube_mem : ∀ᵐ x ∂μ, ∀ j, |x j|<1 := by + apply (ae_map_iff (by fun_prop) (by measurability)).mpr + apply ae_all_iff.mpr + intro j + have h := (measurePreserving_eval (fun _ : Fin m => GaussianCDF.uniform) j).quasiMeasurePreserving.ae uniform_mem + filter_upwards [h] with x hx + exact abs_lt.mpr hx + +lemma uniform_pow (k : ℕ) : (∫ t, t^k ∂GaussianCDF.uniform)= + (1-(-1:ℝ)^(k+1))/(2*(k+1)) := by + rw [GaussianCDF.uniform,integral_smul_measure,restrict_Ioo_eq_restrict_Ioc, + ← intervalIntegral.integral_of_le (by norm_num : (-1:ℝ)≤1),integral_pow] + simp only [ENNReal.toReal_inv,ENNReal.toReal_ofNat,smul_eq_mul,one_pow] + field_simp + +lemma uniform_pow_integrable (k : ℕ) : Integrable (fun t : ℝ => t^k) GaussianCDF.uniform := by + apply (integrable_const (1:ℝ)).mono' (by fun_prop) + filter_upwards [uniform_mem] with t ht + rw [Real.norm_eq_abs,abs_pow] + exact (pow_le_pow_left₀ (abs_nonneg t) (abs_lt.mpr ht).le k).trans_eq (one_pow k) + +lemma coordinate_preserving (j : Fin m) : MeasurePreserving (fun x : E => x j) μ GaussianCDF.uniform := by + refine ⟨by fun_prop,?_⟩ + rw [CubePoincare.cube,Measure.map_map (by fun_prop) (by fun_prop)] + exact (measurePreserving_eval (fun _ : Fin m => GaussianCDF.uniform) j).map_eq + +lemma coordinate_pow (j : Fin m) (k : ℕ) : (∫ x : E, (x j)^k ∂μ)= + (1-(-1:ℝ)^(k+1))/(2*(k+1)) := by + rw [← uniform_pow k,← (coordinate_preserving j).map_eq] + exact (integral_map (by fun_prop) (continuous_id.pow k).aestronglyMeasurable).symm + +lemma coordinate_pow_integrable (j : Fin m) (k : ℕ) : Integrable (fun x : E => (x j)^k) μ := + ((coordinate_preserving j).integrable_comp (continuous_id.pow k).aestronglyMeasurable).mpr (uniform_pow_integrable k) + +lemma cube_norm : ∀ᵐ x : E ∂μ, ‖x‖≤Real.sqrt m := by + filter_upwards [cube_mem] with x hx + have h : ‖x‖^2≤(m:ℝ) := by + rw [EuclideanSpace.norm_sq_eq] + calc + _ ≤ ∑ _j : Fin m, (1:ℝ) := by + apply Finset.sum_le_sum; intro j _ + rw [Real.norm_eq_abs,sq_abs] + nlinarith [abs_lt.mp (hx j)] + _ = _ := by simp + nlinarith [Real.sq_sqrt (Nat.cast_nonneg (α := ℝ) m),norm_nonneg x,Real.sqrt_nonneg (m:ℝ)] + +lemma bounded_integrable {f : E → ℝ} (hf : AEStronglyMeasurable f μ) {B : ℝ} + (hb : ∀ᵐ x ∂μ, |f x|≤B) : Integrable f μ := + (integrable_const B).mono' hf (by simpa only [Real.norm_eq_abs] using hb) + +lemma pair_norm_bound : ∀ᵐ z : E × E ∂(μ).prod μ, ‖z.1-z.2‖≤2*Real.sqrt m := by + have hp : ∀ᵐ z : E × E ∂(μ).prod μ, ‖z.1‖≤Real.sqrt m ∧ ‖z.2‖≤Real.sqrt m := by + apply (Measure.ae_prod_iff_ae_ae (by measurability)).mpr + filter_upwards [cube_norm (m := m)] with x hx + filter_upwards [cube_norm (m := m)] with y hy + exact ⟨hx,hy⟩ + filter_upwards [hp] with z hz + exact (norm_sub_le _ _).trans (by linarith [hz.1,hz.2]) + +lemma pair_norm_integrable : Integrable (fun z : E × E => ‖z.1-z.2‖) ((μ).prod μ) := by + apply (integrable_const (2*Real.sqrt m)).mono' (by fun_prop) + simpa only [Real.norm_eq_abs,abs_norm] using pair_norm_bound (m := m) + +lemma coordinate_difference_sq (j : Fin m) : + (∫ z : E × E, (z.1 j-z.2 j)^2 ∂(μ).prod μ)=2/3 := by + have h1 : Integrable (fun x : E => x j) μ := by simpa using coordinate_pow_integrable j 1 + have h2 := coordinate_pow_integrable j 2 + have he : (fun z : E × E => (z.1 j-z.2 j)^2) = + (fun z => (z.1 j)^2+(z.2 j)^2-2*(z.1 j*z.2 j)) := by funext z; ring + rw [he] + have hsub := integral_sub ((h2.comp_fst μ).add (h2.comp_snd μ)) ((h1.mul_prod h1).const_mul 2) + simp only [Pi.add_apply] at hsub + rw [hsub] + have hadd := integral_add (h2.comp_fst μ) (h2.comp_snd μ) + rw [hadd,integral_const_mul,integral_prod_mul (fun x : E => x j) (fun x : E => x j)] + have he0 : (∫ x : E, x j ∂μ)=0 := by simpa using coordinate_pow j 1 + have he2 : (∫ x : E, (x j)^2 ∂μ)=1/3 := by + have hh := coordinate_pow j 2 + norm_num at hh ⊢ + exact hh + rw [integral_fun_fst (fun x : E => (x j)^2),integral_fun_snd (fun x : E => (x j)^2)] + simp [he0,he2] + norm_num + +lemma coordinate_difference_sq_integrable (j : Fin m) : + Integrable (fun z : E × E => (z.1 j-z.2 j)^2) ((μ).prod μ) := by + have h1 : Integrable (fun x : E => x j) μ := by simpa using coordinate_pow_integrable j 1 + have h2 := coordinate_pow_integrable j 2 + convert ((h2.comp_fst μ).add (h2.comp_snd μ)).sub ((h1.mul_prod h1).const_mul 2) using 1 + ext z + simp only [Pi.add_apply,Pi.sub_apply] + ring + +lemma pair_norm_sq_integral : (∫ z : E × E, ‖z.1-z.2‖^2 ∂(μ).prod μ)=2*(m:ℝ)/3 := by + have hnorm (z : E × E) : ‖z.1-z.2‖^2=∑ j, (z.1 j-z.2 j)^2 := by + rw [EuclideanSpace.norm_sq_eq] + congr 1 + funext j + simp only [PiLp.sub_apply,Real.norm_eq_abs,sq_abs] + simp_rw [hnorm] + rw [integral_finsetSum _ (fun j _ => coordinate_difference_sq_integrable j)] + simp only [coordinate_difference_sq,Finset.sum_const,Finset.card_univ,Fintype.card_fin,nsmul_eq_mul] + ring + +lemma pair_norm_average (hm : 0 < m) : + Real.sqrt m/3≤∫ z : E × E, ‖z.1-z.2‖ ∂(μ).prod μ := by + have hsq : Integrable (fun z : E × E => ‖z.1-z.2‖^2) ((μ).prod μ) := by + apply (integrable_const ((2*Real.sqrt m)^2)).mono' (by fun_prop) + filter_upwards [pair_norm_bound (m := m)] with z hz + rw [Real.norm_eq_abs,abs_of_nonneg (sq_nonneg _)] + exact pow_le_pow_left₀ (norm_nonneg _) hz 2 + have hh := integral_mono_ae hsq (pair_norm_integrable.const_mul (2*Real.sqrt m)) (by + filter_upwards [pair_norm_bound (m := m)] with z hz + exact (show ‖z.1-z.2‖^2≤2*Real.sqrt m*‖z.1-z.2‖ by nlinarith [norm_nonneg (z.1-z.2)])) + rw [pair_norm_sq_integral,integral_const_mul] at hh + have hp : 0 EuclideanSpace ℝ (Fin m) + +def Ψ (x : E) : E := WithLp.toLp 2 (fun i => GaussianCDF.ψ (x i)) +def cube : Measure E := (Measure.pi (fun _ : Fin m => GaussianCDF.uniform)).map (WithLp.toLp 2) + +instance cube_probability : IsProbabilityMeasure (cube (m := m)) := by + unfold cube + infer_instance + +def coordinate (i : Fin m) : E →L[ℝ] ℝ := + (ContinuousLinearMap.proj i).comp (EuclideanSpace.equiv (Fin m) ℝ).toContinuousLinearMap + +@[simp] lemma coordinate_apply (i : Fin m) (x : E) : coordinate i x = x i := rfl + +def derivative (x : E) : E →L[ℝ] E := + (EuclideanSpace.equiv (Fin m) ℝ).symm.toContinuousLinearMap.comp + (ContinuousLinearMap.pi (fun i => (2*GaussianCDF.φ (x i)) • coordinate i)) + +@[simp] lemma derivative_apply (x v : E) (i : Fin m) : derivative x v i = 2*GaussianCDF.φ (x i)*v i := rfl + +lemma Ψ_hasFDeriv (x : E) : HasFDerivAt Ψ (derivative x) x := by + have hi (i : Fin m) := (GaussianCDF.ψ_hasDeriv (x i)).comp_hasFDerivAt x (coordinate i).hasFDerivAt + have hp := hasFDerivAt_pi.mpr hi + have h := (EuclideanSpace.equiv (Fin m) ℝ).symm.toContinuousLinearMap.hasFDerivAt.comp x hp + convert h using 1 <;> rfl + +lemma Ψ_contDiff : ContDiff ℝ 1 (Ψ (m := m)) := by + have h : ContDiff ℝ 1 (fun x : E => fun i => GaussianCDF.ψ (x i)) := + contDiff_pi.mpr (fun i => GaussianCDF.ψ_contDiff.comp (coordinate i).contDiff) + exact (EuclideanSpace.equiv (Fin m) ℝ).symm.toContinuousLinearMap.contDiff.comp h + +lemma Ψ_norm (x : E) : ‖Ψ x‖ ≤ Real.sqrt m := by + have h : ‖Ψ x‖^2 ≤ (m:ℝ) := by + rw [EuclideanSpace.norm_sq_eq] + calc + _ ≤ ∑ _i : Fin m, (1:ℝ) := by + apply Finset.sum_le_sum + intro i _ + have hi := GaussianCDF.ψ_mem (x i) + change ‖GaussianCDF.ψ (x i)‖^2 ≤ 1 + rw [Real.norm_eq_abs, sq_abs] + nlinarith [hi.1,hi.2] + _ = _ := by simp + nlinarith [Real.sq_sqrt (Nat.cast_nonneg (α := ℝ) m), Real.sqrt_nonneg (m:ℝ), norm_nonneg (Ψ x)] + +lemma derivative_norm (x : E) : ‖derivative x‖ ≤ 1 := by + apply (derivative x).opNorm_le_bound (by norm_num) + intro v + simp only [one_mul] + have h : ‖derivative x v‖^2 ≤ ‖v‖^2 := by + simp only [EuclideanSpace.norm_sq_eq] + apply Finset.sum_le_sum + intro i _ + change ‖2*GaussianCDF.φ (x i)*v i‖^2 ≤ ‖v i‖^2 + rw [norm_mul, mul_pow] + have hi := GaussianCDF.ψ_deriv_bound (x i) + have hh : ‖2*GaussianCDF.φ (x i)‖^2 ≤ 1 := by + rw [Real.norm_eq_abs] + nlinarith [abs_nonneg (2*GaussianCDF.φ (x i))] + nlinarith [sq_nonneg ‖v i‖] + nlinarith [norm_nonneg (derivative x v), norm_nonneg v] + +lemma Ψ_map : (stdGaussian E).map Ψ = cube := by + rw [← map_pi_eq_stdGaussian, Measure.map_map Ψ_contDiff.continuous.measurable (by fun_prop)] + have he : (Ψ (m := m)) ∘ WithLp.toLp 2 = WithLp.toLp 2 ∘ + (fun x : Fin m → ℝ => fun i => GaussianCDF.ψ (x i)) := rfl + have hmeas : Measurable (fun x : Fin m → ℝ => fun i => GaussianCDF.ψ (x i)) := + Measurable.of_eval (fun i => GaussianCDF.ψ_contDiff.continuous.measurable.comp (measurable_pi_apply i)) + rw [he, ← Measure.map_map (by fun_prop) hmeas, Measure.pi_map_pi] + · simp_rw [GaussianCDF.ψ_map] + rfl + · intro i + exact GaussianCDF.ψ_contDiff.continuous.measurable.aemeasurable + +lemma cube_first_moment (h : E → ℝ) (hh : ContDiff ℝ 1 h) : + (∫ z : E × E, |h z.1-h z.2| ∂((cube (m := m)).prod cube)) ≤ + (Real.pi/2)*(∫ x : E, ‖fderiv ℝ h x‖ ∂cube) := by + let μ := stdGaussian E + let H : E → ℝ := h ∘ Ψ + have hH : ContDiff ℝ 1 H := hh.comp Ψ_contDiff + have hcompact := isCompact_closedBall (0:E) (Real.sqrt m) + obtain ⟨B,hB⟩ := hcompact.exists_bound_of_continuousOn hh.continuous.continuousOn + obtain ⟨M,hM⟩ := hcompact.exists_bound_of_continuousOn (hh.continuous_fderiv (by norm_num)).continuousOn + have hmem (x : E) : Ψ x ∈ Metric.closedBall 0 (Real.sqrt m) := by simpa using Ψ_norm x + have hB' (x : E) : ‖H x‖ ≤ max B 0 := (hB _ (hmem x)).trans (le_max_left _ _) + have hcomp (x : E) : fderiv ℝ H x = (fderiv ℝ h (Ψ x)).comp (derivative x) := + ((hh.differentiable (by norm_num) (Ψ x)).hasFDerivAt.comp x (Ψ_hasFDeriv x)).fderiv + have hnorm (x : E) : ‖fderiv ℝ H x‖ ≤ ‖fderiv ℝ h (Ψ x)‖ := by + rw [hcomp] + exact ContinuousLinearMap.opNorm_comp_le _ _ |>.trans + ((mul_le_mul_of_nonneg_left (derivative_norm x) (norm_nonneg _)).trans_eq (mul_one _)) + have hdB (x : E) : ‖fderiv ℝ H x‖ ≤ max M 0 := + (hnorm x).trans ((hM _ (hmem x)).trans (le_max_left _ _)) + have hint : Integrable (fun x : E => ‖fderiv ℝ h (Ψ x)‖) μ := by + apply (integrable_const (max M 0)).mono' ((hh.continuous_fderiv (by norm_num)).comp Ψ_contDiff.continuous |>.norm.aestronglyMeasurable) + filter_upwards with x + simpa only [norm_norm, Function.comp_apply] using (hM _ (hmem x)).trans (le_max_left _ _) + have hintH : Integrable (fun x : E => ‖fderiv ℝ H x‖) μ := by + apply hint.mono' (by have hc := hH.continuous_fderiv (by norm_num); fun_prop) + filter_upwards with x + simpa only [norm_norm] using hnorm x + have hp := GaussianPoincare.rotation_first_moment H hH (le_max_right M 0) hdB hB' + have hmeasure : MeasurePreserving Ψ μ cube := ⟨Ψ_contDiff.continuous.measurable, Ψ_map⟩ + have hprod := hmeasure.prod hmeasure + have heL : (∫ z : E × E, |H z.1-H z.2| ∂μ.prod μ) = + ∫ z : E × E, |h z.1-h z.2| ∂((cube (m := m)).prod cube) := by + rw [← hprod.map_eq] + exact (integral_map (f := fun z : E × E => |h z.1-h z.2|) hprod.measurable.aemeasurable (by fun_prop)).symm + have heR : (∫ x : E, ‖fderiv ℝ h (Ψ x)‖ ∂μ) = ∫ x : E, ‖fderiv ℝ h x‖ ∂cube := by + rw [← hmeasure.map_eq] + exact (integral_map (f := fun x : E => ‖fderiv ℝ h x‖) hmeasure.measurable.aemeasurable + (by have hc := hh.continuous_fderiv (by norm_num); fun_prop)).symm + rw [← heL, ← heR] + exact hp.trans (mul_le_mul_of_nonneg_left (integral_mono hintH hint hnorm) (by positivity)) + +end UniformSparsestCut.CubePoincare + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SparsestCut/CubeTransfer.lean b/lean/OAI/Combinatorics/SparsestCut/CubeTransfer.lean new file mode 100644 index 0000000000000000000000000000000000000000..9f6d8c12bad4d6692a5a6c35ec6ad2aba41a4b58 --- /dev/null +++ b/lean/OAI/Combinatorics/SparsestCut/CubeTransfer.lean @@ -0,0 +1,145 @@ +import OAI.Combinatorics.SparsestCut.CubeGeometry + +namespace OAI + +universe u1 u2 + +open scoped BigOperators Topology NNReal RealInnerProductSpace InnerProductSpace Matrix ContDiff ENNReal +open MeasureTheory ProbabilityTheory Set Filter Matrix + +noncomputable section + +namespace UniformSparsestCut.CubeTransfer +open MeasureTheory Set Filter +open scoped BigOperators +noncomputable section +variable {m : ℕ} {A : Type u1} [Fintype A] +local notation "E" => EuclideanSpace ℝ (Fin m) +local notation "μ" => CubePoincare.cube (m := m) +lemma continuous_integrable (f : E → ℝ) (hf : Continuous f) : Integrable f μ := by + obtain ⟨B,hB⟩ := (isCompact_closedBall (0:E) (Real.sqrt m)).exists_bound_of_continuousOn hf.continuousOn + apply CubeGeometry.bounded_integrable hf.aestronglyMeasurable + filter_upwards [CubeGeometry.cube_norm (m := m)] with x hx + simpa only [Real.norm_eq_abs] using hB x (by simpa using hx) +lemma pair_continuous_integrable (f : E × E → ℝ) (hf : Continuous f) : Integrable f ((μ).prod μ) := by + let K : Set E := Metric.closedBall 0 (Real.sqrt m) + have hK : IsCompact K := isCompact_closedBall _ _ + obtain ⟨B,hB⟩ := (hK.prod hK).exists_bound_of_continuousOn hf.continuousOn + have hm : ∀ᵐ x : E ∂μ, x∈K := by simpa only [K,Metric.mem_closedBall,dist_zero_right] using CubeGeometry.cube_norm (m := m) + have hp : ∀ᵐ z : E × E ∂(μ).prod μ, z∈K ×ˢ K := by + apply (Measure.ae_prod_iff_ae_ae (hK.measurableSet.prod hK.measurableSet)).mpr + filter_upwards [hm] with x hx + filter_upwards [hm] with y hy + exact ⟨hx,hy⟩ + apply (integrable_const B).mono' hf.aestronglyMeasurable + filter_upwards [hp] with z hz + exact hB z hz + +lemma average_from_gradient (f H : A → E → ℝ) {M B K : ℝ} + (hf : ∀ a, Measurable (f a)) (hM : ∀ a x, |f a x|≤M) + (hH : ∀ a, ContDiff ℝ 1 (H a)) + (he : ∀ᵐ x : E ∂μ, ∑ a, |H a x-f a x|≤B) + (hg : ∀ᵐ x : E ∂μ, ∑ a, ‖fderiv ℝ (H a) x‖≤K) : + (∫ z : E × E, ∑ a, |f a z.1-f a z.2| ∂(μ).prod μ)≤2*B+(Real.pi/2)*K := by + classical + have hfi (a : A) : Integrable (f a) μ := + CubeGeometry.bounded_integrable (hf a).aestronglyMeasurable (Eventually.of_forall (hM a)) + have hfdi (a : A) : Integrable (fun z : E × E => |f a z.1-f a z.2|) ((μ).prod μ) := + ((hfi a).comp_fst μ |>.sub ((hfi a).comp_snd μ)).abs + have hHd (a : A) : Integrable (fun z : E × E => |H a z.1-H a z.2|) ((μ).prod μ) := + pair_continuous_integrable _ (by have hh := (hH a).continuous; fun_prop) + have hDi (a : A) : Integrable (fun x : E => ‖fderiv ℝ (H a) x‖) μ := + continuous_integrable _ (by exact ((hH a).continuous_fderiv (by norm_num)).norm) + have hgb : (∫ z : E × E, ∑ a, |H a z.1-H a z.2| ∂(μ).prod μ)≤(Real.pi/2)*K := by + rw [integral_finsetSum _ (fun a _ => hHd a)] + calc + _ ≤ ∑ a, (Real.pi/2)*(∫ x : E, ‖fderiv ℝ (H a) x‖ ∂μ) := + Finset.sum_le_sum (fun a _ => CubePoincare.cube_first_moment (H a) (hH a)) + _ = (Real.pi/2)*(∫ x : E, ∑ a, ‖fderiv ℝ (H a) x‖ ∂μ) := by + rw [integral_finsetSum _ (fun a _ => hDi a),Finset.mul_sum] + _ ≤ (Real.pi/2)*K := by + apply mul_le_mul_of_nonneg_left _ (by positivity) + calc + _ ≤ ∫ _x : E, K ∂μ := integral_mono_ae (integrable_finsetSum _ (fun a _ => hDi a)) (integrable_const K) hg + _ = _ := by simp + have hep : ∀ᵐ z : E × E ∂(μ).prod μ, + (∑ a, |H a z.1-f a z.1|≤B) ∧ (∑ a, |H a z.2-f a z.2|≤B) := by + have hem : Measurable (fun x : E => ∑ a, |H a x-f a x|) := + Finset.measurable_sum _ (fun a _ => ((hH a).continuous.measurable.sub (hf a)).abs) + apply (Measure.ae_prod_iff_ae_ae + ((measurableSet_le (hem.comp measurable_fst) measurable_const).inter + (measurableSet_le (hem.comp measurable_snd) measurable_const))).mpr + filter_upwards [he] with x hx + filter_upwards [he] with y hy + exact ⟨hx,hy⟩ + 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 + filter_upwards [hep] with z hz + 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 + calc + _ = |-(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 + _ ≤ _ := 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)) + have hh := Finset.sum_le_sum (fun a (_ : a∈(Finset.univ : Finset A)) => hle a) + simp only [Finset.sum_add_distrib] at hh + linarith [hz.1,hz.2] + have hfinal := integral_mono_ae (integrable_finsetSum _ (fun a _ => hfdi a)) + ((integrable_const (2*B)).add (integrable_finsetSum _ (fun a _ => hHd a))) hpoint + simp only [Pi.add_apply] at hfinal + have hadd := integral_add (show Integrable (fun _ : E × E => 2*B) ((μ).prod μ) from integrable_const _) + (integrable_finsetSum Finset.univ (fun a _ => hHd a)) + rw [hadd] at hfinal + simpa using hfinal.trans (add_le_add le_rfl hgb) +end +end UniformSparsestCut.CubeTransfer + +namespace UniformSparsestCut.ContractionAverage +open MeasureTheory Set Filter +open scoped BigOperators RealInnerProductSpace +noncomputable section +variable {m N S : ℕ} {A : Type u2} [Fintype A] +local notation "E" => EuclideanSpace ℝ (Fin (m+1)) +local notation "μ" => CubePoincare.cube (m := m+1) +open ContractionCore + +lemma average (u : Fin S → Fin N → E) (hu : ∀ s i, u s i 0≠0) + (hnp : ∀ s i j, i≠j → ∀ t : ℝ, u s i≠t • u s j) (hn : ∀ s i, ‖u s i‖≤2) + {τ lam δ R J G : ℝ} (hτ : 0<τ) (hlam : 0 ConvolutionBounds.smooth (KernelGeometry.κ lam) (f a) volume + have hc (a : A) : ContDiff ℝ 1 (H a) := by + exact (KernelGeometry.compact hlam).contDiff_convolution_left (ContinuousLinearMap.mul ℝ ℝ) + ((KernelGeometry.smooth lam).of_le (by simp)) (ConcreteCells.function_integrable u hu τ F hM hbound s0 a) + have he : ∀ᵐ x : E ∂μ, (∑ a, |H a x-f a x|)≤G*(lam*Real.sqrt (m+1:ℕ))+R := by + have hr := CubeGeometry.cube_ac.ae_le (RoundedCharts.ae_regular (u s0) τ (by + intro i h; exact hu s0 i (by rw [h]; rfl))) + filter_upwards [CubeGeometry.cube_mem (m := m+1),hr] with x hx hrx + exact smoothing_error u hu hτ hlam hlam1 hn hG F hM hbound hmacro s0 x (fun j => (hx j).le) hrx + have hg : ∀ᵐ x : E ∂μ, (∑ a, ‖fderiv ℝ (H a) x‖)≤ + 2*(δ*((N:ℝ)*(2*J/τ))+(m+1:ℕ)*R*KernelGeometry.L lam) := by + filter_upwards [CubeGeometry.cube_mem (m := m+1)] with x hx + 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) + have h := CubeTransfer.average_from_gradient f H (fun a => ConcreteCells.function_measurable u hu τ F s0 a) + (fun a x => ConcreteCells.function_bounded u hu τ F hM hbound s0 a x) hc he hg + convert h using 1 ; ring +end +end UniformSparsestCut.ContractionAverage + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SparsestCut/CutDuality.lean b/lean/OAI/Combinatorics/SparsestCut/CutDuality.lean new file mode 100644 index 0000000000000000000000000000000000000000..915c0cc1ec808ebe46d7442f42fecfc6579d5fde --- /dev/null +++ b/lean/OAI/Combinatorics/SparsestCut/CutDuality.lean @@ -0,0 +1,134 @@ +import OAI.Combinatorics.SparsestCut.Semimetrics +import OAI.Combinatorics.SparsestCut.FiniteDuality + +namespace OAI + +universe u1 + +open scoped BigOperators Topology NNReal RealInnerProductSpace InnerProductSpace Matrix ContDiff ENNReal +open MeasureTheory ProbabilityTheory Set Filter Matrix + +noncomputable section + +namespace UniformSparsestCut + +section CutConeDuality +variable {n : ℕ} + +lemma pairSum_sum {K : Type u1} [Fintype K] (f : K → Fin n → Fin n → ℝ) : + pairSum (fun i j => ∑ k, f k i j) = ∑ k, pairSum (f k) := by + classical + unfold pairSum + have hh (i j : Fin n) : (if i < j then ∑ k, f k i j else 0) = + ∑ k, if i < j then f k i j else 0 := by + split_ifs <;> simp_all + simp_rw [hh] + conv_lhs => arg 2; intro i; rw [Finset.sum_comm] + rw [Finset.sum_comm] + +noncomputable def symmetrizeCapacity (c : (Fin n × Fin n) → ℝ) + (hc : ∀ e, 0 ≤ c e) : Capacity n where + cap i j := if i = j then 0 else c (i,j) + c (j,i) + nonneg i j := by split_ifs; exact le_rfl; exact add_nonneg (hc _) (hc _) + symm i j := by by_cases h : i = j <;> simp [h, eq_comm, add_comm] + diagonal i := by simp + +lemma symmetrize_objective (c : (Fin n × Fin n) → ℝ) (hc : ∀ e, 0 ≤ c e) + (d : Fin n → Fin n → ℝ) (hs : ∀ i j, d i j = d j i) (hd : ∀ i, d i i = 0) : + pairSum (fun i j => (symmetrizeCapacity c hc).cap i j * d i j) = + ∑ e, c e * d e.1 e.2 := by + have hfun : (fun i j => (symmetrizeCapacity c hc).cap i j * d i j) = + (fun i j => c (i,j) * d i j + c (j,i) * d j i) := by + funext i j + by_cases h : i = j + · subst j; simp [hd] + · simp [symmetrizeCapacity, h, hs j i, add_mul] + rw [hfun, pairSum_add, pairSum_swap _ (fun i => by simp [hd])] + exact (Fintype.sum_prod_type (fun e : Fin n × Fin n => c e * d e.1 e.2)).symm + +theorem cut_cone_duality (hn : 2 ≤ n) (d : Fin n → Fin n → ℝ) + (hd : NegativeType d) {a b : ℝ} (ha : 0 < a) (hb : 0 < b) + (havg : (n : ℝ)^2 * a ≤ ∑ i, ∑ j, d i j) + (hcon : ∀ (K : Type) [Fintype K] (F : Fin n → K → ℝ), + (∀ i j, (∑ k, |F i k - F j k|) ≤ d i j) → + (∑ i, ∑ j, ∑ k, |F i k - F j k|) ≤ (n : ℝ)^2 * b) : + ∃ C : Capacity n, 1 ≤ OPT C ∧ 0 < glValue C ∧ glValue C ≤ b / a := by + classical + have hsemi := hd.semimetric + let A : (Fin n × Fin n) → Cut n → ℝ := fun e B => cutDist B.1 e.1 e.2 + let w : Cut n → ℝ := fun B => cutDemand B.1 + have hcol (B : Cut n) : 0 < ∑ e, A e B := by + change 0 < ∑ e : Fin n × Fin n, cutDist B.1 e.1 e.2 + rw [Fintype.sum_prod_type, orderedSum_eq_two_pairSum _ (cutDist_symm _) (cutDist_self _), pairSum_cut] + exact mul_pos (by norm_num) (cutDemand_pos B) + have hbound (t : Cut n → ℝ) (ht : ∀ B, 0 ≤ t B) + (htd : ∀ e, ∑ B, A e B * t B ≤ d e.1 e.2) : + (∑ B, w B * t B) ≤ (n : ℝ)^2 * b / 2 := by + let F : Fin n → Cut n → ℝ := fun i B => t B * cutIndicator B.1 i + have hFd (i j : Fin n) : (∑ B, |F i B - F j B|) = ∑ B, t B * cutDist B.1 i j := by + apply Finset.sum_congr rfl + intro B hB + simp [F, cutDist, ← mul_sub, abs_mul, abs_of_nonneg (ht B)] + have hcontract (i j : Fin n) : (∑ B, |F i B - F j B|) ≤ d i j := by + rw [hFd] + simpa only [A, mul_comm] using htd (i,j) + have htavg := hcon (Cut n) F hcontract + simp_rw [hFd] at htavg + have hsym (i j : Fin n) : (∑ B, t B * cutDist B.1 i j) = + ∑ B, t B * cutDist B.1 j i := by simp_rw [cutDist_symm _ i j] + rw [orderedSum_eq_two_pairSum _ hsym (fun i => by simp), pairSum_sum] at htavg + simp_rw [pairSum_smul, pairSum_cut] at htavg + have he : (∑ B, w B * t B) = ∑ B, t B * cutDemand B.1 := by + unfold w; simp_rw [mul_comm] + rw [he] + linarith + let W : ℝ := ∑ B : Cut n, w B + have hw0 (B : Cut n) : 0 ≤ w B := (cutDemand_pos B).le + obtain ⟨c,hc,hcover,hobj⟩ := FiniteDuality.packing_duality A w + (fun e B => cutDist_binary B.1 e.1 e.2) hcol + (fun e => d e.1 e.2) (fun e => hsemi.1 _ _) + (show 0 ≤ (n : ℝ)^2 * b / 2 by positivity) + (show 0 ≤ W from Finset.sum_nonneg (fun B hB => hw0 B)) + (fun B => Finset.single_le_sum (fun B hB => hw0 B) (Finset.mem_univ B)) hbound + let C := symmetrizeCapacity c hc + have hC (B : Cut n) : cutDemand B.1 ≤ ∑ i ∈ B.1, ∑ j ∈ B.1ᶜ, C.cap i j := by + rw [← cut_capacity_pair, symmetrize_objective c hc _ (cutDist_symm _) (cutDist_self _)] + simpa only [A, w, mul_comm] using hcover B + refine ⟨C, OPT_ge_one_of_cuts C hn hC, glValue_pos_of_cuts C hn hC, ?_⟩ + let D := pairSum d + have havg' : (n : ℝ)^2 * a ≤ 2 * D := by + simpa only [orderedSum_eq_two_pairSum d hsemi.2.1 hsemi.2.2.1] using havg + have hn0 : 0 < (n : ℝ) := by exact_mod_cast (show 0 < n by omega) + have hD : 0 < D := by nlinarith [mul_pos (sq_pos_of_pos hn0) ha] + let d' := fun i j => D⁻¹ * d i j + have hd' : Feasible d' := by + refine ⟨hd.scale (inv_nonneg.mpr hD.le), ?_⟩ + change pairSum (fun i j => D⁻¹ * d i j) = 1 + rw [pairSum_smul, inv_mul_cancel₀ hD.ne'] + have hbdd : BddBelow {r | ∃ d : Fin n → Fin n → ℝ, Feasible d ∧ + r = pairSum (fun i j => C.cap i j * d i j)} := by + refine ⟨0, ?_⟩ + rintro r ⟨d,hd,rfl⟩ + exact objective_nonneg C hd.1.semimetric + have hgl : glValue C ≤ pairSum (fun i j => C.cap i j * d' i j) := + csInf_le hbdd ⟨d',hd',rfl⟩ + apply hgl.trans + have hscale : pairSum (fun i j => C.cap i j * d' i j) = + (pairSum (fun i j => C.cap i j * d i j)) / D := by + simp only [d', div_eq_mul_inv] + rw [mul_comm _ D⁻¹, ← pairSum_smul D⁻¹] + congr 1 + funext i j; ring + rw [hscale, symmetrize_objective c hc d hsemi.2.1 hsemi.2.2.1, + div_le_div_iff₀ hD ha] + have hh1 := mul_le_mul_of_nonneg_right hobj ha.le + have hh2 := mul_le_mul_of_nonneg_right havg' hb.le + nlinarith + +end CutConeDuality + +end UniformSparsestCut + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SparsestCut/CutSums.lean b/lean/OAI/Combinatorics/SparsestCut/CutSums.lean new file mode 100644 index 0000000000000000000000000000000000000000..98fec49b6ea34a10c35e62d929b93be769b5ed74 --- /dev/null +++ b/lean/OAI/Combinatorics/SparsestCut/CutSums.lean @@ -0,0 +1,165 @@ +import OAI.Combinatorics.SparsestCut.FiniteDuality + +namespace OAI + +open scoped BigOperators Topology NNReal RealInnerProductSpace InnerProductSpace Matrix ContDiff ENNReal +open MeasureTheory ProbabilityTheory Set Filter Matrix + +noncomputable section + +namespace UniformSparsestCut + +section CutSums + +variable {n : ℕ} + +lemma pairSum_nonneg {f : Fin n → Fin n → ℝ} (hf : ∀ i j, 0 ≤ f i j) : + 0 ≤ pairSum f := by + apply Finset.sum_nonneg + intro i hi + apply Finset.sum_nonneg + intro j hj + split_ifs + · exact hf _ _ + · exact le_rfl + +lemma pairSum_add (f g : Fin n → Fin n → ℝ) : + pairSum (fun i j => f i j + g i j) = pairSum f + pairSum g := by + simp only [pairSum, ← Finset.sum_add_distrib] + apply Finset.sum_congr rfl + intro i hi + apply Finset.sum_congr rfl + intro j hj + split_ifs <;> ring + +lemma pairSum_smul (a : ℝ) (f : Fin n → Fin n → ℝ) : + pairSum (fun i j => a * f i j) = a * pairSum f := by + simp only [pairSum, Finset.mul_sum] + apply Finset.sum_congr rfl + intro i hi + apply Finset.sum_congr rfl + intro j hj + split_ifs <;> ring + +lemma pairSum_swap (f : Fin n → Fin n → ℝ) (hd : ∀ i, f i i = 0) : + pairSum f + pairSum (fun i j => f j i) = ∑ i, ∑ j, f i j := by + unfold pairSum + conv_lhs => rhs; rw [Finset.sum_comm] + rw [← Finset.sum_add_distrib] + apply Finset.sum_congr rfl + intro i hi + rw [← Finset.sum_add_distrib] + apply Finset.sum_congr rfl + intro j hj + rcases lt_trichotomy i j with h | h | h + · simp [h, not_lt.mpr h.le] + · subst j; simp [hd] + · simp [h, not_lt.mpr h.le] + +lemma orderedSum_eq_two_pairSum (f : Fin n → Fin n → ℝ) + (hs : ∀ i j, f i j = f j i) (hd : ∀ i, f i i = 0) : + (∑ i, ∑ j, f i j) = 2 * pairSum f := by + have he : (fun i j => f j i) = f := funext (fun i => funext (fun j => hs j i)) + simpa [he, two_mul] using (pairSum_swap f hd).symm + +lemma le_pairSum {f : Fin n → Fin n → ℝ} (hf : ∀ i j, 0 ≤ f i j) + {i j : Fin n} (hij : i < j) : f i j ≤ pairSum f := by + calc + f i j ≤ ∑ k, if i < k then f i k else 0 := by + have := Finset.single_le_sum (s := Finset.univ) + (f := fun k => if i < k then f i k else 0) + (fun k hk => by split_ifs; exact hf _ _; exact le_rfl) (Finset.mem_univ j) + simpa [hij] using this + _ ≤ pairSum f := by + unfold pairSum + apply Finset.single_le_sum (f := fun k => ∑ l, if k < l then f k l else 0) (a := i) + · intro k hk + apply Finset.sum_nonneg + intro l hl + split_ifs + · exact hf _ _ + · exact le_rfl + · exact Finset.mem_univ i + +noncomputable def cutIndicator (B : Finset (Fin n)) (i : Fin n) : ℝ := if i ∈ B then 1 else 0 +noncomputable def cutDist (B : Finset (Fin n)) (i j : Fin n) : ℝ := + |cutIndicator B i - cutIndicator B j| +noncomputable def cutDemand (B : Finset (Fin n)) : ℝ := (B.card : ℝ) * (Bᶜ.card : ℝ) + +def Cut (n : ℕ) := {B : Finset (Fin n) // B.Nonempty ∧ B ≠ Finset.univ} + +noncomputable instance : Fintype (Cut n) := by unfold Cut; exact Fintype.ofFinite _ + +lemma cutDist_nonneg (B : Finset (Fin n)) (i j : Fin n) : 0 ≤ cutDist B i j := abs_nonneg _ +lemma cutDist_symm (B : Finset (Fin n)) (i j : Fin n) : cutDist B i j = cutDist B j i := + abs_sub_comm _ _ +@[simp] lemma cutDist_self (B : Finset (Fin n)) (i : Fin n) : cutDist B i i = 0 := by + simp [cutDist] + +lemma cutDist_binary (B : Finset (Fin n)) (i j : Fin n) : + cutDist B i j = 0 ∨ cutDist B i j = 1 := by + classical + unfold cutDist cutIndicator + split_ifs <;> norm_num + +lemma cutDist_triangle (B : Finset (Fin n)) (i j k : Fin n) : + cutDist B i k ≤ cutDist B i j + cutDist B j k := abs_sub_le _ _ _ + +lemma cutDemand_eq (B : Finset (Fin n)) : + cutDemand B = (B.card : ℝ) * ((n : ℝ) - B.card) := by + unfold cutDemand + rw [Finset.card_compl, Fintype.card_fin, Nat.cast_sub (show B.card ≤ n by simpa using B.card_le_univ)] + +lemma cutDemand_pos (B : Cut n) : 0 < cutDemand B.1 := by + unfold cutDemand + apply mul_pos + · exact_mod_cast Finset.card_pos.mpr B.2.1 + · exact_mod_cast Finset.card_pos.mpr (by simpa [Finset.nonempty_iff_ne_empty] using B.2.2) + +lemma ordered_cut_sum (B : Finset (Fin n)) (f : Fin n → Fin n → ℝ) : + (∑ i, ∑ j, f i j * cutDist B i j) = + (∑ i ∈ B, ∑ j ∈ Bᶜ, f i j) + (∑ i ∈ Bᶜ, ∑ j ∈ B, f i j) := by + classical + have hp (i j : Fin n) : f i j * cutDist B i j = + (if i ∈ B then if j ∈ Bᶜ then f i j else 0 else 0) + + (if i ∈ Bᶜ then if j ∈ B then f i j else 0 else 0) := by + unfold cutDist cutIndicator + by_cases hi : i ∈ B <;> by_cases hj : j ∈ B <;> simp [hi, hj] + simp_rw [hp] + simp only [Finset.sum_add_distrib, Finset.sum_ite_irrel, + Finset.sum_const_zero, Finset.sum_ite_mem, Finset.univ_inter] + +lemma ordered_cut_sum_symm (B : Finset (Fin n)) (f : Fin n → Fin n → ℝ) + (hs : ∀ i j, f i j = f j i) : + (∑ i, ∑ j, f i j * cutDist B i j) = 2 * (∑ i ∈ B, ∑ j ∈ Bᶜ, f i j) := by + rw [ordered_cut_sum, two_mul] + congr 1 + rw [Finset.sum_comm] + apply Finset.sum_congr rfl + intro i hi + apply Finset.sum_congr rfl + intro j hj + exact hs j i + +lemma pairSum_cut (B : Finset (Fin n)) : pairSum (cutDist B) = cutDemand B := by + have h := ordered_cut_sum_symm B (fun _ _ => 1) (fun _ _ => rfl) + simp only [one_mul, Finset.sum_const, nsmul_eq_mul, mul_one] at h + rw [orderedSum_eq_two_pairSum _ (cutDist_symm B) (cutDist_self B)] at h + unfold cutDemand + nlinarith + +lemma cut_capacity_pair (C : Capacity n) (B : Finset (Fin n)) : + pairSum (fun i j => C.cap i j * cutDist B i j) = + ∑ i ∈ B, ∑ j ∈ Bᶜ, C.cap i j := by + have h := ordered_cut_sum_symm B C.cap C.symm + rw [orderedSum_eq_two_pairSum _ (fun i j => by rw [C.symm i j, cutDist_symm B i j]) + (fun i => by simp)] at h + linarith + +end CutSums + +end UniformSparsestCut + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SparsestCut/DirectionAsymptotics.lean b/lean/OAI/Combinatorics/SparsestCut/DirectionAsymptotics.lean new file mode 100644 index 0000000000000000000000000000000000000000..f9ec028e6847423ef83046a9bfb63e418db9f81f --- /dev/null +++ b/lean/OAI/Combinatorics/SparsestCut/DirectionAsymptotics.lean @@ -0,0 +1,217 @@ +import OAI.Combinatorics.SparsestCut.DirectionInterpolation + +namespace OAI + +open scoped BigOperators Topology NNReal RealInnerProductSpace InnerProductSpace Matrix ContDiff ENNReal +open MeasureTheory ProbabilityTheory Set Filter Matrix + +noncomputable section + +namespace UniformSparsestCut.DirectionAsymptotics +open Filter +open scoped Topology + +lemma grid_card_bound (m k : ℕ) (hm : 2 ≤ m) : + (((2*m^k+1)^m : ℕ) : ℝ) ≤ Real.exp (((k : ℝ)+2)*(m : ℝ)^2) := by + have hm' : (2 : ℝ) ≤ m := by exact_mod_cast hm + have hp : (1 : ℝ) ≤ (m : ℝ)^k := one_le_pow₀ (by linarith) + have he : (m : ℝ) ≤ Real.exp m := by linarith [Real.add_one_le_exp (m : ℝ)] + have h3 : (3 : ℝ) ≤ Real.exp m := by linarith [Real.add_one_le_exp (m : ℝ)] + have hb : (2 : ℝ)*(m : ℝ)^k+1 ≤ Real.exp ((k+1 : ℕ)*(m : ℝ)) := by + calc + _ ≤ 3*(m : ℝ)^k := by linarith + _ ≤ Real.exp m * (Real.exp m)^k := by gcongr + _ = _ := by rw [← Real.exp_nat_mul]; rw [← Real.exp_add]; congr 1; push_cast; ring + push_cast + calc + _ ≤ (Real.exp ((k+1 : ℕ)*(m : ℝ)))^m := pow_le_pow_left₀ (by positivity) hb _ + _ = Real.exp (((k : ℝ)+1)*(m : ℝ)^2) := by rw [← Real.exp_nat_mul]; congr 1; push_cast; ring + _ ≤ _ := by apply Real.exp_le_exp.mpr; nlinarith [sq_nonneg (m : ℝ)] + +lemma polynomial_exp_tendsto_zero (k : ℕ) {c : ℝ} (hc : 0 < c) : + Tendsto (fun m : ℕ => (m : ℝ)^k * Real.exp (-c*(m : ℝ))) atTop (𝓝 0) := by + have h := (tendsto_rpow_mul_exp_neg_mul_atTop_nhds_zero (k : ℝ) c hc).comp + tendsto_natCast_atTop_atTop + simpa only [Real.rpow_natCast, Function.comp_def] using h + +lemma large_fourier_exponent (x : ℝ) (hx : 1000000 ≤ x) : + 54*x^2 - x^4/2048 ≤ -x := by + have hx0 : 0 ≤ x := by linarith + have hx2 : 1000000^2 ≤ x^2 := by nlinarith + have hprod := mul_nonneg (show 1000000^2 - (54*2048+2048 : ℝ) ≥ 0 by norm_num) (sq_nonneg x) + have hx4 : (1000000 : ℝ)^2*x^2 ≤ x^4 := by nlinarith [mul_le_mul_of_nonneg_right hx2 (sq_nonneg x)] + have hxx : x ≤ x^2 := by nlinarith + nlinarith + +lemma large_chart_exponent (x : ℝ) (hx : 1000000 ≤ x) : + 6*x^2 - x^3/32 ≤ -x := by + have hh : 1000000*x^2 ≤ x^3 := by nlinarith [mul_le_mul_of_nonneg_right hx (sq_nonneg x)] + have hxx : x ≤ x^2 := by nlinarith + nlinarith + +lemma selection_majorant_tendsto : + Tendsto (fun m : ℕ => 2*(m : ℝ)^9*Real.exp (-(m : ℝ)/8) + + 6*(m : ℝ)^3*Real.exp (-(m : ℝ))) atTop (𝓝 0) := by + have h1 := (polynomial_exp_tendsto_zero 9 (c := 1/8) (by norm_num)).const_mul 2 + have h2 := (polynomial_exp_tendsto_zero 3 (c := 1) (by norm_num)).const_mul 6 + convert h1.add h2 using 1 + · funext m + simp only [show -(1/8 : ℝ)*(m : ℝ) = -(m : ℝ)/8 by ring, + show -(1 : ℝ)*(m : ℝ) = -(m : ℝ) by ring] + ring + · norm_num + +lemma eventual_selection_majorant : ∀ᶠ m : ℕ in atTop, + 2*(m : ℝ)^9*Real.exp (-(m : ℝ)/8) + + 6*(m : ℝ)^3*Real.exp (-(m : ℝ)) < 1 := + selection_majorant_tendsto.eventually (gt_mem_nhds (by norm_num)) + +lemma normalized_fourier_exponent {m : ℕ} (hm : 0 < m) : + -(m : ℝ)^6*(1/(2*Real.sqrt m))^2/(2*(2*Real.sqrt m)^2) = -(m : ℝ)^4/32 := by + have hm0 : (m : ℝ) ≠ 0 := by exact_mod_cast hm.ne' + have hs : (2*Real.sqrt m)^2 = 4*(m : ℝ) := by + nlinarith [Real.sq_sqrt (Nat.cast_nonneg (α := ℝ) m)] + rw [_root_.one_div_pow, hs] + field_simp + ring + +lemma normalized_covariance_exponent (m : ℕ) (hm : 0 < m) : + -(m : ℝ)^6*(1/8)^2/(2*(4*(m : ℝ))^2) = -(m : ℝ)^4/2048 := by + have hm0 : (m : ℝ) ≠ 0 := by exact_mod_cast hm.ne' + field_simp + ring + +lemma probability_majorization {m : ℕ} (hm : 1000000 ≤ m) {A B : ℝ} + (_hA0 : 0 ≤ A) (hB0 : 0 ≤ B) + (hA : A ≤ Real.exp (6*(m : ℝ)^2)) (hB : B ≤ Real.exp (48*(m : ℝ)^2)) : + (m : ℝ)^3*((m : ℝ)^6*(2*Real.exp (-(m : ℝ)/8)) + + A*B*(2*Real.exp (-(m : ℝ)^4/32)) + A*(2*Real.exp (-(m : ℝ)^4/2048))) + + A*(2*Real.exp (-(m : ℝ)^3/32)) ≤ + 2*(m : ℝ)^9*Real.exp (-(m : ℝ)/8) + 6*(m : ℝ)^3*Real.exp (-(m : ℝ)) := by + have hm' : (1000000 : ℝ) ≤ m := by exact_mod_cast hm + have hpow : (1 : ℝ) ≤ (m : ℝ)^3 := one_le_pow₀ (by linarith) + have hf : A*B*(2*Real.exp (-(m : ℝ)^4/32)) ≤ 2*Real.exp (-(m : ℝ)) := by + calc + _ ≤ Real.exp (6*(m : ℝ)^2)*Real.exp (48*(m : ℝ)^2)* + (2*Real.exp (-(m : ℝ)^4/32)) := by gcongr + _ = 2*Real.exp (54*(m : ℝ)^2-(m : ℝ)^4/32) := by + rw [show 54*(m : ℝ)^2-(m : ℝ)^4/32 = + (6*(m : ℝ)^2+48*(m : ℝ)^2)+(-(m : ℝ)^4/32) by ring, Real.exp_add, Real.exp_add] + ring + _ ≤ _ := by + apply mul_le_mul_of_nonneg_left (Real.exp_le_exp.mpr ?_) (by norm_num) + have := large_fourier_exponent (m : ℝ) hm' + nlinarith [pow_nonneg (Nat.cast_nonneg (α := ℝ) m) 4] + have hc : A*(2*Real.exp (-(m : ℝ)^4/2048)) ≤ 2*Real.exp (-(m : ℝ)) := by + calc + _ ≤ Real.exp (6*(m : ℝ)^2)*(2*Real.exp (-(m : ℝ)^4/2048)) := by gcongr + _ = 2*Real.exp (6*(m : ℝ)^2-(m : ℝ)^4/2048) := by simp only [Real.exp_sub, neg_div, Real.exp_neg]; ring + _ ≤ _ := by + apply mul_le_mul_of_nonneg_left (Real.exp_le_exp.mpr ?_) (by norm_num) + have := large_fourier_exponent (m : ℝ) hm' + nlinarith [sq_nonneg (m : ℝ)] + have hg : A*(2*Real.exp (-(m : ℝ)^3/32)) ≤ 2*Real.exp (-(m : ℝ)) := by + calc + _ ≤ Real.exp (6*(m : ℝ)^2)*(2*Real.exp (-(m : ℝ)^3/32)) := by gcongr + _ = 2*Real.exp (6*(m : ℝ)^2-(m : ℝ)^3/32) := by simp only [Real.exp_sub, neg_div, Real.exp_neg]; ring + _ ≤ _ := mul_le_mul_of_nonneg_left (Real.exp_le_exp.mpr (large_chart_exponent _ hm')) (by norm_num) + have hs := mul_le_mul_of_nonneg_left (add_le_add (add_le_add (le_refl + ((m : ℝ)^6*(2*Real.exp (-(m : ℝ)/8)))) hf) hc) (pow_nonneg (Nat.cast_nonneg m) 3) + have he := mul_le_mul_of_nonneg_right hpow (Real.exp_pos (-(m : ℝ))).le + have hid : (m : ℝ)^3*((m : ℝ)^6*(2*Real.exp (-(m : ℝ)/8))) = + 2*(m : ℝ)^9*Real.exp (-(m : ℝ)/8) := by ring + nlinarith + +lemma projection_failure_bound {m : ℕ} (hm : 2 ≤ m) (hlog : 0 ≤ Real.log m) : + (m : ℝ)^6*(2*Real.exp (-(10*Real.sqrt (Real.log m))^2/2)) ≤ 1/4 := by + have hm' : (2 : ℝ) ≤ m := by exact_mod_cast hm + have hm0 : (0 : ℝ) < m := by linarith + have hs : -(10*Real.sqrt (Real.log m))^2/2 = -((50 : ℕ) * Real.log m) := by + nlinarith [Real.sq_sqrt hlog] + rw [hs, Real.exp_neg, Real.exp_nat_mul, Real.exp_log hm0] + have hpow : (8 : ℝ) ≤ (m : ℝ)^44 := by + have hh : (2 : ℝ)^44 ≤ (m : ℝ)^44 := pow_le_pow_left₀ (by norm_num) hm' _ + norm_num at hh ⊢ ; linarith + have hid : (m : ℝ)^6*(2*((m : ℝ)^50)⁻¹) = 2/(m : ℝ)^44 := by + field_simp + rw [hid] + apply (div_le_iff₀ (pow_pos hm0 _)).mpr + linarith + +lemma eventual_bias_bound : ∀ᶠ m : ℕ in atTop, + 0 < m ∧ 16*Real.exp (-(m : ℝ)/12) ≤ 1/(8*(m : ℝ)) := by + have ht := (polynomial_exp_tendsto_zero 1 (c := 1/12) (by norm_num)).const_mul 128 + have hsmall : ∀ᶠ m : ℕ in atTop, + 128*((m : ℝ)*Real.exp (-(m : ℝ)/12)) < 1 := by + simpa only [pow_one, mul_zero, neg_mul, one_div_mul_eq_div, neg_div] using + ht.eventually (gt_mem_nhds (by norm_num : (128 : ℝ)*0 < 1)) + filter_upwards [hsmall, eventually_ge_atTop 1] with m hs hm + have hm' : (0 : ℝ) < m := by exact_mod_cast (show 0 < m by omega) + refine ⟨by omega, (le_div_iff₀ (by positivity : (0 : ℝ) < 8*(m : ℝ))).mpr ?_⟩ + nlinarith + +lemma scalar_net_error {m : ℕ} (hm : 1000 ≤ m) + (hb : 16*Real.exp (-(m : ℝ)/12) ≤ 1/(8*(m : ℝ))) : + (1/(2*Real.sqrt m) + 16*Real.exp (-(m : ℝ)/12))/(1-1/(m : ℝ)^3) + + (5*(m : ℝ))*(1/(m : ℝ)^3) ≤ 2/Real.sqrt m := by + have hx : (1000 : ℝ) ≤ m := by exact_mod_cast hm + have hx0 : (0 : ℝ) < m := by linarith + have ht : 0 < Real.sqrt m := Real.sqrt_pos.mpr hx0 + have ht2 := Real.sq_sqrt hx0.le + have htm : Real.sqrt m ≤ (m : ℝ) := by nlinarith + have hp3 : (8 : ℝ) ≤ (m : ℝ)^3 := by nlinarith [pow_le_pow_left₀ (by norm_num : (0 : ℝ) ≤ 2) (show (2 : ℝ) ≤ m by linarith) 3] + have hr : 1/(m : ℝ)^3 ≤ 1/8 := (div_le_div_iff₀ (by positivity) (by norm_num)).mpr (by linarith) + have hd : (7/8 : ℝ) ≤ 1-1/(m : ℝ)^3 := by linarith + have hsmall : 1/(8*(m : ℝ)) ≤ 1/(8*Real.sqrt m) := + one_div_le_one_div_of_le (by positivity) (by linarith) + have hbs : 1/(2*Real.sqrt m) + 16*Real.exp (-(m : ℝ)/12) ≤ (5/8)/Real.sqrt m := by + have he : 1/(2*Real.sqrt m) + 1/(8*Real.sqrt m) = (5/8)/Real.sqrt m := by ring + linarith + have hfirst : (1/(2*Real.sqrt m) + 16*Real.exp (-(m : ℝ)/12))/(1-1/(m : ℝ)^3) ≤ + (5/7)/Real.sqrt m := by + calc + _ ≤ ((5/8)/Real.sqrt m)/(7/8) := div_le_div₀ (by positivity) hbs (by norm_num) hd + _ = _ := by ring + have hlast : (5*(m : ℝ))*(1/(m : ℝ)^3) ≤ 1/Real.sqrt m := by + rw [show (5*(m : ℝ))*(1/(m : ℝ)^3) = 5/(m : ℝ)^2 by field_simp ] + apply (div_le_div_iff₀ (by positivity) ht).mpr + nlinarith + have hrest : (5/7)/Real.sqrt m + 1/Real.sqrt m ≤ 2/Real.sqrt m := by + rw [← add_div] + exact div_le_div_of_nonneg_right (by norm_num) ht.le + linarith + +lemma covariance_net_error {m : ℕ} (hm : 1000 ≤ m) + (hb : 16*Real.exp (-(m : ℝ)/12) ≤ 1/(8*(m : ℝ))) : + 1/8 + 16*Real.exp (-(m : ℝ)/12) + 8*(m : ℝ)*(1/(m : ℝ)^3) ≤ 1/2 := by + have hx : (1000 : ℝ) ≤ m := by exact_mod_cast hm + have hx0 : (0 : ℝ) < m := by linarith + have hsm : 1/(8*(m : ℝ)) ≤ 1/8 := one_div_le_one_div_of_le (by norm_num) (by linarith) + have hh : 8*(m : ℝ)*(1/(m : ℝ)^3) ≤ 1/4 := by + rw [show 8*(m : ℝ)*(1/(m : ℝ)^3) = 8/(m : ℝ)^2 by field_simp ] + apply (div_le_iff₀ (by positivity)).mpr + nlinarith + linarith + +lemma projection_net_error {m : ℕ} (hm : 1000 ≤ m) (hl : 1 ≤ Real.log m) : + 10*Real.sqrt (Real.log m) + 2*Real.sqrt m*(1/(m : ℝ)^3) ≤ + 11*Real.sqrt (Real.log m) := by + have hx : (1000 : ℝ) ≤ m := by exact_mod_cast hm + have hx0 : (0 : ℝ) < m := by linarith + have ht := Real.sq_sqrt hx0.le + have htm : Real.sqrt m ≤ (m : ℝ) := by nlinarith [Real.sqrt_nonneg (m : ℝ)] + have hs : 1 ≤ Real.sqrt (Real.log m) := by + nlinarith [Real.sq_sqrt (show 0 ≤ Real.log m by linarith), Real.sqrt_nonneg (Real.log m)] + have hg : 2*Real.sqrt m*(1/(m : ℝ)^3) ≤ 1 := by + rw [mul_one_div] + apply (div_le_iff₀ (by positivity)).mpr + have hp : (m : ℝ)^2 ≤ (m : ℝ)^3 := by + nlinarith [mul_le_mul_of_nonneg_right (show (1 : ℝ) ≤ m by linarith) (sq_nonneg (m : ℝ))] + nlinarith + linarith + +end UniformSparsestCut.DirectionAsymptotics + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SparsestCut/DirectionFamily.lean b/lean/OAI/Combinatorics/SparsestCut/DirectionFamily.lean new file mode 100644 index 0000000000000000000000000000000000000000..deab4cc6e4d41f4cc27b2543f2b5ea30f327c3f7 --- /dev/null +++ b/lean/OAI/Combinatorics/SparsestCut/DirectionFamily.lean @@ -0,0 +1,201 @@ +import OAI.Combinatorics.SparsestCut.DirectionAsymptotics + +namespace OAI + +open scoped BigOperators Topology NNReal RealInnerProductSpace InnerProductSpace Matrix ContDiff ENNReal +open MeasureTheory ProbabilityTheory Set Filter Matrix + +noncomputable section + +namespace UniformSparsestCut.DirectionFamily +open Directions DirectionInterpolation DirectionAsymptotics GaussianTools FiniteNets +open MeasureTheory ProbabilityTheory Set Filter +open scoped BigOperators Topology + +variable {m N S : ℕ} +local notation "E" => EuclideanSpace ℝ (Fin m) + +lemma normBounds_of_not_bad {g : Fin N → E} (hg : g ∉ normBad) (i : Fin N) : + (m : ℝ)/4 ≤ ‖g i‖^2 ∧ ‖g i‖^2 ≤ 4*(m : ℝ) := by + constructor + · by_contra h; exact hg ⟨i, Or.inl (lt_of_not_ge h)⟩ + · by_contra h; exact hg ⟨i, Or.inr (lt_of_not_ge h)⟩ + +lemma inner_empiricalSin (g : Fin N → E) (v w : E) : + inner ℝ (empiricalSin g w - Real.exp (-‖w‖^2/2) • w) v = + (∑ i, inner ℝ (g i) v * Real.sin (inner ℝ (g i) w))/(N : ℝ) - + inner ℝ w v * Real.exp (-‖w‖^2/2) := by + simp only [empiricalSin, inner_sub_left, inner_smul_left, conj_trivial, + sum_inner, div_eq_mul_inv] + congr 1 + · rw [Finset.mul_sum, Finset.sum_mul] + apply Finset.sum_congr rfl + intro i _ + ring + · ring + +lemma net_fourier_scalar (hm : 0 < m) {g : Fin N → E} (hg : g ∉ normBad) + {u : ℝ} (v w : E) (hv : ‖v‖ = 1) (hf : g ∉ fourierBad u v w) : + |inner ℝ (empiricalSin g w - Real.exp (-‖w‖^2/2) • w) v| ≤ + u + 16*Real.exp (-(m : ℝ)/12) := by + have hsample (i : Fin N) : fourierSummand v w (g i) = + inner ℝ (g i) v * Real.sin (inner ℝ (g i) w) := by + dsimp only [fourierSummand, covarianceSummand, truncate] + exact Set.indicator_of_mem (show g i ∈ {z : E | ‖z‖^2 ≤ 4*(m : ℝ)} from + (normBounds_of_not_bad hg i).2) _ + have hdev : |(∑ i, fourierSummand v w (g i))/(N : ℝ) - + ∫ z, fourierSummand v w z ∂stdGaussian E| ≤ u := le_of_not_gt hf + simp_rw [hsample] at hdev + rw [inner_empiricalSin] + have hb := truncation_fourier_bias (show 1 ≤ m by omega) v w hv + exact (abs_sub_le _ (∫ z, fourierSummand v w z ∂stdGaussian E) _).trans (add_le_add hdev hb) + +lemma net_covariance_scalar {g : Fin N → E} (hg : g ∉ normBad) + (v : E) (hv : ‖v‖ = 1) (hf : g ∉ covarianceBad v) : + |empiricalCov g v - 1| ≤ 1/8 + 16*Real.exp (-(m : ℝ)/12) := by + have hsample (i : Fin N) : covarianceSummand v (g i) = (inner ℝ v (g i))^2 := by + dsimp only [fourierSummand, covarianceSummand, truncate] + exact Set.indicator_of_mem (show g i ∈ {z : E | ‖z‖^2 ≤ 4*(m : ℝ)} from + (normBounds_of_not_bad hg i).2) _ + have hdev : |(∑ i, covarianceSummand v (g i))/(N : ℝ) - + ∫ z, covarianceSummand v z ∂stdGaussian E| ≤ 1/8 := le_of_not_gt hf + simp_rw [hsample] at hdev + exact (abs_sub_le _ (∫ z, covarianceSummand v z ∂stdGaussian E) _).trans + (add_le_add hdev (truncation_covariance_bias v hv)) + +lemma source_nets (hm : 2 ≤ m) : ∃ V W : Finset E, + (∀ v ∈ V, ‖v‖ = 1) ∧ + (V.card : ℝ) ≤ Real.exp (6*(m : ℝ)^2) ∧ + (W.card : ℝ) ≤ Real.exp (48*(m : ℝ)^2) ∧ + (∀ v : E, ‖v‖ = 1 → ∃ v' ∈ V, ‖v-v'‖ ≤ 1/(m : ℝ)^3) ∧ + (∀ w : E, ‖w‖ ≤ (m : ℝ)^42 → ∃ w' ∈ W, ‖w-w'‖ ≤ 1/(m : ℝ)^3) := by + have hm0 : (0 : ℝ) < m := by exact_mod_cast (show 0 < m by omega) + have hδ : (0 : ℝ) < 1/(m : ℝ)^4 := by positivity + have hid : (m : ℝ) * (1/(m : ℝ)^4) = 1/(m : ℝ)^3 := by field_simp + obtain ⟨V,hV,hVc,hVnet⟩ := exists_coordinate_net (K := m^4) hδ {v : E | ‖v‖ = 1} (by + intro v hv + change ‖v‖ = 1 at hv + rw [hv, Nat.cast_pow] + simp [hm0.ne']) + obtain ⟨W,hW,hWc,hWnet⟩ := exists_coordinate_net (K := m^46) hδ {w : E | ‖w‖ ≤ (m : ℝ)^42} (by + intro w hw + change ‖w‖ ≤ (m : ℝ)^42 at hw + have he : (((m^46 : ℕ) : ℝ))*(1/(m : ℝ)^4) = (m : ℝ)^42 := by push_cast; field_simp + rwa [he]) + refine ⟨V,W,hV,?_,?_,?_,?_⟩ + · 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) + · 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) + · intro v hv; simpa only [hid] using hVnet v hv + · intro w hw; simpa only [hid] using hWnet w hw + +lemma select_source_nets (hm : 1000000 ≤ m) (hlog : 1 ≤ Real.log m) + (hmajor : 2*(m : ℝ)^9*Real.exp (-(m : ℝ)/8) + + 6*(m : ℝ)^3*Real.exp (-(m : ℝ)) < 1) + (V W : Finset E) (hV : ∀ v ∈ V, ‖v‖ = 1) + (hVc : (V.card : ℝ) ≤ Real.exp (6*(m : ℝ)^2)) + (hWc : (W.card : ℝ) ≤ Real.exp (48*(m : ℝ)^2)) : + ∃ g : Fin (m^3) → Fin (m^6) → E, + (∀ s a b, a ≠ b → ∀ t : ℝ, g s a ≠ t • g s b) ∧ + (∀ s, g s ∉ normBad) ∧ + (∀ s, ∀ v ∈ V, ∀ w ∈ W, g s ∉ fourierBad (1/(2*Real.sqrt m)) v w) ∧ + (∀ s, ∀ v ∈ V, g s ∉ covarianceBad v) ∧ + (∀ v ∈ V, (badCount (projectionBad (10*Real.sqrt (Real.log m)) v) g : ℝ) ≤ + ((m^3 : ℕ) : ℝ)/2) := by + have hm0 : 0 < m := by omega + apply select_on_nets hm0 (pow_pos hm0 _) (pow_pos hm0 _) V W hV + (by positivity) (by positivity) + · simpa only [Nat.cast_pow] using projection_failure_bound (show 2 ≤ m by omega) + (show 0 ≤ Real.log m by linarith) + · exact GaussianNonparallel.charts_pairwise_nonparallel (show 2 ≤ m by omega) + · simp only [Nat.cast_pow] + rw [normalized_fourier_exponent hm0, normalized_covariance_exponent m hm0] + exact (probability_majorization hm (Nat.cast_nonneg _) (Nat.cast_nonneg _) hVc hWc).trans_lt hmajor + +lemma badCount_le_of_imp {A B : Set (Fin N → E)} (g : Fin S → Fin N → E) + (h : ∀ s, g s ∈ A → g s ∈ B) : badCount A g ≤ badCount B g := by + classical + apply Finset.card_le_card + intro s hs + simp only [Finset.mem_filter, Finset.mem_univ, true_and] at hs ⊢ + exact h s hs + +lemma good_chart_interpolation {N S : ℕ} (g : Fin S → Fin N → E) + (hg : ∀ s, g s ∉ normBad) {v v' : E} {ρ q q' : ℝ} + (hd : ‖v-v'‖ ≤ ρ) (hq : q+2*Real.sqrt m*ρ ≤ q') : + badCount (projectionBad q' v) g ≤ badCount (projectionBad q v') g := by + apply badCount_le_of_imp g + intro s hs + by_contra hn + obtain ⟨i,hi⟩ := hs + have hp : |inner ℝ v' (g s i)| ≤ q := by + by_contra h; exact hn ⟨i,lt_of_not_ge h⟩ + have hgn : ‖g s i‖ ≤ 2*Real.sqrt m := by + have := (normBounds_of_not_bad (hg s) i).2 + nlinarith [Real.sq_sqrt (Nat.cast_nonneg (α := ℝ) m), Real.sqrt_nonneg (m : ℝ), norm_nonneg (g s i)] + have hh := (projection_interpolate hgn (by positivity) hd hp).trans hq + exact not_lt_of_ge hh hi + +structure Family (m : ℕ) where + g : Fin (m^3) → Fin (m^6) → EuclideanSpace ℝ (Fin m) + norms : ∀ s i, Real.sqrt m/2 ≤ ‖g s i‖ ∧ ‖g s i‖ ≤ 2*Real.sqrt m + nonparallel : ∀ s a b, a ≠ b → ∀ t : ℝ, g s a ≠ t • g s b + covariance : ∀ s v, ‖v‖ = 1 → 1/2 ≤ empiricalCov (g s) v ∧ empiricalCov (g s) v ≤ 2 + fourier : ∀ s w, ‖w‖ ≤ (m : ℝ)^42 → + ‖empiricalSin (g s) w - Real.exp (-‖w‖^2/2) • w‖ ≤ 2/Real.sqrt m + good : ∀ v, ‖v‖ = 1 → + (badCount (projectionBad (11*Real.sqrt (Real.log m)) v) g : ℝ) ≤ ((m^3 : ℕ) : ℝ)/2 + +lemma family_at_large (hm : 1000000 ≤ m) (hlog : 1 ≤ Real.log m) + (hbias : 16*Real.exp (-(m : ℝ)/12) ≤ 1/(8*(m : ℝ))) + (hmajor : 2*(m : ℝ)^9*Real.exp (-(m : ℝ)/8) + + 6*(m : ℝ)^3*Real.exp (-(m : ℝ)) < 1) : Nonempty (Family m) := by + classical + obtain ⟨V,W,hV,hVc,hWc,hVnet,hWnet⟩ := source_nets (show 2 ≤ m by omega) + obtain ⟨g,hpar,hg,hfour,hcov,hgood⟩ := select_source_nets hm hlog hmajor V W hV hVc hWc + have hm0 : 0 < m := by omega + have hm0' : (0 : ℝ) < m := by exact_mod_cast hm0 + have hn : 0 < m^6 := pow_pos hm0 _ + have hu (s : Fin (m^3)) (i : Fin (m^6)) : ‖g s i‖^2 ≤ 4*(m : ℝ) := + (normBounds_of_not_bad (hg s) i).2 + refine ⟨{ g := g, norms := ?_, nonparallel := hpar, covariance := ?_, fourier := ?_, good := ?_ }⟩ + · intro s i + have h := normBounds_of_not_bad (hg s) i + have hs := Real.sq_sqrt hm0'.le + constructor <;> nlinarith [Real.sqrt_nonneg (m : ℝ), norm_nonneg (g s i)] + · intro s v hv + have hh := covariance_net_bound hn (g s) (hu s) (by positivity) V hV hVnet + (fun v hv => net_covariance_scalar (hg s) v (hV v hv) (hcov s v hv)) v hv + have herr := covariance_net_error (show 1000 ≤ m by omega) hbias + have heq : 2*(4*(m : ℝ))*(1/(m : ℝ)^3) = 8*(m : ℝ)*(1/(m : ℝ)^3) := by ring + rw [heq] at hh + have hab := abs_le.mp (hh.trans herr) + constructor <;> linarith + · intro s w hw + have hρ : 1/(m : ℝ)^3 < 1 := by + apply (div_lt_one (by positivity)).mpr + have hx : (2 : ℝ) ≤ m := by exact_mod_cast (show 2 ≤ m by omega) + have hh := pow_le_pow_left₀ (by norm_num : (0 : ℝ) ≤ 2) hx 3 + norm_num at hh; linarith + have hh := fourier_net_bound hn (g s) (hu s) (by positivity) (by positivity) hρ V W + 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 + have herr := scalar_net_error (show 1000 ≤ m by omega) hbias + have heq : 4*(m : ℝ)+(m : ℝ) = 5*(m : ℝ) := by ring + rw [heq] at hh + exact hh.trans herr + · intro v hv + obtain ⟨v',hv',hd⟩ := hVnet v hv + have hh := good_chart_interpolation g hg hd (projection_net_error (show 1000 ≤ m by omega) hlog) + exact (Nat.cast_le.mpr hh).trans (hgood v' hv') + +theorem directions_exist : ∀ᶠ m : ℕ in atTop, Nonempty (Family m) := by + have hlog : ∀ᶠ m : ℕ in atTop, 1 ≤ Real.log m := + (Real.tendsto_log_atTop.comp tendsto_natCast_atTop_atTop).eventually (eventually_ge_atTop 1) + filter_upwards [eventually_ge_atTop 1000000, hlog, eventual_bias_bound, + eventual_selection_majorant] with m hm hl hb hp + exact family_at_large hm hl hb.2 hp + +end UniformSparsestCut.DirectionFamily + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SparsestCut/DirectionInterpolation.lean b/lean/OAI/Combinatorics/SparsestCut/DirectionInterpolation.lean new file mode 100644 index 0000000000000000000000000000000000000000..fcbee6eabcda3e9ffb551aa4064eafb607e4d2b9 --- /dev/null +++ b/lean/OAI/Combinatorics/SparsestCut/DirectionInterpolation.lean @@ -0,0 +1,152 @@ +import OAI.Combinatorics.SparsestCut.GaussianNonparallel + +namespace OAI + +open scoped BigOperators Topology NNReal RealInnerProductSpace InnerProductSpace Matrix ContDiff ENNReal +open MeasureTheory ProbabilityTheory Set Filter Matrix + +noncomputable section + +namespace UniformSparsestCut.DirectionInterpolation +open GaussianTools FiniteNets MeasureTheory ProbabilityTheory +open scoped BigOperators Topology + +variable {m N : ℕ} +local notation "E" => EuclideanSpace ℝ (Fin m) +noncomputable def empiricalSin (g : Fin N → E) (w : E) : E := + (N : ℝ)⁻¹ • ∑ i, Real.sin (inner ℝ (g i) w) • g i +noncomputable def empiricalCov (g : Fin N → E) (v : E) : ℝ := + (∑ i, (inner ℝ v (g i))^2)/(N : ℝ) + +lemma sin_vector_lipschitz (g w w' : E) : + ‖Real.sin (inner ℝ g w) • g - Real.sin (inner ℝ g w') • g‖ ≤ + ‖g‖^2 * ‖w-w'‖ := by + rw [← sub_smul, norm_smul, Real.norm_eq_abs] + have hs : |Real.sin (inner ℝ g w) - Real.sin (inner ℝ g w')| ≤ + |inner ℝ g (w-w')| := by + simpa only [Real.dist_eq, dist_eq_norm, Real.norm_eq_abs, inner_sub_right, NNReal.coe_one, one_mul] using + Real.lipschitzWith_sin.dist_le_mul (inner ℝ g w) (inner ℝ g w') + calc + _ ≤ |inner ℝ g (w-w')| * ‖g‖ := mul_le_mul_of_nonneg_right hs (norm_nonneg _) + _ ≤ (‖g‖*‖w-w'‖)*‖g‖ := mul_le_mul_of_nonneg_right (abs_real_inner_le_norm _ _) (norm_nonneg _) + _ = _ := by ring + +lemma empiricalSin_lipschitz (hN : 0 < N) (g : Fin N → E) {B : ℝ} + (hB : ∀ i, ‖g i‖^2 ≤ B) (w w' : E) : + ‖empiricalSin g w - empiricalSin g w'‖ ≤ B*‖w-w'‖ := by + have hn : (0 : ℝ) < N := by exact_mod_cast hN + rw [empiricalSin, empiricalSin, ← smul_sub, ← Finset.sum_sub_distrib, norm_smul, + Real.norm_eq_abs, abs_of_pos (inv_pos.mpr hn)] + calc + _ ≤ (N : ℝ)⁻¹ * ∑ i, ‖Real.sin (inner ℝ (g i) w) • g i - + Real.sin (inner ℝ (g i) w') • g i‖ := + mul_le_mul_of_nonneg_left (norm_sum_le _ _) (inv_nonneg.mpr hn.le) + _ ≤ (N : ℝ)⁻¹ * ∑ _ : Fin N, B * ‖w-w'‖ := by + gcongr with i + exact (sin_vector_lipschitz _ _ _).trans (mul_le_mul_of_nonneg_right (hB i) (norm_nonneg _)) + _ = _ := by simp [hn.ne'] + +lemma gaussian_norm_sq_mean : (∫ g : E, ‖g‖^2 ∂stdGaussian E) = m := by + have hid (g : E) : ‖g‖^2 = ∑ i : Fin m, (inner ℝ (EuclideanSpace.single i 1) g)^2 := by + simp only [EuclideanSpace.norm_sq_eq, EuclideanSpace.inner_single_left, conj_trivial, one_mul, + Real.norm_eq_abs, sq_abs] + simp_rw [hid] + rw [integral_finsetSum _ (fun i _ => inner_sq_integrable _)] + simp_rw [gaussian_inner_sq] + simp + +lemma gaussianTransform_lipschitz (w w' : E) : + ‖Real.exp (-‖w‖^2/2) • w - Real.exp (-‖w'‖^2/2) • w'‖ ≤ (m : ℝ)*‖w-w'‖ := by + rw [← gaussian_vector_sin w, ← gaussian_vector_sin w', + ← integral_sub (gaussian_vector_sin_integrable w) (gaussian_vector_sin_integrable w')] + calc + _ ≤ ∫ g : E, ‖Real.sin (inner ℝ g w) • g - Real.sin (inner ℝ g w') • g‖ ∂stdGaussian E := + norm_integral_le_integral_norm _ + _ ≤ ∫ g : E, ‖g‖^2 * ‖w-w'‖ ∂stdGaussian E := by + apply integral_mono ((gaussian_vector_sin_integrable w).sub (gaussian_vector_sin_integrable w')).norm + (gaussian_norm_sq_integrable.mul_const ‖w-w'‖) + exact fun g => sin_vector_lipschitz g w w' + _ = _ := by rw [integral_mul_const, gaussian_norm_sq_mean] + +lemma covariance_lipschitz (hN : 0 < N) (g : Fin N → E) {B : ℝ} + (hg : ∀ i, ‖g i‖^2 ≤ B) {v v' : E} (hv : ‖v‖ = 1) (hv' : ‖v'‖ = 1) : + |empiricalCov g v - empiricalCov g v'| ≤ 2*B*‖v-v'‖ := by + have hn : (0 : ℝ) < N := by exact_mod_cast hN + have hterm (i : Fin N) : |(inner ℝ v (g i))^2 - (inner ℝ v' (g i))^2| ≤ + 2*B*‖v-v'‖ := by + rw [sq_sub_sq, abs_mul, mul_comm] + have ha : |inner ℝ v (g i)| ≤ ‖g i‖ := by simpa [hv] using abs_real_inner_le_norm v (g i) + have hb : |inner ℝ v' (g i)| ≤ ‖g i‖ := by simpa [hv'] using abs_real_inner_le_norm v' (g i) + have hd : |inner ℝ v (g i) - inner ℝ v' (g i)| ≤ ‖v-v'‖*‖g i‖ := by + simpa only [inner_sub_left] using abs_real_inner_le_norm (v-v') (g i) + calc + _ ≤ (‖v-v'‖*‖g i‖)*(2*‖g i‖) := + mul_le_mul hd ((abs_add_le _ _).trans (by linarith)) (abs_nonneg _) (by positivity) + _ = 2*‖g i‖^2*‖v-v'‖ := by ring + _ ≤ 2*B*‖v-v'‖ := by gcongr; exact hg i + rw [empiricalCov, empiricalCov, ← sub_div, abs_div, abs_of_pos hn, ← Finset.sum_sub_distrib] + apply (div_le_iff₀ hn).mpr + calc + _ ≤ ∑ i : Fin N, |(inner ℝ v (g i))^2 - (inner ℝ v' (g i))^2| := Finset.abs_sum_le_sum_abs _ _ + _ ≤ ∑ _ : Fin N, 2*B*‖v-v'‖ := Finset.sum_le_sum (fun i _ => hterm i) + _ = _ := by simp [mul_comm] + +lemma covariance_net_bound (hN : 0 < N) (g : Fin N → E) {B b ρ : ℝ} + (hg : ∀ i, ‖g i‖^2 ≤ B) (hB : 0 ≤ B) (V : Finset E) + (hV : ∀ v ∈ V, ‖v‖ = 1) + (hnet : ∀ x : E, ‖x‖ = 1 → ∃ v ∈ V, ‖x-v‖ ≤ ρ) + (hdev : ∀ v ∈ V, |empiricalCov g v - 1| ≤ b) + (x : E) (hx : ‖x‖ = 1) : |empiricalCov g x - 1| ≤ b + 2*B*ρ := by + obtain ⟨v,hv,hd⟩ := hnet x hx + calc + _ ≤ |empiricalCov g x - empiricalCov g v| + |empiricalCov g v - 1| := abs_sub_le _ _ _ + _ ≤ 2*B*‖x-v‖ + b := add_le_add (covariance_lipschitz hN g hg hx (hV v hv)) (hdev v hv) + _ ≤ b + 2*B*ρ := by nlinarith + +lemma fourier_net_bound (hN : 0 < N) (g : Fin N → E) {B b ρ δ R : ℝ} + (hg : ∀ i, ‖g i‖^2 ≤ B) (hB : 0 ≤ B) (hb : 0 ≤ b) (hρ : ρ < 1) + (V W : Finset E) + (hV : ∀ x : E, ‖x‖ = 1 → ∃ v ∈ V, ‖x-v‖ ≤ ρ) + (hW : ∀ w : E, ‖w‖ ≤ R → ∃ w' ∈ W, ‖w-w'‖ ≤ δ) + (hdev : ∀ v ∈ V, ∀ w ∈ W, + |inner ℝ (empiricalSin g w - Real.exp (-‖w‖^2/2) • w) v| ≤ b) + (w : E) (hw : ‖w‖ ≤ R) : + ‖empiricalSin g w - Real.exp (-‖w‖^2/2) • w‖ ≤ b/(1-ρ) + (B+(m : ℝ))*δ := by + obtain ⟨w',hw',hd⟩ := hW w hw + have hn : ‖empiricalSin g w' - Real.exp (-‖w'‖^2/2) • w'‖ ≤ b/(1-ρ) := by + apply (le_div_iff₀ (by linarith : 0 < 1-ρ)).mpr + nlinarith [sphere_net_norm_bound hV (fun v hv => hdev v hv w' hw') hb] + calc + _ ≤ ‖empiricalSin g w - empiricalSin g w'‖ + + ‖empiricalSin g w' - Real.exp (-‖w'‖^2/2) • w'‖ + + ‖Real.exp (-‖w'‖^2/2) • w' - Real.exp (-‖w‖^2/2) • w‖ := + by + have hid : empiricalSin g w - Real.exp (-‖w‖^2/2) • w = + (empiricalSin g w - empiricalSin g w') + + (empiricalSin g w' - Real.exp (-‖w'‖^2/2) • w') + + (Real.exp (-‖w'‖^2/2) • w' - Real.exp (-‖w‖^2/2) • w) := by abel + rw [hid] + exact (norm_add_le _ _).trans (add_le_add (norm_add_le _ _) (le_refl _)) + _ ≤ B*‖w-w'‖ + b/(1-ρ) + (m : ℝ)*‖w-w'‖ := by + apply add_le_add (add_le_add (empiricalSin_lipschitz hN g hg w w') hn) + simpa only [norm_sub_rev] using gaussianTransform_lipschitz w' w + _ ≤ b/(1-ρ) + (B+(m : ℝ))*δ := by + have hm : (0 : ℝ) ≤ m := Nat.cast_nonneg m + nlinarith + +lemma projection_interpolate {g v v' : E} {q K ρ : ℝ} + (hg : ‖g‖ ≤ K) (_hK : 0 ≤ K) (hd : ‖v-v'‖ ≤ ρ) + (hp : |inner ℝ v' g| ≤ q) : |inner ℝ v g| ≤ q + K*ρ := by + have hi : inner ℝ v g = inner ℝ v' g + inner ℝ (v-v') g := by rw [inner_sub_left]; ring + calc + _ ≤ |inner ℝ v' g| + |inner ℝ (v-v') g| := by rw [hi]; exact abs_add_le _ _ + _ ≤ q + ‖v-v'‖*‖g‖ := add_le_add hp (abs_real_inner_le_norm _ _) + _ ≤ q + K*ρ := by + have hρ : 0 ≤ ρ := (norm_nonneg _).trans hd + nlinarith [mul_le_mul hd hg (norm_nonneg _) hρ] + +end UniformSparsestCut.DirectionInterpolation + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SparsestCut/Directions.lean b/lean/OAI/Combinatorics/SparsestCut/Directions.lean new file mode 100644 index 0000000000000000000000000000000000000000..89212916e0719486a5816292aa53e9009db2dbba --- /dev/null +++ b/lean/OAI/Combinatorics/SparsestCut/Directions.lean @@ -0,0 +1,291 @@ +import OAI.Combinatorics.SparsestCut.FiniteNets + +namespace OAI + +universe u1 u2 u3 u4 u5 + +open scoped BigOperators Topology NNReal RealInnerProductSpace InnerProductSpace Matrix ContDiff ENNReal +open MeasureTheory ProbabilityTheory Set Filter Matrix + +noncomputable section + +namespace UniformSparsestCut.Directions +open GaussianTools FiniteNets MeasureTheory ProbabilityTheory Set Filter +open scoped BigOperators NNReal Topology + +section ProductMeasures +variable {E : Type u1} [MeasurableSpace E] {μ : Measure E} [IsProbabilityMeasure μ] + +lemma integral_eval {n : ℕ} {f : E → ℝ} (hf : Measurable f) (i : Fin n) : + (∫ x : Fin n → E, f (x i) ∂Measure.pi (fun _ => μ)) = ∫ x, f x ∂μ := by + have hp := measurePreserving_eval (fun _ : Fin n => μ) i + have hh := integral_map hp.aemeasurable (hf.aestronglyMeasurable : + AEStronglyMeasurable f ((Measure.pi (fun _ : Fin n => μ)).map (Function.eval i))) + rw [hp.map_eq] at hh + exact hh.symm + +lemma real_measure_eval {n : ℕ} {A : Set E} (hA : MeasurableSet A) (i : Fin n) : + (Measure.pi (fun _ : Fin n => μ)).real {x | x i ∈ A} = μ.real A := by + have hp := (measurePreserving_eval (fun _ : Fin n => μ) i).measure_preimage hA.nullMeasurableSet + exact congrArg ENNReal.toReal hp + +lemma iid_bounded_concentration {n : ℕ} (hn : 0 < n) {f : E → ℝ} + (hf : Measurable f) {B : ℝ} (hB : 0 < B) (hfB : ∀ x, |f x| ≤ B) + {u : ℝ} (hu : 0 ≤ u) : + (Measure.pi (fun _ : Fin n => μ)).real + {x | u < |(∑ i, f (x i)) / (n : ℝ) - ∫ z, f z ∂μ|} ≤ + 2 * Real.exp (-(n : ℝ)*u^2/(2*B^2)) := by + have h := bounded_concentration hn (fun i (x : Fin n → E) => f (x i)) + (fun i => (hf.comp (measurable_pi_apply i)).aemeasurable) + (iIndepFun_pi (μ := fun _ : Fin n => μ) (fun _ => hf.aemeasurable)) hB + (fun i => ae_of_all _ (fun x => hfB (x i))) hu + have hn0 : (n : ℝ) ≠ 0 := by exact_mod_cast hn.ne' + have heq (x : Fin n → E) : + (∑ i, (f (x i) - ∫ z : Fin n → E, f (z i) ∂Measure.pi (fun _ => μ))) / (n : ℝ) = + (∑ i, f (x i)) / (n : ℝ) - ∫ z, f z ∂μ := by + simp_rw [integral_eval hf] + rw [Finset.sum_sub_distrib] + simp only [Finset.sum_const, Finset.card_univ, Fintype.card_fin, nsmul_eq_mul] + field_simp + simpa only [heq] using h + +lemma real_measure_exists_le {n : ℕ} (A : Fin n → Set E) (hA : ∀ i, MeasurableSet (A i)) + {p : ℝ} (hp : ∀ i, μ.real (A i) ≤ p) : + (Measure.pi (fun _ : Fin n => μ)).real {x | ∃ i, x i ∈ A i} ≤ (n : ℝ)*p := by + calc + _ = (Measure.pi (fun _ : Fin n => μ)).real (⋃ i : Fin n, {x | x i ∈ A i}) := by + congr 1; ext x; simp + _ ≤ ∑ i : Fin n, (Measure.pi (fun _ : Fin n => μ)).real {x | x i ∈ A i} := + measureReal_iUnion_fintype_le _ + _ = ∑ i : Fin n, μ.real (A i) := by simp_rw [real_measure_eval (hA _)] + _ ≤ ∑ _ : Fin n, p := Finset.sum_le_sum (fun i _ => hp i) + _ = _ := by simp + +noncomputable def badCount {S : ℕ} (A : Set E) (x : Fin S → E) : ℕ := by + classical + exact (Finset.univ.filter (fun s => x s ∈ A)).card + +lemma bad_chart_fraction {S : ℕ} (hS : 0 < S) {A : Set E} (hA : MeasurableSet A) + (hp : μ.real A ≤ 1/4) : + (Measure.pi (fun _ : Fin S => μ)).real + {x | (S : ℝ)/2 < (badCount A x : ℝ)} ≤ + 2 * Real.exp (-(S : ℝ)/32) := by + classical + let f : E → ℝ := A.indicator (fun _ => 1) + have hf : Measurable f := measurable_const.indicator hA + have hbound (x : E) : |f x| ≤ 1 := by + by_cases hx : x ∈ A <;> simp [f, hx] + have hmean : (∫ x, f x ∂μ) = μ.real A := integral_indicator_one hA + have h := iid_bounded_concentration (μ := μ) hS hf (by norm_num : (0 : ℝ) < 1) hbound + (u := 1/4) (by norm_num) + have hcount (x : Fin S → E) : (∑ s : Fin S, f (x s)) = + (badCount A x : ℝ) := by + dsimp [badCount] + simp only [f, Set.indicator] + rw [← Finset.sum_filter] + simp + have hspos : (0 : ℝ) < S := by exact_mod_cast hS + have hsub : {x : Fin S → E | (S : ℝ)/2 < (badCount A x : ℝ)} ⊆ + {x | (1/4 : ℝ) < |(∑ s, f (x s))/(S : ℝ) - ∫ z, f z ∂μ|} := by + intro x hx + change (S : ℝ)/2 < (badCount A x : ℝ) at hx + change (1/4 : ℝ) < |(∑ s, f (x s))/(S : ℝ) - ∫ z, f z ∂μ| + rw [hcount, hmean] + apply (lt_abs.mpr (Or.inl ?_)) + have hh : (1/2 : ℝ) < (badCount A x : ℝ)/(S : ℝ) := + (lt_div_iff₀ hspos).mpr (by linarith) + linarith + calc + _ ≤ _ := measureReal_mono hsub + _ ≤ 2 * Real.exp (-(S : ℝ) * (1/4)^2 / (2*1^2)) := h + _ = _ := by congr 2; ring + +lemma exists_outside_of_real_lt_one {Ω : Type u2} [MeasurableSpace Ω] + {ν : Measure Ω} [IsProbabilityMeasure ν] {A : Set Ω} (hA : (ν).real A < 1) : + ∃ x, x ∉ A := by + by_contra h + push Not at h + have heq : A = Set.univ := Set.eq_univ_of_forall h + simp [heq, measureReal_def] at hA + +lemma exists_outside_with_ae {Ω : Type u3} [MeasurableSpace Ω] + {ν : Measure Ω} [IsProbabilityMeasure ν] {A : Set Ω} (hA : (ν).real A < 1) + {P : Ω → Prop} (hP : ∀ᵐ x ∂ν, P x) : ∃ x, x ∉ A ∧ P x := by + have hnull : (ν).real {x | ¬ P x} = 0 := by + rw [measureReal_def, ae_iff.mp hP, ENNReal.toReal_zero] + have hlt : (ν).real (A ∪ {x | ¬ P x}) < 1 := + ((measureReal_union_le _ _).trans_eq (by rw [hnull, add_zero])).trans_lt hA + obtain ⟨x,hx⟩ := exists_outside_of_real_lt_one hlt + exact ⟨x, fun ha => hx (Or.inl ha), by_contra (fun hn => hx (Or.inr hn))⟩ + +end ProductMeasures + +lemma finite_union_bound {Ω : Type u4} {I : Type u5} [MeasurableSpace Ω] [Fintype I] + {ν : Measure Ω} [IsProbabilityMeasure ν] (A : I → Set Ω) {p : ℝ} + (hA : ∀ i, (ν).real (A i) ≤ p) : + (ν).real {x | ∃ i, x ∈ A i} ≤ (Fintype.card I : ℝ)*p := by + calc + _ = (ν).real (⋃ i, A i) := by congr 1; ext; simp + _ ≤ ∑ i, (ν).real (A i) := measureReal_iUnion_fintype_le _ + _ ≤ ∑ _ : I, p := Finset.sum_le_sum (fun i _ => hA i) + _ = _ := by simp + +section GaussianSelection +variable {m N S : ℕ} +local notation "E" => EuclideanSpace ℝ (Fin m) +local notation "μ" => stdGaussian E +local notation "ν" => Measure.pi (fun _ : Fin N => μ) +local notation "π" => Measure.pi (fun _ : Fin S => ν) + +noncomputable def fourierSummand (v w : E) : E → ℝ := + truncate m (fun g => inner ℝ g v * Real.sin (inner ℝ g w)) +noncomputable def covarianceSummand (v : E) : E → ℝ := + truncate m (fun g => (inner ℝ v g)^2) + +def normBad : Set (Fin N → E) := + {x | ∃ i, ‖x i‖^2 < (m : ℝ)/4 ∨ 4*(m : ℝ) < ‖x i‖^2} +noncomputable def fourierBad (u : ℝ) (v w : E) : Set (Fin N → E) := + {x | u < |(∑ i, fourierSummand v w (x i))/(N : ℝ) - ∫ g, fourierSummand v w g ∂μ|} +noncomputable def covarianceBad (v : E) : Set (Fin N → E) := + {x | (1/8 : ℝ) < |(∑ i, covarianceSummand v (x i))/(N : ℝ) - ∫ g, covarianceSummand v g ∂μ|} +def projectionBad (q : ℝ) (v : E) : Set (Fin N → E) := + {x | ∃ i, q < |inner ℝ v (x i)|} + +lemma fourierSummand_measurable (v w : E) : Measurable (fourierSummand v w) := + (by fun_prop : Measurable (fun g : E => inner ℝ g v * Real.sin (inner ℝ g w))).indicator + measurable_truncation_set +lemma covarianceSummand_measurable (v : E) : Measurable (covarianceSummand v) := + (by fun_prop : Measurable (fun g : E => (inner ℝ v g)^2)).indicator measurable_truncation_set +lemma normBad_measurable : MeasurableSet (normBad (m := m) (N := N)) := by + unfold normBad; measurability +lemma fourierBad_measurable (u : ℝ) (v w : E) : MeasurableSet (fourierBad (N := N) u v w) := by + unfold fourierBad + have hf (i : Fin N) : Measurable (fun x : Fin N → E => fourierSummand v w (x i)) := + (fourierSummand_measurable v w).comp (measurable_pi_apply i) + measurability +lemma covarianceBad_measurable (v : E) : MeasurableSet (covarianceBad (N := N) v) := by + unfold covarianceBad + have hf (i : Fin N) : Measurable (fun x : Fin N → E => covarianceSummand v (x i)) := + (covarianceSummand_measurable v).comp (measurable_pi_apply i) + measurability +lemma projectionBad_measurable (q : ℝ) (v : E) : MeasurableSet (projectionBad (N := N) q v) := by + unfold projectionBad; measurability + +lemma normBad_bound : (ν).real (normBad (m := m) (N := N)) ≤ + (N : ℝ)* (2*Real.exp (-(m : ℝ)/8)) := + real_measure_exists_le (fun _ => {g : E | ‖g‖^2 < (m : ℝ)/4 ∨ 4*(m : ℝ) < ‖g‖^2}) + (fun _ => by measurability) (fun _ => by + have h := (measureReal_union_le + {g : E | ‖g‖^2 < (m : ℝ)/4} {g : E | 4*(m : ℝ) < ‖g‖^2}).trans + (add_le_add (gaussian_norm_lower (n := m)) (gaussian_norm_upper (n := m))) + have he : Real.exp (-(m : ℝ)/2) ≤ Real.exp (-(m : ℝ)/8) := + Real.exp_le_exp.mpr (by have := Nat.cast_nonneg (α := ℝ) m; linarith) + exact h.trans (by linarith)) + +lemma fourierBad_bound (hm : 0 < m) (hN : 0 < N) {u : ℝ} (hu : 0 ≤ u) + (v w : E) (hv : ‖v‖ = 1) : + (ν).real (fourierBad (N := N) u v w) ≤ + 2*Real.exp (-(N : ℝ)*u^2/(2*(2*Real.sqrt m)^2)) := by + exact iid_bounded_concentration hN (fourierSummand_measurable v w) + (by positivity) (truncate_fourier_bound v w hv) hu +lemma covarianceBad_bound (hm : 0 < m) (hN : 0 < N) (v : E) (hv : ‖v‖ = 1) : + (ν).real (covarianceBad (N := N) v) ≤ + 2*Real.exp (-(N : ℝ)*(1/8)^2/(2*(4*(m : ℝ))^2)) := by + exact iid_bounded_concentration hN (covarianceSummand_measurable v) + (by positivity) (truncate_covariance_bound v hv) (by norm_num) +lemma projectionBad_bound {q : ℝ} (hq : 0 ≤ q) (v : E) (hv : ‖v‖ = 1) : + (ν).real (projectionBad (N := N) q v) ≤ (N : ℝ)*(2*Real.exp (-q^2/2)) := + real_measure_exists_le (fun _ => {g : E | q < |inner ℝ v g|}) + (fun _ => by measurability) (fun _ => gaussian_inner_tail v hv hq) + +noncomputable def chartBad (V W : Finset E) (u : ℝ) : Set (Fin N → E) := + normBad ∪ {x | ∃ z : V × W, x ∈ fourierBad u z.1 z.2} ∪ + {x | ∃ v : V, x ∈ covarianceBad v} + +lemma chartBad_measurable (V W : Finset E) (u : ℝ) : + MeasurableSet (chartBad (N := N) V W u) := by + classical + have hFm : MeasurableSet {x : Fin N → E | ∃ z : V × W, x ∈ fourierBad u z.1 z.2} := by + rw [show {x : Fin N → E | ∃ z : V × W, x ∈ fourierBad u z.1 z.2} = + ⋃ z : V × W, fourierBad (N := N) u z.1 z.2 by ext x; simp] + exact MeasurableSet.iUnion (fun z : V × W => fourierBad_measurable (m := m) (N := N) u z.1 z.2) + have hCm : MeasurableSet {x : Fin N → E | ∃ v : V, x ∈ covarianceBad v} := by + rw [show {x : Fin N → E | ∃ v : V, x ∈ covarianceBad v} = + ⋃ v : V, covarianceBad (N := N) v by ext x; simp] + exact MeasurableSet.iUnion (fun v : V => covarianceBad_measurable (m := m) (N := N) v) + exact (normBad_measurable.union hFm).union hCm + +lemma chartBad_bound (hm : 0 < m) (hN : 0 < N) (V W : Finset E) + (hV : ∀ v ∈ V, ‖v‖ = 1) {u : ℝ} (hu : 0 ≤ u) : + (ν).real (chartBad (N := N) V W u) ≤ (N : ℝ)*(2*Real.exp (-(m : ℝ)/8)) + + (V.card : ℝ)*(W.card : ℝ)*(2*Real.exp (-(N : ℝ)*u^2/(2*(2*Real.sqrt m)^2))) + + (V.card : ℝ)*(2*Real.exp (-(N : ℝ)*(1/8)^2/(2*(4*(m : ℝ))^2))) := by + classical + have h1 := finite_union_bound («ν» := ν) (fun z : V × W => fourierBad u z.1 z.2) + (fun z => fourierBad_bound hm hN hu z.1 z.2 (hV z.1 z.1.property)) + have h2 := finite_union_bound («ν» := ν) (fun v : V => covarianceBad v) + (fun v => covarianceBad_bound hm hN v (hV v v.property)) + simp only [Fintype.card_prod, Fintype.card_coe, Nat.cast_mul] at h1 h2 + exact (measureReal_union_le _ _).trans + (add_le_add ((measureReal_union_le _ _).trans (add_le_add normBad_bound h1)) h2) + +lemma projection_chart_fraction (hS : 0 < S) (v : E) (hv : ‖v‖ = 1) + {q : ℝ} (hq : 0 ≤ q) (hqprob : (N : ℝ)*(2*Real.exp (-q^2/2)) ≤ 1/4) : + (π).real {g | (S : ℝ)/2 < (badCount (projectionBad q v) g : ℝ)} ≤ + 2*Real.exp (-(S : ℝ)/32) := by + have hmeas : MeasurableSet (projectionBad (N := N) q v) := projectionBad_measurable q v + have hbound : (ν).real (projectionBad (N := N) q v) ≤ 1/4 := + (projectionBad_bound hq v hv).trans hqprob + exact bad_chart_fraction hS hmeas hbound + +lemma goodBad_bound (hS : 0 < S) (V : Finset E) (hV : ∀ v ∈ V, ‖v‖ = 1) + {q : ℝ} (hq : 0 ≤ q) (hqprob : (N : ℝ)*(2*Real.exp (-q^2/2)) ≤ 1/4) : + (π).real {g | ∃ v : V, (S : ℝ)/2 < (badCount (projectionBad q v) g : ℝ)} ≤ + (V.card : ℝ)*(2*Real.exp (-(S : ℝ)/32)) := by + classical + have h := finite_union_bound («ν» := π) + (fun v : V => {g | (S : ℝ)/2 < (badCount (projectionBad q v) g : ℝ)}) + (fun v => projection_chart_fraction hS (v : E) (hV v v.property) hq hqprob) + simpa only [Fintype.card_coe, Set.mem_ofPred_eq] using h + +theorem select_on_nets (hm : 0 < m) (hN : 0 < N) (hS : 0 < S) + (V W : Finset E) (hV : ∀ v ∈ V, ‖v‖ = 1) + {u q : ℝ} (hu : 0 ≤ u) (hq : 0 ≤ q) + (hqprob : (N : ℝ)*(2*Real.exp (-q^2/2)) ≤ 1/4) + {P : (Fin S → Fin N → E) → Prop} (hP : ∀ᵐ g ∂π, P g) + (hprob : (S : ℝ) * ((N : ℝ)*(2*Real.exp (-(m : ℝ)/8)) + + (V.card : ℝ)*(W.card : ℝ)*(2*Real.exp (-(N : ℝ)*u^2/(2*(2*Real.sqrt m)^2))) + + (V.card : ℝ)*(2*Real.exp (-(N : ℝ)*(1/8)^2/(2*(4*(m : ℝ))^2)))) + + (V.card : ℝ)*(2*Real.exp (-(S : ℝ)/32)) < 1) : + ∃ g : Fin S → Fin N → E, P g ∧ + (∀ s, g s ∉ normBad) ∧ + (∀ s, ∀ v ∈ V, ∀ w ∈ W, g s ∉ fourierBad u v w) ∧ + (∀ s, ∀ v ∈ V, g s ∉ covarianceBad v) ∧ + (∀ v ∈ V, (badCount (projectionBad q v) g : ℝ) ≤ (S : ℝ)/2) := by + classical + let A := chartBad (N := N) V W u + let B : Set (Fin S → Fin N → E) := {g | ∃ s, g s ∈ A} + let C : Set (Fin S → Fin N → E) := + {g | ∃ v : V, (S : ℝ)/2 < (badCount (projectionBad q v) g : ℝ)} + have hBbound := real_measure_exists_le (fun _ : Fin S => A) + (fun _ => chartBad_measurable V W u) (fun _ => chartBad_bound hm hN V W hV hu) + have hCbound := goodBad_bound hS V hV hq hqprob + have hBC : (π).real (B ∪ C) < 1 := + ((measureReal_union_le B C).trans (add_le_add hBbound hCbound)).trans_lt hprob + obtain ⟨g, hg, hgP⟩ := exists_outside_with_ae hBC hP + have hgB : ∀ s, g s ∉ A := by + intro s hs; exact hg (Or.inl ⟨s, hs⟩) + refine ⟨g, hgP, ?_, ?_, ?_, ?_⟩ + · intro s hs; exact hgB s (Or.inl (Or.inl hs)) + · intro s v hv w hw hs; exact hgB s (Or.inl (Or.inr ⟨(⟨v,hv⟩,⟨w,hw⟩), hs⟩)) + · intro s v hv hs; exact hgB s (Or.inr ⟨⟨v,hv⟩, hs⟩) + · intro v hv; by_contra h + exact hg (Or.inr ⟨⟨v,hv⟩, lt_of_not_ge h⟩) + +end GaussianSelection + +end UniformSparsestCut.Directions + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SparsestCut/EuclideanCells.lean b/lean/OAI/Combinatorics/SparsestCut/EuclideanCells.lean new file mode 100644 index 0000000000000000000000000000000000000000..bffc14f26e0b4987d02de6eed747ca3f2b69169a --- /dev/null +++ b/lean/OAI/Combinatorics/SparsestCut/EuclideanCells.lean @@ -0,0 +1,164 @@ +import OAI.Combinatorics.SparsestCut.CoordinateSplit + +namespace OAI + +universe u1 u2 + +open scoped BigOperators Topology NNReal RealInnerProductSpace InnerProductSpace Matrix ContDiff ENNReal +open MeasureTheory ProbabilityTheory Set Filter Matrix + +noncomputable section + +namespace UniformSparsestCut.EuclideanCells +open MeasureTheory Set ProductSlice CellInterface CoordinateSplit +open scoped BigOperators RealInnerProductSpace +noncomputable section +variable {m : ℕ} {I : Type u1} {A : Type u2} [Fintype I] [Fintype A] [DecidableEq I] +local notation "E" => EuclideanSpace ℝ (Fin (m+1)) +local notation "Z" => EuclideanSpace ℝ (Fin m) + +def B (u : I → E) : I → Z →L[ℝ] ℝ := fun i => slope (u i) +def pivot (u : I → E) (i : I) : ℝ := u i 0 + +def values (u : I → E) (τ : ℝ) (s : Finset ℤ) (U : Set (ℝ × Z)) + (F : LabelVertex (ell (B u) (pivot u)) τ U → A → ℝ) : Finset (I × s) → A → ℝ := + extension (ell (B u) (pivot u)) (pivot u) τ s U F + +def chartFunction (u : I → E) (τ : ℝ) (s : Finset ℤ) (U : Set (ℝ × Z)) + (F : LabelVertex (ell (B u) (pivot u)) τ U → A → ℝ) (a : A) : E → ℝ := + (cell (B u) (fun i (k : s) => -((k:ℤ)*τ/pivot u i)) (fun P => values u τ s U F P a)) ∘ split + +lemma form_comp (u : E) (hu : u 0≠0) : + (form (slope u)).comp split.toContinuousLinearMap=(u 0)⁻¹ • InnerProductSpace.toDual ℝ E u := by + ext x + have hh := normalized_form u hu x + change (split x).1-slope u (split x).2=(u 0)⁻¹*inner ℝ u x + rw [← hh,div_eq_mul_inv,mul_comm] + +lemma kernel_split (φ : ℝ → ℝ) : + (ProductMollifier.kernel (m := m+1) φ) ∘ split.symm = + (fun p : ℝ × Z => φ p.1*ProductMollifier.kernel φ p.2) := by + funext p + simp [ProductMollifier.kernel,Fin.prod_univ_succ] + +omit [Fintype A] [DecidableEq I] in +lemma chartFunction_eq (u : I → E) (hu : ∀ i, u i 0≠0) + {τ : ℝ} (hτ : 0<τ) (s : Finset ℤ) (U : Set (ℝ × Z)) + (hb : ∀ x∈U, regular (ell (B u) (pivot u)) τ x → ∀ i, label (ell (B u) (pivot u)) τ x i∈s) + (F : LabelVertex (ell (B u) (pivot u)) τ U → A → ℝ) + (x : E) (hx : split x∈U) (hr : regular (ell (B u) (pivot u)) τ (split x)) (a : A) : + chartFunction u τ s U F a x=F (vertex (ell (B u) (pivot u)) τ (split x) hx hr) a := by + 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)=_ + rw [cell_eq_extension (B u) (pivot u) hu (F := F)] + exact congrFun (extension_eq (ell (B u) (pivot u)) (pivot u) hu hτ s U hb F _ hx hr) a + +omit [Fintype A] in +lemma chartFunction_measurable (u : I → E) (τ : ℝ) (s : Finset ℤ) (U : Set (ℝ × Z)) + (F : LabelVertex (ell (B u) (pivot u)) τ U → A → ℝ) (a : A) : + Measurable (chartFunction u τ s U F a) := + (cell_measurable _ _ _).comp split.continuous.measurable + +omit [Fintype A] in +lemma chartFunction_integrable (u : I → E) (τ : ℝ) (s : Finset ℤ) (U : Set (ℝ × Z)) + (F : LabelVertex (ell (B u) (pivot u)) τ U → A → ℝ) {M : ℝ} (hM : 0≤M) + (hF : ∀ v a, |F v a|≤M) (a : A) : LocallyIntegrable (chartFunction u τ s U F a) := by + apply (locallyIntegrable_const M).mono (chartFunction_measurable _ _ _ _ _ _).aestronglyMeasurable + filter_upwards with x + simpa only [chartFunction,Function.comp_apply,cell,values,Real.norm_eq_abs,abs_of_nonneg hM] using extension_bounded _ _ _ _ _ F hM hF _ a + +lemma coefficients (u : I → E) (hu : ∀ i, u i 0≠0) + (hnp : ∀ i j, i≠j → ∀ t : ℝ, u i≠t • u j) + {τ lam : ℝ} (hτ : 0<τ) (hlam : 0 (ProductMollifier.density_support hlam ht).le) + have hiψ : Integrable ψ := hcψ.continuous.integrable_of_hasCompactSupport hcompψ + have hnψ := ProductMollifier.kernel_nonneg (m := m) hnφ + have hψ1 : ∫ z, ψ z=1 := by rw [ProductMollifier.kernel_integral,ProductMollifier.density_integral hlam,one_pow] + obtain ⟨C,hC⟩ := hcφ.bounded_above_of_compact_support hcompφ + have hC0 : 0≤C := (norm_nonneg (φ 0)).trans (hC 0) + have hΞ : ∀ P a, |Ξ P a|≤M := extension_bounded _ _ _ _ _ F hM hbound + let d (i : I) (a : A) : ℝ := ∑ k : s, ∫ z, + -(φ (form (B u i) (split θ)+B u i z-(k:ℤ)*τ/pivot u i)* + jump (B u) q Ξ (split θ) i k z a) ∂law ψ volume + refine ⟨fun i a => (pivot u i)⁻¹*d i a,?_,?_⟩ + · intro a + have hd := convolution_derivative (B u) hBij q hq (fun P => Ξ P a) hM hC0 (fun P => hΞ P a) + hiφ hcφ hC hcψ.continuous.measurable hnψ hiψ hψ1 (split θ) + have he : convolution (ProductMollifier.kernel (m := m+1) φ) (chartFunction u τ s U F a) + (ContinuousLinearMap.mul ℝ ℝ) volume = + (convolution (fun p : ℝ × Z => φ p.1*ψ p.2) (cell (B u) q (fun P => Ξ P a)) + (ContinuousLinearMap.mul ℝ ℝ) volume) ∘ split := by + funext x + rw [chartFunction,convolution_split,kernel_split] + rfl + rw [he] + have hd' : HasFDerivAt + (convolution (fun p : ℝ × Z => φ p.1*ψ p.2) (cell (B u) q (fun P => Ξ P a)) + (ContinuousLinearMap.mul ℝ ℝ) volume) + (∑ i, d i a • form (B u i)) (split θ) := by + simpa only [d,jump,q,sub_eq_add_neg] using hd + have ht := derivative_transport _ _ θ hd' + have hL : (∑ i, d i a • form (B u i)).comp split.toContinuousLinearMap = + ∑ i, ((pivot u i)⁻¹*d i a) • InnerProductSpace.toDual ℝ E (u i) := by + ext x + simp only [ContinuousLinearMap.comp_apply,_root_.sum_apply,_root_.smul_apply,smul_eq_mul] + apply Finset.sum_congr rfl + intro i _ + have hi := congrArg (fun L : E →L[ℝ] ℝ => L x) (form_comp (u i) (hu i)) + change form (B u i) (split x)=(pivot u i)⁻¹*inner ℝ (u i) x at hi + change d i a * form (B u i) (split x)=((pivot u i)⁻¹*d i a)*inner ℝ (u i) x + rw [hi] + ring + rw [hL] at ht + exact ht + · intro i + have hj := actual_jump_budget (B u) hBij (pivot u) hu hτ s hU hb F hF φ ψ (split θ) i (by + filter_upwards [hsupp] with z hz k hk + exact hz _ (ProductMollifier.density_support hlam hk)) + have hh := common_coefficient_budget (B u) s (pivot u) hu hτ Ξ hM hC0 hJ hΞ + hdφ hnφ hiφ hiφ' (ProductMollifier.density_integral hlam) hC + hcψ.continuous.measurable hnψ hiψ hψ1 (split θ) i hj (by + rw [ProductMollifier.density_deriv_integral hlam] + exact hsmall i) + exact hh +end +end UniformSparsestCut.EuclideanCells + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SparsestCut/FiniteDuality.lean b/lean/OAI/Combinatorics/SparsestCut/FiniteDuality.lean new file mode 100644 index 0000000000000000000000000000000000000000..d0cba7910d9abff1722f8471965e2b69c1613179 --- /dev/null +++ b/lean/OAI/Combinatorics/SparsestCut/FiniteDuality.lean @@ -0,0 +1,214 @@ +import OAI.Combinatorics.SparsestCut.Model + +namespace OAI + +universe u1 u2 + +open scoped BigOperators Topology NNReal RealInnerProductSpace InnerProductSpace Matrix ContDiff ENNReal +open MeasureTheory ProbabilityTheory Set Filter Matrix + +noncomputable section + +namespace UniformSparsestCut + +namespace FiniteDuality + +variable {E : Type u1} {K : Type u2} [Fintype E] [Fintype K] + +def packingCone (A : E → K → ℝ) (w : K → ℝ) : Set ((E → ℝ) × ℝ) := + {y | ∃ t : K → ℝ, (∀ k, 0 ≤ t k) ∧ + (∀ e, ∑ k, A e k * t k ≤ y.1 e) ∧ y.2 ≤ ∑ k, w k * t k} + +lemma packingCone_closed (A : E → K → ℝ) (w : K → ℝ) + (hA : ∀ e k, 0 ≤ A e k) (hcol : ∀ k, 0 < ∑ e, A e k) : + IsClosed (packingCone A w) := by + classical + apply isSeqClosed_iff_isClosed.mp + intro y b hy hyb + choose t ht0 htA htw using hy + have hsum : Tendsto (fun n => ∑ e, (y n).1 e) atTop (𝓝 (∑ e, b.1 e)) := + tendsto_finsetSum _ (fun e he => (tendsto_pi_nhds.mp hyb.fst_nhds) e) + obtain ⟨B, hB⟩ := hsum.bddAbove_range + have hbound (n : ℕ) (k : K) : t n k ≤ B / (∑ e, A e k) := by + apply (le_div_iff₀ (hcol k)).mpr + calc + t n k * ∑ e, A e k = ∑ e, A e k * t n k := by + rw [Finset.mul_sum]; apply Finset.sum_congr rfl; intros; ring + _ ≤ ∑ e, ∑ j, A e j * t n j := by + apply Finset.sum_le_sum + intro e he + exact Finset.single_le_sum (fun j hj => mul_nonneg (hA e j) (ht0 n j)) + (Finset.mem_univ k) + _ ≤ ∑ e, (y n).1 e := Finset.sum_le_sum (fun e he => htA n e) + _ ≤ B := hB (Set.mem_range_self n) + obtain ⟨u, hu, φ, hφ, htend⟩ := + (isCompact_Icc : IsCompact (Icc (0 : K → ℝ) (fun k => B / (∑ e, A e k)))).tendsto_subseq + (fun n => ⟨ht0 n, hbound n⟩) + refine ⟨u, hu.1, ?_, ?_⟩ + · intro e + apply le_of_tendsto_of_tendsto + (tendsto_finsetSum _ (fun k hk => + tendsto_const_nhds.mul ((tendsto_pi_nhds.mp htend) k))) + (((tendsto_pi_nhds.mp hyb.fst_nhds) e).comp hφ.tendsto_atTop) + exact Eventually.of_forall (fun n => htA (φ n) e) + · apply le_of_tendsto_of_tendsto (hyb.snd_nhds.comp hφ.tendsto_atTop) + (tendsto_finsetSum _ (fun k hk => + tendsto_const_nhds.mul ((tendsto_pi_nhds.mp htend) k))) + exact Eventually.of_forall (fun n => htw (φ n)) + +noncomputable def packingProperCone (A : E → K → ℝ) (w : K → ℝ) + (hA : ∀ e k, 0 ≤ A e k) (hcol : ∀ k, 0 < ∑ e, A e k) : + ProperCone ℝ ((E → ℝ) × ℝ) where + carrier := packingCone A w + zero_mem' := by + refine ⟨0, by simp, ?_, ?_⟩ <;> simp + add_mem' := by + rintro x y ⟨s, hs0, hsA, hsw⟩ ⟨t, ht0, htA, htw⟩ + refine ⟨s+t, fun k => add_nonneg (hs0 k) (ht0 k), ?_, ?_⟩ + · intro e + simpa [mul_add, Finset.sum_add_distrib] using add_le_add (hsA e) (htA e) + · simpa [mul_add, Finset.sum_add_distrib] using add_le_add hsw htw + smul_mem' := by + rintro ⟨a, ha⟩ x ⟨t, ht0, htA, htw⟩ + refine ⟨a • t, fun k => mul_nonneg ha (ht0 k), ?_, ?_⟩ + · intro e + change (∑ k, A e k * (a * t k)) ≤ a * x.1 e + simpa [← Finset.mul_sum, mul_left_comm] using + mul_le_mul_of_nonneg_left (htA e) ha + · change a * x.2 ≤ ∑ k, w k * (a * t k) + simpa [← Finset.mul_sum, mul_left_comm] using + mul_le_mul_of_nonneg_left htw ha + isClosed' := packingCone_closed A w hA hcol + +lemma dual_functional (f : ((E → ℝ) × ℝ) →L[ℝ] ℝ) : + ∃ c : E → ℝ, ∃ q : ℝ, ∀ x : (E → ℝ) × ℝ, + f x = (∑ e, c e * x.1 e) + q * x.2 := by + classical + refine ⟨fun e => f (Pi.single e 1, 0), f (0, 1), ?_⟩ + rintro ⟨x,y⟩ + have heq : (x,y) = (∑ e, x e • (Pi.single e 1, (0 : ℝ))) + y • (0, (1 : ℝ)) := by + ext e <;> simp [Prod.fst_sum, Prod.snd_sum, ← Pi.single_smul, + Finset.univ_sum_single] + calc + f (x,y) = f ((∑ e, x e • (Pi.single e 1, (0 : ℝ))) + y • (0, (1 : ℝ))) := + congrArg f heq + _ = (∑ e, f (Pi.single e 1, 0) * x e) + f (0, 1) * y := by + simp only [map_add, map_sum, map_smul, smul_eq_mul, mul_comm] + +theorem packing_duality_strict (A : E → K → ℝ) (w : K → ℝ) + (hA : ∀ e k, 0 ≤ A e k) (hcol : ∀ k, 0 < ∑ e, A e k) + (d : E → ℝ) (hd : ∀ e, 0 ≤ d e) {β : ℝ} (hβ : 0 < β) + (hbound : ∀ t : K → ℝ, (∀ k, 0 ≤ t k) → + (∀ e, ∑ k, A e k * t k ≤ d e) → (∑ k, w k * t k) < β) : + ∃ c : E → ℝ, (∀ e, 0 ≤ c e) ∧ + (∀ k, w k ≤ ∑ e, A e k * c e) ∧ (∑ e, c e * d e) < β := by + classical + let C := packingProperCone A w hA hcol + have hnot : (d,β) ∉ C := by + rintro ⟨t, ht0, htA, htw⟩ + exact (hbound t ht0 htA).not_ge htw + obtain ⟨f, hf, hfb⟩ := C.hyperplane_separation_point hnot + obtain ⟨c,q,hform⟩ := dual_functional f + have hc (e : E) : 0 ≤ c e := by + have hx : (Pi.single e 1, (0 : ℝ)) ∈ C := by + refine ⟨0, by simp, ?_, ?_⟩ + · intro j; simp only [Pi.zero_apply, mul_zero, Finset.sum_const_zero] + simp [Pi.single_apply]; split_ifs <;> norm_num + · simp + simpa [hform, Pi.single_apply, mul_ite] using hf _ hx + have hq : q < 0 := by + rw [hform] at hfb + have hcd : 0 ≤ ∑ e, c e * d e := + Finset.sum_nonneg (fun e he => mul_nonneg (hc e) (hd e)) + nlinarith + have hcoldual (k : K) : 0 ≤ (∑ e, c e * A e k) + q * w k := by + have hx : ((fun e => A e k), w k) ∈ C := by + refine ⟨Pi.single k 1, ?_, ?_, ?_⟩ + · intro j; simp [Pi.single_apply]; split_ifs <;> norm_num + · intro e; simp [Pi.single_apply, mul_ite] + · simp [Pi.single_apply, mul_ite] + simpa [hform, Pi.single_apply, mul_ite] using hf _ hx + refine ⟨fun e => c e / (-q), fun e => div_nonneg (hc e) (neg_pos.mpr hq).le, ?_, ?_⟩ + · intro k + simp only [← mul_div_assoc, ← Finset.sum_div] + apply (le_div_iff₀ (neg_pos.mpr hq)).mpr + have := hcoldual k + have hsum : (∑ e, A e k * c e) = ∑ e, c e * A e k := by + apply Finset.sum_congr rfl; intros; ring + rw [hsum] + nlinarith + · simp only [div_mul_eq_mul_div, ← Finset.sum_div] + apply (div_lt_iff₀ (neg_pos.mpr hq)).mpr + rw [hform] at hfb + nlinarith + +omit [Fintype K] in + +lemma cap_covering (A : E → K → ℝ) (w : K → ℝ) + (hA : ∀ e k, A e k = 0 ∨ A e k = 1) {W : ℝ} (hW : 0 ≤ W) + (hw : ∀ k, w k ≤ W) (c : E → ℝ) (hc : ∀ e, 0 ≤ c e) + (hcover : ∀ k, w k ≤ ∑ e, A e k * c e) : + ∀ k, w k ≤ ∑ e, A e k * min (c e) W := by + classical + intro k + by_cases hb : ∃ e, A e k = 1 ∧ W < c e + · obtain ⟨e, he, hce⟩ := hb + calc + w k ≤ W := hw k + _ = A e k * min (c e) W := by rw [he, min_eq_right hce.le]; ring + _ ≤ ∑ j, A j k * min (c j) W := + Finset.single_le_sum (fun j hj => mul_nonneg + (show 0 ≤ A j k from by rcases hA j k with h | h <;> rw [h] ; norm_num) + (le_min (hc j) hW)) (Finset.mem_univ e) + · convert hcover k using 1 + apply Finset.sum_congr rfl + intro e he + rcases hA e k with hz | ho + · simp [hz] + · have hcW : c e ≤ W := le_of_not_gt (fun h => hb ⟨e, ho, h⟩) + rw [min_eq_left hcW] + +theorem packing_duality (A : E → K → ℝ) (w : K → ℝ) + (hA : ∀ e k, A e k = 0 ∨ A e k = 1) (hcol : ∀ k, 0 < ∑ e, A e k) + (d : E → ℝ) (hd : ∀ e, 0 ≤ d e) {β W : ℝ} (hβ : 0 ≤ β) (hW : 0 ≤ W) + (hw : ∀ k, w k ≤ W) + (hbound : ∀ t : K → ℝ, (∀ k, 0 ≤ t k) → + (∀ e, ∑ k, A e k * t k ≤ d e) → (∑ k, w k * t k) ≤ β) : + ∃ c : E → ℝ, (∀ e, 0 ≤ c e) ∧ + (∀ k, w k ≤ ∑ e, A e k * c e) ∧ (∑ e, c e * d e) ≤ β := by + classical + have hA0 : ∀ e k, 0 ≤ A e k := by + intro e k; rcases hA e k with h | h <;> rw [h] ; norm_num + let T : Set (E → ℝ) := Icc 0 (fun _ => W) ∩ {c | ∀ k, w k ≤ ∑ e, A e k * c e} + have hTc : IsCompact T := by + refine isCompact_Icc.inter_right ?_ + simp only [ofPred_forall] + apply isClosed_iInter + intro k + apply isClosed_le continuous_const + exact continuous_finsetSum _ (fun e he => continuous_const.mul (continuous_apply e)) + have hcapped : ∀ γ, β < γ → ∃ c ∈ T, (∑ e, c e * d e) < γ := by + intro γ hγ + obtain ⟨c, hc0, hcA, hcd⟩ := packing_duality_strict A w hA0 hcol d hd + (hβ.trans_lt hγ) (fun t ht htA => (hbound t ht htA).trans_lt hγ) + refine ⟨fun e => min (c e) W, ⟨⟨?_, ?_⟩, cap_covering A w hA hW hw c hc0 hcA⟩, ?_⟩ + · exact fun e => le_min (hc0 e) hW + · exact fun e => min_le_right _ _ + · exact lt_of_le_of_lt (Finset.sum_le_sum (fun e he => + mul_le_mul_of_nonneg_right (min_le_left _ _) (hd e))) hcd + obtain ⟨c0, hc0, _⟩ := hcapped (β+1) (by linarith) + have hobj : Continuous (fun c : E → ℝ => ∑ e, c e * d e) := + continuous_finsetSum _ (fun e he => (continuous_apply e).mul continuous_const) + obtain ⟨c, hc, hmin⟩ := hTc.exists_isMinOn ⟨c0,hc0⟩ hobj.continuousOn + refine ⟨c, hc.1.1, hc.2, ?_⟩ + by_contra! hstrict + obtain ⟨c', hc', hlt⟩ := hcapped (∑ e, c e * d e) hstrict + exact hlt.not_ge (hmin hc') + +end FiniteDuality + +end UniformSparsestCut + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SparsestCut/FiniteGraph.lean b/lean/OAI/Combinatorics/SparsestCut/FiniteGraph.lean new file mode 100644 index 0000000000000000000000000000000000000000..237978967c37215c74c3af633c8db357d22bc450 --- /dev/null +++ b/lean/OAI/Combinatorics/SparsestCut/FiniteGraph.lean @@ -0,0 +1,128 @@ +import Mathlib.Algebra.Order.BigOperators.Group.Finset +import Mathlib.Algebra.Order.Field.Rat +import Mathlib.Data.Finset.Max +import Mathlib.Data.Fintype.Powerset +import Mathlib.Tactic.Positivity + +namespace OAI + +/-! +# Finite uniform sparsest cut + +The rational-capacity objective and its unit-demand denominator follow the introduction of +*Constant-factor hardness of uniform sparsest cut* by OpenAI. +-/ + +open scoped BigOperators + +namespace UniformSparsestCut + + +/-- An undirected rational-capacity graph. Zero capacities encode absent edges. +There are no input demand weights: all distinct pairs have demand one. -/ +structure Graph where + n : ℕ + two_le : 2 ≤ n + capacity : Fin n → Fin n → ℚ + nonnegative : ∀ i j, 0 ≤ capacity i j + symmetric : ∀ i j, capacity i j = capacity j i + diagonal : ∀ i, capacity i i = 0 + +/-- Demand is fixed, not chosen by the reduction. -/ +def Graph.demand (G : Graph) (i j : Fin G.n) : ℕ := if i = j then 0 else 1 + +@[simp] theorem Graph.demand_self (G : Graph) (i : Fin G.n) : G.demand i i = 0 := by + simp [Graph.demand] + +theorem Graph.demand_of_ne (G : Graph) {i j : Fin G.n} (h : i ≠ j) : + G.demand i j = 1 := by + simp [Graph.demand, h] + +/-- A nonempty proper subset of the vertices. -/ +def IsCut {n : ℕ} (S : Finset (Fin n)) : Prop := 0 < S.card ∧ S.card < n + +instance {n : ℕ} (S : Finset (Fin n)) : Decidable (IsCut S) := + inferInstanceAs (Decidable (0 < S.card ∧ S.card < n)) + +def cuts (n : ℕ) : Finset (Finset (Fin n)) := Finset.univ.filter IsCut + +@[simp] theorem mem_cuts {n : ℕ} {S : Finset (Fin n)} : S ∈ cuts n ↔ IsCut S := by + simp [cuts] + +theorem cuts_nonempty (G : Graph) : (cuts G.n).Nonempty := by + have hn : 0 < G.n := lt_of_lt_of_le (by decide : 0 < 2) G.two_le + refine ⟨{⟨0, hn⟩}, mem_cuts.mpr ?_⟩ + simpa [IsCut] using (show 0 < 1 ∧ 1 < G.n from ⟨by decide, by have := G.two_le; omega⟩) + +/-- Each unordered separated pair occurs once, with its endpoint in `S` first. -/ +def Graph.cutCapacity (G : Graph) (S : Finset (Fin G.n)) : ℚ := + ∑ i ∈ S, ∑ j ∈ Finset.univ \ S, G.capacity i j + +def Graph.cutRatio (G : Graph) (S : Finset (Fin G.n)) : ℚ := + G.cutCapacity S / ((S.card : ℚ) * (G.n - S.card : ℕ)) + +/-- The actual minimum over all nonempty proper cuts, not a relaxation. -/ +def Graph.phi (G : Graph) : ℚ := + ((cuts G.n).image G.cutRatio).min' ((cuts_nonempty G).image _) + +theorem cut_card_le (G : Graph) (S : Finset (Fin G.n)) : S.card ≤ G.n := by + simpa using Finset.card_le_card (Finset.subset_univ S) + +theorem cut_denominator_pos (G : Graph) {S : Finset (Fin G.n)} (hS : IsCut S) : + (0 : ℚ) < (S.card : ℚ) * (G.n - S.card : ℕ) := by + exact mul_pos (Nat.cast_pos.mpr hS.1) (Nat.cast_pos.mpr (Nat.sub_pos_of_lt hS.2)) + +theorem Graph.cutCapacity_nonneg (G : Graph) (S : Finset (Fin G.n)) : + 0 ≤ G.cutCapacity S := by + exact Finset.sum_nonneg (fun i _ => Finset.sum_nonneg (fun j _ => G.nonnegative i j)) + +theorem Graph.cutRatio_nonneg (G : Graph) (S : Finset (Fin G.n)) : + 0 ≤ G.cutRatio S := by + exact div_nonneg (G.cutCapacity_nonneg S) (by positivity) + +theorem Graph.phi_le_cutRatio (G : Graph) {S : Finset (Fin G.n)} (hS : IsCut S) : + G.phi ≤ G.cutRatio S := by + exact Finset.min'_le _ _ (Finset.mem_image.mpr ⟨S, mem_cuts.mpr hS, rfl⟩) + +theorem Graph.exists_minimizing_cut (G : Graph) : + ∃ S : Finset (Fin G.n), IsCut S ∧ G.cutRatio S = G.phi := by + obtain ⟨S, hS, hv⟩ := Finset.mem_image.mp + (Finset.min'_mem ((cuts G.n).image G.cutRatio) ((cuts_nonempty G).image _)) + exact ⟨S, mem_cuts.mp hS, hv⟩ + +theorem Graph.phi_nonneg (G : Graph) : 0 ≤ G.phi := by + obtain ⟨S, _, hS⟩ := G.exists_minimizing_cut + rw [← hS] + exact G.cutRatio_nonneg S + +/-- In particular, strict soundness for every cut implies strict soundness for the minimum. -/ +theorem Graph.lt_phi_iff (G : Graph) (r : ℚ) : + r < G.phi ↔ ∀ S : Finset (Fin G.n), IsCut S → r < G.cutRatio S := by + constructor + · intro hr S hS + exact hr.trans_le (G.phi_le_cutRatio hS) + · intro h + obtain ⟨S, hS, heq⟩ := G.exists_minimizing_cut + simpa [heq] using h S hS + +/-- Summing the exactly-unit demands gives precisely the denominator in the source. -/ +theorem Graph.separated_demand (G : Graph) (S : Finset (Fin G.n)) : + (∑ i ∈ S, ∑ j ∈ Finset.univ \ S, G.demand i j) = S.card * (G.n - S.card) := by + have hne (i : Fin G.n) (hi : i ∈ S) (j : Fin G.n) (hj : j ∈ Finset.univ \ S) : + i ≠ j := by + intro hij + exact (Finset.mem_sdiff.mp hj).2 (hij ▸ hi) + have hc : (Finset.univ \ S).card = G.n - S.card := by + simp [Finset.card_sdiff] + calc + _ = ∑ _i ∈ S, ∑ _j ∈ Finset.univ \ S, (1 : ℕ) := by + apply Finset.sum_congr rfl + intro i hi + apply Finset.sum_congr rfl + intro j hj + exact G.demand_of_ne (hne i hi j hj) + _ = _ := by simp [hc] + +end UniformSparsestCut + +end OAI diff --git a/lean/OAI/Combinatorics/SparsestCut/FiniteNets.lean b/lean/OAI/Combinatorics/SparsestCut/FiniteNets.lean new file mode 100644 index 0000000000000000000000000000000000000000..271946e548dfb3b705c9915dc31f31dfe1926a3a --- /dev/null +++ b/lean/OAI/Combinatorics/SparsestCut/FiniteNets.lean @@ -0,0 +1,122 @@ +import OAI.Combinatorics.SparsestCut.GaussianTools + +namespace OAI + +universe u1 + +open scoped BigOperators Topology NNReal RealInnerProductSpace InnerProductSpace Matrix ContDiff ENNReal +open MeasureTheory ProbabilityTheory Set Filter Matrix + +noncomputable section + +namespace UniformSparsestCut.FiniteNets + +lemma euclidean_norm_le_sum_abs {n : ℕ} (x : EuclideanSpace ℝ (Fin n)) : + ‖x‖ ≤ ∑ i, |x i| := by + classical + have heq : x = ∑ i : Fin n, (PiLp.single 2 i (x i) : EuclideanSpace ℝ (Fin n)) := by + ext j + simp + calc + _ = ‖∑ i : Fin n, (PiLp.single 2 i (x i) : EuclideanSpace ℝ (Fin n))‖ := congrArg norm heq + _ ≤ ∑ i : Fin n, ‖(PiLp.single 2 i (x i) : EuclideanSpace ℝ (Fin n))‖ := norm_sum_le _ _ + _ = _ := by simp [PiLp.norm_single, Real.norm_eq_abs] + +lemma floor_coordinate_bound {n K : ℕ} {δ : ℝ} (hδ : 0 < δ) + {x : EuclideanSpace ℝ (Fin n)} (hx : ‖x‖ ≤ (K : ℝ) * δ) (i : Fin n) : + ⌊x i / δ⌋ ∈ Finset.Icc (-(K : ℤ)) (K : ℤ) := by + have hcoord : |x i| ≤ ‖x‖ := by simpa using PiLp.norm_apply_le x i + have hi : |x i| ≤ (K : ℝ) * δ := hcoord.trans hx + rw [Finset.mem_Icc] + constructor + · apply Int.le_floor.mpr + push_cast + apply (le_div_iff₀ hδ).mpr + linarith [neg_abs_le (x i)] + · have hh : x i / δ ≤ (K : ℝ) := (div_le_iff₀ hδ).mpr ((le_abs_self _).trans hi) + have h := Int.floor_mono hh + simpa using h + +lemma same_floor_distance {n : ℕ} {δ : ℝ} (hδ : 0 < δ) + {x y : EuclideanSpace ℝ (Fin n)} (hxy : ∀ i, ⌊x i / δ⌋ = ⌊y i / δ⌋) : + ‖x - y‖ ≤ (n : ℝ) * δ := by + have hc (i : Fin n) : |x i - y i| ≤ δ := by + have hx1 := Int.floor_le (x i / δ) + have hx2 := Int.lt_floor_add_one (x i / δ) + have hy1 := Int.floor_le (y i / δ) + have hy2 := Int.lt_floor_add_one (y i / δ) + rw [hxy i] at hx1 hx2 + apply abs_le.mpr + constructor + · have hh : -1 ≤ (x i - y i) / δ := by rw [sub_div]; linarith + have := (le_div_iff₀ hδ).mp hh + linarith + · have hh : (x i - y i) / δ ≤ 1 := by rw [sub_div]; linarith + have := (div_le_iff₀ hδ).mp hh + linarith + calc + ‖x-y‖ ≤ ∑ i, |(x-y) i| := euclidean_norm_le_sum_abs _ + _ ≤ ∑ _ : Fin n, δ := Finset.sum_le_sum (fun i _ => hc i) + _ = _ := by simp + +theorem exists_coordinate_net {n K : ℕ} {δ : ℝ} (hδ : 0 < δ) + (A : Set (EuclideanSpace ℝ (Fin n))) + (hA : ∀ x ∈ A, ‖x‖ ≤ (K : ℝ) * δ) : + ∃ V : Finset (EuclideanSpace ℝ (Fin n)), + (∀ v ∈ V, v ∈ A) ∧ V.card ≤ (2*K+1)^n ∧ + ∀ x ∈ A, ∃ v ∈ V, ‖x-v‖ ≤ (n : ℝ)*δ := by + classical + let G := Fin n → ↥(Finset.Icc (-(K : ℤ)) (K : ℤ)) + let represented : G → Prop := fun g => ∃ x ∈ A, ∀ i, ⌊x i / δ⌋ = (g i).val + let point : G → EuclideanSpace ℝ (Fin n) := fun g => + if h : represented g then h.choose else 0 + have hpoint (g : G) (hg : represented g) : + point g ∈ A ∧ ∀ i, ⌊point g i / δ⌋ = (g i).val := by + simpa [point, hg] using hg.choose_spec + let V := (Finset.univ.filter represented).image point + refine ⟨V, ?_, ?_, ?_⟩ + · intro v hv + obtain ⟨g, hg, rfl⟩ := Finset.mem_image.mp hv + exact (hpoint g (Finset.mem_filter.mp hg).2).1 + · calc + V.card ≤ (Finset.univ.filter represented).card := Finset.card_image_le + _ ≤ Fintype.card G := (Finset.card_filter_le _ _).trans_eq (Finset.card_univ) + _ = (2*K+1)^n := by + simp only [G, Fintype.card_fun, Fintype.card_coe, Int.card_Icc, Fintype.card_fin] + congr 1 + omega + · intro x hx + let g : G := fun i => ⟨⌊x i / δ⌋, floor_coordinate_bound hδ (hA x hx) i⟩ + have hg : represented g := ⟨x, hx, fun _ => rfl⟩ + refine ⟨point g, Finset.mem_image.mpr ⟨g, Finset.mem_filter.mpr ⟨Finset.mem_univ _, hg⟩, rfl⟩, ?_⟩ + exact same_floor_distance hδ (fun i => ((hpoint g hg).2 i).symm) + +lemma sphere_net_norm_bound {E : Type u1} [NormedAddCommGroup E] [InnerProductSpace ℝ E] + {V : Finset E} {ρ B : ℝ} + (hnet : ∀ x : E, ‖x‖ = 1 → ∃ v ∈ V, ‖x-v‖ ≤ ρ) + {z : E} (hz : ∀ v ∈ V, |inner ℝ z v| ≤ B) (hB : 0 ≤ B) : + (1-ρ)*‖z‖ ≤ B := by + by_cases hzero : z = 0 + · simpa [hzero] using hB + have hn : 0 < ‖z‖ := norm_pos_iff.mpr hzero + let x := ‖z‖⁻¹ • z + have hx : ‖x‖ = 1 := by simp [x, norm_smul, hn.ne'] + obtain ⟨v, hv, hdist⟩ := hnet x hx + have hinner : inner ℝ z x = ‖z‖ := by + simp [x, inner_smul_right, sq, hn.ne'] + have heq : inner ℝ z x = inner ℝ z v + inner ℝ z (x-v) := by + rw [inner_sub_right] + ring + have hbound : ‖z‖ ≤ B + ‖z‖ * ρ := by + calc + ‖z‖ = |inner ℝ z x| := by rw [hinner, abs_of_nonneg (norm_nonneg _)] + _ ≤ |inner ℝ z v| + |inner ℝ z (x-v)| := by rw [heq]; exact abs_add_le _ _ + _ ≤ B + ‖z‖ * ρ := add_le_add (hz v hv) + ((abs_real_inner_le_norm _ _).trans (mul_le_mul_of_nonneg_left hdist (norm_nonneg _))) + nlinarith + +end UniformSparsestCut.FiniteNets + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SparsestCut/FiniteWeights.lean b/lean/OAI/Combinatorics/SparsestCut/FiniteWeights.lean new file mode 100644 index 0000000000000000000000000000000000000000..2d0ede8fe5f0f46d4b05cc93e482c605b4b47271 --- /dev/null +++ b/lean/OAI/Combinatorics/SparsestCut/FiniteWeights.lean @@ -0,0 +1,168 @@ +/- +Copyright (c) 2026 OpenAI. All rights reserved. +Authors: OpenAI +-/ +import Mathlib.Algebra.Order.BigOperators.Ring.Finset +import Mathlib.Basic.Real.Basic +import Mathlib.Tactic.Linarith + +namespace OAI + +/-! +# Finite Boolean weights and variances + +Finite weighted laws support Boolean event masses, complementary masses, and the disagreement +of independent draws. The variance estimates give scalar ingredients for the finite graph +construction in Section 7 of *Constant-factor hardness of uniform sparsest cut*. +-/ + +open scoped BigOperators + +namespace UniformSparsestCut.FiniteWeights + +variable {ι : Type*} [Fintype ι] + +def indicator (b : Bool) : ℝ := if b then 1 else 0 + +def disagree (b c : Bool) : ℝ := if b = c then 0 else 1 + +def total (w : ι → ℝ) : ℝ := ∑ i, w i + +def mass (w : ι → ℝ) (h : ι → Bool) : ℝ := ∑ i, w i * indicator (h i) + +def variance (w : ι → ℝ) (h : ι → Bool) : ℝ := mass w h * (1 - mass w h) + +/-- The weight of a disagreement for two independent draws (not necessarily normalized). -/ +def disagreement (w u : ι → ℝ) (h : ι → Bool) : ℝ := + ∑ i, w i * ∑ j, u j * disagree (h i) (h j) + +theorem indicator_nonneg (b : Bool) : 0 ≤ indicator b := by + cases b <;> simp [indicator] + +theorem indicator_le_one (b : Bool) : indicator b ≤ 1 := by + cases b <;> simp [indicator] + +theorem indicator_not (b : Bool) : indicator (!b) = 1 - indicator b := by + cases b <;> simp [indicator] + +theorem disagree_nonneg (b c : Bool) : 0 ≤ disagree b c := by + cases b <;> cases c <;> simp [disagree] + +theorem disagree_eq (b c : Bool) : + disagree b c = indicator b * (1 - indicator c) + (1 - indicator b) * indicator c := by + cases b <;> cases c <;> simp [disagree, indicator] + +theorem total_nonneg {w : ι → ℝ} (hw : ∀ i, 0 ≤ w i) : 0 ≤ total w := + Finset.sum_nonneg (fun i _ => hw i) + +theorem total_mono {w u : ι → ℝ} (hwu : ∀ i, w i ≤ u i) : total w ≤ total u := + Finset.sum_le_sum (fun i _ => hwu i) + +theorem total_add (w u : ι → ℝ) : total (fun i => w i + u i) = total w + total u := by + simp [total, Finset.sum_add_distrib] + +theorem total_smul (a : ℝ) (w : ι → ℝ) : total (fun i => a * w i) = a * total w := by + simp [total, Finset.mul_sum] + +theorem mass_nonneg {w : ι → ℝ} (hw : ∀ i, 0 ≤ w i) (h : ι → Bool) : 0 ≤ mass w h := + Finset.sum_nonneg (fun i _ => mul_nonneg (hw i) (indicator_nonneg (h i))) + +theorem mass_le_total {w : ι → ℝ} (hw : ∀ i, 0 ≤ w i) (h : ι → Bool) : + mass w h ≤ total w := by + apply Finset.sum_le_sum + intro i _ + simpa using mul_le_mul_of_nonneg_left (indicator_le_one (h i)) (hw i) + +theorem mass_mono {w u : ι → ℝ} (hwu : ∀ i, w i ≤ u i) (h : ι → Bool) : + mass w h ≤ mass u h := by + exact Finset.sum_le_sum (fun i _ => + mul_le_mul_of_nonneg_right (hwu i) (indicator_nonneg (h i))) + +theorem mass_add (w u : ι → ℝ) (h : ι → Bool) : + mass (fun i => w i + u i) h = mass w h + mass u h := by + simp [mass, add_mul, Finset.sum_add_distrib] + +theorem mass_smul (a : ℝ) (w : ι → ℝ) (h : ι → Bool) : + mass (fun i => a * w i) h = a * mass w h := by + simp [mass, mul_assoc, Finset.mul_sum] + +theorem mass_compl (w : ι → ℝ) (h : ι → Bool) : + mass w (fun i => !(h i)) = total w - mass w h := by + simp [mass, indicator_not, mul_sub, Finset.sum_sub_distrib, total] + +theorem variance_nonneg {w : ι → ℝ} (hw : ∀ i, 0 ≤ w i) (hw₁ : total w = 1) + (h : ι → Bool) : 0 ≤ variance w h := by + exact mul_nonneg (mass_nonneg hw h) (sub_nonneg.mpr (hw₁ ▸ mass_le_total hw h)) + +theorem inner_disagreement (u : ι → ℝ) (h : ι → Bool) (b : Bool) : + (∑ j, u j * disagree b (h j)) = + indicator b * (total u - mass u h) + (1 - indicator b) * mass u h := by + calc + _ = ∑ j, (indicator b * (u j - u j * indicator (h j)) + + (1 - indicator b) * (u j * indicator (h j))) := by + apply Finset.sum_congr rfl + intro j _ + rw [disagree_eq] + ring + _ = _ := by + simp only [Finset.sum_add_distrib, ← Finset.mul_sum, Finset.sum_sub_distrib, + total, mass] + +theorem disagreement_eq (w u : ι → ℝ) (h : ι → Bool) : + disagreement w u h = mass w h * (total u - mass u h) + + (total w - mass w h) * mass u h := by + unfold disagreement + simp_rw [inner_disagreement] + calc + _ = ∑ i, ((w i * indicator (h i)) * (total u - mass u h) + + (w i - w i * indicator (h i)) * mass u h) := by + apply Finset.sum_congr rfl + intro i _ + ring + _ = _ := by + simp only [Finset.sum_add_distrib, ← Finset.sum_mul, Finset.sum_sub_distrib, + total, mass] + +theorem disagreement_self (w : ι → ℝ) (hw : total w = 1) (h : ι → Bool) : + disagreement w w h = 2 * variance w h := by + rw [disagreement_eq, hw] + unfold variance + ring + +theorem disagreement_nonneg {w u : ι → ℝ} (hw : ∀ i, 0 ≤ w i) + (hu : ∀ i, 0 ≤ u i) (h : ι → Bool) : 0 ≤ disagreement w u h := by + unfold disagreement + exact Finset.sum_nonneg (fun i _ => mul_nonneg (hw i) + (Finset.sum_nonneg (fun j _ => mul_nonneg (hu j) (disagree_nonneg _ _)))) + +/-- Product domination: the constant is squared, since the two draws are independent. -/ +theorem variance_domination {w u : ι → ℝ} {A : ℝ} + (hw : ∀ i, 0 ≤ w i) (hu : ∀ i, 0 ≤ u i) + (hw₁ : total w = 1) (hu₁ : total u = 1) (hA : 0 ≤ A) + (hdom : ∀ i, w i ≤ A * u i) (h : ι → Bool) : + variance w h ≤ A ^ 2 * variance u h := by + have hm : mass w h ≤ A * mass u h := by + simpa [mass_smul] using mass_mono hdom h + have hc : 1 - mass w h ≤ A * (1 - mass u h) := by + simpa [mass_smul, mass_compl, total_smul, hw₁, hu₁, mul_sub] using + mass_mono hdom (fun i => !(h i)) + have hc₀ : 0 ≤ 1 - mass w h := sub_nonneg.mpr (hw₁ ▸ mass_le_total hw h) + have hm₀ : 0 ≤ A * mass u h := mul_nonneg hA (mass_nonneg hu h) + have hh := mul_le_mul hm hc hc₀ hm₀ + unfold variance + nlinarith only [hh] + +/-- A change of color with probability at most `L` changes Boolean variance by at most `L`. +This scalar estimate also follows by coupling two independent draws and a union bound. -/ +theorem variance_change {z r L : ℝ} (hz₀ : 0 ≤ z) (hz₁ : z ≤ 1) + (hr₀ : 0 ≤ r) (hr₁ : r ≤ 1) (h₁ : z - r ≤ L) (h₂ : r - z ≤ L) : + z * (1 - z) ≤ r * (1 - r) + L := by + rcases le_total z r with hzr | hrz + · have hh := mul_nonneg (sub_nonneg.mpr hzr) (show 0 ≤ 2 - z - r by linarith) + nlinarith only [hh, h₂] + · have hh := mul_nonneg (sub_nonneg.mpr hrz) (add_nonneg hz₀ hr₀) + nlinarith only [hh, h₁] + +end UniformSparsestCut.FiniteWeights + +end OAI diff --git a/lean/OAI/Combinatorics/SparsestCut/GapEstimates.lean b/lean/OAI/Combinatorics/SparsestCut/GapEstimates.lean new file mode 100644 index 0000000000000000000000000000000000000000..9eff3f51dbab185d2832e8bdfe4d66edfd9f91b3 --- /dev/null +++ b/lean/OAI/Combinatorics/SparsestCut/GapEstimates.lean @@ -0,0 +1,57 @@ +import Mathlib.Basic.Real.Basic +import Mathlib.Tactic.Linarith + +namespace OAI + +/-! +# Numerical estimates for the finite sparsest-cut graph + +These are the final completeness and soundness inequalities in Section 7 of +*Constant-factor hardness of uniform sparsest cut* by OpenAI. +-/ + +namespace UniformSparsestCut + +/-- A cut of capacity at most `22` whose two sides have counting mass at least +`1 / 40000` lies below the completeness threshold. -/ +theorem completeness_ratio {N z T : ℝ} (hN : 0 < N) + (hz : (1 : ℝ) / 40000 ≤ z) (hz' : (1 : ℝ) / 40000 ≤ 1 - z) + (hT : T ≤ 22) : T / (N ^ 2 * (z * (1 - z))) < 10 ^ 12 / N ^ 2 := by + have hz₀ : 0 < z := by linarith + have hz₁ : 0 < 1 - z := by linarith + have hvar : (1 / 40000 : ℝ) ^ 2 ≤ z * (1 - z) := by + simpa only [pow_two] using + mul_le_mul hz hz' (by norm_num : (0 : ℝ) ≤ 1 / 40000) hz₀.le + have hgap : T < (10 : ℝ) ^ 12 * (z * (1 - z)) := by nlinarith + have hvpos := mul_pos hz₀ hz₁ + have hdiv : T / (z * (1 - z)) < (10 : ℝ) ^ 12 := (div_lt_iff₀ hvpos).mpr hgap + have hN₂ : 0 < N ^ 2 := sq_pos_of_pos hN + calc + _ = (T / (z * (1 - z))) / N ^ 2 := by rw [div_div, mul_comm] + _ < _ := (div_lt_div_iff_of_pos_right hN₂).mpr hdiv + +/-- Variance transfer and the tether bound contradict the comparison gap for a +nontrivial monochromatic-cluster cut. -/ +theorem soundness_contradiction {κ z ν T L D : ℝ} + (hκ : 0 < κ) (hz₀ : 0 < z) (hz₁ : z < 1) (hν : 0 ≤ ν) (hL : 0 ≤ L) + (hsmall : T ≤ κ * (z * (1 - z))) + (htether : 2 * κ * L ≤ T) (htransfer : z * (1 - z) ≤ 36 * ν + L) + (hraw : D ≤ T) (hgap : 0 < ν → 100 * κ * ν < D) : False := by + have ht : T ≤ κ * (36 * ν + L) := + hsmall.trans (mul_le_mul_of_nonneg_left htransfer hκ.le) + have ht72 : T ≤ 72 * κ * ν := by nlinarith only [ht, htether] + have hνpos : 0 < ν := by + by_contra hn + have hνzero : ν = 0 := le_antisymm (le_of_not_gt hn) hν + rw [hνzero] at ht72 htransfer + have hT : T ≤ 0 := by simpa using ht72 + have hLzero : L = 0 := by nlinarith [mul_pos hκ (show (0 : ℝ) < 2 by norm_num)] + have hvarpos : 0 < z * (1 - z) := mul_pos hz₀ (sub_pos.mpr hz₁) + nlinarith only [htransfer, hLzero, hvarpos] + have hpositive := mul_pos hκ hνpos + have hno := hgap hνpos + nlinarith only [ht72, hraw, hno, hpositive] + +end UniformSparsestCut + +end OAI diff --git a/lean/OAI/Combinatorics/SparsestCut/GapReduction.lean b/lean/OAI/Combinatorics/SparsestCut/GapReduction.lean new file mode 100644 index 0000000000000000000000000000000000000000..3f557f10867ccb9e4954e7c0735436c42d117ebc --- /dev/null +++ b/lean/OAI/Combinatorics/SparsestCut/GapReduction.lean @@ -0,0 +1,192 @@ +import OAI.Combinatorics.SparsestCut.FiniteGraph +import Mathlib.Computability.TuringMachine.Computable +import Mathlib.Data.List.OfFn +import Mathlib.Basic.Real.Basic +import Mathlib.Tactic.Linarith + +namespace OAI + +/-! +# Encodings and reductions for uniform sparsest cut + +These definitions express the polynomial-time reduction and approximation search problem in +*Constant-factor hardness of uniform sparsest cut* by OpenAI. The last semantic implication +uses rational threshold comparison. +-/ + +namespace UniformSparsestCut + +abbrev BitString := List Bool + +/-- A self-delimiting binary block: unary length, terminator, then the bits. -/ +def block (s : BitString) : BitString := List.replicate s.length true ++ false :: s + +/-- Binary, not unary, representation of a natural number, with a length prefix. -/ +def encodeNat (n : ℕ) : BitString := block (Computability.encodeNat n) + +/-- Signed numerator and positive denominator, both in binary. -/ +def encodeRat (q : ℚ) : BitString := + decide (q.num < 0) :: (encodeNat q.num.natAbs ++ encodeNat q.den) + +def encodePair (p : BitString × BitString) : BitString := block p.1 ++ p.2 + +def encodeBool (b : Bool) : BitString := [b] + +/-- A finite-stack, finite-alphabet Turing machine with a polynomial step bound. + +Mathlib's `FinTM2` only supplies alphabet finiteness for the input stack. The +extra condition here requires *every* stack alphabet to be finite. Thus one +cannot store an arbitrary natural number or a function in a single stack symbol. +-/ +def Polytime {α β : Type} (ea : α → BitString) (eb : β → BitString) + (f : α → β) : Prop := + ∃ M : Turing.TM2ComputableInPolyTime ea eb f, ∀ k, Finite (M.tm.Γ k) + +/-! ## 3CNF formulas -/ + +structure Literal where + index : ℕ + positive : Bool + deriving DecidableEq + +structure Clause where + first : Literal + second : Literal + third : Literal + deriving DecidableEq + +/-- Exactly three literals per clause; repetitions are permitted. -/ +abbrev Formula := List Clause + +def Literal.eval (v : ℕ → Bool) (l : Literal) : Bool := + if l.positive then v l.index else !(v l.index) + +def Clause.eval (v : ℕ → Bool) (c : Clause) : Bool := + c.first.eval v || c.second.eval v || c.third.eval v + +def Satisfiable (F : Formula) : Prop := + ∃ v : ℕ → Bool, ∀ c ∈ F, c.eval v = true + +def Literal.encode (l : Literal) : BitString := l.positive :: encodeNat l.index + +def Clause.encode (c : Clause) : BitString := + c.first.encode ++ c.second.encode ++ c.third.encode + +def encodeFormula (F : Formula) : BitString := + encodeNat F.length ++ F.flatMap Clause.encode + +def formulaSize (F : Formula) : ℕ := (encodeFormula F).length + +def encodeGraph (G : Graph) : BitString := + encodeNat G.n ++ (List.finRange G.n).flatMap (fun i => + (List.finRange G.n).flatMap (fun j => encodeRat (G.capacity i j))) + +/-- The rational threshold is additional to the graph. -/ +structure Instance where + graph : Graph + threshold : ℚ + threshold_pos : 0 < threshold + +def encodeInstance (I : Instance) : BitString := + block (encodeGraph I.graph) ++ encodeRat I.threshold + +/-- This records graph size, every numeric bit length, and total output length. +The polynomial is quantified *inside* the choice of the fixed factor. -/ +def OutputBound (R : Formula → Instance) (p : Polynomial ℕ) : Prop := + ∀ F, let I := R F + I.graph.n + I.graph.n ^ 2 ≤ p.eval (formulaSize F) ∧ + (∀ i j, (encodeRat (I.graph.capacity i j)).length ≤ p.eval (formulaSize F)) ∧ + (encodeRat I.threshold).length ≤ p.eval (formulaSize F) ∧ + (encodeInstance I).length ≤ p.eval (formulaSize F) + +/-- Polynomial-time gap reduction for the specific objective above. -/ +def HasGapReduction (C : ℝ) : Prop := + ∃ R : Formula → Instance, + Polytime encodeFormula encodeInstance R ∧ + (∃ p : Polynomial ℕ, OutputBound R p) ∧ + (∀ F, Satisfiable F → (R F).graph.phi ≤ (R F).threshold) ∧ + (∀ F, ¬ Satisfiable F → C * ((R F).threshold : ℝ) < ((R F).graph.phi : ℝ)) + +/-! ## The approximation search problem and NP-hardness -/ + +/-- A cut is returned as one bit per vertex, in vertex order. -/ +def cutOfBits (G : Graph) (s : BitString) : Finset (Fin G.n) := + Finset.univ.filter (fun i => s[i.val]?.getD false = true) + +/-- The approximation algorithm must return a feasible cut, not just an estimated value. -/ +def ApproxAnswer (C : ℝ) (G : Graph) (s : BitString) : Prop := + s.length = G.n ∧ IsCut (cutOfBits G s) ∧ + (G.cutRatio (cutOfBits G s) : ℝ) ≤ C * (G.phi : ℝ) + +abbrev Language := BitString → Prop + +/-- NP via a deterministic polynomial-time verifier and a polynomial-length certificate. -/ +def InNP (L : Language) : Prop := + ∃ (V : BitString × BitString → Bool) (p : Polynomial ℕ), + Polytime encodePair encodeBool V ∧ + ∀ x, L x ↔ ∃ w, w.length ≤ p.eval x.length ∧ V (x, w) = true + +/-- NP-hardness of the factor-`C` search problem, under one-call polynomial-time +oracle reductions. The postprocessor must work for *every* valid approximate +answer, not just for a helpful choice of answer. -/ +def ApproximationNPHard (C : ℝ) : Prop := + ∀ L : Language, InNP L → + ∃ (query : BitString → Graph) (decideAnswer : BitString × BitString → Bool), + Polytime id encodeGraph query ∧ + Polytime encodePair encodeBool decideAnswer ∧ + ∀ x s, ApproxAnswer C (query x) s → (decideAnswer (x, s) = true ↔ L x) + +def bitsOfCut (G : Graph) (S : Finset (Fin G.n)) : BitString := + List.ofFn (fun i : Fin G.n => decide (i ∈ S)) + +@[simp] theorem bitsOfCut_length (G : Graph) (S : Finset (Fin G.n)) : + (bitsOfCut G S).length = G.n := by simp [bitsOfCut] + +@[simp] theorem cutOfBits_bitsOfCut (G : Graph) (S : Finset (Fin G.n)) : + cutOfBits G (bitsOfCut G S) = S := by + ext i + simp [cutOfBits, bitsOfCut] + +/-- Every graph has a factor-`C` approximation when `C ≥ 1`. -/ +theorem exists_approximation_answer (G : Graph) {C : ℝ} (hC : 1 ≤ C) : + ∃ s, ApproxAnswer C G s := by + obtain ⟨S, hS, hmin⟩ := G.exists_minimizing_cut + refine ⟨bitsOfCut G S, bitsOfCut_length G S, ?_, ?_⟩ + · simpa using hS + · rw [cutOfBits_bitsOfCut, hmin] + have hp : (0 : ℝ) ≤ G.phi := by exact_mod_cast G.phi_nonneg + simpa using mul_le_mul_of_nonneg_right hC hp + +/-- Rational comparison of the returned cut with a fixed rational factor `B`. +No real-number oracle is used by this predicate. -/ +def decideGap (B : ℚ) (I : Instance) (s : BitString) : Bool := + decide (I.graph.cutRatio (cutOfBits I.graph s) ≤ B * I.threshold) + +/-- A gap for a larger rational factor decides satisfiability from every valid +approximation at the target real factor. -/ +theorem gap_decision_correct {F : Formula} {I : Instance} {C : ℝ} {B : ℚ} + (hC : 0 ≤ C) (hCB : C ≤ (B : ℝ)) + (hyes : Satisfiable F → I.graph.phi ≤ I.threshold) + (hno : ¬ Satisfiable F → (B : ℝ) * I.threshold < I.graph.phi) + {s : BitString} (hs : ApproxAnswer C I.graph s) : + decideGap B I s = true ↔ Satisfiable F := by + simp only [decideGap, decide_eq_true_eq] + constructor + · intro hratio + by_contra hunsat + have hno' := hno hunsat + have hp : (I.graph.phi : ℝ) ≤ I.graph.cutRatio (cutOfBits I.graph s) := by + exact_mod_cast I.graph.phi_le_cutRatio hs.2.1 + have hr : (I.graph.cutRatio (cutOfBits I.graph s) : ℝ) ≤ (B : ℝ) * I.threshold := by + exact_mod_cast hratio + linarith only [hno', hp, hr] + · intro hsat + have hp : (I.graph.phi : ℝ) ≤ I.threshold := by exact_mod_cast hyes hsat + have ha : (0 : ℝ) ≤ I.threshold := by exact_mod_cast I.threshold_pos.le + have hbound := hs.2.2.trans (mul_le_mul_of_nonneg_left hp hC) + have hbound' := hbound.trans (mul_le_mul_of_nonneg_right hCB ha) + exact_mod_cast hbound' + +end UniformSparsestCut + +end OAI diff --git a/lean/OAI/Combinatorics/SparsestCut/GaussianCDF.lean b/lean/OAI/Combinatorics/SparsestCut/GaussianCDF.lean new file mode 100644 index 0000000000000000000000000000000000000000..6a7e1bb56063ec4352e64def51afd318b769bf91 --- /dev/null +++ b/lean/OAI/Combinatorics/SparsestCut/GaussianCDF.lean @@ -0,0 +1,144 @@ +import OAI.Combinatorics.SparsestCut.GaussianPoincare + +namespace OAI + +open scoped BigOperators Topology NNReal RealInnerProductSpace InnerProductSpace Matrix ContDiff ENNReal +open MeasureTheory ProbabilityTheory Set Filter Matrix + +noncomputable section + +namespace UniformSparsestCut.GaussianCDF +local notation "μ" => gaussianReal 0 1 +def Φ (x : ℝ) : ℝ := cdf μ x +def φ (x : ℝ) : ℝ := gaussianPDFReal 0 1 x + +lemma φ_pos (x : ℝ) : 0 < φ x := gaussianPDFReal_pos _ _ _ (by norm_num) +lemma φ_contDiff : ContDiff ℝ ∞ φ := by unfold φ gaussianPDFReal; fun_prop +lemma φ_integrable : Integrable φ := integrable_gaussianPDFReal _ _ +lemma Φ_integral (x : ℝ) : Φ x = ∫ t in Iic x, φ t := by + rw [Φ, cdf_eq_real, measureReal_def, gaussianReal_apply_eq_integral _ (by norm_num)] + exact ENNReal.toReal_ofReal (integral_nonneg (fun t => gaussianPDFReal_nonneg (0:ℝ) 1 t)) + +lemma Φ_primitive (x : ℝ) : Φ x = Φ 0 + ∫ t in (0:ℝ)..x, φ t := by + rw [Φ_integral, Φ_integral] + have h := intervalIntegral.integral_Iic_sub_Iic + (φ_integrable.integrableOn (s := Iic 0)) (φ_integrable.integrableOn (s := Iic x)) + linarith + +lemma Φ_hasDeriv (x : ℝ) : HasDerivAt Φ (φ x) x := by + have h := intervalIntegral.integral_hasDerivAt_right + (φ_contDiff.continuous.intervalIntegrable (0:ℝ) x) + φ_contDiff.continuous.stronglyMeasurable.stronglyMeasurableAtFilter + φ_contDiff.continuous.continuousAt + have h' := h.const_add (Φ 0) + convert h' using 1 + first | rfl | exact funext Φ_primitive + +lemma Φ_continuous : Continuous Φ := continuous_iff_continuousAt.mpr (fun x => (Φ_hasDeriv x).continuousAt) +lemma Φ_strictMono : StrictMono Φ := strictMono_of_deriv_pos (fun x => by rw [(Φ_hasDeriv x).deriv]; exact φ_pos x) +lemma Φ_mem (x : ℝ) : Φ x ∈ Ioo (0:ℝ) 1 := by + constructor + · exact (cdf_nonneg μ (x-1)).trans_lt (Φ_strictMono (by linarith)) + · exact (Φ_strictMono (show x < x+1 by linarith)).trans_le (cdf_le_one μ (x+1)) + +lemma Φ_surj {y : ℝ} (hy : y ∈ Ioo (0:ℝ) 1) : ∃ x, Φ x = y := by + apply intermediate_value_univ₂_eventually₂ (l₁ := atBot) (l₂ := atTop) Φ_continuous continuous_const + · exact (tendsto_cdf_atBot μ).eventually (eventually_le_nhds hy.1) + · exact (tendsto_cdf_atTop μ).eventually (eventually_ge_nhds hy.2) + +lemma Φ_map : (μ).map Φ = volume.restrict (Ioo (0:ℝ) 1) := by + apply Measure.ext_of_Iic + intro y + rw [Measure.map_apply Φ_continuous.measurable measurableSet_Iic, + Measure.restrict_apply measurableSet_Iic] + by_cases h0 : y ≤ 0 + · have he : Φ ⁻¹' Iic y = ∅ := by + ext x; simp only [mem_preimage, mem_Iic, mem_empty_iff_false, iff_false] + exact not_le.mpr (h0.trans_lt (Φ_mem x).1) + 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 + rw [he, he', measure_empty, measure_empty] + by_cases h1 : 1 ≤ y + · 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 + have he' : Iic y ∩ Ioo (0:ℝ) 1 = Ioo (0:ℝ) 1 := by ext x; simp only [mem_inter_iff, mem_Iic, mem_Ioo]; constructor <;> grind + rw [he, he', measure_univ, Real.volume_Ioo]; norm_num + obtain ⟨x,hx⟩ := Φ_surj ⟨lt_of_not_ge h0, lt_of_not_ge h1⟩ + have he : Φ ⁻¹' Iic y = Iic x := by ext z; simpa only [mem_preimage, mem_Iic, ← hx] using Φ_strictMono.le_iff_le + have he' : Iic y ∩ Ioo (0:ℝ) 1 = Ioc (0:ℝ) y := by + ext z; simp only [mem_inter_iff, mem_Iic, mem_Ioo, mem_Ioc]; grind + rw [he, he', ← ofReal_cdf μ x, Real.volume_Ioc, sub_zero, ← hx] + rfl + +def ψ (x : ℝ) : ℝ := 2*Φ x-1 +lemma ψ_hasDeriv (x : ℝ) : HasDerivAt ψ (2*φ x) x := (Φ_hasDeriv x).const_mul 2 |>.sub_const 1 +lemma ψ_mem (x : ℝ) : ψ x ∈ Ioo (-1:ℝ) 1 := by + have h := Φ_mem x + dsimp [ψ]; constructor <;> linarith [h.1,h.2] + +lemma ψ_contDiff : ContDiff ℝ 1 ψ := by + apply contDiff_one_iff_deriv.mpr + constructor + · exact fun x => (ψ_hasDeriv x).differentiableAt + · have he : deriv ψ = fun x => 2*φ x := funext (fun x => (ψ_hasDeriv x).deriv) + rw [he] + exact continuous_const.mul φ_contDiff.continuous + +lemma ψ_deriv_bound (x : ℝ) : |2*φ x| ≤ 1 := by + have hs : 0 < Real.sqrt (2*Real.pi) := Real.sqrt_pos.mpr (by positivity) + have hs2 := Real.sq_sqrt (show 0 ≤ 2*Real.pi by positivity) + have hge : 2 ≤ Real.sqrt (2*Real.pi) := by nlinarith [Real.pi_gt_three] + have he : Real.exp (-x^2/2) ≤ 1 := Real.exp_le_one_iff.mpr (by nlinarith [sq_nonneg x]) + have he0 : 0 ≤ Real.exp (-x^2/2) := (Real.exp_pos _).le + rw [abs_of_pos (mul_pos (by norm_num : (0:ℝ)<2) (φ_pos x))] + change 2*((Real.sqrt (2*Real.pi*1))⁻¹*Real.exp (-(x-0)^2/(2*1))) ≤ 1 + simp only [mul_one, sub_zero] + calc + _ = (Real.sqrt (2*Real.pi))⁻¹*(2*Real.exp (-x^2/2)) := by ring + _ ≤ 1 := (inv_mul_le_iff₀ hs).mpr (by nlinarith) + +def uniform : Measure ℝ := (2:ℝ≥0∞)⁻¹ • volume.restrict (Ioo (-1:ℝ) 1) + +lemma ψ_map : (μ).map ψ = uniform := by + apply Measure.ext_of_Iic + intro y + rw [Measure.map_apply ψ_contDiff.continuous.measurable measurableSet_Iic] + change μ (ψ ⁻¹' Iic y) = (2:ℝ≥0∞)⁻¹ * (volume.restrict (Ioo (-1:ℝ) 1)) (Iic y) + rw [Measure.restrict_apply measurableSet_Iic] + by_cases h0 : y ≤ -1 + · have he : ψ ⁻¹' Iic y = ∅ := by + ext x; simp only [mem_preimage, mem_Iic, mem_empty_iff_false, iff_false] + exact not_le.mpr (h0.trans_lt (ψ_mem x).1) + have he' : Iic y ∩ Ioo (-1:ℝ) 1 = ∅ := by + ext x; simp only [mem_inter_iff, mem_Iic, mem_Ioo, mem_empty_iff_false, iff_false]; grind + simp [he,he'] + by_cases h1 : 1 ≤ y + · 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 + have he' : Iic y ∩ Ioo (-1:ℝ) 1 = Ioo (-1:ℝ) 1 := by + ext x; simp only [mem_inter_iff, mem_Iic, mem_Ioo]; constructor <;> grind + rw [he,he',measure_univ,Real.volume_Ioo]; norm_num; + exact (ENNReal.inv_mul_cancel (by norm_num) (by norm_num)).symm + have hy : (y+1)/2 ∈ Ioo (0:ℝ) 1 := by constructor <;> linarith + obtain ⟨x,hx⟩ := Φ_surj hy + have he : ψ ⁻¹' Iic y = Iic x := by + ext z + simp only [mem_preimage, mem_Iic, ψ] + rw [show y = 2*Φ x-1 by linarith] + rw [show 2*Φ z-1 ≤ 2*Φ x-1 ↔ Φ z ≤ Φ x by constructor <;> intro hn <;> linarith] + exact Φ_strictMono.le_iff_le + have he' : Iic y ∩ Ioo (-1:ℝ) 1 = Ioc (-1:ℝ) y := by + ext z; simp only [mem_inter_iff, mem_Iic, mem_Ioo, mem_Ioc]; grind + rw [he,he',← ofReal_cdf μ x,Real.volume_Ioc] + change ENNReal.ofReal (Φ x) = (2:ℝ≥0∞)⁻¹ * ENNReal.ofReal (y- -1) + rw [hx,show y- -1 = y+1 by ring,ENNReal.ofReal_div_of_pos (by norm_num : (0:ℝ)<2)] + simp [div_eq_mul_inv,mul_comm] + +instance uniform_probability : IsProbabilityMeasure uniform := by + rw [← ψ_map] + infer_instance + +end UniformSparsestCut.GaussianCDF + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SparsestCut/GaussianNonparallel.lean b/lean/OAI/Combinatorics/SparsestCut/GaussianNonparallel.lean new file mode 100644 index 0000000000000000000000000000000000000000..e39a2ffc5f09abe0143ce6edc2d3771001a15bf1 --- /dev/null +++ b/lean/OAI/Combinatorics/SparsestCut/GaussianNonparallel.lean @@ -0,0 +1,116 @@ +import OAI.Combinatorics.SparsestCut.Directions + +namespace OAI + +open scoped BigOperators Topology NNReal RealInnerProductSpace InnerProductSpace Matrix ContDiff ENNReal +open MeasureTheory ProbabilityTheory Set Filter Matrix + +noncomputable section + +namespace UniformSparsestCut.GaussianNonparallel + +variable {m : ℕ} +local notation "E" => EuclideanSpace ℝ (Fin m) +local notation "μ" => stdGaussian E + +lemma gaussian_inner_zero_measure (v : E) (hv : v ≠ 0) : + (stdGaussian E) {x | inner ℝ v x = 0} = 0 := by + let c : ℝ≥0 := ⟨‖v‖^2, sq_nonneg _⟩ + have hc : c ≠ 0 := by + intro h + have := congrArg (fun x : ℝ≥0 => (x : ℝ)) h + change ‖v‖^2 = 0 at this + exact hv (norm_eq_zero.mp (sq_eq_zero_iff.mp this)) + let := nullSingletonClass_gaussianReal («μ» := 0) hc + have hmap : (stdGaussian E).map (fun x => inner ℝ v x) = gaussianReal 0 c := by + have h := IsGaussian.map_eq_gaussianReal («μ» := stdGaussian E) (innerSL ℝ v) + simp only [integral_strongDual_stdGaussian, variance_dual_stdGaussian, + innerSL_apply_norm] at h + convert h using 2 + · rfl + · apply NNReal.eq + change ‖v‖^2 = ((‖v‖^2).toNNReal : ℝ) + simp + have h := congrArg (fun ν : Measure ℝ => ν {0}) hmap + rw [Measure.map_apply (by fun_prop) (measurableSet_singleton _), measure_singleton] at h + exact h + +lemma gaussian_coordinate_ne (i : Fin m) : ∀ᵐ x : E ∂μ, x i ≠ 0 := by + have hv : (EuclideanSpace.single i 1 : E) ≠ 0 := by + intro h + have hh := congrArg (fun x : E => x i) h + simp at hh + have h := gaussian_inner_zero_measure (EuclideanSpace.single i 1) hv + apply ae_iff.mpr + simpa [EuclideanSpace.inner_single_left] using h + +def cross (i j : Fin m) (x y : E) : ℝ := x i * y j - x j * y i + +lemma gaussian_cross_zero_measure (i j : Fin m) (hij : i ≠ j) : + ((μ).prod μ) {z : E × E | cross i j z.1 z.2 = 0} = 0 := by + rw [Measure.prod_apply (by unfold cross; measurability)] + apply lintegral_eq_zero_of_ae_eq_zero + filter_upwards [gaussian_coordinate_ne i] with x hx + let v : E := EuclideanSpace.single j (x i) - EuclideanSpace.single i (x j) + have hv : v ≠ 0 := by + intro h + have hh := congrArg (fun x : E => x j) h + have hh' : x i = 0 := by simpa [v, PiLp.single_apply, hij, Ne.symm hij] using hh + exact hx hh' + have hid (y : E) : inner ℝ v y = cross i j x y := by + simp [v, cross, inner_sub_left, EuclideanSpace.inner_single_left] + simpa only [preimage_ofPred_eq, hid, Pi.zero_apply] using gaussian_inner_zero_measure v hv + +lemma ae_cross_ne (i j : Fin m) (hij : i ≠ j) : + ∀ᵐ z : E × E ∂(μ).prod μ, cross i j z.1 z.2 ≠ 0 := by + apply ae_iff.mpr + simpa only [not_not] using gaussian_cross_zero_measure i j hij + +lemma iid_cross_ne {N : ℕ} (i j : Fin m) (hij : i ≠ j) (a b : Fin N) (hab : a ≠ b) : + ∀ᵐ g : Fin N → E ∂Measure.pi (fun _ => μ), cross i j (g a) (g b) ≠ 0 := by + let ν := Measure.pi (fun _ : Fin N => μ) + have hind : iIndepFun (fun k (g : Fin N → E) => g k) ν := + iIndepFun_pi («μ» := fun _ : Fin N => μ) (fun _ => aemeasurable_id) + have hmap := (hind.indepFun hab).map_prod_eq_prod_map_map + (measurable_pi_apply a).aemeasurable (measurable_pi_apply b).aemeasurable + rw [(measurePreserving_eval (fun _ : Fin N => μ) a).map_eq, + (measurePreserving_eval (fun _ : Fin N => μ) b).map_eq] at hmap + have hh := congrArg (fun ν : Measure (E × E) => ν {z | cross i j z.1 z.2 = 0}) hmap + rw [Measure.map_apply (by fun_prop) (by unfold cross; measurability), + gaussian_cross_zero_measure i j hij] at hh + apply ae_iff.mpr + simpa only [ν, preimage_ofPred_eq, not_not] using hh + +lemma iid_pairwise_nonparallel {N : ℕ} (hm : 2 ≤ m) : + ∀ᵐ g : Fin N → E ∂Measure.pi (fun _ => μ), + ∀ a b, a ≠ b → ∀ t : ℝ, g a ≠ t • g b := by + let i : Fin m := ⟨0, by omega⟩ + let j : Fin m := ⟨1, by omega⟩ + have hij : i ≠ j := by intro h; have := congrArg Fin.val h; simp [i,j] at this + have hh : ∀ a b : Fin N, ∀ᵐ g : Fin N → E ∂Measure.pi (fun _ => μ), + a ≠ b → cross i j (g a) (g b) ≠ 0 := by + intro a b + by_cases hab : a = b + · exact ae_of_all _ (fun _ hn => (hn hab).elim) + · filter_upwards [iid_cross_ne i j hij a b hab] with g hg using fun _ => hg + have hall := (ae_all_iff.mpr (fun a => ae_all_iff.mpr (hh a))) + filter_upwards [hall] with g hg + intro a b hab t h + apply hg a b hab + rw [h] + simp [cross] + ring + +lemma charts_pairwise_nonparallel {N S : ℕ} (hm : 2 ≤ m) : + ∀ᵐ g : Fin S → Fin N → E ∂Measure.pi (fun _ => Measure.pi (fun _ => μ)), + ∀ s a b, a ≠ b → ∀ t : ℝ, g s a ≠ t • g s b := by + apply ae_all_iff.mpr + intro s + exact (measurePreserving_eval (fun _ : Fin S => Measure.pi (fun _ : Fin N => μ)) s).quasiMeasurePreserving.ae + (iid_pairwise_nonparallel hm) + +end UniformSparsestCut.GaussianNonparallel + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SparsestCut/GaussianPoincare.lean b/lean/OAI/Combinatorics/SparsestCut/GaussianPoincare.lean new file mode 100644 index 0000000000000000000000000000000000000000..5a71ca5d619b64686a78dea2c39cbafcc42de266 --- /dev/null +++ b/lean/OAI/Combinatorics/SparsestCut/GaussianPoincare.lean @@ -0,0 +1,155 @@ +import OAI.Combinatorics.SparsestCut.ContractionCore + +namespace OAI + +universe u1 + +open scoped BigOperators Topology NNReal RealInnerProductSpace InnerProductSpace Matrix ContDiff ENNReal +open MeasureTheory ProbabilityTheory Set Filter Matrix + +noncomputable section + +namespace UniformSparsestCut.GaussianPoincare +variable {E : Type u1} [NormedAddCommGroup E] [InnerProductSpace ℝ E] + [FiniteDimensional ℝ E] [MeasurableSpace E] [BorelSpace E] +local notation "μ" => stdGaussian E + +lemma gaussian_dual_sq (L : StrongDual ℝ E) : ∫ x, (L x)^2 ∂μ = ‖L‖^2 := by + have h := variance_dual_stdGaussian L + rw [variance_eq_integral (by fun_prop), integral_strongDual_stdGaussian] at h + simpa only [sub_zero] using h + +lemma gaussian_dual_abs (L : StrongDual ℝ E) : ∫ x, |L x| ∂μ ≤ ‖L‖ := by + by_cases hz : L = 0 + · simp [hz] + have h0 : 0 < ‖L‖ := norm_pos_iff.mpr hz + have hL : MemLp (fun x => L x) 2 μ := IsGaussian.memLp_dual _ _ _ (by norm_num) + have hi : Integrable (fun x => (|L x|-‖L‖)^2) μ := by + simpa using (hL.norm.sub (memLp_const ‖L‖)).integrable_sq + have hn : 0 ≤ ∫ x, (|L x|-‖L‖)^2 ∂μ := integral_nonneg (fun _ => sq_nonneg _) + have he : (∫ x, (|L x|-‖L‖)^2 ∂μ) = 2*‖L‖^2-2*‖L‖*(∫ x, |L x| ∂μ) := by + simp_rw [sub_sq, sq_abs] + have hc := ((hL.integrable (by norm_num)).abs.const_mul 2).mul_const ‖L‖ + rw [integral_add (f := fun x => L x^2-2*|L x| *‖L‖) + (g := fun _ => ‖L‖^2) (hL.integrable_sq.sub hc) (integrable_const _), + integral_sub (f := fun x => L x^2) (g := fun x => 2*|L x| *‖L‖) hL.integrable_sq hc] + rw [gaussian_dual_sq] + simp only [integral_const, measureReal_def, measure_univ, ENNReal.toReal_one, smul_eq_mul, one_mul] + rw [integral_mul_const, integral_const_mul] + ring + rw [he] at hn + nlinarith + +noncomputable def path (t : ℝ) (z : E × E) : E := Real.cos t • z.1 + Real.sin t • z.2 +noncomputable def tangent (t : ℝ) (z : E × E) : E := -Real.sin t • z.1 + Real.cos t • z.2 + +omit [FiniteDimensional ℝ E] [MeasurableSpace E] [BorelSpace E] in +lemma path_hasDeriv (t : ℝ) (z : E × E) : HasDerivAt (fun u => path u z) (tangent t z) t := by + exact ((Real.hasDerivAt_cos t).smul_const z.1).add ((Real.hasDerivAt_sin t).smul_const z.2) + +omit [FiniteDimensional ℝ E] [MeasurableSpace E] [BorelSpace E] in +lemma tangent_norm_le (t : ℝ) (z : E × E) : ‖tangent t z‖ ≤ ‖z.1‖ + ‖z.2‖ := by + calc + _ ≤ ‖-Real.sin t • z.1‖ + ‖Real.cos t • z.2‖ := norm_add_le _ _ + _ = |Real.sin t| *‖z.1‖ + |Real.cos t| *‖z.2‖ := by simp [norm_smul, Real.norm_eq_abs] + _ ≤ 1*‖z.1‖ + 1*‖z.2‖ := add_le_add (mul_le_mul_of_nonneg_right (Real.abs_sin_le_one _) (norm_nonneg _)) + (mul_le_mul_of_nonneg_right (Real.abs_cos_le_one _) (norm_nonneg _)) + _ = _ := by ring + +lemma integral_rotation (f : E × E → ℝ) (hf : AEStronglyMeasurable f ((μ).prod μ)) (t : ℝ) : + ∫ z, f (path t z, tangent t z) ∂((μ).prod μ) = ∫ z, f z ∂((μ).prod μ) := by + have hr := IsGaussian.map_rotation_eq_self (integral_id_stdGaussian (E := E)) t + have hm : AEMeasurable (ContinuousLinearMap.rotation (E := E) t) ((μ).prod μ) := by fun_prop + have h := integral_map hm (hr ▸ hf) + exact h.symm.trans (congrArg (fun ν => ∫ z, f z ∂ν) hr) + +lemma derivative_integrable (h : E → ℝ) (hh : ContDiff ℝ 1 h) {M : ℝ} (_hM : 0 ≤ M) + (hb : ∀ x, ‖fderiv ℝ h x‖ ≤ M) : + Integrable (fun z : E × E => |fderiv ℝ h z.1 z.2|) ((μ).prod μ) := by + have hi : Integrable (fun z : E × E => M*‖z.2‖) ((μ).prod μ) := + ((IsGaussian.integrable_id («μ» := μ)).norm.comp_snd μ).const_mul M + apply hi.mono' (by have hc := hh.continuous_fderiv (by norm_num); fun_prop) + filter_upwards with z + simp only [Real.norm_eq_abs, abs_abs] + exact (ContinuousLinearMap.le_opNorm _ _).trans (mul_le_mul_of_nonneg_right (hb _) (norm_nonneg _)) + +lemma derivative_average_bound (h : E → ℝ) (hh : ContDiff ℝ 1 h) {M : ℝ} (hM : 0 ≤ M) + (hb : ∀ x, ‖fderiv ℝ h x‖ ≤ M) : + (∫ z : E × E, |fderiv ℝ h z.1 z.2| ∂((μ).prod μ)) ≤ ∫ x, ‖fderiv ℝ h x‖ ∂μ := by + rw [integral_prod _ (derivative_integrable h hh hM hb)] + refine integral_mono_ae (derivative_integrable h hh hM hb).integral_prod_left ?_ ?_ + · exact (integrable_const M).mono' (by have hc := hh.continuous_fderiv (by norm_num); fun_prop) + (ae_of_all _ fun x => by simpa using hb x) + · filter_upwards with x using gaussian_dual_abs (fderiv ℝ h x) + +omit [FiniteDimensional ℝ E] [MeasurableSpace E] [BorelSpace E] in +lemma endpoint_bound (h : E → ℝ) (hh : ContDiff ℝ 1 h) (z : E × E) : + |h z.1-h z.2| ≤ ∫ t in (0 : ℝ)..(Real.pi/2), + |fderiv ℝ h (path t z) (tangent t z)| := by + have hd (t : ℝ) : HasDerivAt (fun t => h (path t z)) + (fderiv ℝ h (path t z) (tangent t z)) t := + ((hh.differentiable (by norm_num) _).hasFDerivAt).comp_hasDerivAt t (path_hasDeriv t z) + have hc : Continuous (fun t => fderiv ℝ h (path t z) (tangent t z)) := by + have hD := hh.continuous_fderiv (by norm_num) + unfold path tangent + fun_prop + have he := intervalIntegral.integral_eq_sub_of_hasDerivAt (fun t _ => hd t) + (hc.intervalIntegrable 0 (Real.pi/2)) + have hn := intervalIntegral.abs_integral_le_integral_abs («μ» := volume) + (f := fun t => fderiv ℝ h (path t z) (tangent t z)) + (by positivity : (0 : ℝ) ≤ Real.pi/2) + rw [he] at hn + simpa [path, abs_sub_comm] using hn + +lemma rotation_first_moment (h : E → ℝ) (hh : ContDiff ℝ 1 h) + {M B : ℝ} (hM : 0 ≤ M) (hb : ∀ x, ‖fderiv ℝ h x‖ ≤ M) + (hB : ∀ x, ‖h x‖ ≤ B) : + (∫ z : E × E, |h z.1-h z.2| ∂((μ).prod μ)) ≤ + (Real.pi/2) * ∫ x, ‖fderiv ℝ h x‖ ∂μ := by + let b : ℝ := Real.pi/2 + have hb0 : 0 ≤ b := by dsimp [b]; positivity + let ν := volume.restrict (Ioc (0 : ℝ) b) + have : IsFiniteMeasure ν := by dsimp [ν]; infer_instance + let g (t : ℝ) (z : E × E) := |fderiv ℝ h (path t z) (tangent t z)| + have hc : Continuous (Function.uncurry g) := by + have hD := hh.continuous_fderiv (by norm_num) + dsimp [g, Function.uncurry, path, tangent] + fun_prop + have hnorm : Integrable (fun z : E × E => ‖z.1‖+‖z.2‖) ((μ).prod μ) := + ((IsGaussian.integrable_id («μ» := stdGaussian E)).norm.comp_fst _).add + ((IsGaussian.integrable_id («μ» := stdGaussian E)).norm.comp_snd _) + have hI : Integrable (Function.uncurry g) (ν.prod ((μ).prod μ)) := by + apply ((hnorm.const_mul M).comp_snd ν).mono' hc.aestronglyMeasurable + filter_upwards with x + dsimp [g, Function.uncurry] + simp only [ abs_abs] + exact (ContinuousLinearMap.le_opNorm _ _).trans + ((mul_le_mul_of_nonneg_right (hb _) (norm_nonneg _)).trans + (mul_le_mul_of_nonneg_left (tangent_norm_le _ _) hM)) + have hInt : Integrable (fun z => ∫ t in (0 : ℝ)..b, g t z) ((μ).prod μ) := by + simpa only [intervalIntegral.integral_of_le hb0, ν, Function.uncurry_apply_pair] using hI.integral_prod_right + have hLeft : Integrable (fun z : E × E => |h z.1-h z.2|) ((μ).prod μ) := by + apply (integrable_const (2*B)).mono' (by fun_prop) + filter_upwards with z + simpa only [Real.norm_eq_abs, abs_abs] using + (norm_sub_le (h z.1) (h z.2)).trans (by linarith [hB z.1,hB z.2]) + have hrotate (t : ℝ) : (∫ z, g t z ∂((μ).prod μ)) = + ∫ z : E × E, |fderiv ℝ h z.1 z.2| ∂((μ).prod μ) := by + exact integral_rotation _ (derivative_integrable h hh hM hb).aestronglyMeasurable t + calc + _ ≤ ∫ z : E × E, (∫ t in (0 : ℝ)..b, g t z) ∂((μ).prod μ) := + integral_mono hLeft hInt (endpoint_bound h hh) + _ = ∫ t in (0 : ℝ)..b, ∫ z, g t z ∂((μ).prod μ) := by + symm + apply intervalIntegral_integral_swap + simpa only [uIoc_of_le hb0] using hI + _ = b * ∫ z : E × E, |fderiv ℝ h z.1 z.2| ∂((μ).prod μ) := by + simp_rw [hrotate] + simp [intervalIntegral.integral_const, smul_eq_mul] + _ ≤ _ := mul_le_mul_of_nonneg_left (derivative_average_bound h hh hM hb) hb0 + +end UniformSparsestCut.GaussianPoincare + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SparsestCut/GaussianTools.lean b/lean/OAI/Combinatorics/SparsestCut/GaussianTools.lean new file mode 100644 index 0000000000000000000000000000000000000000..3c764e41ceb9e2008e24979ea58add29e2166e74 --- /dev/null +++ b/lean/OAI/Combinatorics/SparsestCut/GaussianTools.lean @@ -0,0 +1,514 @@ +import OAI.Combinatorics.SparsestCut.Model + +namespace OAI + +universe u1 u2 + +open scoped BigOperators Topology NNReal RealInnerProductSpace InnerProductSpace Matrix ContDiff ENNReal +open MeasureTheory ProbabilityTheory Set Filter Matrix + +noncomputable section + +namespace UniformSparsestCut.GaussianTools + +section Concentration +variable {Ω : Type u1} [MeasurableSpace Ω] {μ : Measure Ω} [IsProbabilityMeasure μ] + +lemma subgaussian_abs_tail {X : Ω → ℝ} {c : ℝ≥0} + (hX : HasSubgaussianMGF X c μ) {u : ℝ} (hu : 0 ≤ u) : + μ.real {sample | u < |X sample|} ≤ 2 * Real.exp (-u^2 / (2 * c)) := by + have hsub : {sample | u < |X sample|} ⊆ {sample | u ≤ X sample} ∪ {sample | u ≤ -X sample} := by + intro sample hω + change u < |X sample| at hω + rcases lt_abs.mp hω with h | h + · exact Or.inl h.le + · exact Or.inr h.le + calc + _ ≤ μ.real ({sample | u ≤ X sample} ∪ {sample | u ≤ -X sample}) := measureReal_mono hsub + _ ≤ μ.real {sample | u ≤ X sample} + μ.real {sample | u ≤ -X sample} := measureReal_union_le _ _ + _ ≤ Real.exp (-u^2 / (2 * c)) + Real.exp (-u^2 / (2 * c)) := + add_le_add (hX.measure_ge_le hu) (hX.neg.measure_ge_le hu) + _ = _ := by ring + +theorem bounded_concentration {n : ℕ} (hn : 0 < n) (X : Fin n → Ω → ℝ) + (hmeas : ∀ i, AEMeasurable (X i) μ) (hind : iIndepFun X μ) + {B : ℝ} (hB : 0 < B) (hbound : ∀ i, ∀ᵐ sample ∂μ, |X i sample| ≤ B) + {u : ℝ} (hu : 0 ≤ u) : + μ.real {sample | u < |(∑ i, (X i sample - ∫ z, X i z ∂μ)) / (n : ℝ)|} ≤ + 2 * Real.exp (-(n : ℝ) * u^2 / (2 * B^2)) := by + classical + let Y : Fin n → Ω → ℝ := fun i sample => X i sample - ∫ z, X i z ∂μ + have hY (i : Fin n) : HasSubgaussianMGF (Y i) ⟨B^2, sq_nonneg B⟩ μ := by + have hh := hasSubgaussianMGF_of_mem_Icc (hmeas i) + (show ∀ᵐ sample ∂μ, X i sample ∈ Icc (-B) B by + filter_upwards [hbound i] with sample hω using abs_le.mp hω) + have hc : ((‖B - -B‖₊ / 2) ^ 2) = (⟨B^2, sq_nonneg B⟩ : ℝ≥0) := by + ext + change (‖B - -B‖ / 2) ^ 2 = B ^ 2 + rw [Real.norm_eq_abs] + rw [abs_of_nonneg (by linarith : 0 ≤ B - -B)] + ring + exact (congrArg (fun variance : ℝ≥0 => HasSubgaussianMGF (Y i) variance μ) hc).mp hh + have hYi : iIndepFun Y μ := hind.comp (fun i z => z - ∫ z, X i z ∂μ) (fun i => by fun_prop) + have hsum := HasSubgaussianMGF.sum_of_iIndepFun hYi + (s := Finset.univ) (fun i hi => hY i) + have havg := hsum.const_mul ((n : ℝ)⁻¹) + have htail := subgaussian_abs_tail havg hu + have hn0 : (n : ℝ) ≠ 0 := by exact_mod_cast hn.ne' + convert htail using 1 + · congr 1; ext sample + simp only [Y, div_eq_mul_inv, mul_comm] + · congr 2 + have hc : ((⟨(n : ℝ)⁻¹ ^ 2, sq_nonneg _⟩ : ℝ≥0) * + ∑ _ : Fin n, (⟨B^2, sq_nonneg _⟩ : ℝ≥0) : ℝ≥0) = + (⟨B^2 / n, div_nonneg (sq_nonneg _) (by positivity)⟩ : ℝ≥0) := by + apply NNReal.eq + change (n : ℝ)⁻¹ ^ 2 * ↑(∑ _ : Fin n, (⟨B^2, sq_nonneg _⟩ : ℝ≥0)) = B^2 / n + simp only [Finset.sum_const, Finset.card_univ, Fintype.card_fin] + change (n : ℝ)⁻¹ ^ 2 * ↑(n • (⟨B^2, sq_nonneg _⟩ : ℝ≥0)) = B^2 / n + simp only [nsmul_eq_mul] + change (n : ℝ)⁻¹ ^ 2 * ((n : ℝ) * B^2) = B^2 / n + field_simp + + change -(n : ℝ) * u^2 / (2 * B^2) = + -u^2 / (2 * (((⟨(n : ℝ)⁻¹ ^ 2, sq_nonneg _⟩ : ℝ≥0) * + ∑ _ : Fin n, (⟨B^2, sq_nonneg _⟩ : ℝ≥0) : ℝ≥0) : ℝ)) + rw [hc] + change -(n : ℝ) * u^2 / (2 * B^2) = -u^2 / (2 * (B^2 / n)) + field_simp + +end Concentration + +section Fourier +variable {E : Type u2} [NormedAddCommGroup E] [InnerProductSpace ℝ E] + [FiniteDimensional ℝ E] [MeasurableSpace E] [BorelSpace E] + +lemma gaussian_cos_integrable (w : E) : + Integrable (fun g : E => Real.cos (inner ℝ g w)) (stdGaussian E) := by + apply Integrable.mono' (integrable_const (1 : ℝ)) + · exact (by fun_prop : Continuous (fun g : E => Real.cos (inner ℝ g w))).aestronglyMeasurable + · exact ae_of_all _ (fun g => by simpa only [Real.norm_eq_abs] using Real.abs_cos_le_one _) + +lemma gaussian_cos (w : E) : + (∫ g : E, Real.cos (inner ℝ g w) ∂stdGaussian E) = + Real.exp (-‖w‖^2 / 2) := by + have hh := congrArg Complex.re (charFun_stdGaussian w) + rw [charFun_apply] at hh + have hf : Integrable (fun g : E => Complex.exp ((inner ℝ g w : ℂ) * Complex.I)) + (stdGaussian E) := by + apply Integrable.mono' (integrable_const (1 : ℝ)) + · exact (by fun_prop : Continuous (fun g : E => Complex.exp ((inner ℝ g w : ℂ) * Complex.I))).aestronglyMeasurable + · exact ae_of_all _ (fun g => by simp) + have hi := Complex.reCLM.integral_comp_comm hf + change (∫ g : E, (Complex.exp ((inner ℝ g w : ℂ) * Complex.I)).re ∂stdGaussian E) = + (∫ g : E, Complex.exp ((inner ℝ g w : ℂ) * Complex.I) ∂stdGaussian E).re at hi + rw [← hi] at hh + simpa [Complex.exp_re, pow_two, Complex.mul_re, Complex.mul_im] using hh + +lemma gaussian_linear_sin_integrable (w v : E) : + Integrable (fun g : E => inner ℝ g v * Real.sin (inner ℝ g w)) (stdGaussian E) := by + apply Integrable.mono' ((IsGaussian.integrable_id (μ := stdGaussian E)).norm.mul_const ‖v‖) + · exact (by fun_prop : Continuous (fun g : E => inner ℝ g v * Real.sin (inner ℝ g w))).aestronglyMeasurable + · filter_upwards [] with g + simp only [Real.norm_eq_abs, abs_mul] + calc + _ ≤ |inner ℝ g v| * 1 := mul_le_mul_of_nonneg_left (Real.abs_sin_le_one _) (abs_nonneg _) + _ ≤ ‖g‖ * ‖v‖ := by simpa using abs_real_inner_le_norm g v + +lemma gaussian_linear_sin (w v : E) : + (∫ g : E, inner ℝ g v * Real.sin (inner ℝ g w) ∂stdGaussian E) = + inner ℝ w v * Real.exp (-‖w‖^2 / 2) := by + let F : ℝ → E → ℝ := fun t g => Real.cos (inner ℝ g (w + t • v)) + let F' : ℝ → E → ℝ := fun t g => -Real.sin (inner ℝ g (w + t • v)) * inner ℝ g v + have hd (g : E) (t : ℝ) : HasDerivAt (fun t => F t g) (F' t g) t := by + have h := ((hasDerivAt_const t w).add ((hasDerivAt_id t).smul_const v)) + have hh := ((hasDerivAt_const t g).inner ℝ h).cos + simpa [F, F'] using hh + have hbound (g : E) (t : ℝ) : ‖F' t g‖ ≤ ‖g‖ * ‖v‖ := by + simp only [F', Real.norm_eq_abs, abs_mul, abs_neg] + calc + _ ≤ 1 * |inner ℝ g v| := mul_le_mul_of_nonneg_right (Real.abs_sin_le_one _) (abs_nonneg _) + _ ≤ ‖g‖ * ‖v‖ := by simpa using abs_real_inner_le_norm g v + have hi := hasDerivAt_integral_of_dominated_loc_of_deriv_le + (μ := stdGaussian E) (F := F) (F' := F') (bound := fun g => ‖g‖ * ‖v‖) + (s := Set.univ) (x₀ := (0 : ℝ)) (Filter.univ_mem) + (Filter.Eventually.of_forall (fun t => + (show Continuous (F t) by dsimp [F]; fun_prop).aestronglyMeasurable)) + (by simpa [F] using gaussian_cos_integrable w) + (show AEStronglyMeasurable (F' 0) (stdGaussian E) from + (show Continuous (F' 0) by dsimp [F']; fun_prop).aestronglyMeasurable) + (ae_of_all _ (fun g t _ => hbound g t)) + ((IsGaussian.integrable_id (μ := stdGaussian E)).norm.mul_const ‖v‖) + (ae_of_all _ (fun g t _ => hd g t)) + have ht := (((hasDerivAt_const (0 : ℝ) w).add + ((hasDerivAt_id (0 : ℝ)).smul_const v)).norm_sq.neg.div_const 2).exp + have heq : (fun t => ∫ g : E, F t g ∂stdGaussian E) = + (fun t : ℝ => Real.exp (-‖w + t • v‖^2 / 2)) := by + funext t + exact gaussian_cos _ + rw [heq] at hi + have huniq := hi.2.unique ht + simp only [F', zero_smul, add_zero, one_smul, zero_add] at huniq + have hneg : (∫ g : E, -Real.sin (inner ℝ g w) * inner ℝ g v ∂stdGaussian E) = + -(∫ g : E, inner ℝ g v * Real.sin (inner ℝ g w) ∂stdGaussian E) := by + rw [← integral_neg] + congr 1 + funext g + ring + rw [hneg] at huniq + dsimp at huniq + simp only [zero_smul, add_zero] at huniq + nlinarith + +lemma gaussian_vector_sin_integrable (w : E) : + Integrable (fun g : E => Real.sin (inner ℝ g w) • g) (stdGaussian E) := by + exact (IsGaussian.integrable_id (μ := stdGaussian E)).bdd_smul 1 + (by fun_prop) (ae_of_all _ (fun g => by simpa using Real.abs_sin_le_one (inner ℝ g w))) + +lemma gaussian_vector_sin (w : E) : + (∫ g : E, Real.sin (inner ℝ g w) • g ∂stdGaussian E) = + Real.exp (-‖w‖^2 / 2) • w := by + apply ext_inner_left ℝ + intro v + rw [← integral_inner (gaussian_vector_sin_integrable w), inner_smul_right] + simp only [inner_smul_right] + simpa only [real_inner_comm, mul_comm] using gaussian_linear_sin w v + +lemma gaussian_inner_law (v : E) : + (stdGaussian E).map (fun g => inner ℝ v g) = + gaussianReal 0 (⟨‖v‖^2, sq_nonneg _⟩ : ℝ≥0) := by + have h := IsGaussian.map_eq_gaussianReal (μ := stdGaussian E) (innerSL ℝ v) + simp only [integral_strongDual_stdGaussian, variance_dual_stdGaussian, + innerSL_apply_norm] at h + have hvariance : (‖v‖^2).toNNReal = (⟨‖v‖^2, sq_nonneg _⟩ : ℝ≥0) := + Real.toNNReal_of_nonneg (sq_nonneg _) + exact h.trans (congrArg (gaussianReal 0) hvariance) + +lemma gaussian_inner_sq (v : E) : + (∫ g : E, (inner ℝ v g)^2 ∂stdGaussian E) = ‖v‖^2 := by + have h := variance_dual_stdGaussian (innerSL ℝ v) + rw [variance_eq_integral (by fun_prop), integral_strongDual_stdGaussian] at h + simpa only [sub_zero, innerSL_apply_norm, innerSL_apply_apply] using h + +lemma gaussian_inner_subgaussian (v : E) : + HasSubgaussianMGF (fun g => inner ℝ v g) (⟨‖v‖^2, sq_nonneg _⟩ : ℝ≥0) (stdGaussian E) where + integrable_exp_mul t := by + have h := integrable_exp_mul_gaussianReal (μ := 0) + (v := (⟨‖v‖^2, sq_nonneg _⟩ : ℝ≥0)) t + rw [← gaussian_inner_law v] at h + exact (integrable_map_measure h.aestronglyMeasurable (by fun_prop)).mp h + mgf_le t := by + rw [mgf_gaussianReal ⟨by fun_prop, gaussian_inner_law v⟩] + simp + +lemma gaussian_inner_tail (v : E) (hv : ‖v‖ = 1) {u : ℝ} (hu : 0 ≤ u) : + (stdGaussian E).real {g | u < |inner ℝ v g|} ≤ 2 * Real.exp (-u^2 / 2) := by + have h := subgaussian_abs_tail (gaussian_inner_subgaussian v) hu + change _ ≤ 2 * Real.exp (-u^2 / (2 * ‖v‖^2)) at h + simpa [hv] using h + +end Fourier +section NormTails + +lemma gaussian_real_exp_sq (t : ℝ) (ht : t < 1/2) : + (∫ x : ℝ, Real.exp (t * x^2) ∂gaussianReal 0 1) = + Real.exp (-(1/2 : ℝ) * Real.log (1 - 2*t)) := by + rw [integral_gaussianReal_eq_integral_smul (by norm_num : (1 : ℝ≥0) ≠ 0)] + have heq (x : ℝ) : gaussianPDFReal 0 1 x * Real.exp (t * x^2) = + (Real.sqrt (2 * Real.pi))⁻¹ * Real.exp (-(1/2-t) * x^2) := by + simp only [gaussianPDFReal, NNReal.coe_one, mul_one, sub_zero] + rw [mul_assoc, ← Real.exp_add] + congr 2 + ring + simp_rw [smul_eq_mul, heq] + rw [integral_const_mul, integral_gaussian] + have hpos : 0 < 1 - 2*t := by linarith + have hhalf : 0 < 1/2-t := by linarith + have hpi := Real.pi_pos + have heq2 : (Real.sqrt (2 * Real.pi))⁻¹ * Real.sqrt (Real.pi / (1/2-t)) = + Real.sqrt ((1 - 2*t)⁻¹) := by + rw [← Real.sqrt_inv, ← Real.sqrt_mul (inv_nonneg.mpr (by positivity))] + congr 1 + field_simp + + rw [heq2, Real.sqrt_eq_rpow, Real.rpow_def_of_pos (inv_pos.mpr hpos), Real.log_inv] + congr 1 + ring + +lemma gaussian_real_exp_sq_integrable (t : ℝ) (ht : t < 1/2) : + Integrable (fun x : ℝ => Real.exp (t * x^2)) (gaussianReal 0 1) := by + by_contra h + have hh := gaussian_real_exp_sq t ht + rw [integral_undef h] at hh + exact (Real.exp_ne_zero _).symm hh + +lemma gaussian_exp_norm_sq {n : ℕ} (t : ℝ) (ht : t < 1/2) : + (∫ g : EuclideanSpace ℝ (Fin n), Real.exp (t * ‖g‖^2) + ∂stdGaussian (EuclideanSpace ℝ (Fin n))) = + Real.exp (-(n : ℝ)/2 * Real.log (1-2*t)) := by + rw [← map_pi_eq_stdGaussian] + rw [integral_map (by fun_prop) (by fun_prop)] + have heq (g : Fin n → ℝ) : Real.exp (t * ‖WithLp.toLp 2 g‖^2) = + ∏ i, Real.exp (t * (g i)^2) := by + rw [EuclideanSpace.real_norm_sq_eq, Finset.mul_sum, Real.exp_sum] + simp_rw [heq] + have hp := integral_fintype_prod_eq_pow (ι := Fin n) (μ := gaussianReal 0 1) + (fun x : ℝ => Real.exp (t * x^2)) + rw [Fintype.card_fin] at hp + change (∫ x : Fin n → ℝ, ∏ i, Real.exp (t * x i ^ 2) ∂Measure.pi (fun _ => gaussianReal 0 1)) = + (∫ x : ℝ, Real.exp (t * x^2) ∂gaussianReal 0 1) ^ n at hp + rw [hp, gaussian_real_exp_sq t ht, ← Real.exp_nat_mul] + congr 1 + ring + +lemma gaussian_exp_norm_sq_integrable {n : ℕ} (t : ℝ) (ht : t < 1/2) : + Integrable (fun g : EuclideanSpace ℝ (Fin n) => Real.exp (t * ‖g‖^2)) + (stdGaussian (EuclideanSpace ℝ (Fin n))) := by + by_contra h + have hh := gaussian_exp_norm_sq (n := n) t ht + rw [integral_undef h] at hh + exact (Real.exp_ne_zero _).symm hh + +lemma gaussian_norm_upper {n : ℕ} : + (stdGaussian (EuclideanSpace ℝ (Fin n))).real + {g | 4 * (n : ℝ) < ‖g‖^2} ≤ Real.exp (-(n : ℝ)/2) := by + let μ := stdGaussian (EuclideanSpace ℝ (Fin n)) + have hmark := mul_meas_ge_le_integral_of_nonneg (μ := μ) + (f := fun g => Real.exp ((1/4 : ℝ) * ‖g‖^2)) + (ae_of_all _ (fun _ => (Real.exp_pos _).le)) + (gaussian_exp_norm_sq_integrable (1/4) (by norm_num)) (Real.exp n) + rw [gaussian_exp_norm_sq (1/4) (by norm_num)] at hmark + have hs : {g : EuclideanSpace ℝ (Fin n) | 4 * (n : ℝ) < ‖g‖^2} ⊆ + {g | Real.exp n ≤ Real.exp ((1/4 : ℝ) * ‖g‖^2)} := by + intro g hg + apply Real.exp_le_exp.mpr + change 4 * (n : ℝ) < ‖g‖^2 at hg + linarith + have hn : (0 : ℝ) ≤ n := Nat.cast_nonneg _ + calc + _ ≤ μ.real {g | Real.exp n ≤ Real.exp ((1/4 : ℝ) * ‖g‖^2)} := measureReal_mono hs + _ ≤ Real.exp (-(n : ℝ)/2 * Real.log (1-2*(1/4 : ℝ))) / Real.exp n := + (le_div_iff₀ (Real.exp_pos _)).mpr (by simpa [mul_comm] using hmark) + _ ≤ Real.exp (-(n : ℝ)/2) := by + rw [← Real.exp_sub] + apply Real.exp_le_exp.mpr + have hh := Real.log_le_sub_one_of_pos (by norm_num : (0 : ℝ) < 2) + have hl : Real.log (1-2*(1/4 : ℝ)) = -Real.log 2 := by + norm_num + rw [show (1/2 : ℝ) = (2 : ℝ)⁻¹ by norm_num, Real.log_inv] + rw [hl] + nlinarith + +lemma gaussian_norm_lower {n : ℕ} : + (stdGaussian (EuclideanSpace ℝ (Fin n))).real + {g | ‖g‖^2 < (n : ℝ)/4} ≤ Real.exp (-(n : ℝ)/8) := by + let μ := stdGaussian (EuclideanSpace ℝ (Fin n)) + have hmark := mul_meas_ge_le_integral_of_nonneg (μ := μ) + (f := fun g => Real.exp ((-1/2 : ℝ) * ‖g‖^2)) + (ae_of_all _ (fun _ => (Real.exp_pos _).le)) + (gaussian_exp_norm_sq_integrable (-1/2) (by norm_num)) (Real.exp (-(n : ℝ)/8)) + rw [gaussian_exp_norm_sq (-1/2) (by norm_num)] at hmark + have hs : {g : EuclideanSpace ℝ (Fin n) | ‖g‖^2 < (n : ℝ)/4} ⊆ + {g | Real.exp (-(n : ℝ)/8) ≤ Real.exp ((-1/2 : ℝ) * ‖g‖^2)} := by + intro g hg + apply Real.exp_le_exp.mpr + change ‖g‖^2 < (n : ℝ)/4 at hg + linarith + have hn : (0 : ℝ) ≤ n := Nat.cast_nonneg _ + calc + _ ≤ μ.real {g | Real.exp (-(n : ℝ)/8) ≤ Real.exp ((-1/2 : ℝ) * ‖g‖^2)} := measureReal_mono hs + _ ≤ Real.exp (-(n : ℝ)/2 * Real.log (1-2*(-1/2 : ℝ))) / Real.exp (-(n : ℝ)/8) := + (le_div_iff₀ (Real.exp_pos _)).mpr (by simpa [mul_comm] using hmark) + _ ≤ Real.exp (-(n : ℝ)/8) := by + rw [← Real.exp_sub] + apply Real.exp_le_exp.mpr + norm_num only at * + have hh := Real.one_sub_inv_le_log_of_pos (by norm_num : (0 : ℝ) < 2) + norm_num at hh ⊢ + nlinarith + +lemma gaussian_norm_tail {n : ℕ} : + (stdGaussian (EuclideanSpace ℝ (Fin n))).real + {g | ‖g‖ ∉ Icc (Real.sqrt n / 2) (2 * Real.sqrt n)} ≤ + 2 * Real.exp (-(n : ℝ)/8) := by + have hs : {g : EuclideanSpace ℝ (Fin n) | ‖g‖ ∉ Icc (Real.sqrt n / 2) (2 * Real.sqrt n)} ⊆ + {g | ‖g‖^2 < (n : ℝ)/4} ∪ {g | 4 * (n : ℝ) < ‖g‖^2} := by + intro g hg + change ¬(Real.sqrt n / 2 ≤ ‖g‖ ∧ ‖g‖ ≤ 2 * Real.sqrt n) at hg + have hsq := Real.sq_sqrt (Nat.cast_nonneg n) + have hsqrt := Real.sqrt_nonneg (n : ℝ) + have hnorm := norm_nonneg g + rcases not_and_or.mp hg with h | h + · exact Or.inl (by simp only [mem_ofPred_eq]; nlinarith [lt_of_not_ge h]) + · exact Or.inr (by simp only [mem_ofPred_eq]; nlinarith [lt_of_not_ge h]) + calc + _ ≤ _ := measureReal_mono hs + _ ≤ _ := measureReal_union_le _ _ + _ ≤ Real.exp (-(n : ℝ)/8) + Real.exp (-(n : ℝ)/2) := + add_le_add gaussian_norm_lower gaussian_norm_upper + _ ≤ 2 * Real.exp (-(n : ℝ)/8) := by + have hh : Real.exp (-(n : ℝ)/2) ≤ Real.exp (-(n : ℝ)/8) := + Real.exp_le_exp.mpr (by have := Nat.cast_nonneg (α := ℝ) n; linarith) + linarith + +lemma gaussian_truncated_sq_bound {n : ℕ} : + (∫ g : EuclideanSpace ℝ (Fin n), + ({g | 4*(n : ℝ) < ‖g‖^2} : Set (EuclideanSpace ℝ (Fin n))).indicator + (fun g => ‖g‖^2) g ∂stdGaussian (EuclideanSpace ℝ (Fin n))) ≤ + 16 * Real.exp (-(n : ℝ)/12) := by + let μ := stdGaussian (EuclideanSpace ℝ (Fin n)) + have hm (g : EuclideanSpace ℝ (Fin n)) : + ({g | 4*(n : ℝ) < ‖g‖^2} : Set (EuclideanSpace ℝ (Fin n))).indicator + (fun g => ‖g‖^2) g ≤ + (16 * Real.exp (-(n : ℝ)/4)) * Real.exp ((1/8 : ℝ) * ‖g‖^2) := by + by_cases hg : 4*(n : ℝ) < ‖g‖^2 + · simp only [Set.indicator, Set.mem_ofPred_eq, hg, ↓reduceIte] + have he := Real.add_one_le_exp (‖g‖^2/16) + have hh : Real.exp (‖g‖^2/16) ≤ + Real.exp (-(n : ℝ)/4) * Real.exp ((1/8 : ℝ) * ‖g‖^2) := by + rw [← Real.exp_add] + apply Real.exp_le_exp.mpr + linarith + nlinarith + · simp only [Set.indicator, Set.mem_ofPred_eq, hg, ↓reduceIte] + positivity + have hi := (gaussian_exp_norm_sq_integrable (n := n) (1/8) (by norm_num)).const_mul + (16 * Real.exp (-(n : ℝ)/4)) + calc + _ ≤ ∫ g : EuclideanSpace ℝ (Fin n), + (16 * Real.exp (-(n : ℝ)/4)) * Real.exp ((1/8 : ℝ) * ‖g‖^2) ∂μ := by + apply integral_mono_of_nonneg + · exact ae_of_all _ (fun g => Set.indicator_nonneg (fun g _ => sq_nonneg ‖g‖) g) + · exact hi + · exact ae_of_all _ hm + _ = 16 * Real.exp (-(n : ℝ)/4 - (n : ℝ)/2 * Real.log (1-2*(1/8 : ℝ))) := by + rw [integral_const_mul, gaussian_exp_norm_sq (1/8) (by norm_num), mul_assoc, ← Real.exp_add] + congr 2 + ring + _ ≤ 16 * Real.exp (-(n : ℝ)/12) := by + gcongr + have hl : Real.log (1-2*(1/8 : ℝ)) = -Real.log (4/3) := by + norm_num + rw [show (3/4 : ℝ) = (4/3 : ℝ)⁻¹ by norm_num, Real.log_inv] + rw [hl] + have hh := Real.log_le_sub_one_of_pos (by norm_num : (0 : ℝ) < 4/3) + have hn := Nat.cast_nonneg (α := ℝ) n + nlinarith + +lemma gaussian_norm_sq_integrable {n : ℕ} : + Integrable (fun g : EuclideanSpace ℝ (Fin n) => ‖g‖^2) + (stdGaussian (EuclideanSpace ℝ (Fin n))) := by + apply Integrable.mono' ((gaussian_exp_norm_sq_integrable (n := n) (1/4) (by norm_num)).const_mul 4) + · fun_prop + · filter_upwards [] with g + rw [Real.norm_eq_abs, abs_of_nonneg (sq_nonneg _)] + have := Real.add_one_le_exp ((1/4 : ℝ) * ‖g‖^2) + linarith + +end NormTails + +section Truncation +variable {n : ℕ} +local notation "E" => EuclideanSpace ℝ (Fin n) +local notation "μ" => stdGaussian E + +noncomputable def truncate (n : ℕ) (f : EuclideanSpace ℝ (Fin n) → ℝ) : + EuclideanSpace ℝ (Fin n) → ℝ := + {g | ‖g‖^2 ≤ 4*(n : ℝ)}.indicator f + +lemma measurable_truncation_set : MeasurableSet {g : E | ‖g‖^2 ≤ 4*(n : ℝ)} := by + measurability + +lemma measurable_tail_set : MeasurableSet {g : E | 4*(n : ℝ) < ‖g‖^2} := by + measurability + +lemma integrable_truncate {f : E → ℝ} (hf : Integrable f μ) : + Integrable (truncate n f) μ := hf.indicator measurable_truncation_set + +lemma truncation_bias {f : E → ℝ} (hf : Integrable f μ) + (hb : ∀ g, 4*(n : ℝ) < ‖g‖^2 → |f g| ≤ ‖g‖^2) : + |(∫ g, truncate n f g ∂μ) - ∫ g, f g ∂μ| ≤ + 16 * Real.exp (-(n : ℝ)/12) := by + let T : Set E := {g | 4*(n : ℝ) < ‖g‖^2} + have hT : MeasurableSet T := measurable_tail_set + have hid (g : E) : truncate n f g - f g = -T.indicator f g := by + by_cases h : ‖g‖^2 ≤ 4*(n : ℝ) + · simp [truncate, T, h, not_lt.mpr h] + · simp [truncate, T, h, lt_of_not_ge h] + rw [← integral_sub (integrable_truncate hf) hf] + simp_rw [hid] + rw [integral_neg, abs_neg] + calc + |∫ g, T.indicator f g ∂μ| ≤ ∫ g, |T.indicator f g| ∂μ := abs_integral_le_integral_abs + _ ≤ ∫ g, T.indicator (fun g => ‖g‖^2) g ∂μ := by + apply integral_mono ((hf.indicator hT).abs) (gaussian_norm_sq_integrable.indicator hT) + intro g + by_cases hg : g ∈ T + · simpa [Set.indicator_of_mem hg] using hb g hg + · simp [Set.indicator_of_notMem hg] + _ ≤ _ := gaussian_truncated_sq_bound + +lemma inner_sq_integrable (v : E) : Integrable (fun g => (inner ℝ v g)^2) μ := by + apply Integrable.mono' (gaussian_norm_sq_integrable.const_mul (‖v‖^2)) + · fun_prop + · filter_upwards [] with g + simp only [Real.norm_eq_abs, abs_sq] + have h := abs_real_inner_le_norm v g + simpa only [sq_abs, mul_pow] using pow_le_pow_left₀ (abs_nonneg _) h 2 + +lemma truncation_covariance_bias (v : E) (hv : ‖v‖ = 1) : + |(∫ g, truncate n (fun g => (inner ℝ v g)^2) g ∂μ) - 1| ≤ + 16 * Real.exp (-(n : ℝ)/12) := by + have h := truncation_bias (inner_sq_integrable v) (fun g hg => by + have hh := abs_real_inner_le_norm v g + rw [hv, one_mul] at hh + simpa only [abs_sq, sq_abs] using pow_le_pow_left₀ (abs_nonneg _) hh 2) + simpa [gaussian_inner_sq, hv] using h + +lemma truncation_fourier_bias (hn : 1 ≤ n) (v w : E) (hv : ‖v‖ = 1) : + |(∫ g, truncate n (fun g => inner ℝ g v * Real.sin (inner ℝ g w)) g ∂μ) - + inner ℝ w v * Real.exp (-‖w‖^2/2)| ≤ + 16 * Real.exp (-(n : ℝ)/12) := by + have h := truncation_bias (gaussian_linear_sin_integrable w v) (fun g hg => by + have hn' : (1 : ℝ) ≤ n := by exact_mod_cast hn + have hh := abs_real_inner_le_norm g v + rw [hv, mul_one] at hh + have hn1 : 1 ≤ ‖g‖ := by nlinarith [norm_nonneg g] + calc + |inner ℝ g v * Real.sin (inner ℝ g w)| ≤ |inner ℝ g v| * 1 := by + rw [abs_mul]; exact mul_le_mul_of_nonneg_left (Real.abs_sin_le_one _) (abs_nonneg _) + _ ≤ ‖g‖^2 := by nlinarith) + simpa only [gaussian_linear_sin] using h + +lemma truncate_fourier_bound (v w : E) (hv : ‖v‖ = 1) (g : E) : + |truncate n (fun g => inner ℝ g v * Real.sin (inner ℝ g w)) g| ≤ 2*Real.sqrt n := by + by_cases hg : ‖g‖^2 ≤ 4*(n : ℝ) + · have hh := abs_real_inner_le_norm g v + rw [hv, mul_one] at hh + have hs := Real.sq_sqrt (Nat.cast_nonneg (α := ℝ) n) + have hb : ‖g‖ ≤ 2*Real.sqrt n := by nlinarith [Real.sqrt_nonneg (n : ℝ), norm_nonneg g] + simp only [truncate, Set.indicator, Set.mem_ofPred_eq, hg, ↓reduceIte, abs_mul] + calc + _ ≤ |inner ℝ g v| * 1 := mul_le_mul_of_nonneg_left (Real.abs_sin_le_one _) (abs_nonneg _) + _ ≤ _ := by linarith + · simp only [truncate, Set.indicator, Set.mem_ofPred_eq, hg, ↓reduceIte, abs_zero] + positivity + +lemma truncate_covariance_bound (v : E) (hv : ‖v‖ = 1) (g : E) : + |truncate n (fun g => (inner ℝ v g)^2) g| ≤ 4*(n : ℝ) := by + by_cases hg : ‖g‖^2 ≤ 4*(n : ℝ) + · have hh := abs_real_inner_le_norm v g + rw [hv, one_mul] at hh + have hb := pow_le_pow_left₀ (abs_nonneg _) hh 2 + rw [sq_abs] at hb + simp only [truncate, Set.indicator, Set.mem_ofPred_eq, hg, ↓reduceIte, abs_sq] + nlinarith + · simp only [truncate, Set.indicator, Set.mem_ofPred_eq, hg, ↓reduceIte, abs_zero] + positivity +end Truncation + +end UniformSparsestCut.GaussianTools + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SparsestCut/GradientBudget.lean b/lean/OAI/Combinatorics/SparsestCut/GradientBudget.lean new file mode 100644 index 0000000000000000000000000000000000000000..c33f902dbc26e8f9773916496c3193882c519b46 --- /dev/null +++ b/lean/OAI/Combinatorics/SparsestCut/GradientBudget.lean @@ -0,0 +1,267 @@ +import OAI.Combinatorics.SparsestCut.ConcreteCells + +namespace OAI + +universe u1 u2 u3 u4 u5 u6 u7 u8 u9 + +open scoped BigOperators Topology NNReal RealInnerProductSpace InnerProductSpace Matrix ContDiff ENNReal +open MeasureTheory ProbabilityTheory Set Filter Matrix + +noncomputable section + +namespace UniformSparsestCut.GradientBudget +variable {E : Type u1} {S : Type u2} {I : Type u3} {A : Type u4} [NormedAddCommGroup E] [InnerProductSpace ℝ E] + [Fintype S] [Fintype I] [Fintype A] [DecidableEq S] + +lemma directional_control (u : I → E) (β : I → ℝ) (a e : E) {δ : ℝ} + (hδ : 0 ≤ δ) (ha : a+e=∑ i, β i • u i) + (hu : ∀ i, |inner ℝ (u i) a| ≤ δ*‖a‖) : + ‖a‖ ≤ δ*∑ i, |β i|+‖e‖ := by + by_cases hz : a=0 + · simp only [hz,norm_zero]; positivity + have hn : 0 < ‖a‖ := norm_pos_iff.mpr hz + have hs : |inner ℝ (∑ i, β i • u i) a| ≤ δ*‖a‖*∑ i, |β i| := by + rw [sum_inner] + calc + _ ≤ ∑ i, |inner ℝ (β i • u i) a| := Finset.abs_sum_le_sum_abs _ _ + _ ≤ ∑ i, |β i| * (δ*‖a‖) := by + apply Finset.sum_le_sum; intro i _ + rw [real_inner_smul_left,abs_mul] + exact mul_le_mul_of_nonneg_left (hu i) (abs_nonneg _) + _ = _ := by rw [← Finset.sum_mul]; ring + have hip : ‖a‖^2 ≤ |inner ℝ (∑ i, β i • u i) a|+‖e‖*‖a‖ := by + rw [← ha,inner_add_left] + have h := abs_real_inner_le_norm e a + rw [real_inner_self_eq_norm_sq] + have hab := le_abs_self (‖a‖^2+inner ℝ e a) + have hab' := neg_le_abs (inner ℝ e a) + nlinarith + have hmul : ‖a‖*‖a‖ ≤ (δ*∑ i, |β i|+‖e‖)*‖a‖ := by nlinarith + nlinarith + +omit [DecidableEq S] in +lemma good_chart_average (u : S → I → E) (β : S → I → ℝ) (a : E) (e : S → E) + {δ : ℝ} (hδ : 0 ≤ δ) + (ha : ∀ s, a+e s=∑ i, β s i • u s i) + (good : Finset S) (hgood : (Fintype.card S : ℝ)/2 ≤ good.card) + (hu : ∀ s ∈ good, ∀ i, |inner ℝ (u s i) a| ≤ δ*‖a‖) : + (Fintype.card S : ℝ)*‖a‖ ≤ 2*∑ s, (δ*∑ i, |β s i|+‖e s‖) := by + have hg : (good.card:ℝ)*‖a‖ ≤ ∑ s ∈ good, (δ*∑ i, |β s i|+‖e s‖) := by + calc + _ = ∑ _s ∈ good, ‖a‖ := by simp + _ ≤ _ := Finset.sum_le_sum (fun s hs => directional_control (u s) (β s) a (e s) hδ (ha s) (hu s hs)) + have hsub : (∑ s ∈ good, (δ*∑ i, |β s i|+‖e s‖)) ≤ ∑ s, (δ*∑ i, |β s i|+‖e s‖) := by + apply Finset.sum_le_sum_of_subset_of_nonneg (Finset.subset_univ _) + intro s _ _; positivity + have hmult := mul_le_mul_of_nonneg_right hgood (norm_nonneg a) + linarith + +omit [DecidableEq S] in +lemma total_gradient (u : S → I → E) (β : S → I → A → ℝ) (a : A → E) (e : S → A → E) + {δ B R : ℝ} (hδ : 0 ≤ δ) + (ha : ∀ s α, a α+e s α=∑ i, β s i α • u s i) + (hg : ∀ α, ∃ good : Finset S, (Fintype.card S : ℝ)/2 ≤ good.card ∧ + ∀ s ∈ good, ∀ i, |inner ℝ (u s i) (a α)| ≤ δ*‖a α‖) + (hβ : ∀ s, ∑ i, ∑ α, |β s i α| ≤ B) + (he : ∀ s, ∑ α, ‖e s α‖ ≤ R) (hS : 0 < Fintype.card S) : + ∑ α, ‖a α‖ ≤ 2*(δ*B+R) := by + have hcomp (α : A) : (Fintype.card S : ℝ)*‖a α‖ ≤ + 2*∑ s, (δ*∑ i, |β s i α|+‖e s α‖) := by + obtain ⟨good,hgood,hu⟩ := hg α + exact good_chart_average u (fun s i => β s i α) (a α) (fun s => e s α) hδ + (fun s => ha s α) good hgood hu + have hs := Finset.sum_le_sum (s := Finset.univ) (fun α _ => hcomp α) + rw [← Finset.mul_sum, ← Finset.mul_sum, Finset.sum_comm] at hs + have hb (s : S) : (∑ α, (δ*∑ i, |β s i α|+‖e s α‖)) ≤ δ*B+R := by + rw [Finset.sum_add_distrib,← Finset.mul_sum,Finset.sum_comm] + exact add_le_add (mul_le_mul_of_nonneg_left (hβ s) hδ) (he s) + have hsum := Finset.sum_le_sum (s := Finset.univ) (fun s _ => hb s) + simp only [Finset.sum_const,Finset.card_univ,nsmul_eq_mul] at hsum + have hcard : (0:ℝ) < Fintype.card S := by exact_mod_cast hS + nlinarith + +end UniformSparsestCut.GradientBudget + +namespace UniformSparsestCut.ConvolutionBounds +open MeasureTheory Set +open scoped BigOperators +variable {G : Type u5} {A : Type u6} [NormedAddCommGroup G] [NormedSpace ℝ G] + [MeasurableSpace G] [BorelSpace G] [Fintype A] + {μ : Measure G} [SFinite μ] [μ.IsAddLeftInvariant] [μ.IsNegInvariant] + +def smooth (κ f : G → ℝ) (μ : Measure G) : G → ℝ := + convolution κ f (ContinuousLinearMap.mul ℝ ℝ) μ + +omit [NormedSpace ℝ G] [BorelSpace G] [SFinite μ] [μ.IsAddLeftInvariant] [μ.IsNegInvariant] in +lemma smooth_eq (κ f : G → ℝ) (x : G) : + smooth κ f μ x = ∫ z, κ z*f (x-z) ∂μ := rfl + +lemma smooth_deriv {κ f : G → ℝ} (hk : HasCompactSupport κ) + (hc : ContDiff ℝ 1 κ) (hf : LocallyIntegrable f μ) (x h : G) : + fderiv ℝ (smooth κ f μ) x h = ∫ z, (fderiv ℝ κ z h)*f (x-z) ∂μ := by + unfold smooth + rw [(hk.hasFDerivAt_convolution_left (ContinuousLinearMap.mul ℝ ℝ) hc hf x).fderiv] + have hi := (hk.fderiv ℝ).convolutionExists_left + ((ContinuousLinearMap.mul ℝ ℝ).precompL G) (hc.continuous_fderiv (by norm_num)) hf x + exact ContinuousLinearMap.integral_apply hi h + +omit [SFinite μ] in +lemma smooth_deriv_integrable {κ f : G → ℝ} (hk : HasCompactSupport κ) + (hc : ContDiff ℝ 1 κ) (hf : LocallyIntegrable f μ) (x h : G) : + Integrable (fun z => (fderiv ℝ κ z h)*f (x-z)) μ := by + have hi := (hk.fderiv ℝ).convolutionExists_left + ((ContinuousLinearMap.mul ℝ ℝ).precompL G) (hc.continuous_fderiv (by norm_num)) hf x + exact hi.apply_continuousLinearMap h + +omit [NormedAddCommGroup G] [NormedSpace ℝ G] [BorelSpace G] [SFinite μ] [μ.IsAddLeftInvariant] [μ.IsNegInvariant] in + +lemma integral_l1_bound (f : A → G → ℝ) (hf : ∀ a, Integrable (f a) μ) + {B : G → ℝ} (hB : Integrable B μ) (hb : ∀ᵐ z ∂μ, ∑ a, |f a z| ≤ B z) : + (∑ a, |∫ z, f a z ∂μ|) ≤ ∫ z, B z ∂μ := by + calc + _ ≤ ∑ a, ∫ z, |f a z| ∂μ := Finset.sum_le_sum (fun a _ => by + simpa only [Real.norm_eq_abs] using norm_integral_le_integral_norm (f a)) + _ = ∫ z, ∑ a, |f a z| ∂μ := (integral_finsetSum _ (fun a _ => (hf a).abs)).symm + _ ≤ _ := integral_mono_ae (integrable_finsetSum _ (fun a _ => (hf a).abs)) hB hb + +lemma mismatch {κ : G → ℝ} (hk : HasCompactSupport κ) (hc : ContDiff ℝ 1 κ) + (f g : A → G → ℝ) (hf : ∀ a, LocallyIntegrable (f a) μ) + (hg : ∀ a, LocallyIntegrable (g a) μ) (x h : G) {B : ℝ} + (hki : Integrable (fun z => |fderiv ℝ κ z h|) μ) + (hb : ∀ᵐ z ∂μ, fderiv ℝ κ z h ≠ 0 → ∑ a, |f a (x-z)-g a (x-z)| ≤ B) : + (∑ a, |fderiv ℝ (smooth κ (f a) μ) x h-fderiv ℝ (smooth κ (g a) μ) x h|) ≤ + B*(∫ z, |fderiv ℝ κ z h| ∂μ) := by + simp_rw [smooth_deriv hk hc (hf _),smooth_deriv hk hc (hg _)] + have hi (a : A) : Integrable (fun z => fderiv ℝ κ z h*(f a (x-z)-g a (x-z))) μ := by + convert! (smooth_deriv_integrable hk hc (hf a) x h).sub + (smooth_deriv_integrable hk hc (hg a) x h) using 1 + ext z + simp only [Pi.sub_apply,mul_sub] + have he (a : A) : (∫ z, fderiv ℝ κ z h*f a (x-z) ∂μ)- + (∫ z, fderiv ℝ κ z h*g a (x-z) ∂μ) = + ∫ z, fderiv ℝ κ z h*(f a (x-z)-g a (x-z)) ∂μ := by + simp only [mul_sub] + exact (integral_sub (smooth_deriv_integrable hk hc (hf a) x h) + (smooth_deriv_integrable hk hc (hg a) x h)).symm + simp_rw [he] + rw [← integral_const_mul] + apply integral_l1_bound _ hi (hki.const_mul B) + filter_upwards [hb] with z hz + by_cases hn : fderiv ℝ κ z h=0 + · simp [hn] + · simp_rw [abs_mul,← Finset.mul_sum] + simpa only [mul_comm] using mul_le_mul_of_nonneg_left (hz hn) (abs_nonneg (fderiv ℝ κ z h)) + +omit [NormedSpace ℝ G] [SFinite μ] in + +lemma error {κ : G → ℝ} (hk : HasCompactSupport κ) (hc : Continuous κ) + (hki : Integrable κ μ) (hkn : ∀ z, 0 ≤ κ z) (hk1 : ∫ z, κ z ∂μ=1) + (f : A → G → ℝ) (hf : ∀ a, LocallyIntegrable (f a) μ) (x : G) {B : ℝ} + (hb : ∀ᵐ z ∂μ, κ z ≠ 0 → ∑ a, |f a (x-z)-f a x| ≤ B) : + (∑ a, |smooth κ (f a) μ x-f a x|) ≤ B := by + have hi0 (a : A) : Integrable (fun z => κ z*f a (x-z)) μ := + hk.convolutionExists_left (ContinuousLinearMap.mul ℝ ℝ) hc (hf a) x + have hi (a : A) : Integrable (fun z => κ z*(f a (x-z)-f a x)) μ := by + convert! (hi0 a).sub (hki.mul_const (f a x)) using 1 + ext z + simp only [Pi.sub_apply,mul_sub] + have he (a : A) : smooth κ (f a) μ x-f a x = ∫ z, κ z*(f a (x-z)-f a x) ∂μ := by + rw [smooth_eq] + simp only [mul_sub] + rw [integral_sub (hi0 a) + (hki.mul_const (f a x)),integral_mul_const,hk1,one_mul] + simp_rw [he] + have hres := integral_l1_bound (μ := μ) _ hi (hki.const_mul B) (by + filter_upwards [hb] with z hz + by_cases hn : κ z=0 + · simp [hn] + · simp_rw [abs_mul,abs_of_nonneg (hkn z),← Finset.mul_sum] + simpa only [mul_comm] using mul_le_mul_of_nonneg_left (hz hn) (hkn z)) + simpa only [integral_const_mul,hk1,mul_one] using hres + +end UniformSparsestCut.ConvolutionBounds + +namespace UniformSparsestCut.GradientCalculus +open MeasureTheory Set +open scoped BigOperators RealInnerProductSpace +noncomputable section +variable {m : ℕ} {A : Type u7} {S : Type u8} {I : Type u9} [Fintype A] [Fintype S] [Fintype I] [DecidableEq S] +local notation "E" => EuclideanSpace ℝ (Fin m) + +def vector (D : StrongDual ℝ E) : E := (InnerProductSpace.toDual ℝ E).symm D +@[simp] lemma vector_norm (D : StrongDual ℝ E) : ‖vector D‖=‖D‖ := + (InnerProductSpace.toDual ℝ E).symm.norm_map D +@[simp] lemma vector_inner (D : StrongDual ℝ E) (x : E) : inner ℝ (vector D) x=D x := + InnerProductSpace.toDual_symm_apply +lemma vector_coordinate (D : StrongDual ℝ E) (j : Fin m) : + vector D j=D (EuclideanSpace.single j 1) := by + have h := vector_inner D (EuclideanSpace.single j 1) + simpa [PiLp.inner_apply,PiLp.single_apply] using h +lemma norm_le_partials (D : StrongDual ℝ E) : ‖D‖≤∑ j, |D (EuclideanSpace.single j 1)| := by + rw [← vector_norm] + have he : vector D=∑ j, EuclideanSpace.single j (vector D j) := by + ext i + simp + calc + _ = ‖∑ j, EuclideanSpace.single j (vector D j)‖ := congrArg norm he + _ ≤ ∑ j, ‖EuclideanSpace.single j (vector D j)‖ := norm_sum_le _ _ + _ = _ := by simp only [PiLp.norm_single,Real.norm_eq_abs,vector_coordinate] +lemma vector_representation (D : StrongDual ℝ E) (u : I → E) (β : I → ℝ) + (hd : D=∑ i, β i • InnerProductSpace.toDual ℝ E (u i)) : + vector D=∑ i, β i • u i := by + apply (InnerProductSpace.toDual ℝ E).injective + simp only [vector,LinearIsometryEquiv.apply_symm_apply,map_sum,map_smul,hd] + +lemma gradient_mismatch {κ : E → ℝ} (hk : HasCompactSupport κ) (hc : ContDiff ℝ 1 κ) + (f g : A → E → ℝ) (hf : ∀ a, LocallyIntegrable (f a)) + (hg : ∀ a, LocallyIntegrable (g a)) (x : E) {B L : ℝ} + (hki : ∀ j : Fin m, Integrable (fun z => |fderiv ℝ κ z (EuclideanSpace.single j 1)|)) + (hL : ∀ j : Fin m, ∫ z, |fderiv ℝ κ z (EuclideanSpace.single j 1)| = L) + (hb : ∀ᵐ z, (∃ j : Fin m, fderiv ℝ κ z (EuclideanSpace.single j 1)≠0) → + ∑ a, |f a (x-z)-g a (x-z)|≤B) : + (∑ a, ‖fderiv ℝ (ConvolutionBounds.smooth κ (f a) volume) x- + fderiv ℝ (ConvolutionBounds.smooth κ (g a) volume) x‖)≤(m:ℝ)*B*L := by + calc + _ ≤ ∑ a, ∑ j : Fin m, |fderiv ℝ (ConvolutionBounds.smooth κ (f a) volume) x (EuclideanSpace.single j 1)- + fderiv ℝ (ConvolutionBounds.smooth κ (g a) volume) x (EuclideanSpace.single j 1)| := by + apply Finset.sum_le_sum; intro a _ + exact norm_le_partials _ + _ = ∑ j : Fin m, ∑ a, |fderiv ℝ (ConvolutionBounds.smooth κ (f a) volume) x (EuclideanSpace.single j 1)- + fderiv ℝ (ConvolutionBounds.smooth κ (g a) volume) x (EuclideanSpace.single j 1)| := Finset.sum_comm + _ ≤ ∑ _j : Fin m, B*L := by + apply Finset.sum_le_sum; intro j _ + rw [← hL j] + apply ConvolutionBounds.mismatch hk hc f g hf hg x _ (hki j) + filter_upwards [hb] with z hz hj using hz ⟨j,hj⟩ + _ = _ := by simp; ring + +omit [DecidableEq S] in +lemma gradient_budget (u : S → I → E) (β : S → I → A → ℝ) + (D : S → A → StrongDual ℝ E) (base : A → StrongDual ℝ E) + {δ B R : ℝ} (hδ : 0≤δ) + (hd : ∀ s a, D s a=∑ i, β s i a • InnerProductSpace.toDual ℝ E (u s i)) + (hgood : ∀ a, ∃ good : Finset S, (Fintype.card S:ℝ)/2≤good.card ∧ + ∀ s∈good, ∀ i, |base a (u s i)|≤δ*‖base a‖) + (hβ : ∀ s, ∑ i, ∑ a, |β s i a|≤B) + (he : ∀ s, ∑ a, ‖D s a-base a‖≤R) (hS : 0 vector (base a)) + (fun s a => vector (D s a-base a)) hδ hvec hg hβ + (by intro s; simpa only [vector_norm] using he s) hS +end +end UniformSparsestCut.GradientCalculus + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SparsestCut/InterfaceStep.lean b/lean/OAI/Combinatorics/SparsestCut/InterfaceStep.lean new file mode 100644 index 0000000000000000000000000000000000000000..fbe937cecc7a27fefe3a781195fd79e987a53f63 --- /dev/null +++ b/lean/OAI/Combinatorics/SparsestCut/InterfaceStep.lean @@ -0,0 +1,582 @@ +import OAI.Combinatorics.SparsestCut.ContractionBounds + +namespace OAI + +universe u1 u2 u3 u4 u5 u6 u7 u8 u9 u10 + +open scoped BigOperators Topology NNReal RealInnerProductSpace InnerProductSpace Matrix ContDiff ENNReal +open MeasureTheory ProbabilityTheory Set Filter Matrix + +noncomputable section + +namespace UniformSparsestCut.InterfaceStep +variable {ι : Type u1} {V : Type u2} [DecidableEq ι] [AddCommGroup V] + +lemma telescoping_events (s : Finset ι) (t : ι → ℝ) (ht : Set.InjOn t s) + (F : Finset ι → V) : + (∑ i ∈ s, (F (s.filter (fun j => t j ≤ t i))-F (s.filter (fun j => t j < t i)))) = + F s-F ∅ := by + revert ht + induction s using Finset.strongInductionOn with + | _ s ih => + intro ht + by_cases hs : s.Nonempty + · obtain ⟨a,ha,hmax⟩ := s.exists_max_image t hs + let r := s.erase a + have hr : r ⊂ s := Finset.erase_ssubset ha + have htr : Set.InjOn t (↑r : Set ι) := ht.mono (by intro i hi; exact Finset.mem_of_mem_erase hi) + have hind := ih r hr htr + have hle : s.filter (fun j => t j ≤ t a) = s := by + apply Finset.filter_eq_self.mpr; intro j hj; exact hmax j hj + have hlt : s.filter (fun j => t j < t a) = r := by + ext j + simp only [Finset.mem_filter, r, Finset.mem_erase] + constructor + · rintro ⟨hj,h⟩; exact ⟨fun he => by simp [he] at h,hj⟩ + · rintro ⟨hne,hj⟩ + exact ⟨hj,lt_of_le_of_ne (hmax j hj) (fun he => hne (ht hj ha he))⟩ + have hfilters (i : ι) (hi : i ∈ r) : + s.filter (fun j => t j ≤ t i) = r.filter (fun j => t j ≤ t i) ∧ + s.filter (fun j => t j < t i) = r.filter (fun j => t j < t i) := by + 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 + constructor <;> (ext j; simp only [Finset.mem_filter, r, Finset.mem_erase]; constructor) + · rintro ⟨hj,hji⟩ + exact ⟨⟨fun he => by subst j; linarith,hj⟩,hji⟩ + · rintro ⟨⟨_,hj⟩,hji⟩; exact ⟨hj,hji⟩ + · rintro ⟨hj,hji⟩ + exact ⟨⟨fun he => by subst j; linarith,hj⟩,hji⟩ + · rintro ⟨⟨_,hj⟩,hji⟩; exact ⟨hj,hji⟩ + rw [← Finset.sum_erase_add _ _ ha, hle,hlt] + change (∑ i ∈ r, _) + (F s-F r) = _ + have he : (∑ i ∈ r, (F (s.filter (fun j => t j ≤ t i))-F (s.filter (fun j => t j < t i)))) = + ∑ i ∈ r, (F (r.filter (fun j => t j ≤ t i))-F (r.filter (fun j => t j < t i))) := by + apply Finset.sum_congr rfl; intro i hi; rw [(hfilters i hi).1,(hfilters i hi).2] + rw [he,hind] + abel + · simp [Finset.not_nonempty_iff_eq_empty.mp hs] + +lemma threshold_decomposition (s : Finset ι) (t : ι → ℝ) (ht : Set.InjOn t s) + (F : Finset ι → V) (x : ℝ) : + F (s.filter (fun i => t i < x)) = F ∅+ + ∑ i ∈ s, if t i < x then + F (s.filter (fun j => t j ≤ t i))-F (s.filter (fun j => t j < t i)) else 0 := by + let r := s.filter (fun i => t i < x) + have htr : Set.InjOn t (↑r : Set ι) := ht.mono (by intro i hi; exact (Finset.mem_filter.mp hi).1) + have h := telescoping_events r t htr F + have hfilters (i : ι) (hi : i ∈ r) : + r.filter (fun j => t j ≤ t i) = s.filter (fun j => t j ≤ t i) ∧ + r.filter (fun j => t j < t i) = s.filter (fun j => t j < t i) := by + have hix : t i < x := (Finset.mem_filter.mp hi).2 + constructor <;> (ext j; simp only [r,Finset.mem_filter]; constructor) + · rintro ⟨⟨hj,_⟩,hji⟩; exact ⟨hj,hji⟩ + · rintro ⟨hj,hji⟩; exact ⟨⟨hj,lt_of_le_of_lt hji hix⟩,hji⟩ + · rintro ⟨⟨hj,_⟩,hji⟩; exact ⟨hj,hji⟩ + · rintro ⟨hj,hji⟩; exact ⟨⟨hj,hji.trans hix⟩,hji⟩ + have he : (∑ i ∈ r, (F (r.filter (fun j => t j ≤ t i))-F (r.filter (fun j => t j < t i)))) = + ∑ i ∈ r, (F (s.filter (fun j => t j ≤ t i))-F (s.filter (fun j => t j < t i))) := by + apply Finset.sum_congr rfl; intro i hi; rw [(hfilters i hi).1,(hfilters i hi).2] + rw [he] at h + rw [← Finset.sum_filter] + change F r = F ∅+_ + rw [h] + abel + +section Integral +variable {W : Type u3} [NormedAddCommGroup W] [NormedSpace ℝ W] [CompleteSpace W] + +lemma integral_deriv_eq_zero {φ : ℝ → ℝ} (hφ : ContDiff ℝ 1 φ) + (hc : HasCompactSupport φ) : ∫ x, deriv φ x = 0 := by + apply integral_eq_zero_of_hasDerivAt_of_integrable + (fun x => (hφ.differentiable one_ne_zero x).hasDerivAt) + · exact (hφ.continuous_deriv le_rfl).integrable_of_hasCompactSupport hc.deriv + · exact hφ.continuous.integrable_of_hasCompactSupport hc + +lemma threshold_integral_deriv (s : Finset ι) (t : ι → ℝ) (ht : Set.InjOn t s) + (F : Finset ι → W) {φ : ℝ → ℝ} (hφ : ContDiff ℝ 1 φ) + (hc : HasCompactSupport φ) : + (∫ x, deriv φ x • F (s.filter (fun i => t i < x))) = + -∑ i ∈ s, φ (t i) • + (F (s.filter (fun j => t j ≤ t i))-F (s.filter (fun j => t j < t i))) := by + let Δ := fun i => F (s.filter (fun j => t j ≤ t i))-F (s.filter (fun j => t j < t i)) + have hd : Integrable (deriv φ) := + (hφ.continuous_deriv le_rfl).integrable_of_hasCompactSupport hc.deriv + have hi (i : ι) : Integrable (fun x => deriv φ x • (if t i < x then Δ i else 0)) := by + have he : (fun x => deriv φ x • (if t i < x then Δ i else 0)) = + (Ioi (t i)).indicator (fun x => deriv φ x • Δ i) := by + funext x; by_cases hx : t i < x <;> simp [hx] + rw [he] + exact (hd.smul_const _).indicator measurableSet_Ioi + have he (x : ℝ) : deriv φ x • F (s.filter (fun i => t i < x)) = + deriv φ x • F ∅ + ∑ i ∈ s, deriv φ x • (if t i < x then Δ i else 0) := by + rw [threshold_decomposition s t ht F x, smul_add, Finset.smul_sum] + simp_rw [he] + rw [integral_add (hd.smul_const _) (integrable_finsetSum _ (fun i _ => hi i)), + integral_smul_const, integral_deriv_eq_zero hφ hc, zero_smul, zero_add, + integral_finsetSum _ (fun i _ => hi i), ← Finset.sum_neg_distrib] + apply Finset.sum_congr rfl + intro i hi' + have he : (fun x => deriv φ x • (if t i < x then Δ i else 0)) = + (Ioi (t i)).indicator (fun x => deriv φ x • Δ i) := by + funext x; by_cases hx : t i < x <;> simp [hx] + rw [he, integral_indicator measurableSet_Ioi, integral_smul_const, + hc.integral_Ioi_deriv_eq hφ, neg_smul] +end Integral + +section MovingEvents +variable {X : Type u4} [MeasurableSpace X] + +lemma measurable_filter_apply (s : Finset ι) (P : ι → X → Prop) + [∀ i, DecidablePred (P i)] (hP : ∀ i, MeasurableSet {x | P i x}) + (F : Finset ι → ℝ) : Measurable (fun x => F (s.filter (fun i => P i x))) := by + classical + induction s using Finset.induction_on generalizing F with + | empty => simp + | @insert i s hi ih => + have h₁ := ih (fun a => F (insert i a)) + have h₂ := ih F + 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₂ + convert h using 1 + funext x + by_cases hx : P i x <;> simp [Finset.filter_insert, hx] + +end MovingEvents + +section ContinuousEvents +variable [Fintype ι] {X : Type u5} [TopologicalSpace X] [FirstCountableTopology X] + +omit [DecidableEq ι] [Fintype ι] [FirstCountableTopology X] in +lemma eventually_threshold_eq (s : Finset ι) (t : ι → X → ℝ) {y : X} {x : ℝ} + (ht : ∀ i ∈ s, ContinuousAt (t i) y) (hx : ∀ i ∈ s, x ≠ t i y) : + ∀ᶠ z in 𝓝 y, s.filter (fun i => t i z < x) = s.filter (fun i => t i y < x) := by + have hi (i : ι) (hi : i ∈ s) : ∀ᶠ z in 𝓝 y, (t i z < x ↔ t i y < x) := by + rcases lt_or_gt_of_ne (hx i hi) with h | h + · filter_upwards [(ht i hi).eventually (lt_mem_nhds h)] with z hz + exact iff_of_false (not_lt.mpr hz.le) (not_lt.mpr h.le) + · filter_upwards [(ht i hi).eventually (gt_mem_nhds h)] with z hz + exact iff_of_true hz h + filter_upwards [s.eventually_all.mpr hi] with z hz + ext i + simp only [Finset.mem_filter] + exact and_congr_right (fun hi => hz i hi) + +lemma continuousAt_threshold_integral (s : Finset ι) (t : ι → X → ℝ) (F : Finset ι → ℝ) + {y : X} (ht : ∀ i ∈ s, ContinuousAt (t i) y) {φ : ℝ → ℝ} (hφ : Integrable φ) : + ContinuousAt (fun z => ∫ x, φ x * F (s.filter (fun i => t i z < x))) y := by + let M : ℝ := ∑ a : Finset ι, |F a| + have hM (a : Finset ι) : |F a| ≤ M := by + exact Finset.single_le_sum (f := fun a : Finset ι => |F a|) (fun _ _ => abs_nonneg _) (Finset.mem_univ a) + apply continuousAt_of_dominated (bound := fun x => |φ x| * M) + · apply Filter.Eventually.of_forall + intro z + exact hφ.aestronglyMeasurable.mul ((measurable_filter_apply s + (fun i x => t i z < x) (fun _ => measurableSet_Ioi) F).aestronglyMeasurable) + · exact Filter.Eventually.of_forall (fun z => ae_of_all _ (fun x => by + simp only [Real.norm_eq_abs, abs_mul] + exact mul_le_mul_of_nonneg_left (hM _) (abs_nonneg _))) + · exact hφ.abs.mul_const M + · have hn : ∀ᵐ x : ℝ, ∀ i : ι, x ≠ t i y := ae_all_iff.mpr (fun i => volume.ae_ne (t i y)) + filter_upwards [hn] with x hx + have he := eventually_threshold_eq s t ht (fun i _ => hx i) + apply ContinuousAt.congr_of_eventuallyEq (by fun_prop : ContinuousAt (fun _ : X => φ x * F (s.filter (fun i => t i y < x))) y) + filter_upwards [he] with z hz + rw [hz] + +omit [Fintype ι] in +lemma threshold_integral (s : Finset ι) (t : ι → ℝ) (ht : Set.InjOn t s) + (F : Finset ι → ℝ) {φ : ℝ → ℝ} (hφ : Integrable φ) : + (∫ x, φ x * F (s.filter (fun i => t i < x))) = + (∫ x, φ x)*F ∅ + ∑ i ∈ s, (∫ x in Ioi (t i), φ x) * + (F (s.filter (fun j => t j ≤ t i))-F (s.filter (fun j => t j < t i))) := by + let Δ := fun i => F (s.filter (fun j => t j ≤ t i))-F (s.filter (fun j => t j < t i)) + have hi (i : ι) : Integrable (fun x => φ x * (if t i < x then Δ i else 0)) := by + have he : (fun x => φ x * (if t i < x then Δ i else 0)) = + (Ioi (t i)).indicator (fun x => φ x * Δ i) := by + funext x; by_cases hx : t i < x <;> simp [hx] + rw [he] + exact (hφ.mul_const _).indicator measurableSet_Ioi + have he (x : ℝ) : φ x * F (s.filter (fun i => t i < x)) = + φ x * F ∅ + ∑ i ∈ s, φ x * (if t i < x then Δ i else 0) := by + rw [threshold_decomposition s t ht F x, mul_add, Finset.mul_sum] + simp_rw [he] + rw [integral_add (hφ.mul_const _) (integrable_finsetSum _ (fun i _ => hi i)), + integral_mul_const, integral_finsetSum _ (fun i _ => hi i)] + congr 1 + apply Finset.sum_congr rfl + intro i hi' + have he : (fun x => φ x * (if t i < x then Δ i else 0)) = + (Ioi (t i)).indicator (fun x => φ x * Δ i) := by + funext x; by_cases hx : t i < x <;> simp [hx] + rw [he, integral_indicator measurableSet_Ioi, integral_mul_const] + +lemma tail_integral_hasDerivAt {φ : ℝ → ℝ} (hφ : Integrable φ) (hc : Continuous φ) (x : ℝ) : + HasDerivAt (fun t => ∫ z in Ioi t, φ z) (-φ x) x := by + have he (t : ℝ) : (∫ z in Ioi t, φ z) = (∫ z in Ioi (0:ℝ), φ z)-(∫ z in (0:ℝ)..t, φ z) := by + rw [← intervalIntegral.integral_Ioi_sub_Ioi' hφ.integrableOn hφ.integrableOn] + ring + rw [show (fun t => ∫ z in Ioi t, φ z) = (fun t => (∫ z in Ioi (0:ℝ), φ z)-(∫ z in (0:ℝ)..t, φ z)) from funext he] + exact (intervalIntegral.integral_hasDerivAt_right (hφ.intervalIntegrable) hc.stronglyMeasurable.stronglyMeasurableAtFilter hc.continuousAt).const_sub _ +end ContinuousEvents + +section Slope +variable [Fintype ι] + +omit [Fintype ι] in +lemma eventually_order_eq {X : Type u6} [TopologicalSpace X] (s : Finset ι) (t : ι → X → ℝ) {y : X} + (ht : ∀ i ∈ s, ContinuousAt (t i) y) (hi : Set.InjOn (fun i => t i y) s) : + ∀ᶠ z in 𝓝 y, Set.InjOn (fun i => t i z) s ∧ + ∀ i ∈ s, s.filter (fun j => t j z ≤ t i z) = s.filter (fun j => t j y ≤ t i y) ∧ + s.filter (fun j => t j z < t i z) = s.filter (fun j => t j y < t i y) := by + have hp (i : ι) (his : i ∈ s) (j : ι) (hjs : j ∈ s) : + ∀ᶠ z in 𝓝 y, (t i z < t j z ↔ t i y < t j y) := by + by_cases hij : i = j + · subst j; simp + have hne : t i y ≠ t j y := fun he => hij (hi his hjs he) + rcases hne.lt_or_gt with h | h + · filter_upwards [(ht i his).eventually_lt (ht j hjs) h] with z hz + exact iff_of_true hz h + · filter_upwards [(ht j hjs).eventually_lt (ht i his) h] with z hz + exact iff_of_false (not_lt.mpr hz.le) (not_lt.mpr h.le) + have hall : ∀ᶠ z in 𝓝 y, ∀ i ∈ s, ∀ j ∈ s, (t i z < t j z ↔ t i y < t j y) := + s.eventually_all.mpr (fun i his => s.eventually_all.mpr (fun j hjs => hp i his j hjs)) + filter_upwards [hall] with z hz + refine ⟨?_,?_⟩ + · intro i his j hjs he + change t i z=t j z at he + apply hi his hjs + apply le_antisymm + · apply not_lt.mp + intro h + have := (hz j hjs i his).mpr h + rw [he] at this + exact (lt_irrefl _ this) + · apply not_lt.mp + intro h + have := (hz i his j hjs).mpr h + rw [he] at this + exact (lt_irrefl _ this) + · intro i his + constructor <;> ext j <;> simp only [Finset.mem_filter] + · apply and_congr_right + intro hjs + simp only [← not_lt, hz i his j hjs] + · exact and_congr_right (fun hjs => hz j hjs i his) + +omit [Fintype ι] in +lemma moving_threshold_integral_hasDerivAt (s : Finset ι) (t : ι → ℝ → ℝ) + (F : Finset ι → ℝ) {y : ℝ} (t' : ι → ℝ) + (ht : ∀ i ∈ s, HasDerivAt (t i) (t' i) y) (hi : Set.InjOn (fun i => t i y) s) + {φ : ℝ → ℝ} (hφ : Integrable φ) (hc : Continuous φ) : + HasDerivAt (fun z => ∫ x, φ x * F (s.filter (fun i => t i z < x))) + (-∑ i ∈ s, t' i * φ (t i y) * + (F (s.filter (fun j => t j y ≤ t i y))-F (s.filter (fun j => t j y < t i y)))) y := by + 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)) + have he : (fun z => ∫ x, φ x * F (s.filter (fun i => t i z < x))) =ᶠ[𝓝 y] + (fun z => (∫ x, φ x)*F ∅ + ∑ i ∈ s, (∫ x in Ioi (t i z), φ x)*Δ i) := by + filter_upwards [eventually_order_eq s t (fun i his => (ht i his).continuousAt) hi] with z hz + rw [threshold_integral s (fun i => t i z) hz.1 F hφ] + congr 1 + apply Finset.sum_congr rfl + intro i his + rw [(hz.2 i his).1,(hz.2 i his).2] + have hd (i : ι) (his : i ∈ s) : HasDerivAt (fun z => (∫ x in Ioi (t i z), φ x)*Δ i) + (-(t' i * φ (t i y)*Δ i)) y := by + convert ((tail_integral_hasDerivAt hφ hc (t i y)).comp y (ht i his)).mul_const (Δ i) using 1 <;> try rfl + ring + have hs := (HasDerivAt.sum (fun i his => hd i his)).const_add ((∫ x, φ x)*F ∅) + simp only [Finset.sum_neg_distrib, Finset.sum_apply] at hs + exact hs.congr_of_eventuallyEq he + +end Slope + +section Weak +variable [Fintype ι] + +lemma integral_deriv_zero_off_countable {f f' : ℝ → ℝ} + (hf : Continuous f) (hs : HasCompactSupport f) (hs' : HasCompactSupport f') + (hi : Integrable f') {bad : Set ℝ} (hb : bad.Countable) + (hd : ∀ x ∉ bad, HasDerivAt f (f' x) x) : ∫ x, f' x = 0 := by + obtain ⟨R,hR,hbound⟩ := (hs.isCompact.union hs'.isCompact).isBounded.exists_pos_norm_lt + have hf0 {x : ℝ} (hx : R ≤ |x|) : f x=0 := by + apply image_eq_zero_of_notMem_tsupport + intro hm + have := hbound x (Or.inl hm) + simpa only [Real.norm_eq_abs] using not_lt.mpr hx this + have hf'0 {x : ℝ} (hx : R ≤ |x|) : f' x=0 := by + apply image_eq_zero_of_notMem_tsupport + intro hm + have := hbound x (Or.inr hm) + simpa only [Real.norm_eq_abs] using not_lt.mpr hx this + have hI := integral_eq_of_hasDerivAt_off_countable_of_le f f' (by linarith : -R ≤ R) + hb hf.continuousOn (fun x hx => hd x hx.2) hi.intervalIntegrable + rw [hf0 (by rw [abs_of_pos hR]), hf0 (by rw [abs_neg,abs_of_pos hR]),sub_self, + intervalIntegral.integral_of_le (by linarith)] at hI + rw [setIntegral_eq_integral_of_forall_compl_eq_zero (fun x hx => hf'0 (by + simp only [mem_Ioc,not_and_or,not_lt,not_le] at hx + rcases hx with hx | hx + · exact (neg_le_abs x).trans' (by linarith) + · exact (le_abs_self x).trans' hx.le))] at hI + exact hI + +omit [DecidableEq ι] in +lemma affine_collisions_countable (s : Finset ι) (a b : ι → ℝ) + (hab : ∀ i ∈ s, ∀ j ∈ s, i ≠ j → a i ≠ a j ∨ b i ≠ b j) : + {y : ℝ | ¬ Set.InjOn (fun i => a i*y+b i) s}.Countable := by + classical + have hp (i j : ι) : {y : ℝ | i ∈ s ∧ j ∈ s ∧ i ≠ j ∧ a i*y+b i=a j*y+b j}.Subsingleton := by + intro x hx y hy + have h := hab i hx.1 j hx.2.1 hx.2.2.1 + rcases h with h | h + · have he : (a i-a j)*(x-y)=0 := by nlinarith [hx.2.2.2,hy.2.2.2] + exact sub_eq_zero.mp ((mul_eq_zero.mp he).resolve_left (sub_ne_zero.mpr h)) + · by_cases ha : a i=a j + · exfalso; apply h; have he := hx.2.2.2; rw [ha] at he; linarith + · have he : (a i-a j)*(x-y)=0 := by nlinarith [hx.2.2.2,hy.2.2.2] + exact sub_eq_zero.mp ((mul_eq_zero.mp he).resolve_left (sub_ne_zero.mpr ha)) + apply (countable_iUnion (fun i => countable_iUnion (fun j => (hp i j).countable))).mono + intro y hy + simp only [mem_ofPred_eq,Set.InjOn,not_forall] at hy + obtain ⟨i,hi,j,hj,he,hne⟩ := hy + exact mem_iUnion.mpr ⟨i,mem_iUnion.mpr ⟨j,hi,hj,hne,he⟩⟩ + +lemma moving_threshold_weak (s : Finset ι) (a b : ι → ℝ) + (hab : ∀ i ∈ s, ∀ j ∈ s, i ≠ j → a i ≠ a j ∨ b i ≠ b j) + (F : Finset ι → ℝ) {φ χ χ' : ℝ → ℝ} + (hφ : Integrable φ) (hcφ : Continuous φ) (hcχ : Continuous χ) + (hsχ : HasCompactSupport χ) (hsχ' : HasCompactSupport χ') + (hdχ : ∀ y, HasDerivAt χ (χ' y) y) + (hi₁ : Integrable (fun y => χ' y * ∫ x, φ x * F (s.filter (fun i => a i*y+b i < x)))) + (hi₂ : Integrable (fun y => χ y * ∑ i ∈ s, a i * φ (a i*y+b i) * + (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))))) : + (∫ y, χ' y * ∫ x, φ x * F (s.filter (fun i => a i*y+b i < x))) = + ∫ y, χ y * ∑ i ∈ s, a i * φ (a i*y+b i) * + (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 + let H := fun y => ∫ x, φ x * F (s.filter (fun i => a i*y+b i < x)) + let D := fun y => ∑ i ∈ s, a i * φ (a i*y+b i) * + (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))) + have hH : Continuous H := continuous_iff_continuousAt.mpr (fun y => + continuousAt_threshold_integral s (fun i y => a i*y+b i) F (fun _ _ => by fun_prop) hφ) + have hprod : HasCompactSupport (fun y => χ y * H y) := hsχ.mul_right + have hder : HasCompactSupport (fun y => χ' y * H y-χ y * D y) := + hsχ'.mul_right.sub hsχ.mul_right + have hzero := integral_deriv_zero_off_countable (hcχ.mul hH) hprod hder (hi₁.sub hi₂) + (affine_collisions_countable s a b hab) (fun y hy => by + have hdy := moving_threshold_integral_hasDerivAt s (fun i y => a i*y+b i) F a + (fun i _ => by simpa using ((hasDerivAt_id y).const_mul (a i)).add_const (b i)) + (not_not.mp hy) hφ hcφ + convert (hdχ y).mul hdy using 1 + dsimp [D] + ring) + rw [integral_sub hi₁ hi₂,sub_eq_zero] at hzero + exact hzero + +end Weak + +section Lipschitz +variable [Fintype ι] + +lemma threshold_integrable (s : Finset ι) (t : ι → ℝ) (F : Finset ι → ℝ) + {φ : ℝ → ℝ} (hφ : Integrable φ) : + Integrable (fun x => φ x * F (s.filter (fun i => t i < x))) := by + classical + let M := ∑ a : Finset ι, |F a| + apply hφ.mul_bdd (measurable_filter_apply s (fun i x => t i < x) + (fun _ => measurableSet_Ioi) F).aestronglyMeasurable + apply ae_of_all + intro x + exact Finset.single_le_sum (f := fun a : Finset ι => |F a|) (fun _ _ => abs_nonneg _) (Finset.mem_univ _) + +lemma threshold_pointwise_bound (s : Finset ι) (t u : ι → ℝ) (F : Finset ι → ℝ) + {M : ℝ} (hM0 : 0 ≤ M) (hM : ∀ a, |F a| ≤ M) (x : ℝ) : + |F (s.filter (fun i => t i < x))-F (s.filter (fun i => u i < x))| ≤ + 2*M*∑ i ∈ s, (uIoc (t i) (u i)).indicator (fun _ => (1:ℝ)) x := by + classical + have hn (i : ι) : 0 ≤ (uIoc (t i) (u i)).indicator (fun _ => (1:ℝ)) x := by + by_cases hx : x ∈ uIoc (t i) (u i) <;> simp [hx] + by_cases he : ∀ i ∈ s, t i < x ↔ u i < x + · have he' : s.filter (fun i => t i < x) = s.filter (fun i => u i < x) := by + ext i; simp only [Finset.mem_filter]; exact and_congr_right (he i) + rw [he',sub_self,abs_zero] + exact mul_nonneg (by positivity) (Finset.sum_nonneg (fun i _ => hn i)) + · simp only [not_forall] at he + obtain ⟨i,his,hi⟩ := he + have hx : x ∈ uIoc (t i) (u i) := by + change min (t i) (u i) < x ∧ x ≤ max (t i) (u i) + rcases lt_or_ge (t i) x with ht | ht <;> rcases lt_or_ge (u i) x with hu | hu + · exact False.elim (hi (iff_of_true ht hu)) + · exact ⟨(min_le_left _ _).trans_lt ht,hu.trans (le_max_right _ _)⟩ + · exact ⟨(min_le_right _ _).trans_lt hu,ht.trans (le_max_left _ _)⟩ + · exact False.elim (hi (iff_of_false (not_lt.mpr ht) (not_lt.mpr hu))) + have hs : 1 ≤ ∑ i ∈ s, (uIoc (t i) (u i)).indicator (fun _ => (1:ℝ)) x := by + have hh := Finset.single_le_sum (fun j _ => hn j) his + simpa [hx] using hh + calc + _ ≤ |F (s.filter (fun i => t i < x))|+|F (s.filter (fun i => u i < x))| := abs_sub _ _ + _ ≤ 2*M := by linarith [hM (s.filter (fun i => t i < x)),hM (s.filter (fun i => u i < x))] + _ ≤ _ := le_mul_of_one_le_right (by positivity) hs + +lemma threshold_integral_diff_bound (s : Finset ι) (t u : ι → ℝ) (F : Finset ι → ℝ) + {φ : ℝ → ℝ} (hφ : Integrable φ) {M C : ℝ} (hM0 : 0 ≤ M) (hC : 0 ≤ C) + (hM : ∀ a, |F a| ≤ M) (hφC : ∀ x, |φ x| ≤ C) : + |(∫ x, φ x * F (s.filter (fun i => t i < x)))- + (∫ x, φ x * F (s.filter (fun i => u i < x)))| ≤ + 2*M*C*∑ i ∈ s, |u i-t i| := by + classical + let I := fun i x => (uIoc (t i) (u i)).indicator (fun _ => (1:ℝ)) x + have hi (i : ι) : Integrable (I i) := by + 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)) + have hiS : Integrable (fun x => 2*M*C*∑ i ∈ s, I i x) := + (integrable_finsetSum s (fun i _ => hi i)).const_mul _ + have hbound (x : ℝ) : ‖φ x*(F (s.filter (fun i => t i < x))-F (s.filter (fun i => u i < x)))‖ ≤ + 2*M*C*∑ i ∈ s, I i x := by + rw [Real.norm_eq_abs,abs_mul] + have hp := mul_le_mul (hφC x) (threshold_pointwise_bound s t u F hM0 hM x) (abs_nonneg _) hC + dsimp [I] + convert hp using 1 + first | rfl | ring + rw [← integral_sub (threshold_integrable s t F hφ) (threshold_integrable s u F hφ)] + simp_rw [← mul_sub] + calc + _ ≤ ∫ x, 2*M*C*∑ i ∈ s, I i x := by + simpa only [Real.norm_eq_abs] using norm_integral_le_of_norm_le hiS (ae_of_all _ hbound) + _ = 2*M*C*∑ i ∈ s, |u i-t i| := by + rw [integral_const_mul,integral_finsetSum s (fun i _ => hi i)] + congr 1 + apply Finset.sum_congr rfl + intro i _ + dsimp [I] + change (∫ x, (uIoc (t i) (u i)).indicator (1 : ℝ → ℝ) x) = _ + rw [integral_indicator_one measurableSet_uIoc,measureReal_def,Real.volume_uIoc,ENNReal.toReal_ofReal (abs_nonneg _)] + +end Lipschitz + +section FDeriv +variable [Fintype ι] +variable {X : Type u7} [NormedAddCommGroup X] [NormedSpace ℝ X] + +omit [Fintype ι] in +lemma moving_threshold_integral_hasFDerivAt (s : Finset ι) (t : ι → X → ℝ) + (F : Finset ι → ℝ) {y : X} (t' : ι → X →L[ℝ] ℝ) + (ht : ∀ i ∈ s, HasFDerivAt (t i) (t' i) y) (hi : Set.InjOn (fun i => t i y) s) + {φ : ℝ → ℝ} (hφ : Integrable φ) (hc : Continuous φ) : + HasFDerivAt (fun z => ∫ x, φ x * F (s.filter (fun i => t i z < x))) + (∑ i ∈ s, (-(φ (t i y) * + (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 + 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)) + have he : (fun z => ∫ x, φ x * F (s.filter (fun i => t i z < x))) =ᶠ[𝓝 y] + (fun z => (∫ x, φ x)*F ∅ + ∑ i ∈ s, (∫ x in Ioi (t i z), φ x)*Δ i) := by + filter_upwards [eventually_order_eq s t (fun i his => (ht i his).continuousAt) hi] with z hz + rw [threshold_integral s (fun i => t i z) hz.1 F hφ] + congr 1 + apply Finset.sum_congr rfl + intro i his + rw [(hz.2 i his).1,(hz.2 i his).2] + have hd (i : ι) (his : i ∈ s) : HasFDerivAt (fun z => (∫ x in Ioi (t i z), φ x)*Δ i) + (-(φ (t i y)*Δ i) • t' i) y := by + convert ((tail_integral_hasDerivAt hφ hc (t i y)).comp_hasFDerivAt y (ht i his)).mul_const (Δ i) using 1 <;> try rfl + simp only [smul_smul] + congr 1; ring + have hs := (HasFDerivAt.sum (fun i his => hd i his)).const_add ((∫ x, φ x)*F ∅) + simp only [Finset.sum_apply] at hs + exact hs.congr_of_eventuallyEq he + +lemma affine_threshold_lipschitz (s : Finset ι) (L : ι → X →L[ℝ] ℝ) (b : ι → ℝ) + (F : Finset ι → ℝ) {φ : ℝ → ℝ} (hφ : Integrable φ) + {M C : ℝ} (hM0 : 0 ≤ M) (hC : 0 ≤ C) (hM : ∀ a, |F a| ≤ M) (hφC : ∀ x, |φ x| ≤ C) : + LipschitzWith (Real.nnabs (2*M*C*∑ i ∈ s, ‖L i‖)) + (fun y => ∫ x, φ x * F (s.filter (fun i => L i y+b i < x))) := by + apply LipschitzWith.of_dist_le_mul + intro y z + simp only [dist_eq_norm] + 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 + simp only [Real.norm_eq_abs] at ⊢ + refine hb.trans ?_ + have hs : (∑ i ∈ s, |L i z+b i-(L i y+b i)|) ≤ (∑ i ∈ s, ‖L i‖)*‖y-z‖ := by + rw [Finset.sum_mul] + apply Finset.sum_le_sum + intro i _ + have ht := (L i).le_opNorm (z-y) + simpa only [map_sub, Real.norm_eq_abs, add_sub_add_right_eq_sub, norm_sub_rev z y] using ht + 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) + +end FDeriv + +end UniformSparsestCut.InterfaceStep + +namespace UniformSparsestCut.InterfaceStep +open MeasureTheory Set +open scoped BigOperators Topology +variable {ι : Type u8} {X : Type u9} {Z : Type u10} [DecidableEq ι] [Fintype ι] + [NormedAddCommGroup X] [NormedSpace ℝ X] [MeasurableSpace Z] + +lemma averaged_threshold_derivative (s : Finset ι) (L : ι → X →L[ℝ] ℝ) + (b : ι → Z → ℝ) (hb : ∀ i, Measurable (b i)) (F : Finset ι → ℝ) + {φ : ℝ → ℝ} (hφ : Integrable φ) (hc : Continuous φ) + {M C : ℝ} (hM0 : 0 ≤ M) (hC : 0 ≤ C) (hM : ∀ a, |F a| ≤ M) (hφC : ∀ x, |φ x| ≤ C) + (μ : Measure Z) [IsFiniteMeasure μ] (y : X) + (hi : ∀ᵐ z ∂μ, Set.InjOn (fun i => L i y+b i z) s) : + HasFDerivAt (fun y => ∫ z, (∫ x, φ x * F (s.filter (fun i => L i y+b i z < x))) ∂μ) + (∑ i ∈ s, (∫ z, -(φ (L i y+b i z) * + (F (s.filter (fun j => L j y+b j z ≤ L i y+b i z))- + F (s.filter (fun j => L j y+b j z < L i y+b i z)))) ∂μ) • L i) y := by + let H : X → Z → ℝ := fun y z => ∫ x, φ x * F (s.filter (fun i => L i y+b i z < x)) + let c : ι → Z → ℝ := fun i z => -(φ (L i y+b i z) * + (F (s.filter (fun j => L j y+b j z ≤ L i y+b i z))- + F (s.filter (fun j => L j y+b j z < L i y+b i z)))) + have hmH (y : X) : StronglyMeasurable (H y) := by + apply StronglyMeasurable.integral_prod_right + apply Measurable.stronglyMeasurable + exact (hc.measurable.comp measurable_snd).mul (measurable_filter_apply s + (fun i (p : Z × ℝ) => L i y+b i p.1 < p.2) + (fun i => measurableSet_lt ((measurable_const.add ((hb i).comp measurable_fst))) measurable_snd) F) + have hmC (i : ι) : Measurable (c i) := by + apply Measurable.neg + apply Measurable.mul (hc.measurable.comp (measurable_const.add (hb i))) + exact (measurable_filter_apply s (fun j z => L j y+b j z ≤ L i y+b i z) + (fun j => measurableSet_le (measurable_const.add (hb j)) (measurable_const.add (hb i))) F).sub + (measurable_filter_apply s (fun j z => L j y+b j z < L i y+b i z) + (fun j => measurableSet_lt (measurable_const.add (hb j)) (measurable_const.add (hb i))) F) + have hcB (i : ι) (z : Z) : ‖c i z‖ ≤ C*(2*M) := by + dsimp [c] + simp only [abs_neg,abs_mul] + have hd := abs_sub_le (F (s.filter (fun j => L j y+b j z ≤ L i y+b i z))) 0 + (F (s.filter (fun j => L j y+b j z < L i y+b i z))) + simp only [sub_zero,zero_sub,abs_neg] at hd + apply mul_le_mul (hφC _) _ (abs_nonneg _) hC + linarith [hM (s.filter (fun j => L j y+b j z ≤ L i y+b i z)), + hM (s.filter (fun j => L j y+b j z < L i y+b i z))] + have hiC (i : ι) : Integrable (c i) μ := + (integrable_const (C*(2*M))).mono' (hmC i).aestronglyMeasurable (ae_of_all _ (hcB i)) + have hiH : Integrable (H y) μ := by + apply (integrable_const (∫ x, |φ x| * M)).mono' (hmH y).aestronglyMeasurable + filter_upwards with z + apply norm_integral_le_of_norm_le (hφ.abs.mul_const M) + filter_upwards with x + rw [Real.norm_eq_abs,abs_mul] + exact mul_le_mul_of_nonneg_left (hM _) (abs_nonneg _) + let K : NNReal := Real.nnabs (2*M*C*∑ i ∈ s, ‖L i‖) + have hLip (z : Z) : LipschitzWith K (fun y => H y z) := + affine_threshold_lipschitz s L (fun i => b i z) F hφ hM0 hC hM hφC + have hD : ∀ᵐ z ∂μ, HasFDerivAt (fun y => H y z) (∑ i ∈ s, c i z • L i) y := by + filter_upwards [hi] with z hz + exact moving_threshold_integral_hasFDerivAt s (fun i y => L i y+b i z) F L + (fun i _ => (L i).hasFDerivAt.add_const _) hz hφ hc + have hres := hasFDerivAt_integral_of_dominated_loc_of_lip (μ := μ) (F := H) + (s := Set.univ) (bound := fun _ => (K : ℝ)) (F' := fun z => ∑ i ∈ s, c i z • L i) + (Filter.univ_mem) (Filter.Eventually.of_forall (fun x => (hmH x).aestronglyMeasurable)) hiH + (by + have hm := (Finset.stronglyMeasurable_sum s (fun i _ => (hmC i).stronglyMeasurable.smul_const (L i))).aestronglyMeasurable (μ := μ) + have he : (∑ i ∈ s, (fun z => c i z • L i)) = (fun z => ∑ i ∈ s, c i z • L i) := by + funext z; exact Finset.sum_apply z s _ + rw [he] at hm + exact hm) + (ae_of_all _ (fun z => by simpa using (hLip z).lipschitzOnWith (s := Set.univ))) + (integrable_const _) hD + rw [integral_finsetSum s (fun i _ => (hiC i).smul_const (L i))] at hres + simp only [integral_smul_const] at hres + exact hres.2 + +end UniformSparsestCut.InterfaceStep + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SparsestCut/KernelApprox.lean b/lean/OAI/Combinatorics/SparsestCut/KernelApprox.lean new file mode 100644 index 0000000000000000000000000000000000000000..51f7d752ebce3ae366d8fa0b34dfb830af543cd6 --- /dev/null +++ b/lean/OAI/Combinatorics/SparsestCut/KernelApprox.lean @@ -0,0 +1,184 @@ +import OAI.Combinatorics.SparsestCut.PositiveKernels + +namespace OAI + +open scoped BigOperators Topology NNReal RealInnerProductSpace InnerProductSpace Matrix ContDiff ENNReal +open MeasureTheory ProbabilityTheory Set Filter Matrix + +noncomputable section + +namespace UniformSparsestCut.KernelApprox + +def profile (t : ℝ) : ℝ := 1 - Real.exp (-1/(2*t^2)) + +lemma profile_nonneg (t : ℝ) : 0 ≤ profile t := by + unfold profile + have h : -1/(2*t^2) ≤ 0 := div_nonpos_of_nonpos_of_nonneg (by norm_num) (by positivity) + linarith [Real.exp_le_one_iff.mpr h] + +lemma profile_le_one (t : ℝ) : profile t ≤ 1 := by + unfold profile + linarith [Real.exp_pos (-1/(2*t^2))] + +lemma profile_le_inv_sq (t : ℝ) : profile t ≤ 1/(2*t^2) := by + have h := Real.add_one_le_exp (-1/(2*t^2)) + unfold profile + rw [neg_div] at h ⊢ + linarith + +lemma profile_pos {t : ℝ} (ht : t ≠ 0) : 0 < profile t := by + unfold profile + have h : -1/(2*t^2) < 0 := div_neg_of_neg_of_pos (by norm_num) (by positivity) + linarith [Real.exp_lt_one_iff.mpr h] + +lemma profile_measurable : Measurable profile := by unfold profile; fun_prop + +lemma profile_integrable_lower : IntegrableOn profile (Ioc 0 1) := by + apply (integrableOn_const (C := (1 : ℝ)) (s := Ioc (0 : ℝ) 1) (by simp)).mono' + profile_measurable.aestronglyMeasurable + filter_upwards with t + simpa only [Real.norm_eq_abs, abs_of_nonneg (profile_nonneg t)] using profile_le_one t + +lemma profile_integrable_upper : IntegrableOn profile (Ioi 1) := by + have hi := (integrableOn_Ioi_rpow_of_lt (by norm_num : (-2 : ℝ) < -1) + (by norm_num : (0 : ℝ) < 1)).const_mul (1/2 : ℝ) + apply hi.mono' profile_measurable.aestronglyMeasurable + filter_upwards [ae_restrict_mem measurableSet_Ioi] with t ht + change 1 < t at ht + have he : (1/2 : ℝ)*t^(-2 : ℝ) = 1/(2*t^2) := by + rw [Real.rpow_neg (by linarith : 0 ≤ t), Real.rpow_two] + ring + simpa only [Real.norm_eq_abs, abs_of_nonneg (profile_nonneg t), he] using profile_le_inv_sq t + +lemma profile_integrable : IntegrableOn profile (Ioi 0) := by + have h := profile_integrable_lower.union profile_integrable_upper + simpa only [Ioc_union_Ioi_eq_Ioi (by norm_num : (0 : ℝ) ≤ 1)] using h + +noncomputable def cstar : ℝ := 2 * ∫ t in Ioi (0 : ℝ), profile t + +lemma cstar_pos : 0 < cstar := by + have hp : 0 < ∫ t in Ioi (0 : ℝ), profile t := by + apply (integral_pos_iff_support_of_nonneg_ae _ profile_integrable).mpr + · have hs : Ioi (0 : ℝ) ⊆ Function.support profile := by + intro t ht + exact ne_of_gt (profile_pos (ne_of_gt ht)) + have hc : (volume.restrict (Ioi (0 : ℝ))) (Ioi (0 : ℝ)) ≠ 0 := by simp + exact bot_lt_iff_ne_bot.mpr (ne_bot_of_le_ne_bot hc (measure_mono hs)) + · filter_upwards with t using profile_nonneg t + exact mul_pos (by norm_num) hp + +def scaled (r t : ℝ) : ℝ := 1-Real.exp (-r^2/(2*t^2)) + +lemma scaled_eq_profile (r t : ℝ) : scaled r t = profile (t/r) := by + by_cases hr : r = 0 + · simp [hr, scaled, profile] + by_cases ht : t = 0 + · simp [ht, scaled, profile] + unfold scaled profile + congr 2 + field_simp + +lemma scaled_nonneg (r t : ℝ) : 0 ≤ scaled r t := by + rw [scaled_eq_profile]; exact profile_nonneg _ + +lemma scaled_le_one (r t : ℝ) : scaled r t ≤ 1 := by + rw [scaled_eq_profile]; exact profile_le_one _ + +lemma scaled_le_tail (r t : ℝ) : scaled r t ≤ r^2/(2*t^2) := by + have h := Real.add_one_le_exp (-r^2/(2*t^2)) + unfold scaled + rw [neg_div] at h ⊢ + linarith + +lemma scaled_measurable (r : ℝ) : Measurable (scaled r) := by unfold scaled; fun_prop + +lemma scaled_integrable_lower (r : ℝ) {a : ℝ} (_ha : 0 ≤ a) : + IntegrableOn (scaled r) (Ioc 0 a) := by + apply (integrableOn_const (C := (1 : ℝ)) (s := Ioc (0 : ℝ) a) (by simp)).mono' + (scaled_measurable r).aestronglyMeasurable + filter_upwards with t + simpa only [Real.norm_eq_abs, abs_of_nonneg (scaled_nonneg r t)] using scaled_le_one r t + +lemma scaled_integrable_upper (r : ℝ) {a : ℝ} (ha : 0 < a) : + IntegrableOn (scaled r) (Ioi a) := by + have hi := (integrableOn_Ioi_rpow_of_lt (by norm_num : (-2 : ℝ) < -1) ha).const_mul (r^2/2) + apply hi.mono' (scaled_measurable r).aestronglyMeasurable + filter_upwards [ae_restrict_mem measurableSet_Ioi] with t ht + change a < t at ht + have he : (r^2/2)*t^(-2 : ℝ) = r^2/(2*t^2) := by + rw [Real.rpow_neg (by linarith : 0 ≤ t), Real.rpow_two] + ring + simpa only [Real.norm_eq_abs, abs_of_nonneg (scaled_nonneg r t), he] using scaled_le_tail r t + +lemma scaled_integrable (r : ℝ) : IntegrableOn (scaled r) (Ioi 0) := by + have h := (scaled_integrable_lower r (by norm_num : (0 : ℝ) ≤ 1)).union + (scaled_integrable_upper r (by norm_num : (0 : ℝ) < 1)) + simpa only [Ioc_union_Ioi_eq_Ioi (by norm_num : (0 : ℝ) ≤ 1)] using h + +lemma full_integral {r : ℝ} (hr : 0 ≤ r) : + 2 * (∫ t in Ioi (0 : ℝ), scaled r t) = cstar*r := by + rcases eq_or_lt_of_le hr with hz | hr + · simp [← hz, scaled] + simp_rw [scaled_eq_profile, div_eq_inv_mul] + rw [integral_comp_mul_left_Ioi profile 0 (inv_pos.mpr hr)] + simp only [mul_zero, inv_inv, smul_eq_mul, cstar] + ring + +lemma lower_tail_bound (r : ℝ) {a : ℝ} (ha : 0 ≤ a) : + (∫ t in Ioc (0 : ℝ) a, scaled r t) ≤ a := by + have h := integral_mono (scaled_integrable_lower r ha) + (integrableOn_const (C := (1 : ℝ)) (s := Ioc (0 : ℝ) a) (by simp)) + (fun t => scaled_le_one r t) + simpa [integral_const, Real.volume_real_Ioc, ha] using h + +lemma upper_tail_bound (r : ℝ) {b : ℝ} (hb : 0 < b) : + (∫ t in Ioi b, scaled r t) ≤ r^2/(2*b) := by + have hi := (integrableOn_Ioi_rpow_of_lt (by norm_num : (-2 : ℝ) < -1) hb).const_mul (r^2/2) + calc + _ ≤ ∫ t in Ioi b, (r^2/2)*t^(-2 : ℝ) := by + apply integral_mono_ae (scaled_integrable_upper r hb) hi + filter_upwards [ae_restrict_mem measurableSet_Ioi] with t ht + change b < t at ht + rw [Real.rpow_neg (by linarith : 0 ≤ t), Real.rpow_two] + exact (scaled_le_tail r t).trans_eq (by ring) + _ = _ := by + rw [integral_const_mul, integral_Ioi_rpow_of_lt (by norm_num : (-2 : ℝ) < -1) hb] + norm_num + rw [Real.rpow_neg_one] + ring + +lemma truncated_error {r a b : ℝ} (hr : 0 ≤ r) (ha : 0 < a) (hab : a ≤ b) : + |2 * (∫ t in Ioc a b, scaled r t) - cstar*r| ≤ 2*a + r^2/b := by + have hb : 0 < b := ha.trans_le hab + have hi1 := scaled_integrable_lower r ha.le + have hi2 : IntegrableOn (scaled r) (Ioc a b) := + (scaled_integrable r).mono_set (fun t ht => ha.trans ht.1) + have hi3 := scaled_integrable_upper r hb + have he : (∫ t in Ioi (0 : ℝ), scaled r t) = + (∫ t in Ioc (0 : ℝ) a, scaled r t) + (∫ t in Ioc a b, scaled r t) + + ∫ t in Ioi b, scaled r t := by + rw [← Ioc_union_Ioi_eq_Ioi hb.le, setIntegral_union] + · rw [← Ioc_union_Ioc_eq_Ioc ha.le hab, setIntegral_union] + · exact Ioc_disjoint_Ioc_of_le le_rfl + · exact measurableSet_Ioc + · exact hi1 + · exact hi2 + · exact Ioc_disjoint_Ioi_same + · exact measurableSet_Ioi + · exact scaled_integrable_lower r hb.le + · exact hi3 + have hx := full_integral hr + rw [he] at hx + have hn1 : 0 ≤ ∫ t in Ioc (0 : ℝ) a, scaled r t := integral_nonneg (fun _ => scaled_nonneg _ _) + have hn3 : 0 ≤ ∫ t in Ioi b, scaled r t := integral_nonneg (fun _ => scaled_nonneg _ _) + have hu1 := lower_tail_bound r ha.le + have hu3 := upper_tail_bound r hb + have he' : r^2/b = 2*(r^2/(2*b)) := by ring + rw [abs_of_nonpos (by linarith), he'] + linarith + +end UniformSparsestCut.KernelApprox + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SparsestCut/LabelCount.lean b/lean/OAI/Combinatorics/SparsestCut/LabelCount.lean new file mode 100644 index 0000000000000000000000000000000000000000..60ca8cf99c1b49afbfb063d72febd64e948c9c63 --- /dev/null +++ b/lean/OAI/Combinatorics/SparsestCut/LabelCount.lean @@ -0,0 +1,129 @@ +import OAI.Combinatorics.SparsestCut.WeightedMetric + +namespace OAI + +open scoped BigOperators Topology NNReal RealInnerProductSpace InnerProductSpace Matrix ContDiff ENNReal +open MeasureTheory ProbabilityTheory Set Filter Matrix + +noncomputable section + +namespace UniformSparsestCut.LabelCount +open scoped BigOperators RealInnerProductSpace +open UniformSparsestCut +variable {m N : ℕ} +local notation "E" => EuclideanSpace ℝ (Fin m) + +def signature (B : ℤ) (l : Fin N → ℤ) : Finset (Fin N × ↥(Finset.Icc (-B) B)) := + Finset.univ.filter (fun p => p.2.val ≤ l p.1) + +lemma signature_injective (B : ℤ) (A : Finset (Fin N → ℤ)) + (hA : ∀ l ∈ A, ∀ i, l i ∈ Finset.Icc (-B) B) : + Set.InjOn (signature B) (↑A : Set (Fin N → ℤ)) := by + intro l hl k hk he + funext i + apply le_antisymm + · have hm : (i,⟨l i,hA l hl i⟩) ∈ signature B l := by simp [signature] + rw [he] at hm + simpa [signature] using hm + · have hm : (i,⟨k i,hA k hk i⟩) ∈ signature B k := by simp [signature] + rw [← he] at hm + simpa [signature] using hm + +lemma regular_floor_iff (u : Fin N → E) {τ : ℝ} (hτ : 0 < τ) + {θ : E} (hθ : RoundedCharts.regular u τ θ) (i : Fin N) (k : ℤ) : + k ≤ RoundedCharts.integerLabel u τ θ i ↔ (k:ℝ)*τ < inner ℝ (u i) θ := by + rw [RoundedCharts.integerLabel, Int.le_floor] + rw [le_div_iff₀ hτ] + exact ⟨fun h => lt_of_le_of_ne h (Ne.symm (hθ i k)), le_of_lt⟩ + +def affineForm (u : Fin N → E) (τ : ℝ) (B : ℤ) + (p : Fin N × ↥(Finset.Icc (-B) B)) : E × ℝ →ₗ[ℝ] ℝ := + (innerSL ℝ (u p.1)).toLinearMap.comp (LinearMap.fst ℝ E ℝ) - + ((p.2.val:ℝ)*τ) • LinearMap.snd ℝ E ℝ + +lemma label_count (u : Fin N → E) {τ : ℝ} (hτ : 0 < τ) (B : ℤ) + (A : Finset (Fin N → ℤ)) + (hb : ∀ l ∈ A, ∀ i, l i ∈ Finset.Icc (-B) B) + (hA : ∀ l ∈ A, ∃ θ : E, RoundedCharts.regular u τ θ ∧ RoundedCharts.integerLabel u τ θ = l) : + A.card ≤ ∑ j ∈ Finset.Iic (m+1), (N*(Finset.Icc (-B) B).card).choose j := by + let P := A.image (signature B) + have hP : ∀ p ∈ P, ∃ θ : E × ℝ, ∀ i, + affineForm u τ B i θ ≠ 0 ∧ (0 < affineForm u τ B i θ ↔ i ∈ p) := by + intro p hp + obtain ⟨l,hl,rfl⟩ := Finset.mem_image.mp hp + obtain ⟨θ,hr,hθ⟩ := hA l hl + refine ⟨(θ,1),?_⟩ + intro i + have he : affineForm u τ B i (θ,1) = inner ℝ (u i.1) θ-(i.2.val:ℝ)*τ := by + simp [affineForm] + rw [he] + refine ⟨sub_ne_zero.mpr (hr _ _),?_⟩ + rw [sub_pos, ← regular_floor_iff u hτ hr,hθ] + simp [signature] + have hc := HyperplaneCount.sign_patterns_bound (affineForm u τ B) P hP + have hdim : Module.finrank ℝ (E × ℝ) = m+1 := by simp [Module.finrank_prod] + have hcard : Fintype.card (Fin N × ↥(Finset.Icc (-B) B)) = N*(Finset.Icc (-B) B).card := by simp + rw [hdim,hcard] at hc + rwa [Finset.card_image_of_injOn (signature_injective B A hb)] at hc + +end UniformSparsestCut.LabelCount + +namespace UniformSparsestCut.LabelCount +open scoped BigOperators +noncomputable section +lemma power_sum_le (H d : ℕ) : (∑ j∈Finset.range (d+1), H^j)≤(H+1)^d := by + induction d with + | zero => simp + | succ d ih => + rw [Finset.sum_range_succ] + calc + _ ≤ (H+1)^d+H^(d+1) := Nat.add_le_add_right ih _ + _ ≤ (H+1)^d+(H+1)^d*H := by + rw [pow_succ] + gcongr + omega + _ = (H+1)^(d+1) := by ring +lemma binomial_sum_le (H d : ℕ) : (∑ j∈Finset.Iic d, H.choose j)≤(H+1)^d := by + have he : Finset.Iic d=Finset.range (d+1) := by ext j; simp + rw [he] + exact (Finset.sum_le_sum (fun j _ => Nat.choose_le_pow H j)).trans (power_sum_le H d) +variable {m N S : ℕ} +local notation "E" => EuclideanSpace ℝ (Fin m) +lemma vertex_count (u : Fin S → Fin N → E) {τ : ℝ} (hτ : 0<τ) + [Fintype (RoundedCharts.Vertex u τ)] (B : ℤ) + (hb : ∀ v : RoundedCharts.Vertex u τ, ∀ i, v.val.2 i∈Finset.Icc (-B) B) : + Fintype.card (RoundedCharts.Vertex u τ)≤S*(N*(Finset.Icc (-B) B).card+1)^(m+1) := by + classical + let T (s : Fin S) := Finset.univ.filter (fun v : RoundedCharts.Vertex u τ => v.val.1=s) + let A (s : Fin S) := (T s).image (fun v => v.val.2) + have hcard (s : Fin S) : (T s).card=(A s).card := by + apply (Finset.card_image_of_injOn _).symm + intro v hv w hw h + apply Subtype.ext + apply Prod.ext + · exact (Finset.mem_filter.mp hv).2.trans (Finset.mem_filter.mp hw).2.symm + · exact h + have hs (s : Fin S) : (T s).card≤(N*(Finset.Icc (-B) B).card+1)^(m+1) := by + rw [hcard] + apply (label_count (u s) hτ B (A s) ?_ ?_).trans (binomial_sum_le _ _) + · intro l hl i + obtain ⟨v,hv,rfl⟩ := Finset.mem_image.mp hl + exact hb v i + · intro l hl + obtain ⟨v,hv,rfl⟩ := Finset.mem_image.mp hl + obtain ⟨θ,hθ,hr,hl⟩ := v.property + have he : v.val.1=s := (Finset.mem_filter.mp hv).2 + exact ⟨θ,by simpa only [← he] using hr,by simpa only [← he] using hl⟩ + calc + _ = ∑ s, (T s).card := by + simpa only [Finset.card_univ] using (Finset.card_eq_sum_card_fiberwise + (f := fun v : RoundedCharts.Vertex u τ => v.val.1) + (s := Finset.univ) (t := Finset.univ) (fun _ _ => Finset.mem_univ _)) + _ ≤ ∑ _s : Fin S, (N*(Finset.Icc (-B) B).card+1)^(m+1) := Finset.sum_le_sum (fun s _ => hs s) + _ = _ := by simp +end +end UniformSparsestCut.LabelCount + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SparsestCut/LatticeDensity.lean b/lean/OAI/Combinatorics/SparsestCut/LatticeDensity.lean new file mode 100644 index 0000000000000000000000000000000000000000..3d386980bbab12f79f41475efe27d2041e4504ce --- /dev/null +++ b/lean/OAI/Combinatorics/SparsestCut/LatticeDensity.lean @@ -0,0 +1,125 @@ +import OAI.Combinatorics.SparsestCut.ProductSlice + +namespace OAI + +open scoped BigOperators Topology NNReal RealInnerProductSpace InnerProductSpace Matrix ContDiff ENNReal +open MeasureTheory ProbabilityTheory Set Filter Matrix + +noncomputable section + +namespace UniformSparsestCut.LatticeDensity + +lemma cell_bound {h h' : ℝ → ℝ} {a b : ℝ} (hab : a ≤ b) + (hd : ∀ t, HasDerivAt h (h' t) t) (hi : IntervalIntegrable h' volume a b) : + (b-a)*h a ≤ (∫ t in a..b, h t)+(b-a)*(∫ t in a..b, |h' t|) := by + have hc : Continuous h := continuous_iff_continuousAt.mpr (fun t => (hd t).continuousAt) + have hh : ∀ t ∈ Icc a b, h a ≤ h t+∫ x in a..b, |h' x| := by + intro t ht + have hid : IntervalIntegrable h' volume a t := hi.mono_set (by + rw [uIcc_of_le ht.1, uIcc_of_le hab] + exact Icc_subset_Icc le_rfl ht.2) + have he := intervalIntegral.integral_eq_sub_of_hasDerivAt (fun x _ => hd x) hid + have hm : (∫ x in a..t, |h' x|) ≤ ∫ x in a..b, |h' x| := by + apply intervalIntegral.integral_mono_interval le_rfl ht.1 ht.2 + · filter_upwards with x using abs_nonneg (h' x) + · exact hi.abs + have hn := intervalIntegral.abs_integral_le_integral_abs (f := h') (μ := volume) ht.1 + rw [he] at hn + have habs : h a-h t ≤ |h t-h a| := by rw [abs_sub_comm]; exact le_abs_self _ + linarith + have h := intervalIntegral.integral_mono_on (μ := volume) hab intervalIntegrable_const + ((hc.intervalIntegrable a b).add intervalIntegrable_const) hh + rw [intervalIntegral.integral_const, intervalIntegral.integral_add (hc.intervalIntegrable a b) intervalIntegrable_const, + intervalIntegral.integral_const] at h + simpa only [smul_eq_mul] using h + +lemma lattice_intervals_disjoint {τ : ℝ} (hτ : 0 < τ) : + ∀ k l : ℤ, k ≠ l → Disjoint (Ioc ((k:ℝ)*τ) (((k:ℝ)+1)*τ)) + (Ioc ((l:ℝ)*τ) (((l:ℝ)+1)*τ)) := by + intro k l hkl + rcases lt_or_gt_of_ne hkl with h | h + · apply Set.disjoint_left.mpr + intro x hx hy + have hkl' : (k:ℝ)+1 ≤ l := by exact_mod_cast (Int.add_one_le_iff.mpr h) + have hz := mul_le_mul_of_nonneg_right hkl' hτ.le + linarith [hx.2, hy.1] + · apply Set.disjoint_left.mpr + intro x hx hy + have hkl' : (l:ℝ)+1 ≤ k := by exact_mod_cast (Int.add_one_le_iff.mpr h) + have hz := mul_le_mul_of_nonneg_right hkl' hτ.le + linarith [hy.2, hx.1] + +lemma lattice_bound {h h' : ℝ → ℝ} {τ : ℝ} (hτ : 0 < τ) + (hd : ∀ t, HasDerivAt h (h' t) t) (hh : ∀ t, 0 ≤ h t) + (hi : Integrable h) (hi' : Integrable h') (s : Finset ℤ) : + τ*(∑ k ∈ s, h ((k:ℝ)*τ)) ≤ (∫ t, h t)+τ*(∫ t, |h' t|) := by + let U := ⋃ k ∈ s, Ioc ((k:ℝ)*τ) (((k:ℝ)+1)*τ) + have hle (k : ℤ) : (k:ℝ)*τ ≤ ((k:ℝ)+1)*τ := by linarith + have hs (f : ℝ → ℝ) (hf : Integrable f) : + (∑ k ∈ s, ∫ t in ((k:ℝ)*τ)..(((k:ℝ)+1)*τ), f t) = ∫ t in U, f t := by + simp_rw [intervalIntegral.integral_of_le (hle _)] + exact (integral_biUnion_finset s (fun _ _ => measurableSet_Ioc) + (fun k _ l _ hkl => lattice_intervals_disjoint hτ k l hkl) + (fun _ _ => hf.integrableOn)).symm + have he (k : ℤ) : (((k:ℝ)+1)*τ-(k:ℝ)*τ) = τ := by ring + have hb (k : ℤ) : τ*h ((k:ℝ)*τ) ≤ + (∫ t in ((k:ℝ)*τ)..(((k:ℝ)+1)*τ), h t)+ + τ*(∫ t in ((k:ℝ)*τ)..(((k:ℝ)+1)*τ), |h' t|) := by + simpa only [he] using cell_bound (a := (k:ℝ)*τ) (b := ((k:ℝ)+1)*τ) + (by linarith) hd hi'.intervalIntegrable + calc + _ = ∑ k ∈ s, τ*h ((k:ℝ)*τ) := Finset.mul_sum .. + _ ≤ ∑ k ∈ s, ((∫ t in ((k:ℝ)*τ)..(((k:ℝ)+1)*τ), h t)+ + τ*(∫ t in ((k:ℝ)*τ)..(((k:ℝ)+1)*τ), |h' t|)) := Finset.sum_le_sum (fun k _ => hb k) + _ = (∫ t in U, h t)+τ*(∫ t in U, |h' t|) := by + rw [Finset.sum_add_distrib, ← Finset.mul_sum, hs h hi, hs (fun t => |h' t|) hi'.abs] + _ ≤ _ := add_le_add + (integral_mono_measure Measure.restrict_le_self (by filter_upwards with t using hh t) hi) + (mul_le_mul_of_nonneg_left + (integral_mono_measure Measure.restrict_le_self (by filter_upwards with t using abs_nonneg (h' t)) hi'.abs) hτ.le) + +end UniformSparsestCut.LatticeDensity + +namespace UniformSparsestCut.LatticeDensity +open MeasureTheory Set +open scoped BigOperators + +lemma affine_integral (f : ℝ → ℝ) (c a : ℝ) : + (∫ t, f (c-t/a)) = |a| *(∫ t, f t) := by + rw [Measure.integral_comp_div (fun x => f (c-x)),smul_eq_mul,integral_sub_left_eq_self] + +lemma affine_integrable {f : ℝ → ℝ} (hf : Integrable f) (c : ℝ) {a : ℝ} (ha : a ≠ 0) : + Integrable (fun t => f (c-t/a)) := + ((integrable_comp_sub_left f c).mpr hf).comp_div ha + +lemma affine_lattice_bound {φ φ' : ℝ → ℝ} (hd : ∀ t, HasDerivAt φ (φ' t) t) + (hn : ∀ t, 0 ≤ φ t) (hi : Integrable φ) (hi' : Integrable φ') + (h1 : ∫ t, φ t=1) {τ a : ℝ} (hτ : 0 < τ) (ha : a ≠ 0) (c : ℝ) (s : Finset ℤ) : + τ/|a| *(∑ k ∈ s, φ (c-(k:ℝ)*τ/a)) ≤ 1+τ/|a| *(∫ t, |φ' t|) := by + let h : ℝ → ℝ := fun t => φ (c-t/a)/|a| + let h' : ℝ → ℝ := fun t => -(φ' (c-t/a)/a)/|a| + have ha' : 0 < |a| := abs_pos.mpr ha + have hD (t : ℝ) : HasDerivAt h (h' t) t := by + convert! ((hd (c-t/a)).comp t (((hasDerivAt_id t).div_const a).const_sub c)).div_const |a| using 1 + dsimp [h'] + ring + have hint : (∫ t, h t)=1 := by + dsimp [h] + rw [integral_div,affine_integral,h1,mul_one,div_self ha'.ne'] + have h'int : (∫ t, |h' t|)=(∫ t, |φ' t|)/|a| := by + dsimp [h'] + simp only [abs_div,abs_neg,abs_abs] + rw [integral_div,integral_div,affine_integral (fun t => |φ' t|)] + field_simp + have hb := lattice_bound hτ hD (fun t => div_nonneg (hn _) (abs_nonneg _)) + ((affine_integrable hi c ha).div_const _) (((affine_integrable hi' c ha).div_const a).neg.div_const _) s + rw [hint,h'int] at hb + dsimp [h] at hb + rw [← Finset.sum_div] at hb + convert hb using 1 <;> ring + +end UniformSparsestCut.LatticeDensity + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SparsestCut/Logarithms.lean b/lean/OAI/Combinatorics/SparsestCut/Logarithms.lean new file mode 100644 index 0000000000000000000000000000000000000000..415494f157e66f0b52ed05e3f1fd3e5b8b3abfff --- /dev/null +++ b/lean/OAI/Combinatorics/SparsestCut/Logarithms.lean @@ -0,0 +1,84 @@ +import OAI.Combinatorics.SparsestCut.UniformMetric + +namespace OAI + +open scoped BigOperators Topology NNReal RealInnerProductSpace InnerProductSpace Matrix ContDiff ENNReal +open MeasureTheory ProbabilityTheory Set Filter Matrix + +noncomputable section + +namespace UniformSparsestCut.RateComparison +open Filter +noncomputable section +def weight (x : ℝ) : ℝ := Real.sqrt x*(Real.log x)^2*Real.sqrt (Real.log x) +lemma weight_pos {d : ℕ} (hd : 0 (d:ℝ)) atTop atTop := tendsto_natCast_atTop_atTop + have hevent : ∀ᶠ d : ℕ in atTop, Nonempty (PivotFamily.PFamily d) ∧ + 3000≤d ∧ 1≤Real.log d ∧ SourceContraction.H≤(d:ℝ) ∧ + 4*SourceWeighted.D≤(d:ℝ) ∧ SourceMetric.C₀+1≤α*(d:ℝ) := by + filter_upwards [PivotFamily.pivot_directions_exist,eventually_ge_atTop 3000, + (Real.tendsto_log_atTop.comp hcast).eventually (eventually_ge_atTop 1), + hcast.eventually (eventually_ge_atTop SourceContraction.H), + hcast.eventually (eventually_ge_atTop (4*SourceWeighted.D)), + hcast.eventually (eventually_ge_atTop ((SourceMetric.C₀+1)/α))] with d hf hd hl hH hD ha + exact ⟨hf,hd,hl,hH,hD,by simpa only [mul_comm] using (div_le_iff₀ hα).mp ha⟩ + obtain ⟨N,hN⟩ := eventually_atTop.mp hevent + have hex : ∀ j : ℕ, ∃ (n : ℕ) (C : Capacity n), + (j+N+1)^(j+N+1)≤n ∧ n≤(j+N+1)^(4030*(j+N+1)) ∧ + 2≤n ∧ 1≤OPT C ∧ 0 ?_) tendsto_id + have hd1 : 1≤j+N+1 := by omega + have hp : j+N+1≤(j+N+1)^(j+N+1) := by + simpa using (Nat.pow_le_pow_right hd1 hd1 : (j+N+1)^1≤(j+N+1)^(j+N+1)) + exact (show j≤j+N+1 by omega).trans (hp.trans (hlo j)) + · exact Filter.Eventually.of_forall (fun j => RateComparison.gap_of_gl + (by omega : 0 EuclideanSpace ℝ (Fin m) +abbrev V := RoundedCharts.Vertex (u f) (p m 2000) +noncomputable instance vertexFintype [NeZero m] : Fintype (V f) := by + 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) + exact Fintype.ofFinite _ +def L : ℝ := GramMetric.localCost (m^6) (m^3) (Real.sqrt m) (p m 5) (p m 200) + (p m 40) ((m:ℝ)^40) (p m 1997) (2/Real.sqrt m) +def err : ℝ := GramMetric.macroCost (m^6) (m^3) (Real.sqrt m) (p m 5) (p m 200) + (p m 40) ((m:ℝ)^40) (p m 1997) (3*Real.sqrt m) 0 +lemma realization [NeZero m] (hm : 3000 ≤ m) (hl : 1≤Real.log m) : + ∃ Z : V f → EuclideanSpace ℝ (V f), + (∀ v w z, ‖Z v-Z z‖^2≤‖Z v-Z w‖^2+‖Z w-Z z‖^2) ∧ + (∀ v w, |‖Z v-Z w‖^2-KernelApprox.cstar*Real.sqrt m* + ‖B f (NeZero.pos m) v.val.1 (RoundedCharts.coordinate (u f) (p m 2000) v)- + B f (NeZero.pos m) w.val.1 (RoundedCharts.coordinate (u f) (p m 2000) w)‖|≤err (m:=m)+8*p m 8) ∧ + (∀ v w, v.val.1=w.val.1 → (∑ i, |RoundedCharts.coordinate (u f) (p m 2000) v i- + RoundedCharts.coordinate (u f) (p m 2000) w i|)=p m 2000 → + ‖Z v-Z w‖^2≤50000000*p m 2000*p m 5*(Real.log m)^2) := by + have hm0 := NeZero.pos m + have hm1 : 1 ≤ m := by omega + have hm2 : 2 ≤ m := by omega + have hx : (1:ℝ) ≤ m := by exact_mod_cast hm1 + have hx0 : (0:ℝ) < m := by exact_mod_cast hm0 + have hτ := p_pos hx0 2000 + let c : V f → Fin (m^3) := fun v => v.val.1 + let x := RoundedCharts.coordinate (u f) (p m 2000) + let θ : V f → E := fun v => B f hm0 (c v) (x v) + have hhab : p m 40≤(m:ℝ)^40 := (p_one_le hx _).trans (one_le_pow₀ hx) + have hb (s : Fin (m^3)) (i : Fin (m^6)) : ‖B f hm0 s (EuclideanSpace.single i 1)‖≤4*p m 5 := by + have h := B_column f hm0 s i + convert h using 1 + unfold p; field_simp + have hFourier (s : Fin (m^3)) (w : E) (hw : ‖w‖≤2*(3*Real.sqrt m)/p m 40) : + ‖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 + rw [norm_sub_rev] + exact f.fourier s w (hw.trans (fourier_radius (show 6 ≤ m by omega))) + have hB (v : V f) : ‖B f hm0 (c v) (x v)‖≤3*Real.sqrt m := by + have h := vertex_B_bound f hm0 hm2 hτ v + rw [rounded_radius hm0] at h + exact h.trans (by linarith [radius_le_sqrt hm1]) + have hres (v : V f) : + ‖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 + have h := vertex_residual_bound f hm0 hτ v + rw [rounded_radius hm0] at h + exact h + have he := (macro_bounds hm1).1 + have her : 3*err (m:=m)/2≤p m 8 := by + have hsmall := macro_small hm + change err (m:=m)≤p m 8/2 at hsmall + nlinarith [p_nonneg hx0.le 8] + obtain ⟨Z,htri,hmac,hloc,hzero⟩ := GramMetric.realization f.g (B f hm0) c x θ + (q:=Real.sqrt m) (k:=p m 5) (ε:=p m 200) (a:=p m 40) (b:=(m:ℝ)^40) + (R:=p m 1997) (T:=3*Real.sqrt m) (Rpos:=0) (γ:=2/Real.sqrt m) (r:=p m 8) + (Real.sqrt_pos.mpr hx0) (p_nonneg hx0.le 5) (p_one_le hx 5) (p_pos hx0 200) (p_pos hx0 40) hhab + (p_nonneg hx0.le 1997) (by positivity) (by positivity) + (by simpa only [Nat.cast_pow] using k_eq hx0) + (fun s i => (f.norms s i).2) hb hFourier hB hres + (fun v => by simp [θ]) he (p_pos hx0 8) her + refine ⟨Z,htri,hmac,?_⟩ + intro v w hc hsum + have hh := local_tau hm hl + have h := hloc v w hc (by rw [hsum]; exact hh.1) (by rw [hsum]; exact hh.2.1) + rw [hsum] at h + exact h.trans hh.2.2 +end +end UniformSparsestCut.SourceMetric + +namespace UniformSparsestCut.SourceMetric +open scoped BigOperators RealInnerProductSpace +open SourceParameters SourceCharts +noncomputable section +variable {m : ℕ} (f : PivotFamily.PFamily m) [NeZero m] +local notation "E" => EuclideanSpace ℝ (Fin m) +def C₀ : ℝ := 9+2*KernelApprox.cstar +lemma C₀_pos : 0 nlinarith [p_nonneg (by positivity : (0:ℝ) ≤ m) 8] +lemma one_step (vp vm : V f) (i : Fin (m^6)) + (hi : vp.val.2 i=vm.val.2 i+1) (hj : ∀ j, j≠i → vp.val.2 j=vm.val.2 j) : + (∑ j, |RoundedCharts.coordinate (u f) (p m 2000) vp j- + RoundedCharts.coordinate (u f) (p m 2000) vm j|)=p m 2000 := by + classical + rw [Finset.sum_eq_single i] + · change |p m 2000*(vp.val.2 i:ℝ)-p m 2000*(vm.val.2 i:ℝ)|=_ + rw [hi,Int.cast_add,Int.cast_one] + have h : p m 2000*((vm.val.2 i:ℝ)+1)-p m 2000*(vm.val.2 i:ℝ)=p m 2000 := by ring + rw [h,abs_of_pos (p_pos (by exact_mod_cast NeZero.pos m) _)] + · intro j hmem hji + change |p m 2000*(vp.val.2 j:ℝ)-p m 2000*(vm.val.2 j:ℝ)|=0 + rw [hj j hji,sub_self,abs_zero] + · simp +end +end UniformSparsestCut.SourceMetric + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SparsestCut/MetricKernel.lean b/lean/OAI/Combinatorics/SparsestCut/MetricKernel.lean new file mode 100644 index 0000000000000000000000000000000000000000..4d45714b5772fe531421f4c713352cba7d1ef541 --- /dev/null +++ b/lean/OAI/Combinatorics/SparsestCut/MetricKernel.lean @@ -0,0 +1,218 @@ +import OAI.Combinatorics.SparsestCut.Profiles + +namespace OAI + +universe u1 u2 u3 u4 u5 u6 + +open scoped BigOperators Topology NNReal RealInnerProductSpace InnerProductSpace Matrix ContDiff ENNReal +open MeasureTheory ProbabilityTheory Set Filter Matrix + +noncomputable section + +namespace UniformSparsestCut.MetricKernel +open MeasureTheory Set +open scoped RealInnerProductSpace BigOperators +variable {E : Type u1} [NormedAddCommGroup E] [InnerProductSpace ℝ E] +variable {ι : Type u2} {κ : Type u3} [Fintype ι] [Fintype κ] + +omit [Fintype ι] in +lemma gram_eq_kernel (g : κ → E) (θ : ι → E) (α : ι → κ → ℝ) + (q ε : ℝ) {a b : ℝ} (ha : 0 < a) (hab : a ≤ b) (v w : ι) : + CommonKernel.gram g θ α q ε a b v w = + Profile.kernel g q ε a b (θ v) (θ w) (α v) (α w) := by + have hf (k : κ) := CommonKernel.circle_integrable g θ α ha hab v w k + have hi := CommonKernel.gaussian_integrable θ ha hab v w + have hiS : IntervalIntegrable (fun σ => ∑ i, inner ℝ + (CommonKernel.circle (inner ℝ (g i) (θ v)/σ) (α v i)) + (CommonKernel.circle (inner ℝ (g i) (θ w)/σ) (α w i))/σ) volume a b := by + convert IntervalIntegrable.sum Finset.univ (fun i _ => hf i) using 1 + funext σ + simp only [Finset.sum_apply] + unfold CommonKernel.gram Profile.kernel Profile.pairing + rw [← intervalIntegral.integral_const_mul, ← intervalIntegral.integral_finsetSum (fun k _ => hf k), + ← intervalIntegral.integral_const_mul, ← intervalIntegral.integral_add (hi.const_mul q) + (hiS.const_mul ε)] + apply intervalIntegral.integral_congr + intro σ hσ + rw [norm_sub_rev (θ w) (θ v)] + + simp only [CommonKernel.circle_inner, inner_sub_right, sub_div, ← Finset.sum_div] + ring + +lemma kernel_psd (g : κ → E) (θ : ι → E) (α : ι → κ → ℝ) + {q ε a b : ℝ} (hq : 0 ≤ q) (hε : 0 ≤ ε) (ha : 0 < a) (hab : a ≤ b) : + Matrix.PosSemidef (fun v w => Profile.kernel g q ε a b (θ v) (θ w) (α v) (α w)) := by + have he : (fun v w => Profile.kernel g q ε a b (θ v) (θ w) (α v) (α w)) = + CommonKernel.gram g θ α q ε a b := by + funext v w; exact (gram_eq_kernel g θ α q ε ha hab v w).symm + rw [he] + exact CommonKernel.gram_posSemidef g θ α hq hε ha hab + +lemma base_pairing (g : κ → E) (q ε σ : ℝ) (θ η : E) : + Profile.pairing g q ε σ θ θ 0 0 + Profile.pairing g q ε σ η η 0 0 - + 2*Profile.pairing g q ε σ θ η 0 0 = + 2*q*KernelApprox.scaled ‖η-θ‖ σ + + 2*ε/σ*∑ i, (1-Real.cos (inner ℝ (g i) (η-θ)/σ)) := by + simp only [Profile.pairing, Pi.zero_apply, mul_zero, zero_mul, add_zero, + sub_self, norm_zero, zero_pow (by decide : (2:ℕ) ≠ 0), neg_zero, + zero_div, Real.exp_zero, inner_zero_right, Real.cos_zero, Real.sin_zero, one_mul, + Finset.sum_const, nsmul_eq_mul, mul_one, Finset.sum_sub_distrib, KernelApprox.scaled] + ring + +omit [InnerProductSpace ℝ E] in +lemma gaussian_scaled_integrable (θ η : E) {a b : ℝ} (ha : 0 < a) (hab : a ≤ b) : + IntervalIntegrable (KernelApprox.scaled ‖η-θ‖) volume a b := by + apply ContinuousOn.intervalIntegrable + rw [uIcc_of_le hab] + unfold KernelApprox.scaled + apply continuousOn_const.sub + apply Real.continuous_exp.comp_continuousOn + exact continuousOn_const.div (by fun_prop) (fun σ hσ => by have := ha.trans_le hσ.1; positivity) + +omit [Fintype κ] in +lemma cos_integrable (g : κ → E) (θ η : E) {a b : ℝ} (ha : 0 < a) (hab : a ≤ b) (i : κ) : + IntervalIntegrable (fun σ => (1-Real.cos (inner ℝ (g i) (η-θ)/σ))/σ) volume a b := by + apply ContinuousOn.intervalIntegrable + rw [uIcc_of_le hab] + have hn : ∀ σ ∈ Icc a b, σ ≠ 0 := fun σ hσ => (ha.trans_le hσ.1).ne' + exact (continuousOn_const.sub (Real.continuous_cos.comp_continuousOn + (continuousOn_const.div continuousOn_id hn))).div continuousOn_id hn + +omit [Fintype κ] in +lemma cos_integral_bound (g : κ → E) (θ η : E) {a b : ℝ} (ha : 0 < a) (hab : a ≤ b) (i : κ) : + |∫ σ in a..b, (1-Real.cos (inner ℝ (g i) (η-θ)/σ))/σ| ≤ 2*Real.log (b/a) := by + have hi := cos_integrable g θ η ha hab i + have hii : IntervalIntegrable (fun σ : ℝ => σ⁻¹) volume a b := by + apply ContinuousOn.intervalIntegrable + rw [uIcc_of_le hab] + exact continuousOn_id.inv₀ (fun σ hσ => (ha.trans_le hσ.1).ne') + have hn : 0 ≤ ∫ σ in a..b, (1-Real.cos (inner ℝ (g i) (η-θ)/σ))/σ := by + apply intervalIntegral.integral_nonneg hab + intro σ hσ + exact div_nonneg (sub_nonneg.mpr (Real.cos_le_one _)) (ha.trans_le hσ.1).le + rw [abs_of_nonneg hn] + calc + _ ≤ ∫ σ in a..b, 2*σ⁻¹ := by + apply intervalIntegral.integral_mono_on hab hi (hii.const_mul 2) + intro σ hσ + rw [← div_eq_mul_inv] + apply div_le_div_of_nonneg_right _ (ha.trans_le hσ.1).le + linarith [Real.neg_one_le_cos (inner ℝ (g i) (η-θ)/σ)] + _ = _ := by rw [intervalIntegral.integral_const_mul, integral_inv_of_pos ha (ha.trans_le hab)] + +lemma base_distance_error (g : κ → E) {q ε a b : ℝ} (hq : 0 ≤ q) (hε : 0 ≤ ε) + (ha : 0 < a) (hab : a ≤ b) (θ η : E) : + |Profile.kernel g q ε a b θ θ 0 0 + Profile.kernel g q ε a b η η 0 0 - + 2*Profile.kernel g q ε a b θ η 0 0 - KernelApprox.cstar*q*‖η-θ‖| ≤ + q*(2*a+‖η-θ‖^2/b)+4*ε*(Fintype.card κ : ℝ)*Real.log (b/a) := by + have hi1 := Profile.pairing_integrable g q ε θ θ 0 0 ha hab + have hi2 := Profile.pairing_integrable g q ε η η 0 0 ha hab + have hi3 := Profile.pairing_integrable g q ε θ η 0 0 ha hab + have hic (i : κ) := cos_integrable g θ η ha hab i + have hig := gaussian_scaled_integrable θ η ha hab + have hiS : IntervalIntegrable (fun σ => ∑ i, (1-Real.cos (inner ℝ (g i) (η-θ)/σ))/σ) volume a b := by + convert IntervalIntegrable.sum Finset.univ (fun i _ => hic i) using 1 + funext σ + simp only [Finset.sum_apply] + have he : Profile.kernel g q ε a b θ θ 0 0 + Profile.kernel g q ε a b η η 0 0 - + 2*Profile.kernel g q ε a b θ η 0 0 = + 2*q*(∫ σ in a..b, KernelApprox.scaled ‖η-θ‖ σ) + + 2*ε*(∑ i, ∫ σ in a..b, (1-Real.cos (inner ℝ (g i) (η-θ)/σ))/σ) := by + unfold Profile.kernel + rw [← intervalIntegral.integral_add hi1 hi2, ← intervalIntegral.integral_const_mul, + ← intervalIntegral.integral_sub (hi1.add hi2) (hi3.const_mul 2)] + have hi : (fun σ => Profile.pairing g q ε σ θ θ 0 0 + Profile.pairing g q ε σ η η 0 0 - + 2*Profile.pairing g q ε σ θ η 0 0) = + (fun σ => 2*q*KernelApprox.scaled ‖η-θ‖ σ + + 2*ε*∑ i, (1-Real.cos (inner ℝ (g i) (η-θ)/σ))/σ) := by + funext σ; rw [base_pairing]; simp only [← Finset.sum_div]; ring + rw [hi, intervalIntegral.integral_add (hig.const_mul _) (hiS.const_mul _), + intervalIntegral.integral_const_mul, intervalIntegral.integral_const_mul, + intervalIntegral.integral_finsetSum (fun i _ => hic i)] + rw [he] + have ht := KernelApprox.truncated_error (norm_nonneg (η-θ)) ha hab + rw [← intervalIntegral.integral_of_le hab] at ht + have hs : |∑ i, ∫ σ in a..b, (1-Real.cos (inner ℝ (g i) (η-θ)/σ))/σ| ≤ + (Fintype.card κ : ℝ)*(2*Real.log (b/a)) := by + calc + _ ≤ ∑ i, |∫ σ in a..b, (1-Real.cos (inner ℝ (g i) (η-θ)/σ))/σ| := Finset.abs_sum_le_sum_abs _ _ + _ ≤ ∑ _i : κ, 2*Real.log (b/a) := Finset.sum_le_sum (fun i _ => cos_integral_bound g θ η ha hab i) + _ = _ := by simp + have hsplit : 2*q*(∫ σ in a..b, KernelApprox.scaled ‖η-θ‖ σ) + + 2*ε*(∑ i, ∫ σ in a..b, (1-Real.cos (inner ℝ (g i) (η-θ)/σ))/σ) - + KernelApprox.cstar*q*‖η-θ‖ = + q*(2*(∫ σ in a..b, KernelApprox.scaled ‖η-θ‖ σ)-KernelApprox.cstar*‖η-θ‖)+ + 2*ε*(∑ i, ∫ σ in a..b, (1-Real.cos (inner ℝ (g i) (η-θ)/σ))/σ) := by ring + rw [hsplit] + calc + _ ≤ |q*(2*(∫ σ in a..b, KernelApprox.scaled ‖η-θ‖ σ)-KernelApprox.cstar*‖η-θ‖)|+ + |2*ε*(∑ i, ∫ σ in a..b, (1-Real.cos (inner ℝ (g i) (η-θ)/σ))/σ)| := abs_add_le .. + _ ≤ q*(2*a+‖η-θ‖^2/b)+2*ε*((Fintype.card κ : ℝ)*(2*Real.log (b/a))) := by + simp only [abs_mul, abs_of_nonneg hq, abs_of_nonneg (mul_nonneg (by norm_num : (0:ℝ) ≤ 2) hε)] + exact add_le_add (mul_le_mul_of_nonneg_left ht hq) (mul_le_mul_of_nonneg_left hs (by positivity)) + _ = _ := by ring + +end UniformSparsestCut.MetricKernel + +namespace UniformSparsestCut.MetricKernel +open MeasureTheory Set +open scoped BigOperators RealInnerProductSpace +variable {E : Type u4} [NormedAddCommGroup E] [InnerProductSpace ℝ E] +variable {S : Type u5} {N : Type u6} [Fintype S] [Fintype N] [DecidableEq S] + +lemma full_differential_bound (g : S → N → E) (s : S) + {q ε σ k γ G A V H D₀ : ℝ} (θ η v : E) (h : N → ℝ) (α β : S × N → ℝ) + (hq : 0 < q) (hε : 0 < ε) (hσ : 0 < σ) (hk : k = q^2/(Fintype.card N : ℝ)) + (hG : 0 ≤ G) (hA : 0 ≤ A) (hV : 0 ≤ V) (hH : 0 ≤ H) (hD : 0 ≤ D₀) (hγ : 0 ≤ γ) + (hg : ∀ s i, ‖g s i‖ ≤ G) (hv : ‖v‖ ≤ V*H) (hh : ∑ i, |h i| ≤ H) + (hα : ∀ i, |α i| ≤ A) (hβ : ∀ i, |β i| ≤ A) + (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) + (hf : ‖Real.exp (-‖(σ⁻¹:ℝ) • (η-θ)‖^2/2) • ((σ⁻¹:ℝ) • (η-θ)) - + ((Fintype.card N : ℝ)⁻¹) • ∑ i, Real.sin (inner ℝ (g s i) (η-θ)/σ) • g s i‖ ≤ γ) : + |Profile.differential (fun j : S × N => g j.1 j.2) q ε σ θ η v α β + (fun j => if j.1 = s then k/ε*(h j.2-inner ℝ (g j.1 j.2) v/q) else 0)| ≤ + ((k+q*γ*V+ε*((Fintype.card S : ℝ)*(Fintype.card N : ℝ))*D₀*A)*H)/σ + + (ε*((Fintype.card S : ℝ)*(Fintype.card N : ℝ))*G*V*(1+A^2+2*A)*H)/σ^2 := by + let δ : S × N → ℝ := fun j => if j.1 = s then k/ε*(h j.2-inner ℝ (g j.1 j.2) v/q) else 0 + let c : ℝ := (Fintype.card S : ℝ)*(Fintype.card N : ℝ) + have hc : 0 ≤ c := by dsimp [c]; positivity + have hk0 : 0 ≤ k := by rw [hk]; positivity + have hg0 := Profile.active_bound g s θ η v h hq hε hσ hk hg hf + have hcorr := Profile.differential_correction (q := q) (fun j : S × N => g j.1 j.2) hε.le hσ θ η v α β δ + have hc' : (∑ i : S × N, (|δ i| *|β i|+|inner ℝ (g i.1 i.2) v|/σ* + (|α i| *|β i|+|α i|+|β i|))) ≤ c*(D₀*H*A+G*(V*H)/σ*(A^2+2*A)) := by + calc + _ ≤ ∑ _i : S × N, (D₀*H*A+G*(V*H)/σ*(A^2+2*A)) := by + apply Finset.sum_le_sum; intro i _ + apply add_le_add + · exact mul_le_mul (hδ i) (hβ i) (abs_nonneg _) (mul_nonneg hD hH) + · apply mul_le_mul + · apply div_le_div_of_nonneg_right _ hσ.le + exact (abs_real_inner_le_norm _ v).trans (mul_le_mul (hg i.1 i.2) hv (norm_nonneg v) hG) + · have hp := mul_le_mul (hα i) (hβ i) (abs_nonneg _) hA + nlinarith [hα i,hβ i] + · positivity + · positivity + _ = _ := by simp [c,Fintype.card_prod]; ring + have hb0 : k/σ*(∑ i, |h i|) + q*γ/σ*‖v‖ + ε/σ^2*(c*G)*‖v‖ ≤ + k/σ*H+q*γ/σ*(V*H)+ε/σ^2*(c*G)*(V*H) := by + exact add_le_add (add_le_add (mul_le_mul_of_nonneg_left hh (by positivity)) + (mul_le_mul_of_nonneg_left hv (by positivity))) (mul_le_mul_of_nonneg_left hv (by positivity)) + calc + _ ≤ |Profile.differential (fun j : S × N => g j.1 j.2) q ε σ θ η v 0 0 δ|+ + |Profile.differential (fun j : S × N => g j.1 j.2) q ε σ θ η v α β δ - + Profile.differential (fun j : S × N => g j.1 j.2) q ε σ θ η v 0 0 δ| := by + simpa only [add_sub_cancel] using abs_add_le + (Profile.differential (fun j : S × N => g j.1 j.2) q ε σ θ η v 0 0 δ) + (Profile.differential (fun j : S × N => g j.1 j.2) q ε σ θ η v α β δ- + Profile.differential (fun j : S × N => g j.1 j.2) q ε σ θ η v 0 0 δ) + _ ≤ (k/σ*H+q*γ/σ*(V*H)+ε/σ^2*(c*G)*(V*H))+ + ε/σ*(c*(D₀*H*A+G*(V*H)/σ*(A^2+2*A))) := + add_le_add (hg0.trans hb0) (hcorr.trans (mul_le_mul_of_nonneg_left hc' (by positivity))) + _ = _ := by dsimp [c]; field_simp; ring + +end UniformSparsestCut.MetricKernel + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SparsestCut/Model.lean b/lean/OAI/Combinatorics/SparsestCut/Model.lean new file mode 100644 index 0000000000000000000000000000000000000000..f62ebd6021060d9e261d596a6f67be487f9c6303 --- /dev/null +++ b/lean/OAI/Combinatorics/SparsestCut/Model.lean @@ -0,0 +1,38 @@ +import Mathlib + +namespace OAI + +open scoped BigOperators + +namespace UniformSparsestCut + +structure Capacity (n : ℕ) where + cap : Fin n → Fin n → ℝ + nonneg : ∀ i j, 0 ≤ cap i j + symm : ∀ i j, cap i j = cap j i + diagonal : ∀ i, cap i i = 0 + +def pairSum {n : ℕ} (f : Fin n → Fin n → ℝ) : ℝ := + ∑ i, ∑ j, if i < j then f i j else 0 + +noncomputable def cutRatio {n : ℕ} (C : Capacity n) (B : Finset (Fin n)) : ℝ := + (∑ i ∈ B, ∑ j ∈ Bᶜ, C.cap i j) / + ((B.card : ℝ) * ((n : ℝ) - (B.card : ℝ))) + +noncomputable def OPT {n : ℕ} (C : Capacity n) : ℝ := + sInf {r | ∃ B : Finset (Fin n), B.Nonempty ∧ B ≠ Finset.univ ∧ r = cutRatio C B} + +def NegativeType {n : ℕ} (d : Fin n → Fin n → ℝ) : Prop := + (∃ x : Fin n → EuclideanSpace ℝ (Fin n), ∀ i j, d i j = ‖x i - x j‖ ^ 2) ∧ + ∀ i j k, d i k ≤ d i j + d j k + +def Feasible {n : ℕ} (d : Fin n → Fin n → ℝ) : Prop := + NegativeType d ∧ pairSum d = 1 + +noncomputable def glValue {n : ℕ} (C : Capacity n) : ℝ := + sInf {r | ∃ d : Fin n → Fin n → ℝ, Feasible d ∧ + r = pairSum (fun i j => C.cap i j * d i j)} + +end UniformSparsestCut + +end OAI diff --git a/lean/OAI/Combinatorics/SparsestCut/Mollifier.lean b/lean/OAI/Combinatorics/SparsestCut/Mollifier.lean new file mode 100644 index 0000000000000000000000000000000000000000..5922e5114882c1d5929b0b1edb32f2623a040615 --- /dev/null +++ b/lean/OAI/Combinatorics/SparsestCut/Mollifier.lean @@ -0,0 +1,156 @@ +import OAI.Combinatorics.SparsestCut.Metric + +namespace OAI + +open scoped BigOperators Topology NNReal RealInnerProductSpace InnerProductSpace Matrix ContDiff ENNReal +open MeasureTheory ProbabilityTheory Set Filter Matrix + +noncomputable section + +namespace UniformSparsestCut.ProductMollifier + +def bump : ContDiffBump (0:ℝ) := ⟨1/2,1,by norm_num,by norm_num⟩ +def rho : ℝ → ℝ := bump.normed volume +lemma rho_nonneg (x : ℝ) : 0 ≤ rho x := bump.nonneg_normed x +lemma rho_integral : ∫ x, rho x = 1 := bump.integral_normed +lemma rho_integrable : Integrable rho := bump.integrable_normed +lemma rho_smooth : ContDiff ℝ (⊤:ℕ∞) rho := bump.contDiff_normed +lemma rho_compact : HasCompactSupport rho := bump.hasCompactSupport_normed +lemma rho_even (x : ℝ) : rho (-x) = rho x := bump.normed_neg x +lemma rho_support {x : ℝ} (hx : rho x ≠ 0) : |x| < 1 := by + have h : x ∈ Function.support rho := hx + rw [rho,bump.support_normed_eq] at h + simpa [bump,Metric.mem_ball,dist_eq_norm] using h +lemma rho_deriv_integrable : Integrable (deriv rho) := + (rho_smooth.continuous_deriv (by simp)).integrable_of_hasCompactSupport rho_compact.deriv + +def density (ell : ℝ) (x : ℝ) : ℝ := ell⁻¹*rho (x/ell) +lemma density_nonneg {ell : ℝ} (hell : 0 ≤ ell) (x : ℝ) : 0 ≤ density ell x := by + exact mul_nonneg (inv_nonneg.mpr hell) (rho_nonneg _) +lemma density_smooth (ell : ℝ) : ContDiff ℝ (⊤:ℕ∞) (density ell) := by + unfold density + exact contDiff_const.mul (rho_smooth.comp (contDiff_id.div_const ell)) +lemma density_integral {ell : ℝ} (hell : 0 < ell) : ∫ x, density ell x = 1 := by + unfold density + rw [integral_const_mul,Measure.integral_comp_div,rho_integral,smul_eq_mul,abs_of_pos hell] + simp [hell.ne'] +lemma density_support {ell x : ℝ} (hell : 0 < ell) (hx : density ell x ≠ 0) : |x| < ell := by + have hρ : rho (x/ell) ≠ 0 := by intro he; exact hx (by simp [density,he]) + have h := rho_support hρ + rwa [abs_div,abs_of_pos hell,div_lt_one hell] at h +lemma density_compact {ell : ℝ} (hell : 0 < ell) : HasCompactSupport (density ell) := by + apply HasCompactSupport.intro (isCompact_Icc (a := -ell) (b := ell)) + intro x hx + by_contra hn + exact hx (abs_le.mp (density_support hell hn).le) +lemma density_integrable {ell : ℝ} (hell : 0 < ell) : Integrable (density ell) := + (density_smooth ell).continuous.integrable_of_hasCompactSupport (density_compact hell) +lemma density_hasDeriv {ell : ℝ} (x : ℝ) : HasDerivAt (density ell) + (ell⁻¹/ell*deriv rho (x/ell)) x := by + have hd := ((rho_smooth.differentiable (by simp) (x/ell)).hasDerivAt.comp x + ((hasDerivAt_id x).div_const ell)).const_mul (ell⁻¹) + convert hd using 1 <;> try rfl + ring +lemma density_deriv_integral {ell : ℝ} (hell : 0 < ell) : + (∫ x, |deriv (density ell) x|) = ell⁻¹*(∫ x, |deriv rho x|) := by + simp_rw [(density_hasDeriv (ell := ell) _).deriv,abs_mul,abs_of_pos (div_pos (inv_pos.mpr hell) hell)] + rw [integral_const_mul] + rw [Measure.integral_comp_div (fun t => |deriv rho t|),smul_eq_mul,abs_of_pos hell] + field_simp + +variable {m : ℕ} +local notation "E" => EuclideanSpace ℝ (Fin m) +def coordinate (i : Fin m) : E →L[ℝ] ℝ := + (ContinuousLinearMap.proj i).comp (EuclideanSpace.equiv (Fin m) ℝ).toContinuousLinearMap +@[simp] lemma coordinate_apply (i : Fin m) (x : E) : coordinate i x = x i := rfl + +def kernel (φ : ℝ → ℝ) (x : E) : ℝ := ∏ i, φ (x i) +lemma kernel_smooth (φ : ℝ → ℝ) {n : ℕ∞} (hc : ContDiff ℝ n φ) : ContDiff ℝ n (kernel (m := m) φ) := by + unfold kernel + apply contDiff_prod + intro i _ + exact hc.comp (coordinate i).contDiff +lemma kernel_nonneg {φ : ℝ → ℝ} (hn : ∀ t, 0 ≤ φ t) (x : E) : 0 ≤ kernel φ x := + Finset.prod_nonneg (fun _i _ => hn _) +lemma kernel_integral (φ : ℝ → ℝ) : (∫ x : E, kernel φ x) = (∫ t, φ t)^m := by + rw [← (PiLp.volume_preserving_toLp (Fin m)).integral_comp (MeasurableEquiv.measurableEmbedding (MeasurableEquiv.toLp 2 _))] + simpa only [kernel,Fintype.card_fin] using integral_fintype_prod_volume_eq_pow (ι := Fin m) φ +lemma kernel_integrable {φ : ℝ → ℝ} (hi : Integrable φ) : Integrable (kernel (m := m) φ) := by + rw [← (PiLp.volume_preserving_toLp (Fin m)).integrable_comp_emb (MeasurableEquiv.measurableEmbedding (MeasurableEquiv.toLp 2 _))] + exact Integrable.fintype_prod (fun _ : Fin m => hi) + +lemma coordinate_norm_bound {R : ℝ} (hR : 0 ≤ R) (x : E) (hx : ∀ j, |x j| ≤ R) : + ‖x‖ ≤ R*Real.sqrt m := by + have hs : ‖x‖^2 ≤ (m:ℝ)*R^2 := by + rw [EuclideanSpace.norm_sq_eq] + calc + _ ≤ ∑ _j : Fin m, R^2 := by + apply Finset.sum_le_sum; intro j _ + rw [Real.norm_eq_abs] + exact pow_le_pow_left₀ (abs_nonneg _) (hx j) _ + _ = _ := by simp + have hroot := Real.sq_sqrt (Nat.cast_nonneg m) + have hp : 0 ≤ R*Real.sqrt m := mul_nonneg hR (Real.sqrt_nonneg _) + have he : (R*Real.sqrt m)^2 = (m:ℝ)*R^2 := by rw [mul_pow,hroot]; ring + nlinarith [norm_nonneg x] + +lemma kernel_support_bound {φ : ℝ → ℝ} {R : ℝ} (hR : 0 ≤ R) + (hφ : ∀ t, φ t ≠ 0 → |t| ≤ R) {x : E} (hx : kernel φ x ≠ 0) : ‖x‖ ≤ R*Real.sqrt m := by + apply coordinate_norm_bound hR x + intro j + apply hφ _ + intro hj + exact hx (Finset.prod_eq_zero (Finset.mem_univ j) hj) + +lemma kernel_compact {φ : ℝ → ℝ} {R : ℝ} (hR : 0 ≤ R) + (hφ : ∀ t, φ t ≠ 0 → |t| ≤ R) : HasCompactSupport (kernel (m := m) φ) := by + apply HasCompactSupport.intro (isCompact_closedBall (0:E) (R*Real.sqrt m)) + intro x hx + by_contra hn + exact hx (by simpa using kernel_support_bound hR hφ hn) + +lemma kernel_hasFDeriv {φ φ' : ℝ → ℝ} (hd : ∀ t, HasDerivAt φ (φ' t) t) (x : E) : + HasFDerivAt (kernel φ) + (∑ i, ((∏ j ∈ Finset.univ.erase i, φ (x j))*φ' (x i)) • coordinate i) x := by + have h (i : Fin m) : HasFDerivAt (fun x : E => φ (x i)) (φ' (x i) • coordinate i) x := + (hd (x i)).comp_hasFDerivAt x (coordinate i).hasFDerivAt + convert! HasFDerivAt.finsetProd (u := Finset.univ) (fun i _ => h i) using 1 + simp only [smul_smul] + +lemma kernel_partial {φ φ' : ℝ → ℝ} (hd : ∀ t, HasDerivAt φ (φ' t) t) (x : E) (i : Fin m) : + fderiv ℝ (kernel φ) x (EuclideanSpace.single i 1) = + φ' (x i)*(∏ j ∈ Finset.univ.erase i, φ (x j)) := by + rw [(kernel_hasFDeriv hd x).fderiv] + simp [coordinate,mul_comm] + +lemma kernel_partial_integral {φ φ' : ℝ → ℝ} (hd : ∀ t, HasDerivAt φ (φ' t) t) + (hn : ∀ t, 0 ≤ φ t) (h1 : ∫ t, φ t = 1) (i : Fin m) : + (∫ x : E, |fderiv ℝ (kernel φ) x (EuclideanSpace.single i 1)|) = ∫ t, |φ' t| := by + classical + simp_rw [kernel_partial hd,abs_mul,abs_of_nonneg (Finset.prod_nonneg (fun j _ => hn _))] + let f : Fin m → ℝ → ℝ := fun j t => if j=i then |φ' t| else φ t + have he (x : E) : |φ' (x i)| *(∏ j ∈ Finset.univ.erase i, φ (x j)) = ∏ j, f j (x j) := by + rw [← Finset.mul_prod_erase (s := Finset.univ) (fun j => f j (x j)) (Finset.mem_univ i)] + simp only [f,ite_eq_left rfl] + congr 1 + apply Finset.prod_congr rfl + intro j hj + simp only [Finset.mem_erase,Finset.mem_univ,and_true] at hj + simp [hj] + simp_rw [he] + rw [← (PiLp.volume_preserving_toLp (Fin m)).integral_comp (MeasurableEquiv.measurableEmbedding (MeasurableEquiv.toLp 2 _))] + rw [integral_fintype_prod_volume_eq_prod] + rw [← Finset.mul_prod_erase (s := Finset.univ) (fun j => ∫ t, f j t) (Finset.mem_univ i)] + simp only [f,ite_eq_left rfl] + have ho : (∏ j ∈ Finset.univ.erase i, ∫ t, if j=i then |φ' t| else φ t) = 1 := by + apply Finset.prod_eq_one + intro j hj + simp only [Finset.mem_erase,Finset.mem_univ,and_true] at hj + simpa [hj] using h1 + rw [ho,mul_one] + +end UniformSparsestCut.ProductMollifier + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SparsestCut/Parameters.lean b/lean/OAI/Combinatorics/SparsestCut/Parameters.lean new file mode 100644 index 0000000000000000000000000000000000000000..bffe124349aeaae88b2e4541234b0bdf5c2d57d9 --- /dev/null +++ b/lean/OAI/Combinatorics/SparsestCut/Parameters.lean @@ -0,0 +1,211 @@ +import OAI.Combinatorics.SparsestCut.ChartMetric + +namespace OAI + +open scoped BigOperators Topology NNReal RealInnerProductSpace InnerProductSpace Matrix ContDiff ENNReal +open MeasureTheory ProbabilityTheory Set Filter Matrix + +noncomputable section + +namespace UniformSparsestCut.SourceParameters +open Filter +noncomputable section + +def p (x : ℝ) (n : ℕ) : ℝ := 1/x^n +lemma p_nonneg {x : ℝ} (hx : 0≤x) (n : ℕ) : 0≤p x n := by unfold p; positivity +lemma p_pos {x : ℝ} (hx : 0 first | exact sqrt_le hx | exact correction_le hx | (unfold p; positivity) + _ = 64*p m 155 := by + have hh := p_succ (by positivity : (m:ℝ)≠0) 155 + nlinarith + _ ≤ 64*p m 5*Real.log m := by + have hh := p_le hx (show 5≤155 by norm_num) + nlinarith + constructor + · have hmain : p m 5≤1440*p m 5*Real.log m := by nlinarith + linarith [show 0≤1440*p m 1798*Real.log m by unfold p; positivity, + show 0≤16*Real.sqrt m*p m 156*(1+p m 1802)^2 by unfold p; positivity] + · nlinarith [mul_nonneg hp5 hl0] +lemma macro_bounds {m : ℕ} (hm1 : 1 ≤ m) : + 0≤GramMetric.macroCost (m^6) (m^3) (Real.sqrt m) (p m 5) (p m 200) + (p m 40) ((m:ℝ)^40) (p m 1997) (3*Real.sqrt m) 0 ∧ + GramMetric.macroCost (m^6) (m^3) (Real.sqrt m) (p m 5) (p m 200) + (p m 40) ((m:ℝ)^40) (p m 1997) (3*Real.sqrt m) 0≤1318*p m 38 := by + have hm0 : 0 < m := by omega + have hx : (1:ℝ) ≤ m := by exact_mod_cast hm1 + have hn : (0:ℝ) ≤ m := by positivity + have hl0 := Real.log_nonneg hx + have hl1 : Real.log m≤(m:ℝ) := (Real.log_le_sub_one_of_pos (by positivity)).trans (by linarith) + rw [macro_formula hm0] + constructor + · unfold p; positivity + · have h1 : 2*Real.sqrt m*p m 40≤2*p m 38 := by + calc + _ ≤ 2*(m:ℝ)*p m 40 := by gcongr <;> first | exact sqrt_le hx | (unfold p; positivity) + _ = 2*p m 39 := by nlinarith [p_succ (by positivity : (m:ℝ)≠0) 39] + _ ≤ _ := by gcongr; exact p_le hx (by norm_num) + have h2 : 36*Real.sqrt m*p m 39≤36*p m 38 := by + calc + _ ≤ 36*(m:ℝ)*p m 39 := by gcongr <;> first | exact sqrt_le hx | (unfold p; positivity) + _ = _ := by nlinarith [p_succ (by positivity : (m:ℝ)≠0) 38] + have h3 : 320*p m 191*Real.log m*(1+p m 1802)^2≤1280*p m 38 := by + calc + _ ≤ 320*p m 191*(m:ℝ)*4 := by gcongr <;> first | exact correction_le hx | exact hl1 | (unfold p; positivity) + _ = 1280*p m 190 := by nlinarith [p_succ (by positivity : (m:ℝ)≠0) 190] + _ ≤ _ := by gcongr; exact p_le hx (by norm_num) + linarith +lemma macro_small {m : ℕ} (hm : 3000 ≤ m) : + GramMetric.macroCost (m^6) (m^3) (Real.sqrt m) (p m 5) (p m 200) + (p m 40) ((m:ℝ)^40) (p m 1997) (3*Real.sqrt m) 0≤p m 8/2 := by + have hx : (1:ℝ) ≤ m := by exact_mod_cast (show 1 ≤ m by omega) + have hp : (2636:ℝ)≤(m:ℝ)^30 := by + have hh := pow_le_pow_right₀ hx (show 1≤30 by norm_num) + simp only [pow_one] at hh + have hm' : (3000:ℝ) ≤ m := by exact_mod_cast hm + linarith + calc + _ ≤ 1318*p m 38 := (macro_bounds (show 1 ≤ m by omega)).2 + _ ≤ p m 8/2 := by + have hm0 : (0:ℝ) < m := by positivity + unfold p + rw [show (m:ℝ)^38=(m:ℝ)^8*(m:ℝ)^30 by ring] + apply (le_div_iff₀ (by norm_num : (0:ℝ)<2)).mpr + field_simp + nlinarith +end +end UniformSparsestCut.SourceParameters + +namespace UniformSparsestCut.SourceParameters +open scoped BigOperators +noncomputable section +lemma sqrt_m6 (m : ℕ) : Real.sqrt (m^6:ℕ)=(m:ℝ)^3 := by + rw [Nat.cast_pow,show (m:ℝ)^6=((m:ℝ)^3)^2 by ring,Real.sqrt_sq (by positivity)] +lemma rounded_radius {m : ℕ} (hm : 0 < m) : Real.sqrt (m^6:ℕ)*p m 2000=p m 1997 := by + rw [sqrt_m6]; unfold p; field_simp +lemma radius_le_sqrt {m : ℕ} (hm : 1 ≤ m) : p m 1997≤Real.sqrt m := by + have hx : (1:ℝ) ≤ m := by exact_mod_cast hm + exact (p_one_le hx _).trans (Real.one_le_sqrt.mpr hx) +lemma fourier_radius {m : ℕ} (hm : 6 ≤ m) : 2*(3*Real.sqrt m)/p m 40≤(m:ℝ)^42 := by + have hx : (6:ℝ) ≤ m := by exact_mod_cast hm + have hx1 : (1:ℝ) ≤ m := by linarith + calc + _ = 6*Real.sqrt m*(m:ℝ)^40 := by unfold p; field_simp ; ring + _ ≤ (m:ℝ)*(m:ℝ)*(m:ℝ)^40 := by gcongr; exact sqrt_le hx1 + _ = _ := by ring +lemma local_tau {m : ℕ} (hm : 3000 ≤ m) (hl : 1≤Real.log m) : + let L := GramMetric.localCost (m^6) (m^3) (Real.sqrt m) (p m 5) (p m 200) + (p m 40) ((m:ℝ)^40) (p m 1997) (2/Real.sqrt m) + 0 gaussianPDFReal_nonneg 0 1 x))] + calc + _ ≤ ∫ x in Icc (-a) a, (1:ℝ) := by + apply integral_mono (integrable_gaussianPDFReal 0 1).integrableOn (integrableOn_const (by rw [Real.volume_Icc]; exact ENNReal.ofReal_ne_top)) + exact standard_density_le_one + _ = 2*a := by + rw [integral_const,measureReal_def,Measure.restrict_apply MeasurableSet.univ,Set.univ_inter,Real.volume_Icc,ENNReal.toReal_ofReal (by linarith : 0 ≤ a-(-a))] + simp only [smul_eq_mul,mul_one]; ring + +lemma coordinate_small_ball {m : ℕ} (j : Fin m) {a : ℝ} (ha : 0 ≤ a) : + (stdGaussian (EuclideanSpace ℝ (Fin m))).real {x | |x j| ≤ a} ≤ 2*a := by + have hmap : (stdGaussian (EuclideanSpace ℝ (Fin m))).map (fun x => x j) = gaussianReal 0 1 := by + have h := gaussian_inner_law (EuclideanSpace.single j 1 : EuclideanSpace ℝ (Fin m)) + have he : (⟨‖(EuclideanSpace.single j 1 : EuclideanSpace ℝ (Fin m))‖^2, sq_nonneg _⟩ : NNReal) = 1 := by + apply Subtype.ext + simp + rw [he] at h + simp only [EuclideanSpace.inner_single_left, map_one, one_mul] at h + exact h + have h := congrArg (fun μ : Measure ℝ => μ.real {x | |x| ≤ a}) hmap + simp only [measureReal_def] at h + rw [Measure.map_apply_of_aemeasurable (by fun_prop) (by measurability)] at h + exact h.le.trans (standard_small_ball ha) + +lemma all_coordinate_small_ball {m N S : ℕ} {a : ℝ} (ha : 0 ≤ a) : + (Measure.pi (fun _ : Fin S => Measure.pi (fun _ : Fin N => stdGaussian (EuclideanSpace ℝ (Fin m))))).real + {g | ∃ s i j, |g s i j| ≤ a} ≤ (S:ℝ)*((N:ℝ)*((m:ℝ)*(2*a))) := by + have hcol : (stdGaussian (EuclideanSpace ℝ (Fin m))).real {x | ∃ j, |x j| ≤ a} ≤ (m:ℝ)*(2*a) := by + 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) + have hchart := real_measure_exists_le (μ := stdGaussian (EuclideanSpace ℝ (Fin m))) + (fun _ : Fin N => {x : EuclideanSpace ℝ (Fin m) | ∃ j, |x j| ≤ a}) (fun _ => by measurability) (fun _ => hcol) + exact real_measure_exists_le + (fun _ : Fin S => {g : Fin N → EuclideanSpace ℝ (Fin m) | ∃ i j, |g i j| ≤ a}) + (fun _ => by measurability) (fun _ => hchart) + +section ExtraSelection +variable {m N S : ℕ} +local notation "E" => EuclideanSpace ℝ (Fin m) +local notation "μ" => stdGaussian E +local notation "ν" => Measure.pi (fun _ : Fin N => μ) +local notation "π" => Measure.pi (fun _ : Fin S => ν) +theorem select_on_nets_extra (hm : 0 < m) (hN : 0 < N) (hS : 0 < S) + (V W : Finset E) (hV : ∀ v ∈ V, ‖v‖ = 1) + {u q : ℝ} (hu : 0 ≤ u) (hq : 0 ≤ q) + (hqprob : (N : ℝ)*(2*Real.exp (-q^2/2)) ≤ 1/4) + {P : (Fin S → Fin N → E) → Prop} (hP : ∀ᵐ g ∂π, P g) + (Q : Set (Fin S → Fin N → E)) {p : ℝ} (hQ : (π).real Q ≤ p) + (hprob : (S : ℝ) * ((N : ℝ)*(2*Real.exp (-(m : ℝ)/8)) + + (V.card : ℝ)*(W.card : ℝ)*(2*Real.exp (-(N : ℝ)*u^2/(2*(2*Real.sqrt m)^2))) + + (V.card : ℝ)*(2*Real.exp (-(N : ℝ)*(1/8)^2/(2*(4*(m : ℝ))^2)))) + + (V.card : ℝ)*(2*Real.exp (-(S : ℝ)/32)) + p < 1) : + ∃ g : Fin S → Fin N → E, P g ∧ g ∉ Q ∧ + (∀ s, g s ∉ normBad) ∧ + (∀ s, ∀ v ∈ V, ∀ w ∈ W, g s ∉ fourierBad u v w) ∧ + (∀ s, ∀ v ∈ V, g s ∉ covarianceBad v) ∧ + (∀ v ∈ V, (badCount (projectionBad q v) g : ℝ) ≤ (S : ℝ)/2) := by + classical + let A := chartBad (N := N) V W u + let B : Set (Fin S → Fin N → E) := {g | ∃ s, g s ∈ A} + let C : Set (Fin S → Fin N → E) := + {g | ∃ v : V, (S : ℝ)/2 < (badCount (projectionBad q v) g : ℝ)} + have hBbound := real_measure_exists_le (fun _ : Fin S => A) + (fun _ => chartBad_measurable V W u) (fun _ => chartBad_bound hm hN V W hV hu) + have hCbound := goodBad_bound hS V hV hq hqprob + have hBC : (π).real ((B ∪ C) ∪ Q) < 1 := + ((measureReal_union_le (B ∪ C) Q).trans + (add_le_add ((measureReal_union_le B C).trans (add_le_add hBbound hCbound)) hQ)).trans_lt hprob + obtain ⟨g, hg0, hgP⟩ := exists_outside_with_ae hBC hP + have hg : g ∉ B ∪ C := fun h => hg0 (Or.inl h) + have hgQ : g ∉ Q := fun h => hg0 (Or.inr h) + have hgB : ∀ s, g s ∉ A := by + intro s hs; exact hg (Or.inl ⟨s, hs⟩) + refine ⟨g, hgP, hgQ, ?_, ?_, ?_, ?_⟩ + · intro s hs; exact hgB s (Or.inl (Or.inl hs)) + · intro s v hv w hw hs; exact hgB s (Or.inl (Or.inr ⟨(⟨v,hv⟩,⟨w,hw⟩), hs⟩)) + · intro s v hv hs; exact hgB s (Or.inr ⟨⟨v,hv⟩, hs⟩) + · intro v hv; by_contra h + exact hg (Or.inr ⟨⟨v,hv⟩, lt_of_not_ge h⟩) + +end ExtraSelection + +variable {m : ℕ} +local notation "E" => EuclideanSpace ℝ (Fin m) + +lemma select_source_nets_pivot (hm : 1000000 ≤ m) (hlog : 1 ≤ Real.log m) + (hmajor : 2*(m : ℝ)^9*Real.exp (-(m : ℝ)/8) + + 6*(m : ℝ)^3*Real.exp (-(m : ℝ)) + 2/(m:ℝ)^20 < 1) + (V W : Finset E) (hV : ∀ v ∈ V, ‖v‖ = 1) + (hVc : (V.card : ℝ) ≤ Real.exp (6*(m : ℝ)^2)) + (hWc : (W.card : ℝ) ≤ Real.exp (48*(m : ℝ)^2)) : + ∃ g : Fin (m^3) → Fin (m^6) → E, + (∀ s a b, a ≠ b → ∀ t : ℝ, g s a ≠ t • g s b) ∧ + (∀ s i j, 1/(m:ℝ)^30 < |g s i j|) ∧ + (∀ s, g s ∉ normBad) ∧ + (∀ s, ∀ v ∈ V, ∀ w ∈ W, g s ∉ fourierBad (1/(2*Real.sqrt m)) v w) ∧ + (∀ s, ∀ v ∈ V, g s ∉ covarianceBad v) ∧ + (∀ v ∈ V, (badCount (projectionBad (10*Real.sqrt (Real.log m)) v) g : ℝ) ≤ + ((m^3 : ℕ) : ℝ)/2) := by + have hm0 : 0 < m := by omega + have hsmall := all_coordinate_small_ball (m := m) (N := m^6) (S := m^3) (by positivity : (0:ℝ) ≤ 1/(m:ℝ)^30) + have hp : ((m^3:ℕ):ℝ)*(((m^6:ℕ):ℝ)*((m:ℝ)*(2*(1/(m:ℝ)^30)))) = 2/(m:ℝ)^20 := by + push_cast; field_simp + rw [hp] at hsmall + obtain ⟨g,hg,hQ,hrest⟩ := select_on_nets_extra (N := m^6) (S := m^3) hm0 (pow_pos hm0 _) (pow_pos hm0 _) + V W hV (by positivity : (0:ℝ) ≤ 1/(2*Real.sqrt m)) + (by positivity : (0:ℝ) ≤ 10*Real.sqrt (Real.log m)) + (by + simpa only [Nat.cast_pow] using (projection_failure_bound (show 2 ≤ m by omega) + (show 0 ≤ Real.log m by linarith))) + (GaussianNonparallel.charts_pairwise_nonparallel (show 2 ≤ m by omega)) + {g | ∃ s i j, |g s i j| ≤ 1/(m:ℝ)^30} hsmall (by + simp only [Nat.cast_pow] + rw [normalized_fourier_exponent hm0, normalized_covariance_exponent m hm0] + exact (add_le_add_left (probability_majorization hm (Nat.cast_nonneg _) (Nat.cast_nonneg _) hVc hWc) _).trans_lt hmajor) + refine ⟨g,hg,?_,hrest⟩ + intro s i j + exact lt_of_not_ge (fun h => hQ ⟨s,i,j,h⟩) + +structure PFamily (m : ℕ) extends Family m where + pivot : ∀ s i j, 1/(m:ℝ)^30 < |g s i j| + +lemma pivot_family_at_large (hm : 1000000 ≤ m) (hlog : 1 ≤ Real.log m) + (hbias : 16*Real.exp (-(m : ℝ)/12) ≤ 1/(8*(m : ℝ))) + (hmajor : 2*(m : ℝ)^9*Real.exp (-(m : ℝ)/8) + + 6*(m : ℝ)^3*Real.exp (-(m : ℝ)) + 2/(m:ℝ)^20 < 1) : Nonempty (PFamily m) := by + classical + obtain ⟨V,W,hV,hVc,hWc,hVnet,hWnet⟩ := source_nets (show 2 ≤ m by omega) + obtain ⟨g,hpar,hpivot,hg,hfour,hcov,hgood⟩ := select_source_nets_pivot hm hlog hmajor V W hV hVc hWc + have hm0 : 0 < m := by omega + have hm0' : (0 : ℝ) < m := by exact_mod_cast hm0 + have hn : 0 < m^6 := pow_pos hm0 _ + have hu (s : Fin (m^3)) (i : Fin (m^6)) : ‖g s i‖^2 ≤ 4*(m : ℝ) := + (normBounds_of_not_bad (hg s) i).2 + refine ⟨{ g := g, norms := ?_, nonparallel := hpar, covariance := ?_, fourier := ?_, good := ?_, pivot := hpivot }⟩ + · intro s i + have h := normBounds_of_not_bad (hg s) i + have hs := Real.sq_sqrt hm0'.le + constructor <;> nlinarith [Real.sqrt_nonneg (m : ℝ), norm_nonneg (g s i)] + · intro s v hv + have hh := covariance_net_bound hn (g s) (hu s) (by positivity) V hV hVnet + (fun v hv => net_covariance_scalar (hg s) v (hV v hv) (hcov s v hv)) v hv + have herr := covariance_net_error (show 1000 ≤ m by omega) hbias + have heq : 2*(4*(m : ℝ))*(1/(m : ℝ)^3) = 8*(m : ℝ)*(1/(m : ℝ)^3) := by ring + rw [heq] at hh + have hab := abs_le.mp (hh.trans herr) + constructor <;> linarith + · intro s w hw + have hρ : 1/(m : ℝ)^3 < 1 := by + apply (div_lt_one (by positivity)).mpr + have hx : (2 : ℝ) ≤ m := by exact_mod_cast (show 2 ≤ m by omega) + have hh := pow_le_pow_left₀ (by norm_num : (0 : ℝ) ≤ 2) hx 3 + norm_num at hh; linarith + have hh := fourier_net_bound hn (g s) (hu s) (by positivity) (by positivity) hρ V W + 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 + have herr := scalar_net_error (show 1000 ≤ m by omega) hbias + have heq : 4*(m : ℝ)+(m : ℝ) = 5*(m : ℝ) := by ring + rw [heq] at hh + exact hh.trans herr + · intro v hv + obtain ⟨v',hv',hd⟩ := hVnet v hv + have hh := good_chart_interpolation g hg hd (projection_net_error (show 1000 ≤ m by omega) hlog) + exact (Nat.cast_le.mpr hh).trans (hgood v' hv') + +lemma pivot_majorant_tendsto : + Tendsto (fun m : ℕ => 2*(m : ℝ)^9*Real.exp (-(m : ℝ)/8) + + 6*(m : ℝ)^3*Real.exp (-(m : ℝ)) + 2/(m:ℝ)^20) atTop (𝓝 0) := by + have hi : Tendsto (fun m : ℕ => (m:ℝ)⁻¹) atTop (𝓝 0) := + tendsto_inv_atTop_zero.comp tendsto_natCast_atTop_atTop + have hh := (hi.pow 20).const_mul 2 + have h := selection_majorant_tendsto.add hh + simpa [div_eq_mul_inv,inv_pow] using h + +theorem pivot_directions_exist : ∀ᶠ m : ℕ in atTop, Nonempty (PFamily m) := by + have hlog : ∀ᶠ m : ℕ in atTop, 1 ≤ Real.log m := + (Real.tendsto_log_atTop.comp tendsto_natCast_atTop_atTop).eventually (eventually_ge_atTop 1) + have hmajor := pivot_majorant_tendsto.eventually (gt_mem_nhds (by norm_num : (0:ℝ) < 1)) + filter_upwards [eventually_ge_atTop 1000000,hlog,eventual_bias_bound,hmajor] with m hm hl hb hp + exact pivot_family_at_large hm hl hb.2 hp + +end UniformSparsestCut.PivotFamily + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SparsestCut/PositiveKernels.lean b/lean/OAI/Combinatorics/SparsestCut/PositiveKernels.lean new file mode 100644 index 0000000000000000000000000000000000000000..4fc19053c7182e18fd2a8ca24b5cb00b33b257a7 --- /dev/null +++ b/lean/OAI/Combinatorics/SparsestCut/PositiveKernels.lean @@ -0,0 +1,164 @@ +import OAI.Combinatorics.SparsestCut.RoundedCharts + +namespace OAI + +universe u1 u2 u3 u4 + +open scoped BigOperators Topology NNReal RealInnerProductSpace InnerProductSpace Matrix ContDiff ENNReal +open MeasureTheory ProbabilityTheory Set Filter Matrix + +noncomputable section + +namespace UniformSparsestCut +namespace TriangleRepair + +variable {ι : Type u1} [Fintype ι] + +lemma gram_posSemidef {H : Type u2} [NormedAddCommGroup H] [InnerProductSpace ℝ H] + (x : ι → H) : (Matrix.of (fun i j => ⟪x i, x j⟫_ℝ)).PosSemidef := by + apply Matrix.PosSemidef.of_dotProduct_mulVec_nonneg + · apply Matrix.IsHermitian.ext + intro i j + simp [real_inner_comm] + · intro c + have h := real_inner_self_nonneg (x := ∑ i, c i • x i) + simp only [sum_inner, inner_sum, real_inner_smul_left, real_inner_smul_right] at h + simp only [Matrix.mulVec, Matrix.of_apply, dotProduct, Finset.mul_sum, Pi.star_apply, + star_trivial] + convert h using 1 + try rfl + apply Finset.sum_congr rfl + intro i hi + apply Finset.sum_congr rfl + intro j hj + rw [real_inner_comm (x j) (x i)] + ring + +lemma ones_posSemidef : (Matrix.of (fun _ _ : ι => (1 : ℝ))).PosSemidef := by + convert Matrix.posSemidef_vecMulVec_self_star (fun _ : ι => (1 : ℝ)) using 1 + ext i j + change (1 : ℝ) = 1 * 1 + ring + +lemma entrywise_pow_posSemidef {A : Matrix ι ι ℝ} (hA : A.PosSemidef) (k : ℕ) : + Matrix.PosSemidef (fun i j => (A i j) ^ k) := by + induction k with + | zero => convert (ones_posSemidef (ι := ι)) using 1; rfl + | succ k hk => convert hk.hadamard hA using 1; rfl + +omit [Fintype ι] in +lemma sum_posSemidef {κ : Type u3} (s : Finset κ) (A : κ → Matrix ι ι ℝ) + (hA : ∀ k ∈ s, (A k).PosSemidef) : (∑ k ∈ s, A k).PosSemidef := by + classical + induction s using Finset.induction_on with + | empty => simpa using (Matrix.PosSemidef.zero : (0 : Matrix ι ι ℝ).PosSemidef) + | @insert a s ha hs => + rw [Finset.sum_insert ha] + exact (hA a (Finset.mem_insert_self a s)).add + (hs (fun k hk => hA k (Finset.mem_insert_of_mem hk))) + +lemma posSemidef_of_tendsto {A : ℕ → Matrix ι ι ℝ} {B : Matrix ι ι ℝ} + (ha : ∀ k, (A k).PosSemidef) + (hab : ∀ i j, Tendsto (fun k => A k i j) atTop (nhds (B i j))) : B.PosSemidef := by + apply Matrix.PosSemidef.of_dotProduct_mulVec_nonneg + · apply Matrix.IsHermitian.ext + intro i j + simp only [star_trivial] + apply tendsto_nhds_unique (hab j i) + have heq : (fun k => A k j i) = (fun k => A k i j) := by + funext k + simpa using (ha k).isHermitian.apply i j + simpa [heq] using hab i j + · intro c + have ht : Tendsto (fun k => star c ⬝ᵥ (A k *ᵥ c)) atTop + (nhds (star c ⬝ᵥ (B *ᵥ c))) := by + simp only [dotProduct, Matrix.mulVec] + exact tendsto_finsetSum _ fun i _ => tendsto_const_nhds.mul + (tendsto_finsetSum _ fun j _ => (hab i j).mul tendsto_const_nhds) + exact ge_of_tendsto' ht (fun k => (ha k).dotProduct_mulVec_nonneg c) + +lemma entrywise_exp_posSemidef {A : Matrix ι ι ℝ} (hA : A.PosSemidef) : + Matrix.PosSemidef (fun i j => Real.exp (A i j)) := by + let P (k : ℕ) : Matrix ι ι ℝ := fun i j => A i j ^ k / (k.factorial : ℝ) + have hp (k : ℕ) : (P k).PosSemidef := by + have h := (entrywise_pow_posSemidef hA k).smul + (inv_nonneg.mpr (Nat.cast_nonneg (α := ℝ) k.factorial)) + convert h using 1 + ext i j + change A i j ^ k / (k.factorial : ℝ) = (k.factorial : ℝ)⁻¹ * A i j ^ k + exact div_eq_inv_mul _ _ + apply posSemidef_of_tendsto (A := fun k => ∑ l ∈ Finset.range k, P l) + (fun k => sum_posSemidef _ _ (fun l _ => hp l)) + intro i j + have h := (NormedSpace.expSeries_div_hasSum_exp (A i j)).tendsto_sum_nat + convert h using 1 + · funext k + exact Matrix.sum_apply i j (Finset.range k) P + · rw [Real.exp_eq_exp_ℝ] + +lemma gaussian_posSemidef {H : Type u4} [NormedAddCommGroup H] [InnerProductSpace ℝ H] + (x : ι → H) {l : ℝ} (hl : 0 < l) : + Matrix.PosSemidef (fun i j => Real.exp (-‖x i - x j‖ ^ 2 / l)) := by + let a : ι → ℝ := fun i => Real.exp (-‖x i‖ ^ 2 / l) + have hgram := (gram_posSemidef x).smul (show 0 ≤ 2 / l by positivity) + have hexp := entrywise_exp_posSemidef hgram + have hrank := Matrix.posSemidef_vecMulVec_self_star a + have heq : (fun i j => Real.exp (-‖x i - x j‖ ^ 2 / l) : Matrix ι ι ℝ) = + Matrix.vecMulVec a (star a) ⊙ (fun i j => Real.exp ((2 / l) * ⟪x i, x j⟫_ℝ)) := by + ext i j + change Real.exp (-‖x i - x j‖ ^ 2 / l) = + (a i * a j) * Real.exp ((2 / l) * ⟪x i, x j⟫_ℝ) + simp only [a, ← Real.exp_add] + congr 1 + rw [norm_sub_sq_real] + ring + rw [heq] + convert hrank.hadamard hexp using 1 + rfl + +open MeasureTheory + +lemma integral_posSemidef (K : ℝ → Matrix ι ι ℝ) {r : ℝ} (hr : 0 ≤ r) + (hK : ∀ l ∈ Set.Icc 0 r, (K l).PosSemidef) + (hi : ∀ i j, IntervalIntegrable (fun l => K l i j) volume 0 r) : + Matrix.PosSemidef (fun i j => ∫ l in (0 : ℝ)..r, K l i j) := by + apply Matrix.PosSemidef.of_dotProduct_mulVec_nonneg + · apply Matrix.IsHermitian.ext + intro i j + simp only [star_trivial] + apply intervalIntegral.integral_congr + intro l hl + simpa using (hK l (by simpa [Set.uIcc_of_le hr] using hl)).isHermitian.apply i j + · intro c + have h : 0 ≤ ∫ l in (0 : ℝ)..r, star c ⬝ᵥ (K l *ᵥ c) := + intervalIntegral.integral_nonneg hr (fun l hl => (hK l hl).dotProduct_mulVec_nonneg c) + simp only [dotProduct, Matrix.mulVec, Pi.star_apply, star_trivial] at h ⊢ + have hrow (i : ι) : IntervalIntegrable + (fun l => ∑ j, K l i j * c j) volume 0 r := by + convert IntervalIntegrable.sum Finset.univ (fun j _ => (hi i j).mul_const (c j)) using 1 + try rfl + funext l + simp only [Finset.sum_apply] + rw [intervalIntegral.integral_finsetSum (fun i _ => (hrow i).const_mul (c i))] at h + simp_rw [intervalIntegral.integral_const_mul] at h + simp_rw [intervalIntegral.integral_finsetSum (fun j _ => (hi _ j).mul_const (c j)), + intervalIntegral.integral_mul_const] at h + exact h + +open scoped MatrixOrder in + +lemma exists_gram {A : Matrix ι ι ℝ} (hA : A.PosSemidef) : + ∃ q : ι → EuclideanSpace ℝ ι, ∀ i j, ⟪q i, q j⟫_ℝ = A i j := by + classical + obtain ⟨B, hB⟩ := CStarAlgebra.nonneg_iff_eq_star_mul_self.mp hA.nonneg + refine ⟨fun i => WithLp.toLp 2 (fun k => B k i), ?_⟩ + intro i j + rw [hB] + simp [PiLp.inner_apply, Matrix.mul_apply, Matrix.star_eq_conjTranspose, mul_comm] + +end TriangleRepair +end UniformSparsestCut + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SparsestCut/ProductSlice.lean b/lean/OAI/Combinatorics/SparsestCut/ProductSlice.lean new file mode 100644 index 0000000000000000000000000000000000000000..d4151b2932a4be0d21c4947f838af6f13f064fd3 --- /dev/null +++ b/lean/OAI/Combinatorics/SparsestCut/ProductSlice.lean @@ -0,0 +1,135 @@ +import OAI.Combinatorics.SparsestCut.SliceCoefficients + +namespace OAI + +universe u1 u2 u3 + +open scoped BigOperators Topology NNReal RealInnerProductSpace InnerProductSpace Matrix ContDiff ENNReal +open MeasureTheory ProbabilityTheory Set Filter Matrix + +noncomputable section + +namespace UniformSparsestCut.ProductSlice +open MeasureTheory Set +open scoped BigOperators +noncomputable section +variable {Z : Type u1} {I : Type u2} {K : Type u3} [NormedAddCommGroup Z] [NormedSpace ℝ Z] + [FiniteDimensional ℝ Z] [MeasureSpace Z] [BorelSpace Z] [(volume : Measure Z).IsAddHaarMeasure] + [Fintype I] [Fintype K] [DecidableEq I] [DecidableEq K] + +def form (B : Z →L[ℝ] ℝ) : (ℝ × Z) →L[ℝ] ℝ := + ContinuousLinearMap.fst ℝ ℝ Z-B.comp (ContinuousLinearMap.snd ℝ ℝ Z) +omit [FiniteDimensional ℝ Z] [MeasureSpace Z] [BorelSpace Z] [(volume : Measure Z).IsAddHaarMeasure] in +@[simp] lemma form_apply (B : Z →L[ℝ] ℝ) (x : ℝ × Z) : form B x=x.1-B x.2 := rfl + +def cell (B : I → Z →L[ℝ] ℝ) (q : I → K → ℝ) (F : Finset (I × K) → ℝ) (x : ℝ × Z) : ℝ := + F (Finset.univ.filter (fun p => form (B p.1) x+q p.1 p.2<0)) +omit [(volume : Measure Z).IsAddHaarMeasure] in +lemma cell_measurable (B : I → Z →L[ℝ] ℝ) (q : I → K → ℝ) (F : Finset (I × K) → ℝ) : + Measurable (cell B q F) := by + unfold cell + apply InterfaceStep.measurable_filter_apply + intro p + exact measurableSet_lt ((form (B p.1)).measurable.add_const (q p.1 p.2)) measurable_const + +omit [(volume : Measure Z).IsAddHaarMeasure] in +lemma cell_locallyIntegrable (B : I → Z →L[ℝ] ℝ) (q : I → K → ℝ) + (F : Finset (I × K) → ℝ) {M : ℝ} (hM : ∀ a, |F a|≤M) + (ν : Measure (ℝ × Z)) [IsLocallyFiniteMeasure ν] : LocallyIntegrable (cell B q F) ν := by + apply (continuous_const (y := M)).locallyIntegrable.mono (cell_measurable B q F).aestronglyMeasurable + filter_upwards with x + exact (show |cell B q F x|≤M from hM _).trans (le_abs_self M) + +omit [FiniteDimensional ℝ Z] [MeasureSpace Z] [BorelSpace Z] [(volume : Measure Z).IsAddHaarMeasure] [DecidableEq I] [DecidableEq K] in +lemma cell_translate (B : I → Z →L[ℝ] ℝ) (q : I → K → ℝ) + (F : Finset (I × K) → ℝ) (θ : ℝ × Z) (x : ℝ) (z : Z) : + cell B q F (θ-(x,z)) = + F (Finset.univ.filter (fun p => form (B p.1) θ+B p.1 z+q p.1 p.2 intro hp <;> linarith + +def law (ψ : Z → ℝ) (ν : Measure Z) : Measure Z := ν.withDensity (fun z => ENNReal.ofReal (ψ z)) +omit [NormedAddCommGroup Z] [NormedSpace ℝ Z] [FiniteDimensional ℝ Z] [BorelSpace Z] [(volume : Measure Z).IsAddHaarMeasure] in +lemma law_ac (ψ : Z → ℝ) (ν : Measure Z) : law ψ ν ≪ ν := withDensity_absolutelyContinuous _ _ +omit [NormedAddCommGroup Z] [NormedSpace ℝ Z] [FiniteDimensional ℝ Z] [BorelSpace Z] [(volume : Measure Z).IsAddHaarMeasure] in +lemma law_integral {ψ : Z → ℝ} (hm : Measurable ψ) (hn : ∀ z, 0≤ψ z) + (ν : Measure Z) (f : Z → ℝ) : + (∫ z, f z ∂law ψ ν) = ∫ z, ψ z*f z ∂ν := by + rw [law,integral_withDensity_eq_integral_toReal_smul (hm.ennreal_ofReal) + (ae_of_all _ (fun _ => ENNReal.ofReal_lt_top))] + simp only [ENNReal.toReal_ofReal (hn _),smul_eq_mul] +omit [NormedAddCommGroup Z] [NormedSpace ℝ Z] [FiniteDimensional ℝ Z] [BorelSpace Z] [(volume : Measure Z).IsAddHaarMeasure] in +lemma law_probability {ψ : Z → ℝ} (_hm : Measurable ψ) (hn : ∀ z, 0≤ψ z) + (ν : Measure Z) (hi : Integrable ψ ν) (h1 : ∫ z, ψ z ∂ν=1) : + IsProbabilityMeasure (law ψ ν) := by + refine ⟨?_⟩ + change (ν.withDensity (fun z => ENNReal.ofReal (ψ z))) Set.univ = 1 + rw [withDensity_apply _ MeasurableSet.univ,Measure.restrict_univ] + rw [← ofReal_integral_eq_lintegral_ofReal hi (ae_of_all _ hn),h1] + simp + +lemma convolution_slice (B : I → Z →L[ℝ] ℝ) (q : I → K → ℝ) + (F : Finset (I × K) → ℝ) {M : ℝ} (_hM0 : 0 ≤ M) (hM : ∀ a, |F a| ≤ M) + {φ : ℝ → ℝ} {ψ : Z → ℝ} (hmφ : Measurable φ) (hmψ : Measurable ψ) + (hφ : Integrable φ) (hψ : Integrable ψ) (hnψ : ∀ z, 0≤ψ z) (θ : ℝ × Z) : + convolution (fun p : ℝ × Z => φ p.1*ψ p.2) (cell B q F) + (ContinuousLinearMap.mul ℝ ℝ) volume θ = + ∫ z, (∫ x, φ x*F (Finset.univ.filter + (fun p => form (B p.1) θ+B p.1 z+q p.1 p.2 (φ p.1*ψ p.2)*cell B q F (θ-p)) := by + apply (((hφ.abs).mul_prod hψ.abs).mul_const M).mono' + (((hmφ.comp measurable_fst).mul (hmψ.comp measurable_snd)).mul + ((cell_measurable B q F).comp (measurable_const.sub measurable_id))).aestronglyMeasurable + filter_upwards with p + change |φ p.1*ψ p.2*cell B q F (θ-p)| ≤ |φ p.1| * |ψ p.2| * M + simp only [abs_mul] + exact mul_le_mul_of_nonneg_left (hM _) (mul_nonneg (abs_nonneg _) (abs_nonneg _)) + change (∫ p : ℝ × Z, (φ p.1*ψ p.2)*cell B q F (θ-p) ∂(volume : Measure ℝ).prod (volume : Measure Z)) = _ + rw [integral_prod_symm _ hi,law_integral hmψ hnψ] + apply integral_congr_ae + filter_upwards with z + rw [← integral_const_mul] + apply integral_congr_ae + filter_upwards with x + rw [cell_translate] + ring + +lemma convolution_derivative (B : I → Z →L[ℝ] ℝ) (hB : Function.Injective B) + (q : I → K → ℝ) (hq : ∀ i, Function.Injective (q i)) + (F : Finset (I × K) → ℝ) {M C : ℝ} (hM0 : 0≤M) (hC : 0≤C) + (hM : ∀ a, |F a|≤M) {φ : ℝ → ℝ} {ψ : Z → ℝ} + (hφ : Integrable φ) (hcφ : Continuous φ) (hφC : ∀ t, |φ t|≤C) + (hmψ : Measurable ψ) (hnψ : ∀ z, 0≤ψ z) (hψ : Integrable ψ) (hψ1 : ∫ z, ψ z=1) + (θ : ℝ × Z) : + HasFDerivAt (convolution (fun p : ℝ × Z => φ p.1*ψ p.2) (cell B q F) + (ContinuousLinearMap.mul ℝ ℝ) volume) + (∑ i, (∑ k, ∫ z, -(φ (form (B i) θ+B i z+q i k)* + (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))- + 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)))) + ∂law ψ volume) • form (B i)) θ := by + let := law_probability hmψ hnψ volume hψ hψ1 + have he : convolution (fun p : ℝ × Z => φ p.1*ψ p.2) (cell B q F) + (ContinuousLinearMap.mul ℝ ℝ) volume = + (fun θ => ∫ z, (∫ x, φ x*F (Finset.univ.filter + (fun p => form (B p.1) θ+B p.1 z+q p.1 p.2 form (B p.1) θ+(B p.1 z+q p.1 p.2)) := by + simpa only [add_assoc] using SliceCoefficients.thresholds_injective_ae + (fun i => form (B i)) B q hq hB volume (law ψ volume) (law_ac ψ volume) θ + simpa only [add_assoc] using SliceCoefficients.family_derivative (fun i => form (B i)) + (fun p z => B p.1 z+q p.1 p.2) (fun p => (B p.1).measurable.add_const _) F + hφ hcφ hM0 hC hM hφC (law ψ volume) θ hi +end +end UniformSparsestCut.ProductSlice + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SparsestCut/Profiles.lean b/lean/OAI/Combinatorics/SparsestCut/Profiles.lean new file mode 100644 index 0000000000000000000000000000000000000000..dddbf66b8b36cd8b421d67f3c863f0f43662e108 --- /dev/null +++ b/lean/OAI/Combinatorics/SparsestCut/Profiles.lean @@ -0,0 +1,348 @@ +import OAI.Combinatorics.SparsestCut.CommonKernel + +namespace OAI + +universe u1 u2 u3 u4 u5 u6 u7 + +open scoped BigOperators Topology NNReal RealInnerProductSpace InnerProductSpace Matrix ContDiff ENNReal +open MeasureTheory ProbabilityTheory Set Filter Matrix + +noncomputable section + +namespace UniformSparsestCut.Profile +variable {E : Type u1} [NormedAddCommGroup E] [InnerProductSpace ℝ E] +variable {ι : Type u2} [Fintype ι] + +def pairing (g : ι → E) (q ε σ : ℝ) (θ η : E) (α β : ι → ℝ) : ℝ := + q*Real.exp (-‖η-θ‖^2/(2*σ^2)) + ε/σ*(∑ i, ( + (1+α i*β i)*Real.cos (inner ℝ (g i) (η-θ)/σ) + + (α i-β i)*Real.sin (inner ℝ (g i) (η-θ)/σ))) + +def differential (g : ι → E) (q ε σ : ℝ) (θ η v : E) + (α β δ : ι → ℝ) : ℝ := + q/σ*(inner ℝ ((σ⁻¹:ℝ) • (η-θ)) v)*Real.exp (-‖η-θ‖^2/(2*σ^2)) + + ε/σ*(∑ i, (δ i*(β i*Real.cos (inner ℝ (g i) (η-θ)/σ)+Real.sin (inner ℝ (g i) (η-θ)/σ)) + + (inner ℝ (g i) v/σ)*((1+α i*β i)*Real.sin (inner ℝ (g i) (η-θ)/σ)- + (α i-β i)*Real.cos (inner ℝ (g i) (η-θ)/σ)))) + +lemma pairing_hasDeriv (g : ι → E) (q ε σ : ℝ) (θ η v : E) + (α β δ : ι → ℝ) (t : ℝ) : + HasDerivAt (fun t => pairing g q ε σ (θ+t • v) η (fun i => α i+t*δ i) β) + (differential g q ε σ (θ+t • v) η v (fun i => α i+t*δ i) β δ) t := by + have hx : HasDerivAt (fun t : ℝ => η-(θ+t • v)) (-v) t := + by simpa using (((hasDerivAt_id t).smul_const v).const_add θ).const_sub η + have hn := hx.norm_sq.neg.div_const (2*σ^2) + have he := hn.exp.const_mul q + have hi (i : ι) : HasDerivAt (fun t : ℝ => inner ℝ (g i) (η-(θ+t • v))/σ) + (-inner ℝ (g i) v/σ) t := by + convert ((innerSL ℝ (g i)).hasFDerivAt.comp_hasDerivAt t hx).div_const σ using 1 <;> try rfl + simp only [innerSL_apply_apply, inner_neg_right] + have hd (i : ι) : HasDerivAt (fun t : ℝ => α i+t*δ i) (δ i) t := by + simpa using ((hasDerivAt_id t).mul_const (δ i)).const_add (α i) + have hs (i : ι) := ((((hd i).mul_const (β i)).const_add 1).mul (hi i).cos).add + (((hd i).sub_const (β i)).mul (hi i).sin) + have hsum := (HasDerivAt.sum (u := Finset.univ) (fun i _ => hs i)).const_mul (ε/σ) + convert he.add hsum using 1 <;> try rfl + · funext z; simp [pairing, Finset.sum_apply] + · simp only [differential, real_inner_smul_left, inner_neg_right, Pi.neg_apply] + congr 1 + · ring + · congr 1; apply Finset.sum_congr rfl; intro i _; ring + +lemma differential_correction (g : ι → E) {q ε σ : ℝ} (hε : 0 ≤ ε) (hσ : 0 < σ) + (θ η v : E) (α β δ : ι → ℝ) : + |differential g q ε σ θ η v α β δ - differential g q ε σ θ η v 0 0 δ| ≤ + ε/σ*(∑ i, (|δ i| * |β i| + |inner ℝ (g i) v|/σ*(|α i| * |β i| + |α i| + |β i|))) := by + have heq : differential g q ε σ θ η v α β δ - differential g q ε σ θ η v 0 0 δ = + ε/σ*(∑ i, (δ i*β i*Real.cos (inner ℝ (g i) (η-θ)/σ) + + (inner ℝ (g i) v/σ)*(α i*β i*Real.sin (inner ℝ (g i) (η-θ)/σ)- + α i*Real.cos (inner ℝ (g i) (η-θ)/σ)+β i*Real.cos (inner ℝ (g i) (η-θ)/σ)))) := by + unfold differential + simp only [Pi.zero_apply, mul_zero, zero_mul, add_zero, sub_zero] + rw [show ∀ a b c : ℝ, (a+b)-(a+c)=b-c by intros; ring] + rw [← mul_sub, ← Finset.sum_sub_distrib] + congr 1 + apply Finset.sum_congr rfl + intro i _; ring + rw [heq, abs_mul, abs_of_nonneg (div_nonneg hε hσ.le)] + apply mul_le_mul_of_nonneg_left _ (div_nonneg hε hσ.le) + refine (Finset.abs_sum_le_sum_abs _ _).trans (Finset.sum_le_sum fun i _ => ?_) + let t := inner ℝ (g i) (η-θ)/σ + have hc : |Real.cos t| ≤ 1 := Real.abs_cos_le_one t + have hs : |Real.sin t| ≤ 1 := Real.abs_sin_le_one t + have hp : |α i*β i*Real.sin t-α i*Real.cos t+β i*Real.cos t| ≤ + |α i| * |β i| + |α i| + |β i| := by + calc + _ ≤ |α i*β i*Real.sin t| + |α i*Real.cos t| + |β i*Real.cos t| := + (abs_add_le _ _).trans (add_le_add (abs_sub _ _) le_rfl) + _ ≤ _ := by + simp only [abs_mul] + exact add_le_add (add_le_add + (mul_le_of_le_one_right (mul_nonneg (abs_nonneg _) (abs_nonneg _)) hs) + (mul_le_of_le_one_right (abs_nonneg _) hc)) + (mul_le_of_le_one_right (abs_nonneg _) hc) + calc + _ ≤ |δ i*β i*Real.cos t| + |(inner ℝ (g i) v/σ)* + (α i*β i*Real.sin t-α i*Real.cos t+β i*Real.cos t)| := abs_add_le _ _ + _ = |δ i| * |β i| * |Real.cos t| + |inner ℝ (g i) v|/σ* + |α i*β i*Real.sin t-α i*Real.cos t+β i*Real.cos t| := by + simp only [abs_mul, abs_div, abs_of_pos hσ] + _ ≤ _ := add_le_add + (mul_le_of_le_one_right (mul_nonneg (abs_nonneg _) (abs_nonneg _)) hc) + (mul_le_mul_of_nonneg_left hp (div_nonneg (abs_nonneg _) hσ.le)) + +lemma cancellation (g : ι → E) (q ε σ k : ℝ) (θ η v : E) (h : ι → ℝ) + (hq : q ≠ 0) (hσ : σ ≠ 0) (hk : k = q^2/(Fintype.card ι : ℝ)) + (hε : ε ≠ 0) : + differential g q ε σ θ η v 0 0 + (fun i => k/ε*(h i-inner ℝ (g i) v/q)) = + k/σ*(∑ i, h i*Real.sin (inner ℝ (g i) (η-θ)/σ)) + + q/σ*inner ℝ + (Real.exp (-‖(σ⁻¹:ℝ) • (η-θ)‖^2/2) • ((σ⁻¹:ℝ) • (η-θ)) - + ((Fintype.card ι : ℝ)⁻¹) • ∑ i, Real.sin (inner ℝ (g i) (η-θ)/σ) • g i) v + + ε/σ^2*(∑ i, inner ℝ (g i) v*Real.sin (inner ℝ (g i) (η-θ)/σ)) := by + have hn : ‖(σ⁻¹:ℝ) • (η-θ)‖^2 = ‖η-θ‖^2/σ^2 := by + rw [norm_smul, mul_pow, Real.norm_eq_abs, sq_abs, inv_pow]; ring + simp only [differential, Pi.zero_apply, mul_zero, zero_mul, add_zero, sub_zero, + zero_add, one_mul, inner_sub_left, real_inner_smul_left, sum_inner, hn] + have he : - (‖η-θ‖^2/σ^2)/2 = -‖η-θ‖^2/(2*σ^2) := by ring + rw [he] + simp only [Finset.mul_sum] + have hterm (i : ι) : ε/σ * (k/ε*(h i-inner ℝ (g i) v/q)*Real.sin (inner ℝ (g i) (η-θ)/σ) + + (inner ℝ (g i) v/σ)*Real.sin (inner ℝ (g i) (η-θ)/σ)) = + k/σ*(h i*Real.sin (inner ℝ (g i) (η-θ)/σ)) - + q/σ*((Fintype.card ι : ℝ)⁻¹)*(Real.sin (inner ℝ (g i) (η-θ)/σ)*inner ℝ (g i) v) + + ε/σ^2*(inner ℝ (g i) v*Real.sin (inner ℝ (g i) (η-θ)/σ)) := by + rw [hk] + field_simp + + simp_rw [hterm] + simp only [Finset.sum_add_distrib, Finset.sum_sub_distrib, ← Finset.mul_sum] + ring + +end UniformSparsestCut.Profile + +namespace UniformSparsestCut.Profile +variable {E : Type u3} [NormedAddCommGroup E] [InnerProductSpace ℝ E] +variable {S : Type u4} {N : Type u5} [Fintype S] [DecidableEq S] [Fintype N] + +lemma active_cancellation (g : S → N → E) (s : S) (q ε σ k : ℝ) + (θ η v : E) (h : N → ℝ) (hq : q ≠ 0) (hσ : σ ≠ 0) + (hk : k = q^2/(Fintype.card N : ℝ)) (hε : ε ≠ 0) : + differential (fun j : S × N => g j.1 j.2) q ε σ θ η v 0 0 + (fun j => if j.1 = s then k/ε*(h j.2-inner ℝ (g j.1 j.2) v/q) else 0) = + k/σ*(∑ i, h i*Real.sin (inner ℝ (g s i) (η-θ)/σ)) + + q/σ*inner ℝ + (Real.exp (-‖(σ⁻¹:ℝ) • (η-θ)‖^2/2) • ((σ⁻¹:ℝ) • (η-θ)) - + ((Fintype.card N : ℝ)⁻¹) • ∑ i, Real.sin (inner ℝ (g s i) (η-θ)/σ) • g s i) v + + ε/σ^2*(∑ j : S × N, inner ℝ (g j.1 j.2) v*Real.sin (inner ℝ (g j.1 j.2) (η-θ)/σ)) := by + have hn : ‖(σ⁻¹:ℝ) • (η-θ)‖^2 = ‖η-θ‖^2/σ^2 := by + rw [norm_smul, mul_pow, Real.norm_eq_abs, sq_abs, inv_pow]; ring + have he : -(‖η-θ‖^2/σ^2)/2 = -‖η-θ‖^2/(2*σ^2) := by ring + simp only [differential, Pi.zero_apply, mul_zero, zero_mul, add_zero, + sub_zero, zero_add, one_mul, Finset.sum_add_distrib] + have hd : (∑ j : S × N, (if j.1 = s then k/ε*(h j.2-inner ℝ (g j.1 j.2) v/q) else 0) * + Real.sin (inner ℝ (g j.1 j.2) (η-θ)/σ)) = + k/ε*∑ i, (h i-inner ℝ (g s i) v/q)*Real.sin (inner ℝ (g s i) (η-θ)/σ) := by + simp only [Fintype.sum_prod_type, ite_mul, zero_mul] + simp only [Finset.sum_ite_irrel, Finset.sum_const_zero, Finset.sum_ite_eq', Finset.mem_univ, ite_true] + rw [Finset.mul_sum]; apply Finset.sum_congr rfl; intros; ring + rw [hd] + simp only [inner_sub_left, real_inner_smul_left, sum_inner, hn, he] + simp only [sub_mul, Finset.sum_sub_distrib, div_mul_eq_mul_div, + ← Finset.sum_div] + have hs : (∑ i, Real.sin (inner ℝ (g s i) (η-θ)/σ)*inner ℝ (g s i) v) = + ∑ i, inner ℝ (g s i) v*Real.sin (inner ℝ (g s i) (η-θ)/σ) := by + apply Finset.sum_congr rfl; intros; ring + rw [hs, hk] + field_simp + ring + +lemma active_bound (g : S → N → E) (s : S) {q ε σ k γ G : ℝ} + (θ η v : E) (h : N → ℝ) (hq : 0 < q) (hε : 0 < ε) (hσ : 0 < σ) + (hk : k = q^2/(Fintype.card N : ℝ)) (hg : ∀ s i, ‖g s i‖ ≤ G) + (hf : ‖Real.exp (-‖(σ⁻¹:ℝ) • (η-θ)‖^2/2) • ((σ⁻¹:ℝ) • (η-θ)) - + ((Fintype.card N : ℝ)⁻¹) • ∑ i, Real.sin (inner ℝ (g s i) (η-θ)/σ) • g s i‖ ≤ γ) : + |differential (fun j : S × N => g j.1 j.2) q ε σ θ η v 0 0 + (fun j => if j.1 = s then k/ε*(h j.2-inner ℝ (g j.1 j.2) v/q) else 0)| ≤ + k/σ*(∑ i, |h i|) + q*γ/σ*‖v‖ + + ε/σ^2*((Fintype.card S : ℝ)*(Fintype.card N : ℝ)*G)*‖v‖ := by + have hk0 : 0 ≤ k := by rw [hk]; positivity + rw [active_cancellation g s q ε σ k θ η v h hq.ne' hσ.ne' hk hε.ne'] + have hsum : |∑ i, h i*Real.sin (inner ℝ (g s i) (η-θ)/σ)| ≤ ∑ i, |h i| := by + refine (Finset.abs_sum_le_sum_abs _ _).trans (Finset.sum_le_sum fun i _ => ?_) + rw [abs_mul]; exact mul_le_of_le_one_right (abs_nonneg _) (Real.abs_sin_le_one _) + have hfour := (abs_real_inner_le_norm _ v).trans (mul_le_mul_of_nonneg_right hf (norm_nonneg v)) + have hglobal : |∑ j : S × N, inner ℝ (g j.1 j.2) v*Real.sin (inner ℝ (g j.1 j.2) (η-θ)/σ)| ≤ + (Fintype.card S : ℝ)*(Fintype.card N : ℝ)*G*‖v‖ := by + calc + _ ≤ ∑ j : S × N, |inner ℝ (g j.1 j.2) v*Real.sin (inner ℝ (g j.1 j.2) (η-θ)/σ)| := + Finset.abs_sum_le_sum_abs _ _ + _ ≤ ∑ _j : S × N, G*‖v‖ := by + apply Finset.sum_le_sum; intro j _ + rw [abs_mul] + exact (mul_le_of_le_one_right (abs_nonneg _) (Real.abs_sin_le_one _)).trans + ((abs_real_inner_le_norm _ _).trans (mul_le_mul_of_nonneg_right (hg j.1 j.2) (norm_nonneg v))) + _ = _ := by simp [Fintype.card_prod]; ring + calc + _ ≤ |k/σ*(∑ i, h i*Real.sin (inner ℝ (g s i) (η-θ)/σ))| + + |q/σ*inner ℝ (Real.exp (-‖(σ⁻¹:ℝ) • (η-θ)‖^2/2) • ((σ⁻¹:ℝ) • (η-θ)) - + ((Fintype.card N : ℝ)⁻¹) • ∑ i, Real.sin (inner ℝ (g s i) (η-θ)/σ) • g s i) v| + + |ε/σ^2*(∑ j : S × N, inner ℝ (g j.1 j.2) v*Real.sin (inner ℝ (g j.1 j.2) (η-θ)/σ))| := + (abs_add_le _ _).trans (add_le_add (abs_add_le _ _) le_rfl) + _ ≤ k/σ*(∑ i, |h i|) + q/σ*(γ*‖v‖) + + ε/σ^2*((Fintype.card S : ℝ)*(Fintype.card N : ℝ)*G*‖v‖) := by + simp only [abs_mul, abs_of_nonneg (div_nonneg hk0 hσ.le), + abs_of_pos (div_pos hq hσ), abs_of_pos (div_pos hε (sq_pos_of_pos hσ))] + exact add_le_add (add_le_add (mul_le_mul_of_nonneg_left hsum (div_nonneg hk0 hσ.le)) + (mul_le_mul_of_nonneg_left hfour (div_nonneg hq.le hσ.le))) + (mul_le_mul_of_nonneg_left hglobal (div_nonneg hε.le (sq_nonneg σ))) + _ = _ := by ring + +end UniformSparsestCut.Profile + +namespace UniformSparsestCut.Profile +variable {E : Type u6} [NormedAddCommGroup E] [InnerProductSpace ℝ E] +variable {ι : Type u7} [Fintype ι] + +def kernel (g : ι → E) (q ε a b : ℝ) (θ η : E) (α β : ι → ℝ) : ℝ := + ∫ σ in a..b, pairing g q ε σ θ η α β + +lemma pairing_continuousOn (g : ι → E) (q ε : ℝ) (θ η : E) (α β : ι → ℝ) + {a b : ℝ} (ha : 0 < a) : ContinuousOn (fun σ => pairing g q ε σ θ η α β) (Icc a b) := by + have hn : ∀ σ ∈ Icc a b, σ ≠ 0 := fun σ h => (ha.trans_le h.1).ne' + have hnp : ∀ σ ∈ Icc a b, 2*σ^2 ≠ 0 := fun σ h => mul_ne_zero (by norm_num) (pow_ne_zero _ (hn σ h)) + unfold pairing + refine (continuousOn_const.mul (Real.continuous_exp.comp_continuousOn + (continuousOn_const.div (by fun_prop) hnp))).add ?_ + apply (continuousOn_const.div continuousOn_id hn).mul + apply continuousOn_finsetSum + intro i _ + have hc := continuousOn_const.div continuousOn_id hn (f := fun _ : ℝ => inner ℝ (g i) (η-θ)) + exact (continuousOn_const.mul (Real.continuous_cos.comp_continuousOn hc)).add + (continuousOn_const.mul (Real.continuous_sin.comp_continuousOn hc)) + +lemma pairing_integrable (g : ι → E) (q ε : ℝ) (θ η : E) (α β : ι → ℝ) + {a b : ℝ} (ha : 0 < a) (hab : a ≤ b) : + IntervalIntegrable (fun σ => pairing g q ε σ θ η α β) volume a b := by + apply ContinuousOn.intervalIntegrable + rw [uIcc_of_le hab] + exact pairing_continuousOn g q ε θ η α β ha + +lemma pairing_correction (g : ι → E) {q ε σ : ℝ} (hε : 0 ≤ ε) (hσ : 0 < σ) + (θ η : E) (α β : ι → ℝ) : + |pairing g q ε σ θ η α β - pairing g q ε σ θ η 0 0| ≤ + ε/σ*∑ i, (|α i| * |β i|+|α i|+|β i|) := by + have he : pairing g q ε σ θ η α β - pairing g q ε σ θ η 0 0 = + ε/σ*∑ i, (α i*β i*Real.cos (inner ℝ (g i) (η-θ)/σ) + + α i*Real.sin (inner ℝ (g i) (η-θ)/σ)-β i*Real.sin (inner ℝ (g i) (η-θ)/σ)) := by + unfold pairing + simp only [Pi.zero_apply, mul_zero, add_zero, zero_mul, sub_zero, one_mul] + rw [show ∀ c d e : ℝ, (c+d)-(c+e)=d-e by intros; ring, ← mul_sub, ← Finset.sum_sub_distrib] + congr 1; apply Finset.sum_congr rfl; intro i _; ring + rw [he, abs_mul, abs_of_nonneg (div_nonneg hε hσ.le)] + apply mul_le_mul_of_nonneg_left _ (div_nonneg hε hσ.le) + refine (Finset.abs_sum_le_sum_abs _ _).trans (Finset.sum_le_sum fun i _ => ?_) + calc + _ ≤ |α i*β i*Real.cos (inner ℝ (g i) (η-θ)/σ)| + + |α i*Real.sin (inner ℝ (g i) (η-θ)/σ)|+|β i*Real.sin (inner ℝ (g i) (η-θ)/σ)| := + (abs_sub _ _).trans (add_le_add (abs_add_le _ _) le_rfl) + _ ≤ _ := by + simp only [abs_mul] + exact add_le_add (add_le_add + (mul_le_of_le_one_right (mul_nonneg (abs_nonneg _) (abs_nonneg _)) (Real.abs_cos_le_one _)) + (mul_le_of_le_one_right (abs_nonneg _) (Real.abs_sin_le_one _))) + (mul_le_of_le_one_right (abs_nonneg _) (Real.abs_sin_le_one _)) + +lemma kernel_correction (g : ι → E) {q ε a b A : ℝ} + (hε : 0 ≤ ε) (ha : 0 < a) (hab : a ≤ b) (hA : 0 ≤ A) + (θ η : E) (α β : ι → ℝ) (hα : ∀ i, |α i| ≤ A) (hβ : ∀ i, |β i| ≤ A) : + |kernel g q ε a b θ η α β - kernel g q ε a b θ η 0 0| ≤ + ε*(Fintype.card ι : ℝ)*(A^2+2*A)*Real.log (b/a) := by + have hip := pairing_integrable g q ε θ η α β ha hab + have hiz := pairing_integrable g q ε θ η 0 0 ha hab + have hiinv : IntervalIntegrable (fun σ : ℝ => σ⁻¹) volume a b := by + apply ContinuousOn.intervalIntegrable + rw [uIcc_of_le hab] + exact continuousOn_id.inv₀ (fun σ h => (ha.trans_le h.1).ne') + have hi := hiinv.const_mul (ε*(Fintype.card ι : ℝ)*(A^2+2*A)) + unfold kernel + rw [← intervalIntegral.integral_sub hip hiz] + calc + _ ≤ ∫ σ in a..b, |pairing g q ε σ θ η α β-pairing g q ε σ θ η 0 0| := + intervalIntegral.abs_integral_le_integral_abs hab + _ ≤ ∫ σ in a..b, ε*(Fintype.card ι : ℝ)*(A^2+2*A)*σ⁻¹ := by + apply intervalIntegral.integral_mono_on hab (hip.sub hiz).abs hi + intro σ hσ + have hp := ha.trans_le hσ.1 + have hs : (∑ i, (|α i| * |β i|+|α i|+|β i|)) ≤ (Fintype.card ι : ℝ)*(A^2+2*A) := by + calc + _ ≤ ∑ _i : ι, (A^2+2*A) := by + apply Finset.sum_le_sum; intro i _ + have hm := mul_le_mul (hα i) (hβ i) (abs_nonneg _) hA + nlinarith [hα i, hβ i] + _ = _ := by simp; ring + calc + _ ≤ ε/σ*∑ i, (|α i| * |β i|+|α i|+|β i|) := pairing_correction g hε hp θ η α β + _ ≤ ε/σ*((Fintype.card ι : ℝ)*(A^2+2*A)) := mul_le_mul_of_nonneg_left hs (div_nonneg hε hp.le) + _ = _ := by ring + _ = _ := by rw [intervalIntegral.integral_const_mul, integral_inv_of_pos ha (ha.trans_le hab)] + +lemma integral_inv_sq {a b : ℝ} (ha : 0 < a) (hab : a ≤ b) : + (∫ σ in a..b, (σ^2)⁻¹) = a⁻¹-b⁻¹ := by + have hd (σ : ℝ) (hσ : σ ∈ Icc a b) : HasDerivAt (fun σ : ℝ => -σ⁻¹) ((σ^2)⁻¹) σ := by + convert ((hasDerivAt_id σ).inv (ha.trans_le hσ.1).ne').neg using 1 <;> try rfl + simp; ring + have hi : IntervalIntegrable (fun σ : ℝ => (σ^2)⁻¹) volume a b := by + apply ContinuousOn.intervalIntegrable + rw [uIcc_of_le hab] + exact (continuousOn_id.pow 2).inv₀ (fun σ h => pow_ne_zero _ (ha.trans_le h.1).ne') + have h := intervalIntegral.integral_eq_sub_of_hasDerivAt + (fun σ hσ => hd σ (by simpa only [uIcc_of_le hab] using hσ)) hi + convert h using 1 ; ring + +lemma kernel_segment_bound (g : ι → E) {q ε a b C D : ℝ} (ha : 0 < a) (hab : a ≤ b) + (hD : 0 ≤ D) (θ η v : E) (α β δ : ι → ℝ) + (hd : ∀ t ∈ Icc (0 : ℝ) 1, ∀ σ ∈ Icc a b, + |differential g q ε σ (θ+t • v) η v (fun i => α i+t*δ i) β δ| ≤ C/σ+D/σ^2) : + |kernel g q ε a b (θ+v) η (fun i => α i+δ i) β-kernel g q ε a b θ η α β| ≤ + C*Real.log (b/a)+D/a := by + have hip := pairing_integrable g q ε (θ+v) η (fun i => α i+δ i) β ha hab + have hiz := pairing_integrable g q ε θ η α β ha hab + have hii : IntervalIntegrable (fun σ : ℝ => σ⁻¹) volume a b := by + apply ContinuousOn.intervalIntegrable + rw [uIcc_of_le hab] + exact continuousOn_id.inv₀ (fun σ h => (ha.trans_le h.1).ne') + have hiis : IntervalIntegrable (fun σ : ℝ => (σ^2)⁻¹) volume a b := by + apply ContinuousOn.intervalIntegrable + rw [uIcc_of_le hab] + exact (continuousOn_id.pow 2).inv₀ (fun σ h => pow_ne_zero _ (ha.trans_le h.1).ne') + have hi := (hii.const_mul C).add (hiis.const_mul D) + have hbound (σ : ℝ) (hσ : σ ∈ Icc a b) : + |pairing g q ε σ (θ+v) η (fun i => α i+δ i) β-pairing g q ε σ θ η α β| ≤ C/σ+D/σ^2 := by + have h := norm_image_sub_le_of_norm_deriv_le_segment_01' + (fun t ht => (pairing_hasDeriv g q ε σ θ η v α β δ t).hasDerivWithinAt) + (fun t ht => by simpa only [Real.norm_eq_abs] using hd t ⟨ht.1, ht.2.le⟩ σ hσ) + simpa only [one_smul, one_mul, zero_smul, add_zero, zero_mul, Real.norm_eq_abs] using h + unfold kernel + rw [← intervalIntegral.integral_sub hip hiz] + calc + _ ≤ ∫ σ in a..b, |pairing g q ε σ (θ+v) η (fun i => α i+δ i) β-pairing g q ε σ θ η α β| := + intervalIntegral.abs_integral_le_integral_abs hab + _ ≤ ∫ σ in a..b, C*σ⁻¹+D*(σ^2)⁻¹ := by + apply intervalIntegral.integral_mono_on hab (hip.sub hiz).abs hi + intro σ hσ; simpa only [div_eq_mul_inv] using hbound σ hσ + _ = C*Real.log (b/a)+D*(a⁻¹-b⁻¹) := by + rw [intervalIntegral.integral_add (hii.const_mul C) (hiis.const_mul D), + intervalIntegral.integral_const_mul, intervalIntegral.integral_const_mul, + integral_inv_of_pos ha (ha.trans_le hab), integral_inv_sq ha hab] + _ ≤ _ := by + simp only [div_eq_mul_inv] + have := mul_nonneg hD (inv_nonneg.mpr (ha.trans_le hab).le) + nlinarith + +end UniformSparsestCut.Profile + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SparsestCut/Replication.lean b/lean/OAI/Combinatorics/SparsestCut/Replication.lean new file mode 100644 index 0000000000000000000000000000000000000000..b39258b99760de6fc3014bfdba61af5877b2cc65 --- /dev/null +++ b/lean/OAI/Combinatorics/SparsestCut/Replication.lean @@ -0,0 +1,172 @@ +import OAI.Combinatorics.SparsestCut.CutDuality + +namespace OAI + +universe u1 u2 u3 u4 + +open scoped BigOperators Topology NNReal RealInnerProductSpace InnerProductSpace Matrix ContDiff ENNReal +open MeasureTheory ProbabilityTheory Set Filter Matrix + +noncomputable section + +namespace UniformSparsestCut.Replication +variable {V : Type u1} [Fintype V] +def count (M : ℕ) (w : V → ℝ) (v : V) : ℕ := 1+⌊(M:ℝ)*w v⌋₊ +def Copies (M : ℕ) (w : V → ℝ) := (v : V) × Fin (count M w v) +instance (M : ℕ) (w : V → ℝ) : Fintype (Copies M w) := inferInstanceAs (Fintype (Sigma _)) +def n (M : ℕ) (w : V → ℝ) : ℕ := Fintype.card (Copies M w) +def q (M : ℕ) (w : V → ℝ) (v : V) : ℝ := (count M w v:ℝ)/(n M w:ℝ) +omit [Fintype V] in +lemma count_pos (M : ℕ) (w : V → ℝ) (v : V) : 0 linarith +lemma n_bounds (M : ℕ) (w : V → ℝ) (hw : ∀ v, 0≤w v) (hws : ∑ v, w v=1) : + M≤n M w ∧ n M w≤M+Fintype.card V := by + have hs : (n M w:ℝ)-(M:ℝ)=∑ v, ((count M w v:ℝ)-(M:ℝ)*w v) := by + rw [Finset.sum_sub_distrib,← Finset.mul_sum,hws,mul_one,n_sum,Nat.cast_sum] + have h0 : 0≤(n M w:ℝ)-(M:ℝ) := by rw [hs]; exact Finset.sum_nonneg (fun v _ => (count_error M w hw v).1.le) + have h1 : (n M w:ℝ)-(M:ℝ)≤Fintype.card V := by + rw [hs] + calc + _ ≤ ∑ _v : V, (1:ℝ) := Finset.sum_le_sum (fun v _ => (count_error M w hw v).2) + _ = _ := by simp + constructor + · exact_mod_cast (show (M:ℝ)≤n M w by linarith) + · exact_mod_cast (show (n M w:ℝ)≤(M:ℝ)+Fintype.card V by linarith) +lemma q_nonneg (M : ℕ) (w : V → ℝ) (v : V) : 0≤q M w v := by unfold q; positivity +lemma q_sum (M : ℕ) (w : V → ℝ) (hn : 0 he v) + _ = 2*((n M w:ℝ)-(M:ℝ))/(n M w:ℝ) := by + rw [← Finset.sum_div,Finset.sum_add_distrib,← Finset.mul_sum,hws,mul_one,← hE]; ring + _ ≤ 2*(Fintype.card V:ℝ)/(n M w:ℝ) := by + apply div_le_div_of_nonneg_right _ hn.le + have h : (n M w:ℝ)≤(M:ℝ)+Fintype.card V := by exact_mod_cast hb.2 + linarith + _ ≤ _ := div_le_div_of_nonneg_left (by positivity) hMr (by exact_mod_cast hb.1) + +lemma product_expectation_bound (p q : V → ℝ) (hp : ∀ v, 0≤p v) (hq : ∀ v, 0≤q v) + (hps : ∑ v, p v=1) (hqs : ∑ v, q v=1) (g : V → V → ℝ) {D : ℝ} + (_hD : 0≤D) (hg : ∀ v z, |g v z|≤D) : + |(∑ v, ∑ z, p v*p z*g v z)-(∑ v, ∑ z, q v*q z*g v z)|≤ + 2*D*(∑ v, |p v-q v|) := by + have he (v z : V) : p v*p z*g v z-q v*q z*g v z= + (p v-q v)*p z*g v z+q v*(p z-q z)*g v z := by ring + calc + _ = |∑ v, ∑ z, ((p v-q v)*p z*g v z+q v*(p z-q z)*g v z)| := by + simp only [← Finset.sum_sub_distrib,he] + _ ≤ ∑ v, ∑ z, |(p v-q v)*p z*g v z+q v*(p z-q z)*g v z| := + (Finset.abs_sum_le_sum_abs _ _).trans (Finset.sum_le_sum (fun v _ => Finset.abs_sum_le_sum_abs _ _)) + _ ≤ ∑ v, ∑ z, (|p v-q v| *p z*D+q v*|p z-q z| *D) := by + apply Finset.sum_le_sum; intro v hv + apply Finset.sum_le_sum; intro z hz + calc + _ ≤ |(p v-q v)*p z*g v z|+|q v*(p z-q z)*g v z| := abs_add_le _ _ + _ ≤ _ := by + rw [abs_mul,abs_mul,abs_mul,abs_mul,abs_of_nonneg (hp z),abs_of_nonneg (hq v)] + exact add_le_add (mul_le_mul_of_nonneg_left (hg v z) (mul_nonneg (abs_nonneg _) (hp z))) + (mul_le_mul_of_nonneg_left (hg v z) (mul_nonneg (hq v) (abs_nonneg _))) + _ = _ := by + simp only [Finset.sum_add_distrib,← Finset.sum_mul,← Finset.mul_sum,hps,hqs,mul_one,one_mul] + ring +end UniformSparsestCut.Replication + +namespace UniformSparsestCut.Replication +open scoped BigOperators RealInnerProductSpace +noncomputable section +variable {V : Type u2} [Fintype V] +def rep (M : ℕ) (w : V → ℝ) (i : Fin (n M w)) : V := ((Fintype.equivFin (Copies M w)).symm i).1 +def representative (M : ℕ) (w : V → ℝ) (v : V) : Fin (n M w) := + (Fintype.equivFin (Copies M w)) ⟨v,⟨0,count_pos M w v⟩⟩ +lemma rep_section (M : ℕ) (w : V → ℝ) (v : V) : rep M w (representative M w v)=v := by + exact congrArg (fun copy : Copies M w => copy.1) + ((Fintype.equivFin (Copies M w)).symm_apply_apply ⟨v, ⟨0, count_pos M w v⟩⟩) +lemma sum_rep (M : ℕ) (w : V → ℝ) (g : V → ℝ) : + (∑ i : Fin (n M w), g (rep M w i))=∑ v, (count M w v:ℝ)*g v := by + classical + calc + _ = ∑ c : Copies M w, g (rep M w ((Fintype.equivFin (Copies M w)) c)) := + ((Fintype.equivFin (Copies M w)).sum_comp (fun i => g (rep M w i))).symm + _ = ∑ c : Copies M w, g c.1 := Finset.sum_congr rfl (fun copy _ => + congrArg (fun copy : Copies M w => g copy.1) + ((Fintype.equivFin (Copies M w)).symm_apply_apply copy)) + _ = _ := by + change (∑ c : (v : V) × Fin (count M w v), g c.1) = _ + simp [Fintype.sum_sigma] +lemma ordered_sum (M : ℕ) (w : V → ℝ) (hn : 0 < n M w) (g : V → V → ℝ) : + (∑ i : Fin (n M w), ∑ j, g (rep M w i) (rep M w j))= + (n M w:ℝ)^2*(∑ v, ∑ z, q M w v*q M w z*g v z) := by + have hn0 : (n M w:ℝ)≠0 := by exact_mod_cast hn.ne' + calc + _ = ∑ i : Fin (n M w), ∑ z, (count M w z:ℝ)*g (rep M w i) z := + Finset.sum_congr rfl (fun i _ => sum_rep M w (g (rep M w i))) + _ = ∑ v, (count M w v:ℝ)*(∑ z, (count M w z:ℝ)*g v z) := + sum_rep M w (fun v => ∑ z, (count M w z:ℝ)*g v z) + _ = _ := by + simp only [Finset.mul_sum,q] + apply Finset.sum_congr rfl + intro v hv + apply Finset.sum_congr rfl + intro z hz + field_simp + +lemma collapse (M : ℕ) (w : V → ℝ) (d : V → V → ℝ) (hself : ∀ v, d v v=0) + {A : Type u3} [Fintype A] (F : Fin (n M w) → A → ℝ) + (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) : + F i a=F (representative M w (rep M w i)) a := by + classical + have h := hF i (representative M w (rep M w i)) + rw [rep_section,hself] at h + 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 + exact sub_eq_zero.mp (abs_nonpos_iff.mp hh) +lemma descend_contraction (M : ℕ) (w : V → ℝ) (d : V → V → ℝ) + {A : Type u4} [Fintype A] (F : Fin (n M w) → A → ℝ) + (hF : ∀ i j, (∑ a, |F i a-F j a|)≤d (rep M w i) (rep M w j)) : + ∀ v z, (∑ a, |F (representative M w v) a-F (representative M w z) a|)≤d v z := by + intro v z + simpa only [rep_section] using hF (representative M w v) (representative M w z) +lemma expectation_error (M : ℕ) (hM : 0 < M) (w : V → ℝ) (hw : ∀ v, 0≤w v) (hws : (∑ v,w v)=1) + (g : V → V → ℝ) {D : ℝ} (hD : 0≤D) (hg : ∀ v z, |g v z|≤D) : + |(∑ v, ∑ z, q M w v*q M w z*g v z)-(∑ v, ∑ z, w v*w z*g v z)|≤ + 4*D*(Fintype.card V:ℝ)/M := by + have hn : 0 < n M w := hM.trans_le (n_bounds M w hw hws).1 + have h := product_expectation_bound (q M w) w (q_nonneg M w) hw (q_sum M w hn) hws g hD hg + calc + _ ≤ 2*D*(∑ v, |q M w v-w v|) := h + _ ≤ 2*D*(2*(Fintype.card V:ℝ)/M) := mul_le_mul_of_nonneg_left (q_l1_bound M hM w hw hws) (by positivity) + _ = _ := by ring +end +end UniformSparsestCut.Replication + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SparsestCut/RoundedCharts.lean b/lean/OAI/Combinatorics/SparsestCut/RoundedCharts.lean new file mode 100644 index 0000000000000000000000000000000000000000..1730d54da8e6e3ffb2af5bc32d410a4588d113f8 --- /dev/null +++ b/lean/OAI/Combinatorics/SparsestCut/RoundedCharts.lean @@ -0,0 +1,321 @@ +import OAI.Combinatorics.SparsestCut.ChartLinear + +namespace OAI + +universe u1 u2 + +open scoped BigOperators Topology NNReal RealInnerProductSpace InnerProductSpace Matrix ContDiff ENNReal +open MeasureTheory ProbabilityTheory Set Filter Matrix + +noncomputable section + +namespace UniformSparsestCut.SourceCharts +open scoped BigOperators RealInnerProductSpace +open Filter Set +noncomputable section +variable {m : ℕ} (f : PivotFamily.PFamily m) (hm : 0 < m) +local notation "E" => EuclideanSpace ℝ (Fin m) +local notation "F" => EuclideanSpace ℝ (Fin (m^6)) +def u (s : Fin (m^3)) (i : Fin (m^6)) : E := (Real.sqrt m)⁻¹ • f.g s i +def lower (m : ℕ) : ℝ := (m:ℝ)^6/(2*m) +include hm +lemma lower_pos : 0 (Real.sqrt m)⁻¹ • f.g s i) x‖^2 + simpa only [Nat.cast_pow] using h +def B (s : Fin (m^3)) : F →L[ℝ] E := + ChartLinear.pseudoInverse (FrameCharts.chart (u f s)) (lower_pos hm) (energy f hm s) +lemma B_left (s : Fin (m^3)) (x : E) : B f hm s (FrameCharts.chart (u f s) x)=x := by + have h := ChartLinear.pseudoInverse_comp (FrameCharts.chart (u f s)) (lower_pos hm) (energy f hm s) + exact congrArg (fun L : E →L[ℝ] E => L x) h +lemma u_norm (s : Fin (m^3)) (i : Fin (m^6)) : 1/2≤‖u f s i‖ ∧ ‖u f s i‖≤2 := + FrameCharts.normalized_norms (f.g s) hm (f.norms s) i +lemma u_nonzero (s : Fin (m^3)) (i : Fin (m^6)) : u f s i≠0 := by + have h := (u_norm f hm s i).1 + intro hz; rw [hz,norm_zero] at h; norm_num at h +lemma u_nonparallel (s : Fin (m^3)) (i j : Fin (m^6)) (hij : i≠j) (t : ℝ) : + u f s i≠t • u f s j := by + intro h + apply f.nonparallel s i j hij t + have hq : (Real.sqrt m)⁻¹≠0 := inv_ne_zero (ne_of_gt (Real.sqrt_pos.mpr (by exact_mod_cast hm))) + have he := congrArg (fun x : E => Real.sqrt m • x) h + have hq0 : Real.sqrt (m:ℝ)≠0 := ne_of_gt (Real.sqrt_pos.mpr (by exact_mod_cast hm)) + have hmul : Real.sqrt (m:ℝ)*(t*(Real.sqrt (m:ℝ))⁻¹)=t := by field_simp + simpa only [u,smul_smul,mul_inv_cancel₀ hq0,hmul,one_smul] using he +lemma u_pivot (s : Fin (m^3)) (i : Fin (m^6)) (j : Fin m ) : + 1/((m:ℝ)^30*Real.sqrt m) < |u f s i j| := by + have hq : 0 f i) := by + classical + rw [Fintype.linearIndependent_iff] + intro c hc j + by_contra hj + let t := s.filter (fun i => ∀ hi : i ∈ s, 0 < c ⟨i,hi⟩) + obtain ⟨u,hu,htu⟩ := hs (t := t) (Finset.filter_subset _ _) + obtain ⟨x,hx⟩ := hA u hu + have hsign (i : s) : 0 < f i x ↔ 0 < c i := by + rw [(hx i).2] + have he : i.val ∈ s ∩ u ↔ i.val ∈ t := by rw [htu] + simp only [Finset.mem_inter, i.property, true_and, t, Finset.mem_filter] at he + exact he.trans ⟨fun h => h trivial, fun h _ => h⟩ + have hprod (i : s) : 0 ≤ c i * f i x := by + by_cases hp : 0 < c i + · exact le_of_lt (mul_pos hp ((hsign i).mpr hp)) + · exact mul_nonneg_of_nonpos_of_nonpos (le_of_not_gt hp) + (le_of_not_gt (mt (hsign i).mp hp)) + have hpj : 0 < c j * f j x := by + by_cases hp : 0 < c j + · exact mul_pos hp ((hsign j).mpr hp) + · have hn : c j < 0 := lt_of_le_of_ne (le_of_not_gt hp) hj + have hf : f j x < 0 := lt_of_le_of_ne (le_of_not_gt (mt (hsign j).mp hp)) (hx j).1 + exact mul_pos_of_neg_of_neg hn hf + have hp : 0 < ∑ i : s, c i * f i x := + Finset.sum_pos' (fun i _ => hprod i) ⟨j, Finset.mem_univ _, hpj⟩ + have hz := congrArg (fun L : E →ₗ[ℝ] ℝ => L x) hc + simp only [LinearMap.sum_apply, LinearMap.smul_apply, smul_eq_mul, LinearMap.zero_apply] at hz + linarith + +omit [Fintype ι] in +lemma vcDim_le (f : ι → E →ₗ[ℝ] ℝ) (A : Finset (Finset ι)) + (hA : ∀ u ∈ A, ∃ x : E, ∀ i, f i x ≠ 0 ∧ (0 < f i x ↔ i ∈ u)) : + A.vcDim ≤ Module.finrank ℝ E := by + apply Finset.sup_le + intro s hs + have h := (shattered_independent f A hA (Finset.mem_shatterer.mp hs)).fintype_card_le_finrank + simpa using h + +lemma sign_patterns_bound (f : ι → E →ₗ[ℝ] ℝ) (A : Finset (Finset ι)) + (hA : ∀ u ∈ A, ∃ x : E, ∀ i, f i x ≠ 0 ∧ (0 < f i x ↔ i ∈ u)) : + A.card ≤ ∑ k ∈ Finset.Iic (Module.finrank ℝ E), (Fintype.card ι).choose k := by + have hv := vcDim_le f A hA + exact (Finset.card_le_card_shatterer A).trans + (Finset.card_shatterer_le_sum_vcDim.trans + (Finset.sum_le_sum_of_subset (Finset.Iic_subset_Iic.mpr hv))) + +end UniformSparsestCut.HyperplaneCount + +namespace UniformSparsestCut.RoundedCharts +open MeasureTheory Set Filter +open scoped Topology BigOperators RealInnerProductSpace +variable {m N S : ℕ} +local notation "E" => EuclideanSpace ℝ (Fin m) +local notation "F" => EuclideanSpace ℝ (Fin N) + +def cube (R : ℝ) : Set E := {θ | ∀ j, |θ j| < R} + +def regular (u : Fin N → E) (τ : ℝ) (θ : E) : Prop := + ∀ i (k : ℤ), inner ℝ (u i) θ ≠ (k:ℝ)*τ + +def integerLabel (u : Fin N → E) (τ : ℝ) (θ : E) (i : Fin N) : ℤ := + ⌊inner ℝ (u i) θ/τ⌋ + +def rounded (u : Fin N → E) (τ : ℝ) (θ : E) : F := + WithLp.toLp 2 (fun i => τ*(integerLabel u τ θ i : ℝ)) + +def Vertex (u : Fin S → Fin N → E) (τ : ℝ) := + {p : Fin S × (Fin N → ℤ) // ∃ θ ∈ cube 2, regular (u p.1) τ θ ∧ integerLabel (u p.1) τ θ = p.2} + +def coordinate (u : Fin S → Fin N → E) (τ : ℝ) (v : Vertex u τ) : F := + WithLp.toLp 2 (fun i => τ*(v.val.2 i : ℝ)) + +lemma cube_norm {R : ℝ} (hR : 0 ≤ R) {θ : E} (hθ : θ ∈ cube R) : + ‖θ‖ ≤ R*Real.sqrt m := by + have hs : ‖θ‖^2 ≤ (m:ℝ)*R^2 := by + rw [EuclideanSpace.norm_sq_eq] + calc + _ ≤ ∑ _j : Fin m, R^2 := by + apply Finset.sum_le_sum; intro j _ + rw [Real.norm_eq_abs] + exact pow_le_pow_left₀ (abs_nonneg _) (hθ j).le _ + _ = _ := by simp + have hroot := Real.sq_sqrt (Nat.cast_nonneg m) + have hp : 0 ≤ R*Real.sqrt m := mul_nonneg hR (Real.sqrt_nonneg _) + have he : (R*Real.sqrt m)^2 = (m:ℝ)*R^2 := by rw [mul_pow,hroot]; ring + nlinarith [norm_nonneg θ] + +lemma hyperplane_null (u : E) (hu : u ≠ 0) (t : ℝ) : + volume {x : E | inner ℝ u x = t} = 0 := by + let H : AffineSubspace ℝ E := + { carrier := {x | inner ℝ u x = t} + smul_vsub_vadd_mem' := by + intro c x y z hx hy hz + change inner ℝ u x = t at hx + change inner ℝ u y = t at hy + change inner ℝ u z = t at hz + change inner ℝ u (c • (x-y)+z) = t + simp only [inner_add_right, inner_smul_right, inner_sub_right, hx, hy, hz] + ring } + have ht : H ≠ ⊤ := by + intro he + have hzero : (0:E) ∈ H := by rw [he]; trivial + have hone : u ∈ H := by rw [he]; trivial + change inner ℝ u 0 = t at hzero + change inner ℝ u u = t at hone + rw [inner_zero_right] at hzero + have := ((inner_self_eq_zero (𝕜 := ℝ)).mp (hone.trans hzero.symm)) + exact hu this + exact Measure.addHaar_affineSubspace volume H ht + +lemma ae_regular (u : Fin N → E) (τ : ℝ) (hu : ∀ i, u i ≠ 0) : + ∀ᵐ θ : E, regular u τ θ := by + have hi (i : Fin N) (k : ℤ) : ∀ᵐ θ : E, inner ℝ (u i) θ ≠ (k:ℝ)*τ := by + rw [ae_iff] + simpa only [not_not] using hyperplane_null (u i) (hu i) ((k:ℝ)*τ) + have hi' (i : Fin N) : ∀ᵐ θ : E, ∀ k : ℤ, inner ℝ (u i) θ ≠ (k:ℝ)*τ := + ae_all_iff.mpr (hi i) + exact ae_all_iff.mpr hi' + +lemma rounded_error_coordinate (u : Fin N → E) {τ : ℝ} (hτ : 0 < τ) (θ : E) (i : Fin N) : + 0 ≤ inner ℝ (u i) θ-rounded u τ θ i ∧ inner ℝ (u i) θ-rounded u τ θ i < τ := by + have hlo := Int.floor_le (inner ℝ (u i) θ/τ) + have hhi := Int.lt_floor_add_one (inner ℝ (u i) θ/τ) + have hl := (le_div_iff₀ hτ).mp hlo + have hh := (div_lt_iff₀ hτ).mp hhi + change 0 ≤ inner ℝ (u i) θ-τ*(⌊inner ℝ (u i) θ/τ⌋:ℝ) ∧ + inner ℝ (u i) θ-τ*(⌊inner ℝ (u i) θ/τ⌋:ℝ) < τ + constructor <;> nlinarith + +lemma rounded_error (u : Fin N → E) {τ : ℝ} (hτ : 0 < τ) (θ : E) : + ‖rounded u τ θ - FrameCharts.chart u θ‖ ≤ Real.sqrt N*τ := by + have hs : ‖rounded u τ θ - FrameCharts.chart u θ‖^2 ≤ (N:ℝ)*τ^2 := by + rw [EuclideanSpace.norm_sq_eq] + calc + _ ≤ ∑ _i : Fin N, τ^2 := by + apply Finset.sum_le_sum; intro i _ + simp only [PiLp.sub_apply, FrameCharts.chart_apply, Real.norm_eq_abs, sq_abs] + have hh := rounded_error_coordinate u hτ θ i + nlinarith + _ = _ := by simp + have hr := Real.sq_sqrt (Nat.cast_nonneg N) + have hp : 0 ≤ Real.sqrt N*τ := mul_nonneg (Real.sqrt_nonneg _) hτ.le + have he : (Real.sqrt N*τ)^2 = (N:ℝ)*τ^2 := by rw [mul_pow,hr] + nlinarith [norm_nonneg (rounded u τ θ-FrameCharts.chart u θ)] + +lemma integerLabel_bound (u : Fin N → E) {τ : ℝ} (hτ : 0 < τ) (hu : ∀ i, ‖u i‖ ≤ 2) + {θ : E} (hθ : θ ∈ cube 2) (i : Fin N) : + |(integerLabel u τ θ i : ℝ)| ≤ 4*Real.sqrt m/τ+1 := by + have hn := cube_norm (by norm_num : (0:ℝ) ≤ 2) hθ + have hh : |inner ℝ (u i) θ| ≤ 4*Real.sqrt m := by + calc + _ ≤ ‖u i‖*‖θ‖ := abs_real_inner_le_norm _ _ + _ ≤ 2*(2*Real.sqrt m) := mul_le_mul (hu i) hn (norm_nonneg θ) (by norm_num) + _ = _ := by ring + have hf := Int.floor_le (inner ℝ (u i) θ/τ) + have hfl := Int.lt_floor_add_one (inner ℝ (u i) θ/τ) + have hab : |inner ℝ (u i) θ/τ| ≤ 4*Real.sqrt m/τ := by + rw [abs_div, abs_of_pos hτ] + exact div_le_div_of_nonneg_right hh hτ.le + change |(⌊inner ℝ (u i) θ/τ⌋:ℝ)| ≤ _ + rw [abs_le] at hab ⊢ + constructor <;> linarith + +lemma vertex_finite (u : Fin S → Fin N → E) {τ : ℝ} (hτ : 0 < τ) + (hu : ∀ s i, ‖u s i‖ ≤ 2) : Finite (Vertex u τ) := by + let B : ℤ := ⌈4*Real.sqrt m/τ+1⌉ + let f : Vertex u τ → Fin S × (Fin N → ↥(Finset.Icc (-B) B)) := fun v => + (v.val.1, fun i => ⟨v.val.2 i, by + obtain ⟨θ,hθ,hr,hlabel⟩ := v.property + have hb := integerLabel_bound (u v.val.1) hτ (hu v.val.1) hθ i + have hB := Int.le_ceil (4*Real.sqrt m/τ+1) + have hv : |(v.val.2 i:ℝ)| ≤ (B:ℝ) := by rw [← hlabel]; exact hb.trans hB + have hlo : -B ≤ v.val.2 i := by exact_mod_cast (abs_le.mp hv).1 + have hhi : v.val.2 i ≤ B := by exact_mod_cast (abs_le.mp hv).2 + exact Finset.mem_Icc.mpr ⟨hlo,hhi⟩⟩) + apply Finite.of_injective f + intro v w h + apply Subtype.ext + apply Prod.ext + · exact congrArg (fun z : Fin S × (Fin N → ↥(Finset.Icc (-B) B)) => z.1) h + · funext i + exact congrArg (fun z : Fin S × (Fin N → ↥(Finset.Icc (-B) B)) => (z.2 i).val) h + +lemma representative (u : Fin S → Fin N → E) (τ : ℝ) (v : Vertex u τ) : + ∃ θ ∈ cube 2, regular (u v.val.1) τ θ ∧ coordinate u τ v = rounded (u v.val.1) τ θ := by + obtain ⟨θ,hθ,hr,hl⟩ := v.property + refine ⟨θ,hθ,hr,?_⟩ + ext i + change τ*(v.val.2 i : ℝ) = τ*(integerLabel (u v.val.1) τ θ i : ℝ) + rw [hl] + +end UniformSparsestCut.RoundedCharts + +namespace UniformSparsestCut.SourceCharts +open scoped BigOperators RealInnerProductSpace +noncomputable section +variable {m : ℕ} (f : PivotFamily.PFamily m) (hm : 0 < m) +local notation "E" => EuclideanSpace ℝ (Fin m) +local notation "F" => EuclideanSpace ℝ (Fin (m^6)) +lemma lower_ge_one (hm2 : 2 ≤ m) : 1≤lower m := by + have hx : (2:ℝ) ≤ m := by exact_mod_cast hm2 + have hp := pow_le_pow_right₀ (by linarith : (1:ℝ) ≤ m) (show 2≤6 by norm_num) + unfold lower + apply (le_div_iff₀ (by positivity : (0:ℝ)<2*m)).mpr + nlinarith +lemma B_norm_le (hm2 : 2 ≤ m) (s : Fin (m^3)) (x : F) : ‖B f hm s x‖≤‖x‖ := by + exact (B_norm f hm s x).trans (div_le_self (norm_nonneg _) ((Real.one_le_sqrt).mpr (lower_ge_one hm2))) +lemma rounded_B_error (hm2 : 2 ≤ m) {τ : ℝ} (hτ : 0<τ) (s : Fin (m^3)) (θ : E) : + ‖B f hm s (RoundedCharts.rounded (u f s) τ θ)-θ‖≤Real.sqrt (m^6:ℕ)*τ := by + have he : B f hm s (RoundedCharts.rounded (u f s) τ θ)-θ= + B f hm s (RoundedCharts.rounded (u f s) τ θ-FrameCharts.chart (u f s) θ) := by + rw [map_sub,B_left] + rw [he] + exact (B_norm_le f hm hm2 s _).trans (RoundedCharts.rounded_error _ hτ θ) +lemma rounded_residual_error {τ : ℝ} (hτ : 0<τ) (s : Fin (m^3)) (θ : E) : + ‖RoundedCharts.rounded (u f s) τ θ-FrameCharts.chart (u f s) (B f hm s (RoundedCharts.rounded (u f s) τ θ))‖≤ + Real.sqrt (m^6:ℕ)*τ := by + let x := RoundedCharts.rounded (u f s) τ θ + have he : x-FrameCharts.chart (u f s) (B f hm s x)= + (x-FrameCharts.chart (u f s) θ)-FrameCharts.chart (u f s) (B f hm s (x-FrameCharts.chart (u f s) θ)) := by + rw [map_sub,B_left,map_sub] + abel + change ‖x-FrameCharts.chart (u f s) (B f hm s x)‖≤_ + rw [he] + exact (residual_norm f hm s _).trans (RoundedCharts.rounded_error _ hτ θ) +lemma vertex_B_bound (hm2 : 2 ≤ m) {τ : ℝ} (hτ : 0<τ) (v : RoundedCharts.Vertex (u f) τ) : + ‖B f hm v.val.1 (RoundedCharts.coordinate (u f) τ v)‖≤2*Real.sqrt m+Real.sqrt (m^6:ℕ)*τ := by + obtain ⟨θ,hθ,hr,hx⟩ := RoundedCharts.representative (u f) τ v + rw [hx] + have h := rounded_B_error f hm hm2 hτ v.val.1 θ + have ht := RoundedCharts.cube_norm (by norm_num : (0:ℝ)≤2) hθ + exact (norm_le_norm_sub_add _ θ).trans (by linarith) +lemma vertex_residual_bound {τ : ℝ} (hτ : 0<τ) (v : RoundedCharts.Vertex (u f) τ) : + ‖RoundedCharts.coordinate (u f) τ v-FrameCharts.chart (u f v.val.1) (B f hm v.val.1 (RoundedCharts.coordinate (u f) τ v))‖≤ + Real.sqrt (m^6:ℕ)*τ := by + obtain ⟨θ,hθ,hr,hx⟩ := RoundedCharts.representative (u f) τ v + rw [hx] + exact rounded_residual_error f hm hτ v.val.1 θ +end +end UniformSparsestCut.SourceCharts + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SparsestCut/Semimetrics.lean b/lean/OAI/Combinatorics/SparsestCut/Semimetrics.lean new file mode 100644 index 0000000000000000000000000000000000000000..e46f25120e3357bd8349343224cfb9a3f176c888 --- /dev/null +++ b/lean/OAI/Combinatorics/SparsestCut/Semimetrics.lean @@ -0,0 +1,193 @@ +import OAI.Combinatorics.SparsestCut.CutSums + +namespace OAI + +open scoped BigOperators Topology NNReal RealInnerProductSpace InnerProductSpace Matrix ContDiff ENNReal +open MeasureTheory ProbabilityTheory Set Filter Matrix + +noncomputable section + +namespace UniformSparsestCut + +section SemimetricBounds + +variable {n : ℕ} + +def IsSemimetric (d : Fin n → Fin n → ℝ) : Prop := + (∀ i j, 0 ≤ d i j) ∧ (∀ i j, d i j = d j i) ∧ + (∀ i, d i i = 0) ∧ (∀ i j k, d i k ≤ d i j + d j k) + +lemma NegativeType.semimetric {d : Fin n → Fin n → ℝ} (hd : NegativeType d) : + IsSemimetric d := by + obtain ⟨x,hx⟩ := hd.1 + refine ⟨fun i j => by rw [hx]; positivity, ?_, ?_, hd.2⟩ + · intro i j; rw [hx, hx, norm_sub_rev] + · intro i; simp [hx] + +lemma NegativeType.scale {d : Fin n → Fin n → ℝ} (hd : NegativeType d) + {a : ℝ} (ha : 0 ≤ a) : NegativeType (fun i j => a * d i j) := by + obtain ⟨x,hx⟩ := hd.1 + refine ⟨⟨fun i => Real.sqrt a • x i, ?_⟩, ?_⟩ + · intro i j + change a * d i j = _ + rw [← smul_sub, norm_smul, mul_pow, Real.norm_eq_abs, + abs_of_nonneg (Real.sqrt_nonneg a), Real.sq_sqrt ha, hx] + · intro i j k + simpa [mul_add] using mul_le_mul_of_nonneg_left (hd.2 i j k) ha + +lemma cutDist_negativeType (B : Finset (Fin n)) (hn : 0 < n) : NegativeType (cutDist B) := by + classical + let i0 : Fin n := ⟨0,hn⟩ + refine ⟨⟨fun i => EuclideanSpace.single i0 (cutIndicator B i), ?_⟩, + cutDist_triangle B⟩ + intro i j + change cutDist B i j = ‖PiLp.single (β := fun _ : Fin n => ℝ) 2 i0 (cutIndicator B i) - + PiLp.single (β := fun _ : Fin n => ℝ) 2 i0 (cutIndicator B j)‖ ^ 2 + rw [← PiLp.single_sub] + change cutDist B i j = ‖EuclideanSpace.single i0 + (cutIndicator B i - cutIndicator B j)‖ ^ 2 + rw [PiLp.norm_single, Real.norm_eq_abs] + change cutDist B i j = cutDist B i j ^ 2 + rcases cutDist_binary B i j with h | h <;> rw [h] <;> norm_num + +lemma cut_nonempty (hn : 2 ≤ n) : Nonempty (Cut n) := by + classical + let i : Fin n := ⟨0,by omega⟩ + refine ⟨⟨{i}, Finset.singleton_nonempty i, ?_⟩⟩ + intro he + have hh := congrArg Finset.card he + simp only [Finset.card_singleton, Finset.card_univ, Fintype.card_fin] at hh + omega + +lemma feasible_nonempty (hn : 2 ≤ n) : ∃ d : Fin n → Fin n → ℝ, Feasible d := by + classical + obtain ⟨B⟩ := cut_nonempty hn + refine ⟨fun i j => (cutDemand B.1)⁻¹ * cutDist B.1 i j, ?_, ?_⟩ + · exact (cutDist_negativeType B.1 (by omega)).scale (inv_nonneg.mpr (cutDemand_pos B).le) + · rw [pairSum_smul, pairSum_cut, inv_mul_cancel₀ (cutDemand_pos B).ne'] + +lemma normalized_pair_le_one {d : Fin n → Fin n → ℝ} (hd : IsSemimetric d) + (hD : pairSum d = 1) (i j : Fin n) : d i j ≤ 1 := by + rcases lt_trichotomy i j with h | h | h + · simpa [hD] using le_pairSum hd.1 h + · subst j; rw [hd.2.2.1]; norm_num + · rw [hd.2.1 i j]; simpa [hD] using le_pairSum hd.1 h + +lemma continuous_pairSum : Continuous (pairSum (n := n)) := by + unfold pairSum + apply continuous_finsetSum + intro i hi + apply continuous_finsetSum + intro j hj + split_ifs + · exact (continuous_apply j).comp (continuous_apply i) + · exact continuous_const + +lemma semimetric_closed : IsClosed {d : Fin n → Fin n → ℝ | IsSemimetric d} := by + unfold IsSemimetric + simp only [ofPred_and, ofPred_forall] + refine IsClosed.inter ?_ (IsClosed.inter ?_ (IsClosed.inter ?_ ?_)) + · apply isClosed_iInter; intro i; apply isClosed_iInter; intro j + exact isClosed_le continuous_const ((continuous_apply j).comp (continuous_apply i)) + · apply isClosed_iInter; intro i; apply isClosed_iInter; intro j + exact isClosed_eq ((continuous_apply j).comp (continuous_apply i)) + ((continuous_apply i).comp (continuous_apply j)) + · apply isClosed_iInter; intro i + exact isClosed_eq ((continuous_apply i).comp (continuous_apply i)) continuous_const + · apply isClosed_iInter; intro i; apply isClosed_iInter; intro j + apply isClosed_iInter; intro k + exact isClosed_le (by fun_prop) (by fun_prop) + +lemma normalized_semimetric_compact : + IsCompact {d : Fin n → Fin n → ℝ | IsSemimetric d ∧ pairSum d = 1} := by + have hclosed : IsClosed {d : Fin n → Fin n → ℝ | IsSemimetric d ∧ pairSum d = 1} := + semimetric_closed.inter (isClosed_eq continuous_pairSum continuous_const) + apply (isCompact_Icc : IsCompact (Icc (0 : Fin n → Fin n → ℝ) (fun _ _ => 1))).of_isClosed_subset hclosed + intro d hd + exact ⟨hd.1.1, normalized_pair_le_one hd.1 hd.2⟩ + +lemma objective_nonneg (C : Capacity n) {d : Fin n → Fin n → ℝ} (hd : IsSemimetric d) : + 0 ≤ pairSum (fun i j => C.cap i j * d i j) := + pairSum_nonneg (fun i j => mul_nonneg (C.nonneg i j) (hd.1 i j)) + +lemma objective_pos_of_cuts (C : Capacity n) + (hC : ∀ B : Cut n, cutDemand B.1 ≤ ∑ i ∈ B.1, ∑ j ∈ B.1ᶜ, C.cap i j) + {d : Fin n → Fin n → ℝ} (hd : IsSemimetric d) (hD : pairSum d = 1) : + 0 < pairSum (fun i j => C.cap i j * d i j) := by + classical + have hnonneg := objective_nonneg C hd + by_contra! hnot + have hzero := le_antisymm hnot hnonneg + have hp (i j : Fin n) : C.cap i j * d i j = 0 := by + have h0 : 0 ≤ C.cap i j * d i j := mul_nonneg (C.nonneg i j) (hd.1 i j) + rcases lt_trichotomy i j with h | h | h + · have hh := le_pairSum (fun i j => mul_nonneg (C.nonneg i j) (hd.1 i j)) h + rw [hzero] at hh + exact le_antisymm hh h0 + · subst j; simp [C.diagonal] + · rw [C.symm i j, hd.2.1 i j] + have hh := le_pairSum (fun i j => mul_nonneg (C.nonneg i j) (hd.1 i j)) h + rw [hzero] at hh + exact le_antisymm hh (mul_nonneg (C.nonneg _ _) (hd.1 _ _)) + have hd0 : ∀ i j, d i j = 0 := by + intro i j + let B : Finset (Fin n) := Finset.univ.filter (fun k => d i k = 0) + have hi : i ∈ B := by simp [B, hd.2.2.1] + have hBall : B = Finset.univ := by + by_contra hne + let B' : Cut n := ⟨B, ⟨i,hi⟩, hne⟩ + have hjump (u : Fin n) (hu : u ∈ B) (v : Fin n) (hv : v ∈ Bᶜ) : C.cap u v = 0 := by + have hu0 : d i u = 0 := (Finset.mem_filter.mp hu).2 + have hv0 : d i v ≠ 0 := by simpa [B] using hv + have hduv : d u v ≠ 0 := by + intro huv + have ht := hd.2.2.2 i u v + rw [hu0,huv] at ht + exact hv0 (le_antisymm (by simpa using ht) (hd.1 i v)) + exact (mul_eq_zero.mp (hp u v)).resolve_right hduv + have hsum : (∑ u ∈ B, ∑ v ∈ Bᶜ, C.cap u v) = 0 := by + apply Finset.sum_eq_zero + intro u hu + exact Finset.sum_eq_zero (fun v hv => hjump u hu v hv) + have hh := hC B' + change cutDemand B ≤ _ at hh + rw [hsum] at hh + exact (cutDemand_pos B').not_ge hh + have hj : j ∈ B := by rw [hBall]; exact Finset.mem_univ j + exact (Finset.mem_filter.mp hj).2 + simp [pairSum,hd0] at hD + +lemma glValue_pos_of_cuts (C : Capacity n) (hn : 2 ≤ n) + (hC : ∀ B : Cut n, cutDemand B.1 ≤ ∑ i ∈ B.1, ∑ j ∈ B.1ᶜ, C.cap i j) : + 0 < glValue C := by + obtain ⟨d0,hd0⟩ := feasible_nonempty hn + have hobj : Continuous (fun d : Fin n → Fin n → ℝ => pairSum (fun i j => C.cap i j * d i j)) := by + apply continuous_pairSum.comp + apply continuous_pi; intro i; apply continuous_pi; intro j + exact continuous_const.mul ((continuous_apply j).comp (continuous_apply i)) + obtain ⟨d,hd,hmin⟩ := normalized_semimetric_compact.exists_isMinOn + ⟨d0,hd0.1.semimetric,hd0.2⟩ hobj.continuousOn + apply (objective_pos_of_cuts C hC hd.1 hd.2).trans_le + apply le_csInf + · exact ⟨_,d0,hd0,rfl⟩ + · rintro b ⟨d',hd',rfl⟩ + exact hmin ⟨hd'.1.semimetric,hd'.2⟩ + +lemma OPT_ge_one_of_cuts (C : Capacity n) (hn : 2 ≤ n) + (hC : ∀ B : Cut n, cutDemand B.1 ≤ ∑ i ∈ B.1, ∑ j ∈ B.1ᶜ, C.cap i j) : + 1 ≤ OPT C := by + obtain ⟨B0⟩ := cut_nonempty hn + apply le_csInf + · exact ⟨_,B0.1,B0.2.1,B0.2.2,rfl⟩ + · rintro b ⟨B,hB,hB',rfl⟩ + unfold cutRatio + rw [← cutDemand_eq] + exact (one_le_div (cutDemand_pos ⟨B,hB,hB'⟩)).mpr (hC ⟨B,hB,hB'⟩) + +end SemimetricBounds + +end UniformSparsestCut + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SparsestCut/SliceCoefficients.lean b/lean/OAI/Combinatorics/SparsestCut/SliceCoefficients.lean new file mode 100644 index 0000000000000000000000000000000000000000..c6042357c37ce17954990bb363289824dd478916 --- /dev/null +++ b/lean/OAI/Combinatorics/SparsestCut/SliceCoefficients.lean @@ -0,0 +1,137 @@ +import OAI.Combinatorics.SparsestCut.InterfaceStep + +namespace OAI + +universe u1 u2 u3 u4 u5 + +open scoped BigOperators Topology NNReal RealInnerProductSpace InnerProductSpace Matrix ContDiff ENNReal +open MeasureTheory ProbabilityTheory Set Filter Matrix + +noncomputable section + +namespace UniformSparsestCut.SliceCoefficients +open MeasureTheory Set +open scoped BigOperators Topology +variable {X : Type u1} {Z : Type u2} {I : Type u3} {K : Type u4} {A : Type u5} [NormedAddCommGroup X] [NormedSpace ℝ X] + [NormedAddCommGroup Z] [NormedSpace ℝ Z] [FiniteDimensional ℝ Z] + [MeasurableSpace Z] [BorelSpace Z] [Fintype I] [Fintype K] [Fintype A] + [DecidableEq I] [DecidableEq K] + +lemma affine_hyperplane_null (L : Z →L[ℝ] ℝ) (hL : L ≠ 0) (t : ℝ) + (ν : Measure Z) [ν.IsAddHaarMeasure] : ν {z | L z=t}=0 := by + let H : AffineSubspace ℝ Z := + { carrier := {z | L z=t} + smul_vsub_vadd_mem' := by + intro c x y z hx hy hz + change L x=t at hx + change L y=t at hy + change L z=t at hz + change L (c • (x-y)+z)=t + simp only [map_add,map_smul,map_sub,smul_eq_mul,hx,hy,hz] + ring } + have ht : H ≠ ⊤ := by + intro he + have hzero : (0:Z) ∈ H := by rw [he]; trivial + change L 0=t at hzero + rw [map_zero] at hzero + apply hL + ext x + have hx : x ∈ H := by rw [he]; trivial + change L x=t at hx + simpa [← hzero] using hx + exact Measure.addHaar_affineSubspace ν H ht + +lemma thresholds_injective_ae (L : I → X →L[ℝ] ℝ) (B : I → Z →L[ℝ] ℝ) + (q : I → K → ℝ) (hq : ∀ i, Function.Injective (q i)) + (hB : Function.Injective B) (ν : Measure Z) [ν.IsAddHaarMeasure] + (μ : Measure Z) (hμ : μ ≪ ν) (y : X) : + ∀ᵐ z ∂μ, Function.Injective (fun p : I × K => L p.1 y+B p.1 z+q p.1 p.2) := by + have hp (p r : I × K) (hpr : p ≠ r) : + ∀ᵐ 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 + by_cases hi : p.1=r.1 + · filter_upwards with z hz + have hk : p.2=r.2 := hq p.1 (by rw [← hi] at hz; linarith) + exact hpr (Prod.ext hi hk) + · have hn : B p.1-B r.1 ≠ 0 := sub_ne_zero.mpr (fun he => hi (hB he)) + have hnul := affine_hyperplane_null (B p.1-B r.1) hn + (L r.1 y+q r.1 r.2-(L p.1 y+q p.1 p.2)) ν + 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 + rw [ae_iff]; simpa only [not_not] using hnul + filter_upwards [hμ.ae_le hae] with z hz he + apply hz + simp only [_root_.sub_apply] + linarith + have ha (p r : I × K) : ∀ᵐ 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 → p=r := by + by_cases hpr : p=r + · exact ae_of_all _ (fun _ _ => hpr) + · filter_upwards [hp p r hpr] with z hz he using (hz he).elim + exact ae_all_iff.mpr (fun p => ae_all_iff.mpr (ha p)) + +omit [NormedAddCommGroup Z] [NormedSpace ℝ Z] [FiniteDimensional ℝ Z] [BorelSpace Z] in + +lemma family_derivative (L : I → X →L[ℝ] ℝ) (b : I × K → Z → ℝ) + (hb : ∀ p, Measurable (b p)) (F : Finset (I × K) → ℝ) + {φ : ℝ → ℝ} (hφ : Integrable φ) (hc : Continuous φ) + {M C : ℝ} (hM0 : 0 ≤ M) (hC : 0 ≤ C) + (hM : ∀ a, |F a| ≤ M) (hφC : ∀ x, |φ x| ≤ C) + (μ : Measure Z) [IsFiniteMeasure μ] (y : X) + (hi : ∀ᵐ z ∂μ, Function.Injective (fun p : I × K => L p.1 y+b p z)) : + HasFDerivAt (fun y => ∫ z, (∫ x, φ x*F (Finset.univ.filter (fun p => L p.1 y+b p z L p.1 y+b p z ≤ L i y+b (i,k) z))- + F (Finset.univ.filter (fun p => L p.1 y+b p z < L i y+b (i,k) z)))) ∂μ) • L i) y := by + have hd := InterfaceStep.averaged_threshold_derivative Finset.univ (fun p : I × K => L p.1) + b hb F hφ hc hM0 hC hM hφC μ y (hi.mono (fun z hz => hz.injOn)) + rw [Fintype.sum_prod_type] at hd + simp only [← Finset.sum_smul] at hd + exact hd + +omit [NormedAddCommGroup Z] [NormedSpace ℝ Z] [FiniteDimensional ℝ Z] [BorelSpace Z] [DecidableEq K] in + +lemma coefficient_budget (μ : Measure Z) [IsProbabilityMeasure μ] + (w : K → Z → ℝ) (Δ : K → Z → A → ℝ) {J B : ℝ} + (hJ : 0 ≤ J) (hw : ∀ k z, 0 ≤ w k z) + (_hiw : ∀ k, Integrable (w k) μ) + (hid : ∀ k a, Integrable (fun z => w k z*Δ k z a) μ) + (hj : ∀ᵐ z ∂μ, ∀ k, w k z ≠ 0 → ∑ a, |Δ k z a| ≤ J) + (hs : ∀ᵐ z ∂μ, ∑ k, w k z ≤ B) : + (∑ a, |∑ k, ∫ z, -(w k z*Δ k z a) ∂μ|) ≤ J*B := by + have hle (a : A) : |∑ k, ∫ z, -(w k z*Δ k z a) ∂μ| ≤ + ∑ k, ∫ z, w k z*|Δ k z a| ∂μ := by + calc + _ ≤ ∑ k, |∫ z, -(w k z*Δ k z a) ∂μ| := Finset.abs_sum_le_sum_abs _ _ + _ ≤ _ := Finset.sum_le_sum (fun k _ => by + simpa only [Real.norm_eq_abs,abs_neg,abs_mul,abs_of_nonneg (hw k _)] using + norm_integral_le_integral_norm (fun z => -(w k z*Δ k z a))) + have hia (k : K) (a : A) : Integrable (fun z => w k z*|Δ k z a|) μ := by + simpa only [abs_mul,abs_of_nonneg (hw k _)] using (hid k a).abs + have hisum : Integrable (fun z => ∑ k, w k z*(∑ a, |Δ k z a|)) μ := by + simp_rw [Finset.mul_sum] + exact integrable_finsetSum _ (fun k _ => integrable_finsetSum _ (fun a _ => hia k a)) + calc + _ ≤ ∑ a, ∑ k, ∫ z, w k z*|Δ k z a| ∂μ := Finset.sum_le_sum (fun a _ => hle a) + _ = ∫ z, ∑ k, w k z*(∑ a, |Δ k z a|) ∂μ := by + rw [Finset.sum_comm] + simp_rw [Finset.mul_sum] + rw [integral_finsetSum _ (fun k _ => integrable_finsetSum _ (fun a _ => hia k a))] + apply Finset.sum_congr rfl + intro k _ + exact (integral_finsetSum _ (fun a _ => hia k a)).symm + _ ≤ ∫ z, J*B ∂μ := by + apply integral_mono_ae hisum (integrable_const _) + filter_upwards [hj,hs] with z hz hzB + calc + _ ≤ ∑ k, w k z*J := Finset.sum_le_sum (fun k _ => by + by_cases hk : w k z=0 + · simp [hk] + · exact mul_le_mul_of_nonneg_left (hz k hk) (hw k z)) + _ = J*∑ k, w k z := by rw [← Finset.sum_mul]; ring + _ ≤ J*B := mul_le_mul_of_nonneg_left hzB hJ + _ = J*B := by simp + +end UniformSparsestCut.SliceCoefficients + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SparsestCut/SliceIntegration.lean b/lean/OAI/Combinatorics/SparsestCut/SliceIntegration.lean new file mode 100644 index 0000000000000000000000000000000000000000..c06f2494ce08fa77d516da4c3478acee274b0f6a --- /dev/null +++ b/lean/OAI/Combinatorics/SparsestCut/SliceIntegration.lean @@ -0,0 +1,98 @@ +import OAI.Combinatorics.SparsestCut.LatticeDensity + +namespace OAI + +universe u1 u2 u3 u4 + +open scoped BigOperators Topology NNReal RealInnerProductSpace InnerProductSpace Matrix ContDiff ENNReal +open MeasureTheory ProbabilityTheory Set Filter Matrix + +noncomputable section + +namespace UniformSparsestCut.ProductSlice +open MeasureTheory Set +open scoped BigOperators +noncomputable section +variable {Z : Type u1} {I : Type u2} {K : Type u3} {A : Type u4} [NormedAddCommGroup Z] [NormedSpace ℝ Z] + [FiniteDimensional ℝ Z] [MeasureSpace Z] [BorelSpace Z] [(volume : Measure Z).IsAddHaarMeasure] + [Fintype I] [Fintype K] [Fintype A] [DecidableEq I] [DecidableEq K] + +def jump (B : I → Z →L[ℝ] ℝ) (q : I → K → ℝ) (F : Finset (I × K) → A → ℝ) + (θ : ℝ × Z) (i : I) (k : K) (z : Z) (α : A) : ℝ := + 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)) α- + 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)) α +omit [FiniteDimensional ℝ Z] [(volume : Measure Z).IsAddHaarMeasure] [Fintype A] in +lemma jump_measurable (B : I → Z →L[ℝ] ℝ) (q : I → K → ℝ) (F : Finset (I × K) → A → ℝ) + (θ : ℝ × Z) (i : I) (k : K) (α : A) : Measurable (fun z => jump B q F θ i k z α) := by + unfold jump + apply Measurable.sub + · apply InterfaceStep.measurable_filter_apply Finset.univ _ _ (fun a => F a α) + intro p + exact measurableSet_le ((measurable_const.add (B p.1).measurable).add_const _) + ((measurable_const.add (B i).measurable).add_const _) + · apply InterfaceStep.measurable_filter_apply Finset.univ _ _ (fun a => F a α) + intro p + exact measurableSet_lt ((measurable_const.add (B p.1).measurable).add_const _) + ((measurable_const.add (B i).measurable).add_const _) + +omit [FiniteDimensional ℝ Z] [MeasureSpace Z] [BorelSpace Z] [(volume : Measure Z).IsAddHaarMeasure] [Fintype A] [DecidableEq I] [DecidableEq K] in +lemma jump_bound (B : I → Z →L[ℝ] ℝ) (q : I → K → ℝ) (F : Finset (I × K) → A → ℝ) + {M : ℝ} (hM : ∀ a α, |F a α|≤M) (θ : ℝ × Z) (i : I) (k : K) (z : Z) (α : A) : + |jump B q F θ i k z α|≤2*M := by + unfold jump + exact (abs_sub _ _).trans (add_le_add (hM _ α) (hM _ α) |>.trans (by ring_nf; rfl)) + +omit [FiniteDimensional ℝ Z] [(volume : Measure Z).IsAddHaarMeasure] in + +lemma common_coefficient_budget (B : I → Z →L[ℝ] ℝ) (s : Finset ℤ) + (pivot : I → ℝ) (hp : ∀ i, pivot i≠0) {τ : ℝ} (hτ : 0<τ) + (F : Finset (I × s) → A → ℝ) {M C J : ℝ} + (_hM0 : 0≤M) (hC : 0≤C) (hJ : 0≤J) (hM : ∀ a α, |F a α|≤M) + {φ φ' : ℝ → ℝ} (hd : ∀ t, HasDerivAt φ (φ' t) t) (hn : ∀ t, 0≤φ t) + (hi : Integrable φ) (hi' : Integrable φ') (h1 : ∫ t, φ t=1) (hφC : ∀ t, |φ t|≤C) + {ψ : Z → ℝ} (hmψ : Measurable ψ) (hnψ : ∀ z, 0≤ψ z) (hiψ : Integrable ψ) (hψ1 : ∫ z, ψ z=1) + (θ : ℝ × Z) (i : I) + (hj : ∀ᵐ z ∂law ψ volume, ∀ k : s, + φ (form (B i) θ+B i z-(k:ℤ)*τ/pivot i)≠0 → + (∑ α, |jump B (fun i (k : s) => -((k:ℤ)*τ/pivot i)) F θ i k z α|)≤J) + (hsmall : τ/|pivot i| *(∫ t, |φ' t|)≤1) : + (∑ α, |(pivot i)⁻¹ * ∑ k : s, ∫ z, + -(φ (form (B i) θ+B i z-(k:ℤ)*τ/pivot i)* + jump B (fun i (k : s) => -((k:ℤ)*τ/pivot i)) F θ i k z α) ∂law ψ volume|) ≤ 2*J/τ := by + let μ := law ψ volume + let q : I → s → ℝ := fun i (k : s) => -((k:ℤ)*τ/pivot i) + let w : s → Z → ℝ := fun k z => φ (form (B i) θ+B i z-(k:ℤ)*τ/pivot i) + have : IsProbabilityMeasure μ := law_probability hmψ hnψ volume hiψ hψ1 + have hcφ : Continuous φ := continuous_iff_continuousAt.mpr (fun t => (hd t).continuousAt) + have hw (k : s) : Measurable (w k) := + hcφ.measurable.comp ((measurable_const.add (B i).measurable).sub_const _) + have hiw (k : s) : Integrable (w k) μ := + (integrable_const C).mono' (hw k).aestronglyMeasurable (ae_of_all _ (fun z => hφC _)) + have hid (k : s) (α : A) : Integrable (fun z => w k z*jump B q F θ i k z α) μ := by + apply (integrable_const (C*(2*M))).mono' ((hw k).mul (jump_measurable B q F θ i k α)).aestronglyMeasurable + filter_upwards with z + simp only [Pi.mul_apply, Real.norm_eq_abs,abs_mul] + exact mul_le_mul (hφC _) (jump_bound B q F hM θ i k z α) (abs_nonneg _) hC + have hs (z : Z) : (∑ k : s, w k z)≤2*|pivot i|/τ := by + have h := LatticeDensity.affine_lattice_bound hd hn hi hi' h1 hτ (hp i) (form (B i) θ+B i z) s + rw [← Finset.sum_coe_sort] at h + have hp0 : 0 < |pivot i| := abs_pos.mpr (hp i) + have hmul : τ/|pivot i| *(∑ k : s, w k z)≤2 := by exact h.trans (by linarith) + apply (le_div_iff₀ hτ).mpr + have hh := mul_le_mul_of_nonneg_right hmul hp0.le + have he : (τ/|pivot i| *(∑ k : s, w k z))*|pivot i| = (∑ k : s, w k z)*τ := by + field_simp + rwa [he] at hh + have hb := SliceCoefficients.coefficient_budget μ w (jump B q F θ i) hJ + (fun k z => hn _) hiw hid hj (ae_of_all _ hs) + simp_rw [abs_mul,abs_inv,← Finset.mul_sum] + calc + _ ≤ |pivot i|⁻¹*(J*(2*|pivot i|/τ)) := mul_le_mul_of_nonneg_left hb (inv_nonneg.mpr (abs_nonneg _)) + _ = _ := by field_simp [abs_ne_zero.mpr (hp i)] + +end +end UniformSparsestCut.ProductSlice + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SparsestCut/Smoothing.lean b/lean/OAI/Combinatorics/SparsestCut/Smoothing.lean new file mode 100644 index 0000000000000000000000000000000000000000..ab7b22983f991d7adf30c58266691c3e1a19c442 --- /dev/null +++ b/lean/OAI/Combinatorics/SparsestCut/Smoothing.lean @@ -0,0 +1,128 @@ +import OAI.Combinatorics.SparsestCut.CellInterface + +namespace OAI + +universe u1 u2 u3 + +open scoped BigOperators Topology NNReal RealInnerProductSpace InnerProductSpace Matrix ContDiff ENNReal +open MeasureTheory ProbabilityTheory Set Filter Matrix + +noncomputable section + +namespace UniformSparsestCut.ProductSlice +open MeasureTheory Set CellInterface +open scoped BigOperators +noncomputable section +variable {Z : Type u1} {I : Type u2} {A : Type u3} [NormedAddCommGroup Z] [NormedSpace ℝ Z] + [FiniteDimensional ℝ Z] [MeasureSpace Z] [BorelSpace Z] [(volume : Measure Z).IsAddHaarMeasure] + [Fintype I] [Fintype A] [DecidableEq I] + +def ell (B : I → Z →L[ℝ] ℝ) (pivot : I → ℝ) (i : I) : (ℝ × Z) →L[ℝ] ℝ := + pivot i • form (B i) +omit [FiniteDimensional ℝ Z] [MeasureSpace Z] [BorelSpace Z] [(volume : Measure Z).IsAddHaarMeasure] [Fintype I] [DecidableEq I] in +@[simp] lemma ell_apply (B : I → Z →L[ℝ] ℝ) (pivot : I → ℝ) (i : I) (x : ℝ × Z) : + ell B pivot i x=pivot i*(x.1-B i x.2) := rfl + +omit [FiniteDimensional ℝ Z] [MeasureSpace Z] [BorelSpace Z] [(volume : Measure Z).IsAddHaarMeasure] [Fintype I] [DecidableEq I] in +lemma normalized_ell (B : I → Z →L[ℝ] ℝ) (pivot : I → ℝ) (hp : ∀ i, pivot i≠0) + (τ : ℝ) (i : I) (k : ℤ) (x : ℝ × Z) : + (ell B pivot i x-(k:ℝ)*τ)/pivot i=form (B i) x-(k:ℝ)*τ/pivot i := by + simp only [ell,_root_.smul_apply,smul_eq_mul,sub_div,mul_div_cancel_left₀ _ (hp i)] + +omit [Fintype A] [FiniteDimensional ℝ Z] [MeasureSpace Z] [BorelSpace Z] [(volume : Measure Z).IsAddHaarMeasure] [DecidableEq I] in +lemma cell_eq_extension (B : I → Z →L[ℝ] ℝ) (pivot : I → ℝ) (hp : ∀ i, pivot i≠0) + (τ : ℝ) (s : Finset ℤ) (U : Set (ℝ × Z)) (F : LabelVertex (ell B pivot) τ U → A → ℝ) + (x : ℝ × Z) (α : A) : + cell B (fun i (k : s) => -((k:ℤ)*τ/pivot i)) + (fun P => extension (ell B pivot) pivot τ s U F P α) x = + extension (ell B pivot) pivot τ s U F (pattern (ell B pivot) pivot τ s x) α := by + unfold cell pattern + simp_rw [normalized_ell B pivot hp] + simp only [sub_eq_add_neg] + +def eventPoint (B : I → Z →L[ℝ] ℝ) (pivot : I → ℝ) (τ : ℝ) + (θ : ℝ × Z) (i : I) (k : ℤ) (z : Z) : ℝ × Z := + θ-(form (B i) θ+B i z-(k:ℝ)*τ/pivot i,z) + +omit [FiniteDimensional ℝ Z] [MeasureSpace Z] [BorelSpace Z] [(volume : Measure Z).IsAddHaarMeasure] [Fintype I] [DecidableEq I] in +lemma event_form (B : I → Z →L[ℝ] ℝ) (pivot : I → ℝ) (τ : ℝ) + (θ : ℝ × Z) (i : I) (k : ℤ) (z : Z) (j : I) : + form (B j) (eventPoint B pivot τ θ i k z) = + form (B j) θ+B j z-(form (B i) θ+B i z-(k:ℝ)*τ/pivot i) := by + simp only [eventPoint,form_apply,map_sub] + ring +omit [FiniteDimensional ℝ Z] [MeasureSpace Z] [BorelSpace Z] [(volume : Measure Z).IsAddHaarMeasure] [Fintype I] [DecidableEq I] in +lemma event_on_plane (B : I → Z →L[ℝ] ℝ) (pivot : I → ℝ) (hp : ∀ i, pivot i≠0) + (τ : ℝ) (θ : ℝ × Z) (i : I) (k : ℤ) (z : Z) : + ell B pivot i (eventPoint B pivot τ θ i k z)=(k:ℝ)*τ := by + change pivot i*form (B i) _=_ + rw [event_form] + field_simp [hp i] + ring + +lemma event_other_regular (B : I → Z →L[ℝ] ℝ) (hB : Function.Injective B) + (pivot : I → ℝ) (hp : ∀ i, pivot i≠0) (τ : ℝ) (θ : ℝ × Z) (i : I) (k : ℤ) + (μ : Measure Z) (hμ : μ ≪ volume) : + ∀ᵐ z ∂μ, ∀ j, j≠i → ∀ l : ℤ, ell B pivot j (eventPoint B pivot τ θ i k z)≠(l:ℝ)*τ := by + apply ae_all_iff.mpr + intro j + by_cases hj : j=i + · simp [hj] + have hpair (l : ℤ) : ∀ᵐ z ∂μ, ell B pivot j (eventPoint B pivot τ θ i k z)≠(l:ℝ)*τ := by + have hn : B j-B i≠0 := sub_ne_zero.mpr (fun he => hj (hB he)) + let t := (l:ℝ)*τ/pivot j-(k:ℝ)*τ/pivot i-form (B j) θ+form (B i) θ + have hnul := SliceCoefficients.affine_hyperplane_null (B j-B i) hn t volume + have hae : ∀ᵐ z ∂volume, (B j-B i) z≠t := by rw [ae_iff]; simpa only [not_not] using hnul + filter_upwards [hμ.ae_le hae] with z hz he + apply hz + change pivot j*form (B j) _=_ at he + rw [event_form] at he + have he' : form (B j) θ+B j z-(form (B i) θ+B i z-(k:ℝ)*τ/pivot i)=(l:ℝ)*τ/pivot j := + (eq_div_iff (hp j)).mpr (by nlinarith [he]) + simp only [_root_.sub_apply] + dsimp only [t] + linarith + filter_upwards [ae_all_iff.mpr hpair] with z hz _ using hz + +omit [Fintype A] [FiniteDimensional ℝ Z] [MeasureSpace Z] [BorelSpace Z] [(volume : Measure Z).IsAddHaarMeasure] [DecidableEq I] in +lemma jump_eq_traces (B : I → Z →L[ℝ] ℝ) (pivot : I → ℝ) (hp : ∀ i, pivot i≠0) + (τ : ℝ) (s : Finset ℤ) (U : Set (ℝ × Z)) (F : LabelVertex (ell B pivot) τ U → A → ℝ) + (θ : ℝ × Z) (i : I) (k : s) (z : Z) (α : A) : + jump B (fun i (k : s) => -((k:ℤ)*τ/pivot i)) + (extension (ell B pivot) pivot τ s U F) θ i k z α = + extension (ell B pivot) pivot τ s U F + (weakPattern (ell B pivot) pivot τ s (eventPoint B pivot τ θ i k.val z)) α- + extension (ell B pivot) pivot τ s U F + (pattern (ell B pivot) pivot τ s (eventPoint B pivot τ θ i k.val z)) α := by + unfold jump weakPattern pattern + congr 2 <;> apply Finset.filter_congr <;> intro p _ <;> + rw [normalized_ell B pivot hp,event_form] <;> constructor <;> intro h <;> linarith + +lemma actual_jump_budget (B : I → Z →L[ℝ] ℝ) (hB : Function.Injective B) + (pivot : I → ℝ) (hp : ∀ i, pivot i≠0) {τ : ℝ} (hτ : 0<τ) (s : Finset ℤ) + {U : Set (ℝ × Z)} (hU : IsOpen U) + (hb : ∀ x∈U, regular (ell B pivot) τ x → ∀ i, label (ell B pivot) τ x i∈s) + (F : LabelVertex (ell B pivot) τ U → A → ℝ) {J : ℝ} + (hF : ∀ (vp vm : LabelVertex (ell B pivot) τ U) (i : I), vp.val i=vm.val i+1 → + (∀ j, j≠i → vp.val j=vm.val j) → ∑ a, |F vp a-F vm a|≤J) + (φ : ℝ → ℝ) (ψ : Z → ℝ) (θ : ℝ × Z) (i : I) + (hsupp : ∀ᵐ z ∂law ψ volume, ∀ k : s, + φ (form (B i) θ+B i z-(k:ℤ)*τ/pivot i)≠0 → eventPoint B pivot τ θ i k.val z∈U) : + ∀ᵐ z ∂law ψ volume, ∀ k : s, + φ (form (B i) θ+B i z-(k:ℤ)*τ/pivot i)≠0 → + ∑ a, |jump B (fun i (k : s) => -((k:ℤ)*τ/pivot i)) + (extension (ell B pivot) pivot τ s U F) θ i k z a|≤J := by + have hae := ae_all_iff.mpr (fun k : s => event_other_regular B hB pivot hp τ θ i k.val _ (law_ac ψ volume)) + filter_upwards [hsupp,hae] with z hz hreg k hk + simp_rw [jump_eq_traces B pivot hp] + apply interface_jump_bound (ell B pivot) pivot hp hτ s hU hb F hF (hz k hk) i k.val + (event_on_plane B pivot hp τ θ i k.val z) (hreg k) (pivot i,0) + simp only [ell_apply,map_zero,sub_zero] + exact mul_self_pos.mpr (hp i) + +end +end UniformSparsestCut.ProductSlice + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SparsestCut/TriangleRepair.lean b/lean/OAI/Combinatorics/SparsestCut/TriangleRepair.lean new file mode 100644 index 0000000000000000000000000000000000000000..36238e0c4a05906e6cad87bfa4f012977427bba2 --- /dev/null +++ b/lean/OAI/Combinatorics/SparsestCut/TriangleRepair.lean @@ -0,0 +1,473 @@ +import OAI.Combinatorics.SparsestCut.ChartAngles + +namespace OAI + +universe u1 u2 u3 u4 u5 u6 u7 + +open scoped BigOperators Topology NNReal RealInnerProductSpace InnerProductSpace Matrix ContDiff ENNReal +open MeasureTheory ProbabilityTheory Set Filter Matrix + +noncomputable section + +namespace UniformSparsestCut.TriangleRepair +variable {ι : Type u1} [Fintype ι] +lemma exp_distance_intervalIntegrable {d r : ℝ} (hd : 0 ≤ d) (hr : 0 ≤ r) : + IntervalIntegrable (fun l => Real.exp (-d / l)) volume 0 r := by + rw [intervalIntegrable_iff_integrableOn_Ioc_of_le hr] + apply (integrable_const (1 : ℝ)).mono' + · exact (Real.measurable_exp.comp (measurable_const.div measurable_id)).aestronglyMeasurable + · filter_upwards [ae_restrict_mem measurableSet_Ioc] with l hl + rw [Real.norm_eq_abs, abs_of_pos (Real.exp_pos _)] + exact Real.exp_le_one_iff.mpr (div_nonpos_of_nonpos_of_nonneg (neg_nonpos.mpr hd) hl.1.le) + +lemma min_posSemidef (u : ι → ℝ) (hu : ∀ i, 0 ≤ u i) : + (Matrix.of (fun i j => min (u i) (u j))).PosSemidef := by + classical + let R : ℝ := ∑ i, u i + have hR : 0 ≤ R := Finset.sum_nonneg (fun i _ => hu i) + have huR (i : ι) : u i ≤ R := Finset.single_le_sum (fun j _ => hu j) (Finset.mem_univ i) + let K : ℝ → Matrix ι ι ℝ := fun l => Matrix.of fun i j => + (if l ≤ u i then 1 else 0) * (if l ≤ u j then 1 else 0) + have hk (l : ℝ) : (K l).PosSemidef := by + convert Matrix.posSemidef_vecMulVec_self_star + (fun i => if l ≤ u i then (1 : ℝ) else 0) using 1 ; try rfl + have hki (i j : ι) : (fun l => K l i j) = + (Set.Iic (min (u i) (u j))).indicator (fun _ => (1 : ℝ)) := by + funext l + simp only [K, Matrix.of_apply, Set.indicator_apply, Set.mem_Iic, le_min_iff] + split_ifs <;> norm_num <;> tauto + have hi (i j : ι) : IntervalIntegrable (fun l => K l i j) volume 0 R := by + rw [hki] + exact ⟨(intervalIntegrable_const (a := 0) (b := R) (c := (1 : ℝ))).1.indicator + measurableSet_Iic, + (intervalIntegrable_const (a := 0) (b := R) (c := (1 : ℝ))).2.indicator + measurableSet_Iic⟩ + have h := integral_posSemidef K hR (fun l _ => hk l) hi + suffices he : Matrix.of (fun i j => min (u i) (u j)) = + (fun i j => ∫ l in (0 : ℝ)..R, K l i j) by + rw [he] + exact h + ext i j + rw [hki] + change min (u i) (u j) = + ∫ l in (0 : ℝ)..R, Set.indicator {l | l ≤ min (u i) (u j)} (fun _ => (1 : ℝ)) l + rw [intervalIntegral.integral_indicator + (show min (u i) (u j) ∈ Set.Icc 0 R from + ⟨le_min (hu i) (hu j), (min_le_left _ _).trans (huR i)⟩)] + simp + +lemma abs_sub_sq_hilbert (u : ι → ℝ) : + ∃ h : ι → EuclideanSpace ℝ ι, ∀ i j, ‖h i - h j‖ ^ 2 = |u i - u j| := by + let b : ℝ := ∑ i, |u i| + have hu (i : ι) : 0 ≤ u i + b := by + have hb : |u i| ≤ b := Finset.single_le_sum (fun j _ => abs_nonneg (u j)) + (Finset.mem_univ i) + have := neg_abs_le (u i) + linarith + obtain ⟨h, hh⟩ := exists_gram (min_posSemidef (fun i => u i + b) hu) + refine ⟨h, fun i j => ?_⟩ + rw [norm_sub_sq_real, ← real_inner_self_eq_norm_sq, ← real_inner_self_eq_norm_sq, + hh, hh, hh] + simp only [Matrix.of_apply, min_self] + rcases le_total (u i) (u j) with hij | hji + · rw [min_eq_left (add_le_add_left hij b), abs_of_nonpos (sub_nonpos.mpr hij)] + ring + · rw [min_eq_right (add_le_add_left hji b), abs_of_nonneg (sub_nonneg.mpr hji)] + ring + +lemma l1_sq_hilbert {κ : Type u2} [Fintype κ] (x : ι → κ → ℝ) {a : ℝ} (ha : 0 ≤ a) : + ∃ h : ι → EuclideanSpace ℝ (κ × ι), + ∀ i j, ‖h i - h j‖ ^ 2 = a * ∑ k, |x i k - x j k| := by + classical + choose h hh using fun k => abs_sub_sq_hilbert (fun i => x i k) + refine ⟨fun i => WithLp.toLp 2 (fun ki => Real.sqrt a * h ki.1 i ki.2), ?_⟩ + intro i j + rw [EuclideanSpace.norm_sq_eq] + simp only [PiLp.sub_apply, Real.norm_eq_abs, sq_abs, + Fintype.sum_prod_type] + have hs : ∀ k, ∑ l, (Real.sqrt a * h k i l - Real.sqrt a * h k j l) ^ 2 = + a * |x i k - x j k| := by + intro k + simp_rw [← mul_sub, mul_pow, Real.sq_sqrt ha] + rw [← Finset.mul_sum, ← hh k i j, EuclideanSpace.norm_sq_eq] + simp [Real.norm_eq_abs] + simp_rw [hs] + exact (Finset.mul_sum _ _ _).symm + +lemma repair_integral_le {d r : ℝ} (hd : 0 ≤ d) (hr : 0 ≤ r) : + (∫ l in (0 : ℝ)..r, 1 - Real.exp (-d / l)) ≤ r := by + have hi := (intervalIntegrable_const (c := (1 : ℝ))).sub (exp_distance_intervalIntegrable hd hr) + have h := intervalIntegral.integral_mono_on hr hi + (intervalIntegrable_const (c := (1 : ℝ))) (fun l _ => by + have := (Real.exp_pos (-d / l)).le + linarith) + simpa using h + +lemma repair_integral_local {d r : ℝ} (hd : 0 < d) (hdr : d ≤ r) : + (∫ l in (0 : ℝ)..r, 1 - Real.exp (-d / l)) ≤ + d * (1 + Real.log (r / d)) := by + have hr : 0 ≤ r := hd.le.trans hdr + have hi := (intervalIntegrable_const (c := (1 : ℝ))).sub (exp_distance_intervalIntegrable hd.le hr) + have hi₀ := (intervalIntegrable_const (c := (1 : ℝ))).sub (exp_distance_intervalIntegrable hd.le hd.le) + have hi₁ : IntervalIntegrable (fun l => 1 - Real.exp (-d / l)) volume d r := + hi.mono_set (by + rw [Set.uIcc_of_le hdr, Set.uIcc_of_le hr] + exact Set.Icc_subset_Icc hd.le le_rfl) + have hn : 0 ∉ Set.uIcc d r := by + rw [Set.uIcc_of_le hdr] + exact fun h => (not_le_of_gt hd) h.1 + have hj : IntervalIntegrable (fun l => d * l⁻¹) volume d r := + (intervalIntegrable_inv_iff.mpr (Or.inr hn)).const_mul d + have hbound := intervalIntegral.integral_mono_on hdr hi₁ hj (fun l hl => by + have he := Real.one_sub_le_exp_neg (d / l) + rw [← neg_div] at he + rw [← div_eq_mul_inv] + linarith) + rw [intervalIntegral.integral_const_mul, integral_inv hn] at hbound + rw [← intervalIntegral.integral_add_adjacent_intervals hi₀ hi₁] + have hfirst := repair_integral_le hd.le hd.le + linarith + +section Charts + +variable {κ : Type u3} {H : Type u4} [Fintype κ] [DecidableEq κ] + [NormedAddCommGroup H] [InnerProductSpace ℝ H] + +noncomputable def chartKernel (c : ι → κ) (h : ι → H) (l : ℝ) : Matrix ι ι ℝ := + Matrix.of fun i j => if c i = c j then Real.exp (-‖h i - h j‖ ^ 2 / l) else 0 + +noncomputable def cappedDistance (c : ι → κ) (h : ι → H) (r : ℝ) (i j : ι) : ℝ := + if c i = c j then min r (‖h i - h j‖ ^ 2) else r + +omit [Fintype κ] in +lemma chartKernel_posSemidef (c : ι → κ) (h : ι → H) {l : ℝ} (hl : 0 ≤ l) : + (chartKernel c h l).PosSemidef := by + have hm := (Matrix.PosSemidef.one (n := κ) (R := ℝ)).submatrix c + rcases hl.eq_or_lt with rfl | hl + · convert hm using 1 + ext i j + simp [chartKernel, Matrix.submatrix_apply, Matrix.one_apply] + · have hg := gaussian_posSemidef h hl + convert hm.hadamard hg using 1 + ext i j + change (if c i = c j then _ else 0) = + (if c i = c j then (1 : ℝ) else 0) * _ + split_ifs <;> simp + +omit [Fintype ι] [Fintype κ] [InnerProductSpace ℝ H] in +lemma chartKernel_intervalIntegrable (c : ι → κ) (h : ι → H) {r : ℝ} + (hr : 0 ≤ r) (i j : ι) : + IntervalIntegrable (fun l => chartKernel c h l i j) volume 0 r := by + by_cases hij : c i = c j + · simpa [chartKernel, hij] using exp_distance_intervalIntegrable (sq_nonneg ‖h i - h j‖) hr + · simp only [chartKernel, Matrix.of_apply, hij, ite_false] + exact intervalIntegrable_const + +omit [Fintype ι] [Fintype κ] [InnerProductSpace ℝ H] in +lemma chartKernel_nonneg (c : ι → κ) (h : ι → H) (l : ℝ) (i j : ι) : + 0 ≤ chartKernel c h l i j := by + simp only [chartKernel, Matrix.of_apply] + split_ifs <;> positivity + +omit [Fintype ι] [Fintype κ] [InnerProductSpace ℝ H] in +lemma chartKernel_le_one (c : ι → κ) (h : ι → H) {l : ℝ} (hl : 0 ≤ l) (i j : ι) : + chartKernel c h l i j ≤ 1 := by + simp only [chartKernel, Matrix.of_apply] + split_ifs + · exact Real.exp_le_one_iff.mpr (div_nonpos_of_nonpos_of_nonneg + (neg_nonpos.mpr (sq_nonneg _)) hl) + · norm_num + +omit [Fintype ι] [Fintype κ] [InnerProductSpace ℝ H] in +lemma chartKernel_self (c : ι → κ) (h : ι → H) (l : ℝ) (i : ι) : + chartKernel c h l i i = 1 := by simp [chartKernel] + +omit [Fintype ι] [Fintype κ] [InnerProductSpace ℝ H] in +lemma chartKernel_symm (c : ι → κ) (h : ι → H) (l : ℝ) (i j : ι) : + chartKernel c h l i j = chartKernel c h l j i := by + simp only [chartKernel, Matrix.of_apply, norm_sub_rev (h j) (h i)] + by_cases hij : c i = c j <;> simp [hij, eq_comm] + +omit [Fintype ι] [Fintype κ] [InnerProductSpace ℝ H] in +lemma cappedDistance_nonneg (c : ι → κ) (h : ι → H) {r : ℝ} (hr : 0 ≤ r) (i j : ι) : + 0 ≤ cappedDistance c h r i j := by + simp only [cappedDistance] + split_ifs + · exact le_min hr (sq_nonneg _) + · exact hr + +omit [Fintype ι] [Fintype κ] [InnerProductSpace ℝ H] in +lemma cappedDistance_le (c : ι → κ) (h : ι → H) (r : ℝ) (i j : ι) : + cappedDistance c h r i j ≤ r := by + simp only [cappedDistance] + split_ifs + · exact min_le_left _ _ + · rfl + +def ChartTriangle (c : ι → κ) (h : ι → H) : Prop := + ∀ i j k, c i = c j → c j = c k → + ‖h i - h k‖ ^ 2 ≤ ‖h i - h j‖ ^ 2 + ‖h j - h k‖ ^ 2 + +omit [Fintype ι] [Fintype κ] [InnerProductSpace ℝ H] in +lemma chartKernel_mul_le (c : ι → κ) (h : ι → H) (ht : ChartTriangle c h) + {l : ℝ} (hl : 0 < l) (i j z : ι) : + chartKernel c h l i z * chartKernel c h l j z ≤ chartKernel c h l i j := by + by_cases hiz : c i = c z + · by_cases hjz : c j = c z + · simp only [chartKernel, Matrix.of_apply, hiz, hjz, ite_true] + rw [← Real.exp_add] + apply Real.exp_le_exp.mpr + rw [← add_div] + apply div_le_div_of_nonneg_right _ hl.le + have htri := ht i z j hiz hjz.symm + rw [norm_sub_rev (h z) (h j)] at htri + linarith + · simp only [chartKernel, Matrix.of_apply, hjz, ite_false, mul_zero] + split_ifs <;> positivity + · simp only [chartKernel, Matrix.of_apply, hiz, ite_false, zero_mul] + split_ifs <;> positivity + +omit [Fintype ι] [Fintype κ] [InnerProductSpace ℝ H] in +lemma chartKernel_le_half (c : ι → κ) (h : ι → H) {r l : ℝ} + (hl : 0 < l) (i j : ι) (hle : l ≤ cappedDistance c h r i j) : + chartKernel c h l i j ≤ 1 / 2 := by + by_cases hij : c i = c j + · have hd : l ≤ ‖h i - h j‖ ^ 2 := by + exact le_trans hle (by simp [cappedDistance, hij]) + simp only [chartKernel, Matrix.of_apply, hij, ite_true] + calc + Real.exp (-‖h i - h j‖ ^ 2 / l) ≤ Real.exp (-1) := by + apply Real.exp_le_exp.mpr + apply (div_le_iff₀ hl).mpr + linarith + _ ≤ 1 / 2 := by + rw [Real.exp_neg, ← one_div] + apply one_div_le_one_div_of_le (by norm_num : (0 : ℝ) < 2) + have := Real.add_one_le_exp (1 : ℝ) + norm_num at this ⊢ + exact this + · simp [chartKernel, hij] + +def IsRepairGram (c : ι → κ) (h : ι → H) (r : ℝ) + (q : ι → EuclideanSpace ℝ ι) : Prop := + ∀ i j, ⟪q i, q j⟫_ℝ = 4 * ∫ l in (0 : ℝ)..r, chartKernel c h l i j + +omit [Fintype κ] in +lemma exists_repairGram (c : ι → κ) (h : ι → H) {r : ℝ} (hr : 0 ≤ r) : + ∃ q : ι → EuclideanSpace ℝ ι, IsRepairGram c h r q := by + have hi := integral_posSemidef (chartKernel c h) hr + (fun l hl => chartKernel_posSemidef c h hl.1) (chartKernel_intervalIntegrable c h hr) + obtain ⟨q, hq⟩ := exists_gram (hi.smul (by norm_num : (0 : ℝ) ≤ 4)) + exact ⟨q, hq⟩ + +omit [Fintype κ] [InnerProductSpace ℝ H] in +lemma repairGram_norm_sq (c : ι → κ) (h : ι → H) {r : ℝ} + {q : ι → EuclideanSpace ℝ ι} (hq : IsRepairGram c h r q) (i : ι) : + ‖q i‖ ^ 2 = 4 * r := by + rw [← real_inner_self_eq_norm_sq, hq] + simp_rw [chartKernel_self] + simp + +omit [Fintype κ] [InnerProductSpace ℝ H] in +lemma repairGram_distance (c : ι → κ) (h : ι → H) {r : ℝ} (hr : 0 ≤ r) + {q : ι → EuclideanSpace ℝ ι} (hq : IsRepairGram c h r q) (i j : ι) : + ‖q i - q j‖ ^ 2 = 8 * ∫ l in (0 : ℝ)..r, 1 - chartKernel c h l i j := by + rw [norm_sub_sq_real, repairGram_norm_sq c h hq, repairGram_norm_sq c h hq, hq, + intervalIntegral.integral_sub intervalIntegrable_const + (chartKernel_intervalIntegrable c h hr i j)] + simp only [intervalIntegral.integral_const, sub_zero, smul_eq_mul, mul_one] + ring + +omit [Fintype κ] [InnerProductSpace ℝ H] in +lemma repairGram_distance_le (c : ι → κ) (h : ι → H) {r : ℝ} (hr : 0 ≤ r) + {q : ι → EuclideanSpace ℝ ι} (hq : IsRepairGram c h r q) (i j : ι) : + ‖q i - q j‖ ^ 2 ≤ 8 * r := by + rw [repairGram_distance c h hr hq] + have hi := (intervalIntegrable_const (c := (1 : ℝ))).sub + (chartKernel_intervalIntegrable c h hr i j) + have hb := intervalIntegral.integral_mono_on hr hi + (intervalIntegrable_const (c := (1 : ℝ))) (fun l _ => by + have := chartKernel_nonneg c h l i j + linarith) + simp only [intervalIntegral.integral_const, sub_zero, smul_eq_mul, mul_one] at hb + linarith + +omit [Fintype κ] [InnerProductSpace ℝ H] in +lemma repairGram_local (c : ι → κ) (h : ι → H) {r : ℝ} + {q : ι → EuclideanSpace ℝ ι} (hq : IsRepairGram c h r q) {i j : ι} + (hij : c i = c j) (hd : 0 < ‖h i - h j‖ ^ 2) (hdr : ‖h i - h j‖ ^ 2 ≤ r) : + ‖q i - q j‖ ^ 2 ≤ 8 * ‖h i - h j‖ ^ 2 * + (1 + Real.log (r / ‖h i - h j‖ ^ 2)) := by + rw [repairGram_distance c h (hd.le.trans hdr) hq] + simp only [chartKernel, Matrix.of_apply, hij, ite_true] + have := repair_integral_local hd hdr + nlinarith + +omit [Fintype κ] [InnerProductSpace ℝ H] in +lemma repairGram_eq_of_zero (c : ι → κ) (h : ι → H) {r : ℝ} (hr : 0 ≤ r) + {q : ι → EuclideanSpace ℝ ι} (hq : IsRepairGram c h r q) {i j : ι} + (hij : c i = c j) (hd : ‖h i - h j‖ ^ 2 = 0) : q i = q j := by + have hdq := repairGram_distance c h hr hq i j + simp only [chartKernel, Matrix.of_apply, hij, ite_true, hd, neg_zero, zero_div, + Real.exp_zero, sub_self, intervalIntegral.integral_zero, mul_zero] at hdq + exact sub_eq_zero.mp (norm_eq_zero.mp (sq_eq_zero_iff.mp hdq)) + +noncomputable def angleIntegrand (c : ι → κ) (h : ι → H) (i j z : ι) (l : ℝ) : ℝ := + 1 - chartKernel c h l i z - chartKernel c h l j z + chartKernel c h l i j + +omit [Fintype ι] [Fintype κ] [InnerProductSpace ℝ H] in +lemma angleIntegrand_integrable (c : ι → κ) (h : ι → H) {r : ℝ} (hr : 0 ≤ r) + (i j z : ι) : IntervalIntegrable (angleIntegrand c h i j z) volume 0 r := + (((intervalIntegrable_const (c := (1 : ℝ))).sub (chartKernel_intervalIntegrable c h hr i z)).sub + (chartKernel_intervalIntegrable c h hr j z)).add (chartKernel_intervalIntegrable c h hr i j) + +omit [Fintype κ] [InnerProductSpace ℝ H] in +lemma repairGram_angle (c : ι → κ) (h : ι → H) {r : ℝ} (hr : 0 ≤ r) + {q : ι → EuclideanSpace ℝ ι} (hq : IsRepairGram c h r q) (i j z : ι) : + ⟪q i - q z, q j - q z⟫_ℝ = 4 * ∫ l in (0 : ℝ)..r, angleIntegrand c h i j z l := by + rw [inner_sub_left, inner_sub_right, inner_sub_right, hq, hq, hq, hq] + simp_rw [chartKernel_self, chartKernel_symm c h _ z j] + rw [show (fun l => angleIntegrand c h i j z l) = + (fun l => 1 - chartKernel c h l i z - chartKernel c h l j z + + chartKernel c h l i j) from rfl] + rw [intervalIntegral.integral_add + (((intervalIntegrable_const (c := (1 : ℝ))).sub + (chartKernel_intervalIntegrable c h hr i z)).sub + (chartKernel_intervalIntegrable c h hr j z)) (chartKernel_intervalIntegrable c h hr i j)] + rw [intervalIntegral.integral_sub + ((intervalIntegrable_const (c := (1 : ℝ))).sub (chartKernel_intervalIntegrable c h hr i z)) + (chartKernel_intervalIntegrable c h hr j z)] + rw [intervalIntegral.integral_sub intervalIntegrable_const + (chartKernel_intervalIntegrable c h hr i z)] + ring + +omit [Fintype ι] [Fintype κ] [InnerProductSpace ℝ H] in +lemma angleIntegrand_nonneg (c : ι → κ) (h : ι → H) (ht : ChartTriangle c h) + {l : ℝ} (hl : 0 < l) (i j z : ι) : 0 ≤ angleIntegrand c h i j z l := by + have ha := chartKernel_le_one c h hl.le i z + have hb := chartKernel_le_one c h hl.le j z + have hc := chartKernel_mul_le c h ht hl i j z + have hp := mul_nonneg (sub_nonneg.mpr ha) (sub_nonneg.mpr hb) + dsimp only [angleIntegrand] + nlinarith + +omit [Fintype ι] [Fintype κ] [InnerProductSpace ℝ H] in +lemma angleIntegrand_ge_quarter (c : ι → κ) (h : ι → H) (ht : ChartTriangle c h) + {r l : ℝ} (hl : 0 < l) (i j z : ι) + (hli : l ≤ cappedDistance c h r i z) (hlj : l ≤ cappedDistance c h r j z) : + 1 / 4 ≤ angleIntegrand c h i j z l := by + have ha := chartKernel_le_half c h hl i z hli + have hb := chartKernel_le_half c h hl j z hlj + have hc := chartKernel_mul_le c h ht hl i j z + have hp := mul_le_mul + (show (1 / 2 : ℝ) ≤ 1 - chartKernel c h l i z by linarith) + (show (1 / 2 : ℝ) ≤ 1 - chartKernel c h l j z by linarith) + (by norm_num : (0 : ℝ) ≤ 1 / 2) + (show 0 ≤ 1 - chartKernel c h l i z by linarith) + dsimp only [angleIntegrand] + nlinarith + +omit [Fintype κ] [InnerProductSpace ℝ H] in +lemma repairGram_angle_lower (c : ι → κ) (h : ι → H) (ht : ChartTriangle c h) + {r : ℝ} (hr : 0 ≤ r) {q : ι → EuclideanSpace ℝ ι} (hq : IsRepairGram c h r q) + (i j z : ι) : + min (cappedDistance c h r i z) (cappedDistance c h r j z) ≤ + ⟪q i - q z, q j - q z⟫_ℝ := by + let t := min (cappedDistance c h r i z) (cappedDistance c h r j z) + have ht₀ : 0 ≤ t := le_min (cappedDistance_nonneg c h hr i z) + (cappedDistance_nonneg c h hr j z) + have htr : t ≤ r := (min_le_left _ _).trans (cappedDistance_le c h r i z) + have hf : (0 : ℝ → ℝ) ≤ᵐ[volume.restrict (Set.Ioc 0 r)] angleIntegrand c h i j z := by + filter_upwards [ae_restrict_mem measurableSet_Ioc] with l hl + exact angleIntegrand_nonneg c h ht hl.1 i j z + have hlower := intervalIntegral.integral_mono_ae_restrict ht₀ + (intervalIntegrable_const (c := (1 / 4 : ℝ))) (angleIntegrand_integrable c h ht₀ i j z) + (show (fun _ => (1 / 4 : ℝ)) ≤ᵐ[volume.restrict (Set.Icc 0 t)] + angleIntegrand c h i j z from by + filter_upwards [ae_restrict_mem measurableSet_Icc, + ae_restrict_of_ae (volume.ae_ne (0 : ℝ))] with l hl hne + exact angleIntegrand_ge_quarter c h ht (lt_of_le_of_ne hl.1 (Ne.symm hne)) i j z + (hl.2.trans (min_le_left _ _)) (hl.2.trans (min_le_right _ _))) + have hmono := intervalIntegral.integral_mono_interval le_rfl ht₀ htr hf + (angleIntegrand_integrable c h hr i j z) + rw [repairGram_angle c h hr hq] + simp only [intervalIntegral.integral_const, sub_zero, smul_eq_mul] at hlower + dsimp only [t] at * + linarith + +omit [Fintype κ] [DecidableEq κ] in + +lemma chart_l1_sq_hilbert {ξ : Type u5} [Fintype ξ] (c : ι → κ) (x : ι → ξ → ℝ) + (a : κ → ℝ) (ha : ∀ s, 0 ≤ a s) : + ∃ h : ι → EuclideanSpace ℝ (ξ × ι), + (∀ i j, c i = c j → ‖h i - h j‖ ^ 2 = a (c i) * ∑ k, |x i k - x j k|) ∧ + ChartTriangle c h := by + obtain ⟨g, hg⟩ := l1_sq_hilbert x (by norm_num : (0 : ℝ) ≤ 1) + let h : ι → EuclideanSpace ℝ (ξ × ι) := fun i => Real.sqrt (a (c i)) • g i + have hh (i j : ι) (hc : c i = c j) : + ‖h i - h j‖ ^ 2 = a (c i) * ∑ k, |x i k - x j k| := by + dsimp only [h] + rw [← hc, ← smul_sub, norm_smul, mul_pow, Real.norm_eq_abs, sq_abs, + Real.sq_sqrt (ha (c i)), hg] + ring + refine ⟨h, hh, fun i j k hij hjk => ?_⟩ + rw [hh i k (hij.trans hjk), hh i j hij, hh j k hjk, ← hij, ← mul_add] + apply mul_le_mul_of_nonneg_left _ (ha (c i)) + rw [← Finset.sum_add_distrib] + exact Finset.sum_le_sum (fun l _ => abs_sub_le (x i l) (x j l) (x k l)) + +lemma sum_sq_hilbert {E : Type u6} [NormedAddCommGroup E] [InnerProductSpace ℝ E] + (P : ι → E) (q : ι → H) : + ∃ z : ι → EuclideanSpace ℝ ι, ∀ i j, + ‖z i - z j‖ ^ 2 = ‖P i - P j‖ ^ 2 + ‖q i - q j‖ ^ 2 := by + obtain ⟨z, hz⟩ := exists_gram ((gram_posSemidef P).add (gram_posSemidef q)) + refine ⟨z, fun i j => ?_⟩ + simp only [norm_sub_sq_real] + simp only [← real_inner_self_eq_norm_sq, hz, Matrix.add_apply, Matrix.of_apply] + ring + +lemma angle_triangle_slack (x y z : H) : + ‖x - y‖ ^ 2 + ‖z - y‖ ^ 2 - ‖x - z‖ ^ 2 = 2 * ⟪x - y, z - y⟫_ℝ := by + have he : x - z = (x - y) - (z - y) := by abel + rw [he, norm_sub_sq_real (x - y) (z - y)] + ring + +omit [Fintype κ] in + +theorem triangle_repair {E : Type u7} [NormedAddCommGroup E] [InnerProductSpace ℝ E] + (c : ι → κ) (h : ι → H) (ht : ChartTriangle c h) {r : ℝ} (hr : 0 < r) + (P : ι → E) + (hP : ∀ i j z, -min (cappedDistance c h r i z) (cappedDistance c h r j z) ≤ + ⟪P i - P z, P j - P z⟫_ℝ) : + ∃ q z : ι → EuclideanSpace ℝ ι, + IsRepairGram c h r q ∧ + (∀ i j, ‖z i - z j‖ ^ 2 = ‖P i - P j‖ ^ 2 + ‖q i - q j‖ ^ 2) ∧ + (∀ i j k, ‖z i - z k‖ ^ 2 ≤ ‖z i - z j‖ ^ 2 + ‖z j - z k‖ ^ 2) ∧ + (∀ i j, ‖q i - q j‖ ^ 2 = 8 * ∫ l in (0 : ℝ)..r, 1 - chartKernel c h l i j) ∧ + (∀ i j, ‖q i - q j‖ ^ 2 ≤ 8 * r) ∧ + (∀ i j, c i = c j → 0 < ‖h i - h j‖ ^ 2 → ‖h i - h j‖ ^ 2 ≤ r → + ‖q i - q j‖ ^ 2 ≤ 8 * ‖h i - h j‖ ^ 2 * (1 + Real.log (r / ‖h i - h j‖ ^ 2))) ∧ + (∀ i j, c i = c j → ‖h i - h j‖ ^ 2 = 0 → q i = q j) := by + obtain ⟨q, hq⟩ := exists_repairGram c h hr.le + obtain ⟨z, hz⟩ := sum_sq_hilbert P q + refine ⟨q, z, hq, hz, ?_, repairGram_distance c h hr.le hq, + repairGram_distance_le c h hr.le hq, + fun _ _ hc hd hdr => repairGram_local c h hq hc hd hdr, + fun _ _ hc hd => repairGram_eq_of_zero c h hr.le hq hc hd⟩ + intro i j k + rw [hz, hz, hz] + have hp := hP i k j + have hqangle := repairGram_angle_lower c h ht hr.le hq i k j + have hpAngle := angle_triangle_slack (P i) (P j) (P k) + have hqAngle := angle_triangle_slack (q i) (q j) (q k) + rw [norm_sub_rev (P k) (P j)] at hpAngle + rw [norm_sub_rev (q k) (q j)] at hqAngle + linarith + +end Charts + +end UniformSparsestCut.TriangleRepair + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SparsestCut/UniformMetric.lean b/lean/OAI/Combinatorics/SparsestCut/UniformMetric.lean new file mode 100644 index 0000000000000000000000000000000000000000..af15e1f766d32e18fbda62f263b3f096ad492c5a --- /dev/null +++ b/lean/OAI/Combinatorics/SparsestCut/UniformMetric.lean @@ -0,0 +1,89 @@ +import OAI.Combinatorics.SparsestCut.UniformReplication +import OAI.Combinatorics.SparsestCut.VertexCount + +namespace OAI + +open scoped BigOperators Topology NNReal RealInnerProductSpace InnerProductSpace Matrix ContDiff ENNReal +open MeasureTheory ProbabilityTheory Set Filter Matrix + +noncomputable section + +namespace UniformSparsestCut.SourceUniform +open scoped BigOperators +open SourceMetric SourceParameters +noncomputable section +lemma size_upper {d v : ℕ} (hd : 3≤d) (hv : v≤d^(4025*d)) : + d^d+d^2*v+v≤d^(4030*d) := by + have hd1 : 1≤d := by omega + have hp : d^d≤d^(4025*d+2) := Nat.pow_le_pow_right hd1 (by omega) + have hv' : v≤d^(4025*d+2) := hv.trans (Nat.pow_le_pow_right hd1 (by omega)) + have hprod : d^2*v≤d^(4025*d+2) := by + calc + _ ≤ d^2*d^(4025*d) := Nat.mul_le_mul_left _ hv + _ = _ := by rw [←pow_add]; congr 1; omega + calc + _ ≤ 3*d^(4025*d+2) := by omega + _ ≤ d*d^(4025*d+2) := Nat.mul_le_mul_right _ hd + _ = d^(4025*d+3) := by rw [←pow_succ'] + _ ≤ _ := Nat.pow_le_pow_right hd1 (by omega) + +lemma instance_exists {m : ℕ} (f : PivotFamily.PFamily (m+1)) + (hm : 3000 ≤ m+1) (hl : 1≤Real.log (m+1:ℕ)) (hH : SourceContraction.H≤(m+1:ℕ)) + (hD : 4*SourceWeighted.D≤(m+1:ℕ)) + (ha : C₀+1≤KernelApprox.cstar/6*(m+1:ℕ)) : + ∃ (n : ℕ) (C : Capacity n), (m+1)^(m+1)≤n ∧ n≤(m+1)^(4030*(m+1)) ∧ + 2≤n ∧ 1≤OPT C ∧ 0 ‖Z (Replication.rep M w i)-Z (Replication.rep M w j)‖^2 + let ε : ℝ := 4*(SourceWeighted.D*d)*(Fintype.card (V f):ℝ)/M + have hε : ε≤1 := by + apply (div_le_one (by exact_mod_cast hM)).mpr + have hM' : (d:ℝ)^2*(Fintype.card (V f):ℝ)≤M := by + exact_mod_cast (Nat.le_add_left (d^2*Fintype.card (V f)) (d^d)) + calc + _ = (4*SourceWeighted.D)*(d:ℝ)*(Fintype.card (V f):ℝ) := by ring + _ ≤ (d:ℝ)*(d:ℝ)*(Fintype.card (V f):ℝ) := + mul_le_mul_of_nonneg_right (mul_le_mul_of_nonneg_right hD hx0.le) (Nat.cast_nonneg _) + _ = (d:ℝ)^2*(Fintype.card (V f):ℝ) := by ring + _ ≤ _ := hM' + have hsize := Replication.n_bounds M w hw hws + have hlo : d^d≤n := (Nat.le_add_right _ _).trans hsize.1 + have hhi : n≤d^(4030*d) := hsize.2.trans (size_upper (by omega) (SourceCount.card_bound f (by omega))) + have hn : 2≤n := by + have hh : d≤d^d := by simpa using (Nat.pow_le_pow_right hd1 hd1 : d^1≤d^d) + omega + obtain ⟨hδ,hav,hco⟩ := UniformReplication.estimates M hM w hw hws Z htri + (mul_nonneg SourceWeighted.D_pos.le hx0.le) hdiam havg hcon + have ha0 : 0 (hco A F hF).trans (mul_le_mul_of_nonneg_left hupp (sq_nonneg (n:ℝ)))) + exact ⟨n,C,hlo,hhi,hn,hopt,hgl,hbound⟩ +end +end UniformSparsestCut.SourceUniform + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SparsestCut/UniformReplication.lean b/lean/OAI/Combinatorics/SparsestCut/UniformReplication.lean new file mode 100644 index 0000000000000000000000000000000000000000..ddb2915997ea0714b946066de4f600010d50bd8b --- /dev/null +++ b/lean/OAI/Combinatorics/SparsestCut/UniformReplication.lean @@ -0,0 +1,78 @@ +import OAI.Combinatorics.SparsestCut.Replication +import OAI.Combinatorics.SparsestCut.PositiveKernels + +namespace OAI + +universe u1 u2 u3 u4 + +open scoped BigOperators Topology NNReal RealInnerProductSpace InnerProductSpace Matrix ContDiff ENNReal +open MeasureTheory ProbabilityTheory Set Filter Matrix + +noncomputable section + +namespace UniformSparsestCut.UniformReplication +open scoped BigOperators RealInnerProductSpace +noncomputable section +lemma negative_pullback {V : Type u1} {H : Type u2} [NormedAddCommGroup H] [InnerProductSpace ℝ H] + (Z : V → H) (htri : ∀ v w z, ‖Z v-Z z‖^2 ≤ ‖Z v-Z w‖^2+‖Z w-Z z‖^2) + {n : ℕ} (r : Fin n → V) : NegativeType (fun i j => ‖Z (r i)-Z (r j)‖^2) := by + classical + obtain ⟨Y,hY⟩ := TriangleRepair.exists_gram (TriangleRepair.gram_posSemidef (fun i => Z (r i))) + refine ⟨⟨Y,?_⟩,fun i j k => htri (r i) (r j) (r k)⟩ + intro i j + simp only [← real_inner_self_eq_norm_sq, inner_sub_left, inner_sub_right, hY, Matrix.of_apply] + +variable {V : Type u3} {H : Type u4} [Fintype V] [NormedAddCommGroup H] [InnerProductSpace ℝ H] +lemma estimates (M : ℕ) (hM : 0 ‖Z (Replication.rep M w i)-Z (Replication.rep M w j)‖^2 + let ε := 4*D*(Fintype.card V:ℝ)/M + NegativeType d ∧ (n:ℝ)^2*(a-ε)≤∑ i, ∑ j,d i j ∧ + ∀ (A : Type) [Fintype A] (F : Fin n → A → ℝ), + (∀ i j, (∑ k, |F i k-F j k|)≤d i j) → + (∑ i, ∑ j, ∑ k, |F i k-F j k|)≤(n:ℝ)^2*(b+ε) := by + dsimp only + have hn : 0 ‖Z v-Z z‖^2)] + apply mul_le_mul_of_nonneg_left _ (sq_nonneg _) + have he := Replication.expectation_error M hM w hw hws + (fun v z => ‖Z v-Z z‖^2) hD (fun v z => by rw [abs_of_nonneg (sq_nonneg _)]; exact hdiam v z) + linarith [(abs_le.mp he).1] + · intro A hA F hF + let G : V → A → ℝ := fun v k => F (Replication.representative M w v) k + have hG : ∀ v z, (∑ k, |G v k-G z k|)≤‖Z v-Z z‖^2 := + Replication.descend_contraction M w _ F hF + have he : (∑ i, ∑ j, ∑ k, |F i k-F j k|)= + ∑ i, ∑ j, ∑ k, |G (Replication.rep M w i) k-G (Replication.rep M w j) k| := by + apply Finset.sum_congr rfl + intro i hi + apply Finset.sum_congr rfl + intro j hj + apply Finset.sum_congr rfl + intro k hk + have h1 := Replication.collapse M w (fun v z => ‖Z v-Z z‖^2) (by simp) F hF i k + have h2 := Replication.collapse M w (fun v z => ‖Z v-Z z‖^2) (by simp) F hF j k + change |F i k-F j k|=|F (Replication.representative M w (Replication.rep M w i)) k- + F (Replication.representative M w (Replication.rep M w j)) k| + rw [h1,h2] + rw [he,Replication.ordered_sum M w hn (fun v z => ∑ k, |G v k-G z k|)] + apply mul_le_mul_of_nonneg_left _ (sq_nonneg _) + have herr := Replication.expectation_error M hM w hw hws + (fun v z => ∑ k, |G v k-G z k|) hD (fun v z => by + rw [abs_of_nonneg (Finset.sum_nonneg (fun k _ => abs_nonneg _))] + exact (hG v z).trans (hdiam v z)) + have hbound := hcon A G hG + linarith [(abs_le.mp herr).2] +end +end UniformSparsestCut.UniformReplication + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SparsestCut/VertexCount.lean b/lean/OAI/Combinatorics/SparsestCut/VertexCount.lean new file mode 100644 index 0000000000000000000000000000000000000000..57de5c8d2ac7b857153096015d025a884d5d0c33 --- /dev/null +++ b/lean/OAI/Combinatorics/SparsestCut/VertexCount.lean @@ -0,0 +1,75 @@ +import OAI.Combinatorics.SparsestCut.LabelCount + +namespace OAI + +open scoped BigOperators Topology NNReal RealInnerProductSpace InnerProductSpace Matrix ContDiff ENNReal +open MeasureTheory ProbabilityTheory Set Filter Matrix + +noncomputable section + +namespace UniformSparsestCut.SourceCount +open SourceCharts SourceParameters SourceMetric +open scoped BigOperators +noncomputable section +variable {m : ℕ} (f : PivotFamily.PFamily m) [NeZero m] +lemma integer_bound (hm : 5 ≤ m) (v : V f) (i : Fin (m^6)) : |(v.val.2 i:ℝ)|≤(m:ℝ)^2003 := by + have hm0 := NeZero.pos m + have hx : (1:ℝ) ≤ m := by exact_mod_cast (show 1 ≤ m by omega) + have hx5 : (5:ℝ) ≤ m := by exact_mod_cast hm + have hx0 : (0:ℝ)< m := by exact_mod_cast hm0 + obtain ⟨θ,hθ,hr,he⟩ := v.property + have h := RoundedCharts.integerLabel_bound (u f v.val.1) (p_pos hx0 2000) + (fun i => (u_norm f hm0 v.val.1 i).2) hθ i + rw [he] at h + calc + _ ≤ 4*Real.sqrt m/p m 2000+1 := h + _ ≤ 4*(m:ℝ)/p m 2000+1 := by + apply add_le_add_left + apply div_le_div_of_nonneg_right _ (p_nonneg hx0.le _) + exact mul_le_mul_of_nonneg_left (sqrt_le hx) (by norm_num) + _ = 4*(m:ℝ)^2001+1 := by unfold p; field_simp + _ ≤ 5*(m:ℝ)^2001 := by nlinarith [one_le_pow₀ hx (n:=2001)] + _ ≤ (m:ℝ)*(m:ℝ)^2001 := mul_le_mul_of_nonneg_right hx5 (by positivity) + _ = (m:ℝ)^2002 := by ring + _ ≤ _ := pow_le_pow_right₀ hx (by norm_num) +lemma card_bound (hm : 5 ≤ m) : Fintype.card (V f)≤ m^(4025*m) := by + have hm0 := NeZero.pos m + have hx0 : (0:ℝ)< m := by exact_mod_cast hm0 + let B : ℤ := (m:ℤ)^2003 + have hB : ∀ v : V f, ∀ i, v.val.2 i∈Finset.Icc (-B) B := by + intro v i + have h := integer_bound f hm v i + have h' : |v.val.2 i|≤B := by exact_mod_cast h + simpa only [Finset.mem_Icc,abs_le] using h' + have h := LabelCount.vertex_count (u f) (p_pos hx0 2000) B hB + have hI : (Finset.Icc (-B) B).card=2*m^2003+1 := by + rw [Int.card_Icc] + dsimp [B] + have he : (m:ℤ)^2003+1-(-(m:ℤ)^2003)=((2*m^2003+1:ℕ):ℤ) := by push_cast; ring + rw [he,Int.toNat_natCast] + rw [hI] at h + have hm1 : 1 ≤ m := by omega + have hp : 1≤ m^2003 := one_le_pow₀ hm1 + have hI' : 2*m^2003+1≤ m^2004 := by + calc + _ ≤ 3*m^2003 := by omega + _ ≤ m*m^2003 := Nat.mul_le_mul_right _ (by omega) + _ = _ := by ring + have hH : m^6*(2*m^2003+1)+1≤ m^2011 := by + calc + _ ≤ m^6*m^2004+1 := Nat.add_le_add_right (Nat.mul_le_mul_left _ hI') _ + _ = m^2010+1 := by ring + _ ≤ 2*m^2010 := by have hh := one_le_pow₀ hm1 (n:=2010); omega + _ ≤ m*m^2010 := Nat.mul_le_mul_right _ (by omega) + _ = _ := by ring + calc + _ ≤ m^3*(m^6*(2*m^2003+1)+1)^(m+1) := h + _ ≤ m^3*(m^2011)^(m+1) := Nat.mul_le_mul_left _ (Nat.pow_le_pow_left hH _) + _ = m^(3+2011*(m+1)) := by rw [← pow_mul,← pow_add] + _ ≤ _ := Nat.pow_le_pow_right hm1 (by omega) +end +end UniformSparsestCut.SourceCount + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SparsestCut/VertexMeasure.lean b/lean/OAI/Combinatorics/SparsestCut/VertexMeasure.lean new file mode 100644 index 0000000000000000000000000000000000000000..5bfe5c86d2b9a0bd06a0c84dd23a962d26f3b289 --- /dev/null +++ b/lean/OAI/Combinatorics/SparsestCut/VertexMeasure.lean @@ -0,0 +1,96 @@ +import OAI.Combinatorics.SparsestCut.ContractionAverage + +namespace OAI + +universe u1 + +open scoped BigOperators Topology NNReal RealInnerProductSpace InnerProductSpace Matrix ContDiff ENNReal +open MeasureTheory ProbabilityTheory Set Filter Matrix + +noncomputable section + +namespace UniformSparsestCut.VertexMeasure +open MeasureTheory Set Filter +open scoped BigOperators RealInnerProductSpace +noncomputable section +variable {m N S : ℕ} +local notation "E" => EuclideanSpace ℝ (Fin m) +local notation "μ" => (CubePoincare.cube (m:=m)) +local instance {u : Fin S → Fin N → E} {τ : ℝ} : MeasurableSpace (RoundedCharts.Vertex u τ) := by unfold RoundedCharts.Vertex; infer_instance +local instance {u : Fin S → Fin N → E} {τ : ℝ} : MeasurableSingletonClass (RoundedCharts.Vertex u τ) := by unfold RoundedCharts.Vertex; infer_instance +lemma cube_measurable (R : ℝ) : MeasurableSet (RoundedCharts.cube (m:=m) R) := by + rw [show RoundedCharts.cube (m:=m) R=(⋂ j : Fin m, {x : E | |x j| inner ℝ (u i) x)) continuous_const).measurableSet.compl +lemma integer_measurable (u : Fin N → E) (τ : ℝ) : Measurable (RoundedCharts.integerLabel u τ) := by + apply Measurable.of_eval + intro i + exact Int.measurable_floor.comp (by fun_prop) +open Classical in +def label (u : Fin S → Fin N → E) (τ : ℝ) (s : Fin S) (v₀ : RoundedCharts.Vertex u τ) (x : E) : RoundedCharts.Vertex u τ := + if h : x∈RoundedCharts.cube 2 ∧ RoundedCharts.regular (u s) τ x then + ⟨(s,RoundedCharts.integerLabel (u s) τ x),x,h.1,h.2,rfl⟩ else v₀ +lemma label_measurable (u : Fin S → Fin N → E) (τ : ℝ) (s : Fin S) (v₀ : RoundedCharts.Vertex u τ) : + Measurable (label u τ s v₀) := by + classical + have hh : Measurable (fun x : E => if x∈RoundedCharts.cube 2 ∧ RoundedCharts.regular (u s) τ x then + (s,RoundedCharts.integerLabel (u s) τ x) else v₀.val) := + (measurable_const.prodMk (integer_measurable (u s) τ)).ite ((cube_measurable 2).inter (regular_measurable (u s) τ)) measurable_const + have hval : Measurable (fun x => (label u τ s v₀ x).val) := by + convert hh using 1 + funext x + by_cases hgood : x ∈ RoundedCharts.cube 2 ∧ RoundedCharts.regular (u s) τ x <;> + simp [label, hgood] + exact hval.subtype_mk +lemma ae_good (u : Fin N → E) (hu : ∀ i, u i≠0) (τ : ℝ) : + ∀ᵐ x : E ∂μ, x∈RoundedCharts.cube 2 ∧ RoundedCharts.regular u τ x := by + filter_upwards [CubeGeometry.cube_mem (m:=m), CubeGeometry.cube_ac.ae_le (RoundedCharts.ae_regular u τ hu)] with x hx hr + exact ⟨fun j => (hx j).trans (by norm_num),hr⟩ +lemma vertex_nonempty (u : Fin S → Fin N → E) (hu : ∀ s i, u s i≠0) (τ : ℝ) (s : Fin S) : + Nonempty (RoundedCharts.Vertex u τ) := by + obtain ⟨x,hx,hr⟩ := (ae_good (u s) (hu s) τ).exists + exact ⟨⟨(s,RoundedCharts.integerLabel (u s) τ x),x,hx,hr,rfl⟩⟩ +def measure (u : Fin S → Fin N → E) (τ : ℝ) (s : Fin S) (v₀ : RoundedCharts.Vertex u τ) : Measure (RoundedCharts.Vertex u τ) := + (μ).map (label u τ s v₀) +instance probability (u : Fin S → Fin N → E) (τ : ℝ) (s : Fin S) (v₀ : RoundedCharts.Vertex u τ) : + IsProbabilityMeasure (measure u τ s v₀) := by + change IsProbabilityMeasure ((μ).map (label u τ s v₀)) + infer_instance +lemma finite_weights {V : Type u1} [Fintype V] [MeasurableSpace V] [MeasurableSingletonClass V] + (ν : Measure V) [IsProbabilityMeasure ν] : (∑ v, ν.real {v})=1 := by + have h : (∫ _ : V, (1:ℝ) ∂ν)=∑ v, ν.real {v} • (1:ℝ) := integral_fintype (integrable_const _) + simp +lemma pair_average (u : Fin S → Fin N → E) (τ : ℝ) (s : Fin S) (v₀ : RoundedCharts.Vertex u τ) + [Fintype (RoundedCharts.Vertex u τ)] (d : RoundedCharts.Vertex u τ → RoundedCharts.Vertex u τ → ℝ) : + (∑ v, ∑ w, (measure u τ s v₀).real {v}*(measure u τ s v₀).real {w}*d v w)= + ∫ z : E × E, d (label u τ s v₀ z.1) (label u τ s v₀ z.2) ∂(μ).prod μ := by + let ν := measure u τ s v₀ + calc + _ = ∫ z : RoundedCharts.Vertex u τ × RoundedCharts.Vertex u τ, d z.1 z.2 ∂ν.prod ν := by + rw [integral_fintype Integrable.of_finite, Fintype.sum_prod_type] + apply Finset.sum_congr rfl + intro v hv + apply Finset.sum_congr rfl + intro w hw + rw [show ({(v,w)} : Set (RoundedCharts.Vertex u τ × RoundedCharts.Vertex u τ))={v}×ˢ{w} by ext z; simp] + rw [measureReal_prod_prod] + rfl + _ = _ := by + change (∫ z, d z.1 z.2 ∂((μ).map (label u τ s v₀)).prod ((μ).map (label u τ s v₀)))=_ + rw [Measure.map_prod_map μ μ (label_measurable u τ s v₀) (label_measurable u τ s v₀)] + exact integral_map ((label_measurable u τ s v₀).prodMap (label_measurable u τ s v₀)).aemeasurable + (measurable_of_countable _).aestronglyMeasurable +end +end UniformSparsestCut.VertexMeasure + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SparsestCut/WeightNormalization.lean b/lean/OAI/Combinatorics/SparsestCut/WeightNormalization.lean new file mode 100644 index 0000000000000000000000000000000000000000..ae8f45755fee1ba45df1aa8ae4ab524b6a63c820 --- /dev/null +++ b/lean/OAI/Combinatorics/SparsestCut/WeightNormalization.lean @@ -0,0 +1,79 @@ +/- +Copyright (c) 2026 OpenAI. All rights reserved. +Authors: OpenAI +-/ +import OAI.Combinatorics.SparsestCut.FiniteWeights +import Mathlib.Algebra.BigOperators.Field + +namespace OAI + +/-! +# Normalization of finite weights + +A lower approximation to a probability law retains coordinatewise domination and +setwise lower bounds after normalization. These are the retained-demand estimates +in Section 7 of OpenAI's *Constant-factor hardness of uniform sparsest cut*. +-/ + +open scoped BigOperators + +namespace UniformSparsestCut.FiniteWeights + +variable {ι : Type*} [Fintype ι] + +noncomputable def normalized (l : ι → ℝ) : ι → ℝ := fun i => l i / total l + +theorem normalized_nonneg {l : ι → ℝ} (hl : ∀ i, 0 ≤ l i) (hL : 0 < total l) : + ∀ i, 0 ≤ normalized l i := + fun i => div_nonneg (hl i) hL.le + +theorem normalized_total {l : ι → ℝ} (hL : 0 < total l) : total (normalized l) = 1 := by + change (∑ i, l i / total l) = 1 + rw [← Finset.sum_div] + exact div_self (ne_of_gt hL) + +theorem normalized_mass (l : ι → ℝ) (h : ι → Bool) : + mass (normalized l) h = mass l h / total l := by + change (∑ i, l i / total l * indicator (h i)) = mass l h / total l + simp_rw [div_mul_eq_mul_div] + rw [← Finset.sum_div] + rfl + +/-- Normalization of a sufficiently large lower approximation increases each weight +by at most a factor of two. -/ +theorem normalized_le_twice {μ l : ι → ℝ} {ε : ℝ} + (hμ : ∀ i, 0 ≤ μ i) (hle : ∀ i, l i ≤ μ i) + (hε : ε ≤ 1 / 2) (hL : 1 - ε ≤ total l) : + ∀ i, normalized l i ≤ 2 * μ i := by + have hpos : 0 < total l := by linarith + intro i + apply (div_le_iff₀ hpos).mpr + have hh := mul_nonneg (hμ i) (show 0 ≤ 2 * total l - 1 by linarith) + nlinarith only [hh, hle i] + +/-- Every finite event loses at most the discarded mass after normalization. -/ +theorem normalized_event_lower {μ l : ι → ℝ} {ε : ℝ} + (hl : ∀ i, 0 ≤ l i) (hle : ∀ i, l i ≤ μ i) (hμ₁ : total μ = 1) + (hε : ε ≤ 1 / 2) (hL : 1 - ε ≤ total l) (E : Finset ι) : + (∑ i ∈ E, μ i) - ε ≤ ∑ i ∈ E, normalized l i := by + have hpos : 0 < total l := by linarith + have hL₁ : total l ≤ 1 := by simpa [hμ₁] using total_mono hle + have herr : (∑ i ∈ E, (μ i - l i)) ≤ 1 - total l := by + calc + _ ≤ ∑ i, (μ i - l i) := + Finset.sum_le_univ_sum_of_nonneg (fun i => sub_nonneg.mpr (hle i)) + _ = _ := by + rw [Finset.sum_sub_distrib] + change total μ - total l = 1 - total l + rw [hμ₁] + have hgain : (∑ i ∈ E, l i) ≤ ∑ i ∈ E, normalized l i := by + apply Finset.sum_le_sum + intro i _ + apply (le_div_iff₀ hpos).mpr + simpa using mul_le_mul_of_nonneg_left hL₁ (hl i) + rw [Finset.sum_sub_distrib] at herr + linarith + +end UniformSparsestCut.FiniteWeights + +end OAI diff --git a/lean/OAI/Combinatorics/SparsestCut/WeightReplacement.lean b/lean/OAI/Combinatorics/SparsestCut/WeightReplacement.lean new file mode 100644 index 0000000000000000000000000000000000000000..2b9a2c9c3a5d79faf2ad44a2ea9f8e2175973dc1 --- /dev/null +++ b/lean/OAI/Combinatorics/SparsestCut/WeightReplacement.lean @@ -0,0 +1,171 @@ +import OAI.Combinatorics.SparsestCut.FiniteWeights + +namespace OAI + +/-! +# Replacing vertices of zero retained demand + +The replacement coupling of Section 7 of OpenAI's +*Constant-factor hardness of uniform sparsest cut* keeps a draw of positive +retained demand and replaces every other draw by an independent retained-demand +draw. Its color-change probability controls the change in Boolean variance. +-/ + +namespace UniformSparsestCut.FiniteWeights + +variable {ι : Type*} [Fintype ι] + +/-- The original law restricted to keys with zero retained demand. -/ +noncomputable def auxiliaryWeights (w retained : ι → ℝ) : ι → ℝ := by + classical + exact fun i => if retained i = 0 then w i else 0 + +/-- The original law restricted to keys with nonzero retained demand. -/ +noncomputable def supportedWeights (w retained : ι → ℝ) : ι → ℝ := by + classical + exact fun i => if retained i = 0 then 0 else w i + +/-- Retain supported draws and replace all others by an independent retained-demand draw. -/ +noncomputable def replacementWeights (w retained : ι → ℝ) : ι → ℝ := + fun i => supportedWeights w retained i + total (auxiliaryWeights w retained) * retained i + +omit [Fintype ι] in +theorem weights_decomposition (w retained : ι → ℝ) (i : ι) : + supportedWeights w retained i + auxiliaryWeights w retained i = w i := by + classical + by_cases hi : retained i = 0 <;> simp [supportedWeights, auxiliaryWeights, hi] + +theorem total_decomposition (w retained : ι → ℝ) : + total (supportedWeights w retained) + total (auxiliaryWeights w retained) = total w := by + rw [← total_add] + congr 1 + funext i + exact weights_decomposition w retained i + +theorem mass_decomposition (w retained : ι → ℝ) (h : ι → Bool) : + mass (supportedWeights w retained) h + mass (auxiliaryWeights w retained) h = mass w h := by + rw [← mass_add] + congr 1 + funext i + exact weights_decomposition w retained i + +omit [Fintype ι] in +theorem auxiliary_nonneg {w : ι → ℝ} (hw : ∀ i, 0 ≤ w i) (retained : ι → ℝ) : + ∀ i, 0 ≤ auxiliaryWeights w retained i := by + classical + intro i + dsimp [auxiliaryWeights] + split + · exact hw i + · exact le_rfl + +omit [Fintype ι] in +theorem supported_nonneg {w : ι → ℝ} (hw : ∀ i, 0 ≤ w i) (retained : ι → ℝ) : + ∀ i, 0 ≤ supportedWeights w retained i := by + classical + intro i + dsimp [supportedWeights] + split + · exact le_rfl + · exact hw i + +omit [Fintype ι] in +theorem auxiliary_le {w : ι → ℝ} (hw : ∀ i, 0 ≤ w i) (retained : ι → ℝ) : + ∀ i, auxiliaryWeights w retained i ≤ w i := by + classical + intro i + dsimp [auxiliaryWeights] + split + · exact le_rfl + · exact hw i + +theorem auxiliary_total_le_one {w : ι → ℝ} (hw : ∀ i, 0 ≤ w i) + (hw₁ : total w = 1) (retained : ι → ℝ) : total (auxiliaryWeights w retained) ≤ 1 := by + simpa [hw₁] using total_mono (auxiliary_le hw retained) + +theorem replacement_nonneg {w retained : ι → ℝ} (hw : ∀ i, 0 ≤ w i) + (hr : ∀ i, 0 ≤ retained i) : ∀ i, 0 ≤ replacementWeights w retained i := by + intro i + exact add_nonneg (supported_nonneg hw retained i) + (mul_nonneg (total_nonneg (auxiliary_nonneg hw retained)) (hr i)) + +theorem replacement_total {w retained : ι → ℝ} (hw₁ : total w = 1) + (hr₁ : total retained = 1) : total (replacementWeights w retained) = 1 := by + change total (fun i => supportedWeights w retained i + + total (auxiliaryWeights w retained) * retained i) = 1 + rw [total_add, total_smul, hr₁, mul_one, + total_decomposition, hw₁] + +theorem replacement_mass (w retained : ι → ℝ) (h : ι → Bool) : + mass (replacementWeights w retained) h = mass (supportedWeights w retained) h + + total (auxiliaryWeights w retained) * mass retained h := by + change mass (fun i => supportedWeights w retained i + + total (auxiliaryWeights w retained) * retained i) h = _ + rw [mass_add, mass_smul] + +/-- Domination of the replacement law before comparison with the original score law. -/ +theorem replacement_le_three {w retained : ι → ℝ} (hw : ∀ i, 0 ≤ w i) + (hw₁ : total w = 1) (hr : ∀ i, 0 ≤ retained i) + (hrep : ∀ i, 0 < retained i → w i ≤ 2 * retained i) : + ∀ i, replacementWeights w retained i ≤ 3 * retained i := by + classical + intro i + have hs : supportedWeights w retained i ≤ 2 * retained i := by + by_cases hi : retained i = 0 + · simp [supportedWeights, hi] + · simpa [supportedWeights, hi] using hrep i (lt_of_le_of_ne (hr i) (Ne.symm hi)) + have ha : total (auxiliaryWeights w retained) * retained i ≤ retained i := by + simpa using mul_le_mul_of_nonneg_right (auxiliary_total_le_one hw hw₁ retained) (hr i) + dsimp [replacementWeights] + linarith only [hs, ha] + +/-- The actual color-change cost of the replacement experiment bounds both signed +changes in the probability of color one. -/ +theorem replacement_mass_change {w retained : ι → ℝ} (hw : ∀ i, 0 ≤ w i) + (hr : ∀ i, 0 ≤ retained i) (hr₁ : total retained = 1) (h : ι → Bool) : + mass w h - mass (replacementWeights w retained) h ≤ + disagreement (auxiliaryWeights w retained) retained h ∧ + mass (replacementWeights w retained) h - mass w h ≤ + disagreement (auxiliaryWeights w retained) retained h := by + rw [replacement_mass, disagreement_eq, hr₁] + have hdec := mass_decomposition w retained h + have haux := auxiliary_nonneg hw retained + have ht : 0 ≤ 1 - mass retained h := sub_nonneg.mpr (hr₁ ▸ mass_le_total hr h) + have hp := mul_nonneg (mass_nonneg haux h) ht + have hq := mul_nonneg (sub_nonneg.mpr (mass_le_total haux h)) (mass_nonneg hr h) + constructor <;> nlinarith only [hdec, hp, hq] + +/-- Variance transfer for the replacement coupling in Section 7 of +*Constant-factor hardness of uniform sparsest cut*. + +Here `w` is the counting law on clusters, `μ` the original score demand law, and +`retained` the normalized retained demand. Zero retained mass is allowed. +The final term is the probability that replacement changes the color, denoted +`L_aux` in the paper. +-/ +theorem variance_transfer {w μ retained : ι → ℝ} + (hw : ∀ i, 0 ≤ w i) (hμ : ∀ i, 0 ≤ μ i) (hr : ∀ i, 0 ≤ retained i) + (hw₁ : total w = 1) (hμ₁ : total μ = 1) (hr₁ : total retained = 1) + (hret : ∀ i, retained i ≤ 2 * μ i) + (hrep : ∀ i, 0 < retained i → w i ≤ 2 * retained i) (h : ι → Bool) : + variance w h ≤ 36 * variance μ h + disagreement (auxiliaryWeights w retained) retained h := by + have hρ := replacement_nonneg hw hr + have hρ₁ := replacement_total hw₁ hr₁ + have hdom : ∀ i, replacementWeights w retained i ≤ 6 * μ i := by + intro i + have hthree := replacement_le_three hw hw₁ hr hrep i + linarith only [hthree, hret i] + have hv : variance (replacementWeights w retained) h ≤ 36 * variance μ h := by + have hv' := variance_domination hρ hμ hρ₁ hμ₁ (by norm_num : (0 : ℝ) ≤ 6) hdom h + norm_num at hv' + exact hv' + have hd := replacement_mass_change hw hr hr₁ h + have hc : variance w h ≤ variance (replacementWeights w retained) h + + disagreement (auxiliaryWeights w retained) retained h := + variance_change (mass_nonneg hw h) (hw₁ ▸ mass_le_total hw h) + (mass_nonneg hρ h) (hρ₁ ▸ mass_le_total hρ h) hd.1 hd.2 + exact hc.trans (add_le_add hv le_rfl) + +end UniformSparsestCut.FiniteWeights + +end OAI diff --git a/lean/OAI/Combinatorics/SparsestCut/WeightReplication.lean b/lean/OAI/Combinatorics/SparsestCut/WeightReplication.lean new file mode 100644 index 0000000000000000000000000000000000000000..2a9f217461dc1e3690122b3186ba71a9d9f88f1a --- /dev/null +++ b/lean/OAI/Combinatorics/SparsestCut/WeightReplication.lean @@ -0,0 +1,133 @@ +/- +Copyright (c) 2026 OpenAI. All rights reserved. +Authors: OpenAI +-/ +import OAI.Combinatorics.SparsestCut.WeightReplacement +import Mathlib.Algebra.BigOperators.Field +import Mathlib.Algebra.Order.Archimedean.Real.Basic +import Mathlib.Algebra.Order.Floor.Semiring + +namespace OAI + +/-! +# Replication of finite weights + +Ceilings produce integer cluster sizes while giving one copy to every key of zero +weight. The resulting counting law satisfies the multiplicative and auxiliary-mass +estimates from Section 7 of OpenAI's *Constant-factor hardness of uniform sparsest cut*. +-/ + +open scoped BigOperators + +namespace UniformSparsestCut.FiniteWeights + +variable {ι : Type*} [Fintype ι] + +noncomputable def copies (K : ℕ) (p : ℝ) : ℕ := if 0 < p then ⌈(K : ℝ) * p⌉₊ else 1 + +noncomputable def population (K : ℕ) (p : ι → ℝ) : ℕ := ∑ i, copies K (p i) + +noncomputable def countingWeights (K : ℕ) (p : ι → ℝ) : ι → ℝ := + fun i => (copies K (p i) : ℝ) / population K p + +omit [Fintype ι] in +theorem copies_zero (K : ℕ) : copies K 0 = 1 := by simp [copies] + +omit [Fintype ι] in +theorem copies_pos (K : ℕ) (hK : 0 < K) (p : ℝ) : 0 < copies K p := by + by_cases hp : 0 < p + · simpa [copies, hp] using Nat.ceil_pos.mpr (mul_pos (Nat.cast_pos.mpr hK) hp) + · simp [copies, hp] + +omit [Fintype ι] in +theorem copies_lower (K : ℕ) {p : ℝ} (hp : 0 ≤ p) : (K : ℝ) * p ≤ copies K p := by + by_cases hpos : 0 < p + · simpa [copies, hpos] using Nat.le_ceil ((K : ℝ) * p) + · have heq : p = 0 := le_antisymm (le_of_not_gt hpos) hp + simp [heq, copies_zero] + +omit [Fintype ι] in +theorem copies_upper (K : ℕ) {p : ℝ} (hp : 0 ≤ p) : (copies K p : ℝ) ≤ (K : ℝ) * p + 1 := by + by_cases hpos : 0 < p + · simpa [copies, hpos] using (Nat.ceil_lt_add_one (mul_nonneg (Nat.cast_nonneg K) hp)).le + · have heq : p = 0 := le_antisymm (le_of_not_gt hpos) hp + simp [heq, copies_zero] + +theorem population_eq_total (K : ℕ) (p : ι → ℝ) : + (population K p : ℝ) = total (fun i => (copies K (p i) : ℝ)) := by + simp [population, total] + +theorem population_bounds (K : ℕ) {p : ι → ℝ} (hp : ∀ i, 0 ≤ p i) (hp₁ : total p = 1) : + (K : ℝ) ≤ population K p ∧ (population K p : ℝ) ≤ K + Fintype.card ι := by + constructor + · calc + (K : ℝ) = total (fun i => (K : ℝ) * p i) := by rw [total_smul, hp₁, mul_one] + _ ≤ total (fun i => (copies K (p i) : ℝ)) := total_mono (fun i => copies_lower K (hp i)) + _ = _ := (population_eq_total K p).symm + · calc + (population K p : ℝ) = total (fun i => (copies K (p i) : ℝ)) := population_eq_total K p + _ ≤ total (fun i => (K : ℝ) * p i + 1) := total_mono (fun i => copies_upper K (hp i)) + _ = _ := by rw [total_add, total_smul, hp₁, mul_one]; simp [total] + +theorem population_pos (K : ℕ) (hK : 0 < K) {p : ι → ℝ} + (hp : ∀ i, 0 ≤ p i) (hp₁ : total p = 1) : (0 : ℝ) < population K p := + lt_of_lt_of_le (Nat.cast_pos.mpr hK) (population_bounds K hp hp₁).1 + +theorem counting_nonneg (K : ℕ) (p : ι → ℝ) : ∀ i, 0 ≤ countingWeights K p i := by + intro i + exact div_nonneg (Nat.cast_nonneg _) (Nat.cast_nonneg _) + +theorem counting_total (K : ℕ) (hK : 0 < K) {p : ι → ℝ} + (hp : ∀ i, 0 ≤ p i) (hp₁ : total p = 1) : total (countingWeights K p) = 1 := by + change (∑ i, (copies K (p i) : ℝ) / population K p) = 1 + rw [← Finset.sum_div] + change total (fun i => (copies K (p i) : ℝ)) / population K p = 1 + rw [← population_eq_total] + exact div_self (ne_of_gt (population_pos K hK hp hp₁)) + +/-- On a key of positive weight, the counting law lies within a factor of two +of the original probability law. -/ +theorem counting_bounds (K : ℕ) (hK : 0 < K) {p : ι → ℝ} + (hp : ∀ i, 0 ≤ p i) (hp₁ : total p = 1) (hKm : Fintype.card ι ≤ K) + (hKp : ∀ i, 0 < p i → 1 ≤ (K : ℝ) * p i) (i : ι) (hpi : 0 < p i) : + p i / 2 ≤ countingWeights K p i ∧ countingWeights K p i ≤ 2 * p i := by + have hN₀ := population_pos K hK hp hp₁ + have hN := population_bounds K hp hp₁ + have hKm' : (Fintype.card ι : ℝ) ≤ K := by exact_mod_cast hKm + have hN₂ : (population K p : ℝ) ≤ 2 * K := by linarith only [hN.2, hKm'] + have hlow := copies_lower K (hp i) + have hupp := copies_upper K (hp i) + have hmin := hKp i hpi + constructor + · apply (le_div_iff₀ hN₀).mpr + have hn := mul_le_mul_of_nonneg_right hN₂ (hp i) + nlinarith only [hn, hlow] + · apply (div_le_iff₀ hN₀).mpr + have hn := mul_le_mul_of_nonneg_right hN.1 (hp i) + nlinarith only [hn, hmin, hupp] + +/-- The total counting mass of auxiliary (zero-retained-demand) vertices. -/ +theorem auxiliary_counting_bound (K : ℕ) (hK : 0 < K) {p : ι → ℝ} {κ : ℝ} + (hp : ∀ i, 0 ≤ p i) (hp₁ : total p = 1) (hκ : 0 < κ) + (hKlarge : 4 * κ * Fintype.card ι ≤ K) : + total (auxiliaryWeights (countingWeights K p) p) ≤ 1 / (4 * κ) := by + classical + have hN₀ := population_pos K hK hp hp₁ + have hN := (population_bounds K hp hp₁).1 + have ha : ∀ i, auxiliaryWeights (countingWeights K p) p i ≤ 1 / population K p := by + intro i + by_cases hi : p i = 0 + · simp [auxiliaryWeights, hi, countingWeights, copies_zero] + · simp [auxiliaryWeights, hi, le_of_lt hN₀] + have hasum : total (auxiliaryWeights (countingWeights K p) p) ≤ + (Fintype.card ι : ℝ) / population K p := by + simpa [total, div_eq_mul_inv] using total_mono ha + have hpop : 4 * κ * Fintype.card ι ≤ (population K p : ℝ) := hKlarge.trans hN + have hbound : (Fintype.card ι : ℝ) / population K p ≤ 1 / (4 * κ) := by + apply (div_le_div_iff₀ hN₀ (mul_pos (by norm_num : (0 : ℝ) < 4) hκ)).mpr + nlinarith only [hpop] + exact hasum.trans hbound + +end UniformSparsestCut.FiniteWeights + +end OAI diff --git a/lean/OAI/Combinatorics/SparsestCut/WeightedMetric.lean b/lean/OAI/Combinatorics/SparsestCut/WeightedMetric.lean new file mode 100644 index 0000000000000000000000000000000000000000..d28c89d8edbb7e84f9cce4162c6f6fd4fc2e5ae2 --- /dev/null +++ b/lean/OAI/Combinatorics/SparsestCut/WeightedMetric.lean @@ -0,0 +1,151 @@ +import OAI.Combinatorics.SparsestCut.VertexMeasure + +namespace OAI + +open scoped BigOperators Topology NNReal RealInnerProductSpace InnerProductSpace Matrix ContDiff ENNReal +open MeasureTheory ProbabilityTheory Set Filter Matrix + +noncomputable section + +namespace UniformSparsestCut.SourceWeighted +open MeasureTheory Set Filter +open scoped BigOperators RealInnerProductSpace +open SourceCharts SourceParameters SourceMetric +noncomputable section +local instance {m N S : ℕ} {u : Fin S → Fin N → EuclideanSpace ℝ (Fin m)} {τ : ℝ} : + MeasurableSpace (RoundedCharts.Vertex u τ) := by unfold RoundedCharts.Vertex; infer_instance +local instance {m N S : ℕ} {u : Fin S → Fin N → EuclideanSpace ℝ (Fin m)} {τ : ℝ} : + MeasurableSingletonClass (RoundedCharts.Vertex u τ) := by unfold RoundedCharts.Vertex; infer_instance + +def D : ℝ := 4*KernelApprox.cstar+C₀ +lemma D_pos : 0 ν.real {v} + have hws : (∑ v, w v)=1 := VertexMeasure.finite_weights ν + have hw : ∀ v, 0≤w v := fun v => measureReal_nonneg + have hL := VertexMeasure.label_measurable (u f) (p d 2000) s v₀ + have hgood : ∀ᵐ x : E ∂μ, x∈RoundedCharts.cube 2 ∧ RoundedCharts.regular (u f s) (p d 2000) x := + VertexMeasure.ae_good (u f s) (hu s) (p d 2000) + have hgoodpair : ∀ᵐ z : E × E ∂μ.prod μ, + (z.1∈RoundedCharts.cube 2 ∧ RoundedCharts.regular (u f s) (p d 2000) z.1) ∧ + (z.2∈RoundedCharts.cube 2 ∧ RoundedCharts.regular (u f s) (p d 2000) z.2) := by + apply (Measure.ae_prod_iff_ae_ae (MeasurableSet.prod + ((VertexMeasure.cube_measurable 2).inter (VertexMeasure.regular_measurable (u f s) (p d 2000))) + ((VertexMeasure.cube_measurable 2).inter (VertexMeasure.regular_measurable (u f s) (p d 2000))))).mpr + filter_upwards [hgood] with x hx + filter_upwards [hgood] with y hy + exact ⟨hx,hy⟩ + obtain ⟨Z,htri,hmac,hloc⟩ := SourceMetric.realization f hm hl + have hdiam := diameter f hm Z hmac + refine ⟨Z,w,hw,hws,htri,hdiam,?_,?_⟩ + · rw [VertexMeasure.pair_average (u f) (p d 2000) s v₀] + have hi : Integrable (fun z : E × E => ‖Z (L z.1)-Z (L z.2)‖^2) (μ.prod μ) := by + apply (integrable_const (D*d)).mono' + · exact ((measurable_of_countable (fun z : V f × V f => ‖Z z.1-Z z.2‖^2)).comp (hL.prodMap hL)).aestronglyMeasurable + · exact ae_of_all _ (fun z => by rw [Real.norm_eq_abs,abs_of_nonneg (sq_nonneg _)]; exact hdiam _ _) + have hb : (∫ z : E × E, KernelApprox.cstar*Real.sqrt d*‖z.1-z.2‖-C₀*p d 8 ∂μ.prod μ)≤ + ∫ z : E × E, ‖Z (L z.1)-Z (L z.2)‖^2 ∂μ.prod μ := by + apply integral_mono_ae ((CubeGeometry.pair_norm_integrable.const_mul _).sub (integrable_const _)) hi + filter_upwards [hgoodpair] with z hz + have he1 : L z.1=vertex f s z.1 hz.1.1 hz.1.2 := by + exact dite_eq_left hz.1 + have he2 : L z.2=vertex f s z.2 hz.2.1 hz.2.2 := by + exact dite_eq_left hz.2 + rw [he1,he2] + have hh := (abs_le.mp (macro_bound f hm Z hmac s s z.1 z.2 hz.1.1 hz.2.1 hz.1.2 hz.2.2)).1 + change KernelApprox.cstar*Real.sqrt (m+1:ℕ)*‖z.1-z.2‖-C₀*p (m+1:ℕ) 8≤_ + linarith only [hh] + rw [integral_sub (CubeGeometry.pair_norm_integrable.const_mul _) (integrable_const _),integral_const_mul,integral_const] at hb + simp at hb + have ha := mul_le_mul_of_nonneg_left (CubeGeometry.pair_norm_average hm0) + (mul_nonneg KernelApprox.cstar_pos.le (Real.sqrt_nonneg d)) + have hs := Real.sq_sqrt (Nat.cast_nonneg (α:=ℝ) d) + change KernelApprox.cstar/3*(d:ℝ)-C₀*p d 8≤_ + have he : KernelApprox.cstar*Real.sqrt d*(Real.sqrt d/3)=KernelApprox.cstar/3*(d:ℝ) := by + calc + _ = KernelApprox.cstar/3*(Real.sqrt d)^2 := by ring + _ = _ := by rw [hs] + rw [he] at ha + linarith only [ha,hb] + · intro A hA F hF + rw [VertexMeasure.pair_average (u f) (p d 2000) s v₀] + have he : (fun z : E × E => ∑ a, |F (L z.1) a-F (L z.2) a|)=ᵐ[μ.prod μ] + (fun z => ∑ a, |ConcreteCells.function (u f) hu0 (p d 2000) F s a z.1- + ConcreteCells.function (u f) hu0 (p d 2000) F s a z.2|) := by + filter_upwards [hgoodpair] with z hz + apply Finset.sum_congr rfl + intro a ha + rw [ConcreteCells.function_eq (u f) hu0 hτ (fun s i => (u_norm f hm0 s i).2) F s z.1 hz.1.1 hz.1.2 a, + ConcreteCells.function_eq (u f) hu0 hτ (fun s i => (u_norm f hm0 s i).2) F s z.2 hz.2.1 hz.2.2 a] + simp [L, VertexMeasure.label, hz.1, hz.2] + rw [integral_congr_ae he] + exact SourceContraction.integral_bound f hm hl hH Z hmac hloc F hF s +end +end UniformSparsestCut.SourceWeighted + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SphericalRamsey.lean b/lean/OAI/Combinatorics/SphericalRamsey.lean new file mode 100644 index 0000000000000000000000000000000000000000..0916863d23318a413bb9490c441759338fcda7a9 --- /dev/null +++ b/lean/OAI/Combinatorics/SphericalRamsey.lean @@ -0,0 +1 @@ +import OAI.Combinatorics.SphericalRamsey.Main diff --git a/lean/OAI/Combinatorics/SphericalRamsey/AffineCopy.lean b/lean/OAI/Combinatorics/SphericalRamsey/AffineCopy.lean new file mode 100644 index 0000000000000000000000000000000000000000..3508beaeb86062cadf48709479d78715e494695a --- /dev/null +++ b/lean/OAI/Combinatorics/SphericalRamsey/AffineCopy.lean @@ -0,0 +1,81 @@ +import OAI.Combinatorics.SphericalRamsey.AffineCopyCore + +namespace OAI + +noncomputable section +open scoped RealInnerProductSpace BigOperators +namespace GrahamSpherical + +lemma dist_vertex_sq (i j : Label) : + dist (vertex i) (vertex j) ^ 2 = + (coordinates i 0-coordinates j 0)^2 + (coordinates i 1-coordinates j 1)^2 := by + rw [dist_eq_norm, EuclideanSpace.real_norm_sq_eq] + simp [vertex, Fin.sum_univ_two] + +lemma inner_sub_self_eq_dist_sq {n : ℕ} (x y : Point n) : + (inner ℝ (x-y) (x-y)) = dist x y ^ 2 := by + rw [real_inner_self_eq_norm_sq, dist_eq_norm] + +/-- Every literal distance-preserving placement of the twelve points has one +common affine expression with an orthonormal pair. No affine hypothesis or +ambient-dimension lower bound is assumed. -/ +theorem affine_copy {n : ℕ} (y : Label → Point n) + (hy : ∀ i j, dist (y i) (y j) = dist (vertex i) (vertex j)) : + ∃ c A B : Point n, (inner ℝ (A) (A)) = 1 ∧ (inner ℝ (B) (B)) = 1 ∧ + (inner ℝ (A) (B)) = 0 ∧ ∀ i, y i = c + coordinates i 0 • A + coordinates i 1 • B := by + let p : Label := (2,0) + let m : Label := (2,1) + let q : Label := (2,2) + have hp0 : coordinates p 0 = 1 := by norm_num [p, coordinates, squareCoordinate, Fin.ext_iff] + have hp1 : coordinates p 1 = 0 := by norm_num [p, coordinates, squareCoordinate, Fin.ext_iff] + have hm0 : coordinates m 0 = -1 := by norm_num [m, coordinates, squareCoordinate, Fin.ext_iff] + have hm1 : coordinates m 1 = 0 := by norm_num [m, coordinates, squareCoordinate, Fin.ext_iff] + have hq0 : coordinates q 0 = 0 := by norm_num [q, coordinates, squareCoordinate, Fin.ext_iff] + have hq1 : coordinates q 1 = 1 := by norm_num [q, coordinates, squareCoordinate, Fin.ext_iff] + have hd (i j : Label) : (inner ℝ (y i-y j) (y i-y j)) = + (coordinates i 0-coordinates j 0)^2 + (coordinates i 1-coordinates j 1)^2 := by + rw [inner_sub_self_eq_dist_sq, hy, dist_vertex_sq] + have hdd : (inner ℝ (y m-y p) (y m-y p)) = 4 := by + rw [hd, hm0, hm1, hp0, hp1]; norm_num + have hee : (inner ℝ (y q-y p) (y q-y p)) = 2 := by + rw [hd, hq0, hq1, hp0, hp1]; norm_num + have hde : (inner ℝ (y m-y p) (y q-y p)) = 2 := by + have h := hd m q + rw [hm0, hm1, hq0, hq1] at h + have he : (y m-y p)-(y q-y p) = y m-y q := by abel + have hh := inner_sub_self n (y m-y p) (y q-y p) + rw [he, h, hdd, hee] at hh + nlinarith + apply affine_frame_of_anchor_gram y (fun i => coordinates i 0) + (fun i => coordinates i 1) (y p) (y m-y p) (y q-y p) hdd hee hde + · intro i + simpa only [hp0, hp1, sub_zero] using hd i p + · intro i + have h := hd i m + rw [hm0, hm1, sub_zero] at h + have hz := hd i p + rw [hp0, hp1, sub_zero] at hz + have he : (y i-y p)-(y m-y p) = y i-y m := by abel + have hh := inner_sub_self n (y i-y p) (y m-y p) + rw [he, h, hz, hdd] at hh + nlinarith + · intro i + have h := hd i q + rw [hq0, hq1, sub_zero] at h + have hz := hd i p + rw [hp0, hp1, sub_zero] at hz + have he : (y i-y p)-(y q-y p) = y i-y q := by abel + have hh := inner_sub_self n (y i-y p) (y q-y p) + rw [he, h, hz, hee] at hh + nlinarith + +/-- Coordinate-square normalization for the derivative-energy calculation. -/ +lemma sum_sq_eq_inner {n : ℕ} (A : Point n) : + (∑ j : Fin n, A j ^ 2) = (inner ℝ (A) (A)) := by + rw [real_inner_self_eq_norm_sq, EuclideanSpace.real_norm_sq_eq] + +end GrahamSpherical + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SphericalRamsey/AffineCopyCore.lean b/lean/OAI/Combinatorics/SphericalRamsey/AffineCopyCore.lean new file mode 100644 index 0000000000000000000000000000000000000000..795aeb6fd99baf78784a0b0f181f7fbab375ad45 --- /dev/null +++ b/lean/OAI/Combinatorics/SphericalRamsey/AffineCopyCore.lean @@ -0,0 +1,80 @@ +import OAI.Combinatorics.SphericalRamsey.Model +import Mathlib.Tactic.Linarith +import Mathlib.Tactic.Module + +namespace OAI + +noncomputable section +open scoped RealInnerProductSpace +namespace GrahamSpherical + +/-- Polarization in the actual real Euclidean inner product. -/ +lemma inner_sub_self (n : ℕ) (x y : Point n) : + (inner ℝ (x-y) (x-y)) = (inner ℝ (x) (x)) - 2*(inner ℝ (x) (y)) + (inner ℝ (y) (y)) := by + rw [inner_sub_left, inner_sub_right, inner_sub_right, real_inner_comm y x] + ring + +/-- An orthonormal pair reconstructs a vector once its two coordinates account +for its full squared norm. No dimension assumption is imposed on the codomain. -/ +lemma vector_eq_of_orthonormal_coordinates {n : ℕ} (A B z : Point n) (a b : ℝ) + (hAA : (inner ℝ (A) (A)) = 1) (hBB : (inner ℝ (B) (B)) = 1) (hAB : (inner ℝ (A) (B)) = 0) + (hzA : (inner ℝ (z) (A)) = a) (hzB : (inner ℝ (z) (B)) = b) + (hzz : (inner ℝ (z) (z)) = a^2+b^2) : z = a • A + b • B := by + have hBA : (inner ℝ (B) (A)) = 0 := (real_inner_comm A B).trans hAB + have hAz : (inner ℝ (A) (z)) = a := (real_inner_comm z A).trans hzA + have hBz : (inner ℝ (B) (z)) = b := (real_inner_comm z B).trans hzB + apply sub_eq_zero.mp + apply (inner_self_eq_zero (𝕜 := ℝ)).mp + simp only [inner_sub_left, inner_sub_right, inner_add_left, inner_add_right, + real_inner_smul_left, real_inner_smul_right, hAA, hBB, hAB, hBA, + hzA, hzB, hAz, hBz, hzz] + ring + +/-- The three-anchor Gram data determine a common affine Euclidean frame. -/ +lemma affine_frame_of_anchor_gram {ι : Type*} {n : ℕ} + (y : ι → Point n) (a b : ι → ℝ) (p : Point n) (d e : Point n) + (hdd : (inner ℝ (d) (d)) = 4) (hee : (inner ℝ (e) (e)) = 2) (hde : (inner ℝ (d) (e)) = 2) + (hzz : ∀ i, (inner ℝ (y i-p) (y i-p)) = (a i-1)^2+(b i)^2) + (hzd : ∀ i, (inner ℝ (y i-p) (d)) = 2*(1-a i)) + (hze : ∀ i, (inner ℝ (y i-p) (e)) = 1-a i+b i) : + ∃ c A B : Point n, (inner ℝ (A) (A)) = 1 ∧ (inner ℝ (B) (B)) = 1 ∧ + (inner ℝ (A) (B)) = 0 ∧ ∀ i, y i = c + a i • A + b i • B := by + let A : Point n := (-1/2 : ℝ) • d + let B : Point n := e - (1/2 : ℝ) • d + let c : Point n := p + (1/2 : ℝ) • d + have hed : (inner ℝ (e) (d)) = 2 := (real_inner_comm d e).trans hde + have hAA : (inner ℝ (A) (A)) = 1 := by + dsimp [A] + simp only [real_inner_smul_left, real_inner_smul_right, hdd] + norm_num + have hBB : (inner ℝ (B) (B)) = 1 := by + dsimp [B] + simp only [inner_sub_left, inner_sub_right, real_inner_smul_left, + real_inner_smul_right, hdd, hee, hde, hed] + norm_num + have hAB : (inner ℝ (A) (B)) = 0 := by + dsimp [A,B] + simp only [inner_sub_right, real_inner_smul_left, real_inner_smul_right, hdd, hde] + norm_num + refine ⟨c,A,B,hAA,hBB,hAB,?_⟩ + intro i + have hzA : (inner ℝ (y i-p) (A)) = a i-1 := by + dsimp [A] + rw [real_inner_smul_right, hzd] + ring + have hzB : (inner ℝ (y i-p) (B)) = b i := by + dsimp [B] + rw [inner_sub_right, real_inner_smul_right, hze, hzd] + ring + have hv := vector_eq_of_orthonormal_coordinates A B (y i-p) (a i-1) (b i) + hAA hBB hAB hzA hzB (hzz i) + calc + y i = p + (y i-p) := by abel + _ = p + ((a i-1) • A + b i • B) := by rw [hv] + _ = c + a i • A + b i • B := by dsimp [c,A]; module + +end GrahamSpherical + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SphericalRamsey/AlgebraicExtension.lean b/lean/OAI/Combinatorics/SphericalRamsey/AlgebraicExtension.lean new file mode 100644 index 0000000000000000000000000000000000000000..6566440071e7f0d80c39c9697c1ce67e6db8defc --- /dev/null +++ b/lean/OAI/Combinatorics/SphericalRamsey/AlgebraicExtension.lean @@ -0,0 +1,90 @@ +import Mathlib.FieldTheory.Differential.Basic + +namespace OAI + +namespace GrahamSpherical.AlgebraicExtension + +open IntermediateField +open scoped Differential + +variable {F K : Type*} [Field F] [Field K] [CharZero F] + [Algebra F K] [Algebra.IsAlgebraic F K] [Differential F] + +local instance finiteSimple (x : K) : FiniteDimensional F F⟮x⟯ := + IntermediateField.adjoin.finiteDimensional + (Algebra.IsIntegral.isIntegral (R := F) x) + +/-- The value forced by the native derivation on a finite simple subextension. -/ +noncomputable def value (x : K) : K := + ((Differential.deriv (⟨x, mem_adjoin_simple_self F x⟩ : F⟮x⟯) : F⟮x⟯) : K) + +/-- All finite subextensions compute the same derivative of a given element. -/ +theorem value_eq (L : IntermediateField F K) [FiniteDimensional F L] + (x : K) (hx : x ∈ L) : + value (F := F) x = ((Differential.deriv (⟨x, hx⟩ : L) : L) : K) := by + have hle : F⟮x⟯ ≤ L := adjoin_le_iff.mpr (Set.singleton_subset_iff.mpr hx) + have h := Differential.algHom_deriv' (inclusion hle) (inclusion_injective hle) + (⟨x, mem_adjoin_simple_self F x⟩ : F⟮x⟯) + exact congrArg (fun z : L => (z : K)) h + +theorem value_zero : value (F := F) (0 : K) = 0 := by + rw [value_eq (F⟮(0 : K)⟯) 0 (zero_mem _)] + change ((Differential.deriv (0 : F⟮(0 : K)⟯) : F⟮(0 : K)⟯) : K) = 0 + simp + +theorem value_add (x y : K) : + value (F := F) (x + y) = value (F := F) x + value (F := F) y := by + let L : IntermediateField F K := F⟮x⟯ ⊔ F⟮y⟯ + have hx : x ∈ L := (show F⟮x⟯ ≤ L from le_sup_left) (mem_adjoin_simple_self F x) + have hy : y ∈ L := (show F⟮y⟯ ≤ L from le_sup_right) (mem_adjoin_simple_self F y) + rw [value_eq L (x + y) (L.add_mem hx hy), value_eq L x hx, value_eq L y hy] + exact congrArg (fun z : L => (z : K)) + (map_add Differential.deriv (⟨x, hx⟩ : L) (⟨y, hy⟩ : L)) + +theorem value_mul (x y : K) : + value (F := F) (x * y) = x * value (F := F) y + y * value (F := F) x := by + let L : IntermediateField F K := F⟮x⟯ ⊔ F⟮y⟯ + have hx : x ∈ L := (show F⟮x⟯ ≤ L from le_sup_left) (mem_adjoin_simple_self F x) + have hy : y ∈ L := (show F⟮y⟯ ≤ L from le_sup_right) (mem_adjoin_simple_self F y) + rw [value_eq L (x * y) (L.mul_mem hx hy), value_eq L x hx, value_eq L y hy] + have hm : (⟨x, hx⟩ : L) * (⟨y, hy⟩ : L) = ⟨x * y, L.mul_mem hx hy⟩ := by + apply Subtype.ext + exact L.coe_mul _ _ + have hd := Derivation.leibniz Differential.deriv (⟨x, hx⟩ : L) (⟨y, hy⟩ : L) + rw [hm] at hd + simpa only [smul_eq_mul, IntermediateField.coe_add, IntermediateField.coe_mul, + Subtype.coe_mk] using congrArg (fun z : L => (z : K)) hd + +/-- Extension to an arbitrary algebraic field extension in characteristic zero. -/ +@[instance_reducible] +noncomputable def differentialAlgebraic : Differential K where + deriv := Derivation.mk' + (AddMonoidHom.toIntLinearMap + { toFun := value (F := F), map_zero' := value_zero, map_add' := value_add }) + (by intro x y; exact value_mul x y) + +theorem value_algebraMap (x : F) : + value (F := F) (algebraMap F K x) = algebraMap F K (Differential.deriv x) := by + let L : IntermediateField F K := F⟮algebraMap F K x⟯ + rw [value_eq L _ (L.algebraMap_mem x)] + change ((Differential.deriv (algebraMap F L x) : L) : K) = _ + rw [deriv_algebraMap] + rfl + +theorem differentialAlgebraAlgebraic : + let := differentialAlgebraic (F := F) (K := K) + DifferentialAlgebra F K := by + let := differentialAlgebraic (F := F) (K := K) + exact ⟨value_algebraMap⟩ + +omit [Differential F] in +/-- Explicit derivation interface, avoiding any preexisting derivative on the target. -/ +theorem exists_extension (D : Derivation ℤ F F) : + ∃ E : Derivation ℤ K K, + ∀ x : F, E (algebraMap F K x) = algebraMap F K (D x) := by + let : Differential F := ⟨D⟩ + exact ⟨(differentialAlgebraic (F := F) (K := K)).deriv, value_algebraMap⟩ + +end GrahamSpherical.AlgebraicExtension + +end OAI diff --git a/lean/OAI/Combinatorics/SphericalRamsey/BasisDerivation.lean b/lean/OAI/Combinatorics/SphericalRamsey/BasisDerivation.lean new file mode 100644 index 0000000000000000000000000000000000000000..4b9a7878e08466cb8368b91f9f232d7c5be7294a --- /dev/null +++ b/lean/OAI/Combinatorics/SphericalRamsey/BasisDerivation.lean @@ -0,0 +1,118 @@ +import Mathlib.Basic.Real.Basic +import Mathlib.Algebra.Algebra.Rat +import Mathlib.Algebra.TrivSqZeroExt.Basic +import Mathlib.RingTheory.AlgebraicIndependent.Adjoin +import Mathlib.RingTheory.Derivation.Basic +import Mathlib.RingTheory.Localization.Basic + +namespace OAI + +noncomputable section + +namespace GrahamSpherical + +private abbrev Poly (ι : Type*) := MvPolynomial ι ℚ +private abbrev RatFun (ι : Type*) := FractionRing (Poly ι) + +private def tangentCoefficient {ι : Type*} : + ℚ →+* TrivSqZeroExt (RatFun ι) (RatFun ι) := + (TrivSqZeroExt.inlHom _ _).comp (algebraMap ℚ (RatFun ι)) + +private def tangentVariable {ι : Type*} (i j : ι) : + TrivSqZeroExt (RatFun ι) (RatFun ι) := by + classical + exact (algebraMap (Poly ι) (RatFun ι) (MvPolynomial.X j), + if j = i then 1 else 0) + +private def polynomialTangent {ι : Type*} (i : ι) : + Poly ι →+* TrivSqZeroExt (RatFun ι) (RatFun ι) := + MvPolynomial.eval₂Hom tangentCoefficient (tangentVariable i) + +private theorem polynomialTangent_X {ι : Type*} (i j : ι) : + polynomialTangent i (MvPolynomial.X j) = tangentVariable i j := + MvPolynomial.eval₂Hom_X' tangentCoefficient (tangentVariable i) j + +private theorem polynomialTangent_fst {ι : Type*} (i : ι) (p : Poly ι) : + (polynomialTangent i p).fst = algebraMap (Poly ι) (RatFun ι) p := by + classical + have h : (TrivSqZeroExt.fstHom (RatFun ι) (RatFun ι) (RatFun ι)).toRingHom.comp + (polynomialTangent i) = algebraMap (Poly ι) (RatFun ι) := by + ext j + · simp [polynomialTangent, tangentCoefficient, IsScalarTower.algebraMap_eq ℚ (Poly ι) (RatFun ι)] + · exact congrArg TrivSqZeroExt.fst (polynomialTangent_X i j) + exact RingHom.congr_fun h p + +private theorem polynomialTangent_units {ι : Type*} (i : ι) + (y : nonZeroDivisors (Poly ι)) : IsUnit (polynomialTangent i y) := by + rw [TrivSqZeroExt.isUnit_iff_isUnit_fst, polynomialTangent_fst] + exact IsFractionRing.isUnit_map_of_injective (IsFractionRing.injective (Poly ι) (RatFun ι)) y + +private def fractionTangent {ι : Type*} (i : ι) : + RatFun ι →+* TrivSqZeroExt (RatFun ι) (RatFun ι) := + IsLocalization.lift (polynomialTangent_units i) + +private theorem fractionTangent_fst {ι : Type*} (i : ι) (x : RatFun ι) : + (fractionTangent i x).fst = x := by + have h : (TrivSqZeroExt.fstHom (RatFun ι) (RatFun ι) (RatFun ι)).toRingHom.comp + (fractionTangent i) = RingHom.id (RatFun ι) := by + apply IsLocalization.ringHom_ext (nonZeroDivisors (Poly ι)) + apply RingHom.ext + intro p + change (fractionTangent i (algebraMap (Poly ι) (RatFun ι) p)).fst = + algebraMap (Poly ι) (RatFun ι) p + rw [fractionTangent, IsLocalization.lift_eq, polynomialTangent_fst] + exact RingHom.congr_fun h x + +private def fractionDerivation {ι : Type*} (i : ι) : + Derivation ℤ (RatFun ι) (RatFun ι) where + toFun x := (fractionTangent i x).snd + map_add' x y := congrArg TrivSqZeroExt.snd (map_add (fractionTangent i) x y) + map_smul' n x := by + simp only [RingHom.id_apply, OreLocalization.zsmul_eq_zsmul] + exact congrArg TrivSqZeroExt.snd (map_zsmul (fractionTangent i) n x) + map_one_eq_zero' := congrArg TrivSqZeroExt.snd (map_one (fractionTangent i)) + leibniz' x y := by + change (fractionTangent i (x * y)).snd = + x * (fractionTangent i y).snd + y * (fractionTangent i x).snd + rw [map_mul, TrivSqZeroExt.snd_mul, fractionTangent_fst, fractionTangent_fst] + change x * (fractionTangent i y).snd + (fractionTangent i x).snd * y = + x * (fractionTangent i y).snd + y * (fractionTangent i x).snd + rw [mul_comm (fractionTangent i x).snd y] + +private theorem fractionDerivation_X {ι : Type*} (i : ι) : + fractionDerivation i (algebraMap (Poly ι) (RatFun ι) (MvPolynomial.X i)) = 1 := by + classical + change (fractionTangent i (algebraMap (Poly ι) (RatFun ι) (MvPolynomial.X i))).snd = 1 + rw [fractionTangent, IsLocalization.lift_eq] + have h := congrArg TrivSqZeroExt.snd (polynomialTangent_X i i) + simpa [tangentVariable] using h + +/-- A selected algebraically independent coordinate admits a unit-valued derivation +on the field generated by all coordinates. -/ +theorem exists_derivation_adjoin_coordinate {ι : Type*} (b : ι → ℝ) + (hb : AlgebraicIndependent ℚ b) (i : ι) : + ∃ D : Derivation ℤ (IntermediateField.adjoin ℚ (Set.range b)) + (IntermediateField.adjoin ℚ (Set.range b)), + D ⟨b i, IntermediateField.subset_adjoin ℚ (Set.range b) ⟨i, rfl⟩⟩ = 1 := by + let e := hb.aevalEquivField + let D : Derivation ℤ (IntermediateField.adjoin ℚ (Set.range b)) + (IntermediateField.adjoin ℚ (Set.range b)) := + { toFun := fun x => e (fractionDerivation i (e.symm x)) + map_add' := fun x y => by simp + map_smul' := fun n x => by simp + map_one_eq_zero' := by simp + leibniz' := fun x y => by simp [Derivation.leibniz, smul_eq_mul] } + refine ⟨D, ?_⟩ + have hx : e (algebraMap (Poly ι) (RatFun ι) (MvPolynomial.X i)) = + ⟨b i, IntermediateField.subset_adjoin ℚ (Set.range b) ⟨i, rfl⟩⟩ := by + apply Subtype.ext + simp [e, hb.aevalEquivField_algebraMap_apply_coe] + rw [← hx] + change e (fractionDerivation i (e.symm (e _))) = 1 + rw [e.symm_apply_apply, fractionDerivation_X, map_one] + +end GrahamSpherical + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SphericalRamsey/Coloring.lean b/lean/OAI/Combinatorics/SphericalRamsey/Coloring.lean new file mode 100644 index 0000000000000000000000000000000000000000..7b775a6dbdb27f5adb91696c3d16fff2f50768f8 --- /dev/null +++ b/lean/OAI/Combinatorics/SphericalRamsey/Coloring.lean @@ -0,0 +1,81 @@ +import Mathlib.Algebra.Order.Floor.Ring +import Mathlib.Algebra.Order.Archimedean.Real.Basic +import Mathlib.Algebra.BigOperators.Fin +import Mathlib.Data.Fintype.BigOperators +import Mathlib.Tactic.Linarith +import Mathlib.Tactic.NormNum +import Mathlib.Tactic.Push +import Mathlib.Tactic.Ring +import Lean.Elab.Tactic.Omega + +namespace OAI + +noncomputable section +open scoped BigOperators +namespace GrahamSpherical + +/-- The actual fifty-residue rounding obstruction. No nonnegativity or +geometric surrogate is required of the twelve input energies. -/ +theorem rounding_obstruction (e : (Fin 3 × Fin 4) → ℝ) + (henergy : ∑ i, (if i.1 = 2 then (-2 : ℝ) else 1) * e i = 8) : + ∃ i j, (Int.floor (3 * e i)) % 50 ≠ (Int.floor (3 * e j)) % 50 := by + classical + by_contra h + push Not at h + let f : (Fin 3 × Fin 4) → ℤ := fun i => Int.floor (3 * e i) + have hr (i : Fin 3 × Fin 4) : f i % 50 = f (0, 0) % 50 := h i (0, 0) + have heq (i : Fin 3 × Fin 4) : f i = 50 * (f i / 50) + f (0, 0) % 50 := by + have hi := Int.emod_add_mul_ediv (f i) 50 + rw [hr i] at hi + omega + let S : ℤ := f (0, 0) + f (0, 1) + f (0, 2) + f (0, 3) + f (1, 0) + f (1, 1) + f (1, 2) + f (1, 3) - 2 * (f (2, 0) + f (2, 1) + f (2, 2) + f (2, 3)) + let q : (Fin 3 × Fin 4) → ℤ := fun i => f i / 50 + let Q : ℤ := q (0, 0) + q (0, 1) + q (0, 2) + q (0, 3) + q (1, 0) + q (1, 1) + q (1, 2) + q (1, 3) - 2 * (q (2, 0) + q (2, 1) + q (2, 2) + q (2, 3)) + have hdiv : S = 50 * Q := by + conv_lhs => + dsimp [S] + rw [heq (0, 0), heq (0, 1), heq (0, 2), heq (0, 3), heq (1, 0), heq (1, 1), heq (1, 2), heq (1, 3), heq (2, 0), heq (2, 1), heq (2, 2), heq (2, 3)] + dsimp [Q, q] + ring + norm_num [Fintype.sum_prod_type, Fin.sum_univ_succ, Fin.ext_iff] at henergy + have hl00 : (f (0, 0) : ℝ) ≤ 3 * e (0, 0) := Int.floor_le _ + have hu00 : 3 * e (0, 0) < (f (0, 0) : ℝ) + 1 := Int.lt_floor_add_one _ + have hl01 : (f (0, 1) : ℝ) ≤ 3 * e (0, 1) := Int.floor_le _ + have hu01 : 3 * e (0, 1) < (f (0, 1) : ℝ) + 1 := Int.lt_floor_add_one _ + have hl02 : (f (0, 2) : ℝ) ≤ 3 * e (0, 2) := Int.floor_le _ + have hu02 : 3 * e (0, 2) < (f (0, 2) : ℝ) + 1 := Int.lt_floor_add_one _ + have hl03 : (f (0, 3) : ℝ) ≤ 3 * e (0, 3) := Int.floor_le _ + have hu03 : 3 * e (0, 3) < (f (0, 3) : ℝ) + 1 := Int.lt_floor_add_one _ + have hl10 : (f (1, 0) : ℝ) ≤ 3 * e (1, 0) := Int.floor_le _ + have hu10 : 3 * e (1, 0) < (f (1, 0) : ℝ) + 1 := Int.lt_floor_add_one _ + have hl11 : (f (1, 1) : ℝ) ≤ 3 * e (1, 1) := Int.floor_le _ + have hu11 : 3 * e (1, 1) < (f (1, 1) : ℝ) + 1 := Int.lt_floor_add_one _ + have hl12 : (f (1, 2) : ℝ) ≤ 3 * e (1, 2) := Int.floor_le _ + have hu12 : 3 * e (1, 2) < (f (1, 2) : ℝ) + 1 := Int.lt_floor_add_one _ + have hl13 : (f (1, 3) : ℝ) ≤ 3 * e (1, 3) := Int.floor_le _ + have hu13 : 3 * e (1, 3) < (f (1, 3) : ℝ) + 1 := Int.lt_floor_add_one _ + have hl20 : (f (2, 0) : ℝ) ≤ 3 * e (2, 0) := Int.floor_le _ + have hu20 : 3 * e (2, 0) < (f (2, 0) : ℝ) + 1 := Int.lt_floor_add_one _ + have hl21 : (f (2, 1) : ℝ) ≤ 3 * e (2, 1) := Int.floor_le _ + have hu21 : 3 * e (2, 1) < (f (2, 1) : ℝ) + 1 := Int.lt_floor_add_one _ + have hl22 : (f (2, 2) : ℝ) ≤ 3 * e (2, 2) := Int.floor_le _ + have hu22 : 3 * e (2, 2) < (f (2, 2) : ℝ) + 1 := Int.lt_floor_add_one _ + have hl23 : (f (2, 3) : ℝ) ≤ 3 * e (2, 3) := Int.floor_le _ + have hu23 : 3 * e (2, 3) < (f (2, 3) : ℝ) + 1 := Int.lt_floor_add_one _ + have hSl : (16 : ℝ) < (S : ℝ) := by + dsimp [S] + push_cast + linarith + have hSu : (S : ℝ) < (32 : ℝ) := by + dsimp [S] + push_cast + linarith + have hSl' : (16 : ℤ) < S := by exact_mod_cast hSl + have hSu' : S < (32 : ℤ) := by exact_mod_cast hSu + omega + +end GrahamSpherical + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SphericalRamsey/CopyInvariant.lean b/lean/OAI/Combinatorics/SphericalRamsey/CopyInvariant.lean new file mode 100644 index 0000000000000000000000000000000000000000..08f22b1b5b38177c79bab0dbae03bf54f1707db5 --- /dev/null +++ b/lean/OAI/Combinatorics/SphericalRamsey/CopyInvariant.lean @@ -0,0 +1,46 @@ +import OAI.Combinatorics.SphericalRamsey.MonochromaticObstruction +import OAI.Combinatorics.SphericalRamsey.AffineCopy + +namespace OAI + +noncomputable section +open scoped BigOperators RealInnerProductSpace +namespace GrahamSpherical + +/-- All distance-preserving copies, with no affine-form or dimension premise. -/ +theorem weighted_copy_derivation_energy {n : ℕ} + (D : Derivation ℤ ℝ ℝ) + (hD : D parameter = (1 + parameter ^ 2) / 2) + (f : witness → Point n) (hf : Isometry f) : + ∑ i : Label, (weight i : ℝ) * + derivationEnergy D (f ⟨vertex i, ⟨i, rfl⟩⟩) = 8 := by + let y : Label → Point n := fun i => f ⟨vertex i, ⟨i, rfl⟩⟩ + have hy : ∀ i j, dist (y i) (y j) = dist (vertex i) (vertex j) := by + intro i j + exact hf.dist_eq ⟨vertex i, ⟨i, rfl⟩⟩ ⟨vertex j, ⟨j, rfl⟩⟩ + obtain ⟨z, A, B, hA, hB, _hAB, hform⟩ := affine_copy y hy + have hAs : ∑ j : Fin n, A j ^ 2 = 1 := (sum_sq_eq_inner A).trans hA + have hBs : ∑ j : Fin n, B j ^ 2 = 1 := (sum_sq_eq_inner B).trans hB + have hpoint (i : Label) (j : Fin n) : + y i j = z j + coordinates i 0 * A j + coordinates i 1 * B j := by + have h := congrArg (fun x : Point n => x j) (hform i) + simpa using h + have henergy (i : Label) : derivationEnergy D (y i) = + ∑ j : Fin n, (D (z j + coordinates i 0 * A j + coordinates i 1 * B j)) ^ 2 := by + unfold derivationEnergy + simp_rw [hpoint] + change (∑ i : Label, (weight i : ℝ) * derivationEnergy D (y i)) = 8 + simp_rw [henergy] + exact weighted_affine_derivation_energy D hD z A B hAs hBs + +theorem derivationColor_avoids {n : ℕ} + (D : Derivation ℤ ℝ ℝ) + (hD : D parameter = (1 + parameter ^ 2) / 2) : + AvoidsCopy witness (energyColor (derivationEnergy (n := n) D)) := + energyColor_avoids_of_invariant _ (weighted_copy_derivation_energy D hD) + +end GrahamSpherical + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SphericalRamsey/DerivationCoordinates.lean b/lean/OAI/Combinatorics/SphericalRamsey/DerivationCoordinates.lean new file mode 100644 index 0000000000000000000000000000000000000000..9051a74fa51f5b31bcff2075abfb10a42af81c20 --- /dev/null +++ b/lean/OAI/Combinatorics/SphericalRamsey/DerivationCoordinates.lean @@ -0,0 +1,34 @@ +import Mathlib.RingTheory.Derivation.Basic +import Mathlib.Basic.Real.Basic +import Mathlib.Tactic.FieldSimp +import Mathlib.Tactic.Positivity +import Mathlib.Tactic.Ring + +namespace OAI + +namespace GrahamSpherical + +/-- Only the algebraic quotient rule is used; no continuity or differentiation +of the infinite series defining the parameter is involved. -/ +theorem derivation_rotation_coordinates (D : Derivation ℤ ℝ ℝ) (t : ℝ) + (ht : D t = (1 + t ^ 2) / 2) : + D ((1 - t ^ 2) / (1 + t ^ 2)) = -(2 * t / (1 + t ^ 2)) ∧ + D (2 * t / (1 + t ^ 2)) = (1 - t ^ 2) / (1 + t ^ 2) := by + have hden : (1 + t ^ 2 : ℝ) ≠ 0 := by positivity + have htwo : D (2 : ℝ) = 0 := D.map_natCast 2 + have hpow : D (t ^ 2) = 2 * t * D t := by + simp [Derivation.leibniz_pow, smul_eq_mul, two_smul] + ring + constructor + · rw [D.leibniz_div, map_sub, map_add, D.map_one_eq_zero, hpow, ht] + simp only [smul_eq_mul] + field_simp [hden] + ring + · rw [D.leibniz_div, D.leibniz, map_add, D.map_one_eq_zero, htwo, hpow, ht] + simp only [smul_eq_mul] + field_simp [hden] + ring + +end GrahamSpherical + +end OAI diff --git a/lean/OAI/Combinatorics/SphericalRamsey/EnergyIdentity.lean b/lean/OAI/Combinatorics/SphericalRamsey/EnergyIdentity.lean new file mode 100644 index 0000000000000000000000000000000000000000..f96b3b124ae83481d5b72b23b572c6309ef7ec80 --- /dev/null +++ b/lean/OAI/Combinatorics/SphericalRamsey/EnergyIdentity.lean @@ -0,0 +1,65 @@ +import OAI.Combinatorics.SphericalRamsey.Model +import OAI.Combinatorics.SphericalRamsey.DerivationCoordinates +import Mathlib.Tactic.FinCases +import Mathlib.Tactic.Ring + +namespace OAI + +noncomputable section +open scoped BigOperators +namespace GrahamSpherical + +theorem rotation_norm_sq : u ^ 2 + v ^ 2 = 1 := by + have hden : (1 + parameter ^ 2 : ℝ) ≠ 0 := by positivity + unfold u v + field_simp [hden] + ring + +theorem derivation_u_v (D : Derivation ℤ ℝ ℝ) + (hD : D parameter = (1 + parameter ^ 2) / 2) : + D u = -v ∧ D v = u := + derivation_rotation_coordinates D parameter hD + +/-- The translation and orientation-derivative coefficients are arbitrary. -/ +theorem weighted_coordinate_square (D : Derivation ℤ ℝ ℝ) + (hD : D parameter = (1 + parameter ^ 2) / 2) + (p a b c d : ℝ) : + ∑ i : Label, (weight i : ℝ) * + (p + a * coordinates i 0 + b * coordinates i 1 + + c * D (coordinates i 0) + d * D (coordinates i 1)) ^ 2 = + 4 * (c ^ 2 + d ^ 2) := by + obtain ⟨hu, hv⟩ := derivation_u_v D hD + calc + _ = 4 * (u ^ 2 + v ^ 2) * (c ^ 2 + d ^ 2) + + 4 * (u ^ 2 + v ^ 2 - 1) * (a ^ 2 + b ^ 2) := by + simp [Fintype.sum_prod_type, Fin.sum_univ_succ, coordinates, + squareCoordinate, weight, map_neg, hu, hv] + ring + _ = _ := by rw [rotation_norm_sq]; ring + +/-- Weighted derivative energy for an actual affine placement. The mixed +orthogonality condition is not needed after the exact moment cancellation. -/ +theorem weighted_affine_derivation_energy {n : ℕ} + (D : Derivation ℤ ℝ ℝ) + (hD : D parameter = (1 + parameter ^ 2) / 2) + (z A B : Fin n → ℝ) + (hA : ∑ j, A j ^ 2 = 1) (hB : ∑ j, B j ^ 2 = 1) : + ∑ i : Label, (weight i : ℝ) * ∑ j : Fin n, + (D (z j + coordinates i 0 * A j + coordinates i 1 * B j)) ^ 2 = 8 := by + simp_rw [Finset.mul_sum] + rw [Finset.sum_comm] + have he (i : Label) (j : Fin n) : + D (z j + coordinates i 0 * A j + coordinates i 1 * B j) = + D (z j) + D (A j) * coordinates i 0 + D (B j) * coordinates i 1 + + A j * D (coordinates i 0) + B j * D (coordinates i 1) := by + simp only [map_add, Derivation.leibniz, smul_eq_mul] + ring + simp_rw [he, weighted_coordinate_square D hD] + rw [← Finset.mul_sum, Finset.sum_add_distrib, hA, hB] + norm_num + +end GrahamSpherical + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SphericalRamsey/Main.lean b/lean/OAI/Combinatorics/SphericalRamsey/Main.lean new file mode 100644 index 0000000000000000000000000000000000000000..0bbceb83cc41bd0a605255402002e8f424b521b4 --- /dev/null +++ b/lean/OAI/Combinatorics/SphericalRamsey/Main.lean @@ -0,0 +1,33 @@ +import OAI.Combinatorics.SphericalRamsey.Ramsey +import OAI.Combinatorics.SphericalRamsey.CopyInvariant +import OAI.Combinatorics.SphericalRamsey.RealDerivation +import OAI.Combinatorics.SphericalRamsey.Parameter +import OAI.Combinatorics.SphericalRamsey.WitnessCoordinates + +namespace OAI + +noncomputable section +namespace GrahamSpherical + +/-- A single actual real derivation defines avoiding colorings in all dimensions. -/ +theorem exists_common_derivation_colorings : + ∃ D : Derivation ℤ ℝ ℝ, + D parameter = (1 + parameter ^ 2) / 2 ∧ + ∀ n : ℕ, AvoidsCopy witness (energyColor (derivationEnergy (n := n) D)) := by + obtain ⟨D, hD⟩ := exists_real_derivation parameter + ((1 + parameter ^ 2) / 2) parameter_transcendental + exact ⟨D, hD, fun _ => derivationColor_avoids D hD⟩ + +/-- The literal twelve-point spherical witness defeats fifty colors in every +positive dimension, hence is not Euclidean Ramsey. No auxiliary premise remains. -/ +theorem full_main : Specification.FullAuthoredResult := by + obtain ⟨D, _hD, hcolors⟩ := exists_common_derivation_colorings + apply assemble_full_result witness_ncard witness_subset_sphere + intro n _hn + exact ⟨energyColor (derivationEnergy (n := n) D), hcolors n⟩ + +end GrahamSpherical + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SphericalRamsey/Model.lean b/lean/OAI/Combinatorics/SphericalRamsey/Model.lean new file mode 100644 index 0000000000000000000000000000000000000000..49b19875bcc80ad119d1bb1961bc9d9a9cd27312 --- /dev/null +++ b/lean/OAI/Combinatorics/SphericalRamsey/Model.lean @@ -0,0 +1,66 @@ +import Mathlib.Analysis.InnerProductSpace.PiL2 +import Mathlib.Topology.Algebra.InfiniteSum.Real + +namespace OAI + +/-! +The explicit twelve-point witness and the ordinary Euclidean Ramsey property. +These definitions contain no proof-specific field derivation or affine-placement assumption. +-/ +noncomputable section + +namespace GrahamSpherical + +abbrev Point (n : ℕ) := EuclideanSpace ℝ (Fin n) +abbrev Label := Fin 3 × Fin 4 + +/-- The factorial series starts at `1!`. -/ +def parameter : ℝ := ∑' m : ℕ, 1 / (10 : ℝ) ^ ((m + 1).factorial) + +def u : ℝ := (1 - parameter ^ 2) / (1 + parameter ^ 2) +def v : ℝ := (2 * parameter) / (1 + parameter ^ 2) + +def squareCoordinate (q : Fin 4) : Fin 2 → ℝ := + if q = 0 then ![1, 0] else + if q = 1 then ![-1, 0] else + if q = 2 then ![0, 1] else ![0, -1] + +/-- First the positively rotated square, then the negatively rotated square, +and finally the original coordinate square. -/ +def coordinates (i : Label) : Fin 2 → ℝ := + let q := squareCoordinate i.2 + if i.1 = 0 then ![u * q 0 - v * q 1, v * q 0 + u * q 1] else + if i.1 = 1 then ![u * q 0 + v * q 1, -v * q 0 + u * q 1] else q + +def vertex (i : Label) : Point 2 := WithLp.toLp 2 (coordinates i) + +def witness : Set (Point 2) := Set.range vertex + +def weight (i : Label) : ℤ := if i.1 = 2 then -2 else 1 + +/-- Arbitrary colorings and exact distance-preserving copies; no measurability, +computability, continuity of the coloring, or extension of the copy is assumed. -/ +def AvoidsCopy {d n r : ℕ} (X : Set (Point d)) (color : Point n → Fin r) : Prop := + ¬ ∃ f : X → Point n, Isometry f ∧ ∃ c : Fin r, ∀ x, color (f x) = c + +def EuclideanRamsey {d : ℕ} (X : Set (Point d)) : Prop := + ∀ r : ℕ, 0 < r → ∃ n : ℕ, 0 < n ∧ + ∀ color : Point n → Fin r, + ∃ f : X → Point n, Isometry f ∧ ∃ c : Fin r, ∀ x, color (f x) = c + +end GrahamSpherical + +end + +/-! Independent statement of the full authored result. -/ +namespace GrahamSpherical.Specification + +def FullAuthoredResult : Prop := + witness.ncard = 12 ∧ + witness ⊆ Metric.sphere (0 : Point 2) 1 ∧ + (∀ n : ℕ, 0 < n → ∃ color : Point n → Fin 50, AvoidsCopy witness color) ∧ + ¬ EuclideanRamsey witness + +end GrahamSpherical.Specification + +end OAI diff --git a/lean/OAI/Combinatorics/SphericalRamsey/MonochromaticObstruction.lean b/lean/OAI/Combinatorics/SphericalRamsey/MonochromaticObstruction.lean new file mode 100644 index 0000000000000000000000000000000000000000..6c6f167617fbf026ac057a6b7bb25bdc5f297d5c --- /dev/null +++ b/lean/OAI/Combinatorics/SphericalRamsey/MonochromaticObstruction.lean @@ -0,0 +1,51 @@ +import OAI.Combinatorics.SphericalRamsey.Coloring +import OAI.Combinatorics.SphericalRamsey.EnergyIdentity +import Lean.Elab.Tactic.Omega + +namespace OAI + +noncomputable section +open scoped BigOperators +namespace GrahamSpherical + +/-- The actual finite squared Euclidean energy of the entrywise derivation. -/ +def derivationEnergy {n : ℕ} (D : Derivation ℤ ℝ ℝ) (y : Point n) : ℝ := + ∑ j : Fin n, (D (y j)) ^ 2 + +/-- Native integer floor and Euclidean remainder, reindexed into Fin 50. -/ +def energyColor {n : ℕ} (e : Point n → ℝ) (y : Point n) : Fin 50 := + ⟨((Int.floor (3 * e y)) % 50).toNat, by + have h0 := Int.emod_nonneg (Int.floor (3 * e y)) (by norm_num : (50 : ℤ) ≠ 0) + have hlt := Int.emod_lt_of_pos (Int.floor (3 * e y)) (by norm_num : (0 : ℤ) < 50) + omega⟩ + +theorem energyColor_eq_implies_residue_eq {n : ℕ} (e : Point n → ℝ) + (x y : Point n) (h : energyColor e x = energyColor e y) : + (Int.floor (3 * e x)) % 50 = (Int.floor (3 * e y)) % 50 := by + have he := congrArg Fin.val h + change ((Int.floor (3 * e x)) % 50).toNat = + ((Int.floor (3 * e y)) % 50).toNat at he + have hx := Int.emod_nonneg (Int.floor (3 * e x)) (by norm_num : (50 : ℤ) ≠ 0) + have hy := Int.emod_nonneg (Int.floor (3 * e y)) (by norm_num : (50 : ℤ) ≠ 0) + omega + +/-- Every copy here is an actual isometry of the literal witness subtype. +The energy identity is an explicit intermediate premise, discharged separately. -/ +theorem energyColor_avoids_of_invariant {n : ℕ} (e : Point n → ℝ) + (hinvariant : ∀ (f : witness → Point n), Isometry f → + ∑ i : Label, (weight i : ℝ) * e (f ⟨vertex i, ⟨i, rfl⟩⟩) = 8) : + AvoidsCopy witness (energyColor e) := by + rintro ⟨f, hf, c, hc⟩ + have hi := hinvariant f hf + obtain ⟨i, j, hij⟩ := rounding_obstruction + (fun i : Label => e (f ⟨vertex i, ⟨i, rfl⟩⟩)) (by + simpa [weight] using hi) + apply hij + apply energyColor_eq_implies_residue_eq e + exact (hc ⟨vertex i, ⟨i, rfl⟩⟩).trans (hc ⟨vertex j, ⟨j, rfl⟩⟩).symm + +end GrahamSpherical + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SphericalRamsey/Parameter.lean b/lean/OAI/Combinatorics/SphericalRamsey/Parameter.lean new file mode 100644 index 0000000000000000000000000000000000000000..7d59beea271707d44fca2d820ad3718e7347b983 --- /dev/null +++ b/lean/OAI/Combinatorics/SphericalRamsey/Parameter.lean @@ -0,0 +1,48 @@ +import OAI.Combinatorics.SphericalRamsey.Specification +import Mathlib.NumberTheory.Transcendental.Liouville.LiouvilleNumber +import Mathlib.RingTheory.Localization.Integral + +namespace OAI + +noncomputable section + +namespace GrahamSpherical + +/-- The native series includes the additional factorial-zero term. -/ +theorem parameter_add_tenth : + (1 : ℝ) / 10 + parameter = liouvilleNumber 10 := by + simpa [LiouvilleNumber.partialSum, LiouvilleNumber.remainder, parameter] using + (LiouvilleNumber.partialSum_add_remainder (m := (10 : ℝ)) (by norm_num) 0) + +theorem parameter_eq_liouville_sub : + parameter = liouvilleNumber 10 - (1 : ℝ) / 10 := by + linarith [parameter_add_tenth] + +/-- Transcendence of the factorial-series parameter, over the rational field. -/ +theorem parameter_transcendental : Transcendental ℚ parameter := by + intro hp + have hrat : IsAlgebraic ℚ ((1 : ℝ) / 10) := by + simpa using (isAlgebraic_ratCast ℚ (1 / 10 : ℚ) : + IsAlgebraic ℚ ((1 / 10 : ℚ) : ℝ)) + have hsum : IsAlgebraic ℚ (liouvilleNumber 10) := by + rw [← parameter_add_tenth] + exact hrat.add hp + have hint : IsAlgebraic ℤ (liouvilleNumber 10) := + (IsFractionRing.isAlgebraic_iff ℤ ℚ ℝ).mpr hsum + exact (transcendental_liouvilleNumber (m := 10) (by norm_num)) hint + +/-- The strict rational bounds stated for the literal factorial series. -/ +theorem parameter_bounds : + (11 : ℝ) / 100 < parameter ∧ parameter < 12 / 100 := by + have hsplit := LiouvilleNumber.partialSum_add_remainder + (m := (10 : ℝ)) (by norm_num) 2 + have hpos := LiouvilleNumber.remainder_pos (m := (10 : ℝ)) (by norm_num) 2 + have hupp := LiouvilleNumber.remainder_lt (m := (10 : ℝ)) 2 (by norm_num) + norm_num [LiouvilleNumber.partialSum, Finset.sum_range_succ, Nat.factorial] at hsplit hupp + constructor <;> linarith [parameter_add_tenth] + +end GrahamSpherical + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SphericalRamsey/Ramsey.lean b/lean/OAI/Combinatorics/SphericalRamsey/Ramsey.lean new file mode 100644 index 0000000000000000000000000000000000000000..80bc80b07f284fec312588ff4aafc8785a9acb06 --- /dev/null +++ b/lean/OAI/Combinatorics/SphericalRamsey/Ramsey.lean @@ -0,0 +1,30 @@ +import OAI.Combinatorics.SphericalRamsey.Specification + +namespace OAI + +namespace GrahamSpherical + +/-- Fixed fifty-color avoidance in every positive dimension contradicts the +ordinary Ramsey quantifier, without assuming any copy exists. -/ +theorem not_euclideanRamsey_of_fifty_colorings + (havoid : ∀ n : ℕ, 0 < n → + ∃ color : Point n → Fin 50, AvoidsCopy witness color) : + ¬ EuclideanRamsey witness := by + intro hRamsey + obtain ⟨n, hn, hall⟩ := hRamsey 50 (by decide) + obtain ⟨color, hc⟩ := havoid n hn + exact hc (hall color) + +/-- The geometric and coloring properties jointly imply the spherical +non-Ramsey conclusion. -/ +theorem assemble_full_result + (hcard : witness.ncard = 12) + (hsphere : witness ⊆ Metric.sphere (0 : Point 2) 1) + (havoid : ∀ n : ℕ, 0 < n → + ∃ color : Point n → Fin 50, AvoidsCopy witness color) : + Specification.FullAuthoredResult := + ⟨hcard, hsphere, havoid, not_euclideanRamsey_of_fifty_colorings havoid⟩ + +end GrahamSpherical + +end OAI diff --git a/lean/OAI/Combinatorics/SphericalRamsey/RealDerivation.lean b/lean/OAI/Combinatorics/SphericalRamsey/RealDerivation.lean new file mode 100644 index 0000000000000000000000000000000000000000..e35136bcf07f888d805bd1a9a37dc1bc1dbe8b60 --- /dev/null +++ b/lean/OAI/Combinatorics/SphericalRamsey/RealDerivation.lean @@ -0,0 +1,36 @@ +import OAI.Combinatorics.SphericalRamsey.RealTranscendenceBasis +import OAI.Combinatorics.SphericalRamsey.BasisDerivation +import OAI.Combinatorics.SphericalRamsey.AlgebraicExtension + +namespace OAI + +noncomputable section +namespace GrahamSpherical + +/-- Prescribe a derivation at any transcendental real, with an arbitrary real +value. The final scalar need not belong to the rational-function subfield. -/ +theorem exists_real_derivation (a c : ℝ) (ha : Transcendental ℚ a) : + ∃ D : Derivation ℤ ℝ ℝ, D a = c := by + classical + obtain ⟨B, haB, hB⟩ := exists_real_transcendenceBasis_containing a ha + let b : B → ℝ := fun x => (x : ℝ) + let i : B := ⟨a, haB⟩ + let F := IntermediateField.adjoin ℚ (Set.range b) + let : Algebra.IsAlgebraic F ℝ := hB.isAlgebraic_field + obtain ⟨δ, hδ⟩ := exists_derivation_adjoin_coordinate b hB.1 i + obtain ⟨D, hD⟩ := AlgebraicExtension.exists_extension (K := ℝ) δ + let x : F := ⟨b i, IntermediateField.subset_adjoin ℚ (Set.range b) ⟨i, rfl⟩⟩ + have hδx : δ x = 1 := by + exact hδ + have hDa : D a = 1 := by + have h := hD x + rw [hδx, map_one] at h + exact h + refine ⟨c • D, ?_⟩ + simp [Derivation.smul_apply, hDa] + +end GrahamSpherical + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SphericalRamsey/RealTranscendenceBasis.lean b/lean/OAI/Combinatorics/SphericalRamsey/RealTranscendenceBasis.lean new file mode 100644 index 0000000000000000000000000000000000000000..39b2fbaa90e797507a1b82bf3f78e5cedbb230e2 --- /dev/null +++ b/lean/OAI/Combinatorics/SphericalRamsey/RealTranscendenceBasis.lean @@ -0,0 +1,25 @@ +import Mathlib.RingTheory.AlgebraicIndependent.TranscendenceBasis +import Mathlib.Basic.Real.Basic +import Mathlib.Algebra.Algebra.Rat + +namespace OAI + +noncomputable section +namespace GrahamSpherical + +/-- The designated transcendental real is retained in the actual maximal +algebraically independent subset of the real field. -/ +theorem exists_real_transcendenceBasis_containing (a : ℝ) + (ha : Transcendental ℚ a) : + ∃ B : Set ℝ, a ∈ B ∧ IsTranscendenceBasis ℚ (fun b : B => (b : ℝ)) := by + have hs : AlgebraicIndepOn ℚ id ({a} : Set ℝ) := by + exact (algebraicIndependent_singleton_iff + (R := ℚ) (x := fun b : ({a} : Set ℝ) => (b : ℝ)) ⟨a, by simp⟩).2 ha + obtain ⟨B, hsub, hB⟩ := exists_isTranscendenceBasis_superset hs + exact ⟨B, hsub (by simp), hB⟩ + +end GrahamSpherical + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SphericalRamsey/Result.lean b/lean/OAI/Combinatorics/SphericalRamsey/Result.lean new file mode 100644 index 0000000000000000000000000000000000000000..96a882abc55ff96a9a29968cf3bfcb974516397b --- /dev/null +++ b/lean/OAI/Combinatorics/SphericalRamsey/Result.lean @@ -0,0 +1,13 @@ +import OAI.Combinatorics.SphericalRamsey.Main + +namespace OAI + +namespace GrahamSphericalReference + +/-- The explicit twelve-point spherical non-Ramsey result. -/ +theorem challenge : GrahamSpherical.Specification.FullAuthoredResult := + GrahamSpherical.full_main + +end GrahamSphericalReference + +end OAI diff --git a/lean/OAI/Combinatorics/SphericalRamsey/Specification.lean b/lean/OAI/Combinatorics/SphericalRamsey/Specification.lean new file mode 100644 index 0000000000000000000000000000000000000000..9a7da1ddc456564c6dc78001472ade05f6ebd3be --- /dev/null +++ b/lean/OAI/Combinatorics/SphericalRamsey/Specification.lean @@ -0,0 +1 @@ +import OAI.Combinatorics.SphericalRamsey.Model diff --git a/lean/OAI/Combinatorics/SphericalRamsey/WitnessCoordinates.lean b/lean/OAI/Combinatorics/SphericalRamsey/WitnessCoordinates.lean new file mode 100644 index 0000000000000000000000000000000000000000..885ec926a8bf0e2fe8e82b9f9c189ded0ad73cef --- /dev/null +++ b/lean/OAI/Combinatorics/SphericalRamsey/WitnessCoordinates.lean @@ -0,0 +1,43 @@ +import OAI.Combinatorics.SphericalRamsey.WitnessScalars +import Mathlib.Tactic.FinCases + +namespace OAI + +noncomputable section +namespace GrahamSpherical + +theorem vertex_injective : Function.Injective vertex := by + rintro ⟨a, b⟩ ⟨c, d⟩ h + have h0 := congrArg (fun x : Point 2 => x 0) h + have h1 := congrArg (fun x : Point 2 => x 1) h + have hp := v_pos + have hpu := u_pos + have hlt := v_lt_u + have hu := u_lt_one + fin_cases a <;> fin_cases b <;> fin_cases c <;> fin_cases d + all_goals norm_num [vertex, coordinates, squareCoordinate, Fin.ext_iff] at h0 + all_goals norm_num [vertex, coordinates, squareCoordinate, Fin.ext_iff] at h1 + all_goals first | rfl | linarith + +theorem vertex_norm (i : Label) : ‖vertex i‖ = 1 := by + have hs : ‖vertex i‖ ^ 2 = 1 := by + rw [EuclideanSpace.real_norm_sq_eq] + rcases i with ⟨a,b⟩ + fin_cases a <;> fin_cases b <;> + simp [vertex, coordinates, squareCoordinate, Fin.ext_iff, Fin.sum_univ_two, u_sq_add_v_sq, + add_comm (v ^ 2) (u ^ 2)] + nlinarith [norm_nonneg (vertex i)] + +theorem witness_subset_sphere : witness ⊆ Metric.sphere (0 : Point 2) 1 := by + rintro x ⟨i, rfl⟩ + simpa [Metric.mem_sphere, dist_zero_right] using vertex_norm i + +theorem witness_ncard : witness.ncard = 12 := by + rw [witness, Set.ncard_range_of_injective vertex_injective] + norm_num [Label] + +end GrahamSpherical + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SphericalRamsey/WitnessScalars.lean b/lean/OAI/Combinatorics/SphericalRamsey/WitnessScalars.lean new file mode 100644 index 0000000000000000000000000000000000000000..2f180fd19816936e288de76df96fe40eaa7a6e46 --- /dev/null +++ b/lean/OAI/Combinatorics/SphericalRamsey/WitnessScalars.lean @@ -0,0 +1,41 @@ +import OAI.Combinatorics.SphericalRamsey.Parameter +import Mathlib.Tactic.FieldSimp +import Mathlib.Tactic.Positivity +import Mathlib.Tactic.Linarith + +namespace OAI + +noncomputable section +namespace GrahamSpherical + +theorem parameter_den_pos : 0 < 1 + parameter ^ 2 := by positivity + +theorem u_sq_add_v_sq : u ^ 2 + v ^ 2 = 1 := by + unfold u v + field_simp [ne_of_gt parameter_den_pos] + ring + +theorem v_pos : 0 < v := by + have ht : 0 < parameter := by linarith [parameter_bounds.1] + exact div_pos (mul_pos (by norm_num) ht) parameter_den_pos + +theorem v_lt_u : v < u := by + apply (div_lt_div_iff_of_pos_right parameter_den_pos).2 + have ht := parameter_bounds + have hprod : 0 ≤ (12 / 100 - parameter) * (12 / 100 + parameter) := + mul_nonneg (by linarith) (by linarith) + nlinarith + +theorem u_lt_one : u < 1 := by + change (1 - parameter ^ 2) / (1 + parameter ^ 2) < 1 + apply (div_lt_one parameter_den_pos).2 + have ht : 0 < parameter := by linarith [parameter_bounds.1] + nlinarith [sq_pos_of_pos ht] + +theorem u_pos : 0 < u := lt_trans v_pos v_lt_u + +end GrahamSpherical + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SquareDifference/ActualIntervalPair.lean b/lean/OAI/Combinatorics/SquareDifference/ActualIntervalPair.lean new file mode 100644 index 0000000000000000000000000000000000000000..32bb5f01794d268200e4dbdfb677f4185285449f --- /dev/null +++ b/lean/OAI/Combinatorics/SquareDifference/ActualIntervalPair.lean @@ -0,0 +1,51 @@ +import OAI.Combinatorics.SquareDifference.IntervalPair + +namespace OAI + +section + +open Finset + +open scoped BigOperators + +namespace SquareDifference + +open LiftTheory.SquareDifference PairBridge + +section FullPair + +variable {S J : Type*} [Fintype S] [DecidableEq S] [Fintype J] [DecidableEq J] + (ps : S → ℕ) (p : J → ℕ) [∀i,Fact (ps i).Prime] [∀j,Fact (p j).Prime] + +lemma actual_interval_pair (hinj : Function.Injective (extendedPrime ps p)) + (hp : ∀j,64≤p j) (hmass : ∀j,tupleMassThreshold≤(p j:ℝ)) + (B : Finset J) (a b L N Q H : ℕ) (hN : 1≤N) (hH : 1≤H) (hab : a+L≤b) + (hHQ : H*(∏j∈B,p j)≤Q) + (hD : (smallModulus ps*(∏j∈B,p j):ℝ)≤(N:ℝ)^((1:ℝ)/1000)) + (hHn : (H:ℝ)≤(N:ℝ)^((1:ℝ)/1000)) (hlarge : 8≤(N:ℝ)^((1:ℝ)/16)) + (hcover : ∀r : ℕ,r.Prime → r≤N → ∃i,extendedPrime ps p i=r) + (A : Finset ℕ) (hA : A⊆range N) (hfree : NatSquareFree A) + (s t : ZMod (smallModulus ps)) (hst : smallStrictPair ps s t) + (z w : ResidueSpace p) (hzw : ∀j∈B,w j-z j≠0 ∧ IsSquare (w j-z j)) + (R : ℝ) (hm₁ : (𝔼 x,intervalLift p a L Q (smallResidueInput (smallModulus ps) A s) x^2)≤R^2) + (hm₂ : (𝔼 x,intervalLift p b L Q (smallResidueInput (smallModulus ps) A t) x^2)≤R^2) + (k : ℕ) : + |tensorLaw (fun j => tupleGoodLaw (p:=p j)) (fun x => + intervalLift p a L Q (smallResidueInput (smallModulus ps) A s) (freezeCoordinates B z (x (cycleVertex k)))* + intervalLift p b L Q (smallResidueInput (smallModulus ps) A t) (freezeCoordinates B w (x (cycleVertex (k+1)))))|≤ + (∏j∈B,p j:ℝ)*(H:ℝ)^(-(1:ℝ)/3)* + (((N:ℝ)/L)^2*(smallModulus ps)*kernelAbsoluteConstant+R^2) := by + have hlo := interval_low_pair ps p hinj (fun j => by have := hp j; omega) B a b L N Q H hN hH hab hHQ hD hHn hlarge hcover A hA hfree s t hst z w hzw + have hhi := frozen_pair_tail p hp B _ _ R hm₁ hm₂ z w H (by exact_mod_cast (show 0 F (fun v => q^2*z v+a)) = tupleComponent S F := by + classical + let e : (TupleListEntry S → ZMod p) ≃ (TupleListEntry S → ZMod p) := + Equiv.piCongrRight fun _ => affineEquiv q a hq + unfold tupleComponent + let g := fun Y => 𝔼 j : TupleVertex → TupleListIndex S, + tupleValidity S Y * tupleWeight S j * F (tupleOutput S Y j) + have hr : (𝔼 Y, g (e Y)) = 𝔼 Y, g Y := + Fintype.expect_equiv e _ _ (fun _ => rfl) + rw [← hr] + apply expect_congr rfl + intro Y _ + apply expect_congr rfl + intro j _ + change _ = tupleValidity S (fun i => q^2*Y i+a) * tupleWeight S j * + F (fun v => q^2 * tupleOutput S Y j v + a) + rw [tupleValidity_affine S q a hq] + +lemma tupleMixture_affine {p : ℕ} [Fact p.Prime] + (q a : ZMod p) (hq : q ≠ 0) (F : (TupleVertex → ZMod p) → ℝ) : + tupleMixture (fun z => F (fun v => q^2*z v+a)) = tupleMixture F := by + unfold tupleMixture + simp_rw [tupleComponent_affine _ q a hq] + +lemma tupleLaw_affine {p : ℕ} [Fact p.Prime] + (q a : ZMod p) (hq : q ≠ 0) (F : (TupleVertex → ZMod p) → ℝ) : + tupleLaw (fun z => F (fun v => q^2*z v+a)) = tupleLaw F := by + simp only [tupleLaw, LinearMap.smul_apply, smul_eq_mul, tupleMixtureMap_apply] + rw [tupleMixture_affine q a hq] + +lemma invariant_marginal_uniform {V G : Type*} [Nonempty G] [Fintype G] [AddGroup G] + (L : ((V → G) → ℝ) →ₗ[ℝ] ℝ) + (hinv : ∀ a F, L (fun z => F (fun v => z v+a))=L F) + (v : V) (f : G → ℝ) : L (fun z => f (z v)) = L (fun _ => 1) * 𝔼 x, f x := by + classical + have he (z : V → G) : 𝔼 a : G, f (z v+a) = 𝔼 x, f x := by + exact Fintype.expect_equiv (Equiv.addLeft (z v)) _ _ (fun _ => rfl) + have hsum : (fun z : V → G => 𝔼 a : G, f (z v+a)) = + (Fintype.card G : ℝ)⁻¹ • ∑ a : G, (fun z : V → G => f (z v+a)) := by + ext z + rw [Fintype.expect_eq_sum_div_card] + simp [div_eq_mul_inv, mul_comm] + have hlinear := congrArg L hsum + simp only [he, map_smul, map_sum] at hlinear + have hi (a : G) : L (fun z => f (z v+a)) = L (fun z => f (z v)) := + hinv a (fun z => f (z v)) + simp_rw [hi] at hlinear + have hcard : (Fintype.card G : ℝ) ≠ 0 := Nat.cast_ne_zero.mpr Fintype.card_ne_zero + simp only [sum_const, card_univ, nsmul_eq_mul, smul_eq_mul, + inv_mul_cancel_left₀ hcard] at hlinear + rw [← hlinear] + have hc : (fun _ : V → G => 𝔼 x : G, f x) = (𝔼 x : G, f x) • (fun _ => (1 : ℝ)) := by + ext; simp + rw [hc, map_smul] + simp only [smul_eq_mul, mul_comm] + +lemma tupleLaw_marginal {p : ℕ} [Fact p.Prime] + (hp : tupleMassThreshold ≤ (p : ℝ)) (v : TupleVertex) (f : ZMod p → ℝ) : + tupleLaw (fun z => f (z v)) = 𝔼 x, f x := by + have hinv (a : ZMod p) (F : (TupleVertex → ZMod p) → ℝ) : + tupleLaw (fun z => F (fun v => z v+a))=tupleLaw F := by + simpa only [one_pow, one_mul] using tupleLaw_affine 1 a one_ne_zero F + rw [invariant_marginal_uniform tupleLaw hinv v f, tupleLaw_probability hp, one_mul] + +lemma diagonalRoot_one {V X : Type*} [Fintype V] + (L : ((V → X) → ℝ) →ₗ[ℝ] ℝ) (hL : L (fun _ => 1)=1) : + diagonalRoot L (fun _ => 1)=1 := by + simp [diagonalRoot, diagonalIntegral, multilinearIntegral, hL] + +lemma holder_mean {V X : Type*} [Fintype V] [Fintype X] [Nonempty V] + (L : ((V → X) → ℝ) →ₗ[ℝ] ℝ) (hL : L (fun _ => 1)=1) + (hm : ∀ v (f : X → ℝ), L (fun z => f (z v))=𝔼 x, f x) + (hh : ∀ a : V → X → ℝ, |multilinearIntegral L a| ≤ ∏ v, diagonalRoot L (a v)) + (f : X → ℝ) : |𝔼 x, f x| ≤ diagonalRoot L f := by + classical + let v : V := Classical.choice inferInstance + have h := hh (fun w => if w=v then f else fun _ => 1) + have he : multilinearIntegral L (fun w => if w=v then f else fun _ => 1) = 𝔼 x, f x := by + unfold multilinearIntegral + simp only [ite_apply] + rw [show (fun z : V → X => ∏ w, if w=v then f (z w) else (1 : ℝ)) = + (fun z => f (z v)) by funext z; simp] + exact hm v f + rw [he] at h + have he' : (∏ w : V, diagonalRoot L (if w=v then f else fun _ => 1))=diagonalRoot L f := by + simp only [apply_ite, diagonalRoot_one L hL] + simp + rwa [he'] at h + +lemma lawDensity_equiv {Ω : Type*} [DecidableEq Ω] + (L : (Ω → ℝ) →ₗ[ℝ] ℝ) (e : Ω ≃ Ω) + (hL : ∀ F, L (fun z => F (e z))=L F) (x : Ω) : + lawDensity L (e x)=lawDensity L x := by + unfold lawDensity + rw [← hL (fun y => if y=e x then 1 else 0)] + simp only [Equiv.apply_eq_iff_eq] + +lemma tensorLaw_equiv {J V : Type*} [Fintype J] [DecidableEq J] + [Fintype V] [DecidableEq V] {X : J → Type*} [∀ j, Fintype (X j)] + [∀ j, DecidableEq (X j)] (L : ∀ j, ((V → X j) → ℝ) →ₗ[ℝ] ℝ) + (e : ∀ j, X j ≃ X j) + (hL : ∀ j F, L j (fun z => F (fun v => e j (z v)))=L j F) + (F : (V → ∀ j, X j) → ℝ) : + tensorLaw L (fun z => F (fun v j => e j (z v j)))=tensorLaw L F := by + classical + let ej (j : J) : (V → X j) ≃ (V → X j) := Equiv.piCongrRight fun _ => e j + let E : (∀ j, V → X j) ≃ (∀ j, V → X j) := Equiv.piCongrRight ej + have hinv (j : J) (z : V → X j) : lawDensity (L j) (ej j z)=lawDensity (L j) z := + lawDensity_equiv (L j) (ej j) (hL j) z + unfold tensorLaw + simp only [LinearMap.coe_mk, AddHom.coe_mk] + apply Fintype.sum_equiv E _ _ + intro z + change (∏ j, lawDensity (L j) (z j))*F (fun v j => e j (z j v)) = + (∏ j, lawDensity (L j) (ej j (z j)))*F (fun v j => e j (z j v)) + simp only [hinv] + +lemma productTupleLaw_affine {J : Type*} [Fintype J] [DecidableEq J] + (p : J → ℕ) [∀ j, Fact (p j).Prime] + (q a : ∀ j, ZMod (p j)) (hq : ∀ j, q j ≠ 0) + (F : (TupleVertex → ∀ j, ZMod (p j)) → ℝ) : + productTupleLaw p (fun z => F (fun v j => q j^2*z v j+a j))=productTupleLaw p F := by + exact tensorLaw_equiv (fun _ => tupleLaw) (fun j => affineEquiv (q j) (a j) (hq j)) + (fun j => tupleLaw_affine (q j) (a j) (hq j)) F + +lemma productTupleLaw_probability {J : Type*} [Fintype J] [DecidableEq J] + (p : J → ℕ) [∀ j, Fact (p j).Prime] (hp : ∀ j, tupleMassThreshold ≤ (p j : ℝ)) : + productTupleLaw p (fun _ => 1)=1 := + tensorLaw_probability _ (fun j => tupleLaw_probability (hp j)) + +lemma productTupleLaw_marginal {J : Type*} [Fintype J] [DecidableEq J] + (p : J → ℕ) [∀ j, Fact (p j).Prime] (hp : ∀ j, tupleMassThreshold ≤ (p j : ℝ)) + (v : TupleVertex) (f : (∀ j, ZMod (p j)) → ℝ) : + productTupleLaw p (fun z => f (z v)) = 𝔼 x, f x := by + have hinv (a : ∀ j, ZMod (p j)) (F : (TupleVertex → ∀ j, ZMod (p j)) → ℝ) : + productTupleLaw p (fun z => F (fun v => z v+a))=productTupleLaw p F := by + change productTupleLaw p (fun z => F (fun v j => z v j+a j))=productTupleLaw p F + simpa only [one_pow, one_mul] using + productTupleLaw_affine p (fun _ => 1) a (fun _ => one_ne_zero) F + rw [invariant_marginal_uniform _ hinv v f, productTupleLaw_probability p hp, one_mul] + +lemma productTupleLaw_mean {J : Type*} [Fintype J] [DecidableEq J] + (p : J → ℕ) [∀ j, Fact (p j).Prime] + (hp : ∀ j, max tupleMassThreshold tupleReflectionThreshold ≤ (p j : ℝ)) + (f : (∀ j, ZMod (p j)) → ℝ) : + |𝔼 x, f x| ≤ diagonalRoot (productTupleLaw p) f := by + apply holder_mean _ (productTupleLaw_probability p (fun j => (le_max_left _ _).trans (hp j))) + (productTupleLaw_marginal p (fun j => (le_max_left _ _).trans (hp j))) + exact productTupleLaw_signed_holder p (fun j => (le_max_right _ _).trans (hp j)) + +lemma weighted_expect_cauchy {X : Type*} [Fintype X] (f k : X → ℝ) + (hk : ∀ x, 0 ≤ k x) : + (𝔼 x, f x*k x)^2 ≤ (𝔼 x, k x)*(𝔼 x, f x^2*k x) := by + have hh := expect_mul_sq_le_sq_mul_sq univ (fun x => Real.sqrt (k x)) + (fun x => f x*Real.sqrt (k x)) + have he (x : X) : Real.sqrt (k x)*(f x*Real.sqrt (k x))=f x*k x := by + rw [mul_left_comm, Real.mul_self_sqrt (hk x)] + have he' (x : X) : (f x*Real.sqrt (k x))^2=f x^2*k x := by + rw [mul_pow, Real.sq_sqrt (hk x)] + simpa only [he, he', Real.sq_sqrt (hk _)] using hh + +lemma weighted_expect_cauchy_le {X : Type*} [Fintype X] (f k : X → ℝ) + (hk : ∀ x, 0 ≤ k x) (hk1 : ∀ x, k x ≤ 1) : + (𝔼 x, f x*k x)^2 ≤ (𝔼 x, k x)*(𝔼 x, f x^2) := by + apply (weighted_expect_cauchy f k hk).trans + apply mul_le_mul_of_nonneg_left _ (expect_nonneg fun x _ => hk x) + apply expect_le_expect + intro x _ + exact mul_le_of_le_one_right (sq_nonneg _) (hk1 x) + +lemma ratio_energy_pointwise (a b c F : ℝ) (ha : 0 ≤ a) (hc : 0 < c) + (hF : 0 ≤ F) (hb : b^2 ≤ a*F) : + b^2/a ≤ (2/c)*b^2+(4/c^2)*(a-c)^2*F := by + have hr : b^2/a ≤ F := by + by_cases hz : a=0 + · simp [hz, hF] + · exact (div_le_iff₀ (lt_of_le_of_ne ha (Ne.symm hz))).mpr (by nlinarith) + by_cases hl : c/2 ≤ a + · have hap : 0 < a := by linarith + have hratio : b^2/a ≤ (2/c)*b^2 := by + apply (div_le_iff₀ hap).mpr + have hm := mul_le_mul_of_nonneg_left hl (by positivity : 0 ≤ 2/c*b^2) + have he : (2/c*b^2)*(c/2)=b^2 := by field_simp + rw [he] at hm + exact hm + exact hratio.trans (le_add_of_nonneg_right (by positivity)) + · have hs : c^2 ≤ 4*(a-c)^2 := by nlinarith + have hfrac : 1 ≤ (4/c^2)*(a-c)^2 := by + rw [div_mul_eq_mul_div] + exact (le_div_iff₀ (sq_pos_of_pos hc)).mpr (by simpa using hs) + exact hr.trans (by nlinarith [mul_nonneg (by positivity : 0 ≤ 2/c) (sq_nonneg b)]) + +lemma bayes_energy_bound {Y : Type*} [Fintype Y] (a b L : Y → ℝ) + (c δ F : ℝ) (hc : 0 < c) (hF : 0 ≤ F) + (ha : ∀ y, 0 ≤ a y) (hL : ∀ y, L y ≤ 1) + (hpoint : ∀ y, b y^2 ≤ a y*F) + (hb : (𝔼 y, b y^2) ≤ δ^2*F) + (herror : (𝔼 y, (a y-c)^2) ≤ δ^2) : + (𝔼 y, L y*(b y^2/a y)) ≤ (2/c+4/c^2)*δ^2*F := by + calc + _ ≤ (𝔼 y, ((2/c)*b y^2+(4/c^2)*(a y-c)^2*F)) := by + apply expect_le_expect + intro y _ + exact (mul_le_of_le_one_left (div_nonneg (sq_nonneg _) (ha y)) (hL y)).trans + (ratio_energy_pointwise (a y) (b y) c F (ha y) hc hF (hpoint y)) + _ = (2/c)*(𝔼 y, b y^2)+(4/c^2)*(𝔼 y, (a y-c)^2)*F := by + rw [expect_add_distrib] + congr 1 + · exact (mul_expect _ _ _).symm + · rw [show (𝔼 y, 4/c^2*(a y-c)^2*F) = (𝔼 y, 4/c^2*(a y-c)^2)*F from (expect_mul _ _ _).symm, ← mul_expect] + _ ≤ (2/c)*(δ^2*F)+(4/c^2)*δ^2*F := by gcongr + _ = _ := by ring + +noncomputable def conditionalEnergy {X Y : Type*} [Fintype X] [Fintype Y] + (W : X → Y → ℝ) (f : X → ℝ) : ℝ := + 𝔼 y, (𝔼 x, f x*W x y)^2/(𝔼 x, W x y) + +lemma conditionalEnergy_nonneg {X Y : Type*} [Fintype X] [Fintype Y] + (W : X → Y → ℝ) (f : X → ℝ) (hW : ∀ x y, 0 ≤ W x y) : + 0 ≤ conditionalEnergy W f := + expect_nonneg fun y _ => div_nonneg (sq_nonneg _) (expect_nonneg fun x _ => hW x y) + +lemma conditionalEnergy_le {X Y : Type*} [Fintype X] [Fintype Y] + (W : X → Y → ℝ) (f : X → ℝ) (hW : ∀ x y, 0 ≤ W x y) : + conditionalEnergy W f ≤ 𝔼 x, f x^2*(𝔼 y, W x y) := by + calc + _ ≤ 𝔼 y, 𝔼 x, f x^2*W x y := by + apply expect_le_expect + intro y _ + have ha : 0 ≤ 𝔼 x, W x y := expect_nonneg (fun x _ => hW x y) + have hb := weighted_expect_cauchy f (fun x => W x y) (fun x => hW x y) + by_cases hz : (𝔼 x, W x y)=0 + · simp only [hz, div_zero] + exact expect_nonneg fun x _ => mul_nonneg (sq_nonneg _) (hW x y) + · exact (div_le_iff₀ (lt_of_le_of_ne ha (Ne.symm hz))).mpr (by nlinarith) + _ = _ := by rw [expect_comm]; simp only [mul_expect] + +lemma conditionalEnergy_uniform {X Y : Type*} [Fintype X] [Fintype Y] + (W : X → Y → ℝ) (f : X → ℝ) (hW : ∀ x y, 0 ≤ W x y) + (M : ℝ) (hM : ∀ x, (𝔼 y, W x y)=M) : + conditionalEnergy W f ≤ M*(𝔼 x, f x^2) := by + calc + _ ≤ 𝔼 x, f x^2*(𝔼 y, W x y) := conditionalEnergy_le W f hW + _ = _ := by simp only [hM, ← expect_mul]; ring + +lemma ratio_add_le (a b c d : ℝ) (ha : 0 ≤ a) (hc : 0 ≤ c) + (hab : a=0 → b=0) (hcd : c=0 → d=0) : + (b+d)^2/(a+c) ≤ b^2/a+d^2/c := by + by_cases ha0 : a=0 + · simp [ha0, hab ha0] + by_cases hc0 : c=0 + · simp [hc0, hcd hc0] + have hap : 0 < a := lt_of_le_of_ne ha (Ne.symm ha0) + have hcp : 0 < c := lt_of_le_of_ne hc (Ne.symm hc0) + apply (div_le_iff₀ (add_pos hap hcp)).mpr + have he : (b^2/a+d^2/c)*(a+c)-(b+d)^2 = (b*c-d*a)^2/(a*c) := by + field_simp + ring + have hnon : 0 ≤ (b*c-d*a)^2/(a*c) := by positivity + linarith + +lemma conditionalEnergy_add_le {X Y : Type*} [Fintype X] [Fintype Y] + (W T : X → Y → ℝ) (f : X → ℝ) + (hW : ∀ x y, 0 ≤ W x y) (hT : ∀ x y, 0 ≤ T x y) : + conditionalEnergy (fun x y => W x y+T x y) f ≤ + conditionalEnergy W f+conditionalEnergy T f := by + unfold conditionalEnergy + rw [← expect_add_distrib] + apply expect_le_expect + intro y _ + simp only [mul_add, expect_add_distrib] + apply ratio_add_le + · exact expect_nonneg fun x _ => hW x y + · exact expect_nonneg fun x _ => hT x y + · intro hz + have hb := weighted_expect_cauchy f (fun x => W x y) (fun x => hW x y) + rw [hz, zero_mul] at hb + nlinarith [sq_nonneg (𝔼 x, f x*W x y)] + · intro hz + have hb := weighted_expect_cauchy f (fun x => T x y) (fun x => hT x y) + rw [hz, zero_mul] at hb + nlinarith [sq_nonneg (𝔼 x, f x*T x y)] + +lemma conditionalEnergy_smul {X Y : Type*} [Fintype X] [Fintype Y] + (W : X → Y → ℝ) (f : X → ℝ) (c : ℝ) : + conditionalEnergy (fun x y => c*W x y) f = c*conditionalEnergy W f := by + unfold conditionalEnergy + rw [mul_expect] + apply expect_congr rfl + intro y _ + simp only [mul_left_comm (f _) c, ← mul_expect, mul_pow] + by_cases hc : c=0 + · simp [hc] + · field_simp + +lemma conditionalEnergy_leading {X Y : Type*} [Fintype X] [Fintype Y] + (K : X → Y → ℝ) (L : Y → ℝ) (f : X → ℝ) + (c δ : ℝ) (hc : 0 < c) (hK : ∀ x y, 0 ≤ K x y) + (hK1 : ∀ x y, K x y ≤ 1) (hL : ∀ y, L y ≤ 1) + (hb : (𝔼 y, (𝔼 x, f x*K x y)^2) ≤ δ^2*(𝔼 x, f x^2)) + (he : (𝔼 y, ((𝔼 x, K x y)-c)^2) ≤ δ^2) : + conditionalEnergy (fun x y => L y*K x y) f ≤ + (2/c+4/c^2)*δ^2*(𝔼 x, f x^2) := by + have hid : conditionalEnergy (fun x y => L y*K x y) f = + 𝔼 y, L y*((𝔼 x, f x*K x y)^2/(𝔼 x, K x y)) := by + unfold conditionalEnergy + apply expect_congr rfl + intro y _ + simp only [mul_left_comm (f _) (L y), ← mul_expect, mul_pow] + by_cases hz : L y=0 + · simp [hz] + · field_simp + rw [hid] + apply bayes_energy_bound _ _ L c δ (𝔼 x, f x^2) hc + (expect_nonneg fun x _ => sq_nonneg _) _ hL _ hb he + · intro y; exact expect_nonneg fun x _ => hK x y + · intro y; exact weighted_expect_cauchy_le f (fun x => K x y) + (fun x => hK x y) (fun x => hK1 x y) + +lemma bilinear_l2_bound {X Y : Type*} [Fintype X] [Fintype Y] + (K : X → Y → ℝ) (δ : ℝ) (_hδ : 0 ≤ δ) + (h : ∀ (f : X → ℝ) (g : Y → ℝ), |𝔼 x, 𝔼 y, f x*K x y*g y| ≤ + δ*Real.sqrt (𝔼 x, f x^2)*Real.sqrt (𝔼 y, g y^2)) (f : X → ℝ) : + (𝔼 y, (𝔼 x, f x*K x y)^2) ≤ δ^2*(𝔼 x, f x^2) := by + let g := fun y => 𝔼 x, f x*K x y + let A := 𝔼 y, g y^2 + let F := 𝔼 x, f x^2 + have hA : 0 ≤ A := expect_nonneg fun y _ => sq_nonneg _ + have hF : 0 ≤ F := expect_nonneg fun x _ => sq_nonneg _ + have he : (𝔼 x, 𝔼 y, f x*K x y*g y)=A := by + rw [expect_comm] + dsimp only [A, g] + simp only [← expect_mul, pow_two] + have hh := h f g + rw [he, abs_of_nonneg hA] at hh + change A ≤ δ^2*F + by_cases hA0 : A=0 + · rw [hA0]; positivity + have hAp : 0 < Real.sqrt A := Real.sqrt_pos.mpr (lt_of_le_of_ne hA (Ne.symm hA0)) + have hs : Real.sqrt A ≤ δ*Real.sqrt F := by + have hsq := Real.sq_sqrt hA + nlinarith + have hs' := mul_self_le_mul_self (Real.sqrt_nonneg A) hs + rw [← sq, ← sq, mul_pow, Real.sq_sqrt hA, Real.sq_sqrt hF] at hs' + exact hs' + +lemma list_mixing_l2 {I J : Type*} [Fintype I] [Fintype J] + [DecidableEq I] [DecidableEq J] + {p : ℕ} [Fact p.Prime] (hp : p ≠ 2) + (E : Finset (I × J)) (dir : I → J → Bool) + (f : (I → ZMod p) → ℝ) : + (𝔼 y : J → ZMod p, (𝔼 x : I → ZMod p, + f x*(listKernel E dir x y-(1/2 : ℝ)^E.card))^2) ≤ + ((32*E.card : ℝ)^((1 : ℝ)/4)*(p : ℝ)^(-(1 : ℝ)/8))^2 * + (𝔼 x, f x^2) := by + apply bilinear_l2_bound _ _ (by positivity) + intro f g + exact list_mixing hp E dir f g + +lemma listKernel_nonneg {I J : Type*} {p : ℕ} [Fact p.Prime] + (E : Finset (I × J)) (dir : I → J → Bool) (x : I → ZMod p) (y : J → ZMod p) : + 0 ≤ listKernel E dir x y := by + apply prod_nonneg + intro e _ + split <;> exact squareIndicator_nonneg _ + +lemma listKernel_le_one {I J : Type*} {p : ℕ} [Fact p.Prime] + (E : Finset (I × J)) (dir : I → J → Bool) (x : I → ZMod p) (y : J → ZMod p) : + listKernel E dir x y ≤ 1 := by + apply prod_le_one₀ + · intro e _; split <;> exact squareIndicator_nonneg _ + · intro e _; split <;> exact squareIndicator_le_one _ + +lemma list_conditional_mixing {I J : Type*} [Fintype I] [Fintype J] + [DecidableEq I] [DecidableEq J] + {p : ℕ} [Fact p.Prime] (hp : p ≠ 2) + (E : Finset (I × J)) (dir : I → J → Bool) + (L : (J → ZMod p) → ℝ) (hL : ∀ y, L y ≤ 1) + (f : (I → ZMod p) → ℝ) (hf : (𝔼 x, f x)=0) : + conditionalEnergy (fun x y => L y*listKernel E dir x y) f ≤ + (2/(1/2 : ℝ)^E.card+4/((1/2 : ℝ)^E.card)^2)* + ((32*E.card : ℝ)^((1 : ℝ)/4)*(p : ℝ)^(-(1 : ℝ)/8))^2 * + (𝔼 x, f x^2) := by + apply conditionalEnergy_leading (listKernel E dir) L f _ _ (by positivity) + (listKernel_nonneg E dir) (listKernel_le_one E dir) hL + · have he (y : J → ZMod p) : + (𝔼 x : I → ZMod p, f x*(listKernel E dir x y-(1/2 : ℝ)^E.card)) = + (𝔼 x, f x*listKernel E dir x y) := by + simp only [mul_sub, expect_sub_distrib, ← expect_mul, hf, zero_mul, sub_zero] + simpa only [he] using list_mixing_l2 hp E dir f + · have he (y : J → ZMod p) : + (𝔼 x : I → ZMod p, (1 : ℝ)*(listKernel E dir x y-(1/2 : ℝ)^E.card)) = + (𝔼 x : I → ZMod p, listKernel E dir x y)-(1/2 : ℝ)^E.card := by + simp only [one_mul, expect_sub_distrib, Fintype.expect_const] + simpa only [he, one_pow, Fintype.expect_const, mul_one] using + list_mixing_l2 hp E dir (fun _ => 1) + +noncomputable def jointDensity {Ω X Y : Type*} [Fintype Ω] [DecidableEq Ω] + (L : (Ω → ℝ) →ₗ[ℝ] ℝ) (e : Ω ≃ X×Y) (x : X) (y : Y) : ℝ := + Fintype.card Ω * lawDensity L (e.symm (x,y)) + +lemma lawDensity_expect {Ω : Type*} [Fintype Ω] [Nonempty Ω] [DecidableEq Ω] + (L : (Ω → ℝ) →ₗ[ℝ] ℝ) (F : Ω → ℝ) : + L F = 𝔼 z, (Fintype.card Ω : ℝ)*lawDensity L z*F z := by + rw [Fintype.expect_eq_sum_div_card] + simp_rw [mul_assoc] + rw [← mul_sum] + rw [mul_div_cancel_left₀ _ (Nat.cast_ne_zero.mpr Fintype.card_ne_zero)] + exact linearFunctional_density L F + +lemma jointDensity_integral {Ω X Y : Type*} [Fintype Ω] [Nonempty Ω] [DecidableEq Ω] + [Fintype X] [Fintype Y] (L : (Ω → ℝ) →ₗ[ℝ] ℝ) (e : Ω ≃ X×Y) + (F : X → Y → ℝ) : L (fun z => F (e z).1 (e z).2) = + 𝔼 x, 𝔼 y, jointDensity L e x y*F x y := by + rw [lawDensity_expect] + have h := Fintype.expect_equiv e + (fun z => (Fintype.card Ω : ℝ)*lawDensity L z*F (e z).1 (e z).2) + (fun xy => jointDensity L e xy.1 xy.2*F xy.1 xy.2) (by intro z; simp [jointDensity]) + rw [h, ← univ_product_univ, expect_product] + +lemma jointDensity_nonneg {Ω X Y : Type*} [Fintype Ω] [DecidableEq Ω] + (L : (Ω → ℝ) →ₗ[ℝ] ℝ) (e : Ω ≃ X×Y) + (hL : ∀F, (∀z, 0 ≤ F z) → 0 ≤ L F) (x : X) (y : Y) : + 0 ≤ jointDensity L e x y := by + apply mul_nonneg (Nat.cast_nonneg _) (hL _ _) + intro z; split <;> norm_num + +lemma jointDensity_marginal {Ω X Y : Type*} [Fintype Ω] [Nonempty Ω] [DecidableEq Ω] + [Fintype X] [Nonempty X] [Fintype Y] + (L : (Ω → ℝ) →ₗ[ℝ] ℝ) (e : Ω ≃ X×Y) (m : ℝ) + (hL : ∀f : X → ℝ, L (fun z => f (e z).1)=m*(𝔼 x, f x)) (x : X) : + (𝔼 y, jointDensity L e x y)=m := by + classical + have h := jointDensity_integral L e (fun a _ => if a=x then 1 else 0) + rw [hL (fun a => if a=x then 1 else 0)] at h + simp only [mul_ite, mul_one, mul_zero] at h + have he : (𝔼 a : X, if a=x then (1:ℝ) else 0)=(Fintype.card X : ℝ)⁻¹ := by + simp + rw [he] at h + have he' : (𝔼 a, 𝔼 y, if a=x then jointDensity L e a y else 0)= + (𝔼 y, jointDensity L e x y)/(Fintype.card X : ℝ) := by + rw [expect_comm, Fintype.expect_eq_sum_div_card] + simp only [Fintype.expect_eq_sum_div_card, sum_ite_eq', mem_univ, ite_true] + rw [← sum_div] + ring + rw [he'] at h + have hc : (Fintype.card X : ℝ)≠0 := Nat.cast_ne_zero.mpr Fintype.card_ne_zero + field_simp at h + nlinarith + +lemma jointDensity_uniform {Ω X Y : Type*} [Fintype Ω] [Nonempty Ω] [DecidableEq Ω] + (L : (Ω → ℝ) →ₗ[ℝ] ℝ) (e : Ω ≃ X×Y) (w : Ω → ℝ) + (hL : ∀F, L F=𝔼 z, w z*F z) (x : X) (y : Y) : + jointDensity L e x y=w (e.symm (x,y)) := by + unfold jointDensity lawDensity + rw [hL, Fintype.expect_eq_sum_div_card] + simp only [mul_ite, mul_one, mul_zero, sum_ite_eq', mem_univ, ite_true] + exact mul_div_cancel₀ _ (Nat.cast_ne_zero.mpr Fintype.card_ne_zero) + +lemma conditionalEnergy_equiv {X X' Y Y' : Type*} + [Fintype X] [Fintype X'] [Fintype Y] [Fintype Y'] + (e : X ≃ X') (d : Y ≃ Y') (W : X' → Y' → ℝ) (f : X' → ℝ) : + conditionalEnergy (fun x y => W (e x) (d y)) (fun x => f (e x))= + conditionalEnergy W f := by + unfold conditionalEnergy + have hb y : (𝔼 x, f (e x)*W (e x) y)=(𝔼 x, f x*W x y) := + Fintype.expect_equiv e _ _ (fun _ => rfl) + have ha y : (𝔼 x, W (e x) y)=(𝔼 x, W x y) := + Fintype.expect_equiv e _ _ (fun _ => rfl) + simp only [hb, ha] + exact Fintype.expect_equiv d _ _ (fun _ => rfl) + +noncomputable def splitIndex {V : Type*} [DecidableEq V] (v : V) : + Unit ⊕ {w : V // w≠v} ≃ V where + toFun := Sum.elim (fun _ => v) Subtype.val + invFun w := if h : w=v then Sum.inl () else Sum.inr ⟨w,h⟩ + left_inv i := by cases i with + | inl i => cases i; simp + | inr i => simp [i.property] + right_inv w := by by_cases h : w=v <;> simp [h] + +noncomputable def crossEdges {I J : Type*} [Fintype I] [Fintype J] + (E : Finset ((I⊕J)×(I⊕J))) : Finset (I×J) := + univ.filter fun e => (Sum.inl e.1,Sum.inr e.2)∈E ∨ (Sum.inr e.2,Sum.inl e.1)∈E + +noncomputable def crossDir {I J : Type*} (E : Finset ((I⊕J)×(I⊕J))) + (i : I) (j : J) : Bool := decide ((Sum.inl i,Sum.inr j)∈E) + +end SquareDifference +end + +end OAI diff --git a/lean/OAI/Combinatorics/SquareDifference/BlockAverage.lean b/lean/OAI/Combinatorics/SquareDifference/BlockAverage.lean new file mode 100644 index 0000000000000000000000000000000000000000..0017f98ceb7920062f68344de3f186c789676536 --- /dev/null +++ b/lean/OAI/Combinatorics/SquareDifference/BlockAverage.lean @@ -0,0 +1,88 @@ +import OAI.Combinatorics.SquareDifference.PositiveResidue + +namespace OAI + +section + +open Finset + +open scoped BigOperators + +namespace SquareDifference + +open LiftTheory.SquareDifference + +lemma cyclic_ascent_of_start_ne {β : Type*} [LinearOrder β] (f : ℕ → β) + (hperiod : f 24=f 0) (hne : f 0≠f 1) : ∃k<24,f k hn ⟨k,hk,h⟩) + have hbound : ∀k,k≤23 → f (k+1)≤f 1 := by + intro k hk + induction k with + | zero => exact le_rfl + | succ k ih => exact (hd (k+1) (by omega)).trans (ih (by omega)) + have hf := hbound 23 (by omega) + rw [hperiod] at hf + exact hne (le_antisymm hf (hd 0 (by omega))) + +lemma tuple_interval_ascent (a : TupleVertex → ℕ) + (ha : a (cycleVertex 0)≠a (cycleVertex 1)) : + ∃k<24,a (cycleVertex k) a (cycleVertex k)) _ ha + exact congrArg a (cycleVertex_period 0) + +lemma cycleVertex_consecutive_ne (k : ℕ) : cycleVertex k≠cycleVertex (k+1) := by + intro he + have hpow : tupleCycle^k=tupleCycle^(k+1) := congrFun he (⟨0, by decide⟩ : Fin tupleBlocks) + rw [pow_succ] at hpow + exact tupleCycle_ne_one (mul_left_cancel (show tupleCycle^k*tupleCycle=tupleCycle^k*1 by simpa using hpow.symm)) + +lemma equal_choice_probability {V I : Type*} [Fintype V] [DecidableEq V] + [Fintype I] [Nonempty I] [DecidableEq I] (u v : V) (huv : u≠v) : + (𝔼 a : V → I,if a u=a v then (1:ℝ) else 0)=(Fintype.card I:ℝ)⁻¹ := by + rw [expect_two_evals u v huv (fun x y => if x=y then (1:ℝ) else 0)] + have he (x : I) : (𝔼 y : I,if x=y then (1:ℝ) else 0)=(Fintype.card I:ℝ)⁻¹ := by + simp_rw [eq_comm] + simp [expect_eq_sum_div_card] + simp only [he,Fintype.expect_const] + +lemma choice_average_bound {V I : Type*} [Fintype V] [DecidableEq V] + [Fintype I] [Nonempty I] [DecidableEq I] (u v : V) (huv : u≠v) + (F : (V → I) → ℝ) (B E : ℝ) (hE : 0≤E) + (hb : ∀a,|F a|≤B) (hg : ∀a,a u≠a v → |F a|≤E) : + |𝔼 a,F a|≤(Fintype.card I:ℝ)⁻¹*B+E := by + apply (abs_expect_le _ _).trans + calc + _ ≤ 𝔼 a : V → I,((if a u=a v then (1:ℝ) else 0)*B+E) := by + apply expect_le_expect + intro a _ + by_cases ha : a u=a v + · simp only [ha,ite_true,one_mul] + exact (hb a).trans (le_add_of_nonneg_right hE) + · simp only [ha,ite_false,zero_mul,zero_add] + exact hg a ha + _ = _ := by rw [expect_add_distrib,←expect_mul,Fintype.expect_const,equal_choice_probability u v huv] + +lemma multilinearIntegral_scale_expect {V X I : Type*} [Fintype V] [DecidableEq V] + [Fintype I] [Nonempty I] (Llaw : ((V → X) → ℝ) →ₗ[ℝ] ℝ) + (f : V → I → X → ℝ) (c : ℝ) : + multilinearIntegral Llaw (fun v x => c*(𝔼 i,f v i x))= + c^(Fintype.card V)*(𝔼 a : V → I,multilinearIntegral Llaw (fun v => f v (a v))) := by + unfold multilinearIntegral + have he (z : V → X) : (∏v,c*(𝔼 i,f v i (z v)))= + c^(Fintype.card V)*(𝔼 a : V → I,∏v,f v (a v) (z v)) := by + rw [prod_mul_distrib,prod_const,card_univ] + congr 1 + exact (expect_prod_pi (fun v i => f v i (z v))).symm + simp_rw [he] + rw [show (fun z : V → X => c^(Fintype.card V)*(𝔼 a : V → I,∏v,f v (a v) (z v)))= + c^(Fintype.card V) • (fun z => 𝔼 a : V → I,∏v,f v (a v) (z v)) by rfl, + map_smul,smul_eq_mul,linearMap_expect] + +end SquareDifference + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SquareDifference/BlockParameters.lean b/lean/OAI/Combinatorics/SquareDifference/BlockParameters.lean new file mode 100644 index 0000000000000000000000000000000000000000..beb69dc11223910222c6251893bb30d870372217 --- /dev/null +++ b/lean/OAI/Combinatorics/SquareDifference/BlockParameters.lean @@ -0,0 +1,125 @@ +import OAI.Combinatorics.SquareDifference.IntervalTransfer + +namespace OAI + +section + +open Finset Filter + +open scoped Topology + +namespace SquareDifference + +noncomputable def blockLength (N K : ℕ) : ℕ := ⌈(N:ℝ)/K⌉₊ + +lemma blockLength_pos (N K : ℕ) (hN : 0 (p i).Coprime (p j)) + (M : ℕ) [instNeZeroM : NeZero M] (hM : ∀j,M.Coprime (p j)) + +include hp hM + +lemma combined_residue (B : Finset J) (s : ZMod M) (z : ResidueSpace p) : + ∃a : ℕ,a < M*(∏j∈B,p j) ∧ ∀n : ℕ, + ((n:ZMod M)=s ∧ ∀j∈B,(n:ZMod (p j))=z j) ↔ n%(M*(∏j∈B,p j))=a := by + let p' : Option J → ℕ := fun j => j.elim M p + let : ∀j,NeZero (p' j) := fun j => by cases j <;> dsimp [p'] <;> infer_instance + have hp' : Pairwise fun i j => (p' i).Coprime (p' j) := by + intro i j hij + cases i with + | none => cases j with + | none => exact False.elim (hij rfl) + | some j => exact hM j + | some i => cases j with + | none => exact (hM i).symm + | some j => exact hp (fun h => hij (congrArg some h)) + let B' : Finset (Option J) := insert none (B.image some) + let z' : ResidueSpace p' := fun j => by cases j with + | none => exact s + | some j => exact z j + have hprod : (∏j∈B',p' j)=M*(∏j∈B,p j) := by + rw [show B'=insert none (B.image some) by rfl,prod_insert (by simp),prod_image] + · rfl + · exact fun _ _ _ _ h => Option.some.inj h + obtain ⟨a,ha,hres⟩ := residue_crt p' hp' B' z' + refine ⟨a,by rwa [hprod] at ha,fun n => ?_⟩ + rw [←hprod,←hres] + constructor + · rintro ⟨hn,hj⟩ j hmem + rcases mem_insert.mp hmem with rfl | hj' + · exact hn + · obtain ⟨i,hi,rfl⟩ := mem_image.mp hj' + exact hj i hi + · intro h + refine ⟨h none (mem_insert_self _ _),fun j hj => ?_⟩ + exact h (some j) (mem_insert_of_mem (mem_image.mpr ⟨j,hj,rfl⟩)) + +omit hp hM in +lemma combined_modulus_coprime {J : Type*} + [DecidableEq J] + (p : J → ℕ) + [∀ (j : J), NeZero (p j)] + (hp : Pairwise fun i j => (p i).Coprime (p j)) + (M : ℕ) + [NeZero M] + (hM : ∀ (j : J), M.Coprime (p j)) (B : Finset J) (j : J) (hj : j∉B) : + (M*(∏i∈B,p i)).Coprime (p j) := by + apply (hM j).mul_left + apply Nat.coprime_prod_left_iff.mpr + intro i hi + exact hp (fun he => hj (he ▸ hi)) + +lemma exists_combined_units (B : Finset J) : + ∃w : ∀j,(ZMod (p j))ˣ,∀j,j∉B → (w j:ZMod (p j))=((M*(∏i∈B,p i):ℕ):ZMod (p j)) := by + classical + refine ⟨fun j => if hj : j∈B then 1 else ZMod.unitOfCoprime _ (combined_modulus_coprime p hp M hM B j hj),?_⟩ + intro j hj + simp only [dite_eq_right hj,ZMod.coe_unitOfCoprime] + +end ResidueCombine + +noncomputable def smallResidueInput (M : ℕ) (A : Finset ℕ) (s : ZMod M) (n : ℕ) : ℝ := + (M:ℝ)*(if (n:ZMod M)=s then natIndicator A n else 0) + +lemma smallResidueInput_bound (M : ℕ) (A : Finset ℕ) (s : ZMod M) (n : ℕ) : + |smallResidueInput M A s n|≤M := by + unfold smallResidueInput + rw [abs_mul,abs_of_nonneg (Nat.cast_nonneg _)] + apply mul_le_of_le_one_right (Nat.cast_nonneg _) + split_ifs + · exact natIndicator_bound A n + · norm_num + +lemma smallResidueInput_average (M : ℕ) [NeZero M] (A : Finset ℕ) (n : ℕ) : + (𝔼 s : ZMod M,smallResidueInput M A s n)=natIndicator A n := by + rw [expect_eq_sum_div_card] + simp only [smallResidueInput,←mul_sum,sum_ite_eq,mem_univ,ite_true,card_univ,ZMod.card] + exact mul_div_cancel_left₀ (natIndicator A n) (show (M:ℝ)≠0 from Nat.cast_ne_zero.mpr (NeZero.ne M)) + +section ActualResidueTransfer + +variable {J : Type} [Fintype J] [DecidableEq J] (p : J → ℕ) [∀j,Fact (p j).Prime] + (hp : Pairwise fun i j => (p i).Coprime (p j)) + (M : ℕ) [NeZero M] (hM : ∀j,M.Coprime (p j)) + +include hp hM + +lemma smallResidue_fiber_identity (B : Finset J) (s : ZMod M) (z : ResidueSpace p) + (A : Finset ℕ) : + ∃a : ℕ,a < M*(∏j∈B,p j) ∧ ∀n : ℕ, + (∏j∈B,p j:ℝ)*(if ∀j∈B,(n:ZMod (p j))=z j then smallResidueInput M A s n else 0)= + ((M*(∏j∈B,p j):ℕ):ℝ)*(if n%(M*(∏j∈B,p j))=a then natIndicator A n else 0) := by + obtain ⟨a,ha,hres⟩ := combined_residue p hp M hM B s z + refine ⟨a,ha,fun n => ?_⟩ + simp only [←hres] + unfold smallResidueInput + push_cast + split_ifs <;> simp_all ; ring + +lemma actual_set_fiber_transfer + (hcond : ∀j,tupleConditionalThreshold≤(p j:ℝ)) + (href : ∀j,tupleReflectionThreshold≤(p j:ℝ)) + (N Q H L Qc : ℕ) (B : Finset J) (s : ZMod M) (z : ResidueSpace p) + (hH : 0 actualTruncatedLift p N Q (smallResidueInput M A s) (freezeCoordinates B z x))≤ + (((M*(∏j∈B,p j):ℕ):ℝ)^2*L/N)^(Fintype.card TupleVertex)* + (K+(Fintype.card TupleVertex:ℝ)*(H:ℝ)^(-(1:ℝ)/64)*M₂^(Fintype.card TupleVertex))+ + (Fintype.card TupleVertex:ℝ)*(H:ℝ)^(-(1:ℝ)/64)*(∏j∈B,p j:ℝ)*M₁^(Fintype.card TupleVertex) := by + let D := M*(∏j∈B,p j) + have hD : 0 (Fact.out : (p j).Prime).pos)) + obtain ⟨a,ha,hres⟩ := smallResidue_fiber_identity p hp M hM B s z A + obtain ⟨w,hw⟩ := exists_combined_units p hp M hM B + apply actual_frozen_diagonal_transfer p hcond href N Q H D L Qc a B z hH hHQ hHQc + hD hL ha hNL (smallResidueInput M A s) (natIndicator A) + (natIndicator_vanish N A hA) hres w hw K M₁ M₂ hK hM₁ hM₂ hm₁ + · intro j hj t ht r hr + have hid : (fun t => natIndicator A (a+D*j+D^2*t))=natIndicator (squareChild A (a+D*j) D L) := by + funext t + exact (squareChild_indicator N A hA (a+D*j) D L hNL t).symm + rw [hid] + exact hm₂ _ (squareChild_sub _ _ _ _) t ht r hr + · intro j hj + have hid : (fun t => natIndicator A (a+D*j+D^2*t))=natIndicator (squareChild A (a+D*j) D L) := by + funext t + exact (squareChild_indicator N A hA (a+D*j) D L hNL t).symm + rw [hid] + exact hchild _ (squareChild_sub _ _ _ _) (squareChild_free A hfree _ _ _ hD) + +end ActualResidueTransfer + +end SquareDifference + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SquareDifference/CircleDistance.lean b/lean/OAI/Combinatorics/SquareDifference/CircleDistance.lean new file mode 100644 index 0000000000000000000000000000000000000000..44c8dac1b21f208e24378cffe71735bd5e64536e --- /dev/null +++ b/lean/OAI/Combinatorics/SquareDifference/CircleDistance.lean @@ -0,0 +1,534 @@ +import OAI.Combinatorics.SquareDifference.CompleteWeights + +namespace OAI + +section +open Finset +open scoped ComplexConjugate BigOperators +namespace SquareDifference + +lemma periodic_nat_mod (a : ℕ → ℂ) (q : ℕ) (ha : Function.Periodic a q) (n : ℕ) : + a (n % q) = a n := by + have h := (ha.nsmul (n / q)) (n % q) + simpa only [nsmul_eq_mul,Nat.cast_id,Nat.mul_comm (n / q) q,Nat.mod_add_div] using h.symm + +lemma periodic_sum_multiple (a : ℕ → ℂ) (q k : ℕ) (ha : Function.Periodic a q) : + ∑ m ∈ range (q*k), a m = (k : ℂ) * ∑ m ∈ range q, a m := by + induction k with + | zero => simp + | succ k ih => + rw [Nat.mul_succ,sum_range_add,ih] + have h (i : ℕ) : a (q*k+i)=a i := by + simpa only [nsmul_eq_mul,Nat.cast_id,Nat.mul_comm k q,Nat.add_comm] using (ha.nsmul k) i + simp_rw [h] + push_cast + ring + +lemma periodicMean_multiple (a : ℕ → ℂ) (q k : ℕ) (hk : k ≠ 0) + (ha : Function.Periodic a q) : periodicMean a (q*k)=periodicMean a q := by + rw [periodicMean,periodic_sum_multiple a q k ha,periodicMean,Nat.cast_mul,mul_inv_rev] + have hk' : (k : ℂ) ≠ 0 := Nat.cast_ne_zero.mpr hk + field_simp + +lemma periodicMean_of_dvd (a : ℕ → ℂ) (q t : ℕ) (ht : t ≠ 0) + (hqt : q ∣ t) (ha : Function.Periodic a q) : + periodicMean a t=periodicMean a q := by + obtain ⟨k,rfl⟩ := hqt + apply periodicMean_multiple a q k _ ha + intro hz + exact ht (by simp [hz]) + +lemma periodicMean_independent (a : ℕ → ℂ) (q t : ℕ) (hq : q ≠ 0) (ht : t ≠ 0) + (haq : Function.Periodic a q) (hat : Function.Periodic a t) : + periodicMean a q = periodicMean a t := by + calc + _ = periodicMean a (q*t) := (periodicMean_multiple a q t ht haq).symm + _ = periodicMean a (t*q) := by rw [Nat.mul_comm] + _ = _ := periodicMean_multiple a t q hq hat + +lemma periodicMean_sum {I : Type*} (S : Finset I) (f : I → ℕ → ℂ) (t : ℕ) : + periodicMean (fun n => ∑ i ∈ S, f i n) t = ∑ i ∈ S, periodicMean (f i) t := by + simp only [periodicMean,mul_sum] + rw [sum_comm] + +lemma periodicMean_mul_left (a : ℕ → ℂ) (z : ℂ) (t : ℕ) : + periodicMean (fun n => z*a n) t=z*periodicMean a t := by + simp only [periodicMean,← mul_sum] + ring + +lemma prime_dvd_finset_prod_iff {I : Type*} (p : I → ℕ) (S : Finset I) + (q : ℕ) (hq : q.Prime) : q ∣ ∏ i ∈ S, p i ↔ ∃ i ∈ S, q ∣ p i := by + classical + induction S using Finset.induction_on with + | empty => simp [hq.not_dvd_one] + | @insert i S hi ih => + simp only [prod_insert hi,hq.dvd_mul,ih,mem_insert] + aesop + +lemma mem_iff_dvd_prime_product {I : Type*} (p : I → ℕ) + (hp : ∀i, (p i).Prime) (hinj : Function.Injective p) (S : Finset I) (i : I) : + i ∈ S ↔ p i ∣ ∏ j ∈ S, p j := by + rw [prime_dvd_finset_prod_iff p S (p i) (hp i)] + constructor + · intro hi; exact ⟨i,hi,dvd_rfl⟩ + · rintro ⟨j,hj,hij⟩ + have he : p i=p j := (Nat.dvd_prime (hp j)).mp hij |>.resolve_left (hp i).ne_one + simpa only [hinj he] using hj + +lemma prime_product_injective {I : Type*} (p : I → ℕ) + (hp : ∀i, (p i).Prime) (hinj : Function.Injective p) : + Function.Injective (fun S : Finset I => ∏ i ∈ S, p i) := by + intro S T h + change (∏ i ∈ S, p i) = (∏ i ∈ T, p i) at h + ext i + rw [mem_iff_dvd_prime_product p hp hinj,mem_iff_dvd_prime_product p hp hinj,h] + +lemma bounded_prime_subsets_card {I : Type*} (p : I → ℕ) + (hp : ∀i, (p i).Prime) (hinj : Function.Injective p) + (S : Finset (Finset I)) (H : ℕ) (hS : ∀T∈S, ∏i∈T,p i≤H) : S.card≤H := by + classical + let f : S → Fin H := fun T => ⟨(∏i∈T.val,p i)-1, by + have hpos : 0<∏i∈T.val,p i := prod_pos (fun i _ => (hp i).pos) + have hle := hS T.val T.property + omega⟩ + have hf : Function.Injective f := by + intro T U h + have hh := congrArg Fin.val h + have hT : 0<∏i∈T.val,p i := prod_pos (fun i _ => (hp i).pos) + have hU : 0<∏i∈U.val,p i := prod_pos (fun i _ => (hp i).pos) + apply Subtype.ext + apply prime_product_injective p hp hinj + change (∏i∈T.val,p i)-1=(∏i∈U.val,p i)-1 at hh + change (∏i∈T.val,p i)=(∏i∈U.val,p i) + omega + simpa only [Fintype.card_coe,Fintype.card_fin] using Fintype.card_le_of_injective f hf + +lemma hasFourierBound_zero {R : Type*} [CommRing R] [Fintype R] + (ψ : AddChar R ℂ) : HasFourierBound ψ (fun _ => 0) 0 := by + refine ⟨fun _ => 0, ?_, ?_⟩ <;> simp + +lemma HasFourierBound.mono {R : Type*} [CommRing R] [Fintype R] + {ψ : AddChar R ℂ} {w : R → ℂ} {C D : ℝ} + (h : HasFourierBound ψ w C) (hCD : C≤D) : HasFourierBound ψ w D := by + rcases h with ⟨a,ha,hb⟩ + exact ⟨a,ha,hb.trans hCD⟩ + +lemma HasFourierBound.mul_left {R : Type*} [CommRing R] [Fintype R] + {ψ : AddChar R ℂ} {w : R → ℂ} {C : ℝ} + (h : HasFourierBound ψ w C) (z : ℂ) : HasFourierBound ψ (fun x => z*w x) (‖z‖*C) := by + rcases h with ⟨a,ha,hb⟩ + refine ⟨fun i => z*a i, ?_, ?_⟩ + · intro x + dsimp only + rw [ha,mul_sum] + simp only [mul_assoc] + · simpa only [norm_mul,← mul_sum] using mul_le_mul_of_nonneg_left hb (norm_nonneg z) + +lemma hasFourierBound_sum {R I : Type*} [CommRing R] [Fintype R] + (ψ : AddChar R ℂ) (S : Finset I) (w : I → R → ℂ) (C : I → ℝ) + (h : ∀i∈S, HasFourierBound ψ (w i) (C i)) : + HasFourierBound ψ (fun x => ∑i∈S,w i x) (∑i∈S,C i) := by + classical + choose a ha hb using h + refine ⟨fun j => ∑i:S, a i i.property j, ?_, ?_⟩ + · intro x + dsimp only + calc + _ = ∑i:S,w i x := (sum_coe_sort S _).symm + _ = ∑i:S,∑j:R,a i i.property j*ψ (j*x) := by + apply sum_congr rfl + intro i _ + exact ha i i.property x + _ = _ := by rw [sum_comm]; simp only [sum_mul] + · calc + _ ≤ ∑j:R, ∑i:S, ‖a i i.property j‖ := sum_le_sum fun _ _ => norm_sum_le _ _ + _ = ∑i:S, ∑j:R, ‖a i i.property j‖ := sum_comm + _ ≤ ∑i:S,C i := sum_le_sum fun i _ => hb i i.property + _ = _ := sum_coe_sort S _ + +lemma hasFourierBound_prod_budget {R I : Type*} [CommRing R] [Fintype R] [DecidableEq I] + (ψ : AddChar R ℂ) (S : Finset I) (w : I → R → ℂ) (C : I → ℝ) + (hw : ∀i∈S, HasFourierBound ψ (w i) (C i)) : + HasFourierBound ψ (fun x => ∏i∈S,w i x) (∏i∈S,C i) := by + induction S using Finset.induction_on with + | empty => simpa only [prod_empty] using hasFourierBound_one ψ + | @insert i S hi ih => + simpa only [prod_insert hi] using + (hw i (mem_insert_self i S)).mul (ih (fun j hj => hw j (mem_insert_of_mem hj))) + +section ActualWeight + +variable {I : Type*} [Fintype I] [DecidableEq I] + (p : I → ℕ) [∀i, Fact (p i).Prime] + (R : Finset I) (c : ∀i, ZMod (p i)) + +omit [Fintype I] [DecidableEq I] in +lemma actualRootWeight_norm (n : ℕ) : ‖actualRootWeight p R c n‖≤(∏i∈R,p i : ℕ) := by + unfold actualRootWeight + rw [norm_prod,Nat.cast_prod] + apply Finset.prod_le_prod₀ (fun _ _ => norm_nonneg _) + intro i _ + split_ifs <;> simp + +omit [Fintype I] in +lemma actualSieveWeight_norm (T : Finset I) (n : ℕ) : ‖actualSieveWeight p R T n‖≤1 := by + unfold actualSieveWeight + rw [norm_prod] + apply prod_le_one₀ (fun _ _ => norm_nonneg _) + intro i _ + split_ifs + · simp + · simpa only [Complex.norm_real,Real.norm_eq_abs] using primeSieveWeight_abs_le (n : ZMod (p i)) + +omit [Fintype I] [DecidableEq I] in +lemma actualRootWeight_periodic (t : ℕ) (ht : ∀i∈R,p i∣t) : + Function.Periodic (actualRootWeight p R c) t := by + intro n + unfold actualRootWeight + apply prod_congr rfl + intro i hi + rw [Nat.cast_add,(ZMod.natCast_eq_zero_iff t (p i)).mpr (ht i hi),add_zero] + +omit [Fintype I] in +lemma actualSieveWeight_periodic (T : Finset I) (t : ℕ) (ht : ∀i∈T,p i∣t) : + Function.Periodic (actualSieveWeight p R T) t := by + intro n + unfold actualSieveWeight + apply prod_congr rfl + intro i hi + rw [Nat.cast_add,(ZMod.natCast_eq_zero_iff t (p i)).mpr (ht i hi),add_zero] + +omit [Fintype I] in +lemma actualTermWeight_periodic (T : Finset I) : + Function.Periodic (fun n => actualRootWeight p R c n*actualSieveWeight p R T n) + ((∏i∈R,p i)*(∏i∈T,p i)) := by + apply Function.Periodic.mul + · apply actualRootWeight_periodic + intro i hi + exact dvd_mul_of_dvd_left (dvd_prod_of_mem p hi) _ + · apply actualSieveWeight_periodic + intro i hi + exact dvd_mul_of_dvd_right (dvd_prod_of_mem p hi) _ + +variable (q : ℕ) [NeZero q] (hpq : ∀i,p i∣q) + +noncomputable def ringRootWeight (x : ZMod q) : ℂ := + ∏i∈R,(residueDensity (hpq i) (c i) x : ℂ) + +noncomputable def ringSieveWeight (T : Finset I) (x : ZMod q) : ℂ := + ∏i∈T, if i∈R then 0 else (primeSieveWeight (p i) (ZMod.castHom (hpq i) (ZMod (p i)) x) : ℂ) + +noncomputable def ringDivisorWeight (H : ℝ) (x : ZMod q) : ℂ := + ringRootWeight p R c q hpq x * ∑T∈(univ:Finset I).powerset, + if ((∏i∈T,p i : ℕ):ℝ)≤H then (-1)^T.card * ringSieveWeight p R q hpq T x else 0 + +omit [Fintype I] [DecidableEq I] [NeZero q] in +lemma ringRootWeight_natCast (n : ℕ) : + ringRootWeight p R c q hpq (n : ZMod q)=actualRootWeight p R c n := by + simp only [ringRootWeight,residueDensity,map_natCast,actualRootWeight] + simp only [apply_ite (fun x : ℝ => (x : ℂ)),Complex.ofReal_natCast,Complex.ofReal_zero] + +omit [Fintype I] [NeZero q] in +lemma ringSieveWeight_natCast (T : Finset I) (n : ℕ) : + ringSieveWeight p R q hpq T (n : ZMod q)=actualSieveWeight p R T n := by + simp only [ringSieveWeight,map_natCast,actualSieveWeight] + +omit [NeZero q] in +lemma ringDivisorWeight_natCast (H : ℝ) (n : ℕ) : + ringDivisorWeight p R c q hpq H (n : ZMod q)=actualDivisorWeight p R c H n := by + simp only [ringDivisorWeight,ringRootWeight_natCast,ringSieveWeight_natCast,actualDivisorWeight] + +omit [Fintype I] in +lemma ringRootWeight_fourier : + HasFourierBound (ZMod.stdAddChar (N:=q)) (ringRootWeight p R c q hpq) (∏i∈R,p i : ℕ) := by + rw [Nat.cast_prod] + exact hasFourierBound_prod_budget _ R _ _ (fun i _ => + residueDensity_fourier_dvd (hpq i) _ (ZMod.isPrimitive_stdAddChar q) (c i)) + +omit [Fintype I] in +lemma ringSieveWeight_fourier (T : Finset I) : + HasFourierBound (ZMod.stdAddChar (N:=q)) (ringSieveWeight p R q hpq T) 1 := by + apply hasFourierBound_prod + intro i _ + by_cases hi : i∈R + · simp only [ite_eq_left hi] + exact (hasFourierBound_zero _).mono zero_le_one + · simp only [ite_eq_right hi] + exact primeSieveWeight_fourier_dvd (hpq i) _ (ZMod.isPrimitive_stdAddChar q) + +lemma ringDivisorWeight_fourier (hinj : Function.Injective p) (H : ℝ) (hH : 0≤H) : + HasFourierBound (ZMod.stdAddChar (N:=q)) (ringDivisorWeight p R c q hpq H) + ((∏i∈R,p i : ℕ)*H) := by + classical + let S := (univ:Finset I).powerset.filter (fun T => ((∏i∈T,p i : ℕ):ℝ)≤H) + have he (x : ZMod q) : ringDivisorWeight p R c q hpq H x= + ringRootWeight p R c q hpq x*∑T∈S,(-1)^T.card*ringSieveWeight p R q hpq T x := by + simp [ringDivisorWeight,S,sum_filter] + have hf := hasFourierBound_sum (ZMod.stdAddChar (N:=q)) S + (fun T x => (-1)^T.card*ringSieveWeight p R q hpq T x) (fun _ => 1) (by + intro T _ + simpa only [norm_pow,norm_neg,norm_one,one_pow,one_mul] using + (ringSieveWeight_fourier p R q hpq T).mul_left ((-1)^T.card)) + have hcard : (S.card:ℝ)≤H := by + have h := bounded_prime_subsets_card p (fun i => Fact.out) hinj S ⌊H⌋₊ (by + intro T hT + exact Nat.le_floor (mem_filter.mp hT).2) + have hnat : (S.card:ℝ)≤⌊H⌋₊ := by exact_mod_cast h + exact hnat.trans (Nat.floor_le hH) + have hmul := (ringRootWeight_fourier p R c q hpq).mul hf + simp only [sum_const,nsmul_eq_mul,mul_one] at hmul + simpa only [← he] using hmul.mono (mul_le_mul_of_nonneg_left hcard (by positivity)) + +end ActualWeight + +section CompleteWeight + +variable {I : Type*} [Fintype I] [DecidableEq I] + (p : I → ℕ) [∀i, Fact (p i).Prime] (R : Finset I) (c : ∀i, ZMod (p i)) + +noncomputable def actualCompleteWeight (n : ℕ) : ℂ := + actualRootWeight p R c n * ∏i, (1 - if i∈R then 0 else + (primeSieveWeight (p i) (n : ZMod (p i)) : ℂ)) + +omit [DecidableEq I] in +lemma prime_subset_product_le (T : Finset I) : (∏i∈T,p i) ≤ ∏i,p i := by + exact prod_le_prod_of_subset_of_one_le (subset_univ T) + (fun i _ _ => (Fact.out : (p i).Prime).one_le) + +lemma actualDivisorWeight_complete (n : ℕ) : + actualDivisorWeight p R c ((∏i,p i : ℕ) : ℝ) n=actualCompleteWeight p R c n := by + unfold actualDivisorWeight actualCompleteWeight + congr 1 + have h (T : Finset I) : ((∏i∈T,p i : ℕ) : ℝ)≤((∏i,p i : ℕ):ℝ) := by + exact_mod_cast prime_subset_product_le p T + simp only [ite_eq_left (h _),actualSieveWeight] + exact finite_complete_sieve univ _ + +lemma actualCompleteWeight_periodic (t : ℕ) (ht : ∀i,p i∣t) : + Function.Periodic (actualCompleteWeight p R c) t := by + intro n + unfold actualCompleteWeight + rw [actualRootWeight_periodic p R c t (fun i _ => ht i) n] + congr 1 + apply prod_congr rfl + intro i _ + rw [Nat.cast_add,(ZMod.natCast_eq_zero_iff t (p i)).mpr (ht i),add_zero] + +variable (hinj : Function.Injective p) (b : ℚ) + (hb : b.den∣∏i,primaryModulus b.den (p i)) + +lemma primaryModelCoefficient_complete (H : ℝ) (htwo : ∀i,p i=2 → i∈R) : + primaryModelCoefficient p hinj b hb R c H = + if ((∏i∈primaryActive p b.den\R,p i : ℕ) : ℝ)≤H then + periodicMean (fun n => actualCompleteWeight p R c (n+1)* + expPhase ((b:ℝ)*(n+1)^2)) (∏i,primaryModulus b.den (p i)) else 0 := by + have hfull : ((∏i∈primaryActive p b.den\R,p i : ℕ):ℝ)≤((∏i,p i : ℕ):ℝ) := by + exact_mod_cast prime_subset_product_le p (primaryActive p b.den\R) + have hmean := actualDivisorWeight_coefficient p hinj b hb R c ((∏i,p i : ℕ):ℝ) + simp_rw [actualDivisorWeight_complete] at hmean + rw [hmean,primary_coefficient_small p hinj b hb R c _ htwo hfull] + unfold primaryModelCoefficient + split_ifs <;> simp_all + exfalso + linarith + +end CompleteWeight + +noncomputable def smallQuadraticModulus (p : ℕ) : ℕ := if p=2 then 8 else p + +lemma smallQuadraticModulus_pos {p : ℕ} (hp : p.Prime) : 0 (smallQuadraticModulus (p i)).Coprime (smallQuadraticModulus (p j))) := by + intro i j hij + have hc : (p i).Coprime (p j) := (Nat.coprime_primes (hp i) (hp j)).mpr (hinj.ne hij) + unfold smallQuadraticModulus + split_ifs with hi hj hj + · exact False.elim (hij (hinj (hi.trans hj.symm))) + · simpa only [hi,show 2^3=8 by norm_num] using hc.pow_left 3 + · simpa only [hj,show 2^3=8 by norm_num] using hc.pow_right 3 + · exact hc + +noncomputable def smallRootSquare (p : ℕ) (c : ZMod p) : ZMod (smallQuadraticModulus p) := + if p=2 then 1 else (c.val : ZMod (smallQuadraticModulus p))^2 + +lemma small_root_quadratic {p : ℕ} [Fact p.Prime] (c : ZMod p) + (hc : p=2 → c=1) (ψ : AddChar (ZMod (smallQuadraticModulus p)) ℂ) : + (𝔼 x : ZMod (smallQuadraticModulus p), + (residueDensity (prime_dvd_smallQuadraticModulus p) c x : ℂ)*ψ (x^2))= + ψ (smallRootSquare p c) := by + by_cases h2 : p=2 + · subst p + rw [hc rfl] + exact odd_root_quadratic_small (by norm_num [smallQuadraticModulus]) + (by simp [smallQuadraticModulus]) ψ + · have hm : smallQuadraticModulus p=p := ite_eq_right h2 + have he (m : ℕ) [NeZero m] (hpm : p∣m) (hm : m=p) (φ : AddChar (ZMod m) ℂ) : + (𝔼 x : ZMod m, (residueDensity hpm c x : ℂ)*φ (x^2))=φ ((c.val : ZMod m)^2) := by + subst m + simpa only [ZMod.natCast_zmod_val] using residueDensity_self_quadratic p c φ + unfold smallRootSquare + rw [ite_eq_right h2] + exact he _ (prime_dvd_smallQuadraticModulus p) hm ψ + +section CompleteCRT + +variable {I : Type*} [Fintype I] [DecidableEq I] + (p m : I → ℕ) [∀i, Fact (p i).Prime] [∀i, NeZero (m i)] + (hm : ∀i, p i∣m i) (R : Finset I) (c : ∀i, ZMod (p i)) + +lemma crt_complete_coefficient {L : ℕ} [NeZero L] + (e : ZMod L ≃+* ∀i, ZMod (m i)) (ψ : AddChar (ZMod L) ℂ) : + (𝔼 x : ZMod L, (∏i,localRootWeight p m hm R c i (e x i))* + (∏i,(1-localSieveWeight p m hm R i (e x i)))*ψ (x^2))= + ∏i,(𝔼 x : ZMod (m i), localRootWeight p m hm R c i x* + (1-localSieveWeight p m hm R i x)* + coordinateChar (ψ.compAddMonoidHom e.symm.toAddMonoidHom) i (x^2)) := by + rw [quadratic_mean_equiv e ψ (fun x => (∏i,localRootWeight p m hm R c i (x i))* + (∏i,(1-localSieveWeight p m hm R i (x i))))] + simp_rw [← prod_mul_distrib] + exact product_quadratic_mean (I := I) (R := fun i => ZMod (m i)) + (ψ.compAddMonoidHom e.symm.toAddMonoidHom) + (fun i x => localRootWeight p m hm R c i x*(1-localSieveWeight p m hm R i x)) + +lemma periodicMean_crt_complete {L : ℕ} [NeZero L] + (e : ZMod L ≃+* ∀i, ZMod (m i)) (b : ℚ) (hbL : b.den∣L) : + periodicMean (fun n => actualCompleteWeight p R c (n+1)*expPhase ((b:ℝ)*(n+1)^2)) L= + ∏i,(𝔼 x : ZMod (m i), localRootWeight p m hm R c i x* + (1-localSieveWeight p m hm R i x)* + coordinateChar ((rationalChar b |>.compAddMonoidHom + (ZMod.castHom hbL (ZMod b.den)).toAddMonoidHom).compAddMonoidHom e.symm.toAddMonoidHom) i (x^2)) := by + let w : ZMod L → ℂ := fun x => (∏i,localRootWeight p m hm R c i (e x i))* + ∏i,(1-localSieveWeight p m hm R i (e x i)) + have hw (n : ℕ) : w (n:ZMod L)=actualCompleteWeight p R c n := by + simp only [w,map_natCast,Pi.natCast_apply,localRootWeight_natCast,localSieveWeight_natCast] + unfold actualCompleteWeight actualRootWeight + congr 1 + rw [← prod_filter] + simp only [filter_mem_eq_inter,univ_inter] + rw [show (fun n : ℕ => actualCompleteWeight p R c (n+1)*expPhase ((b:ℝ)*(n+1)^2))= + (fun n : ℕ => w ((n+1:ℕ):ZMod L)*expPhase ((b:ℝ)*(n+1)^2)) by + funext n; rw [hw]] + rw [rational_periodic_coefficient b hbL w] + exact crt_complete_coefficient p m hm R c e + ((rationalChar b).compAddMonoidHom (ZMod.castHom hbL (ZMod b.den)).toAddMonoidHom) + +end CompleteCRT + +noncomputable def circleDistance (t : ℝ) : ℝ := |t - round t| + +@[simp] lemma expPhase_zero : expPhase 0 = 1 := by simp [expPhase] +@[simp] lemma norm_expPhase (t : ℝ) : ‖expPhase t‖ = 1 := Circle.norm_coe _ + +lemma expPhase_add (s t : ℝ) : expPhase (s+t) = expPhase s * expPhase t := by + simp [expPhase, AddChar.map_add_eq_mul] + +lemma expPhase_neg (t : ℝ) : expPhase (-t) = conj (expPhase t) := by + simp only [expPhase, AddChar.map_neg_eq_inv, Circle.coe_inv_eq_conj] + +lemma expPhase_sub (s t : ℝ) : expPhase (s-t) = expPhase s * conj (expPhase t) := by + rw [sub_eq_add_neg, expPhase_add, expPhase_neg] + +lemma expPhase_nat_mul (t : ℝ) (n : ℕ) : expPhase (n*t) = expPhase t^n := by + simpa only [expPhase, nsmul_eq_mul, Circle.coe_pow] using congrArg (fun z : Circle => (z : ℂ)) + (AddChar.map_nsmul_eq_pow Real.fourierChar n t) + +lemma expPhase_int (n : ℤ) : expPhase n = 1 := by + change Complex.exp (↑(2 * Real.pi * (n : ℝ)) * Complex.I) = 1 + rw [show (↑(2 * Real.pi * (n : ℝ)) : ℂ) * Complex.I = + (n : ℂ) * (2 * Real.pi * Complex.I) by push_cast; ring] + exact Complex.exp_int_mul_two_pi_mul_I n + +lemma expPhase_sub_int (t : ℝ) (n : ℤ) : expPhase (t-n) = expPhase t := by + rw [expPhase_sub, expPhase_int, map_one, mul_one] + +lemma circleDistance_nonneg (t : ℝ) : 0 ≤ circleDistance t := abs_nonneg _ + +lemma circleDistance_le_half (t : ℝ) : circleDistance t ≤ 1/2 := abs_sub_round t + +lemma circleDistance_le_abs_sub_int (t : ℝ) (n : ℤ) : circleDistance t ≤ |t-n| := + round_le t n + +lemma circleDistance_le_abs (t : ℝ) : circleDistance t ≤ |t| := by + simpa using circleDistance_le_abs_sub_int t 0 + +lemma circleDistance_sub_le (s t : ℝ) : circleDistance (s-t) ≤ + |(s-round s)-(t-round t)| := by + convert circleDistance_le_abs_sub_int (s-t) (round s-round t) using 1 + push_cast + congr 1 + ring + +lemma expPhase_sub_one_lower (t : ℝ) : 4*circleDistance t ≤ ‖expPhase t-1‖ := by + let u := t-(round t : ℝ) + have hu : |u| ≤ 1/2 := abs_sub_round t + have hp := Real.pi_pos + have hs := Real.mul_abs_le_abs_sin (x := Real.pi*u) + (by rw [abs_mul, abs_of_pos hp]; nlinarith) + rw [abs_mul, abs_of_pos hp] at hs + have hmul : 2/Real.pi*(Real.pi*|u|)=2*|u| := by field_simp + rw [hmul] at hs + rw [← expPhase_sub_int t (round t)] + change 4*|u| ≤ ‖Complex.exp (↑(2*Real.pi*u)*Complex.I)-1‖ + rw [mul_comm _ Complex.I, Complex.norm_exp_I_mul_ofReal_sub_one] + rw [show 2*Real.pi*u/2=Real.pi*u by ring, Real.norm_eq_abs, + abs_mul, abs_of_pos (by norm_num : (0 : ℝ)<2)] + linarith + +lemma linear_phase_sum_trivial (t : ℝ) (L : ℕ) : + ‖∑ m ∈ range L, expPhase (m*t)‖ ≤ L := by + calc + _ ≤ ∑ m ∈ range L, ‖expPhase (m*t)‖ := norm_sum_le _ _ + _ = L := by simp + +lemma linear_phase_sum_distance (t : ℝ) (L : ℕ) (ht : 0 < circleDistance t) : + ‖∑ m ∈ range L, expPhase (m*t)‖ ≤ 1 / (2*circleDistance t) := by + have hz : expPhase t ≠ 1 := by + intro he + have := expPhase_sub_one_lower t + rw [he, sub_self, norm_zero] at this + linarith + simp_rw [expPhase_nat_mul] + rw [geom_sum_eq hz, norm_div] + have hn : ‖expPhase t ^ L - 1‖ ≤ 2 := by + calc + _ ≤ ‖expPhase t^L‖+‖(1 : ℂ)‖ := norm_sub_le _ _ + _ = 2 := by simp; norm_num + calc + _ ≤ 2 / (4*circleDistance t) := + div_le_div₀ (by positivity) hn (by positivity) (expPhase_sub_one_lower t) + _ = 1 / (2*circleDistance t) := by ring + +noncomputable def phaseBound (M t : ℝ) : ℝ := + if circleDistance t = 0 then M else min M (circleDistance t)⁻¹ + +lemma phaseBound_nonneg {M : ℝ} (hM : 0 ≤ M) (t : ℝ) : 0 ≤ phaseBound M t := by + unfold phaseBound + split_ifs + · exact hM + · exact le_min hM (inv_nonneg.mpr (circleDistance_nonneg t)) + +lemma phaseBound_le (M t : ℝ) : phaseBound M t ≤ M := by + unfold phaseBound + split_ifs + · rfl + · exact min_le_left _ _ + +end SquareDifference +end + +end OAI diff --git a/lean/OAI/Combinatorics/SquareDifference/CompleteWeights.lean b/lean/OAI/Combinatorics/SquareDifference/CompleteWeights.lean new file mode 100644 index 0000000000000000000000000000000000000000..1bf57d40fa0937fcef95183c6e048f9ebdee13d4 --- /dev/null +++ b/lean/OAI/Combinatorics/SquareDifference/CompleteWeights.lean @@ -0,0 +1,723 @@ +import OAI.Combinatorics.SquareDifference.PrimaryKernel + +namespace OAI + +section +open Finset +open scoped ComplexConjugate BigOperators +namespace SquareDifference + +lemma coordinateChar_inflation_trivial {I : Type*} [DecidableEq I] + (m : I → ℕ) {q L : ℕ} (hqL : q∣L) + (e : ZMod L ≃+* ∀i, ZMod (m i)) + (ψ : AddChar (ZMod q) ℂ) (i : I) (hiq : (m i).Coprime q) : + coordinateChar ((ψ.compAddMonoidHom (ZMod.castHom hqL (ZMod q)).toAddMonoidHom).compAddMonoidHom + e.symm.toAddMonoidHom) i=1 := by + let f : ZMod (m i) →+ ZMod q := + ((ZMod.castHom hqL (ZMod q)).toAddMonoidHom.comp e.symm.toAddMonoidHom).comp + (AddMonoidHom.single (fun j => ZMod (m j)) i) + have hf (a : ZMod (m i)) : f a=0 := by + have hzero : m i • a=0 := by simp only [nsmul_eq_mul,ZMod.natCast_self,zero_mul] + have h := congrArg f hzero + rw [map_nsmul,map_zero,nsmul_eq_mul] at h + exact (ZMod.isUnit_iff_coprime (m i) q).mpr hiq |>.mul_left_cancel (h.trans (mul_zero _).symm) + ext a + change ψ (f a)=1 + rw [hf,AddChar.map_zero_eq_one] + +noncomputable def primaryModulus (q p : ℕ) : ℕ := p^(max 1 (q.factorization p)) + +lemma primaryModulus_of_dvd {q p : ℕ} (hq : q≠0) (hp : p.Prime) (h : p∣q) : + primaryModulus q p=p^(q.factorization p) := by + have he : 1≤q.factorization p := (hp.pow_dvd_iff_le_factorization hq).mp (by simpa using h) + simp only [primaryModulus,max_eq_right he] + +lemma primaryModulus_of_not_dvd {q p : ℕ} (h : ¬p∣q) : primaryModulus q p=p := by + simp only [primaryModulus,Nat.factorization_eq_zero_of_not_dvd h,Nat.max_eq_left (by omega : 0≤1),pow_one] + +lemma primaryModulus_pos {q p : ℕ} (hp : p.Prime) : 0 (primaryModulus q p).Coprime (primaryModulus q r)) := by + intro p r hpr + apply Nat.Coprime.pow + exact (Nat.coprime_primes (hp p p.prop) (hp r r.prop)).mpr + (fun h => hpr (Subtype.ext h)) + +lemma dvd_primaryModulus_product (q : ℕ) (hq : q≠0) (S : Finset ℕ) + (hS : q.primeFactors⊆S) : + q∣∏p∈S, primaryModulus q p := by + have he : q=∏p∈q.primeFactors, primaryModulus q p := by + conv_lhs => rw [Nat.prod_primeFactors_pow_factorization hq] + apply prod_congr rfl + intro p hp + exact (primaryModulus_of_dvd hq (Nat.mem_primeFactors.mp hp).1 (Nat.mem_primeFactors.mp hp).2.1).symm + calc + q = ∏p∈q.primeFactors, primaryModulus q p := he + _ ∣ ∏p∈S, primaryModulus q p := prod_dvd_prod_of_subset _ _ _ hS + +lemma prime_dvd_primaryModulus (q p : ℕ) : p∣primaryModulus q p := by + exact dvd_pow_self p (by have := le_max_left 1 (q.factorization p); omega) + +lemma primaryModulus_eq_or_square (q p : ℕ) : + primaryModulus q p=p ∨ p*p∣primaryModulus q p := by + by_cases he : max 1 (q.factorization p)=1 + · left; simp only [primaryModulus,he,pow_one] + · right + have h2 : 2 ≤ max 1 (q.factorization p) := by have := le_max_left 1 (q.factorization p); omega + simpa only [primaryModulus,pow_two] using pow_dvd_pow p h2 + +lemma primaryModulus_eq_of_dvd_prime {q p : ℕ} (hp : p.Prime) + (h : primaryModulus q p∣p) : primaryModulus q p=p := + le_antisymm (Nat.le_of_dvd hp.pos h) (primaryModulus_le hp) + +lemma primaryModulus_two_small_or_large (q : ℕ) : + primaryModulus q 2∣8 ∨ 16∣primaryModulus q 2 := by + by_cases he : max 1 (q.factorization 2)≤3 + · left + change 2^max 1 (q.factorization 2)∣2^3 + exact pow_dvd_pow 2 he + · right + change 2^4∣2^max 1 (q.factorization 2) + exact pow_dvd_pow 2 (by omega) + +lemma primaryModulus_odd_unit_two {q p : ℕ} (hp : p.Prime) (h2 : p≠2) : + IsUnit (2 : ZMod (primaryModulus q p)) := by + apply (ZMod.isUnit_iff_coprime 2 _).mpr + apply Nat.Coprime.pow_right + exact (Nat.coprime_primes Nat.prime_two hp).mpr h2.symm + +instance primaryModulus_neZero (q p : ℕ) [Fact p.Prime] : NeZero (primaryModulus q p) := + ⟨(primaryModulus_pos (Fact.out : p.Prime)).ne'⟩ + +lemma primary_root_odd_zero {q p : ℕ} [Fact p.Prime] + (hp : p≠2) (c : ZMod p) (hc : c≠0) (hm : primaryModulus q p≠p) + (ψ : AddChar (ZMod (primaryModulus q p)) ℂ) (hψ : ψ.IsPrimitive) : + (𝔼 x : ZMod (primaryModulus q p), + (residueDensity (prime_dvd_primaryModulus q p) c x : ℂ)*ψ (x^2))=0 := by + let : NeZero (primaryModulus q p) := ⟨(primaryModulus_pos (Fact.out : p.Prime)).ne'⟩ + have hs := (primaryModulus_eq_or_square q p).resolve_left hm + apply residueDensity_quadratic_zero_dvd hs c _ ψ hψ + have h2 : (2 : ZMod p)≠0 := Ring.two_ne_zero (by simpa only [ZMod.ringChar_zmod_n] using hp) + exact mul_ne_zero h2 hc + +lemma primary_root_two_zero (q : ℕ) (hm : ¬primaryModulus q 2∣8) + (ψ : AddChar (ZMod (primaryModulus q 2)) ℂ) (hψ : ψ.IsPrimitive) : + (𝔼 x : ZMod (primaryModulus q 2), + (residueDensity (prime_dvd_primaryModulus q 2) 1 x : ℂ)*ψ (x^2))=0 := by + let : NeZero (primaryModulus q 2) := ⟨(primaryModulus_pos Nat.prime_two).ne'⟩ + exact odd_root_quadratic_large_dvd ((primaryModulus_two_small_or_large q).resolve_left hm) ψ hψ + +lemma primary_sieve_square_zero {q p : ℕ} [Fact p.Prime] + (hp : p≠2) (hm : primaryModulus q p≠p) + (ψ : AddChar (ZMod (primaryModulus q p)) ℂ) (hψ : ψ.IsPrimitive) : + (𝔼 x : ZMod (primaryModulus q p), ψ (x^2))- + (𝔼 x : ZMod (primaryModulus q p), + (primeSieveWeight p (ZMod.castHom (prime_dvd_primaryModulus q p) (ZMod p) x) : ℂ)*ψ (x^2))=0 := by + let : NeZero (primaryModulus q p) := ⟨(primaryModulus_pos (Fact.out : p.Prime)).ne'⟩ + exact prime_power_sieved_zero_dvd hp ((primaryModulus_eq_or_square q p).resolve_left hm) ψ hψ + +noncomputable def expPhase (t : ℝ) : ℂ := Real.fourierChar t + +noncomputable def periodicMean (a : ℕ → ℂ) (T : ℕ) : ℂ := (T : ℂ)⁻¹*∑m∈range T, a m + +lemma rational_num_isUnit (b : ℚ) : IsUnit (b.num : ZMod b.den) := by + have h := b.isCoprime_num_den.map (Int.castRingHom (ZMod b.den)) + change IsCoprime (b.num : ZMod b.den) ((b.den : ℤ) : ZMod b.den) at h + rw [Int.cast_natCast,ZMod.natCast_self] at h + exact isCoprime_zero_right.mp h + +noncomputable def rationalChar (b : ℚ) : AddChar (ZMod b.den) ℂ := + (@ZMod.stdAddChar b.den ⟨b.pos.ne'⟩).mulShift b.num + +lemma rationalChar_primitive (b : ℚ) : (rationalChar b).IsPrimitive := by + let : NeZero b.den := ⟨b.pos.ne'⟩ + exact primitive_mulShift _ (ZMod.isPrimitive_stdAddChar b.den) _ (rational_num_isUnit b) + +lemma rationalChar_int (b : ℚ) (z : ℤ) : rationalChar b (z : ZMod b.den)=expPhase ((b : ℝ)*(z : ℝ)) := by + let : NeZero b.den := ⟨b.pos.ne'⟩ + rw [rationalChar,AddChar.mulShift_apply,← Int.cast_mul,ZMod.stdAddChar_coe] + change Complex.exp _=Complex.exp (↑(2*Real.pi*((b : ℝ)*z))*Complex.I) + congr 1 + have hb : (b : ℝ)=(b.num : ℝ)/(b.den : ℝ) := by exact_mod_cast b.num_div_den.symm + rw [hb] + push_cast + ring + +lemma rationalChar_nat_square (b : ℚ) (m : ℕ) : + rationalChar b ((m : ZMod b.den)^2)=expPhase ((b : ℝ)*(m : ℝ)^2) := by + have h₁ : (((m : ℤ)^2 : ℤ) : ZMod b.den)=(m : ZMod b.den)^2 := by + rw [Int.cast_pow,Int.cast_natCast] + have h₂ : (((m : ℤ)^2 : ℤ) : ℝ)=(m : ℝ)^2 := by + rw [Int.cast_pow,Int.cast_natCast] + rw [← h₁,← h₂] + exact rationalChar_int b ((m : ℤ)^2) + +open Fin.NatCast in +lemma finEquiv_natCast {q : ℕ} [NeZero q] (x : Fin q) : + ZMod.finEquiv q x=(x.val : ZMod q) := by + cases q with + | zero => exact (NeZero.ne 0 rfl).elim + | succ q => + change x=(Nat.cast x.val : Fin (q+1)) + exact (Fin.natCast_eq_mk x.isLt).symm + +lemma expect_zmod_range {q : ℕ} [NeZero q] (f : ZMod q → ℂ) : + (𝔼 x : ZMod q, f x)=periodicMean (fun m => f (m : ZMod q)) q := by + rw [← Fintype.expect_equiv (ZMod.finEquiv q).toEquiv (fun x => f (ZMod.finEquiv q x)) f (fun _ => rfl)] + simp_rw [finEquiv_natCast] + rw [expect_eq_sum_div_card,card_univ,Fintype.card_fin,Fin.sum_univ_eq_sum_range (fun m => f (m : ZMod q)) q] + simp only [periodicMean,div_eq_mul_inv,mul_comm] + +lemma periodicMean_shift_one (a : ℕ → ℂ) (q : ℕ) (h : Function.Periodic a q) : + periodicMean (fun m => a (m+1)) q=periodicMean a q := by + have hs := (sum_range_succ' a q).symm.trans (sum_range_succ a q) + have h0 : a q=a 0 := by simpa using h 0 + rw [h0] at hs + exact congrArg (fun z : ℂ => (q : ℂ)⁻¹*z) (add_right_cancel hs) + +lemma zmod_natCast_periodic (q : ℕ) (f : ZMod q → ℂ) : + Function.Periodic (fun m : ℕ => f (m : ZMod q)) q := by + intro m + simp only [Nat.cast_add,ZMod.natCast_self,add_zero] + +lemma periodicMean_factor_expect {q t : ℕ} [NeZero q] [NeZero t] + (hqt : q∣t) (f : ZMod q → ℂ) : + periodicMean (fun m : ℕ => f (m : ZMod q)) t=𝔼 x : ZMod q, f x := by + have he := (expect_zmod_range (fun x : ZMod t => f (ZMod.castHom hqt (ZMod q) x))).symm + simp only [map_natCast] at he + apply he.trans + exact expect_surjective_addHom (ZMod.castHom hqt (ZMod q)).toAddMonoidHom + (ZMod.ringHom_surjective _) f + +lemma rational_periodic_coefficient {q : ℕ} [NeZero q] (b : ℚ) (hbq : b.den∣q) + (v : ZMod q → ℂ) : + periodicMean (fun m => v ((m+1 : ℕ) : ZMod q)*expPhase ((b : ℝ)*(m+1)^2)) q= + 𝔼 x : ZMod q, v x*rationalChar b (ZMod.castHom hbq (ZMod b.den) (x^2)) := by + have he (m : ℕ) : v (m : ZMod q)*expPhase ((b : ℝ)*(m : ℝ)^2)= + v (m : ZMod q)*rationalChar b (ZMod.castHom hbq (ZMod b.den) ((m : ZMod q)^2)) := by + rw [map_pow,map_natCast,rationalChar_nat_square] + have hs := periodicMean_shift_one + (fun m : ℕ => v (m : ZMod q)*rationalChar b (ZMod.castHom hbq (ZMod b.den) ((m : ZMod q)^2))) q + (zmod_natCast_periodic q (fun x => v x*rationalChar b (ZMod.castHom hbq (ZMod b.den) (x^2)))) + have he' (m : ℕ) : v ((m+1 : ℕ) : ZMod q)*expPhase ((b : ℝ)*(m+1)^2)= + v ((m+1 : ℕ) : ZMod q)*rationalChar b (ZMod.castHom hbq (ZMod b.den) (((m+1 : ℕ) : ZMod q)^2)) := by + simpa only [Nat.cast_add,Nat.cast_one] using he (m+1) + simp_rw [he'] + rw [hs] + exact (expect_zmod_range (fun x : ZMod q => v x*rationalChar b (ZMod.castHom hbq (ZMod b.den) (x^2)))).symm + +section CRTRootSieve + +variable {I : Type*} [Fintype I] [DecidableEq I] + (p m : I → ℕ) [∀i, Fact (p i).Prime] [∀i, NeZero (m i)] + (hm : ∀i, p i∣m i) (R : Finset I) (c : ∀i, ZMod (p i)) + +noncomputable def localRootWeight (i : I) (x : ZMod (m i)) : ℂ := + if i∈R then (residueDensity (hm i) (c i) x : ℂ) else 1 + +noncomputable def localSieveWeight (i : I) (x : ZMod (m i)) : ℂ := + if i∈R then 0 else (primeSieveWeight (p i) (ZMod.castHom (hm i) (ZMod (p i)) x) : ℂ) + +omit [Fintype I] [∀i, NeZero (m i)] in +lemma localRootWeight_natCast (i : I) (n : ℕ) : + localRootWeight p m hm R c i (n : ZMod (m i))= + if i∈R then (if (n : ZMod (p i))=c i then (p i : ℂ) else 0) else 1 := by + unfold localRootWeight residueDensity + simp only [map_natCast] + split_ifs <;> simp + +omit [Fintype I] [∀i, NeZero (m i)] in +lemma localSieveWeight_natCast (i : I) (n : ℕ) : + localSieveWeight p m hm R i (n : ZMod (m i))= + if i∈R then 0 else (primeSieveWeight (p i) (n : ZMod (p i)) : ℂ) := by + unfold localSieveWeight + simp only [map_natCast] + +lemma crt_root_sieve_coefficient {L : ℕ} [NeZero L] + (e : ZMod L ≃+* ∀i, ZMod (m i)) (ψ : AddChar (ZMod L) ℂ) (H : ℝ) : + (∑T∈(univ : Finset I).powerset, if ((∏i∈T, p i : ℕ) : ℝ)≤H then + (-1)^T.card*(𝔼 x : ZMod L, + (∏i, localRootWeight p m hm R c i (e x i))* + (∏i∈T, localSieveWeight p m hm R i (e x i))*ψ (x^2)) else 0)= + truncatedSieveMean univ p H + (rootSieveA p m hm R c (fun i => coordinateChar (ψ.compAddMonoidHom e.symm.toAddMonoidHom) i)) + (rootSieveB p m hm R (fun i => coordinateChar (ψ.compAddMonoidHom e.symm.toAddMonoidHom) i)) := by + have he (T : Finset I) := quadratic_mean_equiv e ψ + (fun x => (∏i, localRootWeight p m hm R c i (x i))*(∏i∈T, localSieveWeight p m hm R i (x i))) + simp_rw [he] + rw [product_sieve_coefficient] + congr 1 <;> funext i + · unfold rootSieveA localRootWeight + split_ifs <;> simp only [one_mul] + · unfold rootSieveB localRootWeight localSieveWeight + split_ifs <;> simp only [mul_zero,zero_mul,expect_const_zero,one_mul] + +lemma periodicMean_crt_root_sieve {L : ℕ} [NeZero L] + (e : ZMod L ≃+* ∀i, ZMod (m i)) (b : ℚ) (hbL : b.den∣L) (H : ℝ) : + (∑T∈(univ : Finset I).powerset, if ((∏i∈T, p i : ℕ) : ℝ)≤H then + (-1)^T.card*periodicMean (fun n : ℕ => + (∏i, localRootWeight p m hm R c i ((n+1 : ℕ) : ZMod (m i)))* + (∏i∈T, localSieveWeight p m hm R i ((n+1 : ℕ) : ZMod (m i)))* + expPhase ((b : ℝ)*(n+1)^2)) L else 0)= + truncatedSieveMean univ p H + (rootSieveA p m hm R c (fun i => coordinateChar + (((rationalChar b).compAddMonoidHom (ZMod.castHom hbL (ZMod b.den)).toAddMonoidHom).compAddMonoidHom e.symm.toAddMonoidHom) i)) + (rootSieveB p m hm R (fun i => coordinateChar + (((rationalChar b).compAddMonoidHom (ZMod.castHom hbL (ZMod b.den)).toAddMonoidHom).compAddMonoidHom e.symm.toAddMonoidHom) i)) := by + rw [← crt_root_sieve_coefficient p m hm R c e + ((rationalChar b).compAddMonoidHom (ZMod.castHom hbL (ZMod b.den)).toAddMonoidHom) H] + apply sum_congr rfl + intro T _ + split_ifs + · congr 1 + have hn (n : ℕ) : e (n : ZMod L)=(fun i => (n : ZMod (m i))) := by + rw [map_natCast] + rfl + have h := rational_periodic_coefficient b hbL + (fun x => (∏i, localRootWeight p m hm R c i (e x i))* + (∏i∈T, localSieveWeight p m hm R i (e x i))) + simp only [hn] at h + exact h + · rfl + +end CRTRootSieve + +lemma primaryModuli_pairwise {I : Type*} (p : I → ℕ) [∀i, Fact (p i).Prime] + (hinj : Function.Injective p) (q : ℕ) : + Pairwise (fun i j => (primaryModulus q (p i)).Coprime (primaryModulus q (p j))) := by + intro i j hij + apply Nat.Coprime.pow + exact (Nat.coprime_primes (Fact.out : (p i).Prime) (Fact.out : (p j).Prime)).mpr + (fun h => hij (hinj h)) + +lemma primary_two_root_zero_of_eq {q p : ℕ} [Fact p.Prime] + (hp : p=2) (c : ZMod p) (hc : c=1) (hm : ¬primaryModulus q p∣8) + (ψ : AddChar (ZMod (primaryModulus q p)) ℂ) (hψ : ψ.IsPrimitive) : + (𝔼 x : ZMod (primaryModulus q p), + (residueDensity (prime_dvd_primaryModulus q p) c x : ℂ)*ψ (x^2))=0 := by + subst p + rw [hc] + exact primary_root_two_zero q hm ψ hψ + +section PrimaryCoefficient + +variable {I : Type*} [Fintype I] [DecidableEq I] + (p : I → ℕ) [∀i, Fact (p i).Prime] (hinj : Function.Injective p) + (q : ℕ) [NeZero q] + (hq : q∣∏i, primaryModulus q (p i)) + +noncomputable def primaryCoordinateChar (ψ : AddChar (ZMod q) ℂ) + (i : I) : AddChar (ZMod (primaryModulus q (p i))) ℂ := + coordinateChar ((ψ.compAddMonoidHom (ZMod.castHom hq (ZMod q)).toAddMonoidHom).compAddMonoidHom + (ZMod.prodEquivPi (fun i => primaryModulus q (p i)) (primaryModuli_pairwise p hinj q)).symm.toAddMonoidHom) i + +lemma primaryCoordinateChar_primitive (ψ : AddChar (ZMod q) ℂ) (hψ : ψ.IsPrimitive) + (i : I) (hi : p i∣q) : (primaryCoordinateChar p hinj q hq ψ i).IsPrimitive := by + exact coordinateChar_inflation_primitive _ hq _ ψ hψ i + (primaryModulus_dvd (NeZero.ne q) (Fact.out : (p i).Prime) hi) + +omit [NeZero q] in +lemma primaryCoordinateChar_trivial (ψ : AddChar (ZMod q) ℂ) + (i : I) (hi : ¬p i∣q) : primaryCoordinateChar p hinj q hq ψ i=1 := by + exact coordinateChar_inflation_trivial _ hq _ ψ i + (primaryModulus_coprime (Fact.out : (p i).Prime) hi) + +noncomputable def primaryActive : Finset I := univ.filter (fun i => p i∣q) + +omit [DecidableEq I] [∀i, Fact (p i).Prime] [NeZero q] in +@[simp] lemma mem_primaryActive (i : I) : i∈primaryActive p q ↔ p i∣q := by + simp only [primaryActive,mem_filter,mem_univ,true_and] + +lemma primary_root_sieve_decay (R : Finset I) (c : ∀i, ZMod (p i)) + (htwo : ∀i, p i=2 → i∈R) (ψ : AddChar (ZMod q) ℂ) (hψ : ψ.IsPrimitive) (H : ℝ) : + ‖truncatedSieveMean univ p H + (rootSieveA p (fun i => primaryModulus q (p i)) (fun i => prime_dvd_primaryModulus q (p i)) R c + (primaryCoordinateChar p hinj q hq ψ)) + (rootSieveB p (fun i => primaryModulus q (p i)) (fun i => prime_dvd_primaryModulus q (p i)) R + (primaryCoordinateChar p hinj q hq ψ))‖≤ + 2^64*(∏i∈primaryActive p q\R, (primaryModulus q (p i) : ℝ))^(-(1 : ℝ)/3) := by + apply rootSieve_decay p (fun i => primaryModulus q (p i)) + (fun i => prime_dvd_primaryModulus q (p i)) R c (primaryCoordinateChar p hinj q hq ψ) + univ (primaryActive p q) (subset_univ _) H (hinj.injOn) + · intro i _; exact primaryModulus_le (Fact.out : (p i).Prime) + · intro i _ hi + exact primaryCoordinateChar_trivial p hinj q hq ψ i (by simpa only [mem_primaryActive] using hi) + · intro i hi + exact primaryCoordinateChar_primitive p hinj q hq ψ hψ i (mem_primaryActive p q i |>.mp (mem_sdiff.mp hi).1) + · intro i hi + exact primaryModulus_odd_unit_two (Fact.out : (p i).Prime) + (fun he => (mem_sdiff.mp hi).2 (htwo i he)) + +lemma primary_root_sieve_odd_zero (R : Finset I) (c : ∀i, ZMod (p i)) + (ψ : AddChar (ZMod q) ℂ) (hψ : ψ.IsPrimitive) (H : ℝ) + (i : I) (hi : i∈R) (hqi : p i∣q) (hpi : p i≠2) (hci : c i≠0) + (hei : primaryModulus q (p i)≠p i) : + truncatedSieveMean univ p H + (rootSieveA p (fun i => primaryModulus q (p i)) (fun i => prime_dvd_primaryModulus q (p i)) R c + (primaryCoordinateChar p hinj q hq ψ)) + (rootSieveB p (fun i => primaryModulus q (p i)) (fun i => prime_dvd_primaryModulus q (p i)) R + (primaryCoordinateChar p hinj q hq ψ))=0 := by + apply rootSieve_zero_of_root p (fun i => primaryModulus q (p i)) + (fun i => prime_dvd_primaryModulus q (p i)) R c (primaryCoordinateChar p hinj q hq ψ) + univ (primaryActive p q) (subset_univ _) H + (fun j _ hj => primaryCoordinateChar_trivial p hinj q hq ψ j (by simpa only [mem_primaryActive] using hj)) i + (mem_inter.mpr ⟨(mem_primaryActive p q i).mpr hqi,hi⟩) + exact primary_root_odd_zero hpi (c i) hci hei _ + (primaryCoordinateChar_primitive p hinj q hq ψ hψ i hqi) + +lemma primary_root_sieve_square_zero (R : Finset I) (c : ∀i, ZMod (p i)) + (ψ : AddChar (ZMod q) ℂ) (hψ : ψ.IsPrimitive) (H : ℝ) + (hH : ((∏i∈primaryActive p q\R, p i : ℕ) : ℝ)≤H) + (i : I) (hi : i∉R) (hqi : p i∣q) (hpi : p i≠2) + (hei : primaryModulus q (p i)≠p i) : + truncatedSieveMean univ p H + (rootSieveA p (fun i => primaryModulus q (p i)) (fun i => prime_dvd_primaryModulus q (p i)) R c + (primaryCoordinateChar p hinj q hq ψ)) + (rootSieveB p (fun i => primaryModulus q (p i)) (fun i => prime_dvd_primaryModulus q (p i)) R + (primaryCoordinateChar p hinj q hq ψ))=0 := by + exact rootSieve_zero_of_squarefactor p (fun i => primaryModulus q (p i)) + (fun i => prime_dvd_primaryModulus q (p i)) R c (primaryCoordinateChar p hinj q hq ψ) + univ (primaryActive p q) (subset_univ _) H + (fun j _ hj => primaryCoordinateChar_trivial p hinj q hq ψ j (by simpa only [mem_primaryActive] using hj)) hH i + (mem_sdiff.mpr ⟨(mem_primaryActive p q i).mpr hqi,hi⟩) hpi + ((primaryModulus_eq_or_square q (p i)).resolve_left hei) + (primaryCoordinateChar_primitive p hinj q hq ψ hψ i hqi) + +omit [NeZero q] in +lemma primary_root_sieve_complete (R : Finset I) (c : ∀i, ZMod (p i)) + (ψ : AddChar (ZMod q) ℂ) (H : ℝ) + (hH : ((∏i∈primaryActive p q\R, p i : ℕ) : ℝ)≤H) + (he : ∀i∈primaryActive p q\R, primaryModulus q (p i)=p i) : + truncatedSieveMean univ p H + (rootSieveA p (fun i => primaryModulus q (p i)) (fun i => prime_dvd_primaryModulus q (p i)) R c + (primaryCoordinateChar p hinj q hq ψ)) + (rootSieveB p (fun i => primaryModulus q (p i)) (fun i => prime_dvd_primaryModulus q (p i)) R + (primaryCoordinateChar p hinj q hq ψ))= + (∏i∈primaryActive p q∩R, + rootSieveA p (fun i => primaryModulus q (p i)) (fun i => prime_dvd_primaryModulus q (p i)) R c + (primaryCoordinateChar p hinj q hq ψ) i)* + ∏i∈primaryActive p q\R, unitQuadraticMean (primaryCoordinateChar p hinj q hq ψ i) := by + rw [rootSieve_complete p (fun i => primaryModulus q (p i)) + (fun i => prime_dvd_primaryModulus q (p i)) R c (primaryCoordinateChar p hinj q hq ψ) + univ (primaryActive p q) (subset_univ _) H + (fun j _ hj => primaryCoordinateChar_trivial p hinj q hq ψ j (by simpa only [mem_primaryActive] using hj)) hH] + congr 1 + apply prod_congr rfl + intro i hi + simp only [rootSieveA,rootSieveB,ite_eq_right (mem_sdiff.mp hi).2] + exact prime_unit_quadratic_of_eq (prime_dvd_primaryModulus q (p i)) (he i hi) _ + +lemma primary_root_sieve_tail (R : Finset I) (c : ∀i, ZMod (p i)) + (htwo : ∀i, p i=2 → i∈R) (ψ : AddChar (ZMod q) ℂ) (hψ : ψ.IsPrimitive) + (H : ℝ) (hH : 0 primaryModulus q (p i)) (fun i => prime_dvd_primaryModulus q (p i)) R c + (primaryCoordinateChar p hinj q hq ψ)) + (rootSieveB p (fun i => primaryModulus q (p i)) (fun i => prime_dvd_primaryModulus q (p i)) R + (primaryCoordinateChar p hinj q hq ψ))‖≤2^64*H^(-(1 : ℝ)/3) := by + apply (primary_root_sieve_decay p hinj q hq R c htwo ψ hψ H).trans + apply mul_le_mul_of_nonneg_left _ (by positivity) + apply Real.rpow_le_rpow_of_nonpos hH + · exact htail.trans (Finset.prod_le_prod₀ (fun _ _ => Nat.cast_nonneg _) (fun i _ => by + exact_mod_cast primaryModulus_le (q := q) (Fact.out : (p i).Prime))) + · norm_num + +lemma primary_root_sieve_two_zero (R : Finset I) (c : ∀i, ZMod (p i)) + (ψ : AddChar (ZMod q) ℂ) (hψ : ψ.IsPrimitive) (H : ℝ) + (i : I) (hi : i∈R) (hqi : p i∣q) (hpi : p i=2) (hci : c i=1) + (hei : ¬primaryModulus q (p i)∣8) : + truncatedSieveMean univ p H + (rootSieveA p (fun i => primaryModulus q (p i)) (fun i => prime_dvd_primaryModulus q (p i)) R c + (primaryCoordinateChar p hinj q hq ψ)) + (rootSieveB p (fun i => primaryModulus q (p i)) (fun i => prime_dvd_primaryModulus q (p i)) R + (primaryCoordinateChar p hinj q hq ψ))=0 := by + apply rootSieve_zero_of_root p (fun i => primaryModulus q (p i)) + (fun i => prime_dvd_primaryModulus q (p i)) R c (primaryCoordinateChar p hinj q hq ψ) + univ (primaryActive p q) (subset_univ _) H + (fun j _ hj => primaryCoordinateChar_trivial p hinj q hq ψ j (by simpa only [mem_primaryActive] using hj)) i + (mem_inter.mpr ⟨(mem_primaryActive p q i).mpr hqi,hi⟩) + exact primary_two_root_zero_of_eq hpi (c i) hci hei _ + (primaryCoordinateChar_primitive p hinj q hq ψ hψ i hqi) + +end PrimaryCoefficient + +lemma nat_pairwise_coprime_prod_dvd {I : Type*} [DecidableEq I] + (S : Finset I) (m : I → ℕ) (q : ℕ) + (hc : (↑S : Set I).Pairwise (fun i j => (m i).Coprime (m j))) + (hm : ∀i∈S, m i∣q) : (∏i∈S, m i)∣q := by + induction S using Finset.induction_on with + | empty => simp + | @insert a S ha ih => + rw [prod_insert ha] + apply Nat.Coprime.mul_dvd_of_dvd_of_dvd + · apply Nat.Coprime.prod_right + intro i hi + exact hc (mem_insert_self _ _) (mem_insert_of_mem hi) (ne_of_mem_of_not_mem hi ha).symm + · exact hm a (mem_insert_self _ _) + · apply ih + · exact hc.mono (by intro i hi; exact mem_insert_of_mem hi) + · intro i hi; exact hm i (mem_insert_of_mem hi) + +lemma primary_denominator_factor {I : Type*} [Fintype I] [DecidableEq I] + (p : I → ℕ) [∀i, Fact (p i).Prime] (hinj : Function.Injective p) + (q : ℕ) [NeZero q] (hq : q∣∏i, primaryModulus q (p i)) : + q=∏i∈primaryActive p q, primaryModulus q (p i) := by + apply Nat.dvd_antisymm + · have hc : q.Coprime (∏i∈(primaryActive p q)ᶜ, primaryModulus q (p i)) := by + apply Nat.Coprime.prod_right + intro i hi + apply Nat.Coprime.symm + exact primaryModulus_coprime (Fact.out : (p i).Prime) + (by simpa only [mem_compl,mem_primaryActive] using hi) + apply hc.dvd_of_dvd_mul_right + rwa [prod_mul_prod_compl] + · apply nat_pairwise_coprime_prod_dvd + · intro i _ j _ hij; exact primaryModuli_pairwise p hinj q hij + · intro i hi + exact primaryModulus_dvd (NeZero.ne q) (Fact.out : (p i).Prime) ((mem_primaryActive p q i).mp hi) + +lemma primary_denominator_root_factor {I : Type*} [Fintype I] [DecidableEq I] + (p : I → ℕ) [∀i, Fact (p i).Prime] (hinj : Function.Injective p) + (q : ℕ) [NeZero q] (hq : q∣∏i, primaryModulus q (p i)) (R : Finset I) : + q=(∏i∈primaryActive p q∩R, primaryModulus q (p i))* + (∏i∈primaryActive p q\R, primaryModulus q (p i)) := by + rw [prod_inter_mul_prod_sdiff,← primary_denominator_factor p hinj q hq] + +section KernelCoefficient + +variable {I : Type*} [Fintype I] [DecidableEq I] + (p : I → ℕ) [∀ i, Fact (p i).Prime] (hinj : Function.Injective p) + (b : ℚ) (hb : b.den ∣ ∏ i, primaryModulus b.den (p i)) + (R : Finset I) (c : ∀ i, ZMod (p i)) + +noncomputable def primarySieveCoefficient (H : ℝ) : ℂ := + truncatedSieveMean univ p H + (rootSieveA p (fun i => primaryModulus b.den (p i)) + (fun i => prime_dvd_primaryModulus b.den (p i)) R c + (primaryCoordinateChar p hinj b.den hb (rationalChar b))) + (rootSieveB p (fun i => primaryModulus b.den (p i)) + (fun i => prime_dvd_primaryModulus b.den (p i)) R + (primaryCoordinateChar p hinj b.den hb (rationalChar b))) + +noncomputable def primaryModelCoefficient (H : ℝ) : ℂ := + if ((∏ i ∈ primaryActive p b.den \ R, p i : ℕ) : ℝ) ≤ H ∧ + (∀ i ∈ primaryActive p b.den \ R, primaryModulus b.den (p i) = p i) then + (∏ i ∈ primaryActive p b.den ∩ R, + rootSieveA p (fun i => primaryModulus b.den (p i)) + (fun i => prime_dvd_primaryModulus b.den (p i)) R c + (primaryCoordinateChar p hinj b.den hb (rationalChar b)) i) * + ∏ i ∈ primaryActive p b.den \ R, + unitQuadraticMean (primaryCoordinateChar p hinj b.den hb (rationalChar b) i) + else 0 + +lemma primary_coefficient_small (H : ℝ) + (htwo : ∀ i, p i = 2 → i ∈ R) + (hH : ((∏ i ∈ primaryActive p b.den \ R, p i : ℕ) : ℝ) ≤ H) : + primarySieveCoefficient p hinj b hb R c H = + primaryModelCoefficient p hinj b hb R c H := by + classical + let : NeZero b.den := ⟨b.pos.ne'⟩ + unfold primaryModelCoefficient + by_cases he : ∀ i ∈ primaryActive p b.den \ R, primaryModulus b.den (p i) = p i + · rw [ite_eq_left ⟨hH, he⟩] + exact primary_root_sieve_complete p hinj b.den hb R c (rationalChar b) H hH he + · rw [ite_eq_right (fun h => he h.2)] + push Not at he + obtain ⟨i,hi,hei⟩ := he + apply primary_root_sieve_square_zero p hinj b.den hb R c (rationalChar b) + (rationalChar_primitive b) H hH i (mem_sdiff.mp hi).2 + ((mem_primaryActive p b.den i).mp (mem_sdiff.mp hi).1) _ hei + exact fun h2 => (mem_sdiff.mp hi).2 (htwo i h2) + +lemma primary_coefficient_uniform (H : ℝ) (hH : 0 < H) + (htwo : ∀ i, p i = 2 → i ∈ R) : + ‖primarySieveCoefficient p hinj b hb R c H - + primaryModelCoefficient p hinj b hb R c H‖ ≤ 2^64 * H^(-(1 : ℝ)/3) := by + classical + let : NeZero b.den := ⟨b.pos.ne'⟩ + by_cases h : ((∏ i ∈ primaryActive p b.den \ R, p i : ℕ) : ℝ) ≤ H + · rw [primary_coefficient_small p hinj b hb R c H htwo h, sub_self, norm_zero] + positivity + · rw [primaryModelCoefficient,ite_eq_right (fun hh => h hh.1),sub_zero] + exact primary_root_sieve_tail p hinj b.den hb R c htwo (rationalChar b) + (rationalChar_primitive b) H hH (by + simpa only [Nat.cast_prod] using (le_of_lt (lt_of_not_ge h))) + +noncomputable def actualRootWeight (n : ℕ) : ℂ := + ∏ i ∈ R, if (n : ZMod (p i)) = c i then (p i : ℂ) else 0 + +noncomputable def actualSieveWeight (T : Finset I) (n : ℕ) : ℂ := + ∏ i ∈ T, if i ∈ R then 0 else (primeSieveWeight (p i) (n : ZMod (p i)) : ℂ) + +noncomputable def actualDivisorWeight (H : ℝ) (n : ℕ) : ℂ := + actualRootWeight p R c n * + ∑ T ∈ (univ : Finset I).powerset, + if ((∏ i ∈ T, p i : ℕ) : ℝ) ≤ H then + (-1)^T.card * actualSieveWeight p R T n else 0 + +lemma actualRootWeight_local (n : ℕ) : + (∏ i, localRootWeight p (fun i => primaryModulus b.den (p i)) + (fun i => prime_dvd_primaryModulus b.den (p i)) R c i + (n : ZMod (primaryModulus b.den (p i)))) = actualRootWeight p R c n := by + simp only [localRootWeight_natCast, actualRootWeight] + rw [← prod_filter] + simp only [filter_mem_eq_inter, univ_inter] + +omit [Fintype I] in +lemma actualSieveWeight_local (T : Finset I) (n : ℕ) : + (∏ i ∈ T, localSieveWeight p (fun i => primaryModulus b.den (p i)) + (fun i => prime_dvd_primaryModulus b.den (p i)) R i + (n : ZMod (primaryModulus b.den (p i)))) = actualSieveWeight p R T n := by + simp only [localSieveWeight_natCast, actualSieveWeight] + +lemma actualDivisorWeight_coefficient (H : ℝ) : + periodicMean (fun n => actualDivisorWeight p R c H (n+1) * + expPhase ((b : ℝ)*(n+1)^2)) (∏ i, primaryModulus b.den (p i)) = + primarySieveCoefficient p hinj b hb R c H := by + classical + let : NeZero (∏ i, primaryModulus b.den (p i)) := + ⟨(Finset.prod_pos (fun i _ => primaryModulus_pos (Fact.out : (p i).Prime))).ne'⟩ + have h := periodicMean_crt_root_sieve p (fun i => primaryModulus b.den (p i)) + (fun i => prime_dvd_primaryModulus b.den (p i)) R c + (ZMod.prodEquivPi (fun i => primaryModulus b.den (p i)) + (primaryModuli_pairwise p hinj b.den)) b hb H + change _ = primarySieveCoefficient p hinj b hb R c H at h + rw [← h] + unfold periodicMean actualDivisorWeight + simp only [actualRootWeight_local,actualSieveWeight_local] + simp only [mul_sum, sum_mul] + rw [sum_comm] + apply sum_congr rfl + intro T _ + by_cases hT : ((∏ i ∈ T, p i : ℕ) : ℝ) ≤ H + · simp only [ite_eq_left hT] + apply sum_congr rfl + intro n _ + ring + · simp only [ite_eq_right hT,mul_zero,zero_mul,sum_const_zero] + +lemma actualDivisorWeight_coefficient_uniform (H : ℝ) (hH : 0 < H) + (htwo : ∀ i, p i = 2 → i ∈ R) : + ‖periodicMean (fun n => actualDivisorWeight p R c H (n+1) * + expPhase ((b : ℝ)*(n+1)^2)) (∏ i, primaryModulus b.den (p i)) - + primaryModelCoefficient p hinj b hb R c H‖ ≤ 2^64 * H^(-(1 : ℝ)/3) := by + rw [actualDivisorWeight_coefficient p hinj b hb R c] + exact primary_coefficient_uniform p hinj b hb R c H hH htwo + +noncomputable def rootSquareModulus : ℕ := ∏ i ∈ R, if p i = 2 then 8 else p i + +omit [Fintype I] [DecidableEq I] in +lemma rootSquareModulus_pos : 0 < rootSquareModulus p R := by + apply prod_pos + intro i _ + split_ifs + · norm_num + · exact (Fact.out : (p i).Prime).pos + +lemma unitQuadraticMean_norm {S : Type*} [CommRing S] [Fintype S] [DecidableEq S] + (ψ : AddChar S ℂ) : ‖unitQuadraticMean ψ‖ ≤ 1 := by + unfold unitQuadraticMean + apply (RCLike.norm_expect_le (K := ℂ)).trans + simp only [ψ.norm_apply, Fintype.expect_const] + exact le_rfl + +lemma primaryModelCoefficient_norm (H : ℝ) : + ‖primaryModelCoefficient p hinj b hb R c H‖ ≤ 1 := by + classical + unfold primaryModelCoefficient + split_ifs + · rw [norm_mul, norm_prod, norm_prod] + apply le_trans (mul_le_of_le_one_left (by positivity) ?_) ?_ + · apply prod_le_one₀ (fun _ _ => norm_nonneg _) + intro index membership + rw [rootSieveA, ite_eq_left (mem_inter.mp membership).2] + exact residueDensity_quadratic_norm _ _ _ + · apply prod_le_one₀ (fun _ _ => norm_nonneg _) + intro index _ + exact unitQuadraticMean_norm _ + · simp + +lemma primaryModelCoefficient_denominator (H : ℝ) + (htwo : ∀ i, p i = 2 → i ∈ R) + (hc : ∀ i ∈ R, if p i = 2 then c i = 1 else c i ≠ 0) + (hne : primaryModelCoefficient p hinj b hb R c H ≠ 0) : + b.den ∣ rootSquareModulus p R * ∏ i ∈ primaryActive p b.den \ R, p i := by + classical + let : NeZero b.den := ⟨b.pos.ne'⟩ + have hd : ((∏ i ∈ primaryActive p b.den \ R, p i : ℕ) : ℝ) ≤ H ∧ + (∀ i ∈ primaryActive p b.den \ R, primaryModulus b.den (p i) = p i) := by + by_contra hd + exact hne (ite_eq_right hd) + have hs : primarySieveCoefficient p hinj b hb R c H ≠ 0 := by + rwa [primary_coefficient_small p hinj b hb R c H htwo hd.1] + have hr (i : I) (hi : i ∈ primaryActive p b.den ∩ R) : + primaryModulus b.den (p i) ∣ (if p i = 2 then 8 else p i) := by + have hqi : p i ∣ b.den := (mem_primaryActive p b.den i).mp (mem_inter.mp hi).1 + have hiR := (mem_inter.mp hi).2 + by_cases h2 : p i = 2 + · rw [ite_eq_left h2] + by_contra hlarge + apply hs + exact primary_root_sieve_two_zero p hinj b.den hb R c (rationalChar b) + (rationalChar_primitive b) H i hiR hqi h2 (by simpa [h2] using hc i hiR) hlarge + · rw [ite_eq_right h2] + have hm : primaryModulus b.den (p i) = p i := by + by_contra hlarge + apply hs + exact primary_root_sieve_odd_zero p hinj b.den hb R c (rationalChar b) + (rationalChar_primitive b) H i hiR hqi h2 (by simpa [h2] using hc i hiR) hlarge + rw [hm] + have hrprod : (∏ i ∈ primaryActive p b.den ∩ R, primaryModulus b.den (p i)) ∣ + rootSquareModulus p R := by + apply (prod_dvd_prod_of_dvd _ _ hr).trans + exact prod_dvd_prod_of_subset (primaryActive p b.den ∩ R) R + (fun i => if p i = 2 then 8 else p i) inter_subset_right + nth_rw 1 [primary_denominator_root_factor p hinj b.den hb R] + have he : (∏ i ∈ primaryActive p b.den \ R, primaryModulus b.den (p i)) = + ∏ i ∈ primaryActive p b.den \ R, p i := prod_congr rfl hd.2 + rw [he] + exact mul_dvd_mul_right hrprod _ + +lemma primaryModelCoefficient_denominator_le (H : ℝ) + (htwo : ∀ i, p i = 2 → i ∈ R) + (hc : ∀ i ∈ R, if p i = 2 then c i = 1 else c i ≠ 0) + (hne : primaryModelCoefficient p hinj b hb R c H ≠ 0) : + (b.den : ℝ) ≤ rootSquareModulus p R * H := by + have hd : ((∏ i ∈ primaryActive p b.den \ R, p i : ℕ) : ℝ) ≤ H := by + by_contra hd + exact hne (ite_eq_right (fun h => hd h.1)) + have hp : 0 < rootSquareModulus p R * ∏ i ∈ primaryActive p b.den \ R, p i := + mul_pos (rootSquareModulus_pos p R) (prod_pos (fun i _ => (Fact.out : (p i).Prime).pos)) + calc + _ ≤ ((rootSquareModulus p R * ∏ i ∈ primaryActive p b.den \ R, p i : ℕ) : ℝ) := by + exact_mod_cast Nat.le_of_dvd hp (primaryModelCoefficient_denominator p hinj b hb R c H htwo hc hne) + _ = (rootSquareModulus p R : ℝ) * ((∏ i ∈ primaryActive p b.den \ R, p i : ℕ) : ℝ) := by push_cast; rfl + _ ≤ _ := mul_le_mul_of_nonneg_left hd (Nat.cast_nonneg _) + +lemma primaryModelCoefficient_zero_of_denominator (H : ℝ) + (htwo : ∀ i, p i = 2 → i ∈ R) + (hc : ∀ i ∈ R, if p i = 2 then c i = 1 else c i ≠ 0) + (hden : rootSquareModulus p R * H < (b.den : ℝ)) : + primaryModelCoefficient p hinj b hb R c H = 0 := by + by_contra hne + exact (not_le_of_gt hden) (primaryModelCoefficient_denominator_le p hinj b hb R c H htwo hc hne) + +end KernelCoefficient + +end SquareDifference +end + +end OAI diff --git a/lean/OAI/Combinatorics/SquareDifference/ConductorBounds.lean b/lean/OAI/Combinatorics/SquareDifference/ConductorBounds.lean new file mode 100644 index 0000000000000000000000000000000000000000..fdbfd9b884f69ff43e6471f34c12be13f5565b3c --- /dev/null +++ b/lean/OAI/Combinatorics/SquareDifference/ConductorBounds.lean @@ -0,0 +1,527 @@ +import OAI.Combinatorics.SquareDifference.ResidueFourier + +namespace OAI + +section +open Finset +open scoped ComplexConjugate BigOperators +open Filter +open scoped Topology +open Finset Complex +open scoped BigOperators ComplexConjugate +namespace LiftTheory +open Finset +open scoped BigOperators InnerProductSpace ComplexConjugate +namespace SquareDifference + +def HasFourierBound {R : Type*} [CommRing R] [Fintype R] + (ψ : AddChar R ℂ) (w : R → ℂ) (C : ℝ) : Prop := + ∃ c : R → ℂ, (∀x, w x=∑a, c a*ψ (a*x)) ∧ (∑a, ‖c a‖)≤C + +lemma hasFourierBound_of_expansion {R I : Type*} [CommRing R] [Fintype R] [Fintype I] + (ψ : AddChar R ℂ) (w : R → ℂ) (b : I → R) (c : I → ℂ) (C : ℝ) + (hw : ∀x, w x=∑i, c i*ψ (b i*x)) (hc : (∑i, ‖c i‖)≤C) : + HasFourierBound ψ w C := by + classical + refine ⟨fun a => ∑i, if b i=a then c i else 0, ?_, ?_⟩ + · intro x + rw [hw] + simp only [sum_mul, ite_mul, zero_mul] + rw [sum_comm] + apply sum_congr rfl + intro i _ + simp + · calc + _ ≤ ∑a : R, ∑i : I, ‖if b i=a then c i else 0‖ := sum_le_sum fun _ _ => norm_sum_le _ _ + _ = ∑i, ‖c i‖ := by + simp only [apply_ite norm, norm_zero] + rw [sum_comm] + simp + _ ≤ C := hc + +lemma hasFourierBound_one {R : Type*} [CommRing R] [Fintype R] + (ψ : AddChar R ℂ) : HasFourierBound ψ (fun _ => 1) 1 := by + apply hasFourierBound_of_expansion ψ (fun _ => 1) (fun _ : Unit => 0) (fun _ => 1) + · intro x; simp + · simp + +lemma HasFourierBound.mul {R : Type*} [CommRing R] [Fintype R] + {ψ : AddChar R ℂ} {w v : R → ℂ} {C D : ℝ} + (hw : HasFourierBound ψ w C) (hv : HasFourierBound ψ v D) : + HasFourierBound ψ (fun x => w x*v x) (C*D) := by + rcases hw with ⟨c,hc,hC⟩ + rcases hv with ⟨d,hd,hD⟩ + have h0 : 0≤C := (sum_nonneg fun _ _ => norm_nonneg _).trans hC + apply hasFourierBound_of_expansion ψ _ (fun a : R×R => a.1+a.2) + (fun a => c a.1*d a.2) + · intro x + rw [hc, hd, ← univ_product_univ, sum_product, sum_mul] + apply sum_congr rfl + intro a _ + rw [mul_sum] + apply sum_congr rfl + intro b _ + simp only [add_mul, AddChar.map_add_eq_mul] + ring + · rw [← univ_product_univ, sum_product] + simp only [norm_mul, ← mul_sum, ← sum_mul] + exact mul_le_mul hC hD (sum_nonneg fun _ _ => norm_nonneg _) h0 + +lemma hasFourierBound_prod {R I : Type*} [CommRing R] [Fintype R] [DecidableEq I] + (ψ : AddChar R ℂ) (S : Finset I) (w : I → R → ℂ) + (hw : ∀i∈S, HasFourierBound ψ (w i) 1) : + HasFourierBound ψ (fun x => ∏i∈S, w i x) 1 := by + induction S using Finset.induction_on with + | empty => simpa only [prod_empty] using hasFourierBound_one ψ + | @insert a S ha ih => + have h1 := hw a (mem_insert_self _ _) + have h2 := ih (fun i hi => hw i (mem_insert_of_mem hi)) + simpa only [one_mul, prod_insert ha] using h1.mul h2 + +lemma primeSieveWeight_fourier_bound {p k : ℕ} [Fact p.Prime] [NeZero k] + (ψ : AddChar (ZMod (p*k)) ℂ) (hψ : ψ.IsPrimitive) : + HasFourierBound ψ (fun x => (primeSieveWeight p (ZMod.castHom (dvd_mul_right p k) (ZMod p) x) : ℂ)) 1 := by + classical + apply hasFourierBound_of_expansion ψ _ (fun a : ZMod p => zmodScaleHom p k a) + (fun a : ZMod p => if a=0 then 0 else (p-1 : ℂ)⁻¹) + · intro x + rw [primeSieveWeight_fourier_char _ (zmodScale_primitive (NeZero.ne k) ψ hψ)] + simp only [AddChar.compAddMonoidHom_apply, zmodScaleHom_mul, mul_sum, ite_mul, zero_mul] + rw [← sum_erase (univ : Finset (ZMod p)) (a := 0) (f := fun a => if a=0 then 0 else (p-1 : ℂ)⁻¹*ψ (zmodScaleHom p k a*x)) (by simp)] + apply sum_congr rfl + intro a ha + rw [ite_eq_right (mem_erase.mp ha).1] + · have hp : (0:ℝ) ‖if a=0 then (0 : ℂ) else (p-1 : ℂ)⁻¹‖) (by simp)] + have he : (∑a∈(univ : Finset (ZMod p)).erase 0, ‖if a=0 then (0 : ℂ) else (p-1 : ℂ)⁻¹‖)= + ((p : ℝ)-1)*((p : ℝ)-1)⁻¹ := by + calc + _ = ∑_a∈(univ : Finset (ZMod p)).erase 0, ((p : ℝ)-1)⁻¹ := by + apply sum_congr rfl + intro a ha + rw [ite_eq_right (mem_erase.mp ha).1, norm_inv, hn] + _ = _ := by + rw [sum_const, nsmul_eq_mul, card_erase_of_mem (mem_univ 0), card_univ, ZMod.card, + Nat.cast_sub (Fact.out : p.Prime).one_lt.le, Nat.cast_one] + rw [he, mul_inv_cancel₀ hp.ne'] + +lemma HasFourierBound.gauss {R : Type*} [CommRing R] [Fintype R] [DecidableEq R] + {ψ : AddChar R ℂ} {w : R → ℂ} {C : ℝ} (hw : HasFourierBound ψ w C) + (hψ : ψ.IsPrimitive) (a : R) (ha : IsUnit (2*a)) : + ‖𝔼 x, w x*ψ (a*x^2)‖≤C*(Fintype.card R : ℝ)^(-(1:ℝ)/2) := by + rcases hw with ⟨c,hc,hC⟩ + simp_rw [hc] + exact (fourier_weighted_gauss ψ hψ a ha id c).trans + (mul_le_mul_of_nonneg_right hC (Real.rpow_nonneg (Nat.cast_nonneg _) _)) + +lemma primitive_transport {R S : Type*} [CommRing R] [CommRing S] + (e : R ≃+* S) (ψ : AddChar R ℂ) (hψ : ψ.IsPrimitive) : + (ψ.compAddMonoidHom e.symm.toAddMonoidHom).IsPrimitive := by + intro a ha he + apply hψ (show e.symm a≠0 by exact fun h => ha (e.symm.injective (by simpa using h))) + ext x + have h := congrArg (fun φ : AddChar S ℂ => φ (e x)) he + change ψ (e.symm (a*e x))=1 at h + simpa only [AddChar.mulShift_apply, AddChar.one_apply, map_mul, RingEquiv.symm_apply_apply] using h + +lemma primitive_mulShift {R : Type*} [CommRing R] (ψ : AddChar R ℂ) + (hψ : ψ.IsPrimitive) (a : R) (ha : IsUnit a) : (ψ.mulShift a).IsPrimitive := by + intro b hb he + apply hψ (show a*b≠0 by exact fun h => hb ((ha.mul_right_eq_zero).mp h)) + ext x + have h := congrArg (fun φ : AddChar R ℂ => φ x) he + simpa only [AddChar.mulShift_apply, AddChar.one_apply, mul_assoc] using h + +noncomputable def coordinateChar {I : Type*} [DecidableEq I] {R : I → Type*} + [∀i, CommRing (R i)] (ψ : AddChar (∀i, R i) ℂ) (i : I) : AddChar (R i) ℂ := + ψ.compAddMonoidHom (AddMonoidHom.single R i) + +lemma coordinateChar_apply {I : Type*} [DecidableEq I] {R : I → Type*} + [∀i, CommRing (R i)] (ψ : AddChar (∀i, R i) ℂ) (i : I) (x : R i) : + coordinateChar ψ i x=ψ (Pi.single i x) := rfl + +lemma coordinateChar_primitive {I : Type*} [DecidableEq I] {R : I → Type*} + [∀i, CommRing (R i)] (ψ : AddChar (∀i, R i) ℂ) (hψ : ψ.IsPrimitive) (i : I) : + (coordinateChar ψ i).IsPrimitive := by + intro a ha he + have hs : (Pi.single i a : ∀i, R i)≠0 := by + intro h + have hh := congrFun h i + exact ha (by simpa only [Pi.single_eq_same, Pi.zero_apply] using hh) + apply hψ hs + ext x + have h := congrArg (fun φ : AddChar (R i) ℂ => φ (x i)) he + have hm : (Pi.single i a : ∀i, R i)*x=Pi.single i (a*x i) := by + ext j + by_cases hj : j=i + · subst j; simp + · simp [Pi.single_eq_of_ne hj] + simpa only [AddChar.mulShift_apply, coordinateChar_apply, AddChar.one_apply, hm] using h + +lemma addChar_finset_sum {I A : Type*} [AddCommMonoid A] (ψ : AddChar A ℂ) + (S : Finset I) (f : I → A) : ψ (∑i∈S, f i)=∏i∈S, ψ (f i) := by + classical + induction S using Finset.induction_on with + | empty => simp + | @insert a S ha ih => rw [sum_insert ha, prod_insert ha, AddChar.map_add_eq_mul, ih] + +lemma additive_character_product {I : Type*} [Fintype I] [DecidableEq I] + {R : I → Type*} [∀i, CommRing (R i)] (ψ : AddChar (∀i, R i) ℂ) (x : ∀i, R i) : + ψ x=∏i, coordinateChar ψ i (x i) := by + have h : x=∑i, Pi.single i (x i) := by + ext j + simp only [Finset.sum_apply] + rw [sum_eq_single j] + · simp + · intro i _ hij; exact Pi.single_eq_of_ne (Ne.symm hij) _ + · simp + conv_lhs => rw [h] + rw [addChar_finset_sum] + rfl + +lemma complex_expect_pi_prod {I : Type*} [Fintype I] [DecidableEq I] + {X : I → Type*} [∀i, Fintype (X i)] (f : ∀i, X i → ℂ) : + (𝔼 x : ∀i, X i, ∏i, f i (x i))=∏i, 𝔼 t : X i, f i t := by + simp only [expect_eq_sum_div_card, card_univ, Fintype.card_pi, Nat.cast_prod, + Finset.prod_div_distrib] + rw [Fintype.prod_sum] + +lemma product_quadratic_mean {I : Type*} [Fintype I] [DecidableEq I] + {R : I → Type*} [∀i, CommRing (R i)] [∀i, Fintype (R i)] + (ψ : AddChar (∀i, R i) ℂ) (w : ∀i, R i → ℂ) : + (𝔼 x : ∀i, R i, (∏i, w i (x i))*ψ (x^2))= + ∏i, 𝔼 t : R i, w i t*coordinateChar ψ i (t^2) := by + have h (x : ∀i, R i) : (∏i, w i (x i))*ψ (x^2)= + ∏i, w i (x i)*coordinateChar ψ i ((x i)^2) := by + rw [additive_character_product ψ (x^2), ← prod_mul_distrib] + rfl + calc + _ = 𝔼 x : ∀i, R i, ∏i, w i (x i)*coordinateChar ψ i ((x i)^2) := + expect_congr rfl (fun x _ => h x) + _ = _ := complex_expect_pi_prod (I := I) (X := R) + (fun i t => w i t*coordinateChar ψ i (t^2)) + +lemma primeSieveWeight_fourier_dvd {p q : ℕ} [Fact p.Prime] [NeZero q] + (hpq : p∣q) (ψ : AddChar (ZMod q) ℂ) (hψ : ψ.IsPrimitive) : + HasFourierBound ψ (fun x => (primeSieveWeight p (ZMod.castHom hpq (ZMod p) x) : ℂ)) 1 := by + obtain ⟨k,rfl⟩ := hpq + have hk : k≠0 := by + intro h; have hh := NeZero.ne (p*k); simp [h] at hh + let : NeZero k := ⟨hk⟩ + exact primeSieveWeight_fourier_bound ψ hψ + +lemma fiber_gauss_zero_char {p k : ℕ} [NeZero p] [NeZero k] + (hpk : p∣k) (ψ : AddChar (ZMod (p*k)) ℂ) (hψ : ψ.IsPrimitive) (c : ZMod p) + (hc : (2 : ZMod p)*c≠0) : + (𝔼 x : ZMod (p*k), + (if ZMod.castHom (dvd_mul_right p k) (ZMod p) x=c then (p : ℂ) else 0)*ψ (x^2))=0 := by + classical + let φ := ZMod.castHom (dvd_mul_right p k) (ZMod p) + let R := ZMod (p*k) + have ht : φ (k : R)=0 := by + dsimp only [φ] + rw [map_natCast] + exact (ZMod.natCast_eq_zero_iff k p).mpr hpk + have ht2 : (k : R)^2=0 := by + rw [pow_two] + exact zmod_kernel_factor p k (k : R) ht + let ζ := ψ ((2*(c.val : R))*(k : R)) + have hζ : ζ≠1 := by + intro he + have he0 : (2*(c.val : R))*(k : R)=0 := + (hψ.zmod_char_eq_one_iff (p*k) _).mp he + have hz : ((2*(c.val : ℤ) : ℤ) : ZMod p)=0 := + (zmod_factor_zero p k (NeZero.ne k) (2*c.val)).mp (by simpa using he0) + exact hc (by simpa using hz) + have hz : (∑x : R, (if φ x=c then (1 : ℂ) else 0)*ψ (x^2))=0 := by + have h := quadratic_shift_cancellation ψ (1 : R) (k : R) + (fun x => if φ x=c then (1 : ℂ) else 0) ζ hζ + simp only [one_mul] at h + apply h + · exact zmod_fiber_translation p k c (k : R) ht + · intro x hx + have hxc : φ x=c := by + by_contra hh + exact hx (ite_eq_right hh) + have hkern : (x-(c.val : R))*(k : R)=0 := by + apply zmod_kernel_factor p k + change φ (x-(c.val : R))=0 + rw [map_sub, map_natCast, ZMod.natCast_zmod_val, hxc, sub_self] + have hxk : x*(k : R)=(c.val : R)*(k : R) := by linear_combination hkern + apply congrArg ψ + calc + _ = 2*(x*(k : R))+(k : R)^2 := by ring + _ = _ := by rw [hxk, ht2]; ring + rw [expect_eq_sum_div_card] + have hs : (∑x : R, (if φ x=c then (p : ℂ) else 0)*ψ (x^2))= + (p : ℂ)*∑x : R, (if φ x=c then (1 : ℂ) else 0)*ψ (x^2) := by + rw [mul_sum] + apply sum_congr rfl + intro x _ + split_ifs <;> ring + rw [hs,hz,mul_zero,zero_div] + +lemma quadratic_mean_equiv {R S : Type*} [CommRing R] [CommRing S] + [Fintype R] [Fintype S] (e : R ≃+* S) (ψ : AddChar R ℂ) (w : S → ℂ) : + (𝔼 x : R, w (e x)*ψ (x^2))= + 𝔼 x : S, w x*(ψ.compAddMonoidHom e.symm.toAddMonoidHom) (x^2) := by + classical + apply Fintype.expect_equiv e.toEquiv + intro x + change w (e x)*ψ (x^2)=w (e x)*ψ (e.symm ((e x)^2)) + rw [← map_pow, RingEquiv.symm_apply_apply] + +lemma crt_quadratic_mean {I : Type*} [Fintype I] [DecidableEq I] + (m : I → ℕ) [∀i, NeZero (m i)] [NeZero (∏i, m i)] + (hcop : Pairwise (Function.onFun Nat.Coprime m)) + (ψ : AddChar (ZMod (∏i, m i)) ℂ) (w : ∀i, ZMod (m i) → ℂ) : + (𝔼 x : ZMod (∏i, m i), + (∏i, w i (ZMod.prodEquivPi m hcop x i))*ψ (x^2)) = + ∏i, 𝔼 t : ZMod (m i), w i t* + coordinateChar (ψ.compAddMonoidHom (ZMod.prodEquivPi m hcop).symm.toAddMonoidHom) i (t^2) := by + rw [quadratic_mean_equiv (ZMod.prodEquivPi m hcop) ψ (fun x => ∏i, w i (x i))] + exact product_quadratic_mean _ w + +lemma fiber_sum_gauss_zero_char {p k : ℕ} [NeZero p] [NeZero k] + (hpk : p∣k) (ψ : AddChar (ZMod (p*k)) ℂ) (hψ : ψ.IsPrimitive) (c : ZMod p) + (hc : (2 : ZMod p)*c≠0) : + (∑x : ZMod (p*k), + (if ZMod.castHom (dvd_mul_right p k) (ZMod p) x=c then (1 : ℂ) else 0)*ψ (x^2))=0 := by + classical + have h := fiber_gauss_zero_char hpk ψ hψ c hc + rw [expect_eq_sum_div_card, div_eq_zero_iff] at h + have hc0 : (Fintype.card (ZMod (p*k)) : ℂ)≠0 := by + simp only [ZMod.card, ne_eq, Nat.cast_eq_zero] + exact mul_ne_zero (NeZero.ne p) (NeZero.ne k) + have hs := h.resolve_right hc0 + have he : (∑x : ZMod (p*k), + (if ZMod.castHom (dvd_mul_right p k) (ZMod p) x=c then (p : ℂ) else 0)*ψ (x^2))= + (p : ℂ)*(∑x : ZMod (p*k), + (if ZMod.castHom (dvd_mul_right p k) (ZMod p) x=c then (1 : ℂ) else 0)*ψ (x^2)) := by + rw [mul_sum] + apply sum_congr rfl + intro x _ + split_ifs <;> ring + rw [he] at hs + exact (mul_eq_zero.mp hs).resolve_left (by exact_mod_cast NeZero.ne p) + +lemma gauss_zero_of_fiber_char {p k : ℕ} [NeZero p] [NeZero k] + (hpk : p∣k) (ψ : AddChar (ZMod (p*k)) ℂ) (hψ : ψ.IsPrimitive) (w : ZMod p → ℂ) + (hw : ∀c, w c≠0 → (2 : ZMod p)*c≠0) : + (𝔼 x : ZMod (p*k), w (ZMod.castHom (dvd_mul_right p k) (ZMod p) x)*ψ (x^2))=0 := by + classical + rw [expect_eq_sum_div_card, weighted_fiber_sum] + suffices (∑c : ZMod p, w c*∑x : ZMod (p*k), + (if ZMod.castHom (dvd_mul_right p k) (ZMod p) x=c then (1 : ℂ) else 0)*ψ (x^2))=0 by + rw [this, zero_div] + apply sum_eq_zero + intro c _ + by_cases hc : w c=0 + · rw [hc, zero_mul] + · rw [fiber_sum_gauss_zero_char hpk ψ hψ c (hw c hc), mul_zero] + +lemma odd_unit_gauss_zero_char {p k : ℕ} [Fact p.Prime] [NeZero k] + (hp : p≠2) (hpk : p∣k) (ψ : AddChar (ZMod (p*k)) ℂ) (hψ : ψ.IsPrimitive) : + (𝔼 x : ZMod (p*k), + (if ZMod.castHom (dvd_mul_right p k) (ZMod p) x≠0 then (1 : ℂ) else 0)*ψ (x^2))=0 := by + apply gauss_zero_of_fiber_char hpk ψ hψ (fun c => if c≠0 then 1 else 0) + intro c hc + have hc0 : c≠0 := by intro h; simp [h] at hc + have h2 : (2 : ZMod p)≠0 := Ring.two_ne_zero (by simpa only [ZMod.ringChar_zmod_n] using hp) + exact mul_ne_zero h2 hc0 + +lemma two_unit_gauss_zero_char {k : ℕ} [NeZero k] + (hk : 4∣k) (ψ : AddChar (ZMod (4*k)) ℂ) (hψ : ψ.IsPrimitive) : + (𝔼 x : ZMod (4*k), + (if IsUnit (ZMod.castHom (dvd_mul_right 4 k) (ZMod 4) x) then (1 : ℂ) else 0)*ψ (x^2))=0 := by + classical + apply gauss_zero_of_fiber_char hk ψ hψ (fun c => if IsUnit c then 1 else 0) + intro c hc + have hc0 : IsUnit c := by by_contra h; simp [h] at hc + simpa only [mul_one] using four_unit_mul_two isUnit_one hc0 + +lemma finite_complete_sieve {I : Type*} [DecidableEq I] (S : Finset I) (w : I → ℂ) : + (∑T∈S.powerset, (-1 : ℂ)^T.card*∏i∈T, w i)=∏i∈S, (1-w i) := by + have h := Finset.prod_add (fun i => -w i) (fun _ => (1 : ℂ)) S + simp only [Finset.prod_const_one, mul_one, Finset.prod_neg] at h + simpa only [add_comm (-w _) 1, sub_eq_add_neg] using h.symm + +lemma zmodScale_primitive_general {m k : ℕ} [NeZero m] [NeZero k] + (ψ : AddChar (ZMod (m*k)) ℂ) (hψ : ψ.IsPrimitive) : + (ψ.compAddMonoidHom (zmodScaleHom m k)).IsPrimitive := by + intro a ha he + have h := congrArg (fun χ : AddChar (ZMod m) ℂ => χ 1) he + simp only [AddChar.mulShift_apply, mul_one, AddChar.compAddMonoidHom_apply, AddChar.one_apply] at h + have hz := (hψ.zmod_char_eq_one_iff (m*k) _).mp h + apply ha + exact zmodScaleHom_injective m k (NeZero.ne k) (by simpa only [map_zero] using hz) + +noncomputable def residueDensity {m q : ℕ} (hmq : m∣q) (c : ZMod m) (x : ZMod q) : ℝ := + if ZMod.castHom hmq (ZMod m) x=c then m else 0 + +lemma residueDensity_fourier_bound {m k : ℕ} [NeZero m] [NeZero k] + (ψ : AddChar (ZMod (m*k)) ℂ) (hψ : ψ.IsPrimitive) (c : ZMod m) : + HasFourierBound ψ (fun x => (residueDensity (dvd_mul_right m k) c x : ℂ)) m := by + classical + let φ := ZMod.castHom (dvd_mul_right m k) (ZMod m) + let χ := ψ.compAddMonoidHom (zmodScaleHom m k) + have hχ : χ.IsPrimitive := zmodScale_primitive_general ψ hψ + apply hasFourierBound_of_expansion ψ _ (fun a : ZMod m => zmodScaleHom m k a) + (fun a => χ (-a*c)) m + · intro x + have h := AddChar.sum_mulShift (φ x-c) hχ + simp only [ZMod.card, sub_eq_zero, Nat.cast_ite, Nat.cast_zero] at h + have he (a : ZMod m) : χ (-a*c)*ψ (zmodScaleHom m k a*x)=χ (a*(φ x-c)) := by + rw [← zmodScaleHom_mul] + change χ (-a*c)*χ (a*φ x)=χ (a*(φ x-c)) + rw [← AddChar.map_add_eq_mul] + congr 1 + ring + simp_rw [he] + rw [h] + simp only [residueDensity,φ] + split_ifs <;> simp + · simp only [AddChar.norm_apply, sum_const, card_univ, ZMod.card, nsmul_eq_mul, mul_one, le_refl] + +lemma residueDensity_fourier_dvd {m q : ℕ} [NeZero m] [NeZero q] + (hmq : m∣q) (ψ : AddChar (ZMod q) ℂ) (hψ : ψ.IsPrimitive) (c : ZMod m) : + HasFourierBound ψ (fun x => (residueDensity hmq c x : ℂ)) m := by + obtain ⟨k,rfl⟩ := hmq + have hk : k≠0 := by intro hk; have hh := NeZero.ne (m*k); simp [hk] at hh + let : NeZero k := ⟨hk⟩ + exact residueDensity_fourier_bound ψ hψ c + +lemma residueDensity_mean {m q : ℕ} [NeZero m] [NeZero q] + (hmq : m∣q) (c : ZMod m) : (𝔼 x : ZMod q, (residueDensity hmq c x : ℂ))=1 := by + classical + have hsur : Function.Surjective (ZMod.castHom hmq (ZMod m)) := + ZMod.ringHom_surjective _ + have h := expect_surjective_addHom (ZMod.castHom hmq (ZMod m)).toAddMonoidHom hsur + (fun x => if x=c then (m : ℂ) else 0) + have he (x : ZMod q) : (residueDensity hmq c x : ℂ) = + if ZMod.castHom hmq (ZMod m) x=c then (m : ℂ) else 0 := by + unfold residueDensity + split_ifs <;> simp + simp_rw [he] + change (𝔼 x : ZMod q, if ZMod.castHom hmq (ZMod m) x=c then (m : ℂ) else 0)= + (𝔼 x : ZMod m, if x=c then (m : ℂ) else 0) at h + have hm : (m : ℂ)≠0 := by exact_mod_cast NeZero.ne m + simpa only [expect_eq_sum_div_card, sum_ite_eq', mem_univ, ite_true, card_univ, + ZMod.card, div_self hm] using h + +lemma residueDensity_self (m : ℕ) [NeZero m] (c x : ZMod m) : + residueDensity (dvd_refl m) c x = if x=c then (m : ℝ) else 0 := by + have he : ZMod.castHom (dvd_refl m) (ZMod m)=RingHom.id (ZMod m) := Subsingleton.elim _ _ + simp only [residueDensity,he,RingHom.id_apply] + +lemma residueDensity_self_quadratic (m : ℕ) [NeZero m] (c : ZMod m) + (ψ : AddChar (ZMod m) ℂ) : + (𝔼 x : ZMod m, (residueDensity (dvd_refl m) c x : ℂ)*ψ (x^2))=ψ (c^2) := by + classical + have he (x : ZMod m) : (residueDensity (dvd_refl m) c x : ℂ)*ψ (x^2)= + if x=c then (m : ℂ)*ψ (c^2) else 0 := by + rw [residueDensity_self] + split_ifs with hx + · rw [hx]; simp + · simp + simp_rw [he] + simp only [expect_eq_sum_div_card,sum_ite_eq',mem_univ,ite_true,card_univ,ZMod.card] + have hm : (m : ℂ)≠0 := by exact_mod_cast NeZero.ne m + field_simp + +lemma residueDensity_quadratic_zero {p k : ℕ} [NeZero p] [NeZero k] + (hpk : p∣k) (ψ : AddChar (ZMod (p*k)) ℂ) (hψ : ψ.IsPrimitive) + (c : ZMod p) (hc : (2 : ZMod p)*c≠0) : + (𝔼 x : ZMod (p*k), (residueDensity (dvd_mul_right p k) c x : ℂ)*ψ (x^2))=0 := by + have he (x : ZMod (p*k)) : (residueDensity (dvd_mul_right p k) c x : ℂ)= + if ZMod.castHom (dvd_mul_right p k) (ZMod p) x=c then (p : ℂ) else 0 := by + unfold residueDensity + split_ifs <;> simp + simp_rw [he] + exact fiber_gauss_zero_char hpk ψ hψ c hc + +lemma zmod_cast_comp {a b c : ℕ} (hab : a∣b) (hbc : b∣c) : + (ZMod.castHom hab (ZMod a)).comp (ZMod.castHom hbc (ZMod b)) = + ZMod.castHom (hab.trans hbc) (ZMod a) := Subsingleton.elim _ _ + +lemma odd_square_eight (x : ZMod 8) + (hx : ZMod.castHom (by norm_num : 2∣8) (ZMod 2) x=1) : x^2=1 := by + revert x + decide + +lemma odd_square_of_dvd_eight {q : ℕ} [NeZero q] (h2 : 2∣q) (h8 : q∣8) + (x : ZMod q) (hx : ZMod.castHom h2 (ZMod 2) x=1) : x^2=1 := by + obtain ⟨z,rfl⟩ := ZMod.ringHom_surjective (ZMod.castHom h8 (ZMod q)) x + have hz : ZMod.castHom (h2.trans h8) (ZMod 2) z=1 := by + rw [← zmod_cast_comp h2 h8] + exact hx + have h := congrArg (ZMod.castHom h8 (ZMod q)) (odd_square_eight z hz) + simpa only [map_pow,map_one] using h + +lemma odd_root_quadratic_small {q : ℕ} [NeZero q] (h2 : 2∣q) (h8 : q∣8) + (ψ : AddChar (ZMod q) ℂ) : + (𝔼 x : ZMod q, (residueDensity h2 1 x : ℂ)*ψ (x^2))=ψ 1 := by + have he (x : ZMod q) : (residueDensity h2 1 x : ℂ)*ψ (x^2)= + (residueDensity h2 1 x : ℂ)*ψ 1 := by + by_cases hx : ZMod.castHom h2 (ZMod 2) x=1 + · rw [odd_square_of_dvd_eight h2 h8 x hx] + · simp only [residueDensity,ite_eq_right hx,Complex.ofReal_zero,zero_mul] + simp_rw [he] + rw [← expect_mul,residueDensity_mean,one_mul] + +lemma unit_four_iff_odd (x : ZMod 4) : + IsUnit x ↔ ZMod.castHom (by norm_num : 2∣4) (ZMod 2) x=1 := by + revert x + decide + +lemma odd_root_quadratic_large {k : ℕ} [NeZero k] (hk : 4∣k) + (ψ : AddChar (ZMod (4*k)) ℂ) (hψ : ψ.IsPrimitive) : + (𝔼 x : ZMod (4*k), + (residueDensity ((by norm_num : 2∣4).trans (dvd_mul_right 4 k)) 1 x : ℂ)*ψ (x^2))=0 := by + classical + have he (x : ZMod (4*k)) : + (residueDensity ((by norm_num : 2∣4).trans (dvd_mul_right 4 k)) 1 x : ℂ)= + 2*(if IsUnit (ZMod.castHom (dvd_mul_right 4 k) (ZMod 4) x) then (1 : ℂ) else 0) := by + simp only [unit_four_iff_odd] + have hc := DFunLike.congr_fun (zmod_cast_comp (by norm_num : 2∣4) (dvd_mul_right 4 k)) x + change ZMod.castHom (by norm_num : 2∣4) (ZMod 2) + (ZMod.castHom (dvd_mul_right 4 k) (ZMod 4) x)=_ at hc + rw [hc] + unfold residueDensity + split_ifs <;> norm_num + simp_rw [he,mul_assoc] + rw [← mul_expect,two_unit_gauss_zero_char hk ψ hψ,mul_zero] + +noncomputable def localSieveTerm {I : Type*} [DecidableEq I] + (S : Finset I) (a b : I → ℂ) (T : Finset I) : ℂ := + (-1)^T.card*(∏i∈S\T, a i)*∏i∈T, b i + +noncomputable def truncatedSieveMean {I : Type*} [DecidableEq I] + (S : Finset I) (p : I → ℕ) (H : ℝ) (a b : I → ℂ) : ℂ := + ∑T∈S.powerset, if ((∏i∈T, p i : ℕ) : ℝ)≤H then localSieveTerm S a b T else 0 + +lemma localSieveTerm_norm {I : Type*} [DecidableEq I] + (S T : Finset I) (hTS : T⊆S) (a b : I → ℂ) (k : I → ℝ) + (ha : ∀i∈S, ‖a i‖≤k i) (hb : ∀i∈S, ‖b i‖≤k i) : + ‖localSieveTerm S a b T‖≤∏i∈S, k i := by + have hk (i : I) (hi : i∈S) : 0≤k i := (norm_nonneg _).trans (ha i hi) + simp only [localSieveTerm,norm_mul,norm_pow,norm_neg,norm_one,one_pow,one_mul,norm_prod] + calc + _ ≤ (∏i∈S\T, k i)*(∏i∈T, k i) := by + apply mul_le_mul + · exact Finset.prod_le_prod₀ (fun _ _ => norm_nonneg _) (fun i hi => ha i (mem_sdiff.mp hi).1) + · exact Finset.prod_le_prod₀ (fun _ _ => norm_nonneg _) (fun i hi => hb i (hTS hi)) + · exact prod_nonneg (fun _ _ => norm_nonneg _) + · exact prod_nonneg (fun i hi => hk i (mem_sdiff.mp hi).1) + _ = _ := prod_sdiff hTS + +end SquareDifference +end LiftTheory +end + +end OAI diff --git a/lean/OAI/Combinatorics/SquareDifference/CrossProducts.lean b/lean/OAI/Combinatorics/SquareDifference/CrossProducts.lean new file mode 100644 index 0000000000000000000000000000000000000000..83b01e5c301b93abcc41200185a601144a9c764b --- /dev/null +++ b/lean/OAI/Combinatorics/SquareDifference/CrossProducts.lean @@ -0,0 +1,513 @@ +import OAI.Combinatorics.SquareDifference.AffineTuples + +namespace OAI + +section +open Finset +open scoped BigOperators +namespace SquareDifference +open scoped Classical + +lemma crossEdges_factor {I J : Type*} [Fintype I] [Fintype J] + {p : ℕ} [Fact p.Prime] (E : Finset ((I⊕J)×(I⊕J))) + (hnoopp : ∀e∈E, (e.2,e.1)∉E) (x : I → ZMod p) (y : J → ZMod p) : + listKernel (crossEdges E) (crossDir E) x y = + (∏i, ∏j, if (Sum.inl i,Sum.inr j)∈E then squareIndicator (y j-x i) else 1)* + (∏j, ∏i, if (Sum.inr j,Sum.inl i)∈E then squareIndicator (x i-y j) else 1) := by + classical + rw [listKernel, ← Fintype.prod_ite_mem, ← univ_product_univ, prod_product] + rw [prod_comm (f := fun j i => if (Sum.inr j,Sum.inl i)∈E then squareIndicator (x i-y j) else 1)] + rw [← prod_mul_distrib] + apply prod_congr rfl; intro i _ + rw [← prod_mul_distrib] + apply prod_congr rfl; intro j _ + by_cases h : (Sum.inl i,Sum.inr j)∈E + · have h' := hnoopp _ h + simp [crossEdges, crossDir, h, h'] + · by_cases h' : (Sum.inr j,Sum.inl i)∈E <;> simp [crossEdges, crossDir, h, h'] + +lemma graphValidity_singleton_cut {J : Type*} [Fintype J] + {p : ℕ} [Fact p.Prime] (E : Finset ((Unit⊕J)×(Unit⊕J))) + (hnoopp : ∀e∈E, (e.2,e.1)∉E) (hloop : (Sum.inl (),Sum.inl ())∉E) + (x : Unit → ZMod p) (y : J → ZMod p) : + graphValidity E (Sum.elim x y)= + (∏i, ∏j, if (Sum.inr i,Sum.inr j)∈E then squareIndicator (y j-y i) else 1)* + listKernel (crossEdges E) (crossDir E) x y := by + classical + rw [graphValidity_all, Fintype.prod_sum_type] + simp only [Fintype.prod_sum_type, Sum.elim_inl, Sum.elim_inr, prod_mul_distrib] + rw [crossEdges_factor E hnoopp] + simp only [Fintype.prod_unique, show (default : Unit)=() from rfl, ite_eq_right hloop, one_mul] + ring + +noncomputable def tupleZeroIndex : TupleListIndex ∅ := + ⟨0, by simp only [card_empty, pow_zero]; decide⟩ + +instance tupleEmptyIndexSubsingleton : Subsingleton (TupleListIndex ∅) where + allEq i j := by + apply Fin.ext + have hi := i.isLt + have hj := j.isLt + simp only [card_empty, pow_zero] at hi hj + omega + +noncomputable def tupleLeadingEntry : TupleVertex ≃ TupleListEntry ∅ where + toFun v := (tupleProjection ∅ v, tupleZeroIndex) + invFun u b := u.1 ⟨b, by simp⟩ + left_inv v := rfl + right_inv u := by + apply Prod.ext + · rfl + · exact Subsingleton.elim _ _ + +noncomputable def tupleLeadingGraph : Finset (TupleVertex×TupleVertex) := + graphPullback tupleLeadingEntry (tupleListEdges ∅) + +lemma graphPullback_no_opp {I K : Type*} [Fintype I] (e : I ≃ K) + (E : Finset (K×K)) (hE : ∀u∈E, (u.2,u.1)∉E) : + ∀u∈graphPullback e E, (u.2,u.1)∉graphPullback e E := by + intro u hu hn + have h1 : (e u.1,e u.2)∈E := (mem_filter.mp hu).2 + have h2 : (e u.2,e u.1)∈E := (mem_filter.mp hn).2 + exact hE (e u.1,e u.2) h1 h2 + +lemma graphPullback_no_loop {I K : Type*} [Fintype I] (e : I ≃ K) + (E : Finset (K×K)) (hE : ∀u∈E, u.1≠u.2) (v : I) : + (v,v)∉graphPullback e E := by + intro hv + exact hE (e v,e v) (mem_filter.mp hv).2 rfl + +lemma tupleLeadingGraph_no_opp : ∀e∈tupleLeadingGraph, (e.2,e.1)∉tupleLeadingGraph := + graphPullback_no_opp tupleLeadingEntry (tupleListEdges ∅) (tupleListEdges_no_opp ∅) + +lemma tupleLeadingGraph_no_loop (v : TupleVertex) : (v,v)∉tupleLeadingGraph := + graphPullback_no_loop tupleLeadingEntry (tupleListEdges ∅) (tupleListEdges_no_loop ∅) v + +lemma tupleComponent_leading_integral {p : ℕ} [Fact p.Prime] + (F : (TupleVertex → ZMod p) → ℝ) : + tupleComponent ∅ F=𝔼 z, graphValidity tupleLeadingGraph z*F z := by + classical + have ho (Y : TupleListEntry ∅ → ZMod p) (j : TupleVertex → TupleListIndex ∅) : + tupleOutput ∅ Y j=Y ∘ tupleLeadingEntry := by + funext v + change Y (tupleProjection ∅ v, j v)=Y (tupleProjection ∅ v,tupleZeroIndex) + rw [Subsingleton.elim (j v) tupleZeroIndex] + simp only [tupleComponent, tupleWeight_empty, mul_one, ho, Fintype.expect_const] + rw [expect_precompose tupleLeadingEntry.symm] + apply expect_congr rfl; intro z _ + have he : (z ∘ tupleLeadingEntry.symm) ∘ tupleLeadingEntry=z := by ext v; simp + rw [he] + change graphValidity (tupleListEdges ∅) (z ∘ tupleLeadingEntry.symm)*F z=_ + rw [← graphValidity_pullback tupleLeadingEntry (tupleListEdges ∅) (z ∘ tupleLeadingEntry.symm)] + rw [he] + rfl + +noncomputable def graphCondConstant {V : Type*} [Fintype V] [DecidableEq V] + (E : Finset (V×V)) (v : V) : ℝ := + let m := (crossEdges (graphPullback (splitIndex v) E)).card + (2/(1/2 : ℝ)^m+4/((1/2 : ℝ)^m)^2)*((32*m : ℝ)^((1:ℝ)/4))^2 + +lemma graphCondConstant_nonneg {V : Type*} [Fintype V] [DecidableEq V] + (E : Finset (V×V)) (v : V) : 0 ≤ graphCondConstant E v := by + unfold graphCondConstant; positivity + +lemma mem_graphPullback {I K : Type*} [Fintype I] (e : I ≃ K) + (E : Finset (K×K)) (u : I×I) : u∈graphPullback e E ↔ (e u.1,e u.2)∈E := by + simp only [graphPullback, mem_filter, mem_univ, true_and] + +noncomputable def graphRest {J : Type*} [Fintype J] {p : ℕ} [Fact p.Prime] + (E : Finset ((Unit⊕J)×(Unit⊕J))) (y : J → ZMod p) : ℝ := + ∏i, ∏j, if (Sum.inr i,Sum.inr j)∈E then squareIndicator (y j-y i) else 1 + +lemma graphRest_le_one {J : Type*} [Fintype J] {p : ℕ} [Fact p.Prime] + (E : Finset ((Unit⊕J)×(Unit⊕J))) (y : J → ZMod p) : graphRest E y≤1 := by + unfold graphRest + apply prod_le_one₀ + · intro i _; apply prod_nonneg; intro j _; split <;> first | exact squareIndicator_nonneg _ | norm_num + · intro i _; apply prod_le_one₀ + · intro j _; split <;> first | exact squareIndicator_nonneg _ | norm_num + · intro j _; split <;> first | exact squareIndicator_le_one _ | norm_num + +lemma split_merge {V X : Type*} [DecidableEq V] (v : V) + (x : Unit → X) (y : {w : V // w≠v} → X) : + ((Equiv.funSplitAt v X).symm (x (),y)) ∘ splitIndex v=Sum.elim x y := by + funext i + cases i with + | inl i => cases i; simp [Equiv.funSplitAt, Equiv.piSplitAt, splitIndex] + | inr i => simp [Equiv.funSplitAt, Equiv.piSplitAt, splitIndex, i.property] + +lemma graphValidity_singleton_reindex {V : Type*} [Fintype V] [DecidableEq V] + {p : ℕ} [Fact p.Prime] (E : Finset (V×V)) (hE : ∀u∈E, (u.2,u.1)∉E) + (hl : ∀v, (v,v)∉E) (v : V) (x : Unit → ZMod p) (y : {w : V // w≠v} → ZMod p) : + graphValidity E ((Equiv.funSplitAt v (ZMod p)).symm (x (),y))= + graphRest (graphPullback (splitIndex v) E) y* + listKernel (crossEdges (graphPullback (splitIndex v) E)) + (crossDir (graphPullback (splitIndex v) E)) x y := by + rw [← graphValidity_pullback (splitIndex v) E ((Equiv.funSplitAt v (ZMod p)).symm (x (),y)), + split_merge] + apply graphValidity_singleton_cut + · exact graphPullback_no_opp (splitIndex v) E hE + · intro h + exact hl v ((mem_graphPullback (splitIndex v) E _).mp h) + +lemma singleton_list_conditional_mixing {J : Type*} [Fintype J] [DecidableEq J] + {p : ℕ} [Fact p.Prime] (hp : p≠2) + (E : Finset (Unit × J)) (dir : Unit → J → Bool) + (L : (J → ZMod p) → ℝ) (hL : ∀y, L y≤1) + (f : ZMod p → ℝ) (hf : (𝔼 x, f x)=0) : + conditionalEnergy (fun x y => L y*listKernel E dir (fun _ => x) y) f ≤ + ((2/(1/2 : ℝ)^E.card+4/((1/2 : ℝ)^E.card)^2)* + ((32*E.card : ℝ)^((1:ℝ)/4))^2)*(p : ℝ)^(-(1:ℝ)/4)*(𝔼 x, f x^2) := by + have hex (g : ZMod p → ℝ) : (𝔼 x : Unit → ZMod p, g (x ()))=𝔼 x, g x := + Fintype.expect_equiv (Equiv.funUnique Unit (ZMod p)) _ _ (fun _ => rfl) + have hfun (x : Unit → ZMod p) : (fun _ : Unit => x ())=x := by ext i; cases i; rfl + have hh := list_conditional_mixing hp E dir L hL (fun x => f (x ())) (by rw [hex, hf]) + have hpow : ((p : ℝ)^(-(1:ℝ)/8))^2=(p : ℝ)^(-(1:ℝ)/4) := by + rw [← Real.rpow_natCast, ← Real.rpow_mul (Nat.cast_nonneg p)] + congr 1; norm_num + have hid := conditionalEnergy_equiv (Equiv.funUnique Unit (ZMod p)) + (Equiv.refl (J → ZMod p)) (fun x y => L y*listKernel E dir (fun _ => x) y) f + simp only [Equiv.funUnique_apply, Equiv.refl_apply, hfun] at hid + rw [← hid] + have hx : (𝔼 x : Unit → ZMod p, f (x ())^2)=𝔼 x, f x^2 := hex (fun x => f x^2) + simpa only [hx, mul_pow, hpow, mul_assoc] using hh + +lemma graph_conditional_mixing {V : Type*} [Fintype V] [DecidableEq V] + {p : ℕ} [Fact p.Prime] (hp : p≠2) + (E : Finset (V×V)) (hE : ∀u∈E, (u.2,u.1)∉E) + (hl : ∀v, (v,v)∉E) (v : V) (f : ZMod p → ℝ) (hf : (𝔼 x, f x)=0) : + conditionalEnergy (fun x y => graphValidity E ((Equiv.funSplitAt v (ZMod p)).symm (x,y))) f ≤ + graphCondConstant E v*(p : ℝ)^(-(1:ℝ)/4)*(𝔼 x, f x^2) := by + classical + let E' := graphPullback (splitIndex v) E + have hd (x : ZMod p) (y : {w : V // w≠v} → ZMod p) : + graphValidity E ((Equiv.funSplitAt v (ZMod p)).symm (x,y))= + graphRest E' y*listKernel (crossEdges E') (crossDir E') (fun _ => x) y := + graphValidity_singleton_reindex E hE hl v (fun _ => x) y + simp only [hd] + exact singleton_list_conditional_mixing hp (crossEdges E') (crossDir E') + (graphRest E') (graphRest_le_one E') f hf + +lemma tupleLeading_conditional_mixing {p : ℕ} [Fact p.Prime] (hp : p≠2) + (v : TupleVertex) (f : ZMod p → ℝ) (hf : (𝔼 x, f x)=0) : + conditionalEnergy (jointDensity (tupleComponentMap ∅) (Equiv.funSplitAt v (ZMod p))) f ≤ + graphCondConstant tupleLeadingGraph v*(p : ℝ)^(-(1:ℝ)/4)*(𝔼 x, f x^2) := by + have he x y : jointDensity (tupleComponentMap (p := p) ∅) (Equiv.funSplitAt v (ZMod p)) x y= + graphValidity tupleLeadingGraph ((Equiv.funSplitAt v (ZMod p)).symm (x,y)) := + jointDensity_uniform (tupleComponentMap ∅) _ (graphValidity tupleLeadingGraph) + (tupleComponent_leading_integral) x y + rw [show jointDensity (tupleComponentMap (p := p) ∅) (Equiv.funSplitAt v (ZMod p))= + (fun x y => graphValidity tupleLeadingGraph ((Equiv.funSplitAt v (ZMod p)).symm (x,y))) + from funext fun x => funext fun y => he x y] + exact graph_conditional_mixing hp tupleLeadingGraph tupleLeadingGraph_no_opp + tupleLeadingGraph_no_loop v f hf + +lemma tupleComponent_marginal {p : ℕ} [Fact p.Prime] + (S : Finset (Fin tupleBlocks)) (v : TupleVertex) (f : ZMod p → ℝ) : + tupleComponent S (fun z => f (z v))=tupleComponent (p := p) S (fun _ => 1)*(𝔼 x, f x) := by + apply invariant_marginal_uniform (tupleComponentMap S) _ v f + intro a F + change tupleComponent S (fun z => F (fun v => z v+a))=tupleComponent S F + simpa only [one_pow, one_mul] using tupleComponent_affine S 1 a one_ne_zero F + +lemma tupleComponent_conditional_contraction {p : ℕ} [Fact p.Prime] + (S : Finset (Fin tupleBlocks)) (v : TupleVertex) (f : ZMod p → ℝ) : + conditionalEnergy (jointDensity (tupleComponentMap S) (Equiv.funSplitAt v (ZMod p))) f ≤ + tupleComponent (p := p) S (fun _ => 1)*(𝔼 x, f x^2) := by + apply conditionalEnergy_uniform _ f + (jointDensity_nonneg (tupleComponentMap S) _ (tupleComponent_nonneg S)) + intro x + apply jointDensity_marginal + intro g + exact tupleComponent_marginal S v g + +lemma jointDensity_smul {Ω X Y : Type*} [Fintype Ω] [DecidableEq Ω] + (L : (Ω → ℝ) →ₗ[ℝ] ℝ) (e : Ω ≃ X×Y) (c : ℝ) : + jointDensity (c • L) e=fun x y => c*jointDensity L e x y := by + funext x y + simp only [jointDensity, lawDensity, LinearMap.smul_apply, smul_eq_mul] + ring + +lemma jointDensity_sum {Ω X Y I : Type*} [Fintype Ω] [DecidableEq Ω] + (L : I → (Ω → ℝ) →ₗ[ℝ] ℝ) (e : Ω ≃ X×Y) (s : Finset I) : + jointDensity (∑i∈s, L i) e=fun x y => ∑i∈s, jointDensity (L i) e x y := by + funext x y + simp only [jointDensity, lawDensity, LinearMap.sum_apply, mul_sum] + +lemma conditionalEnergy_sum_le {X Y I : Type*} [Fintype X] [Fintype Y] + (s : Finset I) (W : I → X → Y → ℝ) (f : X → ℝ) + (hW : ∀i∈s, ∀x y, 0≤W i x y) : + conditionalEnergy (fun x y => ∑i∈s, W i x y) f ≤ + ∑i∈s, conditionalEnergy (W i) f := by + classical + induction s using Finset.induction_on with + | empty => simp [conditionalEnergy] + | @insert i s hi ih => + simp only [sum_insert hi] + exact (conditionalEnergy_add_le _ _ f (hW i (mem_insert_self _ _)) + (fun x y => sum_nonneg fun j hj => hW j (mem_insert_of_mem hj) x y)).trans + (add_le_add_right (ih fun j hj => hW j (mem_insert_of_mem hj)) _) + +noncomputable def tupleSubmixture {p : ℕ} [Fact p.Prime] + (D : Finset (Finset (Fin tupleBlocks))) : ((TupleVertex → ZMod p) → ℝ) →ₗ[ℝ] ℝ := + ∑S∈D, tupleMixtureWeight p S • tupleComponentMap S + +lemma tupleSubmixture_apply {p : ℕ} [Fact p.Prime] + (D : Finset (Finset (Fin tupleBlocks))) (F : (TupleVertex → ZMod p) → ℝ) : + tupleSubmixture D F=∑S∈D, tupleMixtureWeight p S*tupleComponent S F := by + simp only [tupleSubmixture, LinearMap.sum_apply, LinearMap.smul_apply, smul_eq_mul] + rfl + +lemma tupleSubmixture_nonneg {p : ℕ} [Fact p.Prime] + (D : Finset (Finset (Fin tupleBlocks))) (F : (TupleVertex → ZMod p) → ℝ) + (hF : ∀z, 0≤F z) : 0≤tupleSubmixture D F := by + rw [tupleSubmixture_apply] + exact sum_nonneg fun S _ => mul_nonneg (tupleMixtureWeight_nonneg p S) + (tupleComponent_nonneg S F hF) + +lemma tupleSubmixture_mass_lower {p : ℕ} [Fact p.Prime] + (hp : tupleMassThreshold≤(p : ℝ)) (D : Finset (Finset (Fin tupleBlocks))) (hD : ∅∈D) : + tupleLeadingMassLower≤tupleSubmixture (p := p) D (fun _ => 1) := by + refine (tupleLeading_mass_lower hp).trans ?_ + rw [tupleSubmixture_apply] + have h := single_le_sum (s := D) (fun S _ => mul_nonneg (tupleMixtureWeight_nonneg p S) + (tupleComponent_nonneg (p := p) S (fun _ => 1) (fun _ => by norm_num))) hD + simpa [tupleMixtureWeight] using h + +lemma tupleSubmixture_marginal {p : ℕ} [Fact p.Prime] + (D : Finset (Finset (Fin tupleBlocks))) (v : TupleVertex) (f : ZMod p → ℝ) : + tupleSubmixture D (fun z => f (z v))=tupleSubmixture (p := p) D (fun _ => 1)*(𝔼 x, f x) := by + simp only [tupleSubmixture_apply, tupleComponent_marginal, sum_mul, mul_assoc] + +noncomputable def tupleSubLaw {p : ℕ} [Fact p.Prime] + (D : Finset (Finset (Fin tupleBlocks))) : ((TupleVertex → ZMod p) → ℝ) →ₗ[ℝ] ℝ := + (tupleSubmixture (p := p) D (fun _ => 1))⁻¹ • tupleSubmixture D + +lemma tupleSubLaw_probability {p : ℕ} [Fact p.Prime] + (hp : tupleMassThreshold≤(p : ℝ)) (D : Finset (Finset (Fin tupleBlocks))) (hD : ∅∈D) : + tupleSubLaw (p := p) D (fun _ => 1)=1 := by + have hm := lt_of_lt_of_le tupleLeadingMassLower_pos (tupleSubmixture_mass_lower hp D hD) + simp only [tupleSubLaw, LinearMap.smul_apply, smul_eq_mul, inv_mul_cancel₀ hm.ne'] + +lemma tupleSubLaw_nonneg {p : ℕ} [Fact p.Prime] + (D : Finset (Finset (Fin tupleBlocks))) (F : (TupleVertex → ZMod p) → ℝ) + (hF : ∀z, 0≤F z) : 0≤tupleSubLaw D F := + mul_nonneg (inv_nonneg.mpr (tupleSubmixture_nonneg D _ (fun _ => by norm_num))) + (tupleSubmixture_nonneg D F hF) + +lemma tupleSubLaw_marginal {p : ℕ} [Fact p.Prime] + (hp : tupleMassThreshold≤(p : ℝ)) (D : Finset (Finset (Fin tupleBlocks))) (hD : ∅∈D) + (v : TupleVertex) (f : ZMod p → ℝ) : + tupleSubLaw D (fun z => f (z v))=𝔼 x, f x := by + have hm := lt_of_lt_of_le tupleLeadingMassLower_pos (tupleSubmixture_mass_lower hp D hD) + simp only [tupleSubLaw, LinearMap.smul_apply, smul_eq_mul, tupleSubmixture_marginal, + ← mul_assoc, inv_mul_cancel₀ hm.ne', one_mul] + +lemma tupleMixtureWeight_small {p : ℕ} [Fact p.Prime] + (S : Finset (Fin tupleBlocks)) (hS : S≠∅) : + tupleMixtureWeight p S≤(p : ℝ)^(-(1:ℝ)/16) := by + apply Real.rpow_le_rpow_of_exponent_le (by exact_mod_cast (Fact.out : p.Prime).one_lt.le) + have hc : (1 : ℝ)≤S.card := by exact_mod_cast Nat.one_le_iff_ne_zero.mpr (Finset.nonempty_iff_ne_empty.mpr hS).card_ne_zero + linarith + +lemma le_univ_sum_real {I : Type*} [Fintype I] (f : I → ℝ) + (hf : ∀i, 0≤f i) (i : I) : f i≤∑j, f j := + single_le_sum (fun j _ => hf j) (mem_univ i) + +noncomputable def tupleConditionalNumerator : ℝ := + (∑v : TupleVertex, graphCondConstant tupleLeadingGraph v)+ + ((univ : Finset (Finset (Fin tupleBlocks))).card : ℝ)*tupleWeightBound + +lemma tupleConditionalNumerator_nonneg : 0≤tupleConditionalNumerator := by + apply add_nonneg (sum_nonneg fun v _ => graphCondConstant_nonneg _ _) + exact mul_nonneg (Nat.cast_nonneg _) tupleWeightBound_pos.le + +lemma tupleSubmixture_conditional {p : ℕ} [Fact p.Prime] (hp : p≠2) + (D : Finset (Finset (Fin tupleBlocks))) (hD : ∀S∈D, S.card≤tupleT+1) + (v : TupleVertex) (f : ZMod p → ℝ) (hf : (𝔼 x, f x)=0) : + conditionalEnergy (jointDensity (tupleSubmixture D) (Equiv.funSplitAt v (ZMod p))) f ≤ + tupleConditionalNumerator*(p : ℝ)^(-(1:ℝ)/16)*(𝔼 x, f x^2) := by + let R := (p : ℝ)^(-(1:ℝ)/16) + let A := ∑v : TupleVertex, graphCondConstant tupleLeadingGraph v + let W := fun S => jointDensity (tupleComponentMap (p := p) S) (Equiv.funSplitAt v (ZMod p)) + have hR : 0≤R := Real.rpow_nonneg (Nat.cast_nonneg _) _ + have hA : 0≤A := sum_nonneg fun v _ => graphCondConstant_nonneg _ _ + have hf2 : 0≤𝔼 x, f x^2 := expect_nonneg fun x _ => sq_nonneg _ + have hlead : conditionalEnergy (W ∅) f≤A*R*(𝔼 x, f x^2) := by + refine (tupleLeading_conditional_mixing hp v f hf).trans ?_ + apply mul_le_mul_of_nonneg_right _ hf2 + apply mul_le_mul + · exact le_univ_sum_real (graphCondConstant tupleLeadingGraph) + (graphCondConstant_nonneg tupleLeadingGraph) v + · exact Real.rpow_le_rpow_of_exponent_le + (by exact_mod_cast (Fact.out : p.Prime).one_lt.le) (by norm_num) + · exact Real.rpow_nonneg (Nat.cast_nonneg p) _ + · exact hA + have hterm (S) (hS : S∈D) : tupleMixtureWeight p S*conditionalEnergy (W S) f≤ + ((if S=∅ then A else 0)+tupleWeightBound)*R*(𝔼 x, f x^2) := by + by_cases hs : S=∅ + · subst S + simpa only [tupleMixtureWeight, card_empty, Nat.cast_zero, neg_zero, zero_div, + Real.rpow_zero, one_mul, ite_true] using hlead.trans + (mul_le_mul_of_nonneg_right (mul_le_mul_of_nonneg_right + (le_add_of_nonneg_right tupleWeightBound_pos.le) hR) hf2) + · rw [ite_eq_right hs, zero_add] + exact (mul_le_mul_of_nonneg_left (tupleComponent_conditional_contraction S v f) + (tupleMixtureWeight_nonneg p S)).trans (by + rw [← mul_assoc] + apply mul_le_mul_of_nonneg_right _ hf2 + calc + _ ≤ R*tupleWeightBound := mul_le_mul (tupleMixtureWeight_small S hs) + (tupleComponent_mass_le S (hD S hS)) + (tupleComponent_nonneg S _ (fun _ => by norm_num)) hR + _ = _ := mul_comm _ _) + have hsum : (∑S∈D, ((if S=∅ then A else 0)+tupleWeightBound))≤tupleConditionalNumerator := by + rw [sum_add_distrib, sum_ite_eq', sum_const, nsmul_eq_mul] + apply add_le_add + · by_cases hd : (∅ : Finset (Fin tupleBlocks))∈D + · rw [ite_eq_left hd] + · rw [ite_eq_right hd]; exact hA + · apply mul_le_mul_of_nonneg_right _ tupleWeightBound_pos.le + exact_mod_cast card_le_card (subset_univ D) + unfold tupleSubmixture + rw [jointDensity_sum] + simp only [jointDensity_smul] + refine (conditionalEnergy_sum_le D (fun S x y => tupleMixtureWeight p S*W S x y) f + (fun S _ x y => mul_nonneg (tupleMixtureWeight_nonneg p S) + (jointDensity_nonneg _ _ (tupleComponent_nonneg S) x y))).trans ?_ + simp only [conditionalEnergy_smul] + calc + _ ≤ ∑S∈D, ((if S=∅ then A else 0)+tupleWeightBound)*R*(𝔼 x, f x^2) := sum_le_sum hterm + _ = (∑S∈D, ((if S=∅ then A else 0)+tupleWeightBound))*R*(𝔼 x, f x^2) := by rw [sum_mul, sum_mul] + _ ≤ _ := mul_le_mul_of_nonneg_right (mul_le_mul_of_nonneg_right hsum hR) hf2 + +noncomputable def tupleConditionalConstant : ℝ := tupleConditionalNumerator/tupleLeadingMassLower + +noncomputable def tupleConditionalThreshold : ℝ := + max tupleMassThreshold (max 3 (tupleConditionalConstant^32)) + +lemma rpow_absorb_32 {C p : ℝ} (hC : 0≤C) (hp : 0 sq_nonneg _ + rw [tupleSubLaw, jointDensity_smul, conditionalEnergy_smul] + calc + _ ≤ (tupleSubmixture D (fun _ => 1))⁻¹* + (tupleConditionalNumerator*(p : ℝ)^(-(1:ℝ)/16)*(𝔼 x, f x^2)) := + mul_le_mul_of_nonneg_left (tupleSubmixture_conditional hp2 D hD v f hf) (inv_nonneg.mpr hm.le) + _ ≤ tupleLeadingMassLower⁻¹* + (tupleConditionalNumerator*(p : ℝ)^(-(1:ℝ)/16)*(𝔼 x, f x^2)) := by + apply mul_le_mul_of_nonneg_right + · exact inv_anti₀ tupleLeadingMassLower_pos (tupleSubmixture_mass_lower ((le_max_left _ _).trans hp) D hD0) + · exact mul_nonneg (mul_nonneg tupleConditionalNumerator_nonneg + (Real.rpow_nonneg (Nat.cast_nonneg _) _)) hf2 + _ = (tupleConditionalConstant*(p : ℝ)^(-(1:ℝ)/16))*(𝔼 x, f x^2) := by unfold tupleConditionalConstant; ring + _ ≤ _ := mul_le_mul_of_nonneg_right (rpow_absorb_32 + (div_nonneg tupleConditionalNumerator_nonneg tupleLeadingMassLower_pos.le) + (Nat.cast_pos.mpr (Fact.out : p.Prime).pos) + ((le_max_right _ _).trans ((le_max_right _ _).trans hp))) hf2 + +lemma linearMap_expect {Ω I : Type*} [Fintype I] + (L : (Ω → ℝ) →ₗ[ℝ] ℝ) (F : I → Ω → ℝ) : + L (fun z => 𝔼 i, F i z)=𝔼 i, L (F i) := by + rw [show (fun z => 𝔼 i, F i z)=(𝔼 i, F i) from (funext fun z => + (expect_apply univ F z).symm)] + exact map_expect (L.restrictScalars ℚ≥0) F univ + +noncomputable def squarePairAverage {F : Type*} [Field F] [Fintype F] [DecidableEq F] + (g : F → F → ℝ) : ℝ := 𝔼 q : Fˣ, 𝔼 x, g x (x+(q : F)^2) + +lemma square_affine_pair_average {F : Type*} [Field F] [Fintype F] [DecidableEq F] + (g : F → F → ℝ) (x y : F) (hxy : y-x≠0 ∧ IsSquare (y-x)) : + (𝔼 q : Fˣ, 𝔼 a : F, g ((q : F)^2*x+a) ((q : F)^2*y+a))=squarePairAverage g := by + classical + obtain ⟨r, hr⟩ := hxy.2 + have hr0 : r≠0 := by intro hz; simp [hz] at hr; exact hxy.1 hr + have h1 (q : Fˣ) : (𝔼 a : F, g ((q : F)^2*x+a) ((q : F)^2*y+a))= + 𝔼 a : F, g a (a+((q : F)*r)^2) := by + apply Fintype.expect_equiv (Equiv.addLeft ((q : F)^2*x)) + intro a + congr 1 + have h : y=x+r*r := by linear_combination hr + rw [h] + simp only [Equiv.coe_addLeft] + ring + simp only [h1] + unfold squarePairAverage + apply Fintype.expect_equiv (Equiv.mulRight (Units.mk0 r hr0)) + intro q + simp only [Equiv.coe_mulRight, Units.val_mul, Units.val_mk0] + +lemma tupleComponent_pair_congr {p : ℕ} [Fact p.Prime] + (S : Finset (Fin tupleBlocks)) (hS : S.card≤tupleT) (k : ℕ) + (F G : ZMod p → ZMod p → ℝ) + (hFG : ∀x y, y-x≠0 ∧ IsSquare (y-x) → F x y=G x y) : + tupleComponent S (fun z => F (z (cycleVertex k)) (z (cycleVertex (k+1))))= + tupleComponent S (fun z => G (z (cycleVertex k)) (z (cycleVertex (k+1)))) := by + unfold tupleComponent + apply expect_congr rfl; intro Y _ + apply expect_congr rfl; intro j _ + by_cases hY : tupleValidity S Y=0 + · rw [hY]; ring + · dsimp only + rw [hFG _ _ (tuple_cycle_support S hS Y hY j k)] + +lemma tupleComponent_pair_square {p : ℕ} [Fact p.Prime] + (S : Finset (Fin tupleBlocks)) (hS : S.card≤tupleT) (k : ℕ) + (F : ZMod p → ZMod p → ℝ) : + tupleComponent S (fun z => F (z (cycleVertex k)) (z (cycleVertex (k+1))))= + tupleComponent (p := p) S (fun _ => 1)*squarePairAverage F := by + have havg : tupleComponent S (fun z => 𝔼 q : (ZMod p)ˣ, 𝔼 a : ZMod p, + F ((q : ZMod p)^2*z (cycleVertex k)+a) ((q : ZMod p)^2*z (cycleVertex (k+1))+a))= + tupleComponent S (fun z => F (z (cycleVertex k)) (z (cycleVertex (k+1)))) := by + change tupleComponentMap S (fun z => 𝔼 q : (ZMod p)ˣ, 𝔼 a : ZMod p, + F ((q : ZMod p)^2*z (cycleVertex k)+a) ((q : ZMod p)^2*z (cycleVertex (k+1))+a))=_ + rw [linearMap_expect] + simp_rw [linearMap_expect] + have hi (q : (ZMod p)ˣ) (a : ZMod p) : tupleComponentMap S + (fun z => F ((q : ZMod p)^2*z (cycleVertex k)+a) ((q : ZMod p)^2*z (cycleVertex (k+1))+a))= + tupleComponent S (fun z => F (z (cycleVertex k)) (z (cycleVertex (k+1)))) := + tupleComponent_affine S (q : ZMod p) a q.ne_zero + (fun z => F (z (cycleVertex k)) (z (cycleVertex (k+1)))) + simp only [hi, Fintype.expect_const] + rw [← havg] + have he := tupleComponent_pair_congr S hS k + (fun x y => 𝔼 q : (ZMod p)ˣ, 𝔼 a : ZMod p, F ((q : ZMod p)^2*x+a) ((q : ZMod p)^2*y+a)) + (fun _ _ => squarePairAverage F) (fun x y h => square_affine_pair_average F x y h) + exact he.trans (by + change tupleComponentMap S (fun _ => squarePairAverage F)=_ + have hc : (fun _ : TupleVertex → ZMod p => squarePairAverage F)=squarePairAverage F • (fun _ => (1:ℝ)) := by + ext; simp + rw [hc, map_smul, smul_eq_mul] + exact mul_comm _ _) + +lemma expect_eval {I X : Type*} [Fintype I] [DecidableEq I] [Fintype X] [Nonempty X] + (i : I) (f : X → ℝ) : (𝔼 Y : I → X, f (Y i))=𝔼 x, f x := by + have h := Fintype.expect_equiv (Equiv.funSplitAt i X) (fun Y => f (Y i)) + (fun z => f z.1) (fun _ => rfl) + rw [h, ← univ_product_univ, expect_product] + simp only [Fintype.expect_const] + +end SquareDifference +end + +end OAI diff --git a/lean/OAI/Combinatorics/SquareDifference/CyclicIndicator.lean b/lean/OAI/Combinatorics/SquareDifference/CyclicIndicator.lean new file mode 100644 index 0000000000000000000000000000000000000000..2b5493d745bda76856eac87e75a236fbaec4024c --- /dev/null +++ b/lean/OAI/Combinatorics/SquareDifference/CyclicIndicator.lean @@ -0,0 +1,118 @@ +import OAI.Combinatorics.SquareDifference.ExtendedPair + +namespace OAI + +section + +open Finset + +open scoped BigOperators ComplexConjugate + +namespace SquareDifference + +open LiftTheory.SquareDifference + +lemma sum_zmod_val {E : Type*} [AddCommMonoid E] (q : ℕ) [NeZero q] (f : ℕ → E) : + (∑z : ZMod q,f z.val)=∑n∈range q,f n := by + apply sum_bij (fun z _ => z.val) + · intro z _; exact mem_range.mpr (ZMod.val_lt z) + · intro x _ y _ h; exact ZMod.val_injective q h + · intro n hn + refine ⟨(n:ZMod q),mem_univ _,?_⟩ + simp only [ZMod.val_natCast,Nat.mod_eq_of_lt (mem_range.mp hn)] + · intros; rfl + +lemma sum_zmod_val_support {E : Type*} [AddCommMonoid E] (q : ℕ) [NeZero q] + (N : ℕ) (hN : N≤q) (f : ℕ → E) (hf : ∀n,N≤n → f n=0) : + (∑z : ZMod q,f z.val)=∑n∈range N,f n := by + rw [sum_zmod_val] + symm + exact sum_subset (range_mono hN) (fun n _ hn => hf n (by simpa only [mem_range,not_lt] using hn)) + +section Selected + +variable {J : Type*} [Fintype J] [DecidableEq J] (p : J → ℕ) [instNeZeropj : ∀j,NeZero (p j)] + +noncomputable def selectedIndicator (M a L : ℕ) (A : Finset ℕ) (s : ZMod M) + (B : Finset J) (z : ResidueSpace p) (n : ℕ) : ℝ := + if n∈A ∧ n∈Ico a (a+L) ∧ (n:ZMod M)=s ∧ ∀j∈B,(n:ZMod (p j))=z j then 1 else 0 + +lemma selectedIndicator_bound {J : Type*} + [Fintype J] + [DecidableEq J] + (p : J → ℕ) + [∀ (j : J), NeZero (p j)] (M a L : ℕ) (A : Finset ℕ) (s : ZMod M) + (B : Finset J) (z : ResidueSpace p) (n : ℕ) : |selectedIndicator p M a L A s B z n|≤1 := by + unfold selectedIndicator + split_ifs <;> norm_num + +lemma selectedIndicator_zero {J : Type*} + [Fintype J] + [DecidableEq J] + (p : J → ℕ) + [∀ (j : J), NeZero (p j)] (M a L N : ℕ) (A : Finset ℕ) (hA : A⊆range N) (s : ZMod M) + (B : Finset J) (z : ResidueSpace p) (n : ℕ) (hn : N≤n) : selectedIndicator p M a L A s B z n=0 := by + apply ite_eq_right + intro h + exact (Nat.not_lt.mpr hn) (mem_range.mp (hA h.1)) + +lemma selectedIndicator_mem {J : Type*} + [Fintype J] + [DecidableEq J] + (p : J → ℕ) + [∀ (j : J), NeZero (p j)] (M a L : ℕ) (A : Finset ℕ) (s : ZMod M) + (B : Finset J) (z : ResidueSpace p) (n : ℕ) (hn : selectedIndicator p M a L A s B z n≠0) : + n∈A ∧ n∈Ico a (a+L) ∧ (n:ZMod M)=s ∧ ∀j∈B,(n:ZMod (p j))=z j := by + by_contra h + exact hn (ite_eq_right h) + +lemma selectedIndicator_norm (M a L N : ℕ) (A : Finset ℕ) (hA : A⊆range N) (s : ZMod M) + (B : Finset J) (z : ResidueSpace p) (q : ℕ) [NeZero q] (hN : N≤q) : + (∑x : ZMod q,‖(selectedIndicator p M a L A s B z x.val:ℂ)‖^2)≤N := by + rw [sum_zmod_val_support q N hN (fun n => ‖(selectedIndicator p M a L A s B z n:ℂ)‖^2) + (fun n hn => by rw [selectedIndicator_zero p M a L N A hA s B z n hn]; simp)] + calc + _ ≤ ∑n∈range N,(1:ℝ) := by + apply sum_le_sum + intro n _ + rw [Complex.norm_real,Real.norm_eq_abs] + exact pow_le_one₀ (abs_nonneg _) (selectedIndicator_bound p M a L A s B z n) + _ = _ := by simp + +lemma selectedIndicator_order (M a b L N : ℕ) (hab : a+L≤b) (A : Finset ℕ) (hA : A⊆range N) + (s t : ZMod M) (B : Finset J) (z w : ResidueSpace p) + {q : ℕ} [NeZero q] (x y : ZMod q) + (hxy : (selectedIndicator p M a L A s B z x.val:ℂ)*(selectedIndicator p M b L A t B w y.val:ℂ)≠0) : + x.val simp_all + +lemma cyclicChar_orthogonal (a b : ZMod q) : + (𝔼 x, cyclicChar a x*conj (cyclicChar b x))=if a=b then 1 else 0 := by + classical + have he x : cyclicChar (a-b) x=cyclicChar a x*conj (cyclicChar b x) := by + simp only [cyclicChar, sub_mul] + simp only [sub_eq_add_neg, AddChar.map_add_eq_mul, AddChar.map_neg_eq_conj] + simp_rw [← he] + rw [cyclicChar_expect] + simp only [sub_eq_zero] + +noncomputable def cyclicPolynomial (c : ZMod q → ℂ) (x : ZMod q) : ℂ := + ∑a, c a*cyclicChar a x + +noncomputable def cyclicFourier (f : ZMod q → ℂ) (a : ZMod q) : ℂ := + 𝔼 x, f x*conj (cyclicChar a x) + +lemma cyclicPolynomial_parseval (c : ZMod q → ℂ) : + (𝔼 x, ‖cyclicPolynomial c x‖^2)=∑a, ‖c a‖^2 := by + classical + have he : (𝔼 x, cyclicPolynomial c x*conj (cyclicPolynomial c x))= + ∑a, c a*conj (c a) := by + simp only [cyclicPolynomial, map_sum, sum_mul, mul_sum, map_mul] + rw [expect_sum_comm] + apply sum_congr rfl; intro a _ + rw [expect_sum_comm] + have he a b x : c a*cyclicChar a x*(conj (c b)*conj (cyclicChar b x))= + c a*conj (c b)*(cyclicChar a x*conj (cyclicChar b x)) := by ring + simp only [he, ← mul_expect, cyclicChar_orthogonal] + simp + apply Complex.ofReal_injective + simpa only [Complex.mul_conj', ← Complex.ofReal_pow, ← Complex.ofReal_sum, + ← Complex.ofReal_expect] using he + +lemma cyclicFourier_reconstruction (f : ZMod q → ℂ) (z : ZMod q) : + cyclicPolynomial (cyclicFourier f) z=f z := by + classical + unfold cyclicPolynomial cyclicFourier + simp_rw [Finset.expect_mul] + rw [← expect_sum_comm] + have he x : (∑a, f x*conj (cyclicChar a x)*cyclicChar a z)= + f x*q*(if z=x then 1 else 0) := by + simp_rw [mul_assoc, mul_comm (conj _), ← cyclicChar_sub_right] + rw [← mul_sum] + have hs := cyclicChar_expect (z-x) + simp_rw [cyclicChar_symm _ (z-x)] + rw [expect_eq_sum_div_card] at hs + have hc : (Fintype.card (ZMod q) : ℂ)≠0 := + Nat.cast_ne_zero.mpr Fintype.card_ne_zero + have hs' := (div_eq_iff hc).mp hs + rw [hs'] + simp only [sub_eq_zero, ZMod.card] + ring + simp only [he, expect_eq_sum_div_card, mul_ite, mul_one, mul_zero, + sum_ite_eq, mem_univ, ite_true, card_univ, ZMod.card] + exact mul_div_cancel_right₀ _ (Nat.cast_ne_zero.mpr (NeZero.ne q)) + +lemma cyclicFourier_parseval (f : ZMod q → ℂ) : + (∑a, ‖cyclicFourier f a‖^2)=𝔼 x, ‖f x‖^2 := by + rw [← cyclicPolynomial_parseval] + simp only [cyclicFourier_reconstruction] + +lemma cyclicFourier_neg (f : ZMod q → ℂ) (a : ZMod q) : + cyclicFourier f (-a)=𝔼 x, f x*cyclicChar a x := by + simp only [cyclicFourier, cyclicChar_neg, Complex.conj_conj] + +lemma cyclic_bilinear_fourier (F G k : ZMod q → ℂ) : + (𝔼 x, 𝔼 y, F x*G y*k (y-x))= + ∑a, cyclicFourier k a*cyclicFourier F a*cyclicFourier G (-a) := by + have hk z : k z=∑a, cyclicFourier k a*cyclicChar a z := + (cyclicFourier_reconstruction k z).symm + simp_rw [hk, mul_sum, cyclicChar_sub_right, expect_sum_comm] + apply sum_congr rfl + intro a _ + have he x y : F x*G y*(cyclicFourier k a*(cyclicChar a y*conj (cyclicChar a x)))= + cyclicFourier k a*(F x*conj (cyclicChar a x))*(G y*cyclicChar a y) := by ring + simp_rw [he, ← mul_expect, ← expect_mul] + rw [cyclicFourier_neg, ← mul_expect] + rfl + +lemma cyclic_bilinear_multiplier (F G k : ZMod q → ℂ) + (δ : ℝ) (hδ : 0≤δ) (hk : ∀a, ‖cyclicFourier k a‖≤δ) : + ‖𝔼 x, 𝔼 y, F x*G y*k (y-x)‖≤ + δ*Real.sqrt (𝔼 x, ‖F x‖^2)*Real.sqrt (𝔼 x, ‖G x‖^2) := by + rw [cyclic_bilinear_fourier] + calc + _ ≤ ∑a, ‖cyclicFourier k a*cyclicFourier F a*cyclicFourier G (-a)‖ := norm_sum_le _ _ + _ ≤ δ*∑a, ‖cyclicFourier F a‖*‖cyclicFourier G (-a)‖ := by + rw [mul_sum] + apply sum_le_sum + intro a _ + simp only [norm_mul] + rw [← mul_assoc] + exact mul_le_mul_of_nonneg_right + (mul_le_mul_of_nonneg_right (hk a) (norm_nonneg _)) (norm_nonneg _) + _ ≤ δ*(Real.sqrt (∑a, ‖cyclicFourier F a‖^2)* + Real.sqrt (∑a, ‖cyclicFourier G (-a)‖^2)) := + mul_le_mul_of_nonneg_left (Real.sum_mul_le_sqrt_mul_sqrt _ _ _) hδ + _ = _ := by + have hs : (∑a, ‖cyclicFourier G (-a)‖^2)=∑a, ‖cyclicFourier G a‖^2 := + Fintype.sum_equiv (Equiv.neg (ZMod q)) _ _ (fun a => rfl) + rw [hs, cyclicFourier_parseval, cyclicFourier_parseval] + ring + +lemma cyclic_bilinear_counting (F G k : ZMod q → ℂ) + (δ : ℝ) (hδ : 0≤δ) (hk : ∀a, ‖∑x, k x*conj (cyclicChar a x)‖≤δ) : + ‖∑x, ∑y, F x*G y*k (y-x)‖≤ + δ*Real.sqrt (∑x, ‖F x‖^2)*Real.sqrt (∑x, ‖G x‖^2) := by + have hq : 0<(q:ℝ) := Nat.cast_pos.mpr (NeZero.pos q) + have hq' : (q:ℂ)≠0 := Nat.cast_ne_zero.mpr (NeZero.ne q) + have hf (a : ZMod q) : ‖cyclicFourier k a‖≤δ/q := by + simp only [cyclicFourier,expect_eq_sum_div_card,card_univ,ZMod.card,norm_div, + Complex.norm_natCast] + exact div_le_div_of_nonneg_right (hk a) hq.le + have h := cyclic_bilinear_multiplier F G k (δ/q) (div_nonneg hδ hq.le) hf + have he : (𝔼 x, 𝔼 y, F x*G y*k (y-x))= + (∑x, ∑y, F x*G y*k (y-x))/(q:ℂ)^2 := by + simp only [expect_eq_sum_div_card,card_univ,ZMod.card,← sum_div] + field_simp + rw [he,norm_div,norm_pow,Complex.norm_natCast] at h + simp only [expect_eq_sum_div_card,card_univ,ZMod.card] at h + simp only [Real.sqrt_div' _ hq.le] at h + have hs : Real.sqrt (q:ℝ)*Real.sqrt q=q := Real.mul_self_sqrt hq.le + have hs0 : 0 hut (hinj hu ht h)) + · exact fun hh => (hh ht).elim + +lemma cyclicPush_bilinear_zero {T : Type*} (s : Finset T) (shift : T → ZMod q) + (w : T → ℂ) (F G : ZMod q → ℂ) + (hz : ∀x y t, t∈s → shift t=y-x → F x*G y=0) : + (∑x, ∑y, F x*G y*cyclicPush s shift w (y-x))=0 := by + classical + apply sum_eq_zero; intro x _ + apply sum_eq_zero; intro y _ + rw [cyclicPush,mul_sum] + apply sum_eq_zero; intro t ht + split_ifs with h + · rw [hz x y t ht h,zero_mul] + · exact mul_zero _ + +lemma cyclic_interval_injective {q : ℕ} + [NeZero q] (N : ℕ) (hN : N ((n+1:ℕ):ZMod q)) (range N) := by + intro n hn m hm he + have hn' : n+1 ((n+1:ℕ):ZMod q)) w z=w (z.val-1) := by + have hh : ((z.val-1+1:ℕ):ZMod q)=z := by + rw [Nat.sub_add_cancel hz.1,ZMod.natCast_zmod_val] + rw [← hh] + have hn : z.val-1∈range N := mem_range.mpr (by omega) + convert cyclicPush_point (range N) _ w (cyclic_interval_injective N hN) _ hn using 1 + rw [hh] + +end SequenceKernel + +end SquareDifference + +namespace SquareDifference + +open Finset + +section OrderedModel + +variable {q : ℕ} [NeZero q] + +noncomputable def intervalFourier (N : ℕ) (F : ZMod q → ℂ) (α : ℝ) : ℂ := + (N:ℂ)⁻¹*∑x, F x*expPhase (-(x.val:ℝ)*α) + +noncomputable def intervalModelWeight {B : Type*} [Fintype B] + (N : ℕ) (β : B → ℝ) (c : B → ℂ) (n : ℕ) : ℂ := + (N:ℂ)⁻¹*∑b, c b*expPhase (-β b*((n:ℝ)+1)) + +lemma intervalModel_bilinear {B : Type*} [Fintype B] + (N : ℕ) (hN : N ((n+1:ℕ):ZMod q)) + (intervalModelWeight N β c) (y-x)) : ℂ)/N= + ∑b, c b*intervalFourier N F (-β b)*intervalFourier N G (β b) := by + classical + have he (x y : ZMod q) : F x*G y*cyclicPush (range N) + (fun n => ((n+1:ℕ):ZMod q)) (intervalModelWeight N β c) (y-x)= + (N:ℂ)⁻¹*∑b, c b*(F x*expPhase (-(x.val:ℝ)*(-β b)))* + (G y*expPhase (-(y.val:ℝ)*β b)) := by + by_cases hz : F x*G y=0 + · rw [hz,zero_mul] + symm + rw [mul_eq_zero] + refine Or.inr (sum_eq_zero (fun b _ => ?_)) + calc + _ = c b*(F x*G y)*(expPhase (-(x.val:ℝ)*(-β b))*expPhase (-(y.val:ℝ)*β b)) := by ring + _ = 0 := by rw [hz]; ring + · obtain ⟨hxy,hy⟩ := hord x y hz + have hval : (y-x).val=y.val-x.val := ZMod.val_sub (le_of_lt hxy) + rw [cyclic_interval_point N hN _ _ (by rw [hval]; omega),intervalModelWeight] + have hv : (((y-x).val-1:ℕ):ℝ)+1=(y.val:ℝ)-(x.val:ℝ) := by + rw [hval,Nat.cast_sub (by omega),Nat.cast_sub (by omega)] + norm_num + rw [hv] + simp only [mul_sum] + apply sum_congr rfl + intro b _ + have hp : expPhase (-β b*((y.val:ℝ)-(x.val:ℝ)))= + expPhase (-(x.val:ℝ)*(-β b))*expPhase (-(y.val:ℝ)*β b) := by + rw [← expPhase_add] + congr 1 + ring + rw [hp] + ring + have hswap : (∑x, ∑y, ∑b, c b*(F x*expPhase (-(x.val:ℝ)*(-β b)))* + (G y*expPhase (-(y.val:ℝ)*β b)))= + ∑b, ∑x, ∑y, c b*(F x*expPhase (-(x.val:ℝ)*(-β b)))* + (G y*expPhase (-(y.val:ℝ)*β b)) := by + have hh (x : ZMod q) : (∑y, ∑b, c b*(F x*expPhase (-(x.val:ℝ)*(-β b)))* + (G y*expPhase (-(y.val:ℝ)*β b)))= + ∑b, ∑y, c b*(F x*expPhase (-(x.val:ℝ)*(-β b)))* + (G y*expPhase (-(y.val:ℝ)*β b)) := sum_comm + simp_rw [hh] + exact sum_comm + simp_rw [he] + simp only [← mul_sum] + rw [hswap] + simp only [← mul_sum,← sum_mul] + rw [mul_sum,sum_div] + apply sum_congr rfl + intro b _ + unfold intervalFourier + ring + +end OrderedModel + +end SquareDifference + +namespace SquareDifference + +open Finset + +section KernelTransforms + +variable {q : ℕ} [NeZero q] + +lemma cyclic_square_transform (M N : ℕ) (w : ℕ → ℂ) (a : ZMod q) : + (∑z, cyclicPush (range M) (fun m => (((m+1)^2:ℕ):ZMod q)) + (fun m => (2*((m:ℝ)+1)/(N:ℝ):ℝ) • w (m+1)) z*conj (cyclicChar a z))= + ∑m∈range M, squareWeight N (-(a.val:ℝ)/q) m*w (m+1) := by + rw [cyclicPush_transform] + apply sum_congr rfl + intro m hm + rw [cyclicChar_nat,← expPhase_neg] + have he : -((a.val:ℝ)/q*((((m+1)^2:ℕ):ℝ)))= + (-(a.val:ℝ)/q)*((m:ℝ)+1)^2 := by push_cast; ring + rw [he] + simp only [squareWeight,Complex.real_smul] + ring + +lemma cyclic_model_transform {B : Type*} [Fintype B] + (N : ℕ) (β : B → ℝ) (c : B → ℂ) (a : ZMod q) : + (∑z, cyclicPush (range N) (fun n => ((n+1:ℕ):ZMod q)) + (intervalModelWeight N β c) z*conj (cyclicChar a z))= + ∑b, c b*normalizedLinearSum N (-(a.val:ℝ)/q-β b) := by + rw [cyclicPush_transform] + simp only [intervalModelWeight,cyclicChar_nat,← expPhase_neg,mul_sum,sum_mul] + rw [sum_comm] + apply sum_congr rfl + intro b _ + unfold normalizedLinearSum + simp only [Complex.real_smul,Complex.ofReal_inv,Complex.ofReal_natCast,mul_sum] + apply sum_congr rfl + intro n hn + have he : expPhase (-β b*((n:ℝ)+1))*expPhase (-((a.val:ℝ)/q*((n+1:ℕ):ℝ)))= + expPhase ((-(a.val:ℝ)/q-β b)*((n:ℝ)+1)) := by + rw [← expPhase_add] + congr 1 + push_cast + ring + calc + _ = c b*((N:ℂ)⁻¹*(expPhase (-β b*((n:ℝ)+1))* + expPhase (-((a.val:ℝ)/q*((n+1:ℕ):ℝ))))) := by ring + _ = _ := by rw [he] + +lemma ordered_square_kernel_bilinear {B : Type*} [Fintype B] + (M N : ℕ) (hN : 0 (((m+1)^2:ℕ):ZMod q)) + (fun m => (2*((m:ℝ)+1)/(N:ℝ):ℝ) • w (m+1)) + let k₂ : ZMod q → ℂ := cyclicPush (range N) (fun n => ((n+1:ℕ):ZMod q)) + (intervalModelWeight N β c) + have hk : ∀a, ‖∑z, (k₁ z-k₂ z)*conj (cyclicChar a z)‖≤δ := by + intro a + simp only [sub_mul,sum_sub_distrib] + rw [show (∑z, k₁ z*conj (cyclicChar a z))= + ∑m∈range M, squareWeight N (-(a.val:ℝ)/q) m*w (m+1) from + cyclic_square_transform M N w a] + rw [show (∑z, k₂ z*conj (cyclicChar a z))= + ∑b, c b*normalizedLinearSum N (-(a.val:ℝ)/q-β b) from + cyclic_model_transform N β c a] + exact hkernel _ + have hz : (∑x, ∑y, F x*G y*k₁ (y-x))=0 := + cyclicPush_bilinear_zero _ _ _ F G hsquare + have he := intervalModel_bilinear N hq β c F G hord + have hb := cyclic_bilinear_normalized F G (fun z => k₁ z-k₂ z) N + (Nat.cast_pos.mpr hN) δ hδ hk hF hG + simp only [mul_sub,sum_sub_distrib,hz,zero_sub] at hb + simp only [neg_div,norm_neg,Complex.ofReal_natCast] at hb + exact he ▸ hb + +end KernelTransforms + +end SquareDifference + +namespace SquareDifference + +open Finset + +section ActualBilinear + +variable {I : Type*} [Fintype I] [DecidableEq I] + (p : I → ℕ) [∀i,Fact (p i).Prime] + (R : Finset I) (c : ∀i,ZMod (p i)) + +lemma actual_kernel_ordered_bilinear (hinj : Function.Injective p) + (H : ℝ) (hH : 1≤H) (N : ℕ) (hN : 1≤N) + (hD : (rootSquareModulus p R:ℝ)≤(N:ℝ)^((1:ℝ)/1000)) + (hHn : H≤(N:ℝ)^((1:ℝ)/1000)) (hlarge : 8≤(N:ℝ)^((1:ℝ)/16)) + (hcover : ∀b : ℚ,(b.den:ℝ)≤(N:ℝ)^((1:ℝ)/8) → + b.den∣∏i,primaryModulus b.den (p i)) + (htwo : ∀i,p i=2 → i∈R) + (hc : ∀i∈R,if p i=2 then c i=1 else c i≠0) + {q : ℕ} [NeZero q] (hq : N (b.val:ℝ)) + (fun b => kernelModelCoefficient p R c H b.val) + (kernelAbsoluteConstant*H^(-(1:ℝ)/3)) + · unfold kernelAbsoluteConstant + positivity + · exact actual_kernel_power_error p R c hinj H hH N hN hD hHn hlarge hcover htwo hc + · exact hF + · exact hG + · exact hord + · exact hsquare + +end ActualBilinear + +end SquareDifference + +namespace SquareDifference + +open Finset + +section DualCoordinates + +variable {q : ℕ} [NeZero q] + +noncomputable def standardCharEquiv : ZMod q ≃ AddChar (ZMod q) ℂ := + Equiv.ofBijective (fun a => (ZMod.stdAddChar (N:=q)).mulShift a) (by + rw [Fintype.bijective_iff_injective_and_card,AddChar.card_eq] + refine ⟨?_,rfl⟩ + intro a b h + have h1 := congrArg (fun ψ : AddChar (ZMod q) ℂ => ψ 1) h + simp only [AddChar.mulShift_apply,mul_one] at h1 + exact ZMod.injective_stdAddChar h1) + +lemma standardCharEquiv_apply (a x : ZMod q) : + standardCharEquiv a x=ZMod.stdAddChar (a*x) := rfl + +lemma standardCharEquiv_symm_apply (ψ : AddChar (ZMod q) ℂ) (x : ZMod q) : + ZMod.stdAddChar ((standardCharEquiv (q:=q)).symm ψ*x)=ψ x := by + rw [← standardCharEquiv_apply,(standardCharEquiv (q:=q)).apply_symm_apply] + +lemma standardCharEquiv_zero : standardCharEquiv (0:ZMod q)=1 := by + ext x + simp [standardCharEquiv_apply,AddChar.map_zero_eq_one] + +lemma rationalGrid_char (a : ZMod q) : + (rationalChar (rationalGridPoint q a)).compAddMonoidHom + (ZMod.castHom (rationalGridPoint_den_dvd q a) (ZMod (rationalGridPoint q a).den)).toAddMonoidHom= + standardCharEquiv a := by + ext x + have hx : x=(x.val:ZMod q) := (ZMod.natCast_zmod_val x).symm + rw [hx] + change rationalChar (rationalGridPoint q a) + ((ZMod.castHom (rationalGridPoint_den_dvd q a) (ZMod (rationalGridPoint q a).den)) + (x.val:ZMod q))=ZMod.stdAddChar (a*(x.val:ZMod q)) + rw [map_natCast] + have he := rationalChar_int (rationalGridPoint q a) (x.val:ℤ) + simp only [Int.cast_natCast] at he + rw [he] + have hs := AddChar.map_nsmul_eq_pow (ZMod.stdAddChar (N:=q)) x.val a + simp only [nsmul_eq_mul] at hs + rw [mul_comm a _,hs,stdAddChar_eq_expPhase,← expPhase_nat_mul] + congr 1 + simp only [rationalGridPoint,Rat.cast_div,Rat.cast_natCast] + ring + +end DualCoordinates + +section ProductDual + +variable {I : Type*} [Fintype I] [DecidableEq I] + (m : I → ℕ) [∀i,NeZero (m i)] (hcop : Pairwise fun i j => (m i).Coprime (m j)) + +local instance productModulusNeZero : NeZero (∏i,m i) := + ⟨prod_ne_zero_iff.mpr (fun _ _ => NeZero.ne _)⟩ + +noncomputable def dualCRTCoordinates (a : ZMod (∏i,m i)) (i : I) : ZMod (m i) := + standardCharEquiv.symm + (coordinateChar ((standardCharEquiv a).compAddMonoidHom + (ZMod.prodEquivPi m hcop).symm.toAddMonoidHom) i) + +lemma dualCRTCoordinates_char (a : ZMod (∏i,m i)) (i : I) (x : ZMod (m i)) : + ZMod.stdAddChar (dualCRTCoordinates m hcop a i*x)= + coordinateChar ((standardCharEquiv a).compAddMonoidHom + (ZMod.prodEquivPi m hcop).symm.toAddMonoidHom) i x := by + exact standardCharEquiv_symm_apply _ x + +lemma dualCRTCoordinates_product (a : ZMod (∏i,m i)) (x : ∀i,ZMod (m i)) : + ZMod.stdAddChar (a*(ZMod.prodEquivPi m hcop).symm x)= + ∏i,ZMod.stdAddChar (dualCRTCoordinates m hcop a i*x i) := by + simp_rw [dualCRTCoordinates_char] + exact additive_character_product + ((standardCharEquiv a).compAddMonoidHom (ZMod.prodEquivPi m hcop).symm.toAddMonoidHom) x + +lemma dualCRTCoordinates_injective : Function.Injective (dualCRTCoordinates m hcop) := by + intro a b hab + apply standardCharEquiv.injective + ext x + obtain ⟨y,rfl⟩ := (ZMod.prodEquivPi m hcop).symm.surjective x + change ZMod.stdAddChar (a*(ZMod.prodEquivPi m hcop).symm y)= + ZMod.stdAddChar (b*(ZMod.prodEquivPi m hcop).symm y) + rw [dualCRTCoordinates_product,dualCRTCoordinates_product,hab] + +noncomputable def dualCRTEquiv : ZMod (∏i,m i) ≃ ∀i,ZMod (m i) := + Equiv.ofBijective (dualCRTCoordinates m hcop) (by + rw [Fintype.bijective_iff_injective_and_card] + exact ⟨dualCRTCoordinates_injective m hcop,by simp [Fintype.card_pi]⟩) + +lemma dualCRT_nat (a : ZMod (∏i,m i)) (n : ℕ) : + ZMod.stdAddChar (a*(n:ZMod (∏i,m i)))= + ∏i,ZMod.stdAddChar (dualCRTEquiv m hcop a i*(n:ZMod (m i))) := by + have h := dualCRTCoordinates_product m hcop a (fun _ => (n:_)) + have hn : (ZMod.prodEquivPi m hcop).symm (fun _ => (n:_))=(n:ZMod (∏i,m i)) := by + apply (ZMod.prodEquivPi m hcop).injective + rw [RingEquiv.apply_symm_apply] + simp only [map_natCast] + rfl + rw [hn] at h + exact h + +end ProductDual + +end SquareDifference + +namespace SquareDifference + +open Finset + +section SmallDual + +variable {I : Type*} [Fintype I] [DecidableEq I] + (p : I → ℕ) [∀i,Fact (p i).Prime] (hinj : Function.Injective p) + +local instance smallFactorNeZero (i : I) : NeZero (smallQuadraticModulus (p i)) := + ⟨(smallQuadraticModulus_pos (Fact.out : (p i).Prime)).ne'⟩ + +noncomputable def smallDualEquiv : + ZMod (∏i,smallQuadraticModulus (p i)) ≃ ∀i,ZMod (smallQuadraticModulus (p i)) := + dualCRTEquiv _ (smallQuadraticModuli_pairwise p (fun _ => Fact.out) hinj) + +lemma smallCoordinateChar_grid (a : ZMod (∏i,smallQuadraticModulus (p i))) (i : I) : + smallCoordinateChar p hinj (rationalGridPoint _ a) + (rationalGridPoint_den_dvd _ a) i=standardCharEquiv (smallDualEquiv p hinj a i) := by + ext x + unfold smallCoordinateChar + rw [rationalGrid_char] + symm + exact dualCRTCoordinates_char _ _ a i x + +lemma smallDual_active (a : ZMod (∏i,smallQuadraticModulus (p i))) + (i : I) (h2 : p i≠2) : + p i∣(rationalGridPoint _ a).den ↔ smallDualEquiv p hinj a i≠0 := by + have he := smallCoordinateChar_grid p hinj a i + constructor + · intro hd hz + have hp := smallCoordinateChar_primitive p hinj _ (rationalGridPoint_den_dvd _ a) i h2 hd + rw [he,hz,standardCharEquiv_zero] at hp + have hne : (1:ZMod (smallQuadraticModulus (p i)))≠0 := by + rw [ne_eq,ZMod.one_eq_zero_iff] + simpa only [smallQuadraticModulus,ite_eq_right h2] using (Fact.out : (p i).Prime).ne_one + have hh := hp hne + exact hh (by ext x; simp) + · intro hn + by_contra hd + have ht := smallCoordinateChar_trivial p hinj _ (rationalGridPoint_den_dvd _ a) i hd + rw [he,← standardCharEquiv_zero] at ht + exact hn (standardCharEquiv.injective ht) + +lemma smallDual_support (a : ZMod (∏i,smallQuadraticModulus (p i))) (R : Finset I) + (htwo : ∀i,p i=2 → i∈R) : + primaryActive p (rationalGridPoint _ a).den\R= + Rᶜ.filter (fun i => smallDualEquiv p hinj a i≠0) := by + classical + ext i + by_cases hi : i∈R + · simp [hi] + · have h2 : p i≠2 := fun hh => hi (htwo i hh) + simp only [Finset.mem_sdiff,mem_primaryActive,mem_filter,mem_compl,hi,not_false_eq_true,and_true,true_and] + exact smallDual_active p hinj a i h2 + +lemma kernelModelCoefficient_dual (a : ZMod (∏i,smallQuadraticModulus (p i))) + (R : Finset I) (c : ∀i,ZMod (p i)) (H : ℝ) + (htwo : ∀i,p i=2 → i∈R) (hc : ∀i∈R,p i=2 → c i=1) : + kernelModelCoefficient p R c H (rationalGridPoint _ a)= + if ((∏i∈Rᶜ.filter (fun i => smallDualEquiv p hinj a i≠0),p i : ℕ):ℝ)≤H then + ∏i, if i∈R then ZMod.stdAddChar + (smallDualEquiv p hinj a i*smallRootSquare (p i) (c i)) + else unitQuadraticMean (standardCharEquiv (smallDualEquiv p hinj a i)) + else 0 := by + rw [kernelModelCoefficient_small p hinj R c _ (rationalGridPoint_den_dvd _ a) H htwo hc, + smallDual_support p hinj a R htwo] + simp only [smallCoordinateChar_grid,standardCharEquiv_apply] + +end SmallDual + +end SquareDifference + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SquareDifference/Endpoint.lean b/lean/OAI/Combinatorics/SquareDifference/Endpoint.lean new file mode 100644 index 0000000000000000000000000000000000000000..9e7c370ee01358803b5726306c34dff96fa9a8ba --- /dev/null +++ b/lean/OAI/Combinatorics/SquareDifference/Endpoint.lean @@ -0,0 +1,87 @@ +import OAI.Combinatorics.SquareDifference.PairBridge + +namespace OAI + +section + +open Finset + +open scoped BigOperators + +namespace SquareDifference + +def NatSquareFree (A : Finset ℕ) : Prop := + ∀ a ∈ A, ∀ b ∈ A, ∀ m : ℕ, 1 ≤ m → b ≠ a + m^2 + +noncomputable def natIndicator (A : Finset ℕ) (n : ℕ) : ℝ := if n∈A then 1 else 0 + +lemma natIndicator_bound (A : Finset ℕ) (n : ℕ) : |natIndicator A n|≤1 := by + unfold natIndicator + split_ifs <;> norm_num + +lemma natIndicator_nonneg (A : Finset ℕ) (n : ℕ) : 0≤natIndicator A n := by + unfold natIndicator + split_ifs <;> norm_num + +lemma natIndicator_vanish (N : ℕ) (A : Finset ℕ) (hA : A⊆range N) (n : ℕ) (hn : N≤n) : + natIndicator A n=0 := by + exact ite_eq_right (fun h => (Nat.not_lt.mpr hn) (mem_range.mp (hA h))) + +lemma sum_natIndicator (N : ℕ) (A : Finset ℕ) (hA : A⊆range N) : + (∑n∈range N,natIndicator A n)=(A.card:ℝ) := by + unfold natIndicator + rw [sum_boole] + congr 1 + exact congrArg Finset.card (filter_mem_eq_inter.trans (inter_eq_right.mpr hA)) + +noncomputable def squareChild (A : Finset ℕ) (c D L : ℕ) : Finset ℕ := + (range L).filter (fun t => c+D^2*t∈A) + +lemma squareChild_sub (A : Finset ℕ) (c D L : ℕ) : squareChild A c D L⊆range L := filter_subset _ _ + +lemma squareChild_free (A : Finset ℕ) (hA : NatSquareFree A) (c D L : ℕ) (hD : 0 ht (mem_range.mp ((mem_filter.mp h).1))) + +section Functional + +variable {J : Type} [Fintype J] [DecidableEq J] (p : J → ℕ) [∀j,Fact (p j).Prime] + +noncomputable def setFunctional (N Q : ℕ) (A : Finset ℕ) : ℝ := + diagonalIntegral (productTupleLaw p) (actualTruncatedLift p N Q (natIndicator A)) + +lemma setFunctional_nonneg (hp : ∀j,tupleReflectionThreshold≤(p j:ℝ)) (N Q : ℕ) (A : Finset ℕ) : + 0≤ setFunctional p N Q A := productTupleLaw_diagonal_nonneg p hp _ + +lemma setFunctional_density (hp : ∀j,max tupleMassThreshold tupleReflectionThreshold≤(p j:ℝ)) + (N Q : ℕ) (hQ : 1≤Q) (A : Finset ℕ) (hA : A⊆range N) : + ((A.card:ℝ)/(N:ℝ))^(Fintype.card TupleVertex)≤ setFunctional p N Q A := by + have hm := productTupleLaw_mean p hp (actualTruncatedLift p N Q (natIndicator A)) + rw [PairBridge.actualLift_mean p N Q hQ,sum_natIndicator N A hA] at hm + have h0 : 0≤(A.card:ℝ)/(N:ℝ) := div_nonneg (Nat.cast_nonneg _) (Nat.cast_nonneg _) + rw [show (N:ℝ)⁻¹*(A.card:ℝ)=(A.card:ℝ)/(N:ℝ) by ring,abs_of_nonneg h0] at hm + have hh := pow_le_pow_left₀ h0 hm (Fintype.card TupleVertex) + rw [diagonalRoot_pow _ (productTupleLaw_diagonal_nonneg p (fun j => (le_max_right _ _).trans (hp j)))] at hh + exact hh + +end Functional + +end SquareDifference + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SquareDifference/EulerBudget.lean b/lean/OAI/Combinatorics/SquareDifference/EulerBudget.lean new file mode 100644 index 0000000000000000000000000000000000000000..9d26e6141079859e72c9db30b66d14723cf95c13 --- /dev/null +++ b/lean/OAI/Combinatorics/SquareDifference/EulerBudget.lean @@ -0,0 +1,90 @@ +import OAI.Combinatorics.SquareDifference.FunctionalSplit + +namespace OAI + +section + +open Finset + +namespace SquareDifference + +lemma euler_step_bound {x : ℝ} (hx : 2≤x) : + ((x-1)/x)*(1+1/x^3)≤x/(x+1) := by + have hx0 : 0 + simp only [Ico_self,prod_empty] + have hP0 : (P : ℝ)≠0 := by exact_mod_cast (by omega : P≠0) + have hP1 : (P : ℝ)-1≠0 := by + have hpR : (2 : ℝ)≤P := by exact_mod_cast hP + linarith + field_simp + norm_num + | @succ L hPL ih => + rw [prod_Ico_succ_top hPL] + have hL : (2 : ℝ)≤L := by exact_mod_cast hP.trans hPL + have hC : 0≤(P : ℝ)/(P-1) := by + have hpR : (2 : ℝ)≤P := by exact_mod_cast hP + exact div_nonneg (by positivity) (by linarith) + calc + _ ≤ ((P : ℝ)/(P-1))*(((L : ℝ)-1)/L)*(1+1/(L : ℝ)^3) := + mul_le_mul_of_nonneg_right ih (by positivity) + _ ≤ ((P : ℝ)/(P-1))*((L : ℝ)/(L+1)) := by + rw [mul_assoc] + exact mul_le_mul_of_nonneg_left (euler_step_bound hL) hC + _ = _ := by push_cast; congr 1; ring + +lemma euler_finite_bound (S : Finset ℕ) (hS : ∀n∈S, 5≤n) : + (∏n∈S, (1+1/(n : ℝ)^3))≤5/4 := by + let L := max 5 (S.sup id+1) + have hSL : S⊆Ico 5 L := by + intro n hn + apply mem_Ico.mpr + refine ⟨hS n hn,?_⟩ + exact lt_of_lt_of_le (Nat.lt_succ_of_le (le_sup (f:=id) hn)) (le_max_right _ _) + have h1 : (∏n∈S, (1+1/(n : ℝ)^3))≤∏n∈Ico 5 L, (1+1/(n : ℝ)^3) := by + apply prod_le_prod_of_subset_of_one_le₀ hSL + · intro n hn; positivity + · intro n hn _; linarith [one_div_nonneg.mpr (show 0≤(n : ℝ)^3 by positivity)] + apply h1.trans + apply (euler_interval_bound 5 L (by omega) (le_max_left _ _)).trans + have hL : 0<(L : ℝ) := by exact_mod_cast (lt_of_lt_of_le (by omega : 0<5) (le_max_left _ _)) + norm_num + have hq : ((L : ℝ)-1)/L≤1 := (div_le_one hL).mpr (by linarith) + nlinarith + +lemma weighted_exceptional_budget {I : Type*} [DecidableEq I] + (S : Finset I) (p : I → ℕ) (hinj : Set.InjOn p (↑S : Set I)) + (hp : ∀i∈S, 5≤p i) (η : I → ℝ) + (hη : ∀i∈S, 0≤η i) (hηp : ∀i∈S, η i≤1/(p i : ℝ)^3) : + (∑B∈S.powerset.erase ∅, ∏i∈B, η i)≤1/4 := by + classical + have hprod : (∏i∈S, (1+η i))≤5/4 := by + calc + _ ≤ ∏i∈S, (1+1/(p i : ℝ)^3) := by + apply prod_le_prod₀ (fun i hi => by linarith [hη i hi]) + intro i hi + linarith [hηp i hi] + _ = ∏n∈S.image p, (1+1/(n : ℝ)^3) := (prod_image (f:=fun n : ℕ => (1 : ℝ)+1/(n : ℝ)^3) hinj).symm + _ ≤ 5/4 := euler_finite_bound (S.image p) (by + intro n hn; obtain ⟨i,hi,rfl⟩ := mem_image.mp hn; exact hp i hi) + have he : (∑B∈S.powerset.erase ∅, ∏i∈B, η i)+1=∏i∈S, (1+η i) := by + rw [prod_one_add, ← sum_erase_add _ _ (empty_mem_powerset S)] + simp only [prod_empty] + linarith + +end SquareDifference + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SquareDifference/ExceptionalBasics.lean b/lean/OAI/Combinatorics/SquareDifference/ExceptionalBasics.lean new file mode 100644 index 0000000000000000000000000000000000000000..308339686d978009ab4abee34b875e9de13c7ca7 --- /dev/null +++ b/lean/OAI/Combinatorics/SquareDifference/ExceptionalBasics.lean @@ -0,0 +1,119 @@ +import OAI.Combinatorics.SquareDifference.IntervalContraction + +namespace OAI + +section + +open Finset + +open scoped BigOperators + +namespace SquareDifference + +lemma tupleExceptionalLaw_marginal {p : ℕ} [Fact p.Prime] + (hp : tupleMassThreshold≤(p:ℝ)) (v : TupleVertex) (f : ZMod p → ℝ) : + tupleExceptionalLaw (fun z => f (z v))=tupleEta p*(𝔼 x,f x) := by + have h := congrArg (fun L : ((TupleVertex → ZMod p) → ℝ) →ₗ[ℝ] ℝ => L (fun z => f (z v))) (tupleLaw_decomposition hp) + simp only [LinearMap.add_apply,LinearMap.smul_apply,smul_eq_mul,tupleLaw_marginal hp,tupleGoodLaw_marginal hp] at h + linarith + +lemma tensorLaw_weighted_marginal {J V : Type*} [Fintype J] [DecidableEq J] + [Fintype V] [DecidableEq V] {X : J → Type*} [∀j,Fintype (X j)] + [∀j,DecidableEq (X j)] + (L : ∀j,((V → X j) → ℝ) →ₗ[ℝ] ℝ) (v : V) (c : J → ℝ) + (hm : ∀j (g : X j → ℝ),L j (fun z => g (z v))=c j*(𝔼 x,g x)) + (f : (∀j,X j) → ℝ) : tensorLaw L (fun z => f (z v))=(∏j,c j)*(𝔼 x,f x) := by + have hd (a : ∀j,X j) : tensorLaw L (fun z => if z v=a then 1 else 0)= + (∏j,c j)*(Fintype.card (∀j,X j) : ℝ)⁻¹ := by + have he (z : V → ∀j,X j) : (if z v=a then (1:ℝ) else 0)= + ∏j,if z v j=a j then 1 else 0 := by + rw [prod_indicator_forall] + congr 1 + exact propext (funext_iff) + simp_rw [he] + rw [tensorLaw_fubini L (fun j z => if z v=a j then 1 else 0)] + have hh (j : J) : L j (fun z => if z v=a j then (1:ℝ) else 0)= + c j*(𝔼 x : X j, if x=a j then (1:ℝ) else 0) := hm j (fun x => if x=a j then 1 else 0) + simp_rw [hh] + simp only [prod_mul_distrib,expect_eq_sum_div_card,card_univ,sum_ite_eq',mem_univ,ite_true, + one_div,←prod_inv_distrib,Fintype.card_pi,Nat.cast_prod] + have hf : (fun z : V → ∀j,X j => f (z v))= + ∑a : ∀j,X j,f a • (fun z => if z v=a then (1:ℝ) else 0) := by + funext z + simp only [Finset.sum_apply,Pi.smul_apply,smul_eq_mul,mul_ite,mul_one,mul_zero] + simp + rw [hf,map_sum] + simp only [map_smul,smul_eq_mul,hd,←mul_assoc,←sum_mul,expect_eq_sum_div_card,card_univ,div_eq_mul_inv] + ring + +lemma weighted_uniform_multilinear_crude {V X : Type*} [Fintype V] [DecidableEq V] + [Nontrivial V] [Fintype X] [Nonempty X] + (Llaw : ((V → X) → ℝ) →ₗ[ℝ] ℝ) (hpos : ∀F,(∀z,0≤F z) → 0≤Llaw F) + (c : ℝ) (hc : 0≤c) + (hmar : ∀(v : V) (g : X → ℝ),Llaw (fun z => g (z v))=c*(𝔼 x,g x)) + (F : V → X → ℝ) (R : ℝ) (hR : 1≤R) + (hm : ∀v r,r+1=Fintype.card V → (𝔼 x,F v x^(2*r))≤R^(2*r)) : + |multilinearIntegral Llaw F|≤c*(2*R^(2*Fintype.card V)) := by + apply positiveLaw_product_bound Llaw hpos (fun v z => F v (z v)) _ + intro v + rw [hmar v (fun x => |F v x|^(Fintype.card V))] + apply mul_le_mul_of_nonneg_left _ hc + have hd : 2≤Fintype.card V := Fintype.one_lt_card + have hn : Fintype.card V≤2*(Fintype.card V-1) := by omega + have hpow : R^(2*(Fintype.card V-1))≤R^(2*Fintype.card V) := pow_le_pow_right₀ hR (by omega) + calc + _ ≤ 𝔼 x : X,(1+|F v x|^(2*(Fintype.card V-1))) := + expect_le_expect (fun x _ => pow_le_one_add_pow (abs_nonneg _) hn) + _ = 1+(𝔼 x : X,F v x^(2*(Fintype.card V-1))) := by + rw [expect_add_distrib,Fintype.expect_const] + simp only [(even_two_mul _).pow_abs] + _ ≤ 1+R^(2*(Fintype.card V-1)) := add_le_add le_rfl (hm v (Fintype.card V-1) (by omega)) + _ ≤ _ := by have hp : 1≤R^(2*Fintype.card V) := one_le_pow₀ hR; linarith + +section Mixed + +variable {J : Type*} [instFintypeJ : Fintype J] [instDecidableEqJ : DecidableEq J] (p : J → ℕ) [∀j,Fact (p j).Prime] + +noncomputable def exceptionalProduct (B : Finset J) : ℝ := ∏j∈B,tupleEta (p j) + +noncomputable def actualMixedLaw (B : Finset J) : ((TupleVertex → ∀j,ZMod (p j)) → ℝ) →ₗ[ℝ] ℝ := + mixedTensorLaw (fun j => tupleLaw (p:=p j)) (fun j => tupleExceptionalLaw (p:=p j)) B + +lemma exceptionalProduct_nonneg {J : Type*} + [Fintype J] + [DecidableEq J] + (p : J → ℕ) + [∀ (j : J), Fact (Nat.Prime (p j))] (B : Finset J) : 0≤exceptionalProduct p B := prod_nonneg (fun _ _ => tupleEta_nonneg _) + +lemma actualMixedLaw_nonneg (B : Finset J) (F : (TupleVertex → ∀j,ZMod (p j)) → ℝ) (hF : ∀z,0≤F z) : + 0≤actualMixedLaw p B F := mixedTensorLaw_nonneg _ _ (fun _ => tupleLaw_nonneg) (fun _ => tupleExceptionalLaw_nonneg) B F hF + +lemma actualMixedLaw_marginal (hp : ∀j,tupleMassThreshold≤(p j:ℝ)) (B : Finset J) + (v : TupleVertex) (g : (∀j,ZMod (p j)) → ℝ) : + actualMixedLaw p B (fun z => g (z v))=exceptionalProduct p B*(𝔼 x,g x) := by + have h := tensorLaw_weighted_marginal (fun j => if j∈B then tupleExceptionalLaw (p:=p j) else tupleLaw (p:=p j)) + v (fun j => if j∈B then tupleEta (p j) else 1) (fun j f => by + by_cases hj : j∈B + · simp only [hj,ite_true]; exact tupleExceptionalLaw_marginal (hp j) v f + · simp only [hj,ite_false,one_mul]; exact tupleLaw_marginal (hp j) v f) g + simpa only [prod_ite_mem,univ_inter,actualMixedLaw,mixedTensorLaw,exceptionalProduct] using h + +lemma actualMixedLaw_mass (hp : ∀j,tupleMassThreshold≤(p j:ℝ)) (B : Finset J) : + actualMixedLaw p B (fun _ : TupleVertex → ∀j,ZMod (p j) => (1:ℝ))=exceptionalProduct p B := by + have h := actualMixedLaw_marginal p hp B (Classical.arbitrary TupleVertex) (fun _ => (1:ℝ)) + simpa only [Fintype.expect_const,mul_one] using h + +lemma actualMixedLaw_crude (hp : ∀j,tupleMassThreshold≤(p j:ℝ)) (B : Finset J) + (F : TupleVertex → (∀j,ZMod (p j)) → ℝ) (R : ℝ) (hR : 1≤R) + (hm : ∀v r,r+1=Fintype.card TupleVertex → (𝔼 x,F v x^(2*r))≤R^(2*r)) : + |multilinearIntegral (actualMixedLaw p B) F|≤exceptionalProduct p B*(2*R^(2*Fintype.card TupleVertex)) := + weighted_uniform_multilinear_crude _ (actualMixedLaw_nonneg p B) _ (exceptionalProduct_nonneg p B) + (actualMixedLaw_marginal p hp B) F R hR hm + +end Mixed + +end SquareDifference + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SquareDifference/ExceptionalBudget.lean b/lean/OAI/Combinatorics/SquareDifference/ExceptionalBudget.lean new file mode 100644 index 0000000000000000000000000000000000000000..47805e529f9f52a44334357192dc3da11670acc3 --- /dev/null +++ b/lean/OAI/Combinatorics/SquareDifference/ExceptionalBudget.lean @@ -0,0 +1,107 @@ +import OAI.Combinatorics.SquareDifference.EulerBudget + +namespace OAI + +section + +open Finset Filter + +open scoped BigOperators Topology + +namespace SquareDifference + +lemma exists_exceptional_threshold : + ∃P : ℕ,64≤P ∧ ∀{p : ℕ} [Fact p.Prime],P≤p → + max tupleMassThreshold tupleConditionalThreshold≤(p:ℝ) ∧ + tupleReflectionThreshold≤(p:ℝ) ∧ tupleEta p≤1/(p:ℝ)^4 := by + have he := eventually_rpow_dominate tupleExceptionalConstant (-(81:ℝ)/16) (-4) (by norm_num) + have ht : ∀ᶠ p : ℕ in atTop, + max (max tupleMassThreshold tupleConditionalThreshold) tupleReflectionThreshold≤(p:ℝ) := + tendsto_natCast_atTop_atTop.eventually_ge_atTop _ + obtain ⟨P,hP⟩ := eventually_atTop.mp (he.and ht) + refine ⟨max P 64,le_max_right _ _,?_⟩ + intro p _ hp + have hp' := hP p ((le_max_left _ _).trans hp) + have hm := (le_max_left _ _).trans hp'.2 + have hr := (le_max_right _ _).trans hp'.2 + refine ⟨hm,hr,?_⟩ + have hh := (tupleEta_le ((le_max_left _ _).trans hm)).trans hp'.1 + simpa only [Real.rpow_neg (Nat.cast_nonneg _),show (4:ℝ)=(4:ℕ) by norm_num,Real.rpow_natCast,one_div] using hh + +section Budget + +variable {J : Type*} [instFintypeJ : Fintype J] [instDecidableEqJ : DecidableEq J] (p : J → ℕ) [∀j,Fact (p j).Prime] + +lemma primeProduct_one_le {J : Type*} + [Fintype J] + [DecidableEq J] + (p : J → ℕ) + [∀ (j : J), Fact (Nat.Prime (p j))] (B : Finset J) : 1≤(∏j∈B,p j:ℝ) := + one_le_prod₀ (fun j _ => by exact_mod_cast (Fact.out : (p j).Prime).one_lt.le) + +lemma tupleEta_le_one_of_fourth {J : Type*} + [Fintype J] + [DecidableEq J] + (p : J → ℕ) + [∀ (j : J), Fact (Nat.Prime (p j))] (h : ∀j,tupleEta (p j)≤1/(p j:ℝ)^4) (j : J) : tupleEta (p j)≤1 := by + apply (h j).trans + apply (div_le_one (pow_pos (by exact_mod_cast (Fact.out : (p j).Prime).pos) 4)).mpr + exact one_le_pow₀ (by exact_mod_cast (Fact.out : (p j).Prime).one_lt.le) + +lemma exceptional_weight_budget (hinj : Function.Injective p) (hp : ∀j,5≤p j) + (heta : ∀j,tupleEta (p j)≤1/(p j:ℝ)^4) : + (∑B∈(univ : Finset (Finset J)).erase ∅,(∏j∈B,p j:ℝ)*exceptionalProduct p B)≤1/4 := by + have hb := weighted_exceptional_budget (univ : Finset J) p hinj.injOn (fun j _ => hp j) + (fun j => (p j:ℝ)*tupleEta (p j)) + (fun j _ => mul_nonneg (Nat.cast_nonneg _) (tupleEta_nonneg _)) (fun j _ => ?_) + · simpa only [powerset_univ,prod_mul_distrib,exceptionalProduct] using hb + · have h0 : (p j:ℝ)≠0 := by exact_mod_cast (Fact.out : (p j).Prime).ne_zero + calc + _ ≤ (p j:ℝ)*(1/(p j:ℝ)^4) := mul_le_mul_of_nonneg_left (heta j) (Nat.cast_nonneg _) + _ = _ := by field_simp + +lemma exceptional_large_tail (hinj : Function.Injective p) (hp : ∀j,5≤p j) + (heta : ∀j,tupleEta (p j)≤1/(p j:ℝ)^4) (N : ℕ) (hN : 0 (N:ℝ)^t<(∏j∈B,p j:ℝ)),exceptionalProduct p B)≤ + (N:ℝ)^(-t)/4 := by + let S := ((univ : Finset (Finset J)).erase ∅).filter (fun B => (N:ℝ)^t<(∏j∈B,p j:ℝ)) + have hn : (0:ℝ) + mul_nonneg (prod_nonneg (fun j _ => Nat.cast_nonneg _)) (exceptionalProduct_nonneg p B)) + _ = _ := by ring + +lemma exceptional_small_power_budget (hinj : Function.Injective p) (hp : ∀j,5≤p j) + (heta : ∀j,tupleEta (p j)≤1/(p j:ℝ)^4) (S : Finset (Finset J)) + (hS : S⊆(univ : Finset (Finset J)).erase ∅) (a : ℝ) (ha : a≤1) : + (∑B∈S,exceptionalProduct p B*(∏j∈B,p j:ℝ)^a)≤1/4 := by + calc + _ ≤ ∑B∈S,(∏j∈B,p j:ℝ)*exceptionalProduct p B := by + apply sum_le_sum + intro B _ + rw [mul_comm] + apply mul_le_mul_of_nonneg_right _ (exceptionalProduct_nonneg p B) + simpa only [Real.rpow_one] using Real.rpow_le_rpow_of_exponent_le (primeProduct_one_le p B) ha + _ ≤ _ := le_trans (sum_le_sum_of_subset_of_nonneg hS (fun B _ _ => + mul_nonneg (prod_nonneg (fun j _ => Nat.cast_nonneg _)) (exceptionalProduct_nonneg p B))) + (exceptional_weight_budget p hinj hp heta) + +end Budget + +end SquareDifference + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SquareDifference/ExtendedPair.lean b/lean/OAI/Combinatorics/SquareDifference/ExtendedPair.lean new file mode 100644 index 0000000000000000000000000000000000000000..97e6e92c7bb1c967f9833ecd6ca3b6bfaa6bc42f --- /dev/null +++ b/lean/OAI/Combinatorics/SquareDifference/ExtendedPair.lean @@ -0,0 +1,115 @@ +import OAI.Combinatorics.SquareDifference.PrimeExtension + +namespace OAI + +section + +open Finset + +open scoped BigOperators + +namespace SquareDifference + +open LiftTheory.SquareDifference + +lemma coefficient_reindex {J K : Type*} [Fintype J] [DecidableEq J] [Fintype K] [DecidableEq K] + (p : J → ℕ) (m : K → ℕ) [∀j,NeZero (p j)] [∀k,NeZero (m k)] + (e : K ≃ J) (hm : m=fun k => p (e k)) {Ω : Type*} [Fintype Ω] + (N : ℕ) (F : Ω → ℂ) (n : Ω → ℕ) (f : ResidueSpace p → ℂ) (a : ℝ) (H : ℝ) + (hf : ∀ξ,(supportDenominator p ξ:ℝ)≤H → + residueFourier p f ξ=(a:ℂ)*sequenceResidueFourier p N F n ξ) : + ∀ξ,(supportDenominator m ξ:ℝ)≤H → + residueFourier m (fun x => f ((residueReindex p m e hm).symm x)) ξ= + (a:ℂ)*sequenceResidueFourier m N F n ξ := by + intro ξ hξ + obtain ⟨η,rfl⟩ := (residueReindex p m e hm).surjective ξ + rw [supportDenominator_reindex] at hξ + rw [residueFourier_reindex,sequenceResidueFourier_reindex] + exact hf η hξ + +lemma kernel_cover_from_bound {I : Type*} [Fintype I] [DecidableEq I] + (p : I → ℕ) (hinj : Function.Injective p) (N : ℕ) (hN : 1≤N) + (hcover : ∀r : ℕ,r.Prime → r≤N → ∃i,p i=r) : + ∀b : ℚ,(b.den:ℝ)≤(N:ℝ)^((1:ℝ)/8) → b.den∣∏i,primaryModulus b.den (p i) := by + intro b hb + apply primary_product_cover p hinj N hcover b.den b.den_pos + have hh : (b.den:ℝ)≤N := hb.trans (by + simpa using Real.rpow_le_rpow_of_exponent_le (by exact_mod_cast hN : (1:ℝ)≤N) (show (1:ℝ)/8≤1 by norm_num)) + exact_mod_cast hh + +lemma kernel_cover_cutoff {I : Type*} [Fintype I] [DecidableEq I] + (p : I → ℕ) (hinj : Function.Injective p) (N : ℕ) (hN : 1≤N) + (hcover : ∀r : ℕ,r.Prime → r≤N → ∃i,p i=r) + (D H : ℝ) (hH : 0≤H) (hD : D≤(N:ℝ)^((1:ℝ)/1000)) + (hHn : H≤(N:ℝ)^((1:ℝ)/1000)) : + ∀b : ℚ,b.den≤⌈D*H⌉₊ → b.den∣∏i,primaryModulus b.den (p i) := by + have hn : (0:ℝ) (supportDenominator (OutsideModulus p B) ξ:ℝ)≤H), + residueFourier _ f (-ξ)*residueFourier _ g ξ*squareMultiplier _ ξ‖≤ + a*b/((∏s,smallQuadraticModulus (ps s))*(∏j∈B,p j):ℝ)* + (kernelAbsoluteConstant*H^(-(1:ℝ)/3)) := by + let m := OutsideModulus (fun i => smallQuadraticModulus (extendedPrime ps p i)) (extendedRoots (S:=S) B) + let e := outsideSumEquiv (S:=S) B + have hm : m=fun i => OutsideModulus p B (e i) := extended_outside_modulus ps p B hp2 + let re := residueReindex (OutsideModulus p B) m e hm + have hmod := extended_roots_modulus ps p B hp2 + have hD' : (rootSquareModulus (extendedPrime ps p) (extendedRoots (S:=S) B):ℝ)≤(N:ℝ)^((1:ℝ)/1000) := by + simpa only [hmod,Nat.cast_mul,Nat.cast_prod] using hD + have htwo : ∀i,extendedPrime ps p i=2 → i∈extendedRoots (S:=S) B := by + intro i hi + cases i with + | inl s => exact inl_mem_extendedRoots B s + | inr j => exact False.elim (hp2 j hi) + have hk := actual_kernel_low_pair (extendedPrime ps p) hinj (extendedRoots (S:=S) B) c + H hH N hN hD' hHn hlarge (kernel_cover_from_bound _ hinj N hN hcover) + (kernel_cover_cutoff _ hinj N hN hcover _ H (by linarith) hD' hHn) + htwo hc hq F G hF hG hord hsquare s t hr hs ht + (fun x => f (re.symm x)) (fun x => g (re.symm x)) a b ha hb + (coefficient_reindex _ m e hm N F ZMod.val f a H hf) + (coefficient_reindex _ m e hm N G ZMod.val g b H hg) + rw [low_pair_reindex _ m e hm f g H] at hk + simpa only [hmod,Nat.cast_mul,Nat.cast_prod] using hk + +end Extended + +end SquareDifference + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SquareDifference/FiniteKernel.lean b/lean/OAI/Combinatorics/SquareDifference/FiniteKernel.lean new file mode 100644 index 0000000000000000000000000000000000000000..dfc66024c5054cff1c49071d642536adb0b26bce --- /dev/null +++ b/lean/OAI/Combinatorics/SquareDifference/FiniteKernel.lean @@ -0,0 +1,524 @@ +import OAI.Combinatorics.SquareDifference.RationalApproximation + +namespace OAI + +section +open Finset +open scoped ComplexConjugate BigOperators +namespace SquareDifference + +noncomputable def finiteSquareKernel {K : Type*} [Fintype K] + (ε : K → ℂ) (v : K → ℕ → ℂ) (M N : ℕ) (α : ℝ) : ℂ := + ∑k, ε k*∑m∈range M, squareWeight N α m*v k (m+1) + +noncomputable def finiteRationalCoefficient {K : Type*} [Fintype K] + (ε : K → ℂ) (v : K → ℕ → ℂ) (t : K → ℕ) (b : ℚ) : ℂ := + ∑k, ε k*periodicMean (fun m => v k (m+1)*expPhase ((b : ℝ)*(m+1)^2)) (b.den*t k) + +lemma finite_square_kernel_major {K : Type*} [Fintype K] + (ε : K → ℂ) (v : K → ℕ → ℂ) (t : K → ℕ) + (ht : ∀k, 0 + mul_nonneg (mul_nonneg (norm_nonneg _) (by positivity)) (hB k))) (by positivity)) (by positivity)) (by positivity) + have hlarge : 0≤(∑j, ‖w j‖)*(4*(M : ℝ)/N)*Real.sqrt + (5*M+32*(M : ℝ)^2/R+(64*M+8*T)*(1+Real.log T)) := by positivity + have hmodel' : ‖(∑i, z i*normalizedLinearSum N (α-c i))- + modelCenterCoefficient c z b*normalizedLinearSum N (α-b)‖≤ + (∑i, ‖z i‖)*((T : ℝ)*L/N) := by + apply hmodel.trans + gcongr + by_cases hbr : (b.den : ℝ)≤R + · have hactual := finite_square_kernel_major ε v t ht hv B hB hb b α T R hbr ha M N hM hlo hhi + have he : ‖finiteRationalCoefficient ε v t b*normalizedLinearSum N (α-b)- + modelCenterCoefficient c z b*normalizedLinearSum N (α-b)‖≤E := by + rw [←sub_mul,norm_mul] + exact (mul_le_mul (hcoef b hbr) (normalizedLinearSum_norm N (α-b)) + (norm_nonneg _) hE).trans_eq (mul_one E) + have hh := norm_sub_le_norm_sub_add_norm_sub (finiteSquareKernel ε v M N α) + (finiteRationalCoefficient ε v t b*normalizedLinearSum N (α-b)) + (modelCenterCoefficient c z b*normalizedLinearSum N (α-b)) + have hh' := norm_sub_le_norm_sub_add_norm_sub (finiteSquareKernel ε v M N α) + (modelCenterCoefficient c z b*normalizedLinearSum N (α-b)) + (∑i, z i*normalizedLinearSum N (α-c i)) + rw [norm_sub_rev (modelCenterCoefficient c z b*normalizedLinearSum N (α-b))] at hh' + linarith + · have hbL : L ((v.1.val : ℚ)/(v.2.val+1)))).filter (fun b => 0≤b ∧ b<1 ∧ b.den≤L) + +lemma mem_boundedRationals (L : ℕ) (b : ℚ) : + b∈boundedRationals L ↔ 0≤b ∧ b<1 ∧ b.den≤L := by + classical + constructor + · intro h + exact (mem_filter.mp h).2 + · rintro ⟨hb0,hb1,hden⟩ + apply mem_filter.mpr + refine ⟨?_,hb0,hb1,hden⟩ + have hnum0 : 0≤b.num := Rat.num_nonneg.mpr hb0 + have hnum1 : b.num<(b.den : ℤ) := by + have hd : (0 : ℚ).mp hc).1, + (mem_boundedRationals L c |>.mp hc).2.1⟩] + +attribute [local instance] Classical.propDecidable + +lemma boundedRationals_sum_mod_int (L : ℕ) (f : ℚ → ℂ) (b : ℚ) : + (∑c∈boundedRationals L, if ∃k : ℤ, b-c=(k:ℚ) then f c else 0)= + if b.den≤L then f (Int.fract b) else 0 := by + classical + have he : (∑c∈boundedRationals L, if ∃k : ℤ, b-c=(k:ℚ) then f c else 0)= + ∑c∈boundedRationals L, if Int.fract b=c then f c else 0 := by + apply sum_congr rfl + intro c hc + rw [boundedRationals_equiv_int b c hc] + split_ifs <;> rfl + rw [he] + by_cases hb : b.den≤L + · rw [ite_eq_left hb,sum_eq_single (Int.fract b)] + · simp + · intro c _ hc; rw [ite_eq_right (Ne.symm hc)] + · exact fun h => False.elim (h (boundedRationals_fract b hb)) + · rw [ite_eq_right hb] + apply sum_eq_zero + intro c hc + rw [ite_eq_right] + rintro rfl + exact hb (by simpa only [Rat.den_intFract] using (mem_boundedRationals L (Int.fract b)).mp hc |>.2.2) + +section ActualKernelCoefficient + +variable {I : Type*} [Fintype I] [DecidableEq I] + (p : I → ℕ) [∀i, Fact (p i).Prime] (R : Finset I) (c : ∀i, ZMod (p i)) + +lemma actualCompleteQuadratic_periodic (b : ℚ) (t : ℕ) + (hpt : ∀i,p i∣t) (hbt : b.den∣t) : + Function.Periodic (fun n => actualCompleteWeight p R c (n+1)*expPhase ((b:ℝ)*(n+1)^2)) t := by + apply Function.Periodic.mul + · intro n + simpa only [Nat.add_assoc,Nat.add_comm,Nat.add_left_comm] using + actualCompleteWeight_periodic p R c t hpt (n+1) + · exact expPhase_rat_square_periodic b t hbt + +noncomputable def completeRationalCoefficient (b : ℚ) : ℂ := + periodicMean (fun n => actualCompleteWeight p R c (n+1)*expPhase ((b:ℝ)*(n+1)^2)) + (b.den*∏i,p i) + +lemma completeRationalCoefficient_eq (b : ℚ) (t : ℕ) (ht : 0 actualCompleteWeight p R c (n+1)*expPhase ((b:ℝ)*(n+1)^2)) t := by + apply periodicMean_independent + · exact (mul_pos b.pos (prod_pos (fun i _ => (Fact.out : (p i).Prime).pos))).ne' + · exact ht.ne' + · exact actualCompleteQuadratic_periodic p R c b _ + (fun i => dvd_mul_of_dvd_right (dvd_prod_of_mem p (mem_univ i)) _) (dvd_mul_right _ _) + · exact actualCompleteQuadratic_periodic p R c b t hpt hbt + +noncomputable def kernelModelCoefficient (H : ℝ) (b : ℚ) : ℂ := + if ((∏i∈primaryActive p b.den\R,p i : ℕ):ℝ)≤H then completeRationalCoefficient p R c b else 0 + +lemma primaryModelCoefficient_eq_kernelModel (hinj : Function.Injective p) (b : ℚ) + (hb : b.den∣∏i,primaryModulus b.den (p i)) (H : ℝ) (htwo : ∀i,p i=2 → i∈R) : + primaryModelCoefficient p hinj b hb R c H=kernelModelCoefficient p R c H b := by + rw [primaryModelCoefficient_complete p R c hinj b hb H htwo] + unfold kernelModelCoefficient + rw [completeRationalCoefficient_eq p R c b (∏i,primaryModulus b.den (p i)) + (prod_pos (fun i _ => primaryModulus_pos (Fact.out : (p i).Prime))) + (fun i => (prime_dvd_primaryModulus b.den (p i)).trans + (dvd_prod_of_mem (fun i => primaryModulus b.den (p i)) (mem_univ i))) hb] + +lemma expPhase_rat_add_int_square (b : ℚ) (k : ℤ) (n : ℕ) : + expPhase (((b+k : ℚ):ℝ)*(n:ℝ)^2)=expPhase ((b:ℝ)*(n:ℝ)^2) := by + rw [show (((b+k : ℚ):ℝ)*(n:ℝ)^2)=(b:ℝ)*(n:ℝ)^2+((k*(n:ℤ)^2:ℤ):ℝ) by push_cast; ring] + rw [expPhase_add,expPhase_int,mul_one] + +lemma completeRationalCoefficient_add_int (b : ℚ) (k : ℤ) : + completeRationalCoefficient p R c (b+k)=completeRationalCoefficient p R c b := by + unfold completeRationalCoefficient + rw [Rat.add_intCast_den] + congr 1 + funext n + have h := expPhase_rat_add_int_square b k (n+1) + simpa only [Nat.cast_add,Nat.cast_one] using congrArg (fun z => actualCompleteWeight p R c (n+1)*z) h + +lemma kernelModelCoefficient_add_int (H : ℝ) (b : ℚ) (k : ℤ) : + kernelModelCoefficient p R c H (b+k)=kernelModelCoefficient p R c H b := by + simp only [kernelModelCoefficient,Rat.add_intCast_den,completeRationalCoefficient_add_int] + +lemma kernelModelCoefficient_fract (H : ℝ) (b : ℚ) : + kernelModelCoefficient p R c H (Int.fract b)=kernelModelCoefficient p R c H b := by + have h := kernelModelCoefficient_add_int p R c H (Int.fract b) (Int.floor b) + rw [Int.fract_add_floor] at h + exact h.symm + +lemma kernelModelCoefficient_norm (hinj : Function.Injective p) (b : ℚ) + (hb : b.den∣∏i,primaryModulus b.den (p i)) (H : ℝ) (htwo : ∀i,p i=2 → i∈R) : + ‖kernelModelCoefficient p R c H b‖≤1 := by + rw [← primaryModelCoefficient_eq_kernelModel p R c hinj b hb H htwo] + exact primaryModelCoefficient_norm p hinj b hb R c H + +lemma kernelModelCoefficient_zero_of_denominator (hinj : Function.Injective p) (b : ℚ) + (hb : b.den∣∏i,primaryModulus b.den (p i)) (H : ℝ) (htwo : ∀i,p i=2 → i∈R) + (hc : ∀i∈R,if p i=2 then c i=1 else c i≠0) + (hden : rootSquareModulus p R*H<(b.den:ℝ)) : + kernelModelCoefficient p R c H b=0 := by + rw [← primaryModelCoefficient_eq_kernelModel p R c hinj b hb H htwo] + exact primaryModelCoefficient_zero_of_denominator p hinj b hb R c H htwo hc hden + +lemma bounded_kernel_model_center (hinj : Function.Injective p) (L : ℕ) (H : ℝ) + (hL : rootSquareModulus p R*H≤(L:ℝ)) (htwo : ∀i,p i=2 → i∈R) + (hc : ∀i∈R,if p i=2 then c i=1 else c i≠0) + (b : ℚ) (hb : b.den∣∏i,primaryModulus b.den (p i)) : + modelCenterCoefficient (fun z : boundedRationals L => z.val) + (fun z => kernelModelCoefficient p R c H z.val) b = kernelModelCoefficient p R c H b := by + classical + unfold modelCenterCoefficient + change (∑ z : boundedRationals L, (fun x : ℚ => if ∃k : ℤ, b-x=(k:ℚ) then kernelModelCoefficient p R c H x else 0) z.val) = _ + rw [Finset.sum_coe_sort (boundedRationals L) (fun x : ℚ => if ∃k : ℤ, b-x=(k:ℚ) then kernelModelCoefficient p R c H x else 0), boundedRationals_sum_mod_int] + by_cases hden : b.den≤L + · rw [ite_eq_left hden,kernelModelCoefficient_fract] + · rw [ite_eq_right hden] + symm + apply kernelModelCoefficient_zero_of_denominator p R c hinj b hb H htwo hc + exact hL.trans_lt (by exact_mod_cast (lt_of_not_ge hden)) + +end ActualKernelCoefficient + +lemma stdAddChar_eq_expPhase {p : ℕ} [NeZero p] (a : ZMod p) : + ZMod.stdAddChar a=expPhase ((a.val : ℝ)/p) := by + rw [ZMod.stdAddChar_apply, ZMod.toCircle_apply] + change Complex.exp _ = Complex.exp _ + congr 1 + push_cast + ring + +section ActualKernelTerms + +variable {I : Type*} [Fintype I] [DecidableEq I] + (p : I → ℕ) [∀i, Fact (p i).Prime] (R : Finset I) (c : ∀i, ZMod (p i)) + +noncomputable def boundedSieveSets (H : ℝ) : Finset (Finset I) := + (univ : Finset I).powerset.filter (fun T => ((∏i∈T,p i : ℕ):ℝ)≤H) + +noncomputable def sieveTermSign (T : Finset I) : ℂ := (-1)^T.card + +noncomputable def sieveTermWeight (T : Finset I) (n : ℕ) : ℂ := + actualRootWeight p R c n*actualSieveWeight p R T n + +noncomputable def sieveTermPeriod (T : Finset I) : ℕ := (∏i∈R,p i)*(∏i∈T,p i) + +omit [Fintype I] [DecidableEq I] in +lemma sieveTermPeriod_pos (T : Finset I) : 0 (Fact.out : (p i).Prime).pos)) + (prod_pos (fun i _ => (Fact.out : (p i).Prime).pos)) + +omit [Fintype I] in +lemma sieveTermWeight_periodic (T : Finset I) : + Function.Periodic (sieveTermWeight p R c T) (sieveTermPeriod p R T) := + actualTermWeight_periodic p R c T + +omit [Fintype I] in +lemma sieveTermWeight_norm (T : Finset I) (n : ℕ) : + ‖sieveTermWeight p R c T n‖≤(∏i∈R,p i : ℕ) := by + rw [sieveTermWeight,norm_mul] + exact (mul_le_mul (actualRootWeight_norm p R c n) (actualSieveWeight_norm p R T n) + (norm_nonneg _) (Nat.cast_nonneg _)).trans_eq (mul_one _) + +omit [Fintype I] [DecidableEq I] in +lemma sieveTermSign_norm (T : Finset I) : ‖sieveTermSign T‖=1 := by + simp only [sieveTermSign,norm_pow,norm_neg,norm_one,one_pow] + +lemma actualDivisorWeight_eq_terms (H : ℝ) (n : ℕ) : + actualDivisorWeight p R c H n= + ∑T : boundedSieveSets p H, sieveTermSign T.val*sieveTermWeight p R c T.val n := by + change _ = ∑ T : boundedSieveSets p H, (fun S : Finset I => sieveTermSign S*sieveTermWeight p R c S n) T.val + rw [Finset.sum_coe_sort (boundedSieveSets p H) (fun S : Finset I => sieveTermSign S*sieveTermWeight p R c S n)] + unfold boundedSieveSets sieveTermSign sieveTermWeight actualDivisorWeight + rw [sum_filter,mul_sum] + apply sum_congr rfl + intro T _ + split_ifs <;> ring + +omit [Fintype I] in +lemma sieveTermQuadratic_periodic (T : Finset I) (b : ℚ) (t : ℕ) + (hpt : ∀i,p i∣t) (hbt : b.den∣t) : + Function.Periodic (fun n => sieveTermWeight p R c T (n+1)*expPhase ((b:ℝ)*(n+1)^2)) t := by + have hw : Function.Periodic (sieveTermWeight p R c T) t := + (actualRootWeight_periodic p R c t (fun i _ => hpt i)).mul + (actualSieveWeight_periodic p R T t (fun i _ => hpt i)) + apply Function.Periodic.mul + · intro n + simpa only [Nat.add_assoc,Nat.add_comm,Nat.add_left_comm] using hw (n+1) + · exact expPhase_rat_square_periodic b t hbt + +omit [Fintype I] in +lemma sieveTermCoefficient_eq (T : Finset I) (b : ℚ) (t : ℕ) (ht : 0 sieveTermWeight p R c T (n+1)*expPhase ((b:ℝ)*(n+1)^2)) + (b.den*sieveTermPeriod p R T)= + periodicMean (fun n => sieveTermWeight p R c T (n+1)*expPhase ((b:ℝ)*(n+1)^2)) t := by + apply periodicMean_independent + · exact (mul_pos b.pos (sieveTermPeriod_pos p R T)).ne' + · exact ht.ne' + · exact periodic_rational_quadratic _ _ (sieveTermWeight_periodic p R c T) b + · exact sieveTermQuadratic_periodic p R c T b t hpt hbt + +lemma finiteRationalCoefficient_actual (H : ℝ) (b : ℚ) (t : ℕ) (ht : 0 sieveTermSign T.val) + (fun T => sieveTermWeight p R c T.val) (fun T => sieveTermPeriod p R T.val) b= + periodicMean (fun n => actualDivisorWeight p R c H (n+1)*expPhase ((b:ℝ)*(n+1)^2)) t := by + unfold finiteRationalCoefficient + simp_rw [sieveTermCoefficient_eq p R c _ b t ht hpt hbt,actualDivisorWeight_eq_terms,sum_mul] + rw [periodicMean_sum] + apply sum_congr rfl + intro T _ + rw [← periodicMean_mul_left] + congr 1 + funext n + ring + +lemma finiteRationalCoefficient_actual_uniform (hinj : Function.Injective p) (H : ℝ) (hH : 0 sieveTermSign T.val) + (fun T => sieveTermWeight p R c T.val) (fun T => sieveTermPeriod p R T.val) b- + kernelModelCoefficient p R c H b‖≤2^64*H^(-(1:ℝ)/3) := by + rw [finiteRationalCoefficient_actual p R c H b (∏i,primaryModulus b.den (p i)) + (prod_pos (fun i _ => primaryModulus_pos (Fact.out : (p i).Prime))) + (fun i => (prime_dvd_primaryModulus b.den (p i)).trans + (dvd_prod_of_mem (fun i => primaryModulus b.den (p i)) (mem_univ i))) hb, + ← primaryModelCoefficient_eq_kernelModel p R c hinj b hb H htwo] + exact actualDivisorWeight_coefficient_uniform p hinj b hb R c H hH htwo + +lemma actualDivisorWeight_fourier (hinj : Function.Injective p) (H : ℝ) (hH : 0≤H) : + ∃ (q : ℕ) (_ : NeZero q) (w : ZMod q → ℂ), + (∀n,actualDivisorWeight p R c H n= + ∑a : ZMod q,w a*expPhase (((a.val:ℝ)/q)*n)) ∧ + (∑a : ZMod q,‖w a‖)≤(∏i∈R,p i : ℕ)*H := by + let q : ℕ := ∏i,p i + have hq : 0 (Fact.out : (p i).Prime).pos) + let hq' : NeZero q := ⟨hq.ne'⟩ + have hpq (i : I) : p i∣q := dvd_prod_of_mem p (mem_univ i) + obtain ⟨w,hw,hbound⟩ := ringDivisorWeight_fourier p R c q hpq hinj H hH + refine ⟨q,hq',w,?_,hbound⟩ + intro n + rw [← ringDivisorWeight_natCast p R c q hpq H n,hw] + apply sum_congr rfl + intro a _ + congr 1 + have he := AddChar.map_nsmul_eq_pow (ZMod.stdAddChar (N:=q)) n a + simp only [nsmul_eq_mul] at he + rw [mul_comm a _,he,stdAddChar_eq_expPhase,←expPhase_nat_mul,mul_comm] + +omit [DecidableEq I] in +lemma boundedSieveSets_card (hinj : Function.Injective p) (H : ℝ) (hH : 0≤H) : + (Fintype.card (boundedSieveSets p H) : ℝ)≤H := by + have hc := bounded_prime_subsets_card p (fun i => (Fact.out : (p i).Prime)) hinj + (boundedSieveSets p H) ⌊H⌋₊ (fun T hT => Nat.le_floor ((mem_filter.mp hT).2)) + rw [Fintype.card_coe] + exact (Nat.cast_le.mpr hc).trans (Nat.floor_le hH) + +omit [DecidableEq I] in +lemma sieveTermCost (hinj : Function.Injective p) (H : ℝ) (hH : 0≤H) : + (∑T : boundedSieveSets p H, ‖sieveTermSign T.val‖* + (2*(sieveTermPeriod p R T.val : ℝ)+1)*(∏i∈R,p i : ℕ))≤ + H*(2*(∏i∈R,p i : ℕ)*H+1)*(∏i∈R,p i : ℕ) := by + calc + _ ≤ ∑T : boundedSieveSets p H, + (2*(∏i∈R,p i : ℕ)*H+1)*(∏i∈R,p i : ℕ) := by + apply sum_le_sum + intro T _ + rw [sieveTermSign_norm,one_mul,sieveTermPeriod,Nat.cast_mul] + have ht := (mem_filter.mp T.property).2 + apply mul_le_mul_of_nonneg_right _ (Nat.cast_nonneg _) + apply add_le_add _ le_rfl + rw [← mul_assoc] + exact mul_le_mul_of_nonneg_left ht (by positivity) + _ = (Fintype.card (boundedSieveSets p H) : ℝ)* + ((2*(∏i∈R,p i : ℕ)*H+1)*(∏i∈R,p i : ℕ)) := by simp + _ ≤ _ := by + have hc := boundedSieveSets_card p hinj H hH + nlinarith [show 0≤(2*(∏i∈R,p i : ℕ)*H+1)*(∏i∈R,p i : ℕ) by positivity] + +noncomputable def actualSquareTransform (H : ℝ) (M N : ℕ) (α : ℝ) : ℂ := + ∑m∈range M,squareWeight N α m*actualDivisorWeight p R c H (m+1) + +noncomputable def actualModelTransform (H : ℝ) (L N : ℕ) (α : ℝ) : ℂ := + ∑b : boundedRationals L,kernelModelCoefficient p R c H b.val* + normalizedLinearSum N (α-b.val) + +lemma finiteSquareKernel_actual (H : ℝ) (M N : ℕ) (α : ℝ) : + finiteSquareKernel (fun T : boundedSieveSets p H => sieveTermSign T.val) + (fun T => sieveTermWeight p R c T.val) M N α=actualSquareTransform p R c H M N α := by + unfold finiteSquareKernel actualSquareTransform + simp_rw [mul_sum] + rw [sum_comm] + apply sum_congr rfl + intro m _ + rw [actualDivisorWeight_eq_terms,mul_sum] + apply sum_congr rfl + intro T _ + ring + +lemma actual_kernel_uniform (hinj : Function.Injective p) + (H : ℝ) (hH : 0 sieveTermSign T.val) + (fun T => sieveTermWeight p R c T.val) (fun T => sieveTermPeriod p R T.val) + (fun T => sieveTermPeriod_pos p R T.val) (fun T => sieveTermWeight_periodic p R c T.val) + (fun _ => ((∏i∈R,p i : ℕ):ℝ)) (fun _ => Nat.cast_nonneg _) + (fun T m => sieveTermWeight_norm p R c T.val m) + (fun b : boundedRationals L => b.val) (fun b => kernelModelCoefficient p R c H b.val) + L T X (2^64*H^(-(1:ℝ)/3)) hT hL + (fun b => ((mem_boundedRationals L b.val).mp b.property).2.2) hX hLX (by positivity) + (fun b hb => by + rw [bounded_kernel_model_center p R c hinj L H hmodel htwo hc b (hcover b hb)] + exact finiteRationalCoefficient_actual_uniform p R c hinj H hH htwo b (hcover b hb)) + w (fun a : ZMod q => (a.val:ℝ)/q) + (fun m => by rw [← actualDivisorWeight_eq_terms,hw]) M N hM hlo hhi α + rw [finiteSquareKernel_actual] at hf + apply hf.trans + have hcost := sieveTermCost p R hinj H hH.le + have hX0 : 0≤X := by linarith + gcongr + +end ActualKernelTerms + +end SquareDifference + +namespace SquareDifference + +open Finset + +noncomputable def rationalGridPoint (q : ℕ) (a : ZMod q) : ℚ := (a.val : ℚ)/q + +lemma rationalGridPoint_nonneg (q : ℕ) (a : ZMod q) : 0≤rationalGridPoint q a := by + unfold rationalGridPoint + positivity + +lemma rationalGridPoint_lt_one (q : ℕ) [NeZero q] (a : ZMod q) : rationalGridPoint q a<1 := by + unfold rationalGridPoint + rw [div_lt_one (Nat.cast_pos.mpr (NeZero.pos q))] + exact_mod_cast ZMod.val_lt a + +lemma rationalGridPoint_den_dvd (q : ℕ) (a : ZMod q) : (rationalGridPoint q a).den∣q := by + have h := Rat.den_dvd (a.val : ℤ) (q : ℤ) + rw [Rat.divInt_eq_div] at h + simp only [Int.cast_natCast] at h + exact Int.natCast_dvd_natCast.mp h + +end SquareDifference +end + +end OAI diff --git a/lean/OAI/Combinatorics/SquareDifference/FourierLift.lean b/lean/OAI/Combinatorics/SquareDifference/FourierLift.lean new file mode 100644 index 0000000000000000000000000000000000000000..495fbd838b16301be2495cf9a92f52355404c950 --- /dev/null +++ b/lean/OAI/Combinatorics/SquareDifference/FourierLift.lean @@ -0,0 +1,1501 @@ +import OAI.Combinatorics.SquareDifference.WalshMoments + +namespace OAI + +section +open Finset +open scoped BigOperators +namespace LiftAnalysis +open Finset +open scoped BigOperators InnerProductSpace ComplexConjugate +namespace SquareDifference + +lemma symmetrization_moment {J : Type*} [Fintype J] [DecidableEq J] + {X : J → Type*} [∀j, Fintype (X j)] [∀j, Nonempty (X j)] + (F : Finset (Finset J)) (f : Finset J → (∀j, X j) → ℝ) + (hf : ∀U∈F, ExactSupport U (f U)) + (k : ℕ) (hk : ∀U∈F, U.card ≤ k) (r : ℕ) (hr : 1 ≤ r) : + (𝔼 x, (∑U∈F, f U x)^(2*r)) ≤ + (((4:ℝ)*(2:ℝ)^(2*r))^k)^r*(𝔼 x, (∑U∈F, f U x^2)^r) := by + classical + let D := fun U x y => copyDifference U (f U) x y + let S := fun x => ∑U∈F, f U x^2 + let C : ℝ := (2:ℝ)^(2*r) + let B : ℝ := (4*C)^k + have hC : 1 ≤ C := one_le_pow₀ (by norm_num) + have hB : 0 ≤ B := by positivity + have hS : ∀x, 0 ≤ S x := fun x => sum_nonneg fun U _ => sq_nonneg (f U x) + have hmean (x : ∀j, X j) : (𝔼 y, ∑U∈F, D U x y)=∑U∈F, f U x := by + rw [expect_sum_comm] + apply sum_congr rfl + intro U hU + exact copyDifference_mean U (f U) (hf U hU) x + have hsign : + (𝔼 x, 𝔼 y, (∑U∈F, D U x y)^(2*r))= + 𝔼 x, 𝔼 y, 𝔼 e : J → Bool, + (walsh univ (fun U => if U∈F then D U x y else 0) e)^(2*r) := by + have he (e : J → Bool) : + (𝔼 x, 𝔼 y, (walsh univ (fun U => if U∈F then D U x y else 0) e)^(2*r))= + 𝔼 x, 𝔼 y, (∑U∈F, D U x y)^(2*r) := by + simp only [walsh_family] + have hp x y U : D U x y*boolChar U e=D U (hybrid e x y) (hybrid e y x) := by + dsimp only [D] + rw [copyDifference_swap, mul_comm] + simp only [hp] + exact expect_copySwap e (fun x y => (∑U∈F, D U x y)^(2*r)) + conv_rhs => arg 2; ext x; rw [expect_comm] + conv_rhs => rw [expect_comm] + simp only [he, Fintype.expect_const] + have hpoint (x y : ∀j, X j) : + (𝔼 e : J → Bool, (walsh univ (fun U => if U∈F then D U x y else 0) e)^(2*r)) ≤ + B^r*(𝔼 e : J → Bool, (S (hybrid e x y))^r) := by + apply (walsh_hypercontractivity univ _ r hr).trans + have he := difference_energy_bound F f k hk C hC x y + calc + _ ≤ (B*(𝔼 e : J → Bool, S (hybrid e x y)))^r := + pow_le_pow_left₀ (walshEnergy_nonneg _ _ (by positivity) _) he r + _ = B^r*(𝔼 e : J → Bool, S (hybrid e x y))^r := mul_pow _ _ _ + _ ≤ _ := mul_le_mul_of_nonneg_left + (expect_pow_le (fun e => S (hybrid e x y)) (fun e => hS _) r) (pow_nonneg hB _) + change _ ≤ B^r*(𝔼 x, S x^r) + calc + _ ≤ (𝔼 x, 𝔼 y, (∑U∈F, D U x y)^(2*r)) := by + apply expect_le_expect + intro x _ + rw [← hmean x] + exact expect_even_pow_le (fun y => ∑U∈F, D U x y) r + _ = _ := hsign + _ ≤ (𝔼 x, 𝔼 y, B^r*(𝔼 e : J → Bool, (S (hybrid e x y))^r)) := by + apply expect_le_expect + intro x _ + exact expect_le_expect fun y _ => hpoint x y + _ = B^r*(𝔼 x, S x^r) := by + simp only [← mul_expect] + congr 1 + conv_lhs => arg 2; ext x; rw [expect_comm] + rw [expect_comm] + have he (e : J → Bool) : (𝔼 x, 𝔼 y, S (hybrid e x y)^r)=𝔼 x, S x^r := + expect_hybrid e (fun x => S x^r) + simp only [he, Fintype.expect_const] + +lemma sum_pow_tuples {I : Type*} [Fintype I] (a : I → ℝ) (r : ℕ) : + (∑i, a i)^r=∑t : Fin r → I, ∏j, a (t j) := by + have hh := Fintype.prod_sum (fun (_ : Fin r) (i : I) => a i) + simpa only [prod_const, card_univ, Fintype.card_fin] using hh + +lemma expect_condition {J : Type*} [Fintype J] [DecidableEq J] + {X : J → Type*} [∀j, Fintype (X j)] [∀j, Nonempty (X j)] + (W : Finset J) (h g : (∀j, X j) → ℝ) + (hh : ∀x y, (∀j∈W, x j=y j) → h x=h y) : + (𝔼 x, h x*g x) = 𝔼 x, h x*(𝔼 y, g (hybrid (fun j => decide (j∈W)) x y)) := by + have he x y : h (hybrid (fun j => decide (j∈W)) x y)=h x := by + apply hh + intro j hj + simp [hybrid, hj] + have hp := expect_hybrid (fun j => decide (j∈W)) (fun x => h x*g x) + simp only [he, ← mul_expect] at hp + exact hp.symm + +lemma square_moment_step {J I : Type*} [Fintype J] [DecidableEq J] [Fintype I] + {X : J → Type*} [∀j, Fintype (X j)] [∀j, Nonempty (X j)] + (U : I → Finset J) (f : I → (∀j, X j) → ℝ) + (hf : ∀i, ∀x y, (∀j∈U i, x j=y j) → f i x=f i y) + (k : ℕ) (hk : ∀i, (U i).card ≤ k) + (A D : ℝ) (hA : 0 ≤ A) (hD : 1 ≤ D) + (hcond : ∀ (W : Finset J) x, + (𝔼 y, ∑i, f i (hybrid (fun j => decide (j∈W)) x y)^2) ≤ A*D^W.card) + (r : ℕ) : + (𝔼 x, (∑i, f i x^2)^(r+1)) ≤ (A*D^(r*k))*(𝔼 x, (∑i, f i x^2)^r) := by + classical + let S := fun x => ∑i, f i x^2 + let h := fun (t : Fin r → I) x => ∏j, f (t j) x^2 + have hh t x : 0 ≤ h t x := prod_nonneg fun j _ => sq_nonneg _ + have hpow x : S x^r=∑t : Fin r → I, h t x := sum_pow_tuples _ r + have hbound (t : Fin r → I) : + (𝔼 x, h t x*S x) ≤ (A*D^(r*k))*(𝔼 x, h t x) := by + let W : Finset J := univ.biUnion (fun j => U (t j)) + have hw : W.card ≤ r*k := by + calc + _ ≤ ∑j : Fin r, (U (t j)).card := card_biUnion_le + _ ≤ ∑_j : Fin r, k := sum_le_sum fun j _ => hk (t j) + _ = _ := by simp + have hdep x y (hxy : ∀j∈W, x j=y j) : h t x=h t y := by + apply prod_congr rfl + intro j _ + rw [hf (t j) x y (fun a ha => hxy a (mem_biUnion.mpr ⟨j,mem_univ j,ha⟩))] + calc + _ = (𝔼 x, h t x*(𝔼 y, S (hybrid (fun j => decide (j∈W)) x y))) := + expect_condition W (h t) S hdep + _ ≤ (𝔼 x, h t x*(A*D^(r*k))) := by + apply expect_le_expect + intro x _ + apply mul_le_mul_of_nonneg_left _ (hh t x) + exact (hcond W x).trans (mul_le_mul_of_nonneg_left (pow_le_pow_right₀ hD hw) hA) + _ = _ := by rw [← expect_mul]; ring + change (𝔼 x, S x^(r+1)) ≤ _*(𝔼 x, S x^r) + calc + _ = ∑t : Fin r → I, (𝔼 x, h t x*S x) := by + simp only [pow_succ, hpow, sum_mul, expect_sum_comm] + _ ≤ ∑t : Fin r → I, (A*D^(r*k))*(𝔼 x, h t x) := + sum_le_sum fun t _ => hbound t + _ = (A*D^(r*k))*(𝔼 x, S x^r) := by + rw [← mul_sum, ← expect_sum_comm] + simp only [← hpow] + +lemma square_moment_bound {J I : Type*} [Fintype J] [DecidableEq J] [Fintype I] + {X : J → Type*} [∀j, Fintype (X j)] [∀j, Nonempty (X j)] + (U : I → Finset J) (f : I → (∀j, X j) → ℝ) + (hf : ∀i, ∀x y, (∀j∈U i, x j=y j) → f i x=f i y) + (k : ℕ) (hk : ∀i, (U i).card ≤ k) + (A D : ℝ) (hA : 0 ≤ A) (hD : 1 ≤ D) + (hcond : ∀ (W : Finset J) x, + (𝔼 y, ∑i, f i (hybrid (fun j => decide (j∈W)) x y)^2) ≤ A*D^W.card) + (r : ℕ) : + (𝔼 x, (∑i, f i x^2)^r) ≤ (A*D^(r*k))^r := by + have hD0 : 0 ≤ D := by linarith + have hbase : 0 ≤ A*D^(r*k) := mul_nonneg hA (pow_nonneg hD0 _) + have hind (t : ℕ) (ht : t ≤ r) : + (𝔼 x, (∑i, f i x^2)^t) ≤ (A*D^(r*k))^t := by + induction t with + | zero => simp only [pow_zero, Fintype.expect_const, le_refl] + | succ t ih => + have ht' : t ≤ r := by omega + have hi := ih ht' + have he := square_moment_step U f hf k hk A D hA hD hcond t + apply he.trans + calc + _ ≤ (A*D^(r*k))*(A*D^(r*k))^t := by + apply mul_le_mul _ hi + (expect_nonneg fun x _ => pow_nonneg (sum_nonneg fun i _ => sq_nonneg _) _) hbase + exact mul_le_mul_of_nonneg_left (pow_le_pow_right₀ hD (Nat.mul_le_mul_right k ht')) hA + _ = _ := by rw [pow_succ]; ring + exact hind r le_rfl + +lemma synthesis_norm_sq_bound {I E : Type*} [Fintype I] [DecidableEq I] + [NormedAddCommGroup E] [InnerProductSpace ℂ E] + (v : I → E) (D δ : ℝ) (hδ : 0 ≤ δ) + (hgram : ∀ i j, ‖inner ℂ (v i) (v j)‖ ≤ (if i = j then D else 0) + δ) + (a : I → ℂ) : + ‖∑ i, a i • v i‖ ^ 2 ≤ (D + Fintype.card I * δ) * ∑ i, ‖a i‖ ^ 2 := by + classical + have hcs : (∑ i, ‖a i‖) ^ 2 ≤ (Fintype.card I : ℝ) * ∑ i, ‖a i‖ ^ 2 := by + simpa using Finset.sum_mul_sq_le_sq_mul_sq (univ : Finset I) + (fun _ => (1 : ℝ)) (fun i => ‖a i‖) + calc + ‖∑ i, a i • v i‖ ^ 2 = + (∑ i, ∑ j, (starRingEnd ℂ) (a i) * a j * inner ℂ (v i) (v j)).re := by + rw [norm_sq_eq_re_inner (𝕜 := ℂ)] + change (inner ℂ _ _).re = _ + simp only [sum_inner, inner_sum, inner_smul_left, inner_smul_right, mul_sum] + rw [sum_comm] + congr 1 + apply sum_congr rfl; intro i _ + apply sum_congr rfl; intro j _ + ring + _ ≤ ∑ i, ∑ j, ‖a i‖ * ‖a j‖ * ‖inner ℂ (v i) (v j)‖ := by + simp only [Complex.re_sum] + apply sum_le_sum; intro i _ + apply sum_le_sum; intro j _ + simpa only [norm_mul, Complex.norm_conj] using + Complex.re_le_norm ((starRingEnd ℂ) (a i) * a j * inner ℂ (v i) (v j)) + _ ≤ ∑ i, ∑ j, ‖a i‖ * ‖a j‖ * ((if i = j then D else 0) + δ) := by + apply sum_le_sum; intro i _ + apply sum_le_sum; intro j _ + exact mul_le_mul_of_nonneg_left (hgram i j) (mul_nonneg (norm_nonneg _) (norm_nonneg _)) + _ = D * (∑ i, ‖a i‖ ^ 2) + δ * (∑ i, ‖a i‖) ^ 2 := by + simp_rw [mul_add, sum_add_distrib] + simp only [mul_ite, mul_zero, sum_ite_eq, mem_univ, ite_true] + simp only [← sum_mul, ← mul_sum] + simp only [← sq] + ring + _ ≤ (D + Fintype.card I * δ) * ∑ i, ‖a i‖ ^ 2 := by + nlinarith [mul_le_mul_of_nonneg_left hcs hδ] + +lemma analysis_of_synthesis {I E : Type*} [Fintype I] [DecidableEq I] + [NormedAddCommGroup E] [InnerProductSpace ℂ E] + (v : I → E) (C : ℝ) (hC : 0 ≤ C) + (h : ∀ a : I → ℂ, ‖∑ i, a i • v i‖ ^ 2 ≤ C * ∑ i, ‖a i‖ ^ 2) + (f : E) : ∑ i, ‖inner ℂ (v i) f‖ ^ 2 ≤ C * ‖f‖ ^ 2 := by + classical + let a : I → ℂ := fun i => inner ℂ (v i) f + let S : E := ∑ i, a i • v i + let t : ℝ := ∑ i, ‖a i‖ ^ 2 + have ht : 0 ≤ t := sum_nonneg fun _ _ => sq_nonneg _ + have heq : (inner ℂ S f).re = t := by + simp only [S, sum_inner, inner_smul_left, Complex.re_sum, t] + change (∑ i, ((starRingEnd ℂ) (a i) * a i).re) = _ + apply sum_congr rfl; intro i _ + rw [Complex.conj_mul', ← Complex.ofReal_pow, Complex.ofReal_re] + have htf : t ≤ ‖S‖ * ‖f‖ := by + rw [← heq] + exact (Complex.re_le_norm _).trans (norm_inner_le_norm _ _) + have hs : ‖S‖ ^ 2 ≤ C * t := h a + have hc : t ^ 2 ≤ C * t * ‖f‖ ^ 2 := by + calc + t ^ 2 ≤ (‖S‖ * ‖f‖) ^ 2 := pow_le_pow_left₀ ht htf 2 + _ = ‖S‖ ^ 2 * ‖f‖ ^ 2 := mul_pow _ _ _ + _ ≤ C * t * ‖f‖ ^ 2 := mul_le_mul_of_nonneg_right hs (sq_nonneg _) + change t ≤ C * ‖f‖ ^ 2 + by_cases ht0 : t = 0 + · rw [ht0] + exact mul_nonneg hC (sq_nonneg _) + · exact le_of_mul_le_mul_left (by nlinarith [hc]) (lt_of_le_of_ne ht (Ne.symm ht0)) + +noncomputable def expPhase (t : ℝ) : ℂ := Real.fourierChar t + +noncomputable def circleDistance (t : ℝ) : ℝ := |t - round t| + +@[simp] lemma expPhase_zero : expPhase 0 = 1 := by simp [expPhase] +@[simp] lemma norm_expPhase (t : ℝ) : ‖expPhase t‖ = 1 := Circle.norm_coe _ + +lemma expPhase_add (s t : ℝ) : expPhase (s+t) = expPhase s * expPhase t := by + simp [expPhase, AddChar.map_add_eq_mul] + +lemma expPhase_neg (t : ℝ) : expPhase (-t) = conj (expPhase t) := by + simp only [expPhase, AddChar.map_neg_eq_inv, Circle.coe_inv_eq_conj] + +lemma expPhase_sub (s t : ℝ) : expPhase (s-t) = expPhase s * conj (expPhase t) := by + rw [sub_eq_add_neg, expPhase_add, expPhase_neg] + +lemma expPhase_nat_mul (t : ℝ) (n : ℕ) : expPhase (n*t) = expPhase t^n := by + simpa only [expPhase, nsmul_eq_mul, Circle.coe_pow] using congrArg (fun z : Circle => (z : ℂ)) + (AddChar.map_nsmul_eq_pow Real.fourierChar n t) + +lemma expPhase_int (n : ℤ) : expPhase n = 1 := by + change Complex.exp (↑(2 * Real.pi * (n : ℝ)) * Complex.I) = 1 + rw [show (↑(2 * Real.pi * (n : ℝ)) : ℂ) * Complex.I = + (n : ℂ) * (2 * Real.pi * Complex.I) by push_cast; ring] + exact Complex.exp_int_mul_two_pi_mul_I n + +lemma expPhase_sub_int (t : ℝ) (n : ℤ) : expPhase (t-n) = expPhase t := by + rw [expPhase_sub, expPhase_int, map_one, mul_one] + +lemma circleDistance_nonneg (t : ℝ) : 0 ≤ circleDistance t := abs_nonneg _ + +lemma circleDistance_le_half (t : ℝ) : circleDistance t ≤ 1/2 := abs_sub_round t + +lemma circleDistance_le_abs_sub_int (t : ℝ) (n : ℤ) : circleDistance t ≤ |t-n| := + round_le t n + +lemma circleDistance_le_abs (t : ℝ) : circleDistance t ≤ |t| := by + simpa using circleDistance_le_abs_sub_int t 0 + +lemma circleDistance_sub_le (s t : ℝ) : circleDistance (s-t) ≤ + |(s-round s)-(t-round t)| := by + convert circleDistance_le_abs_sub_int (s-t) (round s-round t) using 1 + push_cast + congr 1 + ring + +lemma expPhase_sub_one_lower (t : ℝ) : 4*circleDistance t ≤ ‖expPhase t-1‖ := by + let u := t-(round t : ℝ) + have hu : |u| ≤ 1/2 := abs_sub_round t + have hp := Real.pi_pos + have hs := Real.mul_abs_le_abs_sin (x := Real.pi*u) + (by rw [abs_mul, abs_of_pos hp]; nlinarith) + rw [abs_mul, abs_of_pos hp] at hs + have hmul : 2/Real.pi*(Real.pi*|u|)=2*|u| := by field_simp + rw [hmul] at hs + rw [← expPhase_sub_int t (round t)] + change 4*|u| ≤ ‖Complex.exp (↑(2*Real.pi*u)*Complex.I)-1‖ + rw [mul_comm _ Complex.I, Complex.norm_exp_I_mul_ofReal_sub_one] + rw [show 2*Real.pi*u/2=Real.pi*u by ring, Real.norm_eq_abs, + abs_mul, abs_of_pos (by norm_num : (0 : ℝ)<2)] + linarith + +lemma linear_phase_sum_trivial (t : ℝ) (L : ℕ) : + ‖∑ m ∈ range L, expPhase (m*t)‖ ≤ L := by + calc + _ ≤ ∑ m ∈ range L, ‖expPhase (m*t)‖ := norm_sum_le _ _ + _ = L := by simp + +lemma linear_phase_sum_distance (t : ℝ) (L : ℕ) (ht : 0 < circleDistance t) : + ‖∑ m ∈ range L, expPhase (m*t)‖ ≤ 1 / (2*circleDistance t) := by + have hz : expPhase t ≠ 1 := by + intro he + have := expPhase_sub_one_lower t + rw [he, sub_self, norm_zero] at this + linarith + simp_rw [expPhase_nat_mul] + rw [geom_sum_eq hz, norm_div] + have hn : ‖expPhase t ^ L - 1‖ ≤ 2 := by + calc + _ ≤ ‖expPhase t^L‖+‖(1 : ℂ)‖ := norm_sub_le _ _ + _ = 2 := by simp; norm_num + calc + _ ≤ 2 / (4*circleDistance t) := + div_le_div₀ (by positivity) hn (by positivity) (expPhase_sub_one_lower t) + _ = 1 / (2*circleDistance t) := by ring + +lemma finite_phase_analysis {I : Type*} [Fintype I] [DecidableEq I] + (θ : I → ℝ) (L : ℕ) (d : ℝ) (hd : 0 < d) + (hsep : ∀ i j, i ≠ j → d ≤ circleDistance (θ j-θ i)) + (f : Fin L → ℂ) : + (∑ i, ‖∑ n : Fin L, f n * expPhase (-(n : ℝ)*θ i)‖ ^ 2) ≤ + ((L : ℝ) + Fintype.card I / (2*d)) * ∑ n, ‖f n‖ ^ 2 := by + let v : I → EuclideanSpace ℂ (Fin L) := fun i => WithLp.toLp 2 + (fun n : Fin L => expPhase ((n : ℝ)*θ i)) + let f' : EuclideanSpace ℂ (Fin L) := WithLp.toLp 2 f + have hinner (i j : I) : inner ℂ (v i) (v j) = + ∑ n ∈ range L, expPhase ((n : ℝ)*(θ j-θ i)) := by + rw [PiLp.inner_apply] + simp only [v, RCLike.inner_apply] + simp_rw [← expPhase_sub, ← mul_sub] + exact Fin.sum_univ_eq_sum_range (fun n : ℕ => expPhase ((n : ℝ)*(θ j-θ i))) L + have hg (i j : I) : ‖inner ℂ (v i) (v j)‖ ≤ + (if i=j then (L : ℝ) else 0) + 1/(2*d) := by + rw [hinner] + by_cases hij : i=j + · subst j + simp only [sub_self, mul_zero, expPhase_zero, sum_const, card_range, + nsmul_eq_mul, mul_one, Complex.norm_natCast, ite_true] + exact le_add_of_nonneg_right (by positivity) + · rw [ite_eq_right hij, zero_add] + exact (linear_phase_sum_distance _ L (hd.trans_le (hsep i j hij))).trans + (one_div_le_one_div_of_le (by positivity) (by linarith [hsep i j hij])) + have hs : ∀ a : I → ℂ, ‖∑ i, a i • v i‖ ^ 2 ≤ + ((L : ℝ)+Fintype.card I*(1/(2*d))) * ∑ i, ‖a i‖ ^ 2 := + synthesis_norm_sq_bound v L (1/(2*d)) (by positivity) hg + have h := analysis_of_synthesis v _ (by positivity) hs f' + have he (i : I) : inner ℂ (v i) f' = + ∑ n : Fin L, f n * expPhase (-(n : ℝ)*θ i) := by + simp only [PiLp.inner_apply, f', v, RCLike.inner_apply] + simp_rw [← expPhase_neg, neg_mul] + rw [PiLp.norm_sq_eq_of_L2] at h + simp only [he, f'] at h + simpa only [div_eq_mul_inv, one_mul] using h + +lemma finite_phase_analysis_average {I : Type*} [Fintype I] [DecidableEq I] + (θ : I → ℝ) (L : ℕ) (hL : 0 < L) (d : ℝ) (hd : 0 < d) + (hsep : ∀ i j, i ≠ j → d ≤ circleDistance (θ j-θ i)) + (f : Fin L → ℂ) : + (∑ i, ‖(L : ℂ)⁻¹ * ∑ n : Fin L, f n * expPhase (-(n : ℝ)*θ i)‖ ^ 2) ≤ + (1 + Fintype.card I / (2*d*L)) * ((L : ℝ)⁻¹ * ∑ n, ‖f n‖ ^ 2) := by + have h := finite_phase_analysis θ L d hd hsep f + simp only [norm_mul, norm_inv, Complex.norm_natCast, mul_pow, ← mul_sum] + have hL' : (0 : ℝ) < L := Nat.cast_pos.mpr hL + calc + _ ≤ (L : ℝ)⁻¹ ^ 2 * (((L : ℝ)+Fintype.card I/(2*d))*∑ n, ‖f n‖ ^ 2) := + mul_le_mul_of_nonneg_left h (sq_nonneg _) + _ = _ := by field_simp + +lemma stdAddChar_eq_expPhase {p : ℕ} [NeZero p] (a : ZMod p) : + ZMod.stdAddChar a=expPhase ((a.val : ℝ)/p) := by + rw [ZMod.stdAddChar_apply, ZMod.toCircle_apply] + change Complex.exp _ = Complex.exp _ + congr 1 + push_cast + ring + +lemma expPhase_sum {I : Type*} (s : Finset I) (f : I → ℝ) : + expPhase (∑ i∈s, f i)=∏ i∈s, expPhase (f i) := by + classical + induction s using Finset.induction_on with + | empty => simp + | @insert i s hi ih => rw [sum_insert hi, prod_insert hi, expPhase_add, ih] + +variable {J : Type*} [Fintype J] + +variable (p : J → ℕ) [∀ j, NeZero (p j)] + +abbrev ResidueSpace := ∀ j, ZMod (p j) + +noncomputable def prodChar (a z : ResidueSpace p) : ℂ := + ∏ j, ZMod.stdAddChar (a j*z j) + +noncomputable def frequencyAngle (a : ResidueSpace p) : ℝ := + ∑ j, (a j).val/(p j : ℝ) + +noncomputable def primeSupport (a : ResidueSpace p) : Finset J := + univ.filter fun j => a j ≠ 0 + +noncomputable def supportDenominator (a : ResidueSpace p) : ℕ := + ∏ j∈primeSupport p a, p j + +@[simp] lemma prodChar_zero (z : ResidueSpace p) : prodChar p 0 z=1 := by + simp [prodChar, AddChar.map_zero_eq_one] +@[simp] lemma prodChar_zero_right (a : ResidueSpace p) : prodChar p a 0=1 := by + simp [prodChar, AddChar.map_zero_eq_one] +lemma prodChar_add (a b z : ResidueSpace p) : + prodChar p (a+b) z=prodChar p a z*prodChar p b z := by + simp only [prodChar, Pi.add_apply, add_mul, AddChar.map_add_eq_mul, prod_mul_distrib] +lemma prodChar_add_right (a z w : ResidueSpace p) : + prodChar p a (z+w)=prodChar p a z*prodChar p a w := by + simp only [prodChar, Pi.add_apply, mul_add, AddChar.map_add_eq_mul, prod_mul_distrib] +lemma prodChar_neg (a z : ResidueSpace p) : prodChar p (-a) z=conj (prodChar p a z) := by + simp only [prodChar, Pi.neg_apply, neg_mul, AddChar.map_neg_eq_conj, map_prod] +lemma prodChar_sub (a b z : ResidueSpace p) : + prodChar p (a-b) z=prodChar p a z*conj (prodChar p b z) := by + rw [sub_eq_add_neg, prodChar_add, prodChar_neg] +lemma prodChar_symm (a z : ResidueSpace p) : prodChar p a z=prodChar p z a := by + simp only [prodChar, mul_comm] +lemma norm_prodChar (a z : ResidueSpace p) : ‖prodChar p a z‖=1 := by + simp only [prodChar, norm_prod, ZMod.stdAddChar_apply, Circle.norm_coe, prod_const_one] +lemma prodChar_nat_diagonal (a : ResidueSpace p) (n : ℕ) : + prodChar p a (fun j => (n : ZMod (p j)))=expPhase (n*frequencyAngle p a) := by + simp only [prodChar, frequencyAngle, mul_sum, expPhase_sum] + apply prod_congr rfl; intro j _ + rw [expPhase_nat_mul, ← stdAddChar_eq_expPhase] + simpa only [nsmul_eq_mul, Nat.cast_comm, mul_comm] using + AddChar.map_nsmul_eq_pow (ZMod.stdAddChar (N := p j)) n (a j) + +lemma prodChar_one_diagonal (a : ResidueSpace p) : + prodChar p a (fun _ => 1)=expPhase (frequencyAngle p a) := by + simpa using prodChar_nat_diagonal p a 1 + +lemma prodChar_eq_one_iff (a : ResidueSpace p) : + (∀ z, prodChar p a z=1) ↔ a=0 := by + classical + constructor + · intro h + funext j + have hj := h (Pi.single j 1) + have he : prodChar p a (Pi.single j 1)=ZMod.stdAddChar (a j) := by + unfold prodChar + rw [prod_eq_single j] + · simp only [Pi.single_eq_same, mul_one] + · intro i _ hij + simp only [Pi.single_eq_of_ne hij, mul_zero, AddChar.map_zero_eq_one] + · simp + rw [he, ← AddChar.map_zero_eq_one (ZMod.stdAddChar (N := p j))] at hj + exact ZMod.injective_stdAddChar hj + · rintro rfl z + exact prodChar_zero p z + +lemma frequencyAngle_separates + (hp : Pairwise fun i j => (p i).Coprime (p j)) (a b : ResidueSpace p) + (he : expPhase (frequencyAngle p a-frequencyAngle p b)=1) : a=b := by + classical + let : NeZero (∏ j, p j) := ⟨prod_ne_zero_iff.mpr (fun j _ => NeZero.ne (p j))⟩ + have h1 : prodChar p (a-b) (fun j => (1 : ZMod (p j)))=1 := by + rw [prodChar_sub, prodChar_one_diagonal, prodChar_one_diagonal] + simpa only [← expPhase_sub] using he + apply sub_eq_zero.mp + apply (prodChar_eq_one_iff p (a-b)).mp + intro z + let e := ZMod.prodEquivPi p hp + let n : ℕ := (e.symm z).val + have hn : (fun j => (n : ZMod (p j)))=z := by + have hz := e.apply_symm_apply z + convert hz using 1 + funext j + simp only [e, ZMod.prodEquivPi_apply] + rw [← ZMod.natCast_zmod_val (e.symm z), map_natCast] + rw [← hn, prodChar_nat_diagonal] + rw [prodChar_one_diagonal] at h1 + rw [expPhase_nat_mul, h1, one_pow] + +lemma complex_expect_prod_pi [DecidableEq J] {X : J → Type*} [∀ j, Fintype (X j)] + (f : ∀ j, X j → ℂ) : + (𝔼 x : ∀ j, X j, ∏ j, f j (x j))=∏ j, (𝔼 t : X j, f j t) := by + classical + simp only [expect_eq_sum_div_card, card_univ, prod_div_distrib, + Fintype.card_pi, Nat.cast_prod] + rw [Fintype.prod_sum] + +omit [Fintype J] in +lemma prime_char_expect (j : J) (a : ZMod (p j)) : + (𝔼 z : ZMod (p j), ZMod.stdAddChar (a*z))=if a=0 then 1 else 0 := by + rw [expect_eq_sum_div_card] + simp_rw [mul_comm a] + rw [AddChar.sum_mulShift _ (ZMod.isPrimitive_stdAddChar (p j))] + simp only [card_univ, ZMod.card] + split_ifs <;> simp_all + +lemma prodChar_expect [DecidableEq J] (a : ResidueSpace p) : + (𝔼 z, prodChar p a z)=if a=0 then 1 else 0 := by + classical + unfold prodChar + rw [complex_expect_prod_pi (fun j (z : ZMod (p j)) => ZMod.stdAddChar (a j*z))] + simp_rw [prime_char_expect] + by_cases ha : a=0 + · simp [ha] + · rw [ite_eq_right ha] + have hex : ∃ j, a j ≠ 0 := by + by_contra! h + exact ha (funext h) + obtain ⟨j, hj⟩ := hex + exact prod_eq_zero (mem_univ j) (ite_eq_right hj) + +lemma prodChar_orthogonal [DecidableEq J] (a b : ResidueSpace p) : + (𝔼 z, prodChar p a z*conj (prodChar p b z))=if a=b then 1 else 0 := by + simp_rw [← prodChar_sub] + rw [prodChar_expect] + simp only [sub_eq_zero] + +noncomputable def supportNumerator (a : ResidueSpace p) : ℕ := by + classical + exact ∑ j∈primeSupport p a, (a j).val * ∏ i∈(primeSupport p a).erase j, p i + +lemma supportDenominator_pos (a : ResidueSpace p) : 0 < supportDenominator p a := by + unfold supportDenominator + exact prod_pos fun j _ => Nat.pos_of_ne_zero (NeZero.ne (p j)) + +lemma frequencyAngle_numerator (a : ResidueSpace p) : + frequencyAngle p a = (supportNumerator p a : ℝ)/supportDenominator p a := by + classical + have hp0 (j : J) : (p j : ℝ) ≠ 0 := Nat.cast_ne_zero.mpr (NeZero.ne (p j)) + have hq : (supportDenominator p a : ℝ) ≠ 0 := + Nat.cast_ne_zero.mpr (Nat.ne_of_gt (supportDenominator_pos p a)) + apply (eq_div_iff hq).mpr + have hs : frequencyAngle p a = ∑ j∈primeSupport p a, (a j).val/(p j : ℝ) := by + unfold frequencyAngle primeSupport + symm + apply sum_filter_of_ne + intro j _ hj + contrapose! hj + simp [hj] + rw [hs, sum_mul] + unfold supportNumerator + push_cast + apply sum_congr rfl; intro j hj + have he : supportDenominator p a = p j * ∏ i∈(primeSupport p a).erase j, p i := + (mul_prod_erase _ _ hj).symm + rw [he] + push_cast + field_simp [hp0 j] + +lemma frequencyAngle_difference (a b : ResidueSpace p) : + frequencyAngle p a-frequencyAngle p b = + ((supportNumerator p a : ℤ)*supportDenominator p b- + supportNumerator p b*supportDenominator p a : ℤ)/ + ((supportDenominator p a*supportDenominator p b : ℕ) : ℝ) := by + rw [frequencyAngle_numerator, frequencyAngle_numerator] + have ha : (supportDenominator p a : ℝ) ≠ 0 := by positivity [supportDenominator_pos p a] + have hb : (supportDenominator p b : ℝ) ≠ 0 := by positivity [supportDenominator_pos p b] + push_cast + field_simp [ha, hb] + +lemma frequency_difference_not_dvd + (hp : Pairwise fun i j => (p i).Coprime (p j)) + (a b : ResidueSpace p) (hab : a ≠ b) : + ¬ ((supportDenominator p a*supportDenominator p b : ℕ) : ℤ) ∣ + ((supportNumerator p a : ℤ)*supportDenominator p b- + supportNumerator p b*supportDenominator p a) := by + rintro ⟨k, hk⟩ + apply hab + apply frequencyAngle_separates p hp + rw [frequencyAngle_difference, hk] + have hq : ((supportDenominator p a*supportDenominator p b : ℕ) : ℝ) ≠ 0 := by + positivity [supportDenominator_pos p a, supportDenominator_pos p b] + push_cast at hq ⊢ + rw [mul_div_cancel_left₀ _ hq] + exact expPhase_int k + +lemma frequencyAngle_remainder (a : ResidueSpace p) : + expPhase (frequencyAngle p a) = + expPhase ((supportNumerator p a % supportDenominator p a : ℕ)/ + (supportDenominator p a : ℝ)) := by + rw [frequencyAngle_numerator] + have hq : (supportDenominator p a : ℝ) ≠ 0 := by + exact Nat.cast_ne_zero.mpr (Nat.ne_of_gt (supportDenominator_pos p a)) + have he : (supportNumerator p a : ℝ)/supportDenominator p a = + (supportNumerator p a % supportDenominator p a : ℕ)/(supportDenominator p a : ℝ)+ + (supportNumerator p a / supportDenominator p a : ℕ) := by + apply (div_eq_iff hq).mpr + rw [add_mul, div_mul_cancel₀ _ hq] + norm_cast + simpa only [mul_comm] using (Nat.mod_add_div (supportNumerator p a) (supportDenominator p a)).symm + rw [he, expPhase_add] + have hi : expPhase ((supportNumerator p a / supportDenominator p a : ℕ) : ℝ)=1 := by + exact_mod_cast expPhase_int (supportNumerator p a / supportDenominator p a : ℕ) + rw [hi, mul_one] + +lemma bounded_frequency_card + (hp : Pairwise fun i j => (p i).Coprime (p j)) (Q : ℕ) + (F : Finset (ResidueSpace p)) + (hF : ∀ a∈F, supportDenominator p a ≤ Q) : F.card ≤ Q^2 := by + classical + let e : F → Fin Q × Fin Q := fun a => + (⟨supportDenominator p a-1, by + have := supportDenominator_pos p a + have := hF a a.property + omega⟩, + ⟨supportNumerator p a % supportDenominator p a, + (Nat.mod_lt _ (supportDenominator_pos p a)).trans_le (hF a a.property)⟩) + have he : Function.Injective e := by + intro a b hab + have hq : supportDenominator p a=supportDenominator p b := by + have h := congrArg (fun t : Fin Q × Fin Q => t.1.val) hab + have := supportDenominator_pos p a + have := supportDenominator_pos p b + change supportDenominator p a-1=supportDenominator p b-1 at h + omega + have hn : supportNumerator p a % supportDenominator p a= + supportNumerator p b % supportDenominator p b := + congrArg (fun t : Fin Q × Fin Q => t.2.val) hab + apply Subtype.ext + apply frequencyAngle_separates p hp + rw [expPhase_sub, frequencyAngle_remainder, frequencyAngle_remainder, hn, hq] + rw [Complex.mul_conj', norm_expPhase] + norm_num + have hcard := Fintype.card_le_of_injective e he + simpa only [Fintype.card_coe, Fintype.card_prod, Fintype.card_fin, sq] using hcard + +lemma rational_circleDistance_lower (k : ℤ) (q : ℕ) (hq : 0 < q) + (hnd : ¬ (q : ℤ) ∣ k) : 1/(q : ℝ) ≤ circleDistance ((k : ℝ)/q) := by + have hqR : 0 < (q : ℝ) := Nat.cast_pos.mpr hq + let n := round ((k : ℝ)/q) + have hn : k-(q : ℤ)*n ≠ 0 := by + intro he + apply hnd + exact ⟨n, by linarith⟩ + have hI : (1 : ℤ) ≤ |k-(q : ℤ)*n| := by + have := abs_pos.mpr hn + omega + have hR : (1 : ℝ) ≤ |(k : ℝ)-(q : ℝ)*(n : ℝ)| := by exact_mod_cast hI + have he : |(k : ℝ)-(q : ℝ)*(n : ℝ)| = (q : ℝ)*circleDistance ((k : ℝ)/q) := by + calc + _ = |(q : ℝ)*((k : ℝ)/q-(n : ℝ))| := by congr 1; field_simp + _ = _ := by rw [abs_mul, abs_of_pos hqR]; rfl + rw [he] at hR + exact (div_le_iff₀ hqR).mpr (by simpa only [mul_comm] using hR) + +lemma frequency_spacing (hp : Pairwise fun i j => (p i).Coprime (p j)) + (a b : ResidueSpace p) (hab : a ≠ b) (Q : ℕ) + (ha : supportDenominator p a ≤ Q) (hb : supportDenominator p b ≤ Q) + (m : ℕ) (hma : m.Coprime (supportDenominator p a)) + (hmb : m.Coprime (supportDenominator p b)) : + 1/(Q : ℝ)^2 ≤ circleDistance (m*frequencyAngle p a-m*frequencyAngle p b) := by + have hQ : 0 < Q := (supportDenominator_pos p a).trans_le ha + let q := supportDenominator p a*supportDenominator p b + let k : ℤ := (supportNumerator p a : ℤ)*supportDenominator p b- + supportNumerator p b*supportDenominator p a + have hq : 0 < q := Nat.mul_pos (supportDenominator_pos p a) (supportDenominator_pos p b) + have hmk : ¬ (q : ℤ) ∣ (m : ℤ)*k := by + intro h + have hc : IsCoprime (q : ℤ) (m : ℤ) := (hma.mul_right hmb).symm.cast + exact frequency_difference_not_dvd p hp a b hab (hc.dvd_of_dvd_mul_left h) + have hr := rational_circleDistance_lower ((m : ℤ)*k) q hq hmk + have he : m*frequencyAngle p a-m*frequencyAngle p b=((m : ℤ)*k : ℤ)/(q : ℝ) := by + rw [← mul_sub, frequencyAngle_difference] + dsimp only [k, q] + push_cast + ring + rw [he] + apply le_trans _ hr + apply one_div_le_one_div_of_le (Nat.cast_pos.mpr hq) + have hqq := Nat.mul_le_mul ha hb + simpa only [q, sq, Nat.cast_mul] using (show (supportDenominator p a : ℝ)*(supportDenominator p b : ℝ) ≤ (Q : ℝ)*(Q : ℝ) by exact_mod_cast hqq) + +lemma arithmetic_phase_analysis {I : Type*} [Fintype I] [DecidableEq I] + (hp : Pairwise fun i j => (p i).Coprime (p j)) + (a : I → ResidueSpace p) (hinj : Function.Injective a) (Q : ℕ) (hQ : 0 < Q) + (ha : ∀ i, supportDenominator p (a i) ≤ Q) + (m : ℕ) (hm : ∀ i, m.Coprime (supportDenominator p (a i))) + (L : ℕ) (f : Fin L → ℂ) : + (∑ i, ‖∑ n : Fin L, f n*expPhase (-(n : ℝ)*(m*frequencyAngle p (a i)))‖^2) ≤ + (L+(Q : ℝ)^4/2)*∑n, ‖f n‖^2 := by + have hc : Fintype.card I ≤ Q^2 := by + have hh := bounded_frequency_card p hp Q (univ.image a) (by + intro b hb + obtain ⟨i, _, rfl⟩ := mem_image.mp hb + exact ha i) + simpa only [card_image_of_injective _ hinj, card_univ] using hh + have hs (i j : I) (hij : i ≠ j) : + 1/(Q : ℝ)^2 ≤ circleDistance (m*frequencyAngle p (a j)-m*frequencyAngle p (a i)) := + frequency_spacing p hp (a j) (a i) (fun h => hij (hinj h).symm) Q (ha j) (ha i) m (hm j) (hm i) + have hh := finite_phase_analysis (fun i => m*frequencyAngle p (a i)) L (1/(Q : ℝ)^2) + (by positivity) hs f + apply hh.trans + apply mul_le_mul_of_nonneg_right _ (sum_nonneg fun _ _ => sq_nonneg _) + apply add_le_add_right + have hQR : (0 : ℝ) < Q := Nat.cast_pos.mpr hQ + calc + (Fintype.card I : ℝ)/(2*(1/(Q : ℝ)^2)) ≤ (Q : ℝ)^2/(2*(1/(Q : ℝ)^2)) := by + exact div_le_div_of_nonneg_right (by exact_mod_cast hc) (by positivity) + _ = (Q : ℝ)^4/2 := by field_simp + +noncomputable def residueGate (q : ℕ) (x : ZMod q) : ℝ := + (if x=0 then (q : ℝ) else 0)-1 + +lemma sum_char_nonzero {q : ℕ} [NeZero q] (x : ZMod q) : + (∑ a : ZMod q, if a≠0 then ZMod.stdAddChar (a*x) else 0)= + (residueGate q x : ℂ) := by + classical + have hs := AddChar.sum_mulShift x (ZMod.isPrimitive_stdAddChar q) + have he : (∑ a : ZMod q, ZMod.stdAddChar (a*x))= + (∑ a : ZMod q, if a≠0 then ZMod.stdAddChar (a*x) else 0)+1 := by + calc + _ = ∑ a : ZMod q, ((if a≠0 then ZMod.stdAddChar (a*x) else 0)+if a=0 then 1 else 0) := by + apply sum_congr rfl; intro a _ + by_cases ha : a=0 <;> simp [ha, AddChar.map_zero_eq_one] + _ = _ := by simp only [sum_add_distrib, sum_ite_eq', mem_univ, ite_true] + have hs' : (∑ a : ZMod q, ZMod.stdAddChar (a*x))=if x=0 then (q : ℂ) else 0 := by + simpa only [ZMod.card, apply_ite, Nat.cast_zero] using hs + unfold residueGate + push_cast + rw [hs'] at he + split_ifs at * <;> push_cast <;> linear_combination -he + +omit [∀ j, NeZero (p j)] in +lemma exact_support_iff [DecidableEq J] (U : Finset J) (a : ResidueSpace p) : + primeSupport p a=U ↔ ∀j, (a j≠0 ↔ j∈U) := by + simp only [Finset.ext_iff, primeSupport, mem_filter, mem_univ, true_and] + +lemma sum_char_exact [DecidableEq J] (U : Finset J) (z : ResidueSpace p) : + (∑ a : ResidueSpace p, if primeSupport p a=U then prodChar p a z else 0)= + ∏ j∈U, (residueGate (p j) (z j) : ℂ) := by + classical + let w := fun j (a : ZMod (p j)) => + if (if j∈U then a≠0 else a=0) then ZMod.stdAddChar (a*z j) else 0 + have he (a : ResidueSpace p) : (if primeSupport p a=U then prodChar p a z else 0)=∏j, w j (a j) := by + by_cases ha : primeSupport p a=U + · rw [ite_eq_left ha] + apply prod_congr rfl; intro j _ + have hj := (exact_support_iff p U a).mp ha j + by_cases hU : j∈U <;> simp_all [w] + · rw [ite_eq_right ha] + have hn : ∃j, ¬ (a j≠0 ↔ j∈U) := by + simpa only [exact_support_iff, not_forall] using ha + obtain ⟨j,hj⟩ := hn + symm + apply prod_eq_zero (mem_univ j) + by_cases hU : j∈U <;> simp_all [w] + simp only [he] + rw [← Fintype.prod_sum] + have hj (j : J) : (∑ a : ZMod (p j), w j a)=if j∈U then (residueGate (p j) (z j) : ℂ) else 1 := by + by_cases hU : j∈U + · simp only [w, hU, ite_true] + exact sum_char_nonzero (z j) + · simp only [w, hU, ite_false, sum_ite_eq', mem_univ, ite_true, zero_mul, AddChar.map_zero_eq_one] + simp_rw [hj] + rw [prod_ite_mem] + simp + +noncomputable def exactGate [DecidableEq J] (U : Finset J) (z : ResidueSpace p) : ℝ := + ∏j∈U, residueGate (p j) (z j) + +lemma exactGate_fourier [DecidableEq J] (U : Finset J) (z : ResidueSpace p) : + (exactGate p U z : ℂ) = ∑a∈univ.filter (fun a => primeSupport p a=U), prodChar p a z := by + rw [sum_filter, sum_char_exact] + simp only [exactGate, Complex.ofReal_prod] + +lemma prodChar_neg_right (a z : ResidueSpace p) : prodChar p a (-z)=conj (prodChar p a z) := by + rw [prodChar_symm, prodChar_neg, prodChar_symm] + +lemma prodChar_sub_right (a z w : ResidueSpace p) : + prodChar p a (z-w)=prodChar p a z*conj (prodChar p a w) := by + rw [sub_eq_add_neg, prodChar_add_right, prodChar_neg_right] + +noncomputable def fourierPolynomial [DecidableEq J] (c : ResidueSpace p → ℂ) (z : ResidueSpace p) : ℂ := + ∑a, c a*prodChar p a z + +lemma prodChar_norm_sq (a z : ResidueSpace p) : + prodChar p a z*conj (prodChar p a z)=1 := by + rw [Complex.mul_conj', norm_prodChar] + norm_num + +lemma fourierPolynomial_parseval [DecidableEq J] (c : ResidueSpace p → ℂ) : + (𝔼 z, ‖fourierPolynomial p c z‖^2)=∑a, ‖c a‖^2 := by + have he : (𝔼 z, fourierPolynomial p c z*conj (fourierPolynomial p c z))= + ∑a, c a*conj (c a) := by + simp only [fourierPolynomial, map_sum, sum_mul, mul_sum, map_mul] + rw [expect_sum_comm] + apply sum_congr rfl; intro a _ + rw [expect_sum_comm] + have he a b z : c a*prodChar p a z*(conj (c b)*conj (prodChar p b z))= + c a*conj (c b)*(prodChar p a z*conj (prodChar p b z)) := by ring + simp only [he, ← mul_expect, prodChar_orthogonal] + simp + apply Complex.ofReal_injective + simpa only [Complex.mul_conj', ← Complex.ofReal_pow, ← Complex.ofReal_sum, + ← Complex.ofReal_expect] using he + +lemma fourierPolynomial_reconstruction [DecidableEq J] (f : ResidueSpace p → ℂ) (z : ResidueSpace p) : + fourierPolynomial p (fun a => 𝔼 x, f x*conj (prodChar p a x)) z=f z := by + classical + unfold fourierPolynomial + simp_rw [Finset.expect_mul] + rw [← expect_sum_comm] + have he x : (∑a, f x*conj (prodChar p a x)*prodChar p a z)= + f x*(Fintype.card (ResidueSpace p))*(if z=x then 1 else 0) := by + simp_rw [mul_assoc, mul_comm (conj _), ← prodChar_sub_right] + rw [← mul_sum] + have hs := prodChar_expect p (z-x) + simp_rw [prodChar_symm p _ (z-x)] + rw [expect_eq_sum_div_card] at hs + have hc : (Fintype.card (ResidueSpace p) : ℂ) ≠ 0 := by + exact Nat.cast_ne_zero.mpr Fintype.card_ne_zero + have hs' := (div_eq_iff hc).mp hs + rw [hs'] + simp only [sub_eq_zero] + ring + simp only [he, expect_eq_sum_div_card, mul_ite, mul_one, mul_zero, + sum_ite_eq, mem_univ, ite_true, card_univ] + exact mul_div_cancel_right₀ _ (Nat.cast_ne_zero.mpr Fintype.card_ne_zero) + +omit [Fintype J] in +lemma residue_crt [DecidableEq J] + (hp : Pairwise fun i j => (p i).Coprime (p j)) (B : Finset J) (z : ResidueSpace p) : + ∃ a : ℕ, a < ∏j∈B, p j ∧ ∀n : ℕ, + (∀j∈B, (n : ZMod (p j))=z j) ↔ n % (∏j∈B, p j)=a := by + classical + let q := ∏j : B, p j + have hq : 0 < q := prod_pos fun j _ => Nat.pos_of_ne_zero (NeZero.ne (p j)) + let : NeZero q := ⟨Nat.ne_of_gt hq⟩ + have hpB : Pairwise fun i j : B => (p i).Coprime (p j) := fun i j hij => + hp (Subtype.val_injective.ne hij) + let e := ZMod.prodEquivPi (fun j : B => p j) hpB + let w := e.symm (fun j : B => z j) + have hval := ZMod.val_lt w + have hqe : q=∏j∈B, p j := prod_coe_sort B p + refine ⟨w.val, by simpa only [← hqe] using hval, ?_⟩ + intro n + have he : (∀j∈B, (n : ZMod (p j))=z j) ↔ (n : ZMod q)=w := by + constructor + · intro h + apply e.injective + rw [e.apply_symm_apply] + funext j + simp only [e, ZMod.prodEquivPi_apply, map_natCast] + exact h j j.property + · intro h j hj + have hh := congrArg (fun u => e u ⟨j,hj⟩) h + have hw : e w=(fun j : B => z j) := e.apply_symm_apply _ + rw [hw] at hh + simpa only [e, ZMod.prodEquivPi_apply, map_natCast] using hh + rw [he, ← hqe] + constructor + · intro h + simpa only [ZMod.val_natCast] using congrArg ZMod.val h + · intro h + apply ZMod.val_injective + simpa only [ZMod.val_natCast] using h + +omit [∀j, NeZero (p j)] in +lemma support_coprime [DecidableEq J] + (hp : Pairwise fun i j => (p i).Coprime (p j)) + (B : Finset J) (a : ResidueSpace p) (hB : Disjoint B (primeSupport p a)) : + (∏j∈B, p j).Coprime (supportDenominator p a) := by + apply Nat.coprime_prod_left_iff.mpr + intro i hi + apply Nat.coprime_prod_right_iff.mpr + intro j hj + exact hp (fun he => (disjoint_left.mp hB hi) (he ▸ hj)) + +omit [∀j, NeZero (p j)] in +lemma product_indicator [DecidableEq J] (B : Finset J) (z : ResidueSpace p) (n : ℕ) : + (∏j∈B, (if (n : ZMod (p j))=z j then (p j : ℂ) else 0))= + (∏j∈B, p j : ℕ)*(if ∀j∈B, (n : ZMod (p j))=z j then 1 else 0) := by + classical + by_cases h : ∀j∈B, (n : ZMod (p j))=z j + · rw [ite_eq_left h, mul_one] + push_cast + apply prod_congr rfl; intro j hj + rw [ite_eq_left (h j hj)] + · rw [ite_eq_right h, mul_zero] + push Not at h + obtain ⟨j,hj,he⟩ := h + exact prod_eq_zero hj (ite_eq_right he) + +omit [∀j, NeZero (p j)] in +lemma exactGate_expand [DecidableEq J] (B : Finset J) (z : ResidueSpace p) (n : ℕ) : + (exactGate p B (z-fun j => (n : ZMod (p j))) : ℂ)= + ∑S∈B.powerset, (-1 : ℂ)^(B\S).card*(∏j∈S, p j : ℕ)* + (if ∀j∈S, (n : ZMod (p j))=z j then 1 else 0) := by + classical + simp only [exactGate, Complex.ofReal_prod] + have he j : (residueGate (p j) ((z-fun j => (n : ZMod (p j))) j) : ℂ)= + (if (n : ZMod (p j))=z j then (p j : ℂ) else 0)+(-1) := by + dsimp only [residueGate, Pi.sub_apply] + by_cases hn : (n : ZMod (p j))=z j + · simp [hn, sub_eq_add_neg] + · have hz : z j-(n : ZMod (p j))≠0 := fun h => hn (sub_eq_zero.mp h).symm + simp [hn, hz] + simp only [he] + rw [prod_add] + apply sum_congr rfl; intro S _ + rw [product_indicator] + simp only [prod_const] + ring + +lemma vector_signed_sum_bound {I T : Type*} [Fintype I] [DecidableEq I] + (S : Finset T) (v : T → I → ℂ) (sgn : T → ℂ) (C : ℝ) (hC : 0 ≤ C) + (hsgn : ∀t∈S, ‖sgn t‖ ≤ 1) (hv : ∀t∈S, (∑i, ‖v t i‖^2) ≤ C^2) : + (∑i, ‖∑t∈S, sgn t*v t i‖^2) ≤ (S.card*C)^2 := by + let w : T → EuclideanSpace ℂ I := fun t => sgn t • WithLp.toLp 2 (v t) + have hw t (ht : t∈S) : ‖w t‖ ≤ C := by + have hh : ‖(WithLp.toLp 2 (v t) : EuclideanSpace ℂ I)‖ ≤ C := by + apply (sq_le_sq₀ (norm_nonneg _) hC).mp + rw [PiLp.norm_sq_eq_of_L2] + exact hv t ht + exact (norm_smul_le _ _).trans (by nlinarith [hsgn t ht, norm_nonneg (sgn t)]) + have hh : ‖∑t∈S, w t‖ ≤ S.card*C := by + calc + _ ≤ ∑t∈S, ‖w t‖ := norm_sum_le _ _ + _ ≤ ∑_t∈S, C := sum_le_sum fun t ht => hw t ht + _ = _ := by simp + have he : (∑t∈S, w t)=(WithLp.toLp 2 (fun i => ∑t∈S, sgn t*v t i) : EuclideanSpace ℂ I) := by + ext i + simp only [w, WithLp.ofLp_sum, Finset.sum_apply, WithLp.ofLp_smul, + Pi.smul_apply, smul_eq_mul] + rw [he, ← sq_le_sq₀ (norm_nonneg _) (mul_nonneg (Nat.cast_nonneg _) hC), PiLp.norm_sq_eq_of_L2] at hh + exact hh + +lemma sum_residue_progression {E : Type*} [AddCommMonoid E] + (f : ℕ → E) (L q a : ℕ) (hq : 0 < q) (ha : a < q) : + (∑ n ∈ range L, if n%q=a then f n else 0)= + ∑ t ∈ range (L/q+1), if a+q*t a+q*t) + · intro t ht + obtain ⟨_, ht⟩ := mem_filter.mp ht + exact mem_filter.mpr ⟨mem_range.mpr ht, by rw [Nat.add_mul_mod_self_left, Nat.mod_eq_of_lt ha]⟩ + · intro t ht u hu he + exact Nat.eq_of_mul_eq_mul_left hq (Nat.add_left_cancel he) + · intro n hn + obtain ⟨hn, hnq⟩ := mem_filter.mp hn + have hnL := mem_range.mp hn + have he : a+q*(n/q)=n := by rw [← hnq]; exact Nat.mod_add_div n q + refine ⟨n/q, mem_filter.mpr ⟨mem_range.mpr ?_, by rwa [he]⟩, he⟩ + exact Nat.lt_succ_of_le (Nat.div_le_div_right (Nat.le_of_lt hnL)) + · intro t _ + rfl + +lemma progression_analysis {I : Type*} [Fintype I] [DecidableEq I] + (hp : Pairwise fun i j => (p i).Coprime (p j)) + (b : I → ResidueSpace p) (hinj : Function.Injective b) (Q : ℕ) (hQ : 0 < Q) + (hb : ∀ i, supportDenominator p (b i) ≤ Q) + (q : ℕ) (hq : 0 < q) (hcop : ∀ i, q.Coprime (supportDenominator p (b i))) + (L a : ℕ) (ha : a < q) (f : ℕ → ℂ) (M : ℝ) (hM : 0 ≤ M) + (hf : ∀ n if a+q*t.val pow_le_pow_left₀ (norm_nonneg _) (hg t) 2 + _ = _ := by simp + have hh := arithmetic_phase_analysis p hp b hinj Q hQ hb q hcop K g + have he i : (∑ n∈range L, if n%q=a then f n*expPhase (-(n : ℝ)*frequencyAngle p (b i)) else 0)= + expPhase (-(a : ℝ)*frequencyAngle p (b i))* + ∑t : Fin K, g t*expPhase (-(t : ℝ)*(q*frequencyAngle p (b i))) := by + rw [sum_residue_progression _ L q a hq ha, mul_sum] + dsimp only [g] + rw [Fin.sum_univ_eq_sum_range (fun t : ℕ => expPhase (-(a : ℝ)*frequencyAngle p (b i))* + ((if a+q*t (p i).Coprime (p j)) + (b : I → ResidueSpace p) (hinj : Function.Injective b) (Q : ℕ) (hQ : 0 < Q) + (hb : ∀i, supportDenominator p (b i) ≤ Q) + (q : ℕ) (hq : 0 < q) (hcop : ∀i, q.Coprime (supportDenominator p (b i))) + (L : ℕ) (hL : 0 < L) (hsmall : 2*(q : ℝ) ≤ L) + (hsmall' : (q : ℝ)*Q^4 ≤ L) (a : ℕ) (ha : a (n : ZMod (p j))) : ℂ) + +omit [∀j, NeZero (p j)] in +lemma gateCoefficient_expand [DecidableEq J] (L : ℕ) (f : ℕ → ℂ) + (B : Finset J) (z a : ResidueSpace p) : + gateCoefficient p L f B z a= + ∑S∈B.powerset, (-1 : ℂ)^(B\S).card* + (((∏j∈S, p j : ℕ) : ℂ)/L)* + (∑n∈range L, if ∀j∈S, (n : ZMod (p j))=z j then + f n*expPhase (-(n : ℝ)*frequencyAngle p a) else 0) := by + classical + unfold gateCoefficient + simp_rw [exactGate_expand, mul_sum] + rw [sum_comm] + apply sum_congr rfl; intro S _ + apply sum_congr rfl; intro n _ + split_ifs + · simp only [mul_one]; ring + · simp only [mul_zero] + +lemma gateCoefficient_bound [DecidableEq J] {I : Type*} [Fintype I] [DecidableEq I] + (hp : Pairwise fun i j => (p i).Coprime (p j)) + (a : I → ResidueSpace p) (hinj : Function.Injective a) (Q : ℕ) (hQ : 0 < Q) + (ha : ∀i, supportDenominator p (a i) ≤ Q) + (B : Finset J) (hB : ∏j∈B, p j ≤ Q) + (hdis : ∀i, Disjoint B (primeSupport p (a i))) (z : ResidueSpace p) + (L : ℕ) (hL : 0 < L) (hsmall : 2*(Q : ℝ) ≤ L) + (hsmall' : (Q : ℝ)^5 ≤ L) (f : ℕ → ℂ) (M : ℝ) (hM : 0 ≤ M) + (hf : ∀n (((∏j∈S, p j : ℕ) : ℂ)/L)* + ∑n∈range L, if ∀j∈S, (n : ZMod (p j))=z j then + f n*expPhase (-(n : ℝ)*frequencyAngle p (a i)) else 0 + let sgn := fun S : Finset J => (-1 : ℂ)^(B\S).card + have hv S (hS : S∈B.powerset) : (∑i, ‖v S i‖^2) ≤ (2*M)^2 := by + have hSB := mem_powerset.mp hS + have hq : 0 < ∏j∈S, p j := prod_pos fun j _ => Nat.pos_of_ne_zero (NeZero.ne (p j)) + have hqB : 0 < ∏j∈B, p j := prod_pos fun j _ => Nat.pos_of_ne_zero (NeZero.ne (p j)) + have hqQ : ∏j∈S, p j ≤ Q := (Nat.le_of_dvd hqB (prod_dvd_prod_of_subset S B p hSB)).trans hB + have hqR : ((∏j∈S, p j : ℕ) : ℝ) ≤ Q := Nat.cast_le.mpr hqQ + obtain ⟨b,hb,he⟩ := residue_crt p hp S z + have hcp i : (∏j∈S,p j).Coprime (supportDenominator p (a i)) := + support_coprime p hp S (a i) ((hdis i).mono_left hSB) + have h := progression_normalized_bound p hp a hinj Q hQ ha (∏j∈S,p j) hq hcp L hL + (by linarith) (by nlinarith [mul_le_mul_of_nonneg_right hqR (pow_nonneg (Nat.cast_nonneg Q) 4)]) + b hb f M hM hf + dsimp only [v] + simp only [he] + exact h.trans_eq (by ring) + have hsgn S (_hS : S∈B.powerset) : ‖sgn S‖ ≤ 1 := by simp [sgn] + have hh := vector_signed_sum_bound B.powerset v sgn (2*M) (by positivity) hsgn hv + have he i : gateCoefficient p L f B z (a i)=∑S∈B.powerset, sgn S*v S i := by + rw [gateCoefficient_expand] + apply sum_congr rfl; intro S _ + dsimp only [sgn,v] + ring + simp only [he] + apply hh.trans_eq + rw [card_powerset, Nat.cast_pow, Nat.cast_ofNat] + rw [mul_pow, mul_pow, ← pow_mul, Nat.mul_comm B.card 2, pow_mul] + ring + +noncomputable def coordinateFreeze [DecidableEq J] (W : Finset J) + (z x : ResidueSpace p) : ResidueSpace p := fun j => if j∈W then z j else x j + +omit [Fintype J] [∀j, NeZero (p j)] in +lemma exactGate_freeze [DecidableEq J] (U W : Finset J) (z x : ResidueSpace p) : + exactGate p U (coordinateFreeze p W z x)= + exactGate p (U∩W) z*exactGate p (U\W) x := by + classical + have he : U=(U∩W)∪(U\W) := by rw [union_comm, sdiff_union_inter] + conv_lhs => rw [he] + rw [exactGate, prod_union (disjoint_sdiff_inter U W).symm] + congr 1 + · apply prod_congr rfl; intro j hj + simp only [coordinateFreeze, (mem_inter.mp hj).2, ite_true] + · apply prod_congr rfl; intro j hj + simp only [coordinateFreeze, (mem_sdiff.mp hj).2, ite_false] + +omit [Fintype J] [∀j, NeZero (p j)] in +lemma coordinateFreeze_sub [DecidableEq J] (W : Finset J) (z x t : ResidueSpace p) : + coordinateFreeze p W z x-t=coordinateFreeze p W (z-t) (x-t) := by + ext j + by_cases hj : j∈W <;> simp [coordinateFreeze, hj] + +noncomputable def liftPiece [DecidableEq J] (L : ℕ) (f : ℕ → ℝ) + (U : Finset J) (z : ResidueSpace p) : ℝ := + (L : ℝ)⁻¹*∑n∈range L, f n*exactGate p U (z-fun j => (n : ZMod (p j))) + +lemma liftPiece_freeze_fourier [DecidableEq J] (L : ℕ) (f : ℕ → ℝ) + (U W : Finset J) (z x : ResidueSpace p) : + (liftPiece p L f U (coordinateFreeze p W z x) : ℂ)= + fourierPolynomial p (fun a => if primeSupport p a=U\W then + gateCoefficient p L (fun n => (f n : ℂ)) (U∩W) z a else 0) x := by + classical + have he (n : ℕ) : (exactGate p U (coordinateFreeze p W z x-fun j => (n : ZMod (p j))) : ℂ)= + (exactGate p (U∩W) (z-fun j => (n : ZMod (p j))) : ℂ)* + ∑a∈univ.filter (fun a => primeSupport p a=U\W), + prodChar p a x*conj (expPhase ((n : ℝ)*frequencyAngle p a)) := by + rw [coordinateFreeze_sub, exactGate_freeze, Complex.ofReal_mul, + exactGate_fourier p (U\W)] + simp only [prodChar_sub_right, prodChar_nat_diagonal] + simp only [liftPiece, Complex.ofReal_mul, Complex.ofReal_inv, Complex.ofReal_natCast, + Complex.ofReal_sum, he] + simp only [fourierPolynomial, gateCoefficient, ite_mul, zero_mul] + rw [← sum_filter] + simp_rw [mul_sum] + rw [sum_comm] + apply sum_congr rfl; intro a _ + rw [sum_mul] + apply sum_congr rfl; intro n _ + rw [show expPhase (-(n : ℝ)*frequencyAngle p a)= + conj (expPhase ((n : ℝ)*frequencyAngle p a)) by rw [neg_mul, expPhase_neg]] + ring + +lemma liftPiece_conditional_parseval [DecidableEq J] (L : ℕ) (f : ℕ → ℝ) + (U W : Finset J) (z : ResidueSpace p) : + (𝔼 x, liftPiece p L f U (coordinateFreeze p W z x)^2)= + ∑a∈univ.filter (fun a => primeSupport p a=U\W), + ‖gateCoefficient p L (fun n => (f n : ℂ)) (U∩W) z a‖^2 := by + classical + have hh := fourierPolynomial_parseval p (fun a => if primeSupport p a=U\W then + gateCoefficient p L (fun n => (f n : ℂ)) (U∩W) z a else 0) + simp_rw [← liftPiece_freeze_fourier p L f U W z, Complex.norm_real, Real.norm_eq_abs, + sq_abs] at hh + rw [sum_filter] + convert hh using 1 + apply sum_congr rfl + intro a _ + split_ifs <;> simp + +lemma liftPiece_fixed_intersection_bound [DecidableEq J] + (hp : Pairwise fun i j => (p i).Coprime (p j)) + (F : Finset (Finset J)) (W B : Finset J) + (hF : ∀U∈F, U∩W=B) (Q : ℕ) (hQ : 0 < Q) + (hden : ∀U∈F, ∏j∈U, p j ≤ Q) (z : ResidueSpace p) + (L : ℕ) (hL : 0 < L) (hsmall : 2*(Q : ℝ) ≤ L) + (hsmall' : (Q : ℝ)^5 ≤ L) (f : ℕ → ℝ) (M : ℝ) (hM : 0 ≤ M) + (hf : ∀n Nat.zero_le _) + (fun j _ _ => Nat.pos_of_ne_zero (NeZero.ne (p j)))).trans (hden U₀ hU₀) + let T := fun U : Finset J => univ.filter (fun a : ResidueSpace p => primeSupport p a=U\W) + let Ω := F.biUnion T + have memO (a : Ω) : ∃U∈F, primeSupport p a.val=U\W := by + obtain ⟨U,hU,ha⟩ := mem_biUnion.mp a.property + exact ⟨U,hU,(mem_filter.mp ha).2⟩ + have ha (a : Ω) : supportDenominator p a.val ≤ Q := by + obtain ⟨U,hU,he⟩ := memO a + unfold supportDenominator + rw [he] + exact (prod_le_prod_of_subset_of_one_le₀ sdiff_subset (fun _ _ => Nat.zero_le _) + (fun j _ _ => Nat.pos_of_ne_zero (NeZero.ne (p j)))).trans (hden U hU) + have hdis (a : Ω) : Disjoint B (primeSupport p a.val) := by + obtain ⟨U,hU,he⟩ := memO a + rw [← hF U hU, he] + exact (disjoint_sdiff_inter U W).symm + have hpair : (↑F : Set (Finset J)).PairwiseDisjoint T := by + intro U hU V hV hUV + apply disjoint_left.mpr + intro a ha hb + have hUV' : U\W=V\W := (mem_filter.mp ha).2.symm.trans (mem_filter.mp hb).2 + apply hUV + calc + U = (U\W)∪(U∩W) := (sdiff_union_inter U W).symm + _ = (V\W)∪(V∩W) := by rw [hUV', hF U hU, hF V hV] + _ = V := sdiff_union_inter V W + have hh := gateCoefficient_bound p hp (fun a : Ω => a.val) Subtype.val_injective Q hQ ha + B hB hdis z L hL hsmall hsmall' (fun n => (f n : ℂ)) M hM + (fun n hn => by simpa only [Complex.norm_real, Real.norm_eq_abs] using hf n hn) + rw [sum_coe_sort Ω (fun a => ‖gateCoefficient p L (fun n => (f n : ℂ)) B z a‖^2)] at hh + calc + _ = ∑U∈F, ∑a∈T U, ‖gateCoefficient p L (fun n => (f n : ℂ)) B z a‖^2 := by + apply sum_congr rfl; intro U hU + rw [liftPiece_conditional_parseval, hF U hU] + _ = ∑a∈Ω, ‖gateCoefficient p L (fun n => (f n : ℂ)) B z a‖^2 := (sum_biUnion hpair).symm + _ ≤ _ := hh + +lemma liftPiece_conditional_square_sum [DecidableEq J] + (hp : Pairwise fun i j => (p i).Coprime (p j)) + (F : Finset (Finset J)) (Q : ℕ) (hQ : 0 < Q) + (hden : ∀U∈F, ∏j∈U, p j ≤ Q) + (L : ℕ) (hL : 0 < L) (hsmall : 2*(Q : ℝ) ≤ L) + (hsmall' : (Q : ℝ)^5 ≤ L) (f : ℕ → ℝ) (M : ℝ) (hM : 0 ≤ M) + (hf : ∀n mem_powerset.mpr inter_subset_right + rw [← sum_fiberwise_of_maps_to hmap] + calc + _ ≤ ∑B∈W.powerset, 4*M^2*4^B.card := by + apply sum_le_sum; intro B _ + exact liftPiece_fixed_intersection_bound p hp (F.filter (fun U => U∩W=B)) W B + (fun _ hU => (mem_filter.mp hU).2) Q hQ + (fun U hU => hden U (mem_filter.mp hU).1) z L hL hsmall hsmall' f M hM hf + _ = _ := by + rw [← mul_sum] + congr 1 + simpa only [one_pow, mul_one, show (4:ℝ)+1=5 by norm_num] using + sum_pow_mul_eq_add_pow (4:ℝ) 1 W + +omit [Fintype J] in +lemma residueGate_expect (j : J) (c : ZMod (p j)) : + (𝔼 t : ZMod (p j), residueGate (p j) (t-c))=0 := by + classical + have he (t : ZMod (p j)) : residueGate (p j) (t-c)= + (if t=c then (p j : ℝ) else 0)-1 := by simp [residueGate, sub_eq_zero] + simp only [he, expect_eq_sum_div_card] + simp [ZMod.card] + +omit [Fintype J] in +lemma exactGate_update_mean [DecidableEq J] (U : Finset J) (j : J) (hj : j∈U) + (x c : ResidueSpace p) : + (𝔼 t : ZMod (p j), exactGate p U (Function.update x j t-c))=0 := by + classical + have he (t : ZMod (p j)) : exactGate p U (Function.update x j t-c)= + residueGate (p j) (t-c j)*exactGate p (U.erase j) (x-c) := by + rw [exactGate, ← mul_prod_erase U (fun a => residueGate (p a) ((Function.update x j t-c) a)) hj] + simp only [Pi.sub_apply, Function.update_self] + congr 1 + apply prod_congr rfl + intro a ha + rw [Function.update_of_ne (mem_erase.mp ha).1] + rfl + simp only [he, ← expect_mul, residueGate_expect, zero_mul] + +omit [Fintype J] [∀j, NeZero (p j)] in +lemma exactGate_update_outside [DecidableEq J] (U : Finset J) (j : J) (hj : j∉U) + (x c : ResidueSpace p) (t : ZMod (p j)) : + exactGate p U (Function.update x j t-c)=exactGate p U (x-c) := by + apply prod_congr rfl + intro a ha + have haj : a≠j := fun h => hj (h ▸ ha) + simp only [Pi.sub_apply, Function.update_of_ne haj] + +omit [Fintype J] in +lemma liftPiece_exactSupport [DecidableEq J] (L : ℕ) (f : ℕ → ℝ) (U : Finset J) : + ExactSupport U (liftPiece p L f U) := by + constructor + · intro j hj x + simp only [liftPiece, ← mul_expect, expect_sum_comm, exactGate_update_mean p U j hj, + mul_zero, sum_const_zero] + · intro j hj x t + simp only [liftPiece, exactGate_update_outside p U j hj] + +lemma liftPiece_moment [DecidableEq J] + (hp : Pairwise fun i j => (p i).Coprime (p j)) + (F : Finset (Finset J)) (Q : ℕ) (hQ : 0 < Q) + (hden : ∀U∈F, ∏j∈U, p j ≤ Q) + (L : ℕ) (hL : 0 < L) (hsmall : 2*(Q : ℝ) ≤ L) + (hsmall' : (Q : ℝ)^5 ≤ L) (f : ℕ → ℝ) (M : ℝ) (hM : 0 ≤ M) + (hf : ∀n liftPiece_exactSupport p L f U) + k hk r hr).trans + apply mul_le_mul_of_nonneg_left _ (by positivity) + have he x : (∑U∈F, liftPiece p L f U x^2) = ∑U : F, liftPiece p L f U.val x^2 := + (sum_coe_sort F _).symm + simp only [he] + apply square_moment_bound (fun U : F => U.val) (fun U => liftPiece p L f U.val) + (fun U x y hxy => exactSupport_congr U.val _ (liftPiece_exactSupport p L f U.val) x y hxy) + k (fun U => hk U.val U.property) (4*M^2) 5 (by positivity) (by norm_num) + intro W x + have h := liftPiece_conditional_square_sum p hp F Q hQ hden L hL hsmall hsmall' f M hM hf W x + have hh (y : ResidueSpace p) : coordinateFreeze p W x y = + hybrid (fun j => decide (j∈W)) x y := by + ext j + simp [coordinateFreeze, hybrid] + simp_rw [hh] at h + have hsum (y : ResidueSpace p) : + (∑U∈F, liftPiece p L f U (hybrid (fun j => decide (j∈W)) x y)^2)= + ∑U : F, liftPiece p L f U.val (hybrid (fun j => decide (j∈W)) x y)^2 := + (sum_coe_sort F _).symm + simp_rw [hsum] at h + exact h + +lemma liftPiece_moment_small_loss [DecidableEq J] + (hp : Pairwise fun i j => (p i).Coprime (p j)) + (F : Finset (Finset J)) (Q : ℕ) (hQ : 0 < Q) + (hden : ∀U∈F, ∏j∈U, p j ≤ Q) + (L : ℕ) (hL : 0 < L) (hsmall : 2*(Q : ℝ) ≤ L) + (hsmall' : (Q : ℝ)^5 ≤ L) (f : ℕ → ℝ) (M : ℝ) (hM : 0 ≤ M) + (hf : ∀n le_sup hU + have hb : ((4:ℝ)*2^(2*r)*5^r)^k ≤ (Q : ℝ)^(2*ε) := by + rw [show k=U.card from hk] + calc + _ = ∏j∈U, ((4:ℝ)*2^(2*r)*5^r) := by simp + _ ≤ ∏j∈U, (p j : ℝ)^(2*ε) := by + apply prod_le_prod₀ + · intro j _; positivity + · intro j _; exact hprime j + _ = (∏j∈U, (p j : ℝ))^(2*ε) := by + rw [Real.finsetProd_rpow] + intro j _; positivity + _ ≤ (Q : ℝ)^(2*ε) := by + apply Real.rpow_le_rpow (by positivity) _ (by positivity) + exact_mod_cast hden U hU + have hh := liftPiece_moment p hp F Q hQ hden L hL hsmall hsmall' f M hM hf k hcard r hr + calc + _ ≤ (((4:ℝ)*2^(2*r))^k)^r*(4*M^2*5^(r*k))^r := hh + _ = (2*M)^(2*r)*(((4:ℝ)*2^(2*r)*5^r)^k)^r := by + rw [show (4:ℝ)=2^2 by norm_num] + simp only [mul_pow, ← pow_mul, Nat.mul_assoc] + ring + _ ≤ (2*M)^(2*r)*((Q : ℝ)^(2*ε))^r := + mul_le_mul_of_nonneg_left (pow_le_pow_left₀ (by positivity) hb r) (by positivity) + _ = _ := by + conv_rhs => rw [mul_pow] + congr 1 + rw [← Real.rpow_natCast ((Q : ℝ)^(2*ε)) r, + ← Real.rpow_mul (by positivity : 0 ≤ (Q : ℝ)), + ← Real.rpow_natCast ((Q : ℝ)^ε) (2*r), + ← Real.rpow_mul (by positivity : 0 ≤ (Q : ℝ))] + congr 1 + push_cast + ring + · simp only [not_nonempty_iff_eq_empty.mp hF, sum_empty, zero_pow (by omega : 2*r≠0), + Fintype.expect_const] + positivity + +lemma exponential_support_bound {I : Type*} [DecidableEq I] + (U : Finset I) (p : I → ℕ) (hinj : Set.InjOn p (↑U : Set I)) + (hp : ∀i∈U, 1≤p i) (A : ℝ) (hA : 1≤A) (ε : ℝ) (hε : 0≤ε) + (T : ℕ) (hT : ∀n : ℕ, T≤n → A≤(n : ℝ)^ε) : + A^U.card ≤ A^T * (∏i∈U, (p i : ℝ))^ε := by + classical + let B := U.filter (fun i => p i (p i).Coprime (p j)) (hinj : Function.Injective p) + (F : Finset (Finset J)) (Q : ℕ) (hQ : 0 < Q) + (hden : ∀U∈F, ∏j∈U, p j ≤ Q) + (L : ℕ) (hL : 0 < L) (hsmall : 2*(Q : ℝ) ≤ L) + (hsmall' : (Q : ℝ)^5 ≤ L) (f : ℕ → ℝ) (M : ℝ) (hM : 0 ≤ M) + (hf : ∀n le_sup hU + have hb : A^k ≤ A^T*(Q : ℝ)^(2*ε) := by + rw [show k=U.card from hk] + apply (exponential_support_bound U p hinj.injOn (fun i _ => Nat.one_le_iff_ne_zero.mpr (NeZero.ne (p i))) + A hA (2*ε) (by positivity) T hT).trans + apply mul_le_mul_of_nonneg_left _ (by positivity) + apply Real.rpow_le_rpow (by positivity) _ (by positivity) + exact_mod_cast hden U hU + have hh := liftPiece_moment p hp F Q hQ hden L hL hsmall hsmall' f M hM hf k hcard r hr + have hc : A^T ≤ (A^T)^2 := by nlinarith [one_le_pow₀ hA (n:=T)] + calc + _ ≤ (((4:ℝ)*2^(2*r))^k)^r*(4*M^2*5^(r*k))^r := hh + _ = (2*M)^(2*r)*(A^k)^r := by + dsimp [A] + rw [show (4:ℝ)=2^2 by norm_num] + simp only [mul_pow, ← pow_mul, Nat.mul_assoc] + ring + _ ≤ (2*M)^(2*r)*((A^T)^2*(Q : ℝ)^(2*ε))^r := by + apply mul_le_mul_of_nonneg_left _ (by positivity) + apply pow_le_pow_left₀ (by positivity) + exact hb.trans (mul_le_mul_of_nonneg_right hc (by positivity)) + _ = _ := by + change _=(2*M*A^T*(Q : ℝ)^ε)^(2*r) + have hqr : (Q : ℝ)^(2*ε)=((Q : ℝ)^ε)^2 := by + rw [←Real.rpow_natCast ((Q : ℝ)^ε) 2, + ←Real.rpow_mul (by positivity : 0≤(Q : ℝ))] + congr 1 + norm_num + ring + rw [hqr] + simp only [mul_pow, ←pow_mul] + ring + · simp only [not_nonempty_iff_eq_empty.mp hF,sum_empty,zero_pow (by omega : 2*r≠0), + Fintype.expect_const] + positivity + +lemma liftPiece_moment_subpower [DecidableEq J] + (r : ℕ) (hr : 1≤r) (ε : ℝ) (hε : 0<ε) : + ∃ C : ℝ, 0 (p i).Coprime (p j)) + (_hinj : Function.Injective p) (F : Finset (Finset J)) (Q : ℕ), 0 1)=1) + (G : ∀j,((V → X j) → ℝ) →ₗ[ℝ] ℝ) (eta : J → ℝ) + (heta : ∀j,eta j∈Set.Icc (0:ℝ) 1) + (hdec : ∀j,L j-E j=(1-eta j) • G j) (F : V → (∀j,X j) → ℝ) : + |multilinearIntegral (tensorLaw L) F|≤|multilinearIntegral (tensorLaw G) F|+ + ∑B∈(univ : Finset (Finset J)).erase ∅,|multilinearIntegral (mixedTensorLaw L E B) F| := + tensorLaw_exceptional_bound L E hL G eta heta hdec (fun z => ∏v,F v (z v)) + +lemma tuple_multilinear_exceptional_bound {J : Type} [Fintype J] [DecidableEq J] + (p : J → ℕ) [∀j,Fact (p j).Prime] + (L E : ∀j,((TupleVertex → ZMod (p j)) → ℝ) →ₗ[ℝ] ℝ) + (hL : ∀j,L j (fun _ => 1)=1) + (G : ∀j,((TupleVertex → ZMod (p j)) → ℝ) →ₗ[ℝ] ℝ) (eta : J → ℝ) + (heta : ∀j,eta j∈Set.Icc (0:ℝ) 1) + (hdec : ∀j,L j-E j=(1-eta j) • G j) (F : TupleVertex → ResidueSpace p → ℝ) : + |multilinearIntegral (tensorLaw L) F|≤|multilinearIntegral (tensorLaw G) F|+ + ∑B∈(univ : Finset (Finset J)).erase ∅,|multilinearIntegral (mixedTensorLaw L E B) F| := + multilinear_exceptional_bound L E hL G eta heta hdec F + +section Average + +variable {J : Type} [Fintype J] [DecidableEq J] (p : J → ℕ) [∀j,Fact (p j).Prime] + +lemma actualLift_expect {I : Type*} [Fintype I] (N Q : ℕ) (f : I → ℕ → ℝ) (x : ResidueSpace p) : + actualTruncatedLift p N Q (fun n => 𝔼 i,f i n) x=(𝔼 i,actualTruncatedLift p N Q (f i) x) := by + change (∑U∈liftSupportFamily p Q,(N:ℝ)⁻¹*∑n∈range N,(𝔼 i,f i n)*LiftTheory.SquareDifference.exactGate p U (x-fun j => (n:ZMod (p j))))=_ + simp_rw [expect_mul] + simp_rw [←expect_sum_comm,mul_expect] + rw [←expect_sum_comm] + rfl + +lemma setFunctional_small_average (N Q M : ℕ) [NeZero M] (A : Finset ℕ) : + setFunctional p N Q A=𝔼 s : TupleVertex → ZMod M, + multilinearIntegral (productTupleLaw p) (fun v => actualTruncatedLift p N Q (smallResidueInput M A (s v))) := by + have he (x : ResidueSpace p) : actualTruncatedLift p N Q (natIndicator A) x= + 𝔼 s : ZMod M,actualTruncatedLift p N Q (smallResidueInput M A s) x := by + rw [←actualLift_expect] + simp only [smallResidueInput_average] + change multilinearIntegral (productTupleLaw p) (fun _ => actualTruncatedLift p N Q (natIndicator A))=_ + rw [show actualTruncatedLift p N Q (natIndicator A)=(fun x => 𝔼 s : ZMod M,actualTruncatedLift p N Q (smallResidueInput M A s) x) from funext he] + simpa only [one_mul,one_pow] using multilinearIntegral_scale_expect + (I:=ZMod M) (productTupleLaw p) (fun (_v : TupleVertex) (s : ZMod M) (x : ResidueSpace p) => actualTruncatedLift p N Q (smallResidueInput M A s) x) 1 + +lemma actualMixedLaw_empty : actualMixedLaw p ∅=productTupleLaw p := by + rw [actualMixedLaw,mixedTensorLaw_empty] + rfl + +lemma actual_exceptional_bound (hp : ∀j,tupleMassThreshold≤(p j:ℝ)) + (heta : ∀j,tupleEta (p j)≤1) (F : TupleVertex → ResidueSpace p → ℝ) : + |multilinearIntegral (productTupleLaw p) F|≤ + |multilinearIntegral (tensorLaw (fun j => tupleGoodLaw (p:=p j))) F|+ + ∑B∈(univ : Finset (Finset J)).erase ∅,|multilinearIntegral (actualMixedLaw p B) F| := by + exact tuple_multilinear_exceptional_bound p (fun j => tupleLaw (p:=p j)) (fun j => tupleExceptionalLaw (p:=p j)) + (fun j => tupleLaw_probability (p:=p j) (hp j)) (fun j => tupleGoodLaw (p:=p j)) (fun j => tupleEta (p j)) + (fun j => ⟨tupleEta_nonneg (p j),heta j⟩) + (fun j => sub_eq_iff_eq_add.mpr (tupleLaw_decomposition (p:=p j) (hp j))) F + +end Average + +lemma event_average_bound {I : Type*} [Fintype I] [Nonempty I] (P : I → Prop) [DecidablePred P] + (F : I → ℝ) (G B : ℝ) (hg : ∀i,P i → |F i|≤G) (hb : ∀i,¬P i → |F i|≤B) : + |𝔼 i,F i|≤(𝔼 i,if P i then (1:ℝ) else 0)*G+(1-(𝔼 i,if P i then (1:ℝ) else 0))*B := by + apply (abs_expect_le _ _).trans + calc + _ ≤ 𝔼 i : I,((if P i then (1:ℝ) else 0)*G+(1-(if P i then (1:ℝ) else 0))*B) := by + apply expect_le_expect + intro i _ + split_ifs with hi + · simpa only [one_mul,sub_self,zero_mul,add_zero] using hg i hi + · simpa only [zero_mul,sub_zero,one_mul,zero_add] using hb i hi + _ = _ := by rw [expect_add_distrib,←expect_mul,←expect_mul,expect_sub_distrib,Fintype.expect_const] + +end SquareDifference + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SquareDifference/GateExpansion.lean b/lean/OAI/Combinatorics/SquareDifference/GateExpansion.lean new file mode 100644 index 0000000000000000000000000000000000000000..f08347ab2ec80f6613bfe00d77f5cacac17c81e7 --- /dev/null +++ b/lean/OAI/Combinatorics/SquareDifference/GateExpansion.lean @@ -0,0 +1,155 @@ +import OAI.Combinatorics.SquareDifference.GoodPairSupport + +namespace OAI + +section + +open Finset + +open scoped BigOperators + +namespace SquareDifference + +open LiftTheory.SquareDifference + +def OtherVertices {V : Type*} (u v : V) := {w : V // w≠u ∧ w≠v} + +instance {V : Type*} [Fintype V] [DecidableEq V] (u v : V) : Fintype (OtherVertices u v) := inferInstanceAs (Fintype {w : V // w≠u ∧ w≠v}) + +instance {V : Type*} [DecidableEq V] (u v : V) : DecidableEq (OtherVertices u v) := inferInstanceAs (DecidableEq {w : V // w≠u ∧ w≠v}) + +lemma product_pair_split {V E : Type*} [Fintype V] [DecidableEq V] [CommMonoid E] + (u v : V) (huv : u≠v) (f : V → E) : + (∏w,f w)=f u*f v*∏w : OtherVertices u v,f w.val := by + rw [←prod_mul_prod_compl {u,v} f] + rw [prod_insert (by simpa using huv),prod_singleton] + congr 1 + exact prod_subtype _ (fun w => by simp only [mem_compl,mem_insert,mem_singleton,not_or]) f + +lemma otherVertices_card {V : Type*} [Fintype V] [DecidableEq V] (u v : V) (huv : u≠v) : + Fintype.card (OtherVertices u v)+2=Fintype.card V := by + have he : Fintype.card (OtherVertices u v)=({u,v}ᶜ : Finset V).card := by + change Fintype.card {w : V // w≠u ∧ w≠v} = _ + rw [Fintype.card_subtype] + congr 1 + ext w + simp only [mem_filter,mem_univ,true_and,mem_compl,mem_insert,mem_singleton,not_or] + rw [he,card_compl,card_insert_of_notMem (by simpa using huv),card_singleton] + have ht : 2≤Fintype.card V := by + have hcard := card_le_univ ({u,v} : Finset V) + simpa [huv] using hcard + omega + +lemma multilinear_pair_expand {V X I : Type*} [Fintype V] [DecidableEq V] [Fintype I] + (L : ((V → X) → ℝ) →ₗ[ℝ] ℝ) (u v : V) (huv : u≠v) + (F G : X → ℝ) (f : OtherVertices u v → I → X → ℝ) : + multilinearIntegral L (fun w => if hu : w=u then F else if hv : w=v then G else + fun x => ∑i,f ⟨w,hu,hv⟩ i x)= + ∑a : OtherVertices u v → I,L (fun z => F (z u)*G (z v)*∏w,f w (a w) (z w.val)) := by + classical + unfold multilinearIntegral + have he (z : V → X) : (∏w,(if hu : w=u then F else if hv : w=v then G else + fun x => ∑i,f ⟨w,hu,hv⟩ i x) (z w))= + ∑a : OtherVertices u v → I,F (z u)*G (z v)*∏w,f w (a w) (z w.val) := by + rw [product_pair_split u v huv] + simp only [dite_true,Ne.symm huv,dite_false] + have hw (w : OtherVertices u v) : + (if hu : w.val=u then F else if hv : w.val=v then G else + fun x => ∑i,f ⟨w.val,hu,hv⟩ i x) (z w.val)=∑i,f w i (z w.val) := by + rcases w with ⟨w,hw⟩ + simp only [hw.1,hw.2,dite_false] + simp_rw [hw] + rw [Fintype.prod_sum,mul_sum] + simp_rw [he] + have hs : (fun z : V → X => ∑a : OtherVertices u v → I,F (z u)*G (z v)*∏w,f w (a w) (z w.val))= + ∑a : OtherVertices u v → I,fun z : V → X => F (z u)*G (z v)*∏w,f w (a w) (z w.val) := by + funext z + exact (Finset.sum_apply z (univ : Finset (OtherVertices u v → I)) + (fun a z => F (z u)*G (z v)*∏w,f w (a w) (z w.val))).symm + rw [hs,map_sum] + +lemma primeProduct_union_le {J : Type*} [DecidableEq J] (p : J → ℕ) + (hp : ∀j,1≤p j) (U W : Finset J) : (∏j∈U∪W,p j)≤(∏j∈U,p j)*(∏j∈W,p j) := by + have hge : 1≤∏j∈U∩W,p j := one_le_prod₀ (fun j _ => hp j) + calc + _ ≤ (∏j∈U∪W,p j)*(∏j∈U∩W,p j) := Nat.le_mul_of_pos_right _ (by omega) + _ = _ := prod_union_inter + +lemma primeProduct_biUnion_le {J I : Type*} [DecidableEq J] (p : J → ℕ) + (hp : ∀j,1≤p j) (s : Finset I) (U : I → Finset J) : + (∏j∈s.biUnion U,p j)≤∏i∈s,∏j∈U i,p j := by + classical + induction s using Finset.induction_on with + | empty => simp + | @insert i s hi ih => + rw [biUnion_insert,prod_insert hi] + exact (primeProduct_union_le p hp _ _).trans (Nat.mul_le_mul_left _ ih) + +lemma intervalPiece_depends {J : Type*} [Fintype J] [DecidableEq J] + (p : J → ℕ) [∀j,NeZero (p j)] (a L : ℕ) (f : ℕ → ℝ) (U : Finset J) + (x y : ResidueSpace p) (hxy : ∀j∈U,x j=y j) : intervalPiece p a L f U x=intervalPiece p a L f U y := by + unfold intervalPiece + congr 1 + apply sum_congr rfl + intro n hn + congr 1 + unfold exactGate + apply prod_congr rfl + intro j hj + simp only [Pi.sub_apply,hxy j hj] + +section PieceBound + +variable {J V : Type*} [Fintype J] [DecidableEq J] [Fintype V] [DecidableEq V] + (p : J → ℕ) [∀j,Fact (p j).Prime] + +lemma interval_piece_product_bound (hinj : Function.Injective p) + (Llaw : ∀j,((V → ZMod (p j)) → ℝ) →ₗ[ℝ] ℝ) + (hpos : ∀j F,(∀z,0≤F z) → 0≤Llaw j F) (hmass : ∀j,Llaw j (fun _ => 1)=1) + (u v : V) (a : V → ℕ) (L : ℕ) (f : V → ℕ → ℝ) (M : ℝ) (hM : 0≤M) + (hf : ∀v n,|f v n|≤M) (T : ℕ) (U : OtherVertices u v → Finset J) + (hU : ∀w,∏j∈U w,p j≤T) (F G : ResidueSpace p → ℝ) (E : ℝ) (hE : 0≤E) + (hpair : ∀(B : Finset J),(∏j∈B,p j)≤T^(Fintype.card (OtherVertices u v)) → + ∀z,lawDensity (tensorLaw Llaw) z≠0 → + |tensorLaw Llaw (fun x => F (freezeCoordinates B (z u) (x u))* + G (freezeCoordinates B (z v) (x v)))|≤E) : + |tensorLaw Llaw (fun z => + (∏w,intervalPiece p (a w.val) L (f w.val) (U w) (z w.val))*F (z u)*G (z v))|≤ + (M*T)^(Fintype.card (OtherVertices u v))*E := by + classical + let B := univ.biUnion U + have hB : (∏j∈B,p j)≤T^(Fintype.card (OtherVertices u v)) := by + apply (primeProduct_biUnion_le p (fun j => (Fact.out : (p j).Prime).one_lt.le) univ U).trans + calc + _ ≤ ∏w : OtherVertices u v,T := prod_le_prod (fun w _ => hU w) + _ = _ := by simp + apply tensorLaw_localized_pair Llaw hpos hmass B + (fun z => ∏w,intervalPiece p (a w.val) L (f w.val) (U w) (z w.val)) F G u v + ((M*T)^(Fintype.card (OtherVertices u v))) E (pow_nonneg (mul_nonneg hM (Nat.cast_nonneg T)) _) hE + · intro z x + apply prod_congr rfl + intro w _ + apply intervalPiece_depends p + intro j hj + have hjB : j∈B := mem_biUnion.mpr ⟨w,mem_univ _,hj⟩ + simp only [hjB,ite_true] + · intro z + rw [abs_prod] + calc + _ ≤ ∏w : OtherVertices u v,M*T := by + apply prod_le_prod₀ (fun _ _ => abs_nonneg _) + intro w _ + apply (intervalPiece_sup p hinj (a w.val) L (f w.val) M hM (hf w.val) (U w) (z w.val)).trans + apply mul_le_mul_of_nonneg_left _ hM + exact_mod_cast hU w + _ = _ := by simp + · intro z hz + exact hpair B hB z hz + +end PieceBound + +end SquareDifference + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SquareDifference/GaussSum.lean b/lean/OAI/Combinatorics/SquareDifference/GaussSum.lean new file mode 100644 index 0000000000000000000000000000000000000000..5444feb0d5cc2ef785813bddacfbce2eae748ea7 --- /dev/null +++ b/lean/OAI/Combinatorics/SquareDifference/GaussSum.lean @@ -0,0 +1,549 @@ +import Mathlib + +namespace OAI + +section + +open Finset + +open scoped BigOperators + +namespace SquareDifference + +def IsSquareDifferenceFree (A : Finset ℤ) : Prop := + ∀ a ∈ A, ∀ b ∈ A, ∀ m : ℕ, 1 ≤ m → a - b ≠ (m : ℤ) ^ 2 + +def PowerSaving : Prop := + ∃ c C : ℝ, 0 < c ∧ + ∀ N : ℕ, 1 ≤ N → ∀ A : Finset ℤ, + A ⊆ Finset.Icc 1 (N : ℤ) → IsSquareDifferenceFree A → + (A.card : ℝ) ≤ C * (N : ℝ) ^ (1 - c) + +lemma gaussSum_norm_sq {F : Type*} [Field F] [Fintype F] + {χ : MulChar F ℂ} (hχ : χ ≠ 1) {ψ : AddChar F ℂ} + (hψ : ψ.IsPrimitive) : ‖gaussSum χ ψ‖ ^ 2 = Fintype.card F := by + have h := gaussSum_mul_gaussSum_eq_card hχ hψ + rw [← star_gaussSum_eq] at h + have hr := congrArg Complex.re h + simpa [Complex.mul_conj, Complex.sq_norm] using hr + +lemma square_sum_eq_gaussSum {F : Type*} [Field F] [Fintype F] [DecidableEq F] + (hF : ringChar F ≠ 2) {ψ : AddChar F ℂ} (hψ : ψ ≠ 1) : + ∑ a : F, ψ (a ^ 2) = + gaussSum ((quadraticChar F).ringHomComp (Int.castRingHom ℂ)) ψ := by + classical + calc + ∑ a : F, ψ (a ^ 2) = + ∑ b : F, ∑ a ∈ (univ.filter fun a : F => a ^ 2 = b), ψ (a ^ 2) := + (sum_fiberwise univ (fun a : F => a ^ 2) (fun a => ψ (a ^ 2))).symm + _ = ∑ b : F, ((quadraticChar F b : ℂ) + 1) * ψ b := by + apply sum_congr rfl + intro b _ + have hc : ((univ.filter fun a : F => a ^ 2 = b).card : ℂ) = + (quadraticChar F b : ℂ) + 1 := by + have hc' := quadraticChar_card_sqrts hF b + simp only [Set.toFinset_ofPred] at hc' + exact_mod_cast hc' + simp_rw [sum_congr rfl (fun a ha => congrArg ψ (mem_filter.mp ha).2)] + simp only [sum_const, nsmul_eq_mul, hc] + _ = gaussSum ((quadraticChar F).ringHomComp (Int.castRingHom ℂ)) ψ := by + simp [add_mul, sum_add_distrib, AddChar.sum_eq_zero_of_ne_one hψ, gaussSum] + +lemma square_sum_norm_sq {F : Type*} [Field F] [Fintype F] [DecidableEq F] + (hF : ringChar F ≠ 2) {ψ : AddChar F ℂ} (hψ : ψ.IsPrimitive) : + ‖∑ a : F, ψ (a ^ 2)‖ ^ 2 = Fintype.card F := by + have hp : ψ ≠ 1 := by simpa using hψ (show (1 : F) ≠ 0 from one_ne_zero) + rw [square_sum_eq_gaussSum hF hp] + apply gaussSum_norm_sq _ hψ + exact (MulChar.ringHomComp_ne_one_iff (f := Int.castRingHom ℂ) Int.cast_injective).mpr (quadraticChar_ne_one hF) + +noncomputable def squareIndicator {F : Type*} [Field F] (x : F) : ℝ := + by + classical + exact if x ≠ 0 ∧ IsSquare x then 1 else 0 + +lemma squareIndicator_eq {F : Type*} [Field F] [Fintype F] [DecidableEq F] + (x : F) : squareIndicator x = + ((quadraticChar F x : ℝ) + 1 - if x = 0 then 1 else 0) / 2 := by + classical + by_cases hx : x = 0 + · simp [hx, squareIndicator] + by_cases hs : IsSquare x + · simp [squareIndicator, hx, hs, (quadraticChar_one_iff_isSquare hx).mpr hs] + · simp [squareIndicator, hx, hs, quadraticChar_neg_one_iff_not_isSquare.mpr hs] + +lemma squareIndicator_nonneg {F : Type*} [Field F] (x : F) : + 0 ≤ squareIndicator x := by + classical + unfold squareIndicator + split_ifs <;> norm_num + +lemma squareIndicator_le_one {F : Type*} [Field F] (x : F) : + squareIndicator x ≤ 1 := by + classical + unfold squareIndicator + split_ifs <;> norm_num + +lemma squareIndicator_sum {F : Type*} [Field F] [Fintype F] [DecidableEq F] + (hF : ringChar F ≠ 2) : + ∑ x : F, squareIndicator x = (Fintype.card F - 1 : ℝ) / 2 := by + classical + simp_rw [squareIndicator_eq, sub_div, add_div, sum_sub_distrib, sum_add_distrib, + ← sum_div] + have hz : ∑ x : F, (quadraticChar F x : ℝ) = 0 := by + exact_mod_cast quadraticChar_sum_zero hF + rw [hz] + simp only [zero_div, zero_add, sum_const, card_univ, nsmul_eq_mul, mul_one, + sum_ite_eq', mem_univ, ite_true] + +lemma squareIndicator_char_sum {F : Type*} [Field F] [Fintype F] [DecidableEq F] + (hF : ringChar F ≠ 2) {ψ : AddChar F ℂ} (hψ : ψ ≠ 1) : + ∑ x : F, (squareIndicator x : ℂ) * ψ x = + (∑ x : F, ψ (x ^ 2) - 1) / 2 := by + classical + rw [square_sum_eq_gaussSum hF hψ] + simp_rw [squareIndicator_eq, Complex.ofReal_div, Complex.ofReal_sub, + Complex.ofReal_add, Complex.ofReal_intCast, Complex.ofReal_ofNat] + simp_rw [sub_div, add_div, sub_mul, add_mul, sum_sub_distrib, sum_add_distrib] + have hcast (x : F) : ((if x = 0 then 1 else 0 : ℝ) : ℂ) = + if x = 0 then 1 else 0 := by split_ifs <;> simp + simp_rw [hcast, div_mul_eq_mul_div, ← sum_div] + simp [AddChar.sum_eq_zero_of_ne_one hψ, gaussSum] + +lemma squareIndicator_char_sum_norm {F : Type*} [Field F] [Fintype F] [DecidableEq F] + (hF : ringChar F ≠ 2) {ψ : AddChar F ℂ} (hψ : ψ.IsPrimitive) : + ‖∑ x : F, (squareIndicator x : ℂ) * ψ x‖ ≤ + (Real.sqrt (Fintype.card F) + 1) / 2 := by + have hp : ψ ≠ 1 := by simpa using hψ (show (1 : F) ≠ 0 from one_ne_zero) + have hnorm : ‖∑ a : F, ψ (a ^ 2)‖ = Real.sqrt (Fintype.card F) := by + rw [← square_sum_norm_sq hF hψ, Real.sqrt_sq (norm_nonneg _)] + rw [squareIndicator_char_sum hF hp, norm_div] + norm_num only [Complex.norm_ofNat] + apply div_le_div_of_nonneg_right _ (by norm_num : (0 : ℝ) ≤ 2) + calc + ‖(∑ a : F, ψ (a ^ 2)) - 1‖ ≤ ‖∑ a : F, ψ (a ^ 2)‖ + ‖(1 : ℂ)‖ := norm_sub_le _ _ + _ = Real.sqrt (Fintype.card F) + 1 := by rw [hnorm, norm_one] + +lemma dft_inner {N : ℕ} [NeZero N] (f g : ZMod N → ℂ) : + ∑ k : ZMod N, star (ZMod.dft f k) * ZMod.dft g k = + (N : ℂ) * ∑ x : ZMod N, star (f x) * g x := by + classical + have hs (x : ZMod N) : star (ZMod.stdAddChar x) = ZMod.stdAddChar (-x) := + (AddChar.map_neg_eq_conj _ x).symm + simp_rw [ZMod.dft_apply, smul_eq_mul, star_sum, star_mul, hs, neg_neg, + sum_mul, mul_sum] + have hprod (k x y : ZMod N) : + star (f x) * ZMod.stdAddChar (x * k) * + (ZMod.stdAddChar (-(y * k)) * g y) = + ZMod.stdAddChar (k * (x - y)) * (star (f x) * g y) := by + rw [mul_comm (star (f x)), mul_mul_mul_comm, ← AddChar.map_add_eq_mul] + congr 2 + ring + simp_rw [hprod] + rw [sum_comm] + simp_rw [sum_comm (f := fun k y : ZMod N => + ZMod.stdAddChar (k * ( _ - y)) * (star (f _) * g y))] + simp_rw [← sum_mul, AddChar.sum_mulShift _ (ZMod.isPrimitive_stdAddChar N)] + simp only [Nat.cast_ite, ZMod.card, Nat.cast_zero, ite_mul, zero_mul, + sub_eq_zero, sum_ite_eq, mem_univ, ite_true] + +lemma dft_parseval {N : ℕ} [NeZero N] (f : ZMod N → ℂ) : + ∑ k : ZMod N, ‖ZMod.dft f k‖ ^ 2 = + (N : ℝ) * ∑ x : ZMod N, ‖f x‖ ^ 2 := by + have h := dft_inner f f + simp_rw [← starRingEnd_apply, Complex.conj_mul'] at h + exact_mod_cast h + +lemma dft_convolution {N : ℕ} [NeZero N] (a b : ZMod N → ℂ) (k : ZMod N) : + ZMod.dft (fun x => ∑ y : ZMod N, a (x - y) * b y) k = + ZMod.dft a k * ZMod.dft b k := by + classical + simp only [ZMod.dft_apply, smul_eq_mul, mul_sum] + rw [sum_comm] + have hshift (y : ZMod N) : + ∑ x : ZMod N, ZMod.stdAddChar (-(x * k)) * (a (x - y) * b y) = + ∑ t : ZMod N, ZMod.stdAddChar (-((t + y) * k)) * (a t * b y) := by + apply Fintype.sum_equiv (Equiv.subRight y) + intro x + simp + simp_rw [hshift, add_mul, neg_add, AddChar.map_add_eq_mul] + apply sum_congr rfl + intro y _ + rw [sum_mul] + apply sum_congr rfl + intro x _ + ring + +lemma convolution_l2_sq_le {N : ℕ} [NeZero N] (a b : ZMod N → ℂ) + {M : ℝ} (ha : ∀ k, ‖ZMod.dft a k‖ ≤ M) : + ∑ x : ZMod N, ‖∑ y : ZMod N, a (x - y) * b y‖ ^ 2 ≤ + M ^ 2 * ∑ y : ZMod N, ‖b y‖ ^ 2 := by + have hm : 0 ≤ M := (norm_nonneg _).trans (ha 0) + have hbnd : ∑ k : ZMod N, + ‖ZMod.dft (fun x => ∑ y : ZMod N, a (x - y) * b y) k‖ ^ 2 ≤ + M ^ 2 * ∑ k : ZMod N, ‖ZMod.dft b k‖ ^ 2 := by + rw [mul_sum] + apply sum_le_sum + intro k _ + rw [dft_convolution, norm_mul, mul_pow] + exact mul_le_mul_of_nonneg_right (pow_le_pow_left₀ (norm_nonneg _) (ha k) 2) + (sq_nonneg _) + rw [dft_parseval, dft_parseval] at hbnd + have hN : (0 : ℝ) < N := Nat.cast_pos.mpr (NeZero.pos N) + nlinarith + +lemma centered_square_dft_bound {p : ℕ} [Fact p.Prime] (hp : p ≠ 2) (k : ZMod p) : + ‖ZMod.dft (fun x : ZMod p => (squareIndicator x : ℂ) - 1 / 2) k‖ ≤ + (Real.sqrt p + 1) / 2 := by + have hF : ringChar (ZMod p) ≠ 2 := by simpa only [ZMod.ringChar_zmod_n] using hp + by_cases hk : k = 0 + · subst k + rw [ZMod.dft_apply_zero, sum_sub_distrib] + have hs : ∑ x : ZMod p, (squareIndicator x : ℂ) = (p - 1 : ℂ) / 2 := by + have hsum := squareIndicator_sum hF + rw [ZMod.card] at hsum + exact_mod_cast hsum + rw [hs] + simp only [sum_const, card_univ, ZMod.card, nsmul_eq_mul] + have heq : (p - 1 : ℂ) / 2 - (p : ℂ) * (1 / 2) = -(1 / 2) := by ring + rw [heq, norm_neg, norm_div, norm_one] + norm_num only [Complex.norm_ofNat] + linarith [Real.sqrt_nonneg (p : ℝ)] + · let ψ : AddChar (ZMod p) ℂ := ZMod.stdAddChar.mulShift (-k) + have hn : ψ ≠ 1 := ZMod.isPrimitive_stdAddChar p (neg_ne_zero.mpr hk) + have hψ : ψ.IsPrimitive := AddChar.IsPrimitive.of_ne_one hn + have hdft : ZMod.dft (fun x : ZMod p => (squareIndicator x : ℂ) - 1 / 2) k = + ∑ x : ZMod p, (squareIndicator x : ℂ) * ψ x := by + simp only [ZMod.dft_apply, smul_eq_mul, mul_sub, sum_sub_distrib] + have heq (x : ZMod p) : ZMod.stdAddChar (-(x * k)) = ψ x := by + simp [ψ, AddChar.mulShift_apply, mul_comm] + simp_rw [heq] + rw [← sum_mul, AddChar.sum_eq_zero_of_ne_one hn, zero_mul, sub_zero] + apply sum_congr rfl + intro x _ + exact mul_comm _ _ + rw [hdft] + simpa only [ZMod.card] using squareIndicator_char_sum_norm hF hψ + +lemma centered_square_convolution_l2 {p : ℕ} [Fact p.Prime] (hp : p ≠ 2) + (f : ZMod p → ℝ) : + ∑ x : ZMod p, (∑ y : ZMod p, (squareIndicator (x - y) - 1 / 2) * f y) ^ 2 ≤ + ((Real.sqrt p + 1) / 2) ^ 2 * ∑ y : ZMod p, (f y) ^ 2 := by + have h := convolution_l2_sq_le + (fun x : ZMod p => (squareIndicator x : ℂ) - 1 / 2) + (fun x : ZMod p => (f x : ℂ)) (centered_square_dft_bound hp) + have hsum (x : ZMod p) : + ∑ y : ZMod p, ((squareIndicator (x - y) : ℂ) - 1 / 2) * (f y : ℂ) = + ((∑ y : ZMod p, (squareIndicator (x - y) - 1 / 2) * f y : ℝ) : ℂ) := by + push_cast + rfl + simp_rw [hsum, Complex.norm_real, Real.norm_eq_abs, sq_abs] at h + exact h + +lemma single_square_mixing_unnormalized {p : ℕ} [Fact p.Prime] (hp : p ≠ 2) + (f g : ZMod p → ℝ) : + |∑ x : ZMod p, ∑ y : ZMod p, + f x * g y * (squareIndicator (y - x) - 1 / 2)| ≤ + ((Real.sqrt p + 1) / 2) * Real.sqrt (∑ x : ZMod p, (f x) ^ 2) * + Real.sqrt (∑ y : ZMod p, (g y) ^ 2) := by + let c (y : ZMod p) := ∑ x : ZMod p, (squareIndicator (y - x) - 1 / 2) * f x + have hc := centered_square_convolution_l2 hp f + have hcs := sum_mul_sq_le_sq_mul_sq univ g c + have hf : 0 ≤ ∑ x : ZMod p, (f x) ^ 2 := sum_nonneg (fun _ _ => sq_nonneg _) + have hg : 0 ≤ ∑ y : ZMod p, (g y) ^ 2 := sum_nonneg (fun _ _ => sq_nonneg _) + have hM : 0 ≤ (Real.sqrt (p : ℝ) + 1) / 2 := by positivity + have hbnd : (∑ y : ZMod p, g y * c y) ^ 2 ≤ + (((Real.sqrt p + 1) / 2) * Real.sqrt (∑ x : ZMod p, (f x) ^ 2) * + Real.sqrt (∑ y : ZMod p, (g y) ^ 2)) ^ 2 := by + simp only [mul_pow, Real.sq_sqrt hf, Real.sq_sqrt hg] + calc + _ ≤ (∑ y : ZMod p, (g y) ^ 2) * (∑ y : ZMod p, (c y) ^ 2) := hcs + _ ≤ (∑ y : ZMod p, (g y) ^ 2) * + (((Real.sqrt p + 1) / 2) ^ 2 * ∑ x : ZMod p, (f x) ^ 2) := + mul_le_mul_of_nonneg_left hc hg + _ = _ := by ring + have heq : (∑ x : ZMod p, ∑ y : ZMod p, + f x * g y * (squareIndicator (y - x) - 1 / 2)) = + ∑ y : ZMod p, g y * c y := by + rw [sum_comm] + simp only [c, mul_sum] + apply sum_congr rfl + intro y _ + apply sum_congr rfl + intro x _ + ring + rw [heq] + exact abs_le_of_sq_le_sq hbnd (mul_nonneg (mul_nonneg hM (Real.sqrt_nonneg _)) + (Real.sqrt_nonneg _)) + +lemma single_square_mixing_bounded {p : ℕ} [Fact p.Prime] (hp : p ≠ 2) + (f g : ZMod p → ℝ) (hf : ∀ x, |f x| ≤ 1) (hg : ∀ x, |g x| ≤ 1) : + |(∑ x : ZMod p, ∑ y : ZMod p, + f x * g y * (squareIndicator (y - x) - 1 / 2)) / (p : ℝ) ^ 2| ≤ + (Real.sqrt p + 1) / (2 * p) := by + have hnp : (0 : ℝ) < p := Nat.cast_pos.mpr (Nat.Prime.pos Fact.out) + have hfp : ∑ x : ZMod p, (f x) ^ 2 ≤ (p : ℝ) := by + calc + _ ≤ ∑ _x : ZMod p, (1 : ℝ) := sum_le_sum (fun x _ => by + have := (sq_le_sq₀ (abs_nonneg (f x)) zero_le_one).mpr (hf x) + simpa only [sq_abs, one_pow] using this) + _ = _ := by simp + have hgp : ∑ x : ZMod p, (g x) ^ 2 ≤ (p : ℝ) := by + calc + _ ≤ ∑ _x : ZMod p, (1 : ℝ) := sum_le_sum (fun x _ => by + have := (sq_le_sq₀ (abs_nonneg (g x)) zero_le_one).mpr (hg x) + simpa only [sq_abs, one_pow] using this) + _ = _ := by simp + have h := single_square_mixing_unnormalized hp f g + have hh : |∑ x : ZMod p, ∑ y : ZMod p, + f x * g y * (squareIndicator (y - x) - 1 / 2)| ≤ + ((Real.sqrt p + 1) / 2) * p := by + calc + _ ≤ _ := h + _ ≤ ((Real.sqrt p + 1) / 2) * Real.sqrt (p : ℝ) * Real.sqrt (p : ℝ) := by + gcongr + _ = _ := by rw [mul_assoc, ← pow_two, Real.sq_sqrt hnp.le] + rw [abs_div, abs_of_pos (pow_pos hnp 2)] + calc + _ ≤ (((Real.sqrt p + 1) / 2) * p) / (p : ℝ) ^ 2 := + div_le_div_of_nonneg_right hh (by positivity) + _ = _ := by field_simp + +lemma expect_update {W X : Type*} [Fintype W] [Fintype X] [Nonempty X] + [DecidableEq W] (u : W) (H : (W → X) → ℝ) : + (𝔼 z : W → X, 𝔼 x : X, H (Function.update z u x)) = 𝔼 z : W → X, H z := by + let e : ((W → X) × X) ≃ ((W → X) × X) := + { toFun := fun a => (Function.update a.1 u a.2, a.1 u) + invFun := fun a => (Function.update a.1 u a.2, a.1 u) + left_inv := by rintro ⟨z, x⟩; simp + right_inv := by rintro ⟨z, x⟩; simp } + have he := Fintype.expect_equiv e + (fun a : (W → X) × X => H (Function.update a.1 u a.2)) + (fun a : (W → X) × X => H a.1) (fun _ => rfl) + rw [← univ_product_univ, expect_product, expect_product] at he + simpa only [expect_const univ_nonempty] using he + +lemma expect_update_two {W X : Type*} [Fintype W] [Fintype X] [Nonempty X] + [DecidableEq W] (u v : W) (H : (W → X) → ℝ) : + (𝔼 z : W → X, 𝔼 x : X, 𝔼 y : X, + H (Function.update (Function.update z u x) v y)) = 𝔼 z : W → X, H z := by + calc + _ = 𝔼 z : W → X, 𝔼 y : X, H (Function.update z v y) := + expect_update u (fun z => 𝔼 y : X, H (Function.update z v y)) + _ = _ := expect_update v H + +lemma single_square_mixing_expect {p : ℕ} [Fact p.Prime] (hp : p ≠ 2) + (f g : ZMod p → ℝ) (hf : ∀ x, |f x| ≤ 1) (hg : ∀ x, |g x| ≤ 1) : + |𝔼 x : ZMod p, 𝔼 y : ZMod p, + f x * g y * (squareIndicator (y - x) - 1 / 2)| ≤ + (Real.sqrt p + 1) / (2 * p) := by + have h := single_square_mixing_bounded hp f g hf hg + simpa only [Fintype.expect_eq_sum_div_card, ZMod.card, ← sum_div, div_div, + ← pow_two] using h + +lemma edge_product_factor {W X : Type*} [DecidableEq W] + (E : Finset (W × W)) (A : X → X → ℝ) {u v : W} (huv : u ≠ v) + (he : ∀ e ∈ E, ¬ ((e.1 = u ∧ e.2 = v) ∨ (e.1 = v ∧ e.2 = u))) + (z : W → X) (x y : X) : + (∏ e ∈ E, A ((Function.update (Function.update z u x) v y) e.1) + ((Function.update (Function.update z u x) v y) e.2)) = + (∏ e ∈ E, if e.1 = v ∨ e.2 = v then 1 else + A ((Function.update z u x) e.1) ((Function.update z u x) e.2)) * + (∏ e ∈ E, if e.1 = v ∨ e.2 = v then + A ((Function.update z v y) e.1) ((Function.update z v y) e.2) else 1) := by + classical + rw [← prod_mul_distrib] + apply prod_congr rfl + intro e heE + by_cases hv : e.1 = v ∨ e.2 = v + · have hne1 : e.1 ≠ u := by + have := he e heE + aesop + have hne2 : e.2 ≠ u := by + have := he e heE + aesop + simp [hv, Function.update_apply, hne1, hne2] + · have hv1 := (not_or.mp hv).1 + have hv2 := (not_or.mp hv).2 + simp [Function.update_apply, hv1, hv2] + +lemma edge_product_abs_le_one {W X : Type*} (E : Finset (W × W)) + (A : X → X → ℝ) (hA0 : ∀ x y, 0 ≤ A x y) (hA1 : ∀ x y, A x y ≤ 1) + (z : W → X) : |∏ e ∈ E, A (z e.1) (z e.2)| ≤ 1 := by + rw [abs_of_nonneg (prod_nonneg (fun _ _ => hA0 _ _))] + exact prod_le_one₀ (fun _ _ => hA0 _ _) (fun _ _ => hA1 _ _) + +lemma graph_edge_error {W X : Type*} [Fintype W] [Fintype X] [Nonempty X] + [DecidableEq W] (E : Finset (W × W)) (A : X → X → ℝ) + (hA0 : ∀ x y, 0 ≤ A x y) (hA1 : ∀ x y, A x y ≤ 1) + {δ : ℝ} (hmix : ∀ f g : X → ℝ, (∀ x, |f x| ≤ 1) → (∀ x, |g x| ≤ 1) → + |𝔼 x : X, 𝔼 y : X, f x * g y * (A x y - 1 / 2)| ≤ δ) + {u v : W} (huv : u ≠ v) + (he : ∀ e ∈ E, ¬ ((e.1 = u ∧ e.2 = v) ∨ (e.1 = v ∧ e.2 = u))) : + |𝔼 z : W → X, (A (z u) (z v) - 1 / 2) * ∏ e ∈ E, A (z e.1) (z e.2)| ≤ δ := by + classical + let F (z : W → X) (x : X) := ∏ e ∈ E, if e.1 = v ∨ e.2 = v then 1 else + A ((Function.update z u x) e.1) ((Function.update z u x) e.2) + let G (z : W → X) (y : X) := ∏ e ∈ E, if e.1 = v ∨ e.2 = v then + A ((Function.update z v y) e.1) ((Function.update z v y) e.2) else 1 + have hF (z : W → X) (x : X) : |F z x| ≤ 1 := by + dsimp [F] + rw [abs_prod] + apply prod_le_one₀ (fun _ _ => abs_nonneg _) + intro e _ + split_ifs + · norm_num + · rw [abs_of_nonneg (hA0 _ _)] + exact hA1 _ _ + have hG (z : W → X) (y : X) : |G z y| ≤ 1 := by + dsimp [G] + rw [abs_prod] + apply prod_le_one₀ (fun _ _ => abs_nonneg _) + intro e _ + split_ifs + · rw [abs_of_nonneg (hA0 _ _)] + exact hA1 _ _ + · norm_num + let H (z : W → X) := (A (z u) (z v) - 1 / 2) * ∏ e ∈ E, A (z e.1) (z e.2) + have hH (z : W → X) (x y : X) : + H (Function.update (Function.update z u x) v y) = + F z x * G z y * (A x y - 1 / 2) := by + dsimp [H, F, G] + rw [edge_product_factor E A huv he] + simp only [Function.update_of_ne huv, Function.update_self] + ring + change |𝔼 z : W → X, H z| ≤ δ + rw [← expect_update_two u v H] + simp_rw [hH] + calc + _ ≤ 𝔼 z : W → X, |𝔼 x : X, 𝔼 y : X, + F z x * G z y * (A x y - 1 / 2)| := abs_expect_le _ _ + _ ≤ δ := expect_le univ_nonempty (fun z _ => hmix (F z) (G z) (hF z) (hG z)) + +lemma graph_counting {W X : Type*} [Fintype W] [Fintype X] [Nonempty X] + [DecidableEq W] (E : Finset (W × W)) (A : X → X → ℝ) + (hA0 : ∀ x y, 0 ≤ A x y) (hA1 : ∀ x y, A x y ≤ 1) + {δ : ℝ} (hδ : 0 ≤ δ) + (hmix : ∀ f g : X → ℝ, (∀ x, |f x| ≤ 1) → (∀ x, |g x| ≤ 1) → + |𝔼 x : X, 𝔼 y : X, f x * g y * (A x y - 1 / 2)| ≤ δ) + (hnoloop : ∀ e ∈ E, e.1 ≠ e.2) + (hnoopp : ∀ e ∈ E, (e.2, e.1) ∉ E) : + |(𝔼 z : W → X, ∏ e ∈ E, A (z e.1) (z e.2)) - (1 / 2 : ℝ) ^ E.card| ≤ + E.card * δ := by + classical + induction E using Finset.induction_on with + | empty => simp + | @insert e E hne ih => + have hloop := hnoloop e (mem_insert_self e E) + have hcross : ∀ a ∈ E, ¬ ((a.1 = e.1 ∧ a.2 = e.2) ∨ + (a.1 = e.2 ∧ a.2 = e.1)) := by + intro a ha h + rcases h with h | h + · have hae : a = e := Prod.ext h.1 h.2 + exact hne (hae ▸ ha) + · have hae : a = (e.2, e.1) := Prod.ext h.1 h.2 + exact hnoopp e (mem_insert_self e E) (mem_insert_of_mem (hae ▸ ha)) + have herr := graph_edge_error E A hA0 hA1 hmix hloop hcross + have hind := ih (fun a ha => hnoloop a (mem_insert_of_mem ha)) + (fun a ha hop => hnoopp a (mem_insert_of_mem ha) (mem_insert_of_mem hop)) + let S : ℝ := 𝔼 z : W → X, ∏ a ∈ E, A (z a.1) (z a.2) + let R : ℝ := 𝔼 z : W → X, + (A (z e.1) (z e.2) - 1 / 2) * ∏ a ∈ E, A (z a.1) (z a.2) + have heq : (𝔼 z : W → X, ∏ a ∈ insert e E, A (z a.1) (z a.2)) = + R + (1 / 2) * S := by + dsimp [R, S] + simp only [prod_insert hne, sub_mul, expect_sub_distrib, ← mul_expect] + ring + rw [heq, card_insert_of_notMem hne, pow_succ, Nat.cast_add, Nat.cast_one] + have hrewrite : R + 1 / 2 * S - (1 / 2 : ℝ) ^ E.card * (1 / 2) = + R + 1 / 2 * (S - (1 / 2 : ℝ) ^ E.card) := by ring + rw [hrewrite] + calc + _ ≤ |R| + |1 / 2 * (S - (1 / 2 : ℝ) ^ E.card)| := abs_add_le _ _ + _ = |R| + 1 / 2 * |S - (1 / 2 : ℝ) ^ E.card| := by + rw [abs_mul] + norm_num + _ ≤ δ + 1 / 2 * (E.card * δ) := add_le_add herr (mul_le_mul_of_nonneg_left hind (by norm_num)) + _ ≤ (E.card + 1) * δ := by nlinarith [mul_nonneg (Nat.cast_nonneg E.card) hδ] + +lemma graph_count {W : Type*} [Fintype W] [DecidableEq W] + {p : ℕ} [Fact p.Prime] (hp : p ≠ 2) (E : Finset (W × W)) + (hnoloop : ∀ e ∈ E, e.1 ≠ e.2) (hnoopp : ∀ e ∈ E, (e.2, e.1) ∉ E) : + |(𝔼 z : W → ZMod p, ∏ e ∈ E, squareIndicator (z e.2 - z e.1)) - + (1 / 2 : ℝ) ^ E.card| ≤ E.card * ((Real.sqrt p + 1) / (2 * p)) := by + exact graph_counting E (fun x y : ZMod p => squareIndicator (y - x)) + (fun _ _ => squareIndicator_nonneg _) (fun _ _ => squareIndicator_le_one _) + (by positivity) (single_square_mixing_expect hp) hnoloop hnoopp + +lemma four_cycle_bound {X Y : Type*} [Fintype X] [Fintype Y] + (B : X → Y → ℝ) (f : X → ℝ) (g : Y → ℝ) : + (𝔼 x : X, 𝔼 y : Y, f x * B x y * g y) ^ 4 ≤ + (𝔼 x : X, 𝔼 x' : X, 𝔼 y : Y, 𝔼 y' : Y, + B x y * B x y' * B x' y * B x' y') * + (𝔼 x : X, (f x) ^ 2) ^ 2 * (𝔼 y : Y, (g y) ^ 2) ^ 2 := by + classical + let T (x : X) := 𝔼 y : Y, B x y * g y + let C (y y' : Y) := 𝔼 x : X, B x y * B x y' + have h1 := expect_mul_sq_le_sq_mul_sq univ f T + have h2 := expect_mul_sq_le_sq_mul_sq (univ : Finset (Y × Y)) + (fun yy => g yy.1 * g yy.2) (fun yy => C yy.1 yy.2) + have hT : (𝔼 x : X, (T x) ^ 2) = + 𝔼 yy : Y × Y, (g yy.1 * g yy.2) * C yy.1 yy.2 := by + rw [← univ_product_univ, expect_product] + dsimp [T, C] + simp_rw [sq, expect_mul, mul_expect] + rw [expect_comm] + congr 1 + ext y + rw [expect_comm] + congr 1 + ext y' + apply expect_congr rfl + intro x _ + ring + have hgg : (𝔼 yy : Y × Y, (g yy.1 * g yy.2) ^ 2) = + (𝔼 y : Y, (g y) ^ 2) ^ 2 := by + rw [← univ_product_univ, expect_product] + simp_rw [mul_pow, ← mul_expect, ← expect_mul] + ring + have hC : (𝔼 yy : Y × Y, (C yy.1 yy.2) ^ 2) = + 𝔼 x : X, 𝔼 x' : X, 𝔼 y : Y, 𝔼 y' : Y, + B x y * B x y' * B x' y * B x' y' := by + rw [← univ_product_univ, expect_product] + dsimp [C] + simp_rw [sq, expect_mul, mul_expect] + rw [expect_comm] + simp_rw [expect_comm (univ : Finset Y) (univ : Finset X)] + rw [expect_comm] + apply expect_congr rfl + intro x _ + apply expect_congr rfl + intro x' _ + apply expect_congr rfl + intro y _ + apply expect_congr rfl + intro y' _ + ring + rw [hgg, hC, ← hT] at h2 + have hF : 0 ≤ 𝔼 x : X, (f x) ^ 2 := expect_nonneg (fun _ _ => sq_nonneg _) + have hT0 : 0 ≤ 𝔼 x : X, (T x) ^ 2 := expect_nonneg (fun _ _ => sq_nonneg _) + have hrewrite : (𝔼 x : X, 𝔼 y : Y, f x * B x y * g y) = + 𝔼 x : X, f x * T x := by + dsimp [T] + simp_rw [mul_expect, mul_assoc] + rw [hrewrite, show (4 : ℕ) = 2 * 2 from rfl, pow_mul] + calc + _ ≤ ((𝔼 x : X, (f x) ^ 2) * (𝔼 x : X, (T x) ^ 2)) ^ 2 := + (sq_le_sq₀ (sq_nonneg _) (mul_nonneg hF hT0)).mpr h1 + _ = (𝔼 x : X, (f x) ^ 2) ^ 2 * (𝔼 x : X, (T x) ^ 2) ^ 2 := mul_pow _ _ _ + _ ≤ (𝔼 x : X, (f x) ^ 2) ^ 2 * + ((𝔼 y : Y, (g y) ^ 2) ^ 2 * + (𝔼 x : X, 𝔼 x' : X, 𝔼 y : Y, 𝔼 y' : Y, + B x y * B x y' * B x' y * B x' y')) := + mul_le_mul_of_nonneg_left h2 (sq_nonneg _) + _ = _ := by ring + +end SquareDifference +end + +end OAI diff --git a/lean/OAI/Combinatorics/SquareDifference/GoodPairSupport.lean b/lean/OAI/Combinatorics/SquareDifference/GoodPairSupport.lean new file mode 100644 index 0000000000000000000000000000000000000000..c71390b57dd32624964fd12ad0871ba52af2ab19 --- /dev/null +++ b/lean/OAI/Combinatorics/SquareDifference/GoodPairSupport.lean @@ -0,0 +1,43 @@ +import OAI.Combinatorics.SquareDifference.LocalizedPair + +namespace OAI + +section + +open Finset + +open scoped BigOperators + +namespace SquareDifference + +open LiftTheory.SquareDifference + +lemma tensorGood_density_square [Fintype TupleVertex] [DecidableEq TupleVertex] + {J : Type*} [Fintype J] [DecidableEq J] (p : J → ℕ) [∀j,Fact (p j).Prime] + (hp : ∀j,tupleMassThreshold≤(p j:ℝ)) (k : ℕ) + (z : TupleVertex → ResidueSpace p) + (hz : lawDensity (tensorLaw (fun j => tupleGoodLaw (p:=p j))) z≠0) : + ∀j,z (cycleVertex (k+1)) j-z (cycleVertex k) j≠0 ∧ + IsSquare (z (cycleVertex (k+1)) j-z (cycleVertex k) j) := by + classical + let P : ResidueSpace p × ResidueSpace p → Prop := fun xy => + ∀j,xy.2 j-xy.1 j≠0 ∧ IsSquare (xy.2 j-xy.1 j) + have hprob : tensorLaw (fun j => tupleGoodLaw (p:=p j)) + (fun z => if P (z (cycleVertex k),z (cycleVertex (k+1))) then 0 else 1)=0 := by + rw [tensorGood_pair p hp k (fun x y => if P (x,y) then 0 else 1)] + have hp' (w : ∀j,(ZMod (p j))ˣ) (x : ResidueSpace p) : + P (x,fun j => x j+(w j:ZMod (p j))^2) := by + intro j + dsimp only + rw [add_sub_cancel_left] + exact ⟨pow_ne_zero _ (Units.ne_zero _),⟨(w j:ZMod (p j)),by ring⟩⟩ + simp only [hp',ite_true,Fintype.expect_const] + exact positiveLaw_density_pair_support _ + (tensorLaw_nonneg _ (fun _ => tupleGoodLaw_nonneg)) + (fun z => (z (cycleVertex k),z (cycleVertex (k+1)))) P hprob z hz + +end SquareDifference + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SquareDifference/InductionParameters.lean b/lean/OAI/Combinatorics/SquareDifference/InductionParameters.lean new file mode 100644 index 0000000000000000000000000000000000000000..315fc7187de0838c48d09285f71df671d1323f97 --- /dev/null +++ b/lean/OAI/Combinatorics/SquareDifference/InductionParameters.lean @@ -0,0 +1,68 @@ +import OAI.Combinatorics.SquareDifference.MixedCrude + +namespace OAI + +section + +open Finset Filter + +open scoped Topology + +namespace SquareDifference + +lemma childLength_rpow_bound (N D : ℕ) (hN : 0 (M:ℝ)^(2*a)*(1-3*ρ/4)) 0 := + ((Real.continuous_const_rpow hm).continuousAt.comp (continuousAt_const.mul continuousAt_id)).mul_const _ + have hg : (M:ℝ)^(2*(0:ℝ))*(1-3*ρ/4)<1 := by simp only [mul_zero,Real.rpow_zero,one_mul]; linarith + have he : ∀ᶠ a : ℝ in 𝓝 0,(M:ℝ)^(2*a)*(1-3*ρ/4)<1 ∧ a<σ ∧ a<(1:ℝ)/2 := + (hc.eventually (eventually_lt_nhds hg)).and ((eventually_lt_nhds hσ).and (eventually_lt_nhds (by norm_num : (0:ℝ)<1/2))) + obtain ⟨δ,hδ,hb⟩ := Metric.eventually_nhds_iff.mp he + have hh := hb (show dist (δ/2) (0:ℝ)<δ by rw [Real.dist_eq,sub_zero,abs_of_pos (by linarith)]; linarith) + exact ⟨δ/2,by linarith,hh.2.1,by linarith [hh.2.2],hh.1⟩ + +end SquareDifference + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SquareDifference/InductiveBounds.lean b/lean/OAI/Combinatorics/SquareDifference/InductiveBounds.lean new file mode 100644 index 0000000000000000000000000000000000000000..0a5a04137394b3dd6570af9ca991997fdf38437c --- /dev/null +++ b/lean/OAI/Combinatorics/SquareDifference/InductiveBounds.lean @@ -0,0 +1,139 @@ +import OAI.Combinatorics.SquareDifference.InductionParameters + +namespace OAI + +section + +open Finset Filter + +open scoped BigOperators Topology + +namespace SquareDifference + +open LiftTheory.SquareDifference + +lemma weighted_affine_sum_bound {I : Type*} (S : Finset I) (w k : I → ℝ) + (c e : ℝ) (hc : 0≤c) (he : 0≤e) + (hwk : (∑i∈S,w i*k i)≤1/4) (hw : (∑i∈S,w i)≤1) : + (∑i∈S,w i*(c*k i+e))≤c/4+e := by + have heq : (∑i∈S,w i*(c*k i+e))=c*(∑i∈S,w i*k i)+e*(∑i∈S,w i) := by + rw [mul_sum,mul_sum,←sum_add_distrib] + apply sum_congr rfl + intro i _ + ring + rw [heq] + nlinarith + +lemma source_inductive_step {S : Type} [Fintype S] [DecidableEq S] + (ps : S → ℕ) [∀s,Fact (ps s).Prime] (hM2 : 2 ≤ smallModulus ps) : + ∃E : ℝ,0 Sum.inr.inj (hinj hij) + have hmass' (j : J) := (le_max_left _ _).trans (hmass j) + let q : Finset J → ℕ := fun B => ∏j∈B,p j + have hq (B : Finset J) : 0 (Fact.out : (p j).Prime).pos) + let X := D*(M:ℝ)^(2*a)*(N:ℝ)^(-a) + let T := transferFactor d M N + let e := (N:ℝ)^(-sourceSigma d) + have hX : 0≤X := mul_nonneg (mul_nonneg hD (Real.rpow_nonneg (Nat.cast_nonneg _) _)) (Real.rpow_nonneg (Nat.cast_nonneg _) _) + have hT : 0≤T := transferFactor_nonneg _ _ _ + have he : 0≤e := Real.rpow_nonneg (Nat.cast_nonneg _) _ + let F : (TupleVertex → ZMod M) → TupleVertex → ResidueSpace p → ℝ := + fun s v => actualTruncatedLift p N (powerCutoff N sourceBeta) (smallResidueInput M A (s v)) + have hsmall (B : Finset J) (hB : (∏j∈B,p j:ℝ)≤(N:ℝ)^(sourceTau d)) (s : TupleVertex → ZMod M) : + |multilinearIntegral (actualMixedLaw p B) (F s)|≤exceptionalProduct p B*(T*(X*(∏j∈B,p j:ℝ)^(2*a))+Ct*e) := by + have hL : 0 hind _ (by omega) hLN A' hA' hf) + apply ht'.trans + apply mul_le_mul_of_nonneg_left _ (exceptionalProduct_nonneg p B) + apply add_le_add _ le_rfl + apply mul_le_mul_of_nonneg_left _ hT + have hl := mul_le_mul_of_nonneg_left (childLength_product_rpow_bound N M (q B) hN0 (by omega) (hq B) a ha) hD + apply hl.trans_eq + dsimp [X,q] + rw [Nat.cast_prod] + ring + have hbad (s : TupleVertex → ZMod M) : + |multilinearIntegral (productTupleLaw p) (F s)|≤T*X+E*e := by + have hh := hsmall ∅ (by simpa only [prod_empty] using Real.one_le_rpow (by exact_mod_cast hN1) (sourceTau_pos d).le) s + simp only [actualMixedLaw_empty,exceptionalProduct,prod_empty,Real.one_rpow,mul_one,one_mul] at hh + apply hh.trans + have hCtE : Ct≤E := by dsimp [E]; linarith + exact add_le_add le_rfl (mul_le_mul_of_nonneg_right hCtE he) + have hgood (s : TupleVertex → ZMod M) (hs : goodSmallAssignment ps s) : + |multilinearIntegral (productTupleLaw p) (F s)|≤T*X/4+E*e := by + have ho' := ho p hinj hp hmass hcover A hA hfree s hs + have hi := actual_exceptional_bound p hmass' (tupleEta_le_one_of_fourth p heta) (F s) + let U : Finset (Finset J) := univ.erase ∅ + let V := U.filter (fun B => (∏j∈B,p j:ℝ)≤(N:ℝ)^(sourceTau d)) + let W := U.filter (fun B => (N:ℝ)^(sourceTau d)<(∏j∈B,p j:ℝ)) + have hps (j : J) : 5≤p j := (by omega : 5≤64).trans (hp j) + have hsw := exceptional_small_power_budget p hinjp hps heta V (filter_subset _ _) (2*a) ha1 + have hw : (∑B∈V,exceptionalProduct p B)≤1 := by + have hh := exceptional_small_power_budget p hinjp hps heta V (filter_subset _ _) 0 (by norm_num) + simp only [Real.rpow_zero,mul_one] at hh + linarith + have hvs : (∑B∈V,|multilinearIntegral (actualMixedLaw p B) (F s)|)≤T*X/4+Ct*e := by + apply le_trans (sum_le_sum (fun B hB => hsmall B (mem_filter.mp hB).2 s)) + simpa only [mul_assoc] using weighted_affine_sum_bound V (exceptionalProduct p) (fun B => (∏j∈B,p j:ℝ)^(2*a)) + (T*X) (Ct*e) (mul_nonneg hT hX) (mul_nonneg hCt.le he) hsw hw + have hws : (∑B∈W,|multilinearIntegral (actualMixedLaw p B) (F s)|)≤Cc*e := by + have hh := exceptional_large_tail p hinjp hps heta N hN0 (sourceTau d) + calc + _ ≤ ∑B∈W,exceptionalProduct p B*(Cc*(N:ℝ)^(2*(d:ℝ)*sourceLoss d)) := + sum_le_sum (fun B _ => hc p hinjp hmass' B A s) + _ = (∑B∈W,exceptionalProduct p B)*(Cc*(N:ℝ)^(2*(d:ℝ)*sourceLoss d)) := (sum_mul ..).symm + _ ≤ ((N:ℝ)^(-sourceTau d)/4)*(Cc*(N:ℝ)^(2*(d:ℝ)*sourceLoss d)) := + mul_le_mul_of_nonneg_right hh (mul_nonneg hCc.le (Real.rpow_nonneg (Nat.cast_nonneg _) _)) + _ ≤ _ := crude_tail_rate d N hN1 Cc hCc.le + have hu : (∑B∈U,|multilinearIntegral (actualMixedLaw p B) (F s)|)= + (∑B∈V,|multilinearIntegral (actualMixedLaw p B) (F s)|)+(∑B∈W,|multilinearIntegral (actualMixedLaw p B) (F s)|) := by + simpa only [not_le] using (sum_filter_add_sum_filter_not U (fun B => (∏j∈B,p j:ℝ)≤(N:ℝ)^(sourceTau d)) + (fun B => |multilinearIntegral (actualMixedLaw p B) (F s)|)).symm + rw [hu] at hi + dsimp [E] + linarith + rw [setFunctional_small_average p N (powerCutoff N sourceBeta) M A] + apply (le_abs_self _).trans + have hav := event_average_bound (goodSmallAssignment ps) (fun s => multilinearIntegral (productTupleLaw p) (F s)) + (T*X/4+E*e) (T*X+E*e) hgood (fun s _ => hbad s) + apply hav.trans_eq + change goodSmallProbability ps*(T*X/4+E*e)+(1-goodSmallProbability ps)*(T*X+E*e)=_ + dsimp [X,T,e] + ring + +end SquareDifference + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SquareDifference/IntervalCoefficient.lean b/lean/OAI/Combinatorics/SquareDifference/IntervalCoefficient.lean new file mode 100644 index 0000000000000000000000000000000000000000..6da20dbb3b9d601a6a8909f21fe057a45ed93c9d --- /dev/null +++ b/lean/OAI/Combinatorics/SquareDifference/IntervalCoefficient.lean @@ -0,0 +1,89 @@ +import OAI.Combinatorics.SquareDifference.CyclicIndicator + +namespace OAI + +section + +open Finset + +open scoped BigOperators ComplexConjugate + +namespace SquareDifference + +open LiftTheory.SquareDifference PairBridge + +section Coefficient + +variable {J : Type*} [Fintype J] [instDecidableEqJ : DecidableEq J] (p : J → ℕ) [instNeZeropj : ∀j,NeZero (p j)] + +lemma residueFourier_real_mul (a : ℝ) (f : ResidueSpace p → ℝ) (ξ : ResidueSpace p) : + residueFourier p (fun x => ((a*f x:ℝ):ℂ)) ξ=(a:ℂ)*residueFourier p (fun x => (f x:ℂ)) ξ := by + simp only [residueFourier,Complex.ofReal_mul,mul_assoc,mul_expect] + +lemma sequenceCoeff_mul {J : Type*} + [Fintype J] + [DecidableEq J] + (p : J → ℕ) + [∀ (j : J), NeZero (p j)] (N : ℕ) (a : ℝ) (f : ℕ → ℝ) (ξ : ResidueSpace p) : + sequenceCoeff p N (fun n => a*f n) ξ=(a:ℂ)*sequenceCoeff p N f ξ := by + simp only [sequenceCoeff,Complex.ofReal_mul,mul_assoc,←mul_sum] + ring + +lemma selected_gated {J : Type*} + [Fintype J] + [DecidableEq J] + (p : J → ℕ) + [∀ (j : J), NeZero (p j)] (M a L : ℕ) (A : Finset ℕ) (s : ZMod M) (B : Finset J) (z : ResidueSpace p) (n : ℕ) : + gatedSequence p B z (intervalInput a L (smallResidueInput M A s)) n= + (M*(∏j∈B,p j):ℝ)*selectedIndicator p M a L A s B z n := by + unfold gatedSequence intervalInput smallResidueInput natIndicator selectedIndicator + by_cases hA : n∈A <;> by_cases hi : n∈Ico a (a+L) <;> + by_cases hs : (n:ZMod M)=s <;> by_cases hz : ∀j∈B,(n:ZMod (p j))=z j <;> + simp [hA,hi,hs,hz,Nat.cast_prod] ; ring_nf + +lemma smallResidueInput_zero (M N : ℕ) (A : Finset ℕ) (hA : A⊆range N) (s : ZMod M) + (n : ℕ) (hn : N≤n) : smallResidueInput M A s n=0 := by + unfold smallResidueInput + rw [natIndicator_vanish N A hA n hn] + simp + +lemma selected_sequenceCoeff (M a L N : ℕ) (A : Finset ℕ) (hA : A⊆range N) + (s : ZMod M) (B : Finset J) (z : ResidueSpace p) (q : ℕ) [NeZero q] (hN : N≤q) + (ξ : ResidueSpace (OutsideModulus p B)) : + sequenceCoeff (OutsideModulus p B) N (selectedIndicator p M a L A s B z) ξ= + sequenceResidueFourier (OutsideModulus p B) N + (fun x : ZMod q => (selectedIndicator p M a L A s B z x.val:ℂ)) ZMod.val ξ := by + unfold sequenceCoeff sequenceResidueFourier + congr 1 + symm + exact sum_zmod_val_support q N hN + (fun n => (selectedIndicator p M a L A s B z n:ℂ)*conj (prodChar (OutsideModulus p B) ξ (fun j => (n:ZMod (p j))))) + (fun n hn => by rw [selectedIndicator_zero p M a L N A hA s B z n hn]; simp) + +lemma actual_interval_outside_coefficient (M a L N Q H : ℕ) (hN : 0 (intervalLift p a L Q (smallResidueInput M A s) (assembleOutside p B z x):ℂ)) ξ= + (((N:ℝ)/L*(M*(∏j∈B,p j):ℝ)):ℂ)* + sequenceResidueFourier (OutsideModulus p B) N + (fun x : ZMod q => (selectedIndicator p M a L A s B z x.val:ℂ)) ZMod.val ξ := by + simp_rw [intervalLift_global p N a L Q hN (smallResidueInput M A s) + (smallResidueInput_zero M N A hA s)] + rw [residueFourier_real_mul,actual_frozen_outside_coefficient p B N Q H _ hHQ z ξ hξ] + have heg : gatedSequence p B z (intervalInput a L (smallResidueInput M A s))= + fun n => (M*(∏j∈B,p j):ℝ)*selectedIndicator p M a L A s B z n := + funext (selected_gated p M a L A s B z) + rw [heg] + rw [sequenceCoeff_mul,selected_sequenceCoeff p M a L N A hA s B z q hNq] + push_cast + ring + +end Coefficient + +end SquareDifference + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SquareDifference/IntervalContraction.lean b/lean/OAI/Combinatorics/SquareDifference/IntervalContraction.lean new file mode 100644 index 0000000000000000000000000000000000000000..53c0f9a07b0af48b35857b890c3efd7d50d69946 --- /dev/null +++ b/lean/OAI/Combinatorics/SquareDifference/IntervalContraction.lean @@ -0,0 +1,78 @@ +import OAI.Combinatorics.SquareDifference.OrderedRates + +namespace OAI + +section + +open Finset Filter + +open scoped BigOperators Topology + +namespace SquareDifference + +open LiftTheory.SquareDifference + +lemma orderedErrorConstant_nonneg (d M : ℕ) (C : ℝ) (hC : 0≤C) : 0≤orderedErrorConstant d M C := by + unfold orderedErrorConstant + exact add_nonneg (add_nonneg (add_nonneg (by positivity) (by positivity)) + (mul_nonneg (by positivity) kernelAbsoluteConstant_nonneg)) (by positivity) + +lemma source_ordered_contraction {S : Type} [Fintype S] [DecidableEq S] + (ps : S → ℕ) [∀s,Fact (ps s).Prime] : + ∃C : ℝ,0 tupleGoodLaw (p:=p j))) + (fun v => actualTruncatedLift p N (powerCutoff N sourceBeta) + (smallResidueInput (smallModulus ps) A (s v)))|≤C*(N:ℝ)^(-sourceSigma (Fintype.card TupleVertex)) := by + let d := Fintype.card TupleVertex + let M := smallModulus ps + obtain ⟨C,hC,hb⟩ := uniform_interval_moments (sourceLoss d) (sourceLoss_pos d) + let C' := (C+1)*((M:ℝ)+1) + have hC' : 1≤C' := by dsimp [C']; nlinarith [Nat.cast_nonneg (α:=ℝ) M] + let E := (2:ℝ)^d*orderedErrorConstant d M C' + have hE : 0≤E := mul_nonneg (by positivity) (orderedErrorConstant_nonneg d M C' (by linarith)) + refine ⟨E+1,by linarith,?_⟩ + filter_upwards [eventual_block_scales d M] with N hscale + intro J _ _ p _ hinj hp hmass hcover A hA hfree s hgood + dsimp only at hscale + obtain ⟨hN,hK,hL,hNKL,hfac,hNL,hsize,hQN,hH,hHQ,hD,hHn,hlarge,hKl,hHl⟩ := hscale + let K := powerCutoff N (sourceTau d) + let L := blockLength N K + let H := powerCutoff N (sourceBeta/2) + have hinjp : Function.Injective p := fun i j hij => Sum.inr.inj (hinj (show extendedPrime ps p (Sum.inr i)=extendedPrime ps p (Sum.inr j) from hij)) + have hR : 1≤C'*(N:ℝ)^(sourceLoss d) := one_le_mul_of_one_le_of_one_le hC' + (Real.one_le_rpow (by exact_mod_cast hN) (sourceLoss_pos d).le) + have hm (a : ℕ) (v : TupleVertex) (t : Finset (Finset J)) (ht : t⊆liftSupportFamily p (powerCutoff N sourceBeta)) + (r : ℕ) (hr : r=1 ∨ r+1=d) : + (𝔼 x,(∑U∈t,intervalPiece p a L (smallResidueInput M A (s v)) U x)^(2*r))≤ + (C'*(N:ℝ)^(sourceLoss d))^(2*r) := by + apply (hb p hinjp a L (powerCutoff N sourceBeta) N hsize hQN _ M (Nat.cast_nonneg _) (smallResidueInput_bound M A _) t ht r hr).trans + apply pow_le_pow_left₀ (mul_nonneg (mul_nonneg hC.le (Nat.cast_nonneg M)) (Real.rpow_nonneg (Nat.cast_nonneg N) _)) + apply mul_le_mul_of_nonneg_right _ (Real.rpow_nonneg (Nat.cast_nonneg _) _) + dsimp [C']; nlinarith [Nat.cast_nonneg (α:=ℝ) M] + have he := ordered_global_estimate ps p hinj hp hmass L N (powerCutoff N sourceBeta) H K hN hL + hH hK hNKL hfac hNL hHQ (by simpa only [Nat.cast_mul,Nat.cast_pow] using hD) hHn hlarge hcover + A hA hfree s hgood _ hR hm + have hr := orderedError_bound d M N K H C' (by linarith) hN (powerCutoff_le N _) hKl hHl + have he' : |multilinearIntegral (tensorLaw (fun j => tupleGoodLaw (p:=p j))) + (fun v => actualTruncatedLift p N (powerCutoff N sourceBeta) (smallResidueInput M A (s v)))|≤ + (2:ℝ)^d*orderedError d M N K H C' := by + simpa only [orderedError,sourceGamma,neg_div,add_assoc] using he + calc + _ ≤ (2:ℝ)^d*(orderedErrorConstant d M C'*(N:ℝ)^(-sourceSigma d)) := + he'.trans (mul_le_mul_of_nonneg_left hr (by positivity)) + _ ≤ (E+1)*(N:ℝ)^(-sourceSigma d) := by + dsimp [E] + nlinarith [Real.rpow_nonneg (Nat.cast_nonneg N) (-sourceSigma d)] + +end SquareDifference + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SquareDifference/IntervalCounting.lean b/lean/OAI/Combinatorics/SquareDifference/IntervalCounting.lean new file mode 100644 index 0000000000000000000000000000000000000000..8c5a24d939fa0976855b36e5bc147c8aefbdb6c7 --- /dev/null +++ b/lean/OAI/Combinatorics/SquareDifference/IntervalCounting.lean @@ -0,0 +1,115 @@ +import OAI.Combinatorics.SquareDifference.IntervalLift + +namespace OAI + +section + +open Finset + +open scoped BigOperators + +namespace LiftAnalysis + +namespace SquareDifference + +open Finset + +section SupportCounting + +variable {J : Type*} [instFintypeJ : Fintype J] [instDecidableEqJ : DecidableEq J] (p : J → ℕ) + [∀j,Fact (p j).Prime] (hinj : Function.Injective p) + +include hinj + +omit hinj in +lemma primeProduct_injective {J : Type*} + [Fintype J] + [DecidableEq J] + (p : J → ℕ) + [∀ (j : J), Fact (Nat.Prime (p j))] + (hinj : Function.Injective p) : Function.Injective (fun U : Finset J => ∏j∈U,p j) := by + intro U W he + dsimp only at he + apply subset_antisymm + all_goals intro j hj + · have hjd : p j∣∏i∈W,p i := by rw [←he]; exact dvd_prod_of_mem p hj + obtain ⟨i,hi,hji⟩ := ((Fact.out : (p j).Prime).prime.dvd_finsetProd_iff p).mp hjd + have heq : p j=p i := ((Fact.out : (p i).Prime).eq_one_or_self_of_dvd (p j) hji).resolve_left + (Fact.out : (p j).Prime).ne_one + simpa only [hinj heq] using hi + · have hjd : p j∣∏i∈U,p i := by rw [he]; exact dvd_prod_of_mem p hj + obtain ⟨i,hi,hji⟩ := ((Fact.out : (p j).Prime).prime.dvd_finsetProd_iff p).mp hjd + have heq : p j=p i := ((Fact.out : (p i).Prime).eq_one_or_self_of_dvd (p j) hji).resolve_left + (Fact.out : (p j).Prime).ne_one + simpa only [hinj heq] using hi + +lemma supportFamily_card_le (Q : ℕ) : (supportFamily p Q).card≤Q := by + calc + _ ≤ (Icc 1 Q).card := card_le_card_of_injOn (fun U => ∏j∈U,p j) + (fun U hU => mem_Icc.mpr ⟨primeProduct_pos p U,(mem_filter.mp hU).2⟩) + (primeProduct_injective p hinj).injOn + _ ≤ Q := by simp + +omit hinj in +lemma liftPiece_sup {J : Type*} + [Fintype J] + [DecidableEq J] + (p : J → ℕ) + [∀ (j : J), Fact (Nat.Prime (p j))] + (_ : Function.Injective p) (L : ℕ) (f : ℕ → ℝ) (M : ℝ) (hM : 0≤M) + (hf : ∀n abs_nonneg _) + intro j hj + unfold residueGate + split_ifs + · have hjp : (1:ℝ)≤p j := by exact_mod_cast (Fact.out : (p j).Prime).one_lt.le + rw [abs_of_nonneg (sub_nonneg.mpr hjp)] + linarith + · simpa only [zero_sub,abs_neg,abs_one] using (show (1:ℝ)≤p j by exact_mod_cast (Fact.out : (p j).Prime).one_lt.le) + have hs : |∑n∈range L,f n*exactGate p U (x-fun j => (n:ZMod (p j)))|≤ + (L:ℝ)*(M*(∏j∈U,p j : ℝ)) := by + apply (abs_sum_le_sum_abs _ _).trans + apply le_trans (sum_le_sum (fun n hn => ?_)) + · rw [sum_const,card_range,nsmul_eq_mul] + · rw [abs_mul] + exact mul_le_mul (hf n (mem_range.mp hn)) (hg _) (abs_nonneg _) hM + exact le_trans (mul_le_mul_of_nonneg_left hs (by positivity)) (by + rw [←mul_assoc,inv_mul_cancel₀ (Nat.cast_ne_zero.mpr hL),one_mul]) + +end SupportCounting + +end SquareDifference + +end LiftAnalysis + +namespace SquareDifference + +open LiftTheory.SquareDifference + +section Counting + +variable {J : Type*} [Fintype J] [DecidableEq J] (p : J → ℕ) [∀j,Fact (p j).Prime] + +lemma liftSupportFamily_card_le (hinj : Function.Injective p) (Q : ℕ) : (liftSupportFamily p Q).card≤Q := + LiftAnalysis.SquareDifference.supportFamily_card_le p hinj Q + +lemma intervalPiece_sup (hinj : Function.Injective p) (a L : ℕ) (f : ℕ → ℝ) (M : ℝ) (hM : 0≤M) + (hf : ∀n,|f n|≤M) (U : Finset J) (x : ResidueSpace p) : + |intervalPiece p a L f U x|≤M*(∏j∈U,p j:ℝ) := by + rw [intervalPiece_shift] + exact LiftAnalysis.SquareDifference.liftPiece_sup p hinj L _ M hM (fun n _ => hf _) U _ + +end Counting + +end SquareDifference + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SquareDifference/IntervalCrude.lean b/lean/OAI/Combinatorics/SquareDifference/IntervalCrude.lean new file mode 100644 index 0000000000000000000000000000000000000000..2d5b479e80f0f73f0b7a63452cea0936b085fc18 --- /dev/null +++ b/lean/OAI/Combinatorics/SquareDifference/IntervalCrude.lean @@ -0,0 +1,59 @@ +import OAI.Combinatorics.SquareDifference.OrderedLow + +namespace OAI + +section + +open Finset + +open scoped BigOperators + +namespace SquareDifference + +open LiftTheory.SquareDifference + +lemma pow_le_one_add_pow {x : ℝ} (hx : 0≤x) {m n : ℕ} (hmn : m≤n) : + x^m≤1+x^n := by + by_cases h : x≤1 + · exact (pow_le_one₀ hx h).trans (le_add_of_nonneg_right (pow_nonneg hx _)) + · exact (pow_le_pow_right₀ (le_of_not_ge h) hmn).trans (le_add_of_nonneg_left zero_le_one) + +lemma uniform_multilinear_crude {V X : Type*} [Fintype V] [DecidableEq V] + [Nontrivial V] [Fintype X] [Nonempty X] + (Llaw : ((V → X) → ℝ) →ₗ[ℝ] ℝ) (hpos : ∀F,(∀z,0≤F z) → 0≤Llaw F) + (hmar : ∀(v : V) (g : X → ℝ),Llaw (fun z => g (z v))=𝔼 x,g x) + (F : V → X → ℝ) (R : ℝ) (hR : 1≤R) + (hm : ∀v r,r+1=Fintype.card V → (𝔼 x,F v x^(2*r))≤R^(2*r)) : + |multilinearIntegral Llaw F|≤2*R^(2*Fintype.card V) := by + apply positiveLaw_product_bound Llaw hpos (fun v z => F v (z v)) _ + intro v + rw [hmar v (fun x => |F v x|^(Fintype.card V))] + have hd : 2≤Fintype.card V := Fintype.one_lt_card + have hn : Fintype.card V≤2*(Fintype.card V-1) := by omega + have hpow : R^(2*(Fintype.card V-1))≤R^(2*Fintype.card V) := + pow_le_pow_right₀ hR (by omega) + calc + _ ≤ 𝔼 x : X,(1+|F v x|^(2*(Fintype.card V-1))) := + expect_le_expect (fun x _ => pow_le_one_add_pow (abs_nonneg _) hn) + _ = 1+(𝔼 x : X,F v x^(2*(Fintype.card V-1))) := by + rw [expect_add_distrib,Fintype.expect_const] + simp only [(even_two_mul _).pow_abs] + _ ≤ 1+R^(2*(Fintype.card V-1)) := add_le_add le_rfl (hm v (Fintype.card V-1) (by omega)) + _ ≤ _ := by have hp : 1≤R^(2*Fintype.card V) := one_le_pow₀ hR; linarith + +lemma interval_multilinear_crude {J : Type*} [Fintype J] [DecidableEq J] + (p : J → ℕ) [∀j,Fact (p j).Prime] + (hp : ∀j,max tupleMassThreshold tupleConditionalThreshold≤(p j:ℝ)) + (a : TupleVertex → ℕ) (L Q : ℕ) (f : TupleVertex → ℕ → ℝ) (R : ℝ) (hR : 1≤R) + (hm : ∀v s,s⊆liftSupportFamily p Q → ∀r,r=1 ∨ r+1=Fintype.card TupleVertex → + (𝔼 x,(∑U∈s,intervalPiece p (a v) L (f v) U x)^(2*r))≤R^(2*r)) : + |multilinearIntegral (tensorLaw (fun j => tupleGoodLaw (p:=p j))) + (fun v => intervalLift p (a v) L Q (f v))|≤2*R^(2*Fintype.card TupleVertex) := by + exact uniform_multilinear_crude _ (tensorLaw_nonneg _ (fun _ => tupleGoodLaw_nonneg)) + (tensorGood_uniform_marginal p hp) _ R hR (interval_full_moment p a L Q f R hm) + +end SquareDifference + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SquareDifference/IntervalLift.lean b/lean/OAI/Combinatorics/SquareDifference/IntervalLift.lean new file mode 100644 index 0000000000000000000000000000000000000000..9e54774ec9ca979d4151dab1ebd06b7f17cf4255 --- /dev/null +++ b/lean/OAI/Combinatorics/SquareDifference/IntervalLift.lean @@ -0,0 +1,153 @@ +import OAI.Combinatorics.SquareDifference.UniformTransfer + +namespace OAI + +section + +open Finset + +open scoped BigOperators ComplexConjugate + +namespace SquareDifference + +open LiftTheory.SquareDifference + +noncomputable def intervalInput (a L : ℕ) (f : ℕ → ℝ) (n : ℕ) : ℝ := + if n∈Ico a (a+L) then f n else 0 + +lemma intervalInput_bound (a L : ℕ) (f : ℕ → ℝ) (M : ℝ) (hM : 0≤M) + (hf : ∀n,|f n|≤M) (n : ℕ) : |intervalInput a L f n|≤M := by + unfold intervalInput + split_ifs + · exact hf n + · simpa only [abs_zero] using hM + +lemma interval_sum_mask {E : Type*} [AddCommMonoid E] (N a L : ℕ) (f : ℕ → E) + (hf : ∀n,N≤n → f n=0) : + (∑n∈range N,if n∈Ico a (a+L) then f n else 0)=∑t∈range L,f (a+t) := by + rw [←sum_filter,filter_mem_eq_inter,inter_comm] + have h := sum_subset (inter_subset_left (s₁:=Ico a (a+L)) (s₂:=range N)) + (f:=f) (fun n hn hni => hf n (by simpa only [mem_inter,hn,true_and,mem_range,not_lt] using hni)) + rw [h,sum_Ico_eq_sum_range,Nat.add_sub_cancel_left] + +section Interval + +variable {J : Type*} [instFintypeJ : Fintype J] [DecidableEq J] (p : J → ℕ) [instNeZeropj : ∀j,NeZero (p j)] + +noncomputable def intervalPiece (a L : ℕ) (f : ℕ → ℝ) (U : Finset J) (x : ResidueSpace p) : ℝ := + (L:ℝ)⁻¹*∑t∈range L,f (a+t)*exactGate p U (x-fun j => ((a+t:ℕ):ZMod (p j))) + +noncomputable def intervalLift (a L Q : ℕ) (f : ℕ → ℝ) (x : ResidueSpace p) : ℝ := + ∑U∈liftSupportFamily p Q,intervalPiece p a L f U x + +lemma intervalPiece_shift {J : Type*} + [Fintype J] + [DecidableEq J] + (p : J → ℕ) + [∀ (j : J), NeZero (p j)] (a L : ℕ) (f : ℕ → ℝ) (U : Finset J) (x : ResidueSpace p) : + intervalPiece p a L f U x=actualLiftPiece p L (fun n => f (a+n)) U + (x-fun j => (a:ZMod (p j))) := by + unfold intervalPiece actualLiftPiece LiftAnalysis.SquareDifference.liftPiece + congr 1 + apply sum_congr rfl + intro n _ + congr 2 + funext j + simp only [Pi.sub_apply,Nat.cast_add] + ring + +lemma intervalLift_shift (a L Q : ℕ) (f : ℕ → ℝ) (x : ResidueSpace p) : + intervalLift p a L Q f x=actualTruncatedLift p L Q (fun n => f (a+n)) + (x-fun j => (a:ZMod (p j))) := by + simp only [intervalLift,intervalPiece_shift,actualTruncatedLift,LiftAnalysis.SquareDifference.truncatedLift] + +lemma intervalPiece_exactSupport {J : Type*} + [Fintype J] + [DecidableEq J] + (p : J → ℕ) + [∀ (j : J), NeZero (p j)] (a L : ℕ) (f : ℕ → ℝ) (U : Finset J) : + ExactSupport U (intervalPiece p a L f U) := by + constructor + · intro j hj x + simp only [intervalPiece,←mul_expect,expect_sum_comm,exactGate_update_mean p U j hj, + mul_zero,sum_const_zero] + · intro j hj x t + simp only [intervalPiece,exactGate_update_outside p U j hj] + +lemma intervalPiece_global {J : Type*} + [Fintype J] + [DecidableEq J] + (p : J → ℕ) + [∀ (j : J), NeZero (p j)] (N a L : ℕ) (hN : 0 ((a+t:ℕ):ZMod (p j)))) = + (N:ℝ)/L*((N:ℝ)⁻¹*∑n∈range N,if n∈Ico a (a+L) then f n*exactGate p U (x-fun j => (n:ZMod (p j))) else 0) + rw [interval_sum_mask N a L (fun n => f n*exactGate p U (x-fun j =>(n:ZMod (p j)))) + (fun n hn => by rw [hf n hn,zero_mul])] + field_simp + +lemma intervalLift_global (N a L Q : ℕ) (hN : 0 f (a+n)) U x)^r := by + simp only [intervalPiece_shift] + exact Fintype.expect_equiv (Equiv.subRight (fun j => (a:ZMod (p j)))) _ _ (fun _ => rfl) + +lemma blockPiece_decomposition {J : Type*} + [Fintype J] + [DecidableEq J] + (p : J → ℕ) + [∀ (j : J), NeZero (p j)] (N K L : ℕ) (hN : 0 f n*exactGate p U (x-fun j =>(n:ZMod (p j)))) + (fun n hn hni => by rw [hf n (by simpa only [mem_range,not_lt] using hni),zero_mul]) + rw [mul_comm K L,LiftAnalysis.SquareDifference.sum_range_blocks _ L K hL,sum_comm] at hs + unfold actualLiftPiece LiftAnalysis.SquareDifference.liftPiece intervalPiece + change (N:ℝ)⁻¹*(∑n∈range N,f n*exactGate p U (x-fun j => (n:ZMod (p j)))) = _ + rw [hs] + rw [←mul_sum] + have hl : (L:ℝ)≠0 := Nat.cast_ne_zero.mpr hL.ne' + field_simp + apply sum_congr rfl + intro i _ + apply sum_congr rfl + intro t _ + rw [Nat.add_comm t (L*i)] + +lemma blockLift_decomposition (N K L Q : ℕ) (hN : 0 hf _) s hsub r hr + +end SquareDifference + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SquareDifference/IntervalPair.lean b/lean/OAI/Combinatorics/SquareDifference/IntervalPair.lean new file mode 100644 index 0000000000000000000000000000000000000000..7f327715dd67a4642ff15b3221bd0c213d9edcde --- /dev/null +++ b/lean/OAI/Combinatorics/SquareDifference/IntervalPair.lean @@ -0,0 +1,131 @@ +import OAI.Combinatorics.SquareDifference.SelectedRoots + +namespace OAI + +section + +open Finset + +open scoped BigOperators ComplexConjugate + +namespace SquareDifference + +open LiftTheory.SquareDifference PairBridge + +section LowPair + +variable {S J : Type*} [Fintype S] [DecidableEq S] [Fintype J] [DecidableEq J] + (ps : S → ℕ) (p : J → ℕ) [∀i,Fact (ps i).Prime] [∀j,Fact (p j).Prime] + +lemma interval_low_pair (hinj : Function.Injective (extendedPrime ps p)) (hp2 : ∀j,p j≠2) + (B : Finset J) (a b L N Q H : ℕ) (hN : 1≤N) (hH : 1≤H) (hab : a+L≤b) + (hHQ : H*(∏j∈B,p j)≤Q) + (hD : (smallModulus ps*(∏j∈B,p j):ℝ)≤(N:ℝ)^((1:ℝ)/1000)) + (hHn : (H:ℝ)≤(N:ℝ)^((1:ℝ)/1000)) (hlarge : 8≤(N:ℝ)^((1:ℝ)/16)) + (hcover : ∀r : ℕ,r.Prime → r≤N → ∃i,extendedPrime ps p i=r) + (A : Finset ℕ) (hA : A⊆range N) (hfree : NatSquareFree A) + (s t : ZMod (smallModulus ps)) (hst : smallStrictPair ps s t) + (z w : ResidueSpace p) (hzw : ∀j∈B,w j-z j≠0 ∧ IsSquare (w j-z j)) : + ‖∑ξ∈univ.filter (fun ξ => (supportDenominator (OutsideModulus p B) ξ:ℝ)≤H), + residueFourier (OutsideModulus p B) + (fun x => (intervalLift p a L Q (smallResidueInput (smallModulus ps) A s) (assembleOutside p B z x):ℂ)) (-ξ)* + residueFourier (OutsideModulus p B) + (fun x => (intervalLift p b L Q (smallResidueInput (smallModulus ps) A t) (assembleOutside p B w x):ℂ)) ξ* + squareMultiplier (OutsideModulus p B) ξ‖≤ + ((N:ℝ)/L)^2*(smallModulus ps)*(∏j∈B,p j:ℝ)* + (kernelAbsoluteConstant*(H:ℝ)^(-(1:ℝ)/3)) := by + classical + obtain ⟨c,hc,hr⟩ := selectedRoot_witnesses ps p hp2 B s t hst z w hzw + let q := 2*N+1 + have hq : 2*N (selectedIndicator p (smallModulus ps) a L A s B z x.val:ℂ) + let G : ZMod q → ℂ := fun x => (selectedIndicator p (smallModulus ps) b L A t B w x.val:ℂ) + have hF := selectedIndicator_norm p (smallModulus ps) a L N A hA s B z q (by omega) + have hG := selectedIndicator_norm p (smallModulus ps) b L N A hA t B w q (by omega) + have hs (x : ZMod q) (hx : F x≠0) := selectedIndicator_mem p (smallModulus ps) a L A s B z x.val (by change ((selectedIndicator p (smallModulus ps) a L A s B z x.val:ℝ):ℂ)≠0 at hx; exact_mod_cast hx) + have ht (x : ZMod q) (hx : G x≠0) := selectedIndicator_mem p (smallModulus ps) b L A t B w x.val (by change ((selectedIndicator p (smallModulus ps) b L A t B w x.val:ℝ):ℂ)≠0 at hx; exact_mod_cast hx) + have hco (a : ℕ) (s : ZMod (smallModulus ps)) (z : ResidueSpace p) + (ξ : ResidueSpace (OutsideModulus p B)) (hξ : (supportDenominator (OutsideModulus p B) ξ:ℝ)≤H) := + actual_interval_outside_coefficient p (smallModulus ps) a L N Q H (by omega) A hA s B hHQ z q (by omega) ξ (by exact_mod_cast hξ) + have hk := extended_kernel_low_pair ps p hinj hp2 B c H (by exact_mod_cast hH) N hN + hD hHn hlarge hcover hc (by omega : N selectedRootLabels_nat ps p hp2 B s z x.val (hs x hx).2.2.1 (hs x hx).2.2.2) + (fun x hx => selectedRootLabels_nat ps p hp2 B t w x.val (ht x hx).2.2.1 (ht x hx).2.2.2) + (fun x => (intervalLift p a L Q (smallResidueInput (smallModulus ps) A s) (assembleOutside p B z x):ℂ)) + (fun x => (intervalLift p b L Q (smallResidueInput (smallModulus ps) A t) (assembleOutside p B w x):ℂ)) + ((N:ℝ)/L*(smallModulus ps*(∏j∈B,p j):ℝ)) ((N:ℝ)/L*(smallModulus ps*(∏j∈B,p j):ℝ)) + (by positivity) (by positivity) + (by intro ξ hξ; simpa only [F,Complex.ofReal_mul,Complex.ofReal_div,Complex.ofReal_natCast] using hco a s z ξ hξ) + (by intro ξ hξ; simpa only [G,Complex.ofReal_mul,Complex.ofReal_div,Complex.ofReal_natCast] using hco b t w ξ hξ) + have hM : (smallModulus ps:ℝ)≠0 := by + unfold smallModulus + exact_mod_cast (prod_ne_zero_iff.mpr (fun i _ => (NeZero.ne (smallQuadraticModulus (ps i))))) + have hB : (∏j∈B,p j:ℝ)≠0 := by + apply prod_ne_zero_iff.mpr + intro j _ + exact_mod_cast (Fact.out : (p j).Prime).ne_zero + convert hk using 1 + change _= ((N:ℝ)/L*(smallModulus ps*(∏j∈B,p j):ℝ))* + ((N:ℝ)/L*(smallModulus ps*(∏j∈B,p j):ℝ))/((smallModulus ps:ℝ)*(∏j∈B,p j:ℕ))*_ + push_cast + field_simp + +end LowPair + +section PairTail + +variable {J : Type*} [Fintype J] [DecidableEq J] (p : J → ℕ) [∀j,Fact (p j).Prime] + +lemma frozen_pair_tail (hp : ∀j,64≤p j) (B : Finset J) (F G : ResidueSpace p → ℝ) + (R : ℝ) (hF : (𝔼 x,F x^2)≤R^2) (hG : (𝔼 x,G x^2)≤R^2) + (z w : ResidueSpace p) (H : ℝ) (hH : 0 H<(supportDenominator (OutsideModulus p B) ξ:ℝ)), + residueFourier (OutsideModulus p B) (fun x => (F (assembleOutside p B z x):ℂ)) (-ξ)* + residueFourier (OutsideModulus p B) (fun x => (G (assembleOutside p B w x):ℂ)) ξ* + squareMultiplier (OutsideModulus p B) ξ‖≤ H^(-(1:ℝ)/3)*(∏j∈B,p j:ℝ)*R^2 := by + let m := OutsideModulus p B + have hf := outside_fiber_second_moment p B F z + have hg := outside_fiber_second_moment p B G w + have hB : 0≤(∏j∈B,p j:ℝ) := prod_nonneg (fun _ _ => Nat.cast_nonneg _) + have hfs : (𝔼 x,F (assembleOutside p B z x)^2)≤(∏j∈B,p j:ℝ)*R^2 := hf.trans (mul_le_mul_of_nonneg_left hF hB) + have hgs : (𝔼 x,G (assembleOutside p B w x)^2)≤(∏j∈B,p j:ℝ)*R^2 := hg.trans (mul_le_mul_of_nonneg_left hG hB) + have hk := squarePair_tail_bound m (fun j => hp j.val) (fun x => (F (assembleOutside p B z x):ℂ)) + (fun x => (G (assembleOutside p B w x):ℂ)) H hH + simp only [Complex.norm_real,Real.norm_eq_abs,sq_abs] at hk + have hh : H^(-(2:ℝ)/3)=(H^(-(1:ℝ)/3))^2 := by + rw [←Real.rpow_mul_natCast hH.le]; congr 1 ; norm_num + rw [hh] at hk + have hb0 : 0≤ H^(-(1:ℝ)/3)*(∏j∈B,p j:ℝ)*R^2 := by positivity + apply (sq_le_sq₀ (norm_nonneg _) hb0).mp + calc + _ ≤ _ := hk + _ ≤ (H^(-(1:ℝ)/3))^2*((∏j∈B,p j:ℝ)*R^2)*((∏j∈B,p j:ℝ)*R^2) := by + apply mul_le_mul + · exact mul_le_mul_of_nonneg_left hfs (sq_nonneg _) + · exact hgs + · exact expect_nonneg (fun _ _ => sq_nonneg _) + · positivity + _ = _ := by ring + +lemma squarePair_split_bound (F G : ResidueSpace p → ℂ) (H e₁ e₂ : ℝ) + (hlo : ‖∑a∈univ.filter (fun a => (supportDenominator p a:ℝ)≤H),residueFourier p F (-a)*residueFourier p G a*squareMultiplier p a‖≤e₁) + (hhi : ‖∑a∈univ.filter (fun a => H<(supportDenominator p a:ℝ)),residueFourier p F (-a)*residueFourier p G a*squareMultiplier p a‖≤e₂) : + ‖squarePairForm p F G‖≤e₁+e₂ := by + rw [squarePairForm_fourier] + have he := sum_filter_add_sum_filter_not univ (fun a : ResidueSpace p => (supportDenominator p a:ℝ)≤H) + (fun a => residueFourier p F (-a)*residueFourier p G a*squareMultiplier p a) + simp only [not_le] at he + rw [←he] + exact (norm_add_le _ _).trans (add_le_add hlo hhi) + +end PairTail + +end SquareDifference + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SquareDifference/IntervalTransfer.lean b/lean/OAI/Combinatorics/SquareDifference/IntervalTransfer.lean new file mode 100644 index 0000000000000000000000000000000000000000..a46405261ddbc62d58c2938533d145aff3d23663 --- /dev/null +++ b/lean/OAI/Combinatorics/SquareDifference/IntervalTransfer.lean @@ -0,0 +1,60 @@ +import OAI.Combinatorics.SquareDifference.TransferRates + +namespace OAI + +section + +open Finset Filter + +open scoped Topology + +namespace SquareDifference + +open LiftTheory.SquareDifference + +lemma source_actual_fiber_transfer (M : ℕ) [NeZero M] (hM2 : 2≤M) : + ∃C : ℝ,0 actualTruncatedLift p N (powerCutoff N sourceBeta) + (smallResidueInput M A s) (freezeCoordinates B z x))≤ + transferFactor (Fintype.card TupleVertex) M N*K+C*(N:ℝ)^(-sourceSigma (Fintype.card TupleVertex)) := by + let d := Fintype.card TupleVertex + obtain ⟨C,hC,hb⟩ := uniform_actual_fiber_transfer (sourceLoss d) (sourceLoss_pos d) + let E : ℝ := (d:ℝ)*C^d*((2:ℝ)^d+(M:ℝ)^d) + refine ⟨E+1,by dsimp [E]; positivity,?_⟩ + have he := eventual_cutoff_rpow_lower (sourceBeta/2) (sourceBeta/3) + (by have := sourceBeta_pos; linarith) (by have := sourceBeta_pos; linarith) + filter_upwards [eventual_transfer_scales d M hM2,he,eventually_ge_atTop 1] with N hscale he hN + intro J _ _ p _ hinj hcond href hM B hB s z A hA hfree K hK hchild + let q := ∏j∈B,p j + have hq : 0 (Fact.out : (p j).Prime).pos) + have hq' : (q:ℝ)≤(N:ℝ)^(sourceTau d) := by exact_mod_cast hB + obtain ⟨hL,hLN,hhalf,hsize,hsize',hQN,hQcN,hH,hHQ,hHQc,hcover,hl1,hl2⟩ := hscale q hq hq' + have ht := hb p hinj hcond href M hM N (powerCutoff N sourceBeta) + (powerCutoff N (sourceBeta/2)) (childLength N (M*q)) + (powerCutoff (childLength N (M*q)) sourceBeta) B s z hsize hsize' hQN hQcN + hH hHQ hHQc hcover A hA hfree K hK hchild + have herr := transfer_error_bound d M N (powerCutoff N (sourceBeta/2)) q C + (((M*q:ℕ):ℝ)^2*(childLength N (M*q):ℝ)/N) hN hC.le (by positivity) hl2 he hq' + have hfactor := child_factor_le d M N q (by omega) (Nat.mul_pos (by omega) hq) hq' + have herr' := herr.trans (mul_le_mul_of_nonneg_right + (show E≤E+1 from le_add_of_nonneg_right zero_le_one) + (Real.rpow_nonneg (Nat.cast_nonneg N) (-sourceSigma d))) + have hb' := add_le_add (mul_le_mul_of_nonneg_right hfactor hK) herr' + apply ht.trans + simpa only [d,E,sourceGamma,Nat.cast_prod,q,neg_div] using hb' + +end SquareDifference + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SquareDifference/IntervalTruncation.lean b/lean/OAI/Combinatorics/SquareDifference/IntervalTruncation.lean new file mode 100644 index 0000000000000000000000000000000000000000..46e1714e525434c69a94175a9ba71327b5c3af33 --- /dev/null +++ b/lean/OAI/Combinatorics/SquareDifference/IntervalTruncation.lean @@ -0,0 +1,153 @@ +import OAI.Combinatorics.SquareDifference.GateExpansion + +namespace OAI + +section + +open Finset + +open scoped BigOperators + +namespace SquareDifference + +open LiftTheory.SquareDifference + +section Truncate + +variable {J : Type*} [Fintype J] [DecidableEq J] (p : J → ℕ) [instFactNatPrimepj : ∀j,Fact (p j).Prime] + +noncomputable def retainedFamily (Q T : ℕ) (keep : Finset TupleVertex) (v : TupleVertex) : Finset (Finset J) := + if v∈keep then liftSupportFamily p Q else (liftSupportFamily p Q).filter (fun U => ∏j∈U,p j≤T) + +lemma retainedFamily_sub {J : Type*} + [Fintype J] + [DecidableEq J] + (p : J → ℕ) + [∀ (j : J), Fact (Nat.Prime (p j))] (Q T : ℕ) (keep : Finset TupleVertex) (v : TupleVertex) : + retainedFamily p Q T keep v⊆liftSupportFamily p Q := by + unfold retainedFamily + split_ifs + · exact Subset.rfl + · exact filter_subset _ _ + +lemma retainedFamily_tail_den {J : Type*} + [Fintype J] + [DecidableEq J] + (p : J → ℕ) + [∀ (j : J), Fact (Nat.Prime (p j))] (Q T : ℕ) (keep : Finset TupleVertex) (v : TupleVertex) + (U : Finset J) (hU : U∈liftSupportFamily p Q\retainedFamily p Q T keep v) : T<∏j∈U,p j := by + have hu := mem_sdiff.mp hU + unfold retainedFamily at hu + split_ifs at hu with hv + · exact False.elim (hu.2 hu.1) + · exact lt_of_not_ge (fun h => hu.2 (mem_filter.mpr ⟨hu.1,h⟩)) + +noncomputable def retainedIntervalLift (a : TupleVertex → ℕ) (L Q T : ℕ) (keep : Finset TupleVertex) + (f : TupleVertex → ℕ → ℝ) (v : TupleVertex) (x : ResidueSpace p) : ℝ := + ∑U∈retainedFamily p Q T keep v,intervalPiece p (a v) L (f v) U x + +lemma retainedInterval_diff (a : TupleVertex → ℕ) (L Q T : ℕ) (keep : Finset TupleVertex) + (f : TupleVertex → ℕ → ℝ) (v : TupleVertex) : + intervalLift p (a v) L Q (f v)-retainedIntervalLift p a L Q T keep f v= + fun x => ∑U∈liftSupportFamily p Q\retainedFamily p Q T keep v,intervalPiece p (a v) L (f v) U x := by + funext x + exact (eq_sub_iff_add_eq.mpr (sum_sdiff (retainedFamily_sub p Q T keep v))).symm + +lemma uniform_marginal_moment {V X : Type*} [Fintype V] [DecidableEq V] + [Nontrivial V] [Fintype X] (Llaw : ((V → X) → ℝ) →ₗ[ℝ] ℝ) + (hmar : ∀(v : V) (g : X → ℝ),Llaw (fun z => g (z v))=𝔼 x,g x) + (F : V → X → ℝ) (R : ℝ) + (hm : ∀v r,r+1=Fintype.card V → (𝔼 x,F v x^(2*r))≤R^(2*r)) + (v w : V) : + Llaw (fun z => |F w (z w)|^(2*Fintype.card {w : V // w≠v}))≤ + 1*R^(2*Fintype.card {w : V // w≠v}) := by + rw [hmar w (fun x => |F w x|^(2*Fintype.card {w : V // w≠v}))] + simp only [(even_two_mul _).pow_abs,one_mul] + apply hm + rw [Fintype.card_subtype_compl] + simp only [Fintype.card_unique] + exact Nat.sub_add_cancel (Nat.succ_le_of_lt Fintype.card_pos) + +lemma interval_tail_energy (hp : ∀j,max tupleMassThreshold tupleConditionalThreshold≤(p j:ℝ)) + (a : TupleVertex → ℕ) (L Q T : ℕ) (hT : 0 tupleGoodLaw (p:=p j))) (Equiv.funSplitAt v _)) + (intervalLift p (a v) L Q (f v)-retainedIntervalLift p a L Q T keep f v)≤ + (T:ℝ)^(-(1:ℝ)/32)*(1*R^2) := by + rw [retainedInterval_diff] + apply (tupleGoodTensor_conductor_energy p hp v _ + (intervalPiece p (a v) L (f v)) (fun U _ => intervalPiece_exactSupport p (a v) L (f v) U) + T (by exact_mod_cast hT) (fun U hU => by exact_mod_cast (retainedFamily_tail_den p Q T keep v U hU).le)).trans + simpa only [one_mul] using mul_le_mul_of_nonneg_left (hm v _ sdiff_subset) + (Real.rpow_nonneg (Nat.cast_nonneg T) (-(1:ℝ)/32)) + +lemma uniform_truncation_error {V X : Type*} [Fintype V] [DecidableEq V] + [Nontrivial V] [Fintype X] [Nonempty X] [DecidableEq X] + (Llaw : ((V → X) → ℝ) →ₗ[ℝ] ℝ) (hpos : ∀F,(∀z,0≤F z) → 0≤Llaw F) + (hmar : ∀(v : V) (g : X → ℝ),Llaw (fun z => g (z v))=𝔼 x,g x) + (F G : V → X → ℝ) (T R : ℝ) (hT : 0 ⟨uniform_marginal_moment Llaw hmar F R hmF v w, + uniform_marginal_moment Llaw hmar G R hmG v w⟩) + simpa only [mul_one] using hb + +lemma tensor_all_marginals {V : Type*} [Fintype V] [DecidableEq V] + (Llaw : ∀j,((V → ZMod (p j)) → ℝ) →ₗ[ℝ] ℝ) + (hm : ∀j (v : V) (g : ZMod (p j) → ℝ),Llaw j (fun z => g (z v))=𝔼 x,g x) : + ∀(v : V) (g : ResidueSpace p → ℝ),tensorLaw Llaw (fun z => g (z v))=𝔼 x,g x := by + exact fun v g => tensorLaw_marginal Llaw v (fun j => hm j v) g + +lemma tensorGood_uniform_marginal (hp : ∀j,max tupleMassThreshold tupleConditionalThreshold≤(p j:ℝ)) + (v : TupleVertex) (g : ResidueSpace p → ℝ) : + tensorLaw (fun j => tupleGoodLaw (p:=p j)) (fun z => g (z v))=𝔼 x,g x := by + exact tensor_all_marginals p (fun j => tupleGoodLaw (p:=p j)) + (fun j => tupleGoodLaw_marginal ((le_max_left _ _).trans (hp j))) v g + +lemma interval_full_moment (a : TupleVertex → ℕ) (L Q : ℕ) (f : TupleVertex → ℕ → ℝ) (R : ℝ) + (hm : ∀v s,s⊆liftSupportFamily p Q → ∀r,r=1 ∨ r+1=Fintype.card TupleVertex → + (𝔼 x,(∑U∈s,intervalPiece p (a v) L (f v) U x)^(2*r))≤R^(2*r)) : + ∀v r,r+1=Fintype.card TupleVertex → (𝔼 x,intervalLift p (a v) L Q (f v) x^(2*r))≤R^(2*r) := by + exact fun v r hr => hm v _ Subset.rfl r (Or.inr hr) + +lemma interval_retained_moment (a : TupleVertex → ℕ) (L Q T : ℕ) (keep : Finset TupleVertex) + (f : TupleVertex → ℕ → ℝ) (R : ℝ) + (hm : ∀v s,s⊆liftSupportFamily p Q → ∀r,r=1 ∨ r+1=Fintype.card TupleVertex → + (𝔼 x,(∑U∈s,intervalPiece p (a v) L (f v) U x)^(2*r))≤R^(2*r)) : + ∀v r,r+1=Fintype.card TupleVertex → + (𝔼 x,retainedIntervalLift p a L Q T keep f v x^(2*r))≤R^(2*r) := by + exact fun v r hr => hm v _ (retainedFamily_sub p Q T keep v) r (Or.inr hr) + +lemma interval_two_moment (a : TupleVertex → ℕ) (L Q : ℕ) (f : TupleVertex → ℕ → ℝ) (R : ℝ) + (hm : ∀v s,s⊆liftSupportFamily p Q → ∀r,r=1 ∨ r+1=Fintype.card TupleVertex → + (𝔼 x,(∑U∈s,intervalPiece p (a v) L (f v) U x)^(2*r))≤R^(2*r)) : + ∀v s,s⊆liftSupportFamily p Q → (𝔼 x,(∑U∈s,intervalPiece p (a v) L (f v) U x)^2)≤R^2 := by + exact fun v s hs => hm v s hs 1 (Or.inl rfl) + +lemma interval_truncation_error (hp : ∀j,max tupleMassThreshold tupleConditionalThreshold≤(p j:ℝ)) + (a : TupleVertex → ℕ) (L Q T : ℕ) (hT : 0 tupleGoodLaw (p:=p j))) (fun v => intervalLift p (a v) L Q (f v))- + multilinearIntegral (tensorLaw (fun j => tupleGoodLaw (p:=p j))) (retainedIntervalLift p a L Q T keep f)|≤ + (Fintype.card TupleVertex:ℝ)*(T:ℝ)^(-(1:ℝ)/64)*R^(Fintype.card TupleVertex) := by + exact uniform_truncation_error (tensorLaw (fun j => tupleGoodLaw (p:=p j))) + (tensorLaw_nonneg _ (fun _ => tupleGoodLaw_nonneg)) (tensorGood_uniform_marginal p hp) + _ _ _ _ (by exact_mod_cast hT) hR + (interval_tail_energy p hp a L Q T hT keep f R (interval_two_moment p a L Q f R hm)) + (interval_full_moment p a L Q f R hm) (interval_retained_moment p a L Q T keep f R hm) + +end Truncate + +end SquareDifference + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SquareDifference/LiftMoments.lean b/lean/OAI/Combinatorics/SquareDifference/LiftMoments.lean new file mode 100644 index 0000000000000000000000000000000000000000..a37c91d1683259dd2bd51789b09af9cf4d61eb90 --- /dev/null +++ b/lean/OAI/Combinatorics/SquareDifference/LiftMoments.lean @@ -0,0 +1,521 @@ +import OAI.Combinatorics.SquareDifference.DualCoordinates + +namespace OAI + +section +open Finset +open scoped ComplexConjugate BigOperators +open Filter +open scoped Topology +open Finset Complex +open scoped BigOperators ComplexConjugate + +namespace LiftTheory + +open Finset + +open scoped BigOperators InnerProductSpace ComplexConjugate + +namespace SquareDifference + +lemma sum_range_two (n : ℕ) (f : ℕ → ℝ) : + (∑ k∈range (2*n), f k)=∑ k∈range n, (f (2*k)+f (2*k+1)) := by + induction n with + | zero => simp + | succ n ih => + rw [show 2*(n+1)=2*n+1+1 by omega, sum_range_succ, sum_range_succ, + ih, sum_range_succ] + ring + +lemma choose_le_two_pow (n k : ℕ) : n.choose k ≤ 2^n := by + by_cases h : k ≤ n + · rw [← Nat.sum_range_choose] + exact single_le_sum (fun _ _ => Nat.zero_le _) (mem_range.mpr (by omega)) + · rw [Nat.choose_eq_zero_of_lt (by omega)] + exact Nat.zero_le _ + +lemma even_sum_binomial (r : ℕ) (a b : ℝ) : + ((a+b)^(2*r)+(a-b)^(2*r))/2 = + ∑ k∈range (r+1), (↑((2*r).choose (2*k)) : ℝ)*(a^2)^(r-k)*(b^2)^k := by + have he (x : ℝ) : (a+x)^(2*r) = + ∑ i∈range (2*(r+1)), a^(2*r-i)*x^i*↑((2*r).choose i) := by + rw [show 2*(r+1)=(2*r+1)+1 by omega, sum_range_succ] + simp only [Nat.choose_eq_zero_of_lt (by omega : 2*r < 2*r+1), Nat.cast_zero, + mul_zero, add_zero] + calc + _ = (x+a)^(2*r) := by rw [add_comm] + _ = _ := add_pow x a (2*r) + _ = _ := sum_congr rfl fun i _ => by ring + rw [sub_eq_add_neg, he b, he (-b), ← sum_add_distrib, sum_range_two] + rw [sum_div] + apply sum_congr rfl + intro k hk + have hodd : (-b)^(2*k+1) = -(b^(2*k+1)) := by + have hv : (-b)^(2*k)=b^(2*k) := by rw [pow_mul, pow_mul, neg_sq] + rw [pow_succ, pow_succ, hv] + ring + have heven : (-b)^(2*k)=b^(2*k) := by rw [pow_mul, pow_mul, neg_sq] + have hpow : a^(2*r-2*k)=(a^2)^(r-k) := by + rw [← pow_mul, Nat.mul_sub_left_distrib] + rw [heven, hodd, hpow, pow_mul b 2 k] + ring + +lemma two_point_moment (r : ℕ) (_hr : 1 ≤ r) (a b : ℝ) : + ((a+b)^(2*r)+(a-b)^(2*r))/2 ≤ (a^2+(2:ℝ)^(2*r)*b^2)^r := by + rw [even_sum_binomial] + rw [add_comm (a^2), add_pow] + apply sum_le_sum + intro k hk + have hkr : k ≤ r := by simpa only [mem_range, Nat.lt_succ_iff] using hk + have hcoef : (↑((2*r).choose (2*k)) : ℝ) ≤ (2:ℝ)^(2*r*k)*↑(r.choose k) := by + by_cases hz : k=0 + · simp [hz] + · have hk1 : 1 ≤ k := by omega + have hb : (↑((2*r).choose (2*k)) : ℝ) ≤ (2:ℝ)^(2*r) := by + exact_mod_cast choose_le_two_pow (2*r) (2*k) + have hc : (1:ℝ) ≤ ↑(r.choose k) := by exact_mod_cast Nat.choose_pos hkr + have hp : (2:ℝ)^(2*r) ≤ (2:ℝ)^(2*r*k) := by + apply pow_le_pow_right₀ (by norm_num) + nlinarith + exact hb.trans (hp.trans (le_mul_of_one_le_right (by positivity) hc)) + have ha2 := sq_nonneg a + have hb2 := sq_nonneg b + calc + _ ≤ ((2:ℝ)^(2*r*k)*↑(r.choose k))*(a^2)^(r-k)*(b^2)^k := by gcongr + _ = _ := by rw [mul_pow, ← pow_mul]; ring + +lemma expect_pow_zero {X : Type*} [Fintype X] (f : X → ℝ) + (hf : ∀ x, 0 ≤ f x) (r : ℕ) (_hr : 1 ≤ r) + (h : (𝔼 x, f x^r) ≤ 0) : ∀ x, f x=0 := by + have hz : (𝔼 x, f x^r)=0 := le_antisymm h (expect_nonneg (fun x _ => pow_nonneg (hf x) _)) + have hh := (expect_eq_zero_iff_of_nonneg (fun x _ => pow_nonneg (hf x) r)).mp hz + intro x + by_contra hne + exact pow_ne_zero r hne (hh x (mem_univ x)) + +lemma expect_add_pow_le {X : Type*} [Fintype X] [Nonempty X] + (f g : X → ℝ) (hf : ∀ x, 0 ≤ f x) (hg : ∀ x, 0 ≤ g x) + (r : ℕ) (hr : 1 ≤ r) (A B : ℝ) (hA : 0 ≤ A) (hB : 0 ≤ B) + (ha : (𝔼 x, f x^r) ≤ A^r) (hb : (𝔼 x, g x^r) ≤ B^r) : + (𝔼 x, (f x+g x)^r) ≤ (A+B)^r := by + by_cases hAz : A=0 + · have hz : ∀ x, f x=0 := expect_pow_zero f hf r hr (by rw [hAz, zero_pow (by omega : r≠0)] at ha; exact ha) + simpa only [hz, hAz, zero_add] using hb + by_cases hBz : B=0 + · have hz : ∀ x, g x=0 := expect_pow_zero g hg r hr (by rw [hBz, zero_pow (by omega : r≠0)] at hb; exact hb) + simpa only [hz, hBz, add_zero] using ha + have hAp : 0 < A := lt_of_le_of_ne hA (Ne.symm hAz) + have hBp : 0 < B := lt_of_le_of_ne hB (Ne.symm hBz) + have hAB : 0 < A+B := add_pos hAp hBp + have hpoint (x : X) : ((f x+g x)/(A+B))^r ≤ + (A/(A+B))*(f x/A)^r+(B/(A+B))*(g x/B)^r := by + have hc := (convexOn_pow (𝕜 := ℝ) r).2 + (show f x/A∈Set.Ici 0 from div_nonneg (hf x) hA) + (show g x/B∈Set.Ici 0 from div_nonneg (hg x) hB) + (show 0 ≤ A/(A+B) from by positivity) (show 0 ≤ B/(A+B) from by positivity) + (show A/(A+B)+B/(A+B)=1 from by field_simp) + simp only [smul_eq_mul] at hc + have he : A/(A+B)*(f x/A)+B/(A+B)*(g x/B)=(f x+g x)/(A+B) := by field_simp + rwa [he] at hc + have hmean : (𝔼 x, ((f x+g x)/(A+B))^r) ≤ 1 := by + calc + _ ≤ (𝔼 x, (A/(A+B)*(f x/A)^r+B/(A+B)*(g x/B)^r)) := + expect_le_expect fun x _ => hpoint x + _ = A/(A+B)*((𝔼 x, f x^r)/A^r)+B/(A+B)*((𝔼 x, g x^r)/B^r) := by + simp only [expect_add_distrib, div_pow] + simp only [div_eq_mul_inv, ← mul_expect, ← expect_mul] + _ ≤ A/(A+B)*(A^r/A^r)+B/(A+B)*(B^r/B^r) := by gcongr + _ = 1 := by rw [div_self (pow_ne_zero _ hAz), div_self (pow_ne_zero _ hBz)]; field_simp + have he : (𝔼 x, ((f x+g x)/(A+B))^r)=(𝔼 x, (f x+g x)^r)/(A+B)^r := by + simp only [div_pow] + simp only [div_eq_mul_inv, ← expect_mul] + rw [he] at hmean + exact (div_le_one (pow_pos hAB _)).mp hmean + +lemma expect_update_bool {J : Type*} [Fintype J] [DecidableEq J] + (j : J) (f : (J → Bool) → ℝ) : + (𝔼 x : J → Bool, 𝔼 t : Bool, f (Function.update x j t))=𝔼 x, f x := by + let e : ((J → Bool) × Bool) ≃ ((J → Bool) × Bool) := + { toFun := fun a => (Function.update a.1 j a.2, a.1 j) + invFun := fun a => (Function.update a.1 j a.2, a.1 j) + left_inv := by rintro ⟨x,t⟩; simp + right_inv := by rintro ⟨x,t⟩; simp } + have he := Fintype.expect_equiv e + (fun a : (J → Bool) × Bool => f (Function.update a.1 j a.2)) + (fun a : (J → Bool) × Bool => f a.1) (fun _ => rfl) + rw [← univ_product_univ, expect_product, expect_product] at he + simpa only [Fintype.expect_const] using he + +lemma expect_bool (f : Bool → ℝ) : (𝔼 b, f b)=(f true+f false)/2 := by + simp [expect_eq_sum_div_card] + +def boolSign (b : Bool) : ℝ := if b then 1 else -1 + +noncomputable def walsh {J : Type*} [DecidableEq J] (s : Finset J) + (c : Finset J → ℝ) (x : J → Bool) : ℝ := + ∑ U∈s.powerset, c U*∏ j∈U, boolSign (x j) + +noncomputable def walshEnergy {J : Type*} [DecidableEq J] (s : Finset J) + (C : ℝ) (c : Finset J → ℝ) : ℝ := ∑ U∈s.powerset, C^U.card*(c U)^2 + +lemma walsh_update {J : Type*} [DecidableEq J] (s : Finset J) (c : Finset J → ℝ) + (x : J → Bool) (j : J) (hj : j∉s) (t : Bool) : + walsh s c (Function.update x j t)=walsh s c x := by + apply sum_congr rfl + intro U hU + congr 1 + apply prod_congr rfl + intro k hk + rw [Function.update_of_ne] + intro h + subst k + exact hj ((mem_powerset.mp hU) hk) + +lemma walsh_insert {J : Type*} [DecidableEq J] (s : Finset J) (c : Finset J → ℝ) + (x : J → Bool) (j : J) (hj : j∉s) : + walsh (insert j s) c x=walsh s c x+boolSign (x j)*walsh s (fun U => c (insert j U)) x := by + unfold walsh + rw [sum_powerset_insert hj, mul_sum] + congr 1 + apply sum_congr rfl + intro U hU + have hjU : j∉U := fun h => hj ((mem_powerset.mp hU) h) + rw [prod_insert hjU] + ring + +lemma walshEnergy_insert {J : Type*} [DecidableEq J] (s : Finset J) + (C : ℝ) (c : Finset J → ℝ) (j : J) (hj : j∉s) : + walshEnergy (insert j s) C c=walshEnergy s C c+C*walshEnergy s C (fun U => c (insert j U)) := by + unfold walshEnergy + rw [sum_powerset_insert hj, mul_sum] + congr 1 + apply sum_congr rfl + intro U hU + have hjU : j∉U := fun h => hj ((mem_powerset.mp hU) h) + rw [card_insert_of_notMem hjU, pow_succ] + ring + +lemma walshEnergy_nonneg {J : Type*} [DecidableEq J] (s : Finset J) + (C : ℝ) (hC : 0 ≤ C) (c : Finset J → ℝ) : 0 ≤ walshEnergy s C c := + sum_nonneg fun _ _ => mul_nonneg (pow_nonneg hC _) (sq_nonneg _) + +lemma walsh_hypercontractivity {J : Type*} [Fintype J] [DecidableEq J] + (s : Finset J) (c : Finset J → ℝ) (r : ℕ) (hr : 1 ≤ r) : + (𝔼 x : J → Bool, (walsh s c x)^(2*r)) ≤ (walshEnergy s ((2:ℝ)^(2*r)) c)^r := by + induction s using Finset.induction_on generalizing c with + | empty => simp [walsh, walshEnergy, pow_mul] + | @insert j s hj ih => + let C : ℝ := (2:ℝ)^(2*r) + let a := walsh s c + let b := walsh s (fun U => c (insert j U)) + let A := walshEnergy s C c + let B := walshEnergy s C (fun U => c (insert j U)) + have hC : 0 ≤ C := by positivity + have hA : 0 ≤ A := walshEnergy_nonneg _ _ hC _ + have hB : 0 ≤ B := walshEnergy_nonneg _ _ hC _ + have ha : (𝔼 x, (a x^2)^r) ≤ A^r := by + simpa only [a, A, C, ← pow_mul] using ih c + have hb : (𝔼 x, (C*b x^2)^r) ≤ (C*B)^r := by + simp only [mul_pow, ← mul_expect] + exact mul_le_mul_of_nonneg_left (by simpa only [b, B, C, ← pow_mul] using ih (fun U => c (insert j U))) (by positivity) + have hm := expect_add_pow_le (fun x => a x^2) (fun x => C*b x^2) + (fun x => sq_nonneg _) (fun x => mul_nonneg hC (sq_nonneg _)) r hr A (C*B) + hA (mul_nonneg hC hB) ha hb + rw [walshEnergy_insert s _ c j hj] + change _ ≤ (A+C*B)^r + apply le_trans _ hm + rw [← expect_update_bool j] + apply expect_le_expect + intro x _ + rw [expect_bool] + simp only [walsh_insert s c _ j hj, walsh_update s c x j hj, + walsh_update s (fun U => c (insert j U)) x j hj, Function.update_self] + simp only [boolSign, Bool.false_eq_true, ite_false, ite_true, one_mul, neg_one_mul] + simp only [← sub_eq_add_neg] + exact two_point_moment r hr (a x) (b x) + +lemma expect_update_dep {J : Type*} [Fintype J] [DecidableEq J] + {X : J → Type*} [∀ j, Fintype (X j)] [∀ j, Nonempty (X j)] + (j : J) (f : (∀ j, X j) → ℝ) : + (𝔼 x : ∀ j, X j, 𝔼 t : X j, f (Function.update x j t))=𝔼 x, f x := by + let e : ((∀ j, X j) × X j) ≃ ((∀ j, X j) × X j) := + { toFun := fun a => (Function.update a.1 j a.2, a.1 j) + invFun := fun a => (Function.update a.1 j a.2, a.1 j) + left_inv := by rintro ⟨x,t⟩; simp + right_inv := by rintro ⟨x,t⟩; simp } + have he := Fintype.expect_equiv e + (fun a : (∀ j, X j) × X j => f (Function.update a.1 j a.2)) + (fun a : (∀ j, X j) × X j => f a.1) (fun _ => rfl) + rw [← univ_product_univ, expect_product, expect_product] at he + simpa only [Fintype.expect_const] using he + +def patch {J : Type*} [DecidableEq J] {X : J → Type*} + (s : Finset J) (x y : ∀ j, X j) (j : J) : X j := if j∈s then y j else x j + +lemma patch_empty {J : Type*} [DecidableEq J] {X : J → Type*} (x y : ∀ j, X j) : + patch ∅ x y=x := by ext j; simp [patch] + +lemma patch_univ {J : Type*} [Fintype J] [DecidableEq J] + {X : J → Type*} (x y : ∀ j, X j) : patch univ x y=y := by ext j; simp [patch] + +lemma patch_insert_update {J : Type*} [DecidableEq J] {X : J → Type*} + (s : Finset J) (j : J) (_hj : j∉s) (x y : ∀ j, X j) (t : X j) : + patch (insert j s) x (Function.update y j t)=Function.update (patch s x y) j t := by + ext k + by_cases hk : k=j + · subst k; simp [patch] + · simp [patch, hk] + +def ExactSupport {J : Type*} [DecidableEq J] + {X : J → Type*} [∀ j, Fintype (X j)] (U : Finset J) + (f : (∀ j, X j) → ℝ) : Prop := + (∀ j∈U, ∀ x, (𝔼 t : X j, f (Function.update x j t))=0) ∧ + (∀ j∉U, ∀ x t, f (Function.update x j t)=f x) + +lemma expect_pow_le {X : Type*} [Fintype X] [Nonempty X] + (f : X → ℝ) (hf : ∀ x, 0 ≤ f x) (r : ℕ) : + (𝔼 x, f x)^r ≤ 𝔼 x, f x^r := by + have hn : (Fintype.card X : ℝ) ≠ 0 := Nat.cast_ne_zero.mpr Fintype.card_ne_zero + have hh := (convexOn_pow (𝕜 := ℝ) r).map_sum_le + (t := univ) (w := fun _ : X => (Fintype.card X : ℝ)⁻¹) + (p := f) (fun _ _ => by positivity) + (by simp [hn]) (fun x _ => hf x) + simpa only [smul_eq_mul, ← mul_sum, expect_eq_sum_div_card, card_univ, + div_eq_inv_mul] using hh + +lemma expect_even_pow_le {X : Type*} [Fintype X] [Nonempty X] + (f : X → ℝ) (r : ℕ) : (𝔼 x, f x)^(2*r) ≤ 𝔼 x, (f x)^(2*r) := by + have hc := expect_mul_sq_le_sq_mul_sq univ f (fun _ => (1:ℝ)) + simp only [mul_one, one_pow, Fintype.expect_const] at hc + rw [pow_mul] + apply (pow_le_pow_left₀ (sq_nonneg _) hc r).trans + simpa only [← pow_mul] using expect_pow_le (fun x => f x^2) (fun x => sq_nonneg _) r + +lemma exactSupport_congr {J : Type*} [Fintype J] [DecidableEq J] + {X : J → Type*} [∀ j, Fintype (X j)] (U : Finset J) + (f : (∀ j, X j) → ℝ) (hf : ExactSupport U f) + (x y : ∀ j, X j) (hxy : ∀ j∈U, x j=y j) : f x=f y := by + have hh (s : Finset J) : f (patch s x y)=f x := by + induction s using Finset.induction_on with + | empty => rw [patch_empty] + | @insert j s hj ih => + have he : patch (insert j s) x y=Function.update (patch s x y) j (y j) := by + ext a; by_cases ha : a=j + · subst a; simp [patch] + · simp [patch, ha] + rw [he] + by_cases hjU : j∈U + · have hxj : (patch s x y) j = y j := by simp [patch, hj, hxy j hjU] + rw [← hxj, Function.update_eq_self, ih] + · rw [hf.2 j hjU, ih] + simpa only [patch_univ] using (hh univ).symm + +def hybrid {J : Type*} {X : J → Type*} (b : J → Bool) (x y : ∀j, X j) (j : J) : X j := + if b j then x j else y j + +def boolMul (a b : Bool) : Bool := if a then b else !b + +lemma boolMul_symm (a b : Bool) : boolMul a b=boolMul b a := by cases a <;> cases b <;> rfl + +lemma boolMul_self (a b : Bool) : boolMul a (boolMul a b)=b := by cases a <;> cases b <;> rfl + +lemma boolSign_mul (a b : Bool) : boolSign (boolMul a b)=boolSign a*boolSign b := by + cases a <;> cases b <;> norm_num [boolMul, boolSign] + +lemma hybrid_hybrid {J : Type*} {X : J → Type*} (b e : J → Bool) (x y : ∀j, X j) : + hybrid b (hybrid e x y) (hybrid e y x)=hybrid (fun j => boolMul (e j) (b j)) x y := by + ext j + cases hb : b j <;> cases he : e j <;> simp [hybrid, boolMul, hb, he] + +def copySwapEquiv {J : Type*} {X : J → Type*} (e : J → Bool) : + ((∀j, X j) × (∀j, X j)) ≃ ((∀j, X j) × (∀j, X j)) where + toFun a := (hybrid e a.1 a.2, hybrid e a.2 a.1) + invFun a := (hybrid e a.1 a.2, hybrid e a.2 a.1) + left_inv a := by + apply Prod.ext <;> funext j <;> cases he : e j <;> simp [hybrid, he] + right_inv a := by + apply Prod.ext <;> funext j <;> cases he : e j <;> simp [hybrid, he] + +lemma expect_copySwap {J : Type*} [Fintype J] [DecidableEq J] {X : J → Type*} [∀j, Fintype (X j)] + (e : J → Bool) (F : (∀j, X j) → (∀j, X j) → ℝ) : + (𝔼 x, 𝔼 y, F (hybrid e x y) (hybrid e y x))=𝔼 x, 𝔼 y, F x y := by + have hh := Fintype.expect_equiv (copySwapEquiv (X:=X) e) + (fun a => F (hybrid e a.1 a.2) (hybrid e a.2 a.1)) + (fun a => F a.1 a.2) (fun _ => rfl) + simpa only [← univ_product_univ, expect_product] using hh + +lemma expect_hybrid {J : Type*} [Fintype J] [DecidableEq J] {X : J → Type*} + [∀j, Fintype (X j)] [∀j, Nonempty (X j)] + (e : J → Bool) (F : (∀j, X j) → ℝ) : + (𝔼 x, 𝔼 y, F (hybrid e x y))=𝔼 x, F x := by + simpa only [Fintype.expect_const] using expect_copySwap e (fun x _ => F x) + +def boolMulEquiv {J : Type*} (e : J → Bool) : (J → Bool) ≃ (J → Bool) where + toFun b j := boolMul (e j) (b j) + invFun b j := boolMul (e j) (b j) + left_inv b := by funext j; exact boolMul_self _ _ + right_inv b := by funext j; exact boolMul_self _ _ + +noncomputable def boolChar {J : Type*} (U : Finset J) (b : J → Bool) : ℝ := + ∏ j∈U, boolSign (b j) + +lemma boolChar_mul {J : Type*} (U : Finset J) (e b : J → Bool) : + boolChar U (fun j => boolMul (e j) (b j))=boolChar U e*boolChar U b := by + simp only [boolChar, boolSign_mul, prod_mul_distrib] + +lemma boolChar_sq {J : Type*} (U : Finset J) (b : J → Bool) : boolChar U b^2=1 := by + have he j : boolSign (b j)^2=1 := by cases hb : b j <;> norm_num [boolSign, hb] + simp only [boolChar, ← prod_pow, he, prod_const_one] + +lemma exactSupport_hybrid_expect {J : Type*} [Fintype J] [DecidableEq J] + {X : J → Type*} [∀j, Fintype (X j)] [∀j, Nonempty (X j)] + (U : Finset J) (f : (∀j, X j) → ℝ) (hf : ExactSupport U f) + (x : ∀j, X j) (b : J → Bool) : + (𝔼 y, f (hybrid b x y))=(if ∀ j∈U, b j=true then 1 else (0:ℝ))*f x := by + classical + by_cases hb : ∀j∈U, b j=true + · rw [ite_eq_left hb, one_mul] + have he y : f (hybrid b x y)=f x := exactSupport_congr U f hf _ _ + (fun j hj => by simp [hybrid, hb j hj]) + simp only [he, Fintype.expect_const] + · rw [ite_eq_right hb, zero_mul] + push Not at hb + obtain ⟨j,hj,hb⟩ := hb + have hfalse : b j=false := by cases h : b j <;> simp_all + rw [← expect_update_dep j] + have he (y : ∀j, X j) (t : X j) : + hybrid b x (Function.update y j t)=Function.update (hybrid b x y) j t := by + ext a + by_cases ha : a=j + · subst a; simp [hybrid, hfalse] + · simp [hybrid, Function.update_of_ne ha] + simp only [he, hf.1 j hj, Fintype.expect_const] + +lemma expect_prod_pi {J : Type*} [Fintype J] [DecidableEq J] + {X : J → Type*} [∀ j, Fintype (X j)] (f : ∀ j, X j → ℝ) : + (𝔼 x : ∀ j, X j, ∏ j, f j (x j))=∏ j, (𝔼 t : X j, f j t) := by + simp only [expect_eq_sum_div_card, card_univ, prod_div_distrib, + Fintype.card_pi, Nat.cast_prod] + rw [Fintype.prod_sum] + +lemma expect_prod_pi_finset {J : Type*} [Fintype J] [DecidableEq J] + {X : J → Type*} [∀ j, Fintype (X j)] [∀j, Nonempty (X j)] + (U : Finset J) (f : ∀ j, X j → ℝ) : + (𝔼 x : ∀j, X j, ∏ j∈U, f j (x j))=∏ j∈U, (𝔼 t : X j, f j t) := by + have he := expect_prod_pi (fun j (t : X j) => if j∈U then f j t else 1) + simp only [prod_ite_mem, univ_inter] at he + have hp j : (𝔼 t : X j, if j∈U then f j t else 1)= + if j∈U then (𝔼 t : X j, f j t) else 1 := by + by_cases hj : j∈U <;> simp [hj] + simpa only [hp, prod_ite_mem, univ_inter] using he + +lemma bool_indicator_char {J : Type*} [Fintype J] [DecidableEq J] + (U : Finset J) : + (𝔼 b : J → Bool, (if ∀j∈U, b j=true then 1 else (0:ℝ))*boolChar U b)=(1/2:ℝ)^U.card := by + classical + have he (b : J → Bool) : + (if ∀j∈U, b j=true then 1 else (0:ℝ))*boolChar U b= + ∏j∈U, (if b j then (1:ℝ) else 0) := by + by_cases hb : ∀j∈U, b j=true + · simp only [ite_eq_left hb, one_mul, boolChar] + apply prod_congr rfl + intro j hj + simp [hb j hj, boolSign] + · rw [ite_eq_right hb, zero_mul] + push Not at hb + obtain ⟨j,hj,hb⟩ := hb + symm + apply prod_eq_zero hj + cases h : b j <;> simp_all + simp only [he] + rw [expect_prod_pi_finset U (fun _ (b : Bool) => if b then (1:ℝ) else 0)] + simp + +noncomputable def copyDifference {J : Type*} [Fintype J] [DecidableEq J] (U : Finset J) + {X : J → Type*} (f : (∀j, X j) → ℝ) (x y : ∀j, X j) : ℝ := + (2:ℝ)^U.card*(𝔼 b : J → Bool, f (hybrid b x y)*boolChar U b) + +lemma copyDifference_mean {J : Type*} [Fintype J] [DecidableEq J] + {X : J → Type*} [∀j, Fintype (X j)] [∀j, Nonempty (X j)] + (U : Finset J) (f : (∀j, X j) → ℝ) (hf : ExactSupport U f) (x : ∀j, X j) : + (𝔼 y, copyDifference U f x y)=f x := by + unfold copyDifference + rw [← mul_expect, expect_comm] + simp only [← expect_mul, exactSupport_hybrid_expect U f hf] + have he b : (if ∀j∈U, b j=true then 1 else (0:ℝ))*f x*boolChar U b= + ((if ∀j∈U, b j=true then 1 else (0:ℝ))*boolChar U b)*f x := by ring + simp only [he, ← expect_mul, bool_indicator_char] + rw [← mul_assoc, ← mul_pow] + norm_num + +lemma copyDifference_swap {J : Type*} [Fintype J] [DecidableEq J] {X : J → Type*} + (U : Finset J) (f : (∀j, X j) → ℝ) (x y : ∀j, X j) (e : J → Bool) : + copyDifference U f (hybrid e x y) (hybrid e y x)=boolChar U e*copyDifference U f x y := by + unfold copyDifference + simp only [hybrid_hybrid] + have he := Fintype.expect_equiv (boolMulEquiv e) + (fun b => f (hybrid (fun j => boolMul (e j) (b j)) x y)*boolChar U b) + (fun b => f (hybrid b x y)*boolChar U (fun j => boolMul (e j) (b j))) + (fun b => by simp only [boolMulEquiv, Equiv.coe_fn_mk, boolMul_self]) + rw [he] + simp only [boolChar_mul, ← mul_left_comm (boolChar U e), ← mul_expect] + +lemma copyDifference_square {J : Type*} [Fintype J] [DecidableEq J] {X : J → Type*} + (U : Finset J) (f : (∀j, X j) → ℝ) (x y : ∀j, X j) : + (copyDifference U f x y)^2 ≤ (4:ℝ)^U.card*(𝔼 b : J → Bool, f (hybrid b x y)^2) := by + have hc := expect_mul_sq_le_sq_mul_sq univ (fun b => f (hybrid b x y)) (boolChar U) + simp only [boolChar_sq, Fintype.expect_const, mul_one] at hc + unfold copyDifference + rw [mul_pow, pow_right_comm, show (2:ℝ)^2=4 by norm_num] + exact mul_le_mul_of_nonneg_left hc (by positivity) + +lemma sum_powerset_family {J : Type*} [Fintype J] [DecidableEq J] + (F : Finset (Finset J)) (a : Finset J → ℝ) : + (∑U∈(univ : Finset J).powerset, if U∈F then a U else 0)=∑U∈F, a U := by + classical + symm + calc + _ = ∑U∈F, if U∈F then a U else 0 := by + apply sum_congr rfl; intro U hU; rw [ite_eq_left hU] + _ = _ := sum_subset (fun U _ => mem_powerset.mpr (subset_univ U)) + (fun U _ hU => ite_eq_right hU) + +lemma walsh_family {J : Type*} [Fintype J] [DecidableEq J] + (F : Finset (Finset J)) (a : Finset J → ℝ) (e : J → Bool) : + walsh univ (fun U => if U∈F then a U else 0) e=∑U∈F, a U*boolChar U e := by + unfold walsh boolChar + simp only [ite_mul, zero_mul] + exact sum_powerset_family _ _ + +lemma walshEnergy_family {J : Type*} [Fintype J] [DecidableEq J] + (F : Finset (Finset J)) (a : Finset J → ℝ) (C : ℝ) : + walshEnergy univ C (fun U => if U∈F then a U else 0)=∑U∈F, C^U.card*(a U)^2 := by + unfold walshEnergy + simp only [ite_pow, zero_pow (by omega : (2:ℕ)≠0), mul_ite, mul_zero] + exact sum_powerset_family _ _ + +lemma difference_energy_bound {J : Type*} [Fintype J] [DecidableEq J] + {X : J → Type*} (F : Finset (Finset J)) (f : Finset J → (∀j, X j) → ℝ) + (k : ℕ) (hk : ∀U∈F, U.card ≤ k) (C : ℝ) (hC : 1 ≤ C) (x y : ∀j, X j) : + walshEnergy univ C (fun U => if U∈F then copyDifference U (f U) x y else 0) ≤ + (4*C)^k*(𝔼 e : J → Bool, ∑U∈F, f U (hybrid e x y)^2) := by + rw [walshEnergy_family] + calc + _ ≤ ∑U∈F, (4*C)^k*(𝔼 e : J → Bool, f U (hybrid e x y)^2) := by + apply sum_le_sum + intro U hU + calc + _ ≤ C^U.card*((4:ℝ)^U.card*(𝔼 e : J → Bool, f U (hybrid e x y)^2)) := + mul_le_mul_of_nonneg_left (copyDifference_square U (f U) x y) (by positivity) + _ = (4*C)^U.card*(𝔼 e : J → Bool, f U (hybrid e x y)^2) := by + rw [mul_pow]; ring + _ ≤ _ := mul_le_mul_of_nonneg_right + (pow_le_pow_right₀ (by linarith : 1 ≤ 4*C) (hk U hU)) + (expect_nonneg fun _ _ => sq_nonneg _) + _ = _ := by rw [← mul_sum, expect_sum_comm] + +end SquareDifference +end LiftTheory +end + +end OAI diff --git a/lean/OAI/Combinatorics/SquareDifference/LocalizedPair.lean b/lean/OAI/Combinatorics/SquareDifference/LocalizedPair.lean new file mode 100644 index 0000000000000000000000000000000000000000..20467f669867078f9122b99ad4789554f4fee441 --- /dev/null +++ b/lean/OAI/Combinatorics/SquareDifference/LocalizedPair.lean @@ -0,0 +1,90 @@ +import OAI.Combinatorics.SquareDifference.TensorPair + +namespace OAI + +section + +open Finset + +open scoped BigOperators + +namespace SquareDifference + +lemma positiveLaw_density_nonneg {Ω : Type*} [Fintype Ω] [DecidableEq Ω] + (L : (Ω → ℝ) →ₗ[ℝ] ℝ) (hL : ∀F,(∀z,0≤F z) → 0≤L F) (z : Ω) : + 0≤lawDensity L z := hL _ (fun x => by split_ifs <;> norm_num) + +lemma positiveLaw_bound_on_support {Ω : Type*} [Fintype Ω] [DecidableEq Ω] + (L : (Ω → ℝ) →ₗ[ℝ] ℝ) (hL : ∀F,(∀z,0≤F z) → 0≤L F) + (F : Ω → ℝ) (C : ℝ) (hF : ∀z,lawDensity L z≠0 → |F z|≤C) : + |L F|≤C*L (fun _ => 1) := by + rw [linearFunctional_density L F,linearFunctional_density L (fun _ => 1)] + calc + _ ≤ ∑z,|lawDensity L z*F z| := abs_sum_le_sum_abs _ _ + _ ≤ ∑z,lawDensity L z*C := by + apply sum_le_sum + intro z _ + by_cases hz : lawDensity L z=0 + · simp only [hz,zero_mul,abs_zero,le_refl] + · rw [abs_mul,abs_of_nonneg (positiveLaw_density_nonneg L hL z)] + exact mul_le_mul_of_nonneg_left (hF z hz) (positiveLaw_density_nonneg L hL z) + _ = _ := by simp only [mul_one,mul_sum,lawDensity]; apply sum_congr rfl; intros; ring + +lemma positiveLaw_density_pair_support {Ω A : Type*} [Fintype Ω] [DecidableEq Ω] + (L : (Ω → ℝ) →ₗ[ℝ] ℝ) (hL : ∀F,(∀z,0≤F z) → 0≤L F) + (T : Ω → A) (P : A → Prop) [DecidablePred P] + (hP : L (fun x => if P (T x) then 0 else 1)=0) + (z : Ω) (hz : lawDensity L z≠0) : P (T z) := by + by_contra hn + have hle : lawDensity L z≤L (fun x => if P (T x) then 0 else 1) := by + apply positiveLaw_mono L hL + intro x + by_cases hx : x=z + · subst x; simp only [ite_true,hn,ite_false,le_refl] + · simp only [hx,ite_false]; split_ifs <;> norm_num + rw [hP] at hle + exact hz (le_antisymm hle (positiveLaw_density_nonneg L hL z)) + +section Localized + +variable {J V : Type*} [Fintype J] [DecidableEq J] [Fintype V] [DecidableEq V] + {X : J → Type*} [∀j,Fintype (X j)] [∀j,DecidableEq (X j)] + (L : ∀j,((V → X j) → ℝ) →ₗ[ℝ] ℝ) + (hL : ∀j F,(∀z,0≤F z) → 0≤L j F) (hm : ∀j,L j (fun _ => 1)=1) + +include hL hm in +lemma tensorLaw_localized_pair (B : Finset J) (W : (V → ∀j,X j) → ℝ) + (F G : (∀j,X j) → ℝ) (u v : V) (C E : ℝ) (hC : 0≤C) (_ : 0≤E) + (hW : ∀(z x : V → ∀j,X j),W (fun v j => if j∈B then z v j else x v j)=W z) + (hWC : ∀z,|W z|≤C) + (hpair : ∀z,lawDensity (tensorLaw L) z≠0 → + |tensorLaw L (fun x => F (fun j => if j∈B then z u j else x u j)* + G (fun j => if j∈B then z v j else x v j))|≤E) : + |tensorLaw L (fun z => W z*F (z u)*G (z v))|≤C*E := by + rw [←tensorLaw_freeze L L B hm (fun _ _ => rfl)] + have hh (z : V → ∀j,X j) : + tensorLaw L (fun x => W (fun v j => if j∈B then z v j else x v j)* + F (fun j => if j∈B then z u j else x u j)*G (fun j => if j∈B then z v j else x v j))= + W z*tensorLaw L (fun x => F (fun j => if j∈B then z u j else x u j)* + G (fun j => if j∈B then z v j else x v j)) := by + simp_rw [hW,mul_assoc] + exact (tensorLaw L).map_smul (W z) _ + simp_rw [hh] + have hpos := tensorLaw_nonneg L hL + have hmass : tensorLaw L (fun _ => 1)=1 := by + simpa only [prod_const_one,hm] using tensorLaw_fubini L (fun _ _ => (1:ℝ)) + have hb := positiveLaw_bound_on_support (tensorLaw L) hpos + (fun z => W z*tensorLaw L (fun x => F (fun j => if j∈B then z u j else x u j)* + G (fun j => if j∈B then z v j else x v j))) (C*E) (by + intro z hz + rw [abs_mul] + exact mul_le_mul (hWC z) (hpair z hz) (abs_nonneg _) hC) + simpa only [hmass,mul_one] using hb + +end Localized + +end SquareDifference + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SquareDifference/LowProduct.lean b/lean/OAI/Combinatorics/SquareDifference/LowProduct.lean new file mode 100644 index 0000000000000000000000000000000000000000..99069f0ef493732a5ada87047da1be4c027788e8 --- /dev/null +++ b/lean/OAI/Combinatorics/SquareDifference/LowProduct.lean @@ -0,0 +1,95 @@ +import OAI.Combinatorics.SquareDifference.ActualIntervalPair + +namespace OAI + +section + +open Finset + +open scoped BigOperators + +namespace SquareDifference + +open LiftTheory.SquareDifference + +section GenericLow + +variable {J V : Type*} [Fintype J] [DecidableEq J] [Fintype V] [DecidableEq V] + (p : J → ℕ) [∀j,Fact (p j).Prime] + +lemma interval_low_product_bound (hinj : Function.Injective p) + (Llaw : ∀j,((V → ZMod (p j)) → ℝ) →ₗ[ℝ] ℝ) + (hpos : ∀j F,(∀z,0≤F z) → 0≤Llaw j F) (hmass : ∀j,Llaw j (fun _ => 1)=1) + (u v : V) (huv : u≠v) (a : V → ℕ) (L : ℕ) (f : V → ℕ → ℝ) + (M : ℝ) (hM : 0≤M) (hf : ∀v n,|f v n|≤M) (T : ℕ) + (s : Finset (Finset J)) (hcard : s.card≤T) (hs : ∀U∈s,∏j∈U,p j≤T) + (F G : ResidueSpace p → ℝ) (E : ℝ) (hE : 0≤E) + (hpair : ∀(B : Finset J),(∏j∈B,p j)≤T^(Fintype.card (OtherVertices u v)) → + ∀z,lawDensity (tensorLaw Llaw) z≠0 → + |tensorLaw Llaw (fun x => F (freezeCoordinates B (z u) (x u))* + G (freezeCoordinates B (z v) (x v)))|≤E) : + |multilinearIntegral (tensorLaw Llaw) (fun w => if w=u then F else if w=v then G else + fun x => ∑U∈s,intervalPiece p (a w) L (f w) U x)|≤ + (M*(T:ℝ)^2)^(Fintype.card (OtherVertices u v))*E := by + classical + have he := multilinear_pair_expand (tensorLaw Llaw) u v huv F G + (fun w (U : s) => intervalPiece p (a w.val) L (f w.val) U.val) + simp only [dite_eq_ite] at he + have hsum (w : V) (x : ResidueSpace p) : + (∑U : s,intervalPiece p (a w) L (f w) U.val x)=∑U∈s,intervalPiece p (a w) L (f w) U x := + sum_coe_sort s (fun U => intervalPiece p (a w) L (f w) U x) + simp_rw [hsum] at he + rw [he] + apply (abs_sum_le_sum_abs _ _).trans + have ht : 0≤(M*T)^(Fintype.card (OtherVertices u v))*E := mul_nonneg (pow_nonneg (mul_nonneg hM (Nat.cast_nonneg T)) _) hE + calc + _ ≤ ∑U : OtherVertices u v → s,(M*T)^(Fintype.card (OtherVertices u v))*E := by + apply sum_le_sum + intro U _ + have hb := interval_piece_product_bound p hinj Llaw hpos hmass u v a L f M hM hf T + (fun w => (U w).val) (fun w => hs _ (U w).property) F G E hE hpair + simpa only [mul_assoc,mul_left_comm,mul_comm] using hb + _ = (s.card:ℝ)^(Fintype.card (OtherVertices u v))*((M*T)^(Fintype.card (OtherVertices u v))*E) := by + rw [sum_const,card_univ,Fintype.card_fun,Fintype.card_coe,nsmul_eq_mul,Nat.cast_pow] + _ ≤ (T:ℝ)^(Fintype.card (OtherVertices u v))*((M*T)^(Fintype.card (OtherVertices u v))*E) := by + apply mul_le_mul_of_nonneg_right _ ht + exact pow_le_pow_left₀ (Nat.cast_nonneg _) (by exact_mod_cast hcard) _ + _ = _ := by rw [←mul_assoc,←mul_pow]; congr 2; ring + +end GenericLow + +section Retained + +variable {J : Type*} [Fintype J] [DecidableEq J] (p : J → ℕ) [instFactNatPrimepj : ∀j,Fact (p j).Prime] + +lemma retainedInterval_pair {J : Type*} + [Fintype J] + [DecidableEq J] + (p : J → ℕ) + [∀ (j : J), Fact (Nat.Prime (p j))] (a : TupleVertex → ℕ) (L Q T : ℕ) + (u v : TupleVertex) (_ : u≠v) (f : TupleVertex → ℕ → ℝ) (w : TupleVertex) : + retainedIntervalLift p a L Q T {u,v} f w = + if w=u then intervalLift p (a u) L Q (f u) else + if w=v then intervalLift p (a v) L Q (f v) else + fun x => ∑U∈(liftSupportFamily p Q).filter (fun U => ∏j∈U,p j≤T),intervalPiece p (a w) L (f w) U x := by + funext x + by_cases hwu : w=u + · subst w; simp only [retainedIntervalLift,retainedFamily,mem_insert,mem_singleton,true_or,ite_true,intervalLift] + by_cases hwv : w=v + · subst w; simp only [retainedIntervalLift,retainedFamily,mem_insert,mem_singleton,or_true,ite_true,hwu,ite_false,intervalLift] + · simp only [retainedIntervalLift,retainedFamily,mem_insert,mem_singleton,hwu,hwv,false_or,ite_false] + +lemma filteredFamily_card (hinj : Function.Injective p) (Q T : ℕ) : + ((liftSupportFamily p Q).filter (fun U => ∏j∈U,p j≤T)).card≤T := by + apply (card_le_card (show (liftSupportFamily p Q).filter (fun U => ∏j∈U,p j≤T)⊆liftSupportFamily p T from ?_)).trans + · exact liftSupportFamily_card_le p hinj T + · intro U hU + exact mem_filter.mpr ⟨mem_univ _,(mem_filter.mp hU).2⟩ + +end Retained + +end SquareDifference + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SquareDifference/Main.lean b/lean/OAI/Combinatorics/SquareDifference/Main.lean new file mode 100644 index 0000000000000000000000000000000000000000..0a201cdd58d5cd708528eccc7d0093bbd9483505 --- /dev/null +++ b/lean/OAI/Combinatorics/SquareDifference/Main.lean @@ -0,0 +1,97 @@ +import OAI.Combinatorics.SquareDifference.UniformInduction + +namespace OAI + +section + +open Finset + +namespace SquareDifference + +lemma density_root_bound (d N : ℕ) (hd : 0 (z-1).toNat) + +lemma natTranslate_sub (N : ℕ) (A : Finset ℤ) (hA : A⊆Icc 1 (N:ℤ)) : natTranslate A⊆range N := by + intro n hn + obtain ⟨z,hz,rfl⟩ := mem_image.mp hn + have hz' := mem_Icc.mp (hA hz) + rw [mem_range] + omega + +lemma natTranslate_card (N : ℕ) (A : Finset ℤ) (hA : A⊆Icc 1 (N:ℤ)) : (natTranslate A).card=A.card := by + apply card_image_iff.mpr + intro z hz w hw he + change (z-1).toNat=(w-1).toNat at he + have hz' := (mem_Icc.mp (hA hz)).1 + have hw' := (mem_Icc.mp (hA hw)).1 + omega + +lemma natTranslate_free (N : ℕ) (A : Finset ℤ) (hA : A⊆Icc 1 (N:ℤ)) (hf : IsSquareDifferenceFree A) : + NatSquareFree (natTranslate A) := by + intro a ha b hb m hm he + obtain ⟨z,hz,rfl⟩ := mem_image.mp ha + obtain ⟨w,hw,rfl⟩ := mem_image.mp hb + apply hf w hw z hz m hm + have hz' := (mem_Icc.mp (hA hz)).1 + have hw' := (mem_Icc.mp (hA hw)).1 + have he' := congrArg (fun n : ℕ => (n:ℤ)) he + push_cast at he' + omega + +theorem power_saving : + ∃ c C : ℝ, 0 < c ∧ ∀ N : ℕ, 1 ≤ N → ∀ A : Finset ℤ, + A ⊆ Finset.Icc 1 (N : ℤ) → IsSquareDifferenceFree A → + (A.card : ℝ) ≤ C * (N : ℝ) ^ (1 - c) := by + obtain ⟨c,C,hc,h⟩ := nat_power_saving + refine ⟨c,C,hc,?_⟩ + intro N hN A hA hf + have hh := h N hN (natTranslate A) (natTranslate_sub N A hA) (natTranslate_free N A hA hf) + rwa [natTranslate_card N A hA] at hh + +end SquareDifference + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SquareDifference/MarkedTuples.lean b/lean/OAI/Combinatorics/SquareDifference/MarkedTuples.lean new file mode 100644 index 0000000000000000000000000000000000000000..eeeda6606889eafff59679fd1df1ccd3d265dc9d --- /dev/null +++ b/lean/OAI/Combinatorics/SquareDifference/MarkedTuples.lean @@ -0,0 +1,502 @@ +import OAI.Combinatorics.SquareDifference.ReflectionLaw + +namespace OAI + +section +open Finset +open scoped BigOperators +namespace SquareDifference +open scoped Classical + +lemma tuple_marked_uniform {p : ℕ} [Fact p.Prime] + (S : Finset (Fin tupleBlocks)) (hs : S.card ≤ tupleT + 1) + (b : Fin tupleBlocks) (hb : b ∈ S) {α β : Fin tupleH} (hne : α ≠ β) + (F : (CutHalf b α β → ZMod p) → ℝ) : + tupleMarkedConstant * (𝔼 Y : TupleListEntry S → ZMod p, + 𝔼 j : CutHalf b α β → TupleListIndex S, + tupleValidity S Y * (F (fun v => Y (tupleProjection S v.1, j v)))^2) ≤ + tupleCutForm S b α β F := by + refine le_trans (mul_le_mul_of_nonneg_right (tupleMarkedConstant_le S hs b hne) ?_) + (tuple_marked_lower S b hb hne F) + exact expect_nonneg fun Y _ => expect_nonneg fun j _ => + mul_nonneg (tupleValidity_nonneg _ _) (sq_nonneg _) + +lemma tuple_marking_domination {p : ℕ} [Fact p.Prime] + (S : Finset (Fin tupleBlocks)) (hs : S.card ≤ tupleT) + (b : Fin tupleBlocks) (hb : b ∉ S) {α β : Fin tupleH} (hne : α ≠ β) + (F : (CutHalf b α β → ZMod p) → ℝ) : + tupleMarkedConstant * ((tupleR : ℝ)^tupleHalfCount)⁻¹ * + tupleUnmarkedMoment S b hb hne F ≤ tupleCutForm (insert b S) b α β F := by + have hr := tuple_regroup_moment S hs b hb hne F + rw [card_tupleHalf b hne] at hr + have hs' : (insert b S).card ≤ tupleT + 1 := by + rw [card_insert_of_notMem hb]; omega + have h := mul_le_mul_of_nonneg_left hr tupleMarkedConstant_pos.le + rw [← mul_assoc] at h + exact h.trans (tuple_marked_uniform (insert b S) hs' b (mem_insert_self ..) hne F) + +lemma truncated_sum_nonneg_of_pairs {B : Type*} [Fintype B] [DecidableEq B] + (b : B) (t : ℕ) (f : Finset B → ℝ) + (hpair : ∀ S, b ∉ S → S.card ≤ t → 0 ≤ f S + f (insert b S)) + (hterm : ∀ S, b ∉ S → S.card = t + 1 → 0 ≤ f S) : + 0 ≤ ∑ S ∈ (univ : Finset B).powerset, if S.card ≤ t + 1 then f S else 0 := by + classical + rw [← insert_erase (mem_univ b), sum_powerset_insert (notMem_erase b univ), ← sum_add_distrib] + apply sum_nonneg + intro S hS + have hb : b ∉ S := notMem_mono (mem_powerset.mp hS) (notMem_erase b univ) + rw [card_insert_of_notMem hb] + by_cases ht : S.card ≤ t + · simp only [ite_eq_left (by omega : S.card ≤ t + 1), + ite_eq_left (by omega : S.card + 1 ≤ t + 1)] + exact hpair S hb ht + · by_cases he : S.card = t + 1 + · simp only [he, le_refl, ite_true, ite_eq_right (by omega : ¬ t + 1 + 1 ≤ t + 1), add_zero] + exact hterm S hb he + · simp [show ¬ S.card ≤ t + 1 by omega, show ¬ S.card + 1 ≤ t + 1 by omega] + +lemma balanced_rpow_error {C a p : ℝ} (hC : 0 ≤ C) (ha : 0 < a) (hp : 0 < p) + (hthreshold : (C / a)^16 ≤ p) : + C * p^(-(1 : ℝ)/8) ≤ a * p^(-(1 : ℝ)/16) := by + have hroot := Real.rpow_le_rpow (pow_nonneg (div_nonneg hC ha.le) 16) hthreshold + (by norm_num : 0 ≤ (1 : ℝ)/16) + have hx : ((C/a)^16)^((1 : ℝ)/16) = C/a := by + rw [← Real.rpow_natCast, ← Real.rpow_mul (div_nonneg hC ha.le)] + norm_num + rw [hx] at hroot + have hh := mul_le_mul_of_nonneg_right hroot + (mul_nonneg ha.le (Real.rpow_nonneg hp.le (-(1 : ℝ)/8))) + have hpow : p^((1 : ℝ)/16) * p^(-(1 : ℝ)/8) = p^(-(1 : ℝ)/16) := by + rw [← Real.rpow_add hp] + congr 1 + ring + calc + C * p^(-(1 : ℝ)/8) = (C/a) * (a * p^(-(1 : ℝ)/8)) := by field_simp + _ ≤ p^((1 : ℝ)/16) * (a * p^(-(1 : ℝ)/8)) := hh + _ = a * p^(-(1 : ℝ)/16) := by rw [mul_left_comm, hpow] + +lemma tupleUnmarkedConstant_nonneg : 0 ≤ tupleUnmarkedConstant := + mul_nonneg (Real.rpow_nonneg (mul_nonneg (by norm_num) (sq_nonneg _)) _) + (sq_nonneg _) + +noncomputable def tupleReflectionThreshold : ℝ := + max 3 ((tupleUnmarkedConstant * (tupleR : ℝ)^tupleHalfCount / + tupleMarkedConstant)^16) + +lemma tuple_pair_positive {p : ℕ} [Fact p.Prime] + (hp : tupleReflectionThreshold ≤ (p : ℝ)) + (S : Finset (Fin tupleBlocks)) (hs : S.card ≤ tupleT) + (b : Fin tupleBlocks) (hb : b ∉ S) {α β : Fin tupleH} (hne : α ≠ β) + (F : (CutHalf b α β → ZMod p) → ℝ) : + 0 ≤ tupleCutForm S b α β F + (p : ℝ)^(-(1 : ℝ)/16) * + tupleCutForm (insert b S) b α β F := by + have hp3 : (3 : ℝ) ≤ p := (le_max_left _ _).trans hp + have hp0 : (0 : ℝ) < p := lt_of_lt_of_le (by norm_num) hp3 + have hp2 : p ≠ 2 := by intro h; subst p; norm_num at hp3 + let a := tupleMarkedConstant * ((tupleR : ℝ)^tupleHalfCount)⁻¹ + have hr : 0 < (tupleR : ℝ)^tupleHalfCount := pow_pos (Nat.cast_pos.mpr tupleR_pos) _ + have ha : 0 < a := mul_pos tupleMarkedConstant_pos (inv_pos.mpr hr) + have hC : tupleUnmarkedConstant / a = + tupleUnmarkedConstant * (tupleR : ℝ)^tupleHalfCount / tupleMarkedConstant := by + dsimp [a] + field_simp + have hthreshold : (tupleUnmarkedConstant / a)^16 ≤ (p : ℝ) := by + rw [hC] + exact (le_max_right _ _).trans hp + have hc := balanced_rpow_error tupleUnmarkedConstant_nonneg ha hp0 hthreshold + have hl := tuple_unmarked_error hp2 S (by omega) b hb hne F + have hd := tuple_marking_domination S hs b hb hne F + have hd' := mul_le_mul_of_nonneg_left hd + (Real.rpow_nonneg hp0.le (-(1 : ℝ)/16)) + have hD := tupleUnmarkedMoment_nonneg S b hb hne F + have hcd := mul_le_mul_of_nonneg_right hc hD + dsimp [a] at hcd + nlinarith + +noncomputable def tupleMixtureWeight (p : ℕ) (S : Finset (Fin tupleBlocks)) : ℝ := + (p : ℝ)^(-(S.card : ℝ)/16) + +lemma tupleMixtureWeight_nonneg (p : ℕ) (S : Finset (Fin tupleBlocks)) : + 0 ≤ tupleMixtureWeight p S := Real.rpow_nonneg (Nat.cast_nonneg _) _ + +lemma tupleMixtureWeight_insert {p : ℕ} (hp : 0 < p) + (S : Finset (Fin tupleBlocks)) (b : Fin tupleBlocks) (hb : b ∉ S) : + tupleMixtureWeight p (insert b S) = tupleMixtureWeight p S * (p : ℝ)^(-(1 : ℝ)/16) := by + unfold tupleMixtureWeight + rw [card_insert_of_notMem hb, Nat.cast_add, Nat.cast_one] + rw [show -((S.card : ℝ)+1)/16 = -(S.card : ℝ)/16 + -(1 : ℝ)/16 by ring] + exact Real.rpow_add (Nat.cast_pos.mpr hp) _ _ + +noncomputable def tupleMixture {p : ℕ} [Fact p.Prime] + (G : (TupleVertex → ZMod p) → ℝ) : ℝ := + ∑ S ∈ (univ : Finset (Fin tupleBlocks)).powerset, + if S.card ≤ tupleT + 1 then tupleMixtureWeight p S * tupleComponent S G else 0 + +lemma tupleMixture_reflection_positive {p : ℕ} [Fact p.Prime] + (hp : tupleReflectionThreshold ≤ (p : ℝ)) + (b : Fin tupleBlocks) {α β : Fin tupleH} (hne : α ≠ β) + (F : (CutHalf b α β → ZMod p) → ℝ) : + 0 ≤ tupleMixture (fun z => F (fun v => z v.1) * F (fun v => z (reflect b α β v.1))) := by + apply truncated_sum_nonneg_of_pairs b tupleT + · intro S hb hs + have hh := mul_nonneg (tupleMixtureWeight_nonneg p S) (tuple_pair_positive hp S hs b hb hne F) + rw [tupleMixtureWeight_insert (Fact.out : p.Prime).pos S b hb] + simpa only [tupleCutForm, mul_add, mul_assoc] using hh + · intro S hb hs + exact mul_nonneg (tupleMixtureWeight_nonneg p S) + (tuple_terminal_positive (by + have hc : (3 : ℝ) ≤ p := (le_max_left _ _).trans hp + intro h; subst p; norm_num at hc) S hs b hb hne F) + +lemma tupleMixture_symmetric {p : ℕ} [Fact p.Prime] + (b : Fin tupleBlocks) (α β : Fin tupleH) + (F G : (CutHalf b α β → ZMod p) → ℝ) : + tupleMixture (fun z => F (fun v => z v.1) * G (fun v => z (reflect b α β v.1))) = + tupleMixture (fun z => G (fun v => z v.1) * F (fun v => z (reflect b α β v.1))) := by + apply sum_congr rfl + intro S _ + split_ifs + · rw [tupleCutForm_symmetric] + · rfl + +noncomputable def tupleComponentMap {p : ℕ} [Fact p.Prime] + (S : Finset (Fin tupleBlocks)) : ((TupleVertex → ZMod p) → ℝ) →ₗ[ℝ] ℝ where + toFun := tupleComponent S + map_add' F G := by simp [tupleComponent, mul_add, expect_add_distrib] + map_smul' c F := by + simp only [tupleComponent, Pi.smul_apply, smul_eq_mul] + simp_rw [show ∀ a b d : ℝ, a * b * (c * d) = c * (a * b * d) by intros; ring] + simp_rw [← mul_expect] + rfl + +noncomputable def tupleMixtureMap {p : ℕ} [Fact p.Prime] : + ((TupleVertex → ZMod p) → ℝ) →ₗ[ℝ] ℝ where + toFun := tupleMixture + map_add' F G := by + unfold tupleMixture + rw [← sum_add_distrib] + apply sum_congr rfl + intro S _ + split_ifs with hs + · change _ * tupleComponentMap S (F+G) = _ + rw [map_add, mul_add] + rfl + · simp + map_smul' c F := by + change tupleMixture (c • F) = c * tupleMixture F + unfold tupleMixture + rw [mul_sum] + apply sum_congr rfl + intro S _ + split_ifs with hs + · change _ * tupleComponentMap S (c • F) = _ + rw [map_smul, smul_eq_mul] + change tupleMixtureWeight p S * (c * tupleComponent S F) = + c * (tupleMixtureWeight p S * tupleComponent S F) + ring + · simp + +lemma tupleMixtureMap_apply {p : ℕ} [Fact p.Prime] + (F : (TupleVertex → ZMod p) → ℝ) : tupleMixtureMap F = tupleMixture F := by + simp only [tupleMixtureMap, LinearMap.coe_mk, AddHom.coe_mk] + +lemma tupleMixture_nonneg {p : ℕ} [Fact p.Prime] + (F : (TupleVertex → ZMod p) → ℝ) (hF : ∀ z, 0 ≤ F z) : + 0 ≤ tupleMixture F := by + apply sum_nonneg + intro S _ + split_ifs + · exact mul_nonneg (tupleMixtureWeight_nonneg p S) (tupleComponent_nonneg S F hF) + · exact le_rfl + +noncomputable def tupleLeadingEdges : ℕ := (tupleListEdges ∅).card + +noncomputable def tupleLeadingMassLower : ℝ := (1/2 : ℝ)^(tupleLeadingEdges+1) + +noncomputable def tupleMassThreshold : ℝ := + max 3 (((2 : ℝ)^(tupleLeadingEdges+1) * tupleLeadingEdges)^2) + +lemma tupleLeadingMassLower_pos : 0 < tupleLeadingMassLower := pow_pos (by norm_num) _ + +lemma error_le_of_square_threshold {E c p : ℝ} (hE : 0 ≤ E) (hc : 0 < c) + (hp : 0 < p) (h : (E/c)^2 ≤ p) : E * p^(-(1 : ℝ)/2) ≤ c := by + have hh := Real.rpow_le_rpow (sq_nonneg (E/c)) h (by norm_num : 0 ≤ (1 : ℝ)/2) + have he : ((E/c)^2)^((1 : ℝ)/2) = E/c := by + rw [← Real.rpow_natCast, ← Real.rpow_mul (div_nonneg hE hc.le)] + norm_num + rw [he] at hh + have hh' := mul_le_mul_of_nonneg_right hh + (mul_nonneg hc.le (Real.rpow_nonneg hp.le (-(1 : ℝ)/2))) + have hp' : p^((1 : ℝ)/2) * p^(-(1 : ℝ)/2) = 1 := by + rw [← Real.rpow_add hp] + norm_num + calc + _ = (E/c) * (c * p^(-(1 : ℝ)/2)) := by field_simp + _ ≤ p^((1 : ℝ)/2) * (c * p^(-(1 : ℝ)/2)) := hh' + _ = c := by rw [mul_left_comm, hp', mul_one] + +lemma leading_mass_lower_of_count (e : ℕ) {m p : ℝ} + (hp : max 3 (((2 : ℝ)^(e+1) * e)^2) ≤ p) + (hcount : |m-(1/2 : ℝ)^e| ≤ (e : ℝ)*p^(-(1 : ℝ)/2)) : + (1/2 : ℝ)^(e+1) ≤ m := by + have hp0 : 0 < p := lt_of_lt_of_le (by norm_num : (0 : ℝ)<3) ((le_max_left _ _).trans hp) + have hc0 : 0 < (1/2 : ℝ)^(e+1) := pow_pos (by norm_num) _ + have he : (e : ℝ) / (1/2 : ℝ)^(e+1) = (2 : ℝ)^(e+1)*e := by + rw [one_div_pow] + field_simp + have hc := error_le_of_square_threshold (Nat.cast_nonneg e) hc0 hp0 + (by rw [he]; exact (le_max_right _ _).trans hp) + have hc2 : (1/2 : ℝ)^e = 2*(1/2 : ℝ)^(e+1) := by rw [pow_succ]; ring + have he' := hcount.trans hc + rw [abs_le, hc2] at he' + linarith [he'.1] + +lemma tupleLeading_mass_lower {p : ℕ} [Fact p.Prime] + (hp : tupleMassThreshold ≤ (p : ℝ)) : + tupleLeadingMassLower ≤ tupleComponent (p := p) ∅ (fun _ => 1) := by + apply leading_mass_lower_of_count tupleLeadingEdges hp + have hp3 : (3 : ℝ) ≤ p := (le_max_left _ _).trans hp + have hp2 : p ≠ 2 := by intro h; subst p; norm_num at hp3 + exact (tuple_leading_mass hp2).trans (mul_le_mul_of_nonneg_left + (square_delta_le (p := p)) (Nat.cast_nonneg tupleLeadingEdges)) + +lemma tupleMixture_mass_lower {p : ℕ} [Fact p.Prime] + (hp : tupleMassThreshold ≤ (p : ℝ)) : + tupleLeadingMassLower ≤ tupleMixture (p := p) (fun _ => 1) := by + refine (tupleLeading_mass_lower hp).trans ?_ + have hterm : ∀ S : Finset (Fin tupleBlocks), 0 ≤ + if S.card ≤ tupleT+1 then tupleMixtureWeight p S * tupleComponent (p := p) S (fun _ => 1) else 0 := by + intro S + split_ifs + · exact mul_nonneg (tupleMixtureWeight_nonneg p S) + (tupleComponent_nonneg S _ (fun _ => by norm_num)) + · exact le_rfl + have hh := single_le_sum (s := (univ : Finset (Fin tupleBlocks)).powerset) + (fun S _ => hterm S) (a := ∅) (mem_powerset.mpr (empty_subset _)) + simpa only [card_empty, Nat.zero_le, ite_true, tupleMixtureWeight, Nat.cast_zero, + neg_zero, zero_div, Real.rpow_zero, one_mul, tupleMixture] using hh + +lemma tupleMixtureWeight_le_one {p : ℕ} [Fact p.Prime] + (S : Finset (Fin tupleBlocks)) : tupleMixtureWeight p S ≤ 1 := by + apply Real.rpow_le_one_of_one_le_of_nonpos + · exact_mod_cast (Fact.out : p.Prime).one_lt.le + · exact div_nonpos_of_nonpos_of_nonneg (neg_nonpos.mpr (Nat.cast_nonneg _)) (by norm_num) + +lemma tupleMixture_mass_upper {p : ℕ} [Fact p.Prime] : + tupleMixture (p := p) (fun _ => 1) ≤ (2 : ℝ)^tupleBlocks * tupleWeightBound := by + calc + _ ≤ ∑ _S ∈ (univ : Finset (Fin tupleBlocks)).powerset, tupleWeightBound := by + apply sum_le_sum + intro S _ + split_ifs with hs + · exact (mul_le_mul_of_nonneg_right (tupleMixtureWeight_le_one S) + (tupleComponent_nonneg S _ (fun _ => by norm_num))).trans + (by simpa using tupleComponent_mass_le (p := p) S hs) + · exact tupleWeightBound_pos.le + _ = _ := by simp only [sum_const, nsmul_eq_mul, card_powerset, card_univ, + Fintype.card_fin, Nat.cast_pow, Nat.cast_ofNat] + +noncomputable def tupleLaw {p : ℕ} [Fact p.Prime] : + ((TupleVertex → ZMod p) → ℝ) →ₗ[ℝ] ℝ := + (tupleMixture (p := p) (fun _ => 1))⁻¹ • tupleMixtureMap + +lemma tupleLaw_probability {p : ℕ} [Fact p.Prime] + (hp : tupleMassThreshold ≤ (p : ℝ)) : tupleLaw (p := p) (fun _ => 1) = 1 := by + have hm := lt_of_lt_of_le tupleLeadingMassLower_pos (tupleMixture_mass_lower hp) + simp only [tupleLaw, LinearMap.smul_apply, smul_eq_mul, tupleMixtureMap_apply, + inv_mul_cancel₀ hm.ne'] + +lemma tupleLaw_nonneg {p : ℕ} [Fact p.Prime] (F : (TupleVertex → ZMod p) → ℝ) + (hF : ∀ z, 0 ≤ F z) : 0 ≤ tupleLaw F := + mul_nonneg (inv_nonneg.mpr (tupleMixture_nonneg _ (fun _ => by norm_num))) + (by rw [tupleMixtureMap_apply]; exact tupleMixture_nonneg F hF) + +lemma tupleLaw_reflection_positive {p : ℕ} [Fact p.Prime] + (hp : tupleReflectionThreshold ≤ (p : ℝ)) + (b : Fin tupleBlocks) {α β : Fin tupleH} (hne : α ≠ β) + (F : (CutHalf b α β → ZMod p) → ℝ) : + 0 ≤ tupleLaw (fun z => F (fun v => z v.1) * F (fun v => z (reflect b α β v.1))) := by + apply mul_nonneg (inv_nonneg.mpr (tupleMixture_nonneg _ (fun _ => by norm_num))) + rw [tupleMixtureMap_apply] + exact tupleMixture_reflection_positive hp b hne F + +lemma tupleLaw_symmetric {p : ℕ} [Fact p.Prime] + (b : Fin tupleBlocks) (α β : Fin tupleH) + (F G : (CutHalf b α β → ZMod p) → ℝ) : + tupleLaw (fun z => F (fun v => z v.1) * G (fun v => z (reflect b α β v.1))) = + tupleLaw (fun z => G (fun v => z v.1) * F (fun v => z (reflect b α β v.1))) := by + simp only [tupleLaw, LinearMap.smul_apply, smul_eq_mul, tupleMixtureMap_apply, + tupleMixture_symmetric b α β F G] + +noncomputable def finiteIntegral {X : Type*} [Fintype X] (w : X → ℝ) : + (X → ℝ) →ₗ[ℝ] ℝ where + toFun f := ∑ x, w x * f x + map_add' f g := by simp [mul_add, sum_add_distrib] + map_smul' c f := by simp [mul_left_comm, mul_sum] + +lemma finiteIntegral_nonneg {X : Type*} [Fintype X] (w f : X → ℝ) + (hw : ∀ x, 0 ≤ w x) (hf : ∀ x, 0 ≤ f x) : 0 ≤ finiteIntegral w f := + sum_nonneg fun x _ => mul_nonneg (hw x) (hf x) + +lemma linearFunctional_density {X : Type*} [Fintype X] [DecidableEq X] + (L : (X → ℝ) →ₗ[ℝ] ℝ) (f : X → ℝ) : + L f = ∑ x, L (fun y => if y = x then 1 else 0) * f x := by + classical + have hf : f = ∑ x, f x • (fun y => if y = x then (1 : ℝ) else 0) := by + ext y + simp + conv_lhs => rw [hf, map_sum] + apply sum_congr rfl + intro x _ + simp [mul_comm] + +lemma cut_cauchy_schwarz {X I : Type*} + (L : (X → ℝ) →ₗ[ℝ] ℝ) (left right : X → I) + (hsym : ∀ F G : I → ℝ, + L (fun z => F (left z) * G (right z)) = + L (fun z => G (left z) * F (right z))) + (hpos : ∀ F : I → ℝ, 0 ≤ L (fun z => F (left z) * F (right z))) + (F G : I → ℝ) : + |L (fun z => F (left z) * G (right z))|^2 ≤ + L (fun z => F (left z) * F (right z)) * + L (fun z => G (left z) * G (right z)) := by + have hquad (t : ℝ) := hpos (fun x => t * F x + G x) + have heq (t : ℝ) : + (fun z => (t * F (left z) + G (left z)) * + (t * F (right z) + G (right z))) = + (t*t) • (fun z => F (left z) * F (right z)) + + t • (fun z => F (left z) * G (right z)) + + t • (fun z => G (left z) * F (right z)) + + (fun z => G (left z) * G (right z)) := by + ext z + simp only [Pi.add_apply, Pi.smul_apply, smul_eq_mul] + ring + simp only [heq, map_add, map_smul, smul_eq_mul, ← hsym F G] at hquad + have hq := discrim_le_zero (fun t => show 0 ≤ + L (fun z => F (left z) * F (right z)) * (t*t) + + (2*L (fun z => F (left z) * G (right z))) * t + + L (fun z => G (left z) * G (right z)) by nlinarith [hquad t]) + rw [discrim] at hq + rw [sq_abs] + nlinarith + +noncomputable def multilinearIntegral {V X : Type*} [Fintype V] + (L : ((V → X) → ℝ) →ₗ[ℝ] ℝ) (a : V → X → ℝ) : ℝ := + L (fun z => ∏ v, a v (z v)) + +noncomputable def diagonalIntegral {V X : Type*} [Fintype V] + (L : ((V → X) → ℝ) →ₗ[ℝ] ℝ) (g : X → ℝ) : ℝ := + multilinearIntegral L (fun _ => g) + +lemma multilinearIntegral_div {V X : Type*} [Fintype V] + (L : ((V → X) → ℝ) →ₗ[ℝ] ℝ) (a : V → X → ℝ) (c : V → ℝ) : + multilinearIntegral L (fun v x => a v x / c v) = + multilinearIntegral L a / ∏ v, c v := by + unfold multilinearIntegral + simp_rw [prod_div_distrib] + have he : (fun z : V → X => (∏ v, a v (z v)) / ∏ v, c v) = + (∏ v, c v)⁻¹ • (fun z : V → X => ∏ v, a v (z v)) := by + ext z + simp [div_eq_mul_inv, mul_comm] + rw [he, map_smul, smul_eq_mul] + ring + +lemma diagonalIntegral_div {V X : Type*} [Fintype V] + (L : ((V → X) → ℝ) →ₗ[ℝ] ℝ) (g : X → ℝ) (c : ℝ) : + diagonalIntegral L (fun x => g x / c) = + diagonalIntegral L g / c^(Fintype.card V) := by + unfold diagonalIntegral + simpa only [prod_const, card_univ] using + multilinearIntegral_div L (fun _ => g) (fun _ => c) + +lemma holder_of_finite_maximum {V X : Type*} [Fintype V] [Nonempty V] + (L : ((V → X) → ℝ) →ₗ[ℝ] ℝ) + (hdiag : ∀ g, 0 ≤ diagonalIntegral L g) + (hmax : ∀ a : V → X → ℝ, ∃ i : V, + |multilinearIntegral L a| ≤ diagonalIntegral L (a i)) + (a : V → X → ℝ) : + |multilinearIntegral L a| ≤ + ∏ v, (diagonalIntegral L (a v))^((1 : ℝ)/(Fintype.card V : ℝ)) := by + classical + let d : ℝ := Fintype.card V + have hd : 0 < d := Nat.cast_pos.mpr Fintype.card_pos + have hε (ε : ℝ) (hε : 0 < ε) : + |multilinearIntegral L a| ≤ ∏ v, (diagonalIntegral L (a v)+ε)^((1 : ℝ)/d) := by + let c (v : V) : ℝ := (diagonalIntegral L (a v)+ε)^((1 : ℝ)/d) + have hc (v : V) : 0 < c v := Real.rpow_pos_of_pos (by linarith [hdiag (a v)]) _ + have hcp (v : V) : c v ^ Fintype.card V = diagonalIntegral L (a v)+ε := by + dsimp [c] + rw [← Real.rpow_mul_natCast (le_of_lt (by linarith [hdiag (a v)] : + 0 < diagonalIntegral L (a v)+ε))] + change (diagonalIntegral L (a v)+ε)^((1/d)*d) = _ + rw [one_div_mul_cancel hd.ne', Real.rpow_one] + obtain ⟨i, hi⟩ := hmax (fun v x => a v x / c v) + rw [multilinearIntegral_div, diagonalIntegral_div, hcp] at hi + have hle : diagonalIntegral L (a i) / (diagonalIntegral L (a i)+ε) ≤ 1 := by + apply (div_le_one (by linarith [hdiag (a i)])).mpr + linarith + have hprod : 0 < ∏ v, c v := prod_pos fun v _ => hc v + rw [abs_div, abs_of_pos hprod] at hi + exact (div_le_one hprod).mp (hi.trans hle) + have hc : Continuous (fun ε : ℝ => + ∏ v, (diagonalIntegral L (a v)+ε)^((1 : ℝ)/d)) := by + apply continuous_finsetProd + intro v _ + exact (Real.continuous_rpow_const (div_nonneg zero_le_one hd.le)).comp + (continuous_const.add continuous_id) + have ht := hc.continuousAt.tendsto.mono_left (show nhdsWithin (0 : ℝ) (Set.Ioi 0) ≤ nhds 0 by + exact inf_le_left) + have hevent : ∀ᶠ ε : ℝ in nhdsWithin 0 (Set.Ioi 0), + |multilinearIntegral L a| ≤ ∏ v, (diagonalIntegral L (a v)+ε)^((1 : ℝ)/d) := by + filter_upwards [self_mem_nhdsWithin] with ε hεpos + exact hε ε hεpos + have hh := ge_of_tendsto ht hevent + simpa only [add_zero] using hh + +lemma prod_word_split {B M : Type*} [Fintype B] [DecidableEq B] [CommMonoid M] + {h : ℕ} (b : B) {α β : Fin h} (hne : α ≠ β) (f : WordVertex B h → M) : + ∏ v, f v = (∏ v : CutHalf b α β, f v.1) * + ∏ v : CutHalf b α β, f (reflect b α β v.1) := by + classical + rw [← Fintype.prod_equiv (halfSumEquiv b hne) (fun v => f (halfSumEquiv b hne v)) f + (fun _ => rfl)] + exact Fintype.prod_sum_type _ + +lemma foldWord_half {B : Type*} [DecidableEq B] {h : ℕ} + (b : B) (α β : Fin h) (v : CutHalf b α β) : + foldWord b α β v.1 = v.1 := ite_eq_left v.2 + +lemma foldWord_reflect_half {B : Type*} [DecidableEq B] {h : ℕ} + (b : B) {α β : Fin h} (hne : α ≠ β) (v : CutHalf b α β) : + foldWord b α β (reflect b α β v.1) = v.1 := by + have hn : ¬ cutPlus b α β (reflect b α β v.1) := by + rw [cutPlus_reflect_iff_not b hne] + exact not_not.mpr v.2 + rw [foldWord, ite_eq_right hn, reflect_involutive] + +lemma reflect_comm {B : Type*} [DecidableEq B] {h : ℕ} + (b : B) (α β : Fin h) : reflect b α β = reflect b β α := by + funext v + simp only [reflect, Equiv.swap_comm α β] + +lemma foldWord_opposite_half {B : Type*} [DecidableEq B] {h : ℕ} + (b : B) (α β : Fin h) (v : CutHalf b α β) : + foldWord b β α v.1 = reflect b α β v.1 := by + have hn : ¬ cutPlus b β α v.1 := not_lt_of_gt v.2 + rw [foldWord, ite_eq_right hn, reflect_comm b β α] + +lemma foldWord_opposite_reflect_half {B : Type*} [DecidableEq B] {h : ℕ} + (b : B) (α β : Fin h) (v : CutHalf b α β) : + foldWord b β α (reflect b α β v.1) = reflect b α β v.1 := by + apply ite_eq_left + rw [reflect_comm b α β, reflect_cutPlus] + exact v.2 + +noncomputable def halfProduct {B X : Type*} [Fintype B] [DecidableEq B] {h : ℕ} + (b : B) (α β : Fin h) (a : WordVertex B h → X → ℝ) + (x : CutHalf b α β → X) : ℝ := ∏ v, a v.1 (x v) + +end SquareDifference +end + +end OAI diff --git a/lean/OAI/Combinatorics/SquareDifference/MatrixBounds.lean b/lean/OAI/Combinatorics/SquareDifference/MatrixBounds.lean new file mode 100644 index 0000000000000000000000000000000000000000..fffc4dd1fa1517c0a10cf3ab06284cd25b1e92fd --- /dev/null +++ b/lean/OAI/Combinatorics/SquareDifference/MatrixBounds.lean @@ -0,0 +1,513 @@ +import OAI.Combinatorics.SquareDifference.MixedEnergy + +namespace OAI + +section +open Finset +open scoped BigOperators +namespace SquareDifference + +lemma weighted_matrix_lower_quadratic {I : Type*} [Fintype I] [DecidableEq I] + {C : Matrix I I ℝ} {lam : ℝ} (hC : (C - lam • 1).PosSemidef) (hlam : 0 ≤ lam) + (a f : I → ℝ) (ha : ∀ i, 1 ≤ a i) : + lam * ∑ i, (f i) ^ 2 ≤ ∑ i, ∑ j, (a i * f i) * C i j * (a j * f j) := by + calc + lam * ∑ i, (f i) ^ 2 ≤ lam * ∑ i, (a i * f i) ^ 2 := by + apply mul_le_mul_of_nonneg_left _ hlam + apply sum_le_sum + intro i _ + have ha2 : 0 ≤ (a i) ^ 2 - 1 := by nlinarith [ha i] + nlinarith [mul_nonneg ha2 (sq_nonneg (f i))] + _ ≤ _ := matrix_lower_quadratic hC _ + +lemma marked_index_average {I J : Type*} [Fintype I] [Fintype J] + [DecidableEq I] [DecidableEq J] + (A : Matrix I I ℝ) (κ : ℝ) (hκ : 0 ≤ κ) + (hA : (A - κ • 1).PosSemidef) (a f : (I → J) → ℝ) (ha : ∀ j, 1 ≤ a j) : + ((Real.exp κ - 1) ^ Fintype.card I / (Fintype.card J : ℝ) ^ Fintype.card I) * + (𝔼 j : I → J, (f j) ^ 2) ≤ + 𝔼 j : I → J, 𝔼 k : I → J, + (a j * f j) * Real.exp (indexCross A j k) * (a k * f k) := by + classical + have h := weighted_matrix_lower_quadratic (exponential_index_matrix_lower A κ hκ hA) + (pow_nonneg (sub_nonneg.mpr (Real.one_le_exp_iff.mpr hκ)) _) a f ha + have hd := div_le_div_of_nonneg_right h + (sq_nonneg (Fintype.card (I → J) : ℝ)) + simp only [Matrix.of_apply] at hd + simp only [Fintype.expect_eq_sum_div_card, Fintype.card_fun, Nat.cast_pow, ← sum_div, + div_div] at hd ⊢ + convert hd using 1 <;> first | rfl | ring + +abbrev WordVertex (B : Type*) (h : ℕ) := B → Equiv.Perm (Fin h) + +abbrev PositionPair (h : ℕ) := {p : Fin h × Fin h // p.1 < p.2} + +def vertexSwap {B : Type*} [DecidableEq B] {h : ℕ} + (v : WordVertex B h) (b : B) (p : PositionPair h) : WordVertex B h := + Function.update v b (v b * Equiv.swap p.1.1 p.1.2) + +def reflect {B : Type*} [DecidableEq B] {h : ℕ} + (b : B) (α β : Fin h) (v : WordVertex B h) : WordVertex B h := + Function.update v b (Equiv.swap α β * v b) + +def cutPlus {B : Type*} {h : ℕ} (b : B) (α β : Fin h) (v : WordVertex B h) : Prop := + (v b).symm α < (v b).symm β + +instance cutPlusDecidable {B : Type*} {h : ℕ} (b : B) (α β : Fin h) : + DecidablePred (cutPlus b α β) := + fun v => inferInstanceAs (Decidable ((v b).symm α < (v b).symm β)) + +lemma vertexSwap_involutive {B : Type*} [DecidableEq B] {h : ℕ} + (b : B) (p : PositionPair h) : Function.Involutive (fun v : WordVertex B h => vertexSwap v b p) := by + intro v + ext a + by_cases hab : a = b + · subst a + simp [vertexSwap, mul_assoc] + · simp [vertexSwap, hab] + +lemma reflect_involutive {B : Type*} [DecidableEq B] {h : ℕ} + (b : B) (α β : Fin h) : Function.Involutive (reflect b α β) := by + intro v + ext a + by_cases hab : a = b + · subst a + simp [reflect, ← mul_assoc] + · simp [reflect, hab] + +lemma reflect_vertexSwap {B : Type*} [DecidableEq B] {h : ℕ} + (b c : B) (α β : Fin h) (p : PositionPair h) (v : WordVertex B h) : + reflect b α β (vertexSwap v c p) = vertexSwap (reflect b α β v) c p := by + ext a + by_cases hab : a = b <;> by_cases hac : a = c <;> + simp_all [reflect, vertexSwap, mul_assoc] + +lemma reflect_cutPlus {B : Type*} [DecidableEq B] {h : ℕ} + (b : B) (α β : Fin h) (v : WordVertex B h) : + cutPlus b α β (reflect b α β v) ↔ (v b).symm β < (v b).symm α := by + simp [cutPlus, reflect, Equiv.Perm.mul_def] + +lemma reflect_ne_self {B : Type*} [DecidableEq B] {h : ℕ} + (b : B) {α β : Fin h} (hαβ : α ≠ β) (v : WordVertex B h) : + reflect b α β v ≠ v := by + intro heq + have hh := congrArg (fun w : WordVertex B h => w b ((v b).symm α)) heq + simp [reflect, Equiv.Perm.mul_apply] at hh + exact hαβ hh.symm + +lemma swap_reverse_gap {h : ℕ} (i j a b : Fin h) (hij : i < j) (hab : a < b) + (hrev : Equiv.swap a b j < Equiv.swap a b i) (hnot : ¬ (a = i ∧ b = j)) : + j.val - i.val + 1 ≤ b.val - a.val := by + simp only [Equiv.swap_apply_def] at hrev + split_ifs at hrev <;> subst_vars <;> simp_all <;> omega + +lemma vertexSwap_symm_apply {B : Type*} [DecidableEq B] {h : ℕ} + (v : WordVertex B h) (b : B) (p : PositionPair h) (α : Fin h) : + (vertexSwap v b p b).symm α = Equiv.swap p.1.1 p.1.2 ((v b).symm α) := by + simp [vertexSwap, Equiv.Perm.mul_def] + +lemma reflect_eq_positional {B : Type*} [DecidableEq B] {h : ℕ} + (v : WordVertex B h) (b : B) (α β : Fin h) (hp : cutPlus b α β v) : + reflect b α β v = vertexSwap v b ⟨((v b).symm α, (v b).symm β), hp⟩ := by + ext a x + by_cases hab : a = b + · subst a + simp only [reflect, vertexSwap, Function.update_self, Equiv.Perm.mul_apply] + have hh := Equiv.trans_swap_trans_symm α β (v b) + have hh' := congrArg (fun e : Fin h ≃ Fin h => (v b) (e x)) hh + simpa only [Equiv.trans_apply, Equiv.apply_symm_apply] using congrArg Fin.val hh' + · simp [reflect, vertexSwap, hab] + +lemma ordered_swap_injective {h : ℕ} : + Function.Injective (fun p : PositionPair h => Equiv.swap p.1.1 p.1.2) := by + intro p q heq + change Equiv.swap p.1.1 p.1.2 = Equiv.swap q.1.1 q.1.2 at heq + have hp : p.1.1 ≠ p.1.2 := ne_of_lt p.2 + have h1 : p.1.1 = q.1.1 ∨ p.1.1 = q.1.2 := by + apply Equiv.eq_or_eq_of_swap_apply_ne_self + rw [← heq, Equiv.swap_apply_left] + exact hp.symm + have h2 : p.1.2 = q.1.1 ∨ p.1.2 = q.1.2 := by + apply Equiv.eq_or_eq_of_swap_apply_ne_self + rw [← heq, Equiv.swap_apply_right] + exact hp + apply Subtype.ext + apply Prod.ext <;> rcases h1 with h1 | h1 <;> rcases h2 with h2 | h2 <;> + first | assumption | omega + +lemma vertexSwap_ne_self {B : Type*} [DecidableEq B] {h : ℕ} + (v : WordVertex B h) (b : B) (p : PositionPair h) : vertexSwap v b p ≠ v := by + intro heq + have hh := congrArg (fun w : WordVertex B h => w b p.1.1) heq + simp only [vertexSwap, Function.update_self, Equiv.Perm.mul_apply, + Equiv.swap_apply_left] at hh + exact (ne_of_lt p.2).symm ((v b).injective hh) + +lemma vertexSwap_generator_injective {B : Type*} [DecidableEq B] {h : ℕ} + (v : WordVertex B h) : + Function.Injective (fun bp : B × PositionPair h => vertexSwap v bp.1 bp.2) := by + rintro ⟨b, p⟩ ⟨c, q⟩ heq + have hbc : b = c := by + by_contra hbc + have hh := congrArg (fun w : WordVertex B h => w b p.1.1) heq + simp only [vertexSwap, Function.update_self, Function.update_of_ne hbc, + Equiv.Perm.mul_apply, Equiv.swap_apply_left] at hh + exact (ne_of_lt p.2).symm ((v b).injective hh) + subst c + have hh := congrArg (fun w : WordVertex B h => w b) heq + simp only [vertexSwap, Function.update_self] at hh + exact Prod.ext rfl (ordered_swap_injective (mul_left_cancel hh)) + +noncomputable def interaction {B : Type*} [Fintype B] [DecidableEq B] {h : ℕ} + (S : Finset B) (δ : ℝ) (v w : WordVertex B h) : ℝ := + ∑ b ∈ S, ∑ p : PositionPair h, + if w = vertexSwap v b p then δ ^ (p.1.2.val - p.1.1.val) else 0 + +lemma interaction_nonneg {B : Type*} [Fintype B] [DecidableEq B] {h : ℕ} + (S : Finset B) {δ : ℝ} (hδ : 0 ≤ δ) (v w : WordVertex B h) : + 0 ≤ interaction S δ v w := by + unfold interaction + positivity + +lemma interaction_self {B : Type*} [Fintype B] [DecidableEq B] {h : ℕ} + (S : Finset B) (δ : ℝ) (v : WordVertex B h) : interaction S δ v v = 0 := by + classical + simp [interaction, Ne.symm (vertexSwap_ne_self v _ _)] + +lemma interaction_neighbour {B : Type*} [Fintype B] [DecidableEq B] {h : ℕ} + (S : Finset B) (δ : ℝ) (v : WordVertex B h) (b : B) (hb : b ∈ S) + (p : PositionPair h) : + interaction S δ v (vertexSwap v b p) = δ ^ (p.1.2.val - p.1.1.val) := by + classical + simp only [interaction, show ∀ c q, (vertexSwap v b p = vertexSwap v c q) ↔ + b = c ∧ p = q by + intro c q + constructor + · intro hh + have hpair : (b, p) = (c, q) := vertexSwap_generator_injective v hh + exact Prod.mk.inj hpair + · rintro ⟨rfl, rfl⟩ + rfl] + simp only [ite_and] + simp [hb] + +lemma interaction_eq_zero_of_not_neighbour {B : Type*} [Fintype B] [DecidableEq B] {h : ℕ} + (S : Finset B) (δ : ℝ) (v w : WordVertex B h) + (hw : ∀ b ∈ S, ∀ p : PositionPair h, w ≠ vertexSwap v b p) : + interaction S δ v w = 0 := by + classical + apply sum_eq_zero + intro b hb + exact sum_eq_zero fun p _ => ite_eq_right (hw b hb p) + +lemma interaction_symm {B : Type*} [Fintype B] [DecidableEq B] {h : ℕ} + (S : Finset B) (δ : ℝ) (v w : WordVertex B h) : + interaction S δ v w = interaction S δ w v := by + classical + unfold interaction + apply sum_congr rfl + intro b _ + apply sum_congr rfl + intro p _ + simp only [show (w = vertexSwap v b p) ↔ (v = vertexSwap w b p) from + ⟨fun hh => ((congrArg (fun z => vertexSwap z b p) hh).trans + (vertexSwap_involutive b p v)).symm, + fun hh => ((congrArg (fun z => vertexSwap z b p) hh).trans + (vertexSwap_involutive b p w)).symm⟩] + +lemma interaction_reflect {B : Type*} [Fintype B] [DecidableEq B] {h : ℕ} + (S : Finset B) (δ : ℝ) (b : B) (α β : Fin h) (v w : WordVertex B h) : + interaction S δ (reflect b α β v) (reflect b α β w) = interaction S δ v w := by + classical + unfold interaction + apply sum_congr rfl + intro c _ + apply sum_congr rfl + intro p _ + simp only [← reflect_vertexSwap, (reflect_involutive b α β).injective.eq_iff] + +lemma cross_gap {B : Type*} [DecidableEq B] {h : ℕ} + (b c : B) (α β : Fin h) (x y : WordVertex B h) + (hx : cutPlus b α β x) (hy : cutPlus b α β y) (hxy : y ≠ x) + (p : PositionPair h) (heq : reflect b α β y = vertexSwap x c p) : + b = c ∧ ((x b).symm β).val - ((x b).symm α).val + 1 ≤ p.1.2.val - p.1.1.val := by + have hrev : (vertexSwap x c p b).symm β < (vertexSwap x c p b).symm α := by + rw [← heq] + simpa [reflect, cutPlus, Equiv.Perm.mul_def] using hy + have hbc : b = c := by + by_contra hn + simp only [vertexSwap, Function.update_of_ne hn] at hrev + exact lt_asymm hx hrev + subst c + refine ⟨rfl, ?_⟩ + rw [vertexSwap_symm_apply, vertexSwap_symm_apply] at hrev + apply swap_reverse_gap _ _ _ _ hx p.2 hrev + rintro ⟨ha, hb⟩ + apply hxy + apply (reflect_involutive b α β).injective + rw [heq, reflect_eq_positional x b α β hx] + congr 1 + apply Subtype.ext + exact Prod.ext ha hb + +abbrev CutHalf {B : Type*} {h : ℕ} (b : B) (α β : Fin h) := + {v : WordVertex B h // cutPlus b α β v} + +noncomputable def crossInteraction {B : Type*} [Fintype B] [DecidableEq B] {h : ℕ} + (S : Finset B) (δ : ℝ) (b : B) (α β : Fin h) : + Matrix (CutHalf b α β) (CutHalf b α β) ℝ := + Matrix.of fun x y => interaction S δ x.1 (reflect b α β y.1) + +lemma crossInteraction_symmetric {B : Type*} [Fintype B] [DecidableEq B] {h : ℕ} + (S : Finset B) (δ : ℝ) (b : B) (α β : Fin h) : + (crossInteraction S δ b α β).IsHermitian := by + ext x y + simp only [Matrix.conjTranspose_apply, star_trivial, crossInteraction, Matrix.of_apply] + calc + interaction S δ y.1 (reflect b α β x.1) = + interaction S δ (reflect b α β y.1) x.1 := by + rw [← interaction_reflect S δ b α β y.1 (reflect b α β x.1), + reflect_involutive b α β x.1] + _ = interaction S δ x.1 (reflect b α β y.1) := interaction_symm _ _ _ _ + +lemma crossInteraction_diagonal_lower {B : Type*} [Fintype B] [DecidableEq B] {h : ℕ} + (S : Finset B) {δ : ℝ} (hδ : 0 ≤ δ) (b : B) (hb : b ∈ S) + (α β : Fin h) (x : CutHalf b α β) : + δ ^ (((x.1 b).symm β).val - ((x.1 b).symm α).val) ≤ + crossInteraction S δ b α β x x := by + classical + let p : PositionPair h := ⟨((x.1 b).symm α, (x.1 b).symm β), x.2⟩ + let f (c : B) (q : PositionPair h) : ℝ := + if reflect b α β x.1 = vertexSwap x.1 c q then δ ^ (q.1.2.val - q.1.1.val) else 0 + have hf (c : B) (q : PositionPair h) : 0 ≤ f c q := + ite_nonneg (pow_nonneg hδ _) le_rfl + have hp : f b p ≤ ∑ q : PositionPair h, f b q := + single_le_sum (fun q _ => hf b q) (mem_univ p) + have hb' : (∑ q : PositionPair h, f b q) ≤ ∑ c ∈ S, ∑ q : PositionPair h, f c q := + single_le_sum (fun c _ => sum_nonneg fun q _ => hf c q) hb + change δ ^ _ ≤ ∑ c ∈ S, ∑ q : PositionPair h, f c q + refine le_trans ?_ (hp.trans hb') + dsimp [f] + rw [ite_eq_left (reflect_eq_positional x.1 b α β x.2)] + +lemma crossInteraction_generator_bound {B : Type*} [Fintype B] [DecidableEq B] {h : ℕ} + {δ : ℝ} (hδ : 0 ≤ δ) (hδ1 : δ ≤ 1) (b c : B) + (α β : Fin h) (x : CutHalf b α β) (p : PositionPair h) : + ∑ y ∈ univ.erase x, (if reflect b α β y.1 = vertexSwap x.1 c p then + δ ^ (p.1.2.val - p.1.1.val) else 0) ≤ + if c = b then δ ^ (((x.1 b).symm β).val - ((x.1 b).symm α).val + 1) else 0 := by + classical + by_cases hex : ∃ y ∈ (univ : Finset (CutHalf b α β)).erase x, + reflect b α β y.1 = vertexSwap x.1 c p + · obtain ⟨y, hy, heq⟩ := hex + have hyx : y.1 ≠ x.1 := fun hh => (mem_erase.mp hy).1 (Subtype.ext hh) + obtain ⟨hbc, hgap⟩ := cross_gap b c α β x.1 y.1 x.2 y.2 hyx p heq + subst c + rw [ite_eq_left rfl] + calc + _ = δ ^ (p.1.2.val - p.1.1.val) := by + rw [sum_eq_single y, ite_eq_left heq] + · intro z _ hzy + rw [ite_eq_right] + intro hz + apply hzy + apply Subtype.ext + exact (reflect_involutive b α β).injective (hz.trans heq.symm) + · exact fun hn => False.elim (hn hy) + _ ≤ _ := pow_le_pow_of_le_one hδ hδ1 hgap + · have hz : ∀ y ∈ (univ : Finset (CutHalf b α β)).erase x, + reflect b α β y.1 ≠ vertexSwap x.1 c p := by simpa using hex + rw [sum_eq_zero (fun y hy => ite_eq_right (hz y hy))] + split_ifs <;> positivity + +lemma crossInteraction_offdiag_bound {B : Type*} [Fintype B] [DecidableEq B] {h : ℕ} + (S : Finset B) {δ : ℝ} (hδ : 0 ≤ δ) (hδ1 : δ ≤ 1) (b : B) (hb : b ∈ S) + (α β : Fin h) (x : CutHalf b α β) : + ∑ y ∈ univ.erase x, |crossInteraction S δ b α β x y| ≤ + (h : ℝ) ^ 2 * δ ^ (((x.1 b).symm β).val - ((x.1 b).symm α).val + 1) := by + classical + simp only [crossInteraction, Matrix.of_apply] + simp_rw [abs_of_nonneg (interaction_nonneg S hδ _ _)] + unfold interaction + rw [sum_comm] + conv_lhs => arg 2; ext c; rw [sum_comm] + calc + _ ≤ ∑ c ∈ S, ∑ _p : PositionPair h, + if c = b then δ ^ (((x.1 b).symm β).val - ((x.1 b).symm α).val + 1) else 0 := by + apply sum_le_sum + intro c hc + apply sum_le_sum + intro p hp + exact crossInteraction_generator_bound hδ hδ1 b c α β x p + _ = (Fintype.card (PositionPair h) : ℝ) * + δ ^ (((x.1 b).symm β).val - ((x.1 b).symm α).val + 1) := by + simp [sum_ite_eq', hb] + _ ≤ _ := by + apply mul_le_mul_of_nonneg_right _ (pow_nonneg hδ _) + have hc : Fintype.card (PositionPair h) ≤ h ^ 2 := by + have hh := Fintype.card_subtype_le (fun p : Fin h × Fin h => p.1 < p.2) + simpa [Fintype.card_prod, pow_two] using hh + exact_mod_cast hc + +lemma crossInteraction_diagonal_dominance {B : Type*} [Fintype B] [DecidableEq B] {h : ℕ} + (S : Finset B) {δ : ℝ} (hδ : 0 ≤ δ) (hδ1 : δ ≤ 1) + (hscale : (h : ℝ) ^ 2 * δ = 1 / 10) (b : B) (hb : b ∈ S) + (α β : Fin h) (x : CutHalf b α β) : + (9 / 10 : ℝ) * δ ^ (h - 1) + ∑ y ∈ univ.erase x, + |crossInteraction S δ b α β x y| ≤ crossInteraction S δ b α β x x := by + classical + let g := ((x.1 b).symm β).val - ((x.1 b).symm α).val + have hg : g ≤ h - 1 := by + have hh := ((x.1 b).symm β).isLt + dsimp [g] + omega + have hpow : δ ^ (h - 1) ≤ δ ^ g := pow_le_pow_of_le_one hδ hδ1 hg + have hoff := crossInteraction_offdiag_bound S hδ hδ1 b hb α β x + have hdiag := crossInteraction_diagonal_lower S hδ b hb α β x + have heq : (h : ℝ) ^ 2 * δ ^ (g + 1) = (1 / 10 : ℝ) * δ ^ g := by + rw [pow_succ] + calc + (h : ℝ) ^ 2 * (δ ^ g * δ) = ((h : ℝ) ^ 2 * δ) * δ ^ g := by ring + _ = _ := by rw [hscale] + change _ ≤ (h : ℝ) ^ 2 * δ ^ (g + 1) at hoff + rw [heq] at hoff + linarith + +def tupleH : ℕ := 24 + +def tupleT : ℕ := 80 + +def tupleBlocks : ℕ := 2 * tupleT + 1 + +noncomputable def tupleDelta : ℝ := 1 / (10 * (tupleH : ℝ) ^ 2) + +noncomputable def tupleKappa : ℝ := (9 / 10) * tupleDelta ^ (tupleH - 1) + +lemma tupleDelta_pos : 0 < tupleDelta := by norm_num [tupleDelta, tupleH] + +lemma tupleDelta_le_one : tupleDelta ≤ 1 := by norm_num [tupleDelta, tupleH] + +lemma tupleDelta_scale : (tupleH : ℝ) ^ 2 * tupleDelta = 1 / 10 := by + norm_num [tupleDelta, tupleH] + +lemma tupleKappa_pos : 0 < tupleKappa := by + unfold tupleKappa + exact mul_pos (by norm_num) (pow_pos tupleDelta_pos _) + +lemma cutPlus_reflect_iff_not {B : Type*} [DecidableEq B] {h : ℕ} + (b : B) {α β : Fin h} (hαβ : α ≠ β) (v : WordVertex B h) : + cutPlus b α β (reflect b α β v) ↔ ¬ cutPlus b α β v := by + rw [reflect_cutPlus] + have hne : (v b).symm α ≠ (v b).symm β := (v b).symm.injective.ne hαβ + exact lt_iff_not_ge.trans (not_congr (le_iff_lt_or_eq.trans (or_iff_left hne))) + +noncomputable def halfSumEquiv {B : Type*} [DecidableEq B] {h : ℕ} + (b : B) {α β : Fin h} (hαβ : α ≠ β) : + CutHalf b α β ⊕ CutHalf b α β ≃ WordVertex B h where + toFun := Sum.elim Subtype.val (fun v => reflect b α β v.1) + invFun := fun v => if hp : cutPlus b α β v then Sum.inl ⟨v, hp⟩ else + Sum.inr ⟨reflect b α β v, (cutPlus_reflect_iff_not b hαβ v).mpr hp⟩ + left_inv := by + rintro (x | x) + · simp [x.2] + · have hn : ¬ cutPlus b α β (reflect b α β x.1) := by + rw [cutPlus_reflect_iff_not b hαβ] + exact not_not.mpr x.2 + simp [hn] + exact Subtype.ext (reflect_involutive b α β x.1) + right_inv := by + intro v + by_cases hv : cutPlus b α β v + · simp [hv] + · simp only [dite_eq_right hv, Sum.elim_inr] + exact reflect_involutive b α β v + +lemma card_cutHalf {B : Type*} [Fintype B] [DecidableEq B] {h : ℕ} + (b : B) {α β : Fin h} (hαβ : α ≠ β) : + 2 * Fintype.card (CutHalf b α β) = (Nat.factorial h) ^ Fintype.card B := by + classical + have hh := Fintype.card_congr (halfSumEquiv b hαβ) + simpa [Fintype.card_sum, Fintype.card_fun, Fintype.card_perm, two_mul] using hh + +def addressEdge {B G : Type*} [Fintype B] [DecidableEq G] [Group G] + (c : G) (T : ℕ) (u v : B → G) : Prop := + T ≤ (univ.filter fun b => v b = u b * c).card + +lemma addressEdge_irrefl {B G : Type*} [Fintype B] [DecidableEq G] [Group G] + {c : G} (hc : c ≠ 1) {T : ℕ} (hT : 0 < T) (u : B → G) : ¬ addressEdge c T u u := by + have hh (b : B) : u b ≠ u b * c := by + intro hh + apply hc + exact (mul_left_cancel (show u b * c = u b * 1 by simpa using hh.symm)) + simp [addressEdge, hh, hT.not_ge] + +lemma addressEdge_asymm {B G : Type*} [Fintype B] [DecidableEq G] [Group G] + {c : G} (hc : c ^ 2 ≠ 1) {T : ℕ} (hT : Fintype.card B < 2 * T) + {u v : B → G} (huv : addressEdge c T u v) : ¬ addressEdge c T v u := by + classical + intro hvu + let s := univ.filter fun b : B => v b = u b * c + let t := univ.filter fun b : B => u b = v b * c + have hdis : Disjoint s t := by + rw [disjoint_left] + intro b hbs hbt + have hs : v b = u b * c := (mem_filter.mp hbs).2 + have ht : u b = v b * c := (mem_filter.mp hbt).2 + apply hc + apply mul_left_cancel (a := u b) + calc + u b * c ^ 2 = (u b * c) * c := by rw [pow_two, mul_assoc] + _ = u b := by rw [← hs, ← ht] + _ = u b * 1 := (mul_one _).symm + have hcard : s.card + t.card ≤ Fintype.card B := by + rw [← card_union_of_disjoint hdis] + exact card_le_univ _ + change T ≤ s.card at huv + change T ≤ t.card at hvu + omega + +lemma addressEdge_left_translate {B G : Type*} [Fintype B] [DecidableEq G] [Group G] + (c : G) (T : ℕ) (a u v : B → G) : + addressEdge c T (fun b => a b * u b) (fun b => a b * v b) ↔ addressEdge c T u v := by + simp only [addressEdge, mul_assoc, mul_right_inj] + +lemma addressEdge_mono_blocks {B C G : Type*} [Fintype B] [Fintype C] + [DecidableEq G] [Group G] (c : G) (T : ℕ) (f : B ↪ C) (u v : C → G) + (hedge : addressEdge c T (u ∘ f) (v ∘ f)) : addressEdge c T u v := by + classical + apply le_trans hedge + apply card_le_card_of_injOn f + · intro b hb + simpa using hb + · exact f.injective.injOn + +lemma addressEdge_full_shift {B G : Type*} [Fintype B] [DecidableEq G] [Group G] + (c : G) (T : ℕ) (hT : T ≤ Fintype.card B) (u : B → G) : + addressEdge c T u (fun b => u b * c) := by + simpa [addressEdge] using hT + +lemma crossInteraction_gap {B : Type*} [Fintype B] [DecidableEq B] + (S : Finset B) (b : B) (hb : b ∈ S) (α β : Fin tupleH) : + (crossInteraction S tupleDelta b α β - tupleKappa • 1).PosSemidef := by + classical + apply matrix_gap_of_diagonal_dominance (crossInteraction_symmetric S tupleDelta b α β) + exact crossInteraction_diagonal_dominance S tupleDelta_pos.le tupleDelta_le_one + tupleDelta_scale b hb α β + +lemma marked_interaction_index_average {B : Type*} [Fintype B] [DecidableEq B] + {J : Type*} [Fintype J] [DecidableEq J] + (S : Finset B) (b : B) (hb : b ∈ S) (α β : Fin tupleH) + (a f : (CutHalf b α β → J) → ℝ) (ha : ∀ j, 1 ≤ a j) : + ((Real.exp tupleKappa - 1) ^ Fintype.card (CutHalf b α β) / + (Fintype.card J : ℝ) ^ Fintype.card (CutHalf b α β)) * + (𝔼 j : CutHalf b α β → J, (f j) ^ 2) ≤ + 𝔼 j : CutHalf b α β → J, 𝔼 k : CutHalf b α β → J, + (a j * f j) * Real.exp (indexCross (crossInteraction S tupleDelta b α β) j k) * + (a k * f k) := by + exact marked_index_average _ tupleKappa tupleKappa_pos.le + (crossInteraction_gap S b hb α β) a f ha + +end SquareDifference +end + +end OAI diff --git a/lean/OAI/Combinatorics/SquareDifference/MixedCrude.lean b/lean/OAI/Combinatorics/SquareDifference/MixedCrude.lean new file mode 100644 index 0000000000000000000000000000000000000000..acd16a7c632b639f31bfd10bdb93aca5815faaf6 --- /dev/null +++ b/lean/OAI/Combinatorics/SquareDifference/MixedCrude.lean @@ -0,0 +1,55 @@ +import OAI.Combinatorics.SquareDifference.ExceptionalBudget + +namespace OAI + +section + +open Finset Filter + +open scoped BigOperators Topology + +namespace SquareDifference + +open LiftTheory.SquareDifference + +lemma crude_rpow_identity (d N : ℕ) (C b η : ℝ) : + η*(2*(C*(N:ℝ)^b)^(2*d))=η*((2*C^(2*d))*(N:ℝ)^(2*(d:ℝ)*b)) := by + rw [mul_pow,←Real.rpow_mul_natCast (Nat.cast_nonneg _)] + have he : b*((2*d:ℕ):ℝ)=2*(d:ℝ)*b := by push_cast; ring + rw [he] + ring + +lemma source_mixed_crude (M : ℕ) : + ∃C : ℝ,0 actualTruncatedLift p N (powerCutoff N sourceBeta) (smallResidueInput M A (s v)))|≤ + exceptionalProduct p B*(C*(N:ℝ)^(2*(Fintype.card TupleVertex:ℝ)*sourceLoss (Fintype.card TupleVertex))) := by + let d := Fintype.card TupleVertex + obtain ⟨C,hC,hb⟩ := uniform_partial_lift_moments (sourceLoss d) (sourceLoss_pos d) + let C' := C*(M:ℝ)+1 + have hC' : 1≤C' := by dsimp [C']; nlinarith [Nat.cast_nonneg (α:=ℝ) M] + refine ⟨2*C'^(2*d),mul_pos (by norm_num) (pow_pos (lt_of_lt_of_le zero_lt_one hC') _),?_⟩ + filter_upwards [eventual_cutoff_size sourceBeta sourceBeta_pos (by norm_num [sourceBeta]),eventually_ge_atTop 1] with N hsz hN + intro J _ _ p _ hinj hp B A s + have hR : 1≤C'*(N:ℝ)^(sourceLoss d) := one_le_mul_of_one_le_of_one_le hC' + (Real.one_le_rpow (by exact_mod_cast hN) (sourceLoss_pos d).le) + have hm (v : TupleVertex) (r : ℕ) (hr : r+1=d) : + (𝔼 x,actualTruncatedLift p N (powerCutoff N sourceBeta) (smallResidueInput M A (s v)) x^(2*r))≤ + (C'*(N:ℝ)^(sourceLoss d))^(2*r) := by + apply (hb p hinj N (powerCutoff N sourceBeta) N hsz + (powerCutoff_le_self N hN sourceBeta sourceBeta_le) _ M (Nat.cast_nonneg _) + (fun n _ => smallResidueInput_bound M A (s v) n) _ (Subset.refl _) r (Or.inr hr)).trans + apply pow_le_pow_left₀ (mul_nonneg (mul_nonneg hC.le (Nat.cast_nonneg _)) (Real.rpow_nonneg (Nat.cast_nonneg _) _)) + apply mul_le_mul_of_nonneg_right _ (Real.rpow_nonneg (Nat.cast_nonneg _) _) + dsimp [C']; linarith + have hh := actualMixedLaw_crude p hp B _ _ hR hm + exact hh.trans_eq (crude_rpow_identity d N C' (sourceLoss d) (exceptionalProduct p B)) + +end SquareDifference + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SquareDifference/MixedEnergy.lean b/lean/OAI/Combinatorics/SquareDifference/MixedEnergy.lean new file mode 100644 index 0000000000000000000000000000000000000000..0dcd4aa342aae112cc81fc95e9efde8a45753db1 --- /dev/null +++ b/lean/OAI/Combinatorics/SquareDifference/MixedEnergy.lean @@ -0,0 +1,505 @@ +import OAI.Combinatorics.SquareDifference.GaussSum + +namespace OAI + +section +open Finset +open scoped BigOperators +namespace SquareDifference + +def directedCrossEdge {I J A B : Type*} (dir : I → J → Bool) + (e : (I × J) × (A × B)) : ((I × A) ⊕ (J × B)) × ((I × A) ⊕ (J × B)) := + if dir e.1.1 e.1.2 then + (Sum.inl (e.1.1, e.2.1), Sum.inr (e.1.2, e.2.2)) + else (Sum.inr (e.1.2, e.2.2), Sum.inl (e.1.1, e.2.1)) + +lemma directedCrossEdge_injective {I J A B : Type*} (dir : I → J → Bool) : + Function.Injective (directedCrossEdge (A := A) (B := B) dir) := by + rintro ⟨⟨i,j⟩,⟨a,b⟩⟩ ⟨⟨i',j'⟩,⟨a',b'⟩⟩ h + dsimp [directedCrossEdge] at h + split_ifs at h <;> simp_all only [Prod.mk.injEq, Sum.inl.injEq, Sum.inr.injEq, + Sum.inl_ne_inr, Sum.inr_ne_inl, and_false] + +lemma directedCrossEdge_noloop {I J A B : Type*} (dir : I → J → Bool) + (e : (I × J) × (A × B)) : + (directedCrossEdge dir e).1 ≠ (directedCrossEdge dir e).2 := by + dsimp [directedCrossEdge] + split_ifs <;> simp + +lemma directedCrossEdge_noopp {I J A B : Type*} (dir : I → J → Bool) + (e e' : (I × J) × (A × B)) : + directedCrossEdge dir e' ≠ ((directedCrossEdge dir e).2, (directedCrossEdge dir e).1) := by + rcases e with ⟨⟨i,j⟩,⟨a,b⟩⟩ + rcases e' with ⟨⟨i',j'⟩,⟨a',b'⟩⟩ + dsimp [directedCrossEdge] + split_ifs <;> simp_all only [Prod.mk.injEq, Sum.inl.injEq, Sum.inr.injEq, + Sum.inl_ne_inr, Sum.inr_ne_inl, and_false, not_false_eq_true] + all_goals rintro ⟨⟨hi,ha⟩,⟨hj,hb⟩⟩; subst_vars; simp_all + +noncomputable def listKernel {I J : Type*} {p : ℕ} [Fact p.Prime] + (E : Finset (I × J)) (dir : I → J → Bool) (x : I → ZMod p) (y : J → ZMod p) : ℝ := + ∏ e ∈ E, if dir e.1 e.2 then squareIndicator (y e.2 - x e.1) + else squareIndicator (x e.1 - y e.2) + +lemma copied_graph_count {I J A B : Type*} + [Fintype I] [Fintype J] [Fintype A] [Fintype B] + [DecidableEq I] [DecidableEq J] [DecidableEq A] [DecidableEq B] + {p : ℕ} [Fact p.Prime] (hp : p ≠ 2) + (E : Finset (I × J)) (dir : I → J → Bool) (F : Finset (A × B)) : + |(𝔼 z : (I × A) ⊕ (J × B) → ZMod p, + ∏ ab ∈ F, listKernel E dir (fun i => z (Sum.inl (i, ab.1))) + (fun j => z (Sum.inr (j, ab.2)))) - (1 / 2 : ℝ) ^ (E.card * F.card)| ≤ + (E.card * F.card : ℕ) * ((Real.sqrt p + 1) / (2 * p)) := by + classical + let G := (E ×ˢ F).image (directedCrossEdge dir) + have hnoloop : ∀ e ∈ G, e.1 ≠ e.2 := by + intro e he + obtain ⟨a, _, rfl⟩ := mem_image.mp he + exact directedCrossEdge_noloop dir a + have hnoopp : ∀ e ∈ G, (e.2, e.1) ∉ G := by + intro e he h + obtain ⟨a, _, rfl⟩ := mem_image.mp he + obtain ⟨a', _, ha'⟩ := mem_image.mp h + exact directedCrossEdge_noopp dir a a' ha' + have hc : G.card = E.card * F.card := by + rw [card_image_of_injective _ (directedCrossEdge_injective dir), card_product] + have hprod (z : (I × A) ⊕ (J × B) → ZMod p) : + (∏ e ∈ G, squareIndicator (z e.2 - z e.1)) = + ∏ ab ∈ F, listKernel E dir (fun i => z (Sum.inl (i, ab.1))) + (fun j => z (Sum.inr (j, ab.2))) := by + rw [prod_image (directedCrossEdge_injective dir).injOn, prod_product, prod_comm] + apply prod_congr rfl + intro ab _ + dsimp [listKernel] + apply prod_congr rfl + intro ij _ + dsimp [directedCrossEdge] + split_ifs <;> rfl + have h := graph_count hp G hnoloop hnoopp + simpa only [hc, hprod] using h + +lemma centered_product_moment_bound {T X : Type*} [Fintype X] [Nonempty X] + [DecidableEq T] (S : Finset T) (hS : S.Nonempty) (K : T → X → ℝ) + {c δ : ℝ} (hc : |c| ≤ 1) (hδ : 0 ≤ δ) + (hmom : ∀ F ⊆ S, |(𝔼 x : X, ∏ i ∈ F, K i x) - c ^ F.card| ≤ F.card * δ) : + |𝔼 x : X, ∏ i ∈ S, (K i x - c)| ≤ + (∑ F ∈ S.powerset, (F.card : ℝ)) * δ := by + classical + have hmain : (∑ F ∈ S.powerset, c ^ F.card * (-c) ^ (S \ F).card) = 0 := by + have h := prod_add (fun _ : T => c) (fun _ : T => -c) S + simpa [hS.card_pos.ne'] using h.symm + have hexpand : (𝔼 x : X, ∏ i ∈ S, (K i x - c)) = + ∑ F ∈ S.powerset, (𝔼 x : X, ∏ i ∈ F, K i x) * (-c) ^ (S \ F).card := by + simp_rw [sub_eq_add_neg, prod_add, prod_const, expect_sum_comm, ← expect_mul] + rw [hexpand, ← sub_zero (∑ F ∈ S.powerset, + (𝔼 x : X, ∏ i ∈ F, K i x) * (-c) ^ (S \ F).card), ← hmain, ← sum_sub_distrib] + simp_rw [← sub_mul] + calc + _ ≤ ∑ F ∈ S.powerset, + |((𝔼 x : X, ∏ i ∈ F, K i x) - c ^ F.card) * (-c) ^ (S \ F).card| := + abs_sum_le_sum_abs _ _ + _ ≤ ∑ F ∈ S.powerset, (F.card : ℝ) * δ := by + apply sum_le_sum + intro F hF + rw [abs_mul] + have hpow : |(-c) ^ (S \ F).card| ≤ 1 := by + rw [abs_pow, abs_neg] + exact pow_le_one₀ (abs_nonneg _) hc + calc + _ ≤ (F.card * δ) * 1 := + mul_le_mul (hmom F (mem_powerset.mp hF)) hpow (abs_nonneg _) + (mul_nonneg (Nat.cast_nonneg _) hδ) + _ = _ := mul_one _ + _ = _ := (sum_mul _ _ _).symm + +def fourListsEquiv (I J X : Type*) : + ((I × Bool) ⊕ (J × Bool) → X) ≃ ((I → X) × (I → X)) × ((J → X) × (J → X)) where + toFun z := ((fun i => z (.inl (i, false)), fun i => z (.inl (i, true))), + (fun j => z (.inr (j, false)), fun j => z (.inr (j, true)))) + invFun z := fun w => match w with + | .inl (i, false) => z.1.1 i + | .inl (i, true) => z.1.2 i + | .inr (j, false) => z.2.1 j + | .inr (j, true) => z.2.2 j + left_inv z := by funext w; rcases w with ⟨i, b⟩ | ⟨j, b⟩ <;> cases b <;> rfl + right_inv z := rfl + +lemma expect_fourLists {I J X : Type*} [Fintype I] [Fintype J] [Fintype X] + [DecidableEq I] [DecidableEq J] + (H : (I → X) → (I → X) → (J → X) → (J → X) → ℝ) : + (𝔼 z : (I × Bool) ⊕ (J × Bool) → X, + H (fun i => z (.inl (i, false))) (fun i => z (.inl (i, true))) + (fun j => z (.inr (j, false))) (fun j => z (.inr (j, true)))) = + 𝔼 x : I → X, 𝔼 x' : I → X, 𝔼 y : J → X, 𝔼 y' : J → X, H x x' y y' := by + classical + calc + _ = 𝔼 z : ((I → X) × (I → X)) × ((J → X) × (J → X)), + H z.1.1 z.1.2 z.2.1 z.2.2 := + Fintype.expect_equiv (fourListsEquiv I J X) _ _ (fun _ => rfl) + _ = _ := by simp_rw [← univ_product_univ, expect_product] + +lemma list_four_cycle {I J : Type*} [Fintype I] [Fintype J] + [DecidableEq I] [DecidableEq J] + {p : ℕ} [Fact p.Prime] (hp : p ≠ 2) + (E : Finset (I × J)) (dir : I → J → Bool) : + |𝔼 x : I → ZMod p, 𝔼 x' : I → ZMod p, + 𝔼 y : J → ZMod p, 𝔼 y' : J → ZMod p, + (listKernel E dir x y - (1 / 2 : ℝ) ^ E.card) * + (listKernel E dir x y' - (1 / 2 : ℝ) ^ E.card) * + (listKernel E dir x' y - (1 / 2 : ℝ) ^ E.card) * + (listKernel E dir x' y' - (1 / 2 : ℝ) ^ E.card)| ≤ + 32 * E.card * ((Real.sqrt p + 1) / (2 * p)) := by + classical + let S : Finset (Bool × Bool) := univ + let K (ab : Bool × Bool) (z : (I × Bool) ⊕ (J × Bool) → ZMod p) := + listKernel E dir (fun i => z (.inl (i, ab.1))) (fun j => z (.inr (j, ab.2))) + have h := centered_product_moment_bound S univ_nonempty K + (c := (1 / 2 : ℝ) ^ E.card) (δ := E.card * ((Real.sqrt p + 1) / (2 * p))) + (by rw [abs_of_nonneg (by positivity)]; exact pow_le_one₀ (by norm_num) (by norm_num)) + (by positivity) (fun F _ => by + have h := copied_graph_count hp E dir F + simpa only [K, pow_mul, Nat.cast_mul, mul_assoc, mul_left_comm, mul_comm] using h) + have hsum : (∑ F ∈ S.powerset, (F.card : ℝ)) = 32 := by + rw [sum_powerset_apply_card] + norm_num [S, Fintype.card_prod, Fintype.card_bool, sum_range_succ, Nat.choose] + rw [hsum] at h + have heq : (𝔼 z : (I × Bool) ⊕ (J × Bool) → ZMod p, + ∏ ab ∈ S, (K ab z - (1 / 2 : ℝ) ^ E.card)) = + 𝔼 x : I → ZMod p, 𝔼 x' : I → ZMod p, + 𝔼 y : J → ZMod p, 𝔼 y' : J → ZMod p, + (listKernel E dir x y - (1 / 2 : ℝ) ^ E.card) * + (listKernel E dir x y' - (1 / 2 : ℝ) ^ E.card) * + (listKernel E dir x' y - (1 / 2 : ℝ) ^ E.card) * + (listKernel E dir x' y' - (1 / 2 : ℝ) ^ E.card) := by + rw [← expect_fourLists] + apply expect_congr rfl + intro z _ + simp only [S, K, Fintype.prod_prod_type, Fintype.prod_bool] + ring + rw [heq] at h + simpa only [mul_assoc] using h + +lemma square_delta_le {p : ℕ} [Fact p.Prime] : + (Real.sqrt p + 1) / (2 * p) ≤ (p : ℝ) ^ (-(1 : ℝ) / 2) := by + have hp : (0 : ℝ) < p := Nat.cast_pos.mpr (Nat.Prime.pos Fact.out) + have hp1 : (1 : ℝ) ≤ p := by exact_mod_cast (Nat.Prime.one_lt Fact.out).le + have hs : (1 : ℝ) ≤ Real.sqrt p := by simpa using Real.sqrt_le_sqrt hp1 + rw [show -(1 : ℝ) / 2 = 1 / 2 - 1 by norm_num, Real.rpow_sub hp, + Real.rpow_one, ← Real.sqrt_eq_rpow] + apply (div_le_div_iff₀ (by positivity) hp).mpr + nlinarith + +lemma list_mixing {I J : Type*} [Fintype I] [Fintype J] + [DecidableEq I] [DecidableEq J] + {p : ℕ} [Fact p.Prime] (hp : p ≠ 2) + (E : Finset (I × J)) (dir : I → J → Bool) + (f : (I → ZMod p) → ℝ) (g : (J → ZMod p) → ℝ) : + |𝔼 x : I → ZMod p, 𝔼 y : J → ZMod p, + f x * (listKernel E dir x y - (1 / 2 : ℝ) ^ E.card) * g y| ≤ + (32 * E.card : ℝ) ^ ((1 : ℝ) / 4) * (p : ℝ) ^ (-(1 : ℝ) / 8) * + Real.sqrt (𝔼 x : I → ZMod p, (f x) ^ 2) * + Real.sqrt (𝔼 y : J → ZMod p, (g y) ^ 2) := by + let B (x : I → ZMod p) (y : J → ZMod p) := + listKernel E dir x y - (1 / 2 : ℝ) ^ E.card + let C : ℝ := (32 * E.card : ℝ) ^ ((1 : ℝ) / 4) * (p : ℝ) ^ (-(1 : ℝ) / 8) + have hC : 0 ≤ C := by dsimp [C]; positivity + have hCp : C ^ 4 = 32 * E.card * (p : ℝ) ^ (-(1 : ℝ) / 2) := by + dsimp [C] + rw [mul_pow, ← Real.rpow_mul_natCast (by positivity), + ← Real.rpow_mul_natCast (by positivity)] + norm_num + have ht := list_four_cycle hp E dir + have ht' : (𝔼 x : I → ZMod p, 𝔼 x' : I → ZMod p, + 𝔼 y : J → ZMod p, 𝔼 y' : J → ZMod p, + B x y * B x y' * B x' y * B x' y') ≤ C ^ 4 := by + calc + _ ≤ |𝔼 x : I → ZMod p, 𝔼 x' : I → ZMod p, + 𝔼 y : J → ZMod p, 𝔼 y' : J → ZMod p, + B x y * B x y' * B x' y * B x' y'| := le_abs_self _ + _ ≤ 32 * E.card * ((Real.sqrt p + 1) / (2 * p)) := ht + _ ≤ 32 * E.card * (p : ℝ) ^ (-(1 : ℝ) / 2) := + mul_le_mul_of_nonneg_left square_delta_le (by positivity) + _ = _ := hCp.symm + have hF : 0 ≤ 𝔼 x : I → ZMod p, (f x) ^ 2 := + expect_nonneg (fun _ _ => sq_nonneg _) + have hG : 0 ≤ 𝔼 y : J → ZMod p, (g y) ^ 2 := + expect_nonneg (fun _ _ => sq_nonneg _) + have h4 : (𝔼 x : I → ZMod p, 𝔼 y : J → ZMod p, f x * B x y * g y) ^ 4 ≤ + (C * Real.sqrt (𝔼 x : I → ZMod p, (f x) ^ 2) * + Real.sqrt (𝔼 y : J → ZMod p, (g y) ^ 2)) ^ 4 := by + calc + _ ≤ (𝔼 x : I → ZMod p, 𝔼 x' : I → ZMod p, + 𝔼 y : J → ZMod p, 𝔼 y' : J → ZMod p, + B x y * B x y' * B x' y * B x' y') * + (𝔼 x : I → ZMod p, (f x) ^ 2) ^ 2 * + (𝔼 y : J → ZMod p, (g y) ^ 2) ^ 2 := four_cycle_bound B f g + _ ≤ C ^ 4 * (𝔼 x : I → ZMod p, (f x) ^ 2) ^ 2 * + (𝔼 y : J → ZMod p, (g y) ^ 2) ^ 2 := by gcongr + _ = _ := by + have hf4 : (Real.sqrt (𝔼 x : I → ZMod p, (f x) ^ 2)) ^ 4 = + (𝔼 x : I → ZMod p, (f x) ^ 2) ^ 2 := by + rw [show (4 : ℕ) = 2 * 2 from rfl, pow_mul, Real.sq_sqrt hF] + have hg4 : (Real.sqrt (𝔼 y : J → ZMod p, (g y) ^ 2)) ^ 4 = + (𝔼 y : J → ZMod p, (g y) ^ 2) ^ 2 := by + rw [show (4 : ℕ) = 2 * 2 from rfl, pow_mul, Real.sq_sqrt hG] + calc + _ = C ^ 4 * (Real.sqrt (𝔼 x : I → ZMod p, (f x) ^ 2)) ^ 4 * + (Real.sqrt (𝔼 y : J → ZMod p, (g y) ^ 2)) ^ 4 := by rw [hf4, hg4] + _ = _ := by ring + apply (pow_le_pow_iff_left₀ (abs_nonneg _) (by positivity) (by norm_num : (4 : ℕ) ≠ 0)).mp + have habs (a : ℝ) : |a| ^ 4 = a ^ 4 := by + rw [show (4 : ℕ) = 2 * 2 from rfl, pow_mul, sq_abs, ← pow_mul] + simpa only [habs] using h4 + +lemma posSemidef_entrywise_pow {I : Type*} [Fintype I] + {A : Matrix I I ℝ} (hA : A.PosSemidef) (k : ℕ) : + (Matrix.of fun i j => A i j ^ k).PosSemidef := by + induction k with + | zero => simpa [Matrix.vecMulVec] using Matrix.posSemidef_vecMulVec_self_star (fun _ : I => (1 : ℝ)) + | succ k hk => simpa [Matrix.hadamard, pow_succ] using hk.hadamard hA + +lemma posSemidef_entrywise_exp {I : Type*} [Fintype I] + {A : Matrix I I ℝ} (hA : A.PosSemidef) : + (Matrix.of fun i j => Real.exp (A i j)).PosSemidef := by + classical + let T (n : ℕ) : Matrix I I ℝ := + ∑ k ∈ range n, (Nat.factorial k : ℝ)⁻¹ • (Matrix.of fun i j => A i j ^ k) + have hT (n : ℕ) : (T n).PosSemidef := by + exact Matrix.posSemidef_sum (range n) fun k _ => + (posSemidef_entrywise_pow hA k).smul (by positivity) + have ht (i j : I) : Filter.Tendsto (fun n => T n i j) + Filter.atTop (nhds (Real.exp (A i j))) := by + simpa [T, Matrix.sum_apply, Matrix.smul_apply, Matrix.of_apply, Pi.smul_apply, smul_eq_mul, div_eq_mul_inv, mul_comm, Real.exp_eq_exp_ℝ] using + (NormedSpace.expSeries_div_hasSum_exp (A i j)).tendsto_sum_nat + rw [Matrix.posSemidef_iff_dotProduct_mulVec] + refine ⟨?_, fun v => ?_⟩ + · ext i j + simp only [Matrix.conjTranspose_apply, star_trivial, Matrix.of_apply] + rw [show A j i = A i j by simpa using hA.isHermitian.apply i j] + · have ht' : Filter.Tendsto (fun n => star v ⬝ᵥ (T n).mulVec v) + Filter.atTop (nhds (star v ⬝ᵥ (Matrix.of fun i j => Real.exp (A i j)).mulVec v)) := by + simp only [dotProduct, Matrix.mulVec] + apply tendsto_finsetSum + intro i _ + apply Filter.Tendsto.const_mul + apply tendsto_finsetSum + intro j _ + exact (ht i j).mul_const _ + apply ge_of_tendsto ht' + exact Filter.Eventually.of_forall fun n => + (Matrix.posSemidef_iff_dotProduct_mulVec.mp (hT n)).2 v + +lemma posSemidef_entrywise_prod {I L : Type*} [Fintype I] + (s : Finset L) (A : L → Matrix I I ℝ) (hA : ∀ l ∈ s, (A l).PosSemidef) : + (Matrix.of fun i j => ∏ l ∈ s, A l i j).PosSemidef := by + classical + induction s using Finset.induction_on with + | empty => simpa [Matrix.vecMulVec] using + Matrix.posSemidef_vecMulVec_self_star (fun _ : I => (1 : ℝ)) + | @insert l s hl hs => + simpa [prod_insert hl, Matrix.hadamard] using + (hA l (mem_insert_self _ _)).hadamard + (hs fun k hk => hA k (mem_insert_of_mem hk)) + +lemma posSemidef_product_gap {I L : Type*} [Fintype I] + (s : Finset L) (a : L → ℝ) (A : L → Matrix I I ℝ) + (ha : ∀ l ∈ s, 0 ≤ a l) (hA : ∀ l ∈ s, (A l).PosSemidef) : + (Matrix.of fun i j => (∏ l ∈ s, (1 + a l * A l i j)) - + (∏ l ∈ s, a l) * (∏ l ∈ s, A l i j)).PosSemidef := by + classical + have hOne : (Matrix.of fun _ _ : I => (1 : ℝ)).PosSemidef := by + simpa [Matrix.vecMulVec] using Matrix.posSemidef_vecMulVec_self_star (fun _ : I => (1 : ℝ)) + induction s using Finset.induction_on with + | empty => + convert (Matrix.PosSemidef.zero : (0 : Matrix I I ℝ).PosSemidef) using 1 + ext i j + simp + | @insert l s hl hs => + have hal := ha l (mem_insert_self _ _) + have hAl := hA l (mem_insert_self _ _) + have has : ∀ k ∈ s, 0 ≤ a k := fun k hk => ha k (mem_insert_of_mem hk) + have hAs : ∀ k ∈ s, (A k).PosSemidef := fun k hk => hA k (mem_insert_of_mem hk) + have hfactors (k : L) (hk : k ∈ s) : + (Matrix.of fun i j => 1 + a k * A k i j).PosSemidef := by + convert hOne.add ((hAs k hk).smul (has k hk)) using 1 + ext i j + simp [Matrix.add_apply, Matrix.smul_apply] + have hc := posSemidef_entrywise_prod s + (fun k => Matrix.of fun i j => 1 + a k * A k i j) hfactors + have hd := hc.add ((hAl.hadamard (hs has hAs)).smul hal) + convert hd using 1 + ext i j + simp only [Matrix.of_apply, prod_insert hl, Matrix.add_apply, Matrix.smul_apply, + Matrix.hadamard_apply, smul_eq_mul] + ring + +lemma posSemidef_equality {I J : Type*} [Fintype I] [DecidableEq J] + (f : I → J) : (Matrix.of fun i j => if f i = f j then (1 : ℝ) else 0).PosSemidef := by + have hd : (Matrix.diagonal (fun _ : J => (1 : ℝ))).PosSemidef := + Matrix.posSemidef_diagonal_iff.mpr (fun _ => zero_le_one) + simpa [Matrix.submatrix, Matrix.diagonal_apply] using hd.submatrix f + +lemma posSemidef_exp_agreement_gap {I J : Type*} [Fintype I] [Fintype J] + [DecidableEq J] (κ : ℝ) (hκ : 0 ≤ κ) : + (Matrix.of fun j k : I → J => + Real.exp (κ * ∑ x : I, if j x = k x then (1 : ℝ) else 0) - + (Real.exp κ - 1) ^ Fintype.card I * (if j = k then 1 else 0)).PosSemidef := by + classical + have h := posSemidef_product_gap (univ : Finset I) (fun _ => Real.exp κ - 1) + (fun x => Matrix.of fun j k : I → J => if j x = k x then (1 : ℝ) else 0) + (fun _ _ => sub_nonneg.mpr (Real.one_le_exp_iff.mpr hκ)) + (fun x _ => posSemidef_equality (fun j : I → J => j x)) + convert h using 1 + ext j k + simp only [Matrix.of_apply, prod_const, card_univ, prod_boole, mem_univ, forall_true_left] + simp only [← funext_iff] + congr 1 + rw [mul_sum, Real.exp_sum] + apply prod_congr rfl + intro x _ + split_ifs with hx <;> simp + +lemma posSemidef_gram {I K : Type*} [Fintype I] [Fintype K] + {A : Matrix I I ℝ} (hA : A.PosSemidef) (v : K → I → ℝ) : + (Matrix.of fun j k => ∑ x : I, ∑ y : I, v j x * A x y * v k y).PosSemidef := by + convert hA.mul_mul_conjTranspose_same (Matrix.of v) using 1 + ext j k + simp only [Matrix.of_apply, Matrix.mul_apply, Matrix.conjTranspose_apply, star_trivial, + sum_mul] + rw [sum_comm] + +noncomputable def indexCross {I J : Type*} [Fintype I] [DecidableEq J] + (A : Matrix I I ℝ) (j k : I → J) : ℝ := + ∑ x : I, ∑ y : I, A x y * (if j x = k y then 1 else 0) + +lemma posSemidef_indexCross {I J : Type*} [Fintype I] [Fintype J] [DecidableEq J] + {A : Matrix I I ℝ} (hA : A.PosSemidef) : + (Matrix.of (indexCross (J := J) A)).PosSemidef := by + classical + have h (a : J) := posSemidef_gram hA (fun j : I → J => + fun x => if j x = a then (1 : ℝ) else 0) + convert Matrix.posSemidef_sum univ (fun a _ => h a) using 1 + ext j k + simp only [Matrix.of_apply, Matrix.sum_apply, indexCross] + symm + rw [sum_comm] + apply sum_congr rfl + intro x _ + rw [sum_comm] + apply sum_congr rfl + intro y _ + simp [ite_mul, mul_ite, eq_comm] + +lemma indexCross_sub_scalar_one {I J : Type*} [Fintype I] [DecidableEq I] [DecidableEq J] + (A : Matrix I I ℝ) (κ : ℝ) (j k : I → J) : + indexCross (A - κ • 1) j k = indexCross A j k - + κ * ∑ x : I, if j x = k x then (1 : ℝ) else 0 := by + simp only [indexCross, Matrix.sub_apply, Matrix.smul_apply, Matrix.one_apply, + smul_eq_mul, sub_mul, sum_sub_distrib] + congr 1 + have hxy (x y : I) : κ * (if x = y then (1 : ℝ) else 0) * + (if j x = k y then 1 else 0) = + if y = x then κ * (if j x = k x then 1 else 0) else 0 := by + by_cases h : y = x + · subst y; simp + · simp [h, Ne.symm h] + simp_rw [hxy] + simp only [sum_ite_eq', mem_univ, ite_true] + rw [mul_sum] + +lemma exponential_index_matrix_lower {I J : Type*} [Fintype I] [Fintype J] + [DecidableEq I] [DecidableEq J] (A : Matrix I I ℝ) (κ : ℝ) (hκ : 0 ≤ κ) + (hA : (A - κ • 1).PosSemidef) : + (Matrix.of (fun j k : I → J => Real.exp (indexCross A j k)) - + (Real.exp κ - 1) ^ Fintype.card I • 1).PosSemidef := by + classical + let lam := (Real.exp κ - 1) ^ Fintype.card I + let D := Matrix.of (indexCross (J := J) (A - κ • 1)) + let R := Matrix.of (fun j k => Real.exp (D j k)) + have hD : D.PosSemidef := posSemidef_indexCross hA + have hR : R.PosSemidef := posSemidef_entrywise_exp hD + have hlam : 0 ≤ lam := pow_nonneg (sub_nonneg.mpr (Real.one_le_exp_iff.mpr hκ)) _ + have hdiag : (Matrix.diagonal (fun j => lam * (R j j - 1))).PosSemidef := by + apply Matrix.posSemidef_diagonal_iff.mpr + intro j + apply mul_nonneg hlam + exact sub_nonneg.mpr (Real.one_le_exp_iff.mpr hD.diag_nonneg) + let E := Matrix.of fun j k : I → J => + Real.exp (κ * ∑ x : I, if j x = k x then (1 : ℝ) else 0) - + lam * (if j = k then 1 else 0) + have hE : E.PosSemidef := posSemidef_exp_agreement_gap κ hκ + have hmat : (Matrix.of (fun j k : I → J => Real.exp (indexCross A j k)) - + lam • 1) = E.hadamard R + Matrix.diagonal (fun j => lam * (R j j - 1)) := by + ext j k + simp only [Matrix.sub_apply, Matrix.smul_apply, Matrix.one_apply, Matrix.of_apply, + Matrix.add_apply, Matrix.hadamard_apply, Matrix.diagonal_apply, smul_eq_mul] + have he : Real.exp (indexCross A j k) = + Real.exp (κ * ∑ x : I, if j x = k x then (1 : ℝ) else 0) * R j k := by + dsimp [R, D] + rw [indexCross_sub_scalar_one, Real.exp_sub] + field_simp + rw [he] + dsimp only [E, Matrix.of_apply] + by_cases hjk : j = k + · subst k + simp only [ite_true] + ring + · simp only [hjk, ite_false, mul_zero, sub_zero, add_zero] + change (Matrix.of (fun j k : I → J => Real.exp (indexCross A j k)) - + lam • (1 : Matrix (I → J) (I → J) ℝ)).PosSemidef + rw [hmat] + exact (hE.hadamard hR).add hdiag + +lemma posSemidef_of_diagonal_dominance {I : Type*} [Fintype I] [DecidableEq I] + {A : Matrix I I ℝ} (hA : A.IsHermitian) + (hdom : ∀ i, ∑ j ∈ univ.erase i, |A i j| ≤ A i i) : A.PosSemidef := by + rw [hA.posSemidef_iff_eigenvalues_nonneg] + intro i + have hμ : Module.End.HasEigenvalue (Matrix.toLin' A) (hA.eigenvalues i) := by + apply Module.End.HasEigenvalue.of_mem_spectrum + change hA.eigenvalues i ∈ spectrum ℝ (Matrix.toLinAlgEquiv' A) + rw [AlgEquiv.spectrum_eq] + exact hA.eigenvalues_mem_spectrum_real i + obtain ⟨k, hk⟩ := eigenvalue_mem_ball hμ + simp only [Metric.mem_closedBall, Real.dist_eq, Real.norm_eq_abs] at hk + have ht := (abs_le.mp hk).1 + have hd := hdom k + change 0 ≤ hA.eigenvalues i + linarith + +lemma matrix_gap_of_diagonal_dominance {I : Type*} [Fintype I] [DecidableEq I] + {A : Matrix I I ℝ} (hA : A.IsHermitian) (κ : ℝ) + (hdom : ∀ i, κ + ∑ j ∈ univ.erase i, |A i j| ≤ A i i) : + (A - κ • 1).PosSemidef := by + apply posSemidef_of_diagonal_dominance + (hA.sub (Matrix.isHermitian_one.smul (by simp [IsSelfAdjoint]))) + intro i + calc + ∑ j ∈ univ.erase i, |(A - κ • 1) i j| = ∑ j ∈ univ.erase i, |A i j| := by + apply sum_congr rfl + intro j hj + have hji := (mem_erase.mp hj).1 + simp [Matrix.sub_apply, Matrix.smul_apply, Ne.symm hji] + _ ≤ A i i - κ := by linarith [hdom i] + _ = (A - κ • 1) i i := by simp + +lemma matrix_lower_quadratic {I : Type*} [Fintype I] [DecidableEq I] + {C : Matrix I I ℝ} {lam : ℝ} (hC : (C - lam • 1).PosSemidef) (v : I → ℝ) : + lam * ∑ i, (v i) ^ 2 ≤ ∑ i, ∑ j, v i * C i j * v j := by + have h := hC.dotProduct_mulVec_nonneg v + rw [Matrix.sub_mulVec, dotProduct_sub] at h + have hid : star v ⬝ᵥ (lam • (1 : Matrix I I ℝ)).mulVec v = lam * ∑ i, (v i) ^ 2 := by + simp only [Matrix.smul_mulVec, Matrix.one_mulVec, star_trivial, dotProduct, + Pi.smul_apply, smul_eq_mul, mul_sum] + apply sum_congr rfl + intro i _ + ring + have hc : star v ⬝ᵥ C.mulVec v = ∑ i, ∑ j, v i * C i j * v j := by + simp only [star_trivial, dotProduct, Matrix.mulVec, mul_sum, mul_assoc] + rw [hid, hc] at h + linarith + +end SquareDifference +end + +end OAI diff --git a/lean/OAI/Combinatorics/SquareDifference/MixedTransfer.lean b/lean/OAI/Combinatorics/SquareDifference/MixedTransfer.lean new file mode 100644 index 0000000000000000000000000000000000000000..20188f7e605917edff3ddb08dd7fc9ef7b2d4b2b --- /dev/null +++ b/lean/OAI/Combinatorics/SquareDifference/MixedTransfer.lean @@ -0,0 +1,92 @@ +import OAI.Combinatorics.SquareDifference.ExceptionalBasics + +namespace OAI + +section + +open Finset Filter + +open scoped BigOperators Topology + +namespace SquareDifference + +open LiftTheory.SquareDifference + +lemma signedHolder_uniform_bound {V X : Type*} [Fintype V] [Nonempty V] + (L : ((V → X) → ℝ) →ₗ[ℝ] ℝ) (hd : ∀g,0≤diagonalIntegral L g) + (hh : ∀F : V → X → ℝ,|multilinearIntegral L F|≤∏v,diagonalRoot L (F v)) + (F : V → X → ℝ) (K : ℝ) (hK : 0≤K) (hF : ∀v,diagonalIntegral L (F v)≤K) : + |multilinearIntegral L F|≤K := by + apply (hh F).trans + calc + _ ≤ ∏_v : V,K^(1/(Fintype.card V:ℝ)) := by + apply prod_le_prod₀ (fun v _ => diagonalRoot_nonneg L hd (F v)) + intro v _ + exact Real.rpow_le_rpow (hd _) (hF v) (by positivity) + _ = K := by + rw [prod_const,card_univ,←Real.rpow_mul_natCast hK] + rw [one_div_mul_cancel (Nat.cast_ne_zero.mpr Fintype.card_ne_zero),Real.rpow_one] + +lemma positiveLaw_const {X : Type*} (L : (X → ℝ) →ₗ[ℝ] ℝ) (c : ℝ) : L (fun _ => c)=c*L (fun _ => 1) := by + rw [show (fun _ : X => c)=c • (fun _ : X => (1:ℝ)) by ext; simp] + exact L.map_smul c (fun _ => (1:ℝ)) + +section Mixed + +variable {J : Type} [Fintype J] [DecidableEq J] (p : J → ℕ) [∀j,Fact (p j).Prime] + +lemma actualMixedLaw_freeze (hp : ∀j,tupleMassThreshold≤(p j:ℝ)) (B : Finset J) + (F : (TupleVertex → ResidueSpace p) → ℝ) : + actualMixedLaw p B (fun z => productTupleLaw p (fun x => F (fun v => freezeCoordinates B (z v) (x v))))= + actualMixedLaw p B F := by + exact tensorLaw_freeze (fun j => if j∈B then tupleExceptionalLaw (p:=p j) else tupleLaw (p:=p j)) + (fun j => tupleLaw (p:=p j)) B (fun j => tupleLaw_probability (hp j)) + (fun j hj => ite_eq_right hj) F + +lemma actualMixedLaw_transfer (hp : ∀j,tupleMassThreshold≤(p j:ℝ)) + (href : ∀j,tupleReflectionThreshold≤(p j:ℝ)) (B : Finset J) + (F : TupleVertex → ResidueSpace p → ℝ) (K : ℝ) (hK : 0≤K) + (hF : ∀(v : TupleVertex) (z : ResidueSpace p), + diagonalIntegral (productTupleLaw p) (fun x => F v (freezeCoordinates B z x))≤K) : + |multilinearIntegral (actualMixedLaw p B) F|≤exceptionalProduct p B*K := by + unfold multilinearIntegral + rw [←actualMixedLaw_freeze p hp B] + apply (positiveLaw_abs _ (actualMixedLaw_nonneg p B) _).trans + calc + _ ≤ actualMixedLaw p B (fun _ => K) := by + apply positiveLaw_mono _ (actualMixedLaw_nonneg p B) + intro z + exact signedHolder_uniform_bound _ (productTupleLaw_diagonal_nonneg p href) + (productTupleLaw_signed_holder p href) (fun v x => F v (freezeCoordinates B (z v) x)) K hK + (fun v => hF v (z v)) + _ = _ := by rw [positiveLaw_const,actualMixedLaw_mass p hp]; ring + +end Mixed + +lemma source_mixed_transfer (M : ℕ) [NeZero M] (hM2 : 2≤M) : + ∃C : ℝ,0 actualTruncatedLift p N (powerCutoff N sourceBeta) (smallResidueInput M A (s v)))|≤ + exceptionalProduct p B*(transferFactor (Fintype.card TupleVertex) M N*K+C*(N:ℝ)^(-sourceSigma (Fintype.card TupleVertex))) := by + obtain ⟨C,hC,hb⟩ := source_actual_fiber_transfer M hM2 + refine ⟨C,hC,?_⟩ + filter_upwards [hb] with N hb + intro J _ _ p _ hinj hp href hcop B hB s A hA hfree K hK hchild + exact actualMixedLaw_transfer p (fun j => (le_max_left _ _).trans (hp j)) href B _ _ + (add_nonneg (mul_nonneg (transferFactor_nonneg _ _ _) hK) (mul_nonneg hC.le (Real.rpow_nonneg (Nat.cast_nonneg N) _))) + (fun v z => hb p hinj (fun j => (le_max_right _ _).trans (hp j)) href hcop B hB (s v) z A hA hfree K hK hchild) + +end SquareDifference + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SquareDifference/OrderedBlock.lean b/lean/OAI/Combinatorics/SquareDifference/OrderedBlock.lean new file mode 100644 index 0000000000000000000000000000000000000000..f319f9452e861121d837c70799eb2ffa1a3374e1 --- /dev/null +++ b/lean/OAI/Combinatorics/SquareDifference/OrderedBlock.lean @@ -0,0 +1,90 @@ +import OAI.Combinatorics.SquareDifference.BlockParameters + +namespace OAI + +section + +open Finset + +open scoped BigOperators + +namespace SquareDifference + +open LiftTheory.SquareDifference + +noncomputable def orderedLowError (d M K H : ℕ) (R : ℝ) : ℝ := + (M:ℝ)^d*(K:ℝ)^(3*d)*(H:ℝ)^(-(1:ℝ)/3)*((K:ℝ)^2*M*kernelAbsoluteConstant+R^2) + +lemma orderedLowError_nonneg (d M K H : ℕ) (R : ℝ) : 0≤orderedLowError d M K H R := by + unfold orderedLowError + exact mul_nonneg (mul_nonneg (mul_nonneg (pow_nonneg (Nat.cast_nonneg _) _) (pow_nonneg (Nat.cast_nonneg _) _)) + (Real.rpow_nonneg (Nat.cast_nonneg _) _)) + (add_nonneg (mul_nonneg (mul_nonneg (sq_nonneg _) (Nat.cast_nonneg _)) kernelAbsoluteConstant_nonneg) (sq_nonneg R)) + +lemma ordered_low_cost (d m M N L K H : ℕ) (hm : m≤d) (hM : 1≤M) (hK : 1≤K) + (hNL : (N:ℝ)/L≤K) (R : ℝ) : + ((M:ℝ)*(K:ℝ)^2)^m*((K:ℝ)^d*(H:ℝ)^(-(1:ℝ)/3)* + (((N:ℝ)/L)^2*M*kernelAbsoluteConstant+R^2))≤orderedLowError d M K H R := by + have hb : 1≤(M:ℝ)*(K:ℝ)^2 := one_le_mul_of_one_le_of_one_le (by exact_mod_cast hM) (one_le_pow₀ (by exact_mod_cast hK)) + have hn : 0≤(N:ℝ)/L := by positivity + have hs : ((N:ℝ)/L)^2*M*kernelAbsoluteConstant+R^2≤(K:ℝ)^2*M*kernelAbsoluteConstant+R^2 := by + exact add_le_add (mul_le_mul_of_nonneg_right (mul_le_mul_of_nonneg_right (pow_le_pow_left₀ hn hNL 2) + (Nat.cast_nonneg M)) kernelAbsoluteConstant_nonneg) le_rfl + calc + _ ≤ ((M:ℝ)*(K:ℝ)^2)^d*((K:ℝ)^d*(H:ℝ)^(-(1:ℝ)/3)* + ((K:ℝ)^2*M*kernelAbsoluteConstant+R^2)) := by + apply mul_le_mul (pow_le_pow_right₀ hb hm) _ (by + exact mul_nonneg (mul_nonneg (pow_nonneg (Nat.cast_nonneg _) _) (Real.rpow_nonneg (Nat.cast_nonneg _) _)) + (add_nonneg (mul_nonneg (mul_nonneg (sq_nonneg _) (Nat.cast_nonneg _)) kernelAbsoluteConstant_nonneg) (sq_nonneg R))) (by positivity) + exact mul_le_mul_of_nonneg_left hs (by positivity) + _ = _ := by unfold orderedLowError; rw [mul_pow,←pow_mul,show 3*d=2*d+d by omega,pow_add]; ring + +section Ordered + +variable {S J : Type*} [Fintype S] [DecidableEq S] [Fintype J] [DecidableEq J] + (ps : S → ℕ) (p : J → ℕ) [∀i,Fact (ps i).Prime] [∀j,Fact (p j).Prime] + +lemma ordered_interval_full (hinj : Function.Injective (extendedPrime ps p)) + (hp : ∀j,64≤p j) (hmass : ∀j,max tupleMassThreshold tupleConditionalThreshold≤(p j:ℝ)) + (a : TupleVertex → ℕ) (L N Q H K : ℕ) (hN : 1≤N) (hH : 1≤H) (hK : 1≤K) + (hHQ : H*K^(Fintype.card TupleVertex)≤Q) + (hD : (smallModulus ps*(K^(Fintype.card TupleVertex)):ℝ)≤(N:ℝ)^((1:ℝ)/1000)) + (hHn : (H:ℝ)≤(N:ℝ)^((1:ℝ)/1000)) (hlarge : 8≤(N:ℝ)^((1:ℝ)/16)) + (hcover : ∀r : ℕ,r.Prime → r≤N → ∃i,extendedPrime ps p i=r) + (A : Finset ℕ) (hA : A⊆range N) (hfree : NatSquareFree A) + (s : TupleVertex → ZMod (smallModulus ps)) (k : ℕ) + (hab : a (cycleVertex k)+L≤a (cycleVertex (k+1))) + (hst : smallStrictPair ps (s (cycleVertex k)) (s (cycleVertex (k+1)))) + (hNL : (N:ℝ)/L≤K) (R : ℝ) (hR : 0≤R) + (hm : ∀v t,t⊆liftSupportFamily p Q → ∀r,r=1 ∨ r+1=Fintype.card TupleVertex → + (𝔼 x,(∑U∈t,intervalPiece p (a v) L (smallResidueInput (smallModulus ps) A (s v)) U x)^(2*r))≤R^(2*r)) : + |multilinearIntegral (tensorLaw (fun j => tupleGoodLaw (p:=p j))) + (fun v => intervalLift p (a v) L Q (smallResidueInput (smallModulus ps) A (s v)))|≤ + (Fintype.card TupleVertex:ℝ)*(K:ℝ)^(-(1:ℝ)/64)*R^(Fintype.card TupleVertex)+ + orderedLowError (Fintype.card TupleVertex) (smallModulus ps) K H R := by + have ht := interval_truncation_error p hmass a L Q K (by omega) {cycleVertex k,cycleVertex (k+1)} + (fun v => smallResidueInput (smallModulus ps) A (s v)) R hR hm + have hl := ordered_low_bound ps p hinj hp (fun j => (le_max_left _ _).trans (hmass j)) a L N Q H K + hN hH hK hHQ hD hHn hlarge hcover A hA hfree s k hab hst R + (fun v => interval_two_moment p a L Q _ R hm v _ Subset.rfl) + have hc := ordered_low_cost (Fintype.card TupleVertex) (Fintype.card (OtherVertices (cycleVertex k) (cycleVertex (k+1)))) (smallModulus ps) N L K H + (by have := otherVertices_card (cycleVertex k) (cycleVertex (k+1)) (cycleVertex_consecutive_ne k); omega) + (show 1≤ smallModulus ps from prod_pos (fun i _ => smallQuadraticModulus_pos (Fact.out : (ps i).Prime))) hK hNL R + have htri (x y : ℝ) : |x|≤|x-y|+|y| := by simpa only [sub_add_cancel] using abs_add_le (x-y) y + exact (htri _ _).trans (add_le_add ht (hl.trans hc)) + +lemma blockLift_expect (N K L Q : ℕ) (hN : 0 actualTruncatedLift p N Q (f v))= + ((K:ℝ)*L/N)^(Fintype.card V)*(𝔼 a : V → Fin K, + multilinearIntegral Llaw (fun v => intervalLift p (L*(a v).val) L Q (f v))) := by + let : NeZero K := ⟨hK.ne'⟩ + have heq : (fun v => actualTruncatedLift p N Q (f v))= + (fun v x => ((K:ℝ)*L/N)*(𝔼 i : Fin K,intervalLift p (L*i.val) L Q (f v) x)) := + funext (fun v => funext (blockLift_expect p N K L Q hN hK hL hNKL (f v) (hf v))) + rw [heq] + exact multilinearIntegral_scale_expect (I:=Fin K) Llaw (fun v (i : Fin K) => intervalLift p (L*i.val) L Q (f v)) _ + +lemma ordered_global_estimate (hinj : Function.Injective (extendedPrime ps p)) + (hp : ∀j,64≤p j) (hmass : ∀j,max tupleMassThreshold tupleConditionalThreshold≤(p j:ℝ)) + (L N Q H K : ℕ) (hN : 1≤N) (hL : 0 tupleGoodLaw (p:=p j))) + (fun v => actualTruncatedLift p N Q (smallResidueInput (smallModulus ps) A (s v)))|≤ + (2:ℝ)^(Fintype.card TupleVertex)*((K:ℝ)⁻¹*(2*R^(2*Fintype.card TupleVertex))+ + ((Fintype.card TupleVertex:ℝ)*(K:ℝ)^(-(1:ℝ)/64)*R^(Fintype.card TupleVertex)+ + orderedLowError (Fintype.card TupleVertex) (smallModulus ps) K H R)) := by + let : NeZero K := ⟨by omega⟩ + let F (a : TupleVertex → Fin K) : ℝ := multilinearIntegral (tensorLaw (fun j => tupleGoodLaw (p:=p j))) + (fun v => intervalLift p (L*(a v).val) L Q (smallResidueInput (smallModulus ps) A (s v))) + let E : ℝ := (Fintype.card TupleVertex:ℝ)*(K:ℝ)^(-(1:ℝ)/64)*R^(Fintype.card TupleVertex)+ + orderedLowError (Fintype.card TupleVertex) (smallModulus ps) K H R + have hE : 0≤E := add_nonneg (by positivity) (orderedLowError_nonneg _ _ _ _ _) + have hb : ∀a,|F a|≤2*R^(2*Fintype.card TupleVertex) := by + intro a + exact interval_multilinear_crude p hmass (fun v => L*(a v).val) L Q _ R hR (fun v => hm _ v) + have hg : ∀a,a (cycleVertex 0)≠a (cycleVertex 1) → |F a|≤E := by + intro a ha + have ha' : (a (cycleVertex 0)).val≠(a (cycleVertex 1)).val := fun h => ha (Fin.ext h) + obtain ⟨k,hk,hasc⟩ := tuple_interval_ascent (fun v => (a v).val) ha' + have hasc' : L*(a (cycleVertex k)).val+L≤L*(a (cycleVertex (k+1))).val := by + calc + _ = L*((a (cycleVertex k)).val+1) := by ring + _ ≤ _ := Nat.mul_le_mul_left _ (Nat.succ_le_of_lt hasc) + exact ordered_interval_full ps p hinj hp hmass (fun v => L*(a v).val) L N Q H K + hN hH hK hHQ hD hHn hlarge hcover A hA hfree s k hasc' (hgood k hk) hNL R (by linarith) + (fun v => hm _ v) + have hav := choice_average_bound (cycleVertex 0) (cycleVertex 1) (cycleVertex_consecutive_ne 0) + F (2*R^(2*Fintype.card TupleVertex)) E hE hb hg + simp only [Fintype.card_fin] at hav + have hid : multilinearIntegral (tensorLaw (fun j => tupleGoodLaw (p:=p j))) + (fun v => actualTruncatedLift p N Q (smallResidueInput (smallModulus ps) A (s v)))= + ((K:ℝ)*L/N)^(Fintype.card TupleVertex)*(𝔼 a,F a) := by + exact block_multilinear_identity p _ N K L Q (by omega) (by omega) hL hNKL + (fun v => smallResidueInput (smallModulus ps) A (s v)) + (fun v => smallResidueInput_zero _ N A hA _) + rw [hid,abs_mul,abs_of_nonneg (pow_nonneg (by positivity) _)] + exact mul_le_mul (pow_le_pow_left₀ (by positivity) hfac _) hav (abs_nonneg _) (by positivity) + +end Global + +end SquareDifference + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SquareDifference/OrderedLow.lean b/lean/OAI/Combinatorics/SquareDifference/OrderedLow.lean new file mode 100644 index 0000000000000000000000000000000000000000..1e9d78832013a3080e9776a66bb84669a5f11cdb --- /dev/null +++ b/lean/OAI/Combinatorics/SquareDifference/OrderedLow.lean @@ -0,0 +1,103 @@ +import OAI.Combinatorics.SquareDifference.BlockAverage + +namespace OAI + +section + +open Finset + +open scoped BigOperators + +namespace SquareDifference + +open LiftTheory.SquareDifference + +lemma kernelAbsoluteConstant_nonneg : 0≤kernelAbsoluteConstant := by + unfold kernelAbsoluteConstant + positivity + +section Low + +variable {S J : Type*} [Fintype S] [DecidableEq S] [Fintype J] [DecidableEq J] + (ps : S → ℕ) (p : J → ℕ) [∀i,Fact (ps i).Prime] [∀j,Fact (p j).Prime] + +lemma tensorGood_pair_uniform (hinj : Function.Injective (extendedPrime ps p)) + (hp : ∀j,64≤p j) (hmass : ∀j,tupleMassThreshold≤(p j:ℝ)) + (a : TupleVertex → ℕ) (L N Q H T : ℕ) (hN : 1≤N) (hH : 1≤H) (hT : 1≤T) + (hHQ : H*T^(Fintype.card TupleVertex)≤Q) + (hD : (smallModulus ps*(T^(Fintype.card TupleVertex)):ℝ)≤(N:ℝ)^((1:ℝ)/1000)) + (hHn : (H:ℝ)≤(N:ℝ)^((1:ℝ)/1000)) (hlarge : 8≤(N:ℝ)^((1:ℝ)/16)) + (hcover : ∀r : ℕ,r.Prime → r≤N → ∃i,extendedPrime ps p i=r) + (A : Finset ℕ) (hA : A⊆range N) (hfree : NatSquareFree A) + (s : TupleVertex → ZMod (smallModulus ps)) (k : ℕ) + (hab : a (cycleVertex k)+L≤a (cycleVertex (k+1))) + (hst : smallStrictPair ps (s (cycleVertex k)) (s (cycleVertex (k+1)))) + (R : ℝ) + (hm : ∀v,(𝔼 x,intervalLift p (a v) L Q (smallResidueInput (smallModulus ps) A (s v)) x^2)≤R^2) + (B : Finset J) (hB : (∏j∈B,p j)≤T^(Fintype.card (OtherVertices (cycleVertex k) (cycleVertex (k+1))))) + (z : TupleVertex → ResidueSpace p) (hz : lawDensity (tensorLaw (fun j => tupleGoodLaw (p:=p j))) z≠0) : + |tensorLaw (fun j => tupleGoodLaw (p:=p j)) (fun x => + intervalLift p (a (cycleVertex k)) L Q (smallResidueInput (smallModulus ps) A (s (cycleVertex k))) + (freezeCoordinates B (z (cycleVertex k)) (x (cycleVertex k)))* + intervalLift p (a (cycleVertex (k+1))) L Q (smallResidueInput (smallModulus ps) A (s (cycleVertex (k+1)))) + (freezeCoordinates B (z (cycleVertex (k+1))) (x (cycleVertex (k+1)))))|≤ + (T:ℝ)^(Fintype.card TupleVertex)*(H:ℝ)^(-(1:ℝ)/3)* + (((N:ℝ)/L)^2*(smallModulus ps)*kernelAbsoluteConstant+R^2) := by + have hc := otherVertices_card (cycleVertex k) (cycleVertex (k+1)) (cycleVertex_consecutive_ne k) + have hq : (∏j∈B,p j)≤T^(Fintype.card TupleVertex) := + hB.trans (Nat.pow_le_pow_right hT (by omega)) + have hq' : (∏j∈B,p j:ℝ)≤(T:ℝ)^(Fintype.card TupleVertex) := by exact_mod_cast hq + have hDB : (smallModulus ps*(∏j∈B,p j):ℝ)≤(N:ℝ)^((1:ℝ)/1000) := by + exact_mod_cast (mul_le_mul_of_nonneg_left hq' (Nat.cast_nonneg (smallModulus ps))).trans hD + have hsq := tensorGood_density_square p hmass k z hz + have hb := actual_interval_pair ps p hinj hp hmass B _ _ L N Q H hN hH hab + ((Nat.mul_le_mul_left H hq).trans hHQ) hDB hHn hlarge hcover A hA hfree + _ _ hst _ _ (fun j _ => hsq j) R (hm _) (hm _) k + apply hb.trans + exact mul_le_mul_of_nonneg_right + (mul_le_mul_of_nonneg_right hq' (Real.rpow_nonneg (Nat.cast_nonneg H) _)) + (add_nonneg (mul_nonneg (mul_nonneg (sq_nonneg _) (Nat.cast_nonneg _)) kernelAbsoluteConstant_nonneg) (sq_nonneg R)) + +lemma ordered_low_bound (hinj : Function.Injective (extendedPrime ps p)) + (hp : ∀j,64≤p j) (hmass : ∀j,tupleMassThreshold≤(p j:ℝ)) + (a : TupleVertex → ℕ) (L N Q H T : ℕ) (hN : 1≤N) (hH : 1≤H) (hT : 1≤T) + (hHQ : H*T^(Fintype.card TupleVertex)≤Q) + (hD : (smallModulus ps*(T^(Fintype.card TupleVertex)):ℝ)≤(N:ℝ)^((1:ℝ)/1000)) + (hHn : (H:ℝ)≤(N:ℝ)^((1:ℝ)/1000)) (hlarge : 8≤(N:ℝ)^((1:ℝ)/16)) + (hcover : ∀r : ℕ,r.Prime → r≤N → ∃i,extendedPrime ps p i=r) + (A : Finset ℕ) (hA : A⊆range N) (hfree : NatSquareFree A) + (s : TupleVertex → ZMod (smallModulus ps)) (k : ℕ) + (hab : a (cycleVertex k)+L≤a (cycleVertex (k+1))) + (hst : smallStrictPair ps (s (cycleVertex k)) (s (cycleVertex (k+1)))) + (R : ℝ) + (hm : ∀v,(𝔼 x,intervalLift p (a v) L Q (smallResidueInput (smallModulus ps) A (s v)) x^2)≤R^2) : + |multilinearIntegral (tensorLaw (fun j => tupleGoodLaw (p:=p j))) + (retainedIntervalLift p a L Q T {cycleVertex k,cycleVertex (k+1)} + (fun v => smallResidueInput (smallModulus ps) A (s v)))|≤ + ((smallModulus ps:ℝ)*(T:ℝ)^2)^(Fintype.card (OtherVertices (cycleVertex k) (cycleVertex (k+1))))* + ((T:ℝ)^(Fintype.card TupleVertex)*(H:ℝ)^(-(1:ℝ)/3)* + (((N:ℝ)/L)^2*(smallModulus ps)*kernelAbsoluteConstant+R^2)) := by + have hinjp : Function.Injective p := fun x y h => Sum.inr_injective (hinj h) + have he : 0≤(T:ℝ)^(Fintype.card TupleVertex)*(H:ℝ)^(-(1:ℝ)/3)* + (((N:ℝ)/L)^2*(smallModulus ps)*kernelAbsoluteConstant+R^2) := by + exact mul_nonneg (mul_nonneg (pow_nonneg (Nat.cast_nonneg _) _) (Real.rpow_nonneg (Nat.cast_nonneg _) _)) + (add_nonneg (mul_nonneg (mul_nonneg (sq_nonneg _) (Nat.cast_nonneg _)) kernelAbsoluteConstant_nonneg) (sq_nonneg R)) + have hb := interval_low_product_bound p hinjp (fun j => tupleGoodLaw (p:=p j)) + (fun _ => tupleGoodLaw_nonneg) (fun j => tupleGoodLaw_probability (hmass j)) + (cycleVertex k) (cycleVertex (k+1)) (cycleVertex_consecutive_ne k) a L + (fun v => smallResidueInput (smallModulus ps) A (s v)) (smallModulus ps) (Nat.cast_nonneg _) + (fun _ n => smallResidueInput_bound _ _ _ n) T _ (filteredFamily_card p hinjp Q T) + (fun U hU => (mem_filter.mp hU).2) _ _ _ he + (tensorGood_pair_uniform ps p hinj hp hmass a L N Q H T hN hH hT hHQ hD hHn hlarge hcover A hA hfree s k hab hst R hm) + convert hb using 1 + congr 2 + funext w + exact retainedInterval_pair p a L Q T _ _ (cycleVertex_consecutive_ne k) _ w + +end Low + +end SquareDifference + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SquareDifference/OrderedRates.lean b/lean/OAI/Combinatorics/SquareDifference/OrderedRates.lean new file mode 100644 index 0000000000000000000000000000000000000000..2416c49a61eaef60fb2233e15ce686731786fa5f --- /dev/null +++ b/lean/OAI/Combinatorics/SquareDifference/OrderedRates.lean @@ -0,0 +1,132 @@ +import OAI.Combinatorics.SquareDifference.OrderedGlobal + +namespace OAI + +section + +open Finset Filter + +open scoped Topology + +namespace SquareDifference + +lemma source_d_loss (d : ℕ) : (d:ℝ)*sourceLoss d≤ sourceGamma*sourceTau d/100 := by + unfold sourceLoss + have hd : 0<(d:ℝ)+1 := by positivity + have hf : (d:ℝ)/((d:ℝ)+1)≤1 := (div_le_one hd).mpr (by linarith) + calc + _ = sourceGamma*sourceTau d/100*((d:ℝ)/((d:ℝ)+1)) := by field_simp + _ ≤ _ := mul_le_of_le_one_right (by have := sourceGamma_pos; have := sourceTau_pos d; positivity) hf + +lemma ordered_exponent_gaps (d : ℕ) : + 2*(d:ℝ)*sourceLoss d-sourceTau d/2≤ -sourceSigma d ∧ + (d:ℝ)*sourceLoss d-sourceGamma*sourceTau d/2≤ -sourceSigma d ∧ + (3*(d:ℝ)+2)*sourceTau d-sourceBeta/9≤ -sourceSigma d ∧ + 3*(d:ℝ)*sourceTau d-sourceBeta/9+2*sourceLoss d≤ -sourceSigma d := by + have hl := source_d_loss d + have hd := source_d_tau d + have ht := sourceTau_le d + have hpos := (sourceTau_pos d).le + have he : sourceLoss d≤ sourceGamma*sourceTau d/100 := by + unfold sourceLoss + apply div_le_div_of_nonneg_left (mul_nonneg sourceGamma_pos.le hpos) (by norm_num) + have := Nat.cast_nonneg (α:=ℝ) d + linarith + unfold sourceSigma + norm_num [sourceBeta,sourceGamma] at * + constructor + · nlinarith + constructor + · nlinarith + constructor <;> nlinarith + +lemma cutoff_pow_upper (N K d : ℕ) (t : ℝ) (hN : 0 if hj : j∈B then 0 else a ⟨j,hj⟩ + +lemma outsideExtend_neg {J : Type*} + [Fintype J] + [DecidableEq J] + (p : J → ℕ) + [∀ (j : J), NeZero (p j)] + (B : Finset J) (a : ResidueSpace (OutsideModulus p B)) : + outsideExtend p B (-a)= -(outsideExtend p B a) := by + funext j + simp only [outsideExtend, Pi.neg_apply] + split_ifs <;> simp + +lemma outsideExtend_disjoint {J : Type*} + [Fintype J] + [DecidableEq J] + (p : J → ℕ) + [∀ (j : J), NeZero (p j)] + (B : Finset J) (a : ResidueSpace (OutsideModulus p B)) : + Disjoint (primeSupport p (outsideExtend p B a)) B := by + apply disjoint_left.mpr + intro j hj hB + simp [primeSupport,outsideExtend,hB] at hj + +lemma outsideExtend_char (a : ResidueSpace (OutsideModulus p B)) (x : ResidueSpace p) : + prodChar p (outsideExtend p B a) x=prodChar (OutsideModulus p B) a (outsideCoordinate p B x) := by + rw [prodChar_split p B] + have ho : outsideCoordinate p B (outsideExtend p B a)=a := by + funext j + simp only [outsideCoordinate,outsideExtend,j.property,dite_false] + have hr : rootCharacter p B (outsideExtend p B a) x=1 := by + apply prod_eq_one + intro j hj + simp only [outsideExtend,hj,dite_true,zero_mul,AddChar.map_zero_eq_one] + rw [hr,ho,one_mul] + +lemma outsideExtend_denominator {J : Type*} + [Fintype J] + [DecidableEq J] + (p : J → ℕ) + [∀ (j : J), NeZero (p j)] + (B : Finset J) (a : ResidueSpace (OutsideModulus p B)) : + supportDenominator p (outsideExtend p B a)=supportDenominator (OutsideModulus p B) a := by + unfold supportDenominator primeSupport + rw [prod_filter] + have he : (∏j,if outsideExtend p B a j≠0 then p j else 1)= + ∏j∈Bᶜ,if outsideExtend p B a j≠0 then p j else 1 := by + symm + apply prod_subset (subset_univ _) + intro j _ hj + have hB : j∈B := by simpa using hj + simp [outsideExtend,hB] + rw [he,prod_filter] + rw [prod_subtype Bᶜ (fun j => mem_compl) (fun j => if outsideExtend p B a j≠0 then p j else 1)] + apply prod_congr rfl + intro j _ + simp only [outsideExtend,j.property,dite_false,OutsideModulus] + +lemma expect_outside {E : Type*} [AddCommMonoid E] [Module ℚ≥0 E] + (f : ResidueSpace (OutsideModulus p B) → E) : + (𝔼 x : ResidueSpace p,f (outsideCoordinate p B x))=𝔼 y,f y := by + let e := Equiv.piEquivPiSubtypeProd (fun j : J => j∈B) (fun j => ZMod (p j)) + rw [Fintype.expect_equiv e (fun x => f (outsideCoordinate p B x)) (fun x => f x.2) (fun _ => rfl)] + rw [←univ_product_univ,expect_product] + simp only [Fintype.expect_const] + +noncomputable def assembleOutside (z : ResidueSpace p) (x : ResidueSpace (OutsideModulus p B)) : ResidueSpace p := + fun j => if hj : j∈B then z j else x ⟨j,hj⟩ + +lemma assembleOutside_freeze {J : Type*} + [Fintype J] + [DecidableEq J] + (p : J → ℕ) + [∀ (j : J), NeZero (p j)] + (B : Finset J) (z x : ResidueSpace p) : + assembleOutside p B z (outsideCoordinate p B x)=freezeCoordinates B z x := by + funext j + simp only [assembleOutside,outsideCoordinate,freezeCoordinates] + split_ifs <;> rfl + +lemma frozenFourier_outside (F : ResidueSpace p → ℂ) (z : ResidueSpace p) + (a : ResidueSpace (OutsideModulus p B)) : + residueFourier p (fun x => F (freezeCoordinates B z x)) (outsideExtend p B a)= + residueFourier (OutsideModulus p B) (fun x => F (assembleOutside p B z x)) a := by + simp only [residueFourier,outsideExtend_char] + rw [←expect_outside p B (fun x => F (assembleOutside p B z x)*conj (prodChar (OutsideModulus p B) a x))] + simp only [assembleOutside_freeze] + +lemma sequenceCoeff_outside (L : ℕ) (f : ℕ → ℝ) (a : ResidueSpace (OutsideModulus p B)) : + sequenceCoeff p L f (outsideExtend p B a)=sequenceCoeff (OutsideModulus p B) L f a := by + simp only [sequenceCoeff,outsideExtend_char] + rfl + +lemma actual_frozen_outside_coefficient (L Q H : ℕ) (f : ℕ → ℝ) + (hHQ : H*(∏j∈B,p j)≤Q) (z : ResidueSpace p) (a : ResidueSpace (OutsideModulus p B)) + (ha : supportDenominator (OutsideModulus p B) a≤H) : + residueFourier (OutsideModulus p B) + (fun x => (actualTruncatedLift p L Q f (assembleOutside p B z x):ℂ)) a= + sequenceCoeff (OutsideModulus p B) L (gatedSequence p B z f) a := by + rw [←frozenFourier_outside p B (fun x => (actualTruncatedLift p L Q f x:ℂ)) z a, frozen_lift_fiber_fourier p L Q H f B hHQ z _ + (by rwa [outsideExtend_denominator]) (outsideExtend_disjoint p B a),sequenceCoeff_outside] + +lemma outside_fiber_second_moment (F : ResidueSpace p → ℝ) (z : ResidueSpace p) : + (𝔼 x,F (assembleOutside p B z x)^2)≤(∏j∈B,p j:ℝ)*(𝔼 x,F x^2) := by + have h := expect_freeze_le (fun x => F x^2) (fun _ => sq_nonneg _) B z + rw [←expect_outside p B (fun x => F (assembleOutside p B z x)^2)] + simpa only [assembleOutside_freeze,ZMod.card] using h + +end Outside + +end SquareDifference.PairBridge + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SquareDifference/PairBridge.lean b/lean/OAI/Combinatorics/SquareDifference/PairBridge.lean new file mode 100644 index 0000000000000000000000000000000000000000..995487a3c2d0761dacc95fd20849ba56cf4b454d --- /dev/null +++ b/lean/OAI/Combinatorics/SquareDifference/PairBridge.lean @@ -0,0 +1,231 @@ +import OAI.Combinatorics.SquareDifference.RootModels + +namespace OAI + +section + +open Finset + +open scoped BigOperators ComplexConjugate + +namespace SquareDifference + +namespace PairBridge + +open LiftTheory.SquareDifference + +section Fourier + +variable {J : Type*} [instFintypeJ : Fintype J] [instDecidableEqJ : DecidableEq J] (p : J → ℕ) + [instNeZeropj : ∀j,NeZero (p j)] + +lemma actualLiftPiece_eq {J : Type*} + [Fintype J] + [DecidableEq J] + (p : J → ℕ) + [∀ (j : J), NeZero (p j)] (L : ℕ) (f : ℕ → ℝ) (U : Finset J) (x : ResidueSpace p) : + actualLiftPiece p L f U x=liftPiece p L f U x := rfl + +lemma actualSupportFamily_eq {J : Type*} + [Fintype J] + [DecidableEq J] + (p : J → ℕ) + [∀ (j : J), NeZero (p j)] (Q : ℕ) : + liftSupportFamily p Q=univ.filter (fun U : Finset J => ∏j∈U,p j≤Q) := rfl + +noncomputable def sequenceCoeff (L : ℕ) (f : ℕ → ℝ) (a : ResidueSpace p) : ℂ := + (L : ℂ)⁻¹*∑n∈range L,(f n:ℂ)*conj (prodChar p a (fun j => (n:ZMod (p j)))) + +lemma gateCoefficient_empty (L : ℕ) (f : ℕ → ℝ) (z a : ResidueSpace p) : + gateCoefficient p L (fun n => (f n:ℂ)) ∅ z a=sequenceCoeff p L f a := by + simp only [gateCoefficient,exactGate,prod_empty,Complex.ofReal_one,mul_one, + sequenceCoeff,prodChar_nat_diagonal,neg_mul,LiftTheory.SquareDifference.expPhase_neg] + +lemma actualPiece_polynomial (L : ℕ) (f : ℕ → ℝ) (U : Finset J) : + (fun x => (actualLiftPiece p L f U x:ℂ))= + fourierPolynomial p (fun a => if primeSupport p a=U then sequenceCoeff p L f a else 0) := by + funext x + have h := LiftTheory.SquareDifference.liftPiece_freeze_fourier p L f U ∅ (0:ResidueSpace p) x + have hc : LiftTheory.SquareDifference.coordinateFreeze p ∅ (0:ResidueSpace p) x=x := by + funext j + simp only [LiftTheory.SquareDifference.coordinateFreeze,notMem_empty,ite_false] + rw [hc] at h + simpa only [sdiff_empty,inter_empty,gateCoefficient_empty,actualLiftPiece_eq] using h + +lemma polynomial_sum {T : Type*} (s : Finset T) (c : T → ResidueSpace p → ℂ) : + (fun x => ∑t∈s,fourierPolynomial p (c t) x)= + fourierPolynomial p (fun a => ∑t∈s,c t a) := by + funext x + simp only [fourierPolynomial,sum_mul] + rw [sum_comm] + +lemma actualLift_polynomial (L Q : ℕ) (f : ℕ → ℝ) : + (fun x => (actualTruncatedLift p L Q f x:ℂ))= + fourierPolynomial p (fun a => if supportDenominator p a≤Q then sequenceCoeff p L f a else 0) := by + change (fun x => (((∑U∈liftSupportFamily p Q,actualLiftPiece p L f U x):ℝ):ℂ))=_ + simp only [Complex.ofReal_sum] + have he (U : Finset J) (x : ResidueSpace p) := congrFun (actualPiece_polynomial p L f U) x + simp_rw [he] + rw [polynomial_sum] + congr 1 + funext a + simp only [actualSupportFamily_eq,sum_filter] + rw [sum_eq_single (primeSupport p a)] + · simp only [ite_true,LiftTheory.SquareDifference.supportDenominator] + rfl + · intro U _ hU + by_cases h : ∏j∈U,p j≤Q + · simp only [h,ite_true,Ne.symm hU,ite_false] + · simp only [h,ite_false] + · simp + +lemma actualLift_fourier (L Q : ℕ) (f : ℕ → ℝ) (a : ResidueSpace p) : + residueFourier p (fun x => (actualTruncatedLift p L Q f x:ℂ)) a= + if supportDenominator p a≤Q then sequenceCoeff p L f a else 0 := by + rw [actualLift_polynomial,residueFourier_polynomial] + +lemma sequenceCoeff_bound {J : Type*} + [Fintype J] + [DecidableEq J] + (p : J → ℕ) + [∀ (j : J), NeZero (p j)] (L : ℕ) (hL : 0 (n:ZMod (p j))))‖≤L*M := by + apply (norm_sum_le _ _).trans + calc + _ ≤ ∑n∈range L,M := by + apply sum_le_sum + intro n hn + simpa only [norm_mul,Complex.norm_real,Real.norm_eq_abs,Complex.norm_conj,norm_prodChar,mul_one] using hf n (mem_range.mp hn) + _ = _ := by simp + have hL0 : (L:ℝ)≠0 := by exact_mod_cast hL.ne' + calc + _ ≤ (L:ℝ)⁻¹*(L*M) := mul_le_mul_of_nonneg_left hs (inv_nonneg.mpr (Nat.cast_nonneg L)) + _ = M := by field_simp + +lemma actualLift_pointwise_bound (hp : Pairwise fun i j => (p i).Coprime (p j)) + (L Q : ℕ) (hL : 0 if supportDenominator p a≤Q then sequenceCoeff p L f a else 0) x‖≤(Q:ℝ)^2*M := by + unfold fourierPolynomial + simp only [ite_mul,zero_mul] + rw [←sum_filter] + calc + _ ≤ ∑a∈univ.filter (fun a => supportDenominator p a≤Q),‖sequenceCoeff p L f a*prodChar p a x‖ := norm_sum_le _ _ + _ ≤ ∑a∈univ.filter (fun a => supportDenominator p a≤Q),M := by + apply sum_le_sum + intro a _ + simpa only [norm_mul,norm_prodChar,mul_one] using sequenceCoeff_bound p L hL f M hf a + _ = ((univ.filter (fun a => supportDenominator p a≤Q)).card:ℝ)*M := by simp + _ ≤ (Q:ℝ)^2*M := by + apply mul_le_mul_of_nonneg_right _ hM + exact_mod_cast bounded_frequency_card p hp Q _ (fun a ha => (mem_filter.mp ha).2) + rw [←h,Complex.norm_real,Real.norm_eq_abs] at hh + exact hh + +lemma actualLift_mean (L Q : ℕ) (hQ : 1≤Q) (f : ℕ → ℝ) : + (𝔼 x,actualTruncatedLift p L Q f x)=(L:ℝ)⁻¹*∑n∈range L,f n := by + have h := actualLift_fourier p L Q f (0:ResidueSpace p) + have hc (x : ResidueSpace p) : prodChar p (0:ResidueSpace p) x=1 := by + simp only [prodChar,Pi.zero_apply,zero_mul,AddChar.map_zero_eq_one,prod_const_one] + have hd : supportDenominator p (0:ResidueSpace p)=1 := by + simp only [supportDenominator,primeSupport,Pi.zero_apply,ne_eq,not_true_eq_false,filter_false,prod_empty] + simp only [residueFourier,hc,map_one,mul_one,hd,ite_eq_left hQ,sequenceCoeff] at h + apply Complex.ofReal_injective + simpa only [expect_eq_sum_div_card,Complex.ofReal_div,Complex.ofReal_sum,Complex.ofReal_natCast, + Complex.ofReal_mul,Complex.ofReal_inv] using h + +lemma actualFamily_polynomial (L : ℕ) (f : ℕ → ℝ) (F : Finset (Finset J)) : + (fun x => ((∑U∈F,actualLiftPiece p L f U x:ℝ):ℂ))= + fourierPolynomial p (fun a => if primeSupport p a∈F then sequenceCoeff p L f a else 0) := by + simp only [Complex.ofReal_sum] + have he (U : Finset J) (x : ResidueSpace p) := congrFun (actualPiece_polynomial p L f U) x + simp_rw [he] + rw [polynomial_sum] + congr 1 + funext a + by_cases ha : primeSupport p a∈F + · rw [ite_eq_left ha,sum_eq_single (primeSupport p a)] + · simp + · intro U _ hU + exact ite_eq_right (Ne.symm hU) + · exact fun h => (h ha).elim + · rw [ite_eq_right ha] + apply sum_eq_zero + intro U hU + exact ite_eq_right (fun (he : primeSupport p a=U) => ha (he.symm ▸ hU)) + +lemma actualFamily_fourier (L : ℕ) (f : ℕ → ℝ) (F : Finset (Finset J)) (a : ResidueSpace p) : + residueFourier p (fun x => ((∑U∈F,actualLiftPiece p L f U x:ℝ):ℂ)) a= + if primeSupport p a∈F then sequenceCoeff p L f a else 0 := by + rw [actualFamily_polynomial,residueFourier_polynomial] + +lemma frozenFamily_fourier (L : ℕ) (f : ℕ → ℝ) (F : Finset (Finset J)) + (B : Finset J) (z a : ResidueSpace p) : + residueFourier p (fun x => ((∑U∈F,actualLiftPiece p L f U (freezeCoordinates B z x):ℝ):ℂ)) a= + ∑U∈F,if primeSupport p a=U\B then gateCoefficient p L (fun n => (f n:ℂ)) (U∩B) z a else 0 := by + have he (U : Finset J) (x : ResidueSpace p) : + (actualLiftPiece p L f U (freezeCoordinates B z x):ℂ)= + fourierPolynomial p (fun a => if primeSupport p a=U\B then + gateCoefficient p L (fun n => (f n:ℂ)) (U∩B) z a else 0) x := + liftPiece_freeze_fourier p L f U B z x + simp_rw [Complex.ofReal_sum,he] + rw [polynomial_sum,residueFourier_polynomial] + +lemma frozen_lift_low_fourier (L Q H : ℕ) (f : ℕ → ℝ) (B : Finset J) + (z a : ResidueSpace p) (ha : supportDenominator p a≤H) : + residueFourier p (fun x => (actualTruncatedLift p L Q f (freezeCoordinates B z x):ℂ)) a= + residueFourier p (fun x => ((∑U∈(liftSupportFamily p Q).filter (fun U => ∏j∈U\B,p j≤H), + actualLiftPiece p L f U (freezeCoordinates B z x):ℝ):ℂ)) a := by + change residueFourier p (fun x => ((∑U∈liftSupportFamily p Q, + actualLiftPiece p L f U (freezeCoordinates B z x):ℝ):ℂ)) a=_ + rw [frozenFamily_fourier,frozenFamily_fourier,sum_filter] + apply sum_congr rfl + intro U hU + by_cases he : primeSupport p a=U\B + · have hUH : ∏j∈U\B,p j≤H := by + simpa only [supportDenominator,he] using ha + simp only [he,hUH,ite_true] + · simp only [he,ite_false,ite_self] + +noncomputable def gatedSequence (B : Finset J) (z : ResidueSpace p) (f : ℕ → ℝ) (n : ℕ) : ℝ := + (∏j∈B,p j:ℝ)*(if ∀j∈B,(n:ZMod (p j))=z j then f n else 0) + +lemma frozen_low_lift_gated (L Q H : ℕ) (f : ℕ → ℝ) (B : Finset J) + (hHQ : H*(∏j∈B,p j)≤Q) (z x : ResidueSpace p) : + (∑U∈(liftSupportFamily p Q).filter (fun U => ∏j∈U\B,p j≤H), + actualLiftPiece p L f U (freezeCoordinates B z x))= + ∑U∈actualRemainingFamily p B H,actualLiftPiece p L (gatedSequence p B z f) U x := by + change (∑U∈(LiftAnalysis.SquareDifference.supportFamily p Q).filter (fun U => ∏j∈U\B,p j≤H), + LiftAnalysis.SquareDifference.liftPiece p L f U (LiftAnalysis.SquareDifference.coordinateFreeze p B z x))=_ + rw [LiftAnalysis.SquareDifference.frozen_low_lift_identity p L Q H f B hHQ z x] + simp only [actualLiftPiece,LiftAnalysis.SquareDifference.liftPiece,gatedSequence,mul_sum,div_eq_mul_inv] + apply sum_congr rfl + intro U hU + apply sum_congr rfl + intro n hn + split_ifs <;> ring + +lemma frozen_lift_fiber_fourier (L Q H : ℕ) (f : ℕ → ℝ) (B : Finset J) + (hHQ : H*(∏j∈B,p j)≤Q) (z a : ResidueSpace p) + (ha : supportDenominator p a≤H) (hB : Disjoint (primeSupport p a) B) : + residueFourier p (fun x => (actualTruncatedLift p L Q f (freezeCoordinates B z x):ℂ)) a= + sequenceCoeff p L (gatedSequence p B z f) a := by + rw [frozen_lift_low_fourier p L Q H f B z a ha] + simp_rw [frozen_low_lift_gated p L Q H f B hHQ z] + rw [actualFamily_fourier,ite_eq_left] + exact mem_filter.mpr ⟨mem_univ _,hB,ha⟩ + +end Fourier + +end PairBridge + +end SquareDifference + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SquareDifference/PhaseBounds.lean b/lean/OAI/Combinatorics/SquareDifference/PhaseBounds.lean new file mode 100644 index 0000000000000000000000000000000000000000..f68f6bc95deb77445d0a0c58dc2b0084c19341d3 --- /dev/null +++ b/lean/OAI/Combinatorics/SquareDifference/PhaseBounds.lean @@ -0,0 +1,512 @@ +import OAI.Combinatorics.SquareDifference.CircleDistance + +namespace OAI + +section +open Finset +open scoped ComplexConjugate BigOperators +namespace SquareDifference + +lemma linear_phase_sum_bound (t : ℝ) (L : ℕ) : + ‖∑ m ∈ range L, expPhase (m*t)‖ ≤ phaseBound L t := by + unfold phaseBound + split_ifs with ht + · exact linear_phase_sum_trivial t L + · refine le_min (linear_phase_sum_trivial t L) ?_ + have htp : 0 < circleDistance t := lt_of_le_of_ne (circleDistance_nonneg t) (Ne.symm ht) + refine (linear_phase_sum_distance t L htp).trans ?_ + rw [one_div] + exact inv_anti₀ htp (by linarith) + +noncomputable def distanceBucket (q : ℕ) (t : ℝ) : ℕ := + ⌊2*(q : ℝ)*circleDistance t⌋₊ + +lemma distanceBucket_le (q : ℕ) (t : ℝ) : distanceBucket q t ≤ q := by + apply Nat.floor_le_of_le + have := circleDistance_le_half t + nlinarith [Nat.cast_nonneg (α := ℝ) q] + +lemma distanceBucket_same_close {q : ℕ} (hq : 0 < q) {s t : ℝ} + (h : distanceBucket q s = distanceBucket q t) + (hsign : (0 ≤ s-round s) ↔ (0 ≤ t-round t)) : + circleDistance (s-t) < 1/(2*(q : ℝ)) := by + have hqR : 0 < (q : ℝ) := Nat.cast_pos.mpr hq + have hl (x : ℝ) : (distanceBucket q x : ℝ) ≤ 2*q*circleDistance x := + Nat.floor_le (mul_nonneg (by positivity) (circleDistance_nonneg x)) + have hu (x : ℝ) : 2*q*circleDistance x < (distanceBucket q x : ℝ)+1 := + Nat.lt_floor_add_one _ + have hab : |circleDistance s-circleDistance t| < 1/(2*(q : ℝ)) := by + rw [abs_lt] + constructor + · have hc : circleDistance t-circleDistance s < 1/(2*(q : ℝ)) := by + rw [lt_div_iff₀ (by positivity)] + have := hl s + have := hu t + rw [← h] at this + nlinarith + linarith + · rw [lt_div_iff₀ (by positivity)] + have := hl t + have := hu s + rw [h] at this + nlinarith + apply (circleDistance_sub_le s t).trans_lt + have he : |(s-round s)-(t-round t)| = |circleDistance s-circleDistance t| := by + unfold circleDistance + by_cases hs : 0 ≤ s-round s + · rw [abs_of_nonneg hs, abs_of_nonneg (hsign.mp hs)] + · have ht : t-round t < 0 := lt_of_not_ge (fun ht => hs (hsign.mpr ht)) + rw [abs_of_neg (lt_of_not_ge hs), abs_of_neg ht] + rw [← abs_neg] + congr 1 + ring + rwa [he] + +noncomputable def bucketWeight (q : ℕ) (M : ℝ) (k : ℕ) : ℝ := + if k=0 then M else 2*q/(k : ℝ) + +lemma phaseBound_le_bucketWeight (q : ℕ) (M t : ℝ) : + phaseBound M t ≤ bucketWeight q M (distanceBucket q t) := by + unfold bucketWeight + split_ifs with hk + · exact phaseBound_le M t + · have hkpos : 0 < (distanceBucket q t : ℝ) := Nat.cast_pos.mpr (Nat.pos_of_ne_zero hk) + have hl : (distanceBucket q t : ℝ) ≤ 2*q*circleDistance t := + Nat.floor_le (mul_nonneg (by positivity) (circleDistance_nonneg t)) + have ht : 0 < circleDistance t := by + by_contra hn + have hz : circleDistance t = 0 := le_antisymm (le_of_not_gt hn) (circleDistance_nonneg t) + rw [hz, mul_zero] at hl + linarith + unfold phaseBound + rw [ite_eq_right (ne_of_gt ht)] + apply (min_le_right _ _).trans + apply (le_div_iff₀ hkpos).mpr + rw [inv_mul_eq_div, div_le_iff₀ ht] + exact hl + +lemma separated_phaseBound_sum {I : Type*} [Fintype I] + (q : ℕ) (hq : 0 < q) (M : ℝ) (hM : 0 ≤ M) (t : I → ℝ) + (hsep : ∀ i j, i ≠ j → 1/(2*(q : ℝ)) ≤ circleDistance (t i-t j)) : + ∑ i, phaseBound M (t i) ≤ 2*M + 4*q*(harmonic q : ℝ) := by + classical + let e : I → Fin (q+1) × Bool := fun i => + (⟨distanceBucket q (t i), Nat.lt_succ_of_le (distanceBucket_le q (t i))⟩, + decide (0 ≤ t i-round (t i))) + have hinj : Function.Injective e := by + intro i j hij + by_contra hne + have hb : distanceBucket q (t i)=distanceBucket q (t j) := + congrArg (fun x : Fin (q+1) × Bool => x.1.val) hij + have hs : (0 ≤ t i-round (t i)) ↔ (0 ≤ t j-round (t j)) := by + have hh := congrArg Prod.snd hij + exact decide_eq_decide.mp hh + exact (not_lt_of_ge (hsep i j hne)) (distanceBucket_same_close hq hb hs) + calc + _ ≤ ∑ i, bucketWeight q M (e i).1.val := + sum_le_sum fun i _ => phaseBound_le_bucketWeight q M (t i) + _ = ∑ j ∈ univ.image e, bucketWeight q M j.1.val := by + rw [sum_image] + exact Set.injOn_of_injective hinj + _ ≤ ∑ j : Fin (q+1) × Bool, bucketWeight q M j.1.val := by + apply sum_le_sum_of_subset_of_nonneg (subset_univ _) + intro j _ _ + unfold bucketWeight + split_ifs + · exact hM + · positivity + _ = 2*M + 4*q*(harmonic q : ℝ) := by + rw [Fintype.sum_prod_type] + simp only [Fintype.sum_bool, ← two_mul] + rw [← mul_sum] + rw [Fin.sum_univ_eq_sum_range] + rw [sum_range_succ'] + simp only [bucketWeight, Nat.add_eq_zero_iff, one_ne_zero, and_false, + ↓reduceIte, Nat.cast_add, Nat.cast_one, div_eq_mul_inv] + rw [← mul_sum] + simp only [harmonic, Rat.cast_sum, Rat.cast_inv] + push_cast + ring + +lemma circleDistance_lipschitz (s t : ℝ) : circleDistance s ≤ circleDistance t + |s-t| := by + calc + _ ≤ |s-round t| := circleDistance_le_abs_sub_int s (round t) + _ = |(t-round t)+(s-t)| := by congr 1; ring + _ ≤ |t-round t|+|s-t| := abs_add_le _ _ + +lemma rational_circleDistance_lower (k : ℤ) (q : ℕ) (hq : 0 < q) + (hnd : ¬ (q : ℤ) ∣ k) : 1/(q : ℝ) ≤ circleDistance ((k : ℝ)/q) := by + have hqR : 0 < (q : ℝ) := Nat.cast_pos.mpr hq + let n := round ((k : ℝ)/q) + have hn : k-(q : ℤ)*n ≠ 0 := by + intro he + apply hnd + exact ⟨n, by linarith⟩ + have hI : (1 : ℤ) ≤ |k-(q : ℤ)*n| := by + have := abs_pos.mpr hn + omega + have hR : (1 : ℝ) ≤ |(k : ℝ)-(q : ℝ)*(n : ℝ)| := by exact_mod_cast hI + have he : |(k : ℝ)-(q : ℝ)*(n : ℝ)| = (q : ℝ)*circleDistance ((k : ℝ)/q) := by + calc + _ = |(q : ℝ)*((k : ℝ)/q-(n : ℝ))| := by congr 1; field_simp + _ = _ := by rw [abs_mul, abs_of_pos hqR]; rfl + rw [he] at hR + exact (div_le_iff₀ hqR).mpr (by simpa only [mul_comm] using hR) + +lemma rational_quadratic_spacing (α : ℝ) (a : ℤ) (q : ℕ) (hq : 0 < q) + (hc : IsCoprime a (q : ℤ)) (ha : |α-(a : ℝ)/q| ≤ 1/(q : ℝ)^2) + (h : ℤ) (h0 : h ≠ 0) (hh : 4*|h| < (q : ℤ)) : + 1/(2*(q : ℝ)) ≤ circleDistance (2*α*h) := by + have hqR : 0 < (q : ℝ) := Nat.cast_pos.mpr hq + have hnd : ¬ (q : ℤ) ∣ 2*a*h := by + intro hd + have hd' : (q : ℤ) ∣ 2*h := hc.symm.dvd_of_dvd_mul_left (by rwa [show a*(2*h)=2*a*h by ring]) + have hab : |2*h| < (q : ℤ) := by rw [abs_mul]; norm_num at *; omega + have hpos : 0 < |2*h| := abs_pos.mpr (mul_ne_zero (by norm_num) h0) + exact (not_le_of_gt hab) (Int.le_of_dvd hpos ((dvd_abs _ _).mpr hd')) + have hr := rational_circleDistance_lower (2*a*h) q hq hnd + push_cast at hr + have hdiff : |((2 : ℝ)*a*h)/q-2*α*h| ≤ 1/(2*(q : ℝ)) := by + have he : (2 : ℝ)*a*h/q-2*α*h = -(2*h*(α-(a : ℝ)/q)) := by ring + rw [he, abs_neg, abs_mul] + have hmul := mul_le_mul_of_nonneg_left ha (abs_nonneg (2*(h : ℝ))) + apply hmul.trans + rw [abs_mul, abs_of_pos (by norm_num : (0 : ℝ)<2)] + have hhr : 4*|(h : ℝ)| < (q : ℝ) := by exact_mod_cast hh + apply (le_div_iff₀ (by positivity)).mpr + field_simp + nlinarith + have hl := circleDistance_lipschitz (((2 : ℝ)*a*h)/q) (2*α*h) + have hqeq : 1/(q : ℝ)=2*(1/(2*(q : ℝ))) := by ring + rw [hqeq] at hr + linarith + +lemma sum_range_blocks {A : Type*} [AddCommMonoid A] (f : ℕ → A) (b k : ℕ) : + ∑ n ∈ range (b*k), f n = ∑ i ∈ range k, ∑ j ∈ range b, f (b*i+j) := by + induction k with + | zero => simp + | succ k ih => + rw [Nat.mul_succ, sum_range_add, ih, sum_range_succ] + +lemma quadratic_block_bound (α : ℝ) (a : ℤ) (q : ℕ) (hq : 4 ≤ q) + (hc : IsCoprime a (q : ℤ)) (ha : |α-(a : ℝ)/q| ≤ 1/(q : ℝ)^2) + (M : ℕ) (x : ℝ) : + ∑ j ∈ range (q/4), phaseBound M (2*α*(x+j)) ≤ + 2*M+4*q*(harmonic q : ℝ) := by + have hqpos : 0 < q := by omega + have hbq : 4*(q/4) ≤ q := by omega + let b := q/4 + have hs := separated_phaseBound_sum q hqpos (M : ℝ) (Nat.cast_nonneg M) + (fun j : Fin b => 2*α*(x+j)) + rw [← Fin.sum_univ_eq_sum_range] + apply hs + intro j k hjk + have hh0 : (j : ℤ)-(k : ℤ) ≠ 0 := by + intro he + apply hjk + exact Fin.ext (by exact_mod_cast sub_eq_zero.mp he) + have hj : (j : ℤ) < (b : ℤ) := by exact_mod_cast j.isLt + have hk : (k : ℤ) < (b : ℤ) := by exact_mod_cast k.isLt + have hj0 : (0 : ℤ) ≤ j := by positivity + have hk0 : (0 : ℤ) ≤ k := by positivity + have hab : |(j : ℤ)-(k : ℤ)| ≤ (b : ℤ)-1 := abs_le.mpr ⟨by omega, by omega⟩ + have hbqI : 4*(b : ℤ) ≤ (q : ℤ) := by exact_mod_cast hbq + have hsmall : 4*|(j : ℤ)-(k : ℤ)| < (q : ℤ) := by omega + have hr := rational_quadratic_spacing α a q hqpos hc ha _ hh0 hsmall + convert hr using 1 + push_cast + congr 1 + ring + +lemma rational_spacing_sum (α : ℝ) (a : ℤ) (q : ℕ) (hq : 8 ≤ q) + (hc : IsCoprime a (q : ℤ)) (ha : |α-(a : ℝ)/q| ≤ 1/(q : ℝ)^2) + (M : ℕ) : + ∑ j ∈ range M, phaseBound M (2*α*j) ≤ + (8*(M : ℝ)/q+1)*(2*M+4*q*(1+Real.log q)) := by + let b := q/4 + have hb : 0 < b := by dsimp [b]; omega + have hcover : M ≤ b*(M/b+1) := by + have := Nat.mod_lt M hb + have := Nat.mod_add_div M b + nlinarith + have hsum : ∑ j ∈ range M, phaseBound M (2*α*j) ≤ + ((M/b+1 : ℕ) : ℝ)*(2*M+4*q*(harmonic q : ℝ)) := by + calc + _ ≤ ∑ j ∈ range (b*(M/b+1)), phaseBound M (2*α*j) := + sum_le_sum_of_subset_of_nonneg (range_mono hcover) (fun _ _ _ => + phaseBound_nonneg (Nat.cast_nonneg _) _) + _ = ∑ i ∈ range (M/b+1), ∑ j ∈ range b, phaseBound M (2*α*(b*i+j)) := by + rw [sum_range_blocks] + simp only [Nat.cast_add, Nat.cast_mul] + _ ≤ ∑ _i ∈ range (M/b+1), (2*M+4*q*(harmonic q : ℝ)) := by + apply sum_le_sum + intro i _ + exact quadratic_block_bound α a q (by omega) hc ha M ((b : ℝ)*i) + _ = _ := by simp; ring + have hqR : 0 < (q : ℝ) := by exact_mod_cast (show 0 ⟨x.1-x.2,x.2⟩) + (fun x : Σ _ : ℕ, ℕ => ⟨x.2+x.1,x.2⟩) ?_ ?_ ?_ ?_ ?_ + · intro x hx + simp only [mem_sigma, mem_range, mem_Ico] at hx ⊢ + omega + · intro x hx + simp only [mem_sigma, mem_range, mem_Ico] at hx ⊢ + omega + · rintro ⟨n,m⟩ hx + simp only [mem_sigma, mem_range] at hx + apply Sigma.ext (by dsimp; omega) + rfl + · rintro ⟨j,m⟩ _ + apply Sigma.ext (by dsimp; omega) + rfl + · rintro ⟨n,m⟩ hx + simp only [mem_sigma, mem_range] at hx + change f m n = f m (m+(n-m)) + congr 1 + omega + +lemma complex_sum_square_identity (z : ℕ → ℂ) (L : ℕ) + (hz : ∀ n < L, ‖z n‖=1) : + (∑ n ∈ range L, z n) * conj (∑ n ∈ range L, z n) = + (L : ℂ) + (∑ n ∈ range L, ∑ m ∈ range n, z n*conj (z m)) + + conj (∑ n ∈ range L, ∑ m ∈ range n, z n*conj (z m)) := by + induction L with + | zero => simp + | succ L ih => + have hi := ih (fun n hn => hz n (Nat.lt_succ_of_lt hn)) + have hn : z L*conj (z L)=1 := by simp only [Complex.mul_conj', hz L (Nat.lt_succ_self _), Complex.ofReal_one, one_pow] + simp only [sum_range_succ, Nat.cast_add, Nat.cast_one, map_add] + rw [add_mul, mul_add, mul_add, hi, hn] + simp only [map_sum, map_mul, starRingEnd_self_apply] + simp only [← mul_sum] + ring + +lemma norm_sum_square_differencing (z : ℕ → ℂ) (L : ℕ) + (hz : ∀ n < L, ‖z n‖=1) : + ‖∑ n ∈ range L, z n‖^2 ≤ (L : ℝ) + + 2 * ∑ j ∈ Ico 1 L, ‖∑ m ∈ range (L-j), z (m+j)*conj (z m)‖ := by + have hid := congrArg Complex.re (complex_sum_square_identity z L hz) + rw [Complex.mul_conj'] at hid + simp only [← Complex.ofReal_pow, Complex.ofReal_re, Complex.add_re, Complex.natCast_re, Complex.conj_re] at hid + rw [sum_triangle_differences (fun m n => z n*conj (z m)) L] at hid + have hle : (∑ j ∈ Ico 1 L, ∑ m ∈ range (L-j), z (m+j)*conj (z m)).re ≤ + ∑ j ∈ Ico 1 L, ‖∑ m ∈ range (L-j), z (m+j)*conj (z m)‖ := by + rw [Complex.re_sum] + exact sum_le_sum fun j _ => Complex.re_le_norm _ + linarith + +lemma quadratic_correlation (α θ : ℝ) (j L : ℕ) : + ‖∑ m ∈ range L, expPhase (α*(m+j)^2+θ*(m+j)) * + conj (expPhase (α*m^2+θ*m))‖ = + ‖∑ m ∈ range L, expPhase (m*(2*α*j))‖ := by + simp_rw [← expPhase_sub] + have he (m : ℕ) : α*((m : ℝ)+j)^2+θ*((m : ℝ)+j)-(α*m^2+θ*m) = + (α*j^2+θ*j)+m*(2*α*j) := by ring + simp_rw [he, expPhase_add, ← mul_sum, norm_mul, norm_expPhase, one_mul] + +lemma phaseBound_mono {M N : ℝ} (hMN : M ≤ N) (t : ℝ) : + phaseBound M t ≤ phaseBound N t := by + unfold phaseBound + split_ifs + · exact hMN + · exact min_le_min_right _ hMN + +lemma quadratic_sum_differencing (α θ : ℝ) (L M : ℕ) (hLM : L ≤ M) : + ‖∑ m ∈ range L, expPhase (α*m^2+θ*m)‖^2 ≤ (M : ℝ) + + 2 * ∑ j ∈ Ico 1 M, phaseBound M (2*α*j) := by + apply (norm_sum_square_differencing (fun m => expPhase (α*m^2+θ*m)) L + (fun _ _ => norm_expPhase _)).trans + apply add_le_add (Nat.cast_le.mpr hLM) + apply mul_le_mul_of_nonneg_left _ (by norm_num) + calc + _ = ∑ j ∈ Ico 1 L, ‖∑ m ∈ range (L-j), expPhase (m*(2*α*j))‖ := by + apply sum_congr rfl + intro j _ + simp only [Nat.cast_add] + exact quadratic_correlation α θ j (L-j) + _ ≤ ∑ j ∈ Ico 1 L, phaseBound M (2*α*j) := by + apply sum_le_sum + intro j _ + exact (linear_phase_sum_bound (2*α*j) (L-j)).trans + (phaseBound_mono (Nat.cast_le.mpr ((Nat.sub_le L j).trans hLM)) _) + _ ≤ ∑ j ∈ Ico 1 M, phaseBound M (2*α*j) := by + apply sum_le_sum_of_subset_of_nonneg (Ico_subset_Ico_right hLM) + intro i _ _ + exact phaseBound_nonneg (Nat.cast_nonneg _) _ + +lemma expPhase_lipschitz (s t : ℝ) : ‖expPhase s-expPhase t‖ ≤ 2*Real.pi*|s-t| := by + have he : expPhase s-expPhase t = (expPhase (s-t)-1)*expPhase t := by + rw [sub_mul, one_mul, ← expPhase_add, sub_add_cancel] + rw [he, norm_mul, norm_expPhase, mul_one] + change ‖Complex.exp (↑(2*Real.pi*(s-t))*Complex.I)-1‖ ≤ _ + rw [mul_comm _ Complex.I] + convert Real.norm_exp_I_mul_ofReal_sub_one_le (x := 2*Real.pi*(s-t)) using 1 + rw [Real.norm_eq_abs, abs_mul, abs_of_pos (by positivity : 0 < 2*Real.pi)] + +lemma periodic_zero_prefix (a : ℕ → ℂ) (T : ℕ) (hT : 0 < T) + (hp : Function.Periodic a T) (hz : ∑ m ∈ range T, a m = 0) + (B : ℝ) (hB : 0 ≤ B) (ha : ∀ m, ‖a m‖ ≤ B) (L : ℕ) : + ‖∑ m ∈ range L, a m‖ ≤ T*B := by + have hperiod (k j : ℕ) : a (T*k+j) = a j := by + simpa [mul_comm, add_comm] using hp.nat_mul k j + rw [← Nat.mod_add_div L T, add_comm, sum_range_add, sum_range_blocks] + simp_rw [hperiod, hz, sum_const_zero, zero_add] + calc + _ ≤ ∑ _m ∈ range (L%T), B := (norm_sum_le _ _).trans (sum_le_sum (fun m _ => ha m)) + _ ≤ (T : ℝ)*B := by + simp only [sum_const, card_range, nsmul_eq_mul] + exact mul_le_mul_of_nonneg_right (Nat.cast_le.mpr (Nat.mod_lt L hT).le) hB + +lemma norm_periodicMean (a : ℕ → ℂ) (T : ℕ) (hT : 0 < T) + (B : ℝ) (ha : ∀ m, ‖a m‖ ≤ B) : ‖periodicMean a T‖ ≤ B := by + have hTR : (0 : ℝ) < T := Nat.cast_pos.mpr hT + unfold periodicMean + rw [norm_mul, norm_inv, Complex.norm_natCast] + calc + _ ≤ (T : ℝ)⁻¹ * ∑ _m ∈ range T, B := + mul_le_mul_of_nonneg_left ((norm_sum_le _ _).trans (sum_le_sum (fun m _ => ha m))) + (inv_nonneg.mpr hTR.le) + _ = B := by simp [ne_of_gt hTR] + +lemma periodic_prefix_error (a : ℕ → ℂ) (T : ℕ) (hT : 0 < T) + (hp : Function.Periodic a T) (B : ℝ) (hB : 0 ≤ B) + (ha : ∀ m, ‖a m‖ ≤ B) (L : ℕ) : + ‖∑ m ∈ range L, a m-(L : ℂ)*periodicMean a T‖ ≤ 2*T*B := by + have hTC : (T : ℂ) ≠ 0 := by exact_mod_cast (ne_of_gt hT) + have hμ := norm_periodicMean a T hT B ha + have hz : ∑ m ∈ range T, (a m-periodicMean a T) = 0 := by + simp [sum_sub_distrib, periodicMean, mul_inv_cancel_left₀ hTC] + have hc : Function.Periodic (fun m => a m-periodicMean a T) T := by + intro m; dsimp; rw [hp m] + have hh := periodic_zero_prefix (fun m => a m-periodicMean a T) T hT hc hz + (2*B) (by positivity) (fun m => by linarith [norm_sub_le (a m) (periodicMean a T), ha m]) L + convert hh using 1 + · simp only [sum_sub_distrib, sum_const, card_range, nsmul_eq_mul] + · ring + +lemma norm_weighted_partial_bound (a f : ℕ → ℂ) (L : ℕ) (B : ℝ) + (_hB : 0 ≤ B) (ha : ∀ K ≤ L, ‖∑ m ∈ range K, a m‖ ≤ B) : + ‖∑ m ∈ range L, f m*a m‖ ≤ + B*(‖f (L-1)‖+∑ m ∈ range (L-1), ‖f (m+1)-f m‖) := by + change ‖∑ m ∈ range L, f m • a m‖ ≤ _ + rw [sum_range_by_parts] + calc + _ ≤ ‖f (L-1)‖*‖∑ m ∈ range L, a m‖+ + ∑ m ∈ range (L-1), ‖f (m+1)-f m‖*‖∑ j ∈ range (m+1), a j‖ := by + apply (norm_sub_le _ _).trans + rw [norm_smul] + exact add_le_add le_rfl ((norm_sum_le _ _).trans (le_of_eq (by simp))) + _ ≤ ‖f (L-1)‖*B+∑ m ∈ range (L-1), ‖f (m+1)-f m‖*B := by + apply add_le_add (mul_le_mul_of_nonneg_left (ha L le_rfl) (norm_nonneg _)) + apply sum_le_sum + intro m hm + apply mul_le_mul_of_nonneg_left _ (norm_nonneg _) + exact ha (m+1) (by have := mem_range.mp hm; omega) + _ = _ := by rw [← sum_mul]; ring + +noncomputable def squareWeight (N : ℕ) (y : ℝ) (m : ℕ) : ℂ := + (2*((m : ℝ)+1)/(N : ℝ)) • expPhase (y*(m+1)^2) + +lemma norm_squareWeight (N : ℕ) (y : ℝ) (m : ℕ) : + ‖squareWeight N y m‖ = 2*((m : ℝ)+1)/N := by + unfold squareWeight + rw [norm_smul, norm_expPhase, mul_one, Real.norm_of_nonneg (by positivity)] + +lemma squareWeight_difference (N : ℕ) (y : ℝ) (m : ℕ) : + ‖squareWeight N y (m+1)-squareWeight N y m‖ ≤ + 2/(N : ℝ) + (2*((m : ℝ)+1)/N)*(2*Real.pi*|y| *(2*m+3)) := by + have he : squareWeight N y (m+1)-squareWeight N y m = + (2/(N : ℝ)) • expPhase (y*(m+2)^2)+ + (2*((m : ℝ)+1)/N) • (expPhase (y*(m+2)^2)-expPhase (y*(m+1)^2)) := by + unfold squareWeight + simp only [Nat.cast_add, Nat.cast_one, smul_sub] + rw [show (m : ℝ)+1+1=m+2 by ring] + module + rw [he] + apply (norm_add_le _ _).trans + simp only [norm_smul, norm_expPhase, mul_one] + rw [Real.norm_of_nonneg (by positivity : 0 ≤ 2/(N : ℝ)), + Real.norm_of_nonneg (by positivity : 0 ≤ 2*((m : ℝ)+1)/N)] + apply add_le_add le_rfl (mul_le_mul_of_nonneg_left _ (by positivity)) + apply (expPhase_lipschitz _ _).trans + rw [show y*((m : ℝ)+2)^2-y*((m : ℝ)+1)^2=y*(2*m+3) by ring, + abs_mul, abs_of_nonneg (by positivity : 0 ≤ 2*(m : ℝ)+3)] + apply le_of_eq + ring + +lemma squareWeight_variation (N M : ℕ) (hM : 1 ≤ M) (y : ℝ) : + ‖squareWeight N y (M-1)‖+ + ∑ m ∈ range (M-1), ‖squareWeight N y (m+1)-squareWeight N y m‖ ≤ + (4+8*Real.pi*|y| *(M : ℝ)^2)*M/N := by + have hlast : ((M-1 : ℕ) : ℝ)+1=M := by exact_mod_cast Nat.sub_add_cancel hM + rw [norm_squareWeight, hlast] + calc + _ ≤ 2*(M : ℝ)/N + ∑ _m ∈ range (M-1), + (2/(N : ℝ)+8*Real.pi*|y| *(M : ℝ)^2/N) := by + apply add_le_add le_rfl (sum_le_sum _) + intro m hm + apply (squareWeight_difference N y m).trans + apply add_le_add le_rfl + have hmR : (m : ℝ)+2 ≤ M := by exact_mod_cast (show m+2 ≤ M by + have := mem_range.mp hm; omega) + calc + _ ≤ (2*(M : ℝ)/N)*(2*Real.pi*|y| *(2*M)) := by + gcongr <;> linarith + _ = _ := by ring + _ ≤ 2*(M : ℝ)/N+(M : ℝ)*(2/(N : ℝ)+8*Real.pi*|y| *(M : ℝ)^2/N) := by + simp only [sum_const, card_range, nsmul_eq_mul] + apply add_le_add le_rfl + exact mul_le_mul_of_nonneg_right (Nat.cast_le.mpr (Nat.sub_le M 1)) (by positivity) + _ = _ := by ring + +lemma periodic_squareWeight_error (a : ℕ → ℂ) (T : ℕ) (hT : 0 < T) + (hp : Function.Periodic a T) (B : ℝ) (hB : 0 ≤ B) + (ha : ∀ m, ‖a m‖ ≤ B) (M N : ℕ) (hM : 1 ≤ M) (y : ℝ) : + ‖(∑ m ∈ range M, squareWeight N y m*a m)- + periodicMean a T*(∑ m ∈ range M, squareWeight N y m)‖ ≤ + (2*T*B)*((4+8*Real.pi*|y| *(M : ℝ)^2)*M/N) := by + have hb : ∀ K ≤ M, ‖∑ m ∈ range K, (a m-periodicMean a T)‖ ≤ 2*T*B := by + intro K _ + simpa only [sum_sub_distrib, sum_const, card_range, nsmul_eq_mul] using + periodic_prefix_error a T hT hp B hB ha K + have hh := norm_weighted_partial_bound (fun m => a m-periodicMean a T) + (squareWeight N y) M (2*T*B) (by positivity) hb + have he : (∑ m ∈ range M, squareWeight N y m*a m)- + periodicMean a T*(∑ m ∈ range M, squareWeight N y m) = + ∑ m ∈ range M, squareWeight N y m*(a m-periodicMean a T) := by + simp only [mul_sub, sum_sub_distrib, ← sum_mul, mul_comm (periodicMean a T)] + rw [he] + exact hh.trans (mul_le_mul_of_nonneg_left (squareWeight_variation N M hM y) (by positivity)) + +end SquareDifference +end + +end OAI diff --git a/lean/OAI/Combinatorics/SquareDifference/PositiveResidue.lean b/lean/OAI/Combinatorics/SquareDifference/PositiveResidue.lean new file mode 100644 index 0000000000000000000000000000000000000000..b5efa1242822f4923fde0f93e5b523d710e6cc8d --- /dev/null +++ b/lean/OAI/Combinatorics/SquareDifference/PositiveResidue.lean @@ -0,0 +1,162 @@ +import OAI.Combinatorics.SquareDifference.LowProduct + +namespace OAI + +section + +open Finset + +open scoped BigOperators + +namespace SquareDifference + +lemma exists_strict_square_steps (p : ℕ) [Fact p.Prime] : + ∃ δ : ℕ → ZMod p, (∀j, δ j≠0 ∧ IsSquare (δ j)) ∧ ∑j∈range 24, δ j=0 := by + classical + by_cases hs : IsSquare (-1 : ZMod p) + · let δ : ℕ → ZMod p := fun j => if j%2=0 then 1 else -1 + refine ⟨δ,?_,?_⟩ + · intro j + dsimp [δ] + split_ifs + · exact ⟨one_ne_zero, ⟨1, by simp⟩⟩ + · exact ⟨neg_ne_zero.mpr one_ne_zero,hs⟩ + · norm_num [δ,Finset.sum_range_succ] + · obtain ⟨a,b,hab⟩ := ZMod.sq_add_sq p (-1) + have ha : a^2≠0 := by + intro h + have he : -1=b*b := by simpa [h,pow_two] using hab.symm + exact hs ⟨b,he⟩ + have hb : b^2≠0 := by + intro h + have he : -1=a*a := by simpa [h,pow_two] using hab.symm + exact hs ⟨a,he⟩ + let δ : ℕ → ZMod p := fun j => if j%3=0 then a^2 else if j%3=1 then b^2 else 1 + refine ⟨δ,?_,?_⟩ + · intro j + dsimp [δ] + split_ifs + · exact ⟨ha,⟨a,by rw [pow_two]⟩⟩ + · exact ⟨hb,⟨b,by rw [pow_two]⟩⟩ + · exact ⟨one_ne_zero,⟨1,by simp⟩⟩ + · norm_num only [δ,Finset.sum_range_succ,Finset.sum_range_zero, + Nat.reduceMod,Nat.reduceEqDiff,ite_true,ite_false,zero_add] + linear_combination 8*hab + +lemma prefix_cyclic_difference {G : Type*} [AddCommGroup G] + (δ : ℕ → G) (hδ : ∑j∈range 24, δ j=0) (j : Fin 24) : + (∑k∈range (j+1).val, δ k)-(∑k∈range j.val, δ k)=δ j.val := by + by_cases hj : j.val<23 + · have hval : (j+1).val=j.val+1 := by + rw [Fin.val_add] + norm_num only [Fin.val_one] + exact Nat.mod_eq_of_lt (by omega) + rw [hval,sum_range_succ,add_sub_cancel_left] + · have hj23 : j.val=23 := by omega + have hval : (j+1).val=0 := by rw [Fin.val_add,hj23]; norm_num + rw [hval,hj23,sum_range_zero,zero_sub] + have hh := hδ + rw [show 24=23+1 by rfl,sum_range_succ] at hh + simpa using congrArg Neg.neg (eq_neg_iff_add_eq_zero.mpr hh) + +lemma exists_cyclic_labels {G V : Type*} [AddCommGroup G] + (ι : Fin 24 → V) (hι : Function.Injective ι) (δ : ℕ → G) + (hδ : ∑j∈range 24, δ j=0) : + ∃ s : V → G, ∀j : Fin 24, s (ι (j+1))-s (ι j)=δ j.val := by + classical + let f : Fin 24 → G := fun j => ∑k∈range j.val, δ k + let s : V → G := Function.extend ι f (fun _ => 0) + refine ⟨s,?_⟩ + intro j + dsimp [s] + rw [Function.Injective.extend_apply hι,Function.Injective.extend_apply hι] + exact prefix_cyclic_difference δ hδ j + +lemma exists_product_strict_steps {I : Type*} (p : I → ℕ) [∀i, Fact (p i).Prime] + {D : ℕ} (e : ZMod D ≃+* (ZMod 8 × ∀i, ZMod (p i))) : + ∃ δ : ℕ → ZMod D, (∀j, (e (δ j)).1=1 ∧ + ∀i, (e (δ j)).2 i≠0 ∧ IsSquare ((e (δ j)).2 i)) ∧ + (∑j∈range 24, δ j)=0 := by + classical + choose d hd hd0 using fun i => exists_strict_square_steps (p i) + let δ : ℕ → ZMod D := fun j => e.symm (1,fun i => d i j) + refine ⟨δ,?_,?_⟩ + · intro j + simp only [δ,e.apply_symm_apply] + exact ⟨trivial,fun i => hd i j⟩ + · apply e.injective + rw [map_sum,map_zero] + simp only [δ,e.apply_symm_apply] + ext + · simp only [Prod.fst_sum] + norm_num only [sum_const,card_range,nsmul_eq_mul,mul_one] + change (24 : ZMod 8)=0 + decide + · simp only [Prod.snd_sum,Finset.sum_apply,Prod.snd_zero,Pi.zero_apply] + exact hd0 _ + +lemma exists_good_cyclic_labels {I V : Type*} (p : I → ℕ) [∀i, Fact (p i).Prime] + {D : ℕ} (e : ZMod D ≃+* (ZMod 8 × ∀i, ZMod (p i))) + (ι : Fin 24 → V) (hι : Function.Injective ι) : + ∃ s : V → ZMod D, ∀j : Fin 24, + (e (s (ι (j+1))-s (ι j))).1=1 ∧ + ∀i, (e (s (ι (j+1))-s (ι j))).2 i≠0 ∧ + IsSquare ((e (s (ι (j+1))-s (ι j))).2 i) := by + obtain ⟨δ,hδ,hδ0⟩ := exists_product_strict_steps p e + obtain ⟨s,hs⟩ := exists_cyclic_labels ι hι δ hδ0 + exact ⟨s,fun j => by rw [hs j]; exact hδ j.val⟩ + +end SquareDifference + +namespace SquareDifference + +lemma tupleCycle_order : orderOf tupleCycle=24 := by + change orderOf (finRotate 24)=24 + rw [(isCycle_finRotate_of_le (show 2≤24 by decide)).orderOf, + support_finRotate_of_le (show 2≤24 by decide)] + simp + +lemma cycleVertex_fin_injective : Function.Injective (fun j : Fin 24 => cycleVertex j.val) := by + intro i j hij + apply Fin.ext + have he := congrFun hij (⟨0,by decide⟩ : Fin tupleBlocks) + change tupleCycle^i.val=tupleCycle^j.val at he + exact pow_injOn_Iio_orderOf (by simp [tupleCycle_order]) + (by simp [tupleCycle_order]) he + +lemma cycleVertex_fin_successor (j : Fin 24) : + cycleVertex (j+1).val=cycleVertex (j.val+1) := by + by_cases hj : j.val<23 + · congr 1 + rw [Fin.val_add] + norm_num only [Fin.val_one] + exact Nat.mod_eq_of_lt (by omega) + · have hj23 : j.val=23 := by omega + have hv : (j+1).val=0 := by rw [Fin.val_add,hj23]; norm_num + rw [hv,hj23] + exact (cycleVertex_period 0).symm + +lemma exists_good_tuple_residues {I : Type*} (p : I → ℕ) [∀i,Fact (p i).Prime] + {D : ℕ} (e : ZMod D ≃+* (ZMod 8 × ∀i,ZMod (p i))) : + ∃s : TupleVertex → ZMod D,∀j : Fin 24, + (e (s (cycleVertex (j.val+1))-s (cycleVertex j.val))).1=1 ∧ + ∀i,(e (s (cycleVertex (j.val+1))-s (cycleVertex j.val))).2 i≠0 ∧ + IsSquare ((e (s (cycleVertex (j.val+1))-s (cycleVertex j.val))).2 i) := by + obtain ⟨s,hs⟩ := exists_good_cyclic_labels p e _ cycleVertex_fin_injective + refine ⟨s,fun j => ?_⟩ + simpa only [cycleVertex_fin_successor] using hs j + +lemma uniform_event_positive {X : Type*} [Fintype X] [Nonempty X] + (P : X → Prop) [DecidablePred P] (hP : ∃x,P x) : + 0<(𝔼 x,if P x then (1:ℝ) else 0) := by + obtain ⟨x,hx⟩ := hP + rw [expect_eq_sum_div_card] + apply div_pos _ (by exact_mod_cast Fintype.card_pos) + apply sum_pos' (fun _ _ => by positivity) + exact ⟨x,mem_univ x,by rw [ite_eq_left hx]; norm_num⟩ + +end SquareDifference + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SquareDifference/PowerParameters.lean b/lean/OAI/Combinatorics/SquareDifference/PowerParameters.lean new file mode 100644 index 0000000000000000000000000000000000000000..729cd7fc27c4fef40e28bb7fa64652014977fa15 --- /dev/null +++ b/lean/OAI/Combinatorics/SquareDifference/PowerParameters.lean @@ -0,0 +1,139 @@ +import OAI.Combinatorics.SquareDifference.IntervalCrude + +namespace OAI + +section + +open Finset Filter + +open scoped Topology + +namespace SquareDifference + +noncomputable def sourceBeta : ℝ := 1/100000 + +noncomputable def sourceGamma : ℝ := 1/64 + +noncomputable def sourceTau (d : ℕ) : ℝ := sourceBeta*sourceGamma/(1000*((d:ℝ)+1)) + +noncomputable def sourceSigma (d : ℕ) : ℝ := sourceGamma*sourceTau d/4 + +noncomputable def sourceLoss (d : ℕ) : ℝ := sourceGamma*sourceTau d/(100*((d:ℝ)+1)) + +noncomputable def powerCutoff (N : ℕ) (a : ℝ) : ℕ := ⌊(N:ℝ)^a⌋₊ + +noncomputable def childLength (N D : ℕ) : ℕ := ⌈(N:ℝ)/(D:ℝ)^2⌉₊ + +lemma sourceBeta_pos : 0 (z : ℂ)) + (primeSieveWeight_unit_density (ZMod.castHom (dvd_mul_right p k) (ZMod p) x)) + push_cast at hh + calc + _ = (1-(primeSieveWeight p (ZMod.castHom (dvd_mul_right p k) (ZMod p) x) : ℂ))*ψ (x^2) := by ring + _ = _ := by rw [hh]; split_ifs <;> simp only [Complex.ofReal_one,Complex.ofReal_zero] <;> ring + rw [← expect_sub_distrib] + simp_rw [he] + rw [← mul_expect,odd_unit_gauss_zero_char hp hpk ψ hψ,mul_zero] + +lemma two_le_rpow_sixth {x : ℝ} (hx : 64≤x) : 2≤x^((1 : ℝ)/6) := by + have h : (2 : ℝ)≤x^(6 : ℝ)⁻¹ := by + apply (Real.le_rpow_inv_iff_of_pos (by norm_num) (by linarith : 0≤x) (by norm_num)).mpr + norm_num + exact hx + simpa only [one_div] using h + +lemma smallPrime_product_bound (S : Finset ℕ) (a : ℕ → ℕ) + (ha : ∀p∈S, p≤a p) (hp : ∀p∈S, 1≤p) : + (2 : ℝ)^S.card≤2^64*((∏p∈S, (a p : ℝ))^((1 : ℝ)/6)) := by + let K := S.filter (fun p => p<64) + have hK : K⊆range 64 := by intro p hp; exact mem_range.mpr (mem_filter.mp hp).2 + have hcard : K.card≤64 := le_trans (card_le_card hK) (by simp) + have hk0 : ∀p∈S, 0≤(a p : ℝ) := fun _ _ => Nat.cast_nonneg _ + have hle (p : ℕ) (hps : p∈S) : (2 : ℝ)≤ + (if p<64 then (2 : ℝ) else 1)*(a p : ℝ)^((1 : ℝ)/6) := by + split_ifs with h + · have h1 : (1 : ℝ)≤(a p : ℝ)^((1 : ℝ)/6) := + Real.one_le_rpow (by exact_mod_cast (hp p hps).trans (ha p hps)) (by norm_num) + linarith + · rw [one_mul] + apply two_le_rpow_sixth + exact_mod_cast (le_trans (Nat.le_of_not_gt h) (ha p hps)) + calc + _ = ∏p∈S, (2 : ℝ) := (prod_const 2).symm + _ ≤ ∏p∈S, (if p<64 then (2 : ℝ) else 1)*(a p : ℝ)^((1 : ℝ)/6) := + Finset.prod_le_prod₀ (by intros; norm_num) hle + _ = (2 : ℝ)^K.card*(∏p∈S, (a p : ℝ))^((1 : ℝ)/6) := by + rw [prod_mul_distrib,prod_ite] + simp only [prod_const,one_pow,mul_one] + rw [Real.finsetProd_rpow _ _ (fun p hp => hk0 p hp)] + _ ≤ _ := mul_le_mul_of_nonneg_right (pow_le_pow_right₀ (by norm_num) hcard) + (Real.rpow_nonneg (prod_nonneg hk0) _) + +lemma truncatedSieveMean_decay (S : Finset ℕ) (a : ℕ → ℕ) (H : ℝ) (A B : ℕ → ℂ) + (ha : ∀p∈S, p≤a p) (hp : ∀p∈S, 1≤p) + (hA : ∀p∈S, ‖A p‖≤(a p : ℝ)^(-(1 : ℝ)/2)) + (hB : ∀p∈S, ‖B p‖≤(a p : ℝ)^(-(1 : ℝ)/2)) : + ‖truncatedSieveMean S id H A B‖≤2^64*(∏p∈S, (a p : ℝ))^(-(1 : ℝ)/3) := by + have hpos (p : ℕ) (hps : p∈S) : (0 : ℝ) (hpos p hp).le)] + calc + _ ≤ (2^64*(∏p∈S, (a p : ℝ))^((1 : ℝ)/6))*(∏p∈S, (a p : ℝ))^(-(1 : ℝ)/2) := + mul_le_mul_of_nonneg_right (smallPrime_product_bound S a ha hp) (Real.rpow_nonneg hprod.le _) + _ = _ := by rw [mul_assoc,← Real.rpow_add hprod]; norm_num + +lemma truncatedSieveMean_restrict {I : Type*} [DecidableEq I] + (S U : Finset I) (hUS : U⊆S) (p : I → ℕ) (H : ℝ) (a b : I → ℂ) + (ha : ∀i∈S, i∉U → a i=1) (hb : ∀i∈S, i∉U → b i=0) : + truncatedSieveMean S p H a b=truncatedSieveMean U p H a b := by + unfold truncatedSieveMean + symm + calc + _ = ∑T∈U.powerset, if ((∏i∈T, p i : ℕ) : ℝ)≤H then localSieveTerm S a b T else 0 := by + apply sum_congr rfl + intro T hTU + have hT := mem_powerset.mp hTU + split_ifs + · unfold localSieveTerm + congr 2 + apply prod_subset + · exact sdiff_subset_sdiff_left T hUS + · intro i hi hni + exact ha i (mem_sdiff.mp hi).1 (by intro hiu; exact hni (mem_sdiff.mpr ⟨hiu,(mem_sdiff.mp hi).2⟩)) + · rfl + _ = _ := by + apply sum_subset (powerset_mono.mpr hUS) + intro T hTS hTU + have hsub := mem_powerset.mp hTS + have hnsub : ¬T⊆U := fun h => hTU (mem_powerset.mpr h) + obtain ⟨i,hiT,hiU⟩ := not_subset.mp hnsub + split_ifs + · unfold localSieveTerm + rw [prod_eq_zero hiT (hb i (hsub hiT) hiU),mul_zero] + · rfl + +lemma product_sieve_coefficient {I : Type*} [Fintype I] [DecidableEq I] + {R : I → Type*} [∀i, CommRing (R i)] [∀i, Fintype (R i)] + (ψ : AddChar (∀i, R i) ℂ) (root w : ∀i, R i → ℂ) + (p : I → ℕ) (H : ℝ) : + (∑T∈(univ : Finset I).powerset, if ((∏i∈T, p i : ℕ) : ℝ)≤H then + (-1)^T.card*(𝔼 x : ∀i, R i, (∏i, root i (x i))*(∏i∈T, w i (x i))*ψ (x^2)) else 0)= + truncatedSieveMean univ p H + (fun i => 𝔼 t : R i, root i t*coordinateChar ψ i (t^2)) + (fun i => 𝔼 t : R i, (root i t*w i t)*coordinateChar ψ i (t^2)) := by + unfold truncatedSieveMean + apply sum_congr rfl + intro T hT + split_ifs + · rw [localSieveTerm_product _ _ (subset_univ _)] + congr 1 + have he (x : ∀i, R i) : (∏i, root i (x i))*(∏i∈T, w i (x i))= + ∏i, root i (x i)*(if i∈T then w i (x i) else 1) := by + rw [prod_mul_distrib] + congr 1 + rw [prod_ite] + simp + simp_rw [he] + rw [product_quadratic_mean ψ (fun i t => root i t*(if i∈T then w i t else 1))] + apply prod_congr rfl + intro i _ + by_cases hi : i∈T + · simp only [ite_eq_left hi] + · simp only [ite_eq_right hi,mul_one] + · rfl + +lemma localSieveTerm_factor {I : Type*} [DecidableEq I] + (S U T : Finset I) (hUS : U⊆S) (hTU : T⊆U) (a b : I → ℂ) : + localSieveTerm S a b T=(∏i∈S\U, a i)*localSieveTerm U a b T := by + have hd : Disjoint (S\U) (U\T) := by + rw [disjoint_left] + intro i hi hj + exact (mem_sdiff.mp hi).2 (mem_sdiff.mp hj).1 + have he : S\T=(S\U)∪(U\T) := by + ext i + simp only [mem_sdiff,mem_union] + constructor + · rintro ⟨hiS,hiT⟩ + by_cases hiU : i∈U + · exact Or.inr ⟨hiU,hiT⟩ + · exact Or.inl ⟨hiS,hiU⟩ + · rintro (⟨hiS,hiU⟩|⟨hiU,hiT⟩) + · exact ⟨hiS,fun hiT => hiU (hTU hiT)⟩ + · exact ⟨hUS hiU,hiT⟩ + unfold localSieveTerm + rw [he,prod_union hd] + ring + +lemma truncatedSieveMean_factor {I : Type*} [DecidableEq I] + (S U : Finset I) (hUS : U⊆S) (p : I → ℕ) (H : ℝ) (a b : I → ℂ) + (hb : ∀i∈S, i∉U → b i=0) : + truncatedSieveMean S p H a b=(∏i∈S\U, a i)*truncatedSieveMean U p H a b := by + unfold truncatedSieveMean + rw [mul_sum] + symm + calc + _ = ∑T∈U.powerset, if ((∏i∈T, p i : ℕ) : ℝ)≤H then localSieveTerm S a b T else 0 := by + apply sum_congr rfl + intro T hTU + split_ifs + · exact (localSieveTerm_factor S U T hUS (mem_powerset.mp hTU) a b).symm + · exact mul_zero _ + _ = _ := by + apply sum_subset (powerset_mono.mpr hUS) + intro T hTS hTU + have hsub := mem_powerset.mp hTS + obtain ⟨i,hiT,hiU⟩ := not_subset.mp (show ¬T⊆U from fun h => hTU (mem_powerset.mpr h)) + split_ifs + · unfold localSieveTerm + rw [prod_eq_zero hiT (hb i (hsub hiT) hiU),mul_zero] + · rfl + +lemma truncatedSieveMean_congr_active {I : Type*} [DecidableEq I] + (S : Finset I) (p : I → ℕ) (H : ℝ) (a b c : I → ℂ) + (hp : ∀i∈S, 1≤p i) (hbc : ∀i∈S, (p i : ℝ)≤H → b i=c i) : + truncatedSieveMean S p H a b=truncatedSieveMean S p H a c := by + unfold truncatedSieveMean + apply sum_congr rfl + intro T hT + split_ifs with hH + · unfold localSieveTerm + congr 1 + apply prod_congr rfl + intro i hiT + apply hbc i ((mem_powerset.mp hT) hiT) + apply le_trans _ hH + exact_mod_cast single_le_prod (fun j hj => hp j ((mem_powerset.mp hT) hj)) hiT + · rfl + +lemma residueDensity_nonneg {m q : ℕ} (hmq : m∣q) (c : ZMod m) (x : ZMod q) : + 0≤residueDensity hmq c x := by unfold residueDensity; split_ifs <;> positivity + +lemma residueDensity_quadratic_norm {m q : ℕ} [NeZero m] [NeZero q] + (hmq : m∣q) (c : ZMod m) (ψ : AddChar (ZMod q) ℂ) : + ‖𝔼 x : ZMod q, (residueDensity hmq c x : ℂ)*ψ (x^2)‖≤1 := by + apply (RCLike.norm_expect_le (K := ℂ)).trans + have he (x : ZMod q) : ‖(residueDensity hmq c x : ℂ)*ψ (x^2)‖=residueDensity hmq c x := by + rw [norm_mul,ψ.norm_apply,mul_one,Complex.norm_real,Real.norm_eq_abs,abs_of_nonneg (residueDensity_nonneg hmq c x)] + simp_rw [he] + have h := residueDensity_mean hmq c + have hr : (𝔼 x : ZMod q, residueDensity hmq c x)=(1 : ℝ) := by exact_mod_cast h + exact hr.le + +lemma smallPrime_product_bound_inj {I : Type*} [DecidableEq I] + (S : Finset I) (p a : I → ℕ) (hi : Set.InjOn p S) + (ha : ∀i∈S, p i≤a i) (hp : ∀i∈S, 1≤p i) : + (2 : ℝ)^S.card≤2^64*((∏i∈S, (a i : ℝ))^((1 : ℝ)/6)) := by + let K := S.filter (fun i => p i<64) + have hK : K.image p⊆range 64 := by + intro j hj + obtain ⟨i,hi,rfl⟩ := mem_image.mp hj + exact mem_range.mpr (mem_filter.mp hi).2 + have hki : Set.InjOn p K := hi.mono (filter_subset _ _) + have hcard : K.card≤64 := by + rw [← card_image_of_injOn hki] + exact le_trans (card_le_card hK) (by simp) + have hk0 : ∀i∈S, 0≤(a i : ℝ) := fun _ _ => Nat.cast_nonneg _ + have hle (i : I) (his : i∈S) : (2 : ℝ)≤ + (if p i<64 then (2 : ℝ) else 1)*(a i : ℝ)^((1 : ℝ)/6) := by + split_ifs with h + · have h1 : (1 : ℝ)≤(a i : ℝ)^((1 : ℝ)/6) := + Real.one_le_rpow (by exact_mod_cast (hp i his).trans (ha i his)) (by norm_num) + linarith + · rw [one_mul] + apply two_le_rpow_sixth + exact_mod_cast (le_trans (Nat.le_of_not_gt h) (ha i his)) + calc + _ = ∏i∈S, (2 : ℝ) := (prod_const 2).symm + _ ≤ ∏i∈S, (if p i<64 then (2 : ℝ) else 1)*(a i : ℝ)^((1 : ℝ)/6) := + Finset.prod_le_prod₀ (by intros; norm_num) hle + _ = (2 : ℝ)^K.card*(∏i∈S, (a i : ℝ))^((1 : ℝ)/6) := by + rw [prod_mul_distrib,prod_ite] + simp only [prod_const,one_pow,mul_one] + rw [Real.finsetProd_rpow _ _ hk0] + _ ≤ _ := mul_le_mul_of_nonneg_right (pow_le_pow_right₀ (by norm_num) hcard) + (Real.rpow_nonneg (prod_nonneg hk0) _) + +lemma truncatedSieveMean_decay_inj {I : Type*} [DecidableEq I] + (S : Finset I) (p a : I → ℕ) (hi : Set.InjOn p S) (H : ℝ) (A B : I → ℂ) + (ha : ∀i∈S, p i≤a i) (hp : ∀i∈S, 1≤p i) + (hA : ∀i∈S, ‖A i‖≤(a i : ℝ)^(-(1 : ℝ)/2)) + (hB : ∀i∈S, ‖B i‖≤(a i : ℝ)^(-(1 : ℝ)/2)) : + ‖truncatedSieveMean S p H A B‖≤2^64*(∏i∈S, (a i : ℝ))^(-(1 : ℝ)/3) := by + have hpos (i : I) (his : i∈S) : (0 : ℝ) (hpos i hi).le)] + calc + _ ≤ (2^64*(∏i∈S, (a i : ℝ))^((1 : ℝ)/6))*(∏i∈S, (a i : ℝ))^(-(1 : ℝ)/2) := + mul_le_mul_of_nonneg_right (smallPrime_product_bound_inj S p a hi ha hp) (Real.rpow_nonneg hprod.le _) + _ = _ := by rw [mul_assoc,← Real.rpow_add hprod]; norm_num + +section RootSieve + +variable {I : Type*} [DecidableEq I] + (p m : I → ℕ) [∀i, Fact (p i).Prime] [∀i, NeZero (m i)] + (hm : ∀i, p i∣m i) (R : Finset I) (c : ∀i, ZMod (p i)) + (ψ : ∀i, AddChar (ZMod (m i)) ℂ) + +noncomputable def rootSieveA (i : I) : ℂ := + if i∈R then 𝔼 x : ZMod (m i), (residueDensity (hm i) (c i) x : ℂ)*ψ i (x^2) + else 𝔼 x : ZMod (m i), ψ i (x^2) + +noncomputable def rootSieveB (i : I) : ℂ := + if i∈R then 0 else 𝔼 x : ZMod (m i), + (primeSieveWeight (p i) (ZMod.castHom (hm i) (ZMod (p i)) x) : ℂ)*ψ i (x^2) + +lemma rootSieveA_trivial (i : I) (hi : ψ i=1) : rootSieveA p m hm R c ψ i=1 := by + unfold rootSieveA + rw [hi] + split_ifs + · simpa only [AddChar.one_apply,mul_one] using residueDensity_mean (hm i) (c i) + · simp only [AddChar.one_apply,Fintype.expect_const] + +lemma rootSieveB_trivial (i : I) (hi : ψ i=1) : rootSieveB p m hm R ψ i=0 := by + unfold rootSieveB + rw [hi] + split_ifs + · rfl + · simpa only [AddChar.one_apply,mul_one] using nonprime_sieve_mean_zero (hm i) + +lemma rootSieveA_root_bound (i : I) (hi : i∈R) : ‖rootSieveA p m hm R c ψ i‖≤1 := by + rw [rootSieveA,ite_eq_left hi] + exact residueDensity_quadratic_norm (hm i) (c i) (ψ i) + +lemma rootSieveB_root (i : I) (hi : i∈R) : rootSieveB p m hm R ψ i=0 := by + rw [rootSieveB,ite_eq_left hi] + +lemma rootSieve_factor (S T : Finset I) (hTS : T⊆S) (H : ℝ) + (hψ : ∀i∈S, i∉T → ψ i=1) : + truncatedSieveMean S p H (rootSieveA p m hm R c ψ) (rootSieveB p m hm R ψ)= + (∏i∈T∩R, rootSieveA p m hm R c ψ i)* + truncatedSieveMean (T\R) p H (rootSieveA p m hm R c ψ) (rootSieveB p m hm R ψ) := by + rw [truncatedSieveMean_restrict S T hTS p H _ _ + (fun i hi hn => rootSieveA_trivial p m hm R c ψ i (hψ i hi hn)) + (fun i hi hn => rootSieveB_trivial p m hm R ψ i (hψ i hi hn))] + rw [truncatedSieveMean_factor T (T\R) sdiff_subset p H _ _ (by + intro i hi hn + apply rootSieveB_root p m hm R ψ i + by_contra hir + exact hn (mem_sdiff.mpr ⟨hi,hir⟩))] + congr 2 + ext i + simp + +lemma rootSieve_decay (S T : Finset I) (hTS : T⊆S) (H : ℝ) + (hinj : Set.InjOn p (↑(T\R) : Set I)) (hle : ∀i∈T, p i ≤ m i) + (hψ0 : ∀i∈S, i∉T → ψ i=1) + (hψ : ∀i∈T\R, (ψ i).IsPrimitive) + (hodd : ∀i∈T\R, IsUnit (2 : ZMod (m i))) : + ‖truncatedSieveMean S p H (rootSieveA p m hm R c ψ) (rootSieveB p m hm R ψ)‖≤ + 2^64*(∏i∈T\R, (m i : ℝ))^(-(1 : ℝ)/3) := by + rw [rootSieve_factor p m hm R c ψ S T hTS H hψ0,norm_mul] + have hr : ‖∏i∈T∩R, rootSieveA p m hm R c ψ i‖≤1 := by + rw [norm_prod] + exact prod_le_one₀ (fun _ _ => norm_nonneg _) (fun i hi => rootSieveA_root_bound p m hm R c ψ i (mem_inter.mp hi).2) + apply (mul_le_mul_of_nonneg_right hr (norm_nonneg _)).trans + rw [one_mul] + apply truncatedSieveMean_decay_inj (T\R) p m hinj H _ _ + (fun i hi => hle i (mem_sdiff.mp hi).1) (fun i _ => (Fact.out : (p i).Prime).one_lt.le) + · intro i hi + rw [rootSieveA,ite_eq_right (mem_sdiff.mp hi).2] + exact (quadratic_sieve_bounds (hm i) (hodd i hi) (ψ i) (hψ i hi)).1 + · intro i hi + rw [rootSieveB,ite_eq_right (mem_sdiff.mp hi).2] + exact (quadratic_sieve_bounds (hm i) (hodd i hi) (ψ i) (hψ i hi)).2 + +end RootSieve + +lemma residueDensity_quadratic_zero_dvd {p q : ℕ} [NeZero p] [NeZero q] + (h : p*p∣q) (c : ZMod p) (hc : (2 : ZMod p)*c≠0) + (ψ : AddChar (ZMod q) ℂ) (hψ : ψ.IsPrimitive) : + (𝔼 x : ZMod q, (residueDensity ((dvd_mul_right p p).trans h) c x : ℂ)*ψ (x^2))=0 := by + obtain ⟨k,hk⟩ := h + have he : q=p*(p*k) := by rw [hk]; ring + subst he + have hk0 : k≠0 := by intro hz; subst k; simpa using (NeZero.ne (p*(p*0))) + let : NeZero k := ⟨hk0⟩ + exact residueDensity_quadratic_zero (dvd_mul_right p k) ψ hψ c hc + +lemma odd_prime_power_root_zero {p : ℕ} [Fact p.Prime] (k : ℕ) + (c : ZMod p) (hc : (2 : ZMod p)*c≠0) + (ψ : AddChar (ZMod (p^(k+2))) ℂ) (hψ : ψ.IsPrimitive) : + (𝔼 x : ZMod (p^(k+2)), (residueDensity (dvd_pow_self p (by omega : k+2≠0)) c x : ℂ)*ψ (x^2))=0 := by + apply residueDensity_quadratic_zero_dvd _ c hc ψ hψ + exact ⟨p^k,by ring⟩ + +lemma odd_root_quadratic_large_dvd {q : ℕ} [NeZero q] (h : 16∣q) + (ψ : AddChar (ZMod q) ℂ) (hψ : ψ.IsPrimitive) : + (𝔼 x : ZMod q, (residueDensity ((by norm_num : 2∣16).trans h) 1 x : ℂ)*ψ (x^2))=0 := by + obtain ⟨k,hk⟩ := h + have he : q=4*(4*k) := by omega + subst he + have hk0 : k≠0 := by + have hh := NeZero.ne (4*(4*k)) + intro hz + rw [hz] at hh + norm_num at hh + let : NeZero k := ⟨hk0⟩ + exact odd_root_quadratic_large (dvd_mul_right 4 k) ψ hψ + +lemma two_prime_power_root_zero (k : ℕ) + (ψ : AddChar (ZMod (2^(k+4))) ℂ) (hψ : ψ.IsPrimitive) : + (𝔼 x : ZMod (2^(k+4)), (residueDensity (dvd_pow_self 2 (by omega : k+4≠0)) 1 x : ℂ)*ψ (x^2))=0 := by + apply odd_root_quadratic_large_dvd _ ψ hψ + exact ⟨2^k,by ring⟩ + +lemma two_prime_power_root_small (e : ℕ) (he1 : 1≤e) (he3 : e≤3) + (ψ : AddChar (ZMod (2^e)) ℂ) : + (𝔼 x : ZMod (2^e), (residueDensity (dvd_pow_self 2 (by omega : e≠0)) 1 x : ℂ)*ψ (x^2))=ψ 1 := by + have hs : 2^e∣8 := by + change 2^e∣2^3 + exact pow_dvd_pow 2 he3 + exact odd_root_quadratic_small (dvd_pow_self 2 (by omega : e≠0)) hs ψ + +lemma prime_power_sieved_zero_dvd {p q : ℕ} [Fact p.Prime] [NeZero q] + (hp : p≠2) (h : p*p∣q) (ψ : AddChar (ZMod q) ℂ) (hψ : ψ.IsPrimitive) : + (𝔼 x : ZMod q, ψ (x^2))- + (𝔼 x : ZMod q, (primeSieveWeight p (ZMod.castHom ((dvd_mul_right p p).trans h) (ZMod p) x) : ℂ)*ψ (x^2))=0 := by + obtain ⟨k,hk⟩ := h + have he : q=p*(p*k) := by rw [hk]; ring + subst he + have hk0 : k≠0 := by intro hz; subst k; simpa using (NeZero.ne (p*(p*0))) + let : NeZero k := ⟨hk0⟩ + exact prime_power_sieved_zero hp (dvd_mul_right p k) ψ hψ + +lemma prime_power_sieve_complete_zero {p : ℕ} [Fact p.Prime] (hp : p≠2) (k : ℕ) + (ψ : AddChar (ZMod (p^(k+2))) ℂ) (hψ : ψ.IsPrimitive) : + (𝔼 x : ZMod (p^(k+2)), ψ (x^2))- + (𝔼 x : ZMod (p^(k+2)), (primeSieveWeight p (ZMod.castHom (dvd_pow_self p (by omega : k+2≠0)) (ZMod p) x) : ℂ)*ψ (x^2))=0 := by + apply prime_power_sieved_zero_dvd hp _ ψ hψ + exact ⟨p^k,by ring⟩ + +lemma residueDensity_quadratic_phase {p m : ℕ} [NeZero p] [NeZero m] + (hpm : p∣m) (c : ZMod p) (r : ZMod m) (ψ : AddChar (ZMod m) ℂ) + (hsq : ∀x : ZMod m, ZMod.castHom hpm (ZMod p) x=c → x^2=r) : + (𝔼 x : ZMod m, (residueDensity hpm c x : ℂ)*ψ (x^2))=ψ r := by + have he (x : ZMod m) : (residueDensity hpm c x : ℂ)*ψ (x^2)= + (residueDensity hpm c x : ℂ)*ψ r := by + by_cases hx : ZMod.castHom hpm (ZMod p) x=c + · rw [hsq x hx] + · simp only [residueDensity,ite_eq_right hx,Complex.ofReal_zero,zero_mul] + simp_rw [he] + rw [← expect_mul,residueDensity_mean,one_mul] + +lemma prime_unit_quadratic_of_eq {p m : ℕ} [Fact p.Prime] [NeZero m] + (hpm : p∣m) (he : m=p) (ψ : AddChar (ZMod m) ℂ) : + (𝔼 x : ZMod m, ψ (x^2))- + (𝔼 x : ZMod m, (primeSieveWeight p (ZMod.castHom hpm (ZMod p) x) : ℂ)*ψ (x^2))= + unitQuadraticMean ψ := by + subst m + have hh : ZMod.castHom hpm (ZMod p)=RingHom.id (ZMod p) := Subsingleton.elim _ _ + simp only [hh,RingHom.id_apply] + exact prime_unit_quadratic ψ + +section RootSieveComplete + +variable {I : Type*} [DecidableEq I] + (p m : I → ℕ) [∀i, Fact (p i).Prime] [∀i, NeZero (m i)] + (hm : ∀i, p i∣m i) (R : Finset I) (c : ∀i, ZMod (p i)) + (ψ : ∀i, AddChar (ZMod (m i)) ℂ) + +lemma rootSieve_complete (S T : Finset I) (hTS : T⊆S) (H : ℝ) + (hψ0 : ∀i∈S, i∉T → ψ i=1) (hH : ((∏i∈T\R, p i : ℕ) : ℝ)≤H) : + truncatedSieveMean S p H (rootSieveA p m hm R c ψ) (rootSieveB p m hm R ψ)= + (∏i∈T∩R, rootSieveA p m hm R c ψ i)* + ∏i∈T\R, (rootSieveA p m hm R c ψ i-rootSieveB p m hm R ψ i) := by + rw [rootSieve_factor p m hm R c ψ S T hTS H hψ0] + congr 1 + exact truncatedSieveMean_complete _ _ _ _ _ + (fun i _ => (Fact.out : (p i).Prime).one_lt.le) hH + +lemma rootSieve_complete_phase (S T : Finset I) (hTS : T⊆S) (H : ℝ) + (hψ0 : ∀i∈S, i∉T → ψ i=1) (hH : ((∏i∈T\R, p i : ℕ) : ℝ)≤H) + (he : ∀i∈T\R, m i=p i) (r : ∀i, ZMod (m i)) + (hsq : ∀i∈T∩R, ∀x : ZMod (m i), ZMod.castHom (hm i) (ZMod (p i)) x=c i → x^2=r i) : + truncatedSieveMean S p H (rootSieveA p m hm R c ψ) (rootSieveB p m hm R ψ)= + (∏i∈T∩R, ψ i (r i))*(∏i∈T\R, unitQuadraticMean (ψ i)) := by + rw [rootSieve_complete p m hm R c ψ S T hTS H hψ0 hH] + congr 1 + · apply prod_congr rfl + intro i hi + rw [rootSieveA,ite_eq_left (mem_inter.mp hi).2] + exact residueDensity_quadratic_phase (hm i) (c i) (r i) (ψ i) (hsq i hi) + · apply prod_congr rfl + intro i hi + simp only [rootSieveA,rootSieveB,ite_eq_right (mem_sdiff.mp hi).2] + exact prime_unit_quadratic_of_eq (hm i) (he i hi) (ψ i) + +lemma rootSieve_zero_of_root (S T : Finset I) (hTS : T⊆S) (H : ℝ) + (hψ0 : ∀i∈S, i∉T → ψ i=1) (i : I) (hi : i∈T∩R) + (hz : (𝔼 x : ZMod (m i), (residueDensity (hm i) (c i) x : ℂ)*ψ i (x^2))=0) : + truncatedSieveMean S p H (rootSieveA p m hm R c ψ) (rootSieveB p m hm R ψ)=0 := by + rw [rootSieve_factor p m hm R c ψ S T hTS H hψ0] + have he : rootSieveA p m hm R c ψ i=0 := by rw [rootSieveA,ite_eq_left (mem_inter.mp hi).2,hz] + rw [prod_eq_zero hi he,zero_mul] + +lemma rootSieve_zero_of_squarefactor (S T : Finset I) (hTS : T⊆S) (H : ℝ) + (hψ0 : ∀i∈S, i∉T → ψ i=1) (hH : ((∏i∈T\R, p i : ℕ) : ℝ)≤H) + (i : I) (hi : i∈T\R) (hp : p i≠2) (h2 : p i*p i∣m i) (hψ : (ψ i).IsPrimitive) : + truncatedSieveMean S p H (rootSieveA p m hm R c ψ) (rootSieveB p m hm R ψ)=0 := by + rw [rootSieve_complete p m hm R c ψ S T hTS H hψ0 hH] + have he : rootSieveA p m hm R c ψ i-rootSieveB p m hm R ψ i=0 := by + simp only [rootSieveA,rootSieveB,ite_eq_right (mem_sdiff.mp hi).2] + exact prime_power_sieved_zero_dvd hp h2 (ψ i) hψ + rw [prod_eq_zero hi he,mul_zero] + +end RootSieveComplete + +lemma zmod_equiv_coordinate {I : Type*} [DecidableEq I] (m : I → ℕ) {L : ℕ} + (e : ZMod L ≃+* ∀i, ZMod (m i)) (i : I) (hi : m i∣L) (x : ZMod L) : + e x i=ZMod.castHom hi (ZMod (m i)) x := by + exact DFunLike.congr_fun (Subsingleton.elim + ((Pi.evalRingHom (fun i => ZMod (m i)) i).comp e.toRingHom) + (ZMod.castHom hi (ZMod (m i)))) x + +lemma coordinateChar_inflation_primitive {I : Type*} [DecidableEq I] + (m : I → ℕ) {q L : ℕ} (hqL : q∣L) + (e : ZMod L ≃+* ∀i, ZMod (m i)) + (ψ : AddChar (ZMod q) ℂ) (hψ : ψ.IsPrimitive) (i : I) (hiq : m i∣q) : + (coordinateChar ((ψ.compAddMonoidHom (ZMod.castHom hqL (ZMod q)).toAddMonoidHom).compAddMonoidHom + e.symm.toAddMonoidHom) i).IsPrimitive := by + intro a ha he + let xL := e.symm (Pi.single i a) + let x := ZMod.castHom hqL (ZMod q) xL + have hx : x≠0 := by + intro hx + have hh := congrArg (ZMod.castHom hiq (ZMod (m i))) hx + have hc : ZMod.castHom hiq (ZMod (m i)) x=a := by + change ((ZMod.castHom hiq (ZMod (m i))).comp (ZMod.castHom hqL (ZMod q))) xL=a + rw [zmod_cast_comp] + rw [← zmod_equiv_coordinate m e i (hiq.trans hqL)] + simp only [xL,RingEquiv.apply_symm_apply,Pi.single_eq_same] + rw [hc,map_zero] at hh + exact ha hh + apply hψ hx + ext z + obtain ⟨y,rfl⟩ := ZMod.ringHom_surjective (ZMod.castHom hqL (ZMod q)) z + have hh := congrArg (fun φ : AddChar (ZMod (m i)) ℂ => φ (e y i)) he + change ψ (ZMod.castHom hqL (ZMod q) (e.symm (Pi.single i (a*e y i))))=1 at hh + have hm : e.symm (Pi.single i (a*e y i))=xL*y := by + apply e.injective + simp only [RingEquiv.apply_symm_apply,map_mul,xL] + ext j + by_cases hj : j=i + · subst j; simp + · simp [Pi.single_eq_of_ne hj] + change ψ (x*ZMod.castHom hqL (ZMod q) y)=1 + rw [hm,map_mul] at hh + exact hh + +end SquareDifference +end + +end OAI diff --git a/lean/OAI/Combinatorics/SquareDifference/PrimeExtension.lean b/lean/OAI/Combinatorics/SquareDifference/PrimeExtension.lean new file mode 100644 index 0000000000000000000000000000000000000000..6d7899b765d3eb28e2f2c501f079f78882617c5c --- /dev/null +++ b/lean/OAI/Combinatorics/SquareDifference/PrimeExtension.lean @@ -0,0 +1,109 @@ +import OAI.Combinatorics.SquareDifference.ResidueReindex + +namespace OAI + +section + +open Finset + +open scoped BigOperators + +namespace SquareDifference + +open LiftTheory.SquareDifference + +section Indexed + +variable {S J : Type*} [instFintypeS : Fintype S] [instDecidableEqS : DecidableEq S] [instFintypeJ : Fintype J] [instDecidableEqJ : DecidableEq J] + (ps : S → ℕ) (p : J → ℕ) + +abbrev extendedPrime : S ⊕ J → ℕ := Sum.elim ps p + +noncomputable def extendedRoots (B : Finset J) : Finset (S ⊕ J) := univ.disjSum B + +@[simp] lemma inl_mem_extendedRoots {S : Type*} + {J : Type*} + [Fintype S] + [DecidableEq S] + [Fintype J] + [DecidableEq J] (B : Finset J) (s : S) : Sum.inl s∈extendedRoots (S:=S) B := by simp [extendedRoots] +@[simp] lemma inr_mem_extendedRoots {S : Type*} + {J : Type*} + [Fintype S] + [DecidableEq S] + [Fintype J] + [DecidableEq J] (B : Finset J) (j : J) : Sum.inr j∈extendedRoots (S:=S) B ↔ j∈B := by simp [extendedRoots] +noncomputable def outsideSumEquiv (B : Finset J) : + {i : S ⊕ J // i∉extendedRoots (S:=S) B} ≃ {j : J // j∉B} where + toFun i := match i with + | ⟨Sum.inl s,hi⟩ => False.elim (hi (inl_mem_extendedRoots B s)) + | ⟨Sum.inr j,hi⟩ => ⟨j,fun hj => hi ((inr_mem_extendedRoots B j).mpr hj)⟩ + invFun j := ⟨Sum.inr j.val,by simpa using j.property⟩ + left_inv i := by + rcases i with ⟨s|j,hi⟩ + · exact False.elim (hi (inl_mem_extendedRoots B s)) + · rfl + right_inv _ := rfl + +lemma extendedPrime_injective {S : Type*} + {J : Type*} + [Fintype S] + [DecidableEq S] + [Fintype J] + [DecidableEq J] + (ps : S → ℕ) + (p : J → ℕ) (hs : Function.Injective ps) (hp : Function.Injective p) + (hdis : ∀s j,ps s≠p j) : Function.Injective (extendedPrime ps p) := by + intro i j hij + cases i <;> cases j + · exact congrArg Sum.inl (hs hij) + · exact False.elim (hdis _ _ hij) + · exact False.elim (hdis _ _ hij.symm) + · exact congrArg Sum.inr (hp hij) + +instance extendedPrime_prime [∀s,Fact (ps s).Prime] [∀j,Fact (p j).Prime] : + ∀i,Fact (extendedPrime ps p i).Prime := fun i => by cases i <;> dsimp [extendedPrime] <;> infer_instance + +lemma extended_roots_modulus {S : Type*} + {J : Type*} + [Fintype S] + [DecidableEq S] + [Fintype J] + [DecidableEq J] + (ps : S → ℕ) + (p : J → ℕ) (B : Finset J) (hp2 : ∀j,p j≠2) : + rootSquareModulus (extendedPrime ps p) (extendedRoots (S:=S) B)= + (∏s,smallQuadraticModulus (ps s))*(∏j∈B,p j) := by + unfold rootSquareModulus extendedRoots + rw [prod_disjSum] + simp only [extendedPrime,Sum.elim_inl,Sum.elim_inr,smallQuadraticModulus,hp2,ite_false] + rfl + +lemma extended_outside_modulus (B : Finset J) (hp2 : ∀j,p j≠2) : + OutsideModulus (fun i => smallQuadraticModulus (extendedPrime ps p i)) (extendedRoots (S:=S) B)= + fun i => OutsideModulus p B (outsideSumEquiv (S:=S) B i) := by + funext i + rcases i with ⟨s|j,hi⟩ + · exact False.elim (hi (inl_mem_extendedRoots B s)) + · simp only [OutsideModulus,outsideSumEquiv,extendedPrime,Sum.elim_inr,smallQuadraticModulus,hp2,ite_false, + Equiv.coe_fn_mk] + +end Indexed + +lemma primary_product_cover {I : Type*} [Fintype I] [DecidableEq I] + (p : I → ℕ) (hinj : Function.Injective p) (N : ℕ) + (hcover : ∀r : ℕ,r.Prime → r≤N → ∃i,p i=r) + (q : ℕ) (hq : 0 hinj h)] at h + +end SquareDifference + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SquareDifference/PrimeGauss.lean b/lean/OAI/Combinatorics/SquareDifference/PrimeGauss.lean new file mode 100644 index 0000000000000000000000000000000000000000..e29837b9506f57fe2dfbf1c7aa8acd743591d191 --- /dev/null +++ b/lean/OAI/Combinatorics/SquareDifference/PrimeGauss.lean @@ -0,0 +1,525 @@ +import OAI.Combinatorics.SquareDifference.ScaleTransfer + +namespace OAI + +section + +open Finset + +open scoped ComplexConjugate BigOperators + +namespace SquareDifference + +lemma quadratic_gauss_ring {R : Type*} [CommRing R] [Fintype R] [DecidableEq R] + (ψ : AddChar R ℂ) (hψ : ψ.IsPrimitive) (a : R) (ha : IsUnit (2*a)) : + ‖∑ m : R, ψ (a*m^2)‖^2 = Fintype.card R := by + have hz (h : R) : 2*a*h=0 ↔ h=0 := by + rcases ha with ⟨u, hu⟩ + rw [← hu] + constructor + · intro he + have := congrArg (fun x : R => ↑u⁻¹*x) he + simpa only [← mul_assoc, Units.inv_mul, one_mul, mul_zero] using this + · rintro rfl; exact mul_zero _ + have he : (∑ m : R, ψ (a*m^2))*conj (∑ n : R, ψ (a*n^2)) = Fintype.card R := by + calc + _ = ∑ n : R, ∑ m : R, ψ (a*m^2-a*n^2) := by + simp only [map_sum, sum_mul, mul_sum, sub_eq_add_neg, AddChar.map_add_eq_mul, AddChar.map_neg_eq_conj] + _ = ∑ n : R, ∑ h : R, ψ (a*(h+n)^2-a*n^2) := by + apply sum_congr rfl + intro n _ + exact Fintype.sum_equiv (Equiv.subRight n) _ _ (by intro m; simp) + _ = ∑ h : R, ψ (a*h^2)*(∑ n : R, ψ ((2*a*h)*n)) := by + rw [sum_comm] + apply sum_congr rfl + intro h _ + rw [mul_sum] + apply sum_congr rfl + intro n _ + rw [← AddChar.map_add_eq_mul] + congr 1 + ring + _ = _ := by + simp_rw [mul_comm (2*a*_) _, AddChar.sum_mulShift _ hψ, hz] + simp + rw [Complex.mul_conj'] at he + exact_mod_cast he + +lemma quadratic_gauss_zmod (q : ℕ) [NeZero q] (a : ℤ) + (hq : q % 2 = 1) (ha : IsCoprime a (q : ℤ)) : + ‖∑ m : ZMod q, ZMod.stdAddChar ((a : ZMod q)*m^2)‖^2 = q := by + have h2 : IsUnit (2 : ZMod q) := by + apply (ZMod.isUnit_iff_coprime _ _).mpr + simpa only [Nat.coprime_comm, Nat.coprime_two_right] using (Nat.odd_iff.mpr hq) + have haa : IsUnit (a : ZMod q) := by + have h := ha.map (Int.castRingHom (ZMod q)) + apply isCoprime_zero_right.mp + simpa using h + simpa using quadratic_gauss_ring ZMod.stdAddChar (ZMod.isPrimitive_stdAddChar q) + (a : ZMod q) (h2.mul haa) + +lemma expect_surjective_addHom {G H : Type*} [AddGroup G] [AddGroup H] + [Fintype G] [Fintype H] (φ : G →+ H) (hφ : Function.Surjective φ) (f : H → ℂ) : + (𝔼 x : G, f (φ x))=𝔼 y : H, f y := by + have he (x : G) : (𝔼 y : H, f (φ x+y))=𝔼 y : H, f y := + Fintype.expect_equiv (Equiv.addLeft (φ x)) _ _ (fun _ => rfl) + have he' (y : H) : (𝔼 x : G, f (φ x+y))=𝔼 x : G, f (φ x) := by + obtain ⟨z,rfl⟩ := hφ y + simpa only [map_add] using + Fintype.expect_equiv (Equiv.addRight z) (fun x => f (φ x+φ z)) + (fun x => f (φ x)) (fun _ => by simp) + calc + _ = 𝔼 y : H, 𝔼 x : G, f (φ x+y) := by simp only [he', Fintype.expect_const] + _ = 𝔼 x : G, 𝔼 y : H, f (φ x+y) := expect_comm _ _ _ + _ = _ := by simp only [he, Fintype.expect_const] + +lemma zmod_factor_zero (m k : ℕ) (hk : k ≠ 0) (b : ℤ) : + (b : ZMod (m*k))*(k : ZMod (m*k))=0 ↔ (b : ZMod m)=0 := by + rw [← Int.cast_natCast k, ← Int.cast_mul, + ZMod.intCast_zmod_eq_zero_iff_dvd, ZMod.intCast_zmod_eq_zero_iff_dvd] + push_cast + exact mul_dvd_mul_iff_right (Int.natCast_ne_zero.mpr hk) + +lemma zmod_kernel_factor (m k : ℕ) [NeZero (m*k)] (x : ZMod (m*k)) + (hx : ZMod.castHom (dvd_mul_right m k) (ZMod m) x=0) : + x*(k : ZMod (m*k))=0 := by + have hk : k ≠ 0 := by intro he; subst k; simpa using (NeZero.ne (m*0)) + have he : ((x.val : ℤ) : ZMod m)=0 := by + have hh := congrArg (ZMod.castHom (dvd_mul_right m k) (ZMod m)) (ZMod.natCast_zmod_val x) + simp only [map_natCast] at hh + simpa only [Int.cast_natCast] using hh.trans hx + have hh := (zmod_factor_zero m k hk x.val).mpr he + simpa only [Int.cast_natCast, ZMod.natCast_zmod_val] using hh + +lemma quadratic_shift_cancellation {R : Type*} [CommRing R] [Fintype R] + (ψ : AddChar R ℂ) (a c : R) (w : R → ℂ) (ζ : ℂ) (hζ : ζ ≠ 1) + (hw : ∀ x, w (x+c)=w x) + (hphase : ∀ x, w x ≠ 0 → ψ (a*((x+c)^2-x^2))=ζ) : + ∑ x : R, w x*ψ (a*x^2)=0 := by + have hs : ∑ x : R, w x*ψ (a*x^2) = ζ*(∑ x : R, w x*ψ (a*x^2)) := by + calc + _ = ∑ x : R, w (x+c)*ψ (a*(x+c)^2) := + (Fintype.sum_equiv (Equiv.addRight c) _ _ (fun _ => rfl)).symm + _ = _ := by + rw [mul_sum] + apply sum_congr rfl + intro x _ + rw [hw] + by_cases hx : w x=0 + · simp [hx] + · have he : a*(x+c)^2=a*((x+c)^2-x^2)+a*x^2 := by ring + rw [he, AddChar.map_add_eq_mul, hphase x hx] + ring + have hz : (1-ζ)*(∑ x : R, w x*ψ (a*x^2))=0 := by linear_combination hs + exact (mul_eq_zero.mp hz).resolve_left (sub_ne_zero.mpr (Ne.symm hζ)) + +lemma zmod_fiber_translation (m k : ℕ) [NeZero (m*k)] + (c : ZMod m) (t : ZMod (m*k)) + (ht : ZMod.castHom (dvd_mul_right m k) (ZMod m) t=0) : + ∀ x : ZMod (m*k), + (if ZMod.castHom (dvd_mul_right m k) (ZMod m) (x+t)=c then (1 : ℂ) else 0)= + if ZMod.castHom (dvd_mul_right m k) (ZMod m) x=c then 1 else 0 := by + intro x + rw [map_add, ht, add_zero] + +lemma fiber_gauss_zero {p k : ℕ} [NeZero p] [NeZero k] + (hpk : p ∣ k) (a : ℤ) (c : ZMod p) + (hac : (2 : ZMod p)*(a : ZMod p)*c ≠ 0) : + ∑ x : ZMod (p*k), + (if ZMod.castHom (dvd_mul_right p k) (ZMod p) x=c then (1 : ℂ) else 0)* + ZMod.stdAddChar ((a : ZMod (p*k))*x^2)=0 := by + classical + have hk : k ≠ 0 := NeZero.ne k + let φ := ZMod.castHom (dvd_mul_right p k) (ZMod p) + let R := ZMod (p*k) + have ht : φ (k : R)=0 := by + dsimp only [φ] + rw [map_natCast] + exact (ZMod.natCast_eq_zero_iff k p).mpr hpk + have ht2 : (k : R)^2=0 := by + rw [pow_two] + exact zmod_kernel_factor p k (k : R) ht + let ζ := ZMod.stdAddChar ((2*(a : R)*(c.val : R))*(k : R)) + have hζ : ζ ≠ 1 := by + intro he + have he0 : (2*(a : R)*(c.val : R))*(k : R)=0 := by + apply ZMod.injective_stdAddChar + simpa only [AddChar.map_zero_eq_one] using he + have hzero : ((2*a*(c.val : ℤ) : ℤ) : ZMod p)=0 := + (zmod_factor_zero p k hk (2*a*c.val)).mp (by simpa using he0) + have hzero' : (2 : ZMod p)*(a : ZMod p)*c=0 := by simpa using hzero + exact hac hzero' + apply quadratic_shift_cancellation ZMod.stdAddChar (a : R) (k : R) _ ζ hζ + · exact zmod_fiber_translation p k c (k : R) ht + · intro x hx + have hxc : φ x=c := by + by_contra h + exact hx (ite_eq_right h) + have hkern : (x-(c.val : R))*(k : R)=0 := by + apply zmod_kernel_factor p k + change φ (x-(c.val : R))=0 + rw [map_sub, map_natCast, ZMod.natCast_zmod_val, hxc, sub_self] + have hxk : x*(k : R)=(c.val : R)*(k : R) := by linear_combination hkern + congr 1 + change (a : R)*((x+(k : R))^2-x^2)=(2*(a : R)*(c.val : R))*(k : R) + calc + _ = 2*(a : R)*(x*(k : R))+(a : R)*(k : R)^2 := by ring + _ = _ := by rw [hxk, ht2]; ring + +lemma odd_fiber_gauss_zero {p k : ℕ} [Fact p.Prime] (hp : p ≠ 2) + [NeZero k] (hpk : p ∣ k) (a : ℤ) (ha : (a : ZMod p) ≠ 0) + (c : ZMod p) (hc : c ≠ 0) : + ∑ x : ZMod (p*k), + (if ZMod.castHom (dvd_mul_right p k) (ZMod p) x=c then (1 : ℂ) else 0)* + ZMod.stdAddChar ((a : ZMod (p*k))*x^2)=0 := by + apply fiber_gauss_zero hpk a c + have h2 : (2 : ZMod p) ≠ 0 := + Ring.two_ne_zero (by simpa only [ZMod.ringChar_zmod_n] using hp) + exact mul_ne_zero (mul_ne_zero h2 ha) hc + +lemma weighted_fiber_sum {X Y : Type*} [Fintype X] [Fintype Y] [DecidableEq Y] + (φ : X → Y) (w : Y → ℂ) (f : X → ℂ) : + ∑ x, w (φ x)*f x = ∑ c, w c * ∑ x, (if φ x=c then (1 : ℂ) else 0)*f x := by + simp only [mul_sum] + rw [sum_comm] + apply sum_congr rfl + intro x _ + simp only [mul_ite, mul_zero, ite_mul, zero_mul] + simp + +lemma gauss_zero_of_fiber {p k : ℕ} [NeZero p] [NeZero k] + (hpk : p ∣ k) (a : ℤ) (w : ZMod p → ℂ) + (hw : ∀ c, w c ≠ 0 → (2 : ZMod p)*(a : ZMod p)*c ≠ 0) : + ∑ x : ZMod (p*k), w (ZMod.castHom (dvd_mul_right p k) (ZMod p) x)* + ZMod.stdAddChar ((a : ZMod (p*k))*x^2)=0 := by + classical + rw [weighted_fiber_sum] + apply sum_eq_zero + intro c _ + by_cases hc : w c=0 + · rw [hc, zero_mul] + · rw [fiber_gauss_zero hpk a c (hw c hc), mul_zero] + +lemma odd_unit_gauss_zero {p k : ℕ} [Fact p.Prime] [NeZero k] + (hp : p ≠ 2) (hpk : p ∣ k) (a : ℤ) (ha : (a : ZMod p) ≠ 0) : + ∑ x : ZMod (p*k), + (if ZMod.castHom (dvd_mul_right p k) (ZMod p) x ≠ 0 then (1 : ℂ) else 0)* + ZMod.stdAddChar ((a : ZMod (p*k))*x^2)=0 := by + apply gauss_zero_of_fiber hpk a (fun c => if c ≠ 0 then 1 else 0) + intro c hc + have hc0 : c ≠ 0 := by intro he; simp [he] at hc + have h2 : (2 : ZMod p) ≠ 0 := + Ring.two_ne_zero (by simpa only [ZMod.ringChar_zmod_n] using hp) + exact mul_ne_zero (mul_ne_zero h2 ha) hc0 + +lemma four_unit_mul_two {a c : ZMod 4} (ha : IsUnit a) (hc : IsUnit c) : + 2*a*c ≠ 0 := by + rcases ha with ⟨a,rfl⟩ + rcases hc with ⟨c,rfl⟩ + intro hz + have h := congrArg (fun x : ZMod 4 => x*(↑c⁻¹)*(↑a⁻¹)) hz + have h2 : (2 : ZMod 4) ≠ 0 := by decide + apply h2 + simpa only [mul_assoc, Units.mul_inv_cancel_left, Units.mul_inv, mul_one, zero_mul] using h + +lemma two_unit_gauss_zero {k : ℕ} [NeZero k] + (hk : 4 ∣ k) (a : ℤ) (ha : IsUnit (a : ZMod 4)) : + ∑ x : ZMod (4*k), + (if IsUnit (ZMod.castHom (dvd_mul_right 4 k) (ZMod 4) x) then (1 : ℂ) else 0)* + ZMod.stdAddChar ((a : ZMod (4*k))*x^2)=0 := by + classical + apply gauss_zero_of_fiber hk a (fun c => if IsUnit c then 1 else 0) + intro c hc + have hc0 : IsUnit c := by by_contra he; simp [he] at hc + exact four_unit_mul_two ha hc0 + +lemma quadratic_gauss_ring_linear {R : Type*} [CommRing R] [Fintype R] [DecidableEq R] + (ψ : AddChar R ℂ) (hψ : ψ.IsPrimitive) (a b : R) (ha : IsUnit (2*a)) : + ‖∑ m : R, ψ (a*m^2+b*m)‖^2 = Fintype.card R := by + have hz (h : R) : 2*a*h=0 ↔ h=0 := by + rcases ha with ⟨u, hu⟩ + rw [← hu] + constructor + · intro he + have := congrArg (fun x : R => ↑u⁻¹*x) he + simpa only [← mul_assoc, Units.inv_mul, one_mul, mul_zero] using this + · rintro rfl; exact mul_zero _ + have he : (∑ m : R, ψ (a*m^2+b*m))*conj (∑ n : R, ψ (a*n^2+b*n)) = Fintype.card R := by + calc + _ = ∑ n : R, ∑ m : R, ψ ((a*m^2+b*m)-(a*n^2+b*n)) := by + simp only [map_sum, sum_mul, mul_sum, sub_eq_add_neg, AddChar.map_add_eq_mul, AddChar.map_neg_eq_conj] + _ = ∑ n : R, ∑ h : R, ψ ((a*(h+n)^2+b*(h+n))-(a*n^2+b*n)) := by + apply sum_congr rfl + intro n _ + exact Fintype.sum_equiv (Equiv.subRight n) _ _ (by intro m; simp) + _ = ∑ h : R, ψ (a*h^2+b*h)*(∑ n : R, ψ ((2*a*h)*n)) := by + rw [sum_comm] + apply sum_congr rfl + intro h _ + rw [mul_sum] + apply sum_congr rfl + intro n _ + rw [← AddChar.map_add_eq_mul] + congr 1 + ring + _ = _ := by + simp_rw [mul_comm (2*a*_) _, AddChar.sum_mulShift _ hψ, hz] + simp + rw [Complex.mul_conj'] at he + exact_mod_cast he + +lemma norm_quadratic_expect {R : Type*} [CommRing R] [Fintype R] [DecidableEq R] + (ψ : AddChar R ℂ) (hψ : ψ.IsPrimitive) (a b : R) (ha : IsUnit (2*a)) : + ‖𝔼 m : R, ψ (a*m^2+b*m)‖= (Fintype.card R : ℝ)^(-(1:ℝ)/2) := by + have hc : (0:ℝ) c i*z) + apply expect_congr rfl + intro m _ + exact mul_comm _ _ + rw [he] + calc + _ ≤ ∑ i, ‖c i*(𝔼 m : R, ψ (a*m^2+b i*m))‖ := norm_sum_le _ _ + _ = _ := by simp only [norm_mul, norm_quadratic_expect ψ hψ a _ ha, ← sum_mul] + +noncomputable def primeSieveWeight (p : ℕ) (x : ZMod p) : ℝ := + ((p : ℝ)*(if x=0 then 1 else 0)-1)/(p-1) + +lemma primeSieveWeight_fourier {p : ℕ} [Fact p.Prime] (x : ZMod p) : + (primeSieveWeight p x : ℂ)=(p-1 : ℂ)⁻¹*∑ a∈univ.erase 0, ZMod.stdAddChar (a*x) := by + classical + have he : ∑ a : ZMod p, ZMod.stdAddChar (a*x)= + if x=0 then (p : ℂ) else 0 := by + simpa only [ZMod.card, Nat.cast_ite, Nat.cast_zero] using + AddChar.sum_mulShift x (ZMod.isPrimitive_stdAddChar p) + have hs := sum_erase_add (univ : Finset (ZMod p)) (fun a => ZMod.stdAddChar (a*x)) (mem_univ 0) + rw [zero_mul, AddChar.map_zero_eq_one, he] at hs + unfold primeSieveWeight + push_cast + rw [div_eq_inv_mul] + congr 1 + by_cases hx : x=0 + · rw [ite_eq_left hx] at hs ⊢ + push_cast + linear_combination -hs + · rw [ite_eq_right hx] at hs ⊢ + push_cast + linear_combination -hs + +lemma primeSieveWeight_abs_le {p : ℕ} [Fact p.Prime] (x : ZMod p) : + |primeSieveWeight p x|≤1 := by + have hp : (1:ℝ)

(k : ZMod (p*k))*(z : ZMod (p*k)) + map_zero' := by simp + map_add' := by intros; simp only [Int.cast_add, mul_add] }, by + change (k : ZMod (p*k))*((p : ℤ) : ZMod (p*k))=0 + rw [Int.cast_natCast] + rw [← Nat.cast_mul, mul_comm k p, ZMod.natCast_self]⟩ + +lemma zmodScaleHom_int (p k : ℕ) (z : ℤ) : + zmodScaleHom p k (z : ZMod p)=(k : ZMod (p*k))*(z : ZMod (p*k)) := + ZMod.lift_coe p _ z + +lemma zmodScaleHom_nat (p k z : ℕ) : + zmodScaleHom p k (z : ZMod p)=(k : ZMod (p*k))*(z : ZMod (p*k)) := by + simpa only [Int.cast_natCast] using zmodScaleHom_int p k (z : ℤ) + +lemma zmodScaleHom_injective (p k : ℕ) [NeZero p] (hk : k≠0) : Function.Injective (zmodScaleHom p k) := by + apply (injective_iff_map_eq_zero _).mpr + intro x hx + have he : ((x.val : ℤ) : ZMod p)=0 := (zmod_factor_zero p k hk (x.val : ℤ)).mp (by + rw [mul_comm ((x.val : ℤ) : ZMod (p*k)) (k : ZMod (p*k)), ← zmodScaleHom_int, Int.cast_natCast, ZMod.natCast_zmod_val] + exact hx) + simpa only [Int.cast_natCast, ZMod.natCast_zmod_val] using he + +lemma zmodScaleHom_mul {p k : ℕ} [NeZero p] [NeZero k] (t : ZMod p) (x : ZMod (p*k)) : + zmodScaleHom p k (t*(ZMod.castHom (dvd_mul_right p k) (ZMod p) x))= + zmodScaleHom p k t*x := by + have ht := ZMod.natCast_zmod_val t + have hx := ZMod.natCast_zmod_val x + conv_lhs => rw [← ht, ← hx] + simp only [map_natCast, ← Nat.cast_mul] + rw [← Int.cast_natCast, zmodScaleHom_int] + simp only [Int.cast_mul, Int.cast_natCast, Nat.cast_mul] + rw [ZMod.natCast_zmod_val, ← mul_assoc, ← zmodScaleHom_nat p k t.val, + ZMod.natCast_zmod_val] + +lemma zmodScale_primitive {p k : ℕ} [Fact p.Prime] (hk : k≠0) + (ψ : AddChar (ZMod (p*k)) ℂ) (hψ : ψ.IsPrimitive) : + (ψ.compAddMonoidHom (zmodScaleHom p k)).IsPrimitive := by + have : NeZero k := ⟨hk⟩ + apply AddChar.IsPrimitive.of_ne_one + intro he + have hh := congrArg (fun χ : AddChar (ZMod p) ℂ => χ 1) he + simp only [AddChar.compAddMonoidHom_apply, AddChar.one_apply] at hh + have hz := (hψ.zmod_char_eq_one_iff (p*k) _).mp hh + have h1 : (1 : ZMod p)=0 := zmodScaleHom_injective p k hk (by simpa using hz) + exact one_ne_zero h1 + +lemma primeSieveWeight_fourier_char {p : ℕ} [Fact p.Prime] + (ψ : AddChar (ZMod p) ℂ) (hψ : ψ.IsPrimitive) (x : ZMod p) : + (primeSieveWeight p x : ℂ)=(p-1 : ℂ)⁻¹*∑ a∈univ.erase 0, ψ (a*x) := by + classical + have he : ∑ a : ZMod p, ψ (a*x)=if x=0 then (p : ℂ) else 0 := by + simpa only [ZMod.card, Nat.cast_ite, Nat.cast_zero] using AddChar.sum_mulShift x hψ + have hs := sum_erase_add (univ : Finset (ZMod p)) (fun a => ψ (a*x)) (mem_univ 0) + rw [zero_mul, AddChar.map_zero_eq_one, he] at hs + unfold primeSieveWeight + push_cast + rw [div_eq_inv_mul] + congr 1 + by_cases hx : x=0 + · rw [ite_eq_left hx] at hs ⊢ + push_cast + linear_combination -hs + · rw [ite_eq_right hx] at hs ⊢ + push_cast + linear_combination -hs + +def HasFourierBound {R : Type*} [CommRing R] [Fintype R] + (ψ : AddChar R ℂ) (w : R → ℂ) (C : ℝ) : Prop := + ∃ c : R → ℂ, (∀x, w x=∑a, c a*ψ (a*x)) ∧ (∑a, ‖c a‖)≤C + +lemma hasFourierBound_of_expansion {R I : Type*} [CommRing R] [Fintype R] [Fintype I] + (ψ : AddChar R ℂ) (w : R → ℂ) (b : I → R) (c : I → ℂ) (C : ℝ) + (hw : ∀x, w x=∑i, c i*ψ (b i*x)) (hc : (∑i, ‖c i‖)≤C) : + HasFourierBound ψ w C := by + classical + refine ⟨fun a => ∑i, if b i=a then c i else 0, ?_, ?_⟩ + · intro x + rw [hw] + simp only [sum_mul, ite_mul, zero_mul] + rw [sum_comm] + apply sum_congr rfl + intro i _ + simp + · calc + _ ≤ ∑a : R, ∑i : I, ‖if b i=a then c i else 0‖ := sum_le_sum fun _ _ => norm_sum_le _ _ + _ = ∑i, ‖c i‖ := by + simp only [apply_ite norm, norm_zero] + rw [sum_comm] + simp + _ ≤ C := hc + +lemma hasFourierBound_one {R : Type*} [CommRing R] [Fintype R] + (ψ : AddChar R ℂ) : HasFourierBound ψ (fun _ => 1) 1 := by + apply hasFourierBound_of_expansion ψ (fun _ => 1) (fun _ : Unit => 0) (fun _ => 1) + · intro x; simp + · simp + +lemma HasFourierBound.mul {R : Type*} [CommRing R] [Fintype R] + {ψ : AddChar R ℂ} {w v : R → ℂ} {C D : ℝ} + (hw : HasFourierBound ψ w C) (hv : HasFourierBound ψ v D) : + HasFourierBound ψ (fun x => w x*v x) (C*D) := by + rcases hw with ⟨c,hc,hC⟩ + rcases hv with ⟨d,hd,hD⟩ + have h0 : 0≤C := (sum_nonneg fun _ _ => norm_nonneg _).trans hC + apply hasFourierBound_of_expansion ψ _ (fun a : R×R => a.1+a.2) + (fun a => c a.1*d a.2) + · intro x + rw [hc, hd, ← univ_product_univ, sum_product, sum_mul] + apply sum_congr rfl + intro a _ + rw [mul_sum] + apply sum_congr rfl + intro b _ + simp only [add_mul, AddChar.map_add_eq_mul] + ring + · rw [← univ_product_univ, sum_product] + simp only [norm_mul, ← mul_sum, ← sum_mul] + exact mul_le_mul hC hD (sum_nonneg fun _ _ => norm_nonneg _) h0 + +lemma hasFourierBound_prod {R I : Type*} [CommRing R] [Fintype R] [DecidableEq I] + (ψ : AddChar R ℂ) (S : Finset I) (w : I → R → ℂ) + (hw : ∀i∈S, HasFourierBound ψ (w i) 1) : + HasFourierBound ψ (fun x => ∏i∈S, w i x) 1 := by + induction S using Finset.induction_on with + | empty => simpa only [prod_empty] using hasFourierBound_one ψ + | @insert a S ha ih => + have h1 := hw a (mem_insert_self _ _) + have h2 := ih (fun i hi => hw i (mem_insert_of_mem hi)) + simpa only [one_mul, prod_insert ha] using h1.mul h2 + +lemma primeSieveWeight_fourier_bound {p k : ℕ} [Fact p.Prime] [NeZero k] + (ψ : AddChar (ZMod (p*k)) ℂ) (hψ : ψ.IsPrimitive) : + HasFourierBound ψ (fun x => (primeSieveWeight p (ZMod.castHom (dvd_mul_right p k) (ZMod p) x) : ℂ)) 1 := by + classical + apply hasFourierBound_of_expansion ψ _ (fun a : ZMod p => zmodScaleHom p k a) + (fun a : ZMod p => if a=0 then 0 else (p-1 : ℂ)⁻¹) + · intro x + rw [primeSieveWeight_fourier_char _ (zmodScale_primitive (NeZero.ne k) ψ hψ)] + simp only [AddChar.compAddMonoidHom_apply, zmodScaleHom_mul, mul_sum, ite_mul, zero_mul] + rw [← sum_erase (univ : Finset (ZMod p)) (a := 0) (f := fun a => if a=0 then 0 else (p-1 : ℂ)⁻¹*ψ (zmodScaleHom p k a*x)) (by simp)] + apply sum_congr rfl + intro a ha + rw [ite_eq_right (mem_erase.mp ha).1] + · have hp : (0:ℝ) ‖if a=0 then (0 : ℂ) else (p-1 : ℂ)⁻¹‖) (by simp)] + have he : (∑a∈(univ : Finset (ZMod p)).erase 0, ‖if a=0 then (0 : ℂ) else (p-1 : ℂ)⁻¹‖)= + ((p : ℝ)-1)*((p : ℝ)-1)⁻¹ := by + calc + _ = ∑_a∈(univ : Finset (ZMod p)).erase 0, ((p : ℝ)-1)⁻¹ := by + apply sum_congr rfl + intro a ha + rw [ite_eq_right (mem_erase.mp ha).1, norm_inv, hn] + _ = _ := by + rw [sum_const, nsmul_eq_mul, card_erase_of_mem (mem_univ 0), card_univ, ZMod.card, + Nat.cast_sub (Fact.out : p.Prime).one_lt.le, Nat.cast_one] + rw [he, mul_inv_cancel₀ hp.ne'] + +end SquareDifference +end + +end OAI diff --git a/lean/OAI/Combinatorics/SquareDifference/PrimeSetup.lean b/lean/OAI/Combinatorics/SquareDifference/PrimeSetup.lean new file mode 100644 index 0000000000000000000000000000000000000000..12c9d4be8d274990df377bb009d3a104466da16a --- /dev/null +++ b/lean/OAI/Combinatorics/SquareDifference/PrimeSetup.lean @@ -0,0 +1,103 @@ +import OAI.Combinatorics.SquareDifference.InductiveBounds + +namespace OAI + +section + +open Finset + +namespace SquareDifference + +structure SourcePrimeHyp {S J : Type} [Fintype S] [DecidableEq S] [Fintype J] [DecidableEq J] + (ps : S → ℕ) (p : J → ℕ) [∀s,Fact (ps s).Prime] [∀j,Fact (p j).Prime] (N : ℕ) : Prop where + injective : Function.Injective (extendedPrime ps p) + lower : ∀j,64≤p j + mass : ∀j,max tupleMassThreshold tupleConditionalThreshold≤(p j:ℝ) + reflection : ∀j,tupleReflectionThreshold≤(p j:ℝ) + coprime : ∀j,(smallModulus ps).Coprime (p j) + exceptional : ∀j,tupleEta (p j)≤1/(p j:ℝ)^4 + cover : ∀r : ℕ,r.Prime → r≤N → ∃i,extendedPrime ps p i=r + +lemma SourcePrimeHyp.mono {S J : Type} [Fintype S] [DecidableEq S] [Fintype J] [DecidableEq J] + {ps : S → ℕ} {p : J → ℕ} [∀s,Fact (ps s).Prime] [∀j,Fact (p j).Prime] + {N n : ℕ} (h : SourcePrimeHyp ps p N) (hn : n≤N) : SourcePrimeHyp ps p n := + ⟨h.injective,h.lower,h.mass,h.reflection,h.coprime,h.exceptional,fun r hr hrn => h.cover r hr (hrn.trans hn)⟩ + +def smallPrimeSet (P : ℕ) : Finset ℕ := (range P).filter Nat.Prime + +def largePrimeSet (P N : ℕ) : Finset ℕ := (Icc P N).filter Nat.Prime + +abbrev SmallPrime (P : ℕ) := ↥(smallPrimeSet P) + +abbrev LargePrime (P N : ℕ) := ↥(largePrimeSet P N) + +def smallPrimes (P : ℕ) : SmallPrime P → ℕ := Subtype.val + +def largePrimes (P N : ℕ) : LargePrime P N → ℕ := Subtype.val + +instance smallPrimes_fact (P : ℕ) (s : SmallPrime P) : Fact (smallPrimes P s).Prime := + ⟨(mem_filter.mp s.property).2⟩ + +instance largePrimes_fact (P N : ℕ) (s : LargePrime P N) : Fact (largePrimes P N s).Prime := + ⟨(mem_filter.mp s.property).2⟩ + +lemma smallPrimes_lt (P : ℕ) (s : SmallPrime P) : smallPrimes P s

cases j with + | inl j => exact congrArg Sum.inl (Subtype.ext hij) + | inr j => have h1 := smallPrimes_lt P i; have h2 := largePrimes_ge P N j; change smallPrimes P i=largePrimes P N j at hij; omega + | inr i => cases j with + | inl j => have h1 := largePrimes_ge P N i; have h2 := smallPrimes_lt P j; change largePrimes P N i=smallPrimes P j at hij; omega + | inr j => exact congrArg Sum.inr (Subtype.ext hij) + +lemma actualPrime_cover (P N : ℕ) (r : ℕ) (hr : r.Prime) (hrN : r≤N) : + ∃i,extendedPrime (smallPrimes P) (largePrimes P N) i=r := by + by_cases h : r

hP.trans (largePrimes_ge P N j),fun j => (hh j).1, + fun j => (hh j).2.1,actualPrime_coprime P N,fun j => (hh j).2.2,actualPrime_cover P N⟩ + +end SquareDifference + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SquareDifference/ProductBounds.lean b/lean/OAI/Combinatorics/SquareDifference/ProductBounds.lean new file mode 100644 index 0000000000000000000000000000000000000000..fa196e04f4f5f2b943152f8ca613b94350f0dd22 --- /dev/null +++ b/lean/OAI/Combinatorics/SquareDifference/ProductBounds.lean @@ -0,0 +1,527 @@ +import OAI.Combinatorics.SquareDifference.TupleWeights + +namespace OAI + +section +open Finset +open scoped BigOperators +namespace SquareDifference +open Finset + +lemma patch_insert_update {J : Type*} [DecidableEq J] {X : J → Type*} + (s : Finset J) (j : J) (_hj : j∉s) (x y : ∀ j, X j) (t : X j) : + patch (insert j s) x (Function.update y j t)=Function.update (patch s x y) j t := by + ext k + by_cases hk : k=j + · subst k; simp [patch] + · simp [patch, hk] + +noncomputable def partialOp {J : Type*} [Fintype J] [DecidableEq J] + {X : J → Type*} [∀ j, Fintype (X j)] + (K : ∀ j, Matrix (X j) (X j) ℝ) (s : Finset J) + (f : (∀ j, X j) → ℝ) (x : ∀ j, X j) : ℝ := + 𝔼 y : ∀ j, X j, (∏ j ∈ s, K j (x j) (y j))*f (patch s x y) + +lemma partialOp_empty {J : Type*} [Fintype J] [DecidableEq J] + {X : J → Type*} [∀ j, Fintype (X j)] [∀ j, Nonempty (X j)] + (K : ∀ j, Matrix (X j) (X j) ℝ) (f : (∀ j, X j) → ℝ) (x : ∀ j, X j) : + partialOp K ∅ f x=f x := by simp [partialOp, patch_empty] + +lemma partialOp_smul {J : Type*} [Fintype J] [DecidableEq J] + {X : J → Type*} [∀ j, Fintype (X j)] + (K : ∀ j, Matrix (X j) (X j) ℝ) (s : Finset J) + (f : (∀ j, X j) → ℝ) (c : ℝ) (x : ∀ j, X j) : + partialOp K s (fun y => c*f y) x=c*partialOp K s f x := by + simp only [partialOp, mul_left_comm _ c, ← mul_expect] + +lemma partialOp_insert {J : Type*} [Fintype J] [DecidableEq J] + {X : J → Type*} [∀ j, Fintype (X j)] [∀ j, Nonempty (X j)] + (K : ∀ j, Matrix (X j) (X j) ℝ) (s : Finset J) (j : J) (hj : j∉s) + (f : (∀ j, X j) → ℝ) (x : ∀ j, X j) : + partialOp K (insert j s) f x=partialOp K s (coordOp K j f) x := by + unfold partialOp + rw [← expect_update_dep j (fun y : ∀ j, X j => + (∏ k ∈ insert j s, K k (x k) (y k))*f (patch (insert j s) x y))] + apply expect_congr rfl + intro y _ + unfold coordOp + rw [mul_expect] + apply expect_congr rfl + intro t _ + have hp : (∏ k ∈ s, K k (x k) (Function.update y j t k))= + ∏ k ∈ s, K k (x k) (y k) := by + apply prod_congr rfl + intro k hk + rw [Function.update_of_ne (ne_of_mem_of_not_mem hk hj)] + simp only [prod_insert hj, Function.update_self, hp, patch_insert_update s j hj, + patch, ite_eq_right hj] + ring + +lemma partialOp_eigen {J : Type*} [Fintype J] [DecidableEq J] + {X : J → Type*} [∀ j, Fintype (X j)] [∀ j, Nonempty (X j)] + (K : ∀ j, Matrix (X j) (X j) ℝ) (lam : J → ℝ) (f : (∀ j, X j) → ℝ) + (he : ∀ j, coordOp K j f=fun x => lam j*f x) (s : Finset J) (x : ∀ j, X j) : + partialOp K s f x=(∏ j ∈ s, lam j)*f x := by + induction s using Finset.induction_on with + | empty => simp [partialOp_empty] + | @insert j s hj ih => + rw [partialOp_insert K s j hj, he j, partialOp_smul, ih, prod_insert hj, mul_assoc] + +lemma product_kernel_eigen {J : Type*} [Fintype J] [DecidableEq J] + {X : J → Type*} [∀ j, Fintype (X j)] [∀ j, Nonempty (X j)] + (K : ∀ j, Matrix (X j) (X j) ℝ) (lam : J → ℝ) (f : (∀ j, X j) → ℝ) + (he : ∀ j, coordOp K j f=fun x => lam j*f x) (x : ∀ j, X j) : + (𝔼 y, (∏ j, K j (x j) (y j))*f y)=(∏ j, lam j)*f x := by + simpa only [partialOp, patch_univ] using partialOp_eigen K lam f he univ x + +def ExactSupport {J : Type*} [DecidableEq J] + {X : J → Type*} [∀ j, Fintype (X j)] (U : Finset J) + (f : (∀ j, X j) → ℝ) : Prop := + (∀ j∈U, ∀ x, (𝔼 t : X j, f (Function.update x j t))=0) ∧ + (∀ j∉U, ∀ x t, f (Function.update x j t)=f x) + +lemma coordOp_noise {J : Type*} [DecidableEq J] + {X : J → Type*} [∀ j, Fintype (X j)] [∀ j, Nonempty (X j)] + [∀ j, DecidableEq (X j)] (d : J → ℝ) (j : J) + (f : (∀ j, X j) → ℝ) (x : ∀ j, X j) : + coordOp (fun j => noiseKernel (X := X j) (d j)) j f x = + (1-(d j)^2)*(𝔼 t, f (Function.update x j t))+(d j)^2*f x := by + have hn : (Fintype.card (X j) : ℝ) ≠ 0 := Nat.cast_ne_zero.mpr Fintype.card_ne_zero + have hh : (𝔼 t : X j, (if x j=t then (1 : ℝ) else 0)*f (Function.update x j t))= + f x/(Fintype.card (X j) : ℝ) := by + simp [expect_eq_sum_div_card] + unfold coordOp noiseKernel + simp only [add_mul, expect_add_distrib, ← mul_expect, mul_assoc, hh] + field_simp + +lemma noise_product_exactSupport {J : Type*} [Fintype J] [DecidableEq J] + {X : J → Type*} [∀ j, Fintype (X j)] [∀ j, Nonempty (X j)] + [∀ j, DecidableEq (X j)] (d : J → ℝ) (U : Finset J) + (f : (∀ j, X j) → ℝ) (hf : ExactSupport U f) (x : ∀ j, X j) : + (𝔼 y, (∏ j, noiseKernel (d j) (x j) (y j))*f y)= + (∏ j∈U, (d j)^2)*f x := by + have he j : coordOp (fun j => noiseKernel (X := X j) (d j)) j f = + fun x => (if j∈U then (d j)^2 else 1)*f x := by + funext x + rw [coordOp_noise] + by_cases hj : j∈U + · rw [ite_eq_left hj, hf.1 j hj x, mul_zero, zero_add] + · simp only [ite_eq_right hj, hf.2 j hj, Fintype.expect_const] + ring + have hh := product_kernel_eigen (fun j => noiseKernel (X := X j) (d j)) + (fun j => if j∈U then (d j)^2 else 1) f he x + simpa only [prod_ite_mem, univ_inter] using hh + +lemma exactSupport_orthogonal {J : Type*} [Fintype J] [DecidableEq J] + {X : J → Type*} [∀ j, Fintype (X j)] [∀ j, Nonempty (X j)] + {U V : Finset J} (hUV : U≠V) (f g : (∀ j, X j) → ℝ) + (hf : ExactSupport U f) (hg : ExactSupport V g) : (𝔼 x, f x*g x)=0 := by + have hsep {U V : Finset J} (f g : (∀ j, X j) → ℝ) + (hf : ExactSupport U f) (hg : ExactSupport V g) (j : J) (hju : j∈U) (hjv : j∉V) : + (𝔼 x, f x*g x)=0 := by + rw [← expect_update_dep j] + simp only [hg.2 j hjv, ← expect_mul, hf.1 j hju, zero_mul, Fintype.expect_const] + by_cases h : U⊆V + · obtain ⟨j,hjv,hju⟩ := not_subset.mp (show ¬V⊆U from fun hh => hUV (Subset.antisymm h hh)) + simpa only [mul_comm] using hsep g f hg hf j hjv hju + · obtain ⟨j,hju,hjv⟩ := not_subset.mp h + exact hsep f g hf hg j hju hjv + +lemma orthogonal_sum_square {I X : Type*} [Fintype X] [DecidableEq I] + (s : Finset I) (f : I → X → ℝ) + (horth : ∀ i∈s, ∀ j∈s, i≠j → (𝔼 x, f i x*f j x)=0) : + (𝔼 x, (∑ i∈s, f i x)^2)=∑ i∈s, (𝔼 x, f i x^2) := by + simp only [pow_two, sum_mul, mul_sum, expect_sum_comm] + apply sum_congr rfl + intro i hi + rw [sum_eq_single i] + · intro j hj hji + exact horth j hj i hi hji + · simp [hi] + +lemma kernelForm_eigen_sum {I X : Type*} [Fintype X] [DecidableEq I] + (K : Matrix X X ℝ) (s : Finset I) (f : I → X → ℝ) (lam : I → ℝ) + (heigen : ∀ i∈s, ∀ x, (𝔼 y, K x y*f i y)=lam i*f i x) + (horth : ∀ i∈s, ∀ j∈s, i≠j → (𝔼 x, f i x*f j x)=0) : + kernelForm K (fun x => ∑ i∈s, f i x) (fun x => ∑ i∈s, f i x) = + ∑ i∈s, lam i*(𝔼 x, f i x^2) := by + have hm x : (𝔼 y, K x y*(∑ i∈s, f i y))=∑ i∈s, lam i*f i x := by + rw [show (fun y => K x y*(∑ i∈s, f i y)) = + (fun y => ∑ i∈s, K x y*f i y) from funext fun _ => mul_sum .., expect_sum_comm] + exact sum_congr rfl fun i hi => heigen i hi x + change (𝔼 x, 𝔼 y, (∑ i∈s, f i x)*K x y*(∑ i∈s, f i y))=_ + simp only [mul_assoc, ← mul_expect, hm] + simp only [sum_mul, mul_sum, expect_sum_comm] + apply sum_congr rfl + intro j hj + rw [sum_eq_single j] + · simp only [mul_left_comm (f j _) (lam j), ← mul_expect, pow_two] + · intro i hi hij + simp only [mul_left_comm (f i _) (lam j), ← mul_expect, horth i hi j hj hij, mul_zero] + · simp [hj] + +lemma noise_product_bound {J : Type*} [Fintype J] [DecidableEq J] + {X : J → Type*} [∀ j, Fintype (X j)] [∀ j, Nonempty (X j)] + [∀ j, DecidableEq (X j)] (d : J → ℝ) (s : Finset (Finset J)) + (f : Finset J → (∀ j, X j) → ℝ) (hf : ∀ U∈s, ExactSupport U (f U)) + (a : ℝ) (ha : ∀ U∈s, (∏ j∈U, (d j)^2) ≤ a) : + kernelForm (fun x y => ∏ j, noiseKernel (d j) (x j) (y j)) + (fun x => ∑ U∈s, f U x) (fun x => ∑ U∈s, f U x) ≤ + a*(𝔼 x, (∑ U∈s, f U x)^2) := by + have ho U hU V hV hUV := exactSupport_orthogonal hUV (f U) (f V) (hf U hU) (hf V hV) + rw [kernelForm_eigen_sum _ s f (fun U => ∏ j∈U, (d j)^2) + (fun U hU x => noise_product_exactSupport d U (f U) (hf U hU) x) ho, + orthogonal_sum_square s f ho, mul_sum] + exact sum_le_sum fun U hU => mul_le_mul_of_nonneg_right (ha U hU) + (expect_nonneg fun _ _ => sq_nonneg _) + +lemma expect_prod_pi {J : Type*} [Fintype J] [DecidableEq J] + {X : J → Type*} [∀ j, Fintype (X j)] (f : ∀ j, X j → ℝ) : + (𝔼 x : ∀ j, X j, ∏ j, f j (x j))=∏ j, (𝔼 t : X j, f j t) := by + simp only [expect_eq_sum_div_card, card_univ, prod_div_distrib, + Fintype.card_pi, Nat.cast_prod] + rw [Fintype.prod_sum] + +lemma conditionalGram_product {J : Type*} [Fintype J] [DecidableEq J] + {X Y : J → Type*} [∀ j, Fintype (X j)] [∀ j, Fintype (Y j)] + (W : ∀ j, X j → Y j → ℝ) : + conditionalGram (fun (x : ∀ j, X j) (y : ∀ j, Y j) => ∏ j, W j (x j) (y j)) = + fun (x : ∀ j, X j) (x' : ∀ j, X j) => ∏ j, conditionalGram (W j) (x j) (x' j) := by + funext x x' + change (𝔼 y : ∀ j, Y j, (∏ j, W j (x j) (y j))*(∏ j, W j (x' j) (y j))/ + (𝔼 z : ∀ j, X j, ∏ j, W j (z j) (y j))) = + ∏ j, (𝔼 t : Y j, W j (x j) t*W j (x' j) t/(𝔼 z : X j, W j z t)) + have hd (y : ∀ j, Y j) : (𝔼 z : ∀ j, X j, ∏ j, W j (z j) (y j)) = + ∏ j, (𝔼 z : X j, W j z (y j)) := expect_prod_pi (fun j z => W j z (y j)) + simp only [hd, ← prod_mul_distrib, ← prod_div_distrib] + exact expect_prod_pi (fun j t => W j (x j) t*W j (x' j) t/(𝔼 z : X j, W j z t)) + +lemma tensor_conditional_decay {J : Type*} [Fintype J] [DecidableEq J] + {X Y : J → Type*} [∀ j, Fintype (X j)] [∀ j, Nonempty (X j)] + [∀ j, DecidableEq (X j)] [∀ j, Fintype (Y j)] + (W : ∀ j, X j → Y j → ℝ) (hW : ∀ j x y, 0 ≤ W j x y) + (hrow : ∀ j x, (𝔼 y, W j x y)=1) (d : J → ℝ) + (hmix : ∀ j, ∀ f : X j → ℝ, (𝔼 x, f x)=0 → + conditionalEnergy (W j) f ≤ (d j)^2*(𝔼 x, f x^2)) + (s : Finset (Finset J)) (f : Finset J → (∀ j, X j) → ℝ) + (hf : ∀ U∈s, ExactSupport U (f U)) (a : ℝ) + (ha : ∀ U∈s, (∏ j∈U, (d j)^2) ≤ a) : + conditionalEnergy (fun (x : ∀ j, X j) (y : ∀ j, Y j) => ∏ j, W j (x j) (y j)) (fun x => ∑ U∈s, f U x) ≤ + a*(𝔼 x, (∑ U∈s, f U x)^2) := by + have hd := product_kernel_monotone + (fun j => conditionalGram (W j)) (fun j => noiseKernel (X := X j) (d j)) + (fun j => conditionalGram_posSemidef (W j) (hW j)) + (fun j => conditionalGram_noise_domination (W j) (hW j) (hrow j) (d j) (hmix j)) + let g := fun x => ∑ U∈s, f U x + have hd' : 0 ≤ kernelForm (fun x y => + (∏ j, noiseKernel (d j) (x j) (y j))- + (∏ j, conditionalGram (W j) (x j) (y j))) g g := by + apply (kernelForm_nonneg_iff _ ?_).mp hd g + intro x y + simp only [noiseKernel, eq_comm, conditionalGram_symm] + have he : kernelForm (fun x y => + (∏ j, noiseKernel (d j) (x j) (y j))- + (∏ j, conditionalGram (W j) (x j) (y j))) g g = + kernelForm (fun x y => ∏ j, noiseKernel (d j) (x j) (y j)) g g- + conditionalEnergy (fun (x : ∀ j, X j) (y : ∀ j, Y j) => ∏ j, W j (x j) (y j)) g := by + rw [← kernelForm_conditionalGram, conditionalGram_product] + unfold kernelForm + simp only [mul_sub, sub_mul, expect_sub_distrib] + rw [he] at hd' + exact (sub_nonneg.mp hd').trans (noise_product_bound d s f hf a ha) + +end SquareDifference + +namespace SquareDifference + +open Finset + +lemma conditional_bilinear_sq {X Y : Type*} [Fintype X] [Fintype Y] + (W : X → Y → ℝ) (hW : ∀x y,0≤W x y) (f : X → ℝ) (g : Y → ℝ) : + (𝔼 x, 𝔼 y, W x y*f x*g y)^2≤ + conditionalEnergy W f*(𝔼 y, (𝔼 x, W x y)*g y^2) := by + let A : Y → ℝ := fun y => 𝔼 x, W x y + let B : Y → ℝ := fun y => 𝔼 x, f x*W x y + have hA y : 0≤A y := expect_nonneg (fun x _ => hW x y) + have hB y : A y=0 → B y=0 := by + intro hz + have hh := weighted_expect_cauchy f (fun x => W x y) (fun x => hW x y) + change (B y)^2≤A y*(𝔼 x, f x^2*W x y) at hh + rw [hz,zero_mul] at hh + exact (sq_eq_zero_iff).mp (le_antisymm hh (sq_nonneg _)) + have he y : (B y/Real.sqrt (A y))*(g y*Real.sqrt (A y))=B y*g y := by + by_cases hz : A y=0 + · rw [hB y hz]; ring + · have hs : Real.sqrt (A y)≠0 := (Real.sqrt_pos.mpr (lt_of_le_of_ne (hA y) (Ne.symm hz))).ne' + field_simp + have hsq y : (B y/Real.sqrt (A y))^2=(B y)^2/A y := by + rw [div_pow, Real.sq_sqrt (hA y)] + have hsq' y : (g y*Real.sqrt (A y))^2=A y*g y^2 := by + rw [mul_pow, Real.sq_sqrt (hA y),mul_comm] + have hh := expect_mul_sq_le_sq_mul_sq univ (fun y => B y/Real.sqrt (A y)) + (fun y => g y*Real.sqrt (A y)) + simp only [he,hsq,hsq'] at hh + have hi : (𝔼 x, 𝔼 y, W x y*f x*g y)=𝔼 y, B y*g y := by + rw [expect_comm] + simp only [B,← expect_mul,mul_comm (W _ _) (f _)] + rw [hi] + exact hh + +lemma prod_le_average_powers {V : Type*} [Fintype V] [Nonempty V] + (f : V → ℝ) (hf : ∀v,0≤f v) : + (∏v,f v)≤𝔼 v, (f v)^(Fintype.card V) := by + have hc : (Fintype.card V:ℝ)≠0 := Nat.cast_ne_zero.mpr Fintype.card_ne_zero + have hi v : ((f v)^(Fintype.card V))^((1:ℝ)/(Fintype.card V))=f v := by + rw [← Real.rpow_natCast_mul (hf v),mul_one_div_cancel hc,Real.rpow_one] + have h := Real.geom_mean_le_arith_mean_weighted univ + (fun _ : V => (1:ℝ)/(Fintype.card V)) (fun v => (f v)^(Fintype.card V)) + (by intros; positivity) (by simp [hc]) (fun i _ => pow_nonneg (hf i) _) + simp only [hi] at h + convert h using 1 + rw [expect_eq_sum_div_card,card_univ,div_eq_mul_inv,sum_mul] + apply sum_congr rfl + intros + ring + +lemma positiveLaw_mono {Ω : Type*} (L : (Ω → ℝ) →ₗ[ℝ] ℝ) + (hL : ∀F,(∀z,0≤F z) → 0≤L F) {f g : Ω → ℝ} (hfg : ∀z,f z≤g z) : + L f≤L g := by + have h := hL (g-f) (fun z => sub_nonneg.mpr (hfg z)) + rw [map_sub] at h + exact sub_nonneg.mp h + +lemma positiveLaw_abs {Ω : Type*} (L : (Ω → ℝ) →ₗ[ℝ] ℝ) + (hL : ∀F,(∀z,0≤F z) → 0≤L F) (f : Ω → ℝ) : |L f|≤L (fun z => |f z|) := by + rw [abs_le] + constructor + · have h := positiveLaw_mono L hL (f:=fun z => -|f z|) (g:=f) (fun z => neg_abs_le _) + change L (-(fun z => |f z|))≤L f at h + rwa [map_neg] at h + · exact positiveLaw_mono L hL (fun z => le_abs_self _) + +lemma positiveLaw_product_bound {Ω V : Type*} [Fintype V] [Nonempty V] + (L : (Ω → ℝ) →ₗ[ℝ] ℝ) (hL : ∀F,(∀z,0≤F z) → 0≤L F) + (f : V → Ω → ℝ) (M : ℝ) + (hm : ∀v,L (fun z => |f v z|^(Fintype.card V))≤M) : + |L (fun z => ∏v,f v z)|≤M := by + calc + _ ≤ L (fun z => |∏v,f v z|) := positiveLaw_abs L hL _ + _ ≤ L (fun z => 𝔼 v, |f v z|^(Fintype.card V)) := by + apply positiveLaw_mono L hL + intro z + rw [abs_prod] + exact prod_le_average_powers _ (fun v => abs_nonneg _) + _ = 𝔼 v, L (fun z => |f v z|^(Fintype.card V)) := by + simp only [expect_eq_sum_div_card,card_univ] + have he : (fun z => (∑v, |f v z|^(Fintype.card V))/(Fintype.card V:ℝ))= + (Fintype.card V:ℝ)⁻¹ • ∑v,(fun z => |f v z|^(Fintype.card V)) := by + funext z + simp only [Pi.smul_apply,smul_eq_mul,Finset.sum_apply] + ring + rw [he,map_smul,map_sum] + simp only [smul_eq_mul] + ring + _ ≤ M := expect_le univ_nonempty (fun v _ => hm v) + +end SquareDifference + +namespace SquareDifference + +open Finset + +lemma tensorLaw_density {J V : Type*} [Fintype J] [DecidableEq J] + [Fintype V] [DecidableEq V] {X : J → Type*} [∀j,Fintype (X j)] + [∀j,DecidableEq (X j)] (L : ∀j,((V → X j) → ℝ) →ₗ[ℝ] ℝ) + (z : V → ∀j,X j) : lawDensity (tensorLaw L) z=∏j,lawDensity (L j) (fun v => z v j) := by + unfold lawDensity + have he (w : V → ∀j,X j) : (if w=z then (1:ℝ) else 0)= + ∏j,if (fun v => w v j)=(fun v => z v j) then 1 else 0 := by + rw [prod_indicator_forall] + congr 1 + apply propext + constructor + · intro h; subst w; simp + · intro h; funext v j; exact congrFun (h j) v + rw [show (fun w => if w=z then (1:ℝ) else 0)= + (fun w => ∏j,if (fun v => w v j)=(fun v => z v j) then 1 else 0) from funext he] + exact tensorLaw_fubini L (fun j w => if w=(fun v => z v j) then 1 else 0) + +lemma jointDensity_tensor {J V : Type*} [Fintype J] [DecidableEq J] + [Fintype V] [DecidableEq V] {X : J → Type*} [∀j,Fintype (X j)] + [∀j,DecidableEq (X j)] (L : ∀j,((V → X j) → ℝ) →ₗ[ℝ] ℝ) + (v : V) (x : ∀j,X j) (y : {w : V // w≠v} → ∀j,X j) : + jointDensity (tensorLaw L) (Equiv.funSplitAt v _) x y= + ∏j,jointDensity (L j) (Equiv.funSplitAt v _) (x j) (fun w => y w j) := by + simp only [jointDensity,tensorLaw_density] + have hc : (Fintype.card (V → ∀j,X j):ℝ)=∏j,(Fintype.card (V → X j):ℝ) := by + rw [Fintype.card_congr (Equiv.piComm (fun _ j => X j)), Fintype.card_pi,Nat.cast_prod] + rw [hc,← prod_mul_distrib] + apply prod_congr rfl + intro j _ + congr 2 + funext w + simp only [Equiv.funSplitAt_symm_apply] + split_ifs <;> rfl + +lemma tensorLaw_conditional_decay {J V : Type*} [Fintype J] [DecidableEq J] + [Fintype V] [DecidableEq V] {X : J → Type*} [∀j,Fintype (X j)] + [∀j,Nonempty (X j)] [∀j,DecidableEq (X j)] + (L : ∀j,((V → X j) → ℝ) →ₗ[ℝ] ℝ) + (hL : ∀j F,(∀z,0≤F z) → 0≤L j F) + (hmarg : ∀j v (f : X j → ℝ),L j (fun z => f (z v))=𝔼 x,f x) + (v : V) (d : J → ℝ) + (hmix : ∀j (f : X j → ℝ),(𝔼 x,f x)=0 → + conditionalEnergy (jointDensity (L j) (Equiv.funSplitAt v _)) f≤ + (d j)^2*(𝔼 x,f x^2)) + (s : Finset (Finset J)) (f : Finset J → (∀j,X j) → ℝ) + (hf : ∀U∈s,ExactSupport U (f U)) (a : ℝ) + (ha : ∀U∈s,(∏j∈U,(d j)^2)≤a) : + conditionalEnergy (jointDensity (tensorLaw L) (Equiv.funSplitAt v _)) + (fun x => ∑U∈s,f U x)≤a*(𝔼 x,(∑U∈s,f U x)^2) := by + let W := fun j => jointDensity (L j) (Equiv.funSplitAt v (X j)) + have h := tensor_conditional_decay W (fun j => jointDensity_nonneg (L j) _ (hL j)) + (fun j x => jointDensity_marginal (L j) _ 1 + (fun g => by simpa using hmarg j v g) x) d hmix s f hf a ha + have he := conditionalEnergy_equiv (Equiv.refl (∀j,X j)) + (Equiv.piComm (fun (_ : {w : V // w≠v}) j => X j)) + (fun x y => ∏j,W j (x j) (y j)) (fun x => ∑U∈s,f U x) + simp only [Equiv.refl_apply] at he + rw [← he] at h + convert h using 1 + congr 1 + funext x y + exact jointDensity_tensor L v x y + +end SquareDifference + +namespace SquareDifference + +open Finset + +lemma law_slot_bilinear_sq {Ω X Y : Type*} [Fintype Ω] [Nonempty Ω] + [DecidableEq Ω] [Fintype X] [Fintype Y] + (L : (Ω → ℝ) →ₗ[ℝ] ℝ) (hL : ∀F,(∀z,0≤F z) → 0≤L F) + (e : Ω ≃ X×Y) (f : X → ℝ) (g : Y → ℝ) : + (L (fun z => f (e z).1*g (e z).2))^2≤ + conditionalEnergy (jointDensity L e) f*L (fun z => g (e z).2^2) := by + rw [jointDensity_integral L e (fun x y => f x*g y),jointDensity_integral L e (fun _ y => g y^2)] + have he : (𝔼 x,𝔼 y,jointDensity L e x y*g y^2)= + 𝔼 y,(𝔼 x,jointDensity L e x y)*g y^2 := by + rw [expect_comm] + simp only [expect_mul] + rw [he] + simpa only [mul_assoc] using conditional_bilinear_sq (jointDensity L e) + (jointDensity_nonneg L e hL) f g + +lemma law_slot_product_sq {V X : Type*} [Fintype V] [DecidableEq V] + [Fintype X] [Nonempty X] [DecidableEq X] (v : V) + [Nonempty {w : V // w≠v}] + (L : ((V → X) → ℝ) →ₗ[ℝ] ℝ) + (hL : ∀F,(∀z,0≤F z) → 0≤L F) (f : X → ℝ) (F : V → X → ℝ) (M : ℝ) + (hm : ∀w : {w : V // w≠v},L (fun z => |F w (z w)|^(2*Fintype.card {w : V // w≠v}))≤M) : + (L (fun z => f (z v)*∏w : {w : V // w≠v},F w (z w)))^2≤ + conditionalEnergy (jointDensity L (Equiv.funSplitAt v X)) f*M := by + have hh := law_slot_bilinear_sq L hL (Equiv.funSplitAt v X) f + (fun z => ∏w : {w : V // w≠v},F w (z w)) + change (L (fun z => f (z v)*∏w : {w : V // w≠v},F w (z w)))^2≤ + conditionalEnergy (jointDensity L (Equiv.funSplitAt v X)) f* + L (fun z => (∏w : {w : V // w≠v},F w (z w))^2) at hh + apply hh.trans + apply mul_le_mul_of_nonneg_left _ (conditionalEnergy_nonneg _ f (jointDensity_nonneg L _ hL)) + have hp := positiveLaw_product_bound L hL + (fun (w : {w : V // w≠v}) z => (F w (z w))^2) M + (fun w => by simpa only [abs_pow,← pow_mul] using hm w) + apply le_trans (le_abs_self _) _ + simpa only [prod_pow] using hp + +end SquareDifference + +namespace SquareDifference + +open Finset + +lemma tensorLaw_marginal {J V : Type*} [Fintype J] [DecidableEq J] + [Fintype V] [DecidableEq V] {X : J → Type*} [∀j,Fintype (X j)] + [∀j,DecidableEq (X j)] + (L : ∀j,((V → X j) → ℝ) →ₗ[ℝ] ℝ) (v : V) + (hm : ∀j (g : X j → ℝ),L j (fun z => g (z v))=𝔼 x,g x) + (f : (∀j,X j) → ℝ) : tensorLaw L (fun z => f (z v))=𝔼 x,f x := by + have hd (a : ∀j,X j) : tensorLaw L (fun z => if z v=a then 1 else 0)= + (Fintype.card (∀j,X j) : ℝ)⁻¹ := by + have he (z : V → ∀j,X j) : (if z v=a then (1:ℝ) else 0)= + ∏j,if z v j=a j then 1 else 0 := by + rw [prod_indicator_forall] + congr 1 + exact propext (funext_iff) + simp_rw [he] + rw [tensorLaw_fubini L (fun j z => if z v=a j then 1 else 0)] + have hh (j : J) : L j (fun z => if z v=a j then (1:ℝ) else 0)= + 𝔼 x : X j, if x=a j then (1:ℝ) else 0 := hm j (fun x => if x=a j then 1 else 0) + simp_rw [hh] + simp only [expect_eq_sum_div_card,card_univ,sum_ite_eq',mem_univ,ite_true, + one_div,← prod_inv_distrib,Fintype.card_pi,Nat.cast_prod] + have hf : (fun z : V → ∀j,X j => f (z v))= + ∑a : ∀j,X j, f a • (fun z => if z v=a then (1:ℝ) else 0) := by + funext z + simp only [Finset.sum_apply,Pi.smul_apply,smul_eq_mul,mul_ite,mul_one,mul_zero] + simp + rw [hf,map_sum] + simp only [map_smul,smul_eq_mul,hd,← sum_mul,expect_eq_sum_div_card,card_univ,div_eq_mul_inv] + +lemma tensorLaw_prime_conductor_energy {J V : Type*} [Fintype J] [DecidableEq J] + [Fintype V] [DecidableEq V] (p : J → ℕ) [∀j,Fact (p j).Prime] + (L : ∀j,((V → ZMod (p j)) → ℝ) →ₗ[ℝ] ℝ) + (hL : ∀j F,(∀z,0≤F z) → 0≤L j F) + (hmarg : ∀j v (f : ZMod (p j) → ℝ),L j (fun z => f (z v))=𝔼 x,f x) + (v : V) + (hmix : ∀j (f : ZMod (p j) → ℝ),(𝔼 x,f x)=0 → + conditionalEnergy (jointDensity (L j) (Equiv.funSplitAt v _)) f≤ + (p j : ℝ)^(-(1:ℝ)/32)*(𝔼 x,f x^2)) + (s : Finset (Finset J)) (f : Finset J → (∀j,ZMod (p j)) → ℝ) + (hf : ∀U∈s,ExactSupport U (f U)) (T : ℝ) (hT : 0 ∑U∈s,f U x)≤T^(-(1:ℝ)/32)*(𝔼 x,(∑U∈s,f U x)^2) := by + have hm' (j : J) (g : ZMod (p j) → ℝ) (hg : (𝔼 x,g x)=0) : + conditionalEnergy (jointDensity (L j) (Equiv.funSplitAt v _)) g≤ + (Real.sqrt ((p j : ℝ)^(-(1:ℝ)/32)))^2*(𝔼 x,g x^2) := by + simpa only [Real.sq_sqrt (Real.rpow_nonneg (Nat.cast_nonneg _) _)] using hmix j g hg + apply tensorLaw_conditional_decay L hL hmarg v + (fun j => Real.sqrt ((p j : ℝ)^(-(1:ℝ)/32))) hm' s f hf + intro U hU + simp only [Real.sq_sqrt (Real.rpow_nonneg (Nat.cast_nonneg _) _)] + rw [Real.finsetProd_rpow U (fun j => (p j : ℝ)) (fun _ _ => Nat.cast_nonneg _) _] + exact Real.rpow_le_rpow_of_nonpos hT (hden U hU) (by norm_num) + +lemma tupleGoodTensor_conductor_energy {J : Type*} [Fintype J] [DecidableEq J] + (p : J → ℕ) [∀j,Fact (p j).Prime] + (hp : ∀j, max tupleMassThreshold tupleConditionalThreshold≤(p j : ℝ)) + (v : TupleVertex) (s : Finset (Finset J)) + (f : Finset J → (∀j,ZMod (p j)) → ℝ) (hf : ∀U∈s,ExactSupport U (f U)) + (T : ℝ) (hT : 0 tupleGoodLaw (p:=p j))) + (Equiv.funSplitAt v _)) (fun x => ∑U∈s,f U x)≤ + T^(-(1:ℝ)/32)*(𝔼 x,(∑U∈s,f U x)^2) := by + apply tensorLaw_prime_conductor_energy p (fun j => tupleGoodLaw (p:=p j)) + (fun _ => tupleGoodLaw_nonneg) + (fun j => tupleGoodLaw_marginal ((le_max_left _ _).trans (hp j))) v + (fun j => tupleGoodLaw_conditional ((le_max_right _ _).trans (hp j)) v) s f hf T hT hden + +lemma tupleTensor_conductor_energy {J : Type*} [Fintype J] [DecidableEq J] + (p : J → ℕ) [∀j,Fact (p j).Prime] + (hp : ∀j, max tupleMassThreshold tupleConditionalThreshold≤(p j : ℝ)) + (v : TupleVertex) (s : Finset (Finset J)) + (f : Finset J → (∀j,ZMod (p j)) → ℝ) (hf : ∀U∈s,ExactSupport U (f U)) + (T : ℝ) (hT : 0 ∑U∈s,f U x)≤T^(-(1:ℝ)/32)*(𝔼 x,(∑U∈s,f U x)^2) := by + apply tensorLaw_prime_conductor_energy p (fun j => tupleLaw (p:=p j)) + (fun _ => tupleLaw_nonneg) + (fun j => tupleLaw_marginal ((le_max_left _ _).trans (hp j))) v + (fun j => tupleLaw_conditional ((le_max_right _ _).trans (hp j)) v) s f hf T hT hden + +end SquareDifference + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SquareDifference/RationalApproximation.lean b/lean/OAI/Combinatorics/SquareDifference/RationalApproximation.lean new file mode 100644 index 0000000000000000000000000000000000000000..2ca8c117e459f1d8c2537a3f37e341a31f5b0aa5 --- /dev/null +++ b/lean/OAI/Combinatorics/SquareDifference/RationalApproximation.lean @@ -0,0 +1,529 @@ +import OAI.Combinatorics.SquareDifference.PhaseBounds + +namespace OAI + +section +open Finset +open scoped ComplexConjugate BigOperators +namespace SquareDifference + +lemma sum_square_cells {E : Type*} [AddCommGroup E] (f : ℕ → E) (M : ℕ) : + ∑ m ∈ range M, ∑ n ∈ Ico (m^2) ((m+1)^2), f n = ∑ n ∈ range (M^2), f n := by + have hstep (m : ℕ) : ∑ n ∈ Ico (m^2) ((m+1)^2), f n = + (∑ n ∈ range ((m+1)^2), f n)-(∑ n ∈ range (m^2), f n) := + sum_Ico_eq_sub f (by gcongr; omega) + simp_rw [hstep] + rw [sum_range_sub (fun m => ∑ n ∈ range (m^2), f n)] + simp + +lemma square_cell_card (m : ℕ) : (Ico (m^2) ((m+1)^2)).card = 2*m+1 := by + have he : (m+1)^2=m^2+(2*m+1) := by ring + simp [he] + +lemma square_phase_cell (y : ℝ) (m M : ℕ) (hm : m < M) : + ‖(2*((m : ℝ)+1)) • expPhase (y*(m+1)^2)- + ∑ n ∈ Ico (m^2) ((m+1)^2), expPhase (y*(n+1))‖ ≤ + 1+8*Real.pi*|y| *(M : ℝ)^2 := by + have he : (2*((m : ℝ)+1)) • expPhase (y*(m+1)^2)- + ∑ n ∈ Ico (m^2) ((m+1)^2), expPhase (y*(n+1)) = + expPhase (y*(m+1)^2)+∑ n ∈ Ico (m^2) ((m+1)^2), + (expPhase (y*(m+1)^2)-expPhase (y*(n+1))) := by + simp only [sum_sub_distrib, sum_const, square_cell_card, nsmul_eq_mul, Complex.real_smul] + push_cast + ring + rw [he] + have hmR : (m : ℝ)+1 ≤ M := by exact_mod_cast (Nat.succ_le_of_lt hm) + have hb (n : ℕ) (hn : n ∈ Ico (m^2) ((m+1)^2)) : + ‖expPhase (y*(m+1)^2)-expPhase (y*(n+1))‖ ≤ 4*Real.pi*|y| *(M : ℝ) := by + have hn0 : (m : ℝ)^2 ≤ n := by exact_mod_cast (mem_Ico.mp hn).1 + have hn1 : (n : ℝ)+1 ≤ ((m : ℝ)+1)^2 := by + exact_mod_cast Nat.succ_le_of_lt (mem_Ico.mp hn).2 + apply (expPhase_lipschitz _ _).trans + rw [← mul_sub, abs_mul, abs_of_nonneg (by linarith : 0 ≤ ((m : ℝ)+1)^2-((n : ℝ)+1))] + have ht : ((m : ℝ)+1)^2-((n : ℝ)+1) ≤ 2*M := by nlinarith + calc + _ ≤ 2*Real.pi*(|y| *(2*M)) := by gcongr + _ = _ := by ring + calc + _ ≤ 1+∑ _n ∈ Ico (m^2) ((m+1)^2), 4*Real.pi*|y| *(M : ℝ) := by + apply (norm_add_le _ _).trans + rw [norm_expPhase] + exact add_le_add le_rfl ((norm_sum_le _ _).trans (sum_le_sum hb)) + _ ≤ _ := by + simp only [sum_const, square_cell_card, nsmul_eq_mul, Nat.cast_add, Nat.cast_mul, Nat.cast_ofNat, Nat.cast_one] + have hh : 2*(m : ℝ)+1 ≤ 2*M := by linarith + calc + _ ≤ 1+(2*(M : ℝ))*(4*Real.pi*|y| *M) := by gcongr + _ = _ := by ring + +lemma square_phase_riemann (y : ℝ) (M : ℕ) : + ‖(∑ m ∈ range M, (2*((m : ℝ)+1)) • expPhase (y*(m+1)^2))- + ∑ n ∈ range (M^2), expPhase (y*(n+1))‖ ≤ + (M : ℝ)*(1+8*Real.pi*|y| *(M : ℝ)^2) := by + rw [← sum_square_cells (fun n => expPhase (y*(n+1))) M, ← sum_sub_distrib] + calc + _ ≤ ∑ _m ∈ range M, (1+8*Real.pi*|y| *(M : ℝ)^2) := by + exact (norm_sum_le _ _).trans (sum_le_sum (fun m hm => square_phase_cell y m M (mem_range.mp hm))) + _ = _ := by simp; ring + +noncomputable def normalizedLinearSum (N : ℕ) (y : ℝ) : ℂ := + (N : ℝ)⁻¹ • ∑ n ∈ range N, expPhase (y*(n+1)) + +lemma squareWeight_riemann (N M : ℕ) (hlo : M^2 ≤ N) (hhi : N < (M+1)^2) (y : ℝ) : + ‖(∑ m ∈ range M, squareWeight N y m)-normalizedLinearSum N y‖ ≤ + (3+8*Real.pi*|y| *(M : ℝ)^2)*M/N := by + have hn : N-M^2 ≤ 2*M := by nlinarith [Nat.sub_add_cancel hlo] + have hs : ‖(∑ n ∈ range N, expPhase (y*(n+1)))- + ∑ n ∈ range (M^2), expPhase (y*(n+1))‖ ≤ 2*(M : ℝ) := by + rw [← sum_Ico_eq_sub _ hlo] + calc + _ ≤ ∑ _n ∈ Ico (M^2) N, (1 : ℝ) := by + simpa only [norm_expPhase] using + (norm_sum_le (Ico (M^2) N) (fun n => expPhase (y*(n+1)))) + _ ≤ _ := by simpa using (show ((N-M^2 : ℕ) : ℝ) ≤ 2*(M : ℝ) by exact_mod_cast hn) + have ht : ‖(∑ m ∈ range M, (2*((m : ℝ)+1)) • expPhase (y*(m+1)^2))- + ∑ n ∈ range N, expPhase (y*(n+1))‖ ≤ + (3+8*Real.pi*|y| *(M : ℝ)^2)*M := by + have := norm_sub_le_norm_sub_add_norm_sub + (∑ m ∈ range M, (2*((m : ℝ)+1)) • expPhase (y*(m+1)^2)) + (∑ n ∈ range (M^2), expPhase (y*(n+1))) + (∑ n ∈ range N, expPhase (y*(n+1))) + rw [norm_sub_rev (∑ n ∈ range (M^2), _) (∑ n ∈ range N, _)] at this + nlinarith [square_phase_riemann y M] + have he : (∑ m ∈ range M, squareWeight N y m)-normalizedLinearSum N y = + (N : ℝ)⁻¹ • ((∑ m ∈ range M, (2*((m : ℝ)+1)) • expPhase (y*(m+1)^2))- + ∑ n ∈ range N, expPhase (y*(n+1))) := by + simp only [squareWeight, normalizedLinearSum, smul_sub, smul_sum, smul_smul] + congr 1 + apply sum_congr rfl + intro m _ + congr 1 + ring + rw [he, norm_smul, Real.norm_of_nonneg (by positivity : 0 ≤ (N : ℝ)⁻¹)] + calc + _ ≤ (N : ℝ)⁻¹*((3+8*Real.pi*|y| *(M : ℝ)^2)*M) := + mul_le_mul_of_nonneg_left ht (by positivity) + _ = _ := by ring + +lemma rational_quadratic_sum (α θ : ℝ) (a : ℤ) (q : ℕ) (hq : 8 ≤ q) + (hc : IsCoprime a (q : ℤ)) (ha : |α-(a : ℝ)/q| ≤ 1/(q : ℝ)^2) + (L M : ℕ) (hLM : L ≤ M) : + ‖∑ m ∈ range L, expPhase (α*m^2+θ*m)‖ ≤ + Real.sqrt (M+2*(8*(M : ℝ)/q+1)*(2*M+4*q*(1+Real.log q))) := by + apply Real.le_sqrt_of_sq_le + apply (quadratic_sum_differencing α θ L M hLM).trans + have hs : ∑ j ∈ Ico 1 M, phaseBound M (2*α*j) ≤ + (8*(M : ℝ)/q+1)*(2*M+4*q*(1+Real.log q)) := by + apply le_trans _ (rational_spacing_sum α a q hq hc ha M) + apply sum_le_sum_of_subset_of_nonneg + · intro j hj; exact mem_range.mpr (mem_Ico.mp hj).2 + · intro j _ _; exact phaseBound_nonneg (Nat.cast_nonneg _) _ + nlinarith + +lemma quadratic_sum_shift (α θ : ℝ) (L : ℕ) : + ‖∑ m ∈ range L, expPhase (α*(m+1)^2+θ*(m+1))‖ = + ‖∑ m ∈ range L, expPhase (α*m^2+(θ+2*α)*m)‖ := by + have he (m : ℕ) : α*((m : ℝ)+1)^2+θ*((m : ℝ)+1) = + (α+θ)+(α*m^2+(θ+2*α)*m) := by ring + simp_rw [he, expPhase_add, ← mul_sum, norm_mul, norm_expPhase, one_mul] + +lemma norm_linear_weighted_sum (z : ℕ → ℂ) (M : ℕ) (B : ℝ) (hB : 0 ≤ B) + (hb : ∀ L ≤ M, ‖∑ m ∈ range L, z m‖ ≤ B) : + ‖∑ m ∈ range M, ((m : ℝ)+1) • z m‖ ≤ 2*M*B := by + rw [sum_range_by_parts] + calc + _ ≤ ‖((M-1 : ℕ) : ℝ)+1‖ * ‖∑ m ∈ range M, z m‖ + + ∑ m ∈ range (M-1), ‖(((m+1 : ℕ) : ℝ)+1) - ((m : ℝ)+1)‖ * + ‖∑ j ∈ range (m+1), z j‖ := by + apply (norm_sub_le _ _).trans + rw [norm_smul] + exact add_le_add le_rfl ((norm_sum_le _ _).trans (le_of_eq (by simp))) + _ ≤ (M : ℝ)*B+(M : ℝ)*B := by + by_cases hM : M=0 + · simp [hM] + have hlast : ((M-1 : ℕ) : ℝ)+1 = M := by + exact_mod_cast (Nat.sub_add_cancel (show 1 ≤ M by omega)) + rw [hlast, Real.norm_of_nonneg (Nat.cast_nonneg _)] + apply add_le_add (mul_le_mul_of_nonneg_left (hb M le_rfl) (Nat.cast_nonneg _)) + calc + _ ≤ ∑ _m ∈ range (M-1), B := by + apply sum_le_sum + intro m hm + simp only [Nat.cast_add, Nat.cast_one] + rw [show (m : ℝ)+1+1-((m : ℝ)+1)=1 by ring, norm_one, one_mul] + exact hb (m+1) (by have := mem_range.mp hm; omega) + _ ≤ (M : ℝ)*B := by + simp only [sum_const, card_range, nsmul_eq_mul] + exact mul_le_mul_of_nonneg_right (Nat.cast_le.mpr (Nat.sub_le M 1)) hB + _ = _ := by ring + +lemma rational_weighted_quadratic_sum (α θ : ℝ) (a : ℤ) (q : ℕ) (hq : 8 ≤ q) + (hc : IsCoprime a (q : ℤ)) (ha : |α-(a : ℝ)/q| ≤ 1/(q : ℝ)^2) + (M N : ℕ) : + ‖∑ m ∈ range M, (2*((m : ℝ)+1)/(N : ℝ)) • + expPhase (α*(m+1)^2+θ*(m+1))‖ ≤ + (4*(M : ℝ)/N)*Real.sqrt + (M+2*(8*(M : ℝ)/q+1)*(2*M+4*q*(1+Real.log q))) := by + let B := Real.sqrt (M+2*(8*(M : ℝ)/q+1)*(2*M+4*q*(1+Real.log q))) + have hb : ∀ L ≤ M, ‖∑ m ∈ range L, + expPhase (α*(m+1)^2+θ*(m+1))‖ ≤ B := by + intro L hLM + rw [quadratic_sum_shift] + exact rational_quadratic_sum α (θ+2*α) a q hq hc ha L M hLM + have hm := norm_linear_weighted_sum + (fun m => expPhase (α*(m+1)^2+θ*(m+1))) M B (Real.sqrt_nonneg _) hb + simp_rw [show ∀ m : ℕ, 2*((m : ℝ)+1)/(N : ℝ) = (2/(N : ℝ))*((m : ℝ)+1) by + intro m; ring, mul_smul, ← smul_sum] + rw [norm_smul, Real.norm_of_nonneg (by positivity : 0 ≤ 2/(N : ℝ))] + calc + _ ≤ (2/(N : ℝ))*(2*M*B) := + mul_le_mul_of_nonneg_left hm (by positivity) + _ = _ := by dsimp only [B]; ring + +lemma periodic_square_main (a : ℕ → ℂ) (T : ℕ) (hT : 0 < T) + (hp : Function.Periodic a T) (B : ℝ) (hB : 0 ≤ B) + (ha : ∀ m, ‖a m‖ ≤ B) (M N : ℕ) (hM : 1 ≤ M) + (hlo : M^2 ≤ N) (hhi : N < (M+1)^2) (y : ℝ) : + ‖(∑ m ∈ range M, squareWeight N y m*a m)- + periodicMean a T*normalizedLinearSum N y‖ ≤ + (2*T+1)*B*((4+8*Real.pi*|y| *(M : ℝ)^2)*M/N) := by + have h1 := periodic_squareWeight_error a T hT hp B hB ha M N hM y + have h2 := squareWeight_riemann N M hlo hhi y + have h3 := norm_periodicMean a T hT B ha + calc + _ ≤ ‖(∑ m ∈ range M, squareWeight N y m*a m)- + periodicMean a T*(∑ m ∈ range M, squareWeight N y m)‖ + + ‖periodicMean a T*((∑ m ∈ range M, squareWeight N y m)-normalizedLinearSum N y)‖ := by + convert norm_sub_le_norm_sub_add_norm_sub + (∑ m ∈ range M, squareWeight N y m*a m) + (periodicMean a T*(∑ m ∈ range M, squareWeight N y m)) + (periodicMean a T*normalizedLinearSum N y) using 1; rw [mul_sub] + _ ≤ (2*T*B)*((4+8*Real.pi*|y| *(M : ℝ)^2)*M/N) + + B*((3+8*Real.pi*|y| *(M : ℝ)^2)*M/N) := by + rw [norm_mul] + exact add_le_add h1 (mul_le_mul h3 h2 (norm_nonneg _) hB) + _ ≤ _ := by + calc + _ ≤ (2*T*B)*((4+8*Real.pi*|y| *(M : ℝ)^2)*M/N) + + B*((4+8*Real.pi*|y| *(M : ℝ)^2)*M/N) := by gcongr; norm_num + _ = _ := by ring + +lemma quadratic_fourier_weight (ι : Type*) [Fintype ι] (w : ι → ℂ) (θ : ι → ℝ) + (α : ℝ) (a : ℤ) (q : ℕ) (hq : 8 ≤ q) + (hc : IsCoprime a (q : ℤ)) (ha : |α-(a : ℝ)/q| ≤ 1/(q : ℝ)^2) + (M N : ℕ) : + ‖∑ m ∈ range M, squareWeight N α m * + ∑ i, w i*expPhase (θ i*(m+1))‖ ≤ + (∑ i, ‖w i‖)*(4*(M : ℝ)/N)*Real.sqrt + (M+2*(8*(M : ℝ)/q+1)*(2*M+4*q*(1+Real.log q))) := by + let B := (4*(M : ℝ)/N)*Real.sqrt + (M+2*(8*(M : ℝ)/q+1)*(2*M+4*q*(1+Real.log q))) + have he : (∑ m ∈ range M, squareWeight N α m * ∑ i, w i*expPhase (θ i*(m+1))) = + ∑ i, w i * ∑ m ∈ range M, (2*((m : ℝ)+1)/(N : ℝ)) • + expPhase (α*(m+1)^2+θ i*(m+1)) := by + simp_rw [mul_sum, squareWeight, expPhase_add, smul_mul_assoc, mul_smul_comm] + rw [sum_comm] + apply sum_congr rfl + intro i _ + apply sum_congr rfl + intro m _ + congr 1 + ring + rw [he] + calc + _ ≤ ∑ i, ‖w i‖*B := (norm_sum_le _ _).trans (sum_le_sum (fun i _ => by + rw [norm_mul] + exact mul_le_mul_of_nonneg_left (rational_weighted_quadratic_sum α (θ i) a q hq hc ha M N) + (norm_nonneg _))) + _ = _ := by dsimp only [B]; rw [← sum_mul]; ring + +lemma dirichlet_fraction (α : ℝ) (T : ℕ) (hT : 0 expPhase ((b : ℝ)*(m+1)^2)) t := by + obtain ⟨k,rfl⟩ := ht + intro m + dsimp only + rw [show (b : ℝ)*((m+(b.den*k) : ℕ)+1)^2 = + (b : ℝ)*((m : ℝ)+1)^2 + + ((b.num*(2*((m : ℤ)+1)*k+(b.den : ℤ)*k^2) : ℤ) : ℝ) by + rw [Rat.cast_def] + push_cast + field_simp + ring] + rw [expPhase_add,expPhase_int,mul_one] + +lemma periodic_rational_quadratic (v : ℕ → ℂ) (t : ℕ) + (hv : Function.Periodic v t) (b : ℚ) : + Function.Periodic (fun m : ℕ => v (m+1)*expPhase ((b : ℝ)*(m+1)^2)) (b.den*t) := by + apply Function.Periodic.mul + · have h := hv.nsmul b.den + intro m + simpa only [nsmul_eq_mul,Nat.cast_id,Nat.add_assoc,Nat.add_comm,Nat.add_left_comm] using h (m+1) + · exact expPhase_rat_square_periodic b (b.den*t) (dvd_mul_right _ _) + +lemma rational_kernel_major (v : ℕ → ℂ) (t : ℕ) (ht : 0 v (m+1)*expPhase ((b : ℝ)*(m+1)^2)) (b.den*t)* + normalizedLinearSum N (α-b)‖≤ + (2*((b.den*t : ℕ) : ℝ)+1)*B* + ((4+8*Real.pi*|α-(b : ℝ)| *(M : ℝ)^2)*M/N) := by + have he (m : ℕ) : squareWeight N α m*v (m+1)= + squareWeight N (α-b) m*(v (m+1)*expPhase ((b : ℝ)*(m+1)^2)) := by + unfold squareWeight + have hx : expPhase (α*((m : ℝ)+1)^2)= + expPhase ((α-b)*((m : ℝ)+1)^2)*expPhase ((b : ℝ)*(m+1)^2) := by + rw [← expPhase_add] + congr 1 + ring + simp only [smul_mul_assoc] + congr 1 + rw [hx] + ring + simp_rw [he] + apply periodic_square_main _ (b.den*t) (Nat.mul_pos b.pos ht) + (periodic_rational_quadratic v t hv b) B hB _ M N hM hlo hhi (α-b) + intro m + simpa only [norm_mul,norm_expPhase,mul_one] using hb (m+1) + +lemma rational_kernel_major_uniform (v : ℕ → ℂ) (t : ℕ) (ht : 0 v (m+1)*expPhase ((b : ℝ)*(m+1)^2)) (b.den*t)* + normalizedLinearSum N (α-b)‖≤ + (2*(t : ℝ)+1)*B*(4*R+8*Real.pi*N/((T : ℝ)+1))*M/N := by + apply (rational_kernel_major v t ht hv B hB hb b α M N hM hlo hhi).trans + have hq0 : (0 : ℝ) copyDifference U (f U) x y + let S := fun x => ∑U∈F, f U x^2 + let C : ℝ := (2:ℝ)^(2*r) + let B : ℝ := (4*C)^k + have hC : 1 ≤ C := one_le_pow₀ (by norm_num) + have hB : 0 ≤ B := by positivity + have hS : ∀x, 0 ≤ S x := fun x => sum_nonneg fun U _ => sq_nonneg (f U x) + have hmean (x : ∀j, X j) : (𝔼 y, ∑U∈F, D U x y)=∑U∈F, f U x := by + rw [expect_sum_comm] + apply sum_congr rfl + intro U hU + exact copyDifference_mean U (f U) (hf U hU) x + have hsign : + (𝔼 x, 𝔼 y, (∑U∈F, D U x y)^(2*r))= + 𝔼 x, 𝔼 y, 𝔼 e : J → Bool, + (walsh univ (fun U => if U∈F then D U x y else 0) e)^(2*r) := by + have he (e : J → Bool) : + (𝔼 x, 𝔼 y, (walsh univ (fun U => if U∈F then D U x y else 0) e)^(2*r))= + 𝔼 x, 𝔼 y, (∑U∈F, D U x y)^(2*r) := by + simp only [walsh_family] + have hp x y U : D U x y*boolChar U e=D U (hybrid e x y) (hybrid e y x) := by + dsimp only [D] + rw [copyDifference_swap, mul_comm] + simp only [hp] + exact expect_copySwap e (fun x y => (∑U∈F, D U x y)^(2*r)) + conv_rhs => arg 2; ext x; rw [expect_comm] + conv_rhs => rw [expect_comm] + simp only [he, Fintype.expect_const] + have hpoint (x y : ∀j, X j) : + (𝔼 e : J → Bool, (walsh univ (fun U => if U∈F then D U x y else 0) e)^(2*r)) ≤ + B^r*(𝔼 e : J → Bool, (S (hybrid e x y))^r) := by + apply (walsh_hypercontractivity univ _ r hr).trans + have he := difference_energy_bound F f k hk C hC x y + calc + _ ≤ (B*(𝔼 e : J → Bool, S (hybrid e x y)))^r := + pow_le_pow_left₀ (walshEnergy_nonneg _ _ (by positivity) _) he r + _ = B^r*(𝔼 e : J → Bool, S (hybrid e x y))^r := mul_pow _ _ _ + _ ≤ _ := mul_le_mul_of_nonneg_left + (expect_pow_le (fun e => S (hybrid e x y)) (fun e => hS _) r) (pow_nonneg hB _) + change _ ≤ B^r*(𝔼 x, S x^r) + calc + _ ≤ (𝔼 x, 𝔼 y, (∑U∈F, D U x y)^(2*r)) := by + apply expect_le_expect + intro x _ + rw [← hmean x] + exact expect_even_pow_le (fun y => ∑U∈F, D U x y) r + _ = _ := hsign + _ ≤ (𝔼 x, 𝔼 y, B^r*(𝔼 e : J → Bool, (S (hybrid e x y))^r)) := by + apply expect_le_expect + intro x _ + exact expect_le_expect fun y _ => hpoint x y + _ = B^r*(𝔼 x, S x^r) := by + simp only [← mul_expect] + congr 1 + conv_lhs => arg 2; ext x; rw [expect_comm] + rw [expect_comm] + have he (e : J → Bool) : (𝔼 x, 𝔼 y, S (hybrid e x y)^r)=𝔼 x, S x^r := + expect_hybrid e (fun x => S x^r) + simp only [he, Fintype.expect_const] + +lemma sum_pow_tuples {I : Type*} [Fintype I] (a : I → ℝ) (r : ℕ) : + (∑i, a i)^r=∑t : Fin r → I, ∏j, a (t j) := by + have hh := Fintype.prod_sum (fun (_ : Fin r) (i : I) => a i) + simpa only [prod_const, card_univ, Fintype.card_fin] using hh + +lemma expect_condition {J : Type*} [Fintype J] [DecidableEq J] + {X : J → Type*} [∀j, Fintype (X j)] [∀j, Nonempty (X j)] + (W : Finset J) (h g : (∀j, X j) → ℝ) + (hh : ∀x y, (∀j∈W, x j=y j) → h x=h y) : + (𝔼 x, h x*g x) = 𝔼 x, h x*(𝔼 y, g (hybrid (fun j => decide (j∈W)) x y)) := by + have he x y : h (hybrid (fun j => decide (j∈W)) x y)=h x := by + apply hh + intro j hj + simp [hybrid, hj] + have hp := expect_hybrid (fun j => decide (j∈W)) (fun x => h x*g x) + simp only [he, ← mul_expect] at hp + exact hp.symm + +lemma square_moment_step {J I : Type*} [Fintype J] [DecidableEq J] [Fintype I] + {X : J → Type*} [∀j, Fintype (X j)] [∀j, Nonempty (X j)] + (U : I → Finset J) (f : I → (∀j, X j) → ℝ) + (hf : ∀i, ∀x y, (∀j∈U i, x j=y j) → f i x=f i y) + (k : ℕ) (hk : ∀i, (U i).card ≤ k) + (A D : ℝ) (hA : 0 ≤ A) (hD : 1 ≤ D) + (hcond : ∀ (W : Finset J) x, + (𝔼 y, ∑i, f i (hybrid (fun j => decide (j∈W)) x y)^2) ≤ A*D^W.card) + (r : ℕ) : + (𝔼 x, (∑i, f i x^2)^(r+1)) ≤ (A*D^(r*k))*(𝔼 x, (∑i, f i x^2)^r) := by + classical + let S := fun x => ∑i, f i x^2 + let h := fun (t : Fin r → I) x => ∏j, f (t j) x^2 + have hh t x : 0 ≤ h t x := prod_nonneg fun j _ => sq_nonneg _ + have hpow x : S x^r=∑t : Fin r → I, h t x := sum_pow_tuples _ r + have hbound (t : Fin r → I) : + (𝔼 x, h t x*S x) ≤ (A*D^(r*k))*(𝔼 x, h t x) := by + let W : Finset J := univ.biUnion (fun j => U (t j)) + have hw : W.card ≤ r*k := by + calc + _ ≤ ∑j : Fin r, (U (t j)).card := card_biUnion_le + _ ≤ ∑_j : Fin r, k := sum_le_sum fun j _ => hk (t j) + _ = _ := by simp + have hdep x y (hxy : ∀j∈W, x j=y j) : h t x=h t y := by + apply prod_congr rfl + intro j _ + rw [hf (t j) x y (fun a ha => hxy a (mem_biUnion.mpr ⟨j,mem_univ j,ha⟩))] + calc + _ = (𝔼 x, h t x*(𝔼 y, S (hybrid (fun j => decide (j∈W)) x y))) := + expect_condition W (h t) S hdep + _ ≤ (𝔼 x, h t x*(A*D^(r*k))) := by + apply expect_le_expect + intro x _ + apply mul_le_mul_of_nonneg_left _ (hh t x) + exact (hcond W x).trans (mul_le_mul_of_nonneg_left (pow_le_pow_right₀ hD hw) hA) + _ = _ := by rw [← expect_mul]; ring + change (𝔼 x, S x^(r+1)) ≤ _*(𝔼 x, S x^r) + calc + _ = ∑t : Fin r → I, (𝔼 x, h t x*S x) := by + simp only [pow_succ, hpow, sum_mul, expect_sum_comm] + _ ≤ ∑t : Fin r → I, (A*D^(r*k))*(𝔼 x, h t x) := + sum_le_sum fun t _ => hbound t + _ = (A*D^(r*k))*(𝔼 x, S x^r) := by + rw [← mul_sum, ← expect_sum_comm] + simp only [← hpow] + +lemma square_moment_bound {J I : Type*} [Fintype J] [DecidableEq J] [Fintype I] + {X : J → Type*} [∀j, Fintype (X j)] [∀j, Nonempty (X j)] + (U : I → Finset J) (f : I → (∀j, X j) → ℝ) + (hf : ∀i, ∀x y, (∀j∈U i, x j=y j) → f i x=f i y) + (k : ℕ) (hk : ∀i, (U i).card ≤ k) + (A D : ℝ) (hA : 0 ≤ A) (hD : 1 ≤ D) + (hcond : ∀ (W : Finset J) x, + (𝔼 y, ∑i, f i (hybrid (fun j => decide (j∈W)) x y)^2) ≤ A*D^W.card) + (r : ℕ) : + (𝔼 x, (∑i, f i x^2)^r) ≤ (A*D^(r*k))^r := by + have hD0 : 0 ≤ D := by linarith + have hbase : 0 ≤ A*D^(r*k) := mul_nonneg hA (pow_nonneg hD0 _) + have hind (t : ℕ) (ht : t ≤ r) : + (𝔼 x, (∑i, f i x^2)^t) ≤ (A*D^(r*k))^t := by + induction t with + | zero => simp only [pow_zero, Fintype.expect_const, le_refl] + | succ t ih => + have ht' : t ≤ r := by omega + have hi := ih ht' + have he := square_moment_step U f hf k hk A D hA hD hcond t + apply he.trans + calc + _ ≤ (A*D^(r*k))*(A*D^(r*k))^t := by + apply mul_le_mul _ hi + (expect_nonneg fun x _ => pow_nonneg (sum_nonneg fun i _ => sq_nonneg _) _) hbase + exact mul_le_mul_of_nonneg_left (pow_le_pow_right₀ hD (Nat.mul_le_mul_right k ht')) hA + _ = _ := by rw [pow_succ]; ring + exact hind r le_rfl + +lemma synthesis_norm_sq_bound {I E : Type*} [Fintype I] [DecidableEq I] + [NormedAddCommGroup E] [InnerProductSpace ℂ E] + (v : I → E) (D δ : ℝ) (hδ : 0 ≤ δ) + (hgram : ∀ i j, ‖inner ℂ (v i) (v j)‖ ≤ (if i = j then D else 0) + δ) + (a : I → ℂ) : + ‖∑ i, a i • v i‖ ^ 2 ≤ (D + Fintype.card I * δ) * ∑ i, ‖a i‖ ^ 2 := by + classical + have hcs : (∑ i, ‖a i‖) ^ 2 ≤ (Fintype.card I : ℝ) * ∑ i, ‖a i‖ ^ 2 := by + simpa using Finset.sum_mul_sq_le_sq_mul_sq (univ : Finset I) + (fun _ => (1 : ℝ)) (fun i => ‖a i‖) + calc + ‖∑ i, a i • v i‖ ^ 2 = + (∑ i, ∑ j, (starRingEnd ℂ) (a i) * a j * inner ℂ (v i) (v j)).re := by + rw [norm_sq_eq_re_inner (𝕜 := ℂ)] + change (inner ℂ _ _).re = _ + simp only [sum_inner, inner_sum, inner_smul_left, inner_smul_right, mul_sum] + rw [sum_comm] + congr 1 + apply sum_congr rfl; intro i _ + apply sum_congr rfl; intro j _ + ring + _ ≤ ∑ i, ∑ j, ‖a i‖ * ‖a j‖ * ‖inner ℂ (v i) (v j)‖ := by + simp only [Complex.re_sum] + apply sum_le_sum; intro i _ + apply sum_le_sum; intro j _ + simpa only [norm_mul, Complex.norm_conj] using + Complex.re_le_norm ((starRingEnd ℂ) (a i) * a j * inner ℂ (v i) (v j)) + _ ≤ ∑ i, ∑ j, ‖a i‖ * ‖a j‖ * ((if i = j then D else 0) + δ) := by + apply sum_le_sum; intro i _ + apply sum_le_sum; intro j _ + exact mul_le_mul_of_nonneg_left (hgram i j) (mul_nonneg (norm_nonneg _) (norm_nonneg _)) + _ = D * (∑ i, ‖a i‖ ^ 2) + δ * (∑ i, ‖a i‖) ^ 2 := by + simp_rw [mul_add, sum_add_distrib] + simp only [mul_ite, mul_zero, sum_ite_eq, mem_univ, ite_true] + simp only [← sum_mul, ← mul_sum] + simp only [← sq] + ring + _ ≤ (D + Fintype.card I * δ) * ∑ i, ‖a i‖ ^ 2 := by + nlinarith [mul_le_mul_of_nonneg_left hcs hδ] + +lemma analysis_of_synthesis {I E : Type*} [Fintype I] [DecidableEq I] + [NormedAddCommGroup E] [InnerProductSpace ℂ E] + (v : I → E) (C : ℝ) (hC : 0 ≤ C) + (h : ∀ a : I → ℂ, ‖∑ i, a i • v i‖ ^ 2 ≤ C * ∑ i, ‖a i‖ ^ 2) + (f : E) : ∑ i, ‖inner ℂ (v i) f‖ ^ 2 ≤ C * ‖f‖ ^ 2 := by + classical + let a : I → ℂ := fun i => inner ℂ (v i) f + let S : E := ∑ i, a i • v i + let t : ℝ := ∑ i, ‖a i‖ ^ 2 + have ht : 0 ≤ t := sum_nonneg fun _ _ => sq_nonneg _ + have heq : (inner ℂ S f).re = t := by + simp only [S, sum_inner, inner_smul_left, Complex.re_sum, t] + change (∑ i, ((starRingEnd ℂ) (a i) * a i).re) = _ + apply sum_congr rfl; intro i _ + rw [Complex.conj_mul', ← Complex.ofReal_pow, Complex.ofReal_re] + have htf : t ≤ ‖S‖ * ‖f‖ := by + rw [← heq] + exact (Complex.re_le_norm _).trans (norm_inner_le_norm _ _) + have hs : ‖S‖ ^ 2 ≤ C * t := h a + have hc : t ^ 2 ≤ C * t * ‖f‖ ^ 2 := by + calc + t ^ 2 ≤ (‖S‖ * ‖f‖) ^ 2 := pow_le_pow_left₀ ht htf 2 + _ = ‖S‖ ^ 2 * ‖f‖ ^ 2 := mul_pow _ _ _ + _ ≤ C * t * ‖f‖ ^ 2 := mul_le_mul_of_nonneg_right hs (sq_nonneg _) + change t ≤ C * ‖f‖ ^ 2 + by_cases ht0 : t = 0 + · rw [ht0] + exact mul_nonneg hC (sq_nonneg _) + · exact le_of_mul_le_mul_left (by nlinarith [hc]) (lt_of_le_of_ne ht (Ne.symm ht0)) + +noncomputable def expPhase (t : ℝ) : ℂ := Real.fourierChar t + +noncomputable def circleDistance (t : ℝ) : ℝ := |t - round t| + +@[simp] lemma expPhase_zero : expPhase 0 = 1 := by simp [expPhase] +@[simp] lemma norm_expPhase (t : ℝ) : ‖expPhase t‖ = 1 := Circle.norm_coe _ + +lemma expPhase_add (s t : ℝ) : expPhase (s+t) = expPhase s * expPhase t := by + simp [expPhase, AddChar.map_add_eq_mul] + +lemma expPhase_neg (t : ℝ) : expPhase (-t) = conj (expPhase t) := by + simp only [expPhase, AddChar.map_neg_eq_inv, Circle.coe_inv_eq_conj] + +lemma expPhase_sub (s t : ℝ) : expPhase (s-t) = expPhase s * conj (expPhase t) := by + rw [sub_eq_add_neg, expPhase_add, expPhase_neg] + +lemma expPhase_nat_mul (t : ℝ) (n : ℕ) : expPhase (n*t) = expPhase t^n := by + simpa only [expPhase, nsmul_eq_mul, Circle.coe_pow] using congrArg (fun z : Circle => (z : ℂ)) + (AddChar.map_nsmul_eq_pow Real.fourierChar n t) + +lemma expPhase_int (n : ℤ) : expPhase n = 1 := by + change Complex.exp (↑(2 * Real.pi * (n : ℝ)) * Complex.I) = 1 + rw [show (↑(2 * Real.pi * (n : ℝ)) : ℂ) * Complex.I = + (n : ℂ) * (2 * Real.pi * Complex.I) by push_cast; ring] + exact Complex.exp_int_mul_two_pi_mul_I n + +lemma expPhase_sub_int (t : ℝ) (n : ℤ) : expPhase (t-n) = expPhase t := by + rw [expPhase_sub, expPhase_int, map_one, mul_one] + +lemma circleDistance_nonneg (t : ℝ) : 0 ≤ circleDistance t := abs_nonneg _ + +lemma circleDistance_le_half (t : ℝ) : circleDistance t ≤ 1/2 := abs_sub_round t + +lemma circleDistance_le_abs_sub_int (t : ℝ) (n : ℤ) : circleDistance t ≤ |t-n| := + round_le t n + +lemma circleDistance_le_abs (t : ℝ) : circleDistance t ≤ |t| := by + simpa using circleDistance_le_abs_sub_int t 0 + +lemma circleDistance_sub_le (s t : ℝ) : circleDistance (s-t) ≤ + |(s-round s)-(t-round t)| := by + convert circleDistance_le_abs_sub_int (s-t) (round s-round t) using 1 + push_cast + congr 1 + ring + +lemma expPhase_sub_one_lower (t : ℝ) : 4*circleDistance t ≤ ‖expPhase t-1‖ := by + let u := t-(round t : ℝ) + have hu : |u| ≤ 1/2 := abs_sub_round t + have hp := Real.pi_pos + have hs := Real.mul_abs_le_abs_sin (x := Real.pi*u) + (by rw [abs_mul, abs_of_pos hp]; nlinarith) + rw [abs_mul, abs_of_pos hp] at hs + have hmul : 2/Real.pi*(Real.pi*|u|)=2*|u| := by field_simp + rw [hmul] at hs + rw [← expPhase_sub_int t (round t)] + change 4*|u| ≤ ‖Complex.exp (↑(2*Real.pi*u)*Complex.I)-1‖ + rw [mul_comm _ Complex.I, Complex.norm_exp_I_mul_ofReal_sub_one] + rw [show 2*Real.pi*u/2=Real.pi*u by ring, Real.norm_eq_abs, + abs_mul, abs_of_pos (by norm_num : (0 : ℝ)<2)] + linarith + +lemma linear_phase_sum_trivial (t : ℝ) (L : ℕ) : + ‖∑ m ∈ range L, expPhase (m*t)‖ ≤ L := by + calc + _ ≤ ∑ m ∈ range L, ‖expPhase (m*t)‖ := norm_sum_le _ _ + _ = L := by simp + +lemma linear_phase_sum_distance (t : ℝ) (L : ℕ) (ht : 0 < circleDistance t) : + ‖∑ m ∈ range L, expPhase (m*t)‖ ≤ 1 / (2*circleDistance t) := by + have hz : expPhase t ≠ 1 := by + intro he + have := expPhase_sub_one_lower t + rw [he, sub_self, norm_zero] at this + linarith + simp_rw [expPhase_nat_mul] + rw [geom_sum_eq hz, norm_div] + have hn : ‖expPhase t ^ L - 1‖ ≤ 2 := by + calc + _ ≤ ‖expPhase t^L‖+‖(1 : ℂ)‖ := norm_sub_le _ _ + _ = 2 := by simp; norm_num + calc + _ ≤ 2 / (4*circleDistance t) := + div_le_div₀ (by positivity) hn (by positivity) (expPhase_sub_one_lower t) + _ = 1 / (2*circleDistance t) := by ring + +lemma finite_phase_analysis {I : Type*} [Fintype I] [DecidableEq I] + (θ : I → ℝ) (L : ℕ) (d : ℝ) (hd : 0 < d) + (hsep : ∀ i j, i ≠ j → d ≤ circleDistance (θ j-θ i)) + (f : Fin L → ℂ) : + (∑ i, ‖∑ n : Fin L, f n * expPhase (-(n : ℝ)*θ i)‖ ^ 2) ≤ + ((L : ℝ) + Fintype.card I / (2*d)) * ∑ n, ‖f n‖ ^ 2 := by + let v : I → EuclideanSpace ℂ (Fin L) := fun i => WithLp.toLp 2 + (fun n : Fin L => expPhase ((n : ℝ)*θ i)) + let f' : EuclideanSpace ℂ (Fin L) := WithLp.toLp 2 f + have hinner (i j : I) : inner ℂ (v i) (v j) = + ∑ n ∈ range L, expPhase ((n : ℝ)*(θ j-θ i)) := by + rw [PiLp.inner_apply] + simp only [v, RCLike.inner_apply] + simp_rw [← expPhase_sub, ← mul_sub] + exact Fin.sum_univ_eq_sum_range (fun n : ℕ => expPhase ((n : ℝ)*(θ j-θ i))) L + have hg (i j : I) : ‖inner ℂ (v i) (v j)‖ ≤ + (if i=j then (L : ℝ) else 0) + 1/(2*d) := by + rw [hinner] + by_cases hij : i=j + · subst j + simp only [sub_self, mul_zero, expPhase_zero, sum_const, card_range, + nsmul_eq_mul, mul_one, Complex.norm_natCast, ite_true] + exact le_add_of_nonneg_right (by positivity) + · rw [ite_eq_right hij, zero_add] + exact (linear_phase_sum_distance _ L (hd.trans_le (hsep i j hij))).trans + (one_div_le_one_div_of_le (by positivity) (by linarith [hsep i j hij])) + have hs : ∀ a : I → ℂ, ‖∑ i, a i • v i‖ ^ 2 ≤ + ((L : ℝ)+Fintype.card I*(1/(2*d))) * ∑ i, ‖a i‖ ^ 2 := + synthesis_norm_sq_bound v L (1/(2*d)) (by positivity) hg + have h := analysis_of_synthesis v _ (by positivity) hs f' + have he (i : I) : inner ℂ (v i) f' = + ∑ n : Fin L, f n * expPhase (-(n : ℝ)*θ i) := by + simp only [PiLp.inner_apply, f', v, RCLike.inner_apply] + simp_rw [← expPhase_neg, neg_mul] + rw [PiLp.norm_sq_eq_of_L2] at h + simp only [he, f'] at h + simpa only [div_eq_mul_inv, one_mul] using h + +lemma finite_phase_analysis_average {I : Type*} [Fintype I] [DecidableEq I] + (θ : I → ℝ) (L : ℕ) (hL : 0 < L) (d : ℝ) (hd : 0 < d) + (hsep : ∀ i j, i ≠ j → d ≤ circleDistance (θ j-θ i)) + (f : Fin L → ℂ) : + (∑ i, ‖(L : ℂ)⁻¹ * ∑ n : Fin L, f n * expPhase (-(n : ℝ)*θ i)‖ ^ 2) ≤ + (1 + Fintype.card I / (2*d*L)) * ((L : ℝ)⁻¹ * ∑ n, ‖f n‖ ^ 2) := by + have h := finite_phase_analysis θ L d hd hsep f + simp only [norm_mul, norm_inv, Complex.norm_natCast, mul_pow, ← mul_sum] + have hL' : (0 : ℝ) < L := Nat.cast_pos.mpr hL + calc + _ ≤ (L : ℝ)⁻¹ ^ 2 * (((L : ℝ)+Fintype.card I/(2*d))*∑ n, ‖f n‖ ^ 2) := + mul_le_mul_of_nonneg_left h (sq_nonneg _) + _ = _ := by field_simp + +lemma stdAddChar_eq_expPhase {p : ℕ} [NeZero p] (a : ZMod p) : + ZMod.stdAddChar a=expPhase ((a.val : ℝ)/p) := by + rw [ZMod.stdAddChar_apply, ZMod.toCircle_apply] + change Complex.exp _ = Complex.exp _ + congr 1 + push_cast + ring + +lemma expPhase_sum {I : Type*} (s : Finset I) (f : I → ℝ) : + expPhase (∑ i∈s, f i)=∏ i∈s, expPhase (f i) := by + classical + induction s using Finset.induction_on with + | empty => simp + | @insert i s hi ih => rw [sum_insert hi, prod_insert hi, expPhase_add, ih] + +variable {J : Type*} [Fintype J] + +variable (p : J → ℕ) [∀ j, NeZero (p j)] + +abbrev ResidueSpace := ∀ j, ZMod (p j) + +noncomputable def prodChar (a z : ResidueSpace p) : ℂ := + ∏ j, ZMod.stdAddChar (a j*z j) + +noncomputable def frequencyAngle (a : ResidueSpace p) : ℝ := + ∑ j, (a j).val/(p j : ℝ) + +noncomputable def primeSupport (a : ResidueSpace p) : Finset J := + univ.filter fun j => a j ≠ 0 + +noncomputable def supportDenominator (a : ResidueSpace p) : ℕ := + ∏ j∈primeSupport p a, p j + +@[simp] lemma prodChar_zero (z : ResidueSpace p) : prodChar p 0 z=1 := by + simp [prodChar, AddChar.map_zero_eq_one] +@[simp] lemma prodChar_zero_right (a : ResidueSpace p) : prodChar p a 0=1 := by + simp [prodChar, AddChar.map_zero_eq_one] +lemma prodChar_add (a b z : ResidueSpace p) : + prodChar p (a+b) z=prodChar p a z*prodChar p b z := by + simp only [prodChar, Pi.add_apply, add_mul, AddChar.map_add_eq_mul, prod_mul_distrib] +lemma prodChar_add_right (a z w : ResidueSpace p) : + prodChar p a (z+w)=prodChar p a z*prodChar p a w := by + simp only [prodChar, Pi.add_apply, mul_add, AddChar.map_add_eq_mul, prod_mul_distrib] +lemma prodChar_neg (a z : ResidueSpace p) : prodChar p (-a) z=conj (prodChar p a z) := by + simp only [prodChar, Pi.neg_apply, neg_mul, AddChar.map_neg_eq_conj, map_prod] +lemma prodChar_sub (a b z : ResidueSpace p) : + prodChar p (a-b) z=prodChar p a z*conj (prodChar p b z) := by + rw [sub_eq_add_neg, prodChar_add, prodChar_neg] +lemma prodChar_symm (a z : ResidueSpace p) : prodChar p a z=prodChar p z a := by + simp only [prodChar, mul_comm] +lemma norm_prodChar (a z : ResidueSpace p) : ‖prodChar p a z‖=1 := by + simp only [prodChar, norm_prod, ZMod.stdAddChar_apply, Circle.norm_coe, prod_const_one] +lemma prodChar_nat_diagonal (a : ResidueSpace p) (n : ℕ) : + prodChar p a (fun j => (n : ZMod (p j)))=expPhase (n*frequencyAngle p a) := by + simp only [prodChar, frequencyAngle, mul_sum, expPhase_sum] + apply prod_congr rfl; intro j _ + rw [expPhase_nat_mul, ← stdAddChar_eq_expPhase] + simpa only [nsmul_eq_mul, Nat.cast_comm, mul_comm] using + AddChar.map_nsmul_eq_pow (ZMod.stdAddChar (N := p j)) n (a j) + +lemma prodChar_one_diagonal (a : ResidueSpace p) : + prodChar p a (fun _ => 1)=expPhase (frequencyAngle p a) := by + simpa using prodChar_nat_diagonal p a 1 + +lemma prodChar_eq_one_iff (a : ResidueSpace p) : + (∀ z, prodChar p a z=1) ↔ a=0 := by + classical + constructor + · intro h + funext j + have hj := h (Pi.single j 1) + have he : prodChar p a (Pi.single j 1)=ZMod.stdAddChar (a j) := by + unfold prodChar + rw [prod_eq_single j] + · simp only [Pi.single_eq_same, mul_one] + · intro i _ hij + simp only [Pi.single_eq_of_ne hij, mul_zero, AddChar.map_zero_eq_one] + · simp + rw [he, ← AddChar.map_zero_eq_one (ZMod.stdAddChar (N := p j))] at hj + exact ZMod.injective_stdAddChar hj + · rintro rfl z + exact prodChar_zero p z + +lemma frequencyAngle_separates + (hp : Pairwise fun i j => (p i).Coprime (p j)) (a b : ResidueSpace p) + (he : expPhase (frequencyAngle p a-frequencyAngle p b)=1) : a=b := by + classical + let : NeZero (∏ j, p j) := ⟨prod_ne_zero_iff.mpr (fun j _ => NeZero.ne (p j))⟩ + have h1 : prodChar p (a-b) (fun j => (1 : ZMod (p j)))=1 := by + rw [prodChar_sub, prodChar_one_diagonal, prodChar_one_diagonal] + simpa only [← expPhase_sub] using he + apply sub_eq_zero.mp + apply (prodChar_eq_one_iff p (a-b)).mp + intro z + let e := ZMod.prodEquivPi p hp + let n : ℕ := (e.symm z).val + have hn : (fun j => (n : ZMod (p j)))=z := by + have hz := e.apply_symm_apply z + convert hz using 1 + funext j + simp only [e, ZMod.prodEquivPi_apply] + rw [← ZMod.natCast_zmod_val (e.symm z), map_natCast] + rw [← hn, prodChar_nat_diagonal] + rw [prodChar_one_diagonal] at h1 + rw [expPhase_nat_mul, h1, one_pow] + +lemma complex_expect_prod_pi [DecidableEq J] {X : J → Type*} [∀ j, Fintype (X j)] + (f : ∀ j, X j → ℂ) : + (𝔼 x : ∀ j, X j, ∏ j, f j (x j))=∏ j, (𝔼 t : X j, f j t) := by + classical + simp only [expect_eq_sum_div_card, card_univ, prod_div_distrib, + Fintype.card_pi, Nat.cast_prod] + rw [Fintype.prod_sum] + +omit [Fintype J] in +lemma prime_char_expect (j : J) (a : ZMod (p j)) : + (𝔼 z : ZMod (p j), ZMod.stdAddChar (a*z))=if a=0 then 1 else 0 := by + rw [expect_eq_sum_div_card] + simp_rw [mul_comm a] + rw [AddChar.sum_mulShift _ (ZMod.isPrimitive_stdAddChar (p j))] + simp only [card_univ, ZMod.card] + split_ifs <;> simp_all + +lemma prodChar_expect [DecidableEq J] (a : ResidueSpace p) : + (𝔼 z, prodChar p a z)=if a=0 then 1 else 0 := by + classical + unfold prodChar + rw [complex_expect_prod_pi (fun j (z : ZMod (p j)) => ZMod.stdAddChar (a j*z))] + simp_rw [prime_char_expect] + by_cases ha : a=0 + · simp [ha] + · rw [ite_eq_right ha] + have hex : ∃ j, a j ≠ 0 := by + by_contra! h + exact ha (funext h) + obtain ⟨j, hj⟩ := hex + exact prod_eq_zero (mem_univ j) (ite_eq_right hj) + +lemma prodChar_orthogonal [DecidableEq J] (a b : ResidueSpace p) : + (𝔼 z, prodChar p a z*conj (prodChar p b z))=if a=b then 1 else 0 := by + simp_rw [← prodChar_sub] + rw [prodChar_expect] + simp only [sub_eq_zero] + +noncomputable def supportNumerator (a : ResidueSpace p) : ℕ := by + classical + exact ∑ j∈primeSupport p a, (a j).val * ∏ i∈(primeSupport p a).erase j, p i + +lemma supportDenominator_pos (a : ResidueSpace p) : 0 < supportDenominator p a := by + unfold supportDenominator + exact prod_pos fun j _ => Nat.pos_of_ne_zero (NeZero.ne (p j)) + +lemma frequencyAngle_numerator (a : ResidueSpace p) : + frequencyAngle p a = (supportNumerator p a : ℝ)/supportDenominator p a := by + classical + have hp0 (j : J) : (p j : ℝ) ≠ 0 := Nat.cast_ne_zero.mpr (NeZero.ne (p j)) + have hq : (supportDenominator p a : ℝ) ≠ 0 := + Nat.cast_ne_zero.mpr (Nat.ne_of_gt (supportDenominator_pos p a)) + apply (eq_div_iff hq).mpr + have hs : frequencyAngle p a = ∑ j∈primeSupport p a, (a j).val/(p j : ℝ) := by + unfold frequencyAngle primeSupport + symm + apply sum_filter_of_ne + intro j _ hj + contrapose! hj + simp [hj] + rw [hs, sum_mul] + unfold supportNumerator + push_cast + apply sum_congr rfl; intro j hj + have he : supportDenominator p a = p j * ∏ i∈(primeSupport p a).erase j, p i := + (mul_prod_erase _ _ hj).symm + rw [he] + push_cast + field_simp [hp0 j] + +lemma frequencyAngle_difference (a b : ResidueSpace p) : + frequencyAngle p a-frequencyAngle p b = + ((supportNumerator p a : ℤ)*supportDenominator p b- + supportNumerator p b*supportDenominator p a : ℤ)/ + ((supportDenominator p a*supportDenominator p b : ℕ) : ℝ) := by + rw [frequencyAngle_numerator, frequencyAngle_numerator] + have ha : (supportDenominator p a : ℝ) ≠ 0 := by positivity [supportDenominator_pos p a] + have hb : (supportDenominator p b : ℝ) ≠ 0 := by positivity [supportDenominator_pos p b] + push_cast + field_simp [ha, hb] + +lemma frequency_difference_not_dvd + (hp : Pairwise fun i j => (p i).Coprime (p j)) + (a b : ResidueSpace p) (hab : a ≠ b) : + ¬ ((supportDenominator p a*supportDenominator p b : ℕ) : ℤ) ∣ + ((supportNumerator p a : ℤ)*supportDenominator p b- + supportNumerator p b*supportDenominator p a) := by + rintro ⟨k, hk⟩ + apply hab + apply frequencyAngle_separates p hp + rw [frequencyAngle_difference, hk] + have hq : ((supportDenominator p a*supportDenominator p b : ℕ) : ℝ) ≠ 0 := by + positivity [supportDenominator_pos p a, supportDenominator_pos p b] + push_cast at hq ⊢ + rw [mul_div_cancel_left₀ _ hq] + exact expPhase_int k + +lemma frequencyAngle_remainder (a : ResidueSpace p) : + expPhase (frequencyAngle p a) = + expPhase ((supportNumerator p a % supportDenominator p a : ℕ)/ + (supportDenominator p a : ℝ)) := by + rw [frequencyAngle_numerator] + have hq : (supportDenominator p a : ℝ) ≠ 0 := by + exact Nat.cast_ne_zero.mpr (Nat.ne_of_gt (supportDenominator_pos p a)) + have he : (supportNumerator p a : ℝ)/supportDenominator p a = + (supportNumerator p a % supportDenominator p a : ℕ)/(supportDenominator p a : ℝ)+ + (supportNumerator p a / supportDenominator p a : ℕ) := by + apply (div_eq_iff hq).mpr + rw [add_mul, div_mul_cancel₀ _ hq] + norm_cast + simpa only [mul_comm] using (Nat.mod_add_div (supportNumerator p a) (supportDenominator p a)).symm + rw [he, expPhase_add] + have hi : expPhase ((supportNumerator p a / supportDenominator p a : ℕ) : ℝ)=1 := by + exact_mod_cast expPhase_int (supportNumerator p a / supportDenominator p a : ℕ) + rw [hi, mul_one] + +lemma bounded_frequency_card + (hp : Pairwise fun i j => (p i).Coprime (p j)) (Q : ℕ) + (F : Finset (ResidueSpace p)) + (hF : ∀ a∈F, supportDenominator p a ≤ Q) : F.card ≤ Q^2 := by + classical + let e : F → Fin Q × Fin Q := fun a => + (⟨supportDenominator p a-1, by + have := supportDenominator_pos p a + have := hF a a.property + omega⟩, + ⟨supportNumerator p a % supportDenominator p a, + (Nat.mod_lt _ (supportDenominator_pos p a)).trans_le (hF a a.property)⟩) + have he : Function.Injective e := by + intro a b hab + have hq : supportDenominator p a=supportDenominator p b := by + have h := congrArg (fun t : Fin Q × Fin Q => t.1.val) hab + have := supportDenominator_pos p a + have := supportDenominator_pos p b + change supportDenominator p a-1=supportDenominator p b-1 at h + omega + have hn : supportNumerator p a % supportDenominator p a= + supportNumerator p b % supportDenominator p b := + congrArg (fun t : Fin Q × Fin Q => t.2.val) hab + apply Subtype.ext + apply frequencyAngle_separates p hp + rw [expPhase_sub, frequencyAngle_remainder, frequencyAngle_remainder, hn, hq] + rw [Complex.mul_conj', norm_expPhase] + norm_num + have hcard := Fintype.card_le_of_injective e he + simpa only [Fintype.card_coe, Fintype.card_prod, Fintype.card_fin, sq] using hcard + +lemma rational_circleDistance_lower (k : ℤ) (q : ℕ) (hq : 0 < q) + (hnd : ¬ (q : ℤ) ∣ k) : 1/(q : ℝ) ≤ circleDistance ((k : ℝ)/q) := by + have hqR : 0 < (q : ℝ) := Nat.cast_pos.mpr hq + let n := round ((k : ℝ)/q) + have hn : k-(q : ℤ)*n ≠ 0 := by + intro he + apply hnd + exact ⟨n, by linarith⟩ + have hI : (1 : ℤ) ≤ |k-(q : ℤ)*n| := by + have := abs_pos.mpr hn + omega + have hR : (1 : ℝ) ≤ |(k : ℝ)-(q : ℝ)*(n : ℝ)| := by exact_mod_cast hI + have he : |(k : ℝ)-(q : ℝ)*(n : ℝ)| = (q : ℝ)*circleDistance ((k : ℝ)/q) := by + calc + _ = |(q : ℝ)*((k : ℝ)/q-(n : ℝ))| := by congr 1; field_simp + _ = _ := by rw [abs_mul, abs_of_pos hqR]; rfl + rw [he] at hR + exact (div_le_iff₀ hqR).mpr (by simpa only [mul_comm] using hR) + +lemma frequency_spacing (hp : Pairwise fun i j => (p i).Coprime (p j)) + (a b : ResidueSpace p) (hab : a ≠ b) (Q : ℕ) + (ha : supportDenominator p a ≤ Q) (hb : supportDenominator p b ≤ Q) + (m : ℕ) (hma : m.Coprime (supportDenominator p a)) + (hmb : m.Coprime (supportDenominator p b)) : + 1/(Q : ℝ)^2 ≤ circleDistance (m*frequencyAngle p a-m*frequencyAngle p b) := by + have hQ : 0 < Q := (supportDenominator_pos p a).trans_le ha + let q := supportDenominator p a*supportDenominator p b + let k : ℤ := (supportNumerator p a : ℤ)*supportDenominator p b- + supportNumerator p b*supportDenominator p a + have hq : 0 < q := Nat.mul_pos (supportDenominator_pos p a) (supportDenominator_pos p b) + have hmk : ¬ (q : ℤ) ∣ (m : ℤ)*k := by + intro h + have hc : IsCoprime (q : ℤ) (m : ℤ) := (hma.mul_right hmb).symm.cast + exact frequency_difference_not_dvd p hp a b hab (hc.dvd_of_dvd_mul_left h) + have hr := rational_circleDistance_lower ((m : ℤ)*k) q hq hmk + have he : m*frequencyAngle p a-m*frequencyAngle p b=((m : ℤ)*k : ℤ)/(q : ℝ) := by + rw [← mul_sub, frequencyAngle_difference] + dsimp only [k, q] + push_cast + ring + rw [he] + apply le_trans _ hr + apply one_div_le_one_div_of_le (Nat.cast_pos.mpr hq) + have hqq := Nat.mul_le_mul ha hb + simpa only [q, sq, Nat.cast_mul] using (show (supportDenominator p a : ℝ)*(supportDenominator p b : ℝ) ≤ (Q : ℝ)*(Q : ℝ) by exact_mod_cast hqq) + +lemma arithmetic_phase_analysis {I : Type*} [Fintype I] [DecidableEq I] + (hp : Pairwise fun i j => (p i).Coprime (p j)) + (a : I → ResidueSpace p) (hinj : Function.Injective a) (Q : ℕ) (hQ : 0 < Q) + (ha : ∀ i, supportDenominator p (a i) ≤ Q) + (m : ℕ) (hm : ∀ i, m.Coprime (supportDenominator p (a i))) + (L : ℕ) (f : Fin L → ℂ) : + (∑ i, ‖∑ n : Fin L, f n*expPhase (-(n : ℝ)*(m*frequencyAngle p (a i)))‖^2) ≤ + (L+(Q : ℝ)^4/2)*∑n, ‖f n‖^2 := by + have hc : Fintype.card I ≤ Q^2 := by + have hh := bounded_frequency_card p hp Q (univ.image a) (by + intro b hb + obtain ⟨i, _, rfl⟩ := mem_image.mp hb + exact ha i) + simpa only [card_image_of_injective _ hinj, card_univ] using hh + have hs (i j : I) (hij : i ≠ j) : + 1/(Q : ℝ)^2 ≤ circleDistance (m*frequencyAngle p (a j)-m*frequencyAngle p (a i)) := + frequency_spacing p hp (a j) (a i) (fun h => hij (hinj h).symm) Q (ha j) (ha i) m (hm j) (hm i) + have hh := finite_phase_analysis (fun i => m*frequencyAngle p (a i)) L (1/(Q : ℝ)^2) + (by positivity) hs f + apply hh.trans + apply mul_le_mul_of_nonneg_right _ (sum_nonneg fun _ _ => sq_nonneg _) + apply add_le_add_right + have hQR : (0 : ℝ) < Q := Nat.cast_pos.mpr hQ + calc + (Fintype.card I : ℝ)/(2*(1/(Q : ℝ)^2)) ≤ (Q : ℝ)^2/(2*(1/(Q : ℝ)^2)) := by + exact div_le_div_of_nonneg_right (by exact_mod_cast hc) (by positivity) + _ = (Q : ℝ)^4/2 := by field_simp + +noncomputable def residueGate (q : ℕ) (x : ZMod q) : ℝ := + (if x=0 then (q : ℝ) else 0)-1 + +lemma sum_char_nonzero {q : ℕ} [NeZero q] (x : ZMod q) : + (∑ a : ZMod q, if a≠0 then ZMod.stdAddChar (a*x) else 0)= + (residueGate q x : ℂ) := by + classical + have hs := AddChar.sum_mulShift x (ZMod.isPrimitive_stdAddChar q) + have he : (∑ a : ZMod q, ZMod.stdAddChar (a*x))= + (∑ a : ZMod q, if a≠0 then ZMod.stdAddChar (a*x) else 0)+1 := by + calc + _ = ∑ a : ZMod q, ((if a≠0 then ZMod.stdAddChar (a*x) else 0)+if a=0 then 1 else 0) := by + apply sum_congr rfl; intro a _ + by_cases ha : a=0 <;> simp [ha, AddChar.map_zero_eq_one] + _ = _ := by simp only [sum_add_distrib, sum_ite_eq', mem_univ, ite_true] + have hs' : (∑ a : ZMod q, ZMod.stdAddChar (a*x))=if x=0 then (q : ℂ) else 0 := by + simpa only [ZMod.card, apply_ite, Nat.cast_zero] using hs + unfold residueGate + push_cast + rw [hs'] at he + split_ifs at * <;> push_cast <;> linear_combination -he + +omit [∀ j, NeZero (p j)] in +lemma exact_support_iff [DecidableEq J] (U : Finset J) (a : ResidueSpace p) : + primeSupport p a=U ↔ ∀j, (a j≠0 ↔ j∈U) := by + simp only [Finset.ext_iff, primeSupport, mem_filter, mem_univ, true_and] + +lemma sum_char_exact [DecidableEq J] (U : Finset J) (z : ResidueSpace p) : + (∑ a : ResidueSpace p, if primeSupport p a=U then prodChar p a z else 0)= + ∏ j∈U, (residueGate (p j) (z j) : ℂ) := by + classical + let w := fun j (a : ZMod (p j)) => + if (if j∈U then a≠0 else a=0) then ZMod.stdAddChar (a*z j) else 0 + have he (a : ResidueSpace p) : (if primeSupport p a=U then prodChar p a z else 0)=∏j, w j (a j) := by + by_cases ha : primeSupport p a=U + · rw [ite_eq_left ha] + apply prod_congr rfl; intro j _ + have hj := (exact_support_iff p U a).mp ha j + by_cases hU : j∈U <;> simp_all [w] + · rw [ite_eq_right ha] + have hn : ∃j, ¬ (a j≠0 ↔ j∈U) := by + simpa only [exact_support_iff, not_forall] using ha + obtain ⟨j,hj⟩ := hn + symm + apply prod_eq_zero (mem_univ j) + by_cases hU : j∈U <;> simp_all [w] + simp only [he] + rw [← Fintype.prod_sum] + have hj (j : J) : (∑ a : ZMod (p j), w j a)=if j∈U then (residueGate (p j) (z j) : ℂ) else 1 := by + by_cases hU : j∈U + · simp only [w, hU, ite_true] + exact sum_char_nonzero (z j) + · simp only [w, hU, ite_false, sum_ite_eq', mem_univ, ite_true, zero_mul, AddChar.map_zero_eq_one] + simp_rw [hj] + rw [prod_ite_mem] + simp + +noncomputable def exactGate [DecidableEq J] (U : Finset J) (z : ResidueSpace p) : ℝ := + ∏j∈U, residueGate (p j) (z j) + +lemma exactGate_fourier [DecidableEq J] (U : Finset J) (z : ResidueSpace p) : + (exactGate p U z : ℂ) = ∑a∈univ.filter (fun a => primeSupport p a=U), prodChar p a z := by + rw [sum_filter, sum_char_exact] + simp only [exactGate, Complex.ofReal_prod] + +lemma prodChar_neg_right (a z : ResidueSpace p) : prodChar p a (-z)=conj (prodChar p a z) := by + rw [prodChar_symm, prodChar_neg, prodChar_symm] + +lemma prodChar_sub_right (a z w : ResidueSpace p) : + prodChar p a (z-w)=prodChar p a z*conj (prodChar p a w) := by + rw [sub_eq_add_neg, prodChar_add_right, prodChar_neg_right] + +noncomputable def fourierPolynomial [DecidableEq J] (c : ResidueSpace p → ℂ) (z : ResidueSpace p) : ℂ := + ∑a, c a*prodChar p a z + +lemma prodChar_norm_sq (a z : ResidueSpace p) : + prodChar p a z*conj (prodChar p a z)=1 := by + rw [Complex.mul_conj', norm_prodChar] + norm_num + +lemma fourierPolynomial_parseval [DecidableEq J] (c : ResidueSpace p → ℂ) : + (𝔼 z, ‖fourierPolynomial p c z‖^2)=∑a, ‖c a‖^2 := by + have he : (𝔼 z, fourierPolynomial p c z*conj (fourierPolynomial p c z))= + ∑a, c a*conj (c a) := by + simp only [fourierPolynomial, map_sum, sum_mul, mul_sum, map_mul] + rw [expect_sum_comm] + apply sum_congr rfl; intro a _ + rw [expect_sum_comm] + have he a b z : c a*prodChar p a z*(conj (c b)*conj (prodChar p b z))= + c a*conj (c b)*(prodChar p a z*conj (prodChar p b z)) := by ring + simp only [he, ← mul_expect, prodChar_orthogonal] + simp + apply Complex.ofReal_injective + simpa only [Complex.mul_conj', ← Complex.ofReal_pow, ← Complex.ofReal_sum, + ← Complex.ofReal_expect] using he + +lemma fourierPolynomial_reconstruction [DecidableEq J] (f : ResidueSpace p → ℂ) (z : ResidueSpace p) : + fourierPolynomial p (fun a => 𝔼 x, f x*conj (prodChar p a x)) z=f z := by + classical + unfold fourierPolynomial + simp_rw [Finset.expect_mul] + rw [← expect_sum_comm] + have he x : (∑a, f x*conj (prodChar p a x)*prodChar p a z)= + f x*(Fintype.card (ResidueSpace p))*(if z=x then 1 else 0) := by + simp_rw [mul_assoc, mul_comm (conj _), ← prodChar_sub_right] + rw [← mul_sum] + have hs := prodChar_expect p (z-x) + simp_rw [prodChar_symm p _ (z-x)] + rw [expect_eq_sum_div_card] at hs + have hc : (Fintype.card (ResidueSpace p) : ℂ) ≠ 0 := by + exact Nat.cast_ne_zero.mpr Fintype.card_ne_zero + have hs' := (div_eq_iff hc).mp hs + rw [hs'] + simp only [sub_eq_zero] + ring + simp only [he, expect_eq_sum_div_card, mul_ite, mul_one, mul_zero, + sum_ite_eq, mem_univ, ite_true, card_univ] + exact mul_div_cancel_right₀ _ (Nat.cast_ne_zero.mpr Fintype.card_ne_zero) + +omit [Fintype J] in +lemma residue_crt [DecidableEq J] + (hp : Pairwise fun i j => (p i).Coprime (p j)) (B : Finset J) (z : ResidueSpace p) : + ∃ a : ℕ, a < ∏j∈B, p j ∧ ∀n : ℕ, + (∀j∈B, (n : ZMod (p j))=z j) ↔ n % (∏j∈B, p j)=a := by + classical + let q := ∏j : B, p j + have hq : 0 < q := prod_pos fun j _ => Nat.pos_of_ne_zero (NeZero.ne (p j)) + let : NeZero q := ⟨Nat.ne_of_gt hq⟩ + have hpB : Pairwise fun i j : B => (p i).Coprime (p j) := fun i j hij => + hp (Subtype.val_injective.ne hij) + let e := ZMod.prodEquivPi (fun j : B => p j) hpB + let w := e.symm (fun j : B => z j) + have hval := ZMod.val_lt w + have hqe : q=∏j∈B, p j := prod_coe_sort B p + refine ⟨w.val, by simpa only [← hqe] using hval, ?_⟩ + intro n + have he : (∀j∈B, (n : ZMod (p j))=z j) ↔ (n : ZMod q)=w := by + constructor + · intro h + apply e.injective + rw [e.apply_symm_apply] + funext j + simp only [e, ZMod.prodEquivPi_apply, map_natCast] + exact h j j.property + · intro h j hj + have hh := congrArg (fun u => e u ⟨j,hj⟩) h + have hw : e w=(fun j : B => z j) := e.apply_symm_apply _ + rw [hw] at hh + simpa only [e, ZMod.prodEquivPi_apply, map_natCast] using hh + rw [he, ← hqe] + constructor + · intro h + simpa only [ZMod.val_natCast] using congrArg ZMod.val h + · intro h + apply ZMod.val_injective + simpa only [ZMod.val_natCast] using h + +omit [∀j, NeZero (p j)] in +lemma support_coprime [DecidableEq J] + (hp : Pairwise fun i j => (p i).Coprime (p j)) + (B : Finset J) (a : ResidueSpace p) (hB : Disjoint B (primeSupport p a)) : + (∏j∈B, p j).Coprime (supportDenominator p a) := by + apply Nat.coprime_prod_left_iff.mpr + intro i hi + apply Nat.coprime_prod_right_iff.mpr + intro j hj + exact hp (fun he => (disjoint_left.mp hB hi) (he ▸ hj)) + +omit [∀j, NeZero (p j)] in +lemma product_indicator [DecidableEq J] (B : Finset J) (z : ResidueSpace p) (n : ℕ) : + (∏j∈B, (if (n : ZMod (p j))=z j then (p j : ℂ) else 0))= + (∏j∈B, p j : ℕ)*(if ∀j∈B, (n : ZMod (p j))=z j then 1 else 0) := by + classical + by_cases h : ∀j∈B, (n : ZMod (p j))=z j + · rw [ite_eq_left h, mul_one] + push_cast + apply prod_congr rfl; intro j hj + rw [ite_eq_left (h j hj)] + · rw [ite_eq_right h, mul_zero] + push Not at h + obtain ⟨j,hj,he⟩ := h + exact prod_eq_zero hj (ite_eq_right he) + +omit [∀j, NeZero (p j)] in +lemma exactGate_expand [DecidableEq J] (B : Finset J) (z : ResidueSpace p) (n : ℕ) : + (exactGate p B (z-fun j => (n : ZMod (p j))) : ℂ)= + ∑S∈B.powerset, (-1 : ℂ)^(B\S).card*(∏j∈S, p j : ℕ)* + (if ∀j∈S, (n : ZMod (p j))=z j then 1 else 0) := by + classical + simp only [exactGate, Complex.ofReal_prod] + have he j : (residueGate (p j) ((z-fun j => (n : ZMod (p j))) j) : ℂ)= + (if (n : ZMod (p j))=z j then (p j : ℂ) else 0)+(-1) := by + dsimp only [residueGate, Pi.sub_apply] + by_cases hn : (n : ZMod (p j))=z j + · simp [hn, sub_eq_add_neg] + · have hz : z j-(n : ZMod (p j))≠0 := fun h => hn (sub_eq_zero.mp h).symm + simp [hn, hz] + simp only [he] + rw [prod_add] + apply sum_congr rfl; intro S _ + rw [product_indicator] + simp only [prod_const] + ring + +lemma vector_signed_sum_bound {I T : Type*} [Fintype I] [DecidableEq I] + (S : Finset T) (v : T → I → ℂ) (sgn : T → ℂ) (C : ℝ) (hC : 0 ≤ C) + (hsgn : ∀t∈S, ‖sgn t‖ ≤ 1) (hv : ∀t∈S, (∑i, ‖v t i‖^2) ≤ C^2) : + (∑i, ‖∑t∈S, sgn t*v t i‖^2) ≤ (S.card*C)^2 := by + let w : T → EuclideanSpace ℂ I := fun t => sgn t • WithLp.toLp 2 (v t) + have hw t (ht : t∈S) : ‖w t‖ ≤ C := by + have hh : ‖(WithLp.toLp 2 (v t) : EuclideanSpace ℂ I)‖ ≤ C := by + apply (sq_le_sq₀ (norm_nonneg _) hC).mp + rw [PiLp.norm_sq_eq_of_L2] + exact hv t ht + exact (norm_smul_le _ _).trans (by nlinarith [hsgn t ht, norm_nonneg (sgn t)]) + have hh : ‖∑t∈S, w t‖ ≤ S.card*C := by + calc + _ ≤ ∑t∈S, ‖w t‖ := norm_sum_le _ _ + _ ≤ ∑_t∈S, C := sum_le_sum fun t ht => hw t ht + _ = _ := by simp + have he : (∑t∈S, w t)=(WithLp.toLp 2 (fun i => ∑t∈S, sgn t*v t i) : EuclideanSpace ℂ I) := by + ext i + simp only [w, WithLp.ofLp_sum, Finset.sum_apply, WithLp.ofLp_smul, + Pi.smul_apply, smul_eq_mul] + rw [he, ← sq_le_sq₀ (norm_nonneg _) (mul_nonneg (Nat.cast_nonneg _) hC), PiLp.norm_sq_eq_of_L2] at hh + exact hh + +lemma sum_residue_progression {E : Type*} [AddCommMonoid E] + (f : ℕ → E) (L q a : ℕ) (hq : 0 < q) (ha : a < q) : + (∑ n ∈ range L, if n%q=a then f n else 0)= + ∑ t ∈ range (L/q+1), if a+q*t a+q*t) + · intro t ht + obtain ⟨_, ht⟩ := mem_filter.mp ht + exact mem_filter.mpr ⟨mem_range.mpr ht, by rw [Nat.add_mul_mod_self_left, Nat.mod_eq_of_lt ha]⟩ + · intro t ht u hu he + exact Nat.eq_of_mul_eq_mul_left hq (Nat.add_left_cancel he) + · intro n hn + obtain ⟨hn, hnq⟩ := mem_filter.mp hn + have hnL := mem_range.mp hn + have he : a+q*(n/q)=n := by rw [← hnq]; exact Nat.mod_add_div n q + refine ⟨n/q, mem_filter.mpr ⟨mem_range.mpr ?_, by rwa [he]⟩, he⟩ + exact Nat.lt_succ_of_le (Nat.div_le_div_right (Nat.le_of_lt hnL)) + · intro t _ + rfl + +lemma progression_analysis {I : Type*} [Fintype I] [DecidableEq I] + (hp : Pairwise fun i j => (p i).Coprime (p j)) + (b : I → ResidueSpace p) (hinj : Function.Injective b) (Q : ℕ) (hQ : 0 < Q) + (hb : ∀ i, supportDenominator p (b i) ≤ Q) + (q : ℕ) (hq : 0 < q) (hcop : ∀ i, q.Coprime (supportDenominator p (b i))) + (L a : ℕ) (ha : a < q) (f : ℕ → ℂ) (M : ℝ) (hM : 0 ≤ M) + (hf : ∀ n if a+q*t.val pow_le_pow_left₀ (norm_nonneg _) (hg t) 2 + _ = _ := by simp + have hh := arithmetic_phase_analysis p hp b hinj Q hQ hb q hcop K g + have he i : (∑ n∈range L, if n%q=a then f n*expPhase (-(n : ℝ)*frequencyAngle p (b i)) else 0)= + expPhase (-(a : ℝ)*frequencyAngle p (b i))* + ∑t : Fin K, g t*expPhase (-(t : ℝ)*(q*frequencyAngle p (b i))) := by + rw [sum_residue_progression _ L q a hq ha, mul_sum] + dsimp only [g] + rw [Fin.sum_univ_eq_sum_range (fun t : ℕ => expPhase (-(a : ℝ)*frequencyAngle p (b i))* + ((if a+q*t (p i).Coprime (p j)) + (b : I → ResidueSpace p) (hinj : Function.Injective b) (Q : ℕ) (hQ : 0 < Q) + (hb : ∀i, supportDenominator p (b i) ≤ Q) + (q : ℕ) (hq : 0 < q) (hcop : ∀i, q.Coprime (supportDenominator p (b i))) + (L : ℕ) (hL : 0 < L) (hsmall : 2*(q : ℝ) ≤ L) + (hsmall' : (q : ℝ)*Q^4 ≤ L) (a : ℕ) (ha : a (n : ZMod (p j))) : ℂ) + +omit [∀j, NeZero (p j)] in +lemma gateCoefficient_expand [DecidableEq J] (L : ℕ) (f : ℕ → ℂ) + (B : Finset J) (z a : ResidueSpace p) : + gateCoefficient p L f B z a= + ∑S∈B.powerset, (-1 : ℂ)^(B\S).card* + (((∏j∈S, p j : ℕ) : ℂ)/L)* + (∑n∈range L, if ∀j∈S, (n : ZMod (p j))=z j then + f n*expPhase (-(n : ℝ)*frequencyAngle p a) else 0) := by + classical + unfold gateCoefficient + simp_rw [exactGate_expand, mul_sum] + rw [sum_comm] + apply sum_congr rfl; intro S _ + apply sum_congr rfl; intro n _ + split_ifs + · simp only [mul_one]; ring + · simp only [mul_zero] + +lemma gateCoefficient_bound [DecidableEq J] {I : Type*} [Fintype I] [DecidableEq I] + (hp : Pairwise fun i j => (p i).Coprime (p j)) + (a : I → ResidueSpace p) (hinj : Function.Injective a) (Q : ℕ) (hQ : 0 < Q) + (ha : ∀i, supportDenominator p (a i) ≤ Q) + (B : Finset J) (hB : ∏j∈B, p j ≤ Q) + (hdis : ∀i, Disjoint B (primeSupport p (a i))) (z : ResidueSpace p) + (L : ℕ) (hL : 0 < L) (hsmall : 2*(Q : ℝ) ≤ L) + (hsmall' : (Q : ℝ)^5 ≤ L) (f : ℕ → ℂ) (M : ℝ) (hM : 0 ≤ M) + (hf : ∀n (((∏j∈S, p j : ℕ) : ℂ)/L)* + ∑n∈range L, if ∀j∈S, (n : ZMod (p j))=z j then + f n*expPhase (-(n : ℝ)*frequencyAngle p (a i)) else 0 + let sgn := fun S : Finset J => (-1 : ℂ)^(B\S).card + have hv S (hS : S∈B.powerset) : (∑i, ‖v S i‖^2) ≤ (2*M)^2 := by + have hSB := mem_powerset.mp hS + have hq : 0 < ∏j∈S, p j := prod_pos fun j _ => Nat.pos_of_ne_zero (NeZero.ne (p j)) + have hqB : 0 < ∏j∈B, p j := prod_pos fun j _ => Nat.pos_of_ne_zero (NeZero.ne (p j)) + have hqQ : ∏j∈S, p j ≤ Q := (Nat.le_of_dvd hqB (prod_dvd_prod_of_subset S B p hSB)).trans hB + have hqR : ((∏j∈S, p j : ℕ) : ℝ) ≤ Q := Nat.cast_le.mpr hqQ + obtain ⟨b,hb,he⟩ := residue_crt p hp S z + have hcp i : (∏j∈S,p j).Coprime (supportDenominator p (a i)) := + support_coprime p hp S (a i) ((hdis i).mono_left hSB) + have h := progression_normalized_bound p hp a hinj Q hQ ha (∏j∈S,p j) hq hcp L hL + (by linarith) (by nlinarith [mul_le_mul_of_nonneg_right hqR (pow_nonneg (Nat.cast_nonneg Q) 4)]) + b hb f M hM hf + dsimp only [v] + simp only [he] + exact h.trans_eq (by ring) + have hsgn S (_hS : S∈B.powerset) : ‖sgn S‖ ≤ 1 := by simp [sgn] + have hh := vector_signed_sum_bound B.powerset v sgn (2*M) (by positivity) hsgn hv + have he i : gateCoefficient p L f B z (a i)=∑S∈B.powerset, sgn S*v S i := by + rw [gateCoefficient_expand] + apply sum_congr rfl; intro S _ + dsimp only [sgn,v] + ring + simp only [he] + apply hh.trans_eq + rw [card_powerset, Nat.cast_pow, Nat.cast_ofNat] + rw [mul_pow, mul_pow, ← pow_mul, Nat.mul_comm B.card 2, pow_mul] + ring + +noncomputable def coordinateFreeze [DecidableEq J] (W : Finset J) + (z x : ResidueSpace p) : ResidueSpace p := fun j => if j∈W then z j else x j + +omit [Fintype J] [∀j, NeZero (p j)] in +lemma exactGate_freeze [DecidableEq J] (U W : Finset J) (z x : ResidueSpace p) : + exactGate p U (coordinateFreeze p W z x)= + exactGate p (U∩W) z*exactGate p (U\W) x := by + classical + have he : U=(U∩W)∪(U\W) := by rw [union_comm, sdiff_union_inter] + conv_lhs => rw [he] + rw [exactGate, prod_union (disjoint_sdiff_inter U W).symm] + congr 1 + · apply prod_congr rfl; intro j hj + simp only [coordinateFreeze, (mem_inter.mp hj).2, ite_true] + · apply prod_congr rfl; intro j hj + simp only [coordinateFreeze, (mem_sdiff.mp hj).2, ite_false] + +omit [Fintype J] [∀j, NeZero (p j)] in +lemma coordinateFreeze_sub [DecidableEq J] (W : Finset J) (z x t : ResidueSpace p) : + coordinateFreeze p W z x-t=coordinateFreeze p W (z-t) (x-t) := by + ext j + by_cases hj : j∈W <;> simp [coordinateFreeze, hj] + +noncomputable def liftPiece [DecidableEq J] (L : ℕ) (f : ℕ → ℝ) + (U : Finset J) (z : ResidueSpace p) : ℝ := + (L : ℝ)⁻¹*∑n∈range L, f n*exactGate p U (z-fun j => (n : ZMod (p j))) + +lemma liftPiece_freeze_fourier [DecidableEq J] (L : ℕ) (f : ℕ → ℝ) + (U W : Finset J) (z x : ResidueSpace p) : + (liftPiece p L f U (coordinateFreeze p W z x) : ℂ)= + fourierPolynomial p (fun a => if primeSupport p a=U\W then + gateCoefficient p L (fun n => (f n : ℂ)) (U∩W) z a else 0) x := by + classical + have he (n : ℕ) : (exactGate p U (coordinateFreeze p W z x-fun j => (n : ZMod (p j))) : ℂ)= + (exactGate p (U∩W) (z-fun j => (n : ZMod (p j))) : ℂ)* + ∑a∈univ.filter (fun a => primeSupport p a=U\W), + prodChar p a x*conj (expPhase ((n : ℝ)*frequencyAngle p a)) := by + rw [coordinateFreeze_sub, exactGate_freeze, Complex.ofReal_mul, + exactGate_fourier p (U\W)] + simp only [prodChar_sub_right, prodChar_nat_diagonal] + simp only [liftPiece, Complex.ofReal_mul, Complex.ofReal_inv, Complex.ofReal_natCast, + Complex.ofReal_sum, he] + simp only [fourierPolynomial, gateCoefficient, ite_mul, zero_mul] + rw [← sum_filter] + simp_rw [mul_sum] + rw [sum_comm] + apply sum_congr rfl; intro a _ + rw [sum_mul] + apply sum_congr rfl; intro n _ + rw [show expPhase (-(n : ℝ)*frequencyAngle p a)= + conj (expPhase ((n : ℝ)*frequencyAngle p a)) by rw [neg_mul, expPhase_neg]] + ring + +lemma liftPiece_conditional_parseval [DecidableEq J] (L : ℕ) (f : ℕ → ℝ) + (U W : Finset J) (z : ResidueSpace p) : + (𝔼 x, liftPiece p L f U (coordinateFreeze p W z x)^2)= + ∑a∈univ.filter (fun a => primeSupport p a=U\W), + ‖gateCoefficient p L (fun n => (f n : ℂ)) (U∩W) z a‖^2 := by + classical + have hh := fourierPolynomial_parseval p (fun a => if primeSupport p a=U\W then + gateCoefficient p L (fun n => (f n : ℂ)) (U∩W) z a else 0) + simp_rw [← liftPiece_freeze_fourier p L f U W z, Complex.norm_real, Real.norm_eq_abs, + sq_abs] at hh + rw [sum_filter] + convert hh using 1 + apply sum_congr rfl + intro a _ + split_ifs <;> simp + +lemma liftPiece_fixed_intersection_bound [DecidableEq J] + (hp : Pairwise fun i j => (p i).Coprime (p j)) + (F : Finset (Finset J)) (W B : Finset J) + (hF : ∀U∈F, U∩W=B) (Q : ℕ) (hQ : 0 < Q) + (hden : ∀U∈F, ∏j∈U, p j ≤ Q) (z : ResidueSpace p) + (L : ℕ) (hL : 0 < L) (hsmall : 2*(Q : ℝ) ≤ L) + (hsmall' : (Q : ℝ)^5 ≤ L) (f : ℕ → ℝ) (M : ℝ) (hM : 0 ≤ M) + (hf : ∀n Nat.zero_le _) + (fun j _ _ => Nat.pos_of_ne_zero (NeZero.ne (p j)))).trans (hden U₀ hU₀) + let T := fun U : Finset J => univ.filter (fun a : ResidueSpace p => primeSupport p a=U\W) + let Ω := F.biUnion T + have memO (a : Ω) : ∃U∈F, primeSupport p a.val=U\W := by + obtain ⟨U,hU,ha⟩ := mem_biUnion.mp a.property + exact ⟨U,hU,(mem_filter.mp ha).2⟩ + have ha (a : Ω) : supportDenominator p a.val ≤ Q := by + obtain ⟨U,hU,he⟩ := memO a + unfold supportDenominator + rw [he] + exact (prod_le_prod_of_subset_of_one_le₀ sdiff_subset (fun _ _ => Nat.zero_le _) + (fun j _ _ => Nat.pos_of_ne_zero (NeZero.ne (p j)))).trans (hden U hU) + have hdis (a : Ω) : Disjoint B (primeSupport p a.val) := by + obtain ⟨U,hU,he⟩ := memO a + rw [← hF U hU, he] + exact (disjoint_sdiff_inter U W).symm + have hpair : (↑F : Set (Finset J)).PairwiseDisjoint T := by + intro U hU V hV hUV + apply disjoint_left.mpr + intro a ha hb + have hUV' : U\W=V\W := (mem_filter.mp ha).2.symm.trans (mem_filter.mp hb).2 + apply hUV + calc + U = (U\W)∪(U∩W) := (sdiff_union_inter U W).symm + _ = (V\W)∪(V∩W) := by rw [hUV', hF U hU, hF V hV] + _ = V := sdiff_union_inter V W + have hh := gateCoefficient_bound p hp (fun a : Ω => a.val) Subtype.val_injective Q hQ ha + B hB hdis z L hL hsmall hsmall' (fun n => (f n : ℂ)) M hM + (fun n hn => by simpa only [Complex.norm_real, Real.norm_eq_abs] using hf n hn) + rw [sum_coe_sort Ω (fun a => ‖gateCoefficient p L (fun n => (f n : ℂ)) B z a‖^2)] at hh + calc + _ = ∑U∈F, ∑a∈T U, ‖gateCoefficient p L (fun n => (f n : ℂ)) B z a‖^2 := by + apply sum_congr rfl; intro U hU + rw [liftPiece_conditional_parseval, hF U hU] + _ = ∑a∈Ω, ‖gateCoefficient p L (fun n => (f n : ℂ)) B z a‖^2 := (sum_biUnion hpair).symm + _ ≤ _ := hh + +lemma liftPiece_conditional_square_sum [DecidableEq J] + (hp : Pairwise fun i j => (p i).Coprime (p j)) + (F : Finset (Finset J)) (Q : ℕ) (hQ : 0 < Q) + (hden : ∀U∈F, ∏j∈U, p j ≤ Q) + (L : ℕ) (hL : 0 < L) (hsmall : 2*(Q : ℝ) ≤ L) + (hsmall' : (Q : ℝ)^5 ≤ L) (f : ℕ → ℝ) (M : ℝ) (hM : 0 ≤ M) + (hf : ∀n mem_powerset.mpr inter_subset_right + rw [← sum_fiberwise_of_maps_to hmap] + calc + _ ≤ ∑B∈W.powerset, 4*M^2*4^B.card := by + apply sum_le_sum; intro B _ + exact liftPiece_fixed_intersection_bound p hp (F.filter (fun U => U∩W=B)) W B + (fun _ hU => (mem_filter.mp hU).2) Q hQ + (fun U hU => hden U (mem_filter.mp hU).1) z L hL hsmall hsmall' f M hM hf + _ = _ := by + rw [← mul_sum] + congr 1 + simpa only [one_pow, mul_one, show (4:ℝ)+1=5 by norm_num] using + sum_pow_mul_eq_add_pow (4:ℝ) 1 W + +omit [Fintype J] in +lemma residueGate_expect (j : J) (c : ZMod (p j)) : + (𝔼 t : ZMod (p j), residueGate (p j) (t-c))=0 := by + classical + have he (t : ZMod (p j)) : residueGate (p j) (t-c)= + (if t=c then (p j : ℝ) else 0)-1 := by simp [residueGate, sub_eq_zero] + simp only [he, expect_eq_sum_div_card] + simp [ZMod.card] + +omit [Fintype J] in +lemma exactGate_update_mean [DecidableEq J] (U : Finset J) (j : J) (hj : j∈U) + (x c : ResidueSpace p) : + (𝔼 t : ZMod (p j), exactGate p U (Function.update x j t-c))=0 := by + classical + have he (t : ZMod (p j)) : exactGate p U (Function.update x j t-c)= + residueGate (p j) (t-c j)*exactGate p (U.erase j) (x-c) := by + rw [exactGate, ← mul_prod_erase U (fun a => residueGate (p a) ((Function.update x j t-c) a)) hj] + simp only [Pi.sub_apply, Function.update_self] + congr 1 + apply prod_congr rfl + intro a ha + rw [Function.update_of_ne (mem_erase.mp ha).1] + rfl + simp only [he, ← expect_mul, residueGate_expect, zero_mul] + +omit [Fintype J] [∀j, NeZero (p j)] in +lemma exactGate_update_outside [DecidableEq J] (U : Finset J) (j : J) (hj : j∉U) + (x c : ResidueSpace p) (t : ZMod (p j)) : + exactGate p U (Function.update x j t-c)=exactGate p U (x-c) := by + apply prod_congr rfl + intro a ha + have haj : a≠j := fun h => hj (h ▸ ha) + simp only [Pi.sub_apply, Function.update_of_ne haj] + +omit [Fintype J] in +lemma liftPiece_exactSupport [DecidableEq J] (L : ℕ) (f : ℕ → ℝ) (U : Finset J) : + ExactSupport U (liftPiece p L f U) := by + constructor + · intro j hj x + simp only [liftPiece, ← mul_expect, expect_sum_comm, exactGate_update_mean p U j hj, + mul_zero, sum_const_zero] + · intro j hj x t + simp only [liftPiece, exactGate_update_outside p U j hj] + +lemma liftPiece_moment [DecidableEq J] + (hp : Pairwise fun i j => (p i).Coprime (p j)) + (F : Finset (Finset J)) (Q : ℕ) (hQ : 0 < Q) + (hden : ∀U∈F, ∏j∈U, p j ≤ Q) + (L : ℕ) (hL : 0 < L) (hsmall : 2*(Q : ℝ) ≤ L) + (hsmall' : (Q : ℝ)^5 ≤ L) (f : ℕ → ℝ) (M : ℝ) (hM : 0 ≤ M) + (hf : ∀n liftPiece_exactSupport p L f U) + k hk r hr).trans + apply mul_le_mul_of_nonneg_left _ (by positivity) + have he x : (∑U∈F, liftPiece p L f U x^2) = ∑U : F, liftPiece p L f U.val x^2 := + (sum_coe_sort F _).symm + simp only [he] + apply square_moment_bound (fun U : F => U.val) (fun U => liftPiece p L f U.val) + (fun U x y hxy => exactSupport_congr U.val _ (liftPiece_exactSupport p L f U.val) x y hxy) + k (fun U => hk U.val U.property) (4*M^2) 5 (by positivity) (by norm_num) + intro W x + have h := liftPiece_conditional_square_sum p hp F Q hQ hden L hL hsmall hsmall' f M hM hf W x + have hh (y : ResidueSpace p) : coordinateFreeze p W x y = + hybrid (fun j => decide (j∈W)) x y := by + ext j + simp [coordinateFreeze, hybrid] + simp_rw [hh] at h + have hsum (y : ResidueSpace p) : + (∑U∈F, liftPiece p L f U (hybrid (fun j => decide (j∈W)) x y)^2)= + ∑U : F, liftPiece p L f U.val (hybrid (fun j => decide (j∈W)) x y)^2 := + (sum_coe_sort F _).symm + simp_rw [hsum] at h + exact h + +lemma liftPiece_moment_small_loss [DecidableEq J] + (hp : Pairwise fun i j => (p i).Coprime (p j)) + (F : Finset (Finset J)) (Q : ℕ) (hQ : 0 < Q) + (hden : ∀U∈F, ∏j∈U, p j ≤ Q) + (L : ℕ) (hL : 0 < L) (hsmall : 2*(Q : ℝ) ≤ L) + (hsmall' : (Q : ℝ)^5 ≤ L) (f : ℕ → ℝ) (M : ℝ) (hM : 0 ≤ M) + (hf : ∀n le_sup hU + have hb : ((4:ℝ)*2^(2*r)*5^r)^k ≤ (Q : ℝ)^(2*ε) := by + rw [show k=U.card from hk] + calc + _ = ∏j∈U, ((4:ℝ)*2^(2*r)*5^r) := by simp + _ ≤ ∏j∈U, (p j : ℝ)^(2*ε) := by + apply Finset.prod_le_prod₀ + · intro j _; positivity + · intro j _; exact hprime j + _ = (∏j∈U, (p j : ℝ))^(2*ε) := by + rw [Real.finsetProd_rpow] + intro j _; positivity + _ ≤ (Q : ℝ)^(2*ε) := by + apply Real.rpow_le_rpow (by positivity) _ (by positivity) + exact_mod_cast hden U hU + have hh := liftPiece_moment p hp F Q hQ hden L hL hsmall hsmall' f M hM hf k hcard r hr + calc + _ ≤ (((4:ℝ)*2^(2*r))^k)^r*(4*M^2*5^(r*k))^r := hh + _ = (2*M)^(2*r)*(((4:ℝ)*2^(2*r)*5^r)^k)^r := by + rw [show (4:ℝ)=2^2 by norm_num] + simp only [mul_pow, ← pow_mul, Nat.mul_assoc] + ring + _ ≤ (2*M)^(2*r)*((Q : ℝ)^(2*ε))^r := + mul_le_mul_of_nonneg_left (pow_le_pow_left₀ (by positivity) hb r) (by positivity) + _ = _ := by + conv_rhs => rw [mul_pow] + congr 1 + rw [← Real.rpow_natCast ((Q : ℝ)^(2*ε)) r, + ← Real.rpow_mul (by positivity : 0 ≤ (Q : ℝ)), + ← Real.rpow_natCast ((Q : ℝ)^ε) (2*r), + ← Real.rpow_mul (by positivity : 0 ≤ (Q : ℝ))] + congr 1 + push_cast + ring + · simp only [not_nonempty_iff_eq_empty.mp hF, sum_empty, zero_pow (by omega : 2*r≠0), + Fintype.expect_const] + positivity + +lemma exponential_support_bound {I : Type*} [DecidableEq I] + (U : Finset I) (p : I → ℕ) (hinj : Set.InjOn p (↑U : Set I)) + (hp : ∀i∈U, 1≤p i) (A : ℝ) (hA : 1≤A) (ε : ℝ) (hε : 0≤ε) + (T : ℕ) (hT : ∀n : ℕ, T≤n → A≤(n : ℝ)^ε) : + A^U.card ≤ A^T * (∏i∈U, (p i : ℝ))^ε := by + classical + let B := U.filter (fun i => p i (p i).Coprime (p j)) (hinj : Function.Injective p) + (F : Finset (Finset J)) (Q : ℕ) (hQ : 0 < Q) + (hden : ∀U∈F, ∏j∈U, p j ≤ Q) + (L : ℕ) (hL : 0 < L) (hsmall : 2*(Q : ℝ) ≤ L) + (hsmall' : (Q : ℝ)^5 ≤ L) (f : ℕ → ℝ) (M : ℝ) (hM : 0 ≤ M) + (hf : ∀n le_sup hU + have hb : A^k ≤ A^T*(Q : ℝ)^(2*ε) := by + rw [show k=U.card from hk] + apply (exponential_support_bound U p hinj.injOn (fun i _ => Nat.one_le_iff_ne_zero.mpr (NeZero.ne (p i))) + A hA (2*ε) (by positivity) T hT).trans + apply mul_le_mul_of_nonneg_left _ (by positivity) + apply Real.rpow_le_rpow (by positivity) _ (by positivity) + exact_mod_cast hden U hU + have hh := liftPiece_moment p hp F Q hQ hden L hL hsmall hsmall' f M hM hf k hcard r hr + have hc : A^T ≤ (A^T)^2 := by nlinarith [one_le_pow₀ hA (n:=T)] + calc + _ ≤ (((4:ℝ)*2^(2*r))^k)^r*(4*M^2*5^(r*k))^r := hh + _ = (2*M)^(2*r)*(A^k)^r := by + dsimp [A] + rw [show (4:ℝ)=2^2 by norm_num] + simp only [mul_pow, ← pow_mul, Nat.mul_assoc] + ring + _ ≤ (2*M)^(2*r)*((A^T)^2*(Q : ℝ)^(2*ε))^r := by + apply mul_le_mul_of_nonneg_left _ (by positivity) + apply pow_le_pow_left₀ (by positivity) + exact hb.trans (mul_le_mul_of_nonneg_right hc (by positivity)) + _ = _ := by + change _=(2*M*A^T*(Q : ℝ)^ε)^(2*r) + have hqr : (Q : ℝ)^(2*ε)=((Q : ℝ)^ε)^2 := by + rw [←Real.rpow_natCast ((Q : ℝ)^ε) 2, + ←Real.rpow_mul (by positivity : 0≤(Q : ℝ))] + congr 1 + norm_num + ring + rw [hqr] + simp only [mul_pow, ←pow_mul] + ring + · simp only [not_nonempty_iff_eq_empty.mp hF,sum_empty,zero_pow (by omega : 2*r≠0), + Fintype.expect_const] + positivity + +lemma liftPiece_moment_subpower [DecidableEq J] + (r : ℕ) (hr : 1≤r) (ε : ℝ) (hε : 0<ε) : + ∃ C : ℝ, 0 (p i).Coprime (p j)) + (_hinj : Function.Injective p) (F : Finset (Finset J)) (Q : ℕ), 0 x (tupleHalfProjection S b hb α β v, j v)) * + F (fun v => y (tupleHalfProjection S b hb α β v, k v)) := by + classical + unfold tupleCutForm tupleComponent + rw [expect_two_halves (tupleEntryHalfEquiv S b hb hne) (halfSumEquiv b hne)] + apply expect_congr rfl + intro x _ + apply expect_congr rfl + intro y _ + apply expect_congr rfl + intro j _ + apply expect_congr rfl + intro k _ + rw [tupleValidity_half S b hb hne, tupleWeight_half S b hb hne] + have hh := tupleOutput_half S b hb hne x y j k + have hl : (fun v : CutHalf b α β => tupleOutput S + ((Sum.elim x y) ∘ (tupleEntryHalfEquiv S b hb hne).symm) + ((Sum.elim j k) ∘ (halfSumEquiv b hne).symm) v.1) = + fun v => x (tupleHalfProjection S b hb α β v, j v) := by + funext v + exact congrFun hh (Sum.inl v) + have hr : (fun v : CutHalf b α β => tupleOutput S + ((Sum.elim x y) ∘ (tupleEntryHalfEquiv S b hb hne).symm) + ((Sum.elim j k) ∘ (halfSumEquiv b hne).symm) (reflect b α β v.1)) = + fun v => y (tupleHalfProjection S b hb α β v, k v) := by + funext v + exact congrFun hh (Sum.inr v) + dsimp only + rw [hl, hr] + ring + +lemma weighted_average_sq_le {J : Type*} [Fintype J] [Nonempty J] + (W f : J → ℝ) {B : ℝ} (hW : ∀ j, 0 ≤ W j ∧ W j ≤ B) : + (𝔼 j : J, W j * f j)^2 ≤ B^2 * (𝔼 j : J, (f j)^2) := by + have hc := expect_mul_sq_le_sq_mul_sq univ W f + have hw : (𝔼 j : J, (W j)^2) ≤ B^2 := + expect_le univ_nonempty (fun j _ => pow_le_pow_left₀ (hW j).1 (hW j).2 _) + exact hc.trans (mul_le_mul_of_nonneg_right hw (expect_nonneg fun _ _ => sq_nonneg _)) + +lemma list_factorized_quadratic {I J L : Type*} [Fintype I] [Fintype J] [Fintype L] + [DecidableEq I] [DecidableEq L] [Nonempty J] {p : ℕ} [Fact p.Prime] + (E : Finset (I × I)) (dir : I → I → Bool) + (K : (I → ZMod p) → ℝ) (W : (L → J) → ℝ) + (f : (I → ZMod p) → (L → J) → ℝ) : + (𝔼 x : I → ZMod p, 𝔼 y : I → ZMod p, 𝔼 j : L → J, 𝔼 k : L → J, + K x * K y * listKernel E dir x y * (W j * W k) * f x j * f y k) = + 𝔼 x : I → ZMod p, 𝔼 y : I → ZMod p, + (K x * (𝔼 j : L → J, W j * f x j)) * listKernel E dir x y * + (K y * (𝔼 k : L → J, W k * f y k)) := by + apply expect_congr rfl + intro x _ + apply expect_congr rfl + intro y _ + conv_lhs => arg 2; ext j; arg 2; ext k; rw [show + K x * K y * listKernel E dir x y * (W j * W k) * f x j * f y k = + (K x * listKernel E dir x y * K y) * ((W j * f x j) * (W k * f y k)) by ring] + simp only [← mul_expect, ← expect_mul] + ring + +lemma list_factorized_lower {I J L : Type*} [Fintype I] [Fintype J] [Fintype L] + [DecidableEq I] [DecidableEq L] [Nonempty J] {p : ℕ} [Fact p.Prime] (hp : p ≠ 2) + (E : Finset (I × I)) (dir : I → I → Bool) + (K : (I → ZMod p) → ℝ) (hK : ∀ x, 0 ≤ K x ∧ (K x)^2 = K x) + (W : (L → J) → ℝ) {B : ℝ} (hW : ∀ j, 0 ≤ W j ∧ W j ≤ B) + (f : (I → ZMod p) → (L → J) → ℝ) : + -(32 * E.card : ℝ) ^ ((1 : ℝ) / 4) * (p : ℝ) ^ (-(1 : ℝ) / 8) * B^2 * + (𝔼 x : I → ZMod p, 𝔼 j : L → J, K x * (f x j)^2) ≤ + 𝔼 x : I → ZMod p, 𝔼 y : I → ZMod p, 𝔼 j : L → J, 𝔼 k : L → J, + K x * K y * listKernel E dir x y * (W j * W k) * f x j * f y k := by + rw [list_factorized_quadratic] + let G (x : I → ZMod p) := K x * (𝔼 j : L → J, W j * f x j) + have h := list_quadratic_lower hp E dir G + have hg : (𝔼 x : I → ZMod p, (G x)^2) ≤ + B^2 * (𝔼 x : I → ZMod p, 𝔼 j : L → J, K x * (f x j)^2) := by + rw [mul_expect] + apply expect_le_expect + intro x _ + dsimp [G] + rw [mul_pow, (hK x).2, ← mul_expect] + calc + _ ≤ K x * (B^2 * (𝔼 j : L → J, (f x j)^2)) := + mul_le_mul_of_nonneg_left (weighted_average_sq_le W (f x) hW) (hK x).1 + _ = _ := by ring + have hc : 0 ≤ (32 * E.card : ℝ) ^ ((1 : ℝ) / 4) * (p : ℝ) ^ (-(1 : ℝ) / 8) := by positivity + have hm := mul_le_mul_of_nonpos_left hg (neg_nonpos.mpr hc) + change _ ≤ 𝔼 x : I → ZMod p, 𝔼 y : I → ZMod p, G x * listKernel E dir x y * G y + calc + _ = -((32 * E.card : ℝ) ^ ((1 : ℝ) / 4) * (p : ℝ) ^ (-(1 : ℝ) / 8)) * + (B^2 * (𝔼 x : I → ZMod p, 𝔼 j : L → J, K x * (f x j)^2)) := by ring + _ ≤ -((32 * E.card : ℝ) ^ ((1 : ℝ) / 4) * (p : ℝ) ^ (-(1 : ℝ) / 8)) * + (𝔼 x : I → ZMod p, (G x)^2) := hm + _ ≤ _ := by simpa only [neg_mul] using h + +noncomputable def tupleUnmarkedMoment {p : ℕ} [Fact p.Prime] + (S : Finset (Fin tupleBlocks)) (b : Fin tupleBlocks) (hb : b ∉ S) + {α β : Fin tupleH} (hne : α ≠ β) (F : (CutHalf b α β → ZMod p) → ℝ) : ℝ := + 𝔼 x : TupleHalfEntry S b hb α β → ZMod p, + 𝔼 j : CutHalf b α β → TupleListIndex S, + graphValidity (cutInternalEdges (tupleUnmarkedGraph S b hb hne)) x * + (F (fun v => x (tupleHalfProjection S b hb α β v, j v))) ^ 2 + +lemma tupleUnmarkedMoment_nonneg {p : ℕ} [Fact p.Prime] + (S : Finset (Fin tupleBlocks)) (b : Fin tupleBlocks) (hb : b ∉ S) + {α β : Fin tupleH} (hne : α ≠ β) (F : (CutHalf b α β → ZMod p) → ℝ) : + 0 ≤ tupleUnmarkedMoment S b hb hne F := + expect_nonneg fun _ _ => expect_nonneg fun _ _ => + mul_nonneg (graphValidity_nonneg _ _) (sq_nonneg _) + +lemma tuple_unmarked_error_exact {p : ℕ} [Fact p.Prime] (hp : p ≠ 2) + (S : Finset (Fin tupleBlocks)) (hS : S.card ≤ tupleT + 1) + (b : Fin tupleBlocks) (hb : b ∉ S) {α β : Fin tupleH} (hne : α ≠ β) + (F : (CutHalf b α β → ZMod p) → ℝ) : + -(32 * (cutCrossEdges (tupleUnmarkedGraph S b hb hne)).card : ℝ) ^ ((1 : ℝ) / 4) * + (p : ℝ) ^ (-(1 : ℝ) / 8) * tupleWeightBound ^ 2 * + tupleUnmarkedMoment S b hb hne F ≤ tupleCutForm S b α β F := by + rw [tupleCutForm_unmarked_factor S b hb hne] + exact list_factorized_lower hp _ _ _ (fun x => + ⟨graphValidity_nonneg _ x, graphValidity_sq _ x⟩) + (tupleHalfWeight S b α β) (fun j => + ⟨(tupleHalfWeight_one_le S b α β j).trans' (by norm_num), + tupleHalfWeight_le S hS b hb hne j⟩) _ + +lemma card_tupleHalfEntry_le (S : Finset (Fin tupleBlocks)) + (b : Fin tupleBlocks) (hb : b ∉ S) (α β : Fin tupleH) : + Fintype.card (TupleHalfEntry S b hb α β) ≤ Fintype.card TupleVertex := by + classical + have hsub : Fintype.card (TupleHalfAddress S b hb α β) ≤ + (Nat.factorial tupleH) ^ (tupleBlocks - S.card) := by + rw [← card_tupleAddress S] + exact Fintype.card_subtype_le _ + have hS : S.card ≤ tupleBlocks := by + simpa using (card_le_card (subset_univ S)) + have hr : tupleR ≤ Nat.factorial tupleH := Nat.div_le_self _ _ + rw [card_tupleVertex] + rw [show Fintype.card (TupleHalfEntry S b hb α β) = + Fintype.card (TupleHalfAddress S b hb α β) * (tupleR ^ S.card) by + simp only [TupleHalfEntry, Fintype.card_prod, TupleListIndex, Fintype.card_fin]] + calc + _ ≤ (Nat.factorial tupleH) ^ (tupleBlocks - S.card) * + (Nat.factorial tupleH) ^ S.card := Nat.mul_le_mul hsub (Nat.pow_le_pow_left hr _) + _ = _ := by rw [← pow_add, Nat.sub_add_cancel hS] + +lemma card_relation_le_sq {I : Type*} [Fintype I] (E : Finset (I × I)) + {d : ℕ} (hd : Fintype.card I ≤ d) : E.card ≤ d^2 := by + calc + _ ≤ Fintype.card (I × I) := card_le_univ _ + _ = (Fintype.card I)^2 := by rw [Fintype.card_prod, sq] + _ ≤ _ := Nat.pow_le_pow_left hd _ + +lemma card_tupleCrossEdges_le (S : Finset (Fin tupleBlocks)) + (b : Fin tupleBlocks) (hb : b ∉ S) {α β : Fin tupleH} (hne : α ≠ β) : + (cutCrossEdges (tupleUnmarkedGraph S b hb hne)).card ≤ (Fintype.card TupleVertex)^2 := + card_relation_le_sq _ (card_tupleHalfEntry_le S b hb α β) + +noncomputable def tupleUnmarkedConstant : ℝ := + (32 * (Fintype.card TupleVertex : ℝ)^2) ^ ((1 : ℝ) / 4) * tupleWeightBound^2 + +lemma tuple_unmarked_error {p : ℕ} [Fact p.Prime] (hp : p ≠ 2) + (S : Finset (Fin tupleBlocks)) (hS : S.card ≤ tupleT + 1) + (b : Fin tupleBlocks) (hb : b ∉ S) {α β : Fin tupleH} (hne : α ≠ β) + (F : (CutHalf b α β → ZMod p) → ℝ) : + -tupleUnmarkedConstant * (p : ℝ)^(-(1 : ℝ)/8) * + tupleUnmarkedMoment S b hb hne F ≤ tupleCutForm S b α β F := by + have hc : (32 * ((cutCrossEdges (tupleUnmarkedGraph S b hb hne)).card : ℝ)) ^ ((1:ℝ)/4) ≤ + (32 * (Fintype.card TupleVertex : ℝ)^2) ^ ((1:ℝ)/4) := by + apply Real.rpow_le_rpow (by positivity) _ (by norm_num) + have ht : ((cutCrossEdges (tupleUnmarkedGraph S b hb hne)).card : ℝ) ≤ + (Fintype.card TupleVertex : ℝ)^2 := by + exact_mod_cast card_tupleCrossEdges_le S b hb hne + linarith + have hm : 0 ≤ (p : ℝ)^(-(1:ℝ)/8) * tupleWeightBound^2 * + tupleUnmarkedMoment S b hb hne F := + mul_nonneg (by positivity) (tupleUnmarkedMoment_nonneg S b hb hne F) + have ht := mul_le_mul_of_nonneg_right hc hm + have he := tuple_unmarked_error_exact hp S hS b hb hne F + dsimp [tupleUnmarkedConstant] + nlinarith + +lemma tupleUnmarkedGraph_terminal (S : Finset (Fin tupleBlocks)) + (hs : S.card = tupleT + 1) (b : Fin tupleBlocks) (hb : b ∉ S) + {α β : Fin tupleH} (hne : α ≠ β) : + tupleUnmarkedGraph S b hb hne = ∅ := by + have ht : ¬ S.card ≤ tupleT := by omega + simp [tupleUnmarkedGraph, graphPullback, tupleListEdges, ht] + +lemma tuple_terminal_positive {p : ℕ} [Fact p.Prime] (hp : p ≠ 2) + (S : Finset (Fin tupleBlocks)) (hs : S.card = tupleT + 1) + (b : Fin tupleBlocks) (hb : b ∉ S) {α β : Fin tupleH} (hne : α ≠ β) + (F : (CutHalf b α β → ZMod p) → ℝ) : + 0 ≤ tupleCutForm S b α β F := by + have h := tuple_unmarked_error_exact hp S (by omega) b hb hne F + simpa only [tupleUnmarkedGraph_terminal S hs b hb hne, cutCrossEdges, + notMem_empty, or_self, filter_false, card_empty, Nat.cast_zero, mul_zero, + Real.zero_rpow (by norm_num : (1 : ℝ)/4 ≠ 0), neg_zero, zero_mul] using h + +abbrev TupleCutWord (α β : Fin tupleH) := + {w : Equiv.Perm (Fin tupleH) // w.symm α < w.symm β} + +noncomputable def orderedPermEquiv {h : ℕ} (α β : Fin h) : + {w : Equiv.Perm (Fin h) // w.symm α < w.symm β} ≃ (CutHalf () α β : Type) where + toFun w := ⟨fun _ => w.1, w.2⟩ + invFun w := ⟨w.1 (), w.2⟩ + left_inv _ := rfl + right_inv w := by ext u; cases u; rfl + +lemma card_orderedPerm {h : ℕ} {α β : Fin h} (hne : α ≠ β) : + Fintype.card {w : Equiv.Perm (Fin h) // w.symm α < w.symm β} = Nat.factorial h / 2 := by + have hh := card_cutHalf () hne + rw [← Fintype.card_congr (orderedPermEquiv α β), Fintype.card_unit, pow_one] at hh + omega + +lemma card_tupleCutWord {α β : Fin tupleH} (hne : α ≠ β) : + Fintype.card (TupleCutWord α β) = tupleR := + card_orderedPerm hne + +def tupleMarkAddress (S : Finset (Fin tupleBlocks)) (b : Fin tupleBlocks) + (a : TupleAddress S) : TupleAddress (insert b S) := + fun c => a ⟨c.1, fun hc => c.2 (mem_insert_of_mem hc)⟩ + +def tupleUnmarkAddress (S : Finset (Fin tupleBlocks)) (b : Fin tupleBlocks) + (u : TupleAddress (insert b S)) (w : Equiv.Perm (Fin tupleH)) : TupleAddress S := + fun c => if hc : c.1 = b then w else u ⟨c.1, by simp [hc, c.2]⟩ + +lemma tupleUnmarkAddress_at (S : Finset (Fin tupleBlocks)) + (b : Fin tupleBlocks) (hb : b ∉ S) + (u : TupleAddress (insert b S)) (w : Equiv.Perm (Fin tupleH)) : + tupleUnmarkAddress S b u w ⟨b, hb⟩ = w := by + simp [tupleUnmarkAddress] + +lemma tupleMark_unmark (S : Finset (Fin tupleBlocks)) (b : Fin tupleBlocks) + (u : TupleAddress (insert b S)) (w : Equiv.Perm (Fin tupleH)) : + tupleMarkAddress S b (tupleUnmarkAddress S b u w) = u := by + funext c + have hb : c.1 ≠ b := by intro h; exact c.2 (by simp [h]) + simp [tupleMarkAddress, tupleUnmarkAddress, hb] + +lemma tupleUnmark_mark (S : Finset (Fin tupleBlocks)) (b : Fin tupleBlocks) + (hb : b ∉ S) (a : TupleAddress S) : + tupleUnmarkAddress S b (tupleMarkAddress S b a) (a ⟨b,hb⟩) = a := by + funext c + by_cases hc : c.1 = b + · have he : c = ⟨b,hb⟩ := Subtype.ext hc + subst c + simp [tupleUnmarkAddress] + · simp [tupleUnmarkAddress, tupleMarkAddress, hc] + +noncomputable def tupleHalfAddressEquiv (S : Finset (Fin tupleBlocks)) + (b : Fin tupleBlocks) (hb : b ∉ S) (α β : Fin tupleH) : + TupleHalfAddress S b hb α β ≃ TupleAddress (insert b S) × TupleCutWord α β where + toFun a := (tupleMarkAddress S b a.1, ⟨a.1 ⟨b,hb⟩, a.2⟩) + invFun a := ⟨tupleUnmarkAddress S b a.1 a.2.1, by + change (tupleUnmarkAddress S b a.1 a.2.1 ⟨b,hb⟩).symm α < + (tupleUnmarkAddress S b a.1 a.2.1 ⟨b,hb⟩).symm β + rw [tupleUnmarkAddress_at] + exact a.2.2⟩ + left_inv a := Subtype.ext (tupleUnmark_mark S b hb a.1) + right_inv a := by + apply Prod.ext + · exact tupleMark_unmark S b a.1 a.2.1 + · apply Subtype.ext + exact tupleUnmarkAddress_at S b hb a.1 a.2.1 + +noncomputable def tupleMarkIndexEquiv (S : Finset (Fin tupleBlocks)) + (b : Fin tupleBlocks) (hb : b ∉ S) {α β : Fin tupleH} (hne : α ≠ β) : + TupleListIndex (insert b S) ≃ TupleCutWord α β × TupleListIndex S := + Fintype.equivOfCardEq (by + simp only [TupleListIndex, Fintype.card_fin, Fintype.card_prod, + card_tupleCutWord hne, card_insert_of_notMem hb, pow_succ, mul_comm]) + +noncomputable def tupleRegroupEquiv (S : Finset (Fin tupleBlocks)) + (b : Fin tupleBlocks) (hb : b ∉ S) {α β : Fin tupleH} (hne : α ≠ β) : + TupleHalfEntry S b hb α β ≃ TupleListEntry (insert b S) := + ((Equiv.prodCongr (tupleHalfAddressEquiv S b hb α β) (Equiv.refl _)).trans + (Equiv.prodAssoc _ _ _)).trans + (Equiv.prodCongr (Equiv.refl _) (tupleMarkIndexEquiv S b hb hne).symm) + +lemma expect_ge_single {I : Type*} [Fintype I] (f : I → ℝ) + (hf : ∀ i, 0 ≤ f i) (i : I) : + (Fintype.card I : ℝ)⁻¹ * f i ≤ 𝔼 j : I, f j := by + rw [Fintype.expect_eq_sum_div_card, div_eq_mul_inv] + rw [mul_comm ((Fintype.card I : ℝ)⁻¹)] + exact mul_le_mul_of_nonneg_right (single_le_sum (fun j _ => hf j) (mem_univ i)) + (inv_nonneg.mpr (Nat.cast_nonneg _)) + +lemma expect_prod_function {V W I : Type*} [Fintype V] [Fintype W] [Fintype I] + [DecidableEq V] (f : (V → W × I) → ℝ) : + (𝔼 j : V → W × I, f j) = + 𝔼 w : V → W, 𝔼 i : V → I, f (fun v => (w v, i v)) := by + calc + _ = 𝔼 j : (V → W) × (V → I), f (fun v => (j.1 v,j.2 v)) := + Fintype.expect_equiv (Equiv.arrowProdEquivProdArrow V (fun _ => W) (fun _ => I)) + _ _ (fun _ => rfl) + _ = _ := by rw [← univ_product_univ, expect_product] + +lemma expect_restrict_first {V W I : Type*} [Fintype V] [Fintype W] [Fintype I] + [DecidableEq V] (f : (V → W × I) → ℝ) (hf : ∀ j, 0 ≤ f j) (w : V → W) : + ((Fintype.card W : ℝ) ^ Fintype.card V)⁻¹ * + (𝔼 i : V → I, f (fun v => (w v, i v))) ≤ 𝔼 j : V → W × I, f j := by + rw [expect_prod_function] + simpa only [Fintype.card_fun, Nat.cast_pow] using + expect_ge_single (fun w : V → W => 𝔼 i : V → I, f (fun v => (w v,i v))) + (fun w => expect_nonneg fun i _ => hf _) w + +lemma tupleRegroup_fst (S : Finset (Fin tupleBlocks)) + (b : Fin tupleBlocks) (hb : b ∉ S) {α β : Fin tupleH} (hne : α ≠ β) + (a : TupleHalfEntry S b hb α β) : + (tupleRegroupEquiv S b hb hne a).1 = tupleMarkAddress S b a.1.1 := rfl + +lemma tupleRegroup_snd (S : Finset (Fin tupleBlocks)) + (b : Fin tupleBlocks) (hb : b ∉ S) {α β : Fin tupleH} (hne : α ≠ β) + (a : TupleHalfEntry S b hb α β) : + (tupleMarkIndexEquiv S b hb hne) (tupleRegroupEquiv S b hb hne a).2 = + (⟨a.1.1 ⟨b,hb⟩, a.1.2⟩, a.2) := by + exact (tupleMarkIndexEquiv S b hb hne).apply_symm_apply _ + +def tupleWordOfHalf (b : Fin tupleBlocks) (α β : Fin tupleH) (v : CutHalf b α β) : + TupleCutWord α β := ⟨v.1 b, v.2⟩ + +lemma tupleRegroup_projection (S : Finset (Fin tupleBlocks)) + (b : Fin tupleBlocks) (hb : b ∉ S) {α β : Fin tupleH} (hne : α ≠ β) + (v : CutHalf b α β) (i : TupleListIndex S) : + tupleRegroupEquiv S b hb hne (tupleHalfProjection S b hb α β v, i) = + (tupleProjection (insert b S) v.1, + (tupleMarkIndexEquiv S b hb hne).symm (tupleWordOfHalf b α β v, i)) := by + apply Prod.ext + · rfl + · rfl + +lemma tuple_regroup_edges (S : Finset (Fin tupleBlocks)) (hs : S.card ≤ tupleT) + (b : Fin tupleBlocks) (hb : b ∉ S) {α β : Fin tupleH} (hne : α ≠ β) : + graphPullback (tupleRegroupEquiv S b hb hne) (tupleListEdges (insert b S)) ⊆ + cutInternalEdges (tupleUnmarkedGraph S b hb hne) := by + intro a ha + simp only [graphPullback, mem_filter, mem_univ, true_and] at ha + simp only [cutInternalEdges, mem_filter, mem_univ, true_and, tupleUnmarkedGraph, + graphPullback, tupleEntryHalfEquiv_inl, tupleListEdges, ite_eq_left hs] + unfold tupleListEdges at ha + split_ifs at ha with hnew + · have h := (mem_filter.mp ha).2 + let f : {c : Fin tupleBlocks // c ∉ insert b S} ↪ + {c : Fin tupleBlocks // c ∉ S} := + ⟨fun c => ⟨c.1, fun hc => c.2 (mem_insert_of_mem hc)⟩, + fun c d he => Subtype.ext (congrArg (fun x : {c : Fin tupleBlocks // c ∉ S} => x.val) he)⟩ + exact addressEdge_mono_blocks tupleCycle (tupleT + 1) f a.1.1.1 a.2.1.1 h + · simp at ha + +lemma graphValidity_antitone {I : Type*} {p : ℕ} [Fact p.Prime] + {E E' : Finset (I × I)} (hE : E' ⊆ E) (z : I → ZMod p) : + graphValidity E z ≤ graphValidity E' z := + prod_le_prod_of_subset_of_le_one₀ hE (fun _ _ => squareIndicator_nonneg _) + (fun _ _ _ => squareIndicator_le_one _) + +lemma tuple_regroup_validity {p : ℕ} [Fact p.Prime] + (S : Finset (Fin tupleBlocks)) (hs : S.card ≤ tupleT) + (b : Fin tupleBlocks) (hb : b ∉ S) {α β : Fin tupleH} (hne : α ≠ β) + (Y : TupleListEntry (insert b S) → ZMod p) : + graphValidity (cutInternalEdges (tupleUnmarkedGraph S b hb hne)) + (Y ∘ tupleRegroupEquiv S b hb hne) ≤ tupleValidity (insert b S) Y := by + have h := graphValidity_antitone (tuple_regroup_edges S hs b hb hne) + (Y ∘ tupleRegroupEquiv S b hb hne) + rw [graphValidity_pullback] at h + exact h + +lemma tuple_regroup_moment {p : ℕ} [Fact p.Prime] + (S : Finset (Fin tupleBlocks)) (hs : S.card ≤ tupleT) + (b : Fin tupleBlocks) (hb : b ∉ S) {α β : Fin tupleH} (hne : α ≠ β) + (F : (CutHalf b α β → ZMod p) → ℝ) : + ((tupleR : ℝ)^Fintype.card (CutHalf b α β))⁻¹ * tupleUnmarkedMoment S b hb hne F ≤ + 𝔼 Y : TupleListEntry (insert b S) → ZMod p, + 𝔼 j : CutHalf b α β → TupleListIndex (insert b S), + tupleValidity (insert b S) Y * + (F (fun v => Y (tupleProjection (insert b S) v.1, j v)))^2 := by + unfold tupleUnmarkedMoment + rw [expect_precompose (tupleRegroupEquiv S b hb hne)] + rw [mul_expect] + apply expect_le_expect + intro Y _ + have hV := tuple_regroup_validity S hs b hb hne Y + have hrest := expect_restrict_first + (fun j : CutHalf b α β → TupleCutWord α β × TupleListIndex S => + tupleValidity (insert b S) Y * (F (fun v => + Y (tupleProjection (insert b S) v.1, (tupleMarkIndexEquiv S b hb hne).symm (j v))))^2) + (fun j => mul_nonneg (tupleValidity_nonneg _ _) (sq_nonneg _)) (tupleWordOfHalf b α β) + rw [card_tupleCutWord hne] at hrest + have he : (𝔼 j : CutHalf b α β → TupleListIndex (insert b S), + tupleValidity (insert b S) Y * (F (fun v => Y (tupleProjection (insert b S) v.1,j v)))^2) = + 𝔼 j : CutHalf b α β → TupleCutWord α β × TupleListIndex S, + tupleValidity (insert b S) Y * (F (fun v => + Y (tupleProjection (insert b S) v.1, (tupleMarkIndexEquiv S b hb hne).symm (j v))))^2 := by + apply Fintype.expect_equiv + (Equiv.arrowCongr (Equiv.refl _) (tupleMarkIndexEquiv S b hb hne)) + intro j + simp + rw [he] + refine le_trans ?_ hrest + apply mul_le_mul_of_nonneg_left _ (inv_nonneg.mpr (pow_nonneg (Nat.cast_nonneg _) _)) + apply expect_le_expect + intro j _ + dsimp only [Function.comp_apply] + simp only [tupleRegroup_projection] + exact mul_le_mul_of_nonneg_right hV (sq_nonneg _) + +lemma card_cutHalf_eq_div {B : Type*} [Fintype B] [DecidableEq B] {h : ℕ} + (b : B) {α β : Fin h} (hne : α ≠ β) : + Fintype.card (CutHalf b α β) = (Nat.factorial h)^Fintype.card B / 2 := by + have hh := card_cutHalf b hne + omega + +def tupleHalfCount : ℕ := (Nat.factorial tupleH)^tupleBlocks / 2 + +lemma card_tupleHalf (b : Fin tupleBlocks) {α β : Fin tupleH} (hne : α ≠ β) : + Fintype.card (CutHalf b α β) = tupleHalfCount := by + simpa only [tupleHalfCount, Fintype.card_fin] using card_cutHalf_eq_div b hne + +lemma tupleR_one_le : 1 ≤ (tupleR : ℝ) := by exact_mod_cast tupleR_pos + +noncomputable def tupleMarkedConstant : ℝ := + (Real.exp tupleKappa - 1)^tupleHalfCount / + ((tupleR : ℝ)^(tupleT + 1))^tupleHalfCount + +lemma tupleMarkedConstant_pos : 0 < tupleMarkedConstant := by + exact div_pos (pow_pos (sub_pos.mpr (Real.one_lt_exp_iff.mpr tupleKappa_pos)) _) + (pow_pos (pow_pos (Nat.cast_pos.mpr tupleR_pos) _) _) + +lemma tupleMarkedConstant_le (S : Finset (Fin tupleBlocks)) (hs : S.card ≤ tupleT + 1) + (b : Fin tupleBlocks) {α β : Fin tupleH} (hne : α ≠ β) : + tupleMarkedConstant ≤ (Real.exp tupleKappa - 1)^Fintype.card (CutHalf b α β) / + (Fintype.card (TupleListIndex S) : ℝ)^Fintype.card (CutHalf b α β) := by + rw [card_tupleHalf b hne] + simp only [TupleListIndex, Fintype.card_fin, Nat.cast_pow] + apply div_le_div_of_nonneg_left + (pow_nonneg (sub_nonneg.mpr (Real.one_le_exp tupleKappa_pos.le)) _) + (pow_pos (pow_pos (Nat.cast_pos.mpr tupleR_pos) _) _) + exact pow_le_pow_left₀ (pow_nonneg (Nat.cast_nonneg _) _) + (pow_le_pow_right₀ tupleR_one_le hs) _ + +end SquareDifference +end + +end OAI diff --git a/lean/OAI/Combinatorics/SquareDifference/ResidueFourier.lean b/lean/OAI/Combinatorics/SquareDifference/ResidueFourier.lean new file mode 100644 index 0000000000000000000000000000000000000000..f7a78ea253452cc30a1a65aebd714136a239dc4a --- /dev/null +++ b/lean/OAI/Combinatorics/SquareDifference/ResidueFourier.lean @@ -0,0 +1,542 @@ +import OAI.Combinatorics.SquareDifference.RationalLift + +namespace OAI + +section +open Finset +open scoped ComplexConjugate BigOperators +open Filter +open scoped Topology +open Finset Complex +open scoped BigOperators ComplexConjugate +namespace LiftTheory +open Finset +open scoped BigOperators InnerProductSpace ComplexConjugate + +namespace SquareDifference + +open Finset + +section PairFourier + +variable {J : Type*} [Fintype J] [DecidableEq J] + (p : J → ℕ) [∀j,NeZero (p j)] + +noncomputable def residueFourier (F : ResidueSpace p → ℂ) (a : ResidueSpace p) : ℂ := + 𝔼 x,F x*conj (prodChar p a x) + +noncomputable def squareMultiplier (a : ResidueSpace p) : ℂ := + 𝔼 u : ∀j,(ZMod (p j))ˣ,prodChar p a (fun j => (u j : ZMod (p j))^2) + +noncomputable def squarePairForm (F G : ResidueSpace p → ℂ) : ℂ := + 𝔼 u : ∀j,(ZMod (p j))ˣ,𝔼 x,F x*G (x+(fun j => (u j : ZMod (p j))^2)) + +lemma residueFourier_polynomial (c : ResidueSpace p → ℂ) (a : ResidueSpace p) : + residueFourier p (fourierPolynomial p c) a=c a := by + unfold residueFourier fourierPolynomial + simp only [sum_mul,mul_assoc,expect_sum_comm] + simp only [← mul_expect,prodChar_orthogonal,mul_ite,mul_one,mul_zero] + simp + +lemma residueFourier_reconstruction (F : ResidueSpace p → ℂ) : + fourierPolynomial p (residueFourier p F)=F := by + funext x + exact fourierPolynomial_reconstruction p F x + +lemma residueFourier_parseval (F : ResidueSpace p → ℂ) : + (∑a,‖residueFourier p F a‖^2)=𝔼 x,‖F x‖^2 := by + rw [← fourierPolynomial_parseval p,residueFourier_reconstruction] + +lemma pair_polynomial (f g : ResidueSpace p → ℂ) : + squarePairForm p (fourierPolynomial p f) (fourierPolynomial p g)= + ∑a,f (-a)*g a*squareMultiplier p a := by + unfold squarePairForm fourierPolynomial + simp only [prodChar_add_right,sum_mul,mul_sum,expect_sum_comm] + have he (u : ∀j,(ZMod (p j))ˣ) (a b : ResidueSpace p) : + (𝔼 x,f a*prodChar p a x*(g b*(prodChar p b x* + prodChar p b (fun j => (u j : ZMod (p j))^2))))= + (f a*g b*prodChar p b (fun j => (u j : ZMod (p j))^2))*(if a=-b then 1 else 0) := by + have h₁ : (fun x => f a*prodChar p a x*(g b*(prodChar p b x* + prodChar p b (fun j => (u j : ZMod (p j))^2))))= + (fun x => (f a*g b*prodChar p b (fun j => (u j : ZMod (p j))^2))*prodChar p (a+b) x) := by + funext x; rw [prodChar_add]; ring + rw [h₁,← mul_expect,prodChar_expect] + simp only [add_eq_zero_iff_eq_neg] + simp_rw [he] + have hu (a b : ResidueSpace p) : + (𝔼 u : ∀j,(ZMod (p j))ˣ,(f a*g b*prodChar p b + (fun j => (u j : ZMod (p j))^2))*(if a=-b then 1 else 0))= + if a=-b then f a*g b*squareMultiplier p b else 0 := by + split_ifs <;> simp only [mul_one,mul_zero,expect_const_zero,← mul_expect,squareMultiplier] + simp_rw [hu] + simp + +lemma squarePairForm_fourier (F G : ResidueSpace p → ℂ) : + squarePairForm p F G=∑a,residueFourier p F (-a)*residueFourier p G a*squareMultiplier p a := by + have h := pair_polynomial p (residueFourier p F) (residueFourier p G) + rwa [residueFourier_reconstruction,residueFourier_reconstruction] at h + +lemma squareMultiplier_product (a : ResidueSpace p) : + squareMultiplier p a=∏j,(𝔼 u : (ZMod (p j))ˣ,ZMod.stdAddChar (a j*(u : ZMod (p j))^2)) := by + unfold squareMultiplier prodChar + simp only [expect_eq_sum_div_card,card_univ,Fintype.card_pi,Nat.cast_prod] + rw [prod_div_distrib,Fintype.prod_sum] + +lemma fourier_pair_tail (F G : ResidueSpace p → ℂ) (s : Finset (ResidueSpace p)) + (m : ResidueSpace p → ℂ) (δ : ℝ) (_hδ : 0≤δ) (hm : ∀a∈s,‖m a‖≤δ) : + ‖∑a∈s,residueFourier p F (-a)*residueFourier p G a*m a‖^2≤ + δ^2*(𝔼 x,‖F x‖^2)*(𝔼 x,‖G x‖^2) := by + have hn : ‖∑a∈s,residueFourier p F (-a)*residueFourier p G a*m a‖≤ + δ*∑a∈s,‖residueFourier p F (-a)‖*‖residueFourier p G a‖ := by + apply (norm_sum_le _ _).trans + rw [mul_sum] + apply sum_le_sum + intro a ha + simp only [norm_mul] + calc + _ ≤ (‖residueFourier p F (-a)‖*‖residueFourier p G a‖)*δ := + mul_le_mul_of_nonneg_left (hm a ha) (by positivity) + _ = _ := by ring + have hc := sum_mul_sq_le_sq_mul_sq s + (fun a => ‖residueFourier p F (-a)‖) (fun a => ‖residueFourier p G a‖) + have hF : (∑a∈s,‖residueFourier p F (-a)‖^2)≤𝔼 x,‖F x‖^2 := by + apply (sum_le_sum_of_subset_of_nonneg (subset_univ s) (fun _ _ _ => sq_nonneg _)).trans + rw [Fintype.sum_equiv (Equiv.neg (ResidueSpace p)) + (fun a => ‖residueFourier p F (-a)‖^2) (fun a => ‖residueFourier p F a‖^2) + (fun _ => rfl),residueFourier_parseval] + have hG : (∑a∈s,‖residueFourier p G a‖^2)≤𝔼 x,‖G x‖^2 := by + rw [← residueFourier_parseval] + exact sum_le_sum_of_subset_of_nonneg (subset_univ s) (fun _ _ _ => sq_nonneg _) + have hc' := hc.trans (mul_le_mul hF hG + (sum_nonneg (fun _ _ => sq_nonneg _)) (expect_nonneg (fun _ _ => sq_nonneg _))) + calc + _ ≤ (δ*∑a∈s,‖residueFourier p F (-a)‖*‖residueFourier p G a‖)^2 := + pow_le_pow_left₀ (norm_nonneg _) hn _ + _ = δ^2*(∑a∈s,‖residueFourier p F (-a)‖*‖residueFourier p G a‖)^2 := by rw [mul_pow] + _ ≤ δ^2*((𝔼 x,‖F x‖^2)*(𝔼 x,‖G x‖^2)) := mul_le_mul_of_nonneg_left hc' (sq_nonneg _) + _ = _ := by ring + +end PairFourier + +end SquareDifference + +namespace SquareDifference + +lemma quadratic_gauss_ring {R : Type*} [CommRing R] [Fintype R] [DecidableEq R] + (ψ : AddChar R ℂ) (hψ : ψ.IsPrimitive) (a : R) (ha : IsUnit (2*a)) : + ‖∑ m : R, ψ (a*m^2)‖^2 = Fintype.card R := by + have hz (h : R) : 2*a*h=0 ↔ h=0 := by + rcases ha with ⟨u, hu⟩ + rw [← hu] + constructor + · intro he + have := congrArg (fun x : R => ↑u⁻¹*x) he + simpa only [← mul_assoc, Units.inv_mul, one_mul, mul_zero] using this + · rintro rfl; exact mul_zero _ + have he : (∑ m : R, ψ (a*m^2))*conj (∑ n : R, ψ (a*n^2)) = Fintype.card R := by + calc + _ = ∑ n : R, ∑ m : R, ψ (a*m^2-a*n^2) := by + simp only [map_sum, sum_mul, mul_sum, sub_eq_add_neg, AddChar.map_add_eq_mul, AddChar.map_neg_eq_conj] + _ = ∑ n : R, ∑ h : R, ψ (a*(h+n)^2-a*n^2) := by + apply sum_congr rfl + intro n _ + exact Fintype.sum_equiv (Equiv.subRight n) _ _ (by intro m; simp) + _ = ∑ h : R, ψ (a*h^2)*(∑ n : R, ψ ((2*a*h)*n)) := by + rw [sum_comm] + apply sum_congr rfl + intro h _ + rw [mul_sum] + apply sum_congr rfl + intro n _ + rw [← AddChar.map_add_eq_mul] + congr 1 + ring + _ = _ := by + simp_rw [mul_comm (2*a*_) _, AddChar.sum_mulShift _ hψ, hz] + simp + rw [Complex.mul_conj'] at he + exact_mod_cast he + +lemma quadratic_gauss_zmod (q : ℕ) [NeZero q] (a : ℤ) + (hq : q % 2 = 1) (ha : IsCoprime a (q : ℤ)) : + ‖∑ m : ZMod q, ZMod.stdAddChar ((a : ZMod q)*m^2)‖^2 = q := by + have h2 : IsUnit (2 : ZMod q) := by + apply (ZMod.isUnit_iff_coprime _ _).mpr + simpa only [Nat.coprime_comm, Nat.coprime_two_right] using (Nat.odd_iff.mpr hq) + have haa : IsUnit (a : ZMod q) := by + have h := ha.map (Int.castRingHom (ZMod q)) + apply isCoprime_zero_right.mp + simpa using h + simpa using quadratic_gauss_ring ZMod.stdAddChar (ZMod.isPrimitive_stdAddChar q) + (a : ZMod q) (h2.mul haa) + +lemma expect_surjective_addHom {G H : Type*} [AddGroup G] [AddGroup H] + [Fintype G] [Fintype H] (φ : G →+ H) (hφ : Function.Surjective φ) (f : H → ℂ) : + (𝔼 x : G, f (φ x))=𝔼 y : H, f y := by + have he (x : G) : (𝔼 y : H, f (φ x+y))=𝔼 y : H, f y := + Fintype.expect_equiv (Equiv.addLeft (φ x)) _ _ (fun _ => rfl) + have he' (y : H) : (𝔼 x : G, f (φ x+y))=𝔼 x : G, f (φ x) := by + obtain ⟨z,rfl⟩ := hφ y + simpa only [map_add] using + Fintype.expect_equiv (Equiv.addRight z) (fun x => f (φ x+φ z)) + (fun x => f (φ x)) (fun _ => by simp) + calc + _ = 𝔼 y : H, 𝔼 x : G, f (φ x+y) := by simp only [he', Fintype.expect_const] + _ = 𝔼 x : G, 𝔼 y : H, f (φ x+y) := expect_comm _ _ _ + _ = _ := by simp only [he, Fintype.expect_const] + +lemma zmod_factor_zero (m k : ℕ) (hk : k ≠ 0) (b : ℤ) : + (b : ZMod (m*k))*(k : ZMod (m*k))=0 ↔ (b : ZMod m)=0 := by + rw [← Int.cast_natCast k, ← Int.cast_mul, + ZMod.intCast_zmod_eq_zero_iff_dvd, ZMod.intCast_zmod_eq_zero_iff_dvd] + push_cast + exact mul_dvd_mul_iff_right (Int.natCast_ne_zero.mpr hk) + +lemma zmod_kernel_factor (m k : ℕ) [NeZero (m*k)] (x : ZMod (m*k)) + (hx : ZMod.castHom (dvd_mul_right m k) (ZMod m) x=0) : + x*(k : ZMod (m*k))=0 := by + have hk : k ≠ 0 := by intro he; subst k; simpa using (NeZero.ne (m*0)) + have he : ((x.val : ℤ) : ZMod m)=0 := by + have hh := congrArg (ZMod.castHom (dvd_mul_right m k) (ZMod m)) (ZMod.natCast_zmod_val x) + simp only [map_natCast] at hh + simpa only [Int.cast_natCast] using hh.trans hx + have hh := (zmod_factor_zero m k hk x.val).mpr he + simpa only [Int.cast_natCast, ZMod.natCast_zmod_val] using hh + +lemma quadratic_shift_cancellation {R : Type*} [CommRing R] [Fintype R] + (ψ : AddChar R ℂ) (a c : R) (w : R → ℂ) (ζ : ℂ) (hζ : ζ ≠ 1) + (hw : ∀ x, w (x+c)=w x) + (hphase : ∀ x, w x ≠ 0 → ψ (a*((x+c)^2-x^2))=ζ) : + ∑ x : R, w x*ψ (a*x^2)=0 := by + have hs : ∑ x : R, w x*ψ (a*x^2) = ζ*(∑ x : R, w x*ψ (a*x^2)) := by + calc + _ = ∑ x : R, w (x+c)*ψ (a*(x+c)^2) := + (Fintype.sum_equiv (Equiv.addRight c) _ _ (fun _ => rfl)).symm + _ = _ := by + rw [mul_sum] + apply sum_congr rfl + intro x _ + rw [hw] + by_cases hx : w x=0 + · simp [hx] + · have he : a*(x+c)^2=a*((x+c)^2-x^2)+a*x^2 := by ring + rw [he, AddChar.map_add_eq_mul, hphase x hx] + ring + have hz : (1-ζ)*(∑ x : R, w x*ψ (a*x^2))=0 := by linear_combination hs + exact (mul_eq_zero.mp hz).resolve_left (sub_ne_zero.mpr (Ne.symm hζ)) + +lemma zmod_fiber_translation (m k : ℕ) [NeZero (m*k)] + (c : ZMod m) (t : ZMod (m*k)) + (ht : ZMod.castHom (dvd_mul_right m k) (ZMod m) t=0) : + ∀ x : ZMod (m*k), + (if ZMod.castHom (dvd_mul_right m k) (ZMod m) (x+t)=c then (1 : ℂ) else 0)= + if ZMod.castHom (dvd_mul_right m k) (ZMod m) x=c then 1 else 0 := by + intro x + rw [map_add, ht, add_zero] + +lemma fiber_gauss_zero {p k : ℕ} [NeZero p] [NeZero k] + (hpk : p ∣ k) (a : ℤ) (c : ZMod p) + (hac : (2 : ZMod p)*(a : ZMod p)*c ≠ 0) : + ∑ x : ZMod (p*k), + (if ZMod.castHom (dvd_mul_right p k) (ZMod p) x=c then (1 : ℂ) else 0)* + ZMod.stdAddChar ((a : ZMod (p*k))*x^2)=0 := by + classical + have hk : k ≠ 0 := NeZero.ne k + let φ := ZMod.castHom (dvd_mul_right p k) (ZMod p) + let R := ZMod (p*k) + have ht : φ (k : R)=0 := by + dsimp only [φ] + rw [map_natCast] + exact (ZMod.natCast_eq_zero_iff k p).mpr hpk + have ht2 : (k : R)^2=0 := by + rw [pow_two] + exact zmod_kernel_factor p k (k : R) ht + let ζ := ZMod.stdAddChar ((2*(a : R)*(c.val : R))*(k : R)) + have hζ : ζ ≠ 1 := by + intro he + have he0 : (2*(a : R)*(c.val : R))*(k : R)=0 := by + apply ZMod.injective_stdAddChar + simpa only [AddChar.map_zero_eq_one] using he + have hzero : ((2*a*(c.val : ℤ) : ℤ) : ZMod p)=0 := + (zmod_factor_zero p k hk (2*a*c.val)).mp (by simpa using he0) + have hzero' : (2 : ZMod p)*(a : ZMod p)*c=0 := by simpa using hzero + exact hac hzero' + apply quadratic_shift_cancellation ZMod.stdAddChar (a : R) (k : R) _ ζ hζ + · exact zmod_fiber_translation p k c (k : R) ht + · intro x hx + have hxc : φ x=c := by + by_contra h + exact hx (ite_eq_right h) + have hkern : (x-(c.val : R))*(k : R)=0 := by + apply zmod_kernel_factor p k + change φ (x-(c.val : R))=0 + rw [map_sub, map_natCast, ZMod.natCast_zmod_val, hxc, sub_self] + have hxk : x*(k : R)=(c.val : R)*(k : R) := by linear_combination hkern + congr 1 + change (a : R)*((x+(k : R))^2-x^2)=(2*(a : R)*(c.val : R))*(k : R) + calc + _ = 2*(a : R)*(x*(k : R))+(a : R)*(k : R)^2 := by ring + _ = _ := by rw [hxk, ht2]; ring + +lemma odd_fiber_gauss_zero {p k : ℕ} [Fact p.Prime] (hp : p ≠ 2) + [NeZero k] (hpk : p ∣ k) (a : ℤ) (ha : (a : ZMod p) ≠ 0) + (c : ZMod p) (hc : c ≠ 0) : + ∑ x : ZMod (p*k), + (if ZMod.castHom (dvd_mul_right p k) (ZMod p) x=c then (1 : ℂ) else 0)* + ZMod.stdAddChar ((a : ZMod (p*k))*x^2)=0 := by + apply fiber_gauss_zero hpk a c + have h2 : (2 : ZMod p) ≠ 0 := + Ring.two_ne_zero (by simpa only [ZMod.ringChar_zmod_n] using hp) + exact mul_ne_zero (mul_ne_zero h2 ha) hc + +lemma weighted_fiber_sum {X Y : Type*} [Fintype X] [Fintype Y] [DecidableEq Y] + (φ : X → Y) (w : Y → ℂ) (f : X → ℂ) : + ∑ x, w (φ x)*f x = ∑ c, w c * ∑ x, (if φ x=c then (1 : ℂ) else 0)*f x := by + simp only [mul_sum] + rw [sum_comm] + apply sum_congr rfl + intro x _ + simp only [mul_ite, mul_zero, ite_mul, zero_mul] + simp + +lemma gauss_zero_of_fiber {p k : ℕ} [NeZero p] [NeZero k] + (hpk : p ∣ k) (a : ℤ) (w : ZMod p → ℂ) + (hw : ∀ c, w c ≠ 0 → (2 : ZMod p)*(a : ZMod p)*c ≠ 0) : + ∑ x : ZMod (p*k), w (ZMod.castHom (dvd_mul_right p k) (ZMod p) x)* + ZMod.stdAddChar ((a : ZMod (p*k))*x^2)=0 := by + classical + rw [weighted_fiber_sum] + apply sum_eq_zero + intro c _ + by_cases hc : w c=0 + · rw [hc, zero_mul] + · rw [fiber_gauss_zero hpk a c (hw c hc), mul_zero] + +lemma odd_unit_gauss_zero {p k : ℕ} [Fact p.Prime] [NeZero k] + (hp : p ≠ 2) (hpk : p ∣ k) (a : ℤ) (ha : (a : ZMod p) ≠ 0) : + ∑ x : ZMod (p*k), + (if ZMod.castHom (dvd_mul_right p k) (ZMod p) x ≠ 0 then (1 : ℂ) else 0)* + ZMod.stdAddChar ((a : ZMod (p*k))*x^2)=0 := by + apply gauss_zero_of_fiber hpk a (fun c => if c ≠ 0 then 1 else 0) + intro c hc + have hc0 : c ≠ 0 := by intro he; simp [he] at hc + have h2 : (2 : ZMod p) ≠ 0 := + Ring.two_ne_zero (by simpa only [ZMod.ringChar_zmod_n] using hp) + exact mul_ne_zero (mul_ne_zero h2 ha) hc0 + +lemma four_unit_mul_two {a c : ZMod 4} (ha : IsUnit a) (hc : IsUnit c) : + 2*a*c ≠ 0 := by + rcases ha with ⟨a,rfl⟩ + rcases hc with ⟨c,rfl⟩ + intro hz + have h := congrArg (fun x : ZMod 4 => x*(↑c⁻¹)*(↑a⁻¹)) hz + have h2 : (2 : ZMod 4) ≠ 0 := by decide + apply h2 + simpa only [mul_assoc, Units.mul_inv_cancel_left, Units.mul_inv, mul_one, zero_mul] using h + +lemma two_unit_gauss_zero {k : ℕ} [NeZero k] + (hk : 4 ∣ k) (a : ℤ) (ha : IsUnit (a : ZMod 4)) : + ∑ x : ZMod (4*k), + (if IsUnit (ZMod.castHom (dvd_mul_right 4 k) (ZMod 4) x) then (1 : ℂ) else 0)* + ZMod.stdAddChar ((a : ZMod (4*k))*x^2)=0 := by + classical + apply gauss_zero_of_fiber hk a (fun c => if IsUnit c then 1 else 0) + intro c hc + have hc0 : IsUnit c := by by_contra he; simp [he] at hc + exact four_unit_mul_two ha hc0 + +lemma quadratic_gauss_ring_linear {R : Type*} [CommRing R] [Fintype R] [DecidableEq R] + (ψ : AddChar R ℂ) (hψ : ψ.IsPrimitive) (a b : R) (ha : IsUnit (2*a)) : + ‖∑ m : R, ψ (a*m^2+b*m)‖^2 = Fintype.card R := by + have hz (h : R) : 2*a*h=0 ↔ h=0 := by + rcases ha with ⟨u, hu⟩ + rw [← hu] + constructor + · intro he + have := congrArg (fun x : R => ↑u⁻¹*x) he + simpa only [← mul_assoc, Units.inv_mul, one_mul, mul_zero] using this + · rintro rfl; exact mul_zero _ + have he : (∑ m : R, ψ (a*m^2+b*m))*conj (∑ n : R, ψ (a*n^2+b*n)) = Fintype.card R := by + calc + _ = ∑ n : R, ∑ m : R, ψ ((a*m^2+b*m)-(a*n^2+b*n)) := by + simp only [map_sum, sum_mul, mul_sum, sub_eq_add_neg, AddChar.map_add_eq_mul, AddChar.map_neg_eq_conj] + _ = ∑ n : R, ∑ h : R, ψ ((a*(h+n)^2+b*(h+n))-(a*n^2+b*n)) := by + apply sum_congr rfl + intro n _ + exact Fintype.sum_equiv (Equiv.subRight n) _ _ (by intro m; simp) + _ = ∑ h : R, ψ (a*h^2+b*h)*(∑ n : R, ψ ((2*a*h)*n)) := by + rw [sum_comm] + apply sum_congr rfl + intro h _ + rw [mul_sum] + apply sum_congr rfl + intro n _ + rw [← AddChar.map_add_eq_mul] + congr 1 + ring + _ = _ := by + simp_rw [mul_comm (2*a*_) _, AddChar.sum_mulShift _ hψ, hz] + simp + rw [Complex.mul_conj'] at he + exact_mod_cast he + +lemma norm_quadratic_expect {R : Type*} [CommRing R] [Fintype R] [DecidableEq R] + (ψ : AddChar R ℂ) (hψ : ψ.IsPrimitive) (a b : R) (ha : IsUnit (2*a)) : + ‖𝔼 m : R, ψ (a*m^2+b*m)‖= (Fintype.card R : ℝ)^(-(1:ℝ)/2) := by + have hc : (0:ℝ) c i*z) + apply expect_congr rfl + intro m _ + exact mul_comm _ _ + rw [he] + calc + _ ≤ ∑ i, ‖c i*(𝔼 m : R, ψ (a*m^2+b i*m))‖ := norm_sum_le _ _ + _ = _ := by simp only [norm_mul, norm_quadratic_expect ψ hψ a _ ha, ← sum_mul] + +noncomputable def primeSieveWeight (p : ℕ) (x : ZMod p) : ℝ := + ((p : ℝ)*(if x=0 then 1 else 0)-1)/(p-1) + +lemma primeSieveWeight_fourier {p : ℕ} [Fact p.Prime] (x : ZMod p) : + (primeSieveWeight p x : ℂ)=(p-1 : ℂ)⁻¹*∑ a∈univ.erase 0, ZMod.stdAddChar (a*x) := by + classical + have he : ∑ a : ZMod p, ZMod.stdAddChar (a*x)= + if x=0 then (p : ℂ) else 0 := by + simpa only [ZMod.card, Nat.cast_ite, Nat.cast_zero] using + AddChar.sum_mulShift x (ZMod.isPrimitive_stdAddChar p) + have hs := sum_erase_add (univ : Finset (ZMod p)) (fun a => ZMod.stdAddChar (a*x)) (mem_univ 0) + rw [zero_mul, AddChar.map_zero_eq_one, he] at hs + unfold primeSieveWeight + push_cast + rw [div_eq_inv_mul] + congr 1 + by_cases hx : x=0 + · rw [ite_eq_left hx] at hs ⊢ + push_cast + linear_combination -hs + · rw [ite_eq_right hx] at hs ⊢ + push_cast + linear_combination -hs + +lemma primeSieveWeight_abs_le {p : ℕ} [Fact p.Prime] (x : ZMod p) : + |primeSieveWeight p x|≤1 := by + have hp : (1:ℝ)

(k : ZMod (p*k))*(z : ZMod (p*k)) + map_zero' := by simp + map_add' := by intros; simp only [Int.cast_add, mul_add] }, by + change (k : ZMod (p*k))*((p : ℤ) : ZMod (p*k))=0 + rw [Int.cast_natCast] + rw [← Nat.cast_mul, mul_comm k p, ZMod.natCast_self]⟩ + +lemma zmodScaleHom_int (p k : ℕ) (z : ℤ) : + zmodScaleHom p k (z : ZMod p)=(k : ZMod (p*k))*(z : ZMod (p*k)) := + ZMod.lift_coe p _ z + +lemma zmodScaleHom_nat (p k z : ℕ) : + zmodScaleHom p k (z : ZMod p)=(k : ZMod (p*k))*(z : ZMod (p*k)) := by + simpa only [Int.cast_natCast] using zmodScaleHom_int p k (z : ℤ) + +lemma zmodScaleHom_injective (p k : ℕ) [NeZero p] (hk : k≠0) : Function.Injective (zmodScaleHom p k) := by + apply (injective_iff_map_eq_zero _).mpr + intro x hx + have he : ((x.val : ℤ) : ZMod p)=0 := (zmod_factor_zero p k hk (x.val : ℤ)).mp (by + rw [mul_comm ((x.val : ℤ) : ZMod (p*k)) (k : ZMod (p*k)), ← zmodScaleHom_int, Int.cast_natCast, ZMod.natCast_zmod_val] + exact hx) + simpa only [Int.cast_natCast, ZMod.natCast_zmod_val] using he + +lemma zmodScaleHom_mul {p k : ℕ} [NeZero p] [NeZero k] (t : ZMod p) (x : ZMod (p*k)) : + zmodScaleHom p k (t*(ZMod.castHom (dvd_mul_right p k) (ZMod p) x))= + zmodScaleHom p k t*x := by + have ht := ZMod.natCast_zmod_val t + have hx := ZMod.natCast_zmod_val x + conv_lhs => rw [← ht, ← hx] + simp only [map_natCast, ← Nat.cast_mul] + rw [← Int.cast_natCast, zmodScaleHom_int] + simp only [Int.cast_mul, Int.cast_natCast, Nat.cast_mul] + rw [ZMod.natCast_zmod_val, ← mul_assoc, ← zmodScaleHom_nat p k t.val, + ZMod.natCast_zmod_val] + +lemma zmodScale_primitive {p k : ℕ} [Fact p.Prime] (hk : k≠0) + (ψ : AddChar (ZMod (p*k)) ℂ) (hψ : ψ.IsPrimitive) : + (ψ.compAddMonoidHom (zmodScaleHom p k)).IsPrimitive := by + have : NeZero k := ⟨hk⟩ + apply AddChar.IsPrimitive.of_ne_one + intro he + have hh := congrArg (fun χ : AddChar (ZMod p) ℂ => χ 1) he + simp only [AddChar.compAddMonoidHom_apply, AddChar.one_apply] at hh + have hz := (hψ.zmod_char_eq_one_iff (p*k) _).mp hh + have h1 : (1 : ZMod p)=0 := zmodScaleHom_injective p k hk (by simpa using hz) + exact one_ne_zero h1 + +lemma primeSieveWeight_fourier_char {p : ℕ} [Fact p.Prime] + (ψ : AddChar (ZMod p) ℂ) (hψ : ψ.IsPrimitive) (x : ZMod p) : + (primeSieveWeight p x : ℂ)=(p-1 : ℂ)⁻¹*∑ a∈univ.erase 0, ψ (a*x) := by + classical + have he : ∑ a : ZMod p, ψ (a*x)=if x=0 then (p : ℂ) else 0 := by + simpa only [ZMod.card, Nat.cast_ite, Nat.cast_zero] using AddChar.sum_mulShift x hψ + have hs := sum_erase_add (univ : Finset (ZMod p)) (fun a => ψ (a*x)) (mem_univ 0) + rw [zero_mul, AddChar.map_zero_eq_one, he] at hs + unfold primeSieveWeight + push_cast + rw [div_eq_inv_mul] + congr 1 + by_cases hx : x=0 + · rw [ite_eq_left hx] at hs ⊢ + push_cast + linear_combination -hs + · rw [ite_eq_right hx] at hs ⊢ + push_cast + linear_combination -hs + +end SquareDifference +end LiftTheory +end + +end OAI diff --git a/lean/OAI/Combinatorics/SquareDifference/ResidueLift.lean b/lean/OAI/Combinatorics/SquareDifference/ResidueLift.lean new file mode 100644 index 0000000000000000000000000000000000000000..cf5b495f1f8d2d9f0f7a896312811412e9c19a97 --- /dev/null +++ b/lean/OAI/Combinatorics/SquareDifference/ResidueLift.lean @@ -0,0 +1,669 @@ +import OAI.Combinatorics.SquareDifference.FourierLift + +namespace OAI + +section +open Finset +open scoped BigOperators +namespace LiftAnalysis +open Finset +open scoped BigOperators InnerProductSpace ComplexConjugate + +namespace SquareDifference + +def IsSquareDifferenceFree (A : Finset ℤ) : Prop := + ∀ a ∈ A, ∀ b ∈ A, ∀ m : ℕ, 1 ≤ m → a-b ≠ (m : ℤ)^2 + +noncomputable def squareStepChild (A : Finset ℤ) (L D : ℕ) (c : ℤ) : Finset ℤ := + (Icc 1 (L : ℤ)).filter (fun n => (D : ℤ)^2*n+c∈A) + +lemma squareStepChild_subset (A : Finset ℤ) (L D : ℕ) (c : ℤ) : + squareStepChild A L D c⊆Icc 1 (L : ℤ) := filter_subset _ _ + +lemma squareStepChild_free (A : Finset ℤ) (hA : IsSquareDifferenceFree A) + (L D : ℕ) (hD : 1≤D) (c : ℤ) : IsSquareDifferenceFree (squareStepChild A L D c) := by + intro a ha b hb m hm he + have h := hA _ (mem_filter.mp ha).2 _ (mem_filter.mp hb).2 (D*m) (by nlinarith) + apply h + push_cast + calc + (D : ℤ)^2*a+c-((D : ℤ)^2*b+c)=(D : ℤ)^2*(a-b) := by ring + _ = _ := by rw [he]; ring + +lemma squareStepChild_mem (A : Finset ℤ) (L D : ℕ) (c n : ℤ) : + n∈squareStepChild A L D c ↔ 1≤n ∧ n≤L ∧ (D : ℤ)^2*n+c∈A := by + simp only [squareStepChild,mem_filter,mem_Icc,and_assoc] + +lemma sum_range_blocks {E : Type*} [AddCommMonoid E] (f : ℕ → E) (D L : ℕ) (hD : 0 f (j+D*t))] + symm + apply sum_bij (fun x _ => x.1+D*x.2) + · intro x hx + obtain ⟨hj,ht⟩ := mem_product.mp hx + simp only [mem_range] at hj ht ⊢ + nlinarith + · intro x hx y hy he + obtain ⟨hxj,hxt⟩ := mem_product.mp hx + obtain ⟨hyj,hyt⟩ := mem_product.mp hy + have hj : x.1=y.1 := by + have hh := congrArg (fun n => n%D) he + simpa only [Nat.add_mul_mod_self_left,Nat.mod_eq_of_lt (mem_range.mp hxj), + Nat.mod_eq_of_lt (mem_range.mp hyj)] using hh + have ht : x.2=y.2 := by rw [hj] at he; exact (Nat.mul_left_cancel hD (Nat.add_left_cancel he)) + exact Prod.ext hj ht + · intro n hn + refine ⟨(n%D,n/D), mem_product.mpr ⟨mem_range.mpr (Nat.mod_lt n hD),mem_range.mpr ?_⟩, + Nat.mod_add_div n D⟩ + apply (Nat.div_lt_iff_lt_mul hD).mpr + simpa only [mul_comm] using mem_range.mp hn + · intro x _; rfl + +lemma squareStep_padded_sum {E : Type*} [AddCommMonoid E] (f : ℕ → E) + (N D L a : ℕ) (hD : 0 rfl + rw [hpad,show D^2*L=D*(D*L) by ring,sum_range_blocks _ D (D*L) hD] + simp only [Nat.add_mul_mod_self_left] + have hsel : (∑j∈range D, ∑t∈range (D*L), if j%D=a then f (j+D*t) else 0)= + ∑t∈range (D*L), f (a+D*t) := by + simp_rw [sum_ite_irrel,sum_const_zero] + rw [sum_eq_single a] + · rw [Nat.mod_eq_of_lt ha,ite_eq_left rfl] + · intro j hj hja + rw [Nat.mod_eq_of_lt (mem_range.mp hj),ite_eq_right hja] + · intro h; exact (h (mem_range.mpr ha)).elim + rw [hsel,sum_range_blocks _ D L hD] + apply sum_congr rfl + intro j _ + apply sum_congr rfl + intro t _ + congr 1 + ring + +lemma ceil_square_scale (N D : ℕ) (hN : 1≤N) (hD : 2≤D) : + 1≤N⌈/⌉D^2 ∧ N≤D^2*(N⌈/⌉D^2) ∧ (2≤N → N⌈/⌉D^2 ring + +omit [∀j,NeZero (p j)] in +lemma sum_exactGate_powerset (B : Finset J) (z : ResidueSpace p) : + (∑W∈B.powerset,exactGate p W z)= + if ∀j∈B,z j=0 then (∏j∈B,p j : ℝ) else 0 := by + classical + have he : (∑W∈B.powerset,exactGate p W z)=∏j∈B,(residueGate (p j) (z j)+1) := by + simpa only [exactGate,prod_const_one,mul_one] using + (prod_add (fun j => residueGate (p j) (z j)) (fun _ => (1:ℝ)) B).symm + rw [he] + simp only [residueGate_plus_one] + by_cases h : ∀j∈B,z j=0 + · rw [ite_eq_left h] + exact prod_congr rfl (fun j hj => ite_eq_left (h j hj)) + · rw [ite_eq_right h] + push Not at h + obtain ⟨j,hj,hz⟩ := h + exact prod_eq_zero hj (ite_eq_right hz) + +omit [Fintype J] [∀j,NeZero (p j)] in +lemma exactGate_union (U W : Finset J) (hUW : Disjoint U W) (z : ResidueSpace p) : + exactGate p (U∪W) z=exactGate p U z*exactGate p W z := by + exact prod_union hUW + +lemma sum_exactGate_frozen {J : Type*} + [Fintype J] + [DecidableEq J] + (p : J → ℕ) + [∀ (j : J), NeZero (p j)] (U B : Finset J) (hUB : Disjoint U B) (z x : ResidueSpace p) : + (∑W∈B.powerset,exactGate p (U∪W) (coordinateFreeze p B z x))= + exactGate p U x*(if ∀j∈B,z j=0 then (∏j∈B,p j : ℝ) else 0) := by + have he (W : Finset J) (hW : W∈B.powerset) : + exactGate p (U∪W) (coordinateFreeze p B z x)=exactGate p U x*exactGate p W z := by + have hWB := mem_powerset.mp hW + rw [exactGate_union p U W (hUB.mono_right hWB)] + congr 1 + · apply prod_congr rfl + intro j hj + simp only [coordinateFreeze,ite_eq_right (disjoint_left.mp hUB hj)] + · apply prod_congr rfl + intro j hj + simp only [coordinateFreeze,ite_eq_left (hWB hj)] + rw [sum_congr rfl he,← mul_sum,sum_exactGate_powerset] + +lemma liftPiece_frozen_complete (L : ℕ) (f : ℕ → ℝ) (U B : Finset J) + (hUB : Disjoint U B) (z x : ResidueSpace p) : + (∑W∈B.powerset,liftPiece p L f (U∪W) (coordinateFreeze p B z x))= + ((∏j∈B,p j : ℝ)/(L : ℝ))*∑n∈range L, + if ∀j∈B,(n : ZMod (p j))=z j then + f n*exactGate p U (x-fun j => (n : ZMod (p j))) else 0 := by + simp only [liftPiece,← mul_sum] + rw [sum_comm] + have he (n : ℕ) : (∑W∈B.powerset,f n*exactGate p (U∪W) + (coordinateFreeze p B z x-fun j => (n : ZMod (p j))))= + (∏j∈B,p j : ℝ)*(if ∀j∈B,(n : ZMod (p j))=z j then + f n*exactGate p U (x-fun j => (n : ZMod (p j))) else 0) := by + rw [← mul_sum,coordinateFreeze_sub,sum_exactGate_frozen p U B hUB] + simp only [Pi.sub_apply,sub_eq_zero,eq_comm (a:=z _) ] + split_ifs <;> ring + simp_rw [he] + rw [← mul_sum] + ring + +lemma residueGate_mul_unit {J : Type*} + [Fintype J] + [DecidableEq J] + (p : J → ℕ) + [∀ (j : J), NeZero (p j)] (j : J) (u : (ZMod (p j))ˣ) (x : ZMod (p j)) : + residueGate (p j) ((u : ZMod (p j))*x)=residueGate (p j) x := by + unfold residueGate + simp only [Units.mul_right_eq_zero] + +lemma exactGate_affine (U : Finset J) (u : ∀j,(ZMod (p j))ˣ) + (z c t : ResidueSpace p) : + exactGate p U (z-(fun j => c j+(u j : ZMod (p j))*t j))= + exactGate p U (fun j => ((u j)⁻¹ : (ZMod (p j))ˣ)*(z j-c j)-t j) := by + apply prod_congr rfl + intro j hj + have he : z j-(c j+(u j : ZMod (p j))*t j)= + (u j : ZMod (p j))*(((u j)⁻¹ : (ZMod (p j))ˣ)*(z j-c j)-t j) := by + rw [mul_sub,← mul_assoc,Units.mul_inv,one_mul] + ring + change residueGate (p j) (z j-(c j+(u j : ZMod (p j))*t j))=_ + rw [he,residueGate_mul_unit] + +lemma exactGate_square_progression (U : Finset J) (u : ∀j,(ZMod (p j))ˣ) + (D c t : ℕ) (hu : ∀j,(u j : ZMod (p j))=(D : ZMod (p j))^2) + (x : ResidueSpace p) : + exactGate p U (x-fun j => ((c+D^2*t : ℕ) : ZMod (p j)))= + exactGate p U ((fun j => ((u j)⁻¹ : (ZMod (p j))ˣ)*(x j-(c : ZMod (p j))))- + fun j => (t : ZMod (p j))) := by + have he := exactGate_affine p U u x (fun j => (c : ZMod (p j))) + (fun j => (t : ZMod (p j))) + convert he using 2 ; ext j ; simp [hu] + +lemma fiber_squareStep_lift (N D L a : ℕ) (hD : 0 (n : ZMod (p j))) else 0)= + ((D : ℝ)*(L : ℝ)/(N : ℝ))*∑j∈range D, + liftPiece p L (fun t => f (a+D*j+D^2*t)) U + (fun k => ((u k)⁻¹ : (ZMod (p k))ˣ)*(x k-((a+D*j : ℕ) : ZMod (p k)))) := by + rw [squareStep_padded_sum (fun n => f n*exactGate p U (x-fun j => (n : ZMod (p j)))) + N D L a hD ha hNL (fun n hn => by rw [hf n hn,zero_mul])] + simp only [liftPiece,exactGate_square_progression p U u D _ _ hu,← mul_sum] + have hL0 : (L : ℝ)≠0 := Nat.cast_ne_zero.mpr (Nat.ne_of_gt hL) + field_simp + +end Fiber + +end SquareDifference + +end LiftAnalysis + +namespace SquareDifference + +open Finset + +section FrozenAnalysis + +variable {J : Type*} [instFintypeJ : Fintype J] [DecidableEq J] + {X : J → Type*} [instFintypeXj : ∀j,Fintype (X j)] [instNonemptyXj : ∀j,Nonempty (X j)] [instDecidableEqXj : ∀j,DecidableEq (X j)] + +noncomputable def freezeCoordinates (B : Finset J) (z x : ∀j,X j) : ∀j,X j := + fun j => if j∈B then z j else x j + +lemma freeze_update_outside {J : Type*} + [Fintype J] + [DecidableEq J] + {X : J → Type*} + [(j : J) → Fintype (X j)] + [∀ (j : J), Nonempty (X j)] + [(j : J) → DecidableEq (X j)] (B : Finset J) (z x : ∀j,X j) (j : J) (hj : j∉B) (t : X j) : + freezeCoordinates B z (Function.update x j t)=Function.update (freezeCoordinates B z x) j t := by + ext i + by_cases hi : i=j + · subst i; simp [freezeCoordinates,hj] + · simp [freezeCoordinates,hi] + +lemma freeze_update_inside {J : Type*} + [Fintype J] + [DecidableEq J] + {X : J → Type*} + [(j : J) → Fintype (X j)] + [∀ (j : J), Nonempty (X j)] + [(j : J) → DecidableEq (X j)] (B : Finset J) (z x : ∀j,X j) (j : J) (hj : j∈B) (t : X j) : + freezeCoordinates B z (Function.update x j t)=freezeCoordinates B z x := by + ext i + by_cases hi : i=j + · subst i; simp [freezeCoordinates,hj] + · simp [freezeCoordinates,hi] + +lemma ExactSupport.freeze (U B : Finset J) (f : (∀j,X j) → ℝ) (hf : ExactSupport U f) + (z : ∀j,X j) : ExactSupport (U\B) (fun x => f (freezeCoordinates B z x)) := by + constructor + · intro j hj x + rw [mem_sdiff] at hj + simp only [freeze_update_outside B z x j hj.2] + exact hf.1 j hj.1 _ + · intro j hj x t + change f (freezeCoordinates B z (Function.update x j t))=f (freezeCoordinates B z x) + by_cases hjB : j∈B + · rw [freeze_update_inside B z x j hjB t] + · rw [freeze_update_outside B z x j hjB t] + exact hf.2 j (fun h => hj (mem_sdiff.mpr ⟨h,hjB⟩)) _ t + +lemma ExactSupport.finset_sum {J : Type*} + [Fintype J] + [DecidableEq J] + {X : J → Type*} + [(j : J) → Fintype (X j)] + [∀ (j : J), Nonempty (X j)] + [(j : J) → DecidableEq (X j)] {I : Type*} (s : Finset I) (U : Finset J) + (f : I → (∀j,X j) → ℝ) (hf : ∀i∈s,ExactSupport U (f i)) : + ExactSupport U (fun x => ∑i∈s,f i x) := by + constructor + · intro j hj x + rw [expect_sum_comm] + exact sum_eq_zero (fun i hi => (hf i hi).1 j hj x) + · intro j hj x t + exact sum_congr rfl (fun i hi => (hf i hi).2 j hj x t) + +lemma expect_fixed_update_le {J : Type*} + [Fintype J] + [DecidableEq J] + {X : J → Type*} + [(j : J) → Fintype (X j)] + [∀ (j : J), Nonempty (X j)] + [(j : J) → DecidableEq (X j)] (F : (∀j,X j) → ℝ) (hF : ∀x,0≤F x) (j : J) (t : X j) : + (𝔼 x,F (Function.update x j t))≤(Fintype.card (X j) : ℝ)*(𝔼 x,F x) := by + have hc : (Fintype.card (X j) : ℝ)≠0 := Nat.cast_ne_zero.mpr Fintype.card_ne_zero + calc + _ ≤ 𝔼 x,(Fintype.card (X j) : ℝ)*(𝔼 u : X j,F (Function.update x j u)) := by + apply expect_le_expect + intro x _ + rw [expect_eq_sum_div_card,card_univ,mul_div_cancel₀ _ hc] + exact single_le_sum (fun u _ => hF _) (mem_univ t) + _ = _ := by rw [← mul_expect,expect_update_dep] + +lemma expect_freeze_le (F : (∀j,X j) → ℝ) (hF : ∀x,0≤F x) (B : Finset J) (z : ∀j,X j) : + (𝔼 x,F (freezeCoordinates B z x))≤(∏j∈B,(Fintype.card (X j) : ℝ))*(𝔼 x,F x) := by + induction B using Finset.induction_on with + | empty => + have he (x : ∀j,X j) : freezeCoordinates ∅ z x=x := by ext j; simp [freezeCoordinates] + simp only [he,prod_empty,one_mul,le_refl] + | @insert j B hj ih => + have he (x : ∀j,X j) : freezeCoordinates (insert j B) z x= + freezeCoordinates B z (Function.update x j (z j)) := by + ext i + by_cases hi : i=j + · subst i; simp [freezeCoordinates,hj] + · simp [freezeCoordinates,hi] + simp_rw [he] + apply (expect_fixed_update_le (fun x => F (freezeCoordinates B z x)) (fun x => hF _) j (z j)).trans + rw [prod_insert hj,mul_assoc] + exact mul_le_mul_of_nonneg_left ih (Nat.cast_nonneg _) + +end FrozenAnalysis + +lemma grouped_conditional_decay {J I V : Type*} [Fintype J] [DecidableEq J] + [DecidableEq I] [Fintype V] [DecidableEq V] + (p : J → ℕ) [∀j,Fact (p j).Prime] + (L : ∀j,((V → ZMod (p j)) → ℝ) →ₗ[ℝ] ℝ) + (hL : ∀j F,(∀z,0≤F z) → 0≤L j F) + (hmarg : ∀j v (f : ZMod (p j) → ℝ),L j (fun z => f (z v))=𝔼 x,f x) + (v : V) + (hmix : ∀j (f : ZMod (p j) → ℝ),(𝔼 x,f x)=0 → + conditionalEnergy (jointDensity (L j) (Equiv.funSplitAt v _)) f≤ + (p j : ℝ)^(-(1:ℝ)/32)*(𝔼 x,f x^2)) + (s : Finset I) (σ : I → Finset J) (f : I → (∀j,ZMod (p j)) → ℝ) + (hf : ∀i∈s,ExactSupport (σ i) (f i)) (T : ℝ) (hT : 0 ∑i∈s,f i x)≤ + T^(-(1:ℝ)/32)*(𝔼 x,(∑i∈s,f i x)^2) := by + let g (U : Finset J) (x : ∀j,ZMod (p j)) := ∑i∈s.filter (fun i => σ i=U),f i x + have hg (U : Finset J) (_hU : U∈s.image σ) : ExactSupport U (g U) := by + apply ExactSupport.finset_sum + intro i hi + obtain ⟨his,hiU⟩ := mem_filter.mp hi + simpa only [← hiU] using hf i his + have he (x : ∀j,ZMod (p j)) : (∑U∈s.image σ,g U x)=∑i∈s,f i x := by + exact sum_fiberwise_of_maps_to (fun i hi => mem_image_of_mem σ hi) (fun i => f i x) + have hh := tensorLaw_prime_conductor_energy p L hL hmarg v hmix (s.image σ) g hg T hT + (fun U hU => by obtain ⟨i,hi,rfl⟩ := mem_image.mp hU; exact hden i hi) + simpa only [he] using hh + +end SquareDifference + +namespace SquareDifference + +open Finset + +lemma multilinearIntegral_slot {V X : Type*} [Fintype V] [DecidableEq V] + (L : ((V → X) → ℝ) →ₗ[ℝ] ℝ) (v : V) (F : V → X → ℝ) : + multilinearIntegral L F=L (fun z => F v (z v)*∏w : {w : V // w≠v},F w (z w)) := by + unfold multilinearIntegral + congr 1; funext z + rw [prod_eq_mul_prod_sdiff_singleton v _ (by simp)] + congr 1 + exact prod_subtype (univ\{v}) (by intro w; simp) _ + +lemma multilinearIntegral_update_sub {V X : Type*} [Fintype V] [DecidableEq V] + (L : ((V → X) → ℝ) →ₗ[ℝ] ℝ) (v : V) (F : V → X → ℝ) (f g : X → ℝ) : + multilinearIntegral L (Function.update F v f)-multilinearIntegral L (Function.update F v g)= + L (fun z => (f (z v)-g (z v))*∏w : {w : V // w≠v},F w (z w)) := by + rw [multilinearIntegral_slot L v,multilinearIntegral_slot L v,←map_sub] + congr 1; funext z + have hf (w : {w : V // w≠v}) : Function.update F v f (w:V)=F w := Function.update_of_ne w.property _ _ + have hg (w : {w : V // w≠v}) : Function.update F v g (w:V)=F w := Function.update_of_ne w.property _ _ + simp only [Function.update_self,hf,hg,Pi.sub_apply,sub_mul] + +lemma multilinearIntegral_telescope {V X : Type*} [Fintype V] [DecidableEq V] + (L : ((V → X) → ℝ) →ₗ[ℝ] ℝ) (F G : V → X → ℝ) (E : V → ℝ) + (hslot : ∀v (A : V → X → ℝ),(∀w,A w=F w ∨ A w=G w) → + |L (fun z => (F v (z v)-G v (z v))*∏w : {w : V // w≠v},A w (z w))|≤E v) : + |multilinearIntegral L F-multilinearIntegral L G|≤∑v,E v := by + have hb (S : Finset V) : + |multilinearIntegral L (fun v => if v∈S then F v else G v)-multilinearIntegral L G|≤∑v∈S,E v := by + induction S using Finset.induction_on with + | empty => simp + | @insert v S hv ih => + let A : V → X → ℝ := fun w => if w∈S then F w else G w + have hA : ∀w,A w=F w ∨ A w=G w := by + intro w + dsimp [A] + split_ifs + · exact Or.inl rfl + · exact Or.inr rfl + have hins : (fun w => if w∈insert v S then F w else G w)=Function.update A v (F v) := by + funext w; by_cases hw : w=v + · subst w; simp + · simp [hw,A] + have hbase : A=Function.update A v (G v) := by + funext w; by_cases hw : w=v + · subst w; simp [A,hv] + · simp [hw] + have hd : |multilinearIntegral L (fun w => if w∈insert v S then F w else G w)- + multilinearIntegral L A|≤E v := by + rw [hins] + calc + _ = |multilinearIntegral L (Function.update A v (F v))- + multilinearIntegral L (Function.update A v (G v))| := + congrArg (fun t => |multilinearIntegral L (Function.update A v (F v))-t|) + (congrArg (multilinearIntegral L) hbase) + _ ≤ E v := by rw [multilinearIntegral_update_sub]; exact hslot v A hA + rw [sum_insert hv] + exact (abs_sub_le _ (multilinearIntegral L A) _).trans (add_le_add hd ih) + simpa using hb univ + +lemma diagonalRoot_zero {V X : Type*} [Fintype V] [Nonempty V] + (L : ((V → X) → ℝ) →ₗ[ℝ] ℝ) : diagonalRoot L (0 : X → ℝ)=0 := by + have hn : Fintype.card V≠0 := Fintype.card_ne_zero + unfold diagonalRoot diagonalIntegral multilinearIntegral + have he : (fun _z : V → X => ∏ _v : V, (0:ℝ))=(0 : (V → X) → ℝ) := by + funext z; simp [hn] + simp only [Pi.zero_apply,he,map_zero] + exact Real.zero_rpow (one_div_ne_zero (Nat.cast_ne_zero.mpr hn)) + +lemma diagonalRoot_nonneg_smul {V X : Type*} [Fintype V] [Nonempty V] + (L : ((V → X) → ℝ) →ₗ[ℝ] ℝ) (hd : ∀g,0≤diagonalIntegral L g) + (c : ℝ) (hc : 0≤c) (f : X → ℝ) : diagonalRoot L (c • f)=c*diagonalRoot L f := by + unfold diagonalRoot + rw [diagonalIntegral_smul,Real.mul_rpow (pow_nonneg hc _) (hd f)] + congr 1 + rw [←Real.rpow_natCast_mul hc,mul_one_div_cancel (Nat.cast_ne_zero.mpr Fintype.card_ne_zero),Real.rpow_one] + +lemma diagonalRoot_sum_le {V X I : Type*} [Fintype V] [Nonempty V] + (L : ((V → X) → ℝ) →ₗ[ℝ] ℝ) (hd : ∀g,0≤diagonalIntegral L g) + (hh : ∀A : V → X → ℝ,|multilinearIntegral L A|≤∏v,diagonalRoot L (A v)) + (S : Finset I) (f : I → X → ℝ) : diagonalRoot L (∑i∈S,f i)≤∑i∈S,diagonalRoot L (f i) := by + classical + induction S using Finset.induction_on with + | empty => simp only [sum_empty,diagonalRoot_zero,le_refl] + | @insert i S hi ih => + rw [sum_insert hi,sum_insert hi] + exact (diagonalRoot_add_le L hd hh _ _).trans (add_le_add_right ih _) + +lemma diagonalRoot_expect_le {V X I : Type*} [Fintype V] [Nonempty V] + [Fintype I] [Nonempty I] + (L : ((V → X) → ℝ) →ₗ[ℝ] ℝ) (hd : ∀g,0≤diagonalIntegral L g) + (hh : ∀A : V → X → ℝ,|multilinearIntegral L A|≤∏v,diagonalRoot L (A v)) + (f : I → X → ℝ) : diagonalRoot L (fun x => 𝔼 i,f i x)≤𝔼 i,diagonalRoot L (f i) := by + have he : (fun x => 𝔼 i,f i x)=(Fintype.card I : ℝ)⁻¹ • ∑i,f i := by + funext x + simp only [Pi.smul_apply,Finset.sum_apply,smul_eq_mul,expect_eq_sum_div_card,card_univ,div_eq_inv_mul] + rw [he,diagonalRoot_nonneg_smul L hd _ (by positivity),expect_eq_sum_div_card,card_univ,div_eq_inv_mul] + exact mul_le_mul_of_nonneg_left (diagonalRoot_sum_le L hd hh univ f) (by positivity) + +end SquareDifference + +namespace SquareDifference + +open Finset + +lemma multilinear_truncation_error {V X : Type*} [Fintype V] [DecidableEq V] + [Nontrivial V] [Fintype X] [Nonempty X] [DecidableEq X] + (L : ((V → X) → ℝ) →ₗ[ℝ] ℝ) (hL : ∀F,(∀z,0≤F z) → 0≤L F) + (F G : V → X → ℝ) (H q M : ℝ) (hH : 0 |F w (z w)|^(2*Fintype.card {w : V // w≠v}))≤ + q*M^(2*Fintype.card {w : V // w≠v}) ∧ + L (fun z => |G w (z w)|^(2*Fintype.card {w : V // w≠v}))≤ + q*M^(2*Fintype.card {w : V // w≠v})) : + |multilinearIntegral L F-multilinearIntegral L G|≤ + (Fintype.card V : ℝ)*H^(-(1:ℝ)/64)*q*M^(Fintype.card V) := by + have hs (v : V) (A : V → X → ℝ) (hA : ∀w,A w=F w ∨ A w=G w) : + |L (fun z => (F v (z v)-G v (z v))*∏w : {w : V // w≠v},A w (z w))|≤ + H^(-(1:ℝ)/64)*q*M^(Fintype.card V) := by + obtain ⟨w,hw⟩ := exists_ne v + let : Nonempty {w : V // w≠v} := ⟨⟨w,hw⟩⟩ + have hr : Fintype.card {w : V // w≠v}+1=Fintype.card V := by + simp only [Fintype.card_subtype_compl,Fintype.card_unique] + exact Nat.sub_add_cancel (Nat.succ_le_of_lt Fintype.card_pos) + have hb := law_slot_product_sq v L hL (F v-G v) A + (q*M^(2*Fintype.card {w : V // w≠v})) (fun w => by + rcases hA w with h | h <;> rw [h] + · exact (hm v w).1 + · exact (hm v w).2) + have hc : (L (fun z => (F v (z v)-G v (z v))*∏w : {w : V // w≠v},A w (z w)))^2≤ + H^(-(1:ℝ)/32)*(q*M^2)*(q*M^(2*Fintype.card {w : V // w≠v})) := + hb.trans (mul_le_mul_of_nonneg_right (henergy v) (by positivity)) + have he : H^(-(1:ℝ)/32)*(q*M^2)*(q*M^(2*Fintype.card {w : V // w≠v}))= + (H^(-(1:ℝ)/64)*q*M^(Fintype.card V))^2 := by + rw [mul_pow,mul_pow,←Real.rpow_mul_natCast hH.le] + have hpow : M^2*M^(2*Fintype.card {w : V // w≠v})=(M^(Fintype.card V))^2 := by + rw [←pow_add,←pow_mul] + congr 1 + omega + rw [show (-(1:ℝ)/64)*(2:ℕ)=-(1:ℝ)/32 by norm_num] + calc + _ = H^(-(1:ℝ)/32)*q^2*(M^2*M^(2*Fintype.card {w : V // w≠v})) := by ring + _ = _ := by rw [hpow] + rw [he] at hc + exact (sq_le_sq₀ (abs_nonneg _) (by positivity)).mp (by simpa only [sq_abs] using hc) + have ht := multilinearIntegral_telescope L F G (fun _ => H^(-(1:ℝ)/64)*q*M^(Fintype.card V)) hs + simpa only [sum_const,card_univ,nsmul_eq_mul,mul_assoc] using ht + +end SquareDifference + +namespace LiftAnalysis + +namespace SquareDifference + +open Finset + +lemma uniform_lift_moment_constant (r : ℕ) (hr : 1≤r) (ε : ℝ) (hε : 0<ε) : + ∃C : ℝ,0 (p i).Coprime (p j)) → Function.Injective p → + ∀(F : Finset (Finset J)) (Q : ℕ),0 ∏j∈U,p j≤Q) + +noncomputable def truncatedLift (L Q : ℕ) (f : ℕ → ℝ) (x : ResidueSpace p) : ℝ := + ∑U∈supportFamily p Q,liftPiece p L f U x + +noncomputable def remainingFamily (B : Finset J) (H : ℕ) : Finset (Finset J) := + univ.filter (fun U => Disjoint U B ∧ ∏j∈U,p j≤H) + +lemma primeProduct_pos {J : Type*} + [Fintype J] + [DecidableEq J] + (p : J → ℕ) + [∀ (j : J), NeZero (p j)] (U : Finset J) : 0<∏j∈U,p j := + prod_pos (fun _ _ => Nat.pos_of_ne_zero (NeZero.ne _)) + +lemma primeProduct_mono {U W : Finset J} (h : U⊆W) : (∏j∈U,p j)≤∏j∈W,p j := + Nat.le_of_dvd (primeProduct_pos p W) (prod_dvd_prod_of_subset U W p h) + +lemma primeProduct_split {J : Type*} + [Fintype J] + [DecidableEq J] + (p : J → ℕ) + [∀ (j : J), NeZero (p j)] (T B : Finset J) : (∏j∈T,p j)=(∏j∈T\B,p j)*(∏j∈T∩B,p j) := by + rw [←prod_union (disjoint_sdiff_inter T B),sdiff_union_inter] + +lemma remaining_complete_sum {E : Type*} [AddCommMonoid E] (B : Finset J) (Q H : ℕ) + (hHQ : H*(∏j∈B,p j)≤Q) (f : Finset J → E) : + (∑T∈(supportFamily p Q).filter (fun T => ∏j∈T\B,p j≤H),f T)= + ∑U∈remainingFamily p B H,∑W∈B.powerset,f (U∪W) := by + rw [←sum_product' (remainingFamily p B H) B.powerset (fun U W => f (U∪W))] + apply sum_bij (fun T _ => (T\B,T∩B)) + · intro T hT + obtain ⟨_,hTH⟩ := mem_filter.mp hT + apply mem_product.mpr + refine ⟨?_,mem_powerset.mpr inter_subset_right⟩ + simp only [remainingFamily,mem_filter,mem_univ,true_and] + exact ⟨sdiff_disjoint,hTH⟩ + · intro T hT U hU he + have h1 := congrArg Prod.fst he + have h2 := congrArg Prod.snd he + dsimp only at h1 h2 + have et : (T\B)∪(T∩B)=T := sdiff_union_inter T B + have eu : (U\B)∪(U∩B)=U := sdiff_union_inter U B + rw [←et,←eu,h1,h2] + · rintro ⟨U,W⟩ hUW + obtain ⟨hU,hW⟩ := mem_product.mp hUW + obtain ⟨hUB,hUH⟩ : Disjoint U B ∧ ∏j∈U,p j≤H := by + simpa only [remainingFamily,mem_filter,mem_univ,true_and] using hU + have hWB := mem_powerset.mp hW + have hdiff : (U∪W)\B=U := by + ext j; simp only [mem_sdiff,mem_union] + constructor + · rintro ⟨h,hB⟩; exact h.resolve_right (fun hW => hB (hWB hW)) + · intro hU; exact ⟨Or.inl hU,disjoint_left.mp hUB hU⟩ + have hinter : (U∪W)∩B=W := by + ext j; simp only [mem_inter,mem_union] + constructor + · rintro ⟨h,hB⟩; exact h.resolve_left (fun hU => disjoint_left.mp hUB hU hB) + · intro hW; exact ⟨Or.inr hW,hWB hW⟩ + refine ⟨U∪W,?_,Prod.ext hdiff hinter⟩ + simp only [mem_filter,supportFamily,mem_univ,true_and,hdiff] + refine ⟨?_,hUH⟩ + rw [prod_union (hUB.mono_right hWB)] + exact (Nat.mul_le_mul hUH (primeProduct_mono p hWB)).trans hHQ + · intro T _ + congr 1 + exact (sdiff_union_inter T B).symm + +lemma frozen_low_lift_identity (L Q H : ℕ) (f : ℕ → ℝ) (B : Finset J) + (hHQ : H*(∏j∈B,p j)≤Q) (z x : ResidueSpace p) : + (∑T∈(supportFamily p Q).filter (fun T => ∏j∈T\B,p j≤H), + liftPiece p L f T (coordinateFreeze p B z x))= + ((∏j∈B,p j : ℝ)/(L : ℝ))*∑U∈remainingFamily p B H,∑n∈range L, + if ∀j∈B,(n : ZMod (p j))=z j then + f n*exactGate p U (x-fun j => (n : ZMod (p j))) else 0 := by + rw [remaining_complete_sum p B Q H hHQ] + simp only [mul_sum] + apply sum_congr rfl + intro U hU + have hUB : Disjoint U B := (mem_filter.mp hU).2.1 + simpa only [mul_sum] using liftPiece_frozen_complete p L f U B hUB z x + +lemma exactGate_square_progression_on (U : Finset J) (u : ∀j,(ZMod (p j))ˣ) + (D c t : ℕ) (hu : ∀j∈U,(u j : ZMod (p j))=(D : ZMod (p j))^2) + (x : ResidueSpace p) : + exactGate p U (x-fun j => ((c+D^2*t : ℕ) : ZMod (p j)))= + exactGate p U ((fun j => ((u j)⁻¹ : (ZMod (p j))ˣ)*(x j-(c : ZMod (p j))))- + fun j => (t : ZMod (p j))) := by + calc + _ = exactGate p U (x-fun j => (c : ZMod (p j))+(u j : ZMod (p j))*(t : ZMod (p j))) := by + apply prod_congr rfl + intro j hj + simp only [Pi.sub_apply,Nat.cast_add,Nat.cast_mul,Nat.cast_pow,hu j hj] + _ = _ := exactGate_affine p U u x (fun j => (c : ZMod (p j))) (fun j => (t : ZMod (p j))) + +lemma fiber_squareStep_lift_on (N D L a : ℕ) (hD : 0 (n : ZMod (p j))) else 0)= + ((D : ℝ)*(L : ℝ)/(N : ℝ))*∑j∈range D, + liftPiece p L (fun t => f (a+D*j+D^2*t)) U + (fun k => ((u k)⁻¹ : (ZMod (p k))ˣ)*(x k-((a+D*j : ℕ) : ZMod (p k)))) := by + rw [squareStep_padded_sum (fun n => f n*exactGate p U (x-fun j => (n : ZMod (p j)))) + N D L a hD ha hNL (fun n hn => by rw [hf n hn,zero_mul])] + simp only [liftPiece,exactGate_square_progression_on p U u D _ _ hu,←mul_sum] + have hL0 : (L : ℝ)≠0 := Nat.cast_ne_zero.mpr (Nat.ne_of_gt hL) + field_simp + +end ActualLift + +end SquareDifference + +end LiftAnalysis + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SquareDifference/ResidueReindex.lean b/lean/OAI/Combinatorics/SquareDifference/ResidueReindex.lean new file mode 100644 index 0000000000000000000000000000000000000000..893d0c750d8fb632b40542ce47df196ff96d1762 --- /dev/null +++ b/lean/OAI/Combinatorics/SquareDifference/ResidueReindex.lean @@ -0,0 +1,144 @@ +import OAI.Combinatorics.SquareDifference.SelectedPair + +namespace OAI + +section + +open Finset + +open scoped BigOperators ComplexConjugate + +namespace SquareDifference + +open LiftTheory.SquareDifference + +section Reindex + +variable {J K : Type*} [instFintypeJ : Fintype J] [instDecidableEqJ : DecidableEq J] [instFintypeK : Fintype K] [instDecidableEqK : DecidableEq K] + (p : J → ℕ) (m : K → ℕ) [instNeZeropj : ∀j,NeZero (p j)] [∀k,NeZero (m k)] + (e : K ≃ J) (hm : m=fun k => p (e k)) + +noncomputable def residueReindex : ResidueSpace p ≃ ResidueSpace m := by + subst m + exact (Equiv.piCongrLeft (fun j => ZMod (p j)) e).symm + +lemma residueReindex_neg {J : Type*} + {K : Type*} + [Fintype J] + [DecidableEq J] + [Fintype K] + [DecidableEq K] + (p : J → ℕ) + (m : K → ℕ) + [∀ (j : J), NeZero (p j)] + [∀ (k : K), NeZero (m k)] + (e : K ≃ J) + (hm : m = fun k => p (e k)) (a : ResidueSpace p) : + residueReindex p m e hm (-a)= -residueReindex p m e hm a := by + subst m + rfl + +lemma residueReindex_natCast {J : Type*} + {K : Type*} + [Fintype J] + [DecidableEq J] + [Fintype K] + [DecidableEq K] + (p : J → ℕ) + (m : K → ℕ) + [∀ (j : J), NeZero (p j)] + [∀ (k : K), NeZero (m k)] + (e : K ≃ J) + (hm : m = fun k => p (e k)) (n : ℕ) : + residueReindex p m e hm (fun j => (n:ZMod (p j)))=(fun k => (n:ZMod (m k))) := by + subst m + rfl + +lemma prodChar_reindex {J : Type*} + {K : Type*} + [Fintype J] + [DecidableEq J] + [Fintype K] + [DecidableEq K] + (p : J → ℕ) + (m : K → ℕ) + [∀ (j : J), NeZero (p j)] + [∀ (k : K), NeZero (m k)] + (e : K ≃ J) + (hm : m = fun k => p (e k)) (a x : ResidueSpace p) : + prodChar m (residueReindex p m e hm a) (residueReindex p m e hm x)=prodChar p a x := by + subst m + exact Fintype.prod_equiv e _ _ (fun _ => rfl) + +lemma supportDenominator_reindex {J : Type*} + {K : Type*} + [Fintype J] + [DecidableEq J] + [Fintype K] + [DecidableEq K] + (p : J → ℕ) + (m : K → ℕ) + [∀ (j : J), NeZero (p j)] + [∀ (k : K), NeZero (m k)] + (e : K ≃ J) + (hm : m = fun k => p (e k)) (a : ResidueSpace p) : + supportDenominator m (residueReindex p m e hm a)=supportDenominator p a := by + subst m + simp only [supportDenominator,primeSupport,prod_filter] + exact Fintype.prod_equiv e _ _ (fun _ => rfl) + +lemma residueFourier_reindex (F : ResidueSpace p → ℂ) (a : ResidueSpace p) : + residueFourier m (fun x => F ((residueReindex p m e hm).symm x)) (residueReindex p m e hm a)= + residueFourier p F a := by + symm + apply Fintype.expect_equiv (residueReindex p m e hm) + intro x + simp only [Equiv.symm_apply_apply,prodChar_reindex] + +lemma squareMultiplier_reindex (a : ResidueSpace p) : + squareMultiplier m (residueReindex p m e hm a)=squareMultiplier p a := by + subst m + unfold squareMultiplier + let u := (Equiv.piCongrLeft (fun j => (ZMod (p j))ˣ) e).symm + have hu : (𝔼 x : ∀j,(ZMod (p j))ˣ, + prodChar (fun k => p (e k)) (residueReindex p (fun k => p (e k)) e rfl a) + (fun k => (x (e k):ZMod (p (e k)))^2))= + 𝔼 y : ∀k,(ZMod (p (e k)))ˣ, + prodChar (fun k => p (e k)) (residueReindex p (fun k => p (e k)) e rfl a) + (fun k => (y k:ZMod (p (e k)))^2) := + Fintype.expect_equiv u _ _ (fun _ => rfl) + rw [←hu] + apply expect_congr rfl + intro x _ + unfold prodChar + exact Fintype.prod_equiv e _ _ (fun _ => rfl) + +lemma sequenceResidueFourier_reindex {Ω : Type*} [Fintype Ω] + (N : ℕ) (F : Ω → ℂ) (n : Ω → ℕ) (a : ResidueSpace p) : + sequenceResidueFourier m N F n (residueReindex p m e hm a)=sequenceResidueFourier p N F n a := by + unfold sequenceResidueFourier + congr 1 + apply sum_congr rfl + intro x _ + rw [←residueReindex_natCast p m e hm,prodChar_reindex] + +lemma low_pair_reindex (F G : ResidueSpace p → ℂ) (H : ℝ) : + (∑a∈univ.filter (fun a => (supportDenominator m a:ℝ)≤H), + residueFourier m (fun x => F ((residueReindex p m e hm).symm x)) (-a)* + residueFourier m (fun x => G ((residueReindex p m e hm).symm x)) a*squareMultiplier m a)= + ∑a∈univ.filter (fun a => (supportDenominator p a:ℝ)≤H), + residueFourier p F (-a)*residueFourier p G a*squareMultiplier p a := by + simp only [sum_filter] + symm + apply Fintype.sum_equiv (residueReindex p m e hm) + intro a + rw [supportDenominator_reindex,←residueReindex_neg,residueFourier_reindex, + residueFourier_reindex,squareMultiplier_reindex] + +end Reindex + +end SquareDifference + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SquareDifference/RootModels.lean b/lean/OAI/Combinatorics/SquareDifference/RootModels.lean new file mode 100644 index 0000000000000000000000000000000000000000..e5f445fe6c7e98d53bff80690d425e4e091d05ab --- /dev/null +++ b/lean/OAI/Combinatorics/SquareDifference/RootModels.lean @@ -0,0 +1,581 @@ +import OAI.Combinatorics.SquareDifference.ConductorBounds + +namespace OAI + +section +open Finset +open scoped ComplexConjugate BigOperators +open Filter +open scoped Topology +open Finset Complex +open scoped BigOperators ComplexConjugate +namespace LiftTheory +open Finset +open scoped BigOperators InnerProductSpace ComplexConjugate +namespace SquareDifference + +lemma truncatedSieveMean_bound {I : Type*} [DecidableEq I] + (S : Finset I) (p : I → ℕ) (H : ℝ) (a b : I → ℂ) (k : I → ℝ) + (ha : ∀i∈S, ‖a i‖≤k i) (hb : ∀i∈S, ‖b i‖≤k i) : + ‖truncatedSieveMean S p H a b‖≤(2 : ℝ)^S.card*∏i∈S, k i := by + unfold truncatedSieveMean + calc + _ ≤ ∑T∈S.powerset, ∏i∈S, k i := by + apply (norm_sum_le _ _).trans + apply sum_le_sum + intro T hT + split_ifs + · exact localSieveTerm_norm S T (mem_powerset.mp hT) a b k ha hb + · rw [norm_zero] + exact prod_nonneg (fun i hi => (norm_nonneg _).trans (ha i hi)) + _ = _ := by simp only [sum_const,nsmul_eq_mul,card_powerset,Nat.cast_pow,Nat.cast_ofNat] + +lemma truncatedSieveMean_complete {I : Type*} [DecidableEq I] + (S : Finset I) (p : I → ℕ) (H : ℝ) (a b : I → ℂ) + (hp : ∀i∈S, 1≤p i) (hH : ((∏i∈S, p i : ℕ) : ℝ)≤H) : + truncatedSieveMean S p H a b=∏i∈S, (a i-b i) := by + unfold truncatedSieveMean + calc + _ = ∑T∈S.powerset, localSieveTerm S a b T := by + apply sum_congr rfl + intro T hT + rw [ite_eq_left] + apply le_trans _ hH + exact_mod_cast prod_le_prod_of_subset_of_one_le₀ (mem_powerset.mp hT) + (fun _ _ => Nat.zero_le _) (fun i hi _ => hp i hi) + _ = _ := (prod_sub a b S).symm + +lemma localSieveTerm_product {I : Type*} [DecidableEq I] + (S T : Finset I) (hTS : T⊆S) (a b : I → ℂ) : + localSieveTerm S a b T=(-1 : ℂ)^T.card*∏i∈S, if i∈T then b i else a i := by + dsimp only [localSieveTerm] + rw [prod_ite] + have h1 : S.filter (fun i => i∈T)=T := by ext i; simp only [mem_filter]; exact ⟨And.right,fun h => ⟨hTS h,h⟩⟩ + have h2 : S.filter (fun i => i∉T)=S\T := by ext i; simp + rw [h1,h2] + ring + +lemma localSieveTerm_zero {I : Type*} [DecidableEq I] + (S U T : Finset I) (a b : I → ℂ) (hTU : ¬T⊆U) + (hb : ∀i∈T, i∉U → b i=0) : localSieveTerm S a b T=0 := by + obtain ⟨i,hi,hiU⟩ := not_subset.mp hTU + rw [localSieveTerm,prod_eq_zero hi (hb i hi hiU),mul_zero] + +lemma quadratic_sieve_bounds {p q : ℕ} [Fact p.Prime] [NeZero q] + (hpq : p∣q) (hq : IsUnit (2 : ZMod q)) + (ψ : AddChar (ZMod q) ℂ) (hψ : ψ.IsPrimitive) : + ‖𝔼 x : ZMod q, ψ (x^2)‖≤(q : ℝ)^(-(1 : ℝ)/2) ∧ + ‖𝔼 x : ZMod q, + (primeSieveWeight p (ZMod.castHom hpq (ZMod p) x) : ℂ)*ψ (x^2)‖≤ + (q : ℝ)^(-(1 : ℝ)/2) := by + constructor + · simpa only [mul_one,one_mul,ZMod.card] using + (hasFourierBound_one ψ).gauss hψ 1 (by simpa only [mul_one] using hq) + · simpa only [mul_one,one_mul,ZMod.card] using + (primeSieveWeight_fourier_dvd hpq ψ hψ).gauss hψ 1 (by simpa only [mul_one] using hq) + +lemma nonprime_sieve_mean_zero {p q : ℕ} [Fact p.Prime] [NeZero q] (hpq : p∣q) : + (𝔼 x : ZMod q, (primeSieveWeight p (ZMod.castHom hpq (ZMod p) x) : ℂ))=0 := by + have h := expect_surjective_addHom (ZMod.castHom hpq (ZMod p)).toAddMonoidHom + (ZMod.ringHom_surjective _) (fun x => (primeSieveWeight p x : ℂ)) + change (𝔼 x : ZMod q, (primeSieveWeight p (ZMod.castHom hpq (ZMod p) x) : ℂ))= + (𝔼 x : ZMod p, (primeSieveWeight p x : ℂ)) at h + rw [h] + have hz := primeSieveWeight_mean_zero (p := p) + exact_mod_cast hz + +noncomputable def unitQuadraticMean {R : Type*} [CommRing R] [Fintype R] + [DecidableEq R] (ψ : AddChar R ℂ) : ℂ := 𝔼 x : Rˣ, ψ ((x : R)^2) + +lemma prime_unit_quadratic {p : ℕ} [Fact p.Prime] (ψ : AddChar (ZMod p) ℂ) : + (𝔼 x : ZMod p, ψ (x^2))- + (𝔼 x : ZMod p, (primeSieveWeight p x : ℂ)*ψ (x^2))=unitQuadraticMean ψ := by + classical + have he (x : ZMod p) : ψ (x^2)-(primeSieveWeight p x : ℂ)*ψ (x^2)= + ((p : ℂ)/(p-1))*(if x≠0 then ψ (x^2) else 0) := by + have hh := congrArg (fun z : ℝ => (z : ℂ)) (primeSieveWeight_unit_density x) + push_cast at hh + calc + _ = (1-(primeSieveWeight p x : ℂ))*ψ (x^2) := by ring + _ = _ := by rw [hh]; split_ifs <;> simp only [Complex.ofReal_one,Complex.ofReal_zero] <;> ring + rw [← expect_sub_distrib] + simp_rw [he] + rw [← mul_expect] + have hs : (∑x : ZMod p, if x≠0 then ψ (x^2) else 0)= + ∑x : (ZMod p)ˣ, ψ ((x : ZMod p)^2) := by + rw [← sum_filter] + rw [sum_subtype (p := fun x : ZMod p => x≠0) _ (by intro x; simp only [mem_filter,mem_univ,true_and])] + symm + exact Fintype.sum_equiv unitsEquivNeZero _ _ (fun _ => rfl) + rw [expect_eq_sum_div_card,hs,unitQuadraticMean,expect_eq_sum_div_card] + simp only [Finset.card_univ,Fintype.card_units,ZMod.card] + have hp : (p : ℂ)≠0 := by exact_mod_cast (Fact.out : p.Prime).ne_zero + have hp1 : (1 : ℕ)≤p := (Fact.out : p.Prime).one_lt.le + rw [Nat.cast_sub hp1,Nat.cast_one] + field_simp + +lemma prime_power_sieved_zero {p k : ℕ} [Fact p.Prime] [NeZero k] + (hp : p≠2) (hpk : p∣k) (ψ : AddChar (ZMod (p*k)) ℂ) (hψ : ψ.IsPrimitive) : + (𝔼 x : ZMod (p*k), ψ (x^2))- + (𝔼 x : ZMod (p*k), + (primeSieveWeight p (ZMod.castHom (dvd_mul_right p k) (ZMod p) x) : ℂ)*ψ (x^2))=0 := by + classical + have he (x : ZMod (p*k)) : + ψ (x^2)-(primeSieveWeight p (ZMod.castHom (dvd_mul_right p k) (ZMod p) x) : ℂ)*ψ (x^2)= + ((p : ℂ)/(p-1))* + ((if ZMod.castHom (dvd_mul_right p k) (ZMod p) x≠0 then (1 : ℂ) else 0)*ψ (x^2)) := by + have hh := congrArg (fun z : ℝ => (z : ℂ)) + (primeSieveWeight_unit_density (ZMod.castHom (dvd_mul_right p k) (ZMod p) x)) + push_cast at hh + calc + _ = (1-(primeSieveWeight p (ZMod.castHom (dvd_mul_right p k) (ZMod p) x) : ℂ))*ψ (x^2) := by ring + _ = _ := by rw [hh]; split_ifs <;> simp only [Complex.ofReal_one,Complex.ofReal_zero] <;> ring + rw [← expect_sub_distrib] + simp_rw [he] + rw [← mul_expect,odd_unit_gauss_zero_char hp hpk ψ hψ,mul_zero] + +lemma two_le_rpow_sixth {x : ℝ} (hx : 64≤x) : 2≤x^((1 : ℝ)/6) := by + have h : (2 : ℝ)≤x^(6 : ℝ)⁻¹ := by + apply (Real.le_rpow_inv_iff_of_pos (by norm_num) (by linarith : 0≤x) (by norm_num)).mpr + norm_num + exact hx + simpa only [one_div] using h + +lemma smallPrime_product_bound (S : Finset ℕ) (a : ℕ → ℕ) + (ha : ∀p∈S, p≤a p) (hp : ∀p∈S, 1≤p) : + (2 : ℝ)^S.card≤2^64*((∏p∈S, (a p : ℝ))^((1 : ℝ)/6)) := by + let K := S.filter (fun p => p<64) + have hK : K⊆range 64 := by intro p hp; exact mem_range.mpr (mem_filter.mp hp).2 + have hcard : K.card≤64 := le_trans (card_le_card hK) (by simp) + have hk0 : ∀p∈S, 0≤(a p : ℝ) := fun _ _ => Nat.cast_nonneg _ + have hle (p : ℕ) (hps : p∈S) : (2 : ℝ)≤ + (if p<64 then (2 : ℝ) else 1)*(a p : ℝ)^((1 : ℝ)/6) := by + split_ifs with h + · have h1 : (1 : ℝ)≤(a p : ℝ)^((1 : ℝ)/6) := + Real.one_le_rpow (by exact_mod_cast (hp p hps).trans (ha p hps)) (by norm_num) + linarith + · rw [one_mul] + apply two_le_rpow_sixth + exact_mod_cast (le_trans (Nat.le_of_not_gt h) (ha p hps)) + calc + _ = ∏p∈S, (2 : ℝ) := (prod_const 2).symm + _ ≤ ∏p∈S, (if p<64 then (2 : ℝ) else 1)*(a p : ℝ)^((1 : ℝ)/6) := + Finset.prod_le_prod₀ (by intros; norm_num) hle + _ = (2 : ℝ)^K.card*(∏p∈S, (a p : ℝ))^((1 : ℝ)/6) := by + rw [prod_mul_distrib,prod_ite] + simp only [prod_const,one_pow,mul_one] + rw [Real.finsetProd_rpow _ _ (fun p hp => hk0 p hp)] + _ ≤ _ := mul_le_mul_of_nonneg_right (pow_le_pow_right₀ (by norm_num) hcard) + (Real.rpow_nonneg (prod_nonneg hk0) _) + +lemma truncatedSieveMean_decay (S : Finset ℕ) (a : ℕ → ℕ) (H : ℝ) (A B : ℕ → ℂ) + (ha : ∀p∈S, p≤a p) (hp : ∀p∈S, 1≤p) + (hA : ∀p∈S, ‖A p‖≤(a p : ℝ)^(-(1 : ℝ)/2)) + (hB : ∀p∈S, ‖B p‖≤(a p : ℝ)^(-(1 : ℝ)/2)) : + ‖truncatedSieveMean S id H A B‖≤2^64*(∏p∈S, (a p : ℝ))^(-(1 : ℝ)/3) := by + have hpos (p : ℕ) (hps : p∈S) : (0 : ℝ) (hpos p hp).le)] + calc + _ ≤ (2^64*(∏p∈S, (a p : ℝ))^((1 : ℝ)/6))*(∏p∈S, (a p : ℝ))^(-(1 : ℝ)/2) := + mul_le_mul_of_nonneg_right (smallPrime_product_bound S a ha hp) (Real.rpow_nonneg hprod.le _) + _ = _ := by rw [mul_assoc,← Real.rpow_add hprod]; norm_num + +end SquareDifference + +namespace SquareDifference + +open scoped ComplexConjugate + +lemma prime_unit_mean_decay {p : ℕ} [Fact p.Prime] (hp : 64≤p) + (a : ZMod p) (ha : a≠0) : + ‖𝔼 u : (ZMod p)ˣ,ZMod.stdAddChar (a*(u : ZMod p)^2)‖≤(p : ℝ)^(-(1:ℝ)/3) := by + let ψ := (ZMod.stdAddChar (N:=p)).mulShift a + have hψ : ψ.IsPrimitive := AddChar.IsPrimitive.of_ne_one (ZMod.isPrimitive_stdAddChar p ha) + have htwo : IsUnit (2 : ZMod p) := by + apply isUnit_iff_ne_zero.mpr + intro hz + have hd := (ZMod.natCast_eq_zero_iff (2:ℕ) p).mp (by simpa using hz) + have := Nat.le_of_dvd (by decide : 0<2) hd + omega + have hb := quadratic_sieve_bounds (p:=p) (q:=p) (dvd_refl p) htwo ψ hψ + simp only [ZMod.castHom_self,RingHom.id_apply] at hb + have he := prime_unit_quadratic ψ + have hle : ‖unitQuadraticMean ψ‖≤2*(p:ℝ)^(-(1:ℝ)/2) := by + rw [← he] + exact (norm_sub_le _ _).trans (by linarith [hb.1,hb.2]) + have hp0 : (0:ℝ)

(p j:ℝ)) (fun j _ => Nat.cast_nonneg (p j))] + apply Finset.prod_le_prod₀ (fun _ _ => norm_nonneg _) + intro j hj + exact prime_unit_mean_decay (hp j) (a j) (by simpa [primeSupport] using hj) + +lemma squarePair_tail_bound (hp : ∀j,64≤p j) (F G : ResidueSpace p → ℂ) + (H : ℝ) (hH : 0 H<(supportDenominator p a:ℝ)), + residueFourier p F (-a)*residueFourier p G a*squareMultiplier p a‖^2≤ + H^(-(2:ℝ)/3)*(𝔼 x,‖F x‖^2)*(𝔼 x,‖G x‖^2) := by + have he : (H^(-(1:ℝ)/3))^2=H^(-(2:ℝ)/3) := by + rw [← Real.rpow_mul_natCast hH.le]; congr 1 ; norm_num + rw [← he] + apply fourier_pair_tail p F G _ _ _ (by positivity) + intro a ha + apply (squareMultiplier_decay p hp a).trans + exact Real.rpow_le_rpow_of_nonpos hH (mem_filter.mp ha).2.le (by norm_num) + +end PairTail + +end SquareDifference + +namespace SquareDifference + +open Finset + +section RootModel + +variable {I : Type*} [instFintypeI : Fintype I] [instDecidableEqI : DecidableEq I] + (m : I → ℕ) [∀i,NeZero (m i)] (R : Finset I) + +abbrev OutsideModulus : {i : I // i∉R} → ℕ := fun i => m i.val + +noncomputable def rootCharacter (a s : ResidueSpace m) : ℂ := + ∏i∈R,ZMod.stdAddChar (a i*s i) + +def outsideCoordinate (a : ResidueSpace m) : ResidueSpace (OutsideModulus m R) := fun i => a i.val + +lemma prodChar_split (a x : ResidueSpace m) : + prodChar m a x=rootCharacter m R a x* + prodChar (OutsideModulus m R) (outsideCoordinate m R a) (outsideCoordinate m R x) := by + unfold prodChar rootCharacter outsideCoordinate OutsideModulus + rw [← prod_subtype Rᶜ (fun i => mem_compl) (fun i => ZMod.stdAddChar (a i*x i))] + rw [prod_mul_prod_compl] + +lemma rootCharacter_neg {I : Type*} + [Fintype I] + [DecidableEq I] + (m : I → ℕ) + [∀ (i : I), NeZero (m i)] + (R : Finset I) (a s : ResidueSpace m) : + rootCharacter m R (-a) s=conj (rootCharacter m R a s) := by + simp only [rootCharacter,Pi.neg_apply,neg_mul,AddChar.map_neg_eq_conj,map_prod] + +lemma rootCharacter_diff_cancel (a r s t : ResidueSpace m) + (h : ∀i∈R,r i=t i-s i) : + rootCharacter m R a r*conj (rootCharacter m R (-a) s)* + conj (rootCharacter m R a t)=1 := by + rw [rootCharacter_neg,starRingEnd_self_apply] + simp only [rootCharacter,map_prod,← prod_mul_distrib] + apply prod_eq_one + intro i hi + rw [← AddChar.map_neg_eq_conj,← AddChar.map_add_eq_mul,← AddChar.map_add_eq_mul] + rw [h i hi,show a i*(t i-s i)+a i*s i+-(a i*t i)=0 by ring,AddChar.map_zero_eq_one] + +lemma sum_outside_coordinate {E : Type*} [AddCommMonoid E] + (f : ResidueSpace (OutsideModulus m R) → E) : + (∑a : ResidueSpace m,f (outsideCoordinate m R a))= + (∏i∈R,m i) • ∑b,f b := by + classical + let e := Equiv.piEquivPiSubtypeProd (fun i : I => i∈R) (fun i => ZMod (m i)) + rw [Fintype.sum_equiv e (fun a => f (outsideCoordinate m R a)) (fun b => f b.2) (fun _ => rfl),Fintype.sum_prod_type] + simp only [sum_const,card_univ,Fintype.card_pi,ZMod.card] + congr 1 + exact (prod_subtype R (fun _ => Iff.rfl) m).symm + +noncomputable def sequenceResidueFourier {Ω : Type*} [Fintype Ω] + (L : ℕ) (F : Ω → ℂ) (n : Ω → ℕ) (a : ResidueSpace m) : ℂ := + (L : ℂ)⁻¹*∑z,F z*conj (prodChar m a (fun i => (n z : ZMod (m i)))) + +lemma sequenceResidueFourier_root {Ω : Type*} [Fintype Ω] + (L : ℕ) (F : Ω → ℂ) (n : Ω → ℕ) (s a : ResidueSpace m) + (hF : ∀z,F z≠0 → ∀i∈R,(n z : ZMod (m i))=s i) : + sequenceResidueFourier m L F n a=conj (rootCharacter m R a s)* + sequenceResidueFourier (OutsideModulus m R) L F n (outsideCoordinate m R a) := by + unfold sequenceResidueFourier + simp only [prodChar_split m R,map_mul,mul_sum] + apply sum_congr rfl + intro z _ + by_cases hz : F z=0 + · simp [hz] + · have he : rootCharacter m R a (fun i => (n z : ZMod (m i)))=rootCharacter m R a s := by + apply prod_congr rfl + intro i hi + change ZMod.stdAddChar (a i*(n z : ZMod (m i)))=_ + rw [hF z hz i hi] + rw [he] + ring_nf + rfl + +lemma root_model_sum {Ω : Type*} [Fintype Ω] + (L : ℕ) (F G : Ω → ℂ) (n : Ω → ℕ) + (s t r : ResidueSpace m) (hr : ∀i∈R,r i=t i-s i) + (hF : ∀z,F z≠0 → ∀i∈R,(n z : ZMod (m i))=s i) + (hG : ∀z,G z≠0 → ∀i∈R,(n z : ZMod (m i))=t i) + (c : ResidueSpace (OutsideModulus m R) → ℂ) : + (∑a : ResidueSpace m,rootCharacter m R a r*c (outsideCoordinate m R a)* + sequenceResidueFourier m L F n (-a)*sequenceResidueFourier m L G n a)= + ((∏i∈R,m i : ℕ):ℂ)*∑b,c b* + sequenceResidueFourier (OutsideModulus m R) L F n (-b)* + sequenceResidueFourier (OutsideModulus m R) L G n b := by + have he (a : ResidueSpace m) : rootCharacter m R a r*c (outsideCoordinate m R a)* + sequenceResidueFourier m L F n (-a)*sequenceResidueFourier m L G n a= + c (outsideCoordinate m R a)* + sequenceResidueFourier (OutsideModulus m R) L F n (-(outsideCoordinate m R a))* + sequenceResidueFourier (OutsideModulus m R) L G n (outsideCoordinate m R a) := by + rw [sequenceResidueFourier_root m R L F n s (-a) hF, + sequenceResidueFourier_root m R L G n t a hG] + have hn : outsideCoordinate m R (-a)=-(outsideCoordinate m R a) := rfl + rw [hn] + calc + _ = (rootCharacter m R a r*conj (rootCharacter m R (-a) s)* + conj (rootCharacter m R a t))*(c (outsideCoordinate m R a)* + sequenceResidueFourier (OutsideModulus m R) L F n (-(outsideCoordinate m R a))* + sequenceResidueFourier (OutsideModulus m R) L G n (outsideCoordinate m R a)) := by ring + _ = _ := by rw [rootCharacter_diff_cancel m R a r s t hr,one_mul] + simp_rw [he] + rw [sum_outside_coordinate m R (fun b => c b* + sequenceResidueFourier (OutsideModulus m R) L F n (-b)* + sequenceResidueFourier (OutsideModulus m R) L G n b)] + simp only [nsmul_eq_mul] + +end RootModel + +end SquareDifference + +end LiftTheory + +namespace SquareDifference + +open Finset + +open scoped ComplexConjugate + +section ModelPair + +variable {I : Type*} [Fintype I] [DecidableEq I] + (m : I → ℕ) [∀i,NeZero (m i)] + (hcop : Pairwise fun i j => (m i).Coprime (m j)) + +local instance productNonzero : NeZero (∏i,m i) := + ⟨(prod_pos (fun i _ => Nat.pos_of_ne_zero (NeZero.ne (m i)))).ne'⟩ + +lemma grid_phase_char (a : ZMod (∏i,m i)) (n : ℕ) : + expPhase ((n:ℝ)*(rationalGridPoint _ a:ℝ))= + LiftTheory.SquareDifference.prodChar m (dualCRTEquiv m hcop a) (fun i => (n:ZMod (m i))) := by + have he := rationalChar_int (rationalGridPoint _ a) (n:ℤ) + simp only [Int.cast_natCast] at he + rw [show (n:ℝ)*(rationalGridPoint _ a:ℝ)=(rationalGridPoint _ a:ℝ)*(n:ℝ) by ring, ←he] + have hc := congrArg (fun χ : AddChar (ZMod (∏i,m i)) ℂ => χ (n : ZMod (∏i,m i))) (rationalGrid_char (q:=∏i,m i) a) + simp only [AddChar.compAddMonoidHom_apply, RingHom.toAddMonoidHom_eq_coe, AddMonoidHom.coe_coe, map_natCast] at hc + rw [hc] + simpa only [LiftTheory.SquareDifference.prodChar,standardCharEquiv_apply] using dualCRT_nat m hcop a n + +lemma intervalFourier_grid {q : ℕ} [NeZero q] (N : ℕ) (F : ZMod q → ℂ) + (a : ZMod (∏i,m i)) : + intervalFourier N F (rationalGridPoint _ a:ℝ)= + LiftTheory.SquareDifference.sequenceResidueFourier m N F ZMod.val (dualCRTEquiv m hcop a) := by + unfold intervalFourier LiftTheory.SquareDifference.sequenceResidueFourier + congr 1 + apply sum_congr rfl + intro x _ + congr 1 + rw [neg_mul,expPhase_neg,grid_phase_char m hcop] + +lemma intervalFourier_neg_grid {q : ℕ} [NeZero q] (N : ℕ) (F : ZMod q → ℂ) + (a : ZMod (∏i,m i)) : + intervalFourier N F (-(rationalGridPoint _ a:ℝ))= + LiftTheory.SquareDifference.sequenceResidueFourier m N F ZMod.val (-(dualCRTEquiv m hcop a)) := by + unfold intervalFourier LiftTheory.SquareDifference.sequenceResidueFourier + congr 1 + apply sum_congr rfl + intro x _ + congr 1 + rw [neg_mul_neg,grid_phase_char m hcop,LiftTheory.SquareDifference.prodChar_neg,starRingEnd_self_apply] + +end ModelPair + +end SquareDifference + +namespace SquareDifference + +open Finset + +section RootCombination + +variable {I : Type*} [Fintype I] [DecidableEq I] + (m : I → ℕ) [instNeZeromi : ∀i,NeZero (m i)] (R : Finset I) + +lemma root_unit_product (a r : ∀i,ZMod (m i)) : + (∏i,if i∈R then ZMod.stdAddChar (a i*r i) else unitQuadraticMean (standardCharEquiv (a i)))= + LiftTheory.SquareDifference.rootCharacter m R a r* + LiftTheory.SquareDifference.squareMultiplier (LiftTheory.SquareDifference.OutsideModulus m R) + (LiftTheory.SquareDifference.outsideCoordinate m R a) := by + rw [←prod_mul_prod_compl R (fun i => if i∈R then ZMod.stdAddChar (a i*r i) else unitQuadraticMean (standardCharEquiv (a i)))] + congr 1 + · exact prod_congr rfl (fun i hi => ite_eq_left hi) + · rw [LiftTheory.SquareDifference.squareMultiplier_product] + change (∏i∈Rᶜ,if i∈R then ZMod.stdAddChar (a i*r i) else unitQuadraticMean (standardCharEquiv (a i)))= + ∏i : {i : I // i∉R},unitQuadraticMean (standardCharEquiv (a i)) + rw [←prod_subtype Rᶜ (fun i => mem_compl) (fun i => unitQuadraticMean (standardCharEquiv (a i)))] + apply prod_congr rfl + intro i hi + rw [ite_eq_right (mem_compl.mp hi)] + +lemma outside_support_denominator {I : Type*} + [Fintype I] + [DecidableEq I] + (m : I → ℕ) + [∀ (i : I), NeZero (m i)] + (R : Finset I) (a : ∀i,ZMod (m i)) : + LiftTheory.SquareDifference.supportDenominator (LiftTheory.SquareDifference.OutsideModulus m R) + (LiftTheory.SquareDifference.outsideCoordinate m R a)= + ∏i∈Rᶜ.filter (fun i => a i≠0),m i := by + classical + unfold LiftTheory.SquareDifference.supportDenominator LiftTheory.SquareDifference.primeSupport + rw [prod_filter] + change (∏i : {i : I // i∉R}, if a i≠0 then m i else 1)=_ + rw [←prod_subtype Rᶜ (fun i => mem_compl) (fun i => if a i≠0 then m i else 1)] + rw [prod_filter] + +end RootCombination + +section ActualRootCombination + +variable {I : Type*} [Fintype I] [DecidableEq I] + (p : I → ℕ) [∀i,Fact (p i).Prime] (hinj : Function.Injective p) + +lemma small_outside_support (R : Finset I) (htwo : ∀i,p i=2 → i∈R) + (a : ∀i,ZMod (smallQuadraticModulus (p i))) : + LiftTheory.SquareDifference.supportDenominator + (LiftTheory.SquareDifference.OutsideModulus (fun i => smallQuadraticModulus (p i)) R) + (LiftTheory.SquareDifference.outsideCoordinate _ R a)= + ∏i∈Rᶜ.filter (fun i => a i≠0),p i := by + rw [outside_support_denominator] + apply prod_congr rfl + intro i hi + exact ite_eq_right (fun h => mem_compl.mp (mem_filter.mp hi).1 (htwo i h)) + +lemma kernelModelCoefficient_root (a : ZMod (∏i,smallQuadraticModulus (p i))) + (R : Finset I) (c : ∀i,ZMod (p i)) (H : ℝ) + (htwo : ∀i,p i=2 → i∈R) (hc : ∀i∈R,p i=2 → c i=1) : + kernelModelCoefficient p R c H (rationalGridPoint _ a)= + LiftTheory.SquareDifference.rootCharacter (fun i => smallQuadraticModulus (p i)) R + (smallDualEquiv p hinj a) (fun i => smallRootSquare (p i) (c i))* + (if (LiftTheory.SquareDifference.supportDenominator + (LiftTheory.SquareDifference.OutsideModulus (fun i => smallQuadraticModulus (p i)) R) + (LiftTheory.SquareDifference.outsideCoordinate _ R (smallDualEquiv p hinj a)):ℝ)≤H then + LiftTheory.SquareDifference.squareMultiplier + (LiftTheory.SquareDifference.OutsideModulus (fun i => smallQuadraticModulus (p i)) R) + (LiftTheory.SquareDifference.outsideCoordinate _ R (smallDualEquiv p hinj a)) else 0) := by + rw [kernelModelCoefficient_dual p hinj a R c H htwo hc,small_outside_support p R htwo] + split_ifs + · exact root_unit_product _ R _ _ + · exact (mul_zero _).symm + +end ActualRootCombination + +end SquareDifference + +namespace SquareDifference + +open Finset + +section BilinearGrid + +variable {I : Type*} [Fintype I] [DecidableEq I] + (p : I → ℕ) [∀i,Fact (p i).Prime] (hinj : Function.Injective p) + +include hinj + +lemma modelBilinear_grid (R : Finset I) (c : ∀i,ZMod (p i)) (H : ℝ) (L N : ℕ) + (hmodel : (rootSquareModulus p R:ℝ)*H≤L) + (hcover : ∀b : ℚ,b.den≤L → b.den∣∏i,primaryModulus b.den (p i)) + (htwo : ∀i,p i=2 → i∈R) + (hc : ∀i∈R,if p i=2 then c i=1 else c i≠0) + {q : ℕ} [NeZero q] (F G : ZMod q → ℂ) : + (∑b : boundedRationals L,kernelModelCoefficient p R c H b.val* + intervalFourier N F (-(b.val:ℝ))*intervalFourier N G b.val)= + ∑a : ZMod (∏i,smallQuadraticModulus (p i)), + kernelModelCoefficient p R c H (rationalGridPoint _ a)* + intervalFourier N F (-(rationalGridPoint _ a:ℝ))* + intervalFourier N G (rationalGridPoint _ a:ℝ) := by + rw [Finset.sum_coe_sort (boundedRationals L) (fun b : ℚ => + kernelModelCoefficient p R c H b*intervalFourier N F (-(b:ℝ))*intervalFourier N G b)] + apply bounded_sum_grid_of + · intro b hb hh + exact kernelModelCoefficient_den_smallProduct p hinj R c b + (hcover b ((mem_boundedRationals L b).mp hb).2.2) H htwo hc + (left_ne_zero_of_mul (left_ne_zero_of_mul hh)) + · intro b hb hh + have hb' := smallProduct_primary_cover p hinj b ((mem_rationalGrid _ b).mp hb).2.2 + have hne := left_ne_zero_of_mul (left_ne_zero_of_mul hh) + rw [←primaryModelCoefficient_eq_kernelModel p R c hinj b hb' H htwo] at hne + exact_mod_cast (primaryModelCoefficient_denominator_le p hinj b hb' R c H htwo hc hne).trans hmodel + +lemma modelBilinear_root (R : Finset I) (c : ∀i,ZMod (p i)) (H : ℝ) (L N : ℕ) + (hmodel : (rootSquareModulus p R:ℝ)*H≤L) + (hcover : ∀b : ℚ,b.den≤L → b.den∣∏i,primaryModulus b.den (p i)) + (htwo : ∀i,p i=2 → i∈R) + (hc : ∀i∈R,if p i=2 then c i=1 else c i≠0) + {q : ℕ} [NeZero q] (F G : ZMod q → ℂ) + (s t : ∀i,ZMod (smallQuadraticModulus (p i))) + (hr : ∀i∈R,smallRootSquare (p i) (c i)=t i-s i) + (hF : ∀z,F z≠0 → ∀i∈R,(z.val:ZMod (smallQuadraticModulus (p i)))=s i) + (hG : ∀z,G z≠0 → ∀i∈R,(z.val:ZMod (smallQuadraticModulus (p i)))=t i) : + (∑b : boundedRationals L,kernelModelCoefficient p R c H b.val* + intervalFourier N F (-(b.val:ℝ))*intervalFourier N G b.val)= + ((∏i∈R,smallQuadraticModulus (p i):ℕ):ℂ)* + ∑a : LiftTheory.SquareDifference.ResidueSpace + (LiftTheory.SquareDifference.OutsideModulus (fun i => smallQuadraticModulus (p i)) R), + (if (LiftTheory.SquareDifference.supportDenominator + (LiftTheory.SquareDifference.OutsideModulus (fun i => smallQuadraticModulus (p i)) R) a:ℝ)≤H then + LiftTheory.SquareDifference.squareMultiplier + (LiftTheory.SquareDifference.OutsideModulus (fun i => smallQuadraticModulus (p i)) R) a else 0)* + LiftTheory.SquareDifference.sequenceResidueFourier + (LiftTheory.SquareDifference.OutsideModulus (fun i => smallQuadraticModulus (p i)) R) N F ZMod.val (-a)* + LiftTheory.SquareDifference.sequenceResidueFourier + (LiftTheory.SquareDifference.OutsideModulus (fun i => smallQuadraticModulus (p i)) R) N G ZMod.val a := by + rw [modelBilinear_grid p hinj R c H L N hmodel hcover htwo hc] + simp_rw [kernelModelCoefficient_root p hinj _ R c H htwo (fun i hi h => by simpa only [h,ite_true] using hc i hi), + intervalFourier_grid (fun i => smallQuadraticModulus (p i)) + (smallQuadraticModuli_pairwise p (fun i => Fact.out) hinj), + intervalFourier_neg_grid (fun i => smallQuadraticModulus (p i)) + (smallQuadraticModuli_pairwise p (fun i => Fact.out) hinj)] + have hh := LiftTheory.SquareDifference.root_model_sum (fun i => smallQuadraticModulus (p i)) R N F G ZMod.val s t + (fun i => smallRootSquare (p i) (c i)) hr hF hG + (fun a => if (LiftTheory.SquareDifference.supportDenominator + (LiftTheory.SquareDifference.OutsideModulus (fun i => smallQuadraticModulus (p i)) R) a:ℝ)≤H then + LiftTheory.SquareDifference.squareMultiplier + (LiftTheory.SquareDifference.OutsideModulus (fun i => smallQuadraticModulus (p i)) R) a else 0) + apply Eq.trans _ hh + exact Fintype.sum_equiv (smallDualEquiv p hinj) _ _ (fun a => rfl) + +end BilinearGrid + +end SquareDifference + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SquareDifference/ScaleTransfer.lean b/lean/OAI/Combinatorics/SquareDifference/ScaleTransfer.lean new file mode 100644 index 0000000000000000000000000000000000000000..c96ab973391f590cec78dbec45e0d14fcaa425d8 --- /dev/null +++ b/lean/OAI/Combinatorics/SquareDifference/ScaleTransfer.lean @@ -0,0 +1,537 @@ +import OAI.Combinatorics.SquareDifference.ResidueLift + +namespace OAI + +section +open Finset +open scoped BigOperators + +namespace SquareDifference + +open Finset + +section Projections + +variable {J : Type*} [instFintypeJ : Fintype J] [DecidableEq J] + {X : J → Type*} [∀j,Fintype (X j)] [instNonemptyXj : ∀j,Nonempty (X j)] [instDecidableEqXj : ∀j,DecidableEq (X j)] + +lemma ExactSupport.freeze_disjoint {J : Type*} + [Fintype J] + [DecidableEq J] + {X : J → Type*} + [(j : J) → Fintype (X j)] + [∀ (j : J), Nonempty (X j)] + [(j : J) → DecidableEq (X j)] (U B : Finset J) (f : (∀j,X j) → ℝ) + (hf : ExactSupport U f) (hUB : Disjoint U B) (z x : ∀j,X j) : + f (freezeCoordinates B z x)=f x := by + induction B using Finset.induction_on with + | empty => rfl + | @insert j B hj ih => + have hjU : j∉U := fun hjU => disjoint_left.mp hUB hjU (mem_insert_self _ _) + have hUB' := hUB.mono_right (subset_insert j B) + have he : freezeCoordinates (insert j B) z x=Function.update (freezeCoordinates B z x) j (z j) := by + ext i + by_cases hij : i=j + · subst i; simp [freezeCoordinates] + · simp [freezeCoordinates,hij] + rw [he,hf.2 j hjU] + exact ih hUB' + +lemma ExactSupport.project (U B : Finset J) (f : (∀j,X j) → ℝ) + (hf : ExactSupport U f) (x : ∀j,X j) : + (𝔼 z,f (freezeCoordinates B z x))=if Disjoint U B then f x else 0 := by + classical + by_cases hUB : Disjoint U B + · simp only [hUB,ite_true,hf.freeze_disjoint U B f hUB,Fintype.expect_const] + · rw [ite_eq_right hUB] + obtain ⟨j,hjU,hjB⟩ := not_disjoint_iff.mp hUB + rw [←expect_update_dep j (fun z => f (freezeCoordinates B z x))] + have he (z : ∀j,X j) (t : X j) : freezeCoordinates B (Function.update z j t) x= + Function.update (freezeCoordinates B z x) j t := by + ext i + by_cases hij : i=j + · subst i; simp [freezeCoordinates,hjB] + · simp [freezeCoordinates,hij] + simp only [he,hf.1 j hjU,Fintype.expect_const] + +end Projections + +section GroupProjection + +variable {J : Type*} [Fintype J] [DecidableEq J] + {X : J → Type*} [∀j,Fintype (X j)] [∀j,AddCommGroup (X j)] [instDecidableEqXj : ∀j,DecidableEq (X j)] + +noncomputable def coordinateProjection (B : Finset J) (f : (∀j,X j) → ℝ) (x : ∀j,X j) : ℝ := + 𝔼 z,f (freezeCoordinates B z x) + +def maskedCoordinate (B : Finset J) (z : ∀j,X j) : ∀j,X j := fun j => if j∈B then z j else 0 + +lemma coordinateProjection_translates {J : Type*} + [Fintype J] + [DecidableEq J] + {X : J → Type*} + [(j : J) → Fintype (X j)] + [(j : J) → AddCommGroup (X j)] + [(j : J) → DecidableEq (X j)] (B : Finset J) (f : (∀j,X j) → ℝ) (x : ∀j,X j) : + coordinateProjection B f x=𝔼 z,f (x+maskedCoordinate B z) := by + unfold coordinateProjection + have he (z : ∀j,X j) : freezeCoordinates B (x+z) x=x+maskedCoordinate B z := by + ext j + by_cases hj : j∈B <;> simp [freezeCoordinates,maskedCoordinate,hj] + exact (Fintype.expect_equiv (Equiv.addLeft x) + (fun z => f (x+maskedCoordinate B z)) (fun z => f (freezeCoordinates B z x)) + (fun z => congrArg f (he z).symm)).symm + +lemma diagonalRoot_projection_le {V : Type*} [Fintype V] [Nonempty V] + (L : ((V → ∀j,X j) → ℝ) →ₗ[ℝ] ℝ) (hd : ∀g,0≤diagonalIntegral L g) + (hh : ∀A : V → (∀j,X j) → ℝ,|multilinearIntegral L A|≤∏v,diagonalRoot L (A v)) + (ht : ∀(a : ∀j,X j) F,L (fun z => F (fun v => z v+a))=L F) + (B : Finset J) (f : (∀j,X j) → ℝ) : + diagonalRoot L (coordinateProjection B f)≤diagonalRoot L f := by + have he (a : ∀j,X j) : diagonalRoot L (fun x => f (x+a))=diagonalRoot L f := by + unfold diagonalRoot diagonalIntegral multilinearIntegral + rw [ht a (fun z => ∏v,f (z v))] + have hfun : coordinateProjection B f=(fun x => 𝔼 z,f (x+maskedCoordinate B z)) := + funext (coordinateProjection_translates B f) + rw [hfun] + exact (diagonalRoot_expect_le L hd hh (fun z x => f (x+maskedCoordinate B z))).trans_eq (by simp only [he,Fintype.expect_const]) + +end GroupProjection + +end SquareDifference + +namespace SquareDifference + +open Finset + +section FrozenFamily + +variable {J : Type*} [instFintypeJ : Fintype J] [DecidableEq J] + (p : J → ℕ) [instFactNatPrimepj : ∀j,Fact (p j).Prime] + +noncomputable def frozenFamily (B : Finset J) (z : ∀j,ZMod (p j)) + (s : Finset (Finset J)) (f : Finset J → (∀j,ZMod (p j)) → ℝ) (x : ∀j,ZMod (p j)) : ℝ := + ∑U∈s,f U (freezeCoordinates B z x) + +lemma frozenFamily_moment (B : Finset J) (z : ∀j,ZMod (p j)) + (s : Finset (Finset J)) (f : Finset J → (∀j,ZMod (p j)) → ℝ) + (r : ℕ) (M : ℝ) (hm : (𝔼 x,(∑U∈s,f U x)^(2*r))≤M^(2*r)) : + (𝔼 x,frozenFamily p B z s f x^(2*r))≤(∏j∈B,p j : ℝ)*M^(2*r) := by + have hh := expect_freeze_le (fun x => (∑U∈s,f U x)^(2*r)) + (fun x => Even.pow_nonneg (even_two_mul r) _) B z + simp only [ZMod.card] at hh + exact hh.trans (mul_le_mul_of_nonneg_left hm (prod_nonneg (fun _ _ => Nat.cast_nonneg _))) + +lemma frozenFamily_sub_filter {J : Type*} + [Fintype J] + [DecidableEq J] + (p : J → ℕ) + [∀ (j : J), Fact (Nat.Prime (p j))] (B : Finset J) (z : ∀j,ZMod (p j)) + (s : Finset (Finset J)) (f : Finset J → (∀j,ZMod (p j)) → ℝ) + (H : ℝ) : + frozenFamily p B z s f-frozenFamily p B z (s.filter (fun U => (∏j∈U\B,p j : ℝ)≤H)) f= + frozenFamily p B z (s.filter (fun U => H<(∏j∈U\B,p j : ℝ))) f := by + funext x + have he := sum_filter_add_sum_filter_not s (fun U => (∏j∈U\B,p j : ℝ)≤H) + (fun U => f U (freezeCoordinates B z x)) + simp only [not_le] at he + change (∑U∈s,f U (freezeCoordinates B z x))-(∑U∈s.filter _,f U (freezeCoordinates B z x))= + ∑U∈s.filter _,f U (freezeCoordinates B z x) + linarith + +lemma frozen_family_telescope {V : Type*} [Fintype V] [DecidableEq V] [Nontrivial V] + (L : ∀j,((V → ZMod (p j)) → ℝ) →ₗ[ℝ] ℝ) + (hL : ∀j F,(∀z,0≤F z) → 0≤L j F) + (hmarg : ∀j v (f : ZMod (p j) → ℝ),L j (fun z => f (z v))=𝔼 x,f x) + (hmix : ∀j v (f : ZMod (p j) → ℝ),(𝔼 x,f x)=0 → + conditionalEnergy (jointDensity (L j) (Equiv.funSplitAt v _)) f≤ + (p j : ℝ)^(-(1:ℝ)/32)*(𝔼 x,f x^2)) + (s : Finset (Finset J)) (f : V → Finset J → (∀j,ZMod (p j)) → ℝ) + (hf : ∀v U, U∈s → ExactSupport U (f v U)) + (B : Finset J) (z : V → ∀j,ZMod (p j)) (H M : ℝ) (hH : 0 frozenFamily p B (z v) s (f v))- + multilinearIntegral (tensorLaw L) (fun v => frozenFamily p B (z v) + (s.filter (fun U => (∏j∈U\B,p j : ℝ)≤H)) (f v))|≤ + (Fintype.card V : ℝ)*H^(-(1:ℝ)/64)*(∏j∈B,p j : ℝ)*M^(Fintype.card V) := by + apply multilinear_truncation_error (tensorLaw L) (tensorLaw_nonneg L hL) _ _ H _ M hH + (prod_nonneg (fun _ _ => Nat.cast_nonneg _)) hM + · intro v + rw [frozenFamily_sub_filter] + have he := grouped_conditional_decay p L hL hmarg v (fun j => hmix j v) + (s.filter (fun U => H<(∏j∈U\B,p j : ℝ))) (fun U => U\B) + (fun U x => f v U (freezeCoordinates B (z v) x)) + (fun U hU => (hf v U (mem_filter.mp hU).1).freeze U B (f v U) (z v)) H hH + (fun U hU => (mem_filter.mp hU).2.le) + have hm' := frozenFamily_moment p B (z v) (s.filter (fun U => H<(∏j∈U\B,p j : ℝ))) + (f v) 1 M (hm v _ (filter_subset _ _) 1 (Or.inl rfl)) + norm_num only [mul_one] at hm' + exact he.trans (mul_le_mul_of_nonneg_left hm' (Real.rpow_nonneg hH.le _)) + · intro v w + have hr : Fintype.card {w : V // w≠v}+1=Fintype.card V := by + simp only [Fintype.card_subtype_compl,Fintype.card_unique] + exact Nat.sub_add_cancel (Nat.succ_le_of_lt Fintype.card_pos) + have he (t : Finset (Finset J)) : + tensorLaw L (fun x => |frozenFamily p B (z w) t (f w) (x w)|^(2*Fintype.card {w : V // w≠v}))= + 𝔼 x,frozenFamily p B (z w) t (f w) x^(2*Fintype.card {w : V // w≠v}) := by + have h := tensorLaw_marginal L w (fun j => hmarg j w) + (fun x => |frozenFamily p B (z w) t (f w) x|^(2*Fintype.card {w : V // w≠v})) + simpa only [(even_two_mul (Fintype.card {w : V // w≠v})).pow_abs] using h + rw [he s,he (s.filter (fun U => (∏j∈U\B,p j : ℝ)≤H))] + exact ⟨frozenFamily_moment p B (z w) s (f w) _ M (hm w s (Subset.refl _) _ (Or.inr hr)), + frozenFamily_moment p B (z w) _ (f w) _ M (hm w _ (filter_subset _ _) _ (Or.inr hr))⟩ + +end FrozenFamily + +end SquareDifference + +namespace SquareDifference + +open Finset + +noncomputable abbrev liftSupportFamily {J : Type*} [Fintype J] [DecidableEq J] (p : J → ℕ) := LiftAnalysis.SquareDifference.supportFamily p + +noncomputable abbrev actualLiftPiece {J : Type*} [DecidableEq J] (p : J → ℕ) := LiftAnalysis.SquareDifference.liftPiece p + +noncomputable abbrev actualTruncatedLift {J : Type*} [Fintype J] [DecidableEq J] (p : J → ℕ) := LiftAnalysis.SquareDifference.truncatedLift p + +noncomputable abbrev actualRemainingFamily {J : Type*} [Fintype J] [DecidableEq J] (p : J → ℕ) := LiftAnalysis.SquareDifference.remainingFamily p + +section LiftProjection + +variable {J : Type*} [instFintypeJ : Fintype J] [DecidableEq J] (p : J → ℕ) + [∀j,Fact (p j).Prime] + +lemma actualLiftPiece_exactSupport {J : Type*} + [Fintype J] + [DecidableEq J] + (p : J → ℕ) + [∀ (j : J), Fact (Nat.Prime (p j))] (L : ℕ) (f : ℕ → ℝ) (U : Finset J) : + ExactSupport U (actualLiftPiece p L f U) := + LiftAnalysis.SquareDifference.liftPiece_exactSupport p L f U + +lemma actualLift_projection (L Q : ℕ) (f : ℕ → ℝ) (B : Finset J) : + coordinateProjection B (actualTruncatedLift p L Q f)= + (fun x => ∑U∈actualRemainingFamily p B Q,actualLiftPiece p L f U x) := by + funext x + unfold coordinateProjection + change (𝔼 z,∑U∈liftSupportFamily p Q,actualLiftPiece p L f U (freezeCoordinates B z x))=_ + rw [expect_sum_comm] + simp only [(actualLiftPiece_exactSupport p L f _).project _ B _ x] + rw [←sum_filter] + apply sum_congr + · ext U + simp only [Finset.mem_filter, LiftAnalysis.SquareDifference.supportFamily, + LiftAnalysis.SquareDifference.remainingFamily,mem_univ,true_and] + exact and_comm + · intro U hU; rfl + +lemma actualLift_projection_diagonal_le (hp : ∀j,tupleReflectionThreshold≤(p j : ℝ)) + (L Q : ℕ) (f : ℕ → ℝ) (B : Finset J) : + diagonalIntegral (productTupleLaw p) + (fun x => ∑U∈actualRemainingFamily p B Q,actualLiftPiece p L f U x)≤ + diagonalIntegral (productTupleLaw p) (actualTruncatedLift p L Q f) := by + rw [←actualLift_projection] + have hh := diagonalRoot_projection_le (productTupleLaw p) (productTupleLaw_diagonal_nonneg p hp) + (productTupleLaw_signed_holder p hp) + (fun a F => by simpa only [one_pow,one_mul,Pi.add_def] using productTupleLaw_affine p (fun _ => 1) a (by intro j; exact one_ne_zero) F) + B (actualTruncatedLift p L Q f) + have hpow := pow_le_pow_left₀ (diagonalRoot_nonneg _ (productTupleLaw_diagonal_nonneg p hp) _) hh (Fintype.card TupleVertex) + simpa only [diagonalRoot_pow _ (productTupleLaw_diagonal_nonneg p hp)] using hpow + +end LiftProjection + +lemma uniform_common_lift_moments {V : Type} [Fintype V] [Nontrivial V] + (ε : ℝ) (hε : 0<ε) : + ∃C : ℝ,0 (p i).Coprime (p j)) → Function.Injective p → + ∀(s : Finset (Finset J)) (Q : ℕ),0 ∏j∈T\B,p j≤H), + actualLiftPiece p N f T (freezeCoordinates B z x))= + ((D:ℝ)*(L:ℝ)/(N:ℝ))*∑j∈range D, + ∑U∈actualRemainingFamily p B H, + actualLiftPiece p L (fun t => f₀ (a+D*j+D^2*t)) U + (fun k => ((u k)⁻¹ : (ZMod (p k))ˣ)*(x k-((a+D*j:ℕ):ZMod (p k)))) := by + change (∑T∈(LiftAnalysis.SquareDifference.supportFamily p Q).filter (fun T => ∏j∈T\B,p j≤H), + LiftAnalysis.SquareDifference.liftPiece p N f T + (LiftAnalysis.SquareDifference.coordinateFreeze p B z x))=_ + rw [LiftAnalysis.SquareDifference.frozen_low_lift_identity p N Q H f B hHQ z x] + have he (U : Finset J) : + ((∏j∈B,p j : ℝ)/(N:ℝ))*∑n∈range N, + (if ∀j∈B,(n:ZMod (p j))=z j then f n*LiftAnalysis.SquareDifference.exactGate p U (x-fun j => (n:ZMod (p j))) else 0)= + ((D:ℝ)/(N:ℝ))*∑n∈range N, + (if n%D=a then f₀ n*LiftAnalysis.SquareDifference.exactGate p U (x-fun j => (n:ZMod (p j))) else 0) := by + simp only [mul_sum] + apply sum_congr rfl + intro n _ + have hh := congrArg (fun y : ℝ => y*LiftAnalysis.SquareDifference.exactGate p U + (x-fun j => (n:ZMod (p j)))/(N:ℝ)) (hres n) + convert hh using 1 <;> split_ifs <;> ring + rw [mul_sum] + simp_rw [he] + have he₂ (U : Finset J) (hU : U∈actualRemainingFamily p B H) := + LiftAnalysis.SquareDifference.fiber_squareStep_lift_on p N D L a hD hL ha hNL f₀ hf U u + (fun j hj => hu j (Finset.disjoint_left.mp (Finset.mem_filter.mp hU).2.1 hj)) x + simp_rw [sum_congr rfl he₂] + rw [←mul_sum,sum_comm] + +end LowFiber + +end SquareDifference + +namespace SquareDifference + +open Finset + +lemma diagonalIntegral_average_le {V X I : Type*} [Fintype V] [Nonempty V] + [Fintype I] [Nonempty I] + (L : ((V → X) → ℝ) →ₗ[ℝ] ℝ) (hd : ∀g,0≤diagonalIntegral L g) + (hh : ∀A : V → X → ℝ,|multilinearIntegral L A|≤∏v,diagonalRoot L (A v)) + (f : I → X → ℝ) (K : ℝ) (hK : 0≤K) (hf : ∀i,diagonalIntegral L (f i)≤K) : + diagonalIntegral L (fun x => 𝔼 i,f i x)≤K := by + have he : diagonalRoot L (fun x => 𝔼 i,f i x)≤K^((1:ℝ)/(Fintype.card V:ℝ)) := by + apply (diagonalRoot_expect_le L hd hh f).trans + apply le_trans (expect_le_expect (fun i _ => Real.rpow_le_rpow (hd (f i)) (hf i) (by positivity))) + rw [Fintype.expect_const] + have hp := pow_le_pow_left₀ (diagonalRoot_nonneg L hd _) he (Fintype.card V) + rw [diagonalRoot_pow L hd,←Real.rpow_mul_natCast hK, + one_div_mul_cancel (Nat.cast_ne_zero.mpr Fintype.card_ne_zero),Real.rpow_one] at hp + exact hp + +lemma diagonalRoot_change_variables {V X : Type*} [Fintype V] + (L : ((V → X) → ℝ) →ₗ[ℝ] ℝ) (e : X → X) + (he : ∀F,L (fun z => F (fun v => e (z v)))=L F) (f : X → ℝ) : + diagonalRoot L (fun x => f (e x))=diagonalRoot L f := by + unfold diagonalRoot diagonalIntegral multilinearIntegral + rw [he (fun z => ∏v,f (z v))] + +lemma diagonalIntegral_change_variables {V X : Type*} [Fintype V] + (L : ((V → X) → ℝ) →ₗ[ℝ] ℝ) (e : X → X) + (he : ∀F,L (fun z => F (fun v => e (z v)))=L F) (f : X → ℝ) : + diagonalIntegral L (fun x => f (e x))=diagonalIntegral L f := by + exact he (fun z => ∏v,f (z v)) + +lemma diagonalIntegral_affine_average_le {V X I : Type*} [Fintype V] [Nonempty V] + [Fintype I] [Nonempty I] + (L : ((V → X) → ℝ) →ₗ[ℝ] ℝ) (hd : ∀g,0≤diagonalIntegral L g) + (hh : ∀A : V → X → ℝ,|multilinearIntegral L A|≤∏v,diagonalRoot L (A v)) + (f : I → X → ℝ) (e : I → X → X) (he : ∀i F,L (fun z => F (fun v => e i (z v)))=L F) + (K lam : ℝ) (hK : 0≤K) (hlam : 0≤lam) (hf : ∀i,diagonalIntegral L (f i)≤K) : + diagonalIntegral L (fun x => lam*(𝔼 i,f i (e i x)))≤lam^(Fintype.card V)*K := by + change diagonalIntegral L (lam • (fun x => 𝔼 i,f i (e i x)))≤_ + rw [diagonalIntegral_smul] + apply mul_le_mul_of_nonneg_left _ (pow_nonneg hlam _) + apply diagonalIntegral_average_le L hd hh _ K hK + intro i + rw [diagonalIntegral_change_variables L (e i) (he i)] + exact hf i + +end SquareDifference + +namespace SquareDifference + +open Finset + +instance tupleVertexNontrivial : Nontrivial TupleVertex := by + refine ⟨⟨cycleVertex 0,cycleVertex 1,?_⟩⟩ + intro h + apply tupleCycle_ne_one + have he := congrFun h (⟨0,by decide⟩ : Fin tupleBlocks) + simpa only [cycleVertex,pow_zero,pow_one] using he.symm + +section ActualTails + +variable {J : Type} [Fintype J] [DecidableEq J] (p : J → ℕ) [∀j,Fact (p j).Prime] + +lemma actual_frozen_lift_error (hp : ∀j,tupleConditionalThreshold≤(p j:ℝ)) + (L Q H : ℕ) (hH : 0 actualTruncatedLift p L Q (f v) (freezeCoordinates B (z v) x))- + multilinearIntegral (productTupleLaw p) (fun v x => + ∑U∈(liftSupportFamily p Q).filter (fun U => ∏j∈U\B,p j≤H), + actualLiftPiece p L (f v) U (freezeCoordinates B (z v) x))|≤ + (Fintype.card TupleVertex:ℝ)*(H:ℝ)^(-(1:ℝ)/64)*(∏j∈B,p j:ℝ)*M^(Fintype.card TupleVertex) := by + have hh := frozen_family_telescope p (fun j => (tupleLaw (p:=p j))) + (fun _ => tupleLaw_nonneg) (fun j => tupleLaw_marginal ((le_max_left _ _).trans (hp j))) + (fun j => tupleLaw_conditional (hp j)) (liftSupportFamily p Q) + (fun v U => actualLiftPiece p L (f v) U) + (fun v U _ => actualLiftPiece_exactSupport p L (f v) U) B z (H:ℝ) M + (by exact_mod_cast hH) hM hm + convert hh using 1 + congr 3 + funext v x + congr 1 + ext U + simp only [mem_filter,←Nat.cast_prod,Nat.cast_le] + +lemma actual_projected_lift_error (hp : ∀j,tupleConditionalThreshold≤(p j:ℝ)) + (L Q H : ℕ) (hH : 0 ∑U∈actualRemainingFamily p B H,actualLiftPiece p L f U x)- + diagonalIntegral (productTupleLaw p) (fun x => ∑U∈actualRemainingFamily p B Q,actualLiftPiece p L f U x)|≤ + (Fintype.card TupleVertex:ℝ)*(H:ℝ)^(-(1:ℝ)/64)*M^(Fintype.card TupleVertex) := by + have hsub : actualRemainingFamily p B Q⊆liftSupportFamily p Q := by + intro U hU + exact mem_filter.mpr ⟨mem_univ _,(mem_filter.mp hU).2.2⟩ + have hh := frozen_family_telescope p (fun j => (tupleLaw (p:=p j))) + (fun _ => tupleLaw_nonneg) (fun j => tupleLaw_marginal ((le_max_left _ _).trans (hp j))) + (fun j => tupleLaw_conditional (hp j)) (actualRemainingFamily p B Q) + (fun (_v : TupleVertex) U => actualLiftPiece p L f U) + (fun _ U _ => actualLiftPiece_exactSupport p L f U) ∅ (fun _ => 0) (H:ℝ) M + (by exact_mod_cast hH) hM (fun _ t ht => hm t (ht.trans hsub)) + have hfilt : (actualRemainingFamily p B Q).filter (fun U => (∏j∈U\∅,p j:ℝ)≤H)=actualRemainingFamily p B H := by + ext U + simp only [LiftAnalysis.SquareDifference.remainingFamily,mem_filter,mem_univ,true_and, + sdiff_empty,←Nat.cast_prod,Nat.cast_le] + constructor + · rintro ⟨⟨h₁,h₂⟩,h₃⟩; exact ⟨h₁,h₃⟩ + · rintro ⟨h₁,h₂⟩; exact ⟨⟨h₁,h₂.trans hHQ⟩,h₂⟩ + rw [hfilt] at hh + change |diagonalIntegral (productTupleLaw p) (fun x => ∑U∈actualRemainingFamily p B Q,actualLiftPiece p L f U x)- + diagonalIntegral (productTupleLaw p) (fun x => ∑U∈actualRemainingFamily p B H,actualLiftPiece p L f U x)|≤ + (Fintype.card TupleVertex:ℝ)*(H:ℝ)^(-(1:ℝ)/64)*(∏j∈(∅:Finset J),p j:ℝ)*M^(Fintype.card TupleVertex) at hh + simp only [prod_empty,mul_one] at hh + simpa only [diagonalIntegral,abs_sub_comm] using hh + +lemma productTupleLaw_inverse_square (w : ∀j,(ZMod (p j))ˣ) (c : ∀j,ZMod (p j)) + (F : (TupleVertex → ∀j,ZMod (p j)) → ℝ) : + productTupleLaw p (fun z => F (fun v j => (((w j)^2)⁻¹ : (ZMod (p j))ˣ)*(z v j-c j)))= + productTupleLaw p F := by + have he := productTupleLaw_affine p (fun j => ((w j)⁻¹ : (ZMod (p j))ˣ)) + (fun j => -(((w j)⁻¹ : (ZMod (p j))ˣ):ZMod (p j))^2*c j) + (fun j => Units.ne_zero _) F + convert he using 1 + congr 1 + funext z + congr 1 + funext v j + simp only [mul_sub,Units.val_inv_eq_inv_val,Units.val_pow_eq_pow_val,inv_pow] + ring + +end ActualTails + +end SquareDifference + +namespace SquareDifference + +open Finset + +lemma scale_sum_eq_expect {D : ℕ} (hD : 0 f₀ (a+D*j+D^2*t)) U x)^(2*r))≤M₂^(2*r)) + (hchild : ∀j f₀ (a+D*j+D^2*t)))≤K) : + diagonalIntegral (productTupleLaw p) + (fun x => actualTruncatedLift p N Q f (freezeCoordinates B z x))≤ + ((D:ℝ)^2*L/N)^(Fintype.card TupleVertex)* + (K+(Fintype.card TupleVertex:ℝ)*(H:ℝ)^(-(1:ℝ)/64)*M₂^(Fintype.card TupleVertex))+ + (Fintype.card TupleVertex:ℝ)*(H:ℝ)^(-(1:ℝ)/64)*(∏j∈B,p j:ℝ)*M₁^(Fintype.card TupleVertex) := by + let : NeZero D := ⟨hD.ne'⟩ + let E : ℝ := (Fintype.card TupleVertex:ℝ)*(H:ℝ)^(-(1:ℝ)/64)*M₂^(Fintype.card TupleVertex) + let g (j : Fin D) (x : ∀j,ZMod (p j)) : ℝ := + ∑U∈actualRemainingFamily p B H,actualLiftPiece p L (fun t => f₀ (a+D*j.val+D^2*t)) U x + let e (j : Fin D) (x : ∀j,ZMod (p j)) : ∀j,ZMod (p j) := + fun k => (((w k)^2)⁻¹ : (ZMod (p k))ˣ)*(x k-((a+D*j.val:ℕ):ZMod (p k))) + have he (j : Fin D) (F : (TupleVertex → ∀j,ZMod (p j)) → ℝ) : + productTupleLaw p (fun x => F (fun v => e j (x v)))=productTupleLaw p F := + productTupleLaw_inverse_square p w (fun k => ((a+D*j.val:ℕ):ZMod (p k))) F + have hg (j : Fin D) : diagonalIntegral (productTupleLaw p) (g j)≤K+E := by + have ht := actual_projected_lift_error p hp L Qc H hH hHQc + (fun t => f₀ (a+D*j.val+D^2*t)) B M₂ hM₂ (hm₂ j.val j.isLt) + have hc := (actualLift_projection_diagonal_le p href L Qc + (fun t => f₀ (a+D*j.val+D^2*t)) B).trans (hchild j.val j.isLt) + exact diagonal_transfer_close ht hc + have hE : 0≤E := mul_nonneg (mul_nonneg (Nat.cast_nonneg _) (Real.rpow_nonneg (Nat.cast_nonneg H) _)) (pow_nonneg hM₂ _) + have hcoef : 0≤(D:ℝ)^2*L/N := div_nonneg (mul_nonneg (sq_nonneg _) (Nat.cast_nonneg _)) (Nat.cast_nonneg _) + have havg := diagonalIntegral_affine_average_le (productTupleLaw p) + (productTupleLaw_diagonal_nonneg p href) (productTupleLaw_signed_holder p href) + g e he (K+E) ((D:ℝ)^2*L/N) (add_nonneg hK hE) hcoef hg + have hid : (fun x => ∑T∈(liftSupportFamily p Q).filter (fun T => ∏j∈T\B,p j≤H), + actualLiftPiece p N f T (freezeCoordinates B z x))= + (fun x => ((D:ℝ)^2*L/N)*(𝔼 j,g j (e j x))) := by + funext x + rw [actual_low_lift_affine_sum p N Q H D L a B z hHQ hD hL ha hNL f f₀ hf hres + (fun j => (w j)^2) (fun j hj => by simp only [Units.val_pow_eq_pow_val,hw j hj])] + rw [←Fin.sum_univ_eq_sum_range] + exact scale_sum_eq_expect hD L N (fun j => g j (e j x)) + have ht := actual_frozen_lift_error p hp N Q H hH (fun _ => f) B (fun _ => z) M₁ hM₁ + (fun _ => hm₁) + rw [←hid] at havg + dsimp only [E] at havg + exact diagonal_transfer_close ht havg + +end ActualTransfer + +end SquareDifference + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SquareDifference/SelectedPair.lean b/lean/OAI/Combinatorics/SquareDifference/SelectedPair.lean new file mode 100644 index 0000000000000000000000000000000000000000..de365eabcbb504eee8c0de0c218c6edfc9e7d7a3 --- /dev/null +++ b/lean/OAI/Combinatorics/SquareDifference/SelectedPair.lean @@ -0,0 +1,119 @@ +import OAI.Combinatorics.SquareDifference.IntervalTruncation + +namespace OAI + +section + +open Finset + +open scoped BigOperators ComplexConjugate + +namespace SquareDifference + +open LiftTheory.SquareDifference + +lemma complex_scaled_bound {D a b E : ℝ} (hD : 0 < D) (ha : 0 ≤ a) (hb : 0 ≤ b) + (S : ℂ) (h : ‖(D:ℂ)*S‖ ≤ E) : + ‖(a:ℂ)*(b:ℂ)*S‖ ≤ a*b/D*E := by + have he : (a:ℂ)*(b:ℂ)*S=((a*b/D:ℝ):ℂ)*((D:ℂ)*S) := by + push_cast + field_simp [Complex.ofReal_ne_zero.mpr hD.ne'] + rw [he,norm_mul,Complex.norm_real,Real.norm_eq_abs,abs_of_nonneg (div_nonneg (mul_nonneg ha hb) hD.le)] + exact mul_le_mul_of_nonneg_left h (div_nonneg (mul_nonneg ha hb) hD.le) + +lemma squarePair_bound_from_low {J : Type*} [Fintype J] [DecidableEq J] + (p : J → ℕ) [∀j,Fact (p j).Prime] (hp : ∀j,64 ≤ p j) + (F G : ResidueSpace p → ℂ) (H M₁ M₂ E : ℝ) (hH : 0 < H) + (hM₁ : 0 ≤ M₁) (hM₂ : 0 ≤ M₂) + (hF : (𝔼 x,‖F x‖^2) ≤ M₁^2) (hG : (𝔼 x,‖G x‖^2) ≤ M₂^2) + (hlow : ‖∑a∈univ.filter (fun a => (supportDenominator p a:ℝ) ≤ H), + residueFourier p F (-a)*residueFourier p G a*squareMultiplier p a‖ ≤ E) : + ‖squarePairForm p F G‖ ≤ E+H^(-(1:ℝ)/3)*M₁*M₂ := by + have ht := squarePair_tail_bound p hp F G H hH + have hd : 0 ≤ H^(-(1:ℝ)/3) := Real.rpow_nonneg hH.le _ + have he : H^(-(2:ℝ)/3)=(H^(-(1:ℝ)/3))^2 := by + rw [←Real.rpow_mul_natCast hH.le] + congr 1 ; norm_num + rw [he,mul_assoc] at ht + have ht' := ht.trans (mul_le_mul_of_nonneg_left + (mul_le_mul hF hG (expect_nonneg (fun _ _ => sq_nonneg _)) (sq_nonneg _)) (sq_nonneg _)) + have hb : ‖∑a∈univ.filter (fun a => H < (supportDenominator p a:ℝ)), + residueFourier p F (-a)*residueFourier p G a*squareMultiplier p a‖ ≤ H^(-(1:ℝ)/3)*M₁*M₂ := by + have hh : (H^(-(1:ℝ)/3))^2*(M₁^2*M₂^2)=(H^(-(1:ℝ)/3)*M₁*M₂)^2 := by ring + rw [hh] at ht' + exact (sq_le_sq₀ (norm_nonneg _) (mul_nonneg (mul_nonneg hd hM₁) hM₂)).mp ht' + rw [squarePairForm_fourier] + have hs := sum_filter_add_sum_filter_not (s:=univ) + (p:=fun a : ResidueSpace p => (supportDenominator p a:ℝ) ≤ H) + (f:=fun a => residueFourier p F (-a)*residueFourier p G a*squareMultiplier p a) + simp only [not_le] at hs + rw [←hs] + exact (norm_add_le _ _).trans (add_le_add hlow hb) + +section KernelPair + +variable {I : Type*} [Fintype I] [DecidableEq I] + (p : I → ℕ) [∀i,Fact (p i).Prime] (hinj : Function.Injective p) + (R : Finset I) (c : ∀i,ZMod (p i)) + +include hinj in +lemma actual_kernel_low_pair + (H : ℝ) (hH : 1 ≤ H) (N : ℕ) (hN : 1 ≤ N) + (hD : (rootSquareModulus p R:ℝ) ≤ (N:ℝ)^((1:ℝ)/1000)) + (hHn : H ≤ (N:ℝ)^((1:ℝ)/1000)) (hlarge : 8 ≤ (N:ℝ)^((1:ℝ)/16)) + (hcover : ∀b : ℚ,(b.den:ℝ) ≤ (N:ℝ)^((1:ℝ)/8) → + b.den∣∏i,primaryModulus b.den (p i)) + (hcover' : ∀b : ℚ,b.den ≤ ⌈(rootSquareModulus p R:ℝ)*H⌉₊ → + b.den∣∏i,primaryModulus b.den (p i)) + (htwo : ∀i,p i=2 → i∈R) + (hc : ∀i∈R,if p i=2 then c i=1 else c i≠0) + {q : ℕ} [NeZero q] (hq : N < q) (F G : ZMod q → ℂ) + (hF : (∑x,‖F x‖^2) ≤ N) (hG : (∑x,‖G x‖^2) ≤ N) + (hord : ∀x y,F x*G y≠0 → x.val < y.val ∧ y.val ≤ N) + (hsquare : ∀x y m,m∈range N.sqrt → (((m+1)^2:ℕ):ZMod q)=y-x → F x*G y=0) + (s t : ∀i,ZMod (smallQuadraticModulus (p i))) + (hr : ∀i∈R,smallRootSquare (p i) (c i)=t i-s i) + (hs : ∀z,F z≠0 → ∀i∈R,(z.val:ZMod (smallQuadraticModulus (p i)))=s i) + (ht : ∀z,G z≠0 → ∀i∈R,(z.val:ZMod (smallQuadraticModulus (p i)))=t i) + (f g : ResidueSpace (OutsideModulus (fun i => smallQuadraticModulus (p i)) R) → ℂ) + (a b : ℝ) (ha : 0 ≤ a) (hb : 0 ≤ b) + (hf : ∀ξ,(supportDenominator (OutsideModulus (fun i => smallQuadraticModulus (p i)) R) ξ:ℝ) ≤ H → + residueFourier _ f ξ=(a:ℂ)*sequenceResidueFourier _ N F ZMod.val ξ) + (hg : ∀ξ,(supportDenominator (OutsideModulus (fun i => smallQuadraticModulus (p i)) R) ξ:ℝ) ≤ H → + residueFourier _ g ξ=(b:ℂ)*sequenceResidueFourier _ N G ZMod.val ξ) : + ‖∑ξ∈univ.filter (fun ξ => (supportDenominator (OutsideModulus (fun i => smallQuadraticModulus (p i)) R) ξ:ℝ) ≤ H), + residueFourier _ f (-ξ)*residueFourier _ g ξ*squareMultiplier _ ξ‖ ≤ + a*b/(rootSquareModulus p R:ℝ)*(kernelAbsoluteConstant*H^(-(1:ℝ)/3)) := by + let m := OutsideModulus (fun i => smallQuadraticModulus (p i)) R + have hk := actual_kernel_ordered_bilinear p R c hinj H hH N hN hD hHn hlarge hcover htwo hc hq F G hF hG hord hsquare + rw [modelBilinear_root p hinj R c H _ N (Nat.le_ceil _) hcover' htwo hc F G s t hr hs ht] at hk + have hd : (∏i∈R,smallQuadraticModulus (p i))=rootSquareModulus p R := rfl + rw [hd] at hk + let S : ℂ := ∑ξ : ResidueSpace m,(if (supportDenominator m ξ:ℝ) ≤ H then squareMultiplier m ξ else 0)* + sequenceResidueFourier m N F ZMod.val (-ξ)*sequenceResidueFourier m N G ZMod.val ξ + have hscaled := complex_scaled_bound (Nat.cast_pos.mpr (rootSquareModulus_pos p R)) ha hb S hk + apply le_trans (le_of_eq ?_) hscaled + congr 1 + change (∑ξ∈univ.filter (fun ξ : ResidueSpace m => (supportDenominator m ξ:ℝ) ≤ H), + residueFourier m f (-ξ)*residueFourier m g ξ*squareMultiplier m ξ)=(a:ℂ)*(b:ℂ)*S + dsimp only [S] + simp only [mul_sum,ite_mul,mul_ite,zero_mul,mul_zero] + rw [←sum_filter] + apply sum_congr rfl + intro ξ hξ + have hξ' := (mem_filter.mp hξ).2 + have hneg : supportDenominator m (-ξ)=supportDenominator m ξ := by + unfold supportDenominator primeSupport + congr 1 + ext j + simp only [mem_filter,mem_univ,true_and,Pi.neg_apply,neg_ne_zero] + rw [hf (-ξ) (by rwa [hneg]),hg ξ hξ'] + ring + +end KernelPair + +end SquareDifference + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SquareDifference/SelectedRoots.lean b/lean/OAI/Combinatorics/SquareDifference/SelectedRoots.lean new file mode 100644 index 0000000000000000000000000000000000000000..da92313fd7d263f9c5be357779f9842c68bd3067 --- /dev/null +++ b/lean/OAI/Combinatorics/SquareDifference/SelectedRoots.lean @@ -0,0 +1,101 @@ +import OAI.Combinatorics.SquareDifference.SmallRoots + +namespace OAI + +section + +open Finset + +open scoped BigOperators + +namespace SquareDifference + +open LiftTheory.SquareDifference + +lemma exists_large_root (p : ℕ) [Fact p.Prime] (hp : p≠2) (z w : ZMod p) + (hne : w-z≠0) (hsq : IsSquare (w-z)) : ∃c : ZMod p,c≠0 ∧ + smallRootSquare p c=(w.val:ZMod (smallQuadraticModulus p))-(z.val:ZMod (smallQuadraticModulus p)) := by + obtain ⟨c,hc⟩ := hsq + refine ⟨c,(fun h => hne (by simpa only [h,mul_zero] using hc)),?_⟩ + let e : ZMod (smallQuadraticModulus p) ≃+* ZMod p := RingEquiv.cast (by simp only [smallQuadraticModulus,hp,ite_false]) + apply e.injective + simp only [smallRootSquare,hp,ite_false,map_pow,map_natCast,ZMod.natCast_zmod_val,map_sub] + simpa only [pow_two] using hc.symm + +section Roots + +variable {S J : Type*} [Fintype S] [DecidableEq S] [Fintype J] [DecidableEq J] + (ps : S → ℕ) (p : J → ℕ) [instFactNatPrimepsi : ∀i,Fact (ps i).Prime] [∀j,Fact (p j).Prime] + +noncomputable def selectedRootLabels (s : ZMod (smallModulus ps)) (z : ResidueSpace p) : + ∀i,ZMod (smallQuadraticModulus (extendedPrime ps p i)) := fun i => match i with + | Sum.inl j => smallProjection ps j s + | Sum.inr j => ((z j).val:ZMod (smallQuadraticModulus (p j))) + +lemma selectedRootLabels_nat {S : Type*} + {J : Type*} + [Fintype S] + [DecidableEq S] + [Fintype J] + [DecidableEq J] + (ps : S → ℕ) + (p : J → ℕ) + [∀ (i : S), Fact (Nat.Prime (ps i))] + [∀ (j : J), Fact (Nat.Prime (p j))] (hp2 : ∀j,p j≠2) (B : Finset J) (s : ZMod (smallModulus ps)) + (z : ResidueSpace p) (n : ℕ) (hn : (n:ZMod (smallModulus ps))=s) + (hz : ∀j∈B,(n:ZMod (p j))=z j) : + ∀i∈extendedRoots (S:=S) B,(n:ZMod (smallQuadraticModulus (extendedPrime ps p i)))=selectedRootLabels ps p s z i := by + intro i hi + cases i with + | inl j => + change (n:ZMod (smallQuadraticModulus (ps j)))=smallProjection ps j s + rw [← smallProjection_nat ps j n,hn] + | inr j => + have hj : j∈B := (inr_mem_extendedRoots B j).mp hi + have hpj := hp2 j + have he : smallQuadraticModulus (p j)=p j := by simp only [smallQuadraticModulus,hpj,ite_false] + let e : ZMod (smallQuadraticModulus (p j)) ≃+* ZMod (p j) := RingEquiv.cast he + change (n:ZMod (smallQuadraticModulus (p j)))=((z j).val:ZMod (smallQuadraticModulus (p j))) + apply e.injective + simpa only [map_natCast,ZMod.natCast_zmod_val] using hz j hj + +lemma selectedRoot_witnesses (hp2 : ∀j,p j≠2) (B : Finset J) + (s t : ZMod (smallModulus ps)) (hst : smallStrictPair ps s t) (z w : ResidueSpace p) + (hzw : ∀j∈B,w j-z j≠0 ∧ IsSquare (w j-z j)) : + ∃c : ∀i,ZMod (extendedPrime ps p i), + (∀i∈extendedRoots (S:=S) B,if extendedPrime ps p i=2 then c i=1 else c i≠0) ∧ + (∀i∈extendedRoots (S:=S) B,smallRootSquare (extendedPrime ps p i) (c i)= + selectedRootLabels ps p t w i-selectedRootLabels ps p s z i) := by + classical + choose cs hcs using (fun i => exists_small_root (ps i) (smallProjection ps i (t-s)) (hst i)) + have hex (j : J) : ∃c : ZMod (p j),c≠0 ∧ (j∈B → smallRootSquare (p j) c= + ((w j).val:ZMod (smallQuadraticModulus (p j)))-((z j).val:ZMod (smallQuadraticModulus (p j)))) := by + by_cases hj : j∈B + · obtain ⟨c,hc,he⟩ := exists_large_root (p j) (hp2 j) (z j) (w j) (hzw j hj).1 (hzw j hj).2 + exact ⟨c,hc,fun _ => he⟩ + · exact ⟨1,one_ne_zero,fun h => False.elim (hj h)⟩ + choose cp hcp using hex + let c : ∀i,ZMod (extendedPrime ps p i) := fun i => match i with + | Sum.inl j => cs j + | Sum.inr j => cp j + refine ⟨c,?_,?_⟩ + · intro i hi + cases i with + | inl j => exact (hcs j).1 + | inr j => + change (if p j=2 then cp j=1 else cp j≠0) + simpa only [hp2,ite_false] using (hcp j).1 + · intro i hi + cases i with + | inl j => + change smallRootSquare (ps j) (cs j)=smallProjection ps j t-smallProjection ps j s + simpa only [map_sub] using (hcs j).2 + | inr j => exact (hcp j).2 ((inr_mem_extendedRoots B j).mp hi) + +end Roots + +end SquareDifference + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SquareDifference/SievedFourier.lean b/lean/OAI/Combinatorics/SquareDifference/SievedFourier.lean new file mode 100644 index 0000000000000000000000000000000000000000..0fd35c9b4c7decf83738b4ef66277589470dae21 --- /dev/null +++ b/lean/OAI/Combinatorics/SquareDifference/SievedFourier.lean @@ -0,0 +1,523 @@ +import OAI.Combinatorics.SquareDifference.PrimeGauss + +namespace OAI + +section +open Finset +open scoped ComplexConjugate BigOperators +namespace SquareDifference + +lemma HasFourierBound.gauss {R : Type*} [CommRing R] [Fintype R] [DecidableEq R] + {ψ : AddChar R ℂ} {w : R → ℂ} {C : ℝ} (hw : HasFourierBound ψ w C) + (hψ : ψ.IsPrimitive) (a : R) (ha : IsUnit (2*a)) : + ‖𝔼 x, w x*ψ (a*x^2)‖≤C*(Fintype.card R : ℝ)^(-(1:ℝ)/2) := by + rcases hw with ⟨c,hc,hC⟩ + simp_rw [hc] + exact (fourier_weighted_gauss ψ hψ a ha id c).trans + (mul_le_mul_of_nonneg_right hC (Real.rpow_nonneg (Nat.cast_nonneg _) _)) + +lemma primitive_transport {R S : Type*} [CommRing R] [CommRing S] + (e : R ≃+* S) (ψ : AddChar R ℂ) (hψ : ψ.IsPrimitive) : + (ψ.compAddMonoidHom e.symm.toAddMonoidHom).IsPrimitive := by + intro a ha he + apply hψ (show e.symm a≠0 by exact fun h => ha (e.symm.injective (by simpa using h))) + ext x + have h := congrArg (fun φ : AddChar S ℂ => φ (e x)) he + change ψ (e.symm (a*e x))=1 at h + simpa only [AddChar.mulShift_apply, AddChar.one_apply, map_mul, RingEquiv.symm_apply_apply] using h + +lemma primitive_mulShift {R : Type*} [CommRing R] (ψ : AddChar R ℂ) + (hψ : ψ.IsPrimitive) (a : R) (ha : IsUnit a) : (ψ.mulShift a).IsPrimitive := by + intro b hb he + apply hψ (show a*b≠0 by exact fun h => hb ((ha.mul_right_eq_zero).mp h)) + ext x + have h := congrArg (fun φ : AddChar R ℂ => φ x) he + simpa only [AddChar.mulShift_apply, AddChar.one_apply, mul_assoc] using h + +noncomputable def coordinateChar {I : Type*} [DecidableEq I] {R : I → Type*} + [∀i, CommRing (R i)] (ψ : AddChar (∀i, R i) ℂ) (i : I) : AddChar (R i) ℂ := + ψ.compAddMonoidHom (AddMonoidHom.single R i) + +lemma coordinateChar_apply {I : Type*} [DecidableEq I] {R : I → Type*} + [∀i, CommRing (R i)] (ψ : AddChar (∀i, R i) ℂ) (i : I) (x : R i) : + coordinateChar ψ i x=ψ (Pi.single i x) := rfl + +lemma coordinateChar_primitive {I : Type*} [DecidableEq I] {R : I → Type*} + [∀i, CommRing (R i)] (ψ : AddChar (∀i, R i) ℂ) (hψ : ψ.IsPrimitive) (i : I) : + (coordinateChar ψ i).IsPrimitive := by + intro a ha he + have hs : (Pi.single i a : ∀i, R i)≠0 := by + intro h + have hh := congrFun h i + exact ha (by simpa only [Pi.single_eq_same, Pi.zero_apply] using hh) + apply hψ hs + ext x + have h := congrArg (fun φ : AddChar (R i) ℂ => φ (x i)) he + have hm : (Pi.single i a : ∀i, R i)*x=Pi.single i (a*x i) := by + ext j + by_cases hj : j=i + · subst j; simp + · simp [Pi.single_eq_of_ne hj] + simpa only [AddChar.mulShift_apply, coordinateChar_apply, AddChar.one_apply, hm] using h + +lemma addChar_finset_sum {I A : Type*} [AddCommMonoid A] (ψ : AddChar A ℂ) + (S : Finset I) (f : I → A) : ψ (∑i∈S, f i)=∏i∈S, ψ (f i) := by + classical + induction S using Finset.induction_on with + | empty => simp + | @insert a S ha ih => rw [sum_insert ha, prod_insert ha, AddChar.map_add_eq_mul, ih] + +lemma additive_character_product {I : Type*} [Fintype I] [DecidableEq I] + {R : I → Type*} [∀i, CommRing (R i)] (ψ : AddChar (∀i, R i) ℂ) (x : ∀i, R i) : + ψ x=∏i, coordinateChar ψ i (x i) := by + have h : x=∑i, Pi.single i (x i) := by + ext j + simp only [Finset.sum_apply] + rw [sum_eq_single j] + · simp + · intro i _ hij; exact Pi.single_eq_of_ne (Ne.symm hij) _ + · simp + conv_lhs => rw [h] + rw [addChar_finset_sum] + rfl + +lemma complex_expect_pi_prod {I : Type*} [Fintype I] [DecidableEq I] + {X : I → Type*} [∀i, Fintype (X i)] (f : ∀i, X i → ℂ) : + (𝔼 x : ∀i, X i, ∏i, f i (x i))=∏i, 𝔼 t : X i, f i t := by + simp only [expect_eq_sum_div_card, card_univ, Fintype.card_pi, Nat.cast_prod, + Finset.prod_div_distrib] + rw [Fintype.prod_sum] + +lemma product_quadratic_mean {I : Type*} [Fintype I] [DecidableEq I] + {R : I → Type*} [∀i, CommRing (R i)] [∀i, Fintype (R i)] + (ψ : AddChar (∀i, R i) ℂ) (w : ∀i, R i → ℂ) : + (𝔼 x : ∀i, R i, (∏i, w i (x i))*ψ (x^2))= + ∏i, 𝔼 t : R i, w i t*coordinateChar ψ i (t^2) := by + have h (x : ∀i, R i) : (∏i, w i (x i))*ψ (x^2)= + ∏i, w i (x i)*coordinateChar ψ i ((x i)^2) := by + rw [additive_character_product ψ (x^2), ← prod_mul_distrib] + rfl + calc + _ = 𝔼 x : ∀i, R i, ∏i, w i (x i)*coordinateChar ψ i ((x i)^2) := + expect_congr rfl (fun x _ => h x) + _ = _ := complex_expect_pi_prod (I := I) (X := R) + (fun i t => w i t*coordinateChar ψ i (t^2)) + +lemma primeSieveWeight_fourier_dvd {p q : ℕ} [Fact p.Prime] [NeZero q] + (hpq : p∣q) (ψ : AddChar (ZMod q) ℂ) (hψ : ψ.IsPrimitive) : + HasFourierBound ψ (fun x => (primeSieveWeight p (ZMod.castHom hpq (ZMod p) x) : ℂ)) 1 := by + obtain ⟨k,rfl⟩ := hpq + have hk : k≠0 := by + intro h; have hh := NeZero.ne (p*k); simp [h] at hh + let : NeZero k := ⟨hk⟩ + exact primeSieveWeight_fourier_bound ψ hψ + +lemma fiber_gauss_zero_char {p k : ℕ} [NeZero p] [NeZero k] + (hpk : p∣k) (ψ : AddChar (ZMod (p*k)) ℂ) (hψ : ψ.IsPrimitive) (c : ZMod p) + (hc : (2 : ZMod p)*c≠0) : + (𝔼 x : ZMod (p*k), + (if ZMod.castHom (dvd_mul_right p k) (ZMod p) x=c then (p : ℂ) else 0)*ψ (x^2))=0 := by + classical + let φ := ZMod.castHom (dvd_mul_right p k) (ZMod p) + let R := ZMod (p*k) + have ht : φ (k : R)=0 := by + dsimp only [φ] + rw [map_natCast] + exact (ZMod.natCast_eq_zero_iff k p).mpr hpk + have ht2 : (k : R)^2=0 := by + rw [pow_two] + exact zmod_kernel_factor p k (k : R) ht + let ζ := ψ ((2*(c.val : R))*(k : R)) + have hζ : ζ≠1 := by + intro he + have he0 : (2*(c.val : R))*(k : R)=0 := + (hψ.zmod_char_eq_one_iff (p*k) _).mp he + have hz : ((2*(c.val : ℤ) : ℤ) : ZMod p)=0 := + (zmod_factor_zero p k (NeZero.ne k) (2*c.val)).mp (by simpa using he0) + exact hc (by simpa using hz) + have hz : (∑x : R, (if φ x=c then (1 : ℂ) else 0)*ψ (x^2))=0 := by + have h := quadratic_shift_cancellation ψ (1 : R) (k : R) + (fun x => if φ x=c then (1 : ℂ) else 0) ζ hζ + simp only [one_mul] at h + apply h + · exact zmod_fiber_translation p k c (k : R) ht + · intro x hx + have hxc : φ x=c := by + by_contra hh + exact hx (ite_eq_right hh) + have hkern : (x-(c.val : R))*(k : R)=0 := by + apply zmod_kernel_factor p k + change φ (x-(c.val : R))=0 + rw [map_sub, map_natCast, ZMod.natCast_zmod_val, hxc, sub_self] + have hxk : x*(k : R)=(c.val : R)*(k : R) := by linear_combination hkern + apply congrArg ψ + calc + _ = 2*(x*(k : R))+(k : R)^2 := by ring + _ = _ := by rw [hxk, ht2]; ring + rw [expect_eq_sum_div_card] + have hs : (∑x : R, (if φ x=c then (p : ℂ) else 0)*ψ (x^2))= + (p : ℂ)*∑x : R, (if φ x=c then (1 : ℂ) else 0)*ψ (x^2) := by + rw [mul_sum] + apply sum_congr rfl + intro x _ + split_ifs <;> ring + rw [hs,hz,mul_zero,zero_div] + +lemma quadratic_mean_equiv {R S : Type*} [CommRing R] [CommRing S] + [Fintype R] [Fintype S] (e : R ≃+* S) (ψ : AddChar R ℂ) (w : S → ℂ) : + (𝔼 x : R, w (e x)*ψ (x^2))= + 𝔼 x : S, w x*(ψ.compAddMonoidHom e.symm.toAddMonoidHom) (x^2) := by + classical + apply Fintype.expect_equiv e.toEquiv + intro x + change w (e x)*ψ (x^2)=w (e x)*ψ (e.symm ((e x)^2)) + rw [← map_pow, RingEquiv.symm_apply_apply] + +lemma crt_quadratic_mean {I : Type*} [Fintype I] [DecidableEq I] + (m : I → ℕ) [∀i, NeZero (m i)] [NeZero (∏i, m i)] + (hcop : Pairwise (Function.onFun Nat.Coprime m)) + (ψ : AddChar (ZMod (∏i, m i)) ℂ) (w : ∀i, ZMod (m i) → ℂ) : + (𝔼 x : ZMod (∏i, m i), + (∏i, w i (ZMod.prodEquivPi m hcop x i))*ψ (x^2)) = + ∏i, 𝔼 t : ZMod (m i), w i t* + coordinateChar (ψ.compAddMonoidHom (ZMod.prodEquivPi m hcop).symm.toAddMonoidHom) i (t^2) := by + rw [quadratic_mean_equiv (ZMod.prodEquivPi m hcop) ψ (fun x => ∏i, w i (x i))] + exact product_quadratic_mean _ w + +lemma fiber_sum_gauss_zero_char {p k : ℕ} [NeZero p] [NeZero k] + (hpk : p∣k) (ψ : AddChar (ZMod (p*k)) ℂ) (hψ : ψ.IsPrimitive) (c : ZMod p) + (hc : (2 : ZMod p)*c≠0) : + (∑x : ZMod (p*k), + (if ZMod.castHom (dvd_mul_right p k) (ZMod p) x=c then (1 : ℂ) else 0)*ψ (x^2))=0 := by + classical + have h := fiber_gauss_zero_char hpk ψ hψ c hc + rw [expect_eq_sum_div_card, div_eq_zero_iff] at h + have hc0 : (Fintype.card (ZMod (p*k)) : ℂ)≠0 := by + simp only [ZMod.card, ne_eq, Nat.cast_eq_zero] + exact mul_ne_zero (NeZero.ne p) (NeZero.ne k) + have hs := h.resolve_right hc0 + have he : (∑x : ZMod (p*k), + (if ZMod.castHom (dvd_mul_right p k) (ZMod p) x=c then (p : ℂ) else 0)*ψ (x^2))= + (p : ℂ)*(∑x : ZMod (p*k), + (if ZMod.castHom (dvd_mul_right p k) (ZMod p) x=c then (1 : ℂ) else 0)*ψ (x^2)) := by + rw [mul_sum] + apply sum_congr rfl + intro x _ + split_ifs <;> ring + rw [he] at hs + exact (mul_eq_zero.mp hs).resolve_left (by exact_mod_cast NeZero.ne p) + +lemma gauss_zero_of_fiber_char {p k : ℕ} [NeZero p] [NeZero k] + (hpk : p∣k) (ψ : AddChar (ZMod (p*k)) ℂ) (hψ : ψ.IsPrimitive) (w : ZMod p → ℂ) + (hw : ∀c, w c≠0 → (2 : ZMod p)*c≠0) : + (𝔼 x : ZMod (p*k), w (ZMod.castHom (dvd_mul_right p k) (ZMod p) x)*ψ (x^2))=0 := by + classical + rw [expect_eq_sum_div_card, weighted_fiber_sum] + suffices (∑c : ZMod p, w c*∑x : ZMod (p*k), + (if ZMod.castHom (dvd_mul_right p k) (ZMod p) x=c then (1 : ℂ) else 0)*ψ (x^2))=0 by + rw [this, zero_div] + apply sum_eq_zero + intro c _ + by_cases hc : w c=0 + · rw [hc, zero_mul] + · rw [fiber_sum_gauss_zero_char hpk ψ hψ c (hw c hc), mul_zero] + +lemma odd_unit_gauss_zero_char {p k : ℕ} [Fact p.Prime] [NeZero k] + (hp : p≠2) (hpk : p∣k) (ψ : AddChar (ZMod (p*k)) ℂ) (hψ : ψ.IsPrimitive) : + (𝔼 x : ZMod (p*k), + (if ZMod.castHom (dvd_mul_right p k) (ZMod p) x≠0 then (1 : ℂ) else 0)*ψ (x^2))=0 := by + apply gauss_zero_of_fiber_char hpk ψ hψ (fun c => if c≠0 then 1 else 0) + intro c hc + have hc0 : c≠0 := by intro h; simp [h] at hc + have h2 : (2 : ZMod p)≠0 := Ring.two_ne_zero (by simpa only [ZMod.ringChar_zmod_n] using hp) + exact mul_ne_zero h2 hc0 + +lemma two_unit_gauss_zero_char {k : ℕ} [NeZero k] + (hk : 4∣k) (ψ : AddChar (ZMod (4*k)) ℂ) (hψ : ψ.IsPrimitive) : + (𝔼 x : ZMod (4*k), + (if IsUnit (ZMod.castHom (dvd_mul_right 4 k) (ZMod 4) x) then (1 : ℂ) else 0)*ψ (x^2))=0 := by + classical + apply gauss_zero_of_fiber_char hk ψ hψ (fun c => if IsUnit c then 1 else 0) + intro c hc + have hc0 : IsUnit c := by by_contra h; simp [h] at hc + simpa only [mul_one] using four_unit_mul_two isUnit_one hc0 + +lemma finite_complete_sieve {I : Type*} [DecidableEq I] (S : Finset I) (w : I → ℂ) : + (∑T∈S.powerset, (-1 : ℂ)^T.card*∏i∈T, w i)=∏i∈S, (1-w i) := by + have h := Finset.prod_add (fun i => -w i) (fun _ => (1 : ℂ)) S + simp only [Finset.prod_const_one, mul_one, Finset.prod_neg] at h + simpa only [add_comm (-w _) 1, sub_eq_add_neg] using h.symm + +lemma zmodScale_primitive_general {m k : ℕ} [NeZero m] [NeZero k] + (ψ : AddChar (ZMod (m*k)) ℂ) (hψ : ψ.IsPrimitive) : + (ψ.compAddMonoidHom (zmodScaleHom m k)).IsPrimitive := by + intro a ha he + have h := congrArg (fun χ : AddChar (ZMod m) ℂ => χ 1) he + simp only [AddChar.mulShift_apply, mul_one, AddChar.compAddMonoidHom_apply, AddChar.one_apply] at h + have hz := (hψ.zmod_char_eq_one_iff (m*k) _).mp h + apply ha + exact zmodScaleHom_injective m k (NeZero.ne k) (by simpa only [map_zero] using hz) + +noncomputable def residueDensity {m q : ℕ} (hmq : m∣q) (c : ZMod m) (x : ZMod q) : ℝ := + if ZMod.castHom hmq (ZMod m) x=c then m else 0 + +lemma residueDensity_fourier_bound {m k : ℕ} [NeZero m] [NeZero k] + (ψ : AddChar (ZMod (m*k)) ℂ) (hψ : ψ.IsPrimitive) (c : ZMod m) : + HasFourierBound ψ (fun x => (residueDensity (dvd_mul_right m k) c x : ℂ)) m := by + classical + let φ := ZMod.castHom (dvd_mul_right m k) (ZMod m) + let χ := ψ.compAddMonoidHom (zmodScaleHom m k) + have hχ : χ.IsPrimitive := zmodScale_primitive_general ψ hψ + apply hasFourierBound_of_expansion ψ _ (fun a : ZMod m => zmodScaleHom m k a) + (fun a => χ (-a*c)) m + · intro x + have h := AddChar.sum_mulShift (φ x-c) hχ + simp only [ZMod.card, sub_eq_zero, Nat.cast_ite, Nat.cast_zero] at h + have he (a : ZMod m) : χ (-a*c)*ψ (zmodScaleHom m k a*x)=χ (a*(φ x-c)) := by + rw [← zmodScaleHom_mul] + change χ (-a*c)*χ (a*φ x)=χ (a*(φ x-c)) + rw [← AddChar.map_add_eq_mul] + congr 1 + ring + simp_rw [he] + rw [h] + simp only [residueDensity,φ] + split_ifs <;> simp + · simp only [AddChar.norm_apply, sum_const, card_univ, ZMod.card, nsmul_eq_mul, mul_one, le_refl] + +lemma residueDensity_fourier_dvd {m q : ℕ} [NeZero m] [NeZero q] + (hmq : m∣q) (ψ : AddChar (ZMod q) ℂ) (hψ : ψ.IsPrimitive) (c : ZMod m) : + HasFourierBound ψ (fun x => (residueDensity hmq c x : ℂ)) m := by + obtain ⟨k,rfl⟩ := hmq + have hk : k≠0 := by intro hk; have hh := NeZero.ne (m*k); simp [hk] at hh + let : NeZero k := ⟨hk⟩ + exact residueDensity_fourier_bound ψ hψ c + +lemma residueDensity_mean {m q : ℕ} [NeZero m] [NeZero q] + (hmq : m∣q) (c : ZMod m) : (𝔼 x : ZMod q, (residueDensity hmq c x : ℂ))=1 := by + classical + have hsur : Function.Surjective (ZMod.castHom hmq (ZMod m)) := + ZMod.ringHom_surjective _ + have h := expect_surjective_addHom (ZMod.castHom hmq (ZMod m)).toAddMonoidHom hsur + (fun x => if x=c then (m : ℂ) else 0) + have he (x : ZMod q) : (residueDensity hmq c x : ℂ) = + if ZMod.castHom hmq (ZMod m) x=c then (m : ℂ) else 0 := by + unfold residueDensity + split_ifs <;> simp + simp_rw [he] + change (𝔼 x : ZMod q, if ZMod.castHom hmq (ZMod m) x=c then (m : ℂ) else 0)= + (𝔼 x : ZMod m, if x=c then (m : ℂ) else 0) at h + have hm : (m : ℂ)≠0 := by exact_mod_cast NeZero.ne m + simpa only [expect_eq_sum_div_card, sum_ite_eq', mem_univ, ite_true, card_univ, + ZMod.card, div_self hm] using h + +lemma residueDensity_self (m : ℕ) [NeZero m] (c x : ZMod m) : + residueDensity (dvd_refl m) c x = if x=c then (m : ℝ) else 0 := by + have he : ZMod.castHom (dvd_refl m) (ZMod m)=RingHom.id (ZMod m) := Subsingleton.elim _ _ + simp only [residueDensity,he,RingHom.id_apply] + +lemma residueDensity_self_quadratic (m : ℕ) [NeZero m] (c : ZMod m) + (ψ : AddChar (ZMod m) ℂ) : + (𝔼 x : ZMod m, (residueDensity (dvd_refl m) c x : ℂ)*ψ (x^2))=ψ (c^2) := by + classical + have he (x : ZMod m) : (residueDensity (dvd_refl m) c x : ℂ)*ψ (x^2)= + if x=c then (m : ℂ)*ψ (c^2) else 0 := by + rw [residueDensity_self] + split_ifs with hx + · rw [hx]; simp + · simp + simp_rw [he] + simp only [expect_eq_sum_div_card,sum_ite_eq',mem_univ,ite_true,card_univ,ZMod.card] + have hm : (m : ℂ)≠0 := by exact_mod_cast NeZero.ne m + field_simp + +lemma residueDensity_quadratic_zero {p k : ℕ} [NeZero p] [NeZero k] + (hpk : p∣k) (ψ : AddChar (ZMod (p*k)) ℂ) (hψ : ψ.IsPrimitive) + (c : ZMod p) (hc : (2 : ZMod p)*c≠0) : + (𝔼 x : ZMod (p*k), (residueDensity (dvd_mul_right p k) c x : ℂ)*ψ (x^2))=0 := by + have he (x : ZMod (p*k)) : (residueDensity (dvd_mul_right p k) c x : ℂ)= + if ZMod.castHom (dvd_mul_right p k) (ZMod p) x=c then (p : ℂ) else 0 := by + unfold residueDensity + split_ifs <;> simp + simp_rw [he] + exact fiber_gauss_zero_char hpk ψ hψ c hc + +lemma zmod_cast_comp {a b c : ℕ} (hab : a∣b) (hbc : b∣c) : + (ZMod.castHom hab (ZMod a)).comp (ZMod.castHom hbc (ZMod b)) = + ZMod.castHom (hab.trans hbc) (ZMod a) := Subsingleton.elim _ _ + +lemma odd_square_eight (x : ZMod 8) + (hx : ZMod.castHom (by norm_num : 2∣8) (ZMod 2) x=1) : x^2=1 := by + revert x + decide + +lemma odd_square_of_dvd_eight {q : ℕ} [NeZero q] (h2 : 2∣q) (h8 : q∣8) + (x : ZMod q) (hx : ZMod.castHom h2 (ZMod 2) x=1) : x^2=1 := by + obtain ⟨z,rfl⟩ := ZMod.ringHom_surjective (ZMod.castHom h8 (ZMod q)) x + have hz : ZMod.castHom (h2.trans h8) (ZMod 2) z=1 := by + rw [← zmod_cast_comp h2 h8] + exact hx + have h := congrArg (ZMod.castHom h8 (ZMod q)) (odd_square_eight z hz) + simpa only [map_pow,map_one] using h + +lemma odd_root_quadratic_small {q : ℕ} [NeZero q] (h2 : 2∣q) (h8 : q∣8) + (ψ : AddChar (ZMod q) ℂ) : + (𝔼 x : ZMod q, (residueDensity h2 1 x : ℂ)*ψ (x^2))=ψ 1 := by + have he (x : ZMod q) : (residueDensity h2 1 x : ℂ)*ψ (x^2)= + (residueDensity h2 1 x : ℂ)*ψ 1 := by + by_cases hx : ZMod.castHom h2 (ZMod 2) x=1 + · rw [odd_square_of_dvd_eight h2 h8 x hx] + · simp only [residueDensity,ite_eq_right hx,Complex.ofReal_zero,zero_mul] + simp_rw [he] + rw [← expect_mul,residueDensity_mean,one_mul] + +lemma unit_four_iff_odd (x : ZMod 4) : + IsUnit x ↔ ZMod.castHom (by norm_num : 2∣4) (ZMod 2) x=1 := by + revert x + decide + +lemma odd_root_quadratic_large {k : ℕ} [NeZero k] (hk : 4∣k) + (ψ : AddChar (ZMod (4*k)) ℂ) (hψ : ψ.IsPrimitive) : + (𝔼 x : ZMod (4*k), + (residueDensity ((by norm_num : 2∣4).trans (dvd_mul_right 4 k)) 1 x : ℂ)*ψ (x^2))=0 := by + classical + have he (x : ZMod (4*k)) : + (residueDensity ((by norm_num : 2∣4).trans (dvd_mul_right 4 k)) 1 x : ℂ)= + 2*(if IsUnit (ZMod.castHom (dvd_mul_right 4 k) (ZMod 4) x) then (1 : ℂ) else 0) := by + simp only [unit_four_iff_odd] + have hc := DFunLike.congr_fun (zmod_cast_comp (by norm_num : 2∣4) (dvd_mul_right 4 k)) x + change ZMod.castHom (by norm_num : 2∣4) (ZMod 2) + (ZMod.castHom (dvd_mul_right 4 k) (ZMod 4) x)=_ at hc + rw [hc] + unfold residueDensity + split_ifs <;> norm_num + simp_rw [he,mul_assoc] + rw [← mul_expect,two_unit_gauss_zero_char hk ψ hψ,mul_zero] + +noncomputable def localSieveTerm {I : Type*} [DecidableEq I] + (S : Finset I) (a b : I → ℂ) (T : Finset I) : ℂ := + (-1)^T.card*(∏i∈S\T, a i)*∏i∈T, b i + +noncomputable def truncatedSieveMean {I : Type*} [DecidableEq I] + (S : Finset I) (p : I → ℕ) (H : ℝ) (a b : I → ℂ) : ℂ := + ∑T∈S.powerset, if ((∏i∈T, p i : ℕ) : ℝ)≤H then localSieveTerm S a b T else 0 + +lemma localSieveTerm_norm {I : Type*} [DecidableEq I] + (S T : Finset I) (hTS : T⊆S) (a b : I → ℂ) (k : I → ℝ) + (ha : ∀i∈S, ‖a i‖≤k i) (hb : ∀i∈S, ‖b i‖≤k i) : + ‖localSieveTerm S a b T‖≤∏i∈S, k i := by + have hk (i : I) (hi : i∈S) : 0≤k i := (norm_nonneg _).trans (ha i hi) + simp only [localSieveTerm,norm_mul,norm_pow,norm_neg,norm_one,one_pow,one_mul,norm_prod] + calc + _ ≤ (∏i∈S\T, k i)*(∏i∈T, k i) := by + apply mul_le_mul + · exact Finset.prod_le_prod₀ (fun _ _ => norm_nonneg _) (fun i hi => ha i (mem_sdiff.mp hi).1) + · exact Finset.prod_le_prod₀ (fun _ _ => norm_nonneg _) (fun i hi => hb i (hTS hi)) + · exact prod_nonneg (fun _ _ => norm_nonneg _) + · exact prod_nonneg (fun i hi => hk i (mem_sdiff.mp hi).1) + _ = _ := prod_sdiff hTS + +lemma truncatedSieveMean_bound {I : Type*} [DecidableEq I] + (S : Finset I) (p : I → ℕ) (H : ℝ) (a b : I → ℂ) (k : I → ℝ) + (ha : ∀i∈S, ‖a i‖≤k i) (hb : ∀i∈S, ‖b i‖≤k i) : + ‖truncatedSieveMean S p H a b‖≤(2 : ℝ)^S.card*∏i∈S, k i := by + unfold truncatedSieveMean + calc + _ ≤ ∑T∈S.powerset, ∏i∈S, k i := by + apply (norm_sum_le _ _).trans + apply sum_le_sum + intro T hT + split_ifs + · exact localSieveTerm_norm S T (mem_powerset.mp hT) a b k ha hb + · rw [norm_zero] + exact prod_nonneg (fun i hi => (norm_nonneg _).trans (ha i hi)) + _ = _ := by simp only [sum_const,nsmul_eq_mul,card_powerset,Nat.cast_pow,Nat.cast_ofNat] + +lemma truncatedSieveMean_complete {I : Type*} [DecidableEq I] + (S : Finset I) (p : I → ℕ) (H : ℝ) (a b : I → ℂ) + (hp : ∀i∈S, 1≤p i) (hH : ((∏i∈S, p i : ℕ) : ℝ)≤H) : + truncatedSieveMean S p H a b=∏i∈S, (a i-b i) := by + unfold truncatedSieveMean + calc + _ = ∑T∈S.powerset, localSieveTerm S a b T := by + apply sum_congr rfl + intro T hT + rw [ite_eq_left] + apply le_trans _ hH + exact_mod_cast prod_le_prod_of_subset_of_one_le₀ (mem_powerset.mp hT) + (fun _ _ => Nat.zero_le _) (fun i hi _ => hp i hi) + _ = _ := (prod_sub a b S).symm + +lemma localSieveTerm_product {I : Type*} [DecidableEq I] + (S T : Finset I) (hTS : T⊆S) (a b : I → ℂ) : + localSieveTerm S a b T=(-1 : ℂ)^T.card*∏i∈S, if i∈T then b i else a i := by + dsimp only [localSieveTerm] + rw [prod_ite] + have h1 : S.filter (fun i => i∈T)=T := by ext i; simp only [mem_filter]; exact ⟨And.right,fun h => ⟨hTS h,h⟩⟩ + have h2 : S.filter (fun i => i∉T)=S\T := by ext i; simp + rw [h1,h2] + ring + +lemma localSieveTerm_zero {I : Type*} [DecidableEq I] + (S U T : Finset I) (a b : I → ℂ) (hTU : ¬T⊆U) + (hb : ∀i∈T, i∉U → b i=0) : localSieveTerm S a b T=0 := by + obtain ⟨i,hi,hiU⟩ := not_subset.mp hTU + rw [localSieveTerm,prod_eq_zero hi (hb i hi hiU),mul_zero] + +lemma quadratic_sieve_bounds {p q : ℕ} [Fact p.Prime] [NeZero q] + (hpq : p∣q) (hq : IsUnit (2 : ZMod q)) + (ψ : AddChar (ZMod q) ℂ) (hψ : ψ.IsPrimitive) : + ‖𝔼 x : ZMod q, ψ (x^2)‖≤(q : ℝ)^(-(1 : ℝ)/2) ∧ + ‖𝔼 x : ZMod q, + (primeSieveWeight p (ZMod.castHom hpq (ZMod p) x) : ℂ)*ψ (x^2)‖≤ + (q : ℝ)^(-(1 : ℝ)/2) := by + constructor + · simpa only [mul_one,one_mul,ZMod.card] using + (hasFourierBound_one ψ).gauss hψ 1 (by simpa only [mul_one] using hq) + · simpa only [mul_one,one_mul,ZMod.card] using + (primeSieveWeight_fourier_dvd hpq ψ hψ).gauss hψ 1 (by simpa only [mul_one] using hq) + +lemma nonprime_sieve_mean_zero {p q : ℕ} [Fact p.Prime] [NeZero q] (hpq : p∣q) : + (𝔼 x : ZMod q, (primeSieveWeight p (ZMod.castHom hpq (ZMod p) x) : ℂ))=0 := by + have h := expect_surjective_addHom (ZMod.castHom hpq (ZMod p)).toAddMonoidHom + (ZMod.ringHom_surjective _) (fun x => (primeSieveWeight p x : ℂ)) + change (𝔼 x : ZMod q, (primeSieveWeight p (ZMod.castHom hpq (ZMod p) x) : ℂ))= + (𝔼 x : ZMod p, (primeSieveWeight p x : ℂ)) at h + rw [h] + have hz := primeSieveWeight_mean_zero (p := p) + exact_mod_cast hz + +noncomputable def unitQuadraticMean {R : Type*} [CommRing R] [Fintype R] + [DecidableEq R] (ψ : AddChar R ℂ) : ℂ := 𝔼 x : Rˣ, ψ ((x : R)^2) + +lemma prime_unit_quadratic {p : ℕ} [Fact p.Prime] (ψ : AddChar (ZMod p) ℂ) : + (𝔼 x : ZMod p, ψ (x^2))- + (𝔼 x : ZMod p, (primeSieveWeight p x : ℂ)*ψ (x^2))=unitQuadraticMean ψ := by + classical + have he (x : ZMod p) : ψ (x^2)-(primeSieveWeight p x : ℂ)*ψ (x^2)= + ((p : ℂ)/(p-1))*(if x≠0 then ψ (x^2) else 0) := by + have hh := congrArg (fun z : ℝ => (z : ℂ)) (primeSieveWeight_unit_density x) + push_cast at hh + calc + _ = (1-(primeSieveWeight p x : ℂ))*ψ (x^2) := by ring + _ = _ := by rw [hh]; split_ifs <;> simp only [Complex.ofReal_one,Complex.ofReal_zero] <;> ring + rw [← expect_sub_distrib] + simp_rw [he] + rw [← mul_expect] + have hs : (∑x : ZMod p, if x≠0 then ψ (x^2) else 0)= + ∑x : (ZMod p)ˣ, ψ ((x : ZMod p)^2) := by + rw [← sum_filter] + rw [sum_subtype (p := fun x : ZMod p => x≠0) _ (by intro x; simp only [mem_filter,mem_univ,true_and])] + symm + exact Fintype.sum_equiv unitsEquivNeZero _ _ (fun _ => rfl) + rw [expect_eq_sum_div_card,hs,unitQuadraticMean,expect_eq_sum_div_card] + simp only [Finset.card_univ,Fintype.card_units,ZMod.card] + have hp : (p : ℂ)≠0 := by exact_mod_cast (Fact.out : p.Prime).ne_zero + have hp1 : (1 : ℕ)≤p := (Fact.out : p.Prime).one_lt.le + rw [Nat.cast_sub hp1,Nat.cast_one] + field_simp + +end SquareDifference +end + +end OAI diff --git a/lean/OAI/Combinatorics/SquareDifference/SmallGood.lean b/lean/OAI/Combinatorics/SquareDifference/SmallGood.lean new file mode 100644 index 0000000000000000000000000000000000000000..cf46213d09c8ebc57dfabdd8a9a3e732d4a34532 --- /dev/null +++ b/lean/OAI/Combinatorics/SquareDifference/SmallGood.lean @@ -0,0 +1,106 @@ +import OAI.Combinatorics.SquareDifference.MixedTransfer + +namespace OAI + +section + +open Finset + +open scoped BigOperators + +namespace SquareDifference + +lemma exists_small_strict_steps (p : ℕ) [Fact p.Prime] : + ∃δ : ℕ → ZMod (smallQuadraticModulus p),(∀j,smallStrict p (δ j)) ∧ ∑j∈range 24,δ j=0 := by + by_cases h2 : p=2 + · subst p + refine ⟨fun _ => 1,fun j => ?_,?_⟩ + · simp only [smallStrict,ite_true] + · simp only [sum_const,card_range,nsmul_eq_mul,mul_one] + change (24 : ZMod 8)=0 + decide + · let e : ZMod (smallQuadraticModulus p) ≃+* ZMod p := RingEquiv.cast (ite_eq_right h2) + obtain ⟨δ,hδ,h0⟩ := exists_strict_square_steps p + refine ⟨fun j => e.symm (δ j),?_,?_⟩ + · intro j + simp only [smallStrict,h2,ite_false] + refine ⟨fun he => (hδ j).1 (e.symm.injective (he.trans e.symm.map_zero.symm)),?_⟩ + obtain ⟨a,ha⟩ := (hδ j).2 + exact ⟨e.symm a,by rw [ha,map_mul]⟩ + · rw [←map_sum,h0,map_zero] + +section Small + +variable {S : Type*} [Fintype S] [instDecidableEqS : DecidableEq S] (ps : S → ℕ) [∀s,Fact (ps s).Prime] + +lemma smallModulus_pos {S : Type*} + [Fintype S] + [DecidableEq S] + (ps : S → ℕ) + [∀ (s : S), Fact (Nat.Prime (ps s))] : 0 smallQuadraticModulus_pos (Fact.out : (ps s).Prime)) + +noncomputable def smallResidueEquiv (hinj : Function.Injective ps) : + ZMod (smallModulus ps) ≃+* (∀s,ZMod (smallQuadraticModulus (ps s))) := + ZMod.prodEquivPi _ (smallQuadraticModuli_pairwise ps (fun _ => Fact.out) hinj) + +lemma smallResidueEquiv_apply (hinj : Function.Injective ps) (x : ZMod (smallModulus ps)) (s : S) : + smallResidueEquiv ps hinj x s=smallProjection ps s x := by + exact ZMod.prodEquivPi_apply (fun s => smallQuadraticModulus (ps s)) + (smallQuadraticModuli_pairwise ps (fun _ => Fact.out) hinj) x s + +lemma exists_small_product_steps (hinj : Function.Injective ps) : + ∃δ : ℕ → ZMod (smallModulus ps),(∀j s,smallStrict (ps s) (smallProjection ps s (δ j))) ∧ ∑j∈range 24,δ j=0 := by + classical + choose δ hδ hs using fun s => exists_small_strict_steps (ps s) + let e := smallResidueEquiv ps hinj + refine ⟨fun j => e.symm (fun s => δ s j),?_,?_⟩ + · intro j s + rw [←smallResidueEquiv_apply ps hinj] + change smallStrict (ps s) (e (e.symm (fun s => δ s j)) s) + rw [e.apply_symm_apply] + exact hδ s j + · apply e.injective + rw [map_sum,map_zero] + simp only [e.apply_symm_apply] + funext s + simp only [Finset.sum_apply,Pi.zero_apply] + exact hs s + +noncomputable def goodSmallAssignment (s : TupleVertex → ZMod (smallModulus ps)) : Prop := + ∀k<24,smallStrictPair ps (s (cycleVertex k)) (s (cycleVertex (k+1))) + +lemma exists_goodSmallAssignment (hinj : Function.Injective ps) : ∃s,goodSmallAssignment ps s := by + obtain ⟨δ,hδ,hδ0⟩ := exists_small_product_steps ps hinj + obtain ⟨s,hs⟩ := exists_cyclic_labels (fun j : Fin 24 => cycleVertex j.val) cycleVertex_fin_injective δ hδ0 + refine ⟨s,fun k hk i => ?_⟩ + have hh := hs (⟨k,hk⟩ : Fin 24) + rw [cycleVertex_fin_successor] at hh + change s (cycleVertex (k+1))-s (cycleVertex k)=δ k at hh + rw [hh] + exact hδ k i + +noncomputable def goodSmallProbability : ℝ := by + classical + letI : NeZero (smallModulus ps) := ⟨(smallModulus_pos ps).ne'⟩ + exact 𝔼 s : TupleVertex → ZMod (smallModulus ps),if goodSmallAssignment ps s then (1:ℝ) else 0 + +lemma goodSmallProbability_pos (hinj : Function.Injective ps) : 0 by split_ifs <;> norm_num) + _ = 1 := Fintype.expect_const 1 + +end Small + +end SquareDifference + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SquareDifference/SmallRoots.lean b/lean/OAI/Combinatorics/SquareDifference/SmallRoots.lean new file mode 100644 index 0000000000000000000000000000000000000000..f30fd0024ea6c782e951b3dd4a75666c423481ff --- /dev/null +++ b/lean/OAI/Combinatorics/SquareDifference/SmallRoots.lean @@ -0,0 +1,65 @@ +import OAI.Combinatorics.SquareDifference.IntervalCoefficient + +namespace OAI + +section + +open Finset + +open scoped BigOperators + +namespace SquareDifference + +open LiftTheory.SquareDifference + +noncomputable def smallStrict (p : ℕ) (x : ZMod (smallQuadraticModulus p)) : Prop := + if p=2 then x=1 else x≠0 ∧ IsSquare x + +lemma exists_small_root (p : ℕ) [Fact p.Prime] (x : ZMod (smallQuadraticModulus p)) + (hx : smallStrict p x) : ∃c : ZMod p,(if p=2 then c=1 else c≠0) ∧ smallRootSquare p c=x := by + classical + by_cases h2 : p=2 + · subst p + refine ⟨1,by simp,?_⟩ + simpa only [smallStrict,smallRootSquare,ite_true] using hx.symm + · have he : smallQuadraticModulus p=p := by simp only [smallQuadraticModulus,h2,ite_false] + let e : ZMod (smallQuadraticModulus p) ≃+* ZMod p := RingEquiv.cast he + have hx' : x≠0 ∧ IsSquare x := by simpa only [smallStrict,h2,ite_false] using hx + have hn := hx'.1 + have hs := hx'.2 + obtain ⟨y,hy⟩ := hs + refine ⟨e y,by simpa only [h2,ite_false] using (show e y≠0 from fun hz => hn (by + have hy0 : y=0 := e.injective (by simpa using hz) + simp only [hy0,mul_zero] at hy; exact hy)),?_⟩ + apply e.injective + rw [hy,map_mul] + have hh : e (smallRootSquare p (e y))=(e y)^2 := by + simp only [smallRootSquare,h2,ite_false,map_pow,map_natCast,ZMod.natCast_zmod_val] + rw [hh,pow_two] + +section Small + +variable {S : Type*} [Fintype S] [instDecidableEqS : DecidableEq S] (ps : S → ℕ) + +noncomputable def smallModulus : ℕ := ∏s,smallQuadraticModulus (ps s) + +lemma smallModulus_dvd {S : Type*} + [Fintype S] + [DecidableEq S] + (ps : S → ℕ) (s : S) : smallQuadraticModulus (ps s)∣smallModulus ps := dvd_prod_of_mem _ (mem_univ s) + +noncomputable def smallProjection (s : S) : ZMod (smallModulus ps) →+* ZMod (smallQuadraticModulus (ps s)) := + ZMod.castHom (smallModulus_dvd ps s) _ + +@[simp] lemma smallProjection_nat (s : S) (n : ℕ) : smallProjection ps s (n:ZMod (smallModulus ps))=(n:ZMod (smallQuadraticModulus (ps s))) := map_natCast _ _ + +noncomputable def smallStrictPair (s t : ZMod (smallModulus ps)) : Prop := + ∀i,smallStrict (ps i) (smallProjection ps i (t-s)) + +end Small + +end SquareDifference + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SquareDifference/TensorLaw.lean b/lean/OAI/Combinatorics/SquareDifference/TensorLaw.lean new file mode 100644 index 0000000000000000000000000000000000000000..d290c91e8a9f1ee0c2bd87bc96cb0cb542b40ec1 --- /dev/null +++ b/lean/OAI/Combinatorics/SquareDifference/TensorLaw.lean @@ -0,0 +1,186 @@ +import OAI.Combinatorics.SquareDifference.OutsideFourier + +namespace OAI + +section + +open Finset + +open scoped BigOperators + +namespace SquareDifference + +open Finset + +section TensorExpansion + +variable {J V : Type*} [Fintype J] [DecidableEq J] [Fintype V] [DecidableEq V] + {X : J → Type*} [∀j,Fintype (X j)] [∀j,DecidableEq (X j)] + (L E : ∀j,((V → X j) → ℝ) →ₗ[ℝ] ℝ) + +noncomputable def mixedTensorLaw (B : Finset J) : ((V → ∀j,X j) → ℝ) →ₗ[ℝ] ℝ := + tensorLaw (fun j => if j∈B then E j else L j) + +lemma mixedTensorLaw_empty : mixedTensorLaw L E ∅=tensorLaw L := by + simp only [mixedTensorLaw,Finset.notMem_empty,ite_false] + +lemma mixedTensorLaw_nonneg (hL : ∀j F,(∀z,0≤F z) → 0≤L j F) + (hE : ∀j F,(∀z,0≤F z) → 0≤E j F) (B : Finset J) (F : (V → ∀j,X j) → ℝ) + (hF : ∀z,0≤F z) : 0 ≤ mixedTensorLaw L E B F := by + apply tensorLaw_nonneg _ _ F hF + intro j G hG + split_ifs + · exact hE j G hG + · exact hL j G hG + +lemma mixedTensorLaw_mass (hL : ∀j,L j (fun _ => 1)=1) (B : Finset J) : + mixedTensorLaw L E B (fun _ => 1)=∏j∈B,E j (fun _ => 1) := by + have hh := tensorLaw_fubini (fun j => if j∈B then E j else L j) (fun _ _ => 1) + have he (j : J) : (if j∈B then E j else L j) (fun _ => 1)=if j∈B then E j (fun _ => 1) else 1 := by + by_cases hj : j∈B <;> simp only [hj,ite_true,ite_false,hL] + simpa only [prod_const_one,he,prod_ite_mem,univ_inter,mixedTensorLaw] using hh + +lemma tensorLaw_scalar (c : J → ℝ) (F : (V → ∀j,X j) → ℝ) : + tensorLaw (fun j => c j • L j) F=(∏j,c j)*tensorLaw L F := by + change (∑z : ∀j,V → X j,(∏j,lawDensity (c j • L j) (z j))*F (fun v j => z j v))=_ + simp only [lawDensity,LinearMap.smul_apply,smul_eq_mul,prod_mul_distrib,mul_assoc,←mul_sum] + rfl + +lemma tensorLaw_sub_expansion (F : (V → ∀j,X j) → ℝ) : + tensorLaw (fun j => L j-E j) F= + ∑B : Finset J,(-1:ℝ)^B.card*mixedTensorLaw L E B F := by + change (∑z : ∀j,V → X j,(∏j,lawDensity (L j-E j) (z j))*F (fun v j => z j v))=_ + simp only [lawDensity,LinearMap.sub_apply] + simp_rw [prod_sub] + simp only [powerset_univ,sum_mul] + rw [sum_comm] + apply sum_congr rfl + intro B _ + change (∑x : ∀j,V → X j,_) = (-1:ℝ)^B.card*(∑x : ∀j,V → X j,_) + rw [mul_sum] + apply sum_congr rfl + intro z _ + have he : (∏j,lawDensity (if j∈B then E j else L j) (z j))= + (∏j∈univ\B,lawDensity (L j) (z j))*(∏j∈B,lawDensity (E j) (z j)) := by + rw [←prod_mul_prod_compl B (fun j => lawDensity (if j∈B then E j else L j) (z j))] + have h₁ : (∏j∈B,lawDensity (if j∈B then E j else L j) (z j))=∏j∈B,lawDensity (E j) (z j) := by + apply prod_congr rfl + intro j hj + rw [ite_eq_left hj] + have h₂ : (∏j∈Bᶜ,lawDensity (if j∈B then E j else L j) (z j))=∏j∈Bᶜ,lawDensity (L j) (z j) := by + apply prod_congr rfl + intro j hj + rw [ite_eq_right (mem_compl.mp hj)] + rw [h₁,h₂,mul_comm] + rfl + change (-1:ℝ)^B.card*(_)*(_)*_=(-1:ℝ)^B.card*((∏j,lawDensity (if j∈B then E j else L j) (z j))*_) + rw [he] + simp only [lawDensity] + ring + +lemma tensorLaw_exceptional_bound (_ : ∀j,L j (fun _ => 1)=1) + (G : ∀j,((V → X j) → ℝ) →ₗ[ℝ] ℝ) (eta : J → ℝ) + (heta : ∀j,eta j∈Set.Icc (0:ℝ) 1) + (hdec : ∀j,L j-E j=(1-eta j) • G j) + (F : (V → ∀j,X j) → ℝ) : + |tensorLaw L F|≤|tensorLaw G F|+ + ∑B∈(univ : Finset (Finset J)).erase ∅,|mixedTensorLaw L E B F| := by + have he := tensorLaw_sub_expansion L E F + simp_rw [hdec] at he + rw [tensorLaw_scalar] at he + rw [←sum_erase_add _ _ (mem_univ (∅ : Finset J))] at he + simp only [card_empty,pow_zero,one_mul,mixedTensorLaw_empty] at he + have hc : 0≤∏j,(1-eta j) := prod_nonneg (fun j _ => sub_nonneg.mpr (heta j).2) + have hc' : (∏j,(1-eta j))≤1 := prod_le_one₀ (fun j _ => sub_nonneg.mpr (heta j).2) + (fun j _ => sub_le_self _ (heta j).1) + have ha : |(∏j,(1-eta j))*tensorLaw G F|≤|tensorLaw G F| := by + rw [abs_mul,abs_of_nonneg hc] + exact mul_le_of_le_one_left (abs_nonneg _) hc' + have hb : |∑B∈(univ : Finset (Finset J)).erase ∅,(-1:ℝ)^B.card*mixedTensorLaw L E B F|≤ + ∑B∈(univ : Finset (Finset J)).erase ∅,|mixedTensorLaw L E B F| := by + apply (abs_sum_le_sum_abs _ _).trans + exact sum_le_sum (fun B _ => by simp only [abs_mul,abs_pow,abs_neg,abs_one,one_pow,one_mul,le_refl]) + have he' : tensorLaw L F=(∏j,(1-eta j))*tensorLaw G F- + ∑B∈(univ : Finset (Finset J)).erase ∅,(-1:ℝ)^B.card*mixedTensorLaw L E B F := by linarith + rw [he'] + exact (abs_sub _ _).trans (add_le_add ha hb) + +end TensorExpansion + +end SquareDifference + +namespace SquareDifference + +open Finset + +section TensorFreeze + +variable {J V : Type*} [Fintype J] [DecidableEq J] [Fintype V] [DecidableEq V] + {X : J → Type*} [∀j,Fintype (X j)] [∀j,DecidableEq (X j)] + (M L : ∀j,((V → X j) → ℝ) →ₗ[ℝ] ℝ) + +noncomputable def frozenTensorLaw (B : Finset J) : ((V → ∀j,X j) → ℝ) →ₗ[ℝ] ℝ where + toFun F := tensorLaw M (fun z => tensorLaw L (fun x => F (fun v j => if j∈B then z v j else x v j))) + map_add' F G := by + simp only [Pi.add_apply] + simp only [←Pi.add_def,map_add] + map_smul' c F := by + simp only [Pi.smul_apply,←Pi.smul_def,map_smul,RingHom.id_apply] + +lemma tensorLaw_freeze (B : Finset J) (hL : ∀j,L j (fun _ => 1)=1) + (hML : ∀j,j∉B → M j=L j) (F : (V → ∀j,X j) → ℝ) : + tensorLaw M (fun z => tensorLaw L (fun x => F (fun v j => if j∈B then z v j else x v j)))=tensorLaw M F := by + have hd (y : V → ∀j,X j) : lawDensity (frozenTensorLaw M L B) y=lawDensity (tensorLaw M) y := by + change tensorLaw M (fun z => tensorLaw L (fun x => if (fun v j => if j∈B then z v j else x v j)=y then 1 else 0))=_ + have hind (z x : V → ∀j,X j) : + (if (fun v j => if j∈B then z v j else x v j)=y then (1:ℝ) else 0)= + ∏j,if j∈B then (if (fun v => z v j)=(fun v => y v j) then 1 else 0) + else (if (fun v => x v j)=(fun v => y v j) then 1 else 0) := by + have he : (fun v j => if j∈B then z v j else x v j)=y ↔ + ∀j,(if j∈B then (fun v => z v j) else (fun v => x v j))=(fun v => y v j) := by + constructor + · intro h j; funext v; simpa only [ite_apply] using congrFun (congrFun h v) j + · intro h; funext v j; simpa only [ite_apply] using congrFun (h j) v + simp only [he] + rw [←prod_indicator_forall] + apply prod_congr rfl + intro j _ + split_ifs <;> rfl + simp_rw [hind] + have hi (z : V → ∀j,X j) : + tensorLaw L (fun x => ∏j,if j∈B then (if (fun v => z v j)=(fun v => y v j) then 1 else 0) + else (if (fun v => x v j)=(fun v => y v j) then 1 else 0))= + ∏j,if j∈B then (if (fun v => z v j)=(fun v => y v j) then 1 else 0) + else lawDensity (L j) (fun v => y v j) := by + rw [tensorLaw_fubini L (fun j w => if j∈B then (if (fun v => z v j)=(fun v => y v j) then 1 else 0) + else (if w=(fun v => y v j) then 1 else 0))] + apply prod_congr rfl + intro j _ + by_cases hj : j∈B + · simp only [hj,ite_true] + by_cases hz : (fun v => z v j)=(fun v => y v j) + · simp only [hz,ite_true,hL] + · simp only [hz,ite_false] + exact (L j).map_zero + · simp only [hj,ite_false,lawDensity] + simp_rw [hi] + rw [tensorLaw_fubini M (fun j w => if j∈B then (if w=(fun v => y v j) then 1 else 0) + else lawDensity (L j) (fun v => y v j)),tensorLaw_density] + apply prod_congr rfl + intro j _ + by_cases hj : j∈B + · simp only [hj,ite_true,lawDensity] + · simp only [hj,ite_false,hML j hj] + simpa only [Pi.smul_def,smul_eq_mul,mul_one,hL] using + (L j).map_smul (lawDensity (L j) (fun v => y v j)) (fun _ => (1:ℝ)) + change frozenTensorLaw M L B F=tensorLaw M F + rw [linearFunctional_density (frozenTensorLaw M L B),linearFunctional_density (tensorLaw M)] + exact sum_congr rfl (fun y _ => congrArg (fun t => t*F y) (hd y)) + +end TensorFreeze + +end SquareDifference + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SquareDifference/TensorPair.lean b/lean/OAI/Combinatorics/SquareDifference/TensorPair.lean new file mode 100644 index 0000000000000000000000000000000000000000..e92867ae238b45b29507b1622880b7d4e1602e30 --- /dev/null +++ b/lean/OAI/Combinatorics/SquareDifference/TensorPair.lean @@ -0,0 +1,186 @@ +import OAI.Combinatorics.SquareDifference.TensorLaw + +namespace OAI + +section + +open Finset + +open scoped BigOperators + +namespace SquareDifference + +section TensorPair + +variable {J V : Type*} [Fintype J] [instDecidableEqJ : DecidableEq J] [Fintype V] [DecidableEq V] + {X Ω : J → Type*} [instFintypeXj : ∀j,Fintype (X j)] [∀j,DecidableEq (X j)] [∀j,Fintype (Ω j)] + (L : ∀j,((V → X j) → ℝ) →ₗ[ℝ] ℝ) (u v : V) + (a b : ∀j,Ω j → X j) + +noncomputable def pairPush : (((∀j,X j) × (∀j,X j)) → ℝ) →ₗ[ℝ] ℝ where + toFun F := tensorLaw L (fun z => F (z u,z v)) + map_add' F G := by simp only [Pi.add_apply,←Pi.add_def,map_add] + map_smul' c F := by simp only [Pi.smul_apply,←Pi.smul_def,map_smul,RingHom.id_apply] + +noncomputable def pairSample : (((∀j,X j) × (∀j,X j)) → ℝ) →ₗ[ℝ] ℝ where + toFun F := 𝔼 w : ∀j,Ω j,F (fun j => a j (w j),fun j => b j (w j)) + map_add' F G := by simp only [Pi.add_apply,expect_add_distrib] + map_smul' c F := by simp only [Pi.smul_apply,smul_eq_mul,mul_expect,RingHom.id_apply] + +lemma pair_indicator_pi {J : Type*} + [Fintype J] + [DecidableEq J] + {X : J → Type*} + [(j : J) → Fintype (X j)] + [(j : J) → DecidableEq (X j)] (x y r s : ∀j,X j) : + (if (x,y)=(r,s) then (1:ℝ) else 0)=∏j,if (x j,y j)=(r j,s j) then 1 else 0 := by + rw [prod_indicator_forall] + congr 1 + apply propext + constructor + · intro h; cases h; simp + · intro h + apply Prod.ext + · funext j; exact congrArg Prod.fst (h j) + · funext j; exact congrArg Prod.snd (h j) + +lemma tensorLaw_pair_sampling + (hloc : ∀j (F : X j → X j → ℝ),L j (fun z => F (z u) (z v))=𝔼 w,F (a j w) (b j w)) + (F : (∀j,X j) → (∀j,X j) → ℝ) : + tensorLaw L (fun z => F (z u) (z v))= + 𝔼 w : ∀j,Ω j,F (fun j => a j (w j)) (fun j => b j (w j)) := by + have hd (y : (∀j,X j) × (∀j,X j)) : + lawDensity (pairPush L u v) y=lawDensity (pairSample a b) y := by + rcases y with ⟨r,s⟩ + change tensorLaw L (fun z => if (z u,z v)=(r,s) then (1:ℝ) else 0)= + 𝔼 w : ∀j,Ω j,if ((fun j => a j (w j)),(fun j => b j (w j)))=(r,s) then 1 else 0 + simp_rw [pair_indicator_pi] + rw [tensorLaw_fubini L (fun j z => if (z u,z v)=(r j,s j) then 1 else 0)] + rw [expect_prod_pi (fun j w => if (a j w,b j w)=(r j,s j) then (1:ℝ) else 0)] + apply prod_congr rfl + intro j _ + exact hloc j (fun x y => if (x,y)=(r j,s j) then 1 else 0) + change pairPush L u v (fun z => F z.1 z.2)=pairSample a b (fun z => F z.1 z.2) + rw [linearFunctional_density,linearFunctional_density] + exact sum_congr rfl (fun y _ => congrArg (fun t => t*F y.1 y.2) (hd y)) + +end TensorPair + +section PiProduct + +variable {J : Type*} [Fintype J] [DecidableEq J] {X Y : J → Type*} + [∀j,Fintype (X j)] [∀j,Fintype (Y j)] + +def piProductEquiv : (∀j,X j × Y j) ≃ (∀j,X j) × (∀j,Y j) where + toFun z := (fun j => (z j).1,fun j => (z j).2) + invFun z j := (z.1 j,z.2 j) + left_inv _ := rfl + right_inv _ := rfl + +lemma expect_pi_product (F : (∀j,X j) → (∀j,Y j) → ℝ) : + (𝔼 w : ∀j,X j × Y j,F (fun j => (w j).1) (fun j => (w j).2))=𝔼 x,𝔼 y,F x y := by + rw [Fintype.expect_equiv piProductEquiv (fun w => F (fun j => (w j).1) (fun j => (w j).2)) (fun w => F w.1 w.2) (fun _ => rfl)] + rw [←univ_product_univ,expect_product] + +end PiProduct + +lemma tensorLaw_pair_product_sampling {J V : Type*} [Fintype J] [DecidableEq J] + [Fintype V] [DecidableEq V] {X Y : J → Type*} [∀j,Fintype (X j)] + [∀j,DecidableEq (X j)] [∀j,Fintype (Y j)] + (L : ∀j,((V → X j) → ℝ) →ₗ[ℝ] ℝ) (u v : V) (t : ∀j,Y j → X j → X j) + (hloc : ∀j (G : X j → X j → ℝ),L j (fun z => G (z u) (z v))= + 𝔼 w : Y j × X j,G w.2 (t j w.1 w.2)) + (F : (∀j,X j) → (∀j,X j) → ℝ) : + tensorLaw L (fun z => F (z u) (z v))= + 𝔼 w : ∀j,Y j,𝔼 x,F x (fun j => t j (w j) (x j)) := by + exact (tensorLaw_pair_sampling L u v (fun j (w : Y j × X j) => w.2) + (fun j (w : Y j × X j) => t j w.1 w.2) hloc F).trans + (expect_pi_product (fun w x => F x (fun j => t j (w j) (x j)))) + +lemma tupleGoodLaw_pair_product {p : ℕ} [Fact p.Prime] + (hp : tupleMassThreshold ≤ (p:ℝ)) (k : ℕ) (G : ZMod p → ZMod p → ℝ) : + tupleGoodLaw (fun z => G (z (cycleVertex k)) (z (cycleVertex (k+1))))= + 𝔼 w : (ZMod p)ˣ × ZMod p,G w.2 (w.2+(w.1:ZMod p)^2) := by + rw [tupleGoodLaw_pair hp,squarePairAverage,←univ_product_univ,expect_product] + +lemma tensorLaw_squarePair_sampling {J V : Type*} [Fintype J] [DecidableEq J] [Fintype V] [DecidableEq V] + (p : J → ℕ) [∀j,Fact (p j).Prime] + (L : ∀j,((V → ZMod (p j)) → ℝ) →ₗ[ℝ] ℝ) (u v : V) + (hloc : ∀j (G : ZMod (p j) → ZMod (p j) → ℝ),L j + (fun z => G (z u) (z v))=𝔼 w : (ZMod (p j))ˣ × ZMod (p j),G w.2 (w.2+(w.1:ZMod (p j))^2)) + (F : (∀j,ZMod (p j)) → (∀j,ZMod (p j)) → ℝ) : + tensorLaw L (fun z => F (z u) (z v))= + 𝔼 w : ∀j,(ZMod (p j))ˣ × ZMod (p j), + F (fun j => (w j).2) (fun j => (w j).2+((w j).1:ZMod (p j))^2) := by + exact tensorLaw_pair_sampling (X:=fun j => ZMod (p j)) + (Ω:=fun j => (ZMod (p j))ˣ × ZMod (p j)) L u v + (fun j (w : (ZMod (p j))ˣ × ZMod (p j)) => w.2) + (fun j (w : (ZMod (p j))ˣ × ZMod (p j)) => w.2+(w.1:ZMod (p j))^2) hloc F + +lemma tensorGood_pair [Fintype TupleVertex] [DecidableEq TupleVertex] {J : Type*} [Fintype J] [DecidableEq J] + (p : J → ℕ) [∀j,Fact (p j).Prime] (hp : ∀j,tupleMassThreshold ≤ (p j:ℝ)) + (k : ℕ) (F : (∀j,ZMod (p j)) → (∀j,ZMod (p j)) → ℝ) : + tensorLaw (fun j => tupleGoodLaw (p:=p j)) + (fun z => F (z (cycleVertex k)) (z (cycleVertex (k+1))))= + 𝔼 w : ∀j,(ZMod (p j))ˣ,𝔼 x : ∀j,ZMod (p j),F x (fun j => x j+(w j:ZMod (p j))^2) := by + calc + _ = 𝔼 w : ∀j,(ZMod (p j))ˣ × ZMod (p j), + F (fun j => (w j).2) (fun j => (w j).2+((w j).1:ZMod (p j))^2) := by + apply tensorLaw_squarePair_sampling p (fun j => tupleGoodLaw (p:=p j)) + (cycleVertex k) (cycleVertex (k+1)) + intro j G + exact tupleGoodLaw_pair_product (hp j) k G + _ = _ := expect_pi_product (fun (w : ∀j,(ZMod (p j))ˣ) (x : ∀j,ZMod (p j)) => + F x (fun j => x j+(w j:ZMod (p j))^2)) + +lemma expect_restrict_compl {J : Type*} [Fintype J] [DecidableEq J] + {X : J → Type*} [∀j,Fintype (X j)] [∀j,Nonempty (X j)] (B : Finset J) + {E : Type*} [AddCommMonoid E] [Module ℚ≥0 E] + (F : (∀j : {j : J // j∉B},X j.val) → E) : + (𝔼 x : ∀j,X j,F (fun j => x j.val))=𝔼 x,F x := by + let e := Equiv.piEquivPiSubtypeProd (fun j : J => j∈B) X + rw [Fintype.expect_equiv e (fun x => F (fun j => x j.val)) (fun x => F x.2) (fun _ => rfl)] + rw [←univ_product_univ,expect_product] + simp only [Fintype.expect_const] + +section FrozenPair + +variable [Fintype TupleVertex] [DecidableEq TupleVertex] + +open LiftTheory.SquareDifference PairBridge + +variable {J : Type*} [Fintype J] [DecidableEq J] + (p : J → ℕ) [∀j,Fact (p j).Prime] (hp : ∀j,tupleMassThreshold ≤ (p j:ℝ)) + +include hp in +lemma tensorGood_frozen_pair (k : ℕ) (B : Finset J) (r s : ResidueSpace p) + (F G : ResidueSpace p → ℝ) : + (tensorLaw (fun j => tupleGoodLaw (p:=p j)) (fun z => + F (freezeCoordinates B r (z (cycleVertex k)))* + G (freezeCoordinates B s (z (cycleVertex (k+1))))):ℂ)= + squarePairForm (OutsideModulus p B) + (fun x => (F (assembleOutside p B r x):ℂ)) + (fun x => (G (assembleOutside p B s x):ℂ)) := by + rw [tensorGood_pair p hp k (fun x y => F (freezeCoordinates B r x)*G (freezeCoordinates B s y))] + have he (w : ∀j,(ZMod (p j))ˣ) (x : ResidueSpace p) : + freezeCoordinates B s (fun j => x j+(w j:ZMod (p j))^2)= + assembleOutside p B s ((outsideCoordinate p B x)+(fun j : {j : J // j∉B} => (w j.val:ZMod (p j.val))^2)) := by + funext j + simp only [freezeCoordinates,assembleOutside,Pi.add_apply,outsideCoordinate] + split_ifs <;> rfl + simp_rw [←assembleOutside_freeze p B r,he] + have hbase (w : ∀j,(ZMod (p j))ˣ) := expect_outside p B + (fun x => F (assembleOutside p B r x)*G (assembleOutside p B s (x+(fun j : {j : J // j∉B} => (w j.val:ZMod (p j.val))^2)))) + simp_rw [hbase] + rw [expect_restrict_compl (X:=fun j => (ZMod (p j))ˣ) B + (fun w => 𝔼 x,F (assembleOutside p B r x)*G (assembleOutside p B s (x+(fun j => (w j:ZMod (p j.val))^2))))] + simp only [squarePairForm,expect_eq_sum_div_card,Complex.ofReal_div,Complex.ofReal_sum, + Complex.ofReal_natCast,Complex.ofReal_mul] + +end FrozenPair + +end SquareDifference + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SquareDifference/TransferParameters.lean b/lean/OAI/Combinatorics/SquareDifference/TransferParameters.lean new file mode 100644 index 0000000000000000000000000000000000000000..5c3fce56efee50ceb386a0034501151294126e2a --- /dev/null +++ b/lean/OAI/Combinatorics/SquareDifference/TransferParameters.lean @@ -0,0 +1,114 @@ +import OAI.Combinatorics.SquareDifference.PowerParameters + +namespace OAI + +section + +open Finset Filter + +open scoped Topology + +namespace SquareDifference + +lemma sourceTau_lt_halfBeta (d : ℕ) : sourceTau d < sourceBeta/2 := + (sourceTau_le d).trans_lt (by norm_num [sourceBeta,sourceGamma]) + +lemma eventual_cutoff_size (a : ℝ) (ha : 0 transferFactor d M N) atTop (𝓝 1) := by + have ht : 0<1-2*sourceTau d := by have := sourceTau_lt_quarter d; linarith + have hh := (tendsto_rpow_neg_atTop ht).comp tendsto_natCast_atTop_atTop + have he : -(1-2*sourceTau d)=2*sourceTau d-1 := by ring + have hh' : Tendsto (fun N : ℕ => (N:ℝ)^(2*sourceTau d-1)) atTop (𝓝 0) := by + simpa only [he,Function.comp_def] using hh + have h : Tendsto (fun N : ℕ => (1+(M:ℝ)^2*(N:ℝ)^(2*sourceTau d-1))^d) atTop (𝓝 ((1+(M:ℝ)^2*0)^d)) := + (tendsto_const_nhds.add (tendsto_const_nhds.mul hh')).pow d + simpa only [mul_zero,add_zero,one_pow,transferFactor] using h + +lemma child_factor_le (d M N q : ℕ) (hN : 0 sum_nonneg fun y _ => mul_nonneg (hH x y) (by positivity) + +lemma one_le_indexWeight {I J : Type*} [Fintype I] [DecidableEq J] + (H : Matrix I I ℝ) (hH : ∀ x y, 0 ≤ H x y) (j : I → J) : + 1 ≤ indexWeight H j := Real.one_le_exp_iff.mpr (indexEnergy_nonneg H hH j) + +lemma indexCross_equiv {I K J : Type*} [Fintype I] [Fintype K] [DecidableEq J] + (e : I ≃ K) (H : Matrix K K ℝ) (j k : K → J) : + indexCross (H.submatrix e e) (j ∘ e) (k ∘ e) = indexCross H j k := by + unfold indexCross + apply Fintype.sum_equiv e + intro x + exact Fintype.sum_equiv e _ _ (fun y => rfl) + +lemma indexCross_transpose {I J : Type*} [Fintype I] [DecidableEq J] + (H : Matrix I I ℝ) (j k : I → J) : + indexCross H.transpose k j = indexCross H j k := by + unfold indexCross + rw [sum_comm] + simp only [Matrix.transpose_apply, eq_comm] + +lemma indexCross_sum {I J : Type*} [Fintype I] [DecidableEq J] + (H : Matrix (I ⊕ I) (I ⊕ I) ℝ) (j k : I → J) : + indexCross H (Sum.elim j k) (Sum.elim j k) = + indexCross (H.submatrix Sum.inl Sum.inl) j j + + indexCross (H.submatrix Sum.inl Sum.inr) j k + + indexCross (H.submatrix Sum.inr Sum.inl) k j + + indexCross (H.submatrix Sum.inr Sum.inr) k k := by + simp only [indexCross, Fintype.sum_sum_type, Sum.elim_inl, Sum.elim_inr, + Matrix.submatrix_apply, sum_add_distrib] + simp only [add_assoc, add_left_comm] + rfl + +lemma indexWeight_factor {I J : Type*} [Fintype I] [DecidableEq J] + (H : Matrix (I ⊕ I) (I ⊕ I) ℝ) + (hsym : ∀ x y, H (Sum.inr x) (Sum.inl y) = H (Sum.inl y) (Sum.inr x)) + (href : ∀ x y, H (Sum.inr x) (Sum.inr y) = H (Sum.inl x) (Sum.inl y)) + (j k : I → J) : + indexWeight H (Sum.elim j k) = + indexWeight (H.submatrix Sum.inl Sum.inl) j * + Real.exp (indexCross (H.submatrix Sum.inl Sum.inr) j k) * + indexWeight (H.submatrix Sum.inl Sum.inl) k := by + have hrl : H.submatrix Sum.inr Sum.inl = (H.submatrix Sum.inl Sum.inr).transpose := by + ext x y + exact hsym x y + have hrr : H.submatrix Sum.inr Sum.inr = H.submatrix Sum.inl Sum.inl := by + ext x y + exact href x y + simp only [indexWeight, indexEnergy, indexCross_sum, hrl, hrr, indexCross_transpose] + rw [← Real.exp_add, ← Real.exp_add] + congr 1 + ring + +lemma expect_sum_function {I J M : Type*} [Fintype I] [Fintype J] [DecidableEq I] + [AddCommMonoid M] [Module ℚ≥0 M] (f : (I ⊕ I → J) → M) : + (𝔼 j : I ⊕ I → J, f j) = 𝔼 j : I → J, 𝔼 k : I → J, f (Sum.elim j k) := by + calc + _ = 𝔼 jk : (I → J) × (I → J), f (Sum.elim jk.1 jk.2) := by + apply Fintype.expect_equiv (Equiv.sumArrowEquivProdArrow I I J) + intro j + congr 1 + ext (i | i) <;> rfl + _ = _ := by rw [← univ_product_univ, expect_product] + +lemma reflected_index_weight_lower {I J : Type*} [Fintype I] [Fintype J] + [DecidableEq I] [DecidableEq J] (H : Matrix (I ⊕ I) (I ⊕ I) ℝ) + (hpos : ∀ x y, 0 ≤ H (Sum.inl x) (Sum.inl y)) + (hsym : ∀ x y, H (Sum.inr x) (Sum.inl y) = H (Sum.inl y) (Sum.inr x)) + (href : ∀ x y, H (Sum.inr x) (Sum.inr y) = H (Sum.inl x) (Sum.inl y)) + (κ : ℝ) (hκ : 0 ≤ κ) (hgap : (H.submatrix Sum.inl Sum.inr - κ • 1).PosSemidef) + (f : (I → J) → ℝ) : + ((Real.exp κ - 1) ^ Fintype.card I / (Fintype.card J : ℝ) ^ Fintype.card I) * + (𝔼 j : I → J, (f j) ^ 2) ≤ + 𝔼 j : I ⊕ I → J, indexWeight H j * f (j ∘ Sum.inl) * f (j ∘ Sum.inr) := by + rw [expect_sum_function] + simp only [indexWeight_factor H hsym href] + have hh := marked_index_average (H.submatrix Sum.inl Sum.inr) κ hκ hgap + (indexWeight (H.submatrix Sum.inl Sum.inl)) f (one_le_indexWeight _ hpos) + convert hh using 1 + apply expect_congr rfl + intro j _ + apply expect_congr rfl + intro k _ + simp only [Function.comp_def, Sum.elim_inl, Sum.elim_inr] + ring + +lemma card_positionPair (h : ℕ) : Fintype.card (PositionPair h) = h.choose 2 := by + simpa [Fintype.card_subtype] using (Fintype.card_product_filter_lt (α := Fin h)) + +lemma interaction_row_sum {B : Type*} [Fintype B] [DecidableEq B] {h : ℕ} + (S : Finset B) (δ : ℝ) (v : WordVertex B h) : + ∑ w : WordVertex B h, interaction S δ v w = + ∑ _b ∈ S, ∑ p : PositionPair h, δ ^ (p.1.2.val - p.1.1.val) := by + classical + unfold interaction + rw [sum_comm] + apply sum_congr rfl + intro b _ + rw [sum_comm] + simp + +lemma interaction_row_sum_le {B : Type*} [Fintype B] [DecidableEq B] {h : ℕ} + (S : Finset B) {δ : ℝ} (hδ : 0 ≤ δ) (hδ1 : δ ≤ 1) (v : WordVertex B h) : + ∑ w : WordVertex B h, interaction S δ v w ≤ (S.card : ℝ) * (h.choose 2 : ℝ) * δ := by + rw [interaction_row_sum] + calc + _ ≤ ∑ _b ∈ S, ∑ _p : PositionPair h, δ := by + apply sum_le_sum + intro b _ + apply sum_le_sum + intro p _ + have hg : 1 ≤ p.1.2.val - p.1.1.val := by have := p.2; omega + simpa using pow_le_pow_of_le_one hδ hδ1 hg + _ = _ := by simp [card_positionPair, mul_assoc] + +abbrev TupleVertex := WordVertex (Fin tupleBlocks) tupleH + +abbrev TupleAddress (S : Finset (Fin tupleBlocks)) := + {b : Fin tupleBlocks // b ∉ S} → Equiv.Perm (Fin tupleH) + +def tupleR : ℕ := Nat.factorial tupleH / 2 + +abbrev TupleListIndex (S : Finset (Fin tupleBlocks)) := Fin (tupleR ^ S.card) + +abbrev TupleListEntry (S : Finset (Fin tupleBlocks)) := TupleAddress S × TupleListIndex S + +def tupleProjection (S : Finset (Fin tupleBlocks)) (v : TupleVertex) : TupleAddress S := + fun b => v b.1 + +def tupleCycle : Equiv.Perm (Fin tupleH) := finRotate tupleH + +def cycleVertex (j : ℕ) : TupleVertex := fun _ => tupleCycle ^ j + +lemma tupleCycle_ne_one : tupleCycle ≠ 1 := by decide + +lemma tupleCycle_sq_ne_one : tupleCycle ^ 2 ≠ 1 := by decide + +lemma tupleCycle_pow : tupleCycle ^ tupleH = 1 := by + have ho : orderOf tupleCycle = tupleH := by + change orderOf (finRotate tupleH) = tupleH + rw [(isCycle_finRotate_of_le (show 2 ≤ tupleH by decide)).orderOf, + support_finRotate_of_le (show 2 ≤ tupleH by decide)] + simp + simpa only [ho] using pow_orderOf_eq_one tupleCycle + +lemma card_tupleVertex : Fintype.card TupleVertex = (Nat.factorial tupleH) ^ tupleBlocks := by + simp [TupleVertex, WordVertex, Fintype.card_perm] + +lemma tupleR_pos : 0 < tupleR := by norm_num [tupleR, tupleH] + +instance tupleListIndexNonempty (S : Finset (Fin tupleBlocks)) : Nonempty (TupleListIndex S) := + Fin.pos_iff_nonempty.mp (pow_pos tupleR_pos _) + +lemma card_cleanBlocks (S : Finset (Fin tupleBlocks)) : + Fintype.card {b : Fin tupleBlocks // b ∉ S} = tupleBlocks - S.card := by + classical + rw [Fintype.card_subtype] + have heq : (univ.filter fun b : Fin tupleBlocks => b ∉ S) = univ \ S := by ext; simp + rw [heq, card_sdiff_of_subset (subset_univ S)] + simp + +lemma card_tupleAddress (S : Finset (Fin tupleBlocks)) : + Fintype.card (TupleAddress S) = (Nat.factorial tupleH) ^ (tupleBlocks - S.card) := by + simp [TupleAddress, Fintype.card_perm] + +noncomputable def tupleListEdges (S : Finset (Fin tupleBlocks)) : + Finset (TupleListEntry S × TupleListEntry S) := by + classical + exact if S.card ≤ tupleT then + univ.filter fun e => addressEdge tupleCycle (tupleT + 1) e.1.1 e.2.1 else ∅ + +lemma tupleListEdges_no_loop (S : Finset (Fin tupleBlocks)) + (e : TupleListEntry S × TupleListEntry S) (he : e ∈ tupleListEdges S) : e.1 ≠ e.2 := by + classical + unfold tupleListEdges at he + split_ifs at he with hs + · intro heq + have hh := (mem_filter.mp he).2 + rw [heq] at hh + exact addressEdge_irrefl tupleCycle_ne_one (by norm_num [tupleT]) e.2.1 hh + · simp at he + +lemma tupleListEdges_no_opp (S : Finset (Fin tupleBlocks)) + (e : TupleListEntry S × TupleListEntry S) (he : e ∈ tupleListEdges S) : + (e.2, e.1) ∉ tupleListEdges S := by + classical + unfold tupleListEdges at he ⊢ + split_ifs at he ⊢ with hs + · intro hop + apply addressEdge_asymm tupleCycle_sq_ne_one _ (mem_filter.mp he).2 (mem_filter.mp hop).2 + rw [card_cleanBlocks] + simp only [tupleBlocks, tupleT] + omega + · simp at he + +lemma cycle_addressEdge (S : Finset (Fin tupleBlocks)) (hs : S.card ≤ tupleT) (j : ℕ) : + addressEdge tupleCycle (tupleT + 1) + (tupleProjection S (cycleVertex j)) (tupleProjection S (cycleVertex (j + 1))) := by + have hh : tupleT + 1 ≤ Fintype.card {b : Fin tupleBlocks // b ∉ S} := by + rw [card_cleanBlocks] + change tupleT + 1 ≤ (2 * tupleT + 1) - S.card + omega + convert addressEdge_full_shift tupleCycle (tupleT + 1) hh + (tupleProjection S (cycleVertex j)) using 1 + funext b + exact pow_succ tupleCycle j + +lemma cycle_listEdge (S : Finset (Fin tupleBlocks)) (hs : S.card ≤ tupleT) + (j : ℕ) (i k : TupleListIndex S) : + ((tupleProjection S (cycleVertex j), i), (tupleProjection S (cycleVertex (j + 1)), k)) ∈ + tupleListEdges S := by + classical + simp only [tupleListEdges, ite_eq_left hs, mem_filter, mem_univ, true_and] + exact cycle_addressEdge S hs j + +lemma expect_precompose {I K J M : Type*} [Fintype I] [Fintype K] [Fintype J] + [DecidableEq I] [DecidableEq K] [AddCommMonoid M] [Module ℚ≥0 M] + (e : I ≃ K) (f : (I → J) → M) : + (𝔼 j : I → J, f j) = 𝔼 j : K → J, f (j ∘ e) := by + apply Fintype.expect_equiv (Equiv.arrowCongr e (Equiv.refl J)) + intro j + congr 1 + funext i + simp + +lemma indexWeight_equiv {I K J : Type*} [Fintype I] [Fintype K] [DecidableEq J] + (e : I ≃ K) (H : Matrix K K ℝ) (j : K → J) : + indexWeight (H.submatrix e e) (j ∘ e) = indexWeight H j := by + simp only [indexWeight, indexEnergy, indexCross_equiv] + +lemma marked_interaction_weight_lower {B : Type*} [Fintype B] [DecidableEq B] + {J : Type*} [Fintype J] [DecidableEq J] + (S : Finset B) (b : B) (hb : b ∈ S) {α β : Fin tupleH} (hαβ : α ≠ β) + (f : (CutHalf b α β → J) → ℝ) : + ((Real.exp tupleKappa - 1) ^ Fintype.card (CutHalf b α β) / + (Fintype.card J : ℝ) ^ Fintype.card (CutHalf b α β)) * + (𝔼 j : CutHalf b α β → J, (f j) ^ 2) ≤ + 𝔼 j : WordVertex B tupleH → J, indexWeight (interaction S tupleDelta) j * + f (fun x => j x.1) * f (fun x => j (reflect b α β x.1)) := by + classical + let e := halfSumEquiv b hαβ + let H : Matrix (CutHalf b α β ⊕ CutHalf b α β) (CutHalf b α β ⊕ CutHalf b α β) ℝ := + Matrix.submatrix (interaction S tupleDelta) e e + have hp : ∀ x y, 0 ≤ H (Sum.inl x) (Sum.inl y) := + fun x y => interaction_nonneg S tupleDelta_pos.le x.1 y.1 + have hs : ∀ x y, H (Sum.inr x) (Sum.inl y) = H (Sum.inl y) (Sum.inr x) := + fun x y => interaction_symm S tupleDelta _ _ + have hr : ∀ x y, H (Sum.inr x) (Sum.inr y) = H (Sum.inl x) (Sum.inl y) := + fun x y => interaction_reflect S tupleDelta b α β x.1 y.1 + have hg : (H.submatrix Sum.inl Sum.inr - tupleKappa • 1).PosSemidef := + crossInteraction_gap S b hb α β + have hh := reflected_index_weight_lower H hp hs hr tupleKappa tupleKappa_pos.le hg f + rw [expect_precompose e] at hh + have hw (j : WordVertex B tupleH → J) : + indexWeight H (j ∘ e) = indexWeight (interaction S tupleDelta) j := + indexWeight_equiv e _ j + refine hh.trans_eq ?_ + apply expect_congr rfl + intro j _ + rw [hw] + rfl + +noncomputable def tupleWeight (S : Finset (Fin tupleBlocks)) + (j : TupleVertex → TupleListIndex S) : ℝ := indexWeight (interaction S tupleDelta) j + +noncomputable def tupleValidity {p : ℕ} [Fact p.Prime] (S : Finset (Fin tupleBlocks)) + (Y : TupleListEntry S → ZMod p) : ℝ := + ∏ e ∈ tupleListEdges S, squareIndicator (Y e.2 - Y e.1) + +def tupleOutput {p : ℕ} (S : Finset (Fin tupleBlocks)) + (Y : TupleListEntry S → ZMod p) (j : TupleVertex → TupleListIndex S) : + TupleVertex → ZMod p := fun v => Y (tupleProjection S v, j v) + +noncomputable def tupleComponent {p : ℕ} [Fact p.Prime] (S : Finset (Fin tupleBlocks)) + (G : (TupleVertex → ZMod p) → ℝ) : ℝ := + 𝔼 Y : TupleListEntry S → ZMod p, 𝔼 j : TupleVertex → TupleListIndex S, + tupleValidity S Y * tupleWeight S j * G (tupleOutput S Y j) + +noncomputable def tupleCutForm {p : ℕ} [Fact p.Prime] (S : Finset (Fin tupleBlocks)) + (b : Fin tupleBlocks) (α β : Fin tupleH) (F : (CutHalf b α β → ZMod p) → ℝ) : ℝ := + tupleComponent S (fun z => F (fun x => z x.1) * F (fun x => z (reflect b α β x.1))) + +lemma tupleValidity_nonneg {p : ℕ} [Fact p.Prime] (S : Finset (Fin tupleBlocks)) + (Y : TupleListEntry S → ZMod p) : 0 ≤ tupleValidity S Y := by + unfold tupleValidity + exact prod_nonneg fun e _ => squareIndicator_nonneg _ + +lemma tupleValidity_le_one {p : ℕ} [Fact p.Prime] (S : Finset (Fin tupleBlocks)) + (Y : TupleListEntry S → ZMod p) : tupleValidity S Y ≤ 1 := by + unfold tupleValidity + exact prod_le_one₀ (fun e _ => squareIndicator_nonneg _) (fun e _ => squareIndicator_le_one _) + +lemma tupleProjection_reflect (S : Finset (Fin tupleBlocks)) (b : Fin tupleBlocks) + (hb : b ∈ S) (α β : Fin tupleH) (v : TupleVertex) : + tupleProjection S (reflect b α β v) = tupleProjection S v := by + funext a + have hab : a.1 ≠ b := by intro h; exact a.2 (h ▸ hb) + simp [tupleProjection, reflect, hab] + +lemma tuple_marked_lower {p : ℕ} [Fact p.Prime] (S : Finset (Fin tupleBlocks)) + (b : Fin tupleBlocks) (hb : b ∈ S) {α β : Fin tupleH} (hαβ : α ≠ β) + (F : (CutHalf b α β → ZMod p) → ℝ) : + ((Real.exp tupleKappa - 1) ^ Fintype.card (CutHalf b α β) / + (Fintype.card (TupleListIndex S) : ℝ) ^ Fintype.card (CutHalf b α β)) * + (𝔼 Y : TupleListEntry S → ZMod p, 𝔼 j : CutHalf b α β → TupleListIndex S, + tupleValidity S Y * (F (fun x => Y (tupleProjection S x.1, j x))) ^ 2) ≤ + tupleCutForm S b α β F := by + classical + unfold tupleCutForm tupleComponent + rw [mul_expect] + apply expect_le_expect + intro Y _ + have hh := mul_le_mul_of_nonneg_left + (marked_interaction_weight_lower S b hb hαβ + (fun j : CutHalf b α β → TupleListIndex S => + F (fun x => Y (tupleProjection S x.1, j x)))) (tupleValidity_nonneg S Y) + simp only [mul_expect] at hh ⊢ + convert hh using 1 + · apply expect_congr rfl + intro j _ + ring + · apply expect_congr rfl + intro j _ + simp only [tupleWeight, tupleOutput, tupleProjection_reflect S b hb α β] + ring + +lemma indexEnergy_le_of_row {I J : Type*} [Fintype I] [DecidableEq J] + (H : Matrix I I ℝ) (hH : ∀ x y, 0 ≤ H x y) (C : ℝ) + (hC : ∀ x, ∑ y, H x y ≤ C) (j : I → J) : + indexEnergy H j ≤ (Fintype.card I : ℝ) * C / 2 := by + unfold indexEnergy indexCross + calc + _ ≤ (1 / 2 : ℝ) * ∑ x, ∑ y, H x y := by + apply mul_le_mul_of_nonneg_left _ (by norm_num) + apply sum_le_sum + intro x _ + apply sum_le_sum + intro y _ + split_ifs <;> simp_all + _ ≤ (1 / 2 : ℝ) * ∑ _x : I, C := + mul_le_mul_of_nonneg_left (sum_le_sum fun x _ => hC x) (by norm_num) + _ = _ := by simp; ring + +noncomputable def tupleWeightBound : ℝ := + Real.exp ((Fintype.card TupleVertex : ℝ) * (tupleT + 1) * + (tupleH.choose 2 : ℝ) * tupleDelta / 2) + +lemma tupleWeightBound_pos : 0 < tupleWeightBound := Real.exp_pos _ + +lemma tupleWeight_one_le (S : Finset (Fin tupleBlocks)) + (j : TupleVertex → TupleListIndex S) : 1 ≤ tupleWeight S j := + one_le_indexWeight _ (interaction_nonneg S tupleDelta_pos.le) j + +lemma tupleWeight_le (S : Finset (Fin tupleBlocks)) (hS : S.card ≤ tupleT + 1) + (j : TupleVertex → TupleListIndex S) : tupleWeight S j ≤ tupleWeightBound := by + unfold tupleWeight tupleWeightBound indexWeight + apply Real.exp_le_exp.mpr + refine (indexEnergy_le_of_row (interaction S tupleDelta) (interaction_nonneg S tupleDelta_pos.le) + ((S.card : ℝ) * (tupleH.choose 2 : ℝ) * tupleDelta) + (interaction_row_sum_le S tupleDelta_pos.le tupleDelta_le_one) j).trans ?_ + have hSc : (S.card : ℝ) ≤ (tupleT : ℝ) + 1 := by exact_mod_cast hS + have hδ := tupleDelta_pos.le + calc + _ ≤ (Fintype.card TupleVertex : ℝ) * + (((tupleT : ℝ) + 1) * (tupleH.choose 2 : ℝ) * tupleDelta) / 2 := by gcongr + _ = _ := by ring + +lemma tupleComponent_nonneg {p : ℕ} [Fact p.Prime] (S : Finset (Fin tupleBlocks)) + (G : (TupleVertex → ZMod p) → ℝ) (hG : ∀ z, 0 ≤ G z) : + 0 ≤ tupleComponent S G := by + apply expect_nonneg + intro Y _ + apply expect_nonneg + intro j _ + exact mul_nonneg (mul_nonneg (tupleValidity_nonneg S Y) + (le_trans (by norm_num) (tupleWeight_one_le S j))) (hG _) + +lemma tupleComponent_mass_le {p : ℕ} [Fact p.Prime] (S : Finset (Fin tupleBlocks)) + (hS : S.card ≤ tupleT + 1) : tupleComponent (p := p) S (fun _ => 1) ≤ tupleWeightBound := by + unfold tupleComponent + calc + _ ≤ 𝔼 _Y : TupleListEntry S → ZMod p, + 𝔼 _j : TupleVertex → TupleListIndex S, tupleWeightBound := by + apply expect_le_expect + intro Y _ + apply expect_le_expect + intro j _ + rw [mul_one] + calc + tupleValidity S Y * tupleWeight S j ≤ 1 * tupleWeight S j := + mul_le_mul_of_nonneg_right (tupleValidity_le_one S Y) + (le_trans (by norm_num) (tupleWeight_one_le S j)) + _ ≤ tupleWeightBound := by simpa using tupleWeight_le S hS j + _ = _ := by simp + +lemma squareIndicator_ne_zero_iff {F : Type*} [Field F] (x : F) : + squareIndicator x ≠ 0 ↔ x ≠ 0 ∧ IsSquare x := by + classical + simp only [squareIndicator] + split_ifs with h <;> simp_all + +lemma tupleValidity_edge {p : ℕ} [Fact p.Prime] (S : Finset (Fin tupleBlocks)) + (Y : TupleListEntry S → ZMod p) (hY : tupleValidity S Y ≠ 0) + (e : TupleListEntry S × TupleListEntry S) (he : e ∈ tupleListEdges S) : + Y e.2 - Y e.1 ≠ 0 ∧ IsSquare (Y e.2 - Y e.1) := by + exact (squareIndicator_ne_zero_iff _).mp (prod_ne_zero_iff.mp hY e he) + +lemma tuple_cycle_support {p : ℕ} [Fact p.Prime] (S : Finset (Fin tupleBlocks)) + (hS : S.card ≤ tupleT) (Y : TupleListEntry S → ZMod p) + (hY : tupleValidity S Y ≠ 0) (j : TupleVertex → TupleListIndex S) (k : ℕ) : + tupleOutput S Y j (cycleVertex (k + 1)) - tupleOutput S Y j (cycleVertex k) ≠ 0 ∧ + IsSquare (tupleOutput S Y j (cycleVertex (k + 1)) - tupleOutput S Y j (cycleVertex k)) := by + exact tupleValidity_edge S Y hY _ + (cycle_listEdge S hS k (j (cycleVertex k)) (j (cycleVertex (k + 1)))) + +lemma cycleVertex_period (j : ℕ) : cycleVertex (j + tupleH) = cycleVertex j := by + funext b + simp [cycleVertex, pow_add, tupleCycle_pow] + +lemma tupleWeight_empty (j : TupleVertex → TupleListIndex ∅) : tupleWeight ∅ j = 1 := by + simp [tupleWeight, indexWeight, indexEnergy, indexCross, interaction] + +lemma tuple_leading_mass {p : ℕ} [Fact p.Prime] (hp : p ≠ 2) : + |tupleComponent (p := p) ∅ (fun _ => 1) - + (1 / 2 : ℝ) ^ (tupleListEdges ∅).card| ≤ + ((tupleListEdges ∅).card : ℝ) * ((Real.sqrt p + 1) / (2 * p)) := by + have heq : tupleComponent (p := p) ∅ (fun _ => 1) = + 𝔼 Y : TupleListEntry ∅ → ZMod p, tupleValidity ∅ Y := by + simp [tupleComponent, tupleWeight_empty] + rw [heq] + exact graph_count hp (tupleListEdges ∅) (tupleListEdges_no_loop ∅) (tupleListEdges_no_opp ∅) + +noncomputable def reflectEquiv {B : Type*} [DecidableEq B] {h : ℕ} + (b : B) (α β : Fin h) : Equiv.Perm (WordVertex B h) := + Function.Involutive.toPerm (reflect b α β) (reflect_involutive b α β) + +lemma interaction_zero_of_unmarked_word {B : Type*} [Fintype B] [DecidableEq B] {h : ℕ} + (S : Finset B) (δ : ℝ) (b : B) (hb : b ∉ S) (v w : WordVertex B h) + (hvw : v b ≠ w b) : interaction S δ v w = 0 := by + classical + apply interaction_eq_zero_of_not_neighbour + intro c hc p heq + apply hvw + have hcb : b ≠ c := by intro h; exact hb (h ▸ hc) + have hh := congrArg (fun v : WordVertex B h => v b) heq + simpa [vertexSwap, hcb] using hh.symm + +lemma unmarked_crossInteraction_zero {B : Type*} [Fintype B] [DecidableEq B] {h : ℕ} + (S : Finset B) (δ : ℝ) (b : B) (hb : b ∉ S) {α β : Fin h} (hne : α ≠ β) : + crossInteraction S δ b α β = 0 := by + classical + ext x y + apply interaction_zero_of_unmarked_word S δ b hb + intro heq + have hn : ¬ cutPlus b α β (reflect b α β y.1) := + by + rw [cutPlus_reflect_iff_not b hne] + exact not_not.mpr y.2 + apply hn + change (reflect b α β y.1 b).symm α < (reflect b α β y.1 b).symm β + rw [← heq] + exact x.2 + +lemma unmarked_weight_factor {B : Type*} [Fintype B] [DecidableEq B] {h : ℕ} + {J : Type*} [DecidableEq J] (S : Finset B) (δ : ℝ) (b : B) (hb : b ∉ S) + {α β : Fin h} (hne : α ≠ β) (j k : CutHalf b α β → J) : + indexWeight (Matrix.submatrix (interaction S δ) (halfSumEquiv b hne) (halfSumEquiv b hne)) + (Sum.elim j k) = + indexWeight (Matrix.submatrix (interaction S δ) Subtype.val Subtype.val) j * + indexWeight (Matrix.submatrix (interaction S δ) Subtype.val Subtype.val) k := by + classical + rw [indexWeight_factor] + · have hz := unmarked_crossInteraction_zero S δ b hb hne + change indexWeight _ j * Real.exp (indexCross (crossInteraction S δ b α β) j k) * + indexWeight _ k = _ + rw [hz] + simp only [indexCross, Matrix.zero_apply, zero_mul, sum_const_zero, Real.exp_zero, + mul_one] + rfl + · intro x y + exact interaction_symm S δ _ _ + · intro x y + exact interaction_reflect S δ b α β x.1 y.1 + +end SquareDifference +end + +end OAI diff --git a/lean/OAI/Combinatorics/SquareDifference/TupleReflection.lean b/lean/OAI/Combinatorics/SquareDifference/TupleReflection.lean new file mode 100644 index 0000000000000000000000000000000000000000..0c3edf6381eecb8e202cdb7a0abf10a405638f22 --- /dev/null +++ b/lean/OAI/Combinatorics/SquareDifference/TupleReflection.lean @@ -0,0 +1,513 @@ +import OAI.Combinatorics.SquareDifference.TupleEnergy + +namespace OAI + +section +open Finset +open scoped BigOperators +namespace SquareDifference + +noncomputable def tupleAddressReflect (S : Finset (Fin tupleBlocks)) + (b : Fin tupleBlocks) (α β : Fin tupleH) : Equiv.Perm (TupleAddress S) := + Function.Involutive.toPerm + (fun u a => (if a.1 = b then Equiv.swap α β else 1) * u a) + (by + intro u + funext a + by_cases ha : a.1 = b <;> simp [ha, ← mul_assoc]) + +lemma tupleProjection_reflect_all (S : Finset (Fin tupleBlocks)) + (b : Fin tupleBlocks) (α β : Fin tupleH) (v : TupleVertex) : + tupleProjection S (reflect b α β v) = tupleAddressReflect S b α β (tupleProjection S v) := by + funext a + by_cases ha : a.1 = b <;> simp [tupleProjection, reflect, tupleAddressReflect, ha] + +noncomputable def tupleEntryReflect (S : Finset (Fin tupleBlocks)) + (b : Fin tupleBlocks) (α β : Fin tupleH) : Equiv.Perm (TupleListEntry S) := + Equiv.prodCongr (tupleAddressReflect S b α β) (Equiv.refl _) + +lemma tupleListEdges_reflect (S : Finset (Fin tupleBlocks)) + (b : Fin tupleBlocks) (α β : Fin tupleH) (e : TupleListEntry S × TupleListEntry S) : + (tupleEntryReflect S b α β e.1, tupleEntryReflect S b α β e.2) ∈ tupleListEdges S ↔ + e ∈ tupleListEdges S := by + classical + unfold tupleListEdges + split_ifs with hs + · simp only [mem_filter, mem_univ, true_and] + exact addressEdge_left_translate tupleCycle (tupleT + 1) + (fun a : {a : Fin tupleBlocks // a ∉ S} => if a.1 = b then Equiv.swap α β else 1) + e.1.1 e.2.1 + · simp + +lemma tupleValidity_reflect {p : ℕ} [Fact p.Prime] (S : Finset (Fin tupleBlocks)) + (b : Fin tupleBlocks) (α β : Fin tupleH) (Y : TupleListEntry S → ZMod p) : + tupleValidity S (Y ∘ tupleEntryReflect S b α β) = tupleValidity S Y := by + classical + apply prod_equiv (Equiv.prodCongr (tupleEntryReflect S b α β) (tupleEntryReflect S b α β)) + · intro e + exact (tupleListEdges_reflect S b α β e).symm + · intro e _ + rfl + +lemma tupleWeight_reflect (S : Finset (Fin tupleBlocks)) (b : Fin tupleBlocks) + (α β : Fin tupleH) (j : TupleVertex → TupleListIndex S) : + tupleWeight S (j ∘ reflect b α β) = tupleWeight S j := by + classical + have heq : Matrix.submatrix (interaction (h := tupleH) S tupleDelta) + (reflectEquiv b α β) (reflectEquiv b α β) = interaction S tupleDelta := by + ext x y + change interaction S tupleDelta (reflect b α β x) (reflect b α β y) = _ + exact interaction_reflect S tupleDelta b α β x y + have hh := indexWeight_equiv (reflectEquiv b α β) (interaction S tupleDelta) j + have hleft : indexWeight (Matrix.submatrix (interaction S tupleDelta) + (reflectEquiv b α β) (reflectEquiv b α β)) (j ∘ reflect b α β) = + indexWeight (interaction S tupleDelta) (j ∘ reflect b α β) := congrArg (fun H => indexWeight H (j ∘ reflect b α β)) heq + exact hleft.symm.trans hh + +lemma tupleOutput_reflect {p : ℕ} (S : Finset (Fin tupleBlocks)) (b : Fin tupleBlocks) + (α β : Fin tupleH) (Y : TupleListEntry S → ZMod p) (j : TupleVertex → TupleListIndex S) : + tupleOutput S (Y ∘ tupleEntryReflect S b α β) (j ∘ reflect b α β) = + tupleOutput S Y j ∘ reflect b α β := by + funext v + simp only [tupleOutput, Function.comp_def, tupleProjection_reflect_all, + tupleEntryReflect, Equiv.prodCongr_apply, Prod.map, Equiv.refl_apply] + +lemma tupleComponent_reflect {p : ℕ} [Fact p.Prime] (S : Finset (Fin tupleBlocks)) + (b : Fin tupleBlocks) (α β : Fin tupleH) (G : (TupleVertex → ZMod p) → ℝ) : + tupleComponent S (fun z => G (z ∘ reflect b α β)) = tupleComponent S G := by + classical + symm + unfold tupleComponent + rw [expect_precompose (tupleEntryReflect S b α β) + (fun Y => 𝔼 j : TupleVertex → TupleListIndex S, + tupleValidity S Y * tupleWeight S j * G (tupleOutput S Y j))] + apply expect_congr rfl + intro Y _ + rw [expect_precompose (reflectEquiv b α β) + (fun j => tupleValidity S (Y ∘ tupleEntryReflect S b α β) * + tupleWeight S j * G (tupleOutput S (Y ∘ tupleEntryReflect S b α β) j))] + apply expect_congr rfl + intro j _ + change tupleValidity S (Y ∘ tupleEntryReflect S b α β) * + tupleWeight S (j ∘ reflect b α β) * + G (tupleOutput S (Y ∘ tupleEntryReflect S b α β) (j ∘ reflect b α β)) = _ + rw [tupleValidity_reflect, tupleWeight_reflect, tupleOutput_reflect] + +lemma tupleCutForm_symmetric {p : ℕ} [Fact p.Prime] (S : Finset (Fin tupleBlocks)) + (b : Fin tupleBlocks) (α β : Fin tupleH) + (F G : (CutHalf b α β → ZMod p) → ℝ) : + tupleComponent S (fun z => F (fun x => z x.1) * G (fun x => z (reflect b α β x.1))) = + tupleComponent S (fun z => G (fun x => z x.1) * F (fun x => z (reflect b α β x.1))) := by + rw [← tupleComponent_reflect (p := p) S b α β + (fun z => G (fun x => z x.1) * F (fun x => z (reflect b α β x.1)))] + apply congrArg (fun H : (TupleVertex → ZMod p) → ℝ => tupleComponent S H) + funext z + change F (fun x => z x.1) * G (fun x => z (reflect b α β x.1)) = + G (fun x => z (reflect b α β x.1)) * + F (fun x => z (reflect b α β (reflect b α β x.1))) + have hz : (fun x : CutHalf b α β => z (reflect b α β (reflect b α β x.1))) = + fun x : CutHalf b α β => z x.1 := funext fun x => congrArg z (reflect_involutive b α β x.1) + rw [hz, mul_comm] + +def symbolPotential {h : ℕ} (w : Equiv.Perm (Fin h)) : ℤ := + ∑ i : Fin h, (i.val : ℤ) * ((w.symm i).val : ℤ) + +lemma symbolPotential_swap {h : ℕ} (w : Equiv.Perm (Fin h)) + {α β : Fin h} (hne : α ≠ β) : + symbolPotential (Equiv.swap α β * w) - symbolPotential w = + ((β.val : ℤ) - α.val) * (((w.symm α).val : ℤ) - (w.symm β).val) := by + unfold symbolPotential + rw [← sum_sub_distrib] + calc + _ = ∑ i : Fin h, ( + (if i = α then (α.val : ℤ) * ((w.symm β).val : ℤ) - (α.val : ℤ) * (w.symm α).val else 0) + + (if i = β then (β.val : ℤ) * ((w.symm α).val : ℤ) - (β.val : ℤ) * (w.symm β).val else 0)) := by + apply sum_congr rfl + intro i _ + by_cases hi : i = α + · subst i + simp [Equiv.Perm.mul_def, hne] + · by_cases hj : i = β + · subst i + simp [Equiv.Perm.mul_def, hne.symm] + · simp [Equiv.Perm.mul_def, Equiv.swap_apply_of_ne_of_ne hi hj, hi, hj] + _ = _ := by + simp only [sum_add_distrib, sum_ite_eq', mem_univ, ite_true] + ring + +def wordPotential {B : Type*} [Fintype B] {h : ℕ} (v : WordVertex B h) : ℤ := + ∑ b : B, symbolPotential (v b) + +lemma wordPotential_reflect {B : Type*} [Fintype B] [DecidableEq B] {h : ℕ} + (b : B) {α β : Fin h} (hne : α ≠ β) (v : WordVertex B h) : + wordPotential (reflect b α β v) - wordPotential v = + ((β.val : ℤ) - α.val) * (((v b).symm α).val - ((v b).symm β).val) := by + unfold wordPotential + rw [← sum_sub_distrib, sum_eq_single b] + · simpa [reflect] using symbolPotential_swap (v b) hne + · intro c _ hcb + simp [reflect, hcb] + · simp + +def foldWord {B : Type*} [DecidableEq B] {h : ℕ} (b : B) (α β : Fin h) + (v : WordVertex B h) : WordVertex B h := + if cutPlus b α β v then v else reflect b α β v + +lemma foldWord_potential_le {B : Type*} [Fintype B] [DecidableEq B] {h : ℕ} + (b : B) {α β : Fin h} (hab : α < β) (v : WordVertex B h) : + wordPotential v ≤ wordPotential (foldWord b α β v) := by + unfold foldWord + split_ifs with hv + · exact le_rfl + · have hgap := wordPotential_reflect b hab.ne v + have h₁ : 0 ≤ (β.val : ℤ) - α.val := sub_nonneg.mpr (by exact_mod_cast hab.le) + have h₂ : 0 ≤ (((v b).symm α).val : ℤ) - ((v b).symm β).val := by + have hh : (v b).symm β ≤ (v b).symm α := le_of_not_gt hv + exact sub_nonneg.mpr (by exact_mod_cast hh) + have := mul_nonneg h₁ h₂ + omega + +lemma foldWord_potential_lt {B : Type*} [Fintype B] [DecidableEq B] {h : ℕ} + (b : B) {α β : Fin h} (hab : α < β) (v : WordVertex B h) + (hv : ¬ cutPlus b α β v) : + wordPotential v < wordPotential (foldWord b α β v) := by + rw [foldWord, ite_eq_right hv] + have hgap := wordPotential_reflect b hab.ne v + have h₁ : 0 < (β.val : ℤ) - α.val := sub_pos.mpr (by exact_mod_cast hab) + have h₂ : 0 < (((v b).symm α).val : ℤ) - ((v b).symm β).val := by + have hh : (v b).symm β < (v b).symm α := + lt_of_le_of_ne (le_of_not_gt hv) (by intro hh; exact hab.ne ((v b).symm.injective hh.symm)) + exact sub_pos.mpr (by exact_mod_cast hh) + have := mul_pos h₁ h₂ + omega + +lemma exists_unsorted_cut {B : Type*} [DecidableEq B] {h : ℕ} + (v : WordVertex B h) (hv : v ≠ fun _ => 1) : + ∃ b : B, ∃ α β : Fin h, α < β ∧ ¬ cutPlus b α β v := by + by_contra! hn + apply hv + funext b + have hm : Monotone ((v b).symm) := by + intro α β hab + rcases hab.eq_or_lt with rfl | hab + · exact le_rfl + · exact (hn b α β hab).le + have heq : (v b).symm = 1 := (Equiv.Perm.monotone_iff _).mp hm + exact inv_eq_one.mp heq + +abbrev WordCut (B : Type*) (h : ℕ) := B × PositionPair h + +def foldMap {B : Type*} [DecidableEq B] {h : ℕ} (cs : List (WordCut B h)) : + WordVertex B h → WordVertex B h := + cs.foldr (fun c f => foldWord c.1 c.2.1.1 c.2.1.2 ∘ f) id + +lemma exists_constant_fold {B : Type*} [Fintype B] [DecidableEq B] {h : ℕ} : + ∃ cs : List (WordCut B h), ∀ v : WordVertex B h, foldMap cs v = fun _ => 1 := by + classical + let R : Finset (WordVertex B h → WordVertex B h) := + univ.filter fun f => ∃ cs : List (WordCut B h), foldMap cs = f + have hR : R.Nonempty := ⟨id, mem_filter.mpr ⟨mem_univ _, ⟨[], rfl⟩⟩⟩ + obtain ⟨f, hf, hmax⟩ := R.exists_max_image (fun f => ∑ v, wordPotential (f v)) hR + obtain ⟨cs, rfl⟩ := (mem_filter.mp hf).2 + refine ⟨cs, fun v => ?_⟩ + by_contra hv + obtain ⟨b, α, β, hab, hv⟩ := exists_unsorted_cut (foldMap cs v) hv + let c : WordCut B h := (b, ⟨(α, β), hab⟩) + have hmem : foldMap (c :: cs) ∈ R := + mem_filter.mpr ⟨mem_univ _, ⟨c :: cs, rfl⟩⟩ + have hlt : (∑ w : WordVertex B h, wordPotential (foldMap cs w)) < + ∑ w : WordVertex B h, wordPotential (foldMap (c :: cs) w) := by + apply sum_lt_sum + · intro w _ + exact foldWord_potential_le b hab (foldMap cs w) + · exact ⟨v, mem_univ _, foldWord_potential_lt b hab (foldMap cs v) hv⟩ + exact (not_lt_of_ge (hmax _ hmem)) hlt + +lemma max_fold_preserved {V A : Type*} [Fintype V] [Fintype A] + (Λ : (V → A) → ℝ) {M : ℝ} (_hM : 0 ≤ M) + (hbound : ∀ a, |Λ a| ≤ M) (φ ψ : V → V) + (hfold : ∀ a, |Λ a| ^ 2 ≤ Λ (a ∘ φ) * Λ (a ∘ ψ)) + (hpos : ∀ a, 0 ≤ Λ (a ∘ φ) ∧ 0 ≤ Λ (a ∘ ψ)) + (a : V → A) (ha : |Λ a| = M) : |Λ (a ∘ φ)| = M := by + have hx := (hpos a).1 + have hy := (hpos a).2 + have hxy := hfold a + have hxb := hbound (a ∘ φ) + have hyb := hbound (a ∘ ψ) + rw [ha] at hxy + rw [abs_of_nonneg hx] at hxb ⊢ + rw [abs_of_nonneg hy] at hyb + nlinarith [mul_le_mul_of_nonneg_left hyb hx, + mul_le_mul_of_nonneg_left hxb hx, sq_nonneg (M - Λ (a ∘ φ))] + +lemma word_folding_maximum {B A : Type*} [Fintype B] [DecidableEq B] + [Fintype A] [Nonempty A] {h : ℕ} + (Λ : (WordVertex B h → A) → ℝ) + (hfold : ∀ b α β, α ≠ β → ∀ a, + |Λ a| ^ 2 ≤ Λ (a ∘ foldWord b α β) * Λ (a ∘ foldWord b β α)) + (hpos : ∀ b α β, α ≠ β → ∀ a, 0 ≤ Λ (a ∘ foldWord b α β)) : + ∃ i : A, ∀ a : WordVertex B h → A, |Λ a| ≤ |Λ (fun _ => i)| := by + classical + obtain ⟨a, _, hmax⟩ := univ.exists_max_image (fun a : WordVertex B h → A => |Λ a|) + univ_nonempty + have hbnd : ∀ a', |Λ a'| ≤ |Λ a| := fun a' => hmax a' (mem_univ _) + have hpres (b : B) (α β : Fin h) (hne : α ≠ β) (a' : WordVertex B h → A) + (ha' : |Λ a'| = |Λ a|) : |Λ (a' ∘ foldWord b α β)| = |Λ a| := + max_fold_preserved Λ (abs_nonneg _) hbnd _ _ (hfold b α β hne) + (fun a' => ⟨hpos b α β hne a', hpos b β α hne.symm a'⟩) a' ha' + have hseq (cs : List (WordCut B h)) (a' : WordVertex B h → A) + (ha' : |Λ a'| = |Λ a|) : |Λ (a' ∘ foldMap cs)| = |Λ a| := by + induction cs generalizing a' with + | nil => exact ha' + | cons c cs ih => + exact ih (a' ∘ foldWord c.1 c.2.1.1 c.2.1.2) + (hpres c.1 c.2.1.1 c.2.1.2 c.2.2.ne a' ha') + obtain ⟨cs, hcs⟩ := exists_constant_fold (B := B) (h := h) + have heq : a ∘ foldMap cs = fun _ => a (fun _ => 1) := funext fun v => congrArg a (hcs v) + refine ⟨a (fun _ => 1), fun a' => ?_⟩ + have hs := hseq cs a rfl + rw [heq] at hs + exact (hbnd a').trans_eq hs.symm + +noncomputable def graphValidity {I : Type*} {p : ℕ} [Fact p.Prime] + (E : Finset (I × I)) (z : I → ZMod p) : ℝ := + ∏ e ∈ E, squareIndicator (z e.2 - z e.1) + +lemma graphValidity_all {I : Type*} [Fintype I] [DecidableEq I] + {p : ℕ} [Fact p.Prime] (E : Finset (I × I)) (z : I → ZMod p) : + graphValidity E z = ∏ i, ∏ j, if (i,j) ∈ E then squareIndicator (z j - z i) else 1 := by + classical + rw [graphValidity, ← Fintype.prod_ite_mem] + rw [← univ_product_univ, prod_product] + +noncomputable def cutInternalEdges {I : Type*} [Fintype I] + (E : Finset ((I ⊕ I) × (I ⊕ I))) : Finset (I × I) := by + classical + exact univ.filter fun e => (Sum.inl e.1, Sum.inl e.2) ∈ E + +noncomputable def cutCrossEdges {I : Type*} [Fintype I] + (E : Finset ((I ⊕ I) × (I ⊕ I))) : Finset (I × I) := by + classical + exact univ.filter fun e => (Sum.inl e.1, Sum.inr e.2) ∈ E ∨ + (Sum.inr e.2, Sum.inl e.1) ∈ E + +noncomputable def cutCrossDirection {I : Type*} + (E : Finset ((I ⊕ I) × (I ⊕ I))) (i j : I) : Bool := by + classical + exact decide ((Sum.inl i, Sum.inr j) ∈ E) + +lemma cutCrossEdges_factor {I : Type*} [Fintype I] [DecidableEq I] + {p : ℕ} [Fact p.Prime] (E : Finset ((I ⊕ I) × (I ⊕ I))) + (hnoopp : ∀ e ∈ E, (e.2,e.1) ∉ E) (x y : I → ZMod p) : + listKernel (cutCrossEdges E) (cutCrossDirection E) x y = + (∏ i, ∏ j, if (Sum.inl i, Sum.inr j) ∈ E then squareIndicator (y j - x i) else 1) * + (∏ j, ∏ i, if (Sum.inr j, Sum.inl i) ∈ E then squareIndicator (x i - y j) else 1) := by + classical + rw [listKernel, ← Fintype.prod_ite_mem, ← univ_product_univ, prod_product] + rw [prod_comm (f := fun j i => if (Sum.inr j, Sum.inl i) ∈ E then + squareIndicator (x i - y j) else 1)] + rw [← prod_mul_distrib] + apply prod_congr rfl + intro i _ + rw [← prod_mul_distrib] + apply prod_congr rfl + intro j _ + by_cases hpm : (Sum.inl i, Sum.inr j) ∈ E + · have hmp := hnoopp _ hpm + simp [cutCrossEdges, cutCrossDirection, hpm, hmp] + · by_cases hmp : (Sum.inr j, Sum.inl i) ∈ E <;> + simp [cutCrossEdges, cutCrossDirection, hpm, hmp] + +lemma graphValidity_cut {I : Type*} [Fintype I] [DecidableEq I] + {p : ℕ} [Fact p.Prime] (E : Finset ((I ⊕ I) × (I ⊕ I))) + (hnoopp : ∀ e ∈ E, (e.2,e.1) ∉ E) + (href : ∀ i j, (Sum.inr i, Sum.inr j) ∈ E ↔ (Sum.inl i, Sum.inl j) ∈ E) + (x y : I → ZMod p) : + graphValidity E (Sum.elim x y) = + graphValidity (cutInternalEdges E) x * graphValidity (cutInternalEdges E) y * + listKernel (cutCrossEdges E) (cutCrossDirection E) x y := by + classical + rw [graphValidity_all, Fintype.prod_sum_type] + simp only [Fintype.prod_sum_type, Sum.elim_inl, Sum.elim_inr, prod_mul_distrib] + rw [cutCrossEdges_factor E hnoopp, graphValidity_all, graphValidity_all] + simp only [cutInternalEdges, mem_filter, mem_univ, true_and, href] + ring + +lemma graphValidity_nonneg {I : Type*} {p : ℕ} [Fact p.Prime] + (E : Finset (I × I)) (z : I → ZMod p) : 0 ≤ graphValidity E z := by + exact prod_nonneg fun e _ => squareIndicator_nonneg _ + +lemma graphValidity_sq {I : Type*} {p : ℕ} [Fact p.Prime] + (E : Finset (I × I)) (z : I → ZMod p) : graphValidity E z ^ 2 = graphValidity E z := by + classical + unfold graphValidity + rw [← prod_pow] + apply prod_congr rfl + intro e _ + unfold squareIndicator + split_ifs <;> norm_num + +lemma list_quadratic_lower {I : Type*} [Fintype I] [DecidableEq I] + {p : ℕ} [Fact p.Prime] (hp : p ≠ 2) (E : Finset (I × I)) + (dir : I → I → Bool) (f : (I → ZMod p) → ℝ) : + -(32 * E.card : ℝ) ^ ((1 : ℝ) / 4) * (p : ℝ) ^ (-(1 : ℝ) / 8) * + (𝔼 x : I → ZMod p, (f x)^2) ≤ + 𝔼 x : I → ZMod p, 𝔼 y : I → ZMod p, f x * listKernel E dir x y * f y := by + have h := list_mixing hp E dir f f + have hv : 0 ≤ 𝔼 x : I → ZMod p, (f x)^2 := expect_nonneg (fun _ _ => sq_nonneg _) + have hs : Real.sqrt (𝔼 x : I → ZMod p, (f x)^2) * + Real.sqrt (𝔼 x : I → ZMod p, (f x)^2) = 𝔼 x : I → ZMod p, (f x)^2 := + Real.mul_self_sqrt hv + rw [mul_assoc, hs] at h + have hex : (𝔼 x : I → ZMod p, 𝔼 y : I → ZMod p, + f x * (listKernel E dir x y - (1/2:ℝ)^E.card) * f y) = + (𝔼 x : I → ZMod p, 𝔼 y : I → ZMod p, f x * listKernel E dir x y * f y) - + (1/2:ℝ)^E.card * (𝔼 x : I → ZMod p, f x)^2 := by + simp only [sub_mul, mul_sub, expect_sub_distrib, ← expect_mul, ← mul_expect] + ring + rw [hex] at h + have hc : 0 ≤ (1/2:ℝ)^E.card * (𝔼 x : I → ZMod p, f x)^2 := by positivity + have hl := (abs_le.mp h).1 + nlinarith + +open scoped Classical + +noncomputable def graphPullback {I K : Type*} [Fintype I] + (e : I ≃ K) (E : Finset (K × K)) : Finset (I × I) := by + classical + exact univ.filter fun ij => (e ij.1, e ij.2) ∈ E + +lemma graphValidity_pullback {I K : Type*} [Fintype I] {p : ℕ} [Fact p.Prime] + (e : I ≃ K) (E : Finset (K × K)) (z : K → ZMod p) : + graphValidity (graphPullback e E) (z ∘ e) = graphValidity E z := by + classical + apply prod_equiv (Equiv.prodCongr e e) + · intro ij + simp only [graphPullback, mem_filter, mem_univ, true_and, Equiv.prodCongr_apply] + rfl + · intro ij _ + rfl + +abbrev TupleHalfAddress (S : Finset (Fin tupleBlocks)) (b : Fin tupleBlocks) (hb : b ∉ S) + (α β : Fin tupleH) := CutHalf (⟨b, hb⟩ : {c : Fin tupleBlocks // c ∉ S}) α β + +abbrev TupleHalfEntry (S : Finset (Fin tupleBlocks)) (b : Fin tupleBlocks) (hb : b ∉ S) + (α β : Fin tupleH) := TupleHalfAddress S b hb α β × TupleListIndex S + +noncomputable instance tupleHalfEntryFintype (S : Finset (Fin tupleBlocks)) + (b : Fin tupleBlocks) (hb : b ∉ S) (α β : Fin tupleH) : + Fintype (TupleHalfEntry S b hb α β) := by + classical + unfold TupleHalfEntry + infer_instance + +noncomputable def tupleEntryHalfEquiv (S : Finset (Fin tupleBlocks)) + (b : Fin tupleBlocks) (hb : b ∉ S) {α β : Fin tupleH} (hne : α ≠ β) : + TupleHalfEntry S b hb α β ⊕ TupleHalfEntry S b hb α β ≃ TupleListEntry S := + (Equiv.sumProdDistrib _ _ _).symm.trans + (Equiv.prodCongr (halfSumEquiv (⟨b, hb⟩ : {c : Fin tupleBlocks // c ∉ S}) hne) (Equiv.refl _)) + +lemma tupleEntryHalfEquiv_inl (S : Finset (Fin tupleBlocks)) + (b : Fin tupleBlocks) (hb : b ∉ S) {α β : Fin tupleH} (hne : α ≠ β) + (a : TupleHalfEntry S b hb α β) : + tupleEntryHalfEquiv S b hb hne (Sum.inl a) = (a.1.1, a.2) := rfl + +lemma tupleEntryHalfEquiv_inr (S : Finset (Fin tupleBlocks)) + (b : Fin tupleBlocks) (hb : b ∉ S) {α β : Fin tupleH} (hne : α ≠ β) + (a : TupleHalfEntry S b hb α β) : + tupleEntryHalfEquiv S b hb hne (Sum.inr a) = + tupleEntryReflect S b α β (a.1.1, a.2) := by + apply Prod.ext + · funext c + change reflect (⟨b,hb⟩ : {c : Fin tupleBlocks // c ∉ S}) α β a.1.1 c = + (if c.1 = b then Equiv.swap α β else 1) * a.1.1 c + have he : c = ⟨b,hb⟩ ↔ c.1 = b := Subtype.ext_iff + by_cases hc : c = ⟨b,hb⟩ + · subst c; simp [reflect] + · have hc' : c.1 ≠ b := fun h => hc (he.mpr h) + simp [reflect, hc, hc'] + · rfl + +def tupleHalfProjection (S : Finset (Fin tupleBlocks)) (b : Fin tupleBlocks) + (hb : b ∉ S) (α β : Fin tupleH) (x : CutHalf b α β) : TupleHalfAddress S b hb α β := + ⟨tupleProjection S x.1, x.2⟩ + +noncomputable def tupleHalfWeight (S : Finset (Fin tupleBlocks)) + (b : Fin tupleBlocks) (α β : Fin tupleH) (j : CutHalf b α β → TupleListIndex S) : ℝ := + indexWeight (Matrix.submatrix (interaction S tupleDelta) Subtype.val Subtype.val) j + +noncomputable def tupleUnmarkedGraph (S : Finset (Fin tupleBlocks)) + (b : Fin tupleBlocks) (hb : b ∉ S) {α β : Fin tupleH} (hne : α ≠ β) := + graphPullback (tupleEntryHalfEquiv S b hb hne) (tupleListEdges S) + +lemma tupleUnmarkedGraph_noopp (S : Finset (Fin tupleBlocks)) + (b : Fin tupleBlocks) (hb : b ∉ S) {α β : Fin tupleH} (hne : α ≠ β) : + ∀ e ∈ tupleUnmarkedGraph S b hb hne, (e.2,e.1) ∉ tupleUnmarkedGraph S b hb hne := by + classical + intro e he hh + simp only [tupleUnmarkedGraph, graphPullback, mem_filter, mem_univ, true_and] at he hh + exact tupleListEdges_no_opp S _ he hh + +lemma tupleUnmarkedGraph_reflect (S : Finset (Fin tupleBlocks)) + (b : Fin tupleBlocks) (hb : b ∉ S) {α β : Fin tupleH} (hne : α ≠ β) + (a c : TupleHalfEntry S b hb α β) : + (Sum.inr a, Sum.inr c) ∈ tupleUnmarkedGraph S b hb hne ↔ + (Sum.inl a, Sum.inl c) ∈ tupleUnmarkedGraph S b hb hne := by + classical + simp only [tupleUnmarkedGraph, graphPullback, mem_filter, mem_univ, true_and, + tupleEntryHalfEquiv_inl, tupleEntryHalfEquiv_inr] + exact tupleListEdges_reflect S b α β ((a.1.1,a.2),(c.1.1,c.2)) + +lemma tupleOutput_half (S : Finset (Fin tupleBlocks)) + (b : Fin tupleBlocks) (hb : b ∉ S) {α β : Fin tupleH} (hne : α ≠ β) + {p : ℕ} (x y : TupleHalfEntry S b hb α β → ZMod p) + (j k : CutHalf b α β → TupleListIndex S) : + tupleOutput S ((Sum.elim x y) ∘ (tupleEntryHalfEquiv S b hb hne).symm) + ((Sum.elim j k) ∘ (halfSumEquiv b hne).symm) ∘ (halfSumEquiv b hne) = + Sum.elim (fun v => x (tupleHalfProjection S b hb α β v, j v)) + (fun v => y (tupleHalfProjection S b hb α β v, k v)) := by + funext v + rcases v with v | v + · change (Sum.elim x y) ((tupleEntryHalfEquiv S b hb hne).symm + (tupleProjection S v.1, (Sum.elim j k) ((halfSumEquiv b hne).symm ((halfSumEquiv b hne) (Sum.inl v))))) = _ + rw [Equiv.symm_apply_apply] + change (Sum.elim x y) ((tupleEntryHalfEquiv S b hb hne).symm + ((tupleEntryHalfEquiv S b hb hne) (Sum.inl (tupleHalfProjection S b hb α β v, j v)))) = _ + rw [Equiv.symm_apply_apply] + rfl + · change (Sum.elim x y) ((tupleEntryHalfEquiv S b hb hne).symm + (tupleProjection S (reflect b α β v.1), + (Sum.elim j k) ((halfSumEquiv b hne).symm ((halfSumEquiv b hne) (Sum.inr v))))) = _ + rw [Equiv.symm_apply_apply] + change (Sum.elim x y) ((tupleEntryHalfEquiv S b hb hne).symm + (tupleProjection S (reflect b α β v.1), k v)) = _ + rw [tupleProjection_reflect_all] + have he := tupleEntryHalfEquiv_inr S b hb hne (tupleHalfProjection S b hb α β v, k v) + change _ = (tupleAddressReflect S b α β (tupleProjection S v.1), k v) at he + rw [← he, Equiv.symm_apply_apply] + rfl + +lemma tupleHalfWeight_one_le (S : Finset (Fin tupleBlocks)) + (b : Fin tupleBlocks) (α β : Fin tupleH) (j : CutHalf b α β → TupleListIndex S) : + 1 ≤ tupleHalfWeight S b α β j := + one_le_indexWeight _ (fun _ _ => interaction_nonneg S tupleDelta_pos.le _ _) j + +lemma tupleHalfWeight_le (S : Finset (Fin tupleBlocks)) (hS : S.card ≤ tupleT + 1) + (b : Fin tupleBlocks) (hb : b ∉ S) {α β : Fin tupleH} (hne : α ≠ β) + (j : CutHalf b α β → TupleListIndex S) : tupleHalfWeight S b α β j ≤ tupleWeightBound := by + let J := (Sum.elim j j) ∘ (halfSumEquiv b hne).symm + have hW := tupleWeight_le S hS J + have he := indexWeight_equiv (halfSumEquiv b hne) (interaction S tupleDelta) J + have hj : J ∘ halfSumEquiv b hne = Sum.elim j j := by + funext x + exact congrArg (Sum.elim j j) ((halfSumEquiv b hne).symm_apply_apply x) + rw [hj, unmarked_weight_factor S tupleDelta b hb hne] at he + change tupleHalfWeight S b α β j * tupleHalfWeight S b α β j = tupleWeight S J at he + rw [← he] at hW + have h1 := tupleHalfWeight_one_le S b α β j + nlinarith + +end SquareDifference +end + +end OAI diff --git a/lean/OAI/Combinatorics/SquareDifference/TupleWeights.lean b/lean/OAI/Combinatorics/SquareDifference/TupleWeights.lean new file mode 100644 index 0000000000000000000000000000000000000000..cf155f57a4e1b06903c3a2ff2faa97887596ff0c --- /dev/null +++ b/lean/OAI/Combinatorics/SquareDifference/TupleWeights.lean @@ -0,0 +1,513 @@ +import OAI.Combinatorics.SquareDifference.CrossProducts + +namespace OAI + +section +open Finset +open scoped BigOperators +namespace SquareDifference +open scoped Classical + +lemma expect_two_evals {I X : Type*} [Fintype I] [DecidableEq I] [Fintype X] [Nonempty X] + (i j : I) (hij : i≠j) (f : X → X → ℝ) : + (𝔼 Y : I → X, f (Y i) (Y j))=𝔼 x, 𝔼 y, f x y := by + let j' : {k : I // k≠i} := ⟨j, hij.symm⟩ + have h := Fintype.expect_equiv (Equiv.funSplitAt i X) (fun Y => f (Y i) (Y j)) + (fun z => f z.1 (z.2 j')) (fun _ => rfl) + rw [h, ← univ_product_univ, expect_product] + apply expect_congr rfl; intro x _ + exact expect_eval j' (f x) + +lemma tupleProjection_cycle_ne (S : Finset (Fin tupleBlocks)) + (hS : S.card≤tupleT+1) (k : ℕ) : + tupleProjection S (cycleVertex k)≠tupleProjection S (cycleVertex (k+1)) := by + have hc : 0 F (z (cycleVertex k)) (z (cycleVertex (k+1))))= + tupleComponent (p := p) S (fun _ => 1)*(𝔼 x, 𝔼 y, F x y) := by + have he (j : TupleVertex → TupleListIndex S) : + (𝔼 Y : TupleListEntry S → ZMod p, + F (tupleOutput S Y j (cycleVertex k)) (tupleOutput S Y j (cycleVertex (k+1))))= + 𝔼 x, 𝔼 y, F x y := by + apply expect_two_evals + intro hh + exact tupleProjection_cycle_ne S hS.le k (congrArg Prod.fst hh) + unfold tupleComponent + simp only [tupleValidity_terminal S hS, one_mul, mul_one, Fintype.expect_const] + rw [expect_comm] + simp only [← mul_expect, he, ← expect_mul] + +lemma filtered_powerset_sum {B M : Type*} [Fintype B] [DecidableEq B] [AddCommMonoid M] + (n : ℕ) (f : Finset B → M) : + (∑S∈(univ : Finset (Finset B)).filter (fun S => S.card≤n), f S)= + ∑S∈(univ : Finset B).powerset, if S.card≤n then f S else 0 := by + rw [sum_filter, powerset_univ] + +lemma filtered_card_split {B M : Type*} [Fintype B] [DecidableEq B] [AddCommMonoid M] + (n : ℕ) (f : Finset B → M) : + (∑S∈(univ : Finset (Finset B)).filter (fun S => S.card≤n+1), f S)= + (∑S∈(univ : Finset (Finset B)).filter (fun S => S.card≤n), f S)+ + (∑S∈(univ : Finset (Finset B)).filter (fun S => S.card=n+1), f S) := by + simp only [sum_filter, ← sum_add_distrib] + apply sum_congr rfl + intro S _ + by_cases h : S.card≤n + · simp only [ite_eq_left h, ite_eq_left (h.trans (Nat.le_succ _)), ite_eq_right (by omega : S.card≠n+1), add_zero] + · by_cases he : S.card=n+1 + · simp only [ite_eq_left he, ite_eq_left he.le, ite_eq_right h, zero_add] + · simp only [ite_eq_right h, ite_eq_right he, ite_eq_right (by omega : ¬S.card≤n+1), add_zero] + +noncomputable def tupleFamily (n : ℕ) : Finset (Finset (Fin tupleBlocks)) := + univ.filter (fun S => S.card≤n) + +lemma mem_tupleFamily {n : ℕ} {S : Finset (Fin tupleBlocks)} : S∈tupleFamily n ↔ S.card≤n := by + simp only [tupleFamily, mem_filter, mem_univ, true_and] + +lemma empty_mem_tupleFamily (n : ℕ) : ∅∈tupleFamily n := + mem_tupleFamily.mpr (by simp only [card_empty, Nat.zero_le]) + +lemma tupleSubmixture_full {p : ℕ} [Fact p.Prime] : + tupleSubmixture (p := p) (tupleFamily (tupleT+1))=tupleMixtureMap := by + apply LinearMap.ext + intro F + rw [tupleSubmixture_apply, tupleMixtureMap_apply] + exact filtered_powerset_sum (tupleT+1) (fun S => tupleMixtureWeight p S*tupleComponent S F) + +lemma tupleSubLaw_full {p : ℕ} [Fact p.Prime] : + tupleSubLaw (p := p) (tupleFamily (tupleT+1))=tupleLaw := by + rw [tupleSubLaw, tupleSubmixture_full] + simp only [tupleLaw, tupleMixtureMap_apply] + +noncomputable def tupleGoodLaw {p : ℕ} [Fact p.Prime] : + ((TupleVertex → ZMod p) → ℝ) →ₗ[ℝ] ℝ := tupleSubLaw (tupleFamily tupleT) + +noncomputable def tupleTerminalFamily : Finset (Finset (Fin tupleBlocks)) := + univ.filter (fun S => S.card=tupleT+1) + +lemma mem_tupleTerminalFamily {S : Finset (Fin tupleBlocks)} : + S∈tupleTerminalFamily ↔ S.card=tupleT+1 := by + simp only [tupleTerminalFamily, mem_filter, mem_univ, true_and] + +lemma tupleSubmixture_split {p : ℕ} [Fact p.Prime] : + tupleMixtureMap (p := p)=tupleSubmixture (tupleFamily tupleT)+tupleSubmixture tupleTerminalFamily := by + rw [← tupleSubmixture_full] + apply LinearMap.ext + intro F + simp only [LinearMap.add_apply, tupleSubmixture_apply] + exact filtered_card_split tupleT (fun S => tupleMixtureWeight p S*tupleComponent S F) + +noncomputable def tupleExceptionalLaw {p : ℕ} [Fact p.Prime] : + ((TupleVertex → ZMod p) → ℝ) →ₗ[ℝ] ℝ := + (tupleMixture (p := p) (fun _ => 1))⁻¹ • tupleSubmixture tupleTerminalFamily + +noncomputable def tupleEta (p : ℕ) [Fact p.Prime] : ℝ := tupleExceptionalLaw (p := p) (fun _ => 1) + +lemma tupleExceptionalLaw_nonneg {p : ℕ} [Fact p.Prime] + (F : (TupleVertex → ZMod p) → ℝ) (hF : ∀z, 0≤F z) : + 0≤tupleExceptionalLaw F := + mul_nonneg (inv_nonneg.mpr (tupleMixture_nonneg _ (fun _ => by norm_num))) + (tupleSubmixture_nonneg _ F hF) + +lemma tupleEta_nonneg (p : ℕ) [Fact p.Prime] : 0≤tupleEta p := + tupleExceptionalLaw_nonneg _ (fun _ => by norm_num) + +lemma tupleLaw_decomposition {p : ℕ} [Fact p.Prime] + (hp : tupleMassThreshold≤(p : ℝ)) : + tupleLaw (p := p)=(1-tupleEta p) • tupleGoodLaw+tupleExceptionalLaw := by + have hm := lt_of_lt_of_le tupleLeadingMassLower_pos (tupleMixture_mass_lower hp) + have hg := lt_of_lt_of_le tupleLeadingMassLower_pos + (tupleSubmixture_mass_lower hp (tupleFamily tupleT) (empty_mem_tupleFamily _)) + have hs : tupleMixture (p := p) (fun _ => 1)= + tupleSubmixture (p := p) (tupleFamily tupleT) (fun _ => 1)+tupleSubmixture (p := p) tupleTerminalFamily (fun _ => 1) := by + rw [← tupleMixtureMap_apply, tupleSubmixture_split, LinearMap.add_apply] + have hc : 1-tupleEta p=(tupleMixture (p := p) (fun _ => 1))⁻¹* + tupleSubmixture (p := p) (tupleFamily tupleT) (fun _ => 1) := by + unfold tupleEta tupleExceptionalLaw + simp only [LinearMap.smul_apply, smul_eq_mul] + calc + _ = (tupleMixture (p := p) (fun _ => 1))⁻¹*tupleMixture (p := p) (fun _ => 1)- + (tupleMixture (p := p) (fun _ => 1))⁻¹*tupleSubmixture (p := p) tupleTerminalFamily (fun _ => 1) := by + rw [inv_mul_cancel₀ hm.ne'] + _ = _ := by rw [hs]; ring + rw [tupleLaw, tupleSubmixture_split, smul_add, hc] + simp only [tupleGoodLaw, tupleSubLaw, smul_smul, mul_assoc, mul_inv_cancel₀ hg.ne', mul_one, + tupleExceptionalLaw] + +lemma tupleGoodLaw_pair {p : ℕ} [Fact p.Prime] + (hp : tupleMassThreshold≤(p : ℝ)) (k : ℕ) (F : ZMod p → ZMod p → ℝ) : + tupleGoodLaw (fun z => F (z (cycleVertex k)) (z (cycleVertex (k+1))))=squarePairAverage F := by + have hs : tupleSubmixture (tupleFamily tupleT) + (fun z => F (z (cycleVertex k)) (z (cycleVertex (k+1))))= + tupleSubmixture (p := p) (tupleFamily tupleT) (fun _ => 1)*squarePairAverage F := by + simp only [tupleSubmixture_apply, sum_mul] + apply sum_congr rfl + intro S hS + rw [tupleComponent_pair_square S (mem_tupleFamily.mp hS), mul_assoc] + have hm := lt_of_lt_of_le tupleLeadingMassLower_pos + (tupleSubmixture_mass_lower hp (tupleFamily tupleT) (empty_mem_tupleFamily _)) + simp only [tupleGoodLaw, tupleSubLaw, LinearMap.smul_apply, smul_eq_mul, hs, ← mul_assoc, + inv_mul_cancel₀ hm.ne', one_mul] + +lemma tupleExceptionalLaw_pair {p : ℕ} [Fact p.Prime] + (k : ℕ) (F : ZMod p → ZMod p → ℝ) : + tupleExceptionalLaw (fun z => F (z (cycleVertex k)) (z (cycleVertex (k+1))))= + tupleEta p*(𝔼 x, 𝔼 y, F x y) := by + have hs : tupleSubmixture tupleTerminalFamily + (fun z => F (z (cycleVertex k)) (z (cycleVertex (k+1))))= + tupleSubmixture (p := p) tupleTerminalFamily (fun _ => 1)*(𝔼 x, 𝔼 y, F x y) := by + simp only [tupleSubmixture_apply, sum_mul] + apply sum_congr rfl + intro S hS + rw [tupleComponent_pair_uniform S (mem_tupleTerminalFamily.mp hS), mul_assoc] + simp only [tupleEta, tupleExceptionalLaw, LinearMap.smul_apply, smul_eq_mul, hs, mul_assoc] + +lemma tupleLaw_pair {p : ℕ} [Fact p.Prime] + (hp : tupleMassThreshold≤(p : ℝ)) (k : ℕ) (F : ZMod p → ZMod p → ℝ) : + tupleLaw (fun z => F (z (cycleVertex k)) (z (cycleVertex (k+1))))= + (1-tupleEta p)*squarePairAverage F+tupleEta p*(𝔼 x, 𝔼 y, F x y) := by + rw [tupleLaw_decomposition hp, LinearMap.add_apply, LinearMap.smul_apply, smul_eq_mul, + tupleGoodLaw_pair hp, tupleExceptionalLaw_pair] + +lemma tupleGoodLaw_probability {p : ℕ} [Fact p.Prime] + (hp : tupleMassThreshold≤(p : ℝ)) : tupleGoodLaw (p := p) (fun _ => 1)=1 := + tupleSubLaw_probability hp _ (empty_mem_tupleFamily _) + +lemma tupleGoodLaw_nonneg {p : ℕ} [Fact p.Prime] + (F : (TupleVertex → ZMod p) → ℝ) (hF : ∀z, 0≤F z) : 0≤tupleGoodLaw F := + tupleSubLaw_nonneg _ F hF + +lemma tupleGoodLaw_marginal {p : ℕ} [Fact p.Prime] + (hp : tupleMassThreshold≤(p : ℝ)) (v : TupleVertex) (f : ZMod p → ℝ) : + tupleGoodLaw (fun z => f (z v))=𝔼 x, f x := + tupleSubLaw_marginal hp _ (empty_mem_tupleFamily _) v f + +lemma tupleLaw_conditional {p : ℕ} [Fact p.Prime] + (hp : tupleConditionalThreshold≤(p : ℝ)) (v : TupleVertex) (f : ZMod p → ℝ) (hf : (𝔼 x, f x)=0) : + conditionalEnergy (jointDensity tupleLaw (Equiv.funSplitAt v (ZMod p))) f ≤ + (p : ℝ)^(-(1:ℝ)/32)*(𝔼 x, f x^2) := by + rw [← tupleSubLaw_full] + exact tupleSubLaw_conditional hp _ (empty_mem_tupleFamily _) + (fun S hS => mem_tupleFamily.mp hS) v f hf + +lemma tupleGoodLaw_conditional {p : ℕ} [Fact p.Prime] + (hp : tupleConditionalThreshold≤(p : ℝ)) (v : TupleVertex) (f : ZMod p → ℝ) (hf : (𝔼 x, f x)=0) : + conditionalEnergy (jointDensity tupleGoodLaw (Equiv.funSplitAt v (ZMod p))) f ≤ + (p : ℝ)^(-(1:ℝ)/32)*(𝔼 x, f x^2) := + tupleSubLaw_conditional hp _ (empty_mem_tupleFamily _) + (fun _S hS => (mem_tupleFamily.mp hS).trans (Nat.le_succ _)) v f hf + +noncomputable def tupleExceptionalConstant : ℝ := + ((univ : Finset (Finset (Fin tupleBlocks))).card : ℝ)*tupleWeightBound/tupleLeadingMassLower + +lemma tupleEta_le {p : ℕ} [Fact p.Prime] (hp : tupleMassThreshold≤(p : ℝ)) : + tupleEta p≤tupleExceptionalConstant*(p : ℝ)^(-(81:ℝ)/16) := by + have hs : tupleSubmixture (p := p) tupleTerminalFamily (fun _ => 1)≤ + (p : ℝ)^(-(81:ℝ)/16)*(((univ : Finset (Finset (Fin tupleBlocks))).card : ℝ)*tupleWeightBound) := by + rw [tupleSubmixture_apply] + calc + _ ≤ ∑_S∈tupleTerminalFamily, (p : ℝ)^(-(81:ℝ)/16)*tupleWeightBound := by + apply sum_le_sum + intro S hS + have hc : S.card=81 := mem_tupleTerminalFamily.mp hS + simp only [tupleMixtureWeight, hc, Nat.cast_ofNat] + exact mul_le_mul_of_nonneg_left (tupleComponent_mass_le S (by change S.card≤81; omega)) + (Real.rpow_nonneg (Nat.cast_nonneg _) _) + _ = (p : ℝ)^(-(81:ℝ)/16)*((tupleTerminalFamily.card : ℝ)*tupleWeightBound) := by + rw [sum_const, nsmul_eq_mul]; ring + _ ≤ _ := mul_le_mul_of_nonneg_left (mul_le_mul_of_nonneg_right + (by exact_mod_cast card_le_card (subset_univ tupleTerminalFamily)) tupleWeightBound_pos.le) + (Real.rpow_nonneg (Nat.cast_nonneg _) _) + have hm := lt_of_lt_of_le tupleLeadingMassLower_pos (tupleMixture_mass_lower hp) + unfold tupleEta tupleExceptionalLaw + simp only [LinearMap.smul_apply, smul_eq_mul] + calc + _ ≤ (tupleMixture (p := p) (fun _ => 1))⁻¹* + ((p : ℝ)^(-(81:ℝ)/16)*(((univ : Finset (Finset (Fin tupleBlocks))).card : ℝ)*tupleWeightBound)) := + mul_le_mul_of_nonneg_left hs (inv_nonneg.mpr hm.le) + _ ≤ tupleLeadingMassLower⁻¹* + ((p : ℝ)^(-(81:ℝ)/16)*(((univ : Finset (Finset (Fin tupleBlocks))).card : ℝ)*tupleWeightBound)) := + mul_le_mul_of_nonneg_right (inv_anti₀ tupleLeadingMassLower_pos (tupleMixture_mass_lower hp)) + (mul_nonneg (Real.rpow_nonneg (Nat.cast_nonneg _) _) + (mul_nonneg (Nat.cast_nonneg _) tupleWeightBound_pos.le)) + _ = _ := by unfold tupleExceptionalConstant; ring + +end SquareDifference + +namespace SquareDifference + +open Finset + +noncomputable def kernelForm {X : Type*} [Fintype X] + (K : Matrix X X ℝ) (f g : X → ℝ) : ℝ := + 𝔼 x, 𝔼 y, f x*K x y*g y + +noncomputable def conditionalGram {X Y : Type*} [Fintype X] [Fintype Y] + (W : X → Y → ℝ) : Matrix X X ℝ := + fun x x' => 𝔼 y, W x y*W x' y/(𝔼 z, W z y) + +lemma kernelForm_conditionalGram {X Y : Type*} [Fintype X] [Fintype Y] + (W : X → Y → ℝ) (f : X → ℝ) : + kernelForm (conditionalGram W) f f = conditionalEnergy W f := by + unfold kernelForm conditionalGram conditionalEnergy + simp only [mul_expect, expect_mul] + have hc : (𝔼 x, 𝔼 x', 𝔼 y, f x*(W x y*W x' y/(𝔼 z, W z y))*f x') = + (𝔼 x, 𝔼 y, 𝔼 x', f x*(W x y*W x' y/(𝔼 z, W z y))*f x') := by + apply expect_congr rfl + intro x _ + rw [expect_comm] + rw [hc, expect_comm] + apply expect_congr rfl + intro y _ + calc + _ = (𝔼 x, f x*W x y)*(𝔼 x', f x'*W x' y)/(𝔼 z, W z y) := by + simp only [mul_expect, expect_mul, expect_div] + apply expect_congr rfl + intro x _ + apply expect_congr rfl + intro x' _ + ring + _ = _ := by ring + +lemma conditionalGram_symm {X Y : Type*} [Fintype X] [Fintype Y] + (W : X → Y → ℝ) (x x' : X) : conditionalGram W x x'=conditionalGram W x' x := by + unfold conditionalGram + simp only [mul_comm (W x _) (W x' _)] + +lemma conditionalGram_row {X Y : Type*} [Fintype X] [Nonempty X] [Fintype Y] + (W : X → Y → ℝ) (hW : ∀ x y, 0 ≤ W x y) + (hrow : ∀ x, (𝔼 y, W x y)=1) (x : X) : + (𝔼 x', conditionalGram W x x')=1 := by + unfold conditionalGram + rw [expect_comm] + have he (y : Y) : (𝔼 x', W x y*W x' y/(𝔼 z, W z y))=W x y := by + by_cases ha : (𝔼 z, W z y)=0 + · have hz := (Finset.expect_eq_zero_iff_of_nonneg (fun z _ => hW z y)).mp ha x (mem_univ _) + simp [hz] + · simp only [← expect_div, ← mul_expect] + field_simp + simp only [he, hrow] + +lemma kernelForm_nonneg_iff {X : Type*} [Fintype X] [Nonempty X] + (K : Matrix X X ℝ) (hs : ∀ x y, K x y=K y x) : + Matrix.PosSemidef K ↔ ∀ f, 0 ≤ kernelForm K f f := by + have hn : (0 : ℝ) < Fintype.card X := Nat.cast_pos.mpr Fintype.card_pos + have he (f : X → ℝ) : kernelForm K f f = + (dotProduct (star f) (Matrix.mulVec K f))/(Fintype.card X : ℝ)^2 := by + unfold kernelForm + simp only [expect_eq_sum_div_card, card_univ, dotProduct, Matrix.mulVec, + Pi.star_apply, star_trivial, mul_sum, mul_assoc] + rw [← sum_div] + ring + rw [Matrix.posSemidef_iff_dotProduct_mulVec] + constructor + · intro h f + rw [he] + exact div_nonneg (h.2 f) (sq_nonneg _) + · intro h + constructor + · ext x y + exact hs y x + · intro f + have hp := h f + rw [he] at hp + have hh := mul_nonneg hp (le_of_lt (sq_pos_of_pos hn)) + simpa only [div_mul_cancel₀ _ (ne_of_gt (sq_pos_of_pos hn))] using hh + +lemma conditionalGram_posSemidef {X Y : Type*} [Fintype X] [Nonempty X] [Fintype Y] + (W : X → Y → ℝ) (hW : ∀ x y, 0 ≤ W x y) : + Matrix.PosSemidef (conditionalGram W) := by + apply (kernelForm_nonneg_iff _ (conditionalGram_symm W)).mpr + intro f + rw [kernelForm_conditionalGram] + exact conditionalEnergy_nonneg W f hW + +lemma kernelForm_symmetric {X : Type*} [Fintype X] (K : Matrix X X ℝ) + (hs : ∀ x y, K x y=K y x) (f g : X → ℝ) : + kernelForm K f g=kernelForm K g f := by + unfold kernelForm + rw [expect_comm] + apply expect_congr rfl + intro x _ + apply expect_congr rfl + intro y _ + rw [hs y x] + ring + +lemma kernelForm_const_right {X : Type*} [Fintype X] + (K : Matrix X X ℝ) (hrow : ∀ x, (𝔼 y, K x y)=1) + (f : X → ℝ) (c : ℝ) : kernelForm K f (fun _ => c)=c*(𝔼 x, f x) := by + unfold kernelForm + simp only [← expect_mul, ← mul_expect, hrow, mul_one] + ring + +lemma kernelForm_center {X : Type*} [Fintype X] [Nonempty X] + (K : Matrix X X ℝ) (hs : ∀ x y, K x y=K y x) + (hrow : ∀ x, (𝔼 y, K x y)=1) (f : X → ℝ) : + kernelForm K (fun x => f x-(𝔼 z, f z)) (fun x => f x-(𝔼 z, f z)) = + kernelForm K f f-(𝔼 z, f z)^2 := by + let c := 𝔼 z, f z + have he : kernelForm K (fun x => f x-c) (fun x => f x-c) = + kernelForm K f f-kernelForm K f (fun _ => c)- + kernelForm K (fun _ => c) f+kernelForm K (fun _ => c) (fun _ => c) := by + unfold kernelForm + simp only [sub_mul, mul_sub, expect_sub_distrib] + ring + rw [he, kernelForm_symmetric K hs (fun _ => c) f, + kernelForm_const_right K hrow, kernelForm_const_right K hrow, + Fintype.expect_const] + dsimp only [c] + ring + +noncomputable def noiseKernel {X : Type*} [Fintype X] [DecidableEq X] + (δ : ℝ) : Matrix X X ℝ := + fun x y => 1-δ^2+δ^2*(Fintype.card X : ℝ)*(if x=y then 1 else 0) + +lemma kernelForm_noise {X : Type*} [Fintype X] [Nonempty X] [DecidableEq X] + (δ : ℝ) (f : X → ℝ) : + kernelForm (noiseKernel δ) f f = (𝔼 x, f x)^2+ + δ^2*((𝔼 x, f x^2)-(𝔼 x, f x)^2) := by + have hn : (Fintype.card X : ℝ) ≠ 0 := Nat.cast_ne_zero.mpr Fintype.card_ne_zero + have he (x : X) : (𝔼 y, (if x=y then (1 : ℝ) else 0)*f y)= + f x/(Fintype.card X : ℝ) := by + simp [expect_eq_sum_div_card] + have he' (x : X) : (𝔼 y, f x*noiseKernel δ x y*f y) = + (1-δ^2)*f x*(𝔼 y, f y)+δ^2*f x^2 := by + unfold noiseKernel + simp only [mul_add, add_mul, expect_add_distrib, mul_assoc, ← mul_expect, he] + field_simp + unfold kernelForm + simp only [he', expect_add_distrib, ← expect_mul, ← mul_expect] + ring + +lemma centered_square_mean {X : Type*} [Fintype X] [Nonempty X] (f : X → ℝ) : + (𝔼 x, (f x-(𝔼 y, f y))^2) = (𝔼 x, f x^2)-(𝔼 x, f x)^2 := by + simp only [sub_sq, expect_add_distrib, expect_sub_distrib, ← mul_expect, + ← expect_mul, Fintype.expect_const] + ring + +lemma conditionalGram_noise_domination {X Y : Type*} + [Fintype X] [Nonempty X] [DecidableEq X] [Fintype Y] + (W : X → Y → ℝ) (hW : ∀ x y, 0 ≤ W x y) + (hrow : ∀ x, (𝔼 y, W x y)=1) (δ : ℝ) + (hmix : ∀ f : X → ℝ, (𝔼 x, f x)=0 → + conditionalEnergy W f ≤ δ^2*(𝔼 x, f x^2)) : + Matrix.PosSemidef (fun x y => noiseKernel δ x y-conditionalGram W x y) := by + apply (kernelForm_nonneg_iff _ (by + intro x y + simp only [noiseKernel, conditionalGram_symm W x y, eq_comm])).mpr + intro f + have hm := hmix (fun x => f x-(𝔼 z, f z)) (by + simp only [expect_sub_distrib, Fintype.expect_const, sub_self]) + rw [← kernelForm_conditionalGram, kernelForm_center _ (conditionalGram_symm W) + (conditionalGram_row W hW hrow), centered_square_mean] at hm + have he : kernelForm (fun x y => noiseKernel δ x y-conditionalGram W x y) f f = + kernelForm (noiseKernel δ) f f-kernelForm (conditionalGram W) f f := by + unfold kernelForm + simp only [mul_sub, sub_mul, expect_sub_distrib] + rw [he, kernelForm_noise, kernelForm_conditionalGram] + rw [kernelForm_conditionalGram] at hm + linarith + +lemma matrix_prod_monotone {J I : Type*} [Fintype J] [Fintype I] + (A B : J → Matrix I I ℝ) (hA : ∀ j, (A j).PosSemidef) + (hD : ∀ j, (B j-A j).PosSemidef) : + Matrix.PosSemidef (fun x y => (∏ j, B j x y)-(∏ j, A j x y)) := by + classical + have hB j : (B j).PosSemidef := by + have hh := (hD j).add (hA j) + simpa only [sub_add_cancel] using hh + have hprod (s : Finset J) : Matrix.PosSemidef (fun x y => ∏ j ∈ s, A j x y) := by + have hh := matrix_prod_posSemidef (fun j : s => A j) (fun j => hA j) + have he : (fun x y => ∏ j : s, A j x y) = (fun x y => ∏ j∈s, A j x y) := by + funext x y + exact prod_coe_sort s (fun j => A j x y) + rw [he] at hh + exact hh + have hd (s : Finset J) : + Matrix.PosSemidef (fun x y => (∏ j ∈ s, B j x y)-(∏ j ∈ s, A j x y)) := by + induction s using Finset.induction_on with + | empty => + simp only [prod_empty, sub_self] + change (0 : Matrix I I ℝ).PosSemidef + exact Matrix.PosSemidef.zero + | @insert j s hj ih => + have hh := ((hD j).hadamard (hprod s)).add ((hB j).hadamard ih) + have he : ((fun x y => (∏ k∈insert j s, B k x y)-(∏ k∈insert j s, A k x y)) : Matrix I I ℝ) = + (B j-A j).hadamard (fun x y => ∏ k∈s, A k x y) + + (B j).hadamard (fun x y => (∏ k∈s, B k x y)-(∏ k∈s, A k x y)) := by + ext x y + simp only [prod_insert hj, Matrix.add_apply] + change B j x y*(∏ k∈s, B k x y)-A j x y*(∏ k∈s, A k x y) = + (B j x y-A j x y)*(∏ k∈s, A k x y)+ + B j x y*((∏ k∈s, B k x y)-(∏ k∈s, A k x y)) + ring + rw [he] + exact hh + exact hd univ + +lemma product_kernel_monotone {J : Type*} [Fintype J] + {X : J → Type*} [∀ j, Fintype (X j)] + (A B : ∀ j, Matrix (X j) (X j) ℝ) (hA : ∀ j, (A j).PosSemidef) + (hD : ∀ j, (B j-A j).PosSemidef) : + Matrix.PosSemidef (fun x y : ∀ j, X j => + (∏ j, B j (x j) (y j))-(∏ j, A j (x j) (y j))) := by + classical + apply matrix_prod_monotone (fun j => (A j).submatrix (fun x : ∀ j, X j => x j) (fun x : ∀ j, X j => x j)) + (fun j => (B j).submatrix (fun x : ∀ j, X j => x j) (fun x : ∀ j, X j => x j)) + · intro j; exact (hA j).submatrix _ + · intro j + exact (hD j).submatrix _ + +lemma expect_update_dep {J : Type*} [Fintype J] [DecidableEq J] + {X : J → Type*} [∀ j, Fintype (X j)] [∀ j, Nonempty (X j)] + (j : J) (f : (∀ j, X j) → ℝ) : + (𝔼 x : ∀ j, X j, 𝔼 t : X j, f (Function.update x j t))=𝔼 x, f x := by + let e : ((∀ j, X j) × X j) ≃ ((∀ j, X j) × X j) := + { toFun := fun a => (Function.update a.1 j a.2, a.1 j) + invFun := fun a => (Function.update a.1 j a.2, a.1 j) + left_inv := by rintro ⟨x,t⟩; simp + right_inv := by rintro ⟨x,t⟩; simp } + have he := Fintype.expect_equiv e + (fun a : (∀ j, X j) × X j => f (Function.update a.1 j a.2)) + (fun a : (∀ j, X j) × X j => f a.1) (fun _ => rfl) + rw [← univ_product_univ, expect_product, expect_product] at he + simpa only [Fintype.expect_const] using he + +noncomputable def coordOp {J : Type*} [DecidableEq J] + {X : J → Type*} [∀ j, Fintype (X j)] + (K : ∀ j, Matrix (X j) (X j) ℝ) (j : J) + (f : (∀ j, X j) → ℝ) (x : ∀ j, X j) : ℝ := + 𝔼 t : X j, K j (x j) t*f (Function.update x j t) + +def patch {J : Type*} [DecidableEq J] {X : J → Type*} + (s : Finset J) (x y : ∀ j, X j) (j : J) : X j := if j∈s then y j else x j + +lemma patch_empty {J : Type*} [DecidableEq J] {X : J → Type*} (x y : ∀ j, X j) : + patch ∅ x y=x := by ext j; simp [patch] + +lemma patch_univ {J : Type*} [Fintype J] [DecidableEq J] + {X : J → Type*} (x y : ∀ j, X j) : patch univ x y=y := by ext j; simp [patch] + +end SquareDifference +end + +end OAI diff --git a/lean/OAI/Combinatorics/SquareDifference/UniformBase.lean b/lean/OAI/Combinatorics/SquareDifference/UniformBase.lean new file mode 100644 index 0000000000000000000000000000000000000000..fad81c469508d6e41ba25bb5eb9e3d3c48d66001 --- /dev/null +++ b/lean/OAI/Combinatorics/SquareDifference/UniformBase.lean @@ -0,0 +1,63 @@ +import OAI.Combinatorics.SquareDifference.PrimeSetup + +namespace OAI + +section + +open Finset + +open scoped BigOperators + +namespace SquareDifference + +open LiftTheory.SquareDifference + +lemma positiveLaw_diagonal_pointwise {V X : Type*} [Fintype V] + (L : ((V → X) → ℝ) →ₗ[ℝ] ℝ) (hpos : ∀F,(∀z,0≤F z) → 0≤L F) + (hm : L (fun _ => 1)=1) (f : X → ℝ) (R : ℝ) (hf : ∀x,|f x|≤R) : + diagonalIntegral L f≤R^(Fintype.card V) := by + change L (fun z => ∏v,f (z v))≤_ + calc + _ ≤ L (fun _ => R^(Fintype.card V)) := by + apply positiveLaw_mono L hpos + intro z + calc + _ ≤ |∏v,f (z v)| := le_abs_self _ + _ = ∏v,|f (z v)| := abs_prod _ _ + _ ≤ ∏_v : V,R := prod_le_prod₀ (fun _ _ => abs_nonneg _) (fun v _ => hf (z v)) + _ = _ := by rw [prod_const,card_univ] + _ = _ := by rw [positiveLaw_const,hm,mul_one] + +lemma setFunctional_base {J : Type} [Fintype J] [DecidableEq J] + (p : J → ℕ) [∀j,Fact (p j).Prime] (hinj : Function.Injective p) + (hp : ∀j,tupleMassThreshold≤(p j:ℝ)) (N : ℕ) (hN : 1≤N) (A : Finset ℕ) : + setFunctional p N (powerCutoff N sourceBeta) A≤(N:ℝ)^(2*Fintype.card TupleVertex) := by + have hcop : Pairwise fun i j => (p i).Coprime (p j) := by + intro i j hij + exact ((Fact.out : (p i).Prime).coprime_iff_not_dvd.mpr + (fun h => hij (hinj ((Nat.prime_dvd_prime_iff_eq (Fact.out : (p i).Prime) (Fact.out : (p j).Prime)).mp h)))) + have hpt (x : ResidueSpace p) : |actualTruncatedLift p N (powerCutoff N sourceBeta) (natIndicator A) x|≤(powerCutoff N sourceBeta:ℝ)^2 := by + simpa only [mul_one] using (PairBridge.actualLift_pointwise_bound p hcop N (powerCutoff N sourceBeta) (by omega) (natIndicator A) 1 (by norm_num) (fun n _ => natIndicator_bound A n) x) + have hh := positiveLaw_diagonal_pointwise (productTupleLaw p) (tensorLaw_nonneg (fun j => tupleLaw (p:=p j)) (fun _ => tupleLaw_nonneg)) + (productTupleLaw_probability p hp) (actualTruncatedLift p N (powerCutoff N sourceBeta) (natIndicator A)) + ((powerCutoff N sourceBeta:ℝ)^2) hpt + apply hh.trans + rw [←pow_mul] + exact pow_le_pow_left₀ (Nat.cast_nonneg _) (by exact_mod_cast powerCutoff_le_self N hN sourceBeta sourceBeta_le) _ + +lemma inverse_power_base (n T k : ℕ) (hn : 0 transferFactor d M N*θ) atTop (𝓝 θ) := by + simpa only [one_mul] using (transferFactor_limit d M).mul_const θ + have herr : Tendsto (fun N : ℕ => E*(N:ℝ)^(a-σ)) atTop (𝓝 0) := by + have hh := (tendsto_rpow_neg_atTop (sub_pos.mpr haσ)).comp (tendsto_natCast_atTop_atTop (R:=ℝ)) + have he : -(σ-a)=a-σ := by ring + simpa only [he,Function.comp_def,mul_zero] using hh.const_mul E + have ht : ∀ᶠ N : ℕ in atTop, transferFactor d M N*θ≤1-κ ∧ E*(N:ℝ)^(a-σ)≤κ := by + filter_upwards [htf.eventually_lt_const hgap, herr.eventually_lt_const hκ] with N h1 h2 + exact ⟨h1.le,h2.le⟩ + obtain ⟨T,hT⟩ := eventually_atTop.mp (hs.and (ht.and (eventually_ge_atTop 2))) + let D := max 1 ((T:ℝ)^(2*d)*(T:ℝ)^a) + have hD : 1≤D := le_max_left _ _ + have hD0 : 0≤D := by linarith + refine ⟨a,D,ha,hD,?_⟩ + intro N + induction N using Nat.strong_induction_on with + | h N ih => + intro hN J _ _ p _ hp A hA hfree + have hN0 : 0 Sum.inr.inj (hp.injective (show extendedPrime ps p (Sum.inr i)=extendedPrime ps p (Sum.inr j) from hij)) + by_cases hnT : N≤T + · apply (setFunctional_base p hinjp (fun j => (le_max_left _ _).trans (hp.mass j)) N hN A).trans + exact inverse_power_base N T (2*d) hN0 hnT a D ha.le (le_max_right _ _) + · have hlarge := hT N (by omega) + have hh := hlarge.1 p hp.injective hp.lower hp.mass hp.reflection hp.coprime hp.exceptional hp.cover + a ha.le ha1 D hD0 (fun n hn hnN A' hA' hf => ih n hnN hn p (hp.mono hnN.le) A' hA' hf) + A hA hfree + apply hh.trans + have hr := induction_error_absorb N hN0 E a σ κ D hκ.le hD hlarge.2.1.2 + have hn : 0≤D*(N:ℝ)^(-a) := mul_nonneg hD0 (Real.rpow_nonneg (Nat.cast_nonneg _) _) + have hc := mul_le_mul_of_nonneg_right hlarge.2.1.1 hn + change E*(N:ℝ)^(-σ)+transferFactor d M N*D*(N:ℝ)^(-a)*θ≤D*(N:ℝ)^(-a) + calc + _ = E*(N:ℝ)^(-σ)+(transferFactor d M N*θ)*(D*(N:ℝ)^(-a)) := by ring + _ ≤ κ*(D*(N:ℝ)^(-a))+(1-κ)*(D*(N:ℝ)^(-a)) := add_le_add hr hc + _ = _ := by ring + +end SquareDifference + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SquareDifference/UniformRates.lean b/lean/OAI/Combinatorics/SquareDifference/UniformRates.lean new file mode 100644 index 0000000000000000000000000000000000000000..371b95b7e391a5105cac000f96b0fb31e89466e9 --- /dev/null +++ b/lean/OAI/Combinatorics/SquareDifference/UniformRates.lean @@ -0,0 +1,603 @@ +import OAI.Combinatorics.SquareDifference.FiniteKernel + +namespace OAI + +section +open Finset +open scoped ComplexConjugate BigOperators +namespace SquareDifference +open Finset + +lemma rationalGridPoint_injective (q : ℕ) [NeZero q] : Function.Injective (rationalGridPoint q) := by + intro a b h + apply ZMod.val_injective + have hq : (q : ℚ)≠0 := Nat.cast_ne_zero.mpr (NeZero.ne q) + have he := (div_left_inj' hq).mp h + exact_mod_cast he + +lemma exists_rationalGridPoint (q : ℕ) [NeZero q] (b : ℚ) + (hb0 : 0≤b) (hb1 : b<1) (hbd : b.den∣q) : + ∃a : ZMod q, rationalGridPoint q a=b := by + let n : ℕ := b.num.toNat*(q/b.den) + have hnum : 0≤b.num := Rat.num_nonneg.mpr hb0 + have hqeq : b.den*(q/b.den)=q := Nat.mul_div_cancel' hbd + have hden0 : (b.den : ℚ)≠0 := Nat.cast_ne_zero.mpr b.den_nz + have hq0 : (q : ℚ)≠0 := Nat.cast_ne_zero.mpr (NeZero.ne q) + have he : (n:ℚ)/q=b := by + dsimp only [n] + rw [Nat.cast_mul,← Int.cast_natCast,Int.toNat_of_nonneg hnum] + apply (div_eq_iff hq0).mpr + conv_rhs => rw [← Rat.num_div_den b] + rw [div_mul_eq_mul_div] + apply (eq_div_iff hden0).mpr + have heq : (b.den:ℚ)*(q/b.den:ℕ)=q := by exact_mod_cast hqeq + calc + _ = (b.num:ℚ)*((b.den:ℚ)*(q/b.den:ℕ)) := by ring + _ = _ := by rw [heq] + have hn : n rationalGridPoint_injective q h) + +lemma bounded_sum_eq_grid {E : Type*} [AddCommMonoid E] (q : ℕ) [NeZero q] + (L : ℕ) (f : ℚ → E) + (hf : ∀b, 0≤b → b<1 → f b≠0 → b.den≤L ∧ b.den∣q) : + (∑b∈boundedRationals L,f b)=∑a : ZMod q,f (rationalGridPoint q a) := by + classical + rw [← sum_rationalGrid] + apply sum_congr_of_eq_on_inter + · intro b hb hbg + by_contra h + have hh := hf b ((mem_boundedRationals L b).mp hb).1 ((mem_boundedRationals L b).mp hb).2.1 h + exact hbg ((mem_rationalGrid q b).mpr ⟨((mem_boundedRationals L b).mp hb).1, + ((mem_boundedRationals L b).mp hb).2.1,hh.2⟩) + · intro b hb hbg + by_contra h + have hh := hf b ((mem_rationalGrid q b).mp hb).1 ((mem_rationalGrid q b).mp hb).2.1 h + exact hbg ((mem_boundedRationals L b).mpr ⟨((mem_rationalGrid q b).mp hb).1, + ((mem_rationalGrid q b).mp hb).2.1,hh.1⟩) + · intro b hb hbg; rfl + +end SquareDifference + +namespace SquareDifference + +open Finset + +lemma bounded_sum_grid_of {E : Type*} [AddCommMonoid E] (q : ℕ) [NeZero q] + (L : ℕ) (f : ℚ → E) + (hf₁ : ∀b∈boundedRationals L, f b≠0 → b.den∣q) + (hf₂ : ∀b∈rationalGrid q, f b≠0 → b.den≤L) : + (∑b∈boundedRationals L,f b)=∑a : ZMod q,f (rationalGridPoint q a) := by + classical + rw [← sum_rationalGrid] + apply sum_congr_of_eq_on_inter + · intro b hb hbg + by_contra h + exact hbg ((mem_rationalGrid q b).mpr ⟨((mem_boundedRationals L b).mp hb).1, + ((mem_boundedRationals L b).mp hb).2.1,hf₁ b hb h⟩) + · intro b hb hbg + by_contra h + exact hbg ((mem_boundedRationals L b).mpr ⟨((mem_rationalGrid q b).mp hb).1, + ((mem_rationalGrid q b).mp hb).2.1,hf₂ b hb h⟩) + · intro b hb hbg; rfl + +lemma prime_dvd_smallQuadraticModulus_iff {p r : ℕ} (hp : p.Prime) (hr : r.Prime) : + r∣smallQuadraticModulus p ↔ r=p := by + unfold smallQuadraticModulus + split_ifs with h + · subst p + constructor + · intro hd + have hd2 := hr.dvd_of_dvd_pow (show r∣2^3 by simpa using hd) + exact ((Nat.dvd_prime Nat.prime_two).mp hd2).resolve_left hr.ne_one + · rintro rfl; norm_num + · exact (Nat.dvd_prime hp).trans (or_iff_right hr.ne_one) + +section GridModel + +variable {I : Type*} [Fintype I] [instDecidableEqI : DecidableEq I] + (p : I → ℕ) [∀i, Fact (p i).Prime] (hinj : Function.Injective p) + +include hinj + +omit [DecidableEq I] [∀i, Fact (p i).Prime] in +lemma primary_cover_of_prime_support (q : ℕ) (hq : q≠0) + (hs : ∀r, r.Prime → r∣q → ∃i,p i=r) : q∣∏i,primaryModulus q (p i) := by + classical + have h := dvd_primaryModulus_product q hq (univ.image p) (by + intro r hr + obtain ⟨i,hi⟩ := hs r (Nat.mem_primeFactors.mp hr).1 (Nat.mem_primeFactors.mp hr).2.1 + exact mem_image.mpr ⟨i,mem_univ _,hi⟩) + rwa [prod_image (fun _ _ _ _ h => hinj h)] at h + +omit hinj in +lemma smallProduct_primary_cover {I : Type*} + [Fintype I] + [DecidableEq I] + (p : I → ℕ) + [∀ (i : I), Fact (Nat.Prime (p i))] + (hinj : Function.Injective p) (b : ℚ) + (hb : b.den∣∏i,smallQuadraticModulus (p i)) : + b.den∣∏i,primaryModulus b.den (p i) := by + apply primary_cover_of_prime_support p hinj b.den b.den_nz + intro r hr hrd + obtain ⟨i,_,hi⟩ := (prime_dvd_finset_prod_iff (fun i => smallQuadraticModulus (p i)) univ r hr).mp (hrd.trans hb) + exact ⟨i,((prime_dvd_smallQuadraticModulus_iff (Fact.out : (p i).Prime) hr).mp hi).symm⟩ + +variable (R : Finset I) (c : ∀i,ZMod (p i)) + +omit hinj [∀i, Fact (p i).Prime] in +lemma root_active_div_smallProduct (B : Finset I) : + rootSquareModulus p R*(∏i∈B\R,p i)∣∏i,smallQuadraticModulus (p i) := by + have h₁ : (∏i∈B\R,p i)∣∏i∈Rᶜ,smallQuadraticModulus (p i) := by + apply (prod_dvd_prod_of_dvd _ _ (fun i _ => prime_dvd_smallQuadraticModulus (p i))).trans + exact prod_dvd_prod_of_subset _ _ _ (by intro i hi; exact mem_compl.mpr (mem_sdiff.mp hi).2) + have h₂ := Nat.mul_dvd_mul_left (rootSquareModulus p R) h₁ + simpa only [rootSquareModulus,smallQuadraticModulus,prod_mul_prod_compl] using h₂ + +lemma kernelModelCoefficient_den_smallProduct (b : ℚ) + (hb : b.den∣∏i,primaryModulus b.den (p i)) (H : ℝ) + (htwo : ∀i,p i=2 → i∈R) + (hc : ∀i∈R,if p i=2 then c i=1 else c i≠0) + (hne : kernelModelCoefficient p R c H b≠0) : + b.den∣∏i,smallQuadraticModulus (p i) := by + rw [←primaryModelCoefficient_eq_kernelModel p R c hinj b hb H htwo] at hne + exact (primaryModelCoefficient_denominator p hinj b hb R c H htwo hc hne).trans + (root_active_div_smallProduct p R (primaryActive p b.den)) + +omit hinj in +instance smallProductNeZero : NeZero (∏i,smallQuadraticModulus (p i)) := + ⟨(prod_pos (fun i _ => smallQuadraticModulus_pos (Fact.out : (p i).Prime))).ne'⟩ + +lemma actualModelTransform_grid (H : ℝ) (L N : ℕ) (α : ℝ) + (hmodel : (rootSquareModulus p R:ℝ)*H≤L) + (hcover : ∀b : ℚ,b.den≤L → b.den∣∏i,primaryModulus b.den (p i)) + (htwo : ∀i,p i=2 → i∈R) + (hc : ∀i∈R,if p i=2 then c i=1 else c i≠0) : + actualModelTransform p R c H L N α= + ∑a : ZMod (∏i,smallQuadraticModulus (p i)), + kernelModelCoefficient p R c H (rationalGridPoint _ a)* + normalizedLinearSum N (α-rationalGridPoint _ a) := by + let : NeZero (∏i,smallQuadraticModulus (p i)) := + ⟨(prod_pos (fun i _ => smallQuadraticModulus_pos (Fact.out : (p i).Prime))).ne'⟩ + unfold actualModelTransform + rw [Finset.sum_coe_sort (boundedRationals L) (fun b : ℚ => + kernelModelCoefficient p R c H b*normalizedLinearSum N (α-b))] + apply bounded_sum_grid_of + · intro b hb hh + exact kernelModelCoefficient_den_smallProduct p hinj R c b + (hcover b ((mem_boundedRationals L b).mp hb).2.2) H htwo hc (left_ne_zero_of_mul hh) + · intro b hb hh + have hb' := smallProduct_primary_cover p hinj b ((mem_rationalGrid _ b).mp hb).2.2 + have hne := left_ne_zero_of_mul hh + rw [← primaryModelCoefficient_eq_kernelModel p R c hinj b hb' H htwo] at hne + have hd := (primaryModelCoefficient_denominator_le p hinj b hb' R c H htwo hc hne).trans hmodel + exact_mod_cast hd + +end GridModel + +end SquareDifference + +namespace SquareDifference + +open Finset + +section SmallCoordinates + +variable {I : Type*} [instFintypeI : Fintype I] [DecidableEq I] + (p : I → ℕ) [∀i, Fact (p i).Prime] (hinj : Function.Injective p) + +noncomputable def smallTupleEquiv : + ZMod (∏i,smallQuadraticModulus (p i)) ≃+* ∀i,ZMod (smallQuadraticModulus (p i)) := + ZMod.prodEquivPi _ (smallQuadraticModuli_pairwise p (fun _ => Fact.out) hinj) + +noncomputable def smallCoordinateChar (b : ℚ) + (hb : b.den∣∏i,smallQuadraticModulus (p i)) (i : I) : + AddChar (ZMod (smallQuadraticModulus (p i))) ℂ := + coordinateChar (((rationalChar b).compAddMonoidHom + (ZMod.castHom hb (ZMod b.den)).toAddMonoidHom).compAddMonoidHom + (smallTupleEquiv p hinj).symm.toAddMonoidHom) i + +lemma smallCoordinateChar_trivial (b : ℚ) + (hb : b.den∣∏i,smallQuadraticModulus (p i)) (i : I) (hi : ¬p i∣b.den) : + smallCoordinateChar p hinj b hb i=1 := by + apply coordinateChar_inflation_trivial + have hc := (Fact.out : (p i).Prime).coprime_iff_not_dvd.mpr hi + unfold smallQuadraticModulus + split_ifs with h2 + · simpa only [h2,show 2^3=8 by norm_num] using hc.pow_left 3 + · exact hc + +lemma smallCoordinateChar_primitive (b : ℚ) + (hb : b.den∣∏i,smallQuadraticModulus (p i)) (i : I) + (h2 : p i≠2) (hi : p i∣b.den) : + (smallCoordinateChar p hinj b hb i).IsPrimitive := by + apply coordinateChar_inflation_primitive _ hb _ _ (rationalChar_primitive b) + simpa only [smallQuadraticModulus,ite_eq_right h2] using hi + +variable (R : Finset I) (c : ∀i,ZMod (p i)) + +lemma smallCompleteLocal {I : Type*} + [Fintype I] + [DecidableEq I] + (p : I → ℕ) + [∀ (i : I), Fact (Nat.Prime (p i))] + (R : Finset I) + (c : (i : I) → ZMod (p i)) (htwo : ∀i,p i=2 → i∈R) + (hc : ∀i∈R,p i=2 → c i=1) (i : I) + (ψ : AddChar (ZMod (smallQuadraticModulus (p i))) ℂ) : + (𝔼 x : ZMod (smallQuadraticModulus (p i)), + localRootWeight p (fun i => smallQuadraticModulus (p i)) + (fun i => prime_dvd_smallQuadraticModulus (p i)) R c i x* + (1-localSieveWeight p (fun i => smallQuadraticModulus (p i)) + (fun i => prime_dvd_smallQuadraticModulus (p i)) R i x)*ψ (x^2))= + if i∈R then ψ (smallRootSquare (p i) (c i)) else unitQuadraticMean ψ := by + classical + by_cases hi : i∈R + · simp only [localRootWeight,localSieveWeight,ite_eq_left hi,sub_zero,mul_one] + exact small_root_quadratic (c i) (hc i hi) ψ + · simp only [localRootWeight,localSieveWeight,ite_eq_right hi,one_mul] + simp_rw [sub_mul,one_mul,expect_sub_distrib] + exact prime_unit_quadratic_of_eq (prime_dvd_smallQuadraticModulus (p i)) + (ite_eq_right (fun h => hi (htwo i h))) ψ + +lemma completeRationalCoefficient_small (b : ℚ) + (hb : b.den∣∏i,smallQuadraticModulus (p i)) + (htwo : ∀i,p i=2 → i∈R) (hc : ∀i∈R,p i=2 → c i=1) : + completeRationalCoefficient p R c b= + ∏i, if i∈R then smallCoordinateChar p hinj b hb i (smallRootSquare (p i) (c i)) + else unitQuadraticMean (smallCoordinateChar p hinj b hb i) := by + classical + trans periodicMean + (fun n => actualCompleteWeight p R c (n+1)*expPhase ((b:ℝ)*(n+1)^2)) + (∏i,smallQuadraticModulus (p i)) + · exact completeRationalCoefficient_eq p R c b _ + (NeZero.pos _) (fun i => (prime_dvd_smallQuadraticModulus (p i)).trans + (dvd_prod_of_mem _ (mem_univ i))) hb + · trans ∏i,(𝔼 x : ZMod (smallQuadraticModulus (p i)), + localRootWeight p (fun i => smallQuadraticModulus (p i)) + (fun i => prime_dvd_smallQuadraticModulus (p i)) R c i x* + (1-localSieveWeight p (fun i => smallQuadraticModulus (p i)) + (fun i => prime_dvd_smallQuadraticModulus (p i)) R i x)* + smallCoordinateChar p hinj b hb i (x^2)) + · exact periodicMean_crt_complete p (fun i => smallQuadraticModulus (p i)) + (fun i => prime_dvd_smallQuadraticModulus (p i)) R c (smallTupleEquiv p hinj) b hb + · apply prod_congr rfl + intro i _ + exact smallCompleteLocal p R c htwo hc i _ + +lemma kernelModelCoefficient_small (b : ℚ) + (hb : b.den∣∏i,smallQuadraticModulus (p i)) (H : ℝ) + (htwo : ∀i,p i=2 → i∈R) (hc : ∀i∈R,p i=2 → c i=1) : + kernelModelCoefficient p R c H b= + if ((∏i∈primaryActive p b.den\R,p i : ℕ):ℝ)≤H then + ∏i, if i∈R then smallCoordinateChar p hinj b hb i (smallRootSquare (p i) (c i)) + else unitQuadraticMean (smallCoordinateChar p hinj b hb i) + else 0 := by + unfold kernelModelCoefficient + rw [completeRationalCoefficient_small p hinj R c b hb htwo hc] + +end SmallCoordinates + +end SquareDifference + +open Filter + +open scoped Topology + +namespace SquareDifference + +lemma pow_le_pow_of_one_le (n : ℝ) (hn : 1≤n) {a b : ℝ} (h : a≤b) : n^a≤n^b := + Real.rpow_le_rpow_of_exponent_le hn h + +lemma kernel_rate_log (n T : ℝ) (hn : 1≤n) (hT : 0 (p i).Coprime (p j) := by + intro i j hij + exact ((Fact.out : (p i).Prime).coprime_iff_not_dvd.mpr + (fun h => hij (hinj ((Nat.prime_dvd_prime_iff_eq (Fact.out : (p i).Prime) (Fact.out : (p j).Prime)).mp h)))) + apply (hb p hp hinj t Q hs.2.1 (fun U hU => (mem_filter.mp (ht hU)).2) + L hs.1 hs.2.2.1 hs.2.2.2 f M hM hf r hr).trans + apply pow_le_pow_left₀ (by positivity) + exact mul_le_mul_of_nonneg_left + (Real.rpow_le_rpow (Nat.cast_nonneg _) (by exact_mod_cast hQN) hε.le) + (mul_nonneg hC.le hM) + +lemma fiber_transfer_algebra (l K H C t m q : ℝ) (d : ℕ) : + l^d*(K+(d:ℝ)*H*(C*t)^d)+(d:ℝ)*H*q*(C*m*t)^d= + l^d*K+(d:ℝ)*H*(C*t)^d*(l^d+q*m^d) := by + rw [show C*m*t=(C*t)*m by ring,mul_pow] + ring + +lemma uniform_actual_fiber_transfer (ε : ℝ) (hε : 0<ε) : + ∃C : ℝ,0 actualTruncatedLift p N Q (smallResidueInput M A s) (freezeCoordinates B z x))≤ + (((M*(∏j∈B,p j):ℕ):ℝ)^2*L/N)^(Fintype.card TupleVertex)*K+ + (Fintype.card TupleVertex:ℝ)*(H:ℝ)^(-(1:ℝ)/64)*(C*(N:ℝ)^ε)^(Fintype.card TupleVertex)* + ((((M*(∏j∈B,p j):ℕ):ℝ)^2*L/N)^(Fintype.card TupleVertex)+ + (∏j∈B,p j:ℝ)*(M:ℝ)^(Fintype.card TupleVertex)) := by + obtain ⟨C,hC,hb⟩ := uniform_partial_lift_moments ε hε + refine ⟨C,hC,?_⟩ + intro J _ _ p _ hinj hcond href M _ hM N Q H L Qc B s z hs hs' hQN hQcN hH hHQ hHQc hNL A hA hfree K hK hchild + have hp : Pairwise fun i j => (p i).Coprime (p j) := by + intro i j hij + exact ((Fact.out : (p i).Prime).coprime_iff_not_dvd.mpr + (fun h => hij (hinj ((Nat.prime_dvd_prime_iff_eq (Fact.out : (p i).Prime) (Fact.out : (p j).Prime)).mp h)))) + have hh := actual_set_fiber_transfer p hp M hM hcond href N Q H L Qc B s z + hH hHQ hHQc hs'.1 hNL A hA hfree K (C*M*(N:ℝ)^ε) (C*(N:ℝ)^ε) + hK (by positivity) (by positivity) + (fun t ht r hr => hb p hinj N Q N hs hQN _ M (Nat.cast_nonneg _) + (fun n _ => smallResidueInput_bound M A s n) t ht r hr) + (by + intro A' hA' t ht r hr + simpa only [mul_one] using hb p hinj L Qc N hs' hQcN (natIndicator A') 1 + (by norm_num) (fun n _ => natIndicator_bound A' n) t ht r hr) + hchild + exact hh.trans_eq (fiber_transfer_algebra _ _ _ _ _ _ _ _) + +end SquareDifference + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SquareDifference/WalshMoments.lean b/lean/OAI/Combinatorics/SquareDifference/WalshMoments.lean new file mode 100644 index 0000000000000000000000000000000000000000..fa15dc5e7f25e77d04e2533d1fae4e2866bb06d6 --- /dev/null +++ b/lean/OAI/Combinatorics/SquareDifference/WalshMoments.lean @@ -0,0 +1,517 @@ +import OAI.Combinatorics.SquareDifference.ProductBounds + +namespace OAI + +section +open Finset +open scoped BigOperators + +namespace LiftAnalysis + +open Finset + +open scoped BigOperators InnerProductSpace ComplexConjugate + +namespace SquareDifference + +lemma sum_range_two (n : ℕ) (f : ℕ → ℝ) : + (∑ k∈range (2*n), f k)=∑ k∈range n, (f (2*k)+f (2*k+1)) := by + induction n with + | zero => simp + | succ n ih => + rw [show 2*(n+1)=2*n+1+1 by omega, sum_range_succ, sum_range_succ, + ih, sum_range_succ] + ring + +lemma choose_le_two_pow (n k : ℕ) : n.choose k ≤ 2^n := by + by_cases h : k ≤ n + · rw [← Nat.sum_range_choose] + exact single_le_sum (fun _ _ => Nat.zero_le _) (mem_range.mpr (by omega)) + · rw [Nat.choose_eq_zero_of_lt (by omega)] + exact Nat.zero_le _ + +lemma even_sum_binomial (r : ℕ) (a b : ℝ) : + ((a+b)^(2*r)+(a-b)^(2*r))/2 = + ∑ k∈range (r+1), (↑((2*r).choose (2*k)) : ℝ)*(a^2)^(r-k)*(b^2)^k := by + have he (x : ℝ) : (a+x)^(2*r) = + ∑ i∈range (2*(r+1)), a^(2*r-i)*x^i*↑((2*r).choose i) := by + rw [show 2*(r+1)=(2*r+1)+1 by omega, sum_range_succ] + simp only [Nat.choose_eq_zero_of_lt (by omega : 2*r < 2*r+1), Nat.cast_zero, + mul_zero, add_zero] + calc + _ = (x+a)^(2*r) := by rw [add_comm] + _ = _ := add_pow x a (2*r) + _ = _ := sum_congr rfl fun i _ => by ring + rw [sub_eq_add_neg, he b, he (-b), ← sum_add_distrib, sum_range_two] + rw [sum_div] + apply sum_congr rfl + intro k hk + have hodd : (-b)^(2*k+1) = -(b^(2*k+1)) := by + have hv : (-b)^(2*k)=b^(2*k) := by rw [pow_mul, pow_mul, neg_sq] + rw [pow_succ, pow_succ, hv] + ring + have heven : (-b)^(2*k)=b^(2*k) := by rw [pow_mul, pow_mul, neg_sq] + have hpow : a^(2*r-2*k)=(a^2)^(r-k) := by + rw [← pow_mul, Nat.mul_sub_left_distrib] + rw [heven, hodd, hpow, pow_mul b 2 k] + ring + +lemma two_point_moment (r : ℕ) (_hr : 1 ≤ r) (a b : ℝ) : + ((a+b)^(2*r)+(a-b)^(2*r))/2 ≤ (a^2+(2:ℝ)^(2*r)*b^2)^r := by + rw [even_sum_binomial] + rw [add_comm (a^2), add_pow] + apply sum_le_sum + intro k hk + have hkr : k ≤ r := by simpa only [mem_range, Nat.lt_succ_iff] using hk + have hcoef : (↑((2*r).choose (2*k)) : ℝ) ≤ (2:ℝ)^(2*r*k)*↑(r.choose k) := by + by_cases hz : k=0 + · simp [hz] + · have hk1 : 1 ≤ k := by omega + have hb : (↑((2*r).choose (2*k)) : ℝ) ≤ (2:ℝ)^(2*r) := by + exact_mod_cast choose_le_two_pow (2*r) (2*k) + have hc : (1:ℝ) ≤ ↑(r.choose k) := by exact_mod_cast Nat.choose_pos hkr + have hp : (2:ℝ)^(2*r) ≤ (2:ℝ)^(2*r*k) := by + apply pow_le_pow_right₀ (by norm_num) + nlinarith + exact hb.trans (hp.trans (le_mul_of_one_le_right (by positivity) hc)) + have ha2 := sq_nonneg a + have hb2 := sq_nonneg b + calc + _ ≤ ((2:ℝ)^(2*r*k)*↑(r.choose k))*(a^2)^(r-k)*(b^2)^k := by gcongr + _ = _ := by rw [mul_pow, ← pow_mul]; ring + +lemma expect_pow_zero {X : Type*} [Fintype X] (f : X → ℝ) + (hf : ∀ x, 0 ≤ f x) (r : ℕ) (_hr : 1 ≤ r) + (h : (𝔼 x, f x^r) ≤ 0) : ∀ x, f x=0 := by + have hz : (𝔼 x, f x^r)=0 := le_antisymm h (expect_nonneg (fun x _ => pow_nonneg (hf x) _)) + have hh := (expect_eq_zero_iff_of_nonneg (fun x _ => pow_nonneg (hf x) r)).mp hz + intro x + by_contra hne + exact pow_ne_zero r hne (hh x (mem_univ x)) + +lemma expect_add_pow_le {X : Type*} [Fintype X] [Nonempty X] + (f g : X → ℝ) (hf : ∀ x, 0 ≤ f x) (hg : ∀ x, 0 ≤ g x) + (r : ℕ) (hr : 1 ≤ r) (A B : ℝ) (hA : 0 ≤ A) (hB : 0 ≤ B) + (ha : (𝔼 x, f x^r) ≤ A^r) (hb : (𝔼 x, g x^r) ≤ B^r) : + (𝔼 x, (f x+g x)^r) ≤ (A+B)^r := by + by_cases hAz : A=0 + · have hz : ∀ x, f x=0 := expect_pow_zero f hf r hr (by rw [hAz, zero_pow (by omega : r≠0)] at ha; exact ha) + simpa only [hz, hAz, zero_add] using hb + by_cases hBz : B=0 + · have hz : ∀ x, g x=0 := expect_pow_zero g hg r hr (by rw [hBz, zero_pow (by omega : r≠0)] at hb; exact hb) + simpa only [hz, hBz, add_zero] using ha + have hAp : 0 < A := lt_of_le_of_ne hA (Ne.symm hAz) + have hBp : 0 < B := lt_of_le_of_ne hB (Ne.symm hBz) + have hAB : 0 < A+B := add_pos hAp hBp + have hpoint (x : X) : ((f x+g x)/(A+B))^r ≤ + (A/(A+B))*(f x/A)^r+(B/(A+B))*(g x/B)^r := by + have hc := (convexOn_pow (𝕜 := ℝ) r).2 + (show f x/A∈Set.Ici 0 from div_nonneg (hf x) hA) + (show g x/B∈Set.Ici 0 from div_nonneg (hg x) hB) + (show 0 ≤ A/(A+B) from by positivity) (show 0 ≤ B/(A+B) from by positivity) + (show A/(A+B)+B/(A+B)=1 from by field_simp) + simp only [smul_eq_mul] at hc + have he : A/(A+B)*(f x/A)+B/(A+B)*(g x/B)=(f x+g x)/(A+B) := by field_simp + rwa [he] at hc + have hmean : (𝔼 x, ((f x+g x)/(A+B))^r) ≤ 1 := by + calc + _ ≤ (𝔼 x, (A/(A+B)*(f x/A)^r+B/(A+B)*(g x/B)^r)) := + expect_le_expect fun x _ => hpoint x + _ = A/(A+B)*((𝔼 x, f x^r)/A^r)+B/(A+B)*((𝔼 x, g x^r)/B^r) := by + simp only [expect_add_distrib, div_pow] + simp only [div_eq_mul_inv, ← mul_expect, ← expect_mul] + _ ≤ A/(A+B)*(A^r/A^r)+B/(A+B)*(B^r/B^r) := by gcongr + _ = 1 := by rw [div_self (pow_ne_zero _ hAz), div_self (pow_ne_zero _ hBz)]; field_simp + have he : (𝔼 x, ((f x+g x)/(A+B))^r)=(𝔼 x, (f x+g x)^r)/(A+B)^r := by + simp only [div_pow] + simp only [div_eq_mul_inv, ← expect_mul] + rw [he] at hmean + exact (div_le_one (pow_pos hAB _)).mp hmean + +lemma expect_update_bool {J : Type*} [Fintype J] [DecidableEq J] + (j : J) (f : (J → Bool) → ℝ) : + (𝔼 x : J → Bool, 𝔼 t : Bool, f (Function.update x j t))=𝔼 x, f x := by + let e : ((J → Bool) × Bool) ≃ ((J → Bool) × Bool) := + { toFun := fun a => (Function.update a.1 j a.2, a.1 j) + invFun := fun a => (Function.update a.1 j a.2, a.1 j) + left_inv := by rintro ⟨x,t⟩; simp + right_inv := by rintro ⟨x,t⟩; simp } + have he := Fintype.expect_equiv e + (fun a : (J → Bool) × Bool => f (Function.update a.1 j a.2)) + (fun a : (J → Bool) × Bool => f a.1) (fun _ => rfl) + rw [← univ_product_univ, expect_product, expect_product] at he + simpa only [Fintype.expect_const] using he + +lemma expect_bool (f : Bool → ℝ) : (𝔼 b, f b)=(f true+f false)/2 := by + simp [expect_eq_sum_div_card] + +def boolSign (b : Bool) : ℝ := if b then 1 else -1 + +noncomputable def walsh {J : Type*} [DecidableEq J] (s : Finset J) + (c : Finset J → ℝ) (x : J → Bool) : ℝ := + ∑ U∈s.powerset, c U*∏ j∈U, boolSign (x j) + +noncomputable def walshEnergy {J : Type*} [DecidableEq J] (s : Finset J) + (C : ℝ) (c : Finset J → ℝ) : ℝ := ∑ U∈s.powerset, C^U.card*(c U)^2 + +lemma walsh_update {J : Type*} [DecidableEq J] (s : Finset J) (c : Finset J → ℝ) + (x : J → Bool) (j : J) (hj : j∉s) (t : Bool) : + walsh s c (Function.update x j t)=walsh s c x := by + apply sum_congr rfl + intro U hU + congr 1 + apply prod_congr rfl + intro k hk + rw [Function.update_of_ne] + intro h + subst k + exact hj ((mem_powerset.mp hU) hk) + +lemma walsh_insert {J : Type*} [DecidableEq J] (s : Finset J) (c : Finset J → ℝ) + (x : J → Bool) (j : J) (hj : j∉s) : + walsh (insert j s) c x=walsh s c x+boolSign (x j)*walsh s (fun U => c (insert j U)) x := by + unfold walsh + rw [sum_powerset_insert hj, mul_sum] + congr 1 + apply sum_congr rfl + intro U hU + have hjU : j∉U := fun h => hj ((mem_powerset.mp hU) h) + rw [prod_insert hjU] + ring + +lemma walshEnergy_insert {J : Type*} [DecidableEq J] (s : Finset J) + (C : ℝ) (c : Finset J → ℝ) (j : J) (hj : j∉s) : + walshEnergy (insert j s) C c=walshEnergy s C c+C*walshEnergy s C (fun U => c (insert j U)) := by + unfold walshEnergy + rw [sum_powerset_insert hj, mul_sum] + congr 1 + apply sum_congr rfl + intro U hU + have hjU : j∉U := fun h => hj ((mem_powerset.mp hU) h) + rw [card_insert_of_notMem hjU, pow_succ] + ring + +lemma walshEnergy_nonneg {J : Type*} [DecidableEq J] (s : Finset J) + (C : ℝ) (hC : 0 ≤ C) (c : Finset J → ℝ) : 0 ≤ walshEnergy s C c := + sum_nonneg fun _ _ => mul_nonneg (pow_nonneg hC _) (sq_nonneg _) + +lemma walsh_hypercontractivity {J : Type*} [Fintype J] [DecidableEq J] + (s : Finset J) (c : Finset J → ℝ) (r : ℕ) (hr : 1 ≤ r) : + (𝔼 x : J → Bool, (walsh s c x)^(2*r)) ≤ (walshEnergy s ((2:ℝ)^(2*r)) c)^r := by + induction s using Finset.induction_on generalizing c with + | empty => simp [walsh, walshEnergy, pow_mul] + | @insert j s hj ih => + let C : ℝ := (2:ℝ)^(2*r) + let a := walsh s c + let b := walsh s (fun U => c (insert j U)) + let A := walshEnergy s C c + let B := walshEnergy s C (fun U => c (insert j U)) + have hC : 0 ≤ C := by positivity + have hA : 0 ≤ A := walshEnergy_nonneg _ _ hC _ + have hB : 0 ≤ B := walshEnergy_nonneg _ _ hC _ + have ha : (𝔼 x, (a x^2)^r) ≤ A^r := by + simpa only [a, A, C, ← pow_mul] using ih c + have hb : (𝔼 x, (C*b x^2)^r) ≤ (C*B)^r := by + simp only [mul_pow, ← mul_expect] + exact mul_le_mul_of_nonneg_left (by simpa only [b, B, C, ← pow_mul] using ih (fun U => c (insert j U))) (by positivity) + have hm := expect_add_pow_le (fun x => a x^2) (fun x => C*b x^2) + (fun x => sq_nonneg _) (fun x => mul_nonneg hC (sq_nonneg _)) r hr A (C*B) + hA (mul_nonneg hC hB) ha hb + rw [walshEnergy_insert s _ c j hj] + change _ ≤ (A+C*B)^r + apply le_trans _ hm + rw [← expect_update_bool j] + apply expect_le_expect + intro x _ + rw [expect_bool] + simp only [walsh_insert s c _ j hj, walsh_update s c x j hj, + walsh_update s (fun U => c (insert j U)) x j hj, Function.update_self] + simp only [boolSign, Bool.false_eq_true, ite_false, ite_true, one_mul, neg_one_mul] + simp only [← sub_eq_add_neg] + exact two_point_moment r hr (a x) (b x) + +lemma expect_update_dep {J : Type*} [Fintype J] [DecidableEq J] + {X : J → Type*} [∀ j, Fintype (X j)] [∀ j, Nonempty (X j)] + (j : J) (f : (∀ j, X j) → ℝ) : + (𝔼 x : ∀ j, X j, 𝔼 t : X j, f (Function.update x j t))=𝔼 x, f x := by + let e : ((∀ j, X j) × X j) ≃ ((∀ j, X j) × X j) := + { toFun := fun a => (Function.update a.1 j a.2, a.1 j) + invFun := fun a => (Function.update a.1 j a.2, a.1 j) + left_inv := by rintro ⟨x,t⟩; simp + right_inv := by rintro ⟨x,t⟩; simp } + have he := Fintype.expect_equiv e + (fun a : (∀ j, X j) × X j => f (Function.update a.1 j a.2)) + (fun a : (∀ j, X j) × X j => f a.1) (fun _ => rfl) + rw [← univ_product_univ, expect_product, expect_product] at he + simpa only [Fintype.expect_const] using he + +def patch {J : Type*} [DecidableEq J] {X : J → Type*} + (s : Finset J) (x y : ∀ j, X j) (j : J) : X j := if j∈s then y j else x j + +lemma patch_empty {J : Type*} [DecidableEq J] {X : J → Type*} (x y : ∀ j, X j) : + patch ∅ x y=x := by ext j; simp [patch] + +lemma patch_univ {J : Type*} [Fintype J] [DecidableEq J] + {X : J → Type*} (x y : ∀ j, X j) : patch univ x y=y := by ext j; simp [patch] + +lemma patch_insert_update {J : Type*} [DecidableEq J] {X : J → Type*} + (s : Finset J) (j : J) (_hj : j∉s) (x y : ∀ j, X j) (t : X j) : + patch (insert j s) x (Function.update y j t)=Function.update (patch s x y) j t := by + ext k + by_cases hk : k=j + · subst k; simp [patch] + · simp [patch, hk] + +def ExactSupport {J : Type*} [DecidableEq J] + {X : J → Type*} [∀ j, Fintype (X j)] (U : Finset J) + (f : (∀ j, X j) → ℝ) : Prop := + (∀ j∈U, ∀ x, (𝔼 t : X j, f (Function.update x j t))=0) ∧ + (∀ j∉U, ∀ x t, f (Function.update x j t)=f x) + +lemma expect_pow_le {X : Type*} [Fintype X] [Nonempty X] + (f : X → ℝ) (hf : ∀ x, 0 ≤ f x) (r : ℕ) : + (𝔼 x, f x)^r ≤ 𝔼 x, f x^r := by + have hn : (Fintype.card X : ℝ) ≠ 0 := Nat.cast_ne_zero.mpr Fintype.card_ne_zero + have hh := (convexOn_pow (𝕜 := ℝ) r).map_sum_le + (t := univ) (w := fun _ : X => (Fintype.card X : ℝ)⁻¹) + (p := f) (fun _ _ => by positivity) + (by simp [hn]) (fun x _ => hf x) + simpa only [smul_eq_mul, ← mul_sum, expect_eq_sum_div_card, card_univ, + div_eq_inv_mul] using hh + +lemma expect_even_pow_le {X : Type*} [Fintype X] [Nonempty X] + (f : X → ℝ) (r : ℕ) : (𝔼 x, f x)^(2*r) ≤ 𝔼 x, (f x)^(2*r) := by + have hc := expect_mul_sq_le_sq_mul_sq univ f (fun _ => (1:ℝ)) + simp only [mul_one, one_pow, Fintype.expect_const] at hc + rw [pow_mul] + apply (pow_le_pow_left₀ (sq_nonneg _) hc r).trans + simpa only [← pow_mul] using expect_pow_le (fun x => f x^2) (fun x => sq_nonneg _) r + +lemma exactSupport_congr {J : Type*} [Fintype J] [DecidableEq J] + {X : J → Type*} [∀ j, Fintype (X j)] (U : Finset J) + (f : (∀ j, X j) → ℝ) (hf : ExactSupport U f) + (x y : ∀ j, X j) (hxy : ∀ j∈U, x j=y j) : f x=f y := by + have hh (s : Finset J) : f (patch s x y)=f x := by + induction s using Finset.induction_on with + | empty => rw [patch_empty] + | @insert j s hj ih => + have he : patch (insert j s) x y=Function.update (patch s x y) j (y j) := by + ext a; by_cases ha : a=j + · subst a; simp [patch] + · simp [patch, ha] + rw [he] + by_cases hjU : j∈U + · have hxj : (patch s x y) j = y j := by simp [patch, hj, hxy j hjU] + rw [← hxj, Function.update_eq_self, ih] + · rw [hf.2 j hjU, ih] + simpa only [patch_univ] using (hh univ).symm + +def hybrid {J : Type*} {X : J → Type*} (b : J → Bool) (x y : ∀j, X j) (j : J) : X j := + if b j then x j else y j + +def boolMul (a b : Bool) : Bool := if a then b else !b + +lemma boolMul_symm (a b : Bool) : boolMul a b=boolMul b a := by cases a <;> cases b <;> rfl + +lemma boolMul_self (a b : Bool) : boolMul a (boolMul a b)=b := by cases a <;> cases b <;> rfl + +lemma boolSign_mul (a b : Bool) : boolSign (boolMul a b)=boolSign a*boolSign b := by + cases a <;> cases b <;> norm_num [boolMul, boolSign] + +lemma hybrid_hybrid {J : Type*} {X : J → Type*} (b e : J → Bool) (x y : ∀j, X j) : + hybrid b (hybrid e x y) (hybrid e y x)=hybrid (fun j => boolMul (e j) (b j)) x y := by + ext j + cases hb : b j <;> cases he : e j <;> simp [hybrid, boolMul, hb, he] + +def copySwapEquiv {J : Type*} {X : J → Type*} (e : J → Bool) : + ((∀j, X j) × (∀j, X j)) ≃ ((∀j, X j) × (∀j, X j)) where + toFun a := (hybrid e a.1 a.2, hybrid e a.2 a.1) + invFun a := (hybrid e a.1 a.2, hybrid e a.2 a.1) + left_inv a := by + apply Prod.ext <;> funext j <;> cases he : e j <;> simp [hybrid, he] + right_inv a := by + apply Prod.ext <;> funext j <;> cases he : e j <;> simp [hybrid, he] + +lemma expect_copySwap {J : Type*} [Fintype J] [DecidableEq J] {X : J → Type*} [∀j, Fintype (X j)] + (e : J → Bool) (F : (∀j, X j) → (∀j, X j) → ℝ) : + (𝔼 x, 𝔼 y, F (hybrid e x y) (hybrid e y x))=𝔼 x, 𝔼 y, F x y := by + have hh := Fintype.expect_equiv (copySwapEquiv (X:=X) e) + (fun a => F (hybrid e a.1 a.2) (hybrid e a.2 a.1)) + (fun a => F a.1 a.2) (fun _ => rfl) + simpa only [← univ_product_univ, expect_product] using hh + +lemma expect_hybrid {J : Type*} [Fintype J] [DecidableEq J] {X : J → Type*} + [∀j, Fintype (X j)] [∀j, Nonempty (X j)] + (e : J → Bool) (F : (∀j, X j) → ℝ) : + (𝔼 x, 𝔼 y, F (hybrid e x y))=𝔼 x, F x := by + simpa only [Fintype.expect_const] using expect_copySwap e (fun x _ => F x) + +def boolMulEquiv {J : Type*} (e : J → Bool) : (J → Bool) ≃ (J → Bool) where + toFun b j := boolMul (e j) (b j) + invFun b j := boolMul (e j) (b j) + left_inv b := by funext j; exact boolMul_self _ _ + right_inv b := by funext j; exact boolMul_self _ _ + +noncomputable def boolChar {J : Type*} (U : Finset J) (b : J → Bool) : ℝ := + ∏ j∈U, boolSign (b j) + +lemma boolChar_mul {J : Type*} (U : Finset J) (e b : J → Bool) : + boolChar U (fun j => boolMul (e j) (b j))=boolChar U e*boolChar U b := by + simp only [boolChar, boolSign_mul, prod_mul_distrib] + +lemma boolChar_sq {J : Type*} (U : Finset J) (b : J → Bool) : boolChar U b^2=1 := by + have he j : boolSign (b j)^2=1 := by cases hb : b j <;> norm_num [boolSign, hb] + simp only [boolChar, ← prod_pow, he, prod_const_one] + +lemma exactSupport_hybrid_expect {J : Type*} [Fintype J] [DecidableEq J] + {X : J → Type*} [∀j, Fintype (X j)] [∀j, Nonempty (X j)] + (U : Finset J) (f : (∀j, X j) → ℝ) (hf : ExactSupport U f) + (x : ∀j, X j) (b : J → Bool) : + (𝔼 y, f (hybrid b x y))=(if ∀ j∈U, b j=true then 1 else (0:ℝ))*f x := by + classical + by_cases hb : ∀j∈U, b j=true + · rw [ite_eq_left hb, one_mul] + have he y : f (hybrid b x y)=f x := exactSupport_congr U f hf _ _ + (fun j hj => by simp [hybrid, hb j hj]) + simp only [he, Fintype.expect_const] + · rw [ite_eq_right hb, zero_mul] + push Not at hb + obtain ⟨j,hj,hb⟩ := hb + have hfalse : b j=false := by cases h : b j <;> simp_all + rw [← expect_update_dep j] + have he (y : ∀j, X j) (t : X j) : + hybrid b x (Function.update y j t)=Function.update (hybrid b x y) j t := by + ext a + by_cases ha : a=j + · subst a; simp [hybrid, hfalse] + · simp [hybrid, Function.update_of_ne ha] + simp only [he, hf.1 j hj, Fintype.expect_const] + +lemma expect_prod_pi {J : Type*} [Fintype J] [DecidableEq J] + {X : J → Type*} [∀ j, Fintype (X j)] (f : ∀ j, X j → ℝ) : + (𝔼 x : ∀ j, X j, ∏ j, f j (x j))=∏ j, (𝔼 t : X j, f j t) := by + simp only [expect_eq_sum_div_card, card_univ, prod_div_distrib, + Fintype.card_pi, Nat.cast_prod] + rw [Fintype.prod_sum] + +lemma expect_prod_pi_finset {J : Type*} [Fintype J] [DecidableEq J] + {X : J → Type*} [∀ j, Fintype (X j)] [∀j, Nonempty (X j)] + (U : Finset J) (f : ∀ j, X j → ℝ) : + (𝔼 x : ∀j, X j, ∏ j∈U, f j (x j))=∏ j∈U, (𝔼 t : X j, f j t) := by + have he := expect_prod_pi (fun j (t : X j) => if j∈U then f j t else 1) + simp only [prod_ite_mem, univ_inter] at he + have hp j : (𝔼 t : X j, if j∈U then f j t else 1)= + if j∈U then (𝔼 t : X j, f j t) else 1 := by + by_cases hj : j∈U <;> simp [hj] + simpa only [hp, prod_ite_mem, univ_inter] using he + +lemma bool_indicator_char {J : Type*} [Fintype J] [DecidableEq J] + (U : Finset J) : + (𝔼 b : J → Bool, (if ∀j∈U, b j=true then 1 else (0:ℝ))*boolChar U b)=(1/2:ℝ)^U.card := by + classical + have he (b : J → Bool) : + (if ∀j∈U, b j=true then 1 else (0:ℝ))*boolChar U b= + ∏j∈U, (if b j then (1:ℝ) else 0) := by + by_cases hb : ∀j∈U, b j=true + · simp only [ite_eq_left hb, one_mul, boolChar] + apply prod_congr rfl + intro j hj + simp [hb j hj, boolSign] + · rw [ite_eq_right hb, zero_mul] + push Not at hb + obtain ⟨j,hj,hb⟩ := hb + symm + apply prod_eq_zero hj + cases h : b j <;> simp_all + simp only [he] + rw [expect_prod_pi_finset U (fun _ (b : Bool) => if b then (1:ℝ) else 0)] + simp + +noncomputable def copyDifference {J : Type*} [Fintype J] [DecidableEq J] (U : Finset J) + {X : J → Type*} (f : (∀j, X j) → ℝ) (x y : ∀j, X j) : ℝ := + (2:ℝ)^U.card*(𝔼 b : J → Bool, f (hybrid b x y)*boolChar U b) + +lemma copyDifference_mean {J : Type*} [Fintype J] [DecidableEq J] + {X : J → Type*} [∀j, Fintype (X j)] [∀j, Nonempty (X j)] + (U : Finset J) (f : (∀j, X j) → ℝ) (hf : ExactSupport U f) (x : ∀j, X j) : + (𝔼 y, copyDifference U f x y)=f x := by + unfold copyDifference + rw [← mul_expect, expect_comm] + simp only [← expect_mul, exactSupport_hybrid_expect U f hf] + have he b : (if ∀j∈U, b j=true then 1 else (0:ℝ))*f x*boolChar U b= + ((if ∀j∈U, b j=true then 1 else (0:ℝ))*boolChar U b)*f x := by ring + simp only [he, ← expect_mul, bool_indicator_char] + rw [← mul_assoc, ← mul_pow] + norm_num + +lemma copyDifference_swap {J : Type*} [Fintype J] [DecidableEq J] {X : J → Type*} + (U : Finset J) (f : (∀j, X j) → ℝ) (x y : ∀j, X j) (e : J → Bool) : + copyDifference U f (hybrid e x y) (hybrid e y x)=boolChar U e*copyDifference U f x y := by + unfold copyDifference + simp only [hybrid_hybrid] + have he := Fintype.expect_equiv (boolMulEquiv e) + (fun b => f (hybrid (fun j => boolMul (e j) (b j)) x y)*boolChar U b) + (fun b => f (hybrid b x y)*boolChar U (fun j => boolMul (e j) (b j))) + (fun b => by simp only [boolMulEquiv, Equiv.coe_fn_mk, boolMul_self]) + rw [he] + simp only [boolChar_mul, ← mul_left_comm (boolChar U e), ← mul_expect] + +lemma copyDifference_square {J : Type*} [Fintype J] [DecidableEq J] {X : J → Type*} + (U : Finset J) (f : (∀j, X j) → ℝ) (x y : ∀j, X j) : + (copyDifference U f x y)^2 ≤ (4:ℝ)^U.card*(𝔼 b : J → Bool, f (hybrid b x y)^2) := by + have hc := expect_mul_sq_le_sq_mul_sq univ (fun b => f (hybrid b x y)) (boolChar U) + simp only [boolChar_sq, Fintype.expect_const, mul_one] at hc + unfold copyDifference + rw [mul_pow, pow_right_comm, show (2:ℝ)^2=4 by norm_num] + exact mul_le_mul_of_nonneg_left hc (by positivity) + +lemma sum_powerset_family {J : Type*} [Fintype J] [DecidableEq J] + (F : Finset (Finset J)) (a : Finset J → ℝ) : + (∑U∈(univ : Finset J).powerset, if U∈F then a U else 0)=∑U∈F, a U := by + classical + symm + calc + _ = ∑U∈F, if U∈F then a U else 0 := by + apply sum_congr rfl; intro U hU; rw [ite_eq_left hU] + _ = _ := sum_subset (fun U _ => mem_powerset.mpr (subset_univ U)) + (fun U _ hU => ite_eq_right hU) + +lemma walsh_family {J : Type*} [Fintype J] [DecidableEq J] + (F : Finset (Finset J)) (a : Finset J → ℝ) (e : J → Bool) : + walsh univ (fun U => if U∈F then a U else 0) e=∑U∈F, a U*boolChar U e := by + unfold walsh boolChar + simp only [ite_mul, zero_mul] + exact sum_powerset_family _ _ + +lemma walshEnergy_family {J : Type*} [Fintype J] [DecidableEq J] + (F : Finset (Finset J)) (a : Finset J → ℝ) (C : ℝ) : + walshEnergy univ C (fun U => if U∈F then a U else 0)=∑U∈F, C^U.card*(a U)^2 := by + unfold walshEnergy + simp only [ite_pow, zero_pow (by omega : (2:ℕ)≠0), mul_ite, mul_zero] + exact sum_powerset_family _ _ + +lemma difference_energy_bound {J : Type*} [Fintype J] [DecidableEq J] + {X : J → Type*} (F : Finset (Finset J)) (f : Finset J → (∀j, X j) → ℝ) + (k : ℕ) (hk : ∀U∈F, U.card ≤ k) (C : ℝ) (hC : 1 ≤ C) (x y : ∀j, X j) : + walshEnergy univ C (fun U => if U∈F then copyDifference U (f U) x y else 0) ≤ + (4*C)^k*(𝔼 e : J → Bool, ∑U∈F, f U (hybrid e x y)^2) := by + rw [walshEnergy_family] + calc + _ ≤ ∑U∈F, (4*C)^k*(𝔼 e : J → Bool, f U (hybrid e x y)^2) := by + apply sum_le_sum + intro U hU + calc + _ ≤ C^U.card*((4:ℝ)^U.card*(𝔼 e : J → Bool, f U (hybrid e x y)^2)) := + mul_le_mul_of_nonneg_left (copyDifference_square U (f U) x y) (by positivity) + _ = (4*C)^U.card*(𝔼 e : J → Bool, f U (hybrid e x y)^2) := by + rw [mul_pow]; ring + _ ≤ _ := mul_le_mul_of_nonneg_right + (pow_le_pow_right₀ (by linarith : 1 ≤ 4*C) (hk U hU)) + (expect_nonneg fun _ _ => sq_nonneg _) + _ = _ := by rw [← mul_sum, expect_sum_comm] + +end SquareDifference +end LiftAnalysis +end + +end OAI diff --git a/lean/OAI/Combinatorics/SquareDifference/WordReflection.lean b/lean/OAI/Combinatorics/SquareDifference/WordReflection.lean new file mode 100644 index 0000000000000000000000000000000000000000..9ac251e5ba5dd55f567cdf5bc0dd89893732d048 --- /dev/null +++ b/lean/OAI/Combinatorics/SquareDifference/WordReflection.lean @@ -0,0 +1,511 @@ +import OAI.Combinatorics.SquareDifference.MarkedTuples + +namespace OAI + +section +open Finset +open scoped BigOperators +namespace SquareDifference +open scoped Classical + +lemma prod_word_fold {B X : Type*} [Fintype B] [DecidableEq B] + {h : ℕ} (b : B) {α β : Fin h} (hne : α ≠ β) + (a : WordVertex B h → X → ℝ) (z : WordVertex B h → X) : + (∏ v, (a ∘ foldWord b α β) v (z v)) = + halfProduct b α β a (fun v => z v.1) * + halfProduct b α β a (fun v => z (reflect b α β v.1)) := by + classical + rw [prod_word_split b hne] + simp only [Function.comp_apply, foldWord_half, foldWord_reflect_half b hne, halfProduct] + +lemma prod_word_opposite_fold {B X : Type*} [Fintype B] [DecidableEq B] + {h : ℕ} (b : B) {α β : Fin h} (hne : α ≠ β) + (a : WordVertex B h → X → ℝ) (z : WordVertex B h → X) : + (∏ v, (a ∘ foldWord b β α) v (z v)) = + halfProduct b α β (a ∘ reflect b α β) (fun v => z v.1) * + halfProduct b α β (a ∘ reflect b α β) (fun v => z (reflect b α β v.1)) := by + classical + rw [prod_word_split b hne] + simp only [Function.comp_apply, foldWord_opposite_half, foldWord_opposite_reflect_half, + halfProduct] + +lemma wordIntegral_folding {B X : Type*} [Fintype B] [DecidableEq B] {h : ℕ} + (L : ((WordVertex B h → X) → ℝ) →ₗ[ℝ] ℝ) + (b : B) {α β : Fin h} (hne : α ≠ β) + (hsym : ∀ F G : (CutHalf b α β → X) → ℝ, + L (fun z => F (fun v => z v.1) * G (fun v => z (reflect b α β v.1))) = + L (fun z => G (fun v => z v.1) * F (fun v => z (reflect b α β v.1)))) + (hpos : ∀ F : (CutHalf b α β → X) → ℝ, + 0 ≤ L (fun z => F (fun v => z v.1) * F (fun v => z (reflect b α β v.1)))) + (a : WordVertex B h → X → ℝ) : + |multilinearIntegral L a|^2 ≤ + multilinearIntegral L (a ∘ foldWord b α β) * + multilinearIntegral L (a ∘ foldWord b β α) ∧ + 0 ≤ multilinearIntegral L (a ∘ foldWord b α β) := by + have hsplit : multilinearIntegral L a = + L (fun z => halfProduct b α β a (fun v => z v.1) * + halfProduct b α β (a ∘ reflect b α β) (fun v => z (reflect b α β v.1))) := by + unfold multilinearIntegral + apply congrArg L + funext z + exact prod_word_split b hne (fun v => a v (z v)) + simp only [multilinearIntegral, prod_word_fold b hne, prod_word_opposite_fold b hne] + constructor + · have hcs := cut_cauchy_schwarz L (fun z v => z v.1) + (fun z v => z (reflect b α β v.1)) hsym hpos + (halfProduct b α β a) (halfProduct b α β (a ∘ reflect b α β)) + rw [← hsplit] at hcs + exact hcs + · exact hpos _ + +lemma word_diagonal_nonneg {B X : Type*} [Fintype B] [DecidableEq B] {h : ℕ} + (L : ((WordVertex B h → X) → ℝ) →ₗ[ℝ] ℝ) + (b : B) {α β : Fin h} (hne : α ≠ β) + (hpos : ∀ F : (CutHalf b α β → X) → ℝ, + 0 ≤ L (fun z => F (fun v => z v.1) * F (fun v => z (reflect b α β v.1)))) + (g : X → ℝ) : 0 ≤ diagonalIntegral L g := by + have hf : (fun _ : WordVertex B h => g) ∘ foldWord b α β = fun _ => g := rfl + unfold diagonalIntegral multilinearIntegral + rw [← hf] + simp_rw [prod_word_fold b hne] + exact hpos _ + +lemma word_signed_holder {B X : Type*} [Fintype B] [DecidableEq B] {h : ℕ} + (L : ((WordVertex B h → X) → ℝ) →ₗ[ℝ] ℝ) + (b₀ : B) {α₀ β₀ : Fin h} (hne₀ : α₀ ≠ β₀) + (hsym : ∀ b α β, ∀ F G : (CutHalf b α β → X) → ℝ, + L (fun z => F (fun v => z v.1) * G (fun v => z (reflect b α β v.1))) = + L (fun z => G (fun v => z v.1) * F (fun v => z (reflect b α β v.1)))) + (hpos : ∀ b α β, α ≠ β → ∀ F : (CutHalf b α β → X) → ℝ, + 0 ≤ L (fun z => F (fun v => z v.1) * F (fun v => z (reflect b α β v.1)))) + (a : WordVertex B h → X → ℝ) : + |multilinearIntegral L a| ≤ + ∏ v, (diagonalIntegral L (a v))^((1 : ℝ)/(Fintype.card (WordVertex B h) : ℝ)) := by + classical + have hd := word_diagonal_nonneg L b₀ hne₀ (hpos b₀ α₀ β₀ hne₀) + apply holder_of_finite_maximum L hd ?_ a + intro a + obtain ⟨i, hi⟩ := word_folding_maximum + (fun r : WordVertex B h → WordVertex B h => multilinearIntegral L (a ∘ r)) + (fun b α β hne r => (wordIntegral_folding L b hne (hsym b α β) + (hpos b α β hne) (a ∘ r)).1) + (fun b α β hne r => (wordIntegral_folding L b hne (hsym b α β) + (hpos b α β hne) (a ∘ r)).2) + refine ⟨i, ?_⟩ + have hh := hi id + change |multilinearIntegral L a| ≤ |diagonalIntegral L (a i)| at hh + rwa [abs_of_nonneg (hd (a i))] at hh + +lemma tupleLaw_diagonal_nonneg {p : ℕ} [Fact p.Prime] + (hp : tupleReflectionThreshold ≤ (p : ℝ)) (g : ZMod p → ℝ) : + 0 ≤ diagonalIntegral tupleLaw g := by + exact word_diagonal_nonneg tupleLaw (⟨0, by decide⟩ : Fin tupleBlocks) + (show (⟨0, by decide⟩ : Fin tupleH) ≠ ⟨1, by decide⟩ by decide) + (tupleLaw_reflection_positive hp (⟨0, by decide⟩ : Fin tupleBlocks) (by decide)) g + +lemma tupleLaw_signed_holder {p : ℕ} [Fact p.Prime] + (hp : tupleReflectionThreshold ≤ (p : ℝ)) (a : TupleVertex → ZMod p → ℝ) : + |multilinearIntegral tupleLaw a| ≤ + ∏ v, (diagonalIntegral tupleLaw (a v))^((1 : ℝ)/(Fintype.card TupleVertex : ℝ)) := by + exact word_signed_holder tupleLaw (⟨0, by decide⟩ : Fin tupleBlocks) + (show (⟨0, by decide⟩ : Fin tupleH) ≠ ⟨1, by decide⟩ by decide) tupleLaw_symmetric + (fun b _α _β hne => tupleLaw_reflection_positive hp b hne) a + +lemma multilinearIntegral_sum {V X I : Type*} [Fintype V] [DecidableEq V] [Fintype I] + (L : ((V → X) → ℝ) →ₗ[ℝ] ℝ) (a : V → I → X → ℝ) : + multilinearIntegral L (fun v x => ∑ i, a v i x) = + ∑ r : V → I, multilinearIntegral L (fun v => a v (r v)) := by + classical + unfold multilinearIntegral + rw [← map_sum] + apply congrArg L + funext z + simp only [Finset.sum_apply] + exact Fintype.prod_sum fun v i => a v i (z v) + +lemma diagonalIntegral_smul {V X : Type*} [Fintype V] + (L : ((V → X) → ℝ) →ₗ[ℝ] ℝ) (c : ℝ) (f : X → ℝ) : + diagonalIntegral L (c • f) = c^(Fintype.card V) * diagonalIntegral L f := by + unfold diagonalIntegral multilinearIntegral + simp only [Pi.smul_apply, smul_eq_mul, prod_mul_distrib, prod_const, card_univ] + exact map_smul L (c^Fintype.card V) (fun z => ∏ _v, f (z _v)) + +noncomputable def diagonalRoot {V X : Type*} [Fintype V] + (L : ((V → X) → ℝ) →ₗ[ℝ] ℝ) (g : X → ℝ) : ℝ := + (diagonalIntegral L g)^((1 : ℝ)/(Fintype.card V : ℝ)) + +lemma diagonalRoot_nonneg {V X : Type*} [Fintype V] + (L : ((V → X) → ℝ) →ₗ[ℝ] ℝ) + (hdiag : ∀ g, 0 ≤ diagonalIntegral L g) (g : X → ℝ) : + 0 ≤ diagonalRoot L g := Real.rpow_nonneg (hdiag g) _ + +lemma diagonalRoot_pow {V X : Type*} [Fintype V] [Nonempty V] + (L : ((V → X) → ℝ) →ₗ[ℝ] ℝ) + (hdiag : ∀ g, 0 ≤ diagonalIntegral L g) (g : X → ℝ) : + (diagonalRoot L g)^(Fintype.card V) = diagonalIntegral L g := by + unfold diagonalRoot + rw [← Real.rpow_mul_natCast (hdiag g)] + rw [one_div_mul_cancel (Nat.cast_ne_zero.mpr Fintype.card_ne_zero), Real.rpow_one] + +lemma diagonalRoot_smul {V X : Type*} [Fintype V] [Nonempty V] + (heven : Even (Fintype.card V)) + (L : ((V → X) → ℝ) →ₗ[ℝ] ℝ) + (hdiag : ∀ g, 0 ≤ diagonalIntegral L g) (c : ℝ) (g : X → ℝ) : + diagonalRoot L (c • g) = |c| * diagonalRoot L g := by + unfold diagonalRoot + rw [diagonalIntegral_smul] + rw [← heven.pow_abs c, Real.mul_rpow (pow_nonneg (abs_nonneg c) _) (hdiag g)] + congr 1 + rw [← Real.rpow_natCast_mul (abs_nonneg c)] + rw [mul_one_div_cancel (Nat.cast_ne_zero.mpr Fintype.card_ne_zero), Real.rpow_one] + +lemma diagonalIntegral_add_le {V X : Type*} [Fintype V] + (L : ((V → X) → ℝ) →ₗ[ℝ] ℝ) + (hholder : ∀ a : V → X → ℝ, + |multilinearIntegral L a| ≤ ∏ v, diagonalRoot L (a v)) + (f g : X → ℝ) : + diagonalIntegral L (f+g) ≤ (diagonalRoot L f + diagonalRoot L g)^(Fintype.card V) := by + classical + let a (v : V) (i : Bool) : X → ℝ := if i then g else f + have he (x : X) (v : V) : ∑ i, a v i x = (f+g) x := by simp [a, add_comm] + have heq : diagonalIntegral L (f+g) = + ∑ r : V → Bool, multilinearIntegral L (fun v => a v (r v)) := by + simpa only [he, diagonalIntegral] using multilinearIntegral_sum L a + rw [heq] + calc + _ ≤ ∑ r : V → Bool, ∏ v, diagonalRoot L (a v (r v)) := by + apply sum_le_sum + intro r _ + exact (le_abs_self _).trans (hholder _) + _ = ∏ v : V, ∑ i : Bool, diagonalRoot L (a v i) := (Fintype.prod_sum (fun v i => diagonalRoot L (a v i))).symm + _ = _ := by simp [a, add_comm] + +lemma diagonalRoot_add_le {V X : Type*} [Fintype V] [Nonempty V] + (L : ((V → X) → ℝ) →ₗ[ℝ] ℝ) + (hdiag : ∀ g, 0 ≤ diagonalIntegral L g) + (hholder : ∀ a : V → X → ℝ, + |multilinearIntegral L a| ≤ ∏ v, diagonalRoot L (a v)) + (f g : X → ℝ) : diagonalRoot L (f+g) ≤ diagonalRoot L f + diagonalRoot L g := by + have h := Real.rpow_le_rpow (hdiag (f+g)) (diagonalIntegral_add_le L hholder f g) + (div_nonneg (by norm_num : (0 : ℝ) ≤ 1) (Nat.cast_nonneg (Fintype.card V))) + change diagonalRoot L (f+g) ≤ _ at h + have hn := add_nonneg (diagonalRoot_nonneg L hdiag f) (diagonalRoot_nonneg L hdiag g) + rw [← Real.rpow_natCast_mul hn] at h + rwa [mul_one_div_cancel (Nat.cast_ne_zero.mpr Fintype.card_ne_zero), Real.rpow_one] at h + +noncomputable def functionalSeminorm {V X : Type*} [Fintype V] [Nonempty V] + (heven : Even (Fintype.card V)) + (L : ((V → X) → ℝ) →ₗ[ℝ] ℝ) + (hdiag : ∀ g, 0 ≤ diagonalIntegral L g) + (hholder : ∀ a : V → X → ℝ, + |multilinearIntegral L a| ≤ ∏ v, diagonalRoot L (a v)) : Seminorm ℝ (X → ℝ) := + Seminorm.of (diagonalRoot L) (diagonalRoot_add_le L hdiag hholder) + (fun c g => by simpa only [Real.norm_eq_abs] using diagonalRoot_smul heven L hdiag c g) + +noncomputable def cutKernel {Ω I : Type*} [DecidableEq I] + (L : (Ω → ℝ) →ₗ[ℝ] ℝ) (left right : Ω → I) : Matrix I I ℝ := + fun x y => L (fun z => if left z = x ∧ right z = y then 1 else 0) + +lemma cut_form_eq_sum {Ω I : Type*} [Fintype I] [DecidableEq I] + (L : (Ω → ℝ) →ₗ[ℝ] ℝ) (left right : Ω → I) (F G : I → ℝ) : + L (fun z => F (left z) * G (right z)) = + ∑ x, ∑ y, cutKernel L left right x y * F x * G y := by + classical + have he : (fun z => F (left z) * G (right z)) = + ∑ x, ∑ y, (F x * G y) • (fun z => if left z = x ∧ right z = y then (1 : ℝ) else 0) := by + funext z + simp only [Finset.sum_apply, Pi.smul_apply, smul_eq_mul, ite_and] + simp + rw [he, map_sum] + apply sum_congr rfl + intro x _ + rw [map_sum] + apply sum_congr rfl + intro y _ + rw [map_smul, smul_eq_mul] + change (F x * G y) * cutKernel L left right x y = _ + ring + +lemma cutKernel_posSemidef {Ω I : Type*} [Fintype I] [DecidableEq I] + (L : (Ω → ℝ) →ₗ[ℝ] ℝ) (left right : Ω → I) + (hsym : ∀ F G : I → ℝ, + L (fun z => F (left z) * G (right z)) = + L (fun z => G (left z) * F (right z))) + (hpos : ∀ F : I → ℝ, 0 ≤ L (fun z => F (left z) * F (right z))) : + (cutKernel L left right).PosSemidef := by + rw [Matrix.posSemidef_iff_dotProduct_mulVec] + constructor + · ext x y + have hs := hsym (fun z => if z=x then 1 else 0) (fun z => if z=y then 1 else 0) + have he (x y : I) (z : Ω) : + (if left z=x then (1 : ℝ) else 0) * (if right z=y then 1 else 0) = + if left z=x ∧ right z=y then 1 else 0 := by split_ifs <;> simp_all + simp_rw [he] at hs + exact hs.symm + · intro F + have hh := hpos F + rw [cut_form_eq_sum] at hh + simpa only [dotProduct, Matrix.mulVec, star_trivial, sum_mul, mul_sum, + mul_left_comm, mul_comm, mul_assoc] using hh + +lemma matrix_prod_posSemidef {J I : Type*} [Fintype J] [Fintype I] + (K : J → Matrix I I ℝ) (hK : ∀ j, (K j).PosSemidef) : + Matrix.PosSemidef (fun x y => ∏ j, K j x y) := by + classical + have hs (s : Finset J) : Matrix.PosSemidef (fun x y => ∏ j ∈ s, K j x y) := by + induction s using Finset.induction_on with + | empty => + have he : (fun x y => ∏ j ∈ (∅ : Finset J), K j x y) = + Matrix.vecMulVec (fun _ : I => (1 : ℝ)) (star (fun _ : I => (1 : ℝ))) := by + ext x y + simp [Matrix.vecMulVec] + rw [he] + exact Matrix.posSemidef_vecMulVec_self_star (fun _ : I => (1 : ℝ)) + | @insert j s hj ih => + have he : (fun x y => ∏ k ∈ insert j s, K k x y) = + (K j).hadamard (fun x y => ∏ k ∈ s, K k x y) := by + ext x y + change (∏ k ∈ insert j s, K k x y) = K j x y * ∏ k ∈ s, K k x y + exact prod_insert hj + rw [he] + exact (hK j).hadamard ih + exact hs univ + +lemma cut_positive_of_kernel {Ω I : Type*} [Fintype I] [DecidableEq I] + (L : (Ω → ℝ) →ₗ[ℝ] ℝ) (left right : Ω → I) + (hK : (cutKernel L left right).PosSemidef) (F : I → ℝ) : + 0 ≤ L (fun z => F (left z) * F (right z)) := by + rw [cut_form_eq_sum] + have hh := (Matrix.posSemidef_iff_dotProduct_mulVec.mp hK).2 F + simpa only [dotProduct, Matrix.mulVec, star_trivial, sum_mul, mul_sum, + mul_left_comm, mul_comm, mul_assoc] using hh + +lemma cut_symmetric_of_kernel {Ω I : Type*} [Fintype I] [DecidableEq I] + (L : (Ω → ℝ) →ₗ[ℝ] ℝ) (left right : Ω → I) + (hK : (cutKernel L left right).PosSemidef) (F G : I → ℝ) : + L (fun z => F (left z) * G (right z)) = + L (fun z => G (left z) * F (right z)) := by + rw [cut_form_eq_sum, cut_form_eq_sum, sum_comm] + apply sum_congr rfl + intro x _ + apply sum_congr rfl + intro y _ + have hs : cutKernel L left right x y = cutKernel L left right y x := by + have h := congrFun (congrFun hK.isHermitian x) y + simpa only [Matrix.conjTranspose_apply, star_trivial] using h.symm + rw [hs] + ring + +noncomputable def lawDensity {Ω : Type*} [DecidableEq Ω] + (L : (Ω → ℝ) →ₗ[ℝ] ℝ) (x : Ω) : ℝ := + L (fun y => if y=x then 1 else 0) + +noncomputable def tensorLaw {J V : Type*} [Fintype J] [DecidableEq J] + [Fintype V] [DecidableEq V] {X : J → Type*} [∀ j, Fintype (X j)] + [∀ j, DecidableEq (X j)] + (L : ∀ j, ((V → X j) → ℝ) →ₗ[ℝ] ℝ) : ((V → ∀ j, X j) → ℝ) →ₗ[ℝ] ℝ where + toFun F := ∑ z : ∀ j, V → X j, (∏ j, lawDensity (L j) (z j)) * F (fun v j => z j v) + map_add' F G := by simp only [Pi.add_apply, mul_add, sum_add_distrib] + map_smul' c F := by simp only [Pi.smul_apply, smul_eq_mul, mul_left_comm, ← mul_sum, RingHom.id_apply] + +lemma tensorLaw_fubini {J V : Type*} [Fintype J] [DecidableEq J] + [Fintype V] [DecidableEq V] {X : J → Type*} [∀ j, Fintype (X j)] + [∀ j, DecidableEq (X j)] + (L : ∀ j, ((V → X j) → ℝ) →ₗ[ℝ] ℝ) (F : ∀ j, (V → X j) → ℝ) : + tensorLaw L (fun z => ∏ j, F j (fun v => z v j)) = ∏ j, L j (F j) := by + change (∑ z : ∀ j, V → X j, (∏ j, lawDensity (L j) (z j)) * ∏ j, F j (z j)) = _ + simp_rw [← prod_mul_distrib] + rw [← Fintype.prod_sum (fun j z => lawDensity (L j) z * F j z)] + apply prod_congr rfl + intro j _ + exact (linearFunctional_density (L j) (F j)).symm + +lemma tensorLaw_probability {J V : Type*} [Fintype J] [DecidableEq J] + [Fintype V] [DecidableEq V] {X : J → Type*} [∀ j, Fintype (X j)] + [∀ j, DecidableEq (X j)] + (L : ∀ j, ((V → X j) → ℝ) →ₗ[ℝ] ℝ) (hL : ∀ j, L j (fun _ => 1)=1) : + tensorLaw L (fun _ => 1) = 1 := by + have hh := tensorLaw_fubini L (fun _ _ => 1) + simpa only [prod_const_one, hL] using hh + +lemma tensorLaw_nonneg {J V : Type*} [Fintype J] [DecidableEq J] + [Fintype V] [DecidableEq V] {X : J → Type*} [∀ j, Fintype (X j)] + [∀ j, DecidableEq (X j)] + (L : ∀ j, ((V → X j) → ℝ) →ₗ[ℝ] ℝ) + (hL : ∀ j F, (∀ z, 0 ≤ F z) → 0 ≤ L j F) + (F : (V → ∀ j, X j) → ℝ) (hF : ∀ z, 0 ≤ F z) : + 0 ≤ tensorLaw L F := by + apply sum_nonneg + intro z _ + apply mul_nonneg (prod_nonneg fun j _ => ?_) (hF _) + exact hL j _ (fun _ => by split_ifs <;> norm_num) + +lemma prod_indicator_forall {J : Type*} [Fintype J] (P : J → Prop) [DecidablePred P] + [Decidable (∀ j, P j)] : + (∏ j, if P j then (1 : ℝ) else 0) = if ∀ j, P j then 1 else 0 := by + classical + by_cases h : ∀ j, P j + · simp [h] + · obtain ⟨j, hj⟩ := not_forall.mp h + rw [ite_eq_right h] + exact prod_eq_zero (mem_univ j) (ite_eq_right hj) + +lemma tensorLaw_cutKernel {J V W : Type*} [Fintype J] [DecidableEq J] + [Fintype V] [DecidableEq V] [Fintype W] [DecidableEq W] + {X : J → Type*} [∀ j, Fintype (X j)] [∀ j, DecidableEq (X j)] + (L : ∀ j, ((V → X j) → ℝ) →ₗ[ℝ] ℝ) (l r : W → V) + (x y : W → ∀ j, X j) : + cutKernel (tensorLaw L) (fun z w => z (l w)) (fun z w => z (r w)) x y = + ∏ j, cutKernel (L j) (fun z w => z (l w)) (fun z w => z (r w)) + (fun w => x w j) (fun w => y w j) := by + classical + unfold cutKernel + have he (z : V → ∀ j, X j) : + (if (fun w => z (l w))=x ∧ (fun w => z (r w))=y then (1 : ℝ) else 0) = + ∏ j, if (fun w => z (l w) j)=(fun w => x w j) ∧ + (fun w => z (r w) j)=(fun w => y w j) then 1 else 0 := by + rw [prod_indicator_forall] + congr 1 + apply propext + constructor + · rintro ⟨hl, hr⟩ j + exact ⟨funext fun w => congrFun (congrFun hl w) j, + funext fun w => congrFun (congrFun hr w) j⟩ + · intro h + exact ⟨funext fun w => funext fun j => congrFun (h j).1 w, + funext fun w => funext fun j => congrFun (h j).2 w⟩ + simp_rw [he] + exact tensorLaw_fubini L (fun j z => if (fun w => z (l w))=(fun w => x w j) ∧ + (fun w => z (r w))=(fun w => y w j) then 1 else 0) + +lemma tensorLaw_cut_positive {J V W : Type*} [Fintype J] [DecidableEq J] + [Fintype V] [DecidableEq V] [Fintype W] [DecidableEq W] + {X : J → Type*} [∀ j, Fintype (X j)] [∀ j, DecidableEq (X j)] + (L : ∀ j, ((V → X j) → ℝ) →ₗ[ℝ] ℝ) (l r : W → V) + (hsym : ∀ j, ∀ F G : (W → X j) → ℝ, + L j (fun z => F (fun w => z (l w)) * G (fun w => z (r w))) = + L j (fun z => G (fun w => z (l w)) * F (fun w => z (r w)))) + (hpos : ∀ j, ∀ F : (W → X j) → ℝ, + 0 ≤ L j (fun z => F (fun w => z (l w)) * F (fun w => z (r w)))) : + (cutKernel (tensorLaw L) (fun z w => z (l w)) (fun z w => z (r w))).PosSemidef := by + classical + have he : cutKernel (tensorLaw L) (fun z w => z (l w)) (fun z w => z (r w)) = + fun x y => ∏ j, cutKernel (L j) (fun z w => z (l w)) (fun z w => z (r w)) + (fun w => x w j) (fun w => y w j) := by + funext x y + exact tensorLaw_cutKernel L l r x y + rw [he] + let K (j : J) : Matrix (W → ∀ j, X j) (W → ∀ j, X j) ℝ := + (cutKernel (L j) (fun z w => z (l w)) (fun z w => z (r w))).submatrix + (fun x w => x w j) (fun x w => x w j) + have hK (j : J) : (K j).PosSemidef := + (cutKernel_posSemidef (L j) _ _ (hsym j) (hpos j)).submatrix _ + exact matrix_prod_posSemidef K hK + +lemma tensorLaw_word_symmetric {J B : Type*} [Fintype J] [DecidableEq J] + [Fintype B] [DecidableEq B] {h : ℕ} + {X : J → Type*} [∀ j, Fintype (X j)] [∀ j, DecidableEq (X j)] + (L : ∀ j, ((WordVertex B h → X j) → ℝ) →ₗ[ℝ] ℝ) + (hsym : ∀ j b α β, ∀ F G : (CutHalf b α β → X j) → ℝ, + L j (fun z => F (fun v => z v.1) * G (fun v => z (reflect b α β v.1))) = + L j (fun z => G (fun v => z v.1) * F (fun v => z (reflect b α β v.1)))) + (hpos : ∀ j b α β, α ≠ β → ∀ F : (CutHalf b α β → X j) → ℝ, + 0 ≤ L j (fun z => F (fun v => z v.1) * F (fun v => z (reflect b α β v.1)))) + (b : B) (α β : Fin h) (F G : (CutHalf b α β → ∀ j, X j) → ℝ) : + tensorLaw L (fun z => F (fun v => z v.1) * G (fun v => z (reflect b α β v.1))) = + tensorLaw L (fun z => G (fun v => z v.1) * F (fun v => z (reflect b α β v.1))) := by + classical + by_cases hne : α = β + · subst β + have he (z : WordVertex B h → ∀ j, X j) : (fun v : CutHalf b α α => + z (reflect b α α v.1)) = fun v => z v.1 := by + funext v + exact False.elim (lt_irrefl _ v.2) + simp_rw [he, mul_comm (F _) (G _)] + · exact cut_symmetric_of_kernel (tensorLaw L) _ _ + (tensorLaw_cut_positive L (fun v : CutHalf b α β => v.1) + (fun v => reflect b α β v.1) (fun j => hsym j b α β) + (fun j => hpos j b α β hne)) F G + +lemma tensorLaw_word_positive {J B : Type*} [Fintype J] [DecidableEq J] + [Fintype B] [DecidableEq B] {h : ℕ} + {X : J → Type*} [∀ j, Fintype (X j)] [∀ j, DecidableEq (X j)] + (L : ∀ j, ((WordVertex B h → X j) → ℝ) →ₗ[ℝ] ℝ) + (hsym : ∀ j b α β, ∀ F G : (CutHalf b α β → X j) → ℝ, + L j (fun z => F (fun v => z v.1) * G (fun v => z (reflect b α β v.1))) = + L j (fun z => G (fun v => z v.1) * F (fun v => z (reflect b α β v.1)))) + (hpos : ∀ j b α β, α ≠ β → ∀ F : (CutHalf b α β → X j) → ℝ, + 0 ≤ L j (fun z => F (fun v => z v.1) * F (fun v => z (reflect b α β v.1)))) + (b : B) {α β : Fin h} (hne : α ≠ β) + (F : (CutHalf b α β → ∀ j, X j) → ℝ) : + 0 ≤ tensorLaw L (fun z => F (fun v => z v.1) * F (fun v => z (reflect b α β v.1))) := by + classical + exact cut_positive_of_kernel (tensorLaw L) _ _ + (tensorLaw_cut_positive L (fun v : CutHalf b α β => v.1) + (fun v => reflect b α β v.1) (fun j => hsym j b α β) + (fun j => hpos j b α β hne)) F + +noncomputable def productTupleLaw {J : Type*} [Fintype J] [DecidableEq J] + (p : J → ℕ) [∀ j, Fact (p j).Prime] : + ((TupleVertex → ∀ j, ZMod (p j)) → ℝ) →ₗ[ℝ] ℝ := + tensorLaw (fun j => tupleLaw (p := p j)) + +lemma productTupleLaw_diagonal_nonneg {J : Type*} [Fintype J] [DecidableEq J] + (p : J → ℕ) [∀ j, Fact (p j).Prime] + (hp : ∀ j, tupleReflectionThreshold ≤ (p j : ℝ)) (g : (∀ j, ZMod (p j)) → ℝ) : + 0 ≤ diagonalIntegral (productTupleLaw p) g := by + exact word_diagonal_nonneg (productTupleLaw p) (⟨0, by decide⟩ : Fin tupleBlocks) + (show (⟨0, by decide⟩ : Fin tupleH) ≠ ⟨1, by decide⟩ by decide) + (tensorLaw_word_positive (fun j => tupleLaw (p := p j)) + (fun _j => tupleLaw_symmetric) + (fun j b _α _β hne => tupleLaw_reflection_positive (hp j) b hne) + (⟨0, by decide⟩ : Fin tupleBlocks) (by decide)) g + +lemma productTupleLaw_signed_holder {J : Type*} [Fintype J] [DecidableEq J] + (p : J → ℕ) [∀ j, Fact (p j).Prime] + (hp : ∀ j, tupleReflectionThreshold ≤ (p j : ℝ)) + (a : TupleVertex → (∀ j, ZMod (p j)) → ℝ) : + |multilinearIntegral (productTupleLaw p) a| ≤ + ∏ v, diagonalRoot (productTupleLaw p) (a v) := by + exact word_signed_holder (productTupleLaw p) (⟨0, by decide⟩ : Fin tupleBlocks) + (show (⟨0, by decide⟩ : Fin tupleH) ≠ ⟨1, by decide⟩ by decide) + (tensorLaw_word_symmetric (fun j => tupleLaw (p := p j)) + (fun _j => tupleLaw_symmetric) + (fun j b _α _β hne => tupleLaw_reflection_positive (hp j) b hne)) + (tensorLaw_word_positive (fun j => tupleLaw (p := p j)) + (fun _j => tupleLaw_symmetric) + (fun j b _α _β hne => tupleLaw_reflection_positive (hp j) b hne)) a + +lemma squareIndicator_mul_sq {F : Type*} [Field F] (q : F) (hq : q ≠ 0) (x : F) : + squareIndicator (q^2*x) = squareIndicator x := by + classical + have hs : IsSquare (q^2*x) ↔ IsSquare x := by + constructor + · rintro ⟨y, hy⟩ + refine ⟨y/q, ?_⟩ + apply (mul_right_cancel₀ (pow_ne_zero 2 hq)) + calc + x*q^2 = y*y := by rw [mul_comm]; exact hy + _ = ((y/q)*(y/q))*q^2 := by field_simp + · rintro ⟨y, rfl⟩ + exact ⟨q*y, by ring⟩ + unfold squareIndicator + rw [hs] + have hn : q^2*x ≠ 0 ↔ x ≠ 0 := by + rw [mul_ne_zero_iff] + exact and_iff_right (pow_ne_zero 2 hq) + simp only [hn] + +lemma tupleValidity_affine {p : ℕ} [Fact p.Prime] (S : Finset (Fin tupleBlocks)) + (q a : ZMod p) (hq : q ≠ 0) (Y : TupleListEntry S → ZMod p) : + tupleValidity S (fun i => q^2 * Y i + a) = tupleValidity S Y := by + unfold tupleValidity + apply prod_congr rfl + intro e _ + rw [show (q^2*Y e.2+a)-(q^2*Y e.1+a)=q^2*(Y e.2-Y e.1) by ring] + exact squareIndicator_mul_sq q hq _ + +end SquareDifference +end + +end OAI diff --git a/lean/OAI/Combinatorics/StableGraphs/ExteriorBounds.lean b/lean/OAI/Combinatorics/StableGraphs/ExteriorBounds.lean new file mode 100644 index 0000000000000000000000000000000000000000..3155a3ee6fc6b1baec5b35601ee1cd609f5c3138 --- /dev/null +++ b/lean/OAI/Combinatorics/StableGraphs/ExteriorBounds.lean @@ -0,0 +1,446 @@ +import Mathlib + +namespace OAI + +/-! +# Exterior monomials, color counts and finite stable-graph bounds + +The color-incidence set indexes slots in triples of colors. Its lexicographic +enumeration defines the color word and is used to count occurrences and +word-preserving permutations. The exterior-algebra constructions prove +nonvanishing of a factorial-scaled monomial, not a detector evaluation. + +The strata class `Y`, its realizations, Pixton relation span, detector pairing +and geometric vanishing are not defined here. These combinatorial results +therefore do not assert the geometric main theorem or cohomological corollary. +-/ + +noncomputable section + +open scoped BigOperators + +namespace PixtonChow + +/-! ## The numerical parameters of the proposed example -/ + +def genus : ℕ := 10 ^ 60 + +/-- Computed by the falling-factorial formula to avoid expanding Pascal's +recursion at `10^60`; `entryCount_eq_choose` proves the specified value. -/ +def entryCount : ℕ := genus.descFactorial 3 / 6 + +theorem entryCount_eq_choose : entryCount = genus.choose 3 := by + rw [entryCount, Nat.choose_eq_descFactorial_div_factorial] + rfl + +def markingCount : ℕ := 3 * entryCount + +/-- The elementary numerical bounds needed for the parameters. -/ +theorem parameter_bounds (g d : ℕ) (hg : 2 ≤ g) : + 2 < 2 * g + 3 * d ∧ 2 * d < 3 * g - 3 + 3 * d := by + omega + +/-- Stability of the specific pair in the source, in the form `2g + n > 2`. -/ +theorem parameters_stable : 2 < 2 * genus + markingCount := + (parameter_bounds genus entryCount (by norm_num [genus])).1 + +/-- The proposed codimension is below the moduli dimension. This says +nothing about the existence or the degree of a strata-algebra element. -/ +theorem proposed_codimension_lt_dimension : + 2 * entryCount < 3 * genus - 3 + markingCount := + (parameter_bounds genus entryCount (by norm_num [genus])).2 + +/-! ## Triples, incidences, and the color-word stabilizer -/ + +/-- A set of three distinct colors; sorting it gives its unique increasing triple. -/ +abbrev Triple (g : ℕ) := Set.powersetCard (Fin g) 3 + +/-- Slots indexed by a triple together with one of its colors. -/ +abbrev ColorSlot (g : ℕ) := (s : Triple g) × {c : Fin g // c ∈ s.val} + +/-- The color of a slot. -/ +def incidenceColor {g : ℕ} (p : ColorSlot g) : Fin g := p.2.val + +theorem triple_card (g : ℕ) : Fintype.card (Triple g) = g.choose 3 := by + rw [← Nat.card_eq_fintype_card, Set.powersetCard.card] + simp + +/-- Each block contains exactly three slots. -/ +theorem block_card {g : ℕ} (s : Triple g) : + Fintype.card {c : Fin g // c ∈ s.val} = 3 := by + simpa only [Fintype.card_coe] using Set.powersetCard.card_eq s + +theorem colorSlot_card (g : ℕ) : Fintype.card (ColorSlot g) = 3 * g.choose 3 := by + rw [Fintype.card_sigma] + simp_rw [block_card] + simp only [Finset.sum_const, Finset.card_univ, smul_eq_mul, triple_card, mul_comm] + +/-- Erasing the choice of a distinguished color in a fiber of `incidenceColor` +leaves precisely a triple containing that color. -/ +def colorFiberEquiv {g : ℕ} (c : Fin g) : + {p : ColorSlot g // incidenceColor p = c} ≃ {s : Triple g // c ∈ s.val} where + toFun p := ⟨p.val.1, by + have h : incidenceColor p.val ∈ p.val.1.val := p.val.2.prop + simpa only [p.prop] using h⟩ + invFun s := ⟨⟨s.val, ⟨c, s.prop⟩⟩, rfl⟩ + left_inv p := by + rcases p with ⟨⟨s, ⟨d, hd⟩⟩, he⟩ + change d = c at he + subst d + rfl + right_inv _ := rfl + +/-- Repackaging as the finite set of three-element supersets of `{c}`. -/ +def containingTripleEquiv {g : ℕ} (c : Fin g) : + {s : Triple g // c ∈ s.val} ≃ + {s // s ∈ ((Finset.univ : Finset (Fin g)).powersetCard 3).filter + ({c} ⊆ ·)} where + toFun s := ⟨s.val.val, by simp [s.prop]⟩ + invFun s := ⟨⟨s.val, by simpa using (Finset.mem_filter.mp s.prop).1⟩, + by simpa using (Finset.mem_filter.mp s.prop).2⟩ + left_inv _ := rfl + right_inv _ := rfl + +/-- Every color belongs to `choose (g-1) 2` of the triples. -/ +theorem containingTriple_card {g : ℕ} (c : Fin g) : + Fintype.card {s : Triple g // c ∈ s.val} = (g - 1).choose 2 := by + rw [Fintype.card_congr (containingTripleEquiv c), Fintype.card_coe] + simpa using Finset.card_filter_powersetCard_subset + ({c} : Finset (Fin g)) Finset.univ 3 (Finset.subset_univ _) (by simp) + +theorem colorFiber_card {g : ℕ} (c : Fin g) : + Fintype.card {p : ColorSlot g // incidenceColor p = c} = (g - 1).choose 2 := by + rw [Fintype.card_congr (colorFiberEquiv c), containingTriple_card] + +/-- A permutation of slots preserving their colors. -/ +abbrev ColorStabilizer (g : ℕ) := + {p : Equiv.Perm (ColorSlot g) // incidenceColor ∘ p = incidenceColor} + +/-- The factorial multiplicity appearing in `eq:detector-candidate-value`. +This counts permutations only: no equality involving the detector is asserted. -/ +theorem colorStabilizer_card (g : ℕ) : + Fintype.card (ColorStabilizer g) = ((g - 1).choose 2).factorial ^ g := by + classical + rw [DomMulAct.stabilizer_card] + simp [colorFiber_card] + +/-- Counts are unchanged by any enumeration of the slots, including the +lexicographic enumeration used in Definition `def:candidate`. -/ +theorem reindexed_stabilizer_card (g : ℕ) {A : Type*} [Fintype A] [DecidableEq A] + (e : A ≃ ColorSlot g) : + Fintype.card {p : Equiv.Perm A // (incidenceColor ∘ e) ∘ p = incidenceColor ∘ e} = + ((g - 1).choose 2).factorial ^ g := by + classical + rw [DomMulAct.stabilizer_card] + have h (c : Fin g) : Fintype.card {a : A // incidenceColor (e a) = c} = + (g - 1).choose 2 := by + calc + _ = Fintype.card {p : ColorSlot g // incidenceColor p = c} := + Fintype.card_congr (e.subtypeEquivOfSubtype) + _ = _ := colorFiber_card c + simp only [Function.comp_apply, h, Finset.prod_const, Finset.card_univ, Fintype.card_fin] + +/-! ## The lexicographic color word itself -/ + +/-- Lexicographic order on the sorted lists representing the triples. -/ +@[instance_reducible] def tripleLexOrder (g : ℕ) : LinearOrder (Triple g) := + LinearOrder.lift' (fun s : Triple g => s.val.sort (· ≤ ·)) (by + intro s t h + apply Subtype.ext + simpa only [Finset.sort_toFinset] using congrArg List.toFinset h) + +section OrderedTriples + +local instance (g : ℕ) : LinearOrder (Triple g) := tripleLexOrder g + +/-- Increasing enumeration of all three-color blocks in lexicographic order. -/ +def tripleEnumeration (g : ℕ) : Fin (g.choose 3) ≃ Triple g := + (Fintype.orderIsoFinOfCardEq (Triple g) (triple_card g)).toEquiv + +/-- Each block is enumerated in increasing color order. -/ +def blockSlotEquiv (g : ℕ) : Fin (g.choose 3) × Fin 3 ≃ ColorSlot g := + (Equiv.sigmaEquivProd (Fin (g.choose 3)) (Fin 3)).symm |>.trans + ((Equiv.sigmaCongrRight fun j => + ((tripleEnumeration g j).val.orderIsoOfFin + (Set.powersetCard.card_eq _)).toEquiv) |>.trans + (Equiv.sigmaCongrLeft (β := fun s : Triple g => {c : Fin g // c ∈ s.val}) + (tripleEnumeration g))) + +/-- The first three positions are the first lexicographic block, etc. -/ +def orderedSlotEquiv (g : ℕ) : Fin (3 * g.choose 3) ≃ ColorSlot g := + ((Fin.castOrderIso (Nat.mul_comm 3 (g.choose 3))).toEquiv.trans + finProdFinEquiv.symm).trans (blockSlotEquiv g) + +/-- The concatenation of the increasing triples, with colors numbered `0,...,g-1` +instead of `1,...,g`. -/ +def colorWord (g : ℕ) : Fin (3 * g.choose 3) → Fin g := + incidenceColor ∘ orderedSlotEquiv g + +theorem colorWord_fiber_card {g : ℕ} (c : Fin g) : + Fintype.card {j : Fin (3 * g.choose 3) // colorWord g j = c} = + (g - 1).choose 2 := by + calc + _ = Fintype.card {p : ColorSlot g // incidenceColor p = c} := + Fintype.card_congr (orderedSlotEquiv g).subtypeEquivOfSubtype + _ = _ := colorFiber_card c + +theorem colorWord_stabilizer_card (g : ℕ) : + Fintype.card {p : Equiv.Perm (Fin (3 * g.choose 3)) // + colorWord g ∘ p = colorWord g} = ((g - 1).choose 2).factorial ^ g := + reindexed_stabilizer_card g (orderedSlotEquiv g) + +end OrderedTriples + +/-! ## The nonzero exterior monomial (without a detector evaluation) -/ + +/-- The exterior algebra on a freely specified set of generators. -/ +abbrev ExteriorCoefficients (I : Type*) := ExteriorAlgebra ℚ (I →₀ ℚ) + +/-- The generator indexed by `i`. -/ +def theta {I : Type*} (i : I) : ExteriorCoefficients I := + ExteriorAlgebra.ι ℚ (Finsupp.single i 1) + +/-- The product of all generators, in the given increasing order. -/ +def topExteriorProduct (I : Type*) [Fintype I] [LinearOrder I] : + ExteriorCoefficients I := + ExteriorAlgebra.ιMulti_family ℚ (Fintype.card I) + (Finsupp.basisSingleOne : Module.Basis I ℚ (I →₀ ℚ)) + ⟨Finset.univ, by simp⟩ + +theorem topExteriorProduct_eq_ordered_product (I : Type*) [Fintype I] [LinearOrder I] : + topExteriorProduct I = + (List.ofFn (fun k : Fin (Fintype.card I) => + theta ((Finset.univ : Finset I).orderEmbOfFin Finset.card_univ k))).prod := by + rfl + +/-- Identifying the ordered monomial with an actual exterior-algebra basis +vector, not positing its nonvanishing. -/ +theorem topExteriorProduct_eq_basis (I : Type*) [Fintype I] [LinearOrder I] : + topExteriorProduct I = + (Finsupp.basisSingleOne : Module.Basis I ℚ (I →₀ ℚ)).ExteriorAlgebra Finset.univ := by + symm + exact ExteriorAlgebra.basis_apply_ofCard _ Finset.card_univ + +theorem topExteriorProduct_ne_zero (I : Type*) [Fintype I] [LinearOrder I] : + topExteriorProduct I ≠ 0 := by + rw [topExteriorProduct_eq_basis] + exact Module.Basis.ne_zero _ _ + +/-- The proposed detector's final scalar-multiple monomial is nonzero over `ℚ`. +The crucial claim that it equals a pairing with `t_n(Y)` is not formalized. -/ +theorem factorial_multiple_topExteriorProduct_ne_zero (g : ℕ) (I : Type*) + [Fintype I] [LinearOrder I] : + (((((g - 1).choose 2).factorial : ℕ) : ℚ) ^ g) • topExteriorProduct I ≠ 0 := by + apply smul_ne_zero + · exact pow_ne_zero _ (Nat.cast_ne_zero.mpr (Nat.factorial_ne_zero _)) + · exact topExteriorProduct_ne_zero I + +/-- The monomial `Θ` indexed by all triples in lexicographic order, +in the exterior algebra from Section 3. -/ +def candidateTheta (g : ℕ) : ExteriorCoefficients (Triple g) := + letI := tripleLexOrder g + topExteriorProduct (Triple g) + +theorem candidateTheta_ne_zero (g : ℕ) : candidateTheta g ≠ 0 := by + let _ := tripleLexOrder g + exact topExteriorProduct_ne_zero (Triple g) + +/-- The unsigned right side of `eq:detector-candidate-value` is nonzero. +No equality with a value of the candidate class is claimed here. -/ +theorem candidateTheta_multiple_ne_zero (g : ℕ) : + (((((g - 1).choose 2).factorial : ℕ) : ℚ) ^ g) • candidateTheta g ≠ 0 := by + let _ := tripleLexOrder g + exact factorial_multiple_topExteriorProduct_ne_zero g (Triple g) + +/-! ## Stable-graph incidence bounds + +These are graph presentations, before passing to graph isomorphism classes. +Loops and multiple edges are allowed. The two flags of each edge are +explicitly distinguished. No strata-algebra operations are defined here. +-/ + +/-- The two flags at each edge, together with the labeled legs. -/ +abbrev GraphFlag (E : Type*) (n : ℕ) := (E × Fin 2) ⊕ Fin n + +/-- Undirected adjacency in a graph presentation. -/ +def EdgeAdjacent {V E : Type*} {n : ℕ} (atVertex : GraphFlag E n → V) + (u v : V) : Prop := + ∃ e : E, (atVertex (.inl (e, 0)) = u ∧ atVertex (.inl (e, 1)) = v) ∨ + (atVertex (.inl (e, 0)) = v ∧ atVertex (.inl (e, 1)) = u) + +/-- A finite connected stable graph of type `(g,n)`, given by vertices, edges, +flag incidences, and nonnegative vertex genera. The integer genus equation +avoids truncated subtraction in `|E| - |V| + 1`. -/ +structure StableGraph (g n : ℕ) (V E : Type*) [Fintype V] [Fintype E] + [DecidableEq V] where + atVertex : GraphFlag E n → V + vertexGenus : V → ℕ + connected : ∃ root : V, ∀ v : V, Relation.ReflTransGen (EdgeAdjacent atVertex) root v + genus_eq : (∑ v, (vertexGenus v : ℤ)) + Fintype.card E - Fintype.card V + 1 = g + stable : ∀ v : V, 0 < 2 * (vertexGenus v : ℤ) - 2 + + Fintype.card {f : GraphFlag E n // atVertex f = v} + +namespace StableGraph + +variable {g n : ℕ} {V E : Type*} [Fintype V] [Fintype E] [DecidableEq V] + +/-- Number of flags, including legs, incident to a vertex. -/ +def valence (Γ : StableGraph g n V E) (v : V) : ℕ := + Fintype.card {f : GraphFlag E n // Γ.atVertex f = v} + +theorem sum_valence (Γ : StableGraph g n V E) : + ∑ v, Γ.valence v = 2 * Fintype.card E + n := by + unfold valence + rw [← Fintype.card_sigma, Fintype.card_congr (Equiv.sigmaFiberEquiv Γ.atVertex)] + simp only [GraphFlag, Fintype.card_sum, Fintype.card_prod, Fintype.card_fin, mul_comm] + +/-- Summing the stability weights cancels the individual vertex genera. -/ +theorem sum_stability (Γ : StableGraph g n V E) : + ∑ v, (2 * (Γ.vertexGenus v : ℤ) - 2 + Γ.valence v) = 2 * g - 2 + n := by + have hv : ∑ v, (Γ.valence v : ℤ) = 2 * Fintype.card E + n := by + exact_mod_cast Γ.sum_valence + simp only [Finset.sum_add_distrib, Finset.sum_sub_distrib, + ← Finset.mul_sum, Finset.sum_const, Finset.card_univ, nsmul_eq_mul, hv] + linarith [Γ.genus_eq] + +/-- The usual bound on the number of vertices, including marked graphs. -/ +theorem vertex_bound (Γ : StableGraph g n V E) : + (Fintype.card V : ℤ) ≤ 2 * g - 2 + n := by + calc + _ = ∑ _v : V, (1 : ℤ) := by simp + _ ≤ ∑ v, (2 * (Γ.vertexGenus v : ℤ) - 2 + Γ.valence v) := by + apply Finset.sum_le_sum + intro v _ + have h := Γ.stable v + change 0 < 2 * (Γ.vertexGenus v : ℤ) - 2 + Γ.valence v at h + omega + _ = _ := Γ.sum_stability + +theorem edge_bound (Γ : StableGraph g n V E) : + (Fintype.card E : ℤ) ≤ 3 * g - 3 + n := by + have hnonneg : 0 ≤ ∑ v, (Γ.vertexGenus v : ℤ) := + Finset.sum_nonneg fun _ _ => Nat.cast_nonneg _ + linarith [Γ.genus_eq, Γ.vertex_bound] + +/-- `R_Γ` from `lem:elementary-entry-tests`. -/ +def noiseCount (_Γ : StableGraph g n V E) : ℕ := + 2 * Fintype.card V + 2 * Fintype.card E + +/-- The unmarked global noise bound `eq:global-noise-bound`. -/ +theorem noiseCount_bound (Γ : StableGraph g 0 V E) : + (Γ.noiseCount : ℤ) ≤ 10 * g := by + simp only [noiseCount, Nat.cast_add, Nat.cast_mul, Nat.cast_ofNat] + have hv := Γ.vertex_bound + have he := Γ.edge_bound + simp only [Nat.cast_zero, add_zero] at hv he + linarith + +/-- For any distinguished vertex, the first small-deficit bound. It does not +require that this vertex have maximum genus. -/ +theorem other_vertices_bound (Γ : StableGraph g 0 V E) (v : V) : + (Fintype.card V : ℤ) - 1 ≤ 2 * ((g : ℤ) - Γ.vertexGenus v) := by + let w : V → ℤ := fun u => 2 * (Γ.vertexGenus u : ℤ) - 2 + Γ.valence u + have hsum : ∑ u, w u = 2 * g - 2 := by simpa [w] using Γ.sum_stability + have hsplit : (∑ u ∈ Finset.univ.erase v, w u) + w v = ∑ u, w u := + Finset.sum_erase_add _ _ (Finset.mem_univ v) + have hcard : ((Finset.univ.erase v).card : ℤ) + 1 = Fintype.card V := by + exact_mod_cast Finset.card_erase_add_one (Finset.mem_univ v) + have hle : ((Finset.univ.erase v).card : ℤ) ≤ ∑ u ∈ Finset.univ.erase v, w u := by + calc + _ = ∑ _u ∈ Finset.univ.erase v, (1 : ℤ) := by simp + _ ≤ _ := Finset.sum_le_sum (fun u _ => by + have h := Γ.stable u + change 0 < w u at h + omega) + have hval : (0 : ℤ) ≤ Γ.valence v := Nat.cast_nonneg _ + dsimp [w] at hsplit + linarith + +/-- The edge part of `eq:small-graph-size`. -/ +theorem small_deficit_edge_bound (Γ : StableGraph g 0 V E) (v : V) : + (Fintype.card E : ℤ) ≤ 3 * ((g : ℤ) - Γ.vertexGenus v) := by + have hgen : (Γ.vertexGenus v : ℤ) ≤ ∑ u, (Γ.vertexGenus u : ℤ) := + Finset.single_le_sum (fun u _ => Nat.cast_nonneg _) (Finset.mem_univ v) + linarith [Γ.genus_eq, Γ.other_vertices_bound v] + +/-- The noise budget when the genus deficit at a distinguished vertex is small. -/ +theorem small_deficit_noise_bound (Γ : StableGraph g 0 V E) (v : V) : + (Γ.noiseCount : ℤ) ≤ 10 * ((g : ℤ) - Γ.vertexGenus v) + 2 := by + simp only [noiseCount, Nat.cast_add, Nat.cast_mul, Nat.cast_ofNat] + linarith [Γ.other_vertices_bound v, Γ.small_deficit_edge_bound v] + +end StableGraph + +/-! ## Explicit color-budget inequalities + +These are only arithmetic checks. They do not assert that any Chow-theoretic +support-advancement operation exists. +-/ + +namespace ColorBudget + +def K : ℕ := 10 ^ 5 + +def blockSize : ℕ := 2000 * 10 ^ 40 + +def blockCount : ℕ := 4 * K + 20 + +/-- `C_K`, computed without recursion in the upper argument of `choose`. -/ +def C : ℕ := (2 * K).descFactorial 3 / 6 + +/-- `D_0`, computed by the same falling-factorial formula. -/ +def D₀ : ℕ := blockSize.descFactorial 3 / 6 + +theorem C_eq_choose : C = (2 * K).choose 3 := by + rw [C, Nat.choose_eq_descFactorial_div_factorial] + rfl + +theorem D₀_eq_choose : D₀ = blockSize.choose 3 := by + rw [D₀, Nat.choose_eq_descFactorial_div_factorial] + rfl + +/-- `10^40` is the integer value required for `g^(2/3)` at this genus. -/ +theorem block_scale : (10 ^ 40 : ℕ) ^ 3 = genus ^ 2 := by + norm_num [genus] + +/-- Fewer than one tenth of the colors are needed for the reserved blocks. -/ +theorem reservation_bound : 10 * (blockCount * blockSize) < genus := by + norm_num [blockCount, blockSize, K, genus] + +/-- The remaining number of colors is strictly greater than `0.9 g`. -/ +theorem remaining_bound : 9 * genus < 10 * (genus - blockCount * blockSize) := by + have h := reservation_bound + omega + +theorem C_bound : C < 1334000000000000 := by + norm_num [C, K, Nat.descFactorial] + +theorem block_entry_bound : 10 ^ 9 * genus ^ 2 < D₀ := by + norm_num [D₀, blockSize, genus, Nat.descFactorial] + +theorem ordinary_small_cost : max (10 * K + 3) (C + 1) = C + 1 := by + norm_num [C, K, Nat.descFactorial] + +/-- The two numerical inequalities in `eq:small-loss`, with the second one +multiplied by `100` to stay in natural numbers. -/ +theorem small_loss_bounds : + 3 * genus * (C + 1) + genus * (10 * K + 2) + 2 * K * C < 10 ^ 17 * genus ∧ + 100 * (10 ^ 17 * genus) < D₀ := by + norm_num [C, K, genus, D₀, blockSize, Nat.descFactorial] + +/-- Bounds on the number of reserved blocks; no existence of an advancement is +assumed or derived from these numerical comparisons. -/ +theorem expensive_count_bounds : + 4 * (genus - K - 2) > 3 * genus - 3 ∧ 3 * K + 5 < blockCount := by + norm_num [genus, K, blockCount] + +theorem ordinary_cost_bounds : C + 1 < 11 * genus ∧ 10 * genus + 1 < 11 * genus := by + norm_num [C, K, genus, Nat.descFactorial] + +end ColorBudget + +end PixtonChow + +end + +end OAI diff --git a/lean/OAI/Combinatorics/StripMass/ArchIntegrals.lean b/lean/OAI/Combinatorics/StripMass/ArchIntegrals.lean new file mode 100644 index 0000000000000000000000000000000000000000..0c62c5fc136d7e0b8e63c338f1d77e2fa7306427 --- /dev/null +++ b/lean/OAI/Combinatorics/StripMass/ArchIntegrals.lean @@ -0,0 +1,435 @@ +import Mathlib +import OAI.Combinatorics.StripMass.PfaffianConfluentLimit + +namespace OAI + +/-! Critical honeycomb strip paths, polynomial identities and crossing mass. -/ + + +namespace CriticalStrip +noncomputable section +open scoped BigOperators +open Set MeasureTheory +theorem pointwiseArchIntegral_lower {N : ℕ} {y : Fin N → ℝ} + (hy : y ∈ orderedDomain N) (i : Fin N) (hsmall : ∀ j, y i ≤ y j) : + (1 / 96 : ℝ) * (y i) ^ (-(1 / 4 : ℝ)) ≤ pointwiseArchIntegral N y := by + have hyi := (hy.2 i).1 + have hyi1 := (hy.2 i).2 + have hab : y i / 3 ≤ y i / 2 := by linarith + have hsub : Ioo (y i / 3) (y i / 2) ⊆ Ioo (0 : ℝ) 1 := by + intro x hx + constructor <;> linarith [hx.1, hx.2] + have hint := integrableOn_pointwiseArchIntegrand hy + have hlocal : ∀ x ∈ Ioo (y i / 3) (y i / 2), + (1 / 16 : ℝ) * (y i) ^ (-(1 / 4 : ℝ)) / y i ≤ pointwiseArchIntegrand N y x := by + intro x hx + have hx0 : 0 < x := (hsub hx).1 + have hxi : x ≤ y i := by linarith [hx.2] + have hr := Real.rpow_le_rpow_of_nonpos hx0 hxi (by norm_num : -(1 / 4 : ℝ) ≤ 0) + have homega : (1 / 8 : ℝ) * (y i) ^ (-(1 / 4 : ℝ)) ≤ omega x := + (mul_le_mul_of_nonneg_left hr (by norm_num)).trans + (rpow_le_eight_omega ⟨hx0, by linarith [hx.2]⟩) + have hmul : (1 / 16 : ℝ) * (y i) ^ (-(1 / 4 : ℝ)) ≤ + (1 - reflectionProduct N x y) * omega x := by + calc + (1 / 16 : ℝ) * (y i) ^ (-(1 / 4 : ℝ)) = + (1 / 2 : ℝ) * ((1 / 8 : ℝ) * (y i) ^ (-(1 / 4 : ℝ))) := by ring + _ ≤ (1 - reflectionProduct N x y) * omega x := + mul_le_mul (reflection_deficit_lower hy i hsmall hx) homega + (by positivity) (reflection_deficit_bounds hy hx0).1 + exact (div_le_div_of_nonneg_left (by positivity) hx0 hxi).trans + (div_le_div_of_nonneg_right hmul hx0.le) + have hinterval : (1 / 96 : ℝ) * (y i) ^ (-(1 / 4 : ℝ)) ≤ + ∫ x in Ioo (y i / 3) (y i / 2), pointwiseArchIntegrand N y x := by + have h := setIntegral_mono_on + (show IntegrableOn (fun _ : ℝ => (1 / 16 : ℝ) * (y i) ^ (-(1 / 4 : ℝ)) / y i) + (Ioo (y i / 3) (y i / 2)) from integrable_const _) + (hint.mono_set hsub) measurableSet_Ioo hlocal + calc + (1 / 96 : ℝ) * (y i) ^ (-(1 / 4 : ℝ)) = + ∫ _x in Ioo (y i / 3) (y i / 2), (1 / 16 : ℝ) * (y i) ^ (-(1 / 4 : ℝ)) / y i := by + rw [setIntegral_const, Real.volume_real_Ioo_of_le hab, smul_eq_mul] + field_simp + ring + _ ≤ _ := h + apply hinterval.trans + apply setIntegral_mono_set hint + · filter_upwards [ae_restrict_mem measurableSet_Ioo] with x hx + exact (pointwiseArchIntegrand_bounds hy hx).1 + · exact Filter.Eventually.of_forall hsub + + +theorem pointwiseArchIntegrand_two_majorants {N : ℕ} {y : Fin N → ℝ} + (hy : y ∈ orderedDomain N) {x : ℝ} (hx : x ∈ Ioo 0 1) : + pointwiseArchIntegrand N y x ≤ + (2 * ∑ i, (y i)⁻¹) * x ^ (-(1 / 4 : ℝ)) ∧ + pointwiseArchIntegrand N y x ≤ 2 * x ^ (-(5 / 4 : ℝ)) := by + have hx0 := hx.1 + have hS : 0 ≤ ∑ i, (y i)⁻¹ := Finset.sum_nonneg fun i _ => inv_nonneg.mpr (hy.2 i).1.le + have hdef := (reflection_deficit_bounds hy hx0).2 + have h₁ : 1 - reflectionProduct N x y ≤ 2 * (x * ∑ i, (y i)⁻¹) := + hdef.trans (mul_le_mul_of_nonneg_left (min_le_right _ _) (by norm_num)) + have h₂ : 1 - reflectionProduct N x y ≤ (2 : ℝ) := by + simpa only [mul_one] using hdef.trans (mul_le_mul_of_nonneg_left (min_le_left _ _) (by norm_num)) + constructor + · calc + pointwiseArchIntegrand N y x ≤ + (2 * (x * ∑ i, (y i)⁻¹)) * x ^ (-(1 / 4 : ℝ)) / x := + div_le_div_of_nonneg_right (mul_le_mul h₁ (omega_le_rpow hx) + (omega_nonneg x) (by positivity)) hx0.le + _ = _ := by field_simp + · calc + pointwiseArchIntegrand N y x ≤ 2 * x ^ (-(1 / 4 : ℝ)) / x := + div_le_div_of_nonneg_right (mul_le_mul h₂ (omega_le_rpow hx) + (omega_nonneg x) (by norm_num)) hx0.le + _ = 2 * x ^ (-(5 / 4 : ℝ)) := by + rw [show -(5 / 4 : ℝ) = -(1 / 4 : ℝ) - 1 by norm_num, + Real.rpow_sub hx0, Real.rpow_one] + ring + + + +theorem pointwiseArchIntegral_upper {N : ℕ} (hN : 1 ≤ N) {y : Fin N → ℝ} + (hy : y ∈ orderedDomain N) : + pointwiseArchIntegral N y ≤ (32 / 3 : ℝ) * (∑ i, (y i)⁻¹) ^ (1 / 4 : ℝ) := by + let S : ℝ := ∑ i, (y i)⁻¹ + let t : ℝ := S⁻¹ + have hS : 1 ≤ S := by + let i : Fin N := ⟨0, by omega⟩ + calc + 1 ≤ (y i)⁻¹ := (one_le_inv₀ (hy.2 i).1).mpr (hy.2 i).2.le + _ ≤ S := Finset.single_le_sum (fun j _ => inv_nonneg.mpr (hy.2 j).1.le) (Finset.mem_univ _) + have hSpos : 0 < S := lt_of_lt_of_le zero_lt_one hS + have htpos : 0 < t := inv_pos.mpr hSpos + have ht1 : t ≤ 1 := (inv_le_one₀ hSpos).mpr hS + have hsub₁ : Ioo 0 t ⊆ Ioo (0 : ℝ) 1 := Ioo_subset_Ioo le_rfl ht1 + have hsub₂ : Ioo t 1 ⊆ Ioo (0 : ℝ) 1 := Ioo_subset_Ioo htpos.le le_rfl + have hi := integrableOn_pointwiseArchIntegrand hy + have hi₁ := hi.mono_set hsub₁ + have hi₂ := hi.mono_set hsub₂ + have hit₁ := (intervalIntegrable_iff_integrableOn_Ioo_of_le htpos.le).mpr hi₁ + have hit₂ := (intervalIntegrable_iff_integrableOn_Ioo_of_le ht1).mpr hi₂ + have hpow₁ : S * t ^ (3 / 4 : ℝ) = S ^ (1 / 4 : ℝ) := by + calc + S * t ^ (3 / 4 : ℝ) = S ^ (1 : ℝ) * S ^ (-(3 / 4 : ℝ)) := by + rw [Real.rpow_one, Real.rpow_neg hSpos.le, ← Real.inv_rpow hSpos.le] + _ = S ^ ((1 : ℝ) + -(3 / 4 : ℝ)) := (Real.rpow_add hSpos _ _).symm + _ = S ^ (1 / 4 : ℝ) := by norm_num + have hpow₂ : t ^ (-(1 / 4 : ℝ)) = S ^ (1 / 4 : ℝ) := by + change (S⁻¹) ^ (-(1 / 4 : ℝ)) = _ + rw [Real.inv_rpow hSpos.le, Real.rpow_neg hSpos.le, inv_inv] + have hbound₁ : ∫ x in Ioo 0 t, pointwiseArchIntegrand N y x ≤ + (8 / 3 : ℝ) * S ^ (1 / 4 : ℝ) := by + have hir : IntegrableOn (fun x : ℝ => x ^ (-(1 / 4 : ℝ))) (Ioo 0 t) := + (intervalIntegral.integrableOn_Ioo_rpow_iff htpos).mpr (by norm_num) + calc + ∫ x in Ioo 0 t, pointwiseArchIntegrand N y x ≤ + ∫ x in Ioo 0 t, (2 * S) * x ^ (-(1 / 4 : ℝ)) := + setIntegral_mono_on hi₁ (hir.const_mul _) measurableSet_Ioo + (fun x hx => (pointwiseArchIntegrand_two_majorants hy (hsub₁ hx)).1) + _ = (8 / 3 : ℝ) * S ^ (1 / 4 : ℝ) := by + rw [integral_const_mul, ← integral_Ioc_eq_integral_Ioo, + ← intervalIntegral.integral_of_le htpos.le, + integral_rpow (Or.inl (by norm_num : -(1 : ℝ) < -(1 / 4 : ℝ)))] + norm_num only [show -(1 / 4 : ℝ) + 1 = 3 / 4 by norm_num, + Real.zero_rpow (by norm_num : (3 / 4 : ℝ) ≠ 0), sub_zero] + calc + (2 * S) * (t ^ (3 / 4 : ℝ) / (3 / 4 : ℝ)) = + (8 / 3 : ℝ) * (S * t ^ (3 / 4 : ℝ)) := by ring + _ = _ := by rw [hpow₁] + have hbound₂ : ∫ x in Ioo t 1, pointwiseArchIntegrand N y x ≤ + 8 * S ^ (1 / 4 : ℝ) := by + have hzero : (0 : ℝ) ∉ uIcc t 1 := by + rw [uIcc_of_le ht1] + intro hz + linarith [hz.1] + have hir' : IntervalIntegrable (fun x : ℝ => x ^ (-(5 / 4 : ℝ))) volume t 1 := + intervalIntegral.intervalIntegrable_rpow (Or.inr hzero) + have hir := (intervalIntegrable_iff_integrableOn_Ioo_of_le ht1).mp hir' + calc + ∫ x in Ioo t 1, pointwiseArchIntegrand N y x ≤ + ∫ x in Ioo t 1, 2 * x ^ (-(5 / 4 : ℝ)) := + setIntegral_mono_on hi₂ (hir.const_mul _) measurableSet_Ioo + (fun x hx => (pointwiseArchIntegrand_two_majorants hy (hsub₂ hx)).2) + _ = 8 * (S ^ (1 / 4 : ℝ) - 1) := by + rw [integral_const_mul, ← integral_Ioc_eq_integral_Ioo, + ← intervalIntegral.integral_of_le ht1, + integral_rpow (Or.inr ⟨by norm_num, hzero⟩)] + norm_num only [show -(5 / 4 : ℝ) + 1 = -(1 / 4 : ℝ) by norm_num, + Real.one_rpow, hpow₂] + ring + _ ≤ 8 * S ^ (1 / 4 : ℝ) := by linarith + have hsplit := intervalIntegral.integral_add_adjacent_intervals hit₁ hit₂ + rw [intervalIntegral.integral_of_le htpos.le, intervalIntegral.integral_of_le ht1, + intervalIntegral.integral_of_le (by norm_num : (0 : ℝ) ≤ 1), + integral_Ioc_eq_integral_Ioo, integral_Ioc_eq_integral_Ioo, integral_Ioc_eq_integral_Ioo] at hsplit + change pointwiseArchIntegral N y ≤ (32 / 3 : ℝ) * S ^ (1 / 4 : ℝ) + unfold pointwiseArchIntegral + rw [← hsplit] + linarith + + + + + +theorem integrable_jointArchIntegrand (N : ℕ) : + Integrable (fun p : ℝ × (Fin N → ℝ) => + pointwiseArchIntegrand N p.2 p.1 * density N p.2) + ((volume.restrict (Ioo (0 : ℝ) 1)).prod (volume.restrict (orderedDomain N))) := by + have hp : IntegrableOn (fun x : ℝ => x ^ (-(3 / 4 : ℝ))) (Ioo 0 1) := + (intervalIntegral.integrableOn_Ioo_rpow_iff (by norm_num : (0 : ℝ) < 1)).2 (by norm_num) + have hm : Measurable (fun p : ℝ × (Fin N → ℝ) => + pointwiseArchIntegrand N p.2 p.1 * density N p.2) := by + exact (((measurable_const.sub (measurable_reflectionProduct N)).mul + (measurable_omega.comp measurable_fst)).div measurable_fst).mul + ((measurable_density N).comp measurable_snd) + apply (hp.mul_prod (integrableOn_inverseHalfSum_density N)).mono' hm.aestronglyMeasurable + rw [Measure.prod_restrict] + filter_upwards [ae_restrict_mem (measurableSet_Ioo.prod (isOpen_orderedDomain N).measurableSet)] with p hp + have hb := pointwiseArchIntegrand_bounds hp.2 hp.1 + rw [Real.norm_eq_abs, abs_of_nonneg (mul_nonneg hb.1 (density_pos hp.2).le)] + exact (mul_le_mul_of_nonneg_right hb.2 (density_pos hp.2).le).trans_eq (by ring) + +theorem integrableOn_pointwiseArchIntegral_density (N : ℕ) : + IntegrableOn (fun y => pointwiseArchIntegral N y * density N y) (orderedDomain N) := by + simpa only [IntegrableOn, pointwiseArchIntegral, integral_mul_const] using + (integrable_jointArchIntegrand N).integral_prod_right + +theorem expectation_pointwiseArchIntegrand (N : ℕ) {x : ℝ} (hx : 0 ≤ x) : + expectation N (fun y => pointwiseArchIntegrand N y x) = momentIntegrand N x := by + have he (y : Fin N → ℝ) : + pointwiseArchIntegrand N y x * density N y = + ((1 - reflectionProduct N x y) * density N y) * (omega x / x) := by + unfold pointwiseArchIntegrand + ring + unfold expectation + simp_rw [he] + rw [integral_mul_const] + unfold momentIntegrand + rw [← expectation_deficit N hx] + unfold expectation + ring + + +theorem integral_momentIntegrand_eq_expectation (N : ℕ) : + (∫ x in Ioo 0 1, momentIntegrand N x) = expectation N (pointwiseArchIntegral N) := by + calc + (∫ x in Ioo 0 1, momentIntegrand N x) = + ∫ x in Ioo 0 1, expectation N (fun y => pointwiseArchIntegrand N y x) := by + apply setIntegral_congr_fun measurableSet_Ioo + intro x hx + exact (expectation_pointwiseArchIntegrand N hx.1.le).symm + _ = (∫ x in Ioo 0 1, ∫ y in orderedDomain N, + pointwiseArchIntegrand N y x * density N y) / normalizer N := by + simp only [expectation, integral_div] + _ = expectation N (pointwiseArchIntegral N) := by + rw [integral_integral_swap (integrable_jointArchIntegrand N)] + simp only [expectation, pointwiseArchIntegral, integral_mul_const] + + +theorem fourthRoot_sum_le_sum {ι : Type*} (s : Finset ι) (a : ι → ℝ) + (ha : ∀ i ∈ s, 0 ≤ a i) : + (∑ i ∈ s, a i) ^ (1 / 4 : ℝ) ≤ ∑ i ∈ s, (a i) ^ (1 / 4 : ℝ) := by + classical + induction s using Finset.induction_on with + | empty => simp + | @insert i s hi ih => + have hai := ha i (Finset.mem_insert_self _ _) + have has : ∀ j ∈ s, 0 ≤ a j := fun j hj => ha j (Finset.mem_insert_of_mem hj) + rw [Finset.sum_insert hi, Finset.sum_insert hi] + exact (Real.rpow_add_le_add_rpow hai (Finset.sum_nonneg has) (by norm_num) (by norm_num)).trans + (add_le_add_right (ih has) _) + +theorem inverseQuarterSum_le_inverseHalfSum {N : ℕ} {y : Fin N → ℝ} + (hy : y ∈ orderedDomain N) : + (∑ i, (y i)⁻¹) ^ (1 / 4 : ℝ) ≤ inverseHalfSum N y := by + refine (fourthRoot_sum_le_sum Finset.univ (fun i => (y i)⁻¹) + (fun i _ => inv_nonneg.mpr (hy.2 i).1.le)).trans ?_ + apply Finset.sum_le_sum + intro i _ + rw [Real.inv_rpow (hy.2 i).1.le, ← Real.rpow_neg (hy.2 i).1.le] + exact Real.rpow_le_rpow_of_exponent_ge (hy.2 i).1 (hy.2 i).2.le (by norm_num) + +theorem integrableOn_inverseQuarterSum_density (N : ℕ) : + IntegrableOn (fun y => (∑ i, (y i)⁻¹) ^ (1 / 4 : ℝ) * density N y) (orderedDomain N) := by + have hm : Measurable (fun y : Fin N → ℝ => (∑ i, (y i)⁻¹) ^ (1 / 4 : ℝ) * density N y) := + ((Finset.measurable_sum _ fun i _ => (measurable_pi_apply i).inv).pow_const _).mul (measurable_density N) + apply (integrableOn_inverseHalfSum_density N).mono' hm.aestronglyMeasurable + filter_upwards [ae_restrict_mem (isOpen_orderedDomain N).measurableSet] with y hy + rw [Real.norm_eq_abs, abs_of_nonneg (mul_nonneg (Real.rpow_nonneg (Finset.sum_nonneg + fun i _ => inv_nonneg.mpr (hy.2 i).1.le) _) (density_pos hy).le)] + exact mul_le_mul_of_nonneg_right (inverseQuarterSum_le_inverseHalfSum hy) (density_pos hy).le + +theorem integrableOn_inverseQuarterCoordinate_density (N : ℕ) (i : Fin N) : + IntegrableOn (fun y => (y i) ^ (-(1 / 4 : ℝ)) * density N y) (orderedDomain N) := by + have hm : Measurable (fun y : Fin N → ℝ => (y i) ^ (-(1 / 4 : ℝ)) * density N y) := + ((measurable_pi_apply i).pow_const _).mul (measurable_density N) + apply (integrableOn_coordinate_weight N i).mono' hm.aestronglyMeasurable + filter_upwards [ae_restrict_mem (isOpen_orderedDomain N).measurableSet] with y hy + rw [Real.norm_eq_abs, abs_of_nonneg (mul_nonneg (Real.rpow_pos_of_pos (hy.2 i).1 _).le (density_pos hy).le)] + exact mul_le_mul_of_nonneg_right + (Real.rpow_le_rpow_of_exponent_ge (hy.2 i).1 (hy.2 i).2.le (by norm_num)) (density_pos hy).le + +theorem expectation_mono {N : ℕ} {f g : (Fin N → ℝ) → ℝ} + (hf : IntegrableOn (fun y => f y * density N y) (orderedDomain N)) + (hg : IntegrableOn (fun y => g y * density N y) (orderedDomain N)) + (hfg : ∀ y ∈ orderedDomain N, f y ≤ g y) : expectation N f ≤ expectation N g := by + apply div_le_div_of_nonneg_right _ (normalizer_pos N).le + apply setIntegral_mono_on hf hg (isOpen_orderedDomain N).measurableSet + intro y hy + exact mul_le_mul_of_nonneg_right (hfg y hy) (density_pos hy).le + +theorem expectation_const_mul (N : ℕ) (a : ℝ) (f : (Fin N → ℝ) → ℝ) : + expectation N (fun y => a * f y) = a * expectation N f := by + simp only [expectation, mul_assoc, integral_const_mul, mul_div_assoc] + + + +theorem integral_inverse_comparison {N : ℕ} (hN : 1 ≤ N) : + (1 / 96 : ℝ) * expectation N (fun y => (y ⟨0, by omega⟩) ^ (-(1 / 4 : ℝ))) ≤ + (∫ x in Ioo 0 1, momentIntegrand N x) ∧ + (∫ x in Ioo 0 1, momentIntegrand N x) ≤ + (32 / 3 : ℝ) * expectation N (fun y => (∑ i, (y i)⁻¹) ^ (1 / 4 : ℝ)) := by + let i : Fin N := ⟨0, by omega⟩ + rw [integral_momentIntegrand_eq_expectation] + constructor + · rw [← expectation_const_mul] + apply expectation_mono + · simpa only [IntegrableOn, i, mul_assoc] using (integrableOn_inverseQuarterCoordinate_density N i).const_mul (1 / 96 : ℝ) + · exact integrableOn_pointwiseArchIntegral_density N + · intro y hy + apply pointwiseArchIntegral_lower hy i + intro j + exact hy.1.monotone (show i ≤ j by exact Nat.zero_le _) + · rw [← expectation_const_mul] + apply expectation_mono (integrableOn_pointwiseArchIntegral_density N) + · simpa only [IntegrableOn, mul_assoc] using (integrableOn_inverseQuarterSum_density N).const_mul (32 / 3 : ℝ) + · intro y hy + exact pointwiseArchIntegral_upper hN hy + +end + + +noncomputable section +open scoped BigOperators + + +def bandRank (v : Triangle) : ℤ := if v.2.2 then 2 * v.1 else 2 * v.1 + 1 + +def bandVertex (k : ℤ) : Triangle := + if k % 2 = 0 then up (k / 2) 0 else down (k / 2) 0 + +@[simp] theorem bandVertex_band (k : ℤ) : (bandVertex k).2.1 = 0 := by + simp only [bandVertex]; split <;> rfl + +@[simp] theorem bandRank_bandVertex (k : ℤ) : bandRank (bandVertex k) = k := by + simp only [bandVertex] + split <;> simp only [bandRank, up, down, Bool.false_eq_true, reduceIte, ite_true] + all_goals omega + +theorem bandVertex_bandRank (v : Triangle) (hv : v.2.1 = 0) : bandVertex (bandRank v) = v := by + rcases v with ⟨i, j, b⟩ + change j = 0 at hv + subst j + cases b <;> simp [bandRank, bandVertex, up, down, Int.add_ediv] + +@[simp] theorem bandRank_up (k : ℤ) : bandRank (up k 0) = 2 * k := rfl +@[simp] theorem bandRank_down (k : ℤ) : bandRank (down k 0) = 2 * k + 1 := rfl + + +theorem band_adjacent_iff {v w : Triangle} (hv : v.2.1 = 0) (hw : w.2.1 = 0) : + adjacent v w ↔ bandRank w = bandRank v + 1 ∨ bandRank w = bandRank v - 1 := by + rcases v with ⟨a, j, b⟩ + rcases w with ⟨a', j', b'⟩ + change j = 0 at hv + change j' = 0 at hw + subst j; subst j' + cases b <;> cases b' <;> simp [adjacent, upDownAdjacent, bandRank] <;> omega + +def unitAdjacent (a b : ℤ) : Prop := b = a + 1 ∨ b = a - 1 + +theorem int_chain_directed {l : List ℤ} {a b s : ℤ} + (hs : s = 1 ∨ s = -1) (h : (a :: b :: l).IsChain unitAdjacent) + (hn : (a :: b :: l).Nodup) (hab : b = a + s) : + (a :: b :: l).IsChain (fun x y => y = x + s) := by + induction l generalizing a b with + | nil => simpa [unitAdjacent] using hab + | cons c l ih => + have htl := (List.isChain_cons_cons.mp h).2 + have hbc := (List.isChain_cons_cons.mp htl).1 + have hac : c ≠ a := by + intro heq + exact (List.nodup_cons.mp hn).1 (by simp [← heq]) + have hbc' : c = b + s := by + rcases hs with rfl | rfl <;> rcases hbc with hbc | hbc <;> omega + exact List.isChain_cons_cons.mpr ⟨hab, ih htl hn.of_cons hbc'⟩ + +theorem int_chain_direction {l : List ℤ} (h : l.IsChain unitAdjacent) (hn : l.Nodup) : + ∃ s : ℤ, (s = 1 ∨ s = -1) ∧ l.IsChain (fun x y => y = x + s) := by + rcases l with _ | ⟨a, l⟩ + · exact ⟨1, Or.inl rfl, List.isChain_nil⟩ + rcases l with _ | ⟨b, l⟩ + · exact ⟨1, Or.inl rfl, List.isChain_singleton _⟩ + rcases (List.isChain_cons_cons.mp h).1 with hab | hab + · exact ⟨1, Or.inl rfl, int_chain_directed (Or.inl rfl) h hn hab⟩ + · exact ⟨-1, Or.inr rfl, int_chain_directed (Or.inr rfl) h hn (by omega)⟩ + +theorem directed_chain_eq_range {l : List ℤ} {a s : ℤ} + (hh : l.head? = some a) (hc : l.IsChain (fun x y => y = x + s)) : + l = (List.range l.length).map (fun n : ℕ => a + s * n) := by + induction l generalizing a with + | nil => simp at hh + | cons b l ih => + have hba : b = a := by simpa using hh + subst b + cases l with + | nil => simp + | cons b l => + obtain ⟨hba, htl⟩ := List.isChain_cons_cons.mp hc + have he := ih (a := b) rfl htl + change a :: b :: l = (List.range ((b :: l).length + 1)).map (fun n : ℕ => a + s * n) + rw [List.range_succ_eq_map, List.map_cons, List.map_map] + simp only [Nat.cast_zero, mul_zero, add_zero] + congr 1 + apply he.trans + apply List.map_congr_left + intro n hn + dsimp only [Function.comp_def] + rw [Nat.cast_succ, hba] + ring + + +def integerLinePath (k : ℤ) : List ℤ := + (List.range (k.natAbs + 1)).map (fun n : ℕ => if k < 0 then -(n : ℤ) else (n : ℤ)) + +@[simp] theorem integerLinePath_length (k : ℤ) : (integerLinePath k).length = k.natAbs + 1 := by + simp [integerLinePath] + +@[simp] theorem integerLinePath_head (k : ℤ) : (integerLinePath k).head? = some 0 := by + simp [integerLinePath, List.head?_map, List.head?_range] + +@[simp] theorem integerLinePath_last (k : ℤ) : (integerLinePath k).getLast? = some k := by + simp only [integerLinePath, List.getLast?_map, List.getLast?_range, Nat.add_eq_zero_iff, + Nat.one_ne_zero, and_false, ↓reduceIte, Nat.add_sub_cancel, Option.map_some] + congr 1 + split + · rw [Int.natCast_natAbs, abs_of_neg (by assumption)]; ring + · rw [Int.natAbs_of_nonneg (by omega)] + +theorem integerLinePath_nodup (k : ℤ) : (integerLinePath k).Nodup := by + apply List.Nodup.map _ List.nodup_range + intro a b hab + by_cases hk : k < 0 <;> simpa [hk] using hab + +theorem integerLinePath_chain (k : ℤ) : (integerLinePath k).IsChain unitAdjacent := by + apply (List.isChain_map _).mpr + apply (List.isChain_range_succ _ _).mpr + intro m hm + by_cases hk : k < 0 + · simp only [hk, ↓reduceIte, unitAdjacent]; right; push_cast; ring + · simp only [hk, ↓reduceIte, unitAdjacent]; left; push_cast; ring + +end +end CriticalStrip + +end OAI diff --git a/lean/OAI/Combinatorics/StripMass/ArchRoots.lean b/lean/OAI/Combinatorics/StripMass/ArchRoots.lean new file mode 100644 index 0000000000000000000000000000000000000000..94b8f6a3cc68b322e75b8038c4ed4853b76b22aa --- /dev/null +++ b/lean/OAI/Combinatorics/StripMass/ArchRoots.lean @@ -0,0 +1,569 @@ +import Mathlib +import OAI.Combinatorics.StripMass.BottomGauge + +namespace OAI + +/-! Critical honeycomb strip paths, polynomial identities and crossing mass. -/ + + +namespace CriticalStrip.Diagram +noncomputable section +open scoped Classical BigOperators LaurentPolynomial + +abbrev ArchShiftIndex := Bool × Bool × Fin 2 + +def archRootShift : ArchShiftIndex → ℕ + | (false,false,s) => s.val+2 + | (false,true,s) => s.val+10 + | (true,false,s) => 14-s.val + | (true,true,s) => 6-s.val + +lemma archRootShift_lt (k : ArchShiftIndex) : archRootShift k<16 := by + rcases k with ⟨a,b,s⟩ + cases a <;> cases b <;> fin_cases s <;> decide + +lemma archRootShift_injective : Function.Injective archRootShift := by + decide + +def archRootCoefficient (b : Bool) (k : ArchShiftIndex) : ℂ := + if b then phase^3/(phase^archRootShift k) else phase^archRootShift k + +lemma archRootCoefficient_ne_zero (b : Bool) (k : ArchShiftIndex) : + archRootCoefficient b k≠0 := by + cases b <;> simp [archRootCoefficient,phase_ne_zero] + +lemma archRootCoefficient_injective (b : Bool) : Function.Injective (archRootCoefficient b) := by + intro k l h + apply archRootShift_injective + apply phase_primitive.pow_inj (archRootShift_lt k) (archRootShift_lt l) + cases b with + | false => exact h + | true => + simp only [archRootCoefficient,ite_true] at h + apply inv_injective + exact mul_left_cancel₀ (pow_ne_zero 3 phase_ne_zero) + (by simpa only [div_eq_mul_inv] using h) + +abbrev ArchRootIndex (n : ℕ) := Option (Fin (n+1) × Bool × ArchShiftIndex) + +def archRootExponent {n : ℕ} : ArchRootIndex n → Fin (n+2) → ℤ + | none => 0 + | some (j,b,_) => if b then -(variableExponent j.succ) else variableExponent j.succ + +def archRootScalar {n : ℕ} : ArchRootIndex n → ℂ + | none => 1 + | some (_,b,k) => archRootCoefficient b k + +def archRoot {n : ℕ} (k : ArchRootIndex n) : SpectralField (n+2) := + evalLaurent (monomialL (archRootExponent k) (archRootScalar k)) + +lemma archRootScalar_ne_zero {n : ℕ} (k : ArchRootIndex n) : archRootScalar k≠0 := by + cases k with + | none => exact one_ne_zero + | some k => exact archRootCoefficient_ne_zero k.2.1 k.2.2 + +lemma archRoot_ne_zero {n : ℕ} (k : ArchRootIndex n) : archRoot k≠0 := by + intro h + have he : monomialL (archRootExponent k) (archRootScalar k)=0 := + IsFractionRing.injective (SpectralRing (n+2)) (SpectralField (n+2)) + (by simpa only [archRoot, evalLaurent,map_zero] using h) + exact archRootScalar_ne_zero k (AddMonoidAlgebra.single_eq_zero.mp he) + +lemma archRootExponent_support {n : ℕ} (j : Fin (n+1)) (b : Bool) (k : ArchShiftIndex) (i : Fin (n+2)) : + archRootExponent (some (j,b,k)) i≠0 ↔ i=j.succ := by + cases b <;> simp [archRootExponent,variableExponent,Pi.single_apply] + +lemma archRoot_injective {n : ℕ} : Function.Injective (@archRoot n) := by + intro x y h + have he : monomialL (archRootExponent x) (archRootScalar x) = + monomialL (archRootExponent y) (archRootScalar y) := + IsFractionRing.injective (SpectralRing (n+2)) (SpectralField (n+2)) h + rcases AddMonoidAlgebra.single_inj.mp he with ⟨he,hc⟩|⟨hz,_⟩ + · cases x with + | none => + cases y with + | none => rfl + | some y => + have hh := (archRootExponent_support y.1 y.2.1 y.2.2 y.1.succ).mpr rfl + rw [←he] at hh + exact (hh rfl).elim + | some x => + cases y with + | none => + have hh := (archRootExponent_support x.1 x.2.1 x.2.2 x.1.succ).mpr rfl + rw [he] at hh + exact (hh rfl).elim + | some y => + rcases x with ⟨j,b,k⟩ + rcases y with ⟨l,a,r⟩ + have hi : j=l := by + have hh := (archRootExponent_support j b k j.succ).mpr rfl + rw [he] at hh + exact Fin.succ_injective _ ((archRootExponent_support l a r j.succ).mp hh) + subst l + have hb : b=a := by + have hh := congrFun he j.succ + cases b <;> cases a <;> simp [archRootExponent,variableExponent] at hh ⊢ + subst a + have hk := archRootCoefficient_injective b hc + rw [hk] + · exact (archRootScalar_ne_zero _ hz).elim + +lemma archRoot_none (n : ℕ) : archRoot (none : ArchRootIndex n) = 1 := by + simp [archRoot,archRootExponent,archRootScalar,monomialL,evalLaurent,← AddMonoidAlgebra.one_def] + +lemma archRoot_some {n : ℕ} (j : Fin (n+1)) (b : Bool) (k : ArchShiftIndex) : + archRoot (some (j,b,k)) = + if b then constF (n+2) phase^3/(constF (n+2) phase^archRootShift k*variableF j.succ) + else constF (n+2) phase^archRootShift k*variableF j.succ := by + cases b <;> simp [archRoot,archRootExponent,archRootScalar,archRootCoefficient, + evalLaurent_monomial_product,variableExponent,Pi.single_apply,constF,div_eq_mul_inv, + Finset.prod_ite_eq'] + all_goals ac_rfl + + + +lemma arch_pair_zero {n m : ℕ} (f : Laurent (n+2)) + (hp : ∀ σ,permLaurent σ f=f) (s : ℕ) (hs : pairEvaluation n s f=0) + (j : Fin (n+1)) (z : Fin (n+2) → SpectralField m) (hz : ∀ i,z i≠0) + (he : z j.succ=constF m phase^s*z 0) : torusEvaluation z hz f=0 := by + let σ := Equiv.swap (1:Fin (n+2)) j.succ + have hσ0 : σ 0=0 := Equiv.swap_apply_of_ne_of_ne (by intro h; have : (0:ℕ)=1 := congrArg Fin.val h; omega) (Fin.succ_ne_zero j).symm + have hσ1 : σ 1=j.succ := Equiv.swap_apply_left _ _ + have hzero := pairEvaluation_zero_universal s f hs (z ∘ σ) (fun i=>hz _) + (by simpa only [Function.comp_apply,hσ0,hσ1] using he) + rw [←torusEvaluation_permLaurent,hp] at hzero + exact hzero + +lemma arch_pair_zero_reverse {n m : ℕ} (f : Laurent (n+2)) + (hp : ∀ σ,permLaurent σ f=f) (s : ℕ) (hs : pairEvaluation n s f=0) + (j : Fin (n+1)) (z : Fin (n+2) → SpectralField m) (hz : ∀ i,z i≠0) + (he : z 0=constF m phase^s*z j.succ) : torusEvaluation z hz f=0 := by + let σ := Equiv.swap (0:Fin (n+2)) j.succ + have hzero := arch_pair_zero f hp s hs j (z ∘ σ) (fun i=>hz _) + (by simpa only [σ,Function.comp_apply,Equiv.swap_apply_left,Equiv.swap_apply_right] using he) + rw [←torusEvaluation_permLaurent,hp] at hzero + exact hzero + + + + + + + +def archEvaluate {n : ℕ} (f : Laurent (n+1)) (x : SpectralField (n+1)) (hx : x≠0) : SpectralField (n+1) := + torusEvaluation (Function.update variableF 0 x) + (fun j => by by_cases h:j=0 <;> simp [h,hx,variableF_ne_zero]) f + +lemma archEvaluate_neg {n : ℕ} (f : Laurent (n+1)) (h : signLaurent 0 f = f) + (x : SpectralField (n+1)) (hx : x≠0) : + archEvaluate f (-x) (neg_ne_zero.mpr hx) = archEvaluate f x hx := by + have he := torusEvaluation_signLaurent 0 (Function.update variableF 0 x) + (fun j => by by_cases h:j=0 <;> simp [h,hx,variableF_ne_zero]) f + rw [h] at he + simpa only [Function.update_self,Function.update_idem,archEvaluate] using he.symm + +lemma archEvaluate_reflect {n : ℕ} (f : Laurent (n+1)) (h : rowReflectLaurent 0 f = f) + (x : SpectralField (n+1)) (hx : x≠0) : + archEvaluate f (constF (n+1) phase^3/x) + (div_ne_zero (pow_ne_zero _ (constF_phase_ne_zero _)) hx) = archEvaluate f x hx := by + have he := torusEvaluation_rowReflect 0 (Function.update variableF 0 x) + (fun j => by by_cases h:j=0 <;> simp [h,hx,variableF_ne_zero]) f + rw [h] at he + simpa only [Function.update_self,Function.update_idem,archEvaluate] using he.symm + +lemma archEvaluate_pair {n : ℕ} (f : Laurent (n+2)) + (hp : ∀ σ,permLaurent σ f=f) (s : ℕ) (hs : pairEvaluation n s f=0) + (j : Fin (n+1)) (b : Bool) : + archEvaluate f ((if b then (constF (n+2) phase^s)⁻¹ else constF (n+2) phase^s)*variableF j.succ) + (by cases b <;> simp [constF_phase_ne_zero,variableF_ne_zero]) = 0 := by + unfold archEvaluate + cases b with + | false => + apply arch_pair_zero_reverse f hp s hs j + simp only [Function.update_self,Function.update_of_ne (Fin.succ_ne_zero j),Bool.false_eq_true,ite_false] + | true => + apply arch_pair_zero f hp s hs j + simp only [Function.update_self,Function.update_of_ne (Fin.succ_ne_zero j),ite_true] + field_simp [constF_phase_ne_zero] + +lemma archShift_value (k : ArchShiftIndex) : + phase^archRootShift k = + (if k.2.1 then -1 else 1) * + (if k.1 then (phase^(k.2.2.val+2))⁻¹ else phase^(k.2.2.val+2)) := by + rcases k with ⟨a,b,s⟩ + have hp := phase_more_powers + cases a <;> cases b <;> fin_cases s <;> + simp [archRootShift,hp.1,hp.2.1,hp.2.2.1,hp.2.2.2.1,hp.2.2.2.2.1,hp.2.2.2.2.2] + +lemma archEvaluate_shift {n : ℕ} (f : Laurent (n+2)) + (hp : ∀ σ,permLaurent σ f=f) (hsg : signLaurent 0 f=f) + (h2 : pairEvaluation n 2 f=0) (h3 : pairEvaluation n 3 f=0) + (j : Fin (n+1)) (k : ArchShiftIndex) : + archEvaluate f (constF (n+2) phase^archRootShift k*variableF j.succ) + (mul_ne_zero (pow_ne_zero _ (constF_phase_ne_zero _)) (variableF_ne_zero _)) = 0 := by + have hbase := archEvaluate_pair f hp (k.2.2.val+2) + (by rcases k with ⟨a,b,s⟩; fin_cases s <;> assumption) j k.1 + have hm : constF (n+2) phase^archRootShift k*variableF j.succ = + if k.2.1 then -((if k.1 then (constF (n+2) phase^(k.2.2.val+2))⁻¹ + else constF (n+2) phase^(k.2.2.val+2))*variableF j.succ) + else ((if k.1 then (constF (n+2) phase^(k.2.2.val+2))⁻¹ + else constF (n+2) phase^(k.2.2.val+2))*variableF j.succ) := by + have hc := congrArg (algebraMap ℂ (SpectralField (n+2))) (archShift_value k) + rcases k with ⟨a,b,s⟩ + cases a <;> cases b <;> + simp only [Bool.false_eq_true,ite_false,ite_true,map_pow,map_mul,map_neg,map_one,map_inv₀] at hc ⊢ + all_goals dsimp only [constF]; rw [hc]; simp + cases hb : k.2.1 + · simpa only [hm,hb,Bool.false_eq_true,ite_false] using hbase + · have hh := (archEvaluate_neg f hsg _ _).trans hbase + simpa only [hm,hb,ite_true] using hh + + + +lemma archEvaluate_roots {n : ℕ} (f : Laurent (n+2)) + (hp : ∀ σ,permLaurent σ f=f) (hsg : signLaurent 0 f=f) + (hr : rowReflectLaurent 0 f=f) (hflat : firstFlatEvaluation (n+1) f=0) + (h2 : pairEvaluation n 2 f=0) (h3 : pairEvaluation n 3 f=0) + (k : ArchRootIndex n) : archEvaluate f (archRoot k) (archRoot_ne_zero k)=0 := by + cases k with + | none => + unfold archEvaluate + apply firstFlatEvaluation_zero_universal f hflat + simp only [Function.update_self,archRoot_none] + | some k => + rcases k with ⟨j,b,k⟩ + cases b with + | false => + simpa only [archRoot_some,Bool.false_eq_true,ite_false] using archEvaluate_shift f hp hsg h2 h3 j k + | true => + have hh := (archEvaluate_reflect f hr _ _).trans (archEvaluate_shift f hp hsg h2 h3 j k) + simpa only [archRoot_some,ite_true] using hh + + + +theorem archLaurent_interpolation_zero {n : ℕ} (f : Laurent (n+2)) + (hb : LaurentBox f (fun _ =>4*(n+2))) + (hp : ∀ σ,permLaurent σ f=f) (hsg : signLaurent 0 f=f) + (hr : rowReflectLaurent 0 f=f) (hflat : firstFlatEvaluation (n+1) f=0) + (h2 : pairEvaluation n 2 f=0) (h3 : pairEvaluation n 3 f=0) : f=0 := by + apply fullPeel_injective (0:Fin (n+2)) + rw [map_zero] + refine laurent_eq_zero_of_many_roots (fullPeel (0:Fin (n+2)) f) (4*(n+2)) + (hb.fullPeel 0) (Finset.univ.image (@archRoot n)) ?_ + (fun z hz => by obtain ⟨k,_,rfl⟩ := Finset.mem_image.mp hz; exact archRoot_ne_zero k) ?_ + · rw [Finset.card_image_of_injective _ archRoot_injective,Finset.card_univ] + simp only [ArchRootIndex,ArchShiftIndex,Fintype.card_option,Fintype.card_prod, + Fintype.card_fin,Fintype.card_bool] + omega + · intro z hz + obtain ⟨k,_,rfl⟩ := Finset.mem_image.mp hz + rw [fullPeel_eval] + exact archEvaluate_roots f hp hsg hr hflat h2 h3 k + +end + + + + +noncomputable section +open scoped Classical BigOperators + + + +def previousCoeff {K : Type*} [Semiring K] (n : ℕ) (P : Polynomial K) : K := + if n=0 then 0 else P.coeff (n-1) + +lemma previousCoeff_map {K L : Type*} [Semiring K] [Semiring L] + (g : K →+* L) (n : ℕ) (P : Polynomial K) : + previousCoeff n (P.map g) = g (previousCoeff n P) := by + by_cases h:n=0 <;> simp [previousCoeff,h] + + +def nextScalar {K : Type*} [CommRing K] (f : ℂ →+* K) {n : ℕ} (a : Fin n → K) : Polynomial K := + firstScalarHom f a (scalarPolynomial (n+1) d rho (by exact_mod_cast d_ne_zero)) + +lemma map_scalarValue {K L : Type*} [CommRing K] [CommRing L] + (g : K →+* L) (f : ℂ →+* K) {n : ℕ} (a : Fin n → K) : + g (scalarValue f a) = scalarValue (g.comp f) (g ∘ a) := by + exact MvPolynomial.map_eval₂Hom _ _ _ _ + +lemma nextScalar_map {K L : Type*} [CommRing K] [CommRing L] + (g : K →+* L) (f : ℂ →+* K) {n : ℕ} (a : Fin n → K) : + (nextScalar f a).map g = nextScalar (g.comp f) (g ∘ a) := + map_firstScalarHom g f a _ + +lemma nextScalar_top {K : Type*} [CommRing K] + (f : ℂ →+* K) {n : ℕ} (a : Fin n → K) : + (nextScalar f a).coeff n = scalarValue f a := + scalarPolynomial_first_top_continuation f n _ _ _ _ + +lemma nextScalar_degree {K : Type*} [CommRing K] + (f : ℂ →+* K) {n : ℕ} (a : Fin n → K) : (nextScalar f a).natDegree ≤ n := + scalarPolynomial_first_degree f n _ _ _ _ + + +def headPerm {n : ℕ} (σ : Equiv.Perm (Fin n)) : Equiv.Perm (Fin (n+1)) where + toFun := Fin.cases 0 (fun i => (σ i).succ) + invFun := Fin.cases 0 (fun i => (σ.symm i).succ) + left_inv i := by induction i using Fin.cases <;> simp + right_inv i := by induction i using Fin.cases <;> simp + +lemma nextScalar_permute {K : Type*} [CommRing K] + (f : ℂ →+* K) {n : ℕ} (a : Fin n → K) (σ : Equiv.Perm (Fin n)) : + nextScalar f (a ∘ σ) = nextScalar f a := by + have h := scalarValue_permute (Polynomial.C.comp f) + (Fin.cons Polynomial.X (fun i => Polynomial.C (a i))) (headPerm σ) + have hv : (Fin.cons Polynomial.X (fun i => Polynomial.C (a i))) ∘ headPerm σ = + Fin.cons Polynomial.X (fun i => Polynomial.C (a (σ i))) := by + funext i + induction i using Fin.cases <;> rfl + rw [hv] at h + exact h + + + +def scalarArchNumerator {K : Type*} [CommRing K] + (f : ℂ →+* K) {n : ℕ} (a : Fin n → K) : K := + (∑ i,a i) * scalarValue f a ^ 2 - f (2*(d:ℂ)-1) * scalarValue f a * previousCoeff n (nextScalar f a) + +lemma map_scalarArchNumerator {K L : Type*} [CommRing K] [CommRing L] + (g : K →+* L) (f : ℂ →+* K) {n : ℕ} (a : Fin n → K) : + g (scalarArchNumerator f a) = scalarArchNumerator (g.comp f) (g ∘ a) := by + simp only [scalarArchNumerator,map_sub,map_mul,map_sum,map_pow,map_scalarValue, + ←previousCoeff_map,nextScalar_map,RingHom.comp_apply,Function.comp_apply] + +lemma scalarArchNumerator_permute {K : Type*} [CommRing K] + (f : ℂ →+* K) {n : ℕ} (a : Fin n → K) (σ : Equiv.Perm (Fin n)) : + scalarArchNumerator f (a ∘ σ) = scalarArchNumerator f a := by + rw [scalarArchNumerator,scalarValue_permute,nextScalar_permute] + have h : (∑i,a (σ i))=∑i,a i := Equiv.sum_comp σ a + exact congrArg (fun z => z*scalarValue f a^2-f (2*(d:ℂ)-1)*scalarValue f a*previousCoeff n (nextScalar f a)) h + +def rowCosineL {n : ℕ} (i : Fin n) : Laurent n := + cosineL ((2:ℤ) • variableExponent i) (phase^3)⁻¹ + +lemma rowCosineL_map {n : ℕ} (i : Fin n) : evalLaurent (rowCosineL i)=spectralA i := by + rw [rowCosineL,cosineL_map _ _ (inv_ne_zero (pow_ne_zero _ phase_ne_zero)),map_monomialL_two_variable] + simp only [constF,map_inv₀,map_pow] + congr 1 + simp [constF,div_eq_mul_inv,mul_comm] + +lemma rowCosineL_algebraMap {n : ℕ} (i : Fin n) : + algebraMap (SpectralRing n) (SpectralField n) (rowCosineL i)=spectralA i := rowCosineL_map i + +lemma rowCosineL_box {n : ℕ} (i : Fin n) : LaurentBox (rowCosineL i) (fun _=>2) := by + apply LaurentBox.cosine + intro j + by_cases h:j=i <;> simp [variableExponent,h] + +lemma evalLaurent_constant_comp (n : ℕ) : + (algebraMap (SpectralRing n) (SpectralField n)).comp (constantL n) = + algebraMap ℂ (SpectralField n) := by + ext z + exact map_constantL n z + +lemma scalarValue_rowCosine (n : ℕ) : + scalarValue (constantL n) rowCosineL = polynomialVacuumVector n (empty n) := by + apply IsFractionRing.injective (SpectralRing n) (SpectralField n) + rw [show algebraMap (SpectralRing n) (SpectralField n) _ = _ from + map_scalarValue _ (constantL n) rowCosineL] + simp only [evalLaurent_constant_comp,Function.comp_def,rowCosineL_algebraMap] + change scalarValue _ spectralA = evalLaurent (polynomialVacuumVector n (empty n)) + rw [polynomialVacuumVector_eval,rationalVacuum_empty] + exact scalarPolynomial_eval_spectral n + +lemma nextScalar_rowCosine (n : ℕ) : + nextScalar (constantL n) rowCosineL = (vacuumData n).P (empty (n+1)) := by + apply Polynomial.map_injective (algebraMap (SpectralRing n) (SpectralField n)) + (IsFractionRing.injective _ _) + rw [nextScalar_map,(vacuumData n).map_P,rationalNodalPolynomial_empty] + simp only [evalLaurent_constant_comp,Function.comp_def,rowCosineL_algebraMap,nextScalar] + + +def archCandidate (n : ℕ) : Laurent n := scalarArchNumerator (constantL n) rowCosineL + +lemma archCandidate_eval (n : ℕ) : + evalLaurent (archCandidate n)=scalarArchNumerator (algebraMap ℂ (SpectralField n)) spectralA := by + unfold archCandidate evalLaurent + rw [map_scalarArchNumerator] + simp only [evalLaurent_constant_comp,Function.comp_def,rowCosineL_algebraMap] + +lemma scalarValue_rowCosine_box (n : ℕ) : + LaurentBox (scalarValue (constantL n) rowCosineL) (fun _=>2*(n-1)) := by + rw [scalarValue_rowCosine] + cases n with + | zero => intro e he i; exact Fin.elim0 i + | succ n => exact (vacuumData n).box _ + +lemma previousCoeff_nextScalar_box (n : ℕ) : + LaurentBox (previousCoeff n (nextScalar (constantL n) rowCosineL)) (fun _=>2*n) := by + rw [nextScalar_rowCosine,previousCoeff] + split_ifs + · exact LaurentBox.zero _ + · exact (vacuumData n).box_P _ _ + +lemma archCandidate_box (n : ℕ) : LaurentBox (archCandidate n) (fun _=>4*n) := by + unfold archCandidate scalarArchNumerator + apply LaurentBox.sub + · have h := (LaurentBox.sum Finset.univ rowCosineL (fun _=>2) (fun i _=>rowCosineL_box i)).mul + ((scalarValue_rowCosine_box n).pow 2) + apply h.mono + intro i + have := i.isLt + simp only [Pi.add_apply] + omega + · have h := ((LaurentBox.constant (2*(d:ℂ)-1)).mul (scalarValue_rowCosine_box n)).mul (previousCoeff_nextScalar_box n) + apply h.mono + intro i + simp only [Pi.add_apply,Pi.zero_apply] + omega + +lemma archCandidate_permute {n : ℕ} (σ : Equiv.Perm (Fin n)) : + permLaurent σ (archCandidate n) = archCandidate n := by + apply IsFractionRing.injective (SpectralRing n) (SpectralField n) + change evalLaurent (permLaurent σ (archCandidate n))=evalLaurent (archCandidate n) + rw [←permSpectral_evalLaurent,archCandidate_eval] + rw [map_scalarArchNumerator] + have hc : (permSpectral σ).comp (algebraMap ℂ (SpectralField n)) = + algebraMap ℂ (SpectralField n) := by ext z; exact permSpectral_const σ z + simp only [hc,Function.comp_def,permSpectral_spectralA] + exact scalarArchNumerator_permute (algebraMap ℂ (SpectralField n)) spectralA σ + +lemma archCandidate_parity {n : ℕ} (i : Fin n) : signLaurent i (archCandidate n)=archCandidate n := by + apply IsFractionRing.injective (SpectralRing n) (SpectralField n) + change evalLaurent (signLaurent i (archCandidate n))=evalLaurent (archCandidate n) + rw [←signSpectral_evalLaurent,archCandidate_eval,map_scalarArchNumerator] + have hc : (signSpectral i).comp (algebraMap ℂ (SpectralField n)) = + algebraMap ℂ (SpectralField n) := by ext z; exact signSpectral_const i z + simp only [hc,Function.comp_def,signSpectral_spectralA] + +lemma archCandidate_row_reflection {n : ℕ} (i : Fin n) : + rowReflectLaurent i (archCandidate n)=archCandidate n := by + apply IsFractionRing.injective (SpectralRing n) (SpectralField n) + change evalLaurent (rowReflectLaurent i (archCandidate n))=evalLaurent (archCandidate n) + rw [←rowReflectSpectral_evalLaurent,archCandidate_eval,map_scalarArchNumerator] + have hc : (rowReflectSpectral i).comp (algebraMap ℂ (SpectralField n)) = + algebraMap ℂ (SpectralField n) := by ext z; exact rowReflectSpectral_const i z + simp only [hc,Function.comp_def,rowReflectSpectral_spectralA] + + + + + + +lemma previousCoeff_C_mul {K : Type*} [CommRing K] (n : ℕ) (a : K) (P : Polynomial K) : + previousCoeff n (Polynomial.C a * P) = a * previousCoeff n P := by + by_cases h : n=0 <;> simp [previousCoeff,h,Polynomial.coeff_C_mul] + +lemma previousCoeff_linear {K : Type*} [CommRing K] (n : ℕ) (a : K) (P : Polynomial K) : + previousCoeff (n+1) ((Polynomial.X+Polynomial.C a)*P) = + previousCoeff n P + a*P.coeff n := by + cases n with + | zero => simp [previousCoeff,add_mul] + | succ n => simp [previousCoeff,add_mul,Polynomial.coeff_X_mul,Polynomial.coeff_C_mul] + +lemma previousCoeff_quadratic {K : Type*} [CommRing K] + (n : ℕ) (a b : K) (P : Polynomial K) (hP : P.natDegree ≤ n) : + previousCoeff (n+2) (((Polynomial.X-Polynomial.C a)*(Polynomial.X-Polynomial.C b))*P) = + previousCoeff n P - (a+b)*P.coeff n := by + have hz : P.coeff (n+1)=0 := Polynomial.coeff_eq_zero_of_natDegree_lt (by omega) + have he : ((Polynomial.X-Polynomial.C a)*(Polynomial.X-Polynomial.C b))*P = + (Polynomial.X+Polynomial.C (-a))*((Polynomial.X+Polynomial.C (-b))*P) := by simp; ring + rw [he,show n+2=(n+1)+1 by omega,previousCoeff_linear,previousCoeff_linear] + simp only [add_mul,Polynomial.coeff_add,Polynomial.coeff_X_mul,Polynomial.coeff_C_mul,hz,mul_zero,add_zero] + ring + +lemma specialization_constant_comp {n m : ℕ} (φ : Laurent n →ₐ[ℂ] SpectralField m) : + φ.toRingHom.comp (constantL n) = algebraMap ℂ (SpectralField m) := by + ext z + exact φ.commutes z + +lemma torusEvaluation_rowCosine {n m : ℕ} (z : Fin n → SpectralField m) (hz : ∀i,z i≠0) (i : Fin n) : + torusEvaluation z hz (rowCosineL i) = torusCos ((z i)^2/constF m phase^3) := by + have ha := RationalAt.algebraMap (φ := (torusEvaluation z hz).toRingHom) + (F := SpectralField n) (rowCosineL i) + rw [rowCosineL_algebraMap] at ha + exact ha.unique (rationalAt_torusCos _ (((rationalAt_variable z hz i).pow 2).div + ((rationalAt_const (torusEvaluation z hz) phase).pow 3) (pow_ne_zero _ (constF_phase_ne_zero _))) + (div_ne_zero (pow_ne_zero _ (hz i)) (pow_ne_zero _ (constF_phase_ne_zero _)))) + +lemma firstFlatEvaluation_rowCosine {n : ℕ} (i : Fin (n+1)) : + firstFlatEvaluation n (rowCosineL i) = (Fin.cons (constF n c) spectralA : Fin (n+1) → SpectralField n) i := by + have ha := RationalAt.algebraMap (φ := (firstFlatEvaluation n).toRingHom) + (F := SpectralField (n+1)) (rowCosineL i) + rw [rowCosineL_algebraMap] at ha + exact ha.unique (rationalAt_firstFlat_spectralA i) + +lemma nextScalar_firstFlat (n : ℕ) : + (nextScalar (constantL (n+1)) rowCosineL).map (firstFlatEvaluation n).toRingHom = + Polynomial.C (∏ j:Fin n, (spectralA j+constF n C)) * + ((Polynomial.X+Polynomial.C (constF n C))*nextScalar (algebraMap ℂ (SpectralField n)) spectralA) := by + rw [nextScalar_rowCosine] + have h := congrFun (rationalNodalPolynomial_firstFlat + (vacuumData n).interpolant (vacuumData (n+1)).P (vacuumData (n+1)).map_P) + (empty (n+1)).padBottom + rw [rationalFirstZeroPolynomial_vacant,Pairing.padBottom_empty,rationalNodalPolynomial_empty] at h + exact h + +lemma matrixPolynomial_merge_empty {n m : ℕ} (r : ℕ) (hr : r+2≤n+1) + (P : Pairing n → Polynomial (SpectralField m)) : + matrixPolynomial (mergeMap r hr) P (empty (n+1))=P (empty n) := by + ext k + rw [matrixPolynomial_coeff,mergeMap_mulVec_empty] + +lemma matrixPolynomial_delete_empty {n m : ℕ} (r : ℕ) (hr : r+2≤n+2) + (P : Pairing n → Polynomial (SpectralField m)) : + matrixPolynomial (deletionMap r hr) P (empty (n+2))=P (empty n) := by + ext k + rw [matrixPolynomial_coeff,deletionMap_mulVec_empty] + +lemma nextScalar_pair_merge (n : ℕ) : + (nextScalar (constantL (n+2)) rowCosineL).map (pairEvaluation n 2).toRingHom = + Polynomial.C (mergePairScalar n) * ((Polynomial.X+Polynomial.C (fcos 0 (-1))) * + (nextScalar (constantL (n+1)) rowCosineL).map (mergeEvaluation n).toRingHom) := by + rw [nextScalar_rowCosine,nextScalar_rowCosine] + have h := congrFun (rationalNodalPolynomial_pair_merge + (polynomialVacuumVector (n+1)) (polynomialVacuumVector_eval (n+1)) + (vacuumData (n+1)).P (vacuumData (n+1)).map_P (vacuumData (n+1)).eval_P + (vacuumData (n+2)).P (vacuumData (n+2)).map_P) (empty (n+3)) + rw [matrixPolynomial_merge_empty] at h + simpa only [mergePairPolynomial,mul_assoc] using h + +lemma nextScalar_pair_delete (n : ℕ) : + (nextScalar (constantL (n+2)) rowCosineL).map (pairEvaluation n 3).toRingHom = + Polynomial.C (deletePairScalar n) * (((Polynomial.X-Polynomial.C (fcos 0 (-9)))*(Polynomial.X-Polynomial.C (fcos 0 9))) * + (nextScalar (constantL n) rowCosineL).map (deleteEvaluation n).toRingHom) := by + rw [nextScalar_rowCosine,nextScalar_rowCosine] + have h := congrFun (rationalNodalPolynomial_pair_delete + (polynomialVacuumVector (n+1)) (polynomialVacuumVector_eval (n+1)) + (vacuumData n).P (vacuumData n).map_P (vacuumData n).eval_P + (vacuumData (n+2)).P (vacuumData (n+2)).map_P) (empty (n+3)) + rw [matrixPolynomial_delete_empty] at h + simpa only [deletePairPolynomial,mul_assoc] using h + +lemma nextScalar_specialize {n m : ℕ} (φ : Laurent n →ₐ[ℂ] SpectralField m) : + (nextScalar (constantL n) rowCosineL).map φ.toRingHom = + nextScalar (algebraMap ℂ (SpectralField m)) (fun i =>φ (rowCosineL i)) := by + rw [nextScalar_map,specialization_constant_comp] + rfl + +lemma scalarValue_specialize {n m : ℕ} (φ : Laurent n →ₐ[ℂ] SpectralField m) : + φ (scalarValue (constantL n) rowCosineL)= + scalarValue (algebraMap ℂ (SpectralField m)) (fun i =>φ (rowCosineL i)) := by + rw [show φ (scalarValue (constantL n) rowCosineL)=φ.toRingHom _ from rfl, + map_scalarValue,specialization_constant_comp] + rfl + +lemma archCandidate_specialize {n m : ℕ} (φ : Laurent n →ₐ[ℂ] SpectralField m) : + φ (archCandidate n)= + scalarArchNumerator (algebraMap ℂ (SpectralField m)) (fun i =>φ (rowCosineL i)) := by + unfold archCandidate + rw [show φ (scalarArchNumerator (constantL n) rowCosineL)=φ.toRingHom _ from rfl, + map_scalarArchNumerator,specialization_constant_comp] + rfl + +end +end CriticalStrip.Diagram + +end OAI diff --git a/lean/OAI/Combinatorics/StripMass/ArchTrig.lean b/lean/OAI/Combinatorics/StripMass/ArchTrig.lean new file mode 100644 index 0000000000000000000000000000000000000000..0b24e886be4af08fd103fc7d1ebb5cc7c7c3e35a --- /dev/null +++ b/lean/OAI/Combinatorics/StripMass/ArchTrig.lean @@ -0,0 +1,465 @@ +import Mathlib +import OAI.Combinatorics.StripMass.ArchRoots + +namespace OAI + +/-! Critical honeycomb strip paths, polynomial identities and crossing mass. -/ + + +namespace CriticalStrip.Diagram +noncomputable section +open scoped Classical BigOperators + +lemma arch_flat_constants : (c:ℂ) = (2*(d:ℂ)-1)*(C:ℂ) := by + have hh : c=(2*d-1)*C := by + rw [←c_add_rho_eq_C,rho_eq_two_c_d] + linear_combination -(4*c)*d_sq + exact_mod_cast hh + +lemma fcos_arch_merge {n : ℕ} (i : Fin n) (k : ℤ) : + fcos i (k-2)+fcos i (k+2)-fcos i k=constF n (2*(d:ℂ)-1)*fcos i k := by + have h := (fcos_sum_product i k).1 + simp only [constF,map_sub,map_mul,map_ofNat,map_one] at * + linear_combination h + +lemma fcos_arch_delete {n : ℕ} (i : Fin n) : + fcos i (-3)+fcos i 3 = -constF n (2*(d:ℂ)-1)*(fcos i (-9)+fcos i 9) := by + have ha := (fcos_sum_product i (-1)).1 + have hb := (fcos_sum_product i 1).1 + have hc := fcos_sub_eight i (-1) + have hd := fcos_eight i 1 + norm_num only at ha hb hc hd + rw [hc,hd] + simp only [constF,map_sub,map_mul,map_ofNat,map_one] at * + linear_combination ha+hb + + + + + + +lemma pairEvaluation_rowCosine {n : ℕ} (s : ℕ) (i : Fin (n+2)) : + pairEvaluation n s (rowCosineL i)=pairCosines n s i := by + rw [pairEvaluation,torusEvaluation_rowCosine,pairPoint_cosine] + +lemma mergeEvaluation_rowCosine {n : ℕ} (i : Fin (n+1)) : + mergeEvaluation n (rowCosineL i)= + (Fin.cons (fcos 0 (-1)) (fun j:Fin n => fcos j.succ (-3)) : Fin (n+1) → SpectralField (n+1)) i := by + rw [mergeEvaluation,torusEvaluation_rowCosine] + exact congrFun (mergePoint_cosines n) i + +lemma deleteEvaluation_rowCosine {n : ℕ} (i : Fin n) : + deleteEvaluation n (rowCosineL i)=fcos i.succ (-3) := by + unfold deleteEvaluation + exact (torusEvaluation_rowCosine (deletePoint n) + (fun j => show deletePoint n j ≠ 0 from variableF_ne_zero j.succ) i).trans + (congrFun (deletePoint_cosines n) i) + +lemma nextScalar_flat_previous (n : ℕ) : + previousCoeff (n+1) (nextScalar (algebraMap ℂ (SpectralField n)) (Fin.cons (constF n c) spectralA)) = + (∏j:Fin n,(spectralA j+constF n C)) * + (previousCoeff n (nextScalar (algebraMap ℂ (SpectralField n)) spectralA) + + constF n C * scalarValue (algebraMap ℂ (SpectralField n)) spectralA) := by + have hp := congrArg (previousCoeff (n+1)) (nextScalar_firstFlat n) + rw [nextScalar_specialize] at hp + simp only [firstFlatEvaluation_rowCosine,previousCoeff_C_mul,previousCoeff_linear,nextScalar_top] at hp + exact hp + + + +theorem archCandidate_firstFlat (n : ℕ) : + firstFlatEvaluation n (archCandidate (n+1))= + (∏j:Fin n,(spectralA j+constF n C))^2 * evalLaurent (archCandidate n) := by + rw [archCandidate_specialize,archCandidate_eval] + simp only [firstFlatEvaluation_rowCosine] + unfold scalarArchNumerator + have hs := scalarValue_flat (algebraMap ℂ (SpectralField n)) (@spectralA n) + rw [show (algebraMap ℂ (SpectralField n)) (c:ℂ)=constF n c from rfl] at hs + rw [hs,nextScalar_flat_previous] + simp only [Fin.sum_univ_succ,Fin.cons_zero,Fin.cons_succ] + have hc : constF n c=constF n (2*(d:ℂ)-1)*constF n C := by + simpa only [constF,map_mul] using congrArg (constF n) arch_flat_constants + change _ = (∏j:Fin n,(spectralA j+constF n C))^2 * _ + change constF n c = _ at hc + change ((constF n c + ∑i:Fin n,spectralA i) * _ - _) = _ + simp only [constF] at hc ⊢ + rw [hc] + ring + +lemma nextScalar_merge_previous (n : ℕ) : + previousCoeff (n+2) (nextScalar (algebraMap ℂ (SpectralField (n+1))) (pairCosines n 2)) = + mergePairScalar n * + (previousCoeff (n+1) (nextScalar (algebraMap ℂ (SpectralField (n+1))) + (Fin.cons (fcos 0 (-1)) (fun j:Fin n =>fcos j.succ (-3)))) + + fcos 0 (-1) * scalarValue (algebraMap ℂ (SpectralField (n+1))) + (Fin.cons (fcos 0 (-1)) (fun j:Fin n =>fcos j.succ (-3)))) := by + have hp := congrArg (previousCoeff (n+2)) (nextScalar_pair_merge n) + rw [nextScalar_specialize,nextScalar_specialize] at hp + simp only [pairEvaluation_rowCosine,mergeEvaluation_rowCosine,previousCoeff_C_mul] at hp + rw [previousCoeff_linear (n+1),nextScalar_top] at hp + exact hp + + +theorem archCandidate_merge (n : ℕ) : + pairEvaluation n 2 (archCandidate (n+2))= + mergePairScalar n^2 * mergeEvaluation n (archCandidate (n+1)) := by + rw [archCandidate_specialize,archCandidate_specialize] + simp only [pairEvaluation_rowCosine,mergeEvaluation_rowCosine] + unfold scalarArchNumerator + rw [scalar_pair_merge,nextScalar_merge_previous] + have hc := fcos_arch_merge (0:Fin (n+1)) (-1) + norm_num only at hc + have hs : (∑i:Fin (n+2),pairCosines n 2 i)= + (∑i:Fin (n+1),(Fin.cons (fcos 0 (-1)) (fun j:Fin n =>fcos j.succ (-3)) : Fin (n+1) → SpectralField (n+1)) i) + + constF (n+1) (2*(d:ℂ)-1)*fcos 0 (-1) := by + simp only [pairCosines,Fin.sum_univ_succ,Fin.cons_zero,Fin.cons_succ] + norm_num only + linear_combination hc + rw [hs] + dsimp only [constF] + ring + +lemma nextScalar_delete_previous (n : ℕ) : + previousCoeff (n+2) (nextScalar (algebraMap ℂ (SpectralField (n+1))) (pairCosines n 3)) = + deletePairScalar n * + (previousCoeff n (nextScalar (algebraMap ℂ (SpectralField (n+1))) (fun j:Fin n =>fcos j.succ (-3))) - + (fcos 0 (-9)+fcos 0 9) * scalarValue (algebraMap ℂ (SpectralField (n+1))) (fun j:Fin n =>fcos j.succ (-3))) := by + have hp := congrArg (previousCoeff (n+2)) (nextScalar_pair_delete n) + rw [nextScalar_specialize,nextScalar_specialize] at hp + simp only [pairEvaluation_rowCosine,deleteEvaluation_rowCosine,previousCoeff_C_mul] at hp + rw [previousCoeff_quadratic _ _ _ _ (nextScalar_degree _ _),nextScalar_top] at hp + exact hp + + +theorem archCandidate_delete (n : ℕ) : + pairEvaluation n 3 (archCandidate (n+2))= + deletePairScalar n^2 * deleteEvaluation n (archCandidate n) := by + rw [archCandidate_specialize,archCandidate_specialize] + simp only [pairEvaluation_rowCosine,deleteEvaluation_rowCosine] + unfold scalarArchNumerator + rw [scalar_pair_delete,nextScalar_delete_previous] + have hc := fcos_arch_delete (0:Fin (n+1)) + have hs : (∑i:Fin (n+2),pairCosines n 3 i)= + (∑j:Fin n,fcos j.succ (-3)) - constF (n+1) (2*(d:ℂ)-1)*(fcos 0 (-9)+fcos 0 9) := by + simp only [pairCosines,Fin.sum_univ_succ,Fin.cons_zero,Fin.cons_succ] + norm_num only + linear_combination hc + rw [hs] + dsimp only [constF] + ring + + + + + + +def twoPair : Pairing 2 := ⟨{(0,1)}, by simp [IsPairing]⟩ + +@[simp] lemma twoPair_adj (i j : Fin 2) : twoPair.Adj i j ↔ (i=0 ∧ j=1) ∨ (i=1 ∧ j=0) := by + simp [twoPair,Pairing.Adj,and_comm] + +@[simp] lemma twoPair_occupied (i : Fin 2) : twoPair.Occupied i := by + fin_cases i <;> simp [Pairing.Occupied] + +def oneSourcePair : SourcePairing 1 := ⟨twoPair,twoPair_occupied _⟩ + +lemma SourcePairing.one_eq (p : SourcePairing 1) : p=oneSourcePair := by + apply Subtype.ext + apply Subtype.ext + apply Finset.ext + rintro ⟨i,j⟩ + have hu := p.val.property.1 + have hp := p.property + change ∃ k, p.val.Adj (1:Fin 2) k at hp + obtain ⟨k,hk⟩ := hp + have hk0 : k=0 := by + fin_cases k + · rfl + · exact False.elim (p.val.adj_irrefl 1 hk) + subst k + have hmem : (0,1) ∈ p.val.val := by + rcases hk with hk|hk + · have hh := hu _ hk; simp at hh + · exact hk + fin_cases i <;> fin_cases j <;> simp only [oneSourcePair,twoPair,Finset.mem_singleton,Prod.mk.injEq] + all_goals aesop (add safe (by have : ¬((1:Fin 2)<0) := by decide; exact this)) + +instance : Subsingleton (SourcePairing 1) := + ⟨fun p q => p.one_eq.trans q.one_eq.symm⟩ + +lemma oneSourcePair_glues : Pairing.GluesAt (Fin.last 1) twoPair twoPair := by + refine ⟨twoPair_occupied _,fun _ =>Iff.rfl,?_⟩ + intro i j hij + fin_cases i + · exact .single (Or.inl (by simp)) + · exact .refl + +lemma sourceGlue_one {K : Type*} [CommRing K] (v w : SourcePairing 1 → K) : + sourceGlue 1 v w=v oneSourcePair*w oneSourcePair := by + rw [sourceGlue_eq_sum] + simp only [Fintype.sum_subsingleton _ oneSourcePair,oneSourcePair,oneSourcePair_glues,ite_true,one_mul] + +lemma sourceGlue_zero {K : Type*} [CommRing K] (v w : SourcePairing 0 → K) : + sourceGlue 0 v w=0 := by + have : IsEmpty (SourcePairing 0) := ⟨fun p =>p.ne_empty (p.val.eq_empty_of_le_one (by omega))⟩ + simp [sourceGlue, dotProduct] + +lemma archCandidate_zero : archCandidate 0=0 := by + simp [archCandidate,scalarArchNumerator,previousCoeff] + +lemma polynomialNorthGluing_zero : polynomialNorthGluing 0=0 := sourceGlue_zero _ _ + +lemma empty_insertCup_two : + (empty 2).insertCup 0 1 (by decide) (empty_not_occupied _) (empty_not_occupied _)=twoPair := by + apply Subtype.ext + simp [Pairing.insertCup,twoPair,empty] + +lemma localR_deletion_twoPair {K : Type*} [Field K] : + localR (PartialColumn.rowPosition 0 (show 2≤2 by omega)) (deletionWeights : Weights K) twoPair (empty 2)=1 := by + simp only [localR,Matrix.sum_apply,Matrix.smul_apply,smul_eq_mul] + rw [Finset.sum_eq_single Tile.cup] + · simp [Weights.tile,deletionWeights,optionMatrix,Pairing.tileStep,PartialColumn.rowPosition,empty_insertCup_two] + · intro t _ ht + cases t <;> simp_all [Weights.tile,deletionWeights,optionMatrix,Pairing.tileStep, + PartialColumn.rowPosition] + all_goals intro h; exact empty_not_occupied 0 (h ▸ twoPair_occupied 0) + · simp + +lemma deletionMap_zero_twoPair : + (deletionMap (n:=0) (m:=1) 0 (by omega)).mulVec (fun _=>1) twoPair=1 := by + let : Subsingleton (Pairing 0) := ⟨fun p q =>(p.eq_empty_of_le_one (by omega)).trans (q.eq_empty_of_le_one (by omega)).symm⟩ + rw [deletionMap] + dsimp +instances only [CStarMatrix, CStarMatrix.instHMulOfFintypeOfMulOfAddCommMonoid, + CStarMatrix.ofMatrix, Equiv.refl, Equiv.symm] + simp only [Equiv.coe_fn_mk, id_eq] + simp only [Matrix.mulVec, dotProduct,Fintype.sum_subsingleton _ (empty 0),mul_one] + rw [functionMatrix_mul,mul_functionMatrix] + simpa only [Function.comp_apply,Pairing.map_empty] using (localR_deletion_twoPair (K:=SpectralField 1)) + +lemma reducedNodalDatum_one (p : SourcePairing 1) : + reducedNodalDatum 0 p.val=4*constF 1 c*torusSin (constF 1 phase^3/variableF 0) := by + rw [p.one_eq] + simp only [reducedNodalDatum,reducedNodalHead,oneSourcePair,twoPair_occupied, + matrixPrefix,Nat.lt_succ_self,reducedMovingStep,↓reduceDIte,↓reduceIte,Matrix.mul_one] + simp only [Fin.mk_zero,↓reduceIte,Matrix.one_mulVec] + have hv : (fun q:Pairing 0 =>insertSpectral (0:Fin 1) (rationalVacuum 0 q))=fun _=>1 := by + funext q + rw [rationalVacuum_zero,map_one] + rw [hv] + change 4*constF 1 c*torusSin (constF 1 phase^3/variableF 0) * + (deletionMap (n:=0) (m:=1) 0 (by omega)).mulVec (fun _=>1) twoPair = _ + rw [deletionMap_zero_twoPair,mul_one] + +lemma northNumerator_one (p : SourcePairing 1) : + northNumerator 1 p=4*constF 1 c*torusSin (constF 1 phase^3/variableF 0) := by + have hz : rationalNodalPolynomial 1 p.val=Polynomial.C ((rationalNodalPolynomial 1 p.val).coeff 0) := by + apply Polynomial.eq_C_of_natDegree_le_zero + apply Polynomial.natDegree_le_iff_coeff_eq_zero.mpr + intro k hk + exact rationalNodalPolynomial_degree 1 p.val k (by simpa only [p.property,ite_true] using (show 1≤k by omega)) + have he := rationalNodalPolynomial_eval_div (0:Fin 1) p.val + rw [hz,Polynomial.eval_C,reducedNodalDatum_eq] at he + have hprod : (∏j:Fin 1,reflectionFactor (0:Fin 1) j)=1 := by + apply Finset.prod_eq_one + intro j _ + rw [Subsingleton.elim j 0] + simp [reflectionFactor] + rw [hprod,one_mul] at he + exact he.trans (reducedNodalDatum_one p) + +lemma polynomialNorthSource_one (p : SourcePairing 1) : + evalLaurent (polynomialNorthSource 1 p)= + (2*constF 1 c/constF 1 d)*torusSin (constF 1 phase^3/variableF 0) := by + rw [polynomialNorthSource_eval_numerator,northNumerator_one] + simp only [constF,map_div₀,map_mul,map_ofNat,map_one] + ring + +lemma scalarArchNumerator_one {K : Type*} [CommRing K] (f : ℂ →+* K) (a : Fin 1 → K) : + scalarArchNumerator f a=a 0-f (2*(d:ℂ)-1)*(a 0+f (rho:ℂ)) := by + have ha : a=fun _:Fin 1 =>a 0 := funext (fun i =>congrArg a (Subsingleton.elim i 0)) + rw [ha] + unfold scalarArchNumerator + rw [scalarValue_one] + have he : nextScalar f (fun _:Fin 1=>a 0)= + Polynomial.X+Polynomial.C (a 0)+Polynomial.C (f (rho:ℂ)) := by + exact scalarValue_two (Polynomial.C.comp f) Polynomial.X (Polynomial.C (a 0)) + rw [he] + simp [previousCoeff] + + + + + + +lemma arch_one_constants : + ((2*(c:ℂ)/(d:ℂ))^2/2 = 2-2*(d:ℂ)) ∧ + ((2*(d:ℂ)-1)*(rho:ℂ)=(2-2*(d:ℂ))*(c:ℂ)) := by + have hcs : 2*c^2 = 1-d := by + have h := Real.cos_two_mul (3*lambda) + rw [show 2*(3*lambda) = 6*lambda by ring,cos_six_lambda] at h + change -d=2*c^2-1 at h + linarith + have hd : (d:ℂ)^2=(1/2:ℂ) := by + simpa only [Complex.ofReal_pow,Complex.ofReal_div,Complex.ofReal_one,Complex.ofReal_ofNat] using congrArg Complex.ofReal d_sq + have hdz : (d:ℂ)≠0 := by exact_mod_cast d_ne_zero + have hc : 2*(c:ℂ)^2=1-(d:ℂ) := by exact_mod_cast hcs + constructor + · rw [div_pow,mul_pow,hd] + norm_num + linear_combination 2*hc + · have hr : (rho:ℂ)=2*(c:ℂ)*(d:ℂ) := by exact_mod_cast rho_eq_two_c_d + rw [hr] + linear_combination 4*(c:ℂ)*hd + +lemma arch_one_field_constants (n : ℕ) : + ((2*constF n c/constF n d)^2/2 = 2-2*constF n d) ∧ + (constF n (2*(d:ℂ)-1)*constF n rho=(2-2*constF n d)*constF n c) := by + constructor + · simpa only [constF,map_div₀,map_pow,map_mul,map_ofNat,map_sub] + using congrArg (algebraMap ℂ (SpectralField n)) arch_one_constants.1 + · simpa only [constF,map_mul,map_ofNat,map_sub,map_one] + using congrArg (algebraMap ℂ (SpectralField n)) arch_one_constants.2 + +lemma polynomialNorthGluing_one : polynomialNorthGluing 1=archCandidate 1 := by + apply IsFractionRing.injective (SpectralRing 1) (SpectralField 1) + change evalLaurent (polynomialNorthGluing 1)=evalLaurent (archCandidate 1) + rw [polynomialNorthGluing_eval,sourceGlue_one,polynomialNorthSource_one, + archCandidate_eval,scalarArchNumerator_one] + simp only [map_mul,map_div₀,map_ofNat,map_pow,reflectSpectral_torusSin, + reflectSpectral_const,reflectSpectral_variable] + have hz : constF 1 phase^3/(constF 1 phase^3/variableF 0)=variableF (0:Fin 1) := by + field_simp [constF_phase_ne_zero,variableF_ne_zero] + rw [hz] + have hs := spectral_sine_pair (0:Fin 1) + have hc := arch_one_field_constants 1 + change _ = spectralA 0-constF 1 (2*(d:ℂ)-1)*(spectralA 0+constF 1 rho) + have hleft : (2*constF 1 c/constF 1 d)*torusSin (variableF 0)* + ((2*constF 1 c/constF 1 d)*torusSin (constF 1 phase^3/variableF 0)) = + ((2*constF 1 c/constF 1 d)^2/2) * + (2*torusSin (variableF 0)*torusSin (constF 1 phase^3/variableF 0)) := by ring + rw [hleft,hs,hc.1] + have hη : constF 1 (2*(d:ℂ)-1)=2*constF 1 d-1 := by + simp only [constF,map_sub,map_mul,map_ofNat,map_one] + rw [hη] at hc ⊢ + linear_combination hc.2 + + + +theorem polynomialNorthGluing_eq_archCandidate (n : ℕ) : + polynomialNorthGluing n=archCandidate n := by + induction n using Nat.twoStepInduction with + | zero => rw [polynomialNorthGluing_zero,archCandidate_zero] + | one => exact polynomialNorthGluing_one + | more n ih₀ ih₁ => + apply sub_eq_zero.mp + apply archLaurent_interpolation_zero + · exact (polynomialNorthGluing_box _).sub (archCandidate_box _) + · intro σ + rw [map_sub,polynomialNorthGluing_permute,archCandidate_permute] + · rw [map_sub,polynomialNorthGluing_parity,archCandidate_parity] + · rw [map_sub,polynomialNorthGluing_row_reflection,archCandidate_row_reflection] + · rw [map_sub,polynomialNorthGluing_firstFlat,archCandidate_firstFlat,ih₁,sub_self] + · rw [map_sub,polynomialNorthGluing_merge,archCandidate_merge,ih₁,sub_self] + · rw [map_sub,polynomialNorthGluing_delete,archCandidate_delete,ih₀,sub_self] + + + + + + +lemma scalarValue_allFlat_ne_zero (n : ℕ) : + scalarValue (algebraMap ℂ (SpectralField 0)) (fun _:Fin n =>constF 0 c)≠0 := by + have hc : constF 0 c+constF 0 C≠0 := by + rw [←show constF 0 ((c:ℂ)+(C:ℂ))=constF 0 c+constF 0 C from map_add _ _ _] + apply (map_ne_zero (algebraMap ℂ (SpectralField 0))).mpr + have hC : 0 rw [scalarValue_zero]; exact one_ne_zero + | succ n ih => + have he : (fun _:Fin (n+1) => constF 0 c)= + Fin.cons ((algebraMap ℂ (SpectralField 0)) (c:ℂ)) (fun _:Fin n =>constF 0 c) := by + funext i + induction i using Fin.cases <;> rfl + rw [he,scalarValue_flat] + exact mul_ne_zero (Finset.prod_ne_zero_iff.mpr (fun _ _ =>hc)) ih + +lemma allFlat_rowCosine (n : ℕ) (i : Fin n) : + torusEvaluation (fun _:Fin n =>(1:SpectralField 0)) (fun _=>one_ne_zero) (rowCosineL i)=constF 0 c := by + rw [torusEvaluation_rowCosine] + simp only [one_pow,one_div,torusCos_inv,torusCos_phase_pow] + rfl + + + +theorem spectralNormalization_ne_zero (n : ℕ) : spectralNormalization n≠0 := by + intro hz + have hzero : scalarValue (constantL n) rowCosineL=0 := by + apply IsFractionRing.injective (SpectralRing n) (SpectralField n) + change evalLaurent (scalarValue (constantL n) rowCosineL)=evalLaurent 0 + rw [scalarValue_rowCosine,polynomialVacuumVector_eval,rationalVacuum_empty,hz] + exact (map_zero (algebraMap (SpectralRing n) (SpectralField n))).symm + have he := congrArg (torusEvaluation (fun _:Fin n =>(1:SpectralField 0)) (fun _=>one_ne_zero)) hzero + rw [scalarValue_specialize] at he + simp only [allFlat_rowCosine,map_zero] at he + exact scalarValue_allFlat_ne_zero n he + +lemma scalarValue_spectral (n : ℕ) : + scalarValue (algebraMap ℂ (SpectralField n)) spectralA=spectralNormalization n := + scalarPolynomial_eval_spectral n + + +def rationalArchPolynomial (n : ℕ) : Polynomial (SpectralField n) := + Polynomial.C (spectralNormalization n)⁻¹ * + nextScalar (algebraMap ℂ (SpectralField n)) spectralA + +lemma rationalArchPolynomial_coeff (n k : ℕ) : + (rationalArchPolynomial n).coeff k= + (nextScalar (algebraMap ℂ (SpectralField n)) spectralA).coeff k / spectralNormalization n := by + rw [rationalArchPolynomial,Polynomial.coeff_C_mul] + ring + + +theorem rationalArchPolynomial_monic_degree (n : ℕ) : + (rationalArchPolynomial n).Monic ∧ (rationalArchPolynomial n).natDegree=n := by + have ht : (rationalArchPolynomial n).coeff n=1 := by + rw [rationalArchPolynomial_coeff,nextScalar_top,scalarValue_spectral, + div_self (spectralNormalization_ne_zero _)] + have hd : (rationalArchPolynomial n).natDegree≤n := by + apply Polynomial.natDegree_le_iff_coeff_eq_zero.mpr + intro k hk + rw [rationalArchPolynomial_coeff,Polynomial.coeff_eq_zero_of_natDegree_lt + ((nextScalar_degree _ _).trans_lt hk),zero_div] + have he : (rationalArchPolynomial n).natDegree=n := + le_antisymm hd (Polynomial.le_natDegree_of_ne_zero (by rw [ht]; exact one_ne_zero)) + exact ⟨by rw [Polynomial.Monic,Polynomial.leadingCoeff,he,ht],he⟩ + +lemma previousCoeff_rationalArchPolynomial (n : ℕ) : + previousCoeff n (rationalArchPolynomial n)= + previousCoeff n (nextScalar (algebraMap ℂ (SpectralField n)) spectralA) / spectralNormalization n := by + rw [rationalArchPolynomial,previousCoeff_C_mul] + ring + + + +theorem northSeparatorMoment_arch (n : ℕ) : + northSeparatorMoment n = (∑i:Fin n,spectralA i) - + constF n (2*(d:ℂ)-1)*previousCoeff n (rationalArchPolynomial n) := by + have he := congrArg (@evalLaurent n) (polynomialNorthGluing_eq_archCandidate n) + rw [polynomialNorthGluing_eval_moment,archCandidate_eval,scalarArchNumerator, + scalarValue_spectral] at he + change spectralNormalization n^2*northSeparatorMoment n = + (∑i:Fin n,spectralA i)*spectralNormalization n^2- + constF n (2*(d:ℂ)-1)*spectralNormalization n* + previousCoeff n (nextScalar (algebraMap ℂ (SpectralField n)) spectralA) at he + rw [previousCoeff_rationalArchPolynomial] + apply (mul_left_cancel₀ (pow_ne_zero 2 (spectralNormalization_ne_zero n))) + rw [mul_sub,he] + field_simp [spectralNormalization_ne_zero n] + +end +end CriticalStrip.Diagram + +end OAI diff --git a/lean/OAI/Combinatorics/StripMass/AugmentedColumn.lean b/lean/OAI/Combinatorics/StripMass/AugmentedColumn.lean new file mode 100644 index 0000000000000000000000000000000000000000..a8dd31a5784a1855e4851c19269dd5b112368336 --- /dev/null +++ b/lean/OAI/Combinatorics/StripMass/AugmentedColumn.lean @@ -0,0 +1,491 @@ +import Mathlib +import OAI.Combinatorics.StripMass.ColumnSew +import OAI.Combinatorics.StripMass.PhysicalStationarity + +namespace OAI + +/-! Critical honeycomb strip paths, polynomial identities and crossing mass. -/ + + +namespace CriticalStrip.Diagram +noncomputable section +open scoped BigOperators Classical +open Finset Matrix + + + +def northInjectionWeights {K : Type*} [One K] [Zero K] : Weights K := ⟨1,1,0,0,0⟩ + +def sourceFullSplit (n : ℕ) : Pairing n ⊕ SourcePairing n ≃ Pairing (n+1) where + toFun := Sum.elim Pairing.padTop Subtype.val + invFun p := if h : p.Occupied (Fin.last n) then Sum.inr ⟨p,h⟩ else + Sum.inl (p.restrict Fin.castSuccOrderEmb) + left_inv p := by + cases p with + | inl p => + change (if h : p.padTop.Occupied (Fin.last n) then Sum.inr (⟨p.padTop,h⟩ : SourcePairing n) else + Sum.inl (Pairing.restrict Fin.castSuccOrderEmb p.padTop))=Sum.inl p + rw [dite_eq_right (Pairing.padTop_not_occupied_last p)] + exact congrArg Sum.inl (Pairing.restrict_map _ _) + | inr p => + change (if h : p.val.Occupied (Fin.last n) then Sum.inr ⟨p.val,h⟩ else + Sum.inl (Pairing.restrict Fin.castSuccOrderEmb p.val))=Sum.inr p + rw [dite_eq_left p.property] + right_inv p := by + change Sum.elim Pairing.padTop Subtype.val + (if h : p.Occupied (Fin.last n) then Sum.inr ⟨p,h⟩ else + Sum.inl (Pairing.restrict Fin.castSuccOrderEmb p))=p + split_ifs with h + · rfl + · exact Pairing.padTop_restrict p h + +@[simp] lemma sourceFullSplit_inl {n : ℕ} (p : Pairing n) : + sourceFullSplit n (.inl p)=p.padTop := rfl +@[simp] lemma sourceFullSplit_inr {n : ℕ} (p : SourcePairing n) : + sourceFullSplit n (.inr p)=p.val := rfl + +def augmentVector {K : Type*} {n : ℕ} (v : Pairing n → K) (z : SourcePairing n → K) : + Pairing (n+1) → K := fun p=>Sum.elim v z ((sourceFullSplit n).symm p) + +@[simp] lemma augmentVector_split {K : Type*} {n : ℕ} (v : Pairing n → K) (z : SourcePairing n → K) + (p : Pairing n ⊕ SourcePairing n) : + augmentVector v z (sourceFullSplit n p)=Sum.elim v z p := by + simp only [augmentVector,Equiv.symm_apply_apply] + +@[simp] lemma augmentVector_padTop {K : Type*} {n : ℕ} (v : Pairing n → K) (z : SourcePairing n → K) + (p : Pairing n) : augmentVector v z p.padTop=v p := augmentVector_split v z (.inl p) + +@[simp] lemma augmentVector_source {K : Type*} {n : ℕ} (v : Pairing n → K) (z : SourcePairing n → K) + (p : SourcePairing n) : augmentVector v z p.val=z p := augmentVector_split v z (.inr p) + +@[simp] lemma augmentVector_empty {K : Type*} {n : ℕ} (v : Pairing n → K) (z : SourcePairing n → K) : + augmentVector v z (empty (n+1))=v (empty n) := by + rw [←Pairing.padTop_empty,augmentVector_padTop] + +lemma column_last_factor {K : Type*} [CommRing K] {n : ℕ} + (w : Fin n → Weights K) (z : Weights K) (q p : Pairing (n+1)) : + column (Fin.snoc w z) q p = lastCoefficient (fun i=>(w i).tile) q p * z.tile (lastTile p q) := by + have hw : (fun i=>((Fin.snoc w z : Fin (n+1) → Weights K) i).tile)= + Fin.snoc (fun i=>(w i).tile) z.tile := by + funext i + refine Fin.lastCases ?_ (fun i=>?_) i <;> simp + change rawColumn _ q p=_ + rw [hw,rawColumn_last_factor] + +lemma northInjection_column_blocks {K : Type*} [CommRing K] {n : ℕ} (w : Fin n → Weights K) : + (column (Fin.snoc w northInjectionWeights)).submatrix (sourceFullSplit n) (sourceFullSplit n)= + Matrix.fromBlocks (column w) 0 (northSource (fun i=>(w i).tile)) + (sourceTransfer (fun i=>(w i).tile)) := by + ext q p + change column _ _ _=_ + rw [column_last_factor] + cases q with + | inl q => + cases p with + | inl p => simp [lastCoefficient_padTop,lastTile,Weights.tile]; rfl + | inr p => simp [lastTile,p.property,northInjectionWeights,Weights.tile] + | inr q => + cases p with + | inl p => simp [lastTile,q.property,northInjectionWeights,Weights.tile,northSource] + | inr p => simp [lastTile,q.property,p.property,northInjectionWeights,Weights.tile,sourceTransfer] + +lemma augmentVector_stationary {K : Type*} [CommRing K] {n : ℕ} (w : Fin n → Weights K) + (v : Pairing n → K) (z : SourcePairing n → K) + (hv : (column w).mulVec v=v) + (hz : (sourceTransfer (fun i=>(w i).tile)).mulVec z+ + (northSource (fun i=>(w i).tile)).mulVec v=z) : + (column (Fin.snoc w northInjectionWeights)).mulVec (augmentVector v z)=augmentVector v z := by + funext q + obtain ⟨q,rfl⟩:=(sourceFullSplit n).surjective q + have he : (column (Fin.snoc w northInjectionWeights)).mulVec (augmentVector v z) (sourceFullSplit n q)= + (Matrix.fromBlocks (column w) 0 (northSource (fun i=>(w i).tile)) + (sourceTransfer (fun i=>(w i).tile))).mulVec (Sum.elim v z) q := by + rw [Matrix.mulVec,dotProduct,←(sourceFullSplit n).sum_comp] + simp_rw [augmentVector_split] + change (∑ p,((column (Fin.snoc w northInjectionWeights)).submatrix + (sourceFullSplit n) (sourceFullSplit n)) q p * Sum.elim v z p)=_ + rw [northInjection_column_blocks] + rfl + rw [he,augmentVector_split] + cases q with + | inl q => simpa [Matrix.mulVec,dotProduct,Fintype.sum_sum_type] using congrFun hv q + | inr q => + have hh:=congrFun hz q + simp only [Pi.add_apply,Matrix.mulVec,dotProduct] at hh + simpa only [Matrix.mulVec,dotProduct,Fintype.sum_sum_type,Matrix.fromBlocks_apply₂₁, + Matrix.fromBlocks_apply₂₂,Sum.elim_inl,Sum.elim_inr,add_comm] using hh + + +def angleAugmented {n : ℕ} (u : Fin n → ℝ) : Pairing (n+1) → ℝ := + augmentVector (angleVacuum u) (angleNorthSource u) + +lemma angleAugmented_restricted_stationary {n : ℕ} (u : Fin n → ℝ) + (hL : ∀i,L (3*lambda-u i)≠0) (h : angleScalar u≠0) : + (restrictedColumn (Fin.snoc (fun i=>physicalWeights (3*lambda-u i)) northInjectionWeights)).mulVec + (fun p=>angleAugmented u p.val)+ + injectionColumn (Fin.snoc (fun i=>physicalWeights (3*lambda-u i)) northInjectionWeights)= + fun p=>angleAugmented u p.val := by + have hh:=augmentVector_stationary (fun i=>physicalWeights (3*lambda-u i)) + (angleVacuum u) (angleNorthSource u) (angleVacuum_stationary u hL) (angleNorthSource_stationary u hL) + funext p + have hp:=congrFun hh p.val + rw [column_mulVec_nonempty,augmentVector_empty,angleVacuum_empty u h,mul_one] at hp + simpa only [Pi.add_apply,add_comm,angleAugmented] using hp + +lemma continuousOn_angleAugmented {n : ℕ} {S : Set (Fin n → ℝ)} + (h : ∀u∈S,angleScalar u≠0) : ContinuousOn (fun u=>angleAugmented u) S := by + apply continuousOn_pi.mpr + intro p + obtain ⟨q,rfl⟩:=(sourceFullSplit n).surjective p + have he : (fun u=>angleAugmented u (sourceFullSplit n q))= + fun u=>Sum.elim (angleVacuum u) (angleNorthSource u) q := by + funext u + exact augmentVector_split _ _ _ + rw [he] + cases q with + | inl q => exact (continuousOn_pi.mp (continuousOn_angleVacuum h)) q + | inr q => exact (continuousOn_pi.mp (continuousOn_angleNorthSource h)) q + +end + + + + + +noncomputable section +open scoped BigOperators Classical +namespace ColumnChain +section RingCoefficients +variable {K : Type*} [CommRing K] {n : ℕ} + +def weight (w : Fin n → Weights K) : List (Configuration n) → K + | [] => 1 + | t::ts => (∏ i,(w i).tile (t i))*weight w ts + +lemma weighted_runs_cons (w : Fin n → Weights K) (p q : Pairing n) + (t : Configuration n) (ts : List (Configuration n)) : + (if Runs p (t::ts) q then weight w (t::ts) else 0)= + ∑ r : Pairing n, (if Realizes r q t then ∏i,(w i).tile (t i) else 0)* + (if Runs p ts r then weight w ts else 0) := by + by_cases hh : ∃r,Runs p ts r + · obtain ⟨r,hr⟩:=hh + rw [Finset.sum_eq_single r] + · have he : Runs p (t::ts) q ↔ Realizes r q t := by + constructor + · rintro ⟨r',hr',ht⟩ + exact runs_unique hr' hr ▸ ht + · exact fun ht=>⟨r,hr,ht⟩ + simp only [he,hr,ite_true,weight] + split_ifs <;> simp + · intro s _ hsr + have hs : ¬Runs p ts s := fun hs=>hsr (runs_unique hs hr) + simp [hs] + · simp + · have hs : ∀r,¬Runs p ts r := fun r hr=>hh ⟨r,hr⟩ + have hq : ¬Runs p (t::ts) q := fun ⟨r,hr,_⟩=>hs r hr + simp [hq,hs] + +def mass (w : Fin n → Weights K) (m : ℕ) (q p : Pairing n) : K := + ∑ h : Fin m → Configuration n, if Runs p (List.ofFn h) q then weight w (List.ofFn h) else 0 + +lemma mass_zero (w : Fin n → Weights K) (q p : Pairing n) : + mass w 0 q p=if q=p then 1 else 0 := by + simp [mass,Runs,weight,eq_comm] + +lemma mass_succ (w : Fin n → Weights K) (m : ℕ) (q p : Pairing n) : + mass w (m+1) q p=∑r,column w q r*mass w m r p := by + unfold mass + rw [←(Fin.consEquiv (fun _ : Fin (m+1)=>Configuration n)).sum_comp] + simp only [Fintype.sum_prod_type] + simp only [Fin.consEquiv,Equiv.coe_fn_mk,List.ofFn_cons] + simp_rw [weighted_runs_cons] + conv_lhs => + arg 2 + ext t + rw [Finset.sum_comm] + rw [Finset.sum_comm] + apply Finset.sum_congr rfl + intro r _ + rw [column,Finset.sum_mul] + apply Finset.sum_congr rfl + intro t _ + rw [Finset.mul_sum] + + + +lemma mass_eq_pow (w : Fin n → Weights K) (m : ℕ) (q p : Pairing n) : + mass w m q p=(column w ^ m) q p := by + induction m generalizing q p with + | zero => simp [mass_zero,Matrix.one_apply] + | succ m ih => + rw [mass_succ,pow_succ'] + simp only [Matrix.mul_apply,ih] + +end RingCoefficients + + + + + + +variable {n : ℕ} + +lemma weight_head_ne_zero (w : Fin n → Weights ℝ) (t : Configuration n) + (ts : List (Configuration n)) (h : weight w (t::ts)≠0) (i : Fin n) : + (w i).tile (t i)≠0 := by + have hh := (mul_ne_zero_iff.mp h).1 + exact (Finset.prod_ne_zero_iff.mp hh) i (Finset.mem_univ i) + +lemma weight_tail_ne_zero (w : Fin n → Weights ℝ) (t : Configuration n) + (ts : List (Configuration n)) (h : weight w (t::ts)≠0) : weight w ts≠0 := + (mul_ne_zero_iff.mp h).2 + + + +theorem north_shape (w : Fin n → Weights ℝ) (ts : List (Configuration (n+1))) + (q : Pairing (n+1)) (hr : Runs (empty (n+1)) ts q) + (hw : weight (Fin.snoc w northInjectionWeights) ts≠0) : + (q.Occupied (Fin.last n) → ∃ k l : ℕ, + ts.map (fun t=>t (Fin.last n))= + List.replicate k Tile.diagonal₁ ++ Tile.vertical₀ :: List.replicate l Tile.vacant) ∧ + (¬q.Occupied (Fin.last n) → + ts.map (fun t=>t (Fin.last n))=List.replicate ts.length Tile.vacant) := by + induction ts generalizing q with + | nil => + have he : empty (n+1)=q := hr + subst q + refine ⟨fun h=>(empty_not_occupied _ h).elim,fun _=>rfl⟩ + | cons t ts ih => + obtain ⟨p,hp,ht⟩:=hr + have hf := weight_head_ne_zero (Fin.snoc w northInjectionWeights) t ts hw (Fin.last n) + rw [Fin.snoc_last] at hf + obtain ⟨h₁,h₀⟩ := ih p hp (weight_tail_ne_zero _ t ts hw) + have he:=ht.last_eq + by_cases hp : p.Occupied (Fin.last n) + · by_cases hq : q.Occupied (Fin.last n) + · have he' : t (Fin.last n)=.diagonal₁ := by simpa only [lastTile,hp,hq,ite_true] using he + obtain ⟨k,l,hshape⟩:=h₁ hp + refine ⟨fun _=>⟨k+1,l,?_⟩,fun h=>(h hq).elim⟩ + simp only [List.map_cons,he',hshape,List.replicate_succ,List.cons_append] + · have he' : t (Fin.last n)=.cap := by simpa only [lastTile,hp,hq,ite_true,ite_false] using he + simp only [he',northInjectionWeights,Weights.tile,ne_eq,not_true_eq_false] at hf + · by_cases hq : q.Occupied (Fin.last n) + · have he' : t (Fin.last n)=.vertical₀ := by simpa only [lastTile,hp,hq,ite_true,ite_false] using he + refine ⟨fun _=>⟨0,ts.length,?_⟩,fun h=>(h hq).elim⟩ + simp only [List.map_cons,he',h₀ hp,List.replicate_zero,List.nil_append] + · have he' : t (Fin.last n)=.vacant := by simpa only [lastTile,hp,hq,ite_false] using he + refine ⟨fun h=>(hq h).elim,fun _=>?_⟩ + simp only [List.map_cons,he',h₀ hp,List.length_cons,List.replicate_succ] + +lemma north_birth_unique_shape (k l k' l' : ℕ) + (h : List.replicate k Tile.diagonal₁ ++ Tile.vertical₀ :: List.replicate l Tile.vacant = + List.replicate k' Tile.diagonal₁ ++ Tile.vertical₀ :: List.replicate l' Tile.vacant) : + k=k' ∧ l=l' := by + induction k generalizing k' with + | zero => + cases k' with + | zero => + have he : List.replicate l Tile.vacant=List.replicate l' Tile.vacant := List.cons.inj h |>.2 + exact ⟨rfl,by simpa only [List.length_replicate] using congrArg List.length he⟩ + | succ k' => simp [List.replicate_succ] at h + | succ k ih => + cases k' with + | zero => simp [List.replicate_succ] at h + | succ k' => + simp only [List.replicate_succ,List.cons_append,List.cons.injEq,true_and] at h + obtain ⟨rfl,rfl⟩:=ih k' h + exact ⟨rfl,rfl⟩ + + +theorem north_birth_exists_unique (w : Fin n → Weights ℝ) + (ts : List (Configuration (n+1))) (q : SourcePairing n) + (hr : Runs (empty (n+1)) ts q.val) + (hw : weight (Fin.snoc w northInjectionWeights) ts≠0) : + ∃! kl : ℕ×ℕ, + ts.map (fun t=>t (Fin.last n))= + List.replicate kl.1 Tile.diagonal₁ ++ Tile.vertical₀ :: List.replicate kl.2 Tile.vacant := by + obtain ⟨k,l,hkl⟩:=(north_shape w ts q hr hw).1 q.property + refine ⟨(k,l),hkl,?_⟩ + rintro ⟨k',l'⟩ he + obtain ⟨rfl,rfl⟩:=north_birth_unique_shape k' l' k l (he.symm.trans hkl) + rfl + +end ColumnChain +end + + + + + +noncomputable section +open scoped Classical +namespace ColumnChain +variable {n : ℕ} + + + +def read (ts : List (Configuration n)) (k : ℕ) : Configuration n := + (ts[k]?).getD (fun _=>.vacant) + +@[simp] lemma read_nil (k : ℕ) : read ([] : List (Configuration n)) k=fun _=>.vacant := by + simp [read] +@[simp] lemma read_cons_zero (t : Configuration n) (ts : List (Configuration n)) : + read (t::ts) 0=t := rfl +@[simp] lemma read_cons_succ (t : Configuration n) (ts : List (Configuration n)) (k : ℕ) : + read (t::ts) (k+1)=read ts k := rfl + +lemma read_ge (ts : List (Configuration n)) (k : ℕ) (hk : ts.length≤k) : + read ts k=fun _=>.vacant := by + simp only [read,List.getElem?_eq_none hk,Option.getD_none] + +lemma read_entries (ts : List (Configuration n)) (k : Fin ts.length) : + read ts k=ColumnRectangle.entries ts k := by + induction ts with + | nil => exact Fin.elim0 k + | cons t ts ih => + induction k using Fin.cases with + | zero => rfl + | succ k => exact ih k + +lemma support_empty_read (ts : List (Configuration n)) (i : Fin n) : + support (empty n) ts i ↔ (read ts 0 i).Occupied 2 := by + cases ts with + | nil => simp only [support,read_nil]; exact ⟨fun h=>(empty_not_occupied i h).elim, + fun h=>(Tile.vacant_not_occupied 2 h).elim⟩ + | cons => rfl + + +structure LocallyCompatible (ts : List (Configuration n)) : Prop where + horizontal : ∀ k i, (read ts (k+1) i).Occupied 2 ↔ (read ts k i).Occupied 1 + south : ∀ k i, i.val=0 → ¬(read ts k i).Occupied 0 + north : ∀ k i, i.val+1=n → ¬(read ts k i).Occupied 3 + vertical : ∀ k i j, i.val+1=j.val → + ((read ts k i).Occupied 3 ↔ (read ts k j).Occupied 0) + +lemma compatible_empty_iff (ts : List (Configuration n)) : + Compatible (empty n) ts ↔ LocallyCompatible ts := by + induction ts with + | nil => + refine ⟨fun _=>⟨?_,?_,?_,?_⟩,fun _=>trivial⟩ <;> simp [Tile.vacant_not_occupied] + | cons t ts ih => + constructor + · rintro ⟨hc,ht⟩ + obtain ⟨hh,hs,hn,hv⟩ := ih.mp hc + refine ⟨?_,?_,?_,?_⟩ + · intro k i + cases k with + | zero => exact (support_empty_read ts i).symm.trans (ht.west i).symm + | succ k => exact hh k i + · intro k i hi + cases k with + | zero => exact ht.south i hi + | succ k => exact hs k i hi + · intro k i hi + cases k with + | zero => exact ht.north i hi + | succ k => exact hn k i hi + · intro k i j hij + cases k with + | zero => exact ht.glued i j hij + | succ k => exact hv k i j hij + · intro h + refine ⟨ih.mpr ⟨fun k i=>h.horizontal (k+1) i,fun k i=>h.south (k+1) i, + fun k i=>h.north (k+1) i,fun k i j=>h.vertical (k+1) i j⟩,?_,?_,?_,?_⟩ + · intro i + exact (h.horizontal 0 i).symm.trans (support_empty_read ts i).symm + · exact h.south 0 + · exact h.north 0 + · exact h.vertical 0 + +lemma read_tile_ne_zero {w : Fin n → Weights ℝ} {ts : List (Configuration n)} + (h : weight w ts ≠ 0) (k : ℕ) (i : Fin n) : (w i).tile (read ts k i)≠0 := by + induction ts generalizing k with + | nil => simp [Weights.tile] + | cons t ts ih => + cases k with + | zero => exact weight_head_ne_zero w t ts h i + | succ k => exact ih (weight_tail_ne_zero w t ts h) k + +end ColumnChain +end +end CriticalStrip.Diagram + + + + + +namespace CriticalStrip.PositiveMatrix +noncomputable section +open Matrix +open scoped BigOperators Classical + +variable {ι κ : Type*} [Fintype ι] [Fintype κ] [DecidableEq ι] [DecidableEq κ] + +lemma submatrix_pow_equiv (Q : Matrix ι ι ℝ) (e : κ ≃ ι) (k : ℕ) : + (Q.submatrix e e)^k=(Q^k).submatrix e e := by + induction k with + | zero => simp only [pow_zero,Matrix.submatrix_one_equiv] + | succ k ih => rw [pow_succ,pow_succ,ih,Matrix.submatrix_mul_equiv] + +lemma SummablePowers.reindex {Q : Matrix ι ι ℝ} (hs : SummablePowers Q) (e : κ ≃ ι) : + SummablePowers (Q.submatrix e e) := by + intro i j + simpa only [submatrix_pow_equiv,Matrix.submatrix_apply] using hs (e i) (e j) + +lemma summablePowers_reindex_iff (Q : Matrix ι ι ℝ) (e : κ ≃ ι) : + SummablePowers (Q.submatrix e e) ↔ SummablePowers Q := by + refine ⟨fun h=>?_,fun h=>h.reindex e⟩ + have hh:=h.reindex e.symm + have he : (Q.submatrix e e).submatrix e.symm e.symm=Q := by + ext i j; simp only [Matrix.submatrix_apply,Equiv.apply_symm_apply] + rw [he] at hh + exact hh + + + +lemma SummablePowers.fromBlocks_zero_right {Q : Matrix ι ι ℝ} (hs : SummablePowers Q) + (hQ : Nonnegative Q) (B : Matrix κ ι ℝ) (hB : ∀i j,0≤B i j) : + SummablePowers (Matrix.fromBlocks Q 0 B 0) := by + obtain ⟨z,hz,he⟩:=hs.hasSupervector hQ + have hBz : ∀i,0≤B.mulVec z i := fun i=>Finset.sum_nonneg fun j _=>mul_nonneg (hB i j) (hz j).le + apply HasSupervector.summablePowers + · refine ⟨Sum.elim z (fun i=>B.mulVec z i+1),?_,?_⟩ + · intro i + cases i with + | inl i => exact hz i + | inr i => exact lt_of_le_of_lt (hBz i) (lt_add_one _) + · intro i + cases i with + | inl i => simpa only [Matrix.mulVec,dotProduct,Fintype.sum_sum_type, + Matrix.fromBlocks_apply₁₁,Matrix.fromBlocks_apply₁₂,Sum.elim_inl,Sum.elim_inr, + Matrix.zero_apply,zero_mul,Finset.sum_const_zero,add_zero] using he i + | inr i => + simp only [Matrix.mulVec,dotProduct,Fintype.sum_sum_type, + Matrix.fromBlocks_apply₂₁,Matrix.fromBlocks_apply₂₂,Sum.elim_inl,Sum.elim_inr, + Matrix.zero_apply,zero_mul,Finset.sum_const_zero,add_zero] + exact lt_add_one _ + · intro i j + cases i <;> cases j <;> simp only [Matrix.fromBlocks_apply₁₁,Matrix.fromBlocks_apply₁₂, + Matrix.fromBlocks_apply₂₁,Matrix.fromBlocks_apply₂₂,Matrix.zero_apply] + · exact hQ _ _ + · exact le_rfl + · exact hB _ _ + · exact le_rfl + + + +lemma summablePowers_of_zero_cols (M : Matrix (ι ⊕ κ) (ι ⊕ κ) ℝ) + (hM : Nonnegative M) (hs : SummablePowers M.toBlocks₁₁) + (hz : ∀i j,M i (.inr j)=0) : SummablePowers M := by + have hblock : M=Matrix.fromBlocks M.toBlocks₁₁ 0 M.toBlocks₂₁ 0 := by + ext i j + cases i <;> cases j <;> simp only [Matrix.fromBlocks_apply₁₁,Matrix.fromBlocks_apply₁₂, + Matrix.fromBlocks_apply₂₁,Matrix.fromBlocks_apply₂₂,Matrix.zero_apply,Matrix.toBlocks₁₁,Matrix.toBlocks₂₁,Matrix.of_apply,hz] + rw [hblock] + exact hs.fromBlocks_zero_right (fun i j=>hM (.inl i) (.inl j)) M.toBlocks₂₁ + (fun i j=>hM (.inr i) (.inl j)) + +end +end CriticalStrip.PositiveMatrix + +end OAI diff --git a/lean/OAI/Combinatorics/StripMass/AugmentedTail.lean b/lean/OAI/Combinatorics/StripMass/AugmentedTail.lean new file mode 100644 index 0000000000000000000000000000000000000000..2f352fc83f8ae93ea41ac102cb5c13e5af4e711d --- /dev/null +++ b/lean/OAI/Combinatorics/StripMass/AugmentedTail.lean @@ -0,0 +1,532 @@ +import Mathlib +import OAI.Combinatorics.StripMass.BlockPfaffian + +namespace OAI + +/-! Critical honeycomb strip paths, polynomial identities and crossing mass. -/ + + + +namespace CriticalStrip.Diagram +noncomputable section +open Finset + +def twoCons {R : Type*} {n : ℕ} (x y : R) (a : Fin n → R) : Fin (n+2) → R := + Fin.cons x (Fin.cons y a) + +@[simp] theorem twoCons_zero {R : Type*} {n : ℕ} (x y : R) (a : Fin n → R) : + twoCons x y a 0 = x := by simp [twoCons] + +@[simp] theorem twoCons_one {R : Type*} {n : ℕ} (x y : R) (a : Fin n → R) : + twoCons x y a 1 = y := by + rw [← Fin.succ_zero_eq_one] + simp only [twoCons, Fin.cons_succ, Fin.cons_zero] + +@[simp] theorem twoCons_succ_succ {R : Type*} {n : ℕ} (x y : R) (a : Fin n → R) (i : Fin n) : + twoCons x y a i.succ.succ = a i := by simp [twoCons] + +theorem twoCons_of_ge {R : Type*} {n : ℕ} (x y : R) (a : Fin n → R) + (i : Fin (n+2)) (hi : 2 ≤ i.val) : + twoCons x y a i = a ⟨i.val-2,by have := i.isLt; omega⟩ := by + have he : i = (⟨i.val-2,by have := i.isLt; omega⟩ : Fin n).succ.succ := by + apply Fin.ext + simp only [Fin.val_succ] + omega + conv_lhs => rw [he] + exact twoCons_succ_succ _ _ _ _ + + + +def augmentTwoIndex (n : ℕ) : Fin ((n+n%2)+2) ≃ Fin ((n+2)+(n+2)%2) := + finCongr (by omega) + +@[simp] theorem augmentTwoIndex_val {n : ℕ} (i : Fin ((n+n%2)+2)) : + (augmentTwoIndex n i).val = i.val := rfl + +@[simp] theorem augmentTwoIndex_zero (n : ℕ) : augmentTwoIndex n 0 = 0 := by + apply Fin.ext + rfl + +@[simp] theorem augmentTwoIndex_one (n : ℕ) : augmentTwoIndex n 1 = 1 := by + apply Fin.ext + simp [augmentTwoIndex, Nat.mod_eq_of_lt (by omega : 1 < n+2+n%2)] + +theorem augmentedNumerator_skew {R : Type*} [CommRing R] {n : ℕ} + (rr : R) (a : Fin n → R) : + ∀ i j, augmentedNumerator rr a j i = -augmentedNumerator rr a i j := by + intro i j + unfold augmentedNumerator + split_ifs <;> ring + +@[simp] theorem augmentedNumerator_two_zero_one {R : Type*} [CommRing R] {n : ℕ} + (rr x y : R) (a : Fin n → R) : + augmentedNumerator rr (twoCons x y a) 0 1 = (x-y)*(x+y+rr) := by + simp [augmentedNumerator, Nat.mod_eq_of_lt (by omega : 1 < n+2+n%2)] + +@[simp] theorem augmentedDenominator_two_zero_one {R : Type*} [CommRing R] {n : ℕ} + (dd x y : R) (a : Fin n → R) : + augmentedDenominator dd (twoCons x y a) 0 1 = discriminant dd x y := by + simp [augmentedDenominator, Nat.mod_eq_of_lt (by omega : 1 < n+2+n%2)] + +theorem augmentedNumerator_two_tail {R : Type*} [CommRing R] {n : ℕ} + (rr x y : R) (a : Fin n → R) (i j : Fin (n+n%2)) : + augmentedNumerator rr (twoCons x y a) + (augmentTwoIndex n i.succ.succ) (augmentTwoIndex n j.succ.succ) = + augmentedNumerator rr a i j := by + simp only [augmentedNumerator, augmentTwoIndex_val, Fin.val_succ, Nat.add_assoc, + Nat.reduceAdd, Nat.add_lt_add_iff_right] + split_ifs <;> rfl + +theorem augmentedDenominator_two_tail {R : Type*} [CommRing R] {n : ℕ} + (dd x y : R) (a : Fin n → R) (i j : Fin (n+n%2)) : + augmentedDenominator dd (twoCons x y a) + (augmentTwoIndex n i.succ.succ) (augmentTwoIndex n j.succ.succ) = + augmentedDenominator dd a i j := by + simp only [augmentedDenominator, augmentTwoIndex_val, Fin.val_succ, Nat.add_assoc, + Nat.reduceAdd, Nat.add_lt_add_iff_right] + split_ifs <;> rfl + + +theorem prod_pad_one {R : Type*} [CommMonoid R] {n m : ℕ} (h : n ≤ m) + (f : Fin n → R) : + (∏ i : Fin m, if hi : i.val < n then f ⟨i.val,hi⟩ else 1) = ∏ i : Fin n, f i := by + classical + symm + apply Fintype.prod_of_injective (fun i : Fin n => i.castLE h) (Fin.castLE_injective h) + · intro i hi + split_ifs with hlt + · exfalso + exact hi ⟨⟨i.val,hlt⟩, Fin.ext rfl⟩ + · rfl + · intro i + simp only [Fin.val_castLE, i.isLt, dite_true] + +theorem augmentedDenominator_two_zero_tail {R : Type*} [CommRing R] {n : ℕ} + (dd x y : R) (a : Fin n → R) (i : Fin (n+n%2)) : + augmentedDenominator dd (twoCons x y a) 0 (augmentTwoIndex n i.succ.succ) = + if hi : i.val < n then discriminant dd x (a ⟨i.val,hi⟩) else 1 := by + simp only [augmentedDenominator, Fin.val_zero, augmentTwoIndex_val, Fin.val_succ, + Nat.add_assoc, Nat.reduceAdd, Nat.add_lt_add_iff_right] + rw [dite_eq_left (by omega : 0 < n+2)] + split_ifs <;> rfl + +theorem augmentedDenominator_two_one_tail {R : Type*} [CommRing R] {n : ℕ} + (dd x y : R) (a : Fin n → R) (i : Fin (n+n%2)) : + augmentedDenominator dd (twoCons x y a) 1 (augmentTwoIndex n i.succ.succ) = + if hi : i.val < n then discriminant dd y (a ⟨i.val,hi⟩) else 1 := by + have hv : (1 : Fin ((n+2)+(n+2)%2)).val = 1 := by + change 1 % ((n+2)+(n+2)%2) = 1 + exact Nat.mod_eq_of_lt (by omega) + simp only [augmentedDenominator, hv, augmentTwoIndex_val, Fin.val_succ, + Nat.add_assoc, Nat.reduceAdd, Nat.add_lt_add_iff_right] + rw [dite_eq_left (by omega : 1 < n+2)] + split_ifs <;> rfl + +theorem augmentedDenominator_two_cross {R : Type*} [CommRing R] {n : ℕ} + (dd x y : R) (a : Fin n → R) : + (∏ i : Fin (n+n%2), + augmentedDenominator dd (twoCons x y a) 0 (augmentTwoIndex n i.succ.succ) * + augmentedDenominator dd (twoCons x y a) 1 (augmentTwoIndex n i.succ.succ)) = + ∏ i : Fin n, discriminant dd x (a i) * discriminant dd y (a i) := by + simp only [augmentedDenominator_two_zero_tail, augmentedDenominator_two_one_tail] + have he : (fun i : Fin (n+n%2) => + (if hi : i.val < n then discriminant dd x (a ⟨i.val,hi⟩) else 1) * + (if hi : i.val < n then discriminant dd y (a ⟨i.val,hi⟩) else 1)) = + (fun i : Fin (n+n%2) => if hi : i.val < n then + discriminant dd x (a ⟨i.val,hi⟩) * discriminant dd y (a ⟨i.val,hi⟩) else 1) := by + funext i + split_ifs <;> simp + rw [he] + exact prod_pad_one (n := n) (m := n+n%2) (Nat.le_add_right _ _) + (fun i => discriminant dd x (a i) * discriminant dd y (a i)) + + + + + + + + + +theorem scalarNumerator_eval_cleared {K : Type*} [Field K] (f : ℂ →+* K) + (n : ℕ) (dd rr : ℂ) (a : Fin n → K) : + MvPolynomial.eval₂Hom f a (scalarNumerator n dd rr) = + clearedPfaffian (2^((n+n%2)/2) * (Nat.factorial ((n+n%2)/2) : K))⁻¹ + (augmentedNumerator (f rr) a) (augmentedDenominator (f dd) a) := by + rw [scalarNumerator, map_clearedPfaffian, map_augmentedNumerator, map_augmentedDenominator] + simp only [MvPolynomial.eval₂Hom_C, MvPolynomial.eval₂Hom_X', + map_inv₀, map_mul, map_pow, map_ofNat, map_natCast] + +theorem scalarNumerator_delete {K : Type*} [Field K] [CharZero K] (f : ℂ →+* K) + (n : ℕ) (dd rr : ℂ) (x y : K) (a : Fin n → K) + (hzero : discriminant (f dd) x y = 0) + (hD : ∀ i j, i ≠ j → ¬ ((i = 0 ∧ j = 1) ∨ (i = 1 ∧ j = 0)) → + discriminant (f dd) (twoCons x y a i) (twoCons x y a j) ≠ 0) : + MvPolynomial.eval₂Hom f (twoCons x y a) (scalarNumerator (n+2) dd rr) = + (x-y)*(x+y+f rr) * (∏ i : Fin n, discriminant (f dd) x (a i) * discriminant (f dd) y (a i)) * + MvPolynomial.eval₂Hom f a (scalarNumerator n dd rr) := by + let N : Matrix (Fin ((n+n%2)+2)) (Fin ((n+n%2)+2)) K := fun i j => + augmentedNumerator (f rr) (twoCons x y a) (augmentTwoIndex n i) (augmentTwoIndex n j) + let D : Matrix (Fin ((n+n%2)+2)) (Fin ((n+n%2)+2)) K := fun i j => + augmentedDenominator (f dd) (twoCons x y a) (augmentTwoIndex n i) (augmentTwoIndex n j) + have hN : ∀ i j, N j i = -N i j := fun i j => + augmentedNumerator_skew _ _ _ _ + have hDs : ∀ i j, D i j = D j i := fun i j => + augmentedDenominator_symm _ _ _ _ + have hD0 : D 0 1 = 0 := by simpa [D] using hzero + have hDn : ∀ i j, i ≠ j → ¬ ((i = 0 ∧ j = 1) ∨ (i = 1 ∧ j = 0)) → D i j ≠ 0 := by + intro i j hij hp + change (if hi : i.val < n + 2 then + if hj : j.val < n + 2 then + discriminant (f dd) (twoCons x y a ⟨i.val, hi⟩) (twoCons x y a ⟨j.val, hj⟩) + else 1 else 1) ≠ 0 + by_cases hi : i.val < n + 2 + · by_cases hj : j.val < n + 2 + · rw [dite_eq_left hi, dite_eq_left hj] + apply hD + · intro he + exact hij (Fin.ext (congrArg (fun z : Fin (n+2) => z.val) he)) + · intro he + apply hp + simp only [Fin.ext_iff, Fin.val_zero, Fin.val_one] at he ⊢ + omega + · simpa only [dite_eq_left hi, dite_eq_right hj] using (one_ne_zero : (1 : K) ≠ 0) + · simpa only [dite_eq_right hi] using (one_ne_zero : (1 : K) ≠ 0) + have hs : (n+2)+(n+2)%2 = (n+n%2)+2 := by omega + have ht : (2^(((n+2)+(n+2)%2)/2) * (Nat.factorial (((n+2)+(n+2)%2)/2) : K))⁻¹ = + (2^(((n+n%2)+2)/2) * (Nat.factorial (((n+n%2)+2)/2) : K))⁻¹ := by rw [hs] + have hc := clearedPfaffian_cast hs + (2^(((n+2)+(n+2)%2)/2) * (Nat.factorial (((n+2)+(n+2)%2)/2) : K))⁻¹ + (augmentedNumerator (f rr) (twoCons x y a)) + (augmentedDenominator (f dd) (twoCons x y a)) + change clearedPfaffian _ N D = _ at hc + rw [scalarNumerator_eval_cleared, ← hc, ht, + clearedPfaffian_delete_even (by omega : (n+n%2)%2 = 0) N D hN hDs hD0 hDn] + have hN01 : N 0 1 = (x-y)*(x+y+f rr) := by simp [N] + have hcross : (∏ i : Fin (n+n%2), D 0 i.succ.succ * D 1 i.succ.succ) = + ∏ i : Fin n, discriminant (f dd) x (a i) * discriminant (f dd) y (a i) := by + simpa only [D, augmentTwoIndex_zero, augmentTwoIndex_one] using + augmentedDenominator_two_cross (f dd) x y a + rw [hN01, hcross] + congr 1 + have htail : ∀ i j : Fin n, i ≠ j → discriminant (f dd) (a i) (a j) ≠ 0 := by + intro i j hij + have h := hD i.succ.succ j.succ.succ + (by simpa only [ne_eq, Fin.succ_inj] using hij) (by simp) + simpa only [twoCons_succ_succ] using h + rw [scalarNumerator_eval f n dd rr a htail] + congr 1 + · apply Finset.prod_congr rfl + intro e _ + exact augmentedDenominator_two_tail _ _ _ _ _ _ + · congr 1 + funext i j + dsimp [N,D] + rw [augmentedNumerator_two_tail, augmentedDenominator_two_tail, ← augmentedKernel_eq] + + + + + + + +theorem sourceVandermonde_twoCons {R : Type*} [CommRing R] {n : ℕ} + (x y : R) (a : Fin n → R) : + sourceVandermonde (twoCons x y a) = + (x-y) * (∏ i : Fin n, (x-a i)*(y-a i)) * sourceVandermonde a := by + unfold sourceVandermonde + apply Eq.trans (prod_upperPair_two (fun i j => twoCons x y a i - twoCons x y a j)) + simp only [twoCons_zero,twoCons_one,twoCons_succ_succ] + + + +theorem scalarPolynomial_delete_mul {K : Type*} [Field K] [CharZero K] (f : ℂ →+* K) + (n : ℕ) (dd rr : ℂ) (hdd : dd ≠ 0) (x y : K) (a : Fin n → K) + (hxy : x ≠ y) (ha : Function.Injective a) + (hzero : discriminant (f dd) x y = 0) + (hD : ∀ i j, i ≠ j → ¬ ((i = 0 ∧ j = 1) ∨ (i = 1 ∧ j = 0)) → + discriminant (f dd) (twoCons x y a i) (twoCons x y a j) ≠ 0) : + (∏ i : Fin n, (x-a i)*(y-a i)) * + MvPolynomial.eval₂Hom f (twoCons x y a) (scalarPolynomial (n+2) dd rr hdd) = + (x+y+f rr) * (∏ i : Fin n, discriminant (f dd) x (a i) * discriminant (f dd) y (a i)) * + MvPolynomial.eval₂Hom f a (scalarPolynomial n dd rr hdd) := by + have h := scalarNumerator_delete f n dd rr x y a hzero hD + rw [scalarNumerator_eq_vandermonde (n+2) dd rr hdd, + scalarNumerator_eq_vandermonde n dd rr hdd] at h + simp only [map_mul, map_sourceVandermonde, MvPolynomial.eval₂Hom_X', + sourceVandermonde_twoCons] at h + apply mul_left_cancel₀ (mul_ne_zero (sub_ne_zero.mpr hxy) (sourceVandermonde_ne_zero a ha)) + calc + _ = ((x-y) * (∏ i : Fin n, (x-a i)*(y-a i)) * sourceVandermonde a) * + MvPolynomial.eval₂Hom f (twoCons x y a) (scalarPolynomial (n+2) dd rr hdd) := by ring + _ = _ := h + _ = _ := by ring + + + +theorem scalarPolynomial_delete_roots {K : Type*} [Field K] [CharZero K] (f : ℂ →+* K) + (n : ℕ) (dd rr : ℂ) (hdd : dd ≠ 0) (x y γ σ : K) (a : Fin n → K) + (ha : Function.Injective (twoCons x y a)) + (hxroot : ∀ z, discriminant (f dd) x z = (z-y)*(z-γ)) + (hyroot : ∀ z, discriminant (f dd) y z = (z-x)*(z-σ)) + (hD : ∀ i j, i ≠ j → ¬ ((i = 0 ∧ j = 1) ∨ (i = 1 ∧ j = 0)) → + discriminant (f dd) (twoCons x y a i) (twoCons x y a j) ≠ 0) : + MvPolynomial.eval₂Hom f (twoCons x y a) (scalarPolynomial (n+2) dd rr hdd) = + (x+y+f rr) * (∏ i : Fin n, (a i-γ)*(a i-σ)) * + MvPolynomial.eval₂Hom f a (scalarPolynomial n dd rr hdd) := by + have hxy : x ≠ y := by + simpa only [twoCons_zero,twoCons_one] using ha.ne (Fin.zero_ne_one (n := n)) + have hai : Function.Injective a := by + intro i j he + have hs := ha (show twoCons x y a i.succ.succ = twoCons x y a j.succ.succ by simpa using he) + simpa only [Fin.succ_inj] using hs + have hx : ∀ i, x-a i ≠ 0 := by + intro i + apply sub_ne_zero.mpr + simpa only [twoCons_zero,twoCons_succ_succ] using ha.ne (Fin.succ_ne_zero i.succ).symm + have hy : ∀ i, y-a i ≠ 0 := by + intro i + apply sub_ne_zero.mpr + simpa only [twoCons_one,twoCons_succ_succ] using ha.ne (Fin.succ_succ_ne_one i).symm + have hA : (∏ i : Fin n, (x-a i)*(y-a i)) ≠ 0 := + Finset.prod_ne_zero_iff.mpr (fun i _ => mul_ne_zero (hx i) (hy i)) + have h := scalarPolynomial_delete_mul f n dd rr hdd x y a hxy hai (by simp [hxroot]) hD + have hB : (∏ i : Fin n, discriminant (f dd) x (a i) * discriminant (f dd) y (a i)) = + (∏ i : Fin n, (x-a i)*(y-a i)) * ∏ i : Fin n, (a i-γ)*(a i-σ) := by + rw [← Finset.prod_mul_distrib] + apply Finset.prod_congr rfl + intro i _ + rw [hxroot,hyroot] + ring + rw [hB] at h + apply mul_left_cancel₀ hA + calc + _ = _ := h + _ = _ := by ring + +end + + + + + +noncomputable section + +@[simp] theorem cos_six_lambda : Real.cos (6*lambda) = -d := by + have h : 6*lambda = Real.pi-2*lambda := by simp [lambda]; ring + rw [h,Real.cos_pi_sub] + rfl + +@[simp] theorem sin_six_lambda : Real.sin (6*lambda) = d := by + have h : 6*lambda = Real.pi-2*lambda := by simp [lambda]; ring + rw [h,Real.sin_pi_sub] + have h2 : 2*lambda = Real.pi/4 := by simp [lambda]; ring + rw [h2,d,h2,Real.sin_pi_div_four,Real.cos_pi_div_four] + +theorem d_sq : d^2 = 1/2 := by + have h2 : 2*lambda = Real.pi/4 := by simp [lambda]; ring + rw [d,h2,Real.cos_pi_div_four,div_pow] + rw [Real.sq_sqrt (by norm_num : (0:ℝ) ≤ 2)] + norm_num + +theorem d_ne_zero : d ≠ 0 := by + intro h + have := d_sq + rw [h] at this + norm_num at this + + +theorem discriminant_cosine_roots (w z : ℝ) : + discriminant d (Real.cos w) z = + (z-Real.cos (w-6*lambda))*(z-Real.cos (w+6*lambda)) := by + rw [Real.cos_sub,Real.cos_add,cos_six_lambda,sin_six_lambda] + unfold discriminant + have hw := Real.sin_sq_add_cos_sq w + nlinarith [sq_nonneg (Real.cos w),d_sq] + + +theorem discriminant_cosine_roots_complex (w : ℝ) (z : ℂ) : + discriminant (d:ℂ) (Real.cos w) z = + (z-(Real.cos (w-6*lambda):ℂ))*(z-(Real.cos (w+6*lambda):ℂ)) := by + have hs : (Real.cos (w-6*lambda):ℂ) + (Real.cos (w+6*lambda):ℂ) = + -2*(d:ℂ)*(Real.cos w:ℂ) := by + rw [Real.cos_sub,Real.cos_add,cos_six_lambda,sin_six_lambda] + push_cast + ring + have hp : (Real.cos (w-6*lambda):ℂ)*(Real.cos (w+6*lambda):ℂ) = + (Real.cos w:ℂ)^2-(d:ℂ)^2 := by + have h := discriminant_cosine_roots w 0 + have hr : Real.cos (w-6*lambda)*Real.cos (w+6*lambda) = Real.cos w^2-d^2 := by + simpa [discriminant] using h.symm + exact_mod_cast hr + unfold discriminant + linear_combination z*hs-hp + + + +theorem scalarPolynomial_delete_cosine (n : ℕ) (w : ℝ) (a : Fin n → ℂ) + (ha : Function.Injective (twoCons (Real.cos w:ℂ) (Real.cos (w+6*lambda):ℂ) a)) + (hD : ∀ i j, i ≠ j → ¬ ((i = 0 ∧ j = 1) ∨ (i = 1 ∧ j = 0)) → + discriminant (d:ℂ) (twoCons (Real.cos w:ℂ) (Real.cos (w+6*lambda):ℂ) a i) + (twoCons (Real.cos w:ℂ) (Real.cos (w+6*lambda):ℂ) a j) ≠ 0) : + MvPolynomial.eval (twoCons (Real.cos w:ℂ) (Real.cos (w+6*lambda):ℂ) a) + (scalarPolynomial (n+2) d rho (by exact_mod_cast d_ne_zero)) = + ((Real.cos w:ℂ)+(Real.cos (w+6*lambda):ℂ)+(rho:ℂ)) * + (∏ i : Fin n, (a i-(Real.cos (w-6*lambda):ℂ))*(a i-(Real.cos (w+12*lambda):ℂ))) * + MvPolynomial.eval a (scalarPolynomial n d rho (by exact_mod_cast d_ne_zero)) := by + apply scalarPolynomial_delete_roots (RingHom.id ℂ) n d rho _ _ _ _ _ a ha + · intro z + simpa only [RingHom.id_apply,mul_comm] using discriminant_cosine_roots_complex w z + · intro z + have h1 : w+6*lambda-6*lambda = w := by ring + have h2 : w+6*lambda+6*lambda = w+12*lambda := by ring + simpa only [RingHom.id_apply,h1,h2] using discriminant_cosine_roots_complex (w+6*lambda) z + · exact hD + + + + + + +open Finset +open scoped Classical + + + +def LastDegree {K : Type*} [CommRing K] {n : ℕ} (m : ℕ) + (P : Pairing (n+1) → Polynomial K) : Prop := + ∀ p k, (if p.Occupied (Fin.last n) then m ≤ k else m < k) → (P p).coeff k = 0 + +theorem lastTransform_coeff_succ {K : Type*} [CommRing K] {n : ℕ} + (w : Fin n → Tile → K) (d c C : K) + (P : Pairing (n+1) → Polynomial K) (q : Pairing (n+1)) (k : ℕ) : + (lastTransform w d c C P q).coeff (k+1) = ∑ p, lastCoefficient w q p * + (if q.Occupied (Fin.last n) then + if p.Occupied (Fin.last n) then (P p).coeff k - c * (P p).coeff (k+1) + else (2*d) * (P p).coeff (k+1) + else if p.Occupied (Fin.last n) then d * ((P p).coeff k - c * (P p).coeff (k+1)) + else (P p).coeff k + C * (P p).coeff (k+1)) := by + classical + simp only [lastTransform, Polynomial.finsetSum_coeff] + apply Finset.sum_congr rfl + intro p _ + by_cases hp : p.Occupied (Fin.last n) <;> by_cases hq : q.Occupied (Fin.last n) + all_goals simp [lastFactor, hp, hq, mul_add, mul_sub, add_mul, sub_mul, + mul_assoc, Polynomial.coeff_C_mul] + +theorem lastTransform_degree {K : Type*} [CommRing K] {n : ℕ} + (w : Fin n → Tile → K) (d c C : K) + (P : Pairing (n+1) → Polynomial K) {m : ℕ} (hP : LastDegree m P) : + LastDegree (m+1) (lastTransform w d c C P) := by + classical + intro q k hk + obtain ⟨j, rfl⟩ : ∃ j, k = j+1 := by + by_cases hq : q.Occupied (Fin.last n) <;> simp only [hq, ite_true, ite_false] at hk <;> + exact ⟨k-1, by omega⟩ + rw [lastTransform_coeff_succ] + apply Finset.sum_eq_zero + intro p _ + by_cases hq : q.Occupied (Fin.last n) <;> by_cases hp : p.Occupied (Fin.last n) + all_goals simp only [hq, hp, ite_true, ite_false] at hk ⊢ + all_goals have h₁ : (P p).coeff (j+1) = 0 := hP p (j+1) (by simp [hp]; omega) + · have h₀ : (P p).coeff j = 0 := hP p j (by simp [hp]; omega) + simp [h₀, h₁] + · simp [h₁] + · have h₀ : (P p).coeff j = 0 := hP p j (by simp [hp]; omega) + simp [h₀, h₁] + · have h₀ : (P p).coeff j = 0 := hP p j (by simp [hp]; omega) + simp [h₀, h₁] + +theorem Pairing.padTop_injective {n : ℕ} : Function.Injective (@Pairing.padTop n) := by + intro p q h + have := congrArg (fun r => r.restrict Fin.castSuccOrderEmb) h + simpa [Pairing.padTop, Pairing.restrict_map] using this + + + +theorem lastTransform_leading {K : Type*} [CommRing K] {n : ℕ} + (w : Fin n → Tile → K) (d c C : K) + (P : Pairing (n+1) → Polynomial K) {m : ℕ} (hP : LastDegree m P) + (q : Pairing n) : + (lastTransform w d c C P q.padTop).coeff (m+1) = + (rawColumn w).mulVec (fun p => (P p.padTop).coeff m) q := by + classical + rw [lastTransform_coeff_succ] + simp only [Pairing.padTop_not_occupied_last, ite_false, Matrix.mulVec, dotProduct] + symm + apply Fintype.sum_of_injective Pairing.padTop Pairing.padTop_injective + · intro p hp + have hp' : p.Occupied (Fin.last n) := by + by_contra h + exact hp ⟨p.restrict Fin.castSuccOrderEmb, Pairing.padTop_restrict p h⟩ + have h₀ := hP p m (by simp [hp']) + have h₁ := hP p (m+1) (by simp [hp']) + simp [hp', h₀, h₁] + · intro p + have h₁ := hP p.padTop (m+1) (by simp) + simp [lastCoefficient_padTop, h₁] + +end + + + + + +noncomputable section +open Finset +open scoped Classical + + + +def deletionNode {n : ℕ} (i : Fin n) : SpectralField n := + variableF i * constF n phase ^ 3 + +def deletionBeta {n : ℕ} (i : Fin n) : SpectralField n := + torusCos (deletionNode i ^ 2 / constF n phase ^ 3) + +def nodalWeights {n : ℕ} (i : Fin n) : Fin (n+1) → Weights (SpectralField n) := + Fin.snoc (spectralWeights n) (torusWeights (constF n phase ^ 3 / deletionNode i)) + + + +def nodalScalar {n : ℕ} (i : Fin n) : SpectralField n := + MvPolynomial.eval₂Hom (algebraMap ℂ (SpectralField n)) + (Fin.snoc spectralA (deletionBeta i)) + (scalarPolynomial (n+1) d rho (by exact_mod_cast d_ne_zero)) + +def nodalVacuum {n : ℕ} (i : Fin n) (p : Pairing (n+1)) : SpectralField n := + nodalScalar i * normalizedVacuum (nodalWeights i) p + + + +def rationalVacuum (n : ℕ) (p : Pairing n) : SpectralField n := + spectralNormalization n * normalizedVacuum (spectralWeights n) p + + + +def rationalNodalPolynomial (n : ℕ) (p : Pairing (n+1)) : Polynomial (SpectralField n) := + if p.Occupied (Fin.last n) then + Lagrange.interpolate univ deletionBeta + (fun i => nodalVacuum i p / torusSin (deletionNode i)) + else + Polynomial.C (rationalVacuum n (p.restrict Fin.castSuccOrderEmb)) * + Lagrange.nodal univ deletionBeta + + Lagrange.interpolate univ deletionBeta (fun i => nodalVacuum i p) + + + +def rationalInterpolant (n : ℕ) (p : Pairing (n+1)) : SpectralField (n+1) := + (if p.Occupied (Fin.last n) then torusSin (variableF (Fin.last n)) else 1) * + (rationalNodalPolynomial n p).eval₂ (liftSpectral n) (spectralA (Fin.last n)) + + + +def rationalInterpolationResidual (n : ℕ) (p : Pairing (n+1)) : SpectralField (n+1) := + (∏ i : Fin (n+1), evalLaurent (rowDenominator i)) * + (((column (spectralWeights (n+1))).mulVec (rationalInterpolant n)) p - + rationalInterpolant n p) + +end +end CriticalStrip.Diagram + +end OAI diff --git a/lean/OAI/Combinatorics/StripMass/Basic.lean b/lean/OAI/Combinatorics/StripMass/Basic.lean new file mode 100644 index 0000000000000000000000000000000000000000..0b709bff926124720fe74307f15c170ca6f193aa --- /dev/null +++ b/lean/OAI/Combinatorics/StripMass/Basic.lean @@ -0,0 +1,422 @@ +import Mathlib + +namespace OAI + +/-! Critical honeycomb strip paths, polynomial identities and crossing mass. -/ + + +namespace CriticalStrip + +noncomputable section +open scoped BigOperators +open Set MeasureTheory + +def rho : ℝ := 1 / Real.sqrt (2 + Real.sqrt 2) +def c : ℝ := Real.cos (3 * Real.pi / 8) +def lambda : ℝ := Real.pi / 8 +def d : ℝ := Real.cos (2 * lambda) +def C : ℝ := Real.cos lambda +def eta : ℝ := 2 * d - 1 + +abbrev Triangle := ℤ × ℕ × Bool + +def up (i : ℤ) (j : ℕ) : Triangle := (i, j, true) +def down (i : ℤ) (j : ℕ) : Triangle := (i, j, false) + +def upDownAdjacent (v w : Triangle) : Prop := + v.2.2 = true ∧ w.2.2 = false ∧ + ((v.2.1 = w.2.1 ∧ (w.1 = v.1 ∨ w.1 + 1 = v.1)) ∨ + (v.2.1 = w.2.1 + 1 ∧ v.1 = w.1)) + +def adjacent (v w : Triangle) : Prop := upDownAdjacent v w ∨ upDownAdjacent w v + + +def IsPath (N : ℕ) (finish : Triangle) (p : List Triangle) : Prop := + p.head? = some (up 0 0) ∧ p.getLast? = some finish ∧ p.Nodup ∧ + p.IsChain adjacent ∧ ∀ v ∈ p, v.2.1 < N + + +def archWeight (N : ℕ) (k : ℤ) (p : List Triangle) : ℝ := by + classical + exact if k ≠ 0 ∧ IsPath N (up k 0) p then rho ^ p.length else 0 + + +def bridgeWeight (N : ℕ) (k : ℤ) (p : List Triangle) : ℝ := by + classical + exact if 0 < N ∧ IsPath N (down k (N - 1)) p then rho ^ p.length else 0 + +def K (N : ℕ) (k : ℤ) : ℝ := ∑' p, archWeight N k p +def bridgeKernel (N : ℕ) (k : ℤ) : ℝ := ∑' p, bridgeWeight N k p +def archMass (N : ℕ) : ℝ := ∑' k : ℤ, K N k +def bridgeMass (N : ℕ) : ℝ := ∑' k : ℤ, bridgeKernel N k +def moment (N : ℕ) : ℝ := ∑' k : ℕ, (k + 1 : ℝ) * K N (k + 1) + + +def StripSumsFinite (N : ℕ) : Prop := + (∀ k : ℤ, Summable (archWeight N k)) ∧ + (∀ k : ℤ, Summable (bridgeWeight N k)) ∧ + Summable (K N) ∧ Summable (bridgeKernel N) ∧ + Summable (fun k : ℕ => (k + 1 : ℝ) * K N (k + 1)) + + +def Comparable (f g : ℕ → ℝ) : Prop := + ∃ lo hi : ℝ, 0 < lo ∧ 0 < hi ∧ + ∀ N : ℕ, 1 ≤ N → lo * g N ≤ f N ∧ f N ≤ hi * g N + + +def CriticalStripMass : Prop := + (∀ N : ℕ, 1 ≤ N → StripSumsFinite N) ∧ + (∀ N : ℕ, 1 ≤ N → c * archMass N + bridgeMass N = 1) ∧ + Comparable (fun N => moment (N + 1) - moment N) bridgeMass ∧ + Comparable moment (fun N => (N : ℝ) ^ (3 / 4 : ℝ)) ∧ + Comparable bridgeMass (fun N => (N : ℝ) ^ (-(1 / 4) : ℝ)) ∧ + (∀ N : ℕ, 1 ≤ N → bridgeMass (N + 1) ≤ bridgeMass N) + + +def homogeneousQ (N : ℕ) (g : Polynomial ℝ) : Polynomial ℝ := + (Polynomial.X - Polynomial.C C) ^ (2 * N + 1) * + (Polynomial.X - Polynomial.C c) ^ N * g + +def harmonicCoordinate : Polynomial ℝ := Polynomial.X ^ 2 * (1 - Polynomial.X ^ 2) + +def HasProjection (N : ℕ) (Q : Polynomial ℝ) : Prop := + ∃ P J E : Polynomial ℝ, + P.natDegree ≤ N ∧ J.natDegree ≤ N ∧ E.degree < (N : WithBot ℕ) ∧ + Q = P.comp harmonicCoordinate + Polynomial.X * J.comp harmonicCoordinate + + Polynomial.X ^ 2 * E.comp harmonicCoordinate + +def MonicProblem (N : ℕ) (g : Polynomial ℝ) : Prop := + g.Monic ∧ g.natDegree = N ∧ HasProjection N (homogeneousQ N g) + + +def omega (x : ℝ) : ℝ := (1 / 2) * Real.sqrt (Real.sqrt ((1 + x) / (2 * x)) - 1) + +def pairKernel (x y : ℝ) : ℝ := (y - x) ^ 2 / (y + x) + +def orderedDomain (N : ℕ) : Set (Fin N → ℝ) := + {y | StrictMono y ∧ ∀ i, y i ∈ Ioo 0 1} + +def density (N : ℕ) (y : Fin N → ℝ) : ℝ := + (∏ i, omega (y i)) * ∏ i, ∏ j ∈ Finset.Ioi i, pairKernel (y i) (y j) + +def normalizer (N : ℕ) : ℝ := ∫ y in orderedDomain N, density N y + +def expectation (N : ℕ) (f : (Fin N → ℝ) → ℝ) : ℝ := + (∫ y in orderedDomain N, f y * density N y) / normalizer N + +def reflectionProduct (N : ℕ) (x : ℝ) (y : Fin N → ℝ) : ℝ := + ∏ i, (y i - x) / (y i + x) + +def momentIntegrand (N : ℕ) (x : ℝ) : ℝ := + (1 - expectation N (reflectionProduct N x)) * omega x / x + + + +def PositiveIntegralCore : Prop := + ∀ N : ℕ, 1 ≤ N → + (∃! g : Polynomial ℝ, MonicProblem N g) ∧ + IntegrableOn (density N) (orderedDomain N) ∧ 0 < normalizer N ∧ + IntegrableOn (momentIntegrand N) (Ioo 0 1) ∧ + moment N = (eta / Real.pi) * ∫ x in Ioo 0 1, momentIntegrand N x + + +theorem omega_nonneg (x : ℝ) : 0 ≤ omega x := by + unfold omega + positivity + +theorem omega_pos {x : ℝ} (hx : x ∈ Ioo 0 1) : 0 < omega x := by + have hx0 := hx.1 + have hh : 1 < (1 + x) / (2 * x) := by + apply (lt_div_iff₀ (by positivity : 0 < 2 * x)).2 + linarith [hx.2] + have hh' : 1 < Real.sqrt ((1 + x) / (2 * x)) := by + simpa using Real.sqrt_lt_sqrt (by norm_num : (0 : ℝ) ≤ 1) hh + unfold omega + exact mul_pos (by norm_num) (Real.sqrt_pos.2 (sub_pos.2 hh')) + +theorem omega_le_rpow {x : ℝ} (hx : x ∈ Ioo 0 1) : + omega x ≤ x ^ (-(1 / 4 : ℝ)) := by + have hx0 := hx.1 + have ha : (1 + x) / (2 * x) ≤ 1 / x := by + apply (div_le_div_iff₀ (by positivity : 0 < 2 * x) hx.1).2 + nlinarith [mul_nonneg hx.1.le (sub_nonneg.mpr hx.2.le)] + have hb : Real.sqrt ((1 + x) / (2 * x)) - 1 ≤ Real.sqrt (1 / x) := + (sub_le_self _ (by norm_num : (0 : ℝ) ≤ 1)).trans (Real.sqrt_le_sqrt ha) + calc + omega x ≤ Real.sqrt (Real.sqrt ((1 + x) / (2 * x)) - 1) := by + unfold omega + nlinarith [Real.sqrt_nonneg (Real.sqrt ((1 + x) / (2 * x)) - 1)] + _ ≤ Real.sqrt (Real.sqrt (1 / x)) := Real.sqrt_le_sqrt hb + _ = x ^ (-(1 / 4 : ℝ)) := by + rw [Real.sqrt_eq_rpow, Real.sqrt_eq_rpow, + ← Real.rpow_mul (by positivity : 0 ≤ 1 / x)] + norm_num only [one_div, show (1 / 2 : ℝ) * (1 / 2) = 1 / 4 by norm_num] + rw [Real.inv_rpow hx.1.le, Real.rpow_neg hx.1.le] + +theorem measurable_omega : Measurable omega := by + unfold omega + fun_prop + +theorem integrableOn_omega : IntegrableOn omega (Ioo 0 1) := by + have hh : IntegrableOn (fun x : ℝ => x ^ (-(1 / 4 : ℝ))) (Ioo 0 1) := + (intervalIntegral.integrableOn_Ioo_rpow_iff (by norm_num : (0 : ℝ) < 1)).2 + (by norm_num) + apply hh.mono' measurable_omega.aestronglyMeasurable + filter_upwards [ae_restrict_mem measurableSet_Ioo] with x hx + simpa only [Real.norm_eq_abs, abs_of_nonneg (omega_nonneg x)] using omega_le_rpow hx + +theorem pairKernel_pos {x y : ℝ} (hx : 0 < x) (hxy : x < y) : + 0 < pairKernel x y := by + unfold pairKernel + exact div_pos (sq_pos_of_pos (sub_pos.2 hxy)) (by linarith) + +theorem pairKernel_nonneg {x y : ℝ} (hx : 0 ≤ x) (hy : 0 ≤ y) : + 0 ≤ pairKernel x y := by + unfold pairKernel + positivity + +theorem pairKernel_le_one {x y : ℝ} (hx : x ∈ Ioo 0 1) (hy : y ∈ Ioo 0 1) : + pairKernel x y ≤ 1 := by + unfold pairKernel + apply (div_le_one (by linarith [hx.1, hy.1] : 0 < y + x)).2 + have hxx : x ^ 2 ≤ x := by nlinarith [hx.1, hx.2] + have hyy : y ^ 2 ≤ y := by nlinarith [hy.1, hy.2] + nlinarith [mul_pos hx.1 hy.1] + +theorem density_pos {N : ℕ} {y : Fin N → ℝ} (hy : y ∈ orderedDomain N) : + 0 < density N y := by + apply mul_pos + · exact Finset.prod_pos fun i _ => omega_pos (hy.2 i) + · apply Finset.prod_pos + intro i _ + apply Finset.prod_pos + intro j hj + exact pairKernel_pos (hy.2 i).1 (hy.1 (Finset.mem_Ioi.1 hj)) + +theorem density_le_product {N : ℕ} {y : Fin N → ℝ} (hy : y ∈ orderedDomain N) : + density N y ≤ ∏ i, omega (y i) := by + have h0 : 0 ≤ ∏ i : Fin N, omega (y i) := + Finset.prod_nonneg fun _ _ => omega_nonneg _ + suffices hh : (∏ i : Fin N, ∏ j ∈ Finset.Ioi i, pairKernel (y i) (y j)) ≤ 1 by + simpa only [density, mul_one] using mul_le_mul_of_nonneg_left hh h0 + apply Finset.prod_le_one₀ + · intro i _ + exact Finset.prod_nonneg fun j _ => pairKernel_nonneg (hy.2 i).1.le (hy.2 j).1.le + · intro i _ + exact Finset.prod_le_one₀ + (fun j _ => pairKernel_nonneg (hy.2 i).1.le (hy.2 j).1.le) + (fun j _ => pairKernel_le_one (hy.2 i) (hy.2 j)) + +theorem measurable_density (N : ℕ) : Measurable (density N) := by + unfold density pairKernel + apply Measurable.mul + · exact Finset.measurable_prod _ fun i _ => measurable_omega.comp (measurable_pi_apply i) + · apply Finset.measurable_prod + intro i _ + apply Finset.measurable_prod + intro j _ + fun_prop + +theorem isOpen_orderedDomain (N : ℕ) : IsOpen (orderedDomain N) := by + have heq : orderedDomain N = + (⋂ i : Fin N, ⋂ j : Fin N, ⋂ (_ : i < j), {y | y i < y j}) ∩ + (⋂ i : Fin N, {y | y i ∈ Ioo (0 : ℝ) 1}) := by + ext y + simp only [orderedDomain, mem_ofPred_eq, mem_inter_iff, mem_iInter, StrictMono] + rw [heq] + apply IsOpen.inter + · apply isOpen_iInter_of_finite + intro i + apply isOpen_iInter_of_finite + intro j + apply isOpen_iInter_of_finite + intro _ + exact isOpen_lt (continuous_apply i) (continuous_apply j) + · exact isOpen_iInter_of_finite fun i => isOpen_Ioo.preimage (continuous_apply i) + +theorem integrableOn_density (N : ℕ) : IntegrableOn (density N) (orderedDomain N) := by + have hi : IntegrableOn (fun y : Fin N → ℝ => ∏ i, omega (y i)) + (Set.univ.pi fun _ : Fin N => Ioo (0 : ℝ) 1) := by + unfold IntegrableOn + rw [volume_pi, Measure.restrict_pi_pi] + exact Integrable.fintype_prod fun _ => integrableOn_omega + have his : IntegrableOn (fun y : Fin N → ℝ => ∏ i, omega (y i)) (orderedDomain N) := + hi.mono_set (fun _ hy => fun i _ => hy.2 i) + apply his.mono' (measurable_density N).aestronglyMeasurable + filter_upwards [ae_restrict_mem (isOpen_orderedDomain N).measurableSet] with y hy + simpa only [Real.norm_eq_abs, abs_of_pos (density_pos hy)] using density_le_product hy + + theorem orderedDomain_nonempty (N : ℕ) : (orderedDomain N).Nonempty := by + refine ⟨fun i => ((i : ℕ) + 1 : ℝ) / (N + 1 : ℕ), ?_⟩ + constructor + · intro i j hij + apply (div_lt_div_iff_of_pos_right (by positivity : (0 : ℝ) < (N + 1 : ℕ))).2 + exact_mod_cast Nat.add_lt_add_right hij 1 + · intro i + constructor + · exact div_pos (by positivity) (by positivity) + · apply (div_lt_one (by positivity : (0 : ℝ) < (N + 1 : ℕ))).2 + exact_mod_cast Nat.add_lt_add_right i.isLt 1 + +theorem normalizer_pos (N : ℕ) : 0 < normalizer N := by + have hpos : 0 ≤ᵐ[volume.restrict (orderedDomain N)] density N := by + filter_upwards [ae_restrict_mem (isOpen_orderedDomain N).measurableSet] with y hy + exact (density_pos hy).le + apply (integral_pos_iff_support_of_nonneg_ae hpos (integrableOn_density N)).2 + have hs : orderedDomain N ⊆ Function.support (density N) := + fun y hy => (density_pos hy).ne' + have hm := (isOpen_orderedDomain N).measure_pos volume (orderedDomain_nonempty N) + calc + 0 < volume (orderedDomain N) := hm + _ = (volume.restrict (orderedDomain N)) (orderedDomain N) := + (Measure.restrict_apply_self _ _).symm + _ ≤ (volume.restrict (orderedDomain N)) (Function.support (density N)) := measure_mono hs + + +theorem integrableOn_power_omega (s : ℝ) (hs : -(3 / 4 : ℝ) < s) : + IntegrableOn (fun x : ℝ => x ^ s * omega x) (Ioo 0 1) := by + have hp : IntegrableOn (fun x : ℝ => x ^ (s - 1 / 4)) (Ioo 0 1) := + (intervalIntegral.integrableOn_Ioo_rpow_iff (by norm_num : (0 : ℝ) < 1)).2 (by linarith) + apply hp.mono' ((measurable_id.pow_const s).mul measurable_omega).aestronglyMeasurable + filter_upwards [ae_restrict_mem measurableSet_Ioo] with x hx + have hx0 := hx.1 + change ‖x ^ s * omega x‖ ≤ _ + rw [Real.norm_eq_abs, abs_of_nonneg (mul_nonneg (Real.rpow_pos_of_pos hx.1 s).le (omega_nonneg x))] + calc + x ^ s * omega x ≤ x ^ s * x ^ (-(1 / 4 : ℝ)) := + mul_le_mul_of_nonneg_left (omega_le_rpow hx) (Real.rpow_pos_of_pos hx.1 s).le + _ = x ^ (s - 1 / 4) := by rw [← Real.rpow_add hx.1]; rfl + +theorem integrableOn_coordinate_weight (N : ℕ) (i : Fin N) : + IntegrableOn (fun y : Fin N → ℝ => (y i) ^ (-(1 / 2 : ℝ)) * density N y) + (orderedDomain N) := by + classical + let f : Fin N → ℝ → ℝ := fun j t => (if j = i then t ^ (-(1 / 2 : ℝ)) else 1) * omega t + have hf : ∀ j, IntegrableOn (f j) (Ioo 0 1) := by + intro j + by_cases hj : j = i + · simpa only [f, hj, ite_true] using integrableOn_power_omega (-(1 / 2 : ℝ)) (by norm_num) + · simpa only [f, hj, ite_false, one_mul] using integrableOn_omega + have hp : IntegrableOn (fun y : Fin N → ℝ => (y i) ^ (-(1 / 2 : ℝ)) * ∏ j, omega (y j)) + (Set.univ.pi fun _ : Fin N => Ioo (0 : ℝ) 1) := by + have he : (fun y : Fin N → ℝ => (y i) ^ (-(1 / 2 : ℝ)) * ∏ j, omega (y j)) = + (fun y => ∏ j, f j (y j)) := by + funext y + simp only [f, Finset.prod_mul_distrib, Finset.prod_ite_eq', Finset.mem_univ, ite_true] + rw [he] + unfold IntegrableOn + rw [volume_pi, Measure.restrict_pi_pi] + exact Integrable.fintype_prod hf + have hps := hp.mono_set (show orderedDomain N ⊆ Set.univ.pi (fun _ : Fin N => Ioo (0 : ℝ) 1) from + fun y hy i _ => hy.2 i) + apply hps.mono' (((measurable_pi_apply i).pow_const _).mul (measurable_density N)).aestronglyMeasurable + filter_upwards [ae_restrict_mem (isOpen_orderedDomain N).measurableSet] with y hy + have hi : 0 ≤ (y i) ^ (-(1 / 2 : ℝ)) := (Real.rpow_pos_of_pos (hy.2 i).1 _).le + change ‖(y i) ^ (-(1 / 2 : ℝ)) * density N y‖ ≤ _ + rw [Real.norm_eq_abs, abs_of_nonneg (mul_nonneg hi (density_pos hy).le)] + exact mul_le_mul_of_nonneg_left (density_le_product hy) hi + + +def inverseHalfSum (N : ℕ) (y : Fin N → ℝ) : ℝ := ∑ i, (y i) ^ (-(1 / 2 : ℝ)) + +theorem integrableOn_inverseHalfSum_density (N : ℕ) : + IntegrableOn (fun y => inverseHalfSum N y * density N y) (orderedDomain N) := by + simp only [inverseHalfSum, Finset.sum_mul] + exact integrable_finsetSum _ fun i _ => integrableOn_coordinate_weight N i + +theorem abs_one_sub_prod_le {ι : Type*} (s : Finset ι) (r : ι → ℝ) + (hr : ∀ i ∈ s, |r i| ≤ 1) : |1 - ∏ i ∈ s, r i| ≤ ∑ i ∈ s, |1 - r i| := by + classical + induction s using Finset.induction_on with + | empty => simp + | @insert i s hi ih => + have his : ∀ j ∈ s, |r j| ≤ 1 := fun j hj => hr j (Finset.mem_insert_of_mem hj) + rw [Finset.prod_insert hi, Finset.sum_insert hi] + calc + |1 - r i * ∏ j ∈ s, r j| = |(1 - r i) + r i * (1 - ∏ j ∈ s, r j)| := by congr 1; ring + _ ≤ |1 - r i| + |r i * (1 - ∏ j ∈ s, r j)| := abs_add_le _ _ + _ = |1 - r i| + |r i| * |1 - ∏ j ∈ s, r j| := by rw [abs_mul] + _ ≤ |1 - r i| + 1 * |1 - ∏ j ∈ s, r j| := + add_le_add le_rfl (mul_le_mul_of_nonneg_right (hr i (Finset.mem_insert_self _ _)) (abs_nonneg _)) + _ ≤ |1 - r i| + ∑ j ∈ s, |1 - r j| := by simpa using add_le_add (le_refl |1 - r i|) (ih his) + +theorem abs_reflectionFactor_le_one {x y : ℝ} (hx : 0 ≤ x) (hy : 0 < y) : + |(y - x) / (y + x)| ≤ 1 := by + apply abs_le.2 + have hxy : 0 < y + x := by linarith + constructor + · apply (le_div_iff₀ hxy).2 + linarith + · apply (div_le_iff₀ hxy).2 + linarith + +theorem abs_one_sub_reflectionFactor_le {x y : ℝ} (hx : 0 < x) (hy : 0 < y) : + |1 - (y - x) / (y + x)| ≤ Real.sqrt x * y ^ (-(1 / 2 : ℝ)) := by + have hxy : 0 < y + x := add_pos hy hx + have hxS := Real.sq_sqrt hx.le + have hyS := Real.sq_sqrt hy.le + have hxsp := Real.sqrt_pos.2 hx + have hysp := Real.sqrt_pos.2 hy + have hAM : 2 * Real.sqrt x * Real.sqrt y ≤ x + y := by + nlinarith [sq_nonneg (Real.sqrt x - Real.sqrt y)] + rw [show 1 - (y - x) / (y + x) = 2 * x / (y + x) by field_simp; ring, + abs_of_pos (div_pos (by positivity) hxy), Real.rpow_neg hy.le, + ← Real.sqrt_eq_rpow, ← div_eq_mul_inv] + apply (div_le_div_iff₀ hxy hysp).2 + nlinarith [mul_le_mul_of_nonneg_left hAM hxsp.le] + +theorem abs_reflectionProduct_le_one {N : ℕ} {y : Fin N → ℝ} + (hy : y ∈ orderedDomain N) {x : ℝ} (hx : 0 ≤ x) : |reflectionProduct N x y| ≤ 1 := by + rw [reflectionProduct, Finset.abs_prod] + exact Finset.prod_le_one₀ (fun _ _ => abs_nonneg _) (fun i _ => + abs_reflectionFactor_le_one hx (hy.2 i).1) + +theorem reflectionProduct_endpoint_bound {N : ℕ} {y : Fin N → ℝ} + (hy : y ∈ orderedDomain N) {x : ℝ} (hx : 0 < x) : + |1 - reflectionProduct N x y| ≤ Real.sqrt x * inverseHalfSum N y := by + calc + |1 - reflectionProduct N x y| ≤ ∑ i : Fin N, |1 - (y i - x) / (y i + x)| := + abs_one_sub_prod_le _ _ fun i _ => abs_reflectionFactor_le_one hx.le (hy.2 i).1 + _ ≤ ∑ i : Fin N, Real.sqrt x * (y i) ^ (-(1 / 2 : ℝ)) := + Finset.sum_le_sum fun i _ => abs_one_sub_reflectionFactor_le hx (hy.2 i).1 + _ = Real.sqrt x * inverseHalfSum N y := by rw [inverseHalfSum, Finset.mul_sum] + +theorem measurable_reflectionProduct (N : ℕ) : + Measurable (fun p : ℝ × (Fin N → ℝ) => reflectionProduct N p.1 p.2) := by + unfold reflectionProduct + apply Finset.measurable_prod + intro i _ + fun_prop + +theorem integrableOn_reflectionProduct_density (N : ℕ) {x : ℝ} (hx : 0 ≤ x) : + IntegrableOn (fun y => reflectionProduct N x y * density N y) (orderedDomain N) := by + have hm : Measurable (fun y => reflectionProduct N x y * density N y) := + ((measurable_reflectionProduct N).comp (measurable_const.prodMk measurable_id)).mul (measurable_density N) + apply (integrableOn_density N).mono' hm.aestronglyMeasurable + filter_upwards [ae_restrict_mem (isOpen_orderedDomain N).measurableSet] with y hy + rw [Real.norm_eq_abs, abs_mul, abs_of_pos (density_pos hy)] + exact (mul_le_mul_of_nonneg_right (abs_reflectionProduct_le_one hy hx) (density_pos hy).le).trans_eq (one_mul _) + +theorem integrableOn_deficit_density (N : ℕ) {x : ℝ} (hx : 0 ≤ x) : + IntegrableOn (fun y => (1 - reflectionProduct N x y) * density N y) (orderedDomain N) := by + simpa only [sub_mul, one_mul, Pi.sub_def] using (integrableOn_density N).sub (integrableOn_reflectionProduct_density N hx) + +theorem expectation_deficit (N : ℕ) {x : ℝ} (hx : 0 ≤ x) : + expectation N (fun y => 1 - reflectionProduct N x y) = 1 - expectation N (reflectionProduct N x) := by + unfold expectation + simp only [sub_mul, one_mul] + rw [integral_sub (integrableOn_density N) (integrableOn_reflectionProduct_density N hx)] + rw [sub_div, show (∫ y in orderedDomain N, density N y) = normalizer N from rfl] + rw [div_self (normalizer_pos N).ne'] + +theorem expectation_nonneg (N : ℕ) (f : (Fin N → ℝ) → ℝ) + (hf : ∀ y ∈ orderedDomain N, 0 ≤ f y) : 0 ≤ expectation N f := by + apply div_nonneg _ (normalizer_pos N).le + apply integral_nonneg_of_ae + filter_upwards [ae_restrict_mem (isOpen_orderedDomain N).measurableSet] with y hy + exact mul_nonneg (hf y hy) (density_pos hy).le + +end +end CriticalStrip + +end OAI diff --git a/lean/OAI/Combinatorics/StripMass/BlockPfaffian.lean b/lean/OAI/Combinatorics/StripMass/BlockPfaffian.lean new file mode 100644 index 0000000000000000000000000000000000000000..3dc5751e893c9efe579af7f870e329053335d6f3 --- /dev/null +++ b/lean/OAI/Combinatorics/StripMass/BlockPfaffian.lean @@ -0,0 +1,621 @@ +import Mathlib +import OAI.Combinatorics.StripMass.LaurentBox + +namespace OAI + +/-! Critical honeycomb strip paths, polynomial identities and crossing mass. -/ + + + +namespace CriticalStrip.Diagram +noncomputable section +open Finset + +def blockFirst {m : ℕ} (i : Fin m) : Fin (2*m) := ⟨2*i.val, by omega⟩ +def blockSecond {m : ℕ} (i : Fin m) : Fin (2*m) := ⟨2*i.val+1, by omega⟩ + +theorem blockFirst_injective {m : ℕ} : Function.Injective (@blockFirst m) := by + intro i j h + apply Fin.ext + have := congrArg Fin.val h + dsimp [blockFirst] at this + omega + +theorem blockSecond_injective {m : ℕ} : Function.Injective (@blockSecond m) := by + intro i j h + apply Fin.ext + have := congrArg Fin.val h + dsimp [blockSecond] at this + omega + +@[simp] theorem blockFirst_ne_second {m : ℕ} (i j : Fin m) : blockFirst i ≠ blockSecond j := by + intro h + have := congrArg Fin.val h + dsimp [blockFirst,blockSecond] at this + omega + +@[simp] theorem blockSecond_ne_first {m : ℕ} (i j : Fin m) : blockSecond i ≠ blockFirst j := + (blockFirst_ne_second j i).symm + +@[simp] theorem blockFirst_zero (m : ℕ) : blockFirst (0 : Fin (m+1)) = 0 := rfl +@[simp] theorem blockSecond_zero (m : ℕ) : blockSecond (0 : Fin (m+1)) = 1 := rfl + +def blockSummand {K : Type*} [CommRing K] {m : ℕ} + (M : Matrix (Fin (2*m)) (Fin (2*m)) K) (σ : Equiv.Perm (Fin (2*m))) : K := + (Equiv.Perm.sign σ : ℤ) * ∏ i : Fin m, M (σ (blockFirst i)) (σ (blockSecond i)) + +def blockSwap {m : ℕ} (k : Fin (m+1)) : Equiv.Perm (Fin (2*(m+1))) := + Equiv.swap (blockFirst 0) (blockFirst k) * Equiv.swap (blockSecond 0) (blockSecond k) + +theorem blockSwap_first {m : ℕ} (k i : Fin (m+1)) : + blockSwap k (blockFirst i) = blockFirst (Equiv.swap 0 k i) := by + simp only [blockSwap, Equiv.Perm.coe_mul, Function.comp_apply, + Equiv.swap_apply_of_ne_of_ne (blockFirst_ne_second i 0) (blockFirst_ne_second i k)] + exact (blockFirst_injective.map_swap 0 k i).symm + +theorem blockSwap_second {m : ℕ} (k i : Fin (m+1)) : + blockSwap k (blockSecond i) = blockSecond (Equiv.swap 0 k i) := by + change Equiv.swap (blockFirst 0) (blockFirst k) + (Equiv.swap (blockSecond 0) (blockSecond k) (blockSecond i)) = _ + rw [← blockSecond_injective.map_swap 0 k i] + exact Equiv.swap_apply_of_ne_of_ne (blockSecond_ne_first _ 0) (blockSecond_ne_first _ k) + +@[simp] theorem blockSwap_sign {m : ℕ} (k : Fin (m+1)) : Equiv.Perm.sign (blockSwap k) = 1 := by + by_cases hk : k = 0 + · simp [blockSwap,hk] + · rw [blockSwap, map_mul, + Equiv.Perm.sign_swap (blockFirst_injective.ne (Ne.symm hk)), + Equiv.Perm.sign_swap (blockSecond_injective.ne (Ne.symm hk))] + simp + +theorem blockSummand_swap {K : Type*} [CommRing K] {m : ℕ} + (M : Matrix (Fin (2*(m+1))) (Fin (2*(m+1))) K) + (σ : Equiv.Perm (Fin (2*(m+1)))) (k : Fin (m+1)) : + blockSummand M (σ*blockSwap k) = blockSummand M σ := by + simp only [blockSummand, map_mul, blockSwap_sign, mul_one, Equiv.Perm.coe_mul, + Function.comp_apply, blockSwap_first, blockSwap_second] + congr 1 + exact Equiv.prod_comp (Equiv.swap 0 k) (fun i => M (σ (blockFirst i)) (σ (blockSecond i))) + +def blockFlip (m : ℕ) : Equiv.Perm (Fin (2*(m+1))) := Equiv.swap 0 1 + +@[simp] theorem blockFlip_first_zero (m : ℕ) : blockFlip m (blockFirst 0) = blockSecond 0 := by + simp [blockFlip] + +@[simp] theorem blockFlip_second_zero (m : ℕ) : blockFlip m (blockSecond 0) = blockFirst 0 := by + simp [blockFlip] + +@[simp] theorem blockFlip_first_succ {m : ℕ} (i : Fin m) : + blockFlip m (blockFirst i.succ) = blockFirst i.succ := by + apply Equiv.swap_apply_of_ne_of_ne <;> intro h <;> + have hv := congrArg Fin.val h <;> simp only [blockFirst, Fin.val_mk, Fin.val_succ, Fin.val_zero, Fin.val_one] at hv <;> omega + +@[simp] theorem blockFlip_second_succ {m : ℕ} (i : Fin m) : + blockFlip m (blockSecond i.succ) = blockSecond i.succ := by + apply Equiv.swap_apply_of_ne_of_ne <;> intro h <;> + have hv := congrArg Fin.val h <;> simp only [blockSecond, Fin.val_mk, Fin.val_succ, Fin.val_zero, Fin.val_one] at hv <;> omega + +@[simp] theorem blockFlip_sign (m : ℕ) : Equiv.Perm.sign (blockFlip m) = -1 := by + exact Equiv.Perm.sign_swap (by intro h; have := congrArg Fin.val h; simp at this) + +theorem blockSummand_flip {K : Type*} [CommRing K] {m : ℕ} + (M : Matrix (Fin (2*(m+1))) (Fin (2*(m+1))) K) + (hM : ∀ i j, M j i = -M i j) (σ : Equiv.Perm (Fin (2*(m+1)))) : + blockSummand M (σ*blockFlip m) = blockSummand M σ := by + simp only [blockSummand, map_mul, blockFlip_sign, Units.val_mul, Int.cast_mul, + Units.val_neg, Units.val_one, Int.cast_neg, Int.cast_one, Equiv.Perm.coe_mul, + Function.comp_apply] + rw [Fin.prod_univ_succ, Fin.prod_univ_succ] + simp only [blockFlip_first_zero, blockFlip_second_zero, + blockFlip_first_succ, blockFlip_second_succ, hM (σ (blockFirst 0)) (σ (blockSecond 0))] + ring + + +def blockSection {m : ℕ} (p : Fin (2*(m+1))) : Equiv.Perm (Fin (2*(m+1))) := + let k : Fin (m+1) := ⟨p.val/2, by omega⟩ + if p.val%2 = 0 then blockSwap k else blockSwap k * blockFlip m + +@[simp] theorem blockSection_zero {m : ℕ} (p : Fin (2*(m+1))) : blockSection p 0 = p := by + unfold blockSection + split_ifs with hp + · rw [← blockFirst_zero m, blockSwap_first, Equiv.swap_apply_left] + apply Fin.ext + dsimp [blockFirst] + omega + · change blockSwap _ (blockFlip m 0) = p + rw [← blockFirst_zero m, blockFlip_first_zero, blockSwap_second, Equiv.swap_apply_left] + apply Fin.ext + dsimp [blockSecond] + omega + +theorem blockSummand_section {K : Type*} [CommRing K] {m : ℕ} + (M : Matrix (Fin (2*(m+1))) (Fin (2*(m+1))) K) + (hM : ∀ i j, M j i = -M i j) (σ : Equiv.Perm (Fin (2*(m+1)))) + (p : Fin (2*(m+1))) : blockSummand M (σ*blockSection p) = blockSummand M σ := by + unfold blockSection + split_ifs + · exact blockSummand_swap M σ _ + · rw [← mul_assoc, blockSummand_flip M hM, blockSummand_swap] + + + + + + + +abbrev FixedZero (n : ℕ) := {σ : Equiv.Perm (Fin (n+1)) // σ 0 = 0} + +instance (n : ℕ) : Fintype (FixedZero n) := by classical exact Subtype.fintype _ + +def fixedZeroEquiv (n : ℕ) : FixedZero n ≃ Equiv.Perm (Fin n) where + toFun σ := (Equiv.Perm.decomposeFin σ.val).2 + invFun σ := ⟨Equiv.Perm.decomposeFin.symm (0,σ), by simp⟩ + left_inv σ := by + apply Subtype.ext + have hp : (Equiv.Perm.decomposeFin σ.val).1 = 0 := by + have h := congrArg (fun e : Equiv.Perm (Fin (n+1)) => e 0) + (Equiv.Perm.decomposeFin.symm_apply_apply σ.val) + change Equiv.Perm.decomposeFin.symm ((Equiv.Perm.decomposeFin σ.val).1, + (Equiv.Perm.decomposeFin σ.val).2) 0 = σ.val 0 at h + rw [Equiv.Perm.decomposeFin_symm_apply_zero, σ.property] at h + exact h + change Equiv.Perm.decomposeFin.symm (0,(Equiv.Perm.decomposeFin σ.val).2) = σ.val + conv_rhs => rw [← Equiv.Perm.decomposeFin.symm_apply_apply σ.val] + congr 1 + exact Prod.ext hp.symm rfl + right_inv σ := by simp + + + +def blockPermutationEquiv (m : ℕ) : Equiv.Perm (Fin (2*(m+1))) ≃ + Fin (2*(m+1)) × FixedZero (2*m+1) where + toFun σ := (σ⁻¹ 0, ⟨σ * blockSection (σ⁻¹ 0), by + change σ (blockSection (m := m) (σ⁻¹ 0) 0) = 0 + rw [blockSection_zero (m := m)] + exact σ.apply_symm_apply 0⟩) + invFun p := p.2.val * (blockSection p.1)⁻¹ + left_inv σ := by simp + right_inv p := by + rcases p with ⟨p,ρ⟩ + have hi : ρ.val⁻¹ 0 = 0 := by + apply ρ.val.injective + change ρ.val (ρ.val.symm 0) = ρ.val 0 + rw [ρ.val.apply_symm_apply] + exact ρ.property.symm + have hp : (ρ.val * (blockSection p)⁻¹)⁻¹ 0 = p := by + simp only [mul_inv_rev, inv_inv, Equiv.Perm.mul_apply, hi] + exact blockSection_zero (m := m) p + apply Prod.ext hp + apply Subtype.ext + change (ρ.val * (blockSection p)⁻¹) * + blockSection ((ρ.val * (blockSection p)⁻¹)⁻¹ 0) = ρ.val + rw [hp, mul_assoc, inv_mul_cancel, mul_one] + +theorem blockSummand_section_inv {K : Type*} [CommRing K] {m : ℕ} + (M : Matrix (Fin (2*(m+1))) (Fin (2*(m+1))) K) + (hM : ∀ i j, M j i = -M i j) (σ : Equiv.Perm (Fin (2*(m+1)))) + (p : Fin (2*(m+1))) : blockSummand M (σ*(blockSection p)⁻¹) = blockSummand M σ := by + have h := blockSummand_section M hM (σ*(blockSection p)⁻¹) p + simpa only [mul_assoc, inv_mul_cancel, mul_one] using h.symm + +theorem blockSummand_sum_fixedZero {K : Type*} [CommRing K] {m : ℕ} + (M : Matrix (Fin (2*(m+1))) (Fin (2*(m+1))) K) + (hM : ∀ i j, M j i = -M i j) : + ∑ σ, blockSummand M σ = (2*(m+1) : K) * + ∑ τ : Equiv.Perm (Fin (2*m+1)), + blockSummand M (Equiv.Perm.decomposeFin.symm (0,τ)) := by + classical + rw [← Equiv.sum_comp (blockPermutationEquiv m).symm] + simp only [Fintype.sum_prod_type, blockPermutationEquiv, Equiv.coe_fn_symm_mk, + blockSummand_section_inv M hM] + rw [Finset.sum_const, Finset.card_univ, Fintype.card_fin, nsmul_eq_mul] + congr 1 + · norm_cast + · exact (Equiv.sum_comp (fixedZeroEquiv (2*m+1)).symm + (fun σ => blockSummand M σ.val)).symm + +@[simp] theorem blockFirst_succ {m : ℕ} (i : Fin m) : + blockFirst i.succ = (blockFirst i).succ.succ := by + apply Fin.ext + simp [blockFirst] + omega + +@[simp] theorem blockSecond_succ {m : ℕ} (i : Fin m) : + blockSecond i.succ = (blockSecond i).succ.succ := by + apply Fin.ext + simp [blockSecond] + omega + + + +theorem blockSummand_fixTwo {K : Type*} [CommRing K] {m : ℕ} + (M : Matrix (Fin (2*(m+1))) (Fin (2*(m+1))) K) + (σ : Equiv.Perm (Fin (2*m))) : + blockSummand M (Equiv.Perm.decomposeFin.symm + (0,Equiv.Perm.decomposeFin.symm (0,σ))) = + M 0 1 * blockSummand (fun i j => M i.succ.succ j.succ.succ) σ := by + change Fin (2*m+2) → Fin (2*m+2) → K at M + unfold blockSummand + rw [Fin.prod_univ_succ] + simp only [blockFirst_zero, blockSecond_zero, blockFirst_succ, blockSecond_succ] + change ((Equiv.Perm.sign (Equiv.Perm.decomposeFin.symm + (0, Equiv.Perm.decomposeFin.symm (0, σ))) : ℤ) : K) * + (M (Equiv.Perm.decomposeFin.symm (0, Equiv.Perm.decomposeFin.symm (0, σ)) 0) + (Equiv.Perm.decomposeFin.symm (0, Equiv.Perm.decomposeFin.symm (0, σ)) 1) * + ∏ index : Fin m, + M (Equiv.Perm.decomposeFin.symm (0, Equiv.Perm.decomposeFin.symm (0, σ)) + (blockFirst index).succ.succ) + (Equiv.Perm.decomposeFin.symm (0, Equiv.Perm.decomposeFin.symm (0, σ)) + (blockSecond index).succ.succ)) = _ + simp only [Equiv.Perm.decomposeFin.symm_sign, ite_true, one_mul, + Equiv.Perm.decomposeFin_symm_apply_zero, + Equiv.Perm.decomposeFin_symm_apply_one, Equiv.swap_self, Equiv.refl_apply, + Fin.succ_zero_eq_one, + Equiv.Perm.decomposeFin_symm_apply_succ] + ring + +theorem blockSummand_isolated_zero {K : Type*} [CommRing K] {m : ℕ} + (M : Matrix (Fin (2*(m+1))) (Fin (2*(m+1))) K) + (hzero : ∀ j, j ≠ 1 → M 0 j = 0) + (p : Fin (2*m+1)) (hp : p ≠ 0) (σ : Equiv.Perm (Fin (2*m))) : + blockSummand M (Equiv.Perm.decomposeFin.symm + (0,Equiv.Perm.decomposeFin.symm (p,σ))) = 0 := by + change Fin (2*m+2) → Fin (2*m+2) → K at M + unfold blockSummand + rw [Fin.prod_univ_succ] + simp only [blockFirst_zero, blockSecond_zero] + change ((Equiv.Perm.sign (Equiv.Perm.decomposeFin.symm + (0, Equiv.Perm.decomposeFin.symm (p, σ))) : ℤ) : K) * + (M (Equiv.Perm.decomposeFin.symm (0, Equiv.Perm.decomposeFin.symm (p, σ)) 0) + (Equiv.Perm.decomposeFin.symm (0, Equiv.Perm.decomposeFin.symm (p, σ)) 1) * _) = 0 + simp only [Equiv.Perm.decomposeFin_symm_apply_zero, + Equiv.Perm.decomposeFin_symm_apply_one, Equiv.swap_self, Equiv.refl_apply] + rw [hzero p.succ (by + change p.succ ≠ (0 : Fin (2*m+1)).succ + exact (Fin.succ_injective (2*m+1)).ne hp), + zero_mul, mul_zero] + +theorem blockSummand_sum_isolated {K : Type*} [CommRing K] {m : ℕ} + (M : Matrix (Fin (2*(m+1))) (Fin (2*(m+1))) K) + (hM : ∀ i j, M j i = -M i j) (hzero : ∀ j, j ≠ 1 → M 0 j = 0) : + ∑ σ, blockSummand M σ = (2*(m+1) : K) * M 0 1 * + ∑ σ, blockSummand (fun i j => M i.succ.succ j.succ.succ) σ := by + classical + rw [blockSummand_sum_fixedZero M hM] + rw [← Equiv.sum_comp (Equiv.Perm.decomposeFin (n := 2*m)).symm] + simp only [Fintype.sum_prod_type] + rw [Finset.sum_eq_single 0] + · have sum_eq : (∑ σ : Equiv.Perm (Fin (2*m)), + blockSummand M (Equiv.Perm.decomposeFin.symm + (0, Equiv.Perm.decomposeFin.symm (0, σ)))) = + M 0 1 * ∑ σ, blockSummand (fun i j => M i.succ.succ j.succ.succ) σ := by + rw [Finset.mul_sum] + apply Finset.sum_congr rfl + intro σ _ + exact blockSummand_fixTwo M σ + exact (congrArg (fun value : K => (2*(m+1) : K) * value) sum_eq).trans + (mul_assoc _ _ _).symm + · intro p _ hp + exact Finset.sum_eq_zero (fun σ _ => blockSummand_isolated_zero M hzero p hp σ) + · simp + + + + + + + + +theorem pfaffian_eq_block {K : Type*} [Field K] {m : ℕ} + (M : Matrix (Fin (2*m)) (Fin (2*m)) K) : + pfaffian M = (2^m * (Nat.factorial m : K))⁻¹ * ∑ σ, blockSummand M σ := by + have hm : 2*m/2 = m := by omega + unfold pfaffian blockSummand + congr 1 + · rw [hm] + · apply Finset.sum_congr rfl + intro σ _ + congr 1 + let e : Fin (2*m/2) ≃ Fin m := finCongr hm + apply Fintype.prod_equiv e + intro i + congr 2 + + + +theorem pfaffian_isolated {K : Type*} [Field K] [CharZero K] {m : ℕ} + (M : Matrix (Fin (2*(m+1))) (Fin (2*(m+1))) K) + (hM : ∀ i j, M j i = -M i j) (hzero : ∀ j, j ≠ 1 → M 0 j = 0) : + pfaffian M = M 0 1 * pfaffian (fun i j : Fin (2*m) => M i.succ.succ j.succ.succ) := by + rw [pfaffian_eq_block M, blockSummand_sum_isolated M hM hzero, + pfaffian_eq_block (m := m) (fun i j : Fin (2*m) => M i.succ.succ j.succ.succ)] + rw [pow_succ, Nat.factorial_succ, Nat.cast_mul, Nat.cast_add, Nat.cast_one] + have htwo : (2 : K) ≠ 0 := by norm_num + have hm : (m+1 : K) ≠ 0 := by exact_mod_cast Nat.succ_ne_zero m + have hf : (Nat.factorial m : K) ≠ 0 := by exact_mod_cast Nat.factorial_ne_zero m + field_simp + + + +theorem blockSummand_fixZero {K : Type*} [CommRing K] {m : ℕ} + (M : Matrix (Fin (2*(m+1))) (Fin (2*(m+1))) K) + (τ : Equiv.Perm (Fin (2*m+1))) : + blockSummand M (Equiv.Perm.decomposeFin.symm (0,τ)) = + (Equiv.Perm.sign τ : ℤ) * M 0 (τ 0).succ * + ∏ i : Fin m, M (τ (blockFirst i).succ).succ (τ (blockSecond i).succ).succ := by + change Fin (2*m+2) → Fin (2*m+2) → K at M + unfold blockSummand + rw [Fin.prod_univ_succ] + simp only [blockFirst_zero, blockSecond_zero, blockFirst_succ, blockSecond_succ] + change ((Equiv.Perm.sign (Equiv.Perm.decomposeFin.symm (0, τ)) : ℤ) : K) * + (M (Equiv.Perm.decomposeFin.symm (0, τ) 0) + (Equiv.Perm.decomposeFin.symm (0, τ) 1) * + ∏ index : Fin m, + M (Equiv.Perm.decomposeFin.symm (0, τ) (blockFirst index).succ.succ) + (Equiv.Perm.decomposeFin.symm (0, τ) (blockSecond index).succ.succ)) = _ + simp only [Equiv.Perm.decomposeFin.symm_sign, ite_true, one_mul, + Equiv.Perm.decomposeFin_symm_apply_zero, + Equiv.Perm.decomposeFin_symm_apply_one, Equiv.swap_self, Equiv.refl_apply, + Equiv.Perm.decomposeFin_symm_apply_succ] + ring + + + +theorem pfaffian_firstRow_add {K : Type*} [Field K] {m : ℕ} + (M A B : Matrix (Fin (2*(m+1))) (Fin (2*(m+1))) K) + (hM : ∀ i j, M j i = -M i j) + (hA : ∀ i j, A j i = -A i j) + (hB : ∀ i j, B j i = -B i j) + (hrow : ∀ j, M 0 j = A 0 j + B 0 j) + (hrestA : ∀ i j : Fin (2*m+1), M i.succ j.succ = A i.succ j.succ) + (hrestB : ∀ i j : Fin (2*m+1), M i.succ j.succ = B i.succ j.succ) : + pfaffian M = pfaffian A + pfaffian B := by + rw [pfaffian_eq_block, pfaffian_eq_block, pfaffian_eq_block, + blockSummand_sum_fixedZero M hM, blockSummand_sum_fixedZero A hA, + blockSummand_sum_fixedZero B hB] + rw [← mul_add, ← mul_add, ← Finset.sum_add_distrib] + congr 2 + apply Finset.sum_congr rfl + intro τ _ + simp only [blockSummand_fixZero, hrow] + have hprodA : (∏ i : Fin m, M (τ (blockFirst i).succ).succ (τ (blockSecond i).succ).succ) = + ∏ i : Fin m, A (τ (blockFirst i).succ).succ (τ (blockSecond i).succ).succ := + Finset.prod_congr rfl (fun _ _ => hrestA _ _) + have hprodB : (∏ i : Fin m, M (τ (blockFirst i).succ).succ (τ (blockSecond i).succ).succ) = + ∏ i : Fin m, B (τ (blockFirst i).succ).succ (τ (blockSecond i).succ).succ := + Finset.prod_congr rfl (fun _ _ => hrestB _ _) + rw [← hprodA, ← hprodB] + ring + + + + + + + + + +theorem clearedPfaffianTerm_of_missing_pair {R : Type*} [CommRing R] {m : ℕ} + (N D : Matrix (Fin (2*(m+1))) (Fin (2*(m+1))) R) + (hD : D 0 1 = 0) (σ : Equiv.Perm (Fin (2*(m+1)))) + (hσ : firstPair m ∉ selectedPairs σ) : clearedPfaffianTerm N D σ = 0 := by + unfold clearedPfaffianTerm + have hz : (∏ e ∈ (selectedPairs σ)ᶜ, D e.val.1 e.val.2) = 0 := by + apply Finset.prod_eq_zero (Finset.mem_compl.mpr hσ) + exact hD + rw [hz, mul_zero] + + +theorem isolateFirstNumerator_prod_of_missing_pair {R : Type*} [CommRing R] {m : ℕ} + (N : Matrix (Fin (2*(m+1))) (Fin (2*(m+1))) R) + (σ : Equiv.Perm (Fin (2*(m+1)))) (hσ : firstPair m ∉ selectedPairs σ) : + (∏ i : Fin (2*(m+1)/2), + isolateFirstNumerator N (σ (pairFirst _ i)) (σ (pairSecond _ i))) = 0 := by + obtain ⟨i,hi⟩ := pairIndex_cover (n := 2*(m+1)) (by omega) σ 0 + apply Finset.prod_eq_zero (Finset.mem_univ i) + have hpair : permutationPair σ i ≠ firstPair m := by + intro he + apply hσ + exact he ▸ Finset.mem_image.mpr ⟨i,Finset.mem_univ _,rfl⟩ + unfold isolateFirstNumerator + rw [ite_eq_left] + rcases hi with hi | hi + · left + refine ⟨hi,?_⟩ + intro hj + apply hpair + unfold permutationPair + simp only [hi,hj] + exact (firstPair_eq_upperPair m).symm + · right + refine ⟨hi,?_⟩ + intro hj + apply hpair + unfold permutationPair upperPair + have h : ¬ (1 : Fin (2*(m+1))) < 0 := by exact not_lt_of_ge (firstPair m).property.le + simp only [hi,hj,h,dite_false,firstPair] + + + +theorem clearedPfaffian_collision {R : Type*} [CommRing R] {m : ℕ} + (t : R) (N D : Matrix (Fin (2*(m+1))) (Fin (2*(m+1))) R) (hD : D 0 1 = 0) : + clearedPfaffian t N D = + clearedPfaffian t (isolateFirstNumerator N) (repairFirstDenominator D) := by + classical + unfold clearedPfaffian + congr 1 + apply Finset.sum_congr rfl + intro σ _ + congr 1 + by_cases hσ : firstPair m ∈ selectedPairs σ + · unfold clearedPfaffianTerm + congr 1 + · apply Finset.prod_congr rfl + intro i _ + exact (isolateFirstNumerator_selected N σ hσ i).symm + · apply Finset.prod_congr rfl + intro e he + exact (repairFirstDenominator_compl D σ hσ e he).symm + · rw [clearedPfaffianTerm_of_missing_pair N D hD σ hσ] + simp only [clearedPfaffianTerm, + isolateFirstNumerator_prod_of_missing_pair N σ hσ, zero_mul] + +theorem repairFirstDenominator_symm {R : Type*} [One R] {m : ℕ} + (D : Matrix (Fin (2*(m+1))) (Fin (2*(m+1))) R) (hD : ∀ i j, D i j = D j i) : + ∀ i j, repairFirstDenominator D i j = repairFirstDenominator D j i := by + intro i j + unfold repairFirstDenominator + have h : ((i = 0 ∧ j = 1) ∨ (i = 1 ∧ j = 0)) ↔ + ((j = 0 ∧ i = 1) ∨ (j = 1 ∧ i = 0)) := by tauto + simp only [h, hD i j] + +theorem isolateFirstNumerator_skew {R : Type*} [AddGroup R] {m : ℕ} + (N : Matrix (Fin (2*(m+1))) (Fin (2*(m+1))) R) (hN : ∀ i j, N j i = -N i j) : + ∀ i j, isolateFirstNumerator N j i = -isolateFirstNumerator N i j := by + intro i j + unfold isolateFirstNumerator + have h : ((j = 0 ∧ i ≠ 1) ∨ (i = 0 ∧ j ≠ 1)) ↔ + ((i = 0 ∧ j ≠ 1) ∨ (j = 0 ∧ i ≠ 1)) := by tauto + simp only [h] + split_ifs + · exact neg_zero.symm + · exact hN i j + + + +theorem clearedPfaffian_collision_formula {K : Type*} [Field K] [CharZero K] {m : ℕ} + (N D : Matrix (Fin (2*(m+1))) (Fin (2*(m+1))) K) + (hN : ∀ i j, N j i = -N i j) (hD : ∀ i j, D i j = D j i) + (hzero : D 0 1 = 0) + (hne : ∀ i j, i ≠ j → ¬ ((i = 0 ∧ j = 1) ∨ (i = 1 ∧ j = 0)) → D i j ≠ 0) : + clearedPfaffian (2^((2*(m+1))/2) * (Nat.factorial ((2*(m+1))/2) : K))⁻¹ N D = + (∏ e : UpperPair (2*(m+1)), repairFirstDenominator D e.val.1 e.val.2) * + (N 0 1 * pfaffian (fun i j : Fin (2*m) => + N i.succ.succ j.succ.succ / D i.succ.succ j.succ.succ)) := by + classical + rw [clearedPfaffian_collision _ N D hzero] + rw [← clear_pfaffian (isolateFirstNumerator N) (repairFirstDenominator D) + (repairFirstDenominator_symm D hD) (by + intro i j hij + unfold repairFirstDenominator + split_ifs with h + · exact one_ne_zero + · exact hne i j hij h)] + congr 1 + let M : Matrix (Fin (2*(m+1))) (Fin (2*(m+1))) K := fun i j => + isolateFirstNumerator N i j / repairFirstDenominator D i j + have hM : ∀ i j, M j i = -M i j := by + intro i j + dsimp [M] + rw [isolateFirstNumerator_skew N hN i j, + repairFirstDenominator_symm D hD j i, neg_div] + change pfaffian M = _ + rw [pfaffian_isolated M hM (by intro j hj; simp [M,isolateFirstNumerator,hj])] + have h01 : M 0 1 = N 0 1 := by + simp [M,isolateFirstNumerator,repairFirstDenominator] + rw [h01] + congr 2 + + + + + + + + +def firstPairDecompose (n : ℕ) : UpperPair (n+1) ≃ Fin n ⊕ UpperPair n where + toFun e := if hi : e.val.1 = 0 then + Sum.inl (e.val.2.pred (ne_of_gt (hi ▸ e.property))) + else + let hj : e.val.2 ≠ 0 := by + intro hj; have := e.property; simp [hj] at this + Sum.inr ⟨(e.val.1.pred hi,e.val.2.pred hj), + (Fin.pred_lt_pred_iff (ha := hi) (hb := hj)).mpr e.property⟩ + invFun e := match e with + | Sum.inl j => ⟨(0,j.succ),Fin.succ_pos _⟩ + | Sum.inr e => ⟨(e.val.1.succ,e.val.2.succ), Fin.succ_lt_succ_iff.mpr e.property⟩ + left_inv e := by + dsimp + split_ifs with hi + · apply Subtype.ext + apply Prod.ext hi.symm + simp only [Fin.succ_pred] + · apply Subtype.ext + apply Prod.ext <;> simp only [Fin.succ_pred] + right_inv e := by + cases e with + | inl j => simp + | inr e => simp + + +theorem prod_upperPair_succ {R : Type*} [CommMonoid R] {n : ℕ} + (D : Fin (n+1) → Fin (n+1) → R) : + (∏ e : UpperPair (n+1), D e.val.1 e.val.2) = + (∏ j : Fin n, D 0 j.succ) * + ∏ e : UpperPair n, D e.val.1.succ e.val.2.succ := by + calc + _ = ∏ e : Fin n ⊕ UpperPair n, + D ((firstPairDecompose n).symm e).val.1 ((firstPairDecompose n).symm e).val.2 := + (Fintype.prod_equiv (firstPairDecompose n).symm _ _ (fun _ => rfl)).symm + _ = _ := by rw [Fintype.prod_sum_type]; rfl + +theorem prod_upperPair_two {R : Type*} [CommMonoid R] {n : ℕ} + (D : Fin (n+2) → Fin (n+2) → R) : + (∏ e : UpperPair (n+2), D e.val.1 e.val.2) = + D 0 1 * (∏ j : Fin n, D 0 j.succ.succ * D 1 j.succ.succ) * + ∏ e : UpperPair n, D e.val.1.succ.succ e.val.2.succ.succ := by + rw [prod_upperPair_succ D, Fin.prod_univ_succ, + prod_upperPair_succ (fun i j : Fin (n+1) => D i.succ j.succ), + Finset.prod_mul_distrib] + simp only [Fin.succ_zero_eq_one] + ac_rfl + + + + + + + +theorem pfaffian_cast {K : Type*} [Field K] {n m : ℕ} (h : n = m) + (M : Matrix (Fin n) (Fin n) K) : + pfaffian (fun i j : Fin m => M (i.cast h.symm) (j.cast h.symm)) = pfaffian M := by + subst m + rfl + +theorem clearedPfaffian_cast {R : Type*} [CommRing R] {n m : ℕ} (h : n = m) + (t : R) (N D : Matrix (Fin n) (Fin n) R) : + clearedPfaffian t (fun i j : Fin m => N (i.cast h.symm) (j.cast h.symm)) + (fun i j : Fin m => D (i.cast h.symm) (j.cast h.symm)) = clearedPfaffian t N D := by + subst m + rfl + + + +theorem clearedPfaffian_delete_even {K : Type*} [Field K] [CharZero K] {n : ℕ} + (hn : n % 2 = 0) (N D : Matrix (Fin (n+2)) (Fin (n+2)) K) + (hN : ∀ i j, N j i = -N i j) (hD : ∀ i j, D i j = D j i) + (hzero : D 0 1 = 0) + (hne : ∀ i j, i ≠ j → ¬ ((i = 0 ∧ j = 1) ∨ (i = 1 ∧ j = 0)) → D i j ≠ 0) : + clearedPfaffian (2^((n+2)/2) * (Nat.factorial ((n+2)/2) : K))⁻¹ N D = + N 0 1 * (∏ j : Fin n, D 0 j.succ.succ * D 1 j.succ.succ) * + ((∏ e : UpperPair n, D e.val.1.succ.succ e.val.2.succ.succ) * + pfaffian (fun i j : Fin n => N i.succ.succ j.succ.succ / D i.succ.succ j.succ.succ)) := by + obtain ⟨m,rfl⟩ : ∃ m, n = 2*m := ⟨n/2,by omega⟩ + apply Eq.trans (clearedPfaffian_collision_formula N D hN hD hzero hne) + apply Eq.trans (congrArg (fun z => z * + (N 0 1 * pfaffian (fun i j : Fin (2*m) => + N i.succ.succ j.succ.succ / D i.succ.succ j.succ.succ))) + (prod_upperPair_two (n := 2*m) (repairFirstDenominator D))) + have hs : ∀ i : Fin (2*m), i.succ.succ ≠ (1 : Fin (2*m+2)) := by + intro i h + have := congrArg Fin.val h + simp at this + simp only [repairFirstDenominator, Fin.succ_ne_zero, hs, + and_false, or_false, ite_false, + and_self, true_or, ite_true, one_mul] + ac_rfl + +end +end CriticalStrip.Diagram + +end OAI diff --git a/lean/OAI/Combinatorics/StripMass/BottomGauge.lean b/lean/OAI/Combinatorics/StripMass/BottomGauge.lean new file mode 100644 index 0000000000000000000000000000000000000000..2447848f97b1b54a3204ba77b6ef570ae7b2c398 --- /dev/null +++ b/lean/OAI/Combinatorics/StripMass/BottomGauge.lean @@ -0,0 +1,512 @@ +import Mathlib +import OAI.Combinatorics.StripMass.SplitGluing + +namespace OAI + +/-! Critical honeycomb strip paths, polynomial identities and crossing mass. -/ + + +namespace CriticalStrip.Diagram +noncomputable section +open scoped Classical BigOperators + + +def occupancyGauge {K : Type*} [One K] {n : ℕ} (a : K) (p : Pairing n) (i : Fin n) : K := + if p.Occupied i then a else 1 + +@[simp] lemma occupancyGauge_empty {K : Type*} [One K] {n : ℕ} (a : K) (i : Fin n) : + occupancyGauge a (empty n) i = 1 := by simp [occupancyGauge] + +lemma rawColumn_bottom_gauge {K : Type*} [CommRing K] {n : ℕ} + (w v : Fin (n+1) → Tile → K) (a : K) + (htail : ∀ i : Fin n, v i.succ = w i.succ) + (hbottom : ∀ t : Tile, ¬t.Occupied 0 → + v 0 t * (if t.Occupied 1 then a else 1) = + (if t.Occupied 2 then a else 1) * w 0 t) + (p q : Pairing (n+1)) : + rawColumn v q p * occupancyGauge a p 0 = occupancyGauge a q 0 * rawColumn w q p := by + simp only [rawColumn,Finset.sum_mul,Finset.mul_sum] + apply Finset.sum_congr rfl + intro t _ + split_ifs with h + · rw [Fin.prod_univ_succ,Fin.prod_univ_succ] + simp only [htail] + have hh := hbottom (t 0) (h.south 0 rfl) + simp only [h.west,h.east] at hh + change v 0 (t 0) * occupancyGauge a p 0 = occupancyGauge a q 0 * w 0 (t 0) at hh + calc + _ = (v 0 (t 0)*occupancyGauge a p 0) * ∏ i:Fin n,w i.succ (t i.succ) := by ring + _ = _ := by rw [hh]; ring + · simp + +lemma lastCoefficient_bottom_gauge {K : Type*} [CommRing K] {n : ℕ} + (w v : Fin (n+1) → Tile → K) (a : K) + (htail : ∀ i : Fin n, v i.succ = w i.succ) + (hbottom : ∀ t : Tile, ¬t.Occupied 0 → + v 0 t * (if t.Occupied 1 then a else 1) = + (if t.Occupied 2 then a else 1) * w 0 t) + (p q : Pairing (n+1+1)) : + lastCoefficient v q p * occupancyGauge a p 0 = + occupancyGauge a q 0 * lastCoefficient w q p := by + simp only [lastCoefficient,Finset.sum_mul,Finset.mul_sum] + apply Finset.sum_congr rfl + intro t _ + split_ifs with h + · rw [Fin.prod_univ_succ,Fin.prod_univ_succ] + simp only [htail] + have hs : ¬(t 0).Occupied 0 := by simpa using h.south 0 rfl + have hw : (t 0).Occupied 1 ↔ p.Occupied 0 := by simpa using h.west 0 + have he : (t 0).Occupied 2 ↔ q.Occupied 0 := by simpa using h.east 0 + have hh := hbottom (t 0) hs + simp only [hw,he] at hh + change v 0 (t 0) * occupancyGauge a p 0 = occupancyGauge a q 0 * w 0 (t 0) at hh + calc + _ = (v 0 (t 0)*occupancyGauge a p 0) * ∏ i:Fin n,w i.succ (t i.succ) := by ring + _ = _ := by rw [hh]; ring + · simp + +lemma Weights.vacantSouth_gauge {K : Type*} [Field K] (w v : Weights K) + (hA : v.A=w.U) (hB : v.B=w.B) (hU : v.U=w.A) (hw : w.U≠0) + (t : Tile) (ht : ¬t.Occupied 0) : + v.tile t * (if t.Occupied 1 then w.A/w.U else 1) = + (if t.Occupied 2 then w.A/w.U else 1) * w.tile t := by + cases t <;> simp_all [Tile.Occupied,Tile.Adj,Tile.edges,Weights.tile] + <;> field_simp + +lemma matrix_mulVec_gauge {K : Type*} [CommRing K] {I J : Type*} [Fintype I] + (M M' : Matrix J I K) (a : I → K) (b : J → K) + (h : ∀ j i,M' j i*a i=b j*M j i) (v : I → K) : + M'.mulVec (fun i=>a i*v i) = fun j=>b j*M.mulVec v j := by + funext j + simp only [Matrix.mulVec,dotProduct,Finset.mul_sum] + apply Finset.sum_congr rfl + intro i _ + rw [←mul_assoc,h] + ring + +lemma normalizedVacuum_gauge_pair {K : Type*} [Field K] {n : ℕ} + (w v : Fin n → Weights K) (hw : VacuumRegular w) (hv : VacuumRegular v) + (a : Pairing n → K) (he : a (empty n)=1) + (hc : ∀ q p,column v q p*a p=a q*column w q p) : + normalizedVacuum v = fun p=>a p*normalizedVacuum w p := by + symm + apply normalizedVacuum_unique _ hv + constructor + · change a (empty n)*normalizedVacuum w (empty n)=1 + rw [he,(normalizedVacuum_stationary w hw).1,one_mul] + · rw [matrix_mulVec_gauge _ _ _ _ hc,(normalizedVacuum_stationary w hw).2] + + + + + + +lemma spectralRow_den_ne_zero {n : ℕ} (i : Fin n) : spectralA i + constF n C ≠ 0 := by + rw [←twice_rowDenominator] + exact mul_ne_zero (by norm_num) (rowDenominator_map_ne_zero i) + +lemma rowReflectSpectral_weightsA {n : ℕ} (i : Fin n) : + rowReflectSpectral i (spectralWeights n i).A = (spectralWeights n i).U := by + have h := congrArg (rowReflectSpectral i) (clearedSpectralRow_vertical₀ i) + simp only [clearedSpectralRow,Weights.tile,map_mul,map_add,map_ofNat,rowReflectSpectral_const, + rowReflectSpectral_spectralA,rowReflectSpectral_torusSin,rowReflectSpectral_variable,ite_true] at h + apply mul_left_cancel₀ (spectralRow_den_ne_zero i) + exact h.trans (clearedSpectralRow_cap i).symm + +lemma rowReflectSpectral_weightsU {n : ℕ} (i : Fin n) : + rowReflectSpectral i (spectralWeights n i).U = (spectralWeights n i).A := by + rw [←rowReflectSpectral_weightsA,rowReflectSpectral_involutive] + +lemma rowReflectSpectral_weightsB {n : ℕ} (i : Fin n) : + rowReflectSpectral i (spectralWeights n i).B = (spectralWeights n i).B := by + have h := congrArg (rowReflectSpectral i) (clearedSpectralRow_diagonal₁ i) + simp only [clearedSpectralRow,Weights.tile,map_mul,map_add,map_sub,rowReflectSpectral_const, + rowReflectSpectral_spectralA] at h + apply mul_left_cancel₀ (spectralRow_den_ne_zero i) + exact h.trans (clearedSpectralRow_diagonal₁ i).symm + +lemma spectralWeights_A_ne_zero {n : ℕ} (i : Fin n) : (spectralWeights n i).A≠0 := by + have hd : constF n d ≠0 := + (map_ne_zero (algebraMap ℂ (SpectralField n))).mpr (by exact_mod_cast d_ne_zero) + have hs : torusSin (variableF i)≠0 := by + apply torusSin_monomial_ne_zero _ _ 1 one_ne_zero + intro he + have h := congrFun he i + simp [variableExponent] at h + have h := mul_ne_zero (mul_ne_zero (by norm_num : (2:SpectralField n)≠0) hd) hs + rw [←clearedSpectralRow_vertical₀] at h + exact (mul_ne_zero_iff.mp h).2 + +lemma spectralWeights_U_ne_zero {n : ℕ} (i : Fin n) : (spectralWeights n i).U≠0 := by + rw [←rowReflectSpectral_weightsA] + exact (map_ne_zero (rowReflectSpectral i)).mpr (spectralWeights_A_ne_zero i) + +lemma rowReflectSpectral_weights_other {n : ℕ} (i j : Fin n) (h : j≠i) : + (spectralWeights n j).map (rowReflectSpectral i) = spectralWeights n j := by + simp only [spectralWeights,rowReflectSpectral_torusWeights,map_div₀,map_pow, + rowReflectSpectral_const,rowReflectSpectral_variable,ite_eq_right h] + +def rowGauge {n : ℕ} (i : Fin n) : SpectralField n := + (spectralWeights n i).A / (spectralWeights n i).U + +lemma rowGauge_ne_zero {n : ℕ} (i : Fin n) : rowGauge i ≠0 := + div_ne_zero (spectralWeights_A_ne_zero i) (spectralWeights_U_ne_zero i) + +lemma reflectSpectral_rowGauge {n : ℕ} (i : Fin n) : + reflectSpectral n (rowGauge i) = (rowGauge i)⁻¹ := by + have h : (spectralWeights n i).map (reflectSpectral n) = + (spectralWeights n i).map (rowReflectSpectral i) := by + simp only [spectralWeights,reflectSpectral_torusWeights,rowReflectSpectral_torusWeights, + map_div₀,map_pow,reflectSpectral_const,rowReflectSpectral_const, + reflectSpectral_variable,rowReflectSpectral_variable,ite_true] + have ha := congrArg Weights.A h + have hu := congrArg Weights.U h + change reflectSpectral n (spectralWeights n i).A = rowReflectSpectral i (spectralWeights n i).A at ha + change reflectSpectral n (spectralWeights n i).U = rowReflectSpectral i (spectralWeights n i).U at hu + simp only [rowGauge,map_div₀,ha,hu,rowReflectSpectral_weightsA,rowReflectSpectral_weightsU,inv_div] + +lemma rowReflectSpectral_bottom_tile (n : ℕ) (t : Tile) (ht : ¬t.Occupied 0) : + rowReflectSpectral (0:Fin (n+1)) ((spectralWeights (n+1) 0).tile t) * + (if t.Occupied 1 then rowGauge (0:Fin (n+1)) else 1) = + (if t.Occupied 2 then rowGauge (0:Fin (n+1)) else 1) * (spectralWeights (n+1) 0).tile t := by + have h := Weights.vacantSouth_gauge (spectralWeights (n+1) 0) + ((spectralWeights (n+1) 0).map (rowReflectSpectral 0)) + (rowReflectSpectral_weightsA 0) (rowReflectSpectral_weightsB 0) + (rowReflectSpectral_weightsU 0) (spectralWeights_U_ne_zero 0) t ht + simpa [Weights.map_tile, rowGauge] using h + +lemma rowReflectSpectral_bottom_column (n : ℕ) (p q : Pairing (n+1)) : + rowReflectSpectral (0:Fin (n+1)) (column (spectralWeights (n+1)) q p) * + occupancyGauge (rowGauge (0:Fin (n+1))) p 0 = + occupancyGauge (rowGauge (0:Fin (n+1))) q 0 * column (spectralWeights (n+1)) q p := by + rw [column_eq_raw] + have hmap := congrFun (congrFun (rawColumn_map (rowReflectSpectral (0:Fin (n+1))) + (fun i=>(spectralWeights (n+1) i).tile)) q) p + rw [Matrix.map_apply] at hmap + rw [hmap] + apply rawColumn_bottom_gauge _ _ _ _ (rowReflectSpectral_bottom_tile n) p q + intro i + have h := rowReflectSpectral_weights_other (0:Fin (n+1)) i.succ (Fin.succ_ne_zero i) + funext t + have hh := congrArg (fun w=>w.tile t) h + simpa [Weights.map_tile] using hh + +lemma rowReflectSpectral_bottom_lastCoefficient (n : ℕ) (p q : Pairing (n+1+1)) : + rowReflectSpectral (0:Fin (n+1)) (lastCoefficient (fun i=>(spectralWeights (n+1) i).tile) q p) * + occupancyGauge (rowGauge (0:Fin (n+1))) p 0 = + occupancyGauge (rowGauge (0:Fin (n+1))) q 0 * + lastCoefficient (fun i=>(spectralWeights (n+1) i).tile) q p := by + rw [←lastCoefficient_map] + apply lastCoefficient_bottom_gauge _ _ _ _ (rowReflectSpectral_bottom_tile n) p q + intro i + have h := rowReflectSpectral_weights_other (0:Fin (n+1)) i.succ (Fin.succ_ne_zero i) + funext t + have hh := congrArg (fun w=>w.tile t) h + simpa [Weights.map_tile] using hh + +lemma rowReflectSpectral_bottom_vacuum (n : ℕ) (p : Pairing (n+1)) : + rowReflectSpectral (0:Fin (n+1)) (normalizedVacuum (spectralWeights (n+1)) p) = + occupancyGauge (rowGauge (0:Fin (n+1))) p 0 * normalizedVacuum (spectralWeights (n+1)) p := by + have hm := normalizedVacuum_map (rowReflectSpectral (0:Fin (n+1))) (spectralWeights (n+1)) + (spectral_regular (n+1)) + have hv := (spectral_regular (n+1)).map (rowReflectSpectral (0:Fin (n+1))) (spectralWeights (n+1)) + have hc (q p : Pairing (n+1)) : column + (fun i=>(spectralWeights (n+1) i).map (rowReflectSpectral 0)) q p * + occupancyGauge (rowGauge (0:Fin (n+1))) p 0 = + occupancyGauge (rowGauge (0:Fin (n+1))) q 0 * column (spectralWeights (n+1)) q p := by + rw [←column_map] + exact rowReflectSpectral_bottom_column n p q + rw [normalizedVacuum_gauge_pair _ _ (spectral_regular (n+1)) hv _ + (occupancyGauge_empty _ _) hc] at hm + exact congrFun hm p + +lemma rowReflectSpectral_bottom_rationalVacuum (n : ℕ) (p : Pairing (n+1)) : + rowReflectSpectral (0:Fin (n+1)) (rationalVacuum (n+1) p) = + occupancyGauge (rowGauge (0:Fin (n+1))) p 0 * rationalVacuum (n+1) p := by + simp only [rationalVacuum,map_mul,rowReflectSpectral_normalization,rowReflectSpectral_bottom_vacuum] + ring + + + + + + +lemma matrix_one_sub_gauge {K : Type*} [CommRing K] {I : Type*} [Fintype I] [DecidableEq I] + (M M' : Matrix I I K) (a : I → K) + (h : ∀ j i, M' j i*a i=a j*M j i) : + ∀ j i, (1-M') j i*a i=a j*(1-M) j i := by + classical + intro j i + simp only [Matrix.sub_apply,sub_mul,mul_sub,h] + congr 1 + by_cases he : j=i + · subst i; simp + · simp [he] + +lemma rowReflectSpectral_bottom_sourceTransfer (n : ℕ) + (p q : SourcePairing (n+1)) : + rowReflectSpectral (0:Fin (n+1)) + (sourceTransfer (fun i=>(spectralWeights (n+1) i).tile) q p) * + occupancyGauge (rowGauge (0:Fin (n+1))) p.val 0 = + occupancyGauge (rowGauge (0:Fin (n+1))) q.val 0 * + sourceTransfer (fun i=>(spectralWeights (n+1) i).tile) q p := + rowReflectSpectral_bottom_lastCoefficient n p.val q.val + +lemma rowReflectSpectral_bottom_northSource (n : ℕ) + (p : Pairing (n+1)) (q : SourcePairing (n+1)) : + rowReflectSpectral (0:Fin (n+1)) + (northSource (fun i=>(spectralWeights (n+1) i).tile) q p) * + occupancyGauge (rowGauge (0:Fin (n+1))) p 0 = + occupancyGauge (rowGauge (0:Fin (n+1))) q.val 0 * + northSource (fun i=>(spectralWeights (n+1) i).tile) q p := by + classical + have h := rowReflectSpectral_bottom_lastCoefficient n p.padTop q.val + have he : occupancyGauge (rowGauge (0:Fin (n+1))) p.padTop 0 = + occupancyGauge (rowGauge (0:Fin (n+1))) p 0 := by + change (if p.padTop.Occupied (0:Fin (n+1)).castSucc then _ else _) = _ + simp only [Pairing.padTop_occupied_castSucc,occupancyGauge] + simpa only [northSource,he] using h + + + +lemma rowReflectSpectral_bottom_northNumerator (n : ℕ) (p : SourcePairing (n+1)) : + rowReflectSpectral (0:Fin (n+1)) (northNumerator (n+1) p) = + occupancyGauge (rowGauge (0:Fin (n+1))) p.val 0 * northNumerator (n+1) p := by + classical + let f := rowReflectSpectral (0:Fin (n+1)) + let T := sourceTransfer (fun i=>(spectralWeights (n+1) i).tile) + let B := northSource (fun i=>(spectralWeights (n+1) i).tile) + let a := fun q : SourcePairing (n+1) => occupancyGauge (rowGauge (0:Fin (n+1))) q.val 0 + let b := fun q : Pairing (n+1) => occupancyGauge (rowGauge (0:Fin (n+1))) q 0 + have hT : ∀ j i,T.map f j i*a i=a j*T j i := + fun j i => rowReflectSpectral_bottom_sourceTransfer n i j + have hB : ∀ j i,B.map f j i*b i=a j*B j i := + fun j i => rowReflectSpectral_bottom_northSource n i j + have hmap : (1-T).map f = 1-T.map f := by + ext j i + simp only [Matrix.map_apply,Matrix.sub_apply,map_sub,Matrix.one_apply,apply_ite,map_one,map_zero] + have hd : (1-T.map f).det≠0 := by + rw [←hmap] + change (f.mapMatrix (1-T)).det≠0 + rw [←RingHom.map_det] + exact (map_ne_zero f).mpr (spectral_source_regular (n+1)) + have he := congrArg (fun v : SourcePairing (n+1) → SpectralField (n+1) => + fun q => f (v q)) (northNumerator_equation (n+1)) + have hv : (fun q => f (rationalVacuum (n+1) q)) = + fun q => b q*rationalVacuum (n+1) q := by + funext q + exact rowReflectSpectral_bottom_rationalVacuum n q + have hf : f (2*constF (n+1) d)=2*constF (n+1) d := by + simp only [f, map_mul,map_ofNat,rowReflectSpectral_const] + have he' : (1-T.map f).mulVec (fun q=>f (northNumerator (n+1) q)) = + fun q=>(2*constF (n+1) d)*(B.map f).mulVec (fun q=>b q*rationalVacuum (n+1) q) q := by + funext q + have hh := congrFun he q + change f ((1-T).mulVec (northNumerator (n+1)) q) = + f ((2*constF (n+1) d)*B.mulVec (rationalVacuum (n+1)) q) at hh + rw [RingHom.map_mulVec,hmap,map_mul,hf, + RingHom.map_mulVec] at hh + change _ = (2*constF (n+1) d)*(B.map f).mulVec (fun q=>f (rationalVacuum (n+1) q)) q at hh + rw [hv] at hh + exact hh + have hm := matrix_mulVec_gauge (1-T) (1-T.map f) a a + (matrix_one_sub_gauge T (T.map f) a hT) (northNumerator (n+1)) + have hh : (fun q=> f (northNumerator (n+1) q)) = + (fun q=>a q*northNumerator (n+1) q) := by + apply Matrix.mulVec_injective_of_det_ne_zero hd + rw [he',hm,matrix_mulVec_gauge B (B.map f) b a hB] + change (fun q=>(2*constF (n+1) d)*(a q*B.mulVec (rationalVacuum (n+1)) q)) = + fun q=>a q*(1-T).mulVec (northNumerator (n+1)) q + rw [northNumerator_equation] + funext q + simp only [Pi.smul_apply,smul_eq_mul] + ring + exact congrFun hh p + +lemma polynomialNorthSource_bottom_reflection (n : ℕ) (p : SourcePairing (n+1)) : + rowReflectSpectral (0:Fin (n+1)) (evalLaurent (polynomialNorthSource (n+1) p)) = + occupancyGauge (rowGauge (0:Fin (n+1))) p.val 0 * + evalLaurent (polynomialNorthSource (n+1) p) := by + classical + simp only [polynomialNorthSource_eval_numerator,map_mul,rowReflectSpectral_const, + rowReflectSpectral_bottom_northNumerator] + ring + +lemma map_occupancyGauge {K L : Type*} [CommRing K] [CommRing L] (f : K →+* L) + {n : ℕ} (a : K) (p : Pairing n) (i : Fin n) : + f (occupancyGauge a p i) = occupancyGauge (f a) p i := by + classical + unfold occupancyGauge + split_ifs <;> simp + +lemma sourceGlue_gauge {K : Type*} [Field K] (n : ℕ) (a : K) (ha : a≠0) + (v w : SourcePairing n → K) (i : Fin (n+1)) : + sourceGlue n (fun p=>occupancyGauge a⁻¹ p.val i*v p) + (fun p=>occupancyGauge a p.val i*w p) = sourceGlue n v w := by + classical + rw [sourceGlue_eq_sum,sourceGlue_eq_sum] + apply Finset.sum_congr rfl + intro p _ + apply Finset.sum_congr rfl + intro q _ + split_ifs with h + · rw [one_mul,one_mul] + simp only [occupancyGauge,h.2.1 i] + split_ifs + · field_simp + · simp + · simp + + + +theorem polynomialNorthGluing_bottom_reflection (n : ℕ) : + rowReflectLaurent (0:Fin (n+1)) (polynomialNorthGluing (n+1)) = + polynomialNorthGluing (n+1) := by + classical + apply IsFractionRing.injective (SpectralRing (n+1)) (SpectralField (n+1)) + change evalLaurent (rowReflectLaurent 0 (polynomialNorthGluing (n+1))) = + evalLaurent (polynomialNorthGluing (n+1)) + rw [←rowReflectSpectral_evalLaurent,polynomialNorthGluing_eval,sourceGlue_map] + simp only [Function.comp_def,←reflectSpectral_rowReflect, + polynomialNorthSource_bottom_reflection,map_mul,map_occupancyGauge, + reflectSpectral_rowGauge] + exact sourceGlue_gauge _ _ (rowGauge_ne_zero _) _ _ _ + + + +theorem polynomialNorthGluing_row_reflection {n : ℕ} (i : Fin n) : + rowReflectLaurent i (polynomialNorthGluing n) = polynomialNorthGluing n := by + classical + obtain ⟨n,rfl⟩ := Nat.exists_eq_succ_of_ne_zero (by have := i.isLt; omega : n≠0) + have h : ∀ k (hk : k intro hk; exact polynomialNorthGluing_bottom_reflection n + | succ k ih => + intro hk + let j : Fin (n+1) := ⟨k,by omega⟩ + let j' : Fin (n+1) := ⟨k+1,hk⟩ + have hx := polynomialNorthGluing_exchange k (by omega : k+2≤n+1) + have hr := rowReflectLaurent_perm j (Equiv.swap j j') (polynomialNorthGluing (n+1)) + simp only [Equiv.swap_apply_left] at hr + change permLaurent (Equiv.swap j j') (polynomialNorthGluing (n+1)) = _ at hx + rw [hx,ih] at hr + exact hr.trans hx + exact h i.val i.isLt + +end + + + + +noncomputable section +open scoped Classical BigOperators LaurentPolynomial + +lemma permLaurent_one {n : ℕ} (f : Laurent n) : permLaurent 1 f = f := by + have h : permLaurent (1 : Equiv.Perm (Fin n)) = RingHom.id _ := by + apply AddMonoidAlgebra.ringHom_ext <;> intro e + all_goals change permLaurent 1 (monomialL _ _) = monomialL _ _ + all_goals simp only [permLaurent_monomial, + Equiv.Perm.one_def,Equiv.refl_symm,Equiv.coe_refl,Function.comp_id] + exact DFunLike.congr_fun h f + +lemma permLaurent_mul {n : ℕ} (σ τ : Equiv.Perm (Fin n)) (f : Laurent n) : + permLaurent (σ*τ) f = permLaurent σ (permLaurent τ f) := by + have h : permLaurent (σ*τ) = (permLaurent σ).comp (permLaurent τ) := by + apply AddMonoidAlgebra.ringHom_ext <;> intro e + all_goals change permLaurent (σ*τ) (monomialL _ _) = permLaurent σ (permLaurent τ (monomialL _ _)) + all_goals simp only [permLaurent_monomial, + Equiv.Perm.mul_def,Equiv.symm_trans,Equiv.coe_trans,Function.comp_assoc] + exact DFunLike.congr_fun h f + + +lemma permLaurent_invariant_of_adjacent {n : ℕ} (f : Laurent n) + (h : ∀ r (hr : r+2≤n), permLaurent (Equiv.swap (⟨r,by omega⟩:Fin n) + ⟨r+1,by omega⟩) f = f) (σ : Equiv.Perm (Fin n)) : permLaurent σ f = f := by + cases n with + | zero => + have he : σ=1 := Subsingleton.elim _ _ + rw [he,permLaurent_one] + | succ n => + let S : Submonoid (Equiv.Perm (Fin (n+1))) := + { carrier := {τ | permLaurent τ f=f} + one_mem' := permLaurent_one f + mul_mem' := by + intro τ υ hτ hυ + change permLaurent (τ*υ) f = f + rw [permLaurent_mul,hυ,hτ] } + have hm : Submonoid.closure (Set.range (fun i : Fin n => Equiv.swap i.castSucc i.succ)) ≤ S := by + rw [Submonoid.closure_le] + rintro _ ⟨i,rfl⟩ + exact h i.val (by have := i.isLt; omega) + rw [Equiv.Perm.mclosure_swap_castSucc_succ] at hm + exact hm (show σ ∈ (⊤ : Submonoid _) from trivial) + +lemma polynomialNorthGluing_permute {n : ℕ} (σ : Equiv.Perm (Fin n)) : + permLaurent σ (polynomialNorthGluing n) = polynomialNorthGluing n := + permLaurent_invariant_of_adjacent _ polynomialNorthGluing_exchange σ + + + +lemma laurent_eq_zero_of_many_roots {K : Type*} [Field K] + (f : LaurentPolynomial K) (m : ℕ) + (hb : LaurentInterval f (-(m:ℤ)) m) (s : Finset K) (hc : 2*m by by_cases h:j=i <;> simp [h,hz,constF_phase_ne_zero]) f := by + have hmono (e : Fin n → ℤ) (c : ℂ) : + torusEvaluation z hz (rowReflectLaurent i (monomialL e c)) = + torusEvaluation (Function.update z i (constF m phase^3/z i)) + (fun j => by by_cases h:j=i <;> simp [h,hz,constF_phase_ne_zero]) (monomialL e c) := by + rw [rowReflectLaurent_monomial,torusEvaluation_monomial,torusEvaluation_monomial] + rw [←Finset.mul_prod_erase _ (fun j => z j ^ reflectExponentAt i e j) (Finset.mem_univ i), + ←Finset.mul_prod_erase _ (fun j => (Function.update z i (constF m phase^3/z i)) j ^ e j) (Finset.mem_univ i)] + have hh : (∏ j ∈ Finset.univ.erase i, z j ^ reflectExponentAt i e j) = + ∏ j ∈ Finset.univ.erase i, (Function.update z i (constF m phase^3/z i)) j ^ e j := by + apply Finset.prod_congr rfl + intro j hj + have hji : j≠i := (Finset.mem_erase.mp hj).1 + simp only [reflectExponentAt,Function.update_of_ne hji] + rw [hh] + simp only [reflectExponentAt,Function.update_self,zpow_neg, + constF,map_mul,map_zpow₀,zpow_mul,div_eq_mul_inv] + simp only [mul_zpow,inv_zpow] + ac_rfl + have he : (torusEvaluation z hz).toRingHom.comp (rowReflectLaurent i) = + (torusEvaluation (Function.update z i (constF m phase^3/z i)) + (fun j => by by_cases h:j=i <;> simp [h,hz,constF_phase_ne_zero])).toRingHom := by + apply AddMonoidAlgebra.ringHom_ext <;> intro e + all_goals exact hmono _ _ + exact DFunLike.congr_fun he f + +end +end CriticalStrip.Diagram + +end OAI diff --git a/lean/OAI/Combinatorics/StripMass/BottomPadding.lean b/lean/OAI/Combinatorics/StripMass/BottomPadding.lean new file mode 100644 index 0000000000000000000000000000000000000000..67f7a060a49fb166d172588f7e34d0b7af65ff41 --- /dev/null +++ b/lean/OAI/Combinatorics/StripMass/BottomPadding.lean @@ -0,0 +1,395 @@ +import Mathlib +import OAI.Combinatorics.StripMass.PairingDiagrams + +namespace OAI + +/-! Critical honeycomb strip paths, polynomial identities and crossing mass. -/ + + +namespace CriticalStrip.Diagram +noncomputable section +open Finset +theorem realizes_padBottom_iff {n : ℕ} (p q : Pairing n) (t : Configuration n) : + Realizes p.padBottom q.padBottom t.padBottom ↔ Realizes p q t := by + constructor + · intro h + refine ⟨?_, ?_, ?_, ?_, ?_, ?_, ?_⟩ + · intro i; simpa using h.west i.succ + · intro i; simpa using h.east i.succ + · intro i hi hocc + have hg := h.glued 0 i.succ (by simpa using hi) + exact Tile.vacant_not_occupied 3 (hg.mpr hocc) + · intro i hi + exact h.north i.succ (by change i.val+1+1 = n+1; omega) + · intro i j hij + exact h.glued i.succ j.succ (by simpa using hij) + · intro v w hvw + obtain ⟨j,hj,hr⟩ := h.no_loop _ _ ((wiring_padBottom_iff p t v w).2 hvw) + induction j using Fin.cases with + | zero => exact (q.padBottom_not_occupied_zero hj).elim + | succ j => + exact ⟨j,(q.padBottom_occupied_succ j).1 hj, (reach_padBottom_iff p t v (j,2)).1 hr⟩ + · intro i j hij + exact (q.padBottom_adj_succ i j).symm.trans <| + (h.output i.succ j.succ (fun h' => hij (Fin.succ_injective n h'))).trans + (reach_padBottom_iff p t (i,2) (j,2)) + · intro h + refine ⟨?_, ?_, ?_, ?_, ?_, ?_, ?_⟩ + · intro i + induction i using Fin.cases with + | zero => simp + | succ i => simpa using h.west i + · intro i + induction i using Fin.cases with + | zero => simp + | succ i => simpa using h.east i + · intro i hi + have : i = 0 := Fin.ext hi + subst i; simp + · intro i hi + induction i using Fin.cases with + | zero => simp + | succ i => exact h.north i (by change i.val+1+1 = n+1 at hi; omega) + · intro i j hij + induction i using Fin.cases with + | zero => + induction j using Fin.cases with + | zero => simp only [Fin.val_zero] at hij; omega + | succ j => + have hj : j.val = 0 := by simpa using hij.symm + simp [h.south j hj] + | succ i => + induction j using Fin.cases with + | zero => simp only [Fin.val_zero, Fin.val_succ] at hij; omega + | succ j => exact h.glued i j (by simpa using hij) + · rintro ⟨i,a⟩ ⟨j,b⟩ hij + induction i using Fin.cases with + | zero => exact (wiring_padBottom_zero p t a _ hij).elim + | succ i => + induction j using Fin.cases with + | zero => exact (wiring_padBottom_zero_right p t _ b hij).elim + | succ j => + obtain ⟨k,hk,hr⟩ := h.no_loop _ _ ((wiring_padBottom_iff p t (i,a) (j,b)).1 hij) + exact ⟨k.succ,(q.padBottom_occupied_succ k).2 hk, + (reach_padBottom_iff p t (i,a) (k,2)).2 hr⟩ + · intro i j hij + induction i using Fin.cases with + | zero => simp [hij.symm] + | succ i => + induction j using Fin.cases with + | zero => simp + | succ j => + exact (Pairing.padBottom_adj_succ q i j).trans <| + (h.output i j (fun h' => hij (congrArg Fin.succ h'))).trans + (reach_padBottom_iff p t (i,2) (j,2)).symm + +theorem Tile.vacant_of_three (t : Tile) (h₀ : ¬ t.Occupied 0) + (h₁ : ¬ t.Occupied 1) (h₂ : ¬ t.Occupied 2) : t = .vacant := by + cases t <;> simp_all [Tile.Occupied, Tile.Adj, Tile.edges] + +theorem Realizes.bottom_vacant {n : ℕ} {p q : Pairing n} {t : Configuration (n+1)} + (h : Realizes p.padBottom q.padBottom t) : t 0 = .vacant := + Tile.vacant_of_three _ (h.south 0 rfl) + (fun hc => p.padBottom_not_occupied_zero ((h.west 0).mp hc)) + (fun hc => q.padBottom_not_occupied_zero ((h.east 0).mp hc)) + +theorem realizes_cons_bottom_iff {n : ℕ} (p q : Pairing n) + (a : Tile) (t : Configuration n) : + Realizes p.padBottom q.padBottom (Fin.cons a t) ↔ + a = .vacant ∧ Realizes p q t := by + constructor + · intro h + have ha : a = .vacant := h.bottom_vacant + subst a + exact ⟨rfl, (realizes_padBottom_iff p q t).mp h⟩ + · rintro ⟨rfl, h⟩ + exact (realizes_padBottom_iff p q t).mpr h + + +theorem column_padBottom {𝕜 : Type*} [CommRing 𝕜] {n : ℕ} + (w : Fin (n+1) → Weights 𝕜) (p q : Pairing n) : + column w q.padBottom p.padBottom = column (fun i => w i.succ) q p := by + classical + unfold column + rw [← Fintype.sum_equiv (Fin.consEquiv (fun _ : Fin (n+1) => Tile)) + (fun tt : Tile × Configuration n => + if Realizes p.padBottom q.padBottom (Fin.cons tt.1 tt.2) + then ∏ i : Fin (n+1), (w i).tile ((Fin.cons tt.1 tt.2 : Configuration (n+1)) i) else 0) + _ (fun _ => rfl)] + rw [Fintype.sum_prod_type] + simp only [realizes_cons_bottom_iff] + rw [Finset.sum_eq_single Tile.vacant] + · apply Finset.sum_congr rfl + intro t _ + simp [Fin.prod_univ_succ, Weights.tile] + · intro a ha hav + simp [hav] + · simp + +theorem Tile.identity_zero_of_south_vacant_east_occupied + {𝕜 : Type*} [Zero 𝕜] [One 𝕜] (a : Tile) (hs : ¬a.Occupied 0) + (he : a.Occupied 2) : (identityWeights : Weights 𝕜).tile a = 0 := by + cases a <;> simp_all [Tile.Occupied, Tile.Adj, Tile.edges, + identityWeights, Weights.tile] + +theorem Tile.deletion_zero_of_south_vacant_west_occupied + {𝕜 : Type*} [Zero 𝕜] [One 𝕜] (a : Tile) (hs : ¬a.Occupied 0) + (hw : a.Occupied 1) : (deletionWeights : Weights 𝕜).tile a = 0 := by + cases a <;> simp_all [Tile.Occupied, Tile.Adj, Tile.edges, + deletionWeights, Weights.tile] + + +theorem column_identity_bottom_row {𝕜 : Type*} [CommRing 𝕜] {n : ℕ} + (w : Fin (n+1) → Weights 𝕜) (hw : w 0 = identityWeights) + (p q : Pairing (n+1)) (hq : q.Occupied 0) : column w q p = 0 := by + classical + apply Finset.sum_eq_zero + intro t ht + split_ifs with h + · apply Finset.prod_eq_zero (Finset.mem_univ (0 : Fin (n+1))) + rw [hw] + exact Tile.identity_zero_of_south_vacant_east_occupied _ + (h.south 0 rfl) ((h.east 0).mpr hq) + · rfl + + +theorem column_deletion_bottom_col {𝕜 : Type*} [CommRing 𝕜] {n : ℕ} + (w : Fin (n+1) → Weights 𝕜) (hw : w 0 = deletionWeights) + (p q : Pairing (n+1)) (hp : p.Occupied 0) : column w q p = 0 := by + classical + apply Finset.sum_eq_zero + intro t ht + split_ifs with h + · apply Finset.prod_eq_zero (Finset.mem_univ (0 : Fin (n+1))) + rw [hw] + exact Tile.deletion_zero_of_south_vacant_west_occupied _ + (h.south 0 rfl) ((h.west 0).mpr hp) + · rfl + +namespace Pairing + +def nonemptyPadBottom {n : ℕ} (p : NonemptyPairing n) : NonemptyPairing (n+1) := + ⟨p.val.padBottom, fun h => p.property ((padBottom_eq_empty _).mp h)⟩ + +def nonemptyBottomVacantEquiv (n : ℕ) : + NonemptyPairing n ≃ {p : NonemptyPairing (n+1) // ¬p.val.Occupied 0} where + toFun p := ⟨nonemptyPadBottom p, p.val.padBottom_not_occupied_zero⟩ + invFun p := ⟨p.val.val.restrict (Fin.succOrderEmb n), by + intro he + have hp := padBottom_restrict p.val.val p.property + rw [he, padBottom_empty] at hp + exact p.val.property hp.symm⟩ + left_inv p := Subtype.ext (restrict_map _ _) + right_inv p := Subtype.ext (Subtype.ext (padBottom_restrict _ p.property)) + +abbrev BottomOccupiedNonempty (n : ℕ) := + {p : NonemptyPairing (n+1) // ¬¬p.val.Occupied 0} + +def nonemptyBottomSplit (n : ℕ) : + NonemptyPairing n ⊕ BottomOccupiedNonempty n ≃ NonemptyPairing (n+1) := by + classical + exact (Equiv.sumCongr (nonemptyBottomVacantEquiv n) (Equiv.refl _)).trans + (Equiv.sumCompl (fun p : NonemptyPairing (n+1) => ¬p.val.Occupied 0)) + +@[simp] theorem nonemptyBottomSplit_inl {n : ℕ} (p : NonemptyPairing n) : + nonemptyBottomSplit n (.inl p) = nonemptyPadBottom p := rfl + +@[simp] theorem nonemptyBottomSplit_inr {n : ℕ} (p : BottomOccupiedNonempty n) : + nonemptyBottomSplit n (.inr p) = p.val := rfl + +end Pairing + + +theorem det_one_sub_zero_rows {𝕜 α β : Type*} [CommRing 𝕜] + [Fintype α] [Fintype β] [DecidableEq α] [DecidableEq β] + (M : Matrix (α ⊕ β) (α ⊕ β) 𝕜) + (h : ∀ i j, M (.inr i) j = 0) : + (1-M).det = (1-M.toBlocks₁₁).det := by + have hm : 1-M = Matrix.fromBlocks (1-M.toBlocks₁₁) (-M.toBlocks₁₂) 0 1 := by + ext i j + cases i <;> cases j <;> simp [Matrix.one_apply, Matrix.toBlocks₁₁, + Matrix.toBlocks₁₂, h] + rw [hm, Matrix.det_fromBlocks_zero₂₁, Matrix.det_one, mul_one] + + +theorem det_one_sub_zero_cols {𝕜 α β : Type*} [CommRing 𝕜] + [Fintype α] [Fintype β] [DecidableEq α] [DecidableEq β] + (M : Matrix (α ⊕ β) (α ⊕ β) 𝕜) + (h : ∀ i j, M i (.inr j) = 0) : + (1-M).det = (1-M.toBlocks₁₁).det := by + have hm : 1-M = Matrix.fromBlocks (1-M.toBlocks₁₁) 0 (-M.toBlocks₂₁) 1 := by + ext i j + cases i <;> cases j <;> simp [Matrix.one_apply, Matrix.toBlocks₁₁, + Matrix.toBlocks₂₁, h] + rw [hm, Matrix.det_fromBlocks_zero₁₂, Matrix.det_one, mul_one] + + +theorem det_flat_bottom {𝕜 : Type*} [CommRing 𝕜] {n : ℕ} + (w : Fin (n+1) → Weights 𝕜) + (hw : w 0 = identityWeights ∨ w 0 = deletionWeights) : + (1-restrictedColumn w).det = (1-restrictedColumn (fun i => w i.succ)).det := by + classical + let e := Pairing.nonemptyBottomSplit n + let M := (restrictedColumn w).submatrix e e + have hblock : M.toBlocks₁₁ = restrictedColumn (fun i => w i.succ) := by + ext q p + exact column_padBottom w p.val q.val + have hdet : (1-restrictedColumn w).det = (1-M).det := by + rw [← Matrix.det_submatrix_equiv_self e] + congr 1 + simp only [Matrix.submatrix_sub, Pi.sub_apply, Matrix.submatrix_one_equiv] + rfl + rw [hdet] + rcases hw with hi | hd + · rw [det_one_sub_zero_rows M, hblock] + intro q p + exact column_identity_bottom_row w hi (e p).val q.val.val (not_not.mp q.property) + · rw [det_one_sub_zero_cols M, hblock] + intro q p + exact column_deletion_bottom_col w hd p.val.val (e q).val (not_not.mp p.property) + +namespace Pairing + + +def padTop {n : ℕ} (p : Pairing n) : Pairing (n+1) := p.map Fin.castSuccOrderEmb + +@[simp] theorem padTop_adj_castSucc {n : ℕ} (p : Pairing n) (i j : Fin n) : + p.padTop.Adj i.castSucc j.castSucc ↔ p.Adj i j := map_adj_image _ _ _ _ + +@[simp] theorem padTop_not_adj_last {n : ℕ} (p : Pairing n) (j : Fin (n+1)) : + ¬ p.padTop.Adj (Fin.last n) j := by + classical + simp [padTop, map, Adj, Finset.mem_map, Fin.castSuccOrderEmb] + +@[simp] theorem padTop_not_adj_last' {n : ℕ} (p : Pairing n) (j : Fin (n+1)) : + ¬ p.padTop.Adj j (Fin.last n) := by + classical + simp [padTop, map, Adj, Finset.mem_map, Fin.castSuccOrderEmb] + +@[simp] theorem padTop_not_occupied_last {n : ℕ} (p : Pairing n) : + ¬ p.padTop.Occupied (Fin.last n) := by simp [Occupied] + +@[simp] theorem padTop_occupied_castSucc {n : ℕ} (p : Pairing n) (i : Fin n) : + p.padTop.Occupied i.castSucc ↔ p.Occupied i := by + simp only [Occupied, Fin.exists_iff_castSucc, padTop_adj_castSucc, + padTop_not_adj_last', false_or] + +@[simp] theorem padTop_empty {n : ℕ} : (empty n).padTop = empty (n+1) := by + classical + apply Subtype.ext + simp [padTop, map, empty] + +@[simp] theorem padTop_eq_empty {n : ℕ} (p : Pairing n) : + p.padTop = empty (n+1) ↔ p = empty n := by + simp only [eq_empty_iff, Fin.forall_iff_castSucc, padTop_not_occupied_last, + padTop_occupied_castSucc, not_false_eq_true, true_and] + +theorem padTop_restrict {n : ℕ} (p : Pairing (n+1)) (hp : ¬p.Occupied (Fin.last n)) : + (p.restrict Fin.castSuccOrderEmb).padTop = p := by + classical + apply Subtype.ext + ext e + rcases e with ⟨i,j⟩ + induction i using Fin.lastCases with + | last => + have hm : (Fin.last n,j) ∉ p.val := fun h => hp ⟨j, Or.inl h⟩ + simp [padTop, map, Finset.mem_map, Fin.castSuccOrderEmb, hm] + | cast i => + induction j using Fin.lastCases with + | last => + have hm : (i.castSucc,Fin.last n) ∉ p.val := fun h => hp ⟨i.castSucc, Or.inr h⟩ + simp [padTop, map, Finset.mem_map, Fin.castSuccOrderEmb, hm] + | cast j => simp [padTop, map, restrict, Finset.mem_map, Fin.castSuccOrderEmb] + +end Pairing + +namespace Configuration + +def padTop {n : ℕ} (t : Configuration n) : Configuration (n+1) := Fin.snoc t .vacant + +@[simp] theorem padTop_last {n : ℕ} (t : Configuration n) : + t.padTop (Fin.last n) = .vacant := Fin.snoc_last _ _ +@[simp] theorem padTop_castSucc {n : ℕ} (t : Configuration n) (i : Fin n) : + t.padTop i.castSucc = t i := Fin.snoc_castSucc _ _ _ + +end Configuration + +def vertexCastSucc {n : ℕ} (v : Vertex n) : Vertex (n+1) := (v.1.castSucc,v.2) + +theorem vertexCastSucc_injective {n : ℕ} : Function.Injective (@vertexCastSucc n) := by + intro v w h + apply Prod.ext + · exact Fin.castSucc_injective n (congrArg (fun v : Vertex (n+1) => v.1) h) + · exact congrArg (fun v : Vertex (n+1) => v.2) h + + +theorem wiring_padTop_last {n : ℕ} (p : Pairing n) (t : Configuration n) + (ht : ∀ i, i.val+1=n → ¬(t i).Occupied 3) + (a : Fin 4) (w : Vertex (n+1)) : + ¬Wiring p.padTop t.padTop (Fin.last n,a) w := by + intro h + rcases h with ⟨hw,hh⟩ | hh | ⟨_,_,hv,_⟩ | ⟨_,_,hv,ho⟩ + · simp at hh + · exact p.padTop_not_adj_last w.1 hh.2.2 + · have hw := w.1.isLt + change n+1 = w.1.val at hv + omega + · rcases w with ⟨j,b⟩ + induction j using Fin.lastCases with + | last => simp at ho + | cast j => exact ht j hv (by simpa using ho) + +theorem wiring_padTop_last_right {n : ℕ} (p : Pairing n) (t : Configuration n) + (ht : ∀ i, i.val+1=n → ¬(t i).Occupied 3) + (v : Vertex (n+1)) (b : Fin 4) : + ¬Wiring p.padTop t.padTop v (Fin.last n,b) := + fun h => wiring_padTop_last p t ht b v (wiring_symm h) + +@[simp] theorem wiring_padTop_iff {n : ℕ} (p : Pairing n) (t : Configuration n) + (v w : Vertex n) : + Wiring p.padTop t.padTop (vertexCastSucc v) (vertexCastSucc w) ↔ Wiring p t v w := by + simp [Wiring, vertexCastSucc] + +theorem reach_padTop_image {n : ℕ} (p : Pairing n) (t : Configuration n) + (ht : ∀ i, i.val+1=n → ¬(t i).Occupied 3) + {v : Vertex n} {w : Vertex (n+1)} (h : Reach p.padTop t.padTop (vertexCastSucc v) w) : + ∃ z, w = vertexCastSucc z ∧ Reach p t v z := by + induction h with + | refl => exact ⟨v,rfl,Relation.ReflTransGen.refl⟩ + | @tail w z _ hwz ih => + obtain ⟨w',rfl,hw'⟩ := ih + rcases z with ⟨j,b⟩ + induction j using Fin.lastCases with + | last => exact (wiring_padTop_last_right p t ht _ b hwz).elim + | cast j => + exact ⟨(j,b),rfl,hw'.tail ((wiring_padTop_iff p t _ _).1 hwz)⟩ + +theorem reach_padTop_iff {n : ℕ} (p : Pairing n) (t : Configuration n) + (ht : ∀ i, i.val+1=n → ¬(t i).Occupied 3) (v w : Vertex n) : + Reach p.padTop t.padTop (vertexCastSucc v) (vertexCastSucc w) ↔ Reach p t v w := by + constructor + · intro h + obtain ⟨z,hz,hz'⟩ := reach_padTop_image p t ht h + have := vertexCastSucc_injective hz + simpa only [this] using hz' + · exact Relation.ReflTransGen.lift vertexCastSucc + (fun a b h => (wiring_padTop_iff p t a b).2 h) _ _ + +theorem reach_padTop_last_iff {n : ℕ} (p : Pairing n) (t : Configuration n) + (ht : ∀ i, i.val+1=n → ¬(t i).Occupied 3) (a : Fin 4) (w : Vertex (n+1)) : + Reach p.padTop t.padTop (Fin.last n,a) w ↔ w = (Fin.last n,a) := + Relation.reflTransGen_iff_eq (wiring_padTop_last p t ht a) + +theorem reach_padTop_last_right_iff {n : ℕ} (p : Pairing n) (t : Configuration n) + (ht : ∀ i, i.val+1=n → ¬(t i).Occupied 3) (v : Vertex (n+1)) (b : Fin 4) : + Reach p.padTop t.padTop v (Fin.last n,b) ↔ v = (Fin.last n,b) := by + constructor + · intro h + exact (reach_padTop_last_iff p t ht b v).1 (reach_symm h) + · rintro rfl; exact Relation.ReflTransGen.refl + + +end +end CriticalStrip.Diagram + +end OAI diff --git a/lean/OAI/Combinatorics/StripMass/BoundaryTree.lean b/lean/OAI/Combinatorics/StripMass/BoundaryTree.lean new file mode 100644 index 0000000000000000000000000000000000000000..73f7b2ebadce421b82d121c85e66fd0c80fb4b5e --- /dev/null +++ b/lean/OAI/Combinatorics/StripMass/BoundaryTree.lean @@ -0,0 +1,580 @@ +import Mathlib +import OAI.Combinatorics.StripMass.ScalarBridge + +namespace OAI + +/-! Critical honeycomb strip paths, polynomial identities and crossing mass. -/ + + +namespace CriticalStrip.FiniteBranchTree +noncomputable section +open scoped BigOperators Classical + +variable {V S : Type*} [DecidableEq V] + + + +def leaves (vertex : S → V) (next : S → Bool → S) (free : Finset V) (s : S) : + Finset (List Bool) := + if _h : vertex s ∈ free then + (leaves vertex next (free.erase (vertex s)) (next s false)).image (List.cons false) ∪ + (leaves vertex next (free.erase (vertex s)) (next s true)).image (List.cons true) + else {[]} +termination_by free.card +decreasing_by all_goals exact Finset.card_erase_lt_of_mem _h + + +def wordWeight (w : Bool → ℂ) : List Bool → ℂ + | [] => 1 + | b::l => w b * wordWeight w l + +@[simp] lemma wordWeight_nil (w : Bool → ℂ) : wordWeight w [] = 1 := rfl +@[simp] lemma wordWeight_cons (w : Bool → ℂ) (b : Bool) (l : List Bool) : + wordWeight w (b::l) = w b * wordWeight w l := rfl + +lemma prefix_disjoint (F G : Finset (List Bool)) : + Disjoint (F.image (List.cons false)) (G.image (List.cons true)) := by + apply Finset.disjoint_left.mpr + intro l hl hr + obtain ⟨a,_,ha⟩ := Finset.mem_image.mp hl + obtain ⟨b,_,hb⟩ := Finset.mem_image.mp hr + have he := ha.trans hb.symm + simp only [List.cons.injEq, Bool.false_eq_true, false_and] at he + +theorem mass_one (vertex : S → V) (next : S → Bool → S) (w : Bool → ℂ) + (hw : w false + w true = 1) (free : Finset V) (s : S) : + ∑ l ∈ leaves vertex next free s, wordWeight w l = 1 := by + induction free using Finset.strongInductionOn generalizing s with + | _ free ih => + rw [leaves] + split_ifs with hs + · rw [Finset.sum_union (prefix_disjoint _ _), + Finset.sum_image (by intro a ha b hb h; simpa only [List.cons.injEq,true_and] using h), + Finset.sum_image (by intro a ha b hb h; simpa only [List.cons.injEq,true_and] using h)] + simp only [wordWeight_cons,←Finset.mul_sum] + rw [ih _ (Finset.erase_ssubset hs),ih _ (Finset.erase_ssubset hs),mul_one,mul_one,hw] + · simp + +lemma nil_mem_iff (vertex : S → V) (next : S → Bool → S) (free : Finset V) (s : S) : + [] ∈ leaves vertex next free s ↔ vertex s ∉ free := by + rw [leaves] + split_ifs <;> simp_all + +lemma cons_mem_iff (vertex : S → V) (next : S → Bool → S) (free : Finset V) + (s : S) (b : Bool) (l : List Bool) : + b::l ∈ leaves vertex next free s ↔ + vertex s ∈ free ∧ l ∈ leaves vertex next (free.erase (vertex s)) (next s b) := by + rw [leaves] + split_ifs with hs + · cases b <;> simp [hs] + · simp [hs] + + +def visited (vertex : S → V) (next : S → Bool → S) (s : S) : List Bool → List V + | [] => [] + | b::l => vertex s :: visited vertex next (next s b) l + + +def terminal (next : S → Bool → S) (s : S) : List Bool → S + | [] => s + | b::l => terminal next (next s b) l + +omit [DecidableEq V] in +@[simp] lemma visited_length (vertex : S → V) (next : S → Bool → S) + (s : S) (l : List Bool) : (visited vertex next s l).length = l.length := by + induction l generalizing s with + | nil => rfl + | cons b l ih => simp only [visited,List.length_cons,ih] + +lemma visited_mem_domain (vertex : S → V) (next : S → Bool → S) {free : Finset V} + {s : S} {l : List Bool} (hl : l ∈ leaves vertex next free s) : + ∀ v ∈ visited vertex next s l, v ∈ free := by + induction l generalizing free s with + | nil => simp [visited] + | cons b l ih => + obtain ⟨hs,hl⟩ := (cons_mem_iff vertex next free s b l).mp hl + intro v hv + rcases List.mem_cons.mp hv with rfl | hv + · exact hs + · exact Finset.mem_of_mem_erase (ih hl v hv) + +lemma visited_nodup (vertex : S → V) (next : S → Bool → S) {free : Finset V} + {s : S} {l : List Bool} (hl : l ∈ leaves vertex next free s) : + (visited vertex next s l).Nodup := by + induction l generalizing free s with + | nil => simp [visited] + | cons b l ih => + obtain ⟨_,hl⟩ := (cons_mem_iff vertex next free s b l).mp hl + apply List.nodup_cons.mpr + refine ⟨?_,ih hl⟩ + intro hv + exact Finset.notMem_erase _ _ (visited_mem_domain vertex next hl _ hv) + +lemma length_le_card (vertex : S → V) (next : S → Bool → S) {free : Finset V} + {s : S} {l : List Bool} (hl : l ∈ leaves vertex next free s) : + l.length ≤ free.card := by + rw [←visited_length vertex next s l, + ←List.toFinset_card_of_nodup (visited_nodup vertex next hl)] + exact Finset.card_le_card (fun v hv => + visited_mem_domain vertex next hl v (List.mem_toFinset.mp hv)) + +lemma terminal_append (next : S → Bool → S) (s : S) (l m : List Bool) : + terminal next s (l++m) = terminal next (terminal next s l) m := by + induction l generalizing s with + | nil => rfl + | cons b l ih => exact ih _ + +omit [DecidableEq V] in +lemma visited_append (vertex : S → V) (next : S → Bool → S) (s : S) (l m : List Bool) : + visited vertex next s (l++m) = + visited vertex next s l ++ visited vertex next (terminal next s l) m := by + induction l generalizing s with + | nil => rfl + | cons b l ih => simp only [List.cons_append,visited,ih,terminal] + +omit [DecidableEq V] in +lemma visited_head (vertex : S → V) (next : S → Bool → S) (s : S) (l : List Bool) + (hl : l ≠ []) : (visited vertex next s l).head? = some (vertex s) := by + cases l with + | nil => exact (hl rfl).elim + | cons b l => rfl + + + +lemma mem_leaves_iff (vertex : S → V) (next : S → Bool → S) (D : Finset V) + (s : S) (l : List Bool) : + l ∈ leaves vertex next D s ↔ + (visited vertex next s l).Nodup ∧ + (∀ v ∈ visited vertex next s l, v ∈ D) ∧ + (vertex (terminal next s l) ∉ D ∨ + vertex (terminal next s l) ∈ visited vertex next s l) := by + induction l generalizing D s with + | nil => simp [nil_mem_iff,visited,terminal] + | cons b l ih => + rw [cons_mem_iff,ih] + simp only [visited,List.nodup_cons,List.mem_cons,forall_eq_or_imp,terminal] + constructor + · rintro ⟨hs,hn,hm,ht⟩ + have hnot : vertex s ∉ visited vertex next (next s b) l := by + intro hv + exact Finset.notMem_erase _ _ (hm _ hv) + refine ⟨⟨hnot,hn⟩,⟨hs,fun v hv => Finset.mem_of_mem_erase (hm v hv)⟩,?_⟩ + rcases ht with ht | ht + · by_cases he : vertex (terminal next (next s b) l)=vertex s + · exact Or.inr (Or.inl he) + · exact Or.inl (fun hd => ht (Finset.mem_erase.mpr ⟨he,hd⟩)) + · exact Or.inr (Or.inr ht) + · rintro ⟨⟨hnot,hn⟩,⟨hs,hm⟩,ht⟩ + refine ⟨hs,hn,fun v hv =>Finset.mem_erase.mpr ⟨?_,hm v hv⟩,?_⟩ + · exact fun he =>hnot (he ▸ hv) + · rcases ht with ht | he | ht + · exact Or.inl (fun hd =>ht (Finset.mem_of_mem_erase hd)) + · exact Or.inl (fun hd =>(Finset.mem_erase.mp hd).1 he) + · exact Or.inr ht + + + +lemma terminal_outside_or_collision (vertex : S → V) (next : S → Bool → S) + {free : Finset V} {s : S} {l : List Bool} (hl : l ∈ leaves vertex next free s) : + vertex (terminal next s l) ∉ free ∨ + vertex (terminal next s l) ∈ visited vertex next s l := by + induction l generalizing free s with + | nil => exact Or.inl ((nil_mem_iff vertex next free s).mp hl) + | cons b l ih => + obtain ⟨hs,hl⟩ := (cons_mem_iff vertex next free s b l).mp hl + rcases ih hl with ht | ht + · by_cases hf : vertex (terminal next (next s b) l) ∈ free + · right + apply List.mem_cons.mpr + left + by_contra hn + exact ht (Finset.mem_erase.mpr ⟨hn,hf⟩) + · exact Or.inl hf + · exact Or.inr (List.mem_cons_of_mem _ ht) + +lemma terminal_mem_domain_iff_collision (vertex : S → V) (next : S → Bool → S) + {free : Finset V} {s : S} {l : List Bool} (hl : l ∈ leaves vertex next free s) : + vertex (terminal next s l) ∈ free ↔ + vertex (terminal next s l) ∈ visited vertex next s l := by + refine ⟨fun h => (terminal_outside_or_collision vertex next hl).resolve_left (not_not.mpr h), + visited_mem_domain vertex next hl _⟩ + +def exitMass (vertex : S → V) (next : S → Bool → S) (w : Bool → ℂ) + (D : Finset V) (s : S) : ℂ := + ∑ l ∈ (leaves vertex next D s).filter (fun l => vertex (terminal next s l) ∉ D), wordWeight w l + +def collisionMass (vertex : S → V) (next : S → Bool → S) (w : Bool → ℂ) + (D : Finset V) (s : S) : ℂ := + ∑ l ∈ (leaves vertex next D s).filter (fun l => vertex (terminal next s l) ∈ D), wordWeight w l + + + +theorem exit_add_collision (vertex : S → V) (next : S → Bool → S) (w : Bool → ℂ) + (hw : w false + w true = 1) (D : Finset V) (s : S) : + exitMass vertex next w D s + collisionMass vertex next w D s = 1 := by + have h := Finset.sum_filter_add_sum_filter_not + (leaves vertex next D s) (fun l => vertex (terminal next s l) ∉ D) (wordWeight w) + simp only [not_not] at h + exact h.trans (mass_one vertex next w hw D s) + +end +end CriticalStrip.FiniteBranchTree + + + + + + + +namespace CriticalStrip.HoneycombBranch +noncomputable section +open scoped BigOperators Classical +open FiniteBranchTree + +abbrev Vertex := ℤ × ℤ × Bool +abbrev State := Vertex × Fin 3 + +def neighbor (v : Vertex) (p : Fin 3) : Vertex := + if v.2.2 then + if p = 0 then (v.1,v.2.1-1,false) + else if p = 1 then (v.1-1,v.2.1,false) else (v.1,v.2.1,false) + else + if p = 0 then (v.1,v.2.1+1,true) + else if p = 1 then (v.1+1,v.2.1,true) else (v.1,v.2.1,true) + +lemma neighbor_reverse (v : Vertex) (p : Fin 3) : neighbor (neighbor v p) p = v := by + rcases v with ⟨i,j,b⟩ + cases b <;> fin_cases p <;> simp [neighbor] + +lemma neighbor_ne (v : Vertex) (p : Fin 3) : neighbor v p ≠ v := by + rcases v with ⟨i,j,b⟩ + cases b <;> fin_cases p <;> simp [neighbor] + +lemma neighbor_injective (v : Vertex) : Function.Injective (neighbor v) := by + rcases v with ⟨i,j,b⟩ + intro p q h + cases b <;> fin_cases p <;> fin_cases q <;> simp_all [neighbor,Prod.mk.injEq] <;> omega + + + +def outgoing (p : Fin 3) (b : Bool) : Fin 3 := if b then p+1 else p+2 + +def next (s : State) (b : Bool) : State := + let q := outgoing s.2 b + (neighbor s.1 q,q) + +lemma outgoing_ne (p : Fin 3) (b : Bool) : outgoing p b ≠ p := by + cases b <;> fin_cases p <;> decide + +lemma outgoing_injective (p : Fin 3) : Function.Injective (outgoing p) := by + intro b c h + cases b <;> cases c <;> fin_cases p <;> simp_all [outgoing] + +lemma outgoing_exhaust (p q : Fin 3) (h : q ≠ p) : ∃! b : Bool, outgoing p b = q := by + fin_cases p <;> fin_cases q <;> simp_all [outgoing,ExistsUnique] + +lemma next_ne (s : State) (b : Bool) : (next s b).1 ≠ s.1 := neighbor_ne _ _ + +lemma next_back (s : State) (b : Bool) : neighbor (next s b).1 (next s b).2 = s.1 := + neighbor_reverse _ _ + +lemma next_not_back (s : State) (b : Bool) : (next s b).1 ≠ neighbor s.1 s.2 := by + exact fun h => outgoing_ne s.2 b (neighbor_injective s.1 h) + +lemma next_injective (s : State) : Function.Injective (fun b => (next s b).1) := by + intro b c h + exact outgoing_injective s.2 (neighbor_injective s.1 h) + + +def sign (b : Bool) : ℤ := if b then 1 else -1 + +def turn : List Bool → ℤ + | [] => 0 + | b::l => sign b + turn l + +def factor (b : Bool) : ℂ := (rho : ℂ) * Diagram.phase ^ sign b + +lemma factor_add : factor false + factor true = 1 := by + have hc := Diagram.phase_cosine (1:ℤ) + simp only [zpow_one,Int.cast_one,one_mul] at hc + change (Diagram.phase + Diagram.phase⁻¹)/2 = (C:ℂ) at hc + have hr := congrArg (fun x : ℝ => (x : ℂ)) two_C_mul_rho + push_cast at hr + dsimp [factor,sign] + simp only [zpow_one,zpow_neg_one] + linear_combination 2 * (rho:ℂ) * hc + hr + +lemma wordWeight_eq (l : List Bool) : + wordWeight factor l = (rho : ℂ)^l.length * Diagram.phase ^ turn l := by + induction l with + | nil => simp [wordWeight,turn] + | cons b l ih => + simp only [wordWeight_cons,ih,List.length_cons,turn,factor,pow_succ, + zpow_add₀ Diagram.phase_ne_zero] + ring + +lemma phase_norm : ‖Diagram.phase‖ = 1 := by + simp [Diagram.phase,Complex.norm_exp] + +lemma wordWeight_norm (l : List Bool) : ‖wordWeight factor l‖ = rho^l.length := by + rw [wordWeight_eq,norm_mul,norm_pow,norm_zpow,phase_norm,one_zpow,mul_one, + Complex.norm_real,Real.norm_eq_abs,abs_of_pos rho_pos] + + +def words (D : Finset Vertex) (s : State) : Finset (List Bool) := leaves Prod.fst next D s + +theorem finite_tree_mass (D : Finset Vertex) (s : State) : + ∑ l ∈ words D s, (rho:ℂ)^l.length * Diagram.phase^turn l = 1 := by + simp_rw [←wordWeight_eq] + exact mass_one Prod.fst next factor factor_add D s + +theorem exit_plus_collision (D : Finset Vertex) (s : State) : + exitMass Prod.fst next factor D s + collisionMass Prod.fst next factor D s = 1 := + exit_add_collision Prod.fst next factor factor_add D s + + +def embedTriangle (v : Triangle) : Vertex := (v.1,(v.2.1:ℤ),v.2.2) + +lemma embedTriangle_injective : Function.Injective embedTriangle := by + rintro ⟨i,j,b⟩ ⟨k,l,c⟩ h + simp only [embedTriangle,Prod.mk.injEq] at h + obtain ⟨rfl,hj,rfl⟩ := h + congr + exact_mod_cast hj + +lemma adjacent_iff (v w : Triangle) : + adjacent v w ↔ ∃ p : Fin 3, neighbor (embedTriangle v) p = embedTriangle w := by + rcases v with ⟨i,j,b⟩ + rcases w with ⟨k,l,c⟩ + cases b <;> cases c <;> + simp [adjacent,upDownAdjacent,neighbor,embedTriangle,Fin.exists_fin_succ] <;> omega + + +lemma visited_chain (s : State) (l : List Bool) : + (visited Prod.fst next s l).IsChain (fun v w => ∃ p, neighbor v p=w) := by + induction l generalizing s with + | nil => simp [visited] + | cons b l ih => + cases l with + | nil => simp [visited] + | cons c l => + apply List.isChain_cons_cons.mpr + exact ⟨⟨outgoing s.2 b,rfl⟩,ih _⟩ + + + +def direction (s : State) : ZMod 6 := (if s.1.2.2 then 0 else 3) - 2 * s.2.val + +lemma direction_next (s : State) (b : Bool) : + direction (next s b) = direction s + (sign b : ZMod 6) := by + rcases s with ⟨⟨i,j,c⟩,p⟩ + cases c <;> cases b <;> fin_cases p <;> norm_num [direction,next,outgoing,neighbor,sign,Fin.add_def,Fin.ext_iff] <;> decide + +lemma direction_terminal (s : State) (l : List Bool) : + direction (terminal next s l) = direction s + (turn l : ZMod 6) := by + induction l generalizing s with + | nil => simp [terminal,turn] + | cons b l ih => simp only [terminal,ih,direction_next,turn,Int.cast_add,add_assoc] + + + + + + + + + + +def back (s : State) : State := (neighbor s.1 s.2,s.2) + +@[simp] lemma back_back (s : State) : back (back s) = s := by + simp only [back,neighbor_reverse] + +@[simp] lemma back_next (s : State) (b : Bool) : + back (next s b) = (s.1,outgoing s.2 b) := by + simp only [back,next,neighbor_reverse] + +lemma outgoing_opp (p : Fin 3) (b : Bool) : outgoing (outgoing p b) (!b) = p := by + cases b <;> fin_cases p <;> decide + +lemma next_back_next (s : State) (b : Bool) : + next (back (next s b)) (!b) = back s := by + rw [back_next] + simp only [next,outgoing_opp,back] + + +def reverseTurns (l : List Bool) : List Bool := l.reverse.map Bool.not + +lemma reverseTurns_involutive (l : List Bool) : reverseTurns (reverseTurns l) = l := by + simp only [reverseTurns,←List.map_reverse,List.reverse_reverse,List.map_map] + simp [Function.comp_def] + +lemma terminal_reverseTurns (s : State) (l : List Bool) : + terminal next (back (terminal next s l)) (reverseTurns l) = back s := by + induction l generalizing s with + | nil => rfl + | cons b l ih => + simp only [reverseTurns,List.reverse_cons,List.map_append,List.map_singleton,terminal, + terminal_append] + change terminal next (terminal next (back (terminal next (next s b) l)) + (reverseTurns l)) [!b] = _ + rw [ih] + exact next_back_next s b + +lemma visited_reverseTurns (s : State) (l : List Bool) : + visited Prod.fst next (back (terminal next s l)) (reverseTurns l) = + (visited Prod.fst next s l).reverse := by + induction l generalizing s with + | nil => rfl + | cons b l ih => + simp only [reverseTurns,List.reverse_cons,List.map_append,List.map_singleton,terminal, + visited_append] + change visited Prod.fst next (back (terminal next (next s b) l)) (reverseTurns l) ++ + visited Prod.fst next (terminal next (back (terminal next (next s b) l)) + (reverseTurns l)) [!b] = _ + rw [ih,terminal_reverseTurns] + simp only [visited,back_next,List.reverse_cons] + +lemma turn_append (l m : List Bool) : turn (l++m)=turn l+turn m := by + induction l with + | nil => simp [turn] + | cons b l ih => simp only [List.cons_append,turn,ih,add_assoc] + +lemma sign_not (b : Bool) : sign (!b) = -sign b := by cases b <;> decide + +lemma turn_reverse (l : List Bool) : turn l.reverse = turn l := by + induction l with + | nil => rfl + | cons b l ih => simp only [List.reverse_cons,turn_append,ih,turn,zero_add,add_comm] + +lemma turn_map_not (l : List Bool) : turn (l.map Bool.not) = -turn l := by + induction l with + | nil => simp [turn] + | cons b l ih => simp only [List.map_cons,turn,sign_not,ih,neg_add] + +lemma turn_reverseTurns (l : List Bool) : turn (reverseTurns l) = -turn l := by + rw [reverseTurns,turn_map_not,turn_reverse] + + + +def reverseCycle : List Bool → List Bool + | [] => [] + | b::l => (!b)::reverseTurns l + +lemma reverseCycle_involutive (l : List Bool) : reverseCycle (reverseCycle l) = l := by + cases l with + | nil => rfl + | cons b l => simp only [reverseCycle,reverseTurns_involutive,Bool.not_not] + +lemma reverseCycle_length (l : List Bool) : (reverseCycle l).length=l.length := by + cases l <;> simp [reverseCycle,reverseTurns] + +lemma turn_reverseCycle (l : List Bool) : turn (reverseCycle l) = -turn l := by + cases l with + | nil => simp [reverseCycle,turn] + | cons b l => simp only [reverseCycle,turn,sign_not,turn_reverseTurns,neg_add] + +lemma reverseCycle_ne {l : List Bool} (hl : l ≠ []) : reverseCycle l ≠ l := by + cases l with + | nil => exact (hl rfl).elim + | cons b l => cases b <;> simp [reverseCycle] + +lemma third_port (p q : Fin 3) (b : Bool) (h₀ : q ≠ p) (h₁ : q ≠ outgoing p b) : + q = outgoing p (!b) := by + cases b <;> fin_cases p <;> fin_cases q <;> simp_all [outgoing] + +lemma reverseCycle_first_step (s : State) (b : Bool) (l : List Bool) + (hcycle : (terminal next s (b::l)).1=s.1) + (h₀ : (terminal next s (b::l)).2 ≠ s.2) + (h₁ : (terminal next s (b::l)).2 ≠ outgoing s.2 b) : + next s (!b) = back (terminal next (next s b) l) := by + have hq := third_port s.2 (terminal next s (b::l)).2 b h₀ h₁ + change next s (!b) = back (terminal next s (b::l)) + simp only [next,back,hcycle,hq] + +lemma terminal_reverseCycle (s : State) (b : Bool) (l : List Bool) + (hcycle : (terminal next s (b::l)).1=s.1) + (h₀ : (terminal next s (b::l)).2 ≠ s.2) + (h₁ : (terminal next s (b::l)).2 ≠ outgoing s.2 b) : + terminal next s (reverseCycle (b::l)) = (s.1,outgoing s.2 b) := by + simp only [reverseCycle,terminal] + rw [reverseCycle_first_step s b l hcycle h₀ h₁,terminal_reverseTurns,back_next] + +lemma visited_reverseCycle (s : State) (b : Bool) (l : List Bool) + (hcycle : (terminal next s (b::l)).1=s.1) + (h₀ : (terminal next s (b::l)).2 ≠ s.2) + (h₁ : (terminal next s (b::l)).2 ≠ outgoing s.2 b) : + visited Prod.fst next s (reverseCycle (b::l)) = + s.1 :: (visited Prod.fst next (next s b) l).reverse := by + simp only [reverseCycle,visited] + rw [reverseCycle_first_step s b l hcycle h₀ h₁,visited_reverseTurns] + + + +lemma visited_reverseCycle_perm (s : State) (b : Bool) (l : List Bool) + (hcycle : (terminal next s (b::l)).1=s.1) + (h₀ : (terminal next s (b::l)).2 ≠ s.2) + (h₁ : (terminal next s (b::l)).2 ≠ outgoing s.2 b) : + (visited Prod.fst next s (reverseCycle (b::l))).Perm + (visited Prod.fst next s (b::l)) := by + rw [visited_reverseCycle s b l hcycle h₀ h₁] + exact (List.reverse_perm _).cons s.1 + + + +lemma prefix_reverseCycle_mem (D : Finset Vertex) (s : State) (stem : List Bool) + (b : Bool) (l : List Bool) (hl : stem++b::l ∈ words D s) + (hcycle : (terminal next s (stem++b::l)).1=(terminal next s stem).1) + (h₀ : (terminal next s (stem++b::l)).2 ≠ (terminal next s stem).2) + (h₁ : (terminal next s (stem++b::l)).2 ≠ outgoing (terminal next s stem).2 b) : + stem++reverseCycle (b::l) ∈ words D s := by + simp only [terminal_append] at hcycle h₀ h₁ + have hp := visited_reverseCycle_perm (terminal next s stem) b l hcycle h₀ h₁ + have hperm : (visited Prod.fst next s (stem++reverseCycle (b::l))).Perm + (visited Prod.fst next s (stem++b::l)) := by + rw [visited_append,visited_append] + exact List.Perm.append_left _ hp + obtain ⟨hn,hm,_⟩ := (mem_leaves_iff Prod.fst next D s (stem++b::l)).mp hl + apply (mem_leaves_iff Prod.fst next D s _).mpr + refine ⟨hperm.nodup_iff.mpr hn,fun v hv =>hm v (hperm.mem_iff.mp hv),?_⟩ + right + rw [terminal_append,terminal_reverseCycle _ b l hcycle h₀ h₁,visited_append] + apply List.mem_append_right + simp only [visited_reverseCycle _ b l hcycle h₀ h₁,List.mem_cons,true_or] + + + +lemma phase_cancel {a : ℤ} (ha : a % 8 = 4) : Diagram.phase ^ a + Diagram.phase ^ (-a) = 0 := by + have hdecomp : a = 8*(a/8)+4 := by omega + have h16 : Diagram.phase ^ (16:ℤ) = 1 := by + norm_cast + rw [show (16:ℕ)=8*2 by rfl,pow_mul,Diagram.phase_eight] + norm_num + have h8 : Diagram.phase ^ (8:ℤ) = -1 := by exact_mod_cast Diagram.phase_eight + have hp : (Diagram.phase ^ a)^2 = -1 := by + rw [←zpow_natCast,←zpow_mul] + norm_num only [Nat.cast_ofNat] + rw [show a*2=16*(a/8)+8 by omega,zpow_add₀ Diagram.phase_ne_zero, + zpow_mul,h16,one_zpow,h8,one_mul] + rw [zpow_neg] + have hn := zpow_ne_zero a Diagram.phase_ne_zero + apply (mul_right_cancel₀ hn) + rw [add_mul,zero_mul,inv_mul_cancel₀ hn,←pow_two,hp] + exact neg_add_cancel 1 + + + +lemma cycle_weight_cancel (stem cycle : List Bool) (hturn : turn cycle % 8 = 4) : + wordWeight factor (stem++cycle) + wordWeight factor (stem++reverseCycle cycle) = 0 := by + simp only [wordWeight_eq,List.length_append,reverseCycle_length,turn_append,turn_reverseCycle] + rw [zpow_add₀ Diagram.phase_ne_zero,zpow_add₀ Diagram.phase_ne_zero] + have h := phase_cancel hturn + calc + _ = (rho:ℂ)^(stem.length+cycle.length)*Diagram.phase^turn stem * + (Diagram.phase^turn cycle + Diagram.phase^(-turn cycle)) := by ring + _ = 0 := by rw [h,mul_zero] + +end +end CriticalStrip.HoneycombBranch + +end OAI diff --git a/lean/OAI/Combinatorics/StripMass/BridgeUnfold.lean b/lean/OAI/Combinatorics/StripMass/BridgeUnfold.lean new file mode 100644 index 0000000000000000000000000000000000000000..d6b7496c076b90e164f627923b5ebb693d47b214 --- /dev/null +++ b/lean/OAI/Combinatorics/StripMass/BridgeUnfold.lean @@ -0,0 +1,536 @@ +import Mathlib +import OAI.Combinatorics.StripMass.SidePaths +import OAI.Combinatorics.StripMass.NorthMass + +namespace OAI + +/-! Critical honeycomb strip paths, polynomial identities and crossing mass. -/ + + +namespace CriticalStrip +noncomputable section +open scoped Classical BigOperators + + +def raiseTriangle (v : Triangle) : Triangle := (v.1,v.2.1+1,v.2.2) + +lemma raiseTriangle_injective : Function.Injective raiseTriangle := by + rintro ⟨i,j,b⟩ ⟨k,l,c⟩ h + simp only [raiseTriangle,Prod.mk.injEq,Nat.add_right_cancel_iff] at h + exact Prod.ext h.1 (Prod.ext h.2.1 h.2.2) + +lemma adjacent_raise (v w : Triangle) : + adjacent (raiseTriangle v) (raiseTriangle w) ↔ adjacent v w := by + simp only [adjacent,upDownAdjacent,raiseTriangle,Nat.add_right_cancel_iff] + +lemma PathBetween.raise {H : ℕ} {a b : Triangle} {p : List Triangle} + (hp : PathBetween H a b p) : + PathBetween (H+1) (raiseTriangle a) (raiseTriangle b) (p.map raiseTriangle) := by + refine ⟨?_,?_,hp.2.2.1.map raiseTriangle_injective,?_,?_⟩ + · rw [List.head?_map,hp.1]; rfl + · rw [List.getLast?_map,hp.2.1]; rfl + · exact (List.isChain_map _).mpr (hp.2.2.2.1.imp (fun v w h=>(adjacent_raise v w).mpr h)) + · intro v hv + obtain ⟨w,hw,rfl⟩:=List.mem_map.mp hv + exact Nat.succ_lt_succ (hp.2.2.2.2 w hw) + +lemma PathBetween.prepend_vertex {H : ℕ} {a b v : Triangle} {p : List Triangle} + (hp : PathBetween H a b p) (hv : v.2.1x.2.1) hv + change v.2.1+1=0 at hx + omega + have hu : up (0:ℤ) 0 ≠ down 0 0 := by decide + exact (hh.prepend_vertex (by change 0 simp [adjacent,upDownAdjacent,up,down] at h ⊢ + all_goals omega + + + +lemma exists_rightmost_down {H : ℕ} {k : ℤ} {p : List Triangle} + (hp : IsPath H (down k (H-1)) p) (hzero : down 0 0∈p) : + ∃ M : ℤ, ∃ j : ℕ, down M j∈p ∧ 0≤M ∧ ∀ v∈p,v.1≤M := by + let F:=p.toFinset.image Prod.fst + have h0 : (0:ℤ)∈F := Finset.mem_image.mpr ⟨down 0 0,List.mem_toFinset.mpr hzero,rfl⟩ + have hne : F.Nonempty:=⟨0,h0⟩ + let M:=F.max' hne + have hM (v : Triangle) (hv : v∈p) : v.1≤M := + Finset.le_max' _ _ (Finset.mem_image.mpr ⟨v,List.mem_toFinset.mpr hv,rfl⟩) + have hM0 : 0≤M := Finset.le_max' F 0 h0 + by_contra hh + have hn (j : ℕ) : down M j∉p := by + intro h; exact hh ⟨M,j,h,hM0,hM⟩ + have hMp : ∃v∈p,v.1=M := by + obtain ⟨v,hv,he⟩:=Finset.mem_image.mp (Finset.max'_mem F hne) + exact ⟨v,List.mem_toFinset.mp hv,he⟩ + obtain ⟨⟨i,j,b⟩,hv,hi⟩:=hMp + change i=M at hi + subst i + cases b with + | false => exact hn j hv + | true => + obtain ⟨a,ha,hv⟩:=List.getElem_of_mem hv + have hfirst : p[0]'(by omega)=up 0 0 := by + simpa only [List.head?_eq_getElem?,List.getElem?_eq_getElem (by omega : 0v.2.2) hb + contradiction + have ha' : a-1+1=a := by omega + have hc:=List.isChain_iff_getElem.mp hp.2.2.2.1 + have hprev : adjacent (up M j) p[a-1] := by + have he:=adjacent_symmetric.symm _ _ (hc (a-1) (by omega)) + simpa only [ha',hv,up] using he + have hnext : adjacent (up M j) p[a+1] := by simpa only [hv,up] using hc a hat + have other {w : Triangle} (hw : w∈p) (had : adjacent (up M j) w) : w=down (M-1) j := by + apply adjacent_up_other_column had + intro he + have hb : w.2.2=false := by + rcases had with h|h + · exact h.2.1 + · exact (by have he := h.2.1; change true=false at he; contradiction) + have hw' : w=down M w.2.1 := by + rcases w with ⟨i,l,b⟩ + exact Prod.ext he (Prod.ext rfl hb) + exact hn w.2.1 (hw' ▸ hw) + have he := (other (List.getElem_mem _) hprev).trans (other (List.getElem_mem _) hnext).symm + have hi := hp.2.2.1.getElem_inj_iff.mp he + omega + + +def ladderVertex (i : ℤ) (r : ℕ) : Triangle := (i,r/2,r%2=0) + +lemma ladderVertex_injective (i : ℤ) : Function.Injective (ladderVertex i) := by + intro a b h + have hr:=congrArg (fun v : Triangle=>v.2.1) h + have hp:=congrArg (fun v : Triangle=>v.2.2) h + simp only [ladderVertex] at hr hp + have ha:=Nat.mod_lt a (by omega : 0<2) + have hb:=Nat.mod_lt b (by omega : 0<2) + simp only [decide_eq_decide] at hp + omega + +lemma ladderVertex_adjacent (i : ℤ) (r : ℕ) : + adjacent (ladderVertex i r) (ladderVertex i (r+1)) := by + have hmod:=Nat.mod_lt r (by omega : 0<2) + by_cases he : r%2=0 + · have he' : (r+1)%2≠0 := by omega + have hd : (r+1)/2=r/2 := by omega + simp [ladderVertex,he,he',hd,adjacent,upDownAdjacent] + · have he' : (r+1)%2=0 := by omega + have hd : (r+1)/2=r/2+1 := by omega + simp [ladderVertex,he,he',hd,adjacent,upDownAdjacent] + +lemma exists_column_connector (H : ℕ) (i : ℤ) (j l : ℕ) (hj : jladderVertex i r.val + have hf : Function.Injective f := (ladderVertex_injective i).comp Fin.val_injective + refine ⟨w.support.map f,⟨?_,?_,hw.support_nodup.map hf,?_,?_⟩,?_,?_⟩ + · simp only [List.head?_map,List.head?_eq_some_head w.support_ne_nil,w.head_support,Option.map_some] + simp [f,a,ladderVertex,up] + · simp only [List.getLast?_map,List.getLast?_eq_some_getLast w.support_ne_nil,w.getLast_support,Option.map_some] + simp only [f,b,ladderVertex,down,Option.some.injEq,Prod.mk.injEq,true_and] + have he : (2*l+1)/2=l := by omega + have hm : (2*l+1)%2≠0 := by omega + simp only [he,hm,decide_false,and_self] + · apply (List.isChain_map _).mpr + apply w.isChain_adj_support.imp + intro v w h + have hh:=SimpleGraph.pathGraph_adj.mp h + rcases hh with hh|hh + · change adjacent (ladderVertex i v.val) (ladderVertex i w.val) + rw [←hh] + exact ladderVertex_adjacent i _ + · change adjacent (ladderVertex i v.val) (ladderVertex i w.val) + rw [←hh] + exact adjacent_symmetric.symm _ _ (ladderVertex_adjacent i _) + · intro v hv + obtain ⟨r,_,rfl⟩:=List.mem_map.mp hv + change r.val/2hpre.sublist.subset h + have hmem₂ : ∀w∈v::y,w∈x++v::y:=fun _ h=>hsuf.sublist.subset h + refine ⟨x++[v],v::y,⟨?_,by simp,hp.2.2.1.sublist hpre.sublist, + hp.2.2.2.1.prefix hpre,fun w hw=>hp.2.2.2.2 w (hmem₁ w hw)⟩, + ⟨rfl,?_,hp.2.2.1.sublist hsuf.sublist,hp.2.2.2.1.suffix hsuf, + fun w hw=>hp.2.2.2.2 w (hmem₂ w hw)⟩,?_,hmem₁,hmem₂⟩ + · have he : (x++[v]).head?=(x++v::y).head? := by cases x <;> rfl + exact he.trans hp.1 + · have he:=hp.2.1 + rw [List.getLast?_append_of_ne_nil x (by simp)] at he + exact he + · simp only [List.tail_cons,List.append_assoc,List.singleton_append] + + + +structure BridgeCut (H : ℕ) (k : ℤ) (p : List Triangle) where + column : ℤ + row : ℕ + left : List Triangle + right : List Triangle + column_nonneg : 0≤column + row_lt : rowhmax v (hm₁ v hv),fun v hv=>hmax v (hm₂ v hv),he⟩⟩ + +namespace BridgeCut +section TraceRealizations +variable {H : ℕ} {k : ℤ} {p : List Triangle} + +lemma height_pos (D : BridgeCut H k p) : 0translateTriangle (2*D.column+2) (rotateTriangle H v))) + have hh:=(D.right_path.rotate).translate (2*D.column+2) + simpa only [rotateTriangle_down _ _ D.row_lt, + rotateTriangle_down _ _ (by have :=D.height_pos; omega : H-1decide (v.1≤D.column))=D.left := by + have hl : D.left.filter (fun v=>decide (v.1≤D.column))=D.left := + List.filter_eq_self.mpr (fun v hv=>by simpa using D.left_le v hv) + have hc : D.connector.filter (fun v=>decide (v.1≤D.column))=[] := by + apply List.filter_eq_nil_iff.mpr + intro v hv + have :=D.connector_spec.2.1 v hv + simp only [decide_eq_true_eq] + omega + have hr : (D.right.map D.move).filter (fun v=>decide (v.1≤D.column))=[] := by + apply List.filter_eq_nil_iff.mpr + intro v hv + have :=D.moved_ge v hv + simp only [decide_eq_true_eq] + omega + simp only [arch,List.filter_append,hl,hc,hr,List.append_nil] + +lemma arch_filter_right (D : BridgeCut H k p) : + D.arch.filter (fun v=>decide (D.column+2≤v.1))=D.right.map D.move := by + have hl : D.left.filter (fun v=>decide (D.column+2≤v.1))=[] := by + apply List.filter_eq_nil_iff.mpr + intro v hv + have :=D.left_le v hv + simp only [decide_eq_true_eq] + omega + have hc : D.connector.filter (fun v=>decide (D.column+2≤v.1))=[] := by + apply List.filter_eq_nil_iff.mpr + intro v hv + have :=D.connector_spec.2.1 v hv + simp only [decide_eq_true_eq] + omega + have hr : (D.right.map D.move).filter (fun v=>decide (D.column+2≤v.1))=D.right.map D.move := + List.filter_eq_self.mpr (fun v hv=>by simpa using D.moved_ge v hv) + simp only [arch,List.filter_append,hl,hc,hr,List.nil_append] + +end TraceRealizations + + + + + + +lemma recover {H : ℕ} {k l : ℤ} {p q : List Triangle} + (D : BridgeCut H k p) (E : BridgeCut H l q) + (hcol : D.column=E.column) (ha : D.arch=E.arch) : p=q := by + have hl : D.left=E.left := by + rw [←D.arch_filter_left,ha,hcol,E.arch_filter_left] + have hr : D.right.map D.move=E.right.map E.move := by + rw [←D.arch_filter_right,ha,hcol,E.arch_filter_right] + have he : E.move=D.move := by funext v; simp only [move,hcol] + rw [he] at hr + have hr' := List.map_injective_iff.mpr D.move_injective hr + rw [D.reconstruct,E.reconstruct,hl,hr'] +end BridgeCut + + +def BridgePath (N : ℕ) := {x : ℤ×List Triangle // IsPath N (down x.1 (N-1)) x.2} + +namespace BridgePath +variable {N : ℕ} + +def cut (hN : 1≤N) (x : BridgePath N) : + BridgeCut (N+1) x.val.1 (prepareBridge x.val.2) := by + apply Classical.choice + apply exists_bridgeCut (by simpa only [Nat.add_sub_cancel] using prepareBridge_spec hN x.property) + simp [prepareBridge] + + + +def toCutArch (hN : 1≤N) (x : BridgePath N) : (ℕ×ℕ)×List Triangle := + let D:=x.cut hN + ((D.column.toNat,(D.column+1-x.val.1).toNat),D.arch.map (translateTriangle (-D.column))) + +lemma toCutArch_injective (hN : 1≤N) : Function.Injective (toCutArch hN) := by + intro x y he + have hm : (x.cut hN).column=(y.cut hN).column := by + have hh:=congrArg (fun z : (ℕ×ℕ)×List Triangle=>z.1.1) he + change (x.cut hN).column.toNat=(y.cut hN).column.toNat at hh + have h₁:=(x.cut hN).column_nonneg + have h₂:=(y.cut hN).column_nonneg + omega + have ha : (x.cut hN).arch=(y.cut hN).arch := by + have hh:=congrArg Prod.snd he + change (x.cut hN).arch.map (translateTriangle (-(x.cut hN).column))= + (y.cut hN).arch.map (translateTriangle (-(y.cut hN).column)) at hh + rw [hm] at hh + exact List.map_injective_iff.mpr (translateTriangle_injective _) hh + have hp := prepareBridge_injective ((x.cut hN).recover (y.cut hN) hm ha) + apply Subtype.ext + apply Prod.ext ?_ hp + have hx:=x.property.2.1 + have hy:=y.property.2.1 + rw [hp,hy] at hx + exact (congrArg Prod.fst (Option.some.inj hx)).symm + +lemma toCutArch_path (hN : 1≤N) (x : BridgePath N) : + PathBetween (N+1) (up (-((toCutArch hN x).1.1:ℤ)) 0) + (up (((toCutArch hN x).1.2:ℤ)+1) 0) (toCutArch hN x).2 := by + let D:=x.cut hN + have hM : (D.column.toNat:ℤ)=D.column := Int.toNat_of_nonneg D.column_nonneg + have he : ((D.column+1-x.val.1).toNat:ℤ)=D.column+1-x.val.1 := + Int.toNat_of_nonneg (by have :=D.end_le; omega) + have hh:=(show PathBetween (N+1) (up 0 0) (up (2*D.column+2-x.val.1) 0) D.arch from + D.arch_path).translate (-D.column) + change PathBetween _ (up (-(D.column.toNat:ℤ)) 0) + (up (((D.column+1-x.val.1).toNat:ℤ)+1) 0) (D.arch.map (translateTriangle (-D.column))) + simpa only [translateTriangle_up,hM,he,add_zero, + show -D.column+(2*D.column+2-x.val.1)=D.column+1-x.val.1+1 by ring] using hh + +lemma rho_le_one : rho≤1 := by nlinarith [rho_pos,rho_sq_lt_one] + +lemma toCutArch_weight_bound (hN : 1≤N) (x : BridgePath N) : + rho^(2*(N+1)+3)*rho^x.val.2.length ≤ cutArchWeight (N+1) (toCutArch hN x) := by + have hp:=toCutArch_path hN x + rw [cutArchWeight,betweenArchWeight,ite_eq_left ⟨by omega,hp⟩,←pow_add] + apply pow_le_pow_of_le_one rho_pos.le rho_le_one + have hl:=(x.cut hN).arch_length + simp only [prepareBridge_length] at hl + change ((x.cut hN).arch.map _).length≤_ + rw [List.length_map] + omega + + + +theorem summable_weight (hN : 1≤N) : Summable (fun x : BridgePath N=>rho^x.val.2.length) := by + have ht := (cutArchWeight_summable_iff (N+1) (archWeight_summable (by omega))).mpr + (moment_summable (by omega)) + have hs:=ht.comp_injective (toCutArch_injective hN) + have hb : Summable (fun x : BridgePath N=>rho^(2*(N+1)+3)*rho^x.val.2.length) := + Summable.of_nonneg_of_le (fun _=>by positivity [rho_pos]) (toCutArch_weight_bound hN) hs + exact (summable_mul_left_iff (pow_ne_zero _ rho_pos.ne')).mp hb +end BridgePath + +theorem summable_bridgeWeight {N : ℕ} (hN : 1≤N) : + Summable (fun x : ℤ×List Triangle=>bridgeWeight N x.1 x.2) := by + have hh:= (summable_subtype_iff_indicator + (f:=fun x : ℤ×List Triangle=>rho^x.2.length) + (s:={x : ℤ×List Triangle | IsPath N (down x.1 (N-1)) x.2})).mp + (BridgePath.summable_weight hN) + apply hh.congr + intro x + dsimp [Set.indicator] + unfold bridgeWeight + split_ifs <;> simp_all + + + +theorem stripSumsFinite {N : ℕ} (hN : 1≤N) : StripSumsFinite N := by + have hb:=(summable_prod_of_nonneg (fun x : ℤ×List Triangle=>bridgeWeight_nonneg N x.1 x.2)).mp + (summable_bridgeWeight hN) + exact ⟨archWeight_summable hN,hb.1,summable_K_of_moment (moment_summable hN),hb.2,moment_summable hN⟩ + +end +end CriticalStrip + +end OAI diff --git a/lean/OAI/Combinatorics/StripMass/CauchyMatrices.lean b/lean/OAI/Combinatorics/StripMass/CauchyMatrices.lean new file mode 100644 index 0000000000000000000000000000000000000000..5b743f5cf8ed36676c8ed9c3df8725acb844fecb --- /dev/null +++ b/lean/OAI/Combinatorics/StripMass/CauchyMatrices.lean @@ -0,0 +1,431 @@ +import Mathlib +import OAI.Combinatorics.StripMass.DeficitBounds + +namespace OAI + +/-! Critical honeycomb strip paths, polynomial identities and crossing mass. -/ + + +namespace CriticalStrip +noncomputable section +section DeterminantBounds +open scoped BigOperators +open Set MeasureTheory Matrix +def boundedCauchyMatrix {N : ℕ} (x y : Fin N → ℝ) : Matrix (Fin N) (Fin N) ℝ := + Matrix.of fun i j => boundedCauchy (x i) (y j) + + theorem basisDet_eq (N : ℕ) (x : Fin N → ℝ) : + basisDet N x = (∏ i, omega (x i)) * (Matrix.vandermonde x).det := by + have hscale := Matrix.det_mul_row (fun j => omega (x j)) (Matrix.vandermonde x).transpose + have hm : (Matrix.of fun i j : Fin N => momentBasis i.val (x j)) = + Matrix.of (fun i j : Fin N => omega (x j) * (Matrix.vandermonde x).transpose i j) := by + ext i j + exact mul_comm _ _ + unfold basisDet + rw [hm, hscale, Matrix.det_transpose] + + theorem boundedCauchyMatrix_det (N : ℕ) (x y : Fin N → ℝ) : + (boundedCauchyMatrix x y).det = (∏ i, x i) * (cauchyMatrix x y).det := by + have hm : boundedCauchyMatrix x y = Matrix.of (fun i j => x i * cauchyMatrix x y i j) := by + ext i j + simp [boundedCauchyMatrix, boundedCauchy, cauchyMatrix, div_eq_mul_inv] + rw [hm, Matrix.det_mul_column] + + theorem basis_cauchy_basis_eq (N : ℕ) (x y : Fin N → ℝ) : + basisDet N x * (boundedCauchyMatrix x y).det * basisDet N y = + ((∏ i, omega (x i)) * (∏ i, x i) * (∏ i, omega (y i))) * cauchyAlternant x y := by + rw [basisDet_eq, basisDet_eq, boundedCauchyMatrix_det] + unfold cauchyAlternant + ring + + theorem basis_cauchy_basis_nonneg (N : ℕ) (x y : Fin N → ℝ) + (hx : ∀ i, 0 < x i) (hy : ∀ i, 0 < y i) : + 0 ≤ basisDet N x * (boundedCauchyMatrix x y).det * basisDet N y := by + rw [basis_cauchy_basis_eq] + apply mul_nonneg + · exact mul_nonneg (mul_nonneg (Finset.prod_nonneg (fun i _ => omega_nonneg _)) + (Finset.prod_nonneg (fun i _ => (hx i).le))) (Finset.prod_nonneg (fun i _ => omega_nonneg _)) + · exact cauchyAlternant_nonneg x y hx hy + + theorem basis_cauchy_basis_pos {N : ℕ} {x y : Fin N → ℝ} + (hx : x ∈ orderedDomain N) (hy : y ∈ orderedDomain N) : + 0 < basisDet N x * (boundedCauchyMatrix x y).det * basisDet N y := by + rw [basis_cauchy_basis_eq] + apply mul_pos + · exact mul_pos (mul_pos (Finset.prod_pos (fun i _ => omega_pos (hx.2 i))) + (Finset.prod_pos (fun i _ => (hx.2 i).1))) (Finset.prod_pos (fun i _ => omega_pos (hy.2 i))) + · exact cauchyAlternant_pos x y hx.1 hy.1 (fun i => (hx.2 i).1) (fun i => (hy.2 i).1) + + theorem product_restrict_cube (N : ℕ) : + Measure.pi (fun _ : Fin N => volume.restrict (Ioo (0 : ℝ) 1)) = + volume.restrict (univ.pi (fun _ : Fin N => Ioo (0 : ℝ) 1)) := by + rw [volume_pi, Measure.restrict_pi_pi] + + theorem integral_pos_on_cube {N : ℕ} {f : (Fin N → ℝ) → ℝ} + (hi : Integrable f (Measure.pi fun _ => volume.restrict (Ioo (0 : ℝ) 1))) + (hn : ∀ x, (∀ i, x i ∈ Ioo 0 1) → 0 ≤ f x) + (hp : ∀ x ∈ orderedDomain N, 0 < f x) : + 0 < ∫ x, f x ∂Measure.pi (fun _ => volume.restrict (Ioo (0 : ℝ) 1)) := by + rw [product_restrict_cube] at hi ⊢ + have hc : MeasurableSet (univ.pi (fun _ : Fin N => Ioo (0 : ℝ) 1)) := + MeasurableSet.univ_pi (fun _ => measurableSet_Ioo) + have hnn : 0 ≤ᵐ[volume.restrict (univ.pi fun _ : Fin N => Ioo (0 : ℝ) 1)] f := by + filter_upwards [ae_restrict_mem hc] with x hx + exact hn x (fun i => hx i (mem_univ _)) + apply (integral_pos_iff_support_of_nonneg_ae hnn hi).2 + have hs : orderedDomain N ⊆ Function.support f := fun x hx => (hp x hx).ne' + have hsub : orderedDomain N ⊆ univ.pi (fun _ : Fin N => Ioo (0 : ℝ) 1) := + fun x hx i _ => hx.2 i + calc + 0 < volume (orderedDomain N) := + (isOpen_orderedDomain N).measure_pos volume (orderedDomain_nonempty N) + _ = (volume.restrict (univ.pi fun _ : Fin N => Ioo (0 : ℝ) 1)) (orderedDomain N) := by + rw [Measure.restrict_apply (isOpen_orderedDomain N).measurableSet, inter_eq_left.2 hsub] + _ ≤ _ := measure_mono hs + + + +theorem integral_cauchy_basis (N : ℕ) (x : Fin N → ℝ) (hx : ∀ i, 0 < x i) : + (∫ y : Fin N → ℝ, (boundedCauchyMatrix x y).det * basisDet N y + ∂Measure.pi (fun _ => volume.restrict (Ioo (0 : ℝ) 1))) = + (Fintype.card (Equiv.Perm (Fin N)) : ℝ) * transformedDet N x := by + have h := integral_det_mul_det (fun i y => boundedCauchy (x i) y) + (fun i : Fin N => momentBasis i.val) + (fun i j => integrableOn_boundedCauchy_basis j.val (hx i)) + have hm : (Matrix.of fun i j : Fin N => + ∫ y in Ioo (0 : ℝ) 1, boundedCauchy (x i) y * momentBasis j.val y) = + (Matrix.of fun i j : Fin N => transformedBasis i.val (x j)).transpose := rfl + change _ = _ * (Matrix.of fun i j : Fin N => transformedBasis i.val (x j)).det + simpa only [hm, Matrix.det_transpose, boundedCauchyMatrix, basisDet] using h + +theorem integrable_cauchy_basis (N : ℕ) (x : Fin N → ℝ) (hx : ∀ i, 0 < x i) : + Integrable (fun y => (boundedCauchyMatrix x y).det * basisDet N y) + (Measure.pi fun _ => volume.restrict (Ioo (0 : ℝ) 1)) := + integrable_det_mul_det (fun i y => boundedCauchy (x i) y) + (fun i : Fin N => momentBasis i.val) + (fun i j => integrableOn_boundedCauchy_basis j.val (hx i)) + +theorem basis_transformed_nonneg (N : ℕ) (x : Fin N → ℝ) (hx : ∀ i, 0 < x i) : + 0 ≤ basisDet N x * transformedDet N x := by + have hi : 0 ≤ ∫ y : Fin N → ℝ, + basisDet N x * ((boundedCauchyMatrix x y).det * basisDet N y) + ∂Measure.pi (fun _ => volume.restrict (Ioo (0 : ℝ) 1)) := by + apply integral_nonneg_of_ae + rw [product_restrict_cube] + filter_upwards [ae_restrict_mem (MeasurableSet.univ_pi fun _ : Fin N => measurableSet_Ioo)] with y hy + simpa only [mul_assoc, Pi.zero_apply] using basis_cauchy_basis_nonneg N x y hx + (fun i => (hy i (mem_univ _)).1) + rw [integral_const_mul, integral_cauchy_basis N x hx] at hi + have hc : (0 : ℝ) < Fintype.card (Equiv.Perm (Fin N)) := by positivity + nlinarith + +theorem basis_transformed_pos {N : ℕ} {x : Fin N → ℝ} (hx : x ∈ orderedDomain N) : + 0 < basisDet N x * transformedDet N x := by + have hi := integral_pos_on_cube + ((integrable_cauchy_basis N x (fun i => (hx.2 i).1)).const_mul (basisDet N x)) + (fun y hy => by + simpa only [mul_assoc] using basis_cauchy_basis_nonneg N x y + (fun i => (hx.2 i).1) (fun i => (hy i).1)) + (fun y hy => by simpa only [mul_assoc] using basis_cauchy_basis_pos hx hy) + rw [integral_const_mul, integral_cauchy_basis N x (fun i => (hx.2 i).1)] at hi + have hc : (0 : ℝ) < Fintype.card (Equiv.Perm (Fin N)) := by positivity + nlinarith + + + +theorem det_momentMatrix_pos (N : ℕ) : 0 < (momentMatrix N).det := by + have hi := integral_pos_on_cube + (integrable_det_mul_det (fun i : Fin N => momentBasis i.val) + (fun i : Fin N => transformedBasis i.val) + (fun i j => integrableOn_basis_transformedBasis i.val j.val)) + (fun x hx => basis_transformed_nonneg N x (fun i => (hx i).1)) + (fun _ hx => basis_transformed_pos hx) + rw [integral_det_mul_det (fun i : Fin N => momentBasis i.val) + (fun i : Fin N => transformedBasis i.val) + (fun i j => integrableOn_basis_transformedBasis i.val j.val)] at hi + change 0 < (Fintype.card (Equiv.Perm (Fin N)) : ℝ) * (momentMatrix N).det at hi + exact (mul_pos_iff_of_pos_left (by positivity)).1 hi + + + +def cauchyDefect (N : ℕ) (D₀ : ℝ) (v : Fin N → ℝ) (x : ℝ) : ℝ := + D₀ - ∑ k, v k * transformedBasis k.val x + +def CauchyMomentProblem (N : ℕ) (D₀ : ℝ) (v : Fin N → ℝ) : Prop := + ∀ j : Fin N, ∫ x in Ioo (0 : ℝ) 1, momentBasis j.val x * cauchyDefect N D₀ v x = 0 + +theorem cauchyDefect_moment (N : ℕ) (D₀ : ℝ) (v : Fin N → ℝ) (j : Fin N) : + (∫ x in Ioo (0 : ℝ) 1, momentBasis j.val x * cauchyDefect N D₀ v x) = + D₀ * (∫ x in Ioo (0 : ℝ) 1, momentBasis j.val x) - (momentMatrix N *ᵥ v) j := by + have heq : (fun x => momentBasis j.val x * cauchyDefect N D₀ v x) = + fun x => D₀ * momentBasis j.val x - + ∑ k : Fin N, v k * (momentBasis j.val x * transformedBasis k.val x) := by + funext x + simp only [cauchyDefect, mul_sub, Finset.mul_sum] + congr 1 + · ring + · apply Finset.sum_congr rfl + intro k _ + ring + rw [heq, integral_sub ((integrableOn_momentBasis j.val).const_mul D₀) + (integrable_finsetSum _ fun k _ => (integrableOn_basis_transformedBasis j.val k.val).const_mul (v k)), + integral_const_mul, integral_finsetSum] + · simp only [integral_const_mul, Matrix.mulVec, dotProduct, momentMatrix, Matrix.of_apply] + congr 1 + apply Finset.sum_congr rfl + intro k _ + exact mul_comm _ _ + · intro k _ + exact (integrableOn_basis_transformedBasis j.val k.val).const_mul (v k) + +theorem cauchyMomentProblem_iff (N : ℕ) (D₀ : ℝ) (v : Fin N → ℝ) : + CauchyMomentProblem N D₀ v ↔ + momentMatrix N *ᵥ v = fun j => D₀ * ∫ x in Ioo (0 : ℝ) 1, momentBasis j.val x := by + simp only [CauchyMomentProblem, cauchyDefect_moment, sub_eq_zero] + exact ⟨fun h => funext fun j => (h j).symm, fun h j => (congrFun h j).symm⟩ + + + +theorem existsUnique_cauchyMomentProblem (N : ℕ) (D₀ : ℝ) : + ∃! v : Fin N → ℝ, CauchyMomentProblem N D₀ v := by + have hu : IsUnit (momentMatrix N) := + (Matrix.isUnit_iff_isUnit_det _).2 (isUnit_iff_ne_zero.2 (det_momentMatrix_pos N).ne') + obtain ⟨v, hv⟩ := (Matrix.mulVec_surjective_iff_isUnit.2 hu) + (fun j => D₀ * ∫ x in Ioo (0 : ℝ) 1, momentBasis j.val x) + refine ⟨v, (cauchyMomentProblem_iff _ _ _).2 hv, ?_⟩ + intro w hw + exact (Matrix.mulVec_injective_iff_isUnit.2 hu) + (((cauchyMomentProblem_iff _ _ _).1 hw).trans hv.symm) + + + +theorem cauchyMomentProblem_zero {N : ℕ} {v : Fin N → ℝ} + (hv : CauchyMomentProblem N 0 v) : v = 0 := by + have hu : IsUnit (momentMatrix N) := + (Matrix.isUnit_iff_isUnit_det _).2 (isUnit_iff_ne_zero.2 (det_momentMatrix_pos N).ne') + apply (Matrix.mulVec_injective_iff_isUnit.2 hu) + rw [Matrix.mulVec_zero] + exact ((cauchyMomentProblem_iff _ _ _).1 hv).trans (by ext j; simp) + +end DeterminantBounds + + + +open Set MeasureTheory Filter +open scoped Topology + +def quarticDen (r t : ℝ) : ℝ := t ^ 4 + 2 * t ^ 2 + r ^ 2 +def quarticBase (r t : ℝ) : ℝ := (t ^ 2 + r) / quarticDen r t +def quarticWeighted (r t : ℝ) : ℝ := 2 * (t ^ 2 + r ^ 2) / quarticDen r t +def straightener (r t : ℝ) : ℝ := t - r / t + +theorem quarticDen_pos {r t : ℝ} (hr : 0 < r) : 0 < quarticDen r t := by + unfold quarticDen + positivity + +theorem straightener_deriv {r t : ℝ} (ht : 0 < t) : + HasDerivAt (straightener r) (1 + r / t ^ 2) t := by + exact ((hasDerivAt_id t).sub ((hasDerivAt_const t r).div + (hasDerivAt_id t) ht.ne')).congr_deriv (by simp; ring) + +theorem straightener_inj {r : ℝ} (hr : 0 < r) : + InjOn (straightener r) (Ioi 0) := by + apply StrictMonoOn.injOn + intro x hx y hy hxy + dsimp [straightener] + have hdiv : r / y < r / x := (div_lt_div_iff_of_pos_left hr hy hx).2 hxy + linarith + +theorem straightener_image {r : ℝ} (hr : 0 < r) : + straightener r '' Ioi 0 = univ := by + apply eq_univ_of_forall + intro u + let s := Real.sqrt (u ^ 2 + 4 * r) + have hs : s ^ 2 = u ^ 2 + 4 * r := Real.sq_sqrt (by positivity) + have hsn : 0 ≤ s := Real.sqrt_nonneg _ + have hsu : -u < s := by nlinarith + have ht : 0 < (u + s) / 2 := by linarith + refine ⟨(u + s) / 2, ht, ?_⟩ + dsimp [straightener] + field_simp [show u + s ≠ 0 by linarith] + nlinarith + +theorem scaled_cauchy {a : ℝ} (ha : 0 < a) : + Integrable (fun x : ℝ => (a ^ 2 + x ^ 2)⁻¹) ∧ + (∫ x : ℝ, (a ^ 2 + x ^ 2)⁻¹) = Real.pi / a := by + have heq : (fun x : ℝ => (a ^ 2 + x ^ 2)⁻¹) = + fun x => (a ^ 2)⁻¹ * (1 + (x / a) ^ 2)⁻¹ := by + funext x + field_simp + rw [heq] + constructor + · exact (integrable_inv_one_add_sq.comp_div ha.ne').const_mul _ + · rw [integral_const_mul, Measure.integral_comp_div (fun x : ℝ => (1 + x ^ 2)⁻¹) a, integral_univ_inv_one_add_sq, + abs_of_pos ha, smul_eq_mul] + field_simp + +theorem quartic_base_integral {r : ℝ} (hr : 0 < r) : + IntegrableOn (quarticBase r) (Ioi 0) ∧ + (∫ t in Ioi 0, quarticBase r t) = Real.pi / Real.sqrt (2 + 2 * r) := by + let a := Real.sqrt (2 + 2 * r) + have ha : 0 < a := Real.sqrt_pos.2 (by linarith) + have ha2 : a ^ 2 = 2 + 2 * r := Real.sq_sqrt (by linarith) + have heq : EqOn (fun t => |1 + r / t ^ 2| • + (a ^ 2 + (straightener r t) ^ 2)⁻¹) (quarticBase r) (Ioi 0) := by + intro t ht + dsimp only + rw [abs_of_pos (by positivity : 0 < 1 + r / t ^ 2), smul_eq_mul, ha2] + dsimp [straightener, quarticBase, quarticDen] + field_simp [show t ≠ 0 from ne_of_gt ht] + ring_nf + field_simp + have hi := integrableOn_image_iff_integrableOn_abs_deriv_smul measurableSet_Ioi + (fun t ht => (straightener_deriv ht).hasDerivWithinAt) + (straightener_inj hr) (fun u => (a ^ 2 + u ^ 2)⁻¹) + rw [straightener_image hr, integrableOn_univ] at hi + refine ⟨(hi.1 (scaled_cauchy ha).1).congr_fun heq measurableSet_Ioi, ?_⟩ + have h := integral_image_eq_integral_abs_deriv_smul measurableSet_Ioi + (fun t ht => (straightener_deriv ht).hasDerivWithinAt) + (straightener_inj hr) (fun u => (a ^ 2 + u ^ 2)⁻¹) + rw [straightener_image hr, Measure.restrict_univ, (scaled_cauchy ha).2] at h + exact (setIntegral_congr_fun measurableSet_Ioi heq).symm.trans h.symm + +theorem integral_reciprocal {r : ℝ} (hr : 0 < r) (g : ℝ → ℝ) : + (∫ t in Ioi 0, (r / t ^ 2) * g (r / t)) = ∫ t in Ioi 0, g t := by + have hd : ∀ t ∈ Ioi (0 : ℝ), HasDerivWithinAt (fun t => r / t) + (-r / t ^ 2) (Ioi 0) t := by + intro t ht + exact (((hasDerivAt_const t r).div (hasDerivAt_id t) ht.ne').congr_deriv + (by simp)).hasDerivWithinAt + have hinj : InjOn (fun t => r / t) (Ioi 0) := by + intro x hx y hy h + have h' := (div_eq_div_iff hx.ne' hy.ne').1 h + nlinarith + have himage : (fun t => r / t) '' Ioi (0 : ℝ) = Ioi 0 := by + ext t + constructor + · rintro ⟨u, hu, rfl⟩ + exact div_pos hr hu + · intro ht + refine ⟨r / t, div_pos hr ht, ?_⟩ + field_simp + have h := integral_image_eq_integral_abs_deriv_smul measurableSet_Ioi hd hinj g + rw [himage] at h + rw [h] + apply setIntegral_congr_fun measurableSet_Ioi + intro t ht + dsimp only + rw [abs_of_neg (by exact div_neg_of_neg_of_pos (neg_neg_of_pos hr) (sq_pos_of_pos ht)), + neg_div, neg_neg, smul_eq_mul] + +theorem quartic_weighted_integral {r : ℝ} (hr : 0 < r) : + IntegrableOn (quarticWeighted r) (Ioi 0) ∧ + (∫ t in Ioi 0, quarticWeighted r t) = + Real.pi * (1 + r) / Real.sqrt (2 + 2 * r) := by + have hbase := quartic_base_integral hr + have hint : IntegrableOn (quarticWeighted r) (Ioi 0) := by + apply (hbase.1.const_mul (2 * (1 + r))).mono' + · apply Measurable.aestronglyMeasurable + unfold quarticWeighted quarticDen + fun_prop + · filter_upwards [ae_restrict_mem measurableSet_Ioi] with t ht + have hd := quarticDen_pos (t := t) hr + rw [Real.norm_eq_abs, abs_of_nonneg (by unfold quarticWeighted; positivity)] + unfold quarticWeighted quarticBase + rw [← mul_div_assoc, div_le_div_iff_of_pos_right hd] + nlinarith [sq_nonneg t] + have heq : EqOn (fun t => quarticWeighted r t + + (r / t ^ 2) * quarticWeighted r (r / t)) + (fun t => (2 * (1 + r)) * quarticBase r t) (Ioi 0) := by + intro t ht + dsimp [quarticWeighted, quarticBase, quarticDen] + field_simp [show t ≠ 0 from ne_of_gt ht] + ring + have hi2 : IntegrableOn (fun t => (r / t ^ 2) * quarticWeighted r (r / t)) (Ioi 0) := by + apply IntegrableOn.congr_fun ((hbase.1.const_mul (2 * (1 + r))).sub hint) _ measurableSet_Ioi + intro t ht + have h := heq ht + dsimp only at h + dsimp only [Pi.sub_apply] + linarith + have h := setIntegral_congr_fun (μ := volume) measurableSet_Ioi heq + rw [integral_add hint hi2, integral_const_mul, integral_reciprocal hr, + hbase.2] at h + refine ⟨hint, ?_⟩ + linear_combination h / 2 + +def uniformDen (t : ℝ) : ℝ := 2 * t ^ 4 + 4 * t ^ 2 + 1 +def uniformizer (t : ℝ) : ℝ := 1 / uniformDen t + +theorem uniformDen_pos (t : ℝ) : 0 < uniformDen t := by + unfold uniformDen + positivity + +theorem uniformizer_mem {t : ℝ} (ht : 0 < t) : uniformizer t ∈ Ioo 0 1 := by + refine ⟨one_div_pos.2 (uniformDen_pos t), ?_⟩ + unfold uniformizer + rw [div_lt_one (uniformDen_pos t)] + unfold uniformDen + have : 0 < t ^ 2 := sq_pos_of_pos ht + nlinarith [sq_nonneg (t ^ 2)] + +theorem uniformizer_deriv (t : ℝ) : + HasDerivAt uniformizer (-8 * t * (t ^ 2 + 1) / (uniformDen t) ^ 2) t := by + have hd : HasDerivAt uniformDen (8 * t * (t ^ 2 + 1)) t := by + exact (((((hasDerivAt_id t).pow 4).const_mul (2 : ℝ)).add + (((hasDerivAt_id t).pow 2).const_mul (4 : ℝ))).add_const 1).congr_deriv (by simp only [id_eq]; ring) + have heq : uniformizer = uniformDen⁻¹ := by funext t; simp [uniformizer] + rw [heq] + exact (hd.inv (uniformDen_pos t).ne').congr_deriv (by ring) + +theorem uniformizer_inj : InjOn uniformizer (Ioi 0) := by + apply StrictAntiOn.injOn + intro x hx y hy hxy + unfold uniformizer + apply one_div_lt_one_div_of_lt (uniformDen_pos x) + unfold uniformDen + gcongr <;> exact le_of_lt hx + +theorem omega_uniformizer {t : ℝ} (ht : 0 < t) : omega (uniformizer t) = t / 2 := by + have hinner : (1 + uniformizer t) / (2 * uniformizer t) = (t ^ 2 + 1) ^ 2 := by + unfold uniformizer uniformDen + field_simp + ring + unfold omega + rw [hinner, Real.sqrt_sq (by positivity : 0 ≤ t ^ 2 + 1)] + simp only [add_sub_cancel_right, Real.sqrt_sq ht.le] + ring + +theorem uniformizer_image : uniformizer '' Ioi 0 = Ioo 0 1 := by + ext x + constructor + · rintro ⟨t, ht, rfl⟩ + exact uniformizer_mem ht + · intro hx + have hx0 : 0 < x := hx.1 + have hx1 : x < 1 := hx.2 + let w := Real.sqrt ((1 + x) / (2 * x)) + have hw2 : w ^ 2 = (1 + x) / (2 * x) := Real.sq_sqrt (by positivity) + have hw : 1 < w := by + apply (Real.lt_sqrt (by norm_num : (0 : ℝ) ≤ 1)).2 + rw [one_pow, lt_div_iff₀ (by positivity : 0 < 2 * x)] + linarith [hx.1, hx.2] + let t := Real.sqrt (w - 1) + have ht : 0 < t := Real.sqrt_pos.2 (by linarith) + have ht2 : t ^ 2 = w - 1 := Real.sq_sqrt (by linarith) + refine ⟨t, ht, ?_⟩ + unfold uniformizer + apply (div_eq_iff (uniformDen_pos t).ne').2 + have hd : uniformDen t = 2 * w ^ 2 - 1 := by + unfold uniformDen + calc + _ = 2 * (t ^ 2) ^ 2 + 4 * t ^ 2 + 1 := by ring + _ = _ := by rw [ht2]; ring + rw [hd, hw2] + field_simp [hx0.ne'] + ring + +end +end CriticalStrip + +end OAI diff --git a/lean/OAI/Combinatorics/StripMass/CollisionLeaf.lean b/lean/OAI/Combinatorics/StripMass/CollisionLeaf.lean new file mode 100644 index 0000000000000000000000000000000000000000..56839ce289be54585e45df81ea02db4d90d64f39 --- /dev/null +++ b/lean/OAI/Combinatorics/StripMass/CollisionLeaf.lean @@ -0,0 +1,401 @@ +import Mathlib +import OAI.Combinatorics.StripMass.BoundaryTree + +namespace OAI + +/-! Critical honeycomb strip paths, polynomial identities and crossing mass. -/ + + +namespace CriticalStrip.HoneycombBranch +noncomputable section +open scoped Classical BigOperators +open FiniteBranchTree + +lemma lastVisited_mem (s : State) (l : List Bool) (hl : l ≠ []) : + (back (terminal next s l)).1 ∈ visited Prod.fst next s l := by + induction l generalizing s with + | nil => exact (hl rfl).elim + | cons b l ih => + cases l with + | nil => simp only [terminal,back_next,visited,List.mem_cons,true_or] + | cons c l => exact List.mem_cons_of_mem _ (ih _ (by simp)) + +lemma exists_split_visit (s : State) (l : List Bool) (v : Vertex) + (hv : v ∈ visited Prod.fst next s l) : + ∃ stem b tail, l=stem++b::tail ∧ (terminal next s stem).1=v := by + induction l generalizing s with + | nil => simp only [visited,List.not_mem_nil] at hv + | cons b l ih => + rcases List.mem_cons.mp hv with he | hv + · exact ⟨[],b,l,rfl,he.symm⟩ + · obtain ⟨stem,c,t,he,hv⟩ := ih (next s b) hv + exact ⟨b::stem,c,t,by simp only [List.cons_append,he],hv⟩ + + + +lemma collision_port_not_first (s : State) (b : Bool) (l : List Bool) + (hn : (visited Prod.fst next s (b::l)).Nodup) + (hc : (terminal next s (b::l)).1=s.1) : + (terminal next s (b::l)).2 ≠ outgoing s.2 b := by + intro hp + have he : (back (terminal next s (b::l))).1=(next s b).1 := by + simp only [back,hc,hp,next] + cases l with + | nil => exact next_ne s b hc + | cons c l => + cases l with + | nil => + have h := next_not_back (next s b) c + rw [next_back] at h + exact h hc + | cons d l => + have hmem := lastVisited_mem (next (next s b) c) (d::l) (by simp) + change (back (terminal next s (b::c::d::l))).1 ∈ _ at hmem + rw [he] at hmem + exact (List.nodup_cons.mp hn.tail).1 hmem + + + +lemma collision_port_not_stem (D : Finset Vertex) (s : State) (stem : List Bool) + (b : Bool) (l : List Bool) (hs : (back s).1 ∉ D) + (hl : stem++b::l ∈ words D s) + (hc : (terminal next s (stem++b::l)).1=(terminal next s stem).1) : + (terminal next s (stem++b::l)).2 ≠ (terminal next s stem).2 := by + intro hp + have he : (back (terminal next s (stem++b::l))).1=(back (terminal next s stem)).1 := by + simp only [back,hc,hp] + have hm := lastVisited_mem (terminal next s stem) (b::l) (by simp) + rw [←terminal_append,he] at hm + have hfull := visited_nodup Prod.fst next hl + have hdom := visited_mem_domain Prod.fst next hl + cases stem with + | nil => exact hs (hdom _ hm) + | cons a stem => + have hh := lastVisited_mem s (a::stem) (by simp) + rw [visited_append] at hfull + exact List.disjoint_left.mp hfull.disjoint hh hm + + +lemma collision_index_eq (s : State) (stem : List Bool) (b : Bool) (l : List Bool) + (hn : (visited Prod.fst next s (stem++b::l)).Nodup) : + (visited Prod.fst next s (stem++b::l)).idxOf (terminal next s stem).1=stem.length := by + rw [visited_append] at hn ⊢ + have hnot : (terminal next s stem).1 ∉ visited Prod.fst next s stem := by + intro h + exact List.disjoint_left.mp hn.disjoint h (List.mem_cons_self) + rw [List.idxOf_append_of_notMem hnot] + simp only [visited,List.idxOf_cons_self,add_zero,visited_length] + + +def collisionIndex (s : State) (l : List Bool) : ℕ := + (visited Prod.fst next s l).idxOf (terminal next s l).1 + +def collisionReverse (s : State) (l : List Bool) : List Bool := + l.take (collisionIndex s l) ++ reverseCycle (l.drop (collisionIndex s l)) + +lemma collisionReverse_split (s : State) (stem : List Bool) (b : Bool) (tail : List Bool) + (hn : (visited Prod.fst next s (stem++b::tail)).Nodup) + (hc : (terminal next s (stem++b::tail)).1=(terminal next s stem).1) : + collisionReverse s (stem++b::tail)=stem++reverseCycle (b::tail) := by + have hx : collisionIndex s (stem++b::tail)=stem.length := by + rw [collisionIndex,hc,collision_index_eq s stem b tail hn] + simp only [collisionReverse,hx,List.take_left,List.drop_left] + +lemma collision_split (D : Finset Vertex) (s : State) (l : List Bool) + (hl : l ∈ words D s) (ht : (terminal next s l).1 ∈ D) : + ∃ stem b tail, l=stem++b::tail ∧ + (terminal next s (stem++b::tail)).1=(terminal next s stem).1 := by + obtain ⟨stem,b,t,he,hc⟩ := exists_split_visit s l (terminal next s l).1 + ((terminal_mem_domain_iff_collision Prod.fst next hl).mp ht) + refine ⟨stem,b,t,he,?_⟩ + rw [←he] + exact hc.symm + +lemma collisionReverse_mem (D : Finset Vertex) (s : State) (l : List Bool) + (hs : (back s).1 ∉ D) (hl : l ∈ words D s) (ht : (terminal next s l).1 ∈ D) : + collisionReverse s l ∈ words D s ∧ + (terminal next s (collisionReverse s l)).1=(terminal next s l).1 := by + obtain ⟨stem,b,t,rfl,hc⟩ := collision_split D s l hl ht + have hn := visited_nodup Prod.fst next hl + have h₀ := collision_port_not_stem D s stem b t hs hl hc + have hn' : (visited Prod.fst next (terminal next s stem) (b::t)).Nodup := by + rw [visited_append] at hn + exact hn.of_append_right + have hc' := hc + rw [terminal_append] at hc' + have h₁ := collision_port_not_first (terminal next s stem) b t hn' hc' + rw [collisionReverse_split s stem b t hn hc] + refine ⟨prefix_reverseCycle_mem D s stem b t hl hc h₀ (by simpa only [terminal_append] using h₁),?_⟩ + rw [terminal_append,terminal_reverseCycle _ b t hc' (by simpa only [terminal_append] using h₀) h₁] + exact hc.symm + +lemma collisionReverse_involutive (D : Finset Vertex) (s : State) (l : List Bool) + (hs : (back s).1 ∉ D) (hl : l ∈ words D s) (ht : (terminal next s l).1 ∈ D) : + collisionReverse s (collisionReverse s l)=l := by + obtain ⟨stem,b,t,rfl,hc⟩ := collision_split D s l hl ht + have he := collisionReverse_split s stem b t (visited_nodup Prod.fst next hl) hc + obtain ⟨hm,hv⟩ := collisionReverse_mem D s (stem++b::t) hs hl ht + rw [he] at hm hv ⊢ + change stem++(!b)::reverseTurns t ∈ words D s at hm + have hc' : (terminal next s (stem++(!b)::reverseTurns t)).1=(terminal next s stem).1 := + hv.trans hc + change collisionReverse s (stem++(!b)::reverseTurns t) = stem++b::t + rw [collisionReverse_split s stem (!b) (reverseTurns t) (visited_nodup Prod.fst next hm) hc'] + simp only [reverseCycle,reverseTurns_involutive,Bool.not_not] + +lemma collisionReverse_weight (D : Finset Vertex) (s : State) (l : List Bool) + (hl : l ∈ words D s) (ht : (terminal next s l).1 ∈ D) + (hturn : turn (l.drop (collisionIndex s l)) % 8 = 4) : + wordWeight factor l + wordWeight factor (collisionReverse s l) = 0 := by + obtain ⟨stem,b,t,rfl,hc⟩ := collision_split D s l hl ht + have hn := visited_nodup Prod.fst next hl + have hx : collisionIndex s (stem++b::t)=stem.length := by + rw [collisionIndex,hc,collision_index_eq s stem b t hn] + rw [hx,List.drop_left] at hturn + rw [collisionReverse_split s stem b t hn hc] + exact cycle_weight_cancel stem (b::t) hturn + + + +theorem collisionMass_zero_of_turns (D : Finset Vertex) (s : State) + (hs : (back s).1 ∉ D) + (hturn : ∀ l ∈ words D s, (terminal next s l).1 ∈ D → + turn (l.drop (collisionIndex s l)) % 8 = 4) : + collisionMass Prod.fst next factor D s=0 := by + let F := (words D s).filter (fun l => (terminal next s l).1 ∈ D) + have hf : ∀ l∈F, collisionReverse s l ∈ F := by + intro l hl + obtain ⟨hl,ht⟩ := Finset.mem_filter.mp hl + obtain ⟨hm,he⟩ := collisionReverse_mem D s l hs hl ht + exact Finset.mem_filter.mpr ⟨hm,he ▸ ht⟩ + have hrev : ∀ l∈F,collisionReverse s (collisionReverse s l)=l := by + intro l hl + obtain ⟨hl,ht⟩ := Finset.mem_filter.mp hl + exact collisionReverse_involutive D s l hs hl ht + have hsum : (∑ l∈F,wordWeight factor (collisionReverse s l)) = + ∑ l∈F,wordWeight factor l := by + apply Finset.sum_bij (fun l _ => collisionReverse s l) hf + · intro a ha b hb he + have hh := congrArg (collisionReverse s) he + rwa [hrev a ha,hrev b hb] at hh + · intro b hb + exact ⟨collisionReverse s b,hf b hb,hrev b hb⟩ + · intro l hl + rfl + have hz : (∑ l∈F,wordWeight factor l) + (∑ l∈F,wordWeight factor (collisionReverse s l)) = 0 := by + rw [←Finset.sum_add_distrib] + apply Finset.sum_eq_zero + intro l hl + obtain ⟨hl,ht⟩ := Finset.mem_filter.mp hl + exact collisionReverse_weight D s l hl ht (hturn l hl ht) + rw [hsum] at hz + change (∑ l∈F,wordWeight factor l)=0 + linear_combination (1/2:ℂ)*hz + +end +end CriticalStrip.HoneycombBranch + + + + + + + +namespace CriticalStrip.Diagram +noncomputable section +open scoped Classical + +namespace Pairing + +def turnOrder {n : ℕ} (i j : Fin n) : ℤ := + if i < j then 1 else if j < i then -1 else 0 + +def arcTurn {n : ℕ} (g : Fin n → ℤ) (i j : Fin n) : ℤ := + g j - g i - 3 * turnOrder i j + +lemma turnOrder_self {n : ℕ} (i : Fin n) : turnOrder i i=0 := by + simp [turnOrder] + +lemma turnOrder_reverse {n : ℕ} (i j : Fin n) : turnOrder j i= -turnOrder i j := by + unfold turnOrder + split_ifs <;> omega + +lemma arcTurn_reverse {n : ℕ} (g : Fin n → ℤ) (i j : Fin n) : + arcTurn g j i= -arcTurn g i j := by + unfold arcTurn + rw [turnOrder_reverse i j] + ring + + +def turnPotential {n : ℕ} (p : Pairing n) (g : Fin n → ℤ) (i : Fin n) : ℤ := + g i - if p.Occupied i ∧ p.partnerOrSelf i < i then 3 else 0 + +lemma turnPotential_of_adj {n : ℕ} {p : Pairing n} (g : Fin n → ℤ) + {i j : Fin n} (h : p.Adj i j) : + p.turnPotential g j-p.turnPotential g i=arcTurn g i j := by + have hi : p.Occupied i := ⟨j,h⟩ + have hj : p.Occupied j := ⟨i,h.symm⟩ + have hpi := (p.adj_partnerOrSelf i j).mp h + have hpj := (p.adj_partnerOrSelf j i).mp h.symm + have hn : i≠j := fun he=>p.adj_irrefl _ (he ▸ h) + simp only [turnPotential,hi,hj,true_and,←hpi.2,←hpj.2,arcTurn,turnOrder] + split_ifs <;> omega + + + +lemma cap_partner_orders {n : ℕ} {p : Pairing n} {a b x y : Fin n} + (hab : a.val+1=b.val) (hx : p.Adj a x) (hy : p.Adj b y) + (hn : ¬p.Adj a b) : + (x rcases ho with ⟨_,_⟩|⟨_,_⟩|⟨_,_⟩ <;> omega + + + +lemma cap_arcTurn {n : ℕ} {p : Pairing n} {a b x y : Fin n} + (g : Fin n → ℤ) (hab : a.val+1=b.val) (hg : g b=g a-2) + (hx : p.Adj a x) (hy : p.Adj b y) (hn : ¬p.Adj a b) : + arcTurn g x a+1+arcTurn g b y=arcTurn g x y := by + have hc:=cap_turn_order hab hx hy hn + simp only [arcTurn,hg] + omega + + + +lemma cap_loop_turn {n : ℕ} (g : Fin n → ℤ) {a b : Fin n} + (hab : a.val+1=b.val) (hg : g b=g a-2) : + arcTurn g a b-1= -6 := by + have hlt : ag (Equiv.swap a b i) + +lemma swapGauge_left {n : ℕ} (g : Fin n → ℤ) (a b : Fin n) : + swapGauge g a b a=g b := by simp [swapGauge] +lemma swapGauge_right {n : ℕ} (g : Fin n → ℤ) (a b : Fin n) : + swapGauge g a b b=g a := by simp [swapGauge] +lemma swapGauge_other {n : ℕ} (g : Fin n → ℤ) (a b i : Fin n) + (ha : i≠a) (hb : i≠b) : swapGauge g a b i=g i := by + simp [swapGauge,Equiv.swap_apply_of_ne_of_ne ha hb] + +lemma cup_arcTurn {n : ℕ} (g : Fin n → ℤ) {a b : Fin n} + (hab : a.val+1=b.val) (hg : g b=g a-2) : + arcTurn (swapGauge g a b) a b = -1 := by + have hlt : a simp only [Fin.lt_def,Fin.ne_iff_vne] at * <;> omega + +lemma diagonal_lower_arcTurn {n : ℕ} (g : Fin n → ℤ) {a b x : Fin n} + (hab : a.val+1=b.val) (ha : x≠a) (hb : x≠b) : + arcTurn g x a = arcTurn (swapGauge g a b) x b := by + have ho:=adjacent_turnOrder hab ha hb + have ho' : turnOrder x a=turnOrder x b := by + rw [turnOrder_reverse a x,turnOrder_reverse b x,ho] + simp only [arcTurn,swapGauge_right,swapGauge_other g a b x ha hb,ho'] + +lemma diagonal_upper_arcTurn {n : ℕ} (g : Fin n → ℤ) {a b x : Fin n} + (hab : a.val+1=b.val) (ha : x≠a) (hb : x≠b) : + arcTurn g x b = arcTurn (swapGauge g a b) x a := by + have ho:=adjacent_turnOrder hab ha hb + have ho' : turnOrder x a=turnOrder x b := by + rw [turnOrder_reverse a x,turnOrder_reverse b x,ho] + simp only [arcTurn,swapGauge_left,swapGauge_other g a b x ha hb,ho'] + +lemma vertical_lower_arcTurn {n : ℕ} (g : Fin n → ℤ) {a b x : Fin n} + (hg : g b=g a-2) (ha : x≠a) (hb : x≠b) : + arcTurn g x a-2=arcTurn (swapGauge g a b) x a := by + simp only [arcTurn,swapGauge_left,swapGauge_other g a b x ha hb,hg] + ring + +lemma vertical_upper_arcTurn {n : ℕ} (g : Fin n → ℤ) {a b x : Fin n} + (hg : g b=g a-2) (ha : x≠a) (hb : x≠b) : + arcTurn g x b+2=arcTurn (swapGauge g a b) x b := by + simp only [arcTurn,swapGauge_right,swapGauge_other g a b x ha hb,hg] + ring + +end Pairing + + + + + + + + +namespace Graph + +variable {V : Type*} {n : ℕ} {r : V → V → Prop} [Std.Symm r] + {b : Fin n → V} {p : Pairing n} + +def boundaryConstant (b : Fin n → V) (r : V → V → Prop) (f : Fin n → ℤ) (v : V) : ℤ := + if h : ∃ i, Relation.ReflTransGen r v (b i) then f (Classical.choose h) else 0 + +lemma boundaryConstant_eq (h : GraphRealizes r b p) (f : Fin n → ℤ) + (hf : ∀ i j, p.Adj i j → f i=f j) {v : V} {i : Fin n} + (hi : Relation.ReflTransGen r v (b i)) : boundaryConstant b r f v=f i := by + have he : ∃ j,Relation.ReflTransGen r v (b j) := ⟨i,hi⟩ + rw [boundaryConstant,dite_eq_left he] + have hj := Classical.choose_spec he + have hc := (h.reach (Classical.choose he) i).mp ((symm hj).trans hi) + exact hc.elim (fun hh=>congrArg f hh) (hf _ _) + +lemma boundaryConstant_boundary (h : GraphRealizes r b p) (f : Fin n → ℤ) + (hf : ∀ i j,p.Adj i j → f i=f j) (i : Fin n) : + boundaryConstant b r f (b i)=f i := + boundaryConstant_eq h f hf .refl + +lemma boundaryConstant_edge (h : GraphRealizes r b p) (f : Fin n → ℤ) + (hf : ∀ i j,p.Adj i j → f i=f j) {v w : V} (hv : r v w) : + boundaryConstant b r f v=boundaryConstant b r f w := by + obtain ⟨i,_,hi⟩ := h.no_loop v w hv + rw [boundaryConstant_eq h f hf hi, + boundaryConstant_eq h f hf ((Relation.ReflTransGen.single (symm hv)).trans hi)] + + + +lemma renormalize_potential (h : GraphRealizes r b p) (P : V → ℤ) + (f : Fin n → ℤ) + (hf : ∀ i j,p.Adj i j → f j-f i=P (b j)-P (b i)) : + ∃ Q : V → ℤ, (∀ i,Q (b i)=f i) ∧ + ∀ v w,r v w → Q w-Q v=P w-P v := by + let d : Fin n → ℤ := fun i=>f i-P (b i) + have hd : ∀ i j,p.Adj i j → d i=d j := by + intro i j hij + have hh := hf i j hij + dsimp only [d] + omega + refine ⟨fun v=>P v+boundaryConstant b r d v,?_,?_⟩ + · intro i + dsimp only + rw [boundaryConstant_boundary h d hd] + simp [d] + · intro v w hvw + dsimp only + rw [boundaryConstant_edge h d hd hvw] + omega + +end Graph +end +end CriticalStrip.Diagram + +end OAI diff --git a/lean/OAI/Combinatorics/StripMass/CollisionSubstitutions.lean b/lean/OAI/Combinatorics/StripMass/CollisionSubstitutions.lean new file mode 100644 index 0000000000000000000000000000000000000000..66adad3788b6e9af16d3ace189fa4923c662289d --- /dev/null +++ b/lean/OAI/Combinatorics/StripMass/CollisionSubstitutions.lean @@ -0,0 +1,559 @@ +import Mathlib +import OAI.Combinatorics.StripMass.NodalExchange +import OAI.Combinatorics.StripMass.Specialization + +namespace OAI + +/-! Critical honeycomb strip paths, polynomial identities and crossing mass. -/ + + + +namespace CriticalStrip.Diagram +noncomputable section +open scoped LaurentPolynomial Classical + +lemma cosineCollisionPacket_eval_root {R : Type*} [CommRing R] [IsDomain R] + (a u : Rˣ) (k : Fin 4) : + LaurentPolynomial.eval₂ (RingHom.id R) (cosineCollisionRoots a u k) (cosineCollisionPacket a u)=0 := by + let φ:=LaurentPolynomial.eval₂ (RingHom.id R) (cosineCollisionRoots a u k) + have h:=congrArg φ (cosineCollision_factorization a u) + rw [map_mul,map_prod] at h + have hz : (∏ l : Fin 4,φ (LaurentPolynomial.T 1-LaurentPolynomial.C ((cosineCollisionRoots a u l):R)))=0 := + Finset.prod_eq_zero (Finset.mem_univ k) (by simp [φ,laurent_eval_linear]) + rw [hz] at h + apply (mul_eq_zero.mp h.symm).resolve_left + simp only [φ,map_mul,LaurentPolynomial.eval₂_C,LaurentPolynomial.eval₂_T,RingHom.id_apply, + zpow_ofNat] + exact mul_ne_zero (Units.ne_zero _) (pow_ne_zero _ (Units.ne_zero _)) + +def collisionCopy {n : ℕ} (i : Fin (n+1)) (j : Fin n) : Fin (n+1) → Fin n := Fin.insertNth i j id + +def collisionSubstitution {n : ℕ} (i : Fin (n+1)) (j : Fin n) (k : Fin 4) : + Laurent (n+1) →+* Laurent n := + substituteLaurent i (cosineCollisionRoots + (constantUnit n (phase^3) (pow_ne_zero _ phase_ne_zero)) (variableUnit j) k) + +lemma collisionSubstitution_beta_self {n : ℕ} (i : Fin (n+1)) (j : Fin n) (k : Fin 4) : + collisionSubstitution i j k (betaL i)=betaL j := by + have h:=cosineCollisionPacket_eval_root + (constantUnit n (phase^3) (pow_ne_zero _ phase_ne_zero)) (variableUnit j) k + rw [cosineCollisionPacket_betaL i j,map_mul,map_ofNat] at h + have hzero : collisionSubstitution i j k (betaL i-betaL (i.succAbove j))=0 := by + exact (mul_eq_zero.mp h).resolve_left (by + intro hz + have h:=congrArg (algebraMap (SpectralRing n) (SpectralField n)) hz + simp only [map_ofNat,map_zero] at h + exact (two_ne_zero : (2 : SpectralField n)≠0) h) + rw [map_sub] at hzero + have ho : collisionSubstitution i j k (betaL (i.succAbove j))=betaL j := by + rw [←insert_betaL i j] + exact substituteLaurent_insert _ _ _ + rw [ho] at hzero + exact sub_eq_zero.mp hzero + +lemma collisionSubstitution_beta {n : ℕ} (i : Fin (n+1)) (j : Fin n) (k : Fin 4) (l : Fin (n+1)) : + collisionSubstitution i j k (betaL l)=betaL (collisionCopy i j l) := by + refine Fin.succAboveCases i ?_ (fun l => ?_) l + · simpa only [collisionCopy,Fin.insertNth_apply_same] using collisionSubstitution_beta_self i j k + · simp only [collisionCopy,Fin.insertNth_apply_succAbove,id_eq] + rw [←insert_betaL i l] + exact substituteLaurent_insert _ _ _ + +lemma collisionCopy_eq {n : ℕ} (i : Fin (n+1)) (j : Fin n) (r s : Fin (n+1)) (hrs:r≠s) + (h:collisionCopy i j r=collisionCopy i j s) : + (r=i ∧ s=i.succAbove j) ∨ (r=i.succAbove j ∧ s=i) := by + unfold collisionCopy at h + revert h hrs + refine Fin.succAboveCases i ?_ (fun r => ?_) r + · refine Fin.succAboveCases i ?_ (fun s => ?_) s + · intro hrs _; exact (hrs rfl).elim + · intro _ h + simp only [Fin.insertNth_apply_same,Fin.insertNth_apply_succAbove,id_eq] at h + exact Or.inl ⟨rfl,congrArg i.succAbove h.symm⟩ + · refine Fin.succAboveCases i ?_ (fun s => ?_) s + · intro _ h + simp only [Fin.insertNth_apply_same,Fin.insertNth_apply_succAbove,id_eq] at h + exact Or.inr ⟨congrArg i.succAbove h,rfl⟩ + · intro hrs h + simp only [Fin.insertNth_apply_succAbove,id_eq] at h + exact (hrs (congrArg i.succAbove h)).elim + +lemma collisionSubstitution_cross {n : ℕ} (i : Fin (n+1)) (j : Fin n) + (hij : i < i.succAbove j) (e:UpperPair (n+1)) (hne:e≠⟨(i,i.succAbove j),hij⟩) (k : Fin 4) : + collisionSubstitution i j k (betaL e.val.1-betaL e.val.2)≠0 := by + rw [map_sub,collisionSubstitution_beta,collisionSubstitution_beta] + apply sub_ne_zero.mpr + intro h + have hcopy:=cosineL_two_injective _ (pow_ne_zero 3 phase_ne_zero) h + rcases collisionCopy_eq i j e.val.1 e.val.2 (ne_of_lt e.property) hcopy with h | h + · apply hne + exact Subtype.ext (Prod.ext h.1 h.2) + · have he:=e.property + rw [h.1,h.2] at he + exact lt_asymm hij he + +end + + + + + +noncomputable section +open scoped Classical + +lemma copyEvaluation_collision {n : ℕ} (i : Fin (n+1)) (j : Fin n) (f : Laurent (n+1)) : + copyEvaluation (collisionCopy i j) f=evalLaurent (substituteLaurent i (variableUnit j) f) := by + apply substitution_torusEvaluation + · simp only [collisionCopy,Fin.insertNth_apply_same] + rfl + · intro k + simp only [collisionCopy,Fin.insertNth_apply_succAbove,id_eq] + +lemma nodalDatumL_copy_collision {n : ℕ} (W : Pairing n → Laurent n) + (hW:∀ p,evalLaurent (W p)=rationalVacuum n p) (i : Fin (n+1)) (j : Fin n) (p : Pairing (n+2)) : + copyEvaluation (collisionCopy i j) (nodalDatumL W i p)= + copyEvaluation (collisionCopy i j) (nodalDatumL W (i.succAbove j) p) := by + have hij:collisionCopy i j i=collisionCopy i j (i.succAbove j) := by + simp only [collisionCopy,Fin.insertNth_apply_same,Fin.insertNth_apply_succAbove,id_eq] + have hm (k : Fin (n+1)) : + RationalAt (copyEvaluation (collisionCopy i j)).toRingHom + (nodalVacuum k p/(if p.Occupied (Fin.last (n+1)) then torusSin (deletionNode k) else 1)) + (copyEvaluation (collisionCopy i j) (nodalDatumL W k p)) := by + rw [←nodalDatumL_map W hW k p] + exact RationalAt.algebraMap _ + by_cases hp:p.Occupied (Fin.last (n+1)) + · obtain ⟨y,hy,hz⟩:=occupied_nodal_collision (collisionCopy i j) i (i.succAbove j) hij p + have hmi:=hm i + have hmj:=hm (i.succAbove j) + simp only [hp,ite_true] at hmi hmj + exact (hmi.unique hy).trans (hmj.unique hz).symm + · obtain ⟨y,hy,hz⟩:=nodalVacuum_collision (collisionCopy i j) i (i.succAbove j) hij p + have hmi:=hm i + have hmj:=hm (i.succAbove j) + simp only [hp,ite_false,div_one] at hmi hmj + exact (hmi.unique hy).trans (hmj.unique hz).symm + +lemma nodalDatumL_ordinary_collision {n : ℕ} (W : Pairing n → Laurent n) + (hW:∀ p,evalLaurent (W p)=rationalVacuum n p) (i : Fin (n+1)) (j : Fin n) (p : Pairing (n+2)) : + substituteLaurent i (variableUnit j) (nodalDatumL W i p)= + substituteLaurent i (variableUnit j) (nodalDatumL W (i.succAbove j) p) := by + apply IsFractionRing.injective (SpectralRing n) (SpectralField n) + exact (copyEvaluation_collision i j _).symm.trans + ((nodalDatumL_copy_collision W hW i j p).trans (copyEvaluation_collision i j _)) + + + + + + + +def reflectionUnit {n : ℕ} (j : Fin n) : (Laurent n)ˣ := + (constantUnit n (phase^3) (pow_ne_zero _ phase_ne_zero))⁻¹*(variableUnit j)⁻¹ + +@[simp] lemma reflectionUnit_coe {n : ℕ} (j : Fin n) : + (reflectionUnit j : Laurent n)=monomialL (-variableExponent j) ((phase^3)⁻¹) := by + simp only [reflectionUnit,Units.val_mul,constantUnit_inv_coe,variableUnit_inv_coe, + monomialL_mul,zero_add,mul_one] + +@[simp] lemma reflectionUnit_inv_coe {n : ℕ} (j : Fin n) : + ((reflectionUnit j)⁻¹ : (Laurent n)ˣ).val=monomialL (variableExponent j) (phase^3) := by + simp only [reflectionUnit,mul_inv_rev,inv_inv,Units.val_mul,constantUnit_coe,variableUnit_coe, + monomialL_mul,add_zero,one_mul] + +lemma substitute_reflection_sine {n : ℕ} (i : Fin (n+1)) (j : Fin n) : + substituteLaurent i (reflectionUnit j) + (sineL (variableExponent i+variableExponent (i.succAbove j)) (phase^3))=0 := by + have hrem : Fin.removeNth i (variableExponent i+variableExponent (i.succAbove j))=variableExponent j := by + funext k + simp [Fin.removeNth,variableExponent,Pi.single_apply,Fin.succAbove_ne] + have he : (variableExponent i+variableExponent (i.succAbove j)) i=1 := by + simp [variableExponent,(Fin.succAbove_ne i j).symm] + have hremn : Fin.removeNth i (-(variableExponent i+variableExponent (i.succAbove j)))= -variableExponent j := by + funext k + change -(Fin.removeNth i (variableExponent i+variableExponent (i.succAbove j)) k)=_ + rw [hrem]; rfl + rw [sineL,map_mul] + suffices h : substituteLaurent i (reflectionUnit j) + (monomialL (variableExponent i+variableExponent (i.succAbove j)) (phase^3) - + monomialL (-(variableExponent i+variableExponent (i.succAbove j))) ((phase^3)⁻¹))=0 by + rw [h,zero_mul] + rw [map_sub,substituteLaurent_monomial,substituteLaurent_monomial] + simp only [hrem,hremn,he,Pi.neg_apply,zpow_one,zpow_neg_one,reflectionUnit_coe, + reflectionUnit_inv_coe,monomialL_mul,add_neg_cancel,neg_add_cancel] + apply sub_eq_zero.mpr + congr 1 + field_simp [phase_ne_zero] + +lemma reflectionFactorL_collision_left {n : ℕ} (i : Fin (n+1)) (j : Fin n) : + substituteLaurent i (reflectionUnit j) (reflectionFactorL i (i.succAbove j))=0 := by + rw [reflectionFactorL,ite_eq_right (Fin.succAbove_ne i j)] + exact substitute_reflection_sine i j + +lemma reflectionFactorL_collision_right {n : ℕ} (i : Fin (n+1)) (j : Fin n) : + substituteLaurent i (reflectionUnit j) (reflectionFactorL (i.succAbove j) i)=0 := by + rw [reflectionFactorL,ite_eq_right (Fin.succAbove_ne i j).symm, + add_comm (variableExponent (i.succAbove j)) (variableExponent i)] + exact substitute_reflection_sine i j + +lemma nodalDatumL_reflection {n : ℕ} (W : Pairing n → Laurent n) + (i : Fin (n+1)) (j : Fin n) (p : Pairing (n+2)) : + substituteLaurent i (reflectionUnit j) (nodalDatumL W i p)=0 ∧ + substituteLaurent i (reflectionUnit j) (nodalDatumL W (i.succAbove j) p)=0 := by + have h1 : (∏ l:Fin (n+1),substituteLaurent i (reflectionUnit j) (reflectionFactorL i l))=0 := + Finset.prod_eq_zero (Finset.mem_univ (i.succAbove j)) (reflectionFactorL_collision_left i j) + have h2 : (∏ l:Fin (n+1),substituteLaurent i (reflectionUnit j) (reflectionFactorL (i.succAbove j) l))=0 := + Finset.prod_eq_zero (Finset.mem_univ i) (reflectionFactorL_collision_right i j) + simp only [nodalDatumL,map_mul,map_prod,h1,h2,zero_mul,and_self] + + + + + + + +lemma substituteLaurent_neg_sign_monomial {n : ℕ} (i : Fin (n+1)) (u : (Laurent n)ˣ) + (e : Fin (n+1) → ℤ) (z : ℂ) : + substituteLaurent i (-u) (monomialL e z)=substituteLaurent i u (signLaurent i (monomialL e z)) := by + rw [signLaurent_monomial,substituteLaurent_monomial,substituteLaurent_monomial] + apply IsFractionRing.injective (SpectralRing n) (SpectralField n) + change evalLaurent (_ * _)=evalLaurent (_ * _) + simp only [evalLaurent,map_mul] + rw [←evalLaurent,evalLaurent_monomial_product,←evalLaurent,evalLaurent_unit_zpow, + ←evalLaurent,evalLaurent_monomial_product,←evalLaurent,evalLaurent_unit_zpow] + simp only [Units.val_neg,evalLaurent,map_neg,constF,map_mul,map_zpow₀,map_neg,map_one] + rw [neg_eq_neg_one_mul,mul_zpow] + ring + +lemma substituteLaurent_neg_sign {n : ℕ} (i : Fin (n+1)) (u : (Laurent n)ˣ) (f:Laurent (n+1)) : + substituteLaurent i (-u) f=substituteLaurent i u (signLaurent i f) := by + have h:(substituteLaurent i (-u))=(substituteLaurent i u).comp (signLaurent i) := by + apply AddMonoidAlgebra.ringHom_ext + · intro z + exact substituteLaurent_neg_sign_monomial i u 0 z + · intro e + exact substituteLaurent_neg_sign_monomial i u e 1 + exact DFunLike.congr_fun h f + + + + + + + +lemma nodalDatumL_collision {n : ℕ} (W : Pairing n → Laurent n) + (hW:∀ p,evalLaurent (W p)=rationalVacuum n p) (i : Fin (n+1)) (j : Fin n) + (p : Pairing (n+2)) (k : Fin 4) : + collisionSubstitution i j k (nodalDatumL W i p)= + collisionSubstitution i j k (nodalDatumL W (i.succAbove j) p) := by + have ho:=nodalDatumL_ordinary_collision W hW i j p + have hr:=nodalDatumL_reflection W i j p + fin_cases k + · exact ho + · change substituteLaurent i (-(variableUnit j)) _=substituteLaurent i (-(variableUnit j)) _ + rw [substituteLaurent_neg_sign,substituteLaurent_neg_sign, + nodalDatumL_sign W hW,nodalDatumL_sign W hW] + split_ifs <;> simp only [map_neg,ho] + · exact hr.1.trans hr.2.symm + · change substituteLaurent i (-(reflectionUnit j)) _=substituteLaurent i (-(reflectionUnit j)) _ + rw [substituteLaurent_neg_sign,substituteLaurent_neg_sign, + nodalDatumL_sign W hW,nodalDatumL_sign W hW] + split_ifs <;> simp only [map_neg,hr.1,hr.2] + +lemma interpolationNumerator_collisionSubstitution {n : ℕ} (W : Pairing n → Laurent n) + (hW:∀ p,evalLaurent (W p)=rationalVacuum n p) (i : Fin (n+1)) (j : Fin n) + (p : Pairing (n+2)) (k : Fin 4) (a : Fin (n+1)) : + collisionSubstitution i j k + (interpolationNumerator betaL (fun l => nodalDatumL W l p) a)=0 := by + rw [interpolationNumerator_map] + apply interpolationNumerator_collision _ _ i (i.succAbove j) (Fin.succAbove_ne i j).symm + · rw [collisionSubstitution_beta_self,collisionSubstitution_beta] + simp only [collisionCopy,Fin.insertNth_apply_succAbove,id_eq] + · exact nodalDatumL_collision W hW i j p k + + + + + + + +def upperPairOther {n : ℕ} (e : UpperPair (n+1)) : Fin n := + (Fin.exists_succAbove_eq (ne_of_gt e.property)).choose + +lemma upperPairOther_spec {n : ℕ} (e : UpperPair (n+1)) : + e.val.1.succAbove (upperPairOther e)=e.val.2 := + (Fin.exists_succAbove_eq (ne_of_gt e.property)).choose_spec + +def edgeSubstitution {n : ℕ} (e : UpperPair (n+1)) (k : Fin 4) : + Laurent (n+1) →+* Laurent n := collisionSubstitution e.val.1 (upperPairOther e) k + +lemma edgeSubstitution_kernel {n : ℕ} (e : UpperPair (n+1)) (f : Laurent (n+1)) + (hf:∀ k,edgeSubstitution e k f=0) : (betaL e.val.2-betaL e.val.1) ∣ f := by + obtain ⟨g,hg⟩:=betaL_difference_dvd e.val.1 (upperPairOther e) f hf + rw [upperPairOther_spec] at hg + refine ⟨-g,?_⟩ + rw [hg] + ring + +lemma edgeSubstitution_cross {n : ℕ} (e f : UpperPair (n+1)) (hef:e≠f) (k : Fin 4) : + edgeSubstitution e k (betaL f.val.2-betaL f.val.1)≠0 := by + have he:e.val.1 nodalDatumL W l p) a := by + rw [Matrix.det_vandermonde,←prod_upperPair] + apply prod_dvd_of_evaluation_packets Finset.univ _ edgeSubstitution + · intro e _ f hf + exact edgeSubstitution_kernel e f hf + · intro e _ f _ hef k + exact edgeSubstitution_cross e f hef k + · intro e _ k + exact interpolationNumerator_collisionSubstitution W hW e.val.1 (upperPairOther e) p k a + + + + + + + + + +lemma interpolate_lift_of_vandermonde_dvd {R K : Type*} [CommRing R] [Field K] + (φ : R →+* K) {n : ℕ} (b y : Fin n → R) + (hb : Function.Injective (fun i => φ (b i))) + (hd : ∀ k,(Matrix.vandermonde b).det ∣ interpolationNumerator b y k) : + ∃ P : Polynomial R,P.map φ=Lagrange.interpolate Finset.univ (fun i => φ (b i)) (fun i => φ (y i)) := by + choose q hq using hd + let p:=Lagrange.interpolate Finset.univ (fun i => φ (b i)) (fun i => φ (y i)) + have hdet:φ (Matrix.vandermonde b).det=(Matrix.vandermonde (fun i => φ (b i))).det := by + rw [RingHom.map_det] + congr 1 + ext i j + simp [Matrix.map_apply,Matrix.vandermonde_apply] + have hc (k:Fin n):φ (q k)=p.coeff k := by + have h:=congrArg φ (hq k) + rw [interpolationNumerator_map,map_mul,hdet, + interpolationNumerator_eq_det_mul_coeff _ _ hb] at h + exact mul_left_cancel₀ (Matrix.det_vandermonde_ne_zero_iff.mpr hb) h.symm + refine ⟨Polynomial.ofFn n q,?_⟩ + ext k + rw [Polynomial.coeff_map] + by_cases hk:k φ (y i)) hb.injOn + simp only [Finset.card_univ,Fintype.card_fin] at hp + exact hp.trans_le (by exact_mod_cast (show n≤k by omega)) + +lemma nodalLow_laurent {n : ℕ} (W : Pairing n → Laurent n) + (hW:∀ p,evalLaurent (W p)=rationalVacuum n p) (p : Pairing (n+2)) : + ∃ P : Polynomial (Laurent (n+1)),P.map (algebraMap (SpectralRing (n+1)) (SpectralField (n+1)))= + Lagrange.interpolate Finset.univ deletionBeta + (fun i => nodalVacuum i p/(if p.Occupied (Fin.last (n+1)) then torusSin (deletionNode i) else 1)) := by + have hbmap (i:Fin (n+1)) : (algebraMap (SpectralRing (n+1)) (SpectralField (n+1))) (betaL i)=deletionBeta i := betaL_map i + have hdmap (i:Fin (n+1)) : (algebraMap (SpectralRing (n+1)) (SpectralField (n+1))) (nodalDatumL W i p)= + nodalVacuum i p/(if p.Occupied (Fin.last (n+1)) then torusSin (deletionNode i) else 1) := nodalDatumL_map W hW i p + have hh:=interpolate_lift_of_vandermonde_dvd + (algebraMap (SpectralRing (n+1)) (SpectralField (n+1))) + betaL (fun i => nodalDatumL W i p) + (by simpa only [hbmap] using deletionBeta_injective (n+1)) + (nodal_vandermonde_dvd W hW p) + simpa only [hbmap,hdmap] using hh + +lemma rationalNodalPolynomial_laurent {n : ℕ} + (W : Pairing n → Laurent n) (V : Pairing (n+1) → Laurent (n+1)) + (hW:∀ p,evalLaurent (W p)=rationalVacuum n p) + (hV:∀ p,evalLaurent (V p)=rationalVacuum (n+1) p) (p:Pairing (n+2)) : + ∃ P : Polynomial (Laurent (n+1)),P.map (algebraMap (SpectralRing (n+1)) (SpectralField (n+1)))= + rationalNodalPolynomial (n+1) p := by + obtain ⟨P,hP⟩:=nodalLow_laurent W hW p + by_cases hp:p.Occupied (Fin.last (n+1)) + · refine ⟨P,?_⟩ + simpa only [rationalNodalPolynomial,hp,ite_true] using hP + · refine ⟨Polynomial.C (V (p.restrict Fin.castSuccOrderEmb))*Lagrange.nodal Finset.univ betaL+P,?_⟩ + simp only [rationalNodalPolynomial,hp,ite_false,Polynomial.map_add,Polynomial.map_mul, + Polynomial.map_C,hP,div_one] + rw [show (algebraMap (SpectralRing (n+1)) (SpectralField (n+1))) (V (p.restrict Fin.castSuccOrderEmb))= + rationalVacuum (n+1) (p.restrict Fin.castSuccOrderEmb) from hV _] + congr 2 + have hbmap (i:Fin (n+1)) : (algebraMap (SpectralRing (n+1)) (SpectralField (n+1))) (betaL i)=deletionBeta i := betaL_map i + simp only [Lagrange.nodal,Polynomial.map_prod,Polynomial.map_sub,Polynomial.map_X, + Polynomial.map_C,hbmap] + + + + + + + +def PolynomialBox {n:ℕ} (P:Polynomial (Laurent n)) (b:Fin n → ℕ) : Prop := + ∀ k,LaurentBox (P.coeff k) b + +lemma PolynomialBox.mono {n:ℕ} {P:Polynomial (Laurent n)} {a b:Fin n → ℕ} + (hP:PolynomialBox P a) (hab:∀ i,a i≤b i) : PolynomialBox P b := fun k => (hP k).mono hab +lemma PolynomialBox.zero {n:ℕ} (b:Fin n → ℕ) : PolynomialBox (0:Polynomial (Laurent n)) b := by + intro k + rw [Polynomial.coeff_zero] + exact LaurentBox.zero _ +lemma PolynomialBox.C {n:ℕ} {f:Laurent n} {b:Fin n → ℕ} (hf:LaurentBox f b) : + PolynomialBox (Polynomial.C f) b := by + intro k + by_cases hk:k=0 + · subst k; simpa only [Polynomial.coeff_C_zero] using hf + · rw [Polynomial.coeff_C,ite_eq_right hk] + exact LaurentBox.zero _ +lemma PolynomialBox.X {n:ℕ} : PolynomialBox (Polynomial.X:Polynomial (Laurent n)) 0 := by + intro k + rw [Polynomial.coeff_X] + split_ifs + · exact LaurentBox.one + · exact LaurentBox.zero _ +lemma PolynomialBox.add {n:ℕ} {P Q:Polynomial (Laurent n)} {b:Fin n → ℕ} + (hP:PolynomialBox P b) (hQ:PolynomialBox Q b) : PolynomialBox (P+Q) b := by + intro k; rw [Polynomial.coeff_add]; exact (hP k).add (hQ k) +lemma PolynomialBox.sub {n:ℕ} {P Q:Polynomial (Laurent n)} {b:Fin n → ℕ} + (hP:PolynomialBox P b) (hQ:PolynomialBox Q b) : PolynomialBox (P-Q) b := by + intro k; rw [Polynomial.coeff_sub]; exact (hP k).sub (hQ k) +lemma PolynomialBox.mul {n:ℕ} {P Q:Polynomial (Laurent n)} {a b:Fin n → ℕ} + (hP:PolynomialBox P a) (hQ:PolynomialBox Q b) : PolynomialBox (P*Q) (a+b) := by + intro k + rw [Polynomial.coeff_mul] + exact LaurentBox.sum _ _ _ (fun ij _ => (hP ij.1).mul (hQ ij.2)) +lemma PolynomialBox.one {n:ℕ} : PolynomialBox (1:Polynomial (Laurent n)) 0 := by + simpa only [Polynomial.C_1] using (PolynomialBox.C (n:=n) LaurentBox.one) +lemma PolynomialBox.prod {n:ℕ} {ι:Type*} (s:Finset ι) (P:ι → Polynomial (Laurent n)) + (b:ι → Fin n → ℕ) (h:∀ i∈s,PolynomialBox (P i) (b i)) : + PolynomialBox (∏ i∈s,P i) (∑ i∈s,b i) := by + induction s using Finset.induction_on with + | empty => simpa only [Finset.prod_empty,Finset.sum_empty] using PolynomialBox.one + | @insert i s hi ih => + rw [Finset.prod_insert hi,Finset.sum_insert hi] + exact (h i (Finset.mem_insert_self _ _)).mul (ih (fun j hj => h j (Finset.mem_insert_of_mem hj))) + +end + + + + + +noncomputable section +open scoped Classical LaurentPolynomial + +lemma nodalLow_laurent_box {n:ℕ} (W:Pairing n → Laurent n) + (hW:∀ p,evalLaurent (W p)=rationalVacuum n p) + (hb:∀ p,LaurentBox (W p) (fun _ => 2*n-2)) (p:Pairing (n+2)) : + ∃ P:Polynomial (Laurent (n+1)), + P.map (algebraMap (SpectralRing (n+1)) (SpectralField (n+1)))= + Lagrange.interpolate Finset.univ deletionBeta + (fun i => nodalVacuum i p/(if p.Occupied (Fin.last (n+1)) then torusSin (deletionNode i) else 1)) ∧ + PolynomialBox P (fun _ => 2*n+2) := by + let φ:=algebraMap (SpectralRing (n+1)) (SpectralField (n+1)) + obtain ⟨P,hP⟩:=nodalLow_laurent W hW p + refine ⟨P,hP,?_⟩ + intro a + have hcoef:φ (P.coeff a)= + (Lagrange.interpolate Finset.univ deletionBeta + (fun i => nodalVacuum i p/(if p.Occupied (Fin.last (n+1)) then torusSin (deletionNode i) else 1))).coeff a := by + rw [←hP,Polynomial.coeff_map] + by_cases ha:a nodalDatumL W i p) ⟨a,ha⟩= + (Matrix.vandermonde (@betaL (n+1))).det*P.coeff a := by + apply IsFractionRing.injective (SpectralRing (n+1)) (SpectralField (n+1)) + rw [map_mul,hcoef,interpolationNumerator_map,RingHom.map_det] + have hbmap (i:Fin (n+1)):φ (betaL i)=deletionBeta i := betaL_map i + have hdmap (i:Fin (n+1)):φ (nodalDatumL W i p)= + nodalVacuum i p/(if p.Occupied (Fin.last (n+1)) then torusSin (deletionNode i) else 1) := + nodalDatumL_map W hW i p + change interpolationNumerator (fun i => φ (betaL i)) (fun i => φ (nodalDatumL W i p)) ⟨a,ha⟩=_ + simp only [hbmap,hdmap] + rw [interpolationNumerator_eq_det_mul_coeff _ _ (deletionBeta_injective (n+1))] + congr 2 + ext i j + change deletionBeta i ^ j.val=φ (betaL i ^ j.val) + rw [map_pow,hbmap] + apply LaurentBox.of_peel + intro k + have hn:LaurentInterval (peelLaurent k (P.coeff a)*peelLaurent k (Matrix.vandermonde (@betaL (n+1))).det) + (-(4*n+2:ℤ)) (4*n+2) := by + have hh:=(interpolationNumerator_box W hb p ⟨a,ha⟩).peel k + rw [he,map_mul,mul_comm] at hh + simpa only [Nat.cast_add,Nat.cast_mul,Nat.cast_ofNat] using hh + obtain ⟨hg,hlo,hhi⟩:=vandermonde_beta_exact k + have hq:=hn.quotient hg hlo hhi + convert hq using 1 <;> push_cast <;> ring + · have he:P.coeff a=0 := by + apply IsFractionRing.injective (SpectralRing (n+1)) (SpectralField (n+1)) + rw [hcoef,map_zero] + apply Polynomial.coeff_eq_zero_of_degree_lt + have hh:=Lagrange.degree_interpolate_lt (s:=Finset.univ) + (fun i => nodalVacuum i p/(if p.Occupied (Fin.last (n+1)) then torusSin (deletionNode i) else 1)) + (deletionBeta_injective (n+1)).injOn + simp only [Finset.card_univ,Fintype.card_fin] at hh + exact hh.trans_le (by exact_mod_cast (show n+1≤a by omega)) + rw [he] + exact LaurentBox.zero _ + +end + + + + + +noncomputable section +open scoped Classical + +lemma nodal_betaL_box {n:ℕ} : PolynomialBox (Lagrange.nodal Finset.univ (@betaL n)) (fun _ => 2) := by + unfold Lagrange.nodal + have h:=PolynomialBox.prod Finset.univ + (fun i:Fin n => Polynomial.X-Polynomial.C (betaL i)) (fun i => selfBound i 2) + (fun i _ => (PolynomialBox.X.mono (fun k => Nat.zero_le _)).sub (PolynomialBox.C (betaL_box i))) + convert h using 1 + funext k + simp only [Finset.sum_apply,selfBound,Finset.sum_ite_eq,Finset.mem_univ,ite_true] + + + +lemma rationalNodalPolynomial_laurent_box {n:ℕ} + (W:Pairing n → Laurent n) (V:Pairing (n+1) → Laurent (n+1)) + (hW:∀ p,evalLaurent (W p)=rationalVacuum n p) + (hV:∀ p,evalLaurent (V p)=rationalVacuum (n+1) p) + (bW:∀ p,LaurentBox (W p) (fun _ => 2*n-2)) + (bV:∀ p,LaurentBox (V p) (fun _ => 2*n)) (p:Pairing (n+2)) : + ∃ P:Polynomial (Laurent (n+1)), + P.map (algebraMap (SpectralRing (n+1)) (SpectralField (n+1)))=rationalNodalPolynomial (n+1) p ∧ + PolynomialBox P (fun _ => 2*n+2) := by + obtain ⟨P,hP,bP⟩:=nodalLow_laurent_box W hW bW p + by_cases hp:p.Occupied (Fin.last (n+1)) + · refine ⟨P,?_,bP⟩ + simpa only [rationalNodalPolynomial,hp,ite_true] using hP + · refine ⟨Polynomial.C (V (p.restrict Fin.castSuccOrderEmb))*Lagrange.nodal Finset.univ betaL+P,?_,?_⟩ + · simp only [rationalNodalPolynomial,hp,ite_false,Polynomial.map_add,Polynomial.map_mul, + Polynomial.map_C,hP,div_one] + rw [show (algebraMap (SpectralRing (n+1)) (SpectralField (n+1))) (V (p.restrict Fin.castSuccOrderEmb))= + rationalVacuum (n+1) (p.restrict Fin.castSuccOrderEmb) from hV _] + congr 2 + have hbmap (i:Fin (n+1)) : (algebraMap (SpectralRing (n+1)) (SpectralField (n+1))) (betaL i)=deletionBeta i := betaL_map i + simp only [Lagrange.nodal,Polynomial.map_prod,Polynomial.map_sub,Polynomial.map_X, + Polynomial.map_C,hbmap] + · exact ((PolynomialBox.C (bV _)).mul nodal_betaL_box).add bP + +end +end CriticalStrip.Diagram + +end OAI diff --git a/lean/OAI/Combinatorics/StripMass/ColumnGeometry.lean b/lean/OAI/Combinatorics/StripMass/ColumnGeometry.lean new file mode 100644 index 0000000000000000000000000000000000000000..618c2ea7071a0e39182b96ea51f59b1e86b841d3 --- /dev/null +++ b/lean/OAI/Combinatorics/StripMass/ColumnGeometry.lean @@ -0,0 +1,416 @@ +import Mathlib +import OAI.Combinatorics.StripMass.HeightOne + +namespace OAI + +/-! Critical honeycomb strip paths, polynomial identities and crossing mass. -/ + + +namespace CriticalStrip +noncomputable section +open scoped BigOperators +theorem columnVertex_adjacent (k : ℕ) : adjacent (columnVertex k) (columnVertex (k + 1)) := by + simp only [columnVertex] + split_ifs <;> simp [adjacent, upDownAdjacent, up, down] <;> omega + + +def diagonalBridge (N : ℕ) : List Triangle := (List.range (2 * N)).map columnVertex + +@[simp] theorem diagonalBridge_length (N : ℕ) : (diagonalBridge N).length = 2 * N := by + simp [diagonalBridge] + +theorem diagonalBridge_spec {N : ℕ} (hN : 0 < N) : + IsPath N (down 0 (N - 1)) (diagonalBridge N) := by + have h2N : 2 * N ≠ 0 := by omega + have hl : columnVertex (2 * N - 1) = down 0 (N - 1) := by + have he : (2 * N - 1) % 2 ≠ 0 := by omega + have hd : (2 * N - 1) / 2 = N - 1 := by omega + simp [columnVertex, he, hd] + refine ⟨?_, ?_, ?_, ?_, ?_⟩ + · simp [diagonalBridge, List.head?_map, List.head?_range, h2N, columnVertex] + · simp [diagonalBridge, List.getLast?_map, List.getLast?_range, h2N, hl] + · exact List.nodup_range.map columnVertex_injective + · apply (List.isChain_map _).mpr + apply (List.isChain_range _ _).mpr + intro k hk + exact columnVertex_adjacent k + · intro v hv + obtain ⟨k, hk, rfl⟩ := List.mem_map.mp hv + simp only [List.mem_range] at hk + simp only [columnVertex_band] + omega + +theorem diagonalBridge_weight {N : ℕ} (hN : 0 < N) : + bridgeWeight N 0 (diagonalBridge N) = rho ^ (2 * N) := by + classical + simp only [bridgeWeight, hN, diagonalBridge_spec hN, and_self, ↓reduceIte, + diagonalBridge_length] + + + +theorem bridgeMass_lower_bound {N : ℕ} (hN : 1 ≤ N) (hf : StripSumsFinite N) : + rho ^ (2 * N) ≤ bridgeMass N := by + calc + rho ^ (2 * N) = bridgeWeight N 0 (diagonalBridge N) := (diagonalBridge_weight (by omega)).symm + _ ≤ bridgeKernel N 0 := (hf.2.1 0).le_tsum (diagonalBridge N) (by + intro p hp + exact bridgeWeight_nonneg N 0 p) + _ ≤ bridgeMass N := hf.2.2.2.1.le_tsum 0 (by + intro k hk + exact bridgeKernel_nonneg N k) + +theorem bridgeMass_pos_of_finite {N : ℕ} (hN : 1 ≤ N) (hf : StripSumsFinite N) : + 0 < bridgeMass N := lt_of_lt_of_le (pow_pos rho_pos _) (bridgeMass_lower_bound hN hf) + +theorem moment_lower_bound {N : ℕ} (hN : 1 ≤ N) (hf : StripSumsFinite N) : + rho ^ 3 / (1 - rho ^ 2) ^ 2 ≤ moment N := by + rw [← moment_one] + exact moment_le_of_finite hN hf + +theorem moment_pos_of_finite {N : ℕ} (hN : 1 ≤ N) (hf : StripSumsFinite N) : + 0 < moment N := by + apply lt_of_lt_of_le _ (moment_lower_bound hN hf) + exact div_pos (pow_pos rho_pos _) (sq_pos_of_pos (sub_pos.mpr rho_sq_lt_one)) + +end + + + +noncomputable section +open scoped BigOperators +open Set MeasureTheory + + +def laguerreDomain (N : ℕ) : Set (Fin N → ℝ) := + {r | StrictMono r ∧ ∀ i, 0 < r i} + +def laguerreWeight (a x : ℝ) : ℝ := x ^ (a - 1) * Real.exp (-x) + +def laguerreDensity (N : ℕ) (a : ℝ) (r : Fin N → ℝ) : ℝ := + (∏ i, laguerreWeight a (r i)) * + ∏ i, ∏ j ∈ Finset.Ioi i, pairKernel (r i) (r j) + +def laguerreNormalizer (N : ℕ) (a : ℝ) : ℝ := + ∫ r in laguerreDomain N, laguerreDensity N a r + +def laguerreExpectation (N : ℕ) (a : ℝ) (f : (Fin N → ℝ) → ℝ) : ℝ := + (∫ r in laguerreDomain N, f r * laguerreDensity N a r) / laguerreNormalizer N a + +theorem laguerreWeight_pos (a : ℝ) {x : ℝ} (hx : 0 < x) : + 0 < laguerreWeight a x := + mul_pos (Real.rpow_pos_of_pos hx _) (Real.exp_pos _) + +theorem measurable_laguerreWeight (a : ℝ) : Measurable (laguerreWeight a) := by + unfold laguerreWeight + fun_prop + +theorem laguerreDensity_pos {N : ℕ} (a : ℝ) {r : Fin N → ℝ} + (hr : r ∈ laguerreDomain N) : 0 < laguerreDensity N a r := by + apply mul_pos + · exact Finset.prod_pos fun i _ => laguerreWeight_pos a (hr.2 i) + · apply Finset.prod_pos + intro i _ + apply Finset.prod_pos + intro j hj + exact pairKernel_pos (hr.2 i) (hr.1 (Finset.mem_Ioi.1 hj)) + +theorem measurable_laguerreDensity (N : ℕ) (a : ℝ) : + Measurable (laguerreDensity N a) := by + unfold laguerreDensity pairKernel + apply Measurable.mul + · exact Finset.measurable_prod _ fun i _ => + (measurable_laguerreWeight a).comp (measurable_pi_apply i) + · apply Finset.measurable_prod + intro i _ + apply Finset.measurable_prod + intro j _ + fun_prop + +theorem isOpen_laguerreDomain (N : ℕ) : IsOpen (laguerreDomain N) := by + have heq : laguerreDomain N = + (⋂ i : Fin N, ⋂ j : Fin N, ⋂ (_ : i < j), {r | r i < r j}) ∩ + (⋂ i : Fin N, {r | 0 < r i}) := by + ext r + simp only [laguerreDomain, mem_ofPred_eq, mem_inter_iff, mem_iInter, StrictMono] + rw [heq] + apply IsOpen.inter + · apply isOpen_iInter_of_finite + intro i + apply isOpen_iInter_of_finite + intro j + apply isOpen_iInter_of_finite + intro _ + exact isOpen_lt (continuous_apply i) (continuous_apply j) + · exact isOpen_iInter_of_finite fun i => + isOpen_lt continuous_const (continuous_apply i) + +theorem laguerreDomain_nonempty (N : ℕ) : (laguerreDomain N).Nonempty := by + refine ⟨fun i => (i : ℝ) + 1, ?_, ?_⟩ + · intro i j hij + dsimp + exact_mod_cast (show i.val + 1 < j.val + 1 by omega) + · intro i + positivity + +theorem pairKernel_le_right {x y : ℝ} (hx : 0 ≤ x) (hy : 0 < y) (hxy : x ≤ y) : + pairKernel x y ≤ y := by + unfold pairKernel + apply (div_le_iff₀ (by linarith : 0 < y + x)).2 + have hxx := mul_le_mul_of_nonneg_left hxy hx + nlinarith [mul_nonneg hx hy.le] + +theorem prod_pair_right (N : ℕ) (r : Fin N → ℝ) : + (∏ i, ∏ j ∈ Finset.Ioi i, r j) = ∏ j, r j ^ j.val := by + classical + calc + (∏ i, ∏ j ∈ Finset.Ioi i, r j) = + ∏ i, ∏ j : Fin N, if i < j then r j else 1 := by + apply Finset.prod_congr rfl + intro i _ + rw [← Finset.prod_filter] + congr 1 + ext j + simp + _ = ∏ j : Fin N, ∏ i : Fin N, if i < j then r j else 1 := Finset.prod_comm + _ = ∏ j : Fin N, r j ^ j.val := by + apply Finset.prod_congr rfl + intro j _ + rw [← Finset.prod_filter] + simp [show Finset.univ.filter (fun i : Fin N => i < j) = Finset.Iio j by ext; simp] + +theorem laguerreDensity_le_product {N : ℕ} (a : ℝ) {r : Fin N → ℝ} + (hr : r ∈ laguerreDomain N) : + laguerreDensity N a r ≤ ∏ i, laguerreWeight (a + i.val) (r i) := by + have hp : (∏ i, ∏ j ∈ Finset.Ioi i, pairKernel (r i) (r j)) ≤ + ∏ i, ∏ j ∈ Finset.Ioi i, r j := by + apply Finset.prod_le_prod₀ + · intro i _ + exact Finset.prod_nonneg fun j _ => pairKernel_nonneg (hr.2 i).le (hr.2 j).le + · intro i _ + apply Finset.prod_le_prod₀ + · intro j _ + exact pairKernel_nonneg (hr.2 i).le (hr.2 j).le + · intro j hj + exact pairKernel_le_right (hr.2 i).le (hr.2 j) (hr.1 (Finset.mem_Ioi.1 hj)).le + rw [prod_pair_right] at hp + calc + laguerreDensity N a r ≤ (∏ i, laguerreWeight a (r i)) * ∏ i, r i ^ i.val := + mul_le_mul_of_nonneg_left hp (Finset.prod_nonneg fun i _ => (laguerreWeight_pos a (hr.2 i)).le) + _ = ∏ i, laguerreWeight (a + i.val) (r i) := by + rw [← Finset.prod_mul_distrib] + apply Finset.prod_congr rfl + intro i _ + unfold laguerreWeight + rw [show a + (i.val : ℝ) - 1 = (a - 1) + (i.val : ℝ) by ring, + Real.rpow_add (hr.2 i), Real.rpow_natCast] + ring + +theorem integrableOn_laguerreWeight {a : ℝ} (ha : 0 < a) : + IntegrableOn (laguerreWeight a) (Ioi 0) := by + change IntegrableOn (fun x : ℝ => x ^ (a - 1) * Real.exp (-x)) (Ioi 0) + simpa only [mul_comm] using Real.GammaIntegral_convergent ha + +theorem integral_laguerreWeight {a : ℝ} (ha : 0 < a) : + (∫ x in Ioi 0, laguerreWeight a x) = Real.Gamma a := by + simpa only [laguerreWeight, mul_comm] using (Real.Gamma_eq_integral ha).symm + +theorem integrableOn_laguerre_product {N : ℕ} {a : ℝ} (ha : 0 < a) : + IntegrableOn (fun r : Fin N → ℝ => ∏ i, laguerreWeight (a + i.val) (r i)) + (Set.univ.pi fun _ : Fin N => Ioi (0 : ℝ)) := by + unfold IntegrableOn + rw [volume_pi, Measure.restrict_pi_pi] + exact Integrable.fintype_prod fun i => + integrableOn_laguerreWeight (by positivity : 0 < a + (i.val : ℝ)) + +theorem integrableOn_laguerreDensity (N : ℕ) {a : ℝ} (ha : 0 < a) : + IntegrableOn (laguerreDensity N a) (laguerreDomain N) := by + have hp := (integrableOn_laguerre_product (N := N) ha).mono_set + (show laguerreDomain N ⊆ Set.univ.pi (fun _ : Fin N => Ioi (0 : ℝ)) from + fun r hr i _ => hr.2 i) + apply hp.mono' (measurable_laguerreDensity N a).aestronglyMeasurable + filter_upwards [ae_restrict_mem (isOpen_laguerreDomain N).measurableSet] with r hr + simpa only [Real.norm_eq_abs, abs_of_pos (laguerreDensity_pos a hr)] using + laguerreDensity_le_product a hr + +theorem laguerreNormalizer_pos (N : ℕ) {a : ℝ} (ha : 0 < a) : + 0 < laguerreNormalizer N a := by + have hpos : 0 ≤ᵐ[volume.restrict (laguerreDomain N)] laguerreDensity N a := by + filter_upwards [ae_restrict_mem (isOpen_laguerreDomain N).measurableSet] with r hr + exact (laguerreDensity_pos a hr).le + apply (integral_pos_iff_support_of_nonneg_ae hpos (integrableOn_laguerreDensity N ha)).2 + have hs : laguerreDomain N ⊆ Function.support (laguerreDensity N a) := + fun r hr => (laguerreDensity_pos a hr).ne' + calc + 0 < volume (laguerreDomain N) := + (isOpen_laguerreDomain N).measure_pos volume (laguerreDomain_nonempty N) + _ = (volume.restrict (laguerreDomain N)) (laguerreDomain N) := + (Measure.restrict_apply_self _ _).symm + _ ≤ (volume.restrict (laguerreDomain N)) (Function.support (laguerreDensity N a)) := + measure_mono hs + +theorem integral_laguerre_product (N : ℕ) {a : ℝ} (ha : 0 < a) : + (∫ r : Fin N → ℝ in Set.univ.pi (fun _ => Ioi 0), + ∏ i, laguerreWeight (a + i.val) (r i)) = ∏ i : Fin N, Real.Gamma (a + i.val) := by + rw [volume_pi, Measure.restrict_pi_pi, integral_fintype_prod_eq_prod] + apply Finset.prod_congr rfl + intro i _ + exact integral_laguerreWeight (by positivity) + +theorem laguerreNormalizer_le_gamma_product (N : ℕ) {a : ℝ} (ha : 0 < a) : + laguerreNormalizer N a ≤ ∏ i : Fin N, Real.Gamma (a + i.val) := by + have hs : laguerreDomain N ⊆ Set.univ.pi (fun _ : Fin N => Ioi (0 : ℝ)) := + fun r hr i _ => hr.2 i + have hprod := integrableOn_laguerre_product (N := N) ha + calc + laguerreNormalizer N a ≤ ∫ r in laguerreDomain N, + ∏ i, laguerreWeight (a + i.val) (r i) := by + apply integral_mono_ae (integrableOn_laguerreDensity N ha) (hprod.mono_set hs) + filter_upwards [ae_restrict_mem (isOpen_laguerreDomain N).measurableSet] with r hr + exact laguerreDensity_le_product a hr + _ ≤ ∫ r : Fin N → ℝ in Set.univ.pi (fun _ => Ioi 0), + ∏ i, laguerreWeight (a + i.val) (r i) := by + apply setIntegral_mono_set hprod ?_ (Filter.Eventually.of_forall hs) + filter_upwards [ae_restrict_mem (MeasurableSet.univ_pi fun _ => measurableSet_Ioi)] with r hr + exact Finset.prod_nonneg fun i _ => (laguerreWeight_pos _ (hr i (mem_univ i))).le + _ = ∏ i : Fin N, Real.Gamma (a + i.val) := integral_laguerre_product N ha + + + +theorem integrableOn_laguerre_inverse_coordinate {N : ℕ} {a p : ℝ} + (ha : 0 < a) (i : Fin N) (hp : p < a + i.val) : + IntegrableOn (fun r => (r i) ^ (-p) * laguerreDensity N a r) (laguerreDomain N) := by + classical + let b : Fin N → ℝ := fun j => a + j.val - if j = i then p else 0 + have hb : ∀ j, 0 < b j := by + intro j + by_cases hj : j = i + · simpa [b, hj] using sub_pos.mpr hp + · simp only [b, hj, ite_false, sub_zero] + positivity + have heq : ∀ r : Fin N → ℝ, (∀ j, 0 < r j) → + (r i) ^ (-p) * (∏ j, laguerreWeight (a + j.val) (r j)) = + ∏ j, laguerreWeight (b j) (r j) := by + intro r hr + calc + _ = (∏ j, if j = i then (r j) ^ (-p) else 1) * + ∏ j, laguerreWeight (a + j.val) (r j) := by simp + _ = ∏ j, (if j = i then (r j) ^ (-p) else 1) * + laguerreWeight (a + j.val) (r j) := (Finset.prod_mul_distrib).symm + _ = _ := by + apply Finset.prod_congr rfl + intro j _ + by_cases hj : j = i + · simp only [b, hj, ite_true, laguerreWeight] + rw [show a + (i.val : ℝ) - p - 1 = -p + (a + i.val - 1) by ring, + Real.rpow_add (hr i)] + ring + · simp [b, hj] + have hi : IntegrableOn (fun r : Fin N → ℝ => ∏ j, laguerreWeight (b j) (r j)) + (Set.univ.pi fun _ : Fin N => Ioi (0 : ℝ)) := by + unfold IntegrableOn + rw [volume_pi, Measure.restrict_pi_pi] + exact Integrable.fintype_prod fun j => integrableOn_laguerreWeight (hb j) + have hs : laguerreDomain N ⊆ Set.univ.pi (fun _ : Fin N => Ioi (0 : ℝ)) := + fun r hr j _ => hr.2 j + apply (hi.mono_set hs).mono' + (((measurable_pi_apply i).pow_const _).mul (measurable_laguerreDensity N a)).aestronglyMeasurable + filter_upwards [ae_restrict_mem (isOpen_laguerreDomain N).measurableSet] with r hr + change ‖(r i) ^ (-p) * laguerreDensity N a r‖ ≤ _ + rw [Real.norm_eq_abs, abs_of_nonneg (mul_nonneg (Real.rpow_pos_of_pos (hr.2 i) _).le + (laguerreDensity_pos a hr).le), + ← heq r hr.2] + exact mul_le_mul_of_nonneg_left (laguerreDensity_le_product a hr) + (Real.rpow_pos_of_pos (hr.2 i) _).le + + + +theorem integrableOn_laguerre_inverseQuarterSum {N : ℕ} {a : ℝ} (ha : 1 / 4 < a) : + IntegrableOn (fun r : Fin N → ℝ => (∑ i, (r i)⁻¹) ^ (1 / 4 : ℝ) * + laguerreDensity N a r) (laguerreDomain N) := by + have hi : IntegrableOn (fun r : Fin N → ℝ => + ∑ i, (r i) ^ (-(1 / 4 : ℝ)) * laguerreDensity N a r) (laguerreDomain N) := + integrable_finsetSum _ fun i _ => + integrableOn_laguerre_inverse_coordinate (by linarith : 0 < a) i + (by + have h : (0 : ℝ) ≤ i.val := by positivity + linarith) + have hm : Measurable (fun r : Fin N → ℝ => + (∑ i, (r i)⁻¹) ^ (1 / 4 : ℝ) * laguerreDensity N a r) := by + apply Measurable.mul _ (measurable_laguerreDensity N a) + fun_prop + apply hi.mono' hm.aestronglyMeasurable + filter_upwards [ae_restrict_mem (isOpen_laguerreDomain N).measurableSet] with r hr + have hh : 0 ≤ ∑ i : Fin N, (r i)⁻¹ := Finset.sum_nonneg fun i _ => (inv_pos.mpr (hr.2 i)).le + rw [Real.norm_eq_abs, abs_of_nonneg (mul_nonneg (Real.rpow_nonneg hh _) + (laguerreDensity_pos a hr).le), ← Finset.sum_mul] + apply mul_le_mul_of_nonneg_right _ (laguerreDensity_pos a hr).le + calc + (∑ i : Fin N, (r i)⁻¹) ^ (1 / 4 : ℝ) ≤ ∑ i : Fin N, ((r i)⁻¹) ^ (1 / 4 : ℝ) := + fourthRoot_sum_le_sum _ _ (fun i _ => (inv_pos.mpr (hr.2 i)).le) + _ = ∑ i : Fin N, (r i) ^ (-(1 / 4 : ℝ)) := by + apply Finset.sum_congr rfl + intro i _ + rw [Real.inv_rpow (hr.2 i).le, Real.rpow_neg (hr.2 i).le] + + + +def laguerreLaw (N : ℕ) (a : ℝ) : Measure (Fin N → ℝ) := + (ENNReal.ofReal (laguerreNormalizer N a))⁻¹ • + (volume.restrict (laguerreDomain N)).withDensity + (fun r => ENNReal.ofReal (laguerreDensity N a r)) + +theorem laguerreLaw_isProbabilityMeasure (N : ℕ) {a : ℝ} (ha : 0 < a) : + IsProbabilityMeasure (laguerreLaw N a) := by + refine ⟨?_⟩ + rw [laguerreLaw, Measure.smul_apply, smul_eq_mul, withDensity_apply _ MeasurableSet.univ, + Measure.restrict_univ, ← ofReal_integral_eq_lintegral_ofReal (integrableOn_laguerreDensity N ha)] + · exact ENNReal.inv_mul_cancel (ENNReal.ofReal_pos.mpr (laguerreNormalizer_pos N ha)).ne' + ENNReal.ofReal_ne_top + · filter_upwards [ae_restrict_mem (isOpen_laguerreDomain N).measurableSet] with r hr + exact (laguerreDensity_pos a hr).le + +theorem ae_laguerreDomain (N : ℕ) (a : ℝ) : + ∀ᵐ r ∂laguerreLaw N a, r ∈ laguerreDomain N := by + apply Measure.ae_smul_measure + apply (ae_withDensity_iff (measurable_laguerreDensity N a).ennreal_ofReal).2 + filter_upwards [ae_restrict_mem (isOpen_laguerreDomain N).measurableSet] with r hr + exact fun _ => hr + +theorem integral_laguerreLaw (N : ℕ) {a : ℝ} (ha : 0 < a) (f : (Fin N → ℝ) → ℝ) : + (∫ r, f r ∂laguerreLaw N a) = laguerreExpectation N a f := by + rw [laguerreLaw, integral_smul_measure, + integral_withDensity_eq_integral_toReal_smul (measurable_laguerreDensity N a).ennreal_ofReal + (Filter.Eventually.of_forall fun _ => ENNReal.ofReal_lt_top)] + simp only [ENNReal.toReal_inv, ENNReal.toReal_ofReal (laguerreNormalizer_pos N ha).le, + smul_eq_mul, laguerreExpectation, div_eq_mul_inv] + rw [mul_comm] + congr 1 + apply integral_congr_ae + filter_upwards [ae_restrict_mem (isOpen_laguerreDomain N).measurableSet] with r hr + rw [ENNReal.toReal_ofReal (laguerreDensity_pos a hr).le, mul_comm] + +theorem integrable_laguerreLaw {N : ℕ} {a : ℝ} (ha : 0 < a) + {f : (Fin N → ℝ) → ℝ} + (hf : IntegrableOn (fun r => f r * laguerreDensity N a r) (laguerreDomain N)) : + Integrable f (laguerreLaw N a) := by + apply Integrable.smul_measure (c := (ENNReal.ofReal (laguerreNormalizer N a))⁻¹) ?_ + (by simp [laguerreNormalizer_pos N ha]) + apply (integrable_withDensity_iff_integrable_smul' (measurable_laguerreDensity N a).ennreal_ofReal + (Filter.Eventually.of_forall fun _ => ENNReal.ofReal_lt_top)).2 + apply hf.congr + filter_upwards [ae_restrict_mem (isOpen_laguerreDomain N).measurableSet] with r hr + simp only [smul_eq_mul, ENNReal.toReal_ofReal (laguerreDensity_pos a hr).le, mul_comm] + +theorem integrable_laguerreLaw_inverse_coordinate {N : ℕ} {a p : ℝ} + (ha : 0 < a) (i : Fin N) (hp : p < a + i.val) : + Integrable (fun r => (r i) ^ (-p)) (laguerreLaw N a) := + integrable_laguerreLaw ha (integrableOn_laguerre_inverse_coordinate ha i hp) + +theorem integrable_laguerreLaw_inverseQuarterSum {N : ℕ} {a : ℝ} (ha : 1 / 4 < a) : + Integrable (fun r : Fin N → ℝ => (∑ i, (r i)⁻¹) ^ (1 / 4 : ℝ)) (laguerreLaw N a) := + integrable_laguerreLaw (by linarith) (integrableOn_laguerre_inverseQuarterSum ha) + +end +end CriticalStrip + +end OAI diff --git a/lean/OAI/Combinatorics/StripMass/ColumnSew.lean b/lean/OAI/Combinatorics/StripMass/ColumnSew.lean new file mode 100644 index 0000000000000000000000000000000000000000..737db28b9311a6e3e583b3e24ef6472f8ed2633d --- /dev/null +++ b/lean/OAI/Combinatorics/StripMass/ColumnSew.lean @@ -0,0 +1,458 @@ +import Mathlib +import OAI.Combinatorics.StripMass.ColumnSweep +import OAI.Combinatorics.StripMass.TripleCircuit + +namespace OAI + +/-! Critical honeycomb strip paths, polynomial identities and crossing mass. -/ + + +namespace CriticalStrip.Diagram +noncomputable section +open scoped Classical + + +def BareColumn {n : ℕ} (t : Configuration n) (v w : Vertex n) : Prop := + (v.1=w.1 ∧ (t v.1).Adj v.2 w.2) ∨ + (v.2=3 ∧ w.2=0 ∧ v.1.val+1=w.1.val ∧ (t v.1).Occupied 3) ∨ + (w.2=3 ∧ v.2=0 ∧ w.1.val+1=v.1.val ∧ (t w.1).Occupied 3) + +namespace ColumnSew +variable {n : ℕ} (p : Pairing n) (t : Configuration n) + +def graph : Sum (Fin n) (Vertex n) → Sum (Fin n) (Vertex n) → Prop := + Patch.glued p.Adj (BareColumn t) id (fun i=>(i,1)) p.Occupied + +def project : Sum (Fin n) (Vertex n) → Vertex n + | .inl i => (i,1) + | .inr v => v + +lemma bare_sub {v w : Vertex n} (h : BareColumn t v w) : Wiring p t v w := by + rcases h with h | h | h + · exact Or.inl h + · exact Or.inr (Or.inr (Or.inl h)) + · exact Or.inr (Or.inr (Or.inr h)) + +lemma west (i : Fin n) (hi : p.Occupied i) : + graph p t (.inl i) (.inr (i,1)) := ⟨i,hi,rfl,rfl⟩ + +lemma west' (i : Fin n) (hi : p.Occupied i) : + graph p t (.inr (i,1)) (.inl i) := ⟨i,hi,rfl,rfl⟩ + +lemma project_edge {v w} (h : graph p t v w) : + Relation.ReflTransGen (Wiring p t) (project v) (project w) := by + cases v with + | inl i => + cases w with + | inl j => exact .single (Or.inr (Or.inl ⟨rfl,rfl,h⟩)) + | inr w => obtain ⟨i,hi,rfl,rfl⟩ := h; exact .refl + | inr v => + cases w with + | inl j => obtain ⟨i,hi,rfl,rfl⟩ := h; exact .refl + | inr w => exact .single (bare_sub p t h) + +lemma include_edge {v w} (h : Wiring p t v w) : + Relation.ReflTransGen (graph p t) (.inr v) (.inr w) := by + rcases h with h | h | h | h + · exact .single (Or.inl h) + · rcases v with ⟨i,a⟩; rcases w with ⟨j,b⟩ + obtain ⟨rfl,rfl,hij⟩ := h + exact ((Relation.ReflTransGen.single (west' p t i ⟨j,hij⟩)).tail (show graph p t (.inl i) (.inl j) from hij)).tail + (west p t j ⟨i,Pairing.adj_symm hij⟩) + · exact .single (Or.inr (Or.inl h)) + · exact .single (Or.inr (Or.inr h)) + +lemma old_used (i : Fin n) (hi : Graph.Used (graph p t) (.inl i)) : p.Occupied i := by + obtain ⟨j,hj⟩ := hi + cases j with + | inl j => exact ⟨j,hj⟩ + | inr j => obtain ⟨i,hi,rfl,rfl⟩ := hj; exact hi + +lemma wiring_west_used (i : Fin n) (hi : p.Occupied i) : + Graph.Used (Wiring p t) (i,1) := by + obtain ⟨j,hj⟩ := hi + exact ⟨(j,1),Or.inr (Or.inl ⟨rfl,rfl,hj⟩)⟩ + +lemma project_used (v) (hv : Graph.Used (graph p t) v) : + Graph.Used (Wiring p t) (project v) := by + cases v with + | inl i => exact wiring_west_used p t i (old_used p t i hv) + | inr v => + obtain ⟨w,hw⟩ := hv + cases w with + | inl i => obtain ⟨i,hi,rfl,rfl⟩ := hw; exact wiring_west_used p t i hi + | inr w => exact ⟨w,bare_sub p t hw⟩ + +lemma include_used (v : Vertex n) (hv : Graph.Used (Wiring p t) v) : + Graph.Used (graph p t) (.inr v) := by + obtain ⟨w,h⟩ := hv + rcases h with h | h | h | h + · exact ⟨.inr w,Or.inl h⟩ + · rcases v with ⟨i,a⟩; rcases w with ⟨j,b⟩ + obtain ⟨rfl,rfl,hij⟩ := h + exact ⟨.inl i,west' p t i ⟨j,hij⟩⟩ + · exact ⟨.inr w,Or.inr (Or.inl h)⟩ + · exact ⟨.inr w,Or.inr (Or.inr h)⟩ + + + +def equivalence : Graph.BoundaryEquiv (graph p t) (Wiring p t) + (fun i=>.inr (i,2)) (fun i=>(i,2)) where + toFun := project + invFun := Sum.inr + map_edge := fun _ _ => project_edge p t + inv_edge := fun _ _ => include_edge p t + map_boundary := fun _=>rfl + inv_boundary := fun _=>rfl + map_used := project_used p t + inv_used := include_used p t + retract := by + intro v hv + cases v with + | inl i => exact .single (west p t i (old_used p t i hv)) + | inr v => exact .refl + inv_retract := fun _ _=>.refl + +end ColumnSew + + +structure ColumnCompatible {n : ℕ} (west : Fin n → Prop) (t : Configuration n) : Prop where + west : ∀ i, (t i).Occupied 1 ↔ west i + south : ∀ i, i.val=0 → ¬(t i).Occupied 0 + north : ∀ i, i.val+1=n → ¬(t i).Occupied 3 + glued : ∀ i j, i.val+1=j.val → ((t i).Occupied 3 ↔ (t j).Occupied 0) + +lemma realizes_iff_column_graph {n : ℕ} (p q : Pairing n) (t : Configuration n) : + Realizes p q t ↔ ColumnCompatible p.Occupied t ∧ + GraphRealizes (Wiring p t) (fun i=>(i,2)) q := by + constructor + · intro h + refine ⟨⟨h.west,h.south,h.north,h.glued⟩,h.no_loop,?_⟩ + intro i j + by_cases hij : i=j + · subst j; exact ⟨fun _=>Or.inl rfl,fun _=>.refl⟩ + · simpa only [Reach,hij,false_or] using (h.output i j hij).symm + · rintro ⟨hc,h⟩ + refine ⟨hc.west,?_,hc.south,hc.north,hc.glued,h.no_loop,?_⟩ + · intro i + exact (PartialColumn.east_used p t i).symm.trans + (h.boundary_used_iff (fun _ _ he=>congrArg Prod.fst he) i) + · intro i j hij + simpa only [Reach,hij,false_or] using (h.reach i j).symm + +lemma realizes_unique {n : ℕ} {p q r : Pairing n} {t : Configuration n} + (hq : Realizes p q t) (hr : Realizes p r t) : q=r := + ((realizes_iff_column_graph p q t).mp hq).2.unique + ((realizes_iff_column_graph p r t).mp hr).2 + + + +lemma realizes_exists_of_drains {n : ℕ} (hn : 0(i,2))) : + ∃ q, Realizes p q t := by + have hd' : Graph.DrainsBoundary (Wiring p t) (PartialColumn.fullBoundary hn) := by + intro v w hvw + obtain ⟨i,hi⟩ := hd v w hvw + exact ⟨i.castSucc,by simpa only [PartialColumn.fullBoundary,Fin.lastCases_castSucc] using hi⟩ + have hc' := (PartialColumn.full_compatible_iff p t).mpr + (show PartialColumn.InputConditions p t from ⟨hc.west,hc.south,hc.glued⟩) + obtain ⟨q,hq⟩ := PartialColumn.circuit_exists p t n le_rfl hc' + ((PartialColumn.fullEquiv hn p t).symm.drains hd') + have hs := (Circuit.eval_sound p.padBottom (PartialColumn.circuit t n le_rfl) q hq).2.2 + have hlast : ¬q.Occupied (Fin.last n) := by + rw [←hs,PartialColumn.circuit_support] + simp only [PartialColumn.support,Fin.val_last,lt_self_iff_false,dite_false, + true_and,dite_eq_left hn] + exact hc.north _ (by dsimp; omega) + let q' := q.restrict Fin.castSuccOrderEmb + refine ⟨q',(PartialColumn.column_eval_iff hn p q' t).mp ?_⟩ + rw [Pairing.padTop_restrict q hlast] + exact hq + +end + + + + + +noncomputable section +open scoped Classical BigOperators + + + +namespace ColumnChain +variable {n : ℕ} + +def Vertices : List (Configuration n) → Type + | [] => Fin n + | _::ts => Sum (Vertices ts) (Vertex n) + +def boundary : (ts : List (Configuration n)) → Fin n → Vertices ts + | [] => id + | _::_ => fun i => .inr (i,2) + +def support (p : Pairing n) : List (Configuration n) → Fin n → Prop + | [] => p.Occupied + | t::_ => fun i => (t i).Occupied 2 + +def wiring (p : Pairing n) : (ts : List (Configuration n)) → Vertices ts → Vertices ts → Prop + | [] => p.Adj + | t::ts => Patch.glued (wiring p ts) (BareColumn t) (boundary ts) + (fun i=>(i,1)) (support p ts) + +def Compatible (p : Pairing n) : List (Configuration n) → Prop + | [] => True + | t::ts => Compatible p ts ∧ ColumnCompatible (support p ts) t + +def Runs (p : Pairing n) : List (Configuration n) → Pairing n → Prop + | [],q => p=q + | t::ts,q => ∃ r, Runs p ts r ∧ Realizes r q t + +lemma runs_sound (p : Pairing n) (ts : List (Configuration n)) (q : Pairing n) + (h : Runs p ts q) : Compatible p ts ∧ + GraphRealizes (wiring p ts) (boundary ts) q ∧ support p ts=q.Occupied := by + induction ts generalizing q with + | nil => + have he : p=q := h + subst q + exact ⟨trivial,p.graphRealizes,rfl⟩ + | cons t ts ih => + obtain ⟨r,hr,hq⟩ := h + obtain ⟨hc,hg,hs⟩ := ih r hr + obtain ⟨hct,hgt⟩ := (realizes_iff_column_graph r q t).mp hq + refine ⟨⟨hc,by simpa only [hs] using hct⟩,?_,?_⟩ + · change GraphRealizes (Patch.glued (wiring p ts) (BareColumn t) (boundary ts) + (fun i=>(i,1)) (support p ts)) (fun i=>.inr (i,2)) q + rw [hs,hg.substitute_iff] + exact (ColumnSew.equivalence r t).symm.realizes hgt + · funext i + exact propext (hq.east i) + +lemma runs_unique {p q r : Pairing n} {ts : List (Configuration n)} + (hq : Runs p ts q) (hr : Runs p ts r) : q=r := + (runs_sound p ts q hq).2.1.unique (runs_sound p ts r hr).2.1 + +lemma runs_exists (hn : 0 exact ⟨p,rfl⟩ + | cons t ts ih => + obtain ⟨hc,ht⟩ := hc + have hd' : Graph.DrainsBoundary (wiring p ts) (boundary ts) := + Graph.glued_drains_local (wiring p ts) (BareColumn t) (boundary ts) + (fun i=>(i,1)) (support p ts) (fun i=>(i,2)) hd + obtain ⟨r,hr⟩ := ih hc hd' + obtain ⟨_,hg,hs⟩ := runs_sound p ts r hr + change Graph.DrainsBoundary (Patch.glued (wiring p ts) (BareColumn t) (boundary ts) + (fun i=>(i,1)) (support p ts)) (fun i=>.inr (i,2)) at hd + rw [hs] at ht hd + have hdr := (hg.substitute_drains_iff (BareColumn t) (fun i=>(i,1)) (fun i=>(i,2))).mp hd + obtain ⟨q,hq⟩ := realizes_exists_of_drains hn r t ht ((ColumnSew.equivalence r t).drains hdr) + exact ⟨q,r,hr,hq⟩ + + + +lemma runs_iff (hn : 0 p.Adj i j + | .inl i, .inr (k,j,a) | .inr (k,j,a), .inl i => + k.val+1=m ∧ i=j ∧ a=1 ∧ p.Occupied i + | .inr (k,i,a), .inr (l,j,b) => + (k=l ∧ BareColumn (h k) (i,a) (j,b)) ∨ + (i=j ∧ a=2 ∧ b=1 ∧ l.val+1=k.val ∧ (h k i).Occupied 2) ∨ + (i=j ∧ a=1 ∧ b=2 ∧ k.val+1=l.val ∧ (h l j).Occupied 2) + +def boundary : (m : ℕ) → Fin n → V n m + | 0 => Sum.inl + | _+1 => fun i=>.inr (0,i,2) + +def active (p : Pairing n) : {m : ℕ} → (Fin m → Configuration n) → Fin n → Prop + | 0,_ => p.Occupied + | _+1,h => fun i=>(h 0 i).Occupied 2 + + +def addColumn (n m : ℕ) : Sum (V n m) (Vertex n) ≃ V n (m+1) where + toFun + | .inl (.inl i) => .inl i + | .inl (.inr (k,v)) => .inr (k.succ,v) + | .inr v => .inr (0,v) + invFun + | .inl i => .inl (.inl i) + | .inr (k,v) => Fin.cases (.inr v) (fun k=>.inl (.inr (k,v))) k + left_inv := by + rintro ((i|⟨k,v⟩)|v) <;> simp + right_inv := by + rintro (i|⟨k,v⟩) + · rfl + · induction k using Fin.cases <;> simp + +@[simp] lemma addColumn_old (i : Fin n) : addColumn n m (.inl (.inl i))=.inl i := rfl +@[simp] lemma addColumn_cell (k : Fin m) (v : Vertex n) : + addColumn n m (.inl (.inr (k,v)))=.inr (k.succ,v) := rfl +@[simp] lemma addColumn_new (v : Vertex n) : addColumn n m (.inr v)=.inr (0,v) := rfl + +lemma wiring_step (p : Pairing n) (t : Configuration n) (h : Fin m → Configuration n) + (v w : Sum (V n m) (Vertex n)) : + Patch.glued (wiring p h) (BareColumn t) (boundary m) (fun i=>(i,1)) (active p h) v w ↔ + wiring p (Fin.cons t h) (addColumn n m v) (addColumn n m w) := by + cases v with + | inl v => + cases w with + | inl w => + cases v with + | inl i => + cases w with + | inl j => rfl + | inr w => + rcases w with ⟨l,j,b⟩ + simp [Patch.glued,wiring] + | inr v => + rcases v with ⟨k,i,a⟩ + cases w with + | inl j => simp [Patch.glued,wiring] + | inr w => + rcases w with ⟨l,j,b⟩ + simp [Patch.glued,wiring] + | inr w => + rcases w with ⟨j,b⟩ + cases m with + | zero => + cases v with + | inl i => + by_cases hij : i=j + · subst j; simp [Patch.glued,wiring,boundary,active,and_assoc,and_comm] + · simp [Patch.glued,wiring,boundary,active,hij,and_assoc,and_left_comm,and_comm] + | inr v => exact Fin.elim0 v.1 + | succ m => + cases v with + | inl i => simp [Patch.glued,wiring,boundary,active] + | inr v => + rcases v with ⟨k,i,a⟩ + induction k using Fin.cases with + | zero => + by_cases hij : i=j + · subst j; simp [Patch.glued,wiring,boundary,active,and_assoc,and_left_comm,and_comm] + · simp [Patch.glued,wiring,boundary,active,hij,and_assoc,and_left_comm,and_comm] + | succ k => simp [Patch.glued,wiring,boundary,active] + | inr v => + rcases v with ⟨i,a⟩ + cases w with + | inl w => + cases m with + | zero => + cases w with + | inl j => + by_cases hij : i=j + · subst j; simp [Patch.glued,wiring,boundary,active,and_assoc,and_comm] + · simp [Patch.glued,wiring,boundary,active,Ne.symm hij,and_assoc,and_left_comm,and_comm] + | inr w => exact Fin.elim0 w.1 + | succ m => + cases w with + | inl j => simp [Patch.glued,wiring,boundary,active] + | inr w => + rcases w with ⟨l,j,b⟩ + induction l using Fin.cases with + | zero => + by_cases hij : i=j + · subst j; simp [Patch.glued,wiring,boundary,active,and_assoc,and_left_comm,and_comm] + · simp [Patch.glued,wiring,boundary,active,hij,Ne.symm hij,and_assoc,and_left_comm,and_comm] + | succ l => + have hh : (0 : Fin (m+2))≠l.succ.succ := Ne.symm (Fin.succ_ne_zero _) + simp [Patch.glued,wiring,boundary,active,hh] + | inr w => + rcases w with ⟨j,b⟩ + simp [Patch.glued,wiring,addColumn,BareColumn] + + + +def flatten : (ts : List (Configuration n)) → ColumnChain.Vertices ts ≃ V n ts.length + | [] => (Equiv.sumEmpty (Fin n) (Fin 0 × Vertex n)).symm + | _::ts => (Equiv.sumCongr (flatten ts) (Equiv.refl (Vertex n))).trans + (addColumn n ts.length) + +def entries : (ts : List (Configuration n)) → Fin ts.length → Configuration n + | [] => Fin.elim0 + | t::ts => Fin.cons t (entries ts) + +lemma ofFn_entries (ts : List (Configuration n)) : List.ofFn (entries ts)=ts := by + induction ts with + | nil => rfl + | cons t ts ih => simp only [entries,List.ofFn_cons,ih] + +lemma flatten_boundary (ts : List (Configuration n)) (i : Fin n) : + flatten ts (ColumnChain.boundary ts i)=boundary ts.length i := by + cases ts <;> rfl + +lemma active_entries (p : Pairing n) (ts : List (Configuration n)) : + active p (entries ts)=ColumnChain.support p ts := by + cases ts <;> rfl + +lemma flatten_wiring (p : Pairing n) (ts : List (Configuration n)) + (v w : ColumnChain.Vertices ts) : ColumnChain.wiring p ts v w ↔ + wiring p (entries ts) (flatten ts v) (flatten ts w) := by + induction ts with + | nil => rfl + | cons t ts ih => + change Patch.glued (ColumnChain.wiring p ts) (BareColumn t) (ColumnChain.boundary ts) + (fun i=>(i,1)) (ColumnChain.support p ts) v w ↔ _ + change _ ↔ wiring p (Fin.cons t (entries ts)) + (addColumn n ts.length ((Equiv.sumCongr (flatten ts) (Equiv.refl (Vertex n))) v)) + (addColumn n ts.length ((Equiv.sumCongr (flatten ts) (Equiv.refl (Vertex n))) w)) + rw [←wiring_step] + cases v with + | inl v => + cases w with + | inl w => exact ih v w + | inr w => + simp only [Patch.glued,Equiv.sumCongr_apply,Sum.map_inl,Sum.map_inr, + Equiv.refl_apply,active_entries,←flatten_boundary,Equiv.apply_eq_iff_eq] + | inr v => + cases w with + | inl w => + simp only [Patch.glued,Equiv.sumCongr_apply,Sum.map_inl,Sum.map_inr, + Equiv.refl_apply,active_entries,←flatten_boundary,Equiv.apply_eq_iff_eq] + | inr w => rfl + +def boundaryEquiv (p : Pairing n) (ts : List (Configuration n)) : + Graph.BoundaryEquiv (ColumnChain.wiring p ts) (wiring p (entries ts)) + (ColumnChain.boundary ts) (boundary ts.length) := + Graph.BoundaryEquiv.ofEquiv (flatten ts) (flatten_wiring p ts) (flatten_boundary ts) + +lemma runs_iff (hn : 0 i + | .inr _ => 0 + +lemma base_edge {p : Pairing n} {t : Configuration n} {v w : V n} (h : wiring p t 0 v w) : + p.padBottom.Adj (baseProject v) (baseProject w) := by + rcases v with i | ⟨i,a⟩ <;> rcases w with j | ⟨j,b⟩ + · exact h + all_goals simp [wiring] at h + +lemma base_used {p : Pairing n} {t : Configuration n} {v : V n} + (h : Graph.Used (wiring p t 0) v) : v=.inl (baseProject v) := by + obtain ⟨w,hw⟩ := h + cases v with + | inl i => rfl + | inr v => cases w <;> simp [wiring] at hw + + def baseEquiv (p : Pairing n) (t : Configuration n) : + Graph.BoundaryEquiv (wiring p t 0) p.padBottom.Adj (boundary 0 (Nat.zero_le n)) id where + toFun := baseProject + invFun := Sum.inl + map_edge := fun _ _ h => .single (base_edge h) + inv_edge := fun _ _ h => .single h + map_boundary := fun i => by simp [baseProject] + inv_boundary := fun i => by simp + map_used := fun _ ⟨w,hw⟩ => ⟨baseProject w,base_edge hw⟩ + inv_used := fun _ ⟨w,hw⟩ => ⟨.inl w,hw⟩ + retract := fun _ hv => by rw [base_used hv]; exact .refl + inv_retract := fun _ _ => .refl + +lemma base_realizes (p : Pairing n) (t : Configuration n) : + GraphRealizes (wiring p t 0) (boundary 0 (Nat.zero_le n)) p.padBottom := + (baseEquiv p t).symm.realizes p.padBottom.graphRealizes + + def gate (t : Configuration n) (row : Fin n) : Gate (n+1) := + ⟨row.castSucc,row.succ,by simp,t row⟩ + + def circuit (t : Configuration n) : (k : ℕ) → k≤n → Circuit (n+1) + | 0,_ => .nil + | k+1,hk => .snoc (circuit t k (by omega)) (gate t ⟨k,hk⟩) + +lemma circuit_support (p : Pairing n) (t : Configuration n) (k : ℕ) (hk : k≤n) : + Circuit.support p.padBottom (circuit t k hk) = support p t k hk := by + induction k with + | zero => funext i; simp [circuit,Circuit.support,support] + | succ k ih => + funext i + apply propext + change (if i=(⟨k,hk⟩:Fin n).castSucc then (t ⟨k,hk⟩).Occupied 2 else + if i=(⟨k,hk⟩:Fin n).succ then (t ⟨k,hk⟩).Occupied 3 else + Circuit.support p.padBottom (circuit t k (by omega)) i) ↔ support p t (k+1) hk i + rw [ih] + exact support_step p t ⟨k,hk⟩ i + +lemma circuit_sound (p : Pairing n) (t : Configuration n) (k : ℕ) (hk : k≤n) + (q : Pairing (n+1)) (he : Circuit.eval p.padBottom (circuit t k hk)=some q) : + GraphRealizes (wiring p t k) (boundary k hk) q := by + induction k generalizing q with + | zero => have hq : p.padBottom=q := Option.some.inj he; subst q; exact base_realizes p t + | succ k ih => + let row : Fin n := ⟨k,hk⟩ + let c := circuit t k (by omega) + change (Circuit.eval p.padBottom c).bind + (fun r => r.tileStep row.castSucc row.succ (by simp [row]) (t row))=some q at he + cases hr : Circuit.eval p.padBottom c with + | none => simp [hr] at he + | some r => + have hstep : r.tileStep row.castSucc row.succ (by simp [row]) (t row)=some q := by + simpa only [hr,Option.bind_some] using he + have hp := ih (by omega) r hr + have hs : support p t k (by omega)=r.Occupied := by + rw [←circuit_support p t k (by omega)] + exact (Circuit.eval_sound p.padBottom c r hr).2.2 + have hne : row.castSucc≠row.succ := by intro hh; have hf := congrArg Fin.val hh; dsimp at hf; omega + have hc := ((graph_gate_step_iff hp row.castSucc row.succ (by simp) (t row) q).mpr hstep).2 + have hc' := (CompactGate.realizes_iff hp (boundary_injective k (by omega)) + row.castSucc row.succ hne (t row) q).mp hc + rw [←hs] at hc' + have hn := ((ports p t row).realizes_iff (boundary_injective k (by omega)) + (support p t k (by omega)) row.castSucc row.succ (t row) q).mp hc' + change GraphRealizes (nextWiring p t row) ((ports p t row).boundary row.castSucc row.succ) q at hn + rw [next_eq p t row,funext (boundary_step p t row)] at hn + exact hn + +lemma circuit_exists (p : Pairing n) (t : Configuration n) (k : ℕ) (hk : k≤n) + (hc : Circuit.Compatible p.padBottom (circuit t k hk)) + (hd : Graph.DrainsBoundary (wiring p t k) (boundary k hk)) : + ∃ q, Circuit.eval p.padBottom (circuit t k hk)=some q := by + induction k with + | zero => exact ⟨p.padBottom,rfl⟩ + | succ k ih => + let row : Fin n := ⟨k,hk⟩ + let hkn : k≤n := by omega + let c := circuit t k hkn + change Circuit.Compatible p.padBottom c ∧ + (Circuit.support p.padBottom c row.castSucc ↔ (t row).Occupied 0) ∧ + (Circuit.support p.padBottom c row.succ ↔ (t row).Occupied 1) at hc + obtain ⟨hc,hl,hr⟩ := hc + have hdnext : Graph.DrainsBoundary (nextWiring p t row) + ((ports p t row).boundary row.castSucc row.succ) := by + rw [next_eq,funext (boundary_step p t row)] + exact hd + have hcompact := ((ports p t row).contraction (boundary_injective k hkn) + (support p t k hkn) row.castSucc row.succ (t row)).drains_inv hdnext + have hold := CompactGate.drains_local (wiring p t k) (boundary k hkn) + (support p t k hkn) row.castSucc row.succ (t row) hcompact + obtain ⟨r,he⟩ := ih hkn hc hold + have hp := circuit_sound p t k hkn r he + have hs : support p t k hkn=r.Occupied := by + rw [←circuit_support] + exact (Circuit.eval_sound p.padBottom c r he).2.2 + have hcomp : CutPatch.Compatible (r.cutShape row.castSucc row.succ) (t row) := by + rw [r.cutShape_compatible] + rw [circuit_support p t k hkn,hs] at hl hr + exact ⟨hl,hr⟩ + have hne : row.castSucc≠row.succ := by + intro hh; have hf := congrArg Fin.val hh; dsimp at hf; omega + rw [hs] at hcompact + have hfull := (CompactGate.contraction hp (boundary_injective k hkn) + row.castSucc row.succ hne (t row)).drains_inv hcompact + obtain ⟨q,hq⟩ := graph_gate_step_exists hp row.castSucc row.succ (by simp) (t row) hcomp hfull + refine ⟨q,?_⟩ + change (Circuit.eval p.padBottom c).bind + (fun r => r.tileStep row.castSucc row.succ (by simp) (t row))=some q + have he' : Circuit.eval p.padBottom c=some r := he + simpa only [he',Option.bind_some] using hq + +lemma circuit_iff (p : Pairing n) (t : Configuration n) (k : ℕ) (hk : k≤n) + (q : Pairing (n+1)) : Circuit.eval p.padBottom (circuit t k hk)=some q ↔ + Circuit.Compatible p.padBottom (circuit t k hk) ∧ + GraphRealizes (wiring p t k) (boundary k hk) q := by + constructor + · intro h + exact ⟨(Circuit.eval_sound p.padBottom (circuit t k hk) q h).1,circuit_sound p t k hk q h⟩ + · rintro ⟨hc,hq⟩ + obtain ⟨r,hr⟩ := circuit_exists p t k hk hc hq.drainsBoundary + have he := (circuit_sound p t k hk r hr).unique hq + exact he ▸ hr + +end BoundaryTracking + +section InputCompatibility +variable {n : ℕ} (p : Pairing n) (t : Configuration n) + +def inputCompatible (row : Fin n) : Prop := + (support p t row.val (Nat.le_of_lt row.isLt) row.castSucc ↔ (t row).Occupied 0) ∧ + (support p t row.val (Nat.le_of_lt row.isLt) row.succ ↔ (t row).Occupied 1) + +lemma circuit_compatible_iff (k : ℕ) (hk : k≤n) : + Circuit.Compatible p.padBottom (circuit t k hk) ↔ + ∀ row : Fin n, row.val simp [circuit,Circuit.Compatible] + | succ k ih => + change (Circuit.Compatible p.padBottom (circuit t k (by omega)) ∧ + (Circuit.support p.padBottom (circuit t k (by omega)) (⟨k,hk⟩:Fin n).castSucc ↔ (t ⟨k,hk⟩).Occupied 0) ∧ + (Circuit.support p.padBottom (circuit t k (by omega)) (⟨k,hk⟩:Fin n).succ ↔ (t ⟨k,hk⟩).Occupied 1)) ↔ _ + rw [ih,circuit_support] + change ((∀ row : Fin n, row.val hc row (by omega),hc ⟨k,hk⟩ (by simp)⟩ + +structure InputConditions : Prop where + west : ∀ i, (t i).Occupied 1 ↔ p.Occupied i + south : ∀ i, i.val=0 → ¬(t i).Occupied 0 + glued : ∀ i j, i.val+1=j.val → ((t i).Occupied 3 ↔ (t j).Occupied 0) + +lemma all_input_iff : (∀ row, inputCompatible p t row) ↔ InputConditions p t := by + constructor + · intro hc + constructor + · intro i; exact ((right_support p t i).symm.trans (hc i).2).symm + · intro i hi hocc + exact left_support_zero p t i hi ((hc i).1.mpr hocc) + · intro i j hij + have hj : 0 (left_support_zero p t row hz h).elim, + fun h => (hc.south row hz h).elim⟩ + · have hp : 0 h row row.isLt, fun h row _ => h row⟩).trans (all_input_iff p t) + +end InputCompatibility + +variable {n : ℕ} (hn : 0 + have hi : (⟨n-1,by omega⟩:Fin n).val+1=n := by dsimp; omega + have hh (v : Vertex n) := Relation.reflTransGen_iff_eq (b:=v) (north_isolated p t ⟨n-1,by omega⟩ hi (h.north _ hi)) + induction j using Fin.lastCases with + | last => exact ⟨fun _ => Or.inl rfl,fun _ => .refl⟩ + | cast j => + simp only [fullBoundary,Fin.lastCases_last,Fin.lastCases_castSucc] + rw [hh _] + simp [(Fin.castSucc_ne_last j).symm] + | cast i => + induction j using Fin.lastCases with + | last => + simp only [fullBoundary,Fin.lastCases_last,Fin.lastCases_castSucc] + constructor + · intro hr + have hi : (⟨n-1,by omega⟩:Fin n).val+1=n := by dsimp; omega + have he := (Relation.reflTransGen_iff_eq + (north_isolated p t ⟨n-1,by omega⟩ hi (h.north _ hi))).mp (reach_symm hr) + have hf := congrArg Prod.snd he + simp at hf + · intro he; simp at he + | cast j => + simp only [fullBoundary,Fin.lastCases_castSucc,Fin.castSucc_inj,Pairing.padTop_adj_castSucc] + by_cases hij : i=j + · subst j; exact ⟨fun _ => Or.inl rfl,fun _ => .refl⟩ + · simp only [hij,false_or] + exact (h.output i j hij).symm + +lemma realizes_of_graph (hc : InputConditions p t) + (h : GraphRealizes (Wiring p t) (fullBoundary hn) q.padTop) : Realizes p q t := by + refine ⟨hc.west,?_,hc.south,?_,hc.glued,?_,?_⟩ + · intro i + have hh := h.boundary_used_iff (fullBoundary_injective hn) i.castSucc + simpa only [fullBoundary,Fin.lastCases_castSucc,east_used,Pairing.padTop_occupied_castSucc] using hh + · intro i hi ht + have he : i=(⟨n-1,by omega⟩:Fin n) := Fin.ext (by dsimp; omega) + obtain ⟨b,hb⟩ := ht + have hu : Graph.Used (Wiring p t) (fullBoundary hn (Fin.last n)) := by + rw [he] at hb + simp only [fullBoundary,Fin.lastCases_last] + exact ⟨(⟨n-1,by omega⟩,b),Or.inl ⟨rfl,hb⟩⟩ + exact q.padTop_not_occupied_last ((h.boundary_used_iff (fullBoundary_injective hn) _).mp hu) + · intro v w hvw + obtain ⟨i,hi,hr⟩ := h.no_loop v w hvw + induction i using Fin.lastCases with + | last => exact (q.padTop_not_occupied_last hi).elim + | cast i => exact ⟨i,(q.padTop_occupied_castSucc i).mp hi,by simpa [fullBoundary,Reach] using hr⟩ + · intro i j hij + have hh := h.reach i.castSucc j.castSucc + simpa only [fullBoundary,Fin.lastCases_castSucc,Fin.castSucc_inj,Pairing.padTop_adj_castSucc, + hij,false_or,Reach] using hh.symm + +lemma realizes_graph_iff : Realizes p q t ↔ InputConditions p t ∧ + GraphRealizes (Wiring p t) (fullBoundary hn) q.padTop := + ⟨fun h => ⟨⟨h.west,h.south,h.glued⟩,graph_of_realizes hn p q t h⟩, + fun h => realizes_of_graph hn p q t h.1 h.2⟩ + +include hn in +lemma column_eval_iff : Circuit.eval p.padBottom (circuit t n le_rfl)=some q.padTop ↔ Realizes p q t := by + rw [circuit_iff,full_compatible_iff,(fullEquiv hn p t).realizes_iff] + exact (realizes_graph_iff hn p q t).symm + +end ColumnGeometry + +open Finset +open scoped Classical +variable {K : Type*} [CommRing K] {n : ℕ} + +def position (i : Fin n) : Position (n+1) := ⟨i.castSucc,i.succ,by simp⟩ + +def program (w : Fin n → Weights K) : (k : ℕ) → k≤n → Program (n+1) K + | 0,_ => .nil + | k+1,hk => .snoc (program w k (by omega)) (position ⟨k,hk⟩) (w ⟨k,hk⟩) + +def choicesEquiv (w : Fin n → Weights K) : (k : ℕ) → (hk : k≤n) → + (program w k hk).Choices ≃ (Fin k → Tile) + | 0,_ => { + toFun := fun _ i => Fin.elim0 i + invFun := fun _ => PUnit.unit + left_inv := fun _ => rfl + right_inv := fun f => funext (fun i => Fin.elim0 i) } + | k+1,hk => (Equiv.prodCongr (choicesEquiv w k (by omega)) (Equiv.refl Tile)).trans + ((Equiv.prodComm _ _).trans (Fin.snocEquiv (fun _ : Fin (k+1) => Tile))) + +lemma circuit_congr (t u : Configuration n) (k : ℕ) (hk : k≤n) + (h : ∀ i, i.val rfl + | succ k ih => + change Circuit.snoc (circuit t k _) (gate t ⟨k,hk⟩)=Circuit.snoc (circuit u k _) (gate u ⟨k,hk⟩) + rw [ih (by omega) (fun i hi => h i (by omega))] + congr 1 + simp only [gate,h ⟨k,hk⟩ (by simp)] + +omit [CommRing K] in +lemma choices_circuit (w : Fin n → Weights K) (k : ℕ) (hk : k≤n) + (c : (program w k hk).Choices) (t : Configuration n) + (ht : ∀ i : Fin k, t ⟨i.val,lt_of_lt_of_le i.isLt hk⟩=choicesEquiv w k hk c i) : + (program w k hk).circuit c=circuit t k hk := by + induction k with + | zero => rfl + | succ k ih => + rcases c with ⟨c,v⟩ + change Circuit.snoc ((program w k _).circuit c) ((position ⟨k,hk⟩).gate v)= + Circuit.snoc (circuit t k _) (gate t ⟨k,hk⟩) + have he : choicesEquiv w (k+1) hk (c,v) = + Fin.snoc (choicesEquiv w k (by omega) c) v := by + simp only [choicesEquiv, Equiv.prodCongr] + rfl + have ht' (i : Fin k) : t ⟨i.val,by omega⟩=choicesEquiv w k (by omega) c i := by + simpa only [he, Fin.snoc_castSucc, Fin.val_castSucc] using ht i.castSucc + rw [ih (by omega) c ht'] + congr 1 + have hv : t ⟨k,hk⟩=v := by simpa only [he, Fin.snoc_last, Fin.val_last] using ht (Fin.last k) + simp only [position,Position.gate,gate,hv] + +lemma choices_weight (w : Fin n → Weights K) (k : ℕ) (hk : k≤n) + (c : (program w k hk).Choices) : + (program w k hk).weight c = ∏ i : Fin k, (w ⟨i.val,lt_of_lt_of_le i.isLt hk⟩).tile + (choicesEquiv w k hk c i) := by + induction k with + | zero => simp [program,Program.weight] + | succ k ih => + rcases c with ⟨c,v⟩ + rw [Fin.prod_univ_castSucc] + change (program w k _).weight c * (w ⟨k,hk⟩).tile v = _ + rw [ih (by omega) c] + have he : choicesEquiv w (k+1) hk (c,v) = + Fin.snoc (choicesEquiv w k (by omega) c) v := by + simp only [choicesEquiv, Equiv.prodCongr] + rfl + simp only [he, Fin.snoc_castSucc, Fin.snoc_last, Fin.val_castSucc, Fin.val_last] + +lemma program_column (hn : 0 rfl) + simp only [hc,column_eval_iff hn,choices_weight] + +end PartialColumn +end +end CriticalStrip.Diagram + +end OAI diff --git a/lean/OAI/Combinatorics/StripMass/CoordinateBoxes.lean b/lean/OAI/Combinatorics/StripMass/CoordinateBoxes.lean new file mode 100644 index 0000000000000000000000000000000000000000..81abafc1cb290e2929bf54f1ea1ed8d6b5c17dce --- /dev/null +++ b/lean/OAI/Combinatorics/StripMass/CoordinateBoxes.lean @@ -0,0 +1,426 @@ +import Mathlib +import OAI.Combinatorics.StripMass.DensityExhaustion + +namespace OAI + +/-! Critical honeycomb strip paths, polynomial identities and crossing mass. -/ + + +namespace CriticalStrip +noncomputable section +open scoped BigOperators +open Set MeasureTheory Filter +lemma isOpen_coordinateBox {ι : Type*} [Fintype ι] {I : Set ℝ} (hI : IsOpen I) : + IsOpen (coordinateBox ι I) := by + have he : coordinateBox ι I = ⋂ i : ι, (fun x : ι → ℝ => x i) ⁻¹' I := by + ext x + simp [coordinateBox] + rw [he] + exact isOpen_iInter_of_finite fun i : ι => hI.preimage (continuous_apply i) + +lemma isOpen_cutoffEvent (N : ℕ) (R : ℝ) : IsOpen (cutoffEvent N R) := + isOpen_coordinateBox isOpen_Iio + +lemma laguerreDomain_cutoff_nonempty (N : ℕ) {R : ℝ} (hR : 0 < R) : + (laguerreDomain N ∩ cutoffEvent N R).Nonempty := by + obtain ⟨v, hvm, hv⟩ := orderedDomain_nonempty N + refine ⟨fun i => R * v i, ⟨?_, ?_⟩, ?_⟩ + · intro i j hij + exact mul_lt_mul_of_pos_left (hvm hij) hR + · intro i + exact mul_pos hR (hv i).1 + · intro i + simpa using mul_lt_mul_of_pos_left (hv i).2 hR + + + +theorem laguerreLaw_cutoff_pos (N : ℕ) {a R : ℝ} (ha : 0 < a) (hR : 0 < R) : + 0 < (laguerreLaw N a).real (cutoffEvent N R) := by + rw [laguerreLaw_measureReal N ha (measurableSet_cutoffEvent N R)] + apply div_pos ?_ (laguerreNormalizer_pos N ha) + let S : Set (Fin N → ℝ) := laguerreDomain N ∩ cutoffEvent N R + have hS : IsOpen S := (isOpen_laguerreDomain N).inter (isOpen_cutoffEvent N R) + have hi : IntegrableOn (laguerreDensity N a) S := + (integrableOn_laguerreDensity N ha).mono_set inter_subset_left + have hpos : 0 ≤ᵐ[volume.restrict S] laguerreDensity N a := by + filter_upwards [ae_restrict_mem hS.measurableSet] with r hr + exact (laguerreDensity_pos a hr.1).le + apply (integral_pos_iff_support_of_nonneg_ae hpos hi).2 + calc 0 < volume S := hS.measure_pos volume (laguerreDomain_cutoff_nonempty N hR) + _ = (volume.restrict S) S := (Measure.restrict_apply_self _ _).symm + _ ≤ (volume.restrict S) (Function.support (laguerreDensity N a)) := + measure_mono (fun r hr => (laguerreDensity_pos a hr.1).ne') + + + +theorem laguerreLaw_conditioned_antitone {N : ℕ} {a R : ℝ} (ha : 0 < a) (hR : 0 < R) + (f : (Fin N → ℝ) → ℝ) + (hfc : ContinuousOn f (coordinateBox (Fin N) (Ioi 0))) + (hfm : AntitoneOn f (coordinateBox (Fin N) (Ioi 0))) + (hf : Integrable f (laguerreLaw N a)) : + (∫ r, f r ∂laguerreLaw N a) ≤ + (∫ r in cutoffEvent N R, f r ∂laguerreLaw N a) / + (laguerreLaw N a).real (cutoffEvent N R) := by + exact (le_div_iff₀ (laguerreLaw_cutoff_pos N ha hR)).2 + (laguerreLaw_cutoff_covariance ha R f hfc hfm hf) + + + +def positiveLaw (N : ℕ) : Measure (Fin N → ℝ) := + (ENNReal.ofReal (normalizer N))⁻¹ • + (volume.restrict (orderedDomain N)).withDensity (fun y => ENNReal.ofReal (density N y)) + +theorem positiveLaw_isProbabilityMeasure (N : ℕ) : IsProbabilityMeasure (positiveLaw N) := by + refine ⟨?_⟩ + rw [positiveLaw, Measure.smul_apply, smul_eq_mul, withDensity_apply _ MeasurableSet.univ, + Measure.restrict_univ, ← ofReal_integral_eq_lintegral_ofReal (integrableOn_density N)] + · exact ENNReal.inv_mul_cancel (ENNReal.ofReal_pos.mpr (normalizer_pos N)).ne' ENNReal.ofReal_ne_top + · filter_upwards [ae_restrict_mem (isOpen_orderedDomain N).measurableSet] with y hy + exact (density_pos hy).le + +theorem ae_positiveLaw_orderedDomain (N : ℕ) : ∀ᵐ y ∂positiveLaw N, y ∈ orderedDomain N := by + apply Measure.ae_smul_measure + apply (ae_withDensity_iff (measurable_density N).ennreal_ofReal).2 + filter_upwards [ae_restrict_mem (isOpen_orderedDomain N).measurableSet] with y hy + exact fun _ => hy + +theorem integral_positiveLaw (N : ℕ) (f : (Fin N → ℝ) → ℝ) : + (∫ y, f y ∂positiveLaw N) = expectation N f := by + rw [positiveLaw, integral_smul_measure, + integral_withDensity_eq_integral_toReal_smul (measurable_density N).ennreal_ofReal + (Eventually.of_forall fun _ => ENNReal.ofReal_lt_top)] + simp only [ENNReal.toReal_inv, ENNReal.toReal_ofReal (normalizer_pos N).le, + smul_eq_mul, expectation, div_eq_mul_inv] + rw [mul_comm] + congr 1 + apply integral_congr_ae + filter_upwards [ae_restrict_mem (isOpen_orderedDomain N).measurableSet] with y hy + rw [ENNReal.toReal_ofReal (density_pos hy).le, mul_comm] + +theorem integrable_positiveLaw_iff {N : ℕ} {f : (Fin N → ℝ) → ℝ} : + Integrable f (positiveLaw N) ↔ + IntegrableOn (fun y => f y * density N y) (orderedDomain N) := by + rw [positiveLaw, integrable_smul_measure (by simp) (by simpa using normalizer_pos N), + integrable_withDensity_iff_integrable_smul' (measurable_density N).ennreal_ofReal + (Eventually.of_forall fun _ => ENNReal.ofReal_lt_top)] + apply integrable_congr + filter_upwards [ae_restrict_mem (isOpen_orderedDomain N).measurableSet] with y hy + simp [smul_eq_mul, ENNReal.toReal_ofReal (density_pos hy).le, mul_comm] + +theorem positiveLaw_covariance {N : ℕ} (f g : (Fin N → ℝ) → ℝ) + (hfc : ContinuousOn f (coordinateBox (Fin N) (Ioo 0 1))) + (hgc : ContinuousOn g (coordinateBox (Fin N) (Ioo 0 1))) + (hfm : MonotoneOn f (coordinateBox (Fin N) (Ioo 0 1))) + (hgm : MonotoneOn g (coordinateBox (Fin N) (Ioo 0 1))) + (hf : Integrable f (positiveLaw N)) (hg : Integrable g (positiveLaw N)) + (hfg : Integrable (fun r => f r * g r) (positiveLaw N)) : + (∫ r, f r ∂positiveLaw N) * (∫ r, g r ∂positiveLaw N) ≤ + ∫ r, f r * g r ∂positiveLaw N := by + simpa only [integral_positiveLaw] using + expectation_covariance f g hfc hgc hfm hgm (integrable_positiveLaw_iff.1 hf) + (integrable_positiveLaw_iff.1 hg) (integrable_positiveLaw_iff.1 hfg) + +theorem positiveLaw_covariance_antitone {N : ℕ} (f g : (Fin N → ℝ) → ℝ) + (hfc : ContinuousOn f (coordinateBox (Fin N) (Ioo 0 1))) + (hgc : ContinuousOn g (coordinateBox (Fin N) (Ioo 0 1))) + (hfm : AntitoneOn f (coordinateBox (Fin N) (Ioo 0 1))) + (hgm : AntitoneOn g (coordinateBox (Fin N) (Ioo 0 1))) + (hf : Integrable f (positiveLaw N)) (hg : Integrable g (positiveLaw N)) + (hfg : Integrable (fun r => f r * g r) (positiveLaw N)) : + (∫ r, f r ∂positiveLaw N) * (∫ r, g r ∂positiveLaw N) ≤ + ∫ r, f r * g r ∂positiveLaw N := by + have h := positiveLaw_covariance (fun r => -f r) (fun r => -g r) hfc.neg hgc.neg + (fun _ hx _ hy hxy => neg_le_neg (hfm hx hy hxy)) + (fun _ hx _ hy hxy => neg_le_neg (hgm hx hy hxy)) hf.neg hg.neg (by simpa using hfg) + simpa only [integral_neg, neg_mul_neg] using h + +theorem positiveLaw_cutoff_covariance {N : ℕ} (R : ℝ) (f : (Fin N → ℝ) → ℝ) + (hfc : ContinuousOn f (coordinateBox (Fin N) (Ioo 0 1))) + (hfm : AntitoneOn f (coordinateBox (Fin N) (Ioo 0 1))) + (hf : Integrable f (positiveLaw N)) : + (∫ r, f r ∂positiveLaw N) * (positiveLaw N).real (cutoffEvent N R) ≤ + ∫ r in cutoffEvent N R, f r ∂positiveLaw N := by + let := positiveLaw_isProbabilityMeasure N + apply le_of_tendsto_of_tendsto + (tendsto_const_nhds.mul (cutoffProduct_integral_tendsto (positiveLaw N) R)) + (cutoffProduct_weighted_tendsto (positiveLaw N) R f hf) + apply Eventually.of_forall + intro n + exact positiveLaw_covariance_antitone f (cutoffProduct N n R) hfc + (continuous_cutoffProduct N n R).continuousOn hfm + ((antitone_cutoffProduct N n R).antitoneOn _) hf (cutoffProduct_integrable _ n R) + (hf.mul_bdd (continuous_cutoffProduct N n R).aestronglyMeasurable + (Eventually.of_forall (cutoffProduct_norm_le N n R))) + +theorem positiveLaw_integrable_inverseQuarterSum (N : ℕ) : + Integrable (fun y : Fin N → ℝ => (∑ i, (y i)⁻¹) ^ (1 / 4 : ℝ)) (positiveLaw N) := + integrable_positiveLaw_iff.2 (integrableOn_inverseQuarterSum_density N) + +theorem positiveLaw_integrable_inverseQuarterCoordinate {N : ℕ} (i : Fin N) : + Integrable (fun y : Fin N → ℝ => (y i) ^ (-(1 / 4 : ℝ))) (positiveLaw N) := + integrable_positiveLaw_iff.2 (integrableOn_inverseQuarterCoordinate_density N i) + + + +theorem positiveLaw_measureReal (N : ℕ) + {s : Set (Fin N → ℝ)} (hs : MeasurableSet s) : + (positiveLaw N).real s = (∫ r in orderedDomain N ∩ s, density N r) / normalizer N := by + let := positiveLaw_isProbabilityMeasure N + rw [← integral_indicator_one hs, integral_positiveLaw N] + unfold expectation + simp_rw [← Set.indicator_mul_left, Pi.one_apply, one_mul] + rw [setIntegral_indicator hs] + +lemma orderedDomain_cutoff_nonempty (N : ℕ) {R : ℝ} (hR : 0 < R) : + (orderedDomain N ∩ cutoffEvent N R).Nonempty := by + obtain ⟨v, hvm, hv⟩ := orderedDomain_nonempty N + have ht : 0 < min R 1 := lt_min hR (by norm_num) + refine ⟨fun i => min R 1 * v i, ⟨?_, ?_⟩, ?_⟩ + · intro i j hij + exact mul_lt_mul_of_pos_left (hvm hij) ht + · intro i + have hi : min R 1 * v i < min R 1 := by simpa using mul_lt_mul_of_pos_left (hv i).2 ht + exact ⟨mul_pos ht (hv i).1, hi.trans_le (min_le_right _ _)⟩ + · intro i + have hi : min R 1 * v i < min R 1 := by simpa using mul_lt_mul_of_pos_left (hv i).2 ht + exact hi.trans_le (min_le_left _ _) + +theorem positiveLaw_cutoff_pos (N : ℕ) {R : ℝ} (hR : 0 < R) : + 0 < (positiveLaw N).real (cutoffEvent N R) := by + rw [positiveLaw_measureReal N (measurableSet_cutoffEvent N R)] + apply div_pos ?_ (normalizer_pos N) + let S : Set (Fin N → ℝ) := orderedDomain N ∩ cutoffEvent N R + have hS : IsOpen S := (isOpen_orderedDomain N).inter (isOpen_cutoffEvent N R) + have hi : IntegrableOn (density N) S := (integrableOn_density N).mono_set inter_subset_left + have hpos : 0 ≤ᵐ[volume.restrict S] density N := by + filter_upwards [ae_restrict_mem hS.measurableSet] with r hr + exact (density_pos hr.1).le + apply (integral_pos_iff_support_of_nonneg_ae hpos hi).2 + calc 0 < volume S := hS.measure_pos volume (orderedDomain_cutoff_nonempty N hR) + _ = (volume.restrict S) S := (Measure.restrict_apply_self _ _).symm + _ ≤ (volume.restrict S) (Function.support (density N)) := + measure_mono (fun _ hr => (density_pos hr.1).ne') + + + +theorem positiveLaw_conditioned_antitone {N : ℕ} {R : ℝ} (hR : 0 < R) + (f : (Fin N → ℝ) → ℝ) + (hfc : ContinuousOn f (coordinateBox (Fin N) (Ioo 0 1))) + (hfm : AntitoneOn f (coordinateBox (Fin N) (Ioo 0 1))) + (hf : Integrable f (positiveLaw N)) : + (∫ r, f r ∂positiveLaw N) ≤ + (∫ r in cutoffEvent N R, f r ∂positiveLaw N) / + (positiveLaw N).real (cutoffEvent N R) := by + exact (le_div_iff₀ (positiveLaw_cutoff_pos N hR)).2 + (positiveLaw_cutoff_covariance R f hfc hfm hf) + +lemma continuousOn_inverse_coordinate {ι : Type*} [Fintype ι] (i : ι) (p : ℝ) : + ContinuousOn (fun r : ι → ℝ => (r i) ^ (-p)) (coordinateBox ι (Ioi 0)) := + (continuous_apply i).continuousOn.rpow_const (fun _ hr => Or.inl (hr i).ne') + +lemma antitoneOn_inverse_coordinate {ι : Type*} [Fintype ι] (i : ι) {p : ℝ} + (hp : 0 ≤ p) : + AntitoneOn (fun r : ι → ℝ => (r i) ^ (-p)) (coordinateBox ι (Ioi 0)) := by + intro x hx y hy hxy + exact Real.rpow_le_rpow_of_nonpos (hx i) (hxy i) (neg_nonpos.mpr hp) + +lemma continuousOn_inverseQuarterSum {ι : Type*} [Fintype ι] : + ContinuousOn (fun r : ι → ℝ => (∑ i, (r i)⁻¹) ^ (1 / 4 : ℝ)) + (coordinateBox ι (Ioi 0)) := by + have hsum : ContinuousOn (fun r : ι → ℝ => ∑ i, (r i)⁻¹) (coordinateBox ι (Ioi 0)) := by + exact continuousOn_finsetSum _ fun i _ => + (continuous_apply i).continuousOn.inv₀ (fun _ hr => (hr i).ne') + exact hsum.rpow_const (fun _ _ => Or.inr (by norm_num)) + +lemma antitoneOn_inverseQuarterSum {ι : Type*} [Fintype ι] : + AntitoneOn (fun r : ι → ℝ => (∑ i, (r i)⁻¹) ^ (1 / 4 : ℝ)) + (coordinateBox ι (Ioi 0)) := by + intro x hx y hy hxy + apply Real.rpow_le_rpow (Finset.sum_nonneg (fun i _ => inv_nonneg.mpr (hy i).le)) ?_ (by norm_num) + exact Finset.sum_le_sum fun i _ => inv_anti₀ (hx i) (hxy i) + +theorem positiveLaw_cutoff_inverseQuarterSum {N : ℕ} {R : ℝ} (hR : 0 < R) : + (∫ y : Fin N → ℝ, (∑ i, (y i)⁻¹) ^ (1 / 4 : ℝ) ∂positiveLaw N) ≤ + (∫ y in cutoffEvent N R, (∑ i, (y i)⁻¹) ^ (1 / 4 : ℝ) ∂positiveLaw N) / + (positiveLaw N).real (cutoffEvent N R) := by + exact positiveLaw_conditioned_antitone hR _ + (continuousOn_inverseQuarterSum.mono (fun _ hx i => (hx i).1)) + (antitoneOn_inverseQuarterSum.mono (fun _ hx i => (hx i).1)) + (positiveLaw_integrable_inverseQuarterSum N) + +theorem laguerreLaw_cutoff_inverseQuarterSum {N : ℕ} {a R : ℝ} + (ha : 1 / 4 < a) (hR : 0 < R) : + (∫ r : Fin N → ℝ, (∑ i, (r i)⁻¹) ^ (1 / 4 : ℝ) ∂laguerreLaw N a) ≤ + (∫ r in cutoffEvent N R, (∑ i, (r i)⁻¹) ^ (1 / 4 : ℝ) ∂laguerreLaw N a) / + (laguerreLaw N a).real (cutoffEvent N R) := by + exact laguerreLaw_conditioned_antitone (by linarith) hR _ + continuousOn_inverseQuarterSum antitoneOn_inverseQuarterSum + (integrable_laguerreLaw_inverseQuarterSum ha) + +theorem laguerreLaw_cutoff_inverse_coordinate {N : ℕ} {a R p : ℝ} (ha : 0 < a) + (hR : 0 < R) (i : Fin N) (hp : 0 ≤ p) (hpD : p < laguerreDimension a (i.val + 1)) : + (∫ r, (r i) ^ (-p) ∂laguerreLaw N a) ≤ + (∫ r in cutoffEvent N R, (r i) ^ (-p) ∂laguerreLaw N a) / + (laguerreLaw N a).real (cutoffEvent N R) := by + exact laguerreLaw_conditioned_antitone ha hR _ + (continuousOn_inverse_coordinate i p) (antitoneOn_inverse_coordinate i hp) + (integrable_laguerreLaw_inverse_coordinate_full ha i hpD) + +lemma mem_cutoffEvent_iff_last {n : ℕ} {r : Fin (n + 1) → ℝ} (hr : Monotone r) (R : ℝ) : + r ∈ cutoffEvent (n + 1) R ↔ r (Fin.last n) < R := by + constructor + · exact fun h => h (Fin.last n) + · intro h i + exact (hr (Fin.le_last i)).trans_lt h + +end + +noncomputable section +open scoped BigOperators +open Set MeasureTheory + + + +theorem omega_antitoneOn : AntitoneOn omega (Ioi 0) := by + intro x hx y hy hxy + change 0 < x at hx + change 0 < y at hy + apply mul_le_mul_of_nonneg_left ?_ (by norm_num) + apply Real.sqrt_le_sqrt + apply sub_le_sub_right + apply Real.sqrt_le_sqrt + apply (div_le_div_iff₀ (by positivity : 0 < 2 * y) (by positivity : 0 < 2 * x)).2 + nlinarith + + +def mobiusCoordinate (z : ℝ) : ℝ := 2 * z / (1 + z) + +lemma mobiusCoordinate_mem {z : ℝ} (hz : z ∈ Ioo 0 1) : + mobiusCoordinate z ∈ Ioo 0 1 := by + have hd : 0 < 1 + z := by linarith [hz.1] + exact ⟨div_pos (by linarith [hz.1]) hd, (div_lt_one hd).2 (by linarith [hz.2])⟩ + +lemma mobiusCoordinate_strictMonoOn : StrictMonoOn mobiusCoordinate (Ioi 0) := by + intro x hx y hy hxy + change 0 < x at hx + change 0 < y at hy + apply (div_lt_div_iff₀ (by linarith : 0 < 1 + x) (by linarith : 0 < 1 + y)).2 + nlinarith + +lemma pairKernel_mobius {x y : ℝ} (hx : 0 < x) (hy : 0 < y) : + pairKernel (mobiusCoordinate x) (mobiusCoordinate y) = + 2 * pairKernel x y / ((1 + x) * (1 + y) * (1 + 2 * x * y / (x + y))) := by + have hxy : x + y ≠ 0 := ne_of_gt (add_pos hx hy) + have hx1 : 1 + x ≠ 0 := by positivity + have hy1 : 1 + y ≠ 0 := by positivity + have ht : x + y + 2 * x * y ≠ 0 := by positivity + unfold pairKernel mobiusCoordinate + field_simp + ring + +lemma harmonicPair_monotone {x x' y y' : ℝ} (hx : 0 < x) (hy : 0 < y) + (hxx' : x ≤ x') (hyy' : y ≤ y') : + 2 * x * y / (x + y) ≤ 2 * x' * y' / (x' + y') := by + have hx' := hx.trans_le hxx' + have hy' := hy.trans_le hyy' + calc + 2 * x * y / (x + y) ≤ 2 * x' * y / (x' + y) := by + apply (div_le_div_iff₀ (add_pos hx hy) (add_pos hx' hy)).2 + nlinarith [mul_nonneg (sub_nonneg.mpr hxx') (sq_nonneg y)] + _ ≤ 2 * x' * y' / (x' + y') := by + apply (div_le_div_iff₀ (add_pos hx' hy) (add_pos hx' hy')).2 + nlinarith [mul_nonneg (sub_nonneg.mpr hyy') (sq_nonneg x')] + + +def mobiusPairFactor (x y : ℝ) : ℝ := (1 + 2 * x * y / (x + y))⁻¹ + +lemma mobiusPairFactor_pos {x y : ℝ} (hx : 0 < x) (hy : 0 < y) : + 0 < mobiusPairFactor x y := by unfold mobiusPairFactor; positivity + +lemma mobiusPairFactor_antitone {x x' y y' : ℝ} (hx : 0 < x) (hy : 0 < y) + (hxx' : x ≤ x') (hyy' : y ≤ y') : + mobiusPairFactor x' y' ≤ mobiusPairFactor x y := by + exact inv_anti₀ (by positivity : 0 < 1 + 2 * x * y / (x + y)) + (by linarith [harmonicPair_monotone hx hy hxx' hyy']) + +lemma exponential_over_power_antitone {m β : ℝ} (hm : 0 ≤ m) (hb : β ≤ m / 2) : + AntitoneOn (fun x : ℝ => Real.exp (β * x - m * Real.log (1 + x))) (Ioo 0 1) := by + have hd (x : ℝ) (hx : x ∈ Ioo (0 : ℝ) 1) : + HasDerivAt (fun x : ℝ => β * x - m * Real.log (1 + x)) (β - m / (1 + x)) x := by + have hd0 : (1 : ℝ) + id x ≠ 0 := by change 1 + x ≠ 0; linarith [hx.1] + apply (((hasDerivAt_id x).const_mul β).sub + ((((hasDerivAt_id x).const_add 1).log hd0).const_mul m)).congr_deriv + simp only [id_eq, mul_one, div_eq_mul_inv, one_mul] + have hder (x : ℝ) (hx : x ∈ Ioo (0 : ℝ) 1) : β - m / (1 + x) ≤ 0 := by + have : m / 2 ≤ m / (1 + x) := div_le_div_of_nonneg_left hm (by linarith [hx.1]) (by linarith [hx.2]) + linarith + have hlog : AntitoneOn (fun x : ℝ => β * x - m * Real.log (1 + x)) (Ioo 0 1) := by + apply antitoneOn_of_hasDerivWithinAt_nonpos (convex_Ioo (0 : ℝ) 1) + (fun x hx => (hd x hx).continuousAt.continuousWithinAt) + (fun x hx => (hd x (by simpa only [interior_Ioo] using hx)).hasDerivWithinAt) + (fun x hx => hder x (by simpa only [interior_Ioo] using hx)) + intro x hx y hy hxy + exact Real.exp_le_exp.mpr (hlog hx hy hxy) + +lemma exponential_over_natPower_eq (k : ℕ) (β : ℝ) {x : ℝ} (hx : 0 < x) : + Real.exp (β * x - (k : ℝ) * Real.log (1 + x)) = Real.exp (β * x) / (1 + x) ^ k := by + rw [Real.exp_sub, mul_comm (k : ℝ), ← Real.rpow_def_of_pos (by linarith : 0 < 1 + x), + Real.rpow_natCast] + + +def lowerLikelihoodWeight (N : ℕ) (β z : ℝ) : ℝ := + omega (mobiusCoordinate z) * (Real.exp (β * z) / (1 + z) ^ (N + 1)) + +lemma lowerLikelihoodWeight_pos (N : ℕ) (β : ℝ) {z : ℝ} (hz : z ∈ Ioo 0 1) : + 0 < lowerLikelihoodWeight N β z := by + have hz0 := hz.1 + exact mul_pos (omega_pos (mobiusCoordinate_mem hz)) (by positivity) + +lemma lowerLikelihoodWeight_antitone (N : ℕ) {β : ℝ} (hb : β ≤ (N + 1 : ℝ) / 2) : + AntitoneOn (lowerLikelihoodWeight N β) (Ioo 0 1) := by + intro x hx y hy hxy + have hω : omega (mobiusCoordinate y) ≤ omega (mobiusCoordinate x) := + omega_antitoneOn (mobiusCoordinate_mem hx).1 (mobiusCoordinate_mem hy).1 + (mobiusCoordinate_strictMonoOn.monotoneOn hx.1 hy.1 hxy) + have he := exponential_over_power_antitone (by positivity : 0 ≤ (N + 1 : ℝ)) hb hx hy hxy + simp only [← Nat.cast_add_one, exponential_over_natPower_eq (N + 1) β hx.1, + exponential_over_natPower_eq (N + 1) β hy.1] at he + have hy0 := hy.1 + exact mul_le_mul hω he (by positivity) (omega_nonneg _) + + + +def lowerLikelihood (N : ℕ) (β : ℝ) (z : Fin N → ℝ) : ℝ := + (∏ i, lowerLikelihoodWeight N β (z i)) * + ∏ i, ∏ j ∈ Finset.univ.filter (i < ·), mobiusPairFactor (z i) (z j) + +lemma lowerLikelihood_pos (N : ℕ) (β : ℝ) {z : Fin N → ℝ} + (hz : z ∈ coordinateBox (Fin N) (Ioo 0 1)) : 0 < lowerLikelihood N β z := by + apply mul_pos + · exact Finset.prod_pos fun i _ => lowerLikelihoodWeight_pos N β (hz i) + · exact Finset.prod_pos fun i _ => Finset.prod_pos fun j _ => mobiusPairFactor_pos (hz i).1 (hz j).1 + +theorem lowerLikelihood_antitone (N : ℕ) {β : ℝ} (hb : β ≤ (N + 1 : ℝ) / 2) : + AntitoneOn (lowerLikelihood N β) (coordinateBox (Fin N) (Ioo 0 1)) := by + intro x hx y hy hxy + have hw : (∏ i, lowerLikelihoodWeight N β (y i)) ≤ ∏ i, lowerLikelihoodWeight N β (x i) := + Finset.prod_le_prod₀ (fun i _ => (lowerLikelihoodWeight_pos N β (hy i)).le) + (fun i _ => lowerLikelihoodWeight_antitone N hb (hx i) (hy i) (hxy i)) + have hp : (∏ i, ∏ j ∈ Finset.univ.filter (i < ·), mobiusPairFactor (y i) (y j)) ≤ + ∏ i, ∏ j ∈ Finset.univ.filter (i < ·), mobiusPairFactor (x i) (x j) := by + apply Finset.prod_le_prod₀ + · exact fun i _ => Finset.prod_nonneg fun j _ => (mobiusPairFactor_pos (hy i).1 (hy j).1).le + · intro i _ + exact Finset.prod_le_prod₀ (fun j _ => (mobiusPairFactor_pos (hy i).1 (hy j).1).le) + (fun j _ => mobiusPairFactor_antitone (hx i).1 (hx j).1 (hxy i) (hxy j)) + exact mul_le_mul hw hp + (Finset.prod_nonneg fun i _ => Finset.prod_nonneg fun j _ => (mobiusPairFactor_pos (hy i).1 (hy j).1).le) + (Finset.prod_nonneg fun i _ => (lowerLikelihoodWeight_pos N β (hx i)).le) + + +def omegaLogHalf (x : ℝ) : ℝ := Real.log (omega x) + (1 / 2 : ℝ) * Real.log x + +end +end CriticalStrip + +end OAI diff --git a/lean/OAI/Combinatorics/StripMass/CramerBounds.lean b/lean/OAI/Combinatorics/StripMass/CramerBounds.lean new file mode 100644 index 0000000000000000000000000000000000000000..1c0fc97aafd542d463da037179fc37c03925872f --- /dev/null +++ b/lean/OAI/Combinatorics/StripMass/CramerBounds.lean @@ -0,0 +1,522 @@ +import Mathlib +import OAI.Combinatorics.StripMass.LaurentNumerator + +namespace OAI + +/-! Critical honeycomb strip paths, polynomial identities and crossing mass. -/ + + + +namespace CriticalStrip.Diagram +noncomputable section +open scoped Classical + +lemma betaL_box {n:ℕ} (i:Fin n) : LaurentBox (betaL i) (selfBound i 2) := by + apply LaurentBox.cosine + intro k + by_cases h:k=i <;> simp_all [selfBound,variableExponent] + +lemma LaurentMatrixBox.det_terms {n m:ℕ} (A:Matrix (Fin m) (Fin m) (Laurent n)) + (b:Fin m → Fin m → Fin n → ℕ) (c:Fin n → ℕ) + (hA:∀ i j,LaurentBox (A i j) (b i j)) + (hc:∀ σ:Equiv.Perm (Fin m),∀ k,(∑ j,b (σ j) j k)≤c k) : LaurentBox A.det c := by + rw [Matrix.det_apply'] + apply LaurentBox.sum + intro σ _ + have hp:LaurentBox (∏ j,A (σ j) j) c := + (LaurentBox.prod Finset.univ (fun j => A (σ j) j) (fun j => b (σ j) j) + (fun j _ => hA (σ j) j)).mono (by simpa only [Finset.sum_apply] using hc σ) + rcases Int.units_eq_one_or (Equiv.Perm.sign σ) with hs|hs + · simpa only [hs,Units.val_one,Int.cast_one,one_mul] using hp + · simpa only [hs,Units.val_neg,Units.val_one,Int.cast_neg,Int.cast_one,neg_one_mul] using hp.neg + + + +lemma interpolationNumerator_box {n:ℕ} (W:Pairing n → Laurent n) + (hW:∀ p,LaurentBox (W p) (fun _ => 2*n-2)) (p:Pairing (n+2)) (a:Fin (n+1)) : + LaurentBox (interpolationNumerator betaL (fun i => nodalDatumL W i p) a) + (fun _ => 4*n+2) := by + let dataBound:=fun (i k:Fin (n+1)) => if k=i then 4*n+2 else 2*n+2 + let b:=fun (i j k:Fin (n+1)) => if j=a then dataBound i k else if k=i then 2*j.val else 0 + apply LaurentMatrixBox.det_terms _ b + · intro i j + by_cases hj:j=a + · subst j + simpa only [Matrix.updateCol_apply,ite_true,b] using nodalDatumL_box W hW i p + · rw [Matrix.updateCol_apply,ite_eq_right hj,Matrix.vandermonde_apply] + have hh:LaurentBox (betaL i ^ j.val) (fun k => j.val*selfBound i 2 k) := (betaL_box i).pow j.val + convert hh using 1 + funext k + dsimp [b] + rw [ite_eq_right hj] + by_cases hk:k=i <;> simp [selfBound,hk,Nat.mul_comm] + · intro σ k + by_cases hk:k=σ a + · have hb (j:Fin (n+1)) : b (σ j) j k=if j=a then 4*n+2 else 0 := by + by_cases hj:j=a + · subst j; simp [b,dataBound,hk] + · have hkj:k≠σ j := by intro h; exact hj (σ.injective (h.symm.trans hk)) + simp [b,hj,hkj] + simp only [hb,Finset.sum_ite_eq',Finset.mem_univ,ite_true,le_refl] + · have hb (j:Fin (n+1)) : b (σ j) j k ≤ + (if j=a then 2*n+2 else 0)+(if j=σ.symm k then 2*j.val else 0) := by + have hkj:k=σ j ↔ j=σ.symm k := by + constructor + · intro h; simpa only [Equiv.symm_apply_apply] using (congrArg σ.symm h).symm + · intro h; simp only [h,Equiv.apply_symm_apply] + by_cases hj:j=a + · subst j; simp [b,dataBound,hk] + · simp only [b,ite_eq_right hj,zero_add,hkj] + exact le_refl _ + have hs:=Finset.sum_le_sum (s:=Finset.univ) (fun j _ => hb j) + simp only [Finset.sum_add_distrib,Finset.sum_ite_eq',Finset.mem_univ,ite_true] at hs + have hj: (σ.symm k).val 2*((if i=k then 1 else 0)+(if j=k then 1 else 0))) := by + apply LaurentBox.sub + · apply (betaL_box j).mono + intro k + by_cases hi:i=k <;> by_cases hj:j=k <;> simp_all [selfBound,eq_comm] + · apply (betaL_box i).mono + intro k + by_cases hi:i=k <;> by_cases hj:j=k <;> simp_all [selfBound,eq_comm] + +lemma beta_difference_exact {n:ℕ} (k i j:Fin (n+1)) (hij:i push_cast <;> rfl + all_goals + have hn:=constants_extreme_nonzero n + by_cases hi:i=k + · subst i + obtain ⟨t,rfl⟩:=Fin.exists_succAbove_eq (ne_of_gt hij) + simp only [Fin.succAbove_ne,ite_false,add_zero,map_sub, + AddMonoidAlgebra.coeff_sub,Finsupp.sub_apply,peel_beta_coeff_self,peel_beta_coeff_other] + norm_num only [show (-2:ℤ)≠2 by omega,show (2:ℤ)≠ -2 by omega,show (2:ℤ)≠0 by omega, + show (-2:ℤ)≠0 by omega,ite_true,ite_false,zero_add,add_zero,zero_sub,neg_ne_zero] + first | exact hn.1 | exact hn.2 + · by_cases hj:j=k + · subst j + obtain ⟨t,rfl⟩:=Fin.exists_succAbove_eq hi + simp only [Fin.succAbove_ne,ite_false,zero_add,map_sub, + AddMonoidAlgebra.coeff_sub,Finsupp.sub_apply,peel_beta_coeff_self,peel_beta_coeff_other] + norm_num only [show (-2:ℤ)≠2 by omega,show (2:ℤ)≠ -2 by omega,show (2:ℤ)≠0 by omega, + show (-2:ℤ)≠0 by omega,ite_true,ite_false,zero_add,add_zero,sub_zero] + first | exact hn.1 | exact hn.2 + · obtain ⟨s,rfl⟩:=Fin.exists_succAbove_eq hi + obtain ⟨t,rfl⟩:=Fin.exists_succAbove_eq hj + simp only [Fin.succAbove_ne,ite_false,zero_add,mul_zero,neg_zero,map_sub, + AddMonoidAlgebra.coeff_sub,Finsupp.sub_apply,peel_beta_coeff_other,ite_true] + apply sub_ne_zero.mpr + exact (deletionBeta_injective n).ne (by intro h; subst t; exact lt_irrefl _ hij) + + + +lemma vandermonde_beta_exact {n:ℕ} (k:Fin (n+1)) : + let f:=peelLaurent k (Matrix.vandermonde (@betaL (n+1))).det + LaurentInterval f (-(2*n:ℤ)) (2*n) ∧ f.coeff (-(2*n:ℤ))≠0 ∧ f.coeff (2*n)≠0 := by + rw [Matrix.det_vandermonde,←prod_upperPair,map_prod] + have hs:(∑ e:UpperPair (n+1),(2*((if e.val.1=k then 1 else 0)+(if e.val.2=k then 1 else 0)):ℤ))=2*n := by + rw [←Finset.mul_sum] + congr 1 + exact_mod_cast upperPair_incidence_sum k + have hh:=LaurentInterval.prod_exact Finset.univ + (fun e:UpperPair (n+1) => peelLaurent k (betaL e.val.2-betaL e.val.1)) + (fun e => -(2*((if e.val.1=k then 1 else 0)+(if e.val.2=k then 1 else 0)):ℤ)) + (fun e => (2*((if e.val.1=k then 1 else 0)+(if e.val.2=k then 1 else 0)):ℤ)) + (fun e _ => beta_difference_exact k e.val.1 e.val.2 e.property) + simpa only [Finset.sum_neg_distrib,hs] using hh + +end + + + + + +noncomputable section +open scoped Classical + +def inlinePrivate155_signMonomial {n : ℕ} (i : Fin n) : Multiplicative (Fin n → ℤ) →* Laurent n where + toFun e := monomialL e.toAdd ((-1:ℂ) ^ (e.toAdd i)) + map_one' := by simp [monomialL]; rfl + map_mul' e f := by + change monomialL (e.toAdd+f.toAdd) ((-1:ℂ) ^ (e.toAdd i+f.toAdd i)) = _ + rw [zpow_add₀ (by norm_num : (-1:ℂ)≠0)] + exact (AddMonoidAlgebra.single_mul_single _ _ _ _).symm + +def signLaurent {n : ℕ} (i : Fin n) : Laurent n →+* Laurent n := + (AddMonoidAlgebra.lift ℂ (Laurent n) (Fin n → ℤ) (inlinePrivate155_signMonomial i)).toRingHom + +@[simp] lemma signLaurent_monomial {n : ℕ} (i : Fin n) (e : Fin n → ℤ) (z : ℂ) : + signLaurent i (monomialL e z)=monomialL e (z * (-1:ℂ)^(e i)) := by + change AddMonoidAlgebra.lift ℂ _ _ (inlinePrivate155_signMonomial i) (AddMonoidAlgebra.single e z)=_ + rw [AddMonoidAlgebra.lift_single] + change z • AddMonoidAlgebra.single e ((-1:ℂ)^(e i))=AddMonoidAlgebra.single e _ + rw [AddMonoidAlgebra.smul_single,smul_eq_mul] + +lemma signLaurent_involutive {n : ℕ} (i : Fin n) : Function.Involutive (signLaurent i) := by + have h : (signLaurent i).comp (signLaurent i)=RingHom.id _ := by + apply AddMonoidAlgebra.ringHom_ext <;> intro e + all_goals change signLaurent i (signLaurent i (monomialL _ _))=monomialL _ _ + all_goals rw [signLaurent_monomial,signLaurent_monomial] + all_goals congr 1; rw [mul_assoc,←mul_zpow]; norm_num + intro f + exact DFunLike.congr_fun h f + +def signSpectral {n : ℕ} (i : Fin n) : SpectralField n →+* SpectralField n := + IsFractionRing.lift (K := SpectralField n) + (g := (algebraMap (SpectralRing n) (SpectralField n)).comp (signLaurent i)) + ((IsFractionRing.injective (SpectralRing n) (SpectralField n)).comp + (signLaurent_involutive i).injective) + +@[simp] lemma signSpectral_evalLaurent {n : ℕ} (i : Fin n) (f : Laurent n) : + signSpectral i (evalLaurent f)=evalLaurent (signLaurent i f) := + IsFractionRing.lift_algebraMap _ _ + +@[simp] lemma signSpectral_const {n : ℕ} (i : Fin n) (z : ℂ) : + signSpectral i (constF n z)=constF n z := by + have hc : constF n z=evalLaurent (constantL n z) := (map_constantL n z).symm + rw [hc,signSpectral_evalLaurent] + change evalLaurent (signLaurent i (monomialL 0 z))=evalLaurent (monomialL 0 z) + rw [signLaurent_monomial] + simp + +@[simp] lemma signSpectral_variable {n : ℕ} (i j : Fin n) : + signSpectral i (variableF j)=if j=i then -variableF j else variableF j := by + change signSpectral i (evalLaurent (monomialL (variableExponent j) 1))=_ + rw [signSpectral_evalLaurent,signLaurent_monomial] + by_cases h:j=i + · subst j + simp only [variableExponent,Pi.single_apply,ite_true,zpow_one,one_mul] + change evalLaurent (AddMonoidAlgebra.single _ (-1)) = _ + rw [AddMonoidAlgebra.single_neg] + simp only [evalLaurent,map_neg] + rfl + · have hi : i≠j := Ne.symm h + simp only [variableExponent,Pi.single_apply,ite_eq_right hi,ite_eq_right h,zpow_zero,mul_one] + rfl + +@[simp] lemma signSpectral_torusSin {n : ℕ} (i : Fin n) (z : SpectralField n) : + signSpectral i (torusSin z)=torusSin (signSpectral i z) := by + simp [torusSin,map_div₀,map_inv₀,map_ofNat] + +@[simp] lemma signSpectral_torusCos {n : ℕ} (i : Fin n) (z : SpectralField n) : + signSpectral i (torusCos z)=torusCos (signSpectral i z) := by + simp [torusCos,map_div₀,map_inv₀,map_ofNat] + +@[simp] lemma signSpectral_torusL {n : ℕ} (i : Fin n) (z : SpectralField n) : + signSpectral i (torusL z)=torusL (signSpectral i z) := by simp [torusL] + +@[simp] lemma signSpectral_torusWeights {n : ℕ} (i : Fin n) (z : SpectralField n) : + (torusWeights z).map (signSpectral i)=torusWeights (signSpectral i z) := by + simp [Weights.map,torusWeights,map_div₀] + +end + + + + + +noncomputable section +open scoped Classical +open Finset + + +def occupancySign {K : Type*} [Ring K] {n : ℕ} (p : Pairing n) (i : Fin n) : K := + if p.Occupied i then -1 else 1 + +def Weights.signTwist {K : Type*} [Ring K] (w : Weights K) : Weights K := + ⟨-w.A,w.B,-w.U,w.E,w.F⟩ + +@[simp] lemma occupancySign_empty {K : Type*} [Ring K] {n : ℕ} (i : Fin n) : + occupancySign (K:=K) (empty n) i=1 := by simp [occupancySign] +@[simp] lemma occupancySign_mul_self {K : Type*} [Ring K] {n : ℕ} (p : Pairing n) (i : Fin n) : + occupancySign (K:=K) p i*occupancySign p i=1 := by + simp only [occupancySign]; split_ifs <;> simp + +def inlinePrivate156_tileWest : Tile → Bool + | .vertical₁ | .diagonal₁ | .cap | .verticalPair | .capCup => true + | _ => false +def inlinePrivate156_tileEast : Tile → Bool + | .vertical₀ | .diagonal₁ | .cup | .verticalPair | .capCup => true + | _ => false +lemma inlinePrivate156_tileWest_iff (t : Tile) : t.Occupied 1 ↔ inlinePrivate156_tileWest t=true := by + cases t <;> unfold Tile.Occupied Tile.Adj Tile.edges inlinePrivate156_tileWest <;> decide +lemma inlinePrivate156_tileEast_iff (t : Tile) : t.Occupied 2 ↔ inlinePrivate156_tileEast t=true := by + cases t <;> unfold Tile.Occupied Tile.Adj Tile.edges inlinePrivate156_tileEast <;> decide + +lemma Weights.signTwist_tile {K : Type*} [CommRing K] (w : Weights K) (t : Tile) : + w.signTwist.tile t=(if t.Occupied 1 then -1 else 1)* + (if t.Occupied 2 then -1 else 1)*w.tile t := by + simp only [inlinePrivate156_tileWest_iff,inlinePrivate156_tileEast_iff] + cases t <;> simp [signTwist,tile,inlinePrivate156_tileWest,inlinePrivate156_tileEast] + +lemma column_signTwist {K : Type*} [CommRing K] {n : ℕ} + (w : Fin n → Weights K) (i : Fin n) (p q : Pairing n) : + column (Function.update w i (w i).signTwist) q p= + occupancySign q i * occupancySign p i * column w q p := by + simp only [column,mul_sum] + apply sum_congr rfl + intro t _ + split_ifs with ht + · have h (j : Fin n) : ((Function.update w i (w i).signTwist) j).tile (t j)= + (if j=i then occupancySign q i * occupancySign p i else 1)*(w j).tile (t j) := by + by_cases hj:j=i + · subst j + rw [Function.update_self,Weights.signTwist_tile] + simp only [ht.west,ht.east,occupancySign,ite_true] + ring + · rw [Function.update_of_ne hj,ite_eq_right hj,one_mul] + simp_rw [h] + rw [prod_mul_distrib] + simp + · simp + +lemma normalizedVacuum_signTwist {K : Type*} [Field K] {n : ℕ} + (w : Fin n → Weights K) (i : Fin n) (hw : VacuumRegular w) + (hs : VacuumRegular (Function.update w i (w i).signTwist)) : + normalizedVacuum (Function.update w i (w i).signTwist)= + fun p => occupancySign p i*normalizedVacuum w p := by + symm + apply normalizedVacuum_unique _ hs + constructor + · simp only [occupancySign_empty,one_mul] + exact (normalizedVacuum_stationary w hw).1 + · funext q + simp only [Matrix.mulVec,dotProduct,column_signTwist] + have hh : ∀ p : Pairing n, + occupancySign q i*occupancySign p i*column w q p* + (occupancySign p i*normalizedVacuum w p)= + occupancySign q i*(column w q p*normalizedVacuum w p) := by + intro p + calc + _=occupancySign q i*(occupancySign p i*occupancySign p i)* + (column w q p*normalizedVacuum w p) := by ring + _=_ := by rw [occupancySign_mul_self,mul_one] + simp_rw [hh] + rw [←mul_sum] + exact congrArg (occupancySign q i * ·) (congrFun (normalizedVacuum_stationary w hw).2 q) + +end + + + + + +noncomputable section +open scoped Classical + +@[simp] lemma torusL_neg {n : ℕ} (z : SpectralField n) : torusL (-z)=torusL z := by + simp only [torusL,mul_neg,torusSin_neg] + ring + +@[simp] lemma torusWeights_neg {n : ℕ} (z : SpectralField n) : + torusWeights (-z)=(torusWeights z).signTwist := by + have hinv : (-z)⁻¹ = -z⁻¹ := inv_neg + simp only [torusWeights,Weights.signTwist,div_eq_mul_inv,hinv, + mul_neg,torusSin_neg,torusL_neg,neg_mul,neg_neg] + +@[simp] lemma signSpectral_spectralA {n : ℕ} (i j : Fin n) : + signSpectral i (spectralA j)=spectralA j := by + simp only [spectralA,signSpectral_torusCos,map_div₀,map_pow,signSpectral_const, + signSpectral_variable] + split_ifs <;> simp + +lemma signSpectral_spectralWeights {n : ℕ} (i : Fin n) : + (fun j => (spectralWeights n j).map (signSpectral i))= + Function.update (spectralWeights n) i (spectralWeights n i).signTwist := by + funext j + simp only [spectralWeights,signSpectral_torusWeights,map_div₀,map_pow,signSpectral_const, + signSpectral_variable] + by_cases h:j=i + · subst j + simp only [ite_true,Function.update_self] + have hh : constF n phase ^ 3 / -variableF i = -(constF n phase ^ 3 / variableF i) := div_neg_eq_neg_div _ _ + rw [hh,torusWeights_neg] + · simp only [ite_eq_right h,Function.update_of_ne h] + rfl + +lemma signSpectral_vacuum {n : ℕ} (i : Fin n) (p : Pairing n) : + signSpectral i (normalizedVacuum (spectralWeights n) p)= + occupancySign p i*normalizedVacuum (spectralWeights n) p := by + have hh:=normalizedVacuum_map (signSpectral i) (spectralWeights n) (spectral_regular n) + have hr:VacuumRegular (Function.update (spectralWeights n) i (spectralWeights n i).signTwist) := by + rw [←signSpectral_spectralWeights] + exact (spectral_regular n).map (signSpectral i) (spectralWeights n) + rw [signSpectral_spectralWeights,normalizedVacuum_signTwist _ _ (spectral_regular n) hr] at hh + exact congrFun hh p + +lemma signSpectral_normalization {n : ℕ} (i : Fin n) : + signSpectral i (spectralNormalization n)=spectralNormalization n := by + simp only [spectralNormalization,map_scalarNormalization,signSpectral_const, + signSpectral_spectralA] + + +theorem rationalVacuum_sign {n : ℕ} (i : Fin n) (p : Pairing n) : + signSpectral i (rationalVacuum n p)=occupancySign p i*rationalVacuum n p := by + rw [rationalVacuum,map_mul,signSpectral_normalization,signSpectral_vacuum] + ring + + + + + + + + + +lemma normalizedVacuum_gauge {K : Type*} [Field K] {n : ℕ} + (w v : Fin n → Weights K) (hw : VacuumRegular w) (hv : VacuumRegular v) + (ε : Pairing n → K) (hε : ∀ p,ε p*ε p=1) (he : ε (empty n)=1) + (hc : ∀ p q,column v q p=ε q*ε p*column w q p) : + normalizedVacuum v=fun p => ε p*normalizedVacuum w p := by + symm + apply normalizedVacuum_unique _ hv + constructor + · change ε (empty n)*normalizedVacuum w (empty n)=1 + rw [he,(normalizedVacuum_stationary w hw).1,one_mul] + · funext q + simp only [Matrix.mulVec,dotProduct,hc] + have hh (p : Pairing n) : ε q*ε p*column w q p*(ε p*normalizedVacuum w p)= + ε q*(column w q p*normalizedVacuum w p) := by + calc + _=ε q*(ε p*ε p)*(column w q p*normalizedVacuum w p) := by ring + _=_ := by rw [hε,mul_one] + simp_rw [hh] + rw [←Finset.mul_sum] + exact congrArg (ε q * ·) (congrFun (normalizedVacuum_stationary w hw).2 q) + + + + + + + +@[simp] lemma spectral_div_neg {n : ℕ} (x y : SpectralField n) : + x/(-y)=-(x/y) := div_neg_eq_neg_div _ _ + +def doubleSignTwist {K : Type*} [Ring K] {n : ℕ} (w : Fin n → Weights K) (i j : Fin n) := + Function.update (Function.update w i (w i).signTwist) j (w j).signTwist + +lemma column_doubleSignTwist {K : Type*} [CommRing K] {n : ℕ} + (w : Fin n → Weights K) (i j : Fin n) (hij : j≠i) (p q : Pairing n) : + column (doubleSignTwist w i j) q p= + (occupancySign q i*occupancySign q j)*(occupancySign p i*occupancySign p j)*column w q p := by + unfold doubleSignTwist + conv_lhs => arg 1; arg 3; rw [←Function.update_of_ne hij (w i).signTwist w] + rw [column_signTwist,column_signTwist] + ring + +@[simp] lemma signSpectral_deletionNode {n : ℕ} (k i : Fin n) : + signSpectral k (deletionNode i)=if i=k then -deletionNode i else deletionNode i := by + simp only [deletionNode,map_mul,signSpectral_variable,map_pow,signSpectral_const] + split_ifs <;> simp + +@[simp] lemma signSpectral_deletionBeta {n : ℕ} (k i : Fin n) : + signSpectral k (deletionBeta i)=deletionBeta i := by + simp only [deletionBeta,signSpectral_torusCos,map_div₀,map_pow,signSpectral_const, + signSpectral_deletionNode] + split_ifs <;> simp + +lemma signSpectral_nodalScalar {n : ℕ} (k i : Fin n) : + signSpectral k (nodalScalar i)=nodalScalar i := by + have hc:(signSpectral k).comp (algebraMap ℂ (SpectralField n))= + algebraMap ℂ (SpectralField n) := by + ext z + exact signSpectral_const k z + have hv:(fun j : Fin (n+1) => signSpectral k + ((Fin.snoc spectralA (deletionBeta i) : Fin (n+1) → SpectralField n) j))= + (Fin.snoc spectralA (deletionBeta i) : Fin (n+1) → SpectralField n) := by + funext j + induction j using Fin.lastCases with + | last => simp + | cast j => simp + rw [nodalScalar,MvPolynomial.map_eval₂Hom,hc,hv] + +lemma signSpectral_nodalWeights {n : ℕ} (k i : Fin n) : + (fun j => (nodalWeights i j).map (signSpectral k))= + if i=k then doubleSignTwist (nodalWeights i) k.castSucc (Fin.last n) + else Function.update (nodalWeights i) k.castSucc (nodalWeights i k.castSucc).signTwist := by + funext j + by_cases hi:i=k + · simp only [ite_eq_left hi,doubleSignTwist] + induction j using Fin.lastCases with + | last => + simp only [nodalWeights,Fin.snoc_last,signSpectral_torusWeights,map_div₀, + map_pow,signSpectral_const,signSpectral_deletionNode,ite_eq_left hi,Function.update_self] + rw [spectral_div_neg,torusWeights_neg] + | cast j => + rw [Function.update_of_ne (Fin.castSucc_ne_last j)] + by_cases hj:j=k + · subst j + simp [nodalWeights,spectralWeights,map_div₀,spectral_div_neg] + · have hj' : j.castSucc≠k.castSucc := fun h => hj (Fin.castSucc_injective n h) + simp [nodalWeights,spectralWeights,map_div₀,hj,hj'] + · simp only [ite_eq_right hi] + induction j using Fin.lastCases with + | last => + simp only [nodalWeights,Fin.snoc_last,signSpectral_torusWeights,map_div₀, + map_pow,signSpectral_const,signSpectral_deletionNode,ite_eq_right hi, + Function.update_of_ne (Fin.castSucc_ne_last k).symm] + | cast j => + by_cases hj:j=k + · subst j + simp [nodalWeights,spectralWeights,map_div₀,spectral_div_neg] + · have hj' : j.castSucc≠k.castSucc := fun h => hj (Fin.castSucc_injective n h) + simp [nodalWeights,spectralWeights,map_div₀,hj,hj'] + +def nodeSign {n : ℕ} (k i : Fin n) (p : Pairing (n+1)) : SpectralField n := + occupancySign p k.castSucc * (if i=k then occupancySign p (Fin.last n) else 1) + +lemma nodeSign_square {n : ℕ} (k i : Fin n) (p : Pairing (n+1)) : + nodeSign k i p*nodeSign k i p=1 := by + unfold nodeSign + split_ifs + · rw [mul_mul_mul_comm,occupancySign_mul_self,occupancySign_mul_self,one_mul] + · simp + +lemma signSpectral_nodalVacuum {n : ℕ} (k i : Fin n) (p : Pairing (n+1)) : + signSpectral k (nodalVacuum i p)=nodeSign k i p*nodalVacuum i p := by + have hcol (p q : Pairing (n+1)) : + column (fun j => (nodalWeights i j).map (signSpectral k)) q p= + nodeSign k i q*nodeSign k i p*column (nodalWeights i) q p := by + rw [signSpectral_nodalWeights] + by_cases hi:i=k + · rw [ite_eq_left hi,column_doubleSignTwist _ _ _ (Fin.castSucc_ne_last k).symm] + simp only [nodeSign,ite_eq_left hi] + · rw [ite_eq_right hi,column_signTwist] + simp only [nodeSign,ite_eq_right hi,mul_one] + have hg:=normalizedVacuum_gauge (nodalWeights i) + (fun j => (nodalWeights i j).map (signSpectral k)) (nodal_regular i) + ((nodal_regular i).map (signSpectral k) (nodalWeights i)) (nodeSign k i) + (nodeSign_square k i) (by simp [nodeSign]) hcol + have hm:=normalizedVacuum_map (signSpectral k) (nodalWeights i) (nodal_regular i) + rw [hg] at hm + rw [nodalVacuum,map_mul,signSpectral_nodalScalar,congrFun hm p] + ring + +end +end CriticalStrip.Diagram + +end OAI diff --git a/lean/OAI/Combinatorics/StripMass/CutPatch.lean b/lean/OAI/Combinatorics/StripMass/CutPatch.lean new file mode 100644 index 0000000000000000000000000000000000000000..464d19eab5b060fb217ed6f11126d71d131e7709 --- /dev/null +++ b/lean/OAI/Combinatorics/StripMass/CutPatch.lean @@ -0,0 +1,499 @@ +import Mathlib +import OAI.Combinatorics.StripMass.PatchReplacement +import OAI.Combinatorics.StripMass.PairingSurgery + +namespace OAI + +/-! Critical honeycomb strip paths, polynomial identities and crossing mass. -/ + + + +namespace CriticalStrip.Diagram.CutPatch +noncomputable section +open Finset + +inductive Shape where + | vacant | single₀ | single₁ | paired | separate + deriving DecidableEq + +instance : Fintype Shape := ⟨{.vacant,.single₀,.single₁,.paired,.separate}, by intro s; cases s <;> simp⟩ + +def inputEdges : Shape → Finset (Fin 6 × Fin 6) + | .vacant => ∅ + | .single₀ => {(0,4)} + | .single₁ => {(1,5)} + | .paired => {(0,1)} + | .separate => {(0,4),(1,5)} + +def tilePort (i : Fin 4) : Fin 6 := Fin.castLE (by decide) i + +def Adj (a : Shape) (t : Tile) (v w : Fin 6) : Prop := + (v,w) ∈ inputEdges a ∨ (w,v) ∈ inputEdges a ∨ + ∃ i j : Fin 4, t.Adj i j ∧ v = tilePort i ∧ w = tilePort j + +instance (a : Shape) (t : Tile) : DecidableRel (Adj a t) := fun _ _ => by + unfold Adj; infer_instance + +def inputOccupied (a : Shape) (i : Fin 2) : Prop := + ∃ j, (tilePort (Fin.castLE (by decide) i),j) ∈ inputEdges a ∨ + (j,tilePort (Fin.castLE (by decide) i)) ∈ inputEdges a + +instance (a : Shape) (i : Fin 2) : Decidable (inputOccupied a i) := by + unfold inputOccupied; infer_instance + +def Compatible (a : Shape) (t : Tile) : Prop := + ∀ i : Fin 2, inputOccupied a i ↔ t.Occupied (Fin.castLE (by decide) i) + +instance (a : Shape) (t : Tile) : Decidable (Compatible a t) := by + unfold Compatible; infer_instance + +def boundary : Fin 4 → Fin 6 := ![2,3,4,5] + +def active (a : Shape) (t : Tile) (i : Fin 4) : Prop := + ∃ w, Adj a t (boundary i) w + +instance (a : Shape) (t : Tile) (i : Fin 4) : Decidable (active a t i) := by + unfold active; infer_instance + +def boundaryAdj (d : Finset (Fin 4 × Fin 4)) (i j : Fin 4) : Prop := + (i,j) ∈ d ∨ (j,i) ∈ d + +def boundarySupport (d : Finset (Fin 4 × Fin 4)) (i : Fin 4) : Prop := + ∃ j, boundaryAdj d i j + +instance (d : Finset (Fin 4 × Fin 4)) (i j : Fin 4) : Decidable (boundaryAdj d i j) := by + unfold boundaryAdj; infer_instance +instance (d : Finset (Fin 4 × Fin 4)) (i : Fin 4) : Decidable (boundarySupport d i) := by + unfold boundarySupport; infer_instance + +def profile : Shape → Tile → Option (Finset (Fin 4 × Fin 4)) + | .vacant, .vacant => some ∅ + | .vacant, .cup => some {(0,1)} + | .single₀, .vertical₀ => some {(0,2)} + | .single₀, .diagonal₀ => some {(1,2)} + | .single₁, .vertical₁ => some {(1,3)} + | .single₁, .diagonal₁ => some {(0,3)} + | .paired, .verticalPair => some {(0,1)} + | .separate, .cap => some {(2,3)} + | .separate, .verticalPair => some {(0,2),(1,3)} + | .separate, .capCup => some {(0,1),(2,3)} + | _,_ => none + +def rootTable : Shape → Tile → Fin 6 → Fin 6 + | .vacant, .vacant => ![0,1,2,3,4,5] + | .vacant, .vertical₀ => ![0,1,0,3,4,5] + | .vacant, .vertical₁ => ![0,1,2,1,4,5] + | .vacant, .diagonal₀ => ![0,1,2,0,4,5] + | .vacant, .diagonal₁ => ![0,1,1,3,4,5] + | .vacant, .cap => ![0,0,2,3,4,5] + | .vacant, .cup => ![0,1,2,2,4,5] + | .vacant, .verticalPair => ![0,1,0,1,4,5] + | .vacant, .capCup => ![0,0,2,2,4,5] + | .single₀, .vacant => ![0,1,2,3,0,5] + | .single₀, .vertical₀ => ![0,1,0,3,0,5] + | .single₀, .vertical₁ => ![0,1,2,1,0,5] + | .single₀, .diagonal₀ => ![0,1,2,0,0,5] + | .single₀, .diagonal₁ => ![0,1,1,3,0,5] + | .single₀, .cap => ![0,0,2,3,0,5] + | .single₀, .cup => ![0,1,2,2,0,5] + | .single₀, .verticalPair => ![0,1,0,1,0,5] + | .single₀, .capCup => ![0,0,2,2,0,5] + | .single₁, .vacant => ![0,1,2,3,4,1] + | .single₁, .vertical₀ => ![0,1,0,3,4,1] + | .single₁, .vertical₁ => ![0,1,2,1,4,1] + | .single₁, .diagonal₀ => ![0,1,2,0,4,1] + | .single₁, .diagonal₁ => ![0,1,1,3,4,1] + | .single₁, .cap => ![0,0,2,3,4,0] + | .single₁, .cup => ![0,1,2,2,4,1] + | .single₁, .verticalPair => ![0,1,0,1,4,1] + | .single₁, .capCup => ![0,0,2,2,4,0] + | .paired, .vacant => ![0,0,2,3,4,5] + | .paired, .vertical₀ => ![0,0,0,3,4,5] + | .paired, .vertical₁ => ![0,0,2,0,4,5] + | .paired, .diagonal₀ => ![0,0,2,0,4,5] + | .paired, .diagonal₁ => ![0,0,0,3,4,5] + | .paired, .cap => ![0,0,2,3,4,5] + | .paired, .cup => ![0,0,2,2,4,5] + | .paired, .verticalPair => ![0,0,0,0,4,5] + | .paired, .capCup => ![0,0,2,2,4,5] + | .separate, .vacant => ![0,1,2,3,0,1] + | .separate, .vertical₀ => ![0,1,0,3,0,1] + | .separate, .vertical₁ => ![0,1,2,1,0,1] + | .separate, .diagonal₀ => ![0,1,2,0,0,1] + | .separate, .diagonal₁ => ![0,1,1,3,0,1] + | .separate, .cap => ![0,0,2,3,0,0] + | .separate, .cup => ![0,1,2,2,0,1] + | .separate, .verticalPair => ![0,1,0,1,0,1] + | .separate, .capCup => ![0,0,2,2,0,0] + +def parentTable : Shape → Tile → Fin 6 → Fin 6 + | .vacant, .vacant => ![0,1,2,3,4,5] + | .vacant, .vertical₀ => ![0,1,0,3,4,5] + | .vacant, .vertical₁ => ![0,1,2,1,4,5] + | .vacant, .diagonal₀ => ![0,1,2,0,4,5] + | .vacant, .diagonal₁ => ![0,1,1,3,4,5] + | .vacant, .cap => ![0,0,2,3,4,5] + | .vacant, .cup => ![0,1,2,2,4,5] + | .vacant, .verticalPair => ![0,1,0,1,4,5] + | .vacant, .capCup => ![0,0,2,2,4,5] + | .single₀, .vacant => ![0,1,2,3,0,5] + | .single₀, .vertical₀ => ![0,1,0,3,0,5] + | .single₀, .vertical₁ => ![0,1,2,1,0,5] + | .single₀, .diagonal₀ => ![0,1,2,0,0,5] + | .single₀, .diagonal₁ => ![0,1,1,3,0,5] + | .single₀, .cap => ![0,0,2,3,0,5] + | .single₀, .cup => ![0,1,2,2,0,5] + | .single₀, .verticalPair => ![0,1,0,1,0,5] + | .single₀, .capCup => ![0,0,2,2,0,5] + | .single₁, .vacant => ![0,1,2,3,4,1] + | .single₁, .vertical₀ => ![0,1,0,3,4,1] + | .single₁, .vertical₁ => ![0,1,2,1,4,1] + | .single₁, .diagonal₀ => ![0,1,2,0,4,1] + | .single₁, .diagonal₁ => ![0,1,1,3,4,1] + | .single₁, .cap => ![0,0,2,3,4,1] + | .single₁, .cup => ![0,1,2,2,4,1] + | .single₁, .verticalPair => ![0,1,0,1,4,1] + | .single₁, .capCup => ![0,0,2,2,4,1] + | .paired, .vacant => ![0,0,2,3,4,5] + | .paired, .vertical₀ => ![0,0,0,3,4,5] + | .paired, .vertical₁ => ![0,0,2,1,4,5] + | .paired, .diagonal₀ => ![0,0,2,0,4,5] + | .paired, .diagonal₁ => ![0,0,1,3,4,5] + | .paired, .cap => ![0,0,2,3,4,5] + | .paired, .cup => ![0,0,2,2,4,5] + | .paired, .verticalPair => ![0,0,0,1,4,5] + | .paired, .capCup => ![0,0,2,2,4,5] + | .separate, .vacant => ![0,1,2,3,0,1] + | .separate, .vertical₀ => ![0,1,0,3,0,1] + | .separate, .vertical₁ => ![0,1,2,1,0,1] + | .separate, .diagonal₀ => ![0,1,2,0,0,1] + | .separate, .diagonal₁ => ![0,1,1,3,0,1] + | .separate, .cap => ![0,0,2,3,0,1] + | .separate, .cup => ![0,1,2,2,0,1] + | .separate, .verticalPair => ![0,1,0,1,0,1] + | .separate, .capCup => ![0,0,2,2,0,1] + +def rankTable : Shape → Tile → Fin 6 → ℕ + | .vacant, .vacant => ![0,0,0,0,0,0] + | .vacant, .vertical₀ => ![0,0,1,0,0,0] + | .vacant, .vertical₁ => ![0,0,0,1,0,0] + | .vacant, .diagonal₀ => ![0,0,0,1,0,0] + | .vacant, .diagonal₁ => ![0,0,1,0,0,0] + | .vacant, .cap => ![0,1,0,0,0,0] + | .vacant, .cup => ![0,0,0,1,0,0] + | .vacant, .verticalPair => ![0,0,1,1,0,0] + | .vacant, .capCup => ![0,1,0,1,0,0] + | .single₀, .vacant => ![0,0,0,0,1,0] + | .single₀, .vertical₀ => ![0,0,1,0,1,0] + | .single₀, .vertical₁ => ![0,0,0,1,1,0] + | .single₀, .diagonal₀ => ![0,0,0,1,1,0] + | .single₀, .diagonal₁ => ![0,0,1,0,1,0] + | .single₀, .cap => ![0,1,0,0,1,0] + | .single₀, .cup => ![0,0,0,1,1,0] + | .single₀, .verticalPair => ![0,0,1,1,1,0] + | .single₀, .capCup => ![0,1,0,1,1,0] + | .single₁, .vacant => ![0,0,0,0,0,1] + | .single₁, .vertical₀ => ![0,0,1,0,0,1] + | .single₁, .vertical₁ => ![0,0,0,1,0,1] + | .single₁, .diagonal₀ => ![0,0,0,1,0,1] + | .single₁, .diagonal₁ => ![0,0,1,0,0,1] + | .single₁, .cap => ![0,1,0,0,0,2] + | .single₁, .cup => ![0,0,0,1,0,1] + | .single₁, .verticalPair => ![0,0,1,1,0,1] + | .single₁, .capCup => ![0,1,0,1,0,2] + | .paired, .vacant => ![0,1,0,0,0,0] + | .paired, .vertical₀ => ![0,1,1,0,0,0] + | .paired, .vertical₁ => ![0,1,0,2,0,0] + | .paired, .diagonal₀ => ![0,1,0,1,0,0] + | .paired, .diagonal₁ => ![0,1,2,0,0,0] + | .paired, .cap => ![0,1,0,0,0,0] + | .paired, .cup => ![0,1,0,1,0,0] + | .paired, .verticalPair => ![0,1,1,2,0,0] + | .paired, .capCup => ![0,1,0,1,0,0] + | .separate, .vacant => ![0,0,0,0,1,1] + | .separate, .vertical₀ => ![0,0,1,0,1,1] + | .separate, .vertical₁ => ![0,0,0,1,1,1] + | .separate, .diagonal₀ => ![0,0,0,1,1,1] + | .separate, .diagonal₁ => ![0,0,1,0,1,1] + | .separate, .cap => ![0,1,0,0,1,2] + | .separate, .cup => ![0,0,0,1,1,1] + | .separate, .verticalPair => ![0,0,1,1,1,1] + | .separate, .capCup => ![0,1,0,1,1,2] + +def ForestConditions (a : Shape) (t : Tile) : Prop := + (∀ v w, Adj a t v w → rootTable a t v = rootTable a t w) ∧ + (∀ v, v ≠ rootTable a t v → Adj a t v (parentTable a t v)) ∧ + (∀ v, v ≠ rootTable a t v → rankTable a t (parentTable a t v) < rankTable a t v) + +instance (a : Shape) (t : Tile) : Decidable (ForestConditions a t) := by + unfold ForestConditions; infer_instance + +theorem forestConditions (a : Shape) (t : Tile) : ForestConditions a t := by + cases a <;> cases t <;> decide + +def forest (a : Shape) (t : Tile) : ConnectivityCertificate (Adj a t) where + root := rootTable a t + parent := parentTable a t + rank := rankTable a t + edge_root := (forestConditions a t).1 + parent_edge := (forestConditions a t).2.1 + parent_rank := (forestConditions a t).2.2 + +theorem adj_symmetric (a : Shape) (t : Tile) : Std.Symm (Adj a t) := by + constructor + intro v w h + rcases h with h | h | ⟨i,j,h,rfl,rfl⟩ + · exact Or.inr (Or.inl h) + · exact Or.inl h + · exact Or.inr (Or.inr ⟨j,i,h.symm,rfl,rfl⟩) + +theorem reach_iff (a : Shape) (t : Tile) (v w : Fin 6) : + Relation.ReflTransGen (Adj a t) v w ↔ rootTable a t v = rootTable a t w := + (forest a t).reach_iff (adj_symmetric a t) v w + +def GoodChecks (a : Shape) (t : Tile) (d : Finset (Fin 4 × Fin 4)) : Prop := + Compatible a t ∧ (∀ i, active a t i ↔ boundarySupport d i) ∧ + (∀ v w, Adj a t v w → ∃ i, active a t i ∧ rootTable a t v = rootTable a t (boundary i)) ∧ + (∀ i j, i ≠ j → (boundaryAdj d i j ↔ rootTable a t (boundary i) = rootTable a t (boundary j))) + +def BadChecks (a : Shape) (t : Tile) : Prop := + ¬ Compatible a t ∨ ∃ v w, Adj a t v w ∧ + ∀ i, active a t i → rootTable a t v ≠ rootTable a t (boundary i) + +instance (a : Shape) (t : Tile) (d : Finset (Fin 4 × Fin 4)) : Decidable (GoodChecks a t d) := by + unfold GoodChecks; infer_instance +instance (a : Shape) (t : Tile) : Decidable (BadChecks a t) := by + unfold BadChecks; infer_instance + +def ProfileChecks (a : Shape) (t : Tile) : Prop := + match profile a t with + | some d => GoodChecks a t d + | none => BadChecks a t + +instance (a : Shape) (t : Tile) : Decidable (ProfileChecks a t) := by + unfold ProfileChecks; split <;> infer_instance + +theorem profileChecks (a : Shape) (t : Tile) : ProfileChecks a t := by + cases a <;> cases t <;> decide + +structure Realizes (a : Shape) (t : Tile) (d : Finset (Fin 4 × Fin 4)) : Prop where + compatible : Compatible a t + occupied : ∀ i, active a t i ↔ boundarySupport d i + no_loop : ∀ v w, Adj a t v w → ∃ i, active a t i ∧ Relation.ReflTransGen (Adj a t) v (boundary i) + output : ∀ i j, i ≠ j → (boundaryAdj d i j ↔ Relation.ReflTransGen (Adj a t) (boundary i) (boundary j)) + +theorem realizes_of_profile {a : Shape} {t : Tile} {d : Finset (Fin 4 × Fin 4)} + (h : profile a t = some d) : Realizes a t d := by + have hp := profileChecks a t + simp only [ProfileChecks,h] at hp + exact ⟨hp.1,hp.2.1,fun v w hvw => by + obtain ⟨i,hi,he⟩ := hp.2.2.1 v w hvw + exact ⟨i,hi,(reach_iff a t v (boundary i)).mpr he⟩, + fun i j hij => (hp.2.2.2 i j hij).trans (reach_iff a t _ _).symm⟩ + +theorem none_has_closed {a : Shape} {t : Tile} (h : profile a t = none) + (hc : Compatible a t) : + ∃ v w, Adj a t v w ∧ ∀ i, active a t i → ¬ Relation.ReflTransGen (Adj a t) v (boundary i) := by + have hp := profileChecks a t + simp only [ProfileChecks,h] at hp + rcases hp with hp | ⟨v,w,hvw,hout⟩ + · exact (hp hc).elim + · exact ⟨v,w,hvw,fun i hi hh => hout i hi ((reach_iff a t _ _).mp hh)⟩ + +end +end CriticalStrip.Diagram.CutPatch + + + + + +namespace CriticalStrip.Diagram +noncomputable section +open Finset +open scoped Classical +namespace Pairing + +def partnerOrSelf {n : ℕ} (p : Pairing n) (i : Fin n) : Fin n := + if h : p.Occupied i then p.partner i h else i + +theorem adj_partnerOrSelf {n : ℕ} (p : Pairing n) (i j : Fin n) : + p.Adj i j ↔ p.Occupied i ∧ j = p.partnerOrSelf i := by + by_cases hi : p.Occupied i + · simp only [partnerOrSelf,hi,dite_eq_left,true_and] + exact ⟨fun h => adj_unique h (p.partner_adj i hi),fun h => h ▸ p.partner_adj i hi⟩ + · simp only [hi,false_and,iff_false] + exact fun h => hi ⟨j,h⟩ + +theorem adj_omit_decomposition {n : ℕ} (p : Pairing n) (a b i j : Fin n) : + p.Adj i j ↔ (p.omitTwo a b).Adj i j ∨ + (i=a ∧ p.Adj a j) ∨ (j=a ∧ p.Adj a i) ∨ + (i=b ∧ p.Adj b j) ∨ (j=b ∧ p.Adj b i) := by + rw [omitTwo_adj] + constructor + · intro h + by_cases hia : i=a + · exact Or.inr (Or.inl ⟨hia,hia ▸ h⟩) + by_cases hja : j=a + · exact Or.inr (Or.inr (Or.inl ⟨hja,hja ▸ adj_symm h⟩)) + by_cases hib : i=b + · exact Or.inr (Or.inr (Or.inr (Or.inl ⟨hib,hib ▸ h⟩))) + by_cases hjb : j=b + · exact Or.inr (Or.inr (Or.inr (Or.inr ⟨hjb,hjb ▸ adj_symm h⟩))) + exact Or.inl ⟨h,hia,hib,hja,hjb⟩ + · rintro (⟨h,_⟩|⟨rfl,h⟩|⟨rfl,h⟩|⟨rfl,h⟩|⟨rfl,h⟩) + · exact h + · exact h + · exact adj_symm h + · exact h + · exact adj_symm h + +@[simp] theorem insertCup_adj {n : ℕ} (p : Pairing n) (a b : Fin n) + (hab : a.val+1=b.val) (ha : ¬ p.Occupied a) (hb : ¬ p.Occupied b) + (i j : Fin n) : + (p.insertCup a b hab ha hb).Adj i j ↔ + (i=a ∧ j=b) ∨ (i=b ∧ j=a) ∨ p.Adj i j := by + simp only [Adj,insertCup,mem_insert,Prod.mk.injEq] + tauto + +@[simp] theorem mapOccupied_equiv_adj {n : ℕ} (p : Pairing n) (f : Equiv.Perm (Fin n)) + (hf : ∀ i j, p.Occupied i → p.Occupied j → (f i < f j ↔ i by_cases hb : p.Occupied b <;> + by_cases hn : p.Adj a b <;> cases t <;> simp [tileStep,cutShape,ha,hb,hn,CutPatch.profile] + + + + + + + +theorem adj_decompose_partners {n : ℕ} (p : Pairing n) (a b i j : Fin n) : + p.Adj i j ↔ (p.omitTwo a b).Adj i j ∨ + (p.Occupied a ∧ ((i=a ∧ j=p.partnerOrSelf a) ∨ (j=a ∧ i=p.partnerOrSelf a))) ∨ + (p.Occupied b ∧ ((i=b ∧ j=p.partnerOrSelf b) ∨ (j=b ∧ i=p.partnerOrSelf b))) := by + rw [adj_omit_decomposition] + simp only [adj_partnerOrSelf] + tauto + +theorem omitTwo_swap_invariant {n : ℕ} (p : Pairing n) (a b i j : Fin n) : + (p.omitTwo a b).Adj (Equiv.swap a b i) (Equiv.swap a b j) ↔ + (p.omitTwo a b).Adj i j := by + by_cases hia : i=a <;> by_cases hib : i=b <;> + by_cases hja : j=a <;> by_cases hjb : j=b <;> + simp [Equiv.swap_apply_def,hia,hib,hja,hjb,omitTwo_adj] + +theorem partnerOrSelf_ne {n : ℕ} (p : Pairing n) (a : Fin n) (ha : p.Occupied a) : + p.partnerOrSelf a ≠ a := by + intro he + have hh := (adj_partnerOrSelf p a (p.partnerOrSelf a)).mpr ⟨ha,rfl⟩ + rw [he] at hh + exact p.adj_irrefl a hh + +theorem partnerOrSelf_ne_of_vacant {n : ℕ} (p : Pairing n) (a b : Fin n) + (ha : p.Occupied a) (hb : ¬ p.Occupied b) : p.partnerOrSelf a ≠ b := by + intro he + have hh := (adj_partnerOrSelf p a (p.partnerOrSelf a)).mpr ⟨ha,rfl⟩ + rw [he] at hh + exact hb ⟨a,adj_symm hh⟩ + +theorem swap_eq_partner_iff {n : ℕ} (p : Pairing n) (a b i : Fin n) + (ha : p.Occupied a) (hb : ¬ p.Occupied b) : + Equiv.swap a b i = p.partnerOrSelf a ↔ i = p.partnerOrSelf a := by + have hx := p.partnerOrSelf_ne a ha + have hy := p.partnerOrSelf_ne_of_vacant a b ha hb + rw [← Equiv.eq_symm_apply] + simp [Equiv.swap_apply_def,hx,hy] + +theorem swap_eq_partner_iff_lower {n : ℕ} (p : Pairing n) (a b i : Fin n) + (ha : ¬ p.Occupied a) (hb : p.Occupied b) : + Equiv.swap a b i = p.partnerOrSelf b ↔ i = p.partnerOrSelf b := by + rw [Equiv.swap_comm] + exact swap_eq_partner_iff p b a i hb ha + + + +def cutRelation {n : ℕ} (p : Pairing n) (a b : Fin n) + (d : Finset (Fin 4 × Fin 4)) (i j : Fin n) : Prop := + (p.omitTwo a b).Adj i j ∨ + ∃ r s, CutPatch.boundaryAdj d r s ∧ p.cutLabels a b r = i ∧ p.cutLabels a b s = j + +theorem cutRelation_empty {n : ℕ} (p : Pairing n) (a b i j : Fin n) : + p.cutRelation a b ∅ i j ↔ (p.omitTwo a b).Adj i j := by + simp [cutRelation,CutPatch.boundaryAdj] + +theorem cutRelation_single {n : ℕ} (p : Pairing n) (a b i j : Fin n) (r s : Fin 4) : + p.cutRelation a b {(r,s)} i j ↔ (p.omitTwo a b).Adj i j ∨ + (i=p.cutLabels a b r ∧ j=p.cutLabels a b s) ∨ + (i=p.cutLabels a b s ∧ j=p.cutLabels a b r) := by + simp only [cutRelation,CutPatch.boundaryAdj,mem_singleton,Prod.mk.injEq] + constructor + · rintro (h|⟨x,y,(⟨rfl,rfl⟩|⟨rfl,rfl⟩),hi,hj⟩) + · exact Or.inl h + · exact Or.inr (Or.inl ⟨hi.symm,hj.symm⟩) + · exact Or.inr (Or.inr ⟨hi.symm,hj.symm⟩) + · rintro (h|⟨rfl,rfl⟩|⟨rfl,rfl⟩) + · exact Or.inl h + · exact Or.inr ⟨r,s,Or.inl ⟨rfl,rfl⟩,rfl,rfl⟩ + · exact Or.inr ⟨s,r,Or.inr ⟨rfl,rfl⟩,rfl,rfl⟩ + +theorem cutRelation_union {n : ℕ} (p : Pairing n) (a b i j : Fin n) + (d e : Finset (Fin 4 × Fin 4)) : + p.cutRelation a b (d ∪ e) i j ↔ + p.cutRelation a b d i j ∨ p.cutRelation a b e i j := by + simp only [cutRelation,CutPatch.boundaryAdj,mem_union] + constructor + · rintro (h|⟨x,y,h,hi,hj⟩) + · exact Or.inl (Or.inl h) + · rcases h with (h|h) | (h|h) + · exact Or.inl (Or.inr ⟨x,y,Or.inl h,hi,hj⟩) + · exact Or.inr (Or.inr ⟨x,y,Or.inl h,hi,hj⟩) + · exact Or.inl (Or.inr ⟨x,y,Or.inr h,hi,hj⟩) + · exact Or.inr (Or.inr ⟨x,y,Or.inr h,hi,hj⟩) + · rintro ((h|⟨x,y,h,hi,hj⟩)|(h|⟨x,y,h,hi,hj⟩)) + · exact Or.inl h + · exact Or.inr ⟨x,y,h.imp Or.inl Or.inl,hi,hj⟩ + · exact Or.inl h + · exact Or.inr ⟨x,y,h.imp Or.inr Or.inr,hi,hj⟩ + +end Pairing +end +end CriticalStrip.Diagram + +end OAI diff --git a/lean/OAI/Combinatorics/StripMass/CutStateSound.lean b/lean/OAI/Combinatorics/StripMass/CutStateSound.lean new file mode 100644 index 0000000000000000000000000000000000000000..607632523400c67734576ba8851bdc092bf05916 --- /dev/null +++ b/lean/OAI/Combinatorics/StripMass/CutStateSound.lean @@ -0,0 +1,475 @@ +import Mathlib +import OAI.Combinatorics.StripMass.CutPatch + +namespace OAI + +/-! Critical honeycomb strip paths, polynomial identities and crossing mass. -/ + + + +namespace CriticalStrip.Diagram +noncomputable section +open Finset +open scoped Classical +namespace Pairing + +theorem tileStep_sound_vacant {n : ℕ} (p : Pairing n) (a b : Fin n) + (hab : a.val+1=b.val) (t : Tile) (q : Pairing n) + (d : Finset (Fin 4 × Fin 4)) + (ha : ¬ p.Occupied a) (hb : ¬ p.Occupied b) + (hq : p.tileStep a b hab t = some q) + (hd : CutPatch.profile (p.cutShape a b) t = some d) (i j : Fin n) : + q.Adj i j ↔ p.cutRelation a b d i j := by + have hp := adj_decompose_partners p a b i j + cases t <;> simp [tileStep,cutShape,ha,hb,CutPatch.profile] at hq hd + all_goals subst q; subst d + all_goals simp only [insertCup_adj,cutRelation_single,cutRelation_empty,cutLabels, + Matrix.cons_val_zero,Matrix.cons_val_one] + all_goals simp only [ha,hb,false_and,or_false] at hp + all_goals try { exact hp } + all_goals itauto + +theorem tileStep_sound_single₀ {n : ℕ} (p : Pairing n) (a b : Fin n) + (hab : a.val+1=b.val) (t : Tile) (q : Pairing n) + (d : Finset (Fin 4 × Fin 4)) + (ha : p.Occupied a) (hb : ¬ p.Occupied b) + (hq : p.tileStep a b hab t = some q) + (hd : CutPatch.profile (p.cutShape a b) t = some d) (i j : Fin n) : + q.Adj i j ↔ p.cutRelation a b d i j := by + have hp := adj_decompose_partners p a b i j + have hs := adj_decompose_partners p a b (Equiv.swap a b i) (Equiv.swap a b j) + rw [omitTwo_swap_invariant] at hs + cases t <;> simp [tileStep,cutShape,ha,hb,CutPatch.profile] at hq hd + all_goals subst q; subst d + all_goals simp only [moveIntoVacancy_adj,cutRelation_single,cutLabels,Matrix.cons_val_zero, + Matrix.cons_val_one,Matrix.cons_val_two,Matrix.head_cons,Matrix.tail_cons] + all_goals simp only [ha,hb,false_and,true_and,or_false] at hp + all_goals try { simpa only [ha,hb,true_and,false_and,or_false,false_or,Equiv.swap_apply_eq_iff, + Equiv.swap_apply_left,Equiv.swap_apply_right,and_comm,swap_eq_partner_iff p a b i ha hb, + swap_eq_partner_iff p a b j ha hb] using hs } + all_goals itauto + +theorem tileStep_sound_single₁ {n : ℕ} (p : Pairing n) (a b : Fin n) + (hab : a.val+1=b.val) (t : Tile) (q : Pairing n) + (d : Finset (Fin 4 × Fin 4)) + (ha : ¬ p.Occupied a) (hb : p.Occupied b) + (hq : p.tileStep a b hab t = some q) + (hd : CutPatch.profile (p.cutShape a b) t = some d) (i j : Fin n) : + q.Adj i j ↔ p.cutRelation a b d i j := by + have hp := adj_decompose_partners p a b i j + have hs := adj_decompose_partners p a b (Equiv.swap a b i) (Equiv.swap a b j) + rw [omitTwo_swap_invariant] at hs + cases t <;> simp [tileStep,cutShape,ha,hb,CutPatch.profile] at hq hd + all_goals subst q; subst d + all_goals simp only [moveIntoLowerVacancy_adj,cutRelation_single,cutLabels,Matrix.cons_val_zero, + Matrix.cons_val_one,Matrix.cons_val_three,Matrix.head_cons,Matrix.tail_cons] + all_goals simp only [ha,hb,false_and,true_and,false_or] at hp + all_goals try { simpa only [ha,hb,true_and,false_and,or_false,false_or,Equiv.swap_apply_eq_iff, + Equiv.swap_apply_left,Equiv.swap_apply_right,and_comm,swap_eq_partner_iff_lower p a b i ha hb, + swap_eq_partner_iff_lower p a b j ha hb] using hs } + all_goals itauto + +theorem tileStep_sound_paired {n : ℕ} (p : Pairing n) (a b : Fin n) + (hab : a.val+1=b.val) (t : Tile) (q : Pairing n) + (d : Finset (Fin 4 × Fin 4)) + (ha : p.Occupied a) (hb : p.Occupied b) (hn : p.Adj a b) + (hq : p.tileStep a b hab t = some q) + (hd : CutPatch.profile (p.cutShape a b) t = some d) (i j : Fin n) : + q.Adj i j ↔ p.cutRelation a b d i j := by + have hp := adj_decompose_partners p a b i j + have hpa : p.partnerOrSelf a = b := ((adj_partnerOrSelf p a b).mp hn).2.symm + have hpb : p.partnerOrSelf b = a := ((adj_partnerOrSelf p b a).mp (adj_symm hn)).2.symm + cases t <;> simp [tileStep,cutShape,ha,hb,hn,CutPatch.profile] at hq hd + all_goals subst q; subst d + all_goals simp only [cutRelation_single,cutLabels,Matrix.cons_val_zero,Matrix.cons_val_one] + all_goals simp only [ha,hb,hpa,hpb,true_and] at hp + all_goals itauto + +theorem tileStep_sound_separate {n : ℕ} (p : Pairing n) (a b : Fin n) + (hab : a.val+1=b.val) (t : Tile) (q : Pairing n) + (d : Finset (Fin 4 × Fin 4)) + (ha : p.Occupied a) (hb : p.Occupied b) (hn : ¬ p.Adj a b) + (hq : p.tileStep a b hab t = some q) + (hd : CutPatch.profile (p.cutShape a b) t = some d) (i j : Fin n) : + q.Adj i j ↔ p.cutRelation a b d i j := by + have hp := adj_decompose_partners p a b i j + cases t <;> simp [tileStep,cutShape,ha,hb,hn,CutPatch.profile] at hq hd + all_goals subst q; subst d + all_goals simp only [insertCup_adj,capRemove_adj,Finset.insert_eq,cutRelation_union, + cutRelation_single,cutLabels,Matrix.cons_val_zero, + Matrix.cons_val_one,Matrix.cons_val_two,Matrix.cons_val_three,Matrix.head_cons,Matrix.tail_cons] + all_goals simp only [ha,hb,true_and] at hp + all_goals try { simp only [and_comm, or_assoc, or_left_comm, or_comm] } + all_goals itauto + +theorem tileStep_sound {n : ℕ} (p : Pairing n) (a b : Fin n) + (hab : a.val+1=b.val) (t : Tile) (q : Pairing n) + (d : Finset (Fin 4 × Fin 4)) + (hq : p.tileStep a b hab t = some q) + (hd : CutPatch.profile (p.cutShape a b) t = some d) (i j : Fin n) : + q.Adj i j ↔ p.cutRelation a b d i j := by + by_cases ha : p.Occupied a + · by_cases hb : p.Occupied b + · by_cases hn : p.Adj a b + · exact tileStep_sound_paired p a b hab t q d ha hb hn hq hd i j + · exact tileStep_sound_separate p a b hab t q d ha hb hn hq hd i j + · exact tileStep_sound_single₀ p a b hab t q d ha hb hq hd i j + · by_cases hb : p.Occupied b + · exact tileStep_sound_single₁ p a b hab t q d ha hb hq hd i j + · exact tileStep_sound_vacant p a b hab t q d ha hb hq hd i j + +end Pairing +end + + + + + +noncomputable section +namespace Pairing + +theorem adj_trans_eq {n : ℕ} {p : Pairing n} {i j k : Fin n} + (h : p.Adj i j) (g : p.Adj j k) : i = k := + adj_unique (adj_symm h) g + +theorem reach_adj_iff {n : ℕ} (p : Pairing n) (i j : Fin n) : + Relation.ReflTransGen p.Adj i j ↔ i=j ∨ p.Adj i j := by + constructor + · intro h + induction h with + | refl => exact Or.inl rfl + | @tail j k h hjk ih => + rcases ih with rfl | h + · exact Or.inr hjk + · exact Or.inl (adj_trans_eq h hjk) + · rintro (rfl|h) + · exact .refl + · exact .single h + +end Pairing + +namespace Patch +variable {A I : Type*} {n : ℕ} +variable (r : A → A → Prop) (s : Fin n → Fin n → Prop) + (a : I → A) (b : I → Fin n) (active : I → Prop) + (d : I → I → Prop) (q : Pairing n) +variable (hd : ∀ i j, d i j → active i ∧ active j) + (ha : ∀ i, active i → ∃ j, d i j) + (hr : ∀ i j, Relation.ReflTransGen r (a i) (a j) ↔ i=j ∨ d i j) + (hq : ∀ x y, q.Adj x y ↔ s x y ∨ ∃ i j, d i j ∧ b i=x ∧ b j=y) + +include hd hr hq in +theorem pairing_adj_compressed {x y : Fin n} (h : q.Adj x y) : + compressed r s a b active x y := by + rcases (hq x y).mp h with hxy | ⟨i,j,hdi,rfl,rfl⟩ + · exact Or.inl hxy + · exact Or.inr ⟨i,j,(hd i j hdi).1,(hd i j hdi).2,(hr i j).mpr (Or.inr hdi),rfl,rfl⟩ + +include ha hr hq in +theorem compressed_pairing {x y : Fin n} (h : compressed r s a b active x y) : + (x=y ∨ q.Adj x y) ∧ q.Occupied x := by + rcases h with h | ⟨i,j,hi,hj,h,rfl,rfl⟩ + · have h' := (hq x y).mpr (Or.inl h) + exact ⟨Or.inr h',⟨y,h'⟩⟩ + · rcases (hr i j).mp h with rfl | h + · obtain ⟨k,hk⟩ := ha i hi + exact ⟨Or.inl rfl,⟨b k,(hq _ _).mpr (Or.inr ⟨i,k,hk,rfl,rfl⟩)⟩⟩ + · have h' := (hq _ _).mpr (Or.inr ⟨i,j,h,rfl,rfl⟩) + exact ⟨Or.inr h',⟨b j,h'⟩⟩ + +include hd ha hr hq in +theorem compressed_reach_pairing (x y : Fin n) : + Relation.ReflTransGen (compressed r s a b active) x y ↔ x=y ∨ q.Adj x y := by + constructor + · intro h + apply (q.reach_adj_iff x y).mp + induction h with + | refl => exact .refl + | @tail j k h hjk ih => + rcases (compressed_pairing r s a b active d q ha hr hq hjk).1 with rfl | h + · exact ih + · exact ih.tail h + · rintro (rfl|h) + · exact .refl + · exact .single (pairing_adj_compressed r s a b active d q hd hr hq h) + +include ha hr hq in +theorem compressed_drains_pairing : drains (compressed r s a b active) q.Occupied := by + intro x y h + exact ⟨x,(compressed_pairing r s a b active d q ha hr hq h).2,.refl⟩ + +include hd ha hr hq in +theorem glued_reach_pairing (x y : Fin n) : + Relation.ReflTransGen (glued r s a b active) (.inr x) (.inr y) ↔ x=y ∨ q.Adj x y := by + rw [exterior_reach_iff] + exact compressed_reach_pairing r s a b active d q hd ha hr hq x y + +include ha hr hq in +theorem glued_drains_pairing + (hlocal : ∀ x y, r x y → ∃ i, active i ∧ Relation.ReflTransGen r x (a i)) : + drains (glued r s a b active) (exteriorOutput q.Occupied) := by + apply (drains_glued_iff r s a b active q.Occupied).mpr + exact ⟨hlocal,compressed_drains_pairing r s a b active d q ha hr hq⟩ + +end Patch + + + + + + + + +structure GraphRealizes {V : Type*} {n : ℕ} (r : V → V → Prop) + (boundary : Fin n → V) (p : Pairing n) : Prop where + no_loop : ∀ v w, r v w → ∃ i, p.Occupied i ∧ Relation.ReflTransGen r v (boundary i) + reach : ∀ i j, Relation.ReflTransGen r (boundary i) (boundary j) ↔ i=j ∨ p.Adj i j + +namespace CutPatch + +theorem Realizes.reach {s : Shape} {t : Tile} {d : Finset (Fin 4 × Fin 4)} + (h : Realizes s t d) (i j : Fin 4) : + Relation.ReflTransGen (Adj s t) (boundary i) (boundary j) ↔ i=j ∨ boundaryAdj d i j := by + by_cases hij : i=j + · subst j + exact ⟨fun _ => Or.inl rfl,fun _ => .refl⟩ + · simp only [hij,false_or] + exact (h.output i j hij).symm + +theorem Realizes.edge_active {s : Shape} {t : Tile} {d : Finset (Fin 4 × Fin 4)} + (h : Realizes s t d) (i j : Fin 4) (hd : boundaryAdj d i j) : + active s t i ∧ active s t j := by + exact ⟨(h.occupied i).mpr ⟨j,hd⟩, + (h.occupied j).mpr ⟨i,hd.elim Or.inr Or.inl⟩⟩ + +end CutPatch + +namespace Pairing + +def cutGraph {n : ℕ} (p : Pairing n) (a b : Fin n) (t : Tile) : + Sum (Fin 6) (Fin n) → Sum (Fin 6) (Fin n) → Prop := + Patch.glued (CutPatch.Adj (p.cutShape a b) t) (p.omitTwo a b).Adj + CutPatch.boundary (p.cutLabels a b) (CutPatch.active (p.cutShape a b) t) + +theorem cutGraph_realizes {n : ℕ} (p : Pairing n) (a b : Fin n) + (hab : a.val+1=b.val) (t : Tile) (q : Pairing n) + (hq : p.tileStep a b hab t = some q) : + GraphRealizes (p.cutGraph a b t) Sum.inr q := by + have hne : CutPatch.profile (p.cutShape a b) t ≠ none := by + intro hh + have := (p.tileStep_none_iff a b hab t).mpr hh + rw [hq] at this + cases this + obtain ⟨d,hd⟩ := Option.ne_none_iff_exists'.mp hne + have hh := CutPatch.realizes_of_profile hd + have ha : ∀ i, CutPatch.active (p.cutShape a b) t i → ∃ j, CutPatch.boundaryAdj d i j := + fun i hi => (hh.occupied i).mp hi + have hq' : ∀ x y, q.Adj x y ↔ (p.omitTwo a b).Adj x y ∨ + ∃ i j, CutPatch.boundaryAdj d i j ∧ p.cutLabels a b i=x ∧ p.cutLabels a b j=y := + p.tileStep_sound a b hab t q d hq hd + have hhloop := Patch.glued_drains_pairing + (CutPatch.Adj (p.cutShape a b) t) (p.omitTwo a b).Adj CutPatch.boundary + (p.cutLabels a b) (CutPatch.active (p.cutShape a b) t) + (CutPatch.boundaryAdj d) q ha hh.reach hq' hh.no_loop + constructor + · intro v w hvw + obtain ⟨z,hz,hr⟩ := hhloop v w hvw + cases z with + | inl z => exact hz.elim + | inr z => exact ⟨z,hz,hr⟩ + · exact Patch.glued_reach_pairing + (CutPatch.Adj (p.cutShape a b) t) (p.omitTwo a b).Adj CutPatch.boundary + (p.cutLabels a b) (CutPatch.active (p.cutShape a b) t) + (CutPatch.boundaryAdj d) q hh.edge_active ha hh.reach hq' + +end Pairing + + + + + + +namespace Graph + +def Used {V : Type*} (r : V → V → Prop) (v : V) : Prop := ∃ w, r v w + +theorem map_reach {V W : Type*} {r : V → V → Prop} {s : W → W → Prop} + (f : V → W) (hf : ∀ v w, r v w → Relation.ReflTransGen s (f v) (f w)) + {v w : V} (h : Relation.ReflTransGen r v w) : Relation.ReflTransGen s (f v) (f w) := by + induction h with + | refl => exact .refl + | @tail y z h hyz ih => exact ih.trans (hf y z hyz) + + + +structure BoundaryEquiv {V W : Type*} {n : ℕ} (r : V → V → Prop) (s : W → W → Prop) + (a : Fin n → V) (b : Fin n → W) where + toFun : V → W + invFun : W → V + map_edge : ∀ v w, r v w → Relation.ReflTransGen s (toFun v) (toFun w) + inv_edge : ∀ v w, s v w → Relation.ReflTransGen r (invFun v) (invFun w) + map_boundary : ∀ i, toFun (a i) = b i + inv_boundary : ∀ i, invFun (b i) = a i + map_used : ∀ v, Used r v → Used s (toFun v) + inv_used : ∀ v, Used s v → Used r (invFun v) + retract : ∀ v, Used r v → Relation.ReflTransGen r v (invFun (toFun v)) + inv_retract : ∀ v, Used s v → Relation.ReflTransGen s v (toFun (invFun v)) + +namespace BoundaryEquiv +variable {V W : Type*} {n : ℕ} {r : V → V → Prop} {s : W → W → Prop} + {a : Fin n → V} {b : Fin n → W} + +protected def symm (e : BoundaryEquiv r s a b) : BoundaryEquiv s r b a := + ⟨e.invFun,e.toFun,e.inv_edge,e.map_edge,e.inv_boundary,e.map_boundary, + e.inv_used,e.map_used,e.inv_retract,e.retract⟩ + +theorem realizes (e : BoundaryEquiv r s a b) {p : Pairing n} + (h : GraphRealizes r a p) : GraphRealizes s b p := by + constructor + · intro v w hvw + obtain ⟨x,hx⟩ := e.inv_used v ⟨w,hvw⟩ + obtain ⟨i,hi,hr⟩ := h.no_loop (e.invFun v) x hx + refine ⟨i,hi,?_⟩ + have hmap := Graph.map_reach e.toFun e.map_edge hr + rw [e.map_boundary] at hmap + exact (e.inv_retract v ⟨w,hvw⟩).trans hmap + · intro i j + constructor + · intro hh + have hm := Graph.map_reach e.invFun e.inv_edge hh + rw [e.inv_boundary,e.inv_boundary] at hm + exact (h.reach i j).mp hm + · intro hh + have hm := Graph.map_reach e.toFun e.map_edge ((h.reach i j).mpr hh) + rwa [e.map_boundary,e.map_boundary] at hm + +theorem realizes_iff (e : BoundaryEquiv r s a b) {p : Pairing n} : + GraphRealizes r a p ↔ GraphRealizes s b p := + ⟨e.realizes,e.symm.realizes⟩ + +end BoundaryEquiv +end Graph + + + + + +open Finset +open scoped Classical + +inductive StepVertex (n : ℕ) where + | old : Fin n → StepVertex n + | box : Fin 4 → StepVertex n + | out : Fin n → StepVertex n + deriving DecidableEq + +namespace Pairing + +def stepWiring {n : ℕ} (p : Pairing n) (a b : Fin n) (t : Tile) : + StepVertex n → StepVertex n → Prop + | .old i, .old j => p.Adj i j + | .box k, .box l => t.Adj k l + | .old i, .box k | .box k, .old i => + (i=a ∧ k=0 ∧ p.Occupied a) ∨ (i=b ∧ k=1 ∧ p.Occupied b) + | .old i, .out j | .out j, .old i => + i=j ∧ i≠a ∧ i≠b ∧ p.Occupied i + | .box k, .out i | .out i, .box k => + (i=a ∧ k=2 ∧ t.Occupied 2) ∨ (i=b ∧ k=3 ∧ t.Occupied 3) + | .out _, .out _ => False + +def stepToCut {n : ℕ} (_p : Pairing n) (a b : Fin n) : StepVertex n → Sum (Fin 6) (Fin n) + | .old i => if i=a then .inl 0 else if i=b then .inl 1 else .inr i + | .box k => .inl (CutPatch.tilePort k) + | .out i => .inr i + +def cutToStep {n : ℕ} (p : Pairing n) (a b : Fin n) : Sum (Fin 6) (Fin n) → StepVertex n + | .inl i => ![.box 0,.box 1,.box 2,.box 3,.old (p.partnerOrSelf a),.old (p.partnerOrSelf b)] i + | .inr i => .out i + +theorem stepWiring_symm {n : ℕ} (p : Pairing n) (a b : Fin n) (t : Tile) + {v w : StepVertex n} (h : p.stepWiring a b t v w) : p.stepWiring a b t w v := by + cases v <;> cases w <;> try exact h + · exact adj_symm h + · exact h.elim Or.inr Or.inl + +instance stepWiring_isSymm {n : ℕ} (p : Pairing n) (a b : Fin n) (t : Tile) : + Std.Symm (p.stepWiring a b t) := ⟨fun _ _ => stepWiring_symm p a b t⟩ + +theorem cutGraph_symm {n : ℕ} (p : Pairing n) (a b : Fin n) (t : Tile) + {v w : Sum (Fin 6) (Fin n)} (h : p.cutGraph a b t v w) : p.cutGraph a b t w v := by + cases v with + | inl v => + cases w with + | inl w => exact (CutPatch.adj_symmetric _ _).symm _ _ h + | inr w => obtain ⟨i,hi,rfl,rfl⟩ := h; exact ⟨i,hi,rfl,rfl⟩ + | inr v => + cases w with + | inl w => obtain ⟨i,hi,rfl,rfl⟩ := h; exact ⟨i,hi,rfl,rfl⟩ + | inr w => exact adj_symm h + +instance cutGraph_isSymm {n : ℕ} (p : Pairing n) (a b : Fin n) (t : Tile) : + Std.Symm (p.cutGraph a b t) := ⟨fun _ _ => cutGraph_symm p a b t⟩ + +end Pairing + +namespace CutPatch + +theorem active_zero (s : Shape) (t : Tile) : active s t 0 ↔ t.Occupied 2 := by + cases s <;> cases t <;> decide + +theorem active_one (s : Shape) (t : Tile) : active s t 1 ↔ t.Occupied 3 := by + cases s <;> cases t <;> decide + +theorem active_two (s : Shape) (t : Tile) : active s t 2 ↔ s=.single₀ ∨ s=.separate := by + cases s <;> cases t <;> decide + +theorem active_three (s : Shape) (t : Tile) : active s t 3 ↔ s=.single₁ ∨ s=.separate := by + cases s <;> cases t <;> decide + +theorem input_occupied_zero (s : Shape) : inputOccupied s 0 ↔ + s=.single₀ ∨ s=.paired ∨ s=.separate := by cases s <;> decide + +theorem input_occupied_one (s : Shape) : inputOccupied s 1 ↔ + s=.single₁ ∨ s=.paired ∨ s=.separate := by cases s <;> decide + +end CutPatch + +namespace Pairing + +theorem cutShape_input_zero {n : ℕ} (p : Pairing n) (a b : Fin n) : + CutPatch.inputOccupied (p.cutShape a b) 0 ↔ p.Occupied a := by + rw [CutPatch.input_occupied_zero] + by_cases ha : p.Occupied a <;> by_cases hb : p.Occupied b <;> by_cases hn : p.Adj a b <;> + simp [cutShape,ha,hb,hn] + +theorem cutShape_input_one {n : ℕ} (p : Pairing n) (a b : Fin n) : + CutPatch.inputOccupied (p.cutShape a b) 1 ↔ p.Occupied b := by + rw [CutPatch.input_occupied_one] + by_cases ha : p.Occupied a <;> by_cases hb : p.Occupied b <;> by_cases hn : p.Adj a b <;> + simp [cutShape,ha,hb,hn] + +theorem cutShape_compatible {n : ℕ} (p : Pairing n) (a b : Fin n) (t : Tile) : + CutPatch.Compatible (p.cutShape a b) t ↔ + (p.Occupied a ↔ t.Occupied 0) ∧ (p.Occupied b ↔ t.Occupied 1) := by + simp only [CutPatch.Compatible,Fin.forall_fin_two,cutShape_input_zero,cutShape_input_one] + rfl + +theorem cutShape_active_two {n : ℕ} (p : Pairing n) (a b : Fin n) (t : Tile) : + CutPatch.active (p.cutShape a b) t 2 ↔ p.Occupied a ∧ ¬ p.Adj a b := by + rw [CutPatch.active_two] + by_cases ha : p.Occupied a <;> by_cases hb : p.Occupied b <;> by_cases hn : p.Adj a b <;> + simp [cutShape,ha,hb,hn] + exact (hb ⟨a,adj_symm hn⟩).elim + +theorem cutShape_active_three {n : ℕ} (p : Pairing n) (a b : Fin n) (t : Tile) : + CutPatch.active (p.cutShape a b) t 3 ↔ p.Occupied b ∧ ¬ p.Adj a b := by + rw [CutPatch.active_three] + by_cases ha : p.Occupied a <;> by_cases hb : p.Occupied b <;> by_cases hn : p.Adj a b <;> + simp [cutShape,ha,hb,hn] + exact (ha ⟨b,hn⟩).elim + +end Pairing +end +end CriticalStrip.Diagram + +end OAI diff --git a/lean/OAI/Combinatorics/StripMass/DeficitBounds.lean b/lean/OAI/Combinatorics/StripMass/DeficitBounds.lean new file mode 100644 index 0000000000000000000000000000000000000000..06fac1d01fa57f2639a3fcfe2b5db1453f08c2e6 --- /dev/null +++ b/lean/OAI/Combinatorics/StripMass/DeficitBounds.lean @@ -0,0 +1,374 @@ +import Mathlib +import OAI.Combinatorics.StripMass.Basic + +namespace OAI + +/-! Critical honeycomb strip paths, polynomial identities and crossing mass. -/ + + +namespace CriticalStrip +noncomputable section +open scoped BigOperators +section GramBounds +open Set MeasureTheory +theorem expected_deficit_bounds (N : ℕ) {x : ℝ} (hx : 0 < x) : + 0 ≤ 1 - expectation N (reflectionProduct N x) ∧ + 1 - expectation N (reflectionProduct N x) ≤ + Real.sqrt x * expectation N (inverseHalfSum N) := by + rw [← expectation_deficit N hx.le] + constructor + · apply expectation_nonneg + intro y hy + exact sub_nonneg.2 ((le_abs_self _).trans (abs_reflectionProduct_le_one hy hx.le)) + · have hi := integral_mono_ae (integrableOn_deficit_density N hx.le) + ((integrableOn_inverseHalfSum_density N).const_mul (Real.sqrt x)) (by + filter_upwards [ae_restrict_mem (isOpen_orderedDomain N).measurableSet] with y hy + have hp := (le_abs_self (1 - reflectionProduct N x y)).trans (reflectionProduct_endpoint_bound hy hx) + exact (mul_le_mul_of_nonneg_right hp (density_pos hy).le).trans_eq (mul_assoc _ _ _)) + unfold expectation + rw [← mul_div_assoc, ← integral_const_mul] + exact div_le_div_of_nonneg_right hi (normalizer_pos N).le + +theorem measurable_momentIntegrand (N : ℕ) : Measurable (momentIntegrand N) := by + have hm : StronglyMeasurable (Function.uncurry + (fun x (y : Fin N → ℝ) => reflectionProduct N x y * density N y)) := by + exact ((measurable_reflectionProduct N).mul ((measurable_density N).comp measurable_snd)).stronglyMeasurable + have hi := hm.integral_prod_right (ν := volume.restrict (orderedDomain N)) + exact ((measurable_const.sub (hi.measurable.div_const (normalizer N))).mul measurable_omega).div measurable_id + +theorem momentIntegrand_bounds (N : ℕ) {x : ℝ} (hx : x ∈ Ioo 0 1) : + 0 ≤ momentIntegrand N x ∧ momentIntegrand N x ≤ + expectation N (inverseHalfSum N) * x ^ (-(3 / 4 : ℝ)) := by + have hb := expected_deficit_bounds N hx.1 + have hE : 0 ≤ expectation N (inverseHalfSum N) := by + apply expectation_nonneg + intro y hy + exact Finset.sum_nonneg fun i _ => (Real.rpow_pos_of_pos (hy.2 i).1 _).le + constructor + · exact div_nonneg (mul_nonneg hb.1 (omega_nonneg x)) hx.1.le + · have hpow : Real.sqrt x * x ^ (-(1 / 4 : ℝ)) / x = x ^ (-(3 / 4 : ℝ)) := by + rw [Real.sqrt_eq_rpow, ← Real.rpow_add hx.1] + calc + x ^ (1 / 2 + -(1 / 4) : ℝ) / x = x ^ (1 / 4 : ℝ) / x ^ (1 : ℝ) := by norm_num + _ = x ^ ((1 / 4 : ℝ) - 1) := (Real.rpow_sub hx.1 _ _).symm + _ = _ := by norm_num + calc + momentIntegrand N x ≤ (Real.sqrt x * expectation N (inverseHalfSum N)) * omega x / x := + div_le_div_of_nonneg_right (mul_le_mul_of_nonneg_right hb.2 (omega_nonneg x)) hx.1.le + _ ≤ (Real.sqrt x * expectation N (inverseHalfSum N)) * x ^ (-(1 / 4 : ℝ)) / x := + div_le_div_of_nonneg_right (mul_le_mul_of_nonneg_left (omega_le_rpow hx) + (mul_nonneg (Real.sqrt_nonneg x) hE)) hx.1.le + _ = expectation N (inverseHalfSum N) * (Real.sqrt x * x ^ (-(1 / 4 : ℝ)) / x) := by ring + _ = _ := by rw [hpow] + + +theorem integrableOn_momentIntegrand (N : ℕ) : + IntegrableOn (momentIntegrand N) (Ioo 0 1) := by + have hp : IntegrableOn (fun x : ℝ => x ^ (-(3 / 4 : ℝ))) (Ioo 0 1) := + (intervalIntegral.integrableOn_Ioo_rpow_iff (by norm_num : (0 : ℝ) < 1)).2 (by norm_num) + apply (hp.const_mul (expectation N (inverseHalfSum N))).mono' + (measurable_momentIntegrand N).aestronglyMeasurable + filter_upwards [ae_restrict_mem measurableSet_Ioo] with x hx + rw [Real.norm_eq_abs, abs_of_nonneg (momentIntegrand_bounds N hx).1] + exact (momentIntegrand_bounds N hx).2 + +end GramBounds + +section CauchyAlternants +open Matrix + + +def cauchyMatrix {n : ℕ} (x y : Fin n → ℝ) : Matrix (Fin n) (Fin n) ℝ := Matrix.of fun i j => 1 / (x i + y j) + +theorem det_cauchyMatrix_pos {n : ℕ} (x y : Fin n → ℝ) + (hx : StrictMono x) (hy : StrictMono y) (hx0 : ∀ i, 0 < x i) (hy0 : ∀ i, 0 < y i) : + 0 < (cauchyMatrix x y).det := by + induction n with + | zero => simp [Matrix.det_isEmpty] + | succ n ih => + let A : Matrix (Fin (n+1)) (Fin (n+1)) ℝ := cauchyMatrix x y + let B : Matrix (Fin (n+1)) (Fin (n+1)) ℝ := + Matrix.of fun i j => if i = 0 then A i j else A i j - (x 0 + y 0) / (x i + y 0) * A 0 j + have hAB : A.det = B.det := by + apply Matrix.det_eq_of_forall_row_eq_smul_add_const + (fun i => if i = 0 then 0 else (x 0 + y 0) / (x i + y 0)) 0 + · simp + · intro i j + by_cases hi : i = 0 + · simp [hi, B] + · simp only [B, Matrix.of_apply, hi, ite_false, ite_true] + ring + have hB0 (i : Fin n) : B i.succ 0 = 0 := by + simp only [B, Matrix.of_apply, Fin.succ_ne_zero, ite_false, A, cauchyMatrix] + have hsum (i j) : x i + y j ≠ 0 := (add_pos (hx0 i) (hy0 j)).ne' + field_simp [hsum] + ring + let r : Fin n → ℝ := fun i => (x i.succ - x 0) / (x i.succ + y 0) + let s : Fin n → ℝ := fun j => (y j.succ - y 0) / (x 0 + y j.succ) + have htail : B.submatrix Fin.succ Fin.succ = + Matrix.of (fun i j : Fin n => r i * (s j * cauchyMatrix (x ∘ Fin.succ) (y ∘ Fin.succ) i j)) := by + apply Matrix.ext + intro i j + change 1 / (x i.succ + y j.succ) - + (x 0 + y 0) / (x i.succ + y 0) * (1 / (x 0 + y j.succ)) = + ((x i.succ - x 0) / (x i.succ + y 0)) * + (((y j.succ - y 0) / (x 0 + y j.succ)) * (1 / (x i.succ + y j.succ))) + have hsum (i j) : x i + y j ≠ 0 := (add_pos (hx0 i) (hy0 j)).ne' + field_simp [hsum] + ring + have hdetB : B.det = A 0 0 * (B.submatrix Fin.succ Fin.succ).det := by + rw [Matrix.det_succ_column_zero, Fin.sum_univ_succ] + simp only [Fin.val_zero, pow_zero, one_mul, Fin.succAbove_zero] + simp [hB0, show B 0 0 = A 0 0 by simp [B]] + have hscale : (Matrix.of (fun i j : Fin n => r i * (s j * cauchyMatrix (x ∘ Fin.succ) (y ∘ Fin.succ) i j))).det = + (∏ i, r i) * ((∏ j, s j) * (cauchyMatrix (x ∘ Fin.succ) (y ∘ Fin.succ)).det) := by + calc + _ = (∏ i, r i) * (Matrix.of (fun i j => s j * cauchyMatrix (x ∘ Fin.succ) (y ∘ Fin.succ) i j)).det := by + simpa only [Matrix.of_apply] using Matrix.det_mul_column r + (Matrix.of fun i j => s j * cauchyMatrix (x ∘ Fin.succ) (y ∘ Fin.succ) i j) + _ = _ := by rw [Matrix.det_mul_row] + change 0 < A.det + rw [hAB, hdetB, htail, hscale] + apply mul_pos + · exact one_div_pos.2 (add_pos (hx0 _) (hy0 _)) + · apply mul_pos + · exact Finset.prod_pos fun i _ => div_pos (sub_pos.2 (hx (Fin.succ_pos i))) (add_pos (hx0 _) (hy0 _)) + · apply mul_pos + · exact Finset.prod_pos fun i _ => div_pos (sub_pos.2 (hy (Fin.succ_pos i))) (add_pos (hx0 _) (hy0 _)) + · exact ih _ _ (hx.comp (Fin.strictMono_succ)) (hy.comp (Fin.strictMono_succ)) + (fun i => hx0 i.succ) (fun i => hy0 i.succ) + +theorem det_vandermonde_pos {n : ℕ} (x : Fin n → ℝ) (hx : StrictMono x) : + 0 < (Matrix.vandermonde x).det := by + rw [Matrix.det_vandermonde] + apply Finset.prod_pos + intro i _ + apply Finset.prod_pos + intro j hj + exact sub_pos.2 (hx (Finset.mem_Ioi.1 hj)) + +def cauchyAlternant {n : ℕ} (x y : Fin n → ℝ) : ℝ := + (Matrix.vandermonde x).det * (cauchyMatrix x y).det * (Matrix.vandermonde y).det + + theorem cauchyAlternant_pos {n : ℕ} (x y : Fin n → ℝ) + (hx : StrictMono x) (hy : StrictMono y) (hx0 : ∀ i, 0 < x i) (hy0 : ∀ i, 0 < y i) : + 0 < cauchyAlternant x y := + mul_pos (mul_pos (det_vandermonde_pos x hx) (det_cauchyMatrix_pos x y hx hy hx0 hy0)) + (det_vandermonde_pos y hy) + + theorem cauchyAlternant_permute {n : ℕ} (x y : Fin n → ℝ) (σ τ : Equiv.Perm (Fin n)) : + cauchyAlternant (x ∘ σ) (y ∘ τ) = cauchyAlternant x y := by + have hV (v : Fin n → ℝ) (p : Equiv.Perm (Fin n)) : + (Matrix.vandermonde (v ∘ p)).det = (p.sign : ℝ) * (Matrix.vandermonde v).det := by + have heq : Matrix.vandermonde (v ∘ p) = (Matrix.vandermonde v).submatrix p id := rfl + rw [heq, Matrix.det_permute] + have hC : cauchyMatrix (x ∘ σ) (y ∘ τ) = (cauchyMatrix x y).submatrix σ τ := rfl + unfold cauchyAlternant + rw [hV, hV, hC] + have hCdet : ((cauchyMatrix x y).submatrix σ τ).det = + (σ.sign : ℝ) * ((τ.sign : ℝ) * (cauchyMatrix x y).det) := by + have heq : (cauchyMatrix x y).submatrix σ τ = + ((cauchyMatrix x y).submatrix id τ).submatrix σ id := rfl + rw [heq, Matrix.det_permute, Matrix.det_permute'] + rw [hCdet] + have hs (p : Equiv.Perm (Fin n)) : (p.sign : ℝ) * (p.sign : ℝ) = 1 := by + norm_cast + simp [Int.units_mul_self] + calc + _ = ((σ.sign : ℝ) * (σ.sign : ℝ)) * ((τ.sign : ℝ) * (τ.sign : ℝ)) * + ((Matrix.vandermonde x).det * (cauchyMatrix x y).det * (Matrix.vandermonde y).det) := by ring + _ = _ := by rw [hs, hs]; ring + + theorem cauchyAlternant_nonneg {n : ℕ} (x y : Fin n → ℝ) + (hx0 : ∀ i, 0 < x i) (hy0 : ∀ i, 0 < y i) : 0 ≤ cauchyAlternant x y := by + by_cases hx : Function.Injective x + · by_cases hy : Function.Injective y + · have hxs : StrictMono (x ∘ Tuple.sort x) := + (Tuple.monotone_sort x).strictMono_of_injective (hx.comp (Tuple.sort x).injective) + have hys : StrictMono (y ∘ Tuple.sort y) := + (Tuple.monotone_sort y).strictMono_of_injective (hy.comp (Tuple.sort y).injective) + rw [← cauchyAlternant_permute x y (Tuple.sort x) (Tuple.sort y)] + exact (cauchyAlternant_pos _ _ hxs hys (fun i => hx0 _) (fun i => hy0 _)).le + · have hz : (Matrix.vandermonde y).det = 0 := by + by_contra h + exact hy (Matrix.det_vandermonde_ne_zero_iff.1 h) + simp [cauchyAlternant, hz] + · have hz : (Matrix.vandermonde x).det = 0 := by + by_contra h + exact hx (Matrix.det_vandermonde_ne_zero_iff.1 h) + simp [cauchyAlternant, hz] + +end CauchyAlternants + +section DeterminantIntegration +open MeasureTheory Matrix + +variable {n : Type*} [Fintype n] [DecidableEq n] +variable {α : Type*} [MeasurableSpace α] {μ : Measure α} [SigmaFinite μ] + + theorem integrable_det_columns (F : n → n → α → ℝ) + (hF : ∀ i j, Integrable (F i j) μ) : + Integrable (fun x : n → α => (Matrix.of fun i j => F i j (x j)).det) (Measure.pi fun _ => μ) := by + simp_rw [Matrix.det_apply', Matrix.of_apply] + apply integrable_finsetSum + intro σ _ + exact (Integrable.fintype_prod fun j => hF (σ j) j).const_mul _ + + theorem integral_det_columns (F : n → n → α → ℝ) + (hF : ∀ i j, Integrable (F i j) μ) : + (∫ x : n → α, (Matrix.of fun i j => F i j (x j)).det ∂Measure.pi (fun _ => μ)) = + (Matrix.of fun i j => ∫ t, F i j t ∂μ).det := by + simp_rw [Matrix.det_apply', Matrix.of_apply] + rw [integral_finsetSum] + · apply Finset.sum_congr rfl + intro σ _ + rw [integral_const_mul, integral_fintype_prod_eq_prod] + · intro σ _ + exact (Integrable.fintype_prod fun j => hF (σ j) j).const_mul _ + +theorem integrable_det_mul_det (f g : n → α → ℝ) + (hfg : ∀ i j, Integrable (fun t => f i t * g j t) μ) : + Integrable (fun x : n → α => (Matrix.of fun i j => f i (x j)).det * + (Matrix.of fun i j => g i (x j)).det) (Measure.pi fun _ => μ) := by + classical + let H : Equiv.Perm n → (n → α) → ℝ := fun σ x => + (Matrix.of fun i j => f (σ j) (x j) * g i (x j)).det + have hH (σ : Equiv.Perm n) : Integrable (H σ) (Measure.pi fun _ => μ) := by + exact integrable_det_columns (fun i j t => f (σ j) t * g i t) (fun i j => hfg _ _) + have hexpand (x : n → α) : + (Matrix.of fun i j => f i (x j)).det * (Matrix.of fun i j => g i (x j)).det = + ∑ σ : Equiv.Perm n, (Equiv.Perm.sign σ : ℝ) * H σ x := by + rw [Matrix.det_apply', Finset.sum_mul] + apply Finset.sum_congr rfl + intro σ _ + dsimp [H] + have hscale := Matrix.det_mul_row (fun j => f (σ j) (x j)) + (Matrix.of fun i j => g i (x j)) + simp only [Matrix.of_apply] at hscale + rw [hscale, mul_assoc] + simp_rw [hexpand] + exact integrable_finsetSum _ fun σ _ => (hH σ).const_mul _ + + + +theorem integral_det_mul_det (f g : n → α → ℝ) + (hfg : ∀ i j, Integrable (fun t => f i t * g j t) μ) : + (∫ x : n → α, (Matrix.of fun i j => f i (x j)).det * + (Matrix.of fun i j => g i (x j)).det ∂Measure.pi (fun _ => μ)) = + (Fintype.card (Equiv.Perm n) : ℝ) * + (Matrix.of fun i j => ∫ t, f i t * g j t ∂μ).det := by + classical + let H : Equiv.Perm n → (n → α) → ℝ := fun σ x => + (Matrix.of fun i j => f (σ j) (x j) * g i (x j)).det + have hH (σ : Equiv.Perm n) : Integrable (H σ) (Measure.pi fun _ => μ) := by + exact integrable_det_columns (fun i j t => f (σ j) t * g i t) (fun i j => hfg _ _) + have hexpand (x : n → α) : + (Matrix.of fun i j => f i (x j)).det * (Matrix.of fun i j => g i (x j)).det = + ∑ σ : Equiv.Perm n, (Equiv.Perm.sign σ : ℝ) * H σ x := by + rw [Matrix.det_apply', Finset.sum_mul] + apply Finset.sum_congr rfl + intro σ _ + dsimp [H] + have hscale := Matrix.det_mul_row (fun j => f (σ j) (x j)) + (Matrix.of fun i j => g i (x j)) + simp only [Matrix.of_apply] at hscale + rw [hscale, mul_assoc] + have hI (σ : Equiv.Perm n) : + (∫ x, H σ x ∂Measure.pi (fun _ => μ)) = + (Equiv.Perm.sign σ : ℝ) * (Matrix.of fun i j => ∫ t, f i t * g j t ∂μ).det := by + rw [integral_det_columns _ (fun i j => hfg (σ j) i)] + have hmat : (Matrix.of fun i j => ∫ t, f (σ j) t * g i t ∂μ) = + (Matrix.of fun i j => ∫ t, f i t * g j t ∂μ).transpose.submatrix id σ := rfl + rw [hmat, Matrix.det_permute', Matrix.det_transpose] + simp_rw [hexpand] + rw [integral_finsetSum _ (fun σ _ => (hH σ).const_mul _)] + simp_rw [integral_const_mul, hI, ← mul_assoc] + have hsign (σ : Equiv.Perm n) : (Equiv.Perm.sign σ : ℝ) * (Equiv.Perm.sign σ : ℝ) = 1 := by + norm_cast + simp [Int.units_mul_self] + simp_rw [hsign, one_mul] + simp + +end DeterminantIntegration + +open Set MeasureTheory Matrix + + + +def boundedCauchy (x y : ℝ) : ℝ := x / (x + y) +def momentBasis (k : ℕ) (x : ℝ) : ℝ := x ^ k * omega x +def transformedBasis (k : ℕ) (x : ℝ) : ℝ := + ∫ y in Ioo (0 : ℝ) 1, boundedCauchy x y * momentBasis k y + +def momentMatrix (N : ℕ) : Matrix (Fin N) (Fin N) ℝ := + Matrix.of fun i j => ∫ x in Ioo (0 : ℝ) 1, momentBasis i.val x * transformedBasis j.val x + +theorem momentBasis_bounds (k : ℕ) {x : ℝ} (hx : x ∈ Ioo 0 1) : + 0 ≤ momentBasis k x ∧ momentBasis k x ≤ omega x := by + constructor + · exact mul_nonneg (pow_nonneg hx.1.le _) (omega_nonneg _) + · exact mul_le_of_le_one_left (omega_nonneg _) (pow_le_one₀ hx.1.le hx.2.le) + +theorem measurable_momentBasis (k : ℕ) : Measurable (momentBasis k) := + (measurable_id.pow_const k).mul measurable_omega + +theorem integrableOn_momentBasis (k : ℕ) : IntegrableOn (momentBasis k) (Ioo 0 1) := by + apply integrableOn_omega.mono' (measurable_momentBasis k).aestronglyMeasurable + filter_upwards [ae_restrict_mem measurableSet_Ioo] with x hx + simpa only [Real.norm_eq_abs, abs_of_nonneg (momentBasis_bounds k hx).1] using + (momentBasis_bounds k hx).2 + +theorem boundedCauchy_bounds {x y : ℝ} (hx : 0 < x) (hy : 0 < y) : + 0 < boundedCauchy x y ∧ boundedCauchy x y ≤ 1 := by + constructor + · exact div_pos hx (add_pos hx hy) + · exact (div_le_one (add_pos hx hy)).2 (by linarith) + +theorem integrableOn_boundedCauchy_basis (k : ℕ) {x : ℝ} (hx : 0 < x) : + IntegrableOn (fun y => boundedCauchy x y * momentBasis k y) (Ioo 0 1) := by + have hm : Measurable (fun y => boundedCauchy x y * momentBasis k y) := by + exact ((measurable_const.div (measurable_const.add measurable_id))).mul (measurable_momentBasis k) + apply (integrableOn_momentBasis k).mono' hm.aestronglyMeasurable + filter_upwards [ae_restrict_mem measurableSet_Ioo] with y hy + have hk := boundedCauchy_bounds hx hy.1 + have hb := momentBasis_bounds k hy + rw [Real.norm_eq_abs, abs_of_nonneg (mul_nonneg hk.1.le hb.1)] + exact mul_le_of_le_one_left hb.1 hk.2 + +theorem transformedBasis_bounds (k : ℕ) {x : ℝ} (hx : 0 < x) : + 0 ≤ transformedBasis k x ∧ transformedBasis k x ≤ ∫ y in Ioo (0 : ℝ) 1, omega y := by + constructor + · apply integral_nonneg_of_ae + filter_upwards [ae_restrict_mem measurableSet_Ioo] with y hy + exact mul_nonneg (boundedCauchy_bounds hx hy.1).1.le (momentBasis_bounds k hy).1 + · apply integral_mono_ae (integrableOn_boundedCauchy_basis k hx) integrableOn_omega + filter_upwards [ae_restrict_mem measurableSet_Ioo] with y hy + exact (mul_le_of_le_one_left (momentBasis_bounds k hy).1 + (boundedCauchy_bounds hx hy.1).2).trans (momentBasis_bounds k hy).2 + +theorem measurable_transformedBasis (k : ℕ) : Measurable (transformedBasis k) := by + have hm : StronglyMeasurable (Function.uncurry (fun x y => boundedCauchy x y * momentBasis k y)) := by + exact ((measurable_fst.div (measurable_fst.add measurable_snd)).mul + ((measurable_momentBasis k).comp measurable_snd)).stronglyMeasurable + exact (hm.integral_prod_right (ν := volume.restrict (Ioo (0 : ℝ) 1))).measurable + +theorem integrableOn_basis_transformedBasis (i j : ℕ) : + IntegrableOn (fun x => momentBasis i x * transformedBasis j x) (Ioo 0 1) := by + apply (integrableOn_omega.mul_const (∫ y in Ioo (0 : ℝ) 1, omega y)).mono' + ((measurable_momentBasis i).mul (measurable_transformedBasis j)).aestronglyMeasurable + filter_upwards [ae_restrict_mem measurableSet_Ioo] with x hx + have hb := momentBasis_bounds i hx + have ht := transformedBasis_bounds j hx.1 + simp only [Pi.mul_apply, Real.norm_eq_abs, abs_of_nonneg (mul_nonneg hb.1 ht.1)] + exact mul_le_mul hb.2 ht.2 ht.1 (omega_nonneg _) + +def basisDet (N : ℕ) (x : Fin N → ℝ) : ℝ := + (Matrix.of fun i j : Fin N => momentBasis i.val (x j)).det + +def transformedDet (N : ℕ) (x : Fin N → ℝ) : ℝ := + (Matrix.of fun i j : Fin N => transformedBasis i.val (x j)).det + +end +end CriticalStrip + +end OAI diff --git a/lean/OAI/Combinatorics/StripMass/DeformationWeights.lean b/lean/OAI/Combinatorics/StripMass/DeformationWeights.lean new file mode 100644 index 0000000000000000000000000000000000000000..87d05de361f6f11f47e3d2d53468fbfca6055bed --- /dev/null +++ b/lean/OAI/Combinatorics/StripMass/DeformationWeights.lean @@ -0,0 +1,457 @@ +import Mathlib +import OAI.Combinatorics.StripMass.HoneycombDictionary +import OAI.Combinatorics.StripMass.MonicPositive +import OAI.Combinatorics.StripMass.AugmentedColumn + +namespace OAI + +/-! Critical honeycomb strip paths, polynomial identities and crossing mass. -/ + + +namespace CriticalStrip.Diagram +noncomputable section +open _root_.Matrix _root_.OAI.Matrix Set +open scoped BigOperators Classical + +lemma lambda_pos : 0 apply Real.sin_pos_of_pos_of_lt_pi <;> + unfold lambda at * <;> linarith [ht.1,ht.2,Real.pi_pos] + +lemma physicalWeights_deformation_pos {t : ℝ} (ht : t∈Ioc 0 lambda) : + 0<(physicalWeights (3*lambda-t)).A ∧ 0<(physicalWeights (3*lambda-t)).B ∧ + 0<(physicalWeights (3*lambda-t)).U := by + have hL:=L_deformation_pos ⟨ht.1.le,ht.2⟩ + have hd : 0 unfold lambda <;> linarith [Real.pi_pos] + have ht₀ : 0 unfold lambda at * <;> linarith [ht.1,ht.2,Real.pi_pos] + unfold physicalWeights + dsimp only + rw [show 3*lambda-(3*lambda-t)=t by ring] + exact ⟨div_pos (mul_pos hd ht₀) hL,div_pos (mul_pos hs ht₀) hL,div_pos (mul_pos hd hs) hL⟩ + +lemma physicalWeights_deformation_tile_nonneg {t : ℝ} (ht : t∈Icc 0 lambda) + (s : Tile) (hs : ¬s.Occupied 0) : 0<(physicalWeights (3*lambda-t)).U ∧ + 0≤(physicalWeights (3*lambda-t)).tile s := by + rcases eq_or_lt_of_le ht.1 with rfl | ht₀ + · rw [sub_zero,physicalWeights_three_lambda] + constructor + · norm_num [deletionWeights] + · cases s <;> norm_num [deletionWeights,Weights.tile] + · obtain ⟨hA,hB,hU⟩:=physicalWeights_deformation_pos ⟨ht₀,ht.2⟩ + refine ⟨hU,?_⟩ + cases s <;> simp_all [Tile.Occupied,Tile.Adj,Tile.edges,Weights.tile] + any_goals positivity + +lemma physicalWeights_two_lambda_nonneg (s : Tile) : 0≤(physicalWeights (2*lambda)).tile s := by + rw [physicalWeights_two_lambda] + have hrho : 0 simp only [Weights.tile] <;> positivity + +lemma physicalWeights_two_lambda_pos : + 0<(physicalWeights (2*lambda)).A ∧ 0<(physicalWeights (2*lambda)).B ∧ + 0<(physicalWeights (2*lambda)).U := by + have hh:=physicalWeights_deformation_pos (t:=lambda) ⟨lambda_pos,le_rfl⟩ + simpa only [show 3*lambda-lambda=2*lambda by ring] using hh + +lemma northInjection_nonneg (s : Tile) : 0≤(northInjectionWeights : Weights ℝ).tile s := by + cases s <;> norm_num [northInjectionWeights,Weights.tile] + + +def augmentedPhysicalWeights (n : ℕ) : Fin (n+1) → Weights ℝ := + Fin.snoc (fun _ : Fin n=>physicalWeights (2*lambda)) northInjectionWeights + +def deformationAngles (n : ℕ) (t : ℝ) : Fin (n+1) → ℝ := Fin.cons t (fun _=>lambda) + +def deformationWeights (n : ℕ) (t : ℝ) : Fin (n+1+1) → Weights ℝ := + Fin.cons (physicalWeights (3*lambda-t)) (augmentedPhysicalWeights n) + +lemma deformationWeights_eq (n : ℕ) (t : ℝ) : + deformationWeights n t=Fin.snoc + (fun i=>physicalWeights (3*lambda-deformationAngles n t i)) northInjectionWeights := by + funext i + refine Fin.cases ?_ (fun j=>?_) i + · change physicalWeights (3*lambda-t)= + (Fin.snoc (fun i : Fin (n+1)=>physicalWeights (3*lambda-deformationAngles n t i)) + northInjectionWeights : Fin (n+1+1) → Weights ℝ) ((0 : Fin (n+1)).castSucc) + rw [Fin.snoc_castSucc] + rfl + · rw [deformationWeights,Fin.cons_succ] + refine Fin.lastCases ?_ (fun j=>?_) j + · rw [augmentedPhysicalWeights,Fin.snoc_last,Fin.succ_last,Fin.snoc_last] + · rw [augmentedPhysicalWeights,Fin.snoc_castSucc,Fin.succ_castSucc,Fin.snoc_castSucc] + simp only [deformationAngles,Fin.cons_succ,show 3*lambda-lambda=2*lambda by ring] + +lemma deformationWeights_physical (n : ℕ) : deformationWeights n lambda=augmentedPhysicalWeights (n+1) := by + rw [deformationWeights_eq] + congr 1 + funext i + refine Fin.cases ?_ (fun j=>?_) i <;> + simp only [deformationAngles,Fin.cons_zero,Fin.cons_succ,show 3*lambda-lambda=2*lambda by ring] + +lemma deformationWeights_flat (n : ℕ) : deformationWeights n 0 0=deletionWeights := by + simp [deformationWeights,physicalWeights_three_lambda] + +lemma augmentedPhysical_tile_nonneg (n : ℕ) (i : Fin (n+1)) (s : Tile) : + 0≤(augmentedPhysicalWeights n i).tile s := by + refine Fin.lastCases ?_ (fun j=>?_) i + · simpa only [augmentedPhysicalWeights,Fin.snoc_last] using northInjection_nonneg s + · simpa only [augmentedPhysicalWeights,Fin.snoc_castSucc] using physicalWeights_two_lambda_nonneg s + +lemma deformationWeights_nonnegative (n : ℕ) {t : ℝ} (ht : t∈Icc 0 lambda) : + ColumnNonnegative (deformationWeights n t) := by + intro p q s hs + apply Finset.prod_nonneg + intro i _ + refine Fin.cases ?_ (fun j=>?_) i + · exact (physicalWeights_deformation_tile_nonneg ht (s 0) (hs.south 0 rfl)).2 + · exact augmentedPhysical_tile_nonneg n j (s j.succ) + +lemma deformationWeights_accessible (n : ℕ) {t : ℝ} (ht : t∈Ioc 0 lambda) : + PositiveMatrix.Accessible (restrictedColumn (deformationWeights n t)) + (injectionColumn (deformationWeights n t)) := by + apply column_accessible _ (deformationWeights_nonnegative n ⟨ht.1.le,ht.2⟩) + · intro i + refine Fin.cases ?_ (fun j=>?_) i + · exact (physicalWeights_deformation_pos ht).1 + · refine Fin.lastCases ?_ (fun j=>?_) j + · norm_num [deformationWeights,augmentedPhysicalWeights,northInjectionWeights] + · simpa only [deformationWeights,Fin.cons_succ,augmentedPhysicalWeights,Fin.snoc_castSucc] + using physicalWeights_two_lambda_pos.1 + · intro i + refine Fin.cases ?_ (fun j=>?_) i + · exact (physicalWeights_deformation_pos ht).2.1 + · refine Fin.lastCases ?_ (fun j=>?_) j + · norm_num [deformationWeights,augmentedPhysicalWeights,northInjectionWeights] + · simpa only [deformationWeights,Fin.cons_succ,augmentedPhysicalWeights,Fin.snoc_castSucc] + using physicalWeights_two_lambda_pos.2.1 + · intro i hi + revert hi + refine Fin.cases ?_ (fun j=>?_) i + · intro _; exact (physicalWeights_deformation_pos ht).2.2 + · revert j + apply Fin.lastCases + · intro hh + simp only [Fin.val_succ,Fin.val_last] at hh + omega + · intro j _ + simpa only [deformationWeights,Fin.cons_succ,augmentedPhysicalWeights,Fin.snoc_castSucc] + using physicalWeights_two_lambda_pos.2.2 + +lemma deformationAngles_scalar_ne_zero (n : ℕ) {t : ℝ} (ht : t∈Icc 0 lambda) : + angleScalar (deformationAngles n t)≠0 := by + rw [angleScalar,angleEvaluation_scalar] + have he : (fun i=>(Real.cos (2*deformationAngles n t i-3*lambda):ℂ))= + Fin.cons (Real.cos (2*t-3*lambda):ℂ) (fun _ : Fin n=>(C:ℂ)) := by + funext i + refine Fin.cases ?_ (fun j=>?_) i + · rfl + · simp only [deformationAngles,Fin.cons_succ,show 2*lambda-3*lambda= -lambda by ring,Real.cos_neg,C] + rw [he] + have hg:=scalarValue_extract (RingHom.id ℂ) + (Fin.snoc (fun _ : Fin n=>(C:ℂ)) (Real.cos (2*t-3*lambda):ℂ)) (Fin.last n) + simp only [Fin.snoc_last,Fin.succAbove_last,Fin.snoc_castSucc] at hg + rw [←hg] + exact scalarValue_deformation_ne_zero n (cosine_deformation ht) + +lemma deformationAngles_L_ne_zero (n : ℕ) {t : ℝ} (ht : t∈Icc 0 lambda) + (i : Fin (n+1)) : L (3*lambda-deformationAngles n t i)≠0 := by + refine Fin.cases ?_ (fun j=>?_) i + · exact (L_deformation_pos ht).ne' + · exact (L_deformation_pos (t:=lambda) ⟨lambda_pos.le,le_rfl⟩).ne' + +lemma deformationWeights_stationary (n : ℕ) {t : ℝ} (ht : t∈Icc 0 lambda) : + (restrictedColumn (deformationWeights n t)).mulVec (fun p=>angleAugmented (deformationAngles n t) p.val)+ + injectionColumn (deformationWeights n t)=fun p=>angleAugmented (deformationAngles n t) p.val := by + rw [deformationWeights_eq] + exact angleAugmented_restricted_stationary _ (deformationAngles_L_ne_zero n ht) + (deformationAngles_scalar_ne_zero n ht) + + + + + + + +lemma continuousOn_column {α : Type*} [TopologicalSpace α] {S : Set α} {n : ℕ} + (w : α → Fin n → Weights ℝ) (hw : ∀i s,ContinuousOn (fun t=>(w t i).tile s) S) : + ContinuousOn (fun t=>column (w t)) S := by + apply continuousOn_pi.mpr + intro p + apply continuousOn_pi.mpr + intro q + unfold column + apply continuousOn_finsetSum + intro s _ + by_cases hs : Realizes q p s + · simp only [ite_eq_left hs] + exact continuousOn_finsetProd _ (fun i _=>hw i (s i)) + · simp only [ite_eq_right hs] + exact continuousOn_const + +lemma continuousOn_deformationWeights_tile (n : ℕ) (i : Fin (n+1+1)) (s : Tile) : + ContinuousOn (fun t=>(deformationWeights n t i).tile s) (Icc 0 lambda) := by + refine Fin.cases ?_ (fun j=>?_) i + · change ContinuousOn (fun t=>(physicalWeights (3*lambda-t)).tile s) (Icc 0 lambda) + cases s <;> simp only [physicalWeights,Weights.tile] + · exact continuousOn_const + all_goals + apply ContinuousOn.div + · fun_prop + · unfold L; fun_prop + · exact fun t ht=>(L_deformation_pos ht).ne' + · change ContinuousOn (fun _ : ℝ=>(augmentedPhysicalWeights n j).tile s) (Icc 0 lambda) + exact continuousOn_const + +lemma continuousOn_deformationColumn (n : ℕ) : + ContinuousOn (fun t=>restrictedColumn (deformationWeights n t)) (Icc 0 lambda) := by + have hh:=continuousOn_column (deformationWeights n) (continuousOn_deformationWeights_tile n) + apply continuousOn_pi.mpr + intro p + apply continuousOn_pi.mpr + intro q + exact continuousOn_pi.mp (continuousOn_pi.mp hh p.val) q.val + +lemma continuous_deformationAngles (n : ℕ) : Continuous (deformationAngles n) := by + apply continuous_pi + intro i + refine Fin.cases ?_ (fun j=>?_) i + · exact continuous_id + · exact continuous_const + +lemma continuousOn_deformationVector (n : ℕ) : + ContinuousOn (fun t=>fun p : NonemptyPairing (n+1+1)=>angleAugmented (deformationAngles n t) p.val) + (Icc 0 lambda) := by + have hc:=continuousOn_angleAugmented (S:=deformationAngles n '' Icc 0 lambda) (by + rintro u ⟨t,ht,rfl⟩ + exact deformationAngles_scalar_ne_zero n ht) + have hh:=hc.comp (continuous_deformationAngles n).continuousOn (fun t ht=>⟨t,ht,rfl⟩) + apply continuousOn_pi.mpr + intro p + exact continuousOn_pi.mp hh p.val + +lemma summablePowers_flat_bottom {n : ℕ} (w : Fin (n+1) → Weights ℝ) + (hzero : w 0=deletionWeights) (hw : ColumnNonnegative w) + (hs : PositiveMatrix.SummablePowers (restrictedColumn (fun i=>w i.succ))) : + PositiveMatrix.SummablePowers (restrictedColumn w) := by + let e:=Pairing.nonemptyBottomSplit n + apply (PositiveMatrix.summablePowers_reindex_iff _ e).mp + apply PositiveMatrix.summablePowers_of_zero_cols + · exact fun i j=>hw.restricted (e i) (e j) + · have he : ((restrictedColumn w).submatrix e e).toBlocks₁₁= + restrictedColumn (fun i=>w i.succ) := by + ext q p + exact column_padBottom w p.val q.val + rw [he] + exact hs + · intro i p + exact column_deletion_bottom_col w hzero p.val.val (e i).val (not_not.mp p.property) + + + +theorem augmentedPhysical_summablePowers (n : ℕ) : + PositiveMatrix.SummablePowers (restrictedColumn (augmentedPhysicalWeights n)) := by + induction n with + | zero => + intro p + exact (p.property (Pairing.eq_empty_of_le_one (by omega) p.val)).elim + | succ n ih => + rw [←deformationWeights_physical] + apply PositiveMatrix.summablePowers_on_Icc + (fun t=>restrictedColumn (deformationWeights n t)) + (fun t=>injectionColumn (deformationWeights n t)) + (fun t=>fun p=>angleAugmented (deformationAngles n t) p.val) + lambda_pos.le (continuousOn_deformationColumn n) (continuousOn_deformationVector n) + (fun t ht=>(deformationWeights_nonnegative n ht).restricted) + (fun t ht=>(deformationWeights_nonnegative n ht).injection) + (fun t ht=>deformationWeights_stationary n ht) + ?_ (fun t ht=>deformationWeights_accessible n ht) + lambda ⟨lambda_pos.le,le_rfl⟩ + apply summablePowers_flat_bottom _ (deformationWeights_flat n) + (deformationWeights_nonnegative n ⟨le_rfl,lambda_pos.le⟩) + simpa only [deformationWeights,Fin.cons_succ] using ih + +end +end CriticalStrip.Diagram + + + + + +namespace CriticalStrip.PositiveMatrix +noncomputable section +open _root_.Matrix _root_.OAI.Matrix +open scoped BigOperators Classical + +variable {ι κ : Type*} + +lemma Nonnegative.submatrix [Fintype ι] [Fintype κ] [DecidableEq ι] [DecidableEq κ] + {Q : Matrix ι ι ℝ} (hQ : Nonnegative Q) (e : κ → ι) : + Nonnegative (Q.submatrix e e) := fun i j=>hQ (e i) (e j) + +variable [Fintype ι] [Fintype κ] [DecidableEq ι] [DecidableEq κ] + +lemma submatrix_pow_le {Q : Matrix ι ι ℝ} (hQ : Nonnegative Q) (e : κ ↪ ι) (k : ℕ) : + ∀i j,((Q.submatrix e e)^k) i j≤(Q^k) (e i) (e j) := by + induction k with + | zero => + intro i j + simp only [pow_zero,Matrix.one_apply,EmbeddingLike.apply_eq_iff_eq] + exact le_rfl + | succ k ih => + intro i j + rw [pow_succ,pow_succ] + calc + _ ≤ ∑l : κ,(Q^k) (e i) (e l)*Q (e l) (e j) := + Finset.sum_le_sum fun l _=>mul_le_mul_of_nonneg_right (ih i l) (hQ (e l) (e j)) + _ = ∑l∈Finset.univ.map e,(Q^k) (e i) l*Q l (e j) := by rw [Finset.sum_map] + _ ≤ _ := Finset.sum_le_sum_of_subset_of_nonneg (Finset.subset_univ _) + (fun l _ _=>mul_nonneg (hQ.pow k _ _) (hQ _ _)) + +lemma SummablePowers.submatrix {Q : Matrix ι ι ℝ} (hs : SummablePowers Q) + (hQ : Nonnegative Q) (e : κ ↪ ι) : SummablePowers (Q.submatrix e e) := by + intro i j + apply (hs (e i) (e j)).of_nonneg_of_le + · intro k + exact (hQ.submatrix e).pow k i j + · intro k + exact submatrix_pow_le hQ e k i j + +lemma SummablePowers.transpose {Q : Matrix ι ι ℝ} (hs : SummablePowers Q) : + SummablePowers Q.transpose := by + intro i j + simpa only [←Matrix.transpose_pow,Matrix.transpose_apply] using hs j i + +lemma summablePowers_of_zero_rows (M : Matrix (ι ⊕ κ) (ι ⊕ κ) ℝ) + (hM : Nonnegative M) (hs : SummablePowers M.toBlocks₁₁) + (hz : ∀i j,M (.inr i) j=0) : SummablePowers M := by + have ht : SummablePowers M.transpose := by + apply summablePowers_of_zero_cols + · exact fun i j=>hM j i + · exact hs.transpose + · intros; apply hz + simpa only [Matrix.transpose_transpose] using ht.transpose + +end +end CriticalStrip.PositiveMatrix + + + + + +namespace CriticalStrip.Diagram +noncomputable section +open _root_.Matrix _root_.OAI.Matrix +open scoped BigOperators Classical + +lemma augmentedPhysical_nonnegative (n : ℕ) : ColumnNonnegative (augmentedPhysicalWeights n) := by + intro p q s hs + exact Finset.prod_nonneg fun i _=>augmentedPhysical_tile_nonneg n i (s i) + + + +def vacuumAugmentEmbedding (n : ℕ) : NonemptyPairing n ↪ NonemptyPairing (n+1) := + (Function.Embedding.trans (.inl) (sourceTopSplit n).toEmbedding) + +def sourceAugmentEmbedding (n : ℕ) : SourcePairing n ↪ NonemptyPairing (n+1) := + (Function.Embedding.trans (.inr) (sourceTopSplit n).toEmbedding) + +lemma augmentedPhysical_vacuum_block (n : ℕ) : + (restrictedColumn (augmentedPhysicalWeights n)).submatrix + (vacuumAugmentEmbedding n) (vacuumAugmentEmbedding n)= + restrictedColumn (fun _ : Fin n=>physicalWeights (2*lambda)) := by + ext q p + simpa only [augmentedPhysicalWeights,Fin.snoc_castSucc,restrictedColumn,Matrix.submatrix_apply, + vacuumAugmentEmbedding,Function.Embedding.trans_apply,Equiv.coe_toEmbedding,Function.Embedding.inl_apply, + sourceTopSplit_inl,Pairing.nonemptyPadTop] using + column_padTop (augmentedPhysicalWeights n) p.val q.val + +lemma augmentedPhysical_source_block (n : ℕ) : + (restrictedColumn (augmentedPhysicalWeights n)).submatrix + (sourceAugmentEmbedding n) (sourceAugmentEmbedding n)= + sourceTransfer (fun _ : Fin n=>(physicalWeights (2*lambda)).tile) := by + ext q p + have hh:=congrFun (congrFun (northInjection_column_blocks + (fun _ : Fin n=>physicalWeights (2*lambda))) (.inr q)) (.inr p) + exact hh + +theorem physical_vacuum_summablePowers (n : ℕ) : + PositiveMatrix.SummablePowers (restrictedColumn (fun _ : Fin n=>physicalWeights (2*lambda))) := by + have hh := (augmentedPhysical_summablePowers n).submatrix + (augmentedPhysical_nonnegative n).restricted (vacuumAugmentEmbedding n) + rw [augmentedPhysical_vacuum_block] at hh + exact hh + +theorem physical_source_summablePowers (n : ℕ) : + PositiveMatrix.SummablePowers (sourceTransfer (fun _ : Fin n=>(physicalWeights (2*lambda)).tile)) := by + have hh := (augmentedPhysical_summablePowers n).submatrix + (augmentedPhysical_nonnegative n).restricted (sourceAugmentEmbedding n) + rw [augmentedPhysical_source_block] at hh + exact hh + +lemma physical_column_nonnegative (n : ℕ) : + ColumnNonnegative (fun _ : Fin n=>physicalWeights (2*lambda)) := by + intro p q s hs + exact Finset.prod_nonneg fun i _=>physicalWeights_two_lambda_nonneg (s i) + +lemma physical_source_nonnegative (n : ℕ) : + PositiveMatrix.Nonnegative (sourceTransfer (fun _ : Fin n=>(physicalWeights (2*lambda)).tile)) := by + rw [←augmentedPhysical_source_block] + exact (augmentedPhysical_nonnegative n).restricted.submatrix _ + +lemma homogeneous_angleScalar_ne_zero (n : ℕ) : angleScalar (fun _ : Fin n=>lambda)≠0 := by + rw [angleScalar,angleEvaluation_scalar] + simpa only [show 2*lambda-3*lambda= -lambda by ring,Real.cos_neg,C] using + scalarValue_homogeneous_ne_zero n + +lemma homogeneous_L_ne_zero : L (3*lambda-lambda)≠0 := + (L_deformation_pos (t:=lambda) ⟨lambda_pos.le,le_rfl⟩).ne' + + + +theorem physical_vacuum_eq_tsum (n : ℕ) (p : NonemptyPairing n) : + angleVacuum (fun _ : Fin n=>lambda) p.val= + ∑' k : ℕ,((restrictedColumn (fun _ : Fin n=>physicalWeights (2*lambda)))^k).mulVec + (injectionColumn (fun _ : Fin n=>physicalWeights (2*lambda))) p := by + apply (physical_vacuum_summablePowers n).stationary_eq_tsum (w:=fun q=>angleVacuum (fun _ : Fin n=>lambda) q.val) (i:=p) + simpa only [show 3*lambda-lambda=2*lambda by ring] using + angleVacuum_restricted_stationary (fun _ : Fin n=>lambda) (fun _=>homogeneous_L_ne_zero) + (homogeneous_angleScalar_ne_zero n) + +theorem physical_vacuum_nonneg (n : ℕ) (p : Pairing n) : + 0≤angleVacuum (fun _ : Fin n=>lambda) p := by + by_cases hp : p=empty n + · rw [hp,angleVacuum_empty _ (homogeneous_angleScalar_ne_zero n)] + exact zero_le_one + · rw [physical_vacuum_eq_tsum n ⟨p,hp⟩] + exact tsum_nonneg fun k=>(physical_column_nonnegative n).restricted.pow k |>.mulVec + (physical_column_nonnegative n).injection _ + + + +theorem physical_northSource_eq_tsum (n : ℕ) (p : SourcePairing n) : + angleNorthSource (fun _ : Fin n=>lambda) p= + ∑' k : ℕ,((sourceTransfer (fun _ : Fin n=>(physicalWeights (2*lambda)).tile))^k).mulVec + ((northSource (fun _ : Fin n=>(physicalWeights (2*lambda)).tile)).mulVec + (angleVacuum (fun _ : Fin n=>lambda))) p := by + apply (physical_source_summablePowers n).stationary_eq_tsum + simpa only [show 3*lambda-lambda=2*lambda by ring] using + angleNorthSource_stationary (fun _ : Fin n=>lambda) (fun _=>homogeneous_L_ne_zero) + + + +theorem physical_source_weighted_summable (n d : ℕ) (p q : SourcePairing n) : + Summable (fun k : ℕ=>(k:ℝ)^d* + ((sourceTransfer (fun _ : Fin n=>(physicalWeights (2*lambda)).tile))^k) p q) := + (physical_source_summablePowers n).weighted (physical_source_nonnegative n) d p q + +end +end CriticalStrip.Diagram + +end OAI diff --git a/lean/OAI/Combinatorics/StripMass/DensityExhaustion.lean b/lean/OAI/Combinatorics/StripMass/DensityExhaustion.lean new file mode 100644 index 0000000000000000000000000000000000000000..6ce6465f47ca9b9414f1b69b1b1d78fdef74ec2f --- /dev/null +++ b/lean/OAI/Combinatorics/StripMass/DensityExhaustion.lean @@ -0,0 +1,433 @@ +import Mathlib +import OAI.Combinatorics.StripMass.PositiveAssociation + +namespace OAI + +/-! Critical honeycomb strip paths, polynomial identities and crossing mass. -/ + + +namespace CriticalStrip +noncomputable section +open scoped BigOperators +open Set MeasureTheory Filter +theorem ordered_density_covariance_exhaustion {N : ℕ} {I : Set ℝ} (l u : ℕ → ℝ) + (hl : ∀ n, 0 < l n) (hlu : ∀ n, l n ≤ u n) + (hm : Monotone (fun n => Icc (l n) (u n))) + (hc : (⋃ n, Icc (l n) (u n)) = I) + (w : Fin N → ℝ → ℝ) (hwc : ∀ i, ContinuousOn (w i) I) + (hw : ∀ i x, x ∈ I → 0 ≤ w i x) + (f g : (Fin N → ℝ) → ℝ) + (hfc : ContinuousOn f (coordinateBox (Fin N) I)) + (hgc : ContinuousOn g (coordinateBox (Fin N) I)) + (hfm : MonotoneOn f (coordinateBox (Fin N) I)) + (hgm : MonotoneOn g (coordinateBox (Fin N) I)) + (hh : IntegrableOn (rawProductDensity N w) (orderedChamber N I)) + (hf : IntegrableOn (fun x => rawProductDensity N w x * f x) (orderedChamber N I)) + (hg : IntegrableOn (fun x => rawProductDensity N w x * g x) (orderedChamber N I)) + (hfg : IntegrableOn (fun x => rawProductDensity N w x * (f x * g x)) (orderedChamber N I)) : + (∫ x in orderedChamber N I, rawProductDensity N w x * f x) * + (∫ x in orderedChamber N I, rawProductDensity N w x * g x) ≤ + (∫ x in orderedChamber N I, rawProductDensity N w x) * + (∫ x in orderedChamber N I, rawProductDensity N w x * (f x * g x)) := by + have hsub (n : ℕ) : Icc (l n) (u n) ⊆ I := hc ▸ subset_iUnion (fun n => Icc (l n) (u n)) n + have hB : (⋃ n, coordinateBox (Fin N) (Icc (l n) (u n))) = coordinateBox (Fin N) I := by + rw [coordinateBox_iUnion_of_monotone hm, hc] + have ht (F : (Fin N → ℝ) → ℝ) + (hi : IntegrableOn (fun x => rawProductDensity N w x * F x) (orderedChamber N I)) : + Tendsto (fun n => ∫ x in coordinateBox (Fin N) (Icc (l n) (u n)), + orderedProductDensity N w x * F x) atTop + (nhds (∫ x in orderedChamber N I, rawProductDensity N w x * F x)) := by + rw [← integral_orderedProductDensity_mul] + have hi' := (integrable_orderedProductDensity_mul_iff I w F).2 hi + rw [← hB] at hi' ⊢ + exact tendsto_setIntegral_of_monotone (fun _ => measurableSet_coordinateBox measurableSet_Icc) + (fun i j hij => coordinateBox_mono (hm hij)) hi' + have hht : Tendsto (fun n => ∫ x in coordinateBox (Fin N) (Icc (l n) (u n)), + orderedProductDensity N w x) atTop + (nhds (∫ x in orderedChamber N I, rawProductDensity N w x)) := by + simpa using ht (fun _ => 1) (by simpa using hh) + exact le_of_tendsto_of_tendsto ((ht f hf).mul (ht g hg)) + (hht.mul (ht (fun x => f x * g x) hfg)) + (Eventually.of_forall fun n => ordered_density_covariance_compact (hl n) (hlu n) w + (fun i => (hwc i).mono (hsub n)) (fun i x hx => hw i x (hsub n hx)) f g + (hfc.mono (coordinateBox_mono (hsub n))) (hgc.mono (coordinateBox_mono (hsub n))) + (hfm.mono (coordinateBox_mono (hsub n))) (hgm.mono (coordinateBox_mono (hsub n)))) + +lemma positiveWindow_mono : Monotone (fun n : ℕ => Icc (1 / (n + 1 : ℝ)) (n + 1 : ℝ)) := by + intro n m hnm x hx + have hnm' : (n : ℝ) ≤ m := Nat.cast_le.mpr hnm + exact ⟨(one_div_le_one_div_of_le (by positivity) (by linarith)).trans hx.1, by linarith [hx.2]⟩ + +lemma positiveWindow_cover : (⋃ n : ℕ, Icc (1 / (n + 1 : ℝ)) (n + 1 : ℝ)) = Ioi (0 : ℝ) := by + ext x + constructor + · intro hx + obtain ⟨n, hn⟩ := mem_iUnion.mp hx + exact (by positivity : (0 : ℝ) < 1 / (n + 1 : ℝ)).trans_le hn.1 + · intro hx + obtain ⟨n, hn⟩ := exists_nat_one_div_lt (show 0 < x from hx) + obtain ⟨m, hm⟩ := exists_nat_gt x + apply mem_iUnion.mpr + refine ⟨max n m, ?_, ?_⟩ + · exact (one_div_le_one_div_of_le (by positivity) + (by exact_mod_cast Nat.add_le_add_right (le_max_left n m) 1)).trans hn.le + · have h : (m : ℝ) ≤ max n m := by exact_mod_cast le_max_right n m + linarith + + + +theorem ordered_density_covariance_Ioi {N : ℕ} (w : Fin N → ℝ → ℝ) + (hwc : ∀ i, ContinuousOn (w i) (Ioi 0)) + (hw : ∀ i x, 0 < x → 0 ≤ w i x) (f g : (Fin N → ℝ) → ℝ) + (hfc : ContinuousOn f (coordinateBox (Fin N) (Ioi 0))) + (hgc : ContinuousOn g (coordinateBox (Fin N) (Ioi 0))) + (hfm : MonotoneOn f (coordinateBox (Fin N) (Ioi 0))) + (hgm : MonotoneOn g (coordinateBox (Fin N) (Ioi 0))) + (hh : IntegrableOn (rawProductDensity N w) (laguerreDomain N)) + (hf : IntegrableOn (fun x => rawProductDensity N w x * f x) (laguerreDomain N)) + (hg : IntegrableOn (fun x => rawProductDensity N w x * g x) (laguerreDomain N)) + (hfg : IntegrableOn (fun x => rawProductDensity N w x * (f x * g x)) (laguerreDomain N)) : + (∫ x in laguerreDomain N, rawProductDensity N w x * f x) * + (∫ x in laguerreDomain N, rawProductDensity N w x * g x) ≤ + (∫ x in laguerreDomain N, rawProductDensity N w x) * + (∫ x in laguerreDomain N, rawProductDensity N w x * (f x * g x)) := by + apply ordered_density_covariance_exhaustion (fun n => 1 / (n + 1 : ℝ)) (fun n => n + 1) + (fun _ => by positivity) (fun n => ?_) positiveWindow_mono positiveWindow_cover + w hwc hw f g hfc hgc hfm hgm hh hf hg hfg + have hn : (1 : ℝ) ≤ n + 1 := by nlinarith [Nat.cast_nonneg (α := ℝ) n] + exact le_trans (one_div_le_one_div_of_le (by norm_num) hn) (by simp) + +lemma boundedWindow_mono {R : ℝ} (hR : 0 ≤ R) : + Monotone (fun n : ℕ => Icc (R / (n + 3 : ℝ)) (R - R / (n + 3 : ℝ))) := by + intro n m hnm x hx + have hnm' : (n : ℝ) ≤ m := Nat.cast_le.mpr hnm + have hd : R / (m + 3 : ℝ) ≤ R / (n + 3 : ℝ) := + div_le_div_of_nonneg_left hR (by positivity) (by linarith) + exact ⟨hd.trans hx.1, by linarith [hx.2]⟩ + +lemma boundedWindow_cover {R : ℝ} (hR : 0 < R) : + (⋃ n : ℕ, Icc (R / (n + 3 : ℝ)) (R - R / (n + 3 : ℝ))) = Ioo 0 R := by + ext x + constructor + · intro hx + obtain ⟨n, hn⟩ := mem_iUnion.mp hx + have hp : 0 < R / (n + 3 : ℝ) := by positivity + exact ⟨hp.trans_le hn.1, by linarith [hn.2]⟩ + · rintro ⟨hx, hxr⟩ + have heps : 0 < min x (R - x) / R := div_pos (lt_min hx (sub_pos.mpr hxr)) hR + obtain ⟨n, hn⟩ := exists_nat_one_div_lt heps + have hsmall : R / (n + 3 : ℝ) < min x (R - x) := by + have hnd : R / (n + 3 : ℝ) ≤ R / (n + 1 : ℝ) := + div_le_div_of_nonneg_left hR.le (by positivity) (by norm_num) + rw [lt_div_iff₀ hR] at hn + have hn' : R / (n + 1 : ℝ) < min x (R - x) := by simpa [div_eq_mul_inv, mul_comm] using hn + exact hnd.trans_lt hn' + exact mem_iUnion.mpr ⟨n, (hsmall.trans_le (min_le_left _ _)).le, + by have h := hsmall.trans_le (min_le_right _ _); linarith⟩ + + + +theorem ordered_density_covariance_Ioo {N : ℕ} {R : ℝ} (hR : 0 < R) + (w : Fin N → ℝ → ℝ) (hwc : ∀ i, ContinuousOn (w i) (Ioo 0 R)) + (hw : ∀ i x, x ∈ Ioo 0 R → 0 ≤ w i x) (f g : (Fin N → ℝ) → ℝ) + (hfc : ContinuousOn f (coordinateBox (Fin N) (Ioo 0 R))) + (hgc : ContinuousOn g (coordinateBox (Fin N) (Ioo 0 R))) + (hfm : MonotoneOn f (coordinateBox (Fin N) (Ioo 0 R))) + (hgm : MonotoneOn g (coordinateBox (Fin N) (Ioo 0 R))) + (hh : IntegrableOn (rawProductDensity N w) (orderedChamber N (Ioo 0 R))) + (hf : IntegrableOn (fun x => rawProductDensity N w x * f x) (orderedChamber N (Ioo 0 R))) + (hg : IntegrableOn (fun x => rawProductDensity N w x * g x) (orderedChamber N (Ioo 0 R))) + (hfg : IntegrableOn (fun x => rawProductDensity N w x * (f x * g x)) (orderedChamber N (Ioo 0 R))) : + (∫ x in orderedChamber N (Ioo 0 R), rawProductDensity N w x * f x) * + (∫ x in orderedChamber N (Ioo 0 R), rawProductDensity N w x * g x) ≤ + (∫ x in orderedChamber N (Ioo 0 R), rawProductDensity N w x) * + (∫ x in orderedChamber N (Ioo 0 R), rawProductDensity N w x * (f x * g x)) := by + apply ordered_density_covariance_exhaustion (fun n => R / (n + 3 : ℝ)) + (fun n => R - R / (n + 3 : ℝ)) (fun _ => by positivity) (fun n => ?_) + (boundedWindow_mono hR.le) (boundedWindow_cover hR) + w hwc hw f g hfc hgc hfm hgm hh hf hg hfg + have hd : R / (n + 3 : ℝ) ≤ R / 2 := + div_le_div_of_nonneg_left hR.le (by norm_num) (by nlinarith [Nat.cast_nonneg (α := ℝ) n]) + linarith + +lemma weighted_covariance_normalize {Af Ag Afg Z : ℝ} (hZ : 0 < Z) + (h : Af * Ag ≤ Z * Afg) : (Af / Z) * (Ag / Z) ≤ Afg / Z := by + apply (le_div_iff₀ hZ).2 + calc + (Af / Z * (Ag / Z)) * Z = (Af * Ag) / Z := by field_simp + _ ≤ Afg := (div_le_iff₀ hZ).2 (by simpa [mul_comm] using h) + +lemma continuousOn_laguerreWeight (a : ℝ) : ContinuousOn (laguerreWeight a) (Ioi 0) := by + unfold laguerreWeight + exact (continuousOn_id.rpow_const (fun _ hx => Or.inl (ne_of_gt hx))).mul + ((Real.continuous_exp.comp continuous_neg).continuousOn) + + + +theorem integrable_laguerreLaw_iff {N : ℕ} {a : ℝ} (ha : 0 < a) + {f : (Fin N → ℝ) → ℝ} : + Integrable f (laguerreLaw N a) ↔ + IntegrableOn (fun r => laguerreDensity N a r * f r) (laguerreDomain N) := by + rw [laguerreLaw, integrable_smul_measure (by simp) + (by simpa using laguerreNormalizer_pos N ha), + integrable_withDensity_iff_integrable_smul' (measurable_laguerreDensity N a).ennreal_ofReal + (Eventually.of_forall fun _ => ENNReal.ofReal_lt_top)] + apply integrable_congr + filter_upwards [ae_restrict_mem (isOpen_laguerreDomain N).measurableSet] with r hr + simp [smul_eq_mul, ENNReal.toReal_ofReal (laguerreDensity_pos a hr).le] + + + +theorem laguerreLaw_covariance {N : ℕ} {a : ℝ} (ha : 0 < a) + (f g : (Fin N → ℝ) → ℝ) + (hfc : ContinuousOn f (coordinateBox (Fin N) (Ioi 0))) + (hgc : ContinuousOn g (coordinateBox (Fin N) (Ioi 0))) + (hfm : MonotoneOn f (coordinateBox (Fin N) (Ioi 0))) + (hgm : MonotoneOn g (coordinateBox (Fin N) (Ioi 0))) + (hf : Integrable f (laguerreLaw N a)) (hg : Integrable g (laguerreLaw N a)) + (hfg : Integrable (fun r => f r * g r) (laguerreLaw N a)) : + (∫ r, f r ∂laguerreLaw N a) * (∫ r, g r ∂laguerreLaw N a) ≤ + ∫ r, f r * g r ∂laguerreLaw N a := by + simp only [integral_laguerreLaw N ha, laguerreExpectation] + apply weighted_covariance_normalize (laguerreNormalizer_pos N ha) + have h := ordered_density_covariance_Ioi (fun _ : Fin N => laguerreWeight a) + (fun _ => continuousOn_laguerreWeight a) (fun _ _ hx => (laguerreWeight_pos a hx).le) + f g hfc hgc hfm hgm (integrableOn_laguerreDensity N ha) + ((integrable_laguerreLaw_iff ha).1 hf) ((integrable_laguerreLaw_iff ha).1 hg) + ((integrable_laguerreLaw_iff ha).1 hfg) + simpa only [rawProductDensity, laguerreNormalizer, laguerreDensity, mul_comm] using h + + + +theorem laguerreLaw_reverse_covariance {N : ℕ} {a : ℝ} (ha : 0 < a) + (f g : (Fin N → ℝ) → ℝ) + (hfc : ContinuousOn f (coordinateBox (Fin N) (Ioi 0))) + (hgc : ContinuousOn g (coordinateBox (Fin N) (Ioi 0))) + (hfm : AntitoneOn f (coordinateBox (Fin N) (Ioi 0))) + (hgm : MonotoneOn g (coordinateBox (Fin N) (Ioi 0))) + (hf : Integrable f (laguerreLaw N a)) (hg : Integrable g (laguerreLaw N a)) + (hfg : Integrable (fun r => f r * g r) (laguerreLaw N a)) : + (∫ r, f r * g r ∂laguerreLaw N a) ≤ + (∫ r, f r ∂laguerreLaw N a) * (∫ r, g r ∂laguerreLaw N a) := by + have h := laguerreLaw_covariance ha (fun r => -f r) g hfc.neg hgc + (fun _ hx _ hy hxy => neg_le_neg (hfm hx hy hxy)) hgm hf.neg hg (by simpa using hfg.neg) + simpa only [neg_mul, integral_neg, neg_le_neg_iff] using h + + + +lemma continuousOn_omega_Ioi : ContinuousOn omega (Ioi 0) := by + intro x hx + have hx0 : x ≠ 0 := ne_of_gt hx + apply ContinuousAt.continuousWithinAt + unfold omega + fun_prop (disch := positivity) + + +theorem expectation_covariance {N : ℕ} (f g : (Fin N → ℝ) → ℝ) + (hfc : ContinuousOn f (coordinateBox (Fin N) (Ioo 0 1))) + (hgc : ContinuousOn g (coordinateBox (Fin N) (Ioo 0 1))) + (hfm : MonotoneOn f (coordinateBox (Fin N) (Ioo 0 1))) + (hgm : MonotoneOn g (coordinateBox (Fin N) (Ioo 0 1))) + (hf : IntegrableOn (fun y => f y * density N y) (orderedDomain N)) + (hg : IntegrableOn (fun y => g y * density N y) (orderedDomain N)) + (hfg : IntegrableOn (fun y => (f y * g y) * density N y) (orderedDomain N)) : + expectation N f * expectation N g ≤ expectation N (fun y => f y * g y) := by + unfold expectation + apply weighted_covariance_normalize (normalizer_pos N) + have h := ordered_density_covariance_Ioo (by norm_num : (0 : ℝ) < 1) + (fun _ : Fin N => omega) (fun _ => continuousOn_omega_Ioi.mono (fun _ hx => hx.1)) + (fun _ x _ => omega_nonneg x) f g hfc hgc hfm hgm (integrableOn_density N) + (by simpa only [rawProductDensity, density, orderedChamber, orderedDomain, mul_comm] using hf) + (by simpa only [rawProductDensity, density, orderedChamber, orderedDomain, mul_comm] using hg) + (by simpa only [rawProductDensity, density, orderedChamber, orderedDomain, mul_comm] using hfg) + simpa only [rawProductDensity, density, orderedChamber, orderedDomain, normalizer, mul_comm] using h + +lemma expectation_neg (N : ℕ) (f : (Fin N → ℝ) → ℝ) : + expectation N (fun y => -f y) = -expectation N f := by + simp only [expectation, neg_mul, integral_neg, neg_div] + + + +theorem expectation_reverse_covariance {N : ℕ} (f g : (Fin N → ℝ) → ℝ) + (hfc : ContinuousOn f (coordinateBox (Fin N) (Ioo 0 1))) + (hgc : ContinuousOn g (coordinateBox (Fin N) (Ioo 0 1))) + (hfm : AntitoneOn f (coordinateBox (Fin N) (Ioo 0 1))) + (hgm : MonotoneOn g (coordinateBox (Fin N) (Ioo 0 1))) + (hf : IntegrableOn (fun y => f y * density N y) (orderedDomain N)) + (hg : IntegrableOn (fun y => g y * density N y) (orderedDomain N)) + (hfg : IntegrableOn (fun y => (f y * g y) * density N y) (orderedDomain N)) : + expectation N (fun y => f y * g y) ≤ expectation N f * expectation N g := by + have h := expectation_covariance (fun y => -f y) g hfc.neg hgc + (fun _ hx _ hy hxy => neg_le_neg (hfm hx hy hxy)) hgm + (by simpa using hf.neg) hg (by simpa using hfg.neg) + simpa only [neg_mul, expectation_neg, neg_le_neg_iff] using h + + + +theorem laguerreLaw_increasing_tilt {N : ℕ} {a : ℝ} (ha : 0 < a) + (f L : (Fin N → ℝ) → ℝ) + (hfc : ContinuousOn f (coordinateBox (Fin N) (Ioi 0))) + (hLc : ContinuousOn L (coordinateBox (Fin N) (Ioi 0))) + (hfm : AntitoneOn f (coordinateBox (Fin N) (Ioi 0))) + (hLm : MonotoneOn L (coordinateBox (Fin N) (Ioi 0))) + (hf : Integrable f (laguerreLaw N a)) (hL : Integrable L (laguerreLaw N a)) + (hfL : Integrable (fun r => f r * L r) (laguerreLaw N a)) + (hLpos : 0 < ∫ r, L r ∂laguerreLaw N a) : + (∫ r, f r * L r ∂laguerreLaw N a) / (∫ r, L r ∂laguerreLaw N a) ≤ + ∫ r, f r ∂laguerreLaw N a := by + exact (div_le_iff₀ hLpos).2 (laguerreLaw_reverse_covariance ha f L hfc hLc hfm hLm hf hL hfL) + + +theorem laguerreLaw_covariance_antitone {N : ℕ} {a : ℝ} (ha : 0 < a) + (f g : (Fin N → ℝ) → ℝ) + (hfc : ContinuousOn f (coordinateBox (Fin N) (Ioi 0))) + (hgc : ContinuousOn g (coordinateBox (Fin N) (Ioi 0))) + (hfm : AntitoneOn f (coordinateBox (Fin N) (Ioi 0))) + (hgm : AntitoneOn g (coordinateBox (Fin N) (Ioi 0))) + (hf : Integrable f (laguerreLaw N a)) (hg : Integrable g (laguerreLaw N a)) + (hfg : Integrable (fun r => f r * g r) (laguerreLaw N a)) : + (∫ r, f r ∂laguerreLaw N a) * (∫ r, g r ∂laguerreLaw N a) ≤ + ∫ r, f r * g r ∂laguerreLaw N a := by + have h := laguerreLaw_covariance ha (fun r => -f r) (fun r => -g r) hfc.neg hgc.neg + (fun _ hx _ hy hxy => neg_le_neg (hfm hx hy hxy)) + (fun _ hx _ hy hxy => neg_le_neg (hgm hx hy hxy)) hf.neg hg.neg (by simpa using hfg) + simpa only [integral_neg, neg_mul_neg] using h + + + + +def cutoffRamp (n : ℕ) (R x : ℝ) : ℝ := min 1 (max 0 ((n + 1 : ℝ) * (R - x))) + +lemma cutoffRamp_bounds (n : ℕ) (R x : ℝ) : + 0 ≤ cutoffRamp n R x ∧ cutoffRamp n R x ≤ 1 := + ⟨le_min (by norm_num) (le_max_left _ _), min_le_left _ _⟩ + +lemma continuous_cutoffRamp (n : ℕ) (R : ℝ) : Continuous (cutoffRamp n R) := by + unfold cutoffRamp + fun_prop + +lemma antitone_cutoffRamp (n : ℕ) (R : ℝ) : Antitone (cutoffRamp n R) := by + intro x y hxy + exact min_le_min_left 1 (max_le_max_left 0 + (mul_le_mul_of_nonneg_left (sub_le_sub_left hxy R) (by positivity))) + +lemma cutoffRamp_tendsto (R x : ℝ) : + Tendsto (fun n => cutoffRamp n R x) atTop (nhds (if x < R then 1 else 0)) := by + split_ifs with hx + · obtain ⟨b, hb⟩ := exists_nat_gt (1 / (R - x)) + have hb' : 1 < (b : ℝ) * (R - x) := (div_lt_iff₀ (sub_pos.mpr hx)).mp hb + have he : (fun n => cutoffRamp n R x) =ᶠ[atTop] (fun _ => 1) := by + filter_upwards [eventually_ge_atTop b] with n hn + have hn' : (b : ℝ) ≤ n := Nat.cast_le.mpr hn + have hm : 1 ≤ (n + 1 : ℝ) * (R - x) := by nlinarith + exact min_eq_left (hm.trans (le_max_right _ _)) + exact (tendsto_congr' he).2 tendsto_const_nhds + · have he : (fun n => cutoffRamp n R x) = (fun _ => 0) := by + funext n + have hm : (n + 1 : ℝ) * (R - x) ≤ 0 := + mul_nonpos_of_nonneg_of_nonpos (by positivity) (sub_nonpos.mpr (le_of_not_gt hx)) + simp only [cutoffRamp, max_eq_left hm, min_eq_right (by norm_num : (0 : ℝ) ≤ 1)] + rw [he] + exact tendsto_const_nhds + + + +def cutoffEvent (N : ℕ) (R : ℝ) : Set (Fin N → ℝ) := coordinateBox (Fin N) (Iio R) + +def cutoffProduct (N n : ℕ) (R : ℝ) (r : Fin N → ℝ) : ℝ := + ∏ i, cutoffRamp n R (r i) + +lemma measurableSet_cutoffEvent (N : ℕ) (R : ℝ) : MeasurableSet (cutoffEvent N R) := + measurableSet_coordinateBox measurableSet_Iio + +lemma cutoffProduct_bounds (N n : ℕ) (R : ℝ) (r : Fin N → ℝ) : + 0 ≤ cutoffProduct N n R r ∧ cutoffProduct N n R r ≤ 1 := by + refine ⟨Finset.prod_nonneg (fun i _ => (cutoffRamp_bounds n R (r i)).1), ?_⟩ + exact Finset.prod_le_one₀ (fun i _ => (cutoffRamp_bounds n R (r i)).1) + (fun i _ => (cutoffRamp_bounds n R (r i)).2) + +lemma cutoffProduct_norm_le (N n : ℕ) (R : ℝ) (r : Fin N → ℝ) : + ‖cutoffProduct N n R r‖ ≤ 1 := by + rw [Real.norm_eq_abs, abs_of_nonneg (cutoffProduct_bounds N n R r).1] + exact (cutoffProduct_bounds N n R r).2 + +lemma continuous_cutoffProduct (N n : ℕ) (R : ℝ) : Continuous (cutoffProduct N n R) := by + unfold cutoffProduct + exact continuous_finsetProd _ fun i _ => (continuous_cutoffRamp n R).comp (continuous_apply i) + +lemma antitone_cutoffProduct (N n : ℕ) (R : ℝ) : Antitone (cutoffProduct N n R) := by + intro r s hrs + exact Finset.prod_le_prod₀ (fun i _ => (cutoffRamp_bounds n R (s i)).1) + (fun i _ => antitone_cutoffRamp n R (hrs i)) + +lemma cutoffProduct_tendsto (N : ℕ) (R : ℝ) (r : Fin N → ℝ) : + Tendsto (fun n => cutoffProduct N n R r) atTop + (nhds ((cutoffEvent N R).indicator (fun _ => (1 : ℝ)) r)) := by + classical + have he : (∏ i : Fin N, if r i < R then (1 : ℝ) else 0) = + (cutoffEvent N R).indicator (fun _ => (1 : ℝ)) r := by + by_cases hr : ∀ i, r i < R + · simp [cutoffEvent, coordinateBox, hr] + · have hr' : r ∉ cutoffEvent N R := hr + rw [indicator_of_notMem hr'] + obtain ⟨i, hi⟩ := not_forall.mp hr + exact Finset.prod_eq_zero (Finset.mem_univ i) (by simp [hi]) + simpa only [cutoffProduct, he] using + tendsto_finsetProd Finset.univ (fun i _ => cutoffRamp_tendsto R (r i)) + +lemma cutoffProduct_integrable {N : ℕ} (μ : Measure (Fin N → ℝ)) [IsFiniteMeasure μ] + (n : ℕ) (R : ℝ) : Integrable (cutoffProduct N n R) μ := + (integrable_const (1 : ℝ)).mono' (continuous_cutoffProduct N n R).aestronglyMeasurable + (Eventually.of_forall (cutoffProduct_norm_le N n R)) + +lemma cutoffProduct_integral_tendsto {N : ℕ} (μ : Measure (Fin N → ℝ)) [IsFiniteMeasure μ] + (R : ℝ) : Tendsto (fun n => ∫ r, cutoffProduct N n R r ∂μ) atTop + (nhds (μ.real (cutoffEvent N R))) := by + rw [← integral_indicator_one (measurableSet_cutoffEvent N R)] + exact tendsto_integral_of_dominated_convergence (fun _ => 1) + (fun n => (continuous_cutoffProduct N n R).aestronglyMeasurable) (integrable_const 1) + (fun n => Eventually.of_forall (cutoffProduct_norm_le N n R)) + (Eventually.of_forall (cutoffProduct_tendsto N R)) + +lemma cutoffProduct_weighted_tendsto {N : ℕ} (μ : Measure (Fin N → ℝ)) (R : ℝ) + (f : (Fin N → ℝ) → ℝ) (hf : Integrable f μ) : + Tendsto (fun n => ∫ r, f r * cutoffProduct N n R r ∂μ) atTop + (nhds (∫ r in cutoffEvent N R, f r ∂μ)) := by + have he : (fun r => f r * (cutoffEvent N R).indicator (fun _ => (1 : ℝ)) r) = + (cutoffEvent N R).indicator f := by + funext r + by_cases hr : r ∈ cutoffEvent N R <;> simp [hr] + have ht := tendsto_integral_of_dominated_convergence (μ := μ) (fun r => ‖f r‖) + (fun n => hf.aestronglyMeasurable.mul (continuous_cutoffProduct N n R).aestronglyMeasurable) hf.norm + (fun n => Eventually.of_forall fun r => + calc ‖f r * cutoffProduct N n R r‖ = ‖f r‖ * ‖cutoffProduct N n R r‖ := norm_mul _ _ + _ ≤ ‖f r‖ * 1 := mul_le_mul_of_nonneg_left (cutoffProduct_norm_le N n R r) (norm_nonneg _) + _ = ‖f r‖ := mul_one _) + (Eventually.of_forall fun r => tendsto_const_nhds.mul (cutoffProduct_tendsto N R r)) + simpa only [Pi.mul_apply, he, integral_indicator (measurableSet_cutoffEvent N R)] using ht + + + +theorem laguerreLaw_cutoff_covariance {N : ℕ} {a : ℝ} (ha : 0 < a) (R : ℝ) + (f : (Fin N → ℝ) → ℝ) + (hfc : ContinuousOn f (coordinateBox (Fin N) (Ioi 0))) + (hfm : AntitoneOn f (coordinateBox (Fin N) (Ioi 0))) + (hf : Integrable f (laguerreLaw N a)) : + (∫ r, f r ∂laguerreLaw N a) * (laguerreLaw N a).real (cutoffEvent N R) ≤ + ∫ r in cutoffEvent N R, f r ∂laguerreLaw N a := by + let := laguerreLaw_isProbabilityMeasure N ha + apply le_of_tendsto_of_tendsto + (tendsto_const_nhds.mul (cutoffProduct_integral_tendsto (laguerreLaw N a) R)) + (cutoffProduct_weighted_tendsto (laguerreLaw N a) R f hf) + apply Eventually.of_forall + intro n + exact laguerreLaw_covariance_antitone ha f (cutoffProduct N n R) hfc + (continuous_cutoffProduct N n R).continuousOn hfm + ((antitone_cutoffProduct N n R).antitoneOn _) hf (cutoffProduct_integrable _ n R) + (hf.mul_bdd (continuous_cutoffProduct N n R).aestronglyMeasurable + (Eventually.of_forall (cutoffProduct_norm_le N n R))) + +end +end CriticalStrip + +end OAI diff --git a/lean/OAI/Combinatorics/StripMass/DiagonalFactors.lean b/lean/OAI/Combinatorics/StripMass/DiagonalFactors.lean new file mode 100644 index 0000000000000000000000000000000000000000..2e8db52e2876a412a7f6b6f160f03b5b1f9c534a --- /dev/null +++ b/lean/OAI/Combinatorics/StripMass/DiagonalFactors.lean @@ -0,0 +1,563 @@ +import Mathlib +import OAI.Combinatorics.StripMass.LastRow +import OAI.Combinatorics.StripMass.PfaffianSupport + +namespace OAI + +/-! Critical honeycomb strip paths, polynomial identities and crossing mass. -/ + + + +namespace CriticalStrip.Diagram +noncomputable section +open Finset + + + +def separateCosine {n : ℕ} (i : Fin n) : + CosineRing n ≃ₐ[ℂ] Polynomial (MvPolynomial {k : Fin n // k ≠ i} ℂ) := + (MvPolynomial.renameEquiv ℂ (Equiv.optionSubtypeNe i).symm).trans + (MvPolynomial.optionEquivLeft ℂ _) + +@[simp] theorem separateCosine_C {n : ℕ} (i : Fin n) (z : ℂ) : + separateCosine i (MvPolynomial.C z) = Polynomial.C (MvPolynomial.C z) := by + simp [separateCosine] + +@[simp] theorem separateCosine_self {n : ℕ} (i : Fin n) : + separateCosine i (MvPolynomial.X i) = Polynomial.X := by + simp [separateCosine] + +@[simp] theorem separateCosine_other {n : ℕ} (i j : Fin n) (h : j ≠ i) : + separateCosine i (MvPolynomial.X j) = Polynomial.C (MvPolynomial.X ⟨j,h⟩) := by + simp [separateCosine, Equiv.optionSubtypeNe_symm_of_ne h] + +def cosineDiagonalEval {n : ℕ} (i j : Fin n) (hji : j ≠ i) : + CosineRing n →+* MvPolynomial {k : Fin n // k ≠ i} ℂ := + (Polynomial.evalRingHom (MvPolynomial.X ⟨j,hji⟩)).comp (separateCosine i).toRingHom + +@[simp] theorem cosineDiagonalEval_C {n : ℕ} (i j : Fin n) (hji : j ≠ i) (z : ℂ) : + cosineDiagonalEval i j hji (MvPolynomial.C z) = MvPolynomial.C z := by + simp [cosineDiagonalEval] + +@[simp] theorem cosineDiagonalEval_self {n : ℕ} (i j : Fin n) (hji : j ≠ i) : + cosineDiagonalEval i j hji (MvPolynomial.X i) = MvPolynomial.X ⟨j,hji⟩ := by + simp [cosineDiagonalEval] + +@[simp] theorem cosineDiagonalEval_other {n : ℕ} (i j k : Fin n) + (hji : j ≠ i) (hki : k ≠ i) : + cosineDiagonalEval i j hji (MvPolynomial.X k) = MvPolynomial.X ⟨k,hki⟩ := by + simp [cosineDiagonalEval, hki] + +theorem cosineDiagonalEval_swap {n : ℕ} (i j : Fin n) (hji : j ≠ i) : + (cosineDiagonalEval i j hji).comp (MvPolynomial.rename (Equiv.swap i j)).toRingHom = + cosineDiagonalEval i j hji := by + ext k + · simp + · by_cases hki : k = i + · subst k; simp [hji] + · by_cases hkj : k = j + · subst k; simp [hji] + · simp [Equiv.swap_apply_of_ne_of_ne hki hkj, hki] + +theorem prime_cosine_difference {n : ℕ} (i j : Fin n) (hij : i ≠ j) : + Prime (MvPolynomial.X i - MvPolynomial.X j : CosineRing n) := by + apply (MulEquiv.prime_iff (separateCosine i)).mp + simpa [map_sub, hij.symm] using + Polynomial.prime_X_sub_C (MvPolynomial.X (⟨j,hij.symm⟩ : {k : Fin n // k ≠ i}) : + MvPolynomial {k : Fin n // k ≠ i} ℂ) + + +theorem cosine_difference_dvd_of_swap {n : ℕ} (p : CosineRing n) + (i j : Fin n) (hij : i ≠ j) + (hp : MvPolynomial.rename (Equiv.swap i j) p = -p) : + (MvPolynomial.X i - MvPolynomial.X j) ∣ p := by + let E := cosineDiagonalEval i j hij.symm + have he : E (MvPolynomial.rename (Equiv.swap i j) p) = E p := + congrArg (fun f : CosineRing n →+* _ => f p) (cosineDiagonalEval_swap i j hij.symm) + have hz : E p = 0 := by + rw [hp, map_neg] at he + have hh : (2 : MvPolynomial {k : Fin n // k ≠ i} ℂ) * E p = 0 := by + linear_combination -he + exact (mul_eq_zero.mp hh).resolve_left (by norm_num) + have hd : Polynomial.X - Polynomial.C (MvPolynomial.X ⟨j,hij.symm⟩) ∣ + separateCosine i p := Polynomial.dvd_iff_isRoot.mpr hz + obtain ⟨q,hq⟩ := hd + refine ⟨(separateCosine i).symm q, ?_⟩ + apply (separateCosine i).injective + simpa [map_mul, map_sub, hij.symm] using hq + + + +theorem cosine_differences_relPrime {n : ℕ} (e f : UpperPair n) (hef : e ≠ f) : + IsRelPrime (MvPolynomial.X e.val.1 - MvPolynomial.X e.val.2 : CosineRing n) + (MvPolynomial.X f.val.1 - MvPolynomial.X f.val.2) := by + apply (prime_cosine_difference e.val.1 e.val.2 (ne_of_lt e.property)).irreducible.isRelPrime_iff_not_dvd.mpr + intro hdiv + let c : Fin n → Fin n := fun k => if k = e.val.1 then e.val.2 else k + have hc : MvPolynomial.rename c + (MvPolynomial.X e.val.1 - MvPolynomial.X e.val.2 : CosineRing n) = 0 := by + simp [c, ne_of_gt e.property] + have hd := map_dvd (MvPolynomial.rename c : CosineRing n →ₐ[ℂ] CosineRing n) hdiv + rw [hc, zero_dvd_iff] at hd + have heq : c f.val.1 = c f.val.2 := by + apply MvPolynomial.X_injective (R := ℂ) + exact sub_eq_zero.mp (by simpa only [map_sub, MvPolynomial.rename_X] using hd) + have he := e.property + have hf := f.property + apply hef + apply Subtype.ext + dsimp [c] at heq + split_ifs at heq with h₁ h₂ h₂ + · exact False.elim (ne_of_lt hf (h₁.trans h₂.symm)) + · exact Prod.ext h₁.symm heq + · exact False.elim (by omega) + · exact False.elim (ne_of_lt hf heq) + + +theorem scalarNumerator_vandermonde_dvd (n : ℕ) (dd rr : ℂ) (hdd : dd ≠ 0) : + (∏ e : UpperPair n, (MvPolynomial.X e.val.1 - MvPolynomial.X e.val.2 : CosineRing n)) ∣ + scalarNumerator n dd rr := by + let : UniqueFactorizationMonoid (CosineRing n) := MvPolynomial.uniqueFactorizationMonoid (Fin n) + let : DecompositionMonoid (CosineRing n) := UniqueFactorizationMonoid.instDecompositionMonoid + apply Fintype.prod_dvd_of_isRelPrime + (s := fun e : UpperPair n => (MvPolynomial.X e.val.1 - MvPolynomial.X e.val.2 : CosineRing n)) + (fun e f hef => cosine_differences_relPrime e f hef) + intro e + apply cosine_difference_dvd_of_swap _ _ _ (ne_of_lt e.property) + rw [scalarNumerator_rename dd rr hdd, Equiv.Perm.sign_swap (ne_of_lt e.property)] + simp + + + + + + + + +def sourceVandermonde {R : Type*} [CommRing R] {n : ℕ} (a : Fin n → R) : R := + ∏ e : UpperPair n, (a e.val.1 - a e.val.2) + +theorem sourceVandermonde_ne_zero {R : Type*} [CommRing R] [IsDomain R] {n : ℕ} + (a : Fin n → R) (ha : Function.Injective a) : sourceVandermonde a ≠ 0 := by + apply Finset.prod_ne_zero_iff.mpr + intro e _ + exact sub_ne_zero.mpr (ha.ne (ne_of_lt e.property)) + +theorem sourceVandermonde_eq_det {R : Type*} [CommRing R] {n : ℕ} (a : Fin n → R) : + sourceVandermonde a = Matrix.det (Matrix.vandermonde (fun i => -a i)) := by + rw [Matrix.det_vandermonde, sourceVandermonde, prod_upperPair (fun i j => a i - a j)] + simp only [neg_sub_neg] + +theorem sourceVandermonde_reindex {R : Type*} [CommRing R] {n : ℕ} + (a : Fin n → R) (σ : Equiv.Perm (Fin n)) : + sourceVandermonde (a ∘ σ) = (Equiv.Perm.sign σ : ℤ) * sourceVandermonde a := by + rw [sourceVandermonde_eq_det, sourceVandermonde_eq_det] + have hm : Matrix.vandermonde (fun i => -(a ∘ σ) i) = + (Matrix.vandermonde (fun i => -a i)).submatrix σ id := by + rfl + rw [hm, Matrix.det_permute] + +theorem map_sourceVandermonde {R S : Type*} [CommRing R] [CommRing S] {n : ℕ} + (f : R →+* S) (a : Fin n → R) : + f (sourceVandermonde a) = sourceVandermonde (fun i => f (a i)) := by + simp [sourceVandermonde, map_prod] + + + +def scalarPolynomial (n : ℕ) (dd rr : ℂ) (hdd : dd ≠ 0) : CosineRing n := + Classical.choose (scalarNumerator_vandermonde_dvd n dd rr hdd) + +theorem scalarNumerator_eq_vandermonde (n : ℕ) (dd rr : ℂ) (hdd : dd ≠ 0) : + scalarNumerator n dd rr = sourceVandermonde MvPolynomial.X * scalarPolynomial n dd rr hdd := + Classical.choose_spec (scalarNumerator_vandermonde_dvd n dd rr hdd) + + + +theorem scalarPolynomial_eval {K : Type*} [Field K] (f : ℂ →+* K) + (n : ℕ) (dd rr : ℂ) (hdd : dd ≠ 0) (a : Fin n → K) + (ha : Function.Injective a) + (hD : ∀ i j, i ≠ j → discriminant (f dd) (a i) (a j) ≠ 0) : + MvPolynomial.eval₂Hom f a (scalarPolynomial n dd rr hdd) = + scalarNormalization (f dd) (f rr) a := by + have h := scalarNumerator_eval_vandermonde f n dd rr a ha hD + rw [scalarNumerator_eq_vandermonde n dd rr hdd, map_mul, + map_sourceVandermonde] at h + simp only [MvPolynomial.eval₂Hom_X'] at h + rw [← prod_upperPair] at h + exact mul_left_cancel₀ (sourceVandermonde_ne_zero a ha) h + + +theorem scalarPolynomial_rename {n : ℕ} (dd rr : ℂ) (hdd : dd ≠ 0) + (σ : Equiv.Perm (Fin n)) : + MvPolynomial.rename σ (scalarPolynomial n dd rr hdd) = scalarPolynomial n dd rr hdd := by + have h := congrArg (MvPolynomial.rename σ) (scalarNumerator_eq_vandermonde n dd rr hdd) + have hv : MvPolynomial.rename σ + (sourceVandermonde (MvPolynomial.X : Fin n → CosineRing n)) = + sourceVandermonde (MvPolynomial.X ∘ σ) := by + simp [sourceVandermonde, map_prod] + rw [scalarNumerator_rename dd rr hdd σ, map_mul, hv] at h + rw [sourceVandermonde_reindex MvPolynomial.X σ, + scalarNumerator_eq_vandermonde n dd rr hdd] at h + have hs : (((Equiv.Perm.sign σ : ℤ) : CosineRing n)) ≠ 0 := by + rcases Int.units_eq_one_or (Equiv.Perm.sign σ) with hs | hs <;> simp [hs] + apply mul_left_cancel₀ (mul_ne_zero hs + (sourceVandermonde_ne_zero (MvPolynomial.X : Fin n → CosineRing n) MvPolynomial.X_injective)) + simpa only [mul_assoc] using h.symm + +end + + + + + +noncomputable section +open Finset +open scoped Classical + +lemma scalarNormalization_quotient {K : Type*} [Field K] {n : ℕ} + (dd rr : K) (a : Fin n → K) : + scalarNormalization dd rr a = + (∏ e : UpperPair n,discriminant dd (a e.val.1) (a e.val.2)) / + sourceVandermonde a * pfaffian (augmentedKernel dd rr a) := by + rw [scalarNormalization,←prod_upperPair,Finset.prod_div_distrib] + rfl + +lemma scalarNormalization_reindex {K : Type*} [Field K] {n : ℕ} + (dd rr : K) (a : Fin n → K) (σ : Equiv.Perm (Fin n)) : + scalarNormalization dd rr (a ∘ σ)=scalarNormalization dd rr a := by + rw [scalarNormalization_quotient,scalarNormalization_quotient, + sourceVandermonde_reindex,augmentedKernel_reindex,pfaffian_reindex,augmentedPerm_sign] + have hp : (∏ e : UpperPair n, discriminant dd ((a ∘ σ) e.val.1) ((a ∘ σ) e.val.2))= + ∏ e : UpperPair n, discriminant dd (a e.val.1) (a e.val.2) := + prod_upperPair_reindex (fun i j => discriminant dd (a i) (a j)) + (fun i j => discriminant_symm dd (a i) (a j)) σ + rw [hp] + rcases Int.units_eq_one_or (Equiv.Perm.sign σ) with hs | hs <;> simp [hs,div_neg] + +lemma map_pfaffian {K L : Type*} [Field K] [Field L] {n : ℕ} + (f : K →+* L) (M : Matrix (Fin n) (Fin n) K) : + f (pfaffian M)=pfaffian (M.map f) := by + simp only [pfaffian,map_mul,map_inv₀,map_pow,map_ofNat,map_natCast,map_sum, + map_intCast,map_prod,Matrix.map_apply] + +lemma map_augmentedKernel {K L : Type*} [Field K] [Field L] {n : ℕ} + (f : K →+* L) (dd rr : K) (a : Fin n → K) : + (augmentedKernel dd rr a).map f=augmentedKernel (f dd) (f rr) (fun i => f (a i)) := by + ext i j + change f (augmentedKernel dd rr a i j)=_ + unfold augmentedKernel + split_ifs <;> simp [discriminant,map_div₀,map_pow,map_ofNat] + +lemma map_scalarNormalization {K L : Type*} [Field K] [Field L] {n : ℕ} + (f : K →+* L) (dd rr : K) (a : Fin n → K) : + f (scalarNormalization dd rr a)=scalarNormalization (f dd) (f rr) (fun i => f (a i)) := by + simp only [scalarNormalization,map_mul,map_pfaffian,map_augmentedKernel,map_prod, + map_div₀,discriminant,map_sub,map_add,map_pow,map_ofNat] + +lemma permSpectral_normalization {n : ℕ} (σ : Equiv.Perm (Fin n)) : + permSpectral σ (spectralNormalization n)=spectralNormalization n := by + simp only [spectralNormalization,map_scalarNormalization,permSpectral_const,permSpectral_spectralA] + exact scalarNormalization_reindex (constF n d) (constF n rho) spectralA σ + +end + + + + + +noncomputable section +open scoped Classical + + + +def insertExponent {n : ℕ} (i : Fin (n+1)) : (Fin n → ℤ) →+ (Fin (n+1) → ℤ) where + toFun e := Fin.insertNth i 0 e + map_zero' := by funext j; refine Fin.succAboveCases i ?_ (fun k => ?_) j <;> simp + map_add' e f := by funext j; refine Fin.succAboveCases i ?_ (fun k => ?_) j <;> simp + +lemma insertExponent_injective {n : ℕ} (i : Fin (n+1)) : Function.Injective (insertExponent i) := by + intro e f h + funext j + simpa [insertExponent] using congrFun h (i.succAbove j) + +def insertLaurent {n : ℕ} (i : Fin (n+1)) : Laurent n →+* Laurent (n+1) := + AddMonoidAlgebra.mapDomainRingHom ℂ (insertExponent i) + +lemma insertLaurent_injective {n : ℕ} (i : Fin (n+1)) : Function.Injective (insertLaurent i) := + AddMonoidAlgebra.mapDomain_injective (insertExponent_injective i) + +def insertSpectral {n : ℕ} (i : Fin (n+1)) : SpectralField n →+* SpectralField (n+1) := + IsFractionRing.lift (K := SpectralField n) + (g := (algebraMap (SpectralRing (n+1)) (SpectralField (n+1))).comp (insertLaurent i)) + ((IsFractionRing.injective (SpectralRing (n+1)) (SpectralField (n+1))).comp + (insertLaurent_injective i)) + +@[simp] lemma insertSpectral_evalLaurent {n : ℕ} (i : Fin (n+1)) (f : Laurent n) : + insertSpectral i (evalLaurent f)=evalLaurent (insertLaurent i f) := + IsFractionRing.lift_algebraMap _ _ + +@[simp] lemma insertLaurent_monomial {n : ℕ} (i : Fin (n+1)) (e : Fin n → ℤ) (z : ℂ) : + insertLaurent i (monomialL e z)=monomialL (Fin.insertNth i 0 e) z := + AddMonoidAlgebra.mapDomain_single + +@[simp] lemma insertSpectral_const {n : ℕ} (i : Fin (n+1)) (z : ℂ) : + insertSpectral i (constF n z)=constF (n+1) z := by + have hc : constF n z=evalLaurent (constantL n z) := (map_constantL n z).symm + rw [hc,insertSpectral_evalLaurent] + change evalLaurent (insertLaurent i (monomialL 0 z))=evalLaurent (monomialL 0 z) + rw [insertLaurent_monomial] + congr 2 + exact (insertExponent i).map_zero + +@[simp] lemma insertSpectral_variable {n : ℕ} (i : Fin (n+1)) (j : Fin n) : + insertSpectral i (variableF j)=variableF (i.succAbove j) := by + change insertSpectral i (evalLaurent (monomialL (variableExponent j) 1))=_ + rw [insertSpectral_evalLaurent,insertLaurent_monomial] + congr 2 + funext k + refine Fin.succAboveCases i ?_ (fun l => ?_) k + · simp [variableExponent] + · simp [variableExponent,Pi.single_apply] + +@[simp] lemma insertSpectral_torusSin {n : ℕ} (i : Fin (n+1)) (z : SpectralField n) : + insertSpectral i (torusSin z)=torusSin (insertSpectral i z) := by + simp [torusSin,map_div₀,map_inv₀,map_ofNat] + +@[simp] lemma insertSpectral_torusCos {n : ℕ} (i : Fin (n+1)) (z : SpectralField n) : + insertSpectral i (torusCos z)=torusCos (insertSpectral i z) := by + simp [torusCos,map_div₀,map_inv₀,map_ofNat] + +@[simp] lemma insertSpectral_torusL {n : ℕ} (i : Fin (n+1)) (z : SpectralField n) : + insertSpectral i (torusL z)=torusL (insertSpectral i z) := by simp [torusL] + +@[simp] lemma insertSpectral_torusWeights {n : ℕ} (i : Fin (n+1)) (z : SpectralField n) : + (torusWeights z).map (insertSpectral i)=torusWeights (insertSpectral i z) := by + simp [Weights.map,torusWeights,map_div₀] + +@[simp] lemma insertSpectral_spectralWeights {n : ℕ} (i : Fin (n+1)) (j : Fin n) : + (spectralWeights n j).map (insertSpectral i)=spectralWeights (n+1) (i.succAbove j) := by + simp [spectralWeights,map_div₀] + +@[simp] lemma insertSpectral_spectralA {n : ℕ} (i : Fin (n+1)) (j : Fin n) : + insertSpectral i (spectralA j)=spectralA (i.succAbove j) := by simp [spectralA,map_div₀] + +lemma insertSpectral_vacuum {n : ℕ} (i : Fin (n+1)) (p : Pairing n) : + insertSpectral i (normalizedVacuum (spectralWeights n) p)= + normalizedVacuum (fun j => spectralWeights (n+1) (i.succAbove j)) p := by + have h:=congrFun (normalizedVacuum_map (insertSpectral i) (spectralWeights n) (spectral_regular n)) p + simpa using h + +lemma insertSpectral_normalization {n : ℕ} (i : Fin (n+1)) : + insertSpectral i (spectralNormalization n)= + scalarNormalization (constF (n+1) d) (constF (n+1) rho) (fun j => spectralA (i.succAbove j)) := by + simp only [spectralNormalization,map_scalarNormalization,insertSpectral_const,insertSpectral_spectralA] + +end + + + + + +noncomputable section +open scoped LaurentPolynomial + + +def peelExponent {n : ℕ} (i : Fin (n+1)) : (Fin (n+1) → ℤ) ≃+ (ℤ × (Fin n → ℤ)) where + toFun e := (e i,Fin.removeNth i e) + invFun p := Fin.insertNth i p.1 p.2 + left_inv e := by simp + right_inv p := by simp + map_add' e f := rfl + +def peelLaurentEquiv {n : ℕ} (i : Fin (n+1)) : + Laurent (n+1) ≃+* LaurentPolynomial (Laurent n) := + (AddMonoidAlgebra.mapDomainRingEquiv ℂ (peelExponent i)).trans + AddMonoidAlgebra.curryRingEquiv + +@[simp] lemma peelLaurentEquiv_monomial {n : ℕ} (i : Fin (n+1)) + (e : Fin (n+1) → ℤ) (z : ℂ) : + peelLaurentEquiv i (monomialL e z)=AddMonoidAlgebra.single (e i) + (monomialL (Fin.removeNth i e) z) := by + change AddMonoidAlgebra.curryRingEquiv + (AddMonoidAlgebra.mapDomain (peelExponent i) (AddMonoidAlgebra.single e z))=_ + rw [AddMonoidAlgebra.mapDomain_single] + exact AddMonoidAlgebra.curryRingEquiv_single _ _ _ + + +def peelLaurent {n : ℕ} (i : Fin (n+1)) : + Laurent (n+1) →+* LaurentPolynomial (SpectralField n) := + (AddMonoidAlgebra.mapRingHom ℤ (algebraMap (SpectralRing n) (SpectralField n))).comp + (peelLaurentEquiv i).toRingHom + +lemma peelLaurent_injective {n : ℕ} (i : Fin (n+1)) : Function.Injective (peelLaurent i) := + (AddMonoidAlgebra.map_injective _ (IsFractionRing.injective (SpectralRing n) (SpectralField n))).comp + (peelLaurentEquiv i).injective + +@[simp] lemma peelLaurent_monomial {n : ℕ} (i : Fin (n+1)) (e : Fin (n+1) → ℤ) (z : ℂ) : + peelLaurent i (monomialL e z)=AddMonoidAlgebra.single (e i) + (evalLaurent (monomialL (Fin.removeNth i e) z)) := by + change AddMonoidAlgebra.mapRingHom ℤ _ (peelLaurentEquiv i (monomialL e z))=_ + rw [peelLaurentEquiv_monomial] + exact AddMonoidAlgebra.mapRingHom_single _ _ _ + +lemma peelLaurent_insert {n : ℕ} (i : Fin (n+1)) (f : Laurent n) : + peelLaurent i (insertLaurent i f)=LaurentPolynomial.C (evalLaurent f) := by + have h : (peelLaurent i).comp (insertLaurent i)= + LaurentPolynomial.C.comp (algebraMap (SpectralRing n) (SpectralField n)) := by + apply AddMonoidAlgebra.ringHom_ext <;> intro e + all_goals change peelLaurent i (insertLaurent i (monomialL _ _))=_ + all_goals + rw [insertLaurent_monomial,peelLaurent_monomial] + simp only [Fin.insertNth_apply_same,Fin.removeNth_insertNth] + rfl + exact DFunLike.congr_fun h f + +lemma peelLaurent_variable {n : ℕ} (i : Fin (n+1)) : + peelLaurent i (monomialL (variableExponent i) 1)=LaurentPolynomial.T 1 := by + rw [peelLaurent_monomial] + have h : Fin.removeNth i (variableExponent i)=0 := by + funext j + simp [Fin.removeNth,variableExponent,Fin.succAbove_ne] + rw [h] + have he : variableExponent i i=1 := by simp [variableExponent] + rw [he,monomialL_zero_one,evalLaurent,map_one] + rfl + +instance peeledRingIsDomain (n : ℕ) : IsDomain (LaurentPolynomial (SpectralField n)) := + AddMonoidAlgebra.instIsDomainOfIsCancelAddOfUniqueSums + +abbrev SingleSpectral (n : ℕ) := FractionRing (LaurentPolynomial (SpectralField n)) + +instance singleSpectralField (n : ℕ) : Field (SingleSpectral n) := FractionRing.field _ + +def peelSpectral {n : ℕ} (i : Fin (n+1)) : SpectralField (n+1) →+* SingleSpectral n := + IsFractionRing.lift (K := SpectralField (n+1)) + (g := (algebraMap (LaurentPolynomial (SpectralField n)) (SingleSpectral n)).comp (peelLaurent i)) + ((IsFractionRing.injective (LaurentPolynomial (SpectralField n)) (SingleSpectral n)).comp (peelLaurent_injective i)) + +@[simp] lemma peelSpectral_evalLaurent {n : ℕ} (i : Fin (n+1)) (f : Laurent (n+1)) : + peelSpectral i (evalLaurent f)= + algebraMap (LaurentPolynomial (SpectralField n)) (SingleSpectral n) (peelLaurent i f) := + IsFractionRing.lift_algebraMap _ _ + +def singleCoeff (n : ℕ) : SpectralField n →+* SingleSpectral n := + (algebraMap (LaurentPolynomial (SpectralField n)) (SingleSpectral n)).comp LaurentPolynomial.C + +lemma peelSpectral_insert {n : ℕ} (i : Fin (n+1)) (x : SpectralField n) : + peelSpectral i (insertSpectral i x)=singleCoeff n x := by + have h : (peelSpectral i).comp (insertSpectral i)=singleCoeff n := by + apply IsFractionRing.ringHom_ext (A := SpectralRing n) + intro f + change peelSpectral i (insertSpectral i (evalLaurent f))= + algebraMap (LaurentPolynomial (SpectralField n)) (SingleSpectral n) + (LaurentPolynomial.C (evalLaurent f)) + rw [insertSpectral_evalLaurent,peelSpectral_evalLaurent,peelLaurent_insert] + exact DFunLike.congr_fun h x + +end + + + + + + + +noncomputable section +open scoped LaurentPolynomial Classical + +variable {K : Type*} [Field K] + +def LaurentInterval (f : LaurentPolynomial K) (a b : ℤ) : Prop := + ∀ e, f.coeff e ≠ 0 → a ≤ e ∧ e ≤ b + +lemma laurent_trunc_coeff (f : LaurentPolynomial K) (k : ℕ) : + (LaurentPolynomial.trunc f).coeff k=f.coeff (k:ℤ) := rfl + +lemma laurent_toLaurent_coeff (p : Polynomial K) (k : ℕ) : + p.toLaurent.coeff (k:ℤ)=p.coeff k := by + rw [LaurentPolynomial.coeff_toLaurent] + exact Finsupp.mapDomain_apply_of_injective Nat.cast_injective p.toFinsupp.coeff k + +lemma laurent_toLaurent_negative (p : Polynomial K) (e : ℤ) (he : e<0) : + p.toLaurent.coeff e=0 := by + rw [LaurentPolynomial.coeff_toLaurent] + apply Finsupp.mapDomain_of_notMem_range + rintro ⟨n,hn⟩ + have : (0:ℤ)≤n := Int.natCast_nonneg _ + change (n:ℤ)=e at hn + omega + +lemma laurent_toLaurent_trunc (f : LaurentPolynomial K) + (h : ∀ e,e<0 → f.coeff e=0) : + (LaurentPolynomial.trunc f).toLaurent=f := by + ext e + by_cases he:0≤e + · lift e to ℕ using he + rw [laurent_toLaurent_coeff,laurent_trunc_coeff] + · rw [laurent_toLaurent_negative _ _ (by omega),h _ (by omega)] + +lemma laurent_shift_coeff (f : LaurentPolynomial K) (a e : ℤ) : + (f*LaurentPolynomial.T a).coeff e=f.coeff (e-a) := by + simp only [LaurentPolynomial.T,AddMonoidAlgebra.coeff_mul_single_apply,mul_one] + rfl + +lemma LaurentInterval.shift {f : LaurentPolynomial K} {a b : ℤ} + (h : LaurentInterval f a b) (c : ℤ) : + LaurentInterval (f*LaurentPolynomial.T c) (a+c) (b+c) := by + intro e he + rw [laurent_shift_coeff] at he + have := h (e-c) he + omega + +lemma LaurentInterval.shift_trunc {f : LaurentPolynomial K} {m : ℕ} {b : ℤ} + (h : LaurentInterval f (-(m:ℤ)) b) : + (LaurentPolynomial.trunc (f*LaurentPolynomial.T m)).toLaurent= + f*LaurentPolynomial.T m := by + apply laurent_toLaurent_trunc + intro e he + by_contra hh + have := h.shift m e hh + omega + + + +theorem laurent_root_saturation (f : LaurentPolynomial K) (m : ℕ) + (hb : LaurentInterval f (-(m:ℤ)) m) (htop : f.coeff (m:ℤ)=0) + (s : Finset K) (hc : s.card=2*m) (hz : ∀ z∈s,z≠0) + (he : ∀ z (h:z∈s), + LaurentPolynomial.eval₂ (RingHom.id K) (Units.mk0 z (hz z h)) f=0) : f=0 := by + let p := LaurentPolynomial.trunc (f*LaurentPolynomial.T m) + have hp : p.degree<(2*m:ℕ) := by + apply (Polynomial.degree_lt_iff_coeff_zero _ _).mpr + intro k hk + rw [laurent_trunc_coeff,laurent_shift_coeff] + by_cases hh:k=2*m + · subst k + convert htop using 2 + push_cast + ring + · by_contra hn + have := hb ((k:ℤ)-m) hn + omega + have hev (z : K) (hs:z∈s) : p.eval z=0 := by + have h:=congrArg (LaurentPolynomial.eval₂ (RingHom.id K) (Units.mk0 z (hz z hs))) + hb.shift_trunc + rw [LaurentPolynomial.eval₂_toLaurent] at h + change p.eval z = _ at h + rw [(LaurentPolynomial.eval₂ (RingHom.id K) (Units.mk0 z (hz z hs))).map_mul, + he z hs,zero_mul] at h + exact h + have hp0 : p=0 := by + apply Polynomial.eq_zero_of_degree_lt_of_eval_finset_eq_zero s + · simpa [hc] using hp + · exact hev + have hh:=hb.shift_trunc + change p.toLaurent=_ at hh + rw [hp0,map_zero] at hh + have hunit:=LaurentPolynomial.isUnit_T (R:=K) (m:ℤ) + exact (hunit.mul_left_eq_zero.mp hh.symm) + +end +end CriticalStrip.Diagram + +end OAI diff --git a/lean/OAI/Combinatorics/StripMass/FiniteEnds.lean b/lean/OAI/Combinatorics/StripMass/FiniteEnds.lean new file mode 100644 index 0000000000000000000000000000000000000000..93d3d40138259659eb740783ecddf0be464f7d00 --- /dev/null +++ b/lean/OAI/Combinatorics/StripMass/FiniteEnds.lean @@ -0,0 +1,433 @@ +import Mathlib +import OAI.Combinatorics.StripMass.SewnAssignment + +namespace OAI + +/-! Critical honeycomb strip paths, polynomial identities and crossing mass. -/ + + +namespace CriticalStrip.Diagram.PathGraph +noncomputable section +open scoped Classical + + + +lemma reachable_of_odd_terminals {V : Type*} [Fintype V] (G : SimpleGraph V) + {a b : V} (ha : Odd (G.degree a)) + (he : ∀ v, Odd (G.degree v) → v=a ∨ v=b) : G.Reachable a b := by + let S : Set V := {v | G.Reachable a v} + let H := G.induce S + have hd (v : S) : H.degree v=G.degree v := by + apply G.degree_induce_of_neighborSet_subset + intro w hw + exact v.property.trans hw.reachable + let a' : S := ⟨a,SimpleGraph.Reachable.refl a⟩ + have ha' : Odd (H.degree a') := by simpa only [hd] using ha + obtain ⟨w,hw,ho⟩ := H.exists_ne_odd_degree_of_exists_odd_degree a' ha' + rw [hd] at ho + rcases he w ho with hwa | hwb + · exact (hw (Subtype.ext hwa)).elim + · exact hwb ▸ w.property + +lemma degree_eq_one_of_single {V : Type*} [Fintype V] (G : SimpleGraph V) {a : V} + (ha : AtMostOne G.Adj a) (hu : Graph.Used G.Adj a) : G.degree a=1 := by + obtain ⟨b,hb⟩ := hu + rw [←G.card_neighborFinset_eq_degree] + have he : G.neighborFinset a={b} := by + ext v + simp only [SimpleGraph.mem_neighborFinset,Finset.mem_singleton] + exact ⟨fun h=>ha h hb,fun h=>h ▸ hb⟩ + rw [he,Finset.card_singleton] + +lemma degree_eq_two_of_two {V : Type*} [Fintype V] (G : SimpleGraph V) + (h₂ : AtMostTwo G.Adj) {v : V} (hv : ∃ x y, G.Adj v x ∧ G.Adj v y ∧ x≠y) : + G.degree v=2 := by + obtain ⟨x,y,hx,hy,hxy⟩ := hv + rw [←G.card_neighborFinset_eq_degree] + have he : G.neighborFinset v={x,y} := by + ext z + simp only [SimpleGraph.mem_neighborFinset,Finset.mem_insert,Finset.mem_singleton] + exact ⟨fun h=>h₂ hx hy h hxy,fun h=>h.elim (fun h=>h ▸ hx) (fun h=>h ▸ hy)⟩ + simp [he,hxy] + + + +lemma endpoints_connected {V : Type*} [Fintype V] (G : SimpleGraph V) + (h₂ : AtMostTwo G.Adj) {a b : V} (ha : AtMostOne G.Adj a) + (hu : Graph.Used G.Adj a) + (hi : ∀ v, v≠a → v≠b → Graph.Used G.Adj v → + ∃ x y, G.Adj v x ∧ G.Adj v y ∧ x≠y) : G.Reachable a b := by + apply reachable_of_odd_terminals G + · rw [degree_eq_one_of_single G ha hu] + exact odd_one + · intro v hv + by_cases hva : v=a + · exact Or.inl hva + by_cases hvb : v=b + · exact Or.inr hvb + exfalso + by_cases hu : Graph.Used G.Adj v + · rw [degree_eq_two_of_two G h₂ (hi v hva hvb hu)] at hv + exact (by decide : ¬Odd (2:ℕ)) hv + · have hz : G.degree v=0 := by + rw [SimpleGraph.degree_eq_zero] + intro w hw + exact hu ⟨w,hw⟩ + rw [hz] at hv + exact (by decide : ¬Odd (0:ℕ)) hv + + + +lemma endpoints_connected_finite_support {V : Type*} (G : SimpleGraph V) + (hf : G.support.Finite) (h₂ : AtMostTwo G.Adj) {a b : V} + (ha : AtMostOne G.Adj a) (hu : Graph.Used G.Adj a) + (hi : ∀ v, v≠a → v≠b → Graph.Used G.Adj v → + ∃ x y, G.Adj v x ∧ G.Adj v y ∧ x≠y) : + Relation.ReflTransGen G.Adj a b := by + + let S : Set V := insert b G.support + have hs : S.Finite := hf.insert b + let := hs.fintype + let H := G.induce S + let a' : S := ⟨a,Set.mem_insert_of_mem b hu⟩ + let b' : S := ⟨b,Set.mem_insert b _⟩ + have h₂' : AtMostTwo H.Adj := by + intro v x y z hx hy hz hxy + rcases h₂ hx hy hz (fun h=>hxy (Subtype.ext h)) with h | h + · exact Or.inl (Subtype.ext h) + · exact Or.inr (Subtype.ext h) + have ha' : AtMostOne H.Adj a' := by + intro x y hx hy + exact Subtype.ext (ha hx hy) + have hu' : Graph.Used H.Adj a' := by + obtain ⟨w,hw⟩:=hu + exact ⟨⟨w,Set.mem_insert_of_mem b ⟨a,G.symm.symm _ _ hw⟩⟩,hw⟩ + have hi' : ∀ v : S, v≠a' → v≠b' → Graph.Used H.Adj v → + ∃ x y, H.Adj v x ∧ H.Adj v y ∧ x≠y := by + intro v hva hvb hv + have hv' : Graph.Used G.Adj v.val := by + obtain ⟨w,hw⟩:=hv + exact ⟨w.val,hw⟩ + obtain ⟨x,y,hx,hy,hxy⟩:=hi v (fun h=>hva (Subtype.ext h)) + (fun h=>hvb (Subtype.ext h)) hv' + let x' : S := ⟨x,Set.mem_insert_of_mem b ⟨v,G.symm.symm _ _ hx⟩⟩ + let y' : S := ⟨y,Set.mem_insert_of_mem b ⟨v,G.symm.symm _ _ hy⟩⟩ + exact ⟨x',y',hx,hy,fun h=>hxy (congrArg Subtype.val h)⟩ + have hr := (SimpleGraph.reachable_iff_reflTransGen (G := H) a' b').mp + (endpoints_connected H h₂' ha' hu' hi') + exact Graph.map_reach Subtype.val (fun _ _ h=>.single h) hr + + + +lemma drains_of_two_terminals {V : Type*} (G : SimpleGraph V) + (hf : G.support.Finite) (h₂ : AtMostTwo G.Adj) {a b : V} + (ha : AtMostOne G.Adj a) (hu : Graph.Used G.Adj a) + (hi : ∀ v, v≠a → v≠b → Graph.Used G.Adj v → + ∃ x y, G.Adj v x ∧ G.Adj v y ∧ x≠y) + (hd : ∀ v w, G.Adj v w → Relation.ReflTransGen G.Adj v a ∨ + Relation.ReflTransGen G.Adj v b) : Graph.DrainsAt G.Adj a := by + have := G.symm + have hr:=endpoints_connected_finite_support G hf h₂ ha hu hi + intro v w hvw + exact (hd v w hvw).elim id (fun hv=>hv.trans (symm hr)) + +end +end CriticalStrip.Diagram.PathGraph + + + + + +namespace CriticalStrip +noncomputable section +open scoped Classical +open Diagram Diagram.PathGraph + +namespace Diagram.Graph + + + +lemma reach_exit {V : Type*} {r : V → V → Prop} {S : Set V} {x z : V} + (h : Relation.ReflTransGen r x z) (hx : x∈S) (hz : z∉S) : + ∃ u v, u∈S ∧ v∉S ∧ r u v ∧ + Relation.ReflTransGen (fun a b=>a∈S ∧ b∈S ∧ r a b) x u := by + induction h using Relation.ReflTransGen.head_induction_on with + | refl => exact (hz hx).elim + | @head y w hxy h ih => + by_cases hy : w∈S + · obtain ⟨u,v,hu,hv,huv,hr⟩:=ih hy + exact ⟨u,v,hu,hv,huv,hr.head ⟨hx,hy,hxy⟩⟩ + · exact ⟨y,w,hx,hy,hxy,.refl⟩ + +end Diagram.Graph + +namespace HoneycombAssignment +variable {N M : ℕ} + + + +def restrict (D : HoneycombAssignment N) (M : ℕ) (hM : M≤N) : HoneycombAssignment M where + tile q := if q.2 first | exact D.physical q | decide + outside i j hj := ite_eq_right (by omega) + horizontal i j := by + by_cases hj : jha (by subst i; rfl)) (fun h=>hb (by subst i; rfl)) + · exact D.up_two i j (fun hj=>by subst j; exact hs i) hu + + + +theorem restrict_drains_of_two_top (D : HoneycombAssignment (N+1)) (hN : 1≤N) + (a b : ℤ) (root : Triangle) (hr : root.2.1=N) + (hd : Graph.DrainsAt D.graph.Adj root) + (hf : (D.restrict N (by omega)).graph.support.Finite) + (hs : ∀i,¬(D.tile (i,0)).Occupied 0) + (ht : ∀i,(D.tile (i,N)).Occupied 0 ↔ i=a ∨ i=b) : + Graph.DrainsAt (D.restrict N (by omega)).graph.Adj (down b (N-1)) := by + let E := D.restrict N (by omega) + have ht' (i : ℤ) : (E.tile (i,N-1)).Occupied 3 ↔ i=a ∨ i=b := by + rw [show E.tile (i,N-1)=D.tile (i,N-1) from D.restrict_tile N (by omega) i (N-1) (by omega)] + have he := D.vertical i (N-1) (by omega) + rw [show N-1+1=N by omega] at he + exact he.trans (ht i) + have hs' (i : ℤ) : ¬(E.tile (i,0)).Occupied 0 := by + simpa only [show E.tile (i,0)=D.tile (i,0) from D.restrict_tile N (by omega) i 0 (by omega)] using hs i + apply PathGraph.drains_of_two_terminals E.graph hf E.two (E.top_one hN ((ht' b).mpr (Or.inr rfl))) + (E.top_used hN ((ht' b).mpr (Or.inr rfl))) + (E.two_interior_top hN b a hs' (fun i h=>(ht' i |>.mp h).symm)) + intro v w hvw + have hm := (D.restrict_adj N (by omega) v w).mp hvw + have hvr := hd v w hm.2.2 + obtain ⟨x,y,hx,hy,hxy,hvx⟩:=Graph.reach_exit (S:={v : Triangle | v.2.1(D.restrict_adj N (by omega) s t).mpr h) _ _ hvx + rcases x with ⟨i,j,c⟩ + cases c + · obtain ⟨hj,hxy⟩:=(D.down_neighbors i j y).mp hxy + rcases hxy with ⟨rfl,_⟩ | ⟨rfl,_⟩ | ⟨_,rfl,ho⟩ + · exact (hy hx).elim + · exact (hy hx).elim + · have hj' : j+1=N := by change ¬j+1t i))[k]?).getD Tile.vacant := by + simp only [read,List.getElem?_map] + cases ts[k]? <;> rfl + +lemma north_shape_read (ts : List (Configuration (n+1))) (k l : ℕ) + (h : ts.map (fun t=>t (Fin.last n))= + List.replicate k Tile.diagonal₁ ++ Tile.vertical₀::List.replicate l Tile.vacant) + (j : ℕ) : read ts j (Fin.last n)= + if j rfl + +end Diagram.ColumnChain + +namespace SewnRectangle +variable {n : ℕ} + +lemma tile_nonvacant_bounds (l r : List (Configuration n)) (q : Cell) + (h : tile l r q≠.vacant) : + -(l.length:ℤ)≤q.1 ∧ q.1<(r.length:ℤ) ∧ q.2t (Fin.last n))= + List.replicate kl Tile.diagonal₁ ++ Tile.vertical₀::List.replicate ll Tile.vacant) + (hr : r.map (fun t=>t (Fin.last n))= + List.replicate kr Tile.diagonal₁ ++ Tile.vertical₀::List.replicate lr Tile.vacant) + (i : ℤ) : (tile l r (i,n)).Occupied 0 ↔ i= -1-(kl:ℤ) ∨ i=(kr:ℤ) := by + rcases split_column i with ⟨k,rfl⟩|⟨k,rfl⟩ + · rw [show tile l r (-1-(k:ℤ),n)=ColumnChain.read l k (Fin.last n) from tile_left l r k (Fin.last n),ColumnChain.north_shape_read l kl ll hl k] + split_ifs with hk he + · have hc : ¬-1-(k:ℤ)= -1-(kl:ℤ) := by omega + have hc' : ¬-1-(k:ℤ)=(kr:ℤ) := by omega + simp only [hc,hc',false_or] + decide + · subst k + simp only [true_or] + decide + · have hc : ¬-1-(k:ℤ)= -1-(kl:ℤ) := by omega + have hc' : ¬-1-(k:ℤ)=(kr:ℤ) := by omega + simp only [hc,hc',false_or] + decide + · rw [show tile l r ((k:ℤ),n)=(ColumnChain.read r k (Fin.last n)).horizontal from tile_right l r k (Fin.last n),Tile.horizontal_occupied_zero, + ColumnChain.north_shape_read r kr lr hr k] + split_ifs with hk he + · have hc : ¬(k:ℤ)= -1-(kl:ℤ) := by omega + have hc' : ¬(k:ℤ)=(kr:ℤ) := by omega + simp only [hc,hc',false_or] + decide + · subst k + simp only [or_true] + decide + · have hc : ¬(k:ℤ)= -1-(kl:ℤ) := by omega + have hc' : ¬(k:ℤ)=(kr:ℤ) := by omega + simp only [hc,hc',false_or] + decide + +end SewnRectangle +end +end CriticalStrip + +end OAI diff --git a/lean/OAI/Combinatorics/StripMass/FirstFlatSpecialization.lean b/lean/OAI/Combinatorics/StripMass/FirstFlatSpecialization.lean new file mode 100644 index 0000000000000000000000000000000000000000..7941cc7bc5303f4d704e7c1d34aed6a1698273e4 --- /dev/null +++ b/lean/OAI/Combinatorics/StripMass/FirstFlatSpecialization.lean @@ -0,0 +1,540 @@ +import Mathlib +import OAI.Combinatorics.StripMass.ScalarFlat + +namespace OAI + +/-! Critical honeycomb strip paths, polynomial identities and crossing mass. -/ + + + +namespace CriticalStrip.Diagram +noncomputable section +open scoped Classical + +def firstFlatPoint (n : ℕ) : Fin (n+1) → SpectralField n := Fin.cons 1 variableF + +lemma firstFlatPoint_ne_zero (n : ℕ) (i : Fin (n+1)) : firstFlatPoint n i ≠ 0 := by + induction i using Fin.cases with + | zero => exact one_ne_zero + | succ i => exact variableF_ne_zero i + +def firstFlatEvaluation (n : ℕ) : Laurent (n+1) →ₐ[ℂ] SpectralField n := + torusEvaluation (firstFlatPoint n) (firstFlatPoint_ne_zero n) + +lemma rationalAt_firstFlat_variable {n : ℕ} (i : Fin (n+1)) : + RationalAt (firstFlatEvaluation n).toRingHom (variableF i) (firstFlatPoint n i) := + rationalAt_variable _ _ i + +lemma rationalAt_firstFlat_spectralA {n : ℕ} (i : Fin (n+1)) : + RationalAt (firstFlatEvaluation n).toRingHom (spectralA i) + ((Fin.cons (constF n c) spectralA : Fin (n+1) → SpectralField n) i) := by + have h := rationalAt_torusCos (firstFlatEvaluation n) + (((rationalAt_firstFlat_variable i).pow 2).div + ((rationalAt_const (firstFlatEvaluation n) phase).pow 3) + (pow_ne_zero _ (constF_phase_ne_zero n))) + (div_ne_zero (pow_ne_zero _ (firstFlatPoint_ne_zero n i)) + (pow_ne_zero _ (constF_phase_ne_zero n))) + induction i using Fin.cases with + | zero => simpa only [firstFlatPoint,Fin.cons_zero,one_pow,one_div,torusCos_inv, + torusCos_phase_pow,Nat.cast_ofNat,spectralA,c] using h + | succ i => exact h + +lemma rationalAt_firstFlat_deletionNode {n : ℕ} (i : Fin (n+1)) : + RationalAt (firstFlatEvaluation n).toRingHom (deletionNode i) + ((Fin.cons (constF n phase^3) deletionNode : Fin (n+1) → SpectralField n) i) := by + have h := (rationalAt_firstFlat_variable i).mul + ((rationalAt_const (firstFlatEvaluation n) phase).pow 3) + induction i using Fin.cases with + | zero => simpa only [firstFlatPoint,Fin.cons_zero,one_mul,deletionNode] using h + | succ i => exact h + +lemma rationalAt_firstFlat_deletionBeta {n : ℕ} (i : Fin (n+1)) : + RationalAt (firstFlatEvaluation n).toRingHom (deletionBeta i) + ((Fin.cons (constF n c) deletionBeta : Fin (n+1) → SpectralField n) i) := by + have hn : (Fin.cons (constF n phase^3) (@deletionNode n) : Fin (n+1) → SpectralField n) i≠0 := by + induction i using Fin.cases with + | zero => exact pow_ne_zero _ (constF_phase_ne_zero n) + | succ i => exact mul_ne_zero (variableF_ne_zero i) (pow_ne_zero _ (constF_phase_ne_zero n)) + have h:=rationalAt_torusCos (firstFlatEvaluation n) + (((rationalAt_firstFlat_deletionNode i).pow 2).div + ((rationalAt_const (firstFlatEvaluation n) phase).pow 3) + (pow_ne_zero _ (constF_phase_ne_zero n))) + (div_ne_zero (pow_ne_zero _ hn) (pow_ne_zero _ (constF_phase_ne_zero n))) + induction i using Fin.cases with + | zero => + have he : (constF n phase^3)^2/constF n phase^3=constF n phase^3 := by + field_simp + simpa only [Fin.cons_zero,he,torusCos_phase_pow,Nat.cast_ofNat,deletionBeta,c] using h + | succ i => exact h + +def firstFlatSmallerWeights (n : ℕ) : Fin (n+1) → Fin (n+1) → Weights (SpectralField n) := + Fin.cons (Fin.snoc (spectralWeights n) identityWeights) nodalWeights + +lemma firstFlatSmaller_regular (n : ℕ) (i : Fin (n+1)) : + VacuumRegular (firstFlatSmallerWeights n i) := by + induction i using Fin.cases with + | zero => + unfold VacuumRegular firstFlatSmallerWeights + simp only [Fin.cons_zero] + rw [det_flat_top _ (Or.inl (Fin.snoc_last ..))] + simpa only [firstFlatSmallerWeights,Fin.cons_zero,Fin.snoc_castSucc,VacuumRegular] using spectral_regular n + | succ i => exact nodal_regular i + +lemma rationalAt_firstFlat_nodalWeights {n : ℕ} (i : Fin (n+1)) + (j : Fin (n+2)) (t : Tile) : + RationalAt (firstFlatEvaluation n).toRingHom ((nodalWeights i j).tile t) + (((Fin.cons deletionWeights (firstFlatSmallerWeights n i) : Fin (n+2) → Weights (SpectralField n)) j).tile t) := by + have hq:=rationalAt_const (firstFlatEvaluation n) phase + induction j using Fin.lastCases with + | cast j => + simp only [nodalWeights,Fin.snoc_castSucc,spectralWeights] + induction j using Fin.cases with + | zero => + have hv := (hq.pow 3).div (rationalAt_firstFlat_variable 0) one_ne_zero + simp only [firstFlatPoint,Fin.cons_zero,div_one] at hv + have h := rationalAt_torusWeights (firstFlatEvaluation n) hv + (pow_ne_zero 3 (constF_phase_ne_zero n)) + (by rw [torusL_phase_three]; simpa only [torusL_one] using torusL_one_ne_zero n) t + simpa [torusWeights_phase_three] using h + | succ j => + have hv := (hq.pow 3).div (rationalAt_firstFlat_variable j.succ) (variableF_ne_zero j) + simp only [firstFlatPoint,Fin.cons_succ] at hv + have h := rationalAt_torusWeights (firstFlatEvaluation n) hv + (div_ne_zero (pow_ne_zero _ (constF_phase_ne_zero n)) (variableF_ne_zero j)) + (by rw [←rowDenominator_map]; exact rowDenominator_map_ne_zero j) t + induction i using Fin.cases with + | zero => simpa [firstFlatSmallerWeights,spectralWeights] using h + | succ i => simpa [firstFlatSmallerWeights,nodalWeights,spectralWeights] using h + | last => + simp only [nodalWeights_last] + induction i using Fin.cases with + | zero => + have hv := (rationalAt_firstFlat_variable (0:Fin (n+1))).inv one_ne_zero + simp only [firstFlatPoint,Fin.cons_zero,inv_one] at hv + have h:=rationalAt_torusWeights (firstFlatEvaluation n) hv + one_ne_zero (torusL_one_ne_zero n) t + simpa only [torusWeights_one,Fin.cons_last,firstFlatSmallerWeights, + Fin.cons_zero,Fin.snoc_last] using h + | succ i => + have hv := (rationalAt_firstFlat_variable i.succ).inv (variableF_ne_zero i) + simp only [firstFlatPoint,Fin.cons_succ] at hv + have h:=rationalAt_torusWeights (firstFlatEvaluation n) hv + (inv_ne_zero (variableF_ne_zero i)) + (by rw [←inverseRowDenominator_map]; exact inverseRowDenominator_map_ne_zero i) t + simpa only [Fin.cons_last,firstFlatSmallerWeights,Fin.cons_succ,nodalWeights_last] using h + +lemma rationalAt_firstFlat_normalizedVacuum {n : ℕ} (i : Fin (n+1)) (p : Pairing (n+2)) : + RationalAt (firstFlatEvaluation n).toRingHom (normalizedVacuum (nodalWeights i) p) + (firstZeroRaw (fun j => (firstFlatSmallerWeights n i j).tile) + (normalizedVacuum (firstFlatSmallerWeights n i)) p) := by + have hr : VacuumRegular (Fin.cons deletionWeights (firstFlatSmallerWeights n i)) := by + unfold VacuumRegular + rw [det_flat_bottom _ (Or.inr rfl)] + exact firstFlatSmaller_regular n i + have h:=rationalAt_normalizedVacuum _ _ (rationalAt_firstFlat_nodalWeights i) hr p + rw [normalizedVacuum_firstZero _ (firstFlatSmaller_regular n i)] at h + exact h + + + + + + + +lemma scalarPolynomial_eval_snoc_flat {K : Type*} [Field K] (f : ℂ →+* K) + (n : ℕ) (a : Fin n → K) : + MvPolynomial.eval₂Hom f (Fin.snoc a (f (c:ℂ))) + (scalarPolynomial (n+1) d rho (by exact_mod_cast d_ne_zero))= + (∏ i, (a i+f (C:ℂ)))*MvPolynomial.eval₂Hom f a + (scalarPolynomial n d rho (by exact_mod_cast d_ne_zero)) := by + rw [Fin.snoc_eq_cons_rotate] + change MvPolynomial.eval₂Hom f ((Fin.cons (f (c:ℂ)) a : Fin (n+1) → K) ∘ finRotate (n+1)) _ = _ + rw [scalarPolynomial_eval_reindex,source_scalarPolynomial_flat] + +lemma scalarPolynomial_eval_spectral (n : ℕ) : + MvPolynomial.eval₂Hom (algebraMap ℂ (SpectralField n)) spectralA + (scalarPolynomial n d rho (by exact_mod_cast d_ne_zero))=spectralNormalization n := by + exact scalarPolynomial_eval _ _ _ _ _ _ (spectralA_injective n) + (fun i j hij => spectralA_discriminant_ne i j hij) + + +def firstFlatSmallerScalar (n : ℕ) (i : Fin (n+1)) : SpectralField n := + (Fin.cons ((∏ j : Fin n, (spectralA j+constF n C))*spectralNormalization n) + nodalScalar : Fin (n+1) → SpectralField n) i + +lemma firstFlatSmallerScalar_eq (n : ℕ) (i : Fin (n+1)) : + firstFlatSmallerScalar n i= + MvPolynomial.eval₂Hom (algebraMap ℂ (SpectralField n)) + (Fin.snoc spectralA ((Fin.cons (constF n c) deletionBeta : Fin (n+1) → SpectralField n) i)) + (scalarPolynomial (n+1) d rho (by exact_mod_cast d_ne_zero)) := by + induction i using Fin.cases with + | zero => + simp only [firstFlatSmallerScalar,Fin.cons_zero,constF] + rw [scalarPolynomial_eval_snoc_flat (algebraMap ℂ (SpectralField n)) n spectralA,scalarPolynomial_eval_spectral] + | succ i => rfl + +lemma rationalAt_firstFlat_nodalScalar {n : ℕ} (i : Fin (n+1)) : + RationalAt (firstFlatEvaluation n).toRingHom (nodalScalar i) + ((∏ j : Fin n, (spectralA j+constF n C))* + (((Fin.cons (constF n c) deletionBeta : Fin (n+1) → SpectralField n) i)+constF n C)* + firstFlatSmallerScalar n i) := by + have h := RationalAt.mv_eval (algebraMap ℂ (SpectralField (n+1))) + (algebraMap ℂ (SpectralField n)) + (Fin.snoc spectralA (deletionBeta i)) + (Fin.snoc (Fin.cons (constF n c) spectralA) + ((Fin.cons (constF n c) deletionBeta : Fin (n+1) → SpectralField n) i)) + (rationalAt_const (firstFlatEvaluation n)) + (fun j => by + induction j using Fin.lastCases with + | last => simpa using rationalAt_firstFlat_deletionBeta i + | cast j => simpa using rationalAt_firstFlat_spectralA j) + (scalarPolynomial (n+2) d rho (by exact_mod_cast d_ne_zero)) + rw [←Fin.cons_snoc_eq_snoc_cons] at h + simp only [constF] at h + rw [source_scalarPolynomial_flat (algebraMap ℂ (SpectralField n)) (n+1)] at h + rw [Fin.prod_univ_castSucc] at h + simpa only [nodalScalar,Fin.snoc_castSucc,Fin.snoc_last,constF,firstFlatSmallerScalar_eq] using h + +lemma rationalAt_firstFlat_nodalVacuum {n : ℕ} (i : Fin (n+1)) (p : Pairing (n+2)) : + RationalAt (firstFlatEvaluation n).toRingHom (nodalVacuum i p) + (((∏ j : Fin n, (spectralA j+constF n C))* + (((Fin.cons (constF n c) deletionBeta : Fin (n+1) → SpectralField n) i)+constF n C)* + firstFlatSmallerScalar n i)* + firstZeroRaw (fun j => (firstFlatSmallerWeights n i j).tile) + (normalizedVacuum (firstFlatSmallerWeights n i)) p) := + (rationalAt_firstFlat_nodalScalar i).mul (rationalAt_firstFlat_normalizedVacuum i p) + + + + + + + +def lastEvaluation {n:ℕ} (z:SpectralField n) (hz:z≠0) : Laurent (n+1) →ₐ[ℂ] SpectralField n := + torusEvaluation (Fin.snoc variableF z) (fun i => Fin.lastCases (by simpa only [Fin.snoc_last] using hz) (fun j => by simpa only [Fin.snoc_castSucc] using variableF_ne_zero j) i) + +lemma lastEvaluation_lift {n:ℕ} (z:SpectralField n) (hz:z≠0) (P:Laurent n) : + lastEvaluation z hz (liftLaurent P)=evalLaurent P := by + have he:(lastEvaluation z hz).toRingHom.comp (liftLaurentHom n)= + algebraMap (SpectralRing n) (SpectralField n) := by + apply AddMonoidAlgebra.ringHom_ext <;> intro e + all_goals change lastEvaluation z hz (liftLaurent (monomialL _ _))=evalLaurent (monomialL _ _) + all_goals rw [liftLaurent_monomial,evalLaurent_monomial_product] + all_goals simp only [lastEvaluation,torusEvaluation_monomial,Fin.prod_univ_castSucc, + Fin.snoc_castSucc,Fin.snoc_last,zpow_zero,mul_one] + exact DFunLike.congr_fun he P + +lemma rationalAt_last_lift {n:ℕ} (z:SpectralField n) (hz:z≠0) (x:SpectralField n) : + RationalAt (lastEvaluation z hz).toRingHom (liftSpectral n x) x := by + obtain ⟨a,b,hb,rfl⟩:=IsFractionRing.div_surjective (SpectralRing n) x + have ha:=RationalAt.algebraMap (φ:=(lastEvaluation z hz).toRingHom) (F:=SpectralField (n+1)) (liftLaurent a) + have hc:=RationalAt.algebraMap (φ:=(lastEvaluation z hz).toRingHom) (F:=SpectralField (n+1)) (liftLaurent b) + change RationalAt _ (evalLaurent (liftLaurent a)) (lastEvaluation z hz (liftLaurent a)) at ha + change RationalAt _ (evalLaurent (liftLaurent b)) (lastEvaluation z hz (liftLaurent b)) at hc + rw [lastEvaluation_lift] at ha hc + change RationalAt _ (liftSpectral n (evalLaurent a / evalLaurent b)) (evalLaurent a / evalLaurent b) + rw [map_div₀,liftSpectral_evalLaurent,liftSpectral_evalLaurent] + exact ha.div hc (map_ne_zero_of_mem_nonZeroDivisors + (algebraMap (SpectralRing n) (SpectralField n)) (IsFractionRing.injective _ _) hb) + +lemma rationalAt_last_variable {n:ℕ} (z:SpectralField n) (hz:z≠0) : + RationalAt (lastEvaluation z hz).toRingHom (variableF (Fin.last n)) z := by + simpa only [lastEvaluation,Fin.snoc_last] using rationalAt_variable (Fin.snoc variableF z) + (fun i => Fin.lastCases (by simpa only [Fin.snoc_last] using hz) (fun j => by simpa only [Fin.snoc_castSucc] using variableF_ne_zero j) i) (Fin.last n) + +lemma rationalAt_last_spectralA {n:ℕ} (z:SpectralField n) (hz:z≠0) : + RationalAt (lastEvaluation z hz).toRingHom (spectralA (Fin.last n)) + (torusCos (z^2/constF n phase^3)) := + rationalAt_torusCos (lastEvaluation z hz) + (((rationalAt_last_variable z hz).pow 2).div ((rationalAt_const _ phase).pow 3) + (pow_ne_zero _ (constF_phase_ne_zero n))) + (div_ne_zero (pow_ne_zero _ hz) (pow_ne_zero _ (constF_phase_ne_zero n))) + +lemma rationalAt_last_interpolant {n:ℕ} (z:SpectralField n) (hz:z≠0) (p:Pairing (n+1)) : + RationalAt (lastEvaluation z hz).toRingHom (rationalInterpolant n p) + (lastValue (RingHom.id _) (torusCos (z^2/constF n phase^3)) (torusSin z) + (rationalNodalPolynomial n) p) := by + have he:=RationalAt.eval₂ (lastEvaluation z hz).toRingHom (liftSpectral n) (RingHom.id _) + (rationalAt_last_lift z hz) (rationalAt_last_spectralA z hz) (rationalNodalPolynomial n p) + unfold rationalInterpolant lastValue + split_ifs + · exact (rationalAt_torusSin _ (rationalAt_last_variable z hz) hz).mul he + · simpa only [one_mul] using he + +lemma rationalAt_last_weights {n:ℕ} (z:SpectralField n) (hz:z≠0) + (hL:torusL (constF n phase^3/z)≠0) (i:Fin (n+1)) (t:Tile) : + RationalAt (lastEvaluation z hz).toRingHom ((spectralWeights (n+1) i).tile t) + (((Fin.snoc (spectralWeights n) (torusWeights (constF n phase^3/z)) : Fin (n+1) → Weights (SpectralField n)) i).tile t) := by + induction i using Fin.lastCases with + | cast i => + simpa only [liftSpectral_weights_tile,Fin.snoc_castSucc] using + rationalAt_last_lift z hz ((spectralWeights n i).tile t) + | last => + simpa only [spectralWeights,Fin.snoc_last] using rationalAt_torusWeights (lastEvaluation z hz) + (((rationalAt_const _ phase).pow 3).div (rationalAt_last_variable z hz) hz) + (div_ne_zero (pow_ne_zero _ (constF_phase_ne_zero n)) hz) hL t + +end + + + + + +noncomputable section +open Finset + +theorem sum_selectedPairs {R : Type*} [AddCommMonoid R] {n : ℕ} + (D : Fin n → Fin n → R) (hD : ∀ i j, D i j = D j i) + (σ : Equiv.Perm (Fin n)) : + (∑ e ∈ selectedPairs σ, D e.val.1 e.val.2) = + ∑ i : Fin (n/2), D (σ (pairFirst n i)) (σ (pairSecond n i)) := by + rw [selectedPairs, Finset.sum_image] + · apply Finset.sum_congr rfl + intro i _ + exact upperPair_value D hD _ _ _ + · exact fun i _ j _ h => permutationPair_injective σ h + + + +theorem clearedPfaffianTerm_degree {n m : ℕ} (k : Fin m) + (N D : Matrix (Fin n) (Fin n) (CosineRing m)) + (w : Fin n → Fin n → ℕ) (hw : ∀ i j, w i j = w j i) + (hN : ∀ i j, MvPolynomial.degreeOf k (N i j) ≤ w i j) + (hD : ∀ i j, MvPolynomial.degreeOf k (D i j) ≤ w i j) + (σ : Equiv.Perm (Fin n)) : + MvPolynomial.degreeOf k (clearedPfaffianTerm N D σ) ≤ + ∑ e : UpperPair n, w e.val.1 e.val.2 := by + unfold clearedPfaffianTerm + refine (MvPolynomial.degreeOf_mul_le _ _ _).trans ?_ + refine (add_le_add ((MvPolynomial.degreeOf_prod_le _ _ _).trans + (Finset.sum_le_sum (fun i _ => hN _ _))) + ((MvPolynomial.degreeOf_prod_le _ _ _).trans + (Finset.sum_le_sum (fun e _ => hD _ _)))).trans ?_ + rw [← sum_selectedPairs w hw σ, Finset.sum_add_sum_compl] + + +theorem clearedPfaffian_degree {n m : ℕ} (k : Fin m) (t : ℂ) + (N D : Matrix (Fin n) (Fin n) (CosineRing m)) + (w : Fin n → Fin n → ℕ) (hw : ∀ i j, w i j = w j i) + (hN : ∀ i j, MvPolynomial.degreeOf k (N i j) ≤ w i j) + (hD : ∀ i j, MvPolynomial.degreeOf k (D i j) ≤ w i j) : + MvPolynomial.degreeOf k (clearedPfaffian (MvPolynomial.C t) N D) ≤ + ∑ e : UpperPair n, w e.val.1 e.val.2 := by + unfold clearedPfaffian + apply (MvPolynomial.degreeOf_C_mul_le _ _ _).trans + apply (MvPolynomial.degreeOf_sum_le _ _ _).trans + apply Finset.sup_le + intro σ _ + have hs : ((Equiv.Perm.sign σ : ℤ) : CosineRing m) = + MvPolynomial.C ((Equiv.Perm.sign σ : ℤ) : ℂ) := by simp + rw [hs] + exact (MvPolynomial.degreeOf_C_mul_le _ _ _).trans + (clearedPfaffianTerm_degree k N D w hw hN hD σ) + +theorem numerator_degree_bound {n : ℕ} (k : Fin n) (rr : ℂ) + (a b : CosineRing n) (r : ℕ) + (ha : MvPolynomial.degreeOf k a ≤ r) (hb : MvPolynomial.degreeOf k b ≤ r) : + MvPolynomial.degreeOf k ((a-b)*(a+b+MvPolynomial.C rr)) ≤ 2*r := by + have h₁ : MvPolynomial.degreeOf k (a-b) ≤ r := + (MvPolynomial.degreeOf_sub_le _ _ _).trans (max_le ha hb) + have h₂ : MvPolynomial.degreeOf k (a+b+MvPolynomial.C rr) ≤ r := by + refine (MvPolynomial.degreeOf_add_le _ _ _).trans (max_le ?_ ?_) + · exact (MvPolynomial.degreeOf_add_le _ _ _).trans (max_le ha hb) + · simp + exact (MvPolynomial.degreeOf_mul_le _ _ _).trans (by omega) + +theorem discriminant_degree_bound {n : ℕ} (k : Fin n) (dd : ℂ) + (a b : CosineRing n) (r : ℕ) + (ha : MvPolynomial.degreeOf k a ≤ r) (hb : MvPolynomial.degreeOf k b ≤ r) : + MvPolynomial.degreeOf k (discriminant (MvPolynomial.C dd) a b) ≤ 2*r := by + have he : discriminant (MvPolynomial.C dd) a b = + a^2+b^2+MvPolynomial.C (2*dd)*(a*b)-MvPolynomial.C (dd^2) := by + simp only [discriminant, map_mul, map_ofNat, map_pow] + ring + rw [he] + refine (MvPolynomial.degreeOf_sub_le _ _ _).trans (max_le ?_ ?_) + swap + · simpa only [MvPolynomial.degreeOf_C] using + (Nat.zero_le (2*r)) + refine (MvPolynomial.degreeOf_add_le _ _ _).trans (max_le ?_ ?_) + · refine (MvPolynomial.degreeOf_add_le _ _ _).trans (max_le ?_ ?_) + · exact (MvPolynomial.degreeOf_pow_le _ _ 2).trans (Nat.mul_le_mul_left 2 ha) + · exact (MvPolynomial.degreeOf_pow_le _ _ 2).trans (Nat.mul_le_mul_left 2 hb) + · exact (MvPolynomial.degreeOf_C_mul_le _ _ _).trans + ((MvPolynomial.degreeOf_mul_le _ _ _).trans (by omega)) + + + +def scalarEdgeDegree {n : ℕ} (k : Fin n) (i j : Fin (n+n%2)) : ℕ := + if i.val < n ∧ j.val < n ∧ (i.val = k.val ∨ j.val = k.val) then 2 else 0 + +theorem scalarEdgeDegree_symm {n : ℕ} (k : Fin n) (i j : Fin (n+n%2)) : + scalarEdgeDegree k i j = scalarEdgeDegree k j i := by + unfold scalarEdgeDegree + congr 1 + apply propext + tauto + +theorem augmentedNumerator_degree {n : ℕ} (k : Fin n) (rr : ℂ) (i j : Fin (n+n%2)) : + MvPolynomial.degreeOf k (augmentedNumerator (MvPolynomial.C rr) MvPolynomial.X i j) ≤ + scalarEdgeDegree k i j := by + unfold augmentedNumerator scalarEdgeDegree + split_ifs with hi hj hd <;> try simp_all + · apply numerator_degree_bound k rr _ _ 1 <;> + simp only [MvPolynomial.degreeOf_X] <;> split_ifs <;> omega + · have hki : k ≠ (⟨i.val,hi⟩ : Fin n) := by intro h; exact hd.1 (congrArg Fin.val h).symm + have hkj : k ≠ (⟨j.val,hj⟩ : Fin n) := by intro h; exact hd.2 (congrArg Fin.val h).symm + simpa using numerator_degree_bound k rr (MvPolynomial.X ⟨i.val,hi⟩) (MvPolynomial.X ⟨j.val,hj⟩) 0 (by simp [MvPolynomial.degreeOf_X, hki]) + (by simp [MvPolynomial.degreeOf_X, hkj]) + +theorem augmentedDenominator_degree {n : ℕ} (k : Fin n) (dd : ℂ) (i j : Fin (n+n%2)) : + MvPolynomial.degreeOf k (augmentedDenominator (MvPolynomial.C dd) MvPolynomial.X i j) ≤ + scalarEdgeDegree k i j := by + unfold augmentedDenominator scalarEdgeDegree + split_ifs with hi hj hd <;> try simp_all + · apply discriminant_degree_bound k dd _ _ 1 <;> + simp only [MvPolynomial.degreeOf_X] <;> split_ifs <;> omega + · have hki : k ≠ (⟨i.val,hi⟩ : Fin n) := by intro h; exact hd.1 (congrArg Fin.val h).symm + have hkj : k ≠ (⟨j.val,hj⟩ : Fin n) := by intro h; exact hd.2 (congrArg Fin.val h).symm + simpa using discriminant_degree_bound k dd (MvPolynomial.X ⟨i.val,hi⟩) (MvPolynomial.X ⟨j.val,hj⟩) 0 (by simp [MvPolynomial.degreeOf_X, hki]) + (by simp [MvPolynomial.degreeOf_X, hkj]) + + + + + + + +def incidentPair {n : ℕ} (k : Fin n) (j : {j : Fin n // j ≠ k}) : UpperPair n := + upperPair k j.val j.property.symm + +theorem incidentPair_injective {n : ℕ} (k : Fin n) : Function.Injective (incidentPair k) := by + intro j l h + rcases (upperPair_eq_iff _ _).mp h with h | h + · exact Subtype.ext h.2 + · exact False.elim (j.property h.2) + +theorem incidentPair_has_k {n : ℕ} (k : Fin n) (j : {j : Fin n // j ≠ k}) : + (incidentPair k j).val.1 = k ∨ (incidentPair k j).val.2 = k := by + unfold incidentPair upperPair + split_ifs <;> simp + +theorem incidentPair_range {n : ℕ} (k : Fin n) (e : UpperPair n) : + e ∈ Set.range (incidentPair k) ↔ e.val.1 = k ∨ e.val.2 = k := by + constructor + · rintro ⟨j,rfl⟩ + exact incidentPair_has_k k j + · rintro (h | h) + · refine ⟨⟨e.val.2, by rw [← h]; exact ne_of_gt e.property⟩,?_⟩ + simp only [incidentPair, upperPair, ← h, e.property, dite_true] + · refine ⟨⟨e.val.1, by rw [← h]; exact ne_of_lt e.property⟩,?_⟩ + have he : ¬ e.val.2 < e.val.1 := not_lt_of_ge e.property.le + simp only [incidentPair, upperPair, ← h, he, dite_false] + +theorem sum_incident_degree {n : ℕ} (k : Fin n) (r : ℕ) : + (∑ e : UpperPair n, if e.val.1 = k ∨ e.val.2 = k then r else 0) = r*(n-1) := by + have hc : Fintype.card {j : Fin n // j ≠ k} = n-1 := by + rw [Fintype.card_subtype_compl] + simp + have hs : (∑ j : {j : Fin n // j ≠ k}, r) = + ∑ e : UpperPair n, if e.val.1 = k ∨ e.val.2 = k then r else 0 := by + apply Fintype.sum_of_injective (incidentPair k) (incidentPair_injective k) + · intro e he + simp only [incidentPair_range] at he + simp [he] + · intro j + simp [incidentPair_has_k] + simpa [hc, mul_comm] using hs.symm + +theorem sum_scalarEdgeDegree {n : ℕ} (k : Fin n) : + (∑ e : UpperPair (n+n%2), scalarEdgeDegree k e.val.1 e.val.2) = 2*(n-1) := by + let hn : n ≤ n+n%2 := Nat.le_add_right _ _ + have hs : (∑ e : UpperPair n, if e.val.1 = k ∨ e.val.2 = k then 2 else 0) = + ∑ e : UpperPair (n+n%2), scalarEdgeDegree k e.val.1 e.val.2 := by + apply Fintype.sum_of_injective (upperPairEmbed hn) (upperPairEmbed_injective hn) + · intro e he + unfold scalarEdgeDegree + split_ifs with h + · exfalso + apply he + refine ⟨⟨(⟨e.val.1.val,h.1⟩,⟨e.val.2.val,h.2.1⟩),e.property⟩,?_⟩ + apply Subtype.ext + exact Prod.ext (Fin.ext rfl) (Fin.ext rfl) + · rfl + · intro e + simp [scalarEdgeDegree, upperPairEmbed, e.val.1.isLt, e.val.2.isLt, Fin.ext_iff] + rw [← hs] + exact sum_incident_degree k 2 + +theorem scalarNumerator_degree (n : ℕ) (dd rr : ℂ) (k : Fin n) : + MvPolynomial.degreeOf k (scalarNumerator n dd rr) ≤ 2*(n-1) := by + rw [← sum_scalarEdgeDegree k] + exact clearedPfaffian_degree k _ _ _ (scalarEdgeDegree k) (scalarEdgeDegree_symm k) + (augmentedNumerator_degree k rr) (augmentedDenominator_degree k dd) + + + + + + + + + +theorem coeff_prod_budget {R ι : Type*} [CommSemiring R] (s : Finset ι) + (P : ι → Polynomial R) (w : ι → ℕ) + (hP : ∀ i ∈ s, (P i).natDegree ≤ w i) : + (∏ i ∈ s, P i).coeff (∑ i ∈ s, w i) = ∏ i ∈ s, (P i).coeff (w i) := by + classical + induction s using Finset.induction_on with + | empty => simp + | @insert i s hi ih => + rw [Finset.prod_insert hi,Finset.sum_insert hi,Finset.prod_insert hi] + rw [Polynomial.coeff_mul_add_eq_of_natDegree_le (hP i (by simp))] + · rw [ih (fun j hj => hP j (by simp [hj]))] + · exact (Polynomial.natDegree_prod_le s P).trans + (Finset.sum_le_sum (fun j hj => hP j (by simp [hj]))) + + + +theorem clearedPfaffianTerm_top {R : Type*} [CommRing R] {n : ℕ} + (N D : Matrix (Fin n) (Fin n) (Polynomial R)) + (w : Fin n → Fin n → ℕ) (hw : ∀ i j, w i j = w j i) + (hN : ∀ i j, (N i j).natDegree ≤ w i j) + (hD : ∀ i j, (D i j).natDegree ≤ w i j) + (σ : Equiv.Perm (Fin n)) : + (clearedPfaffianTerm N D σ).coeff (∑ e : UpperPair n, w e.val.1 e.val.2) = + clearedPfaffianTerm (fun i j => (N i j).coeff (w i j)) + (fun i j => (D i j).coeff (w i j)) σ := by + have hs : (∑ e : UpperPair n, w e.val.1 e.val.2) = + (∑ i : Fin (n/2), w (σ (pairFirst n i)) (σ (pairSecond n i))) + + ∑ e ∈ (selectedPairs σ)ᶜ, w e.val.1 e.val.2 := by + rw [← sum_selectedPairs w hw σ,Finset.sum_add_sum_compl] + rw [clearedPfaffianTerm,hs,Polynomial.coeff_mul_add_eq_of_natDegree_le] + · rw [coeff_prod_budget _ _ _ (fun i _ => hN _ _), + coeff_prod_budget _ _ _ (fun i _ => hD _ _)] + rfl + · exact (Polynomial.natDegree_prod_le _ _).trans (Finset.sum_le_sum (fun i _ => hN _ _)) + · exact (Polynomial.natDegree_prod_le _ _).trans (Finset.sum_le_sum (fun i _ => hD _ _)) + +theorem clearedPfaffian_top {R : Type*} [CommRing R] {n : ℕ} (t : R) + (N D : Matrix (Fin n) (Fin n) (Polynomial R)) + (w : Fin n → Fin n → ℕ) (hw : ∀ i j, w i j = w j i) + (hN : ∀ i j, (N i j).natDegree ≤ w i j) + (hD : ∀ i j, (D i j).natDegree ≤ w i j) : + (clearedPfaffian (Polynomial.C t) N D).coeff (∑ e : UpperPair n, w e.val.1 e.val.2) = + clearedPfaffian t (fun i j => (N i j).coeff (w i j)) + (fun i j => (D i j).coeff (w i j)) := by + unfold clearedPfaffian + rw [Polynomial.coeff_C_mul,Polynomial.finsetSum_coeff,mul_sum] + symm + rw [mul_sum] + apply Finset.sum_congr rfl + intro σ _ + have he : ((Equiv.Perm.sign σ : ℤ) : Polynomial R) = + Polynomial.C ((Equiv.Perm.sign σ : ℤ) : R) := by simp + rw [he,Polynomial.coeff_C_mul,clearedPfaffianTerm_top N D w hw hN hD σ] + +end +end CriticalStrip.Diagram + +end OAI diff --git a/lean/OAI/Combinatorics/StripMass/FirstThree.lean b/lean/OAI/Combinatorics/StripMass/FirstThree.lean new file mode 100644 index 0000000000000000000000000000000000000000..237c3da7ba90285479dac1c316c8cf0e77d752d7 --- /dev/null +++ b/lean/OAI/Combinatorics/StripMass/FirstThree.lean @@ -0,0 +1,538 @@ +import Mathlib +import OAI.Combinatorics.StripMass.ResidualEvaluation + +namespace OAI + +/-! Critical honeycomb strip paths, polynomial identities and crossing mass. -/ + + + +namespace CriticalStrip.Diagram +noncomputable section +open scoped Classical + +lemma vacantBottomExtension_smul {K:Type*} [CommRing K] {n:ℕ} + (a:K) (v:Pairing n → K) : + vacantBottomExtension (a • v)=a • vacantBottomExtension v := by + funext p + by_cases hp:p.Occupied 0 <;> simp [vacantBottomExtension,hp,Pi.smul_apply] + +lemma normalizedVacuum_firstThree {K:Type*} [Field K] {n:ℕ} + (w:Fin n → Weights K) (hw:VacuumRegular w) : + normalizedVacuum (Fin.cons identityWeights w)=vacantBottomExtension (normalizedVacuum w) := by + have hr:VacuumRegular (Fin.cons identityWeights w) := by + unfold VacuumRegular + rw [det_flat_bottom _ (Or.inl rfl)] + exact hw + symm + apply normalizedVacuum_unique _ hr + constructor + · rw [←Pairing.padBottom_empty,vacantBottomExtension_padBottom] + exact (normalizedVacuum_stationary w hw).1 + · funext p + rw [mulVec_vacantBottomExtension] + by_cases hp:p.Occupied 0 + · simp only [vacantBottomExtension,hp,ite_true] + apply Finset.sum_eq_zero + intro q _ + rw [column_identity_bottom_row _ rfl _ _ hp,zero_mul] + · rw [←p.padBottom_restrict hp,vacantBottomExtension_padBottom] + simp only [column_padBottom,Fin.cons_succ] + exact congrFun (normalizedVacuum_stationary w hw).2 _ + +def firstThreePoint (n:ℕ) : Fin (n+1) → SpectralField n := + Fin.cons (constF n phase^3) variableF + +lemma firstThreePoint_ne_zero (n:ℕ) (i:Fin (n+1)) : firstThreePoint n i≠0 := by + induction i using Fin.cases with + | zero => exact pow_ne_zero _ (constF_phase_ne_zero n) + | succ i => exact variableF_ne_zero i + +def firstThreeEvaluation (n:ℕ) : Laurent (n+1) →ₐ[ℂ] SpectralField n := + torusEvaluation (firstThreePoint n) (firstThreePoint_ne_zero n) + +lemma rationalAt_firstThree_variable {n:ℕ} (i:Fin (n+1)) : + RationalAt (firstThreeEvaluation n).toRingHom (variableF i) (firstThreePoint n i) := + rationalAt_variable _ _ i + +lemma rationalAt_firstThree_spectralA {n:ℕ} (i:Fin (n+1)) : + RationalAt (firstThreeEvaluation n).toRingHom (spectralA i) + ((Fin.cons (constF n c) spectralA : Fin (n+1) → SpectralField n) i) := by + have h:=rationalAt_torusCos (firstThreeEvaluation n) + (((rationalAt_firstThree_variable i).pow 2).div + ((rationalAt_const (firstThreeEvaluation n) phase).pow 3) + (pow_ne_zero _ (constF_phase_ne_zero n))) + (div_ne_zero (pow_ne_zero _ (firstThreePoint_ne_zero n i)) + (pow_ne_zero _ (constF_phase_ne_zero n))) + induction i using Fin.cases with + | zero => + have he:(constF n phase^3)^2/constF n phase^3=constF n phase^3 := by + field_simp + simpa only [firstThreePoint,Fin.cons_zero,he,torusCos_phase_pow,Nat.cast_ofNat,spectralA,c] using h + | succ i => exact h + +lemma rationalAt_firstThree_deletionNode {n:ℕ} (i:Fin (n+1)) : + RationalAt (firstThreeEvaluation n).toRingHom (deletionNode i) + ((Fin.cons (constF n phase^6) deletionNode : Fin (n+1) → SpectralField n) i) := by + have h:=(rationalAt_firstThree_variable i).mul + ((rationalAt_const (firstThreeEvaluation n) phase).pow 3) + induction i using Fin.cases with + | zero => simpa only [firstThreePoint,Fin.cons_zero,←pow_add,Nat.reduceAdd,deletionNode] using h + | succ i => exact h + +lemma firstThreeNode_ne_zero {n:ℕ} (i:Fin (n+1)) : + ((Fin.cons (constF n phase^6) deletionNode : Fin (n+1) → SpectralField n) i)≠0 := by + induction i using Fin.cases with + | zero => exact pow_ne_zero _ (constF_phase_ne_zero n) + | succ i => exact mul_ne_zero (variableF_ne_zero i) (pow_ne_zero _ (constF_phase_ne_zero n)) + +lemma torusCos_phase_nine (n:ℕ) :torusCos (constF n phase^9)= -constF n C := by + rw [torusCos_phase_pow] + have h:9*lambda=lambda+Real.pi := by unfold lambda; ring + simp only [Nat.cast_ofNat,h,Real.cos_add_pi,Complex.ofReal_neg,constF,map_neg,C] + +lemma rationalAt_firstThree_deletionBeta {n:ℕ} (i:Fin (n+1)) : + RationalAt (firstThreeEvaluation n).toRingHom (deletionBeta i) + ((Fin.cons (-constF n C) deletionBeta : Fin (n+1) → SpectralField n) i) := by + have h:=rationalAt_torusCos (firstThreeEvaluation n) + (((rationalAt_firstThree_deletionNode i).pow 2).div + ((rationalAt_const (firstThreeEvaluation n) phase).pow 3) + (pow_ne_zero _ (constF_phase_ne_zero n))) + (div_ne_zero (pow_ne_zero _ (firstThreeNode_ne_zero i)) + (pow_ne_zero _ (constF_phase_ne_zero n))) + induction i using Fin.cases with + | zero => + have he:(constF n phase^6)^2/constF n phase^3=constF n phase^9 := by + field_simp + simpa only [Fin.cons_zero,he,torusCos_phase_nine,deletionBeta] using h + | succ i => exact h + +lemma rationalAt_firstThree_weights {n:ℕ} (i:Fin (n+1)) (t:Tile) : + RationalAt (firstThreeEvaluation n).toRingHom ((spectralWeights (n+1) i).tile t) + (((Fin.cons identityWeights (spectralWeights n) : Fin (n+1) → Weights (SpectralField n)) i).tile t) := by + have hz:=rationalAt_firstThree_variable i + have hq:=(rationalAt_const (firstThreeEvaluation n) phase).pow 3 + induction i using Fin.cases with + | zero => + simp only [firstThreePoint,Fin.cons_zero] at hz + have h:=hq.div hz (pow_ne_zero _ (constF_phase_ne_zero n)) + rw [div_self (pow_ne_zero _ (constF_phase_ne_zero n))] at h + simpa only [Fin.cons_zero,torusWeights_one,spectralWeights] using + rationalAt_torusWeights (firstThreeEvaluation n) h one_ne_zero (torusL_one_ne_zero n) t + | succ i => + simp only [firstThreePoint,Fin.cons_succ] at hz + exact rationalAt_torusWeights (firstThreeEvaluation n) + (hq.div hz (variableF_ne_zero i)) + (div_ne_zero (pow_ne_zero _ (constF_phase_ne_zero n)) (variableF_ne_zero i)) + (by rw [←rowDenominator_map]; exact rowDenominator_map_ne_zero i) t + +lemma rationalAt_firstThree_normalization (n:ℕ) : + RationalAt (firstThreeEvaluation n).toRingHom (spectralNormalization (n+1)) + ((∏ j:Fin n,(spectralA j+constF n C))*spectralNormalization n) := by + have h:=RationalAt.mv_eval (algebraMap ℂ (SpectralField (n+1))) + (algebraMap ℂ (SpectralField n)) spectralA (Fin.cons (constF n c) spectralA) + (rationalAt_const (firstThreeEvaluation n)) rationalAt_firstThree_spectralA + (scalarPolynomial (n+1) d rho (by exact_mod_cast d_ne_zero)) + simp only [constF] at h + rw [scalarPolynomial_eval_spectral,source_scalarPolynomial_flat,scalarPolynomial_eval_spectral] at h + exact h + +lemma rationalAt_firstThree_vacuum {n:ℕ} (p:Pairing (n+1)) : + RationalAt (firstThreeEvaluation n).toRingHom (rationalVacuum (n+1) p) + ((∏ j:Fin n,(spectralA j+constF n C))*vacantBottomExtension (rationalVacuum n) p) := by + have hr:VacuumRegular (Fin.cons identityWeights (spectralWeights n)) := by + unfold VacuumRegular + rw [det_flat_bottom _ (Or.inl rfl)] + exact spectral_regular n + have h:=rationalAt_normalizedVacuum _ _ rationalAt_firstThree_weights hr p + rw [normalizedVacuum_firstThree _ (spectral_regular n)] at h + have he:=(rationalAt_firstThree_normalization n).mul h + have hs:rationalVacuum n=spectralNormalization n • normalizedVacuum (spectralWeights n) := rfl + rw [hs,vacantBottomExtension_smul] + simpa only [rationalVacuum,Pi.smul_apply,smul_eq_mul,mul_assoc] using he + + + + + + + +lemma firstThreeHead_zero {n:ℕ} (occupied:Prop) [Decidable occupied] : + firstThreeEvaluation n (nodalHeadL (0:Fin (n+1)) occupied)=0 := by + have h:RationalAt (firstThreeEvaluation n).toRingHom + (reducedNodalHead (0:Fin (n+1)) occupied) 0 := by + by_cases ho:occupied + · simp only [reducedNodalHead,ite_eq_left ho] + have hv:=(rationalAt_const (firstThreeEvaluation n) phase).pow 3 |>.div + (rationalAt_firstThree_variable (0:Fin (n+1))) (pow_ne_zero _ (constF_phase_ne_zero n)) + simp only [firstThreePoint,Fin.cons_zero,div_self (pow_ne_zero _ (constF_phase_ne_zero n))] at hv + have ht:=rationalAt_torusSin (firstThreeEvaluation n) hv one_ne_zero + simp only [torusSin,inv_one,sub_self,zero_div] at ht + have hh:= ((RationalAt.natCast 4).mul (rationalAt_const (firstThreeEvaluation n) (c:ℂ))).mul ht + simpa only [mul_zero,torusSin,Nat.cast_ofNat] using hh + · simp only [reducedNodalHead,ite_eq_right ho] + have hh:=((rationalAt_firstThree_spectralA (0:Fin (n+1))).add + (rationalAt_firstThree_deletionBeta (0:Fin (n+1)))).add + (rationalAt_const (firstThreeEvaluation n) (rho:ℂ)) + simp only [Fin.cons_zero] at hh + have he:constF n c+-constF n C+constF n rho=0 := by + have hc:=congrArg (fun x:ℝ => constF n (x:ℂ)) c_add_rho_eq_C + simp only [Complex.ofReal_add,constF,map_add] at hc ⊢ + linear_combination hc + rw [he] at hh + exact hh + have ha:=RationalAt.algebraMap (φ:=(firstThreeEvaluation n).toRingHom) + (F:=SpectralField (n+1)) (nodalHeadL (0:Fin (n+1)) occupied) + change RationalAt _ (evalLaurent _) _ at ha + rw [nodalHeadL_map] at ha + exact ha.unique h + +lemma nodalDatumL_firstThree_zero {n:ℕ} (W:Pairing n → Laurent n) (p:Pairing (n+2)) : + firstThreeEvaluation n (nodalDatumL W 0 p)=0 := by + simp only [nodalDatumL,map_mul,firstThreeHead_zero,mul_zero,zero_mul] + +lemma rationalNodalPolynomial_firstThree_self {n:ℕ} + (W:Pairing n → Laurent n) (hW:∀q,evalLaurent (W q)=rationalVacuum n q) + (P:Pairing (n+2) → Polynomial (Laurent (n+1))) + (hP:∀p,(P p).map (algebraMap (SpectralRing (n+1)) (SpectralField (n+1)))= + rationalNodalPolynomial (n+1) p) (p:Pairing (n+2)) : + ((P p).map (firstThreeEvaluation n).toRingHom).eval (-constF n C)=0 := by + have he:(P p).eval (betaL 0)=nodalDatumL W 0 p := by + apply IsFractionRing.injective (SpectralRing (n+1)) (SpectralField (n+1)) + change evalLaurent ((P p).eval (betaL 0))=evalLaurent (nodalDatumL W 0 p) + rw [nodalDatumL_map W hW] + have hh:=rationalNodalPolynomial_at_node p (0:Fin (n+1)) + rw [eq_div_iff (by split_ifs; exact deletionNode_sine_ne_zero 0; exact one_ne_zero)] + rw [mul_comm] + rw [←hP] at hh + have hf:evalLaurent ((P p).eval (betaL 0))= + ((P p).map (algebraMap (SpectralRing (n+1)) (SpectralField (n+1)))).eval (deletionBeta 0) := by + rw [←betaL_map] + exact (Polynomial.eval_map_apply ..).symm + rw [hf] + exact hh + have hb:firstThreeEvaluation n (betaL (0:Fin (n+1)))= -constF n C := by + have ha:=RationalAt.algebraMap (φ:=(firstThreeEvaluation n).toRingHom) + (F:=SpectralField (n+1)) (betaL (0:Fin (n+1))) + change RationalAt _ (evalLaurent _) _ at ha + rw [betaL_map] at ha + exact ha.unique (rationalAt_firstThree_deletionBeta 0) + have hh:=congrArg (firstThreeEvaluation n) he + rw [nodalDatumL_firstThree_zero] at hh + rw [←hb] + change ((P p).map (firstThreeEvaluation n).toRingHom).eval + ((firstThreeEvaluation n).toRingHom (betaL 0))=0 + rw [Polynomial.eval_map_apply] + exact hh + +lemma rationalAt_firstThree_nodalWeights {n:ℕ} (i:Fin n) + (j:Fin (n+2)) (t:Tile) : + RationalAt (firstThreeEvaluation n).toRingHom ((nodalWeights i.succ j).tile t) + (((Fin.cons identityWeights (nodalWeights i) : Fin (n+2) → Weights (SpectralField n)) j).tile t) := by + induction j using Fin.lastCases with + | cast j => + have h:=rationalAt_firstThree_weights j t + induction j using Fin.cases with + | zero => + change RationalAt (firstThreeEvaluation n).toRingHom ((spectralWeights (n+1) 0).tile t) (identityWeights.tile t) + exact h + | succ j => + simp only [nodalWeights,Fin.snoc_castSucc] + rw [←Fin.succ_castSucc,Fin.cons_succ,Fin.snoc_castSucc] + exact h + | last => + simp only [Fin.cons_last,nodalWeights_last] + have hv := (rationalAt_firstThree_variable i.succ).inv (variableF_ne_zero i) + simp only [firstThreePoint,Fin.cons_succ] at hv + exact rationalAt_torusWeights (firstThreeEvaluation n) hv + (inv_ne_zero (variableF_ne_zero i)) + (by rw [←inverseRowDenominator_map]; exact inverseRowDenominator_map_ne_zero i) t + +lemma rationalAt_firstThree_nodalScalar {n:ℕ} (i:Fin n) : + RationalAt (firstThreeEvaluation n).toRingHom (nodalScalar i.succ) + ((∏ j:Fin n,(spectralA j+constF n C))*(deletionBeta i+constF n C)*nodalScalar i) := by + have h:=RationalAt.mv_eval (algebraMap ℂ (SpectralField (n+1))) + (algebraMap ℂ (SpectralField n)) + (Fin.snoc spectralA (deletionBeta i.succ)) + (Fin.snoc (Fin.cons (constF n c) spectralA) (deletionBeta i)) + (rationalAt_const (firstThreeEvaluation n)) + (fun j => by + induction j using Fin.lastCases with + | last => simpa using rationalAt_firstThree_deletionBeta i.succ + | cast j => simpa using rationalAt_firstThree_spectralA j) + (scalarPolynomial (n+2) d rho (by exact_mod_cast d_ne_zero)) + rw [←Fin.cons_snoc_eq_snoc_cons] at h + simp only [constF] at h + rw [source_scalarPolynomial_flat (algebraMap ℂ (SpectralField n)) (n+1)] at h + rw [Fin.prod_univ_castSucc] at h + simpa only [nodalScalar,Fin.snoc_castSucc,Fin.snoc_last,constF] using h + +lemma rationalAt_firstThree_nodalVacuum {n:ℕ} (i:Fin n) (p:Pairing (n+2)) : + RationalAt (firstThreeEvaluation n).toRingHom (nodalVacuum i.succ p) + ((∏ j:Fin n,(spectralA j+constF n C))*(deletionBeta i+constF n C)* + vacantBottomExtension (nodalVacuum i) p) := by + have hr:VacuumRegular (Fin.cons identityWeights (nodalWeights i)) := by + unfold VacuumRegular + rw [det_flat_bottom _ (Or.inl rfl)] + exact nodal_regular i + have h:=rationalAt_normalizedVacuum _ _ (rationalAt_firstThree_nodalWeights i) hr p + rw [normalizedVacuum_firstThree _ (nodal_regular i)] at h + have he:=(rationalAt_firstThree_nodalScalar i).mul h + have hs:nodalVacuum i=nodalScalar i • normalizedVacuum (nodalWeights i) := rfl + rw [hs,vacantBottomExtension_smul] + simpa only [nodalVacuum,Pi.smul_apply,smul_eq_mul,mul_assoc] using he + + + + + + + +def firstThreePolynomial {K:Type*} [CommRing K] {n:ℕ} (C:K) + (P:Pairing n → Polynomial K) : Pairing (n+1) → Polynomial K := + fun p => (Polynomial.X+Polynomial.C C)*vacantBottomExtension P p + +lemma firstThreePolynomial_padBottom {K:Type*} [CommRing K] {n:ℕ} (C:K) + (P:Pairing n → Polynomial K) (p:Pairing n) : + firstThreePolynomial C P p.padBottom=(Polynomial.X+Polynomial.C C)*P p := by + rw [firstThreePolynomial,vacantBottomExtension_padBottom] + +lemma firstThreePolynomial_degree {K:Type*} [CommRing K] {n m:ℕ} (C:K) + (P:Pairing (n+1) → Polynomial K) (hP:LastDegree m P) : + LastDegree (m+1) (firstThreePolynomial C P) := by + intro p k hk + by_cases hp:p.Occupied 0 + · simp [firstThreePolynomial,vacantBottomExtension,hp] + · rw [←p.padBottom_restrict hp] at hk ⊢ + rw [firstThreePolynomial_padBottom] + let q:=p.restrict (Fin.succOrderEmb (n+1)) + have ho:(q.padBottom.Occupied (Fin.last (n+1))) ↔ q.Occupied (Fin.last n) := by + exact q.padBottom_occupied_succ (Fin.last n) + change (if q.padBottom.Occupied (Fin.last (n+1)) then m+1≤k else m+1 exact ⟨k-1,by omega⟩ + have hh:(P q).coeff j=0 := hP q j (by split_ifs at hk ⊢ <;> omega) + have hh':(P q).coeff (j+1)=0 := hP q (j+1) (by split_ifs at hk ⊢ <;> omega) + simp [add_mul,Polynomial.coeff_X_mul,hh,hh',q] + +lemma firstThreePolynomial_leading {K:Type*} [CommRing K] {n m:ℕ} (C:K) + (P:Pairing (n+1) → Polynomial K) (hP:LastDegree m P) (p:Pairing (n+1)) : + (firstThreePolynomial C P p.padTop).coeff (m+1)= + vacantBottomExtension (fun q => (P q.padTop).coeff m) p := by + by_cases hp:p.Occupied 0 + · have ht:p.padTop.Occupied 0 := by + exact (p.padTop_occupied_castSucc 0).mpr hp + simp [firstThreePolynomial,vacantBottomExtension,hp,ht] + · rw [←p.padBottom_restrict hp,Pairing.padBottom_padTop, + firstThreePolynomial_padBottom,vacantBottomExtension_padBottom] + have hz:=hP (p.restrict (Fin.succOrderEmb n)).padTop (m+1) (by simp) + simp [add_mul,Polynomial.coeff_X_mul,hz] + +lemma firstThreeBeta_injective (n:ℕ) : + Function.Injective (Fin.cons (-constF n C) deletionBeta : Fin (n+1) → SpectralField n) := by + apply Fin.cons_injective_iff.mpr + constructor + · rintro ⟨i,he⟩ + exact deletionBeta_ne_const i (-C) (by simpa only [Complex.ofReal_neg,constF,map_neg] using he) + · exact deletionBeta_injective n + + + +theorem rationalNodalPolynomial_firstThree {n:ℕ} + (W:Pairing n → Laurent n) (hW:∀q,evalLaurent (W q)=rationalVacuum n q) + (P:Pairing (n+2) → Polynomial (Laurent (n+1))) + (hP:∀p,(P p).map (algebraMap (SpectralRing (n+1)) (SpectralField (n+1)))= + rationalNodalPolynomial (n+1) p) : + (fun p => (P p).map (firstThreeEvaluation n).toRingHom)= + fun p => Polynomial.C (∏j:Fin n,(spectralA j+constF n C))* + firstThreePolynomial (constF n C) (rationalNodalPolynomial n) p := by + have hdeg:LastDegree (n+1) P := + LastDegree.of_map (algebraMap (SpectralRing (n+1)) (SpectralField (n+1))) + (IsFractionRing.injective _ _) (by simpa only [hP] using rationalNodalPolynomial_degree (n+1)) + have hright:LastDegree (n+1) (fun p => Polynomial.C (∏j:Fin n,(spectralA j+constF n C))* + firstThreePolynomial (constF n C) (rationalNodalPolynomial n) p) := by + intro p k hk + rw [Polynomial.coeff_C_mul, + firstThreePolynomial_degree _ _ (rationalNodalPolynomial_degree n) p k hk,mul_zero] + apply lastPolynomial_unique _ _ (hdeg.map _) hright _ (firstThreeBeta_injective n) + · intro p + rw [Polynomial.coeff_map,Polynomial.coeff_C_mul, + firstThreePolynomial_leading _ _ (rationalNodalPolynomial_degree n)] + have hh:(fun q:Pairing n => (rationalNodalPolynomial n q.padTop).coeff n)=rationalVacuum n := by + funext q; exact rationalNodalPolynomial_leading q + rw [hh] + have ha:=RationalAt.algebraMap (φ:=(firstThreeEvaluation n).toRingHom) + (F:=SpectralField (n+1)) ((P p.padTop).coeff (n+1)) + have hb:=congrArg (fun Q:Polynomial (SpectralField (n+1)) => Q.coeff (n+1)) (hP p.padTop) + rw [Polynomial.coeff_map,rationalNodalPolynomial_leading] at hb + rw [hb] at ha + exact ha.unique (rationalAt_firstThree_vacuum p) + · intro p i + induction i using Fin.cases with + | zero => + simp only [Fin.cons_zero] + rw [rationalNodalPolynomial_firstThree_self W hW P hP p] + simp [firstThreePolynomial,Polynomial.eval_mul,Polynomial.eval_add] + | succ i => + simp only [Fin.cons_succ] + have hs:=rationalAt_torusSin (firstThreeEvaluation n) + (rationalAt_firstThree_deletionNode i.succ) + (firstThreeNode_ne_zero i.succ) + have he:RationalAt (firstThreeEvaluation n).toRingHom + ((rationalNodalPolynomial (n+1) p).eval (deletionBeta i.succ)) + (((P p).map (firstThreeEvaluation n).toRingHom).eval (deletionBeta i)) := by + rw [←hP] + exact RationalAt.eval_map _ (rationalAt_firstThree_deletionBeta i.succ) _ + have hsin:RationalAt (firstThreeEvaluation n).toRingHom + (if p.Occupied (Fin.last (n+1)) then torusSin (deletionNode i.succ) else 1) + (if p.Occupied (Fin.last (n+1)) then torusSin (deletionNode i) else 1) := by + split_ifs + · exact hs + · exact RationalAt.one + have hb:=hsin.mul he + rw [rationalNodalPolynomial_at_node] at hb + have hv:=hb.unique (rationalAt_firstThree_nodalVacuum i p) + apply mul_left_cancel₀ (show (if p.Occupied (Fin.last (n+1)) then torusSin (deletionNode i) else 1)≠0 by + split_ifs; exact deletionNode_sine_ne_zero i; exact one_ne_zero) + rw [hv,Polynomial.eval_mul,Polynomial.eval_C] + by_cases hp:p.Occupied 0 + · simp [firstThreePolynomial,vacantBottomExtension,hp] + · rw [←p.padBottom_restrict hp,firstThreePolynomial_padBottom,vacantBottomExtension_padBottom] + rw [Polynomial.eval_mul,Polynomial.eval_add,Polynomial.eval_X,Polynomial.eval_C] + rw [show (p.restrict (Fin.succOrderEmb (n+1))).padBottom.Occupied (Fin.last (n+1)) ↔ + (p.restrict (Fin.succOrderEmb (n+1))).Occupied (Fin.last n) by + exact Pairing.padBottom_occupied_succ _ (Fin.last n)] + rw [←rationalNodalPolynomial_at_node] + ring + + + + + + + +lemma vacuumRegular_of_rationalAt {R F K:Type*} [CommRing R] [IsDomain R] [Field F] [Field K] + [Algebra R F] [IsFractionRing R F] (φ:R →+* K) {n:ℕ} + (w:Fin n → Weights F) (v:Fin n → Weights K) + (h:∀i t,RationalAt φ ((w i).tile t) ((v i).tile t)) + (hv:VacuumRegular v) : VacuumRegular w := by + have hb:∀i j,RationalAt φ ((1-restrictedColumn w) i j) ((1-restrictedColumn v) i j) := by + intro i j + exact (RationalAt.matrixOne i j).sub (rationalAt_column w v h i.val j.val) + exact (RationalAt.det (1-restrictedColumn w) (1-restrictedColumn v) hb).ne_zero hv + +lemma torusRegular_of_rationalAt {m n r:ℕ} (φ:Laurent m →ₐ[ℂ] SpectralField n) + (x:Fin r → SpectralField m) (y:Fin r → SpectralField n) + (h:∀i,RationalAt φ.toRingHom (x i) (y i)) + (hy:∀i,y i≠0) (hL:∀i,torusL (y i)≠0) + (hv:VacuumRegular (fun i =>torusWeights (y i))) : + VacuumRegular (fun i =>torusWeights (x i)) := by + apply vacuumRegular_of_rationalAt φ.toRingHom _ _ _ hv + intro i t + exact rationalAt_torusWeights φ (h i) (hy i) (hL i) t + +def pairPoint (n s:ℕ) : Fin (n+2) → SpectralField (n+1) := + Fin.cons (variableF 0) (Fin.cons (constF (n+1) phase^s*variableF 0) (fun i =>variableF i.succ)) +lemma pairPoint_ne_zero (n s:ℕ) (i:Fin (n+2)) : pairPoint n s i≠0 := by + induction i using Fin.cases with + | zero => exact variableF_ne_zero 0 + | succ i => induction i using Fin.cases with + | zero => exact mul_ne_zero (pow_ne_zero _ (constF_phase_ne_zero _)) (variableF_ne_zero 0) + | succ i => exact variableF_ne_zero i.succ + +def pairEvaluation (n s:ℕ) : Laurent (n+2) →ₐ[ℂ] SpectralField (n+1) := + torusEvaluation (pairPoint n s) (pairPoint_ne_zero n s) + +lemma rationalAt_pair_variable {n:ℕ} (s:ℕ) (i:Fin (n+2)) : + RationalAt (pairEvaluation n s).toRingHom (variableF i) (pairPoint n s i) := + rationalAt_variable _ _ i + +lemma torusL_phase_five (n:ℕ) : torusL (constF n phase^5)=0 := by + unfold torusL + rw [←pow_add,←pow_add] + simp only [Nat.reduceAdd,torusSin_phase_pow] + have he:(8:ℝ)*lambda=Real.pi := by unfold lambda; ring + simp only [Nat.cast_ofNat,he,Real.sin_pi,Complex.ofReal_zero,constF,map_zero,mul_zero] + +lemma torusL_phase_six (n:ℕ) : torusL (constF n phase^6)=0 := by + unfold torusL + rw [←pow_add,←pow_add] + simp only [Nat.reduceAdd,torusSin_phase_pow] + have he:(8:ℝ)*lambda=Real.pi := by unfold lambda; ring + simp only [Nat.cast_ofNat,he,Real.sin_pi,Complex.ofReal_zero,constF,map_zero,zero_mul] + +lemma pairEvaluation_vacantNumerator {n:ℕ} (s:ℕ) (hs:s=2 ∨ s=3) : + pairEvaluation n s (torusNumeratorL (variableExponent (1:Fin (n+2))-variableExponent 0) (phase^3) .vacant)=0 := by + have hv:RationalAt (pairEvaluation n s).toRingHom + (constF (n+2) phase^3*(variableF (1:Fin (n+2))/variableF 0)) + (constF (n+1) phase^(s+3)) := by + have hh:=((rationalAt_const (pairEvaluation n s) phase).pow 3).mul + ((rationalAt_pair_variable s (1:Fin (n+2))).div (rationalAt_pair_variable s 0) (variableF_ne_zero 0)) + have he:constF (n+1) phase^3*(pairPoint n s 1 / pairPoint n s 0)=constF (n+1) phase^(s+3) := by + change constF (n+1) phase^3*((constF (n+1) phase^s*variableF 0)/variableF 0)=_ + rw [mul_div_cancel_right₀ _ (variableF_ne_zero 0),pow_add,mul_comm] + rwa [he] at hh + have ht:=rationalAt_torusL _ hv (pow_ne_zero _ (constF_phase_ne_zero _)) + have ha:=RationalAt.algebraMap (φ:=(pairEvaluation n s).toRingHom) (F:=SpectralField (n+2)) + (torusNumeratorL (variableExponent (1:Fin (n+2))-variableExponent 0) (phase^3) .vacant) + change RationalAt _ (evalLaurent _) _ at ha + rw [torusNumeratorL_pair_map] at ha + change RationalAt _ (torusL _) _ at ha + have hh:=ha.unique ht + rcases hs with rfl | rfl + · simpa using hh.trans (torusL_phase_five (n+1)) + · simpa using hh.trans (torusL_phase_six (n+1)) + + + + + + + +lemma torusL_phase_small_ne_zero (m k:ℕ) (hk:k≤3) : + torusL (constF m phase^k)≠0 := by + unfold torusL + rw [←pow_add,←pow_add,torusSin_phase_pow,torusSin_phase_pow] + apply mul_ne_zero <;> apply (map_ne_zero (algebraMap ℂ (SpectralField m))).mpr + all_goals apply Complex.ofReal_ne_zero.mpr + all_goals apply ne_of_gt; apply Real.sin_pos_of_pos_of_lt_pi + all_goals unfold lambda; push_cast; nlinarith [Real.pi_pos,show (k:ℝ)≤3 by exact_mod_cast hk, Nat.cast_nonneg (α:=ℝ) k] + +def allOneEvaluation (n:ℕ) : Laurent n →ₐ[ℂ] SpectralField 0 := + torusEvaluation (fun _ =>1) (fun _ =>one_ne_zero) + +lemma rationalAt_phaseRow {n:ℕ} (i:Fin n) (k:ℕ) : + RationalAt (allOneEvaluation n).toRingHom (constF n phase^k/variableF i) (constF 0 phase^k) := by + simpa only [div_one] using ((rationalAt_const (allOneEvaluation n) phase).pow k).div + (rationalAt_variable (fun _ : Fin n =>(1:SpectralField 0)) (fun _ =>one_ne_zero) i) one_ne_zero + +lemma torusL_phaseRow_ne_zero {n:ℕ} (i:Fin n) (k:ℕ) (hk:k≤3) : + torusL (constF n phase^k/variableF i)≠0 := + (rationalAt_torusL (allOneEvaluation n) (rationalAt_phaseRow i k) + (pow_ne_zero _ (constF_phase_ne_zero 0))).ne_zero (torusL_phase_small_ne_zero 0 k hk) + + + +lemma phaseRows_regular {n r:ℕ} (v:Fin r → Fin n) (k:Fin r → ℕ) + (hk:∀j,k j≤3) (hm:∀i j, (k i≠0 ∧ k i≠3) → (k j≠0 ∧ k j≠3) → i=j) : + VacuumRegular (fun j =>torusWeights (constF n phase^(k j)/variableF (v j))) := by + apply torusRegular_of_rationalAt (allOneEvaluation n) _ (fun j =>constF 0 phase^(k j)) + (fun j =>rationalAt_phaseRow (v j) (k j)) + (fun j =>pow_ne_zero _ (constF_phase_ne_zero 0)) + (fun j =>torusL_phase_small_ne_zero 0 (k j) (hk j)) + unfold VacuumRegular + rw [det_one_nonflat] + · exact one_ne_zero + · intro i j hi hj + apply hm i j + · constructor + · intro h; apply hi; left; simp [h, torusWeights_one] + · intro h; apply hi; right; rw [h,torusWeights_phase_three] + · constructor + · intro h; apply hj; left; simp [h,torusWeights_one] + · intro h; apply hj; right; rw [h,torusWeights_phase_three] + +end +end CriticalStrip.Diagram + +end OAI diff --git a/lean/OAI/Combinatorics/StripMass/FluxWindow.lean b/lean/OAI/Combinatorics/StripMass/FluxWindow.lean new file mode 100644 index 0000000000000000000000000000000000000000..903166d30f2499f08fe7e067b77591fc088d2ed3 --- /dev/null +++ b/lean/OAI/Combinatorics/StripMass/FluxWindow.lean @@ -0,0 +1,535 @@ +import Mathlib +import OAI.Combinatorics.StripMass.RibbonGlobal + +namespace OAI + +/-! Critical honeycomb strip paths, polynomial identities and crossing mass. -/ + + +namespace CriticalStrip.HoneycombBranch +noncomputable section +open scoped Classical BigOperators +open FiniteBranchTree Filter Topology + + +def IsExit (D : Vertex→Prop) (i : ℤ) (l : List Bool) : Prop := + l≠[] ∧ (visited Prod.fst next (bottom i) l).Nodup ∧ + (∀v∈visited Prod.fst next (bottom i) l,D v) ∧ + ¬D (terminal next (bottom i) l).1 + +def exitWeight (D : Vertex→Prop) (i : ℤ) (l : List Bool) : ℂ := + if IsExit D i l then wordWeight factor l else 0 + +def window (H : ℕ) (i : ℤ) (m : ℕ) : Finset Vertex := + (Finset.Ico (i-(m:ℤ)) (i+(m:ℤ)+1)).product ((Finset.Ico 0 (H:ℤ)).product Finset.univ) + +@[simp] lemma mem_window (H : ℕ) (i : ℤ) (m : ℕ) (v : Vertex) : + v∈window H i m ↔ i-(m:ℤ)≤v.1 ∧ v.1 < i+(m:ℤ)+1 ∧ 0≤v.2.1 ∧ v.2.1<(H:ℤ) := by + rcases v with ⟨k,r,b⟩ + simp [window, and_assoc] + +def clip (D : Vertex→Prop) (H : ℕ) (i : ℤ) (m : ℕ) : Finset Vertex := + (window H i m).filter D + +def finiteExits (D : Vertex→Prop) (H : ℕ) (i : ℤ) (m : ℕ) : Finset (List Bool) := + (words (clip D H i m) (bottom i)).filter (fun l=>(terminal next (bottom i) l).1∉clip D H i m) + +def physicalExits (D : Vertex→Prop) (H : ℕ) (i : ℤ) (m : ℕ) : Finset (List Bool) := + (finiteExits D H i m).filter (fun l=>¬D (terminal next (bottom i) l).1) + +def sideExits (D : Vertex→Prop) (H : ℕ) (i : ℤ) (m : ℕ) : Finset (List Bool) := + (finiteExits D H i m).filter (fun l=>D (terminal next (bottom i) l).1) + +lemma source_clip {D : Vertex→Prop} {H : ℕ} (hH : 1≤H) {i : ℤ} + (hi : D (bottom i).1) (m : ℕ) : (bottom i).1∈clip D H i m := by + simp only [clip,Finset.mem_filter,mem_window,bottom] + exact ⟨⟨by omega,by omega,by omega,by omega⟩,hi⟩ + +lemma finiteExit_nonempty {D : Vertex→Prop} {H : ℕ} (hH : 1≤H) {i : ℤ} + (hi : D (bottom i).1) {m : ℕ} {l : List Bool} (hl : l∈finiteExits D H i m) : l≠[] := by + intro he + subst l + exact (Finset.mem_filter.mp hl).2 (source_clip hH hi m) + +lemma physicalExit_isExit {D : Vertex→Prop} {H : ℕ} (hH : 1≤H) {i : ℤ} + (hi : D (bottom i).1) {m : ℕ} {l : List Bool} (hl : l∈physicalExits D H i m) : IsExit D i l := by + obtain ⟨he,ht⟩:=Finset.mem_filter.mp hl + refine ⟨finiteExit_nonempty hH hi he,visited_nodup Prod.fst next (Finset.mem_filter.mp he).1,?_,ht⟩ + intro v hv + exact (Finset.mem_filter.mp (visited_mem_domain Prod.fst next (Finset.mem_filter.mp he).1 v hv)).2 + +lemma eventually_window {H : ℕ} {i : ℤ} {v : Vertex} (hv : 0≤v.2.1 ∧ v.2.1<(H:ℤ)) : + ∀ᶠ m : ℕ in atTop,v∈window H i m := by + filter_upwards [eventually_ge_atTop ((v.1-i).natAbs+1)] with m hm + rw [mem_window] + have ha : v.1-i≤((v.1-i).natAbs:ℤ) := Int.le_natAbs + have hb : -(v.1-i)≤((v.1-i).natAbs:ℤ) := by simpa only [Int.natAbs_neg] using (Int.le_natAbs : -(v.1-i)≤((-(v.1-i)).natAbs:ℤ)) + exact ⟨by omega,by omega,hv⟩ + +lemma eventually_physicalExit {D : Vertex→Prop} {H : ℕ} {i : ℤ} + (hD : ∀v,D v→0≤v.2.1 ∧ v.2.1<(H:ℤ)) {l : List Bool} (hl : IsExit D i l) : + ∀ᶠ m : ℕ in atTop,l∈physicalExits D H i m := by + have he : ∀ᶠ m : ℕ in atTop,∀v∈(visited Prod.fst next (bottom i) l).toFinset,v∈window H i m := by + apply (Finset.eventually_all _).mpr + intro v hv + exact eventually_window (hD v (hl.2.2.1 v (List.mem_toFinset.mp hv))) + filter_upwards [he] with m hm + have hout : (terminal next (bottom i) l).1∉clip D H i m := by + intro hx; exact hl.2.2.2 (Finset.mem_filter.mp hx).2 + have hw : l∈words (clip D H i m) (bottom i) := by + apply (mem_leaves_iff _ _ _ _ _).mpr + exact ⟨hl.2.1,fun v hv=>Finset.mem_filter.mpr ⟨hm v (List.mem_toFinset.mpr hv),hl.2.2.1 v hv⟩,Or.inl hout⟩ + exact Finset.mem_filter.mpr ⟨Finset.mem_filter.mpr ⟨hw,hout⟩,hl.2.2.2⟩ + +lemma physicalExit_limit {D : Vertex→Prop} {H : ℕ} (hH : 1≤H) {i : ℤ} + (hi : D (bottom i).1) (hD : ∀v,D v→0≤v.2.1 ∧ v.2.1<(H:ℤ)) + (hs : Summable (exitWeight D i)) : + Tendsto (fun m : ℕ=>∑l∈physicalExits D H i m,wordWeight factor l) + atTop (𝓝 (∑'l,exitWeight D i l)) := by + have he (m : ℕ) : (∑l∈physicalExits D H i m,wordWeight factor l)= + ∑'l,if l∈physicalExits D H i m then wordWeight factor l else 0 := by + symm + rw [tsum_eq_sum (s:=physicalExits D H i m) (fun l hl=>ite_eq_right hl)] + apply Finset.sum_congr rfl + intro l hl + rw [ite_eq_left hl] + simp_rw [he] + apply tendsto_tsum_of_dominated_convergence hs.norm + · intro l + by_cases hl : IsExit D i l + · apply tendsto_const_nhds.congr' + filter_upwards [eventually_physicalExit hD hl] with m hm + simp [exitWeight,hl,hm] + · apply tendsto_const_nhds.congr' + apply Eventually.of_forall + intro m + have hn : l∉physicalExits D H i m := fun hm=>hl (physicalExit_isExit hH hi hm) + simp [exitWeight,hl,hn] + · apply Eventually.of_forall + intro m l + split_ifs with hl + · rw [exitWeight,ite_eq_left (physicalExit_isExit hH hi hl)] + · simpa only [norm_zero] using norm_nonneg (exitWeight D i l) + +lemma crossing_column {H : ℕ} {i : ℤ} {m : ℕ} {s : State} + (hp : (back s).1∈window H i m) (hs : 0 ≤ s.1.2.1 ∧ s.1.2.1 < (H:ℤ)) + (hn : s.1∉window H i m) : s.2=1 ∧ (s.1.1=i-(m:ℤ)-1 ∨ s.1.1=i+(m:ℤ)+1) := by + rcases s with ⟨⟨k,r,b⟩,p⟩ + fin_cases p <;> cases b <;> simp [mem_window,back,neighbor] at hp hs hn ⊢ <;> omega + +lemma sideExit_column {D : Vertex→Prop} {H : ℕ} (hH : 1≤H) {i : ℤ} + (hi : D (bottom i).1) (hD : ∀v,D v→0≤v.2.1 ∧ v.2.1<(H:ℤ)) {m : ℕ} {l : List Bool} + (hl : l∈sideExits D H i m) : + (terminal next (bottom i) l).2=1 ∧ + ((terminal next (bottom i) l).1.1=i-(m:ℤ)-1 ∨ (terminal next (bottom i) l).1.1=i+(m:ℤ)+1) := by + obtain ⟨he,hd⟩:=Finset.mem_filter.mp hl + obtain ⟨hw,hn⟩:=Finset.mem_filter.mp he + apply crossing_column + (Finset.mem_filter.mp (visited_mem_domain Prod.fst next hw _ + (lastVisited_mem _ _ (finiteExit_nonempty hH hi he)))).1 (hD _ hd) + intro hm + exact hn (Finset.mem_filter.mpr ⟨hm,hd⟩) + +lemma sideExit_spec {D : Vertex→Prop} {H : ℕ} (hH : 1≤H) {i k : ℤ} + (hi : D (bottom i).1) (hD : ∀v,D v→0≤v.2.1 ∧ v.2.1<(H:ℤ)) {m : ℕ} {l : List Bool} + (hl : l∈sideExits D H i m) (hk : (terminal next (bottom i) l).1.1=k) : + l≠[] ∧ (visited Prod.fst next (bottom i) l).Nodup ∧ + (∀v∈visited Prod.fst next (bottom i) l,0≤v.2.1 ∧ v.2.1<(H:ℤ) ∧ v.1≠k) ∧ + (terminal next (bottom i) l).2=1 ∧ (terminal next (bottom i) l).1.1=k := by + have he := (Finset.mem_filter.mp hl).1 + have hw := (Finset.mem_filter.mp he).1 + have hc:=sideExit_column hH hi hD hl + refine ⟨finiteExit_nonempty hH hi he,visited_nodup Prod.fst next hw,?_,hc.1,hk⟩ + intro v hv + have hm:=Finset.mem_filter.mp (visited_mem_domain Prod.fst next hw v hv) + have hb:=hD _ hm.2 + have hcol:=(mem_window H i m v).mp hm.1 + exact ⟨hb.1,hb.2,by rcases hc.2 with hc|hc <;> omega⟩ + +lemma side_sum_bound {D : Vertex→Prop} {H : ℕ} (hH : 1≤H) {i k : ℤ} + (hi : D (bottom i).1) (hD : ∀v,D v→0≤v.2.1 ∧ v.2.1<(H:ℤ)) {m : ℕ} + (F : Finset (List Bool)) (hF : F⊆sideExits D H i m) + (hk : ∀l∈F,(terminal next (bottom i) l).1.1=k) (hik : i≠k) : + ∑l∈F,rho^l.length ≤ (rho^(2*H))⁻¹*K H (k-i) := by + let e : F→SideWord H i k:=fun l=>⟨l.val,sideExit_spec hH hi hD (hF l.property) (hk l.val l.property)⟩ + have he : Function.Injective e := by intro l n h; apply Subtype.ext; exact congrArg (fun x : SideWord H i k=>x.val) h + have hs:=SideWord.sum_le hH hik (Finset.univ.image e) + rw [Finset.sum_image (fun x _ y _ h=>he h)] at hs + change (∑x : F,rho^x.val.length)≤_ at hs + rw [←Finset.sum_coe_sort F (fun l : List Bool=>rho^l.length)] + exact hs + +lemma sideExit_bound {D : Vertex→Prop} {H : ℕ} (hH : 1≤H) {i : ℤ} + (hi : D (bottom i).1) (hD : ∀v,D v→0≤v.2.1 ∧ v.2.1<(H:ℤ)) (m : ℕ) : + ‖∑l∈sideExits D H i m,wordWeight factor l‖ ≤ + (rho^(2*H))⁻¹*(K H (-(m:ℤ)-1)+K H ((m:ℤ)+1)) := by + have hl:=side_sum_bound hH hi hD + ((sideExits D H i m).filter (fun l=>(terminal next (bottom i) l).1.1=i-(m:ℤ)-1)) + (Finset.filter_subset _ _) (fun l hl=>(Finset.mem_filter.mp hl).2) (by omega : i≠i-(m:ℤ)-1) + have hr:=side_sum_bound hH hi hD + ((sideExits D H i m).filter (fun l=>¬(terminal next (bottom i) l).1.1=i-(m:ℤ)-1)) + (Finset.filter_subset _ _) (fun l hl=>(sideExit_column hH hi hD (Finset.mem_filter.mp hl).1).2.resolve_left + (Finset.mem_filter.mp hl).2) (by omega : i≠i+(m:ℤ)+1) + have hs:=Finset.sum_filter_add_sum_filter_not (sideExits D H i m) + (fun l=>(terminal next (bottom i) l).1.1=i-(m:ℤ)-1) (fun l : List Bool=>rho^l.length) + calc + _ ≤ ∑l∈sideExits D H i m,‖wordWeight factor l‖ := norm_sum_le _ _ + _ = ∑l∈sideExits D H i m,rho^l.length := by simp only [wordWeight_norm] + _ ≤ _ := by + rw [←hs] + have he₁ : i-(m:ℤ)-1-i= -(m:ℤ)-1 := by ring + have he₂ : i+(m:ℤ)+1-i=(m:ℤ)+1 := by ring + rw [he₁] at hl + rw [he₂] at hr + simpa only [mul_add] using add_le_add hl hr + +lemma finite_split {D : Vertex→Prop} {H : ℕ} {i : ℤ} + (hD : ∀v,D v→0≤v.2.1 ∧ v.2.1<(H:ℤ)) (m : ℕ) : + (∑l∈physicalExits D H i m,wordWeight factor l)+ + (∑l∈sideExits D H i m,wordWeight factor l)=1 := by + have hs:=Finset.sum_filter_add_sum_filter_not (finiteExits D H i m) + (fun l=>¬D (terminal next (bottom i) l).1) (wordWeight factor) + simp only [not_not] at hs + rw [physicalExits,sideExits,hs] + exact finite_boundary_flux _ i (fun v hv=>(hD _ (Finset.mem_filter.mp hv).2).1) + + + +theorem infinite_boundary_flux {D : Vertex→Prop} {H : ℕ} (hH : 1≤H) {i : ℤ} + (hi : D (bottom i).1) (hD : ∀v,D v→0≤v.2.1 ∧ v.2.1<(H:ℤ)) + (hs : Summable (exitWeight D i)) : ∑'l,exitWeight D i l=1 := by + have hleft : Summable (fun m : ℕ=>K H (-(m:ℤ)-1)) := + (stripSumsFinite hH).2.2.1.comp_injective (i:=fun m : ℕ=> -(m:ℤ)-1) (by intro m n he; dsimp at he; omega) + have hright : Summable (fun m : ℕ=>K H ((m:ℤ)+1)) := + (stripSumsFinite hH).2.2.1.comp_injective (i:=fun m : ℕ=> (m:ℤ)+1) (by intro m n he; dsimp at he; omega) + have hb : Tendsto (fun m : ℕ=>(rho^(2*H))⁻¹*(K H (-(m:ℤ)-1)+K H ((m:ℤ)+1))) atTop (𝓝 0) := by + simpa using (hleft.tendsto_atTop_zero.add hright.tendsto_atTop_zero).const_mul ((rho^(2*H))⁻¹) + have hz : Tendsto (fun m : ℕ=>∑l∈sideExits D H i m,wordWeight factor l) atTop (𝓝 0) := + squeeze_zero_norm (fun m=>sideExit_bound hH hi hD m) hb + have ht:=(physicalExit_limit hH hi hD hs).add hz + simp only [add_zero] at ht + have hc : Tendsto (fun m : ℕ=>(∑l∈physicalExits D H i m,wordWeight factor l)+ + (∑l∈sideExits D H i m,wordWeight factor l)) atTop (𝓝 1) := by + simpa only [finite_split hD] using (tendsto_const_nhds : Tendsto (fun _ : ℕ=>(1:ℂ)) atTop (𝓝 1)) + exact tendsto_nhds_unique ht hc + +end + + + + + +noncomputable section +open scoped Classical BigOperators +open FiniteBranchTree + + +structure BoundaryPorts (D : Vertex→Prop) (B : Type*) where + port : B→State + injective : Function.Injective port + inside : ∀b,D (port b).1 + outside : ∀b,¬D (back (port b)).1 + complete : ∀s : State,D s.1→¬D (back s).1→∃b,port b=s + +abbrev ExitWord (D : Vertex→Prop) (i : ℤ) := {l : List Bool // IsExit D i l} + +variable {D : Vertex→Prop} {B : Type*} (P : BoundaryPorts D B) {H : ℕ} {i : ℤ} + +def ValidBoundaryPath (H : ℕ) (i : ℤ) (x : B×List Triangle) : Prop := + bottom i≠P.port x.1 ∧ + PathBetween H (up i 0) (retractVertex (P.port x.1).1) x.2 ∧ + ∀v∈x.2,D (embedTriangle v) + +abbrev BoundaryPath (H : ℕ) (i : ℤ) := {x : B×List Triangle // ValidBoundaryPath P H i x} + +def boundaryPathWeight (H : ℕ) (i : ℤ) (x : B×List Triangle) : ℝ := + if ValidBoundaryPath P H i x then rho^x.2.length else 0 + +lemma boundaryPathWeight_nonneg (H : ℕ) (i : ℤ) (x : B×List Triangle) : + 0≤boundaryPathWeight P H i x := by + unfold boundaryPathWeight + split_ifs <;> positivity [rho_pos] + +lemma source_outside (hD : ∀v,D v→0≤v.2.1 ∧ v.2.1<(H:ℤ)) : ¬D (back (bottom i)).1 := by + intro hx + have hh:=(hD _ hx).1 + norm_num [back,bottom,neighbor] at hh + +lemma exists_exit_port (x : ExitWord D i) : ∃b,P.port b=back (terminal next (bottom i) x.val) := by + apply P.complete + · exact x.property.2.2.1 _ (lastVisited_mem _ _ x.property.1) + · simpa only [back_back] using x.property.2.2.2 + +def exitPort (x : ExitWord D i) : B := Classical.choose (exists_exit_port P x) + +lemma exitPort_spec (x : ExitWord D i) : + P.port (exitPort P x)=back (terminal next (bottom i) x.val) := Classical.choose_spec (exists_exit_port P x) + +lemma exitPort_terminal (x : ExitWord D i) : + terminal next (bottom i) x.val=back (P.port (exitPort P x)) := by + rw [exitPort_spec,back_back] + +lemma visited_map_retract (l : List Bool) + (hrow : ∀v∈visited Prod.fst next (bottom i) l,0≤v.2.1) : + ((visited Prod.fst next (bottom i) l).map retractVertex).map embedTriangle= + visited Prod.fst next (bottom i) l := by + rw [List.map_map] + conv_rhs => rw [←List.map_id (visited Prod.fst next (bottom i) l)] + exact List.map_congr_left (fun v hv=>embed_retract v (hrow v hv)) + +def exitToPath (hD : ∀v,D v→0≤v.2.1 ∧ v.2.1<(H:ℤ)) (x : ExitWord D i) : BoundaryPath P H i := by + refine ⟨(exitPort P x,(visited Prod.fst next (bottom i) x.val).map retractVertex),?_,?_,?_⟩ + · intro he + exact word_terminal_ne_source x.property.1 x.property.2.1 + (by calc + terminal next (bottom i) x.val=back (P.port (exitPort P x)) := exitPort_terminal P x + _=back (bottom i) := congrArg back he.symm) + · apply visited_retract_path H (up i 0) _ (bottom i) x.val x.property.1 rfl + _ x.property.2.1 (fun v hv=>hD v (x.property.2.2.1 v hv)) + rw [←exitPort_spec] + exact (embed_retract _ (hD _ (P.inside _)).1).symm + · intro v hv + obtain ⟨w,hw,rfl⟩:=List.mem_map.mp hv + rw [embed_retract _ (hD _ (x.property.2.2.1 w hw)).1] + exact x.property.2.2.1 w hw + +lemma exitToPath_injective (hD : ∀v,D v→0≤v.2.1 ∧ v.2.1<(H:ℤ)) : + Function.Injective (exitToPath P (i:=i) hD) := by + intro x y he + have hb:=congrArg (fun z : BoundaryPath P H i=>z.val.1) he + have hp:=congrArg (fun z : BoundaryPath P H i=>z.val.2.map embedTriangle) he + change exitPort P x=exitPort P y at hb + change ((visited Prod.fst next (bottom i) x.val).map retractVertex).map embedTriangle= + ((visited Prod.fst next (bottom i) y.val).map retractVertex).map embedTriangle at hp + rw [visited_map_retract _ (fun v hv=>(hD v (x.property.2.2.1 v hv)).1), + visited_map_retract _ (fun v hv=>(hD v (y.property.2.2.1 v hv)).1)] at hp + apply Subtype.ext + exact word_unique _ _ _ hp (by rw [exitPort_terminal P x,exitPort_terminal P y,hb]) + +lemma exitToPath_surjective (hD : ∀v,D v→0≤v.2.1 ∧ v.2.1<(H:ℤ)) : + Function.Surjective (exitToPath P (i:=i) hD) := by + intro x + have hp:=x.property.2.1 + have hh : (x.val.2.map embedTriangle).head?=some (bottom i).1 := by + rw [List.head?_map,hp.1]; rfl + have ht : (x.val.2.map embedTriangle).getLast?=some (back (back (P.port x.val.1))).1 := by + rw [back_back,List.getLast?_map,hp.2.1,Option.map_some,embed_retract _ (hD _ (P.inside _)).1] + have hn : (x.val.2.map embedTriangle).Nodup := hp.2.2.1.map embedTriangle_injective + have hc : (x.val.2.map embedTriangle).IsChain (fun v w=>∃q : Fin 3,neighbor v q=w) := + (List.isChain_map _).mpr (hp.2.2.2.1.imp (fun v w h=>(adjacent_iff v w).mp h)) + have hi : (back (bottom i)).1∉x.val.2.map embedTriangle := by + intro hv + obtain ⟨v,hv,he⟩:=List.mem_map.mp hv + exact source_outside hD (he ▸ x.property.2.2 v hv) + have ho : (back (P.port x.val.1)).1∉x.val.2.map embedTriangle := by + intro hv + obtain ⟨v,hv,he⟩:=List.mem_map.mp hv + exact P.outside _ (he ▸ x.property.2.2 v hv) + obtain ⟨l,hv,he⟩:=exists_word (bottom i) (back (P.port x.val.1)) (x.val.2.map embedTriangle) + hh ht hn hc hi ho (by simpa only [back_back] using x.property.1) + have hne:=word_nonempty_of_head _ _ _ hh hv + have hl : IsExit D i l := by + refine ⟨hne,by rw [hv]; exact hn,?_,?_⟩ + · intro v hm + rw [hv] at hm + obtain ⟨w,hw,rfl⟩:=List.mem_map.mp hm + exact x.property.2.2 w hw + · rw [he]; exact P.outside _ + refine ⟨⟨l,hl⟩,?_⟩ + apply Subtype.ext + apply Prod.ext + · apply P.injective + rw [show (exitToPath P hD ⟨l,hl⟩).val.1=exitPort P ⟨l,hl⟩ from rfl, + exitPort_spec,he,back_back] + · change (visited Prod.fst next (bottom i) l).map retractVertex=x.val.2 + rw [hv,List.map_map] + calc + List.map (retractVertex ∘ embedTriangle) x.val.2=List.map id x.val.2 := + List.map_congr_left (fun v _=>retract_embed v) + _=x.val.2 := List.map_id x.val.2 + +def exitPathEquiv (hD : ∀v,D v→0≤v.2.1 ∧ v.2.1<(H:ℤ)) : ExitWord D i ≃ BoundaryPath P H i := + Equiv.ofBijective (exitToPath P hD) ⟨exitToPath_injective P hD,exitToPath_surjective P hD⟩ + +lemma exitPathEquiv_length (hD : ∀v,D v→0≤v.2.1 ∧ v.2.1<(H:ℤ)) (x : ExitWord D i) : + (exitPathEquiv P hD x).val.2.length=x.val.length := by + change ((visited Prod.fst next (bottom i) x.val).map retractVertex).length=x.val.length + simp only [List.length_map,visited_length] + +lemma boundaryPath_summable_iff : + Summable (fun x : BoundaryPath P H i=>rho^x.val.2.length) ↔ Summable (boundaryPathWeight P H i) := by + change Summable (fun x : {x | ValidBoundaryPath P H i x}=>rho^x.val.2.length) ↔ _ + exact summable_subtype_iff_indicator (s:={x | ValidBoundaryPath P H i x}) + (f:=fun x : B×List Triangle=>rho^x.2.length) + +lemma exitWord_summable_iff : + Summable (fun x : ExitWord D i=>rho^x.val.length) ↔ + Summable (fun l=>if IsExit D i l then rho^l.length else 0) := by + exact summable_subtype_iff_indicator (s:={l | IsExit D i l}) (f:=fun l : List Bool=>rho^l.length) + +lemma exit_weight_norm (l : List Bool) : + ‖exitWeight D i l‖=if IsExit D i l then rho^l.length else 0 := by + unfold exitWeight + split_ifs <;> simp only [wordWeight_norm,norm_zero] + + + +theorem exitWeight_summable (hD : ∀v,D v→0≤v.2.1 ∧ v.2.1<(H:ℤ)) + (hs : Summable (boundaryPathWeight P H i)) : Summable (exitWeight D i) := by + have hpath := (boundaryPath_summable_iff P (H:=H) (i:=i)).mpr hs + have hw : Summable (fun x : ExitWord D i=>rho^(exitPathEquiv P hD x).val.2.length) := + ((exitPathEquiv P (i:=i) hD).summable_iff + (f:=fun x : BoundaryPath P H i=>rho^x.val.2.length)).mpr hpath + have hw' : Summable (fun x : ExitWord D i=>rho^x.val.length) := + hw.congr (fun x=>congrArg (fun n : ℕ=>rho^n) (exitPathEquiv_length P hD x)) + have hi := (exitWord_summable_iff (D:=D) (i:=i)).mp hw' + apply (summable_norm_iff (f:=exitWeight D i)).mp + exact hi.congr (fun l=>(exit_weight_norm (D:=D) (i:=i) l).symm) + + +theorem exitWeight_tsum (hD : ∀v,D v→0≤v.2.1 ∧ v.2.1<(H:ℤ)) (θ : B→ℤ) + (hθ : ∀x : ExitWord D i,turn x.val=θ (exitPort P x)) : + (∑'l,exitWeight D i l)= + ∑'x : B×List Triangle,(boundaryPathWeight P H i x:ℂ)*Diagram.phase^(θ x.1) := by + calc + _ = ∑'x : ExitWord D i,wordWeight factor x.val := + (tsum_subtype {l | IsExit D i l} (wordWeight factor)).symm + _ = ∑'x : ExitWord D i,(rho:ℂ)^(exitPathEquiv P hD x).val.2.length * + Diagram.phase^(θ (exitPathEquiv P hD x).val.1) := by + apply tsum_congr + intro x + rw [wordWeight_eq,exitPathEquiv_length,hθ] + rfl + _ = ∑'x : BoundaryPath P H i,(rho:ℂ)^x.val.2.length*Diagram.phase^(θ x.val.1) := + (exitPathEquiv P (i:=i) hD).tsum_eq (fun x : BoundaryPath P H i=>(rho:ℂ)^x.val.2.length*Diagram.phase^(θ x.val.1)) + _ = _ := by + change (∑'x : {x | ValidBoundaryPath P H i x},(rho:ℂ)^x.val.2.length*Diagram.phase^(θ x.val.1))=_ + rw [tsum_subtype {x | ValidBoundaryPath P H i x} (fun x : B×List Triangle=>(rho:ℂ)^x.2.length*Diagram.phase^(θ x.1))] + apply tsum_congr + intro x + simp only [Set.indicator,Set.mem_ofPred_eq,boundaryPathWeight] + split_ifs <;> simp + + + +theorem boundary_flux (hH : 1≤H) (hi : D (bottom i).1) + (hD : ∀v,D v→0≤v.2.1 ∧ v.2.1<(H:ℤ)) (hs : Summable (boundaryPathWeight P H i)) + (θ : B→ℤ) (hθ : ∀x : ExitWord D i,turn x.val=θ (exitPort P x)) : + (∑'x : B×List Triangle,(boundaryPathWeight P H i x:ℂ)*Diagram.phase^(θ x.1))=1 := by + rw [←exitWeight_tsum P hD θ hθ] + exact infinite_boundary_flux hH hi hD (exitWeight_summable P hD hs) + +end + + + + + +noncomputable section +open scoped Classical +open FiniteBranchTree + + +def steppedVertices (N : ℕ) (s : ℤ) (v : Vertex) : Prop := + 0≤v.2.1 ∧ (v.2.1<(N:ℤ) ∨ v.2.1=(N:ℤ) ∧ s≤v.1) + +lemma steppedVertices_embed (N : ℕ) (s : ℤ) (v : Triangle) : + steppedVertices N s (embedTriangle v) ↔ steppedDomain N s v := by + dsimp [steppedVertices,embedTriangle,steppedDomain] + omega + +lemma steppedVertices_bound (N : ℕ) (s : ℤ) (v : Vertex) (hv : steppedVertices N s v) : + 0≤v.2.1 ∧ v.2.1<((N+1:ℕ):ℤ) := by + dsimp [steppedVertices] at hv + exact ⟨hv.1,by omega⟩ + +def sidePort (N : ℕ) (s : ℤ) : State := ((s,(N:ℤ),true),1) + +def stepTop (N : ℕ) (s j : ℤ) : State := if j dsimp <;> omega) he + simpa [turn_append,turn,sign] using hh + +lemma step_top_turn (N : ℕ) (hN : 1≤N) (s i j : ℤ) + (l : List Bool) (hl : l≠[]) (hn : (visited Prod.fst next (bottom i) l).Nodup) + (hD : ∀v∈visited Prod.fst next (bottom i) l,steppedVertices N s v) + (ht : terminal next (bottom i) l=back (stepTop N s j)) : turn l=0 := by + by_cases hj : jsteppedVertices_bound N s v (hD v hv)) ht + +lemma step_side_turn (N : ℕ) (s i : ℤ) + (l : List Bool) (_hl : l≠[]) (hn : (visited Prod.fst next (bottom i) l).Nodup) + (hD : ∀v∈visited Prod.fst next (bottom i) l,steppedVertices N s v) + (ht : terminal next (bottom i) l=back (sidePort N s)) : turn l=1 := by + have hd : (s-1,(N:ℤ),false)∉visited Prod.fst next (bottom i) l := by + intro hv + have hh:=hD _ hv + simp only [steppedVertices,lt_self_iff_false,true_and,false_or] at hh + omega + have hv : visited Prod.fst next (bottom i) (l++[false])= + visited Prod.fst next (bottom i) l++[(s-1,(N:ℤ),false)] := by + rw [visited_append,ht] + simp [visited,back,sidePort,neighbor] + have he : terminal next (bottom i) (l++[false])=back (top (N+1) (s-1)) := by + rw [terminal_append,ht] + simp [terminal,back,top,sidePort,neighbor,next,outgoing,Fin.add_def] + have hh:=top_turn (N+1) (by omega) i (s-1) (l++[false]) (by simp) (by + rw [hv] + apply List.nodup_append.mpr + refine ⟨hn,by simp,?_⟩ + intro v hm w hw hew + have hw:=List.mem_singleton.mp hw + exact hd ((hew.trans hw) ▸ hm)) (by + intro v hm + rw [hv] at hm + rcases List.mem_append.mp hm with hm|hm + · exact steppedVertices_bound N s v (hD v hm) + · have he:=List.mem_singleton.mp hm + rw [he] + dsimp + omega) he + simp [turn_append,turn,sign] at hh + omega + +end +end CriticalStrip.HoneycombBranch + +end OAI diff --git a/lean/OAI/Combinatorics/StripMass/FreshGate.lean b/lean/OAI/Combinatorics/StripMass/FreshGate.lean new file mode 100644 index 0000000000000000000000000000000000000000..8f692c9137ef77750add6c3ad5aa8b8ec1d4212d --- /dev/null +++ b/lean/OAI/Combinatorics/StripMass/FreshGate.lean @@ -0,0 +1,493 @@ +import Mathlib +import OAI.Combinatorics.StripMass.WireContraction + +namespace OAI + +/-! Critical honeycomb strip paths, polynomial identities and crossing mass. -/ + + + +namespace CriticalStrip.Diagram +noncomputable section +open scoped Classical +namespace FreshGate +variable {V : Type*} {n : ℕ} + + +structure Ports (r : V → V → Prop) (old : Fin n → V) where + port : Fin 4 → V + select : V → Option (Fin 4) + select_port : ∀ k, select (port k)=some k + of_some : ∀ v k, select v=some k → v=port k + old_none : ∀ i, select (old i)=none + edge_none : ∀ v w, r v w → select v=none + +namespace Ports +variable {r : V → V → Prop} {old : Fin n → V} (f : Ports r old) + +def project : Sum V (Fin 4) → V + | .inl v => v + | .inr k => f.port k + +def core (v : V) : Sum V (Fin 4) := + match f.select v with | none => .inl v | some k => .inr k + +@[simp] theorem project_core (v : V) : f.project (f.core v)=v := by + cases h : f.select v with + | none => simp [core,h,project] + | some k => simpa [core,h,project] using (f.of_some v k h).symm + +@[simp] theorem core_port (k : Fin 4) : f.core (f.port k)=.inr k := by simp [core,f.select_port] +@[simp] theorem core_old (i : Fin n) : f.core (old i)=.inl (old i) := by simp [core,f.old_none] + +def boundary (a b : Fin n) (i : Fin n) : V := f.project (CompactGate.boundary old a b i) + +def wiring (active : Fin n → Prop) (a b : Fin n) (t : Tile) (v w : V) : Prop := + CompactGate.wiring r old active a b t (f.core v) (f.core w) + +lemma core_boundary (a b i : Fin n) : f.core (f.boundary a b i)=CompactGate.boundary old a b i := by + by_cases hia : i=a <;> by_cases hib : i=b <;> + simp_all [boundary,CompactGate.boundary,project] + +lemma core_project_used (active : Fin n → Prop) (a b : Fin n) (t : Tile) + (v : Sum V (Fin 4)) (hv : Graph.Used (CompactGate.wiring r old active a b t) v) : + f.core (f.project v)=v := by + cases v with + | inr k => exact f.core_port k + | inl v => + have hn : f.select v=none := by + obtain ⟨w,hw⟩ := hv + cases w with + | inl w => exact f.edge_none v w hw + | inr k => + rcases hw with ⟨rfl,_,_⟩ | ⟨rfl,_,_⟩ <;> exact f.old_none _ + simp [project,core,hn] + +instance wiring_symm [Std.Symm r] (active : Fin n → Prop) (a b : Fin n) (t : Tile) : + Std.Symm (f.wiring active a b t) := by + constructor + intro v w h + change CompactGate.wiring r old active a b t (f.core v) (f.core w) at h + change CompactGate.wiring r old active a b t (f.core w) (f.core v) + exact symm h + + def contraction [Std.Symm r] (hinj : Function.Injective old) + (active : Fin n → Prop) (a b : Fin n) (t : Tile) : + Graph.WireContraction (CompactGate.wiring r old active a b t) + (f.wiring active a b t) (CompactGate.boundary old a b) (f.boundary a b) where + project := f.project + core := f.core + section_eq := f.project_core + map_edge := by + intro v w h + apply Relation.ReflTransGen.single + change CompactGate.wiring r old active a b t (f.core (f.project v)) (f.core (f.project w)) + rw [f.core_project_used active a b t v ⟨w,h⟩, + f.core_project_used active a b t w ⟨v,symm h⟩] + exact h + core_edge := fun _ _ h => h + map_boundary := fun _ => rfl + boundary_injective := by + intro i j hij + apply CompactGate.boundary_injective old hinj a b + have he := congrArg f.core hij + simpa only [f.core_boundary] using he + map_used := by + intro v ⟨w,h⟩ + refine ⟨f.project w,?_⟩ + change CompactGate.wiring r old active a b t (f.core (f.project v)) (f.core (f.project w)) + rw [f.core_project_used active a b t v ⟨w,h⟩, + f.core_project_used active a b t w ⟨v,symm h⟩] + exact h + retract := by + intro v hv + rw [f.core_project_used active a b t v hv] + boundary_retract := by + intro i _ + rw [f.core_boundary] + + theorem realizes_iff [Std.Symm r] (hinj : Function.Injective old) + (active : Fin n → Prop) (a b : Fin n) (t : Tile) (q : Pairing n) : + GraphRealizes (CompactGate.wiring r old active a b t) (CompactGate.boundary old a b) q ↔ + GraphRealizes (f.wiring active a b t) (f.boundary a b) q := + (f.contraction hinj active a b t).realizes_iff + +end Ports +end FreshGate +namespace PartialColumn + +abbrev V (n : ℕ) := Sum (Fin (n+1)) (Vertex n) + +def wiring {n : ℕ} (p : Pairing n) (t : Configuration n) (k : ℕ) : V n → V n → Prop + | .inl i, .inl j => p.padBottom.Adj i j + | .inl i, .inr (j,a) | .inr (j,a), .inl i => + j.val + (i=j ∧ i.val by_cases hj : j.val + by_cases hi' : i.val=k ∧ 0 by_cases hj' : j.val=k ∧ 0 + simp_all [boundary] + + def select {n : ℕ} (row : Fin n) : V n → Option (Fin 4) + | .inl _ => none + | .inr (i,a) => if i=row then some a else none + + def ports {n : ℕ} (p : Pairing n) (t : Configuration n) (row : Fin n) : + FreshGate.Ports (wiring p t row.val) (boundary row.val (Nat.le_of_lt row.isLt)) where + port := fun a => .inr (row,a) + select := select row + select_port := fun a => by simp [select] + of_some := by + rintro (i|⟨i,a⟩) b h + · simp [select] at h + · by_cases hi : i=row + · subst i; simpa [select] using h + · simp [select,hi] at h + old_none := by + intro i + by_cases hi : i.val omega + simp only [select] + apply ite_eq_right + intro he; subst i; omega + +section RowTransitions +variable {n : ℕ} (p : Pairing n) (t : Configuration n) (row : Fin n) + + def prev (h : 0 hia (Fin.ext h) + have hib' : i.val≠row.val+1 := fun h => hib (Fin.ext h) + have hlt : i.val simp [hi,hia',hib'] + +lemma support_step (i : Fin (n+1)) : + (if i=row.castSucc then (t row).Occupied 2 else + if i=row.succ then (t row).Occupied 3 else support p t row.val (Nat.le_of_lt row.isLt) i) ↔ + support p t (row.val+1) row.isLt i := by + have ha : row.castSucc≠row.succ := by intro hh; have he := congrArg Fin.val hh; dsimp at he; omega + by_cases hia : i=row.castSucc + · subst i; simp [support] + · by_cases hib : i=row.succ + · subst i; simp [support,ha.symm] + · have hia' : i.val≠row.val := fun h => hia (Fin.ext h) + have hib' : i.val≠row.val+1 := fun h => hib (Fin.ext h) + have hlt : i.val simp [hi,hia',hib'] + +lemma core_initial (i : Fin (n+1)) : (ports p t row).core (.inl i)=.inl (.inl i) := rfl +lemma core_box (i : Fin n) (a : Fin 4) : (ports p t row).core (.inr (i,a))= + if i=row then .inr a else .inl (.inr (i,a)) := by + by_cases hi : i=row <;> simp [FreshGate.Ports.core,ports,select,hi] + + abbrev nextWiring := (ports p t row).wiring (support p t row.val (Nat.le_of_lt row.isLt)) + row.castSucc row.succ (t row) + +lemma next_initial (i j : Fin (n+1)) : + nextWiring p t row (.inl i) (.inl j) ↔ wiring p t (row.val+1) (.inl i) (.inl j) := by + rfl + +lemma next_mixed (i : Fin (n+1)) (j : Fin n) (b : Fin 4) : + nextWiring p t row (.inl i) (.inr (j,b)) ↔ wiring p t (row.val+1) (.inl i) (.inr (j,b)) := by + by_cases hj : j=row + · subst j + simp only [nextWiring,FreshGate.Ports.wiring,core_initial,core_box,CompactGate.wiring] + rw [right_boundary,right_support] + by_cases hrow : row.val=0 + · rw [left_boundary_zero row hrow] + simp [left_support_zero p t row hrow,wiring] + · rw [left_boundary_pos row (by omega),left_support_pos p t row (by omega)] + simp [wiring] + · have hlt : j.val hj (Fin.ext he) + omega + simp [nextWiring,FreshGate.Ports.wiring,core_initial,core_box,hj,CompactGate.wiring,wiring,hlt] + +lemma prev_val_add (h : 0 hi (Fin.ext he) + have hj' : j.val≠row.val := fun he => hj (Fin.ext he) + have hli : i.val rcases w with j | ⟨j,b⟩ + · exact next_initial p t row i j + · exact next_mixed p t row i j b + · constructor + · intro h; exact symm ((next_mixed p t row j i a).mp (symm h)) + · intro h; exact symm ((next_mixed p t row j i a).mpr (symm h)) + · by_cases hi : i=row + · subst i + by_cases hj : j=row + · subst j; exact next_new_new p t row a b + · exact next_new_old p t row j hj a b + · by_cases hj : j=row + · subst j + constructor + · intro h; exact symm ((next_new_old p t row i hi b a).mp (symm h)) + · intro h; exact symm ((next_new_old p t row i hi b a).mpr (symm h)) + · exact next_old_old p t row i j hi hj a b + +lemma next_eq : nextWiring p t row = wiring p t (row.val+1) := by + funext v w + exact propext (next_iff p t row v w) + +end RowTransitions + +variable {n : ℕ} (hn : 0 (i,2)) + +def fullProject : V n → Vertex n + | .inr v => v + | .inl i => Fin.cases (⟨0,hn⟩,0) (fun j => (j,1)) i + +lemma full_box {i j : Fin n} {a b : Fin 4} + (h : wiring p t n (.inr (i,a)) (.inr (j,b))) : Wiring p t (i,a) (j,b) := by + rcases h with ⟨hij,_,hab⟩ | ⟨ha,hb,hij,_,ht⟩ | ⟨hb,ha,hij,_,ht⟩ + · exact Or.inl ⟨hij,hab⟩ + · exact Or.inr (Or.inr (Or.inl ⟨ha,hb,hij,ht⟩)) + · exact Or.inr (Or.inr (Or.inr ⟨hb,ha,hij,ht⟩)) + +lemma full_initial_zero (v : V n) : ¬ wiring p t n (.inl 0) v := by + rcases v with i | ⟨j,a⟩ + · exact p.padBottom_not_adj_zero i + · rintro ⟨_,he,_,_⟩ + have hh := congrArg Fin.val he + simp at hh + +lemma full_mixed {i : Fin (n+1)} {j : Fin n} {a : Fin 4} + (h : wiring p t n (.inl i) (.inr (j,a))) : + fullProject hn (.inl i)=(j,a) ∧ p.Occupied j := by + obtain ⟨_,rfl,rfl,hp⟩ := h + exact ⟨rfl,hp⟩ + +lemma full_map_edge (v w : V n) (h : wiring p t n v w) : + Reach p t (fullProject hn v) (fullProject hn w) := by + rcases v with i | ⟨i,a⟩ <;> rcases w with j | ⟨j,b⟩ + · induction i using Fin.cases with + | zero => exact (p.padBottom_not_adj_zero j h).elim + | succ i => + induction j using Fin.cases with + | zero => exact (p.padBottom_not_adj_zero' i.succ h).elim + | succ j => exact .single (Or.inr (Or.inl ⟨rfl,rfl,(p.padBottom_adj_succ i j).mp h⟩)) + · rw [(full_mixed hn p t h).1]; exact .refl + · have hh := (full_mixed hn p t (symm h)).1 + change Reach p t (i,a) (fullProject hn (.inl j)) + rw [hh]; exact .refl + · exact .single (full_box p t h) + +lemma full_inv_edge (v w : Vertex n) (h : Wiring p t v w) : + Relation.ReflTransGen (wiring p t n) (.inr v) (.inr w) := by + rcases v with ⟨i,a⟩; rcases w with ⟨j,b⟩ + rcases h with ⟨hij,hab⟩ | ⟨rfl,rfl,hp⟩ | ⟨ha,hb,hij,ht⟩ | ⟨hb,ha,hij,ht⟩ + · exact .single (Or.inl ⟨hij,i.isLt,hab⟩) + · have hi : wiring p t n (.inr (i,1)) (.inl i.succ) := ⟨i.isLt,rfl,rfl,⟨j,hp⟩⟩ + have hij : wiring p t n (.inl i.succ) (.inl j.succ) := (p.padBottom_adj_succ i j).mpr hp + have hj : wiring p t n (.inl j.succ) (.inr (j,1)) := ⟨j.isLt,rfl,rfl,⟨i,Pairing.adj_symm hp⟩⟩ + exact ((Relation.ReflTransGen.single hi).tail hij).tail hj + · exact .single (Or.inr (Or.inl ⟨ha,hb,hij,j.isLt,ht⟩)) + · exact .single (Or.inr (Or.inr ⟨hb,ha,hij,i.isLt,ht⟩)) + +lemma full_map_used (v : V n) (h : Graph.Used (wiring p t n) v) : + Graph.Used (Wiring p t) (fullProject hn v) := by + obtain ⟨w,hw⟩ := h + rcases v with i | ⟨i,a⟩ <;> rcases w with j | ⟨j,b⟩ + · induction i using Fin.cases with + | zero => exact (p.padBottom_not_adj_zero j hw).elim + | succ i => + induction j using Fin.cases with + | zero => exact (p.padBottom_not_adj_zero' i.succ hw).elim + | succ j => exact ⟨(j,1),Or.inr (Or.inl ⟨rfl,rfl,(p.padBottom_adj_succ i j).mp hw⟩)⟩ + · obtain ⟨he,k,hpk⟩ := full_mixed hn p t hw + rw [he] + obtain ⟨_,rfl,rfl,_⟩ := hw + exact ⟨(k,1),Or.inr (Or.inl ⟨rfl,rfl,hpk⟩)⟩ + · obtain ⟨_,rfl,rfl,⟨k,hpk⟩⟩ := hw + exact ⟨(k,1),Or.inr (Or.inl ⟨rfl,rfl,hpk⟩)⟩ + · exact ⟨(j,b),full_box p t hw⟩ + +lemma full_inv_used (v : Vertex n) (h : Graph.Used (Wiring p t) v) : + Graph.Used (wiring p t n) (.inr v) := by + obtain ⟨⟨j,b⟩,hw⟩ := h + rcases v with ⟨i,a⟩ + rcases hw with ⟨hij,hab⟩ | ⟨rfl,rfl,hp⟩ | ⟨ha,hb,hij,ht⟩ | ⟨hb,ha,hij,ht⟩ + · exact ⟨.inr (j,b),Or.inl ⟨hij,i.isLt,hab⟩⟩ + · exact ⟨.inl i.succ,i.isLt,rfl,rfl,⟨j,hp⟩⟩ + · exact ⟨.inr (j,b),Or.inr (Or.inl ⟨ha,hb,hij,j.isLt,ht⟩)⟩ + · exact ⟨.inr (j,b),Or.inr (Or.inr ⟨hb,ha,hij,i.isLt,ht⟩)⟩ + +lemma full_boundary (i : Fin (n+1)) : boundary n le_rfl i=.inr (fullBoundary hn i) := by + induction i using Fin.lastCases with + | last => simp [boundary,fullBoundary,hn] + | cast i => simp [boundary,fullBoundary,i.isLt] + +lemma full_retract (v : V n) (h : Graph.Used (wiring p t n) v) : + Relation.ReflTransGen (wiring p t n) v (.inr (fullProject hn v)) := by + cases v with + | inr v => exact .refl + | inl i => + induction i using Fin.cases with + | zero => obtain ⟨w,hw⟩ := h; exact (full_initial_zero p t w hw).elim + | succ i => + have hp : p.Occupied i := by + obtain ⟨w,hw⟩ := h + rcases w with j | ⟨j,b⟩ + · exact (p.padBottom_occupied_succ i).mp ⟨j,hw⟩ + · obtain ⟨_,he,rfl,hp⟩ := hw + have hij : i=j := Fin.succ_injective _ he + exact hij ▸ hp + exact .single ⟨i.isLt,rfl,rfl,hp⟩ + +def fullEquiv : Graph.BoundaryEquiv (wiring p t n) (Wiring p t) (boundary n le_rfl) (fullBoundary hn) where + toFun := fullProject hn + invFun := Sum.inr + map_edge := full_map_edge hn p t + inv_edge := full_inv_edge p t + map_boundary := fun i => by rw [full_boundary hn]; rfl + inv_boundary := fun i => (full_boundary hn i).symm + map_used := full_map_used hn p t + inv_used := full_inv_used p t + retract := full_retract hn p t + inv_retract := fun _ _ => .refl + +end PartialColumn +end +end CriticalStrip.Diagram + +end OAI diff --git a/lean/OAI/Combinatorics/StripMass/GraphPath.lean b/lean/OAI/Combinatorics/StripMass/GraphPath.lean new file mode 100644 index 0000000000000000000000000000000000000000..4fd544d02060238ef449fad4cb13884b0269dea8 --- /dev/null +++ b/lean/OAI/Combinatorics/StripMass/GraphPath.lean @@ -0,0 +1,569 @@ +import Mathlib +import OAI.Combinatorics.StripMass.ScalarBridge + +namespace OAI + +/-! Critical honeycomb strip paths, polynomial identities and crossing mass. -/ + + +namespace CriticalStrip.Diagram.PathGraph +noncomputable section +open scoped Classical + + +def AtMostTwo {V : Type*} (r : V → V → Prop) : Prop := + ∀ ⦃v x y z⦄, r v x → r v y → r v z → x ≠ y → z = x ∨ z = y + +def AtMostOne {V : Type*} (r : V → V → Prop) (v : V) : Prop := + ∀ ⦃x y⦄, r v x → r v y → x = y + + +def Trace {V : Type*} (r : V → V → Prop) (a b : V) (p : List V) : Prop := + p.head? = some a ∧ p.getLast? = some b ∧ p.Nodup ∧ p.IsChain r + + +def Consecutive {V : Type*} (p : List V) (v w : V) : Prop := + ∃ (i : ℕ) (hi : i+1 < p.length), + (p[i] = v ∧ p[i+1] = w) ∨ (p[i] = w ∧ p[i+1] = v) + +lemma consecutive_symm {V : Type*} {p : List V} {v w : V} : + Consecutive p v w → Consecutive p w v := by + rintro ⟨i,hi,h⟩ + exact ⟨i,hi,h.symm⟩ + +lemma consecutive_mem {V : Type*} {p : List V} {v w : V} + (h : Consecutive p v w) : v ∈ p ∧ w ∈ p := by + obtain ⟨i,hi,h⟩ := h + rcases h with ⟨hv,hw⟩ | ⟨hw,hv⟩ <;> + exact ⟨List.mem_of_getElem hv,List.mem_of_getElem hw⟩ + +lemma Trace.length_two_le {V : Type*} {r : V → V → Prop} {a b : V} {p : List V} + (h : Trace r a b p) (hab : a ≠ b) : 2 ≤ p.length := by + rcases p with _ | ⟨x,p⟩ + · simp [Trace] at h + · cases p with + | nil => simp [Trace] at h; exact (hab (h.1.symm.trans h.2)).elim + | cons => simp + +lemma Trace.first {V : Type*} {r : V → V → Prop} {a b : V} {p : List V} + (h : Trace r a b p) (hi : 0 < p.length) : p[0] = a := by + have hh := h.1 + simpa only [List.head?_eq_getElem?,List.getElem?_eq_getElem hi,Option.some.injEq] using hh + +lemma Trace.last {V : Type*} {r : V → V → Prop} {a b : V} {p : List V} + (h : Trace r a b p) (hi : p.length-1 < p.length) : p[p.length-1] = b := by + have hh := h.2.1 + simpa only [List.getLast?_eq_getElem?,List.getElem?_eq_getElem hi,Option.some.injEq] using hh + + + +theorem Trace.edge_consecutive {V : Type*} {r : V → V → Prop} + (hs : Std.Symm r) (h₂ : AtMostTwo r) {a b : V} + (ha : AtMostOne r a) (hb : AtMostOne r b) {p : List V} + (hp : Trace r a b p) (hab : a ≠ b) {v w : V} + (hv : v ∈ p) (hvw : r v w) : Consecutive p v w := by + obtain ⟨i,hi,rfl⟩ := List.getElem_of_mem hv + have hlen := hp.length_two_le hab + have hc := List.isChain_iff_getElem.mp hp.2.2.2 + by_cases hz : i=0 + · subst i + have he : p[1] = w := ha (by simpa only [hp.first (by omega)] using hc 0 (by omega)) + (by simpa only [hp.first (by omega)] using hvw) + exact ⟨0,by omega,Or.inl ⟨rfl,he⟩⟩ + · by_cases ht : i+1=p.length + · have hi' : i=p.length-1 := by omega + have hpi : p[i] = b := by simpa only [hi'] using hp.last (by omega) + have hw : p[i-1] = w := hb + (by have hh := hs.symm _ _ (hc (i-1) (by omega)); + have he : i-1+1=i := by omega + simpa only [he,hpi] using hh) + (by simpa only [hpi] using hvw) + refine ⟨i-1,by omega,Or.inr ⟨hw,?_⟩⟩ + have he : i-1+1=i := by omega + simp only [he] + · have he : i-1+1=i := by omega + have hm : r p[i] p[i-1] := by + have hh := hs.symm _ _ (hc (i-1) (by omega)) + simpa only [he] using hh + have hp' : r p[i] p[i+1] := hc i (by omega) + have hne : p[i-1] ≠ p[i+1] := by + intro hh + have hi' := hp.2.2.1.getElem_inj_iff.mp hh + omega + rcases h₂ hm hp' hvw hne with hw | hw + · exact ⟨i-1,by omega,Or.inr ⟨hw.symm,by simp only [he]⟩⟩ + · exact ⟨i,by omega,Or.inl ⟨rfl,hw.symm⟩⟩ + +lemma Trace.reach_mem {V : Type*} {r : V → V → Prop} + (hs : Std.Symm r) (h₂ : AtMostTwo r) {a b : V} + (ha : AtMostOne r a) (hb : AtMostOne r b) {p : List V} + (hp : Trace r a b p) (hab : a ≠ b) {v : V} + (hr : Relation.ReflTransGen r v a) : v ∈ p := by + induction hr using Relation.ReflTransGen.head_induction_on with + | refl => + have hl := hp.length_two_le hab + exact List.mem_of_getElem (hp.first (by omega)) + | @head v w hvw hr ih => + exact (consecutive_mem (hp.edge_consecutive hs h₂ ha hb hab ih (hs.symm _ _ hvw))).2 + + + +theorem Trace.edges_iff {V : Type*} {r : V → V → Prop} + (hs : Std.Symm r) (h₂ : AtMostTwo r) {a b : V} + (ha : AtMostOne r a) (hb : AtMostOne r b) {p : List V} + (hp : Trace r a b p) (hab : a ≠ b) + (hd : ∀ v w, r v w → Relation.ReflTransGen r v a) (v w : V) : + r v w ↔ Consecutive p v w := by + constructor + · intro hvw + exact hp.edge_consecutive hs h₂ ha hb hab (hp.reach_mem hs h₂ ha hb hab (hd v w hvw)) hvw + · rintro ⟨i,hi,he⟩ + have hc := List.isChain_iff_getElem.mp hp.2.2.2 i hi + rcases he with ⟨rfl,rfl⟩ | ⟨rfl,rfl⟩ + · exact hc + · exact hs.symm _ _ hc + +lemma exists_trace {V : Type*} {r : V → V → Prop} (hs : Std.Symm r) + (hirr : ∀ v, ¬r v v) {a b : V} (hr : Relation.ReflTransGen r a b) : + ∃ p : List V, Trace r a b p := by + let G : SimpleGraph V := ⟨r,hs,⟨hirr⟩⟩ + obtain ⟨w,hw⟩ := ((SimpleGraph.reachable_iff_reflTransGen (G := G) a b).mpr hr).exists_isPath + refine ⟨w.support,?_,?_,hw.support_nodup,w.isChain_adj_support⟩ + · rw [List.head?_eq_some_head w.support_ne_nil]; simp + · rw [List.getLast?_eq_some_getLast w.support_ne_nil]; simp + +lemma Trace.eq_singleton {V : Type*} {r : V → V → Prop} {a : V} {p : List V} + (hp : Trace r a a p) : p = [a] := by + have hpos : 0 < p.length := by + cases p with + | nil => simp [Trace] at hp + | cons => simp + have hf := hp.first hpos + have hl := hp.last (by omega) + have he : 0 = p.length-1 := hp.2.2.1.getElem_inj_iff.mp (hf.trans hl.symm) + obtain ⟨l,rfl⟩ := List.head?_eq_some_iff.mp hp.1 + have hlen : l.length=0 := by simp only [List.length_cons] at he; omega + simp only [List.length_eq_zero_iff.mp hlen] + +lemma Trace.avoid {V : Type*} {r : V → V → Prop} {x a b : V} {p : List V} + (hp : Trace r a b p) (hx : x ∉ p) : + Trace (fun v w => r v w ∧ v ≠ x ∧ w ≠ x) a b p := by + refine ⟨hp.1,hp.2.1,hp.2.2.1,?_⟩ + rw [List.isChain_iff_getElem] + intro i hi + exact ⟨List.isChain_iff_getElem.mp hp.2.2.2 i hi, + fun he => hx (List.mem_of_getElem he), fun he => hx (List.mem_of_getElem he)⟩ + + + +theorem Trace.unique {V : Type*} {r : V → V → Prop} + (hs : Std.Symm r) (h₂ : AtMostTwo r) {a b : V} + (ha : AtMostOne r a) {p q : List V} + (hp : Trace r a b p) (hq : Trace r a b q) : p = q := by + induction p generalizing r a b q with + | nil => simp [Trace] at hp + | cons x p ih => + have hxa : x=a := by simpa using hp.1 + subst x + by_cases hab : a=b + · subst b + exact hp.eq_singleton.trans hq.eq_singleton.symm + have hl := hp.length_two_le hab + obtain ⟨q,rfl⟩ := List.head?_eq_some_iff.mp hq.1 + have hlq := hq.length_two_le hab + cases p with + | nil => simp at hl + | cons v p => + cases q with + | nil => simp at hlq + | cons w q => + have hav : r a v := (List.isChain_cons_cons.mp hp.2.2.2).1 + have haw : r a w := (List.isChain_cons_cons.mp hq.2.2.2).1 + have hvw := ha hav haw + subst w + let s : V → V → Prop := fun v w => r v w ∧ v ≠ a ∧ w ≠ a + have hsp : Trace s v b (v::p) := by + apply Trace.avoid (r := r) + · refine ⟨rfl,?_,hp.2.2.1.of_cons,(List.isChain_cons_cons.mp hp.2.2.2).2⟩ + simpa only [List.getLast?_cons_cons] using hp.2.1 + · exact (List.nodup_cons.mp hp.2.2.1).1 + have hsq : Trace s v b (v::q) := by + apply Trace.avoid (r := r) + · refine ⟨rfl,?_,hq.2.2.1.of_cons,(List.isChain_cons_cons.mp hq.2.2.2).2⟩ + simpa only [List.getLast?_cons_cons] using hq.2.1 + · exact (List.nodup_cons.mp hq.2.2.1).1 + have hss : Std.Symm s := ⟨fun x y h => ⟨hs.symm _ _ h.1,h.2.2,h.2.1⟩⟩ + have hs₂ : AtMostTwo s := by + intro v x y z hx hy hz hn + exact h₂ hx.1 hy.1 hz.1 hn + have hs₁ : AtMostOne s v := by + intro x y hx hy + rcases h₂ (hs.symm _ _ hav) hx.1 hy.1 hx.2.2.symm with hy' | hy' + · exact (hy.2.2 hy').elim + · exact hy'.symm + exact congrArg (List.cons a) (ih hss hs₂ hs₁ hsp hsq) + + + +theorem existsUnique_trace {V : Type*} {r : V → V → Prop} + (hs : Std.Symm r) (hirr : ∀ v, ¬r v v) (h₂ : AtMostTwo r) {a b : V} + (ha : AtMostOne r a) (hr : Relation.ReflTransGen r a b) : + ∃! p : List V, Trace r a b p := by + obtain ⟨p,hp⟩ := exists_trace hs hirr hr + exact ⟨p,hp,fun q hq => hq.unique hs h₂ ha hp⟩ + +lemma consecutive_iff_neighbors {V : Type*} {p : List V} (hp : p.Nodup) + (i : ℕ) (hi : i < p.length) (v : V) : + Consecutive p p[i] v ↔ + (∃ h : 0 < i, v = p[i-1]) ∨ (∃ h : i+1 < p.length, v = p[i+1]) := by + constructor + · rintro ⟨j,hj,⟨he,hv⟩ | ⟨hv,he⟩⟩ + · have hji : j=i := hp.getElem_inj_iff.mp he + subst j + exact Or.inr ⟨hj,hv.symm⟩ + · have hji : j+1=i := hp.getElem_inj_iff.mp he + have hj' : j=i-1 := by omega + exact Or.inl ⟨by omega,by simpa only [hj'] using hv.symm⟩ + · rintro (⟨_,hv⟩ | ⟨hv,hv'⟩) + · refine ⟨i-1,by omega,Or.inr ⟨hv.symm,?_⟩⟩ + have he : i-1+1=i := by omega + simp only [he] + · exact ⟨i,hv,Or.inl ⟨rfl,hv'.symm⟩⟩ + +lemma consecutive_irrefl {V : Type*} {p : List V} (hp : p.Nodup) (v : V) : + ¬Consecutive p v v := by + rintro ⟨i,hi,⟨h₁,h₂⟩ | ⟨h₂,h₁⟩⟩ <;> + have hh := hp.getElem_inj_iff.mp (h₁.trans h₂.symm) <;> omega + +lemma consecutive_two {V : Type*} {p : List V} (hp : p.Nodup) : + AtMostTwo (Consecutive p) := by + intro v x y z hx hy hz hxy + obtain ⟨i,hi,rfl⟩ := List.getElem_of_mem (consecutive_mem hx).1 + rw [consecutive_iff_neighbors hp i hi] at hx hy hz + rcases hx with ⟨hx,rfl⟩ | ⟨hx,rfl⟩ <;> + rcases hy with ⟨hy,rfl⟩ | ⟨hy,rfl⟩ <;> + rcases hz with ⟨hz,rfl⟩ | ⟨hz,rfl⟩ <;> simp_all + +lemma consecutive_first_one {V : Type*} {p : List V} (hp : p.Nodup) + (hpos : 0 < p.length) : AtMostOne (Consecutive p) p[0] := by + intro x y hx hy + rw [consecutive_iff_neighbors hp 0 hpos] at hx hy + simpa only [Nat.lt_irrefl,exists_false,exists_prop,and_true,false_or,exists_and_left] using + (show x=y from by rcases hx with ⟨h,h'⟩ | ⟨h,rfl⟩; · omega + rcases hy with ⟨h,h'⟩ | ⟨h,rfl⟩; · omega + rfl) + +lemma consecutive_last_one {V : Type*} {p : List V} (hp : p.Nodup) + (hpos : 0 < p.length) : AtMostOne (Consecutive p) p[p.length-1] := by + intro x y hx hy + rw [consecutive_iff_neighbors hp (p.length-1) (by omega)] at hx hy + rcases hx with ⟨h,rfl⟩ | ⟨h,h'⟩ + · rcases hy with ⟨h,rfl⟩ | ⟨h,h'⟩ + · rfl + · omega + · omega + +lemma consecutive_chain {V : Type*} (p : List V) : p.IsChain (Consecutive p) := by + rw [List.isChain_iff_getElem] + intro i hi + exact ⟨i,hi,Or.inl ⟨rfl,rfl⟩⟩ + +lemma Trace.used_of_mem {V : Type*} {r : V → V → Prop} + (hs : Std.Symm r) {a b : V} {p : List V} (hp : Trace r a b p) + (hab : a ≠ b) {v : V} (hv : v ∈ p) : ∃ w, r v w := by + obtain ⟨i,hi,rfl⟩ := List.getElem_of_mem hv + have hl := hp.length_two_le hab + have hc := List.isChain_iff_getElem.mp hp.2.2.2 + by_cases hi' : i+1 < p.length + · exact ⟨p[i+1],hc i hi'⟩ + · have hi0 : 0 < i := by omega + have he : i-1+1=i := by omega + exact ⟨p[i-1],by simpa only [he] using hs.symm _ _ (hc (i-1) (by omega))⟩ + +lemma Trace.reach_of_mem {V : Type*} {r : V → V → Prop} {a b : V} + {p : List V} (hp : Trace r a b p) {v : V} (hv : v ∈ p) : + Relation.ReflTransGen r a v := by + obtain ⟨i,hi,rfl⟩ := List.getElem_of_mem hv + induction i with + | zero => rw [hp.first (by omega)] + | succ i ih => + exact (ih (by omega) (by simp)).tail (List.isChain_iff_getElem.mp hp.2.2.2 i hi) + +end +end CriticalStrip.Diagram.PathGraph + + + + + +namespace CriticalStrip +noncomputable section +open scoped Classical BigOperators +open Diagram.PathGraph + + + +structure WireConfiguration (N : ℕ) (finish : Triangle) where + graph : SimpleGraph Triangle + allowed : ∀ v w, graph.Adj v w → adjacent v w ∧ v.2.1 < N ∧ w.2.1 < N + two : AtMostTwo graph.Adj + source_one : AtMostOne graph.Adj (up 0 0) + finish_one : AtMostOne graph.Adj finish + source_used : ∃ w, graph.Adj (up 0 0) w + finish_used : ∃ w, graph.Adj finish w + drains : ∀ v w, graph.Adj v w → Relation.ReflTransGen graph.Adj v (up 0 0) + +namespace WireConfiguration +variable {N : ℕ} {finish : Triangle} + +@[ext] theorem ext {x y : WireConfiguration N finish} (h : x.graph = y.graph) : x=y := by + cases x; cases y; cases h; rfl + +lemma reach (D : WireConfiguration N finish) : + Relation.ReflTransGen D.graph.Adj (up 0 0) finish := by + obtain ⟨w,hw⟩ := D.finish_used + have : Std.Symm D.graph.Adj := D.graph.symm + exact symm (D.drains finish w hw) + +lemma existsUniqueTrace (D : WireConfiguration N finish) : + ∃! p : List Triangle, Trace D.graph.Adj (up 0 0) finish p := + existsUnique_trace D.graph.symm (fun v => D.graph.loopless.irrefl v) D.two D.source_one D.reach + + + +def path (D : WireConfiguration N finish) : List Triangle := + Classical.choose D.existsUniqueTrace + +lemma path_trace (D : WireConfiguration N finish) : + Trace D.graph.Adj (up 0 0) finish D.path := + (Classical.choose_spec D.existsUniqueTrace).1 + +lemma path_isPath (D : WireConfiguration N finish) (hf : finish ≠ up 0 0) : + IsPath N finish D.path := by + have h := D.path_trace + refine ⟨h.1,h.2.1,h.2.2.1,h.2.2.2.imp (fun {_ _} hvw => (D.allowed _ _ hvw).1),?_⟩ + intro v hv + obtain ⟨w,hw⟩ := h.used_of_mem D.graph.symm hf.symm hv + exact (D.allowed _ _ hw).2.1 + +lemma edges_iff (D : WireConfiguration N finish) (hf : finish ≠ up 0 0) (v w : Triangle) : + D.graph.Adj v w ↔ Consecutive D.path v w := + D.path_trace.edges_iff D.graph.symm D.two D.source_one D.finish_one hf.symm D.drains v w + + +lemma support_eq (D : WireConfiguration N finish) (hf : finish ≠ up 0 0) : + D.graph.support = {v | v ∈ D.path} := by + ext v + change (∃ w,D.graph.Adj v w) ↔ v ∈ D.path + constructor + · rintro ⟨w,hw⟩ + exact (consecutive_mem ((D.edges_iff hf v w).mp hw)).1 + · exact D.path_trace.used_of_mem D.graph.symm hf.symm + +lemma support_finite (D : WireConfiguration N finish) (hf : finish ≠ up 0 0) : + D.graph.support.Finite := by + rw [D.support_eq hf] + exact List.finite_toSet _ + +lemma support_ncard (D : WireConfiguration N finish) (hf : finish ≠ up 0 0) : + D.graph.support.ncard = D.path.length := by + rw [D.support_eq hf] + have he : {v | v ∈ D.path} = (↑D.path.toFinset : Set Triangle) := by ext; simp + rw [he,Set.ncard_coe_finset,List.toFinset_card_of_nodup D.path_trace.2.2.1] + + +def weight (D : WireConfiguration N finish) : ℝ := rho ^ D.graph.support.ncard + +lemma weight_eq (D : WireConfiguration N finish) (hf : finish ≠ up 0 0) : + D.weight = rho ^ D.path.length := by rw [weight,D.support_ncard hf] + +lemma ofPath_trace {p : List Triangle} (hp : IsPath N finish p) : + Trace (Consecutive p) (up 0 0) finish p := + ⟨hp.1,hp.2.1,hp.2.2.1,consecutive_chain p⟩ + + + +def ofPath {p : List Triangle} (hf : finish ≠ up 0 0) (hp : IsPath N finish p) : + WireConfiguration N finish := by + have h : Trace (Consecutive p) (up 0 0) finish p := ofPath_trace hp + have hs : Std.Symm (Consecutive p) := ⟨fun _ _ => consecutive_symm⟩ + have hl : 0 < p.length := lt_of_lt_of_le (by omega) (h.length_two_le hf.symm) + refine ⟨⟨Consecutive p,hs,⟨consecutive_irrefl hp.2.2.1⟩⟩,?_,consecutive_two hp.2.2.1,?_,?_,?_,?_,?_⟩ + · intro v w hvw + obtain ⟨hv,hw⟩ := consecutive_mem hvw + refine ⟨?_,hp.2.2.2.2 v hv,hp.2.2.2.2 w hw⟩ + obtain ⟨i,hi,⟨rfl,rfl⟩ | ⟨rfl,rfl⟩⟩ := hvw + · exact List.isChain_iff_getElem.mp hp.2.2.2.1 i hi + · exact adjacent_symmetric.symm _ _ (List.isChain_iff_getElem.mp hp.2.2.2.1 i hi) + · simpa only [h.first hl] using consecutive_first_one hp.2.2.1 hl + · simpa only [h.last (by omega)] using consecutive_last_one hp.2.2.1 hl + · exact h.used_of_mem hs hf.symm (List.mem_of_getElem (h.first hl)) + · exact h.used_of_mem hs hf.symm (List.mem_of_getElem (h.last (by omega))) + · intro v w hvw + have : Std.Symm (Consecutive p) := hs + exact symm (h.reach_of_mem (consecutive_mem hvw).1) + +@[simp] lemma ofPath_graph {p : List Triangle} (hf : finish ≠ up 0 0) + (hp : IsPath N finish p) (v w : Triangle) : + (ofPath hf hp).graph.Adj v w ↔ Consecutive p v w := Iff.rfl + +@[simp] theorem ofPath_path {p : List Triangle} (hf : finish ≠ up 0 0) + (hp : IsPath N finish p) : (ofPath hf hp).path = p := by + exact (ofPath hf hp).path_trace.unique (ofPath hf hp).graph.symm + (ofPath hf hp).two (ofPath hf hp).source_one (ofPath_trace hp) + +@[simp] theorem ofPath_path_isPath (D : WireConfiguration N finish) (hf : finish ≠ up 0 0) : + ofPath hf (D.path_isPath hf) = D := by + apply ext + apply SimpleGraph.ext + funext v w + exact propext (D.edges_iff hf v w).symm + + + +def equivPaths (N : ℕ) (finish : Triangle) (hf : finish ≠ up 0 0) : + WireConfiguration N finish ≃ {p : List Triangle // IsPath N finish p} where + toFun D := ⟨D.path,D.path_isPath hf⟩ + invFun p := ofPath hf p.property + left_inv D := ofPath_path_isPath D hf + right_inv p := Subtype.ext (ofPath_path hf p.property) + +end WireConfiguration +end + + + + + +noncomputable section +open scoped Classical BigOperators + +namespace WireConfiguration + +lemma countable (N : ℕ) (finish : Triangle) (hf : finish ≠ up 0 0) : + Countable (WireConfiguration N finish) := + (equivPaths N finish hf).countable_iff.mpr inferInstance + +lemma summable_weight_iff (N : ℕ) (finish : Triangle) (hf : finish ≠ up 0 0) : + Summable (weight (N := N) (finish := finish)) ↔ + Summable (fun p : List Triangle => if IsPath N finish p then rho ^ p.length else 0) := by + have he := (equivPaths N finish hf).summable_iff + (f := fun p : {p : List Triangle // IsPath N finish p} => rho ^ p.val.length) + have hs := summable_subtype_iff_indicator + (f := fun p : List Triangle => rho ^ p.length) + (s := {p | IsPath N finish p}) + have hw : (fun p : {p : List Triangle // IsPath N finish p} => rho ^ p.val.length) ∘ + (equivPaths N finish hf) = weight := by + funext D + exact (D.weight_eq hf).symm + rw [hw] at he + exact he.trans hs + +lemma tsum_weight (N : ℕ) (finish : Triangle) (hf : finish ≠ up 0 0) : + ∑' D : WireConfiguration N finish, D.weight = + ∑' p : List Triangle, if IsPath N finish p then rho ^ p.length else 0 := by + calc + _ = ∑' D : WireConfiguration N finish, rho ^ D.path.length := + tsum_congr (fun D => D.weight_eq hf) + _ = ∑' p : {p : List Triangle // IsPath N finish p}, rho ^ p.val.length := + (equivPaths N finish hf).tsum_eq (fun p => rho ^ p.val.length) + _ = _ := tsum_subtype {p | IsPath N finish p} (fun p => rho ^ p.length) + + + +theorem arch_sum (N : ℕ) (k : ℤ) (hk : k ≠ 0) : + K N k = ∑' D : WireConfiguration N (up k 0), D.weight := by + have hf : up k 0 ≠ up 0 0 := by simpa [up] using hk + rw [tsum_weight N (up k 0) hf] + apply tsum_congr + intro p + simp [archWeight,hk] + +theorem arch_summable (N : ℕ) (k : ℤ) (hk : k ≠ 0) : + Summable (archWeight N k) ↔ Summable (weight (N := N) (finish := up k 0)) := by + have hf : up k 0 ≠ up 0 0 := by simpa [up] using hk + rw [show archWeight N k = (fun p => if IsPath N (up k 0) p then rho ^ p.length else 0) from + funext (fun p => by simp [archWeight,hk])] + exact (summable_weight_iff N (up k 0) hf).symm + +theorem bridge_sum (N : ℕ) (hN : 1 ≤ N) (k : ℤ) : + bridgeKernel N k = ∑' D : WireConfiguration N (down k (N-1)), D.weight := by + have hf : down k (N-1) ≠ up 0 0 := by simp [down,up] + rw [tsum_weight N (down k (N-1)) hf] + apply tsum_congr + intro p + simp [bridgeWeight,show 0 if IsPath N (down k (N-1)) p then rho ^ p.length else 0) from + funext (fun p => by simp [bridgeWeight,show 0 simp only [adjacent,upDownAdjacent,up,down,Prod.mk.injEq,Bool.false_eq_true, + Bool.true_eq_false,true_and,false_and,or_false,and_true,and_false] + all_goals omega + +lemma adjacent_down_iff (i : ℤ) (j : ℕ) (w : Triangle) : + adjacent (down i j) w ↔ w=up i j ∨ w=up (i+1) j ∨ w=up i (j+1) := by + rcases w with ⟨k,l,b⟩ + cases b <;> simp only [adjacent,upDownAdjacent,up,down,Prod.mk.injEq,Bool.false_eq_true, + Bool.true_eq_false,true_and,false_and,false_or,or_false,and_true,and_false] + all_goals omega + +end +end CriticalStrip + +end OAI diff --git a/lean/OAI/Combinatorics/StripMass/HalfTurn.lean b/lean/OAI/Combinatorics/StripMass/HalfTurn.lean new file mode 100644 index 0000000000000000000000000000000000000000..c3ca22bf229c0938185ec6f8aca0c94a28ab1316 --- /dev/null +++ b/lean/OAI/Combinatorics/StripMass/HalfTurn.lean @@ -0,0 +1,542 @@ +import Mathlib +import OAI.Combinatorics.StripMass.FiniteEnds + +namespace OAI + +/-! Critical honeycomb strip paths, polynomial identities and crossing mass. -/ + + +namespace CriticalStrip +noncomputable section +open scoped Classical +open Diagram + +namespace Diagram.Tile + + +def turn : Tile → Tile + | .vertical₀ => .vertical₁ + | .vertical₁ => .vertical₀ + | .cap => .cup + | .cup => .cap + | t => t + +@[simp] lemma turn_turn (t : Tile) : t.turn.turn=t := by cases t <;> rfl +@[simp] lemma turn_vacant : Tile.vacant.turn=.vacant := rfl +@[simp] lemma turn_physical (t : Tile) : t.turn≠.verticalPair ↔ t≠.verticalPair := by + cases t <;> decide +@[simp] lemma turn_occupied_zero (t : Tile) : t.turn.Occupied 0 ↔ t.Occupied 3 := by + revert t; decide +@[simp] lemma turn_occupied_one (t : Tile) : t.turn.Occupied 1 ↔ t.Occupied 2 := by + revert t; decide +@[simp] lemma turn_occupied_two (t : Tile) : t.turn.Occupied 2 ↔ t.Occupied 1 := by + revert t; decide +@[simp] lemma turn_occupied_three (t : Tile) : t.turn.Occupied 3 ↔ t.Occupied 0 := by + revert t; decide +@[simp] lemma turn_middle (t : Tile) : t.turn.middle=t.middle := by cases t <;> rfl +@[simp] lemma turn_weight (w : Weights ℝ) (t : Tile) : w.tile t.turn=w.tile t := by + cases t <;> rfl + +end Diagram.Tile + + + +def turnTriangle (N : ℕ) (b : ℤ) (v : Triangle) : Triangle := + (b-v.1,N-1-v.2.1,!v.2.2) + +lemma turnTriangle_in_strip (N : ℕ) (b : ℤ) {v : Triangle} (hv : v.2.1 cases d <;> + simp only [adjacent,upDownAdjacent,turnTriangle,Bool.not_false,Bool.not_true, + Bool.false_eq_true,Bool.true_eq_false,false_and,and_false,false_or,or_false, + true_and] at h ⊢ + · rcases h with ⟨hjl,hik|hik⟩|⟨hjl,hik⟩ <;> omega + · rcases h with ⟨hjl,hik|hik⟩|⟨hjl,hik⟩ <;> omega + +lemma PathBetween.turn {N : ℕ} {a b : Triangle} {p : List Triangle} + (hp : PathBetween N a b p) (k : ℤ) : + PathBetween N (turnTriangle N k a) (turnTriangle N k b) (p.map (turnTriangle N k)) := by + refine ⟨?_,?_,?_,?_,?_⟩ + · rw [List.head?_map,hp.1]; rfl + · rw [List.getLast?_map,hp.2.1]; rfl + · apply hp.2.2.1.map_on + intro v hv w hw h + have hh:=congrArg (turnTriangle N k) h + simpa only [turnTriangle_turnTriangle N k (hp.2.2.2.2 _ hv), + turnTriangle_turnTriangle N k (hp.2.2.2.2 _ hw)] using hh + · apply (List.isChain_map _).mpr + apply List.isChain_iff_getElem.mpr + intro i hi + exact turnTriangle_adjacent k (hp.2.2.2.2 _ (List.getElem_mem (by omega))) + (hp.2.2.2.2 _ (List.getElem_mem hi)) (List.isChain_iff_getElem.mp hp.2.2.2.1 i hi) + · intro v hv + obtain ⟨w,hw,rfl⟩:=List.mem_map.mp hv + exact turnTriangle_in_strip N k (hp.2.2.2.2 _ hw) + +namespace HoneycombAssignment +variable {N : ℕ} + + +def turn (D : HoneycombAssignment N) (b : ℤ) : HoneycombAssignment N where + tile q := if q.2.outside i j (by omega),D.outside i j (by omega)] + +lemma turn_up_adj (D : HoneycombAssignment N) (b i : ℤ) (j : ℕ) (w : Triangle) + (hj : j simp only [Bool.not_false,Bool.not_true,Bool.false_eq_true,Bool.true_eq_false, + and_true,and_false,false_and,or_false] + apply or_congr + · apply and_congr_left + intro _ + omega + · apply or_congr + · apply and_congr_left + intro _ + omega + · simp only [←and_assoc] + apply and_congr_left + intro _ + omega + +lemma turn_adj (D : HoneycombAssignment N) (b : ℤ) {v w : Triangle} + (hv : v.2.1.single (D.turn_edge b e)) h + +lemma turn_drains (D : HoneycombAssignment N) (b : ℤ) {root : Triangle} + (h : Graph.DrainsAt D.graph.Adj root) : + Graph.DrainsAt (D.turn b).graph.Adj (turnTriangle N b root) := by + intro v w hvw + have hh:=tileGraph_allowed N (D.turn b).tile hvw + have e:=(D.turn_adj b hh.2.1 hh.2.2).mp hvw + simpa only [turnTriangle_turnTriangle N b hh.2.1] using + D.turn_reach b (h _ _ e) + +end HoneycombAssignment + + + +structure TopArchConfiguration (N : ℕ) (a b : ℤ) extends HoneycombAssignment N where + bottom : ∀i, ¬(tile (i,0)).Occupied 0 + top : ∀i, (tile (i,N-1)).Occupied 3 ↔ i=a ∨ i=b + drains : Graph.DrainsAt toHoneycombAssignment.graph.Adj (down b (N-1)) + +namespace TopArchConfiguration +variable {N : ℕ} {a b : ℤ} + +@[ext] lemma ext {D E : TopArchConfiguration N a b} + (h : D.toHoneycombAssignment=E.toHoneycombAssignment) : D=E := by + cases D; cases E; cases h; rfl + + +def toArch (D : TopArchConfiguration N a b) (hN : 1≤N) : + HoneycombConfiguration N (.bottom (b-a)) where + toHoneycombAssignment := D.toHoneycombAssignment.turn b + bottom i := by + rw [D.toHoneycombAssignment.turn_tile b i 0 (by omega),Tile.turn_occupied_zero] + simp only [Nat.sub_zero,D.top,BoundaryPort.bottom.injEq] + omega + top i := by + rw [D.toHoneycombAssignment.turn_tile b i (N-1) (by omega), + show N-1-(N-1)=0 from Nat.sub_self _,Tile.turn_occupied_three] + simp only [D.bottom,false_iff] + exact BoundaryPort.noConfusion + drains := by + have hh:=D.toHoneycombAssignment.turn_drains b D.drains + simpa only [Graph.DrainsAt,turnTriangle,down,up,sub_self,Nat.sub_self,Bool.not_false] using hh + +def ofArch (D : HoneycombConfiguration N (.bottom (b-a))) (hN : 1≤N) : + TopArchConfiguration N a b where + toHoneycombAssignment := D.toHoneycombAssignment.turn b + bottom i := by + rw [D.toHoneycombAssignment.turn_tile b i 0 (by omega),Tile.turn_occupied_zero,Nat.sub_zero, + D.top] + exact BoundaryPort.noConfusion + top i := by + rw [D.toHoneycombAssignment.turn_tile b i (N-1) (by omega), + Nat.sub_self,Tile.turn_occupied_three,D.bottom] + simp only [BoundaryPort.bottom.injEq] + omega + drains := by + have hh:=D.toHoneycombAssignment.turn_drains b D.drains + simpa only [turnTriangle,down,up,sub_zero,Nat.sub_zero,Bool.not_true] using hh + +@[simp] lemma ofArch_toArch (D : TopArchConfiguration N a b) (hN : 1≤N) : + ofArch (D.toArch hN) hN=D := by + apply ext + exact D.toHoneycombAssignment.turn_turn b + +@[simp] lemma toArch_ofArch (D : HoneycombConfiguration N (.bottom (b-a))) (hN : 1≤N) : + (ofArch D hN).toArch hN=D := by + apply HoneycombConfiguration.ext + exact D.toHoneycombAssignment.turn_turn b + +def equivArch (N : ℕ) (a b : ℤ) (hN : 1≤N) : + TopArchConfiguration N a b ≃ HoneycombConfiguration N (.bottom (b-a)) where + toFun D := D.toArch hN + invFun D := ofArch D hN + left_inv D := ofArch_toArch D hN + right_inv D := toArch_ofArch D hN + +end TopArchConfiguration +end +end CriticalStrip + + + + + +namespace CriticalStrip.Diagram +noncomputable section +open scoped Classical + +namespace PaddedColumn +variable {n : ℕ} + + + +theorem runs_exists (hn : 0 exact ⟨empty n,rfl⟩ + | cons t ts ih => + obtain ⟨hc,ht⟩:=hc + have hd' := (stepEquivalence t ts).symm.drains hd + have hl := Graph.glued_drains_local (wiring ts) (BareColumn t) boundary + (fun i=>(i,1)) (active ts) (fun i=>(i,2)) hd' + obtain ⟨p,hp⟩:=ih hc hl + have hg:=runs_realizes ts p hp + have he : active ts=p.Occupied := by + funext i + exact propext ((ColumnChain.support_empty_read ts i).symm.trans + (by rw [(ColumnChain.runs_sound _ _ _ hp).2.2])) + rw [he] at hd' + have ht' : ColumnCompatible p.Occupied t := by + simpa only [(ColumnChain.runs_sound _ _ _ hp).2.2] using ht + have hdr := (hg.substitute_drains_iff (BareColumn t) (fun i=>(i,1)) (fun i=>(i,2))).mp hd' + obtain ⟨q,hq⟩:=realizes_exists_of_drains hn p t ht' ((ColumnSew.equivalence p t).drains hdr) + exact ⟨q,p,hp,hq⟩ + +lemma runs_iff (hn : 0⟨(ColumnChain.runs_sound _ _ _ h).1,runs_realizes ts q h⟩ + · rintro ⟨hc,hg⟩ + obtain ⟨p,hp⟩:=runs_exists hn ts hc hg.drainsBoundary + exact (runs_realizes ts p hp).unique hg ▸ hp + +end PaddedColumn +end +end CriticalStrip.Diagram + + + + + +namespace CriticalStrip +noncomputable section +open scoped Classical +open Diagram + +namespace NorthExtension + + +def tile (a b i : ℤ) : Tile := + if i=a then .vertical₀ else if i=b then .cap else + if a< i ∧ i decide + +lemma south (a b i : ℤ) (_h : a decide + +lemma middle (a b i : ℤ) (h : a simp_all <;> omega + +end NorthExtension + +namespace TopArchConfiguration +variable {N : ℕ} {a b : ℤ} + + + +def extend (D : TopArchConfiguration N a b) (hN : 1≤N) (hab : a + by_cases hi : i=b + · subst i; exact .refl + · have hlt : iD.extend_base_edge hN hab) _ _ + (D.drains _ _ hx)).tail (D.extend_enter hN hab) + · have hvN' : v.2.1=N := by omega + rcases v with ⟨i,j,c⟩ + dsimp at hvN'; subst j + cases c + · obtain ⟨_,hh⟩:=(HoneycombAssignment.down_neighbors _ _ _ _).mp hvw + rw [D.extend_last hN hab,NorthExtension.middle _ _ _ hab, + NorthExtension.east _ _ _ hab] at hh + have hi : a≤ i ∧ i omega + exact D.extend_up_reach hN hab hi.1 hi.2 + +lemma extend_drains (D : TopArchConfiguration N a b) (hN : 1≤N) (hab : a simp at hh + | cons => simp + obtain ⟨s, hs, hsc⟩ := int_chain_direction hc hn + have he := directed_chain_eq_range hh hsc + simp only [zero_add] at he + have ht' : s * ((l.length - 1 : ℕ) : ℤ) = k := by + rw [he, List.getLast?_map, List.getLast?_range] at ht + simpa [Nat.ne_of_gt hlenpos] using ht + have hlen : l.length = k.natAbs + 1 := by + rw [← ht', Int.natAbs_mul] + rcases hs with rfl | rfl <;> simp <;> omega + rw [he] + unfold integerLinePath + rw [hlen] + apply List.map_congr_left + intro n hn + rcases hs with rfl | rfl + · simp only [one_mul] at ht' + have hk : ¬ k < 0 := by omega + simp [hk] + · simp only [neg_one_mul] at ht' + by_cases hk : k < 0 + · simp [hk] + · have hk0 : k = 0 := by omega + simp only [List.mem_range, hk0, Int.natAbs_zero] at hn + have hn0 : n = 0 := by omega + simp [hn0] + + +def oneBandPath (finish : Triangle) : List Triangle := + (integerLinePath (bandRank finish)).map bandVertex + +theorem oneBandPath_spec {finish : Triangle} (hf : finish.2.1 = 0) : + IsPath 1 finish (oneBandPath finish) := by + refine ⟨?_, ?_, ?_, ?_, ?_⟩ + · simp [oneBandPath, List.head?_map, bandVertex, up] + · simp [oneBandPath, List.getLast?_map, bandVertex_bandRank finish hf] + · exact (integerLinePath_nodup _).map (Function.LeftInverse.injective bandRank_bandVertex) + · apply (List.isChain_map _).mpr + apply (integerLinePath_chain _).imp + intro a b hab + apply (band_adjacent_iff (bandVertex_band a) (bandVertex_band b)).mpr + simpa [unitAdjacent] using hab + · intro v hv + obtain ⟨k, hk, rfl⟩ := List.mem_map.mp hv + simp + +theorem oneBandPath_unique {finish : Triangle} {p : List Triangle} + (hp : IsPath 1 finish p) : p = oneBandPath finish := by + have hz (v) (hv : v ∈ p) : v.2.1 = 0 := Nat.eq_zero_of_le_zero (Nat.le_of_lt_succ (hp.2.2.2.2 v hv)) + have he : p.map bandRank = integerLinePath (bandRank finish) := by + apply integerLinePath_unique + · rw [List.head?_map, hp.1]; rfl + · rw [List.getLast?_map, hp.2.1]; rfl + · apply hp.2.2.1.map_on + intro v hv w hw he + simpa only [bandVertex_bandRank v (hz v hv), bandVertex_bandRank w (hz w hw)] using congrArg bandVertex he + · rw [List.isChain_iff_getElem] + intro i hi + simp only [List.length_map] at hi + simp only [List.getElem_map] + exact (band_adjacent_iff (hz _ (List.getElem_mem _)) (hz _ (List.getElem_mem _))).mp + (hp.2.2.2.1.getElem i hi) + calc + p = (p.map bandRank).map bandVertex := by + rw [List.map_map] + exact (List.map_id p).symm.trans (List.map_congr_left fun v hv => (bandVertex_bandRank v (hz v hv)).symm) + _ = oneBandPath finish := by rw [he]; rfl + +theorem oneBandPath_length (finish : Triangle) : + (oneBandPath finish).length = (bandRank finish).natAbs + 1 := by + simp [oneBandPath] + + + +theorem isPath_one_iff {v : Triangle} (hv : v.2.1 = 0) (p : List Triangle) : + IsPath 1 v p ↔ p = oneBandPath v := by + refine ⟨oneBandPath_unique, ?_⟩ + rintro rfl + exact oneBandPath_spec hv + +theorem archWeight_one (k : ℤ) (p : List Triangle) : + archWeight 1 k p = + if p = oneBandPath (up k 0) then (if k = 0 then 0 else rho ^ (2 * k.natAbs + 1)) else 0 := by + classical + unfold archWeight + rw [isPath_one_iff rfl] + by_cases hp : p = oneBandPath (up k 0) + · subst p + simp [oneBandPath_length, Int.natAbs_mul] + · simp [hp] + +theorem bridgeWeight_one (k : ℤ) (p : List Triangle) : + bridgeWeight 1 k p = + if p = oneBandPath (down k 0) then rho ^ ((2 * k + 1).natAbs + 1) else 0 := by + classical + unfold bridgeWeight + norm_num only [Nat.sub_self, Nat.zero_lt_one, true_and] + rw [isPath_one_iff rfl] + by_cases hp : p = oneBandPath (down k 0) + · subst p + simp [oneBandPath_length] + · simp [hp] + +theorem hasSum_archWeight_one (k : ℤ) : + HasSum (archWeight 1 k) (if k = 0 then 0 else rho ^ (2 * k.natAbs + 1)) := by + classical + simp_rw [show archWeight 1 k = fun p => + if p = oneBandPath (up k 0) then (if k = 0 then 0 else rho ^ (2 * k.natAbs + 1)) else 0 + from funext (archWeight_one k)] + exact hasSum_ite_eq _ _ + +theorem hasSum_bridgeWeight_one (k : ℤ) : + HasSum (bridgeWeight 1 k) (rho ^ ((2 * k + 1).natAbs + 1)) := by + classical + simp_rw [show bridgeWeight 1 k = fun p => + if p = oneBandPath (down k 0) then rho ^ ((2 * k + 1).natAbs + 1) else 0 + from funext (bridgeWeight_one k)] + exact hasSum_ite_eq _ _ + + +theorem K_one (k : ℤ) : K 1 k = if k = 0 then 0 else rho ^ (2 * k.natAbs + 1) := + (hasSum_archWeight_one k).tsum_eq + +theorem bridgeKernel_one (k : ℤ) : bridgeKernel 1 k = rho ^ ((2 * k + 1).natAbs + 1) := + (hasSum_bridgeWeight_one k).tsum_eq + +theorem K_one_right (n : ℕ) : K 1 ((n : ℤ) + 1) = rho ^ 3 * (rho ^ 2) ^ n := by + have he : (n : ℤ) + 1 = (n + 1 : ℕ) := by omega + rw [he, K_one] + simp only [Nat.cast_eq_zero, Nat.add_eq_zero_iff, Nat.one_ne_zero, and_false, + ↓reduceIte, Int.natAbs_natCast] + rw [show 2 * (n + 1) + 1 = 3 + 2 * n by omega, pow_add, ← pow_mul] + +theorem K_one_left (n : ℕ) : K 1 (-((n : ℤ) + 1)) = rho ^ 3 * (rho ^ 2) ^ n := by + rw [show K 1 (-((n : ℤ) + 1)) = K 1 ((n : ℤ) + 1) by simp only [K_one, neg_eq_zero, Int.natAbs_neg]] + exact K_one_right n + +theorem bridgeKernel_one_right (n : ℕ) : + bridgeKernel 1 (n : ℤ) = rho ^ 2 * (rho ^ 2) ^ n := by + rw [bridgeKernel_one, show 2 * (n : ℤ) + 1 = ((2 * n + 1 : ℕ) : ℤ) by omega] + simp only [Int.natAbs_natCast] + rw [show 2 * n + 1 + 1 = 2 + 2 * n by omega, pow_add, ← pow_mul] + +theorem bridgeKernel_one_left (n : ℕ) : + bridgeKernel 1 (-((n : ℤ) + 1)) = rho ^ 2 * (rho ^ 2) ^ n := by + rw [bridgeKernel_one, show 2 * (-((n : ℤ) + 1)) + 1 = -((2 * n + 1 : ℕ) : ℤ) by omega] + simp only [Int.natAbs_neg, Int.natAbs_natCast] + rw [show 2 * n + 1 + 1 = 2 + 2 * n by omega, pow_add, ← pow_mul] + + +theorem rho_sq_lt_one : rho ^ 2 < 1 := by + have hs : (1 : ℝ) < Real.sqrt (2 + Real.sqrt 2) := by + exact (Real.sqrt_one ▸ Real.sqrt_lt_sqrt (by norm_num) (by nlinarith [Real.sqrt_nonneg 2])) + have hp : 0 < Real.sqrt (2 + Real.sqrt 2) := lt_trans zero_lt_one hs + have hr : rho < 1 := (div_lt_one hp).2 hs + nlinarith [rho_pos] + +theorem hasSum_K_one : HasSum (K 1) (2 * rho ^ 3 / (1 - rho ^ 2)) := by + have hg := hasSum_geometric_of_lt_one (sq_nonneg rho) rho_sq_lt_one + have hr : HasSum (fun n : ℕ => K 1 ((n : ℤ) + 1)) (rho ^ 3 / (1 - rho ^ 2)) := by + simp only [K_one_right, div_eq_mul_inv] + exact hg.mul_left _ + have hl : HasSum (fun n : ℕ => K 1 (-((n : ℤ) + 1))) (rho ^ 3 / (1 - rho ^ 2)) := by + simp only [K_one_left, div_eq_mul_inv] + exact hg.mul_left _ + have hn : HasSum (fun n : ℕ => K 1 (n : ℤ)) (rho ^ 3 / (1 - rho ^ 2)) := by + have h := (hasSum_nat_add_iff (f := fun n : ℕ => K 1 (n : ℤ)) 1).mp (by simpa using hr) + simpa using h + convert hn.of_nat_of_neg_add_one hl using 1 + ring + +theorem hasSum_bridgeKernel_one : HasSum (bridgeKernel 1) (2 * rho ^ 2 / (1 - rho ^ 2)) := by + have hg := hasSum_geometric_of_lt_one (sq_nonneg rho) rho_sq_lt_one + have hr : HasSum (fun n : ℕ => bridgeKernel 1 (n : ℤ)) (rho ^ 2 / (1 - rho ^ 2)) := by + simp only [bridgeKernel_one_right, div_eq_mul_inv] + exact hg.mul_left _ + have hl : HasSum (fun n : ℕ => bridgeKernel 1 (-((n : ℤ) + 1))) (rho ^ 2 / (1 - rho ^ 2)) := by + simp only [bridgeKernel_one_left, div_eq_mul_inv] + exact hg.mul_left _ + convert hr.of_nat_of_neg_add_one hl using 1 + ring + +theorem hasSum_moment_one : + HasSum (fun n : ℕ => (n + 1 : ℝ) * K 1 (n + 1)) (rho ^ 3 / (1 - rho ^ 2) ^ 2) := by + have hs := hasSum_choose_mul_geometric_of_norm_lt_one (r := rho ^ 2) 1 + (by simpa [Real.norm_eq_abs, abs_of_nonneg (sq_nonneg rho)] using rho_sq_lt_one) + have he (n : ℕ) : (n+1 : ℝ) * K 1 (n+1) = rho ^ 3 * ((n+1 : ℝ) * (rho ^ 2) ^ n) := by + rw [K_one_right]; ring + simp only [he] + simpa only [Nat.choose_one_right, Nat.cast_add, Nat.cast_one, div_eq_mul_inv, + Nat.reduceAdd, one_mul] using hs.mul_left (rho ^ 3) + + + +theorem stripSumsFinite_one : StripSumsFinite 1 := + ⟨fun k => (hasSum_archWeight_one k).summable, + fun k => (hasSum_bridgeWeight_one k).summable, + hasSum_K_one.summable, hasSum_bridgeKernel_one.summable, hasSum_moment_one.summable⟩ + +theorem archMass_one : archMass 1 = 2 * rho ^ 3 / (1 - rho ^ 2) := hasSum_K_one.tsum_eq + +theorem bridgeMass_one : bridgeMass 1 = 2 * rho ^ 2 / (1 - rho ^ 2) := hasSum_bridgeKernel_one.tsum_eq + +theorem moment_one : moment 1 = rho ^ 3 / (1 - rho ^ 2) ^ 2 := hasSum_moment_one.tsum_eq + + +theorem two_C_mul_rho : 2 * C * rho = 1 := by + unfold C lambda rho + rw [Real.cos_pi_div_eight] + have hn : Real.sqrt (2 + Real.sqrt 2) ≠ 0 := ne_of_gt (Real.sqrt_pos.mpr (by positivity)) + field_simp + +theorem c_eq_sqrt_two_mul_rho : c = (Real.sqrt 2 / 2) * rho := by + have hs : 2 * c * C = Real.sqrt 2 / 2 := by + unfold c C lambda + rw [show 3 * Real.pi / 8 = Real.pi / 2 - Real.pi / 8 by ring, + Real.cos_pi_div_two_sub, ← Real.sin_two_mul, + show 2 * (Real.pi / 8) = Real.pi / 4 by ring, Real.sin_pi_div_four] + linear_combination rho * hs - c * two_C_mul_rho + +theorem rho_sq : rho ^ 2 = (2 - Real.sqrt 2) / 2 := by + unfold rho + rw [div_pow, Real.sq_sqrt (by positivity : 0 ≤ 2 + Real.sqrt 2)] + apply (div_eq_iff (by positivity : (2 + Real.sqrt 2 : ℝ) ≠ 0)).2 + nlinarith [Real.sq_sqrt (show (0 : ℝ) ≤ 2 by norm_num)] + +theorem critical_one_band_identity : 2 * c * rho ^ 3 + 3 * rho ^ 2 = 1 := by + rw [c_eq_sqrt_two_mul_rho] + calc + 2 * (Real.sqrt 2 / 2 * rho) * rho ^ 3 + 3 * rho ^ 2 = + Real.sqrt 2 * (rho ^ 2) ^ 2 + 3 * rho ^ 2 := by ring + _ = 1 := by + rw [rho_sq] + linear_combination (Real.sqrt 2 / 4 - 1) * Real.sq_sqrt (show (0 : ℝ) ≤ 2 by norm_num) + + +theorem flux_one : c * archMass 1 + bridgeMass 1 = 1 := by + rw [archMass_one, bridgeMass_one] + have hn : 1 - rho ^ 2 ≠ 0 := ne_of_gt (sub_pos.mpr rho_sq_lt_one) + field_simp + nlinarith [critical_one_band_identity] + + + + + + +def mirrorTriangle (v : Triangle) : Triangle := + (-v.1 - (v.2.1 : ℤ) - (if v.2.2 then 0 else 1), v.2.1, v.2.2) + +@[simp] theorem mirrorTriangle_band (v : Triangle) : (mirrorTriangle v).2.1 = v.2.1 := rfl + +@[simp] theorem mirrorTriangle_up (i : ℤ) (j : ℕ) : + mirrorTriangle (up i j) = up (-i - j) j := by + simp [mirrorTriangle, up] + +@[simp] theorem mirrorTriangle_down (i : ℤ) (j : ℕ) : + mirrorTriangle (down i j) = down (-i - j - 1) j := by + simp [mirrorTriangle, down] + +@[simp] theorem mirrorTriangle_mirrorTriangle (v : Triangle) : + mirrorTriangle (mirrorTriangle v) = v := by + rcases v with ⟨i, j, b⟩ + cases b <;> simp [mirrorTriangle] + ring + +theorem mirrorTriangle_involutive : Function.Involutive mirrorTriangle := mirrorTriangle_mirrorTriangle + +theorem mirrorTriangles_involutive : Function.Involutive (List.map mirrorTriangle) := by + intro l + simp [List.map_map, Function.comp_def] + + +theorem adjacent_mirror_iff (v w : Triangle) : + adjacent (mirrorTriangle v) (mirrorTriangle w) ↔ adjacent v w := by + rcases v with ⟨a, j, b⟩ + rcases w with ⟨a', j', b'⟩ + cases b <;> cases b' <;> simp [adjacent, upDownAdjacent, mirrorTriangle] + all_goals omega + +theorem IsPath.mirror {N : ℕ} {finish : Triangle} {p : List Triangle} + (hp : IsPath N finish p) : + IsPath N (mirrorTriangle finish) (p.map mirrorTriangle) := by + refine ⟨?_, ?_, hp.2.2.1.map mirrorTriangle_involutive.injective, ?_, ?_⟩ + · rw [List.head?_map, hp.1] + simp + · rw [List.getLast?_map, hp.2.1] + rfl + · apply (List.isChain_map _).mpr + apply hp.2.2.2.1.imp + intro v w h + exact (adjacent_mirror_iff v w).mpr h + · intro v hv + obtain ⟨w, hw, rfl⟩ := List.mem_map.mp hv + exact hp.2.2.2.2 w hw + +@[simp] theorem isPath_mirror_iff {N : ℕ} {finish : Triangle} {p : List Triangle} : + IsPath N (mirrorTriangle finish) (p.map mirrorTriangle) ↔ IsPath N finish p := by + refine ⟨fun h => ?_, IsPath.mirror⟩ + simpa [List.map_map, Function.comp_def] using h.mirror + +theorem archWeight_mirror (N : ℕ) (k : ℤ) (p : List Triangle) : + archWeight N (-k) (p.map mirrorTriangle) = archWeight N k p := by + classical + have he : up (-k) 0 = mirrorTriangle (up k 0) := by simp + simp only [archWeight, neg_ne_zero, he, isPath_mirror_iff, List.length_map] + +theorem bridgeWeight_mirror (N : ℕ) (k : ℤ) (p : List Triangle) : + bridgeWeight N (-k - N) (p.map mirrorTriangle) = bridgeWeight N k p := by + classical + rcases N with _ | N + · simp [bridgeWeight] + · have he : down (-k - (N + 1 : ℕ)) (N + 1 - 1) = + mirrorTriangle (down k (N + 1 - 1)) := by + simp only [mirrorTriangle_down, Nat.add_sub_cancel] + congr 1 + push_cast + ring + simp only [bridgeWeight, he, isPath_mirror_iff, List.length_map] + + + +theorem K_reflection (N : ℕ) (k : ℤ) : K N (-k) = K N k := by + let e := mirrorTriangles_involutive.toPerm _ + calc + K N (-k) = ∑' p : List Triangle, archWeight N (-k) (p.map mirrorTriangle) := + (e.tsum_eq (archWeight N (-k))).symm + _ = K N k := tsum_congr (archWeight_mirror N k) + +theorem bridgeKernel_reflection (N : ℕ) (k : ℤ) : + bridgeKernel N (-k - N) = bridgeKernel N k := by + let e := mirrorTriangles_involutive.toPerm _ + calc + bridgeKernel N (-k - N) = ∑' p : List Triangle, bridgeWeight N (-k - N) (p.map mirrorTriangle) := + (e.tsum_eq (bridgeWeight N (-k - N))).symm + _ = bridgeKernel N k := tsum_congr (bridgeWeight_mirror N k) + + +theorem hasSum_absoluteMoment {N : ℕ} + (hM : Summable (fun n : ℕ => (n + 1 : ℝ) * K N (n + 1))) : + HasSum (fun k : ℤ => (k.natAbs : ℝ) * K N k) (2 * moment N) := by + have hp : HasSum (fun n : ℕ => (((n : ℤ) + 1).natAbs : ℝ) * K N ((n : ℤ) + 1)) (moment N) := by + have he (n : ℕ) : (((n : ℤ) + 1).natAbs : ℝ) = (n : ℝ) + 1 := by + rw [show (n : ℤ) + 1 = ((n + 1 : ℕ) : ℤ) by omega, Int.natAbs_natCast, + Nat.cast_add, Nat.cast_one] + simp only [he] + exact hM.hasSum + have hn : HasSum (fun n : ℕ => ((-((n : ℤ) + 1)).natAbs : ℝ) * K N (-((n : ℤ) + 1))) (moment N) := by + simpa only [Int.natAbs_neg, K_reflection] using hp + have hp0 : HasSum (fun n : ℕ => (((n : ℤ)).natAbs : ℝ) * K N (n : ℤ)) (moment N) := by + have h := (hasSum_nat_add_iff (f := fun n : ℕ => (((n : ℤ)).natAbs : ℝ) * K N (n : ℤ)) 1).mp + (by simpa using hp) + simpa using h + simpa only [two_mul] using hp0.of_nat_of_neg_add_one (f := fun k : ℤ => (k.natAbs : ℝ) * K N k) hn + +theorem absoluteMoment_eq {N : ℕ} (hN : StripSumsFinite N) : + (∑' k : ℤ, (k.natAbs : ℝ) * K N k) = 2 * moment N := + (hasSum_absoluteMoment hN.2.2.2.2).tsum_eq + + + +theorem summable_K_of_moment {N : ℕ} + (hM : Summable (fun n : ℕ => (n + 1 : ℝ) * K N (n + 1))) : + Summable (K N) := by + have hp : Summable (fun n : ℕ => K N ((n : ℤ) + 1)) := by + apply Summable.of_nonneg_of_le (fun n => K_nonneg _ _) (fun n => ?_) hM + have hn : (1 : ℝ) ≤ n + 1 := by linarith [Nat.cast_nonneg (α := ℝ) n] + exact (one_mul _).symm.le.trans (mul_le_mul_of_nonneg_right hn (K_nonneg _ _)) + have hm : HasSum (fun n : ℕ => K N (-((n : ℤ) + 1))) (∑' n : ℕ, K N ((n : ℤ) + 1)) := by + simpa only [K_reflection] using hp.hasSum + have hp0 : HasSum (fun n : ℕ => K N (n : ℤ)) (∑' n : ℕ, K N ((n : ℤ) + 1)) := by + have h := (hasSum_nat_add_iff (f := fun n : ℕ => K N (n : ℤ)) 1).mp (by simpa using hp.hasSum) + simpa using h + exact (hp0.of_nat_of_neg_add_one hm).summable + +theorem archMass_eq_twice_right {N : ℕ} (hN : StripSumsFinite N) : + archMass N = 2 * ∑' n : ℕ, K N ((n : ℤ) + 1) := by + have hp : Summable (fun n : ℕ => K N ((n : ℤ) + 1)) := + hN.2.2.1.comp_injective (fun n m h => by omega) + have hm : HasSum (fun n : ℕ => K N (-((n : ℤ) + 1))) (∑' n : ℕ, K N ((n : ℤ) + 1)) := by + simpa only [K_reflection] using hp.hasSum + have hp0 : HasSum (fun n : ℕ => K N (n : ℤ)) (∑' n : ℕ, K N ((n : ℤ) + 1)) := by + have h := (hasSum_nat_add_iff (f := fun n : ℕ => K N (n : ℤ)) 1).mp (by simpa using hp.hasSum) + simpa using h + unfold archMass + simpa only [two_mul] using (hp0.of_nat_of_neg_add_one hm).tsum_eq + + + + + +def columnVertex (k : ℕ) : Triangle := + if k % 2 = 0 then up 0 (k / 2) else down 0 (k / 2) + +@[simp] theorem columnVertex_band (k : ℕ) : (columnVertex k).2.1 = k / 2 := by + simp only [columnVertex] + split <;> rfl + +theorem columnVertex_injective : Function.Injective columnVertex := by + have hr (k : ℕ) : 2 * (columnVertex k).2.1 + (if (columnVertex k).2.2 then 0 else 1) = k := by + simp only [columnVertex] + split <;> simp only [up, down, Bool.false_eq_true, reduceIte, ite_true] + all_goals omega + intro a b hab + have hh := congrArg (fun v : Triangle => 2 * v.2.1 + (if v.2.2 then 0 else 1)) hab + simpa only [hr] using hh + +end +end CriticalStrip + +end OAI diff --git a/lean/OAI/Combinatorics/StripMass/HoneycombClip.lean b/lean/OAI/Combinatorics/StripMass/HoneycombClip.lean new file mode 100644 index 0000000000000000000000000000000000000000..c6238071458e35248fcc6c04bc07c45eb51b4657 --- /dev/null +++ b/lean/OAI/Combinatorics/StripMass/HoneycombClip.lean @@ -0,0 +1,589 @@ +import Mathlib +import OAI.Combinatorics.StripMass.HalfTurn + +namespace OAI + +/-! Critical honeycomb strip paths, polynomial identities and crossing mass. -/ + + +namespace CriticalStrip +noncomputable section +open scoped Classical BigOperators +open Diagram + + +def turnRow (N j : ℕ) : ℕ := if j decide +end Diagram.Tile + +namespace HoneycombAssignment +variable {N : ℕ} + +def weight (D : HoneycombAssignment N) : ℝ := + ∏ᶠ q : Cell,(physicalWeights (2*Diagram.lambda)).tile (D.tile q) + +lemma turn_tile_all (D : HoneycombAssignment N) (b : ℤ) (q : Cell) : + (D.turn b).tile q=(D.tile (turnCell N b q)).turn := by + rcases q with ⟨i,j⟩ + by_cases hj : j.trans (by simp only [turnCell,turnRow,hj,ite_true,Equiv.coe_fn_mk]) + · simp only [turn,turnCell,Equiv.coe_fn_mk,turnRow,hj,ite_false,D.outside (b-i) j (by omega),Tile.turn_vacant] + +lemma turn_weight (D : HoneycombAssignment N) (b : ℤ) : (D.turn b).weight=D.weight := by + unfold weight + simp_rw [D.turn_tile_all b,Tile.turn_weight] + exact finprod_comp_equiv (turnCell N b) (f:=fun q : Cell=>(physicalWeights (2*Diagram.lambda)).tile (D.tile q)) + +lemma turn_tileSupport (D : HoneycombAssignment N) (b : ℤ) : + (D.turn b).tileSupport=turnCell N b ⁻¹' D.tileSupport := by + ext q + change ((D.turn b).tile q≠.vacant) ↔ D.tile (turnCell N b q)≠.vacant + rw [D.turn_tile_all b,Tile.turn_nonvacant] + + +def Fits (D : HoneycombAssignment N) (m : ℕ) : Prop := + ∀q : Cell,D.tile q≠.vacant → -(m:ℤ)≤q.1 ∧ q.1<(m:ℤ) + +lemma Fits.mono {D : HoneycombAssignment N} {m l : ℕ} (h : D.Fits m) (hm : m≤l) : + D.Fits l := by + intro q hq + obtain ⟨h₁,h₂⟩:=h q hq + constructor <;> omega + +lemma exists_fits (D : HoneycombAssignment N) (h : D.tileSupport.Finite) : ∃m,D.Fits m := by + let F:=h.toFinset + refine ⟨F.sup (fun q=>q.1.natAbs+1),?_⟩ + intro q hq + have hm : q∈F := h.mem_toFinset.mpr hq + have hs : q.1.natAbs+1≤F.sup (fun q=>q.1.natAbs+1) := Finset.le_sup (f:=fun q : Cell=>q.1.natAbs+1) hm + have hi : q.1≤(q.1.natAbs:ℤ) := Int.le_natAbs + have hi' : -q.1≤(q.1.natAbs:ℤ) := by have ht : -q.1≤((-q.1).natAbs:ℤ) := Int.le_natAbs; simpa only [Int.natAbs_neg] using ht + constructor <;> omega + +lemma Fits.vacant_left {D : HoneycombAssignment N} {m k : ℕ} (h : D.Fits m) (hk : m≤k) + (j : ℕ) : D.tile (-1-(k:ℤ),j)=.vacant := by + by_contra he + have hh:=(h _ he).1 + omega + +lemma Fits.vacant_right {D : HoneycombAssignment N} {m k : ℕ} (h : D.Fits m) (hk : m≤k) + (j : ℕ) : D.tile ((k:ℤ),j)=.vacant := by + by_contra he + have hh:=(h _ he).2 + omega + +def leftClip (D : HoneycombAssignment N) (m : ℕ) : Fin m → Configuration N := + fun k j=>D.tile (-1-(k.val:ℤ),j.val) + +def rightClip (D : HoneycombAssignment N) (m : ℕ) : Fin m → Configuration N := + fun k j=>(D.tile ((k.val:ℤ),j.val)).horizontal + +lemma read_leftClip (D : HoneycombAssignment N) (m : ℕ) (h : D.Fits m) (k : ℕ) (j : Fin N) : + ColumnChain.read (List.ofFn (D.leftClip m)) k j=D.tile (-1-(k:ℤ),j.val) := by + by_cases hk : k < m + · simp only [ColumnChain.read,List.getElem?_ofFn,hk,dite_eq_left,Option.getD_some,leftClip] + · rw [ColumnChain.read_ge _ k (by simpa only [List.length_ofFn] using Nat.le_of_not_gt hk), + h.vacant_left (by omega)] + +lemma read_rightClip (D : HoneycombAssignment N) (m : ℕ) (h : D.Fits m) (k : ℕ) (j : Fin N) : + ColumnChain.read (List.ofFn (D.rightClip m)) k j=(D.tile ((k:ℤ),j.val)).horizontal := by + by_cases hk : k < m + · simp only [ColumnChain.read,List.getElem?_ofFn,hk,dite_eq_left,Option.getD_some,rightClip] + · rw [ColumnChain.read_ge _ k (by simpa only [List.length_ofFn] using Nat.le_of_not_gt hk), + h.vacant_right (by omega)] + rfl + +lemma sewn_clips (D : HoneycombAssignment N) (m : ℕ) (h : D.Fits m) : + D.tile=SewnRectangle.tile (List.ofFn (D.leftClip m)) (List.ofFn (D.rightClip m)) := by + funext ⟨i,j⟩ + by_cases hj : j dsimp <;> omega + · have he : (D.extend hN hab).tile (i,j)=D.tile (i,j) := ite_eq_right hj + exact hf _ (he ▸ hq) + +lemma weight_toArch (D : TopArchConfiguration N a b) (hN : 1≤N) : + (D.toArch hN).weight=D.toHoneycombAssignment.weight := + D.toHoneycombAssignment.turn_weight b + +end TopArchConfiguration +end + + + + + +noncomputable section +open scoped Classical +open Diagram + +namespace Diagram.Graph + +lemma glued_reach_right_boundary {V W I : Type*} (r : V → V → Prop) (s : W → W → Prop) + (a : I → V) (b : I → W) (active : I → Prop) (root : I) + {x : V⊕W} (h : Relation.ReflTransGen (Patch.glued r s a b active) x (.inr (b root))) : + match x with + | .inl _ => True + | .inr x => ∃ i,Relation.ReflTransGen s x (b i) := by + induction h using Relation.ReflTransGen.head_induction_on with + | refl => exact ⟨root,.refl⟩ + | @head x y hxy h ih => + cases x with + | inl x => trivial + | inr x => + cases y with + | inl y => + obtain ⟨i,hi,rfl,hy⟩:=hxy + exact ⟨i,.refl⟩ + | inr y => + obtain ⟨i,hi⟩:=ih + exact ⟨i,hi.head hxy⟩ + +lemma glued_drainsAt_halves {V W I : Type*} (r : V → V → Prop) (s : W → W → Prop) + (a : I → V) (b : I → W) (active : I → Prop) (root : I) + (h : DrainsAt (Patch.glued r s a b active) (.inr (b root))) : + DrainsBoundary r a ∧ DrainsBoundary s b := by + constructor + · intro v w hvw + obtain ⟨i,hi,hr,_⟩:=Patch.reach_to_exterior r s a b active (h (.inl v) (.inl w) hvw) + exact ⟨i,hr⟩ + · intro v w hvw + exact glued_reach_right_boundary r s a b active root (h (.inr v) (.inr w) hvw) + +end Diagram.Graph + +namespace HoneycombAssignment +variable {N : ℕ} + +lemma clip_occupancies (D : HoneycombAssignment N) (m : ℕ) (hf : D.Fits m) + (p q : Pairing N) + (hl : ColumnChain.Runs (empty N) (List.ofFn (D.leftClip m)) p) + (hr : ColumnChain.Runs (empty N) (List.ofFn (D.rightClip m)) q) : + (∀i,p.Occupied i ↔ (D.tile (-1,i.val)).Occupied 2) ∧ + (∀i,q.Occupied i ↔ (D.tile (0,i.val)).Occupied 1) := by + have hp:=(ColumnChain.runs_sound _ _ _ hl).2.2 + have hq:=(ColumnChain.runs_sound _ _ _ hr).2.2 + constructor + · intro i + rw [←hp,ColumnChain.support_empty_read,D.read_leftClip m hf] + norm_num + · intro i + rw [←hq,ColumnChain.support_empty_read,D.read_rightClip m hf,Tile.horizontal_occupied_two] + norm_num + + + +lemma clips_runs_glues (D : HoneycombAssignment N) (hN : 0physicalWeights (2*Diagram.lambda)) northInjectionWeights + +def rightWeights (N : ℕ) : Fin (N+1) → Weights ℝ := + Fin.snoc (fun _ : Fin N=>physicalWeights Diagram.lambda) northInjectionWeights + +lemma north_row_tile (l r : List (Configuration (N+1))) (kl ll kr lr : ℕ) + (hl : l.map (fun t=>t (Fin.last N))= + List.replicate kl Tile.diagonal₁ ++ Tile.vertical₀::List.replicate ll Tile.vacant) + (hr : r.map (fun t=>t (Fin.last N))= + List.replicate kr Tile.diagonal₁ ++ Tile.vertical₀::List.replicate lr Tile.vacant) + (i : ℤ) : tile l r (i,N)=NorthExtension.tile (-1-(kl:ℤ)) kr i := by + rcases split_column i with ⟨k,rfl⟩|⟨k,rfl⟩ + · rw [show tile l r (-1-(k:ℤ),N)=ColumnChain.read l k (Fin.last N) from tile_left l r k (Fin.last N),ColumnChain.north_shape_read l kl ll hl k] + unfold NorthExtension.tile + split_ifs <;> first | rfl | omega + · rw [show tile l r ((k:ℤ),N)=(ColumnChain.read r k (Fin.last N)).horizontal from tile_right l r k (Fin.last N),ColumnChain.north_shape_read r kr lr hr k] + unfold NorthExtension.tile + split_ifs <;> first | rfl | omega + +lemma runs_cut {l r : List (Configuration (N+1))} {p q : Pairing (N+1)} + (hl : ColumnChain.Runs (empty (N+1)) l p) + (hr : ColumnChain.Runs (empty (N+1)) r q) + (hg : p.GluesAt (Fin.last N) q) : + ∀i,(ColumnChain.read l 0 i).Occupied 2 ↔ (ColumnChain.read r 0 i).Occupied 2 := by + intro i + rw [←ColumnChain.support_empty_read,←ColumnChain.support_empty_read, + (ColumnChain.runs_sound _ _ _ hl).2.2,(ColumnChain.runs_sound _ _ _ hr).2.2] + exact hg.2.1 i + + + +def northAssignment (l r : List (Configuration (N+1))) (p q : Pairing (N+1)) + (hl : ColumnChain.Runs (empty (N+1)) l p) + (hr : ColumnChain.Runs (empty (N+1)) r q) + (hg : p.GluesAt (Fin.last N) q) + (hwl : ColumnChain.weight (leftWeights N) l≠0) + (hwr : ColumnChain.weight (rightWeights N) r≠0) : HoneycombAssignment (N+1) := + assignment l r ((ColumnChain.compatible_empty_iff l).mp (ColumnChain.runs_sound _ _ _ hl).1) + ((ColumnChain.compatible_empty_iff r).mp (ColumnChain.runs_sound _ _ _ hr).1) + (runs_cut hl hr hg) (physical_from_weights l r hwl hwr).1 (physical_from_weights l r hwl hwr).2 + +lemma northAssignment_drains (l r : List (Configuration (N+1))) (p q : Pairing (N+1)) + (hl : ColumnChain.Runs (empty (N+1)) l p) + (hr : ColumnChain.Runs (empty (N+1)) r q) + (hg : p.GluesAt (Fin.last N) q) + (hwl : ColumnChain.weight (leftWeights N) l≠0) + (hwr : ColumnChain.weight (rightWeights N) r≠0) : + Graph.DrainsAt (northAssignment l r p q hl hr hg hwl hwr).graph.Adj (up 0 N) := by + let D:=northAssignment l r p q hl hr hg hwl hwr + have hh:=(gluesAt_physical_iff l r p q hl hr D rfl (Fin.last N)).mp hg + have ho : (D.tile (0,N)).Occupied 1 := by + change (tile l r ((0:ℕ), (Fin.last N).val)).Occupied 1 + rw [tile_right,Tile.horizontal_occupied_one,←ColumnChain.support_empty_read, + (ColumnChain.runs_sound _ _ _ hr).2.2] + exact (hg.2.1 _).mp hg.1 + exact (D.port_drains_iff ((D.port_used _).mpr ho)).mp hh.2.2 + + +def northArch (l r : List (Configuration (N+1))) (p q : Pairing (N+1)) (hN : 1≤N) + (hl : ColumnChain.Runs (empty (N+1)) l p) + (hr : ColumnChain.Runs (empty (N+1)) r q) + (hg : p.GluesAt (Fin.last N) q) + (hwl : ColumnChain.weight (leftWeights N) l≠0) + (hwr : ColumnChain.weight (rightWeights N) r≠0) + (kl ll kr lr : ℕ) + (hsl : l.map (fun t=>t (Fin.last N))= + List.replicate kl Tile.diagonal₁ ++ Tile.vertical₀::List.replicate ll Tile.vacant) + (hsr : r.map (fun t=>t (Fin.last N))= + List.replicate kr Tile.diagonal₁ ++ Tile.vertical₀::List.replicate lr Tile.vacant) : + TopArchConfiguration N (-1-(kl:ℤ)) kr where + toHoneycombAssignment := (northAssignment l r p q hl hr hg hwl hwr).restrict N (by omega) + bottom i := by + rw [HoneycombAssignment.restrict_tile _ _ _ i 0 (by omega)] + exact south_vacant l r ((ColumnChain.compatible_empty_iff l).mp (ColumnChain.runs_sound _ _ _ hl).1) + ((ColumnChain.compatible_empty_iff r).mp (ColumnChain.runs_sound _ _ _ hr).1) i + top i := by + rw [HoneycombAssignment.restrict_tile _ _ _ i (N-1) (by omega)] + have hh:=(northAssignment l r p q hl hr hg hwl hwr).vertical i (N-1) (by omega) + rw [show N-1+1=N by omega] at hh + exact hh.trans (north_south_occupied l r kl ll kr lr hsl hsr i) + drains := by + apply HoneycombAssignment.restrict_drains_of_two_top _ hN _ _ (up 0 N) rfl + (northAssignment_drains l r p q hl hr hg hwl hwr) + (restrict_finite_support _ l r rfl) + · exact south_vacant l r ((ColumnChain.compatible_empty_iff l).mp (ColumnChain.runs_sound _ _ _ hl).1) + ((ColumnChain.compatible_empty_iff r).mp (ColumnChain.runs_sound _ _ _ hr).1) + · exact north_south_occupied l r kl ll kr lr hsl hsr + +lemma northArch_extend (l r : List (Configuration (N+1))) (p q : Pairing (N+1)) (hN : 1≤N) + (hl : ColumnChain.Runs (empty (N+1)) l p) + (hr : ColumnChain.Runs (empty (N+1)) r q) + (hg : p.GluesAt (Fin.last N) q) + (hwl : ColumnChain.weight (leftWeights N) l≠0) + (hwr : ColumnChain.weight (rightWeights N) r≠0) + (kl ll kr lr : ℕ) + (hsl : l.map (fun t=>t (Fin.last N))= + List.replicate kl Tile.diagonal₁ ++ Tile.vertical₀::List.replicate ll Tile.vacant) + (hsr : r.map (fun t=>t (Fin.last N))= + List.replicate kr Tile.diagonal₁ ++ Tile.vertical₀::List.replicate lr Tile.vacant) : + (northArch l r p q hN hl hr hg hwl hwr kl ll kr lr hsl hsr).extend hN (by omega)= + northAssignment l r p q hl hr hg hwl hwr := by + apply HoneycombAssignment.ext + funext ⟨i,j⟩ + by_cases hj : j=N + · subst j + rw [TopArchConfiguration.extend_last] + exact (north_row_tile l r kl ll kr lr hsl hsr i).symm + · by_cases hn : j simp [weight] + | succ m ih => rw [List.ofFn_succ,weight,ih,Fin.prod_univ_succ] +end Diagram.ColumnChain + + +def windowCell (N m : ℕ) : (Fin m ⊕ Fin m) × Fin N → Cell + | (.inl k,j) => (-1-(k.val:ℤ),j.val) + | (.inr k,j) => ((k.val:ℤ),j.val) + +lemma windowCell_injective (N m : ℕ) : Function.Injective (windowCell N m) := by + rintro ⟨k,j⟩ ⟨l,i⟩ h + cases k <;> cases l + all_goals simp only [windowCell,Prod.mk.injEq] at h + · exact Prod.ext (congrArg Sum.inl (Fin.ext (by omega))) (Fin.ext h.2) + · omega + · omega + · exact Prod.ext (congrArg Sum.inr (Fin.ext (by omega))) (Fin.ext h.2) + +lemma windowCell_range (N m : ℕ) (q : Cell) : + (∃ x,windowCell N m x=q) ↔ -(m:ℤ)≤q.1 ∧ q.1<(m:ℤ) ∧ q.2 dsimp [windowCell] <;> omega + · rintro ⟨hl,hr,hj⟩ + by_cases hq : q.1<0 + · refine ⟨(.inl ⟨(-1-q.1).toNat,by omega⟩,⟨q.2,hj⟩),?_⟩ + apply Prod.ext <;> dsimp [windowCell] + omega + · refine ⟨(.inr ⟨q.1.toNat,by omega⟩,⟨q.2,hj⟩),?_⟩ + apply Prod.ext <;> dsimp [windowCell] + omega + +namespace HoneycombAssignment +variable {N : ℕ} + +lemma weight_window (D : HoneycombAssignment N) (m : ℕ) (h : D.Fits m) : + D.weight=(∏ k : Fin m,∏ j : Fin N, + (physicalWeights (2*Diagram.lambda)).tile (D.tile (-1-(k.val:ℤ),j.val))) * + (∏ k : Fin m,∏ j : Fin N, + (physicalWeights (2*Diagram.lambda)).tile (D.tile ((k.val:ℤ),j.val))) := by + let F:=Finset.univ.image (windowCell N m) + have hs : Function.mulSupport (fun q=>(physicalWeights (2*Diagram.lambda)).tile (D.tile q)) ⊆ (F:Set Cell) := by + intro q hq + have ht : D.tile q≠.vacant := by + intro he + exact hq (by change (physicalWeights (2*Diagram.lambda)).tile (D.tile q)=1; rw [he]; rfl) + have hj : q.2 simp_all [Weights.tile] +end HoneycombAssignment + +namespace TopArchConfiguration +variable {N : ℕ} {a b : ℤ} + +lemma extend_left_north_weight (D : TopArchConfiguration N a b) (hN : 1≤N) (hab : a first | omega | rfl + +lemma extend_right_north_weight (D : TopArchConfiguration N a b) (hN : 1≤N) (hab : a first | omega | rfl + +lemma leftClip_weight (D : TopArchConfiguration N a b) (hN : 1≤N) (hab : a apply Finset.prod_ne_zero_iff.mpr <;> intro k _ <;> + apply Finset.prod_ne_zero_iff.mpr <;> intro j _ <;> + exact HoneycombAssignment.physical_tile_weight_ne_zero _ _ + +end TopArchConfiguration +end +end CriticalStrip + +end OAI diff --git a/lean/OAI/Combinatorics/StripMass/HoneycombDictionary.lean b/lean/OAI/Combinatorics/StripMass/HoneycombDictionary.lean new file mode 100644 index 0000000000000000000000000000000000000000..74aa4e4ff52aec058edc20c6baf0ebd00f8a8d03 --- /dev/null +++ b/lean/OAI/Combinatorics/StripMass/HoneycombDictionary.lean @@ -0,0 +1,525 @@ +import Mathlib +import OAI.Combinatorics.StripMass.HoneycombTiles + +namespace OAI + +/-! Critical honeycomb strip paths, polynomial identities and crossing mass. -/ + + +namespace CriticalStrip +noncomputable section +open scoped Classical BigOperators +open Diagram Diagram.PathGraph + +namespace HoneycombAssignment +variable {N : ℕ} + +@[ext] lemma ext {D E : HoneycombAssignment N} (h : D.tile=E.tile) : D=E := by + cases D; cases E; cases h; rfl + + + +lemma ext_graph_boundary (D E : HoneycombAssignment N) (hN : 1≤N) + (hg : D.graph=E.graph) + (hb : ∀ i, (D.tile (i,0)).Occupied 0 ↔ (E.tile (i,0)).Occupied 0) + (ht : ∀ i, (D.tile (i,N-1)).Occupied 3 ↔ (E.tile (i,N-1)).Occupied 3) : D=E := by + apply ext + funext ⟨i,j⟩ + by_cases hj : j hf.1 (h.2.1.mp hp) + · exact fun hp => hf.2.1 (h.2.2.1.mp hp) + · exact fun hp => hf.2.2.1 (h.2.2.2.1.mp hp) + · exact fun hp => hf.2.2.2.1 (h.2.2.2.2.1.mp hp) + horizontal i j := by + rw [(D.physicalTile_spec hN hb i j).2.2.2.1, + (D.physicalTile_spec hN hb (i+1) j).2.2.1] + simp only [east,west,add_sub_cancel_right] + exact ⟨D.graph.symm.symm _ _,D.graph.symm.symm _ _⟩ + vertical i j hj := by + rw [(D.physicalTile_spec hN hb i j).2.2.2.2.1, + (D.physicalTile_spec hN hb i (j+1)).2.1] + simp only [north,south,show j+1≠N by omega,show j+1≠0 by omega, + add_tsub_cancel_right] + exact ⟨D.graph.symm.symm _ _,D.graph.symm.symm _ _⟩ + +lemma toAssignment_up (D : WireConfiguration N (b.vertex N)) (hN : 1≤N) + (hb : b ≠ .bottom 0) (i : ℤ) (j : ℕ) (w : Triangle) : + (D.toAssignment hN hb).graph.Adj (up i j) w ↔ D.graph.Adj (up i j) w := by + rw [HoneycombAssignment.up_neighbors] + change (j exact D.toHoneycombAssignment.bottom_one ((D.bottom i).mpr (Or.inr rfl)) + | top i => exact D.toHoneycombAssignment.top_one hN ((D.top i).mpr rfl) + source_used := D.toHoneycombAssignment.bottom_used hN ((D.bottom 0).mpr (Or.inl rfl)) + finish_used := by + cases b with + | bottom i => exact D.toHoneycombAssignment.bottom_used hN ((D.bottom i).mpr (Or.inr rfl)) + | top i => exact D.toHoneycombAssignment.top_used hN ((D.top i).mpr rfl) + drains := D.drains + +def ofWire (D : WireConfiguration N (b.vertex N)) (hN : 1≤N) + (hb : b ≠ .bottom 0) : HoneycombConfiguration N b where + toHoneycombAssignment := D.toAssignment hN hb + bottom := D.toAssignment_bottom hN hb + top := D.toAssignment_top hN hb + drains v w h := by + have hg := D.toAssignment_graph hN hb + rw [hg] at h ⊢ + exact D.drains v w h + +@[simp] lemma toWire_ofWire (D : WireConfiguration N (b.vertex N)) (hN : 1≤N) + (hb : b ≠ .bottom 0) : (ofWire D hN hb).toWire hN=D := by + apply WireConfiguration.ext + exact D.toAssignment_graph hN hb + +@[simp] lemma ofWire_toWire (D : HoneycombConfiguration N b) (hN : 1≤N) + (hb : b ≠ .bottom 0) : ofWire (D.toWire hN) hN hb=D := by + apply ext + apply HoneycombAssignment.ext_graph_boundary _ _ hN + · exact (D.toWire hN).toAssignment_graph hN hb + · intro i + exact ((D.toWire hN).toAssignment_bottom hN hb i).trans (D.bottom i).symm + · intro i + exact ((D.toWire hN).toAssignment_top hN hb i).trans (D.top i).symm + + + +def equivWires (N : ℕ) (b : BoundaryPort) (hN : 1≤N) (hb : b ≠ .bottom 0) : + HoneycombConfiguration N b ≃ WireConfiguration N (b.vertex N) where + toFun D := D.toWire hN + invFun D := ofWire D hN hb + left_inv D := ofWire_toWire D hN hb + right_inv D := toWire_ofWire D hN hb + +def equivPaths (N : ℕ) (b : BoundaryPort) (hN : 1≤N) (hb : b ≠ .bottom 0) : + HoneycombConfiguration N b ≃ {p : List Triangle // IsPath N (b.vertex N) p} := + (equivWires N b hN hb).trans (WireConfiguration.equivPaths N (b.vertex N) (b.vertex_ne_source hb)) + +lemma path_spec (D : HoneycombConfiguration N b) (hN : 1≤N) (hb : b ≠ .bottom 0) : + IsPath N (b.vertex N) (D.toWire hN).path := + (D.toWire hN).path_isPath (b.vertex_ne_source hb) + +end HoneycombConfiguration + + + + + + +namespace Diagram + + + +lemma physicalWeights_two_lambda : + physicalWeights (2*lambda) = (⟨rho^2,rho^2,rho,0,rho^2⟩ : Weights ℝ) := by + have hL : L (2*lambda)=C := by + unfold L + rw [show 2*lambda+2*lambda=4*lambda by ring, + show 3*lambda+2*lambda=5*lambda by ring, + sin_four_lambda_eq_one,sin_five_lambda_eq,sin_three_lambda_eq_C,one_mul] + unfold physicalWeights + dsimp only + change (⟨d * _ / _,_,_,_,_⟩ : Weights ℝ) = _ + rw [hL,show 3*lambda-2*lambda=lambda by ring,show 2*lambda-2*lambda=0 by ring, + show 2*lambda-lambda=lambda by ring,sin_lambda_eq_c,sin_two_lambda_eq_d, + Real.sin_zero,mul_zero,zero_div,d_mul_c_div_C,show c*d=d*c by ring, + d_mul_c_div_C] + change (⟨rho^2,rho^2,d*d/C,0,rho^2⟩ : Weights ℝ) = _ + rw [←pow_two,d_sq_div_C] + +lemma Tile.nonvacant_iff_used (t : Tile) : t ≠ .vacant ↔ t.upperUsed ∨ t.lowerUsed := by + revert t + decide + +lemma Tile.upperUsed_internal (t : Tile) (ht : t ≠ .verticalPair) : + t.upperUsed → t.Occupied 1 ∨ t.middle := by + revert t + decide + +lemma Tile.lowerUsed_internal (t : Tile) (ht : t ≠ .verticalPair) : + t.lowerUsed → t.Occupied 2 ∨ t.middle := by + revert t + decide + +end Diagram + +namespace HoneycombAssignment +variable {N : ℕ} + +lemma up_support_iff (D : HoneycombAssignment N) (i : ℤ) (j : ℕ) : + up i j ∈ D.graph.support ↔ (D.tile (i,j)).upperUsed := by + change (∃ w, D.graph.Adj (up i j) w) ↔ _ + constructor + · rintro ⟨w,hw⟩ + apply (Tile.upperUsed_iff _ (D.physical (i,j))).mpr + rcases (D.up_neighbors i j w).mp hw with ⟨_,h⟩ + rcases h with ⟨_,hm⟩ | ⟨_,he⟩ | ⟨_,_,hs⟩ + · exact Or.inr (Or.inr hm) + · exact Or.inr (Or.inl he) + · exact Or.inl hs + · intro hu + have hj : j (v.1,v.2.1)) '' D.graph.support := by + ext ⟨i,j⟩ + change D.tile (i,j) ≠ .vacant ↔ ∃ v ∈ D.graph.support, (v.1,v.2.1)=(i,j) + rw [Tile.nonvacant_iff_used] + constructor + · rintro (hu | hd) + · exact ⟨up i j,(D.up_support_iff i j).mpr hu,rfl⟩ + · exact ⟨down i j,(D.down_support_iff i j).mpr hd,rfl⟩ + · rintro ⟨⟨a,k,b⟩,hv,he⟩ + have hi : a=i := congrArg Prod.fst he + have hj : k=j := congrArg Prod.snd he + subst a k + cases b + · exact Or.inr ((D.down_support_iff i j).mp hv) + · exact Or.inl ((D.up_support_iff i j).mp hv) + + + +lemma support_ncard_eq (D : HoneycombAssignment N) (F : Finset Cell) + (hF : ∀ q, D.tile q ≠ .vacant ↔ q∈F) : + D.graph.support.ncard = + ∑ q∈F, ((if (D.tile q).upperUsed then 1 else 0) + + (if (D.tile q).lowerUsed then 1 else 0) : ℕ) := by + let U := F.filter (fun q => (D.tile q).upperUsed) + let L := F.filter (fun q => (D.tile q).lowerUsed) + let fu : Cell → Triangle := fun q => up q.1 q.2 + let fl : Cell → Triangle := fun q => down q.1 q.2 + have hu : Function.Injective fu := by + intro q r h + have hh := congrArg (fun v : Triangle => (v.1,v.2.1)) h + exact hh + have hl : Function.Injective fl := by + intro q r h + have hh := congrArg (fun v : Triangle => (v.1,v.2.1)) h + exact hh + have hd : Disjoint (U.image fu) (L.image fl) := by + apply Finset.disjoint_left.mpr + intro v hv hw + obtain ⟨q,_,rfl⟩ := Finset.mem_image.mp hv + obtain ⟨r,_,hr⟩ := Finset.mem_image.mp hw + have hh := congrArg (fun v : Triangle => v.2.2) hr + exact Bool.false_ne_true hh + have hs : D.graph.support = ↑(U.image fu ∪ L.image fl) := by + ext ⟨i,j,b⟩ + cases b + · change down i j ∈ D.graph.support ↔ _ + rw [D.down_support_iff] + simp only [Finset.mem_coe,Finset.mem_union,Finset.mem_image,U,L, + Finset.mem_filter,fu,fl,up,down,Prod.mk.injEq,Bool.true_eq_false,and_false,exists_false, + false_or,and_true] + constructor + · intro h + exact ⟨(i,j),⟨(hF (i,j)).mp ((Tile.nonvacant_iff_used _).mpr (Or.inr h)),h⟩,rfl,rfl⟩ + · rintro ⟨⟨a,k⟩,⟨_,h⟩,hi,hj⟩ + dsimp only at hi hj + subst a k; exact h + · change up i j ∈ D.graph.support ↔ _ + rw [D.up_support_iff] + simp only [Finset.mem_coe,Finset.mem_union,Finset.mem_image,U,L, + Finset.mem_filter,fu,fl,up,down,Prod.mk.injEq,Bool.false_eq_true,and_false,exists_false, + or_false,and_true] + constructor + · intro h + exact ⟨(i,j),⟨(hF (i,j)).mp ((Tile.nonvacant_iff_used _).mpr (Or.inl h)),h⟩,rfl,rfl⟩ + · rintro ⟨⟨a,k⟩,⟨_,h⟩,hi,hj⟩ + dsimp only at hi hj + subst a k; exact h + rw [hs,Set.ncard_coe_finset,Finset.card_union_of_disjoint hd, + Finset.card_image_of_injective _ hu,Finset.card_image_of_injective _ hl,Finset.sum_add_distrib] + simp [U,L] + +end HoneycombAssignment + +namespace HoneycombConfiguration +variable {N : ℕ} {b : BoundaryPort} + +lemma tileSupport_finite (D : HoneycombConfiguration N b) (hN : 1≤N) (hb : b ≠ .bottom 0) : + D.toHoneycombAssignment.tileSupport.Finite := by + rw [HoneycombAssignment.tileSupport_eq_image] + exact ((D.toWire hN).support_finite (b.vertex_ne_source hb)).image _ + + + +def weight (D : HoneycombConfiguration N b) : ℝ := + ∏ᶠ q : Cell, (physicalWeights (2*Diagram.lambda)).tile (D.tile q) + +lemma finite_weight_support (D : HoneycombConfiguration N b) (hN : 1≤N) (hb : b ≠ .bottom 0) : + (Function.mulSupport (fun q : Cell => (physicalWeights (2*Diagram.lambda)).tile (D.tile q))).Finite := by + apply (D.tileSupport_finite hN hb).subset + intro q hq + change D.tile q ≠ .vacant + intro ht + exact hq (by simp only [ht,Weights.tile]) + + +theorem weight_eq_wire (D : HoneycombConfiguration N b) (hN : 1≤N) (hb : b ≠ .bottom 0) : + D.weight=(D.toWire hN).weight := by + let F := (D.tileSupport_finite hN hb).toFinset + have hF : ∀ q, D.tile q≠.vacant ↔ q∈F := by + intro q + exact ((D.tileSupport_finite hN hb).mem_toFinset).symm + have he := finprod_eq_prod_of_mulSupport_subset + (fun q : Cell => (physicalWeights (2*Diagram.lambda)).tile (D.tile q)) (s := F) + have hw : D.weight = ∏ q∈F, (physicalWeights (2*Diagram.lambda)).tile (D.tile q) := by + apply he + intro q hq + apply (hF q).mp + intro ht; exact hq (by simp only [ht,Weights.tile]) + rw [hw,physicalWeights_two_lambda] + change (∏ q∈F, (⟨rho^2,rho^2,rho,0,rho^2⟩ : Weights ℝ).tile (D.tile q)) = _ + have hw' (q : Cell) : + (⟨rho^2,rho^2,rho,0,rho^2⟩ : Weights ℝ).tile (D.tile q) = + rho ^ ((if (D.tile q).upperUsed then 1 else 0) + + (if (D.tile q).lowerUsed then 1 else 0) : ℕ) := + Tile.physical_weight rho (D.tile q) (D.physical q) + simp_rw [hw'] + rw [Finset.prod_pow_eq_pow_sum] + change rho ^ _ = rho ^ D.toHoneycombAssignment.graph.support.ncard + rw [D.toHoneycombAssignment.support_ncard_eq F hF] + +lemma weight_eq_path (D : HoneycombConfiguration N b) (hN : 1≤N) (hb : b ≠ .bottom 0) : + D.weight = rho ^ (D.toWire hN).path.length := by + rw [D.weight_eq_wire hN hb,(D.toWire hN).weight_eq (b.vertex_ne_source hb)] + +lemma countable (N : ℕ) (b : BoundaryPort) (hN : 1≤N) (hb : b ≠ .bottom 0) : + Countable (HoneycombConfiguration N b) := + (equivPaths N b hN hb).countable_iff.mpr inferInstance + + +theorem summable_weight_iff (N : ℕ) (b : BoundaryPort) (hN : 1≤N) (hb : b ≠ .bottom 0) : + Summable (weight (N := N) (b := b)) ↔ + Summable (WireConfiguration.weight (N := N) (finish := b.vertex N)) := by + have h := (equivWires N b hN hb).summable_iff (f := WireConfiguration.weight) + have he : WireConfiguration.weight ∘ (equivWires N b hN hb) = weight := by + funext D + exact (D.weight_eq_wire hN hb).symm + rwa [he] at h + +lemma tsum_weight (N : ℕ) (b : BoundaryPort) (hN : 1≤N) (hb : b ≠ .bottom 0) : + ∑' D : HoneycombConfiguration N b, D.weight = + ∑' D : WireConfiguration N (b.vertex N), D.weight := by + rw [show (fun D : HoneycombConfiguration N b => D.weight) = + (fun D => (D.toWire hN).weight) from funext (fun D => D.weight_eq_wire hN hb)] + exact (equivWires N b hN hb).tsum_eq WireConfiguration.weight + +theorem arch_sum (N : ℕ) (hN : 1≤N) (k : ℤ) (hk : k≠0) : + K N k = ∑' D : HoneycombConfiguration N (.bottom k), D.weight := by + rw [tsum_weight N (.bottom k) hN (by simpa using hk)] + exact WireConfiguration.arch_sum N k hk + +theorem arch_summable (N : ℕ) (hN : 1≤N) (k : ℤ) (hk : k≠0) : + Summable (archWeight N k) ↔ Summable (weight (N := N) (b := .bottom k)) := by + rw [summable_weight_iff N (.bottom k) hN (by simpa using hk)] + exact WireConfiguration.arch_summable N k hk + +theorem bridge_sum (N : ℕ) (hN : 1≤N) (k : ℤ) : + bridgeKernel N k = ∑' D : HoneycombConfiguration N (.top k), D.weight := by + rw [tsum_weight N (.top k) hN (by simp)] + exact WireConfiguration.bridge_sum N hN k + +theorem bridge_summable (N : ℕ) (hN : 1≤N) (k : ℤ) : + Summable (bridgeWeight N k) ↔ Summable (weight (N := N) (b := .top k)) := by + rw [summable_weight_iff N (.top k) hN (by simp)] + exact WireConfiguration.bridge_summable N hN k + +end HoneycombConfiguration +end +end CriticalStrip + +end OAI diff --git a/lean/OAI/Combinatorics/StripMass/HoneycombTiles.lean b/lean/OAI/Combinatorics/StripMass/HoneycombTiles.lean new file mode 100644 index 0000000000000000000000000000000000000000..e235d297e859ed7635012c2793bc437f5184ef04 --- /dev/null +++ b/lean/OAI/Combinatorics/StripMass/HoneycombTiles.lean @@ -0,0 +1,509 @@ +import Mathlib +import OAI.Combinatorics.StripMass.GraphPath + +namespace OAI + +/-! Critical honeycomb strip paths, polynomial identities and crossing mass. -/ + + +namespace CriticalStrip.Diagram +noncomputable section +open scoped BigOperators + + +def ValidTriangle (a b m : Prop) : Prop := + (¬a ∧ ¬b ∧ ¬m) ∨ (a ∧ b ∧ ¬m) ∨ (a ∧ ¬b ∧ m) ∨ (¬a ∧ b ∧ m) + +lemma ValidTriangle.not_three {a b m : Prop} (h : ValidTriangle a b m) : ¬(a ∧ b ∧ m) := by + unfold ValidTriangle at h + tauto + +lemma ValidTriangle.one_off {a b m : Prop} (h : ValidTriangle a b m) (ha : a) : + (b ∧ ¬m) ∨ (¬b ∧ m) := by + unfold ValidTriangle at h + tauto + +lemma ValidTriangle.of_not_three_not_one {a b m : Prop} + (h₃ : ¬(a ∧ b ∧ m)) (ha : a → b ∨ m) (hb : b → a ∨ m) (hm : m → a ∨ b) : + ValidTriangle a b m := by + unfold ValidTriangle + tauto + +namespace Tile + + + +def middle : Tile → Bool + | .vertical₀ | .vertical₁ | .diagonal₀ | .diagonal₁ => true + | _ => false + +def upperUsed : Tile → Bool + | .vacant | .cup => false + | _ => true + +def lowerUsed : Tile → Bool + | .vacant | .cap => false + | _ => true + +lemma physical_up (t : Tile) (h : t ≠ .verticalPair) : + ValidTriangle (t.Occupied 0) (t.Occupied 1) t.middle := by + revert t + unfold ValidTriangle + decide + +lemma physical_down (t : Tile) (h : t ≠ .verticalPair) : + ValidTriangle (t.Occupied 2) (t.Occupied 3) t.middle := by + revert t + unfold ValidTriangle + decide + +lemma upperUsed_iff (t : Tile) (h : t ≠ .verticalPair) : + t.upperUsed ↔ t.Occupied 0 ∨ t.Occupied 1 ∨ t.middle := by + revert t + decide + +lemma lowerUsed_iff (t : Tile) (h : t ≠ .verticalPair) : + t.lowerUsed ↔ t.Occupied 2 ∨ t.Occupied 3 ∨ t.middle := by + revert t + decide + +lemma physical_ext {t u : Tile} (ht : t ≠ .verticalPair) (hu : u ≠ .verticalPair) + (h : ∀ i, t.Occupied i ↔ u.Occupied i) (hm : t.middle=u.middle) : t=u := by + revert t u + decide + + + +theorem existsUnique_physical (s w e n m : Bool) + (hu : ValidTriangle s w m) (hd : ValidTriangle e n m) : + ∃! t : Tile, t ≠ .verticalPair ∧ + (t.Occupied 0 ↔ s) ∧ (t.Occupied 1 ↔ w) ∧ + (t.Occupied 2 ↔ e) ∧ (t.Occupied 3 ↔ n) ∧ t.middle=m := by + have hex : ∃ t : Tile, t ≠ .verticalPair ∧ + (t.Occupied 0 ↔ s) ∧ (t.Occupied 1 ↔ w) ∧ + (t.Occupied 2 ↔ e) ∧ (t.Occupied 3 ↔ n) ∧ t.middle=m := by + cases s <;> cases w <;> cases e <;> cases n <;> cases m <;> + simp_all only [ValidTriangle, Bool.false_eq_true, not_false_eq_true, not_true, + and_false, and_true, or_false, false_or] + all_goals first + | exact ⟨.vacant, by decide⟩ + | exact ⟨.vertical₀, by decide⟩ + | exact ⟨.vertical₁, by decide⟩ + | exact ⟨.diagonal₀, by decide⟩ + | exact ⟨.diagonal₁, by decide⟩ + | exact ⟨.cap, by decide⟩ + | exact ⟨.cup, by decide⟩ + | exact ⟨.capCup, by decide⟩ + obtain ⟨t,ht⟩ := hex + refine ⟨t,ht,?_⟩ + intro u hu + apply physical_ext hu.1 ht.1 ?_ (hu.2.2.2.2.2.trans ht.2.2.2.2.2.symm) + intro i + fin_cases i + · exact hu.2.1.trans ht.2.1.symm + · exact hu.2.2.1.trans ht.2.2.1.symm + · exact hu.2.2.2.1.trans ht.2.2.2.1.symm + · exact hu.2.2.2.2.1.trans ht.2.2.2.2.1.symm + + +lemma physical_weight (r : ℝ) (t : Tile) (h : t ≠ .verticalPair) : + (Weights.mk (r^2) (r^2) r 0 (r^2)).tile t = + r ^ ((if t.upperUsed then 1 else 0) + (if t.lowerUsed then 1 else 0) : ℕ) := by + cases t <;> simp_all [Weights.tile,upperUsed,lowerUsed] + +end Tile +end +end CriticalStrip.Diagram + + + + + +namespace CriticalStrip +noncomputable section +open scoped Classical BigOperators +open Diagram Diagram.PathGraph + +abbrev Cell := ℤ × ℕ + + + +def upDownWire (t : Cell → Tile) (v w : Triangle) : Prop := + v.2.2=true ∧ w.2.2=false ∧ + ((v.2.1=w.2.1 ∧ + ((w.1=v.1 ∧ (t (v.1,v.2.1)).middle) ∨ + (w.1+1=v.1 ∧ (t (v.1,v.2.1)).Occupied 1))) ∨ + (v.2.1=w.2.1+1 ∧ v.1=w.1 ∧ (t (v.1,v.2.1)).Occupied 0)) + +def tileGraph (N : ℕ) (t : Cell → Tile) : SimpleGraph Triangle where + Adj v w := v.2.1 ⟨h.2.1,h.1,h.2.2.symm⟩⟩ + loopless := ⟨by + intro v h + rcases h.2.2 with h | h <;> exact Bool.noConfusion (h.1.symm.trans h.2.1)⟩ + +lemma tileGraph_allowed (N : ℕ) (t : Cell → Tile) {v w : Triangle} + (h : (tileGraph N t).Adj v w) : adjacent v w ∧ v.2.1 hbound hj + +lemma tileGraph_up (N : ℕ) (t : Cell → Tile) (i : ℤ) (j : ℕ) (w : Triangle) : + (tileGraph N t).Adj (up i j) w ↔ j ⟨D.graph.symm.symm _ _,D.graph.symm.symm _ _⟩ + have hm := tileGraph_middle N D.tile i j + have he := tileGraph_west N D.tile (i+1) j + have hn := tileGraph_south N D.tile i (j+1) (by omega) + simp only [add_sub_cancel_right] at he hn + constructor + · intro h + refine ⟨h.1,?_⟩ + rcases (adjacent_down_iff i j w).mp (tileGraph_allowed N D.tile h).1 with rfl | rfl | rfl + · exact Or.inl ⟨rfl,(hm.mp (D.graph.symm.symm _ _ h)).2⟩ + · exact Or.inr (Or.inl ⟨rfl,(D.horizontal i j).mpr (he.mp (D.graph.symm.symm _ _ h)).2⟩) + · have h' := hn.mp (D.graph.symm.symm _ _ h) + exact Or.inr (Or.inr ⟨h'.1,rfl,(D.vertical i j h'.1).mpr h'.2⟩) + · rintro ⟨hj,⟨rfl,h⟩ | ⟨rfl,h⟩ | ⟨hn',rfl,h⟩⟩ + · exact D.graph.symm.symm _ _ (hm.mpr ⟨hj,h⟩) + · exact D.graph.symm.symm _ _ (he.mpr ⟨hj,(D.horizontal i j).mp h⟩) + · exact D.graph.symm.symm _ _ (hn.mpr ⟨hn',(D.vertical i j hn').mp h⟩) + +end HoneycombAssignment + +lemma atMostTwo_of_three {V : Type*} {r : V → V → Prop} {v a b c : V} + {A B C : Prop} (h₃ : ¬(A ∧ B ∧ C)) + (h : ∀ w, r v w → (w=a ∧ A) ∨ (w=b ∧ B) ∨ (w=c ∧ C)) : + ∀ {x y z}, r v x → r v y → r v z → x≠y → z=x ∨ z=y := by + intro x y z hx hy hz hxy + rcases h x hx with ⟨rfl,hx⟩ | ⟨rfl,hx⟩ | ⟨rfl,hx⟩ <;> + rcases h y hy with ⟨rfl,hy⟩ | ⟨rfl,hy⟩ | ⟨rfl,hy⟩ <;> + rcases h z hz with ⟨rfl,hz⟩ | ⟨rfl,hz⟩ | ⟨rfl,hz⟩ <;> tauto + +namespace HoneycombAssignment +variable {N : ℕ} + +lemma two (D : HoneycombAssignment N) : AtMostTwo D.graph.Adj := by + intro v x y z hx hy hz hn + rcases v with ⟨i,j,b⟩ + cases b + · have h := (Tile.physical_down (D.tile (i,j)) (D.physical (i,j))).not_three + apply atMostTwo_of_three (a := up i j) (b := up (i+1) j) (c := up i (j+1)) + (A := (D.tile (i,j)).middle) (B := (D.tile (i,j)).Occupied 2) (C := (D.tile (i,j)).Occupied 3) + (by tauto) (fun w hw => ?_) hx hy hz hn + rcases (D.down_neighbors i j w).mp hw with ⟨_,h⟩ + exact h.imp id (Or.imp id (fun h => ⟨h.2.1,h.2.2⟩)) + · have h := (Tile.physical_up (D.tile (i,j)) (D.physical (i,j))).not_three + apply atMostTwo_of_three (a := down i j) (b := down (i-1) j) (c := down i (j-1)) + (A := (D.tile (i,j)).middle) (B := (D.tile (i,j)).Occupied 1) (C := (D.tile (i,j)).Occupied 0) + (by tauto) (fun w hw => ?_) hx hy hz hn + rcases (D.up_neighbors i j w).mp hw with ⟨_,h⟩ + exact h.imp id (Or.imp id (fun h => ⟨h.2.1,h.2.2⟩)) + +lemma bottom_one (D : HoneycombAssignment N) {i : ℤ} (hb : (D.tile (i,0)).Occupied 0) : + AtMostOne D.graph.Adj (up i 0) := by + intro x y hx hy + have h := (Tile.physical_up (D.tile (i,0)) (D.physical (i,0))).one_off hb + rw [D.up_neighbors] at hx hy + simp only [lt_self_iff_false,false_and,or_false] at hx hy + rcases hx.2 with ⟨rfl,hx⟩ | ⟨rfl,hx⟩ <;> + rcases hy.2 with ⟨rfl,hy⟩ | ⟨rfl,hy⟩ <;> tauto + +lemma bottom_used (D : HoneycombAssignment N) (hN : 1≤N) {i : ℤ} + (hb : (D.tile (i,0)).Occupied 0) : ∃ w, D.graph.Adj (up i 0) w := by + have h := (Tile.physical_up (D.tile (i,0)) (D.physical (i,0))).one_off hb + rcases h with ⟨hw,hm⟩ | ⟨hw,hm⟩ + · exact ⟨down (i-1) 0,(D.up_neighbors i 0 _).mpr ⟨by omega,Or.inr (Or.inl ⟨rfl,hw⟩)⟩⟩ + · exact ⟨down i 0,(D.up_neighbors i 0 _).mpr ⟨by omega,Or.inl ⟨rfl,hm⟩⟩⟩ + +lemma top_one (D : HoneycombAssignment N) (hN : 1≤N) {i : ℤ} + (ht : (D.tile (i,N-1)).Occupied 3) : AtMostOne D.graph.Adj (down i (N-1)) := by + intro x y hx hy + have h := Tile.physical_down (D.tile (i,N-1)) (D.physical (i,N-1)) + unfold ValidTriangle at h + rw [D.down_neighbors] at hx hy + have hn : ¬(N-1+1 + rcases hy.2 with ⟨rfl,hy⟩ | ⟨rfl,hy⟩ <;> tauto + +lemma top_used (D : HoneycombAssignment N) (hN : 1≤N) {i : ℤ} + (ht : (D.tile (i,N-1)).Occupied 3) : ∃ w, D.graph.Adj (down i (N-1)) w := by + have h := Tile.physical_down (D.tile (i,N-1)) (D.physical (i,N-1)) + have h' : (D.tile (i,N-1)).middle ∨ (D.tile (i,N-1)).Occupied 2 := by + unfold ValidTriangle at h + tauto + rcases h' with hm | he + · exact ⟨up i (N-1),(D.down_neighbors i (N-1) _).mpr ⟨by omega,Or.inl ⟨rfl,hm⟩⟩⟩ + · exact ⟨up (i+1) (N-1),(D.down_neighbors i (N-1) _).mpr ⟨by omega,Or.inr (Or.inl ⟨rfl,he⟩)⟩⟩ + +end HoneycombAssignment + + + + + + +lemma validTriangle_of_neighbors {V : Type*} {r : V → V → Prop} {v a b c : V} + (h₂ : AtMostTwo r) (hab : a≠b) (hac : a≠c) (hbc : b≠c) + (he : ∀ w, r v w → w=a ∨ w=b ∨ w=c) + (ho : ∀ w, r v w → ∃ z, r v z ∧ z≠w) : + ValidTriangle (r v a) (r v b) (r v c) := by + apply ValidTriangle.of_not_three_not_one + · rintro ⟨ha,hb,hc⟩ + exact (h₂ ha hb hc hab).elim hac.symm hbc.symm + · intro ha + obtain ⟨z,hz,hza⟩ := ho a ha + rcases he z hz with rfl | rfl | rfl + · exact (hza rfl).elim + · exact Or.inl hz + · exact Or.inr hz + · intro hb + obtain ⟨z,hz,hzb⟩ := ho b hb + rcases he z hz with rfl | rfl | rfl + · exact Or.inl hz + · exact (hzb rfl).elim + · exact Or.inr hz + · intro hc + obtain ⟨z,hz,hzc⟩ := ho c hc + rcases he z hz with rfl | rfl | rfl + · exact Or.inl hz + · exact Or.inr hz + · exact (hzc rfl).elim + +lemma validTriangle_with_port {V : Type*} {r : V → V → Prop} {v a b : V} {P : Prop} + (hab : a≠b) (he : ∀ w, r v w → w=a ∨ w=b) + (h₁ : P → AtMostOne r v) (hu : P → ∃ w, r v w) + (ho : ¬P → ∀ w, r v w → ∃ z, r v z ∧ z≠w) : + ValidTriangle P (r v a) (r v b) := by + apply ValidTriangle.of_not_three_not_one + · exact fun ⟨hp,ha,hb⟩ => hab (h₁ hp ha hb) + · intro hp + obtain ⟨w,hw⟩ := hu hp + rcases he w hw with rfl | rfl + · exact Or.inl hw + · exact Or.inr hw + · intro ha + by_cases hp : P + · exact Or.inl hp + obtain ⟨w,hw,hwa⟩ := ho hp a ha + rcases he w hw with rfl | rfl + · exact (hwa rfl).elim + · exact Or.inr hw + · intro hb + by_cases hp : P + · exact Or.inl hp + obtain ⟨w,hw,hwb⟩ := ho hp b hb + rcases he w hw with rfl | rfl + · exact Or.inr hw + · exact (hwb rfl).elim + + +inductive BoundaryPort where + | bottom (index : ℤ) + | top (index : ℤ) + deriving DecidableEq + +namespace BoundaryPort + +def vertex (N : ℕ) : BoundaryPort → Triangle + | .bottom k => up k 0 + | .top k => down k (N-1) + +lemma vertex_ne_source {N : ℕ} (b : BoundaryPort) (hb : b ≠ .bottom 0) : + b.vertex N ≠ up 0 0 := by + cases b with + | bottom k => simpa [vertex,up] using hb + | top k => simp [vertex,up,down] + +lemma up_eq_iff {N j : ℕ} {i : ℤ} {b : BoundaryPort} : + up i j=b.vertex N ↔ b=.bottom i ∧ j=0 := by + cases b <;> simp [vertex,up,down,eq_comm] + +lemma down_eq_iff {N j : ℕ} {i : ℤ} {b : BoundaryPort} : + down i j=b.vertex N ↔ b=.top i ∧ j=N-1 := by + cases b <;> simp [vertex,up,down,eq_comm] + +end BoundaryPort + +namespace WireConfiguration +variable {N : ℕ} {b : BoundaryPort} + +def south (D : WireConfiguration N (b.vertex N)) (i : ℤ) (j : ℕ) : Prop := + if j=0 then i=0 ∨ b=.bottom i else D.graph.Adj (up i j) (down i (j-1)) + +def west (D : WireConfiguration N (b.vertex N)) (i : ℤ) (j : ℕ) : Prop := + D.graph.Adj (up i j) (down (i-1) j) + +def middle (D : WireConfiguration N (b.vertex N)) (i : ℤ) (j : ℕ) : Prop := + D.graph.Adj (up i j) (down i j) + +def east (D : WireConfiguration N (b.vertex N)) (i : ℤ) (j : ℕ) : Prop := + D.graph.Adj (down i j) (up (i+1) j) + +def north (D : WireConfiguration N (b.vertex N)) (i : ℤ) (j : ℕ) : Prop := + if j+1=N then b=.top i else D.graph.Adj (down i j) (up i (j+1)) + +lemma up_nonterminal (_D : WireConfiguration N (b.vertex N)) {i : ℤ} {j : ℕ} + (hj : 0 hn (Or.inl h) + simpa [up] using h + · intro he + exact hn (Or.inr (BoundaryPort.up_eq_iff.mp he).1) + · have hpos : 0 simp + +lemma permLaurent_lift {n:ℕ} (σ:Equiv.Perm (Fin n)) (f:Laurent n) : + permLaurent (topPerm σ) (liftLaurent f)=liftLaurent (permLaurent σ f) := by + have he:(permLaurent (topPerm σ)).comp (liftLaurentHom n)= + (liftLaurentHom n).comp (permLaurent σ) := by + apply AddMonoidAlgebra.ringHom_ext <;> intro e + all_goals change permLaurent (topPerm σ) (liftLaurent (monomialL _ _))=liftLaurent (permLaurent σ (monomialL _ _)) + all_goals rw [liftLaurent_monomial,permLaurent_monomial,permLaurent_monomial,liftLaurent_monomial] + all_goals congr 1; funext i; induction i using Fin.lastCases <;> simp [topPerm_symm] + exact DFunLike.congr_fun he f + +lemma permSpectral_lift {n:ℕ} (σ:Equiv.Perm (Fin n)) (f:SpectralField n) : + permSpectral (topPerm σ) (liftSpectral n f)=liftSpectral n (permSpectral σ f) := by + have he:(permSpectral (topPerm σ)).comp (liftSpectral n)= + (liftSpectral n).comp (permSpectral σ) := by + apply IsFractionRing.ringHom_ext (A:=SpectralRing n) + intro P + change permSpectral (topPerm σ) (liftSpectral n (evalLaurent P))=liftSpectral n (permSpectral σ (evalLaurent P)) + rw [liftSpectral_evalLaurent,permSpectral_evalLaurent,permSpectral_evalLaurent,liftSpectral_evalLaurent,permLaurent_lift] + exact DFunLike.congr_fun he f + +lemma localR_map_hom {K L:Type*} [CommRing K] [CommRing L] {n:ℕ} + (f:K →+* L) (a:Position n) (w:Weights K) : + (localR a w).map f=localR a (w.map f) := by + ext p q + simp only [localR,Matrix.map_apply, Matrix.sum_apply, Matrix.smul_apply,smul_eq_mul,map_sum,map_mul,Weights.map_tile] + apply Finset.sum_congr rfl + intro t _ + unfold optionMatrix + split_ifs <;> simp + +lemma permSpectral_interpolant {n:ℕ} (σ:Equiv.Perm (Fin n)) (p:Pairing (n+1)) : + permSpectral (topPerm σ) (rationalInterpolant n p)= + (if p.Occupied (Fin.last n) then torusSin (variableF (Fin.last n)) else 1)* + ((rationalNodalPolynomial n p).map (permSpectral σ)).eval₂ (liftSpectral n) (spectralA (Fin.last n)) := by + have hm:(permSpectral (topPerm σ)).comp (liftSpectral n)=(liftSpectral n).comp (permSpectral σ) := + RingHom.ext (permSpectral_lift σ) + simp only [rationalInterpolant,map_mul,Polynomial.hom_eval₂,hm,Polynomial.eval₂_map, + permSpectral_spectralA,topPerm_last] + split_ifs <;> simp + + + +theorem rationalInterpolant_covariance {n:ℕ} (r:ℕ) (hr:r+2≤n) : + rationalInterpolant n= + (localR (PartialColumn.rowPosition r hr).padTop + (torusWeights (variableF (⟨r+1,by omega⟩:Fin n).castSucc / + variableF (⟨r,by omega⟩:Fin n).castSucc))).mulVec + (fun p =>permSpectral (topPerm (Equiv.swap (⟨r,by omega⟩:Fin n) ⟨r+1,by omega⟩)) (rationalInterpolant n p)) := by + let σ:=Equiv.swap (⟨r,by omega⟩:Fin n) ⟨r+1,by omega⟩ + let a:=PartialColumn.rowPosition r hr + let w:=torusWeights (variableF (⟨r+1,by omega⟩:Fin n)/variableF (⟨r,by omega⟩:Fin n)) + have hw:w.map (liftSpectral n)=torusWeights (variableF (⟨r+1,by omega⟩:Fin n).castSucc/variableF (⟨r,by omega⟩:Fin n).castSucc) := by + simp only [w,torusWeights,Weights.map,map_div₀,map_mul,map_pow,liftSpectral_const,liftSpectral_variable, + liftSpectral_torusSin,torusL,map_mul,map_pow,liftSpectral_const, + liftSpectral_torusSin,map_div₀,liftSpectral_variable] + have hM:(localR a.padTop w).map (liftSpectral n)=localR a.padTop (w.map (liftSpectral n)):=localR_map_hom _ _ _ + funext p + have hp:=congrArg (fun P:Polynomial (SpectralField n) =>P.eval₂ (liftSpectral n) (spectralA (Fin.last n))) + (congrFun (rationalNodalPolynomial_covariance r hr) p) + simp only [nodalExchangePolynomial,Polynomial.eval₂_finsetSum,Polynomial.eval₂_mul,Polynomial.eval₂_C] at hp + simp_rw [permSpectral_interpolant] + change (if p.Occupied (Fin.last n) then torusSin (variableF (Fin.last n)) else 1)* + (rationalNodalPolynomial n p).eval₂ (liftSpectral n) (spectralA (Fin.last n))=_ + rw [hp,Finset.mul_sum] + simp only [Matrix.mulVec,dotProduct] + apply Finset.sum_congr rfl + intro q _ + have he:liftSpectral n (localR a.padTop w p q)=localR a.padTop (w.map (liftSpectral n)) p q := congrFun (congrFun hM p) q + change _ * (liftSpectral n (localR a.padTop w p q)*_)=_ + rw [he,hw] + by_cases ho:p.Occupied (Fin.last n) ↔ q.Occupied (Fin.last n) + · simp only [ho]; ring + · have hh:=localR_padTop_zero_last a (w.map (liftSpectral n)) q p ho + rw [hw] at hh + rw [hh,zero_mul,mul_zero,zero_mul] + +end + + + + + +noncomputable section +open Finset + + + +theorem pfaffian_eq_zero_of_equal_rows {K : Type*} [Field K] [CharZero K] {n : ℕ} + (M : Matrix (Fin n) (Fin n) K) (hM : ∀ i j, M j i = -M i j) + (a b : Fin n) (hab : a ≠ b) (hrows : ∀ j, M a j = M b j) : pfaffian M = 0 := by + have hr (i j : Fin n) : M (Equiv.swap a b i) j = M i j := by + by_cases hi : i = a + · subst i; simpa using (hrows j).symm + by_cases hi' : i = b + · subst i; simpa using hrows j + rw [Equiv.swap_apply_of_ne_of_ne hi hi'] + have hc (i j : Fin n) : M i (Equiv.swap a b j) = M i j := by + rw [hM, hr, hM, neg_neg] + have hm : (fun i j => M (Equiv.swap a b i) (Equiv.swap a b j)) = M := by + funext i j + rw [hr, hc] + have h := pfaffian_reindex M (Equiv.swap a b) + rw [hm, Equiv.Perm.sign_swap hab] at h + simp only [Units.val_neg, Units.val_one, Int.cast_neg, Int.cast_one, neg_one_mul] at h + have hz : (2:K)*pfaffian M = 0 := by linear_combination h + exact (mul_eq_zero.mp hz).resolve_left (by norm_num) + + + +def replaceFirst {K : Type*} [CommRing K] {n : ℕ} + (M : Matrix (Fin (n+1)) (Fin (n+1)) K) (v : Fin (n+1) → K) : + Matrix (Fin (n+1)) (Fin (n+1)) K := fun i j => + if i = 0 then v j else if j = 0 then -v i else M i j + +@[simp] theorem replaceFirst_row {K : Type*} [CommRing K] {n : ℕ} + (M : Matrix (Fin (n+1)) (Fin (n+1)) K) (v : Fin (n+1) → K) (j : Fin (n+1)) : + replaceFirst M v 0 j = v j := by simp [replaceFirst] + +@[simp] theorem replaceFirst_rest {K : Type*} [CommRing K] {n : ℕ} + (M : Matrix (Fin (n+1)) (Fin (n+1)) K) (v : Fin (n+1) → K) (i j : Fin n) : + replaceFirst M v i.succ j.succ = M i.succ j.succ := by + simp [replaceFirst, Fin.succ_ne_zero] + +theorem replaceFirst_skew {K : Type*} [CommRing K] {n : ℕ} + (M : Matrix (Fin (n+1)) (Fin (n+1)) K) (hM : ∀ i j, M j i = -M i j) + (v : Fin (n+1) → K) (hv : v 0 = 0) (i j : Fin (n+1)) : + replaceFirst M v j i = -replaceFirst M v i j := by + by_cases hi : i = 0 <;> by_cases hj : j = 0 <;> + simp only [replaceFirst, hi, hj, ite_true, ite_false] + all_goals first | exact hM i j | simp only [hv, neg_zero, neg_neg] + +theorem pfaffian_replaceFirst_add {K : Type*} [Field K] {m : ℕ} + (M : Matrix (Fin (2*(m+1))) (Fin (2*(m+1))) K) (hM : ∀ i j, M j i = -M i j) + (v w : Fin (2*(m+1)) → K) (hv : v 0 = 0) (hw : w 0 = 0) : + pfaffian (replaceFirst M (v+w)) = pfaffian (replaceFirst M v) + + pfaffian (replaceFirst M w) := by + apply pfaffian_firstRow_add + · exact replaceFirst_skew M hM _ (by simp [hv,hw]) + · exact replaceFirst_skew M hM v hv + · exact replaceFirst_skew M hM w hw + · intro j; simp + · intro i j; simp only [replaceFirst_rest] + · intro i j; simp only [replaceFirst_rest] + +theorem pfaffian_replaceFirst_smul {K : Type*} [Field K] {m : ℕ} + (M : Matrix (Fin (2*(m+1))) (Fin (2*(m+1))) K) (hM : ∀ i j, M j i = -M i j) + (v : Fin (2*(m+1)) → K) (hv : v 0 = 0) (t : K) : + pfaffian (replaceFirst M (t • v)) = t * pfaffian (replaceFirst M v) := by + rw [pfaffian_eq_block (m := m+1) (replaceFirst M (t • v)), + pfaffian_eq_block (m := m+1) (replaceFirst M v), + blockSummand_sum_fixedZero _ (replaceFirst_skew M hM _ (by simp [hv])), + blockSummand_sum_fixedZero _ (replaceFirst_skew M hM v hv)] + simp only [blockSummand_fixZero, replaceFirst_row, replaceFirst_rest, Pi.smul_apply, + smul_eq_mul] + simp only [mul_left_comm _ t, mul_assoc, ← Finset.mul_sum] + +theorem skew_diagonal_zero {K : Type*} [Field K] [CharZero K] {n : ℕ} + (M : Matrix (Fin n) (Fin n) K) (hM : ∀ i j, M j i = -M i j) (i : Fin n) : + M i i = 0 := by + have h := hM i i + have hz : (2:K)*M i i = 0 := by linear_combination h + exact (mul_eq_zero.mp hz).resolve_left (by norm_num) + + + +theorem pfaffian_replaceFirst_otherRow {K : Type*} [Field K] [CharZero K] {m : ℕ} + (M : Matrix (Fin (2*(m+1))) (Fin (2*(m+1))) K) (hM : ∀ i j, M j i = -M i j) + (r : Fin (2*(m+1))) (hr : r ≠ 0) : + pfaffian (replaceFirst M (fun j => if j = 0 then 0 else M r j)) = 0 := by + apply pfaffian_eq_zero_of_equal_rows _ (replaceFirst_skew M hM _ (by simp)) 0 r hr.symm + intro j + by_cases hj : j = 0 + · subst j + simp [replaceFirst, hr, skew_diagonal_zero M hM r] + · simp [replaceFirst, hr, hj] + + + +theorem pfaffian_firstRow_add_other {K : Type*} [Field K] [CharZero K] {m : ℕ} + (M : Matrix (Fin (2*(m+1))) (Fin (2*(m+1))) K) (hM : ∀ i j, M j i = -M i j) + (r : Fin (2*(m+1))) (hr : r ≠ 0) (t : K) : + pfaffian (replaceFirst M (fun j => if j = 0 then 0 else M 0 j + t * M r j)) = + pfaffian M := by + let v : Fin (2*(m+1)) → K := fun j => M 0 j + let w : Fin (2*(m+1)) → K := fun j => if j = 0 then 0 else M r j + have hv : v 0 = 0 := skew_diagonal_zero M hM 0 + have hw : w 0 = 0 := by simp [w] + have he : (fun j => if j = 0 then 0 else M 0 j + t * M r j) = v + t • w := by + funext j + by_cases hj : j = 0 + · subst j; simp [v,w,skew_diagonal_zero M hM 0] + · simp [v,w,hj] + apply Eq.trans (congrArg (fun x => pfaffian (replaceFirst M x)) he) + have hw0 : pfaffian (replaceFirst M w) = 0 := + pfaffian_replaceFirst_otherRow M hM r hr + rw [pfaffian_replaceFirst_add M hM v _ hv (by simp [hw]), + pfaffian_replaceFirst_smul M hM w hw t, hw0, + mul_zero, add_zero] + congr 1 + funext i j + by_cases hi : i = 0 + · subst i; simp [v] + by_cases hj : j = 0 + · subst j; simp only [replaceFirst,hi,ite_false,ite_true,v] + exact (hM 0 i).symm + · simp [replaceFirst,hi,hj] + + + + + + + + +def frontBorder {R : Type*} [Neg R] [Zero R] {n : ℕ} + (M : Matrix (Fin n) (Fin n) R) (v : R) : Matrix (Fin (n+1)) (Fin (n+1)) R := + fun i j => Fin.cases (Fin.cases 0 (fun _ => v) j) + (fun i => Fin.cases (-v) (M i) j) i + +def backBorder {R : Type*} [Neg R] [Zero R] [One R] {n : ℕ} + (M : Matrix (Fin n) (Fin n) R) : Matrix (Fin (n+1)) (Fin (n+1)) R := + fun i j => Fin.lastCases (Fin.lastCases 0 (fun _ => -1) j) + (fun i => Fin.lastCases 1 (M i) j) i + +@[simp] theorem frontBorder_zero_zero {R : Type*} [Neg R] [Zero R] {n : ℕ} + (M : Matrix (Fin n) (Fin n) R) (v : R) : frontBorder M v 0 0 = 0 := rfl +@[simp] theorem frontBorder_zero_succ {R : Type*} [Neg R] [Zero R] {n : ℕ} + (M : Matrix (Fin n) (Fin n) R) (v : R) (j : Fin n) : frontBorder M v 0 j.succ = v := rfl +@[simp] theorem frontBorder_succ_zero {R : Type*} [Neg R] [Zero R] {n : ℕ} + (M : Matrix (Fin n) (Fin n) R) (v : R) (i : Fin n) : frontBorder M v i.succ 0 = -v := rfl +@[simp] theorem frontBorder_succ_succ {R : Type*} [Neg R] [Zero R] {n : ℕ} + (M : Matrix (Fin n) (Fin n) R) (v : R) (i j : Fin n) : + frontBorder M v i.succ j.succ = M i j := rfl +@[simp] theorem backBorder_last_last {R : Type*} [Neg R] [Zero R] [One R] {n : ℕ} + (M : Matrix (Fin n) (Fin n) R) : backBorder M (Fin.last n) (Fin.last n) = 0 := by + simp [backBorder] +@[simp] theorem backBorder_cast_last {R : Type*} [Neg R] [Zero R] [One R] {n : ℕ} + (M : Matrix (Fin n) (Fin n) R) (i : Fin n) : backBorder M i.castSucc (Fin.last n) = 1 := by + simp [backBorder] +@[simp] theorem backBorder_last_cast {R : Type*} [Neg R] [Zero R] [One R] {n : ℕ} + (M : Matrix (Fin n) (Fin n) R) (j : Fin n) : backBorder M (Fin.last n) j.castSucc = -1 := by + simp [backBorder] +@[simp] theorem backBorder_cast_cast {R : Type*} [Neg R] [Zero R] [One R] {n : ℕ} + (M : Matrix (Fin n) (Fin n) R) (i j : Fin n) : backBorder M i.castSucc j.castSucc = M i j := by + simp [backBorder] + +theorem frontBorder_skew {R : Type*} [AddGroup R] {n : ℕ} + (M : Matrix (Fin n) (Fin n) R) (v : R) (hM : ∀ i j, M j i = -M i j) : + ∀ i j, frontBorder M v j i = -frontBorder M v i j := by + intro i j + induction i using Fin.cases <;> induction j using Fin.cases <;> + simp only [frontBorder_zero_zero,frontBorder_zero_succ,frontBorder_succ_zero, + frontBorder_succ_succ,neg_zero,neg_neg] + exact hM _ _ + +theorem backBorder_skew {R : Type*} [AddGroupWithOne R] {n : ℕ} + (M : Matrix (Fin n) (Fin n) R) (hM : ∀ i j, M j i = -M i j) : + ∀ i j, backBorder M j i = -backBorder M i j := by + intro i j + induction i using Fin.lastCases <;> induction j using Fin.lastCases <;> + simp only [backBorder_last_last,backBorder_last_cast,backBorder_cast_last, + backBorder_cast_cast,neg_zero,neg_neg] + exact hM _ _ + +@[simp] theorem rotateInv_zero (n : ℕ) : (finRotate (n+1)).symm 0 = Fin.last n := by + apply (finRotate (n+1)).injective + rw [Equiv.apply_symm_apply, finRotate_last] + +@[simp] theorem rotateInv_succ {n : ℕ} (i : Fin n) : + (finRotate (n+1)).symm i.succ = i.castSucc := by + apply (finRotate (n+1)).injective + rw [Equiv.apply_symm_apply] + exact (finRotate_of_lt i.isLt).symm + +theorem backBorder_rotate {R : Type*} [AddGroupWithOne R] {n : ℕ} + (M : Matrix (Fin n) (Fin n) R) : + (fun i j => backBorder M ((finRotate (n+1)).symm i) ((finRotate (n+1)).symm j)) = + frontBorder M (-1) := by + funext i j + induction i using Fin.cases <;> induction j using Fin.cases <;> + simp only [rotateInv_zero,rotateInv_succ,backBorder_last_last,backBorder_cast_last, + backBorder_last_cast,backBorder_cast_cast,frontBorder_zero_zero,frontBorder_zero_succ, + frontBorder_succ_zero,frontBorder_succ_succ,neg_neg] + +theorem pfaffian_frontBorder_scale {K : Type*} [Field K] {m : ℕ} + (M : Matrix (Fin (2*m+1)) (Fin (2*m+1)) K) (hM : ∀ i j, M j i = -M i j) (v t : K) : + pfaffian (frontBorder M (t*v)) = t * pfaffian (frontBorder M v) := by + let A := frontBorder M v + have hA := frontBorder_skew M v hM + have he : replaceFirst A (t • (fun j => A 0 j)) = frontBorder M (t*v) := by + funext i j + induction i using Fin.cases <;> induction j using Fin.cases <;> + simp [replaceFirst,A] + have he' : replaceFirst A (fun j => A 0 j) = A := by + funext i j + induction i using Fin.cases <;> induction j using Fin.cases <;> simp [replaceFirst,A] + have h := pfaffian_replaceFirst_smul A hA (fun j => A 0 j) (by simp [A]) t + calc + _ = pfaffian (replaceFirst A (t • (fun j => A 0 j))) := congrArg pfaffian he.symm + _ = _ := h + _ = _ := congrArg (fun X => t * pfaffian X) he' + + + +theorem pfaffian_front_back {K : Type*} [Field K] {m : ℕ} + (M : Matrix (Fin (2*m+1)) (Fin (2*m+1)) K) (hM : ∀ i j, M j i = -M i j) : + pfaffian (frontBorder M 1) = pfaffian (backBorder M) := by + have h := pfaffian_reindex (backBorder M) (finRotate (2*m+1+1)).symm + rw [backBorder_rotate] at h + have hs : Equiv.Perm.sign (finRotate (2*m+1+1)).symm = -1 := by + change Equiv.Perm.sign ((finRotate (2*m+1+1))⁻¹) = -1 + rw [Equiv.Perm.sign_inv,sign_finRotate] + simp [pow_add,pow_mul] + rw [hs] at h + simp only [Units.val_neg,Units.val_one,Int.cast_neg,Int.cast_one,neg_one_mul] at h + have hv := pfaffian_frontBorder_scale M hM (1:K) (-1) + simp only [neg_one_mul] at hv + rw [hv] at h + exact neg_injective h + + + +def tailRotateInv (n : ℕ) : Equiv.Perm (Fin (n+2)) := + Equiv.Perm.decomposeFin.symm (0,(finRotate (n+1)).symm) + +@[simp] theorem tailRotateInv_zero (n : ℕ) : tailRotateInv n 0 = 0 := by + simp [tailRotateInv] +@[simp] theorem tailRotateInv_one (n : ℕ) : tailRotateInv n 1 = (Fin.last n).succ := by + simp only [tailRotateInv,Equiv.Perm.decomposeFin_symm_apply_one,Equiv.swap_self, + Equiv.refl_apply,rotateInv_zero] +@[simp] theorem tailRotateInv_succ_succ {n : ℕ} (i : Fin n) : + tailRotateInv n i.succ.succ = i.castSucc.succ := by + simp only [tailRotateInv,Equiv.Perm.decomposeFin_symm_apply_succ,Equiv.swap_self, + Equiv.refl_apply,rotateInv_succ] + +theorem sign_tailRotateInv (n : ℕ) : Equiv.Perm.sign (tailRotateInv n) = (-1)^n := by + rw [tailRotateInv,Equiv.Perm.decomposeFin.symm_sign,ite_eq_left rfl,one_mul] + change Equiv.Perm.sign ((finRotate (n+1))⁻¹) = _ + rw [Equiv.Perm.sign_inv,sign_finRotate,Nat.add_sub_cancel] + + + +theorem pfaffian_doubleBorder {K : Type*} [Field K] [CharZero K] {m : ℕ} + (M : Matrix (Fin (2*m)) (Fin (2*m)) K) (hM : ∀ i j, M j i = -M i j) : + pfaffian (frontBorder (backBorder M) 1) = pfaffian M := by + let A := frontBorder (backBorder M) 1 + let r : Fin (2*m+2) := (Fin.last (2*m)).succ + let v := fun j => if j = 0 then 0 else A 0 j + A r j + let B := replaceFirst A v + let σ := tailRotateInv (2*m) + let T := fun i j => B (σ i) (σ j) + have hA : ∀ i j, A j i = -A i j := frontBorder_skew _ _ (backBorder_skew M hM) + have hv : v 0 = 0 := by simp [v] + have hB : ∀ i j, B j i = -B i j := replaceFirst_skew A hA v hv + have hT : ∀ i j, T j i = -T i j := fun i j => hB (σ i) (σ j) + have hzero : ∀ j, j ≠ 1 → T 0 j = 0 := by + intro j hj + induction j using Fin.cases with + | zero => simp only [T,σ,tailRotateInv_zero,B,replaceFirst_row,hv] + | succ j => + induction j using Fin.cases with + | zero => exact (hj rfl).elim + | succ j => + simp only [T,σ,tailRotateInv_zero,tailRotateInv_succ_succ,B,replaceFirst_row,v, + Fin.succ_ne_zero,ite_false,A,frontBorder_zero_succ,r,frontBorder_succ_succ, + backBorder_last_cast,add_neg_cancel] + have h01 : T 0 1 = 1 := by + simp only [T,σ,tailRotateInv_zero,tailRotateInv_one,B,replaceFirst_row,v, + Fin.succ_ne_zero,ite_false,A,frontBorder_zero_succ,r,frontBorder_succ_succ, + backBorder_last_last,add_zero] + have htail : (fun i j : Fin (2*m) => T i.succ.succ j.succ.succ) = M := by + funext i j + simp only [T,σ,tailRotateInv_succ_succ,B,replaceFirst_rest,A, + frontBorder_succ_succ,backBorder_cast_cast] + have hep : pfaffian T = pfaffian M := by + have h := pfaffian_isolated T hT hzero + apply Eq.trans h + apply Eq.trans (congrArg (fun z => z * pfaffian (fun i j : Fin (2*m) => + T i.succ.succ j.succ.succ)) h01) + rw [one_mul] + exact congrArg pfaffian htail + have hσ : Equiv.Perm.sign σ = 1 := by simp [σ,sign_tailRotateInv,pow_mul] + have htp : pfaffian T = pfaffian B := by + have h := pfaffian_reindex B σ + change pfaffian T = _ at h + simpa only [hσ,Units.val_one,Int.cast_one,one_mul] using h + have hbp : pfaffian B = pfaffian A := by + apply Eq.trans ?_ (pfaffian_firstRow_add_other A hA r (Fin.succ_ne_zero _) 1) + congr 1 + funext i j + simp only [B,v,one_mul,replaceFirst] + exact hbp.symm.trans (htp.symm.trans hep) + + + + + + + +theorem back_front_row {K : Type*} [Field K] {n : ℕ} + (M : Matrix (Fin n) (Fin n) K) (t : K) (j : Fin (n+1)) : + backBorder (frontBorder M t) 0 j.succ = Fin.lastCases 1 (fun _ => t) j := by + change backBorder (frontBorder M t) (0 : Fin (n+1)).castSucc j.succ = _ + induction j using Fin.lastCases with + | last => rw [Fin.succ_last,backBorder_cast_last]; simp only [Fin.lastCases_last] + | cast j => rw [Fin.succ_castSucc,backBorder_cast_cast]; simp only [frontBorder_zero_succ,Fin.lastCases_castSucc] + +theorem back_front_tail {K : Type*} [Field K] {n : ℕ} + (M : Matrix (Fin n) (Fin n) K) (t : K) (i j : Fin (n+1)) : + backBorder (frontBorder M t) i.succ j.succ = backBorder M i j := by + induction i using Fin.lastCases <;> induction j using Fin.lastCases <;> + simp only [Fin.succ_last,Fin.succ_castSucc,backBorder_last_last,backBorder_last_cast, + backBorder_cast_last,backBorder_cast_cast,frontBorder_succ_succ] + +theorem back_front_eq_rowAdd {K : Type*} [Field K] {n : ℕ} + (M : Matrix (Fin n) (Fin n) K) (hM : ∀ i j, M j i = -M i j) (t : K) : + backBorder (frontBorder M t) = + replaceFirst (frontBorder (backBorder M) 1) + (fun j => if j = 0 then 0 else frontBorder (backBorder M) 1 0 j + + (1-t)*frontBorder (backBorder M) 1 (Fin.last n).succ j) := by + have hsk := backBorder_skew _ (frontBorder_skew M t hM) + funext i j + induction i using Fin.cases with + | zero => + induction j using Fin.cases with + | zero => + change backBorder (frontBorder M t) (0 : Fin (n+1)).castSucc (0 : Fin (n+1)).castSucc = _ + rw [backBorder_cast_cast, frontBorder_zero_zero] + simp only [replaceFirst, ite_true] + | succ j => + rw [back_front_row] + induction j using Fin.lastCases <;> + simp only [replaceFirst,Fin.succ_ne_zero,ite_true,ite_false, + frontBorder_zero_succ,frontBorder_succ_succ,backBorder_last_last, + backBorder_last_cast,Fin.lastCases_last,Fin.lastCases_castSucc] <;> ring + | succ i => + induction j using Fin.cases with + | zero => + rw [hsk 0 i.succ,back_front_row] + induction i using Fin.lastCases <;> + simp only [replaceFirst,Fin.succ_ne_zero,ite_true,ite_false, + frontBorder_zero_succ,frontBorder_succ_succ,backBorder_last_last, + backBorder_last_cast,Fin.lastCases_last,Fin.lastCases_castSucc] <;> ring + | succ j => rw [back_front_tail]; simp [replaceFirst] + + + +theorem pfaffian_back_front {K : Type*} [Field K] [CharZero K] {m : ℕ} + (M : Matrix (Fin (2*m)) (Fin (2*m)) K) (hM : ∀ i j, M j i = -M i j) (t : K) : + pfaffian (backBorder (frontBorder M t)) = pfaffian M := by + apply Eq.trans (congrArg pfaffian (back_front_eq_rowAdd M hM t)) + apply Eq.trans (pfaffian_firstRow_add_other _ + (frontBorder_skew _ _ (backBorder_skew M hM)) (Fin.last (2*m)).succ (Fin.succ_ne_zero _) (1-t)) + exact pfaffian_doubleBorder M hM + +def plainKernel {K : Type*} [Field K] {n : ℕ} (dd rr : K) (a : Fin n → K) : + Matrix (Fin n) (Fin n) K := + fun i j => (a i-a j)*(a i+a j+rr)/discriminant dd (a i) (a j) + +theorem plainKernel_skew {K : Type*} [Field K] {n : ℕ} (dd rr : K) (a : Fin n → K) : + ∀ i j, plainKernel dd rr a j i = -plainKernel dd rr a i j := by + intro i j + unfold plainKernel discriminant + have hD : a j^2+a i^2+2*dd*a j*a i-dd^2 = a i^2+a j^2+2*dd*a i*a j-dd^2 := by ring + rw [hD,← neg_div] + congr 1 + ring + +theorem pfaffian_augmented_even {K : Type*} [Field K] (m : ℕ) (dd rr : K) (a : Fin (2*m) → K) : + pfaffian (augmentedKernel dd rr a) = pfaffian (plainKernel dd rr a) := by + have hs : 2*m+(2*m)%2 = 2*m := by omega + apply Eq.trans (pfaffian_cast hs (augmentedKernel dd rr a)).symm + congr 1 + funext i j + simp only [augmentedKernel,Fin.val_cast,i.isLt,j.isLt,dite_eq_left] + rfl + +theorem pfaffian_augmented_odd {K : Type*} [Field K] (m : ℕ) (dd rr : K) (a : Fin (2*m+1) → K) : + pfaffian (augmentedKernel dd rr a) = pfaffian (backBorder (plainKernel dd rr a)) := by + have hs : (2*m+1)+(2*m+1)%2 = (2*m+1)+1 := by omega + apply Eq.trans (pfaffian_cast hs (augmentedKernel dd rr a)).symm + congr 1 + funext i j + induction i using Fin.lastCases <;> induction j using Fin.lastCases <;> + simp only [augmentedKernel,Fin.val_cast,Fin.val_last,Fin.val_castSucc, + lt_self_iff_false,dite_false,ite_true,ite_false,Fin.isLt,dite_eq_left,backBorder_last_last, + backBorder_last_cast,backBorder_cast_last,backBorder_cast_cast,plainKernel] + +end +end CriticalStrip.Diagram + +end OAI diff --git a/lean/OAI/Combinatorics/StripMass/InverseIntegrability.lean b/lean/OAI/Combinatorics/StripMass/InverseIntegrability.lean new file mode 100644 index 0000000000000000000000000000000000000000..d58f8e322eb3bd98db79a757ec9e9c42a3e9476d --- /dev/null +++ b/lean/OAI/Combinatorics/StripMass/InverseIntegrability.lean @@ -0,0 +1,432 @@ +import Mathlib +import OAI.Combinatorics.StripMass.LaguerreScaling + +namespace OAI + +/-! Critical honeycomb strip paths, polynomial identities and crossing mass. -/ + + +namespace CriticalStrip +noncomputable section +open scoped BigOperators Pointwise +open Set MeasureTheory Filter +lemma integrableOn_scaledLaguerre_inverse_coordinate {N : ℕ} {a p β : ℝ} + (ha : 0 < a) (i : Fin N) (hp : p < a + i.val) (hb : 1 ≤ β) : + IntegrableOn (fun r => (r i) ^ (-p) * scaledLaguerreDensity N a β r) (laguerreDomain N) := by + apply (integrableOn_laguerre_inverse_coordinate ha i hp).mono' + (((measurable_pi_apply i).pow_const _).mul + (measurable_scaledLaguerreDensity N a β)).aestronglyMeasurable + filter_upwards [ae_restrict_mem (isOpen_laguerreDomain N).measurableSet] with r hr + simp only [Pi.mul_apply] + rw [Real.norm_eq_abs, abs_of_nonneg (mul_nonneg (Real.rpow_pos_of_pos (hr.2 i) _).le + (scaledLaguerreDensity_pos a β hr).le)] + exact mul_le_mul_of_nonneg_left (scaledLaguerreDensity_le a hb hr) + (Real.rpow_pos_of_pos (hr.2 i) _).le + +abbrev mobiusInverseQuarter {N : ℕ} (i : Fin N) (z : Fin N → ℝ) : ℝ := + (mobiusCoordinate (z i)) ^ (-(1/4:ℝ)) + +lemma continuousOn_mobiusInverseQuarter {N : ℕ} (i : Fin N) : + ContinuousOn (mobiusInverseQuarter i) (coordinateBox (Fin N) (Ioo 0 1)) := by + exact (continuousOn_mobiusCoordinate.comp (continuous_apply i).continuousOn + (fun z hz => (hz i).1)).rpow_const (fun z hz => Or.inl (mobiusCoordinate_mem (hz i)).1.ne') + +lemma antitoneOn_mobiusInverseQuarter {N : ℕ} (i : Fin N) : + AntitoneOn (mobiusInverseQuarter i) (coordinateBox (Fin N) (Ioo 0 1)) := by + intro x hx y hy hxy + exact Real.rpow_le_rpow_of_nonpos (mobiusCoordinate_mem (hx i)).1 + (mobiusCoordinate_strictMonoOn.monotoneOn (hx i).1 (hy i).1 (hxy i)) (by norm_num) + +lemma integrableOn_scaledLaguerre_mobiusInverseQuarter {N : ℕ} {β : ℝ} (i : Fin N) (hb : 1 ≤ β) : + IntegrableOn (fun z => mobiusInverseQuarter i z * scaledLaguerreDensity N 1 β z) + (orderedDomain N) := by + have hs : orderedDomain N ⊆ laguerreDomain N := fun _ hz => ⟨hz.1, fun i => (hz.2 i).1⟩ + have hm : Measurable (fun z => mobiusInverseQuarter i z * scaledLaguerreDensity N 1 β z) := by + unfold mobiusInverseQuarter mobiusCoordinate + apply Measurable.mul + · fun_prop + · exact measurable_scaledLaguerreDensity N 1 β + apply ((integrableOn_scaledLaguerre_inverse_coordinate (by norm_num : (0:ℝ)<1) + i (by linarith [Nat.cast_nonneg (α:=ℝ) i.val] : (1/4:ℝ) < 1 + i.val) hb).mono_set hs).mono' hm.aestronglyMeasurable + filter_upwards [ae_restrict_mem (isOpen_orderedDomain N).measurableSet] with z hz + rw [Real.norm_eq_abs, abs_of_nonneg (mul_nonneg + (Real.rpow_pos_of_pos (mobiusCoordinate_mem (hz.2 i)).1 _).le + (scaledLaguerreDensity_pos 1 β (hs hz)).le)] + exact mul_le_mul_of_nonneg_right (mobius_inverseQuarter_bounds (hz.2 i)).2 + (scaledLaguerreDensity_pos 1 β (hs hz)).le + +lemma positiveLaw_mobius_expectation {N : ℕ} (β : ℝ) (g : (Fin N → ℝ) → ℝ) : + (∫ y, g y ∂positiveLaw N) = + (∫ z in orderedDomain N, scaledLaguerreDensity N 1 β z * + (g (mobiusMap N z) * lowerLikelihood N β z)) / + (∫ z in orderedDomain N, scaledLaguerreDensity N 1 β z * lowerLikelihood N β z) := by + rw [integral_positiveLaw] + unfold expectation + rw [integral_density_mobius_likelihood N β g, mobiusLikelihood_Normalizer N β, + mul_div_mul_left _ _ (mobiusDensityConstant_pos N).ne'] + + + +theorem positiveLaw_inverseQuarter_ge_scaled_reference {N : ℕ} (i : Fin N) {β : ℝ} + (hb : 1 ≤ β) (hb' : β ≤ (N + 1 : ℝ) / 2) : + (2 : ℝ) ^ (-(1/4:ℝ)) * + ((∫ z in orderedDomain N, (z i) ^ (-(1/4:ℝ)) * scaledLaguerreDensity N 1 β z) / + (∫ z in orderedDomain N, scaledLaguerreDensity N 1 β z)) ≤ + ∫ y, (y i) ^ (-(1/4:ℝ)) ∂positiveLaw N := by + have hS : orderedDomain N ⊆ laguerreDomain N := fun _ hz => ⟨hz.1, fun j => (hz.2 j).1⟩ + have hiB : IntegrableOn (scaledLaguerreDensity N 1 β) (orderedDomain N) := + (integrableOn_scaledLaguerreDensity (by norm_num : (0:ℝ)<1) hb).mono_set hS + have hiBF : IntegrableOn (fun z => scaledLaguerreDensity N 1 β z * mobiusInverseQuarter i z) + (orderedDomain N) := by + simpa only [mul_comm] using integrableOn_scaledLaguerre_mobiusInverseQuarter i hb + have hiBL := integrableOn_mobiusLikelihood N β + have hiBFL : IntegrableOn (fun z => scaledLaguerreDensity N 1 β z * + (mobiusInverseQuarter i z * lowerLikelihood N β z)) (orderedDomain N) := + (integrableOn_density_mobius_likelihood_iff N β (fun y => (y i) ^ (-(1/4:ℝ)))).1 + (integrableOn_inverseQuarterCoordinate_density N i) + have hiBcoord := (integrableOn_scaledLaguerre_inverse_coordinate (by norm_num : (0:ℝ)<1) + i (by linarith [Nat.cast_nonneg (α:=ℝ) i.val] : (1/4:ℝ) < 1 + i.val) hb).mono_set hS + have hcov := ordered_density_covariance_Ioo (by norm_num : (0:ℝ)<1) + (fun _ : Fin N => scaledLaguerreWeight 1 β) + (fun _ => (continuousOn_scaledLaguerreWeight 1 β).mono (fun _ hx => hx.1)) + (fun _ _ hx => (scaledLaguerreWeight_pos 1 β hx.1).le) + (fun z => -mobiusInverseQuarter i z) (fun z => -lowerLikelihood N β z) + (continuousOn_mobiusInverseQuarter i).neg (continuousOn_lowerLikelihood N β).neg + (fun _ hx _ hy hxy => neg_le_neg (antitoneOn_mobiusInverseQuarter i hx hy hxy)) + (fun _ hx _ hy hxy => neg_le_neg (lowerLikelihood_antitone N hb' hx hy hxy)) + hiB (by simpa only [orderedDomain, orderedChamber, scaledLaguerreDensity, mul_neg, Pi.neg_def] using hiBF.neg) + (by simpa only [orderedDomain, orderedChamber, scaledLaguerreDensity, mul_neg, Pi.neg_def] using hiBL.neg) + (by simpa only [orderedDomain, orderedChamber, scaledLaguerreDensity, neg_mul_neg] using hiBFL) + have hZ : 0 < ∫ z in orderedDomain N, scaledLaguerreDensity N 1 β z := + scaledLaguerre_cutoffNormalizer_pos N (by norm_num) hb (by norm_num) + have hL := mobiusLikelihood_Normalizer_pos N β + have hcomp : + (∫ z in orderedDomain N, scaledLaguerreDensity N 1 β z * mobiusInverseQuarter i z) / + (∫ z in orderedDomain N, scaledLaguerreDensity N 1 β z) ≤ + (∫ z in orderedDomain N, scaledLaguerreDensity N 1 β z * + (mobiusInverseQuarter i z * lowerLikelihood N β z)) / + (∫ z in orderedDomain N, scaledLaguerreDensity N 1 β z * lowerLikelihood N β z) := by + apply (div_le_div_iff₀ hZ hL).2 + simp only [mul_neg, neg_mul, neg_neg, integral_neg] at hcov + simpa only [orderedDomain, orderedChamber, scaledLaguerreDensity, mul_comm] using hcov + calc + _ ≤ (∫ z in orderedDomain N, scaledLaguerreDensity N 1 β z * mobiusInverseQuarter i z) / + (∫ z in orderedDomain N, scaledLaguerreDensity N 1 β z) := by + rw [← mul_div_assoc, ← integral_const_mul] + apply div_le_div_of_nonneg_right _ hZ.le + apply setIntegral_mono_on (hiBcoord.const_mul _) hiBF (isOpen_orderedDomain N).measurableSet + intro z hz + have h := mul_le_mul_of_nonneg_right (mobius_inverseQuarter_bounds (hz.2 i)).1 + (scaledLaguerreDensity_pos 1 β (hS hz)).le + simpa only [mobiusInverseQuarter, _root_.mul_assoc] using + h.trans_eq (_root_.mul_comm _ _) + _ ≤ _ := hcomp + _ = _ := (positiveLaw_mobius_expectation β (fun y => (y i) ^ (-(1/4:ℝ)))).symm + +lemma integral_scaledLaguerre_cutoff_inverse_coordinate {N : ℕ} (a p R : ℝ) (i : Fin N) + {β : ℝ} (hb : 0 < β) : + (laguerreDensityScale N a β * (β ^ p)⁻¹) * + (∫ y in orderedChamber N (Ioo 0 R), (y i) ^ (-p) * scaledLaguerreDensity N a β y) = + (β ^ N)⁻¹ * (∫ r in orderedChamber N (Ioo 0 (β * R)), (r i) ^ (-p) * laguerreDensity N a r) := by + rw [← integral_const_mul] + calc + (∫ y in orderedChamber N (Ioo 0 R), (laguerreDensityScale N a β * (β ^ p)⁻¹) * + ((y i) ^ (-p) * scaledLaguerreDensity N a β y)) = + ∫ y in orderedChamber N (Ioo 0 R), ((β • y) i) ^ (-p) * laguerreDensity N a (β • y) := by + apply setIntegral_congr_fun (measurableSet_orderedChamber_Ioo N R) + intro y hy + dsimp only + rw [laguerreDensity_scaled a hb (fun j => (hy.2 j).1)] + simp only [Pi.smul_apply, smul_eq_mul, Real.mul_rpow hb.le (hy.2 i).1.le, Real.rpow_neg hb.le] + ring + _ = _ := integral_orderedChamber_scaled R hb (fun r => (r i) ^ (-p) * laguerreDensity N a r) + +lemma scaled_reference_cutoff_inverse_coordinate {N : ℕ} (a p R : ℝ) (i : Fin N) + {β : ℝ} (hb : 0 < β) : + (∫ y in orderedChamber N (Ioo 0 R), (y i) ^ (-p) * scaledLaguerreDensity N a β y) / + (∫ y in orderedChamber N (Ioo 0 R), scaledLaguerreDensity N a β y) = + β ^ p * + ((∫ r in orderedChamber N (Ioo 0 (β * R)), (r i) ^ (-p) * laguerreDensity N a r) / + (∫ r in orderedChamber N (Ioo 0 (β * R)), laguerreDensity N a r)) := by + exact scaled_quotient (laguerreDensityScale_pos N a hb).ne' + (inv_ne_zero (pow_ne_zero _ hb.ne')) (Real.rpow_pos_of_pos hb _).ne' + (integral_scaledLaguerre_cutoff N a R hb) (integral_scaledLaguerre_cutoff_inverse_coordinate a p R i hb) + + + +theorem positiveLaw_inverseQuarter_ge_reference {N : ℕ} (i : Fin N) {β : ℝ} + (hb : 1 ≤ β) (hb' : β ≤ (N + 1 : ℝ) / 2) : + (2 : ℝ) ^ (-(1/4:ℝ)) * β ^ (1/4:ℝ) * + (∫ r, (r i) ^ (-(1/4:ℝ)) ∂laguerreLaw N 1) ≤ + ∫ y, (y i) ^ (-(1/4:ℝ)) ∂positiveLaw N := by + have hb0 : 0 < β := by linarith + have hpD : (1/4:ℝ) < laguerreDimension 1 (i.val + 1) := by + unfold laguerreDimension + have hi : 0 ≤ (i.val : ℝ) := Nat.cast_nonneg _ + push_cast + nlinarith [sq_nonneg (i.val : ℝ)] + have hcut := laguerreLaw_cutoff_inverse_coordinate (by norm_num : (0:ℝ)<1) hb0 i + (by norm_num : (0:ℝ)≤1/4) hpD + have hscale := scaled_reference_cutoff_inverse_coordinate 1 (1/4) 1 i hb0 + simp only [mul_one] at hscale + calc + _ ≤ (2 : ℝ) ^ (-(1/4:ℝ)) * (β ^ (1/4:ℝ) * + ((∫ r in cutoffEvent N β, (r i) ^ (-(1/4:ℝ)) ∂laguerreLaw N 1) / + (laguerreLaw N 1).real (cutoffEvent N β))) := by + rw [← mul_assoc] + exact mul_le_mul_of_nonneg_left hcut + (mul_nonneg (Real.rpow_pos_of_pos (by norm_num : (0:ℝ)<2) _).le + (Real.rpow_pos_of_pos hb0 _).le) + _ = (2 : ℝ) ^ (-(1/4:ℝ)) * + ((∫ z in orderedDomain N, (z i) ^ (-(1/4:ℝ)) * scaledLaguerreDensity N 1 β z) / + (∫ z in orderedDomain N, scaledLaguerreDensity N 1 β z)) := by + rw [laguerreLaw_conditioned_eq N (by norm_num), ← hscale] + rfl + _ ≤ _ := positiveLaw_inverseQuarter_ge_scaled_reference i hb hb' + +end +end CriticalStrip + + + +namespace StripPfaffian +noncomputable section +open scoped BigOperators Matrix + +lemma congruence_skew {n : ℕ} (M A : Matrix (Fin n) (Fin n) ℂ) + (hA : ∀ i j, A j i = -A i j) : + ∀ i j, (M * A * M.transpose) j i = -(M * A * M.transpose) i j := by + intro i j + simp only [Matrix.mul_apply, Matrix.transpose_apply, Finset.sum_mul] + rw [Finset.sum_comm] + simp only [← Finset.sum_neg_distrib] + apply Finset.sum_congr rfl + intro k hk + apply Finset.sum_congr rfl + intro l hl + rw [hA l k] + ring + +lemma toLin_basis {n : ℕ} (M : Matrix (Fin n) (Fin n) ℂ) (i : Fin n) : + Matrix.toLin' M (standardBasis n i) = ∑ j, M j i • standardBasis n j := by + ext k + simp [Matrix.toLin'_apply, Matrix.mulVec, dotProduct, standardBasis, + Pi.basisFun_apply, Pi.single_apply, Pi.smul_apply, smul_eq_mul] + +lemma sum_four_reverse {ι E : Type*} [Fintype ι] [AddCommMonoid E] + (F : ι → ι → ι → ι → E) : + (∑ i, ∑ j, ∑ k, ∑ l, F i j k l) = ∑ l, ∑ k, ∑ j, ∑ i, F i j k l := by + let e : (ι × ι × ι × ι) ≃ (ι × ι × ι × ι) := + ⟨(fun p => (p.2.2.2, p.2.2.1, p.2.1, p.1)), + (fun p => (p.2.2.2, p.2.2.1, p.2.1, p.1)), by intro p; rfl, by intro p; rfl⟩ + simpa only [Fintype.sum_prod_type] using + (Fintype.sum_equiv e (fun p => F p.1 p.2.1 p.2.2.1 p.2.2.2) + (fun p => F p.2.2.2 p.2.2.1 p.2.1 p.1) (fun _ => rfl)) + +lemma twoForm_congruence {n : ℕ} (M A : Matrix (Fin n) (Fin n) ℂ) + (hA : ∀ i j, A j i = -A i j) : + ExteriorAlgebra.map (Matrix.toLin' M) (twoForm A) = twoForm (M * A * M.transpose) := by + rw [twoForm_full A hA, twoForm_full _ (congruence_skew M A hA)] + simp only [map_smul, map_sum, map_mul] + congr 1 + simp only [generator, ExteriorAlgebra.map_apply_ι, + toLin_basis, Matrix.mul_apply, Matrix.transpose_apply, map_sum, map_smul, + Finset.sum_mul, Finset.mul_sum, Finset.smul_sum, Finset.sum_smul, + smul_mul_assoc, mul_smul_comm, smul_smul] + rw [sum_four_reverse] + apply Finset.sum_congr rfl + intro k hk + apply Finset.sum_congr rfl + intro l hl + apply Finset.sum_congr rfl + intro j hj + apply Finset.sum_congr rfl + intro i hi + congr 1 + ring + +lemma pfaffian_congruence {n : ℕ} (hn : Even n) (M A : Matrix (Fin n) (Fin n) ℂ) + (hA : ∀ i j, A j i = -A i j) : + pfaffian n (M * A * M.transpose) = M.det * pfaffian n A := by + have hdeg : 2 * (n / 2) = n := Nat.mul_div_cancel' (even_iff_two_dvd.mp hn) + have hhom : twoForm A ^ (n / 2) ∈ ExteriorAlgebra.exteriorPower ℂ n (Vec n) := + by simpa only [hdeg] using twoForm_pow_mem A (n / 2) + change topCoord n (twoForm _ ^ (n / 2)) / _ = + M.det * (topCoord n (twoForm A ^ (n / 2)) / _) + rw [← twoForm_congruence M A hA, ← map_pow, topCoord_map n _ _ hhom] + have hd : (Matrix.toLin' M).det = M.det := by + rw [← LinearMap.det_toMatrix (standardBasis n)] + congr 1 + ext i j + simp [standardBasis, Matrix.toLin'_apply, + Matrix.mulVec, dotProduct, Pi.single_apply] + rw [hd] + ring + +lemma pfaffian_scale_coordinates {n : ℕ} (hn : Even n) + (A : Matrix (Fin n) (Fin n) ℂ) (hA : ∀ i j, A j i = -A i j) (s : Fin n → ℂ) : + pfaffian n (fun i j => s i * A i j * s j) = (∏ i, s i) * pfaffian n A := by + have hM : Matrix.diagonal s * A * (Matrix.diagonal s).transpose = + fun i j => s i * A i j * s j := by + ext i j + simp only [Matrix.diagonal_transpose, Matrix.mul_diagonal, Matrix.diagonal_mul] + simpa only [hM, Matrix.det_diagonal] using + pfaffian_congruence hn (Matrix.diagonal s) A hA + +def schurComplement {n : ℕ} (A : Matrix (Fin n) (Fin n) ℂ) (u v : Vec n) (t : ℂ) : + Matrix (Fin n) (Fin n) ℂ := fun i j => A i j - (u i * v j - v i * u j) / t + +lemma schurComplement_skew {n : ℕ} (A : Matrix (Fin n) (Fin n) ℂ) + (hA : ∀ i j, A j i = -A i j) (u v : Vec n) (t : ℂ) : + ∀ i j, schurComplement A u v t j i = -schurComplement A u v t i j := by + intro i j + simp only [schurComplement, hA i j] + ring + +def eliminatingShear {n : ℕ} (u v : Vec n) (t : ℂ) : Matrix (Fin (n + 2)) (Fin (n + 2)) ℂ := + Fin.snoc + (Fin.snoc + (fun i : Fin n => Fin.snoc (Fin.snoc (fun j => if i = j then (1 : ℂ) else 0) (-v i / t)) (u i / t)) + (Fin.snoc (Fin.snoc (fun _ : Fin n => (0 : ℂ)) 1) 0)) + (Fin.snoc (Fin.snoc (fun _ : Fin n => (0 : ℂ)) 0) 1) + +lemma eliminatingShear_upper {n : ℕ} (u v : Vec n) (t : ℂ) : + (eliminatingShear u v t).IsUpperTriangular := by + intro i j + refine Fin.lastCases ?_ (fun i => Fin.lastCases ?_ (fun i => ?_) i) i + all_goals + refine Fin.lastCases ?_ (fun j => Fin.lastCases ?_ (fun j => ?_) j) j + all_goals + intro hji + simp only [id_eq] at hji + simp_all [eliminatingShear] + all_goals + simp only [Fin.lt_def, Fin.val_last, Fin.val_castSucc] at hji + try omega + +lemma eliminatingShear_det {n : ℕ} (u v : Vec n) (t : ℂ) : + (eliminatingShear u v t).det = 1 := by + rw [Matrix.det_of_isUpperTriangular (eliminatingShear_upper u v t), + Fin.prod_univ_castSucc, Fin.prod_univ_castSucc] + simp [eliminatingShear] + +lemma eliminatingShear_congruence {n : ℕ} (A : Matrix (Fin n) (Fin n) ℂ) + (_hA : ∀ i j, A j i = -A i j) (u v : Vec n) {t : ℂ} (ht : t ≠ 0) : + eliminatingShear u v t * border (border A u) (Fin.snoc v t) * (eliminatingShear u v t).transpose = + border (border (schurComplement A u v t) 0) (Fin.snoc 0 t) := by + ext i j + refine Fin.lastCases ?_ (fun i => Fin.lastCases ?_ (fun i => ?_) i) i + all_goals + refine Fin.lastCases ?_ (fun j => Fin.lastCases ?_ (fun j => ?_) j) j + all_goals + simp only [Matrix.mul_apply, Matrix.transpose_apply] + simp only [Fin.sum_univ_castSucc] + simp [eliminatingShear, schurComplement, ht] + all_goals field_simp [ht] + all_goals ring + +lemma pfaffian_schur_complement {n : ℕ} (hn : Even n) + (A : Matrix (Fin n) (Fin n) ℂ) (hA : ∀ i j, A j i = -A i j) + (u v : Vec n) {t : ℂ} (ht : t ≠ 0) : + pfaffian (n + 2) (border (border A u) (Fin.snoc v t)) = + t * pfaffian n (schurComplement A u v t) := by + have h := pfaffian_congruence (hn.add (by decide : Even 2)) + (eliminatingShear u v t) (border (border A u) (Fin.snoc v t)) + (border_skew _ (border_skew A hA u) _) + rw [eliminatingShear_det, one_mul, eliminatingShear_congruence A hA u v ht, + pfaffian_block_extra hn _ (schurComplement_skew A hA u v t)] at h + exact h.symm + +end + +noncomputable section +open scoped BigOperators + +def schurEntry (x y : ℂ) : ℂ := (y - x) / (x + y) +def schurMatrix {n : ℕ} (x : Fin n → ℂ) : Matrix (Fin n) (Fin n) ℂ := + fun i j => schurEntry (x i) (x j) +def schurProduct {n : ℕ} (x : Fin n → ℂ) : ℂ := + ∏ i, ∏ j ∈ Finset.Ioi i, schurEntry (x i) (x j) + +lemma schurEntry_self (x : ℂ) : schurEntry x x = 0 := by simp [schurEntry] +lemma schurEntry_swap (x y : ℂ) : schurEntry y x = -schurEntry x y := by + simp only [schurEntry, add_comm y x] + ring +lemma schurMatrix_skew {n : ℕ} (x : Fin n → ℂ) : + ∀ i j, schurMatrix x j i = -schurMatrix x i j := + fun i j => schurEntry_swap (x i) (x j) +lemma schurEntry_ne_zero {x y : ℂ} (hne : y ≠ x) (hd : x + y ≠ 0) : + schurEntry x y ≠ 0 := div_ne_zero (sub_ne_zero.mpr hne) hd + +lemma schurEntry_elimination {x y a b : ℂ} + (hxy : x + y ≠ 0) (hxa : x + a ≠ 0) (hxb : x + b ≠ 0) + (hya : y + a ≠ 0) (hyb : y + b ≠ 0) (_hab : a + b ≠ 0) (hne : b ≠ a) : + schurEntry x y - + (schurEntry x a * schurEntry y b - schurEntry x b * schurEntry y a) / + schurEntry a b = + (schurEntry x a * schurEntry x b) * schurEntry x y * + (schurEntry y a * schurEntry y b) := by + have hba := sub_ne_zero.mpr hne + unfold schurEntry + field_simp + ring + +lemma schurEntry_border_elimination {x y a : ℂ} + (hxy : x + y ≠ 0) (hxa : x + a ≠ 0) (hya : y + a ≠ 0) : + schurEntry x y - (schurEntry x a - schurEntry y a) = + schurEntry x a * schurEntry x y * schurEntry y a := by + unfold schurEntry + field_simp + ring + +lemma schurMatrix_snoc {n : ℕ} (x : Fin n → ℂ) (a : ℂ) : + schurMatrix (Fin.snoc x a) = border (schurMatrix x) (fun i => schurEntry (x i) a) := by + ext i j + refine Fin.lastCases ?_ (fun i => ?_) i <;> + refine Fin.lastCases ?_ (fun j => ?_) j <;> + simp only [schurMatrix, Fin.snoc_last, Fin.snoc_castSucc, border_last_last, + border_last_old, border_old_last, border_old_old, schurEntry_self] + exact schurEntry_swap _ _ + +lemma schurColumn_snoc {n : ℕ} (x : Fin n → ℂ) (a b : ℂ) : + (fun i : Fin (n + 1) => schurEntry (Fin.snoc (α := fun _ => ℂ) x a i) b) = + Fin.snoc (fun i => schurEntry (x i) b) (schurEntry a b) := by + ext i + refine Fin.lastCases ?_ (fun i => ?_) i <;> simp + +lemma schurProduct_snoc {n : ℕ} (x : Fin n → ℂ) (a : ℂ) : + schurProduct (Fin.snoc x a) = schurProduct x * ∏ i, schurEntry (x i) a := by + unfold schurProduct + rw [Fin.prod_univ_castSucc, prod_Ioi_last, mul_one] + simp_rw [prod_Ioi_castSucc, Fin.snoc_castSucc, Fin.snoc_last] + exact Finset.prod_mul_distrib + +@[simp] lemma pfaffian_empty (A : Matrix (Fin 0) (Fin 0) ℂ) : pfaffian 0 A = 1 := by + have h := topCoord_topWedge 0 + simpa [topCoord, topWedge, ExteriorAlgebra.ιMulti_zero_apply, pfaffian, + Module.Basis.coord_apply] using h + +lemma pfaffian_schur_snoc_snoc {n : ℕ} (hn : Even n) (x : Fin n → ℂ) (a b : ℂ) + (hbase : pfaffian n (schurMatrix x) = schurProduct x) + (hxx : ∀ i j, x i + x j ≠ 0) (hxa : ∀ i, x i + a ≠ 0) + (hxb : ∀ i, x i + b ≠ 0) (hab : a + b ≠ 0) (hne : b ≠ a) : + pfaffian (n + 2) (schurMatrix (Fin.snoc (Fin.snoc x a) b)) = + schurProduct (Fin.snoc (Fin.snoc x a) b) := by + have hc : schurComplement (schurMatrix x) (fun i => schurEntry (x i) a) + (fun i => schurEntry (x i) b) (schurEntry a b) = + fun i j => (schurEntry (x i) a * schurEntry (x i) b) * schurMatrix x i j * + (schurEntry (x j) a * schurEntry (x j) b) := by + ext i j + exact schurEntry_elimination (hxx i j) (hxa i) (hxb i) (hxa j) (hxb j) hab hne + rw [schurMatrix_snoc, schurMatrix_snoc, schurColumn_snoc, + pfaffian_schur_complement hn _ (schurMatrix_skew x) _ _ (schurEntry_ne_zero hne hab), + hc, pfaffian_scale_coordinates hn _ (schurMatrix_skew x), hbase] + simp only [schurProduct_snoc, Fin.prod_univ_castSucc, Fin.snoc_castSucc, Fin.snoc_last, + Finset.prod_mul_distrib] + ring + + +end +end StripPfaffian + +end OAI diff --git a/lean/OAI/Combinatorics/StripMass/InverseMoments.lean b/lean/OAI/Combinatorics/StripMass/InverseMoments.lean new file mode 100644 index 0000000000000000000000000000000000000000..ca878f9babcc752d466a2505f1dcb9fe463205b1 --- /dev/null +++ b/lean/OAI/Combinatorics/StripMass/InverseMoments.lean @@ -0,0 +1,414 @@ +import Mathlib +import OAI.Combinatorics.StripMass.LaguerreNormalization + +namespace OAI + +/-! Critical honeycomb strip paths, polynomial identities and crossing mass. -/ + + +namespace CriticalStrip +noncomputable section +open scoped BigOperators +open MeasureTheory Set StripPfaffian +theorem laguerreExpectation_inverseSum (n : ℕ) {a : ℝ} (ha : 1 < a) : + laguerreExpectation n a (fun r => ∑ i, (r i)⁻¹) = + (n:ℝ)*(2*a+n-1)/(2*a*(a-1)) := by + cases n with + | zero => simp [laguerreExpectation] + | succ n => + have ha0 : 0 < a := by linarith + unfold laguerreExpectation + rw [integral_laguerre_inverseSum_eq_gammaProduct ha, + gammaSchurProduct_inverse n ha, laguerreNormalizer_succ_product n ha0, + telescoping_inverse_product n (mul_pos (by norm_num : (0:ℝ)<2) ha0)] + have hg := Real.Gamma_add_one (show a-1 ≠ 0 by linarith) + rw [sub_add_cancel] at hg + rw [hg] + have hG : Real.Gamma (a-1) ≠ 0 := (Real.Gamma_pos_of_pos (by linarith : 0 < a-1)).ne' + have hZ : laguerreNormalizer n (a+1) ≠ 0 := (laguerreNormalizer_pos n (by linarith)).ne' + have hP : (∏ i : Fin n, ((i.val:ℝ)+1)/(2*a+i.val+1)) ≠ 0 := by + apply Finset.prod_ne_zero_iff.mpr + intro i _ + positivity + simp only [Nat.cast_add, Nat.cast_one] + field_simp + ring + + + + + + +def minTilt (s r : ℝ) : ℝ := (max (1-s/r) 0)^2 / (1+s/r) +def minTiltProduct (n : ℕ) (s : ℝ) (r : Fin n → ℝ) : ℝ := ∏ i, minTilt s (r i) +def inverseSum (n : ℕ) (r : Fin n → ℝ) : ℝ := ∑ i, (r i)⁻¹ + +lemma minTilt_nonneg {s r : ℝ} (hs : 0 ≤ s) (hr : 0 < r) : 0 ≤ minTilt s r := by + exact div_nonneg (sq_nonneg _) (by positivity) + +lemma minTilt_le_one {s r : ℝ} (hs : 0 ≤ s) (hr : 0 < r) : minTilt s r ≤ 1 := by + have ht : 0 ≤ s/r := div_nonneg hs hr.le + have hm : 0 ≤ max (1-s/r) 0 := le_max_right _ _ + have hm1 : max (1-s/r) 0 ≤ 1 := max_le (by linarith) zero_le_one + apply (div_le_one (by positivity : 0 < 1+s/r)).2 + nlinarith [mul_self_le_mul_self hm hm1] + +lemma minTilt_eq_zero {s r : ℝ} (hr : 0 < r) (hrs : r ≤ s) : minTilt s r = 0 := by + have ht : 1 ≤ s/r := (le_div_iff₀ hr).2 (by simpa using hrs) + simp [minTilt, max_eq_right (by linarith : 1-s/r ≤ 0)] + +lemma minTilt_eq_pair {s r : ℝ} (hs : 0 < s) (hrs : s < r) : + minTilt s r = pairKernel s r / r := by + have hr := hs.trans hrs + rw [minTilt, max_eq_left (by rw [sub_nonneg]; exact (div_le_one hr).2 hrs.le)] + unfold pairKernel + field_simp + +lemma one_sub_minTilt_le {s r : ℝ} (hs : 0 ≤ s) (hr : 0 < r) : + 1-minTilt s r ≤ 3*s/r := by + by_cases hrs : r ≤ s + · rw [minTilt_eq_zero hr hrs] + have ht : 1 ≤ s/r := (le_div_iff₀ hr).2 (by simpa using hrs) + have he : 3*s/r = 3*(s/r) := by ring + rw [he] + linarith + · have ht : 0 ≤ s/r := div_nonneg hs hr.le + have ht1 : s/r ≤ 1 := (div_le_one hr).2 (le_of_not_ge hrs) + rw [minTilt, max_eq_left (by linarith : 0 ≤ 1-s/r)] + have hd : 0 < 1+s/r := by positivity + have he : 3*s/r = 3*(s/r) := by ring + rw [he] + have hh : 1-3*(s/r) ≤ (1-s/r)^2/(1+s/r) := by + apply (le_div_iff₀ hd).2 + nlinarith [sq_nonneg (s/r)] + linarith + +lemma continuousOn_minTilt {s : ℝ} (hs : 0 ≤ s) : ContinuousOn (minTilt s) (Ioi 0) := by + have hc : ContinuousOn (fun r : ℝ => s/r) (Ioi 0) := + continuousOn_const.div continuousOn_id (fun _ hr => ne_of_gt hr) + unfold minTilt + exact (((continuousOn_const.sub hc).sup continuousOn_const).pow 2).div + (continuousOn_const.add hc) (fun r hr => + ne_of_gt (add_pos_of_pos_of_nonneg zero_lt_one (div_nonneg hs hr.le))) + +lemma monotoneOn_minTilt {s : ℝ} (hs : 0 ≤ s) : MonotoneOn (minTilt s) (Ioi 0) := by + intro r hr t ht hrt + have hst : s/t ≤ s/r := div_le_div_of_nonneg_left hs hr hrt + apply div_le_div₀ + · exact sq_nonneg _ + · exact pow_le_pow_left₀ (le_max_right _ _) (max_le_max_right 0 (by linarith)) 2 + · exact add_pos_of_pos_of_nonneg zero_lt_one (div_nonneg hs ht.le) + · linarith + +lemma measurable_minTilt (s : ℝ) : Measurable (minTilt s) := by unfold minTilt; fun_prop + +lemma minTiltProduct_nonneg {n : ℕ} {s : ℝ} (hs : 0 ≤ s) {r : Fin n → ℝ} (hr : ∀ i, 0 < r i) : + 0 ≤ minTiltProduct n s r := Finset.prod_nonneg fun i _ => minTilt_nonneg hs (hr i) + +lemma minTiltProduct_le_one {n : ℕ} {s : ℝ} (hs : 0 ≤ s) {r : Fin n → ℝ} (hr : ∀ i, 0 < r i) : + minTiltProduct n s r ≤ 1 := Finset.prod_le_one₀ (fun i _ => minTilt_nonneg hs (hr i)) + (fun i _ => minTilt_le_one hs (hr i)) + +lemma minTiltProduct_eq_zero {n : ℕ} {s : ℝ} {r : Fin n → ℝ} (hr : ∀ i, 0 < r i) + (h : ¬∀ i, s < r i) : minTiltProduct n s r = 0 := by + classical + obtain ⟨i, hi⟩ := not_forall.mp h + exact Finset.prod_eq_zero (Finset.mem_univ i) (minTilt_eq_zero (hr i) (not_lt.mp hi)) + +lemma minTiltProduct_pair {n : ℕ} {s : ℝ} (hs : 0 < s) {r : Fin n → ℝ} + (hr : ∀ i, s < r i) : + (∏ i, r i) * minTiltProduct n s r = ∏ i, pairKernel s (r i) := by + unfold minTiltProduct + rw [← Finset.prod_mul_distrib] + apply Finset.prod_congr rfl + intro i _ + rw [minTilt_eq_pair hs (hr i), mul_div_cancel₀ _ (hs.trans (hr i)).ne'] + +lemma laguerreDensity_cons_tilt {n : ℕ} {s : ℝ} (hs : 0 < s) + {r : Fin n → ℝ} (hr : r ∈ laguerreDomain n) (hsr : ∀ i, s < r i) (a : ℝ) : + laguerreDensity (n+1) a (Fin.cons s r) = + laguerreWeight a s * minTiltProduct n s r * laguerreDensity n (a+1) r := by + rw [laguerreDensity_cons, laguerreDensity_succ_parameter _ _ hr.2] + calc + _ = laguerreWeight a s * laguerreDensity n a r * + ((∏ i, r i) * minTiltProduct n s r) := by rw [minTiltProduct_pair hs hsr] + _ = _ := by ring + +lemma continuousOn_minTiltProduct (n : ℕ) {s : ℝ} (hs : 0 ≤ s) : + ContinuousOn (minTiltProduct n s) (coordinateBox (Fin n) (Ioi 0)) := by + apply continuousOn_finsetProd + intro i _ + exact (continuousOn_minTilt hs).comp (continuous_apply i).continuousOn (fun _ hr => hr i) + +lemma monotoneOn_minTiltProduct (n : ℕ) {s : ℝ} (hs : 0 ≤ s) : + MonotoneOn (minTiltProduct n s) (coordinateBox (Fin n) (Ioi 0)) := by + intro r hr t ht hrt + apply Finset.prod_le_prod₀ + · intro i _ + exact minTilt_nonneg hs (hr i) + · intro i _ + exact monotoneOn_minTilt hs (hr i) (ht i) (hrt i) + +lemma measurable_minTiltProduct (n : ℕ) (s : ℝ) : Measurable (minTiltProduct n s) := by + apply Finset.measurable_prod + intro i _ + exact (measurable_minTilt s).comp (measurable_pi_apply i) + +lemma inverseSum_nonneg {n : ℕ} {r : Fin n → ℝ} (hr : ∀ i, 0 < r i) : 0 ≤ inverseSum n r := + Finset.sum_nonneg fun i _ => (inv_pos.mpr (hr i)).le + +lemma continuousOn_inverseSum (n : ℕ) : + ContinuousOn (inverseSum n) (coordinateBox (Fin n) (Ioi 0)) := by + apply continuousOn_finsetSum + intro i _ + exact (continuous_apply i).continuousOn.inv₀ fun _ hr => ne_of_gt (hr i) + +lemma antitoneOn_inverseSum (n : ℕ) : + AntitoneOn (inverseSum n) (coordinateBox (Fin n) (Ioi 0)) := by + intro r hr t ht hrt + exact Finset.sum_le_sum fun i _ => inv_anti₀ (hr i) (hrt i) + +lemma measurable_inverseSum (n : ℕ) : Measurable (inverseSum n) := by unfold inverseSum; fun_prop + +lemma integrable_laguerreLaw_inverseSum {n : ℕ} {a : ℝ} (ha : 1 < a) : + Integrable (inverseSum n) (laguerreLaw n a) := + integrable_laguerreLaw (by linarith) (integrableOn_laguerre_inverseSum ha) + +lemma integrable_laguerreLaw_minTiltProduct (n : ℕ) {a s : ℝ} (ha : 0 < a) (hs : 0 ≤ s) : + Integrable (minTiltProduct n s) (laguerreLaw n a) := by + let := laguerreLaw_isProbabilityMeasure n ha + apply (integrable_const (1 : ℝ)).mono' (measurable_minTiltProduct n s).aestronglyMeasurable + filter_upwards [ae_laguerreDomain n a] with r hr + rw [Real.norm_eq_abs, abs_of_nonneg (minTiltProduct_nonneg hs hr.2)] + exact minTiltProduct_le_one hs hr.2 + +lemma integrable_laguerreLaw_inverseSum_minTilt {n : ℕ} {a s : ℝ} (ha : 1 < a) (hs : 0 ≤ s) : + Integrable (fun r => inverseSum n r * minTiltProduct n s r) (laguerreLaw n a) := by + apply (integrable_laguerreLaw_inverseSum ha).mono' + ((measurable_inverseSum n).mul (measurable_minTiltProduct n s)).aestronglyMeasurable + filter_upwards [ae_laguerreDomain n a] with r hr + change ‖inverseSum n r * minTiltProduct n s r‖ ≤ inverseSum n r + rw [Real.norm_eq_abs, abs_of_nonneg (mul_nonneg (inverseSum_nonneg hr.2) + (minTiltProduct_nonneg hs hr.2))] + exact mul_le_of_le_one_right (inverseSum_nonneg hr.2) (minTiltProduct_le_one hs hr.2) + +lemma laguerre_inverseSum_minTilt_le (n : ℕ) {a s : ℝ} (ha : 1 < a) (hs : 0 ≤ s) : + (∫ r, inverseSum n r * minTiltProduct n s r ∂laguerreLaw n a) ≤ + ((n:ℝ)*(2*a+n-1)/(2*a*(a-1))) * (∫ r, minTiltProduct n s r ∂laguerreLaw n a) := by + have h := laguerreLaw_reverse_covariance (by linarith : 0 < a) (inverseSum n) (minTiltProduct n s) + (continuousOn_inverseSum n) (continuousOn_minTiltProduct n hs) + (antitoneOn_inverseSum n) (monotoneOn_minTiltProduct n hs) + (integrable_laguerreLaw_inverseSum ha) (integrable_laguerreLaw_minTiltProduct n (by linarith) hs) + (integrable_laguerreLaw_inverseSum_minTilt ha hs) + have he : (∫ r, inverseSum n r ∂laguerreLaw n a) = (n:ℝ)*(2*a+n-1)/(2*a*(a-1)) := by + rw [integral_laguerreLaw n (by linarith)] + exact laguerreExpectation_inverseSum n ha + rw [he] at h + exact h + + + +lemma laguerre_indicator_cons_tilt (n : ℕ) (a : ℝ) (f : (Fin (n+1) → ℝ) → ℝ) + (s : ℝ) (r : Fin n → ℝ) : + (laguerreDomain (n+1)).indicator (fun x => f x * laguerreDensity (n+1) a x) (Fin.cons s r) = + (Ioi 0).indicator (laguerreWeight a) s * (laguerreDomain n).indicator + (fun r => f (Fin.cons s r) * minTiltProduct n s r * laguerreDensity n (a+1) r) r := by + classical + by_cases hs : 0 < s + · rw [indicator_of_mem (show s ∈ Ioi (0 : ℝ) from hs)] + by_cases hr : r ∈ laguerreDomain n + · rw [indicator_of_mem hr] + by_cases hsr : ∀ i, s < r i + · rw [indicator_of_mem ((laguerreDomain_cons_iff s r).2 ⟨hs,hr,hsr⟩), + laguerreDensity_cons_tilt hs hr hsr a] + ring + · have hx : Fin.cons s r ∉ laguerreDomain (n+1) := by + intro hx + exact hsr ((laguerreDomain_cons_iff s r).1 hx).2.2 + rw [indicator_of_notMem hx, minTiltProduct_eq_zero hr.2 hsr] + ring + · have hx : Fin.cons s r ∉ laguerreDomain (n+1) := by + intro hx + exact hr ((laguerreDomain_cons_iff s r).1 hx).2.1 + simp only [indicator_of_notMem hx, indicator_of_notMem hr, mul_zero] + · have hx : Fin.cons s r ∉ laguerreDomain (n+1) := by + intro hx + exact hs ((laguerreDomain_cons_iff s r).1 hx).1 + simp only [indicator_of_notMem hx, indicator_of_notMem (show s ∉ Ioi (0 : ℝ) from hs), zero_mul] + +lemma integral_laguerre_splitMin (n : ℕ) (a : ℝ) (f : (Fin (n+1) → ℝ) → ℝ) + (hf : IntegrableOn (fun x => f x * laguerreDensity (n+1) a x) (laguerreDomain (n+1))) : + (∫ x in laguerreDomain (n+1), f x * laguerreDensity (n+1) a x) = + ∫ s in Ioi 0, laguerreWeight a s * + ∫ r in laguerreDomain n, f (Fin.cons s r) * minTiltProduct n s r * laguerreDensity n (a+1) r := by + have hi := (integrable_indicator_iff (isOpen_laguerreDomain (n+1)).measurableSet).2 hf + rw [← integral_indicator (isOpen_laguerreDomain (n+1)).measurableSet, integral_fin_cons_eq] + calc + _ = ∫ s, ∫ r : Fin n → ℝ, (laguerreDomain (n+1)).indicator + (fun x => f x * laguerreDensity (n+1) a x) (Fin.cons s r) := + integral_prod _ (integrable_fin_cons hi) + _ = _ := by + simp_rw [laguerre_indicator_cons_tilt, integral_const_mul, + integral_indicator (isOpen_laguerreDomain n).measurableSet] + rw [← integral_indicator measurableSet_Ioi] + apply integral_congr_ae + exact Filter.Eventually.of_forall fun s => + (indicator_mul_left (Ioi 0) (laguerreWeight a) + (fun s => ∫ r in laguerreDomain n, + f (Fin.cons s r) * minTiltProduct n s r * laguerreDensity n (a+1) r)).symm + +lemma integrable_laguerre_splitMin (n : ℕ) (a : ℝ) (f : (Fin (n+1) → ℝ) → ℝ) + (hf : IntegrableOn (fun x => f x * laguerreDensity (n+1) a x) (laguerreDomain (n+1))) : + IntegrableOn (fun s => laguerreWeight a s * + ∫ r in laguerreDomain n, f (Fin.cons s r) * minTiltProduct n s r * laguerreDensity n (a+1) r) + (Ioi 0) := by + have hi := (integrable_indicator_iff (isOpen_laguerreDomain (n+1)).measurableSet).2 hf + have hj := (integrable_fin_cons hi).integral_prod_left + simp_rw [laguerre_indicator_cons_tilt, integral_const_mul, + integral_indicator (isOpen_laguerreDomain n).measurableSet] at hj + have he : (fun s => (Ioi 0).indicator (laguerreWeight a) s * + ∫ r in laguerreDomain n, f (Fin.cons s r) * minTiltProduct n s r * laguerreDensity n (a+1) r) = + (Ioi 0).indicator (fun s => laguerreWeight a s * + ∫ r in laguerreDomain n, f (Fin.cons s r) * minTiltProduct n s r * laguerreDensity n (a+1) r) := by + ext s + exact (indicator_mul_left (Ioi 0) (laguerreWeight a) + (fun s => ∫ r in laguerreDomain n, + f (Fin.cons s r) * minTiltProduct n s r * laguerreDensity n (a+1) r)).symm + rw [he] at hj + exact (integrable_indicator_iff measurableSet_Ioi).1 hj + +lemma integrableOn_laguerre_tailInverseSum {n : ℕ} {a : ℝ} (ha : 0 < a) : + IntegrableOn (fun r : Fin (n+1) → ℝ => (∑ i : Fin n, (r i.succ)⁻¹) * laguerreDensity (n+1) a r) + (laguerreDomain (n+1)) := by + simp only [Finset.sum_mul] + apply integrable_finsetSum + intro i _ + simpa only [IntegrableOn, Real.rpow_neg_one] using integrableOn_laguerre_inverse_coordinate ha + i.succ (p := 1) (by simp only [Fin.val_succ, Nat.cast_add, Nat.cast_one]; linarith [Nat.cast_nonneg (α := ℝ) i.val]) + +lemma weighted_integral_laguerre_inverseSum_minTilt_le (n : ℕ) {a s : ℝ} (ha : 1 < a) (hs : 0 ≤ s) : + (∫ r in laguerreDomain n, inverseSum n r * minTiltProduct n s r * laguerreDensity n a r) ≤ + ((n:ℝ)*(2*a+n-1)/(2*a*(a-1))) * + (∫ r in laguerreDomain n, minTiltProduct n s r * laguerreDensity n a r) := by + have h := laguerre_inverseSum_minTilt_le n ha hs + simp only [integral_laguerreLaw n (show 0 < a by linarith), laguerreExpectation, + ← mul_div_assoc] at h + exact (div_le_div_iff_of_pos_right (laguerreNormalizer_pos n (by linarith))).1 h + + + +theorem laguerreExpectation_tailInverseSum_le (n : ℕ) {a : ℝ} (ha : 0 < a) : + laguerreExpectation (n+1) a (fun r => ∑ i : Fin n, (r i.succ)⁻¹) ≤ + (n:ℝ)*(2*(a+1)+n-1)/(2*(a+1)*a) := by + let T := (n:ℝ)*(2*(a+1)+n-1)/(2*(a+1)*a) + have hi := integrableOn_laguerre_tailInverseSum (n := n) ha + have h1 : IntegrableOn (fun x => (1:ℝ) * laguerreDensity (n+1) a x) (laguerreDomain (n+1)) := by + simpa using integrableOn_laguerreDensity (n+1) ha + have hb (s : ℝ) (hs : 0 < s) : + (∫ r in laguerreDomain n, (∑ i : Fin n, (r i)⁻¹) * minTiltProduct n s r * laguerreDensity n (a+1) r) ≤ + T * ∫ r in laguerreDomain n, minTiltProduct n s r * laguerreDensity n (a+1) r := by + simpa only [inverseSum, add_sub_cancel_right, T] using + weighted_integral_laguerre_inverseSum_minTilt_le n (by linarith : 1 < a+1) hs.le + have hm : (∫ x in laguerreDomain (n+1), (∑ i : Fin n, (x i.succ)⁻¹) * laguerreDensity (n+1) a x) ≤ + T * laguerreNormalizer (n+1) a := by + rw [integral_laguerre_splitMin n a _ hi] + change _ ≤ T * ∫ x in laguerreDomain (n+1), laguerreDensity (n+1) a x + have he : (∫ x in laguerreDomain (n+1), laguerreDensity (n+1) a x) = + ∫ x in laguerreDomain (n+1), (1:ℝ) * laguerreDensity (n+1) a x := by simp + rw [he] + rw [integral_laguerre_splitMin n a (fun _ => 1) h1, ← integral_const_mul] + apply integral_mono_ae (integrable_laguerre_splitMin n a _ hi) + ((integrable_laguerre_splitMin n a (fun _ => 1) h1).const_mul T) + filter_upwards [ae_restrict_mem measurableSet_Ioi] with s hs + simp only [Fin.cons_succ, one_mul] + have H := mul_le_mul_of_nonneg_left (hb s hs) (laguerreWeight_pos a hs).le + simpa only [mul_left_comm] using H + exact (div_le_iff₀ (laguerreNormalizer_pos (n+1) ha)).2 hm + +end + + + +noncomputable section +open scoped BigOperators +open Set MeasureTheory + +lemma reciprocal_product_succ (n : ℕ) : + (∏ i : Fin n, ((i.val:ℝ)+1)/(i.val+2)) = 1/(n+1) := by + induction n with + | zero => simp + | succ n ih => + rw [Fin.prod_univ_castSucc] + simp only [Fin.val_castSucc, Fin.val_last, Nat.cast_add, Nat.cast_one] + rw [ih] + have h1 : (n:ℝ)+1 ≠ 0 := by positivity + have h2 : (n:ℝ)+2 ≠ 0 := by positivity + field_simp + ring + +lemma laguerreNormalizer_half_step (n : ℕ) : + laguerreNormalizer (n+1) (1/2) = + Real.Gamma (1/2) / (n+1) * laguerreNormalizer n (3/2) := by + rw [laguerreNormalizer_succ_product n (by norm_num : (0:ℝ)<1/2)] + norm_num only at * + have he : (fun i : Fin n => ((i.val:ℝ)+1)/(1+i.val+1)) = + (fun i : Fin n => ((i.val:ℝ)+1)/(i.val+2)) := by ext i; congr 1; ring + rw [he, reciprocal_product_succ] + ring + +lemma laguerreSmallCoefficient_half_one (n : ℕ) : + laguerreSmallCoefficient (n+1) (1/2) 1 = 2*(n+1)/Real.Gamma (1/2) := by + unfold laguerreSmallCoefficient + simp only [Nat.add_sub_cancel, Fin.prod_univ_one, Fin.val_zero, Nat.cast_zero, add_zero] + rw [laguerreNormalizer_half_step] + have hZ : laguerreNormalizer n (3/2) ≠ 0 := (laguerreNormalizer_pos n (by norm_num)).ne' + have hG : Real.Gamma (1/2) ≠ 0 := (Real.Gamma_pos_of_pos (by norm_num : (0:ℝ)<1/2)).ne' + have hN : (n:ℝ)+1 ≠ 0 := by positivity + field_simp + ring_nf + +lemma laguerre_least_inverseQuarter_upper (n : ℕ) : + laguerreExpectation (n+1) (1/2) (fun r => (r 0)^(-(1/4:ℝ))) ≤ + (2*(2/Real.Gamma (1/2))^(1/2:ℝ)) * ((n:ℝ)+1)^(1/2:ℝ) := by + have H := laguerre_inverse_bound_normalizer_ratio + (by norm_num : (0:ℝ)<1/2) (0 : Fin (n+1)) (by norm_num : (0:ℝ)<1/4) + (by norm_num [laguerreDimension] : (1/4:ℝ) ∑ i : Fin n, (r i.succ)⁻¹) ≤ ((n:ℝ)+1)^2 := by + have H := laguerreExpectation_tailInverseSum_le n (by norm_num : (0:ℝ)<1/2) + apply H.trans + norm_num only + have hn := Nat.cast_nonneg (α := ℝ) n + nlinarith [sq_nonneg ((n:ℝ)+1)] + + + +end +end CriticalStrip + +end OAI diff --git a/lean/OAI/Combinatorics/StripMass/LaguerreNormalization.lean b/lean/OAI/Combinatorics/StripMass/LaguerreNormalization.lean new file mode 100644 index 0000000000000000000000000000000000000000..d8bab99ea89a9bb72c2118d4c5ecff30585aab4d --- /dev/null +++ b/lean/OAI/Combinatorics/StripMass/LaguerreNormalization.lean @@ -0,0 +1,434 @@ +import Mathlib +import OAI.Combinatorics.StripMass.PfaffianIntegration + +namespace OAI + +/-! Critical honeycomb strip paths, polynomial identities and crossing mass. -/ + + +namespace CriticalStrip +noncomputable section +open scoped BigOperators +open MeasureTheory Set StripPfaffian +local notation "μ₊" => volume.restrict (Ioi (0 : ℝ)) +lemma integral_laguerreOddIntegrand {n : ℕ} (hn : Odd n) {a : ℝ} (ha : 0 < a) : + (∫ x, laguerreOddIntegrand n a x ∂Measure.pi (fun _ : Fin n => μ₊)) = + (n.factorial : ℂ) * (laguerreNormalizer n a : ℂ) := by + have he : ∀ᵐ x ∂volume.restrict (laguerreDomain n), + laguerreOddIntegrand n a x = (laguerreDensity n a x : ℂ) := + (ae_restrict_mem (isOpen_laguerreDomain n).measurableSet).mono + fun x hx => laguerreOddIntegrand_eq hn a hx + rw [integral_symmetric_ordered _ + (fun σ x => determinantPfaffian_symmetric_odd hn _ + (fun r s : ℝ => schurEntry r s) (fun _ => 1) (fun r s => schurEntry_swap _ _) σ x) + (fun x hx => by + unfold laguerreOddIntegrand + rw [evaluationMatrix_det_of_not_injective _ hx, zero_mul]) + (by + have hi := (integrableOn_laguerreDensity n ha).ofReal (𝕜 := ℂ) + simp only [RCLike.ofReal_eq_complex_ofReal] at hi + exact hi.congr (he.mono fun _ h => h.symm))] + rw [integral_congr_ae he, integral_complex_ofReal] + rfl + +lemma laguerre_doubleIntegrand_eq {n : ℕ} (a : ℝ) (i j : Fin n) (rs : ℝ × ℝ) : + doubleIntegrand (laguerrePhi n a) (fun r s : ℝ => schurEntry r s) i j rs = + (gammaSkewIntegrand (a+i.val) (a+j.val) rs : ℂ) := by + simp only [doubleIntegrand, laguerrePhi, gammaSkewIntegrand, schurEntry, + Complex.ofReal_mul, Complex.ofReal_div, Complex.ofReal_sub, Complex.ofReal_add] + rw [add_comm (rs.2 : ℂ) (rs.1 : ℂ)] + ring + +lemma integrable_laguerre_doubleIntegrand {n : ℕ} {a : ℝ} (ha : 0 < a) (i j : Fin n) : + Integrable (doubleIntegrand (laguerrePhi n a) (fun r s : ℝ => schurEntry r s) i j) + (μ₊.prod μ₊) := by + have he : doubleIntegrand (laguerrePhi n a) (fun r s : ℝ => schurEntry r s) i j = + fun rs => (gammaSkewIntegrand (a+i.val) (a+j.val) rs : ℂ) := + funext (laguerre_doubleIntegrand_eq a i j) + rw [he] + simpa only [RCLike.ofReal_eq_complex_ofReal] using + (laguerre_double_moment ha i.val j.val).1.ofReal (𝕜 := ℂ) + +lemma laguerre_doubleMomentMatrix_eq {a : ℝ} (n : ℕ) : + doubleMomentMatrix μ₊ (laguerrePhi n a) (fun r s : ℝ => schurEntry r s) = + laguerreMomentMatrix n a := by + ext i j + simp only [doubleMomentMatrix, laguerre_doubleIntegrand_eq, integral_complex_ofReal, + laguerreMomentMatrix] + +lemma laguerre_singleMoment_eq (n : ℕ) (a : ℝ) : + singleMoment μ₊ (laguerrePhi n a) (fun _ => 1) = laguerreMomentColumn n a := by + ext i + simp only [singleMoment, laguerrePhi, mul_one, integral_complex_ofReal, laguerreMomentColumn] + + + +theorem laguerreNormalizer_eq_product (n : ℕ) {a : ℝ} (ha : 0 < a) : + laguerreNormalizer n a = laguerreNormalizerProduct n a := by + apply Complex.ofReal_injective + rcases Nat.even_or_odd n with hn | hn + · obtain ⟨m, hm⟩ := hn + have hn : n = m*2 := by omega + clear hm + subst n + have he : Even (m*2) := ⟨m, by omega⟩ + have h := deBruijn_even μ₊ m (laguerrePhi (m*2) a) + (fun r s : ℝ => schurEntry r s) (fun r s => schurEntry_swap _ _) + (integrable_laguerre_doubleIntegrand ha) + change (∫ x, laguerreEvenIntegrand (m*2) a x ∂Measure.pi (fun _ => μ₊)) = _ at h + rw [integral_laguerreEvenIntegrand he ha, laguerre_doubleMomentMatrix_eq, + laguerreMomentMatrix_pfaffian_even ha _ he] at h + exact mul_left_cancel₀ (show ((m*2).factorial : ℂ) ≠ 0 by exact_mod_cast Nat.factorial_ne_zero (m*2)) h + · obtain ⟨m, hm⟩ := hn + have hn : n = m*2+1 := by omega + clear hm + subst n + have he : Odd (m*2+1) := ⟨m, by omega⟩ + have hs (i : Fin (m*2+1)) : Integrable (fun t => laguerrePhi (m*2+1) a i t * 1) μ₊ := by + simpa only [IntegrableOn, laguerrePhi, mul_one, RCLike.ofReal_eq_complex_ofReal] using + (integrableOn_laguerreWeight (show 0 < a+i.val by positivity)).ofReal (𝕜 := ℂ) + have h := deBruijn_odd μ₊ m (laguerrePhi (m*2+1) a) + (fun r s : ℝ => schurEntry r s) (fun _ => 1) (fun r s => schurEntry_swap _ _) + (integrable_laguerre_doubleIntegrand ha) hs + change (∫ x, laguerreOddIntegrand (m*2+1) a x ∂Measure.pi (fun _ => μ₊)) = _ at h + rw [integral_laguerreOddIntegrand he ha, laguerre_doubleMomentMatrix_eq, + laguerre_singleMoment_eq] at h + rw [laguerreMomentMatrix_pfaffian_odd ha _ he] at h + exact mul_left_cancel₀ (show ((m*2+1).factorial : ℂ) ≠ 0 by exact_mod_cast Nat.factorial_ne_zero (m*2+1)) h + +end +end CriticalStrip + + + +namespace Matrix +open scoped _root_.Matrix +noncomputable section +open scoped BigOperators + + +lemma sum_det_updateRow_mul {R ι : Type*} [CommRing R] [Fintype ι] [DecidableEq ι] + (A : Matrix ι ι R) (f : ι → R) : + (∑ i, (A.updateRow i (fun j => A i j * f j)).det) = A.det * ∑ j, f j := by + calc + _ = ∑ i, ∑ j, A.adjugate j i * (A i j * f j) := by + apply Finset.sum_congr rfl + intro i _ + rw [← _root_.Matrix.cramer_transpose_apply, _root_.Matrix.cramer_eq_adjugate_mulVec, ← _root_.Matrix.adjugate_transpose] + rfl + _ = ∑ j, (∑ i, A.adjugate j i * A i j) * f j := by + rw [Finset.sum_comm] + simp only [Finset.sum_mul, mul_assoc] + _ = ∑ j, A.det * f j := by + apply Finset.sum_congr rfl + intro j _ + change (A.adjugate * A) j j * f j = _ + rw [_root_.Matrix.adjugate_mul] + simp + _ = _ := by rw [Finset.mul_sum] + +end +end Matrix + +namespace CriticalStrip +noncomputable section +open scoped BigOperators +open MeasureTheory Set StripPfaffian + +local notation "μ₊" => volume.restrict (Ioi (0 : ℝ)) + +def gammaPhi {n : ℕ} (q : Fin n → ℝ) (i : Fin n) (x : ℝ) : ℂ := laguerreWeight (q i) x + +def gammaSchurProduct {n : ℕ} (q : Fin n → ℝ) : ℝ := + (∏ i, Real.Gamma (q i)) * (∏ i, ∏ j ∈ Finset.Ioi i, (q j - q i)/(q i + q j)) + +lemma gammaSchurProduct_eq {n : ℕ} (q : Fin n → ℝ) : + (gammaSchurProduct q : ℂ) = + (∏ i, (Real.Gamma (q i) : ℂ)) * schurProduct (fun i => (q i : ℂ)) := by + simp only [gammaSchurProduct, Complex.ofReal_mul, Complex.ofReal_prod, schurProduct, + schurEntry, Complex.ofReal_div, Complex.ofReal_sub, Complex.ofReal_add] + +lemma gammaPhi_doubleIntegrand_eq {n : ℕ} (q : Fin n → ℝ) (i j : Fin n) (rs : ℝ × ℝ) : + doubleIntegrand (gammaPhi q) (fun r s : ℝ => schurEntry r s) i j rs = + (gammaSkewIntegrand (q i) (q j) rs : ℂ) := by + simp only [doubleIntegrand, gammaPhi, gammaSkewIntegrand, schurEntry, + Complex.ofReal_mul, Complex.ofReal_div, Complex.ofReal_sub, Complex.ofReal_add] + rw [add_comm (rs.2 : ℂ) (rs.1 : ℂ)] + ring + +lemma gammaPhi_doubleMomentMatrix_eq {n : ℕ} {q : Fin n → ℝ} (hq : ∀ i, 0 < q i) : + doubleMomentMatrix μ₊ (gammaPhi q) (fun r s : ℝ => schurEntry r s) = + fun i j => (Real.Gamma (q i) : ℂ) * schurEntry (q i) (q j) * (Real.Gamma (q j) : ℂ) := by + ext i j + unfold doubleMomentMatrix + rw [funext (gammaPhi_doubleIntegrand_eq q i j), integral_complex_ofReal, + integral_gammaSkewIntegrand (hq i) (hq j)] + simp only [schurEntry, Complex.ofReal_mul, Complex.ofReal_div, + Complex.ofReal_sub, Complex.ofReal_add] + ring + +lemma integrable_gammaPhi_doubleIntegrand {n : ℕ} {q : Fin n → ℝ} (hq : ∀ i, 0 < q i) + (i j : Fin n) : + Integrable (doubleIntegrand (gammaPhi q) (fun r s : ℝ => schurEntry r s) i j) + (μ₊.prod μ₊) := by + simp only [funext (gammaPhi_doubleIntegrand_eq q i j)] + simpa only [RCLike.ofReal_eq_complex_ofReal] using + (integrable_gammaSkewIntegrand (hq i) (hq j)).ofReal (𝕜 := ℂ) + +lemma gammaPhi_singleMoment_eq {n : ℕ} {q : Fin n → ℝ} (hq : ∀ i, 0 < q i) : + singleMoment μ₊ (gammaPhi q) (fun _ => 1) = fun i => (Real.Gamma (q i) : ℂ) := by + ext i + simp only [singleMoment, gammaPhi, mul_one, integral_complex_ofReal, + integral_laguerreWeight (hq i)] + + + +theorem integral_gamma_determinant_schur {n : ℕ} {q : Fin n → ℝ} + (hq : ∀ i, 0 < q i) (hqi : Function.Injective q) + (f : (Fin n → ℝ) → ℝ) (hint : IntegrableOn f (laguerreDomain n)) + (heq : ∀ x ∈ laguerreDomain n, + (evaluationMatrix (gammaPhi q) x).det * schurProduct (fun i => (x i : ℂ)) = (f x : ℂ)) : + (∫ x in laguerreDomain n, f x) = gammaSchurProduct q := by + have hdq (i j : Fin n) : (q i : ℂ) + (q j : ℂ) ≠ 0 := by + rw [← Complex.ofReal_add, Complex.ofReal_ne_zero] + exact (add_pos (hq i) (hq j)).ne' + have hqic : Function.Injective (fun i => (q i : ℂ)) := Complex.ofReal_injective.comp hqi + have hdx {x : Fin n → ℝ} (hx : x ∈ laguerreDomain n) (i j : Fin n) : + (x i : ℂ) + (x j : ℂ) ≠ 0 := by + rw [← Complex.ofReal_add, Complex.ofReal_ne_zero] + exact (add_pos (hx.2 i) (hx.2 j)).ne' + have hxic {x : Fin n → ℝ} (hx : x ∈ laguerreDomain n) : + Function.Injective (fun i => (x i : ℂ)) := Complex.ofReal_injective.comp hx.1.injective + apply Complex.ofReal_injective + rw [gammaSchurProduct_eq, ← integral_complex_ofReal] + rcases Nat.even_or_odd n with hn | hn + · obtain ⟨m, hm⟩ := hn + have hn : n = m*2 := by omega + clear hm + subst n + have he : Even (m*2) := ⟨m, by omega⟩ + let F := fun x => (evaluationMatrix (gammaPhi q) x).det * + pfaffian (m*2) (schurMatrix (fun i => (x i : ℂ))) + have hF : ∀ᵐ x ∂volume.restrict (laguerreDomain (m*2)), F x = (f x : ℂ) := by + filter_upwards [ae_restrict_mem (isOpen_laguerreDomain (m*2)).measurableSet] with x hx + dsimp [F] + rw [pfaffian_schur_even _ he _ (hdx hx) (hxic hx)] + exact heq x hx + have hFi : IntegrableOn F (laguerreDomain (m*2)) := by + have hi := hint.ofReal (𝕜 := ℂ) + simp only [RCLike.ofReal_eq_complex_ofReal] at hi + exact hi.congr (hF.mono fun _ h => h.symm) + have hy := integral_symmetric_ordered F + (fun σ x => determinantPfaffian_symmetric_even he _ _ + (fun r s : ℝ => schurEntry_swap (r:ℂ) s) σ x) + (fun x hx => by dsimp [F]; rw [evaluationMatrix_det_of_not_injective _ hx, zero_mul]) hFi + have hb := deBruijn_even μ₊ m (gammaPhi q) (fun r s : ℝ => schurEntry r s) + (fun r s => schurEntry_swap _ _) (integrable_gammaPhi_doubleIntegrand hq) + change (∫ x, F x ∂Measure.pi (fun _ => μ₊)) = _ at hb + rw [hy, integral_congr_ae hF, gammaPhi_doubleMomentMatrix_eq hq, + pfaffian_weighted_schur_even _ he _ _ hdq hqic] at hb + exact mul_left_cancel₀ (show ((m*2).factorial : ℂ) ≠ 0 by exact_mod_cast Nat.factorial_ne_zero (m*2)) hb + · obtain ⟨m, hm⟩ := hn + have hn : n = m*2+1 := by omega + clear hm + subst n + have he : Odd (m*2+1) := ⟨m, by omega⟩ + let F := fun x => (evaluationMatrix (gammaPhi q) x).det * + pfaffian (m*2+2) (border (schurMatrix (fun i => (x i : ℂ))) (fun _ => 1)) + have hF : ∀ᵐ x ∂volume.restrict (laguerreDomain (m*2+1)), F x = (f x : ℂ) := by + filter_upwards [ae_restrict_mem (isOpen_laguerreDomain (m*2+1)).measurableSet] with x hx + dsimp [F] + rw [pfaffian_schur_odd _ he _ (hdx hx) (hxic hx)] + exact heq x hx + have hFi : IntegrableOn F (laguerreDomain (m*2+1)) := by + have hi := hint.ofReal (𝕜 := ℂ) + simp only [RCLike.ofReal_eq_complex_ofReal] at hi + exact hi.congr (hF.mono fun _ h => h.symm) + have hy := integral_symmetric_ordered F + (fun σ x => determinantPfaffian_symmetric_odd he _ _ (fun _ => 1) + (fun r s : ℝ => schurEntry_swap (r:ℂ) s) σ x) + (fun x hx => by dsimp [F]; rw [evaluationMatrix_det_of_not_injective _ hx, zero_mul]) hFi + have hs (i : Fin (m*2+1)) : Integrable (fun t => gammaPhi q i t * 1) μ₊ := by + simpa only [IntegrableOn, gammaPhi, mul_one, RCLike.ofReal_eq_complex_ofReal] using + (integrableOn_laguerreWeight (hq i)).ofReal (𝕜 := ℂ) + have hb := deBruijn_odd μ₊ m (gammaPhi q) (fun r s : ℝ => schurEntry r s) (fun _ => 1) + (fun r s => schurEntry_swap _ _) (integrable_gammaPhi_doubleIntegrand hq) hs + change (∫ x, F x ∂Measure.pi (fun _ => μ₊)) = _ at hb + rw [hy, integral_congr_ae hF, gammaPhi_doubleMomentMatrix_eq hq, gammaPhi_singleMoment_eq hq, + pfaffian_weighted_schur_odd _ he _ _ hdq hqic] at hb + exact mul_left_cancel₀ (show ((m*2+1).factorial : ℂ) ≠ 0 by exact_mod_cast Nat.factorial_ne_zero (m*2+1)) hb + +end + +noncomputable section +open scoped BigOperators +open MeasureTheory Set StripPfaffian + + +def inverseExponents (n : ℕ) (a : ℝ) : Fin (n+1) → ℝ := + Fin.cons (a-1) (fun i => a+(i.val+1)) + +lemma inverseExponents_pos {n : ℕ} {a : ℝ} (ha : 1 < a) : + ∀ i : Fin (n+1), 0 < inverseExponents n a i := by + intro i + refine Fin.cases ?_ (fun j => ?_) i + · simpa only [inverseExponents, Fin.cons_zero] using sub_pos.mpr ha + · simp only [inverseExponents, Fin.cons_succ] + positivity + +lemma inverseExponents_strictMono (n : ℕ) (a : ℝ) : StrictMono (inverseExponents n a) := by + rw [inverseExponents, Fin.strictMono_cons] + constructor + · intro i + have hi : (0 : ℝ) ≤ i.val := by positivity + linarith + · intro i j hij + have hij' : (i.val : ℝ) < j.val := by exact_mod_cast hij + linarith + +lemma laguerreWeight_add_one (a : ℝ) {x : ℝ} (hx : 0 < x) : + laguerreWeight (a+1) x = laguerreWeight a x * x := by + simpa using laguerreWeight_shift_nat a 1 hx + +lemma inverseExponents_determinant {n : ℕ} (a : ℝ) {x : Fin (n+1) → ℝ} + (hx : ∀ i, 0 < x i) : + (evaluationMatrix (gammaPhi (inverseExponents n a)) x).det = + (evaluationMatrix (laguerrePhi (n+1) a) x).det * ∑ i, (x i : ℂ)⁻¹ := by + classical + let A := evaluationMatrix (laguerrePhi (n+1) a) x + have he : evaluationMatrix (gammaPhi (inverseExponents n a)) x = + A.updateRow 0 (fun j => A 0 j * (x j : ℂ)⁻¹) := by + ext i j + refine Fin.cases ?_ (fun i => ?_) i + · simp only [Matrix.updateRow_self, evaluationMatrix, gammaPhi, inverseExponents, + Fin.cons_zero, A, laguerrePhi, Fin.val_zero, Nat.cast_zero, add_zero] + have h := laguerreWeight_add_one (a-1) (hx j) + rw [sub_add_cancel] at h + rw [h, Complex.ofReal_mul, mul_inv_cancel_right₀ (by exact_mod_cast (hx j).ne')] + · simp only [Matrix.updateRow_ne (Fin.succ_ne_zero i), evaluationMatrix, gammaPhi, + inverseExponents, Fin.cons_succ, A, laguerrePhi, Fin.val_succ, Nat.cast_add, Nat.cast_one] + have hs (i : Fin n) : (A.updateRow i.succ (fun j => A i.succ j * (x j : ℂ)⁻¹)).det = 0 := by + have hr : (fun j => A i.succ j * (x j : ℂ)⁻¹) = A i.castSucc := by + ext j + dsimp [A, evaluationMatrix, laguerrePhi] + rw [Nat.cast_add, Nat.cast_one, ← add_assoc, laguerreWeight_add_one _ (hx j), + Complex.ofReal_mul, mul_inv_cancel_right₀ (by exact_mod_cast (hx j).ne')] + rw [hr] + apply Matrix.det_updateRow_eq_zero + exact fun h => by have hv := congrArg Fin.val h; simp only [Fin.val_castSucc, Fin.val_succ] at hv; omega + rw [he] + have h := Matrix.sum_det_updateRow_mul A (fun i => (x i : ℂ)⁻¹) + simpa only [Fin.sum_univ_succ, hs, Finset.sum_const_zero, add_zero] using h + +lemma integrableOn_laguerre_inverseSum {n : ℕ} {a : ℝ} (ha : 1 < a) : + IntegrableOn (fun r : Fin n → ℝ => (∑ i, (r i)⁻¹) * laguerreDensity n a r) + (laguerreDomain n) := by + simp only [Finset.sum_mul] + apply integrable_finsetSum + intro i _ + simpa only [IntegrableOn, Real.rpow_neg_one] using integrableOn_laguerre_inverse_coordinate + (by linarith : 0 (s-r)/(r+s))] + simp only [Fin.prod_univ_succ, Fin.cons_zero, Fin.cons_succ] + ring + +lemma gammaSchurProduct_laguerre (n : ℕ) (a : ℝ) : + gammaSchurProduct (fun i : Fin n => a+i.val) = laguerreNormalizerProduct n a := by + unfold gammaSchurProduct laguerreNormalizerProduct + congr 1 + apply Finset.prod_congr rfl + intro i _ + apply Finset.prod_congr rfl + intro j _ + congr 1 <;> ring + +lemma laguerreNormalizer_succ_product (n : ℕ) {a : ℝ} (ha : 0 < a) : + laguerreNormalizer (n+1) a = Real.Gamma a * + (∏ i : Fin n, ((i.val:ℝ)+1)/(2*a+i.val+1)) * laguerreNormalizer n (a+1) := by + rw [laguerreNormalizer_eq_product _ ha, + ← gammaSchurProduct_laguerre, laguerreNormalizer_eq_product _ (by linarith : 0 a+i.val) = Fin.cons a (fun i => (a+1)+i.val) := by + ext i + refine Fin.cases ?_ (fun i => ?_) i + · simp + · simp only [Fin.cons_succ, Fin.val_succ, Nat.cast_add, Nat.cast_one] + ring + rw [hq, gammaSchurProduct_cons] + congr 2 + apply Finset.prod_congr rfl + intro i _ + congr 1 <;> ring + +lemma gammaSchurProduct_inverse (n : ℕ) {a : ℝ} (ha : 1 < a) : + gammaSchurProduct (inverseExponents n a) = Real.Gamma (a-1) * + (∏ i : Fin n, ((i.val:ℝ)+2)/(2*a+i.val)) * laguerreNormalizer n (a+1) := by + have he : inverseExponents n a = Fin.cons (a-1) (fun i => (a+1)+i.val) := by + ext i + refine Fin.cases ?_ (fun i => ?_) i + · rfl + · simp only [inverseExponents, Fin.cons_succ] + ring + rw [he, gammaSchurProduct_cons, gammaSchurProduct_laguerre, + laguerreNormalizer_eq_product _ (by linarith : 0 < a+1)] + congr 2 + apply Finset.prod_congr rfl + intro i _ + congr 1 <;> ring + +lemma telescoping_inverse_product (n : ℕ) {b : ℝ} (hb : 0 < b) : + (∏ i : Fin n, ((i.val:ℝ)+2)/(b+i.val)) = + ((n:ℝ)+1)*(b+n)/b * (∏ i : Fin n, ((i.val:ℝ)+1)/(b+i.val+1)) := by + induction n with + | zero => simp [hb.ne'] + | succ n ih => + rw [Fin.prod_univ_castSucc, Fin.prod_univ_castSucc] + simp only [Fin.val_castSucc, Fin.val_last, Nat.cast_add, Nat.cast_one] + rw [ih] + have hn : b+(n:ℝ) ≠ 0 := by positivity + have hn1 : b+(n:ℝ)+1 ≠ 0 := by positivity + field_simp + ring + + +end +end CriticalStrip + +end OAI diff --git a/lean/OAI/Combinatorics/StripMass/LaguerreScaling.lean b/lean/OAI/Combinatorics/StripMass/LaguerreScaling.lean new file mode 100644 index 0000000000000000000000000000000000000000..73a9d938434382c98f8c081bd324727e28e4c69b --- /dev/null +++ b/lean/OAI/Combinatorics/StripMass/LaguerreScaling.lean @@ -0,0 +1,431 @@ +import Mathlib +import OAI.Combinatorics.StripMass.WeightComparison + +namespace OAI + +/-! Critical honeycomb strip paths, polynomial identities and crossing mass. -/ + + +namespace CriticalStrip +noncomputable section +open scoped BigOperators Pointwise +open Set MeasureTheory Filter +lemma integral_scaledLaguerre_cutoff_inverseQuarter (N : ℕ) (a R : ℝ) {β : ℝ} (hb : 0 < β) : + (laguerreDensityScale N a β * (β ^ (1 / 4 : ℝ))⁻¹) * + (∫ y in orderedChamber N (Ioo 0 R), inverseQuarterStatistic N y * scaledLaguerreDensity N a β y) = + (β ^ N)⁻¹ * (∫ r in orderedChamber N (Ioo 0 (β * R)), + inverseQuarterStatistic N r * laguerreDensity N a r) := by + rw [← integral_const_mul] + calc + (∫ y in orderedChamber N (Ioo 0 R), (laguerreDensityScale N a β * (β ^ (1 / 4 : ℝ))⁻¹) * + (inverseQuarterStatistic N y * scaledLaguerreDensity N a β y)) = + ∫ y in orderedChamber N (Ioo 0 R), inverseQuarterStatistic N (β • y) * + laguerreDensity N a (β • y) := by + apply setIntegral_congr_fun (measurableSet_orderedChamber_Ioo N R) + intro y hy + dsimp only [inverseQuarterStatistic] + rw [laguerreDensity_scaled a hb (fun i => (hy.2 i).1), + inverseQuarterSum_smul hb (fun i => (hy.2 i).1)] + ring + _ = _ := integral_orderedChamber_scaled R hb + (fun r => inverseQuarterStatistic N r * laguerreDensity N a r) + +lemma laguerre_cutoffNormalizer_pos (N : ℕ) {a R : ℝ} (ha : 0 < a) (hR : 0 < R) : + 0 < ∫ r in orderedChamber N (Ioo 0 R), laguerreDensity N a r := by + have h := laguerreLaw_cutoff_pos N ha hR + rw [laguerreLaw_measureReal N ha (measurableSet_cutoffEvent N R), + ← orderedChamber_eq_laguerre_cutoff] at h + exact (div_pos_iff_of_pos_right (laguerreNormalizer_pos N ha)).1 h + +lemma scaled_quotient {A Z B W c J p : ℝ} (hc : c ≠ 0) (hJ : J ≠ 0) (hp : p ≠ 0) + (h0 : c * Z = J * W) (h1 : (c * p⁻¹) * A = J * B) : + A / Z = p * (B / W) := by + have hZ : Z = J * W / c := (eq_div_iff hc).2 (by simpa [mul_comm] using h0) + have hA : A = J * B / (c * p⁻¹) := (eq_div_iff (mul_ne_zero hc (inv_ne_zero hp))).2 + (by simpa [mul_comm] using h1) + rw [hZ, hA] + field_simp + + + +theorem scaled_reference_cutoff_inverseQuarter (N : ℕ) (a R : ℝ) {β : ℝ} (hb : 0 < β) : + (∫ y in orderedChamber N (Ioo 0 R), inverseQuarterStatistic N y * scaledLaguerreDensity N a β y) / + (∫ y in orderedChamber N (Ioo 0 R), scaledLaguerreDensity N a β y) = + β ^ (1 / 4 : ℝ) * + ((∫ r in orderedChamber N (Ioo 0 (β * R)), inverseQuarterStatistic N r * laguerreDensity N a r) / + (∫ r in orderedChamber N (Ioo 0 (β * R)), laguerreDensity N a r)) := by + exact scaled_quotient (laguerreDensityScale_pos N a hb).ne' + (inv_ne_zero (pow_ne_zero _ hb.ne')) (Real.rpow_pos_of_pos hb _).ne' + (integral_scaledLaguerre_cutoff N a R hb) (integral_scaledLaguerre_cutoff_inverseQuarter N a R hb) + +lemma integral_positiveLaw_cutoff (N : ℕ) (R : ℝ) (f : (Fin N → ℝ) → ℝ) : + (∫ y in cutoffEvent N R, f y ∂positiveLaw N) = + (∫ y in orderedDomain N ∩ cutoffEvent N R, f y * density N y) / normalizer N := by + rw [← integral_indicator (measurableSet_cutoffEvent N R), integral_positiveLaw N] + unfold expectation + simp_rw [← Set.indicator_mul_left] + rw [setIntegral_indicator (measurableSet_cutoffEvent N R)] + +lemma positiveLaw_conditioned_eq (N : ℕ) {R : ℝ} (hR : R ≤ 1) (f : (Fin N → ℝ) → ℝ) : + (∫ y in cutoffEvent N R, f y ∂positiveLaw N) / + (positiveLaw N).real (cutoffEvent N R) = + (∫ y in orderedChamber N (Ioo 0 R), f y * density N y) / + (∫ y in orderedChamber N (Ioo 0 R), density N y) := by + rw [integral_positiveLaw_cutoff, positiveLaw_measureReal N (measurableSet_cutoffEvent N R), + ← orderedChamber_eq_positive_cutoff N hR, + div_div_div_cancel_right₀ (normalizer_pos N).ne'] + +lemma integral_laguerreLaw_cutoff (N : ℕ) {a : ℝ} (ha : 0 < a) (R : ℝ) + (f : (Fin N → ℝ) → ℝ) : + (∫ r in cutoffEvent N R, f r ∂laguerreLaw N a) = + (∫ r in orderedChamber N (Ioo 0 R), f r * laguerreDensity N a r) / laguerreNormalizer N a := by + rw [orderedChamber_eq_laguerre_cutoff, ← integral_indicator (measurableSet_cutoffEvent N R), + integral_laguerreLaw N ha] + unfold laguerreExpectation + simp_rw [← Set.indicator_mul_left] + rw [setIntegral_indicator (measurableSet_cutoffEvent N R)] + +lemma laguerreLaw_conditioned_eq (N : ℕ) {a : ℝ} (ha : 0 < a) (R : ℝ) + (f : (Fin N → ℝ) → ℝ) : + (∫ r in cutoffEvent N R, f r ∂laguerreLaw N a) / + (laguerreLaw N a).real (cutoffEvent N R) = + (∫ r in orderedChamber N (Ioo 0 R), f r * laguerreDensity N a r) / + (∫ r in orderedChamber N (Ioo 0 R), laguerreDensity N a r) := by + rw [integral_laguerreLaw_cutoff N ha, + laguerreLaw_measureReal N ha (measurableSet_cutoffEvent N R), + ← orderedChamber_eq_laguerre_cutoff, div_div_div_cancel_right₀ (laguerreNormalizer_pos N ha).ne'] + + + +theorem positiveLaw_inverseQuarter_le_reference (N : ℕ) {β : ℝ} (hb : 4 ≤ β) : + (∫ y, inverseQuarterStatistic N y ∂positiveLaw N) ≤ + β ^ (1 / 4 : ℝ) * (∫ r, inverseQuarterStatistic N r ∂laguerreLaw N (1 / 2)) / + (laguerreLaw N (1 / 2)).real (cutoffEvent N (β / 2)) := by + have hb0 : 0 < β := by linarith + have hp := laguerreLaw_cutoff_pos N (by norm_num : (0:ℝ)<1/2) (by positivity : 0 < β / 2) + have hcut : (∫ r in cutoffEvent N (β / 2), inverseQuarterStatistic N r ∂laguerreLaw N (1/2)) ≤ + ∫ r, inverseQuarterStatistic N r ∂laguerreLaw N (1/2) := by + apply setIntegral_le_integral (integrable_laguerreLaw_inverseQuarterSum (by norm_num : (1/4:ℝ)<1/2)) + filter_upwards [ae_laguerreDomain N (1/2)] with r hr + exact inverseQuarterStatistic_nonneg hr.2 + calc + _ ≤ (∫ y in cutoffEvent N (1/2), inverseQuarterStatistic N y ∂positiveLaw N) / + (positiveLaw N).real (cutoffEvent N (1/2)) := positiveLaw_cutoff_inverseQuarterSum (by norm_num) + _ = (∫ y in orderedChamber N (Ioo 0 (1/2)), inverseQuarterStatistic N y * density N y) / + (∫ y in orderedChamber N (Ioo 0 (1/2)), density N y) := positiveLaw_conditioned_eq N (by norm_num) _ + _ ≤ _ := positive_half_inverseQuarter_le_scaled_reference N hb + _ = β ^ (1/4:ℝ) * + ((∫ r in cutoffEvent N (β/2), inverseQuarterStatistic N r ∂laguerreLaw N (1/2)) / + (laguerreLaw N (1/2)).real (cutoffEvent N (β/2))) := by + rw [scaled_reference_cutoff_inverseQuarter N (1/2) (1/2) hb0, + laguerreLaw_conditioned_eq N (by norm_num)] + simp only [mul_one_div] + _ ≤ _ := by + rw [mul_div_assoc] + exact mul_le_mul_of_nonneg_left (div_le_div_of_nonneg_right hcut hp.le) + (Real.rpow_pos_of_pos hb0 _).le + + + + + + +def mobiusMap (N : ℕ) (z : Fin N → ℝ) : Fin N → ℝ := fun i => mobiusCoordinate (z i) + +lemma mobiusInverse_mem {y : ℝ} (hy : y ∈ Ioo 0 1) : y / (2 - y) ∈ Ioo 0 1 := by + have hd : 0 < 2 - y := by linarith [hy.2] + exact ⟨div_pos hy.1 hd, (div_lt_one hd).2 (by linarith [hy.2])⟩ + +lemma mobiusCoordinate_inverse {y : ℝ} (hy : y < 1) : + mobiusCoordinate (y / (2 - y)) = y := by + have hd : 2 - y ≠ 0 := by linarith + unfold mobiusCoordinate + field_simp + ring + +lemma inverse_mobiusCoordinate {z : ℝ} (hz : 0 < z) : + mobiusCoordinate z / (2 - mobiusCoordinate z) = z := by + have hd : 1 + z ≠ 0 := by positivity + unfold mobiusCoordinate + field_simp + ring + +lemma mobiusMap_mem {N : ℕ} {z : Fin N → ℝ} (hz : z ∈ orderedDomain N) : + mobiusMap N z ∈ orderedDomain N := by + exact ⟨fun i j hij => mobiusCoordinate_strictMonoOn (hz.2 i).1 (hz.2 j).1 (hz.1 hij), + fun i => mobiusCoordinate_mem (hz.2 i)⟩ + +lemma mobiusMap_injOn (N : ℕ) : InjOn (mobiusMap N) (orderedDomain N) := by + intro x hx y hy h + funext i + exact mobiusCoordinate_strictMonoOn.injOn (hx.2 i).1 (hy.2 i).1 (congrFun h i) + +lemma mobiusMap_image (N : ℕ) : mobiusMap N '' orderedDomain N = orderedDomain N := by + apply Subset.antisymm + · rintro _ ⟨x, hx, rfl⟩ + exact mobiusMap_mem hx + · intro y hy + let x : Fin N → ℝ := fun i => y i / (2 - y i) + have heq : mobiusMap N x = y := funext fun i => mobiusCoordinate_inverse (hy.2 i).2 + refine ⟨x, ⟨?_, fun i => mobiusInverse_mem (hy.2 i)⟩, heq⟩ + intro i j hij + have h := hy.1 hij + rw [← congrFun heq i, ← congrFun heq j] at h + exact (mobiusCoordinate_strictMonoOn.lt_iff_lt (mobiusInverse_mem (hy.2 i)).1 + (mobiusInverse_mem (hy.2 j)).1).1 h + +lemma hasDerivAt_mobiusCoordinate {z : ℝ} (hz : 0 < z) : + HasDerivAt mobiusCoordinate (2 / (1 + z)^2) z := by + have hd : (1 : ℝ) + id z ≠ 0 := by change 1 + z ≠ 0; positivity + apply (((hasDerivAt_id z).const_mul 2).div ((hasDerivAt_id z).const_add 1) hd).congr_deriv + simp only [id_eq, mul_one] + ring + + +def mobiusDifferential (N : ℕ) (z : Fin N → ℝ) : (Fin N → ℝ) →L[ℝ] (Fin N → ℝ) := + ContinuousLinearMap.pi fun i => + (ContinuousLinearMap.toSpanSingleton ℝ (2 / (1 + z i)^2)).comp (ContinuousLinearMap.proj i) + +lemma hasFDerivAt_mobiusMap {N : ℕ} {z : Fin N → ℝ} (hz : ∀ i, 0 < z i) : + HasFDerivAt (mobiusMap N) (mobiusDifferential N z) z := by + unfold mobiusMap mobiusDifferential + rw [hasFDerivAt_pi] + intro i + have h1 : HasFDerivAt mobiusCoordinate + (ContinuousLinearMap.toSpanSingleton ℝ (2 / (1 + z i)^2)) (z i) := + (hasDerivAt_mobiusCoordinate (hz i)).hasFDerivAt + simpa only [Function.comp_def, ContinuousLinearMap.proj_apply] using + h1.comp z ((ContinuousLinearMap.proj i : (Fin N → ℝ) →L[ℝ] ℝ).hasFDerivAt) + +def mobiusJacobian (N : ℕ) (z : Fin N → ℝ) : ℝ := ∏ i, 2 / (1 + z i)^2 + +lemma det_mobiusDifferential (N : ℕ) (z : Fin N → ℝ) : + (mobiusDifferential N z).det = mobiusJacobian N z := by + simp only [mobiusDifferential, ContinuousLinearMap.det_pi, + ContinuousLinearMap.det_toSpanSingleton, mobiusJacobian] + +lemma mobiusJacobian_pos {N : ℕ} {z : Fin N → ℝ} (hz : ∀ i, 0 < z i) : + 0 < mobiusJacobian N z := by + exact Finset.prod_pos fun i _ => div_pos (by norm_num) (sq_pos_of_pos (by linarith [hz i])) + + + +theorem integral_mobiusMap (N : ℕ) (g : (Fin N → ℝ) → ℝ) : + (∫ y in orderedDomain N, g y) = + ∫ z in orderedDomain N, mobiusJacobian N z * g (mobiusMap N z) := by + have h := integral_image_eq_integral_abs_det_fderiv_smul volume + (isOpen_orderedDomain N).measurableSet + (fun z hz => (hasFDerivAt_mobiusMap (fun i => (hz.2 i).1)).hasFDerivWithinAt) + (mobiusMap_injOn N) g + rw [mobiusMap_image] at h + apply h.trans + apply setIntegral_congr_fun (isOpen_orderedDomain N).measurableSet + intro z hz + dsimp only + rw [det_mobiusDifferential, abs_of_pos (mobiusJacobian_pos (fun i => (hz.2 i).1)), smul_eq_mul] + +lemma integrableOn_mobiusMap_iff (N : ℕ) (g : (Fin N → ℝ) → ℝ) : + IntegrableOn g (orderedDomain N) ↔ + IntegrableOn (fun z => mobiusJacobian N z * g (mobiusMap N z)) (orderedDomain N) := by + have h := integrableOn_image_iff_integrableOn_abs_det_fderiv_smul volume + (isOpen_orderedDomain N).measurableSet + (fun z hz => (hasFDerivAt_mobiusMap (fun i => (hz.2 i).1)).hasFDerivWithinAt) + (mobiusMap_injOn N) g + rw [mobiusMap_image] at h + apply h.trans + apply integrable_congr + filter_upwards [ae_restrict_mem (isOpen_orderedDomain N).measurableSet] with z hz + rw [det_mobiusDifferential, abs_of_pos (mobiusJacobian_pos (fun i => (hz.2 i).1)), smul_eq_mul] + +lemma prod_pair_coordinates {N : ℕ} (f : Fin N → ℝ) : + (∏ i, ∏ j ∈ Finset.Ioi i, f i * f j) = (∏ i, f i) ^ (N - 1) := by + have h := Finset.prod_prod_Ioi_mul_eq_prod_prod_off_diag (fun i _ : Fin N => f i) + simp only [mul_comm] at h + rw [h] + have heq (i : Fin N) : (∏ j ∈ ({i}ᶜ : Finset (Fin N)), f j) = + ∏ j : Fin N, if i ≠ j then f j else 1 := by + rw [← Finset.prod_filter] + congr 1 + ext j + simp [ne_comm] + simp_rw [heq] + rw [Finset.prod_comm] + have heq' (j : Fin N) : (∏ i : Fin N, if i ≠ j then f j else 1) = f j ^ (N - 1) := by + rw [← Finset.prod_filter] + have hset : (Finset.univ.filter fun i : Fin N => i ≠ j) = {j}ᶜ := by + ext i + simp + rw [hset] + simp only [Finset.prod_const, Finset.card_compl, Finset.card_singleton, Fintype.card_fin] + simp_rw [heq'] + rw [Finset.prod_pow] + + +def mobiusDensityConstant (N : ℕ) : ℝ := + (∏ _ : Fin N, (2 : ℝ)) * ∏ i : Fin N, ∏ _j ∈ Finset.Ioi i, (2 : ℝ) + +lemma mobiusDensityConstant_pos (N : ℕ) : 0 < mobiusDensityConstant N := by + exact mul_pos (Finset.prod_pos fun _ _ => by norm_num) + (Finset.prod_pos fun _ _ => Finset.prod_pos fun _ _ => by norm_num) + +lemma prod_pairKernel_mobius {N : ℕ} {z : Fin N → ℝ} (hz : ∀ i, 0 < z i) : + (∏ i, ∏ j ∈ Finset.Ioi i, pairKernel (mobiusCoordinate (z i)) (mobiusCoordinate (z j))) = + (∏ i : Fin N, ∏ _j ∈ Finset.Ioi i, (2 : ℝ)) * (∏ i, ∏ j ∈ Finset.Ioi i, pairKernel (z i) (z j)) * + (∏ i, ∏ j ∈ Finset.Ioi i, mobiusPairFactor (z i) (z j)) / (∏ i : Fin N, (1 + z i)) ^ (N - 1) := by + have h (i j : Fin N) : pairKernel (mobiusCoordinate (z i)) (mobiusCoordinate (z j)) = + 2 * pairKernel (z i) (z j) * mobiusPairFactor (z i) (z j) / ((1 + z i) * (1 + z j)) := by + rw [pairKernel_mobius (hz i) (hz j)] + simp only [mobiusPairFactor, div_eq_mul_inv, mul_inv_rev] + ring + simp_rw [h, Finset.prod_div_distrib, Finset.prod_mul_distrib] + have hd := prod_pair_coordinates (fun i => 1 + z i) + simp only [Finset.prod_mul_distrib] at hd + rw [hd] + +lemma scaledWeight_mul_lowerLikelihoodWeight (N : ℕ) (β z : ℝ) : + scaledLaguerreWeight 1 β z * lowerLikelihoodWeight N β z = + omega (mobiusCoordinate z) / (1 + z) ^ (N + 1) := by + unfold scaledLaguerreWeight lowerLikelihoodWeight + norm_num only [sub_self, Real.rpow_zero, one_mul] + calc + _ = omega (mobiusCoordinate z) / (1 + z) ^ (N + 1) * + (Real.exp (-(β * z)) * Real.exp (β * z)) := by ring + _ = _ := by rw [← Real.exp_add]; simp + +lemma scaledDensity_mul_lowerLikelihood (N : ℕ) (β : ℝ) (z : Fin N → ℝ) : + scaledLaguerreDensity N 1 β z * lowerLikelihood N β z = + (∏ i, omega (mobiusCoordinate (z i))) / (∏ i : Fin N, (1 + z i)) ^ (N + 1) * + (∏ i, ∏ j ∈ Finset.Ioi i, pairKernel (z i) (z j)) * + (∏ i, ∏ j ∈ Finset.Ioi i, mobiusPairFactor (z i) (z j)) := by + have hw : (∏ i, scaledLaguerreWeight 1 β (z i)) * + (∏ i, lowerLikelihoodWeight N β (z i)) = + (∏ i, omega (mobiusCoordinate (z i))) / (∏ i : Fin N, (1 + z i)) ^ (N + 1) := by + rw [← Finset.prod_mul_distrib] + simp_rw [scaledWeight_mul_lowerLikelihoodWeight, + Finset.prod_div_distrib, Finset.prod_pow] + unfold scaledLaguerreDensity rawProductDensity lowerLikelihood + change ((∏ i, scaledLaguerreWeight 1 β (z i)) * _) * ((∏ i, lowerLikelihoodWeight N β (z i)) * _) = _ + rw [mul_mul_mul_comm, hw] + have hI (i : Fin N) : Finset.univ.filter (i < ·) = Finset.Ioi i := by ext j; simp + simp_rw [hI] + ring + + + +theorem density_mobiusMap {N : ℕ} (β : ℝ) {z : Fin N → ℝ} (hz : ∀ i, 0 < z i) : + mobiusJacobian N z * density N (mobiusMap N z) = + mobiusDensityConstant N * (scaledLaguerreDensity N 1 β z * lowerLikelihood N β z) := by + cases N with + | zero => simp [mobiusJacobian, density, mobiusDensityConstant, + scaledLaguerreDensity, rawProductDensity, lowerLikelihood] + | succ n => + rw [scaledDensity_mul_lowerLikelihood] + unfold density mobiusMap mobiusJacobian mobiusDensityConstant + simp only [Finset.prod_div_distrib, Finset.prod_pow] + rw [prod_pairKernel_mobius hz] + simp only [Nat.add_sub_cancel] + have hd : (∏ i : Fin (n + 1), (1 + z i)) ≠ 0 := Finset.prod_ne_zero_iff.mpr fun i _ => by linarith [hz i] + field_simp + ring + +lemma jacobian_weighted_density {N : ℕ} (β : ℝ) (g : (Fin N → ℝ) → ℝ) + {z : Fin N → ℝ} (hz : z ∈ orderedDomain N) : + mobiusJacobian N z * (g (mobiusMap N z) * density N (mobiusMap N z)) = + mobiusDensityConstant N * (scaledLaguerreDensity N 1 β z * + (g (mobiusMap N z) * lowerLikelihood N β z)) := by + calc + _ = g (mobiusMap N z) * (mobiusJacobian N z * density N (mobiusMap N z)) := by ring + _ = _ := by rw [density_mobiusMap β (fun i => (hz.2 i).1)]; ring + +lemma integral_density_mobius_likelihood (N : ℕ) (β : ℝ) (g : (Fin N → ℝ) → ℝ) : + (∫ y in orderedDomain N, g y * density N y) = + mobiusDensityConstant N * ∫ z in orderedDomain N, + scaledLaguerreDensity N 1 β z * (g (mobiusMap N z) * lowerLikelihood N β z) := by + rw [integral_mobiusMap, ← integral_const_mul] + exact setIntegral_congr_fun (isOpen_orderedDomain N).measurableSet + (fun z hz => jacobian_weighted_density β g hz) + +lemma integrableOn_density_mobius_likelihood_iff (N : ℕ) (β : ℝ) (g : (Fin N → ℝ) → ℝ) : + IntegrableOn (fun y => g y * density N y) (orderedDomain N) ↔ + IntegrableOn (fun z => scaledLaguerreDensity N 1 β z * + (g (mobiusMap N z) * lowerLikelihood N β z)) (orderedDomain N) := by + rw [integrableOn_mobiusMap_iff] + have heq : (fun z => mobiusJacobian N z * (g (mobiusMap N z) * density N (mobiusMap N z))) + =ᵐ[volume.restrict (orderedDomain N)] + (fun z => mobiusDensityConstant N * (scaledLaguerreDensity N 1 β z * + (g (mobiusMap N z) * lowerLikelihood N β z))) := by + filter_upwards [ae_restrict_mem (isOpen_orderedDomain N).measurableSet] with z hz + exact jacobian_weighted_density β g hz + unfold IntegrableOn + rw [integrable_congr heq] + exact integrable_const_mul_iff (isUnit_iff_ne_zero.mpr (mobiusDensityConstant_pos N).ne') _ + +lemma mobiusLikelihood_Normalizer (N : ℕ) (β : ℝ) : + normalizer N = mobiusDensityConstant N * + ∫ z in orderedDomain N, scaledLaguerreDensity N 1 β z * lowerLikelihood N β z := by + simpa only [one_mul, normalizer] using integral_density_mobius_likelihood N β (fun _ => 1) + +lemma integrableOn_mobiusLikelihood (N : ℕ) (β : ℝ) : + IntegrableOn (fun z => scaledLaguerreDensity N 1 β z * lowerLikelihood N β z) (orderedDomain N) := by + simpa only [one_mul] using + (integrableOn_density_mobius_likelihood_iff N β (fun _ => 1)).1 + (by simpa only [one_mul] using integrableOn_density N) + +lemma mobiusLikelihood_Normalizer_pos (N : ℕ) (β : ℝ) : + 0 < ∫ z in orderedDomain N, scaledLaguerreDensity N 1 β z * lowerLikelihood N β z := by + have h := normalizer_pos N + rw [mobiusLikelihood_Normalizer N β] at h + exact (mul_pos_iff_of_pos_left (mobiusDensityConstant_pos N)).1 h + +lemma continuousOn_mobiusCoordinate : ContinuousOn mobiusCoordinate (Ioi 0) := by + exact (continuous_const.mul continuous_id).continuousOn.div + (continuous_const.add continuous_id).continuousOn (fun z hz => (add_pos (by norm_num : (0:ℝ) < 1) hz).ne') + +lemma continuousOn_lowerLikelihood (N : ℕ) (β : ℝ) : + ContinuousOn (lowerLikelihood N β) (coordinateBox (Fin N) (Ioo 0 1)) := by + unfold lowerLikelihood + apply ContinuousOn.mul + · apply continuousOn_finsetProd + intro i _ + have hmob : ContinuousOn (fun z : Fin N → ℝ => mobiusCoordinate (z i)) + (coordinateBox (Fin N) (Ioo 0 1)) := + continuousOn_mobiusCoordinate.comp (continuous_apply i).continuousOn (fun z hz => (hz i).1) + exact (continuousOn_omega_Ioi.comp hmob (fun z hz => (mobiusCoordinate_mem (hz i)).1)).mul + ((Real.continuous_exp.comp (continuous_const.mul (continuous_apply i))).continuousOn.div + ((continuous_const.add (continuous_apply i)).pow (N + 1)).continuousOn + (fun z hz => pow_ne_zero _ (by linarith [(hz i).1]))) + · apply continuousOn_finsetProd + intro i _ + apply continuousOn_finsetProd + intro j _ + have hq : ContinuousOn (fun z : Fin N → ℝ => 2 * z i * z j / (z i + z j)) + (coordinateBox (Fin N) (Ioo 0 1)) := + ((continuous_const.mul (continuous_apply i)).mul (continuous_apply j)).continuousOn.div + ((continuous_apply i).add (continuous_apply j)).continuousOn + (fun z hz => (add_pos (hz i).1 (hz j).1).ne') + exact (continuousOn_const.add hq).inv₀ (fun z hz => + (add_pos (by norm_num : (0:ℝ)<1) + (div_pos (mul_pos (mul_pos (by norm_num) (hz i).1) (hz j).1) + (add_pos (hz i).1 (hz j).1))).ne') + +lemma mobiusCoordinate_le_double {z : ℝ} (hz : 0 < z) : mobiusCoordinate z ≤ 2 * z := by + apply (div_le_iff₀ (by linarith : 0 < 1 + z)).2 + nlinarith [sq_nonneg z] + +lemma self_le_mobiusCoordinate {z : ℝ} (hz : z ∈ Ioo 0 1) : z ≤ mobiusCoordinate z := by + apply (le_div_iff₀ (by linarith [hz.1] : 0 < 1 + z)).2 + nlinarith [mul_nonneg hz.1.le (sub_nonneg.mpr hz.2.le)] + +lemma mobius_inverseQuarter_bounds {z : ℝ} (hz : z ∈ Ioo 0 1) : + (2 : ℝ) ^ (-(1/4:ℝ)) * z ^ (-(1/4:ℝ)) ≤ (mobiusCoordinate z) ^ (-(1/4:ℝ)) ∧ + (mobiusCoordinate z) ^ (-(1/4:ℝ)) ≤ z ^ (-(1/4:ℝ)) := by + constructor + · rw [← Real.mul_rpow (by norm_num : (0:ℝ)≤2) hz.1.le] + exact Real.rpow_le_rpow_of_nonpos (mobiusCoordinate_mem hz).1 + (mobiusCoordinate_le_double hz.1) (by norm_num) + · exact Real.rpow_le_rpow_of_nonpos hz.1 (self_le_mobiusCoordinate hz) (by norm_num) + +end +end CriticalStrip + +end OAI diff --git a/lean/OAI/Combinatorics/StripMass/LaguerreTails.lean b/lean/OAI/Combinatorics/StripMass/LaguerreTails.lean new file mode 100644 index 0000000000000000000000000000000000000000..5a9fd9c1b115b76e7d2ff0116339db756509b491 --- /dev/null +++ b/lean/OAI/Combinatorics/StripMass/LaguerreTails.lean @@ -0,0 +1,409 @@ +import Mathlib +import OAI.Combinatorics.StripMass.TailIntegrals + +namespace OAI + +/-! Critical honeycomb strip paths, polynomial identities and crossing mass. -/ + + +namespace CriticalStrip +noncomputable section +open scoped BigOperators +open Set MeasureTheory +theorem laguerreLaw_small_coordinate_le {N : ℕ} {a h : ℝ} + (ha : 0 < a) (hh : 0 < h) (i : Fin N) : + (laguerreLaw N a).real {r | r i < h} ≤ + min 1 (laguerreSmallCoefficient N a (i.val + 1) * + h ^ laguerreDimension a (i.val + 1)) := by + let := laguerreLaw_isProbabilityMeasure N ha + refine le_min (measureReal_le_one (μ := laguerreLaw N a)) ?_ + have H := laguerreLaw_small_coordinate_le_normalizer_ratio ha hh i + apply H.trans_eq + simp only [laguerreSmallCoefficient, Nat.cast_add, Nat.cast_one] + ring + +theorem laguerreLaw_small_coordinate_power_bound {N : ℕ} {a h : ℝ} + (ha : 0 < a) (hh : 0 < h) (i : Fin N) : + (laguerreLaw N a).real {r | r i < h} ≤ + (laguerreSmallCoefficient N a (i.val + 1) ^ + (1 / laguerreDimension a (i.val + 1)) * h) ^ laguerreDimension a (i.val + 1) := by + have hb := laguerreSmallCoefficient_pos N (i.val + 1) ha + have hD := laguerreDimension_pos ha (show 1 ≤ i.val + 1 by omega) + have H := (laguerreLaw_small_coordinate_le ha hh i).trans (min_le_right _ _) + rw [Real.mul_rpow (Real.rpow_pos_of_pos hb _).le hh.le, + ← Real.rpow_mul hb.le, one_div_mul_cancel hD.ne', Real.rpow_one] + exact H + + + +theorem integrable_inverse_of_small_tail {α : Type*} [MeasurableSpace α] + {μ : Measure α} [IsProbabilityMeasure μ] {X : α → ℝ} + (hX : ∀ᵐ x ∂μ, 0 < X x) {A D p : ℝ} (hA : 0 < A) (hp : 0 < p) + (hpD : p < D) (hXm : AEMeasurable X μ) + (htail : ∀ h > 0, μ.real {x | X x < h} ≤ (A * h) ^ D) : + Integrable (fun x => (X x) ^ (-p)) μ := by + have hq : 1 < D / p := (lt_div_iff₀ hp).2 (by simpa using hpD) + have hnn : 0 ≤ᵐ[μ] (fun x => (X x) ^ (-p)) := by + filter_upwards [hX] with x hx + exact (Real.rpow_pos_of_pos hx _).le + apply integrable_of_power_tail (hXm.pow_const _) hnn (Real.rpow_pos_of_pos hA p) hq + intro t ht + have htpos : 0 < t := (Real.rpow_pos_of_pos hA p).trans ht + have htpow : 0 < t ^ (-1 / p) := Real.rpow_pos_of_pos htpos _ + have hsets : {x | t < (X x) ^ (-p)} =ᵐ[μ] {x | X x < t ^ (-1 / p)} := by + filter_upwards [hX] with x hx + have hh := Real.rpow_lt_rpow_iff_of_neg htpow hx (by linarith : -p < 0) + rw [← Real.rpow_mul htpos.le, show (-1 / p) * -p = (1 : ℝ) by field_simp, Real.rpow_one] at hh + exact propext hh + have hmeas : μ.real {x | t < (X x) ^ (-p)} = μ.real {x | X x < t ^ (-1 / p)} := + congrArg ENNReal.toReal (measure_congr hsets) + rw [hmeas] + calc + _ ≤ (A * t ^ (-1 / p)) ^ D := htail _ htpow + _ = (A ^ p) ^ (D / p) * t ^ (-(D / p)) := by + rw [Real.mul_rpow hA.le htpow.le, ← Real.rpow_mul htpos.le, ← Real.rpow_mul hA.le, + show p * (D / p) = D by field_simp, + show (-1 / p) * D = -(D / p) by ring] + + +theorem integrable_laguerreLaw_inverse_coordinate_full {N : ℕ} {a p : ℝ} + (ha : 0 < a) (i : Fin N) (hpD : p < laguerreDimension a (i.val + 1)) : + Integrable (fun r => (r i) ^ (-p)) (laguerreLaw N a) := by + by_cases hp : 0 < p + · let := laguerreLaw_isProbabilityMeasure N ha + apply integrable_inverse_of_small_tail (D := laguerreDimension a (i.val + 1)) + (A := laguerreSmallCoefficient N a (i.val + 1) ^ (1 / laguerreDimension a (i.val + 1))) + ?_ (Real.rpow_pos_of_pos (laguerreSmallCoefficient_pos _ _ ha) _) hp hpD + (measurable_pi_apply i).aemeasurable + (fun h hh => laguerreLaw_small_coordinate_power_bound ha hh i) + filter_upwards [ae_laguerreDomain N a] with r hr + exact hr.2 i + · apply integrable_laguerreLaw_inverse_coordinate ha i + have hi : (0 : ℝ) ≤ i.val := by positivity + linarith + + + +theorem laguerre_inverse_bound_normalizer_ratio {N : ℕ} {a p : ℝ} + (ha : 0 < a) (i : Fin N) (hp : 0 < p) + (hpD : p < laguerreDimension a (i.val + 1)) : + laguerreExpectation N a (fun r => (r i) ^ (-p)) ≤ + laguerreDimension a (i.val + 1) / (laguerreDimension a (i.val + 1) - p) * + laguerreSmallCoefficient N a (i.val + 1) ^ (p / laguerreDimension a (i.val + 1)) := by + let := laguerreLaw_isProbabilityMeasure N ha + rw [← integral_laguerreLaw N ha] + have hX : ∀ᵐ r ∂laguerreLaw N a, 0 < r i := by + filter_upwards [ae_laguerreDomain N a] with r hr + exact hr.2 i + have hb := laguerreSmallCoefficient_pos N (i.val + 1) ha + have H := integral_inverse_le_of_small_tail hX + (Real.rpow_pos_of_pos hb (1 / laguerreDimension a (i.val + 1))) hp hpD + (measurable_pi_apply i).aemeasurable + (fun h hh => laguerreLaw_small_coordinate_power_bound ha hh i) + simpa only [← Real.rpow_mul hb.le, one_div_mul_eq_div] using H + + + + + +theorem pairProduct_snoc {n : ℕ} (x : ℝ) (r : Fin n → ℝ) : + (∏ i : Fin (n + 1), ∏ j ∈ Finset.Ioi i, + pairKernel ((Fin.snoc r x : Fin (n + 1) → ℝ) i) ((Fin.snoc r x : Fin (n + 1) → ℝ) j)) = + (∏ i, ∏ j ∈ Finset.Ioi i, pairKernel (r i) (r j)) * ∏ i, pairKernel (r i) x := by + classical + have he {m : ℕ} (s : Fin m → ℝ) : + (∏ i : Fin m, ∏ j ∈ Finset.Ioi i, pairKernel (s i) (s j)) = + ∏ i : Fin m, ∏ j : Fin m, if i < j then pairKernel (s i) (s j) else 1 := by + apply Finset.prod_congr rfl + intro i _ + rw [← Finset.prod_filter] + congr 1 + ext j + simp + rw [he, he] + simp [Fin.prod_univ_castSucc, Finset.prod_mul_distrib, not_lt.mpr (Fin.le_last _)] + +theorem laguerreDensity_snoc {n : ℕ} (a x : ℝ) (r : Fin n → ℝ) : + laguerreDensity (n + 1) a (Fin.snoc r x) = + laguerreWeight a x * laguerreDensity n a r * ∏ i, pairKernel (r i) x := by + unfold laguerreDensity + rw [pairProduct_snoc] + simp only [Fin.prod_univ_castSucc, Fin.snoc_castSucc, Fin.snoc_last] + ring + +theorem laguerreDomain_of_snoc {n : ℕ} {x : ℝ} {r : Fin n → ℝ} + (hr : Fin.snoc r x ∈ laguerreDomain (n + 1)) : + r ∈ laguerreDomain n ∧ 0 < x ∧ ∀ i, r i < x := by + refine ⟨⟨?_, ?_⟩, ?_, ?_⟩ + · intro i j hij + simpa using hr.1 (show i.castSucc < j.castSucc from hij) + · intro i + simpa using hr.2 i.castSucc + · simpa using hr.2 (Fin.last n) + · intro i + simpa using hr.1 (Fin.castSucc_lt_last i) + +theorem laguerreDensity_snoc_le {n : ℕ} (a : ℝ) {x : ℝ} {r : Fin n → ℝ} + (hr : Fin.snoc r x ∈ laguerreDomain (n + 1)) : + laguerreDensity (n + 1) a (Fin.snoc r x) ≤ + laguerreWeight (a + n) x * laguerreDensity n a r := by + obtain ⟨hrt, hx, hrx⟩ := laguerreDomain_of_snoc hr + rw [laguerreDensity_snoc] + have hp : (∏ i, pairKernel (r i) x) ≤ x ^ n := by + calc + _ ≤ ∏ _ : Fin n, x := Finset.prod_le_prod₀ + (fun i _ => pairKernel_nonneg (hrt.2 i).le hx.le) + (fun i _ => pairKernel_le_right (hrt.2 i).le hx (hrx i).le) + _ = _ := by simp + calc + _ ≤ (laguerreWeight a x * laguerreDensity n a r) * x ^ n := + mul_le_mul_of_nonneg_left hp (mul_nonneg (laguerreWeight_pos a hx).le (laguerreDensity_pos a hrt).le) + _ = laguerreWeight (a + n) x * laguerreDensity n a r := by + unfold laguerreWeight + rw [show a + (n : ℝ) - 1 = a - 1 + n by ring, Real.rpow_add hx, Real.rpow_natCast] + ring + +theorem integral_fin_snoc_eq (n : ℕ) (f : (Fin (n + 1) → ℝ) → ℝ) : + (∫ r, f r) = ∫ p : ℝ × (Fin n → ℝ), f (Fin.snoc p.2 p.1) := by + symm + simpa only [MeasurableEquiv.piFinSuccAbove_symm_apply, Fin.insertNthEquiv, + Fin.insertNth_last, Fin.succAbove_last, Equiv.coe_fn_mk, cast_eq] using + ((volume_preserving_piFinSuccAbove (fun _ : Fin (n + 1) => ℝ) (Fin.last n)).symm).integral_comp' f + +theorem integrable_fin_snoc {n : ℕ} {f : (Fin (n + 1) → ℝ) → ℝ} + (hf : Integrable f) : Integrable (fun p : ℝ × (Fin n → ℝ) => f (Fin.snoc p.2 p.1)) := by + simpa only [Function.comp_def, MeasurableEquiv.piFinSuccAbove_symm_apply, Fin.insertNthEquiv, + Fin.insertNth_last, Fin.succAbove_last, Equiv.coe_fn_mk, cast_eq] using + ((volume_preserving_piFinSuccAbove (fun _ : Fin (n + 1) => ℝ) (Fin.last n)).symm).integrable_comp_of_integrable hf + +theorem laguerreLaw_measureReal (N : ℕ) {a : ℝ} (ha : 0 < a) + {s : Set (Fin N → ℝ)} (hs : MeasurableSet s) : + (laguerreLaw N a).real s = + (∫ r in laguerreDomain N ∩ s, laguerreDensity N a r) / laguerreNormalizer N a := by + rw [← integral_indicator_one hs, integral_laguerreLaw N ha] + unfold laguerreExpectation + simp_rw [← Set.indicator_mul_left, Pi.one_apply, one_mul] + rw [setIntegral_indicator hs] + +theorem laguerreLargestIntegral_le (n : ℕ) {a h : ℝ} (ha : 0 < a) (hh : 0 ≤ h) : + (∫ r in laguerreDomain (n + 1) ∩ {r | h < r (Fin.last n)}, laguerreDensity (n + 1) a r) ≤ + (∫ x in Ioi h, laguerreWeight (a + n) x) * laguerreNormalizer n a := by + let S : Set (Fin (n + 1) → ℝ) := laguerreDomain (n + 1) ∩ {r | h < r (Fin.last n)} + have hm : MeasurableSet S := (isOpen_laguerreDomain _).measurableSet.inter + (measurableSet_lt measurable_const (measurable_pi_apply _)) + let f : ℝ → ℝ := (Ioi h).indicator (laguerreWeight (a + n)) + let g : (Fin n → ℝ) → ℝ := (laguerreDomain n).indicator (laguerreDensity n a) + have hfi : Integrable f := (integrable_indicator_iff measurableSet_Ioi).2 + ((integrableOn_laguerreWeight (show 0 < a + (n : ℝ) by positivity)).mono_set (Ioi_subset_Ioi hh)) + have hgi : Integrable g := (integrable_indicator_iff (isOpen_laguerreDomain n).measurableSet).2 + (integrableOn_laguerreDensity n ha) + have hfn : ∀ x, 0 ≤ f x := by + intro x + by_cases hx : h < x + · rw [show f x = laguerreWeight (a + n) x from indicator_of_mem hx _] + exact (laguerreWeight_pos _ (hh.trans_lt hx)).le + · exact le_of_eq (indicator_of_notMem hx _).symm + have hgn : ∀ r, 0 ≤ g r := by + intro r + by_cases hr : r ∈ laguerreDomain n + · rw [show g r = laguerreDensity n a r from indicator_of_mem hr _] + exact (laguerreDensity_pos a hr).le + · exact le_of_eq (indicator_of_notMem hr _).symm + have hsi : Integrable (S.indicator (laguerreDensity (n + 1) a)) := + (integrable_indicator_iff hm).2 ((integrableOn_laguerreDensity _ ha).mono_set inter_subset_left) + have hb (p : ℝ × (Fin n → ℝ)) : S.indicator (laguerreDensity (n + 1) a) (Fin.snoc p.2 p.1) ≤ + f p.1 * g p.2 := by + by_cases hp : Fin.snoc p.2 p.1 ∈ S + · have htail := (laguerreDomain_of_snoc hp.1).1 + have hx : p.1 ∈ Ioi h := by simpa using hp.2 + simpa only [f, g, indicator_of_mem hp, indicator_of_mem hx, indicator_of_mem htail] using + laguerreDensity_snoc_le a hp.1 + · rw [indicator_of_notMem hp] + exact mul_nonneg (hfn _) (hgn _) + calc + _ = ∫ p : ℝ × (Fin n → ℝ), S.indicator (laguerreDensity (n + 1) a) (Fin.snoc p.2 p.1) := by + rw [← integral_indicator hm, integral_fin_snoc_eq] + _ ≤ ∫ p : ℝ × (Fin n → ℝ), f p.1 * g p.2 := + integral_mono (integrable_fin_snoc hsi) (hfi.mul_prod hgi) hb + _ = (∫ x, f x) * ∫ r, g r := integral_prod_mul f g + _ = _ := by + simp only [f, g, integral_indicator measurableSet_Ioi, + integral_indicator (isOpen_laguerreDomain n).measurableSet, laguerreNormalizer] + + +theorem laguerreLaw_max_tail_le (n : ℕ) {a h : ℝ} (ha : 0 < a) (hh : 0 ≤ h) : + (laguerreLaw (n + 1) a).real {r | h < r (Fin.last n)} ≤ + (laguerreNormalizer n a / laguerreNormalizer (n + 1) a) * + ∫ x in Ioi h, laguerreWeight (a + n) x := by + rw [laguerreLaw_measureReal _ ha (measurableSet_lt measurable_const (measurable_pi_apply _))] + have H := div_le_div_of_nonneg_right (laguerreLargestIntegral_le n ha hh) + (laguerreNormalizer_pos (n + 1) ha).le + exact H.trans_eq (by ring) + + + +theorem laguerreWeight_tail_exp_bound {b h : ℝ} (hb : 0 < b) (hh : 0 ≤ h) : + (∫ x in Ioi h, laguerreWeight b x) ≤ + Real.exp (-h / 2) * (2 ^ b * Real.Gamma b) := by + let f : ℝ → ℝ := fun x => x ^ (b - 1) * Real.exp (-(1 / 2 * x)) + have hfi : IntegrableOn f (Ioi 0) := by + simpa only [f, Real.rpow_one, neg_mul] using + (integrableOn_rpow_mul_exp_neg_mul_rpow (s := b - 1) (p := 1) (b := 1 / 2) + (by linarith) (by norm_num) (by norm_num)) + have hfn : ∀ x ∈ Ioi 0, 0 ≤ f x := fun x hx => + mul_nonneg (Real.rpow_nonneg (le_of_lt hx) _) (Real.exp_nonneg _) + have ht : ∫ x in Ioi h, laguerreWeight b x ≤ Real.exp (-h / 2) * ∫ x in Ioi h, f x := by + rw [← integral_const_mul] + apply setIntegral_mono_on + ((integrableOn_laguerreWeight hb).mono_set (Ioi_subset_Ioi hh)) + ((hfi.mono_set (Ioi_subset_Ioi hh)).const_mul _) measurableSet_Ioi + intro x hx + have hxpos : 0 < x := lt_of_le_of_lt hh hx + have he : Real.exp (-x / 2) ≤ Real.exp (-h / 2) := + Real.exp_le_exp.2 (by have : h < x := hx; linarith) + calc + laguerreWeight b x = Real.exp (-x / 2) * f x := by + simp only [laguerreWeight, f] + conv_lhs => rw [show -x = -(x / 2) + -(1 / 2 * x) by ring, Real.exp_add] + simp only [neg_div, mul_left_comm] + _ ≤ _ := mul_le_mul_of_nonneg_right he (hfn x hxpos) + calc + _ ≤ Real.exp (-h / 2) * ∫ x in Ioi h, f x := ht + _ ≤ Real.exp (-h / 2) * ∫ x in Ioi 0, f x := by + apply mul_le_mul_of_nonneg_left _ (Real.exp_nonneg _) + apply setIntegral_mono_set hfi _ (Filter.Eventually.of_forall (Ioi_subset_Ioi hh)) + filter_upwards [ae_restrict_mem measurableSet_Ioi] with x hx + exact hfn x hx + _ = _ := by + congr 1 + simpa only [f, one_div_div, div_one] using + (Real.integral_rpow_mul_exp_neg_mul_Ioi hb (by norm_num : (0 : ℝ) < 1 / 2)) + + + +theorem laguerreLaw_max_tail_exp_bound (n : ℕ) {a h : ℝ} (ha : 0 < a) (hh : 0 ≤ h) : + (laguerreLaw (n + 1) a).real {r | h < r (Fin.last n)} ≤ + (laguerreNormalizer n a / laguerreNormalizer (n + 1) a) * + (Real.exp (-h / 2) * (2 ^ (a + (n : ℝ)) * Real.Gamma (a + n))) := by + apply (laguerreLaw_max_tail_le n ha hh).trans + exact mul_le_mul_of_nonneg_left + (laguerreWeight_tail_exp_bound (by positivity) hh) + (div_nonneg (laguerreNormalizer_pos n ha).le (laguerreNormalizer_pos (n + 1) ha).le) + +end + +noncomputable section +open scoped BigOperators +open Set MeasureTheory Filter + + +def orderedPairKernel (x y : ℝ) : ℝ := (max (y - x) 0) ^ 2 / (y + x) + +lemma orderedPairKernel_nonneg {x y : ℝ} (hx : 0 ≤ x) (hy : 0 ≤ y) : + 0 ≤ orderedPairKernel x y := by + unfold orderedPairKernel + positivity + +lemma orderedPairKernel_eq {x y : ℝ} (hxy : x ≤ y) : + orderedPairKernel x y = pairKernel x y := by + simp [orderedPairKernel, pairKernel, max_eq_left (sub_nonneg.mpr hxy)] + +lemma orderedPairKernel_eq_zero {x y : ℝ} (hxy : y ≤ x) : + orderedPairKernel x y = 0 := by + simp [orderedPairKernel, max_eq_right (sub_nonpos.mpr hxy)] + + + +lemma pairKernel_cross {a b s t : ℝ} (ha : 0 < a) (hab : a ≤ b) + (hbs : b < s) (hst : s ≤ t) : + pairKernel a t * pairKernel b s ≤ pairKernel a s * pairKernel b t := by + have hb : 0 < b := ha.trans_le hab + have has : a < s := hab.trans_lt hbs + have hat : a < t := has.trans_le hst + have hbt : b < t := hbs.trans_le hst + have hu : (s - b) / (t - b) ≤ (s - a) / (t - a) := by + rw [div_le_div_iff₀ (sub_pos.mpr hbt) (sub_pos.mpr hat)] + nlinarith [mul_nonneg (sub_nonneg.mpr hab) (sub_nonneg.mpr hst)] + have hv : (t + b) / (s + b) ≤ (t + a) / (s + a) := by + rw [div_le_div_iff₀ (by linarith : 0 < s + b) (by linarith : 0 < s + a)] + nlinarith [mul_nonneg (sub_nonneg.mpr hab) (sub_nonneg.mpr hst)] + have hr : pairKernel b s / pairKernel b t ≤ pairKernel a s / pairKernel a t := by + have he {u : ℝ} (hu0 : 0 < u) (hus : u < s) : + pairKernel u s / pairKernel u t = ((s - u) / (t - u)) ^ 2 * ((t + u) / (s + u)) := by + unfold pairKernel + field_simp + rw [he hb hbs, he ha has] + refine mul_le_mul ((sq_le_sq₀ (by positivity) (by positivity)).2 hu) hv ?_ (sq_nonneg _) + exact div_nonneg (by linarith) (by linarith) + have hr' := (div_le_div_iff₀ (pairKernel_pos hb hbt) (pairKernel_pos ha hat)).1 hr + nlinarith + +lemma orderedPairKernel_logSupermodular {a b s t : ℝ} + (ha : 0 < a) (hb : 0 < b) (hs : 0 < s) (ht : 0 < t) : + orderedPairKernel a s * orderedPairKernel b t ≤ + orderedPairKernel (min a b) (min s t) * orderedPairKernel (max a b) (max s t) := by + wlog hab : a ≤ b generalizing a b s t + · have h := this hb ha ht hs (le_of_not_ge hab) + simpa [min_comm, max_comm, mul_comm] using h + by_cases hst : s ≤ t + · simp [min_eq_left hab, max_eq_right hab, min_eq_left hst, max_eq_right hst] + have hts : t ≤ s := le_of_not_ge hst + rw [min_eq_left hab, max_eq_right hab, min_eq_right hts, max_eq_left hts] + by_cases hbt : b < t + · rw [orderedPairKernel_eq (hab.trans (hbt.le.trans hts)), orderedPairKernel_eq hbt.le, + orderedPairKernel_eq (hab.trans hbt.le), orderedPairKernel_eq (hbt.le.trans hts)] + exact pairKernel_cross ha hab hbt hts + · rw [orderedPairKernel_eq_zero (le_of_not_gt hbt), mul_zero] + exact mul_nonneg (orderedPairKernel_nonneg ha.le ht.le) + (orderedPairKernel_nonneg hb.le hs.le) + + + +lemma product_coordinate_modular {ι α : Type*} [Fintype ι] [LinearOrder α] + (w : ι → α → ℝ) (x y : ι → α) : + (∏ i, w i (x i)) * (∏ i, w i (y i)) = + (∏ i, w i ((x ⊓ y) i)) * (∏ i, w i ((x ⊔ y) i)) := by + classical + simp only [← Finset.prod_mul_distrib, Pi.inf_apply, Pi.sup_apply] + apply Finset.prod_congr rfl + intro i _ + obtain h | h := le_total (x i) (y i) + · simp [inf_eq_left.mpr h, sup_eq_right.mpr h] + · simp [inf_eq_right.mpr h, sup_eq_left.mpr h, mul_comm] + + + +lemma association_finite_product {ι α : Type*} [Fintype ι] [Fintype α] [LinearOrder α] + [MeasurableSpace α] [MeasurableSingletonClass α] + (ν : ι → Measure α) [∀ i, IsFiniteMeasure (ν i)] + (h f g : (ι → α) → ℝ) (hh : 0 ≤ h) (hf : 0 ≤ f) (hg : 0 ≤ g) + (hfm : Monotone f) (hgm : Monotone g) + (hhm : ∀ x y, h x * h y ≤ h (x ⊓ y) * h (x ⊔ y)) : + (∫ x, h x * f x ∂Measure.pi ν) * (∫ x, h x * g x ∂Measure.pi ν) ≤ + (∫ x, h x ∂Measure.pi ν) * (∫ x, h x * (f x * g x) ∂Measure.pi ν) := by + classical + let m : (ι → α) → ℝ := fun x => ∏ i, (ν i).real {x i} + have hm : ∀ x, (Measure.pi ν).real {x} = m x := by + intro x + simp only [measureReal_def, Measure.pi_singleton, ENNReal.toReal_prod, m] + have hmn : 0 ≤ m := fun x => Finset.prod_nonneg fun i _ => measureReal_nonneg + have hmod (x y : ι → α) : m x * m y = m (x ⊓ y) * m (x ⊔ y) := + product_coordinate_modular (fun i z => (ν i).real {z}) x y + have hmh : ∀ x y, (m x * h x) * (m y * h y) ≤ + (m (x ⊓ y) * h (x ⊓ y)) * (m (x ⊔ y) * h (x ⊔ y)) := by + intro x y + rw [mul_mul_mul_comm, mul_mul_mul_comm (m (x ⊓ y)), hmod] + exact mul_le_mul_of_nonneg_left (hhm x y) (mul_nonneg (hmn _) (hmn _)) + simp only [integral_fintype (Integrable.of_finite), hm, smul_eq_mul] + simpa only [mul_assoc] using + fkg f g (fun x => m x * h x) (fun x => mul_nonneg (hmn x) (hh x)) + hf hg hfm hgm hmh + +def coordinateBox (ι : Type*) (I : Set ℝ) : Set (ι → ℝ) := {x | ∀ i, x i ∈ I} + + + +end +end CriticalStrip + +end OAI diff --git a/lean/OAI/Combinatorics/StripMass/LastRow.lean b/lean/OAI/Combinatorics/StripMass/LastRow.lean new file mode 100644 index 0000000000000000000000000000000000000000..9515d0fd3d4295852b29e645ba5a4d1fb2e647e0 --- /dev/null +++ b/lean/OAI/Combinatorics/StripMass/LastRow.lean @@ -0,0 +1,521 @@ +import Mathlib +import OAI.Combinatorics.StripMass.RestrictedDiagrams + +namespace OAI + +/-! Critical honeycomb strip paths, polynomial identities and crossing mass. -/ + + + + + +namespace CriticalStrip.Diagram +noncomputable section +open Finset + + +def lastTile {n : ℕ} (p q : Pairing (n+1)) : Tile := by + classical + exact if p.Occupied (Fin.last n) then + if q.Occupied (Fin.last n) then .diagonal₁ else .cap + else if q.Occupied (Fin.last n) then .vertical₀ else .vacant + +theorem Realizes.last_eq {n : ℕ} {p q : Pairing (n+1)} {t : Configuration (n+1)} + (h : Realizes p q t) : t (Fin.last n) = lastTile p q := by + classical + have hn := h.north (Fin.last n) rfl + have hw := h.west (Fin.last n) + have he := h.east (Fin.last n) + unfold lastTile + generalize t (Fin.last n) = a at hn hw he ⊢ + cases a <;> simp_all [Tile.Occupied, Tile.Adj, Tile.edges] + + + +def lastCoefficient {K : Type*} [CommRing K] {n : ℕ} + (w : Fin n → Tile → K) (q p : Pairing (n+1)) : K := by + classical + exact ∑ t : Configuration n, + if Realizes p q (Fin.snoc t (lastTile p q)) then ∏ i, w i (t i) else 0 + +theorem lastCoefficient_map {K L : Type*} [CommRing K] [CommRing L] + (f : K →+* L) {n : ℕ} (w : Fin n → Tile → K) (q p : Pairing (n+1)) : + lastCoefficient (fun i a => f (w i a)) q p = f (lastCoefficient w q p) := by + classical + simp only [lastCoefficient, map_sum] + apply Finset.sum_congr rfl + intro t _ + split_ifs <;> simp + + +theorem rawColumn_last_factor {K : Type*} [CommRing K] {n : ℕ} + (w : Fin n → Tile → K) (r : Tile → K) (q p : Pairing (n+1)) : + rawColumn (Fin.snoc w r) q p = + lastCoefficient w q p * r (lastTile p q) := by + classical + unfold rawColumn + rw [← Fintype.sum_equiv (Fin.snocEquiv (fun _ : Fin (n+1) => Tile)) + (fun tt : Tile × Configuration n => + if Realizes p q (Fin.snoc tt.2 tt.1) + then ∏ i : Fin (n+1), ((Fin.snoc w r : Fin (n+1) → Tile → K) i) ((Fin.snoc tt.2 tt.1 : Configuration (n+1)) i) else 0) + _ (fun _ => rfl)] + rw [Fintype.sum_prod_type, Finset.sum_eq_single (lastTile p q)] + · simp only [lastCoefficient, Finset.sum_mul] + apply Finset.sum_congr rfl + intro t _ + split_ifs <;> simp [Fin.prod_univ_castSucc] + · intro a ha hne + apply Finset.sum_eq_zero + intro t _ + have hnot : ¬ Realizes p q (Fin.snoc t a) := by + intro h + have hh := h.last_eq + simp only [Fin.snoc_last] at hh + exact hne hh + simp [hnot] + · simp + + +theorem lastCoefficient_padTop {K : Type*} [CommRing K] {n : ℕ} + (w : Fin n → Tile → K) (q p : Pairing n) : + lastCoefficient w q.padTop p.padTop = rawColumn w q p := by + classical + simp only [lastCoefficient, lastTile, Pairing.padTop_not_occupied_last, + ite_false, realizes_snoc_top_iff, true_and, rawColumn] + + + +def lastFactor {K : Type*} [CommRing K] {n : ℕ} + (d c C : K) (p q : Pairing (n+1)) : Polynomial K := by + classical + exact if q.Occupied (Fin.last n) then + if p.Occupied (Fin.last n) then Polynomial.X - Polynomial.C c + else Polynomial.C (2*d) + else if p.Occupied (Fin.last n) then Polynomial.C d * (Polynomial.X - Polynomial.C c) + else Polynomial.X + Polynomial.C C + + + +def lastTransform {K : Type*} [CommRing K] {n : ℕ} + (w : Fin n → Tile → K) (d c C : K) + (P : Pairing (n+1) → Polynomial K) (q : Pairing (n+1)) : Polynomial K := + ∑ p, Polynomial.C (lastCoefficient w q p) * lastFactor d c C p q * P p + + +def lastValue {K L : Type*} [CommRing K] [CommRing L] {n : ℕ} + (f : K →+* L) (b s : L) (P : Pairing (n+1) → Polynomial K) + (p : Pairing (n+1)) : L := by + classical + exact if p.Occupied (Fin.last n) then s * (P p).eval₂ f b else (P p).eval₂ f b + + + +theorem rawColumn_lastValue {K L : Type*} [CommRing K] [CommRing L] {n : ℕ} + (f : K →+* L) (w : Fin n → Tile → K) (d c C : K) + (b s t : L) (r : Tile → L) (P : Pairing (n+1) → Polynomial K) + (hv : r .vacant = b + f C) (hc : r .cap = 2 * f d * t) + (hu : r .vertical₀ = 2 * f d * s) (hb : r .diagonal₁ = b - f c) + (hst : 2 * s * t = b - f c) : + (rawColumn (Fin.snoc (fun i a => f (w i a)) r)).mulVec (lastValue f b s P) = + lastValue f b s (lastTransform w d c C P) := by + classical + funext q + simp only [Matrix.mulVec, dotProduct, rawColumn_last_factor, lastCoefficient_map] + have he (p : Pairing (n+1)) : + f (lastCoefficient w q p) * r (lastTile p q) * lastValue f b s P p = + if q.Occupied (Fin.last n) then + s * (Polynomial.C (lastCoefficient w q p) * lastFactor d c C p q * P p).eval₂ f b + else (Polynomial.C (lastCoefficient w q p) * lastFactor d c C p q * P p).eval₂ f b := by + by_cases hp : p.Occupied (Fin.last n) <;> by_cases hq : q.Occupied (Fin.last n) + all_goals simp [lastTile, lastValue, lastFactor, hp, hq, hv, hc, hu, hb, map_ofNat] + all_goals try ring_nf + calc + _ = f (lastCoefficient w q p) * f d * (2*s*t) * (P p).eval₂ f b := by ring + _ = _ := by rw [hst]; ring + simp_rw [he] + by_cases hq : q.Occupied (Fin.last n) + · simp [lastValue, hq, lastTransform, Polynomial.eval₂_finsetSum, Finset.mul_sum] + · simp [lastValue, hq, lastTransform, Polynomial.eval₂_finsetSum] + +end + + + + + +noncomputable section + + +def c : ℝ := Real.cos (3*lambda) + +theorem phase_cosine (k : ℤ) : (phase^k+(phase^k)⁻¹)/2 = + (Real.cos ((k:ℝ)*lambda) : ℂ) := by + rw [phase_pow, Complex.ofReal_cos] + push_cast + rw [Complex.cos, ← Complex.exp_neg] + simp only [neg_mul] + +theorem phase_eight : phase^(8:ℕ) = -1 := by + have h := phase_pow 8 + norm_num only [zpow_ofNat, Int.cast_ofNat] at h + rw [h] + convert Complex.exp_pi_mul_I using 1 + congr 1 + simp [lambda] + ring + +theorem constF_phase_eight (n : ℕ) : constF n phase ^ 8 = -1 := by + rw [constF, ← map_pow, phase_eight, map_neg, map_one] + +@[simp] theorem torusCos_inv {n : ℕ} (z : SpectralField n) : + torusCos z⁻¹ = torusCos z := by simp [torusCos, add_comm] + +@[simp] theorem torusCos_neg {n : ℕ} (z : SpectralField n) : + torusCos (-z) = -torusCos z := by simp [torusCos]; ring + +theorem torusCos_phase_pow (n : ℕ) (k : ℕ) : + torusCos (constF n phase ^ k) = constF n (Real.cos ((k:ℝ)*lambda)) := by + have h := congrArg (constF n) (phase_cosine (k:ℤ)) + simpa [torusCos, constF, map_ofNat] using h + +theorem torusSin_product {n : ℕ} (z w : SpectralField n) (hz : z ≠ 0) (hw : w ≠ 0) : + 2 * torusSin z * torusSin w = torusCos (z/w) - torusCos (z*w) := by + have hi : (constF n Complex.I)^2 = -1 := by + simp only [constF, ← map_pow, Complex.I_sq, map_neg, map_one] + have hI : constF n Complex.I ≠ 0 := by + exact (map_ne_zero (algebraMap ℂ (SpectralField n))).mpr Complex.I_ne_zero + unfold torusSin torusCos + field_simp + ring_nf + rw [hi] + ring + + +theorem spectral_sine_pair {n : ℕ} (i : Fin n) : + 2 * torusSin (variableF i) * torusSin (constF n phase ^ 3 / variableF i) = + spectralA i - constF n c := by + rw [torusSin_product _ _ (variableF_ne_zero i) + (div_ne_zero (pow_ne_zero _ (constF_phase_ne_zero n)) (variableF_ne_zero i))] + have h₁ : variableF i / (constF n phase ^ 3 / variableF i) = + variableF i ^ 2 / constF n phase ^ 3 := by field_simp + have h₂ : variableF i * (constF n phase ^ 3 / variableF i) = constF n phase ^ 3 := by + field_simp [variableF_ne_zero i] + rw [h₁, h₂, torusCos_phase_pow] + rfl + + +theorem twice_rowDenominator {n : ℕ} (i : Fin n) : + 2 * evalLaurent (rowDenominator i) = spectralA i + constF n C := by + rw [evalLaurent, rowDenominator_map, torusL] + have hq := constF_phase_ne_zero n + have hx := variableF_ne_zero i + have h₅ : constF n phase ^ 2 * (constF n phase ^ 3 / variableF i) = + constF n phase ^ 5 / variableF i := by ring + have h₆ : constF n phase ^ 3 * (constF n phase ^ 3 / variableF i) = + constF n phase ^ 6 / variableF i := by ring + rw [h₅, h₆, ← mul_assoc, torusSin_product _ _ + (div_ne_zero (pow_ne_zero _ hq) hx) (div_ne_zero (pow_ne_zero _ hq) hx)] + have hdiv : (constF n phase ^ 5 / variableF i) / (constF n phase ^ 6 / variableF i) = + (constF n phase)⁻¹ := by field_simp + have hmul : (constF n phase ^ 5 / variableF i) * (constF n phase ^ 6 / variableF i) = + -(variableF i ^ 2 / constF n phase ^ 3)⁻¹ := by + have h := constF_phase_eight n + field_simp + exact h + rw [hdiv, hmul, torusCos_inv, torusCos_neg, torusCos_inv, + ← pow_one (constF n phase), torusCos_phase_pow] + simp only [Nat.cast_one, one_mul, sub_neg_eq_add] + rw [add_comm] + simp [spectralA, C] + + +def clearedSpectralRow {n : ℕ} (i : Fin n) (t : Tile) : SpectralField n := + (spectralA i + constF n C) * (spectralWeights n i).tile t + +theorem clearedSpectralRow_eq {n : ℕ} (i : Fin n) (t : Tile) : + clearedSpectralRow i t = 2 * evalLaurent (rowNumerator i t) := by + rw [clearedSpectralRow, ← twice_rowDenominator] + change (2 * algebraMap (SpectralRing n) (SpectralField n) (rowDenominator i)) * _ = _ + rw [mul_assoc, ← rowNumerator_map] + rfl + +@[simp] theorem clearedSpectralRow_vacant {n : ℕ} (i : Fin n) : + clearedSpectralRow i .vacant = spectralA i + constF n C := by + simp [clearedSpectralRow, Weights.tile] + +@[simp] theorem clearedSpectralRow_cap {n : ℕ} (i : Fin n) : + clearedSpectralRow i .cap = 2 * constF n d * + torusSin (constF n phase ^ 3 / variableF i) := by + rw [clearedSpectralRow_eq] + simp only [evalLaurent, rowNumerator, map_mul, map_constantL, zpow_ofNat, + map_sine_neg_variable_nat, mul_assoc] + +@[simp] theorem clearedSpectralRow_vertical₀ {n : ℕ} (i : Fin n) : + clearedSpectralRow i .vertical₀ = 2 * constF n d * torusSin (variableF i) := by + rw [clearedSpectralRow_eq] + simp only [evalLaurent, rowNumerator, map_mul, map_constantL] + rw [map_sine_variable i (0:ℤ)] + simp only [zpow_zero, one_mul, mul_assoc] + +@[simp] theorem clearedSpectralRow_diagonal₁ {n : ℕ} (i : Fin n) : + clearedSpectralRow i .diagonal₁ = spectralA i - constF n c := by + rw [clearedSpectralRow_eq] + simp only [evalLaurent, rowNumerator, map_mul] + rw [map_sine_variable i (0:ℤ), map_sine_neg_variable i (3:ℤ)] + simp only [zpow_ofNat, pow_zero, one_mul] + rw [mul_comm (torusSin _), ← mul_assoc, spectral_sine_pair] + + + + + + + + +def appendZero (n : ℕ) : (Fin n → ℤ) →+ (Fin (n+1) → ℤ) where + toFun e := Fin.snoc e 0 + map_zero' := by + ext i + refine Fin.lastCases ?_ (fun k => ?_) i <;> simp + map_add' x y := by + ext i + refine Fin.lastCases ?_ (fun k => ?_) i <;> simp + +def liftLaurentHom (n : ℕ) : Laurent n →+* Laurent (n+1) := + AddMonoidAlgebra.mapDomainRingHom ℂ (appendZero n) + +@[simp] theorem liftLaurentHom_apply {n : ℕ} (p : Laurent n) : + liftLaurentHom n p = liftLaurent p := rfl + +theorem appendZero_injective (n : ℕ) : Function.Injective (appendZero n) := by + intro e f h + funext i + simpa [appendZero] using congrFun h i.castSucc + +theorem liftLaurent_injective (n : ℕ) : Function.Injective (@liftLaurent n) := + AddMonoidAlgebra.mapDomain_injective (appendZero_injective n) + + + +def liftSpectral (n : ℕ) : SpectralField n →+* SpectralField (n+1) := + IsFractionRing.lift (K := SpectralField n) + (g := (algebraMap (SpectralRing (n+1)) (SpectralField (n+1))).comp (liftLaurentHom n)) + ((IsFractionRing.injective (SpectralRing (n+1)) (SpectralField (n+1))).comp + (liftLaurent_injective n)) + +@[simp] theorem liftSpectral_evalLaurent {n : ℕ} (p : Laurent n) : + liftSpectral n (evalLaurent p) = evalLaurent (liftLaurent p) := by + exact IsFractionRing.lift_algebraMap _ _ + +@[simp] theorem liftLaurent_monomial {n : ℕ} (e : Fin n → ℤ) (z : ℂ) : + liftLaurent (monomialL e z) = monomialL (Fin.snoc e 0) z := by + exact AddMonoidAlgebra.mapDomain_single + +@[simp] theorem liftLaurent_const {n : ℕ} (z : ℂ) : + liftLaurent (constantL n z) = constantL (n+1) z := by + change liftLaurent (monomialL 0 z) = monomialL 0 z + rw [liftLaurent_monomial] + congr 1 + exact (appendZero n).map_zero + +@[simp] theorem liftSpectral_const (n : ℕ) (z : ℂ) : + liftSpectral n (constF n z) = constF (n+1) z := by + have hc : constF n z = evalLaurent (constantL n z) := (map_constantL n z).symm + rw [hc, liftSpectral_evalLaurent, liftLaurent_const] + exact map_constantL (n+1) z + +@[simp] theorem appendZero_variable {n : ℕ} (i : Fin n) : + Fin.snoc (variableExponent i) 0 = variableExponent i.castSucc := by + ext j + refine Fin.lastCases ?_ (fun k => ?_) j + · simp [variableExponent] + · simp only [Fin.snoc_castSucc, variableExponent, Pi.single_apply, + Fin.castSucc_inj] + +@[simp] theorem liftSpectral_variable {n : ℕ} (i : Fin n) : + liftSpectral n (variableF i) = variableF i.castSucc := by + change liftSpectral n (evalLaurent (monomialL (variableExponent i) 1)) = _ + rw [liftSpectral_evalLaurent, liftLaurent_monomial, appendZero_variable] + rfl + +@[simp] theorem liftSpectral_torusSin {n : ℕ} (z : SpectralField n) : + liftSpectral n (torusSin z) = torusSin (liftSpectral n z) := by + simp [torusSin, map_div₀, map_inv₀, map_ofNat] + +@[simp] theorem liftSpectral_torusCos {n : ℕ} (z : SpectralField n) : + liftSpectral n (torusCos z) = torusCos (liftSpectral n z) := by + simp [torusCos, map_div₀, map_inv₀, map_ofNat] + +@[simp] theorem liftSpectral_spectralA {n : ℕ} (i : Fin n) : + liftSpectral n (spectralA i) = spectralA i.castSucc := by + simp [spectralA, map_div₀] + +@[simp] theorem evalLaurent_lastSine (n : ℕ) : + evalLaurent (lastSine n) = torusSin (variableF (Fin.last n)) := by + have he : lastExponent n 1 = variableExponent (Fin.last n) := by + ext j + refine Fin.lastCases ?_ (fun k => ?_) j + · simp [lastExponent, variableExponent] + · simp [lastExponent, variableExponent] + have he' : lastExponent n (-1) = -variableExponent (Fin.last n) := by + ext j + refine Fin.lastCases ?_ (fun k => ?_) j + · simp [lastExponent, variableExponent] + · simp [lastExponent, variableExponent] + unfold lastSine + change evalLaurent (monomialL (lastExponent n 1) _ - monomialL (lastExponent n (-1)) _) = _ + rw [he, he'] + simp only [evalLaurent, map_sub, map_monomialL_variable, map_monomialL_neg_variable] + simp only [constF, map_div₀, map_mul, map_one, map_ofNat] + simp only [torusSin, constF, div_eq_mul_inv] + ring + + + + + + +open scoped Classical + +namespace Weights +variable {K L : Type*} [CommRing K] [CommRing L] +def map (f : K →+* L) (w : Weights K) : Weights L := + ⟨f w.A,f w.B,f w.U,f w.E,f w.F⟩ +@[simp] lemma map_tile (f : K →+* L) (w : Weights K) (t : Tile) : + (w.map f).tile t=f (w.tile t) := by cases t <;> simp [map,tile] +end Weights + +lemma column_map {K L : Type*} [CommRing K] [CommRing L] {n : ℕ} + (f : K →+* L) (w : Fin n → Weights K) : + (column w).map f=column (fun i => (w i).map f) := by + ext p q + simp only [Matrix.map_apply,column,map_sum,Weights.map_tile] + apply Finset.sum_congr rfl + intro t _ + split_ifs <;> simp only [map_prod,map_zero] + +lemma restrictedColumn_map {K L : Type*} [CommRing K] [CommRing L] {n : ℕ} + (f : K →+* L) (w : Fin n → Weights K) : + (restrictedColumn w).map f=restrictedColumn (fun i => (w i).map f) := by + ext p q + exact congrFun (congrFun (column_map f w) p.val) q.val + +lemma VacuumRegular.map {K L : Type*} [Field K] [Field L] {n : ℕ} + (f : K →+* L) (w : Fin n → Weights K) (h : VacuumRegular w) : + VacuumRegular (fun i => (w i).map f) := by + unfold VacuumRegular at h ⊢ + have hm : (1-restrictedColumn w).map f=1-restrictedColumn (fun i => (w i).map f) := by + rw [←restrictedColumn_map] + ext i j + simp only [Matrix.map_apply,Matrix.sub_apply,Matrix.one_apply,map_sub] + split_ifs <;> simp only [map_one,map_zero] + have hh : f (1-restrictedColumn w).det≠0 := (map_ne_zero f).mpr h + rw [f.map_det] at hh + change ((1-restrictedColumn w).map f).det≠0 at hh + rwa [hm] at hh + +lemma normalizedVacuum_map {K L : Type*} [Field K] [Field L] {n : ℕ} + (f : K →+* L) (w : Fin n → Weights K) (h : VacuumRegular w) : + (fun p => f (normalizedVacuum w p))=normalizedVacuum (fun i => (w i).map f) := by + apply normalizedVacuum_unique _ (h.map f w) + have hs:=normalizedVacuum_stationary w h + constructor + · change f (normalizedVacuum w (empty n))=1 + rw [hs.1,map_one] + · funext p + have hh:=congrArg f (congrFun hs.2 p) + simp only [Matrix.mulVec,dotProduct,map_sum,map_mul] at hh ⊢ + simpa only [←column_map,Matrix.map_apply] using hh + +end + + + + + +noncomputable section +open scoped Classical + +def permExponent {n : ℕ} (σ : Equiv.Perm (Fin n)) : (Fin n → ℤ) →+ (Fin n → ℤ) where + toFun e := e ∘ σ.symm + map_zero' := rfl + map_add' _ _ := rfl + +lemma permExponent_injective {n : ℕ} (σ : Equiv.Perm (Fin n)) : + Function.Injective (permExponent σ) := by + intro e f he + funext i + simpa [permExponent] using congrFun he (σ i) + +def permLaurent {n : ℕ} (σ : Equiv.Perm (Fin n)) : Laurent n →+* Laurent n := + AddMonoidAlgebra.mapDomainRingHom ℂ (permExponent σ) + +lemma permLaurent_injective {n : ℕ} (σ : Equiv.Perm (Fin n)) : + Function.Injective (permLaurent σ) := + AddMonoidAlgebra.mapDomain_injective (permExponent_injective σ) + +def permSpectral {n : ℕ} (σ : Equiv.Perm (Fin n)) : SpectralField n →+* SpectralField n := + IsFractionRing.lift (K := SpectralField n) + (g := (algebraMap (SpectralRing n) (SpectralField n)).comp (permLaurent σ)) + ((IsFractionRing.injective (SpectralRing n) (SpectralField n)).comp + (permLaurent_injective σ)) + +@[simp] lemma permSpectral_evalLaurent {n : ℕ} (σ : Equiv.Perm (Fin n)) (f : Laurent n) : + permSpectral σ (evalLaurent f)=evalLaurent (permLaurent σ f) := + IsFractionRing.lift_algebraMap _ _ + +@[simp] lemma permLaurent_monomial {n : ℕ} (σ : Equiv.Perm (Fin n)) + (e : Fin n → ℤ) (z : ℂ) : permLaurent σ (monomialL e z)= + monomialL (e ∘ σ.symm) z := AddMonoidAlgebra.mapDomain_single + +@[simp] lemma permSpectral_const {n : ℕ} (σ : Equiv.Perm (Fin n)) (z : ℂ) : + permSpectral σ (constF n z)=constF n z := by + have hc : constF n z=evalLaurent (constantL n z) := (map_constantL n z).symm + rw [hc,permSpectral_evalLaurent] + change evalLaurent (permLaurent σ (monomialL 0 z))=evalLaurent (monomialL 0 z) + rw [permLaurent_monomial] + rfl + +@[simp] lemma permSpectral_variable {n : ℕ} (σ : Equiv.Perm (Fin n)) (i : Fin n) : + permSpectral σ (variableF i)=variableF (σ i) := by + change permSpectral σ (evalLaurent (monomialL (variableExponent i) 1))=_ + rw [permSpectral_evalLaurent,permLaurent_monomial] + congr 2 + funext j + by_cases hij : j=σ i + · subst j; simp [variableExponent] + · have hne : σ.symm j≠i := fun he => hij (by simpa using congrArg σ he) + simp [variableExponent,Function.comp_apply,hij,hne] + +@[simp] lemma permSpectral_torusSin {n : ℕ} (σ : Equiv.Perm (Fin n)) (z : SpectralField n) : + permSpectral σ (torusSin z)=torusSin (permSpectral σ z) := by + simp [torusSin,map_div₀,map_inv₀,map_ofNat] + +@[simp] lemma permSpectral_torusCos {n : ℕ} (σ : Equiv.Perm (Fin n)) (z : SpectralField n) : + permSpectral σ (torusCos z)=torusCos (permSpectral σ z) := by + simp [torusCos,map_div₀,map_inv₀,map_ofNat] + +@[simp] lemma permSpectral_torusL {n : ℕ} (σ : Equiv.Perm (Fin n)) (z : SpectralField n) : + permSpectral σ (torusL z)=torusL (permSpectral σ z) := by simp [torusL] + +@[simp] lemma permSpectral_torusWeights {n : ℕ} (σ : Equiv.Perm (Fin n)) (z : SpectralField n) : + (torusWeights z).map (permSpectral σ)=torusWeights (permSpectral σ z) := by + simp [Weights.map,torusWeights,map_div₀] + +@[simp] lemma permSpectral_spectralWeights {n : ℕ} (σ : Equiv.Perm (Fin n)) (i : Fin n) : + (spectralWeights n i).map (permSpectral σ)=spectralWeights n (σ i) := by + simp [spectralWeights,map_div₀] + +@[simp] lemma permSpectral_spectralA {n : ℕ} (σ : Equiv.Perm (Fin n)) (i : Fin n) : + permSpectral σ (spectralA i)=spectralA (σ i) := by simp [spectralA,map_div₀] + +lemma permSpectral_vacuum {n : ℕ} (σ : Equiv.Perm (Fin n)) (p : Pairing n) : + permSpectral σ (normalizedVacuum (spectralWeights n) p)= + normalizedVacuum (fun i => spectralWeights n (σ i)) p := by + have h:=congrFun (normalizedVacuum_map (permSpectral σ) (spectralWeights n) (spectral_regular n)) p + simpa using h + +end +end CriticalStrip.Diagram + +end OAI diff --git a/lean/OAI/Combinatorics/StripMass/LaurentBox.lean b/lean/OAI/Combinatorics/StripMass/LaurentBox.lean new file mode 100644 index 0000000000000000000000000000000000000000..84e1658452c0e46a99f5c69cb1c3d0fa2aced5a1 --- /dev/null +++ b/lean/OAI/Combinatorics/StripMass/LaurentBox.lean @@ -0,0 +1,524 @@ +import Mathlib +import OAI.Combinatorics.StripMass.DiagonalFactors + +namespace OAI + +/-! Critical honeycomb strip paths, polynomial identities and crossing mass. -/ + + + +namespace CriticalStrip.Diagram +noncomputable section +open scoped Classical Pointwise + + +def LaurentBox {n : ℕ} (f : Laurent n) (b : Fin n → ℕ) : Prop := + ∀ e, f.coeff e≠0 → ∀ i, -(b i:ℤ)≤e i ∧ e i≤b i + +lemma LaurentBox.zero {n : ℕ} (b : Fin n → ℕ) : LaurentBox 0 b := by + intro e he + exact (he rfl).elim + +lemma LaurentBox.mono {n : ℕ} {f : Laurent n} {b c : Fin n → ℕ} + (hf : LaurentBox f b) (hbc : ∀ i,b i≤c i) : LaurentBox f c := by + intro e he i + have := hf e he i + have := hbc i + constructor <;> omega + +lemma LaurentBox.add {n : ℕ} {f g : Laurent n} {b : Fin n → ℕ} + (hf : LaurentBox f b) (hg : LaurentBox g b) : LaurentBox (f+g) b := by + intro e he i + by_cases hh:f.coeff e=0 + · exact hg e (by simpa [AddMonoidAlgebra.coeff_add,hh] using he) i + · exact hf e hh i + +lemma LaurentBox.neg {n : ℕ} {f : Laurent n} {b : Fin n → ℕ} + (hf : LaurentBox f b) : LaurentBox (-f) b := by + intro e he i + exact hf e (by simpa using he) i + +lemma LaurentBox.sub {n : ℕ} {f g : Laurent n} {b : Fin n → ℕ} + (hf : LaurentBox f b) (hg : LaurentBox g b) : LaurentBox (f-g) b := by + rw [sub_eq_add_neg] + exact hf.add hg.neg + +lemma LaurentBox.mul {n : ℕ} {f g : Laurent n} {b c : Fin n → ℕ} + (hf : LaurentBox f b) (hg : LaurentBox g c) : LaurentBox (f*g) (b+c) := by + intro e he i + have hs := AddMonoidAlgebra.support_coeff_mul_subset f g (Finsupp.mem_support_iff.mpr he) + obtain ⟨x,hx,y,hy,hxy⟩ := Finset.mem_add.mp hs + have hx := hf x (Finsupp.mem_support_iff.mp hx) i + have hy := hg y (Finsupp.mem_support_iff.mp hy) i + have hh := congrFun hxy i + simp only [Pi.add_apply] at hh ⊢ + push_cast + constructor <;> omega + +lemma LaurentBox.single {n : ℕ} (e : Fin n → ℤ) (z : ℂ) (b : Fin n → ℕ) + (h : ∀ i,-(b i:ℤ)≤e i ∧ e i≤b i) : LaurentBox (monomialL e z) b := by + intro f hf i + have hh:f=e := by + by_contra hh + exact hf (by simp [monomialL,AddMonoidAlgebra.coeff_single,Ne.symm hh]) + subst f + exact h i + +lemma LaurentBox.constant {n : ℕ} (z : ℂ) : LaurentBox (constantL n z) 0 := + LaurentBox.single 0 z 0 (by simp) + +lemma LaurentBox.one {n : ℕ} : LaurentBox (1:Laurent n) 0 := by + rw [←monomialL_zero_one] + exact LaurentBox.single 0 1 0 (by simp) + +lemma LaurentBox.sine {n : ℕ} (e : Fin n → ℤ) (z : ℂ) (b : Fin n → ℕ) + (h : ∀ i,-(b i:ℤ)≤e i ∧ e i≤b i) : LaurentBox (sineL e z) b := by + unfold sineL + have hf:=LaurentBox.single e z b h + have hg:=LaurentBox.single (-e) z⁻¹ b (by intro i; have :=h i; simp only [Pi.neg_apply]; omega) + simpa using (hf.sub hg).mul (LaurentBox.constant ((2*Complex.I)⁻¹)) + +lemma LaurentBox.sum {n : ℕ} {ι : Type*} (s : Finset ι) (f : ι → Laurent n) + (b : Fin n → ℕ) (h : ∀ i∈s,LaurentBox (f i) b) : LaurentBox (∑ i∈s,f i) b := by + induction s using Finset.induction_on with + | empty => simpa using LaurentBox.zero b + | @insert a s ha ih => + rw [Finset.sum_insert ha] + exact (h a (by simp)).add (ih (fun i hi => h i (by simp [hi]))) + +lemma LaurentBox.prod {n : ℕ} {ι : Type*} (s : Finset ι) (f : ι → Laurent n) + (b : ι → Fin n → ℕ) (h : ∀ i∈s,LaurentBox (f i) (b i)) : + LaurentBox (∏ i∈s,f i) (∑ i∈s,b i) := by + induction s using Finset.induction_on with + | empty => simpa using LaurentBox.one (n:=n) + | @insert a s ha ih => + rw [Finset.prod_insert ha,Finset.sum_insert ha] + exact (h a (by simp)).mul (ih (fun i hi => h i (by simp [hi]))) + +end + + + + + +noncomputable section +open scoped LaurentPolynomial Classical + +variable {K : Type*} [Field K] + +lemma laurent_mul_top_coeff (f g : LaurentPolynomial K) (a b : ℤ) + (hf : ∀ e,f.coeff e≠0 → e≤a) (hg : ∀ e,g.coeff e≠0 → e≤b) : + (f*g).coeff (a+b)=f.coeff a*g.coeff b := by + rw [AddMonoidAlgebra.coeff_mul_apply_left] + change (∑ e ∈ f.coeff.support, f.coeff e*g.coeff (-e+(a+b)))=_ + rw [Finset.sum_eq_single a] + · congr 1 + congr 1 + ring + · intro e he hea + have hle:=hf e (Finsupp.mem_support_iff.mp he) + have hz:g.coeff (-e+(a+b))=0 := by + by_contra hh + have := hg _ hh + omega + rw [hz,mul_zero] + · intro ha + rw [Finsupp.notMem_support_iff.mp ha,zero_mul] + +lemma laurent_mul_bottom_coeff (f g : LaurentPolynomial K) (a b : ℤ) + (hf : ∀ e,f.coeff e≠0 → a≤e) (hg : ∀ e,g.coeff e≠0 → b≤e) : + (f*g).coeff (a+b)=f.coeff a*g.coeff b := by + rw [AddMonoidAlgebra.coeff_mul_apply_left] + change (∑ e ∈ f.coeff.support, f.coeff e*g.coeff (-e+(a+b)))=_ + rw [Finset.sum_eq_single a] + · congr 1 + congr 1 + ring + · intro e he hea + have hle:=hf e (Finsupp.mem_support_iff.mp he) + have hz:g.coeff (-e+(a+b))=0 := by + by_contra hh + have := hg _ hh + omega + rw [hz,mul_zero] + · intro ha + rw [Finsupp.notMem_support_iff.mp ha,zero_mul] + + + +theorem LaurentInterval.quotient {f g : LaurentPolynomial K} {a b c d : ℤ} + (h : LaurentInterval (f*g) a b) (hg : LaurentInterval g c d) + (hc : g.coeff c≠0) (hd : g.coeff d≠0) : LaurentInterval f (a-c) (b-d) := by + intro e he + have hs : f.coeff.support.Nonempty := ⟨e,Finsupp.mem_support_iff.mpr he⟩ + let lo:=f.coeff.support.min' hs + let hi:=f.coeff.support.max' hs + have hlo : f.coeff lo≠0 := Finsupp.mem_support_iff.mp (Finset.min'_mem _ hs) + have hhi : f.coeff hi≠0 := Finsupp.mem_support_iff.mp (Finset.max'_mem _ hs) + have hlow (k : ℤ) (hk:f.coeff k≠0) : lo≤k := + Finset.min'_le _ _ (Finsupp.mem_support_iff.mpr hk) + have hhigh (k : ℤ) (hk:f.coeff k≠0) : k≤hi := + Finset.le_max' _ _ (Finsupp.mem_support_iff.mpr hk) + have hl : (f*g).coeff (lo+c)≠0 := by + rw [laurent_mul_bottom_coeff f g lo c hlow (fun k hk => (hg k hk).1)] + exact mul_ne_zero hlo hc + have hh : (f*g).coeff (hi+d)≠0 := by + rw [laurent_mul_top_coeff f g hi d hhigh (fun k hk => (hg k hk).2)] + exact mul_ne_zero hhi hd + have h₁ := (h (lo+c) hl).1 + have h₂ := (h (hi+d) hh).2 + have h₃ := hlow e he + have h₄ := hhigh e he + omega + +end + + + + + +noncomputable section +open scoped Classical LaurentPolynomial + +lemma peelLaurentEquiv_coeff_coeff {n : ℕ} (i : Fin (n+1)) (f:Laurent (n+1)) + (k : ℤ) (e : Fin n → ℤ) : + ((peelLaurentEquiv i f).coeff k).coeff e=f.coeff (Fin.insertNth i k e) := by + change (AddMonoidAlgebra.mapDomainRingEquiv ℂ (peelExponent i) f).coeff (k,e)=_ + rw [AddMonoidAlgebra.coeff_mapDomainRingEquiv] + rfl + +lemma peelLaurent_coeff {n : ℕ} (i : Fin (n+1)) (f:Laurent (n+1)) (k : ℤ) : + (peelLaurent i f).coeff k=evalLaurent ((peelLaurentEquiv i f).coeff k) := + AddMonoidAlgebra.coeff_mapRingHom _ _ _ + +lemma peelLaurent_coeff_ne_zero_iff {n : ℕ} (i : Fin (n+1)) (f:Laurent (n+1)) (k : ℤ) : + (peelLaurent i f).coeff k≠0 ↔ ∃ e : Fin n → ℤ,f.coeff (Fin.insertNth i k e)≠0 := by + rw [peelLaurent_coeff] + constructor + · intro h + by_contra hh + push Not at hh + have hz:(peelLaurentEquiv i f).coeff k=0 := by + ext e + simpa only [peelLaurentEquiv_coeff_coeff,AddMonoidAlgebra.coeff_zero,Finsupp.zero_apply] using hh e + exact h (by rw [hz]; exact map_zero _) + · rintro ⟨e,he⟩ hz + have hh:(peelLaurentEquiv i f).coeff k=0 := + (IsFractionRing.injective (SpectralRing n) (SpectralField n)) (hz.trans (map_zero _).symm) + have :=congrArg (fun g:Laurent n => g.coeff e) hh + rw [peelLaurentEquiv_coeff_coeff] at this + exact he this + +lemma LaurentBox.peel {n : ℕ} {f : Laurent (n+1)} {b : Fin (n+1) → ℕ} + (hf:LaurentBox f b) (i:Fin (n+1)) : LaurentInterval (peelLaurent i f) (-(b i:ℤ)) (b i) := by + intro k hk + obtain ⟨e,he⟩:=(peelLaurent_coeff_ne_zero_iff i f k).mp hk + simpa only [Fin.insertNth_apply_same] using hf _ he i + +lemma LaurentBox.of_peel {n : ℕ} {f : Laurent (n+1)} {b : Fin (n+1) → ℕ} + (hf:∀ i:Fin (n+1),LaurentInterval (peelLaurent i f) (-(b i:ℤ)) (b i)) : LaurentBox f b := by + intro e he i + apply hf i (e i) + apply (peelLaurent_coeff_ne_zero_iff i f (e i)).mpr + exact ⟨Fin.removeNth i e,by simpa only [Fin.insertNth_removeNth,Function.update_eq_self] using he⟩ + +end + + + + + +noncomputable section +open scoped LaurentPolynomial Classical + + + +lemma laurent_linear_dvd {R : Type*} [CommRing R] (f : LaurentPolynomial R) (u : Rˣ) + (h : LaurentPolynomial.eval₂ (RingHom.id R) u f=0) : + LaurentPolynomial.T 1-LaurentPolynomial.C (u:R) ∣ f := by + obtain ⟨m,p,hp⟩:=LaurentPolynomial.exists_T_pow f + have he:p.eval (u:R)=0 := by + have hh:=congrArg (LaurentPolynomial.eval₂ (RingHom.id R) u) hp + rw [LaurentPolynomial.eval₂_toLaurent,map_mul,h,zero_mul] at hh + exact hh + obtain ⟨q,hq⟩:=Polynomial.dvd_iff_isRoot.mpr he + refine ⟨q.toLaurent*LaurentPolynomial.T (-(m:ℤ)),?_⟩ + have hh:=congrArg (fun g : LaurentPolynomial R => g*LaurentPolynomial.T (-(m:ℤ))) hp + rw [hq,map_mul,map_sub,Polynomial.toLaurent_X,Polynomial.toLaurent_C] at hh + simpa only [mul_assoc,←LaurentPolynomial.T_add,add_neg_cancel,LaurentPolynomial.T_zero,mul_one] + using hh.symm + +lemma laurent_eval_linear {R : Type*} [CommRing R] (u v : Rˣ) : + LaurentPolynomial.eval₂ (RingHom.id R) u + (LaurentPolynomial.T 1-LaurentPolynomial.C (v:R))=(u:R)-(v:R) := by + simp [LaurentPolynomial.eval₂_T,LaurentPolynomial.eval₂_C] + + + +lemma laurent_prod_linear_dvd {R : Type*} [CommRing R] [IsDomain R] + (f : LaurentPolynomial R) (s : Finset Rˣ) + (h : ∀ u∈s,LaurentPolynomial.eval₂ (RingHom.id R) u f=0) : + (∏ u∈s,(LaurentPolynomial.T 1-LaurentPolynomial.C (u:R))) ∣ f := by + induction s using Finset.induction_on generalizing f with + | empty => simp + | @insert a s ha ih => + obtain ⟨g,hg⟩:=laurent_linear_dvd f a (h a (Finset.mem_insert_self a s)) + have hs (u : Rˣ) (hu:u∈s) : LaurentPolynomial.eval₂ (RingHom.id R) u g=0 := by + have hh:=h u (Finset.mem_insert_of_mem hu) + rw [hg,map_mul,laurent_eval_linear] at hh + apply (mul_eq_zero.mp hh).resolve_left + apply sub_ne_zero.mpr + intro e + have eu:u=a := Units.ext e + exact ha (eu ▸ hu) + obtain ⟨q,hq⟩:=ih g hs + rw [Finset.prod_insert ha] + refine ⟨q,?_⟩ + rw [hg,hq,mul_assoc] + +end + + + + + +noncomputable section +open scoped Classical LaurentPolynomial + + + +theorem prod_dvd_of_evaluation_packets {R K ι κ : Type*} + [CommRing R] [CommRing K] [IsDomain K] + (s : Finset ι) (D : ι → R) (φ : ι → κ → R →+* K) + (hker : ∀ i∈s, ∀ f:R, (∀ k,φ i k f=0) → D i ∣ f) + (hcross : ∀ i∈s, ∀ j∈s, i≠j → ∀ k,φ i k (D j)≠0) + (f : R) (hf : ∀ i∈s, ∀ k,φ i k f=0) : (∏ i∈s,D i) ∣ f := by + induction s using Finset.induction_on generalizing f with + | empty => simp + | @insert i s hi ih => + obtain ⟨g,hg⟩:=hker i (Finset.mem_insert_self _ _) f (hf i (Finset.mem_insert_self _ _)) + have hsg (j : ι) (hj:j∈s) (k : κ) : φ j k g=0 := by + have hh:=hf j (Finset.mem_insert_of_mem hj) k + rw [hg,map_mul] at hh + apply (mul_eq_zero.mp hh).resolve_left + exact hcross j (Finset.mem_insert_of_mem hj) i (Finset.mem_insert_self _ _) + (fun he => hi (he ▸ hj)) k + obtain ⟨q,hq⟩:=ih (fun j hj => hker j (Finset.mem_insert_of_mem hj)) + (fun j hj k hk => hcross j (Finset.mem_insert_of_mem hj) k (Finset.mem_insert_of_mem hk)) + g hsg + refine ⟨q,?_⟩ + rw [Finset.prod_insert hi,hg,hq,mul_assoc] + +lemma laurent_prod_linear_indexed_dvd {R ι : Type*} [CommRing R] [IsDomain R] + [Fintype ι] (u : ι → Rˣ) (hu : Function.Injective u) + (f : LaurentPolynomial R) (h : ∀ i,LaurentPolynomial.eval₂ (RingHom.id R) (u i) f=0) : + (∏ i,(LaurentPolynomial.T 1-LaurentPolynomial.C ((u i):R))) ∣ f := by + have hh:=laurent_prod_linear_dvd f (Finset.univ.image u) (by + intro v hv + obtain ⟨i,_,rfl⟩:=Finset.mem_image.mp hv + exact h i) + simpa only [Finset.prod_image (fun i _ j _ hij => hu hij)] using hh + +end + + + + + +noncomputable section +open scoped LaurentPolynomial Classical + +def monomialUnit {n : ℕ} (e : Fin n → ℤ) (z : ℂ) (hz:z≠0) : (Laurent n)ˣ where + val := monomialL e z + inv := monomialL (-e) z⁻¹ + val_inv := by simp [monomialL_mul,hz] + inv_val := by simp [monomialL_mul,hz] + +lemma peelLaurentEquiv_insert {n : ℕ} (i : Fin (n+1)) (f : Laurent n) : + peelLaurentEquiv i (insertLaurent i f)=LaurentPolynomial.C f := by + have h : (peelLaurentEquiv i).toRingHom.comp (insertLaurent i)=LaurentPolynomial.C := by + apply AddMonoidAlgebra.ringHom_ext <;> intro e + all_goals change peelLaurentEquiv i (insertLaurent i (monomialL _ _))=_ + all_goals + rw [insertLaurent_monomial,peelLaurentEquiv_monomial] + simp only [Fin.insertNth_apply_same,Fin.removeNth_insertNth] + rfl + exact DFunLike.congr_fun h f + + +def substituteLaurent {n : ℕ} (i : Fin (n+1)) (u : (Laurent n)ˣ) : + Laurent (n+1) →+* Laurent n := + (LaurentPolynomial.eval₂ (RingHom.id _) u).comp (peelLaurentEquiv i).toRingHom + +@[simp] lemma substituteLaurent_insert {n : ℕ} (i : Fin (n+1)) (u : (Laurent n)ˣ) + (f : Laurent n) : substituteLaurent i u (insertLaurent i f)=f := by + change LaurentPolynomial.eval₂ (RingHom.id _) u (peelLaurentEquiv i (insertLaurent i f))=f + rw [peelLaurentEquiv_insert,LaurentPolynomial.eval₂_C] + rfl + + +def cosineCollisionRoots {R : Type*} [CommRing R] (a u : Rˣ) : Fin 4 → Rˣ := + ![u,-u,a⁻¹*u⁻¹,-(a⁻¹*u⁻¹)] + +def cosineCollisionPacket {R : Type*} [CommRing R] (a u : Rˣ) : LaurentPolynomial R := + LaurentPolynomial.C (a:R)*LaurentPolynomial.T 2+ + LaurentPolynomial.C ((a⁻¹:Rˣ):R)*LaurentPolynomial.T (-2)- + LaurentPolynomial.C ((a:R)*(u:R)^2+((a⁻¹:Rˣ):R)*((u⁻¹:Rˣ):R)^2) + +lemma cosineCollision_factorization {R : Type*} [CommRing R] (a u : Rˣ) : + (∏ k:Fin 4, (LaurentPolynomial.T 1-LaurentPolynomial.C ((cosineCollisionRoots a u k):R)))= + (LaurentPolynomial.C ((a⁻¹:Rˣ):R)*LaurentPolynomial.T 2)*cosineCollisionPacket a u := by + simp only [cosineCollisionRoots,Fin.prod_univ_succ,Matrix.cons_val_zero, + Matrix.cons_val_succ,Fin.prod_univ_zero,mul_one,Units.val_neg,Units.val_mul, + map_neg,map_mul,cosineCollisionPacket,map_add,map_pow] + have h2 : (LaurentPolynomial.T (1:ℤ) : LaurentPolynomial R)^2=LaurentPolynomial.T 2 := by + rw [pow_two,←LaurentPolynomial.T_add]; rfl + have h4 : (LaurentPolynomial.T (1:ℤ) : LaurentPolynomial R)^4=LaurentPolynomial.T 2*LaurentPolynomial.T 2 := by + rw [←h2]; ring + have haa : LaurentPolynomial.C ((a⁻¹:Rˣ):R)*LaurentPolynomial.C (a:R)=1 := by + rw [←map_mul]; simp + have huu : LaurentPolynomial.C ((u⁻¹:Rˣ):R)*LaurentPolynomial.C (u:R)=1 := by + rw [←map_mul]; simp + have hT : (LaurentPolynomial.T (2:ℤ) : LaurentPolynomial R)*LaurentPolynomial.T (-2)=1 := by + rw [←LaurentPolynomial.T_add]; rfl + linear_combination + ((LaurentPolynomial.T 1)^2+LaurentPolynomial.T 2)*h2 + + (LaurentPolynomial.C (u:R)^2+LaurentPolynomial.C ((a⁻¹:Rˣ):R)^2*LaurentPolynomial.C ((u⁻¹:Rˣ):R)^2)*(-h2) - + (LaurentPolynomial.T 2)^2*haa + + (LaurentPolynomial.C (u:R)^2*LaurentPolynomial.T 2)*haa + + LaurentPolynomial.C ((a⁻¹:Rˣ):R)^2*((LaurentPolynomial.C ((u⁻¹:Rˣ):R)*LaurentPolynomial.C (u:R)+1)*huu-hT) + +lemma cosineCollisionPacket_dvd {R : Type*} [CommRing R] [IsDomain R] + (a u : Rˣ) (hi:Function.Injective (cosineCollisionRoots a u)) (f : LaurentPolynomial R) + (h:∀ k,LaurentPolynomial.eval₂ (RingHom.id R) (cosineCollisionRoots a u k) f=0) : + cosineCollisionPacket a u ∣ f := by + have hh:=laurent_prod_linear_indexed_dvd (cosineCollisionRoots a u) hi f h + rw [cosineCollision_factorization] at hh + exact dvd_trans (dvd_mul_left _ _) hh + +end + + + + + +noncomputable section +open Finset + +theorem pairFirst_injective (n : ℕ) : Function.Injective (pairFirst n) := by + intro i j h + apply Fin.ext + have := congrArg Fin.val h + dsimp [pairFirst] at this + omega + +theorem pairSecond_injective (n : ℕ) : Function.Injective (pairSecond n) := by + intro i j h + apply Fin.ext + have := congrArg Fin.val h + dsimp [pairSecond] at this + omega + +theorem upperPair_incident_iff {n : ℕ} (i j v : Fin n) (h : i ≠ j) : + ((upperPair i j h).val.1 = v ∨ (upperPair i j h).val.2 = v) ↔ i = v ∨ j = v := by + unfold upperPair + split_ifs <;> simp [or_comm] + +theorem pairIndex_unique {n : ℕ} (σ : Equiv.Perm (Fin n)) + (i j : Fin (n/2)) (v : Fin n) + (hi : σ (pairFirst n i) = v ∨ σ (pairSecond n i) = v) + (hj : σ (pairFirst n j) = v ∨ σ (pairSecond n j) = v) : i = j := by + rcases hi with hi | hi <;> rcases hj with hj | hj + · exact pairFirst_injective n (σ.injective (hi.trans hj.symm)) + · exact False.elim (pairFirst_ne_pairSecond i j (σ.injective (hi.trans hj.symm))) + · exact False.elim (pairFirst_ne_pairSecond j i (σ.injective (hj.trans hi.symm))) + · exact pairSecond_injective n (σ.injective (hi.trans hj.symm)) + + +theorem selectedPairs_incident_unique {n : ℕ} (σ : Equiv.Perm (Fin n)) + (e f : UpperPair n) (he : e ∈ selectedPairs σ) (hf : f ∈ selectedPairs σ) + (v : Fin n) (hev : e.val.1 = v ∨ e.val.2 = v) (hfv : f.val.1 = v ∨ f.val.2 = v) : + e = f := by + obtain ⟨i,_,rfl⟩ := Finset.mem_image.mp he + obtain ⟨j,_,rfl⟩ := Finset.mem_image.mp hf + apply congrArg (permutationPair σ) + apply pairIndex_unique σ i j v + · exact (upperPair_incident_iff _ _ _ _).mp hev + · exact (upperPair_incident_iff _ _ _ _).mp hfv + + +theorem pairIndex_cover {n : ℕ} (hn : n % 2 = 0) (σ : Equiv.Perm (Fin n)) (v : Fin n) : + ∃ i : Fin (n/2), σ (pairFirst n i) = v ∨ σ (pairSecond n i) = v := by + let p := σ.symm v + let i : Fin (n/2) := ⟨p.val/2, by have := p.isLt; omega⟩ + refine ⟨i,?_⟩ + by_cases hp : p.val%2 = 0 + · left + have h : pairFirst n i = p := by apply Fin.ext; dsimp [pairFirst,i]; omega + rw [h] + exact σ.apply_symm_apply v + · right + have h : pairSecond n i = p := by apply Fin.ext; dsimp [pairSecond,i]; omega + rw [h] + exact σ.apply_symm_apply v + +def firstPair (m : ℕ) : UpperPair (2*(m+1)) := ⟨(0,1), by + change (0 : Fin (2*m+2)) < 1 + exact Fin.zero_lt_one⟩ + +theorem firstPair_eq_upperPair (m : ℕ) : + firstPair m = upperPair 0 1 (by exact ne_of_lt (firstPair m).property) := by + have h : (0 : Fin (2*(m+1))) < 1 := (firstPair m).property + simp only [upperPair, h, dite_true, firstPair] + + +def repairFirstDenominator {R : Type*} [One R] {m : ℕ} + (D : Matrix (Fin (2*(m+1))) (Fin (2*(m+1))) R) : + Matrix (Fin (2*(m+1))) (Fin (2*(m+1))) R := fun i j => + if (i = 0 ∧ j = 1) ∨ (i = 1 ∧ j = 0) then 1 else D i j + + +def isolateFirstNumerator {R : Type*} [Zero R] {m : ℕ} + (N : Matrix (Fin (2*(m+1))) (Fin (2*(m+1))) R) : + Matrix (Fin (2*(m+1))) (Fin (2*(m+1))) R := fun i j => + if (i = 0 ∧ j ≠ 1) ∨ (j = 0 ∧ i ≠ 1) then 0 else N i j + +theorem isolateFirstNumerator_selected {R : Type*} [Zero R] {m : ℕ} + (N : Matrix (Fin (2*(m+1))) (Fin (2*(m+1))) R) + (σ : Equiv.Perm (Fin (2*(m+1)))) (hσ : firstPair m ∈ selectedPairs σ) + (i : Fin (2*(m+1)/2)) : + isolateFirstNumerator N (σ (pairFirst _ i)) (σ (pairSecond _ i)) = + N (σ (pairFirst _ i)) (σ (pairSecond _ i)) := by + classical + unfold isolateFirstNumerator + rw [ite_eq_right] + rintro (h | h) + all_goals + have he : permutationPair σ i = firstPair m := selectedPairs_incident_unique σ _ _ + (Finset.mem_image.mpr ⟨i,Finset.mem_univ _,rfl⟩) hσ 0 + ((upperPair_incident_iff _ _ _ _).mpr (by aesop)) (Or.inl rfl) + rw [firstPair_eq_upperPair] at he + rcases (upperPair_eq_iff _ _).mp he with hc | hc + · simp_all + · simp_all + + + +theorem repairFirstDenominator_compl {R : Type*} [One R] {m : ℕ} + (D : Matrix (Fin (2*(m+1))) (Fin (2*(m+1))) R) + (σ : Equiv.Perm (Fin (2*(m+1)))) (hσ : firstPair m ∈ selectedPairs σ) + (e : UpperPair (2*(m+1))) (he : e ∈ (selectedPairs σ)ᶜ) : + repairFirstDenominator D e.val.1 e.val.2 = D e.val.1 e.val.2 := by + unfold repairFirstDenominator + rw [ite_eq_right] + rintro (h | h) + · have heq : e = firstPair m := Subtype.ext (Prod.ext h.1 h.2) + exact (Finset.mem_compl.mp he) (heq.symm ▸ hσ) + · have := e.property + rw [h.1,h.2] at this + exact (not_lt_of_ge (firstPair m).property.le) this + +end +end CriticalStrip.Diagram + +end OAI diff --git a/lean/OAI/Combinatorics/StripMass/LaurentNumerator.lean b/lean/OAI/Combinatorics/StripMass/LaurentNumerator.lean new file mode 100644 index 0000000000000000000000000000000000000000..e96355fff0ebd31d725c965b6f7c48f92d60b624 --- /dev/null +++ b/lean/OAI/Combinatorics/StripMass/LaurentNumerator.lean @@ -0,0 +1,570 @@ +import Mathlib +import OAI.Combinatorics.StripMass.NodalScalarDeletion + +namespace OAI + +/-! Critical honeycomb strip paths, polynomial identities and crossing mass. -/ + + + +namespace CriticalStrip.Diagram +noncomputable section +open scoped Classical + +lemma evalLaurent_monomial_scale {n : ℕ} (e : Fin n → ℤ) (c z : ℂ) : + (algebraMap (SpectralRing n) (SpectralField n)) (monomialL e (c*z))=constF n c*(algebraMap (SpectralRing n) (SpectralField n)) (monomialL e z) := by + rw [←map_constantL] + change (algebraMap (SpectralRing n) (SpectralField n)) (monomialL e (c*z))=(algebraMap (SpectralRing n) (SpectralField n)) (monomialL 0 c)*(algebraMap (SpectralRing n) (SpectralField n)) (monomialL e z) + rw [←map_mul,monomialL_mul,zero_add] + +lemma evalLaurent_monomial_quot {n : ℕ} (e : Fin n → ℤ) (z : ℂ) (hz:z≠0) (c : ℂ) : + (algebraMap (SpectralRing n) (SpectralField n)) (monomialL (-e) (c/z))=constF n c/(algebraMap (SpectralRing n) (SpectralField n)) (monomialL e z) := by + rw [div_eq_mul_inv,div_eq_mul_inv,evalLaurent_monomial_scale] + congr 1 + exact (map_monomialL_inv e z hz).symm + + +def torusNumeratorL {n : ℕ} (e : Fin n → ℤ) (z : ℂ) : Tile → Laurent n + | .vacant => sineL e (phase^2*z)*sineL e (phase^3*z) + | .vertical₀ | .vertical₁ => constantL n d*sineL (-e) (phase^3/z) + | .cap | .cup => constantL n d*sineL e z + | .diagonal₀ | .diagonal₁ => sineL e z*sineL (-e) (phase^3/z) + | .verticalPair => sineL (-e) (phase^3/z)*sineL (-e) (phase^2/z) + | .capCup => sineL e (z/phase)*sineL e z + +lemma sineL_map_scale {n : ℕ} (e : Fin n → ℤ) (c z : ℂ) (hc:c≠0) (hz:z≠0) : + (algebraMap (SpectralRing n) (SpectralField n)) (sineL e (c*z))=torusSin (constF n c*(algebraMap (SpectralRing n) (SpectralField n)) (monomialL e z)) := by + rw [sineL_map e (c*z) (mul_ne_zero hc hz),evalLaurent_monomial_scale] + +lemma sineL_map_quot {n : ℕ} (e : Fin n → ℤ) (z c : ℂ) (hc:c≠0) (hz:z≠0) : + (algebraMap (SpectralRing n) (SpectralField n)) (sineL (-e) (c/z))=torusSin (constF n c/(algebraMap (SpectralRing n) (SpectralField n)) (monomialL e z)) := by + rw [sineL_map _ _ (div_ne_zero hc hz),evalLaurent_monomial_quot e z hz] + +lemma torusNumeratorL_map {n : ℕ} (e : Fin n → ℤ) (z : ℂ) (hz:z≠0) (t : Tile) : + (algebraMap (SpectralRing n) (SpectralField n)) (torusNumeratorL e z t)=torusNumerator ((algebraMap (SpectralRing n) (SpectralField n)) (monomialL e z)) t := by + cases t + all_goals simp only [torusNumeratorL,torusNumerator,torusL,map_mul,map_constantL] + all_goals try rw [sineL_map e z hz] + all_goals try rw [sineL_map_scale e (phase^2) z (pow_ne_zero _ phase_ne_zero) hz] + all_goals try rw [sineL_map_scale e (phase^3) z (pow_ne_zero _ phase_ne_zero) hz] + all_goals try rw [sineL_map_quot e z (phase^3) (pow_ne_zero _ phase_ne_zero) hz] + all_goals try rw [sineL_map_quot e z (phase^2) (pow_ne_zero _ phase_ne_zero) hz] + all_goals try simp only [constF,map_pow] + have he:z/phase=phase⁻¹*z := by ring + rw [he,sineL_map_scale e phase⁻¹ z (inv_ne_zero phase_ne_zero) hz] + simp only [constF,map_inv₀] + congr 2 + exact inv_mul_eq_div _ _ + +lemma sineL_product_box {n : ℕ} (e f : Fin n → ℤ) (z w : ℂ) (b : Fin n → ℕ) + (he : ∀ i,-(b i:ℤ)≤e i ∧ e i≤b i) (hf : ∀ i,-(b i:ℤ)≤f i ∧ f i≤b i) : + LaurentBox (sineL e z*sineL f w) (b+b) := + LaurentBox.mul (LaurentBox.sine e z b he) (LaurentBox.sine f w b hf) + +lemma constant_sineL_box {n : ℕ} (e : Fin n → ℤ) (z w : ℂ) (b : Fin n → ℕ) + (he : ∀ i,-(b i:ℤ)≤e i ∧ e i≤b i) : + LaurentBox (constantL n z*sineL e w) (b+b) := + LaurentBox.mul ((LaurentBox.constant z).mono (fun i => Nat.zero_le (b i))) + (LaurentBox.sine e w b he) + +lemma torusNumeratorL_box {n : ℕ} (e : Fin n → ℤ) (z : ℂ) + (b : Fin n → ℕ) (h:∀ i,-(b i:ℤ)≤e i ∧ e i≤b i) (t : Tile) : + LaurentBox (torusNumeratorL e z t) (b+b) := by + have hn : ∀ i,-(b i:ℤ)≤(-e) i ∧ (-e) i≤b i := by + intro i; have := h i; simp only [Pi.neg_apply]; omega + cases t with + | vacant => exact sineL_product_box e e _ _ b h h + | cap => exact constant_sineL_box e _ _ b h + | cup => exact constant_sineL_box e _ _ b h + | vertical₀ => exact constant_sineL_box (-e) _ _ b hn + | vertical₁ => exact constant_sineL_box (-e) _ _ b hn + | diagonal₀ => exact sineL_product_box e (-e) _ _ b h hn + | diagonal₁ => exact sineL_product_box e (-e) _ _ b h hn + | verticalPair => exact sineL_product_box (-e) (-e) _ _ b hn hn + | capCup => exact sineL_product_box e e _ _ b h h + + + + + + + +lemma rawLocal_map {K L : Type*} [CommRing K] [CommRing L] (f : K →+* L) + {n : ℕ} (r : Position n) (w : Tile → K) : + (rawLocal r w).map f=rawLocal r (fun t => f (w t)) := by + ext p q + simp only [rawLocal,Matrix.map_apply,Matrix.sum_apply,Matrix.smul_apply, + smul_eq_mul,map_sum,map_mul] + apply Finset.sum_congr rfl + intro t _ + unfold optionMatrix + split_ifs <;> simp + +def LaurentMatrixBox {n : ℕ} {α β : Type*} (A : Matrix α β (Laurent n)) (b : Fin n → ℕ) : Prop := + ∀ p q,LaurentBox (A p q) b + +lemma LaurentMatrixBox.one {n : ℕ} {α : Type*} [DecidableEq α] : + LaurentMatrixBox (1:Matrix α α (Laurent n)) 0 := by + intro p q + by_cases h:p=q + · subst p; simp only [Matrix.one_apply_eq]; exact LaurentBox.one + · simp only [Matrix.one_apply_ne h]; exact LaurentBox.zero _ + +lemma LaurentMatrixBox.mul {n : ℕ} {α β γ : Type*} [Fintype β] + {A : Matrix α β (Laurent n)} {B : Matrix β γ (Laurent n)} + {a b : Fin n → ℕ} (hA : LaurentMatrixBox A a) (hB : LaurentMatrixBox B b) : + LaurentMatrixBox (A*B) (a+b) := by + intro p q + rw [Matrix.mul_apply] + exact LaurentBox.sum _ _ _ (fun i _ => (hA p i).mul (hB i q)) + +lemma LaurentMatrixBox.smul {n : ℕ} {α β : Type*} {A : Matrix α β (Laurent n)} + {c : Laurent n} {a b : Fin n → ℕ} (hc : LaurentBox c a) (hA : LaurentMatrixBox A b) : + LaurentMatrixBox (c • A) (a+b) := by + intro p q + exact hc.mul (hA p q) + +lemma rawLocal_box {n m : ℕ} (r : Position m) (w : Tile → Laurent n) + (b : Fin n → ℕ) (hw : ∀ t,LaurentBox (w t) b) : + LaurentMatrixBox (rawLocal r w) b := by + intro p q + simp only [rawLocal,Matrix.sum_apply,Matrix.smul_apply,smul_eq_mul] + apply LaurentBox.sum + intro t _ + unfold optionMatrix + split_ifs + · simpa using hw t + · simp only [mul_zero]; exact LaurentBox.zero _ + +lemma matrixPrefix_box_partial {n m : ℕ} {α : Type*} [Fintype α] [DecidableEq α] + (A : Fin m → Matrix α α (Laurent n)) (b : Fin m → Fin n → ℕ) + (hA : ∀ i,LaurentMatrixBox (A i) (b i)) (k : ℕ) : + LaurentMatrixBox (matrixPrefix A k) + (∑ j ∈ Finset.range k, (if h : j < m then b ⟨j, h⟩ else 0)) := by + induction k with + | zero => simp only [matrixPrefix,Finset.range_zero,Finset.sum_empty]; exact LaurentMatrixBox.one + | succ k ih => + rw [matrixPrefix,Finset.sum_range_succ] + by_cases hk : k < m + · rw [dite_eq_left hk,dite_eq_left hk,add_comm] + exact (hA ⟨k,hk⟩).mul ih + · rw [dite_eq_right hk,dite_eq_right hk,add_zero] + exact ih + +lemma matrixPrefix_box {n m : ℕ} {α : Type*} [Fintype α] [DecidableEq α] + (A : Fin m → Matrix α α (Laurent n)) (b : Fin m → Fin n → ℕ) + (hA : ∀ i,LaurentMatrixBox (A i) (b i)) : + LaurentMatrixBox (matrixPrefix A m) (∑ j,b j) := by + rw [Finset.sum_fin_eq_sum_range] + exact matrixPrefix_box_partial A b hA m + + + + + + + +lemma map_monomialL_add_variable {n : ℕ} (i j : Fin n) (z : ℂ) : + evalLaurent (monomialL (variableExponent i+variableExponent j) z)= + constF n z*(variableF i*variableF j) := by + have hm : monomialL (variableExponent i+variableExponent j) z = + monomialL (variableExponent i) z*monomialL (variableExponent j) 1 := by simp + rw [hm,evalLaurent,map_mul,map_monomialL_variable,map_monomialL_variable] + simp only [constF,map_one,one_mul,mul_assoc] + + + +def reducedMovingStepL {n : ℕ} (i j : Fin n) : + Matrix (Pairing (n+1)) (Pairing (n+1)) (Laurent n) := + if j=i then 1 else + (constantL n (-4)*sineL (variableExponent i+variableExponent j) (phase^(-6:ℤ))) • + if i p.coeff k)=fun i => p.eval (b i) := by + funext i + simp only [Matrix.mulVec,dotProduct,Matrix.vandermonde_apply] + rw [show (∑ x : Fin n, b i ^ (x:ℕ) * p.coeff (x:ℕ)) = + ∑ x ∈ Finset.range n, b i ^ x * p.coeff x from + Fin.sum_univ_eq_sum_range (fun x => b i ^ x * p.coeff x) n] + by_cases hz:p=0 + · simp [hz] + · rw [Polynomial.eval_eq_sum_range' ((Polynomial.natDegree_lt_iff_degree_lt hz).mpr hp)] + apply Finset.sum_congr rfl + intro k _ + exact mul_comm _ _ + +lemma interpolationNumerator_eq_det_mul_coeff {K : Type*} [Field K] {n : ℕ} + (b y : Fin n → K) (hb:Function.Injective b) (k : Fin n) : + interpolationNumerator b y k=(Matrix.vandermonde b).det* + (Lagrange.interpolate Finset.univ b y).coeff k := by + let p:=Lagrange.interpolate Finset.univ b y + have hp:p.degree p.coeff k)=y := by + rw [vandermonde_mulVec_coeff b p hp] + funext i + exact Lagrange.eval_interpolate_at_node y hb.injOn (Finset.mem_univ i) + have h:=congrArg (Matrix.mulVec (Matrix.vandermonde b).adjugate) hev + rw [Matrix.mulVec_mulVec,Matrix.adjugate_mul,Matrix.smul_mulVec,Matrix.one_mulVec, + ←Matrix.cramer_eq_adjugate_mulVec] at h + exact (congrFun h k).symm + +lemma interpolationNumerator_map {R K : Type*} [CommRing R] [CommRing K] + (f : R →+* K) {n : ℕ} (b y : Fin n → R) (k : Fin n) : + f (interpolationNumerator b y k)=interpolationNumerator (fun i => f (b i)) (fun i => f (y i)) k := by + unfold interpolationNumerator + rw [RingHom.map_det] + congr 1 + change ((Matrix.vandermonde b).updateCol k y).map f = _ + ext i j + simp only [Matrix.map_apply,Matrix.updateCol_apply,Matrix.vandermonde_apply] + split_ifs <;> simp only [map_pow] + +lemma interpolationNumerator_collision {R : Type*} [CommRing R] {n : ℕ} + (b y : Fin n → R) (i j : Fin n) (hij:i≠j) (hb:b i=b j) (hy:y i=y j) (k : Fin n) : + interpolationNumerator b y k=0 := by + apply Matrix.det_zero_of_row_eq hij + funext a + simp only [Matrix.updateCol_apply,Matrix.vandermonde_apply] + split_ifs <;> simp only [hb,hy] + + + + + + + +lemma functionMatrix_ring_map {R S P Q : Type*} [CommRing R] [CommRing S] + (f : R →+* S) (v : P → Q) : (functionMatrix (K:=R) v).map f=functionMatrix v := by + ext p q + simp only [Matrix.map_apply,functionMatrix,optionMatrix] + split_ifs <;> simp + +def deletionMapL {n m : ℕ} (r : ℕ) (hr:r+2≤n+2) : + Matrix (Pairing (n+2)) (Pairing n) (Laurent m) := + @HMul.hMul _ _ _ Matrix.instHMulOfFintypeOfMulOfAddCommMonoid (rawLocal (PartialColumn.rowPosition r hr) (deletionWeights : Weights (Laurent m)).tile) + (@HMul.hMul _ _ _ Matrix.instHMulOfFintypeOfMulOfAddCommMonoid (functionMatrix (K:=Laurent m) (Pairing.map (Fin.succAboveOrderEmb (⟨r+1,by omega⟩ : Fin (n+2))))) + (functionMatrix (K:=Laurent m) (Pairing.map (Fin.succAboveOrderEmb (⟨r,by omega⟩ : Fin (n+1)))))) + +lemma deletionMapL_map {n m : ℕ} (r : ℕ) (hr:r+2≤n+2) : + (deletionMapL (m:=m) r hr).map (algebraMap (SpectralRing m) (SpectralField m))=deletionMap r hr := by + unfold deletionMapL + rw [Matrix.map_mul,Matrix.map_mul,functionMatrix_ring_map,functionMatrix_ring_map,rawLocal_map] + unfold deletionMap + congr 2 + funext t + cases t <;> simp [Weights.tile,deletionWeights] + +def nodalHeadL {n : ℕ} (i : Fin n) (occupied : Prop) [Decidable occupied] : Laurent n := + if occupied then constantL n (4*c)*sineL (-variableExponent i) (phase^3) + else cosineL ((2:ℤ) • variableExponent i) (phase^(-3:ℤ))+ + cosineL ((2:ℤ) • variableExponent i) (phase^3)+constantL n rho + +lemma nodalHeadL_map {n : ℕ} (i : Fin n) (occupied : Prop) [Decidable occupied] : + evalLaurent (nodalHeadL i occupied)=reducedNodalHead i occupied := by + by_cases h:occupied + · simp only [nodalHeadL,reducedNodalHead,ite_eq_left h,evalLaurent,map_mul,map_constantL] + rw [sineL_map _ _ (pow_ne_zero _ phase_ne_zero),map_monomialL_neg_variable] + change constF n 4*constF n c*torusSin (constF n (phase^3)*(variableF i)⁻¹)=_ + simp only [constF,map_ofNat,map_pow,div_eq_mul_inv] + · simp only [nodalHeadL,reducedNodalHead,ite_eq_right h,evalLaurent,map_add,map_constantL] + change evalLaurent (cosineL _ _)+evalLaurent (cosineL _ _)+constF n rho=_ + rw [←deletionBeta_laurent] + congr 2 + rw [cosineL_map _ _ (zpow_ne_zero _ phase_ne_zero),map_monomialL_two_variable] + change torusCos (constF n (phase^(-3:ℤ))*variableF i^2)=torusCos (variableF i^2/constF n phase^3) + congr 1 + simp only [constF,zpow_neg,zpow_ofNat,map_inv₀,map_pow] + ring + +def reflectionFactorL {n : ℕ} (i j : Fin n) : Laurent n := + if j=i then 1 else sineL (variableExponent i+variableExponent j) (phase^3) + +lemma reflectionFactorL_map {n : ℕ} (i j : Fin n) : + evalLaurent (reflectionFactorL i j)=reflectionFactor i j := by + by_cases h:j=i + · simp [reflectionFactorL,reflectionFactor,h,evalLaurent] + · simp only [reflectionFactorL,reflectionFactor,ite_eq_right h] + change (algebraMap (SpectralRing n) (SpectralField n)) (sineL _ _)=_ + rw [sineL_map _ _ (pow_ne_zero _ phase_ne_zero)] + change torusSin (evalLaurent (monomialL _ _))=_ + rw [map_monomialL_add_variable] + simp only [constF,map_pow] + + + +def nodalDatumL {n : ℕ} (W : Pairing n → Laurent n) (i : Fin (n+1)) (p : Pairing (n+2)) : Laurent (n+1) := + (∏ j,reflectionFactorL i j)*nodalHeadL i (p.Occupied (Fin.last (n+1)))* + (matrixPrefix (reducedMovingStepL i) (n+1)).mulVec + ((deletionMapL i.val (show i.val+2≤n+2 by omega)).mulVec + (fun q => insertLaurent i (W q))) p + +lemma nodalDatumL_map {n : ℕ} (W : Pairing n → Laurent n) + (hW:∀ p,evalLaurent (W p)=rationalVacuum n p) (i : Fin (n+1)) (p : Pairing (n+2)) : + evalLaurent (nodalDatumL W i p)= + nodalVacuum i p/(if p.Occupied (Fin.last (n+1)) then torusSin (deletionNode i) else 1) := by + rw [reducedNodalDatum_eq] + simp only [nodalDatumL,evalLaurent,map_mul,map_prod] + change (∏ j,evalLaurent (reflectionFactorL i j))*evalLaurent (nodalHeadL i _) * + (algebraMap (SpectralRing (n+1)) (SpectralField (n+1))) + ((matrixPrefix (reducedMovingStepL i) (n+1)).mulVec _ p)=_ + simp only [reflectionFactorL_map,nodalHeadL_map] + simp only [RingHom.map_mulVec,Function.comp_def,reducedMovingTrainL_map,deletionMapL_map] + have hw (q:Pairing n) : (algebraMap (SpectralRing (n+1)) (SpectralField (n+1))) (insertLaurent i (W q))=insertSpectral i (rationalVacuum n q) := by + change evalLaurent (insertLaurent i (W q))=_ + rw [←insertSpectral_evalLaurent,hW] + simp only [hw] + exact mul_assoc _ _ _ + + + + + + + +lemma LaurentBox.cosine {n : ℕ} (e:Fin n → ℤ) (z:ℂ) (b:Fin n → ℕ) + (he:∀ i,-(b i:ℤ)≤e i ∧ e i≤b i) : LaurentBox (cosineL e z) b := by + apply LaurentBox.add + · exact LaurentBox.single e _ b he + · exact LaurentBox.single (-e) _ b (by intro i; have :=he i; simp only [Pi.neg_apply]; omega) + +lemma LaurentBox.pow {n : ℕ} {f:Laurent n} {b:Fin n → ℕ} (hf:LaurentBox f b) (k:ℕ) : + LaurentBox (f^k) (fun i => k*b i) := by + induction k with + | zero => + rw [pow_zero] + intro e he i + simpa only [Nat.zero_mul,Pi.zero_apply] using LaurentBox.one e he i + | succ k ih => + rw [pow_succ] + convert ih.mul hf using 1 + funext i + simp [Nat.succ_mul] + +lemma LaurentBox.insert {n : ℕ} (i:Fin (n+1)) {f:Laurent n} {b:Fin n → ℕ} + (hf:LaurentBox f b) : LaurentBox (insertLaurent i f) (Fin.insertNth i 0 b) := by + intro e he k + have hs : e∈f.coeff.support.image (insertExponent i) := + (Finsupp.mapDomain_support (s:=f.coeff) (f:=insertExponent i)) (Finsupp.mem_support_iff.mpr he) + obtain ⟨a,ha,rfl⟩:=Finset.mem_image.mp hs + refine Fin.succAboveCases i ?_ (fun j => ?_) k + · simp [insertExponent] + · simpa only [insertExponent,AddMonoidHom.coe_mk,ZeroHom.coe_mk,Fin.insertNth_apply_succAbove] using + hf a (Finsupp.mem_support_iff.mp ha) j + +lemma LaurentMatrixBox.mulVec {n:ℕ} {α β:Type*} [Fintype β] + {A:Matrix α β (Laurent n)} {v:β → Laurent n} {a b:Fin n → ℕ} + (hA:LaurentMatrixBox A a) (hv:∀ q,LaurentBox (v q) b) : + ∀ p,LaurentBox (A.mulVec v p) (a+b) := by + intro p + exact LaurentBox.sum _ _ _ (fun q _ => (hA p q).mul (hv q)) + +lemma functionMatrix_box {n:ℕ} {α β:Type*} (f:α → β) : + LaurentMatrixBox (functionMatrix (K:=Laurent n) f) 0 := by + intro p q + unfold functionMatrix optionMatrix + split_ifs + · exact LaurentBox.one + · exact LaurentBox.zero _ + +lemma LaurentMatrixBox.mono {n:ℕ} {α β:Type*} {A:Matrix α β (Laurent n)} {a b:Fin n → ℕ} + (hA:LaurentMatrixBox A a) (hab:∀ i,a i≤b i) : LaurentMatrixBox A b := + fun p q => (hA p q).mono hab + + + + + + + +def pairBound {n:ℕ} (i j k:Fin n) : ℕ := if j=i then 0 else if k=i ∨ k=j then 1 else 0 + +def selfBound {n:ℕ} (i:Fin n) (b:ℕ) (k:Fin n) : ℕ := if k=i then b else 0 + +lemma pairBound_add {n:ℕ} (i j:Fin n) (h:j≠i) (k:Fin n) : + -(pairBound i j k:ℤ)≤(variableExponent i+variableExponent j) k ∧ + (variableExponent i+variableExponent j) k ≤ pairBound i j k := by + by_cases hki:k=i <;> by_cases hkj:k=j + all_goals simp_all [pairBound,variableExponent] + +lemma pairBound_sub {n:ℕ} (i j k:Fin n) : + -(pairBound i j k:ℤ)≤(variableExponent i-variableExponent j) k ∧ + (variableExponent i-variableExponent j) k ≤ pairBound i j k := by + by_cases hij:j=i <;> by_cases hki:k=i <;> by_cases hkj:k=j + all_goals simp_all [pairBound,variableExponent] + +lemma sum_pairBound {n:ℕ} (i k:Fin (n+1)) : + (∑ j:Fin (n+1),pairBound i j k)=if k=i then n else 1 := by + by_cases hki:k=i + · subst k + simp only [pairBound,ite_true] + simp only [Finset.sum_ite,Finset.sum_const_zero,zero_add,Finset.sum_const,smul_eq_mul,mul_one] + have h:Finset.univ.filter (fun j:Fin (n+1) => ¬j=i)=Finset.univ.erase i := by ext j; simp [eq_comm] + rw [h] + simp [Finset.card_erase_of_mem (Finset.mem_univ i)] + · have hh (j:Fin (n+1)) : pairBound i j k=if j=k then 1 else 0 := by + by_cases hj:j=i <;> by_cases hk:j=k <;> simp_all [pairBound,eq_comm] + simp only [hh,Finset.sum_ite_eq',Finset.mem_univ,ite_true,hki,ite_false] + +lemma reflectionFactorL_box {n:ℕ} (i j:Fin n) : + LaurentBox (reflectionFactorL i j) (pairBound i j) := by + by_cases h:j=i + · subst j + rw [reflectionFactorL,ite_eq_left rfl] + convert LaurentBox.one (n:=n) using 1 + funext k + simp [pairBound] + · rw [reflectionFactorL,ite_eq_right h] + exact LaurentBox.sine _ _ _ (pairBound_add i j h) + +lemma reducedMovingStepL_box {n:ℕ} (i j:Fin n) : + LaurentMatrixBox (reducedMovingStepL i j) (fun k => 3*pairBound i j k) := by + by_cases h:j=i + · subst j + rw [reducedMovingStepL,ite_eq_left rfl] + convert LaurentMatrixBox.one (n:=n) (α:=Pairing (n+1)) using 1 + funext k + simp [pairBound] + · rw [reducedMovingStepL,ite_eq_right h] + have hs:LaurentBox (constantL n (-4)*sineL (variableExponent i+variableExponent j) (phase^(-6:ℤ))) (pairBound i j) := by + simpa using (LaurentBox.constant (-4)).mul (LaurentBox.sine _ _ _ (pairBound_add i j h)) + have hn:=torusNumeratorL_box (variableExponent i-variableExponent j) (phase^3) (pairBound i j) (pairBound_sub i j) + have ht:LaurentMatrixBox + (if i simp_all [selfBound,variableExponent] + have hn:∀ k,-(selfBound i 2 k:ℤ)≤(-variableExponent i) k ∧ + (-variableExponent i) k ≤ selfBound i 2 k := by + intro k + by_cases h:k=i <;> simp_all [selfBound,variableExponent,Pi.single_apply] + unfold nodalHeadL + split_ifs + · simpa using (LaurentBox.constant (4*c)).mul (LaurentBox.sine _ _ _ hn) + · exact ((LaurentBox.cosine _ _ _ he).add (LaurentBox.cosine _ _ _ he)).add + ((LaurentBox.constant rho).mono (fun k => Nat.zero_le _)) + +lemma deletionMapL_box {n m:ℕ} (r:ℕ) (hr:r+2≤n+2) : + LaurentMatrixBox (deletionMapL (m:=m) r hr) 0 := by + have hw:∀ t:Tile,LaurentBox ((deletionWeights : Weights (Laurent m)).tile t) 0 := by + intro t + cases t <;> simp only [Weights.tile,deletionWeights] + all_goals first | exact LaurentBox.one | exact LaurentBox.zero _ + simpa only [deletionMapL,zero_add,Matrix.mul_assoc] using + (rawLocal_box (PartialColumn.rowPosition r hr) _ _ hw).mul + ((functionMatrix_box (n:=m) (Pairing.map (Fin.succAboveOrderEmb (⟨r+1,by omega⟩ : Fin (n+2))))).mul + (functionMatrix_box (n:=m) (Pairing.map (Fin.succAboveOrderEmb (⟨r,by omega⟩ : Fin (n+1)))))) + + +lemma nodalDatumL_box {n:ℕ} (W:Pairing n → Laurent n) + (hW:∀ p,LaurentBox (W p) (fun _ => 2*n-2)) (i:Fin (n+1)) (p:Pairing (n+2)) : + LaurentBox (nodalDatumL W i p) (fun k => if k=i then 4*n+2 else 2*n+2) := by + have hr:=LaurentBox.prod Finset.univ (reflectionFactorL i) (pairBound i) + (fun j _ => reflectionFactorL_box i j) + have ht:=matrixPrefix_box (reducedMovingStepL i) (fun j k => 3*pairBound i j k) + (reducedMovingStepL_box i) + have hw:= (deletionMapL_box (m:=n+1) i.val (show i.val+2≤n+2 by omega)).mulVec + (fun q => (hW q).insert i) + have hres:= (hr.mul (nodalHeadL_box i (p.Occupied (Fin.last (n+1))))).mul + (ht.mulVec hw p) + apply hres.mono + intro k + simp only [Pi.add_apply,Finset.sum_apply,zero_add,←Finset.mul_sum,sum_pairBound] + by_cases hk:k=i + · subst k + simp only [selfBound,ite_true,Fin.insertNth_apply_same] + omega + · obtain ⟨j,hj⟩:=Fin.exists_succAbove_eq hk + rw [←hj,Fin.insertNth_apply_succAbove] + simp only [Fin.succAbove_ne,ite_false,selfBound] + have hn:1≤n := by have :=j.isLt; omega + omega + +end +end CriticalStrip.Diagram + +end OAI diff --git a/lean/OAI/Combinatorics/StripMass/LocalPadding.lean b/lean/OAI/Combinatorics/StripMass/LocalPadding.lean new file mode 100644 index 0000000000000000000000000000000000000000..b60cbc1beca13851ed21f0040fa14724fa018e4c --- /dev/null +++ b/lean/OAI/Combinatorics/StripMass/LocalPadding.lean @@ -0,0 +1,589 @@ +import Mathlib +import OAI.Combinatorics.StripMass.ColumnSweep +import OAI.Combinatorics.StripMass.MirrorExterior + +namespace OAI + +/-! Critical honeycomb strip paths, polynomial identities and crossing mass. -/ + + + +namespace CriticalStrip.Diagram +noncomputable section +open scoped Classical +open Finset +namespace Position +variable {n : ℕ} +def padTop (a : Position n) : Position (n+1) := + ⟨a.left.castSucc,a.right.castSucc,a.adjacent⟩ +def padBottom (a : Position n) : Position (n+1) := + ⟨a.left.succ,a.right.succ,by have:=a.adjacent; simp only [Fin.val_succ]; omega⟩ +end Position + +namespace Pairing +lemma map_injective {n m : ℕ} (f : Fin n ↪o Fin m) : Function.Injective (Pairing.map f) := by + intro p q h + simpa only [restrict_map] using congrArg (Pairing.restrict f) h +end Pairing + +lemma optionMatrix_map {K P Q : Type*} [Zero K] [One K] (e : P → Q) (he : Function.Injective e) + (f : P → Option P) (g : Q → Option Q) (h : ∀ p, g (e p)=(f p).map e) (p q : P) : + (optionMatrix g : Matrix Q Q K) (e q) (e p) = optionMatrix f q p := by + unfold optionMatrix + rw [h] + cases hf : f p <;> simp [he.eq_iff] + +lemma localR_padTop {K : Type*} [CommRing K] {n : ℕ} (a : Position n) (w : Weights K) + (p q : Pairing n) : + localR a.padTop w q.padTop p.padTop=localR a w q p := by + unfold localR + simp only [Matrix.sum_apply,Matrix.smul_apply] + apply sum_congr rfl + intro t _ + congr 1 + exact optionMatrix_map Pairing.padTop (Pairing.map_injective Fin.castSuccOrderEmb) + _ _ (fun p => p.map_tileStep Fin.castSuccOrderEmb a.left a.right a.adjacent a.adjacent t) p q + +lemma localR_padBottom {K : Type*} [CommRing K] {n : ℕ} (a : Position n) (w : Weights K) + (p q : Pairing n) : + localR a.padBottom w q.padBottom p.padBottom=localR a w q p := by + unfold localR + simp only [Matrix.sum_apply,Matrix.smul_apply] + apply sum_congr rfl + intro t _ + congr 1 + exact optionMatrix_map Pairing.padBottom (Pairing.map_injective (Fin.succOrderEmb n)) + _ _ (fun p => p.map_tileStep (Fin.succOrderEmb n) a.left a.right a.adjacent a.padBottom.adjacent t) p q + +lemma localR_zero_of_support {K : Type*} [CommRing K] {n : ℕ} (a : Position n) (w : Weights K) + (p q : Pairing n) (i : Fin n) (hia : i≠a.left) (hib : i≠a.right) + (h : ¬ (q.Occupied i ↔ p.Occupied i)) : localR a w q p=0 := by + unfold localR + simp only [Matrix.sum_apply,Matrix.smul_apply,optionMatrix] + apply sum_eq_zero + intro t _ + have hn : p.tileStep a.left a.right a.adjacent t≠some q := by + intro hh + have hs := p.tileStep_support a.left a.right a.adjacent t q hh i + exact h (by simpa only [Pairing.stepSupport,ite_eq_right hia,ite_eq_right hib] using hs) + simp only [hn,ite_false,smul_zero] + +lemma localR_padTop_outside {K : Type*} [CommRing K] {n : ℕ} (a : Position n) (w : Weights K) + (p : Pairing (n+1)) (q : Pairing n) (hp : ¬ ∃ r : Pairing n, r.padTop=p) : + localR a.padTop w q.padTop p=0 := by + apply localR_zero_of_support a.padTop w p q.padTop (Fin.last n) + · intro he; have hh:=congrArg Fin.val he; simp [Position.padTop] at hh; omega + · intro he; have hh:=congrArg Fin.val he; simp [Position.padTop] at hh; omega + · simp only [Pairing.padTop_not_occupied_last,false_iff,not_not] + by_contra hh + exact hp ⟨p.restrict Fin.castSuccOrderEmb,Pairing.padTop_restrict p hh⟩ + +lemma localR_padBottom_outside {K : Type*} [CommRing K] {n : ℕ} (a : Position n) (w : Weights K) + (p : Pairing n) (q : Pairing (n+1)) (hq : ¬ ∃ r : Pairing n, r.padBottom=q) : + localR a.padBottom w q p.padBottom=0 := by + apply localR_zero_of_support a.padBottom w p.padBottom q 0 + · intro he; have hh:=congrArg Fin.val he; simp [Position.padBottom] at hh + · intro he; have hh:=congrArg Fin.val he; simp [Position.padBottom] at hh + · simp only [Pairing.padBottom_not_occupied_zero,iff_false,not_not] + by_contra hh + exact hq ⟨q.restrict (Fin.succOrderEmb n),Pairing.padBottom_restrict q hh⟩ + +lemma localR_top_matrix {K : Type*} [CommRing K] {n : ℕ} (a : Position n) (w : Weights K) + (M : Matrix (Pairing (n+1)) (Pairing (n+1)) K) (p q : Pairing n) : + (localR a.padTop w * M) q.padTop p.padBottom = + (localR a w * M.submatrix Pairing.padTop Pairing.padBottom) q p := by + simp only [Matrix.mul_apply,Matrix.submatrix_apply] + symm + apply Fintype.sum_of_injective Pairing.padTop (Pairing.map_injective Fin.castSuccOrderEmb) + · intro r hr + simp only [localR_padTop_outside a w r q hr,zero_mul] + · intro r + rw [localR_padTop] + +lemma localR_bottom_matrix {K : Type*} [CommRing K] {n : ℕ} (a : Position n) (w : Weights K) + (M : Matrix (Pairing (n+1)) (Pairing (n+1)) K) (p q : Pairing n) : + (M * localR a.padBottom w) q.padTop p.padBottom = + (M.submatrix Pairing.padTop Pairing.padBottom * localR a w) q p := by + simp only [Matrix.mul_apply,Matrix.submatrix_apply] + symm + apply Fintype.sum_of_injective Pairing.padBottom (Pairing.map_injective (Fin.succOrderEmb n)) + · intro r hr + simp only [localR_padBottom_outside a w p r hr,mul_zero] + · intro r + rw [localR_padBottom] + +end + + + + + +noncomputable section +namespace PartialColumn +variable {K : Type*} [CommRing K] {n : ℕ} + +omit [CommRing K] in +lemma program_congr (w v : Fin n → Weights K) (k : ℕ) (hk : k≤n) + (h : ∀ i : Fin n, i.val rfl + | succ k ih => + change Program.snoc (program w k _) (position ⟨k,hk⟩) (w ⟨k,hk⟩)= + Program.snoc (program v k _) (position ⟨k,hk⟩) (v ⟨k,hk⟩) + rw [ih (by omega) (fun i hi => h i (by omega)),h ⟨k,hk⟩ (by simp)] + +lemma program_commute (w : Fin n → Weights K) (k : ℕ) (hk : k≤n) + (R : Matrix (Pairing (n+1)) (Pairing (n+1)) K) + (h : ∀ i : Fin n, i.val simp [program,Program.matrix] + | succ k ih => + change (localR (position ⟨k,hk⟩) (w ⟨k,hk⟩)*(program w k _).matrix)*R= + R*(localR (position ⟨k,hk⟩) (w ⟨k,hk⟩)*(program w k _).matrix) + rw [Matrix.mul_assoc,ih (by omega) (fun i hi => h i (by omega)), + ←Matrix.mul_assoc,h ⟨k,hk⟩ (by simp),Matrix.mul_assoc] + +lemma exchange_program (w v : Fin n → Weights K) (r : ℕ) (hr : r+2≤n) + (L R : Matrix (Pairing (n+1)) (Pairing (n+1)) K) + (he : ∀ i : Fin n, i.val≠r → i.val≠r+1 → w i=v i) + (hlow : ∀ i : Fin n, i.val he i (by omega) (by omega)) + change (localR (position ⟨r+1,by omega⟩) (w ⟨r+1,by omega⟩) * + (localR (position ⟨r,by omega⟩) (w ⟨r,by omega⟩) * (program w r _).matrix))*R = + L*(localR (position ⟨r+1,by omega⟩) (v ⟨r+1,by omega⟩) * + (localR (position ⟨r,by omega⟩) (v ⟨r,by omega⟩) * (program v r _).matrix)) + rw [Matrix.mul_assoc,Matrix.mul_assoc,hcomm,←Matrix.mul_assoc, + ←Matrix.mul_assoc,hyb,heq] + simp only [Matrix.mul_assoc] + have hstep (k : ℕ) (hkr : r+2≤k) (hkn : k≤n) : + (program w k hkn).matrix*R=L*(program v k hkn).matrix := by + induction k,hkr using Nat.le_induction with + | base => exact hbase + | succ k hk ih => + have hk' : k + change (1 : Matrix (Pairing (n+1)) (Pairing (n+1)) K) q p=0 + exact Matrix.one_apply_ne (fun he => h (he ▸ Iff.rfl)) + | succ k ih => + change (localR (position (n := n) ⟨k,hk⟩) (w ⟨k,hk⟩) * (program w k _).matrix) q p=0 + rw [Matrix.mul_apply] + apply sum_eq_zero + intro r _ + by_cases hr : q.Occupied j ↔ r.Occupied j + · rw [ih (by omega) r (by omega) (fun hh => h (hr.trans hh)),mul_zero] + · rw [localR_zero_of_support _ _ r q j (by intro he; have hh:=congrArg Fin.val he; change j.val=k at hh; omega) + (by intro he; have hh:=congrArg Fin.val he; change j.val=k+1 at hh; omega) hr,zero_mul] + + + +lemma exchange_program_column (w v : Fin n → Weights K) (r : ℕ) (hr : r+2≤n) + (L R : Matrix (Pairing (n+1)) (Pairing (n+1)) K) (p : Pairing (n+1)) + (P : Pairing (n+1) → Prop) + (hzero : ∀ t, ¬P t → (program w r (by omega)).matrix t p=0) + (he : ∀ i : Fin n, i.val≠r → i.val≠r+1 → w i=v i) + (hlow : ∀ i : Fin n, i.val he i (by omega) (by omega)) + change ((localR (position (n := n) ⟨r+1,by omega⟩) (w ⟨r+1,by omega⟩) * + (localR (position (n := n) ⟨r,by omega⟩) (w ⟨r,by omega⟩) * (program w r _).matrix))*R) q p = + (L*(localR (position (n := n) ⟨r+1,by omega⟩) (v ⟨r+1,by omega⟩) * + (localR (position (n := n) ⟨r,by omega⟩) (v ⟨r,by omega⟩) * (program v r _).matrix))) q p + rw [Matrix.mul_assoc,Matrix.mul_assoc,hcomm,←Matrix.mul_assoc,←Matrix.mul_assoc] + rw [←Matrix.mul_assoc L,←Matrix.mul_assoc,←heq] + rw [Matrix.mul_apply, Matrix.mul_apply] + apply sum_congr rfl + intro t _ + by_cases ht : P t + · rw [hyb t ht q] + · rw [hzero t ht,mul_zero,mul_zero] + have hstep (k : ℕ) (hkr : r+2≤k) (hkn : k≤n) : + ∀ q, ((program w k hkn).matrix*R) q p=(L*(program v k hkn).matrix) q p := by + induction k,hkr using Nat.le_induction with + | base => exact hbase + | succ k hk ih => + intro q + have hk' : k intro he <;> have hh:=congrArg Fin.val he <;> simp at hh <;> omega + +lemma row_disjoint_high (r : ℕ) (hr : r+2≤n) (i : Fin n) (hi : r + 1 < i.val) : + (position i).Disjoint (rowPosition r hr).padTop := by + dsimp [Position.Disjoint,position,rowPosition,Position.padTop] + refine ⟨?_,?_,?_,?_⟩ <;> intro he <;> have hh:=congrArg Fin.val he <;> simp at hh <;> omega + + + +theorem torus_column_exchange (r : ℕ) (hr : r+2≤n) (x : Fin n → SpectralField m) + (z : SpectralField m) (hz : z≠0) (hw : x ⟨r+1,by omega⟩≠0) + (hLz : torusL z≠0) (hLw : torusL (x ⟨r+1,by omega⟩)≠0) + (hLx : torusL (x ⟨r,by omega⟩)≠0) + (hx : z*x ⟨r+1,by omega⟩=x ⟨r,by omega⟩) : + column (fun i => torusWeights (x i)) * localR (rowPosition r hr) (torusWeights z) = + localR (rowPosition r hr) (torusWeights z) * + column (fun i => torusWeights (x (Equiv.swap ⟨r,by omega⟩ ⟨r+1,by omega⟩ i))) := by + let w : Fin n → Weights (SpectralField m) := fun i => torusWeights (x i) + let v : Fin n → Weights (SpectralField m) := fun i => + torusWeights (x (Equiv.swap ⟨r,by omega⟩ ⟨r+1,by omega⟩ i)) + have hyb : localR (position ⟨r+1,by omega⟩) (w ⟨r+1,by omega⟩) * + localR (position ⟨r,by omega⟩) (w ⟨r,by omega⟩) * + localR (rowPosition r hr).padBottom (torusWeights z) = + localR (rowPosition r hr).padTop (torusWeights z) * + localR (position ⟨r+1,by omega⟩) (v ⟨r+1,by omega⟩) * + localR (position ⟨r,by omega⟩) (v ⟨r,by omega⟩) := by + simpa only [w,v,Equiv.swap_apply_left,Equiv.swap_apply_right,hx, + rowTriple,TriplePosition.left,TriplePosition.right,position,rowPosition, + Position.padTop,Position.padBottom,Fin.castSucc_mk,Fin.succ_mk,Nat.add_assoc] using + (rowTriple r hr).torus_yang_baxter z (x ⟨r+1,by omega⟩) hz hw hLz hLw (by rwa [hx]) + have he (i : Fin n) (hi : i.val≠r) (hj : i.val≠r+1) : w i=v i := by + dsimp [w,v] + rw [Equiv.swap_apply_of_ne_of_ne (fun he => hi (congrArg Fin.val he)) + (fun he => hj (congrArg Fin.val he))] + have H := exchange_program w v r hr + (localR (rowPosition r hr).padTop (torusWeights z)) + (localR (rowPosition r hr).padBottom (torusWeights z)) he + (fun i hi => localR_commute _ _ (row_disjoint_low r hr i hi) _ _) + (fun i hi => localR_commute _ _ (row_disjoint_high r hr i hi) _ _) hyb + have hcw : (program w n le_rfl).matrix.submatrix Pairing.padTop Pairing.padBottom=column w := by + ext q p + exact program_column (by omega) w p q + have hcv : (program v n le_rfl).matrix.submatrix Pairing.padTop Pairing.padBottom=column v := by + ext q p + exact program_column (by omega) v p q + ext q p + have HH:=congrArg (fun M => M q.padTop p.padBottom) H + rw [localR_bottom_matrix,localR_top_matrix,hcw,hcv] at HH + exact HH + + + + + + +lemma column_restricted_train {K : Type*} [CommRing K] + (w v : Fin n → Weights K) (r : ℕ) (hr : r+2≤n) (a : Weights K) + (p : Pairing n) (P : Pairing (n+1) → Prop) + (hzero : ∀ t, ¬P t → (program w r (by omega)).matrix t p.padBottom=0) + (he : ∀ i : Fin n, i.val≠r → i.val≠r+1 → w i=v i) + (hyb : ∀ t, P t → ∀ q, + (localR (position (n := n) ⟨r+1,by omega⟩) (w ⟨r+1,by omega⟩) * + localR (position (n := n) ⟨r,by omega⟩) (w ⟨r,by omega⟩) * + localR (rowPosition r hr).padBottom a) q t = + (localR (rowPosition r hr).padTop a * + localR (position (n := n) ⟨r+1,by omega⟩) (v ⟨r+1,by omega⟩) * + localR (position (n := n) ⟨r,by omega⟩) (v ⟨r,by omega⟩)) q t) (q : Pairing n) : + (column w * localR (rowPosition r hr) a) q p = + (localR (rowPosition r hr) a * column v) q p := by + have H := exchange_program_column w v r hr + (localR (rowPosition r hr).padTop a) (localR (rowPosition r hr).padBottom a) + p.padBottom P hzero he + (fun i hi => localR_commute _ _ (row_disjoint_low r hr i hi) _ _) + (fun i hi => localR_commute _ _ (row_disjoint_high r hr i hi) _ _) hyb q.padTop + have hcw : (program w n le_rfl).matrix.submatrix Pairing.padTop Pairing.padBottom=column w := by + ext q p; exact program_column (by omega) w p q + have hcv : (program v n le_rfl).matrix.submatrix Pairing.padTop Pairing.padBottom=column v := by + ext q p; exact program_column (by omega) v p q + rw [localR_bottom_matrix,localR_top_matrix,hcw,hcv] at H + exact H + + +theorem column_deletion (r : ℕ) (hr : r+2≤n) + (w v : Fin n → Weights (SpectralField m)) (z : SpectralField m) + (hz : z≠0) (hL : torusL z≠0) (hL3 : torusL (constF m phase^3*z)≠0) + (hw₀ : w ⟨r,by omega⟩=torusWeights (constF m phase^3*z)) + (hw₁ : w ⟨r+1,by omega⟩=torusWeights z) + (hv₀ : v ⟨r,by omega⟩=swapWeights) (hv₁ : v ⟨r+1,by omega⟩=swapWeights) + (he : ∀ i : Fin n, i.val≠r → i.val≠r+1 → w i=v i) + (p q : Pairing n) (hb : ¬p.Occupied ⟨r,by omega⟩) + (hc : ¬p.Occupied ⟨r+1,by omega⟩) : + ((column w * localR (rowPosition r hr) deletionWeights : + Matrix (Pairing n) (Pairing n) (SpectralField m))) q p = + ((localR (rowPosition r hr) deletionWeights * column v : + Matrix (Pairing n) (Pairing n) (SpectralField m))) q p := by + apply column_restricted_train w v r hr deletionWeights p + (fun t => ¬t.Occupied ⟨r+1,by omega⟩ ∧ ¬t.Occupied ⟨r+2,by omega⟩) _ he _ q + · intro t ht + by_cases h₁ : t.Occupied ⟨r+1,by omega⟩ + · apply program_zero_above w r (by omega) p.padBottom t ⟨r+1,by omega⟩ (by simp) + intro hh + exact hb ((Pairing.padBottom_occupied_succ p ⟨r,by omega⟩).mp (hh.mp h₁)) + · have h₂ : t.Occupied ⟨r+2,by omega⟩ := Classical.not_not.mp (fun h₂ => ht ⟨h₁,h₂⟩) + apply program_zero_above w r (by omega) p.padBottom t ⟨r+2,by omega⟩ (by simp) + intro hh + exact hc ((Pairing.padBottom_occupied_succ p ⟨r+1,by omega⟩).mp (hh.mp h₂)) + · intro t ht s + rw [hw₀,hw₁,hv₀,hv₁] + simpa only [rowTriple,TriplePosition.left,TriplePosition.right,position,rowPosition, + Position.padTop,Position.padBottom,Fin.castSucc_mk,Fin.succ_mk,Nat.add_assoc] + using (rowTriple r hr).deletion z hz hL hL3 t s ht.1 ht.2 + + +theorem column_merge (r : ℕ) (hr : r+2≤n) + (w v : Fin n → Weights (SpectralField m)) (z : SpectralField m) + (hz : z≠0) (hL : torusL z≠0) (hL1 : torusL (constF m phase*z)≠0) + (hL2 : torusL (constF m phase^2*z)≠0) + (hw₀ : w ⟨r,by omega⟩=torusWeights (constF m phase^2*z)) + (hw₁ : w ⟨r+1,by omega⟩=torusWeights z) + (hv₀ : v ⟨r,by omega⟩=torusWeights (constF m phase*z)) + (hv₁ : v ⟨r+1,by omega⟩=swapWeights) + (he : ∀ i : Fin n, i.val≠r → i.val≠r+1 → w i=v i) + (p q : Pairing n) (hc : ¬p.Occupied ⟨r+1,by omega⟩) : + ((column w * localR (rowPosition r hr) (mergeWeights (constF m phase)) : + Matrix (Pairing n) (Pairing n) (SpectralField m))) q p = + ((localR (rowPosition r hr) (mergeWeights (constF m phase)) * column v : + Matrix (Pairing n) (Pairing n) (SpectralField m))) q p := by + apply column_restricted_train w v r hr (mergeWeights (constF m phase)) p + (fun t => ¬t.Occupied ⟨r+2,by omega⟩) _ he _ q + · intro t ht + apply program_zero_above w r (by omega) p.padBottom t ⟨r+2,by omega⟩ (by simp) + intro hh + exact hc ((Pairing.padBottom_occupied_succ p ⟨r+1,by omega⟩).mp (hh.mp (Classical.not_not.mp ht))) + · intro t ht s + rw [hw₀,hw₁,hv₀,hv₁] + simpa only [rowTriple,TriplePosition.left,TriplePosition.right,position,rowPosition, + Position.padTop,Position.padBottom,Fin.castSucc_mk,Fin.succ_mk,Nat.add_assoc] + using (rowTriple r hr).merge z hz hL hL1 hL2 t s ht + +end PartialColumn +end + + + + + +noncomputable section +open scoped Classical +open Finset + +variable {K : Type*} [CommRing K] + +def functionMatrix {P Q : Type*} (f : P → Q) : Matrix Q P K := optionMatrix (some ∘ f) + +lemma functionMatrix_mul {P Q R : Type*} [Fintype Q] (f : P → Q) (g : Q → R) : + (functionMatrix (K := K) g : Matrix R Q K) * functionMatrix (K := K) f = functionMatrix (g ∘ f) := by + exact optionMatrix_mul (some ∘ f) (some ∘ g) + +lemma mul_functionMatrix {P Q R : Type*} [Fintype Q] (f : P → Q) (M : Matrix R Q K) + (r : R) (p : P) : (M * functionMatrix (K := K) f) r p = M r (f p) := by + simp only [Matrix.mul_apply,functionMatrix,optionMatrix,Function.comp_apply,Option.some.injEq] + rw [sum_eq_single (f p)] + · simp + · intro q _ hq; simp [Ne.symm hq] + · simp + +lemma functionMatrix_mul_apply {P Q R : Type*} [Fintype P] (f : P → Q) + (hf : Function.Injective f) (M : Matrix P R K) (p : P) (r : R) : + (functionMatrix (K := K) f * M) (f p) r = M p r := by + simp only [Matrix.mul_apply,functionMatrix,optionMatrix,Function.comp_apply,Option.some.injEq, + hf.eq_iff] + rw [sum_eq_single p] + · simp + · intro q _ hq; simp [hq] + · simp + +lemma functionMatrix_mul_outside {P Q R : Type*} [Fintype P] (f : P → Q) + (M : Matrix P R K) (q : Q) (r : R) (h : ¬ ∃ p, f p=q) : + (functionMatrix (K := K) f * M) q r=0 := by + simp only [Matrix.mul_apply,functionMatrix,optionMatrix,Function.comp_apply,Option.some.injEq] + apply sum_eq_zero + intro p _ + rw [ite_eq_right (fun he => h ⟨p,he⟩),zero_mul] + +lemma optionMatrix_natural {P Q : Type*} [Fintype P] [Fintype Q] + (f : P → Q) (a : P → Option P) (b : Q → Option Q) + (h : ∀ p, b (f p)=(a p).map f) : + (optionMatrix b : Matrix Q Q K) * functionMatrix (K := K) f = functionMatrix (K := K) f * optionMatrix a := by + calc + _ = optionMatrix (fun p => ((some ∘ f) p).bind b) := + optionMatrix_mul (some ∘ f) b + _ = optionMatrix (fun p => (a p).bind (some ∘ f)) := by + congr 1 + funext p + simp only [Function.comp_apply, Option.bind_some] + rw [h p] + cases a p <;> rfl + _ = _ := (optionMatrix_mul a (some ∘ f)).symm + +lemma localR_natural {n m : ℕ} (f : Fin n ↪o Fin m) + (a : Position n) (b : Position m) (ha : f a.left=b.left) (hb : f a.right=b.right) + (w : Weights K) : + localR b w * functionMatrix (K := K) (Pairing.map f) = functionMatrix (K := K) (Pairing.map f) * localR a w := by + simp only [localR,Matrix.sum_mul,Matrix.mul_sum,Matrix.smul_mul,Matrix.mul_smul] + apply sum_congr rfl + intro t _ + congr 1 + apply optionMatrix_natural + intro p + simpa only [ha,hb] using p.map_tileStep f a.left a.right a.adjacent (by rw [ha,hb]; exact b.adjacent) t + +end +end CriticalStrip.Diagram + + + + + +namespace Fin +open scoped _root_.Fin +lemma swap_succAbove_adjacent {n : ℕ} (a b : Fin (n+1)) (hab : a.val+1=b.val) + (i : Fin n) : Equiv.swap a b (b.succAbove i)=a.succAbove i := by + by_cases hi : i.val(P p).map (pairEvaluation n 2).toRingHom)= + fun p =>mergePairPolynomial n* + matrixPolynomial (mergeMap 0 (show 2≤n+3 by omega)) + (fun q =>(Q q).map (mergeEvaluation n).toRingHom) p := by + let Q':Pairing (n+2) → Polynomial (SpectralField (n+1)):=fun p =>(Q p).map (mergeEvaluation n).toRingHom + let M:Matrix (Pairing (n+3)) (Pairing (n+2)) (SpectralField (n+1)):=mergeMap 0 (by omega) + have hQd:LastDegree (n+1) Q':=mappedNodal_degree Q hQ _ + have hM:LastMatrix M:=mergeMap_last 0 (show 2≤n+2 by omega) + have hMd:LastDegree (n+1) (matrixPolynomial M Q'):=hM.degree Q' hQd + have hright:LastDegree (n+2) (fun p =>mergePairPolynomial n*matrixPolynomial M Q' p):= + LastDegree.mul_poly _ hMd _ (mergePairPolynomial_degree n) + apply lastPolynomial_unique _ _ (mappedNodal_degree P hP _) hright _ (pairBeta_injective n 2 (Or.inl rfl)) + · intro p + rw [pairMapped_merge_leading P hP p] + rw [LastDegree.mul_poly_top _ hMd _ (mergePairPolynomial_degree n) p,mergePairPolynomial_top] + rw [hM.leading (mergeMap 0 (show 2≤n+2 by omega)) (fun p q =>mergeMap_padTop 0 (by omega) p q)] + have he:(fun q:Pairing (n+1) =>(Q' q.padTop).coeff (n+1))= + scalarValue (algebraMap ℂ (SpectralField (n+1))) (Fin.cons (fcos 0 (-1)) (fun i:Fin n =>fcos i.succ (-3))) • + normalizedVacuum (mergeNewWeights n) := funext (mergeMapped_leading Q hQ) + rw [he,Matrix.mulVec_smul] + simp only [Pi.smul_apply,smul_eq_mul] + ring + · intro p i + by_cases hi:i=1 + · subst i + rw [show pairBeta n 2 1=pairEvaluation n 2 (betaL 1) from (pairEvaluation_betaL 2 1).symm, + rationalNodalPolynomial_pair_self W hW P hP 2 (Or.inl rfl)] + rw [pairEvaluation_betaL,Polynomial.eval_mul,mergePairPolynomial_eval] + change 0=mergePairScalar n*(fcos 0 7+fcos 0 (-1))*_ + have hf:=fcos_sub_eight (0:Fin (n+1)) 7 + norm_num only at hf + rw [hf] + ring + · have he: lastValue (RingHom.id (SpectralField (n+1))) (pairBeta n 2 i) (torusSin (deletionNode (pairIndex n i))) + (fun p =>(P p).map (pairEvaluation n 2).toRingHom)= + lastValue (RingHom.id (SpectralField (n+1))) (pairBeta n 2 i) (torusSin (deletionNode (pairIndex n i))) + (fun p =>mergePairPolynomial n*matrixPolynomial M Q' p) := by + rw [mappedNodal_pair_node (by omega) P hP i hi,lastValue_mul_poly,hM.lastValue] + rw [pairBeta_of_ne i hi,mergeMapped_node Q hprev] + rw [Matrix.mulVec_smul,smul_smul] + rw [normalizedVacuum_pairNode_merge,mergePairPolynomial_eval] + have hs:=scalar_pair_merge_snoc (n:=n) i hi + rw [pairBeta_of_ne i hi] at hs + rw [hs] + have hp:=congrFun he p + by_cases ho:p.Occupied (Fin.last (n+2)) + · simp only [lastValue,Polynomial.eval₂_id,ho,ite_true] at hp + exact mul_left_cancel₀ (deletionNode_sine_ne_zero _) hp + · simpa only [lastValue,Polynomial.eval₂_id,ho,ite_false] using hp + + + + + + + +lemma torusEvaluation_fieldMap {n m k:ℕ} (f:SpectralField m →+* SpectralField k) + (hf:∀c,f (constF m c)=constF k c) + (z:Fin n → SpectralField m) (hz:∀i,z i≠0) (P:Laurent n) : + f (torusEvaluation z hz P)=torusEvaluation (fun i =>f (z i)) (fun i =>(map_ne_zero f).mpr (hz i)) P := by + have he:f.comp (torusEvaluation z hz).toRingHom= + (torusEvaluation (fun i =>f (z i)) (fun i =>(map_ne_zero f).mpr (hz i))).toRingHom := by + apply AddMonoidAlgebra.ringHom_ext <;> intro e + all_goals change f (torusEvaluation z hz (monomialL _ _))=torusEvaluation _ _ (monomialL _ _) + all_goals simp only [torusEvaluation_monomial,map_mul,map_prod,map_zpow₀,hf] + exact DFunLike.congr_fun he P + +def freePoint {n m:ℕ} (z:Fin n → SpectralField m) : Fin (n+1) → SpectralField (m+1) := + Fin.snoc (fun i =>liftSpectral m (z i)) (variableF (Fin.last m)) + +lemma freePoint_ne_zero {n m:ℕ} (z:Fin n → SpectralField m) (hz:∀i,z i≠0) + (i:Fin (n+1)) : freePoint z i≠0 := by + induction i using Fin.lastCases with + | last => simpa only [freePoint,Fin.snoc_last] using variableF_ne_zero (Fin.last m) + | cast i => simpa only [freePoint,Fin.snoc_castSucc] using (map_ne_zero (liftSpectral m)).mpr (hz i) + +lemma freePoint_variable (m:ℕ) : freePoint (@variableF m)=variableF := by + funext i; induction i using Fin.lastCases <;> simp [freePoint] + +lemma freePoint_cons {n m:ℕ} (a:SpectralField m) (z:Fin n → SpectralField m) : + freePoint (Fin.cons a z)=Fin.cons (liftSpectral m a) (freePoint z) := by + unfold freePoint + have he:(fun i =>liftSpectral m ((Fin.cons a z : Fin (n+1) → SpectralField m) i))= + Fin.cons (liftSpectral m a) (fun i =>liftSpectral m (z i)) := by + funext i; induction i using Fin.cases <;> simp + rw [he,←Fin.cons_snoc_eq_snoc_cons] + +lemma torusEvaluation_free_lastLaurent {n m:ℕ} (z:Fin n → SpectralField m) (hz:∀i,z i≠0) + (p:Pairing (n+1)) (P:Polynomial (Laurent n)) : + torusEvaluation (freePoint z) (freePoint_ne_zero z hz) (lastLaurent p P)= + (if p.Occupied (Fin.last n) then torusSin (variableF (Fin.last m)) else 1)* + (P.map (torusEvaluation z hz).toRingHom).eval₂ (liftSpectral m) (spectralA (Fin.last m)) := by + dsimp only [freePoint] + rw [torusEvaluation_lastLaurent _ (fun i =>(map_ne_zero (liftSpectral m)).mpr (hz i)) _ (variableF_ne_zero _)] + have he:(torusEvaluation (fun i =>liftSpectral m (z i)) (fun i =>(map_ne_zero (liftSpectral m)).mpr (hz i))).toRingHom= + (liftSpectral m).comp (torusEvaluation z hz).toRingHom := by + apply RingHom.ext + intro Q + exact (torusEvaluation_fieldMap (liftSpectral m) (liftSpectral_const m) z hz Q).symm + rw [he,Polynomial.eval_map,←Polynomial.eval₂_map] + rfl + +lemma freePoint_firstFlat (n:ℕ) : freePoint (firstFlatPoint n)=firstFlatPoint (n+1) := by + rw [firstFlatPoint,freePoint_cons,map_one,freePoint_variable] + rfl +lemma freePoint_firstThree (n:ℕ) : freePoint (firstThreePoint n)=firstThreePoint (n+1) := by + rw [firstThreePoint,freePoint_cons,map_pow,liftSpectral_const,freePoint_variable] + rfl +lemma freePoint_pair (n s:ℕ) : freePoint (pairPoint n s)=pairPoint (n+1) s := by + unfold pairPoint + rw [freePoint_cons,freePoint_cons] + simp only [map_mul,map_pow,liftSpectral_const,liftSpectral_variable,Fin.castSucc_zero] + congr 2 + funext i + induction i using Fin.lastCases with + | last => simp only [freePoint,Fin.snoc_last]; rfl + | cast i => simp only [freePoint,Fin.snoc_castSucc,liftSpectral_variable]; rfl + +lemma firstFlatEvaluation_lastLaurent {n:ℕ} (p:Pairing (n+2)) (P:Polynomial (Laurent (n+1))) : + firstFlatEvaluation (n+1) (lastLaurent p P)= + lastValue (liftSpectral n) (spectralA (Fin.last n)) (torusSin (variableF (Fin.last n))) + (fun _ : Pairing (n+2) =>P.map (firstFlatEvaluation n).toRingHom) p := by + have h:=torusEvaluation_free_lastLaurent (firstFlatPoint n) (firstFlatPoint_ne_zero n) p P + simpa only [freePoint_firstFlat,firstFlatEvaluation,lastValue,ite_mul,one_mul] using h + +lemma firstThreeEvaluation_lastLaurent {n:ℕ} (p:Pairing (n+2)) (P:Polynomial (Laurent (n+1))) : + firstThreeEvaluation (n+1) (lastLaurent p P)= + lastValue (liftSpectral n) (spectralA (Fin.last n)) (torusSin (variableF (Fin.last n))) + (fun _ : Pairing (n+2) =>P.map (firstThreeEvaluation n).toRingHom) p := by + have h:=torusEvaluation_free_lastLaurent (firstThreePoint n) (firstThreePoint_ne_zero n) p P + simpa only [freePoint_firstThree,firstThreeEvaluation,lastValue,ite_mul,one_mul] using h + + + + + + + +lemma lastValue_spectral (n:ℕ) : + lastValue (liftSpectral n) (spectralA (Fin.last n)) (torusSin (variableF (Fin.last n))) + (rationalNodalPolynomial n)=rationalInterpolant n := by + funext p; simp only [lastValue,rationalInterpolant,ite_mul,one_mul] + +lemma lastValue_C_mul {K L:Type*} [CommRing K] [CommRing L] {n:ℕ} + (f:K →+* L) (a:K) (b s:L) (P:Pairing (n+1) → Polynomial K) : + lastValue f b s (fun p =>Polynomial.C a*P p)=f a • lastValue f b s P := by + funext p + simp only [lastValue,Polynomial.eval₂_mul,Polynomial.eval₂_C,Pi.smul_apply,smul_eq_mul] + split_ifs <;> ring + +lemma lastValue_firstZero_spectral (n:ℕ) : + lastValue (liftSpectral n) (spectralA (Fin.last n)) (torusSin (variableF (Fin.last n))) + (firstZeroPolynomial (fun i =>(spectralWeights n i).tile) (constF n d) (constF n c) + (constF n C) (rationalNodalPolynomial n))= + (spectralA (Fin.last n)+constF (n+1) C) • + firstZeroRaw (fun i =>(spectralWeights (n+1) i).tile) (rationalInterpolant n) := by + let z:SpectralField (n+1):=variableF (Fin.last n) + have hL:torusL (constF (n+1) phase^3/z)≠0 := by + rw [←rowDenominator_map]; exact rowDenominator_map_ne_zero _ + have ht:=torus_last_cleared z (variableF_ne_zero _) hL + have h:=firstZeroPolynomial_evaluation (liftSpectral n) (fun i =>(spectralWeights n i).tile) + (constF n d) (constF n c) (constF n C) + (spectralA (Fin.last n)) (torusSin z) (torusSin (constF (n+1) phase^3/z)) + (fun t =>(spectralA (Fin.last n)+constF (n+1) C)*(spectralWeights (n+1) (Fin.last n)).tile t) + (rationalNodalPolynomial n) + (by simpa only [liftSpectral_const,z,spectralA,spectralWeights] using ht.1) + (by simpa only [liftSpectral_const,z,spectralA,spectralWeights] using ht.2.1) + (by simpa only [liftSpectral_const,z,spectralA,spectralWeights] using ht.2.2.1) + (by simpa only [liftSpectral_const,z,spectralA,spectralWeights] using ht.2.2.2) + (by simpa only [liftSpectral_const,z,spectralA,spectralWeights] using torus_sine_pair z (variableF_ne_zero _)) + rw [lastValue_spectral] at h + have he:Fin.snoc (fun i t =>liftSpectral n ((spectralWeights n i).tile t)) + (fun t =>(spectralA (Fin.last n)+constF (n+1) C)*(spectralWeights (n+1) (Fin.last n)).tile t)= + fun i t =>(Fin.snoc (fun _ =>1) (spectralA (Fin.last n)+constF (n+1) C):Fin (n+1) → SpectralField (n+1)) i * + (spectralWeights (n+1) i).tile t := by + funext i t + induction i using Fin.lastCases <;> simp only [Fin.snoc_last,Fin.snoc_castSucc, + liftSpectral_weights_tile,one_mul] + rw [he,firstZeroRaw_rowScale] at h + simpa only [Fin.prod_univ_castSucc,Fin.snoc_last,Fin.snoc_castSucc,Finset.prod_const_one,one_mul] using h.symm + +lemma firstFlatCandidate_value {n:ℕ} + (hprev:∀p,rationalInterpolant n p=rationalVacuum (n+1) p) + (P:Pairing (n+2) → Polynomial (Laurent (n+1))) + (hP:∀p,(P p).map (algebraMap (SpectralRing (n+1)) (SpectralField (n+1)))=rationalNodalPolynomial (n+1) p) + (p:Pairing (n+2)) : + firstFlatEvaluation (n+1) (lastLaurent p (P p))= + (∏j:Fin (n+1),(spectralA j+constF (n+1) C))* + firstZeroRaw (fun j =>(spectralWeights (n+1) j).tile) (rationalVacuum (n+1)) p := by + rw [firstFlatEvaluation_lastLaurent] + have he:=rationalNodalPolynomial_firstFlat hprev P hP + have hv: lastValue (liftSpectral n) (spectralA (Fin.last n)) (torusSin (variableF (Fin.last n))) + (fun p =>(P p).map (firstFlatEvaluation n).toRingHom) p = _ := + congrFun (congrArg (lastValue (liftSpectral n) (spectralA (Fin.last n)) (torusSin (variableF (Fin.last n)))) he) p + change lastValue (liftSpectral n) (spectralA (Fin.last n)) (torusSin (variableF (Fin.last n))) + (fun p =>(P p).map (firstFlatEvaluation n).toRingHom) p=_ + rw [hv,lastValue_C_mul,lastValue_firstZero_spectral,show rationalInterpolant n=rationalVacuum (n+1) from funext hprev] + simp only [Pi.smul_apply,smul_eq_mul,map_prod,map_add,liftSpectral_spectralA,liftSpectral_const, + Fin.prod_univ_castSucc] + ring + +lemma rationalVacuum_raw_stationary (n:ℕ) : + ((rawColumn (@rowNumerator n)).map (algebraMap (SpectralRing n) (SpectralField n))).mulVec (rationalVacuum n)= + (∏i:Fin n,evalLaurent (rowDenominator i)) • rationalVacuum n := by + rw [rawColumn_map] + simp_rw [rowNumerator_map] + rw [rawColumn_scale,Matrix.smul_mulVec] + exact congrArg (fun v =>(∏i:Fin n,evalLaurent (rowDenominator i)) • v) (rationalVacuum_stationary n) + +lemma residual_specialization_zero {n m:ℕ} (φ:Laurent n →ₐ[ℂ] SpectralField m) + (W:Pairing n → Laurent n) + (hV:∀p,RationalAt φ.toRingHom (rationalVacuum n p) (φ (W p))) (p:Pairing n) : + φ (laurentResidual W p)=0 := by + have hm:=RationalAt.mulVec (φ:=φ.toRingHom) + ((rawColumn (@rowNumerator n)).map (algebraMap (SpectralRing n) (SpectralField n))) + ((rawColumn (@rowNumerator n)).map φ.toRingHom) (rationalVacuum n) (fun q =>φ (W q)) + (fun q r =>RationalAt.algebraMap _) hV p + rw [rationalVacuum_raw_stationary] at hm + have hr: RationalAt φ.toRingHom ((∏i:Fin n,evalLaurent (rowDenominator i))*rationalVacuum n p) + ((∏i:Fin n,φ (rowDenominator i))*φ (W p)) := + (RationalAt.prod _ _ _ (fun i _ =>RationalAt.algebraMap _)).mul (hV p) + have he:=hm.unique hr + simp only [Matrix.map_apply,Matrix.mulVec,dotProduct] at he + simp only [laurentResidual,map_sub,map_mul,map_prod,Matrix.mulVec,dotProduct,map_sum] + exact sub_eq_zero.mpr he + + +theorem residual_firstFlat {n:ℕ} + (hprev:∀p,rationalInterpolant n p=rationalVacuum (n+1) p) + (P:Pairing (n+2) → Polynomial (Laurent (n+1))) + (hP:∀p,(P p).map (algebraMap (SpectralRing (n+1)) (SpectralField (n+1)))=rationalNodalPolynomial (n+1) p) + (p:Pairing (n+2)) : + firstFlatEvaluation (n+1) (laurentResidual (fun q =>lastLaurent q (P q)) p)=0 := by + apply residual_specialization_zero + intro q + rw [firstFlatCandidate_value hprev P hP] + exact rationalAt_firstFlat_vacuum q + + + + + + + +lemma lastValue_mul_poly_map {K L:Type*} [CommRing K] [CommRing L] {n:ℕ} + (f:K →+* L) (Q:Polynomial K) (b s:L) (P:Pairing (n+1) → Polynomial K) : + lastValue f b s (fun p =>Q*P p)=Q.eval₂ f b • lastValue f b s P := by + funext p + simp only [lastValue,Polynomial.eval₂_mul,Pi.smul_apply,smul_eq_mul] + split_ifs <;> ring + +lemma firstThreeCandidate_value {n:ℕ} + (W:Pairing n → Laurent n) (hW:∀q,evalLaurent (W q)=rationalVacuum n q) + (hprev:∀p,rationalInterpolant n p=rationalVacuum (n+1) p) + (P:Pairing (n+2) → Polynomial (Laurent (n+1))) + (hP:∀p,(P p).map (algebraMap (SpectralRing (n+1)) (SpectralField (n+1)))=rationalNodalPolynomial (n+1) p) + (p:Pairing (n+2)) : + firstThreeEvaluation (n+1) (lastLaurent p (P p))= + (∏j:Fin (n+1),(spectralA j+constF (n+1) C))* + vacantBottomExtension (rationalVacuum (n+1)) p := by + rw [firstThreeEvaluation_lastLaurent] + change lastValue (liftSpectral n) (spectralA (Fin.last n)) (torusSin (variableF (Fin.last n))) + (fun p =>(P p).map (firstThreeEvaluation n).toRingHom) p=_ + rw [rationalNodalPolynomial_firstThree W hW P hP,lastValue_C_mul] + change _ * lastValue (liftSpectral n) (spectralA (Fin.last n)) (torusSin (variableF (Fin.last n))) (fun p =>(Polynomial.X+Polynomial.C (constF n C))* + vacantBottomExtension (rationalNodalPolynomial n) p) p=_ + rw [lastValue_mul_poly_map,lastValue_vacantBottomExtension,lastValue_spectral, + show rationalInterpolant n = rationalVacuum (n+1) from funext hprev] + simp only [Pi.smul_apply,smul_eq_mul,map_prod,map_add,liftSpectral_spectralA,liftSpectral_const, + Fin.prod_univ_castSucc,Polynomial.eval₂_add,Polynomial.eval₂_X,Polynomial.eval₂_C] + ring + + +theorem residual_firstThree {n:ℕ} + (W:Pairing n → Laurent n) (hW:∀q,evalLaurent (W q)=rationalVacuum n q) + (hprev:∀p,rationalInterpolant n p=rationalVacuum (n+1) p) + (P:Pairing (n+2) → Polynomial (Laurent (n+1))) + (hP:∀p,(P p).map (algebraMap (SpectralRing (n+1)) (SpectralField (n+1)))=rationalNodalPolynomial (n+1) p) + (p:Pairing (n+2)) : + firstThreeEvaluation (n+1) (laurentResidual (fun q =>lastLaurent q (P q)) p)=0 := by + apply residual_specialization_zero + intro q + rw [firstThreeCandidate_value W hW hprev P hP] + exact rationalAt_firstThree_vacuum q + +end + + + + + +noncomputable section +open scoped Classical LaurentPolynomial + +lemma torusEvaluation_unit_zpow {n m:ℕ} (z:Fin n → SpectralField m) (hz:∀i,z i≠0) + (u:(Laurent n)ˣ) (k:ℤ) : + torusEvaluation z hz ((u^k:(Laurent n)ˣ):Laurent n)=(torusEvaluation z hz (u:Laurent n))^k := + ((torusEvaluation z hz).toMonoidHom.comp (Units.coeHom _)).map_zpow u k + +lemma substitution_torusEvaluation_general {n m:ℕ} (i:Fin (n+1)) (u:(Laurent n)ˣ) + (v:Fin (n+1) → SpectralField m) (hv:∀j,v j≠0) + (z:Fin n → SpectralField m) (hz:∀j,z j≠0) + (hi:v i=torusEvaluation z hz (u:Laurent n)) (hj:∀j,v (i.succAbove j)=z j) + (f:Laurent (n+1)) : + torusEvaluation v hv f=torusEvaluation z hz (substituteLaurent i u f) := by + have h:(torusEvaluation v hv).toRingHom= + (torusEvaluation z hz).toRingHom.comp (substituteLaurent i u) := by + apply AddMonoidAlgebra.ringHom_ext <;> intro e + all_goals change torusEvaluation v hv (monomialL _ _)=torusEvaluation z hz (substituteLaurent i u (monomialL _ _)) + all_goals rw [torusEvaluation_monomial,substituteLaurent_monomial,map_mul, + torusEvaluation_monomial,torusEvaluation_unit_zpow,Fin.prod_univ_succAbove _ i] + all_goals simp only [hi,hj,Fin.removeNth] + all_goals ring + exact DFunLike.congr_fun h f + +lemma generic_substitution_zero {n m:ℕ} (i:Fin (n+1)) (u:(Laurent n)ˣ) + (v:Fin (n+1) → SpectralField n) (hv:∀j,v j≠0) + (hi:v i=evalLaurent (u:Laurent n)) (hj:∀j,v (i.succAbove j)=variableF j) + (f:Laurent (n+1)) (h:torusEvaluation v hv f=0) + (z:Fin (n+1) → SpectralField m) (hz:∀j,z j≠0) + (hzI:z i=torusEvaluation (z ∘ i.succAbove) (fun _ =>hz _) (u:Laurent n)) : + torusEvaluation z hz f=0 := by + rw [substitution_torusEvaluation i u v hv hi hj] at h + have hf:substituteLaurent i u f=0 := + IsFractionRing.injective (SpectralRing n) (SpectralField n) (by simpa only [evalLaurent,map_zero] using h) + rw [substitution_torusEvaluation_general i u z hz (z ∘ i.succAbove) (fun j =>hz _) hzI (fun j =>rfl),hf,map_zero] + +lemma firstFlatEvaluation_zero_universal {n m:ℕ} (f:Laurent (n+1)) + (h:firstFlatEvaluation n f=0) (z:Fin (n+1) → SpectralField m) (hz:∀j,z j≠0) (h0:z 0=1) : + torusEvaluation z hz f=0 := by + apply generic_substitution_zero 0 (monomialUnit 0 1 one_ne_zero) + (firstFlatPoint n) (firstFlatPoint_ne_zero n) _ _ f h z hz + · simpa [monomialUnit,torusEvaluation_monomial,constF] using h0 + · simp [firstFlatPoint,monomialUnit,evalLaurent] + · intro j; simp [firstFlatPoint] + +lemma firstThreeEvaluation_zero_universal {n m:ℕ} (f:Laurent (n+1)) + (h:firstThreeEvaluation n f=0) (z:Fin (n+1) → SpectralField m) (hz:∀j,z j≠0) + (h0:z 0=constF m phase^3) : torusEvaluation z hz f=0 := by + apply generic_substitution_zero 0 (monomialUnit 0 (phase^3) (pow_ne_zero _ phase_ne_zero)) + (firstThreePoint n) (firstThreePoint_ne_zero n) _ _ f h z hz + · simpa [monomialUnit,torusEvaluation_monomial,constF] using h0 + · simp [firstThreePoint,monomialUnit,evalLaurent_monomial_product,constF] + · intro j; simp [firstThreePoint] + +lemma pairEvaluation_zero_universal {n m:ℕ} (s:ℕ) (f:Laurent (n+2)) + (h:pairEvaluation n s f=0) (z:Fin (n+2) → SpectralField m) (hz:∀j,z j≠0) + (h01:z 1=constF m phase^s*z 0) : torusEvaluation z hz f=0 := by + apply generic_substitution_zero 1 (monomialUnit (variableExponent 0) (phase^s) (pow_ne_zero _ phase_ne_zero)) + (pairPoint n s) (pairPoint_ne_zero n s) _ _ f h z hz + · simpa [monomialUnit,torusEvaluation_monomial,variableExponent,Pi.single_apply,constF] using h01 + · simp only [pairPoint,monomialUnit,evalLaurent_monomial_product] + simp [variableExponent,Pi.single_apply,constF] + · intro j + induction j using Fin.cases with + | zero => simp [pairPoint] + | succ j => simp [pairPoint] + +end + + + + + +noncomputable section +open scoped Classical + + + +theorem residual_flat_transport {n m:ℕ} + (P:Pairing (n+2) → Polynomial (Laurent (n+1))) + (hP:∀p,(P p).map (algebraMap (SpectralRing (n+1)) (SpectralField (n+1)))=rationalNodalPolynomial (n+1) p) + (c:SpectralField m) + (hbase:∀(z:Fin (n+2) → SpectralField m) (hz:∀k,z k≠0),z 0=c → ∀p, + torusEvaluation z hz (laurentResidual (fun q =>lastLaurent q (P q)) p)=0) + (i:Fin (n+1)) (z:Fin (n+2) → SpectralField m) (hz:∀k,z k≠0) + (hi:z i.castSucc=c) + (hL:∀j:Fin (n+1),j < i → torusL (z i.castSucc/z j.castSucc)≠0) (p:Pairing (n+2)) : + torusEvaluation z hz (laurentResidual (fun q =>lastLaurent q (P q)) p)=0 := by + induction i using Fin.induction generalizing z p with + | zero => exact hbase z hz hi p + | @succ i ih => + let σ:=Equiv.swap i.castSucc i.succ + let z':=z ∘ topPerm σ + have hz':∀k,z' k≠0 := fun k =>hz _ + have he (k:Fin (n+1)): z' k.castSucc=z (σ k).castSucc := by simp only [z',Function.comp_apply,topPerm_cast] + have hs:σ i.castSucc=i.succ := Equiv.swap_apply_left _ _ + have hr:i.val+2≤n+1 := by omega + have hzero:∀q,torusEvaluation z' hz' (laurentResidual (fun q =>lastLaurent q (P q)) q)=0 := by + intro q + apply ih z' hz' + · rw [he,hs]; exact hi + · intro j hj + rw [he,hs,he] + have hja:j≠i.castSucc := Fin.ne_of_lt hj + have hjb:j≠i.succ := by apply Fin.ne_of_lt; exact hj.trans (Fin.castSucc_lt_succ) + rw [show σ j=j from Equiv.swap_apply_of_ne_of_ne hja hjb] + exact hL j (hj.trans (Fin.castSucc_lt_succ)) + exact residual_zero_transport P hP i.val hr z hz + (hL i.castSucc (Fin.castSucc_lt_succ)) hzero p + + + + + + + +def PairExchangeRegular {n m:ℕ} (z:Fin (n+1) → SpectralField m) (i j:Fin n) : Prop := + ∀a b:Fin n,a≠b → ¬(a=i ∧ b=j ∨ a=j ∧ b=i) → + torusL (z b.castSucc/z a.castSucc)≠0 + +lemma PairExchangeRegular.perm {n m:ℕ} {z:Fin (n+1) → SpectralField m} {i j:Fin n} + (h:PairExchangeRegular z i j) (σ:Equiv.Perm (Fin n)) : + PairExchangeRegular (z ∘ topPerm σ) (σ.symm i) (σ.symm j) := by + intro a b hab hij + simp only [Function.comp_apply,topPerm_cast] + apply h (σ a) (σ b) (fun e =>hab (σ.injective e)) + simpa only [←Equiv.eq_symm_apply] using hij + + + +theorem residual_pair_transport {n m:ℕ} + (P:Pairing (n+1) → Polynomial (Laurent n)) + (hP:∀p,(P p).map (algebraMap (SpectralRing n) (SpectralField n))=rationalNodalPolynomial n p) + (c:SpectralField m) (h2:2≤n) + (hbase:∀(z:Fin (n+1) → SpectralField m) (hz:∀k,z k≠0), + z (⟨1,by omega⟩:Fin n).castSucc=c*z (⟨0,by omega⟩:Fin n).castSucc → ∀p, + torusEvaluation z hz (laurentResidual (fun q =>lastLaurent q (P q)) p)=0) + (i j:Fin n) (hij:ilastLaurent q (P q)) p)=0 := by + generalize hsum:i.val+j.val=t + induction t using Nat.strong_induction_on generalizing i j z p with + | h t ih => + by_cases hi:i.val=0 + · by_cases hj:j.val=1 + · apply hbase z hz + have hi0:i=(⟨0,by omega⟩:Fin n) := Fin.ext hi + have hj1:j=(⟨1,by omega⟩:Fin n) := Fin.ext hj + simpa only [hi0,hj1] using he + · let r:=j.val-1 + have hr:r+2≤n := by dsimp [r]; omega + let a:Fin n:=⟨r,by omega⟩ + let b:Fin n:=⟨r+1,by omega⟩ + let σ:=Equiv.swap a b + have hb:b=j := by apply Fin.ext; dsimp [b,r]; omega + have hia:i≠a := by intro h; have:=congrArg Fin.val h; dsimp [a,r] at this; omega + have hib:i≠b := by rw [hb]; exact Fin.ne_of_lt hij + have hsi:σ i=i := Equiv.swap_apply_of_ne_of_ne hia hib + have hsj:σ a=j := by rw [←hb]; exact Equiv.swap_apply_left _ _ + have horder:ihz _) _ _ q rfl + · simpa only [Function.comp_apply,topPerm_cast,hsi,hsj] using he + · have hh:=hL.perm σ + have hsym:σ.symm=σ := Equiv.symm_swap _ _ + rw [hsym,hsi,show σ j=a by rw [←hb]; exact Equiv.swap_apply_right _ _] at hh + exact hh + · let r:=i.val-1 + have hr:r+2≤n := by dsimp [r]; omega + let a:Fin n:=⟨r,by omega⟩ + let b:Fin n:=⟨r+1,by omega⟩ + let σ:=Equiv.swap a b + have hb:b=i := by apply Fin.ext; dsimp [b,r]; omega + have hja:j≠a := by intro h; have:=congrArg Fin.val h; dsimp [a,r] at this; have:=hij; change i.valhz _) _ _ q rfl + · simpa only [Function.comp_apply,topPerm_cast,hsi,hsj] using he + · have hh:=hL.perm σ + have hsym:σ.symm=σ := Equiv.symm_swap _ _ + rw [hsym,hsj,show σ i=a by rw [←hb]; exact Equiv.swap_apply_right _ _] at hh + exact hh + +end + + + + + +noncomputable section +open scoped Classical LaurentPolynomial + + + +def fullPeel {n:ℕ} (i:Fin (n+1)) : Laurent (n+1) →+* LaurentPolynomial (SpectralField (n+1)) := + (AddMonoidAlgebra.mapRingHom ℤ (insertSpectral i)).comp (peelLaurent i) + +lemma fullPeel_injective {n:ℕ} (i:Fin (n+1)) : Function.Injective (fullPeel i) := + (AddMonoidAlgebra.map_injective _ (insertSpectral i).injective).comp (peelLaurent_injective i) + +lemma fullPeel_coeff {n:ℕ} (i:Fin (n+1)) (f:Laurent (n+1)) (k:ℤ) : + (fullPeel i f).coeff k=insertSpectral i ((peelLaurent i f).coeff k) := + AddMonoidAlgebra.coeff_mapRingHom _ _ _ + +lemma LaurentBox.fullPeel {n:ℕ} {f:Laurent (n+1)} {b:Fin (n+1) → ℕ} + (hb:LaurentBox f b) (i:Fin (n+1)) : LaurentInterval (fullPeel i f) (-(b i:ℤ)) (b i) := by + intro k hk + apply hb.peel i k + intro hz + rw [fullPeel_coeff,hz,map_zero] at hk + exact hk rfl + +lemma fullPeel_monomial {n:ℕ} (i:Fin (n+1)) (e:Fin (n+1) → ℤ) (c:ℂ) : + fullPeel i (monomialL e c)=AddMonoidAlgebra.single (e i) + (evalLaurent (monomialL (Function.update e i 0) c)) := by + change AddMonoidAlgebra.mapRingHom ℤ (insertSpectral i) (peelLaurent i (monomialL e c))=_ + rw [peelLaurent_monomial,AddMonoidAlgebra.mapRingHom_single,insertSpectral_evalLaurent,insertLaurent_monomial] + congr 3 + simp [Fin.insertNth_removeNth] + +lemma evalLaurent_monomial_full {n:ℕ} (e:Fin n → ℤ) (c:ℂ) : + evalLaurent (monomialL e c)=constF n c*∏j:Fin n,variableF j^(e j) := by + exact (evalLaurent_monomial_product e c) + +lemma fullPeel_eval {n:ℕ} (i:Fin (n+1)) (z:SpectralField (n+1)) (hz:z≠0) (f:Laurent (n+1)) : + LaurentPolynomial.eval₂ (RingHom.id _) (Units.mk0 z hz) (fullPeel i f)= + torusEvaluation (Function.update variableF i z) + (fun j =>by by_cases h:j=i <;> simp [h,hz,variableF_ne_zero]) f := by + let ψ:=torusEvaluation (Function.update variableF i z) + (fun j =>by by_cases h:j=i <;> simp [h,hz,variableF_ne_zero]) + have he:(LaurentPolynomial.eval₂ (RingHom.id _) (Units.mk0 z hz)).comp (fullPeel i)=ψ.toRingHom := by + apply AddMonoidAlgebra.ringHom_ext <;> intro e + all_goals change LaurentPolynomial.eval₂ _ _ (fullPeel i (monomialL _ _))=ψ (monomialL _ _) + all_goals rw [fullPeel_monomial, LaurentPolynomial.single_eq_C_mul_T, LaurentPolynomial.eval₂_C_mul_T] + all_goals simp only [RingHom.id_apply,Units.val_zpow_eq_zpow_val,Units.val_mk0] + all_goals rw [evalLaurent_monomial_full,torusEvaluation_monomial] + all_goals rw [Fin.prod_univ_succAbove _ i,Fin.prod_univ_succAbove _ i] + all_goals simp only [Function.update_self,Function.update_of_ne (Fin.succAbove_ne _ _),zpow_zero,one_mul] + all_goals ring + exact DFunLike.congr_fun he f + +end +end CriticalStrip.Diagram + +end OAI diff --git a/lean/OAI/Combinatorics/StripMass/MirrorExterior.lean b/lean/OAI/Combinatorics/StripMass/MirrorExterior.lean new file mode 100644 index 0000000000000000000000000000000000000000..803fc11474b6f2fe206df8bb92b5465c8f407f63 --- /dev/null +++ b/lean/OAI/Combinatorics/StripMass/MirrorExterior.lean @@ -0,0 +1,589 @@ +import Mathlib +import OAI.Combinatorics.StripMass.PhaseAlgebra +import OAI.Combinatorics.StripMass.TriplePatch + +namespace OAI + +/-! Critical honeycomb strip paths, polynomial identities and crossing mass. -/ + + + +namespace CriticalStrip.Diagram +noncomputable section +open scoped Classical +namespace TriplePosition +variable {n : ℕ} (s : TriplePosition n) + +def mirrorInterface : Fin 6 → Fin n ⊕ Fin n := + ![.inl s.c,.inl s.b,.inl s.a,.inr s.c,.inr s.b,.inr s.a] + +def mirrorActive (p q : Pairing n) : Fin 6 → Prop := + ![p.Occupied s.c,p.Occupied s.b,p.Occupied s.a, + q.Occupied s.c,q.Occupied s.b,q.Occupied s.a] + +def mirrorExterior (p q : Pairing n) : (Fin n ⊕ Fin n) → (Fin n ⊕ Fin n) → Prop + | .inl i,.inl j => p.Adj i j + | .inl i,.inr j | .inr j,.inl i => i=j ∧ i≠s.c ∧ i≠s.b ∧ i≠s.a ∧ q.Occupied i + | .inr _,.inr _ => False + +def MirrorOutside (p q : Pairing n) : Prop := + ∀ i, i≠s.c → i≠s.b → i≠s.a → (p.Occupied i ↔ q.Occupied i) + +def mirrorAttached (p q : Pairing n) (t : ThreeBox.Config) := + Graph.Attached.wiring (s.mirrorWiring p t) s.mirrorBoundary q.Occupied + +def mirrorPatch (p q : Pairing n) (t : ThreeBox.Config) := + Patch.glued (ThreeBox.Adj t) (s.mirrorExterior p q) ThreeBox.boundary s.mirrorInterface (s.mirrorActive p q) + +def mirrorExteriorEquiv : ((Fin n ⊕ Fin 12) ⊕ Fin n) ≃ (Fin 12 ⊕ (Fin n ⊕ Fin n)) where + toFun + | .inl (.inl i) => .inr (.inl i) + | .inl (.inr v) => .inl v + | .inr i => .inr (.inr i) + invFun + | .inl v => .inl (.inr v) + | .inr (.inl i) => .inl (.inl i) + | .inr (.inr i) => .inr i + left_inv := by rintro ((i|v)|i) <;> rfl + right_inv := by rintro (v|(i|i)) <;> rfl + +lemma mirror_boundary_old (i j : Fin n) : + ((.inl i : Fin n ⊕ Fin 12)=s.mirrorBoundary j) ↔ + i=j ∧ i≠s.c ∧ i≠s.b ∧ i≠s.a := by + by_cases ha : j=s.c <;> by_cases hb : j=s.b <;> by_cases hc : j=s.a <;> + simp_all [mirrorBoundary] + +lemma mirror_boundary_new (v : Fin 12) (j : Fin n) : + ((.inr v : Fin n ⊕ Fin 12)=s.mirrorBoundary j) ↔ + (j=s.c ∧ v=6) ∨ (j=s.b ∧ v=10) ∨ (j=s.a ∧ v=11) := by + have hab:=s.ab; have hbc:=s.bc; have hac:=s.ac + by_cases ha : j=s.c <;> by_cases hb : j=s.b <;> by_cases hc : j=s.a <;> + simp_all [mirrorBoundary] + +lemma mirror_interface_old (p q : Pairing n) (v : Fin 12) (i : Fin n) : + (∃ k, s.mirrorActive p q k ∧ v=ThreeBox.boundary k ∧ (.inl i : Fin n ⊕ Fin n)=s.mirrorInterface k) ↔ + (i=s.c ∧ v=4 ∧ p.Occupied s.c) ∨ + (i=s.b ∧ v=0 ∧ p.Occupied s.b) ∨ (i=s.a ∧ v=1 ∧ p.Occupied s.a) := by + simp only [Fin.exists_fin_succ,mirrorInterface,mirrorActive,ThreeBox.boundary] + simp only [Matrix.cons_val_zero,Matrix.cons_val_succ,Matrix.cons_val_fin_one, + Sum.inl.injEq,Sum.inl_ne_inr,and_false,or_false,Fin.exists_fin_zero] + itauto + +lemma mirror_interface_new (p q : Pairing n) (v : Fin 12) (i : Fin n) : + (∃ k, s.mirrorActive p q k ∧ v=ThreeBox.boundary k ∧ (.inr i : Fin n ⊕ Fin n)=s.mirrorInterface k) ↔ + ((i=s.c ∧ v=6) ∨ (i=s.b ∧ v=10) ∨ (i=s.a ∧ v=11)) ∧ q.Occupied i := by + simp only [Fin.exists_fin_succ,mirrorInterface,mirrorActive,ThreeBox.boundary] + simp only [Matrix.cons_val_zero,Matrix.cons_val_succ,Matrix.cons_val_fin_one, + Sum.inr.injEq,Sum.inr_ne_inl,and_false,false_or,or_false,Fin.exists_fin_zero] + constructor + · rintro (⟨h,hv,hi⟩ | ⟨h,hv,hi⟩ | ⟨h,hv,hi⟩) <;> subst i + · exact ⟨Or.inl ⟨rfl,hv⟩,h⟩ + · exact ⟨Or.inr (Or.inl ⟨rfl,hv⟩),h⟩ + · exact ⟨Or.inr (Or.inr ⟨rfl,hv⟩),h⟩ + · rintro ⟨(⟨rfl,hv⟩|⟨rfl,hv⟩|⟨rfl,hv⟩),h⟩ + · exact Or.inl ⟨h,hv,rfl⟩ + · exact Or.inr (Or.inl ⟨h,hv,rfl⟩) + · exact Or.inr (Or.inr ⟨h,hv,rfl⟩) + +lemma mirror_exterior_edge (p q : Pairing n) (t : ThreeBox.Config) + (v w : (Fin n ⊕ Fin 12) ⊕ Fin n) : + s.mirrorAttached p q t v w ↔ s.mirrorPatch p q t (mirrorExteriorEquiv v) (mirrorExteriorEquiv w) := by + rcases v with (i|v)|i <;> rcases w with (j|w)|j + all_goals dsimp only [mirrorAttached,Graph.Attached.wiring,mirrorPatch,Patch.glued,mirrorExteriorEquiv,Equiv.coe_fn_mk] + · rfl + · simpa only [mirrorWiring,and_comm,and_left_comm,and_assoc] using (s.mirror_interface_old p q w i).symm + · rw [s.mirror_boundary_old] + change ((i=j ∧ i≠s.c ∧ i≠s.b ∧ i≠s.a) ∧ q.Occupied j) ↔ + i=j ∧ i≠s.c ∧ i≠s.b ∧ i≠s.a ∧ q.Occupied i + constructor + · rintro ⟨⟨rfl,ha,hb,hc⟩,hq⟩; exact ⟨rfl,ha,hb,hc,hq⟩ + · rintro ⟨rfl,ha,hb,hc,hq⟩; exact ⟨⟨rfl,ha,hb,hc⟩,hq⟩ + · exact (s.mirror_interface_old p q v j).symm + · rfl + · rw [s.mirror_boundary_new] + exact (s.mirror_interface_new p q v j).symm + · rw [s.mirror_boundary_old] + change ((j=i ∧ j≠s.c ∧ j≠s.b ∧ j≠s.a) ∧ q.Occupied i) ↔ + j=i ∧ j≠s.c ∧ j≠s.b ∧ j≠s.a ∧ q.Occupied j + constructor + · rintro ⟨⟨rfl,ha,hb,hc⟩,hq⟩; exact ⟨rfl,ha,hb,hc,hq⟩ + · rintro ⟨rfl,ha,hb,hc,hq⟩; exact ⟨⟨rfl,ha,hb,hc⟩,hq⟩ + · rw [s.mirror_boundary_new] + simpa only [and_comm,and_left_comm,and_assoc] using (s.mirror_interface_new p q w i).symm + · rfl + +end TriplePosition +end +end CriticalStrip.Diagram + + + + + +namespace CriticalStrip.Diagram.ThreeBox +noncomputable section + +lemma reverseSlots_involutive : Function.Involutive reverseSlots := by intro i; fin_cases i <;> rfl + +@[simp] lemma reverseSlots_twice (i : Fin 6) : reverseSlots (reverseSlots i)=i := reverseSlots_involutive i + +def reverseEquiv : Fin 6 ≃ Fin 6 := + ⟨reverseSlots,reverseSlots,reverseSlots_involutive,reverseSlots_involutive⟩ + +lemma support_mirror (k : Fin 51) (i : Fin 6) : + boundarySupport (diagram (mirrorIndex k)) i ↔ + boundarySupport (diagram k) (reverseSlots i) := by + unfold boundarySupport + simp only [diagram_mirror] + exact reverseEquiv.surjective.exists.symm + +lemma exterior_mirror {B : Type*} (s : B → B → Prop) (b : Fin 6 → B) + (active : Fin 6 → Prop) (k : Fin 51) : + diagramExterior (diagram k) s (b∘reverseSlots) (active∘reverseSlots) = + diagramExterior (diagram (mirrorIndex k)) s b active := by + funext x y + apply propext + unfold diagramExterior + refine or_congr Iff.rfl ?_ + constructor + · rintro ⟨i,j,hi,hj,h,he,hf⟩ + refine ⟨reverseSlots i,reverseSlots j,hi,hj,?_,he,hf⟩ + rcases h with rfl | h + · exact Or.inl rfl + · exact Or.inr ((diagram_mirror k _ _).mpr (by simpa only [reverseSlots_twice] using h)) + · rintro ⟨i,j,hi,hj,h,he,hf⟩ + refine ⟨reverseSlots i,reverseSlots j,?_,?_,?_,?_,?_⟩ + · simpa only [Function.comp_apply,reverseSlots_twice] using hi + · simpa only [Function.comp_apply,reverseSlots_twice] using hj + · exact h.elim (fun he => Or.inl (congrArg _ he)) (fun hh => Or.inr ((diagram_mirror k i j).mp hh)) + · simpa only [Function.comp_apply,reverseSlots_twice] using he + · simpa only [Function.comp_apply,reverseSlots_twice] using hf + +lemma exteriorTest_mirror {B : Type*} (s : B → B → Prop) (b : Fin 6 → B) + (active : Fin 6 → Prop) (out : B → Prop) (test : (B → B → Prop) → Prop) (k : Fin 51) : + exteriorTest s (b∘reverseSlots) (active∘reverseSlots) out test k ↔ + exteriorTest s b active out test (mirrorIndex k) := by + unfold exteriorTest + rw [exterior_mirror] + refine and_congr ?_ Iff.rfl + simp only [support_mirror,Function.comp_apply] + constructor + · intro h i + simpa only [reverseSlots_twice] using h (reverseSlots i) + · intro h i + simpa only [reverseSlots_twice] using h (reverseSlots i) + +end +end CriticalStrip.Diagram.ThreeBox + + + + + +namespace CriticalStrip.Diagram +noncomputable section +open scoped Classical +namespace TriplePosition +variable {n : ℕ} (s : TriplePosition n) + +def mirrorExteriorPredicate (p q : Pairing n) (k : Fin 51) : Prop := + s.MirrorOutside p q ∧ ThreeBox.exteriorTest (s.mirrorExterior p q) s.mirrorInterface (s.mirrorActive p q) + (output q) (reachTest q) k + +def mirrorPatchEquiv (p q : Pairing n) (t : ThreeBox.Config) : + Graph.BoundaryEquiv (s.mirrorAttached p q t) (s.mirrorPatch p q t) Sum.inr + (fun i => .inr (.inr i)) := + Graph.BoundaryEquiv.ofEquiv mirrorExteriorEquiv (s.mirror_exterior_edge p q t) (fun _ => rfl) + +lemma mirror_active_iff (p q : Pairing n) (t : ThreeBox.Config) : + (∀ i, s.mirrorActive p q i ↔ ThreeBox.boundaryOccupied t i) ↔ + (p.Occupied s.c ↔ t.2.1.Occupied 0) ∧ + (p.Occupied s.b ↔ t.1.Occupied 0) ∧ (p.Occupied s.a ↔ t.1.Occupied 1) ∧ + (q.Occupied s.c ↔ t.2.1.Occupied 2) ∧ + (q.Occupied s.b ↔ t.2.2.Occupied 2) ∧ (q.Occupied s.a ↔ t.2.2.Occupied 3) := by + simp [Fin.forall_fin_succ,mirrorActive,ThreeBox.boundaryOccupied,ThreeBox.boundary, + ThreeBox.atRow,ThreeBox.row,ThreeBox.port] + +lemma mirror_compatible_support_iff (p q : Pairing n) (t : ThreeBox.Config) : + Circuit.Compatible p (s.leftCircuit t) ∧ (∀ i, q.Occupied i ↔ s.mirrorSupport p t i) ↔ + s.MirrorOutside p q ∧ ThreeBox.Compatible t ∧ + (∀ i, s.mirrorActive p q i ↔ ThreeBox.boundaryOccupied t i) := by + rw [s.mirror_compatible_iff,s.mirror_active_iff] + have hab:=s.ab; have hbc:=s.bc; have hac:=s.ac + constructor + · rintro ⟨⟨hc,ha,hb,hc'⟩,hs⟩ + refine ⟨?_,hc,ha,hb,hc',?_,?_,?_⟩ + · intro i hia hib hic + simpa only [mirrorSupport,ite_eq_right hia,ite_eq_right hib,ite_eq_right hic] using (hs i).symm + · simpa [mirrorSupport] using hs s.c + · simpa [mirrorSupport,s.ab,s.bc,s.ac,s.ab.symm,s.bc.symm,s.ac.symm] using hs s.b + · simpa [mirrorSupport,s.ab,s.bc,s.ac,s.ab.symm,s.bc.symm,s.ac.symm] using hs s.a + · rintro ⟨ho,hc,ha,hb,hc',hqa,hqb,hqc⟩ + refine ⟨⟨hc,ha,hb,hc'⟩,?_⟩ + intro i + by_cases hia : i=s.c + · subst i; simpa [mirrorSupport] using hqa + · by_cases hib : i=s.b + · subst i; simpa [mirrorSupport,hia] using hqb + · by_cases hic : i=s.a + · subst i; simpa [mirrorSupport,hia,hib] using hqc + · simpa only [mirrorSupport,ite_eq_right hia,ite_eq_right hib,ite_eq_right hic] using (ho i hia hib hic).symm + +lemma mirror_patchTest_realizes (p q : Pairing n) (t : ThreeBox.Config) : + ThreeBox.patchTest (s.mirrorExterior p q) s.mirrorInterface (s.mirrorActive p q) (output q) (reachTest q) t ↔ + ThreeBox.Compatible t ∧ (∀ i, s.mirrorActive p q i ↔ ThreeBox.boundaryOccupied t i) ∧ + GraphRealizes (s.mirrorPatch p q t) (fun i => .inr (.inr i)) q := by + unfold ThreeBox.patchTest + refine and_congr_right (fun _ => and_congr_right (fun _ => ?_)) + constructor + · rintro ⟨hd,hr⟩ + refine ⟨?_,hr⟩ + intro v w he + obtain ⟨(x|(i|i)),hi,h⟩ := hd v w he + · exact hi.elim + · exact hi.elim + · exact ⟨i,hi,h⟩ + · intro h + refine ⟨?_,h.reach⟩ + intro v w he + obtain ⟨i,hi,hr⟩ := h.no_loop v w he + exact ⟨.inr (.inr i),hi,hr⟩ + +lemma mirror_eval_patch_iff (p q : Pairing n) (t : ThreeBox.Config) : + Circuit.eval p (s.leftCircuit t)=some q ↔ + s.MirrorOutside p q ∧ ThreeBox.patchTest (s.mirrorExterior p q) s.mirrorInterface (s.mirrorActive p q) + (output q) (reachTest q) t := by + rw [s.mirror_eval_iff,s.mirror_patchTest_realizes] + constructor + · rintro ⟨hc,hr⟩ + have hs : ∀ i, q.Occupied i ↔ s.mirrorSupport p t i := fun i => + (hr.boundary_used_iff s.mirror_boundary_injective i).symm.trans (s.mirror_boundary_used p t i) + obtain ⟨ho,hc',ha⟩ := (s.mirror_compatible_support_iff p q t).mp ⟨hc,hs⟩ + refine ⟨ho,hc',ha,?_⟩ + apply (s.mirrorPatchEquiv p q t).realizes_iff.mp + exact (Graph.Attached.contraction (s.mirrorWiring p t) s.mirrorBoundary q.Occupied + (fun i => (hs i).trans (s.mirror_boundary_used p t i).symm) s.mirror_boundary_injective).realizes_inv hr + · rintro ⟨ho,hc,ha,hr⟩ + obtain ⟨hc',hs⟩ := (s.mirror_compatible_support_iff p q t).mpr ⟨ho,hc,ha⟩ + refine ⟨hc',?_⟩ + apply (Graph.Attached.contraction (s.mirrorWiring p t) s.mirrorBoundary q.Occupied + (fun i => (hs i).trans (s.mirror_boundary_used p t i).symm) s.mirror_boundary_injective).realizes + exact (s.mirrorPatchEquiv p q t).realizes_iff.mpr hr + +lemma mirror_eval_profile_iff (p q : Pairing n) (t : ThreeBox.Config) : + Circuit.eval p (s.leftCircuit t)=some q ↔ + ∃ k, ThreeBox.profile t=some k ∧ s.mirrorExteriorPredicate p q k := by + rw [s.mirror_eval_patch_iff,ThreeBox.patchTest_iff] + unfold mirrorExteriorPredicate + constructor + · rintro ⟨ho,k,hk,hp⟩; exact ⟨k,hk,ho,hp⟩ + · rintro ⟨k,hk,ho,hp⟩; exact ⟨ho,k,hk,hp⟩ + +end TriplePosition +end + + + + + +noncomputable section +namespace TriplePosition +variable {n : ℕ} (s : TriplePosition n) + +lemma mirror_interface : s.mirrorInterface=s.interface ∘ ThreeBox.reverseSlots := by + funext i; fin_cases i <;> rfl + +lemma mirror_active (p q : Pairing n) : + s.mirrorActive p q=s.active p q ∘ ThreeBox.reverseSlots := by + funext i; fin_cases i <;> rfl + +lemma mirror_exterior (p q : Pairing n) : s.mirrorExterior p q=s.exterior p q := by + funext x y + rcases x with x|x <;> rcases y with y|y + all_goals simp only [mirrorExterior,exterior] + all_goals apply propext + all_goals itauto + +lemma mirror_outside (p q : Pairing n) : s.MirrorOutside p q ↔ s.Outside p q := by + unfold MirrorOutside Outside + constructor <;> intro h i ha hb hc + · exact h i hc hb ha + · exact h i hc hb ha + +lemma mirror_predicate (p q : Pairing n) (k : Fin 51) : + s.mirrorExteriorPredicate p q k ↔ s.exteriorPredicate p q (ThreeBox.mirrorIndex k) := by + unfold mirrorExteriorPredicate exteriorPredicate + rw [s.mirror_outside,s.mirror_interface,s.mirror_active,s.mirror_exterior] + exact and_congr_right fun _ => ThreeBox.exteriorTest_mirror _ _ _ _ _ k + +end TriplePosition + + + + + +open scoped Classical +open Finset + +variable {K : Type*} [CommRing K] {n : ℕ} + +def tripleCircuit (a b : Position n) (t : ThreeBox.Config) : Circuit n := + .snoc (.snoc (.snoc .nil (a.gate t.1)) (b.gate t.2.1)) (a.gate t.2.2) + +def tripleProgram (a b : Position n) (w₀ w₁ w₂ : Weights K) : Program n K := + .snoc (.snoc (.snoc .nil a w₀) b w₁) a w₂ + +lemma triple_expansion (a b : Position n) (w₀ w₁ w₂ : Weights K) (p q : Pairing n) : + (localR a w₂ * localR b w₁ * localR a w₀) q p = + ∑ t : ThreeBox.Config, if Circuit.eval p (tripleCircuit a b t)=some q + then w₀.tile t.1*w₁.tile t.2.1*w₂.tile t.2.2 else 0 := by + have h := (tripleProgram a b w₀ w₁ w₂).matrix_apply q p + simp only [tripleProgram,Program.matrix,mul_one] at h + rw [Matrix.mul_assoc] + rw [h] + change (∑ x : ((PUnit × Tile) × Tile) × Tile, _) = ∑ t : Tile × (Tile × Tile), _ + simp only [Fintype.sum_prod_type,Fintype.sum_unique,Program.weight,Program.circuit, + one_mul,tripleCircuit] + rfl + +namespace ThreeBox + +def mirrorConfig : Config ≃ Config := + Equiv.prodCongr Tile.mirrorEquiv (Equiv.prodCongr Tile.mirrorEquiv Tile.mirrorEquiv) + +lemma config_sum_mirror (f : Config → K) : ∑ t, f t = ∑ t, f (mirrorConfig t) := + (Equiv.sum_comp mirrorConfig f).symm + +end ThreeBox + +lemma triple_expansion_mirror (a b : Position n) (w₀ w₁ w₂ : Weights K) (p q : Pairing n) : + (localR a w₂ * localR b w₁ * localR a w₀) q p = + ∑ t : ThreeBox.Config, if Circuit.eval p (tripleCircuit a b (ThreeBox.mirrorConfig t))=some q + then w₀.tile t.1*w₁.tile t.2.1*w₂.tile t.2.2 else 0 := by + rw [triple_expansion,ThreeBox.config_sum_mirror] + apply sum_congr rfl + intro t _ + simp only [ThreeBox.mirrorConfig, Equiv.prodCongr, Tile.mirrorEquiv] + change (if Circuit.eval p (tripleCircuit a b (ThreeBox.mirrorConfig t))=some q then + w₀.tile t.1.mirror*w₁.tile t.2.1.mirror*w₂.tile t.2.2.mirror else 0) = _ + simp only [Tile.weight_mirror] + rfl + +end + + + + + +noncomputable section +open scoped Classical +namespace TriplePosition +variable {n m : ℕ} (s : TriplePosition n) + + + +theorem torus_yang_baxter (z w : SpectralField m) + (hz : z≠0) (hw : w≠0) (hLz : torusL z≠0) (hLw : torusL w≠0) + (hLzw : torusL (z*w)≠0) : + localR s.right (torusWeights w) * localR s.left (torusWeights (z*w)) * + localR s.right (torusWeights z) = + localR s.left (torusWeights z) * localR s.right (torusWeights (z*w)) * + localR s.left (torusWeights w) := by + ext q p + rw [triple_expansion,triple_expansion_mirror] + change (∑ t : ThreeBox.Config, if Circuit.eval p (s.rightCircuit t)=some q + then (torusWeights z).tile t.1*(torusWeights (z*w)).tile t.2.1*(torusWeights w).tile t.2.2 else 0) = + (∑ t : ThreeBox.Config, if Circuit.eval p (s.leftCircuit t)=some q + then (torusWeights w).tile t.1*(torusWeights (z*w)).tile t.2.1*(torusWeights z).tile t.2.2 else 0) + simp_rw [s.eval_profile_iff,s.mirror_eval_profile_iff,s.mirror_predicate] + exact ThreeBox.braid_partition z w hz hw hLz hLw hLzw (s.exteriorPredicate p q) + +end TriplePosition + + + + + +namespace Position +variable {n : ℕ} + +def Disjoint (a b : Position n) : Prop := + a.left≠b.left ∧ a.left≠b.right ∧ a.right≠b.left ∧ a.right≠b.right + +lemma disjoint_symm {a b : Position n} (h : a.Disjoint b) : b.Disjoint a := + ⟨h.1.symm,h.2.2.1.symm,h.2.1.symm,h.2.2.2.symm⟩ + +def pairCircuit (a b : Position n) (t u : Tile) : Circuit n := + .snoc (.snoc .nil (a.gate t)) (b.gate u) + +def exchangeEquiv : ((Fin n ⊕ Fin 4) ⊕ Fin 4) ≃ ((Fin n ⊕ Fin 4) ⊕ Fin 4) where + toFun + | .inl (.inl i) => .inl (.inl i) + | .inl (.inr k) => .inr k + | .inr k => .inl (.inr k) + invFun + | .inl (.inl i) => .inl (.inl i) + | .inl (.inr k) => .inr k + | .inr k => .inl (.inr k) + left_inv := by rintro ((i|k)|k) <;> rfl + right_inv := by rintro ((i|k)|k) <;> rfl + +lemma exchange_edge (a b : Position n) (h : a.Disjoint b) (p : Pairing n) (t u : Tile) + (v w : ((Fin n ⊕ Fin 4) ⊕ Fin 4)) : + Circuit.compactWiring p (pairCircuit a b t u) v w ↔ + Circuit.compactWiring p (pairCircuit b a u t) (exchangeEquiv v) (exchangeEquiv w) := by + rcases h with ⟨h₀,h₁,h₂,h₃⟩ + rcases v with (i|k)|k <;> rcases w with (j|l)|l + all_goals simp [pairCircuit,Circuit.compactWiring,CompactGate.wiring,Circuit.support, + Circuit.compactBoundary,CompactGate.boundary,gate,exchangeEquiv, + h₀,h₁,h₂,h₃,h₀.symm,h₁.symm,h₂.symm,h₃.symm] + all_goals dsimp only [Circuit.CompactVertex] at * + all_goals simp only [Sum.inl.injEq] + +lemma exchange_boundary (a b : Position n) (h : a.Disjoint b) (t u : Tile) (i : Fin n) : + exchangeEquiv ((pairCircuit a b t u).compactBoundary i)= + (pairCircuit b a u t).compactBoundary i := by + rcases h with ⟨h₀,h₁,h₂,h₃⟩ + by_cases ha : i=a.left <;> by_cases ha' : i=a.right <;> + by_cases hb : i=b.left <;> by_cases hb' : i=b.right + all_goals simp_all [pairCircuit,Circuit.compactBoundary,CompactGate.boundary,gate,exchangeEquiv] + all_goals rfl + +lemma exchange_compatible (a b : Position n) (h : a.Disjoint b) (p : Pairing n) (t u : Tile) : + Circuit.Compatible p (pairCircuit a b t u) ↔ Circuit.Compatible p (pairCircuit b a u t) := by + rcases h with ⟨h₀,h₁,h₂,h₃⟩ + simp only [pairCircuit,Circuit.Compatible,Circuit.support,gate, + h₀,h₁,h₂,h₃,h₀.symm,h₁.symm,h₂.symm,h₃.symm,true_and] + itauto + +lemma exchange_eval (a b : Position n) (h : a.Disjoint b) (p q : Pairing n) (t u : Tile) : + Circuit.eval p (pairCircuit a b t u)=some q ↔ Circuit.eval p (pairCircuit b a u t)=some q := by + rw [Circuit.compact_eval_iff,Circuit.compact_eval_iff,exchange_compatible a b h] + exact and_congr_right fun _ => + (Graph.BoundaryEquiv.ofEquiv exchangeEquiv (exchange_edge a b h p t u) + (exchange_boundary a b h t u)).realizes_iff + +lemma steps_commute (a b : Position n) (h : a.Disjoint b) (p : Pairing n) (t u : Tile) : + (p.tileStep a.left a.right a.adjacent t).bind (fun q => q.tileStep b.left b.right b.adjacent u) = + (p.tileStep b.left b.right b.adjacent u).bind (fun q => q.tileStep a.left a.right a.adjacent t) := by + apply Option.ext + intro q + exact exchange_eval a b h p q t u + +end Position + +lemma localR_commute {K : Type*} [CommRing K] {n : ℕ} (a b : Position n) + (h : a.Disjoint b) (w v : Weights K) : + localR a w * localR b v = localR b v * localR a w := by + unfold localR + simp only [Finset.sum_mul,Finset.mul_sum,Matrix.smul_mul,Matrix.mul_smul,smul_smul] + rw [Finset.sum_comm] + apply Finset.sum_congr rfl + intro t _ + apply Finset.sum_congr rfl + intro u _ + rw [optionMatrix_mul,optionMatrix_mul] + congr 1 + · ring + · apply congrArg optionMatrix + funext p + exact (a.steps_commute b h p t u).symm + + + + + + +namespace Pairing +variable {n m : ℕ} (f : Fin n ↪o Fin m) + +lemma map_adj (p : Pairing n) (x y : Fin m) : + (p.map f).Adj x y ↔ ∃ i j, p.Adj i j ∧ f i=x ∧ f j=y := by + simp only [map,Adj,Finset.mem_map,Prod.exists,Function.Embedding.coe_prodMap,Prod.map_apply,Prod.mk.injEq] + constructor + · rintro (⟨i,j,h,hi,hj⟩|⟨i,j,h,hj,hi⟩) + · exact ⟨i,j,Or.inl h,hi,hj⟩ + · exact ⟨j,i,Or.inr h,hi,hj⟩ + · rintro ⟨i,j,(h|h),hi,hj⟩ + · exact Or.inl ⟨i,j,h,hi,hj⟩ + · exact Or.inr ⟨j,i,h,hj,hi⟩ + +@[simp] lemma map_occupied (p : Pairing n) (i : Fin n) : + (p.map f).Occupied (f i) ↔ p.Occupied i := by + simp only [Occupied,map_adj] + constructor + · rintro ⟨_,a,b,h,ha,_⟩ + have := f.injective ha + subst a + exact ⟨b,h⟩ + · rintro ⟨j,h⟩ + exact ⟨f j,i,j,h,rfl,rfl⟩ + +@[simp] lemma map_partnerOrSelf (p : Pairing n) (i : Fin n) : + (p.map f).partnerOrSelf (f i)=f (p.partnerOrSelf i) := by + by_cases hi : p.Occupied i + · have hmap : (p.map f).Adj (f i) (f (p.partnerOrSelf i)) := + (map_adj_image f p _ _).mpr ((p.adj_partnerOrSelf i _).mpr ⟨hi,rfl⟩) + exact ((p.map f).adj_partnerOrSelf _ _).mp hmap |>.2.symm + · simp [partnerOrSelf,hi] + +@[simp] lemma map_cutShape (p : Pairing n) (a b : Fin n) : + (p.map f).cutShape (f a) (f b)=p.cutShape a b := by + simp only [cutShape,map_occupied,map_adj_image] + +lemma map_cutLabels (p : Pairing n) (a b : Fin n) (i : Fin 4) : + (p.map f).cutLabels (f a) (f b) i=f (p.cutLabels a b i) := by + fin_cases i <;> simp [cutLabels] + +lemma map_omit_adj (p : Pairing n) (a b : Fin n) (x y : Fin m) : + ((p.map f).omitTwo (f a) (f b)).Adj x y ↔ + ∃ i j, (p.omitTwo a b).Adj i j ∧ f i=x ∧ f j=y := by + simp only [omitTwo_adj,map_adj] + constructor + · rintro ⟨⟨i,j,h,rfl,rfl⟩,hia,hib,hja,hjb⟩ + exact ⟨i,j,⟨h,fun he => hia (congrArg f he),fun he => hib (congrArg f he), + fun he => hja (congrArg f he),fun he => hjb (congrArg f he)⟩,rfl,rfl⟩ + · rintro ⟨i,j,⟨h,hia,hib,hja,hjb⟩,rfl,rfl⟩ + exact ⟨⟨i,j,h,rfl,rfl⟩,fun he => hia (f.injective he),fun he => hib (f.injective he), + fun he => hja (f.injective he),fun he => hjb (f.injective he)⟩ + +lemma map_cutRelation (p : Pairing n) (a b : Fin n) (d : Finset (Fin 4 × Fin 4)) (x y : Fin m) : + (p.map f).cutRelation (f a) (f b) d x y ↔ + ∃ i j, p.cutRelation a b d i j ∧ f i=x ∧ f j=y := by + simp only [cutRelation,map_omit_adj,map_cutLabels] + constructor + · rintro (⟨i,j,h,hi,hj⟩|⟨r,s,h,hi,hj⟩) + · exact ⟨i,j,Or.inl h,hi,hj⟩ + · exact ⟨p.cutLabels a b r,p.cutLabels a b s,Or.inr ⟨r,s,h,rfl,rfl⟩,hi,hj⟩ + · rintro ⟨i,j,(h|⟨r,s,h,rfl,rfl⟩),hi,hj⟩ + · exact Or.inl ⟨i,j,h,hi,hj⟩ + · exact Or.inr ⟨r,s,h,hi,hj⟩ + +lemma map_tileStep (p : Pairing n) (a b : Fin n) (hab : a.val+1=b.val) + (hf : (f a).val+1=(f b).val) (t : Tile) : + (p.map f).tileStep (f a) (f b) hf t=(p.tileStep a b hab t).map (Pairing.map f) := by + cases hp : p.tileStep a b hab t with + | none => + simp only [Option.map_none] + rw [tileStep_none_iff,map_cutShape,←tileStep_none_iff p a b hab t,hp] + | some q => + have hd : CutPatch.profile (p.cutShape a b) t≠none := by + rw [ne_eq,←tileStep_none_iff p a b hab t,hp] + exact Option.some_ne_none q + obtain ⟨d,hd⟩ := Option.ne_none_iff_exists'.mp hd + have hn : (p.map f).tileStep (f a) (f b) hf t≠none := by + rw [ne_eq,tileStep_none_iff,map_cutShape,hd] + exact Option.some_ne_none d + obtain ⟨r,hr⟩ := Option.ne_none_iff_exists'.mp hn + simp only [hr,Option.map_some,Option.some.injEq] + apply ext_adj + intro x y + rw [tileStep_sound (p.map f) _ _ hf t r d hr (by simpa only [map_cutShape] using hd), + map_cutRelation,map_adj] + simp_rw [tileStep_sound p a b hab t q d hp hd] + +end Pairing +end +end CriticalStrip.Diagram + +end OAI diff --git a/lean/OAI/Combinatorics/StripMass/MomentGrowth.lean b/lean/OAI/Combinatorics/StripMass/MomentGrowth.lean new file mode 100644 index 0000000000000000000000000000000000000000..c284c809f19d9f1998f7cf17223969a49cceb0ad --- /dev/null +++ b/lean/OAI/Combinatorics/StripMass/MomentGrowth.lean @@ -0,0 +1,356 @@ +import Mathlib +import OAI.Combinatorics.StripMass.QuarterMoments + +namespace OAI + +/-! Critical honeycomb strip paths, polynomial identities and crossing mass. -/ + + +namespace CriticalStrip +noncomputable section +open scoped BigOperators +open Set MeasureTheory +theorem positiveLaw_inverseQuarterSum_growth_upper (n : ℕ) : + (∫ y, inverseQuarterStatistic (n+1) y ∂positiveLaw (n+1)) ≤ + (2*(64:ℝ)^(1/4:ℝ)*referenceUpperConstant) * ((n:ℝ)+1)^(3/4:ℝ) := by + let b : ℝ := 64*((n:ℝ)+1) + have hb : 4 ≤ b := by dsimp [b]; nlinarith [Nat.cast_nonneg (α := ℝ) n] + have hb0 : 0 < b := by linarith + have hp : (1/2:ℝ) ≤ (laguerreLaw (n+1) (1/2)).real (cutoffEvent (n+1) (b/2)) := by + have he : b/2 = 32*((n:ℝ)+1) := by dsimp [b]; ring + rw [he] + exact laguerreLaw_cutoff_half_uniform n + have H := positiveLaw_inverseQuarter_le_reference (n+1) hb + have hRef := laguerre_inverseQuarterSum_upper n + change (∫ r, inverseQuarterStatistic (n+1) r ∂laguerreLaw (n+1) (1/2)) ≤ + referenceUpperConstant*((n:ℝ)+1)^(1/2:ℝ) at hRef + have hbpow : 0 ≤ b^(1/4:ℝ) := (Real.rpow_pos_of_pos hb0 _).le + calc + _ ≤ _ := H + _ ≤ b^(1/4:ℝ)*(referenceUpperConstant*((n:ℝ)+1)^(1/2:ℝ)) / + (laguerreLaw (n+1) (1/2)).real (cutoffEvent (n+1) (b/2)) := + div_le_div_of_nonneg_right (mul_le_mul_of_nonneg_left hRef hbpow) (by linarith) + _ ≤ b^(1/4:ℝ)*(referenceUpperConstant*((n:ℝ)+1)^(1/2:ℝ)) / (1/2) := + div_le_div_of_nonneg_left (by positivity [referenceUpperConstant_pos]) (by norm_num) hp + _ = _ := by + dsimp only [b] + rw [Real.mul_rpow (by norm_num : (0:ℝ)≤64) (by positivity)] + have hn : 0 < (n:ℝ)+1 := by positivity + have he : ((n:ℝ)+1)^(1/4:ℝ)*((n:ℝ)+1)^(1/2:ℝ) = ((n:ℝ)+1)^(3/4:ℝ) := by + rw [← Real.rpow_add hn] + norm_num + calc + _ = (2*(64:ℝ)^(1/4:ℝ)*referenceUpperConstant) * + (((n:ℝ)+1)^(1/4:ℝ)*((n:ℝ)+1)^(1/2:ℝ)) := by ring + _ = _ := by rw [he] + + + +theorem positiveLaw_least_inverseQuarter_growth_lower (n : ℕ) : + ((2:ℝ)^(-(1/4:ℝ))*(1/2:ℝ)^(1/4:ℝ)*(Real.exp (-1)/48)) * ((n:ℝ)+1)^(3/4:ℝ) ≤ + ∫ y, (y 0)^(-(1/4:ℝ)) ∂positiveLaw (n+1) := by + let b : ℝ := ((n:ℝ)+2)/2 + have hb : 1 ≤ b := by dsimp [b]; nlinarith [Nat.cast_nonneg (α := ℝ) n] + have hb' : b ≤ ((n+1:ℕ)+1:ℝ)/2 := by dsimp [b]; push_cast; linarith + have hb0 : 0 < b := by linarith + have H := positiveLaw_inverseQuarter_ge_reference (0 : Fin (n+1)) hb hb' + have hRef := laguerre_least_inverseQuarter_lower n + rw [← integral_laguerreLaw _ (by norm_num : (0:ℝ)<1)] at hRef + have hscale : ((1/2:ℝ)*((n:ℝ)+1))^(1/4:ℝ) ≤ b^(1/4:ℝ) := by + apply Real.rpow_le_rpow (by positivity) _ (by norm_num) + dsimp [b] + linarith + have hlow : 0 ≤ (Real.exp (-1)/48)*((n:ℝ)+1)^(1/2:ℝ) := by positivity + calc + _ = (2:ℝ)^(-(1/4:ℝ)) * (((1/2:ℝ)*((n:ℝ)+1))^(1/4:ℝ)) * + ((Real.exp (-1)/48) * ((n:ℝ)+1)^(1/2:ℝ)) := by + rw [Real.mul_rpow (by norm_num : (0:ℝ)≤1/2) (by positivity)] + have hn : 0 < (n:ℝ)+1 := by positivity + have he : ((n:ℝ)+1)^(1/4:ℝ)*((n:ℝ)+1)^(1/2:ℝ) = ((n:ℝ)+1)^(3/4:ℝ) := by + rw [← Real.rpow_add hn] + norm_num + calc + _ = ((2:ℝ)^(-(1/4:ℝ))*(1/2:ℝ)^(1/4:ℝ)*(Real.exp (-1)/48)) * + (((n:ℝ)+1)^(1/4:ℝ)*((n:ℝ)+1)^(1/2:ℝ)) := by rw [he] + _ = _ := by ring + _ ≤ (2:ℝ)^(-(1/4:ℝ))*b^(1/4:ℝ)* + ((Real.exp (-1)/48)*((n:ℝ)+1)^(1/2:ℝ)) := + mul_le_mul_of_nonneg_right (mul_le_mul_of_nonneg_left hscale (by positivity)) hlow + _ ≤ (2:ℝ)^(-(1/4:ℝ))*b^(1/4:ℝ)* + (∫ r, (r 0)^(-(1/4:ℝ)) ∂laguerreLaw (n+1) 1) := + mul_le_mul_of_nonneg_left hRef (by positivity) + _ ≤ _ := H + + + +theorem positive_arch_integral_growth : + Comparable (fun N => ∫ x in Ioo 0 1, momentIntegrand N x) + (fun N => (N:ℝ)^(3/4:ℝ)) := by + refine ⟨(1/96) * ((2:ℝ)^(-(1/4:ℝ))*(1/2:ℝ)^(1/4:ℝ)*(Real.exp (-1)/48)), + (32/3) * (2*(64:ℝ)^(1/4:ℝ)*referenceUpperConstant), by positivity, + by have := referenceUpperConstant_pos; positivity, ?_⟩ + intro N hN + obtain ⟨n, rfl⟩ := Nat.exists_eq_succ_of_ne_zero (by omega : N ≠ 0) + have hI := integral_inverse_comparison hN + have hL := positiveLaw_least_inverseQuarter_growth_lower n + have hU := positiveLaw_inverseQuarterSum_growth_upper n + rw [integral_positiveLaw] at hL hU + constructor + · have H := (mul_le_mul_of_nonneg_left hL (by norm_num : (0:ℝ)≤1/96)).trans hI.1 + simpa only [Nat.succ_eq_add_one, Nat.cast_add, Nat.cast_one, mul_assoc] using H + · have H := hI.2.trans (mul_le_mul_of_nonneg_left hU (by norm_num : (0:ℝ)≤32/3)) + simpa only [Nat.succ_eq_add_one, Nat.cast_add, Nat.cast_one, mul_assoc] using H + + + + + +lemma pairKernel_symm (x y : ℝ) : pairKernel x y = pairKernel y x := by + unfold pairKernel + rw [add_comm x y] + congr 1 + ring + +lemma prod_upper_square {n : ℕ} (g : Fin n → Fin n → ℝ) + (hsym : ∀ i j, g i j = g j i) : + (∏ i, ∏ j ∈ Finset.Ioi i, g i j)^2 = + ∏ i, ∏ j, if i = j then 1 else g i j := by + classical + have he : (∏ i, ∏ j ∈ Finset.Ioi i, g i j) = + ∏ i, ∏ j, if i < j then g i j else 1 := by + congr 1 + ext i + rw [← Finset.prod_filter] + congr 1 + ext j + simp + rw [he, pow_two] + conv_lhs => rhs; rw [Finset.prod_comm] + rw [← Finset.prod_mul_distrib] + apply Finset.prod_congr rfl + intro i _ + rw [← Finset.prod_mul_distrib] + apply Finset.prod_congr rfl + intro j _ + rcases lt_trichotomy i j with h | rfl | h + · simp [h, not_lt.mpr h.le, h.ne] + · simp + · simp [h, not_lt.mpr h.le, h.ne', hsym] + +lemma prod_upper_perm {n : ℕ} (g : Fin n → Fin n → ℝ) + (hsym : ∀ i j, g i j = g j i) (hpos : ∀ i j, 0 ≤ g i j) + (σ : Equiv.Perm (Fin n)) : + (∏ i, ∏ j ∈ Finset.Ioi i, g (σ i) (σ j)) = + ∏ i, ∏ j ∈ Finset.Ioi i, g i j := by + classical + have ha : 0 ≤ ∏ i, ∏ j ∈ Finset.Ioi i, g (σ i) (σ j) := + Finset.prod_nonneg fun i _ => Finset.prod_nonneg fun j _ => hpos _ _ + have hb : 0 ≤ ∏ i, ∏ j ∈ Finset.Ioi i, g i j := + Finset.prod_nonneg fun i _ => Finset.prod_nonneg fun j _ => hpos _ _ + have he : (∏ i, ∏ j ∈ Finset.Ioi i, g (σ i) (σ j))^2 = + (∏ i, ∏ j ∈ Finset.Ioi i, g i j)^2 := by + rw [prod_upper_square _ (fun i j => hsym _ _), prod_upper_square g hsym] + apply Fintype.prod_equiv σ + intro i + apply Fintype.prod_equiv σ + intro j + simp + nlinarith + +lemma density_perm_of_nonneg {n : ℕ} {x : Fin n → ℝ} (hx : ∀ i, 0 ≤ x i) + (σ : Equiv.Perm (Fin n)) : density n (x ∘ σ) = density n x := by + unfold density + congr 1 + · exact Fintype.prod_equiv σ _ _ (fun _ => rfl) + · exact prod_upper_perm _ (fun i j => pairKernel_symm _ _) + (fun i j => pairKernel_nonneg (hx i) (hx j)) σ + +lemma density_zero_of_not_injective {n : ℕ} {x : Fin n → ℝ} + (hx : ¬ Function.Injective x) : density n x = 0 := by + classical + obtain ⟨i, j, he, hne⟩ : ∃ i j, x i = x j ∧ i ≠ j := by + simpa only [Function.Injective, not_forall, exists_prop] using hx + suffices (∏ i, ∏ j ∈ Finset.Ioi i, pairKernel (x i) (x j)) = 0 by + simp [density, this] + rcases hne.lt_or_gt with h | h + · apply Finset.prod_eq_zero (Finset.mem_univ i) + apply Finset.prod_eq_zero (Finset.mem_Ioi.mpr h) + simp [pairKernel, he] + · apply Finset.prod_eq_zero (Finset.mem_univ j) + apply Finset.prod_eq_zero (Finset.mem_Ioi.mpr h) + simp [pairKernel, he] + +abbrev unitCubeMeasure (n : ℕ) : Measure (Fin n → ℝ) := + Measure.pi (fun _ => volume.restrict (Ioo (0:ℝ) 1)) + +lemma ae_unitCube (n : ℕ) : + ∀ᵐ x ∂unitCubeMeasure n, ∀ i, x i ∈ Ioo (0:ℝ) 1 := by + rw [unitCubeMeasure, ← Measure.restrict_pi_pi, ← volume_pi] + exact (ae_restrict_mem (MeasurableSet.univ_pi fun _ => measurableSet_Ioo)).mono + fun _ hx i => hx i (mem_univ i) + +lemma unitCube_restrict_ordered (n : ℕ) : + (unitCubeMeasure n).restrict (orderedDomain n) = volume.restrict (orderedDomain n) := by + rw [unitCubeMeasure, ← Measure.restrict_pi_pi, ← volume_pi, + Measure.restrict_restrict (isOpen_orderedDomain n).measurableSet] + congr 1 + exact inter_eq_left.mpr (fun _ hx i _ => hx.2 i) + +lemma integral_symmetric_unitCube {n : ℕ} (F : (Fin n → ℝ) → ℝ) + (hperm : ∀ σ : Equiv.Perm (Fin n), ∀ x, (∀ i, x i ∈ Ioo (0:ℝ) 1) → F (x ∘ σ) = F x) + (hzero : ∀ x, ¬Function.Injective x → F x = 0) + (hint : IntegrableOn F (orderedDomain n)) : + (∫ x, F x ∂unitCubeMeasure n) = + (n.factorial : ℝ) * ∫ x in orderedDomain n, F x := by + classical + let G := (orderedDomain n).indicator F + have hi : Integrable G (unitCubeMeasure n) := by + rw [integrable_indicator_iff (isOpen_orderedDomain n).measurableSet] + simpa only [IntegrableOn, unitCube_restrict_ordered] using hint + have his (σ : Equiv.Perm (Fin n)) : + Integrable (fun x => G (x ∘ σ)) (unitCubeMeasure n) := by + simpa only [Function.comp_def, StripPfaffian.piCongrLeft_const_apply, Equiv.symm_symm] using + (measurePreserving_piCongrLeft (fun _ : Fin n => volume.restrict (Ioo (0:ℝ) 1)) σ.symm).integrable_comp_of_integrable hi + have heq (σ : Equiv.Perm (Fin n)) : + (∫ x, G (x ∘ σ) ∂unitCubeMeasure n) = ∫ x in orderedDomain n, F x := by + have he := (measurePreserving_piCongrLeft + (fun _ : Fin n => volume.restrict (Ioo (0:ℝ) 1)) σ.symm).integral_comp' G + simp only [StripPfaffian.piCongrLeft_const_apply, Equiv.symm_symm] at he + rw [he, integral_indicator (isOpen_orderedDomain n).measurableSet, unitCube_restrict_ordered] + have hs (x : Fin n → ℝ) (hx : ∀ i, x i ∈ Ioo (0:ℝ) 1) : + ∑ σ : Equiv.Perm (Fin n), G (x ∘ σ) = F x := by + by_cases hinj : Function.Injective x + · have hsort : x ∘ Tuple.sort x ∈ orderedDomain n := + ⟨(Tuple.monotone_sort x).strictMono_of_injective (hinj.comp (Tuple.sort x).injective), + fun i => hx _⟩ + rw [Finset.sum_eq_single (Tuple.sort x)] + · exact (indicator_of_mem hsort F).trans (hperm _ _ hx) + · intro σ _ hne + apply indicator_of_notMem + intro hσ + apply hne + apply Equiv.ext + intro i + exact hinj (congrFun (Tuple.unique_monotone hσ.1.monotone (Tuple.monotone_sort x)) i) + · simp + · rw [hzero x hinj] + apply Finset.sum_eq_zero + intro σ _ + by_cases hm : x ∘ σ ∈ orderedDomain n + · exact (indicator_of_mem hm F).trans ((hperm _ _ hx).trans (hzero x hinj)) + · exact indicator_of_notMem hm _ + calc + _ = ∫ x, ∑ σ : Equiv.Perm (Fin n), G (x ∘ σ) ∂unitCubeMeasure n := + integral_congr_ae ((ae_unitCube n).mono fun x hx => (hs x hx).symm) + _ = ∑ σ : Equiv.Perm (Fin n), ∫ x, G (x ∘ σ) ∂unitCubeMeasure n := + integral_finsetSum _ (fun σ _ => his σ) + _ = _ := by simp only [heq, Finset.sum_const, Finset.card_univ, + Fintype.card_perm, Fintype.card_fin, nsmul_eq_mul] + +lemma integral_density_unitCube (n : ℕ) : + (∫ x, density n x ∂unitCubeMeasure n) = (n.factorial:ℝ) * normalizer n := by + exact integral_symmetric_unitCube _ + (fun σ x hx => density_perm_of_nonneg (fun i => (hx i).1.le) σ) + (fun _ hx => density_zero_of_not_injective hx) (integrableOn_density n) + +lemma density_cons (n : ℕ) (x : ℝ) (y : Fin n → ℝ) : + density (n+1) (Fin.cons x y) = + omega x * density n y * ∏ i, pairKernel x (y i) := by + rw [density, Fin.prod_univ_succ, pairProduct_cons] + simp only [Fin.cons_zero, Fin.cons_succ, density] + ring + +lemma density_nonneg_of_nonneg {n : ℕ} {y : Fin n → ℝ} (hy : ∀ i, 0 ≤ y i) : + 0 ≤ density n y := by + unfold density + apply mul_nonneg (Finset.prod_nonneg fun _ _ => omega_nonneg _) + exact Finset.prod_nonneg fun i _ => Finset.prod_nonneg fun j _ => pairKernel_nonneg (hy i) (hy j) + +lemma density_cube_le_product {n : ℕ} {y : Fin n → ℝ} (hy : ∀ i, y i ∈ Ioo (0:ℝ) 1) : + density n y ≤ ∏ i, omega (y i) := by + have h0 : 0 ≤ ∏ i : Fin n, omega (y i) := Finset.prod_nonneg fun _ _ => omega_nonneg _ + unfold density + apply (mul_le_mul_of_nonneg_left _ h0).trans_eq (mul_one _) + exact Finset.prod_le_one₀ + (fun i _ => Finset.prod_nonneg fun j _ => pairKernel_nonneg (hy i).1.le (hy j).1.le) + (fun i _ => Finset.prod_le_one₀ + (fun j _ => pairKernel_nonneg (hy i).1.le (hy j).1.le) + (fun j _ => pairKernel_le_one (hy i) (hy j))) + +lemma integrable_density_unitCube (n : ℕ) : Integrable (density n) (unitCubeMeasure n) := by + apply (Integrable.fintype_prod (fun _ : Fin n => integrableOn_omega)).mono' + (measurable_density n).aestronglyMeasurable + filter_upwards [ae_unitCube n] with y hy + simpa only [Real.norm_eq_abs, abs_of_nonneg (density_nonneg_of_nonneg (fun i => (hy i).1.le))] + using density_cube_le_product hy + +lemma integrable_cube_mul_density {n : ℕ} {g : (Fin n → ℝ) → ℝ} (hg : Measurable g) + {b : ℝ} (hbd : ∀ y, (∀ i, y i ∈ Ioo (0:ℝ) 1) → |g y| ≤ b) : + Integrable (fun y => g y * density n y) (unitCubeMeasure n) := by + apply ((integrable_density_unitCube n).const_mul b).mono' + (hg.mul (measurable_density n)).aestronglyMeasurable + filter_upwards [ae_unitCube n] with y hy + change ‖g y * density n y‖ ≤ _ + rw [Real.norm_eq_abs, abs_mul, abs_of_nonneg (density_nonneg_of_nonneg (fun i => (hy i).1.le))] + exact mul_le_mul_of_nonneg_right (hbd y hy) (density_nonneg_of_nonneg (fun i => (hy i).1.le)) + +lemma reflectionProduct_perm {n : ℕ} (x : ℝ) (y : Fin n → ℝ) (σ : Equiv.Perm (Fin n)) : + reflectionProduct n x (y ∘ σ) = reflectionProduct n x y := by + exact Fintype.prod_equiv σ _ _ (fun _ => rfl) + +lemma expectation_reflection_unitCube (n : ℕ) {x : ℝ} (hx : 0 ≤ x) : + expectation n (reflectionProduct n x) = + (∫ y, reflectionProduct n x y * density n y ∂unitCubeMeasure n) / + (∫ y, density n y ∂unitCubeMeasure n) := by + rw [integral_symmetric_unitCube _ + (fun σ y hy => by rw [reflectionProduct_perm, density_perm_of_nonneg (fun i => (hy i).1.le)]) + (fun y hy => by rw [density_zero_of_not_injective hy, mul_zero]) + (integrableOn_reflectionProduct_density n hx), integral_density_unitCube] + rw [mul_div_mul_left _ _ (by exact_mod_cast (Nat.factorial_ne_zero n))] + rfl + + def reflectionResidue (n : ℕ) (y : Fin n → ℝ) (i : Fin n) : ℝ := + 2 * ∏ j ∈ Finset.univ.erase i, (y j + y i) / (y j - y i) + +lemma reflectionResidue_perm {n : ℕ} (y : Fin n → ℝ) (σ : Equiv.Perm (Fin n)) (i : Fin n) : + reflectionResidue n (y ∘ σ) i = reflectionResidue n y (σ i) := by + classical + unfold reflectionResidue + congr 1 + apply Finset.prod_equiv σ + · intro j + simp + · intro j hj + rfl + +lemma reflectionResidue_zero_cons {n : ℕ} (x : ℝ) (y : Fin n → ℝ) : + reflectionResidue (n+1) (Fin.cons x y) 0 = 2 * ∏ j, (y j+x)/(y j-x) := by + classical + unfold reflectionResidue + congr 1 + have he : (Finset.univ.erase (0 : Fin (n+1))) = Finset.univ.filter (fun i => i ≠ 0) := by ext; simp + rw [he, Finset.prod_filter, Fin.prod_univ_succ] + simp + +lemma reflectionResidue_density_cons {n : ℕ} {x : ℝ} {y : Fin n → ℝ} + (hx : 0 < x) (hy : ∀ i, 0 < y i) : + reflectionResidue (n+1) (Fin.cons x y) 0 * density (n+1) (Fin.cons x y) = + 2 * omega x * density n y * ∏ i, (y i-x) := by + rw [reflectionResidue_zero_cons, density_cons] + have hprod : (∏ i, (y i+x)/(y i-x)) * (∏ i, pairKernel x (y i)) = ∏ i, (y i-x) := by + rw [← Finset.prod_mul_distrib] + apply Finset.prod_congr rfl + intro i _ + unfold pairKernel + by_cases hi : y i = x + · simp [hi] + · field_simp [(add_pos (hy i) hx).ne', sub_ne_zero.mpr hi] + calc + _ = 2 * omega x * density n y * + ((∏ i, (y i+x)/(y i-x)) * (∏ i, pairKernel x (y i))) := by ring + _ = _ := by rw [hprod] + +end +end CriticalStrip + +end OAI diff --git a/lean/OAI/Combinatorics/StripMass/MonicPositive.lean b/lean/OAI/Combinatorics/StripMass/MonicPositive.lean new file mode 100644 index 0000000000000000000000000000000000000000..5fcd121edac4b8c8ac56b942f5dd97108d168947 --- /dev/null +++ b/lean/OAI/Combinatorics/StripMass/MonicPositive.lean @@ -0,0 +1,527 @@ +import Mathlib +import OAI.Combinatorics.StripMass.ScalarBridge +import OAI.Combinatorics.StripMass.RightStieltjes + +namespace OAI + +/-! Critical honeycomb strip paths, polynomial identities and crossing mass. -/ + + +namespace CriticalStrip +noncomputable section +open Set MeasureTheory Filter Polynomial +open scoped Topology BigOperators Classical + +lemma projectionF_high_scaled_limit {n : ℕ} (hn : 1 ≤ n) {g P J E : Polynomial ℝ} + (hP : P.natDegree ≤ n) (hJ : J.natDegree ≤ n) (hE : E.degree < (n : WithBot ℕ)) + (hQ : homogeneousQ n g = P.comp harmonicCoordinate + X * J.comp harmonicCoordinate + + X^2 * E.comp harmonicCoordinate) : + Tendsto (fun z : ℝ => z^(n+1) * + projectionF (tildePoly n P) (tildePoly n J) (tildePoly n E) z) atTop + (𝓝 (((1/8) / ((2*C)*(1-2*C^2)))^(2*n+1) * ((C-c)^n * g.eval C))) := by + have hz : ∀ᶠ z : ℝ in atTop, z ≠ 0 := eventually_ne_atTop 0 + have hi : Tendsto (fun z : ℝ => 1/z) atTop (𝓝 0) := by simpa only [one_div] using tendsto_inv_atTop_zero + have hb : Tendsto (fun z : ℝ => highBranch (1/z)) atTop (𝓝 C) := by + simpa only [highBranch_zero, Function.comp_def] using highBranch_continuous.continuousAt.tendsto.comp hi + have hscale := ((highBranch_rescaled hz hi).pow (2*n+1)).mul + (((hb.sub_const c).pow n).mul (g.continuous.continuousAt.tendsto.comp hb)) + apply hscale.congr' + filter_upwards [hz,hi.eventually (Ioo_mem_nhds (by norm_num : (-1:ℝ)<0) (by norm_num : (0:ℝ)<1))] with z hz hs + have he := tilde_projection_eval n P J E hP hJ + (degree_lt_implies_natDegree_lt (by omega) hE).le hz (branches_harmonic hs).1 + rw [←hQ] at he + change _ = z^(n+1) * ((tildePoly n P).eval z + highBranch (1/z) * (tildePoly n J).eval z + + highBranch (1/z)^2 * (tildePoly n E).eval z) + rw [he] + simp only [homogeneousQ, eval_mul, eval_pow, eval_sub, eval_C, eval_X, mul_pow, Function.comp_def] + ring + +lemma projectionF_cauchy_scaled_limit {n : ℕ} (hn : 1 ≤ n) {g P J E : Polynomial ℝ} + (hg : g.Monic) (hd : g.natDegree = n) + (hP : P.natDegree ≤ n) (hJ : J.natDegree ≤ n) (hE : E.degree < (n : WithBot ℕ)) + (hQ : homogeneousQ n g = P.comp harmonicCoordinate + X * J.comp harmonicCoordinate + + X^2 * E.comp harmonicCoordinate) : + Tendsto (fun z : ℝ => z^(n+1) * + projectionF (tildePoly n P) (tildePoly n J) (tildePoly n E) z) atTop + (𝓝 (-(∫ y, density (n+1) y ∂unitCubeMeasure (n+1)) / + (Real.pi * (8:ℝ)^n * ((n:ℝ)+1) * ∫ y, density n y ∂unitCubeMeasure n))) := by + apply ((cauchyDensity_limit (n+1)).neg.div_const _).congr' + filter_upwards [eventually_gt_atTop (1:ℝ)] with z hz + rw [projectionF_positive_cauchy hn hg hd hP hJ hE hQ hz] + ring + + + +theorem MonicProblem.eval_C_pos {n : ℕ} (hn : 1 ≤ n) {g : Polynomial ℝ} + (hg : MonicProblem n g) : 0 < g.eval C := by + obtain ⟨hgm,hgd,P,J,E,hP,hJ,hE,hQ⟩ := hg + have he := tendsto_nhds_unique + (projectionF_high_scaled_limit hn hP hJ hE hQ) + (projectionF_cauchy_scaled_limit hn hgm hgd hP hJ hE hQ) + have hpos : 0 < Real.pi * (8:ℝ)^n * ((n:ℝ)+1) * ∫ y, density n y ∂unitCubeMeasure n := by + have hi := integral_density_unitCube_positive n + have hp := Real.pi_pos + positivity + have hneg := div_neg_of_neg_of_pos + (neg_neg_of_pos (integral_density_unitCube_positive (n+1))) hpos + rw [←he] at hneg + have hC := C_c_facts + have hCp : 0.2 + +end +end CriticalStrip + + + + + +namespace CriticalStrip.Diagram +noncomputable section +open Filter Polynomial +open scoped Topology BigOperators Classical + +lemma scalarValue_continuous (n : ℕ) : + Continuous (fun a : Fin n → ℂ => scalarValue (RingHom.id ℂ) a) := by + simpa only [scalarValue, MvPolynomial.eval₂Hom, MvPolynomial.eval] using + (MvPolynomial.continuous_eval (scalarPolynomial n (d:ℂ) rho (by exact_mod_cast d_ne_zero))) + +lemma homogeneous_discriminant_ne_zero : StripPfaffian.D (C:ℂ) (C:ℂ) ≠ 0 := by + have hc := C_c_facts + have hCp : 0 (C:ℂ))) := by + apply tendsto_pi_nhds.mpr + intro i + simpa only [mul_zero,add_zero,separatedHomogeneous] using + (tendsto_one_div_add_atTop_nhds_zero_nat (𝕜:=ℂ)).const_mul (i.val:ℂ) |>.const_add (C:ℂ) + +lemma separatedHomogeneous_discriminants (n : ℕ) : + ∀ᶠ m : ℕ in atTop, ∀ i j : Fin n, + StripPfaffian.D (separatedHomogeneous n m i) (separatedHomogeneous n m j) ≠ 0 := by + apply Filter.eventually_all.mpr + intro i + apply Filter.eventually_all.mpr + intro j + have ht := separatedHomogeneous_tendsto n + have hD : Continuous (fun a : Fin n → ℂ => StripPfaffian.D (a i) (a j)) := by + unfold StripPfaffian.D; fun_prop + exact (hD.continuousAt.tendsto.comp ht).eventually_ne homogeneous_discriminant_ne_zero + +lemma polynomial_eval_limit_of_coeff {α : Type*} {l : Filter α} {P : α → Polynomial ℂ} + {g : Polynomial ℂ} {n : ℕ} (hdeg : ∀ᶠ x in l, (P x).natDegree≤n) (hg : g.natDegree≤n) + (ht : ∀ i, Tendsto (fun x => (P x).coeff i) l (𝓝 (g.coeff i))) (z : ℂ) : + Tendsto (fun x => (P x).eval z) l (𝓝 (g.eval z)) := by + rw [Polynomial.eval_eq_sum_range' (show g.natDegree (ht i).mul_const (z^i))).congr' + filter_upwards [hdeg] with x hx + exact (Polynomial.eval_eq_sum_range' (show (P x).natDegree (C:ℂ))≠0) : + ∃ g : Polynomial ℝ, MonicProblem n g ∧ + archPolynomialAt (fun _ : Fin n => (C:ℂ))=g.map Complex.ofRealHom := by + obtain ⟨g₀,hg₀,hu,g,hg,hgc,hgreg⟩ := archPolynomialAt_confluent n hn + refine ⟨g₀,hg₀,?_⟩ + apply Polynomial.funext + intro z + have ht := separatedHomogeneous_tendsto n + have hreg := ht.eventually hgreg + have hpn : ∀ᶠ m in atTop, scalarValue (RingHom.id ℂ) (separatedHomogeneous n m)≠0 := + ((scalarValue_continuous n).continuousAt.tendsto.comp ht).eventually_ne hp + have hgg : Tendsto (fun m => (g (separatedHomogeneous n m)).eval z) atTop + (𝓝 ((g₀.map Complex.ofRealHom).eval z)) := by + apply polynomial_eval_limit_of_coeff (n:=n) + (hreg.mono fun _ h => h.2.1.le) + ((Polynomial.natDegree_map_le).trans hg₀.2.1.le) + intro i + have hh := (hgc i).tendsto.comp ht + simpa only [hg,Function.comp_def] using hh + have hal : ∀ a : Fin n → ℂ, (archPolynomialAt a).eval z = + scalarValue (RingHom.id ℂ) (Fin.snoc a z) / scalarValue (RingHom.id ℂ) a := by + intro a + simp only [archPolynomialAt,Polynomial.eval_mul,Polynomial.eval_C,nextScalar_eval] + ring + have hcont : Continuous (fun a : Fin n → ℂ => scalarValue (RingHom.id ℂ) (Fin.snoc a z)) := by + apply (scalarValue_continuous (n+1)).comp + apply continuous_pi + intro i + induction i using Fin.lastCases <;> simp only [Fin.snoc_last,Fin.snoc_castSucc] <;> fun_prop + have hfrac := ((hcont.continuousAt.tendsto.comp ht).div + ((scalarValue_continuous n).continuousAt.tendsto.comp ht) hp) + have hh : Tendsto (fun m => (g (separatedHomogeneous n m)).eval z) atTop + (𝓝 ((archPolynomialAt (fun _ : Fin n => (C:ℂ))).eval z)) := by + rw [hal] + apply hfrac.congr' + filter_upwards [hreg,hpn,separatedHomogeneous_discriminants n] with m hm hpm hDm + change scalarValue (RingHom.id ℂ) (Fin.snoc (separatedHomogeneous n m) z) / + scalarValue (RingHom.id ℂ) (separatedHomogeneous n m)=_ + rw [←hal,hm.2.2 (separatedHomogeneous_injective n m) (fun i j _ => hDm i j) hpm] + exact tendsto_nhds_unique hh hgg + +lemma nextScalar_homogeneous_of_ne {n : ℕ} (hn : 1≤n) + (hp : scalarValue (RingHom.id ℂ) (fun _ : Fin n => (C:ℂ))≠0) : + ∃ g : Polynomial ℝ, MonicProblem n g ∧ + nextScalar (RingHom.id ℂ) (fun _ : Fin n => (C:ℂ))= + Polynomial.C (scalarValue (RingHom.id ℂ) (fun _ : Fin n => (C:ℂ))) * g.map Complex.ofRealHom := by + obtain ⟨g,hg,he⟩:=archPolynomialAt_homogeneous_of_ne hn hp + refine ⟨g,hg,?_⟩ + rw [←he,archPolynomialAt,←mul_assoc,←Polynomial.C_mul,mul_inv_cancel₀ hp,Polynomial.C_1,one_mul] + + + +theorem scalarValue_homogeneous_positive (n : ℕ) : + ∃ x : ℝ, 0 (C:ℂ))=(x:ℂ) := by + induction n with + | zero => exact ⟨1,by norm_num,by simp only [scalarValue_zero,Complex.ofReal_one]⟩ + | succ n ih => + by_cases hn : n=0 + · subst n + exact ⟨1,by norm_num,by simp only [scalarValue_one,Complex.ofReal_one]⟩ + obtain ⟨x,hx,he⟩:=ih + have hp : scalarValue (RingHom.id ℂ) (fun _ : Fin n => (C:ℂ))≠0 := by + rw [he]; exact_mod_cast hx.ne' + obtain ⟨g,hg,hnext⟩:=nextScalar_homogeneous_of_ne (by omega) hp + refine ⟨x*g.eval C,mul_pos hx (hg.eval_C_pos (by omega)),?_⟩ + have hh:=congrArg (Polynomial.eval (C:ℂ)) hnext + rw [nextScalar_eval,Polynomial.eval_mul,Polynomial.eval_C,he] at hh + have hs : (Fin.snoc (fun _ : Fin n => (C:ℂ)) (C:ℂ) : Fin (n+1) → ℂ)=(fun _ => (C:ℂ)) := by + funext i + induction i using Fin.lastCases <;> simp + have hm : Polynomial.eval₂ Complex.ofRealHom (C:ℂ) g=(↑(g.eval (CriticalStrip.C:ℝ)):ℂ) := + Polynomial.eval₂_at_apply Complex.ofRealHom C + rw [hs,Polynomial.eval_map,hm] at hh + exact hh.trans (Complex.ofReal_mul _ _).symm + +end +end CriticalStrip.Diagram + + + + + +namespace CriticalStrip +noncomputable section +open Set MeasureTheory Filter Polynomial +open scoped Topology BigOperators Classical + +lemma projectionD_nonneg_right {n : ℕ} (hn : 1≤n) {g P J E : Polynomial ℝ} + (hg : g.Monic) (hd : g.natDegree=n) + (hP : P.natDegree≤n) (hJ : J.natDegree≤n) (hE : E.degree<(n:WithBot ℕ)) + (hQ : homogeneousQ n g=P.comp harmonicCoordinate+X*J.comp harmonicCoordinate+ + X^2*E.comp harmonicCoordinate) {z : ℝ} (hz : 1≤z) : + 0≤projectionD (tildePoly n J) (tildePoly n E) z := by + rw [projectionD_expectation n hn g P J E hP hJ hE hQ z (by linarith), + projection_initial_monic hn hg hd hP hJ hE hQ,←expectation_const_mul] + apply expectation_nonneg + intro y hy + have he : ((-8:ℝ)^n)⁻¹*reflectionProduct n z y= + ∏ i,((-8:ℝ)⁻¹*((y i-z)/(y i+z))) := by + rw [Finset.prod_mul_distrib] + simp only [Finset.prod_const,Finset.card_univ,Fintype.card_fin,inv_pow,reflectionProduct] + rw [he] + apply Finset.prod_nonneg + intro i _ + apply mul_nonneg_of_nonpos_of_nonpos (by norm_num) + exact div_nonpos_of_nonpos_of_nonneg (by linarith [(hy.2 i).2]) (by linarith [(hy.2 i).1]) + +lemma integral_cauchyDensity_lower (n : ℕ) {z : ℝ} (hz : 1 (hy i).1.le) le_rfl + (Finset.prod_pos fun i _ => by linarith [(hy i).2]) + calc + (∏ i, (z-y i)) ≤ ∏ _ : Fin n, (2:ℝ) := Finset.prod_le_prod₀ + (fun i _ => by linarith [(hy i).2]) (fun i _ => by linarith [(hy i).1]) + _ = _ := by simp + +lemma projectionF_continuousAt (P J E : Polynomial ℝ) {z : ℝ} (hz : z≠0) : + ContinuousAt (projectionF P J E) z := by + change ContinuousAt (fun z : ℝ => P.eval z + Real.sqrt ((1+Real.sqrt ((1-1/z)/2))/2)*J.eval z + + Real.sqrt ((1+Real.sqrt ((1-1/z)/2))/2)^2*E.eval z) z + fun_prop (disch := assumption) + + +lemma projectionF_one_neg {n : ℕ} (hn : 1≤n) {g P J E : Polynomial ℝ} + (hg : g.Monic) (hd : g.natDegree=n) + (hP : P.natDegree≤n) (hJ : J.natDegree≤n) (hE : E.degree<(n:WithBot ℕ)) + (hQ : homogeneousQ n g=P.comp harmonicCoordinate+X*J.comp harmonicCoordinate+ + X^2*E.comp harmonicCoordinate) : + projectionF (tildePoly n P) (tildePoly n J) (tildePoly n E) 1<0 := by + let b : ℝ := (∫ y, density (n+1) y ∂unitCubeMeasure (n+1)) / + ((2:ℝ)^(n+1)*(Real.pi*8^n*((n:ℝ)+1)*∫ y, density n y ∂unitCubeMeasure n)) + have hb : 0] (1:ℝ), + projectionF (tildePoly n P) (tildePoly n J) (tildePoly n E) z≤ -b := by + filter_upwards [self_mem_nhdsWithin, nhdsWithin_le_nhds (Iio_mem_nhds (by norm_num : (1:ℝ)<2))] with z hz hz₂ + rw [projectionF_positive_cauchy hn hg hd hP hJ hE hQ hz] + have hi:=div_le_div_of_nonneg_right (integral_cauchyDensity_lower (n+1) hz hz₂.le) hden.le + dsimp [b] + calc + _ ≤ -( (∫ y, density (n+1) y ∂unitCubeMeasure (n+1))/(2:ℝ)^(n+1) / + (Real.pi*8^n*((n:ℝ)+1)*∫ y, density n y ∂unitCubeMeasure n)) := by simpa only [neg_div] using neg_le_neg hi + _ = _ := by rw [div_div] + exact (le_of_tendsto ht hbnd).trans_lt (neg_neg_of_pos hb) + +lemma branches_inverse {x : ℝ} (hx : x∈Ioo c C) : + let u:=8*x^2*(1-x^2)-1 + 0 (C:ℂ))≠0 := by + obtain ⟨x,hx,he⟩:=scalarValue_homogeneous_positive n + rw [he] + exact_mod_cast hx.ne' + + + +theorem archPolynomialAt_homogeneous {n : ℕ} (hn : 1≤n) : + ∃ g : Polynomial ℝ, MonicProblem n g ∧ + archPolynomialAt (fun _ : Fin n => (C:ℂ))=g.map Complex.ofRealHom := + archPolynomialAt_homogeneous_of_ne hn (scalarValue_homogeneous_ne_zero n) + +lemma nextScalar_homogeneous {n : ℕ} (hn : 1≤n) : + ∃ g : Polynomial ℝ, MonicProblem n g ∧ + nextScalar (RingHom.id ℂ) (fun _ : Fin n => (C:ℂ))= + Polynomial.C (scalarValue (RingHom.id ℂ) (fun _ : Fin n => (C:ℂ))) * g.map Complex.ofRealHom := + nextScalar_homogeneous_of_ne hn (scalarValue_homogeneous_ne_zero n) + +end +end CriticalStrip.Diagram + +namespace CriticalStrip +noncomputable section +open Set Polynomial +open scoped BigOperators Classical + +lemma MonicProblem.eval_c {n : ℕ} (hn : 1≤n) {g : Polynomial ℝ} + (hg : MonicProblem n g) : g.eval c=(2*C)^n := by + obtain ⟨g₀,hg₀,hnext⟩:=Diagram.nextScalar_homogeneous hn + have heq : g=g₀ := (homogeneous_monic_unique n hn).unique hg hg₀ + subst g₀ + apply Complex.ofReal_injective + have hh:=congrArg (Polynomial.eval (c:ℂ)) hnext + rw [Diagram.nextScalar_eval,Diagram.scalarValue_snoc,←Diagram.c_eq_critical] at hh + have hflat:=Diagram.scalarValue_flat (RingHom.id ℂ) (fun _ : Fin n => (Diagram.C:ℂ)) + simp only [RingHom.id_apply] at hflat + rw [hflat] at hh + simp only [Finset.prod_const,Finset.card_univ,Fintype.card_fin, + Polynomial.eval_mul,Polynomial.eval_C,Polynomial.eval_map] at hh + have hm : Polynomial.eval₂ Complex.ofRealHom (Diagram.c:ℂ) g = (↑(g.eval (c:ℝ)):ℂ) := by + rw [Diagram.c_eq_critical] + exact Polynomial.eval₂_at_apply Complex.ofRealHom c + rw [hm] at hh + have hv := mul_left_cancel₀ (Diagram.scalarValue_homogeneous_ne_zero n) + (hh.symm.trans (mul_comm _ _)) + simpa only [Complex.ofReal_mul,Complex.ofReal_pow,Complex.ofReal_ofNat,two_mul,Diagram.C,Diagram.lambda,C,lambda,Complex.ofReal_add] using hv + + +theorem MonicProblem.eval_pos_Icc {n : ℕ} (hn : 1≤n) {g : Polynomial ℝ} + (hg : MonicProblem n g) {x : ℝ} (hx : x∈Icc c C) : 0 (C:ℂ)) (x:ℂ))=(y:ℂ) := by + by_cases hn : n=0 + · subst n + refine ⟨1,by norm_num,?_⟩ + have he : (Fin.snoc (fun _ : Fin 0 => (C:ℂ)) (x:ℂ) : Fin 1 → ℂ)=fun _ => (x:ℂ) := by + funext i; fin_cases i; rfl + rw [he,scalarValue_one,Complex.ofReal_one] + obtain ⟨p,hp,he⟩:=scalarValue_homogeneous_positive n + obtain ⟨g,hg,hnext⟩:=nextScalar_homogeneous (by omega : 1≤n) + refine ⟨p*g.eval x,mul_pos hp (hg.eval_pos_Icc (by omega) (by simpa only [c_eq_critical,C,lambda,CriticalStrip.C,CriticalStrip.lambda] using hx)),?_⟩ + have hh:=congrArg (Polynomial.eval (x:ℂ)) hnext + have hm : Polynomial.eval₂ Complex.ofRealHom (x:ℂ) g = (↑(g.eval x):ℂ) := + Polynomial.eval₂_at_apply Complex.ofRealHom x + rw [nextScalar_eval,Polynomial.eval_mul,Polynomial.eval_C,he,Polynomial.eval_map,hm] at hh + exact hh.trans (Complex.ofReal_mul _ _).symm + +lemma scalarValue_deformation_ne_zero (n : ℕ) {x : ℝ} (hx : x∈Icc c C) : + scalarValue (RingHom.id ℂ) (Fin.snoc (fun _ : Fin n => (C:ℂ)) (x:ℂ))≠0 := by + obtain ⟨y,hy,he⟩:=scalarValue_deformation_positive n hx + rw [he] + exact_mod_cast hy.ne' + +lemma cosine_deformation {u : ℝ} (hu : u∈Icc 0 lambda) : + Real.cos (2*u-3*lambda)∈Icc c C := by + have hl : 0 linarith [hu.1,hu.2] + rw [show 2*u-3*lambda= -(3*lambda-2*u) by ring,Real.cos_neg] + exact ⟨Real.cos_le_cos_of_nonneg_of_le_pi (by linarith) hπ.le harg.2, + Real.cos_le_cos_of_nonneg_of_le_pi hl.le (harg.2.trans hπ.le) harg.1⟩ + +end +end CriticalStrip.Diagram + +end OAI diff --git a/lean/OAI/Combinatorics/StripMass/NodalEmpty.lean b/lean/OAI/Combinatorics/StripMass/NodalEmpty.lean new file mode 100644 index 0000000000000000000000000000000000000000..3ac4749a61f0fd3c1d67bd9390349f9f9ec3aa62 --- /dev/null +++ b/lean/OAI/Combinatorics/StripMass/NodalEmpty.lean @@ -0,0 +1,535 @@ +import Mathlib +import OAI.Combinatorics.StripMass.ResidualParityCoefficients + +namespace OAI + +/-! Critical honeycomb strip paths, polynomial identities and crossing mass. -/ + + + +namespace CriticalStrip.Diagram +noncomputable section +open scoped Classical + +lemma scalarValue_snoc {K:Type*} [CommRing K] (f:ℂ →+* K) {n:ℕ} + (a:Fin n → K) (z:K) : scalarValue f (Fin.snoc a z)=scalarValue f (Fin.cons z a) := by + rw [Fin.snoc_eq_cons_rotate] + exact scalarValue_permute f _ (finRotate (n+1)) + +lemma rationalVacuum_empty (n:ℕ) : rationalVacuum n (empty n)=spectralNormalization n := by + simp [rationalVacuum,normalizedVacuum,attachEmpty] + +lemma rationalNodalPolynomial_empty (n:ℕ) : + rationalNodalPolynomial n (empty (n+1))= + firstScalarHom (algebraMap ℂ (SpectralField n)) spectralA + (scalarPolynomial (n+1) d rho (by exact_mod_cast d_ne_zero)) := by + let Q:=firstScalarHom (algebraMap ℂ (SpectralField n)) spectralA + (scalarPolynomial (n+1) d rho (by exact_mod_cast d_ne_zero)) + have htop:Q.coeff n=spectralNormalization n := by + rw [show Q.coeff n=_ from scalarPolynomial_first_top_continuation _ _ _ _ _ _,scalarPolynomial_eval_spectral] + have hp:(rationalNodalPolynomial n (empty (n+1))).coeff n=spectralNormalization n := by + rw [←Pairing.padTop_empty,rationalNodalPolynomial_leading,rationalVacuum_empty] + apply Polynomial.eq_of_degree_sub_lt_of_eval_index_eq Finset.univ (deletionBeta_injective n).injOn + · simp only [Finset.card_univ,Fintype.card_fin] + apply (Polynomial.degree_lt_iff_coeff_zero _ _).mpr + intro k hk + rw [Polynomial.coeff_sub] + by_cases he:k=n + · subst k; exact sub_eq_zero.mpr (hp.trans htop.symm) + · have hkn:nliftSpectral n (spectralA i)))=_ + have hc:(liftSpectral n).comp (algebraMap ℂ (SpectralField n))=algebraMap ℂ (SpectralField (n+1)) := by + ext z; exact liftSpectral_const n z + rw [hc] + simp only [liftSpectral_spectralA] + rw [←scalarValue_snoc] + have hs:Fin.snoc (fun i:Fin n =>spectralA i.castSucc) (spectralA (Fin.last n))=spectralA := by + funext i; induction i using Fin.lastCases <;> simp + rw [hs] + exact scalarPolynomial_eval_spectral (n+1) + + + + + + + +lemma stationary_eq_empty_mul_normalized {K:Type*} [Field K] {n:ℕ} + (w:Fin n → Weights K) (hw:VacuumRegular w) (v:Pairing n → K) + (h: (column w).mulVec v=v) : v=fun p =>v (empty n)*normalizedVacuum w p := by + let u:=v+(1-v (empty n)) • normalizedVacuum w + have hu:IsNormalizedStationary w u := by + constructor + · simp [u,normalizedVacuum,attachEmpty] + · simp only [u,Matrix.mulVec_add,Matrix.mulVec_smul,h,(normalizedVacuum_stationary w hw).2] + have hh:=normalizedVacuum_unique w hw u hu + funext p + have he:=congrFun hh p + change v p+(1-v (empty n))*normalizedVacuum w p=normalizedVacuum w p at he + linear_combination he + +lemma interpolant_eq_vacuum_of_residual {n:ℕ} (h:∀p,rationalInterpolationResidual n p=0) : + rationalInterpolant n=rationalVacuum (n+1) := by + have hs:(column (spectralWeights (n+1))).mulVec (rationalInterpolant n)=rationalInterpolant n := by + funext p + have hh:=h p + unfold rationalInterpolationResidual at hh + exact sub_eq_zero.mp ((mul_eq_zero.mp hh).resolve_left + (Finset.prod_ne_zero_iff.mpr (fun i _ =>rowDenominator_map_ne_zero i))) + have he:=stationary_eq_empty_mul_normalized (spectralWeights (n+1)) (spectral_regular (n+1)) + (rationalInterpolant n) hs + simp only [rationalInterpolant_empty] at he ⊢ + exact he + +lemma rationalInterpolationResidual_empty (n:ℕ) : rationalInterpolationResidual n (empty (n+1))=0 := by + simp only [rationalInterpolationResidual,column_mulVec_empty,sub_self,mul_zero] + +lemma Pairing.exists_earlier_occupied {n:ℕ} (p:Pairing (n+1)) (hp:p≠empty (n+1)) : + ∃i:Fin n,p.Occupied i.castSucc := by + have hn:p.val.Nonempty := by + by_contra h + apply hp + apply Subtype.ext + exact Finset.not_nonempty_iff_eq_empty.mp h + obtain ⟨⟨a,b⟩,hab⟩:=hn + have hlt:a2*n) + eval_P : ∀p,evalLaurent (lastLaurent p (P p))=rationalVacuum (n+1) p + +namespace VacuumPolynomialData +variable {n:ℕ} (D:VacuumPolynomialData n) +def W : Pairing (n+1) → Laurent (n+1) := fun p =>lastLaurent p (D.P p) +lemma degree : LastDegree n D.P := + LastDegree.of_map _ (IsFractionRing.injective (SpectralRing n) (SpectralField n)) + (by simpa only [D.map_P] using rationalNodalPolynomial_degree n) +lemma box (p:Pairing (n+1)) : LaurentBox (D.W p) (fun _ =>2*n) := + lastLaurent_box p (D.P p) (D.box_P p) (D.degree p) +include D in +lemma interpolant : ∀p,rationalInterpolant n p=rationalVacuum (n+1) p := by + intro p + rw [←lastLaurent_map p (D.P p) (D.map_P p)] + exact D.eval_P p +end VacuumPolynomialData + +lemma spectralNormalization_zero : spectralNormalization 0=1 := by + rw [←scalarPolynomial_eval_spectral] + exact scalarValue_zero _ _ +lemma rationalVacuum_zero (p:Pairing 0) : rationalVacuum 0 p=1 := by + have hp:p=empty 0 := (p.eq_empty_iff).mpr (fun i =>Fin.elim0 i) + rw [hp,rationalVacuum_empty,spectralNormalization_zero] +lemma Pairing.one_eq_empty (p:Pairing 1) : p=empty 1 := by + apply p.eq_empty_iff.mpr + rintro i ⟨j,hj⟩ + have he:j=i := Subsingleton.elim _ _ + exact p.adj_irrefl i (he ▸ hj) +lemma rationalVacuum_one (p:Pairing 1) : rationalVacuum 1 p=1 := by + rw [p.one_eq_empty,rationalVacuum_empty,←scalarPolynomial_eval_spectral] + convert scalarValue_one (algebraMap ℂ (SpectralField 1)) (spectralA 0) using 1 + congr 2 + funext i + congr 1 + exact Subsingleton.elim _ _ + +lemma rationalNodalPolynomial_zero (p:Pairing 1) : rationalNodalPolynomial 0 p=1 := by + rw [p.one_eq_empty] + simp [rationalNodalPolynomial,rationalVacuum_zero,Lagrange.nodal,Lagrange.interpolate] + +noncomputable def vacuumData_zero : VacuumPolynomialData 0 where + P := fun _ =>1 + map_P := fun p =>by rw [Polynomial.map_one,rationalNodalPolynomial_zero] + box_P := fun p =>by + convert (PolynomialBox.one (n:=0)) using 1 + eval_P := fun p =>by + rw [rationalVacuum_one] + simp [lastLaurent,p.one_eq_empty,evalLaurent] + + + + + + + + + +theorem residual_saturation {n:ℕ} + (P:Pairing (n+2) → Polynomial (Laurent (n+1))) + (hP:∀p,(P p).map (algebraMap (SpectralRing (n+1)) (SpectralField (n+1)))=rationalNodalPolynomial (n+1) p) + (bP:∀p,PolynomialBox (P p) (fun _ =>2*(n+1))) + (hflat:∀(b:Bool) (z:Fin (n+2) → SpectralField (n+2)) (hz:∀k,z k≠0), + z 0=(if b then constF (n+2) phase^3 else 1) → ∀p, + torusEvaluation z hz (laurentResidual (fun q =>lastLaurent q (P q)) p)=0) + (hpair:∀(h2:2≤n+1) (s:ℕ),s=2 ∨ s=3 → + ∀(z:Fin (n+2) → SpectralField (n+2)) (hz:∀k,z k≠0), + z (⟨1,by omega⟩:Fin (n+1)).castSucc=constF (n+2) phase^s*z (⟨0,by omega⟩:Fin (n+1)).castSucc → ∀p, + torusEvaluation z hz (laurentResidual (fun q =>lastLaurent q (P q)) p)=0) : + ∀p,rationalInterpolationResidual (n+1) p=0 := by + have hd:LastDegree (n+1) P := + LastDegree.of_map _ (IsFractionRing.injective (SpectralRing (n+1)) (SpectralField (n+1))) + (by simpa only [hP] using rationalNodalPolynomial_degree (n+1)) + have hb:∀p,LaurentBox (laurentResidual (fun q =>lastLaurent q (P q)) p) (fun _ =>2*((n+1)+1)) := by + intro p + convert laurentResidual_box (fun q =>lastLaurent q (P q)) (2*(n+1)) + (fun q =>lastLaurent_box q (P q) (bP q) (hd q)) p using 1 + intro p + by_cases hp:p=empty (n+2) + · subst p; exact rationalInterpolationResidual_empty _ + · obtain ⟨i,hi⟩:=p.exists_earlier_occupied hp + exact residual_zero_of_root_grid P hP hb p i hi + (residual_root_grid_of_positive P hP i p hi (fun j b =>residual_positive_roots P hP hflat hpair i j b p)) + + + + + + + +lemma LastMatrix.lastValue_map {K L:Type*} [CommRing K] [CommRing L] {n m:ℕ} + {M:Matrix (Pairing (m+1)) (Pairing (n+1)) K} (hM:LastMatrix M) + (f:K →+* L) (b s:L) (P:Pairing (n+1) → Polynomial K) : + CriticalStrip.Diagram.lastValue f b s (matrixPolynomial M P)=(M.map f).mulVec (CriticalStrip.Diagram.lastValue f b s P) := by + funext p + simp only [CriticalStrip.Diagram.lastValue,matrixPolynomial,Polynomial.eval₂_finsetSum, + Polynomial.eval₂_mul,Polynomial.eval₂_C,Matrix.mulVec,dotProduct,Matrix.map_apply] + split_ifs with hp + · rw [Finset.mul_sum] + apply Finset.sum_congr rfl + intro q _ + by_cases hq:q.Occupied (Fin.last n) + · simp only [hq,ite_true]; ring + · rw [hM p q (by simp [hp,hq]),map_zero,zero_mul,mul_zero] + simp + · apply Finset.sum_congr rfl + intro q _ + by_cases hq:q.Occupied (Fin.last n) + · rw [hM p q (by simp [hp,hq]),map_zero,zero_mul,zero_mul] + · simp [hq] + +lemma pairEvaluation_lastLaurent {n:ℕ} (s:ℕ) (p:Pairing (n+3)) (P:Polynomial (Laurent (n+2))) : + pairEvaluation (n+1) s (lastLaurent p P)= + lastValue (liftSpectral (n+1)) (spectralA (Fin.last (n+1))) (torusSin (variableF (Fin.last (n+1)))) + (fun _ : Pairing (n+3) =>P.map (pairEvaluation n s).toRingHom) p := by + have h:=torusEvaluation_free_lastLaurent (pairPoint n s) (pairPoint_ne_zero n s) p P + simpa only [freePoint_pair,pairEvaluation,lastValue,ite_mul,one_mul] using h + +lemma freePoint_delete (n:ℕ) : freePoint (deletePoint n)=deletePoint (n+1) := by + funext i + induction i using Fin.lastCases with + | last => simp only [freePoint,Fin.snoc_last,deletePoint]; rfl + | cast i => simp only [freePoint,Fin.snoc_castSucc,deletePoint,liftSpectral_variable]; rfl + +lemma freePoint_merge (n:ℕ) : freePoint (mergePoint n)=mergePoint (n+1) := by + rw [mergePoint,freePoint_cons,freePoint_delete] + simp only [map_mul,liftSpectral_const,liftSpectral_variable,Fin.castSucc_zero] + rfl + +lemma deleteEvaluation_lastLaurent {n:ℕ} (p:Pairing (n+1)) (P:Polynomial (Laurent n)) : + deleteEvaluation (n+1) (lastLaurent p P)= + lastValue (liftSpectral (n+1)) (spectralA (Fin.last (n+1))) (torusSin (variableF (Fin.last (n+1)))) + (fun _ : Pairing (n+1) =>P.map (deleteEvaluation n).toRingHom) p := by + have h:=torusEvaluation_free_lastLaurent (deletePoint n) (fun i =>variableF_ne_zero i.succ) p P + simpa only [freePoint_delete,deleteEvaluation,lastValue,ite_mul,one_mul] using h + +lemma mergeEvaluation_lastLaurent {n:ℕ} (p:Pairing (n+2)) (P:Polynomial (Laurent (n+1))) : + mergeEvaluation (n+1) (lastLaurent p P)= + lastValue (liftSpectral (n+1)) (spectralA (Fin.last (n+1))) (torusSin (variableF (Fin.last (n+1)))) + (fun _ : Pairing (n+2) =>P.map (mergeEvaluation n).toRingHom) p := by + have h:=torusEvaluation_free_lastLaurent (mergePoint n) (mergePoint_ne_zero n) p P + simpa only [freePoint_merge,mergeEvaluation,lastValue,ite_mul,one_mul] using h + +lemma functionMatrix_map_hom {K L:Type*} [CommRing K] [CommRing L] {α β:Type*} + (f:K →+* L) (g:α → β) : (functionMatrix (K:=K) g).map f=functionMatrix (K:=L) g := by + ext p q + simp only [Matrix.map_apply,functionMatrix,optionMatrix] + split_ifs <;> simp + +lemma deletionMap_map {n m k:ℕ} (f:SpectralField m →+* SpectralField k) (r:ℕ) (hr:r+2≤n+2) : + (deletionMap (m:=m) r hr).map f=deletionMap (m:=k) r hr := by + let E₁ : Matrix (Pairing (n+2)) (Pairing (n+1)) (SpectralField m) := + functionMatrix (Pairing.map (Fin.succAboveOrderEmb ⟨r+1,by omega⟩)) + let E₀ : Matrix (Pairing (n+1)) (Pairing n) (SpectralField m) := + functionMatrix (Pairing.map (Fin.succAboveOrderEmb ⟨r,by omega⟩)) + let S := localR (PartialColumn.rowPosition r hr) (deletionWeights : Weights (SpectralField m)) + have hw:(deletionWeights:Weights (SpectralField m)).map f=deletionWeights := by simp [Weights.map,deletionWeights] + calc + _ = S.map f * (E₁*E₀).map f := Matrix.map_mul + _ = S.map f * (E₁.map f*E₀.map f) := + congrArg (fun M => S.map f * M) (Matrix.map_mul (L := E₁) (M := E₀) (f := f)) + _ = _ := by + dsimp only [S,E₁,E₀] + rw [localR_map_hom,functionMatrix_map_hom,functionMatrix_map_hom,hw] + rfl + +lemma mergeMap_lift {n m:ℕ} (r:ℕ) (hr:r+2≤n+1) : + (mergeMap (m:=m) r hr).map (liftSpectral m)=mergeMap (m:=m+1) r hr := by + let E : Matrix (Pairing (n+1)) (Pairing n) (SpectralField m) := + functionMatrix (Pairing.map (Fin.succAboveOrderEmb ⟨r+1,by omega⟩)) + let S := localR (PartialColumn.rowPosition r hr) (mergeWeights (constF m phase)) + have hw:(mergeWeights (constF m phase)).map (liftSpectral m)=mergeWeights (constF (m+1) phase) := by + simp [Weights.map,mergeWeights,map_div₀,liftSpectral_const] + calc + _ = S.map (liftSpectral m) * E.map (liftSpectral m) := Matrix.map_mul + _ = _ := by + dsimp only [S,E] + rw [localR_map_hom,functionMatrix_map_hom,hw] + rfl + +lemma liftSpectral_fcos {n:ℕ} (i:Fin n) (k:ℤ) : + liftSpectral n (fcos i k)=fcos i.castSucc k := by + simp only [fcos_eq,torusCos] + simp only [map_div₀,map_add,map_mul,map_pow,map_inv₀,liftSpectral_const,liftSpectral_variable,map_ofNat] + +lemma deletePairPolynomial_free (n:ℕ) : + (deletePairPolynomial n).eval₂ (liftSpectral (n+1)) (spectralA (Fin.last (n+1)))=deletePairScalar (n+1) := by + simp only [deletePairPolynomial,Polynomial.eval₂_mul,Polynomial.eval₂_C,Polynomial.eval₂_sub,Polynomial.eval₂_X] + unfold deletePairScalar + simp only [map_mul,map_prod,map_add,map_sub,liftSpectral_fcos,liftSpectral_const,Fin.castSucc_zero,Fin.prod_univ_castSucc] + have he:fcos (Fin.last (n+1)) (-3)=spectralA (Fin.last (n+1)) := by + have h:=phaseCosine (Fin.last (n+1)) 0 + norm_num only at h + simpa only [zpow_zero,one_mul,spectralA] using h.symm + simp only [Fin.succ_last,he,mul_assoc] + rfl + +lemma mergePairPolynomial_free (n:ℕ) : + (mergePairPolynomial n).eval₂ (liftSpectral (n+1)) (spectralA (Fin.last (n+1)))=mergePairScalar (n+1) := by + simp only [mergePairPolynomial,Polynomial.eval₂_mul,Polynomial.eval₂_C,Polynomial.eval₂_add,Polynomial.eval₂_X] + unfold mergePairScalar + simp only [map_mul,map_prod,map_add,liftSpectral_fcos,liftSpectral_const,Fin.castSucc_zero,Fin.prod_univ_castSucc] + have he:fcos (Fin.last (n+1)) (-3)=spectralA (Fin.last (n+1)) := by + have h:=phaseCosine (Fin.last (n+1)) 0 + norm_num only at h + simpa only [zpow_zero,one_mul,spectralA] using h.symm + simp only [Fin.succ_last,he,mul_assoc] + rfl + + + + + + + +lemma pairPoint_weights {n s:ℕ} (hs:s≤3) : + (fun i =>torusWeights (constF (n+1) phase^3/pairPoint n s i))=pairEarlierWeights n s := + funext (fun i =>congrArg torusWeights (pairArgument hs i)) + +lemma rationalAt_pair_vacuum {n s:ℕ} (hs:s≤3) (p:Pairing (n+2)) : + RationalAt (pairEvaluation n s).toRingHom (rationalVacuum (n+2) p) + (scalarValue (algebraMap ℂ (SpectralField (n+1))) (pairCosines n s)* + normalizedVacuum (pairEarlierWeights n s) p) := by + have h:=rationalAt_torusVacuum (pairPoint n s) (pairPoint_ne_zero n s) + (pairEarlier_L hs) (by rw [pairPoint_weights hs]; exact pairEarlier_regular n s) p + rw [pairPoint_weights hs,show (fun i =>torusCos ((pairPoint n s i)^2/constF (n+1) phase^3))= + pairCosines n s from funext (fun i =>pairPoint_cosine i)] at h + exact h + +lemma deleteEvaluation_vacuum {n:ℕ} (W:Pairing n → Laurent n) + (hW:∀p,evalLaurent (W p)=rationalVacuum n p) (p:Pairing n) : + deleteEvaluation n (W p)=scalarValue (algebraMap ℂ (SpectralField (n+1))) + (fun i:Fin n =>fcos i.succ (-3))*normalizedVacuum (deleteWeights n) p := by + have h:=torusEvaluation_vacuum W hW (deletePoint n) (fun i =>variableF_ne_zero i.succ) + (fun i =>torusL_phaseRow_ne_zero i.succ 3 (by omega)) (deleteWeights_regular n) p + rw [deletePoint_cosines] at h + exact h + +lemma mergeEvaluation_vacuum {n:ℕ} (W:Pairing (n+1) → Laurent (n+1)) + (hW:∀p,evalLaurent (W p)=rationalVacuum (n+1) p) (p:Pairing (n+1)) : + mergeEvaluation n (W p)=scalarValue (algebraMap ℂ (SpectralField (n+1))) + (Fin.cons (fcos 0 (-1)) (fun i:Fin n =>fcos i.succ (-3)))*normalizedVacuum (mergeNewWeights n) p := by + have h:=torusEvaluation_vacuum W hW (mergePoint n) (mergePoint_ne_zero n) + (mergePoint_L n) (by rw [mergePoint_weights]; exact mergeNewWeights_regular n) p + rw [mergePoint_cosines,mergePoint_weights] at h + exact h + +lemma deletePairCandidate_value {n:ℕ} + (W:Pairing (n+1) → Laurent (n+1)) (hW:∀p,evalLaurent (W p)=rationalVacuum (n+1) p) + (Q:Pairing (n+1) → Polynomial (Laurent n)) + (hQ:∀p,(Q p).map (algebraMap (SpectralRing n) (SpectralField n))=rationalNodalPolynomial n p) + (hprev:∀p,evalLaurent (lastLaurent p (Q p))=rationalVacuum (n+1) p) + (P:Pairing (n+3) → Polynomial (Laurent (n+2))) + (hP:∀p,(P p).map (algebraMap (SpectralRing (n+2)) (SpectralField (n+2)))=rationalNodalPolynomial (n+2) p) + (p:Pairing (n+3)) : + pairEvaluation (n+1) 3 (lastLaurent p (P p))= + scalarValue (algebraMap ℂ (SpectralField (n+2))) (pairCosines (n+1) 3)* + normalizedVacuum (pairEarlierWeights (n+1) 3) p := by + rw [pairEvaluation_lastLaurent] + change lastValue (liftSpectral (n+1)) (spectralA (Fin.last (n+1))) (torusSin (variableF (Fin.last (n+1)))) + (fun p =>(P p).map (pairEvaluation n 3).toRingHom) p=_ + rw [rationalNodalPolynomial_pair_delete W hW Q hQ hprev P hP,lastValue_mul_poly_map, + (deletionMap_last 0 (show 2≤n+2 by omega)).lastValue_map,deletePairPolynomial_free,deletionMap_map] + have he:lastValue (liftSpectral (n+1)) (spectralA (Fin.last (n+1))) (torusSin (variableF (Fin.last (n+1)))) + (fun q =>(Q q).map (deleteEvaluation n).toRingHom)= + fun q =>deleteEvaluation (n+1) (lastLaurent q (Q q)) := by + funext q + exact (deleteEvaluation_lastLaurent q (Q q)).symm + rw [he] + simp_rw [deleteEvaluation_vacuum _ hprev] + change deletePairScalar (n+1)*((deletionMap 0 (show 2≤n+3 by omega)).mulVec + (scalarValue (algebraMap ℂ (SpectralField (n+2))) (fun i:Fin (n+1) =>fcos i.succ (-3)) • normalizedVacuum (deleteWeights (n+1))) p)=_ + rw [Matrix.mulVec_smul,scalar_pair_delete,normalizedVacuum_pair_delete] + simp only [Pi.smul_apply,smul_eq_mul] + ring + +lemma mergePairCandidate_value {n:ℕ} + (W:Pairing (n+1) → Laurent (n+1)) (hW:∀p,evalLaurent (W p)=rationalVacuum (n+1) p) + (Q:Pairing (n+2) → Polynomial (Laurent (n+1))) + (hQ:∀p,(Q p).map (algebraMap (SpectralRing (n+1)) (SpectralField (n+1)))=rationalNodalPolynomial (n+1) p) + (hprev:∀p,evalLaurent (lastLaurent p (Q p))=rationalVacuum (n+2) p) + (P:Pairing (n+3) → Polynomial (Laurent (n+2))) + (hP:∀p,(P p).map (algebraMap (SpectralRing (n+2)) (SpectralField (n+2)))=rationalNodalPolynomial (n+2) p) + (p:Pairing (n+3)) : + pairEvaluation (n+1) 2 (lastLaurent p (P p))= + scalarValue (algebraMap ℂ (SpectralField (n+2))) (pairCosines (n+1) 2)* + normalizedVacuum (pairEarlierWeights (n+1) 2) p := by + rw [pairEvaluation_lastLaurent] + change lastValue (liftSpectral (n+1)) (spectralA (Fin.last (n+1))) (torusSin (variableF (Fin.last (n+1)))) + (fun p =>(P p).map (pairEvaluation n 2).toRingHom) p=_ + rw [rationalNodalPolynomial_pair_merge W hW Q hQ hprev P hP,lastValue_mul_poly_map, + (mergeMap_last 0 (show 2≤n+2 by omega)).lastValue_map,mergePairPolynomial_free,mergeMap_lift] + have he:lastValue (liftSpectral (n+1)) (spectralA (Fin.last (n+1))) (torusSin (variableF (Fin.last (n+1)))) + (fun q =>(Q q).map (mergeEvaluation n).toRingHom)= + fun q =>mergeEvaluation (n+1) (lastLaurent q (Q q)) := by + funext q + exact (mergeEvaluation_lastLaurent q (Q q)).symm + rw [he] + simp_rw [mergeEvaluation_vacuum _ hprev] + change mergePairScalar (n+1)*((mergeMap 0 (show 2≤n+3 by omega)).mulVec + (scalarValue (algebraMap ℂ (SpectralField (n+2))) + (Fin.cons (fcos 0 (-1)) (fun i:Fin (n+1) =>fcos i.succ (-3))) • normalizedVacuum (mergeNewWeights (n+1))) p)=_ + rw [Matrix.mulVec_smul,scalar_pair_merge,normalizedVacuum_pair_merge] + simp only [Pi.smul_apply,smul_eq_mul] + ring + + + +theorem residual_pair_delete {n:ℕ} + (W:Pairing (n+1) → Laurent (n+1)) (hW:∀p,evalLaurent (W p)=rationalVacuum (n+1) p) + (Q:Pairing (n+1) → Polynomial (Laurent n)) + (hQ:∀p,(Q p).map (algebraMap (SpectralRing n) (SpectralField n))=rationalNodalPolynomial n p) + (hprev:∀p,evalLaurent (lastLaurent p (Q p))=rationalVacuum (n+1) p) + (P:Pairing (n+3) → Polynomial (Laurent (n+2))) + (hP:∀p,(P p).map (algebraMap (SpectralRing (n+2)) (SpectralField (n+2)))=rationalNodalPolynomial (n+2) p) + (p:Pairing (n+3)) : + pairEvaluation (n+1) 3 (laurentResidual (fun q =>lastLaurent q (P q)) p)=0 := by + apply residual_specialization_zero + intro q + rw [deletePairCandidate_value W hW Q hQ hprev P hP] + exact rationalAt_pair_vacuum (by omega) q + +theorem residual_pair_merge {n:ℕ} + (W:Pairing (n+1) → Laurent (n+1)) (hW:∀p,evalLaurent (W p)=rationalVacuum (n+1) p) + (Q:Pairing (n+2) → Polynomial (Laurent (n+1))) + (hQ:∀p,(Q p).map (algebraMap (SpectralRing (n+1)) (SpectralField (n+1)))=rationalNodalPolynomial (n+1) p) + (hprev:∀p,evalLaurent (lastLaurent p (Q p))=rationalVacuum (n+2) p) + (P:Pairing (n+3) → Polynomial (Laurent (n+2))) + (hP:∀p,(P p).map (algebraMap (SpectralRing (n+2)) (SpectralField (n+2)))=rationalNodalPolynomial (n+2) p) + (p:Pairing (n+3)) : + pairEvaluation (n+1) 2 (laurentResidual (fun q =>lastLaurent q (P q)) p)=0 := by + apply residual_specialization_zero + intro q + rw [mergePairCandidate_value W hW Q hQ hprev P hP] + exact rationalAt_pair_vacuum (by omega) q + + + + + + +lemma residual_flat_universal {n:ℕ} + (W:Pairing n → Laurent n) (hW:∀p,evalLaurent (W p)=rationalVacuum n p) + (D:VacuumPolynomialData n) + (P:Pairing (n+2) → Polynomial (Laurent (n+1))) + (hP:∀p,(P p).map (algebraMap (SpectralRing (n+1)) (SpectralField (n+1)))=rationalNodalPolynomial (n+1) p) + (b:Bool) (z:Fin (n+2) → SpectralField (n+2)) (hz:∀k,z k≠0) + (h:z 0=(if b then constF (n+2) phase^3 else 1)) (p:Pairing (n+2)) : + torusEvaluation z hz (laurentResidual (fun q =>lastLaurent q (P q)) p)=0 := by + cases b + · exact firstFlatEvaluation_zero_universal _ (residual_firstFlat D.interpolant P hP p) z hz h + · exact firstThreeEvaluation_zero_universal _ (residual_firstThree W hW D.interpolant P hP p) z hz h + +lemma vacuumData_one_exists : Nonempty (VacuumPolynomialData 1) := by + let W:Pairing 0 → Laurent 0:=fun _ =>1 + have hW:∀p,evalLaurent (W p)=rationalVacuum 0 p := by + intro p; rw [rationalVacuum_zero]; exact map_one _ + have bW:∀p,LaurentBox (W p) (fun _ =>2*0-2) := by + intro p; exact LaurentBox.one + let D:=vacuumData_zero + choose P hP bP using rationalNodalPolynomial_laurent_box W D.W hW D.eval_P bW D.box + have hs:∀p,rationalInterpolationResidual 1 p=0 := + residual_saturation P hP (by simpa using bP) (residual_flat_universal W hW D P hP) + (by intro h2; omega) + have he:=interpolant_eq_vacuum_of_residual hs + exact ⟨⟨P,hP,by simpa using bP,fun p =>by rw [lastLaurent_map p (P p) (hP p)]; exact congrFun he p⟩⟩ + +lemma vacuumData_step_exists {n:ℕ} (D:VacuumPolynomialData n) (E:VacuumPolynomialData (n+1)) : + Nonempty (VacuumPolynomialData (n+2)) := by + have bD:∀p,LaurentBox (D.W p) (fun _ =>2*(n+1)-2) := by + simpa [Nat.mul_add] using D.box + choose P hP bP using rationalNodalPolynomial_laurent_box D.W E.W D.eval_P E.eval_P bD E.box + have hpair : ∀(h2:2≤(n+1)+1) (s:ℕ),s=2 ∨ s=3 → + ∀(z:Fin ((n+1)+2) → SpectralField ((n+1)+2)) (hz:∀k,z k≠0), + z (⟨1,by omega⟩:Fin ((n+1)+1)).castSucc=constF ((n+1)+2) phase^s*z (⟨0,by omega⟩:Fin ((n+1)+1)).castSucc → ∀p, + torusEvaluation z hz (laurentResidual (fun q =>lastLaurent q (P q)) p)=0 := by + intro h2 s hs z hz hh p + rcases hs with rfl|rfl + · exact pairEvaluation_zero_universal 2 _ + (residual_pair_merge D.W D.eval_P E.P E.map_P E.eval_P P hP p) z hz hh + · exact pairEvaluation_zero_universal 3 _ + (residual_pair_delete D.W D.eval_P D.P D.map_P D.eval_P P hP p) z hz hh + have hs:∀p,rationalInterpolationResidual (n+2) p=0 := + residual_saturation P hP (by simpa [Nat.mul_add] using bP) + (residual_flat_universal D.W D.eval_P E P hP) hpair + have he:=interpolant_eq_vacuum_of_residual hs + exact ⟨⟨P,hP,by simpa [Nat.mul_add] using bP, + fun p =>by rw [lastLaurent_map p (P p) (hP p)]; exact congrFun he p⟩⟩ + +theorem vacuumData_exists : ∀n,Nonempty (VacuumPolynomialData n) := by + intro n + induction n using Nat.twoStepInduction with + | zero => exact ⟨vacuumData_zero⟩ + | one => exact vacuumData_one_exists + | more n hn hn1 => + obtain ⟨D⟩:=hn + obtain ⟨E⟩:=hn1 + exact vacuumData_step_exists D E + +noncomputable def vacuumData (n:ℕ) : VacuumPolynomialData n := Classical.choice (vacuumData_exists n) + + + +theorem vacuum_interpolation_stationary : ∀n p,rationalInterpolationResidual n p=0 := by + intro n p + have h: rationalInterpolant n=rationalVacuum (n+1) := funext (vacuumData n).interpolant + simp only [rationalInterpolationResidual,h,rationalVacuum_stationary,sub_self,mul_zero] + +end +end CriticalStrip.Diagram + +end OAI diff --git a/lean/OAI/Combinatorics/StripMass/NodalExchange.lean b/lean/OAI/Combinatorics/StripMass/NodalExchange.lean new file mode 100644 index 0000000000000000000000000000000000000000..67db8d1c94fe8e4ed07edde20462004a57cff5e3 --- /dev/null +++ b/lean/OAI/Combinatorics/StripMass/NodalExchange.lean @@ -0,0 +1,539 @@ +import Mathlib +import OAI.Combinatorics.StripMass.CramerBounds + +namespace OAI + +/-! Critical honeycomb strip paths, polynomial identities and crossing mass. -/ + + + +namespace CriticalStrip.Diagram +noncomputable section +open scoped Classical + +lemma topPerm_swap {n : ℕ} (a b : Fin n) : + topPerm (Equiv.swap a b)=Equiv.swap a.castSucc b.castSucc := by + apply Equiv.ext + intro j + induction j using Fin.lastCases with + | last => simp [Equiv.swap_apply_def,Ne.symm (Fin.castSucc_ne_last a),Ne.symm (Fin.castSucc_ne_last b)] + | cast j => + simp only [topPerm_cast,Equiv.swap_apply_def,Fin.castSucc_inj] + split_ifs <;> rfl + +lemma rationalVacuum_exchange {n : ℕ} (r : ℕ) (hr : r+2≤n) + : let σ := Equiv.swap (⟨r,by omega⟩ : Fin n) ⟨r+1,by omega⟩; + rationalVacuum n = (localR (PartialColumn.rowPosition r hr) + (torusWeights (variableF ⟨r+1,by omega⟩ / variableF ⟨r,by omega⟩))).mulVec + (fun p => permSpectral σ (rationalVacuum n p)) := by + dsimp only + let σ := Equiv.swap (⟨r,by omega⟩ : Fin n) ⟨r+1,by omega⟩ + have hh (p : Pairing n) : permSpectral σ (rationalVacuum n p)= + spectralNormalization n * normalizedVacuum (fun i => spectralWeights n (σ i)) p := by + rw [rationalVacuum,map_mul,permSpectral_normalization,permSpectral_vacuum] + change rationalVacuum n = (localR (PartialColumn.rowPosition r hr) + (torusWeights (variableF ⟨r+1,by omega⟩ / variableF ⟨r,by omega⟩))).mulVec + (fun p => permSpectral σ (rationalVacuum n p)) + simp_rw [hh] + change spectralNormalization n • normalizedVacuum (spectralWeights n)= + (localR (PartialColumn.rowPosition r hr) + (torusWeights (variableF ⟨r+1,by omega⟩ / variableF ⟨r,by omega⟩))).mulVec + (spectralNormalization n • normalizedVacuum (fun i => spectralWeights n (σ i))) + rw [Matrix.mulVec_smul,←spectral_vacuum_exchange r hr] + +lemma nodalVacuum_exchange {n : ℕ} (r : ℕ) (hr : r+2≤n) (i : Fin n) + : let σ := Equiv.swap (⟨r,by omega⟩ : Fin n) ⟨r+1,by omega⟩; + nodalVacuum i = (localR (PartialColumn.rowPosition r hr).padTop + (torusWeights (variableF ⟨r+1,by omega⟩ / variableF ⟨r,by omega⟩))).mulVec + (fun p => permSpectral σ (nodalVacuum (σ i) p)) := by + dsimp only + let σ := Equiv.swap (⟨r,by omega⟩ : Fin n) ⟨r+1,by omega⟩ + let a : Fin n:=⟨r,by omega⟩ + let b : Fin n:=⟨r+1,by omega⟩ + let z : SpectralField n:=variableF b/variableF a + let x : Fin (n+1) → SpectralField n := + Fin.snoc (fun j => constF n phase^3/variableF j) (constF n phase^3/deletionNode i) + have xc (j : Fin n) : x j.castSucc=constF n phase^3/variableF j := by + simp only [x,Fin.snoc_castSucc] + have hw : (fun j => torusWeights (x j))=nodalWeights i := by + funext j + induction j using Fin.lastCases <;> simp [x,nodalWeights,spectralWeights] + have hp : (PartialColumn.rowPosition r (show r+2≤n+1 by omega))= + (PartialColumn.rowPosition r hr).padTop := rfl + have hswap : Equiv.swap (⟨r,by omega⟩ : Fin (n+1)) ⟨r+1,by omega⟩=topPerm σ := + (topPerm_swap a b).symm + have hs : σ (σ i)=i := Equiv.swap_apply_self a b i + have hreg := nodal_regular_reindex σ (σ i) + rw [hs] at hreg + have hx : z*x ⟨r+1,by omega⟩=x ⟨r,by omega⟩ := by + change z*x b.castSucc=x a.castSucc + rw [xc,xc] + dsimp only [z] + field_simp [variableF_ne_zero] + have hL (j : Fin n) : torusL (x j.castSucc)≠0 := by + rw [xc] + rw [←rowDenominator_map]; exact rowDenominator_map_ne_zero j + have H:=normalizedVacuum_torus_exchange r (show r+2≤n+1 by omega) x z + (div_ne_zero (variableF_ne_zero b) (variableF_ne_zero a)) + (by change x b.castSucc≠0; rw [xc]; exact div_ne_zero (pow_ne_zero _ (constF_phase_ne_zero n)) (variableF_ne_zero b)) + (torusL_ratio_ne_zero a b) (hL b) (hL a) hx + (by rw [hw]; exact nodal_regular i) + (by change VacuumRegular (fun j => (fun k => torusWeights (x k)) (Equiv.swap _ _ j)); + rw [hw,hswap]; exact hreg) + rw [hw,hswap,hp] at H + have hwpoint (j : Fin (n+1)) := congrFun hw j + simp_rw [hwpoint] at H + have hv (p : Pairing (n+1)) : permSpectral σ (nodalVacuum (σ i) p)= + nodalScalar i*normalizedVacuum (fun j => nodalWeights i (topPerm σ j)) p := by + rw [permSpectral_nodalVacuum,hs] + change nodalVacuum i = (localR (PartialColumn.rowPosition r hr).padTop + (torusWeights z)).mulVec (fun p => permSpectral σ (nodalVacuum (σ i) p)) + simp_rw [hv] + change nodalScalar i • normalizedVacuum (nodalWeights i)= + (localR (PartialColumn.rowPosition r hr).padTop (torusWeights z)).mulVec + (nodalScalar i • normalizedVacuum (fun j => nodalWeights i (topPerm σ j))) + rw [Matrix.mulVec_smul,←H] + +end + + + + + +noncomputable section +open scoped Classical +open Finset + +lemma localR_padTop_zero_last {K : Type*} [CommRing K] {n : ℕ} (a : Position n) + (w : Weights K) (p q : Pairing (n+1)) + (h : ¬ (q.Occupied (Fin.last n) ↔ p.Occupied (Fin.last n))) : + localR a.padTop w q p=0 := by + apply localR_zero_of_support a.padTop w p q (Fin.last n) _ _ h + · exact Ne.symm (Fin.castSucc_ne_last _) + · exact Ne.symm (Fin.castSucc_ne_last _) + +lemma lastPolynomial_unique {K : Type*} [Field K] {n : ℕ} + (P Q : Pairing (n+1) → Polynomial K) + (hP : LastDegree n P) (hQ : LastDegree n Q) + (v : Fin n → K) (hv : Function.Injective v) + (hlead : ∀ p : Pairing n, (P p.padTop).coeff n=(Q p.padTop).coeff n) + (hnode : ∀ p i, (P p).eval (v i)=(Q p).eval (v i)) : P=Q := by + funext p + apply Polynomial.eq_of_degree_sub_lt_of_eval_index_eq univ hv.injOn + · simp only [card_univ,Fintype.card_fin] + apply (Polynomial.degree_lt_iff_coeff_zero _ _).mpr + intro k hk + rw [Polynomial.coeff_sub] + by_cases hp : p.Occupied (Fin.last n) + · rw [hP p k (by simpa only [hp,ite_true] using hk), + hQ p k (by simpa only [hp,ite_true] using hk), sub_self] + · by_cases he : k=n + · subst k + have h:=hlead (p.restrict Fin.castSuccOrderEmb) + rw [Pairing.padTop_restrict p hp] at h + exact sub_eq_zero.mpr h + · rw [hP p k (by simp only [hp,ite_false]; omega), + hQ p k (by simp only [hp,ite_false]; omega),sub_self] + · intro i _ + exact hnode p i + + + +def nodalExchangePolynomial {n : ℕ} (r : ℕ) (hr : r+2≤n) + (p : Pairing (n+1)) : Polynomial (SpectralField n) := + ∑ q, Polynomial.C (localR (PartialColumn.rowPosition r hr).padTop + (torusWeights (variableF ⟨r+1,by omega⟩ / variableF ⟨r,by omega⟩)) p q) * + (rationalNodalPolynomial n q).map + (permSpectral (Equiv.swap ⟨r,by omega⟩ ⟨r+1,by omega⟩)) + +lemma nodalExchangePolynomial_coeff {n : ℕ} (r : ℕ) (hr : r+2≤n) + (p : Pairing (n+1)) (k : ℕ) : + (nodalExchangePolynomial r hr p).coeff k = + ∑ q, localR (PartialColumn.rowPosition r hr).padTop + (torusWeights (variableF ⟨r+1,by omega⟩ / variableF ⟨r,by omega⟩)) p q * + permSpectral (Equiv.swap ⟨r,by omega⟩ ⟨r+1,by omega⟩) + ((rationalNodalPolynomial n q).coeff k) := by + simp only [nodalExchangePolynomial,Polynomial.finsetSum_coeff,Polynomial.coeff_C_mul, + Polynomial.coeff_map] + +lemma nodalExchangePolynomial_degree {n : ℕ} (r : ℕ) (hr : r+2≤n) : + LastDegree n (nodalExchangePolynomial r hr) := by + intro p k hk + rw [nodalExchangePolynomial_coeff] + apply sum_eq_zero + intro q _ + by_cases hh : p.Occupied (Fin.last n) ↔ q.Occupied (Fin.last n) + · rw [rationalNodalPolynomial_degree n q k (by rwa [←hh]),map_zero,mul_zero] + · rw [localR_padTop_zero_last _ _ q p hh,zero_mul] + +lemma nodalExchangePolynomial_leading {n : ℕ} (r : ℕ) (hr : r+2≤n) (p : Pairing n) : + (nodalExchangePolynomial r hr p.padTop).coeff n=rationalVacuum n p := by + rw [nodalExchangePolynomial_coeff] + rw [congrFun (rationalVacuum_exchange r hr) p] + simp only [Matrix.mulVec,dotProduct] + symm + apply Fintype.sum_of_injective Pairing.padTop Pairing.padTop_injective + · intro q hq + rw [localR_padTop_outside _ _ q p hq,zero_mul] + · intro q + rw [localR_padTop,rationalNodalPolynomial_leading] + +lemma nodalExchangePolynomial_node {n : ℕ} (r : ℕ) (hr : r+2≤n) + (p : Pairing (n+1)) (i : Fin n) : + (if p.Occupied (Fin.last n) then torusSin (deletionNode i) else 1) * + (nodalExchangePolynomial r hr p).eval (deletionBeta i) =nodalVacuum i p := by + let σ := Equiv.swap (⟨r,by omega⟩ : Fin n) ⟨r+1,by omega⟩ + have hσ (j : Fin n) : σ (σ j)=j := Equiv.swap_apply_self _ _ _ + have hβ : permSpectral σ (deletionBeta (σ i))=deletionBeta i := by + rw [permSpectral_deletionBeta,hσ] + have hsin : permSpectral σ (torusSin (deletionNode (σ i)))=torusSin (deletionNode i) := by + simp only [permSpectral_torusSin,permSpectral_deletionNode,hσ] + rw [congrFun (nodalVacuum_exchange r hr i) p] + simp only [nodalExchangePolynomial,Polynomial.eval_finsetSum,Polynomial.eval_mul, + Polynomial.eval_C,mul_sum,Matrix.mulVec,dotProduct] + apply sum_congr rfl + intro q _ + change (if p.Occupied (Fin.last n) then torusSin (deletionNode i) else 1) * + (localR _ _ p q * ((rationalNodalPolynomial n q).map (permSpectral σ)).eval (deletionBeta i)) = + localR _ _ p q * permSpectral σ (nodalVacuum (σ i) q) + by_cases hh : p.Occupied (Fin.last n) ↔ q.Occupied (Fin.last n) + · rw [hh,←rationalNodalPolynomial_at_node q (σ i),map_mul] + rw [←hβ,Polynomial.eval_map_apply] + have hs : permSpectral σ (if q.Occupied (Fin.last n) then torusSin (deletionNode (σ i)) else 1)= + (if q.Occupied (Fin.last n) then torusSin (deletionNode i) else 1) := by + split_ifs <;> simp only [hsin,map_one] + rw [hs] + ring + · rw [localR_padTop_zero_last _ _ q p hh,zero_mul,mul_zero,zero_mul] + + + +theorem rationalNodalPolynomial_covariance {n : ℕ} (r : ℕ) (hr : r+2≤n) : + rationalNodalPolynomial n=nodalExchangePolynomial r hr := by + apply lastPolynomial_unique _ _ (rationalNodalPolynomial_degree n) + (nodalExchangePolynomial_degree r hr) deletionBeta (deletionBeta_injective n) + · intro p + rw [rationalNodalPolynomial_leading,nodalExchangePolynomial_leading] + · intro p i + have h := (rationalNodalPolynomial_at_node p i).trans + (nodalExchangePolynomial_node r hr p i).symm + apply mul_left_cancel₀ _ h + split_ifs + · exact deletionNode_sine_ne_zero i + · exact one_ne_zero + +end + + + + + +noncomputable section +open scoped Classical + +lemma signSpectral_nodal_eval {n : ℕ} (k i : Fin n) (p : Pairing (n+1)) : + ((rationalNodalPolynomial n p).map (signSpectral k)).eval (deletionBeta i)= + occupancySign p k.castSucc*(rationalNodalPolynomial n p).eval (deletionBeta i) := by + have hh:=congrArg (signSpectral k) (rationalNodalPolynomial_at_node p i) + rw [map_mul,signSpectral_nodalVacuum] at hh + have hev : signSpectral k ((rationalNodalPolynomial n p).eval (deletionBeta i))= + ((rationalNodalPolynomial n p).map (signSpectral k)).eval (deletionBeta i) := by + rw [←Polynomial.eval_map_apply,signSpectral_deletionBeta] + rw [hev,←rationalNodalPolynomial_at_node p i] at hh + by_cases hp:p.Occupied (Fin.last n) + · have hs : occupancySign (K:=SpectralField n) p (Fin.last n)= -1 := by simp [occupancySign,hp] + simp only [hp,ite_true,signSpectral_torusSin,signSpectral_deletionNode,nodeSign,hs] at hh + by_cases hi:i=k + · simp only [ite_eq_left hi,torusSin_neg] at hh + apply mul_left_cancel₀ (deletionNode_sine_ne_zero i) + linear_combination -hh + · simp only [ite_eq_right hi,mul_one] at hh + apply mul_left_cancel₀ (deletionNode_sine_ne_zero i) + linear_combination hh + · have hs : occupancySign (K:=SpectralField n) p (Fin.last n)=1 := by simp [occupancySign,hp] + simpa only [hp,ite_false,map_one,one_mul,nodeSign,hs,ite_self,mul_one] using hh + + + +theorem rationalNodalPolynomial_parity {n : ℕ} (k : Fin n) (p : Pairing (n+1)) : + (rationalNodalPolynomial n p).map (signSpectral k)= + Polynomial.C (occupancySign p k.castSucc)*rationalNodalPolynomial n p := by + have h: (fun p : Pairing (n+1) => (rationalNodalPolynomial n p).map (signSpectral k))= + (fun p => Polynomial.C (occupancySign p k.castSucc)*rationalNodalPolynomial n p) := by + apply lastPolynomial_unique + · intro p j hj + rw [Polynomial.coeff_map,rationalNodalPolynomial_degree n p j hj,map_zero] + · intro p j hj + rw [Polynomial.coeff_C_mul,rationalNodalPolynomial_degree n p j hj,mul_zero] + case v => exact deletionBeta + case hv => exact deletionBeta_injective n + · intro p + rw [Polynomial.coeff_map,Polynomial.coeff_C_mul,rationalNodalPolynomial_leading, + rationalVacuum_sign] + simp [occupancySign] + · intro p i + rw [Polynomial.eval_mul,Polynomial.eval_C] + exact signSpectral_nodal_eval k i p + exact congrFun h p + + + + + + + +lemma rationalNodalPolynomial_eval_div {n : ℕ} (i : Fin n) (p : Pairing (n+1)) : + (rationalNodalPolynomial n p).eval (deletionBeta i)= + nodalVacuum i p / (if p.Occupied (Fin.last n) then torusSin (deletionNode i) else 1) := by + apply (eq_div_iff (by split_ifs; exact deletionNode_sine_ne_zero i; exact one_ne_zero)).mpr + rw [mul_comm] + exact rationalNodalPolynomial_at_node p i + +lemma nodalDatumL_map_eval {n : ℕ} (W : Pairing n → Laurent n) + (hW:∀ p,evalLaurent (W p)=rationalVacuum n p) (i : Fin (n+1)) (p : Pairing (n+2)) : + evalLaurent (nodalDatumL W i p)=(rationalNodalPolynomial (n+1) p).eval (deletionBeta i) := by + rw [nodalDatumL_map W hW,rationalNodalPolynomial_eval_div] + +lemma nodalDatumL_sign {n : ℕ} (W : Pairing n → Laurent n) + (hW:∀ p,evalLaurent (W p)=rationalVacuum n p) (k i : Fin (n+1)) (p : Pairing (n+2)) : + signLaurent k (nodalDatumL W i p)= + (if p.Occupied k.castSucc then -nodalDatumL W i p else nodalDatumL W i p) := by + apply IsFractionRing.injective (SpectralRing (n+1)) (SpectralField (n+1)) + change evalLaurent (signLaurent k (nodalDatumL W i p))=evalLaurent _ + rw [←signSpectral_evalLaurent,nodalDatumL_map_eval W hW] + have h:=signSpectral_nodal_eval k i p + rw [←Polynomial.eval_map_apply,signSpectral_deletionBeta,h] + split_ifs with hp + · simp only [evalLaurent,map_neg,occupancySign,hp,ite_true,neg_one_mul] + rw [←evalLaurent,nodalDatumL_map_eval W hW] + · simp only [occupancySign,hp,ite_false,one_mul] + rw [nodalDatumL_map_eval W hW] + +end + + + + + +noncomputable section + +theorem torus_sine_pair {n : ℕ} (z : SpectralField n) (hz : z ≠ 0) : + 2 * torusSin z * torusSin (constF n phase ^ 3 / z) = + torusCos (z^2 / constF n phase ^ 3) - constF n c := by + have hq := constF_phase_ne_zero n + rw [torusSin_product _ _ hz (div_ne_zero (pow_ne_zero _ hq) hz)] + have h₁ : z / (constF n phase ^ 3 / z) = z^2 / constF n phase ^ 3 := by field_simp + have h₂ : z * (constF n phase ^ 3 / z) = constF n phase ^ 3 := by field_simp + rw [h₁, h₂, torusCos_phase_pow] + rfl + +theorem torus_twice_denominator {n : ℕ} (z : SpectralField n) (hz : z ≠ 0) : + 2 * torusL (constF n phase ^ 3 / z) = + torusCos (z^2 / constF n phase ^ 3) + constF n C := by + have hq := constF_phase_ne_zero n + have h₅ : constF n phase ^ 2 * (constF n phase ^ 3 / z) = constF n phase ^ 5 / z := by ring + have h₆ : constF n phase ^ 3 * (constF n phase ^ 3 / z) = constF n phase ^ 6 / z := by ring + rw [torusL, h₅, h₆, ← mul_assoc, torusSin_product _ _ + (div_ne_zero (pow_ne_zero _ hq) hz) (div_ne_zero (pow_ne_zero _ hq) hz)] + have hdiv : (constF n phase ^ 5 / z) / (constF n phase ^ 6 / z) = + (constF n phase)⁻¹ := by field_simp + have hmul : (constF n phase ^ 5 / z) * (constF n phase ^ 6 / z) = + -(z^2 / constF n phase ^ 3)⁻¹ := by + have h := constF_phase_eight n + field_simp + exact h + rw [hdiv, hmul, torusCos_inv, torusCos_neg, torusCos_inv, + ← pow_one (constF n phase), torusCos_phase_pow] + simp only [Nat.cast_one, one_mul, sub_neg_eq_add] + rw [add_comm] + rfl + +theorem torus_last_cleared {n : ℕ} (z : SpectralField n) (hz : z ≠ 0) + (hL : torusL (constF n phase ^ 3 / z) ≠ 0) : + let b := torusCos (z^2 / constF n phase ^ 3) + let r := fun t => (b + constF n C) * (torusWeights (constF n phase^3/z)).tile t + r .vacant = b + constF n C ∧ + r .cap = 2 * constF n d * torusSin (constF n phase^3/z) ∧ + r .vertical₀ = 2 * constF n d * torusSin z ∧ + r .diagonal₁ = b - constF n c := by + dsimp only + rw [← torus_twice_denominator z hz] + have hq := constF_phase_ne_zero n + have h₃ : constF n phase^3 / (constF n phase^3/z) = z := by field_simp + simp only [torusWeights, Weights.tile, mul_one, h₃] + constructor + · trivial + constructor + · field_simp + constructor + · field_simp + · rw [← torus_sine_pair z hz] + field_simp + + + +theorem torus_column_lastValue {n k : ℕ} (w : Fin n → Weights (SpectralField k)) + (z : SpectralField k) (hz : z ≠ 0) (hL : torusL (constF k phase^3/z) ≠ 0) + (P : Pairing (n+1) → Polynomial (SpectralField k)) : + (torusCos (z^2/constF k phase^3) + constF k C) • + (column (Fin.snoc w (torusWeights (constF k phase^3/z)))).mulVec + (lastValue (RingHom.id _) (torusCos (z^2/constF k phase^3)) (torusSin z) P) = + lastValue (RingHom.id _) (torusCos (z^2/constF k phase^3)) (torusSin z) + (lastTransform (fun i => (w i).tile) (constF k d) (constF k c) (constF k C) P) := by + have h := torus_last_cleared z hz hL + have he := rawColumn_lastValue (RingHom.id _) (fun i => (w i).tile) + (constF k d) (constF k c) (constF k C) + (torusCos (z^2/constF k phase^3)) (torusSin z) (torusSin (constF k phase^3/z)) + (fun t => (torusCos (z^2/constF k phase^3) + constF k C) * + (torusWeights (constF k phase^3/z)).tile t) P h.1 h.2.1 h.2.2.1 h.2.2.2 + (torus_sine_pair z hz) + rw [← he] + have hrow : Fin.snoc (fun i => (w i).tile) + (fun t => (torusCos (z^2/constF k phase^3) + constF k C) * + (torusWeights (constF k phase^3/z)).tile t) = + fun i t => (Fin.snoc (fun _ => 1) (torusCos (z^2/constF k phase^3) + constF k C) : + Fin (n+1) → SpectralField k) i * + ((Fin.snoc w (torusWeights (constF k phase^3/z)) : Fin (n+1) → Weights (SpectralField k)) i).tile t := by + funext i t + induction i using Fin.lastCases with + | last => simp only [Fin.snoc_last] + | cast i => simp only [Fin.snoc_castSucc, one_mul] + simp only [RingHom.id_apply] at * + rw [hrow, rawColumn_scale, Matrix.smul_mulVec] + simp only [Fin.prod_univ_castSucc, Fin.snoc_castSucc, Fin.snoc_last, Finset.prod_const_one, one_mul] + rfl + + + + + + +open Finset +open scoped Classical + + + +def rationalResidualPolynomial (n : ℕ) (p : Pairing (n+1)) : Polynomial (SpectralField n) := + lastTransform (fun i => (spectralWeights n i).tile) + (constF n d) (constF n c) (constF n C) (rationalNodalPolynomial n) p - + (Polynomial.X + Polynomial.C (constF n C)) * rationalNodalPolynomial n p + +theorem rationalVacuum_stationary (n : ℕ) : + (column (spectralWeights n)).mulVec (rationalVacuum n) = rationalVacuum n := by + change (column (spectralWeights n)).mulVec + (spectralNormalization n • normalizedVacuum (spectralWeights n)) = + spectralNormalization n • normalizedVacuum (spectralWeights n) + rw [Matrix.mulVec_smul, (spectral_normalizedVacuum_stationary n).2] + + + +theorem rationalResidualPolynomial_degree {n : ℕ} (p : Pairing (n+1)) (k : ℕ) + (hk : n < k) : (rationalResidualPolynomial n p).coeff k = 0 := by + have hP := rationalNodalPolynomial_degree n + have hT := lastTransform_degree (fun i => (spectralWeights n i).tile) + (constF n d) (constF n c) (constF n C) (rationalNodalPolynomial n) hP + obtain ⟨j, rfl⟩ : ∃ j, k = j+1 := ⟨k-1, by omega⟩ + by_cases hp : p.Occupied (Fin.last n) + · rw [rationalResidualPolynomial, Polynomial.coeff_sub, + hT p (j+1) (by simp only [hp, ite_true]; omega)] + have h₀ := hP p j (by simp only [hp, ite_true]; omega) + have h₁ := hP p (j+1) (by simp only [hp, ite_true]; omega) + simp [add_mul, h₀, h₁] + · have h₁ := hP p (j+1) (by simp only [hp, ite_false]; omega) + by_cases he : j = n + · subst j + let q := p.restrict Fin.castSuccOrderEmb + have hpad : q.padTop = p := Pairing.padTop_restrict p hp + rw [← hpad, rationalResidualPolynomial, Polynomial.coeff_sub, lastTransform_leading _ _ _ _ _ hP q] + have hlead : (fun p : Pairing n => (rationalNodalPolynomial n p.padTop).coeff n) = + rationalVacuum n := funext rationalNodalPolynomial_leading + rw [hlead, ← column_eq_raw, rationalVacuum_stationary] + have hz : (rationalNodalPolynomial n q.padTop).coeff (n+1) = 0 := by simpa [hpad] using h₁ + simp [add_mul, rationalNodalPolynomial_leading, hz] + · have h₀ := hP p j (by simp only [hp, ite_false]; omega) + rw [rationalResidualPolynomial, Polynomial.coeff_sub, + hT p (j+1) (by simp only [hp, ite_false]; omega)] + simp [add_mul, h₀, h₁] + + + +theorem rationalResidualPolynomial_at_node {n : ℕ} (p : Pairing (n+1)) (i : Fin n) : + (rationalResidualPolynomial n p).eval (deletionBeta i) = 0 := by + have hz : deletionNode i ≠ 0 := mul_ne_zero (variableF_ne_zero i) + (pow_ne_zero _ (constF_phase_ne_zero n)) + have harg : constF n phase^3 / deletionNode i = (variableF i)⁻¹ := by + unfold deletionNode + field_simp [constF_phase_ne_zero] + have hL : torusL (constF n phase^3 / deletionNode i) ≠ 0 := by + rw [harg, ← inverseRowDenominator_map] + exact inverseRowDenominator_map_ne_zero i + have he := torus_column_lastValue (spectralWeights n) (deletionNode i) hz hL + (rationalNodalPolynomial n) + have hdata : lastValue (RingHom.id _) (deletionBeta i) (torusSin (deletionNode i)) + (rationalNodalPolynomial n) = nodalVacuum i := by + funext q + simpa only [lastValue, Polynomial.eval₂_id, ite_mul, one_mul] using + rationalNodalPolynomial_at_node q i + change (deletionBeta i + constF n C) • + (column (nodalWeights i)).mulVec + (lastValue (RingHom.id _) (deletionBeta i) (torusSin (deletionNode i)) + (rationalNodalPolynomial n)) = _ at he + rw [hdata, nodalVacuum_stationary] at he + have hep := congrFun he p + simp only [Pi.smul_apply, smul_eq_mul] at hep + rw [← congrFun hdata p] at hep + change (deletionBeta i + constF n C) * + lastValue (RingHom.id _) (deletionBeta i) (torusSin (deletionNode i)) + (rationalNodalPolynomial n) p = + lastValue (RingHom.id _) (deletionBeta i) (torusSin (deletionNode i)) + (lastTransform (fun i => (spectralWeights n i).tile) (constF n d) (constF n c) + (constF n C) (rationalNodalPolynomial n)) p at hep + by_cases hp : p.Occupied (Fin.last n) + · simp only [lastValue, hp, ite_true, Polynomial.eval₂_id] at hep + have hc := deletionNode_sine_ne_zero i + rw [rationalResidualPolynomial, Polynomial.eval_sub, Polynomial.eval_mul, + Polynomial.eval_add, Polynomial.eval_X, Polynomial.eval_C] + apply sub_eq_zero.mpr + apply mul_left_cancel₀ hc + calc + _ = (deletionBeta i + constF n C) * + (torusSin (deletionNode i) * (rationalNodalPolynomial n p).eval (deletionBeta i)) := hep.symm + _ = _ := by ring + · simp only [lastValue, hp, ite_false, Polynomial.eval₂_id] at hep + simp only [rationalResidualPolynomial, Polynomial.eval_sub, Polynomial.eval_mul, + Polynomial.eval_add, Polynomial.eval_X, Polynomial.eval_C] + exact sub_eq_zero.mpr hep.symm + + + +def rationalResidualCoefficient (n : ℕ) (p : Pairing (n+1)) : SpectralField n := + (rationalResidualPolynomial n p).coeff n + +theorem rationalResidualPolynomial_factor {n : ℕ} (p : Pairing (n+1)) : + rationalResidualPolynomial n p = + Polynomial.C (rationalResidualCoefficient n p) * Lagrange.nodal univ deletionBeta := by + apply Polynomial.eq_of_degree_sub_lt_of_eval_index_eq univ (deletionBeta_injective n).injOn + · simp only [card_univ, Fintype.card_fin] + apply (Polynomial.degree_lt_iff_coeff_zero _ _).mpr + intro k hk + rw [Polynomial.coeff_sub, Polynomial.coeff_C_mul] + by_cases he : k = n + · subst k + have hnod : (Lagrange.nodal univ (@deletionBeta n)).coeff n = 1 := by + simpa only [Lagrange.natDegree_nodal, card_univ, Fintype.card_fin] using + (Lagrange.nodal_monic (s := (univ : Finset (Fin n))) (v := @deletionBeta n)).coeff_natDegree + simp [hnod, rationalResidualCoefficient] + · rw [rationalResidualPolynomial_degree p k (by omega)] + have hnod : (Lagrange.nodal univ (@deletionBeta n)).coeff k = 0 := by + apply Polynomial.coeff_eq_zero_of_degree_lt + simp only [Lagrange.degree_nodal, card_univ, Fintype.card_fin] + exact_mod_cast (show n < k by omega) + simp [hnod] + · intro i _ + rw [rationalResidualPolynomial_at_node, Polynomial.eval_mul, Polynomial.eval_C, + Lagrange.eval_nodal_at_node (mem_univ _), mul_zero] + +end +end CriticalStrip.Diagram + +end OAI diff --git a/lean/OAI/Combinatorics/StripMass/NodalNodes.lean b/lean/OAI/Combinatorics/StripMass/NodalNodes.lean new file mode 100644 index 0000000000000000000000000000000000000000..116268ce99e43607e813e21aec0106d386ffb0fc --- /dev/null +++ b/lean/OAI/Combinatorics/StripMass/NodalNodes.lean @@ -0,0 +1,481 @@ +import Mathlib +import OAI.Combinatorics.StripMass.AugmentedTail + +namespace OAI + +/-! Critical honeycomb strip paths, polynomial identities and crossing mass. -/ + + + +namespace CriticalStrip.Diagram +noncomputable section + + +def cosineL {n : ℕ} (e : Fin n → ℤ) (z : ℂ) : Laurent n := + monomialL e (z/2) + monomialL (-e) (z⁻¹/2) + +theorem cosineL_map {n : ℕ} (e : Fin n → ℤ) (z : ℂ) (hz : z ≠ 0) : + evalLaurent (cosineL e z) = torusCos (evalLaurent (monomialL e z)) := by + rw [cosineL, evalLaurent, map_add, torusCos, evalLaurent, map_monomialL_inv e z hz] + rw [map_monomialL_factor e (z/2), map_monomialL_factor (-e) (z⁻¹/2), + map_monomialL_factor e z, map_monomialL_factor (-e) z⁻¹] + simp only [constF, map_div₀, map_ofNat] + ring + +theorem twice_variableExponent_ne_neg {n : ℕ} (i j : Fin n) : + (2 : ℤ) • variableExponent i ≠ -((2 : ℤ) • variableExponent j) := by + intro h + have hi := congrFun h i + by_cases hij : i = j + · subst j + simp [variableExponent] at hi + · simp [variableExponent, eq_comm, hij] at hi + +theorem twice_variableExponent_injective {n : ℕ} : + Function.Injective (fun i : Fin n => (2 : ℤ) • variableExponent i) := by + intro i j h + by_contra hij + have hi := congrFun h i + simp [variableExponent, eq_comm, hij] at hi + +theorem cosineL_two_injective {n : ℕ} (z : ℂ) (hz : z ≠ 0) : + Function.Injective (fun i : Fin n => cosineL ((2 : ℤ) • variableExponent i) z) := by + intro i j h + by_contra hij + have he : (2 : ℤ) • variableExponent i ≠ (2 : ℤ) • variableExponent j := + fun h => hij (twice_variableExponent_injective h) + have hh := congrArg (fun f : Laurent n => f.coeff ((2 : ℤ) • variableExponent i)) h + simp only [cosineL, monomialL, AddMonoidAlgebra.coeff_add, AddMonoidAlgebra.coeff_single, + Finsupp.add_apply, Finsupp.single_apply] at hh + simp only [ite_eq_right (twice_variableExponent_ne_neg i i).symm, + ite_eq_right he.symm, ite_eq_right (twice_variableExponent_ne_neg i j).symm, + add_zero] at hh + exact hz ((div_eq_zero_iff).mp hh |>.resolve_right (by norm_num)) + +theorem map_monomialL_two_variable {n : ℕ} (i : Fin n) (z : ℂ) : + evalLaurent (monomialL ((2 : ℤ) • variableExponent i) z) = + constF n z * variableF i ^ 2 := by + have hh : monomialL ((2 : ℤ) • variableExponent i) (1:ℂ) = + monomialL (variableExponent i) 1 ^ 2 := by + simp [pow_two, two_smul] + rw [evalLaurent, map_monomialL_factor, hh, map_pow] + rfl + +theorem deletionBeta_laurent {n : ℕ} (i : Fin n) : + deletionBeta i = evalLaurent (cosineL ((2 : ℤ) • variableExponent i) (phase^3)) := by + rw [cosineL_map _ _ (pow_ne_zero _ phase_ne_zero), map_monomialL_two_variable] + unfold deletionBeta deletionNode + congr 1 + simp only [constF, map_pow] + field_simp [constF_phase_ne_zero] + +theorem deletionBeta_injective (n : ℕ) : Function.Injective (@deletionBeta n) := by + intro i j h + rw [deletionBeta_laurent, deletionBeta_laurent] at h + exact cosineL_two_injective _ (pow_ne_zero _ phase_ne_zero) + (IsFractionRing.injective (SpectralRing n) (SpectralField n) h) + +theorem deletionNode_sine_ne_zero {n : ℕ} (i : Fin n) : torusSin (deletionNode i) ≠ 0 := by + have hs : evalLaurent (sineL (variableExponent i) (phase^3)) = torusSin (deletionNode i) := by + rw [evalLaurent, map_sine_variable_nat] + congr 1 + exact mul_comm .. + rw [← hs] + apply (IsFractionRing.to_map_eq_zero_iff.not).2 + intro he + have hz := congrArg (flatEval n) he + have hflat : flatEval n (sineL (variableExponent i) (phase^3)) = + (Real.sin (3*lambda) : ℂ) := by + simpa only [zpow_ofNat, Int.cast_ofNat] using flatEval_sine_phase (variableExponent i) 3 + rw [hflat, map_zero] at hz + have hd := flatEval_rowDenominator_ne_zero i + rw [flatEval_rowDenominator, hz, zero_mul] at hd + exact hd rfl + + + + + + +open scoped LaurentPolynomial Classical + +def variableUnit {n : ℕ} (i : Fin n) : (Laurent n)ˣ := monomialUnit (variableExponent i) 1 one_ne_zero + +def constantUnit (n : ℕ) (z : ℂ) (hz:z≠0) : (Laurent n)ˣ := monomialUnit 0 z hz + +def betaL {n : ℕ} (i : Fin n) : Laurent n := cosineL ((2:ℤ) • variableExponent i) (phase^3) + +@[simp] lemma betaL_map {n : ℕ} (i : Fin n) : evalLaurent (betaL i)=deletionBeta i := + (deletionBeta_laurent i).symm + +lemma variableExponent_ne_neg {n : ℕ} (i : Fin n) : variableExponent i≠-variableExponent i := by + intro h + have hh:=congrFun h i + simp [variableExponent] at hh + +lemma collisionRoots_injective {n : ℕ} (j : Fin n) : + Function.Injective (cosineCollisionRoots (constantUnit n (phase^3) (pow_ne_zero _ phase_ne_zero)) (variableUnit j)) := by + intro k l h + have hp:=congrArg (fun v : (Laurent n)ˣ => (v:Laurent n).coeff (variableExponent j)) h + have hn:=congrArg (fun v : (Laurent n)ˣ => (v:Laurent n).coeff (-variableExponent j)) h + fin_cases k <;> fin_cases l <;> try rfl + all_goals dsimp [cosineCollisionRoots,constantUnit,variableUnit,monomialUnit] at hp hn + all_goals try simp only [monomialL_mul,zero_add,mul_one,neg_zero,inv_one] at hp hn + all_goals simp [monomialL,variableExponent_ne_neg j,(variableExponent_ne_neg j).symm] at hp hn + all_goals try norm_num at hp + all_goals exfalso; apply inv_ne_zero (pow_ne_zero 3 phase_ne_zero) + all_goals first | linear_combination hn / 2 | linear_combination -hn / 2 + +lemma peel_betaL_self {n : ℕ} (i : Fin (n+1)) : + peelLaurentEquiv i (betaL i)= + LaurentPolynomial.C (constantL n (phase^3/2))*LaurentPolynomial.T 2+ + LaurentPolynomial.C (constantL n ((phase^3)⁻¹/2))*LaurentPolynomial.T (-2) := by + have hrem:Fin.removeNth i ((2:ℤ) • variableExponent i)=0 := by + funext j + simp [Fin.removeNth,variableExponent,Fin.succAbove_ne] + have hval:((2:ℤ) • variableExponent i) i=2 := by simp [variableExponent] + simp only [betaL,cosineL,map_add,peelLaurentEquiv_monomial,hval,hrem,Pi.neg_apply] + have hn:Fin.removeNth i (-((2:ℤ) • variableExponent i))=0 := by + funext j + change -(Fin.removeNth i ((2:ℤ) • variableExponent i) j)=0 + rw [hrem]; rfl + rw [hn] + simp only [LaurentPolynomial.single_eq_C_mul_T] + rfl + +lemma insert_betaL {n : ℕ} (i : Fin (n+1)) (j : Fin n) : + insertLaurent i (betaL j)=betaL (i.succAbove j) := by + simp only [betaL,cosineL,map_add,insertLaurent_monomial] + congr 2 + all_goals funext k; refine Fin.succAboveCases i ?_ (fun l => ?_) k + all_goals simp [variableExponent,Pi.single_apply,eq_comm] + +lemma peel_betaL_other {n : ℕ} (i : Fin (n+1)) (j : Fin n) : + peelLaurentEquiv i (betaL (i.succAbove j))=LaurentPolynomial.C (betaL j) := by + rw [←insert_betaL i j,peelLaurentEquiv_insert] + +@[simp] lemma variableUnit_coe {n : ℕ} (j : Fin n) : + (variableUnit j : Laurent n)=monomialL (variableExponent j) 1 := rfl +@[simp] lemma variableUnit_inv_coe {n : ℕ} (j : Fin n) : + ((variableUnit j)⁻¹ : (Laurent n)ˣ).val=monomialL (-variableExponent j) 1 := by + simp only [variableUnit,monomialUnit,Units.inv_mk,Units.val_mk,inv_one] +@[simp] lemma constantUnit_coe (n : ℕ) (z : ℂ) (hz:z≠0) : + (constantUnit n z hz : Laurent n)=monomialL 0 z := rfl +@[simp] lemma constantUnit_inv_coe (n : ℕ) (z : ℂ) (hz:z≠0) : + ((constantUnit n z hz)⁻¹ : (Laurent n)ˣ).val=monomialL 0 z⁻¹ := by + simp only [constantUnit,monomialUnit,Units.inv_mk,Units.val_mk,neg_zero] + +lemma betaL_monomial_expression {n : ℕ} (j : Fin n) : + monomialL 0 2*(cosineL ((2:ℤ) • variableExponent j) (phase^3))= + monomialL 0 (phase^3)*(monomialL (variableExponent j) 1)^2+ + monomialL 0 ((phase^3)⁻¹)*(monomialL (-variableExponent j) 1)^2 := by + simp only [cosineL,pow_two,mul_add,monomialL_mul,zero_add,mul_one,two_smul,neg_add] + congr 2 <;> ring + +lemma betaL_unit_expression {n : ℕ} (j : Fin n) : + (constantL n 2)*betaL j= + (constantUnit n (phase^3) (pow_ne_zero _ phase_ne_zero) : Laurent n)*(variableUnit j : Laurent n)^2+ + (((constantUnit n (phase^3) (pow_ne_zero _ phase_ne_zero))⁻¹ : (Laurent n)ˣ) : Laurent n)* + (((variableUnit j)⁻¹ : (Laurent n)ˣ) : Laurent n)^2 := by + simp only [variableUnit_coe,variableUnit_inv_coe,constantUnit_coe,constantUnit_inv_coe] + exact betaL_monomial_expression j + +lemma cosineCollisionPacket_betaL {n : ℕ} (i : Fin (n+1)) (j : Fin n) : + cosineCollisionPacket (constantUnit n (phase^3) (pow_ne_zero _ phase_ne_zero)) (variableUnit j)= + 2*(peelLaurentEquiv i (betaL i-betaL (i.succAbove j))) := by + rw [map_sub,peel_betaL_self,peel_betaL_other,cosineCollisionPacket,←betaL_unit_expression] + simp only [map_mul,constantUnit,monomialUnit] + have h1 : (2:LaurentPolynomial (Laurent n))*LaurentPolynomial.C (constantL n (phase^3/2))= + LaurentPolynomial.C (constantL n (phase^3)) := by + rw [←map_ofNat LaurentPolynomial.C 2,←map_mul,←map_ofNat (constantL n) 2,←map_mul] + congr 2 + ring + have h2 : (2:LaurentPolynomial (Laurent n))*LaurentPolynomial.C (constantL n ((phase^3)⁻¹/2))= + LaurentPolynomial.C (constantL n ((phase^3)⁻¹)) := by + rw [←map_ofNat LaurentPolynomial.C 2,←map_mul,←map_ofNat (constantL n) 2,←map_mul] + congr 2 + ring + change LaurentPolynomial.C (constantL n (phase^3))*LaurentPolynomial.T 2+ + LaurentPolynomial.C (constantL n ((phase^3)⁻¹))*LaurentPolynomial.T (-2)- + LaurentPolynomial.C (constantL n 2)*LaurentPolynomial.C (betaL j)=_ + simp only [map_ofNat] + linear_combination -(LaurentPolynomial.T 2)*h1-(LaurentPolynomial.T (-2))*h2 + + +lemma betaL_difference_dvd {n : ℕ} (i : Fin (n+1)) (j : Fin n) (f : Laurent (n+1)) + (h:∀ k, substituteLaurent i + (cosineCollisionRoots (constantUnit n (phase^3) (pow_ne_zero _ phase_ne_zero)) (variableUnit j) k) f=0) : + betaL i-betaL (i.succAbove j) ∣ f := by + have hh:=cosineCollisionPacket_dvd (constantUnit n (phase^3) (pow_ne_zero _ phase_ne_zero)) + (variableUnit j) (collisionRoots_injective j) (peelLaurentEquiv i f) h + rw [cosineCollisionPacket_betaL i j] at hh + have hdiv : peelLaurentEquiv i (betaL i-betaL (i.succAbove j)) ∣ peelLaurentEquiv i f := + dvd_trans (dvd_mul_left _ _) hh + exact (map_dvd_iff (peelLaurentEquiv i)).mp hdiv + +end + + + + + +noncomputable section +open scoped Classical LaurentPolynomial + +lemma sum_upperPair {R:Type*} [AddCommMonoid R] {n:ℕ} (D:Fin n → Fin n → R) : + (∑ e:UpperPair n,D e.val.1 e.val.2)=∑ i,∑ j∈Finset.Ioi i,D i j := by + rw [←Finset.sum_subtype (Finset.univ.filter (fun ij:Fin n × Fin n => ij.1 < ij.2)) + (by simp) (fun ij:Fin n × Fin n => D ij.1 ij.2),Finset.sum_filter] + rw [Fintype.sum_prod_type] + apply Finset.sum_congr rfl + intro i _ + have h:Finset.Ioi i=Finset.univ.filter (fun j => i ((if i=k then 1 else 0)+(if j=k then 1 else 0):ℕ))] + simp_rw [Finset.sum_add_distrib] + have h1:(∑ i:Fin (n+1),∑ _j∈Finset.Ioi i,(if i=k then 1 else 0:ℕ))=n-k.val := by + simp only [Finset.sum_const,smul_eq_mul] + simp only [mul_ite,mul_one,mul_zero,Finset.sum_ite_eq',Finset.mem_univ,ite_true,Fin.card_Ioi] + omega + have h2:(∑ i:Fin (n+1),∑ j∈Finset.Ioi i,(if j=k then 1 else 0:ℕ))=k.val := by + simp only [Finset.sum_ite_eq',Finset.mem_Ioi] + rw [←Finset.sum_filter] + have h:Finset.univ.filter (fun i:Fin (n+1) => i + simp only [Finset.prod_empty,Finset.sum_empty] + refine ⟨?_,?_,?_⟩ + · intro e he + have : e=0 := by + by_contra hh + apply he + change (Finsupp.single (0:ℤ) (1:K)) e=0 + exact Finsupp.single_eq_of_ne hh + simp [this] + · simp + · simp + | @insert i s hi ih => + specialize ih (fun j hj => h j (by simp [hj])) + have hj:=h i (by simp) + rw [Finset.prod_insert hi,Finset.sum_insert hi,Finset.sum_insert hi] + refine ⟨hj.1.mul ih.1,?_,?_⟩ + · rw [laurent_mul_bottom_coeff _ _ _ _ (fun e he => (hj.1 e he).1) (fun e he => (ih.1 e he).1)] + exact mul_ne_zero hj.2.1 ih.2.1 + · rw [laurent_mul_top_coeff _ _ _ _ (fun e he => (hj.1 e he).2) (fun e he => (ih.1 e he).2)] + exact mul_ne_zero hj.2.2 ih.2.2 + +lemma peel_beta_coeff_self {n:ℕ} (i:Fin (n+1)) (e:ℤ) : + (peelLaurent i (betaL i)).coeff e= + (if e=2 then constF n (phase^3/2) else 0)+(if e=(-2) then constF n ((phase^3)⁻¹/2) else 0) := by + rw [peelLaurent_coeff,peel_betaL_self] + simp only [←LaurentPolynomial.single_eq_C_mul_T,AddMonoidAlgebra.coeff_add, + AddMonoidAlgebra.coeff_single,Finsupp.add_apply] + change (algebraMap (SpectralRing n) (SpectralField n)) + ((Finsupp.single 2 (constantL n (phase^3/2))) e + + (Finsupp.single (-2) (constantL n ((phase^3)⁻¹/2))) e)=_ + simp only [Finsupp.single_apply] + rw [map_add] + congr 1 + · by_cases h:e=2 + · subst e + rw [ite_eq_left rfl,ite_eq_left rfl] + exact map_constantL n _ + · rw [ite_eq_right (Ne.symm h),ite_eq_right h,map_zero] + · by_cases h:e=(-2) + · subst e + rw [ite_eq_left rfl,ite_eq_left rfl] + exact map_constantL n _ + · rw [ite_eq_right (Ne.symm h),ite_eq_right h,map_zero] + +lemma peel_beta_coeff_other {n:ℕ} (i:Fin (n+1)) (j:Fin n) (e:ℤ) : + (peelLaurent i (betaL (i.succAbove j))).coeff e=if e=0 then deletionBeta j else 0 := by + rw [peelLaurent_coeff,peel_betaL_other] + change evalLaurent ((AddMonoidAlgebra.single 0 (betaL j)).coeff e)=_ + simp only [AddMonoidAlgebra.coeff_single,Finsupp.single_apply] + by_cases h:e=0 + · subst e + rw [ite_eq_left rfl,ite_eq_left rfl] + exact betaL_map j + · rw [ite_eq_right (Ne.symm h),ite_eq_right h] + exact map_zero _ + +end + + + + + +noncomputable section + +instance spectralFieldCharZero (n : ℕ) : CharZero (SpectralField n) := + charZero_of_injective_algebraMap (algebraMap ℂ (SpectralField n)).injective + + + + + + + +lemma torusCos_sum {n : ℕ} (z w : SpectralField n) (hz : z≠0) (hw : w≠0) : + torusCos (z/w)+torusCos (z*w)=2*torusCos z*torusCos w := by + unfold torusCos + field_simp [hz,hw] + ring + +lemma torusCos_product {n : ℕ} (z w : SpectralField n) (hz : z≠0) (hw : w≠0) : + torusCos (z/w)*torusCos (z*w)=(torusCos z)^2+(torusCos w)^2-1 := by + unfold torusCos + field_simp [hz,hw] + norm_num + ring + +lemma discriminant_torus_roots {n : ℕ} (z t : SpectralField n) (hz : z≠0) : + discriminant (constF n d) (torusCos z) t= + (t-torusCos (z/constF n phase^6))*(t-torusCos (z*constF n phase^6)) := by + have hq := pow_ne_zero 6 (constF_phase_ne_zero n) + have h6 : torusCos (constF n phase^6) = -constF n d := by + rw [torusCos_phase_pow] + simp only [Nat.cast_ofNat,cos_six_lambda,Complex.ofReal_neg,constF,map_neg] + have hd : (constF n d)^2=1/2 := by + have h:=congrArg (fun a : ℝ => constF n (a:ℂ)) d_sq + simpa only [Complex.ofReal_pow,Complex.ofReal_div,Complex.ofReal_one,Complex.ofReal_ofNat, + constF,map_pow,map_div₀,map_one,map_ofNat] using h + have hs:=torusCos_sum z (constF n phase^6) hz hq + have hp:=torusCos_product z (constF n phase^6) hz hq + rw [h6] at hs hp + unfold discriminant + linear_combination t*hs-hp-2*hd + +lemma cosineL_two_ne {n : ℕ} (i j : Fin n) (hij : i≠j) (z w : ℂ) (hz : z≠0) : + cosineL ((2:ℤ) • variableExponent i) z≠cosineL ((2:ℤ) • variableExponent j) w := by + intro h + have he : (2 : ℤ) • variableExponent i ≠ (2 : ℤ) • variableExponent j := + fun h => hij (twice_variableExponent_injective h) + have hh:=congrArg (fun f : Laurent n => f.coeff ((2:ℤ) • variableExponent i)) h + simp only [cosineL,monomialL,AddMonoidAlgebra.coeff_add,AddMonoidAlgebra.coeff_single, + Finsupp.add_apply,Finsupp.single_apply] at hh + simp only [ite_eq_right (twice_variableExponent_ne_neg i i).symm, + ite_eq_right he.symm,ite_eq_right (twice_variableExponent_ne_neg i j).symm,add_zero] at hh + exact hz ((div_eq_zero_iff).mp hh |>.resolve_right (by norm_num)) + +lemma cosineL_two_parameter {n : ℕ} (i : Fin n) (z w : ℂ) : + cosineL ((2:ℤ) • variableExponent i) z=cosineL ((2:ℤ) • variableExponent i) w → z=w := by + intro h + have hh:=congrArg (fun f : Laurent n => f.coeff ((2:ℤ) • variableExponent i)) h + simp only [cosineL,monomialL,AddMonoidAlgebra.coeff_add,AddMonoidAlgebra.coeff_single, + Finsupp.add_apply,Finsupp.single_apply] at hh + simp only [ite_eq_right (twice_variableExponent_ne_neg i i).symm,add_zero] at hh + exact (div_left_inj' (by norm_num : (2:ℂ)≠0)).mp hh + + +def shiftedCosine {n : ℕ} (i : Fin n) (z : ℂ) : SpectralField n := + evalLaurent (cosineL ((2:ℤ) • variableExponent i) z) + +lemma shiftedCosine_eq {n : ℕ} (i : Fin n) (z : ℂ) (hz : z≠0) : + shiftedCosine i z=torusCos (constF n z*variableF i^2) := by + rw [shiftedCosine,cosineL_map _ _ hz,map_monomialL_two_variable] + +lemma shiftedCosine_ne {n : ℕ} (i j : Fin n) (hij : i≠j) (z w : ℂ) (hz : z≠0) : + shiftedCosine i z≠shiftedCosine j w := by + intro h + exact cosineL_two_ne i j hij z w hz ((IsFractionRing.injective (SpectralRing n) (SpectralField n)) h) + +lemma shiftedCosine_parameter {n : ℕ} (i : Fin n) (z w : ℂ) : + shiftedCosine i z=shiftedCosine i w → z=w := by + intro h + exact cosineL_two_parameter i z w ((IsFractionRing.injective (SpectralRing n) (SpectralField n)) h) + +lemma spectralA_shiftedCosine {n : ℕ} (i : Fin n) : spectralA i=shiftedCosine i (phase^(-3:ℤ)) := by + rw [shiftedCosine_eq _ _ (zpow_ne_zero _ phase_ne_zero)] + simp only [spectralA,constF,zpow_neg,zpow_ofNat,map_inv₀,map_pow,div_eq_mul_inv,mul_comm] + +lemma deletionBeta_shiftedCosine {n : ℕ} (i : Fin n) : + deletionBeta i=shiftedCosine i (phase^(3:ℤ)) := deletionBeta_laurent i + + + + + + + +lemma shiftedCosine_roots {n : ℕ} (i : Fin n) (k : ℤ) (t : SpectralField n) : + discriminant (constF n d) (shiftedCosine i (phase^k)) t= + (t-shiftedCosine i (phase^(k-6)))*(t-shiftedCosine i (phase^(k+6))) := by + rw [shiftedCosine_eq _ _ (zpow_ne_zero _ phase_ne_zero), + shiftedCosine_eq _ _ (zpow_ne_zero _ phase_ne_zero), + shiftedCosine_eq _ _ (zpow_ne_zero _ phase_ne_zero), + discriminant_torus_roots _ _ (mul_ne_zero (by + simpa only [constF,map_zero] using (algebraMap ℂ (SpectralField n)).injective.ne (zpow_ne_zero k phase_ne_zero)) (pow_ne_zero _ (variableF_ne_zero i)))] + have hq := constF_phase_ne_zero n + simp only [constF,map_zpow₀,zpow_sub₀ phase_ne_zero,zpow_add₀ phase_ne_zero, + map_div₀,map_mul,map_pow,zpow_ofNat] + congr 2 <;> congr 1 <;> ring + +lemma shiftedCosine_discriminant_ne {n : ℕ} (i j : Fin n) (hij : i≠j) (k l : ℤ) : + discriminant (constF n d) (shiftedCosine i (phase^k)) (shiftedCosine j (phase^l))≠0 := by + rw [shiftedCosine_roots] + exact mul_ne_zero (sub_ne_zero.mpr (shiftedCosine_ne j i hij.symm _ _ (zpow_ne_zero _ phase_ne_zero))) + (sub_ne_zero.mpr (shiftedCosine_ne j i hij.symm _ _ (zpow_ne_zero _ phase_ne_zero))) + +lemma phase_six_ne_one : phase^(6:ℕ)≠1 := by + intro h + have h₃ : phase^(24:ℕ)=1 := by simpa only [←pow_mul,one_pow] using congrArg (fun z : ℂ => z^(4:ℕ)) h + have h₂ : phase^24=-1 := by + calc + _ = (phase^8)^3 := by rw [←pow_mul] + _ = -1 := by rw [phase_eight]; norm_num + rw [h₃] at h₂ + norm_num at h₂ + +lemma spectralA_ne_deletionBeta {n : ℕ} (i : Fin n) : spectralA i≠deletionBeta i := by + rw [spectralA_shiftedCosine,deletionBeta_shiftedCosine] + intro hh + have h:=shiftedCosine_parameter i _ _ hh + simp only [zpow_neg,zpow_ofNat] at h + have hp : phase^6=1 := by + calc + _ = phase^3*phase^3 := by ring + _ = (phase^3)⁻¹*phase^3 := by rw [h] + _ = 1 := inv_mul_cancel₀ (pow_ne_zero _ phase_ne_zero) + exact phase_six_ne_one hp + +lemma spectralA_roots {n : ℕ} (i : Fin n) (t : SpectralField n) : + discriminant (constF n d) (spectralA i) t= + (t-deletionBeta i)*(t-shiftedCosine i (phase^(-9:ℤ))) := by + rw [spectralA_shiftedCosine,deletionBeta_shiftedCosine,shiftedCosine_roots] + norm_num + ring + +lemma deletionBeta_roots {n : ℕ} (i : Fin n) (t : SpectralField n) : + discriminant (constF n d) (deletionBeta i) t= + (t-spectralA i)*(t-shiftedCosine i (phase^(9:ℤ))) := by + rw [spectralA_shiftedCosine,deletionBeta_shiftedCosine,shiftedCosine_roots] + norm_num + +end +end CriticalStrip.Diagram + +end OAI diff --git a/lean/OAI/Combinatorics/StripMass/NodalRegularity.lean b/lean/OAI/Combinatorics/StripMass/NodalRegularity.lean new file mode 100644 index 0000000000000000000000000000000000000000..897b8c00b8c4e1ebb963045eba2b428fdd6070c3 --- /dev/null +++ b/lean/OAI/Combinatorics/StripMass/NodalRegularity.lean @@ -0,0 +1,563 @@ +import Mathlib +import OAI.Combinatorics.StripMass.SwapVacancy + +namespace OAI + +/-! Critical honeycomb strip paths, polynomial identities and crossing mass. -/ + + + +namespace CriticalStrip.Diagram +noncomputable section + + +def inverseRowDenominator {n : ℕ} (i : Fin n) : Laurent n := + sineL (-variableExponent i) (phase^(2:ℤ)) * + sineL (-variableExponent i) (phase^(3:ℤ)) + +def inverseRowNumerator {n : ℕ} (i : Fin n) : Tile → Laurent n + | .vacant => inverseRowDenominator i + | .vertical₀ | .vertical₁ => + constantL n d * sineL (variableExponent i) (phase^(3:ℤ)) + | .diagonal₀ | .diagonal₁ => + sineL (-variableExponent i) (phase^(0:ℤ)) * + sineL (variableExponent i) (phase^(3:ℤ)) + | .cap | .cup => constantL n d * sineL (-variableExponent i) (phase^(0:ℤ)) + | .verticalPair => + sineL (variableExponent i) (phase^(3:ℤ)) * + sineL (variableExponent i) (phase^(2:ℤ)) + | .capCup => + sineL (-variableExponent i) (phase^(-1:ℤ)) * + sineL (-variableExponent i) (phase^(0:ℤ)) + +theorem inverseRowDenominator_flat {n : ℕ} (i : Fin n) : + flatEval n (inverseRowDenominator i) = + (Real.sin (2*lambda) : ℂ) * (Real.sin (3*lambda) : ℂ) := by + simp only [inverseRowDenominator, map_mul, flatEval_sine_phase, Int.cast_ofNat] + +theorem inverseRowDenominator_flat_ne_zero {n : ℕ} (i : Fin n) : + flatEval n (inverseRowDenominator i) ≠ 0 := by + simpa only [inverseRowDenominator_flat, flatEval_rowDenominator, mul_comm] using + flatEval_rowDenominator_ne_zero i + +theorem inverseRowDenominator_map {n : ℕ} (i : Fin n) : + evalLaurent (inverseRowDenominator i) = torusL (variableF i)⁻¹ := by + simp only [evalLaurent, inverseRowDenominator, map_mul, zpow_ofNat, + map_sine_neg_variable_nat, torusL, div_eq_mul_inv] + +theorem inverseRowDenominator_map_ne_zero {n : ℕ} (i : Fin n) : + evalLaurent (inverseRowDenominator i) ≠ 0 := by + apply (IsFractionRing.to_map_eq_zero_iff.not).2 + intro h + exact inverseRowDenominator_flat_ne_zero i (by rw [h, map_zero]) + +theorem inverseRowNumerator_flat {n : ℕ} (i : Fin n) (t : Tile) : + flatEval n (inverseRowNumerator i t) = + flatEval n (inverseRowDenominator i) * (identityWeights : Weights ℂ).tile t := by + have hd : (d : ℂ) = (Real.sin (2*lambda) : ℂ) := by + congr 1 + rw [d, ← Real.sin_pi_div_two_sub] + congr 1 + unfold lambda + ring + cases t <;> simp only [inverseRowNumerator, map_mul, flatEval_constant, + flatEval_sine_phase, inverseRowDenominator_flat, identityWeights, Weights.tile, + Int.cast_ofNat, Int.cast_zero, zero_mul, Real.sin_zero, Complex.ofReal_zero, + mul_zero, mul_one] + all_goals try rw [hd] + all_goals ring + +theorem inverseRowNumerator_map {n : ℕ} (i : Fin n) (t : Tile) : + evalLaurent (inverseRowNumerator i t) = + evalLaurent (inverseRowDenominator i) * (torusWeights (variableF i)⁻¹).tile t := by + have hx := variableF_ne_zero i + have hq := constF_phase_ne_zero n + have hL : torusL (variableF i)⁻¹ ≠ 0 := by + rw [← inverseRowDenominator_map] + exact inverseRowDenominator_map_ne_zero i + have h₃ : constF n phase ^ 3 / (variableF i)⁻¹ = constF n phase ^ 3 * variableF i := by simp + have h₂ : constF n phase ^ 2 / (variableF i)⁻¹ = constF n phase ^ 2 * variableF i := by simp + have hd : algebraMap (SpectralRing n) (SpectralField n) (inverseRowDenominator i) = + torusL (variableF i)⁻¹ := inverseRowDenominator_map i + cases t <;> simp only [evalLaurent, inverseRowNumerator, map_mul, map_constantL, + zpow_ofNat, map_sine_variable_nat, map_sine_neg_variable_nat, + zpow_neg_one, hd, torusWeights, Weights.tile, + h₃, h₂, mul_one] + all_goals try simp only [← one_div (variableF i)] at hL + all_goals try field_simp [hL] + rw [sineL_map _ _ (one_div_ne_zero phase_ne_zero), map_monomialL_neg_variable] + simp only [constF, div_eq_mul_inv, mul_inv_rev] + simp only [mul_one, one_mul, map_inv₀, mul_comm] + +theorem nodalWeights_last {n : ℕ} (i : Fin n) : + nodalWeights i (Fin.last n) = torusWeights (variableF i)⁻¹ := by + simp only [nodalWeights, Fin.snoc_last, deletionNode] + congr 1 + field_simp [constF_phase_ne_zero] + +theorem nodal_regular {n : ℕ} (i : Fin n) : VacuumRegular (nodalWeights i) := by + apply regular_of_cleared_specialization + (algebraMap (SpectralRing n) (SpectralField n)) + (IsFractionRing.injective _ _) (flatEval n).toRingHom + (Fin.snoc rowDenominator (inverseRowDenominator i)) + (Fin.snoc rowNumerator (inverseRowNumerator i)) + (nodalWeights i) (Fin.snoc (fun _ => deletionWeights) identityWeights) + · intro j + induction j using Fin.lastCases with + | last => simpa only [AlgHom.toRingHom_eq_coe, AlgHom.coe_toRingHom, Fin.snoc_last] using inverseRowDenominator_flat_ne_zero i + | cast j => simpa only [AlgHom.toRingHom_eq_coe, AlgHom.coe_toRingHom, Fin.snoc_castSucc] using flatEval_rowDenominator_ne_zero j + · intro j t + induction j using Fin.lastCases with + | last => simpa only [evalLaurent, Fin.snoc_last, nodalWeights_last] using inverseRowNumerator_map i t + | cast j => simpa only [Fin.snoc_castSucc, nodalWeights] using rowNumerator_map j t + · intro j t + induction j using Fin.lastCases with + | last => simpa only [AlgHom.toRingHom_eq_coe, AlgHom.coe_toRingHom, Fin.snoc_last] using inverseRowNumerator_flat i t + | cast j => simpa only [AlgHom.toRingHom_eq_coe, AlgHom.coe_toRingHom, Fin.snoc_castSucc] using rowNumerator_flatEval j t + · unfold VacuumRegular + rw [det_one_nonflat] + · exact one_ne_zero + · intro j k hj hk + induction j using Fin.lastCases with + | last => exact (hj (Or.inl (Fin.snoc_last ..))).elim + | cast j => exact (hj (Or.inr (Fin.snoc_castSucc ..))).elim + +theorem nodalVacuum_stationary {n : ℕ} (i : Fin n) : + (column (nodalWeights i)).mulVec (nodalVacuum i) = nodalVacuum i := by + have h := (normalizedVacuum_stationary (nodalWeights i) (nodal_regular i)).2 + change (column (nodalWeights i)).mulVec (nodalScalar i • normalizedVacuum (nodalWeights i)) = + nodalScalar i • normalizedVacuum (nodalWeights i) + rw [Matrix.mulVec_smul, h] + + + + + + +open scoped Classical + + + +lemma spectral_regular_reindex {n m : ℕ} (f : Fin n → Fin m) : + VacuumRegular (fun i => spectralWeights m (f i)) := by + apply regular_of_cleared_specialization + (algebraMap (SpectralRing m) (SpectralField m)) + (IsFractionRing.injective _ _) (flatEval m).toRingHom + (fun i => rowDenominator (f i)) (fun i => rowNumerator (f i)) + (fun i => spectralWeights m (f i)) (fun _ => deletionWeights) + · intro i; exact flatEval_rowDenominator_ne_zero (f i) + · intro i; exact rowNumerator_map (f i) + · intro i; exact rowNumerator_flatEval (f i) + · unfold VacuumRegular + rw [det_one_nonflat] + · exact one_ne_zero + · intro i j hi; exact (hi (Or.inr rfl)).elim + +lemma map_monomialL_sub_variable {n : ℕ} (i j : Fin n) (z : ℂ) : + evalLaurent (monomialL (variableExponent j-variableExponent i) z)= + constF n z*(variableF j/variableF i) := by + have hm : monomialL (variableExponent j-variableExponent i) z = + monomialL (variableExponent j) z * monomialL (-variableExponent i) 1 := by + simp only [monomialL_mul,mul_one,sub_eq_add_neg] + rw [hm,evalLaurent,map_mul,map_monomialL_variable,map_monomialL_neg_variable] + simp only [constF,map_one,div_eq_mul_inv,mul_assoc,one_mul] + +lemma torusL_ratio_ne_zero {n : ℕ} (i j : Fin n) : torusL (variableF j/variableF i)≠0 := by + let e := variableExponent j-variableExponent i + let D : Laurent n := sineL e (phase^2)*sineL e (phase^3) + have hev : evalLaurent D=torusL (variableF j/variableF i) := by + simp only [D,evalLaurent,map_mul,torusL] + rw [sineL_map _ _ (pow_ne_zero _ phase_ne_zero), + sineL_map _ _ (pow_ne_zero _ phase_ne_zero), + show (algebraMap (SpectralRing n) (SpectralField n)) (monomialL e (phase^2))= + constF n (phase^2)*(variableF j/variableF i) from map_monomialL_sub_variable i j _, + show (algebraMap (SpectralRing n) (SpectralField n)) (monomialL e (phase^3))= + constF n (phase^3)*(variableF j/variableF i) from map_monomialL_sub_variable i j _] + simp only [constF,map_pow] + have hf : flatEval n D=(Real.sin (2*lambda):ℂ)*(Real.sin (3*lambda):ℂ) := by + change (flatEval n (sineL e (phase^(2:ℤ))*sineL e (phase^(3:ℤ))))=_ + simp only [map_mul,flatEval_sine_phase,Int.cast_ofNat] + rw [←hev] + apply (IsFractionRing.to_map_eq_zero_iff.not).2 + intro h + have hne:=flatEval_rowDenominator_ne_zero i + apply hne + rw [flatEval_rowDenominator] + have hh : flatEval n D=0 := by rw [h,map_zero] + rw [hf] at hh + simpa only [mul_comm] using hh + + + +theorem spectral_vacuum_exchange {n : ℕ} (r : ℕ) (hr : r+2≤n) : + normalizedVacuum (spectralWeights n) = + (localR (PartialColumn.rowPosition r hr) + (torusWeights (variableF ⟨r+1,by omega⟩ / variableF ⟨r,by omega⟩))).mulVec + (normalizedVacuum (fun i => spectralWeights n + (Equiv.swap ⟨r,by omega⟩ ⟨r+1,by omega⟩ i))) := by + apply normalizedVacuum_torus_exchange r hr + (fun i => constF n phase^3/variableF i) + (variableF ⟨r+1,by omega⟩/variableF ⟨r,by omega⟩) + · exact div_ne_zero (variableF_ne_zero _) (variableF_ne_zero _) + · exact div_ne_zero (pow_ne_zero _ (constF_phase_ne_zero _)) (variableF_ne_zero _) + · exact torusL_ratio_ne_zero _ _ + · rw [← rowDenominator_map]; exact rowDenominator_map_ne_zero _ + · rw [← rowDenominator_map]; exact rowDenominator_map_ne_zero _ + · field_simp [variableF_ne_zero] + · exact spectral_regular n + · exact spectral_regular_reindex _ + +end + + + + + +noncomputable section +open scoped Classical + + +def insertedNodeWeights {n : ℕ} (i : Fin n) (j : Fin (n+1)) : + Fin (n+1) → Weights (SpectralField n) := + Fin.insertNth j (torusWeights (variableF i)⁻¹) (spectralWeights n) + +lemma insertedNodeWeights_last {n : ℕ} (i : Fin n) : + insertedNodeWeights i (Fin.last n)=nodalWeights i := by + rw [insertedNodeWeights,Fin.insertNth_last'] + funext j + induction j using Fin.lastCases with + | last => rw [Fin.snoc_last,nodalWeights_last] + | cast j => simp [nodalWeights] + + + +lemma insertedNode_regular {n : ℕ} (i : Fin n) (j : Fin (n+1)) : + VacuumRegular (insertedNodeWeights i j) := by + apply regular_of_cleared_specialization + (algebraMap (SpectralRing n) (SpectralField n)) + (IsFractionRing.injective _ _) (flatEval n).toRingHom + (Fin.insertNth j (inverseRowDenominator i) rowDenominator) + (Fin.insertNth j (inverseRowNumerator i) rowNumerator) + (insertedNodeWeights i j) (Fin.insertNth j identityWeights (fun _ => deletionWeights)) + · intro k + refine Fin.succAboveCases j ?_ (fun l => ?_) k <;> simp only [Fin.insertNth_apply_same,Fin.insertNth_apply_succAbove] + · exact inverseRowDenominator_flat_ne_zero i + · exact flatEval_rowDenominator_ne_zero l + · intro k t + refine Fin.succAboveCases j ?_ (fun l => ?_) k <;> simp only [insertedNodeWeights,Fin.insertNth_apply_same,Fin.insertNth_apply_succAbove] + · exact inverseRowNumerator_map i t + · exact rowNumerator_map _ t + · intro k t + refine Fin.succAboveCases j ?_ (fun l => ?_) k <;> simp only [Fin.insertNth_apply_same,Fin.insertNth_apply_succAbove] + · exact inverseRowNumerator_flat i t + · exact rowNumerator_flatEval _ t + · unfold VacuumRegular + rw [det_one_nonflat] + · exact one_ne_zero + · intro k l hk + rcases Fin.eq_self_or_eq_succAbove j k with rfl | ⟨a,rfl⟩ + · exact (hk (Or.inl (Fin.insertNth_apply_same ..))).elim + · exact (hk (Or.inr (Fin.insertNth_apply_succAbove ..))).elim + +lemma insertedNode_deletion {n : ℕ} (i : Fin (n+1)) : + normalizedVacuum (insertedNodeWeights i i.succ) = + (deletionMap i.val (show i.val+2≤n+2 by omega)).mulVec + (normalizedVacuum (fun k => spectralWeights (n+1) (i.succAbove k))) := by + have hrows : (fun k => insertedNodeWeights i i.succ + (i.succ.succAbove (i.succAbove k)))=(fun k => spectralWeights (n+1) (i.succAbove k)) := by + funext k; exact Fin.insertNth_apply_succAbove _ _ _ _ + have h₀ : insertedNodeWeights i i.succ ⟨i.val,by omega⟩= + torusWeights (constF (n+1) phase^3*(variableF i)⁻¹) := by + have hi : i.succ.succAbove i=i.castSucc := by + rw [Fin.succAbove_of_castSucc_lt] + exact Fin.castSucc_lt_succ + change insertedNodeWeights i i.succ i.castSucc=_ + rw [←hi] + simp only [insertedNodeWeights,Fin.insertNth_apply_succAbove,spectralWeights,div_eq_mul_inv] + have h₁ : insertedNodeWeights i i.succ ⟨i.val+1,by omega⟩=torusWeights (variableF i)⁻¹ := + Fin.insertNth_apply_same .. + have hL : torusL (constF (n+1) phase^3*(variableF i)⁻¹)≠0 := by + rw [←div_eq_mul_inv,←rowDenominator_map] + exact rowDenominator_map_ne_zero i + have h := normalizedVacuum_deletion i.val (show i.val+2≤n+2 by omega) + (insertedNodeWeights i i.succ) (variableF i)⁻¹ + (inv_ne_zero (variableF_ne_zero i)) + (by rw [←inverseRowDenominator_map]; exact inverseRowDenominator_map_ne_zero i) hL + h₀ h₁ (insertedNode_regular i i.succ) + (by change VacuumRegular (fun k => insertedNodeWeights i i.succ + (i.succ.succAbove (i.succAbove k))) + rw [hrows]; exact spectral_regular_reindex i.succAbove) + change normalizedVacuum (insertedNodeWeights i i.succ) = + (deletionMap i.val _).mulVec (normalizedVacuum + (fun k => insertedNodeWeights i i.succ (i.succ.succAbove (i.succAbove k)))) at h + rw [hrows] at h + exact h + + + + + + + +lemma Fin.insertNth_swap_adjacent {α : Type*} {n : ℕ} (a b : Fin (n+1)) + (hab : a.val+1=b.val) (x : α) (w : Fin n → α) : + (Fin.insertNth b x w) ∘ Equiv.swap a b=Fin.insertNth a x w := by + rw [Fin.eq_insertNth_iff] + constructor + · simp + · funext i + have h : Equiv.swap a b (a.succAbove i)=b.succAbove i := by + rw [←Fin.swap_succAbove_adjacent a b hab i,Equiv.swap_apply_self] + simp only [Fin.removeNth,Function.comp_apply,h,Fin.insertNth_apply_succAbove] + +lemma torusL_deletion_ratio_ne_zero {n : ℕ} (i j : Fin n) : + torusL (constF n phase^3*(variableF i/variableF j))≠0 := by + let e:=variableExponent i-variableExponent j + let D : Laurent n:=sineL e (phase^5)*sineL e (phase^6) + have hev : evalLaurent D=torusL (constF n phase^3*(variableF i/variableF j)) := by + simp only [D,evalLaurent,map_mul,torusL] + rw [sineL_map _ _ (pow_ne_zero _ phase_ne_zero),sineL_map _ _ (pow_ne_zero _ phase_ne_zero), + show (algebraMap (SpectralRing n) (SpectralField n)) (monomialL e (phase^5))= + constF n (phase^5)*(variableF i/variableF j) from map_monomialL_sub_variable j i _, + show (algebraMap (SpectralRing n) (SpectralField n)) (monomialL e (phase^6))= + constF n (phase^6)*(variableF i/variableF j) from map_monomialL_sub_variable j i _] + simp only [constF,map_pow] + congr 1 <;> congr 1 <;> ring + have hf : flatEval n D=flatEval n (rowDenominator i) := by + change (flatEval n (sineL e (phase^(5:ℤ))*sineL e (phase^(6:ℤ))))=_ + simp only [rowDenominator,map_mul,flatEval_sine_phase] + rw [←hev] + apply (IsFractionRing.to_map_eq_zero_iff.not).2 + intro h + exact flatEval_rowDenominator_ne_zero i (by rw [←hf,h,map_zero]) + + + +theorem insertedNode_move {n : ℕ} (i j : Fin n) : + normalizedVacuum (insertedNodeWeights i j.succ)= + (localR (PartialColumn.rowPosition j.val (show j.val+2≤n+1 by omega)) + (torusWeights (constF n phase^3 * (variableF i/variableF j)))).mulVec + (normalizedVacuum (insertedNodeWeights i j.castSucc)) := by + let a : Fin (n+1):=j.castSucc + let b : Fin (n+1):=j.succ + let x : Fin (n+1) → SpectralField n := Fin.insertNth b (variableF i)⁻¹ (fun k => constF n phase^3/variableF k) + let z := constF n phase^3*(variableF i/variableF j) + have h₀ : x a=constF n phase^3/variableF j := by + have h : b.succAbove j=a := by + rw [Fin.succAbove_of_castSucc_lt] + exact Fin.castSucc_lt_succ + rw [←h] + exact Fin.insertNth_apply_succAbove .. + have h₁ : x b=(variableF i)⁻¹ := Fin.insertNth_apply_same .. + have hw : (fun k => torusWeights (x k))=insertedNodeWeights i b := by + funext k + refine Fin.succAboveCases b ?_ (fun l => ?_) k <;> + simp only [x,insertedNodeWeights,Fin.insertNth_apply_same,Fin.insertNth_apply_succAbove,spectralWeights] + have hx : z*x b=x a := by + rw [h₀,h₁] + dsimp only [z] + field_simp [variableF_ne_zero] + have hL₀ : torusL (x a)≠0 := by + rw [h₀,←rowDenominator_map]; exact rowDenominator_map_ne_zero j + have hL₁ : torusL (x b)≠0 := by + rw [h₁,←inverseRowDenominator_map]; exact inverseRowDenominator_map_ne_zero i + have hswap : (insertedNodeWeights i b) ∘ Equiv.swap a b=insertedNodeWeights i a := + Fin.insertNth_swap_adjacent a b rfl _ _ + have hh := normalizedVacuum_torus_exchange j.val (show j.val+2≤n+1 by omega) x z + (mul_ne_zero (pow_ne_zero _ (constF_phase_ne_zero _)) + (div_ne_zero (variableF_ne_zero _) (variableF_ne_zero _))) + (by change x b≠0; rw [h₁]; exact inv_ne_zero (variableF_ne_zero i)) + (torusL_deletion_ratio_ne_zero i j) hL₁ hL₀ hx + (by rw [hw]; exact insertedNode_regular i b) + (by change VacuumRegular ((fun k => torusWeights (x k)) ∘ Equiv.swap a b) + rw [hw,hswap]; exact insertedNode_regular i a) + rw [hw] at hh + have hs : (fun k => torusWeights (x (Equiv.swap ⟨j.val,by omega⟩ ⟨j.val+1,by omega⟩ k)))= + insertedNodeWeights i a := by + change (fun k => torusWeights (x k)) ∘ Equiv.swap a b=insertedNodeWeights i a + rw [hw,hswap] + rw [hs] at hh + exact hh + + + + + + + + + +def movingBoxes {n : ℕ} (i : Fin n) : ℕ → Matrix (Pairing (n+1)) (Pairing (n+1)) (SpectralField n) + | 0 => 1 + | k+1 => if h : i.val < k ∧ k < n then + localR (PartialColumn.rowPosition k (by omega)) + (torusWeights (constF n phase^3*(variableF i/variableF ⟨k,h.2⟩))) * movingBoxes i k + else movingBoxes i k + +lemma movingBoxes_initial {n : ℕ} (i : Fin n) (k : ℕ) (hk : k ≤ i.val+1) : + movingBoxes i k=1 := by + induction k with + | zero => rfl + | succ k ih => rw [movingBoxes, dite_eq_right (by omega),ih (by omega)] + +lemma insertedNode_moved {n : ℕ} (i : Fin n) (k : ℕ) + (hk : i.val+1 ≤ k) (hkn : k ≤ n) : + normalizedVacuum (insertedNodeWeights i ⟨k,by omega⟩)= + (movingBoxes i k).mulVec (normalizedVacuum (insertedNodeWeights i i.succ)) := by + induction k, hk using Nat.le_induction with + | base => + rw [movingBoxes_initial i _ le_rfl,Matrix.one_mulVec] + rfl + | succ k hk ih => + have hstep:=insertedNode_move i (⟨k,show k spectralWeights (n+1) (i.succAbove k)))) := by + rw [←insertedNodeWeights_last] + have h:=insertedNode_moved i (n+1) (by omega) le_rfl + rw [insertedNode_deletion] at h + exact h + + + + + + + +def topPerm {n : ℕ} (σ : Equiv.Perm (Fin n)) : Equiv.Perm (Fin (n+1)) := + σ.viaEmbedding Fin.castSuccEmb + +@[simp] lemma topPerm_cast {n : ℕ} (σ : Equiv.Perm (Fin n)) (i : Fin n) : + topPerm σ i.castSucc=(σ i).castSucc := + Equiv.Perm.viaEmbedding_apply σ Fin.castSuccEmb i + +@[simp] lemma topPerm_last {n : ℕ} (σ : Equiv.Perm (Fin n)) : + topPerm σ (Fin.last n)=Fin.last n := by + apply Equiv.Perm.viaEmbedding_apply_of_notMem + rintro ⟨i,hi⟩ + exact Fin.castSucc_ne_last i hi + +@[simp] lemma permSpectral_deletionNode {n : ℕ} (σ : Equiv.Perm (Fin n)) (i : Fin n) : + permSpectral σ (deletionNode i)=deletionNode (σ i) := by simp [deletionNode] + +@[simp] lemma permSpectral_deletionBeta {n : ℕ} (σ : Equiv.Perm (Fin n)) (i : Fin n) : + permSpectral σ (deletionBeta i)=deletionBeta (σ i) := by simp [deletionBeta,map_div₀] + +lemma permSpectral_nodalWeights {n : ℕ} (σ : Equiv.Perm (Fin n)) (i : Fin n) : + (fun j => (nodalWeights i j).map (permSpectral σ))= + (fun j => nodalWeights (σ i) (topPerm σ j)) := by + funext j + induction j using Fin.lastCases with + | last => simp [nodalWeights,map_div₀] + | cast j => simp [nodalWeights] + +lemma scalarPolynomial_eval_reindex {K : Type*} [Field K] {n : ℕ} + (f : ℂ →+* K) (a : Fin n → K) (σ : Equiv.Perm (Fin n)) (dd rr : ℂ) (hd : dd≠0) : + MvPolynomial.eval₂Hom f (a ∘ σ) (scalarPolynomial n dd rr hd)= + MvPolynomial.eval₂Hom f a (scalarPolynomial n dd rr hd) := by + rw [←MvPolynomial.eval₂Hom_rename,scalarPolynomial_rename] + +lemma permSpectral_nodalScalar {n : ℕ} (σ : Equiv.Perm (Fin n)) (i : Fin n) : + permSpectral σ (nodalScalar i)=nodalScalar (σ i) := by + have hc : (permSpectral σ).comp (algebraMap ℂ (SpectralField n))= + algebraMap ℂ (SpectralField n) := by + ext z + exact permSpectral_const σ z + have hv : (fun j : Fin (n+1) => permSpectral σ ((Fin.snoc spectralA (deletionBeta i) : Fin (n+1) → SpectralField n) j))= + (Fin.snoc spectralA (deletionBeta (σ i)) : Fin (n+1) → SpectralField n) ∘ topPerm σ := by + funext j + induction j using Fin.lastCases with + | last => simp + | cast j => simp + rw [nodalScalar,MvPolynomial.map_eval₂Hom,hc,hv,scalarPolynomial_eval_reindex] + rfl + +lemma nodal_regular_reindex {n : ℕ} (σ : Equiv.Perm (Fin n)) (i : Fin n) : + VacuumRegular (fun j => nodalWeights (σ i) (topPerm σ j)) := by + rw [←permSpectral_nodalWeights] + exact (nodal_regular i).map (permSpectral σ) (nodalWeights i) + +lemma permSpectral_nodalVacuum {n : ℕ} (σ : Equiv.Perm (Fin n)) (i : Fin n) + (p : Pairing (n+1)) : + permSpectral σ (nodalVacuum i p)=nodalScalar (σ i)* + normalizedVacuum (fun j => nodalWeights (σ i) (topPerm σ j)) p := by + rw [nodalVacuum,map_mul,permSpectral_nodalScalar] + have hh:=congrFun (normalizedVacuum_map (permSpectral σ) (nodalWeights i) (nodal_regular i)) p + rw [permSpectral_nodalWeights] at hh + rw [hh] + +end + + + + + +noncomputable section + + + +def deletionPerm {n : ℕ} (i : Fin (n+1)) : Equiv.Perm (Fin (n+2)) := + Equiv.ofBijective (twoCons i.castSucc (Fin.last (n+1)) (fun j => (i.succAbove j).castSucc)) + (Finite.injective_iff_bijective.mp (by + intro a b h + induction a using Fin.cases with + | zero => + induction b using Fin.cases with + | zero => rfl + | succ b => + induction b using Fin.cases with + | zero => exact (Fin.castSucc_ne_last i (by simp at h)).elim + | succ b => + have hh : i=i.succAbove b := (by simp at h) + exact (Fin.succAbove_ne i b hh.symm).elim + | succ a => + induction a using Fin.cases with + | zero => + induction b using Fin.cases with + | zero => exact (Fin.castSucc_ne_last i (by simpa using h.symm)).elim + | succ b => + induction b using Fin.cases with + | zero => rfl + | succ b => exact (Fin.castSucc_ne_last (i.succAbove b) (by simpa using h.symm)).elim + | succ a => + induction b using Fin.cases with + | zero => + have hh : i.succAbove a=i := (by simp at h) + exact (Fin.succAbove_ne i a hh).elim + | succ b => + induction b using Fin.cases with + | zero => exact (Fin.castSucc_ne_last (i.succAbove a) (by simp at h)).elim + | succ b => + have hh : i.succAbove a=i.succAbove b := (by simpa using h) + exact congrArg (fun j : Fin n => j.succ.succ) (Fin.succAbove_right_injective hh))) + +lemma deletionPerm_tuple {K : Type*} {n : ℕ} (i : Fin (n+1)) (a : Fin (n+1) → K) (b : K) : + (Fin.snoc a b) ∘ deletionPerm i=twoCons (a i) b (fun k => a (i.succAbove k)) := by + funext j + induction j using Fin.cases with + | zero => simp [deletionPerm] + | succ j => + induction j using Fin.cases with + | zero => simp [deletionPerm] + | succ j => simp [deletionPerm] + +lemma scalarPolynomial_snoc_delete_reindex {K : Type*} [Field K] {n : ℕ} (f : ℂ →+* K) + (i : Fin (n+1)) (a : Fin (n+1) → K) (b : K) (dd rr : ℂ) (hd : dd≠0) : + MvPolynomial.eval₂Hom f (Fin.snoc a b) (scalarPolynomial (n+2) dd rr hd)= + MvPolynomial.eval₂Hom f (twoCons (a i) b (fun k => a (i.succAbove k))) + (scalarPolynomial (n+2) dd rr hd) := by + rw [←deletionPerm_tuple,scalarPolynomial_eval_reindex] + +end +end CriticalStrip.Diagram + +end OAI diff --git a/lean/OAI/Combinatorics/StripMass/NodalScalarDeletion.lean b/lean/OAI/Combinatorics/StripMass/NodalScalarDeletion.lean new file mode 100644 index 0000000000000000000000000000000000000000..928576e0e21d3e31fc70c7ad4cc8d58f90c2a381 --- /dev/null +++ b/lean/OAI/Combinatorics/StripMass/NodalScalarDeletion.lean @@ -0,0 +1,535 @@ +import Mathlib +import OAI.Combinatorics.StripMass.NodalRegularity + +namespace OAI + +/-! Critical honeycomb strip paths, polynomial identities and crossing mass. -/ + + + +namespace CriticalStrip.Diagram +noncomputable section +open Finset +open scoped Classical + +lemma spectralA_injective (n : ℕ) : Function.Injective (@spectralA n) := by + intro i j h + by_contra hij + rw [spectralA_shiftedCosine,spectralA_shiftedCosine] at h + exact shiftedCosine_ne i j hij _ _ (zpow_ne_zero _ phase_ne_zero) h + +lemma spectralA_ne_beta {n : ℕ} (i j : Fin n) : spectralA j≠deletionBeta i := by + by_cases hij : j=i + · subst j; exact spectralA_ne_deletionBeta i + · rw [spectralA_shiftedCosine,deletionBeta_shiftedCosine] + exact shiftedCosine_ne j i hij _ _ (zpow_ne_zero _ phase_ne_zero) + +def deletionScalarTuple {n : ℕ} (i : Fin (n+1)) : Fin (n+2) → SpectralField (n+1) := + twoCons (spectralA i) (deletionBeta i) (fun k => spectralA (i.succAbove k)) + +lemma deletionScalarTuple_injective {n : ℕ} (i : Fin (n+1)) : + Function.Injective (deletionScalarTuple i) := by + rw [deletionScalarTuple,←deletionPerm_tuple] + apply Function.Injective.comp _ (deletionPerm i).injective + intro j k h + induction j using Fin.lastCases with + | last => + induction k using Fin.lastCases with + | last => rfl + | cast k => exact (spectralA_ne_beta i k (by simpa using h.symm)).elim + | cast j => + induction k using Fin.lastCases with + | last => exact (spectralA_ne_beta i j (by simpa using h)).elim + | cast k => exact congrArg Fin.castSucc (spectralA_injective _ (by simpa using h)) + +lemma spectralA_discriminant_ne {n : ℕ} (i j : Fin n) (hij : i≠j) : + discriminant (constF n d) (spectralA i) (spectralA j)≠0 := by + rw [spectralA_shiftedCosine,spectralA_shiftedCosine] + exact shiftedCosine_discriminant_ne i j hij _ _ + +lemma beta_spectralA_discriminant_ne {n : ℕ} (i j : Fin n) (hij : i≠j) : + discriminant (constF n d) (deletionBeta i) (spectralA j)≠0 := by + rw [deletionBeta_shiftedCosine,spectralA_shiftedCosine] + exact shiftedCosine_discriminant_ne i j hij _ _ + +lemma deletionScalarTuple_discriminant {n : ℕ} (i : Fin (n+1)) + (j k : Fin (n+2)) (hjk : j≠k) + (hp : ¬((j=0 ∧ k=1) ∨ (j=1 ∧ k=0))) : + discriminant (constF (n+1) d) (deletionScalarTuple i j) (deletionScalarTuple i k)≠0 := by + induction j using Fin.cases with + | zero => + induction k using Fin.cases with + | zero => exact (hjk rfl).elim + | succ k => + induction k using Fin.cases with + | zero => exact (hp (Or.inl ⟨rfl,by simp⟩)).elim + | succ k => + exact spectralA_discriminant_ne i (i.succAbove k) (Fin.succAbove_ne i k).symm + | succ j => + induction j using Fin.cases with + | zero => + induction k using Fin.cases with + | zero => exact (hp (Or.inr ⟨by simp,rfl⟩)).elim + | succ k => + induction k using Fin.cases with + | zero => exact (hjk rfl).elim + | succ k => + exact beta_spectralA_discriminant_ne i (i.succAbove k) (Fin.succAbove_ne i k).symm + | succ j => + induction k using Fin.cases with + | zero => + exact spectralA_discriminant_ne (i.succAbove j) i (Fin.succAbove_ne i j) + | succ k => + induction k using Fin.cases with + | zero => + rw [discriminant_symm] + exact beta_spectralA_discriminant_ne i (i.succAbove j) (Fin.succAbove_ne i j).symm + | succ k => + exact spectralA_discriminant_ne _ _ (fun he => hjk + (congrArg (fun x : Fin n => x.succ.succ) (Fin.succAbove_right_injective he))) + + + +theorem nodalScalar_deletion {n : ℕ} (i : Fin (n+1)) : + nodalScalar i=(spectralA i+deletionBeta i+constF (n+1) rho)* + (∏ j : Fin n, (spectralA (i.succAbove j)-shiftedCosine i (phase^(-9:ℤ)))* + (spectralA (i.succAbove j)-shiftedCosine i (phase^(9:ℤ)))) * + MvPolynomial.eval₂Hom (algebraMap ℂ (SpectralField (n+1))) + (fun j => spectralA (i.succAbove j)) (scalarPolynomial n d rho (by exact_mod_cast d_ne_zero)) := by + rw [nodalScalar,scalarPolynomial_snoc_delete_reindex] + exact scalarPolynomial_delete_roots (algebraMap ℂ (SpectralField (n+1))) n d rho _ _ _ _ _ _ + (deletionScalarTuple_injective i) (spectralA_roots i) (deletionBeta_roots i) + (deletionScalarTuple_discriminant i) + + + + + + + + +def deletionDataFactor {n : ℕ} (i : Fin (n+1)) : SpectralField (n+1) := + (spectralA i+deletionBeta i+constF (n+1) rho)* + ∏ j : Fin n, (spectralA (i.succAbove j)-shiftedCosine i (phase^(-9:ℤ)))* + (spectralA (i.succAbove j)-shiftedCosine i (phase^(9:ℤ))) + +lemma nodalScalar_factor_smaller {n : ℕ} (i : Fin (n+1)) : + nodalScalar i=deletionDataFactor i*insertSpectral i (spectralNormalization n) := by + rw [nodalScalar_deletion,insertSpectral_normalization] + congr 1 + apply scalarPolynomial_eval + · exact (spectralA_injective _).comp (Fin.succAbove_right_injective) + · intro j k hjk + exact spectralA_discriminant_ne _ _ (Fin.succAbove_right_injective.ne hjk) + +lemma insertSpectral_rationalVacuum {n : ℕ} (i : Fin (n+1)) : + (fun p => insertSpectral i (rationalVacuum n p))= + insertSpectral i (spectralNormalization n) • + normalizedVacuum (fun j => spectralWeights (n+1) (i.succAbove j)) := by + funext p + simp only [rationalVacuum,map_mul,insertSpectral_vacuum,Pi.smul_apply,smul_eq_mul] + + + +theorem nodalVacuum_interpolation_data {n : ℕ} (i : Fin (n+1)) : + nodalVacuum i = deletionDataFactor i • + (movingBoxes i (n+1)).mulVec + ((deletionMap i.val (show i.val+2≤n+2 by omega)).mulVec + (fun p => insertSpectral i (rationalVacuum n p))) := by + change nodalScalar i • normalizedVacuum (nodalWeights i)=_ + rw [nodalVacuum_movingBoxes,nodalScalar_factor_smaller,insertSpectral_rationalVacuum, + Matrix.mulVec_smul,Matrix.mulVec_smul,smul_smul] + +end + + + + + +noncomputable section +open scoped Classical + + +def rawLocal {K : Type*} [CommRing K] {n : ℕ} (r : Position n) (w : Tile → K) : + Matrix (Pairing n) (Pairing n) K := + ∑ t : Tile, w t • optionMatrix (fun p => p.tileStep r.left r.right r.adjacent t) + +lemma rawLocal_weights {K : Type*} [CommRing K] {n : ℕ} (r : Position n) (w : Weights K) : + rawLocal r w.tile=localR r w := rfl + +lemma rawLocal_smul {K : Type*} [CommRing K] {n : ℕ} (r : Position n) + (a : K) (w : Tile → K) : rawLocal r (fun t => a*w t)=a • rawLocal r w := by + simp only [rawLocal,Finset.smul_sum,smul_smul] + + +def torusNumerator {n : ℕ} (z : SpectralField n) : Tile → SpectralField n + | .vacant => torusL z + | .cap | .cup => constF n d*torusSin z + | .vertical₀ | .vertical₁ => constF n d*torusSin (constF n phase^3/z) + | .diagonal₀ | .diagonal₁ => torusSin z*torusSin (constF n phase^3/z) + | .verticalPair => torusSin (constF n phase^3/z)*torusSin (constF n phase^2/z) + | .capCup => torusSin (z/constF n phase)*torusSin z + +lemma torusNumerator_eq {n : ℕ} (z : SpectralField n) (hL : torusL z≠0) (t : Tile) : + torusNumerator z t=torusL z*(torusWeights z).tile t := by + cases t <;> simp only [torusNumerator,torusWeights,Weights.tile] + all_goals field_simp + + + +theorem movingBox_cleared {n m : ℕ} (i j : Fin n) (r : Position m) : + ((spectralA j-shiftedCosine i (phase^(-9:ℤ)))* + (spectralA j-shiftedCosine i (phase^(9:ℤ)))) • + localR r (torusWeights (constF n phase^3*(variableF i/variableF j))) = + (-4*torusSin (variableF i*variableF j/constF n phase^6)* + torusSin (constF n phase^3*(variableF i*variableF j))) • + rawLocal r (torusNumerator (constF n phase^3*(variableF i/variableF j))) := by + rw [movingBox_scalar_cancellation,←smul_smul] + congr 1 + rw [←rawLocal_weights,←rawLocal_smul] + congr 1 + funext t + exact (torusNumerator_eq _ (torusL_deletion_ratio_ne_zero i j) t).symm + +end + + + + + +noncomputable section +open scoped Classical + +variable {K L ι : Type*} [CommRing K] [CommRing L] [Fintype ι] [DecidableEq ι] + +def matrixPrefix {n : ℕ} (A : Fin n → Matrix ι ι K) : ℕ → Matrix ι ι K + | 0 => 1 + | k+1 => if h:k a i • A i) k= + (∏ j∈Finset.range k,if h:j simp [matrixPrefix] + | succ k ih => + rw [matrixPrefix,Finset.prod_range_succ,matrixPrefix] + by_cases hk:k a i • A i) n=(∏ i,a i) • matrixPrefix A n := by + rw [matrixPrefix_smul_partial,←Finset.prod_fin_eq_prod_range] + +lemma matrixPrefix_map (f : K →+* L) {n : ℕ} (A : Fin n → Matrix ι ι K) (k : ℕ) : + (matrixPrefix A k).map f=matrixPrefix (fun i => (A i).map f) k := by + induction k with + | zero => simp [matrixPrefix] + | succ k ih => + rw [matrixPrefix,matrixPrefix] + split_ifs with hk + · rw [Matrix.map_mul,ih] + · exact ih + +end + + + + + +noncomputable section + +lemma rho_eq_two_c_d : rho=2*c*d := by + have hc : 2*C*c=d := by + have h₁:=Real.cos_add lambda (3*lambda) + have h₂:=Real.cos_sub lambda (3*lambda) + have he₁ : lambda+3*lambda=Real.pi/2 := by simp [lambda]; ring + have he₂ : lambda-3*lambda=-(2*lambda) := by ring + rw [he₁,Real.cos_pi_div_two] at h₁ + rw [he₂,Real.cos_neg] at h₂ + change 0=C*c-Real.sin lambda*Real.sin (3*lambda) at h₁ + change d=C*c+Real.sin lambda*Real.sin (3*lambda) at h₂ + linarith + rw [rho_eq_inv_two_C] + apply (div_eq_iff (by intro h; rw [h,zero_mul] at hc; exact d_ne_zero hc.symm)).mpr + linear_combination -2*d*hc-2*d_sq + + +theorem deletion_occupied_sine_cancellation {n : ℕ} (i : Fin n) : + spectralA i+deletionBeta i+constF n rho= + 4*constF n c*torusSin (deletionNode i)* + torusSin (constF n phase^3/variableF i) := by + have hq:=constF_phase_ne_zero n + have hi:=variableF_ne_zero i + have hβ : deletionBeta i=torusCos (variableF i^2*constF n phase^3) := by + unfold deletionBeta deletionNode + congr 1 + field_simp + have hs:=torusCos_sum (variableF i^2) (constF n phase^3) + (pow_ne_zero _ hi) (pow_ne_zero _ hq) + rw [torusCos_phase_pow] at hs + change spectralA i+torusCos (variableF i^2*constF n phase^3)= + 2*torusCos (variableF i^2)*constF n c at hs + have hp:=torusSin_product (deletionNode i) (constF n phase^3/variableF i) + (mul_ne_zero hi (pow_ne_zero _ hq)) (div_ne_zero (pow_ne_zero _ hq) hi) + have he₁ : deletionNode i/(constF n phase^3/variableF i)=variableF i^2 := by + unfold deletionNode + field_simp + have he₂ : deletionNode i*(constF n phase^3/variableF i)=constF n phase^6 := by + unfold deletionNode + field_simp + rw [he₁,he₂,torusCos_phase_pow] at hp + simp only [Nat.cast_ofNat,cos_six_lambda,Complex.ofReal_neg,constF,map_neg] at hp + have hr:=congrArg (fun x : ℝ => constF n (x:ℂ)) rho_eq_two_c_d + simp only [Complex.ofReal_mul,Complex.ofReal_ofNat,constF,map_mul,map_ofNat] at hr + rw [hβ] + unfold constF at * + linear_combination hs+hr-2*(algebraMap ℂ (SpectralField n)) (c:ℂ)*hp + + + + + + +open scoped Classical + + +def movingStep {n : ℕ} (i j : Fin n) : Matrix (Pairing (n+1)) (Pairing (n+1)) (SpectralField n) := + if i rfl + | succ k ih => + rw [movingBoxes,matrixPrefix] + by_cases hk:k insertSpectral i (rationalVacuum n p))) := by + rw [nodalVacuum_interpolation_data,deletionDataFactor,←scalarPairFactor_product] + rw [←smul_smul,←Matrix.smul_mulVec,reducedMoving_product,Matrix.smul_mulVec,smul_smul] + +end + + + + + +noncomputable section +open Finset +open scoped Classical + + +theorem rationalNodalPolynomial_at_node {n : ℕ} (p : Pairing (n+1)) (i : Fin n) : + (if p.Occupied (Fin.last n) then torusSin (deletionNode i) else 1) * + (rationalNodalPolynomial n p).eval (deletionBeta i) = nodalVacuum i p := by + have hinj := (deletionBeta_injective n).injOn (s := (univ : Finset (Fin n))) + by_cases hp : p.Occupied (Fin.last n) + · simp only [rationalNodalPolynomial, hp, ite_true] + rw [Lagrange.eval_interpolate_at_node _ hinj (mem_univ _)] + field_simp [deletionNode_sine_ne_zero i] + · simp only [rationalNodalPolynomial, hp, ite_false, one_mul, Polynomial.eval_add, + Polynomial.eval_mul, Polynomial.eval_C, Lagrange.eval_nodal_at_node (mem_univ _), + mul_zero, zero_add] + exact Lagrange.eval_interpolate_at_node _ hinj (mem_univ _) + +theorem rationalNodalPolynomial_degree (n : ℕ) : LastDegree n (rationalNodalPolynomial n) := by + intro p k hk + have hinj := (deletionBeta_injective n).injOn (s := (univ : Finset (Fin n))) + by_cases hp : p.Occupied (Fin.last n) + · simp only [rationalNodalPolynomial, hp, ite_true] at hk ⊢ + apply Polynomial.coeff_eq_zero_of_degree_lt + have hdeg := Lagrange.degree_interpolate_lt + (fun i => nodalVacuum i p / torusSin (deletionNode i)) hinj + simp only [card_univ, Fintype.card_fin] at hdeg + exact hdeg.trans_le (by exact_mod_cast hk) + · simp only [rationalNodalPolynomial, hp, ite_false] at hk ⊢ + rw [Polynomial.coeff_add, Polynomial.coeff_C_mul] + have hi := Lagrange.degree_interpolate_lt (fun i => nodalVacuum i p) hinj + have hn := Lagrange.degree_nodal (s := (univ : Finset (Fin n))) (v := @deletionBeta n) + simp only [card_univ, Fintype.card_fin] at hi hn + rw [Polynomial.coeff_eq_zero_of_degree_lt (hi.trans_le (by exact_mod_cast Nat.le_of_lt hk)), + Polynomial.coeff_eq_zero_of_degree_lt (hn.trans_lt (by exact_mod_cast hk)), mul_zero, add_zero] + +theorem rationalNodalPolynomial_leading {n : ℕ} (p : Pairing n) : + (rationalNodalPolynomial n p.padTop).coeff n = rationalVacuum n p := by + simp only [rationalNodalPolynomial, Pairing.padTop_not_occupied_last, ite_false, + Polynomial.coeff_add, Polynomial.coeff_C_mul] + rw [Pairing.padTop, Pairing.restrict_map] + have hnod : (Lagrange.nodal univ (@deletionBeta n)).coeff n = 1 := by + simpa only [Lagrange.natDegree_nodal, card_univ, Fintype.card_fin] using + (Lagrange.nodal_monic (s := (univ : Finset (Fin n))) (v := @deletionBeta n)).coeff_natDegree + rw [hnod, mul_one, Polynomial.coeff_eq_zero_of_degree_lt, add_zero] + simpa only [card_univ, Fintype.card_fin] using + Lagrange.degree_interpolate_lt (s := univ) (fun i => nodalVacuum i (p.map Fin.castSuccOrderEmb)) + (deletionBeta_injective n).injOn + +end + + + + + +noncomputable section +open scoped Classical + +lemma deletionBeta_eq {n : ℕ} (i : Fin n) : + deletionBeta i=torusCos (constF n phase^3*variableF i^2) := by + unfold deletionBeta deletionNode + congr 1 + field_simp + +lemma deletionBeta_difference {n : ℕ} (i j : Fin n) : + deletionBeta i-deletionBeta j= + -2*torusSin (constF n phase^3*(variableF i*variableF j))* + torusSin (variableF i/variableF j) := by + have hi:=variableF_ne_zero i + have hj:=variableF_ne_zero j + have hq:=constF_phase_ne_zero n + have h:=torusSin_product (constF n phase^3*(variableF i*variableF j)) + (variableF i/variableF j) + (mul_ne_zero (pow_ne_zero _ hq) (mul_ne_zero hi hj)) (div_ne_zero hi hj) + have he₁ : (constF n phase^3*(variableF i*variableF j))/(variableF i/variableF j)= + constF n phase^3*variableF j^2 := by field_simp + have he₂ : (constF n phase^3*(variableF i*variableF j))*(variableF i/variableF j)= + constF n phase^3*variableF i^2 := by field_simp + rw [he₁,he₂,←deletionBeta_eq,←deletionBeta_eq] at h + linear_combination h + +def ordinaryFactor {n : ℕ} (i j : Fin n) : SpectralField n := + if j=i then 1 else -2*torusSin (variableF i/variableF j) + +lemma deletionBeta_product {n : ℕ} (i : Fin n) : + ((Finset.univ.erase i).prod (fun j : Fin n => deletionBeta i-deletionBeta j))= + (∏ j,reflectionFactor i j)*(∏ j,ordinaryFactor i j) := by + rw [←Finset.prod_mul_distrib] + rw [←Finset.prod_erase_mul (Finset.univ : Finset (Fin n)) + (fun j => reflectionFactor i j*ordinaryFactor i j) (Finset.mem_univ i)] + simp only [reflectionFactor,ordinaryFactor,ite_true,mul_one] + apply Finset.prod_congr rfl + intro j hj + have hij: j≠i := (Finset.mem_erase.mp hj).1 + rw [ite_eq_right hij,ite_eq_right hij,deletionBeta_difference] + ring + +lemma reflectionOrdinary_product_ne_zero {n : ℕ} (i : Fin n) : + (∏ j,reflectionFactor i j)≠0 ∧ (∏ j,ordinaryFactor i j)≠0 := by + apply mul_ne_zero_iff.mp + rw [←deletionBeta_product] + apply Finset.prod_ne_zero_iff.mpr + intro j hj + exact sub_ne_zero.mpr ((deletionBeta_injective n).ne (Ne.symm (Finset.mem_erase.mp hj).1)) + +def reducedNodalHead {n : ℕ} (i : Fin n) (occupied : Prop) [Decidable occupied] : SpectralField n := + if occupied then 4*constF n c*torusSin (constF n phase^3/variableF i) + else spectralA i+deletionBeta i+constF n rho + + +def reducedNodalDatum {n : ℕ} (i : Fin (n+1)) (p : Pairing (n+2)) : SpectralField (n+1) := + reducedNodalHead i (p.Occupied (Fin.last (n+1))) * + (matrixPrefix (reducedMovingStep i) (n+1)).mulVec + ((deletionMap i.val (show i.val+2≤n+2 by omega)).mulVec + (fun q => insertSpectral i (rationalVacuum n q))) p + +lemma reducedNodalDatum_eq {n : ℕ} (i : Fin (n+1)) (p : Pairing (n+2)) : + nodalVacuum i p/(if p.Occupied (Fin.last (n+1)) then torusSin (deletionNode i) else 1)= + (∏ j,reflectionFactor i j)*reducedNodalDatum i p := by + have h:=congrFun (nodalVacuum_reduced_data i) p + simp only [Pi.smul_apply,smul_eq_mul] at h + rw [h] + unfold reducedNodalDatum reducedNodalHead + by_cases hp:p.Occupied (Fin.last (n+1)) + · rw [ite_eq_left hp,ite_eq_left hp,deletion_occupied_sine_cancellation] + field_simp [deletionNode_sine_ne_zero i] + · rw [ite_eq_right hp,ite_eq_right hp,div_one] + ring + +lemma nodalWeight_reduced {n : ℕ} (i : Fin (n+1)) (p : Pairing (n+2)) : + Lagrange.nodalWeight Finset.univ deletionBeta i * + (nodalVacuum i p/(if p.Occupied (Fin.last (n+1)) then torusSin (deletionNode i) else 1))= + reducedNodalDatum i p/(∏ j,ordinaryFactor i j) := by + rw [reducedNodalDatum_eq,Lagrange.nodalWeight,Finset.prod_inv_distrib,deletionBeta_product] + have h:=reflectionOrdinary_product_ne_zero i + field_simp [h.1,h.2] + + + +theorem nodal_interpolate_reduced {n : ℕ} (p : Pairing (n+2)) : + Lagrange.interpolate Finset.univ deletionBeta + (fun i : Fin (n+1) => nodalVacuum i p/ + (if p.Occupied (Fin.last (n+1)) then torusSin (deletionNode i) else 1))= + ∑ i : Fin (n+1), Polynomial.C (reducedNodalDatum i p/(∏ j,ordinaryFactor i j))* + Lagrange.nodal (Finset.univ.erase i) deletionBeta := by + rw [Lagrange.interpolate_eq_nodalWeight_mul_nodal_div_X_sub_C] + apply Finset.sum_congr rfl + intro i hi + rw [←Lagrange.nodal_erase_eq_nodal_div hi] + rw [mul_right_comm,←map_mul,nodalWeight_reduced] + +end +end CriticalStrip.Diagram + +end OAI diff --git a/lean/OAI/Combinatorics/StripMass/NodalTorusValue.lean b/lean/OAI/Combinatorics/StripMass/NodalTorusValue.lean new file mode 100644 index 0000000000000000000000000000000000000000..f44dc814a023b5b17e659ad30efb35d1f3731d89 --- /dev/null +++ b/lean/OAI/Combinatorics/StripMass/NodalTorusValue.lean @@ -0,0 +1,532 @@ +import Mathlib +import OAI.Combinatorics.StripMass.PairSelfNode + +namespace OAI + +/-! Critical honeycomb strip paths, polynomial identities and crossing mass. -/ + + + +namespace CriticalStrip.Diagram +noncomputable section +open scoped Classical + +lemma mappedNodal_leading {n m:ℕ} + (P:Pairing (n+1) → Polynomial (Laurent n)) + (hP:∀p,(P p).map (algebraMap (SpectralRing n) (SpectralField n))=rationalNodalPolynomial n p) + (z:Fin n → SpectralField m) (hz:∀i,z i≠0) + (hL:∀i,torusL (constF m phase^3/z i)≠0) + (hreg:VacuumRegular (fun i =>torusWeights (constF m phase^3/z i))) + (p:Pairing n) : + ((P p.padTop).map (torusEvaluation z hz).toRingHom).coeff n= + scalarValue (algebraMap ℂ (SpectralField m)) (fun i =>torusCos ((z i)^2/constF m phase^3))* + normalizedVacuum (fun i =>torusWeights (constF m phase^3/z i)) p := by + rw [Polynomial.coeff_map] + have h:=RationalAt.algebraMap (φ:=(torusEvaluation z hz).toRingHom) + (F:=SpectralField n) ((P p.padTop).coeff n) + have he:=congrArg (fun Q:Polynomial (SpectralField n) =>Q.coeff n) (hP p.padTop) + rw [Polynomial.coeff_map,rationalNodalPolynomial_leading] at he + rw [he] at h + exact h.unique (rationalAt_torusVacuum z hz hL hreg p) + +lemma mappedNodal_degree {n m:ℕ} + (P:Pairing (n+1) → Polynomial (Laurent n)) + (hP:∀p,(P p).map (algebraMap (SpectralRing n) (SpectralField n))=rationalNodalPolynomial n p) + (φ:Laurent n →+* SpectralField m) : LastDegree n (fun p =>(P p).map φ) := by + exact (LastDegree.of_map (algebraMap (SpectralRing n) (SpectralField n)) (IsFractionRing.injective _ _) + (by simpa only [hP] using rationalNodalPolynomial_degree n)).map φ + +lemma lastValue_mul_poly {K:Type*} [CommRing K] {n:ℕ} + (b s:K) (F:Polynomial K) (P:Pairing (n+1) → Polynomial K) : + lastValue (RingHom.id K) b s (fun p =>F*P p)=F.eval b • lastValue (RingHom.id K) b s P := by + funext p + simp only [lastValue,Polynomial.eval₂_id,Polynomial.eval_mul,Pi.smul_apply,smul_eq_mul] + split_ifs <;> ring + +lemma mappedNodal_pair_node {n s:ℕ} (hs:s≤3) + (P:Pairing (n+3) → Polynomial (Laurent (n+2))) + (hP:∀p,(P p).map (algebraMap (SpectralRing (n+2)) (SpectralField (n+2)))=rationalNodalPolynomial (n+2) p) + (i:Fin (n+2)) (hi:i≠1) : + lastValue (RingHom.id (SpectralField (n+1))) (pairBeta n s i) (torusSin (deletionNode (pairIndex n i))) + (fun p =>(P p).map (pairEvaluation n s).toRingHom)= + scalarValue (algebraMap ℂ (SpectralField (n+1))) (Fin.snoc (pairCosines n s) (pairBeta n s i)) • + normalizedVacuum (pairNodeWeights n s i) := by + funext p + have hsine:=rationalAt_torusSin (pairEvaluation n s) (rationalAt_pair_deletionNode s i) + (mul_ne_zero (pairPoint_ne_zero n s i) (pow_ne_zero _ (constF_phase_ne_zero _))) + rw [pairPoint_of_ne i hi] at hsine + change RationalAt _ (torusSin (deletionNode i)) (torusSin (deletionNode (pairIndex n i))) at hsine + have he:RationalAt (pairEvaluation n s).toRingHom + ((rationalNodalPolynomial (n+2) p).eval (deletionBeta i)) + (((P p).map (pairEvaluation n s).toRingHom).eval (pairBeta n s i)) := by + rw [←hP] + exact RationalAt.eval_map _ (rationalAt_pair_deletionBeta s i) _ + have hsin:RationalAt (pairEvaluation n s).toRingHom + (if p.Occupied (Fin.last (n+2)) then torusSin (deletionNode i) else 1) + (if p.Occupied (Fin.last (n+2)) then torusSin (deletionNode (pairIndex n i)) else 1) := by + split_ifs + · exact hsine + · exact RationalAt.one + have hh:=hsin.mul he + rw [rationalNodalPolynomial_at_node] at hh + simpa only [lastValue,Polynomial.eval₂_id,Pi.smul_apply,smul_eq_mul,ite_mul,one_mul] using + hh.unique (rationalAt_pair_nodalVacuum hs i hi p) + + + + + + + +lemma deletePoint_cosines (n:ℕ) : + (fun i:Fin n =>torusCos ((deletePoint n i)^2/constF (n+1) phase^3))= + fun i:Fin n =>fcos i.succ (-3) := by + funext i + have he:=phaseCosine i.succ 0 + norm_num only at he + simpa only [deletePoint,zpow_zero,one_mul] using he + +def deleteEvaluation (n:ℕ) : Laurent n →ₐ[ℂ] SpectralField (n+1) := + torusEvaluation (deletePoint n) (fun i =>variableF_ne_zero i.succ) + +lemma deleteMapped_leading {n:ℕ} + (Q:Pairing (n+1) → Polynomial (Laurent n)) + (hQ:∀p,(Q p).map (algebraMap (SpectralRing n) (SpectralField n))=rationalNodalPolynomial n p) + (p:Pairing n) : + ((Q p.padTop).map (deleteEvaluation n).toRingHom).coeff n= + scalarValue (algebraMap ℂ (SpectralField (n+1))) (fun i:Fin n =>fcos i.succ (-3))* + normalizedVacuum (deleteWeights n) p := by + have h:=mappedNodal_leading Q hQ (deletePoint n) (fun i =>variableF_ne_zero i.succ) + (fun i =>torusL_phaseRow_ne_zero i.succ 3 (by omega)) (deleteWeights_regular n) p + rw [deletePoint_cosines] at h + exact h + +lemma deleteMapped_node {n:ℕ} + (Q:Pairing (n+1) → Polynomial (Laurent n)) + (hQ:∀p,evalLaurent (lastLaurent p (Q p))=rationalVacuum (n+1) p) + (i:Fin (n+1)) : + lastValue (RingHom.id (SpectralField (n+1))) (deletionBeta i) (torusSin (deletionNode i)) + (fun p =>(Q p).map (deleteEvaluation n).toRingHom)= + scalarValue (algebraMap ℂ (SpectralField (n+1))) + (Fin.snoc (fun j:Fin n =>fcos j.succ (-3)) (deletionBeta i)) • + normalizedVacuum (copiedNodeWeights (Fin.succ : Fin n → Fin (n+1)) i) := by + funext p + have he:=lastLaurent_regular_value Q hQ (deletePoint n) (fun j =>variableF_ne_zero j.succ) + (deletionNode i) (mul_ne_zero (variableF_ne_zero i) (pow_ne_zero _ (constF_phase_ne_zero _))) (deletePoint_node_L i) + (by rw [deletePoint_node_weights]; exact copiedNode_regular _ _) p + have hc:(fun j =>torusCos (((Fin.snoc (deletePoint n) (deletionNode i) : Fin (n+1) → SpectralField (n+1)) j)^2/constF (n+1) phase^3))= + Fin.snoc (fun j:Fin n =>fcos j.succ (-3)) (deletionBeta i) := by + funext j + induction j using Fin.lastCases with + | last => simp only [Fin.snoc_last]; rfl + | cast j => simp only [Fin.snoc_castSucc]; exact congrFun (deletePoint_cosines n) j + rw [hc,deletePoint_node_weights] at he + change (if p.Occupied (Fin.last n) then torusSin (deletionNode i) else 1) * + Polynomial.eval (deletionBeta i) ((Q p).map (deleteEvaluation n).toRingHom) = _ at he + simpa only [lastValue,Polynomial.eval₂_id,Pi.smul_apply,smul_eq_mul,ite_mul,one_mul,deleteEvaluation] using he + +lemma pairMapped_delete_leading {n:ℕ} + (P:Pairing (n+3) → Polynomial (Laurent (n+2))) + (hP:∀p,(P p).map (algebraMap (SpectralRing (n+2)) (SpectralField (n+2)))=rationalNodalPolynomial (n+2) p) + (p:Pairing (n+2)) : + ((P p.padTop).map (pairEvaluation n 3).toRingHom).coeff (n+2)= + deletePairScalar n*scalarValue (algebraMap ℂ (SpectralField (n+1))) (fun i:Fin n =>fcos i.succ (-3))* + (deletionMap 0 (show 2≤n+2 by omega)).mulVec (normalizedVacuum (deleteWeights n)) p := by + have hw:(fun i =>torusWeights (constF (n+1) phase^3/pairPoint n 3 i))=pairEarlierWeights n 3 := + funext (fun i =>congrArg torusWeights (pairArgument (by omega) i)) + have h:=mappedNodal_leading P hP (pairPoint n 3) (pairPoint_ne_zero n 3) + (pairEarlier_L (by omega)) (by rw [hw]; exact pairEarlier_regular n 3) p + rw [show (fun i =>torusCos ((pairPoint n 3 i)^2/constF (n+1) phase^3))=pairCosines n 3 from funext (fun i =>pairPoint_cosine i), + hw,scalar_pair_delete,normalizedVacuum_pair_delete] at h + exact h + +def deletePairPolynomial (n:ℕ) : Polynomial (SpectralField (n+1)) := + Polynomial.C (deletePairScalar n)*((Polynomial.X-Polynomial.C (fcos 0 (-9)))*(Polynomial.X-Polynomial.C (fcos 0 9))) + +lemma deletePairPolynomial_degree (n:ℕ) : (deletePairPolynomial n).natDegree≤2 := by + apply (Polynomial.natDegree_mul_le ..).trans + simp only [Polynomial.natDegree_C,zero_add] + apply (Polynomial.natDegree_mul_le ..).trans + simp only [Polynomial.natDegree_X_sub_C]; omega + +lemma deletePairPolynomial_top (n:ℕ) : (deletePairPolynomial n).coeff 2=deletePairScalar n := by + rw [deletePairPolynomial,Polynomial.coeff_C_mul] + have hp:(Polynomial.X-Polynomial.C (fcos (0:Fin (n+1)) (-9)))*(Polynomial.X-Polynomial.C (fcos 0 9))= + Polynomial.X^2-Polynomial.C (fcos 0 (-9)+fcos 0 9)*Polynomial.X+Polynomial.C (fcos 0 (-9)*fcos 0 9) := by simp only [map_add,map_mul]; ring + rw [hp] + simp + +lemma deletePairPolynomial_eval {n:ℕ} (b:SpectralField (n+1)) : + (deletePairPolynomial n).eval b=deletePairScalar n*((b-fcos 0 (-9))*(b-fcos 0 9)) := by + simp [deletePairPolynomial] + + + + + + + +lemma phase_four_ne_one : phase^4≠(1:ℂ) := by + intro h + have hh:=congrArg (fun z:ℂ =>z^2) h + rw [←pow_mul,show 4*2=8 by omega,phase_eight] at hh + norm_num at hh + +lemma pairBeta_head_ne {n s:ℕ} (hs:s=2 ∨ s=3) : + deletionBeta (0:Fin (n+1))≠fcos 0 (2*(s:ℤ)+3) := by + intro h + rw [deletionBeta_shiftedCosine] at h + have hh:=shiftedCosine_parameter 0 _ _ h + rw [show 2*(s:ℤ)+3=3+2*s by ring,zpow_add₀ phase_ne_zero] at hh + have he:phase^((2:ℤ)*s)=1 := mul_left_cancel₀ (zpow_ne_zero 3 phase_ne_zero) (by simpa using hh.symm) + rcases hs with rfl|rfl + · exact phase_four_ne_one (by simpa using he) + · exact phase_six_ne_one (by simpa using he) + +lemma pairBeta_injective (n s:ℕ) (hs:s=2 ∨ s=3) : Function.Injective (pairBeta n s) := by + apply Fin.cons_injective_of_injective + · rintro ⟨v,hv⟩ + induction v using Fin.cases with + | zero => exact pairBeta_head_ne hs hv.symm + | succ v => exact (deletionBeta_injective (n+1)).ne (Fin.succ_ne_zero v) hv + · apply Fin.cons_injective_of_injective + · rintro ⟨v,hv⟩ + change deletionBeta v.succ=fcos 0 (2*(s:ℤ)+3) at hv + rw [deletionBeta_shiftedCosine] at hv + exact shiftedCosine_ne v.succ 0 (Fin.succ_ne_zero v) _ _ (zpow_ne_zero _ phase_ne_zero) hv + · exact (deletionBeta_injective (n+1)).comp (Fin.succ_injective n) + + + + + + + + + +theorem rationalNodalPolynomial_pair_delete {n:ℕ} + (W:Pairing (n+1) → Laurent (n+1)) (hW:∀p,evalLaurent (W p)=rationalVacuum (n+1) p) + (Q:Pairing (n+1) → Polynomial (Laurent n)) + (hQ:∀p,(Q p).map (algebraMap (SpectralRing n) (SpectralField n))=rationalNodalPolynomial n p) + (hprev:∀p,evalLaurent (lastLaurent p (Q p))=rationalVacuum (n+1) p) + (P:Pairing (n+3) → Polynomial (Laurent (n+2))) + (hP:∀p,(P p).map (algebraMap (SpectralRing (n+2)) (SpectralField (n+2)))=rationalNodalPolynomial (n+2) p) : + (fun p =>(P p).map (pairEvaluation n 3).toRingHom)= + fun p =>deletePairPolynomial n* + matrixPolynomial (deletionMap 0 (show 2≤n+3 by omega)) + (fun q =>(Q q).map (deleteEvaluation n).toRingHom) p := by + let Q':Pairing (n+1) → Polynomial (SpectralField (n+1)):=fun p =>(Q p).map (deleteEvaluation n).toRingHom + let M:Matrix (Pairing (n+3)) (Pairing (n+1)) (SpectralField (n+1)):=deletionMap 0 (by omega) + have hQd:LastDegree n Q':=mappedNodal_degree Q hQ _ + have hM:LastMatrix M:=deletionMap_last 0 (show 2≤n+2 by omega) + have hMd:LastDegree n (matrixPolynomial M Q'):=hM.degree Q' hQd + have hright:LastDegree (n+2) (fun p =>deletePairPolynomial n*matrixPolynomial M Q' p):= + LastDegree.mul_poly _ hMd _ (deletePairPolynomial_degree n) + apply lastPolynomial_unique _ _ (mappedNodal_degree P hP _) hright _ (pairBeta_injective n 3 (Or.inr rfl)) + · intro p + rw [pairMapped_delete_leading P hP p] + rw [LastDegree.mul_poly_top _ hMd _ (deletePairPolynomial_degree n) p,deletePairPolynomial_top] + rw [hM.leading (deletionMap 0 (show 2≤n+2 by omega)) (fun p q =>deletionMap_padTop 0 (by omega) p q)] + have he:(fun q:Pairing n =>(Q' q.padTop).coeff n)= + scalarValue (algebraMap ℂ (SpectralField (n+1))) (fun i:Fin n =>fcos i.succ (-3)) • + normalizedVacuum (deleteWeights n) := funext (deleteMapped_leading Q hQ) + rw [he,Matrix.mulVec_smul] + simp only [Pi.smul_apply,smul_eq_mul] + ring + · intro p i + by_cases hi:i=1 + · subst i + rw [show pairBeta n 3 1=pairEvaluation n 3 (betaL 1) from (pairEvaluation_betaL 3 1).symm, + rationalNodalPolynomial_pair_self W hW P hP 3 (Or.inr rfl)] + rw [pairEvaluation_betaL,Polynomial.eval_mul,deletePairPolynomial_eval] + change 0=deletePairScalar n*((fcos 0 9-fcos 0 (-9))*(fcos 0 9-fcos 0 9))*_ + ring + · have he: lastValue (RingHom.id (SpectralField (n+1))) (pairBeta n 3 i) (torusSin (deletionNode (pairIndex n i))) + (fun p =>(P p).map (pairEvaluation n 3).toRingHom)= + lastValue (RingHom.id (SpectralField (n+1))) (pairBeta n 3 i) (torusSin (deletionNode (pairIndex n i))) + (fun p =>deletePairPolynomial n*matrixPolynomial M Q' p) := by + rw [mappedNodal_pair_node (by omega) P hP i hi,lastValue_mul_poly,hM.lastValue] + rw [pairBeta_of_ne i hi,deleteMapped_node Q hprev] + rw [Matrix.mulVec_smul,smul_smul] + rw [normalizedVacuum_pairNode_delete,deletePairPolynomial_eval] + have hs:=scalar_pair_delete_snoc (n:=n) (deletionBeta (pairIndex n i)) + rw [hs] + have hp:=congrFun he p + by_cases ho:p.Occupied (Fin.last (n+2)) + · simp only [lastValue,Polynomial.eval₂_id,ho,ite_true] at hp + exact mul_left_cancel₀ (deletionNode_sine_ne_zero _) hp + · simpa only [lastValue,Polynomial.eval₂_id,ho,ite_false] using hp + + + + + + + +def mergeZ (n:ℕ) : SpectralField (n+1) := constF (n+1) phase/variableF 0 +def mergePoint (n:ℕ) : Fin (n+1) → SpectralField (n+1) := + Fin.cons (constF (n+1) phase*variableF 0) (deletePoint n) +def mergeNewWeights (n:ℕ) : Fin (n+1) → Weights (SpectralField (n+1)) := + Fin.cons (torusWeights (constF (n+1) phase*mergeZ n)) (deleteWeights n) + +def mergeExponent (n:ℕ) : Fin (n+1) → ℕ := Fin.cons 2 (fun _ =>3) + +lemma mergeNewWeights_phase (n:ℕ) : mergeNewWeights n= + fun i =>torusWeights (constF (n+1) phase^mergeExponent n i/variableF i) := by + funext i + induction i using Fin.cases with + | zero => simp only [mergeNewWeights,Fin.cons_zero,mergeExponent,mergeZ]; congr 1; ring + | succ i => rfl + +lemma mergeExponent_le (n:ℕ) (i:Fin (n+1)) : mergeExponent n i≤3 := by + induction i using Fin.cases <;> simp [mergeExponent] + +lemma mergeExponent_mixed {n:ℕ} (i j:Fin (n+1)) + (hi:mergeExponent n i≠0 ∧ mergeExponent n i≠3) + (hj:mergeExponent n j≠0 ∧ mergeExponent n j≠3) : i=j := by + induction i using Fin.cases with + | succ i => exact (hi.2 rfl).elim + | zero => induction j using Fin.cases with + | zero => rfl + | succ j => exact (hj.2 rfl).elim + +lemma mergeNewWeights_regular (n:ℕ) : VacuumRegular (mergeNewWeights n) := by + rw [mergeNewWeights_phase] + exact phaseRows_regular id (mergeExponent n) (mergeExponent_le n) mergeExponent_mixed + +lemma mergeZ_ne_zero (n:ℕ) : mergeZ n≠0 := div_ne_zero (constF_phase_ne_zero _) (variableF_ne_zero _) +lemma mergeZ_L (n:ℕ) : torusL (mergeZ n)≠0 := by + simpa only [mergeZ,pow_one] using torusL_phaseRow_ne_zero (0:Fin (n+1)) 1 (by omega) +lemma mergeZ_one_L (n:ℕ) : torusL (constF (n+1) phase*mergeZ n)≠0 := by + have he:constF (n+1) phase*mergeZ n=constF (n+1) phase^2/variableF 0 := by unfold mergeZ; ring + rw [he]; exact torusL_phaseRow_ne_zero _ _ (by omega) +lemma mergeZ_two_L (n:ℕ) : torusL (constF (n+1) phase^2*mergeZ n)≠0 := by + have he:constF (n+1) phase^2*mergeZ n=constF (n+1) phase^3/variableF 0 := by unfold mergeZ; ring + rw [he]; exact torusL_phaseRow_ne_zero _ _ (by omega) + +lemma pairEarlier_merge (n:ℕ) : pairEarlierWeights n 2= + Fin.cons (torusWeights (constF (n+1) phase^2*mergeZ n)) + (Fin.cons (torusWeights (mergeZ n)) (deleteWeights n)) := by + funext i + induction i using Fin.cases with + | zero => + simp only [pairEarlierWeights,pairExponent,pairIndex,Fin.cons_zero] + rw [ite_eq_right (by intro h; have := congrArg Fin.val h; simp at this)] + congr 1; unfold mergeZ; ring + | succ i => induction i using Fin.cases with + | zero => simp [pairEarlierWeights,pairExponent,pairIndex,mergeZ] + | succ i => + have hi : i.succ.succ≠(1:Fin (n+2)) := by intro h; have := congrArg Fin.val h; simp at this + simp [pairEarlierWeights,pairExponent,pairIndex,hi,deleteWeights] + +lemma normalizedVacuum_pair_merge (n:ℕ) : + normalizedVacuum (pairEarlierWeights n 2)= + (mergeMap 0 (show 2≤n+2 by omega)).mulVec (normalizedVacuum (mergeNewWeights n)) := by + have h:=normalizedVacuum_merge_cons (deleteWeights n) (mergeZ n) (mergeZ_ne_zero n) + (mergeZ_L n) (mergeZ_one_L n) (mergeZ_two_L n) + (by rw [←pairEarlier_merge]; exact pairEarlier_regular n 2) (mergeNewWeights_regular n) + rwa [←pairEarlier_merge] at h + +lemma mergePoint_ne_zero (n:ℕ) (i:Fin (n+1)) : mergePoint n i≠0 := by + induction i using Fin.cases with + | zero => exact mul_ne_zero (constF_phase_ne_zero _) (variableF_ne_zero _) + | succ i => exact variableF_ne_zero _ + +lemma mergePoint_weights (n:ℕ) : + (fun i =>torusWeights (constF (n+1) phase^3/mergePoint n i))=mergeNewWeights n := by + funext i + induction i using Fin.cases with + | zero => + change torusWeights (constF (n+1) phase^3/(constF (n+1) phase*variableF 0))=_ + change _=torusWeights (constF (n+1) phase*(constF (n+1) phase/variableF 0)) + congr 1 + field_simp [constF_phase_ne_zero,variableF_ne_zero] + | succ i => rfl + +lemma mergePoint_argument (n:ℕ) (i:Fin (n+1)) : + constF (n+1) phase^3/mergePoint n i=constF (n+1) phase^(mergeExponent n i)/variableF i := by + induction i using Fin.cases with + | zero => + change constF (n+1) phase^3/(constF (n+1) phase*variableF 0)=constF (n+1) phase^2/variableF 0 + field_simp [constF_phase_ne_zero,variableF_ne_zero] + | succ i => rfl + +lemma mergePoint_L (n:ℕ) (i:Fin (n+1)) : torusL (constF (n+1) phase^3/mergePoint n i)≠0 := by + rw [mergePoint_argument] + exact torusL_phaseRow_ne_zero i _ (mergeExponent_le n i) + +lemma mergePoint_cosines (n:ℕ) : + (fun i =>torusCos ((mergePoint n i)^2/constF (n+1) phase^3))= + Fin.cons (fcos 0 (-1)) (fun j:Fin n =>fcos j.succ (-3)) := by + funext i + induction i using Fin.cases with + | zero => + have he:=phaseCosine (0:Fin (n+1)) 1 + norm_num only at he + simpa only [mergePoint,Fin.cons_zero,zpow_one] using he + | succ i => + have he:=phaseCosine i.succ 0 + norm_num only at he + simpa only [mergePoint,deletePoint,Fin.cons_succ,zpow_zero,one_mul] using he + + + + + + + +def mergeNodeWeights {n:ℕ} (i:Fin (n+1)) : Fin (n+2) → Weights (SpectralField (n+1)) := + Fin.snoc (mergeNewWeights n) (torusWeights ((variableF i)⁻¹)) + +lemma mergeNode_regular {n:ℕ} (i:Fin (n+1)) : VacuumRegular (mergeNodeWeights i) := by + have hw:mergeNodeWeights i=fun j =>torusWeights + (constF (n+1) phase^((Fin.snoc (mergeExponent n) 0 : Fin (n+2) → ℕ) j)/ + variableF ((Fin.snoc id i : Fin (n+2) → Fin (n+1)) j)) := by + funext j + induction j using Fin.lastCases with + | last => simp [mergeNodeWeights] + | cast j => simpa only [mergeNodeWeights,Fin.snoc_castSucc,id_eq] using congrFun (mergeNewWeights_phase n) j + rw [hw] + apply phaseRows_regular + · intro j + induction j using Fin.lastCases with + | last => simp + | cast j => simpa only [Fin.snoc_castSucc] using mergeExponent_le n j + · intro j k hj hk + induction j using Fin.lastCases with + | last => exact (hj.1 (by simp)).elim + | cast j => induction k using Fin.lastCases with + | last => exact (hk.1 (by simp)).elim + | cast k => + simp only [Fin.snoc_castSucc] at hj hk + exact congrArg Fin.castSucc (mergeExponent_mixed j k hj hk) + +lemma pairNode_merge {n:ℕ} (i:Fin (n+2)) : pairNodeWeights n 2 i= + Fin.cons (torusWeights (constF (n+1) phase^2*mergeZ n)) + (Fin.cons (torusWeights (mergeZ n)) + (copiedNodeWeights (Fin.succ : Fin n → Fin (n+1)) (pairIndex n i))) := by + rw [pairNodeWeights,pairEarlier_merge] + rw [←Fin.cons_snoc_eq_snoc_cons,←Fin.cons_snoc_eq_snoc_cons] + rfl + +lemma mergeNode_cons {n:ℕ} (i:Fin (n+1)) : mergeNodeWeights i= + Fin.cons (torusWeights (constF (n+1) phase*mergeZ n)) + (copiedNodeWeights (Fin.succ : Fin n → Fin (n+1)) i) := by + unfold mergeNodeWeights mergeNewWeights + rw [←Fin.cons_snoc_eq_snoc_cons] + rfl + +lemma normalizedVacuum_pairNode_merge {n:ℕ} (i:Fin (n+2)) : + normalizedVacuum (pairNodeWeights n 2 i)= + (mergeMap 0 (show 2≤n+3 by omega)).mulVec + (normalizedVacuum (mergeNodeWeights (pairIndex n i))) := by + rw [pairNode_merge,mergeNode_cons] + exact normalizedVacuum_merge_cons (copiedNodeWeights (Fin.succ : Fin n → Fin (n+1)) (pairIndex n i)) + (mergeZ n) (mergeZ_ne_zero n) (mergeZ_L n) (mergeZ_one_L n) (mergeZ_two_L n) + (by rw [←pairNode_merge i]; exact pairNode_regular n 2 i) + (by rw [←mergeNode_cons]; exact mergeNode_regular _) + +lemma mergePoint_node_weights {n:ℕ} (i:Fin (n+1)) : + (fun j =>torusWeights (constF (n+1) phase^3/ + (Fin.snoc (mergePoint n) (deletionNode i) : Fin (n+2) → SpectralField (n+1)) j)) =mergeNodeWeights i := by + funext j + induction j using Fin.lastCases with + | last => + simp only [Fin.snoc_last,mergeNodeWeights] + congr 1 + rw [deletionNode] + field_simp [constF_phase_ne_zero,variableF_ne_zero] + | cast j => simpa only [Fin.snoc_castSucc,mergeNodeWeights] using congrFun (mergePoint_weights n) j + +lemma mergePoint_node_L {n:ℕ} (i:Fin (n+1)) (j:Fin (n+2)) : + torusL (constF (n+1) phase^3/ + (Fin.snoc (mergePoint n) (deletionNode i) : Fin (n+2) → SpectralField (n+1)) j)≠0 := by + induction j using Fin.lastCases with + | last => + rw [Fin.snoc_last] + have he:constF (n+1) phase^3/deletionNode i=(variableF i)⁻¹ := by + rw [deletionNode]; field_simp [constF_phase_ne_zero,variableF_ne_zero] + rw [he] + simpa using torusL_phaseRow_ne_zero i 0 (by omega) + | cast j => simpa only [Fin.snoc_castSucc] using mergePoint_L n j + + + + + + + +def mergeEvaluation (n:ℕ) : Laurent (n+1) →ₐ[ℂ] SpectralField (n+1) := + torusEvaluation (mergePoint n) (mergePoint_ne_zero n) + +lemma mergeMapped_leading {n:ℕ} + (Q:Pairing (n+2) → Polynomial (Laurent (n+1))) + (hQ:∀p,(Q p).map (algebraMap (SpectralRing (n+1)) (SpectralField (n+1)))=rationalNodalPolynomial (n+1) p) + (p:Pairing (n+1)) : + ((Q p.padTop).map (mergeEvaluation n).toRingHom).coeff (n+1)= + scalarValue (algebraMap ℂ (SpectralField (n+1))) + (Fin.cons (fcos 0 (-1)) (fun i:Fin n =>fcos i.succ (-3)))* + normalizedVacuum (mergeNewWeights n) p := by + have h:=mappedNodal_leading Q hQ (mergePoint n) (mergePoint_ne_zero n) + (mergePoint_L n) (by rw [mergePoint_weights]; exact mergeNewWeights_regular n) p + rw [mergePoint_cosines,mergePoint_weights] at h + exact h + +lemma mergeMapped_node {n:ℕ} + (Q:Pairing (n+2) → Polynomial (Laurent (n+1))) + (hQ:∀p,evalLaurent (lastLaurent p (Q p))=rationalVacuum (n+2) p) + (i:Fin (n+1)) : + lastValue (RingHom.id (SpectralField (n+1))) (deletionBeta i) (torusSin (deletionNode i)) + (fun p =>(Q p).map (mergeEvaluation n).toRingHom)= + scalarValue (algebraMap ℂ (SpectralField (n+1))) + (Fin.snoc (Fin.cons (fcos 0 (-1)) (fun j:Fin n =>fcos j.succ (-3))) (deletionBeta i)) • + normalizedVacuum (mergeNodeWeights i) := by + funext p + have he:=lastLaurent_regular_value Q hQ (mergePoint n) (mergePoint_ne_zero n) + (deletionNode i) (mul_ne_zero (variableF_ne_zero i) (pow_ne_zero _ (constF_phase_ne_zero _))) (mergePoint_node_L i) + (by rw [mergePoint_node_weights]; exact mergeNode_regular _) p + have hc:(fun j =>torusCos (((Fin.snoc (mergePoint n) (deletionNode i) : Fin (n+2) → SpectralField (n+1)) j)^2/constF (n+1) phase^3))= + Fin.snoc (Fin.cons (fcos 0 (-1)) (fun j:Fin n =>fcos j.succ (-3))) (deletionBeta i) := by + funext j + induction j using Fin.lastCases with + | last => simp only [Fin.snoc_last]; rfl + | cast j => simp only [Fin.snoc_castSucc]; exact congrFun (mergePoint_cosines n) j + rw [hc,mergePoint_node_weights] at he + change (if p.Occupied (Fin.last (n+1)) then torusSin (deletionNode i) else 1) * + Polynomial.eval (deletionBeta i) ((Q p).map (mergeEvaluation n).toRingHom) = _ at he + simpa only [lastValue,Polynomial.eval₂_id,Pi.smul_apply,smul_eq_mul,ite_mul,one_mul,mergeEvaluation] using he + +lemma pairMapped_merge_leading {n:ℕ} + (P:Pairing (n+3) → Polynomial (Laurent (n+2))) + (hP:∀p,(P p).map (algebraMap (SpectralRing (n+2)) (SpectralField (n+2)))=rationalNodalPolynomial (n+2) p) + (p:Pairing (n+2)) : + ((P p.padTop).map (pairEvaluation n 2).toRingHom).coeff (n+2)= + mergePairScalar n*scalarValue (algebraMap ℂ (SpectralField (n+1))) + (Fin.cons (fcos 0 (-1)) (fun i:Fin n =>fcos i.succ (-3)))* + (mergeMap 0 (show 2≤n+2 by omega)).mulVec (normalizedVacuum (mergeNewWeights n)) p := by + have hw:(fun i =>torusWeights (constF (n+1) phase^3/pairPoint n 2 i))=pairEarlierWeights n 2 := + funext (fun i =>congrArg torusWeights (pairArgument (by omega) i)) + have h:=mappedNodal_leading P hP (pairPoint n 2) (pairPoint_ne_zero n 2) + (pairEarlier_L (by omega)) (by rw [hw]; exact pairEarlier_regular n 2) p + rw [show (fun i =>torusCos ((pairPoint n 2 i)^2/constF (n+1) phase^3))=pairCosines n 2 from funext (fun i =>pairPoint_cosine i), + hw,scalar_pair_merge,normalizedVacuum_pair_merge] at h + exact h + +def mergePairPolynomial (n:ℕ) : Polynomial (SpectralField (n+1)) := + Polynomial.C (mergePairScalar n)*(Polynomial.X+Polynomial.C (fcos 0 (-1))) + +lemma mergePairPolynomial_degree (n:ℕ) : (mergePairPolynomial n).natDegree≤1 := by + apply (Polynomial.natDegree_mul_le ..).trans + simp + +lemma mergePairPolynomial_top (n:ℕ) : (mergePairPolynomial n).coeff 1=mergePairScalar n := by + simp [mergePairPolynomial] + +lemma mergePairPolynomial_eval {n:ℕ} (b:SpectralField (n+1)) : + (mergePairPolynomial n).eval b=mergePairScalar n*(b+fcos 0 (-1)) := by + simp [mergePairPolynomial] + +end +end CriticalStrip.Diagram + +end OAI diff --git a/lean/OAI/Combinatorics/StripMass/NorthBijection.lean b/lean/OAI/Combinatorics/StripMass/NorthBijection.lean new file mode 100644 index 0000000000000000000000000000000000000000..0d89d5e52a2325ce1691e31332f035861e30a796 --- /dev/null +++ b/lean/OAI/Combinatorics/StripMass/NorthBijection.lean @@ -0,0 +1,526 @@ +import Mathlib +import OAI.Combinatorics.StripMass.ArchTrig +import OAI.Combinatorics.StripMass.HoneycombClip + +namespace OAI + +/-! Critical honeycomb strip paths, polynomial identities and crossing mass. -/ + + +namespace CriticalStrip +noncomputable section +open scoped Classical BigOperators +open Diagram + +namespace Diagram.ColumnChain +lemma read_ofFn {n m : ℕ} (h : Fin m → Configuration n) (k : Fin m) (j : Fin n) : + read (List.ofFn h) k.val j=h k j := by + simp only [read,List.getElem?_ofFn,k.isLt,dite_eq_left,Option.getD_some] +end Diagram.ColumnChain + +namespace SewnRectangle +variable {n m : ℕ} + +lemma clips_left (l r : Fin m → Configuration n) (D : HoneycombAssignment n) + (ht : D.tile=tile (List.ofFn l) (List.ofFn r)) : D.leftClip m=l := by + funext k j + change D.tile (-1-(k.val:ℤ),j.val)=l k j + rw [ht,tile_left,ColumnChain.read_ofFn] + +lemma clips_right (l r : Fin m → Configuration n) (D : HoneycombAssignment n) + (ht : D.tile=tile (List.ofFn l) (List.ofFn r)) : D.rightClip m=r := by + funext k j + change (D.tile ((k.val:ℤ),j.val)).horizontal=r k j + rw [ht,tile_right,ColumnChain.read_ofFn,Tile.horizontal_involutive] + +lemma fits_ofFn (l r : Fin m → Configuration n) (D : HoneycombAssignment n) + (ht : D.tile=tile (List.ofFn l) (List.ofFn r)) : D.Fits m := by + intro q hq + rw [ht] at hq + have hh:=tile_nonvacant_bounds _ _ q hq + simp only [List.length_ofFn] at hh + exact ⟨hh.1,hh.2.1⟩ +end SewnRectangle + + + +structure CrossTopArch (N : ℕ) where + left : ℕ + right : ℕ + arch : TopArchConfiguration N (-1-(left:ℤ)) right + +namespace CrossTopArch +variable {N : ℕ} + +@[ext] lemma ext {D E : CrossTopArch N} (h : D.arch.tile=E.arch.tile) : D=E := by + have hl := (D.arch.top (-1-(D.left:ℤ))).mpr (Or.inl rfl) + have hr := (D.arch.top D.right).mpr (Or.inr rfl) + rw [h,E.arch.top] at hl hr + have h₁ : D.left=E.left := by omega + have h₂ : D.right=E.right := by omega + cases D with + | mk l r D => + cases E with + | mk l' r' E => + dsimp at h₁ h₂; subst l' r' + congr 1 + exact TopArchConfiguration.ext (HoneycombAssignment.ext h) + +def Fits (D : CrossTopArch N) (m : ℕ) : Prop := D.arch.toHoneycombAssignment.Fits m + +def weight (D : CrossTopArch N) : ℝ := D.arch.toHoneycombAssignment.weight + +lemma exists_fits (D : CrossTopArch N) (hN : 1≤N) : ∃m,D.Fits m := + D.arch.toHoneycombAssignment.exists_fits (D.arch.tileSupport_finite hN (by omega)) + + +abbrev Bounded (N m : ℕ) := {D : CrossTopArch N // D.Fits m} + +end CrossTopArch + + + +structure NorthHistory (N m : ℕ) where + left : Fin m → Configuration (N+1) + right : Fin m → Configuration (N+1) + nzleft : ColumnChain.weight (SewnRectangle.leftWeights N) (List.ofFn left)≠0 + nzright : ColumnChain.weight (SewnRectangle.rightWeights N) (List.ofFn right)≠0 + realizes : ∃p q : Pairing (N+1), + ColumnChain.Runs (empty (N+1)) (List.ofFn left) p ∧ + ColumnChain.Runs (empty (N+1)) (List.ofFn right) q ∧ p.GluesAt (Fin.last N) q + +namespace NorthHistory +variable {N m : ℕ} + +@[ext] lemma ext {D E : NorthHistory N m} (hl : D.left=E.left) (hr : D.right=E.right) : D=E := by + cases D; cases E; cases hl; cases hr; rfl + +instance : Fintype (NorthHistory N m) := Fintype.ofInjective + (fun D=>(D.left,D.right)) (fun _ _ h=>ext (congrArg Prod.fst h) (congrArg Prod.snd h)) + +def leftState (h : NorthHistory N m) : Pairing (N+1) := Classical.choose h.realizes + +def rightState (h : NorthHistory N m) : Pairing (N+1) := + Classical.choose (Classical.choose_spec h.realizes) + +lemma runs_left (h : NorthHistory N m) : + ColumnChain.Runs (empty (N+1)) (List.ofFn h.left) h.leftState := + (Classical.choose_spec (Classical.choose_spec h.realizes)).1 + +lemma runs_right (h : NorthHistory N m) : + ColumnChain.Runs (empty (N+1)) (List.ofFn h.right) h.rightState := + (Classical.choose_spec (Classical.choose_spec h.realizes)).2.1 + +lemma glues (h : NorthHistory N m) : h.leftState.GluesAt (Fin.last N) h.rightState := + (Classical.choose_spec (Classical.choose_spec h.realizes)).2.2 + +lemma shape_left_exists (h : NorthHistory N m) : ∃kl : ℕ×ℕ, + (List.ofFn h.left).map (fun t=>t (Fin.last N))= + List.replicate kl.1 Tile.diagonal₁ ++ Tile.vertical₀::List.replicate kl.2 Tile.vacant := by + obtain ⟨k,l,hh⟩ := (ColumnChain.north_shape (fun _ : Fin N=>physicalWeights (2*Diagram.lambda)) + (List.ofFn h.left) h.leftState h.runs_left h.nzleft).1 h.glues.1 + exact ⟨(k,l),hh⟩ + +lemma shape_right_exists (h : NorthHistory N m) : ∃kl : ℕ×ℕ, + (List.ofFn h.right).map (fun t=>t (Fin.last N))= + List.replicate kl.1 Tile.diagonal₁ ++ Tile.vertical₀::List.replicate kl.2 Tile.vacant := by + obtain ⟨k,l,hh⟩ := (ColumnChain.north_shape (fun _ : Fin N=>physicalWeights Diagram.lambda) + (List.ofFn h.right) h.rightState h.runs_right h.nzright).1 ((h.glues.2.1 _).mp h.glues.1) + exact ⟨(k,l),hh⟩ + +def ls (h : NorthHistory N m) : ℕ×ℕ := Classical.choose h.shape_left_exists + +def rs (h : NorthHistory N m) : ℕ×ℕ := Classical.choose h.shape_right_exists + +lemma ls_spec (h : NorthHistory N m) : + (List.ofFn h.left).map (fun t=>t (Fin.last N))= + List.replicate h.ls.1 Tile.diagonal₁ ++ Tile.vertical₀::List.replicate h.ls.2 Tile.vacant := + Classical.choose_spec h.shape_left_exists + +lemma rs_spec (h : NorthHistory N m) : + (List.ofFn h.right).map (fun t=>t (Fin.last N))= + List.replicate h.rs.1 Tile.diagonal₁ ++ Tile.vertical₀::List.replicate h.rs.2 Tile.vacant := + Classical.choose_spec h.shape_right_exists + + + +def toCross (h : NorthHistory N m) (hN : 1≤N) : CrossTopArch N where + left := h.ls.1 + right := h.rs.1 + arch := SewnRectangle.northArch (List.ofFn h.left) (List.ofFn h.right) + h.leftState h.rightState hN h.runs_left h.runs_right h.glues h.nzleft h.nzright + h.ls.1 h.ls.2 h.rs.1 h.rs.2 h.ls_spec h.rs_spec + +lemma toCross_extend (h : NorthHistory N m) (hN : 1≤N) : + ((h.toCross hN).arch.extend hN (by dsimp [toCross]; omega)).tile= + SewnRectangle.tile (List.ofFn h.left) (List.ofFn h.right) := by + exact congrArg HoneycombAssignment.tile + (SewnRectangle.northArch_extend (List.ofFn h.left) (List.ofFn h.right) + h.leftState h.rightState hN h.runs_left h.runs_right h.glues h.nzleft h.nzright + h.ls.1 h.ls.2 h.rs.1 h.rs.2 h.ls_spec h.rs_spec) + +lemma toCross_fits (h : NorthHistory N m) (hN : 1≤N) : (h.toCross hN).Fits m := by + have hf := SewnRectangle.fits_ofFn h.left h.right _ (h.toCross_extend hN) + intro q hq + have hj : q.2augmentedReversed_tile_nonneg n i (s i) + +lemma augmentedReversed_vacuum_block (n : ℕ) : + (restrictedColumn (augmentedReversedWeights n)).submatrix + (vacuumAugmentEmbedding n) (vacuumAugmentEmbedding n)= + restrictedColumn (fun _ : Fin n=>physicalWeights lambda) := by + ext q p + simpa only [augmentedReversedWeights,Fin.snoc_castSucc,restrictedColumn,Matrix.submatrix_apply, + vacuumAugmentEmbedding,Function.Embedding.trans_apply,Equiv.coe_toEmbedding,Function.Embedding.inl_apply, + sourceTopSplit_inl,Pairing.nonemptyPadTop] using + column_padTop (augmentedReversedWeights n) p.val q.val + +lemma augmentedReversed_source_block (n : ℕ) : + (restrictedColumn (augmentedReversedWeights n)).submatrix + (sourceAugmentEmbedding n) (sourceAugmentEmbedding n)= + sourceTransfer (fun _ : Fin n=>(physicalWeights lambda).tile) := by + ext q p + exact congrFun (congrFun (northInjection_column_blocks + (fun _ : Fin n=>physicalWeights lambda)) (.inr q)) (.inr p) + +theorem reversed_vacuum_summablePowers (n : ℕ) : + PositiveMatrix.SummablePowers (restrictedColumn (fun _ : Fin n=>physicalWeights lambda)) := by + have hh := (augmentedReversed_summablePowers n).submatrix + (augmentedReversed_nonnegative n).restricted (vacuumAugmentEmbedding n) + rw [augmentedReversed_vacuum_block] at hh + exact hh + +theorem reversed_source_summablePowers (n : ℕ) : + PositiveMatrix.SummablePowers (sourceTransfer (fun _ : Fin n=>(physicalWeights lambda).tile)) := by + have hh := (augmentedReversed_summablePowers n).submatrix + (augmentedReversed_nonnegative n).restricted (sourceAugmentEmbedding n) + rw [augmentedReversed_source_block] at hh + exact hh + +lemma reversed_column_nonnegative (n : ℕ) : + ColumnNonnegative (fun _ : Fin n=>physicalWeights lambda) := by + intro p q s hs + exact Finset.prod_nonneg fun i _=>physicalWeights_lambda_nonneg (s i) + +lemma reversed_source_nonnegative (n : ℕ) : + PositiveMatrix.Nonnegative (sourceTransfer (fun _ : Fin n=>(physicalWeights lambda).tile)) := by + rw [←augmentedReversed_source_block] + exact (augmentedReversed_nonnegative n).restricted.submatrix _ + +lemma reversed_angleScalar_ne_zero (n : ℕ) : angleScalar (fun _ : Fin n=>2*lambda)≠0 := by + rw [angleScalar,angleEvaluation_scalar] + simpa only [show 2*(2*lambda)-3*lambda=lambda by ring,C] using + scalarValue_homogeneous_ne_zero n + +lemma reversed_L_ne_zero : L (3*lambda-2*lambda)≠0 := by + rw [L_reflection] + simpa only [show 3*lambda-lambda=2*lambda by ring] using homogeneous_L_ne_zero + +theorem reversed_vacuum_eq_tsum (n : ℕ) (p : NonemptyPairing n) : + angleVacuum (fun _ : Fin n=>2*lambda) p.val= + ∑' k : ℕ,((restrictedColumn (fun _ : Fin n=>physicalWeights lambda))^k).mulVec + (injectionColumn (fun _ : Fin n=>physicalWeights lambda)) p := by + apply (reversed_vacuum_summablePowers n).stationary_eq_tsum + (w:=fun q=>angleVacuum (fun _ : Fin n=>2*lambda) q.val) (i:=p) + simpa only [show 3*lambda-2*lambda=lambda by ring] using + angleVacuum_restricted_stationary (fun _ : Fin n=>2*lambda) (fun _=>reversed_L_ne_zero) + (reversed_angleScalar_ne_zero n) + +theorem reversed_vacuum_nonneg (n : ℕ) (p : Pairing n) : + 0≤angleVacuum (fun _ : Fin n=>2*lambda) p := by + by_cases hp : p=empty n + · rw [hp,angleVacuum_empty _ (reversed_angleScalar_ne_zero n)] + exact zero_le_one + · rw [reversed_vacuum_eq_tsum n ⟨p,hp⟩] + exact tsum_nonneg fun k=>(reversed_column_nonnegative n).restricted.pow k |>.mulVec + (reversed_column_nonnegative n).injection _ + +theorem reversed_northSource_eq_tsum (n : ℕ) (p : SourcePairing n) : + angleNorthSource (fun _ : Fin n=>2*lambda) p= + ∑' k : ℕ,((sourceTransfer (fun _ : Fin n=>(physicalWeights lambda).tile))^k).mulVec + ((northSource (fun _ : Fin n=>(physicalWeights lambda).tile)).mulVec + (angleVacuum (fun _ : Fin n=>2*lambda))) p := by + apply (reversed_source_summablePowers n).stationary_eq_tsum + simpa only [show 3*lambda-2*lambda=lambda by ring] using + angleNorthSource_stationary (fun _ : Fin n=>2*lambda) (fun _=>reversed_L_ne_zero) + +theorem reversed_source_weighted_summable (n d : ℕ) (p q : SourcePairing n) : + Summable (fun k : ℕ=>(k:ℝ)^d* + ((sourceTransfer (fun _ : Fin n=>(physicalWeights lambda).tile))^k) p q) := + (reversed_source_summablePowers n).weighted (reversed_source_nonnegative n) d p q + + + + + + + + + +theorem angleVacuum_real {n : ℕ} (u : Fin n → ℝ) + (hL : ∀i,L (3*lambda-u i)≠0) (h : angleScalar u≠0) + (hs : PositiveMatrix.SummablePowers (restrictedColumn (fun i=>physicalWeights (3*lambda-u i)))) + (p : Pairing n) : + angleEvaluation u (polynomialVacuumVector n p)/angleScalar u=(angleVacuum u p:ℂ) := by + let z : Pairing n → ℝ := fun q=>(angleEvaluation u (polynomialVacuumVector n q)/angleScalar u).im + have hz : (transfer u).mulVec z=z := by + funext q + have hh:=congrArg (fun z : ℂ=>(z/angleScalar u).im) (congrFun (angle_rawVacuum_stationary u hL) q) + simpa only [Matrix.mulVec,dotProduct,Matrix.map_apply,Complex.ofRealHom_eq_coe,Finset.sum_div, + mul_div_assoc,Complex.im_sum,Complex.mul_im,Complex.ofReal_re,Complex.ofReal_im,zero_mul, + add_zero,z] using hh + have he : z (empty n)=0 := by + change (angleScalar u/angleScalar u).im=0 + rw [div_self h,Complex.one_im] + have hr : (restrictedColumn (fun i=>physicalWeights (3*lambda-u i))).mulVec (fun p=>z p.val)+0= + fun p=>z p.val := by + funext q + have hh:=congrFun hz q.val + rw [transfer,column_mulVec_nonempty,he,mul_zero,zero_add] at hh + simpa only [Pi.add_apply,Pi.zero_apply,add_zero] using hh + have hzero : (fun p : NonemptyPairing n=>z p.val)=0 := + hs.unique_stationary hr (by simp) + apply Complex.ext + · rfl + · change z p=0 + by_cases hp : p=empty n + · simpa only [hp] using he + · exact congrFun hzero ⟨p,hp⟩ + +theorem angleNorthSource_real {n : ℕ} (u : Fin n → ℝ) + (hL : ∀i,L (3*lambda-u i)≠0) (h : angleScalar u≠0) + (hv : PositiveMatrix.SummablePowers (restrictedColumn (fun i=>physicalWeights (3*lambda-u i)))) + (hs : PositiveMatrix.SummablePowers (sourceTransfer (fun i=>(physicalWeights (3*lambda-u i)).tile))) + (p : SourcePairing n) : + angleEvaluation u (polynomialNorthSource n p)/angleScalar u=(angleNorthSource u p:ℂ) := by + let z : SourcePairing n → ℝ := fun q=>(angleEvaluation u (polynomialNorthSource n q)/angleScalar u).im + have hr : (sourceTransfer (fun i=>(physicalWeights (3*lambda-u i)).tile)).mulVec z+0=z := by + funext q + have hh:=congrArg (fun z : ℂ=>(z/angleScalar u).im) (congrFun (angle_rawNorthSource_equation u hL) q) + simp only [Pi.add_apply,Matrix.mulVec,dotProduct,Matrix.map_apply,Complex.ofRealHom_eq_coe, + add_div,Finset.sum_div,mul_div_assoc,Complex.add_im,Complex.im_sum,Complex.mul_im, + Complex.ofReal_re,Complex.ofReal_im,zero_mul,add_zero,angleVacuum_real u hL h hv, + mul_zero,Finset.sum_const_zero] at hh + simpa only [Pi.add_apply,Pi.zero_apply,add_zero,Matrix.mulVec,dotProduct,z] using hh + have hzero : z=0 := hs.unique_stationary hr (by simp) + apply Complex.ext + · rfl + · exact congrFun hzero p + +lemma physical_northSource_real (n : ℕ) (p : SourcePairing n) : + angleEvaluation (fun _ : Fin n=>lambda) (polynomialNorthSource n p)/ + angleScalar (fun _ : Fin n=>lambda)=(angleNorthSource (fun _ : Fin n=>lambda) p:ℂ) := by + apply angleNorthSource_real _ (fun _=>homogeneous_L_ne_zero) (homogeneous_angleScalar_ne_zero n) + · simpa only [show 3*lambda-lambda=2*lambda by ring] using physical_vacuum_summablePowers n + · simpa only [show 3*lambda-lambda=2*lambda by ring] using physical_source_summablePowers n + +lemma reversed_northSource_real (n : ℕ) (p : SourcePairing n) : + angleEvaluation (fun _ : Fin n=>2*lambda) (polynomialNorthSource n p)/ + angleScalar (fun _ : Fin n=>2*lambda)=(angleNorthSource (fun _ : Fin n=>2*lambda) p:ℂ) := by + apply angleNorthSource_real _ (fun _=>reversed_L_ne_zero) (reversed_angleScalar_ne_zero n) + · simpa only [show 3*lambda-2*lambda=lambda by ring] using reversed_vacuum_summablePowers n + · simpa only [show 3*lambda-2*lambda=lambda by ring] using reversed_source_summablePowers n + +lemma angleEvaluation_reflect {n : ℕ} (u : Fin n → ℝ) (f : Laurent n) : + angleEvaluation u (reflectLaurent n f)=angleEvaluation (fun i=>3*lambda-u i) f := by + have hp (e : Fin n → ℤ) (s : Finset (Fin n)) : + phase^((3:ℤ)*∑i∈s,e i)=∏i∈s,(phase^(3:ℕ))^e i := by + induction s using Finset.induction_on with + | empty => simp + | @insert i s hi ih => + rw [Finset.sum_insert hi,Finset.prod_insert hi,mul_add,zpow_add₀ phase_ne_zero,ih, + _root_.zpow_mul] + simp only [zpow_ofNat] + have hh : (angleEvaluation u).toRingHom.comp (reflectLaurent n)= + (angleEvaluation (fun i=>3*lambda-u i)).toRingHom := by + apply AddMonoidAlgebra.ringHom_ext + · intro z + change angleEvaluation u (reflectLaurent n (monomialL 0 z))= + angleEvaluation (fun i=>3*lambda-u i) (monomialL 0 z) + rw [reflectLaurent_monomial] + simp only [Pi.zero_apply,Finset.sum_const_zero,mul_zero,zpow_zero,mul_one,neg_zero, + angleEvaluation_monomial,Finset.prod_const_one] + · intro e + change angleEvaluation u (reflectLaurent n (monomialL e 1))=_ + rw [reflectLaurent_monomial,angleEvaluation_monomial] + change (1*phase^(3*∑i,e i))*(∏i,anglePhase (u i)^(-e i))= + angleEvaluation (fun i=>3*lambda-u i) (monomialL e 1) + simp only [angleEvaluation_monomial,one_mul,anglePhase_sub, + show anglePhase (3*lambda)=phase^(3:ℕ) from anglePhase_nat_mul 3 _, + div_zpow,Finset.prod_div_distrib,_root_.zpow_neg,Finset.prod_inv_distrib,hp] + rfl + exact DFunLike.congr_fun hh f + +end + + + + + +noncomputable section +open scoped BigOperators Classical + + + +def realNorthSeparator (n : ℕ) : ℝ := + sourceGlue n (angleNorthSource (fun _ : Fin n=>2*lambda)) + (angleNorthSource (fun _ : Fin n=>lambda)) + +lemma physical_angleScalar (n : ℕ) : + angleScalar (fun _ : Fin n=>lambda)= + scalarValue (RingHom.id ℂ) (fun _ : Fin n=>(C:ℂ)) := by + rw [angleScalar,angleEvaluation_scalar] + simp only [show 2*lambda-3*lambda= -lambda by ring,Real.cos_neg,C] + +lemma reversed_angleScalar (n : ℕ) : + angleScalar (fun _ : Fin n=>2*lambda)= + scalarValue (RingHom.id ℂ) (fun _ : Fin n=>(C:ℂ)) := by + rw [angleScalar,angleEvaluation_scalar] + simp only [show 2*(2*lambda)-3*lambda=lambda by ring,C] + +lemma physical_polynomialNorthSource (n : ℕ) (p : SourcePairing n) : + angleEvaluation (fun _ : Fin n=>lambda) (polynomialNorthSource n p)= + scalarValue (RingHom.id ℂ) (fun _ : Fin n=>(C:ℂ)) * + (angleNorthSource (fun _ : Fin n=>lambda) p:ℂ) := by + have hh:=physical_northSource_real n p + rw [physical_angleScalar] at hh + exact (div_eq_iff (scalarValue_homogeneous_ne_zero n)).mp hh |>.trans (mul_comm _ _) + +lemma reversed_polynomialNorthSource (n : ℕ) (p : SourcePairing n) : + angleEvaluation (fun _ : Fin n=>2*lambda) (polynomialNorthSource n p)= + scalarValue (RingHom.id ℂ) (fun _ : Fin n=>(C:ℂ)) * + (angleNorthSource (fun _ : Fin n=>2*lambda) p:ℂ) := by + have hh:=reversed_northSource_real n p + rw [reversed_angleScalar] at hh + exact (div_eq_iff (scalarValue_homogeneous_ne_zero n)).mp hh |>.trans (mul_comm _ _) + +lemma polynomialNorthGluing_physical (n : ℕ) : + angleEvaluation (fun _ : Fin n=>lambda) (polynomialNorthGluing n)= + scalarValue (RingHom.id ℂ) (fun _ : Fin n=>(C:ℂ))^2 * (realNorthSeparator n:ℂ) := by + change (angleEvaluation (fun _ : Fin n=>lambda)).toRingHom + (sourceGlue n (fun p=>reflectLaurent n (polynomialNorthSource n p)) (polynomialNorthSource n))=_ + rw [sourceGlue_map] + let h := scalarValue (RingHom.id ℂ) (fun _ : Fin n=>(C:ℂ)) + have hv : (angleEvaluation (fun _ : Fin n=>lambda)).toRingHom ∘ polynomialNorthSource n= + h • (Complex.ofRealHom ∘ angleNorthSource (fun _ : Fin n=>lambda)) := by + funext p + exact physical_polynomialNorthSource n p + have hz : (angleEvaluation (fun _ : Fin n=>lambda)).toRingHom ∘ + (fun p=>reflectLaurent n (polynomialNorthSource n p))= + h • (Complex.ofRealHom ∘ angleNorthSource (fun _ : Fin n=>2*lambda)) := by + funext p + change angleEvaluation (fun _ : Fin n=>lambda) (reflectLaurent n (polynomialNorthSource n p))=_ + rw [angleEvaluation_reflect,show 3*lambda-lambda=2*lambda by ring] + exact reversed_polynomialNorthSource n p + rw [hv,hz] + rw [sourceGlue_scale,←sourceGlue_map,←pow_two] + rfl + +lemma archCandidate_physical (n : ℕ) : + angleEvaluation (fun _ : Fin n=>lambda) (archCandidate n)= + scalarArchNumerator (RingHom.id ℂ) (fun _ : Fin n=>(C:ℂ)) := by + change (angleEvaluation (fun _ : Fin n=>lambda)).toRingHom + (scalarArchNumerator (constantL n) rowCosineL)=_ + rw [map_scalarArchNumerator] + have hh : (angleEvaluation (fun _ : Fin n=>lambda)).toRingHom.comp (constantL n)=RingHom.id ℂ := by + ext z + exact angleEvaluation_constant _ _ + rw [hh] + congr 1 + funext i + exact (angleEvaluation_rowCosine (fun _ : Fin n=>lambda) i).trans (by + simp only [show 2*lambda-3*lambda= -lambda by ring,Real.cos_neg,C]) + + + +theorem realNorthSeparator_arch {n : ℕ} (hn : 1≤n) : + ∃ g : Polynomial ℝ, MonicProblem n g ∧ + realNorthSeparator n=(n:ℝ)*C-eta*g.coeff (n-1) := by + have hh:=congrArg (angleEvaluation (fun _ : Fin n=>lambda)) + (polynomialNorthGluing_eq_archCandidate n) + rw [polynomialNorthGluing_physical,archCandidate_physical] at hh + obtain ⟨g,hg,hnext⟩:=nextScalar_homogeneous hn + refine ⟨g,hg,?_⟩ + simp only [scalarArchNumerator,hnext,previousCoeff,show n≠0 by omega,ite_false, + Polynomial.coeff_C_mul,Polynomial.coeff_map,Complex.ofRealHom_eq_coe, + Finset.sum_const,Finset.card_univ,Fintype.card_fin,nsmul_eq_mul,RingHom.id_apply] at hh + have hc : (realNorthSeparator n:ℂ)=(n:ℂ)*(C:ℂ)-(2*(d:ℂ)-1)*(g.coeff (n-1):ℂ) := by + apply mul_left_cancel₀ (pow_ne_zero 2 (scalarValue_homogeneous_ne_zero n)) + rw [hh] + ring + exact_mod_cast hc + +end +end CriticalStrip.Diagram + +end OAI diff --git a/lean/OAI/Combinatorics/StripMass/NorthGluing.lean b/lean/OAI/Combinatorics/StripMass/NorthGluing.lean new file mode 100644 index 0000000000000000000000000000000000000000..c3d8625fb16e3187b339206f352493a86f9c243a --- /dev/null +++ b/lean/OAI/Combinatorics/StripMass/NorthGluing.lean @@ -0,0 +1,299 @@ +import Mathlib +import OAI.Combinatorics.StripMass.NorthMerging + +namespace OAI + +/-! Critical honeycomb strip paths, polynomial identities and crossing mass. -/ + + +namespace CriticalStrip.Diagram +noncomputable section +open scoped Classical BigOperators +lemma polynomialNorthGluing_box (n : ℕ) : + LaurentBox (polynomialNorthGluing n) (fun _ => 4*n) := by + rw [polynomialNorthGluing, sourceGlue_eq_sum] + apply LaurentBox.sum + intro p _ + apply LaurentBox.sum + intro q _ + split_ifs + · rw [one_mul] + convert (polynomialNorthSource_box n p).reflect.mul (polynomialNorthSource_box n q) using 1 + ext i + change 4*n = 2*n+2*n + omega + · simp only [zero_mul,mul_zero] + exact LaurentBox.zero _ + +lemma polynomialNorthGluing_reflection (n : ℕ) : + reflectLaurent n (polynomialNorthGluing n) = polynomialNorthGluing n := by + unfold polynomialNorthGluing + rw [sourceGlue_map (reflectLaurent n) n] + have h : reflectLaurent n ∘ (fun p => reflectLaurent n (polynomialNorthSource n p)) = + polynomialNorthSource n := by + funext p + exact reflectLaurent_involutive n _ + rw [h] + exact sourceGlue_symmetric (K:=Laurent n) n _ _ + +lemma map_occupancySign {K L : Type*} [Ring K] [Ring L] + (f : K →+* L) {n : ℕ} (p : Pairing n) (i : Fin n) : + f (occupancySign p i) = occupancySign p i := by + unfold occupancySign + split_ifs <;> simp + +lemma sourceGlue_signTwist {K : Type*} [CommRing K] (n : ℕ) + (v w : SourcePairing n → K) (i : Fin (n+1)) : + sourceGlue n (fun p => occupancySign p.val i * v p) + (fun p => occupancySign p.val i * w p) = sourceGlue n v w := by + rw [sourceGlue_eq_sum, sourceGlue_eq_sum] + apply Finset.sum_congr rfl + intro p _ + apply Finset.sum_congr rfl + intro q _ + split_ifs with h + · rw [one_mul, one_mul] + have hs : (occupancySign p.val i : K) = occupancySign q.val i := by + simp only [occupancySign, h.2.1 i] + rw [hs] + calc + _ = (occupancySign q.val i * occupancySign q.val i) * (v p * w q) := by ring + _ = _ := by rw [occupancySign_mul_self,one_mul] + · simp + +lemma polynomialNorthGluing_eval (n : ℕ) : + evalLaurent (polynomialNorthGluing n) = + sourceGlue n (fun p => reflectSpectral n (evalLaurent (polynomialNorthSource n p))) + (fun p => evalLaurent (polynomialNorthSource n p)) := by + unfold polynomialNorthGluing evalLaurent + rw [sourceGlue_map] + change sourceGlue n (fun p => evalLaurent (reflectLaurent n (polynomialNorthSource n p))) + (fun p => evalLaurent (polynomialNorthSource n p)) = _ + congr 1 + funext p + exact (reflectSpectral_evalLaurent (polynomialNorthSource n p)).symm + + +lemma polynomialNorthGluing_parity (n : ℕ) (i : Fin n) : + signLaurent i (polynomialNorthGluing n) = polynomialNorthGluing n := by + apply IsFractionRing.injective (SpectralRing n) (SpectralField n) + change evalLaurent (signLaurent i (polynomialNorthGluing n)) = + evalLaurent (polynomialNorthGluing n) + rw [←signSpectral_evalLaurent, polynomialNorthGluing_eval, sourceGlue_map] + simp only [Function.comp_def, ←reflectSpectral_sign, polynomialNorthSource_parity, + map_mul, map_occupancySign] + exact sourceGlue_signTwist n _ _ _ + +lemma perm_reflect_ratio {n : ℕ} (i j : Fin n) : + permSpectral (Equiv.swap i j) (reflectSpectral n (variableF j / variableF i)) = + variableF j / variableF i := by + simp only [map_div₀, reflectSpectral_variable, map_pow, permSpectral_const, + permSpectral_variable, Equiv.swap_apply_left, Equiv.swap_apply_right] + field_simp [variableF_ne_zero, constF_phase_ne_zero] + +lemma polynomialNorthSource_reflected_covariance {n : ℕ} (r : ℕ) (hr : r+2≤n) : + (fun p => permSpectral (Equiv.swap ⟨r,by omega⟩ ⟨r+1,by omega⟩) + (reflectSpectral n (evalLaurent (polynomialNorthSource n p)))) = + (sourceBlock (localR (PartialColumn.rowPosition r hr).padTop + (torusWeights (variableF ⟨r+1,by omega⟩ / variableF ⟨r,by omega⟩)))).mulVec + (fun p => reflectSpectral n (evalLaurent (polynomialNorthSource n p))) := by + let σ := Equiv.swap (⟨r,by omega⟩ : Fin n) (⟨r+1,by omega⟩ : Fin n) + let R : Matrix (SourcePairing n) (SourcePairing n) (SpectralField n) := sourceBlock (localR (PartialColumn.rowPosition r hr).padTop + (torusWeights (variableF ⟨r+1,by omega⟩ / variableF ⟨r,by omega⟩))) + have hR : (R.map (reflectSpectral n)).map (permSpectral σ) = R := by + unfold R σ + rw [sourceBlock_map, localR_map_hom, reflectSpectral_torusWeights, + sourceBlock_map, localR_map_hom, permSpectral_torusWeights, perm_reflect_ratio] + have h := congrArg (fun V : SourcePairing n → SpectralField n => + fun p => permSpectral σ (reflectSpectral n (V p))) + (polynomialNorthSource_covariance r hr) + funext p + have hh := congrFun h p + change permSpectral σ (reflectSpectral n (evalLaurent (polynomialNorthSource n p))) = + permSpectral σ (reflectSpectral n (R.mulVec + (fun q => permSpectral σ (evalLaurent (polynomialNorthSource n q))) p)) at hh + rw [RingHom.map_mulVec, RingHom.map_mulVec, hR] at hh + change _ = R.mulVec (fun q => permSpectral σ (reflectSpectral n + (permSpectral σ (evalLaurent (polynomialNorthSource n q))))) p at hh + have hv : (fun q => permSpectral σ (reflectSpectral n + (permSpectral σ (evalLaurent (polynomialNorthSource n q))))) = + (fun q => reflectSpectral n (evalLaurent (polynomialNorthSource n q))) := by + funext q + rw [reflectSpectral_perm] + exact permSpectral_swap_involutive ⟨r,by omega⟩ ⟨r+1,by omega⟩ _ + rw [hv] at hh + exact hh + + + +lemma polynomialNorthGluing_exchange {n : ℕ} (r : ℕ) (hr : r+2≤n) : + permLaurent (Equiv.swap ⟨r,by omega⟩ ⟨r+1,by omega⟩) (polynomialNorthGluing n) = + polynomialNorthGluing n := by + apply IsFractionRing.injective (SpectralRing n) (SpectralField n) + change evalLaurent (permLaurent (Equiv.swap ⟨r,by omega⟩ ⟨r+1,by omega⟩) + (polynomialNorthGluing n)) = evalLaurent (polynomialNorthGluing n) + rw [←permSpectral_evalLaurent, polynomialNorthGluing_eval, sourceGlue_map] + change sourceGlue n + (fun p => permSpectral (Equiv.swap ⟨r,by omega⟩ ⟨r+1,by omega⟩) + (reflectSpectral n (evalLaurent (polynomialNorthSource n p)))) + (fun p => permSpectral (Equiv.swap ⟨r,by omega⟩ ⟨r+1,by omega⟩) + (evalLaurent (polynomialNorthSource n p))) = _ + rw [polynomialNorthSource_reflected_covariance r hr, ←sourceGlue_adjoint, + ←polynomialNorthSource_covariance r hr] + + +def northSeparatorMoment (n : ℕ) : SpectralField n := + sourceGlue n (fun p => reflectSpectral n (integratedNorthSource n p)) + (integratedNorthSource n) + +lemma sourceGlue_scale {K : Type*} [CommRing K] (n : ℕ) (a b : K) + (v w : SourcePairing n → K) : + sourceGlue n (a • v) (b • w) = (a*b)*sourceGlue n v w := by + simp only [sourceGlue,Matrix.mulVec_smul,smul_dotProduct,dotProduct_smul,smul_eq_mul] + ring + + + +theorem polynomialNorthGluing_eval_moment (n : ℕ) : + evalLaurent (polynomialNorthGluing n) = + spectralNormalization n ^ 2 * northSeparatorMoment n := by + rw [polynomialNorthGluing_eval] + simp only [polynomialNorthSource_eval,map_mul,reflectSpectral_normalization] + change sourceGlue n (spectralNormalization n • _) + (spectralNormalization n • integratedNorthSource n) = _ + rw [sourceGlue_scale,pow_two] + rfl + +end + + + + +noncomputable section +open scoped Classical +open Finset Relation +namespace Pairing + +lemma adj_interior {n : ℕ} {p : Pairing n} {a b i j : Fin n} + (hab : p.Adj a b) (hai : a < i) (hib : i < b) (hij : p.Adj i j) : + a < j ∧ j < b := by + have hia : i ≠ a := ne_of_gt hai + have hib' : i ≠ b := ne_of_lt hib + have hja : j ≠ a := by + intro he + subst j + have hh := adj_unique hab (adj_symm hij) + omega + have hjb : j ≠ b := by + intro he + subst j + have hh := adj_unique (adj_symm hab) (adj_symm hij) + omega + exact (not_cross_iff_between (hai.trans hib) hia hib' hja hjb).mp + (not_cross hij hab) |>.mp ⟨hai, hib⟩ + +lemma fully_matched_interval_even {n : ℕ} {p : Pairing n} + (hp : ∀ i, p.Occupied i) {a b : Fin n} (hab : p.Adj a b) (_hlt : a < b) : + Even (b.val - a.val - 1) := by + let I := {i : Fin n // i ∈ Finset.Ioo a b} + let G : SimpleGraph I := ⟨fun i j => p.Adj i.1 j.1, + ⟨fun _ _ h => adj_symm h⟩, ⟨fun _ => p.adj_irrefl _⟩⟩ + have hG : (⊤ : G.Subgraph).IsPerfectMatching := by + rw [SimpleGraph.Subgraph.isPerfectMatching_iff] + intro i + obtain ⟨j, hj⟩ := hp i + have hjmem := adj_interior hab (Finset.mem_Ioo.mp i.2).1 (Finset.mem_Ioo.mp i.2).2 hj + refine ⟨⟨j, Finset.mem_Ioo.mpr hjmem⟩, ?_, ?_⟩ + · exact hj + · intro k hk + exact Subtype.ext (adj_unique hk hj) + have he := hG.even_card + simpa only [I, Fintype.card_coe, Fin.card_Ioo] using he + + + +def shiftedVisitAdj {n : ℕ} (i j : Fin n) : Prop := + (i.val % 2 = 1 ∧ j.val = i.val + 1) ∨ + (j.val % 2 = 1 ∧ i.val = j.val + 1) + +def visitWiring {n : ℕ} (p : Pairing n) (i j : Fin n) : Prop := + p.Adj i j ∨ shiftedVisitAdj i j + +lemma adj_closed_interval {n : ℕ} {p : Pairing n} {a b i j : Fin n} + (hab : p.Adj a b) (h : a ≤ i ∧ i ≤ b) (hij : p.Adj i j) : + a ≤ j ∧ j ≤ b := by + by_cases ha : i = a + · subst i + have := adj_unique hij hab + subst j + exact ⟨h.1.trans h.2, le_rfl⟩ + by_cases hb : i = b + · subst i + have := adj_unique hij (adj_symm hab) + subst j + exact ⟨le_rfl, h.1.trans h.2⟩ + obtain ⟨haj, hjb⟩ := adj_interior hab (lt_of_le_of_ne h.1 (Ne.symm ha)) + (lt_of_le_of_ne h.2 hb) hij + exact ⟨haj.le, hjb.le⟩ + +lemma shiftedVisitAdj_closed_interval {n : ℕ} {a b i j : Fin n} + (ha : a.val % 2 = 1) (hb : b.val % 2 = 0) + (hi : a ≤ i ∧ i ≤ b) (hij : shiftedVisitAdj i j) : + a ≤ j ∧ j ≤ b := by + rcases hij with ⟨hiodd, hv⟩ | ⟨hjodd, hv⟩ <;> constructor + all_goals omega + +lemma odd_initial_arc_impossible {n : ℕ} {p : Pairing (n+2)} + (hp : ∀ i, p.Occupied i) + (hc : ∀ i, ReflTransGen p.visitWiring i 0) + {a b : Fin (n+2)} (hab : p.Adj a b) (hlt : a < b) : + a.val % 2 = 0 := by + by_contra hna + have ha : a.val % 2 = 1 := by omega + have hpv := fully_matched_interval_even hp hab hlt + rw [even_iff_two_dvd, Nat.dvd_iff_mod_eq_zero] at hpv + have hb : b.val % 2 = 0 := by omega + have hstable : ∀ {i j}, a ≤ i ∧ i ≤ b → p.visitWiring i j → a ≤ j ∧ j ≤ b := by + intro i j hi hij + rcases hij with hij | hij + · exact adj_closed_interval hab hi hij + · exact shiftedVisitAdj_closed_interval ha hb hi hij + have hr := hc a + have hreach : ∀ {j}, ReflTransGen p.visitWiring a j → a ≤ j ∧ j ≤ b := by + intro j h + induction h with + | refl => exact ⟨le_rfl, hlt.le⟩ + | tail h hstep ih => exact hstable ih hstep + have hz := (hreach hr).1 + change a.val ≤ 0 at hz + omega + + + +theorem single_component_visits_consecutive {n : ℕ} {p : Pairing (n+2)} + (hp : ∀ i, p.Occupied i) + (hc : ∀ i, ReflTransGen p.visitWiring i 0) + {a b : Fin (n+2)} (hab : p.Adj a b) (hlt : a < b) : + a.val % 2 = 0 ∧ b.val = a.val+1 := by + have ha := odd_initial_arc_impossible hp hc hab hlt + refine ⟨ha, ?_⟩ + by_contra hh + have hgap : a.val + 1 < b.val := by omega + let i : Fin (n+2) := ⟨a.val+1, hgap.trans b.isLt⟩ + have hai : a < i := by change a.val < a.val+1; omega + have hib : i < b := by exact hgap + obtain ⟨j,hj⟩ := hp i + have hjmem := adj_interior hab hai hib hj + have hodd : i.val % 2 = 1 := by dsimp [i]; omega + have hne : i ≠ j := fun h => p.adj_irrefl i (h ▸ hj) + rcases lt_or_gt_of_ne hne with hij | hji + · have he := odd_initial_arc_impossible hp hc hj hij + omega + · have : a.val < j.val ∧ j.val < a.val+1 := ⟨hjmem.1, hji⟩ + omega + +end Pairing +end +end CriticalStrip.Diagram + +end OAI diff --git a/lean/OAI/Combinatorics/StripMass/NorthMass.lean b/lean/OAI/Combinatorics/StripMass/NorthMass.lean new file mode 100644 index 0000000000000000000000000000000000000000..c35fbfc4846bb68483891ebe20e0d0c9d097877d --- /dev/null +++ b/lean/OAI/Combinatorics/StripMass/NorthMass.lean @@ -0,0 +1,440 @@ +import Mathlib +import OAI.Combinatorics.StripMass.NorthBijection + +namespace OAI + +/-! Critical honeycomb strip paths, polynomial identities and crossing mass. -/ + + +namespace CriticalStrip +noncomputable section +open scoped Classical BigOperators +open Diagram + +lemma sum_subtype_indicator {α : Type*} [Fintype α] (P : α→Prop) (f : α→ℝ) : + (∑ x : {a // P a},f x.val)=∑ x,if P x then f x else 0 := by + rw [←Finset.sum_filter] + exact (Finset.sum_subtype (Finset.univ.filter P) (by simp) f).symm + +namespace NorthHistory +variable {N m : ℕ} + +def Valid (l r : Fin m → Configuration (N+1)) : Prop := + ColumnChain.weight (SewnRectangle.leftWeights N) (List.ofFn l)≠0 ∧ + ColumnChain.weight (SewnRectangle.rightWeights N) (List.ofFn r)≠0 ∧ + ∃p q : Pairing (N+1), ColumnChain.Runs (empty (N+1)) (List.ofFn l) p ∧ + ColumnChain.Runs (empty (N+1)) (List.ofFn r) q ∧ p.GluesAt (Fin.last N) q + +def pairEquiv : NorthHistory N m ≃ + {lr : (Fin m → Configuration (N+1)) × (Fin m → Configuration (N+1)) // Valid lr.1 lr.2} where + toFun h := ⟨(h.left,h.right),h.nzleft,h.nzright,h.realizes⟩ + invFun h := ⟨h.val.1,h.val.2,h.property.1,h.property.2.1,h.property.2.2⟩ + left_inv _ := rfl + right_inv _ := rfl + +lemma weighted_valid (l r : Fin m → Configuration (N+1)) : + (if Valid l r then ColumnChain.weight (SewnRectangle.leftWeights N) (List.ofFn l)* + ColumnChain.weight (SewnRectangle.rightWeights N) (List.ofFn r) else 0)= + ∑p : Pairing (N+1),∑q : Pairing (N+1), + (if ColumnChain.Runs (empty (N+1)) (List.ofFn l) p then + ColumnChain.weight (SewnRectangle.leftWeights N) (List.ofFn l) else 0)* + (if p.GluesAt (Fin.last N) q then (1:ℝ) else 0)* + (if ColumnChain.Runs (empty (N+1)) (List.ofFn r) q then + ColumnChain.weight (SewnRectangle.rightWeights N) (List.ofFn r) else 0) := by + by_cases hl : ∃p,ColumnChain.Runs (empty (N+1)) (List.ofFn l) p + · obtain ⟨p,hp⟩:=hl + have hpl (x : Pairing (N+1)) : + ColumnChain.Runs (empty (N+1)) (List.ofFn l) x ↔ x=p := + ⟨fun h=>ColumnChain.runs_unique h hp,fun h=>h ▸ hp⟩ + by_cases hr : ∃q,ColumnChain.Runs (empty (N+1)) (List.ofFn r) q + · obtain ⟨q,hq⟩:=hr + have hqr (x : Pairing (N+1)) : + ColumnChain.Runs (empty (N+1)) (List.ofFn r) x ↔ x=q := + ⟨fun h=>ColumnChain.runs_unique h hq,fun h=>h ▸ hq⟩ + rw [Finset.sum_eq_single p] + · rw [Finset.sum_eq_single q] + · by_cases hwl : ColumnChain.weight (SewnRectangle.leftWeights N) (List.ofFn l)=0 + · simp [Valid,hpl,hqr,hwl] + · by_cases hwr : ColumnChain.weight (SewnRectangle.rightWeights N) (List.ofFn r)=0 + · simp [Valid,hpl,hqr,hwr] + · simp only [Valid,hpl,hqr,hwl,hwr,ne_eq,not_false_eq_true,true_and, + ite_true] + have he : (∃ p₁ q₁ : Pairing (N+1), p₁=p ∧ q₁=q ∧ p₁.GluesAt (Fin.last N) q₁) ↔ + p.GluesAt (Fin.last N) q := + ⟨by rintro ⟨_,_,rfl,rfl,h⟩; exact h, fun h=>⟨p,q,rfl,rfl,h⟩⟩ + simp only [he] + split_ifs <;> simp + · intro q' _ hq' + simp only [hqr,hq',ite_false,mul_zero] + · simp + · intro p' _ hp' + simp only [hpl,hp',ite_false,zero_mul,Finset.sum_const_zero] + · simp + · have he (q : Pairing (N+1)) : ¬ColumnChain.Runs (empty (N+1)) (List.ofFn r) q := + fun h=>hr ⟨q,h⟩ + simp only [Valid,he,false_and,and_false,exists_false,ite_false,mul_zero,Finset.sum_const_zero] + · have he (p : Pairing (N+1)) : ¬ColumnChain.Runs (empty (N+1)) (List.ofFn l) p := + fun h=>hl ⟨p,h⟩ + simp only [Valid,he,false_and,exists_false,and_false,ite_false,zero_mul,Finset.sum_const_zero] + +lemma sum_weight_pairings (N m : ℕ) : + (∑ h : NorthHistory N m,h.weight)= + ∑p : Pairing (N+1),∑q : Pairing (N+1), + (column (SewnRectangle.leftWeights N)^m) p (empty (N+1))* + (if p.GluesAt (Fin.last N) q then (1:ℝ) else 0)* + (column (SewnRectangle.rightWeights N)^m) q (empty (N+1)) := by + rw [show (∑h : NorthHistory N m,h.weight)= + ∑ h : {lr : (Fin m → Configuration (N+1)) × (Fin m → Configuration (N+1)) // Valid lr.1 lr.2}, + ColumnChain.weight (SewnRectangle.leftWeights N) (List.ofFn h.val.1)* + ColumnChain.weight (SewnRectangle.rightWeights N) (List.ofFn h.val.2) from + Fintype.sum_equiv pairEquiv _ _ (fun _=>rfl)] + rw [sum_subtype_indicator (fun lr : (Fin m → Configuration (N+1)) × (Fin m → Configuration (N+1))=>Valid lr.1 lr.2) + (fun lr=>ColumnChain.weight (SewnRectangle.leftWeights N) (List.ofFn lr.1)* + ColumnChain.weight (SewnRectangle.rightWeights N) (List.ofFn lr.2)),Fintype.sum_prod_type] + simp_rw [weighted_valid] + simp_rw [←ColumnChain.mass_eq_pow,ColumnChain.mass,Finset.sum_mul,Finset.mul_sum] + conv_lhs => arg 2; intro l; rw [Finset.sum_comm] + rw [Finset.sum_comm] + apply Finset.sum_congr rfl + intro p _ + conv_lhs => arg 2; intro l; rw [Finset.sum_comm] + rw [Finset.sum_comm] + +lemma sum_weight_source (N m : ℕ) : + (∑ h : NorthHistory N m,h.weight)= + sourceGlue N (fun p=>(column (SewnRectangle.leftWeights N)^m) p.val (empty (N+1))) + (fun q=>(column (SewnRectangle.rightWeights N)^m) q.val (empty (N+1))) := by + rw [sum_weight_pairings,←(sourceFullSplit N).sum_comp,sourceGlue_eq_sum] + simp_rw [←(sourceFullSplit N).sum_comp] + have hl (p : Pairing N) (q : Pairing (N+1)) : ¬p.padTop.GluesAt (Fin.last N) q := + fun h=>Pairing.padTop_not_occupied_last p h.1 + have hr (p : Pairing (N+1)) (q : Pairing N) : ¬p.GluesAt (Fin.last N) q.padTop := + fun h=>Pairing.padTop_not_occupied_last q ((h.2.1 _).mp h.1) + simp only [Fintype.sum_sum_type,sourceFullSplit_inl,sourceFullSplit_inr,hl,hr,ite_false,mul_zero, + zero_mul,Finset.sum_const_zero,zero_add,mul_assoc] + rfl + +instance boundedFintype (N m : ℕ) [hN : Fact (1≤N)] : Fintype (CrossTopArch.Bounded N m) := + Fintype.ofEquiv (NorthHistory N m) (equivCross hN.out) + +lemma sum_weight_cross (N m : ℕ) (hN : 1≤N) [Fintype (CrossTopArch.Bounded N m)] : + (∑ h : NorthHistory N m,h.weight)=∑D : CrossTopArch.Bounded N m,D.val.weight := + Fintype.sum_equiv (equivCross hN) _ _ (fun h=>toCross_weight h hN) + +end NorthHistory +end +end CriticalStrip + + + + + +namespace CriticalStrip.Diagram +noncomputable section +open scoped Classical BigOperators +open _root_.Matrix _root_.OAI.Matrix Filter Topology + +lemma column_pow_empty_empty {n : ℕ} (w : Fin n → Weights ℝ) (m : ℕ) : + (column w^m) (empty n) (empty n)=1 := by + induction m with + | zero => simp + | succ m ih => + rw [pow_succ'] + change (column w).mulVec (fun p=>(column w^m) p (empty n)) (empty n)=1 + rw [column_mulVec_empty,ih] + + + +lemma column_pow_empty_nonempty {n : ℕ} (w : Fin n → Weights ℝ) + (v : NonemptyPairing n → ℝ) + (hv : (restrictedColumn w).mulVec v+injectionColumn w=v) (m : ℕ) : + ∀ p : NonemptyPairing n, (column w^m) p.val (empty n)= + v p-(restrictedColumn w^m).mulVec v p := by + induction m with + | zero => + intro p + simp only [pow_zero,Matrix.one_apply,p.property,ite_false,Matrix.one_mulVec,sub_self] + | succ m ih => + intro p + rw [pow_succ'] + change (column w).mulVec (fun q=>(column w^m) q (empty n)) p.val=_ + rw [column_mulVec_nonempty,column_pow_empty_empty,mul_one] + have he : (fun q : NonemptyPairing n=>(column w^m) q.val (empty n))= + v-(restrictedColumn w^m).mulVec v := funext ih + rw [he,Matrix.mulVec_sub,Matrix.mulVec_mulVec,←pow_succ'] + have hp:=congrFun hv p + simp only [Pi.add_apply] at hp + simp only [Pi.sub_apply] + linarith + +theorem column_pow_empty_tendsto {n : ℕ} (w : Fin n → Weights ℝ) + (hs : PositiveMatrix.SummablePowers (restrictedColumn w)) + (v : NonemptyPairing n → ℝ) + (hv : (restrictedColumn w).mulVec v+injectionColumn w=v) (p : NonemptyPairing n) : + Tendsto (fun m : ℕ=>(column w^m) p.val (empty n)) atTop (𝓝 (v p)) := by + simp_rw [column_pow_empty_nonempty w v hv] + have hh:=(hs.mulVec_tendsto_zero v p).const_sub (v p) + simpa only [sub_zero] using hh + +lemma physical_augmented_stationary (N : ℕ) : + (restrictedColumn (SewnRectangle.leftWeights N)).mulVec + (fun p=>angleAugmented (fun _ : Fin N=>lambda) p.val)+ + injectionColumn (SewnRectangle.leftWeights N)= + fun p=>angleAugmented (fun _ : Fin N=>lambda) p.val := by + simpa only [show 3*lambda-lambda=2*lambda by ring,SewnRectangle.leftWeights] using + angleAugmented_restricted_stationary (fun _ : Fin N=>lambda) + (fun _=>homogeneous_L_ne_zero) (homogeneous_angleScalar_ne_zero N) + +lemma reversed_augmented_stationary (N : ℕ) : + (restrictedColumn (SewnRectangle.rightWeights N)).mulVec + (fun p=>angleAugmented (fun _ : Fin N=>2*lambda) p.val)+ + injectionColumn (SewnRectangle.rightWeights N)= + fun p=>angleAugmented (fun _ : Fin N=>2*lambda) p.val := by + simpa only [show 3*lambda-2*lambda=lambda by ring,SewnRectangle.rightWeights] using + angleAugmented_restricted_stationary (fun _ : Fin N=>2*lambda) + (fun _=>reversed_L_ne_zero) (reversed_angleScalar_ne_zero N) + +lemma physical_empty_tendsto_source (N : ℕ) (p : SourcePairing N) : + Tendsto (fun m : ℕ=>(column (SewnRectangle.leftWeights N)^m) p.val (empty (N+1))) atTop + (𝓝 (angleNorthSource (fun _ : Fin N=>lambda) p)) := by + have hp : p.val≠empty (N+1) := by + intro h; exact empty_not_occupied _ (h ▸ p.property) + have hh:=column_pow_empty_tendsto (SewnRectangle.leftWeights N) + (augmentedPhysical_summablePowers N) _ (physical_augmented_stationary N) ⟨p.val,hp⟩ + simpa only [angleAugmented,augmentVector_source] using hh + +lemma reversed_empty_tendsto_source (N : ℕ) (p : SourcePairing N) : + Tendsto (fun m : ℕ=>(column (SewnRectangle.rightWeights N)^m) p.val (empty (N+1))) atTop + (𝓝 (angleNorthSource (fun _ : Fin N=>2*lambda) p)) := by + have hp : p.val≠empty (N+1) := by + intro h; exact empty_not_occupied _ (h ▸ p.property) + have hh:=column_pow_empty_tendsto (SewnRectangle.rightWeights N) + (augmentedReversed_summablePowers N) _ (reversed_augmented_stationary N) ⟨p.val,hp⟩ + simpa only [angleAugmented,augmentVector_source] using hh + +end +end CriticalStrip.Diagram + + + + + +namespace CriticalStrip +noncomputable section +open scoped BigOperators Classical +open Diagram Filter Topology + +namespace NorthHistory + +lemma mass_tendsto (N : ℕ) : + Tendsto (fun m : ℕ=>∑ h : NorthHistory N m,h.weight) atTop (𝓝 (realNorthSeparator N)) := by + simp_rw [sum_weight_source] + rw [realNorthSeparator,sourceGlue_symmetric] + simp_rw [sourceGlue_eq_sum] + apply tendsto_finsetSum + intro p _ + apply tendsto_finsetSum + intro q _ + exact (physical_empty_tendsto_source N p).mul + ((reversed_empty_tendsto_source N q).const_mul _) + +end NorthHistory + +namespace CrossTopArch +variable {N : ℕ} + +lemma weight_nonneg (D : CrossTopArch N) (hN : 1≤N) : 0≤D.weight := by + rw [weight,←D.arch.weight_toArch hN,(D.arch.toArch hN).weight_eq_path hN (by + intro he + have hx:=BoundaryPort.bottom.inj he + omega)] + exact (pow_pos rho_pos _).le + +lemma Fits.mono {D : CrossTopArch N} {m l : ℕ} (h : D.Fits m) (hm : m≤l) : D.Fits l := + HoneycombAssignment.Fits.mono h hm + +def window (N m : ℕ) [Fact (1≤N)] : Finset (CrossTopArch N) := + (Finset.univ : Finset (Bounded N m)).map ⟨Subtype.val,Subtype.val_injective⟩ + +@[simp] lemma mem_window [Fact (1≤N)] (D : CrossTopArch N) (m : ℕ) : + D∈window N m ↔ D.Fits m := by + simp only [window,Finset.mem_map,Finset.mem_univ,true_and,Function.Embedding.coeFn_mk] + exact ⟨fun ⟨D',he⟩=>he ▸ D'.property,fun h=>⟨⟨D,h⟩,rfl⟩⟩ + +lemma window_tendsto (N : ℕ) [hN : Fact (1≤N)] : + Tendsto (fun m : ℕ=>window N m) atTop atTop := by + apply tendsto_atTop.mpr + intro F + let b : CrossTopArch N → ℕ := fun D=>Classical.choose (D.exists_fits hN.out) + have hb (D : CrossTopArch N) : D.Fits (b D) := Classical.choose_spec (D.exists_fits hN.out) + apply eventually_atTop.mpr + refine ⟨F.sup b,?_⟩ + intro m hm D hD + rw [mem_window] + exact (hb D).mono ((Finset.le_sup hD).trans hm) + +lemma window_mass (N m : ℕ) [hN : Fact (1≤N)] : + (∑D∈window N m,D.weight)=∑h : NorthHistory N m,h.weight := by + rw [window,Finset.sum_map,NorthHistory.sum_weight_cross N m hN.out] + rfl + + + +theorem summable_weight (N : ℕ) (hN : 1≤N) : Summable (weight (N:=N)) := by + let : Fact (1≤N) := ⟨hN⟩ + have hlim : Tendsto (fun m : ℕ=>∑D∈window N m,D.weight) atTop (𝓝 (realNorthSeparator N)) := by + simpa only [window_mass] using NorthHistory.mass_tendsto N + apply summable_of_sum_le (fun D=>D.weight_nonneg hN) + intro F + apply ge_of_tendsto hlim + filter_upwards [tendsto_atTop.mp (window_tendsto N) F] with m hm + exact Finset.sum_le_sum_of_subset_of_nonneg hm (fun D _ _=>D.weight_nonneg hN) + + + +theorem tsum_weight (N : ℕ) (hN : 1≤N) : + (∑' D : CrossTopArch N,D.weight)=realNorthSeparator N := by + let : Fact (1≤N) := ⟨hN⟩ + have h₁ := (summable_weight N hN).hasSum.comp (window_tendsto N) + have h₂ : Tendsto (fun m : ℕ=>∑D∈window N m,D.weight) atTop (𝓝 (realNorthSeparator N)) := by + simpa only [window_mass] using NorthHistory.mass_tendsto N + exact tendsto_nhds_unique h₁ h₂ + +end CrossTopArch +end + + + + + +noncomputable section +open scoped Classical BigOperators +open Diagram + +namespace TopArchConfiguration +variable {N : ℕ} {a b : ℤ} + +lemma weight_nonneg (D : TopArchConfiguration N a b) (hN : 1≤N) (hab : a≠b) : + 0≤D.toHoneycombAssignment.weight := by + rw [←D.weight_toArch hN,(D.toArch hN).weight_eq_path hN (by + intro he; have hx:=BoundaryPort.bottom.inj he; omega)] + exact (pow_pos rho_pos _).le + +lemma weight_sum (N : ℕ) (hN : 1≤N) (a b : ℤ) (hab : a≠b) : + (∑' D : TopArchConfiguration N a b,D.toHoneycombAssignment.weight)=K N (b-a) := by + rw [HoneycombConfiguration.arch_sum N hN (b-a) (by omega)] + rw [show (fun D : TopArchConfiguration N a b=>D.toHoneycombAssignment.weight)= + (fun D : TopArchConfiguration N a b=>(D.toArch hN).weight) from + funext (fun D=>(D.weight_toArch hN).symm)] + exact (equivArch N a b hN).tsum_eq HoneycombConfiguration.weight + +lemma summable_weight_iff (N : ℕ) (hN : 1≤N) (a b : ℤ) (hab : a≠b) : + Summable (fun D : TopArchConfiguration N a b=>D.toHoneycombAssignment.weight) ↔ + Summable (archWeight N (b-a)) := by + rw [HoneycombConfiguration.arch_summable N hN (b-a) (by omega)] + have hh := (equivArch N a b hN).summable_iff (f:=HoneycombConfiguration.weight) + have he : HoneycombConfiguration.weight ∘ (equivArch N a b hN)= + fun D : TopArchConfiguration N a b=>D.toHoneycombAssignment.weight := by + funext D + exact D.weight_toArch hN + rwa [he] at hh + +end TopArchConfiguration + +namespace CrossTopArch + +def sigmaEquiv (N : ℕ) : CrossTopArch N ≃ + Sigma (fun x : ℕ×ℕ=>TopArchConfiguration N (-1-(x.1:ℤ)) (x.2:ℤ)) where + toFun D := ⟨(D.left,D.right),D.arch⟩ + invFun D := ⟨D.1.1,D.1.2,D.2⟩ + left_inv D := by cases D; rfl + right_inv D := by rcases D with ⟨⟨l,r⟩,D⟩; rfl + +lemma summable_sigma (N : ℕ) (hN : 1≤N) : + Summable (fun D : Sigma (fun x : ℕ×ℕ=>TopArchConfiguration N (-1-(x.1:ℤ)) (x.2:ℤ))=> + D.2.toHoneycombAssignment.weight) := + (sigmaEquiv N).summable_iff.mp (summable_weight N hN) + +lemma sigma_sums (N : ℕ) (hN : 1≤N) : + (∀ x : ℕ×ℕ,Summable (fun D : TopArchConfiguration N (-1-(x.1:ℤ)) (x.2:ℤ)=> + D.toHoneycombAssignment.weight)) ∧ + Summable (fun x : ℕ×ℕ=>K N ((x.1+x.2:ℕ)+1)) := by + have hh := (summable_sigma_of_nonneg (fun D : Sigma (fun x : ℕ×ℕ=>TopArchConfiguration N (-1-(x.1:ℤ)) (x.2:ℤ))=> + TopArchConfiguration.weight_nonneg D.2 hN (by omega))).mp (summable_sigma N hN) + refine ⟨hh.1,hh.2.congr ?_⟩ + intro x + rw [TopArchConfiguration.weight_sum N hN _ _ (by omega)] + congr 1 + omega + +end CrossTopArch + + + +theorem archWeight_summable_positive {N : ℕ} (hN : 1≤N) (k : ℤ) (hk : 0archWeight N 0 p) + simp only [archWeight,ne_eq,not_true_eq_false,false_and,ite_false] + exact summable_zero + · exact archWeight_summable_positive hN k hk + + + +theorem moment_summable {N : ℕ} (hN : 1≤N) : + Summable (fun k : ℕ=>(k+1:ℝ)*K N (k+1)) := by + apply (summable_add_diagonal_iff (fun n=>K_nonneg N (n+1))).mp + exact (CrossTopArch.sigma_sums N hN).2 + + + +theorem moment_eq_realNorthSeparator {N : ℕ} (hN : 1≤N) : + moment N=realNorthSeparator N := by + rw [←CrossTopArch.tsum_weight N hN] + have hs:=CrossTopArch.summable_sigma N hN + have he : (∑' D : CrossTopArch N,D.weight)= + ∑' D : Sigma (fun x : ℕ×ℕ=>TopArchConfiguration N (-1-(x.1:ℤ)) (x.2:ℤ)), + D.2.toHoneycombAssignment.weight := + (CrossTopArch.sigmaEquiv N).tsum_eq (fun D=>D.2.toHoneycombAssignment.weight) + rw [he,hs.tsum_sigma' ((CrossTopArch.sigma_sums N hN).1)] + have hi (x : ℕ×ℕ) : + (∑' D : TopArchConfiguration N (-1-(x.1:ℤ)) (x.2:ℤ),D.toHoneycombAssignment.weight)= + K N ((x.1+x.2:ℕ)+1) := by + rw [TopArchConfiguration.weight_sum N hN _ _ (by omega)] + congr 1 + omega + simp_rw [hi] + exact (tsum_add_diagonal (fun n=>K_nonneg N (n+1)) (moment_summable hN)).symm + + + +theorem physical_arch_formula {N : ℕ} (hN : 1≤N) : + ∃ g : Polynomial ℝ, MonicProblem N g ∧ moment N=(N:ℝ)*C-eta*g.coeff (N-1) := by + rw [moment_eq_realNorthSeparator hN] + exact realNorthSeparator_arch hN + + +theorem physical_moment_growth : Comparable moment (fun N=>(N:ℝ)^(3/4:ℝ)) := by + obtain ⟨lo,hi,hl,hh,hg⟩:=homogeneous_arch_coefficient_growth + refine ⟨lo,hi,hl,hh,?_⟩ + intro N hN + obtain ⟨g,hgm,he⟩:=physical_arch_formula hN + simpa only [he] using hg N hN g hgm + +end +end CriticalStrip + +end OAI diff --git a/lean/OAI/Combinatorics/StripMass/NorthMerging.lean b/lean/OAI/Combinatorics/StripMass/NorthMerging.lean new file mode 100644 index 0000000000000000000000000000000000000000..c58c2d8e0bda83fdea2839964e94d7fbdc7faee9 --- /dev/null +++ b/lean/OAI/Combinatorics/StripMass/NorthMerging.lean @@ -0,0 +1,415 @@ +import Mathlib +import OAI.Combinatorics.StripMass.VacuumClosure + +namespace OAI + +/-! Critical honeycomb strip paths, polynomial identities and crossing mass. -/ + + +namespace CriticalStrip.Diagram +noncomputable section +open scoped Classical BigOperators +theorem polynomialNorthSource_merge (n : ℕ) (p : SourcePairing (n+2)) : + pairEvaluation n 2 (polynomialNorthSource (n+2) p) = + mergePairScalar n * + (sourceBlock (mergeMap (m:=n+1) 0 (show 2≤n+3 by omega))).mulVec + (fun q => mergeEvaluation n (polynomialNorthSource (n+1) q)) p := by + let P := (vacuumData (n+2)).P + let Q := (vacuumData (n+1)).P + let M : Matrix (Pairing (n+3)) (Pairing (n+2)) (SpectralField (n+1)) := + mergeMap 0 (by omega) + have he := rationalNodalPolynomial_pair_merge (polynomialVacuumVector (n+1)) + (polynomialVacuumVector_eval (n+1)) Q (vacuumData (n+1)).map_P + (vacuumData (n+1)).eval_P P (vacuumData (n+2)).map_P + have hM : LastMatrix M := mergeMap_last 0 (show 2≤n+2 by omega) + let Q' := fun q => (Q q).map (mergeEvaluation n).toRingHom + have hQ : LastDegree (n+1) (matrixPolynomial M Q') := + hM.degree Q' (((vacuumData (n+1)).degree).map (mergeEvaluation n).toRingHom) + have hh := congrArg (fun U : Pairing (n+3) → Polynomial (SpectralField (n+1)) => + (U p.val).coeff (n+1)) he + change ((P p.val).map _).coeff (n+1) = + (mergePairPolynomial n * matrixPolynomial M Q' p.val).coeff (n+1) at hh + have ht := LastDegree.occupied_mul_top _ hQ _ (mergePairPolynomial_degree n) _ + p.property (by omega : 1 ≤ n+1) + simp only [Nat.add_sub_cancel] at ht + rw [ht, mergePairPolynomial_top, hM.source_coeff] at hh + simp only [Polynomial.coeff_map] at hh + unfold polynomialNorthSource + simp only [map_mul] + + have hc : pairEvaluation n 2 (constantL (n+2) (1/(2*(d:ℂ)))) = + mergeEvaluation n (constantL (n+1) (1/(2*(d:ℂ)))) := by + change pairEvaluation n 2 (algebraMap ℂ (Laurent (n+2)) _) = + mergeEvaluation n (algebraMap ℂ (Laurent (n+1)) _) + rw [AlgHom.commutes, AlgHom.commutes] + rw [hc] + simp only [Nat.add_sub_cancel, show n+2-1=n+1 by omega] + change _ * (pairEvaluation n 2 ((P p.val).coeff (n+1))) = _ + have hh' : pairEvaluation n 2 ((P p.val).coeff (n+1)) = + mergePairScalar n * (sourceBlock M).mulVec + (fun q => (Q' q.val).coeff n) p := hh + rw [hh'] + simp only [Matrix.mulVec, dotProduct, Finset.mul_sum, Q', Polynomial.coeff_map] + + apply Finset.sum_congr rfl + intro q _ + change _ * (_ * (sourceBlock M p q * (mergeEvaluation n ((Q q.val).coeff n)))) = + _ * (sourceBlock M p q * (_ * (mergeEvaluation n ((Q q.val).coeff n)))) + ring + + + +theorem polynomialNorthSource_delete (n : ℕ) (p : SourcePairing (n+2)) : + pairEvaluation n 3 (polynomialNorthSource (n+2) p) = + deletePairScalar n * + (sourceBlock (deletionMap (m:=n+1) 0 (show 2≤n+3 by omega))).mulVec + (fun q => deleteEvaluation n (polynomialNorthSource n q)) p := by + let P := (vacuumData (n+2)).P + let Q := (vacuumData n).P + let M : Matrix (Pairing (n+3)) (Pairing (n+1)) (SpectralField (n+1)) := + deletionMap 0 (by omega) + have he := rationalNodalPolynomial_pair_delete (polynomialVacuumVector (n+1)) + (polynomialVacuumVector_eval (n+1)) Q (vacuumData n).map_P + (vacuumData n).eval_P P (vacuumData (n+2)).map_P + have hM : LastMatrix M := deletionMap_last 0 (show 2≤n+2 by omega) + let Q' := fun q => (Q q).map (deleteEvaluation n).toRingHom + have hQ : LastDegree n (matrixPolynomial M Q') := + hM.degree Q' (((vacuumData n).degree).map (deleteEvaluation n).toRingHom) + have hh := congrArg (fun U : Pairing (n+3) → Polynomial (SpectralField (n+1)) => + (U p.val).coeff (n+1)) he + change ((P p.val).map _).coeff (n+1) = + (deletePairPolynomial n * matrixPolynomial M Q' p.val).coeff (n+1) at hh + have ht : (deletePairPolynomial n * matrixPolynomial M Q' p.val).coeff (n+1) = + deletePairScalar n * (sourceBlock M).mulVec (fun q => (Q' q.val).coeff (n-1)) p := by + by_cases hn : 1 ≤ n + · have ht := LastDegree.occupied_mul_top _ hQ _ (deletePairPolynomial_degree n) _ + p.property hn + have hn' : n+2-1=n+1 := by omega + rw [hn', deletePairPolynomial_top, hM.source_coeff] at ht + exact ht + · have hn : n=0 := by omega + have hz : matrixPolynomial M Q' p.val=0 := by + apply Polynomial.ext + intro k + rw [Polynomial.coeff_zero] + exact hQ p.val k (by simp [p.property, hn]) + rw [hz, mul_zero, Polynomial.coeff_zero] + have hne : IsEmpty (SourcePairing n) := hn ▸ isEmpty_source_zero + let := hne + simp [Matrix.mulVec, dotProduct] + rw [ht, Polynomial.coeff_map] at hh + have hh' : pairEvaluation n 3 ((P p.val).coeff (n+1)) = + deletePairScalar n * (sourceBlock M).mulVec (fun q => (Q' q.val).coeff (n-1)) p := hh + unfold polynomialNorthSource + simp only [map_mul] + have hc : pairEvaluation n 3 (constantL (n+2) (1/(2*(d:ℂ)))) = + deleteEvaluation n (constantL n (1/(2*(d:ℂ)))) := by + change pairEvaluation n 3 (algebraMap ℂ (Laurent (n+2)) _) = + deleteEvaluation n (algebraMap ℂ (Laurent n) _) + rw [AlgHom.commutes, AlgHom.commutes] + rw [hc] + simp only [show n+2-1=n+1 by omega] + change _ * (pairEvaluation n 3 ((P p.val).coeff (n+1))) = _ + rw [hh'] + simp only [Matrix.mulVec, dotProduct, Finset.mul_sum, Q', Polynomial.coeff_map] + apply Finset.sum_congr rfl + intro q _ + change _ * (_ * (sourceBlock M p q * (deleteEvaluation n ((Q q.val).coeff (n-1))))) = + _ * (sourceBlock M p q * (_ * (deleteEvaluation n ((Q q.val).coeff (n-1))))) + ring + + + + + + + +def reflectionMonomial (n : ℕ) : Multiplicative (Fin n → ℤ) →* Laurent n where + toFun e := monomialL (-e.toAdd) (phase ^ (3 * ∑ i, e.toAdd i)) + map_one' := by simp [monomialL]; rfl + map_mul' e f := by + change monomialL (-(e.toAdd+f.toAdd)) + (phase ^ (3 * ∑ i, (e.toAdd i+f.toAdd i))) = _ + rw [Finset.sum_add_distrib, mul_add, zpow_add₀ phase_ne_zero, neg_add] + exact (AddMonoidAlgebra.single_mul_single _ _ _ _).symm + +def reflectLaurent (n : ℕ) : Laurent n →+* Laurent n := + (AddMonoidAlgebra.lift ℂ (Laurent n) (Fin n → ℤ) (reflectionMonomial n)).toRingHom + +@[simp] lemma reflectLaurent_monomial {n : ℕ} (e : Fin n → ℤ) (z : ℂ) : + reflectLaurent n (monomialL e z) = monomialL (-e) (z * phase ^ (3 * ∑ i, e i)) := by + change AddMonoidAlgebra.lift ℂ _ _ (reflectionMonomial n) (AddMonoidAlgebra.single e z) = _ + rw [AddMonoidAlgebra.lift_single] + change z • AddMonoidAlgebra.single (-e) _ = AddMonoidAlgebra.single (-e) _ + rw [AddMonoidAlgebra.smul_single, smul_eq_mul] + rfl + +lemma reflectLaurent_involutive (n : ℕ) : Function.Involutive (reflectLaurent n) := by + have h : (reflectLaurent n).comp (reflectLaurent n) = RingHom.id _ := by + apply AddMonoidAlgebra.ringHom_ext <;> intro e + all_goals change reflectLaurent n (reflectLaurent n (monomialL _ _)) = monomialL _ _ + all_goals rw [reflectLaurent_monomial, reflectLaurent_monomial] + all_goals simp only [neg_neg, Pi.neg_apply, Finset.sum_neg_distrib, mul_neg, + mul_assoc, ←zpow_add₀ phase_ne_zero, add_neg_cancel, zpow_zero, mul_one] + intro f + exact DFunLike.congr_fun h f + +def reflectSpectral (n : ℕ) : SpectralField n →+* SpectralField n := + IsFractionRing.lift (K := SpectralField n) + (g := (algebraMap (SpectralRing n) (SpectralField n)).comp (reflectLaurent n)) + ((IsFractionRing.injective (SpectralRing n) (SpectralField n)).comp + (reflectLaurent_involutive n).injective) + +@[simp] lemma reflectSpectral_evalLaurent {n : ℕ} (f : Laurent n) : + reflectSpectral n (evalLaurent f) = evalLaurent (reflectLaurent n f) := + IsFractionRing.lift_algebraMap _ _ + +lemma reflectSpectral_involutive (n : ℕ) : Function.Involutive (reflectSpectral n) := by + have h : (reflectSpectral n).comp (reflectSpectral n) = RingHom.id _ := by + apply IsFractionRing.ringHom_ext (A := SpectralRing n) + intro f + change reflectSpectral n (reflectSpectral n (evalLaurent f)) = evalLaurent f + rw [reflectSpectral_evalLaurent, reflectSpectral_evalLaurent, reflectLaurent_involutive] + intro f + exact DFunLike.congr_fun h f + +@[simp] lemma reflectSpectral_const (n : ℕ) (z : ℂ) : + reflectSpectral n (constF n z) = constF n z := by + have hc : constF n z = evalLaurent (constantL n z) := (map_constantL n z).symm + rw [hc, reflectSpectral_evalLaurent] + change evalLaurent (reflectLaurent n (monomialL 0 z)) = evalLaurent (monomialL 0 z) + rw [reflectLaurent_monomial] + simp + +@[simp] lemma reflectSpectral_variable {n : ℕ} (i : Fin n) : + reflectSpectral n (variableF i) = constF n phase ^ 3 / variableF i := by + change reflectSpectral n (evalLaurent (monomialL (variableExponent i) 1)) = _ + rw [reflectSpectral_evalLaurent, reflectLaurent_monomial] + simp only [variableExponent, Pi.single_apply, Finset.sum_ite_eq', Finset.mem_univ, + ite_true, one_mul, mul_one] + change evalLaurent (monomialL (-variableExponent i) (phase^3)) = _ + rw [evalLaurent, map_monomialL_neg_variable] + simp [constF, div_eq_mul_inv] + +@[simp] lemma reflectSpectral_torusSin {n : ℕ} (z : SpectralField n) : + reflectSpectral n (torusSin z) = torusSin (reflectSpectral n z) := by + simp [torusSin, map_div₀, map_inv₀, map_ofNat] + +@[simp] lemma reflectSpectral_torusCos {n : ℕ} (z : SpectralField n) : + reflectSpectral n (torusCos z) = torusCos (reflectSpectral n z) := by + simp [torusCos, map_div₀, map_inv₀, map_ofNat] + +@[simp] lemma reflectSpectral_torusL {n : ℕ} (z : SpectralField n) : + reflectSpectral n (torusL z) = torusL (reflectSpectral n z) := by simp [torusL] + +@[simp] lemma reflectSpectral_torusWeights {n : ℕ} (z : SpectralField n) : + (torusWeights z).map (reflectSpectral n) = torusWeights (reflectSpectral n z) := by + simp [Weights.map, torusWeights, map_div₀] + +@[simp] lemma reflectSpectral_spectralA {n : ℕ} (i : Fin n) : + reflectSpectral n (spectralA i) = spectralA i := by + simp only [spectralA, reflectSpectral_torusCos, map_div₀, map_pow, + reflectSpectral_const, reflectSpectral_variable] + unfold torusCos + field_simp [variableF_ne_zero, constF_phase_ne_zero] + ring + +@[simp] lemma reflectSpectral_normalization (n : ℕ) : + reflectSpectral n (spectralNormalization n) = spectralNormalization n := by + simp only [spectralNormalization, map_scalarNormalization, reflectSpectral_const, + reflectSpectral_spectralA] + +lemma reflectLaurent_perm {n : ℕ} (σ : Equiv.Perm (Fin n)) (f : Laurent n) : + reflectLaurent n (permLaurent σ f) = permLaurent σ (reflectLaurent n f) := by + have h : (reflectLaurent n).comp (permLaurent σ) = + (permLaurent σ).comp (reflectLaurent n) := by + apply AddMonoidAlgebra.ringHom_ext <;> intro e + all_goals change reflectLaurent n (permLaurent σ (monomialL _ _)) = + permLaurent σ (reflectLaurent n (monomialL _ _)) + all_goals rw [permLaurent_monomial, reflectLaurent_monomial, + reflectLaurent_monomial, permLaurent_monomial] + all_goals simp only [Function.comp_apply, Equiv.sum_comp] + all_goals rfl + exact DFunLike.congr_fun h f + +lemma reflectSpectral_perm {n : ℕ} (σ : Equiv.Perm (Fin n)) (f : SpectralField n) : + reflectSpectral n (permSpectral σ f) = permSpectral σ (reflectSpectral n f) := by + have h : (reflectSpectral n).comp (permSpectral σ) = + (permSpectral σ).comp (reflectSpectral n) := by + apply IsFractionRing.ringHom_ext (A := SpectralRing n) + intro f + change reflectSpectral n (permSpectral σ (evalLaurent f)) = + permSpectral σ (reflectSpectral n (evalLaurent f)) + simp only [reflectSpectral_evalLaurent, permSpectral_evalLaurent, reflectLaurent_perm] + exact DFunLike.congr_fun h f + +lemma reflectLaurent_sign {n : ℕ} (i : Fin n) (f : Laurent n) : + reflectLaurent n (signLaurent i f) = signLaurent i (reflectLaurent n f) := by + have h : (reflectLaurent n).comp (signLaurent i) = + (signLaurent i).comp (reflectLaurent n) := by + apply AddMonoidAlgebra.ringHom_ext <;> intro e + all_goals change reflectLaurent n (signLaurent i (monomialL _ _)) = + signLaurent i (reflectLaurent n (monomialL _ _)) + all_goals rw [signLaurent_monomial, reflectLaurent_monomial, + reflectLaurent_monomial, signLaurent_monomial] + all_goals simp only [Pi.neg_apply, zpow_neg, ←inv_zpow, inv_neg_one]; congr 1; ring + exact DFunLike.congr_fun h f + +lemma reflectSpectral_sign {n : ℕ} (i : Fin n) (f : SpectralField n) : + reflectSpectral n (signSpectral i f) = signSpectral i (reflectSpectral n f) := by + have h : (reflectSpectral n).comp (signSpectral i) = + (signSpectral i).comp (reflectSpectral n) := by + apply IsFractionRing.ringHom_ext (A := SpectralRing n) + intro f + change reflectSpectral n (signSpectral i (evalLaurent f)) = + signSpectral i (reflectSpectral n (evalLaurent f)) + simp only [reflectSpectral_evalLaurent, signSpectral_evalLaurent, reflectLaurent_sign] + exact DFunLike.congr_fun h f + +lemma LaurentBox.reflect {n : ℕ} {f : Laurent n} {b : Fin n → ℕ} + (hf : LaurentBox f b) : LaurentBox (reflectLaurent n f) b := by + rw [←AddMonoidAlgebra.sum_coeff_single f] + change LaurentBox (reflectLaurent n (∑ e ∈ f.coeff.support, monomialL e (f.coeff e))) b + rw [map_sum] + apply LaurentBox.sum + intro e he + rw [reflectLaurent_monomial] + apply LaurentBox.single + intro i + have hh := hf e (Finsupp.mem_support_iff.mp he) i + simp only [Pi.neg_apply] + omega + + + + + + +lemma sourceBlock_map {K L : Type*} {n m : ℕ} (f : K → L) + (M : Matrix (Pairing (m+1)) (Pairing (n+1)) K) : + (sourceBlock M).map f = sourceBlock (M.map f) := rfl + +lemma sourceBlock_transpose {K : Type*} {n m : ℕ} + (M : Matrix (Pairing (m+1)) (Pairing (n+1)) K) : + sourceBlock M.transpose = (sourceBlock M).transpose := rfl + +lemma LastMatrix.source_mul {K : Type*} [CommRing K] {n m r : ℕ} + {M : Matrix (Pairing (r+1)) (Pairing (m+1)) K} (hM : LastMatrix M) + (N : Matrix (Pairing (m+1)) (Pairing (n+1)) K) : + sourceBlock (M*N) = sourceBlock M * sourceBlock N := by + ext p q + exact hM.source_mulVec (fun a => N a q.val) p + +lemma glueMatrix_last {K : Type*} [Zero K] [One K] (n : ℕ) : + LastMatrix (glueMatrix (Fin.last n) : Matrix _ _ K) := by + intro p q h + apply ite_eq_right + intro hg + exact h (hg.2.1 _) + +lemma LastMatrix.transpose {K : Type*} [Zero K] {n m : ℕ} + {M : Matrix (Pairing (m+1)) (Pairing (n+1)) K} (hM : LastMatrix M) : + LastMatrix M.transpose := by + intro p q h + exact hM q p (fun hh => h hh.symm) + + +def sourceGlue {K : Type*} [CommRing K] (n : ℕ) + (v w : SourcePairing n → K) : K := + v ⬝ᵥ (sourceBlock (glueMatrix (Fin.last n))).mulVec w + +lemma sourceGlue_symmetric {K : Type*} [CommRing K] (n : ℕ) + (v w : SourcePairing n → K) : sourceGlue n v w = sourceGlue n w v := by + unfold sourceGlue + rw [Matrix.dotProduct_mulVec, ←glueMatrix_transpose (Fin.last n), + sourceBlock_transpose,Matrix.vecMul_transpose, dotProduct_comm] + rw [← sourceBlock_transpose, glueMatrix_transpose] + +lemma sourceGlue_map {K L : Type*} [CommRing K] [CommRing L] + (f : K →+* L) (n : ℕ) (v w : SourcePairing n → K) : + f (sourceGlue n v w) = sourceGlue n (f ∘ v) (f ∘ w) := by + simp only [sourceGlue, dotProduct, Matrix.mulVec, map_sum, map_mul, + sourceBlock, glueMatrix, Function.comp_apply, apply_ite, map_one, map_zero] + +lemma sourceGlue_adjoint {K : Type*} [CommRing K] {n : ℕ} + (a : Position n) (w : Weights K) (v z : SourcePairing n → K) : + sourceGlue n v ((sourceBlock (localR a.padTop w)).mulVec z) = + sourceGlue n ((sourceBlock (localR a.padTop w)).mulVec v) z := by + have ha : Fin.last n ≠ a.padTop.left := by + intro he + have hh := congrArg Fin.val he + have := a.left.isLt + simp only [Position.padTop, Fin.val_last, Fin.val_castSucc] at hh + omega + have hb : Fin.last n ≠ a.padTop.right := by + intro he + have hh := congrArg Fin.val he + have := a.right.isLt + simp only [Position.padTop, Fin.val_last, Fin.val_castSucc] at hh + omega + have h := congrArg sourceBlock (localR_glue_adjoint a.padTop (Fin.last n) ha hb w) + rw [(glueMatrix_last n).source_mul, (LastMatrix.local a w).transpose.source_mul, + sourceBlock_transpose] at h + unfold sourceGlue + rw [Matrix.mulVec_mulVec, h, ←Matrix.mulVec_mulVec, + Matrix.dotProduct_mulVec, Matrix.vecMul_transpose] + +lemma polynomialNorthSource_eval_numerator (n : ℕ) (p : SourcePairing n) : + evalLaurent (polynomialNorthSource n p) = + constF n (1/(2*(d:ℂ))) * northNumerator n p := by + unfold polynomialNorthSource evalLaurent + rw [map_mul, map_constantL, ←Polynomial.coeff_map, (vacuumData n).map_P] + rfl + +lemma polynomialNorthSource_covariance {n : ℕ} (r : ℕ) (hr : r+2≤n) : + (fun p => evalLaurent (polynomialNorthSource n p)) = + (sourceBlock (localR (PartialColumn.rowPosition r hr).padTop + (torusWeights (variableF ⟨r+1,by omega⟩ / variableF ⟨r,by omega⟩)))).mulVec + (fun p => permSpectral (Equiv.swap ⟨r,by omega⟩ ⟨r+1,by omega⟩) + (evalLaurent (polynomialNorthSource n p))) := by + simp only [polynomialNorthSource_eval_numerator, map_mul, permSpectral_const] + change constF n (1/(2*(d:ℂ))) • northNumerator n = + Matrix.mulVec _ (constF n (1/(2*(d:ℂ))) • _) + rw [Matrix.mulVec_smul] + exact congrArg (fun v => constF n (1/(2*(d:ℂ))) • v) (northNumerator_covariance r hr) + +lemma polynomialNorthSource_parity {n : ℕ} (k : Fin n) (p : SourcePairing n) : + signSpectral k (evalLaurent (polynomialNorthSource n p)) = + occupancySign p.val k.castSucc * evalLaurent (polynomialNorthSource n p) := by + simp only [polynomialNorthSource_eval_numerator, map_mul, signSpectral_const, + northNumerator_parity] + ring + +lemma permSpectral_swap_involutive {n : ℕ} (i j : Fin n) : + Function.Involutive (permSpectral (Equiv.swap i j)) := by + have h : (permSpectral (Equiv.swap i j)).comp (permSpectral (Equiv.swap i j)) = + RingHom.id _ := by + apply IsFractionRing.ringHom_ext (A := SpectralRing n) + intro f + change permSpectral (Equiv.swap i j) (permSpectral (Equiv.swap i j) (evalLaurent f)) = evalLaurent f + rw [permSpectral_evalLaurent, permSpectral_evalLaurent] + have hl : (permLaurent (Equiv.swap i j)).comp (permLaurent (Equiv.swap i j)) = + RingHom.id _ := by + apply AddMonoidAlgebra.ringHom_ext <;> intro e + all_goals change permLaurent _ (permLaurent _ (monomialL _ _)) = monomialL _ _ + all_goals rw [permLaurent_monomial, permLaurent_monomial]; congr 1 + all_goals ext k; simp + exact congrArg evalLaurent (DFunLike.congr_fun hl f) + exact fun f => DFunLike.congr_fun h f + + + +def polynomialNorthGluing (n : ℕ) : Laurent n := + sourceGlue (K:=Laurent n) n (fun p => reflectLaurent n (polynomialNorthSource n p)) + (polynomialNorthSource n) + +lemma sourceGlue_eq_sum {K : Type*} [CommRing K] (n : ℕ) + (v w : SourcePairing n → K) : + sourceGlue n v w = ∑ p, ∑ q, + v p * ((if Pairing.GluesAt (Fin.last n) p.val q.val then (1:K) else 0) * w q) := by + simp only [sourceGlue, dotProduct, Matrix.mulVec, Finset.mul_sum, sourceBlock, glueMatrix] + +end +end CriticalStrip.Diagram + +end OAI diff --git a/lean/OAI/Combinatorics/StripMass/PairCoordinates.lean b/lean/OAI/Combinatorics/StripMass/PairCoordinates.lean new file mode 100644 index 0000000000000000000000000000000000000000..b8376366862450a1a2ccc17eb430c69fb6ce63ab --- /dev/null +++ b/lean/OAI/Combinatorics/StripMass/PairCoordinates.lean @@ -0,0 +1,427 @@ +import Mathlib +import OAI.Combinatorics.StripMass.SchurIdentity + +namespace OAI + +/-! Critical honeycomb strip paths, polynomial identities and crossing mass. -/ + + +namespace StripPfaffian +noncomputable section +open scoped BigOperators +def pairArrayEquiv (α : Type*) (m : ℕ) : (Fin (m*2) → α) ≃ (Fin m → α × α) := + ((Equiv.arrowCongr finProdFinEquiv.symm (Equiv.refl α)).trans + (Equiv.curry (Fin m) (Fin 2) α)).trans + (Equiv.piCongrRight (fun _ => finTwoArrowEquiv α)) + +def pairLeft {m : ℕ} (i : Fin m) : Fin (m*2) := finProdFinEquiv (i, 0) +def pairRight {m : ℕ} (i : Fin m) : Fin (m*2) := finProdFinEquiv (i, 1) + +@[simp] lemma pairArrayEquiv_apply {α : Type*} {m : ℕ} (v : Fin (m*2) → α) (i : Fin m) : + pairArrayEquiv α m v i = (v (pairLeft i), v (pairRight i)) := rfl + +lemma pair_wedge_product {n m : ℕ} (v : Fin (m*2) → Vec n) : + (List.ofFn (fun i : Fin m => ExteriorAlgebra.ι ℂ (v (pairLeft i)) * + ExteriorAlgebra.ι ℂ (v (pairRight i)))).prod = ExteriorAlgebra.ιMulti ℂ (m*2) v := by + rw [ExteriorAlgebra.ιMulti_apply, List.ofFn_mul, List.prod_flatten, List.map_ofFn] + congr 2 + funext i + simp [List.ofFn_succ, pairLeft, pairRight, finProdFinEquiv, mul_comm, add_comm] + +lemma twoForm_pow_expansion {n : ℕ} (A : Matrix (Fin n) (Fin n) ℂ) + (hA : ∀ i j, A j i = -A i j) (m : ℕ) : + twoForm A ^ m = (1/2:ℂ)^m • ∑ v : Fin (m*2) → Fin n, + (∏ k : Fin m, A (v (pairLeft k)) (v (pairRight k))) • + ExteriorAlgebra.ιMulti ℂ (m*2) (standardBasis n ∘ v) := by + rw [twoForm_full A hA, smul_pow] + congr 1 + rw [← Fintype.sum_prod_type (f := fun p : Fin n × Fin n => + A p.1 p.2 • (generator n p.1 * generator n p.2)), sum_pow_list] + simp_rw [ofFn_smul_prod] + apply Fintype.sum_equiv (pairArrayEquiv (Fin n) m).symm + intro p + have hp : pairArrayEquiv (Fin n) m ((pairArrayEquiv (Fin n) m).symm p) = p := + Equiv.apply_symm_apply _ p + conv_lhs => rw [← hp] + simp only [pairArrayEquiv_apply, generator] + congr 1 + exact pair_wedge_product (standardBasis n ∘ (pairArrayEquiv (Fin n) m).symm p) + +def permInjectiveEquiv (n : ℕ) : Equiv.Perm (Fin n) ≃ + {v : Fin n → Fin n // Function.Injective v} where + toFun σ := ⟨σ, σ.injective⟩ + invFun v := Equiv.ofBijective v.val (Finite.injective_iff_bijective.mp v.property) + left_inv σ := by ext i; rfl + right_inv v := by ext i; rfl + +lemma sum_basis_determinant (n : ℕ) (w : (Fin n → Fin n) → ℂ) : + (∑ v : Fin n → Fin n, w v * (standardBasis n).det (standardBasis n ∘ v)) = + ∑ σ : Equiv.Perm (Fin n), w σ * (Equiv.Perm.sign σ : ℂ) := by + classical + have hz : (∑ v : {f : Fin n → Fin n // ¬Function.Injective f}, + w v.val * (standardBasis n).det (standardBasis n ∘ v.val)) = 0 := by + apply Finset.sum_eq_zero + intro v hv + have hd : (standardBasis n).det (standardBasis n ∘ v.val) = 0 := by + apply AlternatingMap.map_eq_zero_of_not_injective + intro hi + exact v.property (fun a b hab => hi (by simp only [Function.comp_apply, hab])) + rw [hd, mul_zero] + rw [← Fintype.sum_subtype_add_sum_subtype (fun v : Fin n → Fin n => Function.Injective v), + hz, add_zero] + apply Fintype.sum_equiv (permInjectiveEquiv n).symm + intro v + let σ := (permInjectiveEquiv n).symm v + change w σ * (standardBasis n).det (standardBasis n ∘ σ) = w σ * _ + rw [AlternatingMap.map_perm, Module.Basis.det_self] + simp [σ, Units.smul_def, ← Int.cast_smul_eq_zsmul ℂ, smul_eq_mul] + +def pairEntries {m : ℕ} (A : Matrix (Fin (m*2)) (Fin (m*2)) ℂ) : ℂ := + ∏ i : Fin m, A (pairLeft i) (pairRight i) + + + +theorem pfaffian_permutation_expansion (m : ℕ) + (A : Matrix (Fin (m*2)) (Fin (m*2)) ℂ) (hA : ∀ i j, A j i = -A i j) : + pfaffian (m*2) A = ((1/2:ℂ)^m / m.factorial) * + ∑ σ : Equiv.Perm (Fin (m*2)), (Equiv.Perm.sign σ : ℂ) * + pairEntries (fun i j => A (σ i) (σ j)) := by + change topCoord (m*2) (twoForm A ^ ((m*2)/2)) / _ = _ + rw [Nat.mul_div_cancel m (by norm_num : 0 < 2), twoForm_pow_expansion A hA, + map_smul, map_sum] + simp only [map_smul, topCoord_wedge, smul_eq_mul] + rw [sum_basis_determinant] + unfold pairEntries + simp only [mul_comm (∏ i : Fin m, _) (Equiv.Perm.sign _ : ℂ)] + ring + +end + + + +noncomputable section +open scoped BigOperators +open MeasureTheory Set + +@[simp] lemma pairArrayEquiv_symm_left {α : Type*} {m : ℕ} (p : Fin m → α × α) (i : Fin m) : + (pairArrayEquiv α m).symm p (pairLeft i) = (p i).1 := by + exact congrArg (fun v => (v i).1) ((pairArrayEquiv α m).apply_symm_apply p) + +@[simp] lemma pairArrayEquiv_symm_right {α : Type*} {m : ℕ} (p : Fin m → α × α) (i : Fin m) : + (pairArrayEquiv α m).symm p (pairRight i) = (p i).2 := by + exact congrArg (fun v => (v i).2) ((pairArrayEquiv α m).apply_symm_apply p) + +def pairArrayMeasurableEquiv (α : Type*) [MeasurableSpace α] (m : ℕ) : + (Fin (m*2) → α) ≃ᵐ (Fin m → α × α) where + toEquiv := pairArrayEquiv α m + measurable_toFun := by + apply Measurable.of_eval + intro i + change Measurable (fun v : Fin (m*2) → α => (v (pairLeft i), v (pairRight i))) + fun_prop + measurable_invFun := by + apply Measurable.of_eval + intro j + obtain ⟨⟨i,j⟩,rfl⟩ := finProdFinEquiv.surjective j + fin_cases j + · change Measurable (fun p => (pairArrayEquiv α m).symm p (pairLeft i)) + simp only [pairArrayEquiv_symm_left] + fun_prop + · change Measurable (fun p => (pairArrayEquiv α m).symm p (pairRight i)) + simp only [pairArrayEquiv_symm_right] + fun_prop + +lemma pairArray_preimage_pi {α : Type*} {m : ℕ} (s : Fin (m*2) → Set α) : + (pairArrayEquiv α m).symm ⁻¹' (univ.pi s) = + univ.pi (fun i : Fin m => s (pairLeft i) ×ˢ s (pairRight i)) := by + ext p + simp only [mem_preimage, mem_pi, mem_univ, forall_const, mem_prod] + constructor + · intro hp i + exact ⟨by simpa using hp (pairLeft i), by simpa using hp (pairRight i)⟩ + · intro hp j + obtain ⟨⟨i,j⟩,rfl⟩ := finProdFinEquiv.surjective j + fin_cases j + · change (pairArrayEquiv α m).symm p (pairLeft i) ∈ s (pairLeft i) + simpa using (hp i).1 + · change (pairArrayEquiv α m).symm p (pairRight i) ∈ s (pairRight i) + simpa using (hp i).2 + +lemma measurePreserving_pairArray {α : Type*} [MeasurableSpace α] (μ : Measure α) + [SigmaFinite μ] (m : ℕ) : + MeasurePreserving (pairArrayMeasurableEquiv α m) + (Measure.pi (fun _ : Fin (m*2) => μ)) + (Measure.pi (fun _ : Fin m => μ.prod μ)) := by + suffices hs : MeasurePreserving (pairArrayMeasurableEquiv α m).symm + (Measure.pi (fun _ : Fin m => μ.prod μ)) + (Measure.pi (fun _ : Fin (m*2) => μ)) from hs.symm + refine ⟨(pairArrayMeasurableEquiv α m).symm.measurable, ?_⟩ + apply (Measure.pi_eq _).symm + intro s hs + rw [MeasurableEquiv.map_apply] + change (Measure.pi (fun _ : Fin m => μ.prod μ)) + ((pairArrayEquiv α m).symm ⁻¹' univ.pi s) = _ + rw [pairArray_preimage_pi, Measure.pi_pi] + simp only [Measure.prod_prod] + have h := finProdFinEquiv.prod_comp (fun i : Fin (m*2) => μ (s i)) + simpa only [Fintype.prod_prod_type, Fin.prod_univ_two, pairLeft, pairRight] using h + +lemma integral_pair_product {α : Type*} [MeasurableSpace α] (μ : Measure α) + [SigmaFinite μ] (m : ℕ) (f : Fin m → α × α → ℂ) : + (∫ x : Fin (m*2) → α, ∏ i : Fin m, f i (x (pairLeft i), x (pairRight i)) + ∂Measure.pi (fun _ => μ)) = ∏ i, ∫ rs, f i rs ∂μ.prod μ := by + rw [← integral_fintype_prod_eq_prod f (μ := fun _ : Fin m => μ.prod μ)] + exact (measurePreserving_pairArray μ m).integral_comp' (fun p => ∏ i, f i (p i)) + +lemma integrable_pair_product {α : Type*} [MeasurableSpace α] (μ : Measure α) + [SigmaFinite μ] (m : ℕ) {f : Fin m → α × α → ℂ} + (hf : ∀ i, Integrable (f i) (μ.prod μ)) : + Integrable (fun x : Fin (m*2) → α => ∏ i : Fin m, + f i (x (pairLeft i), x (pairRight i))) (Measure.pi (fun _ => μ)) := by + exact (measurePreserving_pairArray μ m).integrable_comp_of_integrable + (Integrable.fintype_prod hf) + +lemma prod_pairs {M : Type*} [CommMonoid M] {m : ℕ} (f : Fin (m*2) → M) : + (∏ i : Fin m, f (pairLeft i) * f (pairRight i)) = ∏ i, f i := by + simpa only [Fintype.prod_prod_type, Fin.prod_univ_two, pairLeft, pairRight] using + finProdFinEquiv.prod_comp f + +lemma piCongrLeft_const_apply {α : Type*} [MeasurableSpace α] {n : ℕ} + (σ : Equiv.Perm (Fin n)) (x : Fin n → α) : + (MeasurableEquiv.piCongrLeft (fun _ : Fin n => α) σ) x = x ∘ σ.symm := by + ext i + obtain ⟨j, rfl⟩ := σ.surjective i + simp [MeasurableEquiv.coe_piCongrLeft] + +lemma integral_alternating_times_perm {α : Type*} [MeasurableSpace α] (μ : Measure α) + [SigmaFinite μ] {n : ℕ} (F G : (Fin n → α) → ℂ) + (hF : ∀ σ : Equiv.Perm (Fin n), ∀ x, F (x ∘ σ) = (Equiv.Perm.sign σ : ℂ) * F x) + (σ : Equiv.Perm (Fin n)) : + (∫ x, F x * G (x ∘ σ) ∂Measure.pi (fun _ => μ)) = + (Equiv.Perm.sign σ : ℂ) * ∫ x, F x * G x ∂Measure.pi (fun _ => μ) := by + have h := (measurePreserving_piCongrLeft (fun _ : Fin n => μ) σ).integral_comp' + (fun x => F x * G (x ∘ σ)) + simp only [piCongrLeft_const_apply] at h + change (∫ x, F (x ∘ σ.symm) * G ((x ∘ σ.symm) ∘ σ) ∂Measure.pi (fun _ => μ)) = _ at h + have hc (x : Fin n → α) : (x ∘ σ.symm) ∘ σ = x := by ext i; simp + simp only [hc, hF, Equiv.Perm.sign_symm, mul_assoc, integral_const_mul] at h + exact h.symm + +lemma integrable_alternating_times_perm {α : Type*} [MeasurableSpace α] (μ : Measure α) + [SigmaFinite μ] {n : ℕ} (F G : (Fin n → α) → ℂ) + (hF : ∀ σ : Equiv.Perm (Fin n), ∀ x, F (x ∘ σ) = (Equiv.Perm.sign σ : ℂ) * F x) + (hi : Integrable (fun x => F x * G x) (Measure.pi (fun _ => μ))) + (σ : Equiv.Perm (Fin n)) : + Integrable (fun x => F x * G (x ∘ σ)) (Measure.pi (fun _ => μ)) := by + apply ((measurePreserving_piCongrLeft (fun _ : Fin n => μ) σ).integrable_comp_emb + (MeasurableEquiv.piCongrLeft (fun _ : Fin n => α) σ).measurableEmbedding).mp + have hc (x : Fin n → α) : (x ∘ σ.symm) ∘ σ = x := by ext i; simp + simp only [Function.comp_def, piCongrLeft_const_apply] + change Integrable (fun x => F (x ∘ σ.symm) * G ((x ∘ σ.symm) ∘ σ)) _ + simp only [hc, hF, mul_assoc] + exact hi.const_mul _ + +def evaluationMatrix {α : Type*} {n : ℕ} (φ : Fin n → α → ℂ) (x : Fin n → α) : + Matrix (Fin n) (Fin n) ℂ := fun i j => φ i (x j) + +def doubleIntegrand {α : Type*} {n : ℕ} (φ : Fin n → α → ℂ) (k : α → α → ℂ) + (i j : Fin n) (rs : α × α) : ℂ := φ i rs.1 * k rs.1 rs.2 * φ j rs.2 + +def doubleMomentMatrix {α : Type*} [MeasurableSpace α] {n : ℕ} (μ : Measure α) + (φ : Fin n → α → ℂ) (k : α → α → ℂ) : Matrix (Fin n) (Fin n) ℂ := + fun i j => ∫ rs, doubleIntegrand φ k i j rs ∂μ.prod μ + +lemma doubleMomentMatrix_skew {α : Type*} [MeasurableSpace α] {n : ℕ} (μ : Measure α) + [SigmaFinite μ] (φ : Fin n → α → ℂ) (k : α → α → ℂ) + (hk : ∀ r s, k s r = -k r s) (i j : Fin n) : + doubleMomentMatrix μ φ k j i = -doubleMomentMatrix μ φ k i j := by + unfold doubleMomentMatrix + rw [← integral_prod_swap (doubleIntegrand φ k j i), ← integral_neg] + apply integral_congr_ae + filter_upwards [] with rs + simp only [doubleIntegrand, Prod.fst_swap, Prod.snd_swap] + rw [hk rs.1 rs.2] + ring + +lemma evaluationMatrix_det_perm {α : Type*} {n : ℕ} (φ : Fin n → α → ℂ) + (σ : Equiv.Perm (Fin n)) (x : Fin n → α) : + (evaluationMatrix φ (x ∘ σ)).det = (Equiv.Perm.sign σ : ℂ) * (evaluationMatrix φ x).det := by + exact Matrix.det_permute' σ (evaluationMatrix φ x) + +lemma product_doubleIntegrand {α : Type*} {m : ℕ} (φ : Fin (m*2) → α → ℂ) + (k : α → α → ℂ) (σ : Equiv.Perm (Fin (m*2))) (x : Fin (m*2) → α) : + (∏ i : Fin m, doubleIntegrand φ k (σ (pairLeft i)) (σ (pairRight i)) + (x (pairLeft i), x (pairRight i))) = + (∏ i : Fin (m*2), φ (σ i) (x i)) * pairEntries (fun i j => k (x i) (x j)) := by + unfold doubleIntegrand pairEntries + rw [← prod_pairs (fun i => φ (σ i) (x i))] + simp only [Finset.prod_mul_distrib] + ring + +lemma determinant_times_pairs {α : Type*} {m : ℕ} (φ : Fin (m*2) → α → ℂ) + (k : α → α → ℂ) (x : Fin (m*2) → α) : + (evaluationMatrix φ x).det * pairEntries (fun i j => k (x i) (x j)) = + ∑ σ : Equiv.Perm (Fin (m*2)), (Equiv.Perm.sign σ : ℂ) * + ∏ i : Fin m, doubleIntegrand φ k (σ (pairLeft i)) (σ (pairRight i)) + (x (pairLeft i), x (pairRight i)) := by + rw [Matrix.det_apply, Finset.sum_mul] + apply Finset.sum_congr rfl + intro σ hσ + rw [product_doubleIntegrand] + simp only [evaluationMatrix, Units.smul_def, ← Int.cast_smul_eq_zsmul ℂ, smul_eq_mul] + ring + +lemma integrable_determinant_times_pairs {α : Type*} [MeasurableSpace α] (μ : Measure α) + [SigmaFinite μ] {m : ℕ} (φ : Fin (m*2) → α → ℂ) (k : α → α → ℂ) + (hi : ∀ i j, Integrable (doubleIntegrand φ k i j) (μ.prod μ)) : + Integrable (fun x => (evaluationMatrix φ x).det * pairEntries (fun i j => k (x i) (x j))) + (Measure.pi (fun _ => μ)) := by + simp only [determinant_times_pairs] + exact integrable_finsetSum _ (fun σ _ => (integrable_pair_product μ m (fun i => hi _ _)).const_mul _) + +lemma integral_determinant_times_pairs {α : Type*} [MeasurableSpace α] (μ : Measure α) + [SigmaFinite μ] {m : ℕ} (φ : Fin (m*2) → α → ℂ) (k : α → α → ℂ) + (hi : ∀ i j, Integrable (doubleIntegrand φ k i j) (μ.prod μ)) : + (∫ x, (evaluationMatrix φ x).det * pairEntries (fun i j => k (x i) (x j)) + ∂Measure.pi (fun _ => μ)) = + ∑ σ : Equiv.Perm (Fin (m*2)), (Equiv.Perm.sign σ : ℂ) * + pairEntries (fun i j => doubleMomentMatrix μ φ k (σ i) (σ j)) := by + simp only [determinant_times_pairs] + rw [integral_finsetSum _ (fun σ _ => (integrable_pair_product μ m (fun i => hi _ _)).const_mul _)] + apply Finset.sum_congr rfl + intro σ hσ + rw [integral_const_mul, integral_pair_product] + rfl + + + +theorem deBruijn_even {α : Type*} [MeasurableSpace α] (μ : Measure α) + [SigmaFinite μ] (m : ℕ) (φ : Fin (m*2) → α → ℂ) (k : α → α → ℂ) + (hk : ∀ r s, k s r = -k r s) + (hi : ∀ i j, Integrable (doubleIntegrand φ k i j) (μ.prod μ)) : + (∫ x, (evaluationMatrix φ x).det * pfaffian (m*2) (fun i j => k (x i) (x j)) + ∂Measure.pi (fun _ => μ)) = + (Nat.factorial (m*2) : ℂ) * pfaffian (m*2) (doubleMomentMatrix μ φ k) := by + let F : (Fin (m*2) → α) → ℂ := fun x => (evaluationMatrix φ x).det + let G : (Fin (m*2) → α) → ℂ := fun x => pairEntries (fun i j => k (x i) (x j)) + have hF (σ : Equiv.Perm (Fin (m*2))) (x : Fin (m*2) → α) : + F (x ∘ σ) = (Equiv.Perm.sign σ : ℂ) * F x := evaluationMatrix_det_perm φ σ x + have hI := integrable_determinant_times_pairs μ φ k hi + have hII (σ : Equiv.Perm (Fin (m*2))) : + Integrable (fun x => F x * ((Equiv.Perm.sign σ : ℂ) * G (x ∘ σ))) + (Measure.pi (fun _ => μ)) := by + have h := (integrable_alternating_times_perm μ F G hF hI σ).const_mul (Equiv.Perm.sign σ : ℂ) + convert h using 1 + ext x + ring + have hpoint (x : Fin (m*2) → α) : + F x * pfaffian (m*2) (fun i j => k (x i) (x j)) = + ((1/2:ℂ)^m / m.factorial) * + ∑ σ : Equiv.Perm (Fin (m*2)), F x * ((Equiv.Perm.sign σ : ℂ) * G (x ∘ σ)) := by + rw [pfaffian_permutation_expansion m _ (fun i j => hk _ _)] + simp only [Finset.mul_sum] + apply Finset.sum_congr rfl + intro σ _ + dsimp [F, G, Function.comp_def] + ring + change (∫ x, F x * pfaffian (m*2) _ ∂Measure.pi (fun _ => μ)) = _ + simp_rw [hpoint] + rw [integral_const_mul, integral_finsetSum _ (fun σ _ => hII σ)] + have he (σ : Equiv.Perm (Fin (m*2))) : + (∫ x, F x * ((Equiv.Perm.sign σ : ℂ) * G (x ∘ σ)) ∂Measure.pi (fun _ => μ)) = + ∫ x, F x * G x ∂Measure.pi (fun _ => μ) := by + calc + _ = (Equiv.Perm.sign σ : ℂ) * ∫ x, F x * G (x ∘ σ) ∂Measure.pi (fun _ => μ) := by + rw [← integral_const_mul] + congr 1 + ext x + ring + _ = _ := by + rw [integral_alternating_times_perm μ F G hF, ← mul_assoc] + have hs : (Equiv.Perm.sign σ : ℂ) * (Equiv.Perm.sign σ : ℂ) = 1 := by + have hs : (Equiv.Perm.sign σ : ℤ) * (Equiv.Perm.sign σ : ℤ) = 1 := + congrArg Units.val (Int.units_mul_self (Equiv.Perm.sign σ)) + exact_mod_cast hs + rw [hs, one_mul] + simp_rw [he] + rw [Finset.sum_const, Finset.card_univ, Fintype.card_perm, Fintype.card_fin, nsmul_eq_mul, + pfaffian_permutation_expansion m _ (doubleMomentMatrix_skew μ φ k hk), + ← integral_determinant_times_pairs μ φ k hi] + dsimp [F,G] + ring + + + + + +lemma borderLinear_eq_topCoord {n : ℕ} (hn : Odd n) + (A : Matrix (Fin n) (Fin n) ℂ) (u : Vec n) : + borderLinear A u = topCoord n (twoForm A ^ (n/2) * ExteriorAlgebra.ι ℂ u) / (n/2).factorial := by + have hn' : 2*(n/2)+1 = n := by + obtain ⟨k, hk⟩ := hn + omega + have hhom : twoForm A ^ (n/2) * ExteriorAlgebra.ι ℂ u ∈ + ExteriorAlgebra.exteriorPower ℂ n (Vec n) := by + simpa only [hn'] using SetLike.mul_mem_graded (twoForm_pow_mem A (n/2)) + (show ExteriorAlgebra.ι ℂ u ∈ ExteriorAlgebra.exteriorPower ℂ 1 (Vec n) from by + simpa only [ExteriorAlgebra.exteriorPower, pow_one] using + (LinearMap.mem_range_self (ExteriorAlgebra.ι ℂ) u)) + change topCoord (n+1) (ExteriorAlgebra.map (embedMap n) (twoForm A) ^ (n/2) * + (ExteriorAlgebra.ι ℂ (embedMap n u) * generator (n+1) (Fin.last n))) / _ = _ + rw [← mul_assoc, ← ExteriorAlgebra.map_apply_ι, ← map_pow, ← map_mul, + topCoord_embed_mul_last _ hhom] + +def oddPairEntries {m : ℕ} (A : Matrix (Fin (m*2+1)) (Fin (m*2+1)) ℂ) + (u : Fin (m*2+1) → ℂ) : ℂ := + (∏ k : Fin m, A (pairLeft k).castSucc (pairRight k).castSucc) * u (Fin.last (m*2)) + +lemma wedge_snoc {n l : ℕ} (v : Fin l → Vec n) (u : Vec n) : + ExteriorAlgebra.ιMulti ℂ l v * ExteriorAlgebra.ι ℂ u = + ExteriorAlgebra.ιMulti ℂ (l+1) (Fin.snoc v u) := by + simp only [ExteriorAlgebra.ιMulti_apply, List.ofFn_succ', List.prod_concat, + Fin.snoc_castSucc, Fin.snoc_last] + +lemma twoForm_pow_mul_expansion {n : ℕ} (A : Matrix (Fin n) (Fin n) ℂ) + (hA : ∀ i j, A j i = -A i j) (u : Vec n) (m : ℕ) : + twoForm A ^ m * ExteriorAlgebra.ι ℂ u = + (1/2:ℂ)^m • ∑ v : Fin (m*2+1) → Fin n, + ((∏ k : Fin m, A (v (pairLeft k).castSucc) (v (pairRight k).castSucc)) * + u (v (Fin.last (m*2)))) • + ExteriorAlgebra.ιMulti ℂ (m*2+1) (standardBasis n ∘ v) := by + rw [twoForm_pow_expansion A hA m, ← generator_expansion n u, smul_mul_assoc, + Finset.sum_mul] + simp_rw [Finset.mul_sum, smul_mul_smul_comm, generator, wedge_snoc] + congr 1 + rw [← Fintype.sum_prod_type (f := fun p : (Fin (m*2) → Fin n) × Fin n => + ((∏ k : Fin m, A (p.1 (pairLeft k)) (p.1 (pairRight k)))*u p.2) • + ExteriorAlgebra.ιMulti ℂ (m*2+1) (Fin.snoc (standardBasis n ∘ p.1) (standardBasis n p.2)))] + apply Fintype.sum_equiv ((Equiv.prodComm _ _).trans + (Fin.snocEquiv (fun _ : Fin (m*2+1) => Fin n))) + intro p + simp only [Equiv.trans_apply, Equiv.prodComm_apply, Fin.snocEquiv, Equiv.coe_fn_mk, Fin.snoc_castSucc, Fin.snoc_last] + congr 1 + congr 1 + ext i + refine Fin.lastCases ?_ (fun j => ?_) i <;> simp [Function.comp_def] + + +theorem pfaffian_border_permutation_expansion (m : ℕ) + (A : Matrix (Fin (m*2+1)) (Fin (m*2+1)) ℂ) (hA : ∀ i j, A j i = -A i j) + (u : Fin (m*2+1) → ℂ) : + pfaffian (m*2+2) (border A u) = ((1/2:ℂ)^m / m.factorial) * + ∑ σ : Equiv.Perm (Fin (m*2+1)), (Equiv.Perm.sign σ : ℂ) * + oddPairEntries (fun i j => A (σ i) (σ j)) (u ∘ σ) := by + have hn : Odd (m*2+1) := ⟨m, by omega⟩ + rw [pfaffian_border hn A hA u, borderLinear_eq_topCoord hn, + show (m*2+1)/2=m by omega, twoForm_pow_mul_expansion A hA u m, + map_smul, map_sum] + simp only [map_smul, topCoord_wedge, smul_eq_mul] + rw [sum_basis_determinant] + unfold oddPairEntries + simp only [Function.comp_apply, mul_comm ((∏ i : Fin m, _) * _) (Equiv.Perm.sign _ : ℂ)] + ring + +end +end StripPfaffian + +end OAI diff --git a/lean/OAI/Combinatorics/StripMass/PairSelfNode.lean b/lean/OAI/Combinatorics/StripMass/PairSelfNode.lean new file mode 100644 index 0000000000000000000000000000000000000000..1d48f5a63420e534d2d35c63f3ed9594380f8d83 --- /dev/null +++ b/lean/OAI/Combinatorics/StripMass/PairSelfNode.lean @@ -0,0 +1,529 @@ +import Mathlib +import OAI.Combinatorics.StripMass.ScalarMergeTrig +import OAI.Combinatorics.StripMass.FirstThree + +namespace OAI + +/-! Critical honeycomb strip paths, polynomial identities and crossing mass. -/ + + + +namespace CriticalStrip.Diagram +noncomputable section +open scoped Classical + +lemma matrixPrefix_zero_of_first {K ι:Type*} [CommRing K] [Fintype ι] [DecidableEq ι] + {n:ℕ} (A:Fin (n+1) → Matrix ι ι K) (h:A 0=0) (k:ℕ) : + matrixPrefix A (k+1)=0 := by + induction k with + | zero => simpa [matrixPrefix] using h + | succ k ih => rw [matrixPrefix]; split_ifs <;> simp only [ih,Matrix.mul_zero] + +lemma reducedMovingStepL_pair_zero {n:ℕ} (s:ℕ) (hs:s=2 ∨ s=3) : + (reducedMovingStepL (1:Fin (n+2)) 0).map (pairEvaluation n s).toRingHom=0 := by + simp only [reducedMovingStepL,show (0:Fin (n+2))≠1 by intro h; have := congrArg Fin.val h; simp at this,ite_false, + show ¬(1:Fin (n+2))<0 from not_lt_of_ge (Fin.zero_le _)] + rw [matrix_map_ring_smul,matrix_map_ring_smul] + rw [show (pairEvaluation n s).toRingHom + (torusNumeratorL (variableExponent (1:Fin (n+2))-variableExponent 0) (phase^3) .vacant)=0 from pairEvaluation_vacantNumerator s hs] + simp + +lemma nodalDatumL_pair_self_zero {n:ℕ} (W:Pairing (n+1) → Laurent (n+1)) + (s:ℕ) (hs:s=2 ∨ s=3) (p:Pairing (n+3)) : + pairEvaluation n s (nodalDatumL W (1:Fin (n+2)) p)=0 := by + simp only [nodalDatumL,map_mul] + have hm:(matrixPrefix (reducedMovingStepL (1:Fin (n+2))) (n+2)).map (pairEvaluation n s).toRingHom=0 := by + rw [matrixPrefix_map] + exact matrixPrefix_zero_of_first _ (reducedMovingStepL_pair_zero s hs) (n+1) + rw [show pairEvaluation n s + ((matrixPrefix (reducedMovingStepL (1:Fin (n+2))) (n+2)).mulVec _ p)= + ((matrixPrefix (reducedMovingStepL (1:Fin (n+2))) (n+2)).map (pairEvaluation n s).toRingHom).mulVec _ p from + RingHom.map_mulVec _ _ _ p] + rw [hm,Matrix.zero_mulVec] + simp + +lemma rationalNodalPolynomial_laurent_at_node {n:ℕ} + (W:Pairing n → Laurent n) (hW:∀q,evalLaurent (W q)=rationalVacuum n q) + (P:Pairing (n+2) → Polynomial (Laurent (n+1))) + (hP:∀p,(P p).map (algebraMap (SpectralRing (n+1)) (SpectralField (n+1)))=rationalNodalPolynomial (n+1) p) + (p:Pairing (n+2)) (i:Fin (n+1)) : + (P p).eval (betaL i)=nodalDatumL W i p := by + apply IsFractionRing.injective (SpectralRing (n+1)) (SpectralField (n+1)) + change evalLaurent ((P p).eval (betaL i))=evalLaurent (nodalDatumL W i p) + rw [nodalDatumL_map W hW] + have hh:=rationalNodalPolynomial_at_node p i + rw [eq_div_iff (by split_ifs; exact deletionNode_sine_ne_zero i; exact one_ne_zero)] + rw [mul_comm] + rw [←hP] at hh + have hf:evalLaurent ((P p).eval (betaL i))= + ((P p).map (algebraMap (SpectralRing (n+1)) (SpectralField (n+1)))).eval (deletionBeta i) := by + rw [←betaL_map] + exact (Polynomial.eval_map_apply ..).symm + rw [hf] + exact hh + + + +theorem rationalNodalPolynomial_pair_self {n:ℕ} + (W:Pairing (n+1) → Laurent (n+1)) (hW:∀q,evalLaurent (W q)=rationalVacuum (n+1) q) + (P:Pairing (n+3) → Polynomial (Laurent (n+2))) + (hP:∀p,(P p).map (algebraMap (SpectralRing (n+2)) (SpectralField (n+2)))=rationalNodalPolynomial (n+2) p) + (s:ℕ) (hs:s=2 ∨ s=3) (p:Pairing (n+3)) : + ((P p).map (pairEvaluation n s).toRingHom).eval (pairEvaluation n s (betaL 1))=0 := by + change ((P p).map (pairEvaluation n s).toRingHom).eval ((pairEvaluation n s).toRingHom (betaL 1))=0 + rw [Polynomial.eval_map_apply,rationalNodalPolynomial_laurent_at_node W hW P hP] + exact nodalDatumL_pair_self_zero W s hs p + + + + + + + +def pairIndex (n:ℕ) : Fin (n+2) → Fin (n+1) := Fin.cons 0 (Fin.cons 0 Fin.succ) +def pairExponent (n s:ℕ) : Fin (n+2) → ℕ := fun i =>if i=1 then 3-s else 3 + +def pairEarlierWeights (n s:ℕ) : Fin (n+2) → Weights (SpectralField (n+1)) := + fun j =>torusWeights (constF (n+1) phase^(pairExponent n s j)/variableF (pairIndex n j)) + +def pairNodeWeights (n s:ℕ) (i:Fin (n+2)) : Fin (n+3) → Weights (SpectralField (n+1)) := + Fin.snoc (pairEarlierWeights n s) (torusWeights (variableF (pairIndex n i))⁻¹) + +lemma pairExponent_le (n s:ℕ) (i:Fin (n+2)) : pairExponent n s i≤3 := by + unfold pairExponent; split_ifs <;> omega + +lemma pairExponent_mixed {n s:ℕ} (i j:Fin (n+2)) + (hi:pairExponent n s i≠0 ∧ pairExponent n s i≠3) + (hj:pairExponent n s j≠0 ∧ pairExponent n s j≠3) : i=j := by + have h₁:i=1 := by by_contra h; exact hi.2 (ite_eq_right h) + have h₂:j=1 := by by_contra h; exact hj.2 (ite_eq_right h) + exact h₁.trans h₂.symm + +lemma pairEarlier_regular (n s:ℕ) : VacuumRegular (pairEarlierWeights n s) := + phaseRows_regular (pairIndex n) (pairExponent n s) (pairExponent_le n s) pairExponent_mixed + +lemma pairNode_regular (n s:ℕ) (i:Fin (n+2)) : VacuumRegular (pairNodeWeights n s i) := by + have h:=phaseRows_regular (Fin.snoc (pairIndex n) (pairIndex n i)) + (Fin.snoc (pairExponent n s) 0) + (fun j =>Fin.lastCases (by simp) (fun j =>by simpa using pairExponent_le n s j) j) ?_ + · convert h using 1 + funext j + induction j using Fin.lastCases <;> simp [pairNodeWeights,pairEarlierWeights] + · intro j k hj hk + induction j using Fin.lastCases with + | last => exact (hj.1 (by simp)).elim + | cast j => induction k using Fin.lastCases with + | last => exact (hk.1 (by simp)).elim + | cast k => exact congrArg Fin.castSucc (pairExponent_mixed (s:=s) j k (by simpa using hj) (by simpa using hk)) + +lemma pairPoint_of_ne {n s:ℕ} (i:Fin (n+2)) (hi:i≠1) : + pairPoint n s i=variableF (pairIndex n i) := by + induction i using Fin.cases with + | zero => rfl + | succ i => induction i using Fin.cases with + | zero => exact (hi rfl).elim + | succ i => rfl + +lemma pairArgument {n s:ℕ} (hs:s≤3) (i:Fin (n+2)) : + constF (n+1) phase^3/pairPoint n s i= + constF (n+1) phase^(pairExponent n s i)/variableF (pairIndex n i) := by + by_cases hi:i=1 + · subst i + change constF (n+1) phase^3/(constF (n+1) phase^s*variableF 0)=constF (n+1) phase^(if (1:Fin (n+2))=1 then 3-s else 3)/variableF 0 + rw [ite_eq_left rfl] + have hp:constF (n+1) phase^(3-s)*constF (n+1) phase^s=constF (n+1) phase^3 := by rw [←pow_add,Nat.sub_add_cancel hs] + apply (div_eq_div_iff (mul_ne_zero (pow_ne_zero _ (constF_phase_ne_zero _)) (variableF_ne_zero _)) (variableF_ne_zero _)).mpr + rw [←hp]; ring + · rw [pairPoint_of_ne i hi,pairExponent,ite_eq_right hi] + +lemma pairEarlier_L {n s:ℕ} (hs:s≤3) (i:Fin (n+2)) : + torusL (constF (n+1) phase^3/pairPoint n s i)≠0 := by + rw [pairArgument hs i] + exact torusL_phaseRow_ne_zero _ _ (pairExponent_le n s i) + +lemma rationalAt_pair_nodalWeights {n s:ℕ} (hs:s≤3) (i:Fin (n+2)) (hi:i≠1) + (j:Fin (n+3)) (t:Tile) : + RationalAt (pairEvaluation n s).toRingHom ((nodalWeights i j).tile t) ((pairNodeWeights n s i j).tile t) := by + induction j using Fin.lastCases with + | cast j => + simp only [nodalWeights,Fin.snoc_castSucc,spectralWeights,pairNodeWeights,pairEarlierWeights] + rw [←pairArgument hs j] + exact rationalAt_torusWeights _ + (((rationalAt_const (pairEvaluation n s) phase).pow 3).div (rationalAt_pair_variable s j) (pairPoint_ne_zero n s j)) + (div_ne_zero (pow_ne_zero _ (constF_phase_ne_zero _)) (pairPoint_ne_zero n s j)) (pairEarlier_L hs j) t + | last => + simp only [nodalWeights_last,pairNodeWeights,Fin.snoc_last] + have hv:=rationalAt_pair_variable s i + rw [pairPoint_of_ne i hi] at hv + exact rationalAt_torusWeights _ (hv.inv (variableF_ne_zero _)) + (inv_ne_zero (variableF_ne_zero _)) + (by simpa only [pow_zero,one_div] using torusL_phaseRow_ne_zero (pairIndex n i) 0 (by omega)) t + + + + + + + +lemma phaseCosine {n:ℕ} (i:Fin n) (s:ℤ) : + torusCos ((constF n phase^s*variableF i)^2/constF n phase^3)=fcos i (2*s-3) := by + rw [fcos_eq,show 2*s-3=s*2-3 by ring,zpow_sub₀ phase_ne_zero,zpow_mul] + simp only [constF,map_div₀,map_pow,map_zpow₀,zpow_ofNat] + congr 1 + ring + +def pairCosines (n s:ℕ) : Fin (n+2) → SpectralField (n+1) := + Fin.cons (fcos 0 (-3)) (Fin.cons (fcos 0 (2*(s:ℤ)-3)) (fun i =>fcos i.succ (-3))) +def pairBeta (n s:ℕ) : Fin (n+2) → SpectralField (n+1) := + Fin.cons (deletionBeta 0) (Fin.cons (fcos 0 (2*(s:ℤ)+3)) (fun i =>deletionBeta i.succ)) + +lemma pairPoint_cosine {n s:ℕ} (i:Fin (n+2)) : + torusCos ((pairPoint n s i)^2/constF (n+1) phase^3)=pairCosines n s i := by + induction i using Fin.cases with + | zero => simpa only [pairPoint,pairCosines,Fin.cons_zero,zpow_zero,one_mul,Int.mul_zero,Int.zero_sub] using phaseCosine (0:Fin (n+1)) 0 + | succ i => induction i using Fin.cases with + | zero => simpa only [pairPoint,pairCosines,Fin.cons_succ,Fin.cons_zero,zpow_natCast] using phaseCosine (0:Fin (n+1)) (s:ℤ) + | succ i => simpa only [pairPoint,pairCosines,Fin.cons_succ,zpow_zero,one_mul,Int.mul_zero,Int.zero_sub] using phaseCosine i.succ 0 + +lemma pairNode_cosine {n s:ℕ} (i:Fin (n+2)) : + torusCos ((pairPoint n s i*constF (n+1) phase^3)^2/constF (n+1) phase^3)=pairBeta n s i := by + induction i using Fin.cases with + | zero => rfl + | succ i => induction i using Fin.cases with + | zero => + change torusCos (((constF (n+1) phase^s*variableF 0)*constF (n+1) phase^3)^2/constF (n+1) phase^3)=_ + have he:(constF (n+1) phase^s*variableF 0)*constF (n+1) phase^3=constF (n+1) phase^((s:ℤ)+3)*variableF 0 := by + rw [zpow_add₀ (constF_phase_ne_zero _),zpow_natCast,zpow_ofNat]; ring + rw [he,phaseCosine] + change fcos 0 (2*((s:ℤ)+3)-3)=fcos 0 (2*(s:ℤ)+3) + congr 1; ring + | succ i => rfl + +lemma rationalAt_pair_spectralA {n:ℕ} (s:ℕ) (i:Fin (n+2)) : + RationalAt (pairEvaluation n s).toRingHom (spectralA i) (pairCosines n s i) := by + rw [←pairPoint_cosine i] + exact rationalAt_torusCos _ (((rationalAt_pair_variable s i).pow 2).div + ((rationalAt_const (pairEvaluation n s) phase).pow 3) (pow_ne_zero _ (constF_phase_ne_zero _))) + (div_ne_zero (pow_ne_zero _ (pairPoint_ne_zero n s i)) (pow_ne_zero _ (constF_phase_ne_zero _))) + +lemma rationalAt_pair_deletionNode {n:ℕ} (s:ℕ) (i:Fin (n+2)) : + RationalAt (pairEvaluation n s).toRingHom (deletionNode i) + (pairPoint n s i*constF (n+1) phase^3) := + (rationalAt_pair_variable s i).mul ((rationalAt_const (pairEvaluation n s) phase).pow 3) + +lemma rationalAt_pair_deletionBeta {n:ℕ} (s:ℕ) (i:Fin (n+2)) : + RationalAt (pairEvaluation n s).toRingHom (deletionBeta i) (pairBeta n s i) := by + rw [←pairNode_cosine i] + exact rationalAt_torusCos _ (((rationalAt_pair_deletionNode s i).pow 2).div + ((rationalAt_const (pairEvaluation n s) phase).pow 3) (pow_ne_zero _ (constF_phase_ne_zero _))) + (div_ne_zero (pow_ne_zero _ (mul_ne_zero (pairPoint_ne_zero n s i) (pow_ne_zero _ (constF_phase_ne_zero _)))) + (pow_ne_zero _ (constF_phase_ne_zero _))) + +lemma pairEvaluation_betaL {n:ℕ} (s:ℕ) (i:Fin (n+2)) : + pairEvaluation n s (betaL i)=pairBeta n s i := by + have h:=RationalAt.algebraMap (φ:=(pairEvaluation n s).toRingHom) (F:=SpectralField (n+2)) (betaL i) + change RationalAt _ (evalLaurent (betaL i)) _ at h + rw [betaL_map] at h + exact h.unique (rationalAt_pair_deletionBeta s i) + +lemma pairBeta_of_ne {n s:ℕ} (i:Fin (n+2)) (hi:i≠1) : pairBeta n s i=deletionBeta (pairIndex n i) := by + rw [←pairNode_cosine i,pairPoint_of_ne i hi] + rfl + +lemma rationalAt_pair_nodalScalar {n:ℕ} (s:ℕ) (i:Fin (n+2)) : + RationalAt (pairEvaluation n s).toRingHom (nodalScalar i) + (scalarValue (algebraMap ℂ (SpectralField (n+1))) (Fin.snoc (pairCosines n s) (pairBeta n s i))) := by + apply rationalAt_scalarValue + intro j + induction j using Fin.lastCases with + | last => simpa only [Fin.snoc_last] using rationalAt_pair_deletionBeta s i + | cast j => simpa only [Fin.snoc_castSucc] using rationalAt_pair_spectralA s j + +lemma rationalAt_pair_nodalVacuum {n s:ℕ} (hs:s≤3) (i:Fin (n+2)) (hi:i≠1) (p:Pairing (n+3)) : + RationalAt (pairEvaluation n s).toRingHom (nodalVacuum i p) + (scalarValue (algebraMap ℂ (SpectralField (n+1))) (Fin.snoc (pairCosines n s) (pairBeta n s i))* + normalizedVacuum (pairNodeWeights n s i) p) := + (rationalAt_pair_nodalScalar s i).mul + (rationalAt_normalizedVacuum _ _ (rationalAt_pair_nodalWeights hs i hi) (pairNode_regular n s i) p) + + + + + + + +lemma twoRows_omit_one {K:Type*} {n:ℕ} (a b d e:Weights K) (w:Fin n → Weights K) : + (fun j =>(PartialColumn.twoRows (Fin.cons a (Fin.cons b w)) 0 d e) + ((1:Fin (n+2)).succAbove j))=Fin.cons d w := by + funext j + induction j using Fin.cases with + | zero => simp [PartialColumn.twoRows,Fin.succAbove] + | succ j => simp [PartialColumn.twoRows,Fin.succAbove,Fin.lt_def] + +lemma omit_first_two {α:Type*} {n:ℕ} (a b:α) (w:Fin n → α) : + (fun j =>(Fin.cons a (Fin.cons b w) : Fin (n+2) → α) + ((1:Fin (n+2)).succAbove ((0:Fin (n+1)).succAbove j)))=w := by + funext j + simp [Fin.succAbove,Fin.lt_def] + +lemma normalizedVacuum_merge_cons {n m:ℕ} (w:Fin n → Weights (SpectralField m)) + (z:SpectralField m) (hz:z≠0) (hL:torusL z≠0) + (hL1:torusL (constF m phase*z)≠0) (hL2:torusL (constF m phase^2*z)≠0) + (hr:VacuumRegular (Fin.cons (torusWeights (constF m phase^2*z)) (Fin.cons (torusWeights z) w))) + (hr':VacuumRegular (Fin.cons (torusWeights (constF m phase*z)) w)) : + normalizedVacuum (Fin.cons (torusWeights (constF m phase^2*z)) (Fin.cons (torusWeights z) w))= + (mergeMap 0 (show 2≤n+2 by omega)).mulVec + (normalizedVacuum (Fin.cons (torusWeights (constF m phase*z)) w)) := by + have he:=normalizedVacuum_merge 0 (show 2≤n+2 by omega) + (Fin.cons (torusWeights (constF m phase^2*z)) (Fin.cons (torusWeights z) w)) + z hz hL hL1 hL2 rfl rfl hr + have hrows : (fun i => PartialColumn.twoRows + (Fin.cons (torusWeights (constF m phase^2*z)) (Fin.cons (torusWeights z) w)) 0 + (torusWeights (constF m phase*z)) swapWeights + ((⟨0+1,by omega⟩ : Fin (n+2)).succAbove i)) = Fin.cons (torusWeights (constF m phase*z)) w := + twoRows_omit_one _ _ _ _ _ + rw [hrows] at he + exact he hr' + +lemma normalizedVacuum_deletion_cons {n m:ℕ} (w:Fin n → Weights (SpectralField m)) + (z:SpectralField m) (hz:z≠0) (hL:torusL z≠0) (hL3:torusL (constF m phase^3*z)≠0) + (hr:VacuumRegular (Fin.cons (torusWeights (constF m phase^3*z)) (Fin.cons (torusWeights z) w))) + (hr':VacuumRegular w) : + normalizedVacuum (Fin.cons (torusWeights (constF m phase^3*z)) (Fin.cons (torusWeights z) w))= + (deletionMap 0 (show 2≤n+2 by omega)).mulVec (normalizedVacuum w) := by + have he:=normalizedVacuum_deletion 0 (show 2≤n+2 by omega) + (Fin.cons (torusWeights (constF m phase^3*z)) (Fin.cons (torusWeights z) w)) + z hz hL hL3 rfl rfl hr + have hrows : (fun i:Fin n => (Fin.cons (torusWeights (constF m phase^3*z)) (Fin.cons (torusWeights z) w) : Fin (n+2) → Weights (SpectralField m)) + ((⟨0+1,by omega⟩ : Fin (n+2)).succAbove ((⟨0,by omega⟩ : Fin (n+1)).succAbove i))) = w := + by funext i; simp [Fin.succAbove,Fin.lt_def] + rw [hrows] at he + exact he hr' + + + + + + + +def deletePoint (n:ℕ) : Fin n → SpectralField (n+1) := fun i =>variableF i.succ + +def deleteWeights (n:ℕ) : Fin n → Weights (SpectralField (n+1)) := + fun i =>torusWeights (constF (n+1) phase^3/variableF i.succ) + +lemma deleteWeights_regular (n:ℕ) : VacuumRegular (deleteWeights n) := + phaseRows_regular Fin.succ (fun _ =>3) (by intros; omega) (by intros i j hi; exact (hi.2 rfl).elim) + +lemma pairEarlier_delete (n:ℕ) : pairEarlierWeights n 3= + Fin.cons (torusWeights (constF (n+1) phase^3*(variableF 0)⁻¹)) + (Fin.cons (torusWeights ((variableF 0)⁻¹)) (deleteWeights n)) := by + funext i + induction i using Fin.cases with + | zero => simp [pairEarlierWeights,pairExponent,pairIndex,div_eq_mul_inv] + | succ i => induction i using Fin.cases with + | zero => simp [pairEarlierWeights,pairExponent,pairIndex] + | succ i => + have hi : i.succ.succ≠(1:Fin (n+2)) := by intro h; have := congrArg Fin.val h; simp at this + simp [pairEarlierWeights,pairExponent,pairIndex,hi,deleteWeights] + +lemma normalizedVacuum_pair_delete (n:ℕ) : + normalizedVacuum (pairEarlierWeights n 3)= + (deletionMap 0 (show 2≤n+2 by omega)).mulVec (normalizedVacuum (deleteWeights n)) := by + have h:=normalizedVacuum_deletion_cons (deleteWeights n) ((variableF (0:Fin (n+1)))⁻¹) + (inv_ne_zero (variableF_ne_zero _)) + (by simpa using torusL_phaseRow_ne_zero (0:Fin (n+1)) 0 (by omega)) + (by simpa only [div_eq_mul_inv] using torusL_phaseRow_ne_zero (0:Fin (n+1)) 3 (by omega)) + (by rw [←pairEarlier_delete]; exact pairEarlier_regular n 3) (deleteWeights_regular n) + rwa [←pairEarlier_delete] at h + +lemma pairNode_delete {n:ℕ} (i:Fin (n+2)) : pairNodeWeights n 3 i= + Fin.cons (torusWeights (constF (n+1) phase^3*(variableF 0)⁻¹)) + (Fin.cons (torusWeights ((variableF 0)⁻¹)) + (copiedNodeWeights (Fin.succ : Fin n → Fin (n+1)) (pairIndex n i))) := by + rw [pairNodeWeights,pairEarlier_delete] + rw [←Fin.cons_snoc_eq_snoc_cons,←Fin.cons_snoc_eq_snoc_cons] + rfl + +lemma normalizedVacuum_pairNode_delete {n:ℕ} (i:Fin (n+2)) : + normalizedVacuum (pairNodeWeights n 3 i)= + (deletionMap 0 (show 2≤n+3 by omega)).mulVec + (normalizedVacuum (copiedNodeWeights (Fin.succ : Fin n → Fin (n+1)) (pairIndex n i))) := by + have h:=normalizedVacuum_deletion_cons (copiedNodeWeights (Fin.succ : Fin n → Fin (n+1)) (pairIndex n i)) + ((variableF (0:Fin (n+1)))⁻¹) (inv_ne_zero (variableF_ne_zero _)) + (by simpa using torusL_phaseRow_ne_zero (0:Fin (n+1)) 0 (by omega)) + (by simpa only [div_eq_mul_inv] using torusL_phaseRow_ne_zero (0:Fin (n+1)) 3 (by omega)) + (by rw [←pairNode_delete i]; exact pairNode_regular n 3 i) (copiedNode_regular _ _) + rwa [←pairNode_delete i] at h + +lemma deletePoint_node_weights {n:ℕ} (i:Fin (n+1)) : + (fun j =>torusWeights (constF (n+1) phase^3/ + (Fin.snoc (deletePoint n) (deletionNode i) : Fin (n+1) → SpectralField (n+1)) j)) = + copiedNodeWeights (Fin.succ : Fin n → Fin (n+1)) i := by + funext j + induction j using Fin.lastCases with + | last => + simp only [Fin.snoc_last,copiedNodeWeights] + congr 1 + rw [deletionNode] + field_simp [constF_phase_ne_zero,variableF_ne_zero] + | cast j => simp only [Fin.snoc_castSucc,copiedNodeWeights,deletePoint,spectralWeights] + +lemma deletePoint_node_L {n:ℕ} (i:Fin (n+1)) (j:Fin (n+1)) : + torusL (constF (n+1) phase^3/ + (Fin.snoc (deletePoint n) (deletionNode i) : Fin (n+1) → SpectralField (n+1)) j)≠0 := by + induction j using Fin.lastCases with + | last => + rw [Fin.snoc_last] + have he:constF (n+1) phase^3/deletionNode i=(variableF i)⁻¹ := by + rw [deletionNode]; field_simp [constF_phase_ne_zero,variableF_ne_zero] + rw [he] + simpa using torusL_phaseRow_ne_zero i 0 (by omega) + | cast j => simpa only [Fin.snoc_castSucc,deletePoint] using torusL_phaseRow_ne_zero j.succ 3 (by omega) + + + + + + + +lemma Fin.snoc_twoCons {α:Type*} {n:ℕ} (a b y:α) (x:Fin n → α) : + (Fin.snoc (Fin.cons a (Fin.cons b x)) y : Fin (n+3) → α)=(Fin.cons a (Fin.cons b (Fin.snoc x y)) : Fin (n+3) → α) := by + rw [←Fin.cons_snoc_eq_snoc_cons,←Fin.cons_snoc_eq_snoc_cons] + +def deletePairScalar (n:ℕ) : SpectralField (n+1) := + (fcos 0 (-3)+fcos 0 3+constF (n+1) rho)* + ∏j:Fin n,(fcos j.succ (-3)-fcos 0 (-9))*(fcos j.succ (-3)-fcos 0 9) + +def mergePairScalar (n:ℕ) : SpectralField (n+1) := + (fcos 0 (-3)+fcos 0 1+constF (n+1) rho)*∏j:Fin n,(fcos j.succ (-3)+fcos 0 (-1)) + +lemma scalar_pair_delete (n:ℕ) : + scalarValue (algebraMap ℂ (SpectralField (n+1))) (pairCosines n 3)= + deletePairScalar n*scalarValue (algebraMap ℂ (SpectralField (n+1))) (fun j:Fin n =>fcos j.succ (-3)) := by + exact scalarValue_fcos_delete 0 (-3) (fun j:Fin n =>fcos j.succ (-3)) + +lemma scalar_pair_delete_snoc {n:ℕ} (b:SpectralField (n+1)) : + scalarValue (algebraMap ℂ (SpectralField (n+1))) (Fin.snoc (pairCosines n 3) b)= + deletePairScalar n*((b-fcos 0 (-9))*(b-fcos 0 9))* + scalarValue (algebraMap ℂ (SpectralField (n+1))) (Fin.snoc (fun j:Fin n =>fcos j.succ (-3)) b) := by + have he:=scalarValue_fcos_delete (0:Fin (n+1)) (-3) + (Fin.snoc (fun j:Fin n =>fcos j.succ (-3)) b) + unfold pairCosines + rw [Fin.snoc_twoCons] + norm_num only at he ⊢ + rw [he] + simp only [Fin.prod_univ_castSucc,Fin.snoc_castSucc,Fin.snoc_last] + dsimp only [deletePairScalar] + ring + +lemma scalar_pair_merge (n:ℕ) : + scalarValue (algebraMap ℂ (SpectralField (n+1))) (pairCosines n 2)= + mergePairScalar n*scalarValue (algebraMap ℂ (SpectralField (n+1))) + (Fin.cons (fcos 0 (-1)) (fun j:Fin n =>fcos j.succ (-3))) := by + exact scalarValue_fcos_merge_all 0 (-1) Fin.succ (fun _:Fin n =>(-3)) + +lemma scalar_pair_merge_snoc {n:ℕ} (i:Fin (n+2)) (hi:i≠1) : + scalarValue (algebraMap ℂ (SpectralField (n+1))) (Fin.snoc (pairCosines n 2) (pairBeta n 2 i))= + mergePairScalar n*(pairBeta n 2 i+fcos 0 (-1))* + scalarValue (algebraMap ℂ (SpectralField (n+1))) + (Fin.snoc (Fin.cons (fcos 0 (-1)) (fun j:Fin n =>fcos j.succ (-3))) (pairBeta n 2 i)) := by + rw [pairBeta_of_ne i hi] + have he:=scalarValue_fcos_merge_all (0:Fin (n+1)) (-1) + (Fin.snoc Fin.succ (pairIndex n i)) (Fin.snoc (fun _:Fin n =>(-3:ℤ)) 3) + have hf:(fun j =>fcos ((Fin.snoc Fin.succ (pairIndex n i) : Fin (n+1) → Fin (n+1)) j) + ((Fin.snoc (fun _:Fin n =>(-3:ℤ)) 3 : Fin (n+1) → ℤ) j))= + Fin.snoc (fun j:Fin n =>fcos j.succ (-3)) (deletionBeta (pairIndex n i)) := by + funext j + induction j using Fin.lastCases with + | last => simp only [Fin.snoc_last,deletionBeta_shiftedCosine] + | cast j => simp only [Fin.snoc_castSucc] + rw [hf] at he + simp only [Fin.prod_univ_castSucc,Fin.snoc_castSucc,Fin.snoc_last] at he + unfold pairCosines + rw [Fin.snoc_twoCons] + norm_num only at he ⊢ + rw [he] + simp only [deletionBeta_shiftedCosine] + dsimp only [mergePairScalar] + rw [←Fin.cons_snoc_eq_snoc_cons] + ring + + + + + + + +lemma mergeMap_last {n m:ℕ} (r:ℕ) (hr:r+2≤n+1) : + LastMatrix (mergeMap (m:=m) r (show r+2≤n+2 by omega)) := by + let j:Fin (n+1):=⟨r+1,by omega⟩ + change LastMatrix (localR (PartialColumn.rowPosition r hr).padTop (mergeWeights (constF m phase)) * + functionMatrix (K:=SpectralField m) (Pairing.map (Fin.succAboveOrderEmb j.castSucc))) + exact (LastMatrix.local _ _).mul (LastMatrix.omit j) + +lemma mergeMap_padTop {n m:ℕ} (r:ℕ) (hr:r+2≤n+1) (p:Pairing (n+1)) (q:Pairing n) : + mergeMap (m:=m) r (show r+2≤n+2 by omega) p.padTop q.padTop=mergeMap r hr p q := by + let j:Fin (n+1):=⟨r+1,by omega⟩ + calc + _ = localR (PartialColumn.rowPosition r hr).padTop (mergeWeights (constF m phase)) p.padTop + (q.padTop.map (Fin.succAboveOrderEmb j.castSucc)) := mul_functionMatrix _ _ _ _ + _ = localR (PartialColumn.rowPosition r hr) (mergeWeights (constF m phase)) p + (q.map (Fin.succAboveOrderEmb j)) := by + rw [←Pairing.omit_padTop,localR_padTop] + _ = _ := (mul_functionMatrix _ _ _ _).symm + +lemma deletionMap_last {n m:ℕ} (r:ℕ) (hr:r+2≤n+2) : + LastMatrix (deletionMap (m:=m) r (show r+2≤n+3 by omega)) := by + let j:Fin (n+2):=⟨r+1,by omega⟩ + let k:Fin (n+1):=⟨r,by omega⟩ + change LastMatrix ((localR (PartialColumn.rowPosition r hr).padTop (deletionWeights : Weights (SpectralField m))) * + ((functionMatrix (K:=SpectralField m) (Pairing.map (Fin.succAboveOrderEmb j.castSucc))) * + (functionMatrix (K:=SpectralField m) (Pairing.map (Fin.succAboveOrderEmb k.castSucc))))) + exact (LastMatrix.local _ _).mul ((LastMatrix.omit j).mul (LastMatrix.omit k)) + +lemma deletionMap_padTop {n m:ℕ} (r:ℕ) (hr:r+2≤n+2) (p:Pairing (n+2)) (q:Pairing n) : + deletionMap (m:=m) r (show r+2≤n+3 by omega) p.padTop q.padTop=deletionMap r hr p q := by + let j:Fin (n+2):=⟨r+1,by omega⟩ + let k:Fin (n+1):=⟨r,by omega⟩ + let B : Matrix (Pairing (n+3)) (Pairing (n+2)) (SpectralField m) := + functionMatrix (Pairing.map (Fin.succAboveOrderEmb j.castSucc)) + let D : Matrix (Pairing (n+2)) (Pairing (n+1)) (SpectralField m) := + functionMatrix (Pairing.map (Fin.succAboveOrderEmb k.castSucc)) + let B' : Matrix (Pairing (n+2)) (Pairing (n+1)) (SpectralField m) := + functionMatrix (Pairing.map (Fin.succAboveOrderEmb j)) + let D' : Matrix (Pairing (n+1)) (Pairing n) (SpectralField m) := + functionMatrix (Pairing.map (Fin.succAboveOrderEmb k)) + change (localR (PartialColumn.rowPosition r hr).padTop (deletionWeights : Weights (SpectralField m)) * (B*D)) p.padTop q.padTop = + (localR (PartialColumn.rowPosition r hr) (deletionWeights : Weights (SpectralField m)) * (B'*D')) p q + rw [←Matrix.mul_assoc,←Matrix.mul_assoc] + dsimp only [B,D,B',D'] + rw [mul_functionMatrix,mul_functionMatrix,mul_functionMatrix,mul_functionMatrix] + change localR (PartialColumn.rowPosition r hr).padTop (deletionWeights : Weights (SpectralField m)) p.padTop + ((q.padTop.map (Fin.succAboveOrderEmb k.castSucc)).map (Fin.succAboveOrderEmb j.castSucc))=_ + rw [←Pairing.omit_padTop,←Pairing.omit_padTop,localR_padTop] + + + +lemma LastDegree.mul_poly {K:Type*} [CommRing K] {n m d:ℕ} + (P:Pairing (n+1) → Polynomial K) (hP:LastDegree m P) + (F:Polynomial K) (hF:F.natDegree≤d) : LastDegree (m+d) (fun p =>F*P p) := by + intro p k hk + rw [Polynomial.coeff_mul] + apply Finset.sum_eq_zero + intro ab hab + have hk':ab.1+ab.2=k:=by simpa using hab + by_cases ha:d omega),mul_zero] + +lemma LastDegree.mul_poly_top {K:Type*} [CommRing K] {n m d:ℕ} + (P:Pairing (n+1) → Polynomial K) (hP:LastDegree m P) + (F:Polynomial K) (hF:F.natDegree≤d) (p:Pairing n) : + (F*P p.padTop).coeff (m+d)=F.coeff d*(P p.padTop).coeff m := by + rw [add_comm,Polynomial.coeff_mul_add_eq_of_natDegree_le hF] + exact Polynomial.natDegree_le_iff_coeff_eq_zero.mpr (fun k hk =>hP _ k (by simpa using hk)) + +end +end CriticalStrip.Diagram + +end OAI diff --git a/lean/OAI/Combinatorics/StripMass/PairingDiagrams.lean b/lean/OAI/Combinatorics/StripMass/PairingDiagrams.lean new file mode 100644 index 0000000000000000000000000000000000000000..a7549421717c286475babc8148c3703b24fb8bb7 --- /dev/null +++ b/lean/OAI/Combinatorics/StripMass/PairingDiagrams.lean @@ -0,0 +1,418 @@ +import Mathlib +import OAI.Combinatorics.StripMass.PfaffianMatrices + +namespace OAI + +/-! Critical honeycomb strip paths, polynomial identities and crossing mass. -/ + + + + + +namespace CriticalStrip.Diagram +noncomputable section +open Finset + + +def IsPairing {n : ℕ} (s : Finset (Fin n × Fin n)) : Prop := + (∀ e ∈ s, e.1 < e.2) ∧ + (∀ e ∈ s, ∀ f ∈ s, e = f ∨ + (e.1 ≠ f.1 ∧ e.1 ≠ f.2 ∧ e.2 ≠ f.1 ∧ e.2 ≠ f.2)) ∧ + (∀ e ∈ s, ∀ f ∈ s, ¬(e.1 < f.1 ∧ f.1 < e.2 ∧ e.2 < f.2)) + +abbrev Pairing (n : ℕ) := {s : Finset (Fin n × Fin n) // IsPairing s} + +instance (n : ℕ) : Fintype (Pairing n) := by classical exact Subtype.fintype _ +instance (n : ℕ) : DecidableEq (Pairing n) := by classical infer_instance + +def empty (n : ℕ) : Pairing n := ⟨∅, by simp [IsPairing]⟩ + +def Pairing.Adj {n : ℕ} (p : Pairing n) (i j : Fin n) : Prop := + (i,j) ∈ p.val ∨ (j,i) ∈ p.val + +def Pairing.Occupied {n : ℕ} (p : Pairing n) (i : Fin n) : Prop := + ∃ j, p.Adj i j + +@[simp] theorem empty_not_adj {n : ℕ} (i j : Fin n) : ¬ (empty n).Adj i j := by + simp [Pairing.Adj, empty] +@[simp] theorem empty_not_occupied {n : ℕ} (i : Fin n) : ¬ (empty n).Occupied i := by + simp [Pairing.Occupied] + +theorem Pairing.adj_irrefl {n : ℕ} (p : Pairing n) (i : Fin n) : ¬p.Adj i i := by + rintro (h | h) <;> exact (lt_irrefl i) (p.property.1 _ h) + +theorem Pairing.eq_empty_iff {n : ℕ} (p : Pairing n) : p = empty n ↔ ∀ i, ¬p.Occupied i := by + constructor + · rintro rfl; simp + · intro h + apply Subtype.ext + apply Finset.eq_empty_iff_forall_notMem.mpr + intro e he + exact h e.1 ⟨e.2, Or.inl he⟩ + +inductive Tile where + | vacant | vertical₀ | vertical₁ | diagonal₀ | diagonal₁ + | cap | cup | verticalPair | capCup + deriving DecidableEq + +instance : Fintype Tile := + ⟨{.vacant, .vertical₀, .vertical₁, .diagonal₀, .diagonal₁, .cap, .cup, + .verticalPair, .capCup}, by intro t; cases t <;> simp⟩ + +def Tile.edges : Tile → Finset (Fin 4 × Fin 4) + | .vacant => ∅ + | .vertical₀ => {(0,2)} + | .vertical₁ => {(1,3)} + | .diagonal₀ => {(0,3)} + | .diagonal₁ => {(1,2)} + | .cap => {(0,1)} + | .cup => {(2,3)} + | .verticalPair => {(0,2),(1,3)} + | .capCup => {(0,1),(2,3)} + +def Tile.Adj (t : Tile) (i j : Fin 4) : Prop := (i,j) ∈ t.edges ∨ (j,i) ∈ t.edges + +def Tile.Occupied (t : Tile) (i : Fin 4) : Prop := ∃ j, t.Adj i j + +@[simp] theorem Tile.vacant_not_adj (i j : Fin 4) : ¬ Tile.vacant.Adj i j := by + simp [Tile.Adj, Tile.edges] +@[simp] theorem Tile.vacant_not_occupied (i : Fin 4) : ¬ Tile.vacant.Occupied i := by + simp [Tile.Occupied] + +theorem Tile.eq_vacant_iff (t : Tile) : t = .vacant ↔ ∀ i, ¬t.Occupied i := by + cases t <;> simp [Tile.Occupied, Tile.Adj, Tile.edges, Fin.forall_fin_succ] + + +structure Weights (𝕜 : Type*) where + A : 𝕜 + B : 𝕜 + U : 𝕜 + E : 𝕜 + F : 𝕜 + +def Weights.tile {𝕜 : Type*} [One 𝕜] (w : Weights 𝕜) : Tile → 𝕜 + | .vacant => 1 + | .vertical₀ | .vertical₁ => w.A + | .diagonal₀ | .diagonal₁ => w.B + | .cap | .cup => w.U + | .verticalPair => w.E + | .capCup => w.F + +abbrev Vertex (n : ℕ) := Fin n × Fin 4 +abbrev Configuration (n : ℕ) := Fin n → Tile + + + +def Wiring {n : ℕ} (p : Pairing n) (t : Configuration n) + (v w : Vertex n) : Prop := + (v.1 = w.1 ∧ (t v.1).Adj v.2 w.2) ∨ + (v.2 = 1 ∧ w.2 = 1 ∧ p.Adj v.1 w.1) ∨ + (v.2 = 3 ∧ w.2 = 0 ∧ v.1.val + 1 = w.1.val ∧ (t v.1).Occupied 3) ∨ + (w.2 = 3 ∧ v.2 = 0 ∧ w.1.val + 1 = v.1.val ∧ (t w.1).Occupied 3) + +def Reach {n : ℕ} (p : Pairing n) (t : Configuration n) := + Relation.ReflTransGen (Wiring p t) + + + +structure Realizes {n : ℕ} (p q : Pairing n) (t : Configuration n) : Prop where + west : ∀ i, (t i).Occupied 1 ↔ p.Occupied i + east : ∀ i, (t i).Occupied 2 ↔ q.Occupied i + south : ∀ i, i.val = 0 → ¬ (t i).Occupied 0 + north : ∀ i, i.val + 1 = n → ¬ (t i).Occupied 3 + glued : ∀ i j, i.val + 1 = j.val → ((t i).Occupied 3 ↔ (t j).Occupied 0) + no_loop : ∀ v w, Wiring p t v w → ∃ j, q.Occupied j ∧ Reach p t v (j,2) + output : ∀ i j, i ≠ j → (q.Adj i j ↔ Reach p t (i,2) (j,2)) + + + +def column {𝕜 : Type*} [CommRing 𝕜] {n : ℕ} (w : Fin n → Weights 𝕜) : + Matrix (Pairing n) (Pairing n) 𝕜 := by + classical + exact fun q p => ∑ t : Configuration n, + if Realizes p q t then ∏ i, (w i).tile (t i) else 0 + + +def identityWeights {𝕜 : Type*} [Zero 𝕜] [One 𝕜] : Weights 𝕜 := ⟨1,0,0,1,0⟩ +def deletionWeights {𝕜 : Type*} [Zero 𝕜] [One 𝕜] : Weights 𝕜 := ⟨0,0,1,0,1⟩ + +def lambda : ℝ := Real.pi / 8 +def L (u : ℝ) : ℝ := Real.sin (2 * lambda + u) * Real.sin (3 * lambda + u) +def physicalWeights (u : ℝ) : Weights ℝ := + let d := Real.cos (2 * lambda) + ⟨d * Real.sin (3 * lambda - u) / L u, + Real.sin u * Real.sin (3 * lambda - u) / L u, + d * Real.sin u / L u, + Real.sin (3 * lambda - u) * Real.sin (2 * lambda - u) / L u, + Real.sin (u - lambda) * Real.sin u / L u⟩ + +def transfer {n : ℕ} (u : Fin n → ℝ) : Matrix (Pairing n) (Pairing n) ℝ := + column (fun i => physicalWeights (3 * lambda - u i)) + + +abbrev NonemptyPairing (n : ℕ) := {p : Pairing n // p ≠ empty n} + +def restrictedColumn {𝕜 : Type*} [CommRing 𝕜] {n : ℕ} (w : Fin n → Weights 𝕜) : + Matrix (NonemptyPairing n) (NonemptyPairing n) 𝕜 := + (column w).submatrix Subtype.val Subtype.val + + +def VacuumRegular {𝕜 : Type*} [Field 𝕜] {n : ℕ} (w : Fin n → Weights 𝕜) : Prop := + (1 - restrictedColumn w).det ≠ 0 + + +theorem realizes_empty_iff {n : ℕ} (p : Pairing n) (t : Configuration n) : + Realizes p (empty n) t ↔ p = empty n ∧ t = fun _ => Tile.vacant := by + constructor + · intro h + have ht : ∀ i, t i = .vacant := by + intro i + apply (Tile.eq_vacant_iff _).2 + intro a ⟨b, hab⟩ + obtain ⟨j, hj, _⟩ := h.no_loop (i,a) (i,b) (Or.inl ⟨rfl, hab⟩) + exact empty_not_occupied j hj + refine ⟨(Pairing.eq_empty_iff _).2 ?_, funext ht⟩ + intro i hi + have := (h.west i).2 hi + simp [ht i] at this + · rintro ⟨rfl, rfl⟩ + have hw : ∀ v w : Vertex n, ¬ Wiring (empty n) (fun _ => Tile.vacant) v w := by + intro v w + simp [Wiring] + refine ⟨?_, ?_, ?_, ?_, ?_, ?_, ?_⟩ + · intro i; simp + · intro i; simp + · intro i _; simp + · intro i _; simp + · intro i j _; simp + · intro v w h; exact (hw v w h).elim + · intro i j hij + have hr : Reach (empty n) (fun _ : Fin n => Tile.vacant) (i,2) (j,2) ↔ + (j, (2 : Fin 4)) = (i,2) := Relation.reflTransGen_iff_eq (hw (i,2)) + simp [hr, Ne.symm hij] + +theorem column_empty_row {𝕜 : Type*} [CommRing 𝕜] {n : ℕ} + (w : Fin n → Weights 𝕜) (p : Pairing n) : + column w (empty n) p = if p = empty n then 1 else 0 := by + classical + by_cases hp : p = empty n + · subst p + simp [column, realizes_empty_iff, Weights.tile] + · simp [column, realizes_empty_iff, hp] + +namespace Pairing + +def map {n m : ℕ} (f : Fin n ↪o Fin m) (p : Pairing n) : Pairing m := by + classical + refine ⟨p.val.map (f.toEmbedding.prodMap f.toEmbedding), ?_⟩ + refine ⟨?_, ?_, ?_⟩ + · intro e he + rcases Finset.mem_map.mp he with ⟨a, ha, heq⟩ + subst e + exact f.strictMono (p.property.1 a ha) + · intro e he g hg + rcases Finset.mem_map.mp he with ⟨a, ha, heq⟩ + subst e + rcases Finset.mem_map.mp hg with ⟨b, hb, hgq⟩ + subst g + rcases p.property.2.1 a ha b hb with h | ⟨h₁,h₂,h₃,h₄⟩ + · exact Or.inl (congrArg _ h) + · exact Or.inr ⟨by simpa, by simpa, by simpa, by simpa⟩ + · intro e he g hg + rcases Finset.mem_map.mp he with ⟨a, ha, heq⟩ + subst e + rcases Finset.mem_map.mp hg with ⟨b, hb, hgq⟩ + subst g + simpa using p.property.2.2 a ha b hb + +def restrict {n m : ℕ} (f : Fin n ↪o Fin m) (p : Pairing m) : Pairing n := by + classical + refine ⟨p.val.preimage (fun e => (f e.1, f e.2)) + (f.toEmbedding.prodMap f.toEmbedding).injective.injOn, ?_⟩ + refine ⟨?_, ?_, ?_⟩ + · intro e he + have h := p.property.1 _ (Finset.mem_preimage.mp he) + simpa using h + · intro e he g hg + have h := p.property.2.1 _ (Finset.mem_preimage.mp he) _ (Finset.mem_preimage.mp hg) + rcases h with h | ⟨h₁,h₂,h₃,h₄⟩ + · exact Or.inl <| Prod.ext (f.injective (congrArg Prod.fst h)) + (f.injective (congrArg Prod.snd h)) + · exact Or.inr ⟨fun h => h₁ (congrArg f h), fun h => h₂ (congrArg f h), + fun h => h₃ (congrArg f h), fun h => h₄ (congrArg f h)⟩ + · intro e he g hg + have h := p.property.2.2 _ (Finset.mem_preimage.mp he) _ (Finset.mem_preimage.mp hg) + simpa using h + +@[simp] theorem restrict_adj {n m : ℕ} (f : Fin n ↪o Fin m) (p : Pairing m) (i j : Fin n) : + (p.restrict f).Adj i j ↔ p.Adj (f i) (f j) := by + classical + exact or_congr + (Finset.mem_preimage (hf := (f.toEmbedding.prodMap f.toEmbedding).injective.injOn)) + (Finset.mem_preimage (hf := (f.toEmbedding.prodMap f.toEmbedding).injective.injOn)) + +@[simp] theorem map_adj_image {n m : ℕ} (f : Fin n ↪o Fin m) (p : Pairing n) (i j : Fin n) : + (p.map f).Adj (f i) (f j) ↔ p.Adj i j := by + classical + simp [map, Adj, Finset.mem_map] + +@[simp] theorem restrict_map {n m : ℕ} (f : Fin n ↪o Fin m) (p : Pairing n) : + (p.map f).restrict f = p := by + classical + apply Subtype.ext + ext e + simp [restrict, map, Finset.mem_map] + + +def padBottom {n : ℕ} (p : Pairing n) : Pairing (n+1) := p.map (Fin.succOrderEmb n) + +@[simp] theorem padBottom_adj_succ {n : ℕ} (p : Pairing n) (i j : Fin n) : + p.padBottom.Adj i.succ j.succ ↔ p.Adj i j := map_adj_image _ _ _ _ + +@[simp] theorem padBottom_not_adj_zero {n : ℕ} (p : Pairing n) (j : Fin (n+1)) : + ¬ p.padBottom.Adj 0 j := by + classical + simp [padBottom, map, Adj, Finset.mem_map] + +@[simp] theorem padBottom_not_adj_zero' {n : ℕ} (p : Pairing n) (j : Fin (n+1)) : + ¬ p.padBottom.Adj j 0 := by + classical + simp [padBottom, map, Adj, Finset.mem_map] + +@[simp] theorem padBottom_not_occupied_zero {n : ℕ} (p : Pairing n) : + ¬ p.padBottom.Occupied 0 := by + simp [Occupied] + +@[simp] theorem padBottom_occupied_succ {n : ℕ} (p : Pairing n) (i : Fin n) : + p.padBottom.Occupied i.succ ↔ p.Occupied i := by + simp only [Occupied, Fin.exists_fin_succ, padBottom_adj_succ, padBottom_not_adj_zero', + false_or] + +@[simp] theorem padBottom_empty {n : ℕ} : (empty n).padBottom = empty (n+1) := by + classical + apply Subtype.ext + simp [padBottom, map, empty] + +@[simp] theorem padBottom_eq_empty {n : ℕ} (p : Pairing n) : + p.padBottom = empty (n+1) ↔ p = empty n := by + simp only [eq_empty_iff, Fin.forall_fin_succ, padBottom_not_occupied_zero, + padBottom_occupied_succ, not_false_eq_true, true_and] + + +theorem padBottom_restrict {n : ℕ} (p : Pairing (n+1)) (hp : ¬p.Occupied 0) : + (p.restrict (Fin.succOrderEmb n)).padBottom = p := by + classical + apply Subtype.ext + ext e + rcases e with ⟨i,j⟩ + induction i using Fin.cases with + | zero => + have hm : (0,j) ∉ p.val := fun h => hp ⟨j, Or.inl h⟩ + simp [padBottom, map, Finset.mem_map, hm] + | succ i => + induction j using Fin.cases with + | zero => + have hm : (i.succ,0) ∉ p.val := fun h => hp ⟨i.succ, Or.inr h⟩ + simp [padBottom, map, Finset.mem_map, hm] + | succ j => simp [padBottom, map, restrict, Finset.mem_map] + +def bottomVacantEquiv (n : ℕ) : Pairing n ≃ {p : Pairing (n+1) // ¬p.Occupied 0} where + toFun p := ⟨p.padBottom, p.padBottom_not_occupied_zero⟩ + invFun p := p.val.restrict (Fin.succOrderEmb n) + left_inv p := restrict_map _ p + right_inv p := Subtype.ext <| padBottom_restrict p.val p.property + +end Pairing + +namespace Configuration + +def padBottom {n : ℕ} (t : Configuration n) : Configuration (n+1) := Fin.cons .vacant t + +@[simp] theorem padBottom_zero {n : ℕ} (t : Configuration n) : t.padBottom 0 = .vacant := rfl +@[simp] theorem padBottom_succ {n : ℕ} (t : Configuration n) (i : Fin n) : + t.padBottom i.succ = t i := rfl + +end Configuration + +def vertexSucc {n : ℕ} (v : Vertex n) : Vertex (n+1) := (v.1.succ,v.2) + +theorem vertexSucc_injective {n : ℕ} : Function.Injective (@vertexSucc n) := by + intro v w h + apply Prod.ext + · exact Fin.succ_injective n (congrArg (fun v : Vertex (n+1) => v.1) h) + · exact congrArg (fun v : Vertex (n+1) => v.2) h + +theorem wiring_symm {n : ℕ} {p : Pairing n} {t : Configuration n} {v w : Vertex n} + (h : Wiring p t v w) : Wiring p t w v := by + rcases h with ⟨h,h'⟩ | ⟨h₁,h₂,h₃⟩ | h | h + · left + refine ⟨h.symm, ?_⟩ + simpa only [← h, Tile.Adj, or_comm] using h' + · right; left + exact ⟨h₂,h₁,h₃.elim Or.inr Or.inl⟩ + · exact Or.inr (Or.inr (Or.inr h)) + · exact Or.inr (Or.inr (Or.inl h)) + +theorem reach_symm {n : ℕ} {p : Pairing n} {t : Configuration n} {v w : Vertex n} + (h : Reach p t v w) : Reach p t w v := by + induction h with + | refl => exact Relation.ReflTransGen.refl + | tail _ h ih => exact (Relation.ReflTransGen.single (wiring_symm h)).trans ih + +@[simp] theorem wiring_padBottom_zero {n : ℕ} (p : Pairing n) (t : Configuration n) + (a : Fin 4) (w : Vertex (n+1)) : + ¬Wiring p.padBottom t.padBottom (0,a) w := by + simp [Wiring] + +@[simp] theorem wiring_padBottom_zero_right {n : ℕ} (p : Pairing n) (t : Configuration n) + (v : Vertex (n+1)) (b : Fin 4) : + ¬Wiring p.padBottom t.padBottom v (0,b) := + fun h => wiring_padBottom_zero p t b v (wiring_symm h) + +@[simp] theorem wiring_padBottom_iff {n : ℕ} (p : Pairing n) (t : Configuration n) + (v w : Vertex n) : + Wiring p.padBottom t.padBottom (vertexSucc v) (vertexSucc w) ↔ Wiring p t v w := by + simp [Wiring, vertexSucc, Nat.add_assoc] + +theorem reach_padBottom_image {n : ℕ} (p : Pairing n) (t : Configuration n) + {v : Vertex n} {w : Vertex (n+1)} (h : Reach p.padBottom t.padBottom (vertexSucc v) w) : + ∃ z, w = vertexSucc z ∧ Reach p t v z := by + induction h with + | refl => exact ⟨v,rfl,Relation.ReflTransGen.refl⟩ + | @tail w z _ hwz ih => + obtain ⟨w',rfl,hw'⟩ := ih + rcases z with ⟨j,b⟩ + induction j using Fin.cases with + | zero => exact (wiring_padBottom_zero_right p t _ b hwz).elim + | succ j => + exact ⟨(j,b),rfl,hw'.tail ((wiring_padBottom_iff p t _ _).1 hwz)⟩ + +@[simp] theorem reach_padBottom_iff {n : ℕ} (p : Pairing n) (t : Configuration n) + (v w : Vertex n) : + Reach p.padBottom t.padBottom (vertexSucc v) (vertexSucc w) ↔ Reach p t v w := by + constructor + · intro h + obtain ⟨z,hz,hz'⟩ := reach_padBottom_image p t h + have := vertexSucc_injective hz + simpa only [this] using hz' + · exact Relation.ReflTransGen.lift vertexSucc (fun a b h => (wiring_padBottom_iff p t a b).2 h) _ _ + +@[simp] theorem reach_padBottom_zero_iff {n : ℕ} (p : Pairing n) (t : Configuration n) + (a : Fin 4) (w : Vertex (n+1)) : + Reach p.padBottom t.padBottom (0,a) w ↔ w = (0,a) := + Relation.reflTransGen_iff_eq (wiring_padBottom_zero p t a) + +@[simp] theorem reach_padBottom_zero_right_iff {n : ℕ} (p : Pairing n) (t : Configuration n) + (v : Vertex (n+1)) (b : Fin 4) : + Reach p.padBottom t.padBottom v (0,b) ↔ v = (0,b) := by + constructor + · intro h + exact (reach_padBottom_zero_iff p t b v).1 (reach_symm h) + · rintro rfl; exact Relation.ReflTransGen.refl + + + +end +end CriticalStrip.Diagram + +end OAI diff --git a/lean/OAI/Combinatorics/StripMass/PairingSurgery.lean b/lean/OAI/Combinatorics/StripMass/PairingSurgery.lean new file mode 100644 index 0000000000000000000000000000000000000000..7d330891b2d3be24df36c33143c1d157df47c5e7 --- /dev/null +++ b/lean/OAI/Combinatorics/StripMass/PairingSurgery.lean @@ -0,0 +1,359 @@ +import Mathlib +import OAI.Combinatorics.StripMass.PairingDiagrams + +namespace OAI + +/-! Critical honeycomb strip paths, polynomial identities and crossing mass. -/ + + + + + +namespace CriticalStrip.Diagram +noncomputable section +open Finset +open scoped Classical +theorem IsPairing.mono {n : ℕ} {s t : Finset (Fin n × Fin n)} + (h : IsPairing s) (ht : t ⊆ s) : IsPairing t := + ⟨fun e he => h.1 e (ht he), fun e he f hf => h.2.1 e (ht he) f (ht hf), + fun e he f hf => h.2.2 e (ht he) f (ht hf)⟩ + +namespace Pairing + +@[symm] theorem adj_symm {n : ℕ} {p : Pairing n} {i j : Fin n} + (h : p.Adj i j) : p.Adj j i := h.symm + +theorem adj_unique {n : ℕ} {p : Pairing n} {i j k : Fin n} + (h : p.Adj i j) (g : p.Adj i k) : j = k := by + rcases h with h | h <;> rcases g with g | g + · rcases p.property.2.1 _ h _ g with he | ⟨hne, _, _, _⟩ + · exact congrArg Prod.snd he + · exact (hne rfl).elim + · rcases p.property.2.1 _ h _ g with he | ⟨_, hne, _, _⟩ + · exact (congrArg Prod.snd he).trans (congrArg Prod.fst he) + · exact (hne rfl).elim + · rcases p.property.2.1 _ h _ g with he | ⟨_, _, hne, _⟩ + · exact (congrArg Prod.fst he).trans (congrArg Prod.snd he) + · exact (hne rfl).elim + · rcases p.property.2.1 _ h _ g with he | ⟨_, _, _, hne⟩ + · exact congrArg Prod.fst he + · exact (hne rfl).elim + + +def Cross {α : Type*} [LinearOrder α] (a b c d : α) : Prop := + (a rcases g with g | g + all_goals + have hp := p.property.1 _ h + have hq := p.property.1 _ g + have hx := p.property.2.2 _ h _ g + have hy := p.property.2.2 _ g _ h + dsimp only at hp hq hx hy + simp only [Cross] + omega + + +def omitTwo {n : ℕ} (p : Pairing n) (a b : Fin n) : Pairing n := + ⟨p.val.filter (fun e => e.1 ≠ a ∧ e.1 ≠ b ∧ e.2 ≠ a ∧ e.2 ≠ b), + p.property.mono (filter_subset _ _)⟩ + +@[simp] theorem omitTwo_adj {n : ℕ} (p : Pairing n) (a b i j : Fin n) : + (p.omitTwo a b).Adj i j ↔ + p.Adj i j ∧ i ≠ a ∧ i ≠ b ∧ j ≠ a ∧ j ≠ b := by + simp only [Adj, omitTwo, mem_filter] + tauto + +theorem not_cross_iff_between {n : ℕ} {a b c d : Fin n} + (hcd : c < d) (hac : a ≠ c) (had : a ≠ d) (hbc : b ≠ c) (hbd : b ≠ d) : + ¬ Cross a b c d ↔ ((c omega + +theorem occupied_of_mem {n : ℕ} {p : Pairing n} {e : Fin n × Fin n} + (h : e ∈ p.val) : p.Occupied e.1 ∧ p.Occupied e.2 := + ⟨⟨e.2, Or.inl h⟩, ⟨e.1, Or.inr h⟩⟩ + +theorem cap_new_edge_disjoint {n : ℕ} {p : Pairing n} {a b x y : Fin n} + (hx : p.Adj a x) (hy : p.Adj b y) {e : Fin n × Fin n} + (he : e ∈ (p.omitTwo a b).val) : + x ≠ e.1 ∧ x ≠ e.2 ∧ y ≠ e.1 ∧ y ≠ e.2 := by + have hij : (p.omitTwo a b).Adj e.1 e.2 := Or.inl he + obtain ⟨he',hca,hcb,hda,hdb⟩ := (omitTwo_adj p a b _ _).mp hij + refine ⟨?_,?_,?_,?_⟩ + · rintro rfl + exact hda (adj_unique he' (adj_symm hx)) + · rintro rfl + exact hca (adj_unique (adj_symm he') (adj_symm hx)) + · rintro rfl + exact hdb (adj_unique he' (adj_symm hy)) + · rintro rfl + exact hcb (adj_unique (adj_symm he') (adj_symm hy)) + + + +def capSplice {n : ℕ} (p : Pairing n) (a b x y : Fin n) + (hab : a.val + 1 = b.val) (hx : p.Adj a x) (hy : p.Adj b y) + (hxy : x ≠ y) : Pairing n := by + refine ⟨insert (orderedEdge x y) (p.omitTwo a b).val, ?_⟩ + refine ⟨?_,?_,?_⟩ + · intro e he + rcases mem_insert.mp he with rfl | he + · exact orderedEdge_lt hxy + · exact (p.omitTwo a b).property.1 _ he + · intro e he f hf + rcases mem_insert.mp he with rfl | he <;> + rcases mem_insert.mp hf with rfl | hf + · exact Or.inl rfl + · right + have hh := cap_new_edge_disjoint hx hy hf + simp only [orderedEdge, min_def, max_def] + split_ifs <;> tauto + · right + have hh := cap_new_edge_disjoint hx hy he + simp only [orderedEdge, min_def, max_def] + split_ifs <;> tauto + · exact (p.omitTwo a b).property.2.1 _ he _ hf + · intro e he f hf + rcases mem_insert.mp he with rfl | he <;> + rcases mem_insert.mp hf with rfl | hf + · simp + · have hd := cap_new_edge_disjoint hx hy hf + have hh := (omitTwo_adj p a b _ _).mp (Or.inl hf) + have hc := cap_no_cross hab ((p.omitTwo a b).property.1 _ hf) hh.2.1 hh.2.2.1 hh.2.2.2.1 hh.2.2.2.2 + hd.1 hd.2.1 hd.2.2.1 hd.2.2.2 (not_cross hx hh.1) (not_cross hy hh.1) + simp only [Cross] at hc + simp only [orderedEdge, min_def, max_def] + split_ifs <;> omega + · have hd := cap_new_edge_disjoint hx hy he + have hh := (omitTwo_adj p a b _ _).mp (Or.inl he) + have hc := cap_no_cross hab ((p.omitTwo a b).property.1 _ he) hh.2.1 hh.2.2.1 hh.2.2.2.1 hh.2.2.2.2 + hd.1 hd.2.1 hd.2.2.1 hd.2.2.2 (not_cross hx hh.1) (not_cross hy hh.1) + simp only [Cross] at hc + simp only [orderedEdge, min_def, max_def] + split_ifs <;> omega + · exact (p.omitTwo a b).property.2.2 _ he _ hf + + + + + + + + + +def mapOccupied {n m : ℕ} (p : Pairing n) (f : Fin n ↪ Fin m) + (hf : ∀ i j, p.Occupied i → p.Occupied j → (f i < f j ↔ i < j)) : Pairing m := by + refine ⟨p.val.map (f.prodMap f), ?_, ?_, ?_⟩ + · intro e he + obtain ⟨a,ha,heq⟩ := mem_map.mp he + subst e + apply (hf _ _ (occupied_of_mem ha).1 (occupied_of_mem ha).2).mpr + exact p.property.1 _ ha + · intro e he g hg + obtain ⟨a,ha,heq⟩ := mem_map.mp he + subst e + obtain ⟨b,hb,hgq⟩ := mem_map.mp hg + subst g + rcases p.property.2.1 _ ha _ hb with rfl | hh + · exact Or.inl rfl + · right + simpa using hh + · intro e he g hg + obtain ⟨a,ha,heq⟩ := mem_map.mp he + subst e + obtain ⟨b,hb,hgq⟩ := mem_map.mp hg + subst g + change ¬ (f a.1 < f b.1 ∧ f b.1 < f a.2 ∧ f a.2 < f b.2) + rw [hf _ _ (occupied_of_mem ha).1 (occupied_of_mem hb).1, + hf _ _ (occupied_of_mem hb).1 (occupied_of_mem ha).2, + hf _ _ (occupied_of_mem ha).2 (occupied_of_mem hb).2] + exact p.property.2.2 _ ha _ hb + +@[simp] theorem mapOccupied_adj {n m : ℕ} (p : Pairing n) (f : Fin n ↪ Fin m) + (hf : ∀ i j, p.Occupied i → p.Occupied j → (f i < f j ↔ i < j)) + (i j : Fin n) : (mapOccupied p f hf).Adj (f i) (f j) ↔ p.Adj i j := by + simp [Adj, mapOccupied] + +theorem swap_adjacent_order {n : ℕ} {a b i j : Fin n} + (hab : a.val+1=b.val) (hi : i ≠ b) (hj : j ≠ b) : + Equiv.swap a b i < Equiv.swap a b j ↔ i omega + + +def moveIntoVacancy {n : ℕ} (p : Pairing n) (a b : Fin n) + (hab : a.val+1=b.val) (hb : ¬ p.Occupied b) : Pairing n := + p.mapOccupied (Equiv.swap a b).toEmbedding (fun _ _ hi hj => + swap_adjacent_order hab (fun h => hb (h ▸ hi)) (fun h => hb (h ▸ hj))) + + + +theorem swap_adjacent_order_lower {n : ℕ} {a b i j : Fin n} + (hab : a.val+1=b.val) (hi : i ≠ a) (hj : j ≠ a) : + Equiv.swap a b i < Equiv.swap a b j ↔ i omega + +def moveIntoLowerVacancy {n : ℕ} (p : Pairing n) (a b : Fin n) + (hab : a.val+1=b.val) (ha : ¬ p.Occupied a) : Pairing n := + p.mapOccupied (Equiv.swap a b).toEmbedding (fun _ _ hi hj => + swap_adjacent_order_lower hab (fun h => ha (h ▸ hi)) (fun h => ha (h ▸ hj))) + + +def insertCup {n : ℕ} (p : Pairing n) (a b : Fin n) (hab : a.val+1=b.val) + (ha : ¬ p.Occupied a) (hb : ¬ p.Occupied b) : Pairing n := by + have hlt : a ha (h ▸ hh.1), fun h => ha (h ▸ hh.2), + fun h => hb (h ▸ hh.1), fun h => hb (h ▸ hh.2)⟩ + refine ⟨insert (a,b) p.val, ?_, ?_, ?_⟩ + · intro e he + rcases mem_insert.mp he with rfl | he + · exact hlt + · exact p.property.1 _ he + · intro e he f hf + rcases mem_insert.mp he with rfl | he <;> rcases mem_insert.mp hf with rfl | hf + · exact Or.inl rfl + · exact Or.inr (havoid _ hf) + · right + have hh := havoid _ he + dsimp only + tauto + · exact p.property.2.1 _ he _ hf + · intro e he f hf + rcases mem_insert.mp he with rfl | he <;> rcases mem_insert.mp hf with rfl | hf + all_goals try dsimp only + · omega + · omega + · omega + · exact p.property.2.2 _ he _ hf + + + + + + + +def partner {n : ℕ} (p : Pairing n) (i : Fin n) (hi : p.Occupied i) : Fin n := + Classical.choose hi + +theorem partner_adj {n : ℕ} (p : Pairing n) (i : Fin n) (hi : p.Occupied i) : + p.Adj i (p.partner i hi) := Classical.choose_spec hi + +theorem adjacent_partners {n : ℕ} {p : Pairing n} {a b x y : Fin n} + (hab : a.val+1=b.val) (hx : p.Adj a x) (hy : p.Adj b y) (hn : ¬ p.Adj a b) : + x ≠ a ∧ x ≠ b ∧ y ≠ a ∧ y ≠ b ∧ x ≠ y := by + refine ⟨?_,?_,?_,?_,?_⟩ + · rintro rfl; exact p.adj_irrefl _ hx + · rintro rfl; exact hn hx + · rintro rfl; exact hn (adj_symm hy) + · rintro rfl; exact p.adj_irrefl _ hy + · rintro rfl + have := adj_unique (adj_symm hx) (adj_symm hy) + omega + +@[simp] theorem capSplice_adj {n : ℕ} (p : Pairing n) (a b x y : Fin n) + (hab : a.val+1=b.val) (hx : p.Adj a x) (hy : p.Adj b y) (hxy : x ≠ y) + (i j : Fin n) : + (capSplice p a b x y hab hx hy hxy).Adj i j ↔ + (i=x ∧ j=y) ∨ (i=y ∧ j=x) ∨ (p.omitTwo a b).Adj i j := by + simp only [Adj, capSplice, mem_insert, orderedEdge, min_def, max_def, + Prod.mk.injEq] + split_ifs <;> tauto + +@[simp] theorem capSplice_occupied {n : ℕ} (p : Pairing n) (a b x y : Fin n) + (hab : a.val+1=b.val) (hx : p.Adj a x) (hy : p.Adj b y) (hxy : x ≠ y) + (i : Fin n) : + (capSplice p a b x y hab hx hy hxy).Occupied i ↔ + i=x ∨ i=y ∨ (p.omitTwo a b).Occupied i := by + simp only [Occupied, capSplice_adj] + constructor + · rintro ⟨j,(⟨h,_⟩|⟨h,_⟩|h)⟩ + · exact Or.inl h + · exact Or.inr (Or.inl h) + · exact Or.inr (Or.inr ⟨j,h⟩) + · rintro (rfl|rfl|⟨j,h⟩) + · exact ⟨y,Or.inl ⟨rfl,rfl⟩⟩ + · exact ⟨x,Or.inr (Or.inl ⟨rfl,rfl⟩)⟩ + · exact ⟨j,Or.inr (Or.inr h)⟩ + +@[simp] theorem omitTwo_not_occupied_left {n : ℕ} (p : Pairing n) (a b : Fin n) : + ¬ (p.omitTwo a b).Occupied a := by simp [Occupied] + +@[simp] theorem omitTwo_not_occupied_right {n : ℕ} (p : Pairing n) (a b : Fin n) : + ¬ (p.omitTwo a b).Occupied b := by simp [Occupied] + + + +def capRemove {n : ℕ} (p : Pairing n) (a b : Fin n) (hab : a.val+1=b.val) + (ha : p.Occupied a) (hb : p.Occupied b) (hn : ¬ p.Adj a b) : Pairing n := + p.capSplice a b (p.partner a ha) (p.partner b hb) hab + (p.partner_adj a ha) (p.partner_adj b hb) + (adjacent_partners hab (p.partner_adj a ha) (p.partner_adj b hb) hn).2.2.2.2 + +theorem capRemove_vacant {n : ℕ} (p : Pairing n) (a b : Fin n) (hab : a.val+1=b.val) + (ha : p.Occupied a) (hb : p.Occupied b) (hn : ¬ p.Adj a b) : + ¬ (capRemove p a b hab ha hb hn).Occupied a ∧ + ¬ (capRemove p a b hab ha hb hn).Occupied b := by + have h := adjacent_partners hab (p.partner_adj a ha) (p.partner_adj b hb) hn + simp only [capRemove,capSplice_occupied,omitTwo_not_occupied_left, + omitTwo_not_occupied_right,or_false,not_or] + exact ⟨⟨h.1.symm,h.2.2.1.symm⟩,⟨h.2.1.symm,h.2.2.2.1.symm⟩⟩ + + + +def tileStep {n : ℕ} (p : Pairing n) (a b : Fin n) (hab : a.val+1=b.val) : + Tile → Option (Pairing n) + | .vacant => if ¬ p.Occupied a ∧ ¬ p.Occupied b then some p else none + | .vertical₀ => if p.Occupied a ∧ ¬ p.Occupied b then some p else none + | .vertical₁ => if ¬ p.Occupied a ∧ p.Occupied b then some p else none + | .diagonal₀ => if h : p.Occupied a ∧ ¬ p.Occupied b then + some (p.moveIntoVacancy a b hab h.2) else none + | .diagonal₁ => if h : ¬ p.Occupied a ∧ p.Occupied b then + some (p.moveIntoLowerVacancy a b hab h.1) else none + | .cap => if ha : p.Occupied a then if hb : p.Occupied b then + if hn : p.Adj a b then none else some (p.capRemove a b hab ha hb hn) + else none else none + | .cup => if h : ¬ p.Occupied a ∧ ¬ p.Occupied b then + some (p.insertCup a b hab h.1 h.2) else none + | .verticalPair => if p.Occupied a ∧ p.Occupied b then some p else none + | .capCup => if ha : p.Occupied a then if hb : p.Occupied b then + if hn : p.Adj a b then none else + some ((p.capRemove a b hab ha hb hn).insertCup a b hab + (capRemove_vacant p a b hab ha hb hn).1 + (capRemove_vacant p a b hab ha hb hn).2) + else none else none + +end Pairing +end +end CriticalStrip.Diagram + +end OAI diff --git a/lean/OAI/Combinatorics/StripMass/PatchReplacement.lean b/lean/OAI/Combinatorics/StripMass/PatchReplacement.lean new file mode 100644 index 0000000000000000000000000000000000000000..b4666dcefd336c0c9865aba996940bdb82bda43e --- /dev/null +++ b/lean/OAI/Combinatorics/StripMass/PatchReplacement.lean @@ -0,0 +1,304 @@ +import Mathlib +import OAI.Combinatorics.StripMass.LaurentBox + +namespace OAI + +/-! Critical honeycomb strip paths, polynomial identities and crossing mass. -/ + + + + + +namespace CriticalStrip.Diagram.Patch +noncomputable section + +variable {A B I : Type*} + + +def glued (r : A → A → Prop) (s : B → B → Prop) (a : I → A) (b : I → B) + (active : I → Prop) : Sum A B → Sum A B → Prop + | .inl x, .inl y => r x y + | .inr x, .inr y => s x y + | .inl x, .inr y => ∃ i, active i ∧ x = a i ∧ y = b i + | .inr x, .inl y => ∃ i, active i ∧ x = b i ∧ y = a i + + + +def compressed (r : A → A → Prop) (s : B → B → Prop) (a : I → A) (b : I → B) + (active : I → Prop) (x y : B) : Prop := + s x y ∨ ∃ i j, active i ∧ active j ∧ + Relation.ReflTransGen r (a i) (a j) ∧ x = b i ∧ y = b j + +variable (r : A → A → Prop) (s : B → B → Prop) (a : I → A) (b : I → B) + (active : I → Prop) + +theorem reach_to_exterior {x : Sum A B} {y : B} + (h : Relation.ReflTransGen (glued r s a b active) x (.inr y)) : + match x with + | .inr x => Relation.ReflTransGen (compressed r s a b active) x y + | .inl x => ∃ i, active i ∧ Relation.ReflTransGen r x (a i) ∧ + Relation.ReflTransGen (compressed r s a b active) (b i) y := by + induction h using Relation.ReflTransGen.head_induction_on with + | refl => exact .refl + | @head x w h hpath ih => + cases x with + | inl x => + cases w with + | inl w => + obtain ⟨i,hi,hr,hs⟩ := ih + exact ⟨i,hi,hr.head h,hs⟩ + | inr w => + obtain ⟨i,hi,rfl,rfl⟩ := h + exact ⟨i,hi,.refl,ih⟩ + | inr x => + cases w with + | inl w => + obtain ⟨i,hi,rfl,rfl⟩ := h + obtain ⟨j,hj,hr,hs⟩ := ih + exact hs.head (Or.inr ⟨i,j,hi,hj,hr,rfl,rfl⟩) + | inr w => exact ih.head (Or.inl h) + +theorem lift_local_reach {x y : A} (h : Relation.ReflTransGen r x y) : + Relation.ReflTransGen (glued r s a b active) (.inl x) (.inl y) := + h.lift Sum.inl (fun _ _ h => h) + +theorem lift_compressed_reach {x y : B} + (h : Relation.ReflTransGen (compressed r s a b active) x y) : + Relation.ReflTransGen (glued r s a b active) (.inr x) (.inr y) := by + apply h.lift' Sum.inr + intro x y he + rcases he with he | ⟨i,j,hi,hj,hr,rfl,rfl⟩ + · exact .single he + · exact ((lift_local_reach r s a b active hr).head ⟨i,hi,rfl,rfl⟩).tail + ⟨j,hj,rfl,rfl⟩ + +theorem exterior_reach_iff {x y : B} : + Relation.ReflTransGen (glued r s a b active) (.inr x) (.inr y) ↔ + Relation.ReflTransGen (compressed r s a b active) x y := + ⟨reach_to_exterior r s a b active, lift_compressed_reach r s a b active⟩ + +theorem interior_reach_iff {x : A} {y : B} : + Relation.ReflTransGen (glued r s a b active) (.inl x) (.inr y) ↔ + ∃ i, active i ∧ Relation.ReflTransGen r x (a i) ∧ + Relation.ReflTransGen (compressed r s a b active) (b i) y := by + refine ⟨reach_to_exterior r s a b active, ?_⟩ + rintro ⟨i,hi,hr,hs⟩ + have hc : Relation.ReflTransGen (glued r s a b active) (.inl x) (.inr (b i)) := + (lift_local_reach r s a b active hr).tail ⟨i,hi,rfl,rfl⟩ + exact hc.trans (lift_compressed_reach r s a b active hs) + + + +def drains {V : Type*} (r : V → V → Prop) (out : V → Prop) : Prop := + ∀ v w, r v w → ∃ j, out j ∧ Relation.ReflTransGen r v j + +def exteriorOutput (out : B → Prop) : Sum A B → Prop + | .inl _ => False + | .inr x => out x + + + +theorem drains_glued_iff (out : B → Prop) : + drains (glued r s a b active) (exteriorOutput out) ↔ + (∀ x y, r x y → ∃ i, active i ∧ Relation.ReflTransGen r x (a i)) ∧ + drains (compressed r s a b active) out := by + constructor + · intro h + constructor + · intro x y hxy + obtain ⟨z,hz,hr⟩ := h (.inl x) (.inl y) hxy + cases z with + | inl z => exact hz.elim + | inr z => + obtain ⟨i,hi,hr,_⟩ := reach_to_exterior r s a b active hr + exact ⟨i,hi,hr⟩ + · intro x y hxy + rcases hxy with hxy | ⟨i,j,hi,hj,hr,rfl,rfl⟩ + · obtain ⟨z,hz,hr⟩ := h (.inr x) (.inr y) hxy + cases z with + | inl z => exact hz.elim + | inr z => exact ⟨z,hz,reach_to_exterior r s a b active hr⟩ + · obtain ⟨z,hz,hr⟩ := h (.inr (b i)) (.inl (a i)) ⟨i,hi,rfl,rfl⟩ + cases z with + | inl z => exact hz.elim + | inr z => exact ⟨z,hz,reach_to_exterior r s a b active hr⟩ + · rintro ⟨hl,he⟩ v w hvw + cases v with + | inl x => + have hx : ∃ i, active i ∧ Relation.ReflTransGen r x (a i) := by + cases w with + | inl y => exact hl x y hvw + | inr y => obtain ⟨i,hi,rfl,rfl⟩ := hvw; exact ⟨i,hi,.refl⟩ + obtain ⟨i,hi,hr⟩ := hx + obtain ⟨z,hz,hs⟩ := he (b i) (b i) (Or.inr ⟨i,i,hi,hi,.refl,rfl,rfl⟩) + refine ⟨.inr z,hz,?_⟩ + exact (interior_reach_iff r s a b active).mpr ⟨i,hi,hr,hs⟩ + | inr x => + have hx : ∃ y, compressed r s a b active x y := by + cases w with + | inl y => + obtain ⟨i,hi,rfl,rfl⟩ := hvw + exact ⟨b i,Or.inr ⟨i,i,hi,hi,.refl,rfl,rfl⟩⟩ + | inr y => exact ⟨y,Or.inl hvw⟩ + obtain ⟨y,hxy⟩ := hx + obtain ⟨z,hz,hr⟩ := he x y hxy + exact ⟨.inr z,hz,lift_compressed_reach r s a b active hr⟩ + +end +end CriticalStrip.Diagram.Patch + + + + + + + +namespace CriticalStrip.Diagram +noncomputable section + +structure ConnectivityCertificate {V : Type*} (r : V → V → Prop) where + root : V → V + parent : V → V + rank : V → ℕ + edge_root : ∀ x y, r x y → root x = root y + parent_edge : ∀ x, x ≠ root x → r x (parent x) + parent_rank : ∀ x, x ≠ root x → rank (parent x) < rank x + +namespace ConnectivityCertificate +variable {V : Type*} {r : V → V → Prop} (c : ConnectivityCertificate r) + +theorem reaches_root (x : V) : Relation.ReflTransGen r x (c.root x) := by + classical + generalize hk : c.rank x = k + induction k using Nat.strong_induction_on generalizing x with + | h k ih => + by_cases hx : x = c.root x + · rw [← hx] + · have hp := c.parent_edge x hx + have hr := ih (c.rank (c.parent x)) (by rw [← hk]; exact c.parent_rank x hx) + (c.parent x) rfl + rw [← c.edge_root _ _ hp] at hr + exact hr.head hp + +theorem reach_root_eq {x y : V} (h : Relation.ReflTransGen r x y) : c.root x = c.root y := by + induction h with + | refl => rfl + | @tail y z h he ih => exact ih.trans (c.edge_root _ _ he) + +theorem reach_symm (hs : Std.Symm r) {x y : V} (h : Relation.ReflTransGen r x y) : + Relation.ReflTransGen r y x := by + induction h with + | refl => exact .refl + | tail hp he ih => exact ih.head (hs.symm _ _ he) + +theorem reach_iff (hs : Std.Symm r) (x y : V) : + Relation.ReflTransGen r x y ↔ c.root x = c.root y := by + refine ⟨c.reach_root_eq, ?_⟩ + intro he + have hx := c.reaches_root x + rw [he] at hx + exact hx.trans (reach_symm hs (c.reaches_root y)) + +end ConnectivityCertificate + +instance tileAdjDecidable (t : Tile) : DecidableRel t.Adj := fun _ _ => + inferInstanceAs (Decidable (_ ∈ t.edges ∨ _ ∈ t.edges)) + +instance tileOccupiedDecidable (t : Tile) (i : Fin 4) : Decidable (t.Occupied i) := + inferInstanceAs (Decidable (∃ j, t.Adj i j)) + +@[simp] theorem Tile.adj_symm (t : Tile) {i j : Fin 4} : t.Adj i j ↔ t.Adj j i := + or_comm + +end +end CriticalStrip.Diagram + + + + + + + +namespace CriticalStrip.Diagram.ThreeBox +noncomputable section +open Finset + +abbrev Config := Tile × Tile × Tile + +def row (v : Fin 12) : Fin 3 := ⟨v.val/4, by have := v.isLt; omega⟩ +def port (v : Fin 12) : Fin 4 := ⟨v.val%4, Nat.mod_lt _ (by decide)⟩ +def atRow (t : Config) : Fin 3 → Tile := ![t.1,t.2.1,t.2.2] + +def tileEdge (t : Config) (v w : Fin 12) : Prop := + row v = row w ∧ (atRow t (row v)).Adj (port v) (port w) + +def wireEdge (a b v w : Fin 12) : Prop := (v=a ∧ w=b) ∨ (v=b ∧ w=a) + +def Adj (t : Config) (v w : Fin 12) : Prop := + tileEdge t v w ∨ + (wireEdge 2 5 v w ∧ t.1.Occupied 2) ∨ + (wireEdge 3 9 v w ∧ t.1.Occupied 3) ∨ + (wireEdge 7 8 v w ∧ t.2.1.Occupied 3) + +instance tileEdgeDecidable (t : Config) : DecidableRel (tileEdge t) := by + intro v w; unfold tileEdge; infer_instance +instance wireEdgeDecidable (a b : Fin 12) : DecidableRel (wireEdge a b) := by + intro v w; unfold wireEdge; infer_instance +instance adjDecidable (t : Config) : DecidableRel (Adj t) := by + intro v w; unfold Adj; infer_instance + +theorem tileEdge_symm (t : Config) {v w : Fin 12} (h : tileEdge t v w) : tileEdge t w v := by + rcases h with ⟨he,he'⟩ + refine ⟨he.symm, ?_⟩ + rw [← he] + exact (Tile.adj_symm _).mp he' + +theorem wireEdge_symm {a b v w : Fin 12} (h : wireEdge a b v w) : wireEdge a b w v := by + rcases h with ⟨rfl,rfl⟩ | ⟨rfl,rfl⟩ + · exact Or.inr ⟨rfl,rfl⟩ + · exact Or.inl ⟨rfl,rfl⟩ + +theorem adj_symm (t : Config) : Std.Symm (Adj t) := by + constructor + intro v w h + rcases h with h | ⟨h,ho⟩ | ⟨h,ho⟩ | ⟨h,ho⟩ + · exact Or.inl (tileEdge_symm t h) + · exact Or.inr (Or.inl ⟨wireEdge_symm h,ho⟩) + · exact Or.inr (Or.inr (Or.inl ⟨wireEdge_symm h,ho⟩)) + · exact Or.inr (Or.inr (Or.inr ⟨wireEdge_symm h,ho⟩)) + + +def Compatible (t : Config) : Prop := + (t.1.Occupied 2 ↔ t.2.1.Occupied 1) ∧ + (t.1.Occupied 3 ↔ t.2.2.Occupied 1) ∧ + (t.2.1.Occupied 3 ↔ t.2.2.Occupied 0) +instance compatibleDecidable (t : Config) : Decidable (Compatible t) := by + unfold Compatible; infer_instance + + +def boundary : Fin 6 → Fin 12 := ![4,0,1,6,10,11] +def boundaryOccupied (t : Config) (i : Fin 6) : Prop := + (atRow t (row (boundary i))).Occupied (port (boundary i)) +instance boundaryOccupiedDecidable (t : Config) (i : Fin 6) : Decidable (boundaryOccupied t i) := by + unfold boundaryOccupied; infer_instance + +def boundaryAdj (d : Finset (Fin 6 × Fin 6)) (i j : Fin 6) : Prop := + (i,j) ∈ d ∨ (j,i) ∈ d + +def boundarySupport (d : Finset (Fin 6 × Fin 6)) (i : Fin 6) : Prop := + ∃ j, boundaryAdj d i j + + + +structure Realizes (t : Config) (d : Finset (Fin 6 × Fin 6)) : Prop where + compatible : Compatible t + occupied : ∀ i, boundaryOccupied t i ↔ boundarySupport d i + no_loop : ∀ v w, Adj t v w → ∃ i, boundaryOccupied t i ∧ + Relation.ReflTransGen (Adj t) v (boundary i) + output : ∀ i j, i ≠ j → (boundaryAdj d i j ↔ + Relation.ReflTransGen (Adj t) (boundary i) (boundary j)) + +end +end CriticalStrip.Diagram.ThreeBox + +end OAI diff --git a/lean/OAI/Combinatorics/StripMass/PfaffianConfluentLimit.lean b/lean/OAI/Combinatorics/StripMass/PfaffianConfluentLimit.lean new file mode 100644 index 0000000000000000000000000000000000000000..af6a8080220aef29a31ab6ae834ea6abac5ef6a1 --- /dev/null +++ b/lean/OAI/Combinatorics/StripMass/PfaffianConfluentLimit.lean @@ -0,0 +1,413 @@ +import Mathlib +import OAI.Combinatorics.StripMass.SpectralComponents + +namespace OAI + +/-! Critical honeycomb strip paths, polynomial identities and crossing mass. -/ + + +namespace StripPfaffian +noncomputable section +open Polynomial Set MeasureTheory Filter Matrix StripComplexification +open scoped Topology BigOperators +theorem pfaffian_confluent_limit (N : ℕ) (hN : 1 ≤ N) : + ∃ g₀ : Polynomial ℝ, CriticalStrip.MonicProblem N g₀ ∧ + (∀ p, CriticalStrip.MonicProblem N p → p = g₀) ∧ + ∃ g : (Fin N → ℂ) → Polynomial ℂ, + g (fun _ => flatC) = g₀.map Complex.ofRealHom ∧ + (∀ k : ℕ, ContinuousAt (fun a => (g a).coeff k) (fun _ => flatC)) ∧ + ∀ᶠ a in 𝓝 (fun _ : Fin N => flatC), + (g a).Monic ∧ (g a).natDegree = N ∧ + ∀ (_ : Function.Injective a) + (_ : ∀ i j, i ≠ j → D (a i) (a j) ≠ 0) + (_ : p N a ≠ 0) (z : ℂ), + (∀ i, z ≠ a i ∧ D (a i) z ≠ 0) → + (g a).eval z = p (N + 1) (Fin.snoc a z) / p N a := by + obtain ⟨g₀, hg₀, huniq⟩ := CriticalStrip.homogeneous_monic_unique N hN + refine ⟨g₀,hg₀,huniq,confluentPolynomial hN, ?_, + confluentPolynomial_continuousAt hN, ?_⟩ + · exact (perturbed_unique hN _ (systemMatrix_homogeneous_unit hN) _ + (real_monic_problem_map hg₀)).symm + · have hd := (systemMatrix_continuous hN).matrix_det.continuousAt.eventually_ne + (isUnit_iff_ne_zero.1 (systemMatrix_homogeneous_unit hN)) + filter_upwards [hd] with a ha + have hu := isUnit_iff_ne_zero.2 ha + have hg := confluentPolynomial_spec hN a hu + refine ⟨hg.1,hg.2.1, ?_⟩ + intro hinj hD hp z hz + obtain ⟨g,hgm,hgn,hproj,hge⟩ := generic_pfaffian_projection N a hinj hD hp + have he := perturbed_unique hN a hu g ⟨hgm,hgn,hproj⟩ + rw [← he] + exact hge z hz + +end +end StripPfaffian + + +namespace CriticalStrip +noncomputable section +open scoped BigOperators +open Set MeasureTheory + + +theorem rho_pos : 0 < rho := by + unfold rho + exact one_div_pos.mpr (Real.sqrt_pos.mpr (by positivity)) + +theorem c_pos : 0 < c := by + unfold c + exact Real.cos_pos_of_mem_Ioo ⟨by linarith [Real.pi_pos], by linarith [Real.pi_pos]⟩ + +theorem archWeight_nonneg (N : ℕ) (k : ℤ) (p : List Triangle) : + 0 ≤ archWeight N k p := by + classical + unfold archWeight + split_ifs + · exact pow_nonneg rho_pos.le _ + · exact le_rfl + +theorem bridgeWeight_nonneg (N : ℕ) (k : ℤ) (p : List Triangle) : + 0 ≤ bridgeWeight N k p := by + classical + unfold bridgeWeight + split_ifs + · exact pow_nonneg rho_pos.le _ + · exact le_rfl + +theorem K_nonneg (N : ℕ) (k : ℤ) : 0 ≤ K N k := + tsum_nonneg (archWeight_nonneg N k) + +theorem bridgeKernel_nonneg (N : ℕ) (k : ℤ) : 0 ≤ bridgeKernel N k := + tsum_nonneg (bridgeWeight_nonneg N k) + +theorem archMass_nonneg (N : ℕ) : 0 ≤ archMass N := + tsum_nonneg (K_nonneg N) + +theorem bridgeMass_nonneg (N : ℕ) : 0 ≤ bridgeMass N := + tsum_nonneg (bridgeKernel_nonneg N) + +theorem moment_nonneg (N : ℕ) : 0 ≤ moment N := + tsum_nonneg fun k => mul_nonneg (by positivity) (K_nonneg N (k + 1)) + +@[simp] theorem K_zero (N : ℕ) : K N 0 = 0 := by + simp [K, archWeight] + + +theorem IsPath.mono {N M : ℕ} {finish : Triangle} {p : List Triangle} + (hp : IsPath N finish p) (hNM : N ≤ M) : IsPath M finish p := by + obtain ⟨hfirst, hlast, hsimple, hchain, hbands⟩ := hp + exact ⟨hfirst, hlast, hsimple, hchain, + fun v hv => (hbands v hv).trans_le hNM⟩ + +theorem archWeight_mono {N M : ℕ} (hNM : N ≤ M) (k : ℤ) (p : List Triangle) : + archWeight N k p ≤ archWeight M k p := by + classical + by_cases hp : k ≠ 0 ∧ IsPath N (up k 0) p + · have hp' : k ≠ 0 ∧ IsPath M (up k 0) p := ⟨hp.1, hp.2.mono hNM⟩ + simp only [archWeight, ite_eq_left hp, ite_eq_left hp', le_refl] + · rw [archWeight, ite_eq_right hp] + exact archWeight_nonneg M k p + + + +theorem K_le_of_summable {N M : ℕ} (hNM : N ≤ M) (k : ℤ) + (hM : Summable (archWeight M k)) : K N k ≤ K M k := by + have hN : Summable (archWeight N k) := + Summable.of_nonneg_of_le (archWeight_nonneg N k) (archWeight_mono hNM k) hM + exact Summable.tsum_le_tsum (archWeight_mono hNM k) hN hM + +theorem archMass_le_of_finite {N M : ℕ} (hNM : N ≤ M) (hM : StripSumsFinite M) : + archMass N ≤ archMass M := by + have hk : ∀ k, K N k ≤ K M k := fun k => K_le_of_summable hNM k (hM.1 k) + have hN : Summable (K N) := + Summable.of_nonneg_of_le (K_nonneg N) hk hM.2.2.1 + exact Summable.tsum_le_tsum hk hN hM.2.2.1 + +theorem moment_le_of_finite {N M : ℕ} (hNM : N ≤ M) (hM : StripSumsFinite M) : + moment N ≤ moment M := by + have hk : ∀ k : ℕ, (k + 1 : ℝ) * K N (k + 1) ≤ (k + 1 : ℝ) * K M (k + 1) := + fun k => mul_le_mul_of_nonneg_left (K_le_of_summable hNM (k + 1) (hM.1 _)) + (by positivity) + have hN : Summable (fun k : ℕ => (k + 1 : ℝ) * K N (k + 1)) := + Summable.of_nonneg_of_le + (fun k => mul_nonneg (by positivity) (K_nonneg N (k + 1))) hk hM.2.2.2.2 + exact Summable.tsum_le_tsum hk hN hM.2.2.2.2 + + + +theorem bridgeMass_le_of_finite_and_flux {N M : ℕ} (hNM : N ≤ M) + (hM : StripSumsFinite M) + (hfluxN : c * archMass N + bridgeMass N = 1) + (hfluxM : c * archMass M + bridgeMass M = 1) : + bridgeMass M ≤ bridgeMass N := by + have hA := mul_le_mul_of_nonneg_left (archMass_le_of_finite hNM hM) c_pos.le + linarith + + +theorem sum_increment_bounds {M B : ℕ → ℝ} {lo hi : ℝ} + (hlo : 0 ≤ lo) (hhi : 0 ≤ hi) + (hB : AntitoneOn B (Set.Ici 1)) + (hinc : ∀ n : ℕ, 1 ≤ n → lo * B n ≤ M (n + 1) - M n ∧ + M (n + 1) - M n ≤ hi * B n) + {a b : ℕ} (ha : 1 ≤ a) (hab : a ≤ b) : + (b - a : ℕ) * lo * B b ≤ M b - M a ∧ + M b - M a ≤ (b - a : ℕ) * hi * B a := by + have h₁ : ∑ j ∈ Finset.Ico a b, lo * B b ≤ + ∑ j ∈ Finset.Ico a b, (M (j + 1) - M j) := by + apply Finset.sum_le_sum + intro j hj + obtain ⟨haj, hjb⟩ := Finset.mem_Ico.mp hj + exact (mul_le_mul_of_nonneg_left (hB (ha.trans haj) (ha.trans hab) hjb.le) hlo).trans + (hinc j (ha.trans haj)).1 + have h₂ : ∑ j ∈ Finset.Ico a b, (M (j + 1) - M j) ≤ + ∑ j ∈ Finset.Ico a b, hi * B a := by + apply Finset.sum_le_sum + intro j hj + obtain ⟨haj, _⟩ := Finset.mem_Ico.mp hj + exact (hinc j (ha.trans haj)).2.trans + (mul_le_mul_of_nonneg_left (hB ha (ha.trans haj) haj) hhi) + constructor + · simpa only [Finset.sum_Ico_sub _ hab, Finset.sum_const, Nat.card_Ico, + nsmul_eq_mul, mul_assoc] using h₁ + · simpa only [Finset.sum_Ico_sub _ hab, Finset.sum_const, Nat.card_Ico, + nsmul_eq_mul, mul_assoc] using h₂ + + + +theorem comparable_of_antitone_increments {M B : ℕ → ℝ} {α : ℝ} + (hα : 0 < α) + (hBnon : ∀ n : ℕ, 1 ≤ n → 0 ≤ B n) + (hBsucc : ∀ n : ℕ, 1 ≤ n → B (n + 1) ≤ B n) + (hdiff : Comparable (fun n => M (n + 1) - M n) B) + (hM : Comparable M (fun n => (n : ℝ) ^ α)) : + Comparable B (fun n => (n : ℝ) ^ (α - 1)) := by + obtain ⟨loD, hiD, hloD, hhiD, hD⟩ := hdiff + obtain ⟨loM, hiM, hloM, hhiM, hM⟩ := hM + have hB : AntitoneOn B (Set.Ici 1) := antitoneOn_nat_Ici_of_succ_le hBsucc + have hM1 : 0 ≤ M 1 := by + have h := (hM 1 le_rfl).1 + norm_num at h + exact hloM.le.trans h + have hupper : ∀ n : ℕ, 2 ≤ n → + B n ≤ (2 * hiM / loD) * (n : ℝ) ^ (α - 1) := by + intro n hn + have hn1 : 1 ≤ n := by omega + have hnr : (2 : ℝ) ≤ n := by exact_mod_cast hn + have hnpos : 0 < (n : ℝ) := by linarith + have hinterval := (sum_increment_bounds hloD.le hhiD.le hB hD + (a := 1) (b := n) le_rfl hn1).1 + rw [Nat.cast_sub hn1, Nat.cast_one] at hinterval + have hbound : ((n : ℝ) - 1) * loD * B n ≤ hiM * (n : ℝ) ^ α := + (hinterval.trans (sub_le_self _ hM1)).trans (hM n hn1).2 + have hnon : 0 ≤ ((n : ℝ) - 2) * (loD * B n) := + mul_nonneg (by linarith) (mul_nonneg hloD.le (hBnon n hn1)) + have hmul : (n : ℝ) * loD * B n ≤ 2 * hiM * (n : ℝ) ^ α := by + nlinarith only [hbound, hnon] + calc + B n ≤ (2 * hiM * (n : ℝ) ^ α) / ((n : ℝ) * loD) := + (le_div_iff₀ (mul_pos hnpos hloD)).2 (by nlinarith only [hmul]) + _ = (2 * hiM / loD) * (n : ℝ) ^ (α - 1) := by + rw [Real.rpow_sub hnpos, Real.rpow_one] + field_simp + obtain ⟨L, hLbig⟩ := exists_nat_gt (max (2 : ℝ) ((2 * hiM / loM) ^ α⁻¹)) + have hLr : (2 : ℝ) ≤ L := (le_max_left _ _).trans hLbig.le + have hL : 2 ≤ L := by exact_mod_cast hLr + have hscale : 2 * hiM ≤ loM * (L : ℝ) ^ α := by + have hpow := Real.rpow_le_rpow (Real.rpow_nonneg (by positivity) _) + ((le_max_right _ _).trans hLbig.le) hα.le + rw [Real.rpow_inv_rpow (by positivity) hα.ne'] at hpow + simpa only [mul_comm] using (div_le_iff₀ hloM).mp hpow + have hdenom : 0 < ((L : ℝ) - 1) * hiD := + mul_pos (by linarith) hhiD + refine ⟨hiM / (((L : ℝ) - 1) * hiD), max (B 1) (2 * hiM / loD), + div_pos hhiM hdenom, lt_of_lt_of_le (by positivity) (le_max_right _ _), ?_⟩ + intro n hn + have hnpos : 0 < (n : ℝ) := by exact_mod_cast (show 0 < n by omega) + have hnpow : 0 ≤ (n : ℝ) ^ α := Real.rpow_nonneg hnpos.le _ + constructor + · have hnLN : n ≤ L * n := by + calc + n = 1 * n := (one_mul n).symm + _ ≤ L * n := Nat.mul_le_mul_right n (by omega) + have hgrowth : hiM * (n : ℝ) ^ α ≤ M (L * n) - M n := by + have hlarge := (hM (L * n) (hn.trans hnLN)).1 + dsimp only at hlarge + rw [Nat.cast_mul, Real.mul_rpow (by positivity) hnpos.le] at hlarge + have hsmall := (hM n hn).2 + have hscale' := mul_le_mul_of_nonneg_right hscale hnpow + nlinarith only [hlarge, hsmall, hscale'] + have hinterval := (sum_increment_bounds hloD.le hhiD.le hB hD hn hnLN).2 + rw [Nat.cast_sub hnLN, Nat.cast_mul] at hinterval + have hbound : hiM * (n : ℝ) ^ α ≤ + B n * (((L : ℝ) - 1) * hiD * (n : ℝ)) := by + nlinarith only [hgrowth, hinterval] + calc + (hiM / (((L : ℝ) - 1) * hiD)) * (n : ℝ) ^ (α - 1) = + (hiM * (n : ℝ) ^ α) / (((L : ℝ) - 1) * hiD * (n : ℝ)) := by + rw [Real.rpow_sub hnpos, Real.rpow_one] + field_simp + _ ≤ B n := (div_le_iff₀ (mul_pos hdenom hnpos)).2 hbound + · rcases eq_or_lt_of_le hn with hn' | hn' + · subst n + simp + · exact (hupper n (by omega)).trans (mul_le_mul_of_nonneg_right + (le_max_right _ _) (Real.rpow_nonneg hnpos.le _)) + + + +theorem criticalStripMass_iff_four_estimates : CriticalStripMass ↔ + (∀ N : ℕ, 1 ≤ N → StripSumsFinite N) ∧ + (∀ N : ℕ, 1 ≤ N → c * archMass N + bridgeMass N = 1) ∧ + Comparable (fun N => moment (N + 1) - moment N) bridgeMass ∧ + Comparable moment (fun N => (N : ℝ) ^ (3 / 4 : ℝ)) := by + constructor + · intro h + exact ⟨h.1, h.2.1, h.2.2.1, h.2.2.2.1⟩ + · rintro ⟨hfinite, hflux, hinc, hmoment⟩ + have hmono : ∀ N : ℕ, 1 ≤ N → bridgeMass (N + 1) ≤ bridgeMass N := by + intro N hN + exact bridgeMass_le_of_finite_and_flux (Nat.le_succ N) + (hfinite (N + 1) (by omega)) (hflux N hN) (hflux (N + 1) (by omega)) + have hbridge := comparable_of_antitone_increments (by norm_num : (0 : ℝ) < 3 / 4) + (fun N _ => bridgeMass_nonneg N) hmono hinc hmoment + refine ⟨hfinite, hflux, hinc, hmoment, ?_, hmono⟩ + simpa only [show (3 / 4 : ℝ) - 1 = -(1 / 4 : ℝ) by norm_num] using hbridge + + + + +theorem reflection_deficit_bounds {N : ℕ} {y : Fin N → ℝ} + (hy : y ∈ orderedDomain N) {x : ℝ} (hx : 0 < x) : + 0 ≤ 1 - reflectionProduct N x y ∧ + 1 - reflectionProduct N x y ≤ 2 * min 1 (x * ∑ i, (y i)⁻¹) := by + have hR := abs_reflectionProduct_le_one hy hx.le + refine ⟨by linarith [(abs_le.mp hR).2], ?_⟩ + rw [mul_min_of_nonneg _ _ (by norm_num : (0 : ℝ) ≤ 2)] + apply le_min + · linarith [(abs_le.mp hR).1] + · calc + 1 - reflectionProduct N x y ≤ |1 - reflectionProduct N x y| := le_abs_self _ + _ ≤ ∑ i : Fin N, |1 - (y i - x) / (y i + x)| := + abs_one_sub_prod_le _ _ fun i _ => abs_reflectionFactor_le_one hx.le (hy.2 i).1 + _ ≤ ∑ i : Fin N, 2 * x * (y i)⁻¹ := by + apply Finset.sum_le_sum + intro i _ + have hyi := (hy.2 i).1 + have hdenom : 0 < y i + x := add_pos hyi hx + rw [show 1 - (y i - x) / (y i + x) = 2 * x / (y i + x) by field_simp; ring, + abs_of_pos (div_pos (by positivity) hdenom)] + change 2 * x / (y i + x) ≤ 2 * x / y i + exact div_le_div_of_nonneg_left (by positivity) hyi (le_add_of_nonneg_right hx.le) + _ = 2 * (x * ∑ i : Fin N, (y i)⁻¹) := by rw [← Finset.mul_sum]; ring + + +theorem reflection_deficit_lower {N : ℕ} {y : Fin N → ℝ} (hy : y ∈ orderedDomain N) + (i : Fin N) (hsmall : ∀ j, y i ≤ y j) {x : ℝ} + (hx : x ∈ Ioo (y i / 3) (y i / 2)) : + (1 / 2 : ℝ) ≤ 1 - reflectionProduct N x y := by + classical + have hyi := (hy.2 i).1 + have hxpos : 0 < x := (by positivity : 0 < y i / 3).trans hx.1 + have hnon : ∀ j : Fin N, 0 ≤ (y j - x) / (y j + x) := by + intro j + exact div_nonneg (by linarith [hsmall j, hx.2]) (add_pos (hy.2 j).1 hxpos).le + have hproduct : reflectionProduct N x y ≤ (y i - x) / (y i + x) := by + have h := Finset.prod_le_prod_of_subset_of_le_one₀ + (s := {i}) (t := Finset.univ) (f := fun j : Fin N => (y j - x) / (y j + x)) + (Finset.subset_univ _) (fun j _ => hnon j) + (fun j _ _ => (le_abs_self _).trans (abs_reflectionFactor_le_one hxpos.le (hy.2 j).1)) + simpa only [reflectionProduct, Finset.prod_singleton] using h + have hhalf : (y i - x) / (y i + x) ≤ (1 / 2 : ℝ) := by + apply (div_le_iff₀ (add_pos hyi hxpos)).2 + linarith [hx.1] + linarith + + +theorem rpow_le_eight_omega {x : ℝ} (hx : x ∈ Ioc 0 (1 / 2 : ℝ)) : + (1 / 8 : ℝ) * x ^ (-(1 / 4 : ℝ)) ≤ omega x := by + have hx0 := hx.1 + have hq : (3 / 2 : ℝ) ≤ (1 + x) / (2 * x) := by + apply (le_div_iff₀ (by positivity : 0 < 2 * x)).2 + nlinarith [hx.2] + have hqnon : 0 ≤ (1 + x) / (2 * x) := by positivity + have hsq := Real.sq_sqrt hqnon + have hsnon := Real.sqrt_nonneg ((1 + x) / (2 * x)) + have hs : (6 / 5 : ℝ) ≤ Real.sqrt ((1 + x) / (2 * x)) := by + nlinarith + have hsn : 0 ≤ Real.sqrt ((1 + x) / (2 * x)) - 1 := by linarith + have hosq : (omega x) ^ 2 = (Real.sqrt ((1 + x) / (2 * x)) - 1) / 4 := by + unfold omega + nlinarith [Real.sq_sqrt hsn] + have hsub : Real.sqrt ((1 + x) / (2 * x)) / 6 ≤ + Real.sqrt ((1 + x) / (2 * x)) - 1 := by linarith + have hpow : ((1 / 8 : ℝ) * x ^ (-(1 / 4 : ℝ))) ^ (4 : ℕ) ≤ (omega x) ^ 4 := by + have hcomp : Real.sqrt ((1 + x) / (2 * x)) / 24 ≤ (omega x) ^ 2 := by linarith + have hcomp' := mul_self_le_mul_self (by positivity) hcomp + have hquart : (1 + x) / (2 * x) / 576 ≤ (omega x) ^ 4 := by nlinarith only [hcomp', hsq] + have hxinv : 0 ≤ x⁻¹ := inv_nonneg.mpr hx.1.le + have hqinv : x⁻¹ / 2 ≤ (1 + x) / (2 * x) := by + calc + x⁻¹ / 2 = 1 / (2 * x) := by ring + _ ≤ (1 + x) / (2 * x) := div_le_div_of_nonneg_right (by linarith [hx.1]) (by positivity) + have he : (x ^ (-(1 / 4 : ℝ))) ^ (4 : ℕ) = x⁻¹ := by + rw [← Real.rpow_natCast, ← Real.rpow_mul hx.1.le] + norm_num [Real.rpow_neg_one] + rw [mul_pow, he] + nlinarith only [hquart, hqinv, hxinv] + exact (pow_le_pow_iff_left₀ (by positivity) (omega_nonneg x) (by norm_num : (4 : ℕ) ≠ 0)).mp hpow + + + +def pointwiseArchIntegrand (N : ℕ) (y : Fin N → ℝ) (x : ℝ) : ℝ := + (1 - reflectionProduct N x y) * omega x / x + +def pointwiseArchIntegral (N : ℕ) (y : Fin N → ℝ) : ℝ := + ∫ x in Ioo 0 1, pointwiseArchIntegrand N y x + +theorem measurable_pointwiseArchIntegrand (N : ℕ) (y : Fin N → ℝ) : + Measurable (pointwiseArchIntegrand N y) := by + have hR : Measurable (fun x : ℝ => reflectionProduct N x y) := (measurable_reflectionProduct N).comp (measurable_id.prodMk measurable_const) + exact ((measurable_const.sub hR).mul measurable_omega).div measurable_id + +theorem pointwiseArchIntegrand_bounds {N : ℕ} {y : Fin N → ℝ} + (hy : y ∈ orderedDomain N) {x : ℝ} (hx : x ∈ Ioo 0 1) : + 0 ≤ pointwiseArchIntegrand N y x ∧ + pointwiseArchIntegrand N y x ≤ inverseHalfSum N y * x ^ (-(3 / 4 : ℝ)) := by + have hdef := (reflection_deficit_bounds hy hx.1).1 + have hb := (le_abs_self (1 - reflectionProduct N x y)).trans + (reflectionProduct_endpoint_bound hy hx.1) + have hS : 0 ≤ inverseHalfSum N y := + Finset.sum_nonneg fun i _ => (Real.rpow_pos_of_pos (hy.2 i).1 _).le + constructor + · exact div_nonneg (mul_nonneg hdef (omega_nonneg x)) hx.1.le + · have hpow : Real.sqrt x * x ^ (-(1 / 4 : ℝ)) / x = x ^ (-(3 / 4 : ℝ)) := by + rw [Real.sqrt_eq_rpow, ← Real.rpow_add hx.1] + calc + x ^ (1 / 2 + -(1 / 4) : ℝ) / x = x ^ (1 / 4 : ℝ) / x ^ (1 : ℝ) := by norm_num + _ = x ^ ((1 / 4 : ℝ) - 1) := (Real.rpow_sub hx.1 _ _).symm + _ = _ := by norm_num + calc + pointwiseArchIntegrand N y x ≤ (Real.sqrt x * inverseHalfSum N y) * omega x / x := + div_le_div_of_nonneg_right (mul_le_mul_of_nonneg_right hb (omega_nonneg x)) hx.1.le + _ ≤ (Real.sqrt x * inverseHalfSum N y) * x ^ (-(1 / 4 : ℝ)) / x := + div_le_div_of_nonneg_right (mul_le_mul_of_nonneg_left (omega_le_rpow hx) + (mul_nonneg (Real.sqrt_nonneg x) hS)) hx.1.le + _ = inverseHalfSum N y * (Real.sqrt x * x ^ (-(1 / 4 : ℝ)) / x) := by ring + _ = _ := by rw [hpow] + +theorem integrableOn_pointwiseArchIntegrand {N : ℕ} {y : Fin N → ℝ} + (hy : y ∈ orderedDomain N) : + IntegrableOn (pointwiseArchIntegrand N y) (Ioo 0 1) := by + have hp : IntegrableOn (fun x : ℝ => x ^ (-(3 / 4 : ℝ))) (Ioo 0 1) := + (intervalIntegral.integrableOn_Ioo_rpow_iff (by norm_num : (0 : ℝ) < 1)).2 (by norm_num) + apply (hp.const_mul (inverseHalfSum N y)).mono' + (measurable_pointwiseArchIntegrand N y).aestronglyMeasurable + filter_upwards [ae_restrict_mem measurableSet_Ioo] with x hx + rw [Real.norm_eq_abs, abs_of_nonneg (pointwiseArchIntegrand_bounds hy hx).1] + exact (pointwiseArchIntegrand_bounds hy hx).2 + + +end +end CriticalStrip + +end OAI diff --git a/lean/OAI/Combinatorics/StripMass/PfaffianEvaluation.lean b/lean/OAI/Combinatorics/StripMass/PfaffianEvaluation.lean new file mode 100644 index 0000000000000000000000000000000000000000..d2d6f42a8f16048f4865fd59ed26b19c8119fdba --- /dev/null +++ b/lean/OAI/Combinatorics/StripMass/PfaffianEvaluation.lean @@ -0,0 +1,432 @@ +import Mathlib +import OAI.Combinatorics.StripMass.PfaffianRecursion + +namespace OAI + +/-! Critical honeycomb strip paths, polynomial identities and crossing mass. -/ + + +namespace StripPfaffian +noncomputable section +open scoped BigOperators +open Polynomial +lemma clearedPf_eval (N : ℕ) (a : Fin N → ℂ) (z : ℂ) + (hz : ∀ i, D (a i) z ≠ 0) : + (clearedPf N a).eval z = (denominatorPoly N a).eval z * actualPf (N + 1) (Fin.snoc a z) := by + rw [clearedPf, polyLift_eval] + have he : (fun i : Fin (N + 1) => Polynomial.eval z ((Fin.snoc (kernelNumerator N a) (denominatorPoly N a) : Fin (N + 1) → Polynomial ℂ) i)) = + (denominatorPoly N a).eval z • Fin.snoc (fun i => kernel (a i) z) 1 := by + ext i + refine Fin.lastCases ?_ (fun j => ?_) i + · simp + · simp [kernelNumerator_eval N a z hz] + rw [he, map_smul, incrementLinear_eval, smul_eq_mul] + +lemma clearedPf_root (N : ℕ) (a : Fin N → ℂ) + (hD : ∀ i j, i ≠ j → D (a i) (a j) ≠ 0) (i : Fin N) : + (clearedPf N a).eval (a i) = 0 := by + by_cases hii : D (a i) (a i) = 0 + · have hH : (denominatorPoly N a).eval (a i) = 0 := by + rw [denominatorPoly_eval] + exact Finset.prod_eq_zero (Finset.mem_univ i) hii + have hK : ∀ j, (kernelNumerator N a j).eval (a i) = 0 := by + intro j + by_cases hji : j = i + · subst j + simp [kernelNumerator, pairNumerator] + · have hj : (deletedDenominator N a j).eval (a i) = 0 := by + rw [deletedDenominator, eval_prod] + apply Finset.prod_eq_zero (i := i) + · simp [Ne.symm hji] + · simpa using hii + simp [kernelNumerator, hj] + rw [clearedPf, polyLift_eval] + convert (incrementLinear N a).map_zero using 1 + congr 1 + ext j + refine Fin.lastCases ?_ (fun k => ?_) j <;> simp [hH, hK] + · have hz : ∀ j, D (a j) (a i) ≠ 0 := by + intro j + by_cases hji : j = i + · simpa [hji] using hii + · exact hD j i hji + rw [clearedPf_eval N a (a i) hz] + have hzero := actualPf_duplicate (Fin.snoc a (a i)) i.castSucc (Fin.last N) + (by simp) (by simp) + rw [hzero, mul_zero] + +def nodalPoly (N : ℕ) (a : Fin N → ℂ) : Polynomial ℂ := ∏ i, (X - C (a i)) + +lemma nodalPoly_monic (N : ℕ) (a : Fin N → ℂ) : (nodalPoly N a).Monic := + monic_prod_X_sub_C a Finset.univ + +lemma nodalPoly_degree (N : ℕ) (a : Fin N → ℂ) : (nodalPoly N a).natDegree = N := by + rw [nodalPoly, natDegree_prod _ _ (fun i _ => (monic_X_sub_C (a i)).ne_zero)] + simp + +lemma nodalPoly_dvd (N : ℕ) (a : Fin N → ℂ) (ha : Function.Injective a) + (hD : ∀ i j, i ≠ j → D (a i) (a j) ≠ 0) : nodalPoly N a ∣ clearedPf N a := by + apply Finset.prod_dvd_of_coprime + · intro i hi j hj hij + exact pairwise_coprime_X_sub_C ha hij + · intro i hi + exact dvd_iff_isRoot.mpr (clearedPf_root N a hD i) + +lemma normalized_cleared_monic (N : ℕ) (a : Fin N → ℂ) (hpf : actualPf N a ≠ 0) : + let Q := C (((-1 : ℂ) ^ N * actualPf N a)⁻¹) * clearedPf N a + Q.Monic ∧ Q.natDegree = 2 * N := by + dsimp only + have hne : (-1 : ℂ) ^ N * actualPf N a ≠ 0 := mul_ne_zero (pow_ne_zero _ (by norm_num)) hpf + have hd : (C (((-1 : ℂ) ^ N * actualPf N a)⁻¹) * clearedPf N a).natDegree ≤ 2 * N := + (natDegree_C_mul_le _ _).trans (clearedPf_degree N a) + have hc : (C (((-1 : ℂ) ^ N * actualPf N a)⁻¹) * clearedPf N a).coeff (2 * N) = 1 := by + rw [coeff_C_mul, clearedPf_coeff, inv_mul_cancel₀ hne] + exact ⟨monic_of_natDegree_le_of_coeff_eq_one _ hd hc, + natDegree_eq_of_le_of_coeff_ne_zero hd (by rw [hc]; exact one_ne_zero)⟩ + +def prefactor (N : ℕ) (a : Fin N → ℂ) : ℂ := + ∏ i, ∏ j ∈ Finset.Ioi i, D (a i) (a j) / (a i - a j) + +lemma p_eq (N : ℕ) (a : Fin N → ℂ) : p N a = prefactor N a * actualPf N a := rfl + +lemma prod_Ioi_castSucc {n : ℕ} (f : Fin (n + 1) → ℂ) (i : Fin n) : + (∏ j ∈ Finset.Ioi i.castSucc, f j) = (∏ j ∈ Finset.Ioi i, f j.castSucc) * f (Fin.last n) := by + have h1 : Finset.Ioi i.castSucc = Finset.univ.filter (fun j => i.castSucc < j) := by ext; simp + have h2 : Finset.Ioi i = Finset.univ.filter (fun j => i < j) := by ext; simp + rw [h1, h2, Finset.prod_filter, Finset.prod_filter, Fin.prod_univ_castSucc] + simp + +lemma prod_Ioi_last {n : ℕ} (f : Fin (n + 1) → ℂ) : + (∏ j ∈ Finset.Ioi (Fin.last n), f j) = 1 := by + apply Finset.prod_eq_one + intro j hj + have h := Finset.mem_Ioi.mp hj + have hj := j.isLt + change n < j.val at h + omega + +lemma prefactor_snoc (N : ℕ) (a : Fin N → ℂ) (z : ℂ) : + prefactor (N + 1) (Fin.snoc a z) = prefactor N a * ∏ i, D (a i) z / (a i - z) := by + unfold prefactor + rw [Fin.prod_univ_castSucc, prod_Ioi_last, mul_one] + simp_rw [prod_Ioi_castSucc, Fin.snoc_castSucc, Fin.snoc_last] + exact Finset.prod_mul_distrib + +lemma nodalPoly_eval (N : ℕ) (a : Fin N → ℂ) (z : ℂ) : + (nodalPoly N a).eval z = ∏ i, (z - a i) := by + simp only [nodalPoly, eval_prod, eval_sub, eval_X, eval_C] + +lemma difference_prod (N : ℕ) (a : Fin N → ℂ) (z : ℂ) : + (∏ i, (a i - z)) = (-1 : ℂ) ^ N * (nodalPoly N a).eval z := by + rw [nodalPoly_eval] + calc (∏ i, (a i - z)) = ∏ i, ((-1 : ℂ) * (z - a i)) := by + apply Finset.prod_congr rfl + intro i hi + ring + _ = (-1 : ℂ) ^ N * ∏ i, (z - a i) := by rw [Finset.prod_mul_distrib]; simp + +lemma generic_arch_quotient_factor (N : ℕ) (a : Fin N → ℂ) + (ha : Function.Injective a) + (hD : ∀ i j, i ≠ j → D (a i) (a j) ≠ 0) + (hp : p N a ≠ 0) : + ∃ g : Polynomial ℂ, g.Monic ∧ g.natDegree = N ∧ + nodalPoly N a * g = C (((-1 : ℂ) ^ N * actualPf N a)⁻¹) * clearedPf N a ∧ + ∀ z : ℂ, (∀ i, z ≠ a i ∧ D (a i) z ≠ 0) → + g.eval z = p (N + 1) (Fin.snoc a z) / p N a := by + have hpre : prefactor N a ≠ 0 := left_ne_zero_of_mul (p_eq N a ▸ hp) + have hpf : actualPf N a ≠ 0 := right_ne_zero_of_mul (p_eq N a ▸ hp) + let Q := C (((-1 : ℂ) ^ N * actualPf N a)⁻¹) * clearedPf N a + have hQ := normalized_cleared_monic N a hpf + change Q.Monic ∧ Q.natDegree = 2 * N at hQ + have hd : nodalPoly N a ∣ Q := dvd_mul_of_dvd_right (nodalPoly_dvd N a ha hD) _ + obtain ⟨g, hg⟩ := hd + have hgm : g.Monic := (nodalPoly_monic N a).of_mul_monic_left (hg ▸ hQ.1) + have hgn : g.natDegree = N := by + have h := hQ.2 + rw [hg, (nodalPoly_monic N a).natDegree_mul hgm, nodalPoly_degree] at h + omega + refine ⟨g, hgm, hgn, hg.symm, ?_⟩ + intro z hz + have hn : (nodalPoly N a).eval z ≠ 0 := by + rw [nodalPoly_eval] + exact Finset.prod_ne_zero_iff.mpr (fun i _ => sub_ne_zero.mpr (hz i).1) + have hs : (-1 : ℂ) ^ N ≠ 0 := pow_ne_zero _ (by norm_num) + have he := congrArg (Polynomial.eval z) hg + dsimp only [Q] at he + rw [eval_mul, eval_C, clearedPf_eval N a z (fun i => (hz i).2), eval_mul] at he + rw [p_eq, prefactor_snoc, p_eq, Finset.prod_div_distrib, difference_prod, + ← denominatorPoly_eval] + apply (eq_div_iff (mul_ne_zero hpre hpf)).mpr + have he' : ((-1 : ℂ) ^ N * actualPf N a)⁻¹ * + ((denominatorPoly N a).eval z * actualPf (N + 1) (Fin.snoc a z)) = + (nodalPoly N a).eval z * g.eval z := he + field_simp [hs, hpf] at he' + field_simp [hn, hs] + simpa only [mul_assoc, mul_left_comm, mul_comm] using he'.symm + + +theorem generic_arch_quotient_monic (N : ℕ) (a : Fin N → ℂ) + (ha : Function.Injective a) + (hD : ∀ i j, i ≠ j → D (a i) (a j) ≠ 0) + (hp : p N a ≠ 0) : + ∃ g : Polynomial ℂ, g.Monic ∧ g.natDegree = N ∧ + ∀ z : ℂ, (∀ i, z ≠ a i ∧ D (a i) z ≠ 0) → + g.eval z = p (N + 1) (Fin.snoc a z) / p N a := +by + obtain ⟨g, hgm, hgn, _, hg⟩ := generic_arch_quotient_factor N a ha hD hp + exact ⟨g, hgm, hgn, hg⟩ + +end +noncomputable section +open Polynomial +open scoped BigOperators + +def flatC : ℂ := (Real.cos (Real.pi / 8) : ℝ) +def harmonicPoly : Polynomial ℂ := X ^ 2 * (1 - X ^ 2) +def Epoly (a : ℂ) : Polynomial ℂ := X ^ 2 - C (2 * d * a) * X + C (a ^ 2 - d ^ 2) +def perturbedRootC {N : ℕ} (a : Fin N → ℂ) : Polynomial ℂ := + (X - C flatC) * ∏ i, ((X - C (a i)) * Epoly (a i)) +def HasProjectionC (N : ℕ) (Q : Polynomial ℂ) : Prop := + ∃ P J E : Polynomial ℂ, + P.natDegree ≤ N ∧ J.natDegree ≤ N ∧ E.degree < (N : WithBot ℕ) ∧ + Q = P.comp harmonicPoly + X * J.comp harmonicPoly + X ^ 2 * E.comp harmonicPoly + + +lemma constant_relations : d ^ 2 = (1 / 2 : ℂ) ∧ flatC * rho = (1 / 2 : ℂ) ∧ + rho * (1 + 2 * d) = 2 * flatC * d := by + have hs : (Real.sqrt 2) ^ 2 = 2 := Real.sq_sqrt (by norm_num) + have ht : (Real.sqrt (2 + Real.sqrt 2)) ^ 2 = 2 + Real.sqrt 2 := Real.sq_sqrt (by positivity) + have ht0 : Real.sqrt (2 + Real.sqrt 2) ≠ 0 := ne_of_gt (Real.sqrt_pos.2 (by positivity)) + have hd : Real.cos (2 * (Real.pi / 8)) = Real.sqrt 2 / 2 := by + rw [show 2 * (Real.pi / 8) = Real.pi / 4 by ring, Real.cos_pi_div_four] + have h1 : (Real.cos (2 * (Real.pi / 8))) ^ 2 = (1 / 2 : ℝ) := by rw [hd]; nlinarith + have h2 : Real.cos (Real.pi / 8) * (1 / Real.sqrt (2 + Real.sqrt 2)) = (1 / 2 : ℝ) := by + rw [Real.cos_pi_div_eight] + field_simp + have h3 : (1 / Real.sqrt (2 + Real.sqrt 2)) * (1 + 2 * Real.cos (2 * (Real.pi / 8))) = + 2 * Real.cos (Real.pi / 8) * Real.cos (2 * (Real.pi / 8)) := by + rw [hd, Real.cos_pi_div_eight] + field_simp + nlinarith + unfold d flatC rho + refine ⟨?_, ?_, ?_⟩ + · simpa using congrArg Complex.ofReal h1 + · simpa using congrArg Complex.ofReal h2 + · exact_mod_cast h3 + +def invariantFactor (a : ℂ) : Polynomial ℂ := C ((a ^ 2 - d ^ 2) ^ 2) - X + +def kernelProjectP (a : ℂ) : Polynomial ℂ := + C (-flatC * (a ^ 2 + a * rho) * (a ^ 2 - d ^ 2)) - C (2 * d * a - rho + flatC) * X + +def kernelProjectJ (a : ℂ) : Polynomial ℂ := + C ((a ^ 2 + a * rho) * (a ^ 2 - d ^ 2) + + flatC * (2 * d * a * (a ^ 2 + a * rho) + rho * (a ^ 2 - d ^ 2))) + X + +def kernelProjectE (a : ℂ) : Polynomial ℂ := + C (-2 * d * a * (a ^ 2 + a * rho) - rho * (a ^ 2 - d ^ 2) - + flatC * (a * rho * (1 + 2 * d) + d ^ 2) + (2 * d * a - rho + flatC)) + +lemma paired_invariant (a : ℂ) : Dpoly a * Epoly a = (invariantFactor a).comp harmonicPoly := by + have hd : 2 * d ^ 2 = (1 : ℂ) := by rw [constant_relations.1]; norm_num + have hc := congrArg (Polynomial.C : ℂ → Polynomial ℂ) hd + simp only [map_mul, map_pow, map_ofNat, map_one] at hc + simp only [Dpoly, Epoly, invariantFactor, harmonicPoly, sub_comp, C_comp, X_comp, + pow_comp, map_mul, map_sub, map_pow, map_ofNat] + linear_combination -(2 * Polynomial.C a ^ 2 + 1) * X ^ 2 * hc + +lemma kernel_projection_identity (a : ℂ) : + (X - C flatC) * pairNumerator a * Epoly a = + (kernelProjectP a).comp harmonicPoly + X * (kernelProjectJ a).comp harmonicPoly + + X ^ 2 * (kernelProjectE a).comp harmonicPoly := by + have hc : a * rho * (1 + 2 * d) + d ^ 2 - flatC * (2 * d * a - rho) - 1 = 0 := by + calc a * rho * (1 + 2 * d) + d ^ 2 - flatC * (2 * d * a - rho) - 1 = + a * (rho * (1 + 2 * d) - 2 * flatC * d) + d ^ 2 + flatC * rho - 1 := by ring + _ = 0 := by rw [constant_relations.2.2, constant_relations.1, constant_relations.2.1]; ring + calc (X - C flatC) * pairNumerator a * Epoly a = + (kernelProjectP a).comp harmonicPoly + X * (kernelProjectJ a).comp harmonicPoly + + X ^ 2 * (kernelProjectE a).comp harmonicPoly + + C (a * rho * (1 + 2 * d) + d ^ 2 - flatC * (2 * d * a - rho) - 1) * X ^ 3 := by + simp only [pairNumerator, Epoly, kernelProjectP, kernelProjectJ, kernelProjectE, + harmonicPoly, sub_comp, add_comp, mul_comp, C_comp, X_comp, + pow_comp, neg_comp, ofNat_comp, one_comp, + map_add, map_mul, map_sub, map_neg, map_pow, map_ofNat, map_one] + ring + _ = _ := by rw [hc]; simp + +lemma HasProjectionC.zero (N : ℕ) : HasProjectionC N 0 := by + refine ⟨0, 0, 0, ?_, ?_, ?_, ?_⟩ <;> simp + +lemma HasProjectionC.add {N : ℕ} {Q R : Polynomial ℂ} + (hQ : HasProjectionC N Q) (hR : HasProjectionC N R) : HasProjectionC N (Q + R) := by + obtain ⟨P, J, E, hp, hj, he, rfl⟩ := hQ + obtain ⟨P', J', E', hp', hj', he', rfl⟩ := hR + refine ⟨P + P', J + J', E + E', (natDegree_add_le _ _).trans (max_le hp hp'), + (natDegree_add_le _ _).trans (max_le hj hj'), + (degree_add_le _ _).trans_lt (max_lt he he'), ?_⟩ + simp only [add_comp] + ring + +lemma HasProjectionC.const_mul {N : ℕ} {Q : Polynomial ℂ} + (hQ : HasProjectionC N Q) (t : ℂ) : HasProjectionC N (C t * Q) := by + obtain ⟨P, J, E, hp, hj, he, rfl⟩ := hQ + refine ⟨C t * P, C t * J, C t * E, (natDegree_C_mul_le _ _).trans hp, + (natDegree_C_mul_le _ _).trans hj, ?_, ?_⟩ + · by_cases ht : t = 0 + · simp [ht] + · rw [degree_C_mul ht] + exact he + · simp only [mul_comp, C_comp] + ring + +lemma HasProjectionC.mul_comp {N M : ℕ} {Q R : Polynomial ℂ} + (hQ : HasProjectionC N Q) (hR : R.natDegree ≤ M) : + HasProjectionC (N + M) (Q * R.comp harmonicPoly) := by + obtain ⟨P, J, E, hp, hj, he, rfl⟩ := hQ + refine ⟨P * R, J * R, E * R, natDegree_mul_le.trans (add_le_add hp hR), + natDegree_mul_le.trans (add_le_add hj hR), ?_, ?_⟩ + · by_cases hE : E = 0 + · simp [hE] + · rw [degree_eq_natDegree hE] at he + have hE' : E.natDegree < N := by exact_mod_cast he + exact degree_le_natDegree.trans_lt (by exact_mod_cast + ((natDegree_mul_le : (E * R).natDegree ≤ E.natDegree + R.natDegree).trans_lt + (Nat.add_lt_add_of_lt_of_le hE' hR))) + · simp only [Polynomial.mul_comp] + ring + +lemma HasProjectionC.sum {N : ℕ} {ι : Type*} (s : Finset ι) (f : ι → Polynomial ℂ) + (hf : ∀ i ∈ s, HasProjectionC N (f i)) : HasProjectionC N (∑ i ∈ s, f i) := by + classical + induction s using Finset.induction_on with + | empty => simpa using HasProjectionC.zero N + | @insert i s hi ih => + rw [Finset.sum_insert hi] + exact (hf i (Finset.mem_insert_self _ _)).add + (ih (fun j hj => hf j (Finset.mem_insert_of_mem hj))) + +lemma base_projected : HasProjectionC 0 (X - C flatC) := by + refine ⟨C (-flatC), 1, 0, ?_, ?_, ?_, ?_⟩ <;> simp; ring + +lemma kernel_projected (a : ℂ) : HasProjectionC 1 ((X - C flatC) * pairNumerator a * Epoly a) := by + refine ⟨kernelProjectP a, kernelProjectJ a, kernelProjectE a, ?_, ?_, ?_, kernel_projection_identity a⟩ + · unfold kernelProjectP; compute_degree! + · unfold kernelProjectJ; compute_degree! + · unfold kernelProjectE; compute_degree! + +lemma invariant_product_degree {ι : Type*} (s : Finset ι) (a : ι → ℂ) : + (∏ i ∈ s, invariantFactor (a i)).natDegree ≤ s.card := by + apply (natDegree_prod_le _ _).trans + calc ∑ i ∈ s, (invariantFactor (a i)).natDegree ≤ ∑ _i ∈ s, 1 := by + apply Finset.sum_le_sum + intro i hi + unfold invariantFactor + compute_degree! + _ = s.card := by simp + +lemma paired_product {ι : Type*} (s : Finset ι) (a : ι → ℂ) : + (∏ i ∈ s, Dpoly (a i)) * (∏ i ∈ s, Epoly (a i)) = + (∏ i ∈ s, invariantFactor (a i)).comp harmonicPoly := by + rw [← Finset.prod_mul_distrib] + simp_rw [paired_invariant] + exact (Polynomial.prod_comp _ _ _).symm + +lemma denominator_projected (N : ℕ) (a : Fin N → ℂ) : + HasProjectionC N ((X - C flatC) * denominatorPoly N a * ∏ i, Epoly (a i)) := by + have h := base_projected.mul_comp (invariant_product_degree Finset.univ a) + simpa only [zero_add, Finset.card_univ, Fintype.card_fin, ← paired_product, + ← mul_assoc, denominatorPoly] using h + +lemma numerator_projected (N : ℕ) (a : Fin N → ℂ) (i : Fin N) : + HasProjectionC N ((X - C flatC) * kernelNumerator N a i * ∏ j, Epoly (a j)) := by + have h := (kernel_projected (a i)).mul_comp + (invariant_product_degree (Finset.univ.erase i) a) + have hcard : 1 + (Finset.univ.erase i).card = N := by + have hi := i.isLt + simp only [Finset.card_erase_of_mem (Finset.mem_univ i), Finset.card_univ, Fintype.card_fin] + omega + rw [hcard, ← paired_product] at h + rw [← Finset.mul_prod_erase Finset.univ (fun j => Epoly (a j)) (Finset.mem_univ i)] + convert h using 1 + unfold kernelNumerator deletedDenominator + ring + +lemma polyLift_projected {n M : ℕ} (L : Vec n →ₗ[ℂ] ℂ) + (f : Fin n → Polynomial ℂ) (Q R : Polynomial ℂ) + (hf : ∀ i, HasProjectionC M (Q * f i * R)) : + HasProjectionC M (Q * polyLift L f * R) := by + have h := HasProjectionC.sum Finset.univ + (fun i => C (L (standardBasis n i)) * (Q * f i * R)) + (fun i _ => (hf i).const_mul (L (standardBasis n i))) + convert h using 1 + simp only [polyLift, Finset.mul_sum, Finset.sum_mul] + apply Finset.sum_congr rfl + intro i hi + ring + +lemma cleared_projected (N : ℕ) (a : Fin N → ℂ) : + HasProjectionC N ((X - C flatC) * clearedPf N a * ∏ i, Epoly (a i)) := by + apply polyLift_projected + intro i + refine Fin.lastCases ?_ (fun j => ?_) i + · simpa only [Fin.snoc_last] using denominator_projected N a + · simpa only [Fin.snoc_castSucc] using numerator_projected N a j + + +theorem generic_pfaffian_projection (N : ℕ) (a : Fin N → ℂ) + (ha : Function.Injective a) + (hD : ∀ i j, i ≠ j → D (a i) (a j) ≠ 0) + (hp : p N a ≠ 0) : + ∃ g : Polynomial ℂ, g.Monic ∧ g.natDegree = N ∧ + HasProjectionC N (perturbedRootC a * g) ∧ + ∀ z : ℂ, (∀ i, z ≠ a i ∧ D (a i) z ≠ 0) → + g.eval z = p (N + 1) (Fin.snoc a z) / p N a := by + obtain ⟨g, hgm, hgn, hgf, hg⟩ := generic_arch_quotient_factor N a ha hD hp + refine ⟨g, hgm, hgn, ?_, hg⟩ + have h := (cleared_projected N a).const_mul (((-1 : ℂ) ^ N * actualPf N a)⁻¹) + convert h using 1 + unfold perturbedRootC + rw [Finset.prod_mul_distrib] + change (X - C flatC) * (nodalPoly N a * ∏ i, Epoly (a i)) * g = _ + calc (X - C flatC) * (nodalPoly N a * ∏ i, Epoly (a i)) * g = + (X - C flatC) * (nodalPoly N a * g) * ∏ i, Epoly (a i) := by ring + _ = _ := by rw [hgf]; ring + +end +end StripPfaffian + +namespace StripComplexification +noncomputable section +open Polynomial +open scoped BigOperators + +def component (l : ℂ →ₗ[ℝ] ℝ) (p : Polynomial ℂ) : Polynomial ℝ := + .ofFinsupp (.ofCoeff (Finsupp.mapRange l (map_zero l) p.toFinsupp.coeff)) + +@[simp] lemma component_coeff (l : ℂ →ₗ[ℝ] ℝ) (p : Polynomial ℂ) (n : ℕ) : + (component l p).coeff n = l (p.coeff n) := rfl + +@[simp] lemma component_add (l : ℂ →ₗ[ℝ] ℝ) (p q : Polynomial ℂ) : + component l (p + q) = component l p + component l q := by + ext n + simp + +@[simp] lemma component_C (l : ℂ →ₗ[ℝ] ℝ) (c : ℂ) : + component l (C c) = C (l c) := by + ext n + by_cases hn : n = 0 + · simp [hn] + · simp [coeff_C, hn] + +lemma component_real_mul (l : ℂ →ₗ[ℝ] ℝ) (q : Polynomial ℝ) (p : Polynomial ℂ) : + component l (q.map Complex.ofRealHom * p) = q * component l p := by + ext n + simp only [component_coeff, coeff_mul, map_sum, coeff_map, Complex.ofRealHom_eq_coe] + apply Finset.sum_congr rfl + intro ij hij + exact l.map_smul (q.coeff ij.1) (p.coeff ij.2) + +end +end StripComplexification + +end OAI diff --git a/lean/OAI/Combinatorics/StripMass/PfaffianIntegration.lean b/lean/OAI/Combinatorics/StripMass/PfaffianIntegration.lean new file mode 100644 index 0000000000000000000000000000000000000000..d06a52d988e9a3e55f9494ff427201f56487266f --- /dev/null +++ b/lean/OAI/Combinatorics/StripMass/PfaffianIntegration.lean @@ -0,0 +1,437 @@ +import Mathlib +import OAI.Combinatorics.StripMass.PairCoordinates + +namespace OAI + +/-! Critical honeycomb strip paths, polynomial identities and crossing mass. -/ + + +namespace StripPfaffian +noncomputable section +open scoped BigOperators +open MeasureTheory Set +lemma integral_pair_single_product {α : Type*} [MeasurableSpace α] (μ : Measure α) + [SigmaFinite μ] (m : ℕ) (f : Fin m → α × α → ℂ) (g : α → ℂ) : + (∫ x : Fin (m*2+1) → α, (∏ i : Fin m, + f i (x (pairLeft i).castSucc, x (pairRight i).castSucc)) * g (x (Fin.last (m*2))) + ∂Measure.pi (fun _ => μ)) = (∏ i, ∫ rs, f i rs ∂μ.prod μ) * ∫ t, g t ∂μ := by + rw [← ((measurePreserving_piFinSuccAbove (fun _ : Fin (m*2+1) => μ) + (Fin.last (m*2))).symm).integral_comp'] + simp only [MeasurableEquiv.piFinSuccAbove_symm_apply, Fin.insertNthEquiv, + Equiv.coe_fn_mk, Fin.insertNth_last, Fin.snoc_castSucc, Fin.snoc_last, cast_eq] + simp_rw [mul_comm _ (g _)] + rw [integral_prod_mul (μ := μ) (ν := Measure.pi (fun _ : Fin (m*2) => μ)) g + (fun x : Fin (m*2) → α => ∏ i, f i (x (pairLeft i), x (pairRight i))), + integral_pair_product, mul_comm] + +lemma integrable_pair_single_product {α : Type*} [MeasurableSpace α] (μ : Measure α) + [SigmaFinite μ] (m : ℕ) {f : Fin m → α × α → ℂ} {g : α → ℂ} + (hf : ∀ i, Integrable (f i) (μ.prod μ)) (hg : Integrable g μ) : + Integrable (fun x : Fin (m*2+1) → α => (∏ i : Fin m, + f i (x (pairLeft i).castSucc, x (pairRight i).castSucc)) * g (x (Fin.last (m*2)))) + (Measure.pi (fun _ => μ)) := by + apply (((measurePreserving_piFinSuccAbove (fun _ : Fin (m*2+1) => μ) + (Fin.last (m*2))).symm).integrable_comp_emb + (MeasurableEquiv.piFinSuccAbove (fun _ : Fin (m*2+1) => α) + (Fin.last (m*2))).symm.measurableEmbedding).mp + simp only [Function.comp_def, MeasurableEquiv.piFinSuccAbove_symm_apply, + Fin.insertNthEquiv, Equiv.coe_fn_mk, Fin.insertNth_last, + Fin.snoc_castSucc, Fin.snoc_last, cast_eq] + simp_rw [mul_comm _ (g _)] + exact hg.mul_prod (integrable_pair_product μ m hf) + +def singleMoment {α : Type*} [MeasurableSpace α] {n : ℕ} (μ : Measure α) + (φ : Fin n → α → ℂ) (g : α → ℂ) : Fin n → ℂ := + fun i => ∫ t, φ i t * g t ∂μ + +lemma product_double_singleIntegrand {α : Type*} {m : ℕ} (φ : Fin (m*2+1) → α → ℂ) + (k : α → α → ℂ) (g : α → ℂ) (σ : Equiv.Perm (Fin (m*2+1))) (x : Fin (m*2+1) → α) : + (∏ i : Fin m, doubleIntegrand φ k (σ (pairLeft i).castSucc) (σ (pairRight i).castSucc) + (x (pairLeft i).castSucc, x (pairRight i).castSucc)) * + (φ (σ (Fin.last (m*2))) (x (Fin.last (m*2))) * g (x (Fin.last (m*2)))) = + (∏ i : Fin (m*2+1), φ (σ i) (x i)) * + oddPairEntries (fun i j => k (x i) (x j)) (g ∘ x) := by + unfold doubleIntegrand oddPairEntries + rw [Fin.prod_univ_castSucc, ← prod_pairs (fun i => φ (σ i.castSucc) (x i.castSucc))] + simp only [Finset.prod_mul_distrib, Function.comp_apply] + ring + +lemma determinant_times_oddPairs {α : Type*} {m : ℕ} (φ : Fin (m*2+1) → α → ℂ) + (k : α → α → ℂ) (g : α → ℂ) (x : Fin (m*2+1) → α) : + (evaluationMatrix φ x).det * oddPairEntries (fun i j => k (x i) (x j)) (g ∘ x) = + ∑ σ : Equiv.Perm (Fin (m*2+1)), (Equiv.Perm.sign σ : ℂ) * + ((∏ i : Fin m, doubleIntegrand φ k (σ (pairLeft i).castSucc) (σ (pairRight i).castSucc) + (x (pairLeft i).castSucc, x (pairRight i).castSucc)) * + (φ (σ (Fin.last (m*2))) (x (Fin.last (m*2))) * g (x (Fin.last (m*2))))) := by + rw [Matrix.det_apply, Finset.sum_mul] + apply Finset.sum_congr rfl + intro σ hσ + rw [product_double_singleIntegrand] + simp only [evaluationMatrix, Units.smul_def, ← Int.cast_smul_eq_zsmul ℂ, smul_eq_mul] + ring + +lemma integrable_determinant_times_oddPairs {α : Type*} [MeasurableSpace α] (μ : Measure α) + [SigmaFinite μ] {m : ℕ} (φ : Fin (m*2+1) → α → ℂ) (k : α → α → ℂ) (g : α → ℂ) + (hi : ∀ i j, Integrable (doubleIntegrand φ k i j) (μ.prod μ)) + (hs : ∀ i, Integrable (fun t => φ i t * g t) μ) : + Integrable (fun x => (evaluationMatrix φ x).det * + oddPairEntries (fun i j => k (x i) (x j)) (g ∘ x)) (Measure.pi (fun _ => μ)) := by + simp only [determinant_times_oddPairs] + exact integrable_finsetSum _ (fun σ _ => + (integrable_pair_single_product μ m (fun i => hi _ _) (hs _)).const_mul _) + +lemma integral_determinant_times_oddPairs {α : Type*} [MeasurableSpace α] (μ : Measure α) + [SigmaFinite μ] {m : ℕ} (φ : Fin (m*2+1) → α → ℂ) (k : α → α → ℂ) (g : α → ℂ) + (hi : ∀ i j, Integrable (doubleIntegrand φ k i j) (μ.prod μ)) + (hs : ∀ i, Integrable (fun t => φ i t * g t) μ) : + (∫ x, (evaluationMatrix φ x).det * oddPairEntries (fun i j => k (x i) (x j)) (g ∘ x) + ∂Measure.pi (fun _ => μ)) = + ∑ σ : Equiv.Perm (Fin (m*2+1)), (Equiv.Perm.sign σ : ℂ) * + oddPairEntries (fun i j => doubleMomentMatrix μ φ k (σ i) (σ j)) + (singleMoment μ φ g ∘ σ) := by + simp only [determinant_times_oddPairs] + rw [integral_finsetSum _ (fun σ _ => + (integrable_pair_single_product μ m (fun i => hi _ _) (hs _)).const_mul _)] + apply Finset.sum_congr rfl + intro σ hσ + rw [integral_const_mul] + congr 1 + exact integral_pair_single_product μ m + (fun i => doubleIntegrand φ k (σ (pairLeft i).castSucc) (σ (pairRight i).castSucc)) + (fun t => φ (σ (Fin.last (m*2))) t * g t) + + + +theorem deBruijn_odd {α : Type*} [MeasurableSpace α] (μ : Measure α) + [SigmaFinite μ] (m : ℕ) (φ : Fin (m*2+1) → α → ℂ) (k : α → α → ℂ) (g : α → ℂ) + (hk : ∀ r s, k s r = -k r s) + (hi : ∀ i j, Integrable (doubleIntegrand φ k i j) (μ.prod μ)) + (hs : ∀ i, Integrable (fun t => φ i t * g t) μ) : + (∫ x, (evaluationMatrix φ x).det * + pfaffian (m*2+2) (border (fun i j => k (x i) (x j)) (g ∘ x)) + ∂Measure.pi (fun _ => μ)) = + (Nat.factorial (m*2+1) : ℂ) * pfaffian (m*2+2) + (border (doubleMomentMatrix μ φ k) (singleMoment μ φ g)) := by + let F : (Fin (m*2+1) → α) → ℂ := fun x => (evaluationMatrix φ x).det + let G : (Fin (m*2+1) → α) → ℂ := fun x => oddPairEntries (fun i j => k (x i) (x j)) (g ∘ x) + have hF (σ : Equiv.Perm (Fin (m*2+1))) (x : Fin (m*2+1) → α) : + F (x ∘ σ) = (Equiv.Perm.sign σ : ℂ) * F x := evaluationMatrix_det_perm φ σ x + have hI := integrable_determinant_times_oddPairs μ φ k g hi hs + have hII (σ : Equiv.Perm (Fin (m*2+1))) : + Integrable (fun x => F x * ((Equiv.Perm.sign σ : ℂ) * G (x ∘ σ))) + (Measure.pi (fun _ => μ)) := by + have h := (integrable_alternating_times_perm μ F G hF hI σ).const_mul (Equiv.Perm.sign σ : ℂ) + convert h using 1 + ext x + ring + have hpoint (x : Fin (m*2+1) → α) : + F x * pfaffian (m*2+2) (border (fun i j => k (x i) (x j)) (g ∘ x)) = + ((1/2:ℂ)^m / m.factorial) * + ∑ σ : Equiv.Perm (Fin (m*2+1)), F x * ((Equiv.Perm.sign σ : ℂ) * G (x ∘ σ)) := by + rw [pfaffian_border_permutation_expansion m _ (fun i j => hk _ _)] + simp only [Finset.mul_sum] + apply Finset.sum_congr rfl + intro σ _ + dsimp [F, G, Function.comp_def] + ring + change (∫ x, F x * pfaffian (m*2+2) _ ∂Measure.pi (fun _ => μ)) = _ + simp_rw [hpoint] + rw [integral_const_mul, integral_finsetSum _ (fun σ _ => hII σ)] + have he (σ : Equiv.Perm (Fin (m*2+1))) : + (∫ x, F x * ((Equiv.Perm.sign σ : ℂ) * G (x ∘ σ)) ∂Measure.pi (fun _ => μ)) = + ∫ x, F x * G x ∂Measure.pi (fun _ => μ) := by + calc + _ = (Equiv.Perm.sign σ : ℂ) * ∫ x, F x * G (x ∘ σ) ∂Measure.pi (fun _ => μ) := by + rw [← integral_const_mul] + congr 1 + ext x + ring + _ = _ := by + rw [integral_alternating_times_perm μ F G hF, ← mul_assoc] + have hs : (Equiv.Perm.sign σ : ℂ) * (Equiv.Perm.sign σ : ℂ) = 1 := by + have hs : (Equiv.Perm.sign σ : ℤ) * (Equiv.Perm.sign σ : ℤ) = 1 := + congrArg Units.val (Int.units_mul_self (Equiv.Perm.sign σ)) + exact_mod_cast hs + rw [hs, one_mul] + simp_rw [he] + rw [Finset.sum_const, Finset.card_univ, Fintype.card_perm, Fintype.card_fin, nsmul_eq_mul, + pfaffian_border_permutation_expansion m _ (doubleMomentMatrix_skew μ φ k hk), + ← integral_determinant_times_oddPairs μ φ k g hi hs] + dsimp [F,G] + ring + +end +end StripPfaffian + + + +namespace CriticalStrip +noncomputable section +open scoped BigOperators +open MeasureTheory Set StripPfaffian + +local notation "μ₊" => volume.restrict (Ioi (0 : ℝ)) + +lemma laguerreDomain_subset_positive (n : ℕ) : + laguerreDomain n ⊆ univ.pi (fun _ : Fin n => Ioi (0 : ℝ)) := + fun _ hr i _ => hr.2 i + +lemma positive_product_restrict_chamber (n : ℕ) : + (Measure.pi (fun _ : Fin n => μ₊)).restrict (laguerreDomain n) = + volume.restrict (laguerreDomain n) := by + rw [← Measure.restrict_pi_pi, ← volume_pi, + Measure.restrict_restrict (isOpen_laguerreDomain n).measurableSet, + inter_eq_left.mpr (laguerreDomain_subset_positive n)] + +lemma ae_positive_product (n : ℕ) : + ∀ᵐ x : Fin n → ℝ ∂Measure.pi (fun _ => μ₊), ∀ i, 0 < x i := by + rw [← Measure.restrict_pi_pi, ← volume_pi] + exact (ae_restrict_mem (MeasurableSet.univ_pi fun _ => measurableSet_Ioi)).mono + fun _ hx i => hx i (mem_univ i) + +lemma sum_ordered_indicator {n : ℕ} (F : (Fin n → ℝ) → ℂ) + (hperm : ∀ σ : Equiv.Perm (Fin n), ∀ x, F (x ∘ σ) = F x) + (hzero : ∀ x, ¬Function.Injective x → F x = 0) + (x : Fin n → ℝ) (hx : ∀ i, 0 < x i) : + (∑ σ : Equiv.Perm (Fin n), (laguerreDomain n).indicator F (x ∘ σ)) = F x := by + classical + by_cases hi : Function.Injective x + · have hs : x ∘ Tuple.sort x ∈ laguerreDomain n := + ⟨(Tuple.monotone_sort x).strictMono_of_injective (hi.comp (Tuple.sort x).injective), + fun i => hx _⟩ + rw [Finset.sum_eq_single (Tuple.sort x)] + · rw [indicator_of_mem hs, hperm] + · intro σ hσ hne + apply indicator_of_notMem + intro hσs + apply hne + apply Equiv.ext + intro i + exact hi (congrFun (Tuple.unique_monotone hσs.1.monotone (Tuple.monotone_sort x)) i) + · simp + · rw [hzero x hi] + apply Finset.sum_eq_zero + intro σ hσ + by_cases hm : x ∘ σ ∈ laguerreDomain n + · rw [indicator_of_mem hm, hperm, hzero x hi] + · exact indicator_of_notMem hm _ + + + +lemma integral_symmetric_ordered {n : ℕ} (F : (Fin n → ℝ) → ℂ) + (hperm : ∀ σ : Equiv.Perm (Fin n), ∀ x, F (x ∘ σ) = F x) + (hzero : ∀ x, ¬Function.Injective x → F x = 0) + (hint : IntegrableOn F (laguerreDomain n)) : + (∫ x, F x ∂Measure.pi (fun _ : Fin n => μ₊)) = + (n.factorial : ℂ) * ∫ x in laguerreDomain n, F x := by + classical + let G := (laguerreDomain n).indicator F + have hi : Integrable G (Measure.pi (fun _ : Fin n => μ₊)) := by + rw [integrable_indicator_iff (isOpen_laguerreDomain n).measurableSet] + simpa only [IntegrableOn, positive_product_restrict_chamber] using hint + have his (σ : Equiv.Perm (Fin n)) : + Integrable (fun x => G (x ∘ σ)) (Measure.pi (fun _ : Fin n => μ₊)) := by + simpa only [Function.comp_def, piCongrLeft_const_apply, Equiv.symm_symm] using + (measurePreserving_piCongrLeft (fun _ : Fin n => μ₊) σ.symm).integrable_comp_of_integrable hi + have heq (σ : Equiv.Perm (Fin n)) : + (∫ x, G (x ∘ σ) ∂Measure.pi (fun _ : Fin n => μ₊)) = + ∫ x in laguerreDomain n, F x := by + have he := (measurePreserving_piCongrLeft (fun _ : Fin n => μ₊) σ.symm).integral_comp' G + simp only [piCongrLeft_const_apply, Equiv.symm_symm] at he + rw [he, integral_indicator (isOpen_laguerreDomain n).measurableSet, + positive_product_restrict_chamber] + calc + _ = ∫ x, ∑ σ : Equiv.Perm (Fin n), G (x ∘ σ) ∂Measure.pi (fun _ => μ₊) := by + apply integral_congr_ae + exact (ae_positive_product n).mono fun x hx => (sum_ordered_indicator F hperm hzero x hx).symm + _ = ∑ σ : Equiv.Perm (Fin n), ∫ x, G (x ∘ σ) ∂Measure.pi (fun _ => μ₊) := + integral_finsetSum _ (fun σ _ => his σ) + _ = _ := by simp only [heq, Finset.sum_const, Finset.card_univ, + Fintype.card_perm, Fintype.card_fin, nsmul_eq_mul] + +end +end CriticalStrip + +namespace StripPfaffian +noncomputable section +open scoped BigOperators +open MeasureTheory Set + +lemma permMap_apply {n : ℕ} (σ : Equiv.Perm (Fin n)) (u : Vec n) : + permMap n σ u = u ∘ σ.symm := by + have hu : ∑ i : Fin n, u i • standardBasis n i = u := by + simpa only [standardBasis, Pi.basisFun_repr] using (standardBasis n).sum_repr u + calc + _ = ∑ i : Fin n, u i • standardBasis n (σ i) := by + conv_lhs => rw [← hu] + simp only [map_sum, map_smul, permMap_basis] + _ = ∑ i : Fin n, u (σ.symm i) • standardBasis n i := by + apply Fintype.sum_equiv σ + intro i + simp + _ = _ := by simpa only [standardBasis, Pi.basisFun_repr, Function.comp_apply] using + (standardBasis n).sum_repr (u ∘ σ.symm) + +lemma pfaffian_border_perm {n : ℕ} (hn : Odd n) + (A : Matrix (Fin n) (Fin n) ℂ) (hA : ∀ i j, A j i = -A i j) (u : Vec n) + (σ : Equiv.Perm (Fin n)) : + pfaffian (n+1) (border (fun i j => A (σ.symm i) (σ.symm j)) (u ∘ σ.symm)) = + (Equiv.Perm.sign σ : ℂ) * pfaffian (n+1) (border A u) := by + have hn' : 2*(n/2)+1 = n := by obtain ⟨k, hk⟩ := hn; omega + have hhom : twoForm A ^ (n/2) * ExteriorAlgebra.ι ℂ u ∈ + ExteriorAlgebra.exteriorPower ℂ n (Vec n) := by + simpa only [hn'] using SetLike.mul_mem_graded (twoForm_pow_mem A (n/2)) + (show ExteriorAlgebra.ι ℂ u ∈ ExteriorAlgebra.exteriorPower ℂ 1 (Vec n) from by + simpa only [ExteriorAlgebra.exteriorPower, pow_one] using + (LinearMap.mem_range_self (ExteriorAlgebra.ι ℂ) u)) + erw [pfaffian_border hn _ (fun i j => hA _ _), pfaffian_border hn A hA, + borderLinear_eq_topCoord hn, borderLinear_eq_topCoord hn, + ← twoForm_perm A hA σ, ← permMap_apply σ u, ← ExteriorAlgebra.map_apply_ι, + ← map_pow, ← map_mul, topCoord_map _ _ _ hhom, permMap_det] + ring + +lemma perm_sign_mul_self {n : ℕ} (σ : Equiv.Perm (Fin n)) : + (Equiv.Perm.sign σ : ℂ) * (Equiv.Perm.sign σ : ℂ) = 1 := by + have hs : (Equiv.Perm.sign σ : ℤ) * (Equiv.Perm.sign σ : ℤ) = 1 := + congrArg Units.val (Int.units_mul_self (Equiv.Perm.sign σ)) + exact_mod_cast hs + +lemma determinantPfaffian_symmetric_even {α : Type*} {n : ℕ} (hn : Even n) + (φ : Fin n → α → ℂ) (k : α → α → ℂ) (hk : ∀ r s, k s r = -k r s) + (σ : Equiv.Perm (Fin n)) (x : Fin n → α) : + (evaluationMatrix φ (x ∘ σ)).det * pfaffian n (fun i j => k (x (σ i)) (x (σ j))) = + (evaluationMatrix φ x).det * pfaffian n (fun i j => k (x i) (x j)) := by + rw [evaluationMatrix_det_perm] + have hp := pfaffian_perm n hn (fun i j => k (x i) (x j)) (fun i j => hk _ _) σ.symm + simp only [Equiv.symm_symm, Equiv.Perm.sign_symm] at hp + erw [hp] + calc + _ = ((Equiv.Perm.sign σ : ℂ) * (Equiv.Perm.sign σ : ℂ)) * + ((evaluationMatrix φ x).det * pfaffian n (fun i j => k (x i) (x j))) := by ring + _ = _ := by rw [perm_sign_mul_self, one_mul] + +lemma determinantPfaffian_symmetric_odd {α : Type*} {n : ℕ} (hn : Odd n) + (φ : Fin n → α → ℂ) (k : α → α → ℂ) (g : α → ℂ) (hk : ∀ r s, k s r = -k r s) + (σ : Equiv.Perm (Fin n)) (x : Fin n → α) : + (evaluationMatrix φ (x ∘ σ)).det * pfaffian (n+1) + (border (fun i j => k (x (σ i)) (x (σ j))) (g ∘ x ∘ σ)) = + (evaluationMatrix φ x).det * pfaffian (n+1) + (border (fun i j => k (x i) (x j)) (g ∘ x)) := by + rw [evaluationMatrix_det_perm] + have hp := pfaffian_border_perm hn (fun i j => k (x i) (x j)) + (fun i j => hk _ _) (g ∘ x) σ.symm + simp only [Equiv.symm_symm, Equiv.Perm.sign_symm] at hp + erw [hp] + calc + _ = ((Equiv.Perm.sign σ : ℂ) * (Equiv.Perm.sign σ : ℂ)) * + ((evaluationMatrix φ x).det * pfaffian (n+1) + (border (fun i j => k (x i) (x j)) (g ∘ x))) := by ring + _ = _ := by rw [perm_sign_mul_self, one_mul] + +lemma evaluationMatrix_det_of_not_injective {α : Type*} {n : ℕ} + (φ : Fin n → α → ℂ) {x : Fin n → α} (hx : ¬Function.Injective x) : + (evaluationMatrix φ x).det = 0 := by + obtain ⟨i, j, hij, hne⟩ := Function.not_injective_iff.mp hx + exact Matrix.det_zero_of_column_eq hne (fun r => congrArg (φ r) hij) + +end +end StripPfaffian + +namespace CriticalStrip +noncomputable section +open scoped BigOperators +open MeasureTheory Set StripPfaffian + +local notation "μ₊" => volume.restrict (Ioi (0 : ℝ)) + +def laguerrePhi (n : ℕ) (a : ℝ) (i : Fin n) (x : ℝ) : ℂ := laguerreWeight (a+i.val) x + +lemma laguerreWeight_shift_nat (a : ℝ) (i : ℕ) {x : ℝ} (hx : 0 < x) : + laguerreWeight (a+i) x = laguerreWeight a x * x^i := by + unfold laguerreWeight + rw [show a+(i:ℝ)-1=(a-1)+(i:ℝ) by ring, Real.rpow_add hx, Real.rpow_natCast] + ring + +lemma laguerre_evaluation_determinant {n : ℕ} (a : ℝ) {x : Fin n → ℝ} + (hx : ∀ i, 0 < x i) : + (evaluationMatrix (laguerrePhi n a) x).det = + (∏ i, (laguerreWeight a (x i) : ℂ)) * + ∏ i, ∏ j ∈ Finset.Ioi i, ((x j : ℂ) - (x i : ℂ)) := by + have he : evaluationMatrix (laguerrePhi n a) x = + Matrix.of (fun i j => (laguerreWeight a (x j) : ℂ) * + (Matrix.vandermonde (fun i => (x i : ℂ))).transpose i j) := by + ext i j + simp only [evaluationMatrix, laguerrePhi, Matrix.of_apply, Matrix.transpose_apply, + Matrix.vandermonde_apply, laguerreWeight_shift_nat a i.val (hx j), + Complex.ofReal_mul, Complex.ofReal_pow] + rw [he, Matrix.det_mul_row, Matrix.det_transpose, Matrix.det_vandermonde] + +lemma vandermonde_schur_density (n : ℕ) (a : ℝ) (x : Fin n → ℝ) : + ((∏ i, (laguerreWeight a (x i) : ℂ)) * + ∏ i, ∏ j ∈ Finset.Ioi i, ((x j : ℂ) - (x i : ℂ))) * + schurProduct (fun i => (x i : ℂ)) = (laguerreDensity n a x : ℂ) := by + simp only [laguerreDensity, Complex.ofReal_mul, Complex.ofReal_prod, mul_assoc, schurProduct] + congr 1 + rw [← Finset.prod_mul_distrib] + apply Finset.prod_congr rfl + intro i _ + rw [← Finset.prod_mul_distrib] + apply Finset.prod_congr rfl + intro j _ + simp only [schurEntry, pairKernel, Complex.ofReal_div, Complex.ofReal_pow, + Complex.ofReal_sub, Complex.ofReal_add] + rw [add_comm (x j : ℂ) (x i : ℂ)] + ring + +def laguerreEvenIntegrand (n : ℕ) (a : ℝ) (x : Fin n → ℝ) : ℂ := + (evaluationMatrix (laguerrePhi n a) x).det * + pfaffian n (schurMatrix (fun i => (x i : ℂ))) + +def laguerreOddIntegrand (n : ℕ) (a : ℝ) (x : Fin n → ℝ) : ℂ := + (evaluationMatrix (laguerrePhi n a) x).det * + pfaffian (n+1) (border (schurMatrix (fun i => (x i : ℂ))) (fun _ => 1)) + +lemma laguerreEvenIntegrand_eq {n : ℕ} (hn : Even n) (a : ℝ) + {x : Fin n → ℝ} (hx : x ∈ laguerreDomain n) : + laguerreEvenIntegrand n a x = laguerreDensity n a x := by + have hd (i j : Fin n) : (x i : ℂ) + (x j : ℂ) ≠ 0 := by + rw [← Complex.ofReal_add, Complex.ofReal_ne_zero] + exact (add_pos (hx.2 i) (hx.2 j)).ne' + have hi : Function.Injective (fun i => (x i : ℂ)) := Complex.ofReal_injective.comp hx.1.injective + rw [laguerreEvenIntegrand, pfaffian_schur_even n hn _ hd hi, + laguerre_evaluation_determinant a hx.2, vandermonde_schur_density] + +lemma laguerreOddIntegrand_eq {n : ℕ} (hn : Odd n) (a : ℝ) + {x : Fin n → ℝ} (hx : x ∈ laguerreDomain n) : + laguerreOddIntegrand n a x = laguerreDensity n a x := by + have hd (i j : Fin n) : (x i : ℂ) + (x j : ℂ) ≠ 0 := by + rw [← Complex.ofReal_add, Complex.ofReal_ne_zero] + exact (add_pos (hx.2 i) (hx.2 j)).ne' + have hi : Function.Injective (fun i => (x i : ℂ)) := Complex.ofReal_injective.comp hx.1.injective + rw [laguerreOddIntegrand, pfaffian_schur_odd n hn _ hd hi, + laguerre_evaluation_determinant a hx.2, vandermonde_schur_density] + +lemma integral_laguerreEvenIntegrand {n : ℕ} (hn : Even n) {a : ℝ} (ha : 0 < a) : + (∫ x, laguerreEvenIntegrand n a x ∂Measure.pi (fun _ : Fin n => μ₊)) = + (n.factorial : ℂ) * (laguerreNormalizer n a : ℂ) := by + have he : ∀ᵐ x ∂volume.restrict (laguerreDomain n), + laguerreEvenIntegrand n a x = (laguerreDensity n a x : ℂ) := + (ae_restrict_mem (isOpen_laguerreDomain n).measurableSet).mono + fun x hx => laguerreEvenIntegrand_eq hn a hx + rw [integral_symmetric_ordered _ + (fun σ x => determinantPfaffian_symmetric_even hn _ + (fun r s : ℝ => schurEntry r s) (fun r s => schurEntry_swap _ _) σ x) + (fun x hx => by + unfold laguerreEvenIntegrand + rw [evaluationMatrix_det_of_not_injective _ hx, zero_mul]) + (by + have hi := (integrableOn_laguerreDensity n ha).ofReal (𝕜 := ℂ) + simp only [RCLike.ofReal_eq_complex_ofReal] at hi + exact hi.congr (he.mono fun _ h => h.symm))] + rw [integral_congr_ae he, integral_complex_ofReal] + rfl + +end +end CriticalStrip + +end OAI diff --git a/lean/OAI/Combinatorics/StripMass/PfaffianMatrices.lean b/lean/OAI/Combinatorics/StripMass/PfaffianMatrices.lean new file mode 100644 index 0000000000000000000000000000000000000000..11e31fc62c15ce56fcd0000194f0c93cb6ca8372 --- /dev/null +++ b/lean/OAI/Combinatorics/StripMass/PfaffianMatrices.lean @@ -0,0 +1,432 @@ +import Mathlib +import OAI.Combinatorics.StripMass.Basic + +namespace OAI + +/-! Critical honeycomb strip paths, polynomial identities and crossing mass. -/ + + +namespace StripPfaffian +noncomputable section +open scoped BigOperators +open Polynomial + +abbrev Vec (n : ℕ) := Fin n → ℂ +abbrev Grassmann (n : ℕ) := ExteriorAlgebra ℂ (Vec n) + +def standardBasis (n : ℕ) : Module.Basis (Fin n) ℂ (Vec n) := Pi.basisFun ℂ (Fin n) +def generator (n : ℕ) (i : Fin n) : Grassmann n := + ExteriorAlgebra.ι ℂ (standardBasis n i) +def twoForm {n : ℕ} (A : Matrix (Fin n) (Fin n) ℂ) : Grassmann n := + ∑ i, ∑ j ∈ Finset.Ioi i, A i j • (generator n i * generator n j) +def pfaffian (n : ℕ) (A : Matrix (Fin n) (Fin n) ℂ) : ℂ := + ((standardBasis n).ExteriorAlgebra.repr ((twoForm A) ^ (n / 2))) Finset.univ / + (Nat.factorial (n / 2) : ℂ) + +def d : ℂ := (Real.cos (2 * (Real.pi / 8)) : ℝ) +def rho : ℂ := (1 / Real.sqrt (2 + Real.sqrt 2) : ℝ) +def D (a b : ℂ) : ℂ := a ^ 2 + b ^ 2 + 2 * d * a * b - d ^ 2 +def kernel (a b : ℂ) : ℂ := (a - b) * (a + b + rho) / D a b + +def pfSize (N : ℕ) : ℕ := 2 * ((N + 1) / 2) +def augmentedKernel (N : ℕ) (a : Fin N → ℂ) : Matrix (Fin (pfSize N)) (Fin (pfSize N)) ℂ := + fun i j => if hi : i.val < N then + if hj : j.val < N then kernel (a ⟨i.val, hi⟩) (a ⟨j.val, hj⟩) else 1 + else if j.val < N then -1 else 0 + +def p (N : ℕ) (a : Fin N → ℂ) : ℂ := + (∏ i, ∏ j ∈ Finset.Ioi i, D (a i) (a j) / (a i - a j)) * + pfaffian (pfSize N) (augmentedKernel N a) + + + +def topWedge (n : ℕ) : Grassmann n := ExteriorAlgebra.ιMulti ℂ n (standardBasis n) +def topCoord (n : ℕ) : Grassmann n →ₗ[ℂ] ℂ := + (standardBasis n).ExteriorAlgebra.coord Finset.univ + +lemma top_wedge_determinant (n : ℕ) (v : Fin n → Vec n) : + ExteriorAlgebra.ιMulti ℂ n v = (standardBasis n).det v • topWedge n := by + have hf : ExteriorAlgebra.ιMulti ℂ n (M := Vec n) = + ((standardBasis n).det).smulRight (topWedge n) := by + apply (standardBasis n).ext_alternating + intro i hi + let σ : Equiv.Perm (Fin n) := Equiv.ofBijective i (Finite.injective_iff_bijective.mp hi) + change ExteriorAlgebra.ιMulti ℂ n ((standardBasis n) ∘ σ) = + (((standardBasis n).det).smulRight (topWedge n)) ((standardBasis n) ∘ σ) + simp [AlternatingMap.map_perm, topWedge, Module.Basis.det_self] + exact DFunLike.congr_fun hf v + +lemma generator_mem (n : ℕ) (i : Fin n) : + generator n i ∈ (LinearMap.range (ExteriorAlgebra.ι ℂ : Vec n →ₗ[ℂ] Grassmann n)) := + LinearMap.mem_range_self _ _ + +lemma twoForm_mem {n : ℕ} (A : Matrix (Fin n) (Fin n) ℂ) : + twoForm A ∈ ExteriorAlgebra.exteriorPower ℂ 2 (Vec n) := by + unfold twoForm ExteriorAlgebra.exteriorPower + apply Submodule.sum_mem + intro i hi + apply Submodule.sum_mem + intro j hj + apply Submodule.smul_mem + simpa only [pow_two] using Submodule.mul_mem_mul (generator_mem n i) (generator_mem n j) + +lemma twoForm_pow_mem {n : ℕ} (A : Matrix (Fin n) (Fin n) ℂ) (m : ℕ) : + twoForm A ^ m ∈ ExteriorAlgebra.exteriorPower ℂ (2 * m) (Vec n) := by + convert Submodule.pow_mem_pow _ (twoForm_mem A) m using 1 + exact pow_mul _ 2 m + +lemma exteriorBasis_univ (n : ℕ) : + (standardBasis n).ExteriorAlgebra Finset.univ = topWedge n := by + rw [ExteriorAlgebra.basis_apply_ofCard _ (by simp : (Finset.univ : Finset (Fin n)).card = n)] + unfold ExteriorAlgebra.ιMulti_family topWedge + congr 1 + funext i + simp only [Function.comp_apply] + apply congrArg (standardBasis n) + rw [Set.powersetCard.ofFinEmbEquiv_symm_apply] + change Finset.univ.orderEmbOfFin (by simp) i = i + exact congr_fun (Finset.orderEmbOfFin_unique (by simp) + (fun x : Fin n => Finset.mem_univ x) (fun _ _ h => h)).symm i + +@[simp] lemma topCoord_topWedge (n : ℕ) : topCoord n (topWedge n) = 1 := by + rw [← exteriorBasis_univ] + simp [topCoord, Module.Basis.coord_apply] + +lemma topCoord_wedge (n : ℕ) (v : Fin n → Vec n) : + topCoord n (ExteriorAlgebra.ιMulti ℂ n v) = (standardBasis n).det v := by + rw [top_wedge_determinant, map_smul, topCoord_topWedge, smul_eq_mul, mul_one] + +lemma homogeneous_eq_coord_topWedge (n : ℕ) (x : Grassmann n) + (hx : x ∈ ExteriorAlgebra.exteriorPower ℂ n (Vec n)) : + x = topCoord n x • topWedge n := by + rw [← ExteriorAlgebra.ιMulti_span_fixedDegree] at hx + induction hx using Submodule.span_induction with + | mem v hv => + obtain ⟨v, rfl⟩ := hv + rw [topCoord_wedge, top_wedge_determinant] + | zero => simp + | add x y hx hy ihx ihy => + rw [map_add, add_smul, ← ihx, ← ihy] + | smul r x hx ih => + rw [map_smul, smul_eq_mul, ← smul_smul, ← ih] + +lemma topCoord_map (n : ℕ) (f : Vec n →ₗ[ℂ] Vec n) (x : Grassmann n) + (hx : x ∈ ExteriorAlgebra.exteriorPower ℂ n (Vec n)) : + topCoord n (ExteriorAlgebra.map f x) = f.det * topCoord n x := by + conv_lhs => rw [homogeneous_eq_coord_topWedge n x hx] + rw [map_smul, map_smul] + unfold topWedge + rw [ExteriorAlgebra.map_apply_ιMulti, topCoord_wedge] + have hd : (standardBasis n).det (f ∘ standardBasis n) = f.det := by + rw [Module.Basis.det_comp, Module.Basis.det_self, mul_one] + rw [hd, smul_eq_mul, mul_comm] + +lemma generator_anticomm (n : ℕ) (i j : Fin n) : + generator n i * generator n j = -(generator n j * generator n i) := + eq_neg_of_add_eq_zero_left (ExteriorAlgebra.ι_add_mul_swap _ _) + +lemma sum_symmetric_offdiag {n : ℕ} {E : Type*} [AddCommGroup E] + (F : Fin n → Fin n → E) (hF : ∀ i j, F i j = F j i) + (hzero : ∀ i, F i i = 0) : + ∑ i, ∑ j, F i j = 2 • (∑ i, ∑ j ∈ Finset.Ioi i, F i j) := by + have hij (i j : Fin n) : F i j = + (if i < j then F i j else 0) + (if j < i then F j i else 0) := by + rcases lt_trichotomy i j with h | rfl | h + · simp [h, not_lt_of_gt h] + · simp [hzero] + · simp [h, not_lt_of_gt h, hF i j] + have hsum (i : Fin n) : (∑ j, if i < j then F i j else 0) = + ∑ j ∈ Finset.Ioi i, F i j := by + rw [← Finset.sum_filter] + congr 1 + ext j + simp + calc + ∑ i, ∑ j, F i j = + (∑ i, ∑ j, if i < j then F i j else 0) + + (∑ i, ∑ j, if j < i then F j i else 0) := by + simp only [← Finset.sum_add_distrib] + exact Finset.sum_congr rfl fun i _ => Finset.sum_congr rfl fun j _ => hij i j + _ = (∑ i, ∑ j, if i < j then F i j else 0) + + (∑ j, ∑ i, if j < i then F j i else 0) := by + rw [Finset.sum_comm (f := fun i j => if j < i then F j i else 0)] + _ = 2 • (∑ i, ∑ j ∈ Finset.Ioi i, F i j) := by + simp only [hsum, two_nsmul] + +lemma twoForm_full {n : ℕ} (A : Matrix (Fin n) (Fin n) ℂ) + (hA : ∀ i j, A j i = -A i j) : + twoForm A = (1 / 2 : ℂ) • ∑ i, ∑ j, A i j • (generator n i * generator n j) := by + have hs := sum_symmetric_offdiag + (fun i j => A i j • (generator n i * generator n j)) + (fun i j => by rw [hA i j, generator_anticomm n j i, neg_smul, smul_neg, neg_neg]) + (fun i => by simp [generator]) + rw [hs] + change twoForm A = (1 / 2 : ℂ) • (2 • twoForm A) + rw [← Nat.cast_smul_eq_nsmul ℂ 2, smul_smul] + norm_num + +def permMap (n : ℕ) (σ : Equiv.Perm (Fin n)) : Vec n →ₗ[ℂ] Vec n := + (standardBasis n).constr ℂ (fun i => standardBasis n (σ i)) + +@[simp] lemma permMap_basis (n : ℕ) (σ : Equiv.Perm (Fin n)) (i : Fin n) : + permMap n σ (standardBasis n i) = standardBasis n (σ i) := by + simp [permMap] + +@[simp] lemma permMap_generator (n : ℕ) (σ : Equiv.Perm (Fin n)) (i : Fin n) : + ExteriorAlgebra.map (permMap n σ) (generator n i) = generator n (σ i) := by + simp [generator] + +lemma permMap_det (n : ℕ) (σ : Equiv.Perm (Fin n)) : + (permMap n σ).det = (Equiv.Perm.sign σ : ℂ) := by + have he : permMap n σ ∘ standardBasis n = standardBasis n ∘ σ := by + funext i + exact permMap_basis n σ i + have hd := Module.Basis.det_comp (standardBasis n) (permMap n σ) (standardBasis n) + rw [he, AlternatingMap.map_perm, Module.Basis.det_self, mul_one] at hd + simpa [Units.smul_def, ← Int.cast_smul_eq_zsmul ℂ, smul_eq_mul] using hd.symm + +lemma twoForm_perm {n : ℕ} (A : Matrix (Fin n) (Fin n) ℂ) + (hA : ∀ i j, A j i = -A i j) (σ : Equiv.Perm (Fin n)) : + ExteriorAlgebra.map (permMap n σ) (twoForm A) = + twoForm (fun i j => A (σ.symm i) (σ.symm j)) := by + rw [twoForm_full A hA, twoForm_full _ (fun i j => hA _ _)] + simp only [map_smul, map_sum, map_mul, permMap_generator] + congr 1 + apply Fintype.sum_equiv σ + intro i + simp only [Equiv.symm_apply_apply] + apply Fintype.sum_equiv σ + intro j + simp + +lemma pfaffian_perm (n : ℕ) (hn : Even n) (A : Matrix (Fin n) (Fin n) ℂ) + (hA : ∀ i j, A j i = -A i j) (σ : Equiv.Perm (Fin n)) : + pfaffian n (fun i j => A (σ.symm i) (σ.symm j)) = + (Equiv.Perm.sign σ : ℂ) * pfaffian n A := by + have hdeg : 2 * (n / 2) = n := Nat.mul_div_cancel' (even_iff_two_dvd.mp hn) + have hhom : twoForm A ^ (n / 2) ∈ ExteriorAlgebra.exteriorPower ℂ n (Vec n) := + by simpa only [hdeg] using twoForm_pow_mem A (n / 2) + change topCoord n (twoForm _ ^ (n / 2)) / _ = + (Equiv.Perm.sign σ : ℂ) * (topCoord n (twoForm A ^ (n / 2)) / _) + rw [← twoForm_perm A hA σ, ← map_pow, topCoord_map n _ _ hhom, permMap_det] + ring + +lemma pfaffian_duplicate (n : ℕ) (hn : Even n) (A : Matrix (Fin n) (Fin n) ℂ) + (hA : ∀ i j, A j i = -A i j) (i j : Fin n) (hij : i ≠ j) + (hrow : ∀ k, A i k = A j k) : pfaffian n A = 0 := by + let σ : Equiv.Perm (Fin n) := Equiv.swap i j + have hs_left (x y : Fin n) : A (σ x) y = A x y := by + by_cases hxi : x = i + · subst x + simpa [σ] using (hrow y).symm + by_cases hxj : x = j + · subst x + simpa [σ] using hrow y + simp [σ, Equiv.swap_apply_of_ne_of_ne hxi hxj] + have hs_right (x y : Fin n) : A x (σ y) = A x y := by + rw [hA, hs_left, hA, neg_neg] + have he : (fun x y => A (σ.symm x) (σ.symm y)) = A := by + funext x y + change A (Equiv.swap i j x) (Equiv.swap i j y) = A x y + rw [show Equiv.swap i j = σ from rfl, hs_left, hs_right] + have hp := pfaffian_perm n hn A hA σ + rw [he] at hp + have hsign : (Equiv.Perm.sign σ : ℂ) = -1 := by + simp [σ, Equiv.Perm.sign_swap hij] + rw [hsign, neg_one_mul] at hp + linear_combination hp / 2 + +lemma wedge_anticomm {n : ℕ} (u v : Vec n) : + ExteriorAlgebra.ι ℂ u * ExteriorAlgebra.ι ℂ v = + -(ExteriorAlgebra.ι ℂ v * ExteriorAlgebra.ι ℂ u) := + eq_neg_of_add_eq_zero_left (ExteriorAlgebra.ι_add_mul_swap _ _) + +lemma wedge_commutes {n : ℕ} (u v : Vec n) (x : Grassmann n) : + Commute (ExteriorAlgebra.ι ℂ u * ExteriorAlgebra.ι ℂ v) x := by + induction x using ExteriorAlgebra.induction with + | algebraMap r => exact (Algebra.commutes r _).symm + | ι w => + change (_ * _) * _ = _ * (_ * _) + calc + _ = ExteriorAlgebra.ι ℂ u * (ExteriorAlgebra.ι ℂ v * ExteriorAlgebra.ι ℂ w) := + mul_assoc _ _ _ + _ = -(ExteriorAlgebra.ι ℂ u * (ExteriorAlgebra.ι ℂ w * ExteriorAlgebra.ι ℂ v)) := by + rw [wedge_anticomm v w, mul_neg] + _ = -((ExteriorAlgebra.ι ℂ u * ExteriorAlgebra.ι ℂ w) * ExteriorAlgebra.ι ℂ v) := by + rw [mul_assoc] + _ = (ExteriorAlgebra.ι ℂ w * ExteriorAlgebra.ι ℂ u) * ExteriorAlgebra.ι ℂ v := by + rw [wedge_anticomm u w, neg_mul, neg_neg] + _ = _ := mul_assoc _ _ _ + | mul a b ha hb => exact ha.mul_right hb + | add a b ha hb => exact ha.add_right hb + +lemma twoForm_commutes {n : ℕ} (A : Matrix (Fin n) (Fin n) ℂ) (x : Grassmann n) : + Commute (twoForm A) x := by + unfold twoForm + apply Commute.sum_left + intro i hi + apply Commute.sum_left + intro j hj + exact (wedge_commutes (standardBasis n i) (standardBasis n j) x).smul_left (A i j) + +lemma wedge_sq_zero {n : ℕ} (u v : Vec n) : + (ExteriorAlgebra.ι ℂ u * ExteriorAlgebra.ι ℂ v) ^ 2 = 0 := by + rw [pow_two, mul_assoc, ← mul_assoc (ExteriorAlgebra.ι ℂ v), wedge_anticomm v u, + neg_mul, mul_neg, ← mul_assoc, ← mul_assoc, ExteriorAlgebra.ι_sq_zero] + simp + +lemma twoForm_add {n : ℕ} (A B : Matrix (Fin n) (Fin n) ℂ) : + twoForm (A + B) = twoForm A + twoForm B := by + simp [twoForm, add_smul, Finset.sum_add_distrib] + +lemma twoForm_smul {n : ℕ} (t : ℂ) (A : Matrix (Fin n) (Fin n) ℂ) : + twoForm (t • A) = t • twoForm A := by + simp [twoForm, smul_smul, Finset.smul_sum] + +lemma generator_expansion (n : ℕ) (u : Vec n) : + (∑ i, u i • generator n i) = ExteriorAlgebra.ι ℂ u := by + have h := congrArg (ExteriorAlgebra.ι ℂ) ((standardBasis n).sum_repr u) + simpa [standardBasis, generator, map_sum, map_smul] using h + +def rankTwo {n : ℕ} (u v : Vec n) : Matrix (Fin n) (Fin n) ℂ := + fun i j => u i * v j - v i * u j + +lemma rankTwo_skew {n : ℕ} (u v : Vec n) (i j : Fin n) : + rankTwo u v j i = -rankTwo u v i j := by + unfold rankTwo + ring + +lemma twoForm_rankTwo {n : ℕ} (u v : Vec n) : + twoForm (rankTwo u v) = ExteriorAlgebra.ι ℂ u * ExteriorAlgebra.ι ℂ v := by + rw [twoForm_full _ (rankTwo_skew u v)] + simp only [rankTwo, sub_smul, Finset.sum_sub_distrib, + ← smul_mul_smul_comm, ← Finset.sum_mul_sum, generator_expansion] + rw [wedge_anticomm v u, sub_neg_eq_add, ← two_smul ℂ] + rw [smul_smul] + norm_num + +lemma pow_add_sq_zero {E : Type*} [Ring E] [Algebra ℂ E] (a b : E) + (hab : Commute a b) (hb : b ^ 2 = 0) (m : ℕ) : + (a + b) ^ (m + 1) = a ^ (m + 1) + (m + 1 : ℂ) • (a ^ m * b) := by + induction m with + | zero => simp + | succ m ih => + rw [pow_succ (a + b), ih, add_mul, mul_add, mul_add, + smul_mul_assoc, smul_mul_assoc] + have hba : a ^ m * b * a = a ^ (m + 1) * b := by + rw [mul_assoc, hab.eq.symm, ← mul_assoc, ← pow_succ] + have hbb : a ^ m * b * b = 0 := by rw [mul_assoc, ← pow_two, hb, mul_zero] + rw [hba, hbb, smul_zero, add_zero, ← pow_succ] + simp only [Nat.cast_add, Nat.cast_one] + module + +lemma high_degree_zero {n k : ℕ} (hk : n < k) (x : Grassmann n) + (hx : x ∈ ExteriorAlgebra.exteriorPower ℂ k (Vec n)) : x = 0 := by + rw [← ExteriorAlgebra.ιMulti_span_fixedDegree] at hx + induction hx using Submodule.span_induction with + | mem v hv => + obtain ⟨v, rfl⟩ := hv + apply AlternatingMap.map_linearDependent + intro hv + have h := hv.fintype_card_le_finrank + simp only [Fintype.card_fin, Module.finrank_pi] at h + omega + | zero => rfl + | add x y hx hy ihx ihy => simp [ihx, ihy] + | smul r x hx ih => simp [ih] + +def embedMap (n : ℕ) : Vec n →ₗ[ℂ] Vec (n + 1) := + (standardBasis n).constr ℂ (fun i => standardBasis (n + 1) i.castSucc) + +@[simp] lemma embedMap_basis (n : ℕ) (i : Fin n) : + embedMap n (standardBasis n i) = standardBasis (n + 1) i.castSucc := by + simp [embedMap] + +@[simp] lemma embedMap_generator (n : ℕ) (i : Fin n) : + ExteriorAlgebra.map (embedMap n) (generator n i) = generator (n + 1) i.castSucc := by + simp [generator] + +lemma embedMap_apply (n : ℕ) (u : Vec n) : embedMap n u = Fin.snoc u 0 := by + conv_lhs => rw [← (standardBasis n).sum_repr u, map_sum] + simp only [map_smul, embedMap_basis] + ext i + refine Fin.lastCases ?_ (fun j => ?_) i + · simp [standardBasis, Pi.basisFun_apply] + · simp [standardBasis, Pi.basisFun_apply, Pi.single_apply] + +def border {n : ℕ} (A : Matrix (Fin n) (Fin n) ℂ) (u : Vec n) : + Matrix (Fin (n + 1)) (Fin (n + 1)) ℂ := + fun i j => Fin.lastCases (Fin.lastCases 0 (fun j => -u j) j) + (fun i => Fin.lastCases (u i) (fun j => A i j) j) i + +@[simp] lemma border_old_old {n : ℕ} (A : Matrix (Fin n) (Fin n) ℂ) (u : Vec n) (i j : Fin n) : + border A u i.castSucc j.castSucc = A i j := by simp [border] +@[simp] lemma border_old_last {n : ℕ} (A : Matrix (Fin n) (Fin n) ℂ) (u : Vec n) (i : Fin n) : + border A u i.castSucc (Fin.last n) = u i := by simp [border] +@[simp] lemma border_last_old {n : ℕ} (A : Matrix (Fin n) (Fin n) ℂ) (u : Vec n) (i : Fin n) : + border A u (Fin.last n) i.castSucc = -u i := by simp [border] +@[simp] lemma border_last_last {n : ℕ} (A : Matrix (Fin n) (Fin n) ℂ) (u : Vec n) : + border A u (Fin.last n) (Fin.last n) = 0 := by simp [border] + +lemma border_skew {n : ℕ} (A : Matrix (Fin n) (Fin n) ℂ) + (hA : ∀ i j, A j i = -A i j) (u : Vec n) (i j : Fin (n + 1)) : + border A u j i = -border A u i j := by + refine Fin.lastCases ?_ (fun i => ?_) i <;> + refine Fin.lastCases ?_ (fun j => ?_) j <;> + simp only [border_last_last, border_last_old, border_old_last, border_old_old, + neg_zero, neg_neg] + exact hA _ _ + +lemma twoForm_border {n : ℕ} (A : Matrix (Fin n) (Fin n) ℂ) + (hA : ∀ i j, A j i = -A i j) (u : Vec n) : + twoForm (border A u) = ExteriorAlgebra.map (embedMap n) (twoForm A) + + ExteriorAlgebra.ι ℂ (embedMap n u) * generator (n + 1) (Fin.last n) := by + rw [twoForm_full _ (border_skew A hA u), twoForm_full A hA] + simp only [map_smul, map_sum, map_mul, embedMap_generator] + rw [Fin.sum_univ_castSucc] + simp only [Fin.sum_univ_castSucc, border_old_old, border_old_last, + border_last_old, border_last_last, zero_smul, add_zero, Finset.sum_add_distrib] + have hu : (∑ i : Fin n, u i • generator (n + 1) i.castSucc) = + ExteriorAlgebra.ι ℂ (embedMap n u) := by + have h := congrArg (ExteriorAlgebra.map (embedMap n)) (generator_expansion n u) + simpa using h + have hp : (∑ i : Fin n, u i • (generator (n + 1) i.castSucc * generator (n + 1) (Fin.last n))) = + ExteriorAlgebra.ι ℂ (embedMap n u) * generator (n + 1) (Fin.last n) := by + rw [← hu, Finset.sum_mul] + simp only [smul_mul_assoc] + have hm : (∑ i : Fin n, -u i • (generator (n + 1) (Fin.last n) * generator (n + 1) i.castSucc)) = + ExteriorAlgebra.ι ℂ (embedMap n u) * generator (n + 1) (Fin.last n) := by + rw [← hp] + apply Finset.sum_congr rfl + intro i hi + rw [generator_anticomm (n + 1) (Fin.last n), neg_smul, smul_neg, neg_neg] + rw [hp, hm] + module + +lemma topWedge_snoc (n : ℕ) : + topWedge (n + 1) = ExteriorAlgebra.map (embedMap n) (topWedge n) * + generator (n + 1) (Fin.last n) := by + unfold topWedge + rw [ExteriorAlgebra.map_apply_ιMulti] + simp only [ExteriorAlgebra.ιMulti_apply] + rw [List.ofFn_succ', List.prod_concat] + simp only [Function.comp_apply, embedMap_basis, generator] + +lemma topCoord_embed_mul_last {n : ℕ} (x : Grassmann n) + (hx : x ∈ ExteriorAlgebra.exteriorPower ℂ n (Vec n)) : + topCoord (n + 1) (ExteriorAlgebra.map (embedMap n) x * generator (n + 1) (Fin.last n)) = + topCoord n x := by + conv_lhs => rw [homogeneous_eq_coord_topWedge n x hx] + rw [map_smul, smul_mul_assoc, ← topWedge_snoc, + map_smul, topCoord_topWedge, smul_eq_mul, mul_one] + +def borderLinear {n : ℕ} (A : Matrix (Fin n) (Fin n) ℂ) : Vec n →ₗ[ℂ] ℂ where + toFun u := topCoord (n + 1) (ExteriorAlgebra.map (embedMap n) (twoForm A) ^ (n / 2) * + (ExteriorAlgebra.ι ℂ (embedMap n u) * generator (n + 1) (Fin.last n))) / (n / 2).factorial + map_add' u v := by simp [mul_add, add_mul, add_div] + map_smul' t u := by simp [smul_eq_mul, mul_div_assoc] + +end +end StripPfaffian + +end OAI diff --git a/lean/OAI/Combinatorics/StripMass/PfaffianRecursion.lean b/lean/OAI/Combinatorics/StripMass/PfaffianRecursion.lean new file mode 100644 index 0000000000000000000000000000000000000000..038c5339bc25f1ee3698d594a71994998903c3b7 --- /dev/null +++ b/lean/OAI/Combinatorics/StripMass/PfaffianRecursion.lean @@ -0,0 +1,444 @@ +import Mathlib +import OAI.Combinatorics.StripMass.PfaffianMatrices + +namespace OAI + +/-! Critical honeycomb strip paths, polynomial identities and crossing mass. -/ + + +namespace StripPfaffian +noncomputable section +open scoped BigOperators +open Polynomial +lemma pfaffian_border {n : ℕ} (hn : Odd n) (A : Matrix (Fin n) (Fin n) ℂ) + (hA : ∀ i j, A j i = -A i j) (u : Vec n) : + pfaffian (n + 1) (border A u) = borderLinear A u := by + have hm : (n + 1) / 2 = n / 2 + 1 := by + obtain ⟨k, hk⟩ := hn + omega + have hz : twoForm A ^ (n / 2 + 1) = 0 := + high_degree_zero (by omega) _ (twoForm_pow_mem A (n / 2 + 1)) + have hcomm : Commute (ExteriorAlgebra.map (embedMap n) (twoForm A)) + (ExteriorAlgebra.ι ℂ (embedMap n u) * generator (n + 1) (Fin.last n)) := + (wedge_commutes _ _ _).symm + unfold pfaffian + change topCoord (n + 1) _ / _ = _ + rw [twoForm_border A hA, hm, pow_add_sq_zero _ _ hcomm (wedge_sq_zero _ _) (n / 2), + ← map_pow, hz, map_zero, zero_add, map_smul, smul_eq_mul] + simp only [Nat.factorial_succ, Nat.cast_mul, Nat.cast_add, Nat.cast_one] + have hm0 : (↑(n / 2) : ℂ) + 1 ≠ 0 := by exact_mod_cast Nat.succ_ne_zero (n / 2) + rw [mul_div_mul_left _ _ hm0] + rfl + +lemma topCoord_embed_twice {n : ℕ} (x : Grassmann n) + (hx : x ∈ ExteriorAlgebra.exteriorPower ℂ n (Vec n)) : + topCoord (n + 2) + (ExteriorAlgebra.map (embedMap (n + 1)) (ExteriorAlgebra.map (embedMap n) x) * + (generator (n + 2) (Fin.last n).castSucc * generator (n + 2) (Fin.last (n + 1)))) = + topCoord n x := by + have ht : ExteriorAlgebra.map (embedMap (n + 1)) + (ExteriorAlgebra.map (embedMap n) (topWedge n)) * + (generator (n + 2) (Fin.last n).castSucc * generator (n + 2) (Fin.last (n + 1))) = + topWedge (n + 2) := by + rw [← embedMap_generator (n + 1) (Fin.last n), ← mul_assoc, ← map_mul, + ← topWedge_snoc, ← topWedge_snoc] + conv_lhs => rw [homogeneous_eq_coord_topWedge n x hx] + rw [map_smul, map_smul, smul_mul_assoc, ht, map_smul, topCoord_topWedge, smul_eq_mul, mul_one] + +lemma pfaffian_block_pair {n : ℕ} (hn : Even n) (A : Matrix (Fin n) (Fin n) ℂ) + (hA : ∀ i j, A j i = -A i j) : + pfaffian (n + 2) (border (border A 0) (standardBasis (n + 1) (Fin.last n))) = + pfaffian n A := by + have hodd : Odd (n + 1) := hn.add_one + have hm : (n + 1) / 2 = n / 2 := by obtain ⟨k, hk⟩ := hn; omega + have hdeg : 2 * (n / 2) = n := Nat.mul_div_cancel' (even_iff_two_dvd.mp hn) + have hhom : twoForm A ^ (n / 2) ∈ ExteriorAlgebra.exteriorPower ℂ n (Vec n) := by + simpa only [hdeg] using twoForm_pow_mem A (n / 2) + rw [pfaffian_border hodd _ (border_skew A hA 0)] + change topCoord (n + 2) _ / _ = _ + rw [twoForm_border A hA 0] + simp only [map_zero, zero_mul, add_zero, embedMap_basis, hm, ← map_pow] + change topCoord (n + 2) + (ExteriorAlgebra.map (embedMap (n + 1)) (ExteriorAlgebra.map (embedMap n) (twoForm A ^ (n / 2))) * + (generator (n + 2) (Fin.last n).castSucc * generator (n + 2) (Fin.last (n + 1)))) / _ = _ + rw [topCoord_embed_twice _ hhom] + rfl + +lemma borderLinear_column {n : ℕ} (hn : Odd n) (A : Matrix (Fin n) (Fin n) ℂ) + (hA : ∀ i j, A j i = -A i j) (j : Fin n) : + borderLinear A (fun i => A i j) = 0 := by + rw [← pfaffian_border hn A hA] + apply pfaffian_duplicate (n + 1) hn.add_one _ (border_skew A hA _) + j.castSucc (Fin.last n) (Fin.castSucc_ne_last j) + intro k + refine Fin.lastCases ?_ (fun k => ?_) k + · simp only [border_old_last, border_last_last] + have hj := hA j j + linear_combination hj / 2 + · simp only [border_old_old, border_last_old] + exact hA k j + +lemma basis_last (n : ℕ) : standardBasis (n + 1) (Fin.last n) = Fin.snoc (fun _ => 0) 1 := by + ext i + refine Fin.lastCases ?_ (fun j => ?_) i <;> simp [standardBasis, Pi.basisFun_apply] + +lemma pfaffian_zero_row (n : ℕ) (hn : Even n) (A : Matrix (Fin n) (Fin n) ℂ) + (hA : ∀ i j, A j i = -A i j) (i : Fin n) (hrow : ∀ j, A i j = 0) : + pfaffian n A = 0 := by + let f : Vec n →ₗ[ℂ] Vec n := + (standardBasis n).constr ℂ (fun j => if j = i then 0 else standardBasis n j) + have hf (j : Fin n) : f (standardBasis n j) = if j = i then 0 else standardBasis n j := by + exact (standardBasis n).constr_basis ℂ _ j + have hdet : f.det = 0 := by + have hd := Module.Basis.det_comp (standardBasis n) f (standardBasis n) + rw [Module.Basis.det_self, mul_one] at hd + rw [← hd] + exact (standardBasis n).det.map_coord_zero i (by simp [hf]) + have hcol (j : Fin n) : A j i = 0 := by rw [hA, hrow, neg_zero] + have hform : ExteriorAlgebra.map f (twoForm A) = twoForm A := by + unfold twoForm + simp only [map_sum, map_smul, map_mul, generator, ExteriorAlgebra.map_apply_ι, hf] + apply Finset.sum_congr rfl + intro j hj + apply Finset.sum_congr rfl + intro k hk + by_cases hji : j = i + · subst j + simp [hrow] + by_cases hki : k = i + · subst k + simp [hcol] + simp [hji, hki] + have hdeg : 2 * (n / 2) = n := Nat.mul_div_cancel' (even_iff_two_dvd.mp hn) + have hhom : twoForm A ^ (n / 2) ∈ ExteriorAlgebra.exteriorPower ℂ n (Vec n) := by + simpa only [hdeg] using twoForm_pow_mem A (n / 2) + have htop := topCoord_map n f (twoForm A ^ (n / 2)) hhom + rw [map_pow, hform, hdet, zero_mul] at htop + change topCoord n (twoForm A ^ (n / 2)) / _ = 0 + rw [htop, zero_div] + +lemma pfaffian_block_extra {n : ℕ} (hn : Even n) (A : Matrix (Fin n) (Fin n) ℂ) + (hA : ∀ i j, A j i = -A i j) (u : Vec n) (t : ℂ) : + pfaffian (n + 2) (border (border A 0) (Fin.snoc u t)) = t * pfaffian n A := by + have hodd : Odd (n + 1) := hn.add_one + have he : Fin.snoc u t = Fin.snoc u 0 + t • standardBasis (n + 1) (Fin.last n) := by + ext i + refine Fin.lastCases ?_ (fun j => ?_) i <;> simp [basis_last] + have hz : borderLinear (border A 0) (Fin.snoc u 0) = 0 := by + rw [← pfaffian_border hodd _ (border_skew A hA 0)] + apply pfaffian_zero_row (n + 2) (hodd.add_one) _ + (border_skew _ (border_skew A hA 0) _) (Fin.last n).castSucc + intro j + refine Fin.lastCases ?_ (fun j => ?_) j + · simp + · refine Fin.lastCases ?_ (fun j => ?_) j <;> simp + rw [pfaffian_border hodd _ (border_skew A hA 0), he, map_add, map_smul, hz, zero_add] + rw [← pfaffian_border hodd _ (border_skew A hA 0), pfaffian_block_pair hn A hA, smul_eq_mul] + +def lastSwap (n : ℕ) : Equiv.Perm (Fin (n + 2)) := + Equiv.swap (Fin.last n).castSucc (Fin.last (n + 1)) + +@[simp] lemma lastSwap_old (n : ℕ) (i : Fin n) : + lastSwap n i.castSucc.castSucc = i.castSucc.castSucc := by + apply Equiv.swap_apply_of_ne_of_ne + · intro h + exact Fin.castSucc_ne_last i (Fin.castSucc_injective _ h) + · exact Fin.castSucc_ne_last _ + +@[simp] lemma lastSwap_middle (n : ℕ) : lastSwap n (Fin.last n).castSucc = Fin.last (n + 1) := by + simp [lastSwap] +@[simp] lemma lastSwap_last (n : ℕ) : lastSwap n (Fin.last (n + 1)) = (Fin.last n).castSucc := by + simp [lastSwap] +@[simp] lemma lastSwap_symm (n : ℕ) : (lastSwap n).symm = lastSwap n := rfl + +lemma border_swap_matrix {n : ℕ} (A : Matrix (Fin n) (Fin n) ℂ) (u v : Vec n) (t : ℂ) : + (fun i j => border (border A u) (Fin.snoc v t) ((lastSwap n).symm i) ((lastSwap n).symm j)) = + border (border A v) (Fin.snoc u (-t)) := by + funext i j + simp only [lastSwap_symm] + refine Fin.lastCases ?_ (fun i => ?_) i <;> + refine Fin.lastCases ?_ (fun j => ?_) j + · simp + · refine Fin.lastCases ?_ (fun j => ?_) j <;> simp + · refine Fin.lastCases ?_ (fun i => ?_) i <;> simp + · refine Fin.lastCases ?_ (fun i => ?_) i <;> + refine Fin.lastCases ?_ (fun j => ?_) j <;> simp + +lemma pfaffian_border_swap {n : ℕ} (hn : Even n) (A : Matrix (Fin n) (Fin n) ℂ) + (hA : ∀ i j, A j i = -A i j) (u v : Vec n) (t : ℂ) : + pfaffian (n + 2) (border (border A v) (Fin.snoc u (-t))) = + -pfaffian (n + 2) (border (border A u) (Fin.snoc v t)) := by + have hp := pfaffian_perm (n + 2) (hn.add (by decide)) + (border (border A u) (Fin.snoc v t)) (border_skew _ (border_skew A hA u) _) (lastSwap n) + rw [border_swap_matrix] at hp + simpa [lastSwap, Equiv.Perm.sign_swap (Fin.castSucc_ne_last (Fin.last n))] using hp + +lemma pfaffian_aug_pair {n : ℕ} (hn : Even n) (A : Matrix (Fin n) (Fin n) ℂ) + (hA : ∀ i j, A j i = -A i j) (u : Vec n) : + pfaffian (n + 2) (border (border A u) (standardBasis (n + 1) (Fin.last n))) = + pfaffian n A := by + rw [basis_last] + have hp := pfaffian_border_swap hn A hA u 0 1 + rw [pfaffian_block_extra hn A hA, neg_one_mul] at hp + exact neg_injective hp.symm + +lemma borderLinear_aug_ones {n : ℕ} (hn : Even n) (A : Matrix (Fin n) (Fin n) ℂ) + (hA : ∀ i j, A j i = -A i j) : + borderLinear (border A (fun _ => 1)) (fun _ => -1) = -pfaffian n A := by + have hodd : Odd (n + 1) := hn.add_one + have hz := borderLinear_column hodd (border A (fun _ => 1)) + (border_skew A hA _) (Fin.last n) + have he : (fun _ : Fin (n + 1) => (-1 : ℂ)) = + -(fun i => border A (fun _ => 1) i (Fin.last n)) - standardBasis (n + 1) (Fin.last n) := by + ext i + refine Fin.lastCases ?_ (fun j => ?_) i <;> simp [basis_last] + rw [he, map_sub, map_neg, hz, neg_zero, zero_sub] + congr 1 + rw [← pfaffian_border hodd _ (border_skew A hA _), pfaffian_aug_pair hn A hA] + +lemma D_symm (a b : ℂ) : D b a = D a b := by unfold D; ring +lemma kernel_skew (a b : ℂ) : kernel b a = -kernel a b := by + unfold kernel + rw [D_symm] + ring +@[simp] lemma kernel_self (a : ℂ) : kernel a a = 0 := by simp [kernel] + +def kernelMatrix (N : ℕ) (a : Fin N → ℂ) : Matrix (Fin N) (Fin N) ℂ := + fun i j => kernel (a i) (a j) + +lemma kernelMatrix_skew (N : ℕ) (a : Fin N → ℂ) (i j : Fin N) : + kernelMatrix N a j i = -kernelMatrix N a i j := kernel_skew _ _ + +lemma kernelMatrix_snoc (N : ℕ) (a : Fin N → ℂ) (z : ℂ) : + kernelMatrix (N + 1) (Fin.snoc a z) = + border (kernelMatrix N a) (fun i => kernel (a i) z) := by + funext i j + refine Fin.lastCases ?_ (fun i => ?_) i <;> + refine Fin.lastCases ?_ (fun j => ?_) j <;> simp [kernelMatrix] + exact kernel_skew _ _ + +lemma augmentedKernel_skew (N : ℕ) (a : Fin N → ℂ) (i j : Fin (pfSize N)) : + augmentedKernel N a j i = -augmentedKernel N a i j := by + by_cases hi : i.val < N <;> by_cases hj : j.val < N <;> + simp only [augmentedKernel, hi, hj, dite_true, dite_false, ite_true, ite_false, neg_neg, neg_zero] + exact kernel_skew _ _ + +def actualPf (N : ℕ) (a : Fin N → ℂ) : ℂ := pfaffian (pfSize N) (augmentedKernel N a) + +lemma pfaffian_cast {m n : ℕ} (h : m = n) (A : Matrix (Fin m) (Fin m) ℂ) : + pfaffian m A = pfaffian n (fun i j => A (Fin.cast h.symm i) (Fin.cast h.symm j)) := by + subst n + rfl + +lemma actualPf_even {N : ℕ} (hN : Even N) (a : Fin N → ℂ) : + actualPf N a = pfaffian N (kernelMatrix N a) := by + have hs : pfSize N = N := by obtain ⟨k, hk⟩ := hN; unfold pfSize; omega + unfold actualPf + rw [pfaffian_cast hs] + congr 1 + funext i j + simp [augmentedKernel, kernelMatrix, i.isLt, j.isLt] + +lemma actualPf_odd {N : ℕ} (hN : Odd N) (a : Fin N → ℂ) : + actualPf N a = pfaffian (N + 1) (border (kernelMatrix N a) (fun _ => 1)) := by + have hs : pfSize N = N + 1 := by obtain ⟨k, hk⟩ := hN; unfold pfSize; omega + unfold actualPf + rw [pfaffian_cast hs] + congr 1 + funext i j + refine Fin.lastCases ?_ (fun i => ?_) i <;> + refine Fin.lastCases ?_ (fun j => ?_) j <;> + simp [augmentedKernel, kernelMatrix] + +lemma actualPf_duplicate {N : ℕ} (a : Fin N → ℂ) (i j : Fin N) + (hij : i ≠ j) (ha : a i = a j) : actualPf N a = 0 := by + have hsize : N ≤ pfSize N := by unfold pfSize; omega + let i' : Fin (pfSize N) := ⟨i.val, lt_of_lt_of_le i.isLt hsize⟩ + let j' : Fin (pfSize N) := ⟨j.val, lt_of_lt_of_le j.isLt hsize⟩ + apply pfaffian_duplicate (pfSize N) (even_two_mul _) _ (augmentedKernel_skew N a) i' j' + · intro h + apply hij + apply Fin.ext + exact congrArg (fun k : Fin (pfSize N) => k.val) h + · intro k + simp only [augmentedKernel, i', j', i.isLt, j.isLt, dite_true] + by_cases hk : k.val < N <;> simp [hk, ha] + +def restrictMap (n : ℕ) : Vec (n + 1) →ₗ[ℂ] Vec n where + toFun u i := u i.castSucc + map_add' _ _ := rfl + map_smul' _ _ := rfl + +def flipLastMap (n : ℕ) : Vec (n + 1) →ₗ[ℂ] Vec (n + 1) where + toFun u := Fin.snoc (fun i => u i.castSucc) (-u (Fin.last n)) + map_add' u v := by ext i; refine Fin.lastCases ?_ (fun j => ?_) i <;> simp [add_comm] + map_smul' t u := by ext i; refine Fin.lastCases ?_ (fun j => ?_) i <;> simp [mul_neg] + +@[simp] lemma restrictMap_snoc (n : ℕ) (u : Vec n) (t : ℂ) : + restrictMap n (Fin.snoc u t) = u := by ext i; simp [restrictMap] +@[simp] lemma flipLastMap_snoc (n : ℕ) (u : Vec n) (t : ℂ) : + flipLastMap n (Fin.snoc u t) = Fin.snoc u (-t) := by simp [flipLastMap] + +def incrementLinear (N : ℕ) (a : Fin N → ℂ) : Vec (N + 1) →ₗ[ℂ] ℂ := by + classical + exact if Odd N then (borderLinear (kernelMatrix N a)).comp (restrictMap N) + else -((borderLinear (border (kernelMatrix N a) (fun _ => 1))).comp (flipLastMap N)) + +lemma incrementLinear_eval (N : ℕ) (a : Fin N → ℂ) (z : ℂ) : + incrementLinear N a (Fin.snoc (fun i => kernel (a i) z) 1) = + actualPf (N + 1) (Fin.snoc a z) := by + by_cases hodd : Odd N + · rw [incrementLinear, ite_eq_left hodd, LinearMap.comp_apply, restrictMap_snoc, + actualPf_even hodd.add_one, kernelMatrix_snoc, + pfaffian_border hodd _ (kernelMatrix_skew N a)] + · have heven : Even N := Nat.not_odd_iff_even.mp hodd + rw [incrementLinear, ite_eq_right hodd, LinearMap.neg_apply, LinearMap.comp_apply, flipLastMap_snoc, + actualPf_odd heven.add_one, kernelMatrix_snoc] + have hone : (fun _ : Fin (N + 1) => (1 : ℂ)) = Fin.snoc (fun _ => 1) 1 := by + ext i + refine Fin.lastCases ?_ (fun j => ?_) i <;> simp + rw [hone, ← pfaffian_border heven.add_one _ (border_skew _ (kernelMatrix_skew N a) _), + pfaffian_border_swap heven _ (kernelMatrix_skew N a), neg_neg] + +lemma incrementLinear_leading (N : ℕ) (a : Fin N → ℂ) : + incrementLinear N a (Fin.snoc (fun _ => -1) 1) = (-1 : ℂ) ^ N * actualPf N a := by + by_cases hodd : Odd N + · rw [incrementLinear, ite_eq_left hodd, LinearMap.comp_apply, restrictMap_snoc, + actualPf_odd hodd, pfaffian_border hodd _ (kernelMatrix_skew N a), hodd.neg_one_pow] + have he : (fun _ : Fin N => (-1 : ℂ)) = -(fun _ => 1) := rfl + rw [he, map_neg, neg_one_mul] + · have heven : Even N := Nat.not_odd_iff_even.mp hodd + rw [incrementLinear, ite_eq_right hodd, LinearMap.neg_apply, LinearMap.comp_apply, flipLastMap_snoc, + heven.neg_one_pow, one_mul, actualPf_even heven] + have he : (Fin.snoc (fun _ : Fin N => (-1 : ℂ)) (-1 : ℂ) : Vec (N + 1)) = + (fun _ : Fin (N + 1) => (-1 : ℂ)) := by + ext i + refine Fin.lastCases ?_ (fun j => ?_) i <;> simp + rw [he, borderLinear_aug_ones heven _ (kernelMatrix_skew N a), neg_neg] + +def polyLift {n : ℕ} (L : Vec n →ₗ[ℂ] ℂ) (f : Fin n → Polynomial ℂ) : Polynomial ℂ := + ∑ i, C (L (standardBasis n i)) * f i + +lemma linear_basis_sum {n : ℕ} (L : Vec n →ₗ[ℂ] ℂ) (v : Vec n) : + (∑ i, L (standardBasis n i) * v i) = L v := by + have h := congrArg L ((standardBasis n).sum_repr v) + simpa [standardBasis, Pi.basisFun_repr, map_sum, map_smul, smul_eq_mul, mul_comm] using h + +lemma polyLift_eval {n : ℕ} (L : Vec n →ₗ[ℂ] ℂ) (f : Fin n → Polynomial ℂ) (z : ℂ) : + (polyLift L f).eval z = L (fun i => (f i).eval z) := by + simp only [polyLift, eval_finsetSum, eval_mul, eval_C] + exact linear_basis_sum L _ + +lemma polyLift_coeff {n : ℕ} (L : Vec n →ₗ[ℂ] ℂ) (f : Fin n → Polynomial ℂ) (k : ℕ) : + (polyLift L f).coeff k = L (fun i => (f i).coeff k) := by + simp only [polyLift, finsetSum_coeff, coeff_C_mul] + exact linear_basis_sum L _ + +lemma polyLift_degree {n k : ℕ} (L : Vec n →ₗ[ℂ] ℂ) (f : Fin n → Polynomial ℂ) + (hf : ∀ i, (f i).natDegree ≤ k) : (polyLift L f).natDegree ≤ k := by + apply natDegree_sum_le_of_forall_le + intro i hi + exact (natDegree_C_mul_le _ _).trans (hf i) + +def Dpoly (a : ℂ) : Polynomial ℂ := X ^ 2 + C (2 * d * a) * X + C (a ^ 2 - d ^ 2) +def pairNumerator (a : ℂ) : Polynomial ℂ := (C a - X) * (C (a + rho) + X) +def denominatorPoly (N : ℕ) (a : Fin N → ℂ) : Polynomial ℂ := ∏ i, Dpoly (a i) +def deletedDenominator (N : ℕ) (a : Fin N → ℂ) (i : Fin N) : Polynomial ℂ := + ∏ j ∈ Finset.univ.erase i, Dpoly (a j) +def kernelNumerator (N : ℕ) (a : Fin N → ℂ) (i : Fin N) : Polynomial ℂ := + pairNumerator (a i) * deletedDenominator N a i + +def clearedPf (N : ℕ) (a : Fin N → ℂ) : Polynomial ℂ := + polyLift (incrementLinear N a) (Fin.snoc (kernelNumerator N a) (denominatorPoly N a)) + +@[simp] lemma Dpoly_eval (a z : ℂ) : (Dpoly a).eval z = D a z := by simp [Dpoly, D]; ring +lemma Dpoly_degree (a : ℂ) : (Dpoly a).natDegree ≤ 2 := by unfold Dpoly; compute_degree! +@[simp] lemma Dpoly_coeff (a : ℂ) : (Dpoly a).coeff 2 = 1 := by + simp only [Dpoly, coeff_add, coeff_C_mul, coeff_X_pow, coeff_X, coeff_C] + norm_num +lemma pairNumerator_degree (a : ℂ) : (pairNumerator a).natDegree ≤ 2 := by + unfold pairNumerator + compute_degree! +@[simp] lemma pairNumerator_coeff (a : ℂ) : (pairNumerator a).coeff 2 = -1 := by + have h : (pairNumerator a).coeff (1 + 1) = (C a - X).coeff 1 * (C (a + rho) + X).coeff 1 := by + apply coeff_mul_add_eq_of_natDegree_le <;> compute_degree! + simpa using h + +lemma denominatorPoly_degree (N : ℕ) (a : Fin N → ℂ) : + (denominatorPoly N a).natDegree ≤ 2 * N := by + apply (natDegree_prod_le _ _).trans + calc ∑ i : Fin N, (Dpoly (a i)).natDegree ≤ ∑ _i : Fin N, 2 := + Finset.sum_le_sum (fun i _ => Dpoly_degree (a i)) + _ = 2 * N := by simp [mul_comm] + +@[simp] lemma denominatorPoly_coeff (N : ℕ) (a : Fin N → ℂ) : + (denominatorPoly N a).coeff (2 * N) = 1 := by + have h := coeff_prod_of_natDegree_le (s := Finset.univ) (fun i => Dpoly (a i)) 2 + (fun i _ => Dpoly_degree (a i)) + simpa [denominatorPoly, mul_comm] using h + +lemma deletedDenominator_degree (N : ℕ) (a : Fin N → ℂ) (i : Fin N) : + (deletedDenominator N a i).natDegree ≤ 2 * (N - 1) := by + apply (natDegree_prod_le _ _).trans + calc ∑ j ∈ Finset.univ.erase i, (Dpoly (a j)).natDegree ≤ ∑ _j ∈ Finset.univ.erase i, 2 := + Finset.sum_le_sum (fun j _ => Dpoly_degree (a j)) + _ = 2 * (N - 1) := by simp [mul_comm] + +@[simp] lemma deletedDenominator_coeff (N : ℕ) (a : Fin N → ℂ) (i : Fin N) : + (deletedDenominator N a i).coeff (2 * (N - 1)) = 1 := by + have h := coeff_prod_of_natDegree_le (s := Finset.univ.erase i) (fun j => Dpoly (a j)) 2 + (fun j _ => Dpoly_degree (a j)) + simpa [deletedDenominator, mul_comm] using h + +lemma kernelNumerator_degree (N : ℕ) (a : Fin N → ℂ) (i : Fin N) : + (kernelNumerator N a i).natDegree ≤ 2 * N := by + have h := natDegree_mul_le.trans (add_le_add (pairNumerator_degree (a i)) + (deletedDenominator_degree N a i)) + have hi := i.isLt + have hn : 2 + 2 * (N - 1) = 2 * N := by omega + simpa [kernelNumerator, hn] using h + +@[simp] lemma kernelNumerator_coeff (N : ℕ) (a : Fin N → ℂ) (i : Fin N) : + (kernelNumerator N a i).coeff (2 * N) = -1 := by + have h := coeff_mul_add_eq_of_natDegree_le (pairNumerator_degree (a i)) + (deletedDenominator_degree N a i) + have hi := i.isLt + have hn : 2 + 2 * (N - 1) = 2 * N := by omega + simpa [kernelNumerator, hn] using h + +lemma clearedPf_degree (N : ℕ) (a : Fin N → ℂ) : (clearedPf N a).natDegree ≤ 2 * N := by + apply polyLift_degree + intro i + refine Fin.lastCases ?_ (fun j => ?_) i + · simpa using denominatorPoly_degree N a + · simpa using kernelNumerator_degree N a j + +lemma clearedPf_coeff (N : ℕ) (a : Fin N → ℂ) : + (clearedPf N a).coeff (2 * N) = (-1 : ℂ) ^ N * actualPf N a := by + rw [clearedPf, polyLift_coeff] + convert incrementLinear_leading N a using 1 + congr 1 + ext i + refine Fin.lastCases ?_ (fun j => ?_) i <;> simp + +lemma denominatorPoly_eval (N : ℕ) (a : Fin N → ℂ) (z : ℂ) : + (denominatorPoly N a).eval z = ∏ i, D (a i) z := by simp only [denominatorPoly, eval_prod, Dpoly_eval] + +lemma deletedDenominator_mul (N : ℕ) (a : Fin N → ℂ) (i : Fin N) : + deletedDenominator N a i * Dpoly (a i) = denominatorPoly N a := by + exact Finset.prod_erase_mul _ _ (Finset.mem_univ i) + +lemma kernelNumerator_eval (N : ℕ) (a : Fin N → ℂ) (z : ℂ) + (hz : ∀ i, D (a i) z ≠ 0) (i : Fin N) : + (kernelNumerator N a i).eval z = (denominatorPoly N a).eval z * kernel (a i) z := by + have h := congrArg (Polynomial.eval z) (deletedDenominator_mul N a i) + simp only [eval_mul, Dpoly_eval] at h + simp only [kernelNumerator, pairNumerator, eval_mul, eval_sub, eval_add, eval_C, eval_X, kernel] + rw [← h] + field_simp [hz i] + ring + +end +end StripPfaffian + +end OAI diff --git a/lean/OAI/Combinatorics/StripMass/PfaffianSupport.lean b/lean/OAI/Combinatorics/StripMass/PfaffianSupport.lean new file mode 100644 index 0000000000000000000000000000000000000000..b26615244b433cec5a35f4acc6ed039bc3ec50ea --- /dev/null +++ b/lean/OAI/Combinatorics/StripMass/PfaffianSupport.lean @@ -0,0 +1,508 @@ +import Mathlib +import OAI.Combinatorics.StripMass.RestrictedDiagrams + +namespace OAI + +/-! Critical honeycomb strip paths, polynomial identities and crossing mass. -/ + + + +namespace CriticalStrip.Diagram +noncomputable section +open Finset + + + +theorem pfaffian_reindex {K : Type*} [Field K] {n : ℕ} + (M : Matrix (Fin n) (Fin n) K) (τ : Equiv.Perm (Fin n)) : + pfaffian (fun i j => M (τ i) (τ j)) = + (Equiv.Perm.sign τ : ℤ) * pfaffian M := by + classical + unfold pfaffian + have hsign : ((Equiv.Perm.sign τ : ℤ) : K) * + ((Equiv.Perm.sign τ : ℤ) : K) = 1 := by + rcases Int.units_eq_one_or (Equiv.Perm.sign τ) with hs | hs <;> simp [hs] + have hs : (∑ σ : Equiv.Perm (Fin n), ((Equiv.Perm.sign σ : ℤ) : K) * + ∏ i : Fin (n/2), M (τ (σ (pairFirst n i))) (τ (σ (pairSecond n i)))) = + ((Equiv.Perm.sign τ : ℤ) : K) * + ∑ σ : Equiv.Perm (Fin n), ((Equiv.Perm.sign σ : ℤ) : K) * + ∏ i : Fin (n/2), M (σ (pairFirst n i)) (σ (pairSecond n i)) := by + rw [mul_sum] + refine Fintype.sum_equiv (Equiv.mulLeft τ) _ _ ?_ + intro σ + change _ = ((Equiv.Perm.sign τ : ℤ) : K) * + (((Equiv.Perm.sign (τ*σ) : ℤ) : K) * + ∏ i : Fin (n/2), M ((τ*σ) (pairFirst n i)) ((τ*σ) (pairSecond n i))) + simp only [Equiv.Perm.coe_mul, Function.comp_apply, map_mul, Units.val_mul, Int.cast_mul] + rw [← mul_assoc, ← mul_assoc, hsign, one_mul] + rw [hs] + ring + + +abbrev UpperPair (n : ℕ) := {ij : Fin n × Fin n // ij.1 < ij.2} + +instance (n : ℕ) : Fintype (UpperPair n) := by classical exact Subtype.fintype _ + + +def upperPair {n : ℕ} (i j : Fin n) (h : i ≠ j) : UpperPair n := + if hij : i < j then ⟨(i,j),hij⟩ else ⟨(j,i),lt_of_le_of_ne (le_of_not_gt hij) h.symm⟩ + +theorem upperPair_symm {n : ℕ} (i j : Fin n) (h : i ≠ j) : + upperPair i j h = upperPair j i h.symm := by + by_cases hij : i < j + · have hji : ¬ j < i := not_lt_of_ge hij.le + simp [upperPair, hij, hji] + · have hji : j < i := lt_of_le_of_ne (le_of_not_gt hij) h.symm + simp [upperPair, hij, hji] + +theorem upperPair_eq_iff {n : ℕ} {a b c d : Fin n} (hab : a ≠ b) (hcd : c ≠ d) : + upperPair a b hab = upperPair c d hcd ↔ (a = c ∧ b = d) ∨ (a = d ∧ b = c) := by + unfold upperPair + split_ifs <;> simp only [Subtype.mk.injEq, Prod.mk.injEq] <;> omega + +theorem pairFirst_ne_pairSecond {n : ℕ} (i j : Fin (n/2)) : + pairFirst n i ≠ pairSecond n j := by + intro h + have := congrArg Fin.val h + simp only [pairFirst, pairSecond] at this + omega + +def permutationPair {n : ℕ} (σ : Equiv.Perm (Fin n)) (i : Fin (n/2)) : UpperPair n := + upperPair (σ (pairFirst n i)) (σ (pairSecond n i)) + (σ.injective.ne (pairFirst_ne_pairSecond i i)) + +theorem permutationPair_injective {n : ℕ} (σ : Equiv.Perm (Fin n)) : + Function.Injective (permutationPair σ) := by + intro i j h + rcases (upperPair_eq_iff _ _).mp h with h | h + · have h₁ := σ.injective h.1 + have hv := congrArg Fin.val h₁ + apply Fin.ext + simp only [pairFirst] at hv + omega + · exact False.elim (pairFirst_ne_pairSecond i j (σ.injective h.1)) + + + + + + + +theorem upperPair_value {R : Type*} {n : ℕ} + (D : Fin n → Fin n → R) (hD : ∀ i j, D i j = D j i) + (i j : Fin n) (h : i ≠ j) : + D (upperPair i j h).val.1 (upperPair i j h).val.2 = D i j := by + unfold upperPair + split_ifs <;> simp [hD] + + +def selectedPairs {n : ℕ} (σ : Equiv.Perm (Fin n)) : Finset (UpperPair n) := + Finset.univ.image (permutationPair σ) + + + +def clearedPfaffianTerm {R : Type*} [CommRing R] {n : ℕ} + (N D : Matrix (Fin n) (Fin n) R) (σ : Equiv.Perm (Fin n)) : R := + (∏ i : Fin (n/2), N (σ (pairFirst n i)) (σ (pairSecond n i))) * + ∏ e ∈ (selectedPairs σ)ᶜ, D e.val.1 e.val.2 + +def clearedPfaffian {R : Type*} [CommRing R] {n : ℕ} (t : R) + (N D : Matrix (Fin n) (Fin n) R) : R := + t * ∑ σ : Equiv.Perm (Fin n), (Equiv.Perm.sign σ : ℤ) * clearedPfaffianTerm N D σ + +theorem prod_selectedPairs {R : Type*} [CommMonoid R] {n : ℕ} + (D : Fin n → Fin n → R) (hD : ∀ i j, D i j = D j i) + (σ : Equiv.Perm (Fin n)) : + (∏ e ∈ selectedPairs σ, D e.val.1 e.val.2) = + ∏ i : Fin (n/2), D (σ (pairFirst n i)) (σ (pairSecond n i)) := by + rw [selectedPairs, Finset.prod_image] + · apply Finset.prod_congr rfl + intro i _ + exact upperPair_value D hD _ _ _ + · exact fun i _ j _ h => permutationPair_injective σ h + +theorem clearedPfaffianTerm_mul_denominator {R : Type*} [CommRing R] {n : ℕ} + (N D : Matrix (Fin n) (Fin n) R) (hD : ∀ i j, D i j = D j i) + (σ : Equiv.Perm (Fin n)) : + clearedPfaffianTerm N D σ * + (∏ i : Fin (n/2), D (σ (pairFirst n i)) (σ (pairSecond n i))) = + (∏ i : Fin (n/2), N (σ (pairFirst n i)) (σ (pairSecond n i))) * + ∏ e : UpperPair n, D e.val.1 e.val.2 := by + rw [clearedPfaffianTerm, mul_assoc, ← prod_selectedPairs D hD σ, + Finset.prod_compl_mul_prod] + +theorem clear_pfaffian {K : Type*} [Field K] {n : ℕ} + (N D : Matrix (Fin n) (Fin n) K) (hD : ∀ i j, D i j = D j i) + (hne : ∀ i j, i ≠ j → D i j ≠ 0) : + (∏ e : UpperPair n, D e.val.1 e.val.2) * + pfaffian (fun i j => N i j / D i j) = + clearedPfaffian (2^(n/2) * (Nat.factorial (n/2) : K))⁻¹ N D := by + classical + unfold pfaffian clearedPfaffian + rw [mul_left_comm, mul_sum] + congr 1 + apply Finset.sum_congr rfl + intro σ _ + rw [mul_left_comm] + congr 1 + rw [Finset.prod_div_distrib] + have hd : (∏ i : Fin (n/2), D (σ (pairFirst n i)) (σ (pairSecond n i))) ≠ 0 := by + apply Finset.prod_ne_zero_iff.mpr + intro i _ + exact hne _ _ (σ.injective.ne (pairFirst_ne_pairSecond i i)) + rw [← mul_div_assoc, div_eq_iff hd] + rw [clearedPfaffianTerm_mul_denominator N D hD σ] + ring + +@[simp] theorem map_clearedPfaffianTerm {R S : Type*} [CommRing R] [CommRing S] {n : ℕ} + (f : R →+* S) (N D : Matrix (Fin n) (Fin n) R) (σ : Equiv.Perm (Fin n)) : + f (clearedPfaffianTerm N D σ) = clearedPfaffianTerm (N.map f) (D.map f) σ := by + simp [clearedPfaffianTerm, Matrix.map_apply] + +@[simp] theorem map_clearedPfaffian {R S : Type*} [CommRing R] [CommRing S] {n : ℕ} + (f : R →+* S) (t : R) (N D : Matrix (Fin n) (Fin n) R) : + f (clearedPfaffian t N D) = clearedPfaffian (f t) (N.map f) (D.map f) := by + simp [clearedPfaffian] + + + + + + + + + +def augmentedNumerator {R : Type*} [CommRing R] {n : ℕ} + (rr : R) (a : Fin n → R) : Matrix (Fin (n+n%2)) (Fin (n+n%2)) R := fun i j => + if hi : i.val < n then + if hj : j.val < n then + (a ⟨i.val,hi⟩-a ⟨j.val,hj⟩)*(a ⟨i.val,hi⟩+a ⟨j.val,hj⟩+rr) + else 1 + else if j.val < n then -1 else 0 + +def augmentedDenominator {R : Type*} [CommRing R] {n : ℕ} + (dd : R) (a : Fin n → R) : Matrix (Fin (n+n%2)) (Fin (n+n%2)) R := fun i j => + if hi : i.val < n then + if hj : j.val < n then discriminant dd (a ⟨i.val,hi⟩) (a ⟨j.val,hj⟩) + else 1 + else 1 + +theorem discriminant_symm {R : Type*} [CommRing R] (dd a b : R) : + discriminant dd a b = discriminant dd b a := by unfold discriminant; ring + +theorem augmentedDenominator_symm {R : Type*} [CommRing R] {n : ℕ} + (dd : R) (a : Fin n → R) (i j : Fin (n+n%2)) : + augmentedDenominator dd a i j = augmentedDenominator dd a j i := by + unfold augmentedDenominator + split_ifs <;> try rfl + exact discriminant_symm _ _ _ + +theorem augmentedKernel_eq {K : Type*} [Field K] {n : ℕ} + (dd rr : K) (a : Fin n → K) (i j : Fin (n+n%2)) : + augmentedKernel dd rr a i j = + augmentedNumerator rr a i j / augmentedDenominator dd a i j := by + unfold augmentedKernel augmentedNumerator augmentedDenominator + split_ifs <;> simp + +@[simp] theorem map_augmentedNumerator {R S : Type*} [CommRing R] [CommRing S] {n : ℕ} + (f : R →+* S) (rr : R) (a : Fin n → R) : + (augmentedNumerator rr a).map f = augmentedNumerator (f rr) (fun i => f (a i)) := by + ext i j + simp only [Matrix.map_apply, augmentedNumerator] + split_ifs <;> simp + +@[simp] theorem map_augmentedDenominator {R S : Type*} [CommRing R] [CommRing S] {n : ℕ} + (f : R →+* S) (dd : R) (a : Fin n → R) : + (augmentedDenominator dd a).map f = augmentedDenominator (f dd) (fun i => f (a i)) := by + ext i j + simp only [Matrix.map_apply, augmentedDenominator] + split_ifs <;> simp [discriminant, map_ofNat] + +abbrev CosineRing (n : ℕ) := MvPolynomial (Fin n) ℂ +abbrev CosineField (n : ℕ) := FractionRing (CosineRing n) + +def cosineVar {n : ℕ} (i : Fin n) : CosineField n := + algebraMap (CosineRing n) (CosineField n) (MvPolynomial.X i) + +def cosineConst (n : ℕ) (z : ℂ) : CosineField n := + algebraMap (CosineRing n) (CosineField n) (MvPolynomial.C z) + + + +def scalarNumerator (n : ℕ) (dd rr : ℂ) : CosineRing n := + clearedPfaffian (MvPolynomial.C ((2^((n+n%2)/2) * + (Nat.factorial ((n+n%2)/2) : ℂ))⁻¹)) + (augmentedNumerator (MvPolynomial.C rr) MvPolynomial.X) + (augmentedDenominator (MvPolynomial.C dd) MvPolynomial.X) + +theorem discriminant_cosineVar_ne {n : ℕ} (dd : ℂ) (hdd : dd ≠ 0) (i j : Fin n) : + discriminant (cosineConst n dd) (cosineVar i) (cosineVar j) ≠ 0 := by + change discriminant (algebraMap (CosineRing n) (CosineField n) (MvPolynomial.C dd)) + (algebraMap (CosineRing n) (CosineField n) (MvPolynomial.X i)) + (algebraMap (CosineRing n) (CosineField n) (MvPolynomial.X j)) ≠ 0 + have hmap : discriminant (algebraMap (CosineRing n) (CosineField n) (MvPolynomial.C dd)) + (algebraMap (CosineRing n) (CosineField n) (MvPolynomial.X i)) + (algebraMap (CosineRing n) (CosineField n) (MvPolynomial.X j)) = + algebraMap (CosineRing n) (CosineField n) + (discriminant (MvPolynomial.C dd) (MvPolynomial.X i) (MvPolynomial.X j)) := by + simp [discriminant, map_ofNat] + rw [hmap] + apply (map_ne_zero_iff _ (IsFractionRing.injective (CosineRing n) (CosineField n))).mpr + intro h + have hh := congrArg (MvPolynomial.eval (fun _ : Fin n => (0 : ℂ))) h + simp [discriminant, hdd] at hh + +theorem augmentedDenominator_cosineVar_ne {n : ℕ} (dd : ℂ) (hdd : dd ≠ 0) + (i j : Fin (n+n%2)) : + augmentedDenominator (cosineConst n dd) cosineVar i j ≠ 0 := by + unfold augmentedDenominator + split_ifs <;> try exact one_ne_zero + exact discriminant_cosineVar_ne dd hdd _ _ + +theorem scalarNumerator_generic (n : ℕ) (dd rr : ℂ) (hdd : dd ≠ 0) : + algebraMap (CosineRing n) (CosineField n) (scalarNumerator n dd rr) = + (∏ e : UpperPair (n+n%2), + augmentedDenominator (cosineConst n dd) cosineVar e.val.1 e.val.2) * + pfaffian (augmentedKernel (cosineConst n dd) (cosineConst n rr) cosineVar) := by + rw [scalarNumerator, map_clearedPfaffian, map_augmentedNumerator, map_augmentedDenominator] + change clearedPfaffian _ (augmentedNumerator (cosineConst n rr) cosineVar) + (augmentedDenominator (cosineConst n dd) cosineVar) = _ + have ht : algebraMap (CosineRing n) (CosineField n) + (MvPolynomial.C ((2^((n+n%2)/2) * (Nat.factorial ((n+n%2)/2) : ℂ))⁻¹)) = + (2^((n+n%2)/2) * (Nat.factorial ((n+n%2)/2) : CosineField n))⁻¹ := by + let f : ℂ →+* CosineField n := + (algebraMap (CosineRing n) (CosineField n)).comp MvPolynomial.C + change f _ = _ + simp only [map_inv₀, map_mul, map_pow, map_ofNat, map_natCast] + rw [ht, ← clear_pfaffian _ _ (augmentedDenominator_symm _ _) + (fun i j _ => augmentedDenominator_cosineVar_ne dd hdd i j)] + congr 2 + ext i j + exact (augmentedKernel_eq _ _ _ i j).symm + + + + + + + +def upperPairMap {n : ℕ} (σ : Equiv.Perm (Fin n)) (e : UpperPair n) : UpperPair n := + upperPair (σ e.val.1) (σ e.val.2) (σ.injective.ne (ne_of_lt e.property)) + +theorem upperPairMap_injective {n : ℕ} (σ : Equiv.Perm (Fin n)) : + Function.Injective (upperPairMap σ) := by + intro e f h + rcases (upperPair_eq_iff _ _).mp h with h | h + · apply Subtype.ext + exact Prod.ext (σ.injective h.1) (σ.injective h.2) + · have h₁ := σ.injective h.1 + have h₂ := σ.injective h.2 + have hef := e.property + rw [h₁, h₂] at hef + exact False.elim (lt_asymm hef f.property) + +def upperPairPerm {n : ℕ} (σ : Equiv.Perm (Fin n)) : Equiv.Perm (UpperPair n) := + Equiv.ofBijective (upperPairMap σ) + ⟨upperPairMap_injective σ, Finite.surjective_of_injective (upperPairMap_injective σ)⟩ + + +theorem prod_upperPair_reindex {R : Type*} [CommMonoid R] {n : ℕ} + (D : Fin n → Fin n → R) (hD : ∀ i j, D i j = D j i) (σ : Equiv.Perm (Fin n)) : + (∏ e : UpperPair n, D (σ e.val.1) (σ e.val.2)) = + ∏ e : UpperPair n, D e.val.1 e.val.2 := by + refine Fintype.prod_equiv (upperPairPerm σ) _ _ ?_ + intro e + exact (upperPair_value D hD _ _ (σ.injective.ne (ne_of_lt e.property))).symm + +theorem prod_upperPair {R : Type*} [CommMonoid R] {n : ℕ} + (D : Fin n → Fin n → R) : + (∏ e : UpperPair n, D e.val.1 e.val.2) = + ∏ i, ∏ j ∈ Finset.Ioi i, D i j := by + rw [← Finset.prod_subtype (Finset.univ.filter (fun ij : Fin n × Fin n => ij.1 < ij.2)) + (by simp) (fun ij : Fin n × Fin n => D ij.1 ij.2), Finset.prod_filter] + rw [Fintype.prod_prod_type] + apply Finset.prod_congr rfl + intro i _ + have h : Finset.Ioi i = Finset.univ.filter (fun j => i < j) := by ext j; simp + rw [h, Finset.prod_filter] + + +def upperPairEmbed {n m : ℕ} (h : n ≤ m) (e : UpperPair n) : UpperPair m := + ⟨(e.val.1.castLE h,e.val.2.castLE h),e.property⟩ + +theorem upperPairEmbed_injective {n m : ℕ} (h : n ≤ m) : + Function.Injective (upperPairEmbed h) := by + intro e f hef + apply Subtype.ext + have hv := congrArg Subtype.val hef + apply Prod.ext + · apply Fin.ext + exact congrArg (fun e : Fin m × Fin m => e.1.val) hv + · apply Fin.ext + exact congrArg (fun e : Fin m × Fin m => e.2.val) hv + + + + + + + +theorem scalarNumerator_eval {K : Type*} [Field K] (f : ℂ →+* K) + (n : ℕ) (dd rr : ℂ) (a : Fin n → K) + (hD : ∀ i j, i ≠ j → discriminant (f dd) (a i) (a j) ≠ 0) : + MvPolynomial.eval₂Hom f a (scalarNumerator n dd rr) = + (∏ e : UpperPair (n+n%2), augmentedDenominator (f dd) a e.val.1 e.val.2) * + pfaffian (augmentedKernel (f dd) (f rr) a) := by + rw [scalarNumerator, map_clearedPfaffian, map_augmentedNumerator, map_augmentedDenominator] + simp only [MvPolynomial.eval₂Hom_C, MvPolynomial.eval₂Hom_X', + map_inv₀, map_mul, map_pow, map_ofNat, map_natCast] + have hn : ∀ i j, i ≠ j → augmentedDenominator (f dd) a i j ≠ 0 := by + intro i j hij + unfold augmentedDenominator + split_ifs with hi hj <;> try exact one_ne_zero + apply hD + intro h + exact hij (Fin.ext (congrArg (fun k : Fin n => k.val) h)) + rw [← clear_pfaffian _ _ (augmentedDenominator_symm _ _) hn] + congr 2 + ext i j + exact (augmentedKernel_eq _ _ _ i j).symm + +theorem product_augmentedDenominator {R : Type*} [CommRing R] {n : ℕ} + (dd : R) (a : Fin n → R) : + (∏ e : UpperPair (n+n%2), augmentedDenominator dd a e.val.1 e.val.2) = + ∏ i, ∏ j ∈ Finset.Ioi i, discriminant dd (a i) (a j) := by + let hn : n ≤ n+n%2 := Nat.le_add_right _ _ + rw [← prod_upperPair] + symm + apply Fintype.prod_of_injective (upperPairEmbed hn) (upperPairEmbed_injective hn) + · intro e he + unfold augmentedDenominator + split_ifs with hi hj + · exfalso + apply he + refine ⟨⟨(⟨e.val.1.val,hi⟩,⟨e.val.2.val,hj⟩),e.property⟩,?_⟩ + apply Subtype.ext + exact Prod.ext (Fin.ext rfl) (Fin.ext rfl) + · rfl + · rfl + · intro e + simp [upperPairEmbed, augmentedDenominator, e.val.1.isLt, e.val.2.isLt] + + + +theorem scalarNumerator_eval_vandermonde {K : Type*} [Field K] (f : ℂ →+* K) + (n : ℕ) (dd rr : ℂ) (a : Fin n → K) (ha : Function.Injective a) + (hD : ∀ i j, i ≠ j → discriminant (f dd) (a i) (a j) ≠ 0) : + MvPolynomial.eval₂Hom f a (scalarNumerator n dd rr) = + (∏ i, ∏ j ∈ Finset.Ioi i, (a i-a j)) * scalarNormalization (f dd) (f rr) a := by + rw [scalarNumerator_eval f n dd rr a hD, product_augmentedDenominator] + unfold scalarNormalization + rw [← prod_upperPair, ← prod_upperPair, ← prod_upperPair, + Finset.prod_div_distrib] + have hv : (∏ e : UpperPair n, (a e.val.1-a e.val.2)) ≠ 0 := by + apply Finset.prod_ne_zero_iff.mpr + intro e _ + exact sub_ne_zero.mpr (ha.ne (ne_of_lt e.property)) + field_simp + + + + + + + +def augmentedPerm {n : ℕ} (σ : Equiv.Perm (Fin n)) : Equiv.Perm (Fin (n+n%2)) := + σ.viaEmbedding (Fin.castAddEmb (n%2)) + +@[simp] theorem augmentedPerm_real {n : ℕ} (σ : Equiv.Perm (Fin n)) (i : Fin n) : + augmentedPerm σ (i.castAdd (n%2)) = (σ i).castAdd (n%2) := + Equiv.Perm.viaEmbedding_apply σ (Fin.castAddEmb (n%2)) i + +theorem augmentedPerm_extra {n : ℕ} (σ : Equiv.Perm (Fin n)) + (i : Fin (n+n%2)) (hi : ¬ i.val < n) : augmentedPerm σ i = i := by + apply Equiv.Perm.viaEmbedding_apply_of_notMem + rintro ⟨j,hj⟩ + apply hi + rw [← hj] + exact j.isLt + +theorem augmentedPerm_apply {n : ℕ} (σ : Equiv.Perm (Fin n)) (i : Fin (n+n%2)) : + augmentedPerm σ i = if hi : i.val < n then (σ ⟨i.val,hi⟩).castAdd (n%2) else i := by + split_ifs with hi + · exact augmentedPerm_real σ ⟨i.val,hi⟩ + · exact augmentedPerm_extra σ i hi + +@[simp] theorem augmentedPerm_sign {n : ℕ} (σ : Equiv.Perm (Fin n)) : + Equiv.Perm.sign (augmentedPerm σ) = Equiv.Perm.sign σ := by + classical + unfold augmentedPerm Equiv.Perm.viaEmbedding + exact @Equiv.Perm.sign_extendDomain _ _ _ _ _ _ σ _ + (fun a => Classical.propDecidable _) _ + +theorem augmentedNumerator_reindex {R : Type*} [CommRing R] {n : ℕ} + (rr : R) (a : Fin n → R) (σ : Equiv.Perm (Fin n)) : + augmentedNumerator rr (a ∘ σ) = + fun i j => augmentedNumerator rr a (augmentedPerm σ i) (augmentedPerm σ j) := by + ext i j + by_cases hi : i.val < n <;> by_cases hj : j.val < n <;> + simp [augmentedNumerator, augmentedPerm_apply, hi, hj, Function.comp_apply] + +theorem augmentedDenominator_reindex {R : Type*} [CommRing R] {n : ℕ} + (dd : R) (a : Fin n → R) (σ : Equiv.Perm (Fin n)) : + augmentedDenominator dd (a ∘ σ) = + fun i j => augmentedDenominator dd a (augmentedPerm σ i) (augmentedPerm σ j) := by + ext i j + by_cases hi : i.val < n <;> by_cases hj : j.val < n <;> + simp [augmentedDenominator, augmentedPerm_apply, hi, hj, Function.comp_apply] + +theorem augmentedKernel_reindex {K : Type*} [Field K] {n : ℕ} + (dd rr : K) (a : Fin n → K) (σ : Equiv.Perm (Fin n)) : + augmentedKernel dd rr (a ∘ σ) = + fun i j => augmentedKernel dd rr a (augmentedPerm σ i) (augmentedPerm σ j) := by + ext i j + rw [augmentedKernel_eq, augmentedKernel_eq, augmentedNumerator_reindex, + augmentedDenominator_reindex] + + + +theorem scalarNumerator_eval_reindex {K : Type*} [Field K] (f : ℂ →+* K) + (n : ℕ) (dd rr : ℂ) (a : Fin n → K) + (hD : ∀ i j, i ≠ j → discriminant (f dd) (a i) (a j) ≠ 0) + (σ : Equiv.Perm (Fin n)) : + MvPolynomial.eval₂Hom f (a ∘ σ) (scalarNumerator n dd rr) = + (Equiv.Perm.sign σ : ℤ) * MvPolynomial.eval₂Hom f a (scalarNumerator n dd rr) := by + have hDσ : ∀ i j, i ≠ j → discriminant (f dd) ((a ∘ σ) i) ((a ∘ σ) j) ≠ 0 := by + intro i j hij + exact hD _ _ (σ.injective.ne hij) + rw [scalarNumerator_eval f n dd rr _ hDσ, scalarNumerator_eval f n dd rr _ hD, + augmentedDenominator_reindex, augmentedKernel_reindex, + prod_upperPair_reindex _ (augmentedDenominator_symm _ _), pfaffian_reindex, + augmentedPerm_sign] + ring + +def cosineCoeff (n : ℕ) : ℂ →+* CosineField n := + (algebraMap (CosineRing n) (CosineField n)).comp MvPolynomial.C + +@[simp] theorem cosineCoeff_apply (n : ℕ) (z : ℂ) : cosineCoeff n z = cosineConst n z := rfl + +theorem eval₂_cosineCoeff (n : ℕ) : + MvPolynomial.eval₂Hom (cosineCoeff n) cosineVar = + algebraMap (CosineRing n) (CosineField n) := by + ext a <;> simp [cosineCoeff, cosineVar] + + + +theorem scalarNumerator_rename {n : ℕ} (dd rr : ℂ) (hdd : dd ≠ 0) + (σ : Equiv.Perm (Fin n)) : + MvPolynomial.rename σ (scalarNumerator n dd rr) = + (Equiv.Perm.sign σ : ℤ) * scalarNumerator n dd rr := by + apply IsFractionRing.injective (CosineRing n) (CosineField n) + rw [← eval₂_cosineCoeff, MvPolynomial.eval₂Hom_rename, map_mul, map_intCast] + exact scalarNumerator_eval_reindex (cosineCoeff n) n dd rr cosineVar + (fun i j _ => discriminant_cosineVar_ne dd hdd i j) σ + +end +end CriticalStrip.Diagram + +end OAI diff --git a/lean/OAI/Combinatorics/StripMass/PhaseAlgebra.lean b/lean/OAI/Combinatorics/StripMass/PhaseAlgebra.lean new file mode 100644 index 0000000000000000000000000000000000000000..485070faf163a5c11b2e96875e59c64c71953274 --- /dev/null +++ b/lean/OAI/Combinatorics/StripMass/PhaseAlgebra.lean @@ -0,0 +1,570 @@ +import Mathlib +import OAI.Combinatorics.StripMass.NodalNodes +import OAI.Combinatorics.StripMass.ThreeBoxSplitPolynomial +import OAI.Combinatorics.StripMass.ThreeBoxBraidPolynomial + +namespace OAI + +/-! Critical honeycomb strip paths, polynomial identities and crossing mass. -/ + + + +namespace CriticalStrip.Diagram +noncomputable section + +theorem phase_four : phase^(4:ℕ) = Complex.I := by + have h := phase_pow 4 + norm_num only [zpow_ofNat, Int.cast_ofNat] at h + rw [h] + have he : (4:ℂ)*lambda*Complex.I = (Real.pi / 2 : ℝ)*Complex.I := by + simp [lambda] + ring + rw [he, Complex.exp_mul_I] + simp + +theorem constF_phase_four (n : ℕ) : constF n phase ^ 4 = constF n Complex.I := by + rw [constF, ← map_pow, phase_four] + rfl + +theorem constF_d_eq (n : ℕ) : + constF n d = ((constF n phase)^4+1)/(2*(constF n phase)^2) := by + change constF n (Real.cos ((2:ℝ)*lambda)) = _ + have h := torusCos_phase_pow n 2 + norm_num only [Nat.cast_ofNat] at h + rw [← h] + unfold torusCos + field_simp [constF_phase_ne_zero] + + + + + + + +def torusCommon {n : ℕ} (z : SpectralField n) : SpectralField n := + (constF n phase^4*z^2-1)*(constF n phase^6*z^2-1) + +theorem torusCommon_eq {n : ℕ} (z : SpectralField n) (hz : z ≠ 0) : + torusCommon z = 4*(constF n Complex.I)^2*(constF n phase)^5*z^2*torusL z := by + unfold torusCommon torusL torusSin + have hq := constF_phase_ne_zero n + have hI : constF n Complex.I ≠ 0 := + (map_ne_zero (algebraMap ℂ (SpectralField n))).mpr Complex.I_ne_zero + field_simp + ring + +theorem torusCommon_ne_zero {n : ℕ} (z : SpectralField n) (hz : z ≠ 0) + (hL : torusL z ≠ 0) : torusCommon z ≠ 0 := by + rw [torusCommon_eq z hz] + have hI : constF n Complex.I ≠ 0 := + (map_ne_zero (algebraMap ℂ (SpectralField n))).mpr Complex.I_ne_zero + exact mul_ne_zero (mul_ne_zero (mul_ne_zero (mul_ne_zero (by norm_num) + (pow_ne_zero _ hI)) (pow_ne_zero _ (constF_phase_ne_zero n))) (pow_ne_zero _ hz)) hL + +end +end CriticalStrip.Diagram + + + + + +namespace CriticalStrip.Diagram.ThreeBox +noncomputable section +open Finset + + + +theorem torusWeights_cleared {n : ℕ} (z : SpectralField n) (hz : z ≠ 0) + (hL : torusL z ≠ 0) (t : Tile) : + torusCommon z * (torusWeights z).tile t = + tileNumerator (constF n phase) (constF n phase^4) z t := by + have hq := constF_phase_ne_zero n + have hI : constF n Complex.I ≠ 0 := + (map_ne_zero (algebraMap ℂ (SpectralField n))).mpr Complex.I_ne_zero + cases t + · simp [Weights.tile, tileNumerator, torusCommon] + all_goals + rw [torusCommon_eq z hz] + simp only [torusWeights, Weights.tile, tileNumerator] + try rw [constF_d_eq] + simp only [torusSin] + rw [← constF_phase_four n] + field_simp [hL] + ring + + + + + + + +theorem coefficient_scale {K : Type*} [CommSemiring K] (a b c : Tile → K) + (r s u : K) (k : Fin 51) : + coefficient (fun t => r*a t) (fun t => s*b t) (fun t => u*c t) k = + (r*s*u) * coefficient a b c k := by + unfold coefficient + rw [mul_sum] + apply sum_congr rfl + intro t _ + ring + + + +theorem braid_coefficient {n : ℕ} (z w : SpectralField n) + (hz : z ≠ 0) (hw : w ≠ 0) (hLz : torusL z ≠ 0) (hLw : torusL w ≠ 0) + (hLzw : torusL (z*w) ≠ 0) (k : Fin 51) : + coefficient (torusWeights z).tile (torusWeights (z*w)).tile (torusWeights w).tile k = + coefficient (torusWeights w).tile (torusWeights (z*w)).tile (torusWeights z).tile + (mirrorIndex k) := by + have hN (v : SpectralField n) (hv : v ≠ 0) (hLv : torusL v ≠ 0) : + (fun t => torusCommon v * (torusWeights v).tile t) = + tileNumerator (constF n phase) (constF n phase^4) v := + funext (torusWeights_cleared v hv hLv) + have h := braid_numerator (constF n phase) z w (constF_phase_eight n) k + rw [← hN z hz hLz, ← hN w hw hLw, ← hN (z*w) (mul_ne_zero hz hw) hLzw, + coefficient_scale, coefficient_scale] at h + have hc := mul_ne_zero (mul_ne_zero (torusCommon_ne_zero z hz hLz) + (torusCommon_ne_zero (z*w) (mul_ne_zero hz hw) hLzw)) (torusCommon_ne_zero w hw hLw) + apply mul_left_cancel₀ hc + calc + _ = (torusCommon w * torusCommon (z*w) * torusCommon z) * + coefficient (torusWeights w).tile (torusWeights (z*w)).tile (torusWeights z).tile + (mirrorIndex k) := h + _ = _ := by ring + +end + + + + + +noncomputable section +open Finset +open scoped Classical + +theorem coefficient_eq_sumif {K : Type*} [CommSemiring K] (a b c : Tile → K) (k : Fin 51) : + coefficient a b c k = + ∑ t : Config, if profile t = some k then a t.1*b t.2.1*c t.2.2 else 0 := by + unfold coefficient + rw [← sum_filter] + congr 1 + ext t + simp only [mem_filter, mem_univ, true_and, mem_fiber_iff] + + + +theorem profile_partition {K : Type*} [CommSemiring K] (a b c : Tile → K) + (P : Fin 51 → Prop) : + (∑ t : Config, if ∃ k, profile t = some k ∧ P k + then a t.1*b t.2.1*c t.2.2 else 0) = + ∑ k : Fin 51, if P k then coefficient a b c k else 0 := by + have hk (k : Fin 51) : (if P k then coefficient a b c k else 0) = + ∑ t : Config, if profile t = some k ∧ P k then a t.1*b t.2.1*c t.2.2 else 0 := by + rw [coefficient_eq_sumif] + by_cases h : P k <;> simp [h] + simp_rw [hk] + rw [sum_comm] + apply sum_congr rfl + intro t _ + cases he : profile t with + | none => simp + | some j => + simp only [Option.some.injEq] + have hs (x : Fin 51) : + (if j = x ∧ P x then a t.1*b t.2.1*c t.2.2 else 0) = + if x = j then (if P j then a t.1*b t.2.1*c t.2.2 else 0) else 0 := by + by_cases h : x = j + · subst x; simp + · simp [h, Ne.symm h] + simp_rw [hs] + simp + + + +theorem patch_partition {K B : Type*} [CommSemiring K] (a₀ a₁ a₂ : Tile → K) + (s : B → B → Prop) (b : Fin 6 → B) (active : Fin 6 → Prop) (out : B → Prop) + (test : (B → B → Prop) → Prop) : + (∑ t : Config, if patchTest s b active out test t + then a₀ t.1*a₁ t.2.1*a₂ t.2.2 else 0) = + ∑ k : Fin 51, if exteriorTest s b active out test k + then coefficient a₀ a₁ a₂ k else 0 := by + simp_rw [patchTest_iff] + exact profile_partition a₀ a₁ a₂ _ + + + +theorem braid_partition {n : ℕ} (z w : SpectralField n) + (hz : z ≠ 0) (hw : w ≠ 0) (hLz : torusL z ≠ 0) (hLw : torusL w ≠ 0) + (hLzw : torusL (z*w) ≠ 0) (P : Fin 51 → Prop) : + (∑ t : Config, if ∃ k, profile t = some k ∧ P k + then (torusWeights z).tile t.1 * (torusWeights (z*w)).tile t.2.1 * + (torusWeights w).tile t.2.2 else 0) = + (∑ t : Config, if ∃ k, profile t = some k ∧ P (mirrorIndex k) + then (torusWeights w).tile t.1 * (torusWeights (z*w)).tile t.2.1 * + (torusWeights z).tile t.2.2 else 0) := by + rw [profile_partition, profile_partition] + simp_rw [braid_coefficient z w hz hw hLz hLw hLzw] + let e : Fin 51 ≃ Fin 51 := + ⟨mirrorIndex,mirrorIndex,mirrorIndex_involutive,mirrorIndex_involutive⟩ + refine Fintype.sum_equiv e _ _ ?_ + intro k + change (if P k then _ else 0) = + (if P (mirrorIndex (mirrorIndex k)) then _ else 0) + rw [mirrorIndex_involutive] + rfl + +end + + + + + +noncomputable section +open scoped Classical + +theorem split3_numerator {K : Type*} [CommRing K] (q z : K) (hq : q^8 = -1) + (k : Fin 51) (h₁ : ¬ boundarySupport (diagram k) 1) (h₂ : ¬ boundarySupport (diagram k) 2) : + coefficient deletionTile (tileNumerator q (q^4) (q^3*z)) (tileNumerator q (q^4) z) k = + commonNumerator q (q^3*z) * commonNumerator q z * coefficient swapTile swapTile deletionTile (mirrorIndex k) := by + fin_cases k + · exact split3_numerator_0 q z hq + · exact False.elim (h₁ (by decide)) + · exact False.elim (h₁ (by decide)) + · exact False.elim (h₁ (by decide)) + · exact False.elim (h₁ (by decide)) + · exact False.elim (h₁ (by decide)) + · exact False.elim (h₁ (by decide)) + · exact False.elim (h₁ (by decide)) + · exact False.elim (h₁ (by decide)) + · exact False.elim (h₁ (by decide)) + · exact False.elim (h₂ (by decide)) + · exact False.elim (h₂ (by decide)) + · exact False.elim (h₂ (by decide)) + · exact False.elim (h₂ (by decide)) + · exact split3_numerator_14 q z hq + · exact False.elim (h₁ (by decide)) + · exact False.elim (h₁ (by decide)) + · exact False.elim (h₁ (by decide)) + · exact False.elim (h₁ (by decide)) + · exact False.elim (h₁ (by decide)) + · exact False.elim (h₂ (by decide)) + · exact False.elim (h₂ (by decide)) + · exact split3_numerator_22 q z hq + · exact split3_numerator_23 q z hq + · exact False.elim (h₁ (by decide)) + · exact False.elim (h₁ (by decide)) + · exact False.elim (h₂ (by decide)) + · exact split3_numerator_27 q z hq + · exact False.elim (h₁ (by decide)) + · exact False.elim (h₁ (by decide)) + · exact split3_numerator_30 q z hq + · exact False.elim (h₁ (by decide)) + · exact False.elim (h₁ (by decide)) + · exact False.elim (h₁ (by decide)) + · exact False.elim (h₁ (by decide)) + · exact False.elim (h₁ (by decide)) + · exact False.elim (h₁ (by decide)) + · exact False.elim (h₁ (by decide)) + · exact False.elim (h₁ (by decide)) + · exact False.elim (h₁ (by decide)) + · exact False.elim (h₁ (by decide)) + · exact False.elim (h₁ (by decide)) + · exact False.elim (h₁ (by decide)) + · exact False.elim (h₂ (by decide)) + · exact False.elim (h₂ (by decide)) + · exact False.elim (h₂ (by decide)) + · exact False.elim (h₂ (by decide)) + · exact False.elim (h₂ (by decide)) + · exact split3_numerator_48 q z hq + · exact split3_numerator_49 q z hq + · exact split3_numerator_50 q z hq + +theorem split2_numerator {K : Type*} [CommRing K] (q z : K) (hq : q^8 = -1) + (k : Fin 51) (h₂ : ¬ boundarySupport (diagram k) 2) : + coefficient (mergeNumerator q) (tileNumerator q (q^4) (q^2*z)) (tileNumerator q (q^4) z) k * commonNumerator q (q*z) = + commonNumerator q (q^2*z) * commonNumerator q z * coefficient (tileNumerator q (q^4) (q*z)) swapTile (mergeNumerator q) (mirrorIndex k) := by + fin_cases k + · exact split2_numerator_0 q z hq + · exact split2_numerator_1 q z hq + · exact False.elim (h₂ (by decide)) + · exact False.elim (h₂ (by decide)) + · exact False.elim (h₂ (by decide)) + · exact False.elim (h₂ (by decide)) + · exact False.elim (h₂ (by decide)) + · exact split2_numerator_7 q z hq + · exact split2_numerator_8 q z hq + · exact split2_numerator_9 q z hq + · exact False.elim (h₂ (by decide)) + · exact False.elim (h₂ (by decide)) + · exact False.elim (h₂ (by decide)) + · exact False.elim (h₂ (by decide)) + · exact split2_numerator_14 q z hq + · exact False.elim (h₂ (by decide)) + · exact False.elim (h₂ (by decide)) + · exact split2_numerator_17 q z hq + · exact False.elim (h₂ (by decide)) + · exact split2_numerator_19 q z hq + · exact False.elim (h₂ (by decide)) + · exact False.elim (h₂ (by decide)) + · exact split2_numerator_22 q z hq + · exact split2_numerator_23 q z hq + · exact False.elim (h₂ (by decide)) + · exact split2_numerator_25 q z hq + · exact False.elim (h₂ (by decide)) + · exact split2_numerator_27 q z hq + · exact False.elim (h₂ (by decide)) + · exact False.elim (h₂ (by decide)) + · exact split2_numerator_30 q z hq + · exact False.elim (h₂ (by decide)) + · exact False.elim (h₂ (by decide)) + · exact False.elim (h₂ (by decide)) + · exact False.elim (h₂ (by decide)) + · exact split2_numerator_35 q z hq + · exact False.elim (h₂ (by decide)) + · exact False.elim (h₂ (by decide)) + · exact split2_numerator_38 q z hq + · exact split2_numerator_39 q z hq + · exact False.elim (h₂ (by decide)) + · exact split2_numerator_41 q z hq + · exact split2_numerator_42 q z hq + · exact False.elim (h₂ (by decide)) + · exact False.elim (h₂ (by decide)) + · exact False.elim (h₂ (by decide)) + · exact False.elim (h₂ (by decide)) + · exact False.elim (h₂ (by decide)) + · exact split2_numerator_48 q z hq + · exact split2_numerator_49 q z hq + · exact split2_numerator_50 q z hq + +end +end CriticalStrip.Diagram.ThreeBox + + + + + +namespace CriticalStrip.Diagram +noncomputable section + + +def swapWeights {K : Type*} [Zero K] [One K] : Weights K := ⟨0,1,0,0,0⟩ + + +def mergeWeights {K : Type*} [Field K] (q : K) : Weights K := + ⟨q/(q^2+1),q/(q^2+1),q/(q^2+1),0,0⟩ + +@[simp] lemma swapWeights_tile {K : Type*} [Zero K] [One K] : + (swapWeights : Weights K).tile = ThreeBox.swapTile := by funext t; cases t <;> rfl +@[simp] lemma deletionWeights_tile {K : Type*} [Zero K] [One K] : + (deletionWeights : Weights K).tile = ThreeBox.deletionTile := by funext t; cases t <;> rfl + +lemma eighthRoot_two_add_one_ne_zero {K : Type*} [Field K] [CharZero K] {q : K} + (hq : q^8 = -1) : q^2+1≠0 := by + intro h + have h2 : q^2 = -1 := by linear_combination h + have h8 : q^8 = 1 := by calc + q^8 = (q^2)^4 := by ring + _ = 1 := by rw [h2]; norm_num + have : (1 : K) = -1 := h8.symm.trans hq + norm_num at this + +lemma mergeWeights_cleared {K : Type*} [Field K] (q : K) (hq : q^2+1≠0) : + (fun t => (q^2+1)*(mergeWeights q).tile t) = ThreeBox.mergeNumerator q := by + funext t + cases t <;> simp [mergeWeights,Weights.tile,ThreeBox.mergeNumerator, mul_div_cancel₀, hq] + +namespace ThreeBox +lemma coefficient_scale₂₃ {K : Type*} [CommSemiring K] (a b c : Tile → K) + (r s : K) (k : Fin 51) : + coefficient a (fun t => r*b t) (fun t => s*c t) k = + (r*s) * coefficient a b c k := by + simpa using coefficient_scale a b c 1 r s k + +lemma coefficient_scale₁₃ {K : Type*} [CommSemiring K] (a b c : Tile → K) + (r s : K) (k : Fin 51) : + coefficient (fun t => r*a t) b (fun t => s*c t) k = + (r*s) * coefficient a b c k := by + simpa using coefficient_scale a b c r 1 s k + +lemma coefficient_deletion {n : ℕ} (z : SpectralField n) + (hz : z≠0) (hL : torusL z≠0) (hL3 : torusL (constF n phase^3*z)≠0) + (k : Fin 51) (h₁ : ¬ boundarySupport (diagram k) 1) + (h₂ : ¬ boundarySupport (diagram k) 2) : + coefficient deletionWeights.tile (torusWeights (constF n phase^3*z)).tile + (torusWeights z).tile k = + coefficient swapWeights.tile swapWeights.tile deletionWeights.tile (mirrorIndex k) := by + have hN (v : SpectralField n) (hv : v≠0) (hLv : torusL v≠0) : + (fun t => torusCommon v*(torusWeights v).tile t) = + tileNumerator (constF n phase) (constF n phase^4) v := + funext (torusWeights_cleared v hv hLv) + have hz3 := mul_ne_zero (pow_ne_zero 3 (constF_phase_ne_zero n)) hz + have h := split3_numerator (constF n phase) z (constF_phase_eight n) k h₁ h₂ + change coefficient deletionTile _ _ k = + torusCommon (constF n phase^3*z)*torusCommon z * + coefficient swapTile swapTile deletionTile (mirrorIndex k) at h + rw [←hN _ hz3 hL3,←hN _ hz hL,coefficient_scale₂₃] at h + simpa only [deletionWeights_tile,swapWeights_tile] using + mul_left_cancel₀ (mul_ne_zero (torusCommon_ne_zero _ hz3 hL3) + (torusCommon_ne_zero _ hz hL)) h + +lemma coefficient_merge {n : ℕ} (z : SpectralField n) + (hz : z≠0) (hL : torusL z≠0) (hL1 : torusL (constF n phase*z)≠0) + (hL2 : torusL (constF n phase^2*z)≠0) + (k : Fin 51) (h₂ : ¬ boundarySupport (diagram k) 2) : + coefficient (mergeWeights (constF n phase)).tile + (torusWeights (constF n phase^2*z)).tile (torusWeights z).tile k = + coefficient (torusWeights (constF n phase*z)).tile swapWeights.tile + (mergeWeights (constF n phase)).tile (mirrorIndex k) := by + let q := constF n phase + have hq := eighthRoot_two_add_one_ne_zero (constF_phase_eight n) + have hN (v : SpectralField n) (hv : v≠0) (hLv : torusL v≠0) : + (fun t => torusCommon v*(torusWeights v).tile t) = + tileNumerator q (q^4) v := funext (torusWeights_cleared v hv hLv) + have hz1 := mul_ne_zero (constF_phase_ne_zero n) hz + have hz2 := mul_ne_zero (pow_ne_zero 2 (constF_phase_ne_zero n)) hz + have h := split2_numerator q z (constF_phase_eight n) k h₂ + change coefficient (mergeNumerator q) _ _ k * torusCommon (q*z) = + torusCommon (q^2*z)*torusCommon z * + coefficient _ swapTile (mergeNumerator q) (mirrorIndex k) at h + rw [←hN _ hz2 hL2,←hN _ hz hL,←hN _ hz1 hL1, + ←mergeWeights_cleared q hq,coefficient_scale,coefficient_scale₁₃] at h + have hc : (q^2+1)*torusCommon (q^2*z)*torusCommon z*torusCommon (q*z)≠0 := + mul_ne_zero (mul_ne_zero (mul_ne_zero hq (torusCommon_ne_zero _ hz2 hL2)) + (torusCommon_ne_zero _ hz hL)) (torusCommon_ne_zero _ hz1 hL1) + apply mul_left_cancel₀ hc + simp only [swapWeights_tile] + calc + _ = ((q^2+1)*torusCommon (q^2*z)*torusCommon z) * + coefficient (mergeWeights q).tile (torusWeights (q^2*z)).tile (torusWeights z).tile k * + torusCommon (q*z) := by ring + _ = _ := h + _ = _ := by ring + +end ThreeBox + + + + + + +lemma rho_eq_inv_two_C : rho=1/(2*C) := by + rw [rho,C,lambda,Real.cos_pi_div_eight] + congr 1 + ring + +lemma phase_div_two_add_one : phase/(phase^2+1)=(rho:ℂ) := by + have h := phase_cosine 1 + simp only [zpow_one,Int.cast_one,one_mul] at h + change (phase+phase⁻¹)/2=(C:ℂ) at h + have he : 2*(C:ℂ)*phase=phase^2+1 := by + field_simp [phase_ne_zero] at h + linear_combination -h + have hden : phase^2+1≠0 := eighthRoot_two_add_one_ne_zero phase_eight + rw [rho_eq_inv_two_C] + push_cast + apply (div_eq_div_iff hden (by + intro hc + have hh:=he + rw [hc,zero_mul] at hh + exact hden hh.symm)).mpr + simpa only [one_mul,mul_comm] using he + +lemma mergeWeights_source_constant (n : ℕ) : + mergeWeights (constF n phase)= + (⟨constF n rho,constF n rho,constF n rho,0,0⟩ : Weights (SpectralField n)) := by + have h:=congrArg (constF n) phase_div_two_add_one + simp only [constF,map_div₀,map_add,map_pow,map_one] at h + unfold mergeWeights + change (⟨_,_,_,0,0⟩ : Weights (SpectralField n))=⟨_,_,_,0,0⟩ + simp only [constF,h] + + + + + + + +@[simp] lemma torusSin_inv {n : ℕ} (z : SpectralField n) : torusSin z⁻¹ = -torusSin z := by + simp only [torusSin,inv_inv] + ring + +@[simp] lemma torusSin_neg {n : ℕ} (z : SpectralField n) : torusSin (-z) = -torusSin z := by + simp only [torusSin] + ring + +lemma shifted_gamma_difference {n : ℕ} (i j : Fin n) : + spectralA j-shiftedCosine i (phase^(-9:ℤ))= + -2*torusSin (variableF i*variableF j/constF n phase^6)* + torusSin (constF n phase^5*(variableF i/variableF j)) := by + have hq := constF_phase_ne_zero n + have hi := variableF_ne_zero i + have hj := variableF_ne_zero j + have hp:=torusSin_product (variableF i*variableF j/constF n phase^6) + (constF n phase^3*variableF j/variableF i) + (div_ne_zero (mul_ne_zero hi hj) (pow_ne_zero _ hq)) + (div_ne_zero (mul_ne_zero (pow_ne_zero _ hq) hj) hi) + have he₁ : (variableF i*variableF j/constF n phase^6)/ + (constF n phase^3*variableF j/variableF i)=constF n (phase^(-9:ℤ))*variableF i^2 := by + simp only [constF,zpow_neg,zpow_ofNat,map_inv₀,map_pow] + field_simp + have he₂ : (variableF i*variableF j/constF n phase^6)* + (constF n phase^3*variableF j/variableF i)=variableF j^2/constF n phase^3 := by + field_simp + have he₃ : constF n phase^3*variableF j/variableF i= + -(constF n phase^5*(variableF i/variableF j))⁻¹ := by + have h:=constF_phase_eight n + field_simp + linear_combination h + rw [he₁,he₂,he₃,torusSin_neg,torusSin_inv] at hp + rw [shiftedCosine_eq _ _ (zpow_ne_zero _ phase_ne_zero)] + change torusCos (variableF j^2/constF n phase^3)-_= _ + rw [neg_neg] at hp + linear_combination hp + +lemma shifted_sigma_difference {n : ℕ} (i j : Fin n) : + spectralA j-shiftedCosine i (phase^(9:ℤ))= + 2*torusSin (constF n phase^3*(variableF i*variableF j))* + torusSin (constF n phase^6*(variableF i/variableF j)) := by + have hq := constF_phase_ne_zero n + have hi := variableF_ne_zero i + have hj := variableF_ne_zero j + have hp:=torusSin_product (constF n phase^3*(variableF i*variableF j)) + (variableF j/(constF n phase^6*variableF i)) + (mul_ne_zero (pow_ne_zero _ hq) (mul_ne_zero hi hj)) + (div_ne_zero hj (mul_ne_zero (pow_ne_zero _ hq) hi)) + have he₁ : (constF n phase^3*(variableF i*variableF j))/ + (variableF j/(constF n phase^6*variableF i))=constF n (phase^(9:ℤ))*variableF i^2 := by + simp only [constF,zpow_ofNat,map_pow] + field_simp + have he₂ : (constF n phase^3*(variableF i*variableF j))* + (variableF j/(constF n phase^6*variableF i))=variableF j^2/constF n phase^3 := by + field_simp + have he₃ : variableF j/(constF n phase^6*variableF i)= + (constF n phase^6*(variableF i/variableF j))⁻¹ := by + field_simp + rw [he₁,he₂,he₃,torusSin_inv] at hp + rw [shiftedCosine_eq _ _ (zpow_ne_zero _ phase_ne_zero)] + change torusCos (variableF j^2/constF n phase^3)-_= _ + linear_combination hp + + + +theorem movingBox_scalar_cancellation {n : ℕ} (i j : Fin n) : + (spectralA j-shiftedCosine i (phase^(-9:ℤ)))* + (spectralA j-shiftedCosine i (phase^(9:ℤ)))= + (-4*torusSin (variableF i*variableF j/constF n phase^6)* + torusSin (constF n phase^3*(variableF i*variableF j)))* + torusL (constF n phase^3*(variableF i/variableF j)) := by + rw [shifted_gamma_difference,shifted_sigma_difference] + unfold torusL + have h₁ : constF n phase^2*(constF n phase^3*(variableF i/variableF j))= + constF n phase^5*(variableF i/variableF j) := by ring + have h₂ : constF n phase^3*(constF n phase^3*(variableF i/variableF j))= + constF n phase^6*(variableF i/variableF j) := by ring + rw [h₁,h₂] + ring + +end +end CriticalStrip.Diagram + +end OAI diff --git a/lean/OAI/Combinatorics/StripMass/PhysicalPorts.lean b/lean/OAI/Combinatorics/StripMass/PhysicalPorts.lean new file mode 100644 index 0000000000000000000000000000000000000000..6b8a480d28e9109f03d4b172d59bd439a212f24e --- /dev/null +++ b/lean/OAI/Combinatorics/StripMass/PhysicalPorts.lean @@ -0,0 +1,561 @@ +import Mathlib +import OAI.Combinatorics.StripMass.FluxWindow + +namespace OAI + +/-! Critical honeycomb strip paths, polynomial identities and crossing mass. -/ + + +namespace CriticalStrip.HoneycombBranch +noncomputable section +open scoped Classical BigOperators +open FiniteBranchTree + +def bandVertices (H : ℕ) (v : Vertex) : Prop := 0≤v.2.1 ∧ v.2.1<(H:ℤ) + +def stripPort (H : ℕ) : ℤ⊕ℤ→State + | .inl j=>bottom j + | .inr j=>top H j + +lemma stripPort_injective (H : ℕ) : Function.Injective (stripPort H) := by + rintro (j|j) (k|k) he <;> simp [stripPort,bottom,top] at he ⊢ <;> tauto + +lemma stripPort_inside (H : ℕ) (hH : 1≤H) (b : ℤ⊕ℤ) : bandVertices H (stripPort H b).1 := by + cases b <;> dsimp [stripPort,bandVertices,bottom,top] <;> omega + +lemma stripPort_outside (H : ℕ) (_hH : 1≤H) (b : ℤ⊕ℤ) : ¬bandVertices H (back (stripPort H b)).1 := by + cases b <;> simp [stripPort,bandVertices,bottom,top,back,neighbor] + +lemma stripPort_complete (H : ℕ) (s : State) (hi : bandVertices H s.1) + (ho : ¬bandVertices H (back s).1) : ∃b,stripPort H b=s := by + rcases s with ⟨⟨k,r,b⟩,p⟩ + fin_cases p + · cases b + · refine ⟨.inr k,?_⟩ + dsimp [bandVertices,back,neighbor] at hi ho + have hr : r=(H:ℤ)-1 := by omega + simp [stripPort,top,hr] + · refine ⟨.inl k,?_⟩ + dsimp [bandVertices,back,neighbor] at hi ho + have hr : r=0 := by omega + simp [stripPort,bottom,hr] + · cases b <;> simp [bandVertices,back,neighbor] at hi ho <;> omega + · cases b <;> simp [bandVertices,back,neighbor] at hi ho <;> omega + +def stripBoundaryPorts (H : ℕ) (hH : 1≤H) : BoundaryPorts (bandVertices H) (ℤ⊕ℤ) where + port:=stripPort H + injective:=stripPort_injective H + inside:=stripPort_inside H hH + outside:=stripPort_outside H hH + complete:=stripPort_complete H + +abbrev StepEndpoint := ℤ⊕(ℤ⊕Unit) + +def stepPort (N : ℕ) (s : ℤ) : StepEndpoint→State + | .inl j=>bottom j + | .inr (.inl j)=>stepTop N s j + | .inr (.inr _)=>sidePort N s + +lemma stepPort_injective (N : ℕ) (s : ℤ) : Function.Injective (stepPort N s) := by + rintro (j|(j|u)) (k|(k|v)) he + all_goals simp only [stepPort,stepTop] at he + all_goals try split_ifs at he + all_goals simp_all [bottom,top,sidePort] + +lemma stepPort_inside (N : ℕ) (hN : 1≤N) (s : ℤ) (b : StepEndpoint) : + steppedVertices N s (stepPort N s b).1 := by + rcases b with j|(j|u) + · dsimp [stepPort,steppedVertices,bottom]; omega + · simp only [stepPort,stepTop] + split_ifs <;> dsimp [steppedVertices,top] <;> omega + · dsimp [stepPort,steppedVertices,sidePort]; omega + +lemma stepPort_outside (N : ℕ) (_hN : 1≤N) (s : ℤ) (b : StepEndpoint) : + ¬steppedVertices N s (back (stepPort N s b)).1 := by + rcases b with j|(j|u) + · simp [stepPort,back,bottom,neighbor,steppedVertices] + · simp only [stepPort,stepTop] + split_ifs <;> dsimp [steppedVertices,top,back,neighbor] <;> omega + · dsimp [stepPort,steppedVertices,sidePort,back,neighbor]; omega + +lemma stepPort_complete (N : ℕ) (s : ℤ) (x : State) (hi : steppedVertices N s x.1) + (ho : ¬steppedVertices N s (back x).1) : ∃b,stepPort N s b=x := by + rcases x with ⟨⟨k,r,b⟩,p⟩ + fin_cases p + · cases b + · refine ⟨.inr (.inl k),?_⟩ + dsimp [steppedVertices,back,neighbor] at hi ho + by_cases hk : k dsimp [steppedVertices,back,neighbor] at hi ho <;> omega + +def stepBoundaryPorts (N : ℕ) (hN : 1≤N) (s : ℤ) : BoundaryPorts (steppedVertices N s) StepEndpoint where + port:=stepPort N s + injective:=stepPort_injective N s + inside:=stepPort_inside N hN s + outside:=stepPort_outside N hN s + complete:=stepPort_complete N s + +lemma retract_bottom (j : ℤ) : retractVertex (bottom j).1=up j 0 := rfl +lemma retract_top (H : ℕ) (hH : 1≤H) (j : ℤ) : retractVertex (top H j).1=down j (H-1) := by + dsimp [retractVertex,top,down] + congr 2 + omega +lemma retract_side (N : ℕ) (s : ℤ) : retractVertex (sidePort N s).1=up s N := by + simp [retractVertex,sidePort,up] + +lemma boundaryPathWeight_strip_bottom (H : ℕ) (hH : 1≤H) (i j : ℤ) (p : List Triangle) : + boundaryPathWeight (stripBoundaryPorts H hH) H i (.inl j,p)=betweenArchWeight H i j p := by + have hc : ValidBoundaryPath (stripBoundaryPorts H hH) H i (.inl j,p) ↔ + i≠j ∧ PathBetween H (up i 0) (up j 0) p := by + simp only [ValidBoundaryPath,stripBoundaryPorts,stripPort,retract_bottom] + have hb : bottom i≠bottom j ↔ i≠j := by simp [bottom] + rw [hb] + constructor + · rintro ⟨h,hp,_⟩; exact ⟨h,hp⟩ + · rintro ⟨h,hp⟩ + exact ⟨h,hp,fun v hv=>⟨by simp [embedTriangle],by change (v.2.1:ℤ)<(H:ℤ); exact_mod_cast hp.2.2.2.2 v hv⟩⟩ + simp only [boundaryPathWeight,betweenArchWeight,hc] + +def betweenBridgeWeight (H : ℕ) (i j : ℤ) (p : List Triangle) : ℝ := + if 0 positivity [rho_pos] + +lemma betweenBridgeWeight_translate (H : ℕ) (i j : ℤ) (p : List Triangle) : + betweenBridgeWeight H i j (p.map (translateTriangle i))=bridgeWeight H (j-i) p := by + have hi : up i 0=translateTriangle i (up 0 0) := by simp + have hj : down j (H-1)=translateTriangle i (down (j-i) (H-1)) := by simp + simp only [betweenBridgeWeight,bridgeWeight,hi,hj,pathBetween_translate_iff,pathBetween_source,List.length_map] + +lemma betweenBridgeWeight_summable (H : ℕ) (hH : 1≤H) (i : ℤ) : + Summable (fun x : ℤ×List Triangle=>betweenBridgeWeight H i x.1 x.2) := by + have hf:=stripSumsFinite hH + have hi (j : ℤ) : Summable (betweenBridgeWeight H i j) := by + rw [←(translatePaths i).summable_iff] + apply (hf.2.1 (j-i)).congr + intro p + exact (betweenBridgeWeight_translate H i j p).symm + have he (j : ℤ) : (∑'p,betweenBridgeWeight H i j p)=bridgeKernel H (j-i) := by + rw [←(translatePaths i).tsum_eq] + exact tsum_congr (betweenBridgeWeight_translate H i j) + apply (summable_prod_of_nonneg (fun x=>betweenBridgeWeight_nonneg H i x.1 x.2)).mpr + refine ⟨hi,?_⟩ + simp_rw [he] + exact hf.2.2.2.1.comp_injective (i:=fun j : ℤ=>j-i) (by intro a b hh; dsimp at hh; omega) + +lemma betweenArchWeight_summable (H : ℕ) (hH : 1≤H) (i : ℤ) : + Summable (fun x : ℤ×List Triangle=>betweenArchWeight H i x.1 x.2) := by + have hf:=stripSumsFinite hH + apply (summable_prod_of_nonneg (fun x=>betweenArchWeight_nonneg H i x.1 x.2)).mpr + refine ⟨fun j=>(summable_betweenArchWeight_iff H i j).mpr (hf.1 _),?_⟩ + change Summable (fun j=>betweenArchKernel H i j) + simp_rw [betweenArchKernel_eq] + exact hf.2.2.1.comp_injective (i:=fun j : ℤ=>j-i) (by intro a b hh; dsimp at hh; omega) + +lemma boundaryPathWeight_strip_top (H : ℕ) (hH : 1≤H) (i j : ℤ) (p : List Triangle) : + boundaryPathWeight (stripBoundaryPorts H hH) H i (.inr j,p)=betweenBridgeWeight H i j p := by + have hc : ValidBoundaryPath (stripBoundaryPorts H hH) H i (.inr j,p) ↔ + 0⟨by simp [embedTriangle],by change (v.2.1:ℤ)<(H:ℤ); exact_mod_cast hp.2.2.2.2 v hv⟩⟩ + simp only [boundaryPathWeight,betweenBridgeWeight,hc] + +lemma boundaryPathWeight_step_bottom (N : ℕ) (hN : 1≤N) (s i j : ℤ) (p : List Triangle) : + boundaryPathWeight (stepBoundaryPorts N hN s) (N+1) i (.inl j,p)=stepArchWeight N s i j p := by + have hc : ValidBoundaryPath (stepBoundaryPorts N hN s) (N+1) i (.inl j,p) ↔ + i≠j ∧ PathBetween (N+1) (up i 0) (up j 0) p ∧ (∀v∈p,steppedDomain N s v) := by + simp only [ValidBoundaryPath,stepBoundaryPorts,stepPort,retract_bottom,steppedVertices_embed] + have hb : bottom i≠bottom j ↔ i≠j := by simp [bottom] + rw [hb] + unfold boundaryPathWeight stepArchWeight betweenArchWeight + rw [hc] + split_ifs <;> tauto + +lemma boundaryPathWeight_step_side (N : ℕ) (hN : 1≤N) (s i : ℤ) (p : List Triangle) : + boundaryPathWeight (stepBoundaryPorts N hN s) (N+1) i (.inr (.inr ()),p)=stepSideWeight N s i p := by + have hc : ValidBoundaryPath (stepBoundaryPorts N hN s) (N+1) i (.inr (.inr ()),p) ↔ + PathBetween (N+1) (up i 0) (up s N) p ∧ (∀v∈p,steppedDomain N s v) := by + simp only [ValidBoundaryPath,stepBoundaryPorts,stepPort,retract_side,steppedVertices_embed] + have hn : bottom i≠sidePort N s := by simp [bottom,sidePort] + change (bottom i≠sidePort N s ∧ PathBetween (N+1) (up i 0) (up s N) p ∧ _) ↔ _ + exact and_iff_right hn + simp only [boundaryPathWeight,stepSideWeight,hc] + + + + + + + +lemma summable_sumProd {A B C E : Type*} [NormedAddCommGroup E] [CompleteSpace E] + {f : (A⊕B)×C→E} + (ha : Summable (fun x : A×C=>f (.inl x.1,x.2))) + (hb : Summable (fun x : B×C=>f (.inr x.1,x.2))) : Summable f := by + apply ((Equiv.sumProdDistrib A B C).symm.summable_iff).mp + exact Summable.sum _ ha hb + +lemma tsum_sumProd {A B C E : Type*} [NormedAddCommGroup E] [CompleteSpace E] + {f : (A⊕B)×C→E} + (ha : Summable (fun x : A×C=>f (.inl x.1,x.2))) + (hb : Summable (fun x : B×C=>f (.inr x.1,x.2))) : + (∑'x,f x)=(∑'x : A×C,f (.inl x.1,x.2))+(∑'x : B×C,f (.inr x.1,x.2)) := by + rw [←(Equiv.sumProdDistrib A B C).symm.tsum_eq f] + exact ha.tsum_sum hb + +lemma phase_re (k : ℤ) : (Diagram.phase^k).re=Real.cos ((k:ℝ)*lambda) := by + rw [Diagram.phase_pow] + simp [Complex.exp_re,Diagram.lambda,lambda] + +lemma phase_im (k : ℤ) : (Diagram.phase^k).im=Real.sin ((k:ℝ)*lambda) := by + rw [Diagram.phase_pow] + simp [Complex.exp_im,Diagram.lambda,lambda] + +variable {D : Vertex→Prop} {B : Type*} (P : BoundaryPorts D B) {H : ℕ} {i : ℤ} + +lemma boundary_complex_summable (hs : Summable (boundaryPathWeight P H i)) (θ : B→ℤ) : + Summable (fun x : B×List Triangle=>(boundaryPathWeight P H i x:ℂ)*Diagram.phase^(θ x.1)) := by + apply hs.of_norm_bounded + intro x + simp [norm_zpow,phase_norm,Real.norm_of_nonneg (boundaryPathWeight_nonneg P H i x)] + +lemma boundary_real_summable (hs : Summable (boundaryPathWeight P H i)) (θ : B→ℤ) : + Summable (fun x : B×List Triangle=>boundaryPathWeight P H i x*Real.cos ((θ x.1:ℝ)*lambda)) := by + have hh := (Complex.hasSum_re (boundary_complex_summable P hs θ).hasSum).summable + simpa only [Complex.mul_re,Complex.ofReal_re,Complex.ofReal_im,zero_mul,sub_zero,phase_re] using hh + +lemma boundary_imaginary_summable (hs : Summable (boundaryPathWeight P H i)) (θ : B→ℤ) : + Summable (fun x : B×List Triangle=>boundaryPathWeight P H i x*Real.sin ((θ x.1:ℝ)*lambda)) := by + have hh := (Complex.hasSum_im (boundary_complex_summable P hs θ).hasSum).summable + simpa only [Complex.mul_im,Complex.ofReal_re,Complex.ofReal_im,zero_mul,add_zero,phase_im] using hh + + +theorem boundary_real_flux (hH : 1≤H) (hi : D (bottom i).1) + (hD : ∀v,D v→0≤v.2.1 ∧ v.2.1<(H:ℤ)) (hs : Summable (boundaryPathWeight P H i)) + (θ : B→ℤ) (hθ : ∀x : ExitWord D i,turn x.val=θ (exitPort P x)) : + (∑'x : B×List Triangle,boundaryPathWeight P H i x*Real.cos ((θ x.1:ℝ)*lambda))=1 := by + have hh:=congrArg Complex.re (boundary_flux P hH hi hD hs θ hθ) + rw [Complex.re_tsum (boundary_complex_summable P hs θ)] at hh + simpa only [Complex.mul_re,Complex.ofReal_re,Complex.ofReal_im,zero_mul,sub_zero,phase_re,Complex.one_re] using hh + +theorem boundary_imaginary_flux (hH : 1≤H) (hi : D (bottom i).1) + (hD : ∀v,D v→0≤v.2.1 ∧ v.2.1<(H:ℤ)) (hs : Summable (boundaryPathWeight P H i)) + (θ : B→ℤ) (hθ : ∀x : ExitWord D i,turn x.val=θ (exitPort P x)) : + (∑'x : B×List Triangle,boundaryPathWeight P H i x*Real.sin ((θ x.1:ℝ)*lambda))=0 := by + have hh:=congrArg Complex.im (boundary_flux P hH hi hD hs θ hθ) + rw [Complex.im_tsum (boundary_complex_summable P hs θ)] at hh + simpa only [Complex.mul_im,Complex.ofReal_re,Complex.ofReal_im,zero_mul,add_zero,phase_im,Complex.one_im] using hh + +lemma stripBoundary_summable (H : ℕ) (hH : 1≤H) (i : ℤ) : + Summable (boundaryPathWeight (stripBoundaryPorts H hH) H i) := by + apply summable_sumProd + · simpa only [boundaryPathWeight_strip_bottom] using betweenArchWeight_summable H hH i + · simpa only [boundaryPathWeight_strip_top] using betweenBridgeWeight_summable H hH i + +def stripTurn (i : ℤ) : ℤ⊕ℤ→ℤ + | .inl j=>if i≤j then -3 else 3 + | .inr _=>0 + +lemma strip_turn (H : ℕ) (hH : 1≤H) (i : ℤ) (x : ExitWord (bandVertices H) i) : + turn x.val=stripTurn i (exitPort (stripBoundaryPorts H hH) x) := by + have ht:=exitPort_terminal (stripBoundaryPorts H hH) x + generalize hb : exitPort (stripBoundaryPorts H hH) x=b at ht ⊢ + rcases b with j|j + · exact bottom_turn i j x.val x.property.1 (ribbonSimple_of_nodup x.property.2.1) + (fun v hv=>(x.property.2.2.1 v hv).1) ht + · exact top_turn H hH i j x.val x.property.1 x.property.2.1 x.property.2.2.1 ht + +lemma stripTurn_cos_bottom (i j : ℤ) : Real.cos ((stripTurn i (.inl j):ℝ)*lambda)=c := by + dsimp only [stripTurn] + split_ifs <;> norm_num [neg_mul,Real.cos_neg,c,lambda] <;> congr 1 <;> ring + +lemma stripTurn_cos_top (i j : ℤ) : Real.cos ((stripTurn i (.inr j):ℝ)*lambda)=1 := by + simp [stripTurn] + + + +theorem physical_strip_flux {H : ℕ} (hH : 1≤H) : c*archMass H+bridgeMass H=1 := by + have ha:=betweenArchWeight_summable H hH 0 + have hb:=betweenBridgeWeight_summable H hH 0 + have hf:=boundary_real_flux (stripBoundaryPorts H hH) hH (by dsimp [bandVertices,bottom]; omega) + (fun v hv=>hv) (stripBoundary_summable H hH 0) (stripTurn 0) (strip_turn H hH 0) + have ht := tsum_sumProd (f:=fun x : (ℤ⊕ℤ)×List Triangle=> + boundaryPathWeight (stripBoundaryPorts H hH) H 0 x*Real.cos ((stripTurn 0 x.1:ℝ)*lambda)) + (by simpa only [boundaryPathWeight_strip_bottom,stripTurn_cos_bottom] using ha.mul_right c) + (by simpa only [boundaryPathWeight_strip_top,stripTurn_cos_top,mul_one] using hb) + simp only [boundaryPathWeight_strip_bottom,boundaryPathWeight_strip_top, + stripTurn_cos_bottom,stripTurn_cos_top,mul_one] at ht + rw [ht,tsum_mul_right,ha.tsum_prod,hb.tsum_prod] at hf + have hac (j : ℤ) : (∑'p,betweenArchWeight H 0 j p)=K H j := by + change betweenArchKernel H 0 j=K H j + simp only [betweenArchKernel_eq,sub_zero] + have hbc (j : ℤ) : (∑'p,betweenBridgeWeight H 0 j p)=bridgeKernel H j := by + apply tsum_congr + intro p + simp only [betweenBridgeWeight,bridgeWeight,pathBetween_source] + simpa only [hac,hbc,archMass,bridgeMass,mul_comm] using hf + +end + + + + + +noncomputable section +open scoped Classical BigOperators +open FiniteBranchTree + + + +def extendStepTop (N : ℕ) (s j : ℤ) (p : List Triangle) : List Triangle := + if j + (steppedVertices_embed N s v).mp (hp.2.2 v hv) + by_cases hj : j + boundaryPathWeight (stepBoundaryPorts N hN s) (N+1) i (.inr (.inl x.1),x.2)) := by + let e : ℤ×List Triangle→ℤ×List Triangle := fun x=>(x.1,extendStepTop N s x.1 x.2) + have he : Function.Injective e := by + intro x y hh + have hj:=congrArg Prod.fst hh + change x.1=y.1 at hj + have hp:=congrArg Prod.snd hh + change extendStepTop N s x.1 x.2=extendStepTop N s y.1 y.2 at hp + rw [hj] at hp + exact Prod.ext hj (extendStepTop_injective N s y.1 hp) + have hg:=(betweenBridgeWeight_summable (N+1) (by omega) i).comp_injective he + have hm : Summable (fun x : ℤ×List Triangle=>rho^2* + boundaryPathWeight (stepBoundaryPorts N hN s) (N+1) i (.inr (.inl x.1),x.2)) := + hg.of_nonneg_of_le (fun x=>mul_nonneg (sq_nonneg _) (boundaryPathWeight_nonneg _ _ _ _)) + (fun x=>extendStepTop_weight hN s i x.1 x.2) + exact (summable_mul_left_iff (pow_ne_zero _ rho_pos.ne')).mp hm + +lemma stepArchWeight_summable {N : ℕ} (hN : 1≤N) (s i : ℤ) : + Summable (fun x : ℤ×List Triangle=>stepArchWeight N s i x.1 x.2) := + (betweenArchWeight_summable (N+1) (by omega) i).of_nonneg_of_le + (fun x=>stepArchWeight_nonneg N s i x.1 x.2) (fun x=>stepArchWeight_le N s i x.1 x.2) + + + +theorem stepBoundary_summable {N : ℕ} (hN : 1≤N) (s i : ℤ) : + Summable (boundaryPathWeight (stepBoundaryPorts N hN s) (N+1) i) := by + apply summable_sumProd + · simpa only [boundaryPathWeight_step_bottom] using stepArchWeight_summable hN s i + · apply summable_sumProd + · exact stepBoundary_top_summable hN s i + · have hs := (stepSideWeight_summable s (stripSumsFinite (show 1≤N+1 by omega))).prod_factor i + apply (summable_prod_of_nonneg (fun x=>boundaryPathWeight_nonneg _ _ _ _)).mpr + refine ⟨?_,(hasSum_fintype _).summable⟩ + intro u + cases u + simpa only [boundaryPathWeight_step_side] using hs + + + + + + + +lemma summable_sumProd_left {A B C E : Type*} [NormedAddCommGroup E] [CompleteSpace E] + {f : (A⊕B)×C→E} (hf : Summable f) : + Summable (fun x : A×C=>f (.inl x.1,x.2)) := by + apply hf.comp_injective + intro x y h + exact Prod.ext (Sum.inl.inj (congrArg (fun z : (A⊕B)×C=>z.1) h)) (congrArg (fun z : (A⊕B)×C=>z.2) h) + +lemma summable_sumProd_right {A B C E : Type*} [NormedAddCommGroup E] [CompleteSpace E] + {f : (A⊕B)×C→E} (hf : Summable f) : + Summable (fun x : B×C=>f (.inr x.1,x.2)) := by + apply hf.comp_injective + intro x y h + exact Prod.ext (Sum.inr.inj (congrArg (fun z : (A⊕B)×C=>z.1) h)) (congrArg (fun z : (A⊕B)×C=>z.2) h) + +def stepTurn (i : ℤ) : StepEndpoint→ℤ + | .inl j=>if i≤j then -3 else 3 + | .inr (.inl _)=>0 + | .inr (.inr _)=>1 + +lemma step_turn (N : ℕ) (hN : 1≤N) (s i : ℤ) (x : ExitWord (steppedVertices N s) i) : + turn x.val=stepTurn i (exitPort (stepBoundaryPorts N hN s) x) := by + have ht:=exitPort_terminal (stepBoundaryPorts N hN s) x + generalize hb : exitPort (stepBoundaryPorts N hN s) x=b at ht ⊢ + rcases b with j|(j|u) + · exact bottom_turn i j x.val x.property.1 (ribbonSimple_of_nodup x.property.2.1) + (fun v hv=>(x.property.2.2.1 v hv).1) ht + · exact step_top_turn N hN s i j x.val x.property.1 x.property.2.1 x.property.2.2.1 ht + · exact step_side_turn N s i x.val x.property.1 x.property.2.1 x.property.2.2.1 ht + +lemma stepTurn_sine_right (i : ℤ) (n : ℕ) : + Real.sin ((stepTurn i (.inl (i+(n:ℤ)+1)):ℝ)*lambda) = -Real.sin (3*lambda) := by + have hh : i≤ i+(n:ℤ)+1 := by omega + simp [stepTurn,hh,neg_mul,Real.sin_neg] + +lemma stepTurn_sine_left (i : ℤ) (n : ℕ) : + Real.sin ((stepTurn i (.inl (i-1-(n:ℤ))):ℝ)*lambda) = Real.sin (3*lambda) := by + have hh : ¬(i≤ i-1-(n:ℤ)) := by omega + simp [stepTurn,hh] + +lemma stepArchKernel_self (N : ℕ) (s i : ℤ) : stepArchKernel N s i i=0 := by + simp [stepArchKernel,stepArchWeight,betweenArchWeight] + +lemma step_bottom_imaginary_tsum {N : ℕ} (hN : 1≤N) (s i : ℤ) : + (∑'x : ℤ×List Triangle,stepArchWeight N s i x.1 x.2 * Real.sin ((stepTurn i (.inl x.1):ℝ)*lambda))= + Real.sin (3*lambda)*(stepArchLeft N s i-stepArchRight N s i) := by + have hB:=summable_sumProd_left (boundary_imaginary_summable (stepBoundaryPorts N hN s) + (stepBoundary_summable hN s i) (stepTurn i)) + simp only [boundaryPathWeight_step_bottom] at hB + let f : ℤ→ℝ:=fun j=>stepArchKernel N s i j * Real.sin ((stepTurn i (.inl j):ℝ)*lambda) + have hprod (j : ℤ) : (∑'p,stepArchWeight N s i j p * Real.sin ((stepTurn i (.inl j):ℝ)*lambda))=f j := by + rw [tsum_mul_right]; rfl + have hf : Summable f := hB.prod.congr hprod + have hr := hf.comp_injective (i:=fun n : ℕ=>i+(n:ℤ)+1) (by intro a b hh; dsimp at hh; omega) + have hl := hf.comp_injective (i:=fun n : ℕ=>i-1-(n:ℤ)) (by intro a b hh; dsimp at hh; omega) + have he (n : ℕ) : i+ -((n:ℤ)+1)=i-1-(n:ℤ) := by ring + have hh := tsum_of_add_one_of_neg_add_one (f:=fun j : ℤ=>f (i+j)) + (by simpa only [Function.comp_def,add_assoc] using hr) + (by simpa only [Function.comp_def,he] using hl) + rw [hB.tsum_prod] + simp_rw [hprod] + rw [←(Equiv.addLeft i).tsum_eq f] + change (∑'j : ℤ,f (i+j))=_ + rw [hh] + have hr' (n : ℕ) : f (i+((n:ℤ)+1)) = stepArchKernel N s i (i+(n:ℤ)+1) * (-Real.sin (3*lambda)) := by + simp only [f,←add_assoc,stepTurn_sine_right] + have hl' (n : ℕ) : f (i+ -((n:ℤ)+1)) = stepArchKernel N s i (i-1-(n:ℤ)) * Real.sin (3*lambda) := by + simp only [f,he,stepTurn_sine_left] + have hz : f (i+0)=0 := by simp only [f,add_zero,stepArchKernel_self,zero_mul] + simp_rw [hr',hl',hz,add_zero,tsum_mul_right] + change stepArchRight N s i * (-Real.sin (3*lambda)) + stepArchLeft N s i * Real.sin (3*lambda) = _ + ring + + + +theorem physical_stepped_flux {N : ℕ} (hN : 1≤N) (s : ℤ) : SteppedBoundaryFlux N s := by + intro i + let P:=stepBoundaryPorts N hN s + let F : StepEndpoint×List Triangle→ℝ := + fun x=>boundaryPathWeight P (N+1) i x*Real.sin ((stepTurn i x.1:ℝ)*lambda) + have hs : Summable F := boundary_imaginary_summable P (stepBoundary_summable hN s i) (stepTurn i) + have hf : (∑'x,F x)=0 := boundary_imaginary_flux P (by omega) + (by dsimp [steppedVertices,bottom]; omega) (steppedVertices_bound N s) + (stepBoundary_summable hN s i) (stepTurn i) (step_turn N hN s i) + have hb:=summable_sumProd_left hs + have hn:=summable_sumProd_right hs + have ht:=summable_sumProd_left hn + have hp:=summable_sumProd_right hn + have hsplit : (∑'x : ℤ×List Triangle,F (.inl x.1,x.2)) + + ((∑'x : ℤ×List Triangle,F (.inr (.inl x.1),x.2)) + + (∑'x : Unit×List Triangle,F (.inr (.inr x.1),x.2)))=0 := + (congrArg (fun y : ℝ => (∑'x : ℤ×List Triangle,F (.inl x.1,x.2)) + y) + (tsum_sumProd (f:=fun x : (ℤ⊕Unit)×List Triangle => F (.inr x.1,x.2)) ht hp)).symm.trans ((tsum_sumProd (f:=F) hb hn).symm.trans hf) + have hbot : (∑'x : ℤ×List Triangle,F (.inl x.1,x.2))= + Real.sin (3*lambda)*(stepArchLeft N s i-stepArchRight N s i) := by + simpa only [F,P,boundaryPathWeight_step_bottom] using step_bottom_imaginary_tsum hN s i + have htop : (∑'x : ℤ×List Triangle,F (.inr (.inl x.1),x.2))=0 := by + simp [F,stepTurn] + have hside : (∑'x : Unit×List Triangle,F (.inr (.inr x.1),x.2))= + Real.sin lambda*stepSideKernel N s i := by + rw [hp.tsum_prod] + simp [F,P,stepTurn,boundaryPathWeight_step_side,tsum_mul_left,stepSideKernel,mul_comm] + have hvalue := congrArg₂ (fun a b : ℝ => a+b) hbot + (congrArg₂ (fun a b : ℝ => a+b) htop hside) + have hresult := hvalue.symm.trans hsplit + simpa only [zero_add] using hresult + +end +end CriticalStrip.HoneycombBranch + + + + + +namespace CriticalStrip + + + +theorem critical_strip_mass : CriticalStripMass := by + exact criticalStripMass_of_physical_identities + (fun _ hN => stripSumsFinite hN) + (fun _ hN => HoneycombBranch.physical_strip_flux hN) + (fun _ hN => ⟨0,HoneycombBranch.physical_stepped_flux hN 0⟩) + (fun _ hN => physical_arch_formula hN) + +end CriticalStrip + +end OAI diff --git a/lean/OAI/Combinatorics/StripMass/PhysicalStationarity.lean b/lean/OAI/Combinatorics/StripMass/PhysicalStationarity.lean new file mode 100644 index 0000000000000000000000000000000000000000..32bc892c35d705f737bc5d2c64d8fcf1f095035a --- /dev/null +++ b/lean/OAI/Combinatorics/StripMass/PhysicalStationarity.lean @@ -0,0 +1,555 @@ +import Mathlib +import OAI.Combinatorics.StripMass.GraphPath +import OAI.Combinatorics.StripMass.RealEvaluation + +namespace OAI + +/-! Critical honeycomb strip paths, polynomial identities and crossing mass. -/ + + +namespace CriticalStrip.Diagram +noncomputable section +open scoped BigOperators Classical +open Finset Matrix + + +def angleScalar {n : ℕ} (u : Fin n → ℝ) : ℂ := + angleEvaluation u (polynomialVacuumVector n (empty n)) + + + +def angleVacuum {n : ℕ} (u : Fin n → ℝ) (p : Pairing n) : ℝ := + (angleEvaluation u (polynomialVacuumVector n p)/angleScalar u).re + +def angleNorthSource {n : ℕ} (u : Fin n → ℝ) (p : SourcePairing n) : ℝ := + (angleEvaluation u (polynomialNorthSource n p)/angleScalar u).re + +lemma rationalAt_angle_vacuum {n : ℕ} (u : Fin n → ℝ) (p : Pairing n) : + RationalAt (angleEvaluation u).toRingHom (rationalVacuum n p) + (angleEvaluation u (polynomialVacuumVector n p)) := by + have h:=RationalAt.algebraMap (φ:=(angleEvaluation u).toRingHom) (F:=SpectralField n) + (polynomialVacuumVector n p) + rw [show algebraMap (Laurent n) (SpectralField n) (polynomialVacuumVector n p)=rationalVacuum n p from + polynomialVacuumVector_eval n p] at h + exact h + +lemma rationalAt_angle_column {n : ℕ} (u : Fin n → ℝ) + (hL : ∀i,L (3*lambda-u i)≠0) (p q : Pairing n) : + RationalAt (angleEvaluation u).toRingHom (column (spectralWeights n) p q) + (transfer u p q:ℂ) := by + have hc:=rationalAt_column (spectralWeights n) + (fun i=>(physicalWeights (3*lambda-u i)).map Complex.ofRealHom) + (fun i t=>by simpa using rationalAt_angle_spectralWeights u hL i t) p q + rw [←column_map] at hc + exact hc + +lemma angle_rawVacuum_stationary {n : ℕ} (u : Fin n → ℝ) + (hL : ∀i,L (3*lambda-u i)≠0) : + ((transfer u).map Complex.ofRealHom).mulVec (fun p=>angleEvaluation u (polynomialVacuumVector n p))= + fun p=>angleEvaluation u (polynomialVacuumVector n p) := by + funext p + have hm:=RationalAt.mulVec (φ:=(angleEvaluation u).toRingHom) + (column (spectralWeights n)) ((transfer u).map Complex.ofRealHom) + (rationalVacuum n) (fun p=>angleEvaluation u (polynomialVacuumVector n p)) + (rationalAt_angle_column u hL) (rationalAt_angle_vacuum u) p + rw [rationalVacuum_stationary] at hm + exact hm.unique (rationalAt_angle_vacuum u p) + +lemma angleVacuum_empty {n : ℕ} (u : Fin n → ℝ) (h : angleScalar u≠0) : + angleVacuum u (empty n)=1 := by + change (angleScalar u / angleScalar u).re = 1 + rw [div_self h, Complex.one_re] + +lemma angleVacuum_stationary {n : ℕ} (u : Fin n → ℝ) + (hL : ∀i,L (3*lambda-u i)≠0) : + (transfer u).mulVec (angleVacuum u)=angleVacuum u := by + funext p + have hh:=congrArg (fun z : ℂ=>(z/angleScalar u).re) (congrFun (angle_rawVacuum_stationary u hL) p) + simp only [Matrix.mulVec,dotProduct,Matrix.map_apply,Complex.ofRealHom_eq_coe,Finset.sum_div] at hh + simpa only [Matrix.mulVec,dotProduct,angleVacuum,mul_div_assoc,Complex.re_sum, + Complex.mul_re,Complex.ofReal_re,Complex.ofReal_im,zero_mul,sub_zero] using hh + +lemma angleVacuum_restricted_stationary {n : ℕ} (u : Fin n → ℝ) + (hL : ∀i,L (3*lambda-u i)≠0) (h : angleScalar u≠0) : + (restrictedColumn (fun i=>physicalWeights (3*lambda-u i))).mulVec + (fun p=>angleVacuum u p.val)+injectionColumn (fun i=>physicalWeights (3*lambda-u i))= + fun p=>angleVacuum u p.val := by + funext p + have hh:=congrFun (angleVacuum_stationary u hL) p.val + rw [transfer,column_mulVec_nonempty,angleVacuum_empty u h,mul_one] at hh + simpa only [Pi.add_apply, add_comm] using hh + +lemma continuous_angleScalar {n : ℕ} : Continuous (@angleScalar n) := + continuous_angleEvaluation _ + +lemma continuousOn_angleVacuum {n : ℕ} {S : Set (Fin n → ℝ)} + (h : ∀u∈S,angleScalar u≠0) : ContinuousOn (fun u=>angleVacuum u) S := by + apply continuousOn_pi.mpr + intro p + exact Complex.continuous_re.continuousOn.comp + ((continuous_angleEvaluation _).continuousOn.div continuous_angleScalar.continuousOn h) + (Set.mapsTo_univ _ _) + +lemma continuousOn_angleNorthSource {n : ℕ} {S : Set (Fin n → ℝ)} + (h : ∀u∈S,angleScalar u≠0) : ContinuousOn (fun u=>angleNorthSource u) S := by + apply continuousOn_pi.mpr + intro p + exact Complex.continuous_re.continuousOn.comp + ((continuous_angleEvaluation _).continuousOn.div continuous_angleScalar.continuousOn h) + (Set.mapsTo_univ _ _) + +section +variable {R F K : Type*} [CommRing R] [Field F] [Field K] + [Algebra R F] {φ : R →+* K} + +lemma rationalAt_lastCoefficient [IsDomain R] [IsFractionRing R F] + {n : ℕ} (w : Fin n → Tile → F) (v : Fin n → Tile → K) + (h : ∀i t,RationalAt φ (w i t) (v i t)) (p q : Pairing (n+1)) : + RationalAt φ (lastCoefficient w p q) (lastCoefficient v p q) := by + unfold lastCoefficient + apply RationalAt.sum + intro t _ + split_ifs + · exact RationalAt.prod _ _ _ (fun i _=>h i (t i)) + · exact RationalAt.zero +end + +lemma rationalAt_angle_sourceTransfer {n : ℕ} (u : Fin n → ℝ) + (hL : ∀i,L (3*lambda-u i)≠0) (p q : SourcePairing n) : + RationalAt (angleEvaluation u).toRingHom + (sourceTransfer (fun i=>(spectralWeights n i).tile) p q) + ((sourceTransfer (fun i=>(physicalWeights (3*lambda-u i)).tile) p q : ℝ):ℂ) := by + have hh:=rationalAt_lastCoefficient (fun i=>(spectralWeights n i).tile) + (fun i t=>Complex.ofRealHom ((physicalWeights (3*lambda-u i)).tile t)) + (rationalAt_angle_spectralWeights u hL) p.val q.val + rw [lastCoefficient_map Complex.ofRealHom] at hh + exact hh + +lemma rationalAt_angle_northSource {n : ℕ} (u : Fin n → ℝ) + (hL : ∀i,L (3*lambda-u i)≠0) (p : SourcePairing n) (q : Pairing n) : + RationalAt (angleEvaluation u).toRingHom + (northSource (fun i=>(spectralWeights n i).tile) p q) + ((northSource (fun i=>(physicalWeights (3*lambda-u i)).tile) p q : ℝ):ℂ) := by + have hh:=rationalAt_lastCoefficient (fun i=>(spectralWeights n i).tile) + (fun i t=>Complex.ofRealHom ((physicalWeights (3*lambda-u i)).tile t)) + (rationalAt_angle_spectralWeights u hL) p.val q.padTop + rw [lastCoefficient_map Complex.ofRealHom] at hh + exact hh + +lemma polynomialNorthSource_rational_equation (n : ℕ) : + (sourceTransfer (fun i=>(spectralWeights n i).tile)).mulVec + (fun p=>evalLaurent (polynomialNorthSource n p))+ + (northSource (fun i=>(spectralWeights n i).tile)).mulVec (rationalVacuum n)= + fun p=>evalLaurent (polynomialNorthSource n p) := by + have hs: (1-sourceTransfer (fun i=>(spectralWeights n i).tile)).mulVec (integratedNorthSource n)= + (northSource (fun i=>(spectralWeights n i).tile)).mulVec (normalizedVacuum (spectralWeights n)) := by + rw [integratedNorthSource,Matrix.mulVec_mulVec,Matrix.mul_nonsing_inv _ + (isUnit_iff_ne_zero.mpr (spectral_source_regular n)),Matrix.one_mulVec] + have ht:=congrArg (fun v=>spectralNormalization n • v) hs + rw [Matrix.sub_mulVec,Matrix.one_mulVec] at ht + simp only [smul_sub,←Matrix.mulVec_smul] at ht + have he : (fun p=>evalLaurent (polynomialNorthSource n p))= + spectralNormalization n • integratedNorthSource n := funext (polynomialNorthSource_eval n) + rw [he] + change _+(northSource _).mulVec (spectralNormalization n • normalizedVacuum (spectralWeights n))=_ + rw [←ht] + abel + +lemma angle_rawNorthSource_equation {n : ℕ} (u : Fin n → ℝ) + (hL : ∀i,L (3*lambda-u i)≠0) : + ((sourceTransfer (fun i=>(physicalWeights (3*lambda-u i)).tile)).map Complex.ofRealHom).mulVec + (fun p=>angleEvaluation u (polynomialNorthSource n p))+ + ((northSource (fun i=>(physicalWeights (3*lambda-u i)).tile)).map Complex.ofRealHom).mulVec + (fun p=>angleEvaluation u (polynomialVacuumVector n p))= + fun p=>angleEvaluation u (polynomialNorthSource n p) := by + funext p + have hm:=RationalAt.mulVec (φ:=(angleEvaluation u).toRingHom) + (sourceTransfer (fun i=>(spectralWeights n i).tile)) + ((sourceTransfer (fun i=>(physicalWeights (3*lambda-u i)).tile)).map Complex.ofRealHom) + (fun q=>evalLaurent (polynomialNorthSource n q)) + (fun q=>angleEvaluation u (polynomialNorthSource n q)) + (rationalAt_angle_sourceTransfer u hL) (fun q=>RationalAt.algebraMap _) p + have hn:=RationalAt.mulVec (φ:=(angleEvaluation u).toRingHom) + (northSource (fun i=>(spectralWeights n i).tile)) + ((northSource (fun i=>(physicalWeights (3*lambda-u i)).tile)).map Complex.ofRealHom) + (rationalVacuum n) (fun q=>angleEvaluation u (polynomialVacuumVector n q)) + (rationalAt_angle_northSource u hL) (rationalAt_angle_vacuum u) p + have hh:=hm.add hn + have he:=congrFun (polynomialNorthSource_rational_equation n) p + simp only [Pi.add_apply] at he + rw [he] at hh + exact hh.unique (RationalAt.algebraMap _) + +lemma angleNorthSource_stationary {n : ℕ} (u : Fin n → ℝ) + (hL : ∀i,L (3*lambda-u i)≠0) : + (sourceTransfer (fun i=>(physicalWeights (3*lambda-u i)).tile)).mulVec (angleNorthSource u)+ + (northSource (fun i=>(physicalWeights (3*lambda-u i)).tile)).mulVec (angleVacuum u)= + angleNorthSource u := by + funext p + have hh:=congrArg (fun z : ℂ=>(z/angleScalar u).re) (congrFun (angle_rawNorthSource_equation u hL) p) + simpa only [Pi.add_apply,Matrix.mulVec,dotProduct,Matrix.map_apply,Complex.ofRealHom_eq_coe, + add_div,Finset.sum_div,mul_div_assoc,Complex.add_re,Complex.re_sum,Complex.mul_re, + Complex.ofReal_re,Complex.ofReal_im,zero_mul,sub_zero,angleNorthSource,angleVacuum] using hh + + + + + + + + + +namespace Pairing + +structure ArcAddition {n : ℕ} (p q : Pairing n) (a b : Fin n) : Prop where + lt : a < b + vacant : ∀ i, a ≤ i → i ≤ b → ¬ p.Occupied i + adj : ∀ i j, q.Adj i j ↔ + (i=a ∧ j=b) ∨ (i=b ∧ j=a) ∨ p.Adj i j + +lemma ArcAddition.occupied {n : ℕ} {p q : Pairing n} {a b : Fin n} + (h : ArcAddition p q a b) (i : Fin n) : + q.Occupied i ↔ i=a ∨ i=b ∨ p.Occupied i := by + simp only [Occupied,h.adj] + aesop + +lemma ArcAddition.old {n : ℕ} {p q : Pairing n} {a b i j : Fin n} + (h : ArcAddition p q a b) (hp : p.Adj i j) : q.Adj i j := + (h.adj i j).mpr (Or.inr (Or.inr hp)) + +lemma ArcAddition.arc {n : ℕ} {p q : Pairing n} {a b : Fin n} + (h : ArcAddition p q a b) : q.Adj a b := (h.adj a b).mpr (Or.inl ⟨rfl,rfl⟩) + +end Pairing + + + +def arcColumn {n : ℕ} (p : Pairing n) (a b : Fin n) : Configuration n := fun i=> + if i=a then .cup else if i=b then .vertical₀ else + if a < i ∧ i < b then .diagonal₀ else if p.Occupied i then .diagonal₁ else .vacant + +namespace ArcColumn +variable {n : ℕ} {p q : Pairing n} {a b : Fin n} (h : Pairing.ArcAddition p q a b) + +include h + +omit h in +lemma at_a : arcColumn p a b a=.cup := by simp [arcColumn] +lemma at_b : arcColumn p a b b=.vertical₀ := by simp [arcColumn,ne_of_gt h.lt] +omit h in +lemma at_inside (i : Fin n) (ha : a < i) (hb : i < b) : arcColumn p a b i=.diagonal₀ := by + simp [arcColumn,ne_of_gt ha,ne_of_lt hb,ha,hb] +lemma at_old (i : Fin n) (hi : p.Occupied i) : arcColumn p a b i=.diagonal₁ := by + have hn : ¬(a ≤ i ∧ i ≤ b) := fun hh=>h.vacant i hh.1 hh.2 hi + have hab:=h.lt + simp only [arcColumn] + split_ifs <;> first | rfl | omega + +lemma west (i : Fin n) : (arcColumn p a b i).Occupied 1 ↔ p.Occupied i := by + have ha:=h.lt + have hv:=h.vacant i + unfold arcColumn + split_ifs <;> simp_all [Tile.Occupied,Tile.Adj,Tile.edges] + all_goals apply hv <;> omega + +lemma east (i : Fin n) : (arcColumn p a b i).Occupied 2 ↔ q.Occupied i := by + rw [h.occupied] + have ha:=h.lt + have hv:=h.vacant i + unfold arcColumn + split_ifs <;> simp_all [Tile.Occupied,Tile.Adj,Tile.edges] + all_goals apply hv <;> omega + +lemma south (i : Fin n) : (arcColumn p a b i).Occupied 0 ↔ a < i ∧ i ≤ b := by + have ha:=h.lt + unfold arcColumn + split_ifs <;> simp_all [Tile.Occupied,Tile.Adj,Tile.edges] <;> omega + +lemma north (i : Fin n) : (arcColumn p a b i).Occupied 3 ↔ a ≤ i ∧ i < b := by + have ha:=h.lt + unfold arcColumn + split_ifs <;> simp_all [Tile.Occupied,Tile.Adj,Tile.edges] <;> omega + +omit h in +lemma tile_edge {i : Fin n} {r s : Fin 4} (ht : (arcColumn p a b i).Adj r s) : + Wiring p (arcColumn p a b) (i,r) (i,s) := Or.inl ⟨rfl,ht⟩ + +lemma reach_north (i : Fin n) (hai : a ≤ i) (hib : i < b) : + Reach p (arcColumn p a b) (a,2) (i,3) := by + induction k : i.val using Nat.strong_induction_on generalizing i with + | h k ih => + by_cases he : i=a + · subst i + exact .single (tile_edge (by simp [at_a,Tile.Adj,Tile.edges])) + · have hip : 0 < i.val := by omega + let j : Fin n:=⟨i.val-1,by omega⟩ + have hji : j.val+1=i.val := by dsimp [j]; omega + have hj : a ≤ j ∧ j < b := by dsimp [j]; constructor <;> omega + have hr:=ih j.val (by dsimp [j]; omega) j hj.1 hj.2 rfl + have hg : Wiring p (arcColumn p a b) (j,3) (i,0) := + Or.inr (Or.inr (Or.inl ⟨rfl,rfl,hji,(north h j).mpr hj⟩)) + have hi : arcColumn p a b i=.diagonal₀ := at_inside i (by omega) hib + exact (hr.tail hg).tail (tile_edge (by simp [hi,Tile.Adj,Tile.edges])) + +lemma reach_south (i : Fin n) (hai : a < i) (hib : i ≤ b) : + Reach p (arcColumn p a b) (a,2) (i,0) := by + have hip : 0 < i.val := by omega + let j : Fin n:=⟨i.val-1,by omega⟩ + have hji : j.val+1=i.val := by dsimp [j]; omega + have hj : a ≤ j ∧ j < b := by dsimp [j]; constructor <;> omega + exact (reach_north h j hj.1 hj.2).tail + (Or.inr (Or.inr (Or.inl ⟨rfl,rfl,hji,(north h j).mpr hj⟩))) + +lemma reach_arc : Reach p (arcColumn p a b) (a,2) (b,2) := + (reach_south h b h.lt le_rfl).tail (tile_edge (by simp [at_b h,Tile.Adj,Tile.edges])) + +lemma reach_old (i : Fin n) (hi : p.Occupied i) : + Reach p (arcColumn p a b) (i,1) (i,2) := + .single (tile_edge (by simp [at_old h i hi,Tile.Adj,Tile.edges])) + +def label (a : Fin n) (v : Vertex n) : Fin n := if v.2=0 ∨ v.2=3 then a else v.1 + +lemma edge_label {v w : Vertex n} (hw : Wiring p (arcColumn p a b) v w) : + label a v=label a w ∨ q.Adj (label a v) (label a w) := by + rcases v with ⟨i,r⟩; rcases w with ⟨j,s⟩ + rcases hw with ⟨rfl,ht⟩ | ⟨rfl,rfl,hp⟩ | ⟨rfl,rfl,_,_⟩ | ⟨rfl,rfl,_,_⟩ + · by_cases hi : i=a + · subst i + simp only [at_a,Tile.Adj,Tile.edges,mem_singleton,Prod.mk.injEq] at ht + rcases ht with ⟨rfl,rfl⟩ | ⟨rfl,rfl⟩ <;> simp [label] + · by_cases hj : i=b + · subst i + rw [at_b h] at ht + simp only [Tile.Adj,Tile.edges,mem_singleton,Prod.mk.injEq] at ht + rcases ht with ⟨rfl,rfl⟩ | ⟨rfl,rfl⟩ + · exact Or.inr h.arc + · exact Or.inr (Pairing.adj_symm h.arc) + · by_cases hm : a < i ∧ i < b + · rw [at_inside i hm.1 hm.2] at ht + simp only [Tile.Adj,Tile.edges,mem_singleton,Prod.mk.injEq] at ht + rcases ht with ⟨rfl,rfl⟩ | ⟨rfl,rfl⟩ <;> simp [label] + · by_cases hp : p.Occupied i + · rw [at_old h i hp] at ht + simp only [Tile.Adj,Tile.edges,mem_singleton,Prod.mk.injEq] at ht + rcases ht with ⟨rfl,rfl⟩ | ⟨rfl,rfl⟩ <;> simp [label] + · simp [arcColumn,hi,hj,hm,hp] at ht + · exact Or.inr (h.old hp) + · exact Or.inl rfl + · exact Or.inl rfl + +lemma reach_label {v w : Vertex n} (hr : Reach p (arcColumn p a b) v w) : + label a v=label a w ∨ q.Adj (label a v) (label a w) := by + induction hr with + | refl => exact Or.inl rfl + | @tail w z _ hw ih => + obtain he | he := edge_label h hw + · simpa only [←he] using ih + obtain hi | hi := ih + · exact Or.inr (hi ▸ he) + · exact Or.inl (Pairing.adj_unique (Pairing.adj_symm hi) he) + +lemma no_loop (v w : Vertex n) (hw : Wiring p (arcColumn p a b) v w) : + ∃ j, q.Occupied j ∧ Reach p (arcColumn p a b) v (j,2) := by + have ha : q.Occupied a:=⟨b,h.arc⟩ + have hb : q.Occupied b:=⟨a,Pairing.adj_symm h.arc⟩ + rcases v with ⟨i,r⟩; rcases w with ⟨j,s⟩ + rcases hw with ⟨rfl,ht⟩ | ⟨rfl,rfl,hp⟩ | ⟨rfl,rfl,_,hn⟩ | ⟨rfl,rfl,hji,hn⟩ + · by_cases hi : i=a + · subst i + simp only [at_a,Tile.Adj,Tile.edges,mem_singleton,Prod.mk.injEq] at ht + rcases ht with ⟨rfl,rfl⟩ | ⟨rfl,rfl⟩ + · exact ⟨a,ha,.refl⟩ + · exact ⟨a,ha,reach_symm (reach_north h a le_rfl h.lt)⟩ + · by_cases hj : i=b + · subst i + rw [at_b h] at ht + simp only [Tile.Adj,Tile.edges,mem_singleton,Prod.mk.injEq] at ht + rcases ht with ⟨rfl,rfl⟩ | ⟨rfl,rfl⟩ + · exact ⟨b,hb,.single (tile_edge (by simp [at_b h,Tile.Adj,Tile.edges]))⟩ + · exact ⟨b,hb,.refl⟩ + · by_cases hm : a < i ∧ i < b + · rw [at_inside i hm.1 hm.2] at ht + simp only [Tile.Adj,Tile.edges,mem_singleton,Prod.mk.injEq] at ht + rcases ht with ⟨rfl,rfl⟩ | ⟨rfl,rfl⟩ + · exact ⟨a,ha,reach_symm (reach_south h i hm.1 hm.2.le)⟩ + · exact ⟨a,ha,reach_symm (reach_north h i hm.1.le hm.2)⟩ + · by_cases hp : p.Occupied i + · rw [at_old h i hp] at ht + simp only [Tile.Adj,Tile.edges,mem_singleton,Prod.mk.injEq] at ht + rcases ht with ⟨rfl,rfl⟩ | ⟨rfl,rfl⟩ + · exact ⟨i,(h.occupied i).mpr (Or.inr (Or.inr hp)),reach_old h i hp⟩ + · exact ⟨i,(h.occupied i).mpr (Or.inr (Or.inr hp)),.refl⟩ + · simp [arcColumn,hi,hj,hm,hp] at ht + · exact ⟨i,⟨j,h.old hp⟩,reach_old h i ⟨j,hp⟩⟩ + · obtain ⟨hi,hb'⟩:=(north h i).mp hn + exact ⟨a,ha,reach_symm (reach_north h i hi hb')⟩ + · obtain ⟨hj,hb'⟩:=(north h j).mp hn + change j.val+1=i.val at hji + exact ⟨a,ha,reach_symm (reach_south h i (by omega) (by omega))⟩ + +lemma realizes : Realizes p q (arcColumn p a b) := by + refine ⟨west h,east h,?_,?_,?_,no_loop h,?_⟩ + · intro i hi ht + have hh:=(south h i).mp ht + omega + · intro i hi ht + have hh:=(north h i).mp ht + have:=b.isLt + omega + · intro i j hij + rw [north h i,south h j] + omega + · intro i j hij + constructor + · intro ht + rcases (h.adj i j).mp ht with ⟨rfl,rfl⟩ | ⟨rfl,rfl⟩ | hp + · exact reach_arc h + · exact reach_symm (reach_arc h) + · exact ((reach_symm (reach_old h i ⟨j,hp⟩)).tail + (Or.inr (Or.inl ⟨rfl,rfl,hp⟩))).trans (reach_old h j ⟨i,Pairing.adj_symm hp⟩) + · intro hr + have hh:=reach_label h hr + simpa [label,hij] using hh + +end ArcColumn + +namespace Pairing + + + +lemma exists_arcAddition {n : ℕ} (q : Pairing n) (hq : q ≠ empty n) : + ∃ (p : Pairing n) (a b : Fin n), p.val.card < q.val.card ∧ ArcAddition p q a b := by + have hne : q.val.Nonempty := by + apply Finset.nonempty_iff_ne_empty.mpr + intro he + exact hq (Subtype.ext he) + obtain ⟨⟨a,b⟩,hab,hmin⟩:=Finset.exists_min_image q.val + (fun e : Fin n × Fin n=>e.2.val-e.1.val) hne + have hlt : a < b:=q.property.1 _ hab + have hqab : q.Adj a b:=Or.inl hab + refine ⟨q.omitTwo a b,a,b,?_,hlt,?_,?_⟩ + · apply Finset.card_lt_card + apply Finset.ssubset_iff_subset_ne.mpr + refine ⟨Finset.filter_subset _ _,?_⟩ + intro he + have hh : (a,b) ∈ (q.omitTwo a b).val:=he ▸ hab + simp [omitTwo] at hh + · intro i hai hib ⟨j,hij⟩ + obtain ⟨hij,hia,hib',hja,hjb⟩:=(omitTwo_adj q a b i j).mp hij + have hai' : a < i:=lt_of_le_of_ne hai (Ne.symm hia) + have hib'' : i < b:=lt_of_le_of_ne hib hib' + rcases hij with hf | hf + · have hf_lt := q.property.1 _ hf + have hc := q.property.2.2 _ hab _ hf + have hm := hmin _ hf + dsimp only at hf_lt hc hm + omega + · have hf_lt := q.property.1 _ hf + have hc := q.property.2.2 _ hf _ hab + have hm := hmin _ hf + dsimp only at hf_lt hc hm + omega + · intro i j + rw [omitTwo_adj] + constructor + · intro hij + by_cases hia : i=a + · subst i + exact Or.inl ⟨rfl,adj_unique hij hqab⟩ + by_cases hib : i=b + · subst i + exact Or.inr (Or.inl ⟨rfl,adj_unique hij (adj_symm hqab)⟩) + have hja : j ≠ a:= by + rintro rfl + exact hib (adj_unique (adj_symm hij) hqab) + have hjb : j ≠ b:= by + rintro rfl + exact hia (adj_unique (adj_symm hij) (adj_symm hqab)) + exact Or.inr (Or.inr ⟨hij,hia,hib,hja,hjb⟩) + · rintro (⟨rfl,rfl⟩ | ⟨rfl,rfl⟩ | ⟨hh,_⟩) + · exact hqab + · exact adj_symm hqab + · exact hh + +end Pairing + + + +def ColumnNonnegative {n : ℕ} (w : Fin n → Weights ℝ) : Prop := + ∀ (p q : Pairing n) (t : Configuration n), Realizes p q t → + 0 ≤ ∏ i, (w i).tile (t i) + +lemma ColumnNonnegative.column {n : ℕ} {w : Fin n → Weights ℝ} + (hw : ColumnNonnegative w) : PositiveMatrix.Nonnegative (column w) := by + intro q p + apply Finset.sum_nonneg + intro t _ + split_ifs with ht + · exact hw p q t ht + · exact le_rfl + +lemma ColumnNonnegative.restricted {n : ℕ} {w : Fin n → Weights ℝ} + (hw : ColumnNonnegative w) : PositiveMatrix.Nonnegative (restrictedColumn w) := + fun p q=>hw.column p.val q.val + +lemma ColumnNonnegative.injection {n : ℕ} {w : Fin n → Weights ℝ} + (hw : ColumnNonnegative w) : ∀ p, 0 ≤ injectionColumn w p := + fun p=>hw.column p.val (empty n) + +lemma arcColumn_weight_pos {n : ℕ} (w : Fin n → Weights ℝ) + (hA : ∀ i,0 < (w i).A) (hB : ∀ i,0 < (w i).B) + (hU : ∀ i,i.val+1 < n → 0 < (w i).U) + {p q : Pairing n} {a b : Fin n} (h : Pairing.ArcAddition p q a b) : + 0 < ∏ i, (w i).tile (arcColumn p a b i) := by + apply Finset.prod_pos + intro i _ + have hab:=h.lt + have hb:=b.isLt + unfold arcColumn + split_ifs <;> simp only [Weights.tile] + · exact hU i (by subst i; omega) + · exact hA i + · exact hB i + · exact hB i + · exact zero_lt_one + +lemma column_arc_pos {n : ℕ} (w : Fin n → Weights ℝ) (hw : ColumnNonnegative w) + (hA : ∀ i,0 < (w i).A) (hB : ∀ i,0 < (w i).B) + (hU : ∀ i,i.val+1 < n → 0 < (w i).U) + {p q : Pairing n} {a b : Fin n} (h : Pairing.ArcAddition p q a b) : + 0 < column w q p := by + have hl : (∏ i,(w i).tile (arcColumn p a b i)) ≤ column w q p := by + have := Finset.single_le_sum (s:=Finset.univ) + (f:=fun t : Configuration n=>if Realizes p q t then ∏ i,(w i).tile (t i) else 0) + (fun t _=>by split_ifs with ht; exact hw p q t ht; exact le_rfl) + (Finset.mem_univ (arcColumn p a b)) + simpa only [ite_eq_left (ArcColumn.realizes h),column] using this + exact (arcColumn_weight_pos w hA hB hU h).trans_le hl + + + +theorem column_accessible {n : ℕ} (w : Fin n → Weights ℝ) (hw : ColumnNonnegative w) + (hA : ∀ i,0 < (w i).A) (hB : ∀ i,0 < (w i).B) + (hU : ∀ i,i.val+1 < n → 0 < (w i).U) : + PositiveMatrix.Accessible (restrictedColumn w) (injectionColumn w) := by + intro q + induction k : q.val.val.card using Nat.strong_induction_on generalizing q with + | h k ih => + obtain ⟨p,a,b,hcard,hadd⟩:=Pairing.exists_arcAddition q.val q.property + have hpq:=column_arc_pos w hw hA hB hU hadd + by_cases hp : p=empty n + · subst p + refine ⟨0,?_⟩ + simpa only [pow_zero,Matrix.one_mulVec,injectionColumn] using hpq + · let p' : NonemptyPairing n:=⟨p,hp⟩ + obtain ⟨m,hm⟩:=ih p.val.card (by omega) p' rfl + refine ⟨m+1,?_⟩ + rw [pow_succ',←Matrix.mulVec_mulVec] + exact (mul_pos hpq hm).trans_le + (PositiveMatrix.entry_mul_le_mulVec hw.restricted + ((hw.restricted.pow m).mulVec hw.injection) q p') + +end +end CriticalStrip.Diagram + +end OAI diff --git a/lean/OAI/Combinatorics/StripMass/PolynomialDegrees.lean b/lean/OAI/Combinatorics/StripMass/PolynomialDegrees.lean new file mode 100644 index 0000000000000000000000000000000000000000..37e812e1610fe790924cf4092118db4a60d0ef1b --- /dev/null +++ b/lean/OAI/Combinatorics/StripMass/PolynomialDegrees.lean @@ -0,0 +1,426 @@ +import Mathlib +import OAI.Combinatorics.StripMass.Trigonometry + +namespace OAI + +/-! Critical honeycomb strip paths, polynomial identities and crossing mass. -/ + +namespace CriticalStrip +noncomputable section +section ProjectionAlgebra +open Polynomial Set MeasureTheory Filter +open scoped Topology BigOperators +theorem natDegree_le_of_mem_degreeLT {N : ℕ} {p : Polynomial ℝ} + (hp : p ∈ degreeLT ℝ (N + 1)) : p.natDegree ≤ N := by + by_cases hp0 : p = 0 + · simp [hp0] + exact Nat.lt_succ_iff.1 ((natDegree_lt_iff_degree_lt hp0).2 (mem_degreeLT.1 hp)) + + + +theorem homogeneous_exists_degree (N : ℕ) (hN : 1 ≤ N) : + ∃ g : Polynomial ℝ, g ≠ 0 ∧ g.natDegree = N ∧ HasProjection N (homogeneousQ N g) := by + have hdim : Module.finrank ℝ (degreeLT ℝ (3 * N + 1)) < Module.finrank ℝ (ProjectionSpace N) := by + rw [Module.finrank_eq_card_basis (degreeLT.basis ℝ (3 * N + 1)), Fintype.card_fin, + projectionSpace_finrank] + omega + obtain ⟨t, ht, htne⟩ := (Submodule.ne_bot_iff _).1 + (LinearMap.ker_ne_bot_of_finrank_lt (f := projectionRemainder N) hdim) + have ht0 : projectionMap N t %ₘ rootPolynomial N = 0 := by + have hv := congrArg Subtype.val (LinearMap.mem_ker.1 ht) + exact hv + obtain ⟨g, hg⟩ := (modByMonic_eq_zero_iff_dvd (rootPolynomial_monic N)).1 ht0 + have hP : t.1.val.natDegree ≤ N := natDegree_le_of_mem_degreeLT t.1.property + have hJ : t.2.1.val.natDegree ≤ N := natDegree_le_of_mem_degreeLT t.2.1.property + have hE : t.2.2.val.degree < (N : WithBot ℕ) := mem_degreeLT.1 t.2.2.property + have hQ : homogeneousQ N g = t.1.val.comp harmonicCoordinate + X * t.2.1.val.comp harmonicCoordinate + + X ^ 2 * t.2.2.val.comp harmonicCoordinate := hg.symm + have hg0 : g ≠ 0 := by + intro hzero + have hz := homogeneous_projection_zero N hN g t.1.val t.2.1.val t.2.2.val + (by simp [hzero]) hP hJ hE hQ + apply htne + apply Prod.ext + · exact Subtype.ext hz.1 + · exact Prod.ext (Subtype.ext hz.2.1) (Subtype.ext hz.2.2.1) + have hgn : g.natDegree ≤ N := by + have hd := projection_natDegree_le N hN t.1.val t.2.1.val t.2.2.val hP hJ hE + rw [← hQ] at hd + change (rootPolynomial N * g).natDegree ≤ 4 * N + 1 at hd + rw [natDegree_mul (rootPolynomial_monic N).ne_zero hg0, rootPolynomial_natDegree] at hd + omega + have hgeq : g.natDegree = N := by + by_contra hne + have hgl : g.degree < (N : WithBot ℕ) := (natDegree_lt_iff_degree_lt hg0).1 (by omega) + exact hg0 (homogeneous_projection_zero N hN g t.1.val t.2.1.val t.2.2.val + hgl hP hJ hE hQ).2.2.2 + exact ⟨g, hg0, hgeq, ⟨t.1.val, t.2.1.val, t.2.2.val, hP, hJ, hE, hQ⟩⟩ + + + + theorem HasProjection.smul {N : ℕ} {Q : Polynomial ℝ} (hQ : HasProjection N Q) (a : ℝ) : + HasProjection N (a • Q) := by + obtain ⟨P, J, E, hP, hJ, hE, he⟩ := hQ + refine ⟨a • P, a • J, a • E, ?_, ?_, (degree_smul_le a E).trans_lt hE, ?_⟩ + · exact (natDegree_smul_le a P).trans hP + · exact (natDegree_smul_le a J).trans hJ + · simp only [he, smul_add, smul_comp, mul_smul_comm] + + theorem HasProjection.sub {N : ℕ} {Q R : Polynomial ℝ} + (hQ : HasProjection N Q) (hR : HasProjection N R) : HasProjection N (Q - R) := by + obtain ⟨P, J, E, hP, hJ, hE, he⟩ := hQ + obtain ⟨P', J', E', hP', hJ', hE', he'⟩ := hR + refine ⟨P-P', J-J', E-E', (natDegree_sub_le _ _).trans (max_le hP hP'), + (natDegree_sub_le _ _).trans (max_le hJ hJ'), + (degree_sub_le _ _).trans_lt (max_lt hE hE'), ?_⟩ + simp only [he, he', sub_comp] + ring + + + +theorem homogeneous_monic_unique (N : ℕ) (hN : 1 ≤ N) : + ∃! g : Polynomial ℝ, MonicProblem N g := by + obtain ⟨q, hq0, hqn, hqproj⟩ := homogeneous_exists_degree N hN + let g := q.leadingCoeff⁻¹ • q + have hgmonic : g.Monic := by + simpa only [g, smul_eq_C_mul, mul_comm] using monic_mul_leadingCoeff_inv hq0 + have hgdeg : g.natDegree = N := by + change (q.leadingCoeff⁻¹ • q).natDegree = N + rw [natDegree_smul q (inv_ne_zero (leadingCoeff_ne_zero.mpr hq0)), hqn] + have hgproj : HasProjection N (homogeneousQ N g) := by + convert hqproj.smul q.leadingCoeff⁻¹ using 1 + simp only [g, homogeneousQ, mul_smul_comm] + have hg : MonicProblem N g := ⟨hgmonic, hgdeg, hgproj⟩ + refine ⟨g, hg, ?_⟩ + intro p hp + have hd : p.degree = (N : WithBot ℕ) := by rw [degree_eq_natDegree hp.1.ne_zero, hp.2.1] + have hdg : g.degree = (N : WithBot ℕ) := by rw [degree_eq_natDegree hgmonic.ne_zero, hgdeg] + have hl : (p - g).degree < (N : WithBot ℕ) := by + simpa only [hd] using degree_sub_lt_left (hd.trans hdg.symm) hp.1.ne_zero (hp.1.trans hgmonic.symm) + have hproj : HasProjection N (homogeneousQ N (p - g)) := by + simpa only [homogeneousQ, mul_sub] using hp.2.2.sub hgproj + obtain ⟨P, J, E, hP, hJ, hE, hQ⟩ := hproj + exact sub_eq_zero.mp (homogeneous_projection_zero N hN (p - g) P J E hl hP hJ hE hQ).2.2.2 + +end ProjectionAlgebra + +open Polynomial Set MeasureTheory Filter Matrix +open scoped Topology BigOperators + + + +def perturbedRoot {N : ℕ} (a : Fin N → ℝ) : Polynomial ℝ := + (X - Polynomial.C C) * ∏ i, ((X - Polynomial.C (a i)) * + (X^2 - Polynomial.C (2*d*a i)*X + Polynomial.C ((a i)^2-d^2))) +def PerturbedMonicProblem {N : ℕ} (a : Fin N → ℝ) (g : Polynomial ℝ) : Prop := + g.Monic ∧ g.natDegree = N ∧ HasProjection N (perturbedRoot a * g) + +theorem paired_homogeneous : + X^2 - Polynomial.C (2*d*C)*X + Polynomial.C (C^2-d^2) = + (X - Polynomial.C C)*(X-Polynomial.C c) := by + have ha := Real.cos_add (2*lambda) lambda + have hs := Real.cos_sub (2*lambda) lambda + rw [show 2*lambda+lambda=3*Real.pi/8 by unfold lambda; ring] at ha + rw [show 2*lambda-lambda=lambda by ring] at hs + change c = d*C - Real.sin (2*lambda)*Real.sin lambda at ha + change C = d*C + Real.sin (2*lambda)*Real.sin lambda at hs + have hc : c+C=2*d*C := by linarith + have hd : d = Real.sqrt 2 / 2 := by + rw [d, lambda, show 2*(Real.pi/8)=Real.pi/4 by ring, Real.cos_pi_div_four] + have hd2 : d^2 = 1/2 := by rw [hd]; nlinarith [Real.sq_sqrt (by norm_num : (0 : ℝ) ≤ 2)] + have hC2 : C^2=(1+d)/2 := by + have hh := Real.cos_two_mul lambda + change d = 2*C^2-1 at hh + linarith + have hprod : C^2-d^2=C*c := by + have hh : c=(2*d-1)*C := by nlinarith [hc] + rw [hh] + nlinarith [hC2, hd2, mul_assoc d (C^2) 2] + rw [← hc, hprod, map_add, map_mul] + ring + + theorem perturbedRoot_homogeneous (N : ℕ) : + perturbedRoot (fun _ : Fin N => C) = rootPolynomial N := by + simp only [perturbedRoot, paired_homogeneous, Finset.prod_const, Finset.card_univ, Fintype.card_fin] + rw [rootPolynomial, mul_pow, mul_pow] + rw [show 2*N+1=N+N+1 by omega, pow_add, pow_add] + ring + +theorem perturbedRoot_natDegree_le {N : ℕ} (a : Fin N → ℝ) : + (perturbedRoot a).natDegree ≤ 3*N+1 := by + have hp : ∀ i, ((X - Polynomial.C (a i)) * + (X^2 - Polynomial.C (2*d*a i)*X + Polynomial.C ((a i)^2-d^2))).natDegree ≤ 3 := by + intro i + apply (natDegree_mul_le).trans + have hq : (X^2 - Polynomial.C (2*d*a i)*X + Polynomial.C ((a i)^2-d^2)).natDegree ≤ 2 := by + apply (natDegree_add_le _ _).trans + apply max_le + · apply (natDegree_sub_le _ _).trans + apply max_le + · simp + · exact (natDegree_mul_le).trans (by simp only [natDegree_C, natDegree_X]; omega) + · simp only [natDegree_C]; omega + simpa only [natDegree_X_sub_C] using Nat.add_le_add_left hq 1 + apply (natDegree_mul_le).trans + have hprod := natDegree_prod_le (s := Finset.univ) (f := fun i : Fin N => + (X - Polynomial.C (a i)) * (X^2 - Polynomial.C (2*d*a i)*X + Polynomial.C ((a i)^2-d^2))) + have hh : (∏ i : Fin N, (X - Polynomial.C (a i)) * + (X^2 - Polynomial.C (2*d*a i)*X + Polynomial.C ((a i)^2-d^2))).natDegree ≤ N*3 := + hprod.trans (by simpa only [Finset.sum_const, Finset.card_univ, Fintype.card_fin, nsmul_eq_mul, Nat.cast_id] using Finset.sum_le_sum (s := Finset.univ) (fun i _ => hp i)) + simpa [perturbedRoot, natDegree_X_sub_C, Nat.mul_comm, Nat.add_comm] using Nat.add_le_add_left hh 1 + +abbrev SystemSpace (N : ℕ) := ProjectionSpace N × degreeLT ℝ N +abbrev SystemIndex (N : ℕ) := (Fin (N+1) ⊕ (Fin (N+1) ⊕ Fin N)) ⊕ Fin N +def systemBasis (N : ℕ) : Module.Basis (SystemIndex N) ℝ (SystemSpace N) := + ((degreeLT.basis ℝ (N+1)).prod ((degreeLT.basis ℝ (N+1)).prod (degreeLT.basis ℝ N))).prod + (degreeLT.basis ℝ N) +def systemIndexEquiv (N : ℕ) : SystemIndex N ≃ Fin (4*N+2) := + Fintype.equivFinOfCardEq (by simp [SystemIndex]; omega) +def targetBasis (N : ℕ) : Module.Basis (SystemIndex N) ℝ (degreeLT ℝ (4*N+2)) := + (degreeLT.basis ℝ (4*N+2)).reindex (systemIndexEquiv N).symm + +def perturbedSystem {N : ℕ} (hN : 1 ≤ N) (a : Fin N → ℝ) : + SystemSpace N →ₗ[ℝ] degreeLT ℝ (4*N+2) where + toFun t := ⟨projectionMap N t.1 - perturbedRoot a*t.2.val, mem_degreeLT.2 (by + apply (degree_le_natDegree).trans_lt + apply WithBot.coe_lt_coe.2 + simp only [Nat.cast_id] + apply lt_of_le_of_lt (natDegree_sub_le _ _) + apply max_lt + · have hh := projection_natDegree_le N hN t.1.1.val t.1.2.1.val t.1.2.2.val + (natDegree_le_of_mem_degreeLT t.1.1.property) (natDegree_le_of_mem_degreeLT t.1.2.1.property) + (mem_degreeLT.1 t.1.2.2.property) + exact lt_of_le_of_lt hh (by omega) + · have hg : t.2.val.natDegree < N := by + by_cases hz : t.2.val=0 + · simp [hz]; omega + exact (natDegree_lt_iff_degree_lt hz).2 (mem_degreeLT.1 t.2.property) + exact lt_of_le_of_lt natDegree_mul_le (by have := perturbedRoot_natDegree_le a; omega))⟩ + map_add' t u := by + apply Subtype.ext + simp only [Prod.fst_add, Prod.snd_add, map_add, Submodule.coe_add] + ring + map_smul' r t := by + apply Subtype.ext + simp only [Prod.smul_fst, Prod.smul_snd, map_smul, Submodule.coe_smul, smul_sub, + mul_smul_comm, RingHom.id_apply] + +theorem homogeneous_system_injective (N : ℕ) (hN : 1 ≤ N) : + Function.Injective (perturbedSystem hN (fun _ => C)) := by + apply (LinearMap.ker_eq_bot).1 + apply LinearMap.ker_eq_bot'.2 + intro t ht + have he : homogeneousQ N t.2.val = projectionMap N t.1 := by + have he := congrArg Subtype.val ht + change projectionMap N t.1 - perturbedRoot (fun _ => C)*t.2.val=0 at he + rw [perturbedRoot_homogeneous] at he + exact (sub_eq_zero.mp he).symm + have hz := homogeneous_projection_zero N hN t.2.val t.1.1.val t.1.2.1.val t.1.2.2.val + (mem_degreeLT.1 t.2.property) (natDegree_le_of_mem_degreeLT t.1.1.property) + (natDegree_le_of_mem_degreeLT t.1.2.1.property) (mem_degreeLT.1 t.1.2.2.property) he + exact Prod.ext (Prod.ext (Subtype.ext hz.1) (Prod.ext (Subtype.ext hz.2.1) (Subtype.ext hz.2.2.1))) + (Subtype.ext hz.2.2.2) + + + +def CoeffContinuous {A : Type*} [TopologicalSpace A] (p : A → Polynomial ℝ) : Prop := + ∀ k, Continuous (fun a => (p a).coeff k) +theorem CoeffContinuous.const {A : Type*} [TopologicalSpace A] (p : Polynomial ℝ) : + CoeffContinuous (fun _ : A => p) := fun _ => continuous_const +theorem CoeffContinuous.C {A : Type*} [TopologicalSpace A] {f : A → ℝ} (hf : Continuous f) : + CoeffContinuous (fun a => Polynomial.C (f a)) := by + intro k + simp only [coeff_C] + split_ifs <;> fun_prop +theorem CoeffContinuous.add {A : Type*} [TopologicalSpace A] {p q : A → Polynomial ℝ} + (hp : CoeffContinuous p) (hq : CoeffContinuous q) : CoeffContinuous (fun a => p a+q a) := by + intro k + simp only [coeff_add] + exact (hp k).add (hq k) +theorem CoeffContinuous.sub {A : Type*} [TopologicalSpace A] {p q : A → Polynomial ℝ} + (hp : CoeffContinuous p) (hq : CoeffContinuous q) : CoeffContinuous (fun a => p a-q a) := by + intro k + simp only [coeff_sub] + exact (hp k).sub (hq k) +theorem CoeffContinuous.mul {A : Type*} [TopologicalSpace A] {p q : A → Polynomial ℝ} + (hp : CoeffContinuous p) (hq : CoeffContinuous q) : CoeffContinuous (fun a => p a*q a) := by + intro k + simp only [coeff_mul] + exact continuous_finsetSum _ (fun ij _ => (hp ij.1).mul (hq ij.2)) +theorem CoeffContinuous.prod {A I : Type*} [TopologicalSpace A] (s : Finset I) + {p : I → A → Polynomial ℝ} (hp : ∀ i ∈ s, CoeffContinuous (p i)) : + CoeffContinuous (fun a => ∏ i ∈ s, p i a) := by + classical + induction s using Finset.induction_on with + | empty => simpa using CoeffContinuous.const (1 : Polynomial ℝ) + | @insert i s hi ih => + simp only [Finset.prod_insert hi] + exact (hp i (Finset.mem_insert_self _ _)).mul (ih (fun j hj => hp j (Finset.mem_insert_of_mem hj))) +theorem perturbedRoot_continuous (N : ℕ) : CoeffContinuous (@perturbedRoot N) := by + apply (CoeffContinuous.const (X-Polynomial.C C)).mul + apply CoeffContinuous.prod + intro i _ + apply ((CoeffContinuous.const X).sub (CoeffContinuous.C (continuous_apply i))).mul + apply CoeffContinuous.add + · exact (CoeffContinuous.const (X^2)).sub ((CoeffContinuous.C (by fun_prop)).mul (CoeffContinuous.const X)) + · exact CoeffContinuous.C (by fun_prop) + +def systemMatrix {N : ℕ} (hN : 1 ≤ N) (a : Fin N → ℝ) : Matrix (SystemIndex N) (SystemIndex N) ℝ := + LinearMap.toMatrix (systemBasis N) (targetBasis N) (perturbedSystem hN a) +theorem target_repr (N : ℕ) (p : degreeLT ℝ (4*N+2)) (i : SystemIndex N) : + (targetBasis N).repr p i = p.val.coeff (systemIndexEquiv N i) := by + simp only [targetBasis, Module.Basis.repr_reindex_apply, Equiv.symm_symm, degreeLT.basis_repr] +theorem systemMatrix_continuous {N : ℕ} (hN : 1 ≤ N) : Continuous (systemMatrix hN) := by + apply continuous_pi + intro i + apply continuous_pi + intro j + simp only [systemMatrix, LinearMap.toMatrix_apply, target_repr] + exact ((CoeffContinuous.const (projectionMap N (systemBasis N j).1)).sub + ((perturbedRoot_continuous N).mul (CoeffContinuous.const (systemBasis N j).2.val))) _ + +theorem systemMatrix_homogeneous_unit {N : ℕ} (hN : 1 ≤ N) : + IsUnit (systemMatrix hN (fun _ => C)).det := by + apply (Matrix.isUnit_iff_isUnit_det _).1 + apply Matrix.mulVec_injective_iff_isUnit.1 + intro v w he + let b := systemBasis N + let bv := b.equivFun.symm v + let bw := b.equivFun.symm w + have hrepr (x : SystemSpace N) : systemMatrix hN (fun _ => C) *ᵥ b.equivFun x = + (targetBasis N).equivFun (perturbedSystem hN (fun _ => C) x) := + LinearMap.toMatrix_mulVec_repr _ _ _ _ + have hve : b.equivFun bv = v := b.equivFun.apply_symm_apply v + have hwe : b.equivFun bw = w := b.equivFun.apply_symm_apply w + rw [← hve, ← hwe, hrepr, hrepr] at he + have heq := (homogeneous_system_injective N hN) ((targetBasis N).equivFun.injective he) + exact hve.symm.trans ((congrArg b.equivFun heq).trans hwe) + +def systemRHS {N : ℕ} (a : Fin N → ℝ) : degreeLT ℝ (4*N+2) := + ⟨perturbedRoot a * X^N, mem_degreeLT.2 (by + apply (degree_le_natDegree).trans_lt + apply WithBot.coe_lt_coe.2 + simp only [Nat.cast_id] + have hh := natDegree_mul_le (p := perturbedRoot a) (q := (X : Polynomial ℝ)^N) + have hd := perturbedRoot_natDegree_le a + simp only [natDegree_X_pow] at hh + omega)⟩ +def rhsVector {N : ℕ} (a : Fin N → ℝ) : SystemIndex N → ℝ := + (targetBasis N).equivFun (systemRHS a) +theorem rhsVector_continuous (N : ℕ) : Continuous (@rhsVector N) := by + apply continuous_pi + intro i + simp only [rhsVector, Module.Basis.equivFun_apply, target_repr] + exact ((perturbedRoot_continuous N).mul (CoeffContinuous.const (X^N))) _ +def solutionVector {N : ℕ} (hN : 1 ≤ N) (a : Fin N → ℝ) : SystemIndex N → ℝ := + (systemMatrix hN a)⁻¹ *ᵥ rhsVector a +def solutionTuple {N : ℕ} (hN : 1 ≤ N) (a : Fin N → ℝ) : SystemSpace N := + (systemBasis N).equivFun.symm (solutionVector hN a) +def confluentPolynomial {N : ℕ} (hN : 1 ≤ N) (a : Fin N → ℝ) : Polynomial ℝ := + X^N + (solutionTuple hN a).2.val + +theorem solutionVector_continuousAt {N : ℕ} (hN : 1 ≤ N) : + ContinuousAt (solutionVector hN) (fun _ => C) := by + have hd := isUnit_iff_ne_zero.1 (systemMatrix_homogeneous_unit hN) + have hi : ContinuousAt (fun a => (systemMatrix hN a)⁻¹) (fun _ => C) := by + apply ContinuousAt.comp ?_ (systemMatrix_continuous hN).continuousAt + apply continuousAt_matrix_inv + simpa only [show (Ring.inverse : ℝ → ℝ) = Inv.inv from funext Ring.inverse_eq_inv] using continuousAt_inv₀ hd + apply continuousAt_pi.2 + intro i + change ContinuousAt (fun a => ∑ j, (systemMatrix hN a)⁻¹ i j * rhsVector a j) _ + apply tendsto_finsetSum + intro j _ + exact (((continuous_apply j).continuousAt.comp ((continuous_apply i).continuousAt.comp hi))).mul + ((continuous_apply j).continuousAt.comp (rhsVector_continuous N).continuousAt) + +theorem confluentPolynomial_continuousAt {N : ℕ} (hN : 1 ≤ N) (k : ℕ) : + ContinuousAt (fun a => (confluentPolynomial hN a).coeff k) (fun _ => C) := by + simp only [confluentPolynomial, solutionTuple, Module.Basis.equivFun_symm_apply, + Prod.snd_sum, Prod.smul_snd, Submodule.coe_sum, Submodule.coe_smul, coeff_add, finsetSum_coeff, coeff_smul, smul_eq_mul] + apply continuousAt_const.add + apply tendsto_finsetSum + intro i _ + exact ((continuous_apply i).continuousAt.comp (solutionVector_continuousAt hN)).mul continuousAt_const + +theorem solutionTuple_spec {N : ℕ} (hN : 1 ≤ N) (a : Fin N → ℝ) + (ha : IsUnit (systemMatrix hN a).det) : + perturbedSystem hN a (solutionTuple hN a) = systemRHS a := by + apply (targetBasis N).equivFun.injective + simp only [Module.Basis.equivFun_apply] + rw [← LinearMap.toMatrix_mulVec_repr (systemBasis N) (targetBasis N) (perturbedSystem hN a)] + change systemMatrix hN a *ᵥ (systemBasis N).equivFun (solutionTuple hN a) = rhsVector a + rw [solutionTuple, LinearEquiv.apply_symm_apply] + rw [solutionVector, Matrix.mulVec_mulVec, Matrix.mul_nonsing_inv _ ha, Matrix.one_mulVec] + +theorem confluentPolynomial_spec {N : ℕ} (hN : 1 ≤ N) (a : Fin N → ℝ) + (ha : IsUnit (systemMatrix hN a).det) : PerturbedMonicProblem a (confluentPolynomial hN a) := by + let t := solutionTuple hN a + have hlow : t.2.val.degree < (N : WithBot ℕ) := mem_degreeLT.1 t.2.property + refine ⟨monic_X_pow_add hlow, ?_, ?_⟩ + · apply natDegree_eq_of_degree_eq_some + simpa only [degree_X_pow, confluentPolynomial, t] using degree_add_eq_left_of_degree_lt (p := (X : Polynomial ℝ)^N) (q := t.2.val) + (by simpa only [degree_X_pow] using hlow) + · refine ⟨t.1.1.val, t.1.2.1.val, t.1.2.2.val, + natDegree_le_of_mem_degreeLT t.1.1.property, natDegree_le_of_mem_degreeLT t.1.2.1.property, + mem_degreeLT.1 t.1.2.2.property, ?_⟩ + have he := congrArg Subtype.val (solutionTuple_spec hN a ha) + change projectionMap N t.1-perturbedRoot a*t.2.val=perturbedRoot a*X^N at he + change perturbedRoot a*(X^N+t.2.val)=projectionMap N t.1 + linear_combination -he + +theorem perturbed_unique {N : ℕ} (hN : 1 ≤ N) (a : Fin N → ℝ) + (ha : IsUnit (systemMatrix hN a).det) (p : Polynomial ℝ) (hp : PerturbedMonicProblem a p) : + p = confluentPolynomial hN a := by + obtain ⟨hpmonic, hpN, P,J,E,hP,hJ,hE,hQ⟩ := hp + have hpdeg : p.degree = (N : WithBot ℕ) := by rw [degree_eq_natDegree hpmonic.ne_zero, hpN] + have hlow : (p-X^N).degree < (N : WithBot ℕ) := by + simpa only [hpdeg] using degree_sub_lt_left + (p := p) (q := (X : Polynomial ℝ)^N) (by simpa only [degree_X_pow] using hpdeg) + hpmonic.ne_zero (hpmonic.trans (monic_X_pow N).symm) + let t : SystemSpace N := ((⟨P,mem_degreeLT.2 (degree_le_natDegree.trans_lt (by exact_mod_cast Nat.lt_succ_of_le hP))⟩, + ⟨J,mem_degreeLT.2 (degree_le_natDegree.trans_lt (by exact_mod_cast Nat.lt_succ_of_le hJ))⟩, + ⟨E,mem_degreeLT.2 hE⟩), ⟨p-X^N,mem_degreeLT.2 hlow⟩) + have he : perturbedSystem hN a t = systemRHS a := by + apply Subtype.ext + change P.comp harmonicCoordinate+X*J.comp harmonicCoordinate+X^2*E.comp harmonicCoordinate- + perturbedRoot a*(p-X^N)=perturbedRoot a*X^N + linear_combination -hQ + have hinj : Function.Injective (perturbedSystem hN a) := by + intro x y hxy + apply (systemBasis N).equivFun.injective + apply (Matrix.mulVec_injective_iff_isUnit.2 ((Matrix.isUnit_iff_isUnit_det _).2 ha)) + change systemMatrix hN a *ᵥ (systemBasis N).repr x = systemMatrix hN a *ᵥ (systemBasis N).repr y + rw [systemMatrix, LinearMap.toMatrix_mulVec_repr, LinearMap.toMatrix_mulVec_repr, hxy] + have ht : t=solutionTuple hN a := hinj (he.trans (solutionTuple_spec hN a ha).symm) + have hlast := congrArg (fun t : SystemSpace N => t.2.val) ht + change p-X^N=(solutionTuple hN a).2.val at hlast + rw [confluentPolynomial, ← hlast] + ring + + + +theorem perturbed_monic_continuity (N : ℕ) (hN : 1 ≤ N) : + ∃ g : (Fin N → ℝ) → Polynomial ℝ, + MonicProblem N (g (fun _ => C)) ∧ + (∀ k : ℕ, ContinuousAt (fun a => (g a).coeff k) (fun _ => C)) ∧ + ∀ᶠ a in 𝓝 (fun _ : Fin N => C), + PerturbedMonicProblem a (g a) ∧ + ∀ p, PerturbedMonicProblem a p → p = g a := by + refine ⟨confluentPolynomial hN, ?_, confluentPolynomial_continuousAt hN, ?_⟩ + · have hh := confluentPolynomial_spec hN (fun _ => C) (systemMatrix_homogeneous_unit hN) + simpa only [PerturbedMonicProblem, MonicProblem, perturbedRoot_homogeneous, rootPolynomial, homogeneousQ] using hh + · have hd := (systemMatrix_continuous hN).matrix_det.continuousAt.eventually_ne + (isUnit_iff_ne_zero.1 (systemMatrix_homogeneous_unit hN)) + filter_upwards [hd] with a ha + exact ⟨confluentPolynomial_spec hN a (isUnit_iff_ne_zero.2 ha), + perturbed_unique hN a (isUnit_iff_ne_zero.2 ha)⟩ + +end +end CriticalStrip + + +namespace StripPfaffian +end StripPfaffian + +end OAI diff --git a/lean/OAI/Combinatorics/StripMass/PositiveAssociation.lean b/lean/OAI/Combinatorics/StripMass/PositiveAssociation.lean new file mode 100644 index 0000000000000000000000000000000000000000..e6bca773dce125a6ab78edc8a3927006842b4d16 --- /dev/null +++ b/lean/OAI/Combinatorics/StripMass/PositiveAssociation.lean @@ -0,0 +1,412 @@ +import Mathlib +import OAI.Combinatorics.StripMass.LaguerreTails + +namespace OAI + +/-! Critical honeycomb strip paths, polynomial identities and crossing mass. -/ + + +namespace CriticalStrip +noncomputable section +open scoped BigOperators +open Set MeasureTheory Filter +lemma association_sampled {ι : Type*} [Fintype ι] + (μ : Measure ℝ) [IsFiniteMeasure μ] (q : SimpleFunc ℝ ℝ) {I : Set ℝ} + (hqI : ∀ x, q x ∈ I) (h f g : (ι → ℝ) → ℝ) + (hh : ∀ x ∈ coordinateBox ι I, 0 ≤ h x) + (hf : ∀ x ∈ coordinateBox ι I, 0 ≤ f x) + (hg : ∀ x ∈ coordinateBox ι I, 0 ≤ g x) + (hfm : MonotoneOn f (coordinateBox ι I)) + (hgm : MonotoneOn g (coordinateBox ι I)) + (hhm : ∀ x ∈ coordinateBox ι I, ∀ y ∈ coordinateBox ι I, + h x * h y ≤ h (x ⊓ y) * h (x ⊔ y)) : + (∫ x, h (fun i => q (x i)) * f (fun i => q (x i)) ∂Measure.pi (fun _ : ι => μ)) * + (∫ x, h (fun i => q (x i)) * g (fun i => q (x i)) ∂Measure.pi (fun _ : ι => μ)) ≤ + (∫ x, h (fun i => q (x i)) ∂Measure.pi (fun _ : ι => μ)) * + (∫ x, h (fun i => q (x i)) * (f (fun i => q (x i)) * g (fun i => q (x i))) + ∂Measure.pi (fun _ : ι => μ)) := by + classical + let A := ↥q.range + let Q : ℝ → A := fun x => ⟨q x, q.mem_range_self x⟩ + let e : (ι → A) → (ι → ℝ) := fun x i => x i + have hQ : Measurable Q := q.measurable.subtype_mk + let ν : Measure A := μ.map Q + have heI (x : ι → A) : e x ∈ coordinateBox ι I := by + intro i + obtain ⟨z, hz⟩ := SimpleFunc.mem_range.mp (x i).property + change (x i).val ∈ I + rw [← hz] + exact hqI z + have hint (k : (ι → ℝ) → ℝ) : + (∫ x, k (fun i => q (x i)) ∂Measure.pi (fun _ : ι => μ)) = + ∫ x : ι → A, k (e x) ∂Measure.pi (fun _ : ι => ν) := by + rw [← Measure.pi_map_pi (fun _ : ι => hQ.aemeasurable)] + symm + apply integral_map (Measurable.of_eval (fun i => hQ.comp (measurable_pi_apply i))).aemeasurable + exact (measurable_of_countable _).aestronglyMeasurable + rw [hint (fun x => h x * f x), hint (fun x => h x * g x), hint h, + hint (fun x => h x * (f x * g x))] + apply association_finite_product (fun _ : ι => ν) (fun x => h (e x)) (fun x => f (e x)) + (fun x => g (e x)) (fun x => hh _ (heI x)) (fun x => hf _ (heI x)) (fun x => hg _ (heI x)) + · intro x y hxy + exact hfm (heI x) (heI y) (fun i => hxy i) + · intro x y hxy + exact hgm (heI x) (heI y) (fun i => hxy i) + · intro x y + exact hhm _ (heI x) _ (heI y) + +lemma measurable_sampled {ι : Type*} [Fintype ι] + (q : SimpleFunc ℝ ℝ) (k : (ι → ℝ) → ℝ) : + Measurable (fun x : ι → ℝ => k (fun i => q (x i))) := by + let Q : ℝ → ↥q.range := fun x => ⟨q x, q.mem_range_self x⟩ + have hQ : Measurable Q := q.measurable.subtype_mk + exact (measurable_of_countable (fun x : ι → ↥q.range => k (fun i => x i))).comp + (Measurable.of_eval (fun i => hQ.comp (measurable_pi_apply i))) + + + +lemma integral_tendsto_quantization {ι : Type*} [Fintype ι] + (μ : Measure ℝ) [IsFiniteMeasure μ] {I : Set ℝ} (hIc : IsCompact I) + {y₀ : ℝ} (h₀ : y₀ ∈ I) (hμI : ∀ᵐ x ∂μ, x ∈ I) + (k : (ι → ℝ) → ℝ) (hk : ContinuousOn k (coordinateBox ι I)) : + Tendsto (fun n => ∫ x : ι → ℝ, + k (fun i => SimpleFunc.approxOn id measurable_id I y₀ h₀ n (x i)) + ∂Measure.pi (fun _ : ι => μ)) atTop + (nhds (∫ x, k x ∂Measure.pi (fun _ : ι => μ))) := by + let q : ℕ → SimpleFunc ℝ ℝ := SimpleFunc.approxOn id measurable_id I y₀ h₀ + have hqI (n : ℕ) (x : ι → ℝ) : (fun i => q n (x i)) ∈ coordinateBox ι I := + fun i => SimpleFunc.approxOn_mem measurable_id h₀ n (x i) + have hB : IsCompact (coordinateBox ι I) := isCompact_pi_infinite fun _ => hIc + obtain ⟨b, hb⟩ := hB.exists_bound_of_continuousOn hk + have hμB : ∀ᵐ x ∂Measure.pi (fun _ : ι => μ), x ∈ coordinateBox ι I := + ae_all_iff.mpr (fun i => (Measure.quasiMeasurePreserving_eval (fun _ : ι => μ) i).ae hμI) + apply tendsto_integral_of_dominated_convergence (fun _ => b) + (fun n => (measurable_sampled (q n) k).aestronglyMeasurable) (integrable_const b) + (fun n => Eventually.of_forall (fun x => hb _ (hqI n x))) + filter_upwards [hμB] with x hx + apply (hk x hx).tendsto.comp + apply tendsto_nhdsWithin_iff.mpr + refine ⟨tendsto_pi_nhds.mpr (fun i => ?_), Eventually.of_forall (fun n => hqI n x)⟩ + exact SimpleFunc.tendsto_approxOn measurable_id h₀ (subset_closure (hx i)) + + + +lemma association_compact_product {ι : Type*} [Fintype ι] + (μ : Measure ℝ) [IsFiniteMeasure μ] {I : Set ℝ} (hIc : IsCompact I) + {y₀ : ℝ} (h₀ : y₀ ∈ I) (hμI : ∀ᵐ x ∂μ, x ∈ I) + (h f g : (ι → ℝ) → ℝ) + (hhc : ContinuousOn h (coordinateBox ι I)) + (hfc : ContinuousOn f (coordinateBox ι I)) + (hgc : ContinuousOn g (coordinateBox ι I)) + (hh : ∀ x ∈ coordinateBox ι I, 0 ≤ h x) + (hf : ∀ x ∈ coordinateBox ι I, 0 ≤ f x) + (hg : ∀ x ∈ coordinateBox ι I, 0 ≤ g x) + (hfm : MonotoneOn f (coordinateBox ι I)) + (hgm : MonotoneOn g (coordinateBox ι I)) + (hhm : ∀ x ∈ coordinateBox ι I, ∀ y ∈ coordinateBox ι I, + h x * h y ≤ h (x ⊓ y) * h (x ⊔ y)) : + (∫ x, h x * f x ∂Measure.pi (fun _ : ι => μ)) * + (∫ x, h x * g x ∂Measure.pi (fun _ : ι => μ)) ≤ + (∫ x, h x ∂Measure.pi (fun _ : ι => μ)) * + (∫ x, h x * (f x * g x) ∂Measure.pi (fun _ : ι => μ)) := by + apply le_of_tendsto_of_tendsto + ((integral_tendsto_quantization μ hIc h₀ hμI _ (hhc.mul hfc)).mul + (integral_tendsto_quantization μ hIc h₀ hμI _ (hhc.mul hgc))) + ((integral_tendsto_quantization μ hIc h₀ hμI h hhc).mul + (integral_tendsto_quantization μ hIc h₀ hμI _ (hhc.mul (hfc.mul hgc)))) + exact Eventually.of_forall (fun n => association_sampled μ + (SimpleFunc.approxOn id measurable_id I y₀ h₀ n) + (SimpleFunc.approxOn_mem measurable_id h₀ n) h f g hh hf hg hfm hgm hhm) + + + +def orderedProductDensity (N : ℕ) (w : Fin N → ℝ → ℝ) (x : Fin N → ℝ) : ℝ := + (∏ i, w i (x i)) * ∏ i, ∏ j ∈ Finset.Ioi i, orderedPairKernel (x i) (x j) + +lemma orderedProductDensity_nonneg {N : ℕ} {I : Set ℝ} + (hI : I ⊆ Ioi 0) (w : Fin N → ℝ → ℝ) (hw : ∀ i x, x ∈ I → 0 ≤ w i x) + {x : Fin N → ℝ} (hx : x ∈ coordinateBox (Fin N) I) : + 0 ≤ orderedProductDensity N w x := by + unfold orderedProductDensity + exact mul_nonneg (Finset.prod_nonneg (fun i _ => hw i _ (hx i))) + (Finset.prod_nonneg (fun i _ => Finset.prod_nonneg (fun j _ => + orderedPairKernel_nonneg (hI (hx i)).le (hI (hx j)).le))) + +lemma continuousOn_orderedProductDensity {N : ℕ} {I : Set ℝ} + (hI : I ⊆ Ioi 0) (w : Fin N → ℝ → ℝ) (hw : ∀ i, ContinuousOn (w i) I) : + ContinuousOn (orderedProductDensity N w) (coordinateBox (Fin N) I) := by + unfold orderedProductDensity + apply ContinuousOn.mul + · apply continuousOn_finsetProd + intro i _ + exact (hw i).comp (continuous_apply i).continuousOn (fun x hx => hx i) + · apply continuousOn_finsetProd + intro i _ + apply continuousOn_finsetProd + intro j _ + unfold orderedPairKernel + apply ContinuousOn.div + · fun_prop + · fun_prop + · intro x hx + exact ne_of_gt (add_pos (hI (hx j)) (hI (hx i))) + +lemma orderedProductDensity_logSupermodular {N : ℕ} {I : Set ℝ} + (hI : I ⊆ Ioi 0) (w : Fin N → ℝ → ℝ) (hw : ∀ i x, x ∈ I → 0 ≤ w i x) + {x y : Fin N → ℝ} (hx : x ∈ coordinateBox (Fin N) I) (hy : y ∈ coordinateBox (Fin N) I) : + orderedProductDensity N w x * orderedProductDensity N w y ≤ + orderedProductDensity N w (x ⊓ y) * orderedProductDensity N w (x ⊔ y) := by + have hp : + (∏ i, ∏ j ∈ Finset.Ioi i, orderedPairKernel (x i) (x j)) * + (∏ i, ∏ j ∈ Finset.Ioi i, orderedPairKernel (y i) (y j)) ≤ + (∏ i, ∏ j ∈ Finset.Ioi i, orderedPairKernel ((x ⊓ y) i) ((x ⊓ y) j)) * + (∏ i, ∏ j ∈ Finset.Ioi i, orderedPairKernel ((x ⊔ y) i) ((x ⊔ y) j)) := by + simp only [← Finset.prod_mul_distrib] + apply Finset.prod_le_prod₀ + · intro i _ + exact Finset.prod_nonneg fun j _ => mul_nonneg + (orderedPairKernel_nonneg (hI (hx i)).le (hI (hx j)).le) + (orderedPairKernel_nonneg (hI (hy i)).le (hI (hy j)).le) + · intro i _ + apply Finset.prod_le_prod₀ + · intro j _ + exact mul_nonneg + (orderedPairKernel_nonneg (hI (hx i)).le (hI (hx j)).le) + (orderedPairKernel_nonneg (hI (hy i)).le (hI (hy j)).le) + · intro j _ + exact orderedPairKernel_logSupermodular + (hI (hx i)) (hI (hy i)) (hI (hx j)) (hI (hy j)) + unfold orderedProductDensity + rw [mul_mul_mul_comm, mul_mul_mul_comm (∏ i, w i ((x ⊓ y) i)), + ← product_coordinate_modular] + exact mul_le_mul_of_nonneg_left hp (mul_nonneg + (Finset.prod_nonneg (fun i _ => hw i _ (hx i))) + (Finset.prod_nonneg (fun i _ => hw i _ (hy i)))) + +lemma orderedProductDensity_eq {N : ℕ} (w : Fin N → ℝ → ℝ) + {x : Fin N → ℝ} (hx : StrictMono x) : + orderedProductDensity N w x = + (∏ i, w i (x i)) * ∏ i, ∏ j ∈ Finset.Ioi i, pairKernel (x i) (x j) := by + unfold orderedProductDensity + congr 1 + apply Finset.prod_congr rfl + intro i _ + apply Finset.prod_congr rfl + intro j hj + exact orderedPairKernel_eq (hx (Finset.mem_Ioi.mp hj)).le + +lemma orderedProductDensity_eq_zero {N : ℕ} (w : Fin N → ℝ → ℝ) + {x : Fin N → ℝ} (hx : ¬ StrictMono x) : orderedProductDensity N w x = 0 := by + classical + unfold StrictMono at hx + push Not at hx + obtain ⟨i, j, hij, hji⟩ := hx + have hz : (∏ i, ∏ j ∈ Finset.Ioi i, orderedPairKernel (x i) (x j)) = 0 := + Finset.prod_eq_zero (Finset.mem_univ i) + (Finset.prod_eq_zero (Finset.mem_Ioi.mpr hij) (orderedPairKernel_eq_zero hji)) + simp [orderedProductDensity, hz] + + + +theorem ordered_density_association_compact {N : ℕ} {l u : ℝ} + (hl : 0 < l) (hlu : l ≤ u) (w : Fin N → ℝ → ℝ) + (hwc : ∀ i, ContinuousOn (w i) (Icc l u)) + (hw : ∀ i x, x ∈ Icc l u → 0 ≤ w i x) + (f g : (Fin N → ℝ) → ℝ) + (hfc : ContinuousOn f (coordinateBox (Fin N) (Icc l u))) + (hgc : ContinuousOn g (coordinateBox (Fin N) (Icc l u))) + (hf : ∀ x ∈ coordinateBox (Fin N) (Icc l u), 0 ≤ f x) + (hg : ∀ x ∈ coordinateBox (Fin N) (Icc l u), 0 ≤ g x) + (hfm : MonotoneOn f (coordinateBox (Fin N) (Icc l u))) + (hgm : MonotoneOn g (coordinateBox (Fin N) (Icc l u))) : + (∫ x in coordinateBox (Fin N) (Icc l u), orderedProductDensity N w x * f x) * + (∫ x in coordinateBox (Fin N) (Icc l u), orderedProductDensity N w x * g x) ≤ + (∫ x in coordinateBox (Fin N) (Icc l u), orderedProductDensity N w x) * + (∫ x in coordinateBox (Fin N) (Icc l u), orderedProductDensity N w x * (f x * g x)) := by + have hI : Icc l u ⊆ Ioi (0 : ℝ) := fun _ hx => hl.trans_le hx.1 + have hb : coordinateBox (Fin N) (Icc l u) = Set.univ.pi (fun _ : Fin N => Icc l u) := by + ext x + simp [coordinateBox, Pi.le_def, forall_and] + have h := association_compact_product (volume.restrict (Icc l u)) isCompact_Icc + (left_mem_Icc.mpr hlu) (ae_restrict_mem measurableSet_Icc) (orderedProductDensity N w) f g + (continuousOn_orderedProductDensity hI w hwc) hfc hgc + (fun _ hx => orderedProductDensity_nonneg hI w hw hx) hf hg hfm hgm + (fun _ hx _ hy => orderedProductDensity_logSupermodular hI w hw hx hy) + simpa only [hb, volume_pi, Measure.restrict_pi_pi] using h + + + +lemma weighted_covariance_shift {α : Type*} [MeasurableSpace α] (μ : Measure α) + (h f g : α → ℝ) (hh : Integrable h μ) (hf : Integrable (fun x => h x * f x) μ) + (hg : Integrable (fun x => h x * g x) μ) + (hfg : Integrable (fun x => h x * (f x * g x)) μ) (b c : ℝ) : + (∫ x, h x * (f x + b) ∂μ) * (∫ x, h x * (g x + c) ∂μ) - + (∫ x, h x ∂μ) * (∫ x, h x * ((f x + b) * (g x + c)) ∂μ) = + (∫ x, h x * f x ∂μ) * (∫ x, h x * g x ∂μ) - + (∫ x, h x ∂μ) * (∫ x, h x * (f x * g x) ∂μ) := by + have hf' : (∫ x, h x * (f x + b) ∂μ) = (∫ x, h x * f x ∂μ) + b * ∫ x, h x ∂μ := by + simp_rw [mul_add] + rw [integral_add hf (hh.mul_const b), integral_mul_const, mul_comm _ b] + have hg' : (∫ x, h x * (g x + c) ∂μ) = (∫ x, h x * g x ∂μ) + c * ∫ x, h x ∂μ := by + simp_rw [mul_add] + rw [integral_add hg (hh.mul_const c), integral_mul_const, mul_comm _ c] + have hfg' : (∫ x, h x * ((f x + b) * (g x + c)) ∂μ) = + (∫ x, h x * (f x * g x) ∂μ) + c * (∫ x, h x * f x ∂μ) + + b * (∫ x, h x * g x ∂μ) + b * c * (∫ x, h x ∂μ) := by + simp_rw [show ∀ x, h x * ((f x + b) * (g x + c)) = + h x * (f x * g x) + c * (h x * f x) + b * (h x * g x) + (b * c) * h x by + intro x; ring] + have hi₁ : Integrable (fun x => h x * (f x * g x) + c * (h x * f x)) μ := + hfg.add (hf.const_mul c) + have hi₂ : Integrable (fun x => h x * (f x * g x) + c * (h x * f x) + b * (h x * g x)) μ := + hi₁.add (hg.const_mul b) + rw [integral_add hi₂ (hh.const_mul (b * c)), + integral_add hi₁ (hg.const_mul b), integral_add hfg (hf.const_mul c)] + simp only [integral_const_mul] + rw [hf', hg', hfg'] + ring + + + +theorem ordered_density_covariance_compact {N : ℕ} {l u : ℝ} + (hl : 0 < l) (hlu : l ≤ u) (w : Fin N → ℝ → ℝ) + (hwc : ∀ i, ContinuousOn (w i) (Icc l u)) + (hw : ∀ i x, x ∈ Icc l u → 0 ≤ w i x) + (f g : (Fin N → ℝ) → ℝ) + (hfc : ContinuousOn f (coordinateBox (Fin N) (Icc l u))) + (hgc : ContinuousOn g (coordinateBox (Fin N) (Icc l u))) + (hfm : MonotoneOn f (coordinateBox (Fin N) (Icc l u))) + (hgm : MonotoneOn g (coordinateBox (Fin N) (Icc l u))) : + (∫ x in coordinateBox (Fin N) (Icc l u), orderedProductDensity N w x * f x) * + (∫ x in coordinateBox (Fin N) (Icc l u), orderedProductDensity N w x * g x) ≤ + (∫ x in coordinateBox (Fin N) (Icc l u), orderedProductDensity N w x) * + (∫ x in coordinateBox (Fin N) (Icc l u), orderedProductDensity N w x * (f x * g x)) := by + have hB : IsCompact (coordinateBox (Fin N) (Icc l u)) := isCompact_pi_infinite fun _ => isCompact_Icc + obtain ⟨b, hb⟩ := hB.exists_bound_of_continuousOn hfc + obtain ⟨c, hc⟩ := hB.exists_bound_of_continuousOn hgc + have hh : ContinuousOn (orderedProductDensity N w) (coordinateBox (Fin N) (Icc l u)) := + continuousOn_orderedProductDensity (fun _ hx => hl.trans_le hx.1) w hwc + have h := ordered_density_association_compact hl hlu w hwc hw + (fun x => f x + b) (fun x => g x + c) (hfc.add continuousOn_const) (hgc.add continuousOn_const) + (fun x hx => by have h := (abs_le.mp (hb x hx)).1; linarith) + (fun x hx => by have h := (abs_le.mp (hc x hx)).1; linarith) + (fun x hx y hy hxy => add_le_add (hfm hx hy hxy) le_rfl) + (fun x hx y hy hxy => add_le_add (hgm hx hy hxy) le_rfl) + have he := weighted_covariance_shift (volume.restrict (coordinateBox (Fin N) (Icc l u))) + (orderedProductDensity N w) f g (hh.integrableOn_compact hB) + ((hh.mul hfc).integrableOn_compact hB) ((hh.mul hgc).integrableOn_compact hB) + ((hh.mul (hfc.mul hgc)).integrableOn_compact hB) b c + linarith + + + +theorem ordered_density_reverse_covariance_compact {N : ℕ} {l u : ℝ} + (hl : 0 < l) (hlu : l ≤ u) (w : Fin N → ℝ → ℝ) + (hwc : ∀ i, ContinuousOn (w i) (Icc l u)) + (hw : ∀ i x, x ∈ Icc l u → 0 ≤ w i x) + (f g : (Fin N → ℝ) → ℝ) + (hfc : ContinuousOn f (coordinateBox (Fin N) (Icc l u))) + (hgc : ContinuousOn g (coordinateBox (Fin N) (Icc l u))) + (hfm : AntitoneOn f (coordinateBox (Fin N) (Icc l u))) + (hgm : MonotoneOn g (coordinateBox (Fin N) (Icc l u))) : + (∫ x in coordinateBox (Fin N) (Icc l u), orderedProductDensity N w x * (f x * g x)) * + (∫ x in coordinateBox (Fin N) (Icc l u), orderedProductDensity N w x) ≤ + (∫ x in coordinateBox (Fin N) (Icc l u), orderedProductDensity N w x * f x) * + (∫ x in coordinateBox (Fin N) (Icc l u), orderedProductDensity N w x * g x) := by + have h := ordered_density_covariance_compact hl hlu w hwc hw (fun x => -f x) g + hfc.neg hgc (fun x hx y hy hxy => neg_le_neg (hfm hx hy hxy)) hgm + simp only [neg_mul, mul_neg, integral_neg, neg_le_neg_iff] at h + nlinarith + + + + +def orderedChamber (N : ℕ) (I : Set ℝ) : Set (Fin N → ℝ) := + {x | StrictMono x ∧ ∀ i, x i ∈ I} + +def rawProductDensity (N : ℕ) (w : Fin N → ℝ → ℝ) (x : Fin N → ℝ) : ℝ := + (∏ i, w i (x i)) * ∏ i, ∏ j ∈ Finset.Ioi i, pairKernel (x i) (x j) + +lemma isOpen_strictMono_coordinates (N : ℕ) : IsOpen {x : Fin N → ℝ | StrictMono x} := by + have heq : {x : Fin N → ℝ | StrictMono x} = + ⋂ i : Fin N, ⋂ j : Fin N, ⋂ (_ : i < j), {x | x i < x j} := by + ext x + simp only [mem_ofPred_eq, mem_iInter, StrictMono] + rw [heq] + exact isOpen_iInter_of_finite fun i => isOpen_iInter_of_finite fun j => + isOpen_iInter_of_finite fun _ => isOpen_lt (continuous_apply i) (continuous_apply j) + +lemma coordinateBox_eq_pi {ι : Type*} (I : Set ℝ) : + coordinateBox ι I = Set.univ.pi (fun _ : ι => I) := by + ext x + simp [coordinateBox] + +lemma measurableSet_coordinateBox {ι : Type*} [Countable ι] {I : Set ℝ} + (hI : MeasurableSet I) : MeasurableSet (coordinateBox ι I) := by + have he : coordinateBox ι I = ⋂ i : ι, (fun x : ι → ℝ => x i) ⁻¹' I := by + ext x + simp [coordinateBox] + rw [he] + exact MeasurableSet.iInter fun i : ι => hI.preimage (measurable_pi_apply i) + +lemma orderedProductDensity_indicator (N : ℕ) (w : Fin N → ℝ → ℝ) : + orderedProductDensity N w = {x : Fin N → ℝ | StrictMono x}.indicator (rawProductDensity N w) := by + classical + funext x + by_cases hx : StrictMono x + · simp only [Set.indicator_of_mem (show x ∈ {x : Fin N → ℝ | StrictMono x} from hx)] + exact orderedProductDensity_eq w hx + · simp only [Set.indicator_of_notMem (show x ∉ {x : Fin N → ℝ | StrictMono x} from hx)] + exact orderedProductDensity_eq_zero w hx + +lemma orderedProductDensity_mul_indicator (N : ℕ) (w : Fin N → ℝ → ℝ) + (f : (Fin N → ℝ) → ℝ) : + (fun x => orderedProductDensity N w x * f x) = + {x : Fin N → ℝ | StrictMono x}.indicator (fun x => rawProductDensity N w x * f x) := by + rw [orderedProductDensity_indicator] + funext x + by_cases hx : StrictMono x <;> simp [hx] + +lemma orderedChamber_eq_inter (N : ℕ) (I : Set ℝ) : + orderedChamber N I = {x : Fin N → ℝ | StrictMono x} ∩ coordinateBox (Fin N) I := rfl + +lemma integral_orderedProductDensity_mul {N : ℕ} (I : Set ℝ) (w : Fin N → ℝ → ℝ) + (f : (Fin N → ℝ) → ℝ) : + (∫ x in coordinateBox (Fin N) I, orderedProductDensity N w x * f x) = + ∫ x in orderedChamber N I, rawProductDensity N w x * f x := by + rw [orderedProductDensity_mul_indicator, setIntegral_indicator (isOpen_strictMono_coordinates N).measurableSet, + orderedChamber_eq_inter, inter_comm] + +lemma integrable_orderedProductDensity_mul_iff {N : ℕ} (I : Set ℝ) (w : Fin N → ℝ → ℝ) + (f : (Fin N → ℝ) → ℝ) : + IntegrableOn (fun x => orderedProductDensity N w x * f x) (coordinateBox (Fin N) I) ↔ + IntegrableOn (fun x => rawProductDensity N w x * f x) (orderedChamber N I) := by + rw [orderedProductDensity_mul_indicator, + integrableOn_indicator_iff (isOpen_strictMono_coordinates N).measurableSet] + rfl + +lemma integral_orderedProductDensity {N : ℕ} (I : Set ℝ) (w : Fin N → ℝ → ℝ) : + (∫ x in coordinateBox (Fin N) I, orderedProductDensity N w x) = + ∫ x in orderedChamber N I, rawProductDensity N w x := by + simpa using integral_orderedProductDensity_mul I w (fun _ => 1) + +lemma integrable_orderedProductDensity_iff {N : ℕ} (I : Set ℝ) (w : Fin N → ℝ → ℝ) : + IntegrableOn (orderedProductDensity N w) (coordinateBox (Fin N) I) ↔ + IntegrableOn (rawProductDensity N w) (orderedChamber N I) := by + simpa using integrable_orderedProductDensity_mul_iff I w (fun _ => 1) + +lemma coordinateBox_mono {ι : Type*} {I J : Set ℝ} (hIJ : I ⊆ J) : + coordinateBox ι I ⊆ coordinateBox ι J := fun _ hx i => hIJ (hx i) + +lemma coordinateBox_iUnion_of_monotone {ι : Type*} [Fintype ι] {s : ℕ → Set ℝ} + (hs : Monotone s) : + (⋃ n, coordinateBox ι (s n)) = coordinateBox ι (⋃ n, s n) := by + simp only [coordinateBox_eq_pi] + exact Set.iUnion_pi_of_monotone (Set.toFinite Set.univ) (fun _ _ => hs) + + + +end +end CriticalStrip + +end OAI diff --git a/lean/OAI/Combinatorics/StripMass/ProjectionInjection.lean b/lean/OAI/Combinatorics/StripMass/ProjectionInjection.lean new file mode 100644 index 0000000000000000000000000000000000000000..fcb325b7ad24aec055f44d3b68c79f4d4e915682 --- /dev/null +++ b/lean/OAI/Combinatorics/StripMass/ProjectionInjection.lean @@ -0,0 +1,508 @@ +import Mathlib +import OAI.Combinatorics.StripMass.NorthGluing +import OAI.Combinatorics.StripMass.SplitProjection + +namespace OAI + +/-! Critical honeycomb strip paths, polynomial identities and crossing mass. -/ + + +namespace CriticalStrip.Diagram +noncomputable section +open scoped Classical BigOperators + + + +lemma twoVacancyInsertion_transpose_deletion {n m : ℕ} (r : ℕ) (hr : r+2≤n+2) : + (twoVacancyInsertion (K:=SpectralField m) r hr).transpose * deletionMap (m:=m) r hr = 1 := by + let b : Fin (n+2) := ⟨r+1,by omega⟩ + let a : Fin (n+1) := ⟨r,by omega⟩ + let f := Fin.succAboveOrderEmb b + let g := Fin.succAboveOrderEmb a + have hab : f a = (PartialColumn.rowPosition r hr).left := by + change b.succAbove a = _ + rw [Fin.succAbove_of_castSucc_lt _ _ (by change r M.transpose*(L*M)) hfg + _ = (E.transpose*L)*E := (Matrix.mul_assoc _ _ _).symm + _ = 1 := by + ext p q + refine (mul_functionMatrix _ _ p q).trans ?_ + refine (transpose_functionMatrix_mul_apply _ _ p _).trans ?_ + change localR (PartialColumn.rowPosition r hr) deletionWeights ((p.map g).map f) ((q.map g).map f) = + (if p=q then (1:SpectralField m) else 0) + rw [localR_vacant_right _ _ _ _ (hf q) (hf p)] + simp only [hg q,ite_false, + (Pairing.map_injective f).eq_iff,(Pairing.map_injective g).eq_iff,eq_comm] + +lemma deletionMap_injective {n m : ℕ} (r : ℕ) (hr : r+2≤n+2) : + Function.Injective (deletionMap (m:=m) r hr).mulVec := by + intro v w hvw + have h := congrArg (twoVacancyInsertion (K:=SpectralField m) r hr).transpose.mulVec hvw + rwa [Matrix.mulVec_mulVec,Matrix.mulVec_mulVec, + twoVacancyInsertion_transpose_deletion,Matrix.one_mulVec,Matrix.one_mulVec] at h + + +def extendSource {K : Type*} [Zero K] {n : ℕ} (v : SourcePairing n → K) : Pairing (n+1) → K := + fun p => if h : p.Occupied (Fin.last n) then v ⟨p,h⟩ else 0 + +@[simp] lemma extendSource_apply {K : Type*} [Zero K] {n : ℕ} + (v : SourcePairing n → K) (p : SourcePairing n) : extendSource v p.val=v p := by + simp [extendSource,p.property] + +lemma LastMatrix.mulVec_extendSource {K : Type*} [CommRing K] {n m : ℕ} + {M : Matrix (Pairing (m+1)) (Pairing (n+1)) K} (hM : LastMatrix M) + (v : SourcePairing n → K) : + M.mulVec (extendSource v)=extendSource ((sourceBlock M).mulVec v) := by + funext p + by_cases hp : p.Occupied (Fin.last m) + · rw [hM.source_mulVec _ ⟨p,hp⟩] + simp only [extendSource_apply] + rw [extendSource,dite_eq_left hp] + · rw [extendSource,dite_eq_right hp] + apply Finset.sum_eq_zero + intro q _ + change M p q * extendSource v q=0 + by_cases hq : q.Occupied (Fin.last n) + · rw [hM p q (by simp [hp,hq]),zero_mul] + · simp [extendSource,hq] + +lemma LastMatrix.source_injective {K : Type*} [CommRing K] {n m : ℕ} + {M : Matrix (Pairing (m+1)) (Pairing (n+1)) K} (hM : LastMatrix M) + (h : Function.Injective M.mulVec) : Function.Injective (sourceBlock M).mulVec := by + intro v w hvw + have he := congrArg extendSource hvw + rw [←hM.mulVec_extendSource,←hM.mulVec_extendSource] at he + have hh := h he + funext p + simpa only [extendSource_apply] using congrFun hh p.val + +lemma sourceBlock_merge_injective {n m : ℕ} (r : ℕ) (hr : r+2≤n+1) : + Function.Injective (sourceBlock (mergeMap (m:=m) r (show r+2≤n+2 by omega))).mulVec := + (mergeMap_last r hr).source_injective (mergeMap_injective r _) + +lemma sourceBlock_deletion_injective {n m : ℕ} (r : ℕ) (hr : r+2≤n+2) : + Function.Injective (sourceBlock (deletionMap (m:=m) r (show r+2≤n+3 by omega))).mulVec := + (deletionMap_last r hr).source_injective (deletionMap_injective r _) + +lemma twoVacancyInsertion_last {n m : ℕ} (r : ℕ) (hr : r+2≤n+2) : + LastMatrix (twoVacancyInsertion (K:=SpectralField m) r (show r+2≤n+3 by omega)) := by + let b : Fin (n+2) := ⟨r+1,by omega⟩ + let a : Fin (n+1) := ⟨r,by omega⟩ + exact (LastMatrix.omit b).mul (LastMatrix.omit a) + +lemma mergeProjection_last {n m : ℕ} (r : ℕ) (hr : r+2≤n+1) : + LastMatrix (mergeProjection (m:=m) r (show r+2≤n+2 by omega)) := by + let b : Fin (n+1) := ⟨r+1,by omega⟩ + exact (LastMatrix.omit b).transpose.mul + (LastMatrix.local (PartialColumn.rowPosition r hr) _) + +lemma deletionProjection_last {n m : ℕ} (r : ℕ) (hr : r+2≤n+2) : + LastMatrix (deletionProjection (m:=m) r (show r+2≤n+3 by omega)) := by + exact (twoVacancyInsertion_last r hr).transpose.mul + (LastMatrix.local (PartialColumn.rowPosition r hr) _) + +lemma sourceBlock_merge_factor {n m : ℕ} (r : ℕ) (hr : r+2≤n+1) : + sourceBlock (mergeMap (m:=m) r (show r+2≤n+2 by omega)) * sourceBlock (mergeProjection r (show r+2≤n+2 by omega)) = + sourceBlock (localR (PartialColumn.rowPosition r hr).padTop (torusWeights (constF m phase^2))) := by + refine ((mergeMap_last r hr).source_mul _).symm.trans ?_ + exact congrArg sourceBlock (mergeMap_mul_projection r _) + +lemma sourceBlock_deletion_factor {n m : ℕ} (r : ℕ) (hr : r+2≤n+2) : + sourceBlock (deletionMap (m:=m) r (show r+2≤n+3 by omega)) * sourceBlock (deletionProjection r (show r+2≤n+3 by omega)) = + sourceBlock (localR (PartialColumn.rowPosition r hr).padTop (torusWeights (constF m phase^3))) := by + refine ((deletionMap_last r hr).source_mul _).symm.trans ?_ + exact congrArg sourceBlock (deletionMap_mul_projection r _) + + + + + + +def twistedReflectionMonomial {n : ℕ} (k : Fin n → ℤ) : + Multiplicative (Fin n → ℤ) →* Laurent n where + toFun e := monomialL (-e.toAdd) (∏ i, phase ^ (k i * e.toAdd i)) + map_one' := by simp [monomialL]; rfl + map_mul' e f := by + change monomialL (-(e.toAdd+f.toAdd)) (∏ i,phase^(k i*(e.toAdd i+f.toAdd i))) = _ + simp only [mul_add,zpow_add₀ phase_ne_zero,Finset.prod_mul_distrib,neg_add] + exact (AddMonoidAlgebra.single_mul_single _ _ _ _).symm + +def twistedReflectLaurent {n : ℕ} (k : Fin n → ℤ) : Laurent n →+* Laurent n := + (AddMonoidAlgebra.lift ℂ (Laurent n) (Fin n → ℤ) (twistedReflectionMonomial k)).toRingHom + +@[simp] lemma twistedReflectLaurent_monomial {n : ℕ} (k : Fin n → ℤ) + (e : Fin n → ℤ) (z : ℂ) : + twistedReflectLaurent k (monomialL e z) = monomialL (-e) (z * ∏ i,phase^(k i*e i)) := by + change AddMonoidAlgebra.lift ℂ _ _ (twistedReflectionMonomial k) (AddMonoidAlgebra.single e z) = _ + rw [AddMonoidAlgebra.lift_single] + change z • AddMonoidAlgebra.single (-e) _ = AddMonoidAlgebra.single (-e) _ + rw [AddMonoidAlgebra.smul_single,smul_eq_mul] + rfl + +lemma twistedReflectLaurent_involutive {n : ℕ} (k : Fin n → ℤ) : + Function.Involutive (twistedReflectLaurent k) := by + have h : (twistedReflectLaurent k).comp (twistedReflectLaurent k) = RingHom.id _ := by + apply AddMonoidAlgebra.ringHom_ext <;> intro e + all_goals change twistedReflectLaurent k (twistedReflectLaurent k (monomialL _ _)) = monomialL _ _ + all_goals rw [twistedReflectLaurent_monomial,twistedReflectLaurent_monomial] + all_goals simp only [neg_neg,Pi.neg_apply,mul_neg,mul_assoc,←Finset.prod_mul_distrib, + ←zpow_add₀ phase_ne_zero,add_neg_cancel,zpow_zero,Finset.prod_const_one,mul_one] + exact fun f => DFunLike.congr_fun h f + +def twistedReflectSpectral {n : ℕ} (k : Fin n → ℤ) : SpectralField n →+* SpectralField n := + IsFractionRing.lift (K:=SpectralField n) + (g:=(algebraMap (SpectralRing n) (SpectralField n)).comp (twistedReflectLaurent k)) + ((IsFractionRing.injective (SpectralRing n) (SpectralField n)).comp + (twistedReflectLaurent_involutive k).injective) + +@[simp] lemma twistedReflectSpectral_evalLaurent {n : ℕ} (k : Fin n → ℤ) (f : Laurent n) : + twistedReflectSpectral k (evalLaurent f)=evalLaurent (twistedReflectLaurent k f) := + IsFractionRing.lift_algebraMap _ _ + +@[simp] lemma twistedReflectSpectral_const {n : ℕ} (k : Fin n → ℤ) (z : ℂ) : + twistedReflectSpectral k (constF n z)=constF n z := by + have hc : constF n z=evalLaurent (constantL n z) := (map_constantL n z).symm + rw [hc,twistedReflectSpectral_evalLaurent] + change evalLaurent (twistedReflectLaurent k (monomialL 0 z)) = evalLaurent (monomialL 0 z) + rw [twistedReflectLaurent_monomial] + simp only [Pi.zero_apply,mul_zero,zpow_zero,Finset.prod_const_one,mul_one,neg_zero] + +@[simp] lemma twistedReflectSpectral_variable {n : ℕ} (k : Fin n → ℤ) (i : Fin n) : + twistedReflectSpectral k (variableF i)=constF n phase ^ k i / variableF i := by + change twistedReflectSpectral k (evalLaurent (monomialL (variableExponent i) 1)) = _ + rw [twistedReflectSpectral_evalLaurent,twistedReflectLaurent_monomial] + have he : (∏ j,phase^(k j * variableExponent i j))=phase^k i := by + simp [variableExponent,Pi.single_apply] + rw [he,one_mul,evalLaurent,map_monomialL_neg_variable] + simp only [constF,map_zpow₀,div_eq_mul_inv] + +lemma torusEvaluation_twistedReflect {n m : ℕ} (k : Fin n → ℤ) + (z : Fin n → SpectralField m) (hz : ∀ i,z i≠0) (f : Laurent n) : + torusEvaluation z hz (twistedReflectLaurent k f) = + torusEvaluation (fun i => constF m phase^k i/z i) + (fun i =>div_ne_zero (zpow_ne_zero _ (constF_phase_ne_zero m)) (hz i)) f := by + have he : (torusEvaluation z hz).toRingHom.comp (twistedReflectLaurent k) = + (torusEvaluation (fun i => constF m phase^k i/z i) + (fun i =>div_ne_zero (zpow_ne_zero _ (constF_phase_ne_zero m)) (hz i))).toRingHom := by + apply AddMonoidAlgebra.ringHom_ext <;> intro e + all_goals change torusEvaluation z hz (twistedReflectLaurent k (monomialL _ _)) = + torusEvaluation _ _ (monomialL _ _) + all_goals rw [twistedReflectLaurent_monomial] + all_goals simp only [torusEvaluation_monomial,constF,map_mul,map_prod,map_zpow₀, + Pi.neg_apply,zpow_neg,zpow_mul,div_eq_mul_inv,mul_zpow,inv_zpow, + Finset.prod_mul_distrib,mul_assoc] + exact DFunLike.congr_fun he f + +lemma sum_zpow_eq_prod {K : Type*} [CommGroupWithZero K] {ι : Type*} + (a : K) (ha : a≠0) (s : Finset ι) (v : ι → ℤ) : + a^(∑ i∈s,v i) = ∏ i∈s,a^v i := by + induction s using Finset.induction_on with + | empty => simp + | @insert i s hi ih => rw [Finset.sum_insert hi,Finset.prod_insert hi,zpow_add₀ ha,ih] + +lemma reflectLaurent_eq_twisted (n : ℕ) : reflectLaurent n=twistedReflectLaurent (fun _:Fin n =>3) := by + apply AddMonoidAlgebra.ringHom_ext <;> intro e + all_goals change reflectLaurent n (monomialL _ _) = twistedReflectLaurent _ (monomialL _ _) + all_goals rw [reflectLaurent_monomial,twistedReflectLaurent_monomial, + Finset.mul_sum,sum_zpow_eq_prod phase phase_ne_zero] + +lemma torusEvaluation_reflect {n m : ℕ} (z : Fin n → SpectralField m) + (hz : ∀ i,z i≠0) (f : Laurent n) : + torusEvaluation z hz (reflectLaurent n f) = + torusEvaluation (fun i => constF m phase^3/z i) + (fun i =>div_ne_zero (pow_ne_zero _ (constF_phase_ne_zero m)) (hz i)) f := by + rw [reflectLaurent_eq_twisted,torusEvaluation_twistedReflect] + rfl + + + +def pairReflection (n s : ℕ) : SpectralField (n+1) →+* SpectralField (n+1) := + twistedReflectSpectral (Fin.cons (3-(s:ℤ)) (fun _ : Fin n =>3)) + +@[simp] lemma pairReflection_const (n s : ℕ) (z : ℂ) : + pairReflection n s (constF (n+1) z)=constF (n+1) z := twistedReflectSpectral_const _ z + +@[simp] lemma pairReflection_variable_zero (n s : ℕ) : + pairReflection n s (variableF 0)=constF (n+1) phase^(3-(s:ℤ))/variableF 0 := + twistedReflectSpectral_variable _ _ + +@[simp] lemma pairReflection_variable_succ (n s : ℕ) (i : Fin n) : + pairReflection n s (variableF i.succ)=constF (n+1) phase^3/variableF i.succ := + twistedReflectSpectral_variable _ _ + +lemma pairReflection_torusCos (n s : ℕ) (z : SpectralField (n+1)) : + pairReflection n s (torusCos z)=torusCos (pairReflection n s z) := by + simp [torusCos,map_div₀,map_inv₀,map_ofNat] + + + + + + +lemma pairReflection_pairPoint (n s : ℕ) (i : Fin (n+2)) : + pairReflection n s (pairPoint n s i) = + constF (n+1) phase^3 / pairPoint n s ((Equiv.swap 0 1) i) := by + have hq := constF_phase_ne_zero (n+1) + have hz := variableF_ne_zero (0:Fin (n+1)) + have hs : constF (n+1) phase ^ (3-(s:ℤ)) = constF (n+1) phase^3 / constF (n+1) phase^s := by + rw [zpow_sub₀ hq] + simp + induction i using Fin.cases with + | zero => + simp only [pairPoint,Fin.cons_zero,pairReflection_variable_zero, + Equiv.swap_apply_left,Fin.cons_one,Fin.cons_zero] + rw [hs]; field_simp + | succ i => induction i using Fin.cases with + | zero => + simp only [Fin.succ_zero_eq_one,pairPoint,Fin.cons_one,Fin.cons_zero,map_mul,map_pow, + pairReflection_const,pairReflection_variable_zero,Equiv.swap_apply_right] + rw [hs]; field_simp + | succ i => + have h0 : i.succ.succ ≠ (0:Fin (n+2)) := Fin.succ_ne_zero _ + have h1 : i.succ.succ ≠ (1:Fin (n+2)) := by + intro he + have := congrArg Fin.val he + simp only [Fin.val_succ,Fin.val_one] at this + omega + rw [Equiv.swap_apply_of_ne_of_ne h0 h1] + simp only [pairPoint,Fin.cons_succ,pairReflection_variable_succ] + +lemma pairEvaluation_swap_reflect {n : ℕ} (s : ℕ) (f : Laurent (n+2)) : + pairEvaluation n s (permLaurent (Equiv.swap 0 1) (reflectLaurent (n+2) f)) = + pairReflection n s (pairEvaluation n s f) := by + unfold pairEvaluation + rw [torusEvaluation_permLaurent,torusEvaluation_reflect, + torusEvaluation_fieldMap (pairReflection n s) (pairReflection_const n s)] + congr 2 + funext i + exact (pairReflection_pairPoint n s i).symm + +lemma pairReflection_mergePoint (n : ℕ) (i : Fin (n+1)) : + pairReflection n 2 (mergePoint n i) = constF (n+1) phase^3 / mergePoint n i := by + induction i using Fin.cases with + | zero => + simp only [mergePoint,Fin.cons_zero,map_mul,pairReflection_const,pairReflection_variable_zero] + norm_num only + field_simp [variableF_ne_zero,constF_phase_ne_zero] + | succ i => simp only [mergePoint,Fin.cons_succ,deletePoint,pairReflection_variable_succ] + +lemma pairReflection_mergeEvaluation {n : ℕ} (f : Laurent (n+1)) : + pairReflection n 2 (mergeEvaluation n f) = mergeEvaluation n (reflectLaurent (n+1) f) := by + unfold mergeEvaluation + rw [torusEvaluation_fieldMap (pairReflection n 2) (pairReflection_const n 2), + torusEvaluation_reflect] + congr 2 + funext i + exact pairReflection_mergePoint n i + +lemma pairReflection_deleteEvaluation {n : ℕ} (f : Laurent n) : + pairReflection n 3 (deleteEvaluation n f) = deleteEvaluation n (reflectLaurent n f) := by + unfold deleteEvaluation + refine (torusEvaluation_fieldMap (pairReflection n 3) (pairReflection_const n 3) + (deletePoint n) (fun i => show deletePoint n i ≠ 0 from variableF_ne_zero i.succ) f).trans ?_ + refine Eq.trans ?_ (torusEvaluation_reflect (deletePoint n) + (fun i => show deletePoint n i ≠ 0 from variableF_ne_zero i.succ) f).symm + congr 2 + funext i + exact pairReflection_variable_succ n 3 i + +lemma twistedReflectSpectral_torusCos {n : ℕ} (k : Fin n → ℤ) (z : SpectralField n) : + twistedReflectSpectral k (torusCos z) = torusCos (twistedReflectSpectral k z) := by + simp [torusCos,map_div₀,map_inv₀,map_ofNat] + +lemma twistedReflectSpectral_fcos {n : ℕ} (k : Fin n → ℤ) (i : Fin n) (r : ℤ) : + twistedReflectSpectral k (fcos i r) = fcos i (-r-2*k i) := by + rw [fcos_eq,twistedReflectSpectral_torusCos] + simp only [map_mul,map_pow,twistedReflectSpectral_const, + twistedReflectSpectral_variable] + have hc (j:ℤ) : constF n (phase^j) = constF n phase^j := by simp [constF] + have hq := constF_phase_ne_zero n + have hp : constF n phase^(-r-2*k i) = + (constF n phase^r * (constF n phase^k i)^2)⁻¹ := by + rw [sub_eq_add_neg,zpow_add₀ hq,zpow_neg,zpow_neg,mul_comm (2:ℤ),zpow_mul] + simp only [zpow_ofNat,mul_inv_rev] + ring + rw [fcos_eq] + simp only [hc] + calc + torusCos (constF n phase^r * (constF n phase^k i / variableF i)^2) = + torusCos ((constF n phase^(-r-2*k i)*variableF i^2)⁻¹) := by + congr 1 + rw [hp] + field_simp + _ = _ := torusCos_inv _ + +lemma pairReflection_fcos_zero (n s : ℕ) (r : ℤ) : + pairReflection n s (fcos 0 r) = fcos 0 (-r-2*(3-(s:ℤ))) := by + exact twistedReflectSpectral_fcos _ _ _ + +lemma pairReflection_fcos_succ (n s : ℕ) (i : Fin n) (r : ℤ) : + pairReflection n s (fcos i.succ r) = fcos i.succ (-r-6) := by + exact twistedReflectSpectral_fcos _ _ _ + +lemma pairReflection_mergeScalar (n : ℕ) : + pairReflection n 2 (mergePairScalar n) = mergePairScalar n := by + unfold mergePairScalar + simp only [map_mul,map_add,map_prod,pairReflection_fcos_zero,pairReflection_fcos_succ, + pairReflection_const] + norm_num only + ring + +lemma pairReflection_deleteScalar (n : ℕ) : + pairReflection n 3 (deletePairScalar n) = deletePairScalar n := by + unfold deletePairScalar + simp only [map_mul,map_add,map_sub,map_prod,pairReflection_fcos_zero,pairReflection_fcos_succ, + pairReflection_const] + norm_num only + have hp : (∏ j:Fin n, (fcos j.succ (-3)-fcos 0 9)*(fcos j.succ (-3)-fcos 0 (-9))) = + ∏ j:Fin n, (fcos j.succ (-3)-fcos 0 (-9))*(fcos j.succ (-3)-fcos 0 9) := by + apply Finset.prod_congr rfl + intro j _ + ring + rw [hp] + ring + + + + + + +lemma constF_C_ne_zero (n : ℕ) : constF n C≠0 := by + simpa only [constF,map_ne_zero,Complex.ofReal_ne_zero] using C_ne_zero + +lemma torusL_split_nonzero (n s : ℕ) (hs : s=2 ∨ s=3) : + torusL (constF n phase^s) ≠ 0 := by + rcases hs with rfl | rfl + · rw [torusL_phase_two]; exact constF_C_ne_zero n + · rw [torusL_phase_three] + simpa only [←torusL_one] using torusL_one_ne_zero n + + + +lemma polynomialNorthSource_reflected_pair (n s : ℕ) (hs : s=2 ∨ s=3) : + (fun p : SourcePairing (n+2) => pairReflection n s + (pairEvaluation n s (polynomialNorthSource (n+2) p))) = + (sourceBlock (localR (PartialColumn.rowPosition 0 (show 2≤n+2 by omega)).padTop + (torusWeights (constF (n+1) phase^s)))).mulVec + (fun p => pairEvaluation n s (reflectLaurent (n+2) (polynomialNorthSource (n+2) p))) := by + let φ := pairEvaluation n s + let a := (PartialColumn.rowPosition 0 (show 2≤n+2 by omega)).padTop + let x := variableF (1:Fin (n+2)) / variableF 0 + let y := constF (n+1) phase^s + have hx : RationalAt φ.toRingHom x y := by + have hh := (rationalAt_pair_variable (n:=n) s (1:Fin (n+2))).div + (rationalAt_pair_variable s 0) (variableF_ne_zero 0) + simpa only [pairPoint,Fin.cons_one,Fin.cons_zero,mul_div_cancel_right₀ _ (variableF_ne_zero 0)] using hh + have hy : y≠0 := pow_ne_zero _ (constF_phase_ne_zero _) + have hw : ∀ t, RationalAt φ.toRingHom ((torusWeights x).tile t) ((torusWeights y).tile t) := + rationalAt_torusWeights φ hx hy (torusL_split_nonzero (n+1) s hs) + have hv (p : SourcePairing (n+2)) : RationalAt φ.toRingHom + (reflectSpectral (n+2) (evalLaurent (polynomialNorthSource (n+2) p))) + (pairEvaluation n s (reflectLaurent (n+2) (polynomialNorthSource (n+2) p))) := by + rw [reflectSpectral_evalLaurent] + exact RationalAt.algebraMap _ + funext p + have hright := RationalAt.mulVec (φ:=φ.toRingHom) + (sourceBlock (localR a (torusWeights x))) (sourceBlock (localR a (torusWeights y))) + (fun q => reflectSpectral (n+2) (evalLaurent (polynomialNorthSource (n+2) q))) + (fun q => pairEvaluation n s (reflectLaurent (n+2) (polynomialNorthSource (n+2) q))) + (fun q q' => rationalAt_localR φ a (torusWeights x) (torusWeights y) hw q.val q'.val) hv p + have he := congrFun (polynomialNorthSource_reflected_covariance 0 (show 2≤n+2 by omega)) p + change permSpectral (Equiv.swap 0 1) (reflectSpectral (n+2) + (evalLaurent (polynomialNorthSource (n+2) p))) = + (sourceBlock (localR a (torusWeights x))).mulVec _ p at he + rw [←he,reflectSpectral_evalLaurent,permSpectral_evalLaurent] at hright + have hleft := RationalAt.algebraMap (φ:=φ.toRingHom) (F:=SpectralField (n+2)) + (permLaurent (Equiv.swap 0 1) (reflectLaurent (n+2) (polynomialNorthSource (n+2) p))) + have hh := hleft.unique hright + change pairEvaluation n s _ = _ at hh + rw [pairEvaluation_swap_reflect] at hh + exact hh + +lemma pairReflection_mergeMap {n m s : ℕ} (r : ℕ) (hr : r+2≤n+1) : + (mergeMap (m:=m+1) r hr).map (pairReflection m s)=mergeMap r hr := by + simp only [mergeMap] + let E := functionMatrix (K:=SpectralField (m+1)) + (Pairing.map (Fin.succAboveOrderEmb (⟨r+1,by omega⟩ : Fin (n+1)))) + let S := localR (PartialColumn.rowPosition r hr) (mergeWeights (constF (m+1) phase)) + have hw : (mergeWeights (constF (m+1) phase)).map (pairReflection m s) = + mergeWeights (constF (m+1) phase) := by + simp [Weights.map,mergeWeights,map_div₀] + calc + _ = S.map (pairReflection m s) * E.map (pairReflection m s) := Matrix.map_mul + _ = _ := by + dsimp only [S,E] + rw [localR_map_hom,functionMatrix_map_hom,hw] + rfl + + + +theorem polynomialNorthSource_reflected_merge (n : ℕ) : + (sourceBlock (mergeProjection (m:=n+1) 0 (show 2≤n+3 by omega))).mulVec + (fun p => pairEvaluation n 2 (reflectLaurent (n+2) (polynomialNorthSource (n+2) p))) = + mergePairScalar n • + (fun q => mergeEvaluation n (reflectLaurent (n+1) (polynomialNorthSource (n+1) q))) := by + have ht : (fun p : SourcePairing (n+2) => pairReflection n 2 + (pairEvaluation n 2 (polynomialNorthSource (n+2) p))) = + mergePairScalar n • + (sourceBlock (mergeMap (m:=n+1) 0 (show 2≤n+3 by omega))).mulVec + (fun q => mergeEvaluation n (reflectLaurent (n+1) (polynomialNorthSource (n+1) q))) := by + funext p + rw [polynomialNorthSource_merge,map_mul,pairReflection_mergeScalar, + RingHom.map_mulVec,sourceBlock_map,pairReflection_mergeMap] + simp only [Pi.smul_apply,smul_eq_mul] + congr 2 + funext q + exact pairReflection_mergeEvaluation _ + have hc := polynomialNorthSource_reflected_pair n 2 (Or.inl rfl) + apply sourceBlock_merge_injective (n:=n+1) (m:=n+1) 0 (show 2≤n+2 by omega) + rw [Matrix.mulVec_mulVec] + refine (congrArg (fun M => M.mulVec (fun p => + pairEvaluation n 2 (reflectLaurent (n+2) (polynomialNorthSource (n+2) p)))) + (sourceBlock_merge_factor (m:=n+1) 0 (show 2≤n+1+1 by omega))).trans ?_ + rw [←hc,ht,Matrix.mulVec_smul] + + +theorem polynomialNorthSource_reflected_delete (n : ℕ) : + (sourceBlock (deletionProjection (m:=n+1) 0 (show 2≤n+3 by omega))).mulVec + (fun p => pairEvaluation n 3 (reflectLaurent (n+2) (polynomialNorthSource (n+2) p))) = + deletePairScalar n • + (fun q => deleteEvaluation n (reflectLaurent n (polynomialNorthSource n q))) := by + have ht : (fun p : SourcePairing (n+2) => pairReflection n 3 + (pairEvaluation n 3 (polynomialNorthSource (n+2) p))) = + deletePairScalar n • + (sourceBlock (deletionMap (m:=n+1) 0 (show 2≤n+3 by omega))).mulVec + (fun q => deleteEvaluation n (reflectLaurent n (polynomialNorthSource n q))) := by + funext p + rw [polynomialNorthSource_delete,map_mul,pairReflection_deleteScalar, + RingHom.map_mulVec,sourceBlock_map,deletionMap_map] + simp only [Pi.smul_apply,smul_eq_mul] + congr 2 + funext q + exact pairReflection_deleteEvaluation _ + have hc := polynomialNorthSource_reflected_pair n 3 (Or.inr rfl) + apply sourceBlock_deletion_injective (n:=n) (m:=n+1) 0 (show 2≤n+2 by omega) + rw [Matrix.mulVec_mulVec] + refine (congrArg (fun M => M.mulVec (fun p => + pairEvaluation n 3 (reflectLaurent (n+2) (polynomialNorthSource (n+2) p)))) + (sourceBlock_deletion_factor (m:=n+1) 0 (show 2≤n+2 by omega))).trans ?_ + rw [←hc,ht,Matrix.mulVec_smul] + +end +end CriticalStrip.Diagram + +end OAI diff --git a/lean/OAI/Combinatorics/StripMass/QuarterMoments.lean b/lean/OAI/Combinatorics/StripMass/QuarterMoments.lean new file mode 100644 index 0000000000000000000000000000000000000000..d1984f0baa0b14076ab821fe6e014758af6e79e0 --- /dev/null +++ b/lean/OAI/Combinatorics/StripMass/QuarterMoments.lean @@ -0,0 +1,413 @@ +import Mathlib +import OAI.Combinatorics.StripMass.InverseMoments + +namespace OAI + +/-! Critical honeycomb strip paths, polynomial identities and crossing mass. -/ + + +namespace CriticalStrip +noncomputable section +open scoped BigOperators +open Set MeasureTheory +theorem laguerre_inverseQuarterSum_upper (n : ℕ) : + (∫ r, inverseQuarterStatistic (n+1) r ∂laguerreLaw (n+1) (1/2)) ≤ + (2*(2/Real.Gamma (1/2))^(1/2:ℝ)+2) * ((n:ℝ)+1)^(1/2:ℝ) := by + let μ := laguerreLaw (n+1) (1/2) + let S := fun r : Fin (n+1) → ℝ => ∑ i : Fin n, (r i.succ)⁻¹ + let T : ℝ := ((n:ℝ)+1)^2 + have ht : 0 < T := by dsimp [T]; positivity + have he : T^(1/4:ℝ) = ((n:ℝ)+1)^(1/2:ℝ) := by + dsimp only [T] + rw [← Real.rpow_natCast_mul (by positivity : 0 ≤ (n:ℝ)+1)] + norm_num + let : IsProbabilityMeasure μ := laguerreLaw_isProbabilityMeasure _ (by norm_num) + have hi : Integrable S μ := integrable_laguerreLaw (by norm_num) + (integrableOn_laguerre_tailInverseSum (by norm_num : (0:ℝ)<1/2)) + have hfirst : Integrable (fun r : Fin (n+1) → ℝ => (r 0)^(-(1/4:ℝ))) μ := + integrable_laguerreLaw_inverse_coordinate (by norm_num) 0 (by norm_num) + have hmaj : Integrable (fun r => (r 0)^(-(1/4:ℝ)) + T^(1/4:ℝ)*(1+S r/T)) μ := + hfirst.add (((integrable_const 1).add (hi.div_const T)).const_mul _) + have hpoint : inverseQuarterStatistic (n+1) ≤ᵐ[μ] + (fun r => (r 0)^(-(1/4:ℝ)) + T^(1/4:ℝ)*(1+S r/T)) := by + filter_upwards [ae_laguerreDomain (n+1) (1/2)] with r hr + have hs : 0 ≤ S r := Finset.sum_nonneg fun i _ => (inv_pos.mpr (hr.2 i.succ)).le + change (∑ i, (r i)⁻¹)^(1/4:ℝ) ≤ _ + rw [Fin.sum_univ_succ] + apply (Real.rpow_add_le_add_rpow (inv_pos.mpr (hr.2 0)).le hs (by norm_num) (by norm_num)).trans + rw [Real.inv_rpow (hr.2 0).le, ← Real.rpow_neg (hr.2 0).le] + exact add_le_add_right (rpow_quarter_le_linear_scaled hs ht) _ + have H := integral_mono_ae (integrable_laguerreLaw_inverseQuarterSum (by norm_num : (1/4:ℝ)<1/2)) + hmaj hpoint + have hs : (∫ r, S r ∂μ) ≤ T := by + rw [show μ = laguerreLaw (n+1) (1/2) from rfl, integral_laguerreLaw _ (by norm_num)] + exact laguerre_tailInverseSum_half_upper n + have hf := laguerre_least_inverseQuarter_upper n + rw [← integral_laguerreLaw _ (by norm_num : (0:ℝ)<1/2)] at hf + have hroot : 0 ≤ T^(1/4:ℝ) := (Real.rpow_pos_of_pos ht _).le + have hj : Integrable (fun r => 1+S r/T) μ := (integrable_const 1).add (hi.div_const T) + have hk : Integrable (fun r => T^(1/4:ℝ)*(1+S r/T)) μ := hj.const_mul _ + change (∫ r, inverseQuarterStatistic (n+1) r ∂μ) ≤ + ∫ r, (r 0)^(-(1/4:ℝ)) + T^(1/4:ℝ)*(1+S r/T) ∂μ at H + rw [integral_add hfirst hk, integral_const_mul, + integral_add (integrable_const 1) (hi.div_const T), integral_div, + integral_const, probReal_univ, one_smul] at H + have hs' : (∫ r, S r ∂μ)/T ≤ 1 := (div_le_one ht).2 hs + calc + _ ≤ _ := H + _ ≤ (2*(2/Real.Gamma (1/2))^(1/2:ℝ)) * ((n:ℝ)+1)^(1/2:ℝ) + T^(1/4:ℝ)*2 := by + exact add_le_add hf (mul_le_mul_of_nonneg_left (by linarith) hroot) + _ = _ := by rw [he]; ring + + + + + +lemma reciprocal_product_two_succ (n : ℕ) : + (∏ i : Fin n, ((i.val:ℝ)+1)/(i.val+3)) = 2/((n+1)*(n+2)) := by + induction n with + | zero => norm_num + | succ n ih => + rw [Fin.prod_univ_castSucc] + simp only [Fin.val_castSucc, Fin.val_last, Nat.cast_add, Nat.cast_one] + rw [ih] + have h1 : (n:ℝ)+1 ≠ 0 := by positivity + have h2 : (n:ℝ)+2 ≠ 0 := by positivity + have h3 : (n:ℝ)+3 ≠ 0 := by positivity + field_simp + ring + +lemma laguerreNormalizer_one_step (n : ℕ) : + laguerreNormalizer (n+1) 1 = + 2/((n+1)*(n+2)) * laguerreNormalizer n 2 := by + rw [laguerreNormalizer_succ_product n (by norm_num : (0:ℝ)<1)] + norm_num only [Real.Gamma_one] + have he : (fun i : Fin n => ((i.val:ℝ)+1)/(2+i.val+1)) = + (fun i : Fin n => ((i.val:ℝ)+1)/(i.val+3)) := by ext i; congr 1; ring + rw [he, reciprocal_product_two_succ] + ring + +lemma laguerreNormalizer_one_ratio (n : ℕ) : + laguerreNormalizer n 2 / laguerreNormalizer (n+1) 1 = ((n:ℝ)+1)*(n+2)/2 := by + rw [laguerreNormalizer_one_step] + have hz : laguerreNormalizer n 2 ≠ 0 := (laguerreNormalizer_pos n (by norm_num)).ne' + have h1 : (n:ℝ)+1 ≠ 0 := by positivity + have h2 : (n:ℝ)+2 ≠ 0 := by positivity + field_simp + +lemma minTiltProduct_lower {n : ℕ} {s : ℝ} (hs : 0 ≤ s) {r : Fin n → ℝ} (hr : ∀ i, 0 < r i) : + 1-3*s*inverseSum n r ≤ minTiltProduct n s r := by + have h := abs_one_sub_prod_le Finset.univ (fun i : Fin n => minTilt s (r i)) + (fun i _ => by rw [abs_of_nonneg (minTilt_nonneg hs (hr i))]; exact minTilt_le_one hs (hr i)) + have hp := minTiltProduct_le_one hs hr + change |1-minTiltProduct n s r| ≤ ∑ i, |1-minTilt s (r i)| at h + rw [abs_of_nonneg (by linarith)] at h + have hsum : (∑ i, |1-minTilt s (r i)|) ≤ 3*s*inverseSum n r := by + unfold inverseSum + rw [Finset.mul_sum] + apply Finset.sum_le_sum + intro i _ + rw [abs_of_nonneg (sub_nonneg.mpr (minTilt_le_one hs (hr i))), ← div_eq_mul_inv] + exact one_sub_minTilt_le hs (hr i) + linarith + +lemma laguerre_minTiltProduct_lower (n : ℕ) {a s : ℝ} (ha : 1 < a) (hs : 0 ≤ s) : + 1-3*s*((n:ℝ)*(2*a+n-1)/(2*a*(a-1))) ≤ + ∫ r, minTiltProduct n s r ∂laguerreLaw n a := by + have ha0 : 0 < a := by linarith + let := laguerreLaw_isProbabilityMeasure n ha0 + have hi := (integrable_laguerreLaw_inverseSum (n := n) ha).const_mul (3*s) + have h := integral_mono_ae ((integrable_const 1).sub hi) + (integrable_laguerreLaw_minTiltProduct n ha0 hs) (show + (fun r => 1-3*s*inverseSum n r) ≤ᵐ[laguerreLaw n a] minTiltProduct n s from by + filter_upwards [ae_laguerreDomain n a] with r hr + exact minTiltProduct_lower hs hr.2) + have he : (∫ r, inverseSum n r ∂laguerreLaw n a) = (n:ℝ)*(2*a+n-1)/(2*a*(a-1)) := by + rw [integral_laguerreLaw n ha0] + exact laguerreExpectation_inverseSum n ha + change (∫ r, 1-3*s*inverseSum n r ∂laguerreLaw n a) ≤ _ at h + rw [integral_sub (integrable_const 1) hi, integral_const_mul, he, + integral_const, probReal_univ, one_smul] at h + exact h + +lemma laguerre_minTiltProduct_two_lower (n : ℕ) {s : ℝ} (hs : 0 ≤ s) + (hs' : s ≤ 1/(12*((n:ℝ)+1)^2)) : + laguerreNormalizer n 2 / 2 ≤ + ∫ r in laguerreDomain n, minTiltProduct n s r * laguerreDensity n 2 r := by + have hn : 0 ≤ (n:ℝ) := by positivity + have ht : 0 < ((n:ℝ)+1)^2 := by positivity + have hs2 : s * ((n:ℝ)+1)^2 ≤ 1/12 := by + have h := (le_div_iff₀ (by positivity : 0 < 12*((n:ℝ)+1)^2)).1 hs' + nlinarith + have he : (n:ℝ)*(2*2+n-1)/(2*2*(2-1)) ≤ ((n:ℝ)+1)^2 := by norm_num; nlinarith + have h := laguerre_minTiltProduct_lower n (by norm_num : (1:ℝ)<2) hs + have hh : (1/2:ℝ) ≤ ∫ r, minTiltProduct n s r ∂laguerreLaw n 2 := by + have hm := mul_le_mul_of_nonneg_left he (by positivity : 0 ≤ 3*s) + nlinarith + rw [integral_laguerreLaw _ (by norm_num), laguerreExpectation] at hh + have H := (le_div_iff₀ (laguerreNormalizer_pos n (by norm_num))).1 hh + linarith + +lemma smallCoordinate_scale_lower (n : ℕ) {s : ℝ} (hs : 0 < s) + (hs' : s ≤ 1/(12*((n:ℝ)+1)^2)) : + ((n:ℝ)+1)^(1/2:ℝ) ≤ s^(-(1/4:ℝ)) := by + have hn : 0 < (n:ℝ)+1 := by positivity + have ht : 0 < ((n:ℝ)+1)^2 := by positivity + have hle : s ≤ 1/((n:ℝ)+1)^2 := by + exact hs'.trans (one_div_le_one_div_of_le ht (by nlinarith)) + have H := Real.rpow_le_rpow_of_nonpos hs hle (by norm_num : -(1/4:ℝ)≤0) + rw [one_div, Real.inv_rpow ht.le, ← Real.rpow_neg ht.le, + neg_neg, ← Real.rpow_natCast_mul hn.le] at H + norm_num only at H + exact H + + + +theorem laguerre_least_inverseQuarter_lower (n : ℕ) : + (Real.exp (-1)/48) * ((n:ℝ)+1)^(1/2:ℝ) ≤ + laguerreExpectation (n+1) 1 (fun r => (r 0)^(-(1/4:ℝ))) := by + let t : ℝ := 1/(12*((n:ℝ)+1)^2) + have ht : 0 < t := by dsimp [t]; positivity + have ht1 : t ≤ 1 := by + apply (div_le_one (by positivity : 0 < 12*((n:ℝ)+1)^2)).2 + nlinarith [Nat.cast_nonneg (α := ℝ) n] + let F := fun s : ℝ => laguerreWeight 1 s * + ∫ r in laguerreDomain n, s^(-(1/4:ℝ)) * minTiltProduct n s r * laguerreDensity n 2 r + have hi := integrableOn_laguerre_inverse_coordinate (N := n+1) (by norm_num : (0:ℝ)<1) + (0 : Fin (n+1)) (p := 1/4) (by norm_num) + have hf : IntegrableOn F (Ioi 0) := by + simpa only [Fin.cons_zero, one_add_one_eq_two] using integrable_laguerre_splitMin n 1 + (fun r => (r 0)^(-(1/4:ℝ))) hi + have hnonneg (s : ℝ) (hs : 0 < s) : 0 ≤ F s := by + apply mul_nonneg (laguerreWeight_pos 1 hs).le + apply setIntegral_nonneg (isOpen_laguerreDomain n).measurableSet + intro r hr + exact mul_nonneg (mul_nonneg (Real.rpow_pos_of_pos hs _).le + (minTiltProduct_nonneg hs.le hr.2)) (laguerreDensity_pos 2 hr).le + have hbound (s : ℝ) (hs : s ∈ Ioo 0 t) : + ((n:ℝ)+1)^(1/2:ℝ) * Real.exp (-1) * (laguerreNormalizer n 2 /2) ≤ F s := by + have he : Real.exp (-1) ≤ laguerreWeight 1 s := by + simp only [laguerreWeight, sub_self, Real.rpow_zero, one_mul] + exact Real.exp_le_exp.2 (by have : s ≤ 1 := hs.2.le.trans ht1; linarith) + have hp := smallCoordinate_scale_lower n hs.1 hs.2.le + have hl := laguerre_minTiltProduct_two_lower n hs.1.le hs.2.le + have hz : 0 < laguerreNormalizer n 2 := laguerreNormalizer_pos n (by norm_num) + dsimp only [F] + simp_rw [mul_assoc (s^(-(1/4:ℝ))) _ _] + rw [integral_const_mul] + calc + _ ≤ Real.exp (-1) * (s^(-(1/4:ℝ))*(laguerreNormalizer n 2/2)) := by + nlinarith [mul_le_mul_of_nonneg_right hp (mul_nonneg (Real.exp_nonneg (-1)) (by positivity : 0 ≤ laguerreNormalizer n 2/2))] + _ ≤ laguerreWeight 1 s * (s^(-(1/4:ℝ)) * + ∫ r in laguerreDomain n, minTiltProduct n s r * laguerreDensity n 2 r) := by + exact mul_le_mul he (mul_le_mul_of_nonneg_left hl (Real.rpow_pos_of_pos hs.1 _).le) + (mul_nonneg (Real.rpow_pos_of_pos hs.1 _).le (by positivity)) (laguerreWeight_pos 1 hs.1).le + have hmass : + t * (((n:ℝ)+1)^(1/2:ℝ) * Real.exp (-1) * (laguerreNormalizer n 2/2)) ≤ ∫ s in Ioi 0, F s := by + calc + _ = ∫ s in Ioo 0 t, ((n:ℝ)+1)^(1/2:ℝ) * Real.exp (-1) * (laguerreNormalizer n 2/2) := by + rw [integral_const, Measure.real, Measure.restrict_apply_univ, Real.volume_Ioo, ENNReal.toReal_ofReal (by linarith), smul_eq_mul] + simp + _ ≤ ∫ s in Ioo 0 t, F s := by + apply setIntegral_mono_on (integrableOn_const (by simp : volume (Ioo 0 t) ≠ ⊤)) + (hf.mono_set Ioo_subset_Ioi_self) measurableSet_Ioo hbound + _ ≤ _ := setIntegral_mono_set hf (by + filter_upwards [ae_restrict_mem measurableSet_Ioi] with s hs + exact hnonneg s hs) (Filter.Eventually.of_forall Ioo_subset_Ioi_self) + have hiEq : (∫ r in laguerreDomain (n+1), (r 0)^(-(1/4:ℝ))*laguerreDensity (n+1) 1 r) = + ∫ s in Ioi 0, F s := by + simpa only [Fin.cons_zero, one_add_one_eq_two] using integral_laguerre_splitMin n 1 + (fun r => (r 0)^(-(1/4:ℝ))) hi + unfold laguerreExpectation + rw [hiEq] + apply (div_le_div_of_nonneg_right hmass (laguerreNormalizer_pos (n+1) (by norm_num)).le).trans' + have hz : 0 < laguerreNormalizer (n+1) 1 := laguerreNormalizer_pos (n+1) (by norm_num) + have he : t * (((n:ℝ)+1)^(1/2:ℝ) * Real.exp (-1) * (laguerreNormalizer n 2/2)) / + laguerreNormalizer (n+1) 1 = + (((n:ℝ)+1)^(1/2:ℝ) * Real.exp (-1)) * ((n:ℝ)+2)/(48*((n:ℝ)+1)) := by + calc + _ = (t * (((n:ℝ)+1)^(1/2:ℝ) * Real.exp (-1))/2) * + (laguerreNormalizer n 2/laguerreNormalizer (n+1) 1) := by ring + _ = _ := by + rw [laguerreNormalizer_one_ratio] + dsimp only [t] + have hn : (n:ℝ)+1 ≠ 0 := by positivity + field_simp + ring + rw [he] + apply (le_div_iff₀ (by positivity : 0 < 48*((n:ℝ)+1))).2 + have hr : 0 ≤ ((n:ℝ)+1)^(1/2:ℝ) := Real.rpow_nonneg (by positivity) _ + nlinarith [mul_nonneg hr (Real.exp_nonneg (-1))] + +end + + + +noncomputable section +open scoped BigOperators +open Set MeasureTheory StripPfaffian + +lemma orderedPairProduct_snoc {α M : Type*} [CommMonoid M] (k : α → α → M) + {n : ℕ} (x : α) (r : Fin n → α) : + (∏ i : Fin (n+1), ∏ j ∈ Finset.Ioi i, k ((Fin.snoc r x : Fin (n+1) → α) i) ((Fin.snoc r x : Fin (n+1) → α) j)) = + (∏ i, ∏ j ∈ Finset.Ioi i, k (r i) (r j)) * ∏ i, k (r i) x := by + classical + have he {m : ℕ} (s : Fin m → α) : + (∏ i : Fin m, ∏ j ∈ Finset.Ioi i, k (s i) (s j)) = + ∏ i : Fin m, ∏ j : Fin m, if i < j then k (s i) (s j) else 1 := by + apply Finset.prod_congr rfl + intro i _ + rw [← Finset.prod_filter] + congr 1 + ext j + simp + rw [he, he] + simp [Fin.prod_univ_castSucc, Finset.prod_mul_distrib, not_lt.mpr (Fin.le_last _)] + +lemma gammaSchurProduct_snoc {n : ℕ} (r : ℝ) (q : Fin n → ℝ) : + gammaSchurProduct (Fin.snoc q r) = + gammaSchurProduct q * Real.Gamma r * (∏ i, (r-q i)/(q i+r)) := by + unfold gammaSchurProduct + rw [orderedPairProduct_snoc (fun r s : ℝ => (s-r)/(r+s))] + simp only [Fin.prod_univ_castSucc, Fin.snoc_castSucc, Fin.snoc_last] + ring + +lemma laguerreNormalizer_snoc_product (n : ℕ) {a : ℝ} (ha : 0 < a) : + laguerreNormalizer (n+1) a = laguerreNormalizer n a * Real.Gamma (a+n) * + (∏ i : Fin n, ((n:ℝ)-i.val)/(2*a+i.val+n)) := by + rw [laguerreNormalizer_eq_product _ ha, + ← gammaSchurProduct_laguerre, laguerreNormalizer_eq_product _ ha, + ← gammaSchurProduct_laguerre] + have hq : (fun i : Fin (n+1) => a+i.val) = Fin.snoc (fun i => a+i.val) (a+n) := by + ext i + refine Fin.lastCases ?_ (fun i => ?_) i <;> simp + rw [hq, gammaSchurProduct_snoc] + congr 1 + apply Finset.prod_congr rfl + intro i _ + congr 1 <;> ring + +lemma prod_nat_sub (n : ℕ) : (∏ i : Fin n, ((n:ℝ)-i.val)) = n.factorial := by + have he : (fun i : Fin n => (n:ℝ)-i.val) = (fun i => ((n-i.val:ℕ):ℝ)) := by + ext i + exact (Nat.cast_sub i.isLt.le).symm + rw [he, ← Nat.cast_prod, Fin.prod_univ_eq_prod_range, ← Nat.descFactorial_eq_prod_range, + Nat.descFactorial_self] + +lemma prod_nat_add (n : ℕ) : (∏ i : Fin n, (1+(i.val:ℝ)+n)) = ((n+1).ascFactorial n:ℝ) := by + have he : (fun i : Fin n => 1+(i.val:ℝ)+n) = (fun i => ((n+1+i.val:ℕ):ℝ)) := by + ext i + push_cast + ring + rw [he, ← Nat.cast_prod, Fin.prod_univ_eq_prod_range, ← Nat.ascFactorial_eq_prod_range] + +lemma laguerreNormalizer_max_half_ratio (n : ℕ) : + laguerreNormalizer n (1/2) / laguerreNormalizer (n+1) (1/2) * Real.Gamma (1/2+n) = + ((n+n).choose n:ℝ) := by + rw [laguerreNormalizer_snoc_product n (by norm_num : (0:ℝ)<1/2)] + norm_num only + rw [Finset.prod_div_distrib, prod_nat_sub, prod_nat_add, Nat.cast_add_choose ℝ] + have he : (n.factorial:ℝ) * ((n+1).ascFactorial n:ℝ) = ((n+n).factorial:ℝ) := by + exact_mod_cast Nat.factorial_mul_ascFactorial n n + rw [← he] + have hz : laguerreNormalizer n (1/2) ≠ 0 := (laguerreNormalizer_pos n (by norm_num)).ne' + have hg : Real.Gamma (1/2+n) ≠ 0 := (Real.Gamma_pos_of_pos (by positivity : (0:ℝ)<1/2+n)).ne' + have hf : (n.factorial:ℝ) ≠ 0 := Nat.cast_ne_zero.mpr (Nat.factorial_ne_zero n) + have hF : ((n+1).ascFactorial n:ℝ) ≠ 0 := by + have : 0 < (n+1).ascFactorial n := Nat.ascFactorial_pos n n + exact_mod_cast this.ne' + field_simp + +lemma choose_double_le_four_pow (n : ℕ) : ((n+n).choose n:ℝ) ≤ (4:ℝ)^n := by + have h := Nat.choose_le_two_pow (n+n) n + have he : (2:ℕ)^(n+n) = 4^n := by rw [pow_add, ← mul_pow]; norm_num + rw [he] at h + exact_mod_cast h + +lemma elementary_exp_half_bound (n : ℕ) : + (4:ℝ)^n * (Real.exp (-(16*((n:ℝ)+1))/2) * 2^((1/2:ℝ)+n)) ≤ 1/4 := by + have hh : (2:ℝ)^((1/2:ℝ)+n) ≤ (2:ℝ)^(n+1) := by + rw [← Real.rpow_natCast] + apply Real.rpow_le_rpow_of_exponent_le (by norm_num) + push_cast + linarith + have he : Real.exp (-8) ≤ (1/8:ℝ) := by + rw [Real.exp_neg] + simpa only [one_div] using inv_anti₀ (by norm_num : (0:ℝ)<8) + (by linarith [Real.add_one_le_exp (8:ℝ)] : 8 ≤ Real.exp 8) + have hn : (Real.exp (-8))^(n+1) ≤ (1/8:ℝ)^(n+1) := + pow_le_pow_left₀ (Real.exp_nonneg _) he _ + have hexp : Real.exp (-(16*((n:ℝ)+1))/2) = (Real.exp (-8))^(n+1) := by + rw [← Real.exp_nat_mul] + congr 1 + push_cast + ring + calc + _ ≤ (4:ℝ)^n * ((1/8:ℝ)^(n+1) * (2:ℝ)^(n+1)) := by + rw [hexp] + exact mul_le_mul_of_nonneg_left (mul_le_mul hn hh (by positivity) (by positivity)) (by positivity) + _ = 1/4 := by + rw [← mul_pow, pow_succ, ← mul_assoc, ← mul_pow] + norm_num + + + +theorem laguerreLaw_max_half_uniform (n : ℕ) : + (laguerreLaw (n+1) (1/2)).real {r | 16*((n:ℝ)+1) < r (Fin.last n)} ≤ 1/4 := by + have h := laguerreLaw_max_tail_exp_bound n (by norm_num : (0:ℝ)<1/2) + (by positivity : 0 ≤ 16*((n:ℝ)+1)) + have he : (laguerreNormalizer n (1/2) / laguerreNormalizer (n+1) (1/2)) * + (Real.exp (-(16*((n:ℝ)+1))/2) * (2^((1/2:ℝ)+n)*Real.Gamma (1/2+n))) = + ((n+n).choose n:ℝ) * (Real.exp (-(16*((n:ℝ)+1))/2) * 2^((1/2:ℝ)+n)) := by + rw [← laguerreNormalizer_max_half_ratio] + ring + rw [he] at h + calc + _ ≤ _ := h + _ ≤ (4:ℝ)^n * (Real.exp (-(16*((n:ℝ)+1))/2) * 2^((1/2:ℝ)+n)) := + mul_le_mul_of_nonneg_right (choose_double_le_four_pow n) (by positivity) + _ ≤ _ := elementary_exp_half_bound n + +end + + + +noncomputable section +open scoped BigOperators +open Set MeasureTheory + +lemma laguerreLaw_cutoff_half_uniform (n : ℕ) : + (1/2:ℝ) ≤ (laguerreLaw (n+1) (1/2)).real (cutoffEvent (n+1) (32*((n:ℝ)+1))) := by + let μ := laguerreLaw (n+1) (1/2) + have : IsProbabilityMeasure μ := laguerreLaw_isProbabilityMeasure _ (by norm_num) + have hsubset : (cutoffEvent (n+1) (32*((n:ℝ)+1)))ᶜ ≤ᵐ[μ] + {r | 16*((n:ℝ)+1) < r (Fin.last n)} := by + filter_upwards [ae_laguerreDomain (n+1) (1/2)] with r hr + intro h + change r ∉ cutoffEvent (n+1) (32*((n:ℝ)+1)) at h + have hh : ¬ r (Fin.last n) < 32*((n:ℝ)+1) := by + simpa only [mem_compl_iff, mem_cutoffEvent_iff_last hr.1.monotone] using h + have hn := Nat.cast_nonneg (α := ℝ) n + change 16*((n:ℝ)+1) < r (Fin.last n) + linarith [le_of_not_gt hh] + have hreal : μ.real (cutoffEvent (n+1) (32*((n:ℝ)+1)))ᶜ ≤ + μ.real {r | 16*((n:ℝ)+1) < r (Fin.last n)} := + ENNReal.toReal_mono (measure_ne_top _ _) (measure_mono_ae hsubset) + rw [measureReal_compl (measurableSet_cutoffEvent _ _), probReal_univ] at hreal + have H := laguerreLaw_max_half_uniform n + change μ.real {r | 16*((n:ℝ)+1) < r (Fin.last n)} ≤ 1/4 at H + change (1/2:ℝ) ≤ μ.real (cutoffEvent (n+1) (32*((n:ℝ)+1))) + linarith + +def referenceUpperConstant : ℝ := 2*(2/Real.Gamma (1/2))^(1/2:ℝ)+2 + +lemma referenceUpperConstant_pos : 0 < referenceUpperConstant := by + have hg : 0 < Real.Gamma (1/2) := Real.Gamma_pos_of_pos (by norm_num) + dsimp [referenceUpperConstant] + positivity + + +end +end CriticalStrip + +end OAI diff --git a/lean/OAI/Combinatorics/StripMass/QuarticIntegrals.lean b/lean/OAI/Combinatorics/StripMass/QuarticIntegrals.lean new file mode 100644 index 0000000000000000000000000000000000000000..0a63625fb2e7efffc52584f29b188bac4c0ac3f9 --- /dev/null +++ b/lean/OAI/Combinatorics/StripMass/QuarticIntegrals.lean @@ -0,0 +1,428 @@ +import Mathlib +import OAI.Combinatorics.StripMass.CauchyMatrices + +namespace OAI + +/-! Critical honeycomb strip paths, polynomial identities and crossing mass. -/ + + +namespace CriticalStrip +noncomputable section +open Set MeasureTheory Filter +open scoped Topology +theorem quartic_weighted_integral_sqrt {r : ℝ} (hr : 0 < r) : + (∫ t in Ioi 0, quarticWeighted r t) = Real.pi * Real.sqrt ((1 + r) / 2) := by + rw [(quartic_weighted_integral hr).2] + have hs : Real.sqrt (2 + 2 * r) = 2 * Real.sqrt ((1 + r) / 2) := by + rw [show 2 + 2 * r = 4 * ((1 + r) / 2) by ring, + Real.sqrt_mul (by norm_num : (0 : ℝ) ≤ 4)] + norm_num + rw [hs] + apply (div_eq_iff (by positivity : 2 * Real.sqrt ((1 + r) / 2) ≠ 0)).2 + have hsq := Real.sq_sqrt (by positivity : (0 : ℝ) ≤ (1 + r) / 2) + linear_combination -2 * Real.pi * hsq + +def minusBranch (s : ℝ) : ℝ := Real.sqrt ((1 + Real.sqrt ((1 + s) / 2)) / 2) + +theorem minusBranch_zero : minusBranch 0 = Real.cos (Real.pi / 8) := by + rw [Real.cos_pi_div_eight] + have h : Real.sqrt ((1 + (0 : ℝ)) / 2) = Real.sqrt 2 / 2 := by + have ha := Real.sq_sqrt (by norm_num : (0 : ℝ) ≤ (1 + 0) / 2) + have hb := Real.sq_sqrt (by norm_num : (0 : ℝ) ≤ 2) + have hna := Real.sqrt_nonneg ((1 + (0 : ℝ)) / 2) + have hnb := Real.sqrt_nonneg (2 : ℝ) + nlinarith + unfold minusBranch + rw [h] + have ha := Real.sq_sqrt (by positivity : (0 : ℝ) ≤ (1 + Real.sqrt 2 / 2) / 2) + have hb := Real.sq_sqrt (by positivity : (0 : ℝ) ≤ 2 + Real.sqrt 2) + have hna := Real.sqrt_nonneg ((1 + Real.sqrt 2 / 2) / 2) + have hnb := Real.sqrt_nonneg (2 + Real.sqrt 2) + nlinarith + +theorem transformed_omega {s t : ℝ} (hs : 0 < s) (ht : 0 < t) : + |(-8 * t * (t ^ 2 + 1) / uniformDen t ^ 2)| • + (s * omega (uniformizer t) / (1 + s * uniformizer t)) = + quarticWeighted (Real.sqrt ((1 + s) / 2)) t - + quarticWeighted (Real.sqrt (1 / 2)) t := by + rw [omega_uniformizer ht, abs_of_neg (by + exact div_neg_of_neg_of_pos (by nlinarith [sq_nonneg t]) + (sq_pos_of_pos (uniformDen_pos t))), smul_eq_mul] + unfold quarticWeighted quarticDen + rw [Real.sq_sqrt (by positivity : (0 : ℝ) ≤ (1 + s) / 2), + Real.sq_sqrt (by norm_num : (0 : ℝ) ≤ 1 / 2)] + unfold uniformizer uniformDen + field_simp + ring + +theorem omega_resolvent {s : ℝ} (hs : 0 < s) : + IntegrableOn (fun x => s * omega x / (1 + s * x)) (Ioo 0 1) ∧ + (∫ x in Ioo 0 1, s * omega x / (1 + s * x)) = + Real.pi * (minusBranch s - minusBranch 0) := by + have hr : 0 < Real.sqrt ((1 + s) / 2) := by positivity + have hr0 : 0 < Real.sqrt ((1 : ℝ) / 2) := by positivity + have hint := (quartic_weighted_integral hr).1.sub (quartic_weighted_integral hr0).1 + have hi := integrableOn_image_iff_integrableOn_abs_deriv_smul measurableSet_Ioi + (fun t _ => (uniformizer_deriv t).hasDerivWithinAt) uniformizer_inj + (fun x => s * omega x / (1 + s * x)) + rw [uniformizer_image] at hi + constructor + · apply hi.2 + exact IntegrableOn.congr_fun hint (fun t ht => (transformed_omega hs ht).symm) + measurableSet_Ioi + · have h := integral_image_eq_integral_abs_deriv_smul measurableSet_Ioi + (fun t _ => (uniformizer_deriv t).hasDerivWithinAt) uniformizer_inj + (fun x => s * omega x / (1 + s * x)) + rw [uniformizer_image] at h + rw [h, setIntegral_congr_fun measurableSet_Ioi (fun t ht => transformed_omega hs ht), + integral_sub (quartic_weighted_integral hr).1 (quartic_weighted_integral hr0).1, + quartic_weighted_integral_sqrt hr, quartic_weighted_integral_sqrt hr0] + simp only [minusBranch, add_zero] + ring + + + +theorem stieltjes_omega {z : ℝ} (hz : z < 0) : + Real.sqrt ((1 + Real.sqrt ((1 - 1 / z) / 2)) / 2) = + Real.cos (Real.pi / 8) + (1 / Real.pi) * + ∫ x in Ioo (0 : ℝ) 1, omega x / (x - z) := by + have hs : 0 < -1 / z := div_pos_of_neg_of_neg (by norm_num) hz + have heq : EqOn (fun x => (-1 / z) * omega x / (1 + (-1 / z) * x)) + (fun x => omega x / (x - z)) (Ioo 0 1) := by + intro x hx + dsimp only + have ha : 1 + (-1 / z) * x ≠ 0 := ne_of_gt (by have := hx.1; positivity) + have hb : x - z ≠ 0 := by linarith [hx.1] + apply (div_eq_div_iff ha hb).2 + field_simp [hz.ne] + ring + have h := (omega_resolvent hs).2 + rw [setIntegral_congr_fun measurableSet_Ioo heq, minusBranch_zero] at h + have he : minusBranch (-1 / z) = + Real.sqrt ((1 + Real.sqrt ((1 - 1 / z) / 2)) / 2) := by + unfold minusBranch + congr 4 + ring + rw [he] at h + rw [h] + field_simp + ring + +def lBranch (x : ℝ) : ℝ := Real.sqrt (1 + Real.sqrt ((1 + 1 / x) / 2)) + +theorem stieltjes_lBranch {z : ℝ} (hz : 0 < z) : + lBranch z = Real.sqrt 2 * Real.cos (Real.pi / 8) + + (Real.sqrt 2 / Real.pi) * ∫ x in Ioo (0 : ℝ) 1, omega x / (x + z) := by + have h := stieltjes_omega (neg_neg_of_pos hz) + have heq : lBranch z = Real.sqrt 2 * + Real.sqrt ((1 + Real.sqrt ((1 - 1 / (-z)) / 2)) / 2) := by + rw [← Real.sqrt_mul (by norm_num : (0 : ℝ) ≤ 2)] + unfold lBranch + congr 2 + field_simp + ring_nf + rw [heq, h] + simp only [sub_neg_eq_add] + ring + +def squareWeight (x : ℝ) : ℝ := Real.sqrt ((1 - x) / (8 * x)) + +theorem lBranch_mul_omega {x : ℝ} (hx : x ∈ Ioo 0 1) : + lBranch x * omega x = squareWeight x := by + have hx0 : 0 < x := hx.1 + have heq : (1 + 1 / x) / 2 = (1 + x) / (2 * x) := by + field_simp [hx0.ne'] + ring + have hsq := Real.sq_sqrt (by positivity : (0 : ℝ) ≤ (1 + x) / (2 * x)) + have hp : (1 + Real.sqrt ((1 + x) / (2 * x))) * + (Real.sqrt ((1 + x) / (2 * x)) - 1) = (1 - x) / (2 * x) := by + calc + _ = (1 + x) / (2 * x) - 1 := by nlinarith + _ = _ := by field_simp [hx0.ne']; ring + unfold lBranch omega squareWeight + rw [heq, ← mul_assoc, mul_comm (Real.sqrt _) (1 / 2 : ℝ), mul_assoc, + ← Real.sqrt_mul (by positivity : (0 : ℝ) ≤ 1 + Real.sqrt ((1 + x) / (2 * x))), hp] + have heq2 : (1 - x) / (8 * x) = (1 / 4) * ((1 - x) / (2 * x)) := by ring + rw [heq2, Real.sqrt_mul (by norm_num : (0 : ℝ) ≤ 1 / 4)] + norm_num + +theorem scaled_cauchy_Ioi {a : ℝ} (ha : 0 < a) : + (∫ t in Ioi (0 : ℝ), (a ^ 2 + t ^ 2)⁻¹) = Real.pi / (2 * a) := by + have heq : (fun t : ℝ => (a ^ 2 + t ^ 2)⁻¹) = + fun t => (a ^ 2)⁻¹ * (1 + (a⁻¹ * t) ^ 2)⁻¹ := by + funext t + field_simp + rw [heq, integral_const_mul, integral_comp_mul_left_Ioi (fun t : ℝ => (1 + t ^ 2)⁻¹) 0 (inv_pos.2 ha)] + simp only [mul_zero, inv_inv, smul_eq_mul, integral_Ioi_inv_one_add_sq, + Real.arctan_zero, sub_zero] + field_simp + +def squareUniformizer (t : ℝ) : ℝ := 1 / (1 + t ^ 2) + +theorem squareUniformizer_deriv (t : ℝ) : + HasDerivAt squareUniformizer (-2 * t / (1 + t ^ 2) ^ 2) t := by + have hd : HasDerivAt (fun t : ℝ => 1 + t ^ 2) (2 * t) t := by + simpa using ((hasDerivAt_id t).pow 2).const_add 1 + change HasDerivAt (fun t : ℝ => 1 / (1 + t ^ 2)) _ t + exact (((hasDerivAt_const t (1 : ℝ)).div hd + (show 1 + t ^ 2 ≠ 0 by positivity))).congr_deriv (by ring) + +theorem squareUniformizer_inj : InjOn squareUniformizer (Ioi 0) := by + apply StrictAntiOn.injOn + intro x hx y hy hxy + unfold squareUniformizer + apply one_div_lt_one_div_of_lt (by positivity) + gcongr + exact le_of_lt hx + +theorem squareUniformizer_image : squareUniformizer '' Ioi 0 = Ioo 0 1 := by + ext x + constructor + · rintro ⟨t, ht, rfl⟩ + refine ⟨by unfold squareUniformizer; positivity, ?_⟩ + unfold squareUniformizer + rw [div_lt_one (by positivity)] + exact lt_add_of_pos_right 1 (sq_pos_of_pos ht) + · intro hx + have hpos : 0 < 1 / x - 1 := by + rw [sub_pos, one_lt_div hx.1] + exact hx.2 + have hs := Real.sq_sqrt hpos.le + refine ⟨Real.sqrt (1 / x - 1), Real.sqrt_pos.2 hpos, ?_⟩ + unfold squareUniformizer + rw [hs] + field_simp [hx.1.ne'] + ring + +theorem squareWeight_uniformizer {t : ℝ} (ht : 0 < t) : + squareWeight (squareUniformizer t) = t / (2 * Real.sqrt 2) := by + have heq : (1 - squareUniformizer t) / (8 * squareUniformizer t) = t ^ 2 / 8 := by + unfold squareUniformizer + field_simp + ring + unfold squareWeight + rw [heq, Real.sqrt_div (sq_nonneg t), Real.sqrt_sq ht.le] + congr 1 + rw [show (8 : ℝ) = 4 * 2 by norm_num, Real.sqrt_mul (by norm_num : (0 : ℝ) ≤ 4)] + norm_num + +theorem transformed_squareWeight {s t : ℝ} (hs : 0 < s) (ht : 0 < t) : + |(-2 * t / (1 + t ^ 2) ^ 2)| • + (s * squareWeight (squareUniformizer t) / (1 + s * squareUniformizer t)) = + (1 / Real.sqrt 2) * ((1 + s) * ((1 + s) + t ^ 2)⁻¹ - (1 + t ^ 2)⁻¹) := by + rw [squareWeight_uniformizer ht, abs_of_neg (by + exact div_neg_of_neg_of_pos (by linarith) (by positivity)), smul_eq_mul] + unfold squareUniformizer + field_simp + ring + +theorem squareWeight_resolvent {s : ℝ} (hs : 0 < s) : + IntegrableOn (fun x => s * squareWeight x / (1 + s * x)) (Ioo 0 1) ∧ + (∫ x in Ioo 0 1, s * squareWeight x / (1 + s * x)) = + (Real.pi / (2 * Real.sqrt 2)) * (Real.sqrt (1 + s) - 1) := by + let a := Real.sqrt (1 + s) + have ha : 0 < a := by dsimp [a]; positivity + have ha2 : a ^ 2 = 1 + s := Real.sq_sqrt (by positivity) + have hint1 : IntegrableOn (fun t : ℝ => ((1 + s) + t ^ 2)⁻¹) (Ioi 0) := by + rw [← ha2] + exact (scaled_cauchy ha).1.integrableOn + have hint0 : IntegrableOn (fun t : ℝ => (1 + t ^ 2)⁻¹) (Ioi 0) := + integrable_inv_one_add_sq.integrableOn + have hint := ((hint1.const_mul (1 + s)).sub hint0).const_mul (1 / Real.sqrt 2) + have hi := integrableOn_image_iff_integrableOn_abs_deriv_smul measurableSet_Ioi + (fun t _ => (squareUniformizer_deriv t).hasDerivWithinAt) squareUniformizer_inj + (fun x => s * squareWeight x / (1 + s * x)) + rw [squareUniformizer_image] at hi + constructor + · apply hi.2 + exact IntegrableOn.congr_fun hint (fun t ht => (transformed_squareWeight hs ht).symm) + measurableSet_Ioi + · have h := integral_image_eq_integral_abs_deriv_smul measurableSet_Ioi + (fun t _ => (squareUniformizer_deriv t).hasDerivWithinAt) squareUniformizer_inj + (fun x => s * squareWeight x / (1 + s * x)) + rw [squareUniformizer_image] at h + rw [h, setIntegral_congr_fun measurableSet_Ioi (fun t ht => transformed_squareWeight hs ht), + integral_const_mul, integral_sub (hint1.const_mul (1 + s)) hint0, + integral_const_mul, ← ha2, scaled_cauchy_Ioi ha, integral_Ioi_inv_one_add_sq, + Real.arctan_zero, sub_zero] + rw [Real.sqrt_sq ha.le] + field_simp + +theorem stieltjes_omega_square {z : ℝ} (hz : z < 0) : + (Real.sqrt ((1 + Real.sqrt ((1 - 1 / z) / 2)) / 2)) ^ 2 = + (Real.cos (Real.pi / 8)) ^ 2 + (1 / Real.pi) * + ∫ x in Ioo (0 : ℝ) 1, lBranch x * omega x / (x - z) := by + have hs : 0 < -1 / z := div_pos_of_neg_of_neg (by norm_num) hz + have heq : EqOn (fun x => (-1 / z) * squareWeight x / (1 + (-1 / z) * x)) + (fun x => lBranch x * omega x / (x - z)) (Ioo 0 1) := by + intro x hx + dsimp only + rw [lBranch_mul_omega hx] + have ha : 1 + (-1 / z) * x ≠ 0 := ne_of_gt (by have := hx.1; positivity) + have hb : x - z ≠ 0 := by linarith [hx.1] + apply (div_eq_div_iff ha hb).2 + field_simp [hz.ne] + ring + have h := (squareWeight_resolvent hs).2 + rw [setIntegral_congr_fun measurableSet_Ioo heq] at h + have hC : (Real.cos (Real.pi / 8)) ^ 2 = (1 + Real.sqrt (1 / 2)) / 2 := by + rw [← minusBranch_zero] + unfold minusBranch + simp only [add_zero] + exact Real.sq_sqrt (by positivity) + rw [h, hC, Real.sq_sqrt (by positivity : (0 : ℝ) ≤ (1 + Real.sqrt ((1 - 1 / z) / 2)) / 2)] + have heq' : 1 - 1 / z = 1 + -1 / z := by ring + rw [heq', Real.sqrt_div (by linarith : (0 : ℝ) ≤ 1 + -1 / z), + Real.sqrt_div (by norm_num : (0 : ℝ) ≤ 1), Real.sqrt_one] + field_simp + ring + + + +theorem integrableOn_lBranch_omega : + IntegrableOn (fun x => lBranch x * omega x) (Ioo (0 : ℝ) 1) := by + have hint := ((squareWeight_resolvent (by norm_num : (0 : ℝ) < 1)).1).const_mul 2 + apply hint.mono' + · apply Measurable.aestronglyMeasurable + unfold lBranch omega + fun_prop + · filter_upwards [ae_restrict_mem measurableSet_Ioo] with x hx + rw [Real.norm_eq_abs, lBranch_mul_omega hx, abs_of_nonneg (show 0 ≤ squareWeight x from Real.sqrt_nonneg _)] + simp only [one_mul] + have hd : 0 < 1 + x := by linarith [hx.1] + have hw : 0 ≤ squareWeight x := Real.sqrt_nonneg _ + rw [← mul_div_assoc, le_div_iff₀ hd] + nlinarith [hx.2] + + + + + +theorem integrableOn_continuous_mul {w g : ℝ → ℝ} + (hw : IntegrableOn w (Ioo (0 : ℝ) 1)) (hg : ContinuousOn g (Icc 0 1)) : + IntegrableOn (fun x => g x * w x) (Ioo (0 : ℝ) 1) := by + have hc : IntegrableOn w (Icc (0 : ℝ) 1) := (integrableOn_Icc_iff_integrableOn_Ioo (f := w) (μ := volume)).2 hw + have h := (hc.mul_continuousOn hg isCompact_Icc).mono_set Ioo_subset_Icc_self + simpa only [mul_comm] using h + + +def realStieltjes (a : ℝ) (w : ℝ → ℝ) (z : ℝ) : ℝ := + ∫ x in Ioo (0 : ℝ) 1, w x / (z - a * x) + +def offCut (a z : ℝ) : Prop := ∀ x ∈ Icc (0 : ℝ) 1, z - a * x ≠ 0 + +theorem integrableOn_stieltjes {a z : ℝ} {w : ℝ → ℝ} + (hw : IntegrableOn w (Ioo (0 : ℝ) 1)) (hz : offCut a z) : + IntegrableOn (fun x => w x / (z - a * x)) (Ioo (0 : ℝ) 1) := by + have hc : ContinuousOn (fun x : ℝ => (z - a * x)⁻¹) (Icc 0 1) := + (continuous_const.sub (continuous_const.mul continuous_id)).continuousOn.inv₀ hz + simpa only [div_eq_mul_inv, mul_comm] using integrableOn_continuous_mul hw hc + +theorem integrableOn_polynomial_weight {a : ℝ} {w : ℝ → ℝ} + (hw : IntegrableOn w (Ioo (0 : ℝ) 1)) (p : Polynomial ℝ) : + IntegrableOn (fun x => p.eval (a * x) * w x) (Ioo (0 : ℝ) 1) := + integrableOn_continuous_mul hw (p.continuous.comp (continuous_const.mul continuous_id)).continuousOn + +theorem realStieltjes_const_mul (a z c : ℝ) (w : ℝ → ℝ) : + realStieltjes a (fun x => c * w x) z = c * realStieltjes a w z := by + unfold realStieltjes + simp only [mul_div_assoc, integral_const_mul] + +theorem realStieltjes_add {a z : ℝ} {w v : ℝ → ℝ} + (hw : IntegrableOn w (Ioo (0 : ℝ) 1)) (hv : IntegrableOn v (Ioo (0 : ℝ) 1)) + (hz : offCut a z) : + realStieltjes a (fun x => w x + v x) z = realStieltjes a w z + realStieltjes a v z := by + unfold realStieltjes + simp only [add_div] + exact integral_add (integrableOn_stieltjes hw hz) (integrableOn_stieltjes hv hz) + +theorem realStieltjes_mul_variable {a z : ℝ} {w : ℝ → ℝ} + (hw : IntegrableOn w (Ioo (0 : ℝ) 1)) (hz : offCut a z) : + z * realStieltjes a w z = realStieltjes a (fun x => a * x * w x) z + + ∫ x in Ioo (0 : ℝ) 1, w x := by + have hi : IntegrableOn (fun x => a * x * w x) (Ioo (0 : ℝ) 1) := + integrableOn_continuous_mul hw (continuous_const.mul continuous_id).continuousOn + unfold realStieltjes + rw [← integral_const_mul, ← integral_add (integrableOn_stieltjes hi hz) hw] + apply setIntegral_congr_fun measurableSet_Ioo + intro x hx + have hne := hz x ⟨hx.1.le, hx.2.le⟩ + dsimp only + field_simp + ring + + + +theorem polynomial_mul_realStieltjes {a : ℝ} {w : ℝ → ℝ} + (hw : IntegrableOn w (Ioo (0 : ℝ) 1)) (p : Polynomial ℝ) : + ∃ R : Polynomial ℝ, ∀ z : ℝ, offCut a z → + p.eval z * realStieltjes a w z = + realStieltjes a (fun x => p.eval (a * x) * w x) z + R.eval z := by + induction p using Polynomial.induction_on' with + | add p q hp hq => + obtain ⟨R, hR⟩ := hp + obtain ⟨S, hS⟩ := hq + refine ⟨R + S, fun z hz => ?_⟩ + simp only [Polynomial.eval_add, add_mul] + rw [realStieltjes_add (integrableOn_polynomial_weight hw p) + (integrableOn_polynomial_weight hw q) hz, hR z hz, hS z hz] + ring + | monomial n c => + induction n with + | zero => + refine ⟨0, fun z hz => ?_⟩ + simp [realStieltjes_const_mul] + | succ n ih => + obtain ⟨R, hR⟩ := ih + let v : ℝ → ℝ := fun x => c * (a * x) ^ n * w x + have hv : IntegrableOn v (Ioo (0 : ℝ) 1) := by + simpa [v] using integrableOn_polynomial_weight hw (Polynomial.monomial n c) + refine ⟨Polynomial.X * R + Polynomial.C (∫ x in Ioo (0 : ℝ) 1, v x), fun z hz => ?_⟩ + have hrec := realStieltjes_mul_variable hv hz + have hpoly := hR z hz + simp only [Polynomial.eval_monomial] at hpoly ⊢ + simp only [Polynomial.eval_add, Polynomial.eval_mul, Polynomial.eval_X, + Polynomial.eval_C] + have heq : (fun x => a * x * v x) = fun x => c * (a * x) ^ (n + 1) * w x := by + funext x + simp only [v, pow_succ] + ring + rw [heq] at hrec + change c * z ^ n * realStieltjes a w z = realStieltjes a v z + R.eval z at hpoly + rw [pow_succ] + linear_combination z * hpoly + hrec + +theorem abs_mul_le_one {a x : ℝ} (ha : |a| ≤ 1) (hx : x ∈ Icc (0 : ℝ) 1) : + |a * x| ≤ 1 := by + rw [abs_mul, abs_of_nonneg hx.1] + nlinarith [abs_nonneg a, hx.1, hx.2] + +theorem offCut_of_abs_large {a z : ℝ} (ha : |a| ≤ 1) (hz : 2 ≤ |z|) : + offCut a z := by + intro x hx heq + have h := abs_mul_le_one ha hx + have hzx : z = a * x := sub_eq_zero.1 heq + rw [hzx] at hz + linarith + +theorem norm_realStieltjes_le {a z : ℝ} {w : ℝ → ℝ} + (hw : IntegrableOn w (Ioo (0 : ℝ) 1)) (ha : |a| ≤ 1) (hz : 2 ≤ |z|) : + ‖realStieltjes a w z‖ ≤ (∫ x in Ioo (0 : ℝ) 1, ‖w x‖) / (|z| - 1) := by + have hd : 0 < |z| - 1 := by linarith + have hi := hw.norm.div_const (|z| - 1) + have hbound : ∀ᵐ x ∂volume.restrict (Ioo (0 : ℝ) 1), + ‖w x / (z - a * x)‖ ≤ ‖w x‖ / (|z| - 1) := by + filter_upwards [ae_restrict_mem measurableSet_Ioo] with x hx + have hax := abs_mul_le_one ha ⟨hx.1.le, hx.2.le⟩ + have hden : |z| - 1 ≤ |z - a * x| := by + have h := abs_sub_abs_le_abs_sub z (a * x) + linarith + rw [norm_div, Real.norm_eq_abs (z - a * x)] + exact div_le_div_of_nonneg_left (norm_nonneg _) hd hden + have h := norm_integral_le_of_norm_le hi hbound + simpa only [realStieltjes, integral_div] using h + +end +end CriticalStrip + +end OAI diff --git a/lean/OAI/Combinatorics/StripMass/RealEvaluation.lean b/lean/OAI/Combinatorics/StripMass/RealEvaluation.lean new file mode 100644 index 0000000000000000000000000000000000000000..ad66e10c90c1f229be7b61e7fc26406a2b82dacf --- /dev/null +++ b/lean/OAI/Combinatorics/StripMass/RealEvaluation.lean @@ -0,0 +1,469 @@ +import Mathlib +import OAI.Combinatorics.StripMass.ArchRoots + +namespace OAI + +/-! Critical honeycomb strip paths, polynomial identities and crossing mass. -/ + + +namespace CriticalStrip.Diagram +noncomputable section +open scoped BigOperators Classical +open Finset + +def anglePhase (u : ℝ) : ℂ := Complex.exp ((u:ℂ)*Complex.I) + +@[simp] lemma anglePhase_ne_zero (u : ℝ) : anglePhase u≠0 := Complex.exp_ne_zero _ +@[simp] lemma anglePhase_zero : anglePhase 0=1 := by simp [anglePhase] +lemma anglePhase_add (u v : ℝ) : anglePhase (u+v)=anglePhase u*anglePhase v := by + simp only [anglePhase,Complex.ofReal_add,add_mul,Complex.exp_add] +lemma anglePhase_neg (u : ℝ) : anglePhase (-u)=(anglePhase u)⁻¹ := by + simp [anglePhase,Complex.exp_neg] +lemma anglePhase_sub (u v : ℝ) : anglePhase (u-v)=anglePhase u/anglePhase v := by + simp only [sub_eq_add_neg,anglePhase_add,anglePhase_neg,div_eq_mul_inv] +lemma anglePhase_nat_mul (k : ℕ) (u : ℝ) : anglePhase ((k:ℝ)*u)=anglePhase u^k := by + simp only [anglePhase,Complex.ofReal_mul,Complex.ofReal_natCast,←Complex.exp_nat_mul,mul_assoc] +lemma anglePhase_int_mul (k : ℤ) (u : ℝ) : anglePhase ((k:ℝ)*u)=anglePhase u^k := by + simp only [anglePhase,Complex.ofReal_mul,Complex.ofReal_intCast,←Complex.exp_int_mul,mul_assoc] +lemma anglePhase_lambda : anglePhase lambda=phase := rfl +lemma anglePhase_sine (u : ℝ) : (anglePhase u-(anglePhase u)⁻¹)/(2*Complex.I)=(Real.sin u:ℂ) := by + rw [anglePhase,Complex.ofReal_sin,Complex.sin,←Complex.exp_neg] + field_simp + simp [Complex.I_sq] +lemma anglePhase_cosine (u : ℝ) : (anglePhase u+(anglePhase u)⁻¹)/2=(Real.cos u:ℂ) := by + rw [anglePhase,Complex.ofReal_cos,Complex.cos,←Complex.exp_neg] + simp only [neg_mul] + +def angleCharacter {n : ℕ} (u : Fin n → ℝ) : Multiplicative (Fin n → ℤ) →* ℂ where + toFun e := ∏ i,anglePhase (u i)^e.toAdd i + map_one' := by simp + map_mul' e f := by + change (∏i,anglePhase (u i)^(e.toAdd i+f.toAdd i))=_ + simp only [zpow_add₀ (anglePhase_ne_zero _),prod_mul_distrib] + +def angleEvaluation {n : ℕ} (u : Fin n → ℝ) : Laurent n →ₐ[ℂ] ℂ := + AddMonoidAlgebra.lift ℂ ℂ (Fin n → ℤ) (angleCharacter u) + +@[simp] lemma angleEvaluation_monomial {n : ℕ} (u : Fin n → ℝ) (e : Fin n → ℤ) (z : ℂ) : + angleEvaluation u (monomialL e z)=z*∏i,anglePhase (u i)^e i := by + simp [angleEvaluation,monomialL,AddMonoidAlgebra.lift_single,angleCharacter] +@[simp] lemma angleEvaluation_constant {n : ℕ} (u : Fin n → ℝ) (z : ℂ) : + angleEvaluation u (constantL n z)=z := by + change angleEvaluation u (monomialL 0 z)=_ + simp +@[simp] lemma angleEvaluation_variable {n : ℕ} (u : Fin n → ℝ) (i : Fin n) : + angleEvaluation u (monomialL (variableExponent i) 1)=anglePhase (u i) := by + simp [variableExponent,Pi.single_apply] + +lemma rationalAt_const_complex {n : ℕ} (φ : Laurent n →ₐ[ℂ] ℂ) (z : ℂ) : + RationalAt φ.toRingHom (constF n z) z := by + have hh:=RationalAt.algebraMap (φ:=φ.toRingHom) (F:=SpectralField n) (constantL n z) + rw [map_constantL] at hh + have he : φ (constantL n z)=z := φ.commutes z + simpa only [AlgHom.toRingHom_eq_coe,AlgHom.coe_toRingHom,he] using hh + +lemma rationalAt_angle_variable {n : ℕ} (u : Fin n → ℝ) (i : Fin n) : + RationalAt (angleEvaluation u).toRingHom (variableF i) (anglePhase (u i)) := by + have hh:=RationalAt.algebraMap (φ:=(angleEvaluation u).toRingHom) (F:=SpectralField n) + (monomialL (variableExponent i) 1) + change RationalAt (angleEvaluation u).toRingHom (variableF i) + (angleEvaluation u (monomialL (variableExponent i) 1)) at hh + simpa only [angleEvaluation_variable] using hh + +lemma rationalAt_angle_sin {n : ℕ} (φ : Laurent n →ₐ[ℂ] ℂ) {x : SpectralField n} {u : ℝ} + (h : RationalAt φ.toRingHom x (anglePhase u)) : + RationalAt φ.toRingHom (torusSin x) (Real.sin u:ℂ) := by + rw [←anglePhase_sine] + exact (h.sub (h.inv (anglePhase_ne_zero _))).div + ((RationalAt.natCast 2).mul (rationalAt_const_complex φ Complex.I)) + (mul_ne_zero (by norm_num) Complex.I_ne_zero) + +lemma rationalAt_angle_cos {n : ℕ} (φ : Laurent n →ₐ[ℂ] ℂ) {x : SpectralField n} {u : ℝ} + (h : RationalAt φ.toRingHom x (anglePhase u)) : + RationalAt φ.toRingHom (torusCos x) (Real.cos u:ℂ) := by + rw [←anglePhase_cosine] + exact (h.add (h.inv (anglePhase_ne_zero _))).div (RationalAt.natCast 2) (by norm_num) + +lemma rationalAt_angle_L {n : ℕ} (φ : Laurent n →ₐ[ℂ] ℂ) {x : SpectralField n} {u : ℝ} + (h : RationalAt φ.toRingHom x (anglePhase u)) : + RationalAt φ.toRingHom (torusL x) (L u:ℂ) := by + have hq:=rationalAt_const_complex φ phase + have hp (k : ℕ) : RationalAt φ.toRingHom (constF n phase^k*x) (anglePhase ((k:ℝ)*lambda+u)) := by + simpa only [anglePhase_add,anglePhase_nat_mul,anglePhase_lambda] using (hq.pow k).mul h + simpa only [torusL,L,Complex.ofReal_mul,Nat.cast_ofNat] using + (rationalAt_angle_sin φ (hp 2)).mul (rationalAt_angle_sin φ (hp 3)) + +lemma rationalAt_angle_weights {n : ℕ} (φ : Laurent n →ₐ[ℂ] ℂ) {x : SpectralField n} {u : ℝ} + (h : RationalAt φ.toRingHom x (anglePhase u)) (hL : L u≠0) (t : Tile) : + RationalAt φ.toRingHom ((torusWeights x).tile t) ((physicalWeights u).tile t:ℂ) := by + have hq:=rationalAt_const_complex φ phase + have hd:=rationalAt_const_complex φ d + have hs:=rationalAt_angle_sin φ h + have hp (k : ℕ) : RationalAt φ.toRingHom (constF n phase^k/x) (anglePhase ((k:ℝ)*lambda-u)) := by + simpa only [anglePhase_sub,anglePhase_nat_mul,anglePhase_lambda] using (hq.pow k).div h (anglePhase_ne_zero _) + have ha: RationalAt φ.toRingHom (x/constF n phase) (anglePhase (u-lambda)) := by + simpa only [anglePhase_sub,anglePhase_lambda] using h.div hq phase_ne_zero + have ht:=rationalAt_angle_sin φ (hp 3) + have hv:=rationalAt_angle_sin φ (hp 2) + have hh:=rationalAt_angle_sin φ ha + have hℓ:=rationalAt_angle_L φ h + have hℓ₀ : (L u:ℂ)≠0 := by exact_mod_cast hL + cases t + · exact RationalAt.one + · simpa [torusWeights,Weights.tile,physicalWeights,d] using (hd.mul ht).div hℓ hℓ₀ + · simpa [torusWeights,Weights.tile,physicalWeights,d] using (hd.mul ht).div hℓ hℓ₀ + · simpa [torusWeights,Weights.tile,physicalWeights,d] using (hs.mul ht).div hℓ hℓ₀ + · simpa [torusWeights,Weights.tile,physicalWeights,d] using (hs.mul ht).div hℓ hℓ₀ + · simpa [torusWeights,Weights.tile,physicalWeights,d] using (hd.mul hs).div hℓ hℓ₀ + · simpa [torusWeights,Weights.tile,physicalWeights,d] using (hd.mul hs).div hℓ hℓ₀ + · simpa [torusWeights,Weights.tile,physicalWeights,d] using (ht.mul hv).div hℓ hℓ₀ + · simpa [torusWeights,Weights.tile,physicalWeights,d] using (hh.mul hs).div hℓ hℓ₀ + +lemma rationalAt_angle_spectralA {n : ℕ} (u : Fin n → ℝ) (i : Fin n) : + RationalAt (angleEvaluation u).toRingHom (spectralA i) (Real.cos (2*u i-3*lambda):ℂ) := by + apply rationalAt_angle_cos + rw [anglePhase_sub,show anglePhase (2*u i)=anglePhase (u i)^2 from anglePhase_nat_mul 2 _, + show anglePhase (3*lambda)=phase^3 from anglePhase_nat_mul 3 _] + exact + ((rationalAt_angle_variable u i).pow 2).div + ((rationalAt_const_complex (angleEvaluation u) phase).pow 3) (pow_ne_zero _ phase_ne_zero) + +lemma rationalAt_angle_spectralWeights {n : ℕ} (u : Fin n → ℝ) + (hL : ∀i,L (3*lambda-u i)≠0) (i : Fin n) (t : Tile) : + RationalAt (angleEvaluation u).toRingHom ((spectralWeights n i).tile t) + ((physicalWeights (3*lambda-u i)).tile t:ℂ) := by + apply rationalAt_angle_weights _ _ (hL i) + rw [anglePhase_sub,show anglePhase (3*lambda)=phase^3 from anglePhase_nat_mul 3 _] + exact ((rationalAt_const_complex (angleEvaluation u) phase).pow 3).div + (rationalAt_angle_variable u i) (anglePhase_ne_zero _) + +lemma angleEvaluation_rowCosine {n : ℕ} (u : Fin n → ℝ) (i : Fin n) : + angleEvaluation u (rowCosineL i)=(Real.cos (2*u i-3*lambda):ℂ) := by + have hh:=RationalAt.algebraMap (φ:=(angleEvaluation u).toRingHom) (F:=SpectralField n) (rowCosineL i) + rw [rowCosineL_algebraMap] at hh + exact hh.unique (rationalAt_angle_spectralA u i) + +lemma angleEvaluation_scalar {n : ℕ} (u : Fin n → ℝ) : + angleEvaluation u (polynomialVacuumVector n (empty n))= + scalarValue (RingHom.id ℂ) (fun i=>(Real.cos (2*u i-3*lambda):ℂ)) := by + rw [←scalarValue_rowCosine] + have hh:=map_scalarValue (angleEvaluation u).toRingHom (constantL n) rowCosineL + have hc : (angleEvaluation u).toRingHom.comp (constantL n)=RingHom.id ℂ := by ext z; simp + rw [hc] at hh + have hf : (angleEvaluation u).toRingHom ∘ rowCosineL=fun i=>(Real.cos (2*u i-3*lambda):ℂ) := by + funext i + exact angleEvaluation_rowCosine u i + rw [hf] at hh + exact hh + +lemma continuous_angleEvaluation {n : ℕ} (f : Laurent n) : + Continuous (fun u : Fin n → ℝ=>angleEvaluation u f) := by + induction f using AddMonoidAlgebra.induction_on with + | of e => + change Continuous (fun u : Fin n → ℝ=>angleEvaluation u (monomialL e 1)) + simp only [angleEvaluation_monomial] + apply continuous_const.mul + apply continuous_finsetProd + intro i _ + apply Continuous.zpow₀ _ _ (fun _=>Or.inl (anglePhase_ne_zero _)) + unfold anglePhase + fun_prop + | add f g hf hg => + simp only [map_add] + exact hf.add hg + | smul z f hf => + simp only [map_smul,smul_eq_mul] + exact continuous_const.mul hf + +end +end CriticalStrip.Diagram + + + + + + + +namespace CriticalStrip.PositiveMatrix +noncomputable section +open Filter Matrix +open scoped BigOperators Topology Classical + +variable {ι : Type*} [Fintype ι] [DecidableEq ι] + +def Nonnegative (Q : Matrix ι ι ℝ) : Prop := ∀ i j, 0≤Q i j + +def SummablePowers (Q : Matrix ι ι ℝ) : Prop := ∀ i j, Summable (fun k : ℕ => (Q^k) i j) + +def Accessible (Q : Matrix ι ι ℝ) (v : ι → ℝ) : Prop := + ∀ i, ∃ k : ℕ, 0<(Q^k).mulVec v i + +lemma Nonnegative.pow {Q : Matrix ι ι ℝ} (hQ : Nonnegative Q) (k : ℕ) : + Nonnegative (Q^k) := by + induction k with + | zero => intro i j; simp only [pow_zero,Matrix.one_apply]; split_ifs <;> norm_num + | succ k ih => + intro i j + rw [pow_succ] + exact Finset.sum_nonneg fun a _ =>mul_nonneg (ih i a) (hQ a j) + +omit [DecidableEq ι] in +lemma Nonnegative.mulVec {Q : Matrix ι ι ℝ} (hQ : Nonnegative Q) + {z : ι → ℝ} (hz : ∀ i,0≤z i) : ∀ i, 0≤Q.mulVec z i := + fun _ =>Finset.sum_nonneg fun j _ =>mul_nonneg (hQ _ j) (hz j) + +omit [DecidableEq ι] in +lemma Nonnegative.mulVec_mono {Q : Matrix ι ι ℝ} (hQ : Nonnegative Q) + {x y : ι → ℝ} (hxy : ∀ i,x i≤y i) : ∀ i, Q.mulVec x i≤Q.mulVec y i := + fun _ =>Finset.sum_le_sum fun j _ =>mul_le_mul_of_nonneg_left (hxy j) (hQ _ j) + +omit [DecidableEq ι] in +lemma entry_mul_le_mulVec {Q : Matrix ι ι ℝ} (hQ : Nonnegative Q) + {z : ι → ℝ} (hz : ∀ i,0≤z i) (i j : ι) : Q i j*z j≤Q.mulVec z i := + Finset.single_le_sum (fun a _ =>mul_nonneg (hQ i a) (hz a)) (Finset.mem_univ j) + +lemma stationary_partial_sum {Q : Matrix ι ι ℝ} {v w : ι → ℝ} + (he : Q.mulVec w+v=w) (k : ℕ) : + (∑ m∈Finset.range k, (Q^m).mulVec v)+(Q^k).mulVec w=w := by + induction k with + | zero => simp + | succ k ih => + rw [Finset.sum_range_succ,pow_succ,←Matrix.mulVec_mulVec,add_assoc, + ←Matrix.mulVec_add,add_comm v (Q.mulVec w),he] + exact ih + + +lemma summable_injection {Q : Matrix ι ι ℝ} {v w : ι → ℝ} + (hQ : Nonnegative Q) (hv : ∀i,0≤v i) (hw : ∀i,0≤w i) + (he : Q.mulVec w+v=w) (i : ι) : Summable (fun k : ℕ =>(Q^k).mulVec v i) := by + apply summable_of_sum_range_le (fun k =>(hQ.pow k).mulVec hv i) (c:=w i) + intro k + have hh:=congrFun (stationary_partial_sum he k) i + simp only [Pi.add_apply,Finset.sum_apply] at hh + linarith [(hQ.pow k).mulVec hw i] + + + +theorem summablePowers_of_stationary {Q : Matrix ι ι ℝ} {v w : ι → ℝ} + (hQ : Nonnegative Q) (hv : ∀i,0≤v i) (hw : ∀i,0≤w i) + (he : Q.mulVec w+v=w) (ha : Accessible Q v) : SummablePowers Q := by + intro i j + obtain ⟨m,hm⟩:=ha j + have hs := (summable_nat_add_iff m).mpr (summable_injection hQ hv hw he i) + apply (hs.div_const ((Q^m).mulVec v j)).of_nonneg_of_le (fun k =>hQ.pow k i j) + intro k + apply (le_div_iff₀ hm).mpr + simpa only [pow_add,Matrix.mulVec_mulVec] using + entry_mul_le_mulVec (hQ.pow k) ((hQ.pow m).mulVec hv) i j + +lemma SummablePowers.tendsto_zero {Q : Matrix ι ι ℝ} (hs : SummablePowers Q) (i j : ι) : + Tendsto (fun k : ℕ =>(Q^k) i j) atTop (𝓝 0) := (hs i j).tendsto_atTop_zero + +lemma SummablePowers.mulVec_tendsto_zero {Q : Matrix ι ι ℝ} (hs : SummablePowers Q) + (w : ι → ℝ) (i : ι) : Tendsto (fun k : ℕ =>(Q^k).mulVec w i) atTop (𝓝 0) := by + simpa only [Matrix.mulVec,dotProduct,zero_mul,Finset.sum_const_zero] using + tendsto_finsetSum Finset.univ (fun j _ =>(hs.tendsto_zero i j).mul_const (w j)) + +lemma SummablePowers.mulVec_summable {Q : Matrix ι ι ℝ} (hs : SummablePowers Q) + (v : ι → ℝ) (i : ι) : Summable (fun k : ℕ =>(Q^k).mulVec v i) := + summable_sum fun j _ =>(hs i j).mul_right (v j) + + + +lemma SummablePowers.stationary_eq_tsum {Q : Matrix ι ι ℝ} (hs : SummablePowers Q) + {v w : ι → ℝ} (he : Q.mulVec w+v=w) (i : ι) : + w i=∑' k : ℕ,(Q^k).mulVec v i := by + have hlim:=((hs.mulVec_summable v i).hasSum.tendsto_sum_nat).add (hs.mulVec_tendsto_zero w i) + simp only [add_zero] at hlim + have hc : Tendsto (fun k : ℕ =>(∑ m∈Finset.range k, (Q^m).mulVec v i)+(Q^k).mulVec w i) + atTop (𝓝 (w i)) := by + have hh : (fun k : ℕ =>(∑ m∈Finset.range k, (Q^m).mulVec v i)+(Q^k).mulVec w i)=fun _=>w i := by + funext k + simpa only [Pi.add_apply,Finset.sum_apply] using congrFun (stationary_partial_sum he k) i + rw [hh]; exact tendsto_const_nhds + exact tendsto_nhds_unique hc hlim + +lemma SummablePowers.stationary_nonneg {Q : Matrix ι ι ℝ} (hs : SummablePowers Q) + (hQ : Nonnegative Q) {v w : ι → ℝ} (hv : ∀i,0≤v i) (he : Q.mulVec w+v=w) : + ∀ i,0≤w i := by + intro i + rw [hs.stationary_eq_tsum he i] + exact tsum_nonneg fun k =>(hQ.pow k).mulVec hv i + +lemma SummablePowers.unique_stationary {Q : Matrix ι ι ℝ} (hs : SummablePowers Q) + {v w z : ι → ℝ} (he : Q.mulVec w+v=w) (hz : Q.mulVec z+v=z) : w=z := by + funext i + rw [hs.stationary_eq_tsum he i,hs.stationary_eq_tsum hz i] + + +lemma pow_mulVec_le {Q : Matrix ι ι ℝ} (hQ : Nonnegative Q) {z : ι → ℝ} + {r : ℝ} (hr : 0≤r) (hz : ∀i,Q.mulVec z i≤r*z i) (k : ℕ) : + ∀ i,(Q^k).mulVec z i≤r^k*z i := by + induction k with + | zero => simp + | succ k ih => + intro i + rw [pow_succ',←Matrix.mulVec_mulVec,pow_succ'] + calc + Q.mulVec ((Q^k).mulVec z) i≤Q.mulVec (fun j=>r^k*z j) i := hQ.mulVec_mono ih i + _ = r^k*Q.mulVec z i := by + simp only [Matrix.mulVec,dotProduct,Finset.mul_sum] + apply Finset.sum_congr rfl + intro j _ + ring + _ ≤ r^k*(r*z i) := mul_le_mul_of_nonneg_left (hz i) (pow_nonneg hr k) + _ = _ := by ring + +lemma summablePowers_of_le {Q : Matrix ι ι ℝ} (hQ : Nonnegative Q) {z : ι → ℝ} + (hz : ∀i,0hQ.pow k i j) + intro k + apply (le_div_iff₀ (hz j)).mpr + exact (entry_mul_le_mulVec (hQ.pow k) (fun i=>(hz i).le) i j).trans + (by simpa only [mul_comm] using pow_mulVec_le hQ hr he k i) + +def HasSupervector (Q : Matrix ι ι ℝ) : Prop := + ∃ z : ι → ℝ, (∀i,0 intro i; exact isEmptyElim i + | inr hi => + let r := Finset.univ.sup' Finset.univ_nonempty (fun i=>Q.mulVec z i/z i) + have hr₁ : r<1 := (Finset.sup'_lt_iff Finset.univ_nonempty).mpr (fun i _ =>(div_lt_one (hz i)).mpr (he i)) + have hr₀ : 0≤r := by + obtain ⟨i⟩:=hi + exact (div_nonneg (hQ.mulVec (fun i=>(hz i).le) i) (hz i).le).trans + (Finset.le_sup' (fun i=>Q.mulVec z i/z i) (Finset.mem_univ i)) + apply summablePowers_of_le hQ hz hr₀ hr₁ + intro i + exact (div_le_iff₀ (hz i)).mp (Finset.le_sup' (fun i=>Q.mulVec z i/z i) (Finset.mem_univ i)) + +lemma SummablePowers.hasSupervector {Q : Matrix ι ι ℝ} (hs : SummablePowers Q) + (hQ : Nonnegative Q) : HasSupervector Q := by + let z : ι → ℝ:=fun i=>∑' k : ℕ,(Q^k).mulVec (fun _=>1) i + have hz : ∀i,1≤z i := by + intro i + have hh:=Summable.le_tsum (hs.mulVec_summable (fun _=>1) i) 0 + (fun k _ =>(hQ.pow k).mulVec (fun _=>by norm_num) i) + simpa only [pow_zero,Matrix.one_mulVec] using hh + have he : ∀ i,Q.mulVec z i+1=z i := by + intro i + have hh := (hs.mulVec_summable (fun _=>1) i).tsum_eq_zero_add + simp only [pow_zero,Matrix.one_mulVec] at hh + suffices hQz : Q.mulVec z i=∑' k : ℕ,(Q^(k+1)).mulVec (fun _=>1) i by + rw [hQz]; linarith + change (∑ j, Q i j * ∑' k : ℕ,(Q^k).mulVec (fun _=>1) j) = _ + simp_rw [← tsum_mul_left] + rw [← Summable.tsum_finsetSum (fun j _ =>(hs.mulVec_summable (fun _=>1) j).mul_left (Q i j))] + congr 1 + funext k + change Q.mulVec ((Q^k).mulVec (fun _=>1)) i=(Q^(k+1)).mulVec (fun _=>1) i + rw [Matrix.mulVec_mulVec,pow_succ'] + refine ⟨z,fun i=>lt_of_lt_of_le (by norm_num) (hz i),?_⟩ + intro i + linarith [he i] + +lemma hasSupervector_iff {Q : Matrix ι ι ℝ} (hQ : Nonnegative Q) : + HasSupervector Q ↔ SummablePowers Q := ⟨fun h=>h.summablePowers hQ,fun hs=>hs.hasSupervector hQ⟩ + +omit [DecidableEq ι] in +lemma isOpen_hasSupervector : IsOpen {Q : Matrix ι ι ℝ | HasSupervector Q} := by + have he : {Q : Matrix ι ι ℝ | HasSupervector Q}= + ⋃ z : ι → ℝ, ⋃ (_ : ∀i,0isClosed_le continuous_const ((continuous_apply i).comp hwc) + have ho : IsOpen S := by + have hh : S=Q ⁻¹' {M | HasSupervector M} := by + ext t + exact (hasSupervector_iff (hQ t)).symm + rw [hh] + exact isOpen_hasSupervector.preimage hQc + have hu : S=Set.univ := (show IsClopen S from ⟨hc,ho⟩).eq_univ ⟨a,hs⟩ + intro t + show t∈S + rw [hu] + trivial + + +theorem summablePowers_on_Icc + (Q : ℝ → Matrix ι ι ℝ) (v w : ℝ → ι → ℝ) {a b : ℝ} (hab : a≤b) + (hQc : ContinuousOn Q (Set.Icc a b)) (hwc : ContinuousOn w (Set.Icc a b)) + (hQ : ∀t∈Set.Icc a b,Nonnegative (Q t)) + (hv : ∀t∈Set.Icc a b,∀i,0≤v t i) + (he : ∀t∈Set.Icc a b,(Q t).mulVec (w t)+v t=w t) + (hs : SummablePowers (Q a)) + (ha : ∀t∈Set.Ioc a b,Accessible (Q t) (v t)) : + ∀t∈Set.Icc a b,SummablePowers (Q t) := by + let : PreconnectedSpace (Set.Icc a b) := isPreconnected_iff_preconnectedSpace.mp isPreconnected_Icc + have hh:=summablePowers_of_connected_stationary + (fun t : Set.Icc a b=>Q t.val) (fun t : Set.Icc a b=>v t.val) + (fun t : Set.Icc a b=>w t.val) ⟨a,le_rfl,hab⟩ + hQc.domRestrict hwc.domRestrict (fun t=>hQ _ t.property) (fun t=>hv _ t.property) + (fun t=>he _ t.property) hs (fun t ht=>ha _ ⟨lt_of_le_of_ne t.property.1 + (by intro hr; exact ht (Subtype.ext hr.symm)),t.property.2⟩) + exact fun t ht=>hh ⟨t,ht⟩ + + + +theorem SummablePowers.weighted {Q : Matrix ι ι ℝ} (hs : SummablePowers Q) + (hQ : Nonnegative Q) (d : ℕ) (i j : ι) : + Summable (fun k : ℕ=>(k:ℝ)^d*(Q^k) i j) := by + obtain ⟨z,hz,he⟩:=hs.hasSupervector hQ + let r := Finset.univ.sup' ⟨i,Finset.mem_univ i⟩ (fun i=>Q.mulVec z i/z i) + have hr₁ : r<1 := (Finset.sup'_lt_iff _).mpr (fun i _=>(div_lt_one (hz i)).mpr (he i)) + have hr₀ : 0≤r := (div_nonneg (hQ.mulVec (fun i=>(hz i).le) i) (hz i).le).trans + (Finset.le_sup' (fun i=>Q.mulVec z i/z i) (Finset.mem_univ i)) + have hle : ∀i,Q.mulVec z i≤r*z i := fun i=>(div_le_iff₀ (hz i)).mp + (Finset.le_sup' (fun i=>Q.mulVec z i/z i) (Finset.mem_univ i)) + have hg : Summable (fun k : ℕ=>(k:ℝ)^d*r^k) := + summable_pow_mul_geometric_of_norm_lt_one d (by simpa [Real.norm_eq_abs,abs_of_nonneg hr₀] using hr₁) + apply ((hg.mul_right (z i)).div_const (z j)).of_nonneg_of_le + (fun k=>mul_nonneg (by positivity) (hQ.pow k i j)) + intro k + have hk : (Q^k) i j≤r^k*z i/z j := (le_div_iff₀ (hz j)).mpr + ((entry_mul_le_mulVec (hQ.pow k) (fun i=>(hz i).le) i j).trans (pow_mulVec_le hQ hr₀ hle k i)) + simpa only [mul_div_assoc,mul_assoc] using mul_le_mul_of_nonneg_left hk (show 0≤(k:ℝ)^d by positivity) + +end +end CriticalStrip.PositiveMatrix + +end OAI diff --git a/lean/OAI/Combinatorics/StripMass/ReflectionFractions.lean b/lean/OAI/Combinatorics/StripMass/ReflectionFractions.lean new file mode 100644 index 0000000000000000000000000000000000000000..4112e927ed3689efe07cb070dbf6f2546e51fba7 --- /dev/null +++ b/lean/OAI/Combinatorics/StripMass/ReflectionFractions.lean @@ -0,0 +1,439 @@ +import Mathlib +import OAI.Combinatorics.StripMass.MomentGrowth + +namespace OAI + +/-! Critical honeycomb strip paths, polynomial identities and crossing mass. -/ + + +namespace CriticalStrip +noncomputable section +open scoped BigOperators +open Set MeasureTheory +lemma reflection_partialFractions_distinct {n : ℕ} (hn : 0 < n) {y : Fin n → ℝ} + (hy : ∀ i, 0 < y i) (hinj : Function.Injective y) {x : ℝ} (hx : 0 ≤ x) : + reflectionProduct n x y = 1 - x * ∑ i, reflectionResidue n y i / (x+y i) := by + classical + let P : Polynomial ℝ := ∏ i, (Polynomial.C (y i) - Polynomial.X) + let Q : Polynomial ℝ := ∏ i, (Polynomial.C (y i) + Polynomial.X) + let R : Fin n → Polynomial ℝ := fun i => ∏ j ∈ Finset.univ.erase i, (Polynomial.C (y j)+Polynomial.X) + let T : Polynomial ℝ := Q - Polynomial.X * ∑ i, Polynomial.C (reflectionResidue n y i) * R i + have hlin (a : ℝ) : (Polynomial.C a + Polynomial.X).natDegree ≤ 1 := by + exact (Polynomial.natDegree_add_le _ _).trans (by simp) + have hR (i : Fin n) : (R i).natDegree ≤ n-1 := by + apply (Polynomial.natDegree_prod_le (Finset.univ.erase i) + (fun j => Polynomial.C (y j) + Polynomial.X)).trans + calc + ∑ j ∈ Finset.univ.erase i, (Polynomial.C (y j)+Polynomial.X).natDegree ≤ + ∑ _j ∈ Finset.univ.erase i, 1 := by + apply Finset.sum_le_sum + intro j _ + exact hlin (y j) + _ = n-1 := by simp + have hP : P.natDegree ≤ n := by + apply (Polynomial.natDegree_prod_le Finset.univ + (fun i => Polynomial.C (y i) - Polynomial.X)).trans + calc + ∑ i : Fin n, (Polynomial.C (y i)-Polynomial.X).natDegree ≤ ∑ _i : Fin n, 1 := by + apply Finset.sum_le_sum + intro i _ + exact (Polynomial.natDegree_sub_le _ _).trans (by simp) + _ = n := by simp + have hQ : Q.natDegree ≤ n := by + apply (Polynomial.natDegree_prod_le Finset.univ + (fun i => Polynomial.C (y i) + Polynomial.X)).trans + calc + ∑ i : Fin n, (Polynomial.C (y i)+Polynomial.X).natDegree ≤ ∑ _i : Fin n, 1 := + by + apply Finset.sum_le_sum + intro i _ + exact hlin (y i) + _ = n := by simp + have hT : T.natDegree ≤ n := by + apply (Polynomial.natDegree_sub_le _ _).trans + apply max_le hQ + apply (Polynomial.natDegree_mul_le).trans + have hh : (∑ i, Polynomial.C (reflectionResidue n y i) * R i).natDegree ≤ n-1 := by + apply Polynomial.natDegree_sum_le_of_forall_le + intro i _ + exact (Polynomial.natDegree_C_mul_le _ _).trans (hR i) + simpa only [Polynomial.natDegree_X] using (add_le_add_right hh 1 |>.trans (by omega : 1+(n-1) ≤ n)) + have hnode : Function.Injective (Fin.cons (0:ℝ) (fun i => -y i)) := by + rw [Fin.cons_injective_iff] + refine ⟨?_, fun i j h => hinj (neg_injective h)⟩ + rintro ⟨i, hi⟩ + exact (hy i).ne' (neg_eq_zero.mp hi) + have he : P = T := by + apply Polynomial.eq_of_degrees_lt_of_eval_index_eq + (s := Finset.univ) (v := Fin.cons (0:ℝ) (fun i => -y i)) + (hnode.injOn) + ((Polynomial.degree_le_of_natDegree_le hP).trans_lt (by + simp only [Finset.card_univ, Fintype.card_fin] + exact_mod_cast Nat.lt_succ_self n)) + ((Polynomial.degree_le_of_natDegree_le hT).trans_lt (by + simp only [Finset.card_univ, Fintype.card_fin] + exact_mod_cast Nat.lt_succ_self n)) + intro i _ + refine Fin.cases ?_ (fun i => ?_) i + · simp [P, Q, T, Polynomial.eval_prod] + · have hQ0 : Q.eval (-y i) = 0 := by + simp only [Q, Polynomial.eval_prod, Polynomial.eval_add, Polynomial.eval_C, Polynomial.eval_X] + exact Finset.prod_eq_zero (Finset.mem_univ i) (by ring) + have hsum : (∑ j, Polynomial.C (reflectionResidue n y j) * R j).eval (-y i) = + reflectionResidue n y i * ∏ j ∈ Finset.univ.erase i, (y j-y i) := by + simp only [Polynomial.eval_finsetSum, Polynomial.eval_mul, Polynomial.eval_C] + rw [Finset.sum_eq_single i] + · simp [R, Polynomial.eval_prod, sub_eq_add_neg] + · intro j _ hji + have hz : (R j).eval (-y i) = 0 := by + simp only [R, Polynomial.eval_prod, Polynomial.eval_add, Polynomial.eval_C, Polynomial.eval_X] + exact Finset.prod_eq_zero (show i ∈ Finset.univ.erase j from by simp [hji.symm]) (by ring) + rw [hz, mul_zero] + · simp + have hres : reflectionResidue n y i * ∏ j ∈ Finset.univ.erase i, (y j-y i) = + 2 * ∏ j ∈ Finset.univ.erase i, (y j+y i) := by + rw [reflectionResidue, Finset.prod_div_distrib, mul_assoc, div_mul_cancel₀] + exact Finset.prod_ne_zero_iff.mpr fun j hj => sub_ne_zero.mpr (hinj.ne (Finset.mem_erase.mp hj).1) + have hPm : P.eval (-y i) = (2*y i) * ∏ j ∈ Finset.univ.erase i, (y j+y i) := by + simp only [P, Polynomial.eval_prod, Polynomial.eval_sub, Polynomial.eval_C, Polynomial.eval_X, sub_neg_eq_add] + rw [← Finset.mul_prod_erase _ _ (Finset.mem_univ i)] + ring + simp only [Fin.cons_succ, T, Polynomial.eval_sub, Polynomial.eval_mul, Polynomial.eval_X, + hQ0, hsum, hres, hPm] + ring + have heval := congrArg (Polynomial.eval x) he + simp only [P, Q, T, Polynomial.eval_prod, Polynomial.eval_sub, Polynomial.eval_add, + Polynomial.eval_C, Polynomial.eval_X, Polynomial.eval_mul, Polynomial.eval_finsetSum, R] at heval + have hden : (∏ i, (y i+x)) ≠ 0 := Finset.prod_ne_zero_iff.mpr fun i _ => (add_pos_of_pos_of_nonneg (hy i) hx).ne' + have hi (i : Fin n) : (∏ j ∈ Finset.univ.erase i, (y j+x))/(∏ j, (y j+x)) = (x+y i)⁻¹ := by + rw [← Finset.mul_prod_erase _ _ (Finset.mem_univ i)] + rw [mul_comm (y i+x), div_mul_cancel_left₀] + · rw [add_comm] + · exact Finset.prod_ne_zero_iff.mpr fun j _ => (add_pos_of_pos_of_nonneg (hy j) hx).ne' + rw [reflectionProduct, Finset.prod_div_distrib, heval, sub_div, div_self hden, + mul_div_assoc, Finset.sum_div] + congr 2 + apply Finset.sum_congr rfl + intro i _ + rw [mul_div_assoc, hi, div_eq_mul_inv] + +lemma integral_unitCube_cons (n : ℕ) (f : (Fin (n+1) → ℝ) → ℝ) : + (∫ z, f z ∂unitCubeMeasure (n+1)) = + ∫ p : ℝ × (Fin n → ℝ), f (Fin.cons p.1 p.2) + ∂(volume.restrict (Ioo 0 1)).prod (unitCubeMeasure n) := by + symm + simpa only [MeasurableEquiv.piFinSuccAbove_symm_apply, Fin.insertNthEquiv, + Fin.insertNth_zero, Fin.zero_succAbove, Equiv.coe_fn_mk, cast_eq] using + ((measurePreserving_piFinSuccAbove + (fun _ : Fin (n+1) => volume.restrict (Ioo (0:ℝ) 1)) 0).symm).integral_comp' f + +lemma integrable_unitCube_cons {n : ℕ} {f : (Fin (n+1) → ℝ) → ℝ} + (hf : Integrable f (unitCubeMeasure (n+1))) : + Integrable (fun p : ℝ × (Fin n → ℝ) => f (Fin.cons p.1 p.2)) + ((volume.restrict (Ioo 0 1)).prod (unitCubeMeasure n)) := by + simpa only [Function.comp_def, MeasurableEquiv.piFinSuccAbove_symm_apply, Fin.insertNthEquiv, + Fin.insertNth_zero, Fin.zero_succAbove, Equiv.coe_fn_mk, cast_eq] using + ((measurePreserving_piFinSuccAbove + (fun _ : Fin (n+1) => volume.restrict (Ioo (0:ℝ) 1)) 0).symm).integrable_comp_of_integrable hf + +lemma integrable_unitCube_of_abs_le_weights {n : ℕ} {f : (Fin n → ℝ) → ℝ} + (hf : Measurable f) {b : ℝ} + (hbd : ∀ z, (∀ i, z i ∈ Ioo (0:ℝ) 1) → |f z| ≤ b * ∏ i, omega (z i)) : + Integrable f (unitCubeMeasure n) := by + apply ((Integrable.fintype_prod (fun _ : Fin n => integrableOn_omega)).const_mul b).mono' + hf.aestronglyMeasurable + filter_upwards [ae_unitCube n] with z hz + exact hbd z hz + +lemma reflection_with_density_cons {n : ℕ} {x : ℝ} {y : Fin n → ℝ} + (_hx : 0 < x) (_hy : ∀ i, 0 < y i) : + omega x * reflectionProduct n x y * density n y = + density (n+1) (Fin.cons x y) / ∏ j, (y j-x) := by + rw [density_cons, mul_div_assoc, ← Finset.prod_div_distrib] + have he : ∏ j, pairKernel x (y j) / (y j-x) = reflectionProduct n x y := by + apply Finset.prod_congr rfl + intro j _ + unfold pairKernel + by_cases h : y j = x + · simp [h] + · field_simp [sub_ne_zero.mpr h] + rw [he] + ring + +lemma lagrange_reverse_denominator_sum {n k : ℕ} (hk : k < n) {z : Fin (n+1) → ℝ} + (hz : Function.Injective z) : + ∑ i, z i ^ k / ∏ j ∈ Finset.univ.erase i, (z j-z i) = 0 := by + classical + have hd : (Polynomial.X ^ k : Polynomial ℝ).degree < + ((Finset.univ : Finset (Fin (n+1))).card : WithBot ℕ) := by + simp only [Polynomial.degree_X_pow, Finset.card_univ, Fintype.card_fin] + exact_mod_cast (by omega : k < n+1) + have H := Lagrange.coeff_eq_sum hz.injOn hd + simp only [Polynomial.coeff_X_pow, Finset.card_univ, Fintype.card_fin, + Nat.add_sub_cancel, ite_eq_right (by omega : n ≠ k), Polynomial.eval_pow, + Polynomial.eval_X] at H + have he (i : Fin (n+1)) : + (∏ j ∈ Finset.univ.erase i, (z j-z i)) = + (-1:ℝ)^n * ∏ j ∈ Finset.univ.erase i, (z i-z j) := by + simp_rw [show ∀ j, z j-z i = (-1:ℝ)*(z i-z j) from fun j => by ring] + rw [Finset.prod_mul_distrib] + simp + simp_rw [he, mul_comm ((-1:ℝ)^n), div_mul_eq_div_mul_one_div] + rw [← Finset.sum_mul, ← H, zero_mul] + + + +def reflectionMomentKernel (n k : ℕ) (z : Fin (n+1) → ℝ) : ℝ := + (z 0)^k * omega (z 0) * reflectionProduct n (z 0) (Fin.tail z) * density n (Fin.tail z) + +lemma measurable_reflectionMomentKernel (n k : ℕ) : Measurable (reflectionMomentKernel n k) := by + have ht : Measurable (fun z : Fin (n+1) → ℝ => Fin.tail z) := + Measurable.of_eval (fun i => measurable_pi_apply i.succ) + exact ((((measurable_pi_apply 0).pow_const k).mul (measurable_omega.comp (measurable_pi_apply 0))).mul + ((measurable_reflectionProduct n).comp ((measurable_pi_apply 0).prodMk ht))).mul + ((measurable_density n).comp ht) + +lemma abs_reflectionMomentKernel_le_weights {n k : ℕ} {z : Fin (n+1) → ℝ} + (hz : ∀ i, z i ∈ Ioo (0:ℝ) 1) : + |reflectionMomentKernel n k z| ≤ ∏ i, omega (z i) := by + have ht : ∀ i, Fin.tail z i ∈ Ioo (0:ℝ) 1 := fun i => hz i.succ + have hpow : (z 0)^k ≤ 1 := pow_le_one₀ (hz 0).1.le (hz 0).2.le + have hrefl : |reflectionProduct n (z 0) (Fin.tail z)| ≤ 1 := by + rw [reflectionProduct, Finset.abs_prod] + exact Finset.prod_le_one₀ (fun _ _ => abs_nonneg _) + (fun i _ => abs_reflectionFactor_le_one (hz 0).1.le (ht i).1) + rw [reflectionMomentKernel, abs_mul, abs_mul, abs_mul, + abs_of_nonneg (pow_nonneg (hz 0).1.le _), abs_of_nonneg (omega_nonneg _), + abs_of_nonneg (density_nonneg_of_nonneg (fun i => (ht i).1.le)), Fin.prod_univ_succ] + calc + _ ≤ 1 * omega (z 0) * 1 * (∏ i, omega (Fin.tail z i)) := by + apply mul_le_mul + · exact mul_le_mul (mul_le_mul_of_nonneg_right hpow (omega_nonneg _)) hrefl + (abs_nonneg _) (by positivity [omega_nonneg (z 0)]) + · exact density_cube_le_product ht + · exact density_nonneg_of_nonneg (fun i => (ht i).1.le) + · positivity [omega_nonneg (z 0)] + _ = _ := by simp [Fin.tail_def] + +lemma integrable_reflectionMomentKernel (n k : ℕ) : + Integrable (reflectionMomentKernel n k) (unitCubeMeasure (n+1)) := by + apply integrable_unitCube_of_abs_le_weights (measurable_reflectionMomentKernel n k) (b := 1) + intro z hz + simpa only [one_mul] using abs_reflectionMomentKernel_le_weights (k := k) hz + +lemma reflectionMomentKernel_sum_swaps {n k : ℕ} (hk : k < n) + {z : Fin (n+1) → ℝ} (hz : ∀ i, 0 < z i) : + ∑ i : Fin (n+1), reflectionMomentKernel n k (z ∘ Equiv.swap 0 i) = 0 := by + classical + have he (i : Fin (n+1)) : reflectionMomentKernel n k (z ∘ Equiv.swap 0 i) = + density (n+1) z * (z i ^ k / ∏ j ∈ Finset.univ.erase i, (z j-z i)) := by + have hx : 0 < (z ∘ Equiv.swap 0 i) 0 := hz _ + have hy : ∀ j, 0 < Fin.tail (z ∘ Equiv.swap 0 i) j := fun j => hz _ + unfold reflectionMomentKernel + rw [mul_assoc ((z ∘ Equiv.swap 0 i) 0 ^ k), mul_assoc, + reflection_with_density_cons hx hy, Fin.cons_self_tail, + density_perm_of_nonneg (fun i => (hz i).le)] + have hp : (∏ j, (Fin.tail (z ∘ Equiv.swap 0 i) j - (z ∘ Equiv.swap 0 i) 0)) = + ∏ j ∈ Finset.univ.erase i, (z j-z i) := by + have he0 : (∏ j, (Fin.tail (z ∘ Equiv.swap 0 i) j - (z ∘ Equiv.swap 0 i) 0)) = + ∏ j ∈ Finset.univ.erase (0 : Fin (n+1)), ((z ∘ Equiv.swap 0 i) j - z i) := by + have he0 : (Finset.univ.erase (0 : Fin (n+1))) = + Finset.univ.filter (fun j => j ≠ 0) := by ext; simp + rw [he0, Finset.prod_filter, Fin.prod_univ_succ] + simp [Fin.tail_def] + have hs : ∏ j ∈ Finset.univ.erase (0 : Fin (n+1)), ((z ∘ Equiv.swap 0 i) j - z i) = + ∏ j ∈ Finset.univ.erase i, (z j-z i) := by + apply Finset.prod_equiv (Equiv.swap 0 i) + · intro j + simp [Equiv.swap_apply_eq_iff] + · intro j hj + rfl + exact he0.trans hs + rw [hp] + simp only [Function.comp_apply, Equiv.swap_apply_left] + ring + simp_rw [he, ← Finset.mul_sum] + by_cases hi : Function.Injective z + · rw [lagrange_reverse_denominator_sum hk hi, mul_zero] + · rw [density_zero_of_not_injective hi, zero_mul] + +lemma integral_reflectionMomentKernel_zero {n k : ℕ} (hk : k < n) : + (∫ z, reflectionMomentKernel n k z ∂unitCubeMeasure (n+1)) = 0 := by + classical + have his (i : Fin (n+1)) : Integrable + (fun z => reflectionMomentKernel n k (z ∘ Equiv.swap 0 i)) (unitCubeMeasure (n+1)) := by + simpa only [Function.comp_def, StripPfaffian.piCongrLeft_const_apply, Equiv.symm_symm] using + (measurePreserving_piCongrLeft (fun _ : Fin (n+1) => volume.restrict (Ioo (0:ℝ) 1)) + (Equiv.swap 0 i).symm).integrable_comp_of_integrable (integrable_reflectionMomentKernel n k) + have he (i : Fin (n+1)) : + (∫ z, reflectionMomentKernel n k (z ∘ Equiv.swap 0 i) ∂unitCubeMeasure (n+1)) = + ∫ z, reflectionMomentKernel n k z ∂unitCubeMeasure (n+1) := by + simpa only [StripPfaffian.piCongrLeft_const_apply, Equiv.symm_symm] using + (measurePreserving_piCongrLeft (fun _ : Fin (n+1) => volume.restrict (Ioo (0:ℝ) 1)) + (Equiv.swap 0 i).symm).integral_comp' (reflectionMomentKernel n k) + have hsum : ((n:ℝ)+1) * (∫ z, reflectionMomentKernel n k z ∂unitCubeMeasure (n+1)) = 0 := by + calc + _ = ∑ i : Fin (n+1), ∫ z, reflectionMomentKernel n k (z ∘ Equiv.swap 0 i) ∂unitCubeMeasure (n+1) := by + simp only [he, Finset.sum_const, Finset.card_univ, Fintype.card_fin, nsmul_eq_mul, Nat.cast_add, Nat.cast_one] + _ = ∫ z, ∑ i : Fin (n+1), reflectionMomentKernel n k (z ∘ Equiv.swap 0 i) ∂unitCubeMeasure (n+1) := + (integral_finsetSum _ (fun i _ => his i)).symm + _ = ∫ _z, (0 : ℝ) ∂unitCubeMeasure (n+1) := by + apply integral_congr_ae + filter_upwards [ae_unitCube (n+1)] with z hz + exact reflectionMomentKernel_sum_swaps hk (fun i => (hz i).1) + _ = 0 := integral_zero _ _ + exact (mul_eq_zero.mp hsum).resolve_left (by positivity) + + + +theorem reflection_expectation_moments {n k : ℕ} (hk : k < n) : + (∫ x in Ioo (0:ℝ) 1, momentBasis k x * expectation n (reflectionProduct n x)) = 0 := by + have hF := integral_reflectionMomentKernel_zero hk + rw [integral_unitCube_cons, integral_prod _ (integrable_unitCube_cons (integrable_reflectionMomentKernel n k))] at hF + have he (x : ℝ) : (∫ y, reflectionMomentKernel n k (Fin.cons x y) ∂unitCubeMeasure n) = + momentBasis k x * (∫ y, reflectionProduct n x y * density n y ∂unitCubeMeasure n) := by + simp only [reflectionMomentKernel, Fin.cons_zero, Fin.tail_cons, momentBasis, + mul_assoc, integral_const_mul] + simp_rw [he] at hF + calc + _ = ∫ x in Ioo (0:ℝ) 1, + (momentBasis k x * (∫ y, reflectionProduct n x y * density n y ∂unitCubeMeasure n)) / + (∫ y, density n y ∂unitCubeMeasure n) := by + apply setIntegral_congr_fun measurableSet_Ioo + intro x hx + dsimp only + rw [expectation_reflection_unitCube n hx.1.le, mul_div_assoc] + _ = 0 := by rw [integral_div, hF, zero_div] + + + +def meanCharacteristic (n : ℕ) : Polynomial ℝ := + ∑ s ∈ (Finset.univ : Finset (Fin n)).powerset, + Polynomial.C ((-1 : ℝ)^s.card * + ∫ y, (∏ j ∈ Finset.univ \ s, y j) * density n y ∂unitCubeMeasure n) * Polynomial.X^s.card + +lemma integrable_coordinateProduct_density {n : ℕ} (s : Finset (Fin n)) : + Integrable (fun y => (∏ j ∈ s, y j) * density n y) (unitCubeMeasure n) := by + apply integrable_cube_mul_density (by fun_prop) (b := 1) + intro y hy + rw [Finset.abs_prod] + exact Finset.prod_le_one₀ (fun _ _ => abs_nonneg _) (fun j _ => by rw [abs_of_pos (hy j).1]; exact (hy j).2.le) + +lemma meanCharacteristic_eval (n : ℕ) (x : ℝ) : + (meanCharacteristic n).eval x = ∫ y, (∏ j, (y j-x)) * density n y ∂unitCubeMeasure n := by + classical + have he (y : Fin n → ℝ) : (∏ j, (y j-x)) * density n y = + ∑ s ∈ (Finset.univ : Finset (Fin n)).powerset, + ((-1 : ℝ)^s.card * x^s.card) * ((∏ j ∈ Finset.univ \ s, y j) * density n y) := by + rw [Finset.prod_sub, Finset.sum_mul] + apply Finset.sum_congr rfl + intro s _ + simp only [Finset.prod_const] + ring + simp_rw [he] + rw [integral_finsetSum _ (fun s _ => (integrable_coordinateProduct_density _).const_mul _)] + simp only [meanCharacteristic, Polynomial.eval_finsetSum, Polynomial.eval_mul, + Polynomial.eval_C, Polynomial.eval_pow, Polynomial.eval_X, integral_const_mul] + apply Finset.sum_congr rfl + intro s _ + ring + +lemma meanCharacteristic_natDegree (n : ℕ) : (meanCharacteristic n).natDegree ≤ n := by + classical + apply Polynomial.natDegree_sum_le_of_forall_le + intro s hs + apply (Polynomial.natDegree_mul_le).trans + simpa only [Polynomial.natDegree_C, Polynomial.natDegree_X_pow, zero_add, Finset.card_univ, + Fintype.card_fin] using (Finset.card_le_card (Finset.mem_powerset.mp hs)) + +lemma polynomial_transformedBasis (n : ℕ) (p : Polynomial ℝ) (hp : p.natDegree < n) + {x : ℝ} (hx : 0 < x) : + x * (∫ y in Ioo (0:ℝ) 1, p.eval y * omega y / (x+y)) = + ∑ k : Fin n, p.coeff k.val * transformedBasis k.val x := by + have hev (y : ℝ) : p.eval y = ∑ k : Fin n, p.coeff k.val * y^k.val := by + rw [Polynomial.eval_eq_sum_range' hp, ← Fin.sum_univ_eq_sum_range] + have heq : (fun y => x * (p.eval y * omega y / (x+y))) = + fun y => ∑ k : Fin n, p.coeff k.val * (boundedCauchy x y * momentBasis k.val y) := by + funext y + rw [hev] + simp only [Finset.sum_mul, Finset.sum_div, Finset.mul_sum] + apply Finset.sum_congr rfl + intro k _ + unfold boundedCauchy momentBasis + ring + rw [← integral_const_mul, heq, + integral_finsetSum _ (fun k _ => (integrableOn_boundedCauchy_basis k.val hx).const_mul _)] + simp only [integral_const_mul, transformedBasis] + + +def reflectionResidueKernel (n : ℕ) (x : ℝ) (i : Fin n) (y : Fin n → ℝ) : ℝ := + reflectionResidue n y i * density n y / (x+y i) + +lemma measurable_reflectionResidueKernel (n : ℕ) (x : ℝ) (i : Fin n) : + Measurable (reflectionResidueKernel n x i) := by + unfold reflectionResidueKernel reflectionResidue + apply Measurable.div + · apply Measurable.mul _ (measurable_density n) + fun_prop + · fun_prop + +lemma reflectionResidueKernel_perm {n : ℕ} (x : ℝ) {y : Fin n → ℝ} + (hy : ∀ i, 0 ≤ y i) (σ : Equiv.Perm (Fin n)) (i : Fin n) : + reflectionResidueKernel n x i (y ∘ σ) = reflectionResidueKernel n x (σ i) y := by + unfold reflectionResidueKernel + rw [reflectionResidue_perm, density_perm_of_nonneg hy] + rfl + +lemma reflectionResidueKernel_cons {n : ℕ} (x : ℝ) {u : ℝ} {y : Fin n → ℝ} + (hu : 0 < u) (hy : ∀ i, 0 < y i) : + reflectionResidueKernel (n+1) x 0 (Fin.cons u y) = + 2 * omega u / (x+u) * ((∏ j, (y j-u)) * density n y) := by + rw [reflectionResidueKernel, reflectionResidue_density_cons hu hy, Fin.cons_zero] + ring + +lemma abs_reflectionResidueKernel_zero_le {n : ℕ} {x : ℝ} (hx : 0 < x) + {z : Fin (n+1) → ℝ} (hz : ∀ i, z i ∈ Ioo (0:ℝ) 1) : + |reflectionResidueKernel (n+1) x 0 z| ≤ (2/x) * ∏ i, omega (z i) := by + have hprod : |∏ j : Fin n, (Fin.tail z j-z 0)| ≤ 1 := by + rw [Finset.abs_prod] + exact Finset.prod_le_one₀ (fun _ _ => abs_nonneg _) (fun j _ => by + rw [abs_le]; constructor <;> dsimp [Fin.tail_def] <;> linarith [(hz j.succ).1, (hz j.succ).2, (hz 0).1, (hz 0).2]) + have hd : 0 ≤ density n (Fin.tail z) := density_nonneg_of_nonneg fun j => (hz j.succ).1.le + have hω := omega_nonneg (z 0) + have hz0 : 0 < z 0 := (hz 0).1 + have he := reflectionResidueKernel_cons (y := Fin.tail z) x (hz 0).1 (fun j => (hz j.succ).1) + change reflectionResidueKernel (n+1) x 0 (Fin.cons (z 0) (Fin.tail z)) = _ at he + rw [Fin.cons_self_tail] at he + rw [he, abs_mul, abs_of_nonneg (by positivity : 0 ≤ 2*omega (z 0)/(x+z 0)), abs_mul, abs_of_nonneg hd] + calc + _ ≤ (2*omega (z 0)/(x+z 0)) * (1 * density n (Fin.tail z)) := + mul_le_mul_of_nonneg_left (mul_le_mul_of_nonneg_right hprod hd) (by positivity [ (hz 0).1 ]) + _ ≤ (2*omega (z 0)/x) * density n (Fin.tail z) := by + rw [one_mul] + apply mul_le_mul_of_nonneg_right _ hd + exact div_le_div_of_nonneg_left (by positivity) hx (le_add_of_nonneg_right (hz 0).1.le) + _ ≤ (2*omega (z 0)/x) * ∏ j : Fin n, omega (Fin.tail z j) := + mul_le_mul_of_nonneg_left (density_cube_le_product (fun j => hz j.succ)) (by positivity) + _ = _ := by rw [Fin.prod_univ_succ]; simp only [Fin.tail_def]; ring + +lemma abs_reflectionResidueKernel_le {n : ℕ} {x : ℝ} (hx : 0 < x) + (i : Fin (n+1)) {z : Fin (n+1) → ℝ} (hz : ∀ i, z i ∈ Ioo (0:ℝ) 1) : + |reflectionResidueKernel (n+1) x i z| ≤ (2/x) * ∏ j, omega (z j) := by + have he : reflectionResidueKernel (n+1) x 0 (z ∘ Equiv.swap 0 i) = + reflectionResidueKernel (n+1) x i z := by + rw [reflectionResidueKernel_perm _ (fun i => (hz i).1.le), Equiv.swap_apply_left] + have h := abs_reflectionResidueKernel_zero_le (z := z ∘ Equiv.swap 0 i) hx (fun j => hz (Equiv.swap 0 i j)) + rw [he] at h + apply h.trans_eq + congr 1 + exact Fintype.prod_equiv (Equiv.swap 0 i) _ _ (fun _ => rfl) + +lemma integrable_reflectionResidueKernel {n : ℕ} {x : ℝ} (hx : 0 < x) (i : Fin (n+1)) : + Integrable (reflectionResidueKernel (n+1) x i) (unitCubeMeasure (n+1)) := by + exact integrable_unitCube_of_abs_le_weights (measurable_reflectionResidueKernel _ _ _) + (fun _ hz => abs_reflectionResidueKernel_le hx i hz) + +end +end CriticalStrip + +end OAI diff --git a/lean/OAI/Combinatorics/StripMass/ReflectionIntegrals.lean b/lean/OAI/Combinatorics/StripMass/ReflectionIntegrals.lean new file mode 100644 index 0000000000000000000000000000000000000000..9a713ec6a5243c01b4ee46a2e8fdb3f7f180440e --- /dev/null +++ b/lean/OAI/Combinatorics/StripMass/ReflectionIntegrals.lean @@ -0,0 +1,478 @@ +import Mathlib +import OAI.Combinatorics.StripMass.ReflectionFractions + +namespace OAI + +/-! Critical honeycomb strip paths, polynomial identities and crossing mass. -/ + + +namespace CriticalStrip +noncomputable section +open scoped BigOperators +open Set MeasureTheory +lemma integral_reflectionResidueKernel_eq_zero_index {n : ℕ} {x : ℝ} + (i : Fin (n+1)) : + (∫ z, reflectionResidueKernel (n+1) x i z ∂unitCubeMeasure (n+1)) = + ∫ z, reflectionResidueKernel (n+1) x 0 z ∂unitCubeMeasure (n+1) := by + have he := (measurePreserving_piCongrLeft (fun _ : Fin (n+1) => volume.restrict (Ioo (0:ℝ) 1)) + (Equiv.swap 0 i).symm).integral_comp' (reflectionResidueKernel (n+1) x 0) + simp only [StripPfaffian.piCongrLeft_const_apply, Equiv.symm_symm] at he + refine (integral_congr_ae ?_).trans he + filter_upwards [ae_unitCube (n+1)] with z hz + rw [reflectionResidueKernel_perm x (fun i => (hz i).1.le), Equiv.swap_apply_left] + +lemma integral_reflectionResidueKernel_zero_index {n : ℕ} {x : ℝ} (hx : 0 < x) : + (∫ z, reflectionResidueKernel (n+1) x 0 z ∂unitCubeMeasure (n+1)) = + 2 * ∫ u in Ioo (0:ℝ) 1, (meanCharacteristic n).eval u * omega u / (x+u) := by + rw [integral_unitCube_cons, integral_prod _ (integrable_unitCube_cons (integrable_reflectionResidueKernel hx 0)), + ← integral_const_mul] + apply setIntegral_congr_fun measurableSet_Ioo + intro u hu + dsimp only + calc + _ = ∫ y, 2*omega u/(x+u)*((∏ j, (y j-u))*density n y) ∂unitCubeMeasure n := by + apply integral_congr_ae + filter_upwards [ae_unitCube n] with y hy + exact reflectionResidueKernel_cons x hu.1 (fun i => (hy i).1) + _ = _ := by rw [integral_const_mul, ← meanCharacteristic_eval]; ring + +lemma reflection_partialFractions_density {n : ℕ} {y : Fin (n+1) → ℝ} + (hy : ∀ i, 0 < y i) {x : ℝ} (hx : 0 ≤ x) : + reflectionProduct (n+1) x y * density (n+1) y = + density (n+1) y - x * ∑ i, reflectionResidueKernel (n+1) x i y := by + by_cases hi : Function.Injective y + · rw [reflection_partialFractions_distinct (Nat.succ_pos n) hy hi hx, sub_mul, + one_mul, mul_assoc, Finset.sum_mul] + congr 1 + congr 1 + apply Finset.sum_congr rfl + intro i _ + unfold reflectionResidueKernel + ring + · simp only [density_zero_of_not_injective hi, reflectionResidueKernel, + mul_zero, zero_div, Finset.sum_const_zero, sub_self] + +lemma expectation_reflection_cauchy (n : ℕ) {x : ℝ} (hx : 0 < x) : + expectation (n+1) (reflectionProduct (n+1) x) = + 1 - (2*((n:ℝ)+1)/(∫ z, density (n+1) z ∂unitCubeMeasure (n+1))) * + ∑ k : Fin (n+1), (meanCharacteristic n).coeff k.val * transformedBasis k.val x := by + have hD : (∫z, density (n+1) z ∂unitCubeMeasure (n+1)) ≠ 0 := by + rw [integral_density_unitCube] + exact mul_ne_zero (by exact_mod_cast Nat.factorial_ne_zero (n+1)) (normalizer_pos _).ne' + rw [expectation_reflection_unitCube (n+1) hx.le] + have he : (∫ y, reflectionProduct (n+1) x y * density (n+1) y ∂unitCubeMeasure (n+1)) = + (∫ y, density (n+1) y ∂unitCubeMeasure (n+1)) - + x * ((n:ℝ)+1) * (2 * ∫ u in Ioo (0:ℝ) 1, (meanCharacteristic n).eval u * omega u / (x+u)) := by + calc + _ = ∫ y, density (n+1) y - x * ∑ i, reflectionResidueKernel (n+1) x i y ∂unitCubeMeasure (n+1) := by + apply integral_congr_ae + filter_upwards [ae_unitCube (n+1)] with y hy + exact reflection_partialFractions_density (fun i => (hy i).1) hx.le + _ = _ := by + rw [integral_sub (integrable_density_unitCube (n+1)) + ((integrable_finsetSum _ (fun i _ => integrable_reflectionResidueKernel hx i)).const_mul x), + integral_const_mul, integral_finsetSum _ (fun i _ => integrable_reflectionResidueKernel hx i)] + simp only [integral_reflectionResidueKernel_eq_zero_index, Finset.sum_const, + Finset.card_univ, Fintype.card_fin, nsmul_eq_mul, Nat.cast_add, Nat.cast_one, + integral_reflectionResidueKernel_zero_index hx, mul_assoc] + rw [he, ← polynomial_transformedBasis (n+1) (meanCharacteristic n) (by have := meanCharacteristic_natDegree n; omega) hx] + field_simp + + + +theorem reflection_expectation_cauchyMomentProblem (n : ℕ) : + ∃ v : Fin (n+1) → ℝ, CauchyMomentProblem (n+1) 1 v ∧ + ∀ x : ℝ, 0 < x → expectation (n+1) (reflectionProduct (n+1) x) = cauchyDefect (n+1) 1 v x := by + let v : Fin (n+1) → ℝ := fun k => + (2*((n:ℝ)+1)/(∫z, density (n+1) z ∂unitCubeMeasure (n+1))) * (meanCharacteristic n).coeff k.val + have he (x : ℝ) (hx : 0 < x) : expectation (n+1) (reflectionProduct (n+1) x) = + cauchyDefect (n+1) 1 v x := by + rw [expectation_reflection_cauchy n hx] + simp only [cauchyDefect, v, Finset.mul_sum, mul_assoc] + refine ⟨v, ?_, he⟩ + intro j + calc + _ = ∫ x in Ioo (0:ℝ) 1, momentBasis j.val x * expectation (n+1) (reflectionProduct (n+1) x) := by + apply setIntegral_congr_fun measurableSet_Ioo + intro x hx + dsimp only + rw [he x hx.1] + _ = 0 := reflection_expectation_moments j.isLt + +end + + + +noncomputable section +open Polynomial Set MeasureTheory Filter +open scoped Topology BigOperators + +lemma harmonicCoordinate_natDegree : harmonicCoordinate.natDegree = 4 := by + unfold harmonicCoordinate + compute_degree <;> norm_num + +lemma harmonicCoordinate_leadingCoeff : harmonicCoordinate.leadingCoeff = -1 := by + rw [leadingCoeff, harmonicCoordinate_natDegree] + have he : harmonicCoordinate = (X^2-X^4 : Polynomial ℝ) := by unfold harmonicCoordinate; ring + rw [he] + norm_num + +lemma degree_lt_implies_natDegree_lt {N : ℕ} (hN : 0 < N) {p : Polynomial ℝ} + (hp : p.degree < (N : WithBot ℕ)) : p.natDegree < N := by + by_cases h : p = 0 + · simpa [h] using hN + · exact (natDegree_lt_iff_degree_lt h).mpr hp + +lemma coeff_comp_top_of_le {p q : Polynomial ℝ} {N : ℕ} (hp : p.natDegree ≤ N) + (hq : q.natDegree ≠ 0) : + (p.comp q).coeff (N*q.natDegree) = p.coeff N * q.leadingCoeff^N := by + rcases hp.eq_or_lt with he | he + · rw [← he] + exact coeff_comp_degree_mul_degree hq + · rw [coeff_eq_zero_of_natDegree_lt he, zero_mul] + apply coeff_eq_zero_of_natDegree_lt + rw [natDegree_comp] + exact Nat.mul_lt_mul_of_pos_right he (Nat.pos_of_ne_zero hq) + +lemma tildePoly_eval_zero (N : ℕ) {p : Polynomial ℝ} (hp : p.natDegree ≤ N) : + (tildePoly N p).eval 0 = p.coeff N * (1/8:ℝ)^N := by + have hq : (Polynomial.C (1/8:ℝ)*(1+X)).natDegree = 1 := by compute_degree; norm_num + have hqL : (Polynomial.C (1/8:ℝ)*(1+X)).leadingCoeff = 1/8 := by + rw [leadingCoeff, hq] + norm_num [coeff_C_mul, coeff_add, coeff_one] + rw [← coeff_zero_eq_eval_zero, tildePoly, coeff_reflect, revAt_zero] + convert coeff_comp_top_of_le hp (by rw [hq]; norm_num) using 1 <;> simp only [hq, mul_one, hqL] + +lemma comp_harmonic_odd (p : Polynomial ℝ) (n : ℕ) : + (p.comp harmonicCoordinate).coeff (2*n+1) = 0 := by + have he : harmonicCoordinate = (X*(1-X) : Polynomial ℝ).comp (X^2) := by + simp only [mul_comp, sub_comp, X_comp, one_comp] + rfl + rw [he, ← comp_assoc, ← expand_eq_comp_X_pow, coeff_expand (by norm_num)] + simp + +lemma projection_top_coefficients (N : ℕ) (hN : 1 ≤ N) (P J E : Polynomial ℝ) + (hP : P.natDegree ≤ N) (hJ : J.natDegree ≤ N) (hE : E.degree < (N : WithBot ℕ)) : + let Q := P.comp harmonicCoordinate + X * J.comp harmonicCoordinate + X^2 * E.comp harmonicCoordinate + Q.coeff (4*N+1) = (-8:ℝ)^N * (tildePoly N J).eval 0 ∧ + Q.coeff (4*N) = (-8:ℝ)^N * (tildePoly N P).eval 0 := by + have hn : 0 < N := by omega + have hen := degree_lt_implies_natDegree_lt hn hE + have he : (X^2*E.comp harmonicCoordinate).natDegree < 4*N := by + exact natDegree_mul_le.trans_lt (by rw [natDegree_X_pow, natDegree_comp, harmonicCoordinate_natDegree]; omega) + have hpcomp : (P.comp harmonicCoordinate).natDegree ≤ 4*N := by + rw [natDegree_comp, harmonicCoordinate_natDegree]; omega + have hjN : (J.comp harmonicCoordinate).coeff (4*N) = J.coeff N * (-1:ℝ)^N := by + simpa only [harmonicCoordinate_natDegree, harmonicCoordinate_leadingCoeff, mul_comm] using + coeff_comp_top_of_le (q := harmonicCoordinate) hJ (by rw [harmonicCoordinate_natDegree]; norm_num) + have hpN : (P.comp harmonicCoordinate).coeff (4*N) = P.coeff N * (-1:ℝ)^N := by + simpa only [harmonicCoordinate_natDegree, harmonicCoordinate_leadingCoeff, mul_comm] using + coeff_comp_top_of_le (q := harmonicCoordinate) hP (by rw [harmonicCoordinate_natDegree]; norm_num) + have hjOdd : (X*J.comp harmonicCoordinate).coeff (4*N) = 0 := by + have ha : 4*N = (4*N-1)+1 := by omega + rw [ha, coeff_X_mul] + have hb : 4*N-1 = 2*(2*N-1)+1 := by omega + rw [hb, comp_harmonic_odd] + have hscalar (a : ℝ) : a*(-1:ℝ)^N = (-8:ℝ)^N*(a*(1/8:ℝ)^N) := by + rw [mul_left_comm, ← mul_pow] + norm_num + dsimp only + constructor + · rw [coeff_add, coeff_add, coeff_eq_zero_of_natDegree_lt (by omega : (P.comp harmonicCoordinate).natDegree < 4*N+1), + coeff_eq_zero_of_natDegree_lt (he.trans_le (by omega)), coeff_X_mul, + zero_add, add_zero, hjN, tildePoly_eval_zero N hJ] + exact hscalar _ + · rw [coeff_add, coeff_add, coeff_eq_zero_of_natDegree_lt he, add_zero, hjOdd, add_zero, + hpN, tildePoly_eval_zero N hP] + exact hscalar _ + +lemma homogeneousQ_monic {N : ℕ} {g : Polynomial ℝ} (hg : g.Monic) : + (homogeneousQ N g).Monic := by + exact (((monic_X_sub_C C).pow _).mul ((monic_X_sub_C c).pow _)).mul hg + +lemma homogeneousQ_natDegree {N : ℕ} {g : Polynomial ℝ} (hg : g.Monic) (hd : g.natDegree = N) : + (homogeneousQ N g).natDegree = 4*N+1 := by + rw [homogeneousQ, (((monic_X_sub_C C).pow _).mul ((monic_X_sub_C c).pow _)).natDegree_mul hg, + ((monic_X_sub_C C).pow _).natDegree_mul ((monic_X_sub_C c).pow _)] + simp only [natDegree_pow, natDegree_X_sub_C, mul_one, hd] + omega + +lemma homogeneousQ_nextCoeff (N : ℕ) (hN : 1 ≤ N) {g : Polynomial ℝ} + (hg : g.Monic) (hd : g.natDegree = N) : + (homogeneousQ N g).coeff (4*N) = g.coeff (N-1) - ((2*N+1:ℕ):ℝ)*C - (N:ℝ)*c := by + have hdeg := homogeneousQ_natDegree hg hd + have hn : 0 < (homogeneousQ N g).natDegree := by rw [hdeg]; omega + rw [show 4*N = (homogeneousQ N g).natDegree-1 by omega, ← nextCoeff_of_natDegree_pos hn, + homogeneousQ, (((monic_X_sub_C C).pow _).mul ((monic_X_sub_C c).pow _)).nextCoeff_mul hg, + ((monic_X_sub_C C).pow _).nextCoeff_mul ((monic_X_sub_C c).pow _), + (monic_X_sub_C C).nextCoeff_pow, (monic_X_sub_C c).nextCoeff_pow, + nextCoeff_X_sub_C, nextCoeff_X_sub_C, + nextCoeff_of_natDegree_pos (by rw [hd]; omega), hd] + simp only [nsmul_eq_mul] + ring + +lemma projectionD_expectation (N : ℕ) (hN : 1 ≤ N) (g P J E : Polynomial ℝ) + (hP : P.natDegree ≤ N) (hJ : J.natDegree ≤ N) (hE : E.degree < (N : WithBot ℕ)) + (hQ : homogeneousQ N g = P.comp harmonicCoordinate + X * J.comp harmonicCoordinate + + X^2 * E.comp harmonicCoordinate) : + ∀ x : ℝ, 0 < x → projectionD (tildePoly N J) (tildePoly N E) x = + (tildePoly N J).eval 0 * expectation N (reflectionProduct N x) := by + have hEn : E.natDegree < N := degree_lt_implies_natDegree_lt (by omega) hE + have hdiv : X ∣ tildePoly N E := X_dvd_iff.2 (by + simpa only [coeff_zero_eq_eval_zero] using tildePoly_zero_of_degree_lt N hE) + obtain ⟨e, he⟩ := hdiv + have hen : e.natDegree < N := by + by_cases he0 : e = 0 + · simp [he0]; omega + have hb := tildePoly_natDegree_le N hEn.le + rw [he, natDegree_X_mul he0] at hb + omega + have hF : ∀ j : ℕ, j ≤ N → Tendsto + (fun t : ℝ => (-t)^j * projectionF (tildePoly N P) (tildePoly N J) (tildePoly N E) (-t)) + atTop (𝓝 0) := fun j hj => tilde_F_decay N g P J E hP hJ hEn.le hQ j hj + obtain ⟨L, hD⟩ := tilde_D_limit N g P J E hP hJ hEn.le hQ + change Tendsto (fun z : ℝ => projectionD (tildePoly N J) (tildePoly N E) z) atTop (𝓝 L) at hD + have hDc := projectionD_cauchy (tildePoly N J) e (by simpa only [← he] using hD) + have hm := projection_moments_of_decay N (tildePoly N P) (tildePoly N J) (tildePoly N E) hF + let D₀ := (tildePoly N J).eval 0 + let v : Fin N → ℝ := fun k => -(Real.sqrt 2 / Real.pi) * (e.coeff k.val * (-1)^k.val) + have hev {x : ℝ} (hx : 0 < x) : + projectionD (tildePoly N J) (tildePoly N E) x = cauchyDefect N D₀ v x := by + rw [he, hDc x hx, mul_assoc, stieltjes_polynomial_basis N e hen hx] + simp only [cauchyDefect, v, Finset.mul_sum, neg_mul, Finset.sum_neg_distrib, sub_neg_eq_add, D₀] + congr 1 + apply Finset.sum_congr rfl + intro k _ + ring + have hv : CauchyMomentProblem N D₀ v := by + intro j + calc + _ = ∫ x in Ioo (0:ℝ) 1, x^j.val * (projectionD (tildePoly N J) (tildePoly N E) x * omega x) := by + apply setIntegral_congr_fun measurableSet_Ioo + intro x hx + dsimp only + rw [hev hx.1] + unfold momentBasis + ring + _ = 0 := hm j.val j.isLt + obtain ⟨n, rfl⟩ := Nat.exists_eq_succ_of_ne_zero (by omega : N ≠ 0) + obtain ⟨w, hw, hew⟩ := reflection_expectation_cauchyMomentProblem n + let w' : Fin (n+1) → ℝ := fun i => D₀ * w i + have bew (x : ℝ) : cauchyDefect (n+1) D₀ w' x = D₀ * cauchyDefect (n+1) 1 w x := by + simp only [cauchyDefect, w', mul_sub, mul_one, Finset.mul_sum, mul_assoc] + have hw' : CauchyMomentProblem (n+1) D₀ w' := by + intro j + simp_rw [bew] + have eq : (fun x => momentBasis j.val x * (D₀ * cauchyDefect (n+1) 1 w x)) = + fun x => D₀ * (momentBasis j.val x * cauchyDefect (n+1) 1 w x) := by funext x; ring + rw [eq, integral_const_mul, hw j, mul_zero] + have huniq : v = w' := (existsUnique_cauchyMomentProblem (n+1) D₀).unique hv hw' + intro x hx + rw [hev hx, huniq, bew, ← hew x hx] + +lemma tendsto_scaled_fBranch_sq_zero : + Tendsto (fun t : ℝ => t * fBranch (-t)^2) (𝓝[>] 0) (𝓝 0) := by + have hcont : Continuous (fun t : ℝ => (t+Real.sqrt ((t^2+t)/2))/2) := by fun_prop + have ht : Tendsto (fun t : ℝ => (t+Real.sqrt ((t^2+t)/2))/2) (𝓝[>] 0) (𝓝 0) := by + simpa using (hcont.tendsto 0).mono_left nhdsWithin_le_nhds + apply ht.congr' + filter_upwards [self_mem_nhdsWithin] with t (ht : 0 < t) + have hs := Real.sqrt_mul (sq_nonneg t) ((1-1/(-t))/2) + have he : t^2*((1-1/(-t))/2) = (t^2+t)/2 := by field_simp; ring + rw [he, Real.sqrt_sq ht.le] at hs + rw [fBranch, Real.sq_sqrt (by positivity : 0 ≤ (1+Real.sqrt ((1-1/(-t))/2))/2)] + linarith [hs] + +lemma tendsto_scaled_fBranch_zero : + Tendsto (fun t : ℝ => t * fBranch (-t)) (𝓝[>] 0) (𝓝 0) := by + have ht : Tendsto (fun t : ℝ => t) (𝓝[>] 0) (𝓝 0) := tendsto_id.mono_left nhdsWithin_le_nhds + have hs : Tendsto (fun t : ℝ => Real.sqrt (t*(t*fBranch (-t)^2))) (𝓝[>] 0) (𝓝 0) := by + simpa using (ht.mul tendsto_scaled_fBranch_sq_zero).sqrt + apply hs.congr' + filter_upwards [self_mem_nhdsWithin] with t (ht : 0 < t) + rw [show t*(t*fBranch (-t)^2) = (t*fBranch (-t))^2 by ring, + Real.sqrt_sq (mul_nonneg ht.le (by unfold fBranch; positivity))] + +lemma projectionF_sub_initial_limit (P J E : Polynomial ℝ) (hE : E.eval 0 = 0) : + Tendsto (fun t : ℝ => projectionF P J E (-t) - J.eval 0 * fBranch (-t)) + (𝓝[>] 0) (𝓝 (P.eval 0)) := by + have hdivJ : X ∣ J-Polynomial.C (J.eval 0) := X_dvd_iff.2 (by simp [coeff_zero_eq_eval_zero]) + have hdivE : X ∣ E := X_dvd_iff.2 (by simpa only [coeff_zero_eq_eval_zero] using hE) + obtain ⟨j, hj⟩ := hdivJ + obtain ⟨e, he⟩ := hdivE + have hJ : J = Polynomial.C (J.eval 0) + X*j := by linear_combination hj + have hp (p : Polynomial ℝ) : Tendsto (fun t : ℝ => p.eval (-t)) (𝓝[>] 0) (𝓝 (p.eval 0)) := by + simpa only [Function.comp_def, neg_zero] using + ((p.continuous.comp continuous_neg).tendsto 0).mono_left nhdsWithin_le_nhds + have hl := ((hp P).sub (tendsto_scaled_fBranch_zero.mul (hp j))).sub + (tendsto_scaled_fBranch_sq_zero.mul (hp e)) + simp only [zero_mul, sub_zero] at hl + convert hl using 1 + funext t + have hj' := congrArg (fun p : Polynomial ℝ => p.eval (-t)) hJ + simp only [eval_add, eval_C, eval_mul, eval_X] at hj' + simp only [projectionF, he, eval_mul, eval_X] + rw [hj'] + ring + +lemma defect_resolvent_limit (N : ℕ) : + Tendsto (fun t : ℝ => ∫ x in Ioo 0 1, momentIntegrand N x * (x/(x+t))) + (𝓝[>] 0) (𝓝 (∫ x in Ioo 0 1, momentIntegrand N x)) := by + apply tendsto_integral_filter_of_dominated_convergence (momentIntegrand N) + · exact Filter.Eventually.of_forall (fun t => ((measurable_momentIntegrand N).mul + (measurable_id.div (measurable_id.add_const t))).aestronglyMeasurable) + · filter_upwards [self_mem_nhdsWithin] with t (ht : 0 < t) + filter_upwards [ae_restrict_mem measurableSet_Ioo] with x hx + have hv := momentIntegrand_bounds N hx + have hb : 0 ≤ x/(x+t) ∧ x/(x+t) ≤ 1 := by + constructor + · exact div_nonneg hx.1.le (by linarith [hx.1]) + · exact (div_le_one (by linarith [hx.1])).mpr (by linarith) + rw [Real.norm_eq_abs, abs_of_nonneg (mul_nonneg hv.1 hb.1)] + exact mul_le_of_le_one_right hv.1 hb.2 + · exact integrableOn_momentIntegrand N + · filter_upwards [ae_restrict_mem measurableSet_Ioo] with x hx + have hl : Tendsto (fun t : ℝ => momentIntegrand N x * (x/(x+t))) (𝓝 0) + (𝓝 (momentIntegrand N x * (x/(x+0)))) := by + exact tendsto_const_nhds.mul (tendsto_const_nhds.div + (tendsto_const_nhds.add tendsto_id) (by simpa using ne_of_gt hx.1)) + simpa [hx.1.ne'] using hl.mono_left nhdsWithin_le_nhds + +lemma projectionF_sub_initial_integral (N : ℕ) (hN : 1 ≤ N) (g P J E : Polynomial ℝ) + (hP : P.natDegree ≤ N) (hJ : J.natDegree ≤ N) (hE : E.degree < (N : WithBot ℕ)) + (hQ : homogeneousQ N g = P.comp harmonicCoordinate + X * J.comp harmonicCoordinate + + X^2 * E.comp harmonicCoordinate) {t : ℝ} (ht : 0 < t) : + projectionF (tildePoly N P) (tildePoly N J) (tildePoly N E) (-t) - + (tildePoly N J).eval 0 * fBranch (-t) = + -(tildePoly N J).eval 0 * C - ((tildePoly N J).eval 0 / Real.pi) * + ∫ x in Ioo 0 1, momentIntegrand N x * (x/(x+t)) := by + let D₀ := (tildePoly N J).eval 0 + let D := projectionD (tildePoly N J) (tildePoly N E) + have hEn : E.natDegree ≤ N := (degree_lt_implies_natDegree_lt (by omega) hE).le + have hDecay : Tendsto (fun t : ℝ => projectionF (tildePoly N P) (tildePoly N J) (tildePoly N E) (-t)) + atTop (𝓝 0) := by + simpa only [pow_zero, one_mul, projectionF, fBranch, highBranch] using tilde_F_decay N g P J E hP hJ hEn hQ 0 (Nat.zero_le N) + have hF := projectionF_cauchy _ _ _ hDecay (-t) (neg_neg_of_pos ht) + have hD := projectionD_expectation N hN g P J E hP hJ hE hQ + have off : offCut 1 (-t) := by + intro x hx + simp only [one_mul] + linarith [hx.1] + have hωint := integrableOn_stieltjes integrableOn_omega off + have hDint := integrableOn_stieltjes (integrableOn_projection_weight (tildePoly N J) (tildePoly N E)) off + have hf := stieltjes_omega (neg_neg_of_pos ht) + change fBranch (-t) = C + (1/Real.pi) * ∫ x in Ioo 0 1, omega x / (x-(-t)) at hf + have hω : realStieltjes 1 omega (-t) = -(∫ x in Ioo 0 1, omega x/(x-(-t))) := by + rw [realStieltjes, ← integral_neg] + apply setIntegral_congr_fun measurableSet_Ioo + intro x _ + dsimp only + rw [one_mul, show -t-x = -(x-(-t)) by ring, div_neg] + have hsub : realStieltjes 1 (fun x => D x * omega x) (-t) - D₀ * realStieltjes 1 omega (-t) = + D₀ * ∫ x in Ioo 0 1, momentIntegrand N x * (x/(x+t)) := by + rw [realStieltjes, realStieltjes, ← integral_const_mul, ← integral_sub hDint (hωint.const_mul D₀), + ← integral_const_mul] + apply setIntegral_congr_fun measurableSet_Ioo + intro x hx + dsimp only + change (projectionD (tildePoly N J) (tildePoly N E) x * omega x) / (-t-1*x) - + D₀ * (omega x / (-t-1*x)) = D₀ * (momentIntegrand N x * (x/(x+t))) + rw [hD x hx.1] + change (D₀ * expectation N (reflectionProduct N x) * omega x)/(-t-1*x) - + D₀ * (omega x / (-t-1*x)) = D₀ * (momentIntegrand N x * (x/(x+t))) + unfold momentIntegrand + have had : x+t ≠ 0 := by linarith [hx.1] + have hab : -t-1*x = -(x+t) := by ring + rw [hab, div_neg, div_neg] + field_simp [hx.1.ne'] + ring + rw [hF, hf] + change _ = -D₀*C - (D₀/Real.pi) * _ + change -(1/Real.pi) * realStieltjes 1 (fun x => D x * omega x) (-t) - + D₀ * (C + 1/Real.pi * _) = _ + rw [eq_add_of_sub_eq hsub, hω] + ring + + + +lemma homogeneous_projection_integral_coefficient (N : ℕ) (hN : 1 ≤ N) (g P J E : Polynomial ℝ) + (hP : P.natDegree ≤ N) (hJ : J.natDegree ≤ N) (hE : E.degree < (N : WithBot ℕ)) + (hQ : homogeneousQ N g = P.comp harmonicCoordinate + X * J.comp harmonicCoordinate + + X^2 * E.comp harmonicCoordinate) : + (tildePoly N P).eval 0 = -(tildePoly N J).eval 0 * C - + ((tildePoly N J).eval 0 / Real.pi) * ∫ x in Ioo 0 1, momentIntegrand N x := by + have hlim := projectionF_sub_initial_limit (tildePoly N P) (tildePoly N J) (tildePoly N E) + (tildePoly_zero_of_degree_lt N hE) + have hint := (tendsto_const_nhds (x := -(tildePoly N J).eval 0*C)).sub ((defect_resolvent_limit N).const_mul ((tildePoly N J).eval 0 / Real.pi)) + apply tendsto_nhds_unique hlim + apply hint.congr' + filter_upwards [self_mem_nhdsWithin] with t (ht : 0 < t) + exact (projectionF_sub_initial_integral N hN g P J E hP hJ hE hQ ht).symm + +lemma eta_pos : 0 < eta := by + have hd : d = Real.sqrt 2 / 2 := by + rw [d, lambda, show 2*(Real.pi/8)=Real.pi/4 by ring, Real.cos_pi_div_four] + have hs : 1 < Real.sqrt 2 := by + simpa using Real.sqrt_lt_sqrt (by norm_num : (0:ℝ)≤1) (by norm_num : (1:ℝ)<2) + unfold eta + rw [hd] + linarith + +lemma C_eta_identity : C = eta*(2*C+c) := by + have ha := Real.cos_add (2*lambda) lambda + have hs := Real.cos_sub (2*lambda) lambda + rw [show 2*lambda+lambda=3*Real.pi/8 by unfold lambda; ring] at ha + rw [show 2*lambda-lambda=lambda by ring] at hs + change c = d*C - Real.sin (2*lambda)*Real.sin lambda at ha + change C = d*C + Real.sin (2*lambda)*Real.sin lambda at hs + have hc : c = (2*d-1)*C := by linarith + have hd : d = Real.sqrt 2 / 2 := by + rw [d, lambda, show 2*(Real.pi/8)=Real.pi/4 by ring, Real.cos_pi_div_four] + have hd2 : d^2 = 1/2 := by rw [hd]; nlinarith [Real.sq_sqrt (by norm_num : (0:ℝ)≤2)] + rw [eta, hc] + nlinarith [congrArg (fun x : ℝ => 2*C*x) hd2] + + + +theorem homogeneous_arch_coefficient_integral (N : ℕ) (hN : 1 ≤ N) + {g : Polynomial ℝ} (hg : MonicProblem N g) : + (N:ℝ)*C - eta*g.coeff (N-1) = + (eta/Real.pi)*∫ x in Ioo 0 1, momentIntegrand N x := by + obtain ⟨hgm, hgd, P, J, E, hP, hJ, hE, hQ⟩ := hg + have hcoeff := projection_top_coefficients N hN P J E hP hJ hE + dsimp only at hcoeff + rw [← hQ] at hcoeff + have hdeg := homogeneousQ_natDegree hgm hgd + have hfirst : 1 = (-8:ℝ)^N * (tildePoly N J).eval 0 := by + rw [← hcoeff.1, ← hdeg] + exact (homogeneousQ_monic hgm).coeff_natDegree.symm + have hsecond := hcoeff.2 + rw [homogeneousQ_nextCoeff N hN hgm hgd] at hsecond + have hint := homogeneous_projection_integral_coefficient N hN g P J E hP hJ hE hQ + have hbalance : g.coeff (N-1) = (N:ℝ)*(2*C+c) - + (∫ x in Ioo 0 1, momentIntegrand N x)/Real.pi := by + push_cast at hsecond + linear_combination hsecond + (-8:ℝ)^N * hint + + (C + (∫ x in Ioo 0 1, momentIntegrand N x)/Real.pi) * hfirst + linear_combination (N:ℝ)*C_eta_identity - eta*hbalance + + +theorem homogeneous_arch_coefficient_growth : + ∃ lo hi : ℝ, 0 < lo ∧ 0 < hi ∧ ∀ N : ℕ, 1 ≤ N → + ∀ g : Polynomial ℝ, MonicProblem N g → + lo*(N:ℝ)^(3/4:ℝ) ≤ (N:ℝ)*C - eta*g.coeff (N-1) ∧ + (N:ℝ)*C - eta*g.coeff (N-1) ≤ hi*(N:ℝ)^(3/4:ℝ) := by + obtain ⟨lo, hi, hl, hh, hbound⟩ := positive_arch_integral_growth + have hc : 0 < eta/Real.pi := div_pos eta_pos Real.pi_pos + refine ⟨(eta/Real.pi)*lo, (eta/Real.pi)*hi, mul_pos hc hl, mul_pos hc hh, ?_⟩ + intro N hN g hg + rw [homogeneous_arch_coefficient_integral N hN hg] + obtain ⟨h1, h2⟩ := hbound N hN + constructor + · simpa only [mul_assoc] using mul_le_mul_of_nonneg_left h1 hc.le + · simpa only [mul_assoc] using mul_le_mul_of_nonneg_left h2 hc.le + +end +end CriticalStrip + +end OAI diff --git a/lean/OAI/Combinatorics/StripMass/ResidualEvaluation.lean b/lean/OAI/Combinatorics/StripMass/ResidualEvaluation.lean new file mode 100644 index 0000000000000000000000000000000000000000..7f32d37667073dc4dcd44b162d79b35b25ea65e9 --- /dev/null +++ b/lean/OAI/Combinatorics/StripMass/ResidualEvaluation.lean @@ -0,0 +1,553 @@ +import Mathlib +import OAI.Combinatorics.StripMass.FirstFlatSpecialization + +namespace OAI + +/-! Critical honeycomb strip paths, polynomial identities and crossing mass. -/ + + + +namespace CriticalStrip.Diagram +noncomputable section +open scoped Classical + +lemma torusEvaluation_rowNumerator {n m:ℕ} (z:Fin n → SpectralField m) (hz:∀i,z i≠0) + (hL:∀i,torusL (constF m phase^3/z i)≠0) (i:Fin n) (t:Tile) : + torusEvaluation z hz (rowNumerator i t)=torusEvaluation z hz (rowDenominator i)* + (torusWeights (constF m phase^3/z i)).tile t := by + let φ:Laurent n →ₐ[ℂ] SpectralField m:=torusEvaluation z hz + have hn:=RationalAt.algebraMap (φ:=φ.toRingHom) (F:=SpectralField n) (rowNumerator i t) + rw [rowNumerator_map] at hn + apply hn.unique + apply (RationalAt.algebraMap (φ:=φ.toRingHom) (F:=SpectralField n) (rowDenominator i)).mul + apply rationalAt_torusWeights + · exact ((rationalAt_const φ phase).pow 3).div (rationalAt_variable z hz i) (hz i) + · exact div_ne_zero (pow_ne_zero _ (constF_phase_ne_zero m)) (hz i) + · exact hL i + +lemma torusEvaluation_residual {n m:ℕ} (W:Pairing n → Laurent n) + (z:Fin n → SpectralField m) (hz:∀i,z i≠0) + (hL:∀i,torusL (constF m phase^3/z i)≠0) (p:Pairing n) : + torusEvaluation z hz (laurentResidual W p)= + (∏i:Fin n,torusEvaluation z hz (rowDenominator i))* + ((column (fun i =>torusWeights (constF m phase^3/z i))).mulVec + (fun q =>torusEvaluation z hz (W q)) p-torusEvaluation z hz (W p)) := by + let φ:Laurent n →ₐ[ℂ] SpectralField m:=torusEvaluation z hz + have hm:(rawColumn (@rowNumerator n)).map φ.toRingHom= + (∏i:Fin n,φ (rowDenominator i)) • column (fun i =>torusWeights (constF m phase^3/z i)) := by + rw [rawColumn_map] + dsimp only [φ,AlgHom.toRingHom_eq_coe,AlgHom.coe_toRingHom] + simp_rw [torusEvaluation_rowNumerator z hz hL] + rw [rawColumn_scale] + rfl + unfold laurentResidual + rw [map_sub,map_mul,map_prod] + have he:φ ((rawColumn rowNumerator).mulVec W p)= + ((rawColumn rowNumerator).map φ.toRingHom).mulVec (fun q =>φ (W q)) p := by + simp only [Matrix.mulVec,dotProduct,map_sum,map_mul,Matrix.map_apply] + rfl + change φ ((rawColumn rowNumerator).mulVec W p)-_=_ + rw [he,hm,Matrix.smul_mulVec] + simp only [Pi.smul_apply,smul_eq_mul,mul_sub] + rfl + +lemma torusEvaluation_residual_zero {n m:ℕ} (W:Pairing n → Laurent n) + (z:Fin n → SpectralField m) (hz:∀i,z i≠0) + (hL:∀i,torusL (constF m phase^3/z i)≠0) + (hreg:VacuumRegular (fun i =>torusWeights (constF m phase^3/z i))) + (a:SpectralField m) + (hW:∀p,torusEvaluation z hz (W p)=a*normalizedVacuum (fun i =>torusWeights (constF m phase^3/z i)) p) + (p:Pairing n) : torusEvaluation z hz (laurentResidual W p)=0 := by + rw [torusEvaluation_residual W z hz hL] + have hv:(fun q =>torusEvaluation z hz (W q))=a • normalizedVacuum (fun i =>torusWeights (constF m phase^3/z i)):=funext hW + rw [hv,Matrix.mulVec_smul,(normalizedVacuum_stationary _ hreg).2] + simp only [Pi.smul_apply,smul_eq_mul,hW,sub_self,mul_zero] + + + + + + + +lemma permSpectral_rowDenominator {n:ℕ} (σ:Equiv.Perm (Fin n)) (i:Fin n) : + permSpectral σ (evalLaurent (rowDenominator i))=evalLaurent (rowDenominator (σ i)) := by + unfold evalLaurent + rw [rowDenominator_map,rowDenominator_map,permSpectral_torusL,map_div₀,map_pow,permSpectral_const,permSpectral_variable] + +lemma permSpectral_rowProduct {n:ℕ} (σ:Equiv.Perm (Fin n)) : + permSpectral σ (∏i:Fin n,evalLaurent (rowDenominator i))=∏i:Fin n,evalLaurent (rowDenominator i) := by + rw [map_prod]; simp_rw [permSpectral_rowDenominator] + exact Equiv.prod_comp σ (fun i:Fin n => (evalLaurent (rowDenominator i):SpectralField n)) + +lemma permSpectral_column_map {n:ℕ} (σ:Equiv.Perm (Fin n)) : + (column (spectralWeights n)).map (permSpectral σ)=column (fun i =>spectralWeights n (σ i)) := by + rw [column_map] + congr 1 + funext i + exact permSpectral_spectralWeights σ i + +lemma spectral_column_exchange {n:ℕ} (r:ℕ) (hr:r+2≤n) : + column (spectralWeights n)*localR (PartialColumn.rowPosition r hr) + (torusWeights (variableF ⟨r+1,by omega⟩/variableF ⟨r,by omega⟩))= + localR (PartialColumn.rowPosition r hr) + (torusWeights (variableF ⟨r+1,by omega⟩/variableF ⟨r,by omega⟩))* + (column (spectralWeights n)).map (permSpectral (Equiv.swap ⟨r,by omega⟩ ⟨r+1,by omega⟩)) := by + rw [permSpectral_column_map] + apply PartialColumn.torus_column_exchange r hr (fun i =>constF n phase^3/variableF i) + · exact div_ne_zero (variableF_ne_zero _) (variableF_ne_zero _) + · exact div_ne_zero (pow_ne_zero _ (constF_phase_ne_zero _)) (variableF_ne_zero _) + · exact torusL_ratio_ne_zero _ _ + · rw [←rowDenominator_map]; exact rowDenominator_map_ne_zero _ + · rw [←rowDenominator_map]; exact rowDenominator_map_ne_zero _ + · field_simp [variableF_ne_zero] + +lemma matrix_residual_covariance {K:Type*} [CommRing K] {ι:Type*} [Fintype ι] + (T R S:Matrix ι ι K) (v w:ι → K) (D:K) + (hv:v=R.mulVec w) (hTR:T*R=R*S) : + (fun p =>D*(T.mulVec v p-v p))=R.mulVec (fun p =>D*(S.mulVec w p-w p)) := by + have h1:T.mulVec v=R.mulVec (S.mulVec w) := by + rw [hv,Matrix.mulVec_mulVec,hTR,←Matrix.mulVec_mulVec] + rw [h1,hv] + change D • (R.mulVec (S.mulVec w)-R.mulVec w)=R.mulVec (D • (S.mulVec w-w)) + rw [Matrix.mulVec_smul,Matrix.mulVec_sub] + + +theorem rationalInterpolationResidual_covariance {n:ℕ} (r:ℕ) (hr:r+2≤n) : + rationalInterpolationResidual n= + (localR (PartialColumn.rowPosition r hr).padTop + (torusWeights (variableF (⟨r+1,by omega⟩:Fin n).castSucc / variableF (⟨r,by omega⟩:Fin n).castSucc))).mulVec + (fun p =>permSpectral (topPerm (Equiv.swap (⟨r,by omega⟩:Fin n) ⟨r+1,by omega⟩)) (rationalInterpolationResidual n p)) := by + let σ:=topPerm (Equiv.swap (⟨r,by omega⟩:Fin n) ⟨r+1,by omega⟩) + let R:=localR (PartialColumn.rowPosition r hr).padTop + (torusWeights (variableF (⟨r+1,by omega⟩:Fin n).castSucc / variableF (⟨r,by omega⟩:Fin n).castSucc)) + have he: column (spectralWeights (n+1))*R=R*(column (spectralWeights (n+1))).map (permSpectral σ) := by + simpa only [R,σ,topPerm_swap,PartialColumn.rowPosition,Position.padTop,Fin.castSucc_mk] using + spectral_column_exchange (n:=n+1) r (by omega) + have hmap: (fun p =>permSpectral σ (rationalInterpolationResidual n p))= + fun p =>(∏i:Fin (n+1),evalLaurent (rowDenominator i))* + (((column (spectralWeights (n+1))).map (permSpectral σ)).mulVec + (fun q =>permSpectral σ (rationalInterpolant n q)) p-permSpectral σ (rationalInterpolant n p)) := by + funext p + simp only [rationalInterpolationResidual,map_mul,map_sub,permSpectral_rowProduct, + Matrix.mulVec,dotProduct,map_sum,Matrix.map_apply] + rw [hmap] + exact matrix_residual_covariance _ _ _ _ _ _ (rationalInterpolant_covariance r hr) he + + + + + + + +lemma torusEvaluation_permLaurent {n m:ℕ} (σ:Equiv.Perm (Fin n)) + (z:Fin n → SpectralField m) (hz:∀i,z i≠0) (f:Laurent n) : + torusEvaluation z hz (permLaurent σ f)= + torusEvaluation (z ∘ σ) (fun i =>hz (σ i)) f := by + have he:(torusEvaluation z hz).toRingHom.comp (permLaurent σ)= + (torusEvaluation (z ∘ σ) (fun i =>hz (σ i))).toRingHom := by + apply AddMonoidAlgebra.ringHom_ext + · intro c + change torusEvaluation z hz (permLaurent σ (monomialL 0 c))= + torusEvaluation (z ∘ σ) _ (monomialL 0 c) + simp only [permLaurent_monomial,torusEvaluation_monomial, + Function.comp_apply,Pi.zero_apply,zpow_zero, + Finset.prod_const_one,mul_one] + · intro e + change torusEvaluation z hz (permLaurent σ (monomialL e 1))= + torusEvaluation (z ∘ σ) _ (monomialL e 1) + rw [permLaurent_monomial,torusEvaluation_monomial,torusEvaluation_monomial] + congr 1 + simpa only [permExponent,AddMonoidHom.coe_mk,ZeroHom.coe_mk,Function.comp_apply,Equiv.symm_apply_apply] using + (Equiv.prod_comp σ (fun i =>z i ^ (e ∘ σ.symm) i)).symm + exact DFunLike.congr_fun he f + +lemma rationalAt_localR {n k l:ℕ} (φ:Laurent k →ₐ[ℂ] SpectralField l) + (a:Position n) (w:Weights (SpectralField k)) (v:Weights (SpectralField l)) + (h:∀t,RationalAt φ.toRingHom (w.tile t) (v.tile t)) (p q:Pairing n) : + RationalAt φ.toRingHom (localR a w p q) (localR a v p q) := by + simp only [localR,Matrix.sum_apply,Matrix.smul_apply,smul_eq_mul] + apply RationalAt.sum + intro t _ + apply (h t).mul + unfold optionMatrix + split_ifs + · exact RationalAt.one + · exact RationalAt.zero + + + +theorem residual_zero_transport {n m:ℕ} + (P:Pairing (n+1) → Polynomial (Laurent n)) + (hP:∀p,(P p).map (algebraMap (SpectralRing n) (SpectralField n))=rationalNodalPolynomial n p) + (r:ℕ) (hr:r+2≤n) (z:Fin (n+1) → SpectralField m) (hz:∀i,z i≠0) + (hL:torusL (z (⟨r+1,by omega⟩:Fin n).castSucc/z (⟨r,by omega⟩:Fin n).castSucc)≠0) + (hzero:∀p,torusEvaluation + (z ∘ topPerm (Equiv.swap (⟨r,by omega⟩:Fin n) ⟨r+1,by omega⟩)) + (fun i =>hz _) (laurentResidual (fun p =>lastLaurent p (P p)) p)=0) + (p:Pairing (n+1)) : + torusEvaluation z hz (laurentResidual (fun p =>lastLaurent p (P p)) p)=0 := by + let σ:=topPerm (Equiv.swap (⟨r,by omega⟩:Fin n) ⟨r+1,by omega⟩) + let φ:=torusEvaluation z hz + let a:=(PartialColumn.rowPosition r hr).padTop + let w:=torusWeights (variableF (⟨r+1,by omega⟩:Fin n).castSucc/variableF (⟨r,by omega⟩:Fin n).castSucc) + let v:=torusWeights (z (⟨r+1,by omega⟩:Fin n).castSucc/z (⟨r,by omega⟩:Fin n).castSucc) + have hw:∀t,RationalAt φ.toRingHom (w.tile t) (v.tile t) := + rationalAt_torusWeights φ ((rationalAt_variable z hz _).div (rationalAt_variable z hz _) (hz _)) + (div_ne_zero (hz _) (hz _)) hL + have hv (q:Pairing (n+1)):RationalAt φ.toRingHom (permSpectral σ (rationalInterpolationResidual n q)) 0 := by + have h:=RationalAt.algebraMap (φ:=φ.toRingHom) (F:=SpectralField (n+1)) + (permLaurent σ (laurentResidual (fun p =>lastLaurent p (P p)) q)) + change RationalAt φ.toRingHom (evalLaurent _) _ at h + rw [←permSpectral_evalLaurent,laurentResidual_map P hP] at h + change RationalAt φ.toRingHom _ (torusEvaluation z hz _) at h + rw [torusEvaluation_permLaurent] at h + exact (hzero q) ▸ h + have hright:=RationalAt.mulVec (φ:=φ.toRingHom) (localR a w) (localR a v) + (fun q =>permSpectral σ (rationalInterpolationResidual n q)) (0:Pairing (n+1) → SpectralField m) + (rationalAt_localR φ a w v hw) hv p + have he:=congrFun (rationalInterpolationResidual_covariance r hr) p + change rationalInterpolationResidual n p=(localR a w).mulVec _ p at he + rw [←he,Matrix.mulVec_zero] at hright + have hleft:=RationalAt.algebraMap (φ:=φ.toRingHom) (F:=SpectralField (n+1)) + (laurentResidual (fun p =>lastLaurent p (P p)) p) + change RationalAt φ.toRingHom (evalLaurent _) _ at hleft + rw [laurentResidual_map P hP] at hleft + exact hleft.unique hright + + + + + + + +lemma firstZeroRaw_smul {K:Type*} [CommRing K] {n:ℕ} + (w:Fin n → Tile → K) (a:K) (v:Pairing n → K) : + firstZeroRaw w (a • v)=a • firstZeroRaw w v := by + have he:vacantBottomExtension (a • v)=a • vacantBottomExtension v := by + funext p + by_cases hp:p.Occupied 0 <;> simp [vacantBottomExtension,hp,Pi.smul_apply] + rw [firstZeroRaw,he,Matrix.mulVec_smul] + rfl + +lemma rationalAt_firstFlat_weights {n:ℕ} (i:Fin (n+1)) (t:Tile) : + RationalAt (firstFlatEvaluation n).toRingHom ((spectralWeights (n+1) i).tile t) + (((Fin.cons deletionWeights (spectralWeights n) : Fin (n+1) → Weights (SpectralField n)) i).tile t) := by + induction i using Fin.cases with + | zero => + have hz:=rationalAt_firstFlat_variable (0:Fin (n+1)) + simp only [firstFlatPoint,Fin.cons_zero] at hz + have h:=rationalAt_torusWeights (firstFlatEvaluation n) + (((rationalAt_const _ phase).pow 3).div hz one_ne_zero) + (by simpa using pow_ne_zero 3 (constF_phase_ne_zero n)) + (by rw [div_one,torusL_phase_three]; simpa only [torusL_one] using torusL_one_ne_zero n) t + simpa only [spectralWeights,Fin.cons_zero,div_one,torusWeights_phase_three] using h + | succ i => + have hz:=rationalAt_firstFlat_variable i.succ + simp only [firstFlatPoint,Fin.cons_succ] at hz + exact rationalAt_torusWeights (firstFlatEvaluation n) + (((rationalAt_const _ phase).pow 3).div hz (variableF_ne_zero i)) + (div_ne_zero (pow_ne_zero _ (constF_phase_ne_zero n)) (variableF_ne_zero i)) + (by rw [←rowDenominator_map]; exact rowDenominator_map_ne_zero i) t + +lemma rationalAt_firstFlat_normalization (n:ℕ) : + RationalAt (firstFlatEvaluation n).toRingHom (spectralNormalization (n+1)) + ((∏ j : Fin n, (spectralA j+constF n C))*spectralNormalization n) := by + have h:=RationalAt.mv_eval (algebraMap ℂ (SpectralField (n+1))) + (algebraMap ℂ (SpectralField n)) spectralA (Fin.cons (constF n c) spectralA) + (rationalAt_const (firstFlatEvaluation n)) rationalAt_firstFlat_spectralA + (scalarPolynomial (n+1) d rho (by exact_mod_cast d_ne_zero)) + simp only [constF] at h + rw [scalarPolynomial_eval_spectral,source_scalarPolynomial_flat,scalarPolynomial_eval_spectral] at h + exact h + +lemma rationalAt_firstFlat_vacuum {n:ℕ} (p:Pairing (n+1)) : + RationalAt (firstFlatEvaluation n).toRingHom (rationalVacuum (n+1) p) + ((∏ j : Fin n, (spectralA j+constF n C))* + firstZeroRaw (fun j => (spectralWeights n j).tile) (rationalVacuum n) p) := by + have hr:VacuumRegular (Fin.cons deletionWeights (spectralWeights n)) := by + unfold VacuumRegular + rw [det_flat_bottom _ (Or.inr rfl)] + exact spectral_regular n + have h:=rationalAt_normalizedVacuum _ _ rationalAt_firstFlat_weights hr p + rw [normalizedVacuum_firstZero _ (spectral_regular n)] at h + have he:= (rationalAt_firstFlat_normalization n).mul h + have hs:rationalVacuum n=spectralNormalization n • normalizedVacuum (spectralWeights n) := rfl + rw [hs,firstZeroRaw_smul] + simpa only [rationalVacuum,Pi.smul_apply,smul_eq_mul,mul_assoc] using he + +lemma deletionBeta_ne_const {n:ℕ} (i:Fin n) (z:ℂ) : deletionBeta i≠constF n z := by + intro h + have hc:evalLaurent (constantL n z)=constF n z := map_constantL _ _ + rw [←betaL_map,←hc] at h + have he:betaL i=constantL n z := IsFractionRing.injective _ _ h + have ht:(2:ℤ) • variableExponent i≠0 := by + intro hh + have hi:=congrFun hh i + simp [variableExponent] at hi + change betaL i=monomialL 0 z at he + have hh:=congrArg (fun P:Laurent n => P.coeff ((2:ℤ) • variableExponent i)) he + simp only [betaL,cosineL,monomialL,AddMonoidAlgebra.coeff_add, + AddMonoidAlgebra.coeff_single,Finsupp.add_apply,Finsupp.single_apply] at hh + simp only [ite_eq_right (twice_variableExponent_ne_neg i i).symm, + ite_eq_right ht.symm,add_zero] at hh + exact (pow_ne_zero 3 phase_ne_zero) ((div_eq_zero_iff).mp hh |>.resolve_right (by norm_num)) + +lemma firstFlatBeta_injective (n:ℕ) : + Function.Injective (Fin.cons (constF n c) deletionBeta : Fin (n+1) → SpectralField n) := by + intro i j h + induction i using Fin.cases with + | zero => + induction j using Fin.cases with + | zero => rfl + | succ j => exact (deletionBeta_ne_const j c (by simpa using h.symm)).elim + | succ i => + induction j using Fin.cases with + | zero => exact (deletionBeta_ne_const i c (by simpa using h)).elim + | succ j => exact congrArg Fin.succ (deletionBeta_injective n (by simpa using h)) + +lemma firstFlatNode_sine_ne_zero {n:ℕ} (i:Fin (n+1)) : + torusSin ((Fin.cons (constF n phase^3) deletionNode : Fin (n+1) → SpectralField n) i)≠0 := by + induction i using Fin.cases with + | zero => + simp only [Fin.cons_zero,torusSin_phase_pow] + apply (map_ne_zero (algebraMap ℂ (SpectralField n))).mpr + exact_mod_cast ne_of_gt sin_three_lambda_pos + | succ i => exact deletionNode_sine_ne_zero i + + + + + + + +lemma torus_firstZero_lastValue {n k:ℕ} (w:Fin n → Weights (SpectralField k)) + (z:SpectralField k) (hz:z≠0) (hL:torusL (constF k phase^3/z)≠0) + (P:Pairing (n+1) → Polynomial (SpectralField k)) : + (torusCos (z^2/constF k phase^3)+constF k C) • + firstZeroRaw (fun i => ((Fin.snoc w (torusWeights (constF k phase^3/z)) : + Fin (n+1) → Weights (SpectralField k)) i).tile) + (lastValue (RingHom.id _) (torusCos (z^2/constF k phase^3)) (torusSin z) P)= + lastValue (RingHom.id _) (torusCos (z^2/constF k phase^3)) (torusSin z) + (firstZeroPolynomial (fun i => (w i).tile) (constF k d) (constF k c) (constF k C) P) := by + have h:=torus_last_cleared z hz hL + have he:=firstZeroPolynomial_evaluation (RingHom.id _) (fun i => (w i).tile) + (constF k d) (constF k c) (constF k C) + (torusCos (z^2/constF k phase^3)) (torusSin z) (torusSin (constF k phase^3/z)) + (fun t => (torusCos (z^2/constF k phase^3)+constF k C)* + (torusWeights (constF k phase^3/z)).tile t) P h.1 h.2.1 h.2.2.1 h.2.2.2 + (torus_sine_pair z hz) + have hrow : Fin.snoc (fun i t => (RingHom.id (SpectralField k)) ((w i).tile t)) + (fun t => (torusCos (z^2/constF k phase^3)+constF k C)* + (torusWeights (constF k phase^3/z)).tile t)= + fun i t => (Fin.snoc (fun _ => 1) (torusCos (z^2/constF k phase^3)+constF k C) : + Fin (n+1) → SpectralField k) i * + ((Fin.snoc w (torusWeights (constF k phase^3/z)) : Fin (n+1) → Weights (SpectralField k)) i).tile t := by + funext i t + induction i using Fin.lastCases <;> simp + rw [hrow,firstZeroRaw_rowScale] at he + simpa only [Fin.prod_univ_castSucc,Fin.snoc_castSucc,Fin.snoc_last,Finset.prod_const_one,one_mul] using he + +lemma rationalAt_last_normalization {n:ℕ} (z:SpectralField n) (hz:z≠0) : + RationalAt (lastEvaluation z hz).toRingHom (spectralNormalization (n+1)) + (MvPolynomial.eval₂Hom (algebraMap ℂ (SpectralField n)) + (Fin.snoc spectralA (torusCos (z^2/constF n phase^3))) + (scalarPolynomial (n+1) d rho (by exact_mod_cast d_ne_zero))) := by + have h:=RationalAt.mv_eval (algebraMap ℂ (SpectralField (n+1))) + (algebraMap ℂ (SpectralField n)) spectralA + (Fin.snoc spectralA (torusCos (z^2/constF n phase^3))) + (rationalAt_const (lastEvaluation z hz)) + (fun i => by + induction i using Fin.lastCases with + | last => simpa only [Fin.snoc_last] using rationalAt_last_spectralA z hz + | cast i => simpa only [Fin.snoc_castSucc,liftSpectral_spectralA] using + rationalAt_last_lift z hz (spectralA i)) + (scalarPolynomial (n+1) d rho (by exact_mod_cast d_ne_zero)) + rwa [scalarPolynomial_eval_spectral] at h + +lemma rationalAt_last_vacuum {n:ℕ} (z:SpectralField n) (hz:z≠0) + (hL:torusL (constF n phase^3/z)≠0) + (hr:VacuumRegular (Fin.snoc (spectralWeights n) (torusWeights (constF n phase^3/z)))) + (p:Pairing (n+1)) : + RationalAt (lastEvaluation z hz).toRingHom (rationalVacuum (n+1) p) + ((MvPolynomial.eval₂Hom (algebraMap ℂ (SpectralField n)) + (Fin.snoc spectralA (torusCos (z^2/constF n phase^3))) + (scalarPolynomial (n+1) d rho (by exact_mod_cast d_ne_zero)))* + normalizedVacuum (Fin.snoc (spectralWeights n) (torusWeights (constF n phase^3/z))) p) := + (rationalAt_last_normalization z hz).mul + (rationalAt_normalizedVacuum _ _ (rationalAt_last_weights z hz hL) hr p) + + + +lemma firstFlat_smaller_values {n:ℕ} + (hprev:∀ p,rationalInterpolant n p=rationalVacuum (n+1) p) + (i:Fin (n+1)) (p:Pairing (n+1)) : + lastValue (RingHom.id _) + ((Fin.cons (constF n c) deletionBeta : Fin (n+1) → SpectralField n) i) + (torusSin ((Fin.cons (constF n phase^3) deletionNode : Fin (n+1) → SpectralField n) i)) + (rationalNodalPolynomial n) p= + firstFlatSmallerScalar n i * normalizedVacuum (firstFlatSmallerWeights n i) p := by + induction i using Fin.cases with + | succ i => + simp only [Fin.cons_succ,firstFlatSmallerScalar,firstFlatSmallerWeights] + simpa only [lastValue,Polynomial.eval₂_id,nodalVacuum,ite_mul,one_mul] using rationalNodalPolynomial_at_node p i + | zero => + have hz:constF n phase^3≠0:=pow_ne_zero _ (constF_phase_ne_zero n) + have hdiv:constF n phase^3/(constF n phase^3)=1:=div_self hz + have hcos:torusCos ((constF n phase^3)^2/constF n phase^3)=constF n c := by + rw [pow_two,mul_div_cancel_right₀ _ hz,torusCos_phase_pow] + rfl + have hr:VacuumRegular (Fin.snoc (spectralWeights n) (torusWeights (constF n phase^3/(constF n phase^3)))) := by + rw [hdiv,torusWeights_one] + exact firstFlatSmaller_regular n 0 + have h:=rationalAt_last_vacuum (constF n phase^3) hz + (by rw [hdiv]; exact torusL_one_ne_zero n) hr p + have he:=rationalAt_last_interpolant (constF n phase^3) hz p + rw [hprev p] at he + have heq:=he.unique h + rw [hcos,hdiv,torusWeights_one] at heq + simp only [constF] at heq + rw [scalarPolynomial_eval_snoc_flat,scalarPolynomial_eval_spectral] at heq + simpa only [firstFlatSmallerScalar,firstFlatSmallerWeights,Fin.cons_zero,constF] using heq + + + + + + + +lemma firstFlatNode_ne_zero {n:ℕ} (i:Fin (n+1)) : + (Fin.cons (constF n phase^3) deletionNode : Fin (n+1) → SpectralField n) i≠0 := by + induction i using Fin.cases with + | zero => exact pow_ne_zero _ (constF_phase_ne_zero n) + | succ i => exact mul_ne_zero (variableF_ne_zero i) (pow_ne_zero _ (constF_phase_ne_zero n)) + +lemma firstFlatNode_cosine {n:ℕ} (i:Fin (n+1)) : + torusCos (((Fin.cons (constF n phase^3) deletionNode : Fin (n+1) → SpectralField n) i)^2/ + constF n phase^3)=((Fin.cons (constF n c) deletionBeta : Fin (n+1) → SpectralField n) i) := by + induction i using Fin.cases with + | zero => + simp only [Fin.cons_zero,pow_two,mul_div_cancel_right₀ _ (pow_ne_zero _ (constF_phase_ne_zero n)),torusCos_phase_pow] + rfl + | succ i => rfl + +lemma firstFlatNode_L {n:ℕ} (i:Fin (n+1)) : + torusL (constF n phase^3 / ((Fin.cons (constF n phase^3) deletionNode : Fin (n+1) → SpectralField n) i))≠0 := by + induction i using Fin.cases with + | zero => + rw [Fin.cons_zero,div_self (pow_ne_zero _ (constF_phase_ne_zero n))] + exact torusL_one_ne_zero n + | succ i => + have ha:constF n phase^3/deletionNode i=(variableF i)⁻¹ := by + unfold deletionNode; field_simp [constF_phase_ne_zero] + rw [Fin.cons_succ,ha,←inverseRowDenominator_map] + exact inverseRowDenominator_map_ne_zero i + +lemma firstFlatNode_weights {n:ℕ} (i:Fin (n+1)) : + Fin.snoc (spectralWeights n) (torusWeights (constF n phase^3 / + ((Fin.cons (constF n phase^3) deletionNode : Fin (n+1) → SpectralField n) i)))= + firstFlatSmallerWeights n i := by + induction i using Fin.cases with + | zero => + simp only [Fin.cons_zero,div_self (pow_ne_zero _ (constF_phase_ne_zero n)), + torusWeights_one,firstFlatSmallerWeights] + | succ i => rfl + +lemma firstZeroPolynomial_flatNode {n:ℕ} + (hprev:∀ p,rationalInterpolant n p=rationalVacuum (n+1) p) + (i:Fin (n+1)) (p:Pairing (n+2)) : + lastValue (RingHom.id _) + ((Fin.cons (constF n c) deletionBeta : Fin (n+1) → SpectralField n) i) + (torusSin ((Fin.cons (constF n phase^3) deletionNode : Fin (n+1) → SpectralField n) i)) + (firstZeroPolynomial (fun j => (spectralWeights n j).tile) + (constF n d) (constF n c) (constF n C) (rationalNodalPolynomial n)) p = + (((Fin.cons (constF n c) deletionBeta : Fin (n+1) → SpectralField n) i)+constF n C)* + firstFlatSmallerScalar n i * firstZeroRaw (fun j => (firstFlatSmallerWeights n i j).tile) + (normalizedVacuum (firstFlatSmallerWeights n i)) p := by + have h:=torus_firstZero_lastValue (spectralWeights n) + ((Fin.cons (constF n phase^3) deletionNode : Fin (n+1) → SpectralField n) i) + (firstFlatNode_ne_zero i) (firstFlatNode_L i) (rationalNodalPolynomial n) + rw [firstFlatNode_cosine,firstFlatNode_weights] at h + have hi: lastValue (RingHom.id _) + ((Fin.cons (constF n c) deletionBeta : Fin (n+1) → SpectralField n) i) + (torusSin ((Fin.cons (constF n phase^3) deletionNode : Fin (n+1) → SpectralField n) i)) + (rationalNodalPolynomial n)= + firstFlatSmallerScalar n i • normalizedVacuum (firstFlatSmallerWeights n i) := by + funext q + exact firstFlat_smaller_values hprev i q + rw [hi,firstZeroRaw_smul] at h + have he:=congrFun h p + simpa only [Pi.smul_apply,smul_eq_mul,mul_assoc] using he.symm + + + +theorem rationalNodalPolynomial_firstFlat {n:ℕ} + (hprev:∀ p,rationalInterpolant n p=rationalVacuum (n+1) p) + (P:Pairing (n+2) → Polynomial (Laurent (n+1))) + (hP:∀ p,(P p).map (algebraMap (SpectralRing (n+1)) (SpectralField (n+1)))= + rationalNodalPolynomial (n+1) p) : + (fun p => (P p).map (firstFlatEvaluation n).toRingHom)= + fun p => Polynomial.C (∏ j:Fin n,(spectralA j+constF n C))* + firstZeroPolynomial (fun j => (spectralWeights n j).tile) + (constF n d) (constF n c) (constF n C) (rationalNodalPolynomial n) p := by + have hdeg:LastDegree (n+1) P := + LastDegree.of_map (algebraMap (SpectralRing (n+1)) (SpectralField (n+1))) + (IsFractionRing.injective _ _) + (by simpa only [hP] using rationalNodalPolynomial_degree (n+1)) + have hrightdeg:LastDegree (n+1) (fun p => Polynomial.C (∏ j:Fin n,(spectralA j+constF n C))* + firstZeroPolynomial (fun j => (spectralWeights n j).tile) + (constF n d) (constF n c) (constF n C) (rationalNodalPolynomial n) p) := by + intro p k hk + rw [Polynomial.coeff_C_mul,firstZeroPolynomial_degree _ _ _ _ _ (rationalNodalPolynomial_degree n) p k hk,mul_zero] + apply lastPolynomial_unique _ _ (hdeg.map _) hrightdeg _ (firstFlatBeta_injective n) + · intro p + rw [Polynomial.coeff_map,Polynomial.coeff_C_mul, + firstZeroPolynomial_leading _ _ _ _ _ (rationalNodalPolynomial_degree n)] + have hh: (fun q:Pairing n => (rationalNodalPolynomial n q.padTop).coeff n)=rationalVacuum n := by + funext q; exact rationalNodalPolynomial_leading q + rw [hh] + have ha:=RationalAt.algebraMap (φ:=(firstFlatEvaluation n).toRingHom) + (F:=SpectralField (n+1)) ((P p.padTop).coeff (n+1)) + have hb:=congrArg (fun Q:Polynomial (SpectralField (n+1)) => Q.coeff (n+1)) (hP p.padTop) + rw [Polynomial.coeff_map,rationalNodalPolynomial_leading] at hb + rw [hb] at ha + exact ha.unique (rationalAt_firstFlat_vacuum p) + · intro p i + have hz:=firstFlatNode_ne_zero i + have hs:=rationalAt_torusSin (firstFlatEvaluation n) (rationalAt_firstFlat_deletionNode i) hz + have he: RationalAt (firstFlatEvaluation n).toRingHom + ((rationalNodalPolynomial (n+1) p).eval (deletionBeta i)) + (((P p).map (firstFlatEvaluation n).toRingHom).eval + ((Fin.cons (constF n c) deletionBeta : Fin (n+1) → SpectralField n) i)) := by + rw [←hP] + exact RationalAt.eval_map _ (rationalAt_firstFlat_deletionBeta i) _ + have hsin:RationalAt (firstFlatEvaluation n).toRingHom + (if p.Occupied (Fin.last (n+1)) then torusSin (deletionNode i) else 1) + (if p.Occupied (Fin.last (n+1)) then torusSin + ((Fin.cons (constF n phase^3) deletionNode : Fin (n+1) → SpectralField n) i) else 1) := by + split_ifs + · exact hs + · exact RationalAt.one + have hb:=hsin.mul he + rw [rationalNodalPolynomial_at_node] at hb + have hv:=hb.unique (rationalAt_firstFlat_nodalVacuum i p) + have hright:=firstZeroPolynomial_flatNode hprev i p + apply mul_left_cancel₀ (show (if p.Occupied (Fin.last (n+1)) then torusSin + ((Fin.cons (constF n phase^3) deletionNode : Fin (n+1) → SpectralField n) i) else 1)≠0 by + split_ifs; exact firstFlatNode_sine_ne_zero i; exact one_ne_zero) + rw [hv,Polynomial.eval_mul,Polynomial.eval_C] + have hr: (if p.Occupied (Fin.last (n+1)) then torusSin + ((Fin.cons (constF n phase^3) deletionNode : Fin (n+1) → SpectralField n) i) else 1)* + (firstZeroPolynomial (fun j => (spectralWeights n j).tile) + (constF n d) (constF n c) (constF n C) (rationalNodalPolynomial n) p).eval + ((Fin.cons (constF n c) deletionBeta : Fin (n+1) → SpectralField n) i)= + (((Fin.cons (constF n c) deletionBeta : Fin (n+1) → SpectralField n) i)+constF n C)* + firstFlatSmallerScalar n i * firstZeroRaw (fun j => (firstFlatSmallerWeights n i j).tile) + (normalizedVacuum (firstFlatSmallerWeights n i)) p := by + simpa only [lastValue,Polynomial.eval₂_id,ite_mul,one_mul] using hright + rw [mul_left_comm,hr] + ring + +end +end CriticalStrip.Diagram + +end OAI diff --git a/lean/OAI/Combinatorics/StripMass/ResidualParityCoefficients.lean b/lean/OAI/Combinatorics/StripMass/ResidualParityCoefficients.lean new file mode 100644 index 0000000000000000000000000000000000000000..c18587358e83288b0f16573275a05acd80b201f3 --- /dev/null +++ b/lean/OAI/Combinatorics/StripMass/ResidualParityCoefficients.lean @@ -0,0 +1,572 @@ +import Mathlib +import OAI.Combinatorics.StripMass.MergePairCandidate + +namespace OAI + +/-! Critical honeycomb strip paths, polynomial identities and crossing mass. -/ + + + +namespace CriticalStrip.Diagram +noncomputable section +open scoped Classical LaurentPolynomial + +lemma signLaurent_coeff {n:ℕ} (i:Fin n) (f:Laurent n) (e:Fin n → ℤ) : + (signLaurent i f).coeff e=f.coeff e*(-1:ℂ)^(e i) := by + induction f using AddMonoidAlgebra.induction_linear with + | zero => simp + | add f g hf hg => simp only [map_add,AddMonoidAlgebra.coeff_add,Finsupp.add_apply,hf,hg]; ring + | single a b => + change (signLaurent i (monomialL a b)).coeff e=_ + rw [signLaurent_monomial] + simp only [monomialL,AddMonoidAlgebra.coeff_single,Finsupp.single_apply] + split_ifs with h + · subst e; rfl + · simp + +lemma signLaurent_odd_even_coeff_zero {n:ℕ} (i:Fin n) (f:Laurent n) + (h:signLaurent i f= -f) (e:Fin n → ℤ) (he:Even (e i)) : f.coeff e=0 := by + have hh:=congrArg (fun g:Laurent n => g.coeff e) h + rw [signLaurent_coeff,he.neg_one_zpow,mul_one,AddMonoidAlgebra.coeff_neg] at hh + change f.coeff e= -f.coeff e at hh + linear_combination (1/2:ℂ)*hh + +lemma laurentResidual_odd {n:ℕ} + (P:Pairing (n+1) → Polynomial (Laurent n)) + (hP:∀p,(P p).map (algebraMap (SpectralRing n) (SpectralField n))=rationalNodalPolynomial n p) + (i:Fin n) (p:Pairing (n+1)) (hp:p.Occupied i.castSucc) : + signLaurent i.castSucc (laurentResidual (fun q =>lastLaurent q (P q)) p)= + -laurentResidual (fun q =>lastLaurent q (P q)) p := by + apply IsFractionRing.injective (SpectralRing (n+1)) (SpectralField (n+1)) + change evalLaurent _=evalLaurent _ + rw [←signSpectral_evalLaurent,laurentResidual_map P hP,rationalInterpolationResidual_parity] + simp only [occupancySign,hp,ite_true,neg_one_mul,evalLaurent,map_neg] + congr 1 + exact (laurentResidual_map P hP p).symm + +lemma laurentResidual_peel_top_zero {n:ℕ} + (P:Pairing (n+1) → Polynomial (Laurent n)) + (hP:∀p,(P p).map (algebraMap (SpectralRing n) (SpectralField n))=rationalNodalPolynomial n p) + (i:Fin n) (p:Pairing (n+1)) (hp:p.Occupied i.castSucc) : + (peelLaurent i.castSucc (laurentResidual (fun q =>lastLaurent q (P q)) p)).coeff (2*(n+1):ℤ)=0 := by + by_contra h + obtain ⟨e,he⟩:=(peelLaurent_coeff_ne_zero_iff _ _ _).mp h + apply he + apply signLaurent_odd_even_coeff_zero i.castSucc _ (laurentResidual_odd P hP i p hp) + simp only [Fin.insertNth_apply_same] + exact even_two_mul (n+1:ℤ) + + + + + + + +lemma phase_primitive : IsPrimitiveRoot phase 16 := by + have h:=Complex.isPrimitiveRoot_exp 16 (by norm_num) + convert h using 2 + unfold phase lambda + congr 1 + push_cast + ring + + + +def residualRootPhase {n:ℕ} (i:Fin n) (j:Fin (n+1)) (k:Fin 4) : ℕ := + if j=i.castSucc then + if k=0 then 0 else if k=1 then 8 else if k=2 then 3 else 11 + else if j=Fin.last n then + if k=0 then 13 else if k=1 then 5 else if k=2 then 0 else 8 + else if j.val < i.val then + if k=0 then 2 else if k=1 then 10 else if k=2 then 3 else 11 + else + if k=0 then 14 else if k=1 then 6 else if k=2 then 13 else 5 + +def residualRootExponent {n:ℕ} (i:Fin n) (j:Fin (n+1)) (k:Fin 4) : Fin (n+1) → ℤ := + if j=i.castSucc then 0 else if j=Fin.last n ∧ 2≤k.val then -variableExponent j else variableExponent j + +def residualRoot {n:ℕ} (i:Fin n) (v:Fin (n+1) × Fin 4) : SpectralField (n+1) := + evalLaurent (monomialL (residualRootExponent i v.1 v.2) (phase^(residualRootPhase i v.1 v.2))) + +lemma residualRootPhase_lt {n:ℕ} (i:Fin n) (j:Fin (n+1)) (k:Fin 4) : residualRootPhase i j k<16 := by + unfold residualRootPhase + split_ifs <;> norm_num + +lemma residualRootPhase_injective {n:ℕ} (i:Fin n) (j:Fin (n+1)) : + Function.Injective (residualRootPhase i j) := by + intro k l h + by_cases hi:j=i.castSucc + · fin_cases k <;> fin_cases l <;> simp_all [residualRootPhase] + · by_cases hj:j=Fin.last n + · fin_cases k <;> fin_cases l <;> simp_all [residualRootPhase] + · by_cases hlt:j.val < i.val + · fin_cases k <;> fin_cases l <;> simp_all [residualRootPhase] + · simp only [residualRootPhase,ite_eq_right hi,ite_eq_right hj,ite_eq_right hlt] at h + fin_cases k <;> fin_cases l <;> simp_all + +lemma residualRootExponent_support {n:ℕ} (i:Fin n) (j:Fin (n+1)) (k:Fin 4) (l:Fin (n+1)) : + residualRootExponent i j k l≠0 ↔ j≠i.castSucc ∧ l=j := by + unfold residualRootExponent + split_ifs <;> simp_all [variableExponent,Pi.single_apply] + +lemma residualRootExponent_index {n:ℕ} (i:Fin n) (j l:Fin (n+1)) (k r:Fin 4) + (h:residualRootExponent i j k=residualRootExponent i l r) : j=l := by + by_cases hj:j=i.castSucc + · by_contra hl + have hl':l≠i.castSucc:=by intro e; exact hl (hj.trans e.symm) + have he:residualRootExponent i l r l≠0 := (residualRootExponent_support i l r l).mpr ⟨hl',rfl⟩ + rw [←h] at he + exact ((residualRootExponent_support i j k l).mp he).1 hj + · have he:residualRootExponent i j k j≠0 := (residualRootExponent_support i j k j).mpr ⟨hj,rfl⟩ + rw [h] at he + exact ((residualRootExponent_support i l r j).mp he).2 + +lemma residualRoot_ne_zero {n:ℕ} (i:Fin n) (v:Fin (n+1) × Fin 4) : residualRoot i v≠0 := by + unfold residualRoot + intro h + have he:monomialL (residualRootExponent i v.1 v.2) (phase^residualRootPhase i v.1 v.2)=0 := + IsFractionRing.injective (SpectralRing (n+1)) (SpectralField (n+1)) (by simpa only [evalLaurent,map_zero] using h) + exact pow_ne_zero _ phase_ne_zero (AddMonoidAlgebra.single_eq_zero.mp he) + +lemma residualRoot_injective {n:ℕ} (i:Fin n) : Function.Injective (residualRoot i) := by + rintro ⟨j,k⟩ ⟨l,r⟩ h + have he:monomialL (residualRootExponent i j k) (phase^residualRootPhase i j k)= + monomialL (residualRootExponent i l r) (phase^residualRootPhase i l r) := + IsFractionRing.injective (SpectralRing (n+1)) (SpectralField (n+1)) h + have hh:=AddMonoidAlgebra.single_inj.mp he + rcases hh with ⟨hex,hphase⟩ | ⟨hz,_⟩ + · have hj:=residualRootExponent_index i j l k r hex + subst l + have hk:=phase_primitive.pow_inj (residualRootPhase_lt i j k) (residualRootPhase_lt i j r) hphase + exact Prod.ext rfl (residualRootPhase_injective i j hk) + · exact (pow_ne_zero _ phase_ne_zero hz).elim + +def residualRootSet {n:ℕ} (i:Fin n) : Finset (SpectralField (n+1)) := + Finset.univ.image (residualRoot i) + +lemma residualRootSet_card {n:ℕ} (i:Fin n) : (residualRootSet i).card=4*(n+1) := by + rw [residualRootSet,Finset.card_image_of_injective _ (residualRoot_injective i)] + simp only [Finset.card_univ,Fintype.card_prod,Fintype.card_fin] + omega + + + +theorem residual_zero_of_root_grid {n:ℕ} + (P:Pairing (n+1) → Polynomial (Laurent n)) + (hP:∀p,(P p).map (algebraMap (SpectralRing n) (SpectralField n))=rationalNodalPolynomial n p) + (hb:∀p,LaurentBox (laurentResidual (fun q =>lastLaurent q (P q)) p) (fun _ =>2*(n+1))) + (p:Pairing (n+1)) (i:Fin n) (hp:p.Occupied i.castSucc) + (hz:∀v:Fin (n+1) × Fin 4, + torusEvaluation (Function.update variableF i.castSucc (residualRoot i v)) + (fun j =>by by_cases h:j=i.castSucc <;> simp [h,residualRoot_ne_zero,variableF_ne_zero]) + (laurentResidual (fun q =>lastLaurent q (P q)) p)=0) : + rationalInterpolationResidual n p=0 := by + let f:=laurentResidual (fun q =>lastLaurent q (P q)) p + have ht:(fullPeel i.castSucc f).coeff (2*(n+1):ℤ)=0 := by + rw [fullPeel_coeff,laurentResidual_peel_top_zero P hP i p hp,map_zero] + have hzero (z:SpectralField (n+1)) (h:z∈residualRootSet i):z≠0 := by + obtain ⟨v,_,rfl⟩:=Finset.mem_image.mp h + exact residualRoot_ne_zero i v + have hh:fullPeel i.castSucc f=0 := by + apply laurent_root_saturation _ (2*(n+1)) ((hb p).fullPeel _) ht (residualRootSet i) + (by rw [residualRootSet_card]; omega) hzero + intro z h + obtain ⟨v,_,rfl⟩:=Finset.mem_image.mp h + rw [fullPeel_eval] + exact hz v + have hf:f=0 := fullPeel_injective i.castSucc (by simpa only [map_zero] using hh) + rw [←laurentResidual_map P hP,show laurentResidual (fun q =>lastLaurent q (P q)) p=f from rfl,hf] + exact map_zero _ + +end + + + + + +noncomputable section +open scoped Classical + +lemma torusSin_monomial_ne_zero {n:ℕ} (e:Fin n → ℤ) (he:e≠0) (c:ℂ) (hc:c≠0) : + torusSin (evalLaurent (monomialL e c))≠0 := by + apply div_ne_zero _ (mul_ne_zero (by norm_num) ((map_ne_zero (algebraMap ℂ (SpectralField n))).mpr Complex.I_ne_zero)) + apply sub_ne_zero.mpr + intro h + rw [show (evalLaurent (monomialL e c))⁻¹=evalLaurent (monomialL (-e) c⁻¹) from map_monomialL_inv e c hc] at h + have hh:=IsFractionRing.injective (SpectralRing n) (SpectralField n) h + rcases AddMonoidAlgebra.single_inj.mp hh with ⟨heq,_⟩|⟨hz,_⟩ + · apply he + funext i + have hi:=congrFun heq i + change e i= -e i at hi + change e i=0 + omega + · exact hc hz + +lemma constF_mul_monomial {n:ℕ} (c d:ℂ) (e:Fin n → ℤ) : + constF n c*evalLaurent (monomialL e d)=evalLaurent (monomialL e (c*d)) := by + rw [←map_constantL] + change evalLaurent (constantL n c)*evalLaurent (monomialL e d)=_ + unfold evalLaurent + rw [←map_mul (algebraMap (SpectralRing n) (SpectralField n))] + simp [constantL,monomialL,AddMonoidAlgebra.single_mul_single] + +lemma torusL_monomial_ne_zero {n:ℕ} (e:Fin n → ℤ) (he:e≠0) (c:ℂ) (hc:c≠0) : + torusL (evalLaurent (monomialL e c))≠0 := by + unfold torusL + have h (s:ℕ):constF n phase^s*evalLaurent (monomialL e c)=evalLaurent (monomialL e (phase^s*c)) := by + change (algebraMap ℂ (SpectralField n)) phase^s*evalLaurent (monomialL e c)=_ + rw [←map_pow (algebraMap ℂ (SpectralField n))]; exact constF_mul_monomial _ _ _ + rw [h 2,h 3] + exact mul_ne_zero (torusSin_monomial_ne_zero e he _ (mul_ne_zero (pow_ne_zero _ phase_ne_zero) hc)) + (torusSin_monomial_ne_zero e he _ (mul_ne_zero (pow_ne_zero _ phase_ne_zero) hc)) + +lemma monomial_ratio_regular {n:ℕ} (e f:Fin n → ℤ) (hef:e≠f) (c d:ℂ) (hc:c≠0) (hd:d≠0) : + torusL (evalLaurent (monomialL e c)/evalLaurent (monomialL f d))≠0 := by + rw [div_eq_mul_inv,show (evalLaurent (monomialL f d))⁻¹=evalLaurent (monomialL (-f) d⁻¹) from map_monomialL_inv f d hd] + unfold evalLaurent + rw [←map_mul (algebraMap (SpectralRing n) (SpectralField n))] + rw [monomialL_mul] + apply torusL_monomial_ne_zero _ _ _ (mul_ne_zero hc (inv_ne_zero hd)) + simpa only [←sub_eq_add_neg,sub_ne_zero] using hef + +lemma variableExponent_injective {n:ℕ} : Function.Injective (@variableExponent n) := by + intro i j h + by_contra hij + have hh:=congrFun h i + simp [variableExponent,hij] at hh + +lemma flat_update_regular {n:ℕ} (i j:Fin n) (hij:i≠j) (c:ℂ) (hc:c≠0) : + torusL ((Function.update variableF i.castSucc (constF (n+1) c)) i.castSucc/ + (Function.update variableF i.castSucc (constF (n+1) c)) j.castSucc)≠0 := by + simp only [Function.update_self,Function.update_of_ne (fun h =>hij (Fin.castSucc_injective n h).symm)] + change torusL (evalLaurent (monomialL 0 c)/evalLaurent (monomialL (variableExponent j.castSucc) 1))≠0 + apply monomial_ratio_regular _ _ _ c 1 hc one_ne_zero + intro h + have hh:=congrFun h j.castSucc + simp [variableExponent] at hh + +lemma pair_update_regular {n:ℕ} (i j:Fin n) (_hij:i≠j) (c:ℂ) (hc:c≠0) : + PairExchangeRegular (Function.update variableF i.castSucc (constF (n+1) c*variableF j.castSucc)) i j := by + let E:Fin n → Fin (n+1) → ℤ:=fun a =>if a=i then variableExponent j.castSucc else variableExponent a.castSucc + let C:Fin n → ℂ:=fun a =>if a=i then c else 1 + have he (a:Fin n):(Function.update variableF i.castSucc (constF (n+1) c*variableF j.castSucc)) a.castSucc= + evalLaurent (monomialL (E a) (C a)) := by + by_cases ha:a=i + · subst a; simp only [Function.update_self,E,C,ite_true] + change constF (n+1) c*evalLaurent (monomialL (variableExponent j.castSucc) 1)=_ + simpa using constF_mul_monomial c 1 (variableExponent j.castSucc) + · simp only [Function.update_of_ne (fun h =>ha (Fin.castSucc_injective n h)),E,C,ite_eq_right ha] + rfl + have hC (a:Fin n):C a≠0 := by dsimp [C]; split_ifs <;> simp_all + intro a b hab hpair + rw [he,he] + apply monomial_ratio_regular _ _ _ _ _ (hC b) (hC a) + intro h + by_cases hai:a=i <;> by_cases hbi:b=i + · exact hab (hai.trans hbi.symm) + · have hh: b=j := Fin.castSucc_injective n (variableExponent_injective (by simpa [E,hai,hbi] using h)) + exact hpair (Or.inl ⟨hai,hh⟩) + · have hh: a=j := Fin.castSucc_injective n (variableExponent_injective (by simpa [E,hai,hbi] using h.symm)) + exact hpair (Or.inr ⟨hh,hbi⟩) + · exact hab (Fin.castSucc_injective n (variableExponent_injective (by simpa [E,hai,hbi] using h.symm))) + + + + + + + +lemma torusEvaluation_signLaurent {n m:ℕ} (i:Fin (n+1)) + (z:Fin (n+1) → SpectralField m) (hz:∀j,z j≠0) (f:Laurent (n+1)) : + torusEvaluation z hz (signLaurent i f)= + torusEvaluation (Function.update z i (-z i)) + (fun j =>by by_cases h:j=i <;> simp [h,hz]) f := by + induction f using AddMonoidAlgebra.induction_linear with + | zero => simp + | add f g hf hg => simp only [map_add,hf,hg] + | single e c => + change torusEvaluation z hz (signLaurent i (monomialL e c))= + torusEvaluation (Function.update z i (-z i)) _ (monomialL e c) + rw [signLaurent_monomial,torusEvaluation_monomial,torusEvaluation_monomial] + rw [Fin.prod_univ_succAbove _ i,Fin.prod_univ_succAbove _ i] + simp only [Function.update_self,Function.update_of_ne (Fin.succAbove_ne i _),constF,map_mul,map_zpow₀,map_neg,map_one] + rw [show -z i=(-1)*z i by ring,mul_zpow] + ring + +lemma torusEvaluation_neg_zero {n m:ℕ} (i:Fin (n+1)) + (z:Fin (n+1) → SpectralField m) (hz:∀j,z j≠0) (f:Laurent (n+1)) + (hodd:signLaurent i f= -f) (h:torusEvaluation z hz f=0) : + torusEvaluation (Function.update z i (-z i)) + (fun j =>by by_cases h:j=i <;> simp [h,hz]) f=0 := by + rw [←torusEvaluation_signLaurent i z hz f,hodd,map_neg,h,neg_zero] + + + + + + + +lemma lastEvaluation_residual_zero {n:ℕ} + (P:Pairing (n+1) → Polynomial (Laurent n)) + (hP:∀p,(P p).map (algebraMap (SpectralRing n) (SpectralField n))=rationalNodalPolynomial n p) + (i:Fin n) (y:SpectralField n) (hy:y≠0) + (hA:torusCos (y^2/constF n phase^3)=deletionBeta i) (p:Pairing (n+1)) : + lastEvaluation y hy (laurentResidual (fun q =>lastLaurent q (P q)) p)=0 := by + let φ:=lastEvaluation y hy + have hpoly:=RationalAt.eval₂ φ.toRingHom (liftSpectral n) (RingHom.id _) + (rationalAt_last_lift y hy) (rationalAt_last_spectralA y hy) + (rationalResidualPolynomial n p) + rw [Polynomial.eval₂_id,hA,rationalResidualPolynomial_at_node] at hpoly + have hs:RationalAt φ.toRingHom + (if p.Occupied (Fin.last n) then torusSin (variableF (Fin.last n)) else 1) + (if p.Occupied (Fin.last n) then torusSin y else 1) := by + split_ifs + · exact rationalAt_torusSin φ (rationalAt_last_variable y hy) hy + · exact RationalAt.one + have hd:=RationalAt.algebraMap (φ:=φ.toRingHom) (F:=SpectralField (n+1)) + ((∏j:Fin n,rowDenominator j.castSucc) * algebraMap ℂ (Laurent (n+1)) (1/2)) + have hden:evalLaurent ((∏j:Fin n,rowDenominator j.castSucc) * algebraMap ℂ (Laurent (n+1)) (1/2))= + (∏j:Fin n,evalLaurent (rowDenominator j.castSucc))/2 := by + change evalLaurent ((∏j:Fin n,rowDenominator j.castSucc) * constantL (n+1) (1/2))=_ + simp only [evalLaurent,map_mul,map_prod,map_constantL] + congr 1 + change (algebraMap ℂ (SpectralField (n+1))) (1/2)=(2:SpectralField (n+1))⁻¹ + norm_num + rw [map_ofNat] + norm_num + change RationalAt _ (evalLaurent _) _ at hd + rw [hden] at hd + have hr:=hd.mul (hs.mul hpoly) + simp only [mul_zero] at hr + have he:=rationalInterpolationResidual_transfer (n:=n) p + simp only [ite_mul,one_mul] at hr + change RationalAt φ.toRingHom ((∏j:Fin n,evalLaurent (rowDenominator j.castSucc))/2 * + lastValue (liftSpectral n) (spectralA (Fin.last n)) (torusSin (variableF (Fin.last n))) (rationalResidualPolynomial n) p) 0 at hr + rw [←he] at hr + have hf:=RationalAt.algebraMap (φ:=φ.toRingHom) (F:=SpectralField (n+1)) + (laurentResidual (fun q =>lastLaurent q (P q)) p) + change RationalAt _ (evalLaurent _) _ at hf + rw [laurentResidual_map P hP] at hf + exact hf.unique hr + +lemma residual_last_delete_universal {n m:ℕ} + (P:Pairing (n+1) → Polynomial (Laurent n)) + (hP:∀p,(P p).map (algebraMap (SpectralRing n) (SpectralField n))=rationalNodalPolynomial n p) + (i:Fin n) (z:Fin (n+1) → SpectralField m) (hz:∀j,z j≠0) + (hzi:z (Fin.last n)=z i.castSucc*constF m phase^3) (p:Pairing (n+1)) : + torusEvaluation z hz (laurentResidual (fun q =>lastLaurent q (P q)) p)=0 := by + let u:=monomialUnit (variableExponent i) (phase^3) (pow_ne_zero _ phase_ne_zero) + have hu:evalLaurent (u:Laurent n)=deletionNode i := by + simp [u,monomialUnit,evalLaurent_monomial_product,variableExponent,Pi.single_apply,deletionNode,constF,mul_comm] + apply generic_substitution_zero (Fin.last n) u + (Fin.snoc variableF (deletionNode i)) _ _ _ _ + (lastEvaluation_residual_zero P hP i _ (mul_ne_zero (variableF_ne_zero i) (pow_ne_zero _ (constF_phase_ne_zero n))) rfl p) z hz + · simpa [u,monomialUnit,torusEvaluation_monomial,variableExponent,Pi.single_apply,constF,mul_comm] using hzi + · rw [Fin.snoc_last,hu] + · intro j; simp + +lemma residual_last_inverse_universal {n m:ℕ} + (P:Pairing (n+1) → Polynomial (Laurent n)) + (hP:∀p,(P p).map (algebraMap (SpectralRing n) (SpectralField n))=rationalNodalPolynomial n p) + (i:Fin n) (z:Fin (n+1) → SpectralField m) (hz:∀j,z j≠0) + (hzi:z (Fin.last n)=(z i.castSucc)⁻¹) (p:Pairing (n+1)) : + torusEvaluation z hz (laurentResidual (fun q =>lastLaurent q (P q)) p)=0 := by + let u:=monomialUnit (-variableExponent i) 1 one_ne_zero + have hu:evalLaurent (u:Laurent n)=(variableF i)⁻¹ := by + simp [u,monomialUnit,evalLaurent_monomial_product,variableExponent,Pi.single_apply,constF] + have hA:torusCos (((variableF i)⁻¹)^2/constF n phase^3)=deletionBeta i := by + rw [deletionBeta,deletionNode] + have he:((variableF i)⁻¹)^2/constF n phase^3= + ((variableF i*constF n phase^3)^2/constF n phase^3)⁻¹ := by + field_simp [variableF_ne_zero,constF_phase_ne_zero] + rw [he,torusCos_inv] + apply generic_substitution_zero (Fin.last n) u + (Fin.snoc variableF ((variableF i)⁻¹)) _ _ _ _ + (lastEvaluation_residual_zero P hP i _ (inv_ne_zero (variableF_ne_zero i)) hA p) z hz + · simpa [u,monomialUnit,torusEvaluation_monomial,variableExponent,Pi.single_apply,constF] using hzi + · rw [Fin.snoc_last,hu] + · intro j; simp + + + + + + + +def positiveResidualRoot {n:ℕ} (i:Fin n) (j:Fin (n+1)) (b:Bool) : SpectralField (n+1) := + if j=i.castSucc then (if b then constF (n+1) phase^3 else 1) + else if j=Fin.last n then (if b then (variableF j)⁻¹ else (constF (n+1) phase^3)⁻¹*variableF j) + else if j.val < i.val then constF (n+1) phase^(if b then 3 else 2)*variableF j + else (constF (n+1) phase^(if b then 3 else 2))⁻¹*variableF j + +lemma phase_more_powers : + phase^10= -phase^2 ∧ phase^11= -phase^3 ∧ phase^13=(phase^3)⁻¹ ∧ + phase^14=(phase^2)⁻¹ ∧ phase^5= -(phase^3)⁻¹ ∧ phase^6= -(phase^2)⁻¹ := by + have h16:phase^16=1 := by + calc + phase^16=(phase^8)^2 := by ring + _=1 := by rw [phase_eight]; norm_num + have h13:phase^13=(phase^3)⁻¹ := by + apply eq_inv_of_mul_eq_one_left + calc + phase^13*phase^3=phase^16 := by ring + _=1 := h16 + have h14:phase^14=(phase^2)⁻¹ := by + apply eq_inv_of_mul_eq_one_left + calc + phase^14*phase^2=phase^16 := by ring + _=1 := h16 + have h (k:ℕ):phase^(8+k)= -phase^k := by rw [pow_add,phase_eight,neg_one_mul] + refine ⟨by simpa using h 2,by simpa using h 3,h13,h14,?_,?_⟩ + · have hh:=h 5; rw [show 8+5=13 from rfl,h13] at hh; linear_combination hh + · have hh:=h 6; rw [show 8+6=14 from rfl,h14] at hh; linear_combination hh + +lemma residualRoot_values {n:ℕ} (i:Fin n) (j:Fin (n+1)) (k:Fin 4) : + residualRoot i (j,k)= + if k=0 then positiveResidualRoot i j false else + if k=1 then -positiveResidualRoot i j false else + if k=2 then positiveResidualRoot i j true else -positiveResidualRoot i j true := by + have hp:=phase_more_powers + by_cases hi:j=i.castSucc + · fin_cases k <;> simp [residualRoot,residualRootPhase,residualRootExponent,positiveResidualRoot,hi, + evalLaurent_monomial_product,constF,show evalLaurent (1:Laurent (n+1))=1 from map_one _,phase_eight,hp.2.1] + · by_cases hl:j=Fin.last n + · have hli : (Fin.last n : Fin (n+1))≠i.castSucc := Ne.symm (Fin.castSucc_ne_last i) + fin_cases k <;> simp [residualRoot,residualRootPhase,residualRootExponent,positiveResidualRoot,hl,hli, + evalLaurent_monomial_product,variableExponent,Pi.single_apply,constF,phase_eight, + hp.2.2.1,hp.2.2.2.2.1] + · by_cases hji:j.val < i.val + · fin_cases k <;> simp [residualRoot,residualRootPhase,residualRootExponent,positiveResidualRoot,hi,hl,hji, + evalLaurent_monomial_product,variableExponent,Pi.single_apply,constF,hp.1,hp.2.1] + · fin_cases k <;> simp [residualRoot,residualRootPhase,residualRootExponent,positiveResidualRoot,hi,hl,hji, + evalLaurent_monomial_product,variableExponent,Pi.single_apply,constF, + hp.2.2.1,hp.2.2.2.1,hp.2.2.2.2.1,hp.2.2.2.2.2] + +lemma positiveResidualRoot_ne_zero {n:ℕ} (i:Fin n) (j:Fin (n+1)) (b:Bool) : + positiveResidualRoot i j b≠0 := by + cases b + · simpa [residualRoot_values] using residualRoot_ne_zero i (j,0) + · simpa [residualRoot_values] using residualRoot_ne_zero i (j,2) + +lemma positiveRoot_negative_zero {n:ℕ} + (P:Pairing (n+1) → Polynomial (Laurent n)) + (hP:∀p,(P p).map (algebraMap (SpectralRing n) (SpectralField n))=rationalNodalPolynomial n p) + (i:Fin n) (p:Pairing (n+1)) (hp:p.Occupied i.castSucc) + (j:Fin (n+1)) (b:Bool) + (h:torusEvaluation (Function.update variableF i.castSucc (positiveResidualRoot i j b)) + (fun k =>by by_cases h:k=i.castSucc <;> simp [h,positiveResidualRoot_ne_zero,variableF_ne_zero]) + (laurentResidual (fun q =>lastLaurent q (P q)) p)=0) : + torusEvaluation (Function.update variableF i.castSucc (-positiveResidualRoot i j b)) + (fun k =>by by_cases h:k=i.castSucc <;> simp [h,positiveResidualRoot_ne_zero,variableF_ne_zero]) + (laurentResidual (fun q =>lastLaurent q (P q)) p)=0 := by + have hh:=torusEvaluation_neg_zero i.castSucc _ _ _ (laurentResidual_odd P hP i p hp) h + simpa only [Function.update_self,Function.update_idem] using hh + +lemma residualRoot_signed {n:ℕ} (i:Fin n) (v:Fin (n+1) × Fin 4) : + ∃b:Bool,residualRoot i v=positiveResidualRoot i v.1 b ∨ + residualRoot i v= -positiveResidualRoot i v.1 b := by + rcases v with ⟨j,k⟩ + fin_cases k + · exact ⟨false,Or.inl (by simp [residualRoot_values])⟩ + · exact ⟨false,Or.inr (by simp [residualRoot_values])⟩ + · exact ⟨true,Or.inl (by simp [residualRoot_values])⟩ + · exact ⟨true,Or.inr (by simp [residualRoot_values])⟩ + +lemma residual_root_grid_of_positive {n:ℕ} + (P:Pairing (n+1) → Polynomial (Laurent n)) + (hP:∀p,(P p).map (algebraMap (SpectralRing n) (SpectralField n))=rationalNodalPolynomial n p) + (i:Fin n) (p:Pairing (n+1)) (hp:p.Occupied i.castSucc) + (hpos:∀j b,torusEvaluation (Function.update variableF i.castSucc (positiveResidualRoot i j b)) + (fun k =>by by_cases h:k=i.castSucc <;> simp [h,positiveResidualRoot_ne_zero,variableF_ne_zero]) + (laurentResidual (fun q =>lastLaurent q (P q)) p)=0) + (v:Fin (n+1) × Fin 4) : + torusEvaluation (Function.update variableF i.castSucc (residualRoot i v)) + (fun k =>by by_cases h:k=i.castSucc <;> simp [h,residualRoot_ne_zero,variableF_ne_zero]) + (laurentResidual (fun q =>lastLaurent q (P q)) p)=0 := by + obtain ⟨b,h|h⟩:=residualRoot_signed i v + · simpa only [h] using hpos v.1 b + · simpa only [h] using positiveRoot_negative_zero P hP i p hp v.1 b (hpos v.1 b) + + + + + + + +lemma PairExchangeRegular.symm {n m:ℕ} {z:Fin (n+1) → SpectralField m} {i j:Fin n} + (h:PairExchangeRegular z i j) : PairExchangeRegular z j i := by + intro a b hab hij + exact h a b hab (by tauto) + + + +theorem residual_positive_roots {n:ℕ} + (P:Pairing (n+2) → Polynomial (Laurent (n+1))) + (hP:∀p,(P p).map (algebraMap (SpectralRing (n+1)) (SpectralField (n+1)))=rationalNodalPolynomial (n+1) p) + (hflat:∀(b:Bool) (z:Fin (n+2) → SpectralField (n+2)) (hz:∀k,z k≠0), + z 0=(if b then constF (n+2) phase^3 else 1) → ∀p, + torusEvaluation z hz (laurentResidual (fun q =>lastLaurent q (P q)) p)=0) + (hpair:∀(h2:2≤n+1) (s:ℕ),s=2 ∨ s=3 → + ∀(z:Fin (n+2) → SpectralField (n+2)) (hz:∀k,z k≠0), + z (⟨1,by omega⟩:Fin (n+1)).castSucc=constF (n+2) phase^s*z (⟨0,by omega⟩:Fin (n+1)).castSucc → ∀p, + torusEvaluation z hz (laurentResidual (fun q =>lastLaurent q (P q)) p)=0) + (i:Fin (n+1)) (j:Fin (n+2)) (b:Bool) (p:Pairing (n+2)) : + torusEvaluation (Function.update variableF i.castSucc (positiveResidualRoot i j b)) + (fun k =>by by_cases h:k=i.castSucc <;> simp [h,positiveResidualRoot_ne_zero,variableF_ne_zero]) + (laurentResidual (fun q =>lastLaurent q (P q)) p)=0 := by + let z:=Function.update variableF i.castSucc (positiveResidualRoot i j b) + have hz:∀k,z k≠0 := fun k =>by dsimp [z]; by_cases h:k=i.castSucc <;> simp [h,positiveResidualRoot_ne_zero,variableF_ne_zero] + change torusEvaluation z hz _=0 + by_cases hji:j=i.castSucc + · have hroot:positiveResidualRoot i j b=(if b then constF (n+2) phase^3 else 1) := by simp [positiveResidualRoot,hji] + apply residual_flat_transport P hP _ (hflat b) i z hz + · simp [z,hroot] + · intro a ha + cases b + · simpa only [z,hroot,Bool.false_eq_true,ite_false,show constF (n+2) (1:ℂ)=1 from map_one (algebraMap ℂ _)] using + flat_update_regular i a (Ne.symm (Fin.ne_of_lt ha)) 1 one_ne_zero + · simpa only [z,hroot,ite_true,constF,map_pow] using + flat_update_regular i a (Ne.symm (Fin.ne_of_lt ha)) (phase^3) (pow_ne_zero _ phase_ne_zero) + · by_cases hjlast:j=Fin.last (n+1) + · have hilast:(Fin.last (n+1):Fin (n+2))≠i.castSucc := Ne.symm (Fin.castSucc_ne_last i) + cases b + · apply residual_last_delete_universal P hP i z hz + simp only [z,positiveResidualRoot,hjlast,hilast,ite_false,ite_true,Function.update_self,Function.update_of_ne hilast,Bool.false_eq_true] + field_simp [constF_phase_ne_zero] + · apply residual_last_inverse_universal P hP i z hz + simp [z,positiveResidualRoot,hjlast,hilast] + · obtain ⟨a,ha⟩:∃a:Fin (n+1),a.castSucc=j := by + have hjv : j.val < n+1 := by + have hne : j.val ≠ n+1 := by + intro h + apply hjlast + exact Fin.ext h + have := j.isLt + omega + exact ⟨⟨j.val,hjv⟩,rfl⟩ + subst j + have hai:a≠i := fun h =>hji (congrArg Fin.castSucc h) + let s:ℕ:=if b then 3 else 2 + have hs:s=2 ∨ s=3 := by cases b <;> simp [s] + have h2:2≤n+1 := by have:=i.isLt; have:=a.isLt; have hne:i.val≠a.val := fun h =>hai (Fin.ext h.symm); omega + by_cases hlt:a < i + · have hroot:positiveResidualRoot i a.castSucc b=constF (n+2) phase^s*variableF a.castSucc := by + simp [positiveResidualRoot,hji,hjlast,show a.val < i.val from hlt,s] + have hr:PairExchangeRegular z i a := by + simpa only [z,hroot,constF,map_pow] using pair_update_regular i a hai.symm (phase^s) (pow_ne_zero _ phase_ne_zero) + apply residual_pair_transport P hP _ h2 (hpair h2 s hs) a i hlt z hz _ hr.symm p + simp only [z,Function.update_self,Function.update_of_ne (fun h =>hai (Fin.castSucc_injective (n+1) h)),hroot] + · have hia:i < a := lt_of_le_of_ne (le_of_not_gt hlt) (Ne.symm hai) + have hroot:positiveResidualRoot i a.castSucc b=(constF (n+2) phase^s)⁻¹*variableF a.castSucc := by + simp [positiveResidualRoot,hji,hjlast,show ¬a.val < i.val from hlt,s] + have hr:PairExchangeRegular z i a := by + simpa only [z,hroot,constF,map_inv₀,map_pow] using pair_update_regular i a hai.symm (phase^s)⁻¹ (inv_ne_zero (pow_ne_zero _ phase_ne_zero)) + apply residual_pair_transport P hP _ h2 (hpair h2 s hs) i a hia z hz _ hr p + simp only [z,Function.update_self,Function.update_of_ne (fun h =>hai (Fin.castSucc_injective (n+1) h)),hroot] + field_simp [constF_phase_ne_zero] + +end +end CriticalStrip.Diagram + +end OAI diff --git a/lean/OAI/Combinatorics/StripMass/RestrictedDiagrams.lean b/lean/OAI/Combinatorics/StripMass/RestrictedDiagrams.lean new file mode 100644 index 0000000000000000000000000000000000000000..f1cd24fc6ac03c07c4fdce12fa22b364b24c9278 --- /dev/null +++ b/lean/OAI/Combinatorics/StripMass/RestrictedDiagrams.lean @@ -0,0 +1,445 @@ +import Mathlib +import OAI.Combinatorics.StripMass.TopPadding + +namespace OAI + +/-! Critical honeycomb strip paths, polynomial identities and crossing mass. -/ + + +namespace CriticalStrip.Diagram +noncomputable section +def rawRestricted {R : Type*} [CommRing R] {n : ℕ} (w : Fin n → Tile → R) : + Matrix (NonemptyPairing n) (NonemptyPairing n) R := + (rawColumn w).submatrix Subtype.val Subtype.val + +theorem column_eq_raw {R : Type*} [CommRing R] {n : ℕ} (w : Fin n → Weights R) : + column w = rawColumn (fun i => (w i).tile) := rfl + +theorem rawColumn_scale {R : Type*} [CommRing R] {n : ℕ} + (w : Fin n → Tile → R) (a : Fin n → R) : + rawColumn (fun i t => a i * w i t) = (∏ i, a i) • rawColumn w := by + classical + ext q p + simp only [rawColumn, Matrix.smul_apply, smul_eq_mul, Finset.mul_sum] + apply Finset.sum_congr rfl + intro t ht + split_ifs <;> simp [Finset.prod_mul_distrib] + +theorem rawColumn_map {R S : Type*} [CommRing R] [CommRing S] {n : ℕ} + (f : R →+* S) (w : Fin n → Tile → R) : + (rawColumn w).map f = rawColumn (fun i t => f (w i t)) := by + classical + ext q p + simp only [Matrix.map_apply, rawColumn, map_sum] + apply Finset.sum_congr rfl + intro t ht + split_ifs <;> simp + +theorem rawRestricted_scale {R : Type*} [CommRing R] {n : ℕ} + (w : Fin n → Tile → R) (a : Fin n → R) : + rawRestricted (fun i t => a i * w i t) = (∏ i, a i) • rawRestricted w := by + unfold rawRestricted + rw [rawColumn_scale] + rfl + +theorem rawRestricted_map {R S : Type*} [CommRing R] [CommRing S] {n : ℕ} + (f : R →+* S) (w : Fin n → Tile → R) : + (rawRestricted w).map f = rawRestricted (fun i t => f (w i t)) := by + unfold rawRestricted + rw [← rawColumn_map] + rfl + +theorem cleared_map {R S : Type*} [CommRing R] [CommRing S] {n : ℕ} + (g : R →+* S) (num : Fin n → Tile → R) (a : Fin n → R) + (w : Fin n → Weights S) + (h : ∀ i t, g (num i t) = g (a i) * (w i).tile t) : + (((∏ i, a i) • 1 - rawRestricted num).map g) = + (∏ i, g (a i)) • (1 - restrictedColumn w) := by + have hraw : (rawRestricted num).map g = + (∏ i, g (a i)) • restrictedColumn w := by + rw [rawRestricted_map] + simp_rw [h] + rw [rawRestricted_scale] + rfl + ext p q + have hh := congrFun (congrFun hraw p) q + simp only [Matrix.map_apply, Matrix.smul_apply, smul_eq_mul] at hh + simp only [Matrix.map_apply, Matrix.sub_apply, Matrix.smul_apply, + smul_eq_mul, map_sub, map_mul, map_prod, Matrix.one_apply] + rw [hh] + split_ifs <;> simp + ring + + + +theorem regular_of_cleared_specialization {R K F : Type*} + [CommRing R] [Field K] [Field F] {n : ℕ} + (f : R →+* K) (hf : Function.Injective f) (e : R →+* F) + (a : Fin n → R) (num : Fin n → Tile → R) + (wa : Fin n → Weights K) (we : Fin n → Weights F) + (ha : ∀ i, e (a i) ≠ 0) + (hnuma : ∀ i t, f (num i t) = f (a i) * (wa i).tile t) + (hnume : ∀ i t, e (num i t) = e (a i) * (we i).tile t) + (he : VacuumRegular we) : VacuumRegular wa := by + classical + let A : Matrix (NonemptyPairing n) (NonemptyPairing n) R := + (∏ i, a i) • 1 - rawRestricted num + have hAe : e A.det ≠ 0 := by + rw [e.map_det] + change (A.map e).det ≠ 0 + rw [show A.map e = _ from cleared_map e num a we hnume, Matrix.det_smul] + apply mul_ne_zero + · exact pow_ne_zero _ (Finset.prod_ne_zero_iff.mpr (fun i _ => ha i)) + · exact he + have hA : A.det ≠ 0 := by + intro h + exact hAe (by rw [h, map_zero]) + have hAf : f A.det ≠ 0 := by + intro h + exact hA (hf (by simpa using h)) + rw [f.map_det] at hAf + change (A.map f).det ≠ 0 at hAf + rw [show A.map f = _ from cleared_map f num a wa hnuma, Matrix.det_smul] at hAf + exact (mul_ne_zero_iff.mp hAf).2 + + + +abbrev Laurent (n : ℕ) := AddMonoidAlgebra ℂ (Fin n → ℤ) +abbrev SpectralRing (n : ℕ) := Laurent n +abbrev SpectralField (n : ℕ) := FractionRing (SpectralRing n) + +def constF (n : ℕ) (z : ℂ) : SpectralField n := algebraMap ℂ (SpectralField n) z + +def variableExponent {n : ℕ} (i : Fin n) : Fin n → ℤ := + Pi.single i 1 + +def variableF {n : ℕ} (i : Fin n) : SpectralField n := + algebraMap (SpectralRing n) (SpectralField n) + (AddMonoidAlgebra.single (variableExponent i) 1) + +def phase : ℂ := Complex.exp (lambda * Complex.I) +def rho : ℝ := 1 / Real.sqrt (2 + Real.sqrt 2) +def d : ℝ := Real.cos (2*lambda) +def C : ℝ := Real.cos lambda + +def torusSin {n : ℕ} (z : SpectralField n) : SpectralField n := + (z-z⁻¹) / (2*constF n Complex.I) + +def torusCos {n : ℕ} (z : SpectralField n) : SpectralField n := (z+z⁻¹)/2 + +def torusL {n : ℕ} (z : SpectralField n) : SpectralField n := + torusSin (constF n phase ^ 2 * z) * torusSin (constF n phase ^ 3 * z) + + +def torusWeights {n : ℕ} (z : SpectralField n) : Weights (SpectralField n) := + let q := constF n phase + let dd := constF n d + let ell := torusL z + ⟨dd * torusSin (q^3/z) / ell, + torusSin z * torusSin (q^3/z) / ell, + dd * torusSin z / ell, + torusSin (q^3/z) * torusSin (q^2/z) / ell, + torusSin (z/q) * torusSin z / ell⟩ + + +def spectralWeights (n : ℕ) (i : Fin n) : Weights (SpectralField n) := + torusWeights (constF n phase ^ 3 / variableF i) + +def spectralA {n : ℕ} (i : Fin n) : SpectralField n := + torusCos (variableF i ^ 2 / constF n phase ^ 3) + +def discriminant {𝕜 : Type*} [CommRing 𝕜] (dd a b : 𝕜) : 𝕜 := + a^2+b^2+2*dd*a*b-dd^2 + +def pairFirst (n : ℕ) (i : Fin (n/2)) : Fin n := ⟨2*i.val, by have := i.isLt; omega⟩ +def pairSecond (n : ℕ) (i : Fin (n/2)) : Fin n := ⟨2*i.val+1, by have := i.isLt; omega⟩ + +def pfaffian {𝕜 : Type*} [Field 𝕜] {n : ℕ} (M : Matrix (Fin n) (Fin n) 𝕜) : 𝕜 := + (2^(n/2) * (Nat.factorial (n/2) : 𝕜))⁻¹ * + ∑ σ : Equiv.Perm (Fin n), (Equiv.Perm.sign σ : ℤ) * + ∏ i : Fin (n/2), M (σ (pairFirst n i)) (σ (pairSecond n i)) + + +def augmentedKernel {𝕜 : Type*} [Field 𝕜] {n : ℕ} (dd rr : 𝕜) (a : Fin n → 𝕜) : + Matrix (Fin (n+n%2)) (Fin (n+n%2)) 𝕜 := fun i j => + if hi : i.val < n then + if hj : j.val < n then + ((a ⟨i.val,hi⟩ - a ⟨j.val,hj⟩) * (a ⟨i.val,hi⟩ + a ⟨j.val,hj⟩ + rr)) / + discriminant dd (a ⟨i.val,hi⟩) (a ⟨j.val,hj⟩) + else 1 + else if j.val < n then -1 else 0 + +def scalarNormalization {𝕜 : Type*} [Field 𝕜] {n : ℕ} (dd rr : 𝕜) (a : Fin n → 𝕜) : 𝕜 := + (∏ i, ∏ j ∈ Finset.Ioi i, discriminant dd (a i) (a j) / (a i-a j)) * + pfaffian (augmentedKernel dd rr a) + +def spectralNormalization (n : ℕ) : SpectralField n := + scalarNormalization (constF n d) (constF n rho) spectralA + + +def evalLaurent {n : ℕ} (f : Laurent n) : SpectralField n := + algebraMap (SpectralRing n) (SpectralField n) f + +def liftLaurent {n : ℕ} (f : Laurent n) : Laurent (n+1) := + AddMonoidAlgebra.ofCoeff (Finsupp.mapDomain (fun e : Fin n → ℤ => Fin.snoc e 0) f.coeff) + +def lastExponent (n : ℕ) (a : ℤ) : Fin (n+1) → ℤ := Fin.snoc (fun _ => 0) a + +def lastCosine (n : ℕ) : Laurent (n+1) := + AddMonoidAlgebra.single (lastExponent n 2) (phase^(-3 : ℤ)/2) + + AddMonoidAlgebra.single (lastExponent n (-2)) (phase^3/2) + +def lastSine (n : ℕ) : Laurent (n+1) := + AddMonoidAlgebra.single (lastExponent n 1) (1/(2*Complex.I)) - + AddMonoidAlgebra.single (lastExponent n (-1)) (1/(2*Complex.I)) + + + +def PolynomialVacuum : Prop := + ∃ W : (n : ℕ) → Pairing n → Laurent n, + (W 0 (empty 0) = 1) ∧ + (∀ n p, evalLaurent (W n p) = + spectralNormalization n * normalizedVacuum (spectralWeights n) p) ∧ + (∀ n p e, e ∈ (W n p).coeff.support → ∀ i, |e i| ≤ ((2*(n-1) : ℕ) : ℤ)) ∧ + (∀ n p, ∃ g : Fin n → Laurent n, + W (n+1) p.padTop = + liftLaurent (W n p) * lastCosine n ^ n + + ∑ j : Fin n, liftLaurent (g j) * lastCosine n ^ j.val) ∧ + (∀ n (p : Pairing (n+1)), p.Occupied (Fin.last n) → + ∃ g : Fin n → Laurent n, + W (n+1) p = lastSine n * + ∑ j : Fin n, liftLaurent (g j) * lastCosine n ^ j.val) + + + +def monomialL {n : ℕ} (e : Fin n → ℤ) (z : ℂ) : Laurent n := + AddMonoidAlgebra.single e z + +def constantL (n : ℕ) : ℂ →+* Laurent n := AddMonoidAlgebra.singleZeroRingHom + +def flatEval (n : ℕ) : Laurent n →ₐ[ℂ] ℂ := + AddMonoidAlgebra.lift ℂ ℂ (Fin n → ℤ) 1 + +@[simp] theorem flatEval_monomial {n : ℕ} (e : Fin n → ℤ) (z : ℂ) : + flatEval n (monomialL e z) = z := by + simp [flatEval, monomialL, AddMonoidAlgebra.lift_single] + +@[simp] theorem flatEval_constant (n : ℕ) (z : ℂ) : + flatEval n (constantL n z) = z := flatEval_monomial 0 z + +@[simp] theorem monomialL_mul {n : ℕ} (e f : Fin n → ℤ) (z w : ℂ) : + monomialL e z * monomialL f w = monomialL (e+f) (z*w) := by + exact AddMonoidAlgebra.single_mul_single _ _ _ _ + +@[simp] theorem monomialL_zero_one (n : ℕ) : monomialL (0 : Fin n → ℤ) 1 = 1 := + AddMonoidAlgebra.one_def.symm + +theorem map_constantL (n : ℕ) (z : ℂ) : + algebraMap (SpectralRing n) (SpectralField n) (constantL n z) = constF n z := by + exact (IsScalarTower.algebraMap_apply ℂ (SpectralRing n) (SpectralField n) z).symm + +theorem map_monomialL_inv {n : ℕ} (e : Fin n → ℤ) (z : ℂ) (hz : z ≠ 0) : + (algebraMap (SpectralRing n) (SpectralField n) (monomialL e z))⁻¹ = + algebraMap (SpectralRing n) (SpectralField n) (monomialL (-e) z⁻¹) := by + apply inv_eq_of_mul_eq_one_right + rw [← map_mul, monomialL_mul] + simp [hz] + +def sineL {n : ℕ} (e : Fin n → ℤ) (z : ℂ) : Laurent n := + (monomialL e z - monomialL (-e) z⁻¹) * constantL n ((2*Complex.I)⁻¹) + +theorem sineL_map {n : ℕ} (e : Fin n → ℤ) (z : ℂ) (hz : z ≠ 0) : + algebraMap (SpectralRing n) (SpectralField n) (sineL e z) = + torusSin (algebraMap (SpectralRing n) (SpectralField n) (monomialL e z)) := by + rw [sineL, map_mul, map_sub, map_constantL] + rw [torusSin, map_monomialL_inv e z hz] + simp only [constF, map_inv₀, map_mul, map_ofNat, div_eq_mul_inv] + +@[simp] theorem flatEval_sine {n : ℕ} (e : Fin n → ℤ) (z : ℂ) : + flatEval n (sineL e z) = (z-z⁻¹)/(2*Complex.I) := by + simp [sineL, div_eq_mul_inv] + +theorem phase_ne_zero : phase ≠ 0 := Complex.exp_ne_zero _ + +theorem phase_pow (k : ℤ) : phase^k = Complex.exp ((k:ℂ)*lambda*Complex.I) := by + rw [phase, ← Complex.exp_int_mul] + congr 1 + ring + +theorem phase_sine (k : ℤ) : (phase^k-(phase^k)⁻¹)/(2*Complex.I) = + (Real.sin ((k:ℝ)*lambda) : ℂ) := by + rw [phase_pow, Complex.ofReal_sin] + push_cast + rw [Complex.sin, ← Complex.exp_neg] + field_simp + simp [Complex.I_sq] + +@[simp] theorem flatEval_sine_phase {n : ℕ} (e : Fin n → ℤ) (k : ℤ) : + flatEval n (sineL e (phase^k)) = (Real.sin ((k:ℝ)*lambda) : ℂ) := by + rw [flatEval_sine, phase_sine] + +theorem variableF_ne_zero {n : ℕ} (i : Fin n) : variableF i ≠ 0 := by + apply (IsFractionRing.to_map_eq_zero_iff.not).2 + simp [AddMonoidAlgebra.single_eq_zero] + +theorem map_monomialL_factor {n : ℕ} (e : Fin n → ℤ) (z : ℂ) : + algebraMap (SpectralRing n) (SpectralField n) (monomialL e z) = + constF n z * algebraMap (SpectralRing n) (SpectralField n) (monomialL e 1) := by + rw [← map_constantL, ← map_mul] + congr 1 + change monomialL e z = monomialL 0 z * monomialL e 1 + simp + +theorem map_monomialL_variable {n : ℕ} (i : Fin n) (z : ℂ) : + algebraMap (SpectralRing n) (SpectralField n) (monomialL (variableExponent i) z) = + constF n z * variableF i := map_monomialL_factor _ z + +theorem map_monomialL_neg_variable {n : ℕ} (i : Fin n) (z : ℂ) : + algebraMap (SpectralRing n) (SpectralField n) (monomialL (-variableExponent i) z) = + constF n z / variableF i := by + rw [map_monomialL_factor, div_eq_mul_inv] + congr 1 + symm + simpa only [variableF, monomialL, inv_one] using + map_monomialL_inv (variableExponent i) 1 one_ne_zero + +theorem constF_phase_ne_zero (n : ℕ) : constF n phase ≠ 0 := by + exact (map_ne_zero (algebraMap ℂ (SpectralField n))).mpr phase_ne_zero + +theorem map_sine_variable {n : ℕ} (i : Fin n) (k : ℤ) : + algebraMap (SpectralRing n) (SpectralField n) (sineL (variableExponent i) (phase^k)) = + torusSin (constF n phase ^ k * variableF i) := by + rw [sineL_map _ _ (zpow_ne_zero _ phase_ne_zero), map_monomialL_variable] + congr 2 + exact map_zpow₀ (algebraMap ℂ (SpectralField n)) phase k + +theorem map_sine_neg_variable {n : ℕ} (i : Fin n) (k : ℤ) : + algebraMap (SpectralRing n) (SpectralField n) (sineL (-variableExponent i) (phase^k)) = + torusSin (constF n phase ^ k / variableF i) := by + rw [sineL_map _ _ (zpow_ne_zero _ phase_ne_zero), map_monomialL_neg_variable] + congr 2 + exact map_zpow₀ (algebraMap ℂ (SpectralField n)) phase k + +theorem map_sine_variable_nat {n : ℕ} (i : Fin n) (k : ℕ) : + algebraMap (SpectralRing n) (SpectralField n) (sineL (variableExponent i) (phase^k)) = + torusSin (constF n phase ^ k * variableF i) := by + rw [sineL_map _ _ (pow_ne_zero _ phase_ne_zero), map_monomialL_variable] + congr 2 + exact map_pow (algebraMap ℂ (SpectralField n)) phase k + +theorem map_sine_neg_variable_nat {n : ℕ} (i : Fin n) (k : ℕ) : + algebraMap (SpectralRing n) (SpectralField n) (sineL (-variableExponent i) (phase^k)) = + torusSin (constF n phase ^ k / variableF i) := by + rw [sineL_map _ _ (pow_ne_zero _ phase_ne_zero), map_monomialL_neg_variable] + congr 2 + exact map_pow (algebraMap ℂ (SpectralField n)) phase k + + + +def rowDenominator {n : ℕ} (i : Fin n) : Laurent n := + sineL (-variableExponent i) (phase^(5:ℤ)) * + sineL (-variableExponent i) (phase^(6:ℤ)) + +def rowNumerator {n : ℕ} (i : Fin n) : Tile → Laurent n + | .vacant => rowDenominator i + | .vertical₀ | .vertical₁ => + constantL n d * sineL (variableExponent i) (phase^(0:ℤ)) + | .diagonal₀ | .diagonal₁ => + sineL (-variableExponent i) (phase^(3:ℤ)) * + sineL (variableExponent i) (phase^(0:ℤ)) + | .cap | .cup => constantL n d * sineL (-variableExponent i) (phase^(3:ℤ)) + | .verticalPair => + sineL (variableExponent i) (phase^(0:ℤ)) * + sineL (variableExponent i) (phase^(-1:ℤ)) + | .capCup => + sineL (-variableExponent i) (phase^(2:ℤ)) * + sineL (-variableExponent i) (phase^(3:ℤ)) + +theorem inlinePrivate0_sin_five_lambda : Real.sin (5*lambda) = Real.sin (3*lambda) := by + rw [show 5*lambda = Real.pi-3*lambda by unfold lambda; ring, Real.sin_pi_sub] +theorem inlinePrivate0_sin_six_lambda : Real.sin (6*lambda) = Real.sin (2*lambda) := by + rw [show 6*lambda = Real.pi-2*lambda by unfold lambda; ring, Real.sin_pi_sub] + +theorem flatEval_rowDenominator {n : ℕ} (i : Fin n) : + flatEval n (rowDenominator i) = + (Real.sin (3*lambda) : ℂ) * (Real.sin (2*lambda) : ℂ) := by + rw [rowDenominator, map_mul, flatEval_sine_phase, flatEval_sine_phase] + norm_num only [Int.cast_ofNat] + rw [inlinePrivate0_sin_five_lambda, inlinePrivate0_sin_six_lambda] + +theorem flatEval_rowDenominator_ne_zero {n : ℕ} (i : Fin n) : + flatEval n (rowDenominator i) ≠ 0 := by + rw [flatEval_rowDenominator] + exact mul_ne_zero (by exact_mod_cast ne_of_gt inlinePrivate0_sin_three_lambda_pos) + (by exact_mod_cast ne_of_gt inlinePrivate0_sin_two_lambda_pos) + +theorem rowDenominator_map {n : ℕ} (i : Fin n) : + algebraMap (SpectralRing n) (SpectralField n) (rowDenominator i) = + torusL (constF n phase ^ 3 / variableF i) := by + simp only [rowDenominator, map_mul, zpow_ofNat, map_sine_neg_variable_nat, torusL] + congr 1 <;> congr 1 <;> ring + +theorem rowDenominator_map_ne_zero {n : ℕ} (i : Fin n) : + algebraMap (SpectralRing n) (SpectralField n) (rowDenominator i) ≠ 0 := by + apply (IsFractionRing.to_map_eq_zero_iff.not).2 + intro h + exact flatEval_rowDenominator_ne_zero i (by rw [h, map_zero]) + +theorem rowNumerator_flatEval {n : ℕ} (i : Fin n) (t : Tile) : + flatEval n (rowNumerator i t) = + flatEval n (rowDenominator i) * (deletionWeights : Weights ℂ).tile t := by + cases t <;> simp only [rowNumerator, map_mul, flatEval_constant, + flatEval_sine_phase, flatEval_rowDenominator, deletionWeights, Weights.tile, + Int.cast_ofNat, Int.cast_zero, zero_mul, Real.sin_zero, Complex.ofReal_zero, + mul_zero, mul_one] + all_goals try rw [d, ← inlinePrivate0_sin_two_lambda] + all_goals ring + +theorem rowNumerator_map {n : ℕ} (i : Fin n) (t : Tile) : + algebraMap (SpectralRing n) (SpectralField n) (rowNumerator i t) = + algebraMap (SpectralRing n) (SpectralField n) (rowDenominator i) * + (spectralWeights n i).tile t := by + let q : SpectralField n := constF n phase + let x : SpectralField n := variableF i + have hq : q ≠ 0 := constF_phase_ne_zero n + have hx : x ≠ 0 := variableF_ne_zero i + have h₃ : q^3 / (q^3/x) = x := by field_simp + have h₂ : q^2 / (q^3/x) = q⁻¹*x := by field_simp + have h₁ : q^3/x/q = q^2/x := by field_simp + have hL : torusL (q^3/x) ≠ 0 := by + simpa only [rowDenominator_map] using rowDenominator_map_ne_zero i + dsimp only [q, x] at h₃ h₂ h₁ hL + cases t <;> + simp only [rowNumerator, map_mul, map_constantL, + zpow_ofNat, map_sine_variable_nat, map_sine_neg_variable_nat, zpow_neg_one, + rowDenominator_map, spectralWeights, torusWeights, Weights.tile] + all_goals try simp only [h₃, h₂, h₁, mul_one] + all_goals field_simp + rw [sineL_map _ _ (one_div_ne_zero phase_ne_zero), map_monomialL_variable] + simp only [constF, one_div, map_inv₀] + rw [mul_comm ((algebraMap ℂ (SpectralField n)) phase)⁻¹, ← div_eq_mul_inv] + + + +theorem spectral_regular (n : ℕ) : VacuumRegular (spectralWeights n) := by + apply regular_of_cleared_specialization + (algebraMap (SpectralRing n) (SpectralField n)) + (IsFractionRing.injective _ _) (flatEval n).toRingHom + rowDenominator rowNumerator (spectralWeights n) (fun _ => deletionWeights) + · exact flatEval_rowDenominator_ne_zero + · exact rowNumerator_map + · exact rowNumerator_flatEval + · unfold VacuumRegular + rw [det_one_nonflat] + · exact one_ne_zero + · intro i j hi + exact (hi (Or.inr rfl)).elim + +theorem spectral_normalizedVacuum_stationary (n : ℕ) : + IsNormalizedStationary (spectralWeights n) (normalizedVacuum (spectralWeights n)) := + normalizedVacuum_stationary _ (spectral_regular n) +end + +end CriticalStrip.Diagram + +end OAI diff --git a/lean/OAI/Combinatorics/StripMass/ReversedConvergence.lean b/lean/OAI/Combinatorics/StripMass/ReversedConvergence.lean new file mode 100644 index 0000000000000000000000000000000000000000..6540de79baa03e081d353e2df8abbc931b2493a0 --- /dev/null +++ b/lean/OAI/Combinatorics/StripMass/ReversedConvergence.lean @@ -0,0 +1,559 @@ +import Mathlib +import OAI.Combinatorics.StripMass.DeformationWeights + +namespace OAI + +/-! Critical honeycomb strip paths, polynomial identities and crossing mass. -/ + + +namespace CriticalStrip.Diagram +noncomputable section +open _root_.Matrix _root_.OAI.Matrix Set +open scoped BigOperators Classical + +lemma L_reflection (u : ℝ) : L (3*lambda-u)=L u := by + have ha : 2*lambda+(3*lambda-u)=Real.pi-(3*lambda+u) := by unfold lambda; ring + have hb : 3*lambda+(3*lambda-u)=Real.pi-(2*lambda+u) := by unfold lambda; ring + unfold L + rw [ha,hb,Real.sin_pi_sub,Real.sin_pi_sub,mul_comm] + +lemma physicalWeights_reflection (u : ℝ) : + physicalWeights (3*lambda-u)= + ⟨(physicalWeights u).U,(physicalWeights u).B,(physicalWeights u).A, + (physicalWeights u).F,(physicalWeights u).E⟩ := by + unfold physicalWeights + dsimp only + rw [L_reflection,show 3*lambda-(3*lambda-u)=u by ring, + show 2*lambda-(3*lambda-u)=u-lambda by ring, + show (3*lambda-u)-lambda=2*lambda-u by ring] + congr 1 <;> ring + +lemma physicalWeights_lambda : physicalWeights lambda=(⟨rho,rho^2,rho^2,rho^2,0⟩ : Weights ℝ) := by + have hh:=physicalWeights_reflection (2*lambda) + rw [show 3*lambda-2*lambda=lambda by ring,physicalWeights_two_lambda] at hh + exact hh + +lemma physicalWeights_lambda_nonneg (s : Tile) : 0≤(physicalWeights lambda).tile s := by + rw [physicalWeights_lambda] + have hrho : 0 simp only [Weights.tile] <;> positivity + +lemma physicalWeights_reverse_pos {t : ℝ} (ht : t∈Ioc 0 lambda) : + 0<(physicalWeights t).A ∧ 0<(physicalWeights t).B ∧ 0<(physicalWeights t).U := by + have hh:=physicalWeights_deformation_pos ht + rw [physicalWeights_reflection] at hh + exact ⟨hh.2.2,hh.2.1,hh.1⟩ + +lemma physicalWeights_reverse_tile_nonneg {t : ℝ} (ht : t∈Icc 0 lambda) + (s : Tile) (hs : ¬s.Occupied 0) : 0≤(physicalWeights t).tile s := by + rcases eq_or_lt_of_le ht.1 with rfl | ht₀ + · rw [physicalWeights_zero] + cases s <;> norm_num [identityWeights,Weights.tile] + · obtain ⟨hA,hB,hU⟩:=physicalWeights_reverse_pos ⟨ht₀,ht.2⟩ + cases s <;> simp_all [Tile.Occupied,Tile.Adj,Tile.edges,Weights.tile] + any_goals positivity + +def augmentedReversedWeights (n : ℕ) : Fin (n+1) → Weights ℝ := + Fin.snoc (fun _ : Fin n=>physicalWeights lambda) northInjectionWeights + +def reverseDeformationAngles (n : ℕ) (t : ℝ) : Fin (n+1) → ℝ := + Fin.cons (3*lambda-t) (fun _=>2*lambda) + +def reverseDeformationWeights (n : ℕ) (t : ℝ) : Fin (n+1+1) → Weights ℝ := + Fin.cons (physicalWeights t) (augmentedReversedWeights n) + +lemma reverseDeformationWeights_eq (n : ℕ) (t : ℝ) : + reverseDeformationWeights n t=Fin.snoc + (fun i=>physicalWeights (3*lambda-reverseDeformationAngles n t i)) northInjectionWeights := by + funext i + refine Fin.cases ?_ (fun j=>?_) i + · change physicalWeights t= + (Fin.snoc (fun i : Fin (n+1)=>physicalWeights (3*lambda-reverseDeformationAngles n t i)) + northInjectionWeights : Fin (n+1+1) → Weights ℝ) ((0 : Fin (n+1)).castSucc) + rw [Fin.snoc_castSucc] + simp only [reverseDeformationAngles,Fin.cons_zero,show 3*lambda-(3*lambda-t)=t by ring] + · rw [reverseDeformationWeights,Fin.cons_succ] + refine Fin.lastCases ?_ (fun j=>?_) j + · rw [augmentedReversedWeights,Fin.snoc_last,Fin.succ_last,Fin.snoc_last] + · rw [augmentedReversedWeights,Fin.snoc_castSucc,Fin.succ_castSucc,Fin.snoc_castSucc] + simp only [reverseDeformationAngles,Fin.cons_succ,show 3*lambda-2*lambda=lambda by ring] + +lemma reverseDeformationWeights_physical (n : ℕ) : + reverseDeformationWeights n lambda=augmentedReversedWeights (n+1) := by + rw [reverseDeformationWeights_eq] + congr 1 + funext i + refine Fin.cases ?_ (fun j=>?_) i <;> + simp only [reverseDeformationAngles,Fin.cons_zero,Fin.cons_succ, + show 3*lambda-(3*lambda-lambda)=lambda by ring,show 3*lambda-2*lambda=lambda by ring] + +lemma reverseDeformationWeights_flat (n : ℕ) : reverseDeformationWeights n 0 0=identityWeights := by + simp [reverseDeformationWeights,physicalWeights_zero] + +lemma augmentedReversed_tile_nonneg (n : ℕ) (i : Fin (n+1)) (s : Tile) : + 0≤(augmentedReversedWeights n i).tile s := by + refine Fin.lastCases ?_ (fun j=>?_) i + · simpa only [augmentedReversedWeights,Fin.snoc_last] using northInjection_nonneg s + · simpa only [augmentedReversedWeights,Fin.snoc_castSucc] using physicalWeights_lambda_nonneg s + +lemma reverseDeformationWeights_nonnegative (n : ℕ) {t : ℝ} (ht : t∈Icc 0 lambda) : + ColumnNonnegative (reverseDeformationWeights n t) := by + intro p q s hs + apply Finset.prod_nonneg + intro i _ + refine Fin.cases ?_ (fun j=>?_) i + · exact physicalWeights_reverse_tile_nonneg ht (s 0) (hs.south 0 rfl) + · exact augmentedReversed_tile_nonneg n j (s j.succ) + +lemma physicalWeights_lambda_pos : + 0<(physicalWeights lambda).A ∧ 0<(physicalWeights lambda).B ∧ 0<(physicalWeights lambda).U := + physicalWeights_reverse_pos ⟨lambda_pos,le_rfl⟩ + +lemma reverseDeformationWeights_accessible (n : ℕ) {t : ℝ} (ht : t∈Ioc 0 lambda) : + PositiveMatrix.Accessible (restrictedColumn (reverseDeformationWeights n t)) + (injectionColumn (reverseDeformationWeights n t)) := by + apply column_accessible _ (reverseDeformationWeights_nonnegative n ⟨ht.1.le,ht.2⟩) + · intro i + refine Fin.cases ?_ (fun j=>?_) i + · exact (physicalWeights_reverse_pos ht).1 + · refine Fin.lastCases ?_ (fun j=>?_) j + · norm_num [reverseDeformationWeights,augmentedReversedWeights,northInjectionWeights] + · simpa only [reverseDeformationWeights,Fin.cons_succ,augmentedReversedWeights,Fin.snoc_castSucc] + using physicalWeights_lambda_pos.1 + · intro i + refine Fin.cases ?_ (fun j=>?_) i + · exact (physicalWeights_reverse_pos ht).2.1 + · refine Fin.lastCases ?_ (fun j=>?_) j + · norm_num [reverseDeformationWeights,augmentedReversedWeights,northInjectionWeights] + · simpa only [reverseDeformationWeights,Fin.cons_succ,augmentedReversedWeights,Fin.snoc_castSucc] + using physicalWeights_lambda_pos.2.1 + · intro i hi + revert hi + refine Fin.cases ?_ (fun j=>?_) i + · intro _; exact (physicalWeights_reverse_pos ht).2.2 + · revert j + apply Fin.lastCases + · intro hh + simp only [Fin.val_succ,Fin.val_last] at hh + omega + · intro j _ + simpa only [reverseDeformationWeights,Fin.cons_succ,augmentedReversedWeights,Fin.snoc_castSucc] + using physicalWeights_lambda_pos.2.2 + +lemma reverseDeformationAngles_scalar_ne_zero (n : ℕ) {t : ℝ} (ht : t∈Icc 0 lambda) : + angleScalar (reverseDeformationAngles n t)≠0 := by + have hh:=deformationAngles_scalar_ne_zero n ht + rw [angleScalar,angleEvaluation_scalar] at hh ⊢ + have he : (fun i=>(Real.cos (2*reverseDeformationAngles n t i-3*lambda):ℂ))= + (fun i=>(Real.cos (2*deformationAngles n t i-3*lambda):ℂ)) := by + funext i + refine Fin.cases ?_ (fun j=>?_) i + · simp only [reverseDeformationAngles,deformationAngles,Fin.cons_zero, + show 2*(3*lambda-t)-3*lambda= -(2*t-3*lambda) by ring,Real.cos_neg] + · simp only [reverseDeformationAngles,deformationAngles,Fin.cons_succ, + show 2*(2*lambda)-3*lambda=lambda by ring,show 2*lambda-3*lambda= -lambda by ring,Real.cos_neg] + rw [he] + exact hh + +lemma reverseDeformationAngles_L_ne_zero (n : ℕ) {t : ℝ} (ht : t∈Icc 0 lambda) + (i : Fin (n+1)) : L (3*lambda-reverseDeformationAngles n t i)≠0 := by + refine Fin.cases ?_ (fun j=>?_) i + · simp only [reverseDeformationAngles,Fin.cons_zero,show 3*lambda-(3*lambda-t)=t by ring] + rw [←L_reflection t] + exact (L_deformation_pos ht).ne' + · simp only [reverseDeformationAngles,Fin.cons_succ] + rw [L_reflection] + simpa only [show 3*lambda-lambda=2*lambda by ring] using + (L_deformation_pos (t:=lambda) ⟨lambda_pos.le,le_rfl⟩).ne' + +lemma reverseDeformationWeights_stationary (n : ℕ) {t : ℝ} (ht : t∈Icc 0 lambda) : + (restrictedColumn (reverseDeformationWeights n t)).mulVec + (fun p=>angleAugmented (reverseDeformationAngles n t) p.val)+ + injectionColumn (reverseDeformationWeights n t)=fun p=>angleAugmented (reverseDeformationAngles n t) p.val := by + rw [reverseDeformationWeights_eq] + exact angleAugmented_restricted_stationary _ (reverseDeformationAngles_L_ne_zero n ht) + (reverseDeformationAngles_scalar_ne_zero n ht) + +lemma continuousOn_reverseDeformationWeights_tile (n : ℕ) (i : Fin (n+1+1)) (s : Tile) : + ContinuousOn (fun t=>(reverseDeformationWeights n t i).tile s) (Icc 0 lambda) := by + refine Fin.cases ?_ (fun j=>?_) i + · change ContinuousOn (fun t=>(physicalWeights t).tile s) (Icc 0 lambda) + cases s <;> simp only [physicalWeights,Weights.tile] + · exact continuousOn_const + all_goals + apply ContinuousOn.div + · fun_prop + · unfold L; fun_prop + · intro t ht + rw [←L_reflection t] + exact (L_deformation_pos ht).ne' + · change ContinuousOn (fun _ : ℝ=>(augmentedReversedWeights n j).tile s) (Icc 0 lambda) + exact continuousOn_const + +lemma continuousOn_reverseDeformationColumn (n : ℕ) : + ContinuousOn (fun t=>restrictedColumn (reverseDeformationWeights n t)) (Icc 0 lambda) := by + have hh:=continuousOn_column (reverseDeformationWeights n) (continuousOn_reverseDeformationWeights_tile n) + apply continuousOn_pi.mpr + intro p + apply continuousOn_pi.mpr + intro q + exact continuousOn_pi.mp (continuousOn_pi.mp hh p.val) q.val + +lemma continuous_reverseDeformationAngles (n : ℕ) : Continuous (reverseDeformationAngles n) := by + apply continuous_pi + intro i + refine Fin.cases ?_ (fun j=>?_) i + · exact continuous_const.sub continuous_id + · exact continuous_const + +lemma continuousOn_reverseDeformationVector (n : ℕ) : + ContinuousOn (fun t=>fun p : NonemptyPairing (n+1+1)=>angleAugmented (reverseDeformationAngles n t) p.val) + (Icc 0 lambda) := by + have hc:=continuousOn_angleAugmented (S:=reverseDeformationAngles n '' Icc 0 lambda) (by + rintro u ⟨t,ht,rfl⟩ + exact reverseDeformationAngles_scalar_ne_zero n ht) + have hh:=hc.comp (continuous_reverseDeformationAngles n).continuousOn (fun t ht=>⟨t,ht,rfl⟩) + apply continuousOn_pi.mpr + intro p + exact continuousOn_pi.mp hh p.val + +lemma summablePowers_identity_bottom {n : ℕ} (w : Fin (n+1) → Weights ℝ) + (hzero : w 0=identityWeights) (hw : ColumnNonnegative w) + (hs : PositiveMatrix.SummablePowers (restrictedColumn (fun i=>w i.succ))) : + PositiveMatrix.SummablePowers (restrictedColumn w) := by + let e:=Pairing.nonemptyBottomSplit n + apply (PositiveMatrix.summablePowers_reindex_iff _ e).mp + apply PositiveMatrix.summablePowers_of_zero_rows + · exact fun i j=>hw.restricted (e i) (e j) + · have he : ((restrictedColumn w).submatrix e e).toBlocks₁₁= + restrictedColumn (fun i=>w i.succ) := by + ext q p + exact column_padBottom w p.val q.val + rw [he] + exact hs + · intro q i + exact column_identity_bottom_row w hzero (e i).val q.val.val (not_not.mp q.property) + + + +theorem augmentedReversed_summablePowers (n : ℕ) : + PositiveMatrix.SummablePowers (restrictedColumn (augmentedReversedWeights n)) := by + induction n with + | zero => + intro p + exact (p.property (Pairing.eq_empty_of_le_one (by omega) p.val)).elim + | succ n ih => + rw [←reverseDeformationWeights_physical] + apply PositiveMatrix.summablePowers_on_Icc + (fun t=>restrictedColumn (reverseDeformationWeights n t)) + (fun t=>injectionColumn (reverseDeformationWeights n t)) + (fun t=>fun p=>angleAugmented (reverseDeformationAngles n t) p.val) + lambda_pos.le (continuousOn_reverseDeformationColumn n) (continuousOn_reverseDeformationVector n) + (fun t ht=>(reverseDeformationWeights_nonnegative n ht).restricted) + (fun t ht=>(reverseDeformationWeights_nonnegative n ht).injection) + (fun t ht=>reverseDeformationWeights_stationary n ht) + ?_ (fun t ht=>reverseDeformationWeights_accessible n ht) + lambda ⟨lambda_pos.le,le_rfl⟩ + apply summablePowers_identity_bottom _ (reverseDeformationWeights_flat n) + (reverseDeformationWeights_nonnegative n ⟨le_rfl,lambda_pos.le⟩) + simpa only [reverseDeformationWeights,Fin.cons_succ] using ih + +end + + + + + +noncomputable section +open scoped Classical +namespace Tile + + + +def horizontalPort : Equiv.Perm (Fin 4) := Equiv.swap 1 2 + +def horizontal : Tile → Tile + | .vertical₀ => .cap + | .vertical₁ => .cup + | .cap => .vertical₀ + | .cup => .vertical₁ + | .verticalPair => .capCup + | .capCup => .verticalPair + | t => t + +@[simp] lemma horizontal_involutive (t : Tile) : t.horizontal.horizontal=t := by cases t <;> rfl + +lemma horizontal_adj (t : Tile) (a b : Fin 4) : + t.horizontal.Adj (horizontalPort a) (horizontalPort b) ↔ t.Adj a b := by + revert t a b + decide + +lemma horizontal_occupied (t : Tile) (a : Fin 4) : + t.horizontal.Occupied (horizontalPort a) ↔ t.Occupied a := by + revert t a + decide + +lemma horizontal_weight (w : Weights ℝ) (t : Tile) : + (⟨w.U,w.B,w.A,w.F,w.E⟩ : Weights ℝ).tile t.horizontal = w.tile t := by + cases t <;> rfl + +lemma physical_horizontal_weight (u : ℝ) (t : Tile) : + (physicalWeights (3*lambda-u)).tile t.horizontal=(physicalWeights u).tile t := by + rw [physicalWeights_reflection,horizontal_weight] + +lemma physical_horizontal_weight_two (t : Tile) : + (physicalWeights (2*lambda)).tile t.horizontal=(physicalWeights lambda).tile t := by + simpa only [show 3*lambda-lambda=2*lambda by ring] using physical_horizontal_weight lambda t + + + +lemma physical_horizontal (t : Tile) : t.horizontal≠.verticalPair ↔ t≠.capCup := by + cases t <;> decide + +end Tile +end +end CriticalStrip.Diagram + + + + + +namespace CriticalStrip +noncomputable section +open scoped Classical +open Diagram + +namespace Diagram.Tile + + +def representative (t : Tile) (upper : Bool) : Fin 4 := + if upper then if t.Occupied 0 then 0 else 1 + else if t.Occupied 2 then 2 else 3 + +lemma representative_side (t : Tile) (b : Bool) : + decide ((t.representative b).val<2)=b := by + cases b <;> simp [representative] <;> split <;> decide + +lemma representative_occupied (t : Tile) (ht : t≠.verticalPair) (b : Bool) : + t.Occupied (t.representative b) ↔ if b then t.upperUsed else t.lowerUsed := by + revert t b + decide + +lemma occupied_triangle (t : Tile) (ht : t≠.verticalPair) (p : Fin 4) (hp : t.Occupied p) : + if decide (p.val<2) then t.upperUsed = true else t.lowerUsed = true := by + revert t p + decide + +lemma reach_representative (t : Tile) (ht : t≠.verticalPair) (p : Fin 4) (hp : t.Occupied p) : + Relation.ReflTransGen t.Adj p (t.representative (decide (p.val<2))) := by + cases t <;> fin_cases p <;> + simp_all [representative,Tile.Occupied,Tile.Adj,Tile.edges] + all_goals first | exact .refl | exact .single (by decide) + +lemma reach_middle (t : Tile) (ht : t≠.verticalPair) (hm : t.middle) : + Relation.ReflTransGen t.Adj (t.representative true) (t.representative false) := by + cases t <;> simp_all [middle,representative,Tile.Occupied,Tile.Adj,Tile.edges] + all_goals exact .single (by decide) + +lemma adjacent_projects (t : Tile) (ht : t≠.verticalPair) (a b : Fin 4) (h : t.Adj a b) : + decide (a.val<2)=decide (b.val<2) ∨ t.middle := by + revert t a b + decide +end Diagram.Tile + +abbrev HoneycombPort := Cell × Fin 4 + +def portTriangle (v : HoneycombPort) : Triangle := + (v.1.1,v.1.2,decide (v.2.val<2)) + +namespace HoneycombAssignment +variable {N : ℕ} + + + +def portWiring (D : HoneycombAssignment N) (v w : HoneycombPort) : Prop := + (v.1=w.1 ∧ (D.tile v.1).Adj v.2 w.2) ∨ + (v.1.2=w.1.2 ∧ v.1.1+1=w.1.1 ∧ v.2=2 ∧ w.2=1 ∧ (D.tile v.1).Occupied 2) ∨ + (w.1.2=v.1.2 ∧ w.1.1+1=v.1.1 ∧ w.2=2 ∧ v.2=1 ∧ (D.tile w.1).Occupied 2) ∨ + (v.1.1=w.1.1 ∧ v.1.2+1=w.1.2 ∧ w.1.2D.portWiring_symm⟩ + +lemma port_used (D : HoneycombAssignment N) (v : HoneycombPort) : + Graph.Used D.portWiring v ↔ (D.tile v.1).Occupied v.2 := by + constructor + · rintro ⟨w,h⟩ + rcases v with ⟨⟨i,j⟩,a⟩ + rcases w with ⟨⟨k,l⟩,b⟩ + dsimp only [portWiring,Prod.fst,Prod.snd] at h + rcases h with ⟨_,h⟩ | ⟨_,_,rfl,_,h⟩ | ⟨hj,hi,_,rfl,h⟩ | + ⟨_,_,_,rfl,_,h⟩ | ⟨hi,hj,hn,_,rfl,h⟩ + · exact ⟨b,h⟩ + · exact h + · have hh := (D.horizontal k l).mp h + simpa only [hi,hj] using hh + · exact h + · have hh := (D.vertical k l (by omega)).mp h + simpa only [hi,hj] using hh + · rintro ⟨p,hp⟩ + exact ⟨(v.1,p),Or.inl ⟨rfl,hp⟩⟩ + +lemma port_in_strip (D : HoneycombAssignment N) {q : Cell} {a : Fin 4} + (h : (D.tile q).Occupied a) : q.2(q,a)) (fun _ _ h=>.single (Or.inl ⟨rfl,h⟩)) h + +lemma port_projects_edge (D : HoneycombAssignment N) {v w : HoneycombPort} + (h : D.portWiring v w) : Relation.ReflTransGen D.graph.Adj (portTriangle v) (portTriangle w) := by + rcases v with ⟨⟨i,j⟩,a⟩ + rcases w with ⟨⟨k,l⟩,b⟩ + dsimp only [portWiring,Prod.fst,Prod.snd] at h + rcases h with ⟨he,h⟩ | ⟨hj,hi,ha,hb,h⟩ | ⟨hj,hi,hb,ha,h⟩ | + ⟨hi,hj,hn,ha,hb,h⟩ | ⟨hi,hj,hn,hb,ha,h⟩ + · cases he + rcases Tile.adjacent_projects (D.tile (i,j)) (D.physical (i,j)) a b h with hp | hm + · have : portTriangle ((i,j),a)=portTriangle ((i,j),b) := by + simp only [portTriangle,hp] + exact this ▸ Relation.ReflTransGen.refl + · have hn := D.port_in_strip (show (D.tile (i,j)).Occupied a from ⟨b,h⟩) + have he : D.graph.Adj (up i j) (down i j) := (tileGraph_middle N D.tile i j).mpr ⟨hn,hm⟩ + by_cases ha : a.val<2 <;> by_cases hb : b.val<2 + · simp only [portTriangle,ha,hb,decide_true]; exact .refl + · simpa only [portTriangle,ha,hb,decide_true,decide_false,up,down] using Relation.ReflTransGen.single he + · simpa only [portTriangle,ha,hb,decide_true,decide_false,up,down] using + Relation.ReflTransGen.single (D.graph.symm.symm _ _ he) + · simp only [portTriangle,ha,hb,decide_false]; exact .refl + · subst k; subst l; subst a; subst b + have hh : D.graph.Adj (down i j) (up (i+1) j) := + (D.down_neighbors i j _).mpr ⟨D.port_in_strip h,Or.inr (Or.inl ⟨rfl,h⟩)⟩ + exact .single hh + · subst i; subst j; subst a; subst b + have hh : D.graph.Adj (down k l) (up (k+1) l) := + (D.down_neighbors k l _).mpr ⟨D.port_in_strip h,Or.inr (Or.inl ⟨rfl,h⟩)⟩ + exact .single (D.graph.symm.symm _ _ hh) + · subst k; subst l; subst a; subst b + exact .single ((D.down_neighbors i j _).mpr ⟨by omega,Or.inr (Or.inr ⟨hn,rfl,h⟩)⟩) + · subst i; subst j; subst a; subst b + exact .single (D.graph.symm.symm _ _ + ((D.down_neighbors k l _).mpr ⟨by omega,Or.inr (Or.inr ⟨hn,rfl,h⟩)⟩)) + +def representative (D : HoneycombAssignment N) (v : Triangle) : HoneycombPort := + ((v.1,v.2.1),(D.tile (v.1,v.2.1)).representative v.2.2) + +lemma representative_projects (D : HoneycombAssignment N) (v : Triangle) : + portTriangle (D.representative v)=v := by + rcases v with ⟨i,j,b⟩ + change (i,j,decide (((D.tile (i,j)).representative b).val<2))=(i,j,b) + rw [Tile.representative_side] + +lemma representative_used (D : HoneycombAssignment N) {v : Triangle} + (hv : v∈D.graph.support) : Graph.Used D.portWiring (D.representative v) := by + rw [D.port_used] + rcases v with ⟨i,j,b⟩ + change (D.tile (i,j)).Occupied ((D.tile (i,j)).representative b) + rw [Tile.representative_occupied _ (D.physical (i,j))] + cases b + · exact (D.down_support_iff i j).mp hv + · exact (D.up_support_iff i j).mp hv + +lemma port_to_representative (D : HoneycombAssignment N) {v : HoneycombPort} + (hv : Graph.Used D.portWiring v) : + Relation.ReflTransGen D.portWiring v (D.representative (portTriangle v)) := + D.tile_reach v.1 (Tile.reach_representative _ (D.physical v.1) _ ((D.port_used v).mp hv)) + +lemma edge_between_representatives (D : HoneycombAssignment N) {v w : HoneycombPort} + (h : D.portWiring v w) : Relation.ReflTransGen D.portWiring + (D.representative (portTriangle v)) (D.representative (portTriangle w)) := + ((symm (D.port_to_representative ⟨w,h⟩)).tail h).trans + (D.port_to_representative ⟨v,D.portWiring_symm h⟩) + +lemma up_lifts_edge (D : HoneycombAssignment N) (i : ℤ) (j : ℕ) (w : Triangle) + (h : D.graph.Adj (up i j) w) : + Relation.ReflTransGen D.portWiring (D.representative (up i j)) (D.representative w) := by + rcases (D.up_neighbors i j w).mp h with ⟨hn,⟨rfl,hm⟩ | ⟨rfl,hw⟩ | ⟨hj,rfl,hs⟩⟩ + · exact D.tile_reach (i,j) (Tile.reach_middle _ (D.physical (i,j)) hm) + · have he : (D.tile (i-1,j)).Occupied 2 := by + exact (D.horizontal (i-1) j).mpr (by simpa only [sub_add_cancel] using hw) + exact D.edge_between_representatives (v:=((i,j),1)) (w:=((i-1,j),2)) + (Or.inr (Or.inr (Or.inl ⟨rfl,by dsimp; omega,rfl,rfl,he⟩))) + · have he : (D.tile (i,j-1)).Occupied 3 := by + have hn' : j-1+1D.port_projects_edge) + · intro h + exact ((D.port_to_representative hv).trans + (Graph.map_reach D.representative (fun _ _=>D.lifts_edge) h)).trans + (symm (D.port_to_representative hw)) + + + +lemma port_drains_iff (D : HoneycombAssignment N) {root : HoneycombPort} + (hr : Graph.Used D.portWiring root) : + Graph.DrainsAt D.portWiring root ↔ Graph.DrainsAt D.graph.Adj (portTriangle root) := by + constructor + · intro h v w hvw + obtain ⟨a,ha⟩ := D.representative_used (show v∈D.graph.support from ⟨w,hvw⟩) + have hh := Graph.map_reach portTriangle (fun _ _=>D.port_projects_edge) (h _ _ ha) + simpa only [D.representative_projects] using hh + · intro h v w hvw + have hv := D.port_projects_used (show Graph.Used D.portWiring v from ⟨w,hvw⟩) + obtain ⟨a,ha⟩ := hv + exact (D.port_reach_iff ⟨w,hvw⟩ hr).mpr (h _ _ ha) + +end HoneycombAssignment +end +end CriticalStrip + +end OAI diff --git a/lean/OAI/Combinatorics/StripMass/RibbonGlobal.lean b/lean/OAI/Combinatorics/StripMass/RibbonGlobal.lean new file mode 100644 index 0000000000000000000000000000000000000000..3fca3a85581219e73dd9a4f5edb3c749731b1623 --- /dev/null +++ b/lean/OAI/Combinatorics/StripMass/RibbonGlobal.lean @@ -0,0 +1,563 @@ +import Mathlib +import OAI.Combinatorics.StripMass.BridgeUnfold +import OAI.Combinatorics.StripMass.RibbonWalk + +namespace OAI + +/-! Critical honeycomb strip paths, polynomial identities and crossing mass. -/ + + +namespace CriticalStrip +noncomputable section +namespace HoneycombBranch +open scoped Classical +section TreeMass +open Diagram FiniteBranchTree + + +def bottom (i : ℤ) : State := ((i,0,true),0) +def top (H : ℕ) (i : ℤ) : State := ((i,(H:ℤ)-1,false),0) + +lemma finite_columns (p : List Vertex) (i j : ℤ) : + ∃ L : ℤ, ∃ M : ℕ, 1 ≤ M ∧ L ≤ i ∧ i < L + (M:ℤ) ∧ L ≤ j ∧ j < L + (M:ℤ) ∧ + ∀v∈p,L≤v.1 ∧ v.1v.1.natAbs) + have hb (v : Vertex) (hv : v∈F) : -(B:ℤ)≤v.1 ∧ v.1<(B:ℤ)+1 := by + have hh:=Finset.le_sup (f:=fun v : Vertex=>v.1.natAbs) hv + have h₁:=(Int.le_natAbs : v.1 ≤ (v.1.natAbs : ℤ)) + have h₂:=(Int.le_natAbs : -v.1 ≤ ((-v.1).natAbs : ℤ)) + rw [Int.natAbs_neg] at h₂ + change v.1.natAbs≤B at hh + omega + have hi:=hb (bottom i).1 (by simp [F]) + have hj:=hb (bottom j).1 (by simp [F]) + dsimp only [bottom,Prod.fst] at hi hj + refine ⟨-(B:ℤ),2*B+1,by omega,by omega,by omega,by omega,by omega,?_⟩ + intro v hv + have hh:=hb v (by simp only [F,List.mem_toFinset,List.mem_cons]; tauto) + constructor <;> omega + +lemma finite_rows (p : List Vertex) : ∃N : ℕ,1≤N ∧ ∀v∈p,v.2.1<(N:ℤ) := by + let B:=p.toFinset.sup (fun v=>v.2.1.natAbs) + refine ⟨B+1,by omega,?_⟩ + intro v hv + have hh:=Finset.le_sup (f:=fun v : Vertex=>v.2.1.natAbs) (List.mem_toFinset.mpr hv) + have ha:=(Int.le_natAbs : v.2.1 ≤ (v.2.1.natAbs : ℤ)) + change v.2.1.natAbs≤B at hh + omega + + + +theorem bottom_turn (i j : ℤ) (l : List Bool) (hl : l≠[]) + (hr : RibbonSimple (bottom i) l) + (hrow : ∀v∈visited Prod.fst next (bottom i) l,0≤v.2.1) + (ht : terminal next (bottom i) l=back (bottom j)) : + turn l=if i≤j then -3 else 3 := by + obtain ⟨L,M,hM,hi₁,hi₂,hj₁,hj₂,hcol⟩:=finite_columns (visited Prod.fst next (bottom i) l) i j + obtain ⟨N,hN,hupper⟩:=finite_rows (visited Prod.fst next (bottom i) l) + let c₀ : Fin M:=⟨(i-L).toNat,by omega⟩ + let c₁ : Fin M:=⟨(j-L).toNat,by omega⟩ + have he₀ : (RibbonRectangle.vertex L M N c₀ ⟨0,by omega⟩ true,0)=bottom i := by + dsimp [RibbonRectangle.vertex,bottom,c₀] + congr 2 + omega + have he₁ : (RibbonRectangle.vertex L M N c₁ ⟨0,by omega⟩ true,0)=bottom j := by + dsimp [RibbonRectangle.vertex,bottom,c₁] + congr 2 + omega + have hh:=RibbonRectangle.bottom_turn hM hN c₀ c₁ l hl + (by rw [he₀]; exact hr) (by + rw [he₀] + intro x hx + have hm:=passes_mem_vertex hx + exact ⟨(hcol _ hm).1,(hcol _ hm).2,hrow _ hm,hupper _ hm⟩) + (by rw [he₀,he₁]; exact ht) + rw [hh] + have he : c₀≤c₁ ↔ i≤j := by dsimp [c₀,c₁]; simp only [Fin.le_iff_val_le_val]; omega + simp only [he] + +lemma closed_cycle_true_turn (i : ℤ) (stem tail : List Bool) + (hn : (visited Prod.fst next (bottom i) (stem++true::tail)).Nodup) + (hrow : ∀v∈visited Prod.fst next (bottom i) (stem++true::tail),0≤v.2.1) + (hc : terminal next (bottom i) (stem++true::tail)= + ((terminal next (bottom i) stem).1,outgoing (terminal next (bottom i) stem).2 false)) : + turn (true::tail)= -4 := by + have hh:=bottom_turn i i (closeStem stem tail) (by simp [closeStem]) + (closeStem_simple _ stem tail hn hc) + (fun v hv=>hrow v (closeStem_visits _ stem tail hc v hv)) + (closeStem_terminal _ stem tail hc) + rw [ite_eq_left le_rfl,closeStem_turn] at hh + omega + + + +theorem collision_cycle_turn (D : Finset Vertex) (i : ℤ) (stem : List Bool) + (b : Bool) (tail : List Bool) (hD : ∀v∈D,0≤v.2.1) + (hl : stem++b::tail∈words D (bottom i)) + (hc : (terminal next (bottom i) (stem++b::tail)).1=(terminal next (bottom i) stem).1) : + turn (b::tail)%8=4 := by + have hs : (back (bottom i)).1∉D := by + intro h + have hh:=hD _ h + norm_num [bottom,back,neighbor] at hh + have hn:=visited_nodup Prod.fst next hl + have hrow:=fun v hv=>hD v (visited_mem_domain Prod.fst next hl v hv) + have h₀:=collision_port_not_stem D (bottom i) stem b tail hs hl hc + have hn' : (visited Prod.fst next (terminal next (bottom i) stem) (b::tail)).Nodup := by + rw [visited_append] at hn + exact hn.of_append_right + have hc' := hc + rw [terminal_append] at hc' + have h₁:=collision_port_not_first _ b tail hn' hc' + have hq:=third_port (terminal next (bottom i) stem).2 + (terminal next (bottom i) (stem++b::tail)).2 b h₀ (by simpa only [terminal_append] using h₁) + cases b with + | true=> + have ht:=closed_cycle_true_turn i stem tail hn hrow (Prod.ext hc hq) + rw [ht] + decide + | false=> + have hcfull : (terminal next (bottom i) (stem++false::tail)).1∈D := by + rw [hc] + apply visited_mem_domain Prod.fst next hl + rw [visited_append] + exact List.mem_append_right _ List.mem_cons_self + have hr:=prefix_reverseCycle_mem D (bottom i) stem false tail hl hc h₀ (by simpa only [terminal_append] using h₁) + have ht:=terminal_reverseCycle (terminal next (bottom i) stem) false tail hc' + (by simpa only [terminal_append] using h₀) h₁ + have he : terminal next (bottom i) (stem++true::reverseTurns tail)= + ((terminal next (bottom i) stem).1,outgoing (terminal next (bottom i) stem).2 false) := by + rw [terminal_append] + exact ht + have hh:=closed_cycle_true_turn i stem (reverseTurns tail) + (visited_nodup Prod.fst next hr) + (fun v hv=>hD v (visited_mem_domain Prod.fst next hr v hv)) he + change turn (reverseCycle (false::tail))= -4 at hh + rw [turn_reverseCycle] at hh + omega + + + +theorem collisionMass_zero (D : Finset Vertex) (i : ℤ) (hD : ∀v∈D,0≤v.2.1) : + collisionMass Prod.fst next factor D (bottom i)=0 := by + apply collisionMass_zero_of_turns + · intro h + have hh:=hD _ h + norm_num [bottom,back,neighbor] at hh + · intro l hl ht + obtain ⟨stem,b,tail,rfl,hc⟩:=collision_split D (bottom i) l hl ht + have he : collisionIndex (bottom i) (stem++b::tail)=stem.length := by + rw [collisionIndex,hc,collision_index_eq _ _ _ _ (visited_nodup Prod.fst next hl)] + rw [he,List.drop_left] + exact collision_cycle_turn D i stem b tail hD hl hc + +theorem finite_boundary_flux (D : Finset Vertex) (i : ℤ) (hD : ∀v∈D,0≤v.2.1) : + exitMass Prod.fst next factor D (bottom i)=1 := by + have h:=exit_plus_collision D (bottom i) + rwa [collisionMass_zero D i hD,add_zero] at h + +end TreeMass + +section BoundaryConnection +open Diagram Diagram.TurnNetwork Diagram.TurnDisk FiniteBranchTree +namespace RibbonRectangle +variable {L : ℤ} {M N : ℕ} (hM : 1≤M) (hN : 1≤N) + +lemma top_outside (c : Fin M) : + ¬Inside L M N (back (vertex L M N c ⟨N-1,by omega⟩ false,0)).1 := by + have he : ((N-1:ℕ):ℤ)+1=(N:ℤ) := by omega + simp [Inside,back,neighbor,vertex,he] + +include hM in +lemma top_turn (c₀ c₁ : Fin M) (l : List Bool) (hl : l≠[]) + (hr : RibbonSimple (vertex L M N c₀ ⟨0,by omega⟩ true,0) l) + (hI : ∀x∈passes (vertex L M N c₀ ⟨0,by omega⟩ true,0) l,Inside L M N x.1.1) + (ht : terminal next (vertex L M N c₀ ⟨0,by omega⟩ true,0) l= + back (vertex L M N c₁ ⟨N-1,by omega⟩ false,0)) : turn l=0 := by + let s : State:=(vertex L M N c₀ ⟨0,by omega⟩ true,0) + have hm:=ribbon_matches (L:=L) (M:=M) (N:=N) hr (bottom_outside hN c₀) + (by rw [ht]; exact top_outside hN c₁) + have hi:=bottom_connector hM hN (ribbon hr) hm c₀ 0 (first_occupied s l hl hr) + have heV : (back (terminal next s l)).1=vertex L M N c₁ ⟨N-1,by omega⟩ false := by rw [ht,back_back] + have heP : (terminal next s l).2=0 := by rw [ht]; rfl + have heNode : node L M N (last_inside s l hl hI) + (lane (back (terminal next s l)).1.2.2 (terminal next s l).2 1)= + node L M N (vertex_inside L M N c₁ ⟨N-1,by omega⟩ false) (lane false 0 1) := by + rw [node_of_vertex _ heV,at_vertex,heV,heP] + rfl + have hbd : boundary (L:=L) hM hN (ribbon hr) (TurnRectangle.northSlot hM hN c₁.isLt 1)= + node L M N (last_inside s l hl hI) + (lane (back (terminal next s l)).1.2.2 (terminal next s l).2 1) := by + rw [heNode,top_boundary] + have hlt : bottomIndex (N:=N) c₀ 0 < TurnRectangle.northSlot hM hN c₁.isLt 1 := by + have hh:=bottomIndex_lt (N:=N) c₀ 0 + rw [Fin.lt_def,TurnRectangle.northSlot_val] + omega + have hh:=endpoint_turn hM hN s l hl hr (vertex_inside _ _ _ _ _ _) hI hm + (bottomIndex c₀ 0) (TurnRectangle.northSlot hM hN c₁.isLt 1) (ne_of_lt hlt) hi.1 + (by rw [hbd]) + (fun P hP=>⟨hi.2 P hP,by rw [hbd,sub_self]⟩) + rw [hh,Pairing.arcTurn,bottom_gauge,top_gauge,Pairing.turnOrder,ite_eq_left hlt] + norm_num + +end RibbonRectangle + + +theorem top_turn (H : ℕ) (hH : 1≤H) (i j : ℤ) (l : List Bool) (hl : l≠[]) + (hn : (visited Prod.fst next (bottom i) l).Nodup) + (hrow : ∀v∈visited Prod.fst next (bottom i) l,0≤v.2.1 ∧ v.2.1<(H:ℤ)) + (ht : terminal next (bottom i) l=back (top H j)) : turn l=0 := by + obtain ⟨L,M,hM,hi₁,hi₂,hj₁,hj₂,hcol⟩:=finite_columns (visited Prod.fst next (bottom i) l) i j + let c₀ : Fin M:=⟨(i-L).toNat,by omega⟩ + let c₁ : Fin M:=⟨(j-L).toNat,by omega⟩ + have he₀ : (RibbonRectangle.vertex L M H c₀ ⟨0,by omega⟩ true,0)=bottom i := by + dsimp [RibbonRectangle.vertex,bottom,c₀] + congr 2 + omega + have he₁ : (RibbonRectangle.vertex L M H c₁ ⟨H-1,by omega⟩ false,0)=top H j := by + dsimp [RibbonRectangle.vertex,top,c₁] + congr 2 + · omega + · ext <;> dsimp + omega + apply RibbonRectangle.top_turn hM hH c₀ c₁ l hl + (by rw [he₀]; exact ribbonSimple_of_nodup hn) (by + rw [he₀] + intro x hx + have hm:=passes_mem_vertex hx + exact ⟨(hcol _ hm).1,(hcol _ hm).2,(hrow _ hm).1,(hrow _ hm).2⟩) + (by rw [he₀,he₁]; exact ht) + +end BoundaryConnection + +open FiniteBranchTree + + + +lemma word_unique (s : State) (l m : List Bool) + (hv : visited Prod.fst next s l=visited Prod.fst next s m) + (ht : terminal next s l=terminal next s m) : l=m := by + induction l generalizing s m with + | nil=> + have hh:=congrArg List.length hv + have hm : m.length=0 := by simpa only [visited_length,List.length_nil] using hh.symm + exact (List.eq_nil_of_length_eq_zero hm).symm + | cons b l ih=> + cases m with + | nil=>have hh:=congrArg List.length hv; simp only [visited_length,List.length_cons,List.length_nil] at hh; omega + | cons c m=> + have htail : visited Prod.fst next (next s b) l=visited Prod.fst next (next s c) m := (List.cons.inj hv).2 + have hlen : l.length=m.length := by simpa only [visited_length] using congrArg List.length htail + have hbc : b=c := by + apply next_injective s + by_cases hl : l=[] + · have hm : m=[] := by apply List.eq_nil_of_length_eq_zero; simpa only [hl,List.length_nil] using hlen.symm + simpa only [hl,hm,terminal] using congrArg Prod.fst ht + · have hm : m≠[] := by intro hh; apply hl; apply List.eq_nil_of_length_eq_zero; simpa only [hh,List.length_nil] using hlen + have hh:=congrArg List.head? htail + rw [visited_head _ _ _ _ hl,visited_head _ _ _ _ hm] at hh + exact Option.some.inj hh + subst c + exact congrArg (List.cons b) (ih (next s b) m htail ht) + + + +lemma exists_word (s t : State) (p : List Vertex) + (hh : p.head?=some s.1) (hl : p.getLast?=some (back t).1) + (hn : p.Nodup) (hc : p.IsChain (fun v w=>∃q : Fin 3,neighbor v q=w)) + (hi : (back s).1∉p) (ho : t.1∉p) (hne : s≠back t) : + ∃l : List Bool, visited Prod.fst next s l=p ∧ terminal next s l=t := by + induction p generalizing s with + | nil=>simp only [List.head?_nil,reduceCtorEq] at hh + | cons v p ih=> + have he : v=s.1 := Option.some.inj hh + subst v + cases p with + | nil=> + have hs : s.1=(back t).1 := by simpa only [List.getLast?_cons,List.getLast?_nil,Option.getD_none,Option.some.injEq] using hl + have hport : t.2≠s.2 := by + intro ht + exact hne (Prod.ext hs ht.symm) + obtain ⟨b,hb,_⟩:=outgoing_exhaust s.2 t.2 hport + refine ⟨[b],rfl,?_⟩ + change next s b=t + dsimp [next] + rw [hb,hs] + exact back_back t + | cons w p=> + have had : ∃q : Fin 3,neighbor s.1 q=w := (List.isChain_cons_cons.mp hc).1 + obtain ⟨q,hq⟩:=had + have hqne : q≠s.2 := by + intro he + have hew : w=(back s).1 := by rw [←hq,he]; rfl + exact hi (hew ▸ List.mem_cons_of_mem _ List.mem_cons_self) + obtain ⟨b,hb,_⟩:=outgoing_exhaust s.2 q hqne + have hnext : (next s b).1=w := by dsimp [next]; rw [hb,hq] + have hsnew : next s b≠back t := by + intro he + have hh : t.1=s.1 := by + have he':=congrArg back he + rw [back_back,back_next] at he' + exact (congrArg Prod.fst he').symm + exact ho (hh ▸ List.mem_cons_self) + obtain ⟨l,hv,ht⟩:=ih (next s b) (by simp only [List.head?_cons,hnext]) + (by simpa only [List.getLast?_cons_cons] using hl) hn.tail + (List.isChain_cons_cons.mp hc).2 + (by rw [back_next]; exact (List.nodup_cons.mp hn).1) + (fun h=>ho (List.mem_cons_of_mem _ h)) hsnew + exact ⟨b::l,by simp only [visited,hv],ht⟩ + +lemma word_nonempty_of_head (s : State) (l : List Bool) (p : List Vertex) + (hh : p.head?=some s.1) (hv : visited Prod.fst next s l=p) : l≠[] := by + intro hl + subst l + change []=p at hv + rw [←hv,List.head?_nil] at hh + contradiction + +lemma word_terminal_ne_source {s : State} {l : List Bool} (hl : l≠[]) + (hn : (visited Prod.fst next s l).Nodup) : terminal next s l≠back s := by + cases l with + | nil=>exact (hl rfl).elim + | cons b l=> + intro ht + cases l with + | nil=> + have hh:=congrArg Prod.snd ht + exact outgoing_ne s.2 b hh + | cons c l=> + have hm:=lastVisited_mem (next s b) (c::l) (by simp) + change (back (terminal next s (b::c::l))).1∈_ at hm + rw [ht,back_back] at hm + exact (List.nodup_cons.mp hn).1 hm + + + +def retractVertex (v : Vertex) : Triangle := (v.1,v.2.1.toNat,v.2.2) + +lemma retract_embed (v : Triangle) : retractVertex (embedTriangle v)=v := by + rcases v with ⟨i,r,b⟩ + simp [retractVertex,embedTriangle] +lemma embed_retract (v : Vertex) (h : 0≤v.2.1) : embedTriangle (retractVertex v)=v := by + rcases v with ⟨i,r,b⟩ + simp only [retractVertex,embedTriangle,Int.toNat_of_nonneg h] + +lemma visited_head_last (s : State) (l : List Bool) (hl : l≠[]) : + (visited Prod.fst next s l).head?=some s.1 ∧ + (visited Prod.fst next s l).getLast?=some (back (terminal next s l)).1 := by + refine ⟨visited_head _ _ _ _ hl,?_⟩ + induction l generalizing s with + | nil=>exact (hl rfl).elim + | cons b l ih=> + cases l with + | nil=>simp only [visited,terminal,back_next,List.getLast?_singleton] + | cons c l=> + simpa only [visited,List.getLast?_cons_cons,terminal] using ih (next s b) (by simp) + +lemma visited_retract_path (H : ℕ) (a b : Triangle) (s : State) (l : List Bool) (hl : l≠[]) + (hs : s.1=embedTriangle a) (ht : (back (terminal next s l)).1=embedTriangle b) + (hn : (visited Prod.fst next s l).Nodup) + (hband : ∀v∈visited Prod.fst next s l,0≤v.2.1 ∧ v.2.1<(H:ℤ)) : + PathBetween H a b ((visited Prod.fst next s l).map retractVertex) := by + have hheads:=visited_head_last s l hl + have he : ((visited Prod.fst next s l).map retractVertex).map embedTriangle=visited Prod.fst next s l := by + rw [List.map_map] + conv_rhs => rw [←List.map_id (visited Prod.fst next s l)] + apply List.map_congr_left + intro v hv + exact embed_retract v (hband v hv).1 + have hc := visited_chain s l + have hc' : (((visited Prod.fst next s l).map retractVertex).map embedTriangle).IsChain + (fun v w=>∃q : Fin 3,neighbor v q=w) := by rw [he]; exact hc + have ha:= (List.isChain_map _).mp hc' + refine ⟨?_,?_,?_,ha.imp (fun v w h=>(adjacent_iff v w).mpr h),?_⟩ + · rw [List.head?_map,hheads.1,Option.map_some,hs,retract_embed] + · rw [List.getLast?_map,hheads.2,Option.map_some,ht,retract_embed] + · apply List.Nodup.of_map (f:=embedTriangle) + rw [he] + exact hn + · intro v hv + obtain ⟨w,hw,rfl⟩:=List.mem_map.mp hv + have hb:=hband w hw + change w.2.1.toNat omega⟩ + let z : Fin (2*H):=⟨0,by omega⟩ + obtain ⟨w,hw⟩:=((SimpleGraph.pathGraph_preconnected (2*H)) a z).exists_isPath + let f : Fin (2*H)→Triangle:=fun r=>ladderVertex i r.val + have hf : Function.Injective f := (ladderVertex_injective i).comp Fin.val_injective + refine ⟨w.support.map f,⟨?_,?_,hw.support_nodup.map hf,?_,?_⟩,?_,?_⟩ + · simp only [List.head?_map,List.head?_eq_some_head w.support_ne_nil,w.head_support,Option.map_some] + cases b <;> simp [f,a,ladderVertex] + omega + · simp [List.getLast?_map,List.getLast?_eq_some_getLast w.support_ne_nil,w.getLast_support,f,z,ladderVertex,up] + · apply (List.isChain_map _).mpr + apply w.isChain_adj_support.imp + intro v w h + rcases SimpleGraph.pathGraph_adj.mp h with hh|hh + · change adjacent (ladderVertex i v.val) (ladderVertex i w.val) + rw [←hh] + exact ladderVertex_adjacent i _ + · change adjacent (ladderVertex i v.val) (ladderVertex i w.val) + rw [←hh] + exact adjacent_symmetric.symm _ _ (ladderVertex_adjacent i _) + · intro v hv + obtain ⟨r,_,rfl⟩:=List.mem_map.mp hv + change r.val/2 rfl + exact he ▸ ⟨hb.1,hb.2.1⟩ + +lemma path_spec (x : SideWord H i k) : + PathBetween H (up i 0) (retractVertex (back x.state).1) x.path := by + apply visited_retract_path H _ _ (bottom i) x.val x.property.1 rfl + (by apply (embed_retract _ _).symm; exact (x.property.2.2.1 _ (lastVisited_mem _ _ x.property.1)).1) + x.property.2.1 + intro v hv + exact ⟨(x.property.2.2.1 v hv).1,(x.property.2.2.1 v hv).2.1⟩ + +lemma path_no_column (x : SideWord H i k) : ∀v∈x.path,v.1≠k := by + intro v hv + obtain ⟨w,hw,rfl⟩:=List.mem_map.mp hv + exact (x.property.2.2.1 w hw).2.2 + +lemma connector_exists (x : SideWord H i k) : + ∃p : List Triangle, PathBetween H (retractVertex x.state.1) (up k 0) p ∧ + (∀v∈p,v.1=k) ∧ p.length≤2*H := by + have hj : x.state.1.2.1.toNatdecide (v.1≠k))=x.path := by + have hp : x.path.filter (fun v=>decide (v.1≠k))=x.path := + List.filter_eq_self.mpr (fun v hv=>by simpa using x.path_no_column v hv) + have hc : x.connector.filter (fun v=>decide (v.1≠k))=[] := + List.filter_eq_nil_iff.mpr (fun v hv=>by simp [x.connector_spec.2.1 v hv]) + simp only [arch,List.filter_append,hp,hc,List.append_nil] + +lemma path_embed (x : SideWord H i k) : + x.path.map embedTriangle=visited Prod.fst next (bottom i) x.val := by + rw [path,List.map_map] + conv_rhs => rw [←List.map_id (visited Prod.fst next (bottom i) x.val)] + apply List.map_congr_left + intro v hv + exact embed_retract v (x.property.2.2.1 v hv).1 + +lemma arch_injective : Function.Injective (arch (H:=H) (i:=i) (k:=k)) := by + intro x y he + have hp : x.path=y.path := by rw [←x.arch_filter,he,y.arch_filter] + have hv : visited Prod.fst next (bottom i) x.val=visited Prod.fst next (bottom i) y.val := by + rw [←x.path_embed,hp,y.path_embed] + apply Subtype.ext + apply word_unique _ _ _ hv + apply terminal_eq_of_visited x.property.1 y.property.1 hv + exact x.property.2.2.2.1.trans y.property.2.2.2.1.symm + +lemma arch_length (x : SideWord H i k) : x.arch.length≤x.val.length+2*H := by + simp only [arch,List.length_append,path,List.length_map,visited_length] + have :=x.connector_spec.2.2 + omega + +lemma weighted_bound (hik : i≠k) (x : SideWord H i k) : + rho^(2*H)*rho^x.val.length≤betweenArchWeight H i k x.arch := by + rw [betweenArchWeight,ite_eq_left ⟨hik,x.arch_spec⟩,←pow_add] + exact pow_le_pow_of_le_one rho_pos.le BridgePath.rho_le_one (by have:=x.arch_length; omega) + +lemma sum_le (hH : 1≤H) (hik : i≠k) (F : Finset (SideWord H i k)) : + ∑ x∈F,rho^x.val.length ≤ (rho^(2*H))⁻¹*K H (k-i) := by + have hs := (summable_betweenArchWeight_iff H i k).mpr ((stripSumsFinite hH).1 _) + have hi : Summable (fun x : SideWord H i k=>betweenArchWeight H i k x.arch) := + hs.comp_injective arch_injective + have hh : rho^(2*H)*(∑ x∈F,rho^x.val.length)≤K H (k-i) := by + rw [Finset.mul_sum] + calc + _ ≤ ∑ x∈F,betweenArchWeight H i k x.arch := Finset.sum_le_sum (fun x _=>weighted_bound hik x) + _ ≤ ∑' x : SideWord H i k,betweenArchWeight H i k x.arch := + hi.sum_le_tsum F (fun x _=>betweenArchWeight_nonneg _ _ _ _) + _ ≤ ∑' p,betweenArchWeight H i k p := + tsum_comp_le_tsum_of_inj hs (betweenArchWeight_nonneg H i k) arch_injective + _ = K H (k-i) := betweenArchKernel_eq H i k + have hh' : (∑ x∈F,rho^x.val.length)≤K H (k-i)/rho^(2*H) := + (le_div_iff₀ (pow_pos rho_pos _)).mpr (by simpa only [mul_comm] using hh) + simpa only [div_eq_mul_inv,mul_comm] using hh' + +end SideWord +end HoneycombBranch +end +end CriticalStrip + +end OAI diff --git a/lean/OAI/Combinatorics/StripMass/RibbonLocal.lean b/lean/OAI/Combinatorics/StripMass/RibbonLocal.lean new file mode 100644 index 0000000000000000000000000000000000000000..e0db707a16eec30c17a4f3ed4c66f22157e42abd --- /dev/null +++ b/lean/OAI/Combinatorics/StripMass/RibbonLocal.lean @@ -0,0 +1,593 @@ +import Mathlib +import OAI.Combinatorics.StripMass.TurnRectangleMatching + +namespace OAI + +/-! Critical honeycomb strip paths, polynomial identities and crossing mass. -/ + + +namespace CriticalStrip.HoneycombBranch +noncomputable section +open scoped Classical +open Diagram + + +def slot (b : Bool) (p : Fin 3) : Fin 3 := + if b then if p=0 then 1 else if p=1 then 0 else 2 + else if p=0 then 2 else if p=1 then 1 else 0 + + +def lane (b : Bool) (p : Fin 3) (l : Fin 2) : Fin 6 := + ⟨2*(slot b p).val+l.val,by have := (slot b p).isLt; omega⟩ + +def localGauge (b : Bool) : Fin 6 → ℤ := + if b then TurnDisk.Rhombus.upGauge else TurnDisk.Rhombus.downGauge + +lemma slot_injective (b : Bool) : Function.Injective (slot b) := by + intro p q h + cases b <;> fin_cases p <;> fin_cases q <;> simp_all [slot] + +lemma lane_injective (b : Bool) {p q : Fin 3} {l m : Fin 2} : + lane b p l=lane b q m ↔ p=q ∧ l=m := by + constructor + · intro h + have hh:=congrArg Fin.val h + change 2*(slot b p).val+l.val=2*(slot b q).val+m.val at hh + have hs : slot b p=slot b q := Fin.ext (by have := l.isLt; have :=m.isLt; omega) + exact ⟨slot_injective b hs,Fin.ext (by have :=l.isLt; have :=m.isLt; omega)⟩ + · rintro ⟨rfl,rfl⟩; rfl + +lemma lane_cover (b : Bool) (i : Fin 6) : ∃ p l,lane b p l=i := by + cases b <;> fin_cases i <;> decide + +lemma local_turn (b : Bool) (p : Fin 3) (a : Bool) : + Pairing.arcTurn (localGauge b) (lane b p 0) (lane b (outgoing p a) 1)=sign a := by + cases b <;> cases a <;> fin_cases p <;> decide + +end + + + + + +noncomputable section +open scoped Classical +open Diagram FiniteBranchTree + + +def passes (s : State) : List Bool → List (State × Fin 3) + | []=>[] + | b::l=>(s,outgoing s.2 b)::passes (next s b) l + +@[simp] lemma passes_nil (s : State) : passes s []=[] := rfl +@[simp] lemma passes_cons (s : State) (b : Bool) (l : List Bool) : + passes s (b::l)=(s,outgoing s.2 b)::passes (next s b) l := rfl + +lemma passes_vertices (s : State) (l : List Bool) : + (passes s l).map (fun x=>x.1.1)=visited Prod.fst next s l := by + induction l generalizing s with + | nil=>rfl + | cons b l ih=>simp only [passes,List.map_cons,visited,ih] + +lemma passes_append (s : State) (l m : List Bool) : + passes s (l++m)=passes s l++passes (terminal next s l) m := by + induction l generalizing s with + | nil=>rfl + | cons b l ih=>simp only [List.cons_append,passes,terminal,ih] + +lemma passes_shift (s : State) (l : List Bool) : + s::(passes s l).map (fun x=>(neighbor x.1.1 x.2,x.2)) = + (passes s l).map Prod.fst ++ [terminal next s l] := by + induction l generalizing s with + | nil=>rfl + | cons b l ih=> + simp only [passes,List.map_cons,List.cons_append,terminal,List.cons.injEq,true_and] + exact ih (next s b) + +lemma passes_mem_vertex {s : State} {l : List Bool} {v : Vertex} {p q : Fin 3} + (h : ((v,p),q)∈passes s l) : v∈visited Prod.fst next s l := by + rw [←passes_vertices] + exact List.mem_map.mpr ⟨((v,p),q),h,rfl⟩ + +lemma passes_ne {s : State} {l : List Bool} {v : Vertex} {p q : Fin 3} + (h : ((v,p),q)∈passes s l) : q≠p := by + induction l generalizing s with + | nil=>simp only [passes,List.not_mem_nil] at h + | cons b l ih=> + rcases List.mem_cons.mp h with he|h + · have hp := congrArg (fun z : State × Fin 3 => z.1.2) he + have hq := congrArg (fun z : State × Fin 3 => z.2) he + change p=s.2 at hp + change q=outgoing s.2 b at hq + rw [hq,hp] + exact outgoing_ne _ _ + · exact ih h + + +def routes (s : State) (l : List Bool) (v : Vertex) : Finset (Fin 3 × Fin 3) := + Finset.univ.filter (fun pq=>((v,pq.1),pq.2)∈passes s l) + +@[simp] lemma mem_routes (s : State) (l : List Bool) (v : Vertex) (pq : Fin 3 × Fin 3) : + pq∈routes s l v ↔ ((v,pq.1),pq.2)∈passes s l := by simp [routes] + +@[simp] lemma routes_nil (s : State) (v : Vertex) : routes s [] v=∅ := by + ext x; simp + +lemma routes_cons (s : State) (b : Bool) (l : List Bool) (v : Vertex) : + routes s (b::l) v=(if v=s.1 then {(s.2,outgoing s.2 b)} else ∅) ∪ routes (next s b) l v := by + rcases s with ⟨w,p⟩ + ext ⟨i,j⟩ + simp only [mem_routes,passes_cons,List.mem_cons,Prod.mk.injEq,Finset.mem_union] + split_ifs <;> simp_all + +lemma routes_append (s : State) (l m : List Bool) (v : Vertex) : + routes s (l++m) v=routes s l v ∪ routes (terminal next s l) m v := by + ext x; simp [passes_append] + +def swapPass (x : State × Fin 3) : State × Fin 3 := ((x.1.1,x.2),x.1.2) + +lemma passes_reverseTurns (s : State) (l : List Bool) : + passes (back (terminal next s l)) (reverseTurns l)=((passes s l).map swapPass).reverse := by + induction l generalizing s with + | nil=>rfl + | cons b l ih=> + simp only [reverseTurns,List.reverse_cons,List.map_append,List.map_singleton,terminal,passes_append] + change passes (back (terminal next (next s b) l)) (reverseTurns l) ++ + passes (terminal next (back (terminal next (next s b) l)) (reverseTurns l)) [!b]=_ + rw [ih,terminal_reverseTurns] + simp only [passes,List.map_cons,List.reverse_cons,back_next,swapPass,outgoing_opp] + +lemma routes_reverseTurns (s : State) (l : List Bool) (v : Vertex) : + routes (back (terminal next s l)) (reverseTurns l) v = (routes s l v).image Prod.swap := by + ext ⟨p,q⟩ + simp only [mem_routes,passes_reverseTurns,List.mem_reverse,List.mem_map,Finset.mem_image] + constructor + · rintro ⟨⟨⟨w,i⟩,j⟩,hm,he⟩ + change ((w,j),i)=((v,p),q) at he + obtain ⟨⟨rfl,rfl⟩,rfl⟩:=Prod.mk.inj he + exact ⟨(i,p),by simpa using hm,rfl⟩ + · rintro ⟨⟨i,j⟩,hm,he⟩ + obtain ⟨rfl,rfl⟩:=Prod.mk.inj he + exact ⟨_,by simpa using hm,rfl⟩ + +lemma routes_empty_of_notMem {s : State} {l : List Bool} {v : Vertex} + (h : v∉visited Prod.fst next s l) : routes s l v=∅ := by + apply Finset.eq_empty_iff_forall_notMem.mpr + intro x hx + exact h (passes_mem_vertex ((mem_routes _ _ _ _).mp hx)) + +lemma routes_singleton_of_nodup {s : State} {l : List Bool} + (hn : (visited Prod.fst next s l).Nodup) (v : Vertex) : + routes s l v=∅ ∨ ∃ p q, q≠p ∧ routes s l v={(p,q)} := by + induction l generalizing s with + | nil=>exact Or.inl (routes_nil _ _) + | cons b l ih=> + have hn':=(List.nodup_cons.mp hn) + rw [routes_cons] + by_cases hv : v=s.1 + · subst v + rw [ite_eq_left rfl,routes_empty_of_notMem hn'.1,Finset.union_empty] + exact Or.inr ⟨s.2,outgoing s.2 b,outgoing_ne _ _,rfl⟩ + · rw [ite_eq_right hv,Finset.empty_union] + exact ih hn'.2 + + +def ribbonArcs (b : Bool) (a : Finset (Fin 3 × Fin 3)) : Finset (Fin 6 × Fin 6) := + a.image (fun pq=>Pairing.orderedEdge (lane b pq.1 0) (lane b pq.2 1)) + +lemma ribbonArcs_empty (b : Bool) : ribbonArcs b ∅=∅ := by simp [ribbonArcs] +lemma ribbonArcs_union (b : Bool) (a d : Finset (Fin 3 × Fin 3)) : + ribbonArcs b (a∪d)=ribbonArcs b a ∪ ribbonArcs b d := Finset.image_union _ _ + +lemma ribbon_singleton (b : Bool) (p q : Fin 3) : IsPairing (ribbonArcs b {(p,q)}) := by + cases b <;> fin_cases p <;> fin_cases q <;> + simp [IsPairing,ribbonArcs,Pairing.orderedEdge,lane,slot] +lemma ribbon_double (b : Bool) (p q : Fin 3) (h : p≠q) : + IsPairing (ribbonArcs b {(p,q),(q,p)}) := by + cases b <;> fin_cases p <;> fin_cases q <;> + first | exact (h rfl).elim | simp [IsPairing,ribbonArcs,Pairing.orderedEdge,lane,slot] +lemma ribbon_joint (b : Bool) (p : Fin 3) : + IsPairing (ribbonArcs b {(p,outgoing p true),(outgoing p false,p)}) := by + cases b <;> fin_cases p <;> + simp [IsPairing,ribbonArcs,Pairing.orderedEdge,lane,slot,outgoing] + + +def RibbonSimple (s : State) (l : List Bool) : Prop := + ∀ v, IsPairing (ribbonArcs v.2.2 (routes s l v)) + +lemma ribbonSimple_of_nodup {s : State} {l : List Bool} + (hn : (visited Prod.fst next s l).Nodup) : RibbonSimple s l := by + intro v + rcases routes_singleton_of_nodup hn v with he|⟨p,q,_,he⟩ + · rw [he,ribbonArcs_empty]; exact (empty 6).property + · rw [he]; exact ribbon_singleton _ _ _ + +end + + + + + +noncomputable section +open scoped Classical +open Diagram Diagram.TurnNetwork Diagram.TurnDisk +namespace RibbonRectangle +section Geometry + +variable (L : ℤ) (M N : ℕ) + +def Inside (v : Vertex) : Prop := + L≤v.1 ∧ v.1 simpa [neighbor,lane,slot,vertex] using hh + · intro c r hc hr hr0 l + have hv:=vertex_inside L M N (⟨c,hc⟩:Fin M) (⟨r,hr⟩:Fin N) true + have he : neighbor (vertex L M N ⟨c,hc⟩ ⟨r,hr⟩ true) 0= + vertex L M N ⟨c,hc⟩ ⟨r-1,by omega⟩ false := by + dsimp [neighbor,vertex]; congr 2; omega + have hh:=hm _ 0 hv (by rw [he]; exact vertex_inside _ _ _ _ _ _) (1-l) + rw [he] at hh + rw [down_time L M N F ⟨c,hc⟩ ⟨r-1,by omega⟩,up_time L M N F ⟨c,hc⟩ ⟨r,hr⟩] + fin_cases l <;> simpa [lane,slot,vertex] using hh.symm + · intro c r hc hc0 hr l + have hv:=vertex_inside L M N (⟨c,hc⟩:Fin M) (⟨r,hr⟩:Fin N) true + have he : neighbor (vertex L M N ⟨c,hc⟩ ⟨r,hr⟩ true) 1= + vertex L M N ⟨c-1,by omega⟩ ⟨r,hr⟩ false := by + dsimp [neighbor,vertex]; congr 2; omega + have hh:=hm _ 1 hv (by rw [he]; exact vertex_inside _ _ _ _ _ _) (1-l) + rw [he] at hh + rw [down_time L M N F ⟨c-1,by omega⟩ ⟨r,hr⟩,up_time L M N F ⟨c,hc⟩ ⟨r,hr⟩] + fin_cases l <;> simpa [lane,slot,vertex] using hh.symm + +lemma physical_matches (hm : Matches (L:=L) (M:=M) (N:=N) F) : + TurnRectangle.PhysicalMatches hM hN (start (L:=L) F) (up L N F) (down L N F) := + TurnRectangle.starter_physical hM hN _ _ (interior_matches F hm) + +end Geometry + + + + + + +variable {L : ℤ} {M N : ℕ} + +lemma node_eq {v w : Vertex} (hv : Inside L M N v) (hw : Inside L M N w) + (he : v=w) (i : Fin 6) : node L M N hv i=node L M N hw i := by + subst w; rfl + +lemma node_of_vertex {v : Vertex} (h : Inside L M N v) {c : Fin M} {r : Fin N} {b : Bool} + (he : v=vertex L M N c r b) (i : Fin 6) : + node L M N h i=TurnRectangle.cellNode c r (if b then .inl i else .inr i) := by + subst v + exact at_vertex c r b i + +variable (hM : 1≤M) (hN : 1≤N) (F : Vertex → Pairing 6) + (hm : Matches (L:=L) (M:=M) (N:=N) F) +include hm + +lemma up_wire (c : Fin M) (r : Fin N) (p : Fin 3) (l : Fin 2) + (hw : Inside L M N (neighbor (vertex L M N c r true) p)) + (hi : (F (vertex L M N c r true)).Occupied (lane true p l)) : + graph (L:=L) hM hN F + (node L M N (vertex_inside L M N c r true) (lane true p l)) + (node L M N hw (lane false p (1-l))) ∧ + turnEdge (L:=L) hM hN F + (node L M N (vertex_inside L M N c r true) (lane true p l)) + (node L M N hw (lane false p (1-l)))=0 := by + have hm':=physical_matches hM hN F hm + fin_cases p + · have hr : 0 exact hi + have hE:=TurnRectangle.vertical_edge hM hN (start (L:=L) F) (up L N F) (down L N F) hm' hr (1-l) hh + have hT:=TurnRectangle.vertical_turn hM hN (start (L:=L) F) (up L N F) (down L N F) hm' hr (1-l) hh + fin_cases l + · refine ⟨symm hE,?_⟩ + rw [turnEdge,TurnRectangle.turns,TurnNetwork.edgeTurn_reverse] + exact congrArg Neg.neg hT + · refine ⟨symm hE,?_⟩ + rw [turnEdge,TurnRectangle.turns,TurnNetwork.edgeTurn_reverse] + exact congrArg Neg.neg hT + · have hc : 0 exact hi + have hE:=TurnRectangle.horizontal_edge hM hN (start (L:=L) F) (up L N F) (down L N F) hm' hc (1-l) hh + have hT:=TurnRectangle.horizontal_turn hM hN (start (L:=L) F) (up L N F) (down L N F) hm' hc (1-l) hh + fin_cases l + · refine ⟨symm hE,?_⟩ + rw [turnEdge,TurnRectangle.turns,TurnNetwork.edgeTurn_reverse] + exact congrArg Neg.neg hT + · refine ⟨symm hE,?_⟩ + rw [turnEdge,TurnRectangle.turns,TurnNetwork.edgeTurn_reverse] + exact congrArg Neg.neg hT + · have he : neighbor (vertex L M N c r true) 2=vertex L M N c r false := rfl + rw [at_vertex,node_of_vertex hw he] + have hh : (up L N F (c.val*N+r.val)).Occupied ⟨4+l.val,by omega⟩ := by + rw [up_time] + exact hi + have hE:=TurnRectangle.diagonal_edge hM hN (start (L:=L) F) (up L N F) (down L N F) hm' l hh + have hT:=TurnRectangle.diagonal_turn hM hN (start (L:=L) F) (up L N F) (down L N F) hm' l hh + fin_cases l <;> exact ⟨hE,hT⟩ + +lemma wire {v : Vertex} (hv : Inside L M N v) (p : Fin 3) (l : Fin 2) + (hw : Inside L M N (neighbor v p)) + (hi : (F v).Occupied (lane v.2.2 p l)) : + graph (L:=L) hM hN F (node L M N hv (lane v.2.2 p l)) + (node L M N hw (lane (!v.2.2) p (1-l))) ∧ + turnEdge (L:=L) hM hN F (node L M N hv (lane v.2.2 p l)) + (node L M N hw (lane (!v.2.2) p (1-l)))=0 := by + let w:=neighbor v p + have hb : w.2.2= !v.2.2 := by + cases he : v.2.2 <;> simp [w,neighbor,he] <;> split_ifs <;> rfl + have hww : neighbor w p=v := neighbor_reverse v p + cases hvb : v.2.2 + · have hwb : w.2.2=true := by simp [hb,hvb] + have hwv : vertex L M N (col hw) (row hw) true=w := by + rw [←hwb] + exact vertex_col_row hw + have hi' : (F w).Occupied (lane true p (1-l)) := by + rw [←hwb,hb] + exact (hm v p hv hw l).mp hi + have hww' : neighbor (vertex L M N (col hw) (row hw) true) p=v := by rw [hwv,hww] + have hh:=up_wire hM hN F hm (col hw) (row hw) p (1-l) + (by rw [hww']; exact hv) (by rwa [hwv]) + have hn₁ (i : Fin 6) : node L M N (vertex_inside L M N (col hw) (row hw) true) i= + node L M N hw i := by rw [at_vertex,node_of_vertex hw hwv.symm] + have hn₂ (i : Fin 6) (hx : Inside L M N (neighbor (vertex L M N (col hw) (row hw) true) p)) : + node L M N hx i=node L M N hv i := by + exact node_eq hx hv hww' i + rw [hn₁,hn₂] at hh + simp only [Bool.not_false] + have hll : 1-(1-l)=l := by fin_cases l <;> decide + rw [hll] at hh + refine ⟨symm hh.1,?_⟩ + rw [turnEdge,TurnRectangle.turns,TurnNetwork.edgeTurn_reverse] + exact congrArg Neg.neg hh.2 + · have hvv : v=vertex L M N (col hv) (row hv) true := by + rw [←hvb] + exact (vertex_col_row hv).symm + have hw' : Inside L M N (neighbor (vertex L M N (col hv) (row hv) true) p) := by rwa [←hvv] + have hh:=up_wire hM hN F hm (col hv) (row hv) p l hw' (by rwa [←hvv,←hvb]) + rw [node_eq _ hv hvv.symm, node_eq _ hw (congrArg (fun x=>neighbor x p) hvv.symm)] at hh + simpa only [hvb,Bool.not_true] using hh + +end RibbonRectangle +end + + + + + +noncomputable section +open scoped Classical +open Diagram FiniteBranchTree + + +def ribbon {s : State} {l : List Bool} (h : RibbonSimple s l) (v : Vertex) : Pairing 6 := + ⟨ribbonArcs v.2.2 (routes s l v),h v⟩ + +lemma ribbon_arc {s : State} {l : List Bool} (h : RibbonSimple s l) {v : Vertex} {p q : Fin 3} + (hp : ((v,p),q)∈passes s l) : (ribbon h v).Adj (lane v.2.2 p 0) (lane v.2.2 q 1) := by + have hm : Pairing.orderedEdge (lane v.2.2 p 0) (lane v.2.2 q 1)∈(ribbon h v).val := + Finset.mem_image.mpr ⟨(p,q),(mem_routes _ _ _ _).mpr hp,rfl⟩ + unfold Pairing.orderedEdge at hm + rcases le_total (lane v.2.2 p 0) (lane v.2.2 q 1) with he|he + · exact Or.inl (by simpa only [min_eq_left he,max_eq_right he] using hm) + · exact Or.inr (by simpa only [min_eq_right he,max_eq_left he] using hm) + +lemma ribbon_occupied {s : State} {l : List Bool} (h : RibbonSimple s l) (v : Vertex) (i : Fin 6) : + (ribbon h v).Occupied i ↔ ∃ p q, ((v,p),q)∈passes s l ∧ + (i=lane v.2.2 p 0 ∨ i=lane v.2.2 q 1) := by + constructor + · rintro ⟨j,hj|hj⟩ <;> obtain ⟨⟨p,q⟩,hp,he⟩:=Finset.mem_image.mp hj + · refine ⟨p,q,(mem_routes _ _ _ _).mp hp,?_⟩ + have hi:=congrArg Prod.fst he + change min (lane v.2.2 p 0) (lane v.2.2 q 1)=i at hi + rcases le_total (lane v.2.2 p 0) (lane v.2.2 q 1) with hh|hh + · exact Or.inl (hi.symm.trans (min_eq_left hh)) + · exact Or.inr (hi.symm.trans (min_eq_right hh)) + · refine ⟨p,q,(mem_routes _ _ _ _).mp hp,?_⟩ + have hi:=congrArg Prod.snd he + change max (lane v.2.2 p 0) (lane v.2.2 q 1)=i at hi + rcases le_total (lane v.2.2 p 0) (lane v.2.2 q 1) with hh|hh + · exact Or.inr (hi.symm.trans (max_eq_right hh)) + · exact Or.inl (hi.symm.trans (max_eq_left hh)) + · rintro ⟨p,q,hp,rfl|rfl⟩ + · exact ⟨_,ribbon_arc h hp⟩ + · exact ⟨_,(ribbon_arc h hp).symm⟩ + +lemma ribbon_incoming {s : State} {l : List Bool} (h : RibbonSimple s l) (v : Vertex) (p : Fin 3) : + (ribbon h v).Occupied (lane v.2.2 p 0) ↔ ∃ q, ((v,p),q)∈passes s l := by + rw [ribbon_occupied] + simp only [lane_injective,Fin.zero_ne_one,and_false,or_false,and_true] + constructor + · rintro ⟨p',q,hp,rfl⟩; exact ⟨q,hp⟩ + · rintro ⟨q,hq⟩; exact ⟨p,q,hq,rfl⟩ + +lemma ribbon_outgoing {s : State} {l : List Bool} (h : RibbonSimple s l) (v : Vertex) (p : Fin 3) : + (ribbon h v).Occupied (lane v.2.2 p 1) ↔ ∃ q, ((v,q),p)∈passes s l := by + rw [ribbon_occupied] + simp only [lane_injective,(show (1:Fin 2)≠0 from by decide),and_false,false_or,and_true] + constructor + · rintro ⟨p',q,hp,rfl⟩; exact ⟨p',hp⟩ + · rintro ⟨q,hq⟩; exact ⟨q,p,hq,rfl⟩ + +lemma route_shift_iff (s : State) (l : List Bool) (v : Vertex) (p : Fin 3) : + ((v,p)=s ∨ ∃ q,((neighbor v p,q),p)∈passes s l) ↔ + (∃q,((v,p),q)∈passes s l) ∨ (v,p)=terminal next s l := by + have hs:=congrArg (fun xs : List State => (v,p)∈xs) (passes_shift s l) + simp only [List.mem_cons,List.mem_append,List.mem_map] at hs + have ha : (∃ a∈passes s l,(neighbor a.1.1 a.2,a.2)=(v,p)) ↔ + ∃q,((neighbor v p,q),p)∈passes s l := by + constructor + · rintro ⟨⟨⟨w,q⟩,r⟩,hm,he⟩ + obtain ⟨hw,hp⟩:=Prod.mk.inj he + change r=p at hp + subst r + have hv := congrArg (fun z=>neighbor z p) hw + rw [neighbor_reverse] at hv + change w=neighbor v p at hv + subst w + exact ⟨q,hm⟩ + · rintro ⟨q,hq⟩ + exact ⟨((neighbor v p,q),p),hq,by simp only [neighbor_reverse]⟩ + have hb : (∃a∈passes s l,a.1=(v,p)) ↔ ∃q,((v,p),q)∈passes s l := by + constructor + · rintro ⟨⟨w,q⟩,hm,he⟩; change w=(v,p) at he; subst w; exact ⟨q,hm⟩ + · rintro ⟨q,hq⟩; exact ⟨((v,p),q),hq,rfl⟩ + simpa only [ha,hb,List.not_mem_nil,or_false] using (Iff.of_eq hs) + +lemma neighbor_bool (v : Vertex) (p : Fin 3) : (neighbor v p).2.2= !v.2.2 := by + unfold neighbor + split_ifs <;> simp_all + +namespace RibbonRectangle +variable {L : ℤ} {M N : ℕ} {s : State} {l : List Bool} + +lemma route_interior_match + (hs : ¬Inside L M N (back s).1) (ht : ¬Inside L M N (terminal next s l).1) + {v : Vertex} {p : Fin 3} (hv : Inside L M N v) (hw : Inside L M N (neighbor v p)) : + (∃q,((v,p),q)∈passes s l) ↔ (∃q,((neighbor v p,q),p)∈passes s l) := by + have h₀ : (v,p)≠s := by + intro he + have hh:=congrArg back he + exact hs (hh ▸ hw) + have h₁ : (v,p)≠terminal next s l := by + intro he + exact ht (congrArg Prod.fst he ▸ hv) + have hh:=route_shift_iff s l v p + simpa only [h₀,h₁,false_or,or_false] using hh.symm + +lemma ribbon_matches (h : RibbonSimple s l) + (hs : ¬Inside L M N (back s).1) (ht : ¬Inside L M N (terminal next s l).1) : + Matches (L:=L) (M:=M) (N:=N) (ribbon h) := by + intro v p hv hw j + rw [←neighbor_bool v p] + fin_cases j + · change (ribbon h v).Occupied (lane v.2.2 p 0) ↔ + (ribbon h (neighbor v p)).Occupied (lane (neighbor v p).2.2 p 1) + rw [ribbon_incoming,ribbon_outgoing] + exact route_interior_match hs ht hv hw + · change (ribbon h v).Occupied (lane v.2.2 p 1) ↔ + (ribbon h (neighbor v p)).Occupied (lane (neighbor v p).2.2 p 0) + rw [ribbon_outgoing,ribbon_incoming] + have hh:=route_interior_match (p:=p) hs ht hw (by simpa only [neighbor_reverse] using hv) + simpa only [neighbor_reverse] using hh.symm + +end RibbonRectangle +end +end CriticalStrip.HoneycombBranch + +end OAI diff --git a/lean/OAI/Combinatorics/StripMass/RibbonWalk.lean b/lean/OAI/Combinatorics/StripMass/RibbonWalk.lean new file mode 100644 index 0000000000000000000000000000000000000000..8093debe3ccbf74e8aa56b3eab99bcbd88f37d7d --- /dev/null +++ b/lean/OAI/Combinatorics/StripMass/RibbonWalk.lean @@ -0,0 +1,483 @@ +import Mathlib +import OAI.Combinatorics.StripMass.RibbonLocal + +namespace OAI + +/-! Critical honeycomb strip paths, polynomial identities and crossing mass. -/ + + +namespace CriticalStrip.HoneycombBranch +noncomputable section +open scoped Classical +open Diagram FiniteBranchTree +namespace RibbonRectangle + +variable {L : ℤ} {M N : ℕ} (hM : 1≤M) (hN : 1≤N) (F : Vertex → Pairing 6) + (hm : Matches (L:=L) (M:=M) (N:=N) F) +include hm + +lemma route_reach (s : State) (l : List Bool) (hs : Inside L M N s.1) + (hI : ∀x∈passes s l,Inside L M N x.1.1) + (hA : ∀x∈passes s l,(F x.1.1).Adj (lane x.1.1.2.2 x.1.2 0) (lane x.1.1.2.2 x.2 1)) + {v : Vertex} {p q : Fin 3} (hp : ((v,p),q)∈passes s l) : + Relation.ReflTransGen (graph (L:=L) hM hN F) + (node L M N hs (lane s.1.2.2 s.2 0)) + (node L M N (hI _ hp) (lane v.2.2 p 0)) ∧ + Relation.ReflTransGen (graph (L:=L) hM hN F) + (node L M N hs (lane s.1.2.2 s.2 0)) + (node L M N (hI _ hp) (lane v.2.2 q 1)) := by + induction l generalizing s with + | nil => simp only [passes,List.not_mem_nil] at hp + | cons b l ih => + have ha:=hA _ (List.mem_cons_self) + have ea:=arc_edge hM hN F hs ha + rcases List.mem_cons.mp hp with he|hp + · have he₁:=congrArg (fun z : State × Fin 3=>z.1.1) he + have he₂:=congrArg (fun z : State × Fin 3=>z.1.2) he + have he₃:=congrArg (fun z : State × Fin 3=>z.2) he + change v=s.1 at he₁; change p=s.2 at he₂; change q=outgoing s.2 b at he₃ + subst v p q + exact ⟨.refl,.single ea⟩ + · cases l with + | nil => simp only [passes,List.not_mem_nil] at hp + | cons c l => + have hs' : Inside L M N (next s b).1 := hI _ (by exact List.mem_cons_of_mem _ List.mem_cons_self) + have ew:= (wire hM hN F hm hs (outgoing s.2 b) 1 hs' ⟨_,ha.symm⟩).1 + have heB : (!s.1.2.2)=(next s b).1.2.2 := (neighbor_bool s.1 (outgoing s.2 b)).symm + have heL : (1-(1:Fin 2))=0 := rfl + rw [heB,heL] at ew + obtain ⟨hi,ho⟩:=ih (next s b) hs' + (fun x hx=>hI x (List.mem_cons_of_mem _ hx)) + (fun x hx=>hA x (List.mem_cons_of_mem _ hx)) hp + exact ⟨(Relation.ReflTransGen.single ea).trans ((Relation.ReflTransGen.single ew).trans hi), + (Relation.ReflTransGen.single ea).trans ((Relation.ReflTransGen.single ew).trans ho)⟩ + +omit hm in +lemma last_inside (s : State) (l : List Bool) (hl : l≠[]) + (hI : ∀x∈passes s l,Inside L M N x.1.1) : + Inside L M N (back (terminal next s l)).1 := by + have hh:=lastVisited_mem s l hl + rw [←passes_vertices] at hh + obtain ⟨x,hx,he⟩:=List.mem_map.mp hh + exact he ▸ hI x hx + +lemma route_turn (s : State) (l : List Bool) (hl : l≠[]) (hs : Inside L M N s.1) + (hI : ∀x∈passes s l,Inside L M N x.1.1) + (hA : ∀x∈passes s l,(F x.1.1).Adj (lane x.1.1.2.2 x.1.2 0) (lane x.1.1.2.2 x.2 1)) + (P : Diagram.TurnNetwork.Node (Diagram.TurnRectangle.ports M N) (M*N) → ℤ) + (hP : ∀v w, graph (L:=L) hM hN F v w → P w-P v=turnEdge (L:=L) hM hN F v w) : + P (node L M N (last_inside s l hl hI) + (lane (back (terminal next s l)).1.2.2 (terminal next s l).2 1)) - + P (node L M N hs (lane s.1.2.2 s.2 0))=turn l := by + induction l generalizing s with + | nil => exact (hl rfl).elim + | cons b l ih => + have ha:=hA _ List.mem_cons_self + have hp:=hP _ _ (arc_edge hM hN F hs ha) + rw [arc_turn hM hN F hs ha,local_turn] at hp + cases l with + | nil => + simp only [terminal,back_next] + simpa only [turn,add_zero,next] using hp + | cons c l => + have hs' : Inside L M N (next s b).1 := hI _ (List.mem_cons_of_mem _ List.mem_cons_self) + have ew:= wire hM hN F hm hs (outgoing s.2 b) 1 hs' ⟨_,ha.symm⟩ + have heB : (!s.1.2.2)=(next s b).1.2.2 := (neighbor_bool s.1 (outgoing s.2 b)).symm + have heL : (1-(1:Fin 2))=0 := rfl + rw [heB,heL] at ew + have hw:= (hP _ _ ew.1).trans ew.2 + have ht:=ih (next s b) (by simp) + hs' (fun x hx=>hI x (List.mem_cons_of_mem _ hx)) + (fun x hx=>hA x (List.mem_cons_of_mem _ hx)) + change _=sign b+turn (c::l) + change _-P (node L M N hs' (lane (next s b).1.2.2 (next s b).2 0))=turn (c::l) at ht + change P (node L M N hs' (lane (next s b).1.2.2 (next s b).2 0))-_ =0 at hw + dsimp only [terminal] at ht ⊢ + dsimp only [next] at hw ht ⊢ + dsimp only at hp + omega + +end RibbonRectangle +end + + + + + +noncomputable section +open scoped Classical +open Diagram Diagram.TurnNetwork Diagram.TurnDisk FiniteBranchTree +namespace RibbonRectangle + +variable {L : ℤ} {M N : ℕ} + +section BoundaryConnection +lemma node_occupied (F : Vertex → Pairing 6) {v : Vertex} (h : Inside L M N v) (i : Fin 6) : + TurnNetwork.Occupied (start (L:=L) F) (up L N F) (down L N F) (M*N) (node L M N h i) ↔ + (F v).Occupied i := by + obtain ⟨c,r,b,rfl⟩ : ∃ c r b,v=vertex L M N c r b := + ⟨col h,row h,v.2.2,(vertex_col_row h).symm⟩ + rw [at_vertex] + cases b + · change (down L N F (c.val*N+r.val)).Occupied i ↔ _ + rw [down_time] + · change (up L N F (c.val*N+r.val)).Occupied i ↔ _ + rw [up_time] + +lemma cover_node (hN : 1≤N) (x : Node (TurnRectangle.ports M N) (M*N)) : + (∃i,x=.inl i) ∨ ∃ (v : Vertex) (h : Inside L M N v),∃i, x=node L M N h i := by + rcases x with i|⟨t,z⟩ + · exact Or.inl ⟨i,rfl⟩ + · have hc : t.val/Nribbon_arc hr hx) hp + refine ⟨i₀,?_⟩ + rcases hj with rfl|rfl + · exact ConnectivityCertificate.reach_symm ⟨fun _ _ hedge=>symm hedge⟩ (h₀.trans hri) + · exact ConnectivityCertificate.reach_symm ⟨fun _ _ hedge=>symm hedge⟩ (h₀.trans hro) + +end BoundaryConnection + + + + + + +def bottomIndex (c : Fin M) (l : Fin 2) : Fin (TurnRectangle.ports M N) := + TurnStarter.left (TurnRectangle.width M N) (TurnRectangle.southRay c (1-l)) + +lemma bottomIndex_val (c : Fin M) (l : Fin 2) : + (bottomIndex (N:=N) c l).val=2*N+2*c.val+l.val := by + have hl : (1-l).val=1-l.val := by fin_cases l <;> decide + dsimp [bottomIndex,TurnStarter.left,TurnRectangle.southRay,TurnRectangle.width] + rw [hl] + omega + +lemma bottomIndex_lt (c : Fin M) (l : Fin 2) : (bottomIndex (N:=N) c l).val omega + +lemma top_boundary (c : Fin M) (l : Fin 2) : + boundary (L:=L) hM hN F (TurnRectangle.northSlot hM hN c.isLt l)= + node L M N (vertex_inside L M N c ⟨N-1,by omega⟩ false) (lane false 0 l) := by + rw [boundary,TurnRectangle.north_boundary,at_vertex] + rfl + +lemma top_gauge (c : Fin M) (l : Fin 2) : + gauge (L:=L) hM hN F (TurnRectangle.northSlot hM hN c.isLt l)=0 := by + rw [gauge,←TurnNetwork.namedGauge_boundary] + change namedGauge (TurnRectangle.starterGauge M N) (M*N) + (boundary (L:=L) hM hN F (TurnRectangle.northSlot hM hN c.isLt l))=0 + rw [top_boundary,at_vertex] + fin_cases l <;> rfl + +variable (hm : Matches (L:=L) (M:=M) (N:=N) F) +include hm + +lemma bottom_connector (c : Fin M) (l : Fin 2) + (hi : (F (vertex L M N c ⟨0,by omega⟩ true)).Occupied (lane true 0 l)) : + Relation.ReflTransGen (graph (L:=L) hM hN F) + (boundary (L:=L) hM hN F (bottomIndex c l)) + (node L M N (vertex_inside L M N c ⟨0,by omega⟩ true) (lane true 0 l)) ∧ + ∀ P : Node (TurnRectangle.ports M N) (M*N) → ℤ, + (∀v w,graph (L:=L) hM hN F v w → P w-P v=turnEdge (L:=L) hM hN F v w) → + P (node L M N (vertex_inside L M N c ⟨0,by omega⟩ true) (lane true 0 l))- + P (boundary (L:=L) hM hN F (bottomIndex c l))=0 := by + have him : (up L N F (c.val*N)).Occupied ⟨3-(1-l).val,by omega⟩ := by + have hh:=up_time L M N F c (⟨0,by omega⟩:Fin N) + simp only [Nat.add_zero] at hh + rw [hh] + fin_cases l <;> exact hi + have hact:=(TurnRectangle.active_south (up L N F) c (1-l)).mpr him + have e₁:=TurnRectangle.starter_edge hM hN (up L N F) (down L N F) hact + have t₁:=TurnRectangle.starter_turn hM hN (up L N F) (down L N F) hact + have e₂:=TurnRectangle.south_edge hM hN (up L N F) (down L N F) (interior_matches F hm) (1-l) him + have t₂:=TurnRectangle.south_turn hM hN (up L N F) (down L N F) (interior_matches F hm) (1-l) him + rw [TurnRectangle.southSlot_right] at e₂ t₂ + rw [bottom_boundary,at_vertex] + have he : (⟨3-(1-l).val,by omega⟩:Fin 6)=lane true 0 l := by fin_cases l <;> rfl + rw [he] at e₂ t₂ + refine ⟨(Relation.ReflTransGen.single e₁).trans (.single e₂),?_⟩ + intro P hP + have hp₁:=(hP _ _ e₁).trans t₁ + have hp₂:=(hP _ _ e₂).trans t₂ + simp only [ite_true] + change _-P (Sum.inl (TurnStarter.left _ _))=0 + omega + +end RibbonRectangle + + + + + + +lemma last_pass (s : State) (l : List Bool) (hl : l≠[]) : + ∃ p, (((back (terminal next s l)).1,p),(terminal next s l).2)∈passes s l := by + induction l generalizing s with + | nil=>exact (hl rfl).elim + | cons b l ih=> + cases l with + | nil=> + refine ⟨s.2,?_⟩ + simp only [terminal,back_next] + exact List.mem_cons_self + | cons c l=> + obtain ⟨p,hp⟩:=ih (next s b) (by simp) + exact ⟨p,List.mem_cons_of_mem _ hp⟩ + +lemma first_occupied (s : State) (l : List Bool) (hl : l≠[]) (hr : RibbonSimple s l) : + (ribbon hr s.1).Occupied (lane s.1.2.2 s.2 0) := by + cases l with + | nil=>exact (hl rfl).elim + | cons b l=>exact ⟨_,ribbon_arc hr List.mem_cons_self⟩ + +namespace RibbonRectangle +variable {L : ℤ} {M N : ℕ} (hM : 1≤M) (hN : 1≤N) + +lemma endpoint_turn (s : State) (l : List Bool) (hl : l≠[]) (hr : RibbonSimple s l) + (hs : Inside L M N s.1) (hI : ∀x∈passes s l,Inside L M N x.1.1) + (hm : Matches (L:=L) (M:=M) (N:=N) (ribbon hr)) + (i j : Fin (TurnRectangle.ports M N)) (hne : i≠j) + (hsi : Relation.ReflTransGen (graph (L:=L) hM hN (ribbon hr)) + (boundary (L:=L) hM hN (ribbon hr) i) (node L M N hs (lane s.1.2.2 s.2 0))) + (hjt : Relation.ReflTransGen (graph (L:=L) hM hN (ribbon hr)) + (boundary (L:=L) hM hN (ribbon hr) j) + (node L M N (last_inside s l hl hI) + (lane (back (terminal next s l)).1.2.2 (terminal next s l).2 1))) + (hzero : ∀P : Node (TurnRectangle.ports M N) (M*N) → ℤ, + (∀v w,graph (L:=L) hM hN (ribbon hr) v w → + P w-P v=turnEdge (L:=L) hM hN (ribbon hr) v w) → + P (node L M N hs (lane s.1.2.2 s.2 0))- + P (boundary (L:=L) hM hN (ribbon hr) i)=0 ∧ + P (node L M N (last_inside s l hl hI) + (lane (back (terminal next s l)).1.2.2 (terminal next s l).2 1))- + P (boundary (L:=L) hM hN (ribbon hr) j)=0) : + turn l=Pairing.arcTurn (gauge (L:=L) hM hN (ribbon hr)) i j := by + have hc:=TurnRectangle.compatible hM hN (start (L:=L) (ribbon hr)) + (up L N (ribbon hr)) (down L N (ribbon hr)) (physical_matches hM hN (ribbon hr) hm) + obtain ⟨a,P,hreach,ha,he⟩:=TurnNetwork.potential (start (L:=L) (ribbon hr)) + (TurnRectangle.starterGauge M N) (up L N (ribbon hr)) (down L N (ribbon hr)) + (TurnRectangle.position M N) (TurnRectangle.position_bound hM hN) (M*N) hc + (ribbon_drains hM hN s l hr hs hI hm i hsi) + obtain ⟨p,hp⟩:=last_pass s l hl + have hrt:=(route_reach hM hN (ribbon hr) hm s l hs hI (fun x hx=>ribbon_arc hr hx) hp).2 + have hab : a.Adj i j := ((hreach i j).mp (hsi.trans (hrt.trans + (ConnectivityCertificate.reach_symm ⟨fun _ _ hedge=>symm hedge⟩ hjt)))).resolve_left hne + have ht:=route_turn hM hN (ribbon hr) hm s l hl hs hI (fun x hx=>ribbon_arc hr hx) P he + have hz:=hzero P he + have hb:=ha i j hab + change P (boundary (L:=L) hM hN (ribbon hr) j)-P (boundary (L:=L) hM hN (ribbon hr) i)=Pairing.arcTurn (gauge (L:=L) hM hN (ribbon hr)) i j at hb + omega + +lemma bottom_outside (c : Fin M) : + ¬Inside L M N (back (vertex L M N c ⟨0,by omega⟩ true,0)).1 := by + simp [Inside,back,neighbor,vertex] + +include hM in +lemma bottom_turn (c₀ c₁ : Fin M) (l : List Bool) (hl : l≠[]) + (hr : RibbonSimple (vertex L M N c₀ ⟨0,by omega⟩ true,0) l) + (hI : ∀x∈passes (vertex L M N c₀ ⟨0,by omega⟩ true,0) l,Inside L M N x.1.1) + (ht : terminal next (vertex L M N c₀ ⟨0,by omega⟩ true,0) l= + back (vertex L M N c₁ ⟨0,by omega⟩ true,0)) : + turn l=if c₀≤c₁ then -3 else 3 := by + let s : State:=(vertex L M N c₀ ⟨0,by omega⟩ true,0) + have hm:=ribbon_matches (L:=L) (M:=M) (N:=N) hr (bottom_outside hN c₀) + (by rw [ht]; exact bottom_outside hN c₁) + have hi:=bottom_connector hM hN (ribbon hr) hm c₀ 0 (first_occupied s l hl hr) + have heV : (back (terminal next s l)).1=vertex L M N c₁ ⟨0,by omega⟩ true := by rw [ht,back_back] + have heP : (terminal next s l).2=0 := by rw [ht]; rfl + obtain ⟨p,hp⟩:=last_pass s l hl + have hocc : (ribbon hr (vertex L M N c₁ ⟨0,by omega⟩ true)).Occupied (lane true 0 1) := by + have hh : (ribbon hr (back (terminal next s l)).1).Occupied + (lane (back (terminal next s l)).1.2.2 (terminal next s l).2 1) := ⟨_,(ribbon_arc hr hp).symm⟩ + simpa only [heV,heP,vertex] using hh + have hj:=bottom_connector hM hN (ribbon hr) hm c₁ 1 hocc + have heNode : node L M N (last_inside s l hl hI) + (lane (back (terminal next s l)).1.2.2 (terminal next s l).2 1)= + node L M N (vertex_inside L M N c₁ ⟨0,by omega⟩ true) (lane true 0 1) := by + rw [node_of_vertex _ heV,at_vertex,heV,heP] + rfl + have hne : bottomIndex (N:=N) c₀ 0 ≠bottomIndex c₁ 1 := by + intro he + have hv:=congrArg Fin.val he + simp only [bottomIndex_val,Fin.val_zero,Fin.val_one] at hv + omega + have hh:=endpoint_turn hM hN s l hl hr (vertex_inside _ _ _ _ _ _) hI hm + (bottomIndex c₀ 0) (bottomIndex c₁ 1) hne hi.1 (by rw [heNode]; exact hj.1) + (fun P hP=>⟨hi.2 P hP,by rw [heNode]; exact hj.2 P hP⟩) + rw [hh,Pairing.arcTurn,bottom_gauge,bottom_gauge] + unfold Pairing.turnOrder + simp only [Fin.le_iff_val_le_val,Fin.lt_def,bottomIndex_val,Fin.val_zero,Fin.val_one] + split_ifs <;> omega + +end RibbonRectangle +end + + + + + +noncomputable section +open scoped Classical +open Diagram FiniteBranchTree + +def closeStem (stem tail : List Bool) : List Bool := + (stem++true::tail)++true::reverseTurns stem + +lemma closeStem_depart (s : State) (stem tail : List Bool) + (hc : terminal next s (stem++true::tail)= + ((terminal next s stem).1,outgoing (terminal next s stem).2 false)) : + next (terminal next s (stem++true::tail)) true=back (terminal next s stem) := by + rw [hc] + have hp:=outgoing_opp (terminal next s stem).2 false + change outgoing (outgoing (terminal next s stem).2 false) true=(terminal next s stem).2 at hp + simp only [next,hp,back] + +lemma closeStem_terminal (s : State) (stem tail : List Bool) + (hc : terminal next s (stem++true::tail)= + ((terminal next s stem).1,outgoing (terminal next s stem).2 false)) : + terminal next s (closeStem stem tail)=back s := by + rw [closeStem,terminal_append,terminal,closeStem_depart s stem tail hc,terminal_reverseTurns] + +lemma closeStem_routes (s : State) (stem tail : List Bool) (v : Vertex) + (hc : terminal next s (stem++true::tail)= + ((terminal next s stem).1,outgoing (terminal next s stem).2 false)) : + routes s (closeStem stem tail) v = + routes s stem v ∪ + (if v=(terminal next s stem).1 then + {((terminal next s stem).2,outgoing (terminal next s stem).2 true), + (outgoing (terminal next s stem).2 false,(terminal next s stem).2)} else ∅) ∪ + routes (next (terminal next s stem) true) tail v ∪ + (routes s stem v).image Prod.swap := by + have hp:=outgoing_opp (terminal next s stem).2 false + change outgoing (outgoing (terminal next s stem).2 false) true=(terminal next s stem).2 at hp + rw [closeStem,routes_append,routes_append,routes_cons,routes_cons, + closeStem_depart s stem tail hc,routes_reverseTurns,hc] + dsimp only [Prod.fst,Prod.snd] + rw [hp] + split_ifs <;> ext z <;> simp only [Finset.mem_union,Finset.mem_insert,Finset.mem_singleton, + Finset.notMem_empty] <;> tauto + +lemma closeStem_simple (s : State) (stem tail : List Bool) + (hn : (visited Prod.fst next s (stem++true::tail)).Nodup) + (hc : terminal next s (stem++true::tail)= + ((terminal next s stem).1,outgoing (terminal next s stem).2 false)) : + RibbonSimple s (closeStem stem tail) := by + rw [visited_append] at hn + have hs:=hn.of_append_left + have hj:=List.nodup_cons.mp hn.of_append_right + have hd:=hn.disjoint + intro v + rw [closeStem_routes s stem tail v hc] + by_cases hv : v=(terminal next s stem).1 + · subst v + have h₁ : (terminal next s stem).1∉visited Prod.fst next s stem := by + intro h + exact List.disjoint_left.mp hd h List.mem_cons_self + rw [ite_eq_left rfl,routes_empty_of_notMem h₁,routes_empty_of_notMem hj.1] + simp only [Finset.empty_union,Finset.union_empty,Finset.image_empty] + exact ribbon_joint _ _ + · rw [ite_eq_right hv,Finset.union_empty] + rcases routes_singleton_of_nodup hs v with he|⟨p,q,hpq,he⟩ + · rw [he,Finset.empty_union,Finset.image_empty,Finset.union_empty] + exact ribbonSimple_of_nodup hj.2 v + · have hm : v∈visited Prod.fst next s stem := + passes_mem_vertex ((mem_routes _ _ _ _).mp (he ▸ Finset.mem_singleton_self _)) + have hnot : v∉visited Prod.fst next (next (terminal next s stem) true) tail := by + intro hh + exact List.disjoint_left.mp hd hm (List.mem_cons_of_mem _ hh) + rw [routes_empty_of_notMem hnot,Finset.union_empty,he] + simp only [Finset.image_singleton,Finset.singleton_union,Prod.swap_prod_mk] + exact ribbon_double _ p q hpq.symm + +lemma closeStem_visits (s : State) (stem tail : List Bool) + (hc : terminal next s (stem++true::tail)= + ((terminal next s stem).1,outgoing (terminal next s stem).2 false)) : + ∀v∈visited Prod.fst next s (closeStem stem tail), + v∈visited Prod.fst next s (stem++true::tail) := by + have hv : (terminal next s (stem++true::tail)).1=(terminal next s stem).1 := by rw [hc] + simp only [closeStem,visited_append,visited,closeStem_depart s stem tail hc, + visited_reverseTurns,List.mem_append,List.mem_cons,List.mem_reverse,hv] + intro v h + tauto + +lemma closeStem_turn (stem tail : List Bool) : + turn (closeStem stem tail)=turn (true::tail)+1 := by + simp only [closeStem,turn_append,turn,sign,ite_true,turn_reverseTurns] + omega + +end +end CriticalStrip.HoneycombBranch + +end OAI diff --git a/lean/OAI/Combinatorics/StripMass/RightStieltjes.lean b/lean/OAI/Combinatorics/StripMass/RightStieltjes.lean new file mode 100644 index 0000000000000000000000000000000000000000..3c69c2786bda2562172004f799b05fe665d3bb44 --- /dev/null +++ b/lean/OAI/Combinatorics/StripMass/RightStieltjes.lean @@ -0,0 +1,568 @@ +import Mathlib +import OAI.Combinatorics.StripMass.ReflectionIntegrals +import OAI.Combinatorics.StripMass.CollisionSubstitutions + +namespace OAI + +/-! Critical honeycomb strip paths, polynomial identities and crossing mass. -/ + + +namespace CriticalStrip +noncomputable section +open Set MeasureTheory Filter +open scoped Topology + +lemma transformed_omega_extended {s t : ℝ} (hs : -1 < s) (ht : 0 < t) : + |(-8 * t * (t ^ 2 + 1) / uniformDen t ^ 2)| • + (s * omega (uniformizer t) / (1 + s * uniformizer t)) = + quarticWeighted (Real.sqrt ((1 + s) / 2)) t - + quarticWeighted (Real.sqrt (1 / 2)) t := by + rw [omega_uniformizer ht, abs_of_neg (by + exact div_neg_of_neg_of_pos (by nlinarith [sq_nonneg t]) + (sq_pos_of_pos (uniformDen_pos t))), smul_eq_mul] + unfold quarticWeighted quarticDen + rw [Real.sq_sqrt (by linarith : (0 : ℝ) ≤ (1 + s) / 2), + Real.sq_sqrt (by norm_num : (0 : ℝ) ≤ 1 / 2)] + unfold uniformizer uniformDen + have hd : 1 + t^2*4 + t^4*2 + s ≠ 0 := by nlinarith [sq_nonneg t,sq_nonneg (t^2)] + field_simp + ring_nf + field_simp [hd] + ring + +lemma omega_resolvent_extended {s : ℝ} (hs : -1 < s) : + IntegrableOn (fun x => s * omega x / (1 + s * x)) (Ioo 0 1) ∧ + (∫ x in Ioo 0 1, s * omega x / (1 + s * x)) = + Real.pi * (minusBranch s - minusBranch 0) := by + have hr : 0 < Real.sqrt ((1 + s) / 2) := Real.sqrt_pos.mpr (by linarith) + have hr0 : 0 < Real.sqrt ((1 : ℝ) / 2) := by positivity + have hint := (quartic_weighted_integral hr).1.sub (quartic_weighted_integral hr0).1 + have hi := integrableOn_image_iff_integrableOn_abs_deriv_smul measurableSet_Ioi + (fun t _ => (uniformizer_deriv t).hasDerivWithinAt) uniformizer_inj + (fun x => s * omega x / (1 + s * x)) + rw [uniformizer_image] at hi + constructor + · apply hi.2 + exact IntegrableOn.congr_fun hint (fun t ht => (transformed_omega_extended hs ht).symm) + measurableSet_Ioi + · have h := integral_image_eq_integral_abs_deriv_smul measurableSet_Ioi + (fun t _ => (uniformizer_deriv t).hasDerivWithinAt) uniformizer_inj + (fun x => s * omega x / (1 + s * x)) + rw [uniformizer_image] at h + rw [h, setIntegral_congr_fun measurableSet_Ioi (fun t ht => transformed_omega_extended hs ht), + integral_sub (quartic_weighted_integral hr).1 (quartic_weighted_integral hr0).1, + quartic_weighted_integral_sqrt hr, quartic_weighted_integral_sqrt hr0] + simp only [minusBranch, add_zero] + ring + + +lemma stieltjes_omega_right {z : ℝ} (hz : 1 < z) : + fBranch z = C + (1 / Real.pi) * + ∫ x in Ioo (0 : ℝ) 1, omega x / (x - z) := by + have hz0 : 0 < z := by linarith + have hs : -1 < -1 / z := by rw [lt_div_iff₀ hz0]; linarith + have heq : EqOn (fun x => (-1 / z) * omega x / (1 + (-1 / z) * x)) + (fun x => omega x / (x - z)) (Ioo 0 1) := by + intro x hx + dsimp only + have ha : 1 + (-1 / z) * x ≠ 0 := by + have he : 1 + (-1 / z) * x = (z-x)/z := by field_simp; ring + rw [he]; exact div_ne_zero (by linarith [hx.2]) hz0.ne' + have hb : x - z ≠ 0 := by linarith [hx.2] + apply (div_eq_div_iff ha hb).2 + field_simp + ring + have h := (omega_resolvent_extended hs).2 + rw [setIntegral_congr_fun measurableSet_Ioo heq, minusBranch_zero] at h + have he : minusBranch (-1 / z) = fBranch z := by + unfold minusBranch fBranch + congr 4 + ring + rw [he] at h + change fBranch z = C + (1 / Real.pi) * _ + change _ = Real.pi * (fBranch z - C) at h + rw [h] + field_simp + ring + +lemma transformed_squareWeight_extended {s t : ℝ} (hs : -1 < s) (ht : 0 < t) : + |(-2 * t / (1 + t ^ 2) ^ 2)| • + (s * squareWeight (squareUniformizer t) / (1 + s * squareUniformizer t)) = + (1 / Real.sqrt 2) * ((1 + s) * ((1 + s) + t ^ 2)⁻¹ - (1 + t ^ 2)⁻¹) := by + rw [squareWeight_uniformizer ht, abs_of_neg (by + exact div_neg_of_neg_of_pos (by linarith) (by positivity)), smul_eq_mul] + unfold squareUniformizer + have hd : 1 + t^2 + s ≠ 0 := by nlinarith [sq_nonneg t] + field_simp + ring_nf + field_simp [hd] + ring + +lemma squareWeight_resolvent_extended {s : ℝ} (hs : -1 < s) : + IntegrableOn (fun x => s * squareWeight x / (1 + s * x)) (Ioo 0 1) ∧ + (∫ x in Ioo 0 1, s * squareWeight x / (1 + s * x)) = + (Real.pi / (2 * Real.sqrt 2)) * (Real.sqrt (1 + s) - 1) := by + let a := Real.sqrt (1 + s) + have ha : 0 < a := Real.sqrt_pos.mpr (by linarith) + have ha2 : a ^ 2 = 1 + s := Real.sq_sqrt (by linarith) + have hint1 : IntegrableOn (fun t : ℝ => ((1 + s) + t ^ 2)⁻¹) (Ioi 0) := by + rw [← ha2] + exact (scaled_cauchy ha).1.integrableOn + have hint0 : IntegrableOn (fun t : ℝ => (1 + t ^ 2)⁻¹) (Ioi 0) := + integrable_inv_one_add_sq.integrableOn + have hint := ((hint1.const_mul (1 + s)).sub hint0).const_mul (1 / Real.sqrt 2) + have hi := integrableOn_image_iff_integrableOn_abs_deriv_smul measurableSet_Ioi + (fun t _ => (squareUniformizer_deriv t).hasDerivWithinAt) squareUniformizer_inj + (fun x => s * squareWeight x / (1 + s * x)) + rw [squareUniformizer_image] at hi + constructor + · apply hi.2 + exact IntegrableOn.congr_fun hint (fun t ht => (transformed_squareWeight_extended hs ht).symm) + measurableSet_Ioi + · have h := integral_image_eq_integral_abs_deriv_smul measurableSet_Ioi + (fun t _ => (squareUniformizer_deriv t).hasDerivWithinAt) squareUniformizer_inj + (fun x => s * squareWeight x / (1 + s * x)) + rw [squareUniformizer_image] at h + rw [h, setIntegral_congr_fun measurableSet_Ioi (fun t ht => transformed_squareWeight_extended hs ht), + integral_const_mul, integral_sub (hint1.const_mul (1 + s)) hint0, + integral_const_mul, ← ha2, scaled_cauchy_Ioi ha, integral_Ioi_inv_one_add_sq, + Real.arctan_zero, sub_zero] + rw [Real.sqrt_sq ha.le] + field_simp + +lemma stieltjes_omega_square_right {z : ℝ} (hz : 1 < z) : + fBranch z ^ 2 = C ^ 2 + (1 / Real.pi) * + ∫ x in Ioo (0 : ℝ) 1, lBranch x * omega x / (x - z) := by + have hz0 : 0 < z := by linarith + have hs : -1 < -1 / z := by rw [lt_div_iff₀ hz0]; linarith + have heq : EqOn (fun x => (-1 / z) * squareWeight x / (1 + (-1 / z) * x)) + (fun x => lBranch x * omega x / (x - z)) (Ioo 0 1) := by + intro x hx + dsimp only + rw [lBranch_mul_omega hx] + have ha : 1 + (-1 / z) * x ≠ 0 := by + have he : 1 + (-1 / z) * x = (z-x)/z := by field_simp; ring + rw [he]; exact div_ne_zero (by linarith [hx.2]) hz0.ne' + have hb : x - z ≠ 0 := by linarith [hx.2] + apply (div_eq_div_iff ha hb).2 + field_simp + ring + have h := (squareWeight_resolvent_extended hs).2 + rw [setIntegral_congr_fun measurableSet_Ioo heq] at h + have hC : C ^ 2 = (1 + Real.sqrt (1 / 2)) / 2 := by + change (Real.cos (Real.pi/8))^2 = _ + rw [← minusBranch_zero] + unfold minusBranch + simp only [add_zero] + exact Real.sq_sqrt (by positivity) + rw [h, hC, fBranch, Real.sq_sqrt (by positivity : (0 : ℝ) ≤ (1 + Real.sqrt ((1 - 1 / z) / 2)) / 2)] + have heq' : 1 - 1 / z = 1 + -1 / z := by ring + rw [heq', Real.sqrt_div (by linarith : (0 : ℝ) ≤ 1 + -1 / z), + Real.sqrt_div (by norm_num : (0 : ℝ) ≤ 1), Real.sqrt_one] + field_simp + ring + + + +lemma offCut_of_outside {z : ℝ} (hz : z < 0 ∨ 1 < z) : offCut 1 z := by + intro x hx + simp only [one_mul] + rcases hz with hz | hz <;> linarith [hx.1,hx.2] + +lemma fBranch_transform_outside {z : ℝ} (hz : z < 0 ∨ 1 < z) : + fBranch z = C - (1 / Real.pi) * realStieltjes 1 omega z := by + have h : fBranch z = C + (1 / Real.pi) * ∫ x in Ioo (0:ℝ) 1, omega x/(x-z) := by + rcases hz with hz | hz + · exact stieltjes_omega hz + · exact stieltjes_omega_right hz + have heq : (∫ x in Ioo (0 : ℝ) 1, omega x / (x - z)) = -realStieltjes 1 omega z := by + rw [realStieltjes, ← integral_neg] + apply setIntegral_congr_fun measurableSet_Ioo + intro x _ + simp only [one_mul] + rw [show x - z = -(z - x) by ring, div_neg] + simpa only [heq, mul_neg, ← sub_eq_add_neg] using h + +lemma fBranch_square_transform_outside {z : ℝ} (hz : z < 0 ∨ 1 < z) : + fBranch z ^ 2 = C ^ 2 - + (1 / Real.pi) * realStieltjes 1 (fun x => lBranch x * omega x) z := by + have h : fBranch z ^ 2 = C ^ 2 + (1 / Real.pi) * + ∫ x in Ioo (0:ℝ) 1, lBranch x * omega x/(x-z) := by + rcases hz with hz | hz + · exact stieltjes_omega_square hz + · exact stieltjes_omega_square_right hz + have heq : (∫ x in Ioo (0 : ℝ) 1, lBranch x * omega x / (x - z)) = + -realStieltjes 1 (fun x => lBranch x * omega x) z := by + rw [realStieltjes, ← integral_neg] + apply setIntegral_congr_fun measurableSet_Ioo + intro x _ + simp only [one_mul] + rw [show x - z = -(z - x) by ring, div_neg] + simpa only [heq, mul_neg, ← sub_eq_add_neg] using h + + +lemma projectionF_polynomial_outside (P J E : Polynomial ℝ) : + ∃ R : Polynomial ℝ, ∀ z : ℝ, z < 0 ∨ 1 < z → + projectionF P J E z = R.eval z - (1 / Real.pi) * + realStieltjes 1 (fun x => projectionD J E x * omega x) z := by + obtain ⟨Rj, hRj⟩ := polynomial_mul_realStieltjes (a := (1 : ℝ)) integrableOn_omega J + obtain ⟨Re, hRe⟩ := polynomial_mul_realStieltjes (a := (1 : ℝ)) integrableOn_lBranch_omega E + refine ⟨P + Polynomial.C C * J + Polynomial.C (C ^ 2) * E - + Polynomial.C (1 / Real.pi) * (Rj + Re), ?_⟩ + intro z hz + have hj := hRj z (offCut_of_outside hz) + have he := hRe z (offCut_of_outside hz) + have hsum := realStieltjes_add + (integrableOn_polynomial_weight (a := (1 : ℝ)) integrableOn_omega J) + (integrableOn_polynomial_weight (a := (1 : ℝ)) integrableOn_lBranch_omega E) + (offCut_of_outside hz) + have hw : (fun x => J.eval (1 * x) * omega x + E.eval (1 * x) * (lBranch x * omega x)) = + fun x => projectionD J E x * omega x := by + funext x + simp only [one_mul, projectionD] + ring + rw [hw] at hsum + simp only [one_mul] at hj he hsum + rw [projectionF, fBranch_square_transform_outside hz, fBranch_transform_outside hz, hsum] + simp only [Polynomial.eval_add, Polynomial.eval_sub, Polynomial.eval_mul, Polynomial.eval_C] + linear_combination -(1 / Real.pi) * hj - (1 / Real.pi) * he + + +lemma projectionF_cauchy_outside (P J E : Polynomial ℝ) + (hF : Tendsto (fun t : ℝ => projectionF P J E (-t)) atTop (𝓝 0)) : + ∀ z : ℝ, z < 0 ∨ 1 < z → projectionF P J E z = -(1 / Real.pi) * + realStieltjes 1 (fun x => projectionD J E x * omega x) z := by + obtain ⟨R, hR⟩ := projectionF_polynomial_outside P J E + have hz : Tendsto (fun t : ℝ => ‖-t‖) atTop atTop := by + simpa only [norm_neg] using (tendsto_norm_atTop_atTop : Tendsto (fun t : ℝ => ‖t‖) atTop atTop) + have hlim := hF.add ((tendsto_realStieltjes_zero (integrableOn_projection_weight J E) + (by norm_num : |(1 : ℝ)| ≤ 1) hz).const_mul (1 / Real.pi)) + have hRlim : Tendsto (fun t : ℝ => R.eval (-t)) atTop (𝓝 0) := by + have hlim' : Tendsto (fun t : ℝ => projectionF P J E (-t) + (1 / Real.pi) * + realStieltjes 1 (fun x => projectionD J E x * omega x) (-t)) atTop (𝓝 0) := by + simpa only [mul_zero, add_zero] using hlim + apply hlim'.congr' + filter_upwards [eventually_gt_atTop (0 : ℝ)] with t ht + have h := hR (-t) (Or.inl (neg_neg_of_pos ht)) + linarith + have hR0 := polynomial_constant_of_limit hz R hRlim + intro z hz + simpa only [hR0, Polynomial.eval_C, zero_sub, neg_mul] using hR z hz + +end + + + + + +noncomputable section +open Set MeasureTheory Filter Polynomial +open scoped Topology BigOperators Classical + + + +lemma lagrange_reverse_cauchy_sum {n : ℕ} {y : Fin (n+1) → ℝ} + (hy : Function.Injective y) {z : ℝ} (hz : ∀ i, z ≠ y i) : + ∑ i, 1 / ((z-y i) * ∏ j ∈ Finset.univ.erase i, (y j-y i)) = + (-1:ℝ)^n / ∏ i, (z-y i) := by + have H := congrArg (Polynomial.eval z) (Lagrange.sum_basis hy.injOn + (Finset.univ_nonempty : (Finset.univ : Finset (Fin (n+1))).Nonempty)) + simp only [eval_finsetSum, eval_one] at H + have hb (i : Fin (n+1)) := Lagrange.eval_basis_not_at_node (Finset.mem_univ i) (hz i) + simp only [Lagrange.eval_nodal, Lagrange.nodalWeight, Finset.prod_inv_distrib] at hb + have he (i : Fin (n+1)) : + (∏ j ∈ Finset.univ.erase i, (y j-y i)) = + (-1:ℝ)^n * ∏ j ∈ Finset.univ.erase i, (y i-y j) := by + simp_rw [show ∀ j, y j-y i = (-1:ℝ)*(y i-y j) from fun j => by ring] + rw [Finset.prod_mul_distrib] + simp + have he' (i : Fin (n+1)) : + 1 / ((z-y i) * ∏ j ∈ Finset.univ.erase i, (y j-y i)) = + (-1:ℝ)^n * (∏ j ∈ Finset.univ.erase i, (y i-y j))⁻¹ * (z-y i)⁻¹ := by + rw [he, one_div, mul_inv, mul_inv] + ring_nf + simp only [inv_neg, inv_one] + ring + simp_rw [he'] + have hh : (∏ i, (z-y i)) * + (∑ i, (∏ j ∈ Finset.univ.erase i, (y i-y j))⁻¹ * (z-y i)⁻¹) = 1 := by + simpa only [hb, ← Finset.mul_sum] using H + have hd : (∏ i, (z-y i)) ≠ 0 := Finset.prod_ne_zero_iff.mpr fun i _ => sub_ne_zero.mpr (hz i) + have hh' : (∑ i, (∏ j ∈ Finset.univ.erase i, (y i-y j))⁻¹ * (z-y i)⁻¹) = + 1/(∏ i, (z-y i)) := (eq_div_iff hd).mpr (by simpa only [mul_comm] using hh) + calc + _ = (-1:ℝ)^n * (∑ i, (∏ j ∈ Finset.univ.erase i, (y i-y j))⁻¹ * (z-y i)⁻¹) := by + simp_rw [mul_assoc]; rw [Finset.mul_sum] + _ = _ := by rw [hh']; ring + +def reflectionCauchyKernel (n : ℕ) (z : ℝ) (y : Fin (n+1) → ℝ) : ℝ := + reflectionMomentKernel n 0 y / (z-y 0) + +lemma measurable_reflectionCauchyKernel (n : ℕ) (z : ℝ) : + Measurable (reflectionCauchyKernel n z) := + (measurable_reflectionMomentKernel n 0).div (measurable_const.sub (measurable_pi_apply 0)) + +lemma integrable_reflectionCauchyKernel (n : ℕ) {z : ℝ} (hz : 1 < z) : + Integrable (reflectionCauchyKernel n z) (unitCubeMeasure (n+1)) := by + apply integrable_unitCube_of_abs_le_weights (measurable_reflectionCauchyKernel n z) + (b := (z-1)⁻¹) + intro y hy + rw [reflectionCauchyKernel, abs_div, abs_of_pos (by linarith [(hy 0).2] : 0 < z-y 0)] + calc + _ ≤ (∏ i, omega (y i))/(z-1) := div_le_div₀ + (Finset.prod_nonneg fun i _ => omega_nonneg _) (abs_reflectionMomentKernel_le_weights hy) + (by linarith) (by linarith [(hy 0).2]) + _ = _ := by ring + +lemma reflectionCauchyKernel_sum_swaps (n : ℕ) {z : ℝ} {y : Fin (n+1) → ℝ} + (hy : ∀ i, 0 < y i) (hz : ∀ i, z ≠ y i) : + ∑ i, reflectionCauchyKernel n z (y ∘ Equiv.swap 0 i) = + (-1:ℝ)^n * (density (n+1) y / ∏ i, (z-y i)) := by + have he (i : Fin (n+1)) : reflectionCauchyKernel n z (y ∘ Equiv.swap 0 i) = + density (n+1) y * (1 / ((z-y i) * ∏ j ∈ Finset.univ.erase i, (y j-y i))) := by + have hx : 0 < (y ∘ Equiv.swap 0 i) 0 := hy _ + have ht : ∀ j, 0 < Fin.tail (y ∘ Equiv.swap 0 i) j := fun j => hy _ + unfold reflectionCauchyKernel reflectionMomentKernel + rw [pow_zero, one_mul, reflection_with_density_cons hx ht, + Fin.cons_self_tail, density_perm_of_nonneg (fun i => (hy i).le)] + have hp : (∏ j, (Fin.tail (y ∘ Equiv.swap 0 i) j - (y ∘ Equiv.swap 0 i) 0)) = + ∏ j ∈ Finset.univ.erase i, (y j-y i) := by + have he0 : (∏ j, (Fin.tail (y ∘ Equiv.swap 0 i) j - (y ∘ Equiv.swap 0 i) 0)) = + ∏ j ∈ Finset.univ.erase (0 : Fin (n+1)), ((y ∘ Equiv.swap 0 i) j - y i) := by + have he0 : (Finset.univ.erase (0 : Fin (n+1))) = + Finset.univ.filter (fun j => j ≠ 0) := by ext; simp + rw [he0, Finset.prod_filter, Fin.prod_univ_succ] + simp [Fin.tail_def] + have hs : ∏ j ∈ Finset.univ.erase (0 : Fin (n+1)), ((y ∘ Equiv.swap 0 i) j - y i) = + ∏ j ∈ Finset.univ.erase i, (y j-y i) := by + apply Finset.prod_equiv (Equiv.swap 0 i) + · intro j + simp [Equiv.swap_apply_eq_iff] + · intro j hj + rfl + exact he0.trans hs + rw [hp] + simp only [Function.comp_apply, Equiv.swap_apply_left] + rw [one_div, mul_inv] + ring + simp_rw [he, ← Finset.mul_sum] + by_cases hi : Function.Injective y + · rw [lagrange_reverse_cauchy_sum hi hz] + ring + · rw [density_zero_of_not_injective hi, zero_mul, zero_div, mul_zero] + + +def cauchyDensity (n : ℕ) (z : ℝ) (y : Fin n → ℝ) : ℝ := + density n y / ∏ i, (z-y i) + +lemma integrable_cauchyDensity (n : ℕ) {z : ℝ} (hz : 1 < z) : + Integrable (cauchyDensity n z) (unitCubeMeasure n) := by + have hi : Integrable (fun y : Fin n → ℝ => (∏ i, (z-y i))⁻¹ * density n y) + (unitCubeMeasure n) := by + apply integrable_cube_mul_density (by fun_prop) (b := ((z-1)⁻¹)^n) + intro y hy + rw [abs_inv, Finset.abs_prod, ← Finset.prod_inv_distrib] + have hh (i : Fin n) : |z-y i|⁻¹ ≤ (z-1)⁻¹ := by + rw [abs_of_pos (by linarith [(hy i).2] : 0 < z-y i)] + exact inv_anti₀ (by linarith) (by linarith [(hy i).2]) + calc + _ ≤ ∏ _ : Fin n, (z-1)⁻¹ := Finset.prod_le_prod₀ + (fun i _ => inv_nonneg.mpr (abs_nonneg _)) (fun i _ => hh i) + _ = _ := by simp + exact hi.congr (Filter.Eventually.of_forall fun y => by dsimp [cauchyDensity]; ring) + +lemma integral_cauchyDensity_pos (n : ℕ) {z : ℝ} (hz : 1 < z) : + 0 < ∫ y, cauchyDensity n z y ∂unitCubeMeasure n := by + apply integral_pos_on_cube (integrable_cauchyDensity n hz) + · intro y hy + exact div_nonneg (density_nonneg_of_nonneg fun i => (hy i).1.le) + (Finset.prod_nonneg fun i _ => by linarith [(hy i).2]) + · intro y hy + exact div_pos (density_pos hy) (Finset.prod_pos fun i _ => by linarith [(hy.2 i).2]) + +lemma integral_reflectionCauchyKernel (n : ℕ) {z : ℝ} (hz : 1 < z) : + ((n:ℝ)+1) * (∫ y, reflectionCauchyKernel n z y ∂unitCubeMeasure (n+1)) = + (-1:ℝ)^n * ∫ y, cauchyDensity (n+1) z y ∂unitCubeMeasure (n+1) := by + have his (i : Fin (n+1)) : Integrable + (fun y => reflectionCauchyKernel n z (y ∘ Equiv.swap 0 i)) (unitCubeMeasure (n+1)) := by + simpa only [Function.comp_def, StripPfaffian.piCongrLeft_const_apply, Equiv.symm_symm] using + (measurePreserving_piCongrLeft (fun _ : Fin (n+1) => volume.restrict (Ioo (0:ℝ) 1)) + (Equiv.swap 0 i).symm).integrable_comp_of_integrable (integrable_reflectionCauchyKernel n hz) + have he (i : Fin (n+1)) : + (∫ y, reflectionCauchyKernel n z (y ∘ Equiv.swap 0 i) ∂unitCubeMeasure (n+1)) = + ∫ y, reflectionCauchyKernel n z y ∂unitCubeMeasure (n+1) := by + simpa only [StripPfaffian.piCongrLeft_const_apply, Equiv.symm_symm] using + (measurePreserving_piCongrLeft (fun _ : Fin (n+1) => volume.restrict (Ioo (0:ℝ) 1)) + (Equiv.swap 0 i).symm).integral_comp' (reflectionCauchyKernel n z) + calc + _ = ∑ i : Fin (n+1), ∫ y, reflectionCauchyKernel n z (y ∘ Equiv.swap 0 i) ∂unitCubeMeasure (n+1) := by + simp only [he, Finset.sum_const, Finset.card_univ, Fintype.card_fin, nsmul_eq_mul, Nat.cast_add, Nat.cast_one] + _ = ∫ y, ∑ i : Fin (n+1), reflectionCauchyKernel n z (y ∘ Equiv.swap 0 i) ∂unitCubeMeasure (n+1) := + (integral_finsetSum _ (fun i _ => his i)).symm + _ = ∫ y, (-1:ℝ)^n * cauchyDensity (n+1) z y ∂unitCubeMeasure (n+1) := by + apply integral_congr_ae + filter_upwards [ae_unitCube (n+1)] with y hy + exact reflectionCauchyKernel_sum_swaps n (fun i => (hy i).1) (fun i => by linarith [(hy i).2]) + _ = _ := integral_const_mul _ _ + +lemma integral_density_unitCube_positive (n : ℕ) : + 0 < ∫ y, density n y ∂unitCubeMeasure n := by + rw [integral_density_unitCube] + exact mul_pos (by exact_mod_cast Nat.factorial_pos n) (normalizer_pos n) + +lemma reflection_expectation_cauchy (n : ℕ) {z : ℝ} (hz : 1 < z) : + realStieltjes 1 (fun x => expectation n (reflectionProduct n x) * omega x) z = + ((-1:ℝ)^n * ∫ y, cauchyDensity (n+1) z y ∂unitCubeMeasure (n+1)) / + (((n:ℝ)+1) * ∫ y, density n y ∂unitCubeMeasure n) := by + have hF := integral_reflectionCauchyKernel n hz + rw [integral_unitCube_cons, + integral_prod _ (integrable_unitCube_cons (integrable_reflectionCauchyKernel n hz))] at hF + have he (x : ℝ) : (∫ y, reflectionCauchyKernel n z (Fin.cons x y) ∂unitCubeMeasure n) = + (omega x / (z-x)) * (∫ y, reflectionProduct n x y * density n y ∂unitCubeMeasure n) := by + simp only [reflectionCauchyKernel, reflectionMomentKernel, pow_zero, one_mul, + Fin.cons_zero, Fin.tail_cons] + simp_rw [show ∀ y : Fin n → ℝ, omega x * reflectionProduct n x y * density n y / (z-x) = + (omega x/(z-x)) * (reflectionProduct n x y * density n y) from fun y => by ring] + rw [integral_const_mul] + simp_rw [he] at hF + have hh : (∫ x in Ioo (0:ℝ) 1, (omega x / (z-x)) * + (∫ y, reflectionProduct n x y * density n y ∂unitCubeMeasure n)) = + (∫ y, density n y ∂unitCubeMeasure n) * + realStieltjes 1 (fun x => expectation n (reflectionProduct n x) * omega x) z := by + rw [realStieltjes, ← integral_const_mul] + apply setIntegral_congr_fun measurableSet_Ioo + intro x hx + dsimp only + rw [expectation_reflection_unitCube n hx.1.le, one_mul] + field_simp [integral_density_unitCube_positive n |>.ne'] + rw [hh] at hF + exact (eq_div_iff (mul_ne_zero (by positivity) (integral_density_unitCube_positive n).ne')).mpr + (by nlinarith [hF]) + + + + + + + +lemma projection_initial_monic {n : ℕ} (hn : 1 ≤ n) {g P J E : Polynomial ℝ} + (hg : g.Monic) (hd : g.natDegree = n) + (hP : P.natDegree ≤ n) (hJ : J.natDegree ≤ n) (hE : E.degree < (n : WithBot ℕ)) + (hQ : homogeneousQ n g = P.comp harmonicCoordinate + X * J.comp harmonicCoordinate + + X^2 * E.comp harmonicCoordinate) : + (tildePoly n J).eval 0 = ((-8:ℝ)^n)⁻¹ := by + have ht := (projection_top_coefficients n hn P J E hP hJ hE).1 + rw [← hQ, ← homogeneousQ_natDegree hg hd, (homogeneousQ_monic hg).coeff_natDegree] at ht + apply (mul_left_cancel₀ (pow_ne_zero n (by norm_num : (-8:ℝ) ≠ 0))) + rw [mul_inv_cancel₀ (pow_ne_zero n (by norm_num : (-8:ℝ) ≠ 0))] + exact ht.symm + +lemma projectionF_positive_cauchy {n : ℕ} (hn : 1 ≤ n) {g P J E : Polynomial ℝ} + (hg : g.Monic) (hd : g.natDegree = n) + (hP : P.natDegree ≤ n) (hJ : J.natDegree ≤ n) (hE : E.degree < (n : WithBot ℕ)) + (hQ : homogeneousQ n g = P.comp harmonicCoordinate + X * J.comp harmonicCoordinate + + X^2 * E.comp harmonicCoordinate) {z : ℝ} (hz : 1 < z) : + projectionF (tildePoly n P) (tildePoly n J) (tildePoly n E) z = + - (∫ y, cauchyDensity (n+1) z y ∂unitCubeMeasure (n+1)) / + (Real.pi * (8:ℝ)^n * ((n:ℝ)+1) * ∫ y, density n y ∂unitCubeMeasure n) := by + have hD := projectionD_expectation n hn g P J E hP hJ hE hQ + have hF : Tendsto (fun t : ℝ => projectionF (tildePoly n P) (tildePoly n J) (tildePoly n E) (-t)) + atTop (𝓝 0) := by + simpa only [pow_zero,one_mul, projectionF, fBranch, highBranch] using tilde_F_decay n g P J E hP hJ + (degree_lt_implies_natDegree_lt (by omega) hE).le hQ 0 (Nat.zero_le n) + rw [projectionF_cauchy_outside _ _ _ hF z (Or.inr hz)] + have he : realStieltjes 1 (fun x => projectionD (tildePoly n J) (tildePoly n E) x * omega x) z = + (tildePoly n J).eval 0 * realStieltjes 1 (fun x => expectation n (reflectionProduct n x) * omega x) z := by + rw [realStieltjes, realStieltjes, ← integral_const_mul] + apply setIntegral_congr_fun measurableSet_Ioo + intro x hx + dsimp only + rw [hD x hx.1] + ring + rw [he, projection_initial_monic hn hg hd hP hJ hE hQ, reflection_expectation_cauchy n hz] + have hs : (-8:ℝ)^n * (-1:ℝ)^n = (8:ℝ)^n := by rw [← mul_pow]; norm_num + have hs' : ((-8:ℝ)^n)⁻¹ * (-1:ℝ)^n = ((8:ℝ)^n)⁻¹ := by + have hp : (-1:ℝ)^n * (-1:ℝ)^n=1 := by rw [←mul_pow]; norm_num + apply (mul_left_cancel₀ (by positivity : (8:ℝ)^n≠0)) + rw [mul_inv_cancel₀ (by positivity : (8:ℝ)^n≠0),←hs] + calc + _ = ((-8:ℝ)^n * ((-8:ℝ)^n)⁻¹) * ((-1:ℝ)^n * (-1:ℝ)^n) := by ring + _ = 1 := by rw [mul_inv_cancel₀ (pow_ne_zero n (by norm_num : (-8:ℝ)≠0)),hp,one_mul] + calc + _ = -(1/Real.pi) * (((-8:ℝ)^n)⁻¹ * (-1:ℝ)^n) * + (∫ y, cauchyDensity (n+1) z y ∂unitCubeMeasure (n+1)) / + (((n:ℝ)+1) * ∫ y, density n y ∂unitCubeMeasure n) := by ring + _ = _ := by rw [hs']; simp only [div_eq_mul_inv, mul_inv]; ring + +lemma projectionF_neg {n : ℕ} (hn : 1 ≤ n) {g P J E : Polynomial ℝ} + (hg : g.Monic) (hd : g.natDegree = n) + (hP : P.natDegree ≤ n) (hJ : J.natDegree ≤ n) (hE : E.degree < (n : WithBot ℕ)) + (hQ : homogeneousQ n g = P.comp harmonicCoordinate + X * J.comp harmonicCoordinate + + X^2 * E.comp harmonicCoordinate) {z : ℝ} (hz : 1 < z) : + projectionF (tildePoly n P) (tildePoly n J) (tildePoly n E) z < 0 := by + rw [projectionF_positive_cauchy hn hg hd hP hJ hE hQ hz] + exact div_neg_of_neg_of_pos (neg_neg_of_pos (integral_cauchyDensity_pos _ hz)) + (by have hp := Real.pi_pos; have hi := integral_density_unitCube_positive n; positivity) + + + + + + + +lemma scaled_cauchyDensity (n : ℕ) {z : ℝ} (hz : z ≠ 0) (y : Fin n → ℝ) : + z^n * cauchyDensity n z y = (∏ i, (1-y i/z)⁻¹) * density n y := by + have he (i : Fin n) : (1-y i/z)⁻¹ = z / (z-y i) := by + rw [show 1-y i/z = (z-y i)/z by field_simp, inv_div] + simp_rw [he] + rw [Finset.prod_div_distrib] + simp only [Finset.prod_const,Finset.card_univ,Fintype.card_fin,cauchyDensity] + ring + +lemma scaled_cauchyDensity_bound {n : ℕ} {z : ℝ} (hz : 2 ≤ z) {y : Fin n → ℝ} + (hy : ∀ i, y i ∈ Ioo (0:ℝ) 1) : + ‖(∏ i, (1-y i/z)⁻¹) * density n y‖ ≤ (2:ℝ)^n * density n y := by + have hd i : 1/2 ≤ 1-y i/z := by + have hdiv : y i/z ≤ 1/2 := (div_le_iff₀ (by linarith : 0 hn i) + (density_nonneg_of_nonneg fun i => (hy i).1.le))] + apply mul_le_mul_of_nonneg_right _ (density_nonneg_of_nonneg fun i => (hy i).1.le) + calc + _ ≤ ∏ _ : Fin n, (2:ℝ) := Finset.prod_le_prod₀ (fun i _ => hn i) (fun i _ => by + have hh := inv_anti₀ (by norm_num : (0:ℝ)<1/2) (hd i) + norm_num at hh + exact hh) + _ = _ := by simp + +lemma cauchyDensity_limit (n : ℕ) : + Tendsto (fun z : ℝ => z^n * ∫ y, cauchyDensity n z y ∂unitCubeMeasure n) + atTop (𝓝 (∫ y, density n y ∂unitCubeMeasure n)) := by + have hi : Tendsto (fun z : ℝ => ∫ y, (∏ i, (1-y i/z)⁻¹) * density n y ∂unitCubeMeasure n) + atTop (𝓝 (∫ y, density n y ∂unitCubeMeasure n)) := by + apply tendsto_integral_filter_of_dominated_convergence (fun y => (2:ℝ)^n * density n y) + · exact Filter.Eventually.of_forall fun z => ((by fun_prop : Measurable + (fun y : Fin n → ℝ => (∏ i, (1-y i/z)⁻¹))).mul (measurable_density n)).aestronglyMeasurable + · filter_upwards [eventually_ge_atTop (2:ℝ)] with z hz + filter_upwards [ae_unitCube n] with y hy + exact scaled_cauchyDensity_bound hz hy + · exact (integrable_density_unitCube n).const_mul _ + · exact Filter.Eventually.of_forall fun y => by + have ht (i : Fin n) : Tendsto (fun z : ℝ => (1-y i/z)⁻¹) atTop (𝓝 1) := by + have hh : Tendsto (fun z : ℝ => 1-y i/z) atTop (𝓝 1) := by + simpa only [mul_zero,sub_zero,div_eq_mul_inv] using + ((tendsto_inv_atTop_zero : Tendsto (fun z : ℝ => z⁻¹) atTop (𝓝 0)).const_mul (y i)).const_sub 1 + simpa only [inv_one] using hh.inv₀ (by norm_num : (1:ℝ)≠0) + simpa using (tendsto_finsetProd Finset.univ (fun i _ => ht i)).mul_const (density n y) + apply hi.congr' + filter_upwards [eventually_gt_atTop (0:ℝ)] with z hz + rw [←integral_const_mul] + apply integral_congr_ae + exact Filter.Eventually.of_forall fun y => (scaled_cauchyDensity n hz.ne' y).symm + +end +end CriticalStrip + +end OAI diff --git a/lean/OAI/Combinatorics/StripMass/RootOfUnityPowers.lean b/lean/OAI/Combinatorics/StripMass/RootOfUnityPowers.lean new file mode 100644 index 0000000000000000000000000000000000000000..29afd525d2fb11dd3902ac72f85a3328aaf4f9e7 --- /dev/null +++ b/lean/OAI/Combinatorics/StripMass/RootOfUnityPowers.lean @@ -0,0 +1,465 @@ +import Mathlib +import OAI.Combinatorics.StripMass.Basic + +namespace OAI + +/-! Critical honeycomb strip paths, polynomial identities and crossing mass. -/ + + + +namespace CriticalStrip.Diagram + +theorem eighthRoot_power {K : Type*} [CommRing K] {q : K} (h : q^8 = -1) (k : ℕ) : + q^k = (-1)^(k/8) * q^(k%8) := by + calc + q^k = q^(8*(k/8)+k%8) := congrArg (q^·) (by omega) + _ = (q^8)^(k/8) * q^(k%8) := by rw [pow_add, pow_mul] + _ = _ := by rw [h] + +theorem eighthRoot_power_8 {K : Type*} [CommRing K] {q : K} (h : q^8 = -1) : + q^8 = -(1) := by + have ht := eighthRoot_power h 8 + norm_num at ht + simpa only [pow_one] using ht + +theorem eighthRoot_power_9 {K : Type*} [CommRing K] {q : K} (h : q^8 = -1) : + q^9 = -(q^1) := by + have ht := eighthRoot_power h 9 + norm_num at ht + simpa only [pow_one] using ht + +theorem eighthRoot_power_10 {K : Type*} [CommRing K] {q : K} (h : q^8 = -1) : + q^10 = -(q^2) := by + have ht := eighthRoot_power h 10 + norm_num at ht + simpa only [pow_one] using ht + +theorem eighthRoot_power_11 {K : Type*} [CommRing K] {q : K} (h : q^8 = -1) : + q^11 = -(q^3) := by + have ht := eighthRoot_power h 11 + norm_num at ht + simpa only [pow_one] using ht + +theorem eighthRoot_power_12 {K : Type*} [CommRing K] {q : K} (h : q^8 = -1) : + q^12 = -(q^4) := by + have ht := eighthRoot_power h 12 + norm_num at ht + simpa only [pow_one] using ht + +theorem eighthRoot_power_13 {K : Type*} [CommRing K] {q : K} (h : q^8 = -1) : + q^13 = -(q^5) := by + have ht := eighthRoot_power h 13 + norm_num at ht + simpa only [pow_one] using ht + +theorem eighthRoot_power_14 {K : Type*} [CommRing K] {q : K} (h : q^8 = -1) : + q^14 = -(q^6) := by + have ht := eighthRoot_power h 14 + norm_num at ht + simpa only [pow_one] using ht + +theorem eighthRoot_power_15 {K : Type*} [CommRing K] {q : K} (h : q^8 = -1) : + q^15 = -(q^7) := by + have ht := eighthRoot_power h 15 + norm_num at ht + simpa only [pow_one] using ht + +theorem eighthRoot_power_16 {K : Type*} [CommRing K] {q : K} (h : q^8 = -1) : + q^16 = (1) := by + have ht := eighthRoot_power h 16 + norm_num at ht + simpa only [pow_one] using ht + +theorem eighthRoot_power_17 {K : Type*} [CommRing K] {q : K} (h : q^8 = -1) : + q^17 = (q^1) := by + have ht := eighthRoot_power h 17 + norm_num at ht + simpa only [pow_one] using ht + +theorem eighthRoot_power_18 {K : Type*} [CommRing K] {q : K} (h : q^8 = -1) : + q^18 = (q^2) := by + have ht := eighthRoot_power h 18 + norm_num at ht + simpa only [pow_one] using ht + +theorem eighthRoot_power_19 {K : Type*} [CommRing K] {q : K} (h : q^8 = -1) : + q^19 = (q^3) := by + have ht := eighthRoot_power h 19 + norm_num at ht + simpa only [pow_one] using ht + +theorem eighthRoot_power_20 {K : Type*} [CommRing K] {q : K} (h : q^8 = -1) : + q^20 = (q^4) := by + have ht := eighthRoot_power h 20 + norm_num at ht + simpa only [pow_one] using ht + +theorem eighthRoot_power_21 {K : Type*} [CommRing K] {q : K} (h : q^8 = -1) : + q^21 = (q^5) := by + have ht := eighthRoot_power h 21 + norm_num at ht + simpa only [pow_one] using ht + +theorem eighthRoot_power_22 {K : Type*} [CommRing K] {q : K} (h : q^8 = -1) : + q^22 = (q^6) := by + have ht := eighthRoot_power h 22 + norm_num at ht + simpa only [pow_one] using ht + +theorem eighthRoot_power_23 {K : Type*} [CommRing K] {q : K} (h : q^8 = -1) : + q^23 = (q^7) := by + have ht := eighthRoot_power h 23 + norm_num at ht + simpa only [pow_one] using ht + +theorem eighthRoot_power_24 {K : Type*} [CommRing K] {q : K} (h : q^8 = -1) : + q^24 = -(1) := by + have ht := eighthRoot_power h 24 + norm_num at ht + simpa only [pow_one] using ht + +theorem eighthRoot_power_25 {K : Type*} [CommRing K] {q : K} (h : q^8 = -1) : + q^25 = -(q^1) := by + have ht := eighthRoot_power h 25 + norm_num at ht + simpa only [pow_one] using ht + +theorem eighthRoot_power_26 {K : Type*} [CommRing K] {q : K} (h : q^8 = -1) : + q^26 = -(q^2) := by + have ht := eighthRoot_power h 26 + norm_num at ht + simpa only [pow_one] using ht + +theorem eighthRoot_power_27 {K : Type*} [CommRing K] {q : K} (h : q^8 = -1) : + q^27 = -(q^3) := by + have ht := eighthRoot_power h 27 + norm_num at ht + simpa only [pow_one] using ht + +theorem eighthRoot_power_28 {K : Type*} [CommRing K] {q : K} (h : q^8 = -1) : + q^28 = -(q^4) := by + have ht := eighthRoot_power h 28 + norm_num at ht + simpa only [pow_one] using ht + +theorem eighthRoot_power_29 {K : Type*} [CommRing K] {q : K} (h : q^8 = -1) : + q^29 = -(q^5) := by + have ht := eighthRoot_power h 29 + norm_num at ht + simpa only [pow_one] using ht + +theorem eighthRoot_power_30 {K : Type*} [CommRing K] {q : K} (h : q^8 = -1) : + q^30 = -(q^6) := by + have ht := eighthRoot_power h 30 + norm_num at ht + simpa only [pow_one] using ht + +theorem eighthRoot_power_31 {K : Type*} [CommRing K] {q : K} (h : q^8 = -1) : + q^31 = -(q^7) := by + have ht := eighthRoot_power h 31 + norm_num at ht + simpa only [pow_one] using ht + +theorem eighthRoot_power_32 {K : Type*} [CommRing K] {q : K} (h : q^8 = -1) : + q^32 = (1) := by + have ht := eighthRoot_power h 32 + norm_num at ht + simpa only [pow_one] using ht + +theorem eighthRoot_power_33 {K : Type*} [CommRing K] {q : K} (h : q^8 = -1) : + q^33 = (q^1) := by + have ht := eighthRoot_power h 33 + norm_num at ht + simpa only [pow_one] using ht + +theorem eighthRoot_power_34 {K : Type*} [CommRing K] {q : K} (h : q^8 = -1) : + q^34 = (q^2) := by + have ht := eighthRoot_power h 34 + norm_num at ht + simpa only [pow_one] using ht + +theorem eighthRoot_power_35 {K : Type*} [CommRing K] {q : K} (h : q^8 = -1) : + q^35 = (q^3) := by + have ht := eighthRoot_power h 35 + norm_num at ht + simpa only [pow_one] using ht + +theorem eighthRoot_power_36 {K : Type*} [CommRing K] {q : K} (h : q^8 = -1) : + q^36 = (q^4) := by + have ht := eighthRoot_power h 36 + norm_num at ht + simpa only [pow_one] using ht + +theorem eighthRoot_power_37 {K : Type*} [CommRing K] {q : K} (h : q^8 = -1) : + q^37 = (q^5) := by + have ht := eighthRoot_power h 37 + norm_num at ht + simpa only [pow_one] using ht + +theorem eighthRoot_power_38 {K : Type*} [CommRing K] {q : K} (h : q^8 = -1) : + q^38 = (q^6) := by + have ht := eighthRoot_power h 38 + norm_num at ht + simpa only [pow_one] using ht + +theorem eighthRoot_power_39 {K : Type*} [CommRing K] {q : K} (h : q^8 = -1) : + q^39 = (q^7) := by + have ht := eighthRoot_power h 39 + norm_num at ht + simpa only [pow_one] using ht + +theorem eighthRoot_power_40 {K : Type*} [CommRing K] {q : K} (h : q^8 = -1) : + q^40 = -(1) := by + have ht := eighthRoot_power h 40 + norm_num at ht + simpa only [pow_one] using ht + +theorem eighthRoot_power_41 {K : Type*} [CommRing K] {q : K} (h : q^8 = -1) : + q^41 = -(q^1) := by + have ht := eighthRoot_power h 41 + norm_num at ht + simpa only [pow_one] using ht + +theorem eighthRoot_power_42 {K : Type*} [CommRing K] {q : K} (h : q^8 = -1) : + q^42 = -(q^2) := by + have ht := eighthRoot_power h 42 + norm_num at ht + simpa only [pow_one] using ht + +theorem eighthRoot_power_43 {K : Type*} [CommRing K] {q : K} (h : q^8 = -1) : + q^43 = -(q^3) := by + have ht := eighthRoot_power h 43 + norm_num at ht + simpa only [pow_one] using ht + +theorem eighthRoot_power_44 {K : Type*} [CommRing K] {q : K} (h : q^8 = -1) : + q^44 = -(q^4) := by + have ht := eighthRoot_power h 44 + norm_num at ht + simpa only [pow_one] using ht + +theorem eighthRoot_power_45 {K : Type*} [CommRing K] {q : K} (h : q^8 = -1) : + q^45 = -(q^5) := by + have ht := eighthRoot_power h 45 + norm_num at ht + simpa only [pow_one] using ht + +theorem eighthRoot_power_46 {K : Type*} [CommRing K] {q : K} (h : q^8 = -1) : + q^46 = -(q^6) := by + have ht := eighthRoot_power h 46 + norm_num at ht + simpa only [pow_one] using ht + +theorem eighthRoot_power_47 {K : Type*} [CommRing K] {q : K} (h : q^8 = -1) : + q^47 = -(q^7) := by + have ht := eighthRoot_power h 47 + norm_num at ht + simpa only [pow_one] using ht + +theorem eighthRoot_power_48 {K : Type*} [CommRing K] {q : K} (h : q^8 = -1) : + q^48 = (1) := by + have ht := eighthRoot_power h 48 + norm_num at ht + simpa only [pow_one] using ht + + + + + + + +theorem eighthRoot_power_49 {K : Type*} [CommRing K] {q : K} (h : q^8 = -1) : + q^49 = (q^1) := by + have ht := eighthRoot_power h 49 + norm_num at ht + simpa only [pow_one] using ht + +theorem eighthRoot_power_50 {K : Type*} [CommRing K] {q : K} (h : q^8 = -1) : + q^50 = (q^2) := by + have ht := eighthRoot_power h 50 + norm_num at ht + simpa only [pow_one] using ht + +theorem eighthRoot_power_51 {K : Type*} [CommRing K] {q : K} (h : q^8 = -1) : + q^51 = (q^3) := by + have ht := eighthRoot_power h 51 + norm_num at ht + simpa only [pow_one] using ht + +theorem eighthRoot_power_52 {K : Type*} [CommRing K] {q : K} (h : q^8 = -1) : + q^52 = (q^4) := by + have ht := eighthRoot_power h 52 + norm_num at ht + simpa only [pow_one] using ht + +theorem eighthRoot_power_53 {K : Type*} [CommRing K] {q : K} (h : q^8 = -1) : + q^53 = (q^5) := by + have ht := eighthRoot_power h 53 + norm_num at ht + simpa only [pow_one] using ht + +theorem eighthRoot_power_54 {K : Type*} [CommRing K] {q : K} (h : q^8 = -1) : + q^54 = (q^6) := by + have ht := eighthRoot_power h 54 + norm_num at ht + simpa only [pow_one] using ht + +theorem eighthRoot_power_55 {K : Type*} [CommRing K] {q : K} (h : q^8 = -1) : + q^55 = (q^7) := by + have ht := eighthRoot_power h 55 + norm_num at ht + simpa only [pow_one] using ht + +theorem eighthRoot_power_56 {K : Type*} [CommRing K] {q : K} (h : q^8 = -1) : + q^56 = -(1) := by + have ht := eighthRoot_power h 56 + norm_num at ht + simpa only [pow_one] using ht + +theorem eighthRoot_power_57 {K : Type*} [CommRing K] {q : K} (h : q^8 = -1) : + q^57 = -(q^1) := by + have ht := eighthRoot_power h 57 + norm_num at ht + simpa only [pow_one] using ht + +theorem eighthRoot_power_58 {K : Type*} [CommRing K] {q : K} (h : q^8 = -1) : + q^58 = -(q^2) := by + have ht := eighthRoot_power h 58 + norm_num at ht + simpa only [pow_one] using ht + +theorem eighthRoot_power_59 {K : Type*} [CommRing K] {q : K} (h : q^8 = -1) : + q^59 = -(q^3) := by + have ht := eighthRoot_power h 59 + norm_num at ht + simpa only [pow_one] using ht + +theorem eighthRoot_power_60 {K : Type*} [CommRing K] {q : K} (h : q^8 = -1) : + q^60 = -(q^4) := by + have ht := eighthRoot_power h 60 + norm_num at ht + simpa only [pow_one] using ht + +theorem eighthRoot_power_61 {K : Type*} [CommRing K] {q : K} (h : q^8 = -1) : + q^61 = -(q^5) := by + have ht := eighthRoot_power h 61 + norm_num at ht + simpa only [pow_one] using ht + +theorem eighthRoot_power_62 {K : Type*} [CommRing K] {q : K} (h : q^8 = -1) : + q^62 = -(q^6) := by + have ht := eighthRoot_power h 62 + norm_num at ht + simpa only [pow_one] using ht + +theorem eighthRoot_power_63 {K : Type*} [CommRing K] {q : K} (h : q^8 = -1) : + q^63 = -(q^7) := by + have ht := eighthRoot_power h 63 + norm_num at ht + simpa only [pow_one] using ht + +theorem eighthRoot_power_64 {K : Type*} [CommRing K] {q : K} (h : q^8 = -1) : + q^64 = (1) := by + have ht := eighthRoot_power h 64 + norm_num at ht + simpa only [pow_one] using ht + +theorem eighthRoot_power_65 {K : Type*} [CommRing K] {q : K} (h : q^8 = -1) : + q^65 = (q^1) := by + have ht := eighthRoot_power h 65 + norm_num at ht + simpa only [pow_one] using ht + +theorem eighthRoot_power_66 {K : Type*} [CommRing K] {q : K} (h : q^8 = -1) : + q^66 = (q^2) := by + have ht := eighthRoot_power h 66 + norm_num at ht + simpa only [pow_one] using ht + +theorem eighthRoot_power_67 {K : Type*} [CommRing K] {q : K} (h : q^8 = -1) : + q^67 = (q^3) := by + have ht := eighthRoot_power h 67 + norm_num at ht + simpa only [pow_one] using ht + +theorem eighthRoot_power_68 {K : Type*} [CommRing K] {q : K} (h : q^8 = -1) : + q^68 = (q^4) := by + have ht := eighthRoot_power h 68 + norm_num at ht + simpa only [pow_one] using ht + +theorem eighthRoot_power_69 {K : Type*} [CommRing K] {q : K} (h : q^8 = -1) : + q^69 = (q^5) := by + have ht := eighthRoot_power h 69 + norm_num at ht + simpa only [pow_one] using ht + +theorem eighthRoot_power_70 {K : Type*} [CommRing K] {q : K} (h : q^8 = -1) : + q^70 = (q^6) := by + have ht := eighthRoot_power h 70 + norm_num at ht + simpa only [pow_one] using ht + +theorem eighthRoot_power_71 {K : Type*} [CommRing K] {q : K} (h : q^8 = -1) : + q^71 = (q^7) := by + have ht := eighthRoot_power h 71 + norm_num at ht + simpa only [pow_one] using ht + +theorem eighthRoot_power_72 {K : Type*} [CommRing K] {q : K} (h : q^8 = -1) : + q^72 = -(1) := by + have ht := eighthRoot_power h 72 + norm_num at ht + simpa only [pow_one] using ht + +theorem eighthRoot_power_73 {K : Type*} [CommRing K] {q : K} (h : q^8 = -1) : + q^73 = -(q^1) := by + have ht := eighthRoot_power h 73 + norm_num at ht + simpa only [pow_one] using ht + +theorem eighthRoot_power_74 {K : Type*} [CommRing K] {q : K} (h : q^8 = -1) : + q^74 = -(q^2) := by + have ht := eighthRoot_power h 74 + norm_num at ht + simpa only [pow_one] using ht + +theorem eighthRoot_power_75 {K : Type*} [CommRing K] {q : K} (h : q^8 = -1) : + q^75 = -(q^3) := by + have ht := eighthRoot_power h 75 + norm_num at ht + simpa only [pow_one] using ht + +theorem eighthRoot_power_76 {K : Type*} [CommRing K] {q : K} (h : q^8 = -1) : + q^76 = -(q^4) := by + have ht := eighthRoot_power h 76 + norm_num at ht + simpa only [pow_one] using ht + +theorem eighthRoot_power_77 {K : Type*} [CommRing K] {q : K} (h : q^8 = -1) : + q^77 = -(q^5) := by + have ht := eighthRoot_power h 77 + norm_num at ht + simpa only [pow_one] using ht + +theorem eighthRoot_power_78 {K : Type*} [CommRing K] {q : K} (h : q^8 = -1) : + q^78 = -(q^6) := by + have ht := eighthRoot_power h 78 + norm_num at ht + simpa only [pow_one] using ht + +theorem eighthRoot_power_79 {K : Type*} [CommRing K] {q : K} (h : q^8 = -1) : + q^79 = -(q^7) := by + have ht := eighthRoot_power h 79 + norm_num at ht + simpa only [pow_one] using ht + +theorem eighthRoot_power_80 {K : Type*} [CommRing K] {q : K} (h : q^8 = -1) : + q^80 = (1) := by + have ht := eighthRoot_power h 80 + norm_num at ht + simpa only [pow_one] using ht + +end CriticalStrip.Diagram + +end OAI diff --git a/lean/OAI/Combinatorics/StripMass/ScalarBridge.lean b/lean/OAI/Combinatorics/StripMass/ScalarBridge.lean new file mode 100644 index 0000000000000000000000000000000000000000..c576c05007dfa11a68046b9eeefadee8f4690503 --- /dev/null +++ b/lean/OAI/Combinatorics/StripMass/ScalarBridge.lean @@ -0,0 +1,534 @@ +import Mathlib +import OAI.Combinatorics.StripMass.PairCoordinates +import OAI.Combinatorics.StripMass.ArchRoots + +namespace OAI + +/-! Critical honeycomb strip paths, polynomial identities and crossing mass. -/ + + +namespace CriticalStrip.Diagram +noncomputable section +open scoped Classical BigOperators + + + +theorem pfaffian_eq_exterior (m : ℕ) (A : Matrix (Fin (m*2)) (Fin (m*2)) ℂ) + (hA : ∀ i j, A j i = -A i j) : + pfaffian A = StripPfaffian.pfaffian (m*2) A := by + rw [StripPfaffian.pfaffian_permutation_expansion m A hA] + unfold pfaffian + simp only [Nat.mul_div_cancel m (by omega : 0<2)] + have hc : ((2:ℂ)^m * (m.factorial:ℂ))⁻¹ = (1/2:ℂ)^m / m.factorial := by + simp [mul_inv_rev, div_eq_mul_inv, mul_comm] + rw [hc] + congr 1 + apply Finset.sum_congr rfl + intro σ _ + congr 1 + unfold StripPfaffian.pairEntries + apply Fintype.prod_equiv (finCongr (Nat.mul_div_cancel m (by norm_num : 0 < 2))) + intro i + congr 2 <;> apply Fin.ext <;> + simp [pairFirst,pairSecond,StripPfaffian.pairLeft,StripPfaffian.pairRight, + finProdFinEquiv,mul_comm,add_comm] + +lemma augmentedKernel_skew_complex {n : ℕ} (a : Fin n → ℂ) : + ∀ i j, augmentedKernel (d:ℂ) (rho:ℂ) a j i = + -augmentedKernel (d:ℂ) (rho:ℂ) a i j := by + intro i j + by_cases hi : i.val by_cases hj : j.valA (i.cast he.symm) (j.cast he.symm) + calc + pfaffian A = pfaffian A' := (pfaffian_cast he A).symm + _ = StripPfaffian.pfaffian (((n+1)/2)*2) A' := + pfaffian_eq_exterior _ _ (fun i j =>augmentedKernel_skew_complex a _ _) + _ = StripPfaffian.pfaffian (StripPfaffian.pfSize n) + (StripPfaffian.augmentedKernel n a) := by + have he' : ((n+1)/2)*2=StripPfaffian.pfSize n := by + unfold StripPfaffian.pfSize; omega + have hcast {u v:ℕ} (h:u=v) (M:Matrix (Fin u) (Fin u) ℂ) : + StripPfaffian.pfaffian v (fun i j=>M (i.cast h.symm) (j.cast h.symm)) = + StripPfaffian.pfaffian u M := by subst v; rfl + rw [←hcast he' A'] + congr 1 + +end + +noncomputable section +open scoped Classical BigOperators +open Filter Topology + +lemma scalarValue_eq_exterior {n : ℕ} (a : Fin n → ℂ) + (ha : Function.Injective a) + (hD : ∀ i j, i ≠ j → StripPfaffian.D (a i) (a j) ≠ 0) : + scalarValue (RingHom.id ℂ) a=StripPfaffian.p n a := by + have hD' : ∀ i j, i≠j → discriminant ((RingHom.id ℂ) (d:ℂ)) (a i) (a j)≠0 := hD + rw [scalarValue, scalarPolynomial_eval (RingHom.id ℂ) n (d:ℂ) (rho:ℂ) _ a ha hD'] + exact scalarNormalization_eq_exterior a + + + +def archPolynomialAt {n : ℕ} (a : Fin n → ℂ) : Polynomial ℂ := + Polynomial.C (scalarValue (RingHom.id ℂ) a)⁻¹ * nextScalar (RingHom.id ℂ) a + +lemma archPolynomialAt_monic_degree {n : ℕ} (a : Fin n → ℂ) + (hp : scalarValue (RingHom.id ℂ) a≠0) : + (archPolynomialAt a).Monic ∧ (archPolynomialAt a).natDegree=n := by + have hd : (archPolynomialAt a).natDegree≤n := + (Polynomial.natDegree_C_mul_le _ _).trans (nextScalar_degree _ _) + have hc : (archPolynomialAt a).coeff n=1 := by + simp [archPolynomialAt,nextScalar_top,hp] + have he : (archPolynomialAt a).natDegree=n := + le_antisymm hd (Polynomial.le_natDegree_of_ne_zero (hc ▸ one_ne_zero)) + exact ⟨by rw [Polynomial.Monic,Polynomial.leadingCoeff,he,hc],he⟩ + +lemma nextScalar_eval {n : ℕ} (a : Fin n → ℂ) (z : ℂ) : + (nextScalar (RingHom.id ℂ) a).eval z = scalarValue (RingHom.id ℂ) (Fin.snoc a z) := by + rw [scalarValue_snoc] + exact eval_firstScalarHom _ _ _ _ + +lemma archPolynomialAt_eval_quotient {n : ℕ} (a : Fin n → ℂ) + (ha : Function.Injective a) + (hD : ∀ i j, i≠j → StripPfaffian.D (a i) (a j)≠0) (z : ℂ) + (hz : ∀ i, z≠a i ∧ StripPfaffian.D (a i) z≠0) : + (archPolynomialAt a).eval z = StripPfaffian.p (n+1) (Fin.snoc a z) / StripPfaffian.p n a := by + have hi : Function.Injective (Fin.snoc a z) := + Fin.snoc_injective_of_injective ha (by rintro ⟨i,hi⟩; exact (hz i).1 hi.symm) + have hs : ∀ i j : Fin (n+1), i≠j → StripPfaffian.D ((Fin.snoc a z : Fin (n+1) → ℂ) i) ((Fin.snoc a z : Fin (n+1) → ℂ) j)≠0 := by + intro i j hij + induction i using Fin.lastCases with + | last => + induction j using Fin.lastCases with + | last => exact (hij rfl).elim + | cast j => + simpa [StripPfaffian.D,add_comm,add_left_comm,mul_comm,mul_left_comm] using (hz j).2 + | cast i => + induction j using Fin.lastCases with + | last => simpa using (hz i).2 + | cast j => simpa using hD i j (fun he => hij (congrArg Fin.castSucc he)) + rw [archPolynomialAt,Polynomial.eval_mul,Polynomial.eval_C,nextScalar_eval, + scalarValue_eq_exterior a ha hD,scalarValue_eq_exterior _ hi hs,div_eq_mul_inv,mul_comm] + +lemma infinitely_many_regular_arguments {n : ℕ} (a : Fin n → ℂ) : + Set.Infinite {z : ℂ | ∀ i, z≠a i ∧ StripPfaffian.D (a i) z≠0} := by + let bad : Set ℂ := Set.range a ∪ ⋃ i, {z : ℂ | (StripPfaffian.Dpoly (a i)).IsRoot z} + have hb : bad.Finite := (Set.finite_range a).union (Set.finite_iUnion (fun i => + Polynomial.finite_setOfPred_isRoot (by + intro he + have hh := StripPfaffian.Dpoly_coeff (a i) + rw [he,Polynomial.coeff_zero] at hh + exact zero_ne_one hh))) + have h : badᶜ = {z : ℂ | ∀ i, z≠a i ∧ StripPfaffian.D (a i) z≠0} := by + ext z + simp only [bad,Set.mem_compl_iff,Set.mem_union,Set.mem_range,Set.mem_iUnion, + Set.mem_ofPred_eq,not_or,not_exists,Polynomial.IsRoot,StripPfaffian.Dpoly_eval] + exact ⟨fun h i => ⟨Ne.symm (h.1 i),h.2 i⟩,fun h => ⟨fun i => (h i).1.symm,fun i => (h i).2⟩⟩ + rw [←h] + exact hb.infinite_compl + + + +theorem archPolynomialAt_confluent (n : ℕ) (hn : 1≤n) : + ∃ g₀ : Polynomial ℝ, MonicProblem n g₀ ∧ + (∀ q, MonicProblem n q → q=g₀) ∧ + ∃ g : (Fin n → ℂ) → Polynomial ℂ, + g (fun _ => (C:ℂ))=g₀.map Complex.ofRealHom ∧ + (∀ k, ContinuousAt (fun a => (g a).coeff k) (fun _ => (C:ℂ))) ∧ + ∀ᶠ a in 𝓝 (fun _ : Fin n => (C:ℂ)), + (g a).Monic ∧ (g a).natDegree=n ∧ + ∀ (_ha : Function.Injective a) + (_hD : ∀ i j, i≠j → StripPfaffian.D (a i) (a j)≠0) + (_hp : scalarValue (RingHom.id ℂ) a≠0), + archPolynomialAt a=g a := by + obtain ⟨g₀,hg₀,hu,g,hg,hgc,hgreg⟩ := StripPfaffian.pfaffian_confluent_limit n hn + refine ⟨g₀,hg₀,hu,g,hg,hgc,?_⟩ + filter_upwards [hgreg] with a ha + refine ⟨ha.1,ha.2.1,?_⟩ + intro hinj hD hp + apply Polynomial.eq_of_infinite_eval_eq + apply (infinitely_many_regular_arguments a).mono + intro z hz + have hpn : StripPfaffian.p n a≠0 := by rwa [←scalarValue_eq_exterior a hinj hD] + exact (archPolynomialAt_eval_quotient a hinj hD z hz).trans (ha.2.2 hinj hD hpn z hz).symm + +end +end CriticalStrip.Diagram + + + + +namespace CriticalStrip +noncomputable section +open scoped BigOperators Classical + + +def PathBetween (N : ℕ) (start finish : Triangle) (p : List Triangle) : Prop := + p.head?=some start ∧ p.getLast?=some finish ∧ p.Nodup ∧ + p.IsChain adjacent ∧ ∀ v ∈ p, v.2.1 h.elim Or.inr Or.inl⟩ + +lemma PathBetween.reverse {N : ℕ} {a b : Triangle} {p : List Triangle} + (hp : PathBetween N a b p) : PathBetween N b a p.reverse := by + refine ⟨by simpa using hp.2.1,by simpa using hp.1,(by simpa only [List.nodup_reverse] using hp.2.2.1),?_,?_⟩ + · exact List.isChain_reverse.mpr (hp.2.2.2.1.imp (fun _ _ h => adjacent_symmetric.symm _ _ h)) + · intro v hv + exact hp.2.2.2.2 v (List.mem_reverse.mp hv) + + +def translateTriangle (i : ℤ) (v : Triangle) : Triangle := (i+v.1,v.2) + +@[simp] lemma translateTriangle_up (i j : ℤ) (k : ℕ) : + translateTriangle i (up j k)=up (i+j) k := rfl +@[simp] lemma translateTriangle_down (i j : ℤ) (k : ℕ) : + translateTriangle i (down j k)=down (i+j) k := rfl +@[simp] lemma translateTriangle_band (i : ℤ) (v : Triangle) : + (translateTriangle i v).2.1=v.2.1 := rfl +@[simp] lemma translateTriangle_zero (v : Triangle) : translateTriangle 0 v=v := by + cases v; simp [translateTriangle] +@[simp] lemma translateTriangle_add (i j : ℤ) (v : Triangle) : + translateTriangle i (translateTriangle j v)=translateTriangle (i+j) v := by + simp [translateTriangle,add_assoc] + +lemma translateTriangle_injective (i : ℤ) : Function.Injective (translateTriangle i) := by + intro v w h + have := congrArg (translateTriangle (-i)) h + simpa using this + +lemma adjacent_translate_iff (i : ℤ) (v w : Triangle) : + adjacent (translateTriangle i v) (translateTriangle i w) ↔ adjacent v w := by + simp only [adjacent,upDownAdjacent,translateTriangle,add_assoc,add_left_cancel_iff] + +lemma PathBetween.translate {N : ℕ} {a b : Triangle} {p : List Triangle} + (hp : PathBetween N a b p) (i : ℤ) : + PathBetween N (translateTriangle i a) (translateTriangle i b) (p.map (translateTriangle i)) := by + refine ⟨?_,?_,hp.2.2.1.map (translateTriangle_injective i),?_,?_⟩ + · rw [List.head?_map,hp.1]; rfl + · rw [List.getLast?_map,hp.2.1]; rfl + · exact (List.isChain_map _).mpr (hp.2.2.2.1.imp (fun _ _ => (adjacent_translate_iff i _ _).mpr)) + · intro v hv + obtain ⟨w,hw,rfl⟩ := List.mem_map.mp hv + exact hp.2.2.2.2 w hw + +@[simp] lemma pathBetween_translate_iff (N : ℕ) (a b : Triangle) (p : List Triangle) (i : ℤ) : + PathBetween N (translateTriangle i a) (translateTriangle i b) (p.map (translateTriangle i)) ↔ + PathBetween N a b p := by + refine ⟨fun h => ?_,fun h => h.translate i⟩ + simpa [List.map_map,Function.comp_def] using h.translate (-i) + +def translatePaths (i : ℤ) : List Triangle ≃ List Triangle where + toFun := List.map (translateTriangle i) + invFun := List.map (translateTriangle (-i)) + left_inv := by intro p; simp [List.map_map,Function.comp_def] + right_inv := by intro p; simp [List.map_map,Function.comp_def] + + +def betweenArchWeight (N : ℕ) (i j : ℤ) (p : List Triangle) : ℝ := + if i≠j ∧ PathBetween N (up i 0) (up j 0) p then rho^p.length else 0 + +def betweenArchKernel (N : ℕ) (i j : ℤ) : ℝ := ∑' p, betweenArchWeight N i j p + +lemma betweenArchWeight_nonneg (N : ℕ) (i j : ℤ) (p : List Triangle) : + 0≤betweenArchWeight N i j p := by + unfold betweenArchWeight + split + · exact (pow_pos rho_pos _).le + · exact le_rfl + +lemma betweenArchWeight_translate (N : ℕ) (i j : ℤ) (p : List Triangle) : + betweenArchWeight N i j (p.map (translateTriangle i))=archWeight N (j-i) p := by + have hi : up i 0=translateTriangle i (up 0 0) := by simp + have hj : up j 0=translateTriangle i (up (j-i) 0) := by simp + have hn : i≠j ↔ j-i≠0 := by omega + simp only [betweenArchWeight,archWeight,hi,hj,pathBetween_translate_iff, + pathBetween_source,hn,List.length_map] + + + +theorem betweenArchKernel_eq (N : ℕ) (i j : ℤ) : betweenArchKernel N i j=K N (j-i) := by + rw [betweenArchKernel,←(translatePaths i).tsum_eq] + exact tsum_congr (betweenArchWeight_translate N i j) + +lemma summable_betweenArchWeight_iff (N : ℕ) (i j : ℤ) : + Summable (betweenArchWeight N i j) ↔ Summable (archWeight N (j-i)) := by + rw [←(translatePaths i).summable_iff] + exact summable_congr (betweenArchWeight_translate N i j) + +lemma betweenArchWeight_reverse (N : ℕ) (i j : ℤ) (p : List Triangle) : + betweenArchWeight N j i p.reverse=betweenArchWeight N i j p := by + have hp : PathBetween N (up j 0) (up i 0) p.reverse ↔ PathBetween N (up i 0) (up j 0) p := by + refine ⟨fun h => ?_,PathBetween.reverse⟩ + simpa using h.reverse + simp only [betweenArchWeight,hp,ne_comm,List.length_reverse] + + + +def cutArchWeight (N : ℕ) (x : (ℕ×ℕ)×List Triangle) : ℝ := + betweenArchWeight N (-(x.1.1:ℤ)) ((x.1.2:ℤ)+1) x.2 + +lemma cutArchWeight_nonneg (N : ℕ) (x : (ℕ×ℕ)×List Triangle) : 0≤cutArchWeight N x := + betweenArchWeight_nonneg _ _ _ _ + +lemma cutArchWeight_path_sum (N : ℕ) (x : ℕ×ℕ) : + (∑' p,cutArchWeight N (x,p))=K N ((x.1+x.2:ℕ)+1) := by + change betweenArchKernel N (-(x.1:ℤ)) ((x.2:ℤ)+1)=_ + rw [betweenArchKernel_eq] + congr 1 + omega + + + +lemma summable_add_diagonal_iff {f : ℕ→ℝ} (hf : ∀ n,0≤f n) : + Summable (fun x : ℕ×ℕ => f (x.1+x.2)) ↔ Summable (fun n : ℕ => (n+1:ℝ)*f n) := by + rw [←Finset.HasAntidiagonal.sigmaAntidiagonalEquivProd.summable_iff] + change Summable (fun x : Σ n : ℕ, Finset.HasAntidiagonal.antidiagonal n => + f (x.2.val.1+x.2.val.2)) ↔ _ + rw [summable_sigma_of_nonneg (fun x => hf _)] + have hsum (n : ℕ) : (∑' x : Finset.HasAntidiagonal.antidiagonal n, + f (x.val.1+x.val.2))=(n+1:ℝ)*f n := by + have he (x : Finset.HasAntidiagonal.antidiagonal n) : x.val.1+x.val.2=n := + Finset.HasAntidiagonal.mem_antidiagonal.mp x.property + simp only [he,tsum_const,Nat.card_eq_fintype_card,nsmul_eq_mul,Fintype.card_coe,Finset.Nat.card_antidiagonal, + Nat.cast_add,Nat.cast_one] + simp only [hsum] + exact ⟨fun h => h.2,fun h => ⟨fun _ => (hasSum_fintype _).summable,h⟩⟩ + +lemma tsum_add_diagonal {f : ℕ→ℝ} (hf : ∀ n,0≤f n) + (h : Summable (fun n : ℕ => (n+1:ℝ)*f n)) : + (∑' x : ℕ×ℕ,f (x.1+x.2))=∑' n : ℕ,(n+1:ℝ)*f n := by + have hs := (Finset.HasAntidiagonal.sigmaAntidiagonalEquivProd.summable_iff).mpr + ((summable_add_diagonal_iff hf).mpr h) + change Summable (fun x : Σ n : ℕ, Finset.HasAntidiagonal.antidiagonal n => + f (x.2.val.1+x.2.val.2)) at hs + rw [←Finset.HasAntidiagonal.sigmaAntidiagonalEquivProd.tsum_eq] + change (∑' x : Σ n : ℕ, Finset.HasAntidiagonal.antidiagonal n, + f (x.2.val.1+x.2.val.2)) = _ + rw [hs.tsum_sigma' (fun _=>(hasSum_fintype _).summable)] + apply tsum_congr + intro n + have he (x : Finset.HasAntidiagonal.antidiagonal n) : x.val.1+x.val.2=n := + Finset.HasAntidiagonal.mem_antidiagonal.mp x.property + simp only [he,tsum_const,Nat.card_eq_fintype_card,nsmul_eq_mul,Fintype.card_coe,Finset.Nat.card_antidiagonal, + Nat.cast_add,Nat.cast_one] + + + +theorem cutArchWeight_summable_iff (N : ℕ) + (hK : ∀ k : ℤ,Summable (archWeight N k)) : + Summable (cutArchWeight N) ↔ Summable (fun n : ℕ => (n+1:ℝ)*K N (n+1)) := by + rw [summable_prod_of_nonneg (cutArchWeight_nonneg N)] + have hi (x : ℕ×ℕ) : Summable (fun p => cutArchWeight N (x,p)) := + (summable_betweenArchWeight_iff N (-(x.1:ℤ)) ((x.2:ℤ)+1)).mpr (hK _) + have he (x : ℕ×ℕ) : (∑' p, cutArchWeight N (x,p)) = + (fun n : ℕ => K N (n+1)) (x.1+x.2) := cutArchWeight_path_sum N x + have hh : Summable (fun x : ℕ×ℕ => ∑' p,cutArchWeight N (x,p)) ↔ + Summable (fun x : ℕ×ℕ => (fun n : ℕ => K N (n+1)) (x.1+x.2)) := summable_congr he + exact ⟨fun h => (summable_add_diagonal_iff (fun n => K_nonneg N (n+1))).mp (hh.mp h.2), + fun h => ⟨hi,hh.mpr ((summable_add_diagonal_iff (fun n => K_nonneg N (n+1))).mpr h)⟩⟩ + + + +theorem physical_moment_eq_cut_sum {N : ℕ} (hN : StripSumsFinite N) : + moment N=∑' x,cutArchWeight N x := by + have hs := (cutArchWeight_summable_iff N hN.1).mpr hN.2.2.2.2 + rw [hs.tsum_prod] + simp only [cutArchWeight_path_sum] + exact (tsum_add_diagonal (fun n => K_nonneg N (n+1)) hN.2.2.2.2).symm + +end + + + + +noncomputable section +open scoped BigOperators Classical +open Filter Topology + + +def steppedDomain (N : ℕ) (s : ℤ) (v : Triangle) : Prop := + v.2.1 < N ∨ v.2.1=N ∧ s ≤ v.1 + + + +def stepArchWeight (N : ℕ) (s i j : ℤ) (p : List Triangle) : ℝ := + if ∀ v∈p,steppedDomain N s v then betweenArchWeight (N+1) i j p else 0 + +def stepArchKernel (N : ℕ) (s i j : ℤ) : ℝ := ∑' p, stepArchWeight N s i j p + +lemma stepArchWeight_nonneg (N : ℕ) (s i j : ℤ) (p : List Triangle) : + 0 ≤ stepArchWeight N s i j p := by + unfold stepArchWeight + split + · exact betweenArchWeight_nonneg _ _ _ _ + · exact le_rfl + +lemma stepArchWeight_le (N : ℕ) (s i j : ℤ) (p : List Triangle) : + stepArchWeight N s i j p ≤ betweenArchWeight (N+1) i j p := by + unfold stepArchWeight + split + · exact le_rfl + · exact betweenArchWeight_nonneg _ _ _ _ + +lemma stepArchWeight_reverse (N : ℕ) (s i j : ℤ) (p : List Triangle) : + stepArchWeight N s j i p.reverse=stepArchWeight N s i j p := by + simp only [stepArchWeight,List.mem_reverse,betweenArchWeight_reverse] + +def reversePaths : List Triangle ≃ List Triangle where + toFun := List.reverse + invFun := List.reverse + left_inv := List.reverse_reverse + right_inv := List.reverse_reverse + +lemma stepArchKernel_reverse (N : ℕ) (s i j : ℤ) : + stepArchKernel N s j i=stepArchKernel N s i j := by + rw [stepArchKernel,←reversePaths.tsum_eq] + exact tsum_congr (stepArchWeight_reverse N s i j) + +lemma betweenArchWeight_mono {N M : ℕ} (hNM : N ≤ M) (i j : ℤ) (p : List Triangle) : + betweenArchWeight N i j p ≤ betweenArchWeight M i j p := by + unfold betweenArchWeight + split_ifs with hn hm hm + · exact le_rfl + · exact (hm ⟨hn.1,hn.2.1,hn.2.2.1,hn.2.2.2.1,hn.2.2.2.2.1, + fun v hv => (hn.2.2.2.2.2 v hv).trans_le hNM⟩).elim + · exact (pow_pos rho_pos _).le + · exact le_rfl + +lemma betweenArchWeight_restrict (N : ℕ) (i j : ℤ) (p : List Triangle) : + (if ∀ v∈p,v.2.1 < N then betweenArchWeight (N+1) i j p else 0)=betweenArchWeight N i j p := by + by_cases h : ∀ v∈p,v.2.1 < N + · have hpath : PathBetween (N+1) (up i 0) (up j 0) p ↔ + PathBetween N (up i 0) (up j 0) p := by + constructor + · intro hp; exact ⟨hp.1,hp.2.1,hp.2.2.1,hp.2.2.2.1,h⟩ + · intro hp; exact ⟨hp.1,hp.2.1,hp.2.2.1,hp.2.2.2.1,fun v hv => (h v hv).trans_le (Nat.le_succ _)⟩ + simp only [ite_eq_left h,betweenArchWeight,hpath] + · rw [ite_eq_right h,betweenArchWeight,ite_eq_right] + rintro ⟨_,hp⟩ + exact h hp.2.2.2.2 + +lemma stepArchWeight_translate (N : ℕ) (s i j q : ℤ) (p : List Triangle) : + stepArchWeight N s (q+i) (q+j) (p.map (translateTriangle q)) = + stepArchWeight N (s-q) i j p := by + have hb : betweenArchWeight (N+1) (q+i) (q+j) (p.map (translateTriangle q))= + betweenArchWeight (N+1) i j p := by + simp only [betweenArchWeight,←translateTriangle_up,pathBetween_translate_iff,List.length_map, + ne_eq,add_left_cancel_iff] + have he : (∀ v∈p.map (translateTriangle q),steppedDomain N s v) ↔ + ∀ v∈p,steppedDomain N (s-q) v := by + simp only [List.forall_mem_map,steppedDomain,translateTriangle] + exact forall_congr' (fun v => forall_congr' (fun _ => by omega)) + simp only [stepArchWeight,he,hb] + + +def stepCutArchWeight (N : ℕ) (s : ℤ) (x : (ℕ×ℕ)×List Triangle) : ℝ := + stepArchWeight N s (-(x.1.1:ℤ)) ((x.1.2:ℤ)+1) x.2 + +lemma stepCutArchWeight_nonneg (N : ℕ) (s : ℤ) (x : (ℕ×ℕ)×List Triangle) : + 0 ≤ stepCutArchWeight N s x := stepArchWeight_nonneg _ _ _ _ _ + +lemma stepCutArchWeight_le (N : ℕ) (s : ℤ) (x : (ℕ×ℕ)×List Triangle) : + stepCutArchWeight N s x ≤ cutArchWeight (N+1) x := stepArchWeight_le _ _ _ _ _ + +lemma stepCutArchWeight_summable (N : ℕ) (s : ℤ) (h : StripSumsFinite (N+1)) : + Summable (stepCutArchWeight N s) := + ((cutArchWeight_summable_iff (N+1) h.1).mpr h.2.2.2.2).of_nonneg_of_le + (stepCutArchWeight_nonneg _ _) (stepCutArchWeight_le _ _) + +lemma eventually_stepContains (N : ℕ) (s : ℤ) (p : List Triangle) + (hp : ∀ v∈p,v.2.1 < N+1) : + ∀ᶠ L : ℕ in atTop,∀ v∈p,steppedDomain N (s-(L:ℤ)) v := by + have h : ∀ᶠ L : ℕ in atTop,∀ v∈p.toFinset,s-(L:ℤ) ≤ v.1 := by + apply (p.toFinset.eventually_all).mpr + intro v _ + filter_upwards [eventually_ge_atTop (s-v.1).toNat] with L hL + omega + filter_upwards [h] with L hL + intro v hv + have hband := hp v hv + have hcol := hL v (List.mem_toFinset.mpr hv) + unfold steppedDomain + omega + +lemma eventually_stepExcludes (N : ℕ) (s : ℤ) (p : List Triangle) : + ∀ᶠ L : ℕ in atTop,∀ v∈p,steppedDomain N (s+(L:ℤ)) v ↔ v.2.1 < N := by + have h : ∀ᶠ L : ℕ in atTop,∀ v∈p.toFinset,v.1 by simp only [stepArchWeight,hz,ite_self]) + +lemma stepArchWeight_eventually_short (N : ℕ) (s i j : ℤ) (p : List Triangle) : + ∀ᶠ L : ℕ in atTop,stepArchWeight N (s+(L:ℤ)) i j p=betweenArchWeight N i j p := by + filter_upwards [eventually_stepExcludes N s p] with L hL + have he : (∀ v∈p,steppedDomain N (s+(L:ℤ)) v) ↔ ∀ v∈p,v.2.1 < N := by + exact forall_congr' (fun v => forall_congr' (hL v)) + simpa only [stepArchWeight,he] using betweenArchWeight_restrict N i j p + + + +theorem step_cut_mass_tall_limit {N : ℕ} (s : ℤ) (h : StripSumsFinite (N+1)) : + Tendsto (fun L : ℕ => ∑' x,stepCutArchWeight N (s-(L:ℤ)) x) atTop (𝓝 (moment (N+1))) := by + rw [physical_moment_eq_cut_sum h] + apply tendsto_tsum_of_dominated_convergence + ((cutArchWeight_summable_iff (N+1) h.1).mpr h.2.2.2.2) + · intro x + exact tendsto_const_nhds.congr' ((stepArchWeight_eventually_tall N s (-(x.1.1:ℤ)) ((x.1.2:ℤ)+1) x.2).mono (fun L hL => hL.symm)) + · exact Eventually.of_forall (fun L x => by + rw [Real.norm_eq_abs,abs_of_nonneg (stepCutArchWeight_nonneg _ _ _)] + exact stepCutArchWeight_le _ _ _) + + + +theorem step_cut_mass_short_limit {N : ℕ} (s : ℤ) + (h : StripSumsFinite (N+1)) (h₀ : StripSumsFinite N) : + Tendsto (fun L : ℕ => ∑' x,stepCutArchWeight N (s+(L:ℤ)) x) atTop (𝓝 (moment N)) := by + rw [physical_moment_eq_cut_sum h₀] + apply tendsto_tsum_of_dominated_convergence + ((cutArchWeight_summable_iff (N+1) h.1).mpr h.2.2.2.2) + · intro x + exact tendsto_const_nhds.congr' ((stepArchWeight_eventually_short N s (-(x.1.1:ℤ)) ((x.1.2:ℤ)+1) x.2).mono (fun L hL => hL.symm)) + · exact Eventually.of_forall (fun L x => by + rw [Real.norm_eq_abs,abs_of_nonneg (stepCutArchWeight_nonneg _ _ _)] + exact stepCutArchWeight_le _ _ _) + +end +end CriticalStrip + +end OAI diff --git a/lean/OAI/Combinatorics/StripMass/ScalarDegree.lean b/lean/OAI/Combinatorics/StripMass/ScalarDegree.lean new file mode 100644 index 0000000000000000000000000000000000000000..d16b314b04fffe1618c04e2307a09079976b04de --- /dev/null +++ b/lean/OAI/Combinatorics/StripMass/ScalarDegree.lean @@ -0,0 +1,478 @@ +import Mathlib +import OAI.Combinatorics.StripMass.FirstFlatSpecialization + +namespace OAI + +/-! Critical honeycomb strip paths, polynomial identities and crossing mass. -/ + + + +namespace CriticalStrip.Diagram +noncomputable section +open Finset + +theorem cosine_difference_degree_self {n : ℕ} (i j : Fin n) (hij : i ≠ j) : + MvPolynomial.degreeOf i (MvPolynomial.X i - MvPolynomial.X j : CosineRing n) = 1 := by + have hlt : MvPolynomial.degreeOf i (-MvPolynomial.X j : CosineRing n) < + MvPolynomial.degreeOf i (MvPolynomial.X i : CosineRing n) := by + simp [MvPolynomial.degreeOf_X, hij] + simpa only [sub_eq_add_neg, MvPolynomial.degreeOf_X_self] using + MvPolynomial.degreeOf_add_eq_of_degreeOf_lt hlt + +theorem cosine_difference_degree {n : ℕ} (k i j : Fin n) (hij : i ≠ j) : + MvPolynomial.degreeOf k (MvPolynomial.X i - MvPolynomial.X j : CosineRing n) = + if i = k ∨ j = k then 1 else 0 := by + by_cases hi : i = k + · subst i + simp [cosine_difference_degree_self k j hij] + · by_cases hj : j = k + · subst j + have he : (MvPolynomial.X i - MvPolynomial.X k : CosineRing n) = + -(MvPolynomial.X k - MvPolynomial.X i) := by ring + rw [he, MvPolynomial.degreeOf_neg, cosine_difference_degree_self k i hij.symm] + simp + · rw [ite_eq_right (not_or.mpr ⟨hi,hj⟩)] + apply Nat.eq_zero_of_le_zero + exact (MvPolynomial.degreeOf_sub_le _ _ _).trans (by + simp [MvPolynomial.degreeOf_X, Ne.symm hi, Ne.symm hj]) + +theorem sourceVandermonde_degree {n : ℕ} (k : Fin n) : + MvPolynomial.degreeOf k (sourceVandermonde (MvPolynomial.X : Fin n → CosineRing n)) = n-1 := by + unfold sourceVandermonde + rw [MvPolynomial.degreeOf_prod_eq _ _ (fun e _ => + (prime_cosine_difference e.val.1 e.val.2 (ne_of_lt e.property)).ne_zero)] + calc + _ = ∑ e : UpperPair n, if e.val.1 = k ∨ e.val.2 = k then 1 else 0 := by + apply Finset.sum_congr rfl + intro e _ + exact cosine_difference_degree k e.val.1 e.val.2 (ne_of_lt e.property) + _ = n-1 := by simpa using sum_incident_degree k 1 + + + +theorem scalarPolynomial_degree (n : ℕ) (dd rr : ℂ) (hdd : dd ≠ 0) (k : Fin n) : + MvPolynomial.degreeOf k (scalarPolynomial n dd rr hdd) ≤ n-1 := by + by_cases hp : scalarPolynomial n dd rr hdd = 0 + · simp [hp] + have hv := sourceVandermonde_ne_zero (MvPolynomial.X : Fin n → CosineRing n) + MvPolynomial.X_injective + have hd := scalarNumerator_degree n dd rr k + rw [scalarNumerator_eq_vandermonde n dd rr hdd, MvPolynomial.degreeOf_mul_eq hv hp, + sourceVandermonde_degree] at hd + omega + +end + + + + + +noncomputable section +open scoped Classical + + + +def firstScalarHom {K:Type*} [CommRing K] (f:ℂ →+* K) {n:ℕ} (a:Fin n → K) : + CosineRing (n+1) →+* Polynomial K := + MvPolynomial.eval₂Hom (Polynomial.C.comp f) (Fin.cons Polynomial.X (fun i => Polynomial.C (a i))) + +lemma firstScalarHom_degree {K:Type*} [CommRing K] (f:ℂ →+* K) {n:ℕ} + (a:Fin n → K) (P:CosineRing (n+1)) : + (firstScalarHom f a P).natDegree ≤ MvPolynomial.degreeOf 0 P := by + conv_lhs => rw [MvPolynomial.as_sum P] + rw [map_sum] + apply Polynomial.natDegree_sum_le_of_forall_le + intro m hm + have he:firstScalarHom f a (MvPolynomial.monomial m (P.coeff m))= + Polynomial.C (f (P.coeff m))*Polynomial.X^(m 0)* + ∏ i:Fin n,Polynomial.C (a i)^(m i.succ) := by + simp only [firstScalarHom,MvPolynomial.eval₂Hom_monomial,RingHom.comp_apply] + rw [Finsupp.prod_fintype _ _ (by simp),Fin.prod_univ_succ] + simp only [Fin.cons_zero,Fin.cons_succ,mul_assoc] + rw [he] + have hz:(∏i:Fin n,Polynomial.C (a i)^(m i.succ)).natDegree=0 := by + have hh:(∏i:Fin n,Polynomial.C (a i)^(m i.succ))=Polynomial.C (∏i:Fin n,(a i)^(m i.succ)) := by + simp only [map_prod,map_pow] + rw [hh,Polynomial.natDegree_C] + exact (Polynomial.natDegree_mul_le.trans (by + rw [hz,add_zero] + exact (Polynomial.natDegree_C_mul_le _ _).trans (Polynomial.natDegree_X_pow_le _))) |>.trans + (MvPolynomial.le_degreeOf_of_mem_support 0 hm) + +lemma scalarPolynomial_first_degree {K:Type*} [CommRing K] (f:ℂ →+* K) + (n:ℕ) (dd rr:ℂ) (hdd:dd≠0) (a:Fin n → K) : + (firstScalarHom f a (scalarPolynomial (n+1) dd rr hdd)).natDegree ≤ n := by + exact (firstScalarHom_degree f a _).trans (by simpa using scalarPolynomial_degree (n+1) dd rr hdd 0) + +lemma polynomial_top_numerator {K:Type*} [CommRing K] (rr a:K) : + ((Polynomial.X-Polynomial.C a)*(Polynomial.X+Polynomial.C a+Polynomial.C rr)).coeff 2=1 := by + have he:(Polynomial.X-Polynomial.C a)*(Polynomial.X+Polynomial.C a+Polynomial.C rr)= + (Polynomial.X^2:Polynomial K)+Polynomial.C rr*Polynomial.X-Polynomial.C (a*(a+rr)) := by + simp only [map_mul,map_add]; ring + rw [he]; simp + +lemma polynomial_top_discriminant {K:Type*} [CommRing K] (dd a:K) : + (discriminant (Polynomial.C dd) Polynomial.X (Polynomial.C a)).coeff 2=1 := by + have he:discriminant (Polynomial.C dd) Polynomial.X (Polynomial.C a)= + (Polynomial.X^2:Polynomial K)+Polynomial.C (2*dd*a)*Polynomial.X+Polynomial.C (a^2-dd^2) := by + simp only [discriminant,map_mul,map_pow,map_sub,map_ofNat]; ring + rw [he] + have hc (z:K):((Polynomial.C z)^2).coeff 2=0 := by + rw [←map_pow,Polynomial.coeff_C]; norm_num + simp [hc] + + + +def infinityNumerator {K:Type*} [CommRing K] {n:ℕ} (rr:K) (a:Fin n → K) := + fun i j:Fin ((n+1)+(n+1)%2) => + (augmentedNumerator (Polynomial.C rr) (Fin.cons Polynomial.X (fun i => Polynomial.C (a i))) i j).coeff + (scalarEdgeDegree (0:Fin (n+1)) i j) +def infinityDenominator {K:Type*} [CommRing K] {n:ℕ} (dd:K) (a:Fin n → K) := + fun i j:Fin ((n+1)+(n+1)%2) => + (augmentedDenominator (Polynomial.C dd) (Fin.cons Polynomial.X (fun i => Polynomial.C (a i))) i j).coeff + (scalarEdgeDegree (0:Fin (n+1)) i j) + +lemma augmentedNumerator_first_degree {K:Type*} [CommRing K] (f:ℂ →+* K) + {n:ℕ} (rr:ℂ) (a:Fin n → K) (i j:Fin ((n+1)+(n+1)%2)) : + (augmentedNumerator (Polynomial.C (f rr)) (Fin.cons Polynomial.X (fun i => Polynomial.C (a i))) i j).natDegree ≤ + scalarEdgeDegree (0:Fin (n+1)) i j := by + have hh: firstScalarHom f a (augmentedNumerator (MvPolynomial.C rr) MvPolynomial.X i j)= + augmentedNumerator (Polynomial.C (f rr)) (Fin.cons Polynomial.X (fun i => Polynomial.C (a i))) i j := by + simpa only [Matrix.map_apply,firstScalarHom,MvPolynomial.eval₂Hom_C,RingHom.comp_apply, + MvPolynomial.eval₂Hom_X'] using + congrFun (congrFun (map_augmentedNumerator (firstScalarHom f a) (MvPolynomial.C rr) MvPolynomial.X) i) j + rw [←hh] + exact (firstScalarHom_degree f a _).trans (augmentedNumerator_degree 0 rr i j) + +lemma augmentedDenominator_first_degree {K:Type*} [CommRing K] (f:ℂ →+* K) + {n:ℕ} (dd:ℂ) (a:Fin n → K) (i j:Fin ((n+1)+(n+1)%2)) : + (augmentedDenominator (Polynomial.C (f dd)) (Fin.cons Polynomial.X (fun i => Polynomial.C (a i))) i j).natDegree ≤ + scalarEdgeDegree (0:Fin (n+1)) i j := by + have hh: firstScalarHom f a (augmentedDenominator (MvPolynomial.C dd) MvPolynomial.X i j)= + augmentedDenominator (Polynomial.C (f dd)) (Fin.cons Polynomial.X (fun i => Polynomial.C (a i))) i j := by + simpa only [Matrix.map_apply,firstScalarHom,MvPolynomial.eval₂Hom_C,RingHom.comp_apply, + MvPolynomial.eval₂Hom_X'] using + congrFun (congrFun (map_augmentedDenominator (firstScalarHom f a) (MvPolynomial.C dd) MvPolynomial.X) i) j + rw [←hh] + exact (firstScalarHom_degree f a _).trans (augmentedDenominator_degree 0 dd i j) + +lemma firstScalarHom_C {K:Type*} [CommRing K] (f:ℂ →+* K) + {n:ℕ} (a:Fin n → K) (z:ℂ) : firstScalarHom f a (MvPolynomial.C z)=Polynomial.C (f z) := by + simp only [firstScalarHom,MvPolynomial.eval₂Hom_C,RingHom.comp_apply] +lemma firstScalarHom_X {K:Type*} [CommRing K] (f:ℂ →+* K) + {n:ℕ} (a:Fin n → K) (i:Fin (n+1)) : firstScalarHom f a (MvPolynomial.X i)= + (Fin.cons Polynomial.X (fun i => Polynomial.C (a i)) : Fin (n+1) → Polynomial K) i := by + simp only [firstScalarHom,MvPolynomial.eval₂Hom_X'] + +lemma scalarNumerator_first_map {K:Type*} [CommRing K] (f:ℂ →+* K) + (n:ℕ) (dd rr:ℂ) (a:Fin n → K) : + firstScalarHom f a (scalarNumerator (n+1) dd rr)= + clearedPfaffian (Polynomial.C (f ((2^(((n+1)+(n+1)%2)/2)* + (Nat.factorial (((n+1)+(n+1)%2)/2):ℂ))⁻¹))) + (augmentedNumerator (Polynomial.C (f rr)) (Fin.cons Polynomial.X (fun i => Polynomial.C (a i)))) + (augmentedDenominator (Polynomial.C (f dd)) (Fin.cons Polynomial.X (fun i => Polynomial.C (a i)))) := by + rw [scalarNumerator,map_clearedPfaffian,map_augmentedNumerator,map_augmentedDenominator] + simp only [firstScalarHom_C,firstScalarHom_X] + +lemma scalarNumerator_first_top {K:Type*} [CommRing K] (f:ℂ →+* K) + (n:ℕ) (dd rr:ℂ) (a:Fin n → K) : + (firstScalarHom f a (scalarNumerator (n+1) dd rr)).coeff (2*n)= + clearedPfaffian (f ((2^(((n+1)+(n+1)%2)/2)* + (Nat.factorial (((n+1)+(n+1)%2)/2):ℂ))⁻¹)) + (infinityNumerator (f rr) a) (infinityDenominator (f dd) a) := by + have he:2*n=∑e:UpperPair ((n+1)+(n+1)%2), scalarEdgeDegree (0:Fin (n+1)) e.val.1 e.val.2 := by + rw [sum_scalarEdgeDegree]; simp + rw [scalarNumerator_first_map] + rw [he,clearedPfaffian_top _ _ _ _ (scalarEdgeDegree_symm 0) + (augmentedNumerator_first_degree f rr a) (augmentedDenominator_first_degree f dd a)] + rfl + + + + + + + + +def infinityKernel {K:Type*} [Field K] {n:ℕ} (dd rr:K) (a:Fin n → K) : + Matrix (Fin ((n+1)+(n+1)%2)) (Fin ((n+1)+(n+1)%2)) K := fun i j => + if hi:i.val try ring_nf + +lemma infinityDenominator_symm {K:Type*} [CommRing K] {n:ℕ} (dd:K) (a:Fin n → K) + (i j:Fin ((n+1)+(n+1)%2)) : + infinityDenominator dd a i j=infinityDenominator dd a j i := by + rw [infinityDenominator,infinityDenominator,scalarEdgeDegree_symm 0 i j, + augmentedDenominator_symm] + +lemma infinityDenominator_zero_real {K:Type*} [CommRing K] {n:ℕ} (dd:K) (a:Fin n → K) + (j:Fin ((n+1)+(n+1)%2)) (hj:j.val simp_all + +lemma infinityKernel_eq {K:Type*} [Field K] {n:ℕ} (dd rr:K) (a:Fin n → K) : + (fun i j => infinityNumerator rr a i j/infinityDenominator dd a i j)=infinityKernel dd rr a := by + funext i j + by_cases hi:i.val + simp [infinityNumerator,augmentedNumerator,scalarEdgeDegree,infinityKernel,hi,hj] + +lemma infinityKernel_real {K:Type*} [Field K] {n:ℕ} (dd rr:K) (a:Fin n → K) + (i j:Fin (n+1)) : + infinityKernel dd rr a ⟨i.val,by omega⟩ ⟨j.val,by omega⟩ = + frontBorder (plainKernel dd rr a) 1 i j := by + induction i using Fin.cases with + | zero => + induction j using Fin.cases with + | zero => simp [infinityKernel] + | succ j => simp [infinityKernel,show j.val+1 + induction j using Fin.cases with + | zero => simp [infinityKernel,show i.val+1 simp [infinityKernel,show i.val+1 infinityKernel dd rr a (Fin.cast hs.symm i) (Fin.cast hs.symm j))= + backBorder (frontBorder (plainKernel dd rr a) 1) := by + funext i j + induction i using Fin.lastCases with + | last => + induction j using Fin.lastCases with + | last => simp [infinityKernel] + | cast j => simp [infinityKernel,show j.val<2*m+1 by omega] + | cast i => + induction j using Fin.lastCases with + | last => simp [infinityKernel,show i.val<2*m+1 by omega] + | cast j => + rw [backBorder_cast_cast] + exact infinityKernel_real dd rr a i j + rw [he,pfaffian_back_front _ (plainKernel_skew _ _ _),pfaffian_augmented_even] + · subst n + have hs:((2*m+1)+1)+((2*m+1)+1)%2=(2*m+1)+1 := by omega + apply Eq.trans (pfaffian_cast hs (infinityKernel dd rr a)).symm + have he:(fun i j => infinityKernel dd rr a (Fin.cast hs.symm i) (Fin.cast hs.symm j))= + frontBorder (plainKernel dd rr a) 1 := by + funext i j + exact infinityKernel_real dd rr a i j + rw [he,pfaffian_front_back _ (plainKernel_skew _ _ _),pfaffian_augmented_odd] + + + + + + + +def infinityPairEmbed (n:ℕ) (e:UpperPair n) : UpperPair ((n+1)+(n+1)%2) := + ⟨(⟨e.val.1.val+1,by omega⟩,⟨e.val.2.val+1,by omega⟩),by simpa using e.property⟩ + +lemma infinityPairEmbed_injective (n:ℕ) : Function.Injective (infinityPairEmbed n) := by + intro e f h + apply Subtype.ext + apply Prod.ext <;> apply Fin.ext + · have hh:=congrArg (fun e:UpperPair ((n+1)+(n+1)%2) => e.val.1.val) h + exact Nat.add_right_cancel hh + · have hh:=congrArg (fun e:UpperPair ((n+1)+(n+1)%2) => e.val.2.val) h + exact Nat.add_right_cancel hh + +lemma infinityDenominator_product {K:Type*} [CommRing K] {n:ℕ} (dd:K) (a:Fin n → K) : + (∏e:UpperPair ((n+1)+(n+1)%2),infinityDenominator dd a e.val.1 e.val.2)= + ∏e:UpperPair n,discriminant dd (a e.val.1) (a e.val.2) := by + symm + apply Fintype.prod_of_injective (infinityPairEmbed n) (infinityPairEmbed_injective n) + · intro e he + by_cases hi:e.val.1.val apply Fin.ext <;> + simp only [infinityPairEmbed] <;> have:=e.property <;> omega + · exact infinityDenominator_fake dd a _ _ (by tauto) + · exact infinityDenominator_fake dd a _ _ (by tauto) + · intro e + rw [infinityDenominator_pos_real dd a _ _ (by dsimp [infinityPairEmbed]; omega) + (by simp [infinityPairEmbed]) (by dsimp [infinityPairEmbed]; omega) (by simp [infinityPairEmbed])] + rfl + +lemma infinityDenominator_ne {K:Type*} [Field K] {n:ℕ} (dd:K) (a:Fin n → K) + (hD:∀i j,i≠j → discriminant dd (a i) (a j)≠0) + (i j:Fin ((n+1)+(n+1)%2)) (hij:i≠j) : infinityDenominator dd a i j≠0 := by + by_cases hi:i.valPolynomial.C (a i)) + have h:=prod_upperPair_succ (fun i j:Fin (n+1) => v i-v j) + apply Eq.trans h + simp only [v,Fin.cons_zero,Fin.cons_succ,map_prod,map_sub] + +lemma firstScalarHom_vandermonde_degree {K:Type*} [CommRing K] (f:ℂ →+* K) + {n:ℕ} (a:Fin n → K) : + (firstScalarHom f a (sourceVandermonde (MvPolynomial.X:Fin (n+1) → CosineRing (n+1)))).natDegree ≤ n := by + rw [firstScalarHom_vandermonde] + apply (Polynomial.natDegree_mul_C_le _ _).trans + exact (Polynomial.natDegree_prod_le _ _).trans ((Finset.sum_le_sum + (fun i _ => Polynomial.natDegree_X_sub_C_le (a i))).trans (by simp)) + +lemma firstScalarHom_vandermonde_top {K:Type*} [CommRing K] (f:ℂ →+* K) + {n:ℕ} (a:Fin n → K) : + (firstScalarHom f a (sourceVandermonde (MvPolynomial.X:Fin (n+1) → CosineRing (n+1)))).coeff n= + sourceVandermonde a := by + rw [firstScalarHom_vandermonde,Polynomial.coeff_mul_C] + have he:n=∑i:Fin n,(1:ℕ) := by simp + have hh:=coeff_prod_budget Finset.univ (fun i:Fin n => (Polynomial.X-Polynomial.C (a i))) + (fun _ => 1) (by intro i _; exact Polynomial.natDegree_X_sub_C_le _) + simp only [Finset.sum_const,Finset.card_univ,Fintype.card_fin,smul_eq_mul,mul_one, + Polynomial.coeff_sub,Polynomial.coeff_X_one,Polynomial.coeff_C] at hh + rw [hh]; simp + + + +theorem scalarPolynomial_first_top {K:Type*} [Field K] [CharZero K] + (f:ℂ →+* K) (n:ℕ) (dd rr:ℂ) (hdd:dd≠0) (a:Fin n → K) + (ha:Function.Injective a) (hD:∀i j,i≠j → discriminant (f dd) (a i) (a j)≠0) : + (firstScalarHom f a (scalarPolynomial (n+1) dd rr hdd)).coeff n= + MvPolynomial.eval₂Hom f a (scalarPolynomial n dd rr hdd) := by + have hh:=scalarNumerator_first_top_eval f n dd rr a hD + rw [scalarNumerator_eq_vandermonde (n+1) dd rr hdd,map_mul (firstScalarHom f a), + show 2*n=n+n by omega, + Polynomial.coeff_mul_add_eq_of_natDegree_le (firstScalarHom_vandermonde_degree f a) + (scalarPolynomial_first_degree f n dd rr hdd a),firstScalarHom_vandermonde_top, + scalarNumerator_eq_vandermonde n dd rr hdd,map_mul (MvPolynomial.eval₂Hom f a), + map_sourceVandermonde] at hh + simp only [MvPolynomial.eval₂Hom_X'] at hh + exact mul_left_cancel₀ (sourceVandermonde_ne_zero a ha) hh + +end +end CriticalStrip.Diagram + +end OAI diff --git a/lean/OAI/Combinatorics/StripMass/ScalarDeleteContinuation.lean b/lean/OAI/Combinatorics/StripMass/ScalarDeleteContinuation.lean new file mode 100644 index 0000000000000000000000000000000000000000..489473c96e34dc976aa1931ec2963cf269cd321d --- /dev/null +++ b/lean/OAI/Combinatorics/StripMass/ScalarDeleteContinuation.lean @@ -0,0 +1,447 @@ +import Mathlib +import OAI.Combinatorics.StripMass.ScalarDegree + +namespace OAI + +/-! Critical honeycomb strip paths, polynomial identities and crossing mass. -/ + + + +namespace CriticalStrip.Diagram +noncomputable section +open scoped Classical + +section Generic +variable {K:Type*} [Field K] {n:ℕ} +abbrev PolynomialField (K:Type*) [Field K] (n:ℕ) := FractionRing (MvPolynomial (Fin n) K) +def genericConst (n:ℕ) : K →+* PolynomialField K n := + (algebraMap (MvPolynomial (Fin n) K) (PolynomialField K n)).comp MvPolynomial.C +def genericVar (i:Fin n) : PolynomialField K n := + algebraMap (MvPolynomial (Fin n) K) (PolynomialField K n) (MvPolynomial.X i) + +lemma genericVar_ne_const (i:Fin n) (z:K) : genericVar i≠genericConst n z := by + intro h + have hh:=IsFractionRing.injective (MvPolynomial (Fin n) K) (PolynomialField K n) h + have he:=congrArg (MvPolynomial.eval (fun _ => z+1)) hh + simp at he + +lemma genericVar_inj (n:ℕ) : Function.Injective (@genericVar K _ n) := + (IsFractionRing.injective _ _).comp MvPolynomial.X_injective + +lemma discriminant_genericVar_ne (dd:K) (hdd:dd≠0) (i j:Fin n) : + discriminant (genericConst n dd) (genericVar i) (genericVar j)≠0 := by + have he:discriminant (genericConst n dd) (genericVar i) (genericVar j)= + algebraMap (MvPolynomial (Fin n) K) (PolynomialField K n) + (discriminant (MvPolynomial.C dd) (MvPolynomial.X i) (MvPolynomial.X j)) := by + simp [genericConst,genericVar,discriminant,map_ofNat] + rw [he] + apply (map_ne_zero_iff _ (IsFractionRing.injective _ _)).mpr + intro h + have hh:=congrArg (MvPolynomial.eval (fun _ => (0:K))) h + simp [discriminant,hdd] at hh + +lemma discriminant_const_genericVar_ne (dd x:K) (i:Fin n) : + discriminant (genericConst n dd) (genericConst n x) (genericVar i)≠0 := by + have he:discriminant (genericConst n dd) (genericConst n x) (genericVar i)= + algebraMap (MvPolynomial (Fin n) K) (PolynomialField K n) + (discriminant (MvPolynomial.C dd) (MvPolynomial.C x) (MvPolynomial.X i)) := by + simp [genericConst,genericVar,discriminant,map_ofNat] + rw [he] + apply (map_ne_zero_iff _ (IsFractionRing.injective _ _)).mpr + intro h + have hh:=congrArg (fun P:MvPolynomial (Fin n) K => + (MvPolynomial.eval₂Hom Polynomial.C (fun _ => Polynomial.X) P).coeff 2) h + simp only [discriminant,map_sub,map_add,map_mul,map_pow,map_ofNat, + MvPolynomial.eval₂Hom_C,MvPolynomial.eval₂Hom_X',map_zero] at hh + have hid:(Polynomial.C x)^2+Polynomial.X^2+2*Polynomial.C dd*Polynomial.C x*Polynomial.X- + (Polynomial.C dd)^2=(Polynomial.X^2 : Polynomial K)+ + Polynomial.C (2*dd*x)*Polynomial.X+Polynomial.C (x^2-dd^2) := by + simp only [map_mul,map_pow,map_sub,map_ofNat]; ring + rw [hid] at hh + have hc (z:K):((Polynomial.C z)^2).coeff 2=0 := by rw [←map_pow,Polynomial.coeff_C]; norm_num + simp [hc] at hh + +lemma generic_twoCons_inj (x y:K) (hxy:x≠y) : + Function.Injective (twoCons (genericConst n x) (genericConst n y) (@genericVar K _ n)) := by + have hc:genericConst n x≠genericConst n y := (genericConst n).injective.ne hxy + intro i j h + induction i using Fin.cases with + | zero => + induction j using Fin.cases with + | zero => rfl + | succ j => + induction j using Fin.cases with + | zero => exact (hc h).elim + | succ j => exact (genericVar_ne_const j x h.symm).elim + | succ i => + induction i using Fin.cases with + | zero => + induction j using Fin.cases with + | zero => exact (hc h.symm).elim + | succ j => + induction j using Fin.cases with + | zero => rfl + | succ j => exact (genericVar_ne_const j y h.symm).elim + | succ i => + induction j using Fin.cases with + | zero => exact (genericVar_ne_const i x h).elim + | succ j => + induction j using Fin.cases with + | zero => exact (genericVar_ne_const i y h).elim + | succ j => exact congrArg (fun k:Fin n => k.succ.succ) (genericVar_inj n h) + +lemma generic_twoCons_discriminant (dd x y:K) (hdd:dd≠0) + (i j:Fin (n+2)) (hij:i≠j) + (hp:¬((i=0 ∧ j=1) ∨ (i=1 ∧ j=0))) : + discriminant (genericConst n dd) + (twoCons (genericConst n x) (genericConst n y) genericVar i) + (twoCons (genericConst n x) (genericConst n y) genericVar j)≠0 := by + induction i using Fin.cases with + | zero => + induction j using Fin.cases with + | zero => exact (hij rfl).elim + | succ j => + induction j using Fin.cases with + | zero => exact (hp (Or.inl ⟨rfl,by simp⟩)).elim + | succ j => exact discriminant_const_genericVar_ne dd x j + | succ i => + induction i using Fin.cases with + | zero => + induction j using Fin.cases with + | zero => exact (hp (Or.inr ⟨by simp,rfl⟩)).elim + | succ j => + induction j using Fin.cases with + | zero => exact (hij rfl).elim + | succ j => exact discriminant_const_genericVar_ne dd y j + | succ i => + induction j using Fin.cases with + | zero => rw [discriminant_symm]; exact discriminant_const_genericVar_ne dd x i + | succ j => + induction j using Fin.cases with + | zero => rw [discriminant_symm]; exact discriminant_const_genericVar_ne dd y i + | succ j => exact discriminant_genericVar_ne dd hdd i j +end Generic + + + +theorem scalarPolynomial_delete_continuation {K:Type*} [Field K] [CharZero K] + (f:ℂ →+* K) (n:ℕ) (dd rr:ℂ) (hdd:dd≠0) (x y γ σ:K) (hxy:x≠y) + (hxroot:∀z,discriminant (f dd) x z=(z-y)*(z-γ)) + (hyroot:∀z,discriminant (f dd) y z=(z-x)*(z-σ)) (a:Fin n → K) : + MvPolynomial.eval₂Hom f (twoCons x y a) (scalarPolynomial (n+2) dd rr hdd)= + (x+y+f rr)*(∏i:Fin n,(a i-γ)*(a i-σ))* + MvPolynomial.eval₂Hom f a (scalarPolynomial n dd rr hdd) := by + let g:K →+* PolynomialField K n:=genericConst n + have rootsMap (v u w:K) (h:∀z,discriminant (f dd) v z=(z-u)*(z-w)) + (z:PolynomialField K n) : + discriminant (g (f dd)) (g v) z=(z-g u)*(z-g w) := by + have h0:=h 0 + have h1:=h 1 + have hc:v^2-(f dd)^2=u*w := by simpa [discriminant] using h0 + have hl:2*f dd*v= -(u+w) := by + simp only [discriminant] at h1 + linear_combination h1-hc + have hcm:=congrArg g hc + have hlm:=congrArg g hl + simp only [map_sub,map_pow,map_mul,map_ofNat,map_neg,map_add] at hcm hlm + unfold discriminant + linear_combination hcm+z*hlm + have hh:=scalarPolynomial_delete_roots (g.comp f) n dd rr hdd + (g x) (g y) (g γ) (g σ) genericVar + (generic_twoCons_inj x y hxy) (rootsMap x y γ hxroot) (rootsMap y x σ hyroot) + (generic_twoCons_discriminant (f dd) x y (by simpa using f.injective.ne hdd)) + have hp: + MvPolynomial.eval₂Hom (MvPolynomial.C.comp f) (twoCons (MvPolynomial.C x) (MvPolynomial.C y) MvPolynomial.X) + (scalarPolynomial (n+2) dd rr hdd)= + (MvPolynomial.C x+MvPolynomial.C y+MvPolynomial.C (f rr)) * + (∏i:Fin n,(MvPolynomial.X i-MvPolynomial.C γ)*(MvPolynomial.X i-MvPolynomial.C σ))* + MvPolynomial.eval₂Hom (MvPolynomial.C.comp f) MvPolynomial.X (scalarPolynomial n dd rr hdd) := by + apply IsFractionRing.injective (MvPolynomial (Fin n) K) (PolynomialField K n) + simp only [MvPolynomial.map_eval₂Hom,map_mul,map_prod,map_sub,map_add] + convert hh using 1 + · apply congrArg (fun v:Fin (n+2) → PolynomialField K n => + MvPolynomial.eval₂Hom (g.comp f) v (scalarPolynomial (n+2) dd rr hdd)) + funext i + induction i using Fin.cases with + | zero => rfl + | succ i => induction i using Fin.cases <;> rfl + · rfl + have hh':=congrArg (MvPolynomial.eval a) hp + simp only [MvPolynomial.map_eval₂Hom,map_mul,map_prod,map_sub,map_add,MvPolynomial.eval_X, + MvPolynomial.eval_C] at hh' + have hc: (MvPolynomial.eval a).comp (MvPolynomial.C.comp f)=f := by + ext z; simp + have hx:(fun i => (MvPolynomial.eval a) + (twoCons (MvPolynomial.C x) (MvPolynomial.C y) MvPolynomial.X i))=twoCons x y a := by + funext i + induction i using Fin.cases with + | zero => simp [twoCons] + | succ i => induction i using Fin.cases <;> simp [twoCons] + simpa only [hc,hx] using hh' + + + + + + + +lemma map_firstScalarHom {K L:Type*} [CommRing K] [CommRing L] (g:K →+* L) + (f:ℂ →+* K) {n:ℕ} (a:Fin n → K) (P:CosineRing (n+1)) : + (firstScalarHom f a P).map g=firstScalarHom (g.comp f) (fun i => g (a i)) P := by + have he:(Polynomial.mapRingHom g).comp (firstScalarHom f a)= + firstScalarHom (g.comp f) (fun i =>g (a i)) := by + apply MvPolynomial.ringHom_ext + · intro z + simp only [RingHom.comp_apply,firstScalarHom_C,Polynomial.map_C,Polynomial.coe_mapRingHom] + · intro z + simp only [RingHom.comp_apply,firstScalarHom_X,Polynomial.coe_mapRingHom] + induction z using Fin.cases <;> simp + exact congrArg (fun h => h P) he + + + +theorem scalarPolynomial_first_top_continuation {K:Type*} [CommRing K] + (f:ℂ →+* K) (n:ℕ) (dd rr:ℂ) (hdd:dd≠0) (a:Fin n → K) : + (firstScalarHom f a (scalarPolynomial (n+1) dd rr hdd)).coeff n= + MvPolynomial.eval₂Hom f a (scalarPolynomial n dd rr hdd) := by + have hi: + (firstScalarHom MvPolynomial.C (MvPolynomial.X:Fin n → CosineRing n) + (scalarPolynomial (n+1) dd rr hdd)).coeff n=scalarPolynomial n dd rr hdd := by + apply IsFractionRing.injective (CosineRing n) (CosineField n) + rw [←Polynomial.coeff_map,map_firstScalarHom] + have hh:=scalarPolynomial_first_top (genericConst n) n dd rr hdd genericVar + (genericVar_inj n) (fun i j _ => discriminant_genericVar_ne dd hdd i j) + have hv: MvPolynomial.eval₂Hom (genericConst n) genericVar= + algebraMap (CosineRing n) (CosineField n) := by + apply MvPolynomial.ringHom_ext + · intro z; simp [genericConst, RingHom.comp_apply] + · intro z; simp [genericVar] + rw [hv] at hh + exact hh + have he:=congrArg (MvPolynomial.eval₂Hom f a) hi + rw [←Polynomial.coeff_map,map_firstScalarHom] at he + have hc:(MvPolynomial.eval₂Hom f a).comp MvPolynomial.C=f := by ext z; simp + simp only [hc,MvPolynomial.eval₂Hom_X'] at he + exact he + + + + + + + + +def scalarValue {K:Type*} [CommRing K] (f:ℂ →+* K) {n:ℕ} (a:Fin n → K) : K := + MvPolynomial.eval₂Hom f a (scalarPolynomial n d rho (by exact_mod_cast d_ne_zero)) + +lemma scalarValue_permute {K:Type*} [CommRing K] (f:ℂ →+* K) {n:ℕ} + (a:Fin n → K) (σ:Equiv.Perm (Fin n)) : scalarValue f (a ∘ σ)=scalarValue f a := by + unfold scalarValue + have h:=congrArg (MvPolynomial.eval₂Hom f a) (scalarPolynomial_rename (d:ℂ) rho + (by exact_mod_cast d_ne_zero) σ) + simpa [MvPolynomial.eval₂Hom_rename] using h + +lemma scalarValue_extract {K:Type*} [CommRing K] (f:ℂ →+* K) {n:ℕ} + (a:Fin (n+1) → K) (i:Fin (n+1)) : + scalarValue f a=scalarValue f (Fin.cons (a i) (fun j => a (i.succAbove j))) := by + have h:=scalarValue_permute f a i.cycleRange.symm + rw [←h] + congr 1 + funext j + induction j using Fin.cases <;> simp + +lemma scalarValue_swap_head {K:Type*} [CommRing K] (f:ℂ →+* K) {n:ℕ} + (x y:K) (a:Fin n → K) : + scalarValue f (Fin.cons x (Fin.cons y a))=scalarValue f (Fin.cons y (Fin.cons x a)) := by + have h:=scalarValue_extract f (Fin.cons x (Fin.cons y a)) (1:Fin (n+2)) + apply h.trans + congr 1 + funext j + induction j using Fin.cases with + | zero => rfl + | succ j => + induction j using Fin.cases with + | zero => rfl + | succ j => simp [Fin.succAbove,Fin.lt_def] + +lemma eval_firstScalarHom {K:Type*} [CommRing K] (f:ℂ →+* K) + {n:ℕ} (a:Fin n → K) (P:CosineRing (n+1)) (z:K) : + (firstScalarHom f a P).eval z=MvPolynomial.eval₂Hom f (Fin.cons z a) P := by + have he:(Polynomial.evalRingHom z).comp (firstScalarHom f a)=MvPolynomial.eval₂Hom f (Fin.cons z a) := by + ext t + · simp only [RingHom.comp_apply,firstScalarHom_C,Polynomial.coe_evalRingHom,Polynomial.eval_C,MvPolynomial.eval₂Hom_C] + · simp only [RingHom.comp_apply,firstScalarHom_X,MvPolynomial.eval₂Hom_X',Polynomial.coe_evalRingHom] + induction t using Fin.cases <;> simp + exact congrArg (fun h =>h P) he + +lemma scalarValue_zero {K:Type*} [CommRing K] (f:ℂ →+* K) (a:Fin 0 → K) : scalarValue f a=1 := by + have hp:=scalarNumerator_eq_vandermonde 0 (d:ℂ) rho (by exact_mod_cast d_ne_zero) + have h0:scalarPolynomial 0 d rho (by exact_mod_cast d_ne_zero)=1 := by + simp [scalarNumerator,sourceVandermonde,clearedPfaffian,clearedPfaffianTerm] at hp + rw [Finset.prod_eq_one (fun e _ => Fin.elim0 e.val.1)] at hp + exact hp.symm + simp [scalarValue,h0] + +lemma scalarValue_one {K:Type*} [CommRing K] (f:ℂ →+* K) (x:K) : + scalarValue f (fun _:Fin 1 =>x)=1 := by + let a:Fin 0 → K := Fin.elim0 + have h:=Polynomial.eq_C_of_natDegree_le_zero + (scalarPolynomial_first_degree f 0 d rho (by exact_mod_cast d_ne_zero) a) + rw [scalarPolynomial_first_top_continuation] at h + change firstScalarHom f a _=Polynomial.C (scalarValue f a) at h + rw [scalarValue_zero] at h + have he:=congrArg (fun P:Polynomial K =>P.eval x) h + rw [eval_firstScalarHom] at he + convert he using 1 + · apply congrArg (scalarValue f) + funext i + induction i using Fin.cases with + | zero => rfl + | succ i => exact Fin.elim0 i + · simp + +lemma scalarValue_two {K:Type*} [CommRing K] (f:ℂ →+* K) (x y:K) : + scalarValue f (Fin.cons x (fun _:Fin 1 =>y))=x+y+f (rho:ℂ) := by + let a:Fin 1 → K := fun _ =>y + let P:=firstScalarHom f a (scalarPolynomial 2 d rho (by exact_mod_cast d_ne_zero)) + have hp:P=Polynomial.X+Polynomial.C (P.coeff 0) := by + have h:=Polynomial.eq_X_add_C_of_natDegree_le_one + (scalarPolynomial_first_degree f 1 d rho (by exact_mod_cast d_ne_zero) a) + rw [scalarPolynomial_first_top_continuation] at h + change P=Polynomial.C (scalarValue f a)*Polynomial.X+Polynomial.C (P.coeff 0) at h + rw [scalarValue_one] at h + simpa using h + have hf:=source_scalarPolynomial_flat f 1 a + have hc:P.eval (f (c:ℂ))=y+f (C:ℂ) := by + change (firstScalarHom f a _).eval _ = _ + rw [eval_firstScalarHom,hf] + change _ * scalarValue f a=_ + rw [scalarValue_one] + simp [a] + rw [hp] at hc + simp only [Polynomial.eval_add,Polynomial.eval_X,Polynomial.eval_C] at hc + have hconst:f (c:ℂ)+f (rho:ℂ)=f (C:ℂ) := by + rw [←map_add]; congr 1; exact_mod_cast c_add_rho_eq_C + have he:=congrArg (fun Q:Polynomial K =>Q.eval x) hp + change (firstScalarHom f a _).eval x = _ at he + rw [eval_firstScalarHom] at he + change scalarValue f (Fin.cons x a)= _ at he + rw [he] + simp only [Polynomial.eval_add,Polynomial.eval_X,Polynomial.eval_C] + linear_combination hc-hconst + + + + + + + +lemma scalarValue_cons_extract {K:Type*} [CommRing K] (f:ℂ →+* K) {n:ℕ} + (z:K) (a:Fin (n+1) → K) (i:Fin (n+1)) : + scalarValue f (Fin.cons z a)= + scalarValue f (Fin.cons z (Fin.cons (a i) (fun j =>a (i.succAbove j)))) := by + have h:=scalarValue_extract f (Fin.cons z a) i.succ + have hv:(fun j:Fin (n+1) => (Fin.cons z a : Fin (n+2) → K) (i.succ.succAbove j))= + Fin.cons z (fun j =>a (i.succAbove j)) := by + funext j + induction j using Fin.cases <;> simp + simp only [Fin.cons_succ,hv] at h + exact h.trans (scalarValue_swap_head f (a i) z _) + +lemma scalarValue_one_middle_extract {K:Type*} [CommRing K] (f:ℂ →+* K) {n:ℕ} + (z x:K) (a:Fin (n+1) → K) (i:Fin (n+1)) : + scalarValue f (Fin.cons z (Fin.cons x a))= + scalarValue f (Fin.cons z (Fin.cons (a i) (Fin.cons x (fun j =>a (i.succAbove j))))) := by + have h:=scalarValue_cons_extract f z (Fin.cons x a) i.succ + have hv:(fun j:Fin (n+1) => (Fin.cons x a : Fin (n+2) → K) (i.succ.succAbove j))= + Fin.cons x (fun j =>a (i.succAbove j)) := by + funext j + induction j using Fin.cases <;> simp + simpa only [Fin.cons_succ,hv] using h + +lemma scalarValue_two_middle_extract {K:Type*} [CommRing K] (f:ℂ →+* K) {n:ℕ} + (z x y:K) (a:Fin (n+1) → K) (i:Fin (n+1)) : + scalarValue f (Fin.cons z (Fin.cons x (Fin.cons y a)))= + scalarValue f (Fin.cons z (Fin.cons (a i) (Fin.cons x (Fin.cons y (fun j =>a (i.succAbove j)))))) := by + have h:=scalarValue_cons_extract f z (Fin.cons x (Fin.cons y a)) i.succ.succ + have hv:(fun j:Fin (n+2) => (Fin.cons x (Fin.cons y a) : Fin (n+3) → K) (i.succ.succ.succAbove j))= + Fin.cons x (Fin.cons y (fun j =>a (i.succAbove j))) := by + funext j + induction j using Fin.cases with + | zero => simp + | succ j => induction j using Fin.cases <;> simp + simpa only [Fin.cons_succ,hv] using h + +lemma scalarValue_delete {K:Type*} [Field K] [CharZero K] (f:ℂ →+* K) {n:ℕ} + (x y γ σ:K) (hxy:x≠y) + (hx:∀z,discriminant (f (d:ℂ)) x z=(z-y)*(z-γ)) + (hy:∀z,discriminant (f (d:ℂ)) y z=(z-x)*(z-σ)) (a:Fin n → K) : + scalarValue f (Fin.cons x (Fin.cons y a))= + (x+y+f (rho:ℂ))*(∏i,(a i-γ)*(a i-σ))*scalarValue f a := by + exact scalarPolynomial_delete_continuation f n d rho _ x y γ σ hxy hx hy a + +lemma scalarValue_flat {K:Type*} [CommRing K] (f:ℂ →+* K) {n:ℕ} (a:Fin n → K) : + scalarValue f (Fin.cons (f (c:ℂ)) a)=(∏i,(a i+f (C:ℂ)))*scalarValue f a := + source_scalarPolynomial_flat f n a + + + + + + + + +def scalarMergeDiff {K:Type*} [CommRing K] (f:ℂ →+* K) {n:ℕ} + (x y t:K) (a:Fin n → K) : Polynomial K := + firstScalarHom f (Fin.cons x (Fin.cons y a)) (scalarPolynomial (n+3) d rho (by exact_mod_cast d_ne_zero)) - + Polynomial.C ((x+y+f (rho:ℂ))*(∏i,(a i+t))) * + ((Polynomial.X+Polynomial.C t)* + firstScalarHom f (Fin.cons t a) (scalarPolynomial (n+2) d rho (by exact_mod_cast d_ne_zero))) + +lemma scalarMergeDiff_eval {K:Type*} [CommRing K] (f:ℂ →+* K) {n:ℕ} + (x y t:K) (a:Fin n → K) (z:K) : + (scalarMergeDiff f x y t a).eval z= + scalarValue f (Fin.cons z (Fin.cons x (Fin.cons y a)))- + (x+y+f (rho:ℂ))*(∏i,(a i+t))*(z+t)*scalarValue f (Fin.cons z (Fin.cons t a)) := by + simp only [scalarMergeDiff,Polynomial.eval_sub,Polynomial.eval_mul,Polynomial.eval_C, + Polynomial.eval_add,Polynomial.eval_X,eval_firstScalarHom,scalarValue] + ring + +lemma scalarMergeDiff_degree {K:Type*} [CommRing K] (f:ℂ →+* K) {n:ℕ} + (x y t:K) (a:Fin n → K) : (scalarMergeDiff f x y t a).natDegree≤n+2 := by + apply (Polynomial.natDegree_sub_le _ _).trans + apply max_le + · exact scalarPolynomial_first_degree f (n+2) d rho _ _ + · apply (Polynomial.natDegree_C_mul_le _ _).trans + apply (Polynomial.natDegree_mul_le).trans + have hp:=scalarPolynomial_first_degree f (n+1) d rho (by exact_mod_cast d_ne_zero) (Fin.cons t a) + change ((firstScalarHom f (Fin.cons t a)) (scalarPolynomial (n+2) d rho _)).natDegree≤n+1 at hp + have hl:(Polynomial.X+Polynomial.C t).natDegree≤1:= + (Polynomial.natDegree_add_le _ _).trans (max_le Polynomial.natDegree_X_le (by simp)) + omega + +lemma scalarMergeDiff_top {K:Type*} [CommRing K] (f:ℂ →+* K) {n:ℕ} + (x y t:K) (a:Fin n → K) + (h:scalarValue f (Fin.cons x (Fin.cons y a))= + (x+y+f (rho:ℂ))*(∏i,(a i+t))*scalarValue f (Fin.cons t a)) : + (scalarMergeDiff f x y t a).coeff (n+2)=0 := by + unfold scalarMergeDiff + rw [Polynomial.coeff_sub,Polynomial.coeff_C_mul,add_mul (Polynomial.X) (Polynomial.C t),Polynomial.coeff_add, + Polynomial.coeff_X_mul,Polynomial.coeff_C_mul] + rw [scalarPolynomial_first_top_continuation,scalarPolynomial_first_top_continuation] + have hp:=scalarPolynomial_first_degree f (n+1) d rho (by exact_mod_cast d_ne_zero) (Fin.cons t a) + rw [Polynomial.coeff_eq_zero_of_natDegree_lt (lt_of_le_of_lt hp (by omega)),mul_zero,add_zero] + exact sub_eq_zero.mpr h + +lemma scalarMergeDiff_degree_reduced {K:Type*} [CommRing K] (f:ℂ →+* K) {n:ℕ} + (x y t:K) (a:Fin n → K) + (h:scalarValue f (Fin.cons x (Fin.cons y a))= + (x+y+f (rho:ℂ))*(∏i,(a i+t))*scalarValue f (Fin.cons t a)) : + (scalarMergeDiff f x y t a).natDegree≤n+1 := by + simpa using Polynomial.natDegree_le_pred (scalarMergeDiff_degree f x y t a) + (scalarMergeDiff_top f x y t a h) + +end +end CriticalStrip.Diagram + +end OAI diff --git a/lean/OAI/Combinatorics/StripMass/ScalarFlat.lean b/lean/OAI/Combinatorics/StripMass/ScalarFlat.lean new file mode 100644 index 0000000000000000000000000000000000000000..96234a50c6ffd15c60cc4cccad356d313b175dfe --- /dev/null +++ b/lean/OAI/Combinatorics/StripMass/ScalarFlat.lean @@ -0,0 +1,587 @@ +import Mathlib +import OAI.Combinatorics.StripMass.InterpolantCovariance + +namespace OAI + +/-! Critical honeycomb strip paths, polynomial identities and crossing mass. -/ + + + +namespace CriticalStrip.Diagram +noncomputable section +open Finset + + + +theorem plainKernel_cons_flat {K : Type*} [Field K] {n : ℕ} (dd rr cc CC : K) + (a : Fin n → K) (hshift : cc+rr = CC) + (hroot : ∀ z, discriminant dd cc z = (z-cc)*(z+CC)) + (hfirst : ∀ i, a i ≠ cc) (hsecond : ∀ i, a i+CC ≠ 0) : + plainKernel dd rr (Fin.cons cc a) = frontBorder (plainKernel dd rr a) (-1) := by + have hrow : ∀ i : Fin n, plainKernel dd rr (Fin.cons cc a) 0 i.succ = -1 := by + intro i + simp only [plainKernel,Fin.cons_zero,Fin.cons_succ,hroot] + have hc : cc+a i+rr = a i+CC := by rw [← hshift]; ring + rw [hc] + field_simp [sub_ne_zero.mpr (hfirst i),hsecond i] + ring + funext i j + induction i using Fin.cases with + | zero => + induction j using Fin.cases with + | zero => simp [plainKernel] + | succ j => exact hrow j + | succ i => + induction j using Fin.cases with + | zero => + rw [plainKernel_skew _ _ _ 0 i.succ,hrow] + simp + | succ j => rfl + + + +theorem pfaffian_augmented_cons_flat {K : Type*} [Field K] [CharZero K] {n : ℕ} + (dd rr cc CC : K) (a : Fin n → K) (hshift : cc+rr = CC) + (hroot : ∀ z, discriminant dd cc z = (z-cc)*(z+CC)) + (hfirst : ∀ i, a i ≠ cc) (hsecond : ∀ i, a i+CC ≠ 0) : + pfaffian (augmentedKernel dd rr (Fin.cons cc a)) = + (-1)^n * pfaffian (augmentedKernel dd rr a) := by + obtain ⟨m,hm|hm⟩ : ∃ m, n = 2*m ∨ n = 2*m+1 := ⟨n/2,by omega⟩ + · subst n + rw [pfaffian_augmented_odd, pfaffian_augmented_even] + apply Eq.trans (congrArg (fun M => pfaffian (backBorder M)) + (plainKernel_cons_flat dd rr cc CC a hshift hroot hfirst hsecond)) + rw [pfaffian_back_front _ (plainKernel_skew _ _ _)] + simp [pow_mul] + · subst n + have hcast : 2*m+1+1 = 2*(m+1) := by omega + have he := pfaffian_augmented_even (m+1) dd rr (Fin.cons cc a) + apply Eq.trans he + apply Eq.trans (congrArg pfaffian (plainKernel_cons_flat dd rr cc CC a hshift hroot hfirst hsecond)) + have h := pfaffian_frontBorder_scale (plainKernel dd rr a) (plainKernel_skew _ _ _) (1:K) (-1) + simp only [neg_one_mul] at h + apply Eq.trans h + rw [pfaffian_front_back _ (plainKernel_skew _ _ _),pfaffian_augmented_odd] + simp [pow_add,pow_mul] + +theorem scalarNormalization_cons_flat {K : Type*} [Field K] [CharZero K] {n : ℕ} + (dd rr cc CC : K) (a : Fin n → K) (hshift : cc+rr = CC) + (hroot : ∀ z, discriminant dd cc z = (z-cc)*(z+CC)) + (hfirst : ∀ i, a i ≠ cc) (hsecond : ∀ i, a i+CC ≠ 0) : + scalarNormalization dd rr (Fin.cons cc a) = + (∏ i : Fin n, (a i+CC)) * scalarNormalization dd rr a := by + have hf : ∀ i, discriminant dd cc (a i)/(cc-a i) = -(a i+CC) := by + intro i + rw [hroot] + field_simp [sub_ne_zero.mpr (hfirst i).symm] + ring + unfold scalarNormalization + rw [← prod_upperPair, ← prod_upperPair] + have hp := prod_upperPair_succ (fun (i j : Fin (n+1)) => + discriminant dd ((Fin.cons cc a : Fin (n+1) → K) i) ((Fin.cons cc a : Fin (n+1) → K) j) / + ((Fin.cons cc a : Fin (n+1) → K) i-(Fin.cons cc a : Fin (n+1) → K) j)) + apply Eq.trans (congrArg (fun z => z * pfaffian (augmentedKernel dd rr (Fin.cons cc a))) hp) + simp only [Fin.cons_zero,Fin.cons_succ,hf] + rw [Finset.prod_neg, Finset.card_univ,Fintype.card_fin, + pfaffian_augmented_cons_flat dd rr cc CC a hshift hroot hfirst hsecond] + have hs : (-1:K)^n * (-1)^n = 1 := by rw [← mul_pow]; simp + calc + _ = ((-1:K)^n * (-1)^n) * ((∏ i : Fin n, (a i+CC)) * + ((∏ e : UpperPair n, discriminant dd (a e.val.1) (a e.val.2)/(a e.val.1-a e.val.2)) * + pfaffian (augmentedKernel dd rr a))) := by ring + _ = _ := by rw [hs,one_mul] + +end + + + + + +noncomputable section +open scoped Classical + +lemma cosineVar_ne_const {n : ℕ} (i : Fin n) (z : ℂ) : + cosineVar i ≠ cosineConst n z := by + intro h + have he := (IsFractionRing.injective (CosineRing n) (CosineField n)) h + have := congrArg (MvPolynomial.eval (fun _ : Fin n => z+1)) he + simp at this + +lemma cosineVar_injective (n : ℕ) : Function.Injective (@cosineVar n) := + (IsFractionRing.injective (CosineRing n) (CosineField n)).comp MvPolynomial.X_injective + +lemma flat_discriminant_map {K : Type*} [CommRing K] (f : ℂ →+* K) + (dd cc CC : ℂ) (hlin : 2*dd*cc=CC-cc) (hconst : cc^2-dd^2= -cc*CC) (z : K) : + discriminant (f dd) (f cc) z=(z-f cc)*(z+f CC) := by + have hl := congrArg f hlin + have hc := congrArg f hconst + simp only [map_mul,map_ofNat,map_sub,map_pow,map_neg] at hl hc + unfold discriminant + linear_combination z*hl+hc + + + +theorem scalarPolynomial_cons_flat_identity (n : ℕ) (dd rr cc CC : ℂ) + (hdd : dd≠0) (hshift : cc+rr=CC) (hlin : 2*dd*cc=CC-cc) + (hconst : cc^2-dd^2= -cc*CC) : + MvPolynomial.eval₂Hom MvPolynomial.C (Fin.cons (MvPolynomial.C cc) MvPolynomial.X) + (scalarPolynomial (n+1) dd rr hdd)= + (∏ i : Fin n, (MvPolynomial.X i + MvPolynomial.C CC))*scalarPolynomial n dd rr hdd := by + let f : ℂ →+* CosineField n := (algebraMap (CosineRing n) (CosineField n)).comp MvPolynomial.C + have hc (z : ℂ) : f z=cosineConst n z := rfl + have hv : MvPolynomial.eval₂Hom f (@cosineVar n)=algebraMap (CosineRing n) (CosineField n) := by + apply MvPolynomial.ringHom_ext <;> intro z <;> simp [f,cosineVar] + have hi : Function.Injective (Fin.cons (f cc) (@cosineVar n)) := by + intro i j hij + induction i using Fin.cases with + | zero => + induction j using Fin.cases with + | zero => rfl + | succ j => exact (cosineVar_ne_const j cc (by simpa [hc] using hij.symm)).elim + | succ i => + induction j using Fin.cases with + | zero => exact (cosineVar_ne_const i cc (by simpa [hc] using hij)).elim + | succ j => exact congrArg Fin.succ (cosineVar_injective n (by simpa using hij)) + have hfirst (i : Fin n) : cosineVar i≠f cc := cosineVar_ne_const i cc + have hsecond (i : Fin n) : cosineVar i+f CC≠0 := by + intro he + apply cosineVar_ne_const i (-CC) + rw [←hc,map_neg] + exact eq_neg_of_add_eq_zero_left he + have hroot (z : CosineField n) : discriminant (f dd) (f cc) z=(z-f cc)*(z+f CC) := + flat_discriminant_map f dd cc CC hlin hconst z + have hD (i j : Fin (n+1)) (hij:i≠j) : + discriminant (f dd) ((Fin.cons (f cc) (@cosineVar n) : Fin (n+1) → CosineField n) i) + ((Fin.cons (f cc) (@cosineVar n) : Fin (n+1) → CosineField n) j)≠0 := by + induction i using Fin.cases with + | zero => + induction j using Fin.cases with + | zero => exact (hij rfl).elim + | succ j => simpa only [Fin.cons_zero,Fin.cons_succ,hroot] using + mul_ne_zero (sub_ne_zero.mpr (hfirst j)) (hsecond j) + | succ i => + induction j using Fin.cases with + | zero => + simp only [Fin.cons_zero,Fin.cons_succ] + rw [discriminant_symm,hroot] + exact mul_ne_zero (sub_ne_zero.mpr (hfirst i)) (hsecond i) + | succ j => exact discriminant_cosineVar_ne dd hdd i j + apply IsFractionRing.injective (CosineRing n) (CosineField n) + rw [MvPolynomial.map_eval₂Hom,map_mul] + have hm : (algebraMap (CosineRing n) (CosineField n)) + (∏ i : Fin n,(MvPolynomial.X i+MvPolynomial.C CC))= + ∏ i : Fin n,(algebraMap (CosineRing n) (CosineField n)) + (MvPolynomial.X i+MvPolynomial.C CC) := map_prod _ _ _ + rw [hm] + have ha : (fun i : Fin (n+1) => (algebraMap (CosineRing n) (CosineField n)) + ((Fin.cons (MvPolynomial.C cc) MvPolynomial.X : Fin (n+1) → CosineRing n) i))= + Fin.cons (f cc) cosineVar := by + funext i + induction i using Fin.cases <;> rfl + rw [ha] + change MvPolynomial.eval₂Hom f (Fin.cons (f cc) cosineVar) _ = _ + rw [scalarPolynomial_eval f (n+1) dd rr hdd _ hi hD] + rw [scalarNormalization_cons_flat _ _ _ _ _ (by simpa only [←map_add] using congrArg f hshift) + hroot hfirst hsecond] + rw [←scalarPolynomial_eval f n dd rr hdd _ (cosineVar_injective n) + (fun i j _ => discriminant_cosineVar_ne dd hdd i j),hv] + congr 1 + apply Finset.prod_congr rfl + intro i _ + simp only [map_add] + rfl + + +theorem scalarPolynomial_eval_cons_flat {K : Type*} [CommRing K] (f : ℂ →+* K) + (n : ℕ) (dd rr cc CC : ℂ) (hdd : dd≠0) (hshift : cc+rr=CC) + (hlin : 2*dd*cc=CC-cc) (hconst : cc^2-dd^2= -cc*CC) (a : Fin n → K) : + MvPolynomial.eval₂Hom f (Fin.cons (f cc) a) (scalarPolynomial (n+1) dd rr hdd)= + (∏ i : Fin n, (a i + f CC))*MvPolynomial.eval₂Hom f a (scalarPolynomial n dd rr hdd) := by + have h := congrArg (MvPolynomial.eval₂Hom f a) + (scalarPolynomial_cons_flat_identity n dd rr cc CC hdd hshift hlin hconst) + rw [MvPolynomial.map_eval₂Hom] at h + have hc : (MvPolynomial.eval₂Hom f a).comp MvPolynomial.C=f := by + ext z + simp + have hv : (fun i : Fin (n+1) => (MvPolynomial.eval₂Hom f a) + ((Fin.cons (MvPolynomial.C cc) MvPolynomial.X : Fin (n+1) → CosineRing n) i))= + Fin.cons (f cc) a := by + funext i + induction i using Fin.cases <;> simp + rw [hc,hv] at h + simpa only [map_mul,map_prod,map_add,MvPolynomial.eval₂Hom_X',MvPolynomial.eval₂Hom_C] using h + +end + + + + + +noncomputable section + +lemma cos_five_lambda_eq : Real.cos (5*lambda)= -c := by + rw [show 5*lambda=Real.pi-3*lambda by simp [lambda]; ring,Real.cos_pi_sub] + rfl + +lemma c_add_rho_eq_C : c+rho=C := by + have h₁ := Real.cos_add (3*lambda) (2*lambda) + have h₂ := Real.cos_sub (3*lambda) (2*lambda) + rw [show 3*lambda+2*lambda=5*lambda by ring,cos_five_lambda_eq] at h₁ + rw [show 3*lambda-2*lambda=lambda by ring] at h₂ + change -c=c*d-Real.sin (3*lambda)*Real.sin (2*lambda) at h₁ + change C=c*d+Real.sin (3*lambda)*Real.sin (2*lambda) at h₂ + rw [rho_eq_two_c_d] + linarith + +lemma discriminant_flat_complex (z : ℂ) : + discriminant (d:ℂ) (c:ℂ) z=(z-(c:ℂ))*(z+(C:ℂ)) := by + have h:=discriminant_cosine_roots_complex (3*lambda) z + rw [show 3*lambda-6*lambda= -(3*lambda) by ring,Real.cos_neg, + show 3*lambda+6*lambda=lambda+Real.pi by simp [lambda]; ring,Real.cos_add_pi] at h + simpa only [c,C,Complex.ofReal_neg,sub_neg_eq_add] using h + +lemma flat_scalar_linear : 2*(d:ℂ)*(c:ℂ)=(C:ℂ)-(c:ℂ) := by + have h:=congrArg (fun x : ℝ => (x:ℂ)) c_add_rho_eq_C + rw [rho_eq_two_c_d] at h + push_cast at h + linear_combination h + +lemma flat_scalar_constant : (c:ℂ)^2-(d:ℂ)^2= -(c:ℂ)*(C:ℂ) := by + simpa [discriminant] using discriminant_flat_complex 0 + +lemma source_scalarPolynomial_flat {K : Type*} [CommRing K] (f : ℂ →+* K) + (n : ℕ) (a : Fin n → K) : + MvPolynomial.eval₂Hom f (Fin.cons (f (c:ℂ)) a) + (scalarPolynomial (n+1) d rho (by exact_mod_cast d_ne_zero))= + (∏ i, (a i + f (C:ℂ)))*MvPolynomial.eval₂Hom f a + (scalarPolynomial n d rho (by exact_mod_cast d_ne_zero)) := + scalarPolynomial_eval_cons_flat f n d rho c C _ (by exact_mod_cast c_add_rho_eq_C) + flat_scalar_linear flat_scalar_constant a + +lemma torusSin_phase_pow (n : ℕ) (k : ℕ) : + torusSin (constF n phase^k)=constF n (Real.sin ((k:ℝ)*lambda)) := by + have h := congrArg (constF n) (phase_sine (k:ℤ)) + simpa [torusSin,constF,map_ofNat] using h + +@[simp] lemma torusSin_one (n : ℕ) : torusSin (1:SpectralField n)=0 := by + simp [torusSin] + +lemma sin_two_lambda_eq_d : Real.sin (2*lambda)=d := by + rw [show 2*lambda=Real.pi/4 by simp [lambda]; ring,d, + show 2*lambda=Real.pi/4 by simp [lambda]; ring,Real.sin_pi_div_four,Real.cos_pi_div_four] + +lemma sin_five_lambda_eq : Real.sin (5*lambda)=Real.sin (3*lambda) := by + rw [show 5*lambda=Real.pi-3*lambda by simp [lambda]; ring,Real.sin_pi_sub] + +lemma torusL_one (n : ℕ) : + torusL (1:SpectralField n)=constF n d*constF n (Real.sin (3*lambda)) := by + rw [torusL,mul_one,mul_one,torusSin_phase_pow,torusSin_phase_pow] + simp only [Nat.cast_ofNat,sin_two_lambda_eq_d] + +lemma torusL_phase_three (n : ℕ) : + torusL (constF n phase^3)=constF n d*constF n (Real.sin (3*lambda)) := by + rw [torusL,←pow_add,←pow_add] + norm_num only [Nat.reduceAdd] + rw [torusSin_phase_pow,torusSin_phase_pow] + simp only [Nat.cast_ofNat] + rw [sin_five_lambda_eq,sin_six_lambda,mul_comm] + +lemma sin_three_lambda_pos : 0 < Real.sin (3*lambda) := by + apply Real.sin_pos_of_pos_of_lt_pi + · unfold lambda + positivity + · unfold lambda + linarith [Real.pi_pos] + +lemma torusL_one_ne_zero (n : ℕ) : torusL (1:SpectralField n)≠0 := by + rw [torusL_one] + apply mul_ne_zero + · exact (map_ne_zero (algebraMap ℂ (SpectralField n))).mpr (by exact_mod_cast d_ne_zero) + · exact (map_ne_zero (algebraMap ℂ (SpectralField n))).mpr + (by exact_mod_cast ne_of_gt sin_three_lambda_pos) + +lemma torusWeights_one (n : ℕ) : torusWeights (1:SpectralField n)=identityWeights := by + have hd := torusL_one_ne_zero n + have hq:=constF_phase_ne_zero n + unfold torusWeights + simp only [div_one,torusSin_one,zero_mul,mul_zero,zero_div,torusSin_phase_pow,Nat.cast_ofNat, + sin_two_lambda_eq_d,torusL_one] + have hn:=torusL_one n + rw [hn] at hd + simp only [mul_comm (constF n (Real.sin (3*lambda))),div_self hd] + rfl + +lemma torusWeights_phase_three (n : ℕ) : + torusWeights (constF n phase^3)=deletionWeights := by + have hd : constF n d*constF n (Real.sin (3*lambda))≠0 := by + simpa only [torusL_one] using torusL_one_ne_zero n + have hq:=constF_phase_ne_zero n + have he : constF n phase^3/constF n phase=constF n phase^2 := by field_simp + unfold torusWeights + simp only [div_self (pow_ne_zero 3 hq),torusSin_one,mul_zero,zero_mul,zero_div,he, + torusSin_phase_pow,Nat.cast_ofNat,sin_two_lambda_eq_d,torusL_phase_three,div_self hd] + rfl + + + + + + + + +open Finset +open scoped Classical + + +def vacantBottomExtension {M : Type*} [Zero M] {n : ℕ} + (v : Pairing n → M) (p : Pairing (n+1)) : M := + if p.Occupied 0 then 0 else v (p.restrict (Fin.succOrderEmb n)) + +@[simp] theorem vacantBottomExtension_padBottom {M : Type*} [Zero M] {n : ℕ} + (v : Pairing n → M) (p : Pairing n) : vacantBottomExtension v p.padBottom = v p := by + simp only [vacantBottomExtension, Pairing.padBottom_not_occupied_zero, ite_false] + simp [Pairing.padBottom, Pairing.restrict_map] + +theorem Pairing.padBottom_injective {n : ℕ} : Function.Injective (@Pairing.padBottom n) := by + intro p q h + have := congrArg (fun r => r.restrict (Fin.succOrderEmb n)) h + simpa [Pairing.padBottom, Pairing.restrict_map] using this + + +theorem Pairing.padBottom_padTop {n : ℕ} (p : Pairing n) : + p.padBottom.padTop = p.padTop.padBottom := by + apply Subtype.ext + simp only [Pairing.padTop, Pairing.padBottom, Pairing.map, Finset.map_map] + congr 1 + + +theorem rawColumn_padBottom {K : Type*} [CommRing K] {n : ℕ} + (w : Fin n → Tile → K) (r : Tile → K) (p q : Pairing n) : + rawColumn (Fin.cons r w) q.padBottom p.padBottom = r .vacant * rawColumn w q p := by + classical + unfold rawColumn + rw [← Fintype.sum_equiv (Fin.consEquiv (fun _ : Fin (n+1) => Tile)) + (fun tt : Tile × Configuration n => + if Realizes p.padBottom q.padBottom (Fin.cons tt.1 tt.2) + then ∏ i : Fin (n+1), ((Fin.cons r w : Fin (n+1) → Tile → K) i) + ((Fin.cons tt.1 tt.2 : Configuration (n+1)) i) else 0) + _ (fun _ => rfl)] + rw [Fintype.sum_prod_type] + simp only [realizes_cons_bottom_iff] + rw [Finset.sum_eq_single Tile.vacant] + · simp only [true_and, Finset.mul_sum] + apply Finset.sum_congr rfl + intro t _ + split_ifs <;> simp [Fin.prod_univ_succ] + · intro a ha hav + simp [hav] + · simp + + +def firstZeroRaw {K : Type*} [CommRing K] {n : ℕ} + (w : Fin n → Tile → K) (v : Pairing n → K) : Pairing (n+1) → K := + (rawColumn (Fin.cons (deletionWeights : Weights K).tile w)).mulVec + (vacantBottomExtension v) + +theorem mulVec_vacantBottomExtension {K : Type*} [CommRing K] {n : ℕ} + (A : Matrix (Pairing (n+1)) (Pairing (n+1)) K) (v : Pairing n → K) + (q : Pairing (n+1)) : + A.mulVec (vacantBottomExtension v) q = ∑ p, A q p.padBottom * v p := by + classical + simp only [Matrix.mulVec, dotProduct] + symm + apply Fintype.sum_of_injective Pairing.padBottom Pairing.padBottom_injective + · intro p hp + have h : p.Occupied 0 := by + by_contra h + exact hp ⟨p.restrict (Fin.succOrderEmb n), p.padBottom_restrict h⟩ + simp [vacantBottomExtension, h] + · intro p; simp + + +theorem firstZeroRaw_vacant {K : Type*} [CommRing K] {n : ℕ} + (w : Fin n → Tile → K) (v : Pairing n → K) (q : Pairing n) : + firstZeroRaw w v q.padBottom = (rawColumn w).mulVec v q := by + rw [firstZeroRaw, mulVec_vacantBottomExtension] + simp only [rawColumn_padBottom, Weights.tile, deletionWeights, one_mul, Matrix.mulVec, dotProduct] + + +theorem deletion_column_mulVec {K : Type*} [CommRing K] {n : ℕ} + (w : Fin n → Weights K) (v : Pairing (n+1) → K) : + (column (Fin.cons deletionWeights w)).mulVec v = + firstZeroRaw (fun i => (w i).tile) (fun p => v p.padBottom) := by + classical + funext q + rw [firstZeroRaw, mulVec_vacantBottomExtension] + simp only [Matrix.mulVec, dotProduct] + symm + apply Fintype.sum_of_injective Pairing.padBottom Pairing.padBottom_injective + · intro p hp + have h : p.Occupied 0 := by + by_contra h + exact hp ⟨p.restrict (Fin.succOrderEmb n), p.padBottom_restrict h⟩ + rw [column_deletion_bottom_col _ rfl _ _ h, zero_mul] + · intro p + congr 1 + change rawColumn _ q p.padBottom = rawColumn _ q p.padBottom + congr 3 + funext i + exact Fin.cases rfl (fun _ => rfl) i + + + +theorem normalizedVacuum_firstZero {K : Type*} [Field K] {n : ℕ} + (w : Fin n → Weights K) (hw : VacuumRegular w) : + normalizedVacuum (Fin.cons deletionWeights w) = + firstZeroRaw (fun i => (w i).tile) (normalizedVacuum w) := by + have hs := normalizedVacuum_stationary w hw + have hr : VacuumRegular (Fin.cons deletionWeights w) := by + unfold VacuumRegular + rw [det_flat_bottom _ (Or.inr rfl)] + exact hw + symm + apply normalizedVacuum_unique _ hr + constructor + · rw [← Pairing.padBottom_empty, firstZeroRaw_vacant] + change (column w).mulVec (normalizedVacuum w) (empty n) = 1 + rw [hs.2, hs.1] + · rw [deletion_column_mulVec] + congr 1 + funext p + rw [firstZeroRaw_vacant] + exact congrFun hs.2 p + + +theorem lastValue_vacantBottomExtension {K L : Type*} [CommRing K] [CommRing L] + (f : K →+* L) {n : ℕ} (b s : L) (P : Pairing (n+1) → Polynomial K) : + lastValue f b s (vacantBottomExtension P) = + vacantBottomExtension (lastValue f b s P) := by + funext p + by_cases hp : p.Occupied 0 + · simp [lastValue, vacantBottomExtension, hp] + · rw [← p.padBottom_restrict hp] + simp only [vacantBottomExtension_padBottom, lastValue, + ← Fin.succ_last, Pairing.padBottom_occupied_succ] + + + +theorem LastDegree.vacantBottomExtension {K : Type*} [CommRing K] {n m : ℕ} + {P : Pairing (n+1) → Polynomial K} (hP : LastDegree m P) : + LastDegree m (vacantBottomExtension P) := by + intro p k hk + by_cases hp : p.Occupied 0 + · simp [CriticalStrip.Diagram.vacantBottomExtension, hp] + · rw [← p.padBottom_restrict hp] at hk ⊢ + rw [vacantBottomExtension_padBottom] + apply hP + simpa only [← Fin.succ_last, Pairing.padBottom_occupied_succ] using hk + + + +theorem vacantBottomExtension_leading {K : Type*} [CommRing K] {n : ℕ} + (P : Pairing (n+1) → Polynomial K) (m : ℕ) : + (fun p : Pairing (n+1) => (vacantBottomExtension P p.padTop).coeff m) = + vacantBottomExtension (fun p : Pairing n => (P p.padTop).coeff m) := by + funext p + by_cases hp : p.Occupied 0 + · have hp' : p.padTop.Occupied 0 := by + simpa using (Pairing.padTop_occupied_castSucc p 0).mpr hp + simp [vacantBottomExtension, hp, hp'] + · rw [← p.padBottom_restrict hp, Pairing.padBottom_padTop] + simp + + +def firstZeroPolynomial {K : Type*} [CommRing K] {n : ℕ} + (w : Fin n → Tile → K) (d c C : K) + (P : Pairing (n+1) → Polynomial K) : Pairing (n+2) → Polynomial K := + lastTransform (Fin.cons (deletionWeights : Weights K).tile w) d c C + (vacantBottomExtension P) + +theorem firstZeroPolynomial_degree {K : Type*} [CommRing K] {n m : ℕ} + (w : Fin n → Tile → K) (d c C : K) + (P : Pairing (n+1) → Polynomial K) (hP : LastDegree m P) : + LastDegree (m+1) (firstZeroPolynomial w d c C P) := + lastTransform_degree _ _ _ _ _ hP.vacantBottomExtension + +theorem firstZeroPolynomial_leading {K : Type*} [CommRing K] {n m : ℕ} + (w : Fin n → Tile → K) (d c C : K) + (P : Pairing (n+1) → Polynomial K) (hP : LastDegree m P) (q : Pairing (n+1)) : + (firstZeroPolynomial w d c C P q.padTop).coeff (m+1) = + firstZeroRaw w (fun p => (P p.padTop).coeff m) q := by + rw [firstZeroPolynomial, lastTransform_leading _ _ _ _ _ hP.vacantBottomExtension, + vacantBottomExtension_leading] + rfl + +@[simp] theorem map_deletion_tile {K L : Type*} [CommRing K] [CommRing L] + (f : K →+* L) (t : Tile) : + f ((deletionWeights : Weights K).tile t) = (deletionWeights : Weights L).tile t := by + cases t <;> simp [deletionWeights, Weights.tile] + + + +theorem firstZeroPolynomial_evaluation {K L : Type*} [CommRing K] [CommRing L] + (f : K →+* L) {n : ℕ} (w : Fin n → Tile → K) (d c C : K) + (b s t : L) (r : Tile → L) (P : Pairing (n+1) → Polynomial K) + (hv : r .vacant = b + f C) (hc : r .cap = 2 * f d * t) + (hu : r .vertical₀ = 2 * f d * s) (hb : r .diagonal₁ = b - f c) + (hst : 2 * s * t = b - f c) : + firstZeroRaw (Fin.snoc (fun i a => f (w i a)) r) (lastValue f b s P) = + lastValue f b s (firstZeroPolynomial w d c C P) := by + have h := rawColumn_lastValue f (Fin.cons (deletionWeights : Weights K).tile w) + d c C b s t r (vacantBottomExtension P) hv hc hu hb hst + rw [lastValue_vacantBottomExtension] at h + have hmap : (fun (i : Fin (n+1)) (a : Tile) => + f ((Fin.cons (deletionWeights : Weights K).tile w : Fin (n+1) → Tile → K) i a)) = + Fin.cons (deletionWeights : Weights L).tile (fun i a => f (w i a)) := by + funext i a + refine Fin.cases ?_ (fun j => ?_) i + · cases a <;> simp only [Fin.cons_zero, deletionWeights, Weights.tile, map_zero, map_one] + · rfl + rw [hmap, ← Fin.cons_snoc_eq_snoc_cons] at h + exact h + +end + + + + + +noncomputable section +open Finset + +theorem firstZeroRaw_rowScale {K : Type*} [CommRing K] {n : ℕ} + (a : Fin n → K) (w : Fin n → Tile → K) (v : Pairing n → K) : + firstZeroRaw (fun i t => a i * w i t) v = + (∏ i, a i) • firstZeroRaw w v := by + have h : Fin.cons (deletionWeights : Weights K).tile (fun i t => a i * w i t) = + (fun (i : Fin (n+1)) t => (Fin.cons 1 a : Fin (n+1) → K) i * + (Fin.cons (deletionWeights : Weights K).tile w : Fin (n+1) → Tile → K) i t) := by + funext i t + refine Fin.cases ?_ (fun j => ?_) i + · simp + · rfl + rw [firstZeroRaw, h, rawColumn_scale] + simp [Fin.prod_univ_succ, firstZeroRaw, Matrix.smul_mulVec] + + + +theorem firstZeroPolynomial_spectral {n k : ℕ} + (w : Fin n → Tile → SpectralField k) (i : Fin k) + (P : Pairing (n+1) → Polynomial (SpectralField k)) : + firstZeroRaw (Fin.snoc w (clearedSpectralRow i)) + (lastValue (RingHom.id _) (spectralA i) (torusSin (variableF i)) P) = + lastValue (RingHom.id _) (spectralA i) (torusSin (variableF i)) + (firstZeroPolynomial w (constF k d) (constF k c) (constF k C) P) := by + apply firstZeroPolynomial_evaluation (RingHom.id _) w (constF k d) (constF k c) + (constF k C) (spectralA i) (torusSin (variableF i)) + (torusSin (constF k phase ^ 3 / variableF i)) (clearedSpectralRow i) P + · exact clearedSpectralRow_vacant i + · exact clearedSpectralRow_cap i + · exact clearedSpectralRow_vertical₀ i + · exact clearedSpectralRow_diagonal₁ i + · exact spectral_sine_pair i + +end +end CriticalStrip.Diagram + +end OAI diff --git a/lean/OAI/Combinatorics/StripMass/ScalarMergeTrig.lean b/lean/OAI/Combinatorics/StripMass/ScalarMergeTrig.lean new file mode 100644 index 0000000000000000000000000000000000000000..cc66eb6d7e9061ad57ad5136da3debfd51d19f27 --- /dev/null +++ b/lean/OAI/Combinatorics/StripMass/ScalarMergeTrig.lean @@ -0,0 +1,529 @@ +import Mathlib +import OAI.Combinatorics.StripMass.ScalarDeleteContinuation + +namespace OAI + +/-! Critical honeycomb strip paths, polynomial identities and crossing mass. -/ + + + +namespace CriticalStrip.Diagram +noncomputable section + +abbrev fcos {n:ℕ} (i:Fin n) (k:ℤ) := shiftedCosine i (phase^k) + +lemma fcos_eq {n:ℕ} (i:Fin n) (k:ℤ) : fcos i k= + torusCos (constF n (phase^k)*variableF i^2) := + shiftedCosine_eq _ _ (zpow_ne_zero _ phase_ne_zero) + +lemma fcos_shift {n:ℕ} (i:Fin n) (k l:ℤ) : + fcos i (k+l)=torusCos ((constF n (phase^k)*variableF i^2)*constF n (phase^l)) := by + rw [fcos_eq,zpow_add₀ phase_ne_zero] + simp only [constF,map_mul] + congr 1; ring + +lemma fcos_eight {n:ℕ} (i:Fin n) (k:ℤ) : fcos i (k+8)= - fcos i k := by + rw [fcos_shift] + simp only [zpow_ofNat,phase_eight,constF,map_neg,map_one,mul_neg,mul_one,torusCos_neg] + rw [fcos_eq] + rfl + +lemma fcos_sub_eight {n:ℕ} (i:Fin n) (k:ℤ) : fcos i (k-8)= - fcos i k := by + have h:=fcos_eight i (k-8) + rw [sub_add_cancel] at h + linear_combination h + +lemma constF_d_sq (n:ℕ) : (constF n d)^2=(1/2:SpectralField n) := by + have h:=congrArg (fun x:ℝ =>constF n (x:ℂ)) d_sq + simpa only [Complex.ofReal_pow,Complex.ofReal_div,Complex.ofReal_one,Complex.ofReal_ofNat, + constF,map_pow,map_div₀,map_one,map_ofNat] using h + +lemma fcos_sum_product {n:ℕ} (i:Fin n) (k:ℤ) : + fcos i (k-2)+fcos i (k+2)=2*constF n d*fcos i k ∧ + fcos i (k-2)*fcos i (k+2)=(fcos i k)^2-(constF n d)^2 := by + let z:=constF n (phase^k)*variableF i^2 + let w:=constF n phase^2 + have hz:z≠0:=mul_ne_zero (by simpa [constF] using (algebraMap ℂ (SpectralField n)).injective.ne (zpow_ne_zero k phase_ne_zero)) (pow_ne_zero _ (variableF_ne_zero i)) + have hw:w≠0:=pow_ne_zero _ (constF_phase_ne_zero n) + have he₁:fcos i (k-2)=torusCos (z/w) := by + rw [fcos_eq,zpow_sub₀ phase_ne_zero] + simp only [zpow_ofNat,constF,map_div₀,map_pow] + congr 1; dsimp [z,w,constF]; ring + have he₂:fcos i (k+2)=torusCos (z*w) := by + rw [fcos_shift]; simp [z,w,constF] + have he₀:fcos i k=torusCos z:=shiftedCosine_eq _ _ (zpow_ne_zero _ phase_ne_zero) + have hew:torusCos w=constF n d:=torusCos_phase_pow n 2 + rw [he₁,he₂,he₀,torusCos_sum z w hz hw,torusCos_product z w hz hw,hew] + constructor + · ring + · linear_combination 2*constF_d_sq n + +lemma fcos_six_ne {n:ℕ} (i:Fin n) (k:ℤ) : fcos i k≠fcos i (k+6) := by + intro h + have hh:=shiftedCosine_parameter i _ _ h + rw [zpow_add₀ phase_ne_zero] at hh + have he:phase^(6:ℤ)=1 := (mul_left_cancel₀ (zpow_ne_zero k phase_ne_zero) (by simpa using hh.symm)) + exact phase_six_ne_one (by simpa using he) + +lemma fcos_ne_const {n:ℕ} (i:Fin n) (k:ℤ) (z:ℂ) : fcos i k≠constF n z := by + intro h + have he:(2:ℤ) • variableExponent i≠0 := by + intro h; have hh:=congrFun h i; simp [variableExponent] at hh + have hl:cosineL ((2:ℤ) • variableExponent i) (phase^k)=constantL n z := + IsFractionRing.injective (SpectralRing n) (SpectralField n) h + change cosineL ((2:ℤ) • variableExponent i) (phase^k)=monomialL 0 z at hl + have hc:=congrArg (fun P:Laurent n =>P.coeff ((2:ℤ) • variableExponent i)) hl + simp only [cosineL,monomialL,AddMonoidAlgebra.coeff_add, + AddMonoidAlgebra.coeff_single,Finsupp.add_apply,Finsupp.single_apply] at hc + simp only [ite_eq_right (twice_variableExponent_ne_neg i i).symm, + ite_eq_right he.symm,add_zero] at hc + exact (zpow_ne_zero k phase_ne_zero) ((div_eq_zero_iff).mp hc |>.resolve_right (by norm_num)) + +lemma scalar_merge_flat_constants : + 2*(d:ℂ)*(C:ℂ)=(c:ℂ)+(C:ℂ) ∧ (C:ℂ)^2-(d:ℂ)^2=(c:ℂ)*(C:ℂ) := by + have hd:(d:ℂ)^2=1/2:=by + have h:=congrArg (fun x:ℝ =>(x:ℂ)) d_sq + push_cast at h + exact h + have hl:=flat_scalar_linear + have hc:=flat_scalar_constant + constructor + · linear_combination (1-2*(d:ℂ))*hl+4*(c:ℂ)*hd + · linear_combination -((C:ℂ)-(c:ℂ)+2*(d:ℂ)*(c:ℂ))*hl+4*(c:ℂ)^2*hd+hc + +lemma fcos_flat_factor {n:ℕ} (i:Fin n) (k:ℤ) : + (constF n C+fcos i (k-2))*(constF n C+fcos i (k+2))= + (constF n c+fcos i k)*(constF n C+fcos i k) := by + obtain ⟨hs,hp⟩:=fcos_sum_product i k + obtain ⟨hl,hc⟩:=scalar_merge_flat_constants + have hl':=congrArg (constF n) hl + have hc':=congrArg (constF n) hc + simp only [constF,map_mul,map_ofNat,map_add,map_sub,map_pow] at hl' hc' + dsimp only [constF] at hs hp ⊢ + linear_combination (algebraMap ℂ (SpectralField n)) (C:ℂ)*hs+hp+fcos i k*hl'+hc' + + +lemma scalar_merge_delete_factor_algebra {K:Type*} [Field K] [CharZero K] + (dd t x y g h:K) (hd:dd^2=1/2) + (hs:x+y=2*dd*t) (hp:x*y=t^2-dd^2) + (hg:g^2+h^2+2*dd*g*h-dd^2=0) : + (x-(-2*dd*g-h))*(x-(-2*dd*h-g))*(y-(-2*dd*g-h))*(y-(-2*dd*h-g))= + (t+g)*(t+h)*(t-(-2*dd*g-h))*(t-(-2*dd*h-g)) := by + have he: (x-(-2*dd*g-h))*(x-(-2*dd*h-g))*(y-(-2*dd*g-h))*(y-(-2*dd*h-g))= + (x*y-(-2*dd*g-h)*(x+y)+(-2*dd*g-h)^2)* + (x*y-(-2*dd*h-g)*(x+y)+(-2*dd*h-g)^2) := by ring + rw [he,hs,hp] + grind + +lemma fcos_sixteen {n:ℕ} (i:Fin n) (k:ℤ) : fcos i (k+16)=fcos i k := by + rw [show k+16=(k+8)+8 by ring,fcos_eight,fcos_eight,neg_neg] + +lemma fcos_roots {n:ℕ} (i:Fin n) (k:ℤ) (z:SpectralField n) : + discriminant (constF n d) (fcos i k) z=(z-fcos i (k-6))*(z-fcos i (k+6)) := + shiftedCosine_roots i k z + +lemma roots_sum {K:Type*} [Field K] (dd x y z:K) + (h:∀t,discriminant dd x t=(t-y)*(t-z)) : y+z= -2*dd*x := by + have h0:=h 0 + have h1:=h 1 + simp only [discriminant] at h0 h1 + linear_combination h1-h0 + +lemma fcos_delete_factor {n:ℕ} (i j:Fin n) (k l:ℤ) : + (fcos i (k-2)-fcos j (l-6))*(fcos i (k-2)-fcos j (l+12))* + (fcos i (k+2)-fcos j (l-6))*(fcos i (k+2)-fcos j (l+12))= + (fcos i k+fcos j l)*(fcos i k+fcos j (l+6))* + (fcos i k-fcos j (l-6))*(fcos i k-fcos j (l+12)) := by + have hs:=roots_sum (constF n d) (fcos j l) (fcos j (l-6)) (fcos j (l+6)) (fcos_roots j l) + have ht:=roots_sum (constF n d) (fcos j (l+6)) (fcos j l) (fcos j (l+12)) (by + intro z; simpa only [add_sub_cancel_right, show l+6+6=l+12 by omega] using fcos_roots j (l+6) z) + have hγ:fcos j (l-6)= -2*constF n d*fcos j l-fcos j (l+6) := by linear_combination hs + have hσ:fcos j (l+12)= -2*constF n d*fcos j (l+6)-fcos j l := by linear_combination ht + rw [hγ,hσ] + have hd:=fcos_roots j l (fcos j (l+6)) + simp only [sub_self,mul_zero,discriminant] at hd + exact scalar_merge_delete_factor_algebra _ _ _ _ _ _ (constF_d_sq n) + (fcos_sum_product i k).1 (fcos_sum_product i k).2 hd + + + + + + +open scoped Classical + +lemma scalarValue_fcos_delete {m n:ℕ} (i:Fin m) (k:ℤ) (a:Fin n → SpectralField m) : + scalarValue (algebraMap ℂ (SpectralField m)) (Fin.cons (fcos i k) (Fin.cons (fcos i (k+6)) a))= + (fcos i k+fcos i (k+6)+constF m rho)* + (∏j,(a j-fcos i (k-6))*(a j-fcos i (k+12)))* + scalarValue (algebraMap ℂ (SpectralField m)) a := by + apply scalarValue_delete _ _ _ _ _ (fcos_six_ne i k) + · intro z + change discriminant (constF m d) (fcos i k) z=_ + rw [fcos_roots,mul_comm] + · intro z; simpa only [constF,add_sub_cancel_right,show k+6+6=k+12 by omega] using fcos_roots i (k+6) z + +lemma scalarMergeDiff_eval_neg {m n:ℕ} (i:Fin m) (k:ℤ) (a:Fin n → SpectralField m) : + (scalarMergeDiff (algebraMap ℂ (SpectralField m)) (fcos i (k-2)) (fcos i (k+2)) (fcos i k) a).eval (-fcos i k)=0 := by + rw [scalarMergeDiff_eval,neg_add_cancel,mul_zero,zero_mul,sub_zero] + rw [←fcos_sub_eight] + have hh:=scalarValue_fcos_delete i (k-8) (Fin.cons (fcos i (k+2)) a) + have hp:fcos i (k-8-6)=fcos i (k+2) := by + rw [←fcos_sixteen i (k-8-6)] + congr 1; omega + simp only [show k-8+6=k-2 by omega,hp,Fin.prod_univ_succ,Fin.cons_zero, + Fin.cons_succ,sub_self,zero_mul,mul_zero] at hh + exact hh + +lemma scalarMergeDiff_eval_flat {m n:ℕ} (i:Fin m) (k:ℤ) (a:Fin n → SpectralField m) + (h:scalarValue (algebraMap ℂ (SpectralField m)) (Fin.cons (fcos i (k-2)) (Fin.cons (fcos i (k+2)) a))= + (fcos i (k-2)+fcos i (k+2)+constF m rho)*(∏j,(a j+fcos i k))* + scalarValue (algebraMap ℂ (SpectralField m)) (Fin.cons (fcos i k) a)) : + (scalarMergeDiff (algebraMap ℂ (SpectralField m)) (fcos i (k-2)) (fcos i (k+2)) (fcos i k) a).eval (constF m c)=0 := by + rw [scalarMergeDiff_eval] + simp only [constF] at h ⊢ + rw [scalarValue_flat,scalarValue_flat,h] + simp only [Fin.prod_univ_succ,Fin.cons_zero,Fin.cons_succ] + have he:=fcos_flat_factor i k + change (constF m C+fcos i (k-2))*(constF m C+fcos i (k+2))=_ at he + have hring: + (fcos i (k-2) + (algebraMap ℂ (SpectralField m)) (C:ℂ)) * + ((fcos i (k+2) + (algebraMap ℂ (SpectralField m)) (C:ℂ)) * (∏j,(a j+(algebraMap ℂ (SpectralField m)) (C:ℂ))))= + (constF m c+fcos i k)*(fcos i k+constF m C)*(∏j,(a j+constF m C)) := by + calc + _ = ((constF m C+fcos i (k-2))*(constF m C+fcos i (k+2)))*(∏j,(a j+constF m C)) := by dsimp only [constF]; ring + _ = _ := by rw [he]; ring + rw [hring] + dsimp only [constF] + ring + +lemma scalarMergeDiff_eval_deletion {m n:ℕ} (i:Fin m) (k:ℤ) + (a:Fin (n+1) → SpectralField m) (j:Fin (n+1)) (g:Fin m) (l:ℤ) + (ha:a j=fcos g l) + (h:scalarValue (algebraMap ℂ (SpectralField m)) + (Fin.cons (fcos i (k-2)) (Fin.cons (fcos i (k+2)) (fun v =>a (j.succAbove v))))= + (fcos i (k-2)+fcos i (k+2)+constF m rho)*(∏v,(a (j.succAbove v)+fcos i k))* + scalarValue (algebraMap ℂ (SpectralField m)) (Fin.cons (fcos i k) (fun v =>a (j.succAbove v)))) : + (scalarMergeDiff (algebraMap ℂ (SpectralField m)) (fcos i (k-2)) (fcos i (k+2)) (fcos i k) a).eval (fcos g (l+6))=0 := by + rw [scalarMergeDiff_eval,scalarValue_two_middle_extract _ _ _ _ a j, + scalarValue_one_middle_extract _ _ _ a j,ha, + scalarValue_swap_head _ (fcos g (l+6)) (fcos g l), + scalarValue_swap_head _ (fcos g (l+6)) (fcos g l), + scalarValue_fcos_delete,scalarValue_fcos_delete,h] + rw [Fin.prod_univ_succAbove (fun v =>a v+fcos i k) j,ha] + simp only [Fin.prod_univ_succ,Fin.cons_zero,Fin.cons_succ] + have he:=fcos_delete_factor i g k l + + have hp: + (fcos i (k-2)-fcos g (l-6))*(fcos i (k-2)-fcos g (l+12))* + ((fcos i (k+2)-fcos g (l-6))*(fcos i (k+2)-fcos g (l+12))* + (∏v,(a (j.succAbove v)-fcos g (l-6))*(a (j.succAbove v)-fcos g (l+12))))= + ((fcos i k+fcos g l)*(fcos i k+fcos g (l+6))* + (fcos i k-fcos g (l-6))*(fcos i k-fcos g (l+12)))* + (∏v,(a (j.succAbove v)-fcos g (l-6))*(a (j.succAbove v)-fcos g (l+12))) := by + rw [←he]; ring + rw [hp] + dsimp only [constF] + ring + +end + + + + + +noncomputable section + +lemma fcos_tuple_injective {m n:ℕ} (j:Fin n → Fin m) (hj:Function.Injective j) (l:Fin n → ℤ) : + Function.Injective (fun v => fcos (j v) (l v)) := by + intro v w h + by_contra hvw + exact shiftedCosine_ne (j v) (j w) (hj.ne hvw) _ _ (zpow_ne_zero _ phase_ne_zero) h + +lemma scalarMerge_nodes_injective {m n:ℕ} (i:Fin m) (k:ℤ) + (j:Fin n → Fin m) (hj:Function.Injective j) (hi:∀v,j v≠i) (l:Fin n → ℤ) : + Function.Injective (Fin.cons (constF m c) (Fin.cons (fcos i (k+8)) (fun v =>fcos (j v) (l v+6)))) := by + apply Fin.cons_injective_of_injective + · rintro ⟨v,hv⟩ + induction v using Fin.cases with + | zero => exact fcos_ne_const i (k+8) c hv + | succ v => exact fcos_ne_const (j v) (l v+6) c hv + · apply Fin.cons_injective_of_injective + · rintro ⟨v,hv⟩ + exact shiftedCosine_ne (j v) i (hi v) _ _ (zpow_ne_zero _ phase_ne_zero) hv + · exact fcos_tuple_injective j hj (fun v =>l v+6) + + + + + + +open scoped Classical + +lemma scalarValue_rotate3 {K:Type*} [CommRing K] (f:ℂ →+* K) {n:ℕ} + (x y z:K) (a:Fin n → K) : + scalarValue f (Fin.cons x (Fin.cons y (Fin.cons z a)))= + scalarValue f (Fin.cons z (Fin.cons x (Fin.cons y a))) := by + rw [scalarValue_cons_extract f x (Fin.cons y (Fin.cons z a)) (1:Fin (n+2))] + have hv:(fun j:Fin (n+1) =>(Fin.cons y (Fin.cons z a):Fin (n+2) → K) ((1:Fin (n+2)).succAbove j))=Fin.cons y a := by + funext j + induction j using Fin.cases with + | zero => rfl + | succ j => simp [Fin.succAbove,Fin.lt_def] + rw [hv] + simpa only [show (1:Fin (n+2))=(0:Fin (n+1)).succ from rfl,Fin.cons_succ,Fin.cons_zero] using scalarValue_swap_head f x z (Fin.cons y a) + + +lemma scalarValue_fcos_merge {m r:ℕ} (i:Fin m) (k:ℤ) + (s:Fin r → Fin m) (hs:Function.Injective s) (hi:∀j,s j≠i) (l:Fin r → ℤ) : + scalarValue (algebraMap ℂ (SpectralField m)) + (Fin.cons (fcos i (k-2)) (Fin.cons (fcos i (k+2)) (fun j =>fcos (s j) (l j))))= + (fcos i (k-2)+fcos i (k+2)+constF m rho)* + (∏j,(fcos (s j) (l j)+fcos i k))* + scalarValue (algebraMap ℂ (SpectralField m)) (Fin.cons (fcos i k) (fun j =>fcos (s j) (l j))) := by + induction r using Nat.strong_induction_on with + | h r ih => + cases r with + | zero => + have he:(Fin.cons (fcos i (k+2)) (fun j:Fin 0 =>fcos (s j) (l j)):Fin 1 → SpectralField m)=fun _ =>fcos i (k+2) := by ext j; fin_cases j; rfl + have ht:(Fin.cons (fcos i k) (fun j:Fin 0 =>fcos (s j) (l j)):Fin 1 → SpectralField m)=fun _ =>fcos i k := by ext j; fin_cases j; rfl + rw [he,ht,scalarValue_two,scalarValue_one] + simp [constF] + | succ n => + let a:Fin n → SpectralField m:=fun j =>fcos (s j.succ) (l j.succ) + have htail:=ih n (by omega) (fun j =>s j.succ) (hs.comp (Fin.succ_injective _)) (fun j =>hi j.succ) (fun j =>l j.succ) + change scalarValue _ (Fin.cons (fcos i (k-2)) (Fin.cons (fcos i (k+2)) a))=_ at htail + let P:=scalarMergeDiff (algebraMap ℂ (SpectralField m)) (fcos i (k-2)) (fcos i (k+2)) (fcos i k) a + have hd:P.natDegree≤n+1:=scalarMergeDiff_degree_reduced _ _ _ _ a htail + let roots:Fin (n+2) → SpectralField m:=Fin.cons (constF m c) (Fin.cons (fcos i (k+8)) (fun j =>fcos (s j.succ) (l j.succ+6))) + have hinj:Function.Injective roots:=scalarMerge_nodes_injective i k _ (hs.comp (Fin.succ_injective _)) (fun j =>hi j.succ) _ + have hr:∀j,P.eval (roots j)=0 := by + intro j + induction j using Fin.cases with + | zero => exact scalarMergeDiff_eval_flat i k a htail + | succ j => + induction j using Fin.cases with + | zero => simpa only [roots,Fin.cons_succ,Fin.cons_zero,fcos_eight] using scalarMergeDiff_eval_neg i k a + | succ j => + cases n with + | zero => exact Fin.elim0 j + | succ v => + have hdel:=ih v (by omega) (fun t =>s (j.succAbove t).succ) + (hs.comp ((Fin.succ_injective _).comp (Fin.succAbove_right_injective))) + (fun t =>hi (j.succAbove t).succ) (fun t =>l (j.succAbove t).succ) + exact scalarMergeDiff_eval_deletion i k a j (s j.succ) (l j.succ) rfl hdel + have hp:P=0:=Polynomial.eq_zero_of_natDegree_lt_card_of_eval_eq_zero P hinj hr (by simp only [Fintype.card_fin]; omega) + have he:=congrArg (fun Q:Polynomial (SpectralField m) =>Q.eval (fcos (s 0) (l 0))) hp + simp only [Polynomial.eval_zero] at he + rw [scalarMergeDiff_eval] at he + have ha:(fun j =>fcos (s j) (l j))=Fin.cons (fcos (s 0) (l 0)) a:= by ext j; induction j using Fin.cases <;> rfl + rw [ha,scalarValue_rotate3,scalarValue_swap_head _ (fcos i k) (fcos (s 0) (l 0))] + simp only [Fin.prod_univ_succ] + dsimp only [constF] at * + linear_combination he + +end + + + + + +noncomputable section +open scoped Classical + +lemma rationalAt_scalarValue {m n r:ℕ} (φ:Laurent m →ₐ[ℂ] SpectralField n) + (a:Fin r → SpectralField m) (b:Fin r → SpectralField n) + (ha:∀j,RationalAt φ.toRingHom (a j) (b j)) : + RationalAt φ.toRingHom (scalarValue (algebraMap ℂ (SpectralField m)) a) + (scalarValue (algebraMap ℂ (SpectralField n)) b) := + RationalAt.mv_eval _ _ a b (rationalAt_const φ) ha _ + +lemma rationalAt_copy_fcos {m n:ℕ} (v:Fin m → Fin n) (i:Fin m) (k:ℤ) : + RationalAt (copyEvaluation v).toRingHom (fcos i k) (fcos (v i) k) := by + rw [fcos_eq,fcos_eq] + apply rationalAt_torusCos + · exact (rationalAt_const (copyEvaluation v) (phase^k)).mul ((rationalAt_copy_variable v i).pow 2) + · exact mul_ne_zero (by simpa [constF] using (algebraMap ℂ (SpectralField n)).injective.ne (zpow_ne_zero k phase_ne_zero)) (pow_ne_zero _ (variableF_ne_zero _)) + + + +theorem scalarValue_fcos_merge_all {m r:ℕ} (i:Fin m) (k:ℤ) + (s:Fin r → Fin m) (l:Fin r → ℤ) : + scalarValue (algebraMap ℂ (SpectralField m)) + (Fin.cons (fcos i (k-2)) (Fin.cons (fcos i (k+2)) (fun j =>fcos (s j) (l j))))= + (fcos i (k-2)+fcos i (k+2)+constF m rho)* + (∏j,(fcos (s j) (l j)+fcos i k))* + scalarValue (algebraMap ℂ (SpectralField m)) (Fin.cons (fcos i k) (fun j =>fcos (s j) (l j))) := by + let v:Fin (r+1) → Fin m:=Fin.cons i s + let φ:=copyEvaluation v + have h:=scalarValue_fcos_merge (0:Fin (r+1)) k Fin.succ (Fin.succ_injective _) (fun j =>Fin.succ_ne_zero j) l + have ht:RationalAt φ.toRingHom + (scalarValue (algebraMap ℂ (SpectralField (r+1))) (Fin.cons (fcos 0 (k-2)) (Fin.cons (fcos 0 (k+2)) (fun j =>fcos j.succ (l j))))) + (scalarValue (algebraMap ℂ (SpectralField m)) (Fin.cons (fcos i (k-2)) (Fin.cons (fcos i (k+2)) (fun j =>fcos (s j) (l j))))) := by + apply rationalAt_scalarValue + intro j + induction j using Fin.cases with + | zero => exact rationalAt_copy_fcos v 0 (k-2) + | succ j => induction j using Fin.cases with + | zero => exact rationalAt_copy_fcos v 0 (k+2) + | succ j => exact rationalAt_copy_fcos v j.succ (l j) + have hv:RationalAt φ.toRingHom + (scalarValue (algebraMap ℂ (SpectralField (r+1))) (Fin.cons (fcos 0 k) (fun j =>fcos j.succ (l j)))) + (scalarValue (algebraMap ℂ (SpectralField m)) (Fin.cons (fcos i k) (fun j =>fcos (s j) (l j)))) := by + apply rationalAt_scalarValue + intro j + induction j using Fin.cases with + | zero => exact rationalAt_copy_fcos v 0 k + | succ j => exact rationalAt_copy_fcos v j.succ (l j) + have hp:=RationalAt.prod Finset.univ + (fun j:Fin r =>fcos j.succ (l j)+fcos (0:Fin (r+1)) k) + (fun j:Fin r =>fcos (s j) (l j)+fcos i k) + (fun j _ => (rationalAt_copy_fcos v j.succ (l j)).add (rationalAt_copy_fcos v 0 k)) + have hq:=((rationalAt_copy_fcos v 0 (k-2)).add (rationalAt_copy_fcos v 0 (k+2))).add (rationalAt_const φ rho) + rw [h] at ht + exact ht.unique ((hq.mul hp).mul hv) + + + + + + + +lemma torusEvaluation_lift {n m:ℕ} (z:Fin n → SpectralField m) (hz:∀i,z i≠0) + (y:SpectralField m) (hy:y≠0) (P:Laurent n) : + torusEvaluation (Fin.snoc z y) (fun i =>Fin.lastCases (by simpa using hy) (fun j =>by simpa using hz j) i) + (liftLaurent P)=torusEvaluation z hz P := by + have he:(torusEvaluation (Fin.snoc z y) (fun i =>Fin.lastCases (by simpa using hy) (fun j =>by simpa using hz j) i)).toRingHom.comp (liftLaurentHom n)= + (torusEvaluation z hz).toRingHom := by + apply AddMonoidAlgebra.ringHom_ext <;> intro e + all_goals change torusEvaluation _ _ (liftLaurent (monomialL _ _))=torusEvaluation _ _ (monomialL _ _) + all_goals rw [liftLaurent_monomial] + all_goals simp only [torusEvaluation_monomial,Fin.prod_univ_castSucc,Fin.snoc_castSucc,Fin.snoc_last,zpow_zero,mul_one] + exact DFunLike.congr_fun he P + +lemma torusEvaluation_lastCosine {n m:ℕ} (z:Fin (n+1) → SpectralField m) (hz:∀i,z i≠0) : + torusEvaluation z hz (lastCosine n)=torusCos (z (Fin.last n)^2/constF m phase^3) := by + have h:=RationalAt.algebraMap (φ:=(torusEvaluation z hz).toRingHom) (F:=SpectralField (n+1)) (lastCosine n) + change RationalAt _ (evalLaurent (lastCosine n)) _ at h + rw [lastCosine_map] at h + apply h.unique + exact rationalAt_torusCos _ (((rationalAt_variable z hz (Fin.last n)).pow 2).div + ((rationalAt_const _ phase).pow 3) (pow_ne_zero _ (constF_phase_ne_zero m))) + (div_ne_zero (pow_ne_zero _ (hz _)) (pow_ne_zero _ (constF_phase_ne_zero m))) + +lemma torusEvaluation_lastSine {n m:ℕ} (z:Fin (n+1) → SpectralField m) (hz:∀i,z i≠0) : + torusEvaluation z hz (lastSine n)=torusSin (z (Fin.last n)) := by + have h:=RationalAt.algebraMap (φ:=(torusEvaluation z hz).toRingHom) (F:=SpectralField (n+1)) (lastSine n) + change RationalAt _ (evalLaurent (lastSine n)) _ at h + rw [evalLaurent_lastSine] at h + exact h.unique (rationalAt_torusSin _ (rationalAt_variable z hz (Fin.last n)) (hz _)) + +lemma torusEvaluation_lastLaurent {n m:ℕ} (z:Fin n → SpectralField m) (hz:∀i,z i≠0) + (y:SpectralField m) (hy:y≠0) (p:Pairing (n+1)) (P:Polynomial (Laurent n)) : + torusEvaluation (Fin.snoc z y) (fun i =>Fin.lastCases (by simpa using hy) (fun j =>by simpa using hz j) i) + (lastLaurent p P)= + (if p.Occupied (Fin.last n) then torusSin y else 1)* + (P.map (torusEvaluation z hz).toRingHom).eval (torusCos (y^2/constF m phase^3)) := by + unfold lastLaurent + rw [map_mul] + change _ * (torusEvaluation (Fin.snoc z y) (fun i =>Fin.lastCases (by simpa using hy) (fun j =>by simpa using hz j) i)).toRingHom (P.eval₂ _ _) = _ + rw [Polynomial.hom_eval₂] + have he:(torusEvaluation (Fin.snoc z y) (fun i =>Fin.lastCases (by simpa using hy) (fun j =>by simpa using hz j) i)).toRingHom.comp (liftLaurentHom n)=(torusEvaluation z hz).toRingHom := + RingHom.ext (torusEvaluation_lift z hz y hy) + change _ * P.eval₂ _ _=_ + rw [he] + change _ * P.eval₂ _ (torusEvaluation _ _ (lastCosine n))=_ + rw [torusEvaluation_lastCosine] + simp only [Fin.snoc_last,Polynomial.eval_map] + congr 1 + split_ifs + · simpa only [Fin.snoc_last] using torusEvaluation_lastSine (Fin.snoc z y) (fun i =>Fin.lastCases (by simpa using hy) (fun j =>by simpa using hz j) i) + · exact map_one _ + + + +lemma lastLaurent_regular_value {n m:ℕ} (P:Pairing (n+1) → Polynomial (Laurent n)) + (hP:∀p,evalLaurent (lastLaurent p (P p))=rationalVacuum (n+1) p) + (z:Fin n → SpectralField m) (hz:∀i,z i≠0) (y:SpectralField m) (hy:y≠0) + (hL:∀i,torusL (constF m phase^3/(Fin.snoc z y : Fin (n+1) → SpectralField m) i)≠0) + (hreg:VacuumRegular (fun i =>torusWeights (constF m phase^3/(Fin.snoc z y : Fin (n+1) → SpectralField m) i))) + (p:Pairing (n+1)) : + (if p.Occupied (Fin.last n) then torusSin y else 1)* + ((P p).map (torusEvaluation z hz).toRingHom).eval (torusCos (y^2/constF m phase^3))= + scalarValue (algebraMap ℂ (SpectralField m)) (fun i =>torusCos (((Fin.snoc z y : Fin (n+1) → SpectralField m) i)^2/constF m phase^3))* + normalizedVacuum (fun i =>torusWeights (constF m phase^3/(Fin.snoc z y : Fin (n+1) → SpectralField m) i)) p := by + let x:Fin (n+1) → SpectralField m:=Fin.snoc z y + have hx:∀i:Fin (n+1),x i≠0:=fun i =>Fin.lastCases (by simpa [x] using hy) (fun j =>by simpa [x] using hz j) i + let φ:=torusEvaluation x hx + have hv:=RationalAt.algebraMap (φ:=φ.toRingHom) (F:=SpectralField (n+1)) (lastLaurent p (P p)) + change RationalAt _ (evalLaurent (lastLaurent p (P p))) _ at hv + rw [hP p] at hv + have hs:RationalAt φ.toRingHom (spectralNormalization (n+1)) + (scalarValue (algebraMap ℂ (SpectralField m)) (fun i =>torusCos ((x i)^2/constF m phase^3))) := by + rw [←scalarPolynomial_eval_spectral] + apply rationalAt_scalarValue + intro i + exact rationalAt_torusCos φ (((rationalAt_variable x hx i).pow 2).div + ((rationalAt_const φ phase).pow 3) (pow_ne_zero _ (constF_phase_ne_zero m))) + (div_ne_zero (pow_ne_zero _ (hx i)) (pow_ne_zero _ (constF_phase_ne_zero m))) + have hw (i:Fin (n+1)) (t:Tile):RationalAt φ.toRingHom ((spectralWeights (n+1) i).tile t) + ((torusWeights (constF m phase^3/x i)).tile t) := by + apply rationalAt_torusWeights + · exact ((rationalAt_const φ phase).pow 3).div (rationalAt_variable x hx i) (hx i) + · exact div_ne_zero (pow_ne_zero _ (constF_phase_ne_zero m)) (hx i) + · exact hL i + have hn:=rationalAt_normalizedVacuum _ _ hw hreg p + have he:=hv.unique (hs.mul hn) + dsimp only [φ,x] at he + change torusEvaluation _ _ (lastLaurent p (P p))=_ at he + rw [torusEvaluation_lastLaurent z hz y hy] at he + exact he + + + + + + + +lemma rationalAt_torusVacuum {n m:ℕ} (z:Fin n → SpectralField m) (hz:∀i,z i≠0) + (hL:∀i,torusL (constF m phase^3/z i)≠0) + (hreg:VacuumRegular (fun i =>torusWeights (constF m phase^3/z i))) + (p:Pairing n) : + RationalAt (torusEvaluation z hz).toRingHom (rationalVacuum n p) + (scalarValue (algebraMap ℂ (SpectralField m)) (fun i =>torusCos ((z i)^2/constF m phase^3))* + normalizedVacuum (fun i =>torusWeights (constF m phase^3/z i)) p) := by + let φ:=torusEvaluation z hz + have hs:RationalAt φ.toRingHom (spectralNormalization n) + (scalarValue (algebraMap ℂ (SpectralField m)) (fun i =>torusCos ((z i)^2/constF m phase^3))) := by + rw [←scalarPolynomial_eval_spectral] + apply rationalAt_scalarValue + intro i + exact rationalAt_torusCos φ (((rationalAt_variable z hz i).pow 2).div + ((rationalAt_const φ phase).pow 3) (pow_ne_zero _ (constF_phase_ne_zero m))) + (div_ne_zero (pow_ne_zero _ (hz i)) (pow_ne_zero _ (constF_phase_ne_zero m))) + have hw (i:Fin n) (t:Tile):RationalAt φ.toRingHom ((spectralWeights n i).tile t) + ((torusWeights (constF m phase^3/z i)).tile t) := by + apply rationalAt_torusWeights + · exact ((rationalAt_const φ phase).pow 3).div (rationalAt_variable z hz i) (hz i) + · exact div_ne_zero (pow_ne_zero _ (constF_phase_ne_zero m)) (hz i) + · exact hL i + exact hs.mul (rationalAt_normalizedVacuum _ _ hw hreg p) + +lemma torusEvaluation_vacuum {n m:ℕ} (W:Pairing n → Laurent n) + (hW:∀p,evalLaurent (W p)=rationalVacuum n p) + (z:Fin n → SpectralField m) (hz:∀i,z i≠0) + (hL:∀i,torusL (constF m phase^3/z i)≠0) + (hreg:VacuumRegular (fun i =>torusWeights (constF m phase^3/z i))) + (p:Pairing n) : + torusEvaluation z hz (W p)= + scalarValue (algebraMap ℂ (SpectralField m)) (fun i =>torusCos ((z i)^2/constF m phase^3))* + normalizedVacuum (fun i =>torusWeights (constF m phase^3/z i)) p := by + have h:=RationalAt.algebraMap (φ:=(torusEvaluation z hz).toRingHom) (F:=SpectralField n) (W p) + change RationalAt _ (evalLaurent (W p)) _ at h + rw [hW] at h + exact h.unique (rationalAt_torusVacuum z hz hL hreg p) + +end +end CriticalStrip.Diagram + +end OAI diff --git a/lean/OAI/Combinatorics/StripMass/SchurIdentity.lean b/lean/OAI/Combinatorics/StripMass/SchurIdentity.lean new file mode 100644 index 0000000000000000000000000000000000000000..b9dae662995b98fd19c8159e9ff1e50122e110e1 --- /dev/null +++ b/lean/OAI/Combinatorics/StripMass/SchurIdentity.lean @@ -0,0 +1,442 @@ +import Mathlib +import OAI.Combinatorics.StripMass.InverseIntegrability + +namespace OAI + +/-! Critical honeycomb strip paths, polynomial identities and crossing mass. -/ + + +namespace StripPfaffian +noncomputable section +open scoped BigOperators +theorem pfaffian_schur_even (n : ℕ) (hn : Even n) (x : Fin n → ℂ) + (hd : ∀ i j, x i + x j ≠ 0) (hx : Function.Injective x) : + pfaffian n (schurMatrix x) = schurProduct x := by + induction n using Nat.twoStepInduction with + | zero => simp [schurProduct] + | one => exact False.elim (by simp at hn) + | more n ih _ => + have he : Even n := by + rw [Nat.even_iff] at * + omega + revert hd hx + refine Fin.snocCases (fun y b => ?_) x + refine Fin.snocCases (fun z a => ?_) y + intro hd hx + apply pfaffian_schur_snoc_snoc he z a b + · apply ih he + · intro i j + simpa only [Fin.snoc_castSucc] using hd i.castSucc.castSucc j.castSucc.castSucc + · intro i j hij + apply Fin.castSucc_injective + apply Fin.castSucc_injective + apply hx + simpa only [Fin.snoc_castSucc] using hij + · intro i j + simpa only [Fin.snoc_castSucc] using hd i.castSucc.castSucc j.castSucc.castSucc + · intro i + simpa only [Fin.snoc_castSucc, Fin.snoc_last] using + hd i.castSucc.castSucc (Fin.last n).castSucc + · intro i + simpa only [Fin.snoc_castSucc, Fin.snoc_last] using + hd i.castSucc.castSucc (Fin.last (n + 1)) + · simpa only [Fin.snoc_castSucc, Fin.snoc_last] using + hd (Fin.last n).castSucc (Fin.last (n + 1)) + · intro hab + exact Fin.castSucc_ne_last (Fin.last n) (hx (by + simpa only [Fin.snoc_castSucc, Fin.snoc_last] using hab.symm)) + +lemma pfaffian_schur_odd_snoc {n : ℕ} (hn : Even n) (x : Fin n → ℂ) (a : ℂ) + (hd : ∀ i j, x i + x j ≠ 0) (hx : Function.Injective x) + (ha : ∀ i, x i + a ≠ 0) : + pfaffian (n + 2) (border (schurMatrix (Fin.snoc x a)) (fun _ => 1)) = + schurProduct (Fin.snoc x a) := by + have hc : schurComplement (schurMatrix x) (fun i => schurEntry (x i) a) (fun _ => 1) 1 = + fun i j => schurEntry (x i) a * schurMatrix x i j * schurEntry (x j) a := by + ext i j + simpa only [schurComplement, schurMatrix, mul_one, one_mul, div_one] using + schurEntry_border_elimination (hd i j) (ha i) (ha j) + have h1 : (fun _ : Fin (n + 1) => (1 : ℂ)) = Fin.snoc (fun _ => 1) 1 := by + ext i + refine Fin.lastCases ?_ (fun i => ?_) i <;> simp + rw [schurMatrix_snoc, h1, + pfaffian_schur_complement hn _ (schurMatrix_skew x) _ _ one_ne_zero, + one_mul, hc, pfaffian_scale_coordinates hn _ (schurMatrix_skew x), + pfaffian_schur_even n hn x hd hx, schurProduct_snoc, mul_comm] + + +theorem pfaffian_schur_odd (n : ℕ) (hn : Odd n) (x : Fin n → ℂ) + (hd : ∀ i j, x i + x j ≠ 0) (hx : Function.Injective x) : + pfaffian (n + 1) (border (schurMatrix x) (fun _ => 1)) = schurProduct x := by + cases n with + | zero => exact False.elim (by simp at hn) + | succ n => + have he : Even n := by + rw [Nat.odd_iff] at hn + rw [Nat.even_iff] + omega + revert hd hx + refine Fin.snocCases (fun y a => ?_) x + intro hd hx + apply pfaffian_schur_odd_snoc he y a + · intro i j + simpa only [Fin.snoc_castSucc] using hd i.castSucc j.castSucc + · intro i j hij + apply Fin.castSucc_injective + apply hx + simpa only [Fin.snoc_castSucc] using hij + · intro i + simpa only [Fin.snoc_castSucc, Fin.snoc_last] using hd i.castSucc (Fin.last n) + +end +end StripPfaffian + +namespace CriticalStrip +noncomputable section +open MeasureTheory Set +open scoped BigOperators + +lemma integral_translate_Ioi (f : ℝ → ℝ) (a b : ℝ) : + (∫ x in Ioi a, f (x + b)) = ∫ x in Ioi (a + b), f x := by + have hp : (fun x : ℝ => x + b) ⁻¹' Ioi (a + b) = Ioi a := by + ext x + simp + simpa only [hp] using (measurePreserving_add_right volume b).setIntegral_preimage_emb + (Homeomorph.addRight b).measurableEmbedding f (Ioi (a + b)) + +lemma integral_shifted_rpow {p : ℝ} (hp : 0 < p) : + (∫ t in Ioi (0 : ℝ), (1 + t) ^ (-(p + 1))) = 1 / p := by + calc + _ = ∫ x in Ioi (1 : ℝ), x ^ (-(p+1)) := by + simpa only [zero_add, add_comm] using + integral_translate_Ioi (fun x : ℝ => x ^ (-(p+1))) 0 1 + _ = 1 / p := by + rw [integral_Ioi_rpow_of_lt (by linarith : -(p+1)< -1) (by norm_num : (0:ℝ)<1), + Real.one_rpow] + rw [show -(p+1)+1 = -p by ring, neg_div_neg_eq] + +local notation "μ₊" => (volume.restrict (Ioi (0 : ℝ))) + +lemma ae_pos_pair : ∀ᵐ rs : ℝ × ℝ ∂μ₊.prod μ₊, 0 < rs.1 ∧ 0 < rs.2 := by + apply (Measure.ae_prod_iff_ae_ae (by measurability)).2 + exact (ae_restrict_mem measurableSet_Ioi).mono fun r hr => + (ae_restrict_mem measurableSet_Ioi).mono fun s hs => ⟨hr, hs⟩ + +def gammaLaplace (p q : ℝ) (z : (ℝ × ℝ) × ℝ) : ℝ := + laguerreWeight p z.1.1 * laguerreWeight q z.1.2 * z.1.1 * + Real.exp (-(z.1.1 + z.1.2) * z.2) + +lemma measurable_gammaLaplace (p q : ℝ) : Measurable (gammaLaplace p q) := by + unfold gammaLaplace laguerreWeight + fun_prop + +lemma integrable_gammaLaplace_section (p q : ℝ) {r s : ℝ} (hr : 0 < r) (hs : 0 < s) : + Integrable (fun t => gammaLaplace p q ((r,s),t)) μ₊ := by + exact (integrableOn_exp_mul_Ioi (show -(r+s) < 0 by linarith) 0).const_mul + (laguerreWeight p r * laguerreWeight q s * r) + +lemma integral_gammaLaplace_section (p q : ℝ) {r s : ℝ} (hr : 0 < r) (hs : 0 < s) : + (∫ t, gammaLaplace p q ((r,s),t) ∂μ₊) = + laguerreWeight p r * laguerreWeight q s * (r / (r+s)) := by + simp only [gammaLaplace, integral_const_mul, + integral_exp_mul_Ioi (show -(r+s) < 0 by linarith) 0, mul_zero, Real.exp_zero, neg_div_neg_eq] + ring + +lemma integrable_gammaFraction {p q : ℝ} (hp : 0 < p) (hq : 0 < q) : + Integrable (fun rs : ℝ × ℝ => laguerreWeight p rs.1 * laguerreWeight q rs.2 * + (rs.1 / (rs.1 + rs.2))) (μ₊.prod μ₊) := by + have hi := (integrableOn_laguerreWeight hp).mul_prod (integrableOn_laguerreWeight hq) + apply hi.mono' (by unfold laguerreWeight; fun_prop) + filter_upwards [ae_pos_pair] with rs hrs + obtain ⟨hr,hs⟩ := hrs + have hw : 0 ≤ laguerreWeight p rs.1 * laguerreWeight q rs.2 := + mul_nonneg (laguerreWeight_pos p hr).le (laguerreWeight_pos q hs).le + rw [Real.norm_eq_abs, abs_of_nonneg (mul_nonneg hw (div_nonneg hr.le (add_pos hr hs).le))] + exact mul_le_of_le_one_right hw ((div_le_one (add_pos hr hs)).2 (by linarith)) + +lemma integrable_gammaLaplace {p q : ℝ} (hp : 0 < p) (hq : 0 < q) : + Integrable (gammaLaplace p q) ((μ₊.prod μ₊).prod μ₊) := by + apply (integrable_prod_iff (measurable_gammaLaplace p q).aestronglyMeasurable).2 + constructor + · exact ae_pos_pair.mono fun rs hrs => integrable_gammaLaplace_section p q hrs.1 hrs.2 + · apply (integrable_gammaFraction hp hq).congr + filter_upwards [ae_pos_pair] with rs hrs + rw [← integral_gammaLaplace_section p q hrs.1 hrs.2] + apply integral_congr_ae + filter_upwards [ae_restrict_mem measurableSet_Ioi] with t ht + exact (Real.norm_of_nonneg (by + unfold gammaLaplace + exact mul_nonneg (mul_nonneg (mul_nonneg + (laguerreWeight_pos p hrs.1).le (laguerreWeight_pos q hrs.2).le) hrs.1.le) + (Real.exp_pos _).le)).symm + +lemma gammaLaplace_factor (p q : ℝ) {r s : ℝ} (hr : 0 < r) (_hs : 0 < s) (t : ℝ) : + gammaLaplace p q ((r,s),t) = + (r ^ p * Real.exp (-((1+t)*r))) * + (s ^ (q-1) * Real.exp (-((1+t)*s))) := by + unfold gammaLaplace laguerreWeight + have hrp : r^p = r^(p-1)*r := by + calc + _ = r ^ ((p-1)+1) := by congr 1; ring + _ = _ := by rw [Real.rpow_add hr, Real.rpow_one] + rw [hrp] + have he : Real.exp (-r) * Real.exp (-s) * Real.exp (-(r+s)*t) = + Real.exp (-((1+t)*r)) * Real.exp (-((1+t)*s)) := by + simp only [← Real.exp_add] + congr 1 + ring + calc + _ = (r^(p-1) * r * s^(q-1)) * + (Real.exp (-r) * Real.exp (-s) * Real.exp (-(r+s)*t)) := by ring + _ = _ := by rw [he]; ring + +lemma integral_gammaLaplace_pair {p q : ℝ} (hp : 0 < p) (hq : 0 < q) {t : ℝ} (ht : 0 < t) : + (∫ rs : ℝ × ℝ, gammaLaplace p q (rs,t) ∂μ₊.prod μ₊) = + (Real.Gamma (p+1) * Real.Gamma q) * (1+t)^(-(p+q+1)) := by + calc + _ = ∫ rs : ℝ × ℝ, (rs.1^p * Real.exp (-((1+t)*rs.1))) * + (rs.2^(q-1) * Real.exp (-((1+t)*rs.2))) ∂μ₊.prod μ₊ := by + apply integral_congr_ae + exact ae_pos_pair.mono fun rs hrs => gammaLaplace_factor p q hrs.1 hrs.2 t + _ = (∫ r in Ioi 0, r^p * Real.exp (-((1+t)*r))) * + (∫ s in Ioi 0, s^(q-1) * Real.exp (-((1+t)*s))) := integral_prod_mul (μ := μ₊) (ν := μ₊) + (fun r : ℝ => r^p * Real.exp (-((1+t)*r))) + (fun s : ℝ => s^(q-1) * Real.exp (-((1+t)*s))) + _ = ((1/(1+t))^(p+1) * Real.Gamma (p+1)) * + ((1/(1+t))^q * Real.Gamma q) := by + rw [show p = (p+1)-1 by ring, Real.integral_rpow_mul_exp_neg_mul_Ioi (by linarith : 0 (integral_gammaLaplace_section p q hrs.1 hrs.2).symm + _ = ∫ t, ∫ rs : ℝ × ℝ, gammaLaplace p q (rs,t) ∂μ₊.prod μ₊ ∂μ₊ := + integral_integral_swap (integrable_gammaLaplace hp hq) + _ = ∫ t, (Real.Gamma (p+1) * Real.Gamma q) * (1+t)^(-(p+q+1)) ∂μ₊ := by + apply integral_congr_ae + exact (ae_restrict_mem measurableSet_Ioi).mono fun t ht => integral_gammaLaplace_pair hp hq ht + _ = _ := by + rw [integral_const_mul, integral_shifted_rpow (add_pos hp hq), Real.Gamma_add_one hp.ne'] + ring + + + +def gammaSkewIntegrand (p q : ℝ) (rs : ℝ × ℝ) : ℝ := + laguerreWeight p rs.1 * laguerreWeight q rs.2 * ((rs.2-rs.1)/(rs.2+rs.1)) + +lemma gammaSkewIntegrand_eq (p q : ℝ) {r s : ℝ} (hr : 0 < r) (hs : 0 < s) : + gammaSkewIntegrand p q (r,s) = + laguerreWeight p r * laguerreWeight q s - + 2 * (laguerreWeight p r * laguerreWeight q s * (r/(r+s))) := by + unfold gammaSkewIntegrand + field_simp [(add_pos hr hs).ne', (add_pos hs hr).ne'] + ring + +lemma integrable_gammaSkewIntegrand {p q : ℝ} (hp : 0 < p) (hq : 0 < q) : + Integrable (gammaSkewIntegrand p q) (μ₊.prod μ₊) := by + have h := ((integrableOn_laguerreWeight hp).mul_prod (integrableOn_laguerreWeight hq)).sub + ((integrable_gammaFraction hp hq).const_mul 2) + exact h.congr (ae_pos_pair.mono fun rs hrs => (gammaSkewIntegrand_eq p q hrs.1 hrs.2).symm) + +lemma integral_gammaSkewIntegrand {p q : ℝ} (hp : 0 < p) (hq : 0 < q) : + (∫ rs : ℝ × ℝ, gammaSkewIntegrand p q rs ∂μ₊.prod μ₊) = + Real.Gamma p * Real.Gamma q * ((q-p)/(p+q)) := by + calc + _ = (∫ rs : ℝ × ℝ, laguerreWeight p rs.1 * laguerreWeight q rs.2 ∂μ₊.prod μ₊) - + 2 * (∫ rs : ℝ × ℝ, laguerreWeight p rs.1 * laguerreWeight q rs.2 * + (rs.1/(rs.1 + rs.2)) ∂μ₊.prod μ₊) := by + rw [← integral_const_mul, ← integral_sub + ((integrableOn_laguerreWeight hp).mul_prod (integrableOn_laguerreWeight hq)) + ((integrable_gammaFraction hp hq).const_mul 2)] + exact integral_congr_ae (ae_pos_pair.mono fun rs hrs => gammaSkewIntegrand_eq p q hrs.1 hrs.2) + _ = _ := by + rw [integral_prod_mul (μ := μ₊) (ν := μ₊) (laguerreWeight p) (laguerreWeight q), + integral_laguerreWeight hp, integral_laguerreWeight hq, integral_gammaFraction hp hq] + field_simp [(add_pos hp hq).ne'] + ring + + +theorem laguerre_double_moment {a : ℝ} (ha : 0 < a) (i j : ℕ) : + Integrable (gammaSkewIntegrand (a+i) (a+j)) (μ₊.prod μ₊) ∧ + (∫ rs : ℝ × ℝ, gammaSkewIntegrand (a+i) (a+j) rs ∂μ₊.prod μ₊) = + Real.Gamma (a+i) * Real.Gamma (a+j) * (((j:ℝ)-i)/(2*a+i+j)) := by + have hi : 0 < a+(i:ℝ) := by positivity + have hj : 0 < a+(j:ℝ) := by positivity + refine ⟨integrable_gammaSkewIntegrand hi hj, ?_⟩ + rw [integral_gammaSkewIntegrand hi hj] + congr 2 <;> ring + +end +end CriticalStrip + +namespace StripPfaffian +noncomputable section +open scoped BigOperators + +lemma border_scale_coordinates {n : ℕ} (A : Matrix (Fin n) (Fin n) ℂ) (u s : Vec n) : + border (fun i j => s i * A i j * s j) (fun i => s i * u i) = + fun i j => (Fin.snoc s (1:ℂ) : Vec (n+1)) i * border A u i j * + (Fin.snoc s (1:ℂ) : Vec (n+1)) j := by + funext i j + refine Fin.lastCases ?_ (fun i => ?_) i + all_goals refine Fin.lastCases ?_ (fun j => ?_) j + all_goals simp [border] + ring + +lemma pfaffian_border_scale_coordinates {n : ℕ} (hn : Odd n) + (A : Matrix (Fin n) (Fin n) ℂ) (hA : ∀ i j, A j i = -A i j) (u s : Vec n) : + pfaffian (n+1) (border (fun i j => s i * A i j * s j) (fun i => s i * u i)) = + (∏ i, s i) * pfaffian (n+1) (border A u) := by + rw [border_scale_coordinates, pfaffian_scale_coordinates hn.add_one _ (border_skew A hA u), + Fin.prod_univ_castSucc] + simp + + + +theorem pfaffian_weighted_schur_even (n : ℕ) (hn : Even n) (x s : Fin n → ℂ) + (hd : ∀ i j, x i + x j ≠ 0) (hx : Function.Injective x) : + pfaffian n (fun i j => s i * schurEntry (x i) (x j) * s j) = + (∏ i, s i) * schurProduct x := by + have h := pfaffian_scale_coordinates hn (schurMatrix x) (schurMatrix_skew x) s + rw [pfaffian_schur_even n hn x hd hx] at h + exact h + +theorem pfaffian_weighted_schur_odd (n : ℕ) (hn : Odd n) (x s : Fin n → ℂ) + (hd : ∀ i j, x i + x j ≠ 0) (hx : Function.Injective x) : + pfaffian (n+1) (border (fun i j => s i * schurEntry (x i) (x j) * s j) s) = + (∏ i, s i) * schurProduct x := by + have h := pfaffian_border_scale_coordinates hn (schurMatrix x) (schurMatrix_skew x) + (fun _ => 1) s + rw [pfaffian_schur_odd n hn x hd hx] at h + simpa only [mul_one, schurMatrix] using h + +end +end StripPfaffian + +namespace CriticalStrip +noncomputable section +open scoped BigOperators +open MeasureTheory Set StripPfaffian + +local notation "μ₊" => volume.restrict (Ioi (0 : ℝ)) + +def laguerreMomentMatrix (n : ℕ) (a : ℝ) : Matrix (Fin n) (Fin n) ℂ := + fun i j => ((∫ rs, gammaSkewIntegrand (a+i.val) (a+j.val) rs ∂μ₊.prod μ₊) : ℝ) + +def laguerreMomentColumn (n : ℕ) (a : ℝ) : Fin n → ℂ := + fun i => ((∫ x in Ioi 0, laguerreWeight (a+i.val) x) : ℝ) + + + +def laguerreNormalizerProduct (n : ℕ) (a : ℝ) : ℝ := + (∏ i : Fin n, Real.Gamma (a+i.val)) * + ∏ i : Fin n, ∏ j ∈ Finset.Ioi i, ((j.val:ℝ)-i.val)/(2*a+i.val+j.val) + +lemma laguerreMomentMatrix_eq {a : ℝ} (ha : 0 < a) (n : ℕ) : + laguerreMomentMatrix n a = fun i j => + (Real.Gamma (a+i.val) : ℂ) * + schurEntry ((a+i.val : ℝ) : ℂ) ((a+j.val : ℝ) : ℂ) * + (Real.Gamma (a+j.val) : ℂ) := by + ext i j + rw [laguerreMomentMatrix, (laguerre_double_moment ha i.val j.val).2] + simp only [StripPfaffian.schurEntry, Complex.ofReal_mul, Complex.ofReal_div, + Complex.ofReal_sub, Complex.ofReal_add, Complex.ofReal_natCast, Complex.ofReal_ofNat] + have hn : ((a:ℂ)+j.val) - ((a:ℂ)+i.val) = (j.val:ℂ)-i.val := by ring + have hd : ((a:ℂ)+i.val) + ((a:ℂ)+j.val) = 2*(a:ℂ)+i.val+j.val := by ring + rw [hn,hd] + ring + +lemma laguerreMomentColumn_eq {a : ℝ} (ha : 0 < a) (n : ℕ) : + laguerreMomentColumn n a = fun i => (Real.Gamma (a+i.val) : ℂ) := by + ext i + exact congrArg Complex.ofReal (integral_laguerreWeight (by positivity)) + +lemma laguerre_schur_denominators {a : ℝ} (ha : 0 < a) (n : ℕ) (i j : Fin n) : + ((a+i.val : ℝ) : ℂ) + ((a+j.val : ℝ) : ℂ) ≠ 0 := by + rw [← Complex.ofReal_add, Complex.ofReal_ne_zero] + positivity + +lemma laguerre_schur_injective (a : ℝ) (n : ℕ) : + Function.Injective (fun i : Fin n => ((a+i.val : ℝ) : ℂ)) := by + intro i j hij + have h := Complex.ofReal_injective hij + have he : (i.val:ℝ) = j.val := add_left_cancel h + exact Fin.ext (Nat.cast_injective he) + +lemma laguerreNormalizerProduct_eq (n : ℕ) (a : ℝ) : + (laguerreNormalizerProduct n a : ℂ) = + (∏ i : Fin n, (Real.Gamma (a+i.val) : ℂ)) * + StripPfaffian.schurProduct (fun i : Fin n => ((a+i.val : ℝ) : ℂ)) := by + simp only [laguerreNormalizerProduct, Complex.ofReal_mul, Complex.ofReal_prod, + StripPfaffian.schurProduct] + congr 1 + apply Finset.prod_congr rfl + intro i hi + apply Finset.prod_congr rfl + intro j hj + simp only [StripPfaffian.schurEntry, Complex.ofReal_div, Complex.ofReal_sub, + Complex.ofReal_add, Complex.ofReal_mul, Complex.ofReal_natCast, Complex.ofReal_ofNat] + congr 1 <;> ring + + + +theorem laguerreMomentMatrix_pfaffian_even {a : ℝ} (ha : 0 < a) (n : ℕ) (hn : Even n) : + StripPfaffian.pfaffian n (laguerreMomentMatrix n a) = laguerreNormalizerProduct n a := by + rw [laguerreMomentMatrix_eq ha, laguerreNormalizerProduct_eq] + exact pfaffian_weighted_schur_even n hn _ _ (laguerre_schur_denominators ha n) + (laguerre_schur_injective a n) + +theorem laguerreMomentMatrix_pfaffian_odd {a : ℝ} (ha : 0 < a) (n : ℕ) (hn : Odd n) : + StripPfaffian.pfaffian (n+1) (StripPfaffian.border (laguerreMomentMatrix n a) + (laguerreMomentColumn n a)) = laguerreNormalizerProduct n a := by + rw [laguerreMomentMatrix_eq ha, laguerreMomentColumn_eq ha, laguerreNormalizerProduct_eq] + exact pfaffian_weighted_schur_odd n hn _ _ (laguerre_schur_denominators ha n) + (laguerre_schur_injective a n) + +end +end CriticalStrip + + + +namespace StripPfaffian +noncomputable section +open scoped BigOperators + +lemma sum_pow_list {ι E : Type*} [Fintype ι] [Semiring E] (f : ι → E) (m : ℕ) : + (∑ i, f i) ^ m = ∑ v : Fin m → ι, (List.ofFn (fun j => f (v j))).prod := by + classical + induction m with + | zero => simp + | succ m ih => + rw [pow_succ', ih, Finset.mul_sum] + conv_lhs => simp only [Finset.sum_mul] + rw [Finset.sum_comm] + rw [← Fintype.sum_prod_type (f := fun p : ι × (Fin m → ι) => + f p.1 * (List.ofFn (fun j => f (p.2 j))).prod)] + apply Fintype.sum_equiv (Fin.consEquiv (fun _ : Fin (m+1) => ι)) + intro p + simp [List.ofFn_succ, Fin.consEquiv] + +lemma ofFn_smul_prod {n m : ℕ} (s : Fin m → ℂ) (v : Fin m → Grassmann n) : + (List.ofFn (fun i => s i • v i)).prod = + (∏ i, s i) • (List.ofFn v).prod := by + induction m with + | zero => simp + | succ m ih => + simp only [List.ofFn_succ, List.prod_cons, Fin.prod_univ_succ] + rw [ih, smul_mul_smul_comm] + +end +end StripPfaffian + +end OAI diff --git a/lean/OAI/Combinatorics/StripMass/SewnAssignment.lean b/lean/OAI/Combinatorics/StripMass/SewnAssignment.lean new file mode 100644 index 0000000000000000000000000000000000000000..5ffef8aee5ae1d1887ae45650be7b38e96a539eb --- /dev/null +++ b/lean/OAI/Combinatorics/StripMass/SewnAssignment.lean @@ -0,0 +1,603 @@ +import Mathlib +import OAI.Combinatorics.StripMass.ReversedConvergence + +namespace OAI + +/-! Critical honeycomb strip paths, polynomial identities and crossing mass. -/ + + +namespace CriticalStrip +noncomputable section +open scoped Classical +open Diagram + +namespace Diagram.Tile +@[simp] lemma horizontal_occupied_zero (t : Tile) : t.horizontal.Occupied 0 ↔ t.Occupied 0 := by + revert t; decide +@[simp] lemma horizontal_occupied_one (t : Tile) : t.horizontal.Occupied 1 ↔ t.Occupied 2 := by + simpa [horizontalPort] using horizontal_occupied t 2 +@[simp] lemma horizontal_occupied_two (t : Tile) : t.horizontal.Occupied 2 ↔ t.Occupied 1 := by + simpa [horizontalPort] using horizontal_occupied t 1 +@[simp] lemma horizontal_occupied_three (t : Tile) : t.horizontal.Occupied 3 ↔ t.Occupied 3 := by + revert t; decide +end Diagram.Tile + +namespace SewnRectangle +variable {n : ℕ} + + + +def tile (l r : List (Configuration n)) (v : Cell) : Tile := + if hj : v.2 + change (tile l r (-1-(0:ℕ),j'.val)).Occupied 2 ↔ (tile l r ((0:ℕ),j'.val)).Occupied 1 + rw [tile_left l r 0 j',tile_right l r 0 j',Tile.horizontal_occupied_one] + exact hcut j' + | succ k => + have he : -1-((k+1:ℕ):ℤ)+1 = -1-(k:ℤ) := by omega + rw [tile_left l r (k+1) j',he,tile_left l r k j'] + exact hl.horizontal k j' + · rw [tile_right l r k j',show (k:ℤ)+1=((k+1:ℕ):ℤ) by omega,tile_right l r (k+1) j', + Tile.horizontal_occupied_two,Tile.horizontal_occupied_one] + exact (hr.horizontal k j').symm + · rw [tile_outside l r i j (by omega),tile_outside l r (i+1) j (by omega)] + exact ⟨fun h=>(Tile.vacant_not_occupied 2 h).elim,fun h=>(Tile.vacant_not_occupied 1 h).elim⟩ + +lemma vertical (l r : List (Configuration n)) + (hl : ColumnChain.LocallyCompatible l) (hr : ColumnChain.LocallyCompatible r) + (i : ℤ) (j : ℕ) (hj : j+1physicalWeights (2*Diagram.lambda)) northInjectionWeights) l≠0) + (hr : ColumnChain.weight (Fin.snoc (fun _ : Fin n=>physicalWeights Diagram.lambda) northInjectionWeights) r≠0) : + (∀k j, ColumnChain.read l k j≠.verticalPair) ∧ (∀k j, ColumnChain.read r k j≠.capCup) := by + constructor + · intro k j h + have hh := ColumnChain.read_tile_ne_zero hl k j + rw [h] at hh + induction j using Fin.lastCases with + | last => simp [Fin.snoc_last,northInjectionWeights,Weights.tile] at hh + | cast i => + rw [Fin.snoc_castSucc] at hh + change (physicalWeights (2*Diagram.lambda)).E≠0 at hh + rw [physicalWeights_two_lambda] at hh + exact hh rfl + · intro k j h + have hh := ColumnChain.read_tile_ne_zero hr k j + rw [h] at hh + induction j using Fin.lastCases with + | last => simp [Fin.snoc_last,northInjectionWeights,Weights.tile] at hh + | cast i => + rw [Fin.snoc_castSucc] at hh + change (physicalWeights Diagram.lambda).F≠0 at hh + rw [physicalWeights_lambda] at hh + exact hh rfl + +end SewnRectangle +end +end CriticalStrip + + + + + +namespace CriticalStrip.Diagram +noncomputable section +open scoped Classical + +namespace Graph + +lemma drainsAt_iff {V : Type*} {r : V → V → Prop} {root : V} : + DrainsAt r root ↔ Patch.drains r (fun v=>v=root) := by + constructor + · intro h v w hvw + exact ⟨root,rfl,h v w hvw⟩ + · intro h v w hvw + obtain ⟨_,rfl,hr⟩:=h v w hvw + exact hr + +lemma drainsAt_glued_iff {V W I : Type*} (r : V → V → Prop) (s : W → W → Prop) + (a : I → V) (b : I → W) (active : I → Prop) (root : W) : + DrainsAt (Patch.glued r s a b active) (.inr root) ↔ + (∀ v w,r v w → ∃ i,active i ∧ Relation.ReflTransGen r v (a i)) ∧ + DrainsAt (Patch.compressed r s a b active) root := by + have he : (fun v : V⊕W=>v=Sum.inr root)=Patch.exteriorOutput (fun w=>w=root) := by + funext v + cases v <;> simp [Patch.exteriorOutput] + rw [drainsAt_iff,he,Patch.drains_glued_iff,←drainsAt_iff] + +end Graph + +namespace GraphRealizes +variable {V W : Type*} {n : ℕ} {r : V → V → Prop} {s : W → W → Prop} + {a : Fin n → V} {b : Fin n → W} {p q : Pairing n} + +lemma compressed_closure_edge (hp : GraphRealizes r a p) {x y : W} + (h : Patch.compressed r s a b p.Occupied x y) : + x=y ∨ Graph.boundaryClosure s b p x y := by + rcases h with h | ⟨i,j,hi,hj,hr,rfl,rfl⟩ + · exact Or.inr (Or.inl h) + · rcases (hp.reach i j).mp hr with rfl | he + · exact Or.inl rfl + · exact Or.inr (Or.inr ⟨i,j,he,rfl,rfl⟩) + +lemma closure_compressed_edge (hp : GraphRealizes r a p) {x y : W} + (h : Graph.boundaryClosure s b p x y) : + Patch.compressed r s a b p.Occupied x y := by + rcases h with h | ⟨i,j,hij,rfl,rfl⟩ + · exact Or.inl h + · exact Or.inr ⟨i,j,⟨j,hij⟩,⟨i,Pairing.adj_symm hij⟩, + (hp.reach i j).mpr (Or.inr hij),rfl,rfl⟩ + +lemma compressed_closure_reach (hp : GraphRealizes r a p) (x y : W) : + Relation.ReflTransGen (Patch.compressed r s a b p.Occupied) x y ↔ + Relation.ReflTransGen (Graph.boundaryClosure s b p) x y := by + constructor + · intro h + induction h with + | refl => exact .refl + | @tail z w h hzw ih => + rcases hp.compressed_closure_edge hzw with rfl | he + · exact ih + · exact ih.tail he + · exact Relation.ReflTransGen.mono (fun _ _=>hp.closure_compressed_edge) _ _ + +lemma compressed_closure_drains (hp : GraphRealizes r a p) (root : W) : + Graph.DrainsAt (Patch.compressed r s a b p.Occupied) root ↔ + Graph.DrainsAt (Graph.boundaryClosure s b p) root := by + constructor + · intro h v w hvw + exact (hp.compressed_closure_reach v root).mp (h v w (hp.closure_compressed_edge hvw)) + · intro h v w hvw + apply (hp.compressed_closure_reach v root).mpr + rcases hvw with he | ⟨i,j,⟨k,hik⟩,hj,hr,rfl,rfl⟩ + · exact h v w (Or.inl he) + · exact h (b i) (b k) (Or.inr ⟨i,k,hik,rfl,rfl⟩) + + + +theorem sewn_drains_iff (hp : GraphRealizes r a p) (hq : GraphRealizes s b q) + (hb : Function.Injective b) (root : Fin n) : + Graph.DrainsAt (Patch.glued r s a b p.Occupied) (.inr (b root)) ↔ + Graph.DrainsAt (p.join q) root := by + rw [Graph.drainsAt_glued_iff,hp.compressed_closure_drains,hq.closure_drains_iff hb] + have he : Graph.DrainsAt (q.join p) root ↔ Graph.DrainsAt (p.join q) root := by + have hj : q.join p=p.join q := by funext i j; exact propext or_comm + rw [hj] + rw [he] + exact ⟨fun h=>h.2,fun h=>⟨hp.no_loop,h⟩⟩ + + + +theorem gluesAt_iff_sewn (hp : GraphRealizes r a p) (hq : GraphRealizes s b q) + (ha : Function.Injective a) (hb : Function.Injective b) (root : Fin n) : + p.GluesAt root q ↔ Graph.Used r (a root) ∧ + (∀ i,Graph.Used r (a i) ↔ Graph.Used s (b i)) ∧ + Graph.DrainsAt (Patch.glued r s a b p.Occupied) (.inr (b root)) := by + simp only [hp.boundary_used_iff ha,hq.boundary_used_iff hb, + hp.sewn_drains_iff hq hb,Pairing.GluesAt] + +end GraphRealizes + + + + + + +namespace PaddedColumn +variable {n : ℕ} +abbrev V (n : ℕ) := ℕ × Vertex n + +def wiring (ts : List (Configuration n)) : V n → V n → Prop + | (k,i,a),(l,j,b) => + (k=l ∧ BareColumn (ColumnChain.read ts k) (i,a) (j,b)) ∨ + (i=j ∧ a=2 ∧ b=1 ∧ l+1=k ∧ (ColumnChain.read ts k i).Occupied 2) ∨ + (i=j ∧ a=1 ∧ b=2 ∧ k+1=l ∧ (ColumnChain.read ts l j).Occupied 2) + +def boundary (i : Fin n) : V n := (0,i,2) + +lemma boundary_injective : Function.Injective (boundary (n:=n)) := by + intro i j h; exact congrArg (fun x=>x.2.1) h + +def active (ts : List (Configuration n)) (i : Fin n) : Prop := + (ColumnChain.read ts 0 i).Occupied 2 + +lemma wiring_nil (v w : V n) : ¬wiring [] v w := by + rcases v with ⟨k,i,a⟩ + rcases w with ⟨l,j,b⟩ + simp only [wiring,ColumnChain.read_nil,BareColumn] + have he (a b : Fin 4) : ¬Tile.vacant.Adj a b := by + exact fun h=>Tile.vacant_not_occupied a ⟨b,h⟩ + simp [he,Tile.vacant_not_occupied] + +lemma empty_realizes : GraphRealizes (wiring ([] : List (Configuration n))) boundary (empty n) := by + constructor + · exact fun v w h=>(wiring_nil v w h).elim + · intro i j + constructor + · intro hr + have hn (v w : V n) (h : Relation.ReflTransGen (wiring []) v w) : v=w := by + induction h with + | refl => rfl + | @tail v w h h₁ ih => exact (wiring_nil v w h₁).elim + have he := hn _ _ hr + exact Or.inl (boundary_injective he) + · rintro (rfl | h) + · exact .refl + · exact (empty_not_occupied i ⟨j,h⟩).elim + + +def addColumn (n : ℕ) : Sum (V n) (Vertex n) ≃ V n where + toFun + | .inl (k,v) => (k+1,v) + | .inr v => (0,v) + invFun + | (0,v) => .inr v + | (k+1,v) => .inl (k,v) + left_inv := by rintro (⟨k,v⟩|v) <;> rfl + right_inv := by rintro ⟨k,v⟩; cases k <;> rfl + +lemma wiring_step (t : Configuration n) (ts : List (Configuration n)) + (v w : Sum (V n) (Vertex n)) : + Patch.glued (wiring ts) (BareColumn t) boundary (fun i=>(i,1)) (active ts) v w ↔ + wiring (t::ts) (addColumn n v) (addColumn n w) := by + cases v with + | inl v => + rcases v with ⟨k,i,a⟩ + cases w with + | inl w => + rcases w with ⟨l,j,b⟩ + simp [Patch.glued,wiring,addColumn] + | inr w => + rcases w with ⟨j,b⟩ + by_cases hij : i=j + · subst j + simp [Patch.glued,wiring,addColumn,boundary,active,and_assoc,and_left_comm,and_comm] + intro h _ _; subst h; rfl + · simp [Patch.glued,wiring,addColumn,boundary,active,hij,Ne.symm hij] + | inr v => + rcases v with ⟨i,a⟩ + cases w with + | inl w => + rcases w with ⟨l,j,b⟩ + by_cases hij : i=j + · subst j + simp [Patch.glued,wiring,addColumn,boundary,active,and_assoc,and_left_comm,and_comm] + intro h _ _; subst h; rfl + · simp [Patch.glued,wiring,addColumn,boundary,active,hij,Ne.symm hij] + | inr w => + rcases w with ⟨j,b⟩ + simp [Patch.glued,wiring,addColumn,BareColumn] + +def stepEquivalence (t : Configuration n) (ts : List (Configuration n)) : + Graph.BoundaryEquiv + (Patch.glued (wiring ts) (BareColumn t) boundary (fun i=>(i,1)) (active ts)) + (wiring (t::ts)) (fun i=>.inr (i,2)) boundary := + Graph.BoundaryEquiv.ofEquiv (addColumn n) (wiring_step t ts) (fun _=>rfl) + + + +theorem runs_realizes (ts : List (Configuration n)) (q : Pairing n) + (h : ColumnChain.Runs (empty n) ts q) : GraphRealizes (wiring ts) boundary q := by + induction ts generalizing q with + | nil => exact h ▸ empty_realizes + | cons t ts ih => + obtain ⟨p,hp,ht⟩ := h + have hg := ih p hp + have he : active ts=p.Occupied := by + funext i + exact propext ((ColumnChain.support_empty_read ts i).symm.trans + (by rw [(ColumnChain.runs_sound _ _ _ hp).2.2])) + apply (stepEquivalence t ts).realizes + rw [he,hg.substitute_iff] + exact (ColumnSew.equivalence p t).symm.realizes ((realizes_iff_column_graph p q t).mp ht).2 + +end PaddedColumn +end +end CriticalStrip.Diagram + + + + + +namespace CriticalStrip +noncomputable section +open scoped Classical +open Diagram + +namespace Diagram.Graph + + + +lemma drainsAt_embedding_iff {V W : Type*} {r : V → V → Prop} {s : W → W → Prop} + (f : V → W) (hf : Function.Injective f) + (he : ∀v w, s (f v) (f w) ↔ r v w) + (hs : ∀x y, s x y → x∈Set.range f ∧ y∈Set.range f) (root : V) : + DrainsAt r root ↔ DrainsAt s (f root) := by + have lift {x y : W} (h : Relation.ReflTransGen s x y) : + ∀v, x=f v → ∃w, y=f w ∧ Relation.ReflTransGen r v w := by + induction h with + | refl => intro v hv; exact ⟨v,hv,.refl⟩ + | @tail y z h hyz ih => + intro v hv + obtain ⟨u,rfl,hu⟩:=ih v hv + obtain ⟨w,rfl⟩:=(hs _ _ hyz).2 + exact ⟨w,rfl,hu.tail ((he u w).mp hyz)⟩ + constructor + · intro h x y hxy + obtain ⟨v,rfl⟩:=(hs x y hxy).1 + obtain ⟨w,rfl⟩:=(hs _ y hxy).2 + exact map_reach f (fun x y h=>.single ((he x y).mpr h)) (h v w ((he v w).mp hxy)) + · intro h v w hvw + obtain ⟨u,hu,hr⟩:=lift (h (f v) (f w) ((he v w).mpr hvw)) v rfl + exact (hf hu).symm ▸ hr + +end Diagram.Graph + +namespace SewnRectangle +variable {n : ℕ} + + +def port : Sum (PaddedColumn.V n) (PaddedColumn.V n) → HoneycombPort + | .inl (k,j,a) => ((-1-(k:ℤ),j.val),a) + | .inr (k,j,a) => (((k:ℤ),j.val),Tile.horizontalPort a) + +lemma port_injective : Function.Injective (port (n:=n)) := by + rintro (⟨k,j,a⟩|⟨k,j,a⟩) (⟨l,i,b⟩|⟨l,i,b⟩) h + all_goals simp only [port,Prod.mk.injEq] at h + · obtain ⟨⟨hk,hj⟩,rfl⟩:=h + have hk : k=l := by omega + have hj : j=i := Fin.ext hj + subst k j; rfl + · obtain ⟨⟨hk,_⟩,_⟩:=h; omega + · obtain ⟨⟨hk,_⟩,_⟩:=h; omega + · obtain ⟨⟨hk,hj⟩,ha⟩:=h + have hk : k=l := by omega + have hj : j=i := Fin.ext hj + have ha : a=b := Tile.horizontalPort.injective ha + subst k j a; rfl + +lemma mem_range_port (v : HoneycombPort) (hv : v.1.2 + rcases v with ⟨k,i,a⟩ + cases w with + | inl w => + rcases w with ⟨l',j,b⟩ + exact wiring_left D l r ht k l' i j a b + | inr w => + rcases w with ⟨l',j,b⟩ + exact wiring_cross D l r ht k l' i j a b + | inr v => + rcases v with ⟨k,i,a⟩ + cases w with + | inl w => + rcases w with ⟨l',j,b⟩ + have hs : D.portWiring (port (.inr (k,i,a))) (port (.inl (l',j,b))) ↔ + D.portWiring (port (.inl (l',j,b))) (port (.inr (k,i,a))) := + ⟨D.portWiring_symm,D.portWiring_symm⟩ + rw [hs,wiring_cross D l r ht l' k j i b a] + simp only [Patch.glued,and_comm] + | inr w => + rcases w with ⟨l',j,b⟩ + exact wiring_right D l r ht hr k l' i j a b + +lemma sewn_drains_iff (D : HoneycombAssignment n) (l r : List (Configuration n)) + (ht : D.tile=tile l r) (hr : ColumnChain.LocallyCompatible r) + (root : Sum (PaddedColumn.V n) (PaddedColumn.V n)) : + Graph.DrainsAt (Patch.glued (PaddedColumn.wiring l) (PaddedColumn.wiring r) + PaddedColumn.boundary PaddedColumn.boundary (PaddedColumn.active l)) root ↔ + Graph.DrainsAt D.portWiring (port root) := by + apply Graph.drainsAt_embedding_iff port port_injective (sewn_wiring D l r ht hr) + intro v w hvw + exact ⟨mem_range_port v (D.port_in_strip ((D.port_used v).mp ⟨w,hvw⟩)), + mem_range_port w (D.port_in_strip ((D.port_used w).mp ⟨v,D.portWiring_symm hvw⟩))⟩ + + + +theorem gluesAt_physical_iff (l r : List (Configuration n)) (p q : Pairing n) + (hl : ColumnChain.Runs (empty n) l p) (hr : ColumnChain.Runs (empty n) r q) + (D : HoneycombAssignment n) (ht : D.tile=tile l r) (root : Fin n) : + p.GluesAt root q ↔ p.Occupied root ∧ + (∀i, p.Occupied i ↔ q.Occupied i) ∧ + Graph.DrainsAt D.portWiring ((0,root.val),1) := by + have hl' := ColumnChain.runs_sound _ _ _ hl + have hr' := ColumnChain.runs_sound _ _ _ hr + have ha : PaddedColumn.active l=p.Occupied := by + funext i + exact propext ((ColumnChain.support_empty_read l i).symm.trans + (by rw [hl'.2.2])) + have hd := sewn_drains_iff D l r ht (ColumnChain.compatible_empty_iff r |>.mp hr'.1) + (.inr (PaddedColumn.boundary root)) + have hp := PaddedColumn.runs_realizes l p hl + have hq := PaddedColumn.runs_realizes r q hr + have hg := hp.sewn_drains_iff hq PaddedColumn.boundary_injective root + rw [ha] at hd + have he : port (.inr (PaddedColumn.boundary root))=((0,root.val),1) := rfl + rw [he] at hd + rw [Pairing.GluesAt,hd.symm,hg] + +end SewnRectangle +end +end CriticalStrip + +end OAI diff --git a/lean/OAI/Combinatorics/StripMass/SidePaths.lean b/lean/OAI/Combinatorics/StripMass/SidePaths.lean new file mode 100644 index 0000000000000000000000000000000000000000..f3a7971058f84d725c7d1003dfcdbc7ea610fadb --- /dev/null +++ b/lean/OAI/Combinatorics/StripMass/SidePaths.lean @@ -0,0 +1,462 @@ +import Mathlib +import OAI.Combinatorics.StripMass.ReflectionIntegrals +import OAI.Combinatorics.StripMass.ScalarBridge + +namespace OAI + +/-! Critical honeycomb strip paths, polynomial identities and crossing mass. -/ + + +namespace CriticalStrip +noncomputable section +open scoped BigOperators Classical + + + +def rotateTriangle (H : ℕ) (v : Triangle) : Triangle := + if v.2.1 < H then (-v.1,H-1-v.2.1,!v.2.2) else v + +lemma rotateTriangle_band_lt {H : ℕ} {v : Triangle} (h : v.2.1 cases b' <;> simp [adjacent,upDownAdjacent,rotateTriangle,hv,hw] + all_goals omega + +lemma PathBetween.rotate {H : ℕ} {a b : Triangle} {p : List Triangle} + (hp : PathBetween H a b p) : + PathBetween H (rotateTriangle H a) (rotateTriangle H b) (p.map (rotateTriangle H)) := by + refine ⟨?_,?_,hp.2.2.1.map (rotateTriangle_involutive H).injective,?_,?_⟩ + · rw [List.head?_map,hp.1]; rfl + · rw [List.getLast?_map,hp.2.1]; rfl + · apply (List.isChain_map _).mpr + apply hp.2.2.2.1.imp_of_mem_imp + intro v w hv hw h + exact (adjacent_rotate_iff (hp.2.2.2.2 v hv) (hp.2.2.2.2 w hw)).mpr h + · intro v hv + obtain ⟨w,hw,rfl⟩ := List.mem_map.mp hv + exact rotateTriangle_band_lt (hp.2.2.2.2 w hw) + +lemma PathBetween.append_vertex {H : ℕ} {a b v : Triangle} {p : List Triangle} + (hp : PathBetween H a b p) (hv : v.2.1 bridgeWeight H x.1 x.2) := by + apply (summable_prod_of_nonneg (fun x => bridgeWeight_nonneg _ _ _)).mpr + exact ⟨hH.2.1,hH.2.2.2.1⟩ + +lemma bridge_all_paths_tsum {H : ℕ} (hH : StripSumsFinite H) : + (∑' x : ℤ×List Triangle,bridgeWeight H x.1 x.2)=bridgeMass H := + (bridge_all_paths_summable hH).tsum_prod + + + +theorem stepSideWeight_summable {N : ℕ} (s : ℤ) (h : StripSumsFinite (N+1)) : + Summable (fun x : ℤ×List Triangle =>stepSideWeight N s x.1 x.2) := by + let e : (ℤ×List Triangle) → (ℤ×List Triangle) := + fun x => (s-1-x.1,sideToTallBridge N s x.2) + have he : Function.Injective e := by + intro x y h + have hi := congrArg Prod.fst h + have hp := (sideToTallBridge_injective N s) (congrArg Prod.snd h) + have hxy : x.1=y.1 := by dsimp [e] at hi; omega + exact Prod.ext hxy hp + have hg := (bridge_all_paths_summable h).comp_injective he + have hmul : Summable (fun x : ℤ×List Triangle =>rho * stepSideWeight N s x.1 x.2) := + hg.of_nonneg_of_le (fun x =>mul_nonneg rho_pos.le (stepSideWeight_nonneg _ _ _ _)) + (fun x =>sideToTallBridge_weight N s x.1 x.2) + exact (summable_mul_left_iff rho_pos.ne').mp hmul + +theorem stepSideMass_le_tall_bridge {N : ℕ} (s : ℤ) (h : StripSumsFinite (N+1)) : + rho * stepSideMass N s ≤ bridgeMass (N+1) := by + let e : (ℤ×List Triangle) → (ℤ×List Triangle) := + fun x => (s-1-x.1,sideToTallBridge N s x.2) + have he : Function.Injective e := by + intro x y h + have hi := congrArg Prod.fst h + have hp := (sideToTallBridge_injective N s) (congrArg Prod.snd h) + have hxy : x.1=y.1 := by dsimp [e] at hi; omega + exact Prod.ext hxy hp + have hs := stepSideWeight_summable s h + have hb := bridge_all_paths_summable h + have ht : rho * stepSideMass N s=∑' x : ℤ×List Triangle,rho * stepSideWeight N s x.1 x.2 := by + rw [tsum_mul_left,hs.tsum_prod]; rfl + rw [ht,←bridge_all_paths_tsum h] + exact (hs.mul_left rho).tsum_le_tsum_of_inj e he (fun _ _ =>bridgeWeight_nonneg _ _ _) + (fun x =>sideToTallBridge_weight N s x.1 x.2) hb + + + +def bridgeToSide (N : ℕ) (s k : ℤ) (p : List Triangle) : List Triangle := + p.map (translateTriangle (s-k)) ++ [up s N] + +lemma bridgeToSide_injective (N : ℕ) (s k : ℤ) : + Function.Injective (bridgeToSide N s k) := by + intro p q h + exact List.map_injective_iff.mpr (translateTriangle_injective (s-k)) + (List.append_cancel_right h) + +lemma bridgeToSide_spec {N : ℕ} (hN : 1≤N) (s k : ℤ) {p : List Triangle} + (hp : IsPath N (down k (N-1)) p) : + PathBetween (N+1) (up (s-k) 0) (up s N) (bridgeToSide N s k p) ∧ + (∀ v∈bridgeToSide N s k p,steppedDomain N s v) := by + have ht : PathBetween N (up (s-k) 0) (down s (N-1)) (p.map (translateTriangle (s-k))) := by + simpa using (show PathBetween N (up 0 0) (down k (N-1)) p from hp).translate (s-k) + have hn : up s N ∉ p.map (translateTriangle (s-k)) := by + intro h + exact (Nat.lt_irrefl N) (ht.2.2.2.2 _ h) + have hA : adjacent (down s (N-1)) (up s N) := by + apply Or.inr + exact ⟨rfl,rfl,Or.inr ⟨by change N=N-1+1; omega,rfl⟩⟩ + have ht' : PathBetween (N+1) (up (s-k) 0) (down s (N-1)) (p.map (translateTriangle (s-k))) := + ⟨ht.1,ht.2.1,ht.2.2.1,ht.2.2.2.1,fun v hv => (ht.2.2.2.2 v hv).trans_le (Nat.le_succ _)⟩ + refine ⟨ht'.append_vertex (Nat.lt_succ_self N) hn hA,?_⟩ + intro v hv + rcases List.mem_append.mp hv with hv|hv + · exact Or.inl (ht.2.2.2.2 v hv) + · have he : v=up s N := List.mem_singleton.mp hv + rw [he] + exact Or.inr ⟨rfl,le_rfl⟩ + +lemma bridgeToSide_weight {N : ℕ} (hN : 1≤N) (s k : ℤ) (p : List Triangle) : + rho * bridgeWeight N k p ≤ stepSideWeight N s (s-k) (bridgeToSide N s k p) := by + unfold bridgeWeight + split_ifs with hp + · rw [stepSideWeight,ite_eq_left (bridgeToSide_spec hN s k hp.2)] + simp [bridgeToSide,pow_succ,mul_comm] + · simp only [mul_zero] + exact stepSideWeight_nonneg _ _ _ _ + + + +theorem stepSideMass_ge_base_bridge {N : ℕ} (hN : 1≤N) (s : ℤ) + (h : StripSumsFinite (N+1)) (h₀ : StripSumsFinite N) : + rho * bridgeMass N ≤ stepSideMass N s := by + let e : (ℤ×List Triangle) → (ℤ×List Triangle) := + fun x => (s-x.1,bridgeToSide N s x.1 x.2) + have he : Function.Injective e := by + intro x y hxy + have hi := congrArg Prod.fst hxy + have h₁ : x.1=y.1 := by dsimp [e] at hi; omega + have hp := congrArg Prod.snd hxy + change bridgeToSide N s x.1 x.2=bridgeToSide N s y.1 y.2 at hp + rw [h₁] at hp + exact Prod.ext h₁ ((bridgeToSide_injective N s y.1) hp) + have hb := bridge_all_paths_summable h₀ + have hs := stepSideWeight_summable s h + have hsum : (∑' x : ℤ×List Triangle,stepSideWeight N s x.1 x.2)=stepSideMass N s := + hs.tsum_prod + rw [←hsum,←bridge_all_paths_tsum h₀,←tsum_mul_left] + exact Summable.tsum_le_tsum_of_inj e he (fun _ _ =>stepSideWeight_nonneg _ _ _ _) + (fun x =>bridgeToSide_weight hN s x.1 x.2) (hb.mul_left rho) hs + +end + + + + +noncomputable section +open scoped BigOperators Classical +open Filter Topology + +lemma stepArchKernel_translate (N : ℕ) (s i j q : ℤ) : + stepArchKernel N s (q+i) (q+j)=stepArchKernel N (s-q) i j := by + rw [stepArchKernel,←(translatePaths q).tsum_eq] + exact tsum_congr (stepArchWeight_translate N s i j q) + + +def stepCutKernel (N : ℕ) (s q : ℤ) (x : ℕ×ℕ) : ℝ := + stepArchKernel N s (q-(x.1:ℤ)) (q+(x.2:ℤ)+1) + +def stepCutMass (N : ℕ) (s q : ℤ) : ℝ := ∑' x,stepCutKernel N s q x + +lemma stepCutKernel_eq (N : ℕ) (s q : ℤ) (x : ℕ×ℕ) : + stepCutKernel N s q x=(∑' p,stepCutArchWeight N (s-q) (x,p)) := by + have ha : q-(x.1:ℤ)=q+(-(x.1:ℤ)) := by ring + have hb : q+(x.2:ℤ)+1=q+((x.2:ℤ)+1) := by ring + rw [stepCutKernel,ha,hb,stepArchKernel_translate] + rfl + +lemma stepCutKernel_summable {N : ℕ} (s q : ℤ) (h : StripSumsFinite (N+1)) : + Summable (stepCutKernel N s q) := by + exact (stepCutArchWeight_summable N (s-q) h).prod.congr + (fun x => (stepCutKernel_eq N s q x).symm) + +lemma stepCutMass_eq {N : ℕ} (s q : ℤ) (h : StripSumsFinite (N+1)) : + stepCutMass N s q=∑' x,stepCutArchWeight N (s-q) x := by + rw [stepCutMass,(stepCutArchWeight_summable N (s-q) h).tsum_prod] + exact tsum_congr (stepCutKernel_eq N s q) + + +lemma tsum_prod_split_column {f : ℕ×ℕ → ℝ} (hf : Summable f) : + (∑' x,f x)=(∑' a,f (a,0))+(∑' a,∑' b,f (a,b+1)) := by + have h₀ : Summable (fun a : ℕ =>f (a,0)) := + hf.comp_injective (fun a b h =>congrArg Prod.fst h) + have ht : Summable (fun x : ℕ×ℕ =>f (x.1,x.2+1)) := + hf.comp_injective (by intro a b h; apply Prod.ext <;> simp_all) + rw [hf.tsum_prod,←h₀.tsum_add ht.prod] + exact tsum_congr (fun a => (hf.prod_factor a).tsum_eq_zero_add) + + + +lemma tsum_array_difference {f g : ℕ×ℕ → ℝ} (hf : Summable f) (hg : Summable g) + (hfg : ∀ a b,f (a,b+1)=g (a+1,b)) : + (∑' x,f x)-(∑' x,g x)=(∑' a,f (a,0))-(∑' b,g (0,b)) := by + rw [tsum_prod_split_column hf,hg.tsum_prod,hg.prod.tsum_eq_zero_add] + have ht : (∑' a,∑' b,f (a,b+1))=∑' a,∑' b,g (a+1,b) := + tsum_congr (fun a =>tsum_congr (fun b =>hfg a b)) + rw [ht] + ring + +def stepArchLeft (N : ℕ) (s i : ℤ) : ℝ := + ∑' j : ℕ,stepArchKernel N s i (i-1-(j:ℤ)) + +def stepArchRight (N : ℕ) (s i : ℤ) : ℝ := + ∑' j : ℕ,stepArchKernel N s i (i+(j:ℤ)+1) + + + +theorem step_cut_divergence {N : ℕ} (s i : ℤ) (h : StripSumsFinite (N+1)) : + stepCutMass N s (i-1)-stepCutMass N s i=stepArchLeft N s i-stepArchRight N s i := by + have he (a b : ℕ) : stepCutKernel N s (i-1) (a,b+1)=stepCutKernel N s i (a+1,b) := by + unfold stepCutKernel + congr 1 <;> push_cast <;> ring + have hh := tsum_array_difference (stepCutKernel_summable s (i-1) h) + (stepCutKernel_summable s i h) he + have hl : (∑' a,stepCutKernel N s (i-1) (a,0))=stepArchLeft N s i := by + apply tsum_congr + intro a + simp only [stepCutKernel,Nat.cast_zero,add_zero,sub_add_cancel] + exact stepArchKernel_reverse _ _ _ _ + have hr : (∑' b,stepCutKernel N s i (0,b))=stepArchRight N s i := by + simp only [stepCutKernel,Nat.cast_zero,sub_zero,stepArchRight] + rw [hl,hr] at hh + exact hh + + + +def SteppedBoundaryFlux (N : ℕ) (s : ℤ) : Prop := + ∀ i : ℤ, Real.sin (3*lambda)*(stepArchLeft N s i-stepArchRight N s i)+ + Real.sin lambda*stepSideKernel N s i=0 + +lemma stepSideKernel_summable {N : ℕ} (s : ℤ) (h : StripSumsFinite (N+1)) : + Summable (stepSideKernel N s) := (stepSideWeight_summable s h).prod + + + +theorem step_moment_identity {N : ℕ} (s : ℤ) + (h : StripSumsFinite (N+1)) (h₀ : StripSumsFinite N) + (hflux : SteppedBoundaryFlux N s) : + Real.sin (3*lambda)*(moment (N+1)-moment N)=Real.sin lambda*stepSideMass N s := by + have hfin (L : ℕ) : Real.sin (3*lambda)* + (stepCutMass N s ((L:ℤ)-1)-stepCutMass N s (-(L:ℤ)-1)) = + Real.sin lambda * ∑ i ∈ Finset.Ico (-(L:ℤ)) (L:ℤ),stepSideKernel N s i := by + have hi (i : ℤ) : Real.sin lambda*stepSideKernel N s i= + Real.sin (3*lambda)*(stepCutMass N s i-stepCutMass N s (i-1)) := by + have hx := hflux i + rw [←step_cut_divergence s i h] at hx + linarith + rw [Finset.mul_sum] + simp_rw [hi] + rw [←Finset.mul_sum] + congr 1 + have hz := Finset.sum_Ico_int_sub L (fun i => stepCutMass N s (i-1)) + have hadd : ∀ i : ℤ,(i+1)-1=i := by intro i; ring + simp only [hadd] at hz + have hn : (∑ i ∈ Finset.Ico (-(L:ℤ)) (L:ℤ), + (stepCutMass N s i-stepCutMass N s (i-1)))= + -(∑ i ∈ Finset.Ico (-(L:ℤ)) (L:ℤ), + (stepCutMass N s (i-1)-stepCutMass N s i)) := by + rw [←Finset.sum_neg_distrib] + apply Finset.sum_congr rfl + intro i _ + ring + rw [hn,hz] + ring + have hr : Tendsto (fun L : ℕ=>stepCutMass N s ((L:ℤ)-1)) atTop (𝓝 (moment (N+1))) := by + have he (L : ℕ) : stepCutMass N s ((L:ℤ)-1)=∑' x,stepCutArchWeight N ((s+1)-(L:ℤ)) x := by + rw [stepCutMass_eq s _ h] + congr 3 + ring_nf + simpa only [he] using step_cut_mass_tall_limit (s+1) h + have hl : Tendsto (fun L : ℕ=>stepCutMass N s (-(L:ℤ)-1)) atTop (𝓝 (moment N)) := by + have he (L : ℕ) : stepCutMass N s (-(L:ℤ)-1)=∑' x,stepCutArchWeight N ((s+1)+(L:ℤ)) x := by + rw [stepCutMass_eq s _ h] + congr 3 + ring_nf + simpa only [he] using step_cut_mass_short_limit (s+1) h h₀ + have hz : Tendsto (fun L : ℕ=>∑ i ∈ Finset.Ico (-(L:ℤ)) (L:ℤ),stepSideKernel N s i) + atTop (𝓝 (stepSideMass N s)) := + (stepSideKernel_summable s h).hasSum.comp Finset.tendsto_Ico_neg + exact tendsto_nhds_unique ((hr.sub hl).const_mul _) ((hz.const_mul _).congr (fun L=>(hfin L).symm)) + +end + + + + +noncomputable section +open scoped BigOperators Classical + +lemma step_sines_pos : 0 < Real.sin lambda ∧ 0 < Real.sin (3*lambda) := by + constructor <;> apply Real.sin_pos_of_pos_of_lt_pi <;> + dsimp [lambda] <;> linarith [Real.pi_pos] + + + +theorem moment_increment_bounds_of_boundary {N : ℕ} (hN : 1≤N) (s : ℤ) + (h : StripSumsFinite (N+1)) (h₀ : StripSumsFinite N) + (hflux : SteppedBoundaryFlux N s) + (hF₀ : c*archMass N+bridgeMass N=1) + (hF₁ : c*archMass (N+1)+bridgeMass (N+1)=1) : + ((Real.sin lambda/Real.sin (3*lambda))*rho)*bridgeMass N ≤ moment (N+1)-moment N ∧ + moment (N+1)-moment N ≤ ((Real.sin lambda/Real.sin (3*lambda))/rho)*bridgeMass N := by + have hs := step_sines_pos + have he := step_moment_identity s h h₀ hflux + have hm : moment (N+1)-moment N = + (Real.sin lambda / Real.sin (3*lambda))*stepSideMass N s := by + apply (mul_left_cancel₀ hs.2.ne') + calc + Real.sin (3*lambda)*(moment (N+1)-moment N)= + Real.sin lambda*stepSideMass N s := he + _=Real.sin (3*lambda)*((Real.sin lambda/Real.sin (3*lambda))*stepSideMass N s) := by + field_simp [hs.2.ne'] + have hmono : bridgeMass (N+1)≤bridgeMass N := + bridgeMass_le_of_finite_and_flux (Nat.le_succ N) h hF₀ hF₁ + have hupper : rho*stepSideMass N s≤bridgeMass N := (stepSideMass_le_tall_bridge s h).trans hmono + have hlower := stepSideMass_ge_base_bridge hN s h h₀ + have hβ : 0≤Real.sin lambda/Real.sin (3*lambda) := (div_pos hs.1 hs.2).le + constructor + · rw [hm,mul_assoc] + exact mul_le_mul_of_nonneg_left hlower hβ + · have hsu : stepSideMass N s≤bridgeMass N/rho := + (le_div_iff₀ rho_pos).mpr (by simpa [mul_comm] using hupper) + have hu := mul_le_mul_of_nonneg_left hsu hβ + simpa only [hm,div_eq_mul_inv,mul_assoc,mul_comm,mul_left_comm] using hu + + + +theorem increment_comparable_of_boundary + (hfinite : ∀ N : ℕ,1≤N → StripSumsFinite N) + (hstrip : ∀ N : ℕ,1≤N → c*archMass N+bridgeMass N=1) + (hstep : ∀ N : ℕ,1≤N → ∃ s : ℤ,SteppedBoundaryFlux N s) : + Comparable (fun N =>moment (N+1)-moment N) bridgeMass := by + have hs := step_sines_pos + refine ⟨(Real.sin lambda/Real.sin (3*lambda))*rho, + (Real.sin lambda/Real.sin (3*lambda))/rho, + mul_pos (div_pos hs.1 hs.2) rho_pos,div_pos (div_pos hs.1 hs.2) rho_pos,?_⟩ + intro N hN + obtain ⟨s,h⟩ := hstep N hN + exact moment_increment_bounds_of_boundary hN s (hfinite (N+1) (by omega)) + (hfinite N hN) h (hstrip N hN) (hstrip (N+1) (by omega)) + + + +theorem criticalStripMass_of_physical_identities + (hfinite : ∀ N : ℕ,1≤N → StripSumsFinite N) + (hstrip : ∀ N : ℕ,1≤N → c*archMass N+bridgeMass N=1) + (hstep : ∀ N : ℕ,1≤N → ∃ s : ℤ,SteppedBoundaryFlux N s) + (hArch : ∀ N : ℕ,1≤N → ∃ g : Polynomial ℝ, + MonicProblem N g ∧ moment N=(N:ℝ)*C-eta*g.coeff (N-1)) : + CriticalStripMass := by + apply criticalStripMass_iff_four_estimates.mpr + refine ⟨hfinite,hstrip,increment_comparable_of_boundary hfinite hstrip hstep,?_⟩ + obtain ⟨lo,hi,hl,hh,hg⟩ := homogeneous_arch_coefficient_growth + refine ⟨lo,hi,hl,hh,?_⟩ + intro N hN + obtain ⟨g,hgm,he⟩ := hArch N hN + simpa only [he] using hg N hN g hgm + +end +end CriticalStrip + +end OAI diff --git a/lean/OAI/Combinatorics/StripMass/Specialization.lean b/lean/OAI/Combinatorics/StripMass/Specialization.lean new file mode 100644 index 0000000000000000000000000000000000000000..caf8705db9a222dab9612c8bfe7e59d894980881 --- /dev/null +++ b/lean/OAI/Combinatorics/StripMass/Specialization.lean @@ -0,0 +1,568 @@ +import Mathlib +import OAI.Combinatorics.StripMass.LaurentNumerator + +namespace OAI + +/-! Critical honeycomb strip paths, polynomial identities and crossing mass. -/ + + + + + +namespace CriticalStrip.Diagram +noncomputable section + +variable {R F K : Type*} [CommRing R] [IsDomain R] [Field F] [Field K] + [Algebra R F] [IsFractionRing R F] + + +def RationalAt (φ : R →+* K) (x : F) (y : K) : Prop := + ∃ a b : R, φ b ≠ 0 ∧ x * algebraMap R F b = algebraMap R F a ∧ y * φ b = φ a + +namespace RationalAt +variable {φ : R →+* K} {x x' : F} {y y' : K} + +omit [IsDomain R] [IsFractionRing R F] in +theorem algebraMap (a : R) : RationalAt φ (algebraMap R F a) (φ a) := by + exact ⟨a, 1, by simp, by simp, by simp⟩ + +omit [IsDomain R] [IsFractionRing R F] in +theorem zero : RationalAt φ (0 : F) (0 : K) := by + simpa using (algebraMap (φ := φ) (F := F) (0 : R)) + +omit [IsDomain R] [IsFractionRing R F] in +theorem one : RationalAt φ (1 : F) (1 : K) := by + simpa using (algebraMap (φ := φ) (F := F) (1 : R)) + +omit [IsDomain R] in +theorem unique (h : RationalAt φ x y) (h' : RationalAt φ x y') : y = y' := by + obtain ⟨a, b, hb, he, hv⟩ := h + obtain ⟨a', b', hb', he', hv'⟩ := h' + have hab : a * b' = a' * b := by + apply IsFractionRing.injective R F + rw [map_mul, map_mul, ← he, ← he'] + ring + have hvv := congrArg φ hab + simp only [map_mul, ← hv, ← hv'] at hvv + apply mul_right_cancel₀ (mul_ne_zero hb hb') + calc + y * (φ b * φ b') = (y * φ b) * φ b' := by ring + _ = (y' * φ b') * φ b := hvv + _ = y' * (φ b * φ b') := by ring + +omit [IsDomain R] [IsFractionRing R F] in +theorem add (h : RationalAt φ x y) (h' : RationalAt φ x' y') : + RationalAt φ (x+x') (y+y') := by + obtain ⟨a,b,hb,he,hv⟩ := h + obtain ⟨a',b',hb',he',hv'⟩ := h' + refine ⟨a*b'+a'*b, b*b', by simpa using mul_ne_zero hb hb', ?_, ?_⟩ + · simp only [_root_.map_mul, _root_.map_add, ← he, ← he']; ring + · simp only [_root_.map_mul, _root_.map_add, ← hv, ← hv']; ring + +omit [IsDomain R] [IsFractionRing R F] in +theorem mul (h : RationalAt φ x y) (h' : RationalAt φ x' y') : + RationalAt φ (x*x') (y*y') := by + obtain ⟨a,b,hb,he,hv⟩ := h + obtain ⟨a',b',hb',he',hv'⟩ := h' + refine ⟨a*a', b*b', by simpa using mul_ne_zero hb hb', ?_, ?_⟩ + · simp only [_root_.map_mul, ← he, ← he']; ring + · simp only [_root_.map_mul, ← hv, ← hv']; ring + +omit [IsDomain R] [IsFractionRing R F] in +theorem neg (h : RationalAt φ x y) : RationalAt φ (-x) (-y) := by + obtain ⟨a,b,hb,he,hv⟩ := h + exact ⟨-a,b,hb, by simp [← he], by simp [← hv]⟩ + +omit [IsDomain R] [IsFractionRing R F] in +theorem sub (h : RationalAt φ x y) (h' : RationalAt φ x' y') : + RationalAt φ (x-x') (y-y') := by simpa only [sub_eq_add_neg] using h.add h'.neg + +omit [IsDomain R] in +theorem ne_zero (h : RationalAt φ x y) (hy : y ≠ 0) : x ≠ 0 := by + intro hx + rw [hx] at h + exact hy (h.unique zero) + +omit [IsDomain R] in +theorem inv (h : RationalAt φ x y) (hy : y ≠ 0) : RationalAt φ x⁻¹ y⁻¹ := by + have hx := h.ne_zero hy + obtain ⟨a,b,hb,he,hv⟩ := h + refine ⟨b,a, by rw [← hv]; exact mul_ne_zero hy hb, ?_, ?_⟩ + · rw [← he, ← mul_assoc, inv_mul_cancel₀ hx, one_mul] + · rw [← hv, ← mul_assoc, inv_mul_cancel₀ hy, one_mul] + +omit [IsDomain R] in +theorem div (h : RationalAt φ x y) (h' : RationalAt φ x' y') (hy' : y' ≠ 0) : + RationalAt φ (x/x') (y/y') := by + simpa only [div_eq_mul_inv] using h.mul (h'.inv hy') + +omit [IsDomain R] [IsFractionRing R F] in +theorem pow (h : RationalAt φ x y) (n : ℕ) : RationalAt φ (x^n) (y^n) := by + induction n with + | zero => simpa using (one (φ := φ) (F := F)) + | succ n ih => simpa only [pow_succ] using ih.mul h + +omit [IsDomain R] [IsFractionRing R F] in +theorem natCast (n : ℕ) : RationalAt φ (n : F) (n : K) := by + simpa using (algebraMap (φ := φ) (F := F) (n : R)) + +omit [IsDomain R] [IsFractionRing R F] in +theorem intCast (n : ℤ) : RationalAt φ (n : F) (n : K) := by + simpa using (algebraMap (φ := φ) (F := F) (n : R)) + +omit [IsDomain R] [IsFractionRing R F] in +theorem sum {ι : Type*} (s : Finset ι) (f : ι → F) (g : ι → K) + (h : ∀ i ∈ s, RationalAt φ (f i) (g i)) : + RationalAt φ (∑ i ∈ s, f i) (∑ i ∈ s, g i) := by + classical + induction s using Finset.induction_on with + | empty => simpa using (zero (φ := φ) (F := F)) + | @insert i s hi ih => + simp only [Finset.sum_insert hi] + exact (h i (Finset.mem_insert_self _ _)).add (ih (fun j hj => h j (Finset.mem_insert_of_mem hj))) + +omit [IsDomain R] [IsFractionRing R F] in +theorem prod {ι : Type*} (s : Finset ι) (f : ι → F) (g : ι → K) + (h : ∀ i ∈ s, RationalAt φ (f i) (g i)) : + RationalAt φ (∏ i ∈ s, f i) (∏ i ∈ s, g i) := by + classical + induction s using Finset.induction_on with + | empty => simpa using (one (φ := φ) (F := F)) + | @insert i s hi ih => + simp only [Finset.prod_insert hi] + exact (h i (Finset.mem_insert_self _ _)).mul (ih (fun j hj => h j (Finset.mem_insert_of_mem hj))) + +end RationalAt +end + + + + + +noncomputable section +variable {R F K : Type*} [CommRing R] [IsDomain R] [Field F] [Field K] + [Algebra R F] [IsFractionRing R F] {φ : R →+* K} + +namespace RationalAt + +omit [IsDomain R] [IsFractionRing R F] in +theorem det {ι : Type*} [Fintype ι] [DecidableEq ι] + (A : Matrix ι ι F) (B : Matrix ι ι K) + (h : ∀ i j, RationalAt φ (A i j) (B i j)) : RationalAt φ A.det B.det := by + classical + simp only [Matrix.det_apply, Units.smul_def, zsmul_eq_mul] + apply sum + intro σ _ + exact (intCast _).mul (prod _ _ _ (fun i _ => h (σ i) i)) + +omit [IsDomain R] [IsFractionRing R F] in +theorem matrixOne {ι : Type*} [DecidableEq ι] (i j : ι) : + RationalAt φ ((1 : Matrix ι ι F) i j) ((1 : Matrix ι ι K) i j) := by + classical + by_cases h : i = j + · subst j; simpa using (one (φ := φ) (F := F)) + · simpa [Matrix.one_apply, h] using (zero (φ := φ) (F := F)) + +omit [IsDomain R] [IsFractionRing R F] in +theorem adjugate {ι : Type*} [Fintype ι] [DecidableEq ι] + (A : Matrix ι ι F) (B : Matrix ι ι K) + (h : ∀ i j, RationalAt φ (A i j) (B i j)) (i j : ι) : + RationalAt φ (A.adjugate i j) (B.adjugate i j) := by + rw [Matrix.adjugate_apply, Matrix.adjugate_apply] + apply det + intro a b + by_cases ha : a = j + · subst a + simp only [Matrix.updateRow_self] + by_cases hb : b = i + · subst b; simpa using (one (φ := φ) (F := F)) + · simpa [Pi.single_apply, hb] using (zero (φ := φ) (F := F)) + · simp only [Matrix.updateRow_ne ha] + exact h a b + +omit [IsDomain R] in +theorem nonsingInv {ι : Type*} [Fintype ι] [DecidableEq ι] + (A : Matrix ι ι F) (B : Matrix ι ι K) + (h : ∀ i j, RationalAt φ (A i j) (B i j)) (hB : B.det ≠ 0) (i j : ι) : + RationalAt φ (A⁻¹ i j) (B⁻¹ i j) := by + simp only [Matrix.inv_def, Ring.inverse_eq_inv, Matrix.smul_apply, smul_eq_mul] + exact ((det A B h).inv hB).mul (adjugate A B h i j) + +omit [IsDomain R] [IsFractionRing R F] in +theorem mulVec {ι κ : Type*} [Fintype κ] + (A : Matrix ι κ F) (B : Matrix ι κ K) (v : κ → F) (w : κ → K) + (hA : ∀ i j, RationalAt φ (A i j) (B i j)) + (hv : ∀ j, RationalAt φ (v j) (w j)) (i : ι) : + RationalAt φ (A.mulVec v i) (B.mulVec w i) := by + apply sum + intro j _ + exact (hA i j).mul (hv j) + +end RationalAt + + + +omit [IsDomain R] [IsFractionRing R F] in +theorem rationalAt_column {n : ℕ} (w : Fin n → Weights F) (v : Fin n → Weights K) + (h : ∀ i t, RationalAt φ ((w i).tile t) ((v i).tile t)) (p q : Pairing n) : + RationalAt φ (column w p q) (column v p q) := by + classical + unfold column + apply RationalAt.sum + intro t _ + split_ifs + · exact RationalAt.prod _ _ _ (fun i _ => h i (t i)) + · exact RationalAt.zero + + + +omit [IsDomain R] in +theorem rationalAt_normalizedVacuum {n : ℕ} + (w : Fin n → Weights F) (v : Fin n → Weights K) + (h : ∀ i t, RationalAt φ ((w i).tile t) ((v i).tile t)) + (hv : VacuumRegular v) (p : Pairing n) : + RationalAt φ (normalizedVacuum w p) (normalizedVacuum v p) := by + classical + unfold normalizedVacuum attachEmpty + split_ifs + · exact RationalAt.one + · apply RationalAt.mulVec + · apply RationalAt.nonsingInv + · intro i j + exact (RationalAt.matrixOne i j).sub (rationalAt_column w v h i.val j.val) + · exact hv + · intro q + exact rationalAt_column w v h q.val (empty n) + +end + + + + + +noncomputable section +open Finset + + + +def torusCharacter {n k : ℕ} (z : Fin n → SpectralField k) (hz : ∀ i, z i ≠ 0) : + Multiplicative (Fin n → ℤ) →* SpectralField k where + toFun e := ∏ i, z i ^ e.toAdd i + map_one' := by simp + map_mul' e f := by + change (∏ i, z i ^ (e.toAdd i + f.toAdd i)) = _ + simp only [zpow_add₀ (hz _), prod_mul_distrib] + +def torusEvaluation {n k : ℕ} (z : Fin n → SpectralField k) (hz : ∀ i, z i ≠ 0) : + Laurent n →ₐ[ℂ] SpectralField k := + AddMonoidAlgebra.lift ℂ (SpectralField k) (Fin n → ℤ) (torusCharacter z hz) + +@[simp] theorem torusEvaluation_monomial {n k : ℕ} (z : Fin n → SpectralField k) + (hz : ∀ i, z i ≠ 0) (e : Fin n → ℤ) (c : ℂ) : + torusEvaluation z hz (monomialL e c) = constF k c * ∏ i, z i ^ e i := by + simp [torusEvaluation, monomialL, AddMonoidAlgebra.lift_single, torusCharacter, constF, Algebra.smul_def] + +@[simp] theorem torusEvaluation_constant {n k : ℕ} (z : Fin n → SpectralField k) + (hz : ∀ i, z i ≠ 0) (c : ℂ) : + torusEvaluation z hz (constantL n c) = constF k c := by + change torusEvaluation z hz (monomialL 0 c) = _ + simp + +@[simp] theorem torusEvaluation_variable {n k : ℕ} (z : Fin n → SpectralField k) + (hz : ∀ i, z i ≠ 0) (i : Fin n) : + torusEvaluation z hz (monomialL (variableExponent i) 1) = z i := by + simp [variableExponent, Pi.single_apply, constF] + + + +theorem rationalAt_const {n k : ℕ} (φ : Laurent n →ₐ[ℂ] SpectralField k) (c : ℂ) : + RationalAt φ.toRingHom (constF n c) (constF k c) := by + have h := RationalAt.algebraMap (φ := φ.toRingHom) (F := SpectralField n) (constantL n c) + rw [map_constantL] at h + have he : φ (constantL n c) = constF k c := φ.commutes c + simpa only [AlgHom.toRingHom_eq_coe, AlgHom.coe_toRingHom, he] using h + +theorem rationalAt_variable {n k : ℕ} (z : Fin n → SpectralField k) + (hz : ∀ i, z i ≠ 0) (i : Fin n) : + RationalAt (torusEvaluation z hz).toRingHom (variableF i) (z i) := by + have h := RationalAt.algebraMap (φ := (torusEvaluation z hz).toRingHom) + (F := SpectralField n) (monomialL (variableExponent i) 1) + change RationalAt (torusEvaluation z hz).toRingHom (variableF i) + (torusEvaluation z hz (monomialL (variableExponent i) 1)) at h + simpa only [torusEvaluation_variable] using h + +theorem rationalAt_torusSin {n k : ℕ} (φ : Laurent n →ₐ[ℂ] SpectralField k) + {x : SpectralField n} {z : SpectralField k} + (h : RationalAt φ.toRingHom x z) (hz : z ≠ 0) : + RationalAt φ.toRingHom (torusSin x) (torusSin z) := by + have hc : constF k (2*Complex.I) ≠ 0 := by + apply (map_ne_zero (algebraMap ℂ (SpectralField k))).mpr + exact mul_ne_zero (by norm_num) Complex.I_ne_zero + have hd : RationalAt φ.toRingHom (2 * constF n Complex.I) (2 * constF k Complex.I) := + (RationalAt.natCast 2).mul (rationalAt_const φ Complex.I) + apply (h.sub (h.inv hz)).div hd + simpa only [constF, map_mul, map_ofNat] using hc + +theorem rationalAt_torusCos {n k : ℕ} (φ : Laurent n →ₐ[ℂ] SpectralField k) + {x : SpectralField n} {z : SpectralField k} + (h : RationalAt φ.toRingHom x z) (hz : z ≠ 0) : + RationalAt φ.toRingHom (torusCos x) (torusCos z) := by + exact (h.add (h.inv hz)).div (RationalAt.natCast 2) (by exact two_ne_zero) + +theorem rationalAt_torusL {n k : ℕ} (φ : Laurent n →ₐ[ℂ] SpectralField k) + {x : SpectralField n} {z : SpectralField k} + (h : RationalAt φ.toRingHom x z) (hz : z ≠ 0) : + RationalAt φ.toRingHom (torusL x) (torusL z) := by + exact (rationalAt_torusSin φ (((rationalAt_const φ phase).pow 2).mul h) + (mul_ne_zero (pow_ne_zero _ (constF_phase_ne_zero k)) hz)).mul + (rationalAt_torusSin φ (((rationalAt_const φ phase).pow 3).mul h) + (mul_ne_zero (pow_ne_zero _ (constF_phase_ne_zero k)) hz)) + +theorem rationalAt_torusWeights {n k : ℕ} (φ : Laurent n →ₐ[ℂ] SpectralField k) + {x : SpectralField n} {z : SpectralField k} + (h : RationalAt φ.toRingHom x z) (hz : z ≠ 0) (hL : torusL z ≠ 0) (t : Tile) : + RationalAt φ.toRingHom ((torusWeights x).tile t) ((torusWeights z).tile t) := by + have hq := rationalAt_const φ phase + have hd := rationalAt_const φ d + have hs := rationalAt_torusSin φ h hz + have ht := rationalAt_torusSin φ ((hq.pow 3).div h hz) + (div_ne_zero (pow_ne_zero _ (constF_phase_ne_zero k)) hz) + have hv := rationalAt_torusSin φ ((hq.pow 2).div h hz) + (div_ne_zero (pow_ne_zero _ (constF_phase_ne_zero k)) hz) + have hu := rationalAt_torusSin φ (h.div hq (constF_phase_ne_zero k)) + (div_ne_zero hz (constF_phase_ne_zero k)) + have hden := rationalAt_torusL φ h hz + cases t + · exact RationalAt.one + · exact (hd.mul ht).div hden hL + · exact (hd.mul ht).div hden hL + · exact (hs.mul ht).div hden hL + · exact (hs.mul ht).div hden hL + · exact (hd.mul hs).div hden hL + · exact (hd.mul hs).div hden hL + · exact (ht.mul hv).div hden hL + · exact (hu.mul hs).div hden hL + +end + + + + + +noncomputable section +open scoped Classical + +def copiedNodeWeights {m n : ℕ} (v : Fin m → Fin n) (i : Fin n) : + Fin (m+1) → Weights (SpectralField n) := + Fin.snoc (fun j => spectralWeights n (v j)) (torusWeights (variableF i)⁻¹) + + + +theorem copiedNode_regular {m n : ℕ} (v : Fin m → Fin n) (i : Fin n) : + VacuumRegular (copiedNodeWeights v i) := by + apply regular_of_cleared_specialization + (algebraMap (SpectralRing n) (SpectralField n)) + (IsFractionRing.injective (SpectralRing n) (SpectralField n)) (flatEval n).toRingHom + (Fin.snoc (fun j => rowDenominator (v j)) (inverseRowDenominator i)) + (Fin.snoc (fun j => rowNumerator (v j)) (inverseRowNumerator i)) + (copiedNodeWeights v i) (Fin.snoc (fun _ => deletionWeights) identityWeights) + · intro j + induction j using Fin.lastCases with + | last => simpa using inverseRowDenominator_flat_ne_zero i + | cast j => simpa using flatEval_rowDenominator_ne_zero (v j) + · intro j t + induction j using Fin.lastCases with + | last => simpa only [evalLaurent,copiedNodeWeights,Fin.snoc_last] using inverseRowNumerator_map i t + | cast j => simpa only [copiedNodeWeights,Fin.snoc_castSucc] using rowNumerator_map (v j) t + · intro j t + induction j using Fin.lastCases with + | last => simpa only [AlgHom.toRingHom_eq_coe,AlgHom.coe_toRingHom,Fin.snoc_last] + using inverseRowNumerator_flat i t + | cast j => simpa only [AlgHom.toRingHom_eq_coe,AlgHom.coe_toRingHom,Fin.snoc_castSucc] + using rowNumerator_flatEval (v j) t + · unfold VacuumRegular + rw [det_one_nonflat] + · exact one_ne_zero + · intro j k hj hk + induction j using Fin.lastCases with + | last => exact (hj (Or.inl (Fin.snoc_last ..))).elim + | cast j => exact (hj (Or.inr (Fin.snoc_castSucc ..))).elim + +def copyEvaluation {m n : ℕ} (v : Fin m → Fin n) : Laurent m →ₐ[ℂ] SpectralField n := + torusEvaluation (fun j => variableF (v j)) (fun j => variableF_ne_zero (v j)) + +lemma rationalAt_copy_variable {m n : ℕ} (v : Fin m → Fin n) (i : Fin m) : + RationalAt (copyEvaluation v).toRingHom (variableF i) (variableF (v i)) := + rationalAt_variable _ _ i + +lemma rationalAt_copy_deletionNode {m n : ℕ} (v : Fin m → Fin n) (i : Fin m) : + RationalAt (copyEvaluation v).toRingHom (deletionNode i) (deletionNode (v i)) := + (rationalAt_copy_variable v i).mul ((rationalAt_const (copyEvaluation v) phase).pow 3) + +lemma rationalAt_copy_spectralA {m n : ℕ} (v : Fin m → Fin n) (i : Fin m) : + RationalAt (copyEvaluation v).toRingHom (spectralA i) (spectralA (v i)) := by + apply rationalAt_torusCos + · exact ((rationalAt_copy_variable v i).pow 2).div + ((rationalAt_const (copyEvaluation v) phase).pow 3) (pow_ne_zero _ (constF_phase_ne_zero n)) + · exact div_ne_zero (pow_ne_zero _ (variableF_ne_zero (v i))) (pow_ne_zero _ (constF_phase_ne_zero n)) + +lemma rationalAt_copy_deletionBeta {m n : ℕ} (v : Fin m → Fin n) (i : Fin m) : + RationalAt (copyEvaluation v).toRingHom (deletionBeta i) (deletionBeta (v i)) := by + apply rationalAt_torusCos + · exact ((rationalAt_copy_deletionNode v i).pow 2).div + ((rationalAt_const (copyEvaluation v) phase).pow 3) (pow_ne_zero _ (constF_phase_ne_zero n)) + · exact div_ne_zero (pow_ne_zero _ (mul_ne_zero (variableF_ne_zero (v i)) + (pow_ne_zero _ (constF_phase_ne_zero n)))) (pow_ne_zero _ (constF_phase_ne_zero n)) + +lemma rationalAt_copy_weights {m n : ℕ} (v : Fin m → Fin n) (i : Fin m) + (j : Fin (m+1)) (t : Tile) : + RationalAt (copyEvaluation v).toRingHom ((nodalWeights i j).tile t) + ((copiedNodeWeights v (v i) j).tile t) := by + induction j using Fin.lastCases with + | cast j => + simp only [nodalWeights,copiedNodeWeights,Fin.snoc_castSucc,spectralWeights] + apply rationalAt_torusWeights + · exact ((rationalAt_const (copyEvaluation v) phase).pow 3).div + (rationalAt_copy_variable v j) (variableF_ne_zero _) + · exact div_ne_zero (pow_ne_zero _ (constF_phase_ne_zero n)) (variableF_ne_zero _) + · rw [←rowDenominator_map] + exact rowDenominator_map_ne_zero _ + | last => + simp only [nodalWeights_last,copiedNodeWeights,Fin.snoc_last] + apply rationalAt_torusWeights + · exact (rationalAt_copy_variable v i).inv (variableF_ne_zero _) + · exact inv_ne_zero (variableF_ne_zero _) + · rw [←inverseRowDenominator_map] + exact inverseRowDenominator_map_ne_zero _ + +lemma rationalAt_copy_vacuum {m n : ℕ} (v : Fin m → Fin n) (i : Fin m) (p : Pairing (m+1)) : + RationalAt (copyEvaluation v).toRingHom + (normalizedVacuum (nodalWeights i) p) + (normalizedVacuum (copiedNodeWeights v (v i)) p) := + rationalAt_normalizedVacuum _ _ (rationalAt_copy_weights v i) (copiedNode_regular v (v i)) p + + + + + + + +lemma RationalAt.mv_eval {R F K C σ : Type*} [CommRing R] [IsDomain R] + [Field F] [Field K] [Algebra R F] [IsFractionRing R F] [CommRing C] + {φ : R →+* K} (c : C →+* F) (d : C →+* K) (v : σ → F) (w : σ → K) + (hc : ∀ z,RationalAt φ (c z) (d z)) (hv : ∀ i,RationalAt φ (v i) (w i)) + (p : MvPolynomial σ C) : + RationalAt φ (MvPolynomial.eval₂Hom c v p) (MvPolynomial.eval₂Hom d w p) := by + induction p using MvPolynomial.induction_on with + | C z => simpa using hc z + | add p q hp hq => simpa only [map_add] using hp.add hq + | mul_X p i hp => simpa only [map_mul,MvPolynomial.eval₂Hom_X'] using hp.mul (hv i) + +def copiedNodeScalar {m n : ℕ} (v : Fin m → Fin n) (i : Fin n) : SpectralField n := + MvPolynomial.eval₂Hom (algebraMap ℂ (SpectralField n)) + (Fin.snoc (fun j => spectralA (v j)) (deletionBeta i)) + (scalarPolynomial (m+1) d rho (by exact_mod_cast d_ne_zero)) + +lemma rationalAt_copy_scalar {m n : ℕ} (v : Fin m → Fin n) (i : Fin m) : + RationalAt (copyEvaluation v).toRingHom (nodalScalar i) (copiedNodeScalar v (v i)) := by + apply RationalAt.mv_eval + · exact rationalAt_const (copyEvaluation v) + · intro j + induction j using Fin.lastCases with + | last => simpa using rationalAt_copy_deletionBeta v i + | cast j => simpa using rationalAt_copy_spectralA v j + +lemma rationalAt_copy_nodalVacuum {m n : ℕ} (v : Fin m → Fin n) (i : Fin m) + (p : Pairing (m+1)) : + RationalAt (copyEvaluation v).toRingHom (nodalVacuum i p) + (copiedNodeScalar v (v i)*normalizedVacuum (copiedNodeWeights v (v i)) p) := + (rationalAt_copy_scalar v i).mul (rationalAt_copy_vacuum v i p) + + + +theorem nodalVacuum_collision {m n : ℕ} (v : Fin m → Fin n) (i j : Fin m) + (hij:v i=v j) (p : Pairing (m+1)) : + ∃ y : SpectralField n, + RationalAt (copyEvaluation v).toRingHom (nodalVacuum i p) y ∧ + RationalAt (copyEvaluation v).toRingHom (nodalVacuum j p) y := by + refine ⟨_,rationalAt_copy_nodalVacuum v i p,?_⟩ + rw [hij] + exact rationalAt_copy_nodalVacuum v j p + + +theorem occupied_nodal_collision {m n : ℕ} (v : Fin m → Fin n) (i j : Fin m) + (hij:v i=v j) (p : Pairing (m+1)) : + ∃ y : SpectralField n, + RationalAt (copyEvaluation v).toRingHom (nodalVacuum i p/torusSin (deletionNode i)) y ∧ + RationalAt (copyEvaluation v).toRingHom (nodalVacuum j p/torusSin (deletionNode j)) y := by + have hi:=rationalAt_torusSin (copyEvaluation v) (rationalAt_copy_deletionNode v i) + (mul_ne_zero (variableF_ne_zero (v i)) (pow_ne_zero _ (constF_phase_ne_zero n))) + have hj:=rationalAt_torusSin (copyEvaluation v) (rationalAt_copy_deletionNode v j) + (mul_ne_zero (variableF_ne_zero (v j)) (pow_ne_zero _ (constF_phase_ne_zero n))) + obtain ⟨y,hy,hz⟩:=nodalVacuum_collision v i j hij p + refine ⟨y/torusSin (deletionNode (v i)),hy.div hi (deletionNode_sine_ne_zero _),?_⟩ + rw [hij] + exact hz.div hj (deletionNode_sine_ne_zero _) + +end + + + + + +noncomputable section +open scoped Classical LaurentPolynomial + +def evalMonomialCharacter (n : ℕ) : Multiplicative (Fin n → ℤ) →* SpectralField n where + toFun e:=evalLaurent (monomialL e.toAdd 1) + map_one' := by simp [evalLaurent] + map_mul' e f:=by + change evalLaurent (monomialL (e.toAdd+f.toAdd) 1)=_ + simp only [evalLaurent] + rw [←map_mul] + simp only [monomialL_mul,mul_one] + +lemma evalLaurent_monomial_product {n : ℕ} (e : Fin n → ℤ) (z : ℂ) : + evalLaurent (monomialL e z)=constF n z*∏ i,variableF i ^ e i := by + rw [evalLaurent,map_monomialL_factor] + congr 1 + have he : e=∑ i:Fin n,(e i) • variableExponent i := by + funext j + simp [variableExponent,Pi.single_apply] + change evalMonomialCharacter n (Multiplicative.ofAdd e)=_ + rw [he] + simp only [ofAdd_sum,map_prod,ofAdd_zsmul,map_zpow] + rw [←he] + rfl + +lemma evalLaurent_unit_zpow {n : ℕ} (u : (Laurent n)ˣ) (k : ℤ) : + evalLaurent ((u^k : (Laurent n)ˣ):Laurent n)=(evalLaurent (u:Laurent n))^k := + ((algebraMap (SpectralRing n) (SpectralField n)).toMonoidHom.comp (Units.coeHom _)).map_zpow u k + +lemma substituteLaurent_monomial {n : ℕ} (i : Fin (n+1)) (u : (Laurent n)ˣ) + (e : Fin (n+1) → ℤ) (z : ℂ) : + substituteLaurent i u (monomialL e z)=monomialL (Fin.removeNth i e) z * (u^(e i):(Laurent n)ˣ) := by + change LaurentPolynomial.eval₂ (RingHom.id _) u (peelLaurentEquiv i _)=_ + rw [peelLaurentEquiv_monomial,LaurentPolynomial.single_eq_C_mul_T,LaurentPolynomial.eval₂_C_mul_T] + rfl + +lemma substitution_torusEvaluation {n : ℕ} (i : Fin (n+1)) (u : (Laurent n)ˣ) + (v : Fin (n+1) → SpectralField n) (hv:∀ j,v j≠0) + (hi:v i=evalLaurent (u:Laurent n)) (hj:∀ j,v (i.succAbove j)=variableF j) (f : Laurent (n+1)) : + torusEvaluation v hv f=evalLaurent (substituteLaurent i u f) := by + have h:(torusEvaluation v hv).toRingHom= + (algebraMap (SpectralRing n) (SpectralField n)).comp (substituteLaurent i u) := by + apply AddMonoidAlgebra.ringHom_ext <;> intro e + all_goals change torusEvaluation v hv (monomialL _ _)=evalLaurent (substituteLaurent i u (monomialL _ _)) + all_goals rw [torusEvaluation_monomial,substituteLaurent_monomial] + all_goals simp only [evalLaurent,map_mul] + all_goals rw [←evalLaurent,evalLaurent_monomial_product,←evalLaurent,evalLaurent_unit_zpow] + all_goals rw [Fin.prod_univ_succAbove _ i] + all_goals simp only [hi,hj,Fin.removeNth] + all_goals ring + exact DFunLike.congr_fun h f + +end +end CriticalStrip.Diagram + +end OAI diff --git a/lean/OAI/Combinatorics/StripMass/SpecializationPolynomial.lean b/lean/OAI/Combinatorics/StripMass/SpecializationPolynomial.lean new file mode 100644 index 0000000000000000000000000000000000000000..0aa222c86037c967ea8140fdd7160c1c29cd5492 --- /dev/null +++ b/lean/OAI/Combinatorics/StripMass/SpecializationPolynomial.lean @@ -0,0 +1,530 @@ +import Mathlib +import OAI.Combinatorics.StripMass.CollisionSubstitutions + +namespace OAI + +/-! Critical honeycomb strip paths, polynomial identities and crossing mass. -/ + + + +namespace CriticalStrip.Diagram +noncomputable section +open scoped Classical + +lemma RationalAt.eval₂ {R F K A:Type*} [CommRing R] [IsDomain R] [Field F] [Field K] + [Algebra R F] [IsFractionRing R F] [CommRing A] + (φ:R →+* K) (f:A →+* F) (g:A →+* K) + (hfg:∀ a,RationalAt φ (f a) (g a)) {x:F} {y:K} (hxy:RationalAt φ x y) + (P:Polynomial A) : RationalAt φ (P.eval₂ f x) (P.eval₂ g y) := by + rw [Polynomial.eval₂_eq_sum,Polynomial.eval₂_eq_sum] + exact RationalAt.sum _ _ _ (fun i _ => (hfg _).mul (hxy.pow i)) + +lemma RationalAt.eval_map {R F K:Type*} [CommRing R] [IsDomain R] [Field F] [Field K] + [Algebra R F] [IsFractionRing R F] (φ:R →+* K) + {x:F} {y:K} (hxy:RationalAt φ x y) (P:Polynomial R) : + RationalAt φ ((P.map (Algebra.algebraMap R F)).eval x) ((P.map φ).eval y) := by + simpa only [Polynomial.eval_map] using + RationalAt.eval₂ φ (Algebra.algebraMap R F) φ RationalAt.algebraMap hxy P + +lemma LastDegree.map {R K:Type*} [CommRing R] [CommRing K] {n m:ℕ} + {P:Pairing (n+1) → Polynomial R} (hP:LastDegree m P) (φ:R →+* K) : + LastDegree m (fun p => (P p).map φ) := by + intro p k hk + rw [Polynomial.coeff_map,hP p k hk,map_zero] + +lemma LastDegree.of_map {R K:Type*} [CommRing R] [CommRing K] {n m:ℕ} + {P:Pairing (n+1) → Polynomial R} (φ:R →+* K) (hφ:Function.Injective φ) + (hP:LastDegree m (fun p => (P p).map φ)) : LastDegree m P := by + intro p k hk + apply hφ + simpa only [Polynomial.coeff_map,map_zero] using hP p k hk + + + + + + + +lemma liftLaurent_eq_insert {n:ℕ} (P:Laurent n) : liftLaurent P=insertLaurent (Fin.last n) P := by + have he:liftLaurentHom n=insertLaurent (Fin.last n) := by + apply AddMonoidAlgebra.ringHom_ext <;> intro e + all_goals change liftLaurent (monomialL _ _)=insertLaurent (Fin.last n) (monomialL _ _) + all_goals rw [liftLaurent_monomial,insertLaurent_monomial] + all_goals congr 1 + all_goals ext i; induction i using Fin.lastCases <;> simp + exact DFunLike.congr_fun he P + +lemma lastExponent_eq_smul (n:ℕ) (a:ℤ) : lastExponent n a=a • variableExponent (Fin.last n) := by + ext i + induction i using Fin.lastCases <;> simp [lastExponent,variableExponent] + +lemma lastCosine_eq (n:ℕ) : lastCosine n=cosineL ((2:ℤ) • variableExponent (Fin.last n)) (phase^3)⁻¹ := by + unfold lastCosine cosineL + rw [lastExponent_eq_smul,lastExponent_eq_smul] + simp only [zpow_neg,zpow_ofNat,inv_inv,neg_smul] + rfl + +lemma lastCosine_map (n:ℕ) : evalLaurent (lastCosine n)=spectralA (Fin.last n) := by + rw [lastCosine_eq,cosineL_map _ _ (inv_ne_zero (pow_ne_zero _ phase_ne_zero)),map_monomialL_two_variable] + simp only [constF,map_inv₀,map_pow] + congr 1 + simp [constF,div_eq_mul_inv,mul_comm] + +lemma lastCosine_box (n:ℕ) : LaurentBox (lastCosine n) (selfBound (Fin.last n) 2) := by + rw [lastCosine_eq] + apply LaurentBox.cosine + intro i + by_cases hi:i=Fin.last n <;> simp [selfBound,variableExponent,hi] + +lemma lastSine_box (n:ℕ) : LaurentBox (lastSine n) (selfBound (Fin.last n) 1) := by + unfold lastSine + apply LaurentBox.sub + all_goals apply LaurentBox.single + all_goals intro i; induction i using Fin.lastCases <;> simp [lastExponent,selfBound] + + +def lastLaurent {n:ℕ} (p:Pairing (n+1)) (P:Polynomial (Laurent n)) : Laurent (n+1) := + (if p.Occupied (Fin.last n) then lastSine n else 1)*P.eval₂ (liftLaurentHom n) (lastCosine n) + +lemma lastLaurent_map {n:ℕ} (p:Pairing (n+1)) (P:Polynomial (Laurent n)) + (hP:P.map (algebraMap (SpectralRing n) (SpectralField n))=rationalNodalPolynomial n p) : + evalLaurent (lastLaurent p P)=rationalInterpolant n p := by + have he:evalLaurent (P.eval₂ (liftLaurentHom n) (lastCosine n))= + (rationalNodalPolynomial n p).eval₂ (liftSpectral n) (spectralA (Fin.last n)) := by + rw [←hP,Polynomial.eval₂_map,←lastCosine_map] + change (algebraMap (SpectralRing (n+1)) (SpectralField (n+1))) _ = _ + rw [Polynomial.hom_eval₂] + have hh:(algebraMap (SpectralRing (n+1)) (SpectralField (n+1))).comp (liftLaurentHom n)= + (liftSpectral n).comp (algebraMap (SpectralRing n) (SpectralField n)) := by + apply RingHom.ext + intro a + exact (liftSpectral_evalLaurent a).symm + rw [hh] + rfl + unfold lastLaurent rationalInterpolant + rw [evalLaurent,map_mul] + change evalLaurent (if p.Occupied (Fin.last n) then lastSine n else 1) * + evalLaurent (P.eval₂ (liftLaurentHom n) (lastCosine n)) = _ + rw [he] + congr 1 + split_ifs + · exact evalLaurent_lastSine n + · exact map_one _ + +lemma lastLaurent_box {n:ℕ} (p:Pairing (n+1)) (P:Polynomial (Laurent n)) + (hb:PolynomialBox P (fun _ => 2*n)) + (hd:∀ k,(if p.Occupied (Fin.last n) then n≤k else n 2*n) := by + have hv:LaurentBox (P.eval₂ (liftLaurentHom n) (lastCosine n)) + (Fin.snoc (fun _ => 2*n) (if p.Occupied (Fin.last n) then 2*(n-1) else 2*n)) := by + rw [Polynomial.eval₂_eq_sum] + apply LaurentBox.sum + intro k hk + have hkz:P.coeff k≠0 := Polynomial.mem_support_iff.mp hk + have hkdeg:if p.Occupied (Fin.last n) then k + simp only [Pi.add_apply,Fin.insertNth_apply_same,selfBound,zero_add,Fin.snoc_last] + split_ifs at hkdeg ⊢ <;> omega + | cast j => + simp only [Pi.add_apply] + have hi:(Fin.insertNth (Fin.last n) 0 (fun _ => 2*n) : Fin (n+1) → ℕ) j.castSucc=2*n := by + simpa only [Fin.succAbove_last] using Fin.insertNth_apply_succAbove (α:=fun _ => ℕ) (Fin.last n) 0 (fun _ => 2*n) j + simp only [hi,Fin.snoc_castSucc,selfBound,Fin.castSucc_ne_last,ite_false,mul_zero,add_zero,le_refl] + unfold lastLaurent + by_cases hp:p.Occupied (Fin.last n) + · have hn:0 simp only [Pi.add_apply,selfBound,Fin.snoc_last,hp,ite_true]; omega + | cast j => simp [selfBound,hp] + · rw [ite_eq_right hp,one_mul] + apply hv.mono + intro j + induction j using Fin.lastCases <;> simp [hp] + +end + + + + + +noncomputable section +open Finset +open scoped Classical + +@[simp] theorem liftSpectral_weights_tile {n : ℕ} (i : Fin n) (t : Tile) : + liftSpectral n ((spectralWeights n i).tile t) = + (spectralWeights (n+1) i.castSucc).tile t := by + cases t <;> simp [spectralWeights, torusWeights, Weights.tile, torusL, map_div₀] + + + +theorem spectralColumn_lastValue {n : ℕ} (P : Pairing (n+1) → Polynomial (SpectralField n)) : + (spectralA (Fin.last n) + constF (n+1) C) • + (column (spectralWeights (n+1))).mulVec + (lastValue (liftSpectral n) (spectralA (Fin.last n)) (torusSin (variableF (Fin.last n))) P) = + lastValue (liftSpectral n) (spectralA (Fin.last n)) (torusSin (variableF (Fin.last n))) + (lastTransform (fun i => (spectralWeights n i).tile) + (constF n d) (constF n c) (constF n C) P) := by + have h := rawColumn_lastValue (liftSpectral n) (fun i => (spectralWeights n i).tile) + (constF n d) (constF n c) (constF n C) + (spectralA (Fin.last n)) (torusSin (variableF (Fin.last n))) + (torusSin (constF (n+1) phase^3/variableF (Fin.last n))) + (clearedSpectralRow (Fin.last n)) P + (by simp) + (by simp) + (by simp) + (by simp) + (by simpa using spectral_sine_pair (Fin.last n)) + have hrow : Fin.snoc (fun i t => liftSpectral n ((spectralWeights n i).tile t)) + (clearedSpectralRow (Fin.last n)) = + fun i t => (Fin.snoc (fun _ => 1) (spectralA (Fin.last n)+constF (n+1) C) : + Fin (n+1) → SpectralField (n+1)) i * (spectralWeights (n+1) i).tile t := by + funext i t + induction i using Fin.lastCases with + | last => simp only [Fin.snoc_last]; rfl + | cast i => simp + rw [hrow, rawColumn_scale, Matrix.smul_mulVec] at h + simpa only [Fin.prod_univ_castSucc, Fin.snoc_castSucc, Fin.snoc_last, + prod_const_one, one_mul, ← column_eq_raw] using h + +@[simp] theorem rationalInterpolant_eq_lastValue (n : ℕ) : + rationalInterpolant n = + lastValue (liftSpectral n) (spectralA (Fin.last n)) + (torusSin (variableF (Fin.last n))) (rationalNodalPolynomial n) := by + funext p + simp only [rationalInterpolant, lastValue] + split_ifs <;> simp + + +theorem rationalInterpolationResidual_transfer {n : ℕ} (p : Pairing (n+1)) : + rationalInterpolationResidual n p = + ((∏ i : Fin n, evalLaurent (rowDenominator i.castSucc)) / 2) * + lastValue (liftSpectral n) (spectralA (Fin.last n)) + (torusSin (variableF (Fin.last n))) (rationalResidualPolynomial n) p := by + have ht := congrFun (spectralColumn_lastValue (rationalNodalPolynomial n)) p + simp only [Pi.smul_apply, smul_eq_mul] at ht + have hden := twice_rowDenominator (Fin.last n) + unfold rationalInterpolationResidual + rw [Fin.prod_univ_castSucc, rationalInterpolant_eq_lastValue] + unfold rationalResidualPolynomial lastValue at * + by_cases hp : p.Occupied (Fin.last n) + · simp only [hp, ite_true, Polynomial.eval₂_sub, Polynomial.eval₂_mul, + Polynomial.eval₂_add, Polynomial.eval₂_X, Polynomial.eval₂_C, liftSpectral_const] at * + rw [← hden] at ht ⊢ + linear_combination ((∏ i : Fin n, evalLaurent (rowDenominator i.castSucc)) / 2) * ht + · simp only [hp, ite_false, Polynomial.eval₂_sub, Polynomial.eval₂_mul, + Polynomial.eval₂_add, Polynomial.eval₂_X, Polynomial.eval₂_C, liftSpectral_const] at * + rw [← hden] at ht ⊢ + linear_combination ((∏ i : Fin n, evalLaurent (rowDenominator i.castSucc)) / 2) * ht + + + +theorem rationalInterpolationResidual_factor {n : ℕ} (p : Pairing (n+1)) : + rationalInterpolationResidual n p = + ((∏ i : Fin n, evalLaurent (rowDenominator i.castSucc)) / 2) * + (if p.Occupied (Fin.last n) then torusSin (variableF (Fin.last n)) else 1) * + liftSpectral n (rationalResidualCoefficient n p) * + (Lagrange.nodal univ (@deletionBeta n)).eval₂ (liftSpectral n) (spectralA (Fin.last n)) := by + rw [rationalInterpolationResidual_transfer] + simp only [lastValue, rationalResidualPolynomial_factor, Polynomial.eval₂_mul, + Polynomial.eval₂_C] + split_ifs <;> ring + +end + + + + + +noncomputable section +open scoped Classical + +lemma rowDenominator_box {n:ℕ} (i:Fin n) : LaurentBox (rowDenominator i) (selfBound i 2) := by + have h:∀j,-(selfBound i 1 j:ℤ)≤(-variableExponent i) j ∧ (-variableExponent i) j≤ selfBound i 1 j := by + intro j + by_cases h:j=i <;> simp [selfBound,variableExponent,h] + convert sineL_product_box (-variableExponent i) (-variableExponent i) (phase^(5:ℤ)) (phase^(6:ℤ)) (selfBound i 1) h h using 1 + · rfl + · funext j + by_cases h:j=i <;> simp [selfBound,h] + +lemma variableExponent_selfBound {n:ℕ} (i:Fin n) : + ∀j,-(selfBound i 1 j:ℤ)≤variableExponent i j ∧ variableExponent i j≤ selfBound i 1 j := by + intro j + by_cases h:j=i <;> simp [selfBound,variableExponent,h] +lemma negVariableExponent_selfBound {n:ℕ} (i:Fin n) : + ∀j,-(selfBound i 1 j:ℤ)≤(-variableExponent i) j ∧ (-variableExponent i) j≤ selfBound i 1 j := by + intro j; have :=variableExponent_selfBound i j; simp only [Pi.neg_apply]; omega +lemma selfBound_one_add {n:ℕ} (i:Fin n) : selfBound i 1+selfBound i 1=selfBound i 2 := by + funext j; by_cases h:j=i <;> simp [selfBound,h] + +lemma rowNumerator_box {n:ℕ} (i:Fin n) (t:Tile) : LaurentBox (rowNumerator i t) (selfBound i 2) := by + rw [←selfBound_one_add] + cases t with + | vacant => rw [selfBound_one_add]; exact rowDenominator_box i + | vertical₀ => exact constant_sineL_box _ _ _ _ (variableExponent_selfBound i) + | vertical₁ => exact constant_sineL_box _ _ _ _ (variableExponent_selfBound i) + | cap => exact constant_sineL_box _ _ _ _ (negVariableExponent_selfBound i) + | cup => exact constant_sineL_box _ _ _ _ (negVariableExponent_selfBound i) + | diagonal₀ => exact sineL_product_box _ _ _ _ _ (negVariableExponent_selfBound i) (variableExponent_selfBound i) + | diagonal₁ => exact sineL_product_box _ _ _ _ _ (negVariableExponent_selfBound i) (variableExponent_selfBound i) + | verticalPair => exact sineL_product_box _ _ _ _ _ (variableExponent_selfBound i) (variableExponent_selfBound i) + | capCup => exact sineL_product_box _ _ _ _ _ (negVariableExponent_selfBound i) (negVariableExponent_selfBound i) + +lemma sum_selfBound (n a:ℕ) : (∑i:Fin n,selfBound i a)=fun _ =>a := by + funext j + simp [selfBound] + +lemma rawColumn_box {n:ℕ} (w:Fin n → Tile → Laurent n) + (h:∀i t,LaurentBox (w i t) (selfBound i 2)) : + LaurentMatrixBox (rawColumn w) (fun _ =>2) := by + intro p q + unfold rawColumn + apply LaurentBox.sum + intro t _ + split_ifs + · rw [←sum_selfBound n 2] + exact LaurentBox.prod _ _ _ (fun i _ =>h i (t i)) + · exact LaurentBox.zero _ + + + +def laurentResidual {n:ℕ} (W:Pairing n → Laurent n) (p:Pairing n) : Laurent n := + (rawColumn rowNumerator).mulVec W p-(∏i:Fin n,rowDenominator i)*W p + +lemma laurentResidual_box {n:ℕ} (W:Pairing n → Laurent n) (b:ℕ) + (h:∀p,LaurentBox (W p) (fun _ =>b)) (p:Pairing n) : + LaurentBox (laurentResidual W p) (fun _ =>b+2) := by + apply LaurentBox.sub + · exact ((rawColumn_box rowNumerator rowNumerator_box).mulVec h p).mono (by intro i; simp; omega) + · have hd:LaurentBox (∏i:Fin n,rowDenominator i) (fun _ =>2) := by + rw [←sum_selfBound n 2] + exact LaurentBox.prod _ _ _ (fun i _ =>rowDenominator_box i) + exact (hd.mul (h p)).mono (by intro i; simp; omega) + +lemma laurentResidual_map {n:ℕ} + (P:Pairing (n+1) → Polynomial (Laurent n)) + (hP:∀p,(P p).map (algebraMap (SpectralRing n) (SpectralField n))=rationalNodalPolynomial n p) + (p:Pairing (n+1)) : + evalLaurent (laurentResidual (fun p =>lastLaurent p (P p)) p)=rationalInterpolationResidual n p := by + have hcol:(rawColumn (@rowNumerator (n+1))).map (algebraMap (SpectralRing (n+1)) (SpectralField (n+1)))= + (∏i:Fin (n+1),evalLaurent (rowDenominator i)) • column (spectralWeights (n+1)) := by + rw [rawColumn_map] + simp_rw [rowNumerator_map] + rw [rawColumn_scale] + rfl + change (algebraMap (SpectralRing (n+1)) (SpectralField (n+1))) _=_ + rw [laurentResidual,map_sub,map_mul,map_prod] + have he:(algebraMap (SpectralRing (n+1)) (SpectralField (n+1))) + ((rawColumn rowNumerator).mulVec (fun p =>lastLaurent p (P p)) p)= + (((rawColumn rowNumerator).map (algebraMap (SpectralRing (n+1)) (SpectralField (n+1)))).mulVec (rationalInterpolant n)) p := by + simp only [Matrix.mulVec,dotProduct,map_sum,map_mul,Matrix.map_apply] + apply Finset.sum_congr rfl + intro q _ + rw [show (algebraMap (SpectralRing (n+1)) (SpectralField (n+1))) (lastLaurent q (P q))=rationalInterpolant n q from lastLaurent_map q (P q) (hP q)] + rw [he,hcol,Matrix.smul_mulVec] + change _ - _ * evalLaurent (lastLaurent p (P p))=_ + rw [lastLaurent_map p (P p) (hP p)] + simp only [rationalInterpolationResidual,Pi.smul_apply,smul_eq_mul,mul_sub,evalLaurent] + + + + + + + +lemma signLaurent_lift {n:ℕ} (i:Fin n) (f:Laurent n) : + signLaurent i.castSucc (liftLaurent f)=liftLaurent (signLaurent i f) := by + have he:(signLaurent i.castSucc).comp (liftLaurentHom n)= + (liftLaurentHom n).comp (signLaurent i) := by + apply AddMonoidAlgebra.ringHom_ext <;> intro e + all_goals change signLaurent i.castSucc (liftLaurent (monomialL _ _))=liftLaurent (signLaurent i (monomialL _ _)) + all_goals rw [liftLaurent_monomial,signLaurent_monomial,signLaurent_monomial,liftLaurent_monomial] + all_goals simp only [Fin.snoc_castSucc] + exact DFunLike.congr_fun he f + +lemma signSpectral_lift {n:ℕ} (i:Fin n) (f:SpectralField n) : + signSpectral i.castSucc (liftSpectral n f)=liftSpectral n (signSpectral i f) := by + have he:(signSpectral i.castSucc).comp (liftSpectral n)= + (liftSpectral n).comp (signSpectral i) := by + apply IsFractionRing.ringHom_ext (A:=SpectralRing n) + intro P + change signSpectral i.castSucc (liftSpectral n (evalLaurent P))=liftSpectral n (signSpectral i (evalLaurent P)) + rw [liftSpectral_evalLaurent,signSpectral_evalLaurent,signSpectral_evalLaurent,liftSpectral_evalLaurent,signLaurent_lift] + exact DFunLike.congr_fun he f + +lemma rationalInterpolant_parity {n:ℕ} (i:Fin n) (p:Pairing (n+1)) : + signSpectral i.castSucc (rationalInterpolant n p)=occupancySign p i.castSucc*rationalInterpolant n p := by + have hp:=congrArg (fun P:Polynomial (SpectralField n) => P.eval₂ (liftSpectral n) (spectralA (Fin.last n))) + (rationalNodalPolynomial_parity i p) + simp only [Polynomial.eval₂_mul,Polynomial.eval₂_C] at hp + have ho:liftSpectral n (occupancySign (K:=SpectralField n) p i.castSucc)=occupancySign p i.castSucc := by + simp only [occupancySign]; split_ifs <;> simp + rw [ho] at hp + have hm:(signSpectral i.castSucc).comp (liftSpectral n)=(liftSpectral n).comp (signSpectral i) := + RingHom.ext (signSpectral_lift i) + have hev:signSpectral i.castSucc ((rationalNodalPolynomial n p).eval₂ (liftSpectral n) (spectralA (Fin.last n)))= + ((rationalNodalPolynomial n p).map (signSpectral i)).eval₂ (liftSpectral n) (spectralA (Fin.last n)) := by + rw [Polynomial.hom_eval₂,hm,Polynomial.eval₂_map,signSpectral_spectralA] + unfold rationalInterpolant + rw [map_mul,hev,hp] + have hs:signSpectral i.castSucc (torusSin (variableF (Fin.last n)))=torusSin (variableF (Fin.last n)) := by + rw [signSpectral_torusSin,signSpectral_variable,ite_eq_right (Ne.symm (Fin.castSucc_ne_last i))] + split_ifs <;> simp only [hs,map_one] <;> ring + +lemma signSpectral_column {n:ℕ} (i:Fin n) (p q:Pairing n) : + signSpectral i (column (spectralWeights n) p q)= + occupancySign p i*occupancySign q i*column (spectralWeights n) p q := by + have h:=column_map (signSpectral i) (spectralWeights n) + rw [signSpectral_spectralWeights] at h + have he:=congrArg (fun M:Matrix (Pairing n) (Pairing n) (SpectralField n) => M p q) h + simpa only [Matrix.map_apply,column_signTwist] using he + +lemma signSpectral_rowDenominator {n:ℕ} (i j:Fin n) : + signSpectral i (evalLaurent (rowDenominator j))=evalLaurent (rowDenominator j) := by + unfold evalLaurent + rw [rowDenominator_map,signSpectral_torusL,map_div₀,map_pow,signSpectral_const,signSpectral_variable] + split_ifs + · have he : constF n phase ^ 3 / -variableF j = -(constF n phase ^ 3 / variableF j) := div_neg_eq_neg_div _ _ + rw [he,torusL_neg] + · rfl + +theorem rationalInterpolationResidual_parity {n:ℕ} (i:Fin n) (p:Pairing (n+1)) : + signSpectral i.castSucc (rationalInterpolationResidual n p)= + occupancySign p i.castSucc*rationalInterpolationResidual n p := by + have hc:signSpectral i.castSucc ((column (spectralWeights (n+1))).mulVec (rationalInterpolant n) p)= + occupancySign p i.castSucc*(column (spectralWeights (n+1))).mulVec (rationalInterpolant n) p := by + simp only [Matrix.mulVec,dotProduct,map_sum,map_mul,signSpectral_column,rationalInterpolant_parity,Finset.mul_sum] + apply Finset.sum_congr rfl + intro q _ + calc + _=occupancySign p i.castSucc*(occupancySign q i.castSucc*occupancySign q i.castSucc)* + (column (spectralWeights (n+1)) p q*rationalInterpolant n q) := by ring + _=_ := by rw [occupancySign_mul_self,mul_one] + rw [rationalInterpolationResidual,map_mul,map_sub,map_prod] + simp_rw [signSpectral_rowDenominator] + rw [hc,rationalInterpolant_parity] + ring + +end + + + + + +noncomputable section +open scoped Classical +open Finset + + +def LastMatrix {K:Type*} [Zero K] {n m:ℕ} + (M:Matrix (Pairing (m+1)) (Pairing (n+1)) K) : Prop := + ∀p q, ¬(p.Occupied (Fin.last m) ↔ q.Occupied (Fin.last n)) → M p q=0 + +def matrixPolynomial {K:Type*} [CommRing K] {n m:ℕ} + (M:Matrix (Pairing m) (Pairing n) K) (P:Pairing n → Polynomial K) : + Pairing m → Polynomial K := fun p =>∑q,Polynomial.C (M p q)*P q + +lemma matrixPolynomial_coeff {K:Type*} [CommRing K] {n m:ℕ} + (M:Matrix (Pairing m) (Pairing n) K) (P:Pairing n → Polynomial K) (p:Pairing m) (k:ℕ) : + (matrixPolynomial M P p).coeff k=M.mulVec (fun q =>(P q).coeff k) p := by + simp only [matrixPolynomial,Polynomial.finsetSum_coeff,Polynomial.coeff_C_mul,Matrix.mulVec,dotProduct] + +lemma LastMatrix.degree {K:Type*} [CommRing K] {n m d:ℕ} + {M:Matrix (Pairing (m+1)) (Pairing (n+1)) K} (hM:LastMatrix M) + (P:Pairing (n+1) → Polynomial K) (hP:LastDegree d P) : LastDegree d (matrixPolynomial M P) := by + intro p k hk + rw [matrixPolynomial_coeff] + apply sum_eq_zero + intro q _ + change M p q*(P q).coeff k=0 + by_cases h:p.Occupied (Fin.last m) ↔ q.Occupied (Fin.last n) + · rw [hP q k (by rwa [←h]),mul_zero] + · rw [hM p q h,zero_mul] + +lemma LastMatrix.lastValue {K:Type*} [CommRing K] {n m:ℕ} + {M:Matrix (Pairing (m+1)) (Pairing (n+1)) K} (hM:LastMatrix M) + (b s:K) (P:Pairing (n+1) → Polynomial K) : + lastValue (RingHom.id K) b s (matrixPolynomial M P)= + M.mulVec (lastValue (RingHom.id K) b s P) := by + funext p + simp only [CriticalStrip.Diagram.lastValue,matrixPolynomial,Polynomial.eval₂_id,Polynomial.eval_finsetSum, + Polynomial.eval_mul,Polynomial.eval_C,Matrix.mulVec,dotProduct] + split_ifs with hp + · rw [mul_sum] + apply sum_congr rfl + intro q _ + by_cases hq:q.Occupied (Fin.last n) + · simp only [hq,ite_true]; ring + · rw [hM p q (by simp [hp,hq]),zero_mul,mul_zero] + simp + · apply sum_congr rfl + intro q _ + by_cases hq:q.Occupied (Fin.last n) + · rw [hM p q (by simp [hp,hq]),zero_mul,zero_mul] + · simp [hq] + +lemma LastMatrix.leading {K:Type*} [CommRing K] {n m d:ℕ} + {M:Matrix (Pairing (m+1)) (Pairing (n+1)) K} (hM:LastMatrix M) + (M':Matrix (Pairing m) (Pairing n) K) + (h:∀p q,M p.padTop q.padTop=M' p q) + (P:Pairing (n+1) → Polynomial K) (p:Pairing m) : + (matrixPolynomial M P p.padTop).coeff d=M'.mulVec (fun q =>(P q.padTop).coeff d) p := by + rw [matrixPolynomial_coeff] + simp only [Matrix.mulVec,dotProduct] + symm + apply Fintype.sum_of_injective Pairing.padTop Pairing.padTop_injective + · intro q hq + have ho:q.Occupied (Fin.last n) := by + by_contra hn + exact hq ⟨q.restrict Fin.castSuccOrderEmb,Pairing.padTop_restrict q hn⟩ + rw [hM p.padTop q (by simp [ho]),zero_mul] + · intro q; rw [h] + +lemma LastMatrix.local {K:Type*} [CommRing K] {n:ℕ} (a:Position n) (w:Weights K) : + LastMatrix (localR a.padTop w) := fun p q =>localR_padTop_zero_last a w q p + +lemma LastMatrix.omit {K:Type*} [CommRing K] {n:ℕ} (r:Fin (n+1)) : + LastMatrix (functionMatrix (K:=K) (Pairing.map (Fin.succAboveOrderEmb r.castSucc))) := by + intro p q h + unfold functionMatrix optionMatrix + split_ifs with he + · have hh:q.map (Fin.succAboveOrderEmb r.castSucc)=p := Option.some.inj he + exfalso; apply h + rw [←hh,←Pairing.omit_last r] + exact Pairing.map_occupied _ q _ + · rfl + +lemma LastMatrix.mul {K:Type*} [CommRing K] {n m r:ℕ} + {M:Matrix (Pairing (r+1)) (Pairing (m+1)) K} + {N:Matrix (Pairing (m+1)) (Pairing (n+1)) K} + (hM:LastMatrix M) (hN:LastMatrix N) : LastMatrix (M*N) := by + intro p q h + apply sum_eq_zero; intro t _ + change M p t*N t q=0 + by_cases ht:p.Occupied (Fin.last r) ↔ t.Occupied (Fin.last m) + · rw [hN t q (fun hh =>h (ht.trans hh)),mul_zero] + · rw [hM p t ht,zero_mul] + +end +end CriticalStrip.Diagram + +end OAI diff --git a/lean/OAI/Combinatorics/StripMass/SpectralComponents.lean b/lean/OAI/Combinatorics/StripMass/SpectralComponents.lean new file mode 100644 index 0000000000000000000000000000000000000000..b8b1efb2db1139cec12dca31b4cbc79b59273059 --- /dev/null +++ b/lean/OAI/Combinatorics/StripMass/SpectralComponents.lean @@ -0,0 +1,434 @@ +import Mathlib +import OAI.Combinatorics.StripMass.PolynomialDegrees +import OAI.Combinatorics.StripMass.PfaffianEvaluation + +namespace OAI + +/-! Critical honeycomb strip paths, polynomial identities and crossing mass. -/ + + +namespace StripComplexification +noncomputable section +open Polynomial +open scoped BigOperators +lemma component_comp (l : ℂ →ₗ[ℝ] ℝ) (p : Polynomial ℂ) (q : Polynomial ℝ) : + component l (p.comp (q.map Complex.ofRealHom)) = (component l p).comp q := by + induction p using Polynomial.induction_on' with + | add p r hp hr => simp only [add_comp, component_add, hp, hr] + | monomial n c => + have hm : (monomial n c : Polynomial ℂ) = C c * X ^ n := C_mul_X_pow_eq_monomial.symm + rw [hm, mul_comp, C_comp, pow_comp, X_comp] + rw [mul_comm, ← Polynomial.map_pow, component_real_mul, component_C] + have hX : (X ^ n : Polynomial ℂ) = (X ^ n : Polynomial ℝ).map Complex.ofRealHom := by simp + rw [mul_comm (C c), hX, component_real_mul, component_C] + simp only [mul_comp, pow_comp, X_comp, C_comp] + +lemma component_projection (l : ℂ →ₗ[ℝ] ℝ) (P J E : Polynomial ℂ) (h : Polynomial ℝ) : + component l (P.comp (h.map Complex.ofRealHom) + X * J.comp (h.map Complex.ofRealHom) + + X ^ 2 * E.comp (h.map Complex.ofRealHom)) = + (component l P).comp h + X * (component l J).comp h + + X ^ 2 * (component l E).comp h := by + rw [component_add, component_add, component_comp] + have hx : (X : Polynomial ℂ) = (X : Polynomial ℝ).map Complex.ofRealHom := by simp + have hx2 : (X ^ 2 : Polynomial ℂ) = (X ^ 2 : Polynomial ℝ).map Complex.ofRealHom := by simp + rw [hx2, component_real_mul, component_comp, hx, component_real_mul, component_comp] + +lemma component_degree_le (l : ℂ →ₗ[ℝ] ℝ) (p : Polynomial ℂ) : + (component l p).degree ≤ p.degree := by + apply (degree_le_iff_coeff_zero _ _).2 + intro n hn + simp [coeff_eq_zero_of_degree_lt hn] + +lemma component_natDegree_le (l : ℂ →ₗ[ℝ] ℝ) (p : Polynomial ℂ) : + (component l p).natDegree ≤ p.natDegree := by + apply natDegree_le_iff_coeff_eq_zero.2 + intro n hn + simp [coeff_eq_zero_of_natDegree_lt hn] + +lemma component_zero_iff (p : Polynomial ℂ) + (hr : component Complex.reLm p = 0) (hi : component Complex.imLm p = 0) : p = 0 := by + ext n + apply Complex.ext + · simpa using congrArg (fun q : Polynomial ℝ => q.coeff n) hr + · simpa using congrArg (fun q : Polynomial ℝ => q.coeff n) hi + +end +end StripComplexification + +namespace StripPfaffian +noncomputable section +open Polynomial Set MeasureTheory Filter Matrix StripComplexification +open scoped Topology BigOperators + +lemma map_harmonic : CriticalStrip.harmonicCoordinate.map Complex.ofRealHom = harmonicPoly := by + simp [CriticalStrip.harmonicCoordinate, harmonicPoly] + +lemma map_perturbedRoot {N : ℕ} (a : Fin N → ℝ) : + (CriticalStrip.perturbedRoot a).map Complex.ofRealHom = + perturbedRootC (fun i => (a i : ℂ)) := by + simp [CriticalStrip.perturbedRoot, perturbedRootC, Epoly, Polynomial.map_prod, + CriticalStrip.C, CriticalStrip.d, CriticalStrip.lambda, flatC, d] + +def rootPolynomialC (N : ℕ) : Polynomial ℂ := + (CriticalStrip.rootPolynomial N).map Complex.ofRealHom + +def homogeneousQC (N : ℕ) (g : Polynomial ℂ) : Polynomial ℂ := rootPolynomialC N * g + +def PerturbedMonicProblemC {N : ℕ} (a : Fin N → ℂ) (g : Polynomial ℂ) : Prop := + g.Monic ∧ g.natDegree = N ∧ HasProjectionC N (perturbedRootC a * g) + +def MonicProblemC (N : ℕ) (g : Polynomial ℂ) : Prop := + g.Monic ∧ g.natDegree = N ∧ HasProjectionC N (homogeneousQC N g) + +lemma perturbedRoot_homogeneous (N : ℕ) : perturbedRootC (fun _ : Fin N => flatC) = rootPolynomialC N := by + change perturbedRootC (fun _ : Fin N => (CriticalStrip.C : ℂ)) = _ + rw [← map_perturbedRoot, CriticalStrip.perturbedRoot_homogeneous] + rfl + +lemma homogeneous_projection_zero_complex (N : ℕ) (hN : 1 ≤ N) (g P J E : Polynomial ℂ) + (hg : g.degree < (N : WithBot ℕ)) + (hP : P.natDegree ≤ N) (hJ : J.natDegree ≤ N) (hE : E.degree < (N : WithBot ℕ)) + (hQ : homogeneousQC N g = P.comp harmonicPoly + X * J.comp harmonicPoly + + X ^ 2 * E.comp harmonicPoly) : + P = 0 ∧ J = 0 ∧ E = 0 ∧ g = 0 := by + have hl (l : ℂ →ₗ[ℝ] ℝ) : component l P = 0 ∧ component l J = 0 ∧ + component l E = 0 ∧ component l g = 0 := by + apply CriticalStrip.homogeneous_projection_zero N hN + (component l g) (component l P) (component l J) (component l E) + ((component_degree_le l g).trans_lt hg) + ((component_natDegree_le l P).trans hP) + ((component_natDegree_le l J).trans hJ) + ((component_degree_le l E).trans_lt hE) + have he := congrArg (component l) hQ + rw [homogeneousQC, rootPolynomialC, component_real_mul, ← map_harmonic, + component_projection] at he + exact he + have hr := hl Complex.reLm + have hi := hl Complex.imLm + exact ⟨component_zero_iff P hr.1 hi.1, + component_zero_iff J hr.2.1 hi.2.1, + component_zero_iff E hr.2.2.1 hi.2.2.1, + component_zero_iff g hr.2.2.2 hi.2.2.2⟩ + +theorem harmonic_natDegree : harmonicPoly.natDegree = 4 := by + unfold harmonicPoly + compute_degree <;> norm_num + +theorem degree_lt_natDegree_le_pred {N : ℕ} {p : Polynomial ℂ} + (hN : 1 ≤ N) (hp : p.degree < (N : WithBot ℕ)) : p.natDegree ≤ N - 1 := by + by_cases hp0 : p = 0 + · simp [hp0] + have h : p.natDegree < N := (natDegree_lt_iff_degree_lt hp0).2 hp + omega + + +theorem projection_natDegree_le (N : ℕ) (hN : 1 ≤ N) (P J E : Polynomial ℂ) + (hP : P.natDegree ≤ N) (hJ : J.natDegree ≤ N) (hE : E.degree < (N : WithBot ℕ)) : + (P.comp harmonicPoly + X * J.comp harmonicPoly + + X ^ 2 * E.comp harmonicPoly).natDegree ≤ 4 * N + 1 := by + have he := degree_lt_natDegree_le_pred hN hE + have hp' : (P.comp harmonicPoly).natDegree ≤ 4 * N + 1 := by + rw [natDegree_comp, harmonic_natDegree] + omega + have hj' : (X * J.comp harmonicPoly).natDegree ≤ 4 * N + 1 := by + apply le_trans natDegree_mul_le + rw [natDegree_X, natDegree_comp, harmonic_natDegree] + omega + have he' : (X ^ 2 * E.comp harmonicPoly).natDegree ≤ 4 * N + 1 := by + apply le_trans natDegree_mul_le + rw [natDegree_X_pow, natDegree_comp, harmonic_natDegree] + omega + exact le_trans (natDegree_add_le _ _) (max_le (le_trans (natDegree_add_le _ _) (max_le hp' hj')) he') + +abbrev ProjectionSpace (N : ℕ) := + (degreeLT ℂ (N + 1)) × (degreeLT ℂ (N + 1)) × (degreeLT ℂ N) + +def projectionMap (N : ℕ) : ProjectionSpace N →ₗ[ℂ] Polynomial ℂ where + toFun t := t.1.val.comp harmonicPoly + X * t.2.1.val.comp harmonicPoly + + X ^ 2 * t.2.2.val.comp harmonicPoly + map_add' t u := by + simp only [Prod.fst_add, Prod.snd_add, Submodule.coe_add, add_comp] + ring + map_smul' a t := by + simp only [Prod.smul_fst, Prod.smul_snd, Submodule.coe_smul, smul_comp, + smul_add, mul_smul_comm, RingHom.id_apply] + +theorem natDegree_le_of_mem_degreeLT {N : ℕ} {p : Polynomial ℂ} + (hp : p ∈ degreeLT ℂ (N + 1)) : p.natDegree ≤ N := by + by_cases hp0 : p = 0 + · simp [hp0] + exact Nat.lt_succ_iff.1 ((natDegree_lt_iff_degree_lt hp0).2 (mem_degreeLT.1 hp)) + +theorem Epoly_natDegree_le (a : ℂ) : (Epoly a).natDegree ≤ 2 := by + unfold Epoly + apply (natDegree_add_le _ _).trans + apply max_le + · apply (natDegree_sub_le _ _).trans + apply max_le + · simp + · exact (natDegree_mul_le).trans (by simp only [natDegree_C, natDegree_X]; omega) + · simp only [natDegree_C]; omega + +theorem perturbedRootC_natDegree_le {N : ℕ} (a : Fin N → ℂ) : + (perturbedRootC a).natDegree ≤ 3*N+1 := by + have hp (i : Fin N) : ((X - C (a i)) * Epoly (a i)).natDegree ≤ 3 := by + exact (natDegree_mul_le).trans (by + rw [natDegree_X_sub_C] + have := Epoly_natDegree_le (a i) + omega) + have hh : (∏ i : Fin N, (X - C (a i)) * Epoly (a i)).natDegree ≤ N*3 := by + apply (natDegree_prod_le (s := Finset.univ) (f := fun i : Fin N => + (X - C (a i)) * Epoly (a i))).trans + simpa only [Finset.sum_const, Finset.card_univ, Fintype.card_fin, nsmul_eq_mul, + Nat.cast_id] using Finset.sum_le_sum (s := Finset.univ) (fun i _ => hp i) + rw [perturbedRootC] + exact (natDegree_mul_le).trans (by rw [natDegree_X_sub_C]; omega) + +abbrev SystemSpace (N : ℕ) := ProjectionSpace N × degreeLT ℂ N +abbrev SystemIndex (N : ℕ) := (Fin (N+1) ⊕ (Fin (N+1) ⊕ Fin N)) ⊕ Fin N +def systemBasis (N : ℕ) : Module.Basis (SystemIndex N) ℂ (SystemSpace N) := + ((degreeLT.basis ℂ (N+1)).prod ((degreeLT.basis ℂ (N+1)).prod (degreeLT.basis ℂ N))).prod + (degreeLT.basis ℂ N) +def systemIndexEquiv (N : ℕ) : SystemIndex N ≃ Fin (4*N+2) := + Fintype.equivFinOfCardEq (by simp [SystemIndex]; omega) +def targetBasis (N : ℕ) : Module.Basis (SystemIndex N) ℂ (degreeLT ℂ (4*N+2)) := + (degreeLT.basis ℂ (4*N+2)).reindex (systemIndexEquiv N).symm + +def perturbedSystem {N : ℕ} (hN : 1 ≤ N) (a : Fin N → ℂ) : + SystemSpace N →ₗ[ℂ] degreeLT ℂ (4*N+2) where + toFun t := ⟨projectionMap N t.1 - perturbedRootC a*t.2.val, mem_degreeLT.2 (by + apply (degree_le_natDegree).trans_lt + apply WithBot.coe_lt_coe.2 + simp only [Nat.cast_id] + apply lt_of_le_of_lt (natDegree_sub_le _ _) + apply max_lt + · have hh := projection_natDegree_le N hN t.1.1.val t.1.2.1.val t.1.2.2.val + (natDegree_le_of_mem_degreeLT t.1.1.property) (natDegree_le_of_mem_degreeLT t.1.2.1.property) + (mem_degreeLT.1 t.1.2.2.property) + exact lt_of_le_of_lt hh (by omega) + · have hg : t.2.val.natDegree < N := by + by_cases hz : t.2.val=0 + · simp [hz]; omega + exact (natDegree_lt_iff_degree_lt hz).2 (mem_degreeLT.1 t.2.property) + exact lt_of_le_of_lt natDegree_mul_le (by have := perturbedRootC_natDegree_le a; omega))⟩ + map_add' t u := by + apply Subtype.ext + simp only [Prod.fst_add, Prod.snd_add, map_add, Submodule.coe_add] + ring + map_smul' r t := by + apply Subtype.ext + simp only [Prod.smul_fst, Prod.smul_snd, map_smul, Submodule.coe_smul, smul_sub, + mul_smul_comm, RingHom.id_apply] + +theorem homogeneous_system_injective (N : ℕ) (hN : 1 ≤ N) : + Function.Injective (perturbedSystem hN (fun _ => flatC)) := by + apply (LinearMap.ker_eq_bot).1 + apply LinearMap.ker_eq_bot'.2 + intro t ht + have he : homogeneousQC N t.2.val = projectionMap N t.1 := by + have he := congrArg Subtype.val ht + change projectionMap N t.1 - perturbedRootC (fun _ => flatC)*t.2.val=0 at he + rw [perturbedRoot_homogeneous] at he + exact (sub_eq_zero.mp he).symm + have hz := homogeneous_projection_zero_complex N hN t.2.val t.1.1.val t.1.2.1.val t.1.2.2.val + (mem_degreeLT.1 t.2.property) (natDegree_le_of_mem_degreeLT t.1.1.property) + (natDegree_le_of_mem_degreeLT t.1.2.1.property) (mem_degreeLT.1 t.1.2.2.property) he + exact Prod.ext (Prod.ext (Subtype.ext hz.1) (Prod.ext (Subtype.ext hz.2.1) (Subtype.ext hz.2.2.1))) + (Subtype.ext hz.2.2.2) + +def CoeffContinuous {A : Type*} [TopologicalSpace A] (p : A → Polynomial ℂ) : Prop := + ∀ k, Continuous (fun a => (p a).coeff k) +theorem CoeffContinuous.const {A : Type*} [TopologicalSpace A] (p : Polynomial ℂ) : + CoeffContinuous (fun _ : A => p) := fun _ => continuous_const +theorem CoeffContinuous.C {A : Type*} [TopologicalSpace A] {f : A → ℂ} (hf : Continuous f) : + CoeffContinuous (fun a => Polynomial.C (f a)) := by + intro k + simp only [coeff_C] + split_ifs <;> fun_prop +theorem CoeffContinuous.add {A : Type*} [TopologicalSpace A] {p q : A → Polynomial ℂ} + (hp : CoeffContinuous p) (hq : CoeffContinuous q) : CoeffContinuous (fun a => p a+q a) := by + intro k + simp only [coeff_add] + exact (hp k).add (hq k) +theorem CoeffContinuous.sub {A : Type*} [TopologicalSpace A] {p q : A → Polynomial ℂ} + (hp : CoeffContinuous p) (hq : CoeffContinuous q) : CoeffContinuous (fun a => p a-q a) := by + intro k + simp only [coeff_sub] + exact (hp k).sub (hq k) +theorem CoeffContinuous.mul {A : Type*} [TopologicalSpace A] {p q : A → Polynomial ℂ} + (hp : CoeffContinuous p) (hq : CoeffContinuous q) : CoeffContinuous (fun a => p a*q a) := by + intro k + simp only [coeff_mul] + exact continuous_finsetSum _ (fun ij _ => (hp ij.1).mul (hq ij.2)) +theorem CoeffContinuous.prod {A I : Type*} [TopologicalSpace A] (s : Finset I) + {p : I → A → Polynomial ℂ} (hp : ∀ i ∈ s, CoeffContinuous (p i)) : + CoeffContinuous (fun a => ∏ i ∈ s, p i a) := by + classical + induction s using Finset.induction_on with + | empty => simpa using CoeffContinuous.const (1 : Polynomial ℂ) + | @insert i s hi ih => + simp only [Finset.prod_insert hi] + exact (hp i (Finset.mem_insert_self _ _)).mul (ih (fun j hj => hp j (Finset.mem_insert_of_mem hj))) +theorem perturbedRootC_continuous (N : ℕ) : CoeffContinuous (@perturbedRootC N) := by + apply (CoeffContinuous.const (X-Polynomial.C flatC)).mul + apply CoeffContinuous.prod + intro i _ + apply ((CoeffContinuous.const X).sub (CoeffContinuous.C (continuous_apply i))).mul + apply CoeffContinuous.add + · exact (CoeffContinuous.const (X^2)).sub ((CoeffContinuous.C (by fun_prop)).mul (CoeffContinuous.const X)) + · exact CoeffContinuous.C (by fun_prop) + +def systemMatrix {N : ℕ} (hN : 1 ≤ N) (a : Fin N → ℂ) : Matrix (SystemIndex N) (SystemIndex N) ℂ := + LinearMap.toMatrix (systemBasis N) (targetBasis N) (perturbedSystem hN a) +theorem target_repr (N : ℕ) (p : degreeLT ℂ (4*N+2)) (i : SystemIndex N) : + (targetBasis N).repr p i = p.val.coeff (systemIndexEquiv N i) := by + simp only [targetBasis, Module.Basis.repr_reindex_apply, Equiv.symm_symm, degreeLT.basis_repr] +theorem systemMatrix_continuous {N : ℕ} (hN : 1 ≤ N) : Continuous (systemMatrix hN) := by + apply continuous_pi + intro i + apply continuous_pi + intro j + simp only [systemMatrix, LinearMap.toMatrix_apply, target_repr] + exact ((CoeffContinuous.const (projectionMap N (systemBasis N j).1)).sub + ((perturbedRootC_continuous N).mul (CoeffContinuous.const (systemBasis N j).2.val))) _ + +theorem systemMatrix_homogeneous_unit {N : ℕ} (hN : 1 ≤ N) : + IsUnit (systemMatrix hN (fun _ => flatC)).det := by + apply (Matrix.isUnit_iff_isUnit_det _).1 + apply Matrix.mulVec_injective_iff_isUnit.1 + intro v w he + let b := systemBasis N + let bv := b.equivFun.symm v + let bw := b.equivFun.symm w + have hrepr (x : SystemSpace N) : systemMatrix hN (fun _ => flatC) *ᵥ b.equivFun x = + (targetBasis N).equivFun (perturbedSystem hN (fun _ => flatC) x) := + LinearMap.toMatrix_mulVec_repr _ _ _ _ + have hve : b.equivFun bv = v := b.equivFun.apply_symm_apply v + have hwe : b.equivFun bw = w := b.equivFun.apply_symm_apply w + rw [← hve, ← hwe, hrepr, hrepr] at he + have heq := (homogeneous_system_injective N hN) ((targetBasis N).equivFun.injective he) + exact hve.symm.trans ((congrArg b.equivFun heq).trans hwe) + +def systemRHS {N : ℕ} (a : Fin N → ℂ) : degreeLT ℂ (4*N+2) := + ⟨perturbedRootC a * X^N, mem_degreeLT.2 (by + apply (degree_le_natDegree).trans_lt + apply WithBot.coe_lt_coe.2 + simp only [Nat.cast_id] + have hh := natDegree_mul_le (p := perturbedRootC a) (q := (X : Polynomial ℂ)^N) + have hd := perturbedRootC_natDegree_le a + simp only [natDegree_X_pow] at hh + omega)⟩ +def rhsVector {N : ℕ} (a : Fin N → ℂ) : SystemIndex N → ℂ := + (targetBasis N).equivFun (systemRHS a) +theorem rhsVector_continuous (N : ℕ) : Continuous (@rhsVector N) := by + apply continuous_pi + intro i + simp only [rhsVector, Module.Basis.equivFun_apply, target_repr] + exact ((perturbedRootC_continuous N).mul (CoeffContinuous.const (X^N))) _ +def solutionVector {N : ℕ} (hN : 1 ≤ N) (a : Fin N → ℂ) : SystemIndex N → ℂ := + (systemMatrix hN a)⁻¹ *ᵥ rhsVector a +def solutionTuple {N : ℕ} (hN : 1 ≤ N) (a : Fin N → ℂ) : SystemSpace N := + (systemBasis N).equivFun.symm (solutionVector hN a) +def confluentPolynomial {N : ℕ} (hN : 1 ≤ N) (a : Fin N → ℂ) : Polynomial ℂ := + X^N + (solutionTuple hN a).2.val + +theorem solutionVector_continuousAt {N : ℕ} (hN : 1 ≤ N) : + ContinuousAt (solutionVector hN) (fun _ => flatC) := by + have hd := isUnit_iff_ne_zero.1 (systemMatrix_homogeneous_unit hN) + have hi : ContinuousAt (fun a => (systemMatrix hN a)⁻¹) (fun _ => flatC) := by + apply ContinuousAt.comp ?_ (systemMatrix_continuous hN).continuousAt + apply continuousAt_matrix_inv + simpa only [show (Ring.inverse : ℂ → ℂ) = Inv.inv from funext Ring.inverse_eq_inv] using continuousAt_inv₀ hd + apply continuousAt_pi.2 + intro i + change ContinuousAt (fun a => ∑ j, (systemMatrix hN a)⁻¹ i j * rhsVector a j) _ + apply tendsto_finsetSum + intro j _ + exact (((continuous_apply j).continuousAt.comp ((continuous_apply i).continuousAt.comp hi))).mul + ((continuous_apply j).continuousAt.comp (rhsVector_continuous N).continuousAt) + +theorem confluentPolynomial_continuousAt {N : ℕ} (hN : 1 ≤ N) (k : ℕ) : + ContinuousAt (fun a => (confluentPolynomial hN a).coeff k) (fun _ => flatC) := by + simp only [confluentPolynomial, solutionTuple, Module.Basis.equivFun_symm_apply, + Prod.snd_sum, Prod.smul_snd, Submodule.coe_sum, Submodule.coe_smul, coeff_add, finsetSum_coeff, coeff_smul, smul_eq_mul] + apply continuousAt_const.add + apply tendsto_finsetSum + intro i _ + exact ((continuous_apply i).continuousAt.comp (solutionVector_continuousAt hN)).mul continuousAt_const + +theorem solutionTuple_spec {N : ℕ} (hN : 1 ≤ N) (a : Fin N → ℂ) + (ha : IsUnit (systemMatrix hN a).det) : + perturbedSystem hN a (solutionTuple hN a) = systemRHS a := by + apply (targetBasis N).equivFun.injective + simp only [Module.Basis.equivFun_apply] + rw [← LinearMap.toMatrix_mulVec_repr (systemBasis N) (targetBasis N) (perturbedSystem hN a)] + change systemMatrix hN a *ᵥ (systemBasis N).equivFun (solutionTuple hN a) = rhsVector a + rw [solutionTuple, LinearEquiv.apply_symm_apply] + rw [solutionVector, Matrix.mulVec_mulVec, Matrix.mul_nonsing_inv _ ha, Matrix.one_mulVec] + +theorem confluentPolynomial_spec {N : ℕ} (hN : 1 ≤ N) (a : Fin N → ℂ) + (ha : IsUnit (systemMatrix hN a).det) : PerturbedMonicProblemC a (confluentPolynomial hN a) := by + let t := solutionTuple hN a + have hlow : t.2.val.degree < (N : WithBot ℕ) := mem_degreeLT.1 t.2.property + refine ⟨monic_X_pow_add hlow, ?_, ?_⟩ + · apply natDegree_eq_of_degree_eq_some + simpa only [degree_X_pow, confluentPolynomial, t] using degree_add_eq_left_of_degree_lt (p := (X : Polynomial ℂ)^N) (q := t.2.val) + (by simpa only [degree_X_pow] using hlow) + · refine ⟨t.1.1.val, t.1.2.1.val, t.1.2.2.val, + natDegree_le_of_mem_degreeLT t.1.1.property, natDegree_le_of_mem_degreeLT t.1.2.1.property, + mem_degreeLT.1 t.1.2.2.property, ?_⟩ + have he := congrArg Subtype.val (solutionTuple_spec hN a ha) + change projectionMap N t.1-perturbedRootC a*t.2.val=perturbedRootC a*X^N at he + change perturbedRootC a*(X^N+t.2.val)=projectionMap N t.1 + linear_combination -he + +theorem perturbed_unique {N : ℕ} (hN : 1 ≤ N) (a : Fin N → ℂ) + (ha : IsUnit (systemMatrix hN a).det) (p : Polynomial ℂ) (hp : PerturbedMonicProblemC a p) : + p = confluentPolynomial hN a := by + obtain ⟨hpmonic, hpN, P,J,E,hP,hJ,hE,hQ⟩ := hp + have hpdeg : p.degree = (N : WithBot ℕ) := by rw [degree_eq_natDegree hpmonic.ne_zero, hpN] + have hlow : (p-X^N).degree < (N : WithBot ℕ) := by + simpa only [hpdeg] using degree_sub_lt_left + (p := p) (q := (X : Polynomial ℂ)^N) (by simpa only [degree_X_pow] using hpdeg) + hpmonic.ne_zero (hpmonic.trans (monic_X_pow N).symm) + let t : SystemSpace N := ((⟨P,mem_degreeLT.2 (degree_le_natDegree.trans_lt (by exact_mod_cast Nat.lt_succ_of_le hP))⟩, + ⟨J,mem_degreeLT.2 (degree_le_natDegree.trans_lt (by exact_mod_cast Nat.lt_succ_of_le hJ))⟩, + ⟨E,mem_degreeLT.2 hE⟩), ⟨p-X^N,mem_degreeLT.2 hlow⟩) + have he : perturbedSystem hN a t = systemRHS a := by + apply Subtype.ext + change P.comp harmonicPoly+X*J.comp harmonicPoly+X^2*E.comp harmonicPoly- + perturbedRootC a*(p-X^N)=perturbedRootC a*X^N + linear_combination -hQ + have hinj : Function.Injective (perturbedSystem hN a) := by + intro x y hxy + apply (systemBasis N).equivFun.injective + apply (Matrix.mulVec_injective_iff_isUnit.2 ((Matrix.isUnit_iff_isUnit_det _).2 ha)) + change systemMatrix hN a *ᵥ (systemBasis N).repr x = systemMatrix hN a *ᵥ (systemBasis N).repr y + rw [systemMatrix, LinearMap.toMatrix_mulVec_repr, LinearMap.toMatrix_mulVec_repr, hxy] + have ht : t=solutionTuple hN a := hinj (he.trans (solutionTuple_spec hN a ha).symm) + have hlast := congrArg (fun t : SystemSpace N => t.2.val) ht + change p-X^N=(solutionTuple hN a).2.val at hlast + rw [confluentPolynomial, ← hlast] + ring + +lemma real_monic_problem_map {N : ℕ} {g : Polynomial ℝ} + (hg : CriticalStrip.MonicProblem N g) : + PerturbedMonicProblemC (fun _ : Fin N => flatC) (g.map Complex.ofRealHom) := by + obtain ⟨hgm,hgn,P,J,E,hP,hJ,hE,hQ⟩ := hg + refine ⟨hgm.map _, ?_, P.map Complex.ofRealHom, J.map Complex.ofRealHom, + E.map Complex.ofRealHom, natDegree_map_le.trans hP, natDegree_map_le.trans hJ, + degree_map_le.trans_lt hE, ?_⟩ + · rw [natDegree_map_of_leadingCoeff_ne_zero _ (by rw [hgm]; simp), hgn] + · have he := congrArg (Polynomial.map Complex.ofRealHom) hQ + rw [CriticalStrip.homogeneousQ] at he + rw [perturbedRoot_homogeneous, rootPolynomialC, CriticalStrip.rootPolynomial] + simpa only [Polynomial.map_mul, Polynomial.map_pow, Polynomial.map_sub, + Polynomial.map_X, Polynomial.map_C, Polynomial.map_add, Polynomial.map_comp, + map_harmonic] using he + + + +end +end StripPfaffian + +end OAI diff --git a/lean/OAI/Combinatorics/StripMass/SplitGluing.lean b/lean/OAI/Combinatorics/StripMass/SplitGluing.lean new file mode 100644 index 0000000000000000000000000000000000000000..24a714e99db647cfcc0542b216b26463a7987347 --- /dev/null +++ b/lean/OAI/Combinatorics/StripMass/SplitGluing.lean @@ -0,0 +1,617 @@ +import Mathlib +import OAI.Combinatorics.StripMass.ProjectionInjection + +namespace OAI + +/-! Critical honeycomb strip paths, polynomial identities and crossing mass. -/ + + +namespace CriticalStrip.Diagram +noncomputable section +open scoped Classical BigOperators + +lemma functionMatrix_omit_glue_adjoint {K : Type*} [CommRing K] {n : ℕ} + (r : Fin (n+1)) : + (glueMatrix (Fin.last (n+1)) : Matrix _ _ K) * + functionMatrix (Pairing.map (Fin.succAboveOrderEmb r.castSucc)) = + functionMatrix (Pairing.map (Fin.succAboveOrderEmb r.castSucc)) * + glueMatrix (Fin.last n) := by + simpa only [Pairing.omit_last] using + functionMatrix_glue_adjoint (K:=K) (Fin.succAboveOrderEmb r.castSucc) (Fin.last n) + +lemma position_padTop_root_ne {n : ℕ} (a : Position n) : + Fin.last n ≠ a.padTop.left ∧ Fin.last n ≠ a.padTop.right := by + constructor + · intro he + have hv := congrArg Fin.val he + have := a.left.isLt + simp only [Position.padTop,Fin.val_last,Fin.val_castSucc] at hv + omega + · intro he + have hv := congrArg Fin.val he + have := a.right.isLt + simp only [Position.padTop,Fin.val_last,Fin.val_castSucc] at hv + omega + +lemma mergeMap_glue_adjoint {n m : ℕ} (r : ℕ) (hr : r+2≤n+1) : + (glueMatrix (Fin.last (n+1)) : Matrix _ _ (SpectralField m)) * + mergeMap r (show r+2≤n+2 by omega) = + (mergeProjection r (show r+2≤n+2 by omega)).transpose * glueMatrix (Fin.last n) := by + let b : Fin (n+1) := ⟨r+1,by omega⟩ + let a := PartialColumn.rowPosition r hr + have ha : (Fin.succAboveOrderEmb b.castSucc) (Fin.last n) ≠ a.padTop.left := by + rw [Pairing.omit_last]; exact (position_padTop_root_ne a).1 + have hb : (Fin.succAboveOrderEmb b.castSucc) (Fin.last n) ≠ a.padTop.right := by + rw [Pairing.omit_last]; exact (position_padTop_root_ne a).2 + have h := splitProjection_glue_adjoint (Fin.succAboveOrderEmb b.castSucc) + a.padTop (mergeWeights (constF m phase)) (Fin.last n) ha hb + rw [Pairing.omit_last] at h + exact h + +lemma twoVacancyInsertion_glue_adjoint {K : Type*} [CommRing K] {n : ℕ} + (r : ℕ) (hr : r+2≤n+2) : + (glueMatrix (Fin.last (n+2)) : Matrix _ _ K) * + twoVacancyInsertion r (show r+2≤n+3 by omega) = + twoVacancyInsertion r (show r+2≤n+3 by omega) * glueMatrix (Fin.last n) := by + let b : Fin (n+2) := ⟨r+1,by omega⟩ + let a : Fin (n+1) := ⟨r,by omega⟩ + let B := functionMatrix (K:=K) (Pairing.map (Fin.succAboveOrderEmb b.castSucc)) + let A := functionMatrix (K:=K) (Pairing.map (Fin.succAboveOrderEmb a.castSucc)) + calc + _ = (glueMatrix (Fin.last (n+2))*B)*A := (Matrix.mul_assoc _ _ _).symm + _ = (B*glueMatrix (Fin.last (n+1)))*A := + congrArg (fun M => M*A) (functionMatrix_omit_glue_adjoint b) + _ = B*(glueMatrix (Fin.last (n+1))*A) := Matrix.mul_assoc _ _ _ + _ = B*(A*glueMatrix (Fin.last n)) := + congrArg (fun M => B*M) (functionMatrix_omit_glue_adjoint a) + _ = (B*A)*glueMatrix (Fin.last n) := (Matrix.mul_assoc _ _ _).symm + +lemma deletionMap_glue_adjoint {n m : ℕ} (r : ℕ) (hr : r+2≤n+2) : + (glueMatrix (Fin.last (n+2)) : Matrix _ _ (SpectralField m)) * + deletionMap r (show r+2≤n+3 by omega) = + (deletionProjection r (show r+2≤n+3 by omega)).transpose * glueMatrix (Fin.last n) := by + have adjoint {ι κ : Type} [Fintype ι] [Fintype κ] + (G L : Matrix ι ι (SpectralField m)) (E : Matrix ι κ (SpectralField m)) + (H : Matrix κ κ (SpectralField m)) (hL : G*L=L.transpose*G) (hE : G*E=E*H) : + G*(L*E) = (E.transpose*L).transpose*H := by + rw [Matrix.transpose_mul, Matrix.transpose_transpose, ← Matrix.mul_assoc, + hL, Matrix.mul_assoc, hE, ← Matrix.mul_assoc] + let a := PartialColumn.rowPosition r hr + let L := localR a.padTop (deletionWeights : Weights (SpectralField m)) + let E := twoVacancyInsertion (K:=SpectralField m) (n:=n+1) r (show r+2≤(n+1)+2 by omega) + let G := glueMatrix (K:=SpectralField m) (Fin.last (n+2)) + let H := glueMatrix (K:=SpectralField m) (Fin.last n) + have hL : G*L=L.transpose*G := localR_glue_adjoint a.padTop (Fin.last (n+2)) + (position_padTop_root_ne a).1 (position_padTop_root_ne a).2 deletionWeights + have hE : G*E=E*H := twoVacancyInsertion_glue_adjoint r hr + have h := adjoint G L E H hL hE + simp only [deletionProjection] at h ⊢ + dsimp +instances only [G, L, E, H, a, deletionMap, twoVacancyInsertion, + CStarMatrix, CStarMatrix.instHMulOfFintypeOfMulOfAddCommMonoid, CStarMatrix.ofMatrix, + Equiv.refl, Equiv.symm] at h ⊢ + simpa only [Equiv.coe_fn_mk, id_eq, PartialColumn.rowPosition, Position.padTop, + Fin.castSucc_mk] using h + + +theorem sourceGlue_merge {n m : ℕ} (r : ℕ) (hr : r+2≤n+1) + (v : SourcePairing (n+1) → SpectralField m) (w : SourcePairing n → SpectralField m) : + sourceGlue (n+1) v ((sourceBlock (mergeMap r (show r+2≤n+2 by omega))).mulVec w) = + sourceGlue n ((sourceBlock (mergeProjection r (show r+2≤n+2 by omega))).mulVec v) w := by + have h : sourceBlock (glueMatrix (K:=SpectralField m) (Fin.last (n+1))) * + sourceBlock (mergeMap (m:=m) r (show r+2≤n+2 by omega)) = + (sourceBlock (mergeProjection (m:=m) r (show r+2≤n+2 by omega))).transpose * + sourceBlock (glueMatrix (K:=SpectralField m) (Fin.last n)) := + ((glueMatrix_last (n+1)).source_mul _).symm.trans + ((congrArg sourceBlock (mergeMap_glue_adjoint (m:=m) r hr)).trans + ((mergeProjection_last r hr).transpose.source_mul _)) + unfold sourceGlue + rw [Matrix.mulVec_mulVec,h,←Matrix.mulVec_mulVec, + Matrix.dotProduct_mulVec,Matrix.vecMul_transpose] + + + +theorem sourceGlue_delete {n m : ℕ} (r : ℕ) (hr : r+2≤n+2) + (v : SourcePairing (n+2) → SpectralField m) (w : SourcePairing n → SpectralField m) : + sourceGlue (n+2) v ((sourceBlock (deletionMap r (show r+2≤n+3 by omega))).mulVec w) = + sourceGlue n ((sourceBlock (deletionProjection r (show r+2≤n+3 by omega))).mulVec v) w := by + have h : sourceBlock (glueMatrix (K:=SpectralField m) (Fin.last (n+2))) * + sourceBlock (deletionMap (m:=m) r (show r+2≤n+3 by omega)) = + (sourceBlock (deletionProjection (m:=m) r (show r+2≤n+3 by omega))).transpose * + sourceBlock (glueMatrix (K:=SpectralField m) (Fin.last n)) := + ((glueMatrix_last (n+2)).source_mul _).symm.trans + ((congrArg sourceBlock (deletionMap_glue_adjoint (m:=m) r hr)).trans + ((deletionProjection_last r hr).transpose.source_mul _)) + unfold sourceGlue + rw [Matrix.mulVec_mulVec,h,←Matrix.mulVec_mulVec, + Matrix.dotProduct_mulVec,Matrix.vecMul_transpose] + +lemma sourceGlue_smul_right {K : Type*} [CommRing K] (n : ℕ) (a : K) + (v w : SourcePairing n → K) : sourceGlue n v (a • w) = a*sourceGlue n v w := by + simpa only [one_smul,one_mul] using sourceGlue_scale n (1:K) a v w + +lemma sourceGlue_smul_left {K : Type*} [CommRing K] (n : ℕ) (a : K) + (v w : SourcePairing n → K) : sourceGlue n (a • v) w = a*sourceGlue n v w := by + simpa only [one_smul,mul_one] using sourceGlue_scale n a (1:K) v w + +lemma sourceGlue_algMap {R K L : Type*} [CommSemiring R] [CommRing K] [CommRing L] + [Algebra R K] [Algebra R L] (f : K →ₐ[R] L) (n : ℕ) + (v w : SourcePairing n → K) : + f (sourceGlue n v w) = sourceGlue n (f ∘ v) (f ∘ w) := + sourceGlue_map f.toRingHom n v w + + + +theorem polynomialNorthGluing_merge (n : ℕ) : + pairEvaluation n 2 (polynomialNorthGluing (n+2)) = + mergePairScalar n ^ 2 * mergeEvaluation n (polynomialNorthGluing (n+1)) := by + unfold polynomialNorthGluing + rw [sourceGlue_algMap (pairEvaluation n 2)] + have h : ((pairEvaluation n 2) ∘ polynomialNorthSource (n+2)) = + mergePairScalar n • + (sourceBlock (mergeMap (m:=n+1) 0 (show 2≤n+3 by omega))).mulVec + (fun q => mergeEvaluation n (polynomialNorthSource (n+1) q)) := by + funext p + exact polynomialNorthSource_merge n p + rw [h,sourceGlue_smul_right,sourceGlue_merge 0 (show 2≤n+2 by omega)] + simp only [Function.comp_def] + rw [polynomialNorthSource_reflected_merge n,sourceGlue_smul_left] + rw [sourceGlue_algMap (mergeEvaluation n)] + simp only [pow_two,mul_assoc] + rfl + + + +theorem polynomialNorthGluing_delete (n : ℕ) : + pairEvaluation n 3 (polynomialNorthGluing (n+2)) = + deletePairScalar n ^ 2 * deleteEvaluation n (polynomialNorthGluing n) := by + unfold polynomialNorthGluing + rw [sourceGlue_algMap (pairEvaluation n 3)] + have h : ((pairEvaluation n 3) ∘ polynomialNorthSource (n+2)) = + deletePairScalar n • + (sourceBlock (deletionMap (m:=n+1) 0 (show 2≤n+3 by omega))).mulVec + (fun q => deleteEvaluation n (polynomialNorthSource n q)) := by + funext p + exact polynomialNorthSource_delete n p + rw [h,sourceGlue_smul_right,sourceGlue_delete 0 (show 2≤n+2 by omega)] + simp only [Function.comp_def] + rw [polynomialNorthSource_reflected_delete n,sourceGlue_smul_left] + rw [sourceGlue_algMap (deleteEvaluation n)] + simp only [pow_two,mul_assoc] + rfl + + + + + + +lemma lastCoefficient_cons_padBottom {K : Type*} [CommRing K] {n : ℕ} + (r : Tile → K) (w : Fin n → Tile → K) (p q : Pairing (n+1)) : + lastCoefficient (Fin.cons r w) q.padBottom p.padBottom = + r .vacant * lastCoefficient w q p := by + have h := rawColumn_padBottom (Fin.snoc w (fun _ => (1:K))) r p q + rw [Fin.cons_snoc_eq_snoc_cons,rawColumn_last_factor,rawColumn_last_factor] at h + simpa only [mul_one] using h + +lemma lastFactor_padBottom {K : Type*} [CommRing K] {n : ℕ} + (d c C : K) (p q : Pairing (n+1)) : + lastFactor d c C p.padBottom q.padBottom = lastFactor d c C p q := by + simp only [lastFactor,←Fin.succ_last,Pairing.padBottom_occupied_succ] + +lemma firstZeroPolynomial_padBottom {K : Type*} [CommRing K] {n : ℕ} + (w : Fin n → Tile → K) (d c C : K) + (P : Pairing (n+1) → Polynomial K) (q : Pairing (n+1)) : + firstZeroPolynomial w d c C P q.padBottom = lastTransform w d c C P q := by + unfold firstZeroPolynomial lastTransform + symm + apply Fintype.sum_of_injective Pairing.padBottom Pairing.padBottom_injective + · intro p hp + have h : p.Occupied 0 := by + by_contra h + exact hp ⟨p.restrict (Fin.succOrderEmb (n+1)),p.padBottom_restrict h⟩ + simp [vacantBottomExtension,h] + · intro p + rw [lastCoefficient_cons_padBottom,lastFactor_padBottom,vacantBottomExtension_padBottom] + simp [Weights.tile] + +lemma rationalFirstZeroPolynomial_vacant (n : ℕ) (q : Pairing (n+1)) : + firstZeroPolynomial (fun j => (spectralWeights n j).tile) + (constF n d) (constF n c) (constF n C) (rationalNodalPolynomial n) q.padBottom = + (Polynomial.X+Polynomial.C (constF n C))*rationalNodalPolynomial n q := by + rw [firstZeroPolynomial_padBottom] + exact sub_eq_zero.mp (rationalResidualPolynomial_zero n q) + + +def SourcePairing.padBottom {n : ℕ} (p : SourcePairing n) : SourcePairing (n+1) := + ⟨p.val.padBottom,(p.val.padBottom_occupied_succ (Fin.last n)).mpr p.property⟩ + +lemma SourcePairing.padBottom_injective {n : ℕ} : + Function.Injective (@SourcePairing.padBottom n) := by + intro p q h + exact Subtype.ext (Pairing.padBottom_injective (congrArg Subtype.val h)) + +lemma SourcePairing.padBottom_range {n : ℕ} (p : SourcePairing (n+1)) : + p ∈ Set.range SourcePairing.padBottom ↔ ¬p.val.Occupied 0 := by + constructor + · rintro ⟨q,rfl⟩ + exact q.val.padBottom_not_occupied_zero + · intro h + have hp := p.val.padBottom_restrict h + let q := p.val.restrict (Fin.succOrderEmb (n+1)) + have hq : q.Occupied (Fin.last n) := by + rw [←Pairing.padBottom_occupied_succ q (Fin.last n),hp] + exact p.property + exact ⟨⟨q,hq⟩,Subtype.ext hp⟩ + +def vacantBottomSourceExtension {K : Type*} [Zero K] {n : ℕ} + (v : SourcePairing n → K) (p : SourcePairing (n+1)) : K := + if h : p ∈ Set.range SourcePairing.padBottom then v (Classical.choose h) else 0 + +lemma vacantBottomSourceExtension_padBottom {K : Type*} [Zero K] {n : ℕ} + (v : SourcePairing n → K) (q : SourcePairing n) : + vacantBottomSourceExtension v q.padBottom=v q := by + rw [vacantBottomSourceExtension,dite_eq_left ⟨q,rfl⟩] + congr 1 + exact SourcePairing.padBottom_injective (Classical.choose_spec (show q.padBottom ∈ Set.range SourcePairing.padBottom from ⟨q,rfl⟩)) + +lemma coefficient_X_add_source {n : ℕ} (p : SourcePairing n) : + ((Polynomial.X+Polynomial.C (constF n C))*rationalNodalPolynomial n p.val).coeff n = + northNumerator n p := by + by_cases hn : n=0 + · subst n + exact (p.ne_empty (p.val.eq_empty_of_le_one (by omega))).elim + · obtain ⟨k,rfl⟩ := Nat.exists_eq_succ_of_ne_zero hn + have hz := rationalNodalPolynomial_degree (k+1) p.val (k+1) (by simp [p.property]) + simp only [add_mul,Polynomial.coeff_add,Polynomial.coeff_X_mul,Polynomial.coeff_C_mul,hz, + mul_zero,add_zero,northNumerator,Nat.succ_sub_one] + + + +theorem polynomialNorthSource_firstFlat (n : ℕ) (p : SourcePairing n) : + firstFlatEvaluation n (polynomialNorthSource (n+1) p.padBottom) = + (∏ j:Fin n,(spectralA j+constF n C))*evalLaurent (polynomialNorthSource n p) := by + have h := congrFun (rationalNodalPolynomial_firstFlat + (vacuumData n).interpolant (vacuumData (n+1)).P + (vacuumData (n+1)).map_P) p.val.padBottom + have hc := congrArg (fun P : Polynomial (SpectralField n) => P.coeff n) h + rw [rationalFirstZeroPolynomial_vacant,Polynomial.coeff_map,Polynomial.coeff_C_mul, + coefficient_X_add_source] at hc + change firstFlatEvaluation n (((vacuumData (n+1)).P p.val.padBottom).coeff n) = _ at hc + rw [polynomialNorthSource_eval_numerator] + unfold polynomialNorthSource + rw [map_mul] + simp only [Nat.add_sub_cancel,SourcePairing.padBottom] + rw [hc] + rw [show firstFlatEvaluation n (constantL (n+1) (1/(2*(d:ℂ)))) = + constF n (1/(2*(d:ℂ))) from torusEvaluation_constant _ _ _] + ring + + + +theorem polynomialNorthSource_firstThree (n : ℕ) : + (fun p => firstThreeEvaluation n (polynomialNorthSource (n+1) p)) = + (∏ j:Fin n,(spectralA j+constF n C)) • + vacantBottomSourceExtension (fun p => evalLaurent (polynomialNorthSource n p)) := by + funext p + have h := congrFun (rationalNodalPolynomial_firstThree + (polynomialVacuumVector n) (polynomialVacuumVector_eval n) + (vacuumData (n+1)).P (vacuumData (n+1)).map_P) p.val + have hc := congrArg (fun P : Polynomial (SpectralField n) => P.coeff n) h + rw [Polynomial.coeff_map,Polynomial.coeff_C_mul] at hc + change firstThreeEvaluation n (((vacuumData (n+1)).P p.val).coeff n) = _ at hc + simp only [Pi.smul_apply,smul_eq_mul] + by_cases hp : p ∈ Set.range SourcePairing.padBottom + · obtain ⟨q,rfl⟩ := hp + simp only [SourcePairing.padBottom] at hc + rw [firstThreePolynomial_padBottom,coefficient_X_add_source] at hc + rw [vacantBottomSourceExtension_padBottom,polynomialNorthSource_eval_numerator] + unfold polynomialNorthSource + rw [map_mul] + simp only [Nat.add_sub_cancel,SourcePairing.padBottom] + rw [hc,show firstThreeEvaluation n (constantL (n+1) (1/(2*(d:ℂ)))) = + constF n (1/(2*(d:ℂ))) from torusEvaluation_constant _ _ _] + ring + · have ho : p.val.Occupied 0 := not_not.mp (fun h => hp ((SourcePairing.padBottom_range p).mpr h)) + simp only [firstThreePolynomial,vacantBottomExtension,ho,ite_true,mul_zero, + Polynomial.coeff_zero] at hc + simp only [vacantBottomSourceExtension,dite_eq_right hp,mul_zero] + unfold polynomialNorthSource + rw [map_mul] + simp only [Nat.add_sub_cancel] + rw [hc,mul_zero] + +lemma firstFlatEvaluation_reflect {n : ℕ} (f : Laurent (n+1)) : + firstFlatEvaluation n (reflectLaurent (n+1) f) = + reflectSpectral n (firstThreeEvaluation n f) := by + unfold firstFlatEvaluation firstThreeEvaluation + rw [torusEvaluation_reflect, + torusEvaluation_fieldMap (reflectSpectral n) (reflectSpectral_const n)] + congr 2 + funext i + refine Fin.cases ?_ (fun i => ?_) i + · simp only [firstFlatPoint,firstThreePoint,Fin.cons_zero,div_one,map_pow,reflectSpectral_const] + · simp only [firstFlatPoint,firstThreePoint,Fin.cons_succ,reflectSpectral_variable] + +lemma firstThreeEvaluation_reflect {n : ℕ} (f : Laurent (n+1)) : + firstThreeEvaluation n (reflectLaurent (n+1) f) = + reflectSpectral n (firstFlatEvaluation n f) := by + have h := firstFlatEvaluation_reflect (reflectLaurent (n+1) f) + rw [reflectLaurent_involutive] at h + exact ((reflectSpectral_involutive n _).symm.trans (congrArg (reflectSpectral n) h).symm) + +lemma vacantBottomSourceExtension_map {K L : Type*} [Zero K] [Zero L] {n : ℕ} + (f : K → L) (hf : f 0=0) (v : SourcePairing n → K) (p : SourcePairing (n+1)) : + f (vacantBottomSourceExtension v p) = vacantBottomSourceExtension (f ∘ v) p := by + unfold vacantBottomSourceExtension + split_ifs <;> simp [hf] + +lemma sourceGlue_vacantBottom_right {K : Type*} [CommRing K] {n : ℕ} + (v : SourcePairing (n+1) → K) (w : SourcePairing n → K) : + sourceGlue (n+1) v (vacantBottomSourceExtension w) = + sourceGlue n (v ∘ SourcePairing.padBottom) w := by + rw [sourceGlue_eq_sum,sourceGlue_eq_sum] + have hinner (p : SourcePairing (n+1)) : + (∑ q : SourcePairing (n+1), v p * + ((if Pairing.GluesAt (Fin.last (n+1)) p.val q.val then (1:K) else 0) * + vacantBottomSourceExtension w q)) = + ∑ q : SourcePairing n, v p * + ((if Pairing.GluesAt (Fin.last (n+1)) p.val q.padBottom.val then (1:K) else 0)*w q) := by + symm + apply Fintype.sum_of_injective SourcePairing.padBottom SourcePairing.padBottom_injective + · intro q hq + simp [vacantBottomSourceExtension,hq] + · intro q + rw [vacantBottomSourceExtension_padBottom] + simp_rw [hinner] + symm + apply Fintype.sum_of_injective SourcePairing.padBottom SourcePairing.padBottom_injective + · intro p hp + apply Finset.sum_eq_zero + intro q _ + have hh : ¬Pairing.GluesAt (Fin.last (n+1)) p.val q.padBottom.val := by + intro h + have ho : ¬p.val.Occupied 0 := fun ho => + q.val.padBottom_not_occupied_zero ((h.2.1 0).mp ho) + exact hp ((SourcePairing.padBottom_range p).mpr ho) + rw [ite_eq_right hh,zero_mul,mul_zero] + · intro p + apply Finset.sum_congr rfl + intro q _ + have hh : Pairing.GluesAt (Fin.last (n+1)) p.padBottom.val q.padBottom.val ↔ + Pairing.GluesAt (Fin.last n) p.val q.val := + Pairing.gluesAt_map (Fin.succOrderEmb _) (Fin.last n) p.val q.val + simp only [hh,Function.comp_apply] + +lemma sourceGlue_vacantBottom_left {K : Type*} [CommRing K] {n : ℕ} + (v : SourcePairing n → K) (w : SourcePairing (n+1) → K) : + sourceGlue (n+1) (vacantBottomSourceExtension v) w = + sourceGlue n v (w ∘ SourcePairing.padBottom) := by + rw [sourceGlue_symmetric,sourceGlue_vacantBottom_right,sourceGlue_symmetric] + + + +theorem polynomialNorthGluing_firstFlat (n : ℕ) : + firstFlatEvaluation n (polynomialNorthGluing (n+1)) = + (∏ j:Fin n,(spectralA j+constF n C))^2 * evalLaurent (polynomialNorthGluing n) := by + unfold polynomialNorthGluing + rw [sourceGlue_algMap (firstFlatEvaluation n)] + have hv : (fun p : SourcePairing (n+1) => firstFlatEvaluation n + (reflectLaurent (n+1) (polynomialNorthSource (n+1) p))) = + (∏ j:Fin n,(spectralA j+constF n C)) • + vacantBottomSourceExtension (fun p => evalLaurent (reflectLaurent n (polynomialNorthSource n p))) := by + funext p + rw [firstFlatEvaluation_reflect,congrFun (polynomialNorthSource_firstThree n) p] + simp only [Pi.smul_apply,smul_eq_mul,map_mul,map_prod,map_add,reflectSpectral_const, + reflectSpectral_spectralA,vacantBottomSourceExtension_map _ (map_zero _)] + congr 2 + funext q + exact reflectSpectral_evalLaurent _ + change ((firstFlatEvaluation n) ∘ (fun p => reflectLaurent (n+1) (polynomialNorthSource (n+1) p))) = _ at hv + rw [hv,sourceGlue_smul_left,sourceGlue_vacantBottom_left] + have hw : ((firstFlatEvaluation n) ∘ polynomialNorthSource (n+1)) ∘ SourcePairing.padBottom = + (∏ j:Fin n,(spectralA j+constF n C)) • + (fun p => evalLaurent (polynomialNorthSource n p)) := by + funext p + exact polynomialNorthSource_firstFlat n p + rw [hw,sourceGlue_smul_right] + unfold evalLaurent + rw [sourceGlue_map] + simp only [pow_two,mul_assoc] + rfl + + +theorem polynomialNorthGluing_firstThree (n : ℕ) : + firstThreeEvaluation n (polynomialNorthGluing (n+1)) = + (∏ j:Fin n,(spectralA j+constF n C))^2 * evalLaurent (polynomialNorthGluing n) := by + rw [←polynomialNorthGluing_reflection (n+1),firstThreeEvaluation_reflect, + polynomialNorthGluing_firstFlat] + simp only [map_mul,map_pow,map_prod,map_add,reflectSpectral_const, + reflectSpectral_spectralA,reflectSpectral_evalLaurent,polynomialNorthGluing_reflection] + + + + + + + +def reflectExponentAt {n : ℕ} (i : Fin n) (e : Fin n → ℤ) : Fin n → ℤ := + Function.update e i (-e i) + +@[simp] lemma reflectExponentAt_same {n : ℕ} (i : Fin n) (e : Fin n → ℤ) : + reflectExponentAt i e i = -e i := by simp [reflectExponentAt] +lemma reflectExponentAt_other {n : ℕ} (i j : Fin n) (h : j ≠ i) (e : Fin n → ℤ) : + reflectExponentAt i e j = e j := by simp [reflectExponentAt,h] +@[simp] lemma reflectExponentAt_zero {n : ℕ} (i : Fin n) : + reflectExponentAt i 0 = 0 := by ext j; simp [reflectExponentAt] +lemma reflectExponentAt_add {n : ℕ} (i : Fin n) (e f : Fin n → ℤ) : + reflectExponentAt i (e+f) = reflectExponentAt i e + reflectExponentAt i f := by + ext j + by_cases h:j=i <;> simp [reflectExponentAt,h,add_comm] +@[simp] lemma reflectExponentAt_neg {n : ℕ} (i : Fin n) (e : Fin n → ℤ) : + reflectExponentAt i (-e) = -reflectExponentAt i e := by + ext j + by_cases h:j=i <;> simp [reflectExponentAt,h] +@[simp] lemma reflectExponentAt_involutive {n : ℕ} (i : Fin n) (e : Fin n → ℤ) : + reflectExponentAt i (reflectExponentAt i e) = e := by + ext j + by_cases h:j=i <;> simp [reflectExponentAt,h] + +def rowReflectionMonomial {n : ℕ} (i : Fin n) : + Multiplicative (Fin n → ℤ) →* Laurent n where + toFun e := monomialL (reflectExponentAt i e.toAdd) (phase ^ (3 * e.toAdd i)) + map_one' := by simp [monomialL]; rfl + map_mul' e f := by + change monomialL (reflectExponentAt i (e.toAdd+f.toAdd)) + (phase ^ (3 * (e.toAdd i+f.toAdd i))) = _ + rw [mul_add, zpow_add₀ phase_ne_zero, reflectExponentAt_add] + exact (AddMonoidAlgebra.single_mul_single _ _ _ _).symm + +def rowReflectLaurent {n : ℕ} (i : Fin n) : Laurent n →+* Laurent n := + (AddMonoidAlgebra.lift ℂ (Laurent n) (Fin n → ℤ) (rowReflectionMonomial i)).toRingHom + +@[simp] lemma rowReflectLaurent_monomial {n : ℕ} (i : Fin n) (e : Fin n → ℤ) (z : ℂ) : + rowReflectLaurent i (monomialL e z) = + monomialL (reflectExponentAt i e) (z * phase ^ (3 * e i)) := by + change AddMonoidAlgebra.lift ℂ _ _ (rowReflectionMonomial i) (AddMonoidAlgebra.single e z) = _ + rw [AddMonoidAlgebra.lift_single] + change z • AddMonoidAlgebra.single _ _ = AddMonoidAlgebra.single _ _ + rw [AddMonoidAlgebra.smul_single, smul_eq_mul] + rfl + +lemma rowReflectLaurent_involutive {n : ℕ} (i : Fin n) : + Function.Involutive (rowReflectLaurent i) := by + have h : (rowReflectLaurent i).comp (rowReflectLaurent i) = RingHom.id _ := by + apply AddMonoidAlgebra.ringHom_ext <;> intro e + all_goals change rowReflectLaurent i (rowReflectLaurent i (monomialL _ _)) = monomialL _ _ + all_goals rw [rowReflectLaurent_monomial,rowReflectLaurent_monomial] + all_goals simp only [reflectExponentAt_involutive,reflectExponentAt_same,mul_neg, + mul_assoc,← zpow_add₀ phase_ne_zero,add_neg_cancel,zpow_zero,mul_one] + exact fun f => DFunLike.congr_fun h f + +def rowReflectSpectral {n : ℕ} (i : Fin n) : SpectralField n →+* SpectralField n := + IsFractionRing.lift (K := SpectralField n) + (g := (algebraMap (SpectralRing n) (SpectralField n)).comp (rowReflectLaurent i)) + ((IsFractionRing.injective (SpectralRing n) (SpectralField n)).comp + (rowReflectLaurent_involutive i).injective) + +@[simp] lemma rowReflectSpectral_evalLaurent {n : ℕ} (i : Fin n) (f : Laurent n) : + rowReflectSpectral i (evalLaurent f) = evalLaurent (rowReflectLaurent i f) := + IsFractionRing.lift_algebraMap _ _ + +lemma rowReflectSpectral_involutive {n : ℕ} (i : Fin n) : + Function.Involutive (rowReflectSpectral i) := by + have h : (rowReflectSpectral i).comp (rowReflectSpectral i) = RingHom.id _ := by + apply IsFractionRing.ringHom_ext (A := SpectralRing n) + intro f + change rowReflectSpectral i (rowReflectSpectral i (evalLaurent f)) = evalLaurent f + rw [rowReflectSpectral_evalLaurent,rowReflectSpectral_evalLaurent,rowReflectLaurent_involutive] + exact fun f => DFunLike.congr_fun h f + +@[simp] lemma rowReflectSpectral_const {n : ℕ} (i : Fin n) (z : ℂ) : + rowReflectSpectral i (constF n z) = constF n z := by + have hc : constF n z = evalLaurent (constantL n z) := (map_constantL n z).symm + rw [hc,rowReflectSpectral_evalLaurent] + change evalLaurent (rowReflectLaurent i (monomialL 0 z)) = evalLaurent (monomialL 0 z) + rw [rowReflectLaurent_monomial] + simp + +@[simp] lemma rowReflectSpectral_variable {n : ℕ} (i j : Fin n) : + rowReflectSpectral i (variableF j) = + if j=i then constF n phase ^ 3 / variableF j else variableF j := by + change rowReflectSpectral i (evalLaurent (monomialL (variableExponent j) 1)) = _ + rw [rowReflectSpectral_evalLaurent,rowReflectLaurent_monomial] + by_cases h:j=i + · subst j + have he : reflectExponentAt i (variableExponent i) = -variableExponent i := by + ext k; by_cases hh:k=i <;> simp [reflectExponentAt,variableExponent,hh] + rw [he] + simp only [variableExponent,Pi.single_eq_same,one_mul,mul_one,ite_true,zpow_ofNat] + change evalLaurent (monomialL (-variableExponent i) (phase^3)) = _ + rw [evalLaurent,map_monomialL_neg_variable] + simp [constF,div_eq_mul_inv] + · have he : reflectExponentAt i (variableExponent j) = variableExponent j := by + ext k + by_cases hh:k=i + · subst k; simp [reflectExponentAt,variableExponent,Ne.symm h] + · simp [reflectExponentAt,hh] + rw [he] + simp only [variableExponent,Pi.single_apply,ite_eq_right (Ne.symm h),mul_zero,zpow_zero, + one_mul,ite_eq_right h] + rfl + +@[simp] lemma rowReflectSpectral_torusSin {n : ℕ} (i : Fin n) (z : SpectralField n) : + rowReflectSpectral i (torusSin z) = torusSin (rowReflectSpectral i z) := by + simp [torusSin,map_div₀,map_inv₀,map_ofNat] +@[simp] lemma rowReflectSpectral_torusCos {n : ℕ} (i : Fin n) (z : SpectralField n) : + rowReflectSpectral i (torusCos z) = torusCos (rowReflectSpectral i z) := by + simp [torusCos,map_div₀,map_inv₀,map_ofNat] +@[simp] lemma rowReflectSpectral_torusL {n : ℕ} (i : Fin n) (z : SpectralField n) : + rowReflectSpectral i (torusL z) = torusL (rowReflectSpectral i z) := by simp [torusL] +@[simp] lemma rowReflectSpectral_torusWeights {n : ℕ} (i : Fin n) (z : SpectralField n) : + (torusWeights z).map (rowReflectSpectral i) = torusWeights (rowReflectSpectral i z) := by + simp [Weights.map,torusWeights,map_div₀] + +@[simp] lemma rowReflectSpectral_spectralA {n : ℕ} (i j : Fin n) : + rowReflectSpectral i (spectralA j) = spectralA j := by + simp only [spectralA,rowReflectSpectral_torusCos,map_div₀,map_pow, + rowReflectSpectral_const,rowReflectSpectral_variable] + split_ifs + · unfold torusCos + field_simp [variableF_ne_zero,constF_phase_ne_zero] + ring + · rfl +@[simp] lemma rowReflectSpectral_normalization {n : ℕ} (i : Fin n) : + rowReflectSpectral i (spectralNormalization n) = spectralNormalization n := by + simp only [spectralNormalization,map_scalarNormalization,rowReflectSpectral_const, + rowReflectSpectral_spectralA] + +lemma reflectLaurent_rowReflect {n : ℕ} (i : Fin n) (f : Laurent n) : + reflectLaurent n (rowReflectLaurent i f) = rowReflectLaurent i (reflectLaurent n f) := by + have he (e : Fin n → ℤ) : ∑ j, reflectExponentAt i e j = ∑ j,e j - 2*e i := by + rw [reflectExponentAt,Finset.sum_update_of_mem (Finset.mem_univ i)] + have h := Finset.sum_sdiff (f:=e) (Finset.subset_univ ({i} : Finset (Fin n))) + simp only [Finset.sum_singleton] at h + omega + have h : (reflectLaurent n).comp (rowReflectLaurent i) = + (rowReflectLaurent i).comp (reflectLaurent n) := by + apply AddMonoidAlgebra.ringHom_ext <;> intro e + all_goals change reflectLaurent n (rowReflectLaurent i (monomialL _ _)) = + rowReflectLaurent i (reflectLaurent n (monomialL _ _)) + all_goals rw [rowReflectLaurent_monomial,reflectLaurent_monomial, + reflectLaurent_monomial,rowReflectLaurent_monomial,reflectExponentAt_neg] + all_goals simp only [mul_assoc,←zpow_add₀ phase_ne_zero,he,Pi.neg_apply] + all_goals (congr 2; ring_nf) + exact DFunLike.congr_fun h f + +lemma reflectSpectral_rowReflect {n : ℕ} (i : Fin n) (f : SpectralField n) : + reflectSpectral n (rowReflectSpectral i f) = rowReflectSpectral i (reflectSpectral n f) := by + have h : (reflectSpectral n).comp (rowReflectSpectral i) = + (rowReflectSpectral i).comp (reflectSpectral n) := by + apply IsFractionRing.ringHom_ext (A := SpectralRing n) + intro f + change reflectSpectral n (rowReflectSpectral i (evalLaurent f)) = + rowReflectSpectral i (reflectSpectral n (evalLaurent f)) + simp only [reflectSpectral_evalLaurent,rowReflectSpectral_evalLaurent,reflectLaurent_rowReflect] + exact DFunLike.congr_fun h f + +lemma rowReflectLaurent_perm {n : ℕ} (i : Fin n) (σ : Equiv.Perm (Fin n)) (f : Laurent n) : + rowReflectLaurent (σ i) (permLaurent σ f) = permLaurent σ (rowReflectLaurent i f) := by + have he (e : Fin n → ℤ) : reflectExponentAt (σ i) (e ∘ σ.symm) = reflectExponentAt i e ∘ σ.symm := by + ext j + by_cases h:j=σ i + · simp [reflectExponentAt,h] + · have h' : σ.symm j ≠ i := by intro hh; exact h ((σ.apply_symm_apply j).symm.trans (congrArg σ hh)) + simp [reflectExponentAt,h,h'] + have h : (rowReflectLaurent (σ i)).comp (permLaurent σ) = + (permLaurent σ).comp (rowReflectLaurent i) := by + apply AddMonoidAlgebra.ringHom_ext <;> intro e + all_goals change rowReflectLaurent (σ i) (permLaurent σ (monomialL _ _)) = + permLaurent σ (rowReflectLaurent i (monomialL _ _)) + all_goals rw [permLaurent_monomial,rowReflectLaurent_monomial, + rowReflectLaurent_monomial,permLaurent_monomial] + all_goals simp only [Function.comp_apply,Equiv.symm_apply_apply]; congr 1; exact he _ + exact DFunLike.congr_fun h f + +end +end CriticalStrip.Diagram + +end OAI diff --git a/lean/OAI/Combinatorics/StripMass/SplitProjection.lean b/lean/OAI/Combinatorics/StripMass/SplitProjection.lean new file mode 100644 index 0000000000000000000000000000000000000000..9cc212b58532cd692f3d2415a6113d748d306579 --- /dev/null +++ b/lean/OAI/Combinatorics/StripMass/SplitProjection.lean @@ -0,0 +1,634 @@ +import Mathlib +import OAI.Combinatorics.StripMass.VacuumClosure + +namespace OAI + +/-! Critical honeycomb strip paths, polynomial identities and crossing mass. -/ + + +namespace CriticalStrip.Diagram +noncomputable section +open scoped Classical BigOperators + +namespace Pairing + +lemma mapRestrict_eq_of_supported {n m : ℕ} (f : Fin n ↪o Fin m) (p : Pairing m) + (hp : ∀ i, p.Occupied i → ∃ j, f j=i) : (p.restrict f).map f=p := by + apply ext_adj + intro i j + rw [map_adj] + constructor + · rintro ⟨a,b,hab,rfl,rfl⟩ + exact (restrict_adj f p a b).mp hab + · intro hij + obtain ⟨a,rfl⟩ := hp i ⟨j,hij⟩ + obtain ⟨b,rfl⟩ := hp j ⟨f a,adj_symm hij⟩ + exact ⟨a,b,(restrict_adj f p a b).mpr hij,rfl,rfl⟩ + +lemma mapRestrict_omit {n : ℕ} (a : Fin (n+1)) (p : Pairing (n+1)) + (hp : ¬p.Occupied a) : (p.restrict (Fin.succAboveOrderEmb a)).map + (Fin.succAboveOrderEmb a)=p := by + apply mapRestrict_eq_of_supported + intro i hi + have hia : i ≠ a := fun he => hp (he ▸ hi) + exact Fin.exists_succAbove_eq hia + +lemma join_map {n m : ℕ} (f : Fin n ↪o Fin m) (p q : Pairing n) (i j : Fin m) : + join (p.map f) (q.map f) i j ↔ ∃ a b, join p q a b ∧ f a=i ∧ f b=j := by + simp only [join,map_adj] + constructor + · rintro (⟨a,b,h,rfl,rfl⟩|⟨a,b,h,rfl,rfl⟩) + · exact ⟨a,b,Or.inl h,rfl,rfl⟩ + · exact ⟨a,b,Or.inr h,rfl,rfl⟩ + · rintro ⟨a,b,h,rfl,rfl⟩ + exact h.elim (fun hh => Or.inl ⟨a,b,hh,rfl,rfl⟩) + (fun hh => Or.inr ⟨a,b,hh,rfl,rfl⟩) + +lemma join_map_reach {n m : ℕ} (f : Fin n ↪o Fin m) (p q : Pairing n) (i j : Fin n) : + Relation.ReflTransGen (join (p.map f) (q.map f)) (f i) (f j) ↔ + Relation.ReflTransGen (join p q) i j := by + constructor + · intro hh + have h : ∀ {y}, Relation.ReflTransGen (join (p.map f) (q.map f)) (f i) y → + ∃ k, f k=y ∧ Relation.ReflTransGen (join p q) i k := by + intro y hy + induction hy with + | refl => exact ⟨i,rfl,.refl⟩ + | @tail y z hy hyz ih => + obtain ⟨k,hk,hpath⟩ := ih + obtain ⟨a,b,hab,ha,hb⟩ := (join_map f p q y z).mp hyz + have hka : k=a := f.injective (hk.trans ha.symm) + subst k + exact ⟨b,hb,hpath.tail hab⟩ + obtain ⟨k,hk,hpath⟩ := h hh + exact f.injective hk ▸ hpath + · intro hh + exact Graph.map_reach f (fun a b hab => .single + ((join_map f p q (f a) (f b)).mpr ⟨a,b,hab,rfl,rfl⟩)) hh + +lemma gluesAt_map {n m : ℕ} (f : Fin n ↪o Fin m) (root : Fin n) (p q : Pairing n) : + GluesAt (f root) (p.map f) (q.map f) ↔ GluesAt root p q := by + constructor + · rintro ⟨hp,ho,hd⟩ + refine ⟨(map_occupied f p root).mp hp,?_,?_⟩ + · intro i + simpa only [map_occupied] using ho (f i) + · intro i j hij + apply (join_map_reach f p q i root).mp + exact hd (f i) (f j) ((join_map f p q _ _).mpr ⟨i,j,hij,rfl,rfl⟩) + · rintro ⟨hp,ho,hd⟩ + refine ⟨(map_occupied f p root).mpr hp,?_,?_⟩ + · intro i + constructor + · rintro ⟨j,hij⟩ + obtain ⟨a,b,hab,rfl,rfl⟩ := (map_adj f p i j).mp hij + exact (map_occupied f q a).mpr ((ho a).mp ⟨b,hab⟩) + · rintro ⟨j,hij⟩ + obtain ⟨a,b,hab,rfl,rfl⟩ := (map_adj f q i j).mp hij + exact (map_occupied f p a).mpr ((ho a).mpr ⟨b,hab⟩) + · intro i j hij + obtain ⟨a,b,hab,rfl,rfl⟩ := (join_map f p q i j).mp hij + exact (join_map_reach f p q a root).mpr (hd a b hab) + +lemma gluesAt_map_supported {n m : ℕ} (f : Fin n ↪o Fin m) (root : Fin n) + (p : Pairing m) (q : Pairing n) (h : GluesAt (f root) p (q.map f)) : + ∃ r : Pairing n, r.map f=p := by + refine ⟨p.restrict f,mapRestrict_eq_of_supported f p ?_⟩ + intro i hi + obtain ⟨j,hij⟩ := (h.2.1 i).mp hi + obtain ⟨a,b,_,ha,_⟩ := (map_adj f q i j).mp hij + exact ⟨a,ha⟩ + +end Pairing + + + +theorem functionMatrix_glue_adjoint {K : Type*} [CommRing K] {n m : ℕ} + (f : Fin n ↪o Fin m) (root : Fin n) : + (glueMatrix (f root) : Matrix _ _ K) * functionMatrix (Pairing.map f) = + functionMatrix (Pairing.map f) * glueMatrix root := by + ext q p + refine (mul_functionMatrix (Pairing.map f) (glueMatrix (K:=K) (f root)) q p).trans ?_ + by_cases h : ∃ r : Pairing n, r.map f=q + · obtain ⟨r,rfl⟩ := h + refine Eq.trans ?_ (functionMatrix_mul_apply (Pairing.map f) (Pairing.map_injective f) + (glueMatrix (K:=K) root) r p).symm + simp only [glueMatrix,Pairing.gluesAt_map] + · refine Eq.trans ?_ (functionMatrix_mul_outside (Pairing.map f) (glueMatrix (K:=K) root) q p h).symm + apply ite_eq_right + exact fun hh => h (Pairing.gluesAt_map_supported f root q p hh) + + + +lemma functionMatrix_transpose_mul_self {K P Q : Type*} [CommRing K] [Fintype P] + [Fintype Q] [DecidableEq P] (f : P → Q) (hf : Function.Injective f) : + (functionMatrix (K:=K) f).transpose * functionMatrix (K:=K) f = 1 := by + ext p q + rw [mul_functionMatrix (K:=K)] + simp [Matrix.transpose_apply,functionMatrix,optionMatrix,hf.eq_iff,Matrix.one_apply] + + + +lemma localR_vacant_right {K : Type*} [CommRing K] {n : ℕ} (a : Position n) + (w : Weights K) (p q : Pairing n) (hp : ¬p.Occupied a.right) + (hq : ¬q.Occupied a.right) : + localR a w q p = if p=q then (if p.Occupied a.left then w.A else 1) else 0 := by + have hne : a.right ≠ a.left := by + intro he + have h := a.adjacent + have he' := congrArg Fin.val he + omega + simp only [localR,Matrix.sum_apply,Matrix.smul_apply,smul_eq_mul] + by_cases ha : p.Occupied a.left + · rw [Finset.sum_eq_single .vertical₀] + · simp [Weights.tile,optionMatrix,Pairing.tileStep,ha,hp] + · intro t _ ht + have ho (htb : t.Occupied 3) : p.tileStep a.left a.right a.adjacent t ≠ some q := by + intro he + have hh := (p.tileStep_support a.left a.right a.adjacent t q he a.right).mpr + (by simp [Pairing.stepSupport,hne,htb]) + exact hq hh + cases t <;> try simp_all [Weights.tile,optionMatrix,Pairing.tileStep] + intro he + exact (ho (by unfold Tile.Occupied Tile.Adj Tile.edges; decide) he).elim + · simp + · rw [Finset.sum_eq_single .vacant] + · simp [Weights.tile,optionMatrix,Pairing.tileStep,ha,hp] + · intro t _ ht + have ho (htb : t.Occupied 3) : p.tileStep a.left a.right a.adjacent t ≠ some q := by + intro he + have hh := (p.tileStep_support a.left a.right a.adjacent t q he a.right).mpr + (by simp [Pairing.stepSupport,hne,htb]) + exact hq hh + cases t <;> try simp_all [Weights.tile,optionMatrix,Pairing.tileStep] + intro he + exact (ho (by unfold Tile.Occupied Tile.Adj Tile.edges; decide) he).elim + · simp + + + +def splitProjection {K : Type*} [CommRing K] {n m : ℕ} + (f : Fin n ↪o Fin m) (a : Position m) (w : Weights K) : + Matrix (Pairing n) (Pairing m) K := + (functionMatrix (K:=K) (Pairing.map f)).transpose * localR a w + +theorem splitProjection_glue_adjoint {K : Type*} [CommRing K] {n m : ℕ} + (f : Fin n ↪o Fin m) (a : Position m) (w : Weights K) (root : Fin n) + (ha : f root ≠ a.left) (hb : f root ≠ a.right) : + (glueMatrix (K:=K) (f root)) * + (localR a w * functionMatrix (K:=K) (Pairing.map f)) = + (splitProjection f a w).transpose * glueMatrix root := by + let E := functionMatrix (K:=K) (Pairing.map f) + let L := localR a w + have ht : (splitProjection f a w).transpose = L.transpose * E := by + simpa only [splitProjection,Matrix.transpose_transpose] using (Matrix.transpose_mul E.transpose L) + calc + _ = (glueMatrix (f root) * L) * E := (Matrix.mul_assoc _ _ _).symm + _ = (L.transpose * glueMatrix (f root)) * E := + congrArg (fun M => M * E) (localR_glue_adjoint a (f root) ha hb w) + _ = L.transpose * (glueMatrix (f root) * E) := Matrix.mul_assoc _ _ _ + _ = L.transpose * (E * glueMatrix root) := + congrArg (fun M => L.transpose * M) (functionMatrix_glue_adjoint f root) + _ = (L.transpose * E) * glueMatrix root := (Matrix.mul_assoc _ _ _).symm + _ = _ := congrArg (fun M => M * glueMatrix root) ht.symm + +lemma transpose_functionMatrix_mul_apply {K P Q R : Type*} [CommRing K] + [Fintype Q] (f : P → Q) (M : Matrix Q R K) (p : P) (r : R) : + ((functionMatrix (K:=K) f).transpose * M) p r = M (f p) r := by + simpa only [functionMatrix,Function.comp_apply,Option.elim_some] using + transpose_optionMatrix_mul_apply M (some ∘ f) p r + +lemma vacant_restriction_localR {K : Type*} [CommRing K] {n : ℕ} + (a : Position (n+1)) (w : Weights K) (p q : Pairing n) : + ((functionMatrix (K:=K) (Pairing.map (Fin.succAboveOrderEmb a.right))).transpose * + localR a w * functionMatrix (K:=K) (Pairing.map (Fin.succAboveOrderEmb a.right))) q p = + if p=q then + (if (p.map (Fin.succAboveOrderEmb a.right)).Occupied a.left then w.A else 1) else 0 := by + rw [mul_functionMatrix,transpose_functionMatrix_mul_apply, + localR_vacant_right a w _ _ (p.map_not_occupied_omit a.right) (q.map_not_occupied_omit a.right)] + simp only [(Pairing.map_injective _).eq_iff] + +lemma vacant_restriction_localR_mulVec {K : Type*} [CommRing K] {n : ℕ} + (a : Position (n+1)) (w : Weights K) (v : Pairing n → K) (p : Pairing n) : + (((functionMatrix (K:=K) (Pairing.map (Fin.succAboveOrderEmb a.right))).transpose * + localR a w * functionMatrix (K:=K) (Pairing.map (Fin.succAboveOrderEmb a.right))).mulVec v) p = + (if (p.map (Fin.succAboveOrderEmb a.right)).Occupied a.left then w.A else 1) * v p := by + simp only [Matrix.mulVec,dotProduct,vacant_restriction_localR] + rw [Finset.sum_eq_single p] + · simp + · intro q _ hq + simp [hq] + · simp + + + +theorem splitMap_injective {K : Type*} [Field K] {n : ℕ} + (a : Position (n+1)) (w : Weights K) (hA : w.A≠0) : + Function.Injective + (localR a w * functionMatrix (K:=K) (Pairing.map (Fin.succAboveOrderEmb a.right))).mulVec := by + intro v z hvz + funext p + have hh := congrArg (fun U => + ((functionMatrix (K:=K) (Pairing.map (Fin.succAboveOrderEmb a.right))).transpose).mulVec U p) hvz + rw [Matrix.mulVec_mulVec,Matrix.mulVec_mulVec,←Matrix.mul_assoc, + vacant_restriction_localR_mulVec,vacant_restriction_localR_mulVec] at hh + exact mul_left_cancel₀ (by split_ifs <;> first | exact hA | exact one_ne_zero) hh + +lemma mergeMap_injective {n m : ℕ} (r : ℕ) (hr : r+2≤n+1) : + Function.Injective (mergeMap (m:=m) r hr).mulVec := by + apply splitMap_injective + exact div_ne_zero (constF_phase_ne_zero m) + (eighthRoot_two_add_one_ne_zero (constF_phase_eight m)) + + + + + + +lemma sum_tiles {K : Type*} [AddCommMonoid K] (f : Tile → K) : + ∑ t, f t = f .vacant + f .vertical₀ + f .vertical₁ + f .diagonal₀ + + f .diagonal₁ + f .cap + f .cup + f .verticalPair + f .capCup := by + change (∑ t ∈ ({.vacant,.vertical₀,.vertical₁,.diagonal₀,.diagonal₁,.cap,.cup, + .verticalPair,.capCup} : Finset Tile), f t) = _ + simp [add_assoc] + +lemma mul_localR_apply {K Q : Type*} [CommRing K] {n : ℕ} + (M : Matrix Q (Pairing n) K) (a : Position n) (w : Weights K) + (q : Q) (p : Pairing n) : + (M * localR a w) q p = ∑ t : Tile, + w.tile t * (p.tileStep a.left a.right a.adjacent t).elim 0 (M q) := by + simp only [localR,Matrix.mul_sum,Matrix.mul_smul,Matrix.sum_apply,Matrix.smul_apply, + smul_eq_mul,mul_optionMatrix_apply] + +lemma localR_apply {K : Type*} [CommRing K] {n : ℕ} + (a : Position n) (w : Weights K) (q p : Pairing n) : + localR a w q p = ∑ t : Tile, + w.tile t * (p.tileStep a.left a.right a.adjacent t).elim 0 + (fun r => if r=q then 1 else 0) := by + have h := mul_localR_apply (1 : Matrix (Pairing n) (Pairing n) K) a w q p + have h1 : (1 : Matrix (Pairing n) (Pairing n) K) q = (fun r => if r=q then 1 else 0) := by + funext r + simp [Matrix.one_apply,eq_comm] + rw [h1,Matrix.one_mul] at h + exact h + +namespace Pairing +lemma mapOccupied_equiv_occupied {n : ℕ} (p : Pairing n) (f : Equiv.Perm (Fin n)) + (hf : ∀ i j, p.Occupied i → p.Occupied j → (f i < f j ↔ i < j)) (i : Fin n) : + (p.mapOccupied f.toEmbedding hf).Occupied i ↔ p.Occupied (f.symm i) := by + simp only [Occupied,mapOccupied_equiv_adj] + constructor + · rintro ⟨j,h⟩ + exact ⟨f.symm j,h⟩ + · rintro ⟨j,h⟩ + exact ⟨f j,by simpa using h⟩ + +@[simp] lemma moveIntoVacancy_occupied {n : ℕ} (p : Pairing n) (a b : Fin n) + (hab : a.val+1=b.val) (hb : ¬p.Occupied b) (i : Fin n) : + (p.moveIntoVacancy a b hab hb).Occupied i ↔ p.Occupied (Equiv.swap a b i) := + mapOccupied_equiv_occupied p (Equiv.swap a b) _ i + +@[simp] lemma moveIntoLowerVacancy_occupied {n : ℕ} (p : Pairing n) (a b : Fin n) + (hab : a.val+1=b.val) (ha : ¬p.Occupied a) (i : Fin n) : + (p.moveIntoLowerVacancy a b hab ha).Occupied i ↔ p.Occupied (Equiv.swap a b i) := + mapOccupied_equiv_occupied p (Equiv.swap a b) _ i + +@[simp] lemma insertCup_occupied {n : ℕ} (p : Pairing n) (a b : Fin n) + (hab : a.val+1=b.val) (ha : ¬p.Occupied a) (hb : ¬p.Occupied b) (i : Fin n) : + (p.insertCup a b hab ha hb).Occupied i ↔ i=a ∨ i=b ∨ p.Occupied i := by + simp [Occupied,insertCup_adj,exists_or] + +lemma moveIntoLowerVacancy_inverse {n : ℕ} (p : Pairing n) (a b : Fin n) + (hab : a.val+1=b.val) (ha : ¬p.Occupied a) + (h : ¬(p.moveIntoLowerVacancy a b hab ha).Occupied b) : + (p.moveIntoLowerVacancy a b hab ha).moveIntoVacancy a b hab h = p := by + apply ext_adj + intro i j + simp only [moveIntoVacancy_adj,moveIntoLowerVacancy_adj,Equiv.swap_apply_self] +end Pairing + + + +def vacantProjection {K : Type*} [Zero K] [One K] {n : ℕ} (b : Fin n) : + Matrix (Pairing n) (Pairing n) K := Matrix.diagonal (fun p => if p.Occupied b then 0 else 1) + +lemma mul_vacantProjection_apply {K Q : Type*} [CommRing K] {n : ℕ} + (M : Matrix Q (Pairing n) K) (b : Fin n) (q : Q) (p : Pairing n) : + (M * vacantProjection (K:=K) b) q p = if p.Occupied b then 0 else M q p := by + rw [vacantProjection,Matrix.mul_diagonal] + by_cases hp : p.Occupied b <;> simp [hp] + +lemma functionMatrix_mul_transpose_omit {K : Type*} [CommRing K] {n : ℕ} + (b : Fin (n+1)) : + functionMatrix (K:=K) (Pairing.map (Fin.succAboveOrderEmb b)) * + (functionMatrix (K:=K) (Pairing.map (Fin.succAboveOrderEmb b))).transpose = + vacantProjection (K:=K) b := by + ext q p + by_cases hp : p.Occupied b + · rw [Matrix.mul_apply] + have hz : (vacantProjection (K:=K) b) q p=0 := by + by_cases he : q=p <;> simp [vacantProjection,he,hp] + rw [hz] + apply Finset.sum_eq_zero + intro r _ + have hne : r.map (Fin.succAboveOrderEmb b) ≠ p := fun he => + r.map_not_occupied_omit b (he.symm ▸ hp) + simp [Matrix.transpose_apply,functionMatrix,optionMatrix,hne] + · have he := Pairing.mapRestrict_omit b p hp + rw [Matrix.mul_apply] + rw [Finset.sum_eq_single (p.restrict (Fin.succAboveOrderEmb b))] + · by_cases hqp : q=p + · subst q + simp [Matrix.transpose_apply,functionMatrix,optionMatrix,he,vacantProjection,hp] + · simp [Matrix.transpose_apply,functionMatrix,optionMatrix,he,vacantProjection,hqp,Ne.symm hqp] + · intro r _ hr + have hn : r.map (Fin.succAboveOrderEmb b) ≠ p := by + intro h + exact hr ((Pairing.map_injective _).eq_iff.mp (h.trans he.symm)) + simp [Matrix.transpose_apply,functionMatrix,optionMatrix,hn] + · simp + + + +theorem localR_factor_merge {K : Type*} [CommRing K] {n : ℕ} + (a : Position n) (r : K) : + localR a ⟨r,r,r,0,0⟩ * vacantProjection (K:=K) a.right * localR a ⟨r,r,r,0,0⟩ = + localR a ⟨r^2,r^2,r,0,r^2⟩ := by + ext q p + rw [mul_localR_apply,localR_apply] + simp only [sum_tiles,Weights.tile] + by_cases ha : p.Occupied a.left + · by_cases hb : p.Occupied a.right + · by_cases hn : p.Adj a.left a.right + · simp [Pairing.tileStep,ha,hb,hn] + · let s := p.capRemove a.left a.right a.adjacent ha hb hn + have hsa : ¬s.Occupied a.left := (p.capRemove_vacant _ _ _ ha hb hn).1 + have hsb : ¬s.Occupied a.right := (p.capRemove_vacant _ _ _ ha hb hn).2 + simp only [Pairing.tileStep,ha,hb,hn,not_true_eq_false,and_false, + and_true,ite_true,ite_false,dite_true,dite_false,Option.elim_none, + Option.elim_some,zero_mul,mul_zero,add_zero,zero_add] + change r * ((localR a ⟨r,r,r,0,0⟩ * vacantProjection (K:=K) a.right) q s) = _ + rw [mul_vacantProjection_apply,ite_eq_right hsb,localR_apply] + simp only [sum_tiles,Weights.tile,Pairing.tileStep,hsa,hsb,not_false_eq_true, + and_self,and_false,false_and,ite_true,ite_false,dite_true,dite_false,Option.elim_none, + Option.elim_some,mul_zero,add_zero,one_mul] + ring + · simp only [Pairing.tileStep,ha,hb,not_true_eq_false,not_false_eq_true,and_self, + and_false,false_and,ite_true,ite_false,dite_true,dite_false,Option.elim_none, + Option.elim_some,mul_zero,add_zero,zero_add] + simp only [mul_vacantProjection_apply,Pairing.moveIntoVacancy_occupied, + Equiv.swap_apply_right,ha,hb,ite_true,ite_false,mul_zero,add_zero] + rw [localR_apply] + simp only [sum_tiles,Weights.tile,Pairing.tileStep,ha,hb,not_true_eq_false, + not_false_eq_true,and_self,and_false,false_and,ite_true,ite_false,dite_true,dite_false, + Option.elim_none,Option.elim_some,mul_zero,add_zero,zero_add] + ring + · by_cases hb : p.Occupied a.right + · let s := p.moveIntoLowerVacancy a.left a.right a.adjacent ha + have hsa : s.Occupied a.left := by simp [s,hb] + have hsb : ¬s.Occupied a.right := by simp [s,ha] + simp only [Pairing.tileStep,ha,hb,not_true_eq_false,not_false_eq_true,and_self, + and_false,false_and,ite_true,ite_false,dite_true,dite_false,Option.elim_none, + Option.elim_some,mul_zero,add_zero,zero_add] + change r * ((localR a (⟨r,r,r,0,0⟩ : Weights K) * vacantProjection (K:=K) a.right) q p) + + r * ((localR a (⟨r,r,r,0,0⟩ : Weights K) * vacantProjection (K:=K) a.right) q s) = _ + rw [mul_vacantProjection_apply,ite_eq_left hb,mul_zero,zero_add, + mul_vacantProjection_apply,ite_eq_right hsb,localR_apply] + simp only [sum_tiles,Weights.tile,Pairing.tileStep,hsa,hsb,not_true_eq_false, + not_false_eq_true,and_self,and_false,false_and,ite_true,ite_false,dite_true,dite_false, + Option.elim_none,Option.elim_some,mul_zero,add_zero,zero_add] + rw [Pairing.moveIntoLowerVacancy_inverse p a.left a.right a.adjacent ha hsb] + ring + · simp only [Pairing.tileStep,ha,hb,not_false_eq_true,and_self,and_false,false_and, + ite_true,ite_false,dite_true,dite_false,Option.elim_none,Option.elim_some, + mul_zero,add_zero,one_mul] + simp only [mul_vacantProjection_apply,Pairing.insertCup_occupied,hb, + or_true,true_or,ite_true,ite_false,mul_zero,add_zero] + rw [localR_apply] + simp only [sum_tiles,Weights.tile,Pairing.tileStep,ha,hb,not_false_eq_true, + and_self,and_false,false_and,ite_true,ite_false,dite_true,dite_false, + Option.elim_none,Option.elim_some,mul_zero,add_zero,one_mul] + + + + + + +lemma sin_lambda_eq_c : Real.sin lambda = c := by + rw [← Real.cos_pi_div_two_sub] + congr 1 + unfold lambda + ring + +lemma sin_three_lambda_eq_C : Real.sin (3*lambda) = C := by + rw [← Real.cos_pi_div_two_sub] + congr 1 + unfold lambda + ring + +lemma sin_four_lambda_eq_one : Real.sin (4*lambda)=1 := by + rw [show 4*lambda=Real.pi/2 by unfold lambda; ring,Real.sin_pi_div_two] + +lemma C_ne_zero : C≠0 := by + rw [←sin_three_lambda_eq_C] + exact ne_of_gt sin_three_lambda_pos + +lemma d_mul_c_div_C : d*c/C=rho^2 := by + have hr := rho_eq_two_c_d + have hC := rho_eq_inv_two_C + calc + d*c/C = (rho/2)/C := by rw [hr]; ring + _ = rho*(1/(2*C)) := by ring + _ = rho^2 := by rw [←hC]; ring + +lemma d_sq_div_C : d^2/C=rho := by + rw [d_sq,rho_eq_inv_two_C] + ring + +lemma torusL_phase_two (n : ℕ) : torusL (constF n phase ^ 2)=constF n C := by + rw [torusL,←pow_add,←pow_add] + norm_num only [Nat.reduceAdd] + rw [torusSin_phase_pow,torusSin_phase_pow] + simp only [Nat.cast_ofNat,sin_four_lambda_eq_one,sin_five_lambda_eq,sin_three_lambda_eq_C] + simp only [Complex.ofReal_one,constF,map_one,one_mul] + + + +lemma torusWeights_phase_two (n : ℕ) : + torusWeights (constF n phase^2) = + (⟨(constF n rho)^2,(constF n rho)^2,constF n rho,0,(constF n rho)^2⟩ : + Weights (SpectralField n)) := by + have hq := constF_phase_ne_zero n + have hq32 : constF n phase^3/constF n phase^2=constF n phase := by field_simp + have hq21 : constF n phase^2/constF n phase=constF n phase := by field_simp + have hs1 : torusSin (constF n phase)=constF n c := by + have h := torusSin_phase_pow n 1 + simpa only [pow_one,Nat.cast_one,one_mul,sin_lambda_eq_c] using h + have he : constF n d*constF n c/constF n C=(constF n rho)^2 := by + have h := congrArg (fun x : ℝ => constF n (x:ℂ)) d_mul_c_div_C + simpa only [Complex.ofReal_div,Complex.ofReal_mul,Complex.ofReal_pow, + constF,map_div₀,map_mul,map_pow] using h + have hu : constF n d*constF n d/constF n C=constF n rho := by + have h := congrArg (fun x : ℝ => constF n (x:ℂ)) d_sq_div_C + simpa only [Complex.ofReal_div,Complex.ofReal_pow,Complex.ofReal_mul,constF, + map_div₀,map_pow,map_mul,pow_two] using h + unfold torusWeights + simp only [hq32,hq21,div_self (pow_ne_zero 2 hq),torusSin_one,torusSin_phase_pow, + Nat.cast_ofNat,sin_two_lambda_eq_d,hs1,torusL_phase_two,mul_zero,zero_div,he,hu, + mul_comm (constF n c) (constF n d)] + + + +def mergeProjection {n m : ℕ} (r : ℕ) (hr : r+2≤n+1) : + Matrix (Pairing n) (Pairing (n+1)) (SpectralField m) := + splitProjection (Fin.succAboveOrderEmb ⟨r+1,by omega⟩) + (PartialColumn.rowPosition r hr) (mergeWeights (constF m phase)) + + + +theorem mergeMap_mul_projection {n m : ℕ} (r : ℕ) (hr : r+2≤n+1) : + mergeMap (m:=m) r hr * mergeProjection r hr = + localR (PartialColumn.rowPosition r hr) (torusWeights (constF m phase^2)) := by + unfold mergeMap mergeProjection splitProjection + let E := functionMatrix (K:=SpectralField m) + (Pairing.map (Fin.succAboveOrderEmb (⟨r+1,by omega⟩ : Fin (n+1)))) + let S := localR (PartialColumn.rowPosition r hr) (mergeWeights (constF m phase)) + calc + _ = S * (E * (E.transpose * S)) := Matrix.mul_assoc _ _ _ + _ = S * ((E * E.transpose) * S) := + congrArg (fun M => S * M) (Matrix.mul_assoc E E.transpose S).symm + _ = (S * (E * E.transpose)) * S := (Matrix.mul_assoc _ _ _).symm + _ = (S * vacantProjection (K:=SpectralField m) (⟨r+1,by omega⟩ : Fin (n+1))) * S := + congrArg (fun M => (S * M) * S) (functionMatrix_mul_transpose_omit _) + _ = _ := by + dsimp only [S] + rw [mergeWeights_source_constant,torusWeights_phase_two] + exact localR_factor_merge (PartialColumn.rowPosition r hr) (constF m rho) + + + + + + +lemma functionMatrix_vacantProjection {K : Type*} [CommRing K] {n m : ℕ} + (f : Fin n ↪o Fin m) (i : Fin n) : + functionMatrix (K:=K) (Pairing.map f) * vacantProjection (K:=K) i = + vacantProjection (K:=K) (f i) * functionMatrix (K:=K) (Pairing.map f) := by + ext q p + simp only [vacantProjection,Matrix.mul_diagonal,Matrix.diagonal_mul] + by_cases h : p.map f=q + · subst q + simp only [Pairing.map_occupied] + ring + · simp [functionMatrix,optionMatrix,h] + + +def twoVacancyInsertion {K : Type*} [CommRing K] {n : ℕ} (r : ℕ) (hr : r+2≤n+2) : + Matrix (Pairing (n+2)) (Pairing n) K := + functionMatrix (Pairing.map (Fin.succAboveOrderEmb (⟨r+1,by omega⟩ : Fin (n+2)))) * + functionMatrix (Pairing.map (Fin.succAboveOrderEmb (⟨r,by omega⟩ : Fin (n+1)))) + +lemma twoVacancyInsertion_mul_transpose {K : Type*} [CommRing K] {n : ℕ} + (r : ℕ) (hr : r+2≤n+2) : + twoVacancyInsertion (K:=K) r hr * (twoVacancyInsertion (K:=K) r hr).transpose = + vacantProjection (K:=K) (PartialColumn.rowPosition r hr).left * + vacantProjection (K:=K) (PartialColumn.rowPosition r hr).right := by + let b : Fin (n+2) := ⟨r+1,by omega⟩ + let a : Fin (n+1) := ⟨r,by omega⟩ + have hab : b.succAbove a = (PartialColumn.rowPosition r hr).left := by + rw [Fin.succAbove_of_castSucc_lt] + · rfl + · change r (B*A)*M) (Matrix.transpose_mul B A) + _ = B * (A * (A.transpose * B.transpose)) := Matrix.mul_assoc _ _ _ + _ = B * ((A * A.transpose) * B.transpose) := + congrArg (fun M => B*M) (Matrix.mul_assoc A A.transpose B.transpose).symm + _ = (B * (A * A.transpose)) * B.transpose := (Matrix.mul_assoc _ _ _).symm + _ = (B * vacantProjection (K:=K) a) * B.transpose := + congrArg (fun M => (B*M)*B.transpose) (functionMatrix_mul_transpose_omit a) + _ = (vacantProjection (K:=K) (b.succAbove a) * B) * B.transpose := + congrArg (fun M => M*B.transpose) (functionMatrix_vacantProjection (Fin.succAboveOrderEmb b) a) + _ = vacantProjection (K:=K) (b.succAbove a) * (B*B.transpose) := Matrix.mul_assoc _ _ _ + _ = vacantProjection (K:=K) (b.succAbove a) * vacantProjection (K:=K) b := + congrArg (fun M => vacantProjection (K:=K) (b.succAbove a)*M) (functionMatrix_mul_transpose_omit b) + _ = _ := by rw [hab]; rfl + + + +lemma localR_factor_deletion {K : Type*} [CommRing K] {n : ℕ} (a : Position n) : + localR a (deletionWeights : Weights K) * vacantProjection (K:=K) a.left * + vacantProjection (K:=K) a.right * localR a (deletionWeights : Weights K) = + localR a (deletionWeights : Weights K) := by + ext q p + rw [mul_localR_apply,localR_apply] + simp only [sum_tiles,deletionWeights,Weights.tile] + by_cases ha : p.Occupied a.left + · by_cases hb : p.Occupied a.right + · by_cases hn : p.Adj a.left a.right + · simp [Pairing.tileStep,ha,hb,hn] + · let s := p.capRemove a.left a.right a.adjacent ha hb hn + have hsa : ¬s.Occupied a.left := (p.capRemove_vacant _ _ _ ha hb hn).1 + have hsb : ¬s.Occupied a.right := (p.capRemove_vacant _ _ _ ha hb hn).2 + simp only [Pairing.tileStep,ha,hb,hn,not_true_eq_false,and_false, + and_true,ite_true,ite_false,dite_true,dite_false,Option.elim_none, + Option.elim_some,zero_mul,mul_zero,add_zero,zero_add,one_mul] + change ((localR a (⟨0,0,1,0,1⟩ : Weights K) * vacantProjection (K:=K) a.left * + vacantProjection (K:=K) a.right) q s) + + ((localR a (⟨0,0,1,0,1⟩ : Weights K) * vacantProjection (K:=K) a.left * + vacantProjection (K:=K) a.right) q (s.insertCup a.left a.right a.adjacent hsa hsb)) = _ + simp only [mul_vacantProjection_apply,hsb,hsa,Pairing.insertCup_occupied, + or_true,true_or,ite_true,ite_false,add_zero] + rw [localR_apply] + simp only [sum_tiles,Weights.tile,Pairing.tileStep,hsa,hsb,not_false_eq_true, + and_self,and_false,false_and,ite_true,ite_false,dite_true,dite_false,Option.elim_none, + Option.elim_some,mul_zero,add_zero,one_mul] + rfl + · simp [Pairing.tileStep,ha,hb] + · by_cases hb : p.Occupied a.right + · simp [Pairing.tileStep,ha,hb] + · simp only [Pairing.tileStep,ha,hb,not_false_eq_true,and_self,and_false,false_and, + ite_true,ite_false,dite_true,dite_false,Option.elim_none,Option.elim_some, + mul_zero,add_zero,one_mul] + simp only [mul_vacantProjection_apply,Pairing.insertCup_occupied,ha,hb, + or_true,true_or,ite_true,ite_false,add_zero] + rw [localR_apply] + simp only [sum_tiles,Weights.tile,Pairing.tileStep,ha,hb,not_false_eq_true, + and_self,and_false,false_and,ite_true,ite_false,dite_true,dite_false, + Option.elim_none,Option.elim_some,mul_zero,add_zero,one_mul] + + +def deletionProjection {n m : ℕ} (r : ℕ) (hr : r+2≤n+2) : + Matrix (Pairing n) (Pairing (n+2)) (SpectralField m) := + (twoVacancyInsertion (K:=SpectralField m) r hr).transpose * + localR (PartialColumn.rowPosition r hr) deletionWeights + +theorem deletionMap_mul_projection {n m : ℕ} (r : ℕ) (hr : r+2≤n+2) : + deletionMap (m:=m) r hr * deletionProjection r hr = + localR (PartialColumn.rowPosition r hr) (torusWeights (constF m phase^3)) := by + let E := twoVacancyInsertion (K:=SpectralField m) r hr + let S := localR (PartialColumn.rowPosition r hr) (deletionWeights : Weights (SpectralField m)) + change (S*E) * (E.transpose*S) = _ + calc + _ = S * (E * (E.transpose * S)) := Matrix.mul_assoc _ _ _ + _ = S * ((E * E.transpose) * S) := + congrArg (fun M => S*M) (Matrix.mul_assoc E E.transpose S).symm + _ = (S * (E * E.transpose)) * S := (Matrix.mul_assoc _ _ _).symm + _ = (S * (vacantProjection (K:=SpectralField m) (PartialColumn.rowPosition r hr).left * + vacantProjection (K:=SpectralField m) (PartialColumn.rowPosition r hr).right)) * S := + congrArg (fun M => (S*M)*S) (twoVacancyInsertion_mul_transpose r hr) + _ = ((S * vacantProjection (K:=SpectralField m) (PartialColumn.rowPosition r hr).left) * + vacantProjection (K:=SpectralField m) (PartialColumn.rowPosition r hr).right) * S := + congrArg (fun M => M*S) (Matrix.mul_assoc _ _ _).symm + _ = _ := by + dsimp only [S] + rw [localR_factor_deletion,torusWeights_phase_three] + +end +end CriticalStrip.Diagram + +end OAI diff --git a/lean/OAI/Combinatorics/StripMass/StepComplete.lean b/lean/OAI/Combinatorics/StripMass/StepComplete.lean new file mode 100644 index 0000000000000000000000000000000000000000..5209346028fdb9a5bf0b0f20c0642a8334f5faf2 --- /dev/null +++ b/lean/OAI/Combinatorics/StripMass/StepComplete.lean @@ -0,0 +1,516 @@ +import Mathlib +import OAI.Combinatorics.StripMass.StepToCut + +namespace OAI + +/-! Critical honeycomb strip paths, polynomial identities and crossing mass. -/ + + + +namespace CriticalStrip.Diagram +noncomputable section +open scoped Classical + +namespace GraphRealizes + +theorem boundary_used_iff {V : Type*} {n : ℕ} {r : V → V → Prop} {a : Fin n → V} + {p : Pairing n} (h : GraphRealizes r a p) (ha : Function.Injective a) (i : Fin n) : + Graph.Used r (a i) ↔ p.Occupied i := by + constructor + · rintro ⟨w,hw⟩ + obtain ⟨j,hj,hr⟩ := h.no_loop (a i) w hw + rcases (h.reach i j).mp hr with hh | hh + · exact hh ▸ hj + · exact ⟨j,hh⟩ + · rintro ⟨j,hj⟩ + apply Graph.used_of_reach_ne ((h.reach i j).mpr (Or.inr hj)) + intro hh + have he := ha hh + subst j + exact p.adj_irrefl i hj + +end GraphRealizes + +namespace Pairing + +theorem tileStep_compatible {n : ℕ} (p : Pairing n) (a b : Fin n) + (hab : a.val+1=b.val) (t : Tile) (q : Pairing n) + (hq : p.tileStep a b hab t = some q) : CutPatch.Compatible (p.cutShape a b) t := by + have hn : CutPatch.profile (p.cutShape a b) t ≠ none := by + intro hh + have := (p.tileStep_none_iff a b hab t).mpr hh + rw [hq] at this + cases this + obtain ⟨d,hd⟩ := Option.ne_none_iff_exists'.mp hn + exact (CutPatch.realizes_of_profile hd).compatible + +theorem cutGraph_profile_ne_none {n : ℕ} (p : Pairing n) (a b : Fin n) (t : Tile) + (hc : CutPatch.Compatible (p.cutShape a b) t) (q : Pairing n) + (hq : GraphRealizes (p.cutGraph a b t) Sum.inr q) : + CutPatch.profile (p.cutShape a b) t ≠ none := by + intro hh + obtain ⟨v,w,hvw,hout⟩ := CutPatch.none_has_closed hh hc + obtain ⟨j,_,hr⟩ := hq.no_loop (.inl v) (.inl w) hvw + obtain ⟨i,hi,hi',_⟩ := Patch.reach_to_exterior + (CutPatch.Adj (p.cutShape a b) t) (p.omitTwo a b).Adj + CutPatch.boundary (p.cutLabels a b) (CutPatch.active (p.cutShape a b) t) hr + exact hout i hi hi' + +theorem tileStep_iff {n : ℕ} (p : Pairing n) (a b : Fin n) + (hab : a.val+1=b.val) (t : Tile) (q : Pairing n) : + p.tileStep a b hab t = some q ↔ + CutPatch.Compatible (p.cutShape a b) t ∧ GraphRealizes (p.stepWiring a b t) StepVertex.out q := by + constructor + · intro hq + exact ⟨p.tileStep_compatible a b hab t q hq,p.stepWiring_realizes a b hab t q hq⟩ + · rintro ⟨hc,hq⟩ + have hne : a≠b := by intro hh; have := congrArg Fin.val hh; omega + have hg := (p.stepCutEquiv a b hne t).realizes hq + have hn : p.tileStep a b hab t ≠ none := by + intro hh + exact p.cutGraph_profile_ne_none a b t hc q hg ((p.tileStep_none_iff a b hab t).mp hh) + obtain ⟨r,hr⟩ := Option.ne_none_iff_exists'.mp hn + have he := (p.stepWiring_realizes a b hab t r hr).unique hq + exact he ▸ hr + +theorem stepWiring_out_used {n : ℕ} (p : Pairing n) (a b : Fin n) (t : Tile) (i : Fin n) : + Graph.Used (p.stepWiring a b t) (.out i) ↔ + (i=a ∧ t.Occupied 2) ∨ (i=b ∧ t.Occupied 3) ∨ + (i≠a ∧ i≠b ∧ p.Occupied i) := by + constructor + · rintro ⟨w,hw⟩ + cases w with + | old j => + obtain ⟨rfl,hja,hjb,hj⟩ := hw + exact Or.inr (Or.inr ⟨hja,hjb,hj⟩) + | box k => + rcases hw with ⟨hi,_,h⟩ | ⟨hi,_,h⟩ + · exact Or.inl ⟨hi,h⟩ + · exact Or.inr (Or.inl ⟨hi,h⟩) + | out j => exact hw.elim + · rintro (⟨h,ht⟩ | ⟨h,ht⟩ | ⟨hia,hib,hi⟩) + · exact ⟨.box 2,Or.inl ⟨h,rfl,ht⟩⟩ + · exact ⟨.box 3,Or.inr ⟨h,rfl,ht⟩⟩ + · exact ⟨.old i,rfl,hia,hib,hi⟩ + +def stepSupport {n : ℕ} (p : Pairing n) (a b : Fin n) (t : Tile) (i : Fin n) : Prop := + if i=a then t.Occupied 2 else if i=b then t.Occupied 3 else p.Occupied i + +theorem tileStep_support {n : ℕ} (p : Pairing n) (a b : Fin n) + (hab : a.val+1=b.val) (t : Tile) (q : Pairing n) + (hq : p.tileStep a b hab t = some q) (i : Fin n) : + q.Occupied i ↔ p.stepSupport a b t i := by + have hne : a≠b := by intro hh; have := congrArg Fin.val hh; omega + rw [← (p.stepWiring_realizes a b hab t q hq).boundary_used_iff (fun _ _ h => StepVertex.out.inj h) i, + p.stepWiring_out_used] + by_cases hia : i=a <;> by_cases hib : i=b <;> simp_all [stepSupport] + +end Pairing + + + + + + +namespace Graph + +def BoundaryEquiv.ofEquiv {V W : Type*} {n : ℕ} {r : V → V → Prop} {s : W → W → Prop} + {a : Fin n → V} {b : Fin n → W} (e : V ≃ W) + (hr : ∀ v w, r v w ↔ s (e v) (e w)) (ha : ∀ i, e (a i)=b i) : + BoundaryEquiv r s a b where + toFun := e + invFun := e.symm + map_edge := fun v w h => .single ((hr v w).mp h) + inv_edge := fun v w h => .single ((hr (e.symm v) (e.symm w)).mpr (by simpa using h)) + map_boundary := ha + inv_boundary := fun i => by rw [←ha i]; exact e.symm_apply_apply _ + map_used := fun v ⟨w,h⟩ => ⟨e w,(hr v w).mp h⟩ + inv_used := fun v ⟨w,h⟩ => ⟨e.symm w,(hr (e.symm v) (e.symm w)).mpr (by simpa using h)⟩ + retract := fun v _ => by rw [e.symm_apply_apply] + inv_retract := fun v _ => by rw [e.apply_symm_apply] + +end Graph + +abbrev GateExterior (n : ℕ) := Sum (Fin 4) (Fin n) + +def gateWiring {n : ℕ} (a b : Fin n) (t : Tile) : GateExterior n → GateExterior n → Prop + | .inl k, .inl l => t.Adj k l + | .inr _, .inr _ => False + | .inl k, .inr i | .inr i, .inl k => + (i=a ∧ k=2 ∧ t.Occupied 2) ∨ (i=b ∧ k=3 ∧ t.Occupied 3) + +def gateInput {n : ℕ} (a b : Fin n) (i : Fin n) : GateExterior n := + if i=a then .inl 0 else if i=b then .inl 1 else .inr i + +def stepVertexEquiv (n : ℕ) : StepVertex n ≃ Sum (Fin n) (GateExterior n) where + toFun + | .old i => .inl i + | .box k => .inr (.inl k) + | .out i => .inr (.inr i) + invFun + | .inl i => .old i + | .inr (.inl k) => .box k + | .inr (.inr i) => .out i + left_inv := fun v => by cases v <;> rfl + right_inv := fun v => by rcases v with i | (k | i) <;> rfl + +@[simp] theorem gateInput_eq_box {n : ℕ} (a b i : Fin n) (hab : a≠b) (k : Fin 4) : + gateInput a b i = .inl k ↔ (i=a ∧ k=0) ∨ (i=b ∧ k=1) := by + by_cases hia : i=a <;> by_cases hib : i=b <;> simp_all [gateInput,eq_comm] + +@[simp] theorem gateInput_eq_out {n : ℕ} (a b i j : Fin n) : + gateInput a b i = .inr j ↔ i=j ∧ i≠a ∧ i≠b := by + by_cases hia : i=a <;> by_cases hib : i=b <;> simp_all [gateInput] + +namespace Pairing + +theorem stepWiring_glued {n : ℕ} (p : Pairing n) (a b : Fin n) (hab : a≠b) (t : Tile) + (v w : StepVertex n) : p.stepWiring a b t v w ↔ + Patch.glued p.Adj (gateWiring a b t) id (gateInput a b) p.Occupied + (stepVertexEquiv n v) (stepVertexEquiv n w) := by + cases v <;> cases w <;> simp only [stepVertexEquiv,Equiv.coe_fn_mk,stepWiring, + Patch.glued,gateWiring,id_eq] + · rename_i i k + by_cases hia : i=a <;> by_cases hib : i=b <;> + simp_all [gateInput,and_comm,eq_comm] + · rename_i i j + by_cases hia : i=a <;> by_cases hib : i=b <;> + simp_all [gateInput,and_comm,eq_comm] + · rename_i k i + by_cases hia : i=a <;> by_cases hib : i=b <;> + simp_all [gateInput,and_comm,eq_comm] + · rename_i j i + by_cases hia : i=a <;> by_cases hib : i=b <;> + simp_all [gateInput,and_comm,eq_comm] + +def stepGluedEquiv {n : ℕ} (p : Pairing n) (a b : Fin n) (hab : a≠b) (t : Tile) : + Graph.BoundaryEquiv (p.stepWiring a b t) + (Patch.glued p.Adj (gateWiring a b t) id (gateInput a b) p.Occupied) + StepVertex.out (fun i => .inr (.inr i)) := + Graph.BoundaryEquiv.ofEquiv (stepVertexEquiv n) (p.stepWiring_glued a b hab t) (fun _ => rfl) + +end Pairing + + + +theorem graph_gate_step_iff {V : Type*} {n : ℕ} {r : V → V → Prop} {boundary : Fin n → V} + {p : Pairing n} (hp : GraphRealizes r boundary p) (a b : Fin n) + (hab : a.val+1=b.val) (t : Tile) (q : Pairing n) : + (CutPatch.Compatible (p.cutShape a b) t ∧ + GraphRealizes (Patch.glued r (gateWiring a b t) boundary (gateInput a b) p.Occupied) + (fun i => .inr (.inr i)) q) ↔ p.tileStep a b hab t = some q := by + have hne : a≠b := by intro hh; have := congrArg Fin.val hh; omega + rw [hp.substitute_iff,← (p.stepGluedEquiv a b hne t).realizes_iff,← p.tileStep_iff] + + + + + + + +namespace Graph + +def DrainsBoundary {V I : Type*} (r : V → V → Prop) (a : I → V) : Prop := + ∀ v w, r v w → ∃ i, Relation.ReflTransGen r v (a i) + +theorem BoundaryEquiv.drains {V W : Type*} {n : ℕ} {r : V → V → Prop} {s : W → W → Prop} + {a : Fin n → V} {b : Fin n → W} (e : BoundaryEquiv r s a b) + (h : DrainsBoundary r a) : DrainsBoundary s b := by + intro v w hvw + obtain ⟨x,hx⟩ := e.inv_used v ⟨w,hvw⟩ + obtain ⟨i,hi⟩ := h (e.invFun v) x hx + refine ⟨i,?_⟩ + have hmap := Graph.map_reach e.toFun e.map_edge hi + rw [e.map_boundary] at hmap + exact (e.inv_retract v ⟨w,hvw⟩).trans hmap + +theorem BoundaryEquiv.drains_iff {V W : Type*} {n : ℕ} {r : V → V → Prop} {s : W → W → Prop} + {a : Fin n → V} {b : Fin n → W} (e : BoundaryEquiv r s a b) : + DrainsBoundary r a ↔ DrainsBoundary s b := ⟨e.drains,e.symm.drains⟩ + +theorem drains_glued_exterior_iff {V W I J : Type*} (r : V → V → Prop) (s : W → W → Prop) + (a : I → V) (b : I → W) (active : I → Prop) (c : J → W) : + DrainsBoundary (Patch.glued r s a b active) (fun i => .inr (c i)) ↔ + Patch.drains (Patch.glued r s a b active) (Patch.exteriorOutput (fun x => ∃ i, x=c i)) := by + constructor + · intro h v w hvw + obtain ⟨i,hi⟩ := h v w hvw + exact ⟨.inr (c i),⟨i,rfl⟩,hi⟩ + · intro h v w hvw + obtain ⟨x,hx,hr⟩ := h v w hvw + cases x with + | inl x => exact hx.elim + | inr x => obtain ⟨i,rfl⟩ := hx; exact ⟨i,hr⟩ + +theorem glued_drains_local {V W I J : Type*} (r : V → V → Prop) (s : W → W → Prop) + (a : I → V) (b : I → W) (active : I → Prop) (c : J → W) + (h : DrainsBoundary (Patch.glued r s a b active) (fun i => .inr (c i))) : + DrainsBoundary r a := by + intro v w hvw + obtain ⟨j,hj⟩ := h (.inl v) (.inl w) hvw + obtain ⟨i,_,hi,_⟩ := Patch.reach_to_exterior r s a b active hj + exact ⟨i,hi⟩ + +end Graph + +namespace GraphRealizes + +theorem drainsBoundary {V : Type*} {n : ℕ} {r : V → V → Prop} {a : Fin n → V} + {p : Pairing n} (h : GraphRealizes r a p) : Graph.DrainsBoundary r a := by + intro v w hvw + obtain ⟨i,_,hi⟩ := h.no_loop v w hvw + exact ⟨i,hi⟩ + +theorem substitute_drains_iff {V B : Type*} {n m : ℕ} {r : V → V → Prop} {a : Fin n → V} + {p : Pairing n} (h : GraphRealizes r a p) (s : B → B → Prop) (b : Fin n → B) (c : Fin m → B) : + Graph.DrainsBoundary (Patch.glued r s a b p.Occupied) (fun i => .inr (c i)) ↔ + Graph.DrainsBoundary (Patch.glued p.Adj s id b p.Occupied) (fun i => .inr (c i)) := by + rw [Graph.drains_glued_exterior_iff,Graph.drains_glued_exterior_iff,h.drains_glued_iff] + +end GraphRealizes + +namespace Pairing + +theorem tileStep_ne_none_of_drains {n : ℕ} (p : Pairing n) (a b : Fin n) + (hab : a.val+1=b.val) (t : Tile) + (hc : CutPatch.Compatible (p.cutShape a b) t) + (hd : Graph.DrainsBoundary (p.stepWiring a b t) StepVertex.out) : + p.tileStep a b hab t ≠ none := by + have hne : a≠b := by intro hh; have := congrArg Fin.val hh; omega + have hg := (p.stepCutEquiv a b hne t).drains hd + intro hh + have hp := (p.tileStep_none_iff a b hab t).mp hh + obtain ⟨v,w,hvw,hout⟩ := CutPatch.none_has_closed hp hc + obtain ⟨j,hr⟩ := hg (.inl v) (.inl w) hvw + obtain ⟨i,hi,hi',_⟩ := Patch.reach_to_exterior + (CutPatch.Adj (p.cutShape a b) t) (p.omitTwo a b).Adj + CutPatch.boundary (p.cutLabels a b) (CutPatch.active (p.cutShape a b) t) hr + exact hout i hi hi' + +end Pairing + +theorem graph_gate_step_exists {V : Type*} {n : ℕ} {r : V → V → Prop} {boundary : Fin n → V} + {p : Pairing n} (hp : GraphRealizes r boundary p) (a b : Fin n) + (hab : a.val+1=b.val) (t : Tile) + (hc : CutPatch.Compatible (p.cutShape a b) t) + (hd : Graph.DrainsBoundary + (Patch.glued r (gateWiring a b t) boundary (gateInput a b) p.Occupied) + (fun i => .inr (.inr i))) : ∃ q, p.tileStep a b hab t = some q := by + have hne : a≠b := by intro hh; have := congrArg Fin.val hh; omega + have hd' := (hp.substitute_drains_iff (gateWiring a b t) (gateInput a b) Sum.inr).mp hd + have hd'' := (p.stepGluedEquiv a b hne t).symm.drains hd' + exact Option.ne_none_iff_exists'.mp (p.tileStep_ne_none_of_drains a b hab t hc hd'') + + + + + + + +structure Gate (n : ℕ) where + left : Fin n + right : Fin n + adjacent : left.val+1=right.val + tile : Tile + +inductive Circuit (n : ℕ) where + | nil : Circuit n + | snoc : Circuit n → Gate n → Circuit n + +namespace Circuit +variable {n : ℕ} + +def Vertex : Circuit n → Type + | .nil => Fin n + | .snoc c _ => Sum c.Vertex (GateExterior n) + +def boundary : (c : Circuit n) → Fin n → c.Vertex + | .nil => id + | .snoc _ _ => fun i => .inr (.inr i) + +def support (p : Pairing n) : Circuit n → Fin n → Prop + | .nil => p.Occupied + | .snoc c g => fun i => if i=g.left then g.tile.Occupied 2 + else if i=g.right then g.tile.Occupied 3 else support p c i + +def wiring (p : Pairing n) : (c : Circuit n) → c.Vertex → c.Vertex → Prop + | .nil => p.Adj + | .snoc c g => Patch.glued (wiring p c) (gateWiring g.left g.right g.tile) + c.boundary (gateInput g.left g.right) (support p c) + +def Compatible (p : Pairing n) : Circuit n → Prop + | .nil => True + | .snoc c g => Compatible p c ∧ + (support p c g.left ↔ g.tile.Occupied 0) ∧ + (support p c g.right ↔ g.tile.Occupied 1) + +def eval (p : Pairing n) : Circuit n → Option (Pairing n) + | .nil => some p + | .snoc c g => (eval p c).bind (fun q => q.tileStep g.left g.right g.adjacent g.tile) + +theorem eval_sound (p : Pairing n) (c : Circuit n) (q : Pairing n) + (h : eval p c = some q) : + Compatible p c ∧ GraphRealizes (wiring p c) c.boundary q ∧ support p c=q.Occupied := by + induction c generalizing q with + | nil => + have he : p=q := Option.some.inj h + subst q + exact ⟨trivial,p.graphRealizes,rfl⟩ + | snoc c g ih => + cases hp : eval p c with + | none => simp [eval,hp] at h + | some r => + have hstep : r.tileStep g.left g.right g.adjacent g.tile = some q := by + simpa only [eval,hp,Option.bind_some] using h + obtain ⟨hc,hr,hs⟩ := ih r hp + have hsc := r.tileStep_compatible g.left g.right g.adjacent g.tile q hstep + have hsc' := (r.cutShape_compatible g.left g.right g.tile).mp hsc + refine ⟨⟨hc,?_,?_⟩,?_,?_⟩ + · simpa only [hs] using hsc'.1 + · simpa only [hs] using hsc'.2 + · change GraphRealizes (Patch.glued (wiring p c) (gateWiring g.left g.right g.tile) + c.boundary (gateInput g.left g.right) (support p c)) (fun i => .inr (.inr i)) q + rw [hs] + exact ((graph_gate_step_iff hr g.left g.right g.adjacent g.tile q).mpr hstep).2 + · funext i + apply propext + change (if i=g.left then g.tile.Occupied 2 else + if i=g.right then g.tile.Occupied 3 else support p c i) ↔ q.Occupied i + rw [hs] + exact (r.tileStep_support g.left g.right g.adjacent g.tile q hstep i).symm + +theorem eval_exists (p : Pairing n) (c : Circuit n) (hc : Compatible p c) + (hd : Graph.DrainsBoundary (wiring p c) c.boundary) : ∃ q, eval p c = some q := by + induction c with + | nil => exact ⟨p,rfl⟩ + | snoc c g ih => + obtain ⟨hc,hleft,hright⟩ := hc + obtain ⟨r,hr⟩ := ih hc (Graph.glued_drains_local (wiring p c) + (gateWiring g.left g.right g.tile) c.boundary (gateInput g.left g.right) + (support p c) Sum.inr hd) + obtain ⟨_,hreal,hs⟩ := eval_sound p c r hr + have hcomp : CutPatch.Compatible (r.cutShape g.left g.right) g.tile := by + rw [r.cutShape_compatible] + exact ⟨by simpa only [hs] using hleft,by simpa only [hs] using hright⟩ + have hd' : Graph.DrainsBoundary (Patch.glued (wiring p c) + (gateWiring g.left g.right g.tile) c.boundary (gateInput g.left g.right) r.Occupied) + (fun i => .inr (.inr i)) := by + change Graph.DrainsBoundary (Patch.glued (wiring p c) + (gateWiring g.left g.right g.tile) c.boundary (gateInput g.left g.right) (support p c)) + (fun i => .inr (.inr i)) at hd + rwa [hs] at hd + obtain ⟨q,hq⟩ := graph_gate_step_exists hreal g.left g.right g.adjacent g.tile hcomp hd' + exact ⟨q,by simpa only [eval,hr,Option.bind_some] using hq⟩ + +theorem eval_iff (p : Pairing n) (c : Circuit n) (q : Pairing n) : + eval p c = some q ↔ Compatible p c ∧ GraphRealizes (wiring p c) c.boundary q := by + constructor + · intro h + exact ⟨(eval_sound p c q h).1,(eval_sound p c q h).2.1⟩ + · rintro ⟨hc,hq⟩ + obtain ⟨r,hr⟩ := eval_exists p c hc hq.drainsBoundary + have he := (eval_sound p c r hr).2.1.unique hq + exact he ▸ hr + +end Circuit +end + + + + + +noncomputable section +open Finset +open scoped Classical + +structure Position (n : ℕ) where + left : Fin n + right : Fin n + adjacent : left.val+1=right.val + +def Position.gate {n : ℕ} (a : Position n) (t : Tile) : Gate n := + ⟨a.left,a.right,a.adjacent,t⟩ + +def optionMatrix {K P Q : Type*} [Zero K] [One K] (f : P → Option Q) : Matrix Q P K := + fun q p => if f p=some q then 1 else 0 + +theorem optionMatrix_mul {K P Q R : Type*} [Semiring K] [Fintype Q] + (f : P → Option Q) (g : Q → Option R) : + (optionMatrix g : Matrix R Q K) * (optionMatrix f : Matrix Q P K) = optionMatrix (fun p => (f p).bind g) := by + ext r p + simp only [Matrix.mul_apply,optionMatrix] + rcases Option.eq_none_or_eq_some (f p) with he | ⟨q,he⟩ + · simp [he] + · simp only [he,Option.bind_some] + rw [sum_eq_single q] + · simp + · intro j _ hj + simp [Ne.symm hj] + · simp + +variable {K : Type*} [CommRing K] + +def localR {n : ℕ} (a : Position n) (w : Weights K) : Matrix (Pairing n) (Pairing n) K := + ∑ t : Tile, w.tile t • optionMatrix (fun p => p.tileStep a.left a.right a.adjacent t) + +inductive Program (n : ℕ) (K : Type*) where + | nil : Program n K + | snoc : Program n K → Position n → Weights K → Program n K + +namespace Program +variable {n : ℕ} + +def Choices : Program n K → Type + | .nil => PUnit + | .snoc p _ _ => p.Choices × Tile + +instance choicesFinite (p : Program n K) : Fintype p.Choices := by + induction p with + | nil => exact inferInstanceAs (Fintype PUnit) + | snoc p _ _ ih => letI := ih; exact inferInstanceAs (Fintype (p.Choices × Tile)) + +def circuit : (p : Program n K) → p.Choices → Circuit n + | .nil,_ => .nil + | .snoc p a _,(c,t) => .snoc (p.circuit c) (a.gate t) + +def weight : (p : Program n K) → p.Choices → K + | .nil,_ => 1 + | .snoc p _ w,(c,t) => p.weight c * w.tile t + +def matrix : Program n K → Matrix (Pairing n) (Pairing n) K + | .nil => 1 + | .snoc p a w => localR a w * p.matrix + +lemma matrix_expansion (p : Program n K) : p.matrix = + ∑ c : p.Choices, p.weight c • optionMatrix (fun q => Circuit.eval q (p.circuit c)) := by + induction p with + | nil => + change (1 : Matrix (Pairing n) (Pairing n) K) = + ∑ _ : PUnit, (1:K) • optionMatrix (fun q : Pairing n => some q) + rw [Fintype.sum_unique] + ext q r + simp [optionMatrix,Matrix.one_apply,eq_comm] + | snoc p a w ih => + simp only [matrix,localR,ih,mul_sum,sum_mul,Matrix.smul_mul,Matrix.mul_smul,smul_smul] + change (∑ c : p.Choices, ∑ t : Tile, + (p.weight c * w.tile t) • (optionMatrix (fun q : Pairing n => q.tileStep a.left a.right a.adjacent t) * + optionMatrix (fun q => Circuit.eval q (p.circuit c)))) = _ + simp_rw [optionMatrix_mul] + change _ = ∑ c : p.Choices × Tile, _ + rw [Fintype.sum_prod_type] + apply sum_congr rfl + intro c _ + apply sum_congr rfl + intro t _ + simp only [weight,circuit,Circuit.eval,Position.gate] + +lemma matrix_apply (p : Program n K) (q r : Pairing n) : p.matrix q r = + ∑ c : p.Choices, if Circuit.eval r (p.circuit c)=some q then p.weight c else 0 := by + rw [matrix_expansion] + simp only [Matrix.sum_apply,Matrix.smul_apply,optionMatrix,smul_eq_mul,mul_ite,mul_one,mul_zero] + +end Program +end +end CriticalStrip.Diagram + +end OAI diff --git a/lean/OAI/Combinatorics/StripMass/StepToCut.lean b/lean/OAI/Combinatorics/StripMass/StepToCut.lean new file mode 100644 index 0000000000000000000000000000000000000000..3824c4a13cd07db15d45fdccee9640a04d59e0ac --- /dev/null +++ b/lean/OAI/Combinatorics/StripMass/StepToCut.lean @@ -0,0 +1,551 @@ +import Mathlib +import OAI.Combinatorics.StripMass.CutStateSound + +namespace OAI + +/-! Critical honeycomb strip paths, polynomial identities and crossing mass. -/ + + + +namespace CriticalStrip.Diagram +noncomputable section +open Finset +open scoped Classical +namespace Pairing + +theorem inlinePrivate74_cut_input_left {n : ℕ} (p : Pairing n) (a b : Fin n) (t : Tile) + (ha : p.Occupied a) (hn : ¬p.Adj a b) : CutPatch.Adj (p.cutShape a b) t 0 4 := by + by_cases hb : p.Occupied b <;> simp only [cutShape,ha,hb,hn,ite_true,ite_false] + all_goals exact Or.inl (by simp [CutPatch.inputEdges]) + +theorem inlinePrivate74_cut_input_right {n : ℕ} (p : Pairing n) (a b : Fin n) (t : Tile) + (hb : p.Occupied b) (hn : ¬p.Adj a b) : CutPatch.Adj (p.cutShape a b) t 1 5 := by + by_cases ha : p.Occupied a <;> simp only [cutShape,ha,hb,hn,ite_true,ite_false] + all_goals exact Or.inl (by simp [CutPatch.inputEdges]) + +theorem inlinePrivate74_cut_input_paired {n : ℕ} (p : Pairing n) (a b : Fin n) (t : Tile) + (hn : p.Adj a b) : CutPatch.Adj (p.cutShape a b) t 0 1 := by + have ha : p.Occupied a := ⟨b,hn⟩ + have hb : p.Occupied b := ⟨a,adj_symm hn⟩ + simp only [cutShape,ha,hb,hn,ite_true] + exact Or.inl (by simp [CutPatch.inputEdges]) + +theorem cutReach_left {n : ℕ} (p : Pairing n) (a b : Fin n) (hab : a≠b) (t : Tile) + (j : Fin n) (h : p.Adj a j) : + Relation.ReflTransGen (p.cutGraph a b t) (.inl 0) (p.stepToCut a b (.old j)) := by + have ha : p.Occupied a := ⟨j,h⟩ + have hja : j≠a := by rintro rfl; exact p.adj_irrefl _ h + by_cases hjb : j=b + · subst j + simp only [stepToCut,Ne.symm hab,ite_false,ite_true] + exact .single (inlinePrivate74_cut_input_paired p a b t h) + · have hn : ¬p.Adj a b := fun hh => hjb (adj_unique h hh) + have hj : p.partnerOrSelf a=j := ((p.adj_partnerOrSelf a j).mp h).2.symm + simp only [stepToCut,hja,hjb,ite_false] + refine (Relation.ReflTransGen.single (show p.cutGraph a b t (.inl 0) (.inl 4) from inlinePrivate74_cut_input_left p a b t ha hn)).tail ?_ + exact ⟨2,(p.cutShape_active_two a b t).mpr ⟨ha,hn⟩,rfl,by simp [cutLabels,hj]⟩ + +theorem cutReach_right {n : ℕ} (p : Pairing n) (a b : Fin n) (hab : a≠b) (t : Tile) + (j : Fin n) (h : p.Adj b j) : + Relation.ReflTransGen (p.cutGraph a b t) (.inl 1) (p.stepToCut a b (.old j)) := by + have hb : p.Occupied b := ⟨j,h⟩ + have hjb : j≠b := by rintro rfl; exact p.adj_irrefl _ h + by_cases hja : j=a + · subst j + simp only [stepToCut,ite_true] + exact .single ((CutPatch.adj_symmetric _ _).symm _ _ (inlinePrivate74_cut_input_paired p a b t (adj_symm h))) + · have hn : ¬p.Adj a b := fun hh => hja (adj_unique h (adj_symm hh)) + have hj : p.partnerOrSelf b=j := ((p.adj_partnerOrSelf b j).mp h).2.symm + simp only [stepToCut,hja,hjb,ite_false] + refine (Relation.ReflTransGen.single (show p.cutGraph a b t (.inl 1) (.inl 5) from inlinePrivate74_cut_input_right p a b t hb hn)).tail ?_ + exact ⟨3,(p.cutShape_active_three a b t).mpr ⟨hb,hn⟩,rfl,by simp [cutLabels,hj]⟩ + +theorem cutReach_old_edge {n : ℕ} (p : Pairing n) (a b : Fin n) (hab : a≠b) (t : Tile) + (i j : Fin n) (h : p.Adj i j) : + Relation.ReflTransGen (p.cutGraph a b t) (p.stepToCut a b (.old i)) (p.stepToCut a b (.old j)) := by + by_cases hia : i=a + · subst i + simp only [stepToCut,ite_true] + exact cutReach_left p a b hab t j h + by_cases hib : i=b + · subst i + simpa only [stepToCut,Ne.symm hab,ite_false,ite_true] using cutReach_right p a b hab t j h + by_cases hja : j=a + · subst j + have hh := symm (cutReach_left p a b hab t i (adj_symm h)) + simpa only [stepToCut,ite_true] using hh + by_cases hjb : j=b + · subst j + have hh := symm (cutReach_right p a b hab t i (adj_symm h)) + simpa only [stepToCut,Ne.symm hab,ite_false,ite_true] using hh + simp only [stepToCut,hia,hib,hja,hjb,ite_false] + exact .single ((omitTwo_adj p a b i j).mpr ⟨h,hia,hib,hja,hjb⟩) + +theorem cutReach_box_output {n : ℕ} (p : Pairing n) (a b : Fin n) (t : Tile) + (k : Fin 4) (i : Fin n) (h : p.stepWiring a b t (.box k) (.out i)) : + Relation.ReflTransGen (p.cutGraph a b t) (p.stepToCut a b (.box k)) (p.stepToCut a b (.out i)) := by + rcases h with ⟨rfl,rfl,h⟩ | ⟨rfl,rfl,h⟩ + · exact .single ⟨0,(CutPatch.active_zero _ _).mpr h,rfl,by simp [cutLabels]⟩ + · exact .single ⟨1,(CutPatch.active_one _ _).mpr h,rfl,by simp [cutLabels]⟩ + +theorem cutReach_old_box {n : ℕ} (p : Pairing n) (a b : Fin n) (hab : a≠b) (t : Tile) + (i : Fin n) (k : Fin 4) (h : p.stepWiring a b t (.old i) (.box k)) : + Relation.ReflTransGen (p.cutGraph a b t) (p.stepToCut a b (.old i)) (p.stepToCut a b (.box k)) := by + rcases h with ⟨rfl,rfl,h⟩ | ⟨rfl,rfl,h⟩ + · simp only [stepToCut,ite_true]; exact .refl + · simp only [stepToCut,Ne.symm hab,ite_false,ite_true]; exact .refl + +theorem cutReach_old_output {n : ℕ} (p : Pairing n) (a b : Fin n) (t : Tile) + (i j : Fin n) (h : p.stepWiring a b t (.old i) (.out j)) : + Relation.ReflTransGen (p.cutGraph a b t) (p.stepToCut a b (.old i)) (p.stepToCut a b (.out j)) := by + obtain ⟨rfl,hia,hib,hi⟩ := h + simp only [stepToCut,hia,hib,ite_false] + exact .refl + +theorem stepToCut_edge {n : ℕ} (p : Pairing n) (a b : Fin n) (hab : a≠b) (t : Tile) + (v w : StepVertex n) (h : p.stepWiring a b t v w) : + Relation.ReflTransGen (p.cutGraph a b t) (p.stepToCut a b v) (p.stepToCut a b w) := by + cases v with + | old i => + cases w with + | old j => exact cutReach_old_edge p a b hab t i j h + | box k => exact cutReach_old_box p a b hab t i k h + | out j => exact cutReach_old_output p a b t i j h + | box k => + cases w with + | old i => exact symm (cutReach_old_box p a b hab t i k h) + | box l => exact .single (Or.inr (Or.inr ⟨k,l,h,rfl,rfl⟩)) + | out i => exact cutReach_box_output p a b t k i h + | out i => + cases w with + | old j => exact symm (cutReach_old_output p a b t j i h) + | box k => exact symm (cutReach_box_output p a b t k i h) + | out j => exact h.elim + + + + + + + +@[simp] theorem cutToStep_tilePort {n : ℕ} (p : Pairing n) (a b : Fin n) (k : Fin 4) : + p.cutToStep a b (.inl (CutPatch.tilePort k)) = .box k := by + fin_cases k <;> rfl + +theorem partnerOrSelf_occupied {n : ℕ} (p : Pairing n) (a : Fin n) (ha : p.Occupied a) : + p.Occupied (p.partnerOrSelf a) := + ⟨a,adj_symm ((adj_partnerOrSelf p a _).mpr ⟨ha,rfl⟩)⟩ + +theorem partnerOrSelf_away_left {n : ℕ} (p : Pairing n) (a b : Fin n) + (ha : p.Occupied a) (hn : ¬p.Adj a b) : p.partnerOrSelf a ≠ b := by + intro h + exact hn ((adj_partnerOrSelf p a b).mpr ⟨ha,h.symm⟩) + +theorem step_input_left {n : ℕ} (p : Pairing n) (a b : Fin n) (t : Tile) + (ha : p.Occupied a) : + Relation.ReflTransGen (p.stepWiring a b t) (.box 0) (.old (p.partnerOrSelf a)) := by + refine (Relation.ReflTransGen.single (show p.stepWiring a b t (.box 0) (.old a) from Or.inl ⟨rfl,rfl,ha⟩)).tail ?_ + exact (adj_partnerOrSelf p a _).mpr ⟨ha,rfl⟩ + +theorem step_input_right {n : ℕ} (p : Pairing n) (a b : Fin n) (t : Tile) + (hb : p.Occupied b) : + Relation.ReflTransGen (p.stepWiring a b t) (.box 1) (.old (p.partnerOrSelf b)) := by + refine (Relation.ReflTransGen.single (show p.stepWiring a b t (.box 1) (.old b) from Or.inr ⟨rfl,rfl,hb⟩)).tail ?_ + exact (adj_partnerOrSelf p b _).mpr ⟨hb,rfl⟩ + +theorem step_input_paired {n : ℕ} (p : Pairing n) (a b : Fin n) (t : Tile) + (hn : p.Adj a b) : Relation.ReflTransGen (p.stepWiring a b t) (.box 0) (.box 1) := by + have h₁ : p.stepWiring a b t (.box 0) (.old a) := Or.inl ⟨rfl,rfl,⟨b,hn⟩⟩ + have h₂ : p.stepWiring a b t (.old a) (.old b) := hn + have h₃ : p.stepWiring a b t (.old b) (.box 1) := Or.inr ⟨rfl,rfl,⟨a,adj_symm hn⟩⟩ + exact ((Relation.ReflTransGen.single h₁).tail h₂).tail h₃ + +theorem cut_input_cases {n : ℕ} (p : Pairing n) (a b : Fin n) (v w : Fin 6) + (h : (v,w) ∈ CutPatch.inputEdges (p.cutShape a b)) : + (v=0 ∧ w=4 ∧ p.Occupied a) ∨ (v=1 ∧ w=5 ∧ p.Occupied b) ∨ + (v=0 ∧ w=1 ∧ p.Adj a b) := by + by_cases ha : p.Occupied a <;> by_cases hb : p.Occupied b <;> by_cases hn : p.Adj a b <;> + simp [cutShape,ha,hb,hn,CutPatch.inputEdges,Prod.mk.injEq] at h ⊢ <;> itauto + +theorem stepReach_input_edge {n : ℕ} (p : Pairing n) (a b : Fin n) (t : Tile) + (v w : Fin 6) (h : (v,w) ∈ CutPatch.inputEdges (p.cutShape a b)) : + Relation.ReflTransGen (p.stepWiring a b t) (p.cutToStep a b (.inl v)) (p.cutToStep a b (.inl w)) := by + rcases cut_input_cases p a b v w h with ⟨rfl,rfl,ha⟩ | ⟨rfl,rfl,hb⟩ | ⟨rfl,rfl,hn⟩ + · exact step_input_left p a b t ha + · exact step_input_right p a b t hb + · exact step_input_paired p a b t hn + +theorem stepReach_interface {n : ℕ} (p : Pairing n) (a b : Fin n) (t : Tile) + (i : Fin 4) (hi : CutPatch.active (p.cutShape a b) t i) : + Relation.ReflTransGen (p.stepWiring a b t) + (p.cutToStep a b (.inl (CutPatch.boundary i))) (p.cutToStep a b (.inr (p.cutLabels a b i))) := by + fin_cases i + · exact .single (Or.inl ⟨rfl,rfl,(CutPatch.active_zero _ _).mp hi⟩) + · exact .single (Or.inr ⟨rfl,rfl,(CutPatch.active_one _ _).mp hi⟩) + · obtain ⟨ha,hn⟩ := (p.cutShape_active_two a b t).mp hi + exact .single ⟨rfl,p.partnerOrSelf_ne a ha,p.partnerOrSelf_away_left a b ha hn, + p.partnerOrSelf_occupied a ha⟩ + · obtain ⟨hb,hn⟩ := (p.cutShape_active_three a b t).mp hi + have hna : ¬p.Adj b a := fun hh => hn (adj_symm hh) + exact .single ⟨rfl,p.partnerOrSelf_away_left b a hb hna,p.partnerOrSelf_ne b hb, + p.partnerOrSelf_occupied b hb⟩ + +theorem stepReach_omitted {n : ℕ} (p : Pairing n) (a b : Fin n) (t : Tile) + (i j : Fin n) (h : (p.omitTwo a b).Adj i j) : + Relation.ReflTransGen (p.stepWiring a b t) (.out i) (.out j) := by + obtain ⟨h,hia,hib,hja,hjb⟩ := (omitTwo_adj p a b i j).mp h + have h₁ : p.stepWiring a b t (.out i) (.old i) := ⟨rfl,hia,hib,⟨j,h⟩⟩ + have h₂ : p.stepWiring a b t (.old i) (.old j) := h + have h₃ : p.stepWiring a b t (.old j) (.out j) := ⟨rfl,hja,hjb,⟨i,adj_symm h⟩⟩ + exact ((Relation.ReflTransGen.single h₁).tail h₂).tail h₃ + +theorem cutToStep_edge {n : ℕ} (p : Pairing n) (a b : Fin n) (t : Tile) + (v w : Sum (Fin 6) (Fin n)) (h : p.cutGraph a b t v w) : + Relation.ReflTransGen (p.stepWiring a b t) (p.cutToStep a b v) (p.cutToStep a b w) := by + cases v with + | inl v => + cases w with + | inl w => + rcases h with h | h | ⟨i,j,h,rfl,rfl⟩ + · exact stepReach_input_edge p a b t v w h + · exact symm (stepReach_input_edge p a b t w v h) + · simp only [cutToStep_tilePort] + exact .single h + | inr w => + obtain ⟨i,hi,rfl,rfl⟩ := h + exact stepReach_interface p a b t i hi + | inr v => + cases w with + | inl w => + obtain ⟨i,hi,rfl,rfl⟩ := h + exact symm (stepReach_interface p a b t i hi) + | inr w => exact stepReach_omitted p a b t v w h + +end Pairing +end + + + + + +noncomputable section +open scoped Classical + +namespace Graph + +theorem used_of_reach_ne {V : Type*} {r : V → V → Prop} {v w : V} + (h : Relation.ReflTransGen r v w) (hne : v ≠ w) : Used r v := by + rcases h.cases_head with h | ⟨x,hx,_⟩ + · exact (hne h).elim + · exact ⟨x,hx⟩ + +end Graph + +@[simp] theorem Tile.adj_irrefl (t : Tile) (i : Fin 4) : ¬t.Adj i i := by + cases t <;> fin_cases i <;> decide + +namespace Pairing + +theorem stepToCut_old_injective {n : ℕ} (p : Pairing n) (a b : Fin n) : + Function.Injective (fun i => p.stepToCut a b (.old i)) := by + intro i j h + by_cases hia : i=a <;> by_cases hib : i=b <;> + by_cases hja : j=a <;> by_cases hjb : j=b <;> + simp_all [stepToCut] + +theorem cutGraph_used_old {n : ℕ} (p : Pairing n) (a b : Fin n) (hab : a≠b) (t : Tile) + (i : Fin n) (hi : p.Occupied i) : Graph.Used (p.cutGraph a b t) (p.stepToCut a b (.old i)) := by + obtain ⟨j,hj⟩ := hi + apply Graph.used_of_reach_ne (p.cutReach_old_edge a b hab t i j hj) + intro hh + have := p.stepToCut_old_injective a b hh + subst j + exact p.adj_irrefl i hj + +theorem stepWiring_old_used {n : ℕ} (p : Pairing n) (a b : Fin n) (t : Tile) + (i : Fin n) : Graph.Used (p.stepWiring a b t) (.old i) ↔ p.Occupied i := by + constructor + · rintro ⟨v,hv⟩ + cases v with + | old j => exact ⟨j,hv⟩ + | box k => rcases hv with ⟨rfl,_,h⟩ | ⟨rfl,_,h⟩ <;> exact h + | out j => exact hv.2.2.2 + · rintro ⟨j,hj⟩ + exact ⟨.old j,hj⟩ + +theorem stepToCut_used {n : ℕ} (p : Pairing n) (a b : Fin n) (hab : a≠b) (t : Tile) + (v : StepVertex n) (hv : Graph.Used (p.stepWiring a b t) v) : + Graph.Used (p.cutGraph a b t) (p.stepToCut a b v) := by + cases v with + | old i => exact p.cutGraph_used_old a b hab t i ((p.stepWiring_old_used a b t i).mp hv) + | box k => + obtain ⟨w,hw⟩ := hv + cases w with + | old i => + rcases hw with ⟨hia,hk,ha⟩ | ⟨hib,hk,hb⟩ + · subst i k + simpa [stepToCut,CutPatch.tilePort] using p.cutGraph_used_old a b hab t a ha + · subst i k + simpa [stepToCut,hab.symm,CutPatch.tilePort] using p.cutGraph_used_old a b hab t b hb + | box l => exact ⟨.inl (CutPatch.tilePort l),Or.inr (Or.inr ⟨k,l,hw,rfl,rfl⟩)⟩ + | out i => + apply Graph.used_of_reach_ne (p.stepToCut_edge a b hab t (.box k) (.out i) hw) + simp [stepToCut] + | out i => + obtain ⟨w,hw⟩ := hv + cases w with + | old j => + obtain ⟨rfl,hja,hjb,hj⟩ := hw + simpa [stepToCut,hja,hjb] using p.cutGraph_used_old a b hab t j hj + | box k => + apply Graph.used_of_reach_ne (p.stepToCut_edge a b hab t (.out i) (.box k) hw) + simp [stepToCut] + | out j => exact hw.elim + +theorem cutToStep_edge_ne {n : ℕ} (p : Pairing n) (a b : Fin n) (t : Tile) + (v w : Sum (Fin 6) (Fin n)) (h : p.cutGraph a b t v w) : + p.cutToStep a b v ≠ p.cutToStep a b w := by + cases v with + | inl v => + cases w with + | inl w => + rcases h with h | h | ⟨i,j,h,rfl,rfl⟩ + · rcases p.cut_input_cases a b v w h with ⟨rfl,rfl,_⟩ | ⟨rfl,rfl,_⟩ | ⟨rfl,rfl,_⟩ <;> + simp [cutToStep] + · rcases p.cut_input_cases a b w v h with ⟨rfl,rfl,_⟩ | ⟨rfl,rfl,_⟩ | ⟨rfl,rfl,_⟩ <;> + simp [cutToStep] + · simp only [cutToStep_tilePort,ne_eq,StepVertex.box.injEq] + intro hh + subst j + exact t.adj_irrefl i h + | inr w => + obtain ⟨i,_,rfl,rfl⟩ := h + fin_cases i <;> simp [cutToStep,CutPatch.boundary] + | inr v => + cases w with + | inl w => + obtain ⟨i,_,rfl,rfl⟩ := h + fin_cases i <;> simp [cutToStep,CutPatch.boundary] + | inr w => + simp only [cutToStep,ne_eq,StepVertex.out.injEq] + intro hh + subst w + exact (p.omitTwo a b).adj_irrefl v h + +theorem cutToStep_used {n : ℕ} (p : Pairing n) (a b : Fin n) (t : Tile) + (v : Sum (Fin 6) (Fin n)) (hv : Graph.Used (p.cutGraph a b t) v) : + Graph.Used (p.stepWiring a b t) (p.cutToStep a b v) := by + obtain ⟨w,hw⟩ := hv + exact Graph.used_of_reach_ne (p.cutToStep_edge a b t v w hw) (p.cutToStep_edge_ne a b t v w hw) + +end Pairing + + + + + + +namespace CutPatch + +theorem adj_four_active : ∀ (s : Shape) (t : Tile) (v : Fin 6), Adj s t 4 v → active s t 2 := by + decide + +theorem adj_five_active : ∀ (s : Shape) (t : Tile) (v : Fin 6), Adj s t 5 v → active s t 3 := by + decide + +end CutPatch + +namespace Pairing + +theorem cutGraph_used_four {n : ℕ} (p : Pairing n) (a b : Fin n) (t : Tile) + (h : Graph.Used (p.cutGraph a b t) (.inl 4)) : CutPatch.active (p.cutShape a b) t 2 := by + obtain ⟨w,hw⟩ := h + cases w with + | inl w => exact CutPatch.adj_four_active _ _ w hw + | inr w => + obtain ⟨i,hi,hb,_⟩ := hw + fin_cases i <;> simp_all [CutPatch.boundary] + +theorem cutGraph_used_five {n : ℕ} (p : Pairing n) (a b : Fin n) (t : Tile) + (h : Graph.Used (p.cutGraph a b t) (.inl 5)) : CutPatch.active (p.cutShape a b) t 3 := by + obtain ⟨w,hw⟩ := h + cases w with + | inl w => exact CutPatch.adj_five_active _ _ w hw + | inr w => + obtain ⟨i,hi,hb,_⟩ := hw + fin_cases i <;> simp_all [CutPatch.boundary] + +theorem stepToCut_retract {n : ℕ} (p : Pairing n) (a b : Fin n) (t : Tile) + (v : StepVertex n) (hv : Graph.Used (p.stepWiring a b t) v) : + Relation.ReflTransGen (p.stepWiring a b t) v (p.cutToStep a b (p.stepToCut a b v)) := by + cases v with + | old i => + have hi := (p.stepWiring_old_used a b t i).mp hv + by_cases hia : i=a + · subst i + simp only [stepToCut,ite_true,cutToStep,Matrix.cons_val_zero] + exact .single (Or.inl ⟨rfl,rfl,hi⟩) + · by_cases hib : i=b + · subst i + simp only [stepToCut,hia,ite_false,ite_true,cutToStep,Matrix.cons_val_one, + Matrix.cons_val_zero] + exact .single (Or.inr ⟨rfl,rfl,hi⟩) + · simp only [stepToCut,hia,hib,ite_false,cutToStep] + exact .single ⟨rfl,hia,hib,hi⟩ + | box k => rw [stepToCut,cutToStep_tilePort] + | out i => exact .refl + +theorem cutToStep_retract {n : ℕ} (p : Pairing n) (a b : Fin n) (t : Tile) + (v : Sum (Fin 6) (Fin n)) (hv : Graph.Used (p.cutGraph a b t) v) : + Relation.ReflTransGen (p.cutGraph a b t) v (p.stepToCut a b (p.cutToStep a b v)) := by + cases v with + | inl k => + fin_cases k + · exact .refl + · exact .refl + · exact .refl + · exact .refl + · have hi := p.cutGraph_used_four a b t hv + obtain ⟨ha,hn⟩ := (p.cutShape_active_two a b t).mp hi + have hpa := p.partnerOrSelf_ne a ha + have hpb := p.partnerOrSelf_away_left a b ha hn + change Relation.ReflTransGen (p.cutGraph a b t) (.inl 4) + (p.stepToCut a b (.old (p.partnerOrSelf a))) + simp only [stepToCut,hpa,hpb,ite_false] + exact .single ⟨2,hi,rfl,rfl⟩ + · have hi := p.cutGraph_used_five a b t hv + obtain ⟨hb,hn⟩ := (p.cutShape_active_three a b t).mp hi + have hpb := p.partnerOrSelf_ne b hb + have hna : ¬ p.Adj b a := fun hh => hn (adj_symm hh) + have hpa := p.partnerOrSelf_away_left b a hb hna + change Relation.ReflTransGen (p.cutGraph a b t) (.inl 5) + (p.stepToCut a b (.old (p.partnerOrSelf b))) + simp only [stepToCut,hpa,hpb,ite_false] + exact .single ⟨3,hi,rfl,rfl⟩ + | inr i => exact .refl + +def stepCutEquiv {n : ℕ} (p : Pairing n) (a b : Fin n) (hab : a≠b) (t : Tile) : + Graph.BoundaryEquiv (p.stepWiring a b t) (p.cutGraph a b t) StepVertex.out Sum.inr where + toFun := p.stepToCut a b + invFun := p.cutToStep a b + map_edge := p.stepToCut_edge a b hab t + inv_edge := p.cutToStep_edge a b t + map_boundary := fun _ => rfl + inv_boundary := fun _ => rfl + map_used := p.stepToCut_used a b hab t + inv_used := p.cutToStep_used a b t + retract := p.stepToCut_retract a b t + inv_retract := p.cutToStep_retract a b t + +theorem stepWiring_realizes {n : ℕ} (p : Pairing n) (a b : Fin n) + (hab : a.val+1=b.val) (t : Tile) (q : Pairing n) + (hq : p.tileStep a b hab t = some q) : + GraphRealizes (p.stepWiring a b t) StepVertex.out q := by + have hne : a≠b := by intro hh; have := congrArg Fin.val hh; omega + exact (p.stepCutEquiv a b hne t).symm.realizes (p.cutGraph_realizes a b hab t q hq) + + + + + + + + +theorem ext_adj {n : ℕ} {p q : Pairing n} (h : ∀ i j, p.Adj i j ↔ q.Adj i j) : p=q := by + apply Subtype.ext + ext e + constructor + · intro he + rcases (h e.1 e.2).mp (Or.inl he) with hh | hh + · exact hh + · have hp := p.property.1 _ he + have hq := q.property.1 _ hh + exact (lt_asymm hp hq).elim + · intro he + rcases (h e.1 e.2).mpr (Or.inl he) with hh | hh + · exact hh + · have hp := q.property.1 _ he + have hq := p.property.1 _ hh + exact (lt_asymm hp hq).elim + +theorem graphRealizes {n : ℕ} (p : Pairing n) : GraphRealizes p.Adj id p where + no_loop := fun v w h => ⟨v,⟨w,h⟩,.refl⟩ + reach := p.reach_adj_iff + +end Pairing + +namespace GraphRealizes + +theorem unique {V : Type*} {n : ℕ} {r : V → V → Prop} {a : Fin n → V} + {p q : Pairing n} (hp : GraphRealizes r a p) (hq : GraphRealizes r a q) : p=q := by + apply Pairing.ext_adj + intro i j + by_cases hij : i=j + · subst j; simp only [p.adj_irrefl,q.adj_irrefl] + · have hh := (hp.reach i j).symm.trans (hq.reach i j) + simpa only [hij,false_or] using hh + + + +theorem compressed_eq {V B : Type*} {n : ℕ} {r : V → V → Prop} {a : Fin n → V} + {p : Pairing n} (h : GraphRealizes r a p) (s : B → B → Prop) (b : Fin n → B) : + Patch.compressed r s a b p.Occupied = Patch.compressed p.Adj s id b p.Occupied := by + funext x y + apply propext + simp only [Patch.compressed,h.reach,Pairing.reach_adj_iff,id_eq] + +theorem drains_glued_iff {V B : Type*} {n : ℕ} {r : V → V → Prop} {a : Fin n → V} + {p : Pairing n} (h : GraphRealizes r a p) (s : B → B → Prop) (b : Fin n → B) + (out : B → Prop) : + Patch.drains (Patch.glued r s a b p.Occupied) (Patch.exteriorOutput out) ↔ + Patch.drains (Patch.glued p.Adj s id b p.Occupied) (Patch.exteriorOutput out) := by + rw [Patch.drains_glued_iff,Patch.drains_glued_iff,h.compressed_eq s b] + have hp := p.graphRealizes + exact ⟨fun hh => ⟨hp.no_loop,hh.2⟩,fun hh => ⟨h.no_loop,hh.2⟩⟩ + +end GraphRealizes + +namespace Patch + +theorem realizes_iff_drains {V B : Type*} {n m : ℕ} (r : V → V → Prop) + (s : B → B → Prop) (a : Fin n → V) (b : Fin n → B) (active : Fin n → Prop) + (c : Fin m → B) (q : Pairing m) : + GraphRealizes (glued r s a b active) (fun i => .inr (c i)) q ↔ + drains (glued r s a b active) (exteriorOutput (fun x => ∃ i, q.Occupied i ∧ x=c i)) ∧ + (∀ i j, Relation.ReflTransGen (compressed r s a b active) (c i) (c j) ↔ i=j ∨ q.Adj i j) := by + constructor + · intro h + constructor + · intro v w hvw + obtain ⟨i,hi,hr⟩ := h.no_loop v w hvw + exact ⟨.inr (c i),⟨i,hi,rfl⟩,hr⟩ + · intro i j + exact (exterior_reach_iff r s a b active).symm.trans (h.reach i j) + · rintro ⟨hd,hr⟩ + constructor + · intro v w hvw + obtain ⟨x,hx,hvx⟩ := hd v w hvw + cases x with + | inl x => exact hx.elim + | inr x => + obtain ⟨i,hi,rfl⟩ := hx + exact ⟨i,hi,hvx⟩ + · intro i j + exact (exterior_reach_iff r s a b active).trans (hr i j) + +end Patch + +namespace GraphRealizes + +theorem substitute_iff {V B : Type*} {n m : ℕ} {r : V → V → Prop} {a : Fin n → V} + {p : Pairing n} (h : GraphRealizes r a p) (s : B → B → Prop) (b : Fin n → B) + (c : Fin m → B) (q : Pairing m) : + GraphRealizes (Patch.glued r s a b p.Occupied) (fun i => .inr (c i)) q ↔ + GraphRealizes (Patch.glued p.Adj s id b p.Occupied) (fun i => .inr (c i)) q := by + rw [Patch.realizes_iff_drains,Patch.realizes_iff_drains,h.compressed_eq s b,h.drains_glued_iff s b] + +end GraphRealizes +end +end CriticalStrip.Diagram + +end OAI diff --git a/lean/OAI/Combinatorics/StripMass/StieltjesLimits.lean b/lean/OAI/Combinatorics/StripMass/StieltjesLimits.lean new file mode 100644 index 0000000000000000000000000000000000000000..8e399667a4b21976c67e31d5f73fbeb37a6a5746 --- /dev/null +++ b/lean/OAI/Combinatorics/StripMass/StieltjesLimits.lean @@ -0,0 +1,432 @@ +import Mathlib +import OAI.Combinatorics.StripMass.QuarticIntegrals + +namespace OAI + +/-! Critical honeycomb strip paths, polynomial identities and crossing mass. -/ + + +namespace CriticalStrip +noncomputable section +open Set MeasureTheory Filter +open scoped Topology +theorem tendsto_realStieltjes_zero {α : Type*} {l : Filter α} {z : α → ℝ} + {a : ℝ} {w : ℝ → ℝ} (hw : IntegrableOn w (Ioo (0 : ℝ) 1)) (ha : |a| ≤ 1) + (hz : Tendsto (fun t => ‖z t‖) l atTop) : + Tendsto (fun t => realStieltjes a w (z t)) l (𝓝 0) := by + have hz' : Tendsto (fun t => |z t|) l atTop := by simpa only [Real.norm_eq_abs] using hz + apply tendsto_zero_iff_norm_tendsto_zero.2 + apply squeeze_zero' (Eventually.of_forall fun _ => norm_nonneg _) + ((hz'.eventually_ge_atTop 2).mono fun _ ht => norm_realStieltjes_le hw ha ht) + exact tendsto_const_nhds.div_atTop (by + simpa only [sub_eq_add_neg] using tendsto_atTop_add_const_right l (-1) hz') + + +theorem polynomial_constant_of_limit {α : Type*} {l : Filter α} [l.NeBot] + {z : α → ℝ} (hz : Tendsto (fun t => ‖z t‖) l atTop) + (p : Polynomial ℝ) {L : ℝ} (hp : Tendsto (fun t => p.eval (z t)) l (𝓝 L)) : + p = Polynomial.C L := by + have hd : p.degree ≤ 0 := by + by_contra h + have htop := p.tendsto_norm_atTop (lt_of_not_ge h) hz + exact not_tendsto_nhds_of_tendsto_atTop htop ‖L‖ hp.norm + have heq := Polynomial.eq_C_of_degree_le_zero hd + have hL : p.coeff 0 = L := by + have hc : Tendsto (fun _ : α => p.coeff 0) l (𝓝 L) := by + apply hp.congr' + exact Eventually.of_forall fun t => + (congrArg (fun q : Polynomial ℝ => q.eval (z t)) heq).trans (Polynomial.eval_C) + exact tendsto_nhds_unique tendsto_const_nhds hc + rw [heq, hL] + + + +theorem moments_zero_of_stieltjes_decay {α : Type*} {l : Filter α} [l.NeBot] + {z : α → ℝ} (hz : Tendsto (fun t => ‖z t‖) l atTop) (N : ℕ) + {w : ℝ → ℝ} (hw : IntegrableOn w (Ioo (0 : ℝ) 1)) + (hdecay : ∀ j : ℕ, j < N → Tendsto + (fun t => z t ^ (j + 1) * realStieltjes 1 w (z t)) l (𝓝 0)) : + ∀ j : ℕ, j < N → ∫ x in Ioo (0 : ℝ) 1, x ^ j * w x = 0 := by + induction N generalizing w with + | zero => simp + | succ N ih => + let v : ℝ → ℝ := fun x => x * w x + have hv : IntegrableOn v (Ioo (0 : ℝ) 1) := + integrableOn_continuous_mul hw continuous_id.continuousOn + have hevent : ∀ᶠ t in l, offCut 1 (z t) := by + filter_upwards [hz.eventually_ge_atTop 2] with t ht + exact offCut_of_abs_large (by norm_num) (by simpa only [Real.norm_eq_abs] using ht) + have hrec : ∀ᶠ t in l, z t * realStieltjes 1 w (z t) = + realStieltjes 1 v (z t) + ∫ x in Ioo (0 : ℝ) 1, w x := by + filter_upwards [hevent] with t ht + simpa only [one_mul] using realStieltjes_mul_variable hw ht + have hlim : Tendsto (fun t => z t * realStieltjes 1 w (z t)) l + (𝓝 (∫ x in Ioo (0 : ℝ) 1, w x)) := by + have h := (tendsto_realStieltjes_zero hv (by norm_num : |(1 : ℝ)| ≤ 1) hz).add_const + (∫ x in Ioo (0 : ℝ) 1, w x) + simpa only [zero_add] using h.congr' (hrec.mono fun _ ht => ht.symm) + have hm : (∫ x in Ioo (0 : ℝ) 1, w x) = 0 := by + apply tendsto_nhds_unique hlim + simpa only [zero_add, pow_one] using hdecay 0 (Nat.succ_pos N) + have hdecayv : ∀ j : ℕ, j < N → Tendsto + (fun t => z t ^ (j + 1) * realStieltjes 1 v (z t)) l (𝓝 0) := by + intro j hj + apply (hdecay (j + 1) (Nat.succ_lt_succ hj)).congr' + filter_upwards [hrec] with t ht + rw [hm, add_zero] at ht + rw [← ht, pow_succ] + ring + intro j hj + cases j with + | zero => simpa using hm + | succ j => + have hj' : j < N := Nat.lt_of_succ_lt_succ hj + have h := ih hv hdecayv j hj' + convert h using 1 + apply setIntegral_congr_fun measurableSet_Ioo + intro x _ + dsimp [v] + rw [pow_succ] + ring + + + + +def fBranch (z : ℝ) : ℝ := Real.sqrt ((1 + Real.sqrt ((1 - 1 / z) / 2)) / 2) +def projectionF (P J E : Polynomial ℝ) (z : ℝ) : ℝ := + P.eval z + fBranch z * J.eval z + fBranch z ^ 2 * E.eval z +def projectionD (J E : Polynomial ℝ) (z : ℝ) : ℝ := + J.eval z + lBranch z * E.eval z + +theorem integrableOn_omega_projection : IntegrableOn omega (Ioo (0 : ℝ) 1) := by + have hi := ((omega_resolvent (by norm_num : (0 : ℝ) < 1)).1).const_mul 2 + apply hi.mono' + · apply Measurable.aestronglyMeasurable + unfold omega + fun_prop + · filter_upwards [ae_restrict_mem measurableSet_Ioo] with x hx + rw [Real.norm_eq_abs, abs_of_nonneg (by unfold omega; positivity)] + simp only [one_mul] + have hd : 0 < 1 + x := by linarith [hx.1] + rw [← mul_div_assoc, le_div_iff₀ hd] + have hw : 0 ≤ omega x := by unfold omega; positivity + nlinarith [hx.2] + +theorem offCut_one_neg {z : ℝ} (hz : z < 0) : offCut 1 z := by + intro x hx + simp only [one_mul] + linarith [hx.1] + +theorem offCut_neg_one_pos {z : ℝ} (hz : 0 < z) : offCut (-1) z := by + intro x hx + simp only [neg_one_mul, sub_neg_eq_add] + linarith [hx.1] + +theorem integrableOn_projection_weight (J E : Polynomial ℝ) : + IntegrableOn (fun x => projectionD J E x * omega x) (Ioo (0 : ℝ) 1) := by + have hj := integrableOn_polynomial_weight (a := (1 : ℝ)) integrableOn_omega_projection J + have he := integrableOn_polynomial_weight (a := (1 : ℝ)) integrableOn_lBranch_omega E + have heq : (fun x => projectionD J E x * omega x) = + fun x => J.eval (1 * x) * omega x + E.eval (1 * x) * (lBranch x * omega x) := by + funext x + simp only [one_mul, projectionD] + ring + rw [heq] + exact hj.add he + +theorem fBranch_transform {z : ℝ} (hz : z < 0) : + fBranch z = Real.cos (Real.pi / 8) - + (1 / Real.pi) * realStieltjes 1 omega z := by + have h := stieltjes_omega hz + have heq : (∫ x in Ioo (0 : ℝ) 1, omega x / (x - z)) = -realStieltjes 1 omega z := by + rw [realStieltjes, ← integral_neg] + apply setIntegral_congr_fun measurableSet_Ioo + intro x _ + simp only [one_mul] + rw [show x - z = -(z - x) by ring, div_neg] + simpa only [fBranch, heq, mul_neg, ← sub_eq_add_neg] using h + +theorem fBranch_square_transform {z : ℝ} (hz : z < 0) : + fBranch z ^ 2 = Real.cos (Real.pi / 8) ^ 2 - + (1 / Real.pi) * realStieltjes 1 (fun x => lBranch x * omega x) z := by + have h := stieltjes_omega_square hz + have heq : (∫ x in Ioo (0 : ℝ) 1, lBranch x * omega x / (x - z)) = + -realStieltjes 1 (fun x => lBranch x * omega x) z := by + rw [realStieltjes, ← integral_neg] + apply setIntegral_congr_fun measurableSet_Ioo + intro x _ + simp only [one_mul] + rw [show x - z = -(z - x) by ring, div_neg] + simpa only [fBranch, heq, mul_neg, ← sub_eq_add_neg] using h + + +theorem projectionF_polynomial (P J E : Polynomial ℝ) : + ∃ R : Polynomial ℝ, ∀ z : ℝ, z < 0 → + projectionF P J E z = R.eval z - (1 / Real.pi) * + realStieltjes 1 (fun x => projectionD J E x * omega x) z := by + obtain ⟨Rj, hRj⟩ := polynomial_mul_realStieltjes (a := (1 : ℝ)) integrableOn_omega_projection J + obtain ⟨Re, hRe⟩ := polynomial_mul_realStieltjes (a := (1 : ℝ)) integrableOn_lBranch_omega E + refine ⟨P + Polynomial.C (Real.cos (Real.pi / 8)) * J + + Polynomial.C (Real.cos (Real.pi / 8) ^ 2) * E - + Polynomial.C (1 / Real.pi) * (Rj + Re), ?_⟩ + intro z hz + have hj := hRj z (offCut_one_neg hz) + have he := hRe z (offCut_one_neg hz) + have hsum := realStieltjes_add + (integrableOn_polynomial_weight (a := (1 : ℝ)) integrableOn_omega_projection J) + (integrableOn_polynomial_weight (a := (1 : ℝ)) integrableOn_lBranch_omega E) + (offCut_one_neg hz) + have hw : (fun x => J.eval (1 * x) * omega x + E.eval (1 * x) * (lBranch x * omega x)) = + fun x => projectionD J E x * omega x := by + funext x + simp only [one_mul, projectionD] + ring + rw [hw] at hsum + simp only [one_mul] at hj he hsum + rw [projectionF, fBranch_square_transform hz, fBranch_transform hz, hsum] + simp only [Polynomial.eval_add, Polynomial.eval_sub, Polynomial.eval_mul, Polynomial.eval_C] + linear_combination -(1 / Real.pi) * hj - (1 / Real.pi) * he + +theorem norm_neg_atTop : Tendsto (fun z : ℝ => ‖-z‖) atTop atTop := by + simpa only [norm_neg] using (tendsto_norm_atTop_atTop : Tendsto (fun z : ℝ => ‖z‖) atTop atTop) + + + +theorem projectionF_cauchy (P J E : Polynomial ℝ) + (hF : Tendsto (fun t : ℝ => projectionF P J E (-t)) atTop (𝓝 0)) : + ∀ z : ℝ, z < 0 → projectionF P J E z = -(1 / Real.pi) * + realStieltjes 1 (fun x => projectionD J E x * omega x) z := by + obtain ⟨R, hR⟩ := projectionF_polynomial P J E + have hlim := hF.add ((tendsto_realStieltjes_zero (integrableOn_projection_weight J E) + (by norm_num : |(1 : ℝ)| ≤ 1) norm_neg_atTop).const_mul (1 / Real.pi)) + have hRlim : Tendsto (fun t : ℝ => R.eval (-t)) atTop (𝓝 0) := by + have hlim' : Tendsto (fun t : ℝ => projectionF P J E (-t) + (1 / Real.pi) * + realStieltjes 1 (fun x => projectionD J E x * omega x) (-t)) atTop (𝓝 0) := by + simpa only [mul_zero, add_zero] using hlim + apply hlim'.congr' + filter_upwards [eventually_gt_atTop (0 : ℝ)] with t ht + have h := hR (-t) (neg_neg_of_pos ht) + linarith + have hR0 := polynomial_constant_of_limit norm_neg_atTop R hRlim + intro z hz + simpa only [hR0, Polynomial.eval_C, zero_sub, neg_mul] using hR z hz + + + +theorem projection_moments_of_decay (N : ℕ) (P J E : Polynomial ℝ) + (hF : ∀ j : ℕ, j ≤ N → Tendsto + (fun t : ℝ => (-t) ^ j * projectionF P J E (-t)) atTop (𝓝 0)) : + ∀ j : ℕ, j < N → ∫ x in Ioo (0 : ℝ) 1, + x ^ j * (projectionD J E x * omega x) = 0 := by + have hFc := projectionF_cauchy P J E (by simpa using hF 0 (Nat.zero_le N)) + apply moments_zero_of_stieltjes_decay norm_neg_atTop N (integrableOn_projection_weight J E) + intro j hj + apply (show Tendsto (fun t : ℝ => (-Real.pi) * + ((-t) ^ (j + 1) * projectionF P J E (-t))) atTop (𝓝 0) from + by simpa using (hF (j + 1) (Nat.succ_le_of_lt hj)).const_mul (-Real.pi)).congr' + filter_upwards [eventually_gt_atTop (0 : ℝ)] with t ht + rw [hFc (-t) (neg_neg_of_pos ht)] + field_simp [Real.pi_ne_zero] + + + +theorem projectionD_cauchy (J e : Polynomial ℝ) {L : ℝ} + (hD : Tendsto (fun z : ℝ => projectionD J (Polynomial.X * e) z) atTop (𝓝 L)) : + ∀ z : ℝ, 0 < z → projectionD J (Polynomial.X * e) z = J.eval 0 + + (Real.sqrt 2 / Real.pi) * z * realStieltjes (-1) + (fun x => e.eval (-x) * omega x) z := by + obtain ⟨R, hR⟩ := polynomial_mul_realStieltjes (a := (-1 : ℝ)) integrableOn_omega_projection e + let v : ℝ → ℝ := fun x => e.eval (-x) * omega x + let S : Polynomial ℝ := J + Polynomial.C (Real.sqrt 2 * Real.cos (Real.pi / 8)) * + (Polynomial.X * e) + Polynomial.C (Real.sqrt 2 / Real.pi) * (Polynomial.X * R) + have hv : IntegrableOn v (Ioo (0 : ℝ) 1) := by + simpa only [neg_one_mul] using integrableOn_polynomial_weight (a := (-1 : ℝ)) + integrableOn_omega_projection e + have hEq : ∀ z : ℝ, 0 < z → projectionD J (Polynomial.X * e) z = S.eval z + + (Real.sqrt 2 / Real.pi) * z * realStieltjes (-1) v z := by + intro z hz + have hl := stieltjes_lBranch hz + have he := hR z (offCut_neg_one_pos hz) + simp only [neg_one_mul] at he + change e.eval z * realStieltjes (-1) omega z = realStieltjes (-1) v z + R.eval z at he + have ht : (∫ x in Ioo (0 : ℝ) 1, omega x / (x + z)) = realStieltjes (-1) omega z := by + simp [realStieltjes, add_comm] + rw [ht] at hl + simp only [projectionD, Polynomial.eval_mul, Polynomial.eval_X, hl, S, + Polynomial.eval_add, Polynomial.eval_C] + linear_combination (Real.sqrt 2 / Real.pi) * z * he + have hnorm : Tendsto (fun z : ℝ => ‖z‖) atTop atTop := tendsto_norm_atTop_atTop + have hzT : Tendsto (fun z : ℝ => z * realStieltjes (-1) v z) atTop + (𝓝 (∫ x in Ioo (0 : ℝ) 1, v x)) := by + have hweight : IntegrableOn (fun x => (-1 : ℝ) * x * v x) (Ioo (0 : ℝ) 1) := + integrableOn_continuous_mul hv (continuous_const.mul continuous_id).continuousOn + have ht := (tendsto_realStieltjes_zero hweight (by norm_num : |(-1 : ℝ)| ≤ 1) hnorm).add_const + (∫ x in Ioo (0 : ℝ) 1, v x) + have ht' : Tendsto (fun z : ℝ => realStieltjes (-1) (fun x => (-1 : ℝ) * x * v x) z + + ∫ x in Ioo (0 : ℝ) 1, v x) atTop (𝓝 (∫ x in Ioo (0 : ℝ) 1, v x)) := by + simpa only [zero_add] using ht + apply ht'.congr' + filter_upwards [eventually_gt_atTop (0 : ℝ)] with z hz + exact (realStieltjes_mul_variable hv (offCut_neg_one_pos hz)).symm + have hSlim : Tendsto (fun z : ℝ => S.eval z) atTop + (𝓝 (L - (Real.sqrt 2 / Real.pi) * ∫ x in Ioo (0 : ℝ) 1, v x)) := by + apply (hD.sub (hzT.const_mul (Real.sqrt 2 / Real.pi))).congr' + filter_upwards [eventually_gt_atTop (0 : ℝ)] with z hz + rw [hEq z hz] + ring + have hS := polynomial_constant_of_limit hnorm S hSlim + have hS0 : S.eval 0 = J.eval 0 := by simp [S] + have hSc : ∀ z : ℝ, S.eval z = J.eval 0 := by + intro z + calc S.eval z = S.eval 0 := by rw [hS]; simp + _ = J.eval 0 := hS0 + intro z hz + simpa only [hSc] using hEq z hz + +end + + + +noncomputable section +open Polynomial Set Filter +open scoped Topology + + +def tildePoly (N : ℕ) (p : Polynomial ℝ) : Polynomial ℝ := + reflect N (p.comp (Polynomial.C (1 / 8) * (1 + X))) + +theorem affine_natDegree : + (Polynomial.C (1 / 8 : ℝ) * (1 + X)).natDegree = 1 := by + compute_degree + norm_num + +theorem affine_leadingCoeff : + (Polynomial.C (1 / 8 : ℝ) * (1 + X)).leadingCoeff = 1 / 8 := by + rw [leadingCoeff, affine_natDegree] + norm_num [coeff_C_mul, coeff_add, coeff_one] + +theorem tildePoly_natDegree_le (N : ℕ) {p : Polynomial ℝ} (hp : p.natDegree ≤ N) : + (tildePoly N p).natDegree ≤ N := by + apply le_trans natDegree_reflect_le + rw [natDegree_comp, affine_natDegree, mul_one, max_eq_left hp] + +theorem tildePoly_eval (N : ℕ) {p : Polynomial ℝ} (hp : p.natDegree ≤ N) + {z : ℝ} (hz : z ≠ 0) : + (tildePoly N p).eval z = z ^ N * p.eval ((1 + 1 / z) / 8) := by + let : Invertible z⁻¹ := invertibleOfNonzero (inv_ne_zero hz) + have hdeg : (p.comp (Polynomial.C (1 / 8) * (1 + X))).natDegree ≤ N := by + rw [natDegree_comp, affine_natDegree, mul_one] + exact hp + have h := eval₂_reflect_mul_pow (RingHom.id ℝ) z⁻¹ N + (p.comp (Polynomial.C (1 / 8) * (1 + X))) hdeg + simp only [invOf_eq_inv, inv_inv, eval₂_id, eval_comp, eval_mul, eval_C, eval_add, + eval_one, eval_X] at h + change (tildePoly N p).eval z * (z⁻¹) ^ N = p.eval ((1 / 8) * (1 + z⁻¹)) at h + have heq : (1 / 8 : ℝ) * (1 + z⁻¹) = (1 + 1 / z) / 8 := by ring + rw [heq] at h + have h' := congrArg (fun x : ℝ => x * z ^ N) h + rw [mul_assoc, ← mul_pow, inv_mul_cancel₀ hz, one_pow, mul_one] at h' + exact h'.trans (mul_comm _ _) + +theorem tildePoly_eq_zero_iff (N : ℕ) (p : Polynomial ℝ) : tildePoly N p = 0 ↔ p = 0 := by + rw [tildePoly, reflect_eq_zero_iff] + rw [comp_eq_zero_iff] + constructor + · intro h + rcases h with h | ⟨_, h⟩ + · exact h + · have hd := congrArg Polynomial.natDegree h + rw [affine_natDegree, natDegree_C] at hd + contradiction + · exact Or.inl + +theorem tildePoly_zero_of_degree_lt (N : ℕ) {p : Polynomial ℝ} + (hp : p.degree < (N : WithBot ℕ)) : (tildePoly N p).eval 0 = 0 := by + rw [← coeff_zero_eq_eval_zero, tildePoly, coeff_reflect, revAt_zero] + apply coeff_eq_zero_of_degree_lt + have hq : (Polynomial.C (1 / 8 : ℝ) * (1 + X)).degree = 1 := by + rw [degree_eq_natDegree (p := Polynomial.C (1 / 8 : ℝ) * (1 + X)) (by + intro h; have hd := affine_natDegree; rw [h, natDegree_zero] at hd; contradiction), + affine_natDegree] + rfl + rw [degree_comp (by rw [hq]; norm_num), hq, mul_one] + exact hp + + +def highBranch (u : ℝ) : ℝ := Real.sqrt ((1 + Real.sqrt ((1 - u) / 2)) / 2) +def lowBranch (u : ℝ) : ℝ := Real.sqrt ((1 - Real.sqrt ((1 - u) / 2)) / 2) + +theorem sqrt_half : Real.sqrt (1 / 2 : ℝ) = Real.sqrt 2 / 2 := by + have h1 := Real.sq_sqrt (by norm_num : (0 : ℝ) ≤ 1 / 2) + have h2 := Real.sq_sqrt (by norm_num : (0 : ℝ) ≤ 2) + have hn1 := Real.sqrt_nonneg (1 / 2 : ℝ) + have hn2 := Real.sqrt_nonneg (2 : ℝ) + nlinarith + +theorem sqrt_two_lt_two : Real.sqrt 2 < 2 := by + have h := Real.sq_sqrt (by norm_num : (0 : ℝ) ≤ 2) + have hn := Real.sqrt_nonneg (2 : ℝ) + nlinarith + +theorem highBranch_zero : highBranch 0 = C := by + rw [C, lambda, Real.cos_pi_div_eight] + unfold highBranch + simp only [sub_zero, sqrt_half] + have ha := Real.sq_sqrt (by positivity : (0 : ℝ) ≤ (1 + Real.sqrt 2 / 2) / 2) + have hb := Real.sq_sqrt (by positivity : (0 : ℝ) ≤ 2 + Real.sqrt 2) + have hna := Real.sqrt_nonneg ((1 + Real.sqrt 2 / 2) / 2) + have hnb := Real.sqrt_nonneg (2 + Real.sqrt 2) + nlinarith + +theorem lowBranch_zero : lowBranch 0 = c := by + have hc : c = Real.sin (Real.pi / 8) := by + rw [c, show 3 * Real.pi / 8 = Real.pi / 2 - Real.pi / 8 by ring, Real.cos_pi_div_two_sub] + rw [hc, Real.sin_pi_div_eight] + unfold lowBranch + simp only [sub_zero, sqrt_half] + have ha := Real.sq_sqrt (show (0 : ℝ) ≤ (1 - Real.sqrt 2 / 2) / 2 by linarith [sqrt_two_lt_two]) + have hb := Real.sq_sqrt (show (0 : ℝ) ≤ 2 - Real.sqrt 2 by linarith [sqrt_two_lt_two]) + have hna := Real.sqrt_nonneg ((1 - Real.sqrt 2 / 2) / 2) + have hnb := Real.sqrt_nonneg (2 - Real.sqrt 2) + nlinarith + +theorem highBranch_continuous : Continuous highBranch := by unfold highBranch; fun_prop +theorem lowBranch_continuous : Continuous lowBranch := by unfold lowBranch; fun_prop + +theorem branches_sq {u : ℝ} (hu : u ∈ Ioo (-1 : ℝ) 1) : + highBranch u ^ 2 = (1 + Real.sqrt ((1 - u) / 2)) / 2 ∧ + lowBranch u ^ 2 = (1 - Real.sqrt ((1 - u) / 2)) / 2 ∧ + Real.sqrt ((1 - u) / 2) ^ 2 = (1 - u) / 2 := by + have hd : 0 ≤ (1 - u) / 2 := by linarith [hu.2] + have hs := Real.sq_sqrt hd + have hn := Real.sqrt_nonneg ((1 - u) / 2) + have hlt : Real.sqrt ((1 - u) / 2) < 1 := by nlinarith [hu.1] + exact ⟨Real.sq_sqrt (by positivity), Real.sq_sqrt (by linarith), hs⟩ + +theorem branches_harmonic {u : ℝ} (hu : u ∈ Ioo (-1 : ℝ) 1) : + harmonicCoordinate.eval (highBranch u) = (1 + u) / 8 ∧ + harmonicCoordinate.eval (lowBranch u) = (1 + u) / 8 := by + obtain ⟨hh, hl, hs⟩ := branches_sq hu + simp only [harmonicCoordinate, eval_mul, eval_pow, eval_X, eval_sub, eval_one] + constructor <;> nlinarith + +theorem branches_sum {u : ℝ} (hu : u ∈ Ioo (-1 : ℝ) 1) : + highBranch u + lowBranch u = Real.sqrt (1 + Real.sqrt ((1 + u) / 2)) := by + obtain ⟨hh, hl, hs⟩ := branches_sq hu + have ha : 0 ≤ highBranch u := Real.sqrt_nonneg _ + have hb : 0 ≤ lowBranch u := Real.sqrt_nonneg _ + have hs' := Real.sq_sqrt (show 0 ≤ (1 + u) / 2 by linarith [hu.1]) + have hn' := Real.sqrt_nonneg ((1 + u) / 2) + have hp : 2 * highBranch u * lowBranch u = Real.sqrt ((1 + u) / 2) := by + have hprod : (highBranch u * lowBranch u) ^ 2 = (1 + u) / 8 := by + rw [mul_pow, hh, hl] + nlinarith + nlinarith [mul_nonneg ha hb] + have hsq := Real.sq_sqrt (show 0 ≤ 1 + Real.sqrt ((1 + u) / 2) by positivity) + have hn := Real.sqrt_nonneg (1 + Real.sqrt ((1 + u) / 2)) + nlinarith + +end +end CriticalStrip + +end OAI diff --git a/lean/OAI/Combinatorics/StripMass/SwapVacancy.lean b/lean/OAI/Combinatorics/StripMass/SwapVacancy.lean new file mode 100644 index 0000000000000000000000000000000000000000..f9c9a994e1fbde2fa7cdea4c876e98fbd7af7c32 --- /dev/null +++ b/lean/OAI/Combinatorics/StripMass/SwapVacancy.lean @@ -0,0 +1,590 @@ +import Mathlib +import OAI.Combinatorics.StripMass.LocalPadding + +namespace OAI + +/-! Critical honeycomb strip paths, polynomial identities and crossing mass. -/ + + + +namespace CriticalStrip.Diagram +noncomputable section +open scoped Classical +open Finset +namespace Pairing + +lemma map_not_occupied_omit {n : ℕ} (p : Pairing n) (a : Fin (n+1)) : + ¬(p.map (Fin.succAboveOrderEmb a)).Occupied a := by + rintro ⟨_,h⟩ + obtain ⟨i,j,_,hi,_⟩ := (map_adj _ p _ _).mp h + exact Fin.succAbove_ne a i hi + +lemma moveIntoVacancy_eq_self {n : ℕ} (p : Pairing n) (a b : Fin n) + (hab : a.val+1=b.val) (ha : ¬p.Occupied a) (hb : ¬p.Occupied b) : + p.moveIntoVacancy a b hab hb=p := by + apply ext_adj + intro i j + rw [moveIntoVacancy_adj] + have hn (x y : Fin n) (h : p.Adj x y) : Equiv.swap a b x=x := by + apply Equiv.swap_apply_of_ne_of_ne + · intro he; exact ha ⟨y,he ▸ h⟩ + · intro he; exact hb ⟨y,he ▸ h⟩ + constructor + · intro h + have hi := hn _ _ h + have hj := hn _ _ (adj_symm h) + simp only [Equiv.swap_apply_self] at hi hj + rwa [←hi,←hj] at h + · intro h + rw [hn _ _ h,hn _ _ (adj_symm h)] + exact h + +lemma moveIntoVacancy_map_omit {n : ℕ} (p : Pairing n) (a b : Fin (n+1)) + (hab : a.val+1=b.val) : + (p.map (Fin.succAboveOrderEmb b)).moveIntoVacancy a b hab (p.map_not_occupied_omit b)= + p.map (Fin.succAboveOrderEmb a) := by + apply ext_adj + intro x y + rw [moveIntoVacancy_adj,map_adj,map_adj] + constructor + · rintro ⟨i,j,h,hi,hj⟩ + refine ⟨i,j,h,?_,?_⟩ + · have hh:=congrArg (Equiv.swap a b) hi + simpa only [Fin.succAboveOrderEmb_apply,Fin.swap_succAbove_adjacent a b hab, + Equiv.swap_apply_self] using hh + · have hh:=congrArg (Equiv.swap a b) hj + simpa only [Fin.succAboveOrderEmb_apply,Fin.swap_succAbove_adjacent a b hab, + Equiv.swap_apply_self] using hh + · rintro ⟨i,j,h,hi,hj⟩ + refine ⟨i,j,h,?_,?_⟩ + · have hh:=congrArg (Equiv.swap a b) hi + simp only [Fin.succAboveOrderEmb_apply] at hh + rw [←Fin.swap_succAbove_adjacent a b hab i,Equiv.swap_apply_self] at hh + exact hh + · have hh:=congrArg (Equiv.swap a b) hj + simp only [Fin.succAboveOrderEmb_apply] at hh + rw [←Fin.swap_succAbove_adjacent a b hab j,Equiv.swap_apply_self] at hh + exact hh +end Pairing + +variable {K : Type*} [CommRing K] +lemma localR_swap_vacant {n : ℕ} (a : Position n) (p q : Pairing n) + (hb : ¬p.Occupied a.right) : + (localR a (swapWeights : Weights K)) q p = + if p.moveIntoVacancy a.left a.right a.adjacent hb=q then 1 else 0 := by + simp only [localR,Matrix.sum_apply,Matrix.smul_apply,smul_eq_mul] + by_cases ha : p.Occupied a.left + · rw [sum_eq_single .diagonal₀] + · simp [swapWeights,Weights.tile,optionMatrix,Pairing.tileStep,ha,hb] + · intro t _ ht + cases t <;> simp_all [swapWeights,Weights.tile,optionMatrix,Pairing.tileStep] + · simp + · rw [Pairing.moveIntoVacancy_eq_self p _ _ a.adjacent ha hb] + rw [sum_eq_single .vacant] + · simp [Weights.tile,optionMatrix,Pairing.tileStep,ha,hb] + · intro t _ ht + cases t <;> simp_all [swapWeights,Weights.tile,optionMatrix,Pairing.tileStep] + · simp + +lemma localR_swap_omit {n : ℕ} (a : Position (n+1)) : + localR a (swapWeights : Weights K) * + functionMatrix (K:=K) (Pairing.map (Fin.succAboveOrderEmb a.right)) = + functionMatrix (K:=K) (Pairing.map (Fin.succAboveOrderEmb a.left)) := by + ext q p + rw [mul_functionMatrix,localR_swap_vacant _ _ _ (p.map_not_occupied_omit a.right), + Pairing.moveIntoVacancy_map_omit] + simp [functionMatrix,optionMatrix] + +end + + + + + +noncomputable section +open scoped Classical +namespace PartialColumn +variable {K : Type*} [CommRing K] {n : ℕ} + +lemma insert_before_gate (r : Fin (n+1)) (w : Fin (n+1) → Weights K) + (v : Fin n → Weights K) (hw : ∀ i, w (r.succAbove i)=v i) (i : Fin n) (hi : i.val change 1*_=_*1; simp + | succ k ih => + have hkn : k + rw [program,Program.matrix] + have hrr : (⟨r.val,by omega⟩ : Fin (n+1))=r := Fin.ext rfl + rw [hrr] + rw [Matrix.mul_assoc,insert_before_program r w v hw r.val le_rfl,←Matrix.mul_assoc,hr] + have hs := localR_swap_omit (K:=K) (position r) + change localR (position r) swapWeights * + functionMatrix (K:=K) (Pairing.map (Fin.succAboveOrderEmb r.succ)) = + functionMatrix (K:=K) (Pairing.map (Fin.succAboveOrderEmb r.castSucc)) at hs + rw [hs] + | succ k hk ih => + have hi : k simp [Fin.succAbove,Fin.lt_def,hi] + +lemma omit_padTop {n : ℕ} (r : Fin (n+1)) (p : Pairing n) : + (p.map (Fin.succAboveOrderEmb r)).padTop = + p.padTop.map (Fin.succAboveOrderEmb r.castSucc) := by + unfold padTop + rw [map_map,map_map] + congr 1 + apply DFunLike.ext + intro i + change (r.succAbove i).castSucc=r.castSucc.succAbove i.castSucc + by_cases hi : i.val simp [Fin.succAbove,Fin.lt_def,hi] + +lemma omit_last {n : ℕ} (r : Fin (n+1)) : + (Fin.succAboveOrderEmb r.castSucc) (Fin.last n)=Fin.last (n+1) := by + change r.castSucc.succAbove (Fin.last n)=Fin.last (n+1) + rw [Fin.succAbove_of_le_castSucc _ _ (by change r.val≤n; omega)] + rfl + +lemma omit_eq_padTop_exists {n : ℕ} (r : Fin (n+1)) (t : Pairing (n+1)) + (q : Pairing (n+1)) (h : t.map (Fin.succAboveOrderEmb r.castSucc)=q.padTop) : + ∃ p : Pairing n, p.padTop=t := by + apply Exists.intro (t.restrict Fin.castSuccOrderEmb) + apply padTop_restrict + intro ht + have hh : (t.map (Fin.succAboveOrderEmb r.castSucc)).Occupied (Fin.last (n+1)) := by + rw [←omit_last r] + exact (map_occupied _ t _).mpr ht + rw [h] at hh + exact q.padTop_not_occupied_last hh + +end Pairing +end + + + + + +noncomputable section +open scoped Classical +open Finset +namespace PartialColumn +variable {K : Type*} [CommRing K] {n : ℕ} + +lemma program_column_all (w : Fin n → Weights K) (p q : Pairing n) : + (program w n le_rfl).matrix q.padTop p.padBottom=column w q p := by + by_cases hn : 0 M q.padTop p.padBottom) H + rw [mul_functionMatrix,←Pairing.omit_padBottom,program_column_all,omit_top_matrix,he] at hh + rw [mul_functionMatrix] + exact hh + +end PartialColumn +end + + + + + +noncomputable section +open scoped Classical +namespace PartialColumn +variable {n m : ℕ} + + +def twoRows {K : Type*} (w : Fin n → Weights K) (r : ℕ) (a b : Weights K) : Fin n → Weights K := + fun i => if i.val=r then a else if i.val=r+1 then b else w i + +lemma twoRows₀ {K : Type*} (w : Fin n → Weights K) (r : ℕ) (hr : r+2≤n) (a b : Weights K) : + twoRows w r a b ⟨r,by omega⟩=a := by simp [twoRows] +lemma twoRows₁ {K : Type*} (w : Fin n → Weights K) (r : ℕ) (hr : r+2≤n) (a b : Weights K) : + twoRows w r a b ⟨r+1,by omega⟩=b := by simp [twoRows] +lemma twoRows_other {K : Type*} (w : Fin n → Weights K) (r : ℕ) (a b : Weights K) + (i : Fin n) (hi : i.val≠r) (hj : i.val≠r+1) : w i=twoRows w r a b i := by simp [twoRows,hi,hj] + + + +theorem column_merge_intertwiner (r : ℕ) (hr : r+2≤n+1) + (w : Fin (n+1) → Weights (SpectralField m)) (z : SpectralField m) + (hz : z≠0) (hL : torusL z≠0) (hL1 : torusL (constF m phase*z)≠0) + (hL2 : torusL (constF m phase^2*z)≠0) + (hw₀ : w ⟨r,by omega⟩=torusWeights (constF m phase^2*z)) + (hw₁ : w ⟨r+1,by omega⟩=torusWeights z) : + let j : Fin (n+1) := ⟨r+1,by omega⟩ + let v := twoRows w r (torusWeights (constF m phase*z)) swapWeights + let E := functionMatrix (K:=SpectralField m) (Pairing.map (Fin.succAboveOrderEmb j)) + let S := localR (rowPosition r hr) (mergeWeights (constF m phase)) + column w * (S*E) = (S*E) * column (fun i => v (j.succAbove i)) := by + dsimp only + let j : Fin (n+1) := ⟨r+1,by omega⟩ + let v := twoRows w r (torusWeights (constF m phase*z)) swapWeights + let E := functionMatrix (K:=SpectralField m) (Pairing.map (Fin.succAboveOrderEmb j)) + let S := localR (rowPosition r hr) (mergeWeights (constF m phase)) + change column w*(S*E)=(S*E)*column (fun i => v (j.succAbove i)) + have hpass := column_insert_swap j v (fun i => v (j.succAbove i)) (fun _ => rfl) + (twoRows₁ w r hr _ _) + have htrain : (column w*S)*E=(S*column v)*E := by + ext q p + rw [mul_functionMatrix,mul_functionMatrix] + apply column_merge r hr w v z hz hL hL1 hL2 hw₀ hw₁ + (twoRows₀ w r hr _ _) (twoRows₁ w r hr _ _) (twoRows_other w r _ _) + exact p.map_not_occupied_omit j + rw [←Matrix.mul_assoc,htrain,Matrix.mul_assoc,hpass,←Matrix.mul_assoc] + + +theorem column_deletion_intertwiner (r : ℕ) (hr : r+2≤n+2) + (w : Fin (n+2) → Weights (SpectralField m)) (z : SpectralField m) + (hz : z≠0) (hL : torusL z≠0) (hL3 : torusL (constF m phase^3*z)≠0) + (hw₀ : w ⟨r,by omega⟩=torusWeights (constF m phase^3*z)) + (hw₁ : w ⟨r+1,by omega⟩=torusWeights z) : + let j : Fin (n+2) := ⟨r+1,by omega⟩ + let k : Fin (n+1) := ⟨r,by omega⟩ + let v := twoRows w r swapWeights swapWeights + let ER := functionMatrix (K:=SpectralField m) (Pairing.map (Fin.succAboveOrderEmb j)) + let EL := functionMatrix (K:=SpectralField m) (Pairing.map (Fin.succAboveOrderEmb k)) + let S : Matrix (Pairing (n+2)) (Pairing (n+2)) (SpectralField m) := localR (rowPosition r hr) deletionWeights + (column w * (S*(ER*EL)) : Matrix (Pairing (n+2)) (Pairing n) (SpectralField m)) = (S*(ER*EL)) * column (fun i => v (j.succAbove (k.succAbove i))) := by + dsimp only + let j : Fin (n+2) := ⟨r+1,by omega⟩ + let k : Fin (n+1) := ⟨r,by omega⟩ + let v := twoRows w r swapWeights swapWeights + let ER := functionMatrix (K:=SpectralField m) (Pairing.map (Fin.succAboveOrderEmb j)) + let EL := functionMatrix (K:=SpectralField m) (Pairing.map (Fin.succAboveOrderEmb k)) + let S : Matrix (Pairing (n+2)) (Pairing (n+2)) (SpectralField m) := localR (rowPosition r hr) deletionWeights + change column w*(S*(ER*EL))=(S*(ER*EL))*column (fun i => v (j.succAbove (k.succAbove i))) + have hjk : j.succAbove k=⟨r,by omega⟩ := by + rw [Fin.succAbove_of_castSucc_lt] + · rfl + · change r v (j.succAbove i)) (fun _ => rfl) + (twoRows₁ w r hr _ _) + have hpassL := column_insert_swap k (fun i => v (j.succAbove i)) + (fun i => v (j.succAbove (k.succAbove i))) (fun _ => rfl) + (by rw [hjk]; exact twoRows₀ w r hr _ _) + have htrain : (column w*S)*(ER*EL)=(S*column v)*(ER*EL) := by + ext q p + rw [←Matrix.mul_assoc,←Matrix.mul_assoc,mul_functionMatrix,mul_functionMatrix, + mul_functionMatrix,mul_functionMatrix] + apply column_deletion r hr w v z hz hL hL3 hw₀ hw₁ + (twoRows₀ w r hr _ _) (twoRows₁ w r hr _ _) (twoRows_other w r _ _) + · rw [←hjk] + exact fun h => p.map_not_occupied_omit k ((Pairing.map_occupied _ _ _).mp h) + · exact (p.map (Fin.succAboveOrderEmb k)).map_not_occupied_omit j + rw [←Matrix.mul_assoc,htrain] + simp only [Matrix.mul_assoc] + rw [←Matrix.mul_assoc (column v) ER EL,hpassR,Matrix.mul_assoc,hpassL] + +end PartialColumn +end + + + + + +noncomputable section +open scoped Classical +open Finset + +lemma Pairing.tileStep_empty_iff {n : ℕ} (p : Pairing n) (a b : Fin n) + (hab : a.val+1=b.val) (t : Tile) : + p.tileStep a b hab t=some (empty n) ↔ p=empty n ∧ t=.vacant := by + constructor + · intro h + have hg:=p.stepWiring_realizes a b hab t (empty n) h + have hp : p=empty n := by + apply (Pairing.eq_empty_iff p).mpr + rintro i ⟨j,hij⟩ + obtain ⟨k,hk,_⟩ := hg.no_loop (.old i) (.old j) hij + exact empty_not_occupied k hk + have ht : t=.vacant := by + apply (Tile.eq_vacant_iff t).mpr + rintro i ⟨j,hij⟩ + obtain ⟨k,hk,_⟩ := hg.no_loop (.box i) (.box j) hij + exact empty_not_occupied k hk + exact ⟨hp,ht⟩ + · rintro ⟨rfl,rfl⟩ + simp [Pairing.tileStep] + +lemma localR_empty_row {K : Type*} [CommRing K] {n : ℕ} (a : Position n) (w : Weights K) + (p : Pairing n) : localR a w (empty n) p=if p=empty n then 1 else 0 := by + unfold localR + simp only [Matrix.sum_apply,Matrix.smul_apply,optionMatrix,Pairing.tileStep_empty_iff] + by_cases hp : p=empty n + · simp [hp,Weights.tile] + · simp [hp] + +lemma localR_mulVec_empty {K : Type*} [CommRing K] {n : ℕ} (a : Position n) (w : Weights K) + (v : Pairing n → K) : (localR a w).mulVec v (empty n)=v (empty n) := by + simp [Matrix.mulVec,dotProduct,localR_empty_row] + + + +theorem normalizedVacuum_torus_exchange {n m : ℕ} (r : ℕ) (hr : r+2≤n) + (x : Fin n → SpectralField m) (z : SpectralField m) (hz : z≠0) + (hw : x ⟨r+1,by omega⟩≠0) (hLz : torusL z≠0) + (hLw : torusL (x ⟨r+1,by omega⟩)≠0) (hLx : torusL (x ⟨r,by omega⟩)≠0) + (hx : z*x ⟨r+1,by omega⟩=x ⟨r,by omega⟩) + (hreg : VacuumRegular (fun i => torusWeights (x i))) + (hreg' : VacuumRegular (fun i => torusWeights (x (Equiv.swap ⟨r,by omega⟩ ⟨r+1,by omega⟩ i)))) : + normalizedVacuum (fun i => torusWeights (x i)) = + (localR (PartialColumn.rowPosition r hr) (torusWeights z)).mulVec + (normalizedVacuum (fun i => torusWeights (x (Equiv.swap ⟨r,by omega⟩ ⟨r+1,by omega⟩ i)))) := by + symm + apply normalizedVacuum_unique _ hreg + have hs := normalizedVacuum_stationary _ hreg' + constructor + · rw [localR_mulVec_empty]; exact hs.1 + · rw [Matrix.mulVec_mulVec,PartialColumn.torus_column_exchange r hr x z hz hw hLz hLw hLx hx, + ←Matrix.mulVec_mulVec,hs.2] + + + + + + + +lemma Pairing.map_eq_empty_iff {n m : ℕ} (e : Fin n ↪o Fin m) (p : Pairing n) : + p.map e=empty m ↔ p=empty n := by + rw [←Pairing.map_empty e] + exact (Pairing.map_injective e).eq_iff + +lemma functionMatrix_map_mulVec_empty {K : Type*} [CommRing K] {n m : ℕ} + (e : Fin n ↪o Fin m) (v : Pairing n → K) : + (functionMatrix (K:=K) (Pairing.map e)).mulVec v (empty m)=v (empty n) := by + simp [Matrix.mulVec,dotProduct,functionMatrix,optionMatrix,Pairing.map_eq_empty_iff] + + +def mergeMap {n m : ℕ} (r : ℕ) (hr : r+2≤n+1) : + Matrix (Pairing (n+1)) (Pairing n) (SpectralField m) := + localR (PartialColumn.rowPosition r hr) (mergeWeights (constF m phase)) * + functionMatrix (Pairing.map (Fin.succAboveOrderEmb ⟨r+1,by omega⟩)) + + +def deletionMap {n m : ℕ} (r : ℕ) (hr : r+2≤n+2) : + Matrix (Pairing (n+2)) (Pairing n) (SpectralField m) := + localR (PartialColumn.rowPosition r hr) deletionWeights * + (functionMatrix (Pairing.map (Fin.succAboveOrderEmb (⟨r+1,by omega⟩ : Fin (n+2)))) * + functionMatrix (Pairing.map (Fin.succAboveOrderEmb (⟨r,by omega⟩ : Fin (n+1))))) + +lemma mergeMap_mulVec_empty {n m : ℕ} (r : ℕ) (hr : r+2≤n+1) + (v : Pairing n → SpectralField m) : + (mergeMap r hr).mulVec v (empty (n+1))=v (empty n) := by + simp only [mergeMap] + let E : Matrix (Pairing (n+1)) (Pairing n) (SpectralField m) := + functionMatrix (Pairing.map (Fin.succAboveOrderEmb ⟨r+1,by omega⟩)) + let S := localR (PartialColumn.rowPosition r hr) (mergeWeights (constF m phase)) + calc + _ = S.mulVec (E.mulVec v) (empty (n+1)) := + congrFun (Matrix.mulVec_mulVec v S E).symm _ + _ = E.mulVec v (empty (n+1)) := localR_mulVec_empty _ _ _ + _ = _ := functionMatrix_map_mulVec_empty _ _ +lemma deletionMap_mulVec_empty {n m : ℕ} (r : ℕ) (hr : r+2≤n+2) + (v : Pairing n → SpectralField m) : + (deletionMap r hr).mulVec v (empty (n+2))=v (empty n) := by + simp only [deletionMap] + let E₁ : Matrix (Pairing (n+2)) (Pairing (n+1)) (SpectralField m) := + functionMatrix (Pairing.map (Fin.succAboveOrderEmb ⟨r+1,by omega⟩)) + let E₀ : Matrix (Pairing (n+1)) (Pairing n) (SpectralField m) := + functionMatrix (Pairing.map (Fin.succAboveOrderEmb ⟨r,by omega⟩)) + let S := localR (PartialColumn.rowPosition r hr) (deletionWeights : Weights (SpectralField m)) + calc + _ = S.mulVec ((E₁*E₀).mulVec v) (empty (n+2)) := + congrFun (Matrix.mulVec_mulVec v S (E₁*E₀)).symm _ + _ = (E₁*E₀).mulVec v (empty (n+2)) := localR_mulVec_empty _ _ _ + _ = E₁.mulVec (E₀.mulVec v) (empty (n+2)) := + congrFun (Matrix.mulVec_mulVec v E₁ E₀).symm _ + _ = E₀.mulVec v (empty (n+1)) := functionMatrix_map_mulVec_empty _ _ + _ = _ := functionMatrix_map_mulVec_empty _ _ + + +theorem normalizedVacuum_merge {n m : ℕ} (r : ℕ) (hr : r+2≤n+1) + (w : Fin (n+1) → Weights (SpectralField m)) (z : SpectralField m) + (hz : z≠0) (hL : torusL z≠0) (hL1 : torusL (constF m phase*z)≠0) + (hL2 : torusL (constF m phase^2*z)≠0) + (hw₀ : w ⟨r,by omega⟩=torusWeights (constF m phase^2*z)) + (hw₁ : w ⟨r+1,by omega⟩=torusWeights z) + (hreg : VacuumRegular w) + (hreg' : VacuumRegular (fun i => (PartialColumn.twoRows w r + (torusWeights (constF m phase*z)) swapWeights) ((⟨r+1,by omega⟩ : Fin (n+1)).succAbove i))) : + normalizedVacuum w = (mergeMap r hr).mulVec (normalizedVacuum + (fun i => (PartialColumn.twoRows w r (torusWeights (constF m phase*z)) swapWeights) + ((⟨r+1,by omega⟩ : Fin (n+1)).succAbove i))) := by + symm + apply normalizedVacuum_unique _ hreg + have hs:=normalizedVacuum_stationary _ hreg' + constructor + · rw [mergeMap_mulVec_empty]; exact hs.1 + · have he := PartialColumn.column_merge_intertwiner r hr w z hz hL hL1 hL2 hw₀ hw₁ + change column w*mergeMap r hr = mergeMap r hr*column _ at he + rw [Matrix.mulVec_mulVec,he,←Matrix.mulVec_mulVec,hs.2] + +theorem normalizedVacuum_deletion {n m : ℕ} (r : ℕ) (hr : r+2≤n+2) + (w : Fin (n+2) → Weights (SpectralField m)) (z : SpectralField m) + (hz : z≠0) (hL : torusL z≠0) (hL3 : torusL (constF m phase^3*z)≠0) + (hw₀ : w ⟨r,by omega⟩=torusWeights (constF m phase^3*z)) + (hw₁ : w ⟨r+1,by omega⟩=torusWeights z) + (hreg : VacuumRegular w) + (hreg' : VacuumRegular (fun i => w ((⟨r+1,by omega⟩ : Fin (n+2)).succAbove + ((⟨r,by omega⟩ : Fin (n+1)).succAbove i)))) : + normalizedVacuum w = (deletionMap r hr).mulVec (normalizedVacuum + (fun i => w ((⟨r+1,by omega⟩ : Fin (n+2)).succAbove + ((⟨r,by omega⟩ : Fin (n+1)).succAbove i)))) := by + let j : Fin (n+2) := ⟨r+1,by omega⟩ + let k : Fin (n+1) := ⟨r,by omega⟩ + have hrows : (fun i => (PartialColumn.twoRows w r swapWeights swapWeights) + (j.succAbove (k.succAbove i)))=(fun i => w (j.succAbove (k.succAbove i))) := by + funext i + symm + apply PartialColumn.twoRows_other + · intro h + have hk:=Fin.succAbove_ne k i + apply hk + have hjk : j.succAbove k=⟨r,by omega⟩ := by + rw [Fin.succAbove_of_castSucc_lt] + · rfl + · change r Fin.succAbove_ne j (k.succAbove i) (Fin.ext h) + have he := PartialColumn.column_deletion_intertwiner r hr w z hz hL hL3 hw₀ hw₁ + change column w*deletionMap r hr=deletionMap r hr*column _ at he + rw [hrows] at he + symm + apply normalizedVacuum_unique _ hreg + have hs:=normalizedVacuum_stationary _ hreg' + constructor + · rw [deletionMap_mulVec_empty]; exact hs.1 + · rw [Matrix.mulVec_mulVec,he,←Matrix.mulVec_mulVec,hs.2] + +end +end CriticalStrip.Diagram + +end OAI diff --git a/lean/OAI/Combinatorics/StripMass/TailIntegrals.lean b/lean/OAI/Combinatorics/StripMass/TailIntegrals.lean new file mode 100644 index 0000000000000000000000000000000000000000..2321ef2b6849b6caff7260384359a6478fd44613 --- /dev/null +++ b/lean/OAI/Combinatorics/StripMass/TailIntegrals.lean @@ -0,0 +1,426 @@ +import Mathlib +import OAI.Combinatorics.StripMass.ColumnGeometry + +namespace OAI + +/-! Critical honeycomb strip paths, polynomial identities and crossing mass. -/ + + +namespace CriticalStrip +noncomputable section +open scoped BigOperators ENNReal +open Set MeasureTheory +theorem integral_le_of_power_tail {α : Type*} [MeasurableSpace α] + {μ : Measure α} [IsProbabilityMeasure μ] {f : α → ℝ} + (hf : Integrable f μ) (hfn : 0 ≤ᵐ[μ] f) {b q : ℝ} + (hb : 0 < b) (hq : 1 < q) + (htail : ∀ t > b, μ.real {x | t < f x} ≤ b ^ q * t ^ (-q)) : + (∫ x, f x ∂μ) ≤ q / (q - 1) * b := by + let g : ℝ → ℝ := fun t => if t ≤ b then 1 else b ^ q * t ^ (-q) + have hg₁ : IntegrableOn g (Ioc 0 b) := by + apply (integrableOn_const (C := (1 : ℝ)) (by simp)).congr_fun _ measurableSet_Ioc + intro t ht + simp [g, ht.2] + have hg₂ : IntegrableOn g (Ioi b) := by + apply IntegrableOn.congr_fun ((integrableOn_Ioi_rpow_of_lt (by linarith : -q < -1) hb).const_mul (b ^ q)) + _ measurableSet_Ioi + intro t ht + simp [g, not_le.mpr (mem_Ioi.1 ht)] + have hg : IntegrableOn g (Ioi 0) := by + rw [← Ioc_union_Ioi_eq_Ioi hb.le, integrableOn_union] + exact ⟨hg₁, hg₂⟩ + calc + (∫ x, f x ∂μ) = ∫ t in Ioi 0, μ.real {x | t < f x} := hf.integral_eq_integral_meas_lt hfn + _ ≤ ∫ t in Ioi 0, g t := by + apply integral_mono_of_nonneg (Filter.Eventually.of_forall fun _ => ENNReal.toReal_nonneg) hg + filter_upwards with t + change μ.real {x | t < f x} ≤ g t + by_cases ht : t ≤ b + · simpa only [g, ite_eq_left ht] using (measureReal_le_one (μ := μ) (s := {x | t < f x})) + · simpa only [g, ite_eq_right ht] using htail t (lt_of_not_ge ht) + _ = (∫ t in Ioc 0 b, g t) + ∫ t in Ioi b, g t := by + rw [← Ioc_union_Ioi_eq_Ioi hb.le] + exact setIntegral_union (disjoint_left.mpr (fun t ht ht' => (not_lt_of_ge ht.2) ht')) + measurableSet_Ioi hg₁ hg₂ + _ = b + b ^ q * (-b ^ (-q + 1) / (-q + 1)) := by + congr 1 + · calc + (∫ t in Ioc 0 b, g t) = ∫ t in Ioc 0 b, (1 : ℝ) := by + apply setIntegral_congr_fun measurableSet_Ioc + intro t ht + simp [g, ht.2] + _ = b := by simp [hb.le] + · calc + (∫ t in Ioi b, g t) = ∫ t in Ioi b, b ^ q * t ^ (-q) := by + apply setIntegral_congr_fun measurableSet_Ioi + intro t ht + simp [g, not_le.mpr (mem_Ioi.1 ht)] + _ = _ := by rw [integral_const_mul, integral_Ioi_rpow_of_lt (by linarith : -q < -1) hb] + _ = q / (q - 1) * b := by + have he : b ^ q * b ^ (-q + 1) = b := by + rw [← Real.rpow_add hb, show q + (-q + 1) = 1 by ring, Real.rpow_one] + have hq' : q - 1 ≠ 0 := ne_of_gt (by linarith) + rw [← mul_div_assoc, mul_neg, he, show -q + 1 = -(q - 1) by ring] + field_simp + ring + + + +theorem integrable_of_power_tail {α : Type*} [MeasurableSpace α] + {μ : Measure α} [IsProbabilityMeasure μ] {f : α → ℝ} + (hf : AEMeasurable f μ) (hfn : 0 ≤ᵐ[μ] f) {b q : ℝ} + (hb : 0 < b) (hq : 1 < q) + (htail : ∀ t > b, μ.real {x | t < f x} ≤ b ^ q * t ^ (-q)) : + Integrable f μ := by + let g : ℝ → ℝ := fun t => if t ≤ b then 1 else b ^ q * t ^ (-q) + have hg₁ : IntegrableOn g (Ioc 0 b) := by + apply (integrableOn_const (C := (1 : ℝ)) (by simp)).congr_fun _ measurableSet_Ioc + intro t ht + simp [g, ht.2] + have hg₂ : IntegrableOn g (Ioi b) := by + apply IntegrableOn.congr_fun ((integrableOn_Ioi_rpow_of_lt + (by linarith : -q < -1) hb).const_mul (b ^ q)) _ measurableSet_Ioi + intro t ht + simp [g, not_le.mpr (mem_Ioi.1 ht)] + have hg : IntegrableOn g (Ioi 0) := by + rw [← Ioc_union_Ioi_eq_Ioi hb.le, integrableOn_union] + exact ⟨hg₁, hg₂⟩ + refine ⟨hf.aestronglyMeasurable, (hasFiniteIntegral_iff_ofReal hfn).2 ?_⟩ + rw [lintegral_eq_lintegral_meas_lt μ hfn hf] + apply lt_of_le_of_lt _ hg.lintegral_lt_top + apply lintegral_mono + intro t + change μ {x | t < f x} ≤ ENNReal.ofReal (g t) + rw [← ENNReal.ofReal_toReal (measure_ne_top μ {x | t < f x})] + apply ENNReal.ofReal_le_ofReal + change μ.real {x | t < f x} ≤ g t + by_cases ht : t ≤ b + · simpa only [g, ite_eq_left ht] using (measureReal_le_one (μ := μ) (s := {x | t < f x})) + · simpa only [g, ite_eq_right ht] using htail t (lt_of_not_ge ht) + + + +theorem integral_inverse_le_of_small_tail {α : Type*} [MeasurableSpace α] + {μ : Measure α} [IsProbabilityMeasure μ] {X : α → ℝ} + (hX : ∀ᵐ x ∂μ, 0 < X x) {A D p : ℝ} (hA : 0 < A) (hp : 0 < p) + (hpD : p < D) (hXm : AEMeasurable X μ) + (htail : ∀ h > 0, μ.real {x | X x < h} ≤ (A * h) ^ D) : + (∫ x, (X x) ^ (-p) ∂μ) ≤ D / (D - p) * A ^ p := by + have hq : 1 < D / p := (lt_div_iff₀ hp).2 (by simpa using hpD) + have hnn : 0 ≤ᵐ[μ] (fun x => (X x) ^ (-p)) := by + filter_upwards [hX] with x hx + exact (Real.rpow_pos_of_pos hx _).le + have hb : ∀ t > A ^ p, μ.real {x | t < (X x) ^ (-p)} ≤ + (A ^ p) ^ (D / p) * t ^ (-(D / p)) := by + intro t ht + have htpos : 0 < t := (Real.rpow_pos_of_pos hA p).trans ht + have htpow : 0 < t ^ (-1 / p) := Real.rpow_pos_of_pos htpos _ + have hsets : {x | t < (X x) ^ (-p)} =ᵐ[μ] {x | X x < t ^ (-1 / p)} := by + filter_upwards [hX] with x hx + have hh := Real.rpow_lt_rpow_iff_of_neg htpow hx (by linarith : -p < 0) + rw [← Real.rpow_mul htpos.le, show (-1 / p) * -p = (1 : ℝ) by field_simp, Real.rpow_one] at hh + exact propext hh + have hmeas : μ.real {x | t < (X x) ^ (-p)} = μ.real {x | X x < t ^ (-1 / p)} := by + exact congrArg ENNReal.toReal (measure_congr hsets) + rw [hmeas] + calc + _ ≤ (A * t ^ (-1 / p)) ^ D := htail _ htpow + _ = (A ^ p) ^ (D / p) * t ^ (-(D / p)) := by + rw [Real.mul_rpow hA.le htpow.le, ← Real.rpow_mul htpos.le, ← Real.rpow_mul hA.le, + show p * (D / p) = D by field_simp, + show (-1 / p) * D = -(D / p) by ring] + have hint : Integrable (fun x => (X x) ^ (-p)) μ := + integrable_of_power_tail (hXm.pow_const _) hnn (Real.rpow_pos_of_pos hA p) hq hb + have h := integral_le_of_power_tail hint hnn (Real.rpow_pos_of_pos hA p) hq hb + convert h using 1 + congr 1 + field_simp + +end + +noncomputable section +open scoped BigOperators +open Set MeasureTheory + + + +theorem laguerre_inverse_bound_of_small_coordinate_bound {N : ℕ} {a A p : ℝ} + (ha : 0 < a) (hA : 0 < A) (i : Fin N) (hp : 0 < p) + (hpD : p < a * (i.val + 1) + (i.val + 1) * i.val / 2) + (htail : ∀ h > 0, (laguerreLaw N a).real {r | r i < h} ≤ + (A * h) ^ (a * (i.val + 1) + (i.val + 1) * i.val / 2)) : + laguerreExpectation N a (fun r => (r i) ^ (-p)) ≤ + (a * (i.val + 1) + (i.val + 1) * i.val / 2) / + (a * (i.val + 1) + (i.val + 1) * i.val / 2 - p) * A ^ p := by + let := laguerreLaw_isProbabilityMeasure N ha + rw [← integral_laguerreLaw N ha] + apply integral_inverse_le_of_small_tail ?_ hA hp hpD (measurable_pi_apply i).aemeasurable htail + filter_upwards [ae_laguerreDomain N a] with r hr + exact hr.2 i + + + + + +theorem laguerreDomain_cons_iff {n : ℕ} (x : ℝ) (r : Fin n → ℝ) : + Fin.cons x r ∈ laguerreDomain (n + 1) ↔ + 0 < x ∧ r ∈ laguerreDomain n ∧ ∀ i, x < r i := by + simp only [laguerreDomain, mem_ofPred_eq, Fin.strictMono_cons, Fin.forall_fin_succ, + Fin.cons_zero, Fin.cons_succ] + tauto + +theorem pairProduct_cons {n : ℕ} (x : ℝ) (r : Fin n → ℝ) : + (∏ i : Fin (n + 1), ∏ j ∈ Finset.Ioi i, + pairKernel ((Fin.cons x r : Fin (n + 1) → ℝ) i) ((Fin.cons x r : Fin (n + 1) → ℝ) j)) = + (∏ j, pairKernel x (r j)) * ∏ i, ∏ j ∈ Finset.Ioi i, pairKernel (r i) (r j) := by + classical + have he {m : ℕ} (s : Fin m → ℝ) : + (∏ i : Fin m, ∏ j ∈ Finset.Ioi i, pairKernel (s i) (s j)) = + ∏ i : Fin m, ∏ j : Fin m, if i < j then pairKernel (s i) (s j) else 1 := by + apply Finset.prod_congr rfl + intro i _ + rw [← Finset.prod_filter] + congr 1 + ext j + simp + rw [he, he] + simp only [Fin.prod_univ_succ, Fin.cons_zero, Fin.cons_succ, + ↓reduceIte, Fin.succ_pos, Fin.not_lt_zero, Fin.succ_lt_succ_iff, one_mul] + +theorem laguerreDensity_cons {n : ℕ} (a x : ℝ) (r : Fin n → ℝ) : + laguerreDensity (n + 1) a (Fin.cons x r) = + laguerreWeight a x * laguerreDensity n a r * ∏ i, pairKernel x (r i) := by + unfold laguerreDensity + rw [pairProduct_cons] + simp only [Fin.prod_univ_succ, Fin.cons_zero, Fin.cons_succ] + ring + +theorem laguerreDensity_succ_parameter {n : ℕ} (a : ℝ) (r : Fin n → ℝ) + (hr : ∀ i, 0 < r i) : + laguerreDensity n (a + 1) r = laguerreDensity n a r * ∏ i, r i := by + have he : ∀ i, laguerreWeight (a + 1) (r i) = laguerreWeight a (r i) * r i := by + intro i + unfold laguerreWeight + rw [show a + 1 - 1 = (a - 1) + 1 by ring, Real.rpow_add (hr i), Real.rpow_one] + ring + simp only [laguerreDensity, he, Finset.prod_mul_distrib] + ring + +theorem laguerreDensity_cons_le {n : ℕ} (a : ℝ) {x : ℝ} {r : Fin n → ℝ} + (hr : Fin.cons x r ∈ laguerreDomain (n + 1)) : + laguerreDensity (n + 1) a (Fin.cons x r) ≤ + x ^ (a - 1) * laguerreDensity n (a + 1) r := by + obtain ⟨hx, hr, hxr⟩ := (laguerreDomain_cons_iff x r).1 hr + rw [laguerreDensity_cons, laguerreDensity_succ_parameter a r hr.2] + have hw : laguerreWeight a x ≤ x ^ (a - 1) := by + apply mul_le_of_le_one_right (Real.rpow_pos_of_pos hx _).le + exact Real.exp_le_one_iff.2 (by linarith) + have hp : (∏ i, pairKernel x (r i)) ≤ ∏ i, r i := by + apply Finset.prod_le_prod₀ + · intro i _ + exact pairKernel_nonneg hx.le (hr.2 i).le + · intro i _ + exact pairKernel_le_right hx.le (hr.2 i) (hxr i).le + calc + _ ≤ (x ^ (a - 1) * laguerreDensity n a r) * ∏ i, r i := + mul_le_mul (mul_le_mul_of_nonneg_right hw (laguerreDensity_pos a hr).le) hp + (Finset.prod_nonneg fun i _ => pairKernel_nonneg hx.le (hr.2 i).le) + (mul_nonneg (Real.rpow_pos_of_pos hx _).le (laguerreDensity_pos a hr).le) + _ = _ := by ring + + +def laguerreCut (n k : ℕ) (h : ℝ) : Set (Fin n → ℝ) := + laguerreDomain n ∩ {r | ∀ i, i.val < k → r i < h} + +def laguerreCutIntegral (n : ℕ) (a : ℝ) (k : ℕ) (h : ℝ) : ℝ := + ∫ r in laguerreCut n k h, laguerreDensity n a r + +theorem measurableSet_laguerreCut (n k : ℕ) (h : ℝ) : + MeasurableSet (laguerreCut n k h) := by + apply (isOpen_laguerreDomain n).measurableSet.inter + simp only [ofPred_forall] + exact MeasurableSet.iInter fun i => MeasurableSet.iInter fun _ => + measurableSet_lt (measurable_pi_apply i) measurable_const + +theorem laguerreCut_zero (n : ℕ) (h : ℝ) : laguerreCut n 0 h = laguerreDomain n := by + ext r + simp [laguerreCut] + +theorem integral_fin_cons_eq (n : ℕ) (f : (Fin (n + 1) → ℝ) → ℝ) : + (∫ r, f r) = ∫ p : ℝ × (Fin n → ℝ), f (Fin.cons p.1 p.2) := by + symm + simpa only [MeasurableEquiv.piFinSuccAbove_symm_apply, Fin.insertNthEquiv, + Fin.insertNth_zero, Fin.zero_succAbove, Equiv.coe_fn_mk, cast_eq] using + ((volume_preserving_piFinSuccAbove (fun _ : Fin (n + 1) => ℝ) 0).symm).integral_comp' f + +theorem integrable_fin_cons {n : ℕ} {f : (Fin (n + 1) → ℝ) → ℝ} + (hf : Integrable f) : Integrable (fun p : ℝ × (Fin n → ℝ) => f (Fin.cons p.1 p.2)) := by + simpa only [Function.comp_def, MeasurableEquiv.piFinSuccAbove_symm_apply, Fin.insertNthEquiv, + Fin.insertNth_zero, Fin.zero_succAbove, Equiv.coe_fn_mk, cast_eq] using + ((volume_preserving_piFinSuccAbove (fun _ : Fin (n + 1) => ℝ) 0).symm).integrable_comp_of_integrable hf + +theorem integral_Ioo_rpow_sub_one {a h : ℝ} (ha : 0 < a) (hh : 0 < h) : + (∫ x in Ioo 0 h, x ^ (a - 1)) = h ^ a / a := by + rw [← integral_Ioc_eq_integral_Ioo, ← intervalIntegral.integral_of_le hh.le, + integral_rpow (Or.inl (by linarith : -1 < a - 1))] + simp [Real.zero_rpow ha.ne'] + +theorem integrable_laguerreCut_indicator (n : ℕ) {a : ℝ} (ha : 0 < a) (k : ℕ) (h : ℝ) : + Integrable ((laguerreCut n k h).indicator (laguerreDensity n a)) := by + apply (integrable_indicator_iff (measurableSet_laguerreCut n k h)).2 + exact (integrableOn_laguerreDensity n ha).mono_set inter_subset_left + +theorem laguerreCut_indicator_nonneg (n : ℕ) (a : ℝ) (k : ℕ) (h : ℝ) (r : Fin n → ℝ) : + 0 ≤ (laguerreCut n k h).indicator (laguerreDensity n a) r := by + by_cases hr : r ∈ laguerreCut n k h + · rw [Set.indicator_of_mem hr] + exact (laguerreDensity_pos a hr.1).le + · rw [Set.indicator_of_notMem hr] + + + +theorem laguerreCutIntegral_succ_le (n k : ℕ) {a h : ℝ} (ha : 0 < a) (hh : 0 < h) : + laguerreCutIntegral (n + 1) a (k + 1) h ≤ + (h ^ a / a) * laguerreCutIntegral n (a + 1) k h := by + let f : ℝ → ℝ := (Ioo 0 h).indicator (fun x => x ^ (a - 1)) + let g : (Fin n → ℝ) → ℝ := (laguerreCut n k h).indicator (laguerreDensity n (a + 1)) + have hfi : Integrable f := (integrable_indicator_iff measurableSet_Ioo).2 + ((intervalIntegral.integrableOn_Ioo_rpow_iff hh).2 (by linarith)) + have hgi : Integrable g := integrable_laguerreCut_indicator n (by linarith) k h + have hfn : ∀ x, 0 ≤ f x := by + intro x + by_cases hx : x ∈ Ioo 0 h + · simpa only [f, indicator_of_mem hx] using (Real.rpow_pos_of_pos hx.1 (a - 1)).le + · simp only [f, indicator_of_notMem hx, le_refl] + have hn (p : ℝ × (Fin n → ℝ)) : + (laguerreCut (n + 1) (k + 1) h).indicator (laguerreDensity (n + 1) a) + (Fin.cons p.1 p.2) ≤ f p.1 * g p.2 := by + by_cases hp : Fin.cons p.1 p.2 ∈ laguerreCut (n + 1) (k + 1) h + · have hm := (laguerreDomain_cons_iff p.1 p.2).1 hp.1 + have hx : p.1 ∈ Ioo 0 h := ⟨hm.1, by simpa using hp.2 0 (by simp)⟩ + have hr : p.2 ∈ laguerreCut n k h := ⟨hm.2.1, fun i hi => by + simpa using hp.2 i.succ (by simpa using hi)⟩ + simpa only [f, g, indicator_of_mem hp, indicator_of_mem hx, indicator_of_mem hr] using + laguerreDensity_cons_le a hp.1 + · rw [indicator_of_notMem hp] + exact mul_nonneg (hfn _) (laguerreCut_indicator_nonneg n (a + 1) k h _) + calc + laguerreCutIntegral (n + 1) a (k + 1) h = + ∫ p : ℝ × (Fin n → ℝ), (laguerreCut (n + 1) (k + 1) h).indicator + (laguerreDensity (n + 1) a) (Fin.cons p.1 p.2) := by + rw [laguerreCutIntegral, ← integral_indicator (measurableSet_laguerreCut _ _ _), integral_fin_cons_eq] + _ ≤ ∫ p : ℝ × (Fin n → ℝ), f p.1 * g p.2 := + integral_mono (integrable_fin_cons (integrable_laguerreCut_indicator _ ha _ _)) + (hfi.mul_prod hgi) hn + _ = (∫ x, f x) * ∫ r, g r := integral_prod_mul f g + _ = (h ^ a / a) * laguerreCutIntegral n (a + 1) k h := by + simp only [f, g, integral_indicator measurableSet_Ioo, + integral_Ioo_rpow_sub_one ha hh, integral_indicator (measurableSet_laguerreCut n k h), + laguerreCutIntegral] + + +theorem laguerreCutIntegral_le_product (n k : ℕ) {a h : ℝ} + (ha : 0 < a) (hh : 0 < h) : + laguerreCutIntegral (n + k) a k h ≤ + (∏ i : Fin k, h ^ (a + i.val) / (a + i.val)) * laguerreNormalizer n (a + k) := by + induction k generalizing a with + | zero => simp [laguerreCutIntegral, laguerreCut_zero, laguerreNormalizer] + | succ k ih => + calc + _ ≤ (h ^ a / a) * laguerreCutIntegral (n + k) (a + 1) k h := + laguerreCutIntegral_succ_le (n + k) k ha hh + _ ≤ (h ^ a / a) * ((∏ i : Fin k, h ^ (a + 1 + i.val) / (a + 1 + i.val)) * + laguerreNormalizer n (a + 1 + k)) := + mul_le_mul_of_nonneg_left (ih (by linarith)) (by positivity) + _ = _ := by + rw [Fin.prod_univ_succ] + simp only [Fin.val_zero, Nat.cast_zero, add_zero, Fin.val_succ, Nat.cast_add, Nat.cast_one] + simp_rw [show ∀ i : Fin k, a + 1 + i.val = a + (i.val + 1) by intro i; ring] + rw [show a + 1 + (k : ℝ) = a + (k + 1) by ring] + ring + + +def laguerreDimension (a : ℝ) (k : ℕ) : ℝ := a * k + (k : ℝ) * (k - 1) / 2 + +theorem laguerreDimension_succ (a : ℝ) (k : ℕ) : + laguerreDimension a (k + 1) = a + laguerreDimension (a + 1) k := by + simp only [laguerreDimension, Nat.cast_add, Nat.cast_one] + ring + +theorem product_coordinate_power_quotient (k : ℕ) {h : ℝ} (hh : 0 < h) (a : ℝ) : + (∏ i : Fin k, h ^ (a + i.val) / (a + i.val)) = + h ^ (laguerreDimension a k) / ∏ i : Fin k, (a + i.val) := by + induction k generalizing a with + | zero => simp [laguerreDimension] + | succ k ih => + rw [Fin.prod_univ_succ, Fin.prod_univ_succ] + simp only [Fin.val_zero, Nat.cast_zero, add_zero, Fin.val_succ, Nat.cast_add, Nat.cast_one] + simp_rw [show ∀ i : Fin k, a + (i.val + 1) = a + 1 + i.val by intro i; ring] + rw [ih (a + 1), ← mul_div_mul_comm, ← Real.rpow_add hh, laguerreDimension_succ] + +theorem laguerreCutIntegral_le_normalizer_ratio (n k : ℕ) {a h : ℝ} + (ha : 0 < a) (hh : 0 < h) : + laguerreCutIntegral (n + k) a k h ≤ + (h ^ laguerreDimension a k / ∏ i : Fin k, (a + i.val)) * laguerreNormalizer n (a + k) := by + simpa only [product_coordinate_power_quotient k hh a] using + laguerreCutIntegral_le_product n k ha hh + +theorem laguerreCut_eq_coordinate_cut {n : ℕ} (i : Fin n) (h : ℝ) : + laguerreCut n (i.val + 1) h = laguerreDomain n ∩ {r | r i < h} := by + ext r + constructor + · intro hr + exact ⟨hr.1, hr.2 i (by omega)⟩ + · rintro ⟨hr, hi⟩ + refine ⟨hr, fun j hj => ?_⟩ + exact lt_of_le_of_lt (hr.1.monotone (by change j.val ≤ i.val; omega)) hi + +theorem laguerreLaw_small_coordinate_eq {n : ℕ} {a : ℝ} (ha : 0 < a) + (i : Fin n) (h : ℝ) : + (laguerreLaw n a).real {r | r i < h} = + laguerreCutIntegral n a (i.val + 1) h / laguerreNormalizer n a := by + have hm : MeasurableSet {r : Fin n → ℝ | r i < h} := + measurableSet_lt (measurable_pi_apply i) measurable_const + rw [← integral_indicator_one hm, integral_laguerreLaw n ha] + unfold laguerreExpectation laguerreCutIntegral + simp_rw [← Set.indicator_mul_left, Pi.one_apply, one_mul] + rw [setIntegral_indicator hm, laguerreCut_eq_coordinate_cut] + + + +theorem laguerreLaw_small_coordinate_le_normalizer_ratio {N : ℕ} {a h : ℝ} + (ha : 0 < a) (hh : 0 < h) (i : Fin N) : + (laguerreLaw N a).real {r | r i < h} ≤ + h ^ laguerreDimension a (i.val + 1) / + (∏ j : Fin (i.val + 1), (a + j.val)) * + (laguerreNormalizer (N - (i.val + 1)) (a + (i.val + 1)) / laguerreNormalizer N a) := by + rw [laguerreLaw_small_coordinate_eq ha i h] + have H := laguerreCutIntegral_le_normalizer_ratio (N - (i.val + 1)) (i.val + 1) ha hh + have hN : N - (i.val + 1) + (i.val + 1) = N := by omega + rw [hN] at H + have hh' := div_le_div_of_nonneg_right H (laguerreNormalizer_pos N ha).le + simpa only [Nat.cast_add, Nat.cast_one, mul_div_assoc] using hh' + + + +def laguerreSmallCoefficient (N : ℕ) (a : ℝ) (k : ℕ) : ℝ := + laguerreNormalizer (N - k) (a + k) / + (laguerreNormalizer N a * ∏ j : Fin k, (a + j.val)) + +theorem laguerreSmallCoefficient_pos (N k : ℕ) {a : ℝ} (ha : 0 < a) : + 0 < laguerreSmallCoefficient N a k := by + apply div_pos (laguerreNormalizer_pos _ (by positivity)) + exact mul_pos (laguerreNormalizer_pos _ ha) (Finset.prod_pos fun j _ => by positivity) + +theorem laguerreDimension_pos {a : ℝ} (ha : 0 < a) {k : ℕ} (hk : 1 ≤ k) : + 0 < laguerreDimension a k := by + have hk' : (1 : ℝ) ≤ k := by exact_mod_cast hk + unfold laguerreDimension + have hp : 0 < a * (k : ℝ) := mul_pos ha (by linarith) + have hq : 0 ≤ (k : ℝ) * (k - 1) := mul_nonneg (by positivity) (by linarith) + linarith + +end +end CriticalStrip + +end OAI diff --git a/lean/OAI/Combinatorics/StripMass/ThreeBoxBraidPolynomial.lean b/lean/OAI/Combinatorics/StripMass/ThreeBoxBraidPolynomial.lean new file mode 100644 index 0000000000000000000000000000000000000000..9b5c29fc536de4f80085b903f4ca90cfeac305c9 --- /dev/null +++ b/lean/OAI/Combinatorics/StripMass/ThreeBoxBraidPolynomial.lean @@ -0,0 +1,610 @@ +import Mathlib +import OAI.Combinatorics.StripMass.ThreeBoxWeights +import OAI.Combinatorics.StripMass.RootOfUnityPowers + +namespace OAI + +/-! Critical honeycomb strip paths, polynomial identities and crossing mass. -/ + + + +namespace CriticalStrip.Diagram.ThreeBox +noncomputable section + +theorem braid_numerator_0 {K : Type*} [CommRing K] (q z w : K) (_hq : q^8 = -1) : + coefficient (tileNumerator q (q^4) z) (tileNumerator q (q^4) (z*w)) + (tileNumerator q (q^4) w) 0 = + coefficient (tileNumerator q (q^4) w) (tileNumerator q (q^4) (z*w)) + (tileNumerator q (q^4) z) 0 := by + rw [coefficient_0, coefficient_0] + simp only [tileNumerator] + ring_nf + +theorem braid_numerator_1 {K : Type*} [CommRing K] (q z w : K) (hq : q^8 = -1) : + coefficient (tileNumerator q (q^4) z) (tileNumerator q (q^4) (z*w)) + (tileNumerator q (q^4) w) 1 = + coefficient (tileNumerator q (q^4) w) (tileNumerator q (q^4) (z*w)) + (tileNumerator q (q^4) z) 31 := by + rw [coefficient_1, coefficient_31] + simp only [tileNumerator] + ring_nf + all_goals simp only [eighthRoot_power_11 hq, eighthRoot_power_13 hq, eighthRoot_power_15 hq, eighthRoot_power_17 hq, eighthRoot_power_19 hq, eighthRoot_power_21 hq, eighthRoot_power_23 hq, eighthRoot_power_25 hq, eighthRoot_power_27 hq, eighthRoot_power_29 hq, eighthRoot_power_31 hq, eighthRoot_power_35 hq] + all_goals ring + +theorem braid_numerator_2 {K : Type*} [CommRing K] (q z w : K) (hq : q^8 = -1) : + coefficient (tileNumerator q (q^4) z) (tileNumerator q (q^4) (z*w)) + (tileNumerator q (q^4) w) 2 = + coefficient (tileNumerator q (q^4) w) (tileNumerator q (q^4) (z*w)) + (tileNumerator q (q^4) z) 28 := by + rw [coefficient_2, coefficient_28] + simp only [tileNumerator] + ring_nf + all_goals simp only [eighthRoot_power_11 hq, eighthRoot_power_13 hq, eighthRoot_power_15 hq, eighthRoot_power_17 hq, eighthRoot_power_19 hq, eighthRoot_power_21 hq, eighthRoot_power_23 hq, eighthRoot_power_25 hq, eighthRoot_power_27 hq, eighthRoot_power_29 hq, eighthRoot_power_31 hq] + all_goals ring + +theorem braid_numerator_3 {K : Type*} [CommRing K] (q z w : K) (_hq : q^8 = -1) : + coefficient (tileNumerator q (q^4) z) (tileNumerator q (q^4) (z*w)) + (tileNumerator q (q^4) w) 3 = + coefficient (tileNumerator q (q^4) w) (tileNumerator q (q^4) (z*w)) + (tileNumerator q (q^4) z) 29 := by + rw [coefficient_3, coefficient_29] + simp only [tileNumerator] + ring_nf + +theorem braid_numerator_4 {K : Type*} [CommRing K] (q z w : K) (hq : q^8 = -1) : + coefficient (tileNumerator q (q^4) z) (tileNumerator q (q^4) (z*w)) + (tileNumerator q (q^4) w) 4 = + coefficient (tileNumerator q (q^4) w) (tileNumerator q (q^4) (z*w)) + (tileNumerator q (q^4) z) 24 := by + rw [coefficient_4, coefficient_24] + simp only [tileNumerator] + ring_nf + all_goals simp only [eighthRoot_power_9 hq, eighthRoot_power_13 hq, eighthRoot_power_15 hq, eighthRoot_power_17 hq, eighthRoot_power_19 hq, eighthRoot_power_21 hq, eighthRoot_power_23 hq, eighthRoot_power_25 hq, eighthRoot_power_27 hq, eighthRoot_power_29 hq, eighthRoot_power_33 hq] + all_goals ring + +theorem braid_numerator_5 {K : Type*} [CommRing K] (q z w : K) (hq : q^8 = -1) : + coefficient (tileNumerator q (q^4) z) (tileNumerator q (q^4) (z*w)) + (tileNumerator q (q^4) w) 5 = + coefficient (tileNumerator q (q^4) w) (tileNumerator q (q^4) (z*w)) + (tileNumerator q (q^4) z) 15 := by + rw [coefficient_5, coefficient_15] + simp only [tileNumerator] + ring_nf + all_goals simp only [eighthRoot_power_11 hq, eighthRoot_power_13 hq, eighthRoot_power_15 hq, eighthRoot_power_17 hq, eighthRoot_power_19 hq, eighthRoot_power_21 hq, eighthRoot_power_23 hq, eighthRoot_power_25 hq, eighthRoot_power_27 hq, eighthRoot_power_29 hq, eighthRoot_power_31 hq, eighthRoot_power_35 hq] + all_goals ring + +theorem braid_numerator_6 {K : Type*} [CommRing K] (q z w : K) (hq : q^8 = -1) : + coefficient (tileNumerator q (q^4) z) (tileNumerator q (q^4) (z*w)) + (tileNumerator q (q^4) w) 6 = + coefficient (tileNumerator q (q^4) w) (tileNumerator q (q^4) (z*w)) + (tileNumerator q (q^4) z) 16 := by + rw [coefficient_6, coefficient_16] + simp only [tileNumerator] + ring_nf + all_goals simp only [eighthRoot_power_8 hq, eighthRoot_power_10 hq, eighthRoot_power_12 hq, eighthRoot_power_14 hq, eighthRoot_power_16 hq, eighthRoot_power_18 hq, eighthRoot_power_20 hq, eighthRoot_power_22 hq, eighthRoot_power_24 hq, eighthRoot_power_26 hq, eighthRoot_power_28 hq, eighthRoot_power_30 hq, eighthRoot_power_32 hq, eighthRoot_power_36 hq] + all_goals ring + +theorem braid_numerator_7 {K : Type*} [CommRing K] (q z w : K) (hq : q^8 = -1) : + coefficient (tileNumerator q (q^4) z) (tileNumerator q (q^4) (z*w)) + (tileNumerator q (q^4) w) 7 = + coefficient (tileNumerator q (q^4) w) (tileNumerator q (q^4) (z*w)) + (tileNumerator q (q^4) z) 34 := by + rw [coefficient_7, coefficient_34] + simp only [tileNumerator] + ring_nf + all_goals simp only [eighthRoot_power_8 hq, eighthRoot_power_10 hq, eighthRoot_power_12 hq, eighthRoot_power_14 hq, eighthRoot_power_16 hq, eighthRoot_power_18 hq, eighthRoot_power_20 hq, eighthRoot_power_22 hq, eighthRoot_power_24 hq, eighthRoot_power_26 hq, eighthRoot_power_28 hq, eighthRoot_power_30 hq, eighthRoot_power_32 hq, eighthRoot_power_34 hq] + all_goals ring + +theorem braid_numerator_8 {K : Type*} [CommRing K] (q z w : K) (hq : q^8 = -1) : + coefficient (tileNumerator q (q^4) z) (tileNumerator q (q^4) (z*w)) + (tileNumerator q (q^4) w) 8 = + coefficient (tileNumerator q (q^4) w) (tileNumerator q (q^4) (z*w)) + (tileNumerator q (q^4) z) 33 := by + rw [coefficient_8, coefficient_33] + simp only [tileNumerator] + ring_nf + all_goals simp only [eighthRoot_power_10 hq, eighthRoot_power_12 hq, eighthRoot_power_14 hq, eighthRoot_power_16 hq, eighthRoot_power_18 hq, eighthRoot_power_20 hq, eighthRoot_power_22 hq, eighthRoot_power_24 hq, eighthRoot_power_26 hq, eighthRoot_power_28 hq, eighthRoot_power_30 hq] + all_goals ring + +theorem braid_numerator_9 {K : Type*} [CommRing K] (q z w : K) (_hq : q^8 = -1) : + coefficient (tileNumerator q (q^4) z) (tileNumerator q (q^4) (z*w)) + (tileNumerator q (q^4) w) 9 = + coefficient (tileNumerator q (q^4) w) (tileNumerator q (q^4) (z*w)) + (tileNumerator q (q^4) z) 32 := by + rw [coefficient_9, coefficient_32] + simp only [tileNumerator] + ring_nf + +theorem braid_numerator_10 {K : Type*} [CommRing K] (q z w : K) (hq : q^8 = -1) : + coefficient (tileNumerator q (q^4) z) (tileNumerator q (q^4) (z*w)) + (tileNumerator q (q^4) w) 10 = + coefficient (tileNumerator q (q^4) w) (tileNumerator q (q^4) (z*w)) + (tileNumerator q (q^4) z) 10 := by + rw [coefficient_10, coefficient_10] + simp only [tileNumerator] + ring_nf + all_goals simp only [eighthRoot_power_9 hq, eighthRoot_power_13 hq, eighthRoot_power_15 hq, eighthRoot_power_17 hq, eighthRoot_power_19 hq, eighthRoot_power_21 hq, eighthRoot_power_23 hq, eighthRoot_power_25 hq, eighthRoot_power_27 hq, eighthRoot_power_29 hq, eighthRoot_power_33 hq] + all_goals ring + +theorem braid_numerator_11 {K : Type*} [CommRing K] (q z w : K) (hq : q^8 = -1) : + coefficient (tileNumerator q (q^4) z) (tileNumerator q (q^4) (z*w)) + (tileNumerator q (q^4) w) 11 = + coefficient (tileNumerator q (q^4) w) (tileNumerator q (q^4) (z*w)) + (tileNumerator q (q^4) z) 13 := by + rw [coefficient_11, coefficient_13] + simp only [tileNumerator] + ring_nf + all_goals simp only [eighthRoot_power_10 hq, eighthRoot_power_12 hq, eighthRoot_power_14 hq, eighthRoot_power_16 hq, eighthRoot_power_18 hq, eighthRoot_power_20 hq, eighthRoot_power_22 hq, eighthRoot_power_24 hq, eighthRoot_power_26 hq, eighthRoot_power_28 hq, eighthRoot_power_30 hq] + all_goals ring + +theorem braid_numerator_12 {K : Type*} [CommRing K] (q z w : K) (_hq : q^8 = -1) : + coefficient (tileNumerator q (q^4) z) (tileNumerator q (q^4) (z*w)) + (tileNumerator q (q^4) w) 12 = + coefficient (tileNumerator q (q^4) w) (tileNumerator q (q^4) (z*w)) + (tileNumerator q (q^4) z) 12 := by + rw [coefficient_12, coefficient_12] + simp only [tileNumerator] + ring_nf + +theorem braid_numerator_13 {K : Type*} [CommRing K] (q z w : K) (hq : q^8 = -1) : + coefficient (tileNumerator q (q^4) z) (tileNumerator q (q^4) (z*w)) + (tileNumerator q (q^4) w) 13 = + coefficient (tileNumerator q (q^4) w) (tileNumerator q (q^4) (z*w)) + (tileNumerator q (q^4) z) 11 := by + rw [coefficient_13, coefficient_11] + simp only [tileNumerator] + ring_nf + all_goals simp only [eighthRoot_power_10 hq, eighthRoot_power_12 hq, eighthRoot_power_14 hq, eighthRoot_power_16 hq, eighthRoot_power_18 hq, eighthRoot_power_20 hq, eighthRoot_power_22 hq, eighthRoot_power_24 hq, eighthRoot_power_26 hq, eighthRoot_power_28 hq, eighthRoot_power_30 hq] + all_goals ring + +theorem braid_numerator_14 {K : Type*} [CommRing K] (q z w : K) (hq : q^8 = -1) : + coefficient (tileNumerator q (q^4) z) (tileNumerator q (q^4) (z*w)) + (tileNumerator q (q^4) w) 14 = + coefficient (tileNumerator q (q^4) w) (tileNumerator q (q^4) (z*w)) + (tileNumerator q (q^4) z) 46 := by + rw [coefficient_14, coefficient_46] + simp only [tileNumerator] + ring_nf + all_goals simp only [eighthRoot_power_8 hq, eighthRoot_power_10 hq, eighthRoot_power_12 hq, eighthRoot_power_14 hq, eighthRoot_power_16 hq, eighthRoot_power_18 hq, eighthRoot_power_20 hq, eighthRoot_power_22 hq, eighthRoot_power_24 hq, eighthRoot_power_26 hq, eighthRoot_power_28 hq, eighthRoot_power_30 hq, eighthRoot_power_32 hq, eighthRoot_power_34 hq, eighthRoot_power_38 hq] + all_goals ring + +theorem braid_numerator_15 {K : Type*} [CommRing K] (q z w : K) (hq : q^8 = -1) : + coefficient (tileNumerator q (q^4) z) (tileNumerator q (q^4) (z*w)) + (tileNumerator q (q^4) w) 15 = + coefficient (tileNumerator q (q^4) w) (tileNumerator q (q^4) (z*w)) + (tileNumerator q (q^4) z) 5 := by + rw [coefficient_15, coefficient_5] + simp only [tileNumerator] + ring_nf + all_goals simp only [eighthRoot_power_11 hq, eighthRoot_power_13 hq, eighthRoot_power_15 hq, eighthRoot_power_17 hq, eighthRoot_power_19 hq, eighthRoot_power_21 hq, eighthRoot_power_23 hq, eighthRoot_power_25 hq, eighthRoot_power_27 hq, eighthRoot_power_29 hq, eighthRoot_power_31 hq, eighthRoot_power_35 hq] + all_goals ring + +theorem braid_numerator_16 {K : Type*} [CommRing K] (q z w : K) (hq : q^8 = -1) : + coefficient (tileNumerator q (q^4) z) (tileNumerator q (q^4) (z*w)) + (tileNumerator q (q^4) w) 16 = + coefficient (tileNumerator q (q^4) w) (tileNumerator q (q^4) (z*w)) + (tileNumerator q (q^4) z) 6 := by + rw [coefficient_16, coefficient_6] + simp only [tileNumerator] + ring_nf + all_goals simp only [eighthRoot_power_8 hq, eighthRoot_power_10 hq, eighthRoot_power_12 hq, eighthRoot_power_14 hq, eighthRoot_power_16 hq, eighthRoot_power_18 hq, eighthRoot_power_20 hq, eighthRoot_power_22 hq, eighthRoot_power_24 hq, eighthRoot_power_26 hq, eighthRoot_power_28 hq, eighthRoot_power_30 hq, eighthRoot_power_32 hq, eighthRoot_power_36 hq] + all_goals ring + +theorem braid_numerator_17 {K : Type*} [CommRing K] (q z w : K) (hq : q^8 = -1) : + coefficient (tileNumerator q (q^4) z) (tileNumerator q (q^4) (z*w)) + (tileNumerator q (q^4) w) 17 = + coefficient (tileNumerator q (q^4) w) (tileNumerator q (q^4) (z*w)) + (tileNumerator q (q^4) z) 40 := by + rw [coefficient_17, coefficient_40] + simp only [tileNumerator] + ring_nf + all_goals simp only [eighthRoot_power_8 hq, eighthRoot_power_10 hq, eighthRoot_power_12 hq, eighthRoot_power_14 hq, eighthRoot_power_16 hq, eighthRoot_power_18 hq, eighthRoot_power_20 hq, eighthRoot_power_22 hq, eighthRoot_power_24 hq, eighthRoot_power_26 hq, eighthRoot_power_28 hq, eighthRoot_power_30 hq, eighthRoot_power_32 hq, eighthRoot_power_34 hq, eighthRoot_power_38 hq] + all_goals ring + +theorem braid_numerator_18 {K : Type*} [CommRing K] (q z w : K) (_hq : q^8 = -1) : + coefficient (tileNumerator q (q^4) z) (tileNumerator q (q^4) (z*w)) + (tileNumerator q (q^4) w) 18 = + coefficient (tileNumerator q (q^4) w) (tileNumerator q (q^4) (z*w)) + (tileNumerator q (q^4) z) 18 := by + rw [coefficient_18, coefficient_18] + simp only [tileNumerator] + ring_nf + +theorem braid_numerator_19 {K : Type*} [CommRing K] (q z w : K) (hq : q^8 = -1) : + coefficient (tileNumerator q (q^4) z) (tileNumerator q (q^4) (z*w)) + (tileNumerator q (q^4) w) 19 = + coefficient (tileNumerator q (q^4) w) (tileNumerator q (q^4) (z*w)) + (tileNumerator q (q^4) z) 37 := by + rw [coefficient_19, coefficient_37] + simp only [tileNumerator] + ring_nf + all_goals simp only [eighthRoot_power_10 hq, eighthRoot_power_12 hq, eighthRoot_power_14 hq, eighthRoot_power_16 hq, eighthRoot_power_18 hq, eighthRoot_power_20 hq, eighthRoot_power_22 hq, eighthRoot_power_24 hq, eighthRoot_power_26 hq, eighthRoot_power_28 hq, eighthRoot_power_30 hq, eighthRoot_power_32 hq, eighthRoot_power_36 hq] + all_goals ring + +theorem braid_numerator_20 {K : Type*} [CommRing K] (q z w : K) (hq : q^8 = -1) : + coefficient (tileNumerator q (q^4) z) (tileNumerator q (q^4) (z*w)) + (tileNumerator q (q^4) w) 20 = + coefficient (tileNumerator q (q^4) w) (tileNumerator q (q^4) (z*w)) + (tileNumerator q (q^4) z) 26 := by + rw [coefficient_20, coefficient_26] + simp only [tileNumerator] + ring_nf + all_goals simp only [eighthRoot_power_10 hq, eighthRoot_power_12 hq, eighthRoot_power_14 hq, eighthRoot_power_16 hq, eighthRoot_power_18 hq, eighthRoot_power_20 hq, eighthRoot_power_22 hq, eighthRoot_power_24 hq, eighthRoot_power_26 hq, eighthRoot_power_28 hq, eighthRoot_power_30 hq, eighthRoot_power_32 hq, eighthRoot_power_36 hq] + all_goals ring + +theorem braid_numerator_21 {K : Type*} [CommRing K] (q z w : K) (_hq : q^8 = -1) : + coefficient (tileNumerator q (q^4) z) (tileNumerator q (q^4) (z*w)) + (tileNumerator q (q^4) w) 21 = + coefficient (tileNumerator q (q^4) w) (tileNumerator q (q^4) (z*w)) + (tileNumerator q (q^4) z) 21 := by + rw [coefficient_21, coefficient_21] + simp only [tileNumerator] + ring_nf + +theorem braid_numerator_22 {K : Type*} [CommRing K] (q z w : K) (hq : q^8 = -1) : + coefficient (tileNumerator q (q^4) z) (tileNumerator q (q^4) (z*w)) + (tileNumerator q (q^4) w) 22 = + coefficient (tileNumerator q (q^4) w) (tileNumerator q (q^4) (z*w)) + (tileNumerator q (q^4) z) 47 := by + rw [coefficient_22, coefficient_47] + simp only [tileNumerator] + ring_nf + all_goals simp only [eighthRoot_power_11 hq, eighthRoot_power_13 hq, eighthRoot_power_15 hq, eighthRoot_power_17 hq, eighthRoot_power_19 hq, eighthRoot_power_21 hq, eighthRoot_power_23 hq, eighthRoot_power_25 hq, eighthRoot_power_27 hq, eighthRoot_power_29 hq, eighthRoot_power_31 hq, eighthRoot_power_35 hq] + all_goals ring + +theorem braid_numerator_23 {K : Type*} [CommRing K] (q z w : K) (hq : q^8 = -1) : + coefficient (tileNumerator q (q^4) z) (tileNumerator q (q^4) (z*w)) + (tileNumerator q (q^4) w) 23 = + coefficient (tileNumerator q (q^4) w) (tileNumerator q (q^4) (z*w)) + (tileNumerator q (q^4) z) 45 := by + rw [coefficient_23, coefficient_45] + simp only [tileNumerator] + ring_nf + all_goals simp only [eighthRoot_power_10 hq, eighthRoot_power_12 hq, eighthRoot_power_14 hq, eighthRoot_power_16 hq, eighthRoot_power_18 hq, eighthRoot_power_20 hq, eighthRoot_power_22 hq, eighthRoot_power_24 hq, eighthRoot_power_26 hq, eighthRoot_power_28 hq, eighthRoot_power_30 hq, eighthRoot_power_32 hq, eighthRoot_power_36 hq] + all_goals ring + +theorem braid_numerator_24 {K : Type*} [CommRing K] (q z w : K) (hq : q^8 = -1) : + coefficient (tileNumerator q (q^4) z) (tileNumerator q (q^4) (z*w)) + (tileNumerator q (q^4) w) 24 = + coefficient (tileNumerator q (q^4) w) (tileNumerator q (q^4) (z*w)) + (tileNumerator q (q^4) z) 4 := by + rw [coefficient_24, coefficient_4] + simp only [tileNumerator] + ring_nf + all_goals simp only [eighthRoot_power_9 hq, eighthRoot_power_13 hq, eighthRoot_power_15 hq, eighthRoot_power_17 hq, eighthRoot_power_19 hq, eighthRoot_power_21 hq, eighthRoot_power_23 hq, eighthRoot_power_25 hq, eighthRoot_power_27 hq, eighthRoot_power_29 hq, eighthRoot_power_33 hq] + all_goals ring + +theorem braid_numerator_25 {K : Type*} [CommRing K] (q z w : K) (_hq : q^8 = -1) : + coefficient (tileNumerator q (q^4) z) (tileNumerator q (q^4) (z*w)) + (tileNumerator q (q^4) w) 25 = + coefficient (tileNumerator q (q^4) w) (tileNumerator q (q^4) (z*w)) + (tileNumerator q (q^4) z) 36 := by + rw [coefficient_25, coefficient_36] + simp only [tileNumerator] + ring_nf + +theorem braid_numerator_26 {K : Type*} [CommRing K] (q z w : K) (hq : q^8 = -1) : + coefficient (tileNumerator q (q^4) z) (tileNumerator q (q^4) (z*w)) + (tileNumerator q (q^4) w) 26 = + coefficient (tileNumerator q (q^4) w) (tileNumerator q (q^4) (z*w)) + (tileNumerator q (q^4) z) 20 := by + rw [coefficient_26, coefficient_20] + simp only [tileNumerator] + ring_nf + all_goals simp only [eighthRoot_power_10 hq, eighthRoot_power_12 hq, eighthRoot_power_14 hq, eighthRoot_power_16 hq, eighthRoot_power_18 hq, eighthRoot_power_20 hq, eighthRoot_power_22 hq, eighthRoot_power_24 hq, eighthRoot_power_26 hq, eighthRoot_power_28 hq, eighthRoot_power_30 hq, eighthRoot_power_32 hq, eighthRoot_power_36 hq] + all_goals ring + +theorem braid_numerator_27 {K : Type*} [CommRing K] (q z w : K) (_hq : q^8 = -1) : + coefficient (tileNumerator q (q^4) z) (tileNumerator q (q^4) (z*w)) + (tileNumerator q (q^4) w) 27 = + coefficient (tileNumerator q (q^4) w) (tileNumerator q (q^4) (z*w)) + (tileNumerator q (q^4) z) 43 := by + rw [coefficient_27, coefficient_43] + simp only [tileNumerator] + ring_nf + +theorem braid_numerator_28 {K : Type*} [CommRing K] (q z w : K) (hq : q^8 = -1) : + coefficient (tileNumerator q (q^4) z) (tileNumerator q (q^4) (z*w)) + (tileNumerator q (q^4) w) 28 = + coefficient (tileNumerator q (q^4) w) (tileNumerator q (q^4) (z*w)) + (tileNumerator q (q^4) z) 2 := by + rw [coefficient_28, coefficient_2] + simp only [tileNumerator] + ring_nf + all_goals simp only [eighthRoot_power_11 hq, eighthRoot_power_13 hq, eighthRoot_power_15 hq, eighthRoot_power_17 hq, eighthRoot_power_19 hq, eighthRoot_power_21 hq, eighthRoot_power_23 hq, eighthRoot_power_25 hq, eighthRoot_power_27 hq, eighthRoot_power_29 hq, eighthRoot_power_31 hq] + all_goals ring + +theorem braid_numerator_29 {K : Type*} [CommRing K] (q z w : K) (_hq : q^8 = -1) : + coefficient (tileNumerator q (q^4) z) (tileNumerator q (q^4) (z*w)) + (tileNumerator q (q^4) w) 29 = + coefficient (tileNumerator q (q^4) w) (tileNumerator q (q^4) (z*w)) + (tileNumerator q (q^4) z) 3 := by + rw [coefficient_29, coefficient_3] + simp only [tileNumerator] + ring_nf + +theorem braid_numerator_30 {K : Type*} [CommRing K] (q z w : K) (hq : q^8 = -1) : + coefficient (tileNumerator q (q^4) z) (tileNumerator q (q^4) (z*w)) + (tileNumerator q (q^4) w) 30 = + coefficient (tileNumerator q (q^4) w) (tileNumerator q (q^4) (z*w)) + (tileNumerator q (q^4) z) 44 := by + rw [coefficient_30, coefficient_44] + simp only [tileNumerator] + ring_nf + all_goals simp only [eighthRoot_power_11 hq, eighthRoot_power_13 hq, eighthRoot_power_15 hq, eighthRoot_power_17 hq, eighthRoot_power_19 hq, eighthRoot_power_21 hq, eighthRoot_power_23 hq, eighthRoot_power_25 hq, eighthRoot_power_27 hq, eighthRoot_power_29 hq, eighthRoot_power_31 hq] + all_goals ring + +theorem braid_numerator_31 {K : Type*} [CommRing K] (q z w : K) (hq : q^8 = -1) : + coefficient (tileNumerator q (q^4) z) (tileNumerator q (q^4) (z*w)) + (tileNumerator q (q^4) w) 31 = + coefficient (tileNumerator q (q^4) w) (tileNumerator q (q^4) (z*w)) + (tileNumerator q (q^4) z) 1 := by + rw [coefficient_31, coefficient_1] + simp only [tileNumerator] + ring_nf + all_goals simp only [eighthRoot_power_11 hq, eighthRoot_power_13 hq, eighthRoot_power_15 hq, eighthRoot_power_17 hq, eighthRoot_power_19 hq, eighthRoot_power_21 hq, eighthRoot_power_23 hq, eighthRoot_power_25 hq, eighthRoot_power_27 hq, eighthRoot_power_29 hq, eighthRoot_power_31 hq, eighthRoot_power_35 hq] + all_goals ring + +theorem braid_numerator_32 {K : Type*} [CommRing K] (q z w : K) (_hq : q^8 = -1) : + coefficient (tileNumerator q (q^4) z) (tileNumerator q (q^4) (z*w)) + (tileNumerator q (q^4) w) 32 = + coefficient (tileNumerator q (q^4) w) (tileNumerator q (q^4) (z*w)) + (tileNumerator q (q^4) z) 9 := by + rw [coefficient_32, coefficient_9] + simp only [tileNumerator] + ring_nf + +theorem braid_numerator_33 {K : Type*} [CommRing K] (q z w : K) (hq : q^8 = -1) : + coefficient (tileNumerator q (q^4) z) (tileNumerator q (q^4) (z*w)) + (tileNumerator q (q^4) w) 33 = + coefficient (tileNumerator q (q^4) w) (tileNumerator q (q^4) (z*w)) + (tileNumerator q (q^4) z) 8 := by + rw [coefficient_33, coefficient_8] + simp only [tileNumerator] + ring_nf + all_goals simp only [eighthRoot_power_10 hq, eighthRoot_power_12 hq, eighthRoot_power_14 hq, eighthRoot_power_16 hq, eighthRoot_power_18 hq, eighthRoot_power_20 hq, eighthRoot_power_22 hq, eighthRoot_power_24 hq, eighthRoot_power_26 hq, eighthRoot_power_28 hq, eighthRoot_power_30 hq] + all_goals ring + +theorem braid_numerator_34 {K : Type*} [CommRing K] (q z w : K) (hq : q^8 = -1) : + coefficient (tileNumerator q (q^4) z) (tileNumerator q (q^4) (z*w)) + (tileNumerator q (q^4) w) 34 = + coefficient (tileNumerator q (q^4) w) (tileNumerator q (q^4) (z*w)) + (tileNumerator q (q^4) z) 7 := by + rw [coefficient_34, coefficient_7] + simp only [tileNumerator] + ring_nf + all_goals simp only [eighthRoot_power_8 hq, eighthRoot_power_10 hq, eighthRoot_power_12 hq, eighthRoot_power_14 hq, eighthRoot_power_16 hq, eighthRoot_power_18 hq, eighthRoot_power_20 hq, eighthRoot_power_22 hq, eighthRoot_power_24 hq, eighthRoot_power_26 hq, eighthRoot_power_28 hq, eighthRoot_power_30 hq, eighthRoot_power_32 hq, eighthRoot_power_34 hq] + all_goals ring + +theorem braid_numerator_35 {K : Type*} [CommRing K] (q z w : K) (hq : q^8 = -1) : + coefficient (tileNumerator q (q^4) z) (tileNumerator q (q^4) (z*w)) + (tileNumerator q (q^4) w) 35 = + coefficient (tileNumerator q (q^4) w) (tileNumerator q (q^4) (z*w)) + (tileNumerator q (q^4) z) 41 := by + rw [coefficient_35, coefficient_41] + simp only [tileNumerator] + ring_nf + all_goals simp only [eighthRoot_power_10 hq, eighthRoot_power_12 hq, eighthRoot_power_14 hq, eighthRoot_power_16 hq, eighthRoot_power_18 hq, eighthRoot_power_20 hq, eighthRoot_power_22 hq, eighthRoot_power_24 hq, eighthRoot_power_26 hq, eighthRoot_power_28 hq, eighthRoot_power_30 hq, eighthRoot_power_32 hq, eighthRoot_power_36 hq] + all_goals ring + +theorem braid_numerator_36 {K : Type*} [CommRing K] (q z w : K) (_hq : q^8 = -1) : + coefficient (tileNumerator q (q^4) z) (tileNumerator q (q^4) (z*w)) + (tileNumerator q (q^4) w) 36 = + coefficient (tileNumerator q (q^4) w) (tileNumerator q (q^4) (z*w)) + (tileNumerator q (q^4) z) 25 := by + rw [coefficient_36, coefficient_25] + simp only [tileNumerator] + ring_nf + +theorem braid_numerator_37 {K : Type*} [CommRing K] (q z w : K) (hq : q^8 = -1) : + coefficient (tileNumerator q (q^4) z) (tileNumerator q (q^4) (z*w)) + (tileNumerator q (q^4) w) 37 = + coefficient (tileNumerator q (q^4) w) (tileNumerator q (q^4) (z*w)) + (tileNumerator q (q^4) z) 19 := by + rw [coefficient_37, coefficient_19] + simp only [tileNumerator] + ring_nf + all_goals simp only [eighthRoot_power_10 hq, eighthRoot_power_12 hq, eighthRoot_power_14 hq, eighthRoot_power_16 hq, eighthRoot_power_18 hq, eighthRoot_power_20 hq, eighthRoot_power_22 hq, eighthRoot_power_24 hq, eighthRoot_power_26 hq, eighthRoot_power_28 hq, eighthRoot_power_30 hq, eighthRoot_power_32 hq, eighthRoot_power_36 hq] + all_goals ring + +theorem braid_numerator_38 {K : Type*} [CommRing K] (q z w : K) (hq : q^8 = -1) : + coefficient (tileNumerator q (q^4) z) (tileNumerator q (q^4) (z*w)) + (tileNumerator q (q^4) w) 38 = + coefficient (tileNumerator q (q^4) w) (tileNumerator q (q^4) (z*w)) + (tileNumerator q (q^4) z) 42 := by + rw [coefficient_38, coefficient_42] + simp only [tileNumerator] + ring_nf + all_goals simp only [eighthRoot_power_9 hq, eighthRoot_power_13 hq, eighthRoot_power_15 hq, eighthRoot_power_17 hq, eighthRoot_power_19 hq, eighthRoot_power_21 hq, eighthRoot_power_23 hq, eighthRoot_power_25 hq, eighthRoot_power_27 hq, eighthRoot_power_29 hq, eighthRoot_power_33 hq] + all_goals ring + +theorem braid_numerator_39 {K : Type*} [CommRing K] (q z w : K) (_hq : q^8 = -1) : + coefficient (tileNumerator q (q^4) z) (tileNumerator q (q^4) (z*w)) + (tileNumerator q (q^4) w) 39 = + coefficient (tileNumerator q (q^4) w) (tileNumerator q (q^4) (z*w)) + (tileNumerator q (q^4) z) 39 := by + rw [coefficient_39, coefficient_39] + simp only [tileNumerator] + ring_nf + +theorem braid_numerator_40 {K : Type*} [CommRing K] (q z w : K) (hq : q^8 = -1) : + coefficient (tileNumerator q (q^4) z) (tileNumerator q (q^4) (z*w)) + (tileNumerator q (q^4) w) 40 = + coefficient (tileNumerator q (q^4) w) (tileNumerator q (q^4) (z*w)) + (tileNumerator q (q^4) z) 17 := by + rw [coefficient_40, coefficient_17] + simp only [tileNumerator] + ring_nf + all_goals simp only [eighthRoot_power_8 hq, eighthRoot_power_10 hq, eighthRoot_power_12 hq, eighthRoot_power_14 hq, eighthRoot_power_16 hq, eighthRoot_power_18 hq, eighthRoot_power_20 hq, eighthRoot_power_22 hq, eighthRoot_power_24 hq, eighthRoot_power_26 hq, eighthRoot_power_28 hq, eighthRoot_power_30 hq, eighthRoot_power_32 hq, eighthRoot_power_34 hq, eighthRoot_power_38 hq] + all_goals ring + +theorem braid_numerator_41 {K : Type*} [CommRing K] (q z w : K) (hq : q^8 = -1) : + coefficient (tileNumerator q (q^4) z) (tileNumerator q (q^4) (z*w)) + (tileNumerator q (q^4) w) 41 = + coefficient (tileNumerator q (q^4) w) (tileNumerator q (q^4) (z*w)) + (tileNumerator q (q^4) z) 35 := by + rw [coefficient_41, coefficient_35] + simp only [tileNumerator] + ring_nf + all_goals simp only [eighthRoot_power_10 hq, eighthRoot_power_12 hq, eighthRoot_power_14 hq, eighthRoot_power_16 hq, eighthRoot_power_18 hq, eighthRoot_power_20 hq, eighthRoot_power_22 hq, eighthRoot_power_24 hq, eighthRoot_power_26 hq, eighthRoot_power_28 hq, eighthRoot_power_30 hq, eighthRoot_power_32 hq, eighthRoot_power_36 hq] + all_goals ring + +theorem braid_numerator_42 {K : Type*} [CommRing K] (q z w : K) (hq : q^8 = -1) : + coefficient (tileNumerator q (q^4) z) (tileNumerator q (q^4) (z*w)) + (tileNumerator q (q^4) w) 42 = + coefficient (tileNumerator q (q^4) w) (tileNumerator q (q^4) (z*w)) + (tileNumerator q (q^4) z) 38 := by + rw [coefficient_42, coefficient_38] + simp only [tileNumerator] + ring_nf + all_goals simp only [eighthRoot_power_9 hq, eighthRoot_power_13 hq, eighthRoot_power_15 hq, eighthRoot_power_17 hq, eighthRoot_power_19 hq, eighthRoot_power_21 hq, eighthRoot_power_23 hq, eighthRoot_power_25 hq, eighthRoot_power_27 hq, eighthRoot_power_29 hq, eighthRoot_power_33 hq] + all_goals ring + +theorem braid_numerator_43 {K : Type*} [CommRing K] (q z w : K) (_hq : q^8 = -1) : + coefficient (tileNumerator q (q^4) z) (tileNumerator q (q^4) (z*w)) + (tileNumerator q (q^4) w) 43 = + coefficient (tileNumerator q (q^4) w) (tileNumerator q (q^4) (z*w)) + (tileNumerator q (q^4) z) 27 := by + rw [coefficient_43, coefficient_27] + simp only [tileNumerator] + ring_nf + +theorem braid_numerator_44 {K : Type*} [CommRing K] (q z w : K) (hq : q^8 = -1) : + coefficient (tileNumerator q (q^4) z) (tileNumerator q (q^4) (z*w)) + (tileNumerator q (q^4) w) 44 = + coefficient (tileNumerator q (q^4) w) (tileNumerator q (q^4) (z*w)) + (tileNumerator q (q^4) z) 30 := by + rw [coefficient_44, coefficient_30] + simp only [tileNumerator] + ring_nf + all_goals simp only [eighthRoot_power_11 hq, eighthRoot_power_13 hq, eighthRoot_power_15 hq, eighthRoot_power_17 hq, eighthRoot_power_19 hq, eighthRoot_power_21 hq, eighthRoot_power_23 hq, eighthRoot_power_25 hq, eighthRoot_power_27 hq, eighthRoot_power_29 hq, eighthRoot_power_31 hq] + all_goals ring + +theorem braid_numerator_45 {K : Type*} [CommRing K] (q z w : K) (hq : q^8 = -1) : + coefficient (tileNumerator q (q^4) z) (tileNumerator q (q^4) (z*w)) + (tileNumerator q (q^4) w) 45 = + coefficient (tileNumerator q (q^4) w) (tileNumerator q (q^4) (z*w)) + (tileNumerator q (q^4) z) 23 := by + rw [coefficient_45, coefficient_23] + simp only [tileNumerator] + ring_nf + all_goals simp only [eighthRoot_power_10 hq, eighthRoot_power_12 hq, eighthRoot_power_14 hq, eighthRoot_power_16 hq, eighthRoot_power_18 hq, eighthRoot_power_20 hq, eighthRoot_power_22 hq, eighthRoot_power_24 hq, eighthRoot_power_26 hq, eighthRoot_power_28 hq, eighthRoot_power_30 hq, eighthRoot_power_32 hq, eighthRoot_power_36 hq] + all_goals ring + +theorem braid_numerator_46 {K : Type*} [CommRing K] (q z w : K) (hq : q^8 = -1) : + coefficient (tileNumerator q (q^4) z) (tileNumerator q (q^4) (z*w)) + (tileNumerator q (q^4) w) 46 = + coefficient (tileNumerator q (q^4) w) (tileNumerator q (q^4) (z*w)) + (tileNumerator q (q^4) z) 14 := by + rw [coefficient_46, coefficient_14] + simp only [tileNumerator] + ring_nf + all_goals simp only [eighthRoot_power_8 hq, eighthRoot_power_10 hq, eighthRoot_power_12 hq, eighthRoot_power_14 hq, eighthRoot_power_16 hq, eighthRoot_power_18 hq, eighthRoot_power_20 hq, eighthRoot_power_22 hq, eighthRoot_power_24 hq, eighthRoot_power_26 hq, eighthRoot_power_28 hq, eighthRoot_power_30 hq, eighthRoot_power_32 hq, eighthRoot_power_34 hq, eighthRoot_power_38 hq] + all_goals ring + +theorem braid_numerator_47 {K : Type*} [CommRing K] (q z w : K) (hq : q^8 = -1) : + coefficient (tileNumerator q (q^4) z) (tileNumerator q (q^4) (z*w)) + (tileNumerator q (q^4) w) 47 = + coefficient (tileNumerator q (q^4) w) (tileNumerator q (q^4) (z*w)) + (tileNumerator q (q^4) z) 22 := by + rw [coefficient_47, coefficient_22] + simp only [tileNumerator] + ring_nf + all_goals simp only [eighthRoot_power_11 hq, eighthRoot_power_13 hq, eighthRoot_power_15 hq, eighthRoot_power_17 hq, eighthRoot_power_19 hq, eighthRoot_power_21 hq, eighthRoot_power_23 hq, eighthRoot_power_25 hq, eighthRoot_power_27 hq, eighthRoot_power_29 hq, eighthRoot_power_31 hq, eighthRoot_power_35 hq] + all_goals ring + +theorem braid_numerator_48 {K : Type*} [CommRing K] (q z w : K) (hq : q^8 = -1) : + coefficient (tileNumerator q (q^4) z) (tileNumerator q (q^4) (z*w)) + (tileNumerator q (q^4) w) 48 = + coefficient (tileNumerator q (q^4) w) (tileNumerator q (q^4) (z*w)) + (tileNumerator q (q^4) z) 50 := by + rw [coefficient_48, coefficient_50] + simp only [tileNumerator] + ring_nf + all_goals simp only [eighthRoot_power_11 hq, eighthRoot_power_13 hq, eighthRoot_power_15 hq, eighthRoot_power_17 hq, eighthRoot_power_19 hq, eighthRoot_power_21 hq, eighthRoot_power_23 hq, eighthRoot_power_25 hq, eighthRoot_power_27 hq, eighthRoot_power_29 hq, eighthRoot_power_31 hq, eighthRoot_power_35 hq] + all_goals ring + +theorem braid_numerator_49 {K : Type*} [CommRing K] (q z w : K) (hq : q^8 = -1) : + coefficient (tileNumerator q (q^4) z) (tileNumerator q (q^4) (z*w)) + (tileNumerator q (q^4) w) 49 = + coefficient (tileNumerator q (q^4) w) (tileNumerator q (q^4) (z*w)) + (tileNumerator q (q^4) z) 49 := by + rw [coefficient_49, coefficient_49] + simp only [tileNumerator] + ring_nf + all_goals simp only [eighthRoot_power_9 hq, eighthRoot_power_13 hq, eighthRoot_power_15 hq, eighthRoot_power_17 hq, eighthRoot_power_19 hq, eighthRoot_power_21 hq, eighthRoot_power_23 hq, eighthRoot_power_25 hq, eighthRoot_power_27 hq, eighthRoot_power_29 hq, eighthRoot_power_33 hq] + all_goals ring + +theorem braid_numerator_50 {K : Type*} [CommRing K] (q z w : K) (hq : q^8 = -1) : + coefficient (tileNumerator q (q^4) z) (tileNumerator q (q^4) (z*w)) + (tileNumerator q (q^4) w) 50 = + coefficient (tileNumerator q (q^4) w) (tileNumerator q (q^4) (z*w)) + (tileNumerator q (q^4) z) 48 := by + rw [coefficient_50, coefficient_48] + simp only [tileNumerator] + ring_nf + all_goals simp only [eighthRoot_power_11 hq, eighthRoot_power_13 hq, eighthRoot_power_15 hq, eighthRoot_power_17 hq, eighthRoot_power_19 hq, eighthRoot_power_21 hq, eighthRoot_power_23 hq, eighthRoot_power_25 hq, eighthRoot_power_27 hq, eighthRoot_power_29 hq, eighthRoot_power_31 hq, eighthRoot_power_35 hq] + all_goals ring + +theorem braid_numerator {K : Type*} [CommRing K] (q z w : K) (hq : q^8 = -1) (k : Fin 51) : + coefficient (tileNumerator q (q^4) z) (tileNumerator q (q^4) (z*w)) + (tileNumerator q (q^4) w) k = + coefficient (tileNumerator q (q^4) w) (tileNumerator q (q^4) (z*w)) + (tileNumerator q (q^4) z) (mirrorIndex k) := by + fin_cases k + · exact braid_numerator_0 q z w hq + · exact braid_numerator_1 q z w hq + · exact braid_numerator_2 q z w hq + · exact braid_numerator_3 q z w hq + · exact braid_numerator_4 q z w hq + · exact braid_numerator_5 q z w hq + · exact braid_numerator_6 q z w hq + · exact braid_numerator_7 q z w hq + · exact braid_numerator_8 q z w hq + · exact braid_numerator_9 q z w hq + · exact braid_numerator_10 q z w hq + · exact braid_numerator_11 q z w hq + · exact braid_numerator_12 q z w hq + · exact braid_numerator_13 q z w hq + · exact braid_numerator_14 q z w hq + · exact braid_numerator_15 q z w hq + · exact braid_numerator_16 q z w hq + · exact braid_numerator_17 q z w hq + · exact braid_numerator_18 q z w hq + · exact braid_numerator_19 q z w hq + · exact braid_numerator_20 q z w hq + · exact braid_numerator_21 q z w hq + · exact braid_numerator_22 q z w hq + · exact braid_numerator_23 q z w hq + · exact braid_numerator_24 q z w hq + · exact braid_numerator_25 q z w hq + · exact braid_numerator_26 q z w hq + · exact braid_numerator_27 q z w hq + · exact braid_numerator_28 q z w hq + · exact braid_numerator_29 q z w hq + · exact braid_numerator_30 q z w hq + · exact braid_numerator_31 q z w hq + · exact braid_numerator_32 q z w hq + · exact braid_numerator_33 q z w hq + · exact braid_numerator_34 q z w hq + · exact braid_numerator_35 q z w hq + · exact braid_numerator_36 q z w hq + · exact braid_numerator_37 q z w hq + · exact braid_numerator_38 q z w hq + · exact braid_numerator_39 q z w hq + · exact braid_numerator_40 q z w hq + · exact braid_numerator_41 q z w hq + · exact braid_numerator_42 q z w hq + · exact braid_numerator_43 q z w hq + · exact braid_numerator_44 q z w hq + · exact braid_numerator_45 q z w hq + · exact braid_numerator_46 q z w hq + · exact braid_numerator_47 q z w hq + · exact braid_numerator_48 q z w hq + · exact braid_numerator_49 q z w hq + · exact braid_numerator_50 q z w hq + +end +end CriticalStrip.Diagram.ThreeBox + +end OAI diff --git a/lean/OAI/Combinatorics/StripMass/ThreeBoxCertificates.lean b/lean/OAI/Combinatorics/StripMass/ThreeBoxCertificates.lean new file mode 100644 index 0000000000000000000000000000000000000000..9db9b4e0c8cf1e47fd3f87506c78e29da86f0144 --- /dev/null +++ b/lean/OAI/Combinatorics/StripMass/ThreeBoxCertificates.lean @@ -0,0 +1,390 @@ +import Mathlib +import OAI.Combinatorics.StripMass.PatchReplacement + +namespace OAI + +/-! Critical honeycomb strip paths, polynomial identities and crossing mass. -/ + + + +namespace CriticalStrip.Diagram.ThreeBox +noncomputable section + + + +def rootTable : Config → Fin 12 → Fin 12 + | (.vacant,.vacant,.vacant) => ![0,1,2,3,4,5,6,7,8,9,10,11] + | (.vacant,.vacant,.cup) => ![0,1,2,3,4,5,6,7,8,9,10,10] + | (.vacant,.vertical₀,.vacant) => ![0,1,2,3,4,5,4,7,8,9,10,11] + | (.vacant,.vertical₀,.cup) => ![0,1,2,3,4,5,4,7,8,9,10,10] + | (.vacant,.diagonal₀,.vertical₀) => ![0,1,2,3,4,5,6,4,4,9,4,11] + | (.vacant,.diagonal₀,.diagonal₀) => ![0,1,2,3,4,5,6,4,4,9,10,4] + | (.vacant,.cup,.vertical₀) => ![0,1,2,3,4,5,6,6,6,9,6,11] + | (.vacant,.cup,.diagonal₀) => ![0,1,2,3,4,5,6,6,6,9,10,6] + | (.vertical₀,.vertical₁,.vertical₀) => ![0,1,0,3,4,0,6,0,0,9,0,11] + | (.vertical₀,.vertical₁,.diagonal₀) => ![0,1,0,3,4,0,6,0,0,9,10,0] + | (.vertical₀,.diagonal₁,.vacant) => ![0,1,0,3,4,0,0,7,8,9,10,11] + | (.vertical₀,.diagonal₁,.cup) => ![0,1,0,3,4,0,0,7,8,9,10,10] + | (.vertical₀,.cap,.vacant) => ![0,1,0,3,0,0,6,7,8,9,10,11] + | (.vertical₀,.cap,.cup) => ![0,1,0,3,0,0,6,7,8,9,10,10] + | (.vertical₀,.verticalPair,.vertical₀) => ![0,1,0,3,4,0,4,0,0,9,0,11] + | (.vertical₀,.verticalPair,.diagonal₀) => ![0,1,0,3,4,0,4,0,0,9,10,0] + | (.vertical₀,.capCup,.vertical₀) => ![0,1,0,3,0,0,6,6,6,9,6,11] + | (.vertical₀,.capCup,.diagonal₀) => ![0,1,0,3,0,0,6,6,6,9,10,6] + | (.vertical₁,.vacant,.vertical₁) => ![0,1,2,1,4,5,6,7,8,1,10,1] + | (.vertical₁,.vacant,.diagonal₁) => ![0,1,2,1,4,5,6,7,8,1,1,11] + | (.vertical₁,.vertical₀,.vertical₁) => ![0,1,2,1,4,5,4,7,8,1,10,1] + | (.vertical₁,.vertical₀,.diagonal₁) => ![0,1,2,1,4,5,4,7,8,1,1,11] + | (.vertical₁,.diagonal₀,.cap) => ![0,1,2,1,1,5,6,1,1,1,10,11] + | (.vertical₁,.diagonal₀,.verticalPair) => ![0,1,2,1,4,5,6,4,4,1,4,1] + | (.vertical₁,.diagonal₀,.capCup) => ![0,1,2,1,1,5,6,1,1,1,10,10] + | (.vertical₁,.cup,.cap) => ![0,1,2,1,4,5,1,1,1,1,10,11] + | (.vertical₁,.cup,.verticalPair) => ![0,1,2,1,4,5,6,6,6,1,6,1] + | (.vertical₁,.cup,.capCup) => ![0,1,2,1,4,5,1,1,1,1,10,10] + | (.diagonal₀,.vacant,.vertical₁) => ![0,1,2,0,4,5,6,7,8,0,10,0] + | (.diagonal₀,.vacant,.diagonal₁) => ![0,1,2,0,4,5,6,7,8,0,0,11] + | (.diagonal₀,.vertical₀,.vertical₁) => ![0,1,2,0,4,5,4,7,8,0,10,0] + | (.diagonal₀,.vertical₀,.diagonal₁) => ![0,1,2,0,4,5,4,7,8,0,0,11] + | (.diagonal₀,.diagonal₀,.cap) => ![0,1,2,0,0,5,6,0,0,0,10,11] + | (.diagonal₀,.diagonal₀,.verticalPair) => ![0,1,2,0,4,5,6,4,4,0,4,0] + | (.diagonal₀,.diagonal₀,.capCup) => ![0,1,2,0,0,5,6,0,0,0,10,10] + | (.diagonal₀,.cup,.cap) => ![0,1,2,0,4,5,0,0,0,0,10,11] + | (.diagonal₀,.cup,.verticalPair) => ![0,1,2,0,4,5,6,6,6,0,6,0] + | (.diagonal₀,.cup,.capCup) => ![0,1,2,0,4,5,0,0,0,0,10,10] + | (.diagonal₁,.vertical₁,.vertical₀) => ![0,1,1,3,4,1,6,1,1,9,1,11] + | (.diagonal₁,.vertical₁,.diagonal₀) => ![0,1,1,3,4,1,6,1,1,9,10,1] + | (.diagonal₁,.diagonal₁,.vacant) => ![0,1,1,3,4,1,1,7,8,9,10,11] + | (.diagonal₁,.diagonal₁,.cup) => ![0,1,1,3,4,1,1,7,8,9,10,10] + | (.diagonal₁,.cap,.vacant) => ![0,1,1,3,1,1,6,7,8,9,10,11] + | (.diagonal₁,.cap,.cup) => ![0,1,1,3,1,1,6,7,8,9,10,10] + | (.diagonal₁,.verticalPair,.vertical₀) => ![0,1,1,3,4,1,4,1,1,9,1,11] + | (.diagonal₁,.verticalPair,.diagonal₀) => ![0,1,1,3,4,1,4,1,1,9,10,1] + | (.diagonal₁,.capCup,.vertical₀) => ![0,1,1,3,1,1,6,6,6,9,6,11] + | (.diagonal₁,.capCup,.diagonal₀) => ![0,1,1,3,1,1,6,6,6,9,10,6] + | (.cap,.vacant,.vacant) => ![0,0,2,3,4,5,6,7,8,9,10,11] + | (.cap,.vacant,.cup) => ![0,0,2,3,4,5,6,7,8,9,10,10] + | (.cap,.vertical₀,.vacant) => ![0,0,2,3,4,5,4,7,8,9,10,11] + | (.cap,.vertical₀,.cup) => ![0,0,2,3,4,5,4,7,8,9,10,10] + | (.cap,.diagonal₀,.vertical₀) => ![0,0,2,3,4,5,6,4,4,9,4,11] + | (.cap,.diagonal₀,.diagonal₀) => ![0,0,2,3,4,5,6,4,4,9,10,4] + | (.cap,.cup,.vertical₀) => ![0,0,2,3,4,5,6,6,6,9,6,11] + | (.cap,.cup,.diagonal₀) => ![0,0,2,3,4,5,6,6,6,9,10,6] + | (.cup,.vertical₁,.cap) => ![0,1,2,2,4,2,6,2,2,2,10,11] + | (.cup,.vertical₁,.verticalPair) => ![0,1,2,2,4,2,6,2,2,2,2,2] + | (.cup,.vertical₁,.capCup) => ![0,1,2,2,4,2,6,2,2,2,10,10] + | (.cup,.diagonal₁,.vertical₁) => ![0,1,2,2,4,2,2,7,8,2,10,2] + | (.cup,.diagonal₁,.diagonal₁) => ![0,1,2,2,4,2,2,7,8,2,2,11] + | (.cup,.cap,.vertical₁) => ![0,1,2,2,2,2,6,7,8,2,10,2] + | (.cup,.cap,.diagonal₁) => ![0,1,2,2,2,2,6,7,8,2,2,11] + | (.cup,.verticalPair,.cap) => ![0,1,2,2,4,2,4,2,2,2,10,11] + | (.cup,.verticalPair,.verticalPair) => ![0,1,2,2,4,2,4,2,2,2,2,2] + | (.cup,.verticalPair,.capCup) => ![0,1,2,2,4,2,4,2,2,2,10,10] + | (.cup,.capCup,.cap) => ![0,1,2,2,2,2,2,2,2,2,10,11] + | (.cup,.capCup,.verticalPair) => ![0,1,2,2,2,2,6,6,6,2,6,2] + | (.cup,.capCup,.capCup) => ![0,1,2,2,2,2,2,2,2,2,10,10] + | (.verticalPair,.vertical₁,.cap) => ![0,0,0,0,4,0,6,0,0,0,10,11] + | (.verticalPair,.vertical₁,.verticalPair) => ![0,1,0,1,4,0,6,0,0,1,0,1] + | (.verticalPair,.vertical₁,.capCup) => ![0,0,0,0,4,0,6,0,0,0,10,10] + | (.verticalPair,.diagonal₁,.vertical₁) => ![0,1,0,1,4,0,0,7,8,1,10,1] + | (.verticalPair,.diagonal₁,.diagonal₁) => ![0,1,0,1,4,0,0,7,8,1,1,11] + | (.verticalPair,.cap,.vertical₁) => ![0,1,0,1,0,0,6,7,8,1,10,1] + | (.verticalPair,.cap,.diagonal₁) => ![0,1,0,1,0,0,6,7,8,1,1,11] + | (.verticalPair,.verticalPair,.cap) => ![0,0,0,0,4,0,4,0,0,0,10,11] + | (.verticalPair,.verticalPair,.verticalPair) => ![0,1,0,1,4,0,4,0,0,1,0,1] + | (.verticalPair,.verticalPair,.capCup) => ![0,0,0,0,4,0,4,0,0,0,10,10] + | (.verticalPair,.capCup,.cap) => ![0,1,0,1,0,0,1,1,1,1,10,11] + | (.verticalPair,.capCup,.verticalPair) => ![0,1,0,1,0,0,6,6,6,1,6,1] + | (.verticalPair,.capCup,.capCup) => ![0,1,0,1,0,0,1,1,1,1,10,10] + | (.capCup,.vertical₁,.cap) => ![0,0,2,2,4,2,6,2,2,2,10,11] + | (.capCup,.vertical₁,.verticalPair) => ![0,0,2,2,4,2,6,2,2,2,2,2] + | (.capCup,.vertical₁,.capCup) => ![0,0,2,2,4,2,6,2,2,2,10,10] + | (.capCup,.diagonal₁,.vertical₁) => ![0,0,2,2,4,2,2,7,8,2,10,2] + | (.capCup,.diagonal₁,.diagonal₁) => ![0,0,2,2,4,2,2,7,8,2,2,11] + | (.capCup,.cap,.vertical₁) => ![0,0,2,2,2,2,6,7,8,2,10,2] + | (.capCup,.cap,.diagonal₁) => ![0,0,2,2,2,2,6,7,8,2,2,11] + | (.capCup,.verticalPair,.cap) => ![0,0,2,2,4,2,4,2,2,2,10,11] + | (.capCup,.verticalPair,.verticalPair) => ![0,0,2,2,4,2,4,2,2,2,2,2] + | (.capCup,.verticalPair,.capCup) => ![0,0,2,2,4,2,4,2,2,2,10,10] + | (.capCup,.capCup,.cap) => ![0,0,2,2,2,2,2,2,2,2,10,11] + | (.capCup,.capCup,.verticalPair) => ![0,0,2,2,2,2,6,6,6,2,6,2] + | (.capCup,.capCup,.capCup) => ![0,0,2,2,2,2,2,2,2,2,10,10] + | _ => fun i => i + +def parentTable : Config → Fin 12 → Fin 12 + | (.vacant,.vacant,.vacant) => ![0,1,2,3,4,5,6,7,8,9,10,11] + | (.vacant,.vacant,.cup) => ![0,1,2,3,4,5,6,7,8,9,10,10] + | (.vacant,.vertical₀,.vacant) => ![0,1,2,3,4,5,4,7,8,9,10,11] + | (.vacant,.vertical₀,.cup) => ![0,1,2,3,4,5,4,7,8,9,10,10] + | (.vacant,.diagonal₀,.vertical₀) => ![0,1,2,3,4,5,6,4,7,9,8,11] + | (.vacant,.diagonal₀,.diagonal₀) => ![0,1,2,3,4,5,6,4,7,9,10,8] + | (.vacant,.cup,.vertical₀) => ![0,1,2,3,4,5,6,6,7,9,8,11] + | (.vacant,.cup,.diagonal₀) => ![0,1,2,3,4,5,6,6,7,9,10,8] + | (.vertical₀,.vertical₁,.vertical₀) => ![0,1,0,3,4,2,6,5,7,9,8,11] + | (.vertical₀,.vertical₁,.diagonal₀) => ![0,1,0,3,4,2,6,5,7,9,10,8] + | (.vertical₀,.diagonal₁,.vacant) => ![0,1,0,3,4,2,5,7,8,9,10,11] + | (.vertical₀,.diagonal₁,.cup) => ![0,1,0,3,4,2,5,7,8,9,10,10] + | (.vertical₀,.cap,.vacant) => ![0,1,0,3,5,2,6,7,8,9,10,11] + | (.vertical₀,.cap,.cup) => ![0,1,0,3,5,2,6,7,8,9,10,10] + | (.vertical₀,.verticalPair,.vertical₀) => ![0,1,0,3,4,2,4,5,7,9,8,11] + | (.vertical₀,.verticalPair,.diagonal₀) => ![0,1,0,3,4,2,4,5,7,9,10,8] + | (.vertical₀,.capCup,.vertical₀) => ![0,1,0,3,5,2,6,6,7,9,8,11] + | (.vertical₀,.capCup,.diagonal₀) => ![0,1,0,3,5,2,6,6,7,9,10,8] + | (.vertical₁,.vacant,.vertical₁) => ![0,1,2,1,4,5,6,7,8,3,10,9] + | (.vertical₁,.vacant,.diagonal₁) => ![0,1,2,1,4,5,6,7,8,3,9,11] + | (.vertical₁,.vertical₀,.vertical₁) => ![0,1,2,1,4,5,4,7,8,3,10,9] + | (.vertical₁,.vertical₀,.diagonal₁) => ![0,1,2,1,4,5,4,7,8,3,9,11] + | (.vertical₁,.diagonal₀,.cap) => ![0,1,2,1,7,5,6,8,9,3,10,11] + | (.vertical₁,.diagonal₀,.verticalPair) => ![0,1,2,1,4,5,6,4,7,3,8,9] + | (.vertical₁,.diagonal₀,.capCup) => ![0,1,2,1,7,5,6,8,9,3,10,10] + | (.vertical₁,.cup,.cap) => ![0,1,2,1,4,5,7,8,9,3,10,11] + | (.vertical₁,.cup,.verticalPair) => ![0,1,2,1,4,5,6,6,7,3,8,9] + | (.vertical₁,.cup,.capCup) => ![0,1,2,1,4,5,7,8,9,3,10,10] + | (.diagonal₀,.vacant,.vertical₁) => ![0,1,2,0,4,5,6,7,8,3,10,9] + | (.diagonal₀,.vacant,.diagonal₁) => ![0,1,2,0,4,5,6,7,8,3,9,11] + | (.diagonal₀,.vertical₀,.vertical₁) => ![0,1,2,0,4,5,4,7,8,3,10,9] + | (.diagonal₀,.vertical₀,.diagonal₁) => ![0,1,2,0,4,5,4,7,8,3,9,11] + | (.diagonal₀,.diagonal₀,.cap) => ![0,1,2,0,7,5,6,8,9,3,10,11] + | (.diagonal₀,.diagonal₀,.verticalPair) => ![0,1,2,0,4,5,6,4,7,3,8,9] + | (.diagonal₀,.diagonal₀,.capCup) => ![0,1,2,0,7,5,6,8,9,3,10,10] + | (.diagonal₀,.cup,.cap) => ![0,1,2,0,4,5,7,8,9,3,10,11] + | (.diagonal₀,.cup,.verticalPair) => ![0,1,2,0,4,5,6,6,7,3,8,9] + | (.diagonal₀,.cup,.capCup) => ![0,1,2,0,4,5,7,8,9,3,10,10] + | (.diagonal₁,.vertical₁,.vertical₀) => ![0,1,1,3,4,2,6,5,7,9,8,11] + | (.diagonal₁,.vertical₁,.diagonal₀) => ![0,1,1,3,4,2,6,5,7,9,10,8] + | (.diagonal₁,.diagonal₁,.vacant) => ![0,1,1,3,4,2,5,7,8,9,10,11] + | (.diagonal₁,.diagonal₁,.cup) => ![0,1,1,3,4,2,5,7,8,9,10,10] + | (.diagonal₁,.cap,.vacant) => ![0,1,1,3,5,2,6,7,8,9,10,11] + | (.diagonal₁,.cap,.cup) => ![0,1,1,3,5,2,6,7,8,9,10,10] + | (.diagonal₁,.verticalPair,.vertical₀) => ![0,1,1,3,4,2,4,5,7,9,8,11] + | (.diagonal₁,.verticalPair,.diagonal₀) => ![0,1,1,3,4,2,4,5,7,9,10,8] + | (.diagonal₁,.capCup,.vertical₀) => ![0,1,1,3,5,2,6,6,7,9,8,11] + | (.diagonal₁,.capCup,.diagonal₀) => ![0,1,1,3,5,2,6,6,7,9,10,8] + | (.cap,.vacant,.vacant) => ![0,0,2,3,4,5,6,7,8,9,10,11] + | (.cap,.vacant,.cup) => ![0,0,2,3,4,5,6,7,8,9,10,10] + | (.cap,.vertical₀,.vacant) => ![0,0,2,3,4,5,4,7,8,9,10,11] + | (.cap,.vertical₀,.cup) => ![0,0,2,3,4,5,4,7,8,9,10,10] + | (.cap,.diagonal₀,.vertical₀) => ![0,0,2,3,4,5,6,4,7,9,8,11] + | (.cap,.diagonal₀,.diagonal₀) => ![0,0,2,3,4,5,6,4,7,9,10,8] + | (.cap,.cup,.vertical₀) => ![0,0,2,3,4,5,6,6,7,9,8,11] + | (.cap,.cup,.diagonal₀) => ![0,0,2,3,4,5,6,6,7,9,10,8] + | (.cup,.vertical₁,.cap) => ![0,1,2,2,4,2,6,5,9,3,10,11] + | (.cup,.vertical₁,.verticalPair) => ![0,1,2,2,4,2,6,5,7,3,8,9] + | (.cup,.vertical₁,.capCup) => ![0,1,2,2,4,2,6,5,9,3,10,10] + | (.cup,.diagonal₁,.vertical₁) => ![0,1,2,2,4,2,5,7,8,3,10,9] + | (.cup,.diagonal₁,.diagonal₁) => ![0,1,2,2,4,2,5,7,8,3,9,11] + | (.cup,.cap,.vertical₁) => ![0,1,2,2,5,2,6,7,8,3,10,9] + | (.cup,.cap,.diagonal₁) => ![0,1,2,2,5,2,6,7,8,3,9,11] + | (.cup,.verticalPair,.cap) => ![0,1,2,2,4,2,4,5,9,3,10,11] + | (.cup,.verticalPair,.verticalPair) => ![0,1,2,2,4,2,4,5,7,3,8,9] + | (.cup,.verticalPair,.capCup) => ![0,1,2,2,4,2,4,5,9,3,10,10] + | (.cup,.capCup,.cap) => ![0,1,2,2,5,2,7,8,9,3,10,11] + | (.cup,.capCup,.verticalPair) => ![0,1,2,2,5,2,6,6,7,3,8,9] + | (.cup,.capCup,.capCup) => ![0,1,2,2,5,2,7,8,9,3,10,10] + | (.verticalPair,.vertical₁,.cap) => ![0,3,0,9,4,2,6,5,7,8,10,11] + | (.verticalPair,.vertical₁,.verticalPair) => ![0,1,0,1,4,2,6,5,7,3,8,9] + | (.verticalPair,.vertical₁,.capCup) => ![0,3,0,9,4,2,6,5,7,8,10,10] + | (.verticalPair,.diagonal₁,.vertical₁) => ![0,1,0,1,4,2,5,7,8,3,10,9] + | (.verticalPair,.diagonal₁,.diagonal₁) => ![0,1,0,1,4,2,5,7,8,3,9,11] + | (.verticalPair,.cap,.vertical₁) => ![0,1,0,1,5,2,6,7,8,3,10,9] + | (.verticalPair,.cap,.diagonal₁) => ![0,1,0,1,5,2,6,7,8,3,9,11] + | (.verticalPair,.verticalPair,.cap) => ![0,3,0,9,4,2,4,5,7,8,10,11] + | (.verticalPair,.verticalPair,.verticalPair) => ![0,1,0,1,4,2,4,5,7,3,8,9] + | (.verticalPair,.verticalPair,.capCup) => ![0,3,0,9,4,2,4,5,7,8,10,10] + | (.verticalPair,.capCup,.cap) => ![0,1,0,1,5,2,7,8,9,3,10,11] + | (.verticalPair,.capCup,.verticalPair) => ![0,1,0,1,5,2,6,6,7,3,8,9] + | (.verticalPair,.capCup,.capCup) => ![0,1,0,1,5,2,7,8,9,3,10,10] + | (.capCup,.vertical₁,.cap) => ![0,0,2,2,4,2,6,5,9,3,10,11] + | (.capCup,.vertical₁,.verticalPair) => ![0,0,2,2,4,2,6,5,7,3,8,9] + | (.capCup,.vertical₁,.capCup) => ![0,0,2,2,4,2,6,5,9,3,10,10] + | (.capCup,.diagonal₁,.vertical₁) => ![0,0,2,2,4,2,5,7,8,3,10,9] + | (.capCup,.diagonal₁,.diagonal₁) => ![0,0,2,2,4,2,5,7,8,3,9,11] + | (.capCup,.cap,.vertical₁) => ![0,0,2,2,5,2,6,7,8,3,10,9] + | (.capCup,.cap,.diagonal₁) => ![0,0,2,2,5,2,6,7,8,3,9,11] + | (.capCup,.verticalPair,.cap) => ![0,0,2,2,4,2,4,5,9,3,10,11] + | (.capCup,.verticalPair,.verticalPair) => ![0,0,2,2,4,2,4,5,7,3,8,9] + | (.capCup,.verticalPair,.capCup) => ![0,0,2,2,4,2,4,5,9,3,10,10] + | (.capCup,.capCup,.cap) => ![0,0,2,2,5,2,7,8,9,3,10,11] + | (.capCup,.capCup,.verticalPair) => ![0,0,2,2,5,2,6,6,7,3,8,9] + | (.capCup,.capCup,.capCup) => ![0,0,2,2,5,2,7,8,9,3,10,10] + | _ => fun i => i + +def rankTable : Config → Fin 12 → ℕ + | (.vacant,.vacant,.vacant) => ![0,0,0,0,0,0,0,0,0,0,0,0] + | (.vacant,.vacant,.cup) => ![0,0,0,0,0,0,0,0,0,0,0,1] + | (.vacant,.vertical₀,.vacant) => ![0,0,0,0,0,0,1,0,0,0,0,0] + | (.vacant,.vertical₀,.cup) => ![0,0,0,0,0,0,1,0,0,0,0,1] + | (.vacant,.diagonal₀,.vertical₀) => ![0,0,0,0,0,0,0,1,2,0,3,0] + | (.vacant,.diagonal₀,.diagonal₀) => ![0,0,0,0,0,0,0,1,2,0,0,3] + | (.vacant,.cup,.vertical₀) => ![0,0,0,0,0,0,0,1,2,0,3,0] + | (.vacant,.cup,.diagonal₀) => ![0,0,0,0,0,0,0,1,2,0,0,3] + | (.vertical₀,.vertical₁,.vertical₀) => ![0,0,1,0,0,2,0,3,4,0,5,0] + | (.vertical₀,.vertical₁,.diagonal₀) => ![0,0,1,0,0,2,0,3,4,0,0,5] + | (.vertical₀,.diagonal₁,.vacant) => ![0,0,1,0,0,2,3,0,0,0,0,0] + | (.vertical₀,.diagonal₁,.cup) => ![0,0,1,0,0,2,3,0,0,0,0,1] + | (.vertical₀,.cap,.vacant) => ![0,0,1,0,3,2,0,0,0,0,0,0] + | (.vertical₀,.cap,.cup) => ![0,0,1,0,3,2,0,0,0,0,0,1] + | (.vertical₀,.verticalPair,.vertical₀) => ![0,0,1,0,0,2,1,3,4,0,5,0] + | (.vertical₀,.verticalPair,.diagonal₀) => ![0,0,1,0,0,2,1,3,4,0,0,5] + | (.vertical₀,.capCup,.vertical₀) => ![0,0,1,0,3,2,0,1,2,0,3,0] + | (.vertical₀,.capCup,.diagonal₀) => ![0,0,1,0,3,2,0,1,2,0,0,3] + | (.vertical₁,.vacant,.vertical₁) => ![0,0,0,1,0,0,0,0,0,2,0,3] + | (.vertical₁,.vacant,.diagonal₁) => ![0,0,0,1,0,0,0,0,0,2,3,0] + | (.vertical₁,.vertical₀,.vertical₁) => ![0,0,0,1,0,0,1,0,0,2,0,3] + | (.vertical₁,.vertical₀,.diagonal₁) => ![0,0,0,1,0,0,1,0,0,2,3,0] + | (.vertical₁,.diagonal₀,.cap) => ![0,0,0,1,5,0,0,4,3,2,0,0] + | (.vertical₁,.diagonal₀,.verticalPair) => ![0,0,0,1,0,0,0,1,2,2,3,3] + | (.vertical₁,.diagonal₀,.capCup) => ![0,0,0,1,5,0,0,4,3,2,0,1] + | (.vertical₁,.cup,.cap) => ![0,0,0,1,0,0,5,4,3,2,0,0] + | (.vertical₁,.cup,.verticalPair) => ![0,0,0,1,0,0,0,1,2,2,3,3] + | (.vertical₁,.cup,.capCup) => ![0,0,0,1,0,0,5,4,3,2,0,1] + | (.diagonal₀,.vacant,.vertical₁) => ![0,0,0,1,0,0,0,0,0,2,0,3] + | (.diagonal₀,.vacant,.diagonal₁) => ![0,0,0,1,0,0,0,0,0,2,3,0] + | (.diagonal₀,.vertical₀,.vertical₁) => ![0,0,0,1,0,0,1,0,0,2,0,3] + | (.diagonal₀,.vertical₀,.diagonal₁) => ![0,0,0,1,0,0,1,0,0,2,3,0] + | (.diagonal₀,.diagonal₀,.cap) => ![0,0,0,1,5,0,0,4,3,2,0,0] + | (.diagonal₀,.diagonal₀,.verticalPair) => ![0,0,0,1,0,0,0,1,2,2,3,3] + | (.diagonal₀,.diagonal₀,.capCup) => ![0,0,0,1,5,0,0,4,3,2,0,1] + | (.diagonal₀,.cup,.cap) => ![0,0,0,1,0,0,5,4,3,2,0,0] + | (.diagonal₀,.cup,.verticalPair) => ![0,0,0,1,0,0,0,1,2,2,3,3] + | (.diagonal₀,.cup,.capCup) => ![0,0,0,1,0,0,5,4,3,2,0,1] + | (.diagonal₁,.vertical₁,.vertical₀) => ![0,0,1,0,0,2,0,3,4,0,5,0] + | (.diagonal₁,.vertical₁,.diagonal₀) => ![0,0,1,0,0,2,0,3,4,0,0,5] + | (.diagonal₁,.diagonal₁,.vacant) => ![0,0,1,0,0,2,3,0,0,0,0,0] + | (.diagonal₁,.diagonal₁,.cup) => ![0,0,1,0,0,2,3,0,0,0,0,1] + | (.diagonal₁,.cap,.vacant) => ![0,0,1,0,3,2,0,0,0,0,0,0] + | (.diagonal₁,.cap,.cup) => ![0,0,1,0,3,2,0,0,0,0,0,1] + | (.diagonal₁,.verticalPair,.vertical₀) => ![0,0,1,0,0,2,1,3,4,0,5,0] + | (.diagonal₁,.verticalPair,.diagonal₀) => ![0,0,1,0,0,2,1,3,4,0,0,5] + | (.diagonal₁,.capCup,.vertical₀) => ![0,0,1,0,3,2,0,1,2,0,3,0] + | (.diagonal₁,.capCup,.diagonal₀) => ![0,0,1,0,3,2,0,1,2,0,0,3] + | (.cap,.vacant,.vacant) => ![0,1,0,0,0,0,0,0,0,0,0,0] + | (.cap,.vacant,.cup) => ![0,1,0,0,0,0,0,0,0,0,0,1] + | (.cap,.vertical₀,.vacant) => ![0,1,0,0,0,0,1,0,0,0,0,0] + | (.cap,.vertical₀,.cup) => ![0,1,0,0,0,0,1,0,0,0,0,1] + | (.cap,.diagonal₀,.vertical₀) => ![0,1,0,0,0,0,0,1,2,0,3,0] + | (.cap,.diagonal₀,.diagonal₀) => ![0,1,0,0,0,0,0,1,2,0,0,3] + | (.cap,.cup,.vertical₀) => ![0,1,0,0,0,0,0,1,2,0,3,0] + | (.cap,.cup,.diagonal₀) => ![0,1,0,0,0,0,0,1,2,0,0,3] + | (.cup,.vertical₁,.cap) => ![0,0,0,1,0,1,0,2,3,2,0,0] + | (.cup,.vertical₁,.verticalPair) => ![0,0,0,1,0,1,0,2,3,2,4,3] + | (.cup,.vertical₁,.capCup) => ![0,0,0,1,0,1,0,2,3,2,0,1] + | (.cup,.diagonal₁,.vertical₁) => ![0,0,0,1,0,1,2,0,0,2,0,3] + | (.cup,.diagonal₁,.diagonal₁) => ![0,0,0,1,0,1,2,0,0,2,3,0] + | (.cup,.cap,.vertical₁) => ![0,0,0,1,2,1,0,0,0,2,0,3] + | (.cup,.cap,.diagonal₁) => ![0,0,0,1,2,1,0,0,0,2,3,0] + | (.cup,.verticalPair,.cap) => ![0,0,0,1,0,1,1,2,3,2,0,0] + | (.cup,.verticalPair,.verticalPair) => ![0,0,0,1,0,1,1,2,3,2,4,3] + | (.cup,.verticalPair,.capCup) => ![0,0,0,1,0,1,1,2,3,2,0,1] + | (.cup,.capCup,.cap) => ![0,0,0,1,2,1,5,4,3,2,0,0] + | (.cup,.capCup,.verticalPair) => ![0,0,0,1,2,1,0,1,2,2,3,3] + | (.cup,.capCup,.capCup) => ![0,0,0,1,2,1,5,4,3,2,0,1] + | (.verticalPair,.vertical₁,.cap) => ![0,7,1,6,0,2,0,3,4,5,0,0] + | (.verticalPair,.vertical₁,.verticalPair) => ![0,0,1,1,0,2,0,3,4,2,5,3] + | (.verticalPair,.vertical₁,.capCup) => ![0,7,1,6,0,2,0,3,4,5,0,1] + | (.verticalPair,.diagonal₁,.vertical₁) => ![0,0,1,1,0,2,3,0,0,2,0,3] + | (.verticalPair,.diagonal₁,.diagonal₁) => ![0,0,1,1,0,2,3,0,0,2,3,0] + | (.verticalPair,.cap,.vertical₁) => ![0,0,1,1,3,2,0,0,0,2,0,3] + | (.verticalPair,.cap,.diagonal₁) => ![0,0,1,1,3,2,0,0,0,2,3,0] + | (.verticalPair,.verticalPair,.cap) => ![0,7,1,6,0,2,1,3,4,5,0,0] + | (.verticalPair,.verticalPair,.verticalPair) => ![0,0,1,1,0,2,1,3,4,2,5,3] + | (.verticalPair,.verticalPair,.capCup) => ![0,7,1,6,0,2,1,3,4,5,0,1] + | (.verticalPair,.capCup,.cap) => ![0,0,1,1,3,2,5,4,3,2,0,0] + | (.verticalPair,.capCup,.verticalPair) => ![0,0,1,1,3,2,0,1,2,2,3,3] + | (.verticalPair,.capCup,.capCup) => ![0,0,1,1,3,2,5,4,3,2,0,1] + | (.capCup,.vertical₁,.cap) => ![0,1,0,1,0,1,0,2,3,2,0,0] + | (.capCup,.vertical₁,.verticalPair) => ![0,1,0,1,0,1,0,2,3,2,4,3] + | (.capCup,.vertical₁,.capCup) => ![0,1,0,1,0,1,0,2,3,2,0,1] + | (.capCup,.diagonal₁,.vertical₁) => ![0,1,0,1,0,1,2,0,0,2,0,3] + | (.capCup,.diagonal₁,.diagonal₁) => ![0,1,0,1,0,1,2,0,0,2,3,0] + | (.capCup,.cap,.vertical₁) => ![0,1,0,1,2,1,0,0,0,2,0,3] + | (.capCup,.cap,.diagonal₁) => ![0,1,0,1,2,1,0,0,0,2,3,0] + | (.capCup,.verticalPair,.cap) => ![0,1,0,1,0,1,1,2,3,2,0,0] + | (.capCup,.verticalPair,.verticalPair) => ![0,1,0,1,0,1,1,2,3,2,4,3] + | (.capCup,.verticalPair,.capCup) => ![0,1,0,1,0,1,1,2,3,2,0,1] + | (.capCup,.capCup,.cap) => ![0,1,0,1,2,1,5,4,3,2,0,0] + | (.capCup,.capCup,.verticalPair) => ![0,1,0,1,2,1,0,1,2,2,3,3] + | (.capCup,.capCup,.capCup) => ![0,1,0,1,2,1,5,4,3,2,0,1] + | _ => fun _ => 0 + +def ForestConditions (t : Config) : Prop := + (∀ v w, Adj t v w → rootTable t v = rootTable t w) ∧ + (∀ v, v ≠ rootTable t v → Adj t v (parentTable t v)) ∧ + (∀ v, v ≠ rootTable t v → rankTable t (parentTable t v) < rankTable t v) + +instance forestConditionsDecidable (t : Config) : Decidable (ForestConditions t) := by + unfold ForestConditions; infer_instance + +theorem forestConditions_0 (x y : Tile) (h : Compatible (.vacant,x,y)) : + ForestConditions (.vacant,x,y) := by + cases x <;> cases y <;> + first | exact absurd h (by decide) | decide + +theorem forestConditions_1 (x y : Tile) (h : Compatible (.vertical₀,x,y)) : + ForestConditions (.vertical₀,x,y) := by + cases x <;> cases y <;> + first | exact absurd h (by decide) | decide + +theorem forestConditions_2 (x y : Tile) (h : Compatible (.vertical₁,x,y)) : + ForestConditions (.vertical₁,x,y) := by + cases x <;> cases y <;> + first | exact absurd h (by decide) | decide + +theorem forestConditions_3 (x y : Tile) (h : Compatible (.diagonal₀,x,y)) : + ForestConditions (.diagonal₀,x,y) := by + cases x <;> cases y <;> + first | exact absurd h (by decide) | decide + +theorem forestConditions_4 (x y : Tile) (h : Compatible (.diagonal₁,x,y)) : + ForestConditions (.diagonal₁,x,y) := by + cases x <;> cases y <;> + first | exact absurd h (by decide) | decide + +theorem forestConditions_5 (x y : Tile) (h : Compatible (.cap,x,y)) : + ForestConditions (.cap,x,y) := by + cases x <;> cases y <;> + first | exact absurd h (by decide) | decide + +theorem forestConditions_6 (x y : Tile) (h : Compatible (.cup,x,y)) : + ForestConditions (.cup,x,y) := by + cases x <;> cases y <;> + first | exact absurd h (by decide) | decide + +theorem forestConditions_7 (x y : Tile) (h : Compatible (.verticalPair,x,y)) : + ForestConditions (.verticalPair,x,y) := by + cases x <;> cases y <;> + first | exact absurd h (by decide) | decide + +theorem forestConditions_8 (x y : Tile) (h : Compatible (.capCup,x,y)) : + ForestConditions (.capCup,x,y) := by + cases x <;> cases y <;> + first | exact absurd h (by decide) | decide + +theorem forestConditions (t : Config) (h : Compatible t) : ForestConditions t := by + rcases t with ⟨t,x,y⟩ + cases t + · exact forestConditions_0 x y h + · exact forestConditions_1 x y h + · exact forestConditions_2 x y h + · exact forestConditions_3 x y h + · exact forestConditions_4 x y h + · exact forestConditions_5 x y h + · exact forestConditions_6 x y h + · exact forestConditions_7 x y h + · exact forestConditions_8 x y h + +def certificate (t : Config) (h : Compatible t) : ConnectivityCertificate (Adj t) where + root := rootTable t + parent := parentTable t + rank := rankTable t + edge_root := (forestConditions t h).1 + parent_edge := (forestConditions t h).2.1 + parent_rank := (forestConditions t h).2.2 + +theorem reach_iff_root_eq (t : Config) (h : Compatible t) (v w : Fin 12) : + Relation.ReflTransGen (Adj t) v w ↔ rootTable t v = rootTable t w := + (certificate t h).reach_iff (adj_symm t) v w + +end +end CriticalStrip.Diagram.ThreeBox + +end OAI diff --git a/lean/OAI/Combinatorics/StripMass/ThreeBoxProfiles.lean b/lean/OAI/Combinatorics/StripMass/ThreeBoxProfiles.lean new file mode 100644 index 0000000000000000000000000000000000000000..47cbe53b68505938e23bc113045a4fec7df591cc --- /dev/null +++ b/lean/OAI/Combinatorics/StripMass/ThreeBoxProfiles.lean @@ -0,0 +1,290 @@ +import Mathlib +import OAI.Combinatorics.StripMass.ThreeBoxCertificates + +namespace OAI + +/-! Critical honeycomb strip paths, polynomial identities and crossing mass. -/ + + + +namespace CriticalStrip.Diagram.ThreeBox +noncomputable section +open Finset + + + +def diagram : Fin 51 → Finset (Fin 6 × Fin 6) := ![ + ∅, + {(0,1)}, + {(0,1),(2,3)}, + {(0,1),(2,3),(4,5)}, + {(0,1),(2,4)}, + {(0,1),(2,5)}, + {(0,1),(2,5),(3,4)}, + {(0,1),(3,4)}, + {(0,1),(3,5)}, + {(0,1),(4,5)}, + {(0,2)}, + {(0,2),(3,4)}, + {(0,2),(3,5)}, + {(0,2),(4,5)}, + {(0,3)}, + {(0,3),(1,2)}, + {(0,3),(1,2),(4,5)}, + {(0,3),(1,4)}, + {(0,3),(1,4),(2,5)}, + {(0,3),(1,5)}, + {(0,3),(2,4)}, + {(0,3),(2,5)}, + {(0,3),(4,5)}, + {(0,4)}, + {(0,4),(1,2)}, + {(0,4),(1,5)}, + {(0,4),(2,5)}, + {(0,5)}, + {(0,5),(1,2)}, + {(0,5),(1,2),(3,4)}, + {(0,5),(3,4)}, + {(1,2)}, + {(1,2),(3,4)}, + {(1,2),(3,5)}, + {(1,2),(4,5)}, + {(1,3)}, + {(1,3),(2,4)}, + {(1,3),(2,5)}, + {(1,3),(4,5)}, + {(1,4)}, + {(1,4),(2,5)}, + {(1,5)}, + {(1,5),(3,4)}, + {(2,3)}, + {(2,3),(4,5)}, + {(2,4)}, + {(2,5)}, + {(2,5),(3,4)}, + {(3,4)}, + {(3,5)}, + {(4,5)}] + +def profile : Config → Option (Fin 51) + | (.vacant,.vacant,.vacant) => some 0 + | (.vacant,.vacant,.cup) => some 50 + | (.vacant,.vertical₀,.vacant) => some 14 + | (.vacant,.vertical₀,.cup) => some 22 + | (.vacant,.diagonal₀,.vertical₀) => some 23 + | (.vacant,.diagonal₀,.diagonal₀) => some 27 + | (.vacant,.cup,.vertical₀) => some 48 + | (.vacant,.cup,.diagonal₀) => some 49 + | (.vertical₀,.vertical₁,.vertical₀) => some 39 + | (.vertical₀,.vertical₁,.diagonal₀) => some 41 + | (.vertical₀,.diagonal₁,.vacant) => some 35 + | (.vertical₀,.diagonal₁,.cup) => some 38 + | (.vertical₀,.cap,.vacant) => some 1 + | (.vertical₀,.cap,.cup) => some 9 + | (.vertical₀,.verticalPair,.vertical₀) => some 17 + | (.vertical₀,.verticalPair,.diagonal₀) => some 19 + | (.vertical₀,.capCup,.vertical₀) => some 7 + | (.vertical₀,.capCup,.diagonal₀) => some 8 + | (.vertical₁,.vacant,.vertical₁) => some 46 + | (.vertical₁,.vacant,.diagonal₁) => some 45 + | (.vertical₁,.vertical₀,.vertical₁) => some 21 + | (.vertical₁,.vertical₀,.diagonal₁) => some 20 + | (.vertical₁,.diagonal₀,.cap) => some 10 + | (.vertical₁,.diagonal₀,.verticalPair) => some 26 + | (.vertical₁,.diagonal₀,.capCup) => some 13 + | (.vertical₁,.cup,.cap) => some 43 + | (.vertical₁,.cup,.verticalPair) => some 47 + | (.vertical₁,.cup,.capCup) => some 44 + | (.diagonal₀,.vacant,.vertical₁) => some 41 + | (.diagonal₀,.vacant,.diagonal₁) => some 39 + | (.diagonal₀,.vertical₀,.vertical₁) => some 19 + | (.diagonal₀,.vertical₀,.diagonal₁) => some 17 + | (.diagonal₀,.diagonal₀,.cap) => some 1 + | (.diagonal₀,.diagonal₀,.verticalPair) => some 25 + | (.diagonal₀,.diagonal₀,.capCup) => some 9 + | (.diagonal₀,.cup,.cap) => some 35 + | (.diagonal₀,.cup,.verticalPair) => some 42 + | (.diagonal₀,.cup,.capCup) => some 38 + | (.diagonal₁,.vertical₁,.vertical₀) => some 45 + | (.diagonal₁,.vertical₁,.diagonal₀) => some 46 + | (.diagonal₁,.diagonal₁,.vacant) => some 43 + | (.diagonal₁,.diagonal₁,.cup) => some 44 + | (.diagonal₁,.cap,.vacant) => some 10 + | (.diagonal₁,.cap,.cup) => some 13 + | (.diagonal₁,.verticalPair,.vertical₀) => some 20 + | (.diagonal₁,.verticalPair,.diagonal₀) => some 21 + | (.diagonal₁,.capCup,.vertical₀) => some 11 + | (.diagonal₁,.capCup,.diagonal₀) => some 12 + | (.cap,.vacant,.vacant) => some 31 + | (.cap,.vacant,.cup) => some 34 + | (.cap,.vertical₀,.vacant) => some 15 + | (.cap,.vertical₀,.cup) => some 16 + | (.cap,.diagonal₀,.vertical₀) => some 24 + | (.cap,.diagonal₀,.diagonal₀) => some 28 + | (.cap,.cup,.vertical₀) => some 32 + | (.cap,.cup,.diagonal₀) => some 33 + | (.cup,.vertical₁,.verticalPair) => some 50 + | (.cup,.diagonal₁,.vertical₁) => some 49 + | (.cup,.diagonal₁,.diagonal₁) => some 48 + | (.cup,.cap,.vertical₁) => some 27 + | (.cup,.cap,.diagonal₁) => some 23 + | (.cup,.verticalPair,.verticalPair) => some 22 + | (.cup,.capCup,.cap) => some 14 + | (.cup,.capCup,.verticalPair) => some 30 + | (.cup,.capCup,.capCup) => some 22 + | (.verticalPair,.vertical₁,.cap) => some 31 + | (.verticalPair,.vertical₁,.verticalPair) => some 40 + | (.verticalPair,.vertical₁,.capCup) => some 34 + | (.verticalPair,.diagonal₁,.vertical₁) => some 37 + | (.verticalPair,.diagonal₁,.diagonal₁) => some 36 + | (.verticalPair,.cap,.vertical₁) => some 5 + | (.verticalPair,.cap,.diagonal₁) => some 4 + | (.verticalPair,.verticalPair,.cap) => some 15 + | (.verticalPair,.verticalPair,.verticalPair) => some 18 + | (.verticalPair,.verticalPair,.capCup) => some 16 + | (.verticalPair,.capCup,.cap) => some 2 + | (.verticalPair,.capCup,.verticalPair) => some 6 + | (.verticalPair,.capCup,.capCup) => some 3 + | (.capCup,.vertical₁,.verticalPair) => some 34 + | (.capCup,.diagonal₁,.vertical₁) => some 33 + | (.capCup,.diagonal₁,.diagonal₁) => some 32 + | (.capCup,.cap,.vertical₁) => some 28 + | (.capCup,.cap,.diagonal₁) => some 24 + | (.capCup,.verticalPair,.verticalPair) => some 16 + | (.capCup,.capCup,.cap) => some 15 + | (.capCup,.capCup,.verticalPair) => some 29 + | (.capCup,.capCup,.capCup) => some 16 + | _ => none + +def Clean (t : Config) : Prop := + ∀ v w, Adj t v w → ∃ i, boundaryOccupied t i ∧ rootTable t v = rootTable t (boundary i) + +def BoundaryData (t : Config) (d : Finset (Fin 6 × Fin 6)) : Prop := + (∀ i, boundaryOccupied t i ↔ boundarySupport d i) ∧ + (∀ i j, i ≠ j → (boundaryAdj d i j ↔ rootTable t (boundary i) = rootTable t (boundary j))) + +instance cleanDecidable (t : Config) : Decidable (Clean t) := by + unfold Clean; infer_instance +instance boundaryAdjDecidable (d : Finset (Fin 6 × Fin 6)) (i j : Fin 6) : + Decidable (boundaryAdj d i j) := by unfold boundaryAdj; infer_instance +instance boundarySupportDecidable (d : Finset (Fin 6 × Fin 6)) (i : Fin 6) : + Decidable (boundarySupport d i) := by unfold boundarySupport; infer_instance +instance boundaryDataDecidable (t : Config) (d : Finset (Fin 6 × Fin 6)) : + Decidable (BoundaryData t d) := by unfold BoundaryData; infer_instance + +def ProfileCorrect (t : Config) : Prop := + match profile t with + | none => ¬ Compatible t ∨ ¬ Clean t + | some k => Compatible t ∧ Clean t ∧ BoundaryData t (diagram k) +instance profileCorrectDecidable (t : Config) : Decidable (ProfileCorrect t) := by + unfold ProfileCorrect; split <;> infer_instance + +theorem profileCorrect_0 (x y : Tile) : ProfileCorrect (.vacant,x,y) := by + cases x <;> cases y <;> decide + +theorem profileCorrect_1 (x y : Tile) : ProfileCorrect (.vertical₀,x,y) := by + cases x <;> cases y <;> decide + +theorem profileCorrect_2 (x y : Tile) : ProfileCorrect (.vertical₁,x,y) := by + cases x <;> cases y <;> decide + +theorem profileCorrect_3 (x y : Tile) : ProfileCorrect (.diagonal₀,x,y) := by + cases x <;> cases y <;> decide + +theorem profileCorrect_4 (x y : Tile) : ProfileCorrect (.diagonal₁,x,y) := by + cases x <;> cases y <;> decide + +theorem profileCorrect_5 (x y : Tile) : ProfileCorrect (.cap,x,y) := by + cases x <;> cases y <;> decide + +theorem profileCorrect_6 (x y : Tile) : ProfileCorrect (.cup,x,y) := by + cases x <;> cases y <;> decide + +theorem profileCorrect_7 (x y : Tile) : ProfileCorrect (.verticalPair,x,y) := by + cases x <;> cases y <;> decide + +theorem profileCorrect_8 (x y : Tile) : ProfileCorrect (.capCup,x,y) := by + cases x <;> cases y <;> decide + +theorem profileCorrect (t : Config) : ProfileCorrect t := by + rcases t with ⟨t,x,y⟩ + cases t + · exact profileCorrect_0 x y + · exact profileCorrect_1 x y + · exact profileCorrect_2 x y + · exact profileCorrect_3 x y + · exact profileCorrect_4 x y + · exact profileCorrect_5 x y + · exact profileCorrect_6 x y + · exact profileCorrect_7 x y + · exact profileCorrect_8 x y + +theorem diagram_injective : Function.Injective diagram := by decide + +theorem diagram_upper (k : Fin 51) : ∀ e ∈ diagram k, e.1 < e.2 := by + fin_cases k <;> decide + +theorem realizes_iff_conditions {t : Config} {d : Finset (Fin 6 × Fin 6)} : + Realizes t d ↔ Compatible t ∧ Clean t ∧ BoundaryData t d := by + constructor + · intro h + refine ⟨h.compatible, ?_, h.occupied, ?_⟩ + · intro v w he + obtain ⟨i,hi,hr⟩ := h.no_loop v w he + exact ⟨i,hi,(reach_iff_root_eq t h.compatible v (boundary i)).mp hr⟩ + · intro i j hij + exact (h.output i j hij).trans (reach_iff_root_eq t h.compatible _ _) + · rintro ⟨hc,hl,ho,he⟩ + refine ⟨hc,ho,?_,?_⟩ + · intro v w hvw + obtain ⟨i,hi,hr⟩ := hl v w hvw + exact ⟨i,hi,(reach_iff_root_eq t hc v (boundary i)).mpr hr⟩ + · intro i j hij + exact (he i j hij).trans (reach_iff_root_eq t hc _ _).symm + +theorem realizes_unique {t : Config} {i j : Fin 51} + (hi : Realizes t (diagram i)) (hj : Realizes t (diagram j)) : i = j := by + apply diagram_injective + have hadj : ∀ a b, a ≠ b → (boundaryAdj (diagram i) a b ↔ boundaryAdj (diagram j) a b) := + fun a b hab => (hi.output a b hab).trans (hj.output a b hab).symm + apply Finset.ext + intro e + constructor + · intro he + have hu := diagram_upper i e he + have hh := (hadj e.1 e.2 (ne_of_lt hu)).mp (Or.inl he) + rcases hh with he' | he' + · exact he' + · exact (lt_asymm hu (diagram_upper j _ he')).elim + · intro he + have hu := diagram_upper j e he + have hh := (hadj e.1 e.2 (ne_of_lt hu)).mpr (Or.inl he) + rcases hh with he' | he' + · exact he' + · exact (lt_asymm hu (diagram_upper i _ he')).elim + + + +theorem profile_some_iff {t : Config} {k : Fin 51} : + profile t = some k ↔ Realizes t (diagram k) := by + have ht := profileCorrect t + unfold ProfileCorrect at ht + constructor + · intro h + rw [h] at ht + exact realizes_iff_conditions.mpr ht + · intro h + cases he : profile t with + | none => + rw [he] at ht + obtain ⟨hc,hl,_⟩ := realizes_iff_conditions.mp h + exact (ht.elim (fun hh => hh hc) (fun hh => hh hl)).elim + | some j => + rw [he] at ht + have hj := realizes_iff_conditions.mpr ht + rw [realizes_unique hj h] + +end +end CriticalStrip.Diagram.ThreeBox + +end OAI diff --git a/lean/OAI/Combinatorics/StripMass/ThreeBoxSplitPolynomial.lean b/lean/OAI/Combinatorics/StripMass/ThreeBoxSplitPolynomial.lean new file mode 100644 index 0000000000000000000000000000000000000000..0b461998c30218a8b563da16c21515c9a8a14b74 --- /dev/null +++ b/lean/OAI/Combinatorics/StripMass/ThreeBoxSplitPolynomial.lean @@ -0,0 +1,402 @@ +import Mathlib +import OAI.Combinatorics.StripMass.ThreeBoxWeights +import OAI.Combinatorics.StripMass.RootOfUnityPowers + +namespace OAI + +/-! Critical honeycomb strip paths, polynomial identities and crossing mass. -/ + + + +namespace CriticalStrip.Diagram.ThreeBox +noncomputable section + +def deletionTile {K : Type*} [Zero K] [One K] : Tile → K + | .vacant | .cap | .cup | .capCup => 1 + | _ => 0 + +def swapTile {K : Type*} [Zero K] [One K] : Tile → K + | .vacant | .diagonal₀ | .diagonal₁ => 1 + | _ => 0 + +def mergeNumerator {K : Type*} [CommRing K] (q : K) : Tile → K + | .vacant => q^2+1 + | .vertical₀ | .vertical₁ | .diagonal₀ | .diagonal₁ | .cap | .cup => q + | _ => 0 + +def commonNumerator {K : Type*} [CommRing K] (q z : K) : K := + (q^4*z^2-1)*(q^6*z^2-1) + +theorem split3_numerator_0 {K : Type*} [CommRing K] (q z : K) (_hq : q^8 = -1) : + coefficient deletionTile (tileNumerator q (q^4) (q^3*z)) (tileNumerator q (q^4) z) 0 = + commonNumerator q (q^3*z) * commonNumerator q z * coefficient swapTile swapTile deletionTile 0 := by + rw [coefficient_0, coefficient_0] + simp only [tileNumerator, deletionTile, swapTile, commonNumerator] + ring_nf + +theorem split3_numerator_14 {K : Type*} [CommRing K] (q z : K) (_hq : q^8 = -1) : + coefficient deletionTile (tileNumerator q (q^4) (q^3*z)) (tileNumerator q (q^4) z) 14 = + commonNumerator q (q^3*z) * commonNumerator q z * coefficient swapTile swapTile deletionTile 46 := by + rw [coefficient_14, coefficient_46] + simp only [tileNumerator, deletionTile, swapTile, commonNumerator] + ring_nf + +theorem split3_numerator_22 {K : Type*} [CommRing K] (q z : K) (hq : q^8 = -1) : + coefficient deletionTile (tileNumerator q (q^4) (q^3*z)) (tileNumerator q (q^4) z) 22 = + commonNumerator q (q^3*z) * commonNumerator q z * coefficient swapTile swapTile deletionTile 47 := by + rw [coefficient_22, coefficient_47] + simp only [tileNumerator, deletionTile, swapTile, commonNumerator] + ring_nf + all_goals simp only [eighthRoot_power_10 hq, eighthRoot_power_12 hq, eighthRoot_power_14 hq, eighthRoot_power_16 hq, eighthRoot_power_18 hq, eighthRoot_power_20 hq, eighthRoot_power_22 hq, eighthRoot_power_24 hq, eighthRoot_power_28 hq] + all_goals ring + +theorem split3_numerator_23 {K : Type*} [CommRing K] (q z : K) (_hq : q^8 = -1) : + coefficient deletionTile (tileNumerator q (q^4) (q^3*z)) (tileNumerator q (q^4) z) 23 = + commonNumerator q (q^3*z) * commonNumerator q z * coefficient swapTile swapTile deletionTile 45 := by + rw [coefficient_23, coefficient_45] + simp only [tileNumerator, deletionTile, swapTile, commonNumerator] + ring_nf + +theorem split3_numerator_27 {K : Type*} [CommRing K] (q z : K) (hq : q^8 = -1) : + coefficient deletionTile (tileNumerator q (q^4) (q^3*z)) (tileNumerator q (q^4) z) 27 = + commonNumerator q (q^3*z) * commonNumerator q z * coefficient swapTile swapTile deletionTile 43 := by + rw [coefficient_27, coefficient_43] + simp only [tileNumerator, deletionTile, swapTile, commonNumerator] + ring_nf + all_goals simp only [eighthRoot_power_10 hq, eighthRoot_power_12 hq, eighthRoot_power_14 hq, eighthRoot_power_16 hq, eighthRoot_power_18 hq, eighthRoot_power_20 hq, eighthRoot_power_22 hq, eighthRoot_power_24 hq, eighthRoot_power_26 hq, eighthRoot_power_28 hq, eighthRoot_power_30 hq, eighthRoot_power_32 hq, eighthRoot_power_34 hq] + all_goals ring + +theorem split3_numerator_30 {K : Type*} [CommRing K] (q z : K) (hq : q^8 = -1) : + coefficient deletionTile (tileNumerator q (q^4) (q^3*z)) (tileNumerator q (q^4) z) 30 = + commonNumerator q (q^3*z) * commonNumerator q z * coefficient swapTile swapTile deletionTile 44 := by + rw [coefficient_30, coefficient_44] + simp only [tileNumerator, deletionTile, swapTile, commonNumerator] + ring_nf + all_goals simp only [eighthRoot_power_10 hq, eighthRoot_power_12 hq, eighthRoot_power_14 hq, eighthRoot_power_16 hq, eighthRoot_power_18 hq, eighthRoot_power_20 hq, eighthRoot_power_22 hq, eighthRoot_power_26 hq, eighthRoot_power_28 hq, eighthRoot_power_32 hq] + all_goals ring + +theorem split3_numerator_48 {K : Type*} [CommRing K] (q z : K) (hq : q^8 = -1) : + coefficient deletionTile (tileNumerator q (q^4) (q^3*z)) (tileNumerator q (q^4) z) 48 = + commonNumerator q (q^3*z) * commonNumerator q z * coefficient swapTile swapTile deletionTile 50 := by + rw [coefficient_48, coefficient_50] + simp only [tileNumerator, deletionTile, swapTile, commonNumerator] + ring_nf + all_goals simp only [eighthRoot_power_10 hq, eighthRoot_power_12 hq, eighthRoot_power_14 hq, eighthRoot_power_16 hq, eighthRoot_power_18 hq, eighthRoot_power_20 hq, eighthRoot_power_22 hq, eighthRoot_power_24 hq, eighthRoot_power_26 hq, eighthRoot_power_28 hq, eighthRoot_power_30 hq, eighthRoot_power_32 hq, eighthRoot_power_34 hq] + all_goals ring + +theorem split3_numerator_49 {K : Type*} [CommRing K] (q z : K) (_hq : q^8 = -1) : + coefficient deletionTile (tileNumerator q (q^4) (q^3*z)) (tileNumerator q (q^4) z) 49 = + commonNumerator q (q^3*z) * commonNumerator q z * coefficient swapTile swapTile deletionTile 49 := by + rw [coefficient_49, coefficient_49] + simp only [tileNumerator, deletionTile, swapTile, commonNumerator] + ring_nf + +theorem split3_numerator_50 {K : Type*} [CommRing K] (q z : K) (hq : q^8 = -1) : + coefficient deletionTile (tileNumerator q (q^4) (q^3*z)) (tileNumerator q (q^4) z) 50 = + commonNumerator q (q^3*z) * commonNumerator q z * coefficient swapTile swapTile deletionTile 48 := by + rw [coefficient_50, coefficient_48] + simp only [tileNumerator, deletionTile, swapTile, commonNumerator] + ring_nf + all_goals simp only [eighthRoot_power_11 hq, eighthRoot_power_13 hq, eighthRoot_power_17 hq, eighthRoot_power_23 hq, eighthRoot_power_27 hq, eighthRoot_power_29 hq, eighthRoot_power_33 hq] + all_goals ring + +theorem split2_numerator_0 {K : Type*} [CommRing K] (q z : K) (_hq : q^8 = -1) : + coefficient (mergeNumerator q) (tileNumerator q (q^4) (q^2*z)) (tileNumerator q (q^4) z) 0 * commonNumerator q (q*z) = + commonNumerator q (q^2*z) * commonNumerator q z * coefficient (tileNumerator q (q^4) (q*z)) swapTile (mergeNumerator q) 0 := by + rw [coefficient_0, coefficient_0] + simp only [tileNumerator, swapTile, mergeNumerator, commonNumerator] + ring_nf + +theorem split2_numerator_1 {K : Type*} [CommRing K] (q z : K) (hq : q^8 = -1) : + coefficient (mergeNumerator q) (tileNumerator q (q^4) (q^2*z)) (tileNumerator q (q^4) z) 1 * commonNumerator q (q*z) = + commonNumerator q (q^2*z) * commonNumerator q z * coefficient (tileNumerator q (q^4) (q*z)) swapTile (mergeNumerator q) 31 := by + rw [coefficient_1, coefficient_31] + simp only [tileNumerator, swapTile, mergeNumerator, commonNumerator] + ring_nf + all_goals simp only [eighthRoot_power_8 hq, eighthRoot_power_10 hq, eighthRoot_power_12 hq, eighthRoot_power_14 hq, eighthRoot_power_16 hq, eighthRoot_power_18 hq, eighthRoot_power_20 hq, eighthRoot_power_22 hq, eighthRoot_power_24 hq, eighthRoot_power_26 hq, eighthRoot_power_28 hq, eighthRoot_power_30 hq, eighthRoot_power_32 hq, eighthRoot_power_34 hq, eighthRoot_power_36 hq, eighthRoot_power_38 hq, eighthRoot_power_40 hq, eighthRoot_power_42 hq, eighthRoot_power_44 hq] + all_goals ring + +theorem split2_numerator_7 {K : Type*} [CommRing K] (q z : K) (hq : q^8 = -1) : + coefficient (mergeNumerator q) (tileNumerator q (q^4) (q^2*z)) (tileNumerator q (q^4) z) 7 * commonNumerator q (q*z) = + commonNumerator q (q^2*z) * commonNumerator q z * coefficient (tileNumerator q (q^4) (q*z)) swapTile (mergeNumerator q) 34 := by + rw [coefficient_7, coefficient_34] + simp only [tileNumerator, swapTile, mergeNumerator, commonNumerator] + ring_nf + all_goals simp only [eighthRoot_power_9 hq, eighthRoot_power_11 hq, eighthRoot_power_13 hq, eighthRoot_power_15 hq, eighthRoot_power_17 hq, eighthRoot_power_19 hq, eighthRoot_power_21 hq, eighthRoot_power_23 hq, eighthRoot_power_25 hq, eighthRoot_power_27 hq, eighthRoot_power_29 hq, eighthRoot_power_31 hq, eighthRoot_power_33 hq, eighthRoot_power_35 hq, eighthRoot_power_37 hq, eighthRoot_power_39 hq, eighthRoot_power_41 hq, eighthRoot_power_43 hq] + all_goals ring + +theorem split2_numerator_8 {K : Type*} [CommRing K] (q z : K) (hq : q^8 = -1) : + coefficient (mergeNumerator q) (tileNumerator q (q^4) (q^2*z)) (tileNumerator q (q^4) z) 8 * commonNumerator q (q*z) = + commonNumerator q (q^2*z) * commonNumerator q z * coefficient (tileNumerator q (q^4) (q*z)) swapTile (mergeNumerator q) 33 := by + rw [coefficient_8, coefficient_33] + simp only [tileNumerator, swapTile, mergeNumerator, commonNumerator] + ring_nf + all_goals simp only [eighthRoot_power_9 hq, eighthRoot_power_11 hq, eighthRoot_power_13 hq, eighthRoot_power_15 hq, eighthRoot_power_17 hq, eighthRoot_power_19 hq, eighthRoot_power_21 hq, eighthRoot_power_23 hq, eighthRoot_power_25 hq, eighthRoot_power_27 hq, eighthRoot_power_29 hq, eighthRoot_power_31 hq, eighthRoot_power_33 hq, eighthRoot_power_35 hq, eighthRoot_power_37 hq] + all_goals ring + +theorem split2_numerator_9 {K : Type*} [CommRing K] (q z : K) (hq : q^8 = -1) : + coefficient (mergeNumerator q) (tileNumerator q (q^4) (q^2*z)) (tileNumerator q (q^4) z) 9 * commonNumerator q (q*z) = + commonNumerator q (q^2*z) * commonNumerator q z * coefficient (tileNumerator q (q^4) (q*z)) swapTile (mergeNumerator q) 32 := by + rw [coefficient_9, coefficient_32] + simp only [tileNumerator, swapTile, mergeNumerator, commonNumerator] + ring_nf + all_goals simp only [eighthRoot_power_9 hq, eighthRoot_power_11 hq, eighthRoot_power_13 hq, eighthRoot_power_15 hq, eighthRoot_power_17 hq, eighthRoot_power_19 hq, eighthRoot_power_21 hq, eighthRoot_power_23 hq, eighthRoot_power_25 hq, eighthRoot_power_27 hq, eighthRoot_power_29 hq, eighthRoot_power_31 hq, eighthRoot_power_33 hq, eighthRoot_power_35 hq, eighthRoot_power_37 hq, eighthRoot_power_39 hq, eighthRoot_power_43 hq] + all_goals ring + +theorem split2_numerator_14 {K : Type*} [CommRing K] (q z : K) (hq : q^8 = -1) : + coefficient (mergeNumerator q) (tileNumerator q (q^4) (q^2*z)) (tileNumerator q (q^4) z) 14 * commonNumerator q (q*z) = + commonNumerator q (q^2*z) * commonNumerator q z * coefficient (tileNumerator q (q^4) (q*z)) swapTile (mergeNumerator q) 46 := by + rw [coefficient_14, coefficient_46] + simp only [tileNumerator, swapTile, mergeNumerator, commonNumerator] + ring_nf + all_goals simp only [eighthRoot_power_8 hq, eighthRoot_power_10 hq, eighthRoot_power_12 hq, eighthRoot_power_14 hq, eighthRoot_power_16 hq, eighthRoot_power_18 hq, eighthRoot_power_20 hq, eighthRoot_power_22 hq, eighthRoot_power_24 hq, eighthRoot_power_26 hq, eighthRoot_power_28 hq, eighthRoot_power_30 hq, eighthRoot_power_32 hq, eighthRoot_power_34 hq, eighthRoot_power_36 hq, eighthRoot_power_38 hq, eighthRoot_power_40 hq, eighthRoot_power_42 hq, eighthRoot_power_44 hq] + all_goals ring + +theorem split2_numerator_17 {K : Type*} [CommRing K] (q z : K) (_hq : q^8 = -1) : + coefficient (mergeNumerator q) (tileNumerator q (q^4) (q^2*z)) (tileNumerator q (q^4) z) 17 * commonNumerator q (q*z) = + commonNumerator q (q^2*z) * commonNumerator q z * coefficient (tileNumerator q (q^4) (q*z)) swapTile (mergeNumerator q) 40 := by + rw [coefficient_17, coefficient_40] + simp only [tileNumerator, swapTile, mergeNumerator, commonNumerator] + ring_nf + +theorem split2_numerator_19 {K : Type*} [CommRing K] (q z : K) (hq : q^8 = -1) : + coefficient (mergeNumerator q) (tileNumerator q (q^4) (q^2*z)) (tileNumerator q (q^4) z) 19 * commonNumerator q (q*z) = + commonNumerator q (q^2*z) * commonNumerator q z * coefficient (tileNumerator q (q^4) (q*z)) swapTile (mergeNumerator q) 37 := by + rw [coefficient_19, coefficient_37] + simp only [tileNumerator, swapTile, mergeNumerator, commonNumerator] + ring_nf + all_goals simp only [eighthRoot_power_9 hq, eighthRoot_power_11 hq, eighthRoot_power_13 hq, eighthRoot_power_15 hq, eighthRoot_power_17 hq, eighthRoot_power_19 hq, eighthRoot_power_21 hq, eighthRoot_power_23 hq, eighthRoot_power_25 hq, eighthRoot_power_27 hq, eighthRoot_power_29 hq, eighthRoot_power_31 hq, eighthRoot_power_33 hq, eighthRoot_power_35 hq, eighthRoot_power_37 hq, eighthRoot_power_39 hq, eighthRoot_power_41 hq, eighthRoot_power_43 hq, eighthRoot_power_45 hq] + all_goals ring + +theorem split2_numerator_22 {K : Type*} [CommRing K] (q z : K) (hq : q^8 = -1) : + coefficient (mergeNumerator q) (tileNumerator q (q^4) (q^2*z)) (tileNumerator q (q^4) z) 22 * commonNumerator q (q*z) = + commonNumerator q (q^2*z) * commonNumerator q z * coefficient (tileNumerator q (q^4) (q*z)) swapTile (mergeNumerator q) 47 := by + rw [coefficient_22, coefficient_47] + simp only [tileNumerator, swapTile, mergeNumerator, commonNumerator] + ring_nf + all_goals simp only [eighthRoot_power_9 hq, eighthRoot_power_11 hq, eighthRoot_power_13 hq, eighthRoot_power_15 hq, eighthRoot_power_17 hq, eighthRoot_power_19 hq, eighthRoot_power_21 hq, eighthRoot_power_23 hq, eighthRoot_power_25 hq, eighthRoot_power_27 hq, eighthRoot_power_29 hq, eighthRoot_power_31 hq, eighthRoot_power_33 hq, eighthRoot_power_35 hq, eighthRoot_power_37 hq, eighthRoot_power_39 hq, eighthRoot_power_41 hq, eighthRoot_power_43 hq] + all_goals ring + +theorem split2_numerator_23 {K : Type*} [CommRing K] (q z : K) (hq : q^8 = -1) : + coefficient (mergeNumerator q) (tileNumerator q (q^4) (q^2*z)) (tileNumerator q (q^4) z) 23 * commonNumerator q (q*z) = + commonNumerator q (q^2*z) * commonNumerator q z * coefficient (tileNumerator q (q^4) (q*z)) swapTile (mergeNumerator q) 45 := by + rw [coefficient_23, coefficient_45] + simp only [tileNumerator, swapTile, mergeNumerator, commonNumerator] + ring_nf + all_goals simp only [eighthRoot_power_8 hq, eighthRoot_power_10 hq, eighthRoot_power_12 hq, eighthRoot_power_14 hq, eighthRoot_power_16 hq, eighthRoot_power_18 hq, eighthRoot_power_20 hq, eighthRoot_power_22 hq, eighthRoot_power_24 hq, eighthRoot_power_26 hq, eighthRoot_power_28 hq, eighthRoot_power_30 hq, eighthRoot_power_32 hq, eighthRoot_power_34 hq, eighthRoot_power_36 hq, eighthRoot_power_38 hq, eighthRoot_power_40 hq, eighthRoot_power_42 hq, eighthRoot_power_44 hq] + all_goals ring + +theorem split2_numerator_25 {K : Type*} [CommRing K] (q z : K) (hq : q^8 = -1) : + coefficient (mergeNumerator q) (tileNumerator q (q^4) (q^2*z)) (tileNumerator q (q^4) z) 25 * commonNumerator q (q*z) = + commonNumerator q (q^2*z) * commonNumerator q z * coefficient (tileNumerator q (q^4) (q*z)) swapTile (mergeNumerator q) 36 := by + rw [coefficient_25, coefficient_36] + simp only [tileNumerator, swapTile, mergeNumerator, commonNumerator] + ring_nf + all_goals simp only [eighthRoot_power_9 hq, eighthRoot_power_11 hq, eighthRoot_power_13 hq, eighthRoot_power_15 hq, eighthRoot_power_17 hq, eighthRoot_power_19 hq, eighthRoot_power_21 hq, eighthRoot_power_23 hq, eighthRoot_power_25 hq, eighthRoot_power_27 hq, eighthRoot_power_29 hq, eighthRoot_power_31 hq, eighthRoot_power_33 hq, eighthRoot_power_35 hq, eighthRoot_power_37 hq, eighthRoot_power_39 hq] + all_goals ring + +theorem split2_numerator_27 {K : Type*} [CommRing K] (q z : K) (hq : q^8 = -1) : + coefficient (mergeNumerator q) (tileNumerator q (q^4) (q^2*z)) (tileNumerator q (q^4) z) 27 * commonNumerator q (q*z) = + commonNumerator q (q^2*z) * commonNumerator q z * coefficient (tileNumerator q (q^4) (q*z)) swapTile (mergeNumerator q) 43 := by + rw [coefficient_27, coefficient_43] + simp only [tileNumerator, swapTile, mergeNumerator, commonNumerator] + ring_nf + all_goals simp only [eighthRoot_power_8 hq, eighthRoot_power_10 hq, eighthRoot_power_12 hq, eighthRoot_power_14 hq, eighthRoot_power_16 hq, eighthRoot_power_18 hq, eighthRoot_power_20 hq, eighthRoot_power_22 hq, eighthRoot_power_24 hq, eighthRoot_power_26 hq, eighthRoot_power_28 hq, eighthRoot_power_30 hq, eighthRoot_power_32 hq, eighthRoot_power_34 hq, eighthRoot_power_36 hq, eighthRoot_power_38 hq, eighthRoot_power_40 hq, eighthRoot_power_42 hq, eighthRoot_power_46 hq] + all_goals ring + +theorem split2_numerator_30 {K : Type*} [CommRing K] (q z : K) (hq : q^8 = -1) : + coefficient (mergeNumerator q) (tileNumerator q (q^4) (q^2*z)) (tileNumerator q (q^4) z) 30 * commonNumerator q (q*z) = + commonNumerator q (q^2*z) * commonNumerator q z * coefficient (tileNumerator q (q^4) (q*z)) swapTile (mergeNumerator q) 44 := by + rw [coefficient_30, coefficient_44] + simp only [tileNumerator, swapTile, mergeNumerator, commonNumerator] + ring_nf + all_goals simp only [eighthRoot_power_9 hq, eighthRoot_power_11 hq, eighthRoot_power_13 hq, eighthRoot_power_15 hq, eighthRoot_power_17 hq, eighthRoot_power_19 hq, eighthRoot_power_21 hq, eighthRoot_power_23 hq, eighthRoot_power_25 hq, eighthRoot_power_27 hq, eighthRoot_power_29 hq, eighthRoot_power_31 hq, eighthRoot_power_33 hq, eighthRoot_power_35 hq, eighthRoot_power_37 hq, eighthRoot_power_39 hq] + all_goals ring + +theorem split2_numerator_35 {K : Type*} [CommRing K] (q z : K) (hq : q^8 = -1) : + coefficient (mergeNumerator q) (tileNumerator q (q^4) (q^2*z)) (tileNumerator q (q^4) z) 35 * commonNumerator q (q*z) = + commonNumerator q (q^2*z) * commonNumerator q z * coefficient (tileNumerator q (q^4) (q*z)) swapTile (mergeNumerator q) 41 := by + rw [coefficient_35, coefficient_41] + simp only [tileNumerator, swapTile, mergeNumerator, commonNumerator] + ring_nf + all_goals simp only [eighthRoot_power_9 hq, eighthRoot_power_11 hq, eighthRoot_power_13 hq, eighthRoot_power_15 hq, eighthRoot_power_17 hq, eighthRoot_power_19 hq, eighthRoot_power_21 hq, eighthRoot_power_23 hq, eighthRoot_power_25 hq, eighthRoot_power_27 hq, eighthRoot_power_29 hq, eighthRoot_power_31 hq, eighthRoot_power_33 hq, eighthRoot_power_35 hq, eighthRoot_power_37 hq, eighthRoot_power_39 hq, eighthRoot_power_43 hq] + all_goals ring + +theorem split2_numerator_38 {K : Type*} [CommRing K] (q z : K) (_hq : q^8 = -1) : + coefficient (mergeNumerator q) (tileNumerator q (q^4) (q^2*z)) (tileNumerator q (q^4) z) 38 * commonNumerator q (q*z) = + commonNumerator q (q^2*z) * commonNumerator q z * coefficient (tileNumerator q (q^4) (q*z)) swapTile (mergeNumerator q) 42 := by + rw [coefficient_38, coefficient_42] + simp only [tileNumerator, swapTile, mergeNumerator, commonNumerator] + ring_nf + +theorem split2_numerator_39 {K : Type*} [CommRing K] (q z : K) (hq : q^8 = -1) : + coefficient (mergeNumerator q) (tileNumerator q (q^4) (q^2*z)) (tileNumerator q (q^4) z) 39 * commonNumerator q (q*z) = + commonNumerator q (q^2*z) * commonNumerator q z * coefficient (tileNumerator q (q^4) (q*z)) swapTile (mergeNumerator q) 39 := by + rw [coefficient_39, coefficient_39] + simp only [tileNumerator, swapTile, mergeNumerator, commonNumerator] + ring_nf + all_goals simp only [eighthRoot_power_9 hq, eighthRoot_power_11 hq, eighthRoot_power_13 hq, eighthRoot_power_15 hq, eighthRoot_power_17 hq, eighthRoot_power_19 hq, eighthRoot_power_21 hq, eighthRoot_power_23 hq, eighthRoot_power_25 hq, eighthRoot_power_27 hq, eighthRoot_power_29 hq, eighthRoot_power_31 hq, eighthRoot_power_33 hq, eighthRoot_power_35 hq, eighthRoot_power_37 hq, eighthRoot_power_39 hq, eighthRoot_power_41 hq, eighthRoot_power_43 hq, eighthRoot_power_45 hq] + all_goals ring + +theorem split2_numerator_41 {K : Type*} [CommRing K] (q z : K) (hq : q^8 = -1) : + coefficient (mergeNumerator q) (tileNumerator q (q^4) (q^2*z)) (tileNumerator q (q^4) z) 41 * commonNumerator q (q*z) = + commonNumerator q (q^2*z) * commonNumerator q z * coefficient (tileNumerator q (q^4) (q*z)) swapTile (mergeNumerator q) 35 := by + rw [coefficient_41, coefficient_35] + simp only [tileNumerator, swapTile, mergeNumerator, commonNumerator] + ring_nf + all_goals simp only [eighthRoot_power_9 hq, eighthRoot_power_11 hq, eighthRoot_power_13 hq, eighthRoot_power_15 hq, eighthRoot_power_17 hq, eighthRoot_power_19 hq, eighthRoot_power_21 hq, eighthRoot_power_23 hq, eighthRoot_power_25 hq, eighthRoot_power_27 hq, eighthRoot_power_29 hq, eighthRoot_power_31 hq, eighthRoot_power_33 hq, eighthRoot_power_35 hq, eighthRoot_power_37 hq, eighthRoot_power_39 hq, eighthRoot_power_41 hq, eighthRoot_power_43 hq, eighthRoot_power_45 hq, eighthRoot_power_47 hq] + all_goals ring + +theorem split2_numerator_42 {K : Type*} [CommRing K] (q z : K) (hq : q^8 = -1) : + coefficient (mergeNumerator q) (tileNumerator q (q^4) (q^2*z)) (tileNumerator q (q^4) z) 42 * commonNumerator q (q*z) = + commonNumerator q (q^2*z) * commonNumerator q z * coefficient (tileNumerator q (q^4) (q*z)) swapTile (mergeNumerator q) 38 := by + rw [coefficient_42, coefficient_38] + simp only [tileNumerator, swapTile, mergeNumerator, commonNumerator] + ring_nf + all_goals simp only [eighthRoot_power_8 hq, eighthRoot_power_10 hq, eighthRoot_power_12 hq, eighthRoot_power_14 hq, eighthRoot_power_16 hq, eighthRoot_power_18 hq, eighthRoot_power_20 hq, eighthRoot_power_22 hq, eighthRoot_power_24 hq, eighthRoot_power_26 hq, eighthRoot_power_28 hq, eighthRoot_power_30 hq, eighthRoot_power_32 hq, eighthRoot_power_34 hq, eighthRoot_power_36 hq, eighthRoot_power_38 hq, eighthRoot_power_40 hq, eighthRoot_power_42 hq, eighthRoot_power_44 hq] + all_goals ring + +theorem split2_numerator_48 {K : Type*} [CommRing K] (q z : K) (hq : q^8 = -1) : + coefficient (mergeNumerator q) (tileNumerator q (q^4) (q^2*z)) (tileNumerator q (q^4) z) 48 * commonNumerator q (q*z) = + commonNumerator q (q^2*z) * commonNumerator q z * coefficient (tileNumerator q (q^4) (q*z)) swapTile (mergeNumerator q) 50 := by + rw [coefficient_48, coefficient_50] + simp only [tileNumerator, swapTile, mergeNumerator, commonNumerator] + ring_nf + all_goals simp only [eighthRoot_power_9 hq, eighthRoot_power_11 hq, eighthRoot_power_13 hq, eighthRoot_power_15 hq, eighthRoot_power_17 hq, eighthRoot_power_19 hq, eighthRoot_power_21 hq, eighthRoot_power_23 hq, eighthRoot_power_25 hq, eighthRoot_power_27 hq, eighthRoot_power_29 hq, eighthRoot_power_31 hq, eighthRoot_power_33 hq, eighthRoot_power_35 hq, eighthRoot_power_37 hq, eighthRoot_power_39 hq, eighthRoot_power_41 hq, eighthRoot_power_43 hq, eighthRoot_power_45 hq, eighthRoot_power_47 hq] + all_goals ring + +theorem split2_numerator_49 {K : Type*} [CommRing K] (q z : K) (hq : q^8 = -1) : + coefficient (mergeNumerator q) (tileNumerator q (q^4) (q^2*z)) (tileNumerator q (q^4) z) 49 * commonNumerator q (q*z) = + commonNumerator q (q^2*z) * commonNumerator q z * coefficient (tileNumerator q (q^4) (q*z)) swapTile (mergeNumerator q) 49 := by + rw [coefficient_49, coefficient_49] + simp only [tileNumerator, swapTile, mergeNumerator, commonNumerator] + ring_nf + all_goals simp only [eighthRoot_power_9 hq, eighthRoot_power_11 hq, eighthRoot_power_13 hq, eighthRoot_power_15 hq, eighthRoot_power_17 hq, eighthRoot_power_19 hq, eighthRoot_power_21 hq, eighthRoot_power_23 hq, eighthRoot_power_25 hq, eighthRoot_power_27 hq, eighthRoot_power_29 hq, eighthRoot_power_31 hq, eighthRoot_power_33 hq, eighthRoot_power_35 hq, eighthRoot_power_37 hq, eighthRoot_power_39 hq, eighthRoot_power_41 hq, eighthRoot_power_43 hq] + all_goals ring + +theorem split2_numerator_50 {K : Type*} [CommRing K] (q z : K) (hq : q^8 = -1) : + coefficient (mergeNumerator q) (tileNumerator q (q^4) (q^2*z)) (tileNumerator q (q^4) z) 50 * commonNumerator q (q*z) = + commonNumerator q (q^2*z) * commonNumerator q z * coefficient (tileNumerator q (q^4) (q*z)) swapTile (mergeNumerator q) 48 := by + rw [coefficient_50, coefficient_48] + simp only [tileNumerator, swapTile, mergeNumerator, commonNumerator] + ring_nf + all_goals simp only [eighthRoot_power_9 hq, eighthRoot_power_11 hq, eighthRoot_power_13 hq, eighthRoot_power_15 hq, eighthRoot_power_17 hq, eighthRoot_power_19 hq, eighthRoot_power_21 hq, eighthRoot_power_23 hq, eighthRoot_power_25 hq, eighthRoot_power_27 hq, eighthRoot_power_29 hq, eighthRoot_power_31 hq, eighthRoot_power_33 hq, eighthRoot_power_35 hq, eighthRoot_power_37 hq, eighthRoot_power_39 hq, eighthRoot_power_41 hq, eighthRoot_power_43 hq, eighthRoot_power_45 hq] + all_goals ring + + + + + + +open Finset + + + +def diagramExterior {B : Type*} (d : Finset (Fin 6 × Fin 6)) + (s : B → B → Prop) (b : Fin 6 → B) (active : Fin 6 → Prop) (x y : B) : Prop := + s x y ∨ ∃ i j, active i ∧ active j ∧ (i=j ∨ boundaryAdj d i j) ∧ x=b i ∧ y=b j + +theorem realizes_boundary_reach {t : Config} {d : Finset (Fin 6 × Fin 6)} + (h : Realizes t d) (i j : Fin 6) : + Relation.ReflTransGen (Adj t) (boundary i) (boundary j) ↔ i=j ∨ boundaryAdj d i j := by + by_cases he : i=j + · subst j + simp only [true_or, iff_true] + exact .refl + · simp only [he, false_or] + exact (h.output i j he).symm + +theorem realizes_compressed {B : Type*} {t : Config} {d : Finset (Fin 6 × Fin 6)} + (h : Realizes t d) (s : B → B → Prop) (b : Fin 6 → B) (active : Fin 6 → Prop) : + Patch.compressed (Adj t) s boundary b active = diagramExterior d s b active := by + funext x y + apply propext + simp only [Patch.compressed, diagramExterior, realizes_boundary_reach h] + +theorem substitute_reach {B : Type*} {t : Config} {d : Finset (Fin 6 × Fin 6)} + (h : Realizes t d) (s : B → B → Prop) (b : Fin 6 → B) (active : Fin 6 → Prop) + (x y : B) : + Relation.ReflTransGen (Patch.glued (Adj t) s boundary b active) (.inr x) (.inr y) ↔ + Relation.ReflTransGen (diagramExterior d s b active) x y := by + rw [Patch.exterior_reach_iff, realizes_compressed h] + +theorem substitute_drains {B : Type*} {t : Config} {d : Finset (Fin 6 × Fin 6)} + (h : Realizes t d) (s : B → B → Prop) (b : Fin 6 → B) (active : Fin 6 → Prop) + (ha : ∀ i, active i ↔ boundaryOccupied t i) (out : B → Prop) : + Patch.drains (Patch.glued (Adj t) s boundary b active) (Patch.exteriorOutput out) ↔ + Patch.drains (diagramExterior d s b active) out := by + rw [Patch.drains_glued_iff, realizes_compressed h] + apply and_iff_right + intro x y hxy + obtain ⟨i,hi,hr⟩ := h.no_loop x y hxy + exact ⟨i,(ha i).mpr hi,hr⟩ + + + +theorem profile_exists_of_drains {B : Type*} {t : Config} (hc : Compatible t) + (s : B → B → Prop) (b : Fin 6 → B) (active : Fin 6 → Prop) + (ha : ∀ i, active i ↔ boundaryOccupied t i) (out : B → Prop) + (hd : Patch.drains (Patch.glued (Adj t) s boundary b active) (Patch.exteriorOutput out)) : + ∃ k, profile t = some k := by + have hl := ((Patch.drains_glued_iff (Adj t) s boundary b active out).mp hd).1 + have hclean : Clean t := by + intro x y hxy + obtain ⟨i,hi,hr⟩ := hl x y hxy + exact ⟨i,(ha i).mp hi,(reach_iff_root_eq t hc x (boundary i)).mp hr⟩ + have hp := profileCorrect t + unfold ProfileCorrect at hp + cases he : profile t with + | none => + rw [he] at hp + exact (hp.elim (fun hh => hh hc) (fun hh => hh hclean)).elim + | some k => exact ⟨k,rfl⟩ + + + +def exteriorTest {B : Type*} (s : B → B → Prop) (b : Fin 6 → B) + (active : Fin 6 → Prop) (out : B → Prop) + (test : (B → B → Prop) → Prop) (k : Fin 51) : Prop := + (∀ i, active i ↔ boundarySupport (diagram k) i) ∧ + Patch.drains (diagramExterior (diagram k) s b active) out ∧ + test (Relation.ReflTransGen (diagramExterior (diagram k) s b active)) + +def patchTest {B : Type*} (s : B → B → Prop) (b : Fin 6 → B) + (active : Fin 6 → Prop) (out : B → Prop) + (test : (B → B → Prop) → Prop) (t : Config) : Prop := + Compatible t ∧ (∀ i, active i ↔ boundaryOccupied t i) ∧ + Patch.drains (Patch.glued (Adj t) s boundary b active) (Patch.exteriorOutput out) ∧ + test (fun x y => Relation.ReflTransGen (Patch.glued (Adj t) s boundary b active) (.inr x) (.inr y)) + +theorem patchTest_iff {B : Type*} (s : B → B → Prop) (b : Fin 6 → B) + (active : Fin 6 → Prop) (out : B → Prop) (test : (B → B → Prop) → Prop) + (t : Config) : + patchTest s b active out test t ↔ + ∃ k, profile t = some k ∧ exteriorTest s b active out test k := by + constructor + · rintro ⟨hc,ha,hd,ht⟩ + obtain ⟨k,hk⟩ := profile_exists_of_drains hc s b active ha out hd + have hr := profile_some_iff.mp hk + refine ⟨k,hk,?_,(substitute_drains hr s b active ha out).mp hd,?_⟩ + · exact fun i => (ha i).trans (hr.occupied i) + · have he : (fun x y => Relation.ReflTransGen + (Patch.glued (Adj t) s boundary b active) (.inr x) (.inr y)) = + Relation.ReflTransGen (diagramExterior (diagram k) s b active) := by + funext x y + exact propext (substitute_reach hr s b active x y) + rwa [← he] + · rintro ⟨k,hk,ha,hd,ht⟩ + have hr := profile_some_iff.mp hk + have ha' : ∀ i, active i ↔ boundaryOccupied t i := + fun i => (ha i).trans (hr.occupied i).symm + refine ⟨hr.compatible,ha',(substitute_drains hr s b active ha' out).mpr hd,?_⟩ + have he : (fun x y => Relation.ReflTransGen + (Patch.glued (Adj t) s boundary b active) (.inr x) (.inr y)) = + Relation.ReflTransGen (diagramExterior (diagram k) s b active) := by + funext x y + exact propext (substitute_reach hr s b active x y) + simpa only [he] using ht + +end +end CriticalStrip.Diagram.ThreeBox + +end OAI diff --git a/lean/OAI/Combinatorics/StripMass/ThreeBoxWeights.lean b/lean/OAI/Combinatorics/StripMass/ThreeBoxWeights.lean new file mode 100644 index 0000000000000000000000000000000000000000..7a6d1f67e4564d7e020a27ed056a77ea13058acc --- /dev/null +++ b/lean/OAI/Combinatorics/StripMass/ThreeBoxWeights.lean @@ -0,0 +1,571 @@ +import Mathlib +import OAI.Combinatorics.StripMass.ThreeBoxProfiles + +namespace OAI + +/-! Critical honeycomb strip paths, polynomial identities and crossing mass. -/ + + + +namespace CriticalStrip.Diagram.ThreeBox +noncomputable section +open Finset +open scoped Classical + +def fiber : Fin 51 → Finset Config := ![ + {(.vacant,.vacant,.vacant)}, + {(.vertical₀,.cap,.vacant),(.diagonal₀,.diagonal₀,.cap)}, + {(.verticalPair,.capCup,.cap)}, + {(.verticalPair,.capCup,.capCup)}, + {(.verticalPair,.cap,.diagonal₁)}, + {(.verticalPair,.cap,.vertical₁)}, + {(.verticalPair,.capCup,.verticalPair)}, + {(.vertical₀,.capCup,.vertical₀)}, + {(.vertical₀,.capCup,.diagonal₀)}, + {(.vertical₀,.cap,.cup),(.diagonal₀,.diagonal₀,.capCup)}, + {(.vertical₁,.diagonal₀,.cap),(.diagonal₁,.cap,.vacant)}, + {(.diagonal₁,.capCup,.vertical₀)}, + {(.diagonal₁,.capCup,.diagonal₀)}, + {(.vertical₁,.diagonal₀,.capCup),(.diagonal₁,.cap,.cup)}, + {(.vacant,.vertical₀,.vacant),(.cup,.capCup,.cap)}, + {(.cap,.vertical₀,.vacant),(.verticalPair,.verticalPair,.cap),(.capCup,.capCup,.cap)}, + {(.cap,.vertical₀,.cup),(.verticalPair,.verticalPair,.capCup),(.capCup,.verticalPair,.verticalPair),(.capCup,.capCup,.capCup)}, + {(.vertical₀,.verticalPair,.vertical₀),(.diagonal₀,.vertical₀,.diagonal₁)}, + {(.verticalPair,.verticalPair,.verticalPair)}, + {(.vertical₀,.verticalPair,.diagonal₀),(.diagonal₀,.vertical₀,.vertical₁)}, + {(.vertical₁,.vertical₀,.diagonal₁),(.diagonal₁,.verticalPair,.vertical₀)}, + {(.vertical₁,.vertical₀,.vertical₁),(.diagonal₁,.verticalPair,.diagonal₀)}, + {(.vacant,.vertical₀,.cup),(.cup,.verticalPair,.verticalPair),(.cup,.capCup,.capCup)}, + {(.vacant,.diagonal₀,.vertical₀),(.cup,.cap,.diagonal₁)}, + {(.cap,.diagonal₀,.vertical₀),(.capCup,.cap,.diagonal₁)}, + {(.diagonal₀,.diagonal₀,.verticalPair)}, + {(.vertical₁,.diagonal₀,.verticalPair)}, + {(.vacant,.diagonal₀,.diagonal₀),(.cup,.cap,.vertical₁)}, + {(.cap,.diagonal₀,.diagonal₀),(.capCup,.cap,.vertical₁)}, + {(.capCup,.capCup,.verticalPair)}, + {(.cup,.capCup,.verticalPair)}, + {(.cap,.vacant,.vacant),(.verticalPair,.vertical₁,.cap)}, + {(.cap,.cup,.vertical₀),(.capCup,.diagonal₁,.diagonal₁)}, + {(.cap,.cup,.diagonal₀),(.capCup,.diagonal₁,.vertical₁)}, + {(.cap,.vacant,.cup),(.verticalPair,.vertical₁,.capCup),(.capCup,.vertical₁,.verticalPair)}, + {(.vertical₀,.diagonal₁,.vacant),(.diagonal₀,.cup,.cap)}, + {(.verticalPair,.diagonal₁,.diagonal₁)}, + {(.verticalPair,.diagonal₁,.vertical₁)}, + {(.vertical₀,.diagonal₁,.cup),(.diagonal₀,.cup,.capCup)}, + {(.vertical₀,.vertical₁,.vertical₀),(.diagonal₀,.vacant,.diagonal₁)}, + {(.verticalPair,.vertical₁,.verticalPair)}, + {(.vertical₀,.vertical₁,.diagonal₀),(.diagonal₀,.vacant,.vertical₁)}, + {(.diagonal₀,.cup,.verticalPair)}, + {(.vertical₁,.cup,.cap),(.diagonal₁,.diagonal₁,.vacant)}, + {(.vertical₁,.cup,.capCup),(.diagonal₁,.diagonal₁,.cup)}, + {(.vertical₁,.vacant,.diagonal₁),(.diagonal₁,.vertical₁,.vertical₀)}, + {(.vertical₁,.vacant,.vertical₁),(.diagonal₁,.vertical₁,.diagonal₀)}, + {(.vertical₁,.cup,.verticalPair)}, + {(.vacant,.cup,.vertical₀),(.cup,.diagonal₁,.diagonal₁)}, + {(.vacant,.cup,.diagonal₀),(.cup,.diagonal₁,.vertical₁)}, + {(.vacant,.vacant,.cup),(.cup,.vertical₁,.verticalPair)}] + +theorem fiber_correct_0 : ∀ t : Config, t ∈ fiber 0 ↔ profile t = some 0 := by + rintro ⟨a,b,c⟩ + cases a <;> revert b c <;> decide + +theorem fiber_correct_1 : ∀ t : Config, t ∈ fiber 1 ↔ profile t = some 1 := by + rintro ⟨a,b,c⟩ + cases a <;> revert b c <;> decide + +theorem fiber_correct_2 : ∀ t : Config, t ∈ fiber 2 ↔ profile t = some 2 := by + rintro ⟨a,b,c⟩ + cases a <;> revert b c <;> decide + +theorem fiber_correct_3 : ∀ t : Config, t ∈ fiber 3 ↔ profile t = some 3 := by + rintro ⟨a,b,c⟩ + cases a <;> revert b c <;> decide + +theorem fiber_correct_4 : ∀ t : Config, t ∈ fiber 4 ↔ profile t = some 4 := by + rintro ⟨a,b,c⟩ + cases a <;> revert b c <;> decide + +theorem fiber_correct_5 : ∀ t : Config, t ∈ fiber 5 ↔ profile t = some 5 := by + rintro ⟨a,b,c⟩ + cases a <;> revert b c <;> decide + +theorem fiber_correct_6 : ∀ t : Config, t ∈ fiber 6 ↔ profile t = some 6 := by + rintro ⟨a,b,c⟩ + cases a <;> revert b c <;> decide + +theorem fiber_correct_7 : ∀ t : Config, t ∈ fiber 7 ↔ profile t = some 7 := by + rintro ⟨a,b,c⟩ + cases a <;> revert b c <;> decide + +theorem fiber_correct_8 : ∀ t : Config, t ∈ fiber 8 ↔ profile t = some 8 := by + rintro ⟨a,b,c⟩ + cases a <;> revert b c <;> decide + +theorem fiber_correct_9 : ∀ t : Config, t ∈ fiber 9 ↔ profile t = some 9 := by + rintro ⟨a,b,c⟩ + cases a <;> revert b c <;> decide + +theorem fiber_correct_10 : ∀ t : Config, t ∈ fiber 10 ↔ profile t = some 10 := by + rintro ⟨a,b,c⟩ + cases a <;> revert b c <;> decide + +theorem fiber_correct_11 : ∀ t : Config, t ∈ fiber 11 ↔ profile t = some 11 := by + rintro ⟨a,b,c⟩ + cases a <;> revert b c <;> decide + +theorem fiber_correct_12 : ∀ t : Config, t ∈ fiber 12 ↔ profile t = some 12 := by + rintro ⟨a,b,c⟩ + cases a <;> revert b c <;> decide + +theorem fiber_correct_13 : ∀ t : Config, t ∈ fiber 13 ↔ profile t = some 13 := by + rintro ⟨a,b,c⟩ + cases a <;> revert b c <;> decide + +theorem fiber_correct_14 : ∀ t : Config, t ∈ fiber 14 ↔ profile t = some 14 := by + rintro ⟨a,b,c⟩ + cases a <;> revert b c <;> decide + +theorem fiber_correct_15 : ∀ t : Config, t ∈ fiber 15 ↔ profile t = some 15 := by + rintro ⟨a,b,c⟩ + cases a <;> revert b c <;> decide + +theorem fiber_correct_16 : ∀ t : Config, t ∈ fiber 16 ↔ profile t = some 16 := by + rintro ⟨a,b,c⟩ + cases a <;> revert b c <;> decide + +theorem fiber_correct_17 : ∀ t : Config, t ∈ fiber 17 ↔ profile t = some 17 := by + rintro ⟨a,b,c⟩ + cases a <;> revert b c <;> decide + +theorem fiber_correct_18 : ∀ t : Config, t ∈ fiber 18 ↔ profile t = some 18 := by + rintro ⟨a,b,c⟩ + cases a <;> revert b c <;> decide + +theorem fiber_correct_19 : ∀ t : Config, t ∈ fiber 19 ↔ profile t = some 19 := by + rintro ⟨a,b,c⟩ + cases a <;> revert b c <;> decide + +theorem fiber_correct_20 : ∀ t : Config, t ∈ fiber 20 ↔ profile t = some 20 := by + rintro ⟨a,b,c⟩ + cases a <;> revert b c <;> decide + +theorem fiber_correct_21 : ∀ t : Config, t ∈ fiber 21 ↔ profile t = some 21 := by + rintro ⟨a,b,c⟩ + cases a <;> revert b c <;> decide + +theorem fiber_correct_22 : ∀ t : Config, t ∈ fiber 22 ↔ profile t = some 22 := by + rintro ⟨a,b,c⟩ + cases a <;> revert b c <;> decide + +theorem fiber_correct_23 : ∀ t : Config, t ∈ fiber 23 ↔ profile t = some 23 := by + rintro ⟨a,b,c⟩ + cases a <;> revert b c <;> decide + +theorem fiber_correct_24 : ∀ t : Config, t ∈ fiber 24 ↔ profile t = some 24 := by + rintro ⟨a,b,c⟩ + cases a <;> revert b c <;> decide + +theorem fiber_correct_25 : ∀ t : Config, t ∈ fiber 25 ↔ profile t = some 25 := by + rintro ⟨a,b,c⟩ + cases a <;> revert b c <;> decide + +theorem fiber_correct_26 : ∀ t : Config, t ∈ fiber 26 ↔ profile t = some 26 := by + rintro ⟨a,b,c⟩ + cases a <;> revert b c <;> decide + +theorem fiber_correct_27 : ∀ t : Config, t ∈ fiber 27 ↔ profile t = some 27 := by + rintro ⟨a,b,c⟩ + cases a <;> revert b c <;> decide + +theorem fiber_correct_28 : ∀ t : Config, t ∈ fiber 28 ↔ profile t = some 28 := by + rintro ⟨a,b,c⟩ + cases a <;> revert b c <;> decide + +theorem fiber_correct_29 : ∀ t : Config, t ∈ fiber 29 ↔ profile t = some 29 := by + rintro ⟨a,b,c⟩ + cases a <;> revert b c <;> decide + +theorem fiber_correct_30 : ∀ t : Config, t ∈ fiber 30 ↔ profile t = some 30 := by + rintro ⟨a,b,c⟩ + cases a <;> revert b c <;> decide + +theorem fiber_correct_31 : ∀ t : Config, t ∈ fiber 31 ↔ profile t = some 31 := by + rintro ⟨a,b,c⟩ + cases a <;> revert b c <;> decide + +theorem fiber_correct_32 : ∀ t : Config, t ∈ fiber 32 ↔ profile t = some 32 := by + rintro ⟨a,b,c⟩ + cases a <;> revert b c <;> decide + +theorem fiber_correct_33 : ∀ t : Config, t ∈ fiber 33 ↔ profile t = some 33 := by + rintro ⟨a,b,c⟩ + cases a <;> revert b c <;> decide + +theorem fiber_correct_34 : ∀ t : Config, t ∈ fiber 34 ↔ profile t = some 34 := by + rintro ⟨a,b,c⟩ + cases a <;> revert b c <;> decide + +theorem fiber_correct_35 : ∀ t : Config, t ∈ fiber 35 ↔ profile t = some 35 := by + rintro ⟨a,b,c⟩ + cases a <;> revert b c <;> decide + +theorem fiber_correct_36 : ∀ t : Config, t ∈ fiber 36 ↔ profile t = some 36 := by + rintro ⟨a,b,c⟩ + cases a <;> revert b c <;> decide + +theorem fiber_correct_37 : ∀ t : Config, t ∈ fiber 37 ↔ profile t = some 37 := by + rintro ⟨a,b,c⟩ + cases a <;> revert b c <;> decide + +theorem fiber_correct_38 : ∀ t : Config, t ∈ fiber 38 ↔ profile t = some 38 := by + rintro ⟨a,b,c⟩ + cases a <;> revert b c <;> decide + +theorem fiber_correct_39 : ∀ t : Config, t ∈ fiber 39 ↔ profile t = some 39 := by + rintro ⟨a,b,c⟩ + cases a <;> revert b c <;> decide + +theorem fiber_correct_40 : ∀ t : Config, t ∈ fiber 40 ↔ profile t = some 40 := by + rintro ⟨a,b,c⟩ + cases a <;> revert b c <;> decide + +theorem fiber_correct_41 : ∀ t : Config, t ∈ fiber 41 ↔ profile t = some 41 := by + rintro ⟨a,b,c⟩ + cases a <;> revert b c <;> decide + +theorem fiber_correct_42 : ∀ t : Config, t ∈ fiber 42 ↔ profile t = some 42 := by + rintro ⟨a,b,c⟩ + cases a <;> revert b c <;> decide + +theorem fiber_correct_43 : ∀ t : Config, t ∈ fiber 43 ↔ profile t = some 43 := by + rintro ⟨a,b,c⟩ + cases a <;> revert b c <;> decide + +theorem fiber_correct_44 : ∀ t : Config, t ∈ fiber 44 ↔ profile t = some 44 := by + rintro ⟨a,b,c⟩ + cases a <;> revert b c <;> decide + +theorem fiber_correct_45 : ∀ t : Config, t ∈ fiber 45 ↔ profile t = some 45 := by + rintro ⟨a,b,c⟩ + cases a <;> revert b c <;> decide + +theorem fiber_correct_46 : ∀ t : Config, t ∈ fiber 46 ↔ profile t = some 46 := by + rintro ⟨a,b,c⟩ + cases a <;> revert b c <;> decide + +theorem fiber_correct_47 : ∀ t : Config, t ∈ fiber 47 ↔ profile t = some 47 := by + rintro ⟨a,b,c⟩ + cases a <;> revert b c <;> decide + +theorem fiber_correct_48 : ∀ t : Config, t ∈ fiber 48 ↔ profile t = some 48 := by + rintro ⟨a,b,c⟩ + cases a <;> revert b c <;> decide + +theorem fiber_correct_49 : ∀ t : Config, t ∈ fiber 49 ↔ profile t = some 49 := by + rintro ⟨a,b,c⟩ + cases a <;> revert b c <;> decide + +theorem fiber_correct_50 : ∀ t : Config, t ∈ fiber 50 ↔ profile t = some 50 := by + rintro ⟨a,b,c⟩ + cases a <;> revert b c <;> decide + +theorem mem_fiber_iff (k : Fin 51) (t : Config) : t ∈ fiber k ↔ profile t = some k := by + fin_cases k + · exact fiber_correct_0 t + · exact fiber_correct_1 t + · exact fiber_correct_2 t + · exact fiber_correct_3 t + · exact fiber_correct_4 t + · exact fiber_correct_5 t + · exact fiber_correct_6 t + · exact fiber_correct_7 t + · exact fiber_correct_8 t + · exact fiber_correct_9 t + · exact fiber_correct_10 t + · exact fiber_correct_11 t + · exact fiber_correct_12 t + · exact fiber_correct_13 t + · exact fiber_correct_14 t + · exact fiber_correct_15 t + · exact fiber_correct_16 t + · exact fiber_correct_17 t + · exact fiber_correct_18 t + · exact fiber_correct_19 t + · exact fiber_correct_20 t + · exact fiber_correct_21 t + · exact fiber_correct_22 t + · exact fiber_correct_23 t + · exact fiber_correct_24 t + · exact fiber_correct_25 t + · exact fiber_correct_26 t + · exact fiber_correct_27 t + · exact fiber_correct_28 t + · exact fiber_correct_29 t + · exact fiber_correct_30 t + · exact fiber_correct_31 t + · exact fiber_correct_32 t + · exact fiber_correct_33 t + · exact fiber_correct_34 t + · exact fiber_correct_35 t + · exact fiber_correct_36 t + · exact fiber_correct_37 t + · exact fiber_correct_38 t + · exact fiber_correct_39 t + · exact fiber_correct_40 t + · exact fiber_correct_41 t + · exact fiber_correct_42 t + · exact fiber_correct_43 t + · exact fiber_correct_44 t + · exact fiber_correct_45 t + · exact fiber_correct_46 t + · exact fiber_correct_47 t + · exact fiber_correct_48 t + · exact fiber_correct_49 t + · exact fiber_correct_50 t + +def coefficient {K : Type*} [CommSemiring K] (a b c : Tile → K) (k : Fin 51) : K := + ∑ t ∈ fiber k, a t.1 * b t.2.1 * c t.2.2 + +def literalCoefficient {K : Type*} [CommSemiring K] (a b c : Tile → K) + (d : Finset (Fin 6 × Fin 6)) : K := + ∑ t : Config, if Realizes t d then a t.1 * b t.2.1 * c t.2.2 else 0 + +theorem coefficient_eq_literal {K : Type*} [CommSemiring K] (a b c : Tile → K) (k : Fin 51) : + coefficient a b c k = literalCoefficient a b c (diagram k) := by + unfold coefficient literalCoefficient + rw [← Finset.sum_filter] + congr 1 + ext t + simp only [mem_filter, mem_univ, true_and, mem_fiber_iff, profile_some_iff] + +def mirrorIndex : Fin 51 → Fin 51 := ![0,31,28,29,24,15,16,34,33,32,10,13,12,11,46,5,6,40,18,37,26,21,47,45,4,36,20,43,2,3,44,1,9,8,7,41,25,19,42,39,17,35,38,27,30,23,14,22,50,49,48] + +theorem mirrorIndex_involutive : Function.Involutive mirrorIndex := by + unfold Function.Involutive + decide + +def reverseSlots : Fin 6 → Fin 6 := ![2,1,0,5,4,3] + +theorem diagram_mirror (k : Fin 51) (i j : Fin 6) : + boundaryAdj (diagram (mirrorIndex k)) i j ↔ + boundaryAdj (diagram k) (reverseSlots i) (reverseSlots j) := by + fin_cases k <;> decide +revert + + + +def tileNumerator {K : Type*} [CommRing K] (q I z : K) : Tile → K + | .vacant => (q^4*z^2-1)*(q^6*z^2-1) + | .vertical₀ | .vertical₁ => I*(q^4+1)*z*(q^6-z^2) + | .diagonal₀ | .diagonal₁ => q^2*(z^2-1)*(q^6-z^2) + | .cap | .cup => I*(q^4+1)*q^3*z*(z^2-1) + | .verticalPair => (q^6-z^2)*(q^4-z^2) + | .capCup => q^4*(z^2-q^2)*(z^2-1) + +theorem coefficient_0 {K : Type*} [CommSemiring K] (a b c : Tile → K) : + coefficient a b c 0 = a .vacant * b .vacant * c .vacant := by + simp [coefficient, fiber] + +theorem coefficient_1 {K : Type*} [CommSemiring K] (a b c : Tile → K) : + coefficient a b c 1 = a .vertical₀ * b .cap * c .vacant + a .diagonal₀ * b .diagonal₀ * c .cap := by + simp [coefficient, fiber] + +theorem coefficient_2 {K : Type*} [CommSemiring K] (a b c : Tile → K) : + coefficient a b c 2 = a .verticalPair * b .capCup * c .cap := by + simp [coefficient, fiber] + +theorem coefficient_3 {K : Type*} [CommSemiring K] (a b c : Tile → K) : + coefficient a b c 3 = a .verticalPair * b .capCup * c .capCup := by + simp [coefficient, fiber] + +theorem coefficient_4 {K : Type*} [CommSemiring K] (a b c : Tile → K) : + coefficient a b c 4 = a .verticalPair * b .cap * c .diagonal₁ := by + simp [coefficient, fiber] + +theorem coefficient_5 {K : Type*} [CommSemiring K] (a b c : Tile → K) : + coefficient a b c 5 = a .verticalPair * b .cap * c .vertical₁ := by + simp [coefficient, fiber] + +theorem coefficient_6 {K : Type*} [CommSemiring K] (a b c : Tile → K) : + coefficient a b c 6 = a .verticalPair * b .capCup * c .verticalPair := by + simp [coefficient, fiber] + +theorem coefficient_7 {K : Type*} [CommSemiring K] (a b c : Tile → K) : + coefficient a b c 7 = a .vertical₀ * b .capCup * c .vertical₀ := by + simp [coefficient, fiber] + +theorem coefficient_8 {K : Type*} [CommSemiring K] (a b c : Tile → K) : + coefficient a b c 8 = a .vertical₀ * b .capCup * c .diagonal₀ := by + simp [coefficient, fiber] + +theorem coefficient_9 {K : Type*} [CommSemiring K] (a b c : Tile → K) : + coefficient a b c 9 = a .vertical₀ * b .cap * c .cup + a .diagonal₀ * b .diagonal₀ * c .capCup := by + simp [coefficient, fiber] + +theorem coefficient_10 {K : Type*} [CommSemiring K] (a b c : Tile → K) : + coefficient a b c 10 = a .vertical₁ * b .diagonal₀ * c .cap + a .diagonal₁ * b .cap * c .vacant := by + simp [coefficient, fiber] + +theorem coefficient_11 {K : Type*} [CommSemiring K] (a b c : Tile → K) : + coefficient a b c 11 = a .diagonal₁ * b .capCup * c .vertical₀ := by + simp [coefficient, fiber] + +theorem coefficient_12 {K : Type*} [CommSemiring K] (a b c : Tile → K) : + coefficient a b c 12 = a .diagonal₁ * b .capCup * c .diagonal₀ := by + simp [coefficient, fiber] + +theorem coefficient_13 {K : Type*} [CommSemiring K] (a b c : Tile → K) : + coefficient a b c 13 = a .vertical₁ * b .diagonal₀ * c .capCup + a .diagonal₁ * b .cap * c .cup := by + simp [coefficient, fiber] + +theorem coefficient_14 {K : Type*} [CommSemiring K] (a b c : Tile → K) : + coefficient a b c 14 = a .vacant * b .vertical₀ * c .vacant + a .cup * b .capCup * c .cap := by + simp [coefficient, fiber] + +theorem coefficient_15 {K : Type*} [CommSemiring K] (a b c : Tile → K) : + coefficient a b c 15 = a .cap * b .vertical₀ * c .vacant + a .verticalPair * b .verticalPair * c .cap + a .capCup * b .capCup * c .cap := by + simp [coefficient, fiber, add_assoc] + +theorem coefficient_16 {K : Type*} [CommSemiring K] (a b c : Tile → K) : + coefficient a b c 16 = a .cap * b .vertical₀ * c .cup + a .verticalPair * b .verticalPair * c .capCup + a .capCup * b .verticalPair * c .verticalPair + a .capCup * b .capCup * c .capCup := by + simp [coefficient, fiber, add_assoc] + +theorem coefficient_17 {K : Type*} [CommSemiring K] (a b c : Tile → K) : + coefficient a b c 17 = a .vertical₀ * b .verticalPair * c .vertical₀ + a .diagonal₀ * b .vertical₀ * c .diagonal₁ := by + simp [coefficient, fiber] + +theorem coefficient_18 {K : Type*} [CommSemiring K] (a b c : Tile → K) : + coefficient a b c 18 = a .verticalPair * b .verticalPair * c .verticalPair := by + simp [coefficient, fiber] + +theorem coefficient_19 {K : Type*} [CommSemiring K] (a b c : Tile → K) : + coefficient a b c 19 = a .vertical₀ * b .verticalPair * c .diagonal₀ + a .diagonal₀ * b .vertical₀ * c .vertical₁ := by + simp [coefficient, fiber] + +theorem coefficient_20 {K : Type*} [CommSemiring K] (a b c : Tile → K) : + coefficient a b c 20 = a .vertical₁ * b .vertical₀ * c .diagonal₁ + a .diagonal₁ * b .verticalPair * c .vertical₀ := by + simp [coefficient, fiber] + +theorem coefficient_21 {K : Type*} [CommSemiring K] (a b c : Tile → K) : + coefficient a b c 21 = a .vertical₁ * b .vertical₀ * c .vertical₁ + a .diagonal₁ * b .verticalPair * c .diagonal₀ := by + simp [coefficient, fiber] + +theorem coefficient_22 {K : Type*} [CommSemiring K] (a b c : Tile → K) : + coefficient a b c 22 = a .vacant * b .vertical₀ * c .cup + a .cup * b .verticalPair * c .verticalPair + a .cup * b .capCup * c .capCup := by + simp [coefficient, fiber, add_assoc] + +theorem coefficient_23 {K : Type*} [CommSemiring K] (a b c : Tile → K) : + coefficient a b c 23 = a .vacant * b .diagonal₀ * c .vertical₀ + a .cup * b .cap * c .diagonal₁ := by + simp [coefficient, fiber] + +theorem coefficient_24 {K : Type*} [CommSemiring K] (a b c : Tile → K) : + coefficient a b c 24 = a .cap * b .diagonal₀ * c .vertical₀ + a .capCup * b .cap * c .diagonal₁ := by + simp [coefficient, fiber] + +theorem coefficient_25 {K : Type*} [CommSemiring K] (a b c : Tile → K) : + coefficient a b c 25 = a .diagonal₀ * b .diagonal₀ * c .verticalPair := by + simp [coefficient, fiber] + +theorem coefficient_26 {K : Type*} [CommSemiring K] (a b c : Tile → K) : + coefficient a b c 26 = a .vertical₁ * b .diagonal₀ * c .verticalPair := by + simp [coefficient, fiber] + +theorem coefficient_27 {K : Type*} [CommSemiring K] (a b c : Tile → K) : + coefficient a b c 27 = a .vacant * b .diagonal₀ * c .diagonal₀ + a .cup * b .cap * c .vertical₁ := by + simp [coefficient, fiber] + +theorem coefficient_28 {K : Type*} [CommSemiring K] (a b c : Tile → K) : + coefficient a b c 28 = a .cap * b .diagonal₀ * c .diagonal₀ + a .capCup * b .cap * c .vertical₁ := by + simp [coefficient, fiber] + +theorem coefficient_29 {K : Type*} [CommSemiring K] (a b c : Tile → K) : + coefficient a b c 29 = a .capCup * b .capCup * c .verticalPair := by + simp [coefficient, fiber] + +theorem coefficient_30 {K : Type*} [CommSemiring K] (a b c : Tile → K) : + coefficient a b c 30 = a .cup * b .capCup * c .verticalPair := by + simp [coefficient, fiber] + +theorem coefficient_31 {K : Type*} [CommSemiring K] (a b c : Tile → K) : + coefficient a b c 31 = a .cap * b .vacant * c .vacant + a .verticalPair * b .vertical₁ * c .cap := by + simp [coefficient, fiber] + +theorem coefficient_32 {K : Type*} [CommSemiring K] (a b c : Tile → K) : + coefficient a b c 32 = a .cap * b .cup * c .vertical₀ + a .capCup * b .diagonal₁ * c .diagonal₁ := by + simp [coefficient, fiber] + +theorem coefficient_33 {K : Type*} [CommSemiring K] (a b c : Tile → K) : + coefficient a b c 33 = a .cap * b .cup * c .diagonal₀ + a .capCup * b .diagonal₁ * c .vertical₁ := by + simp [coefficient, fiber] + +theorem coefficient_34 {K : Type*} [CommSemiring K] (a b c : Tile → K) : + coefficient a b c 34 = a .cap * b .vacant * c .cup + a .verticalPair * b .vertical₁ * c .capCup + a .capCup * b .vertical₁ * c .verticalPair := by + simp [coefficient, fiber, add_assoc] + +theorem coefficient_35 {K : Type*} [CommSemiring K] (a b c : Tile → K) : + coefficient a b c 35 = a .vertical₀ * b .diagonal₁ * c .vacant + a .diagonal₀ * b .cup * c .cap := by + simp [coefficient, fiber] + +theorem coefficient_36 {K : Type*} [CommSemiring K] (a b c : Tile → K) : + coefficient a b c 36 = a .verticalPair * b .diagonal₁ * c .diagonal₁ := by + simp [coefficient, fiber] + +theorem coefficient_37 {K : Type*} [CommSemiring K] (a b c : Tile → K) : + coefficient a b c 37 = a .verticalPair * b .diagonal₁ * c .vertical₁ := by + simp [coefficient, fiber] + +theorem coefficient_38 {K : Type*} [CommSemiring K] (a b c : Tile → K) : + coefficient a b c 38 = a .vertical₀ * b .diagonal₁ * c .cup + a .diagonal₀ * b .cup * c .capCup := by + simp [coefficient, fiber] + +theorem coefficient_39 {K : Type*} [CommSemiring K] (a b c : Tile → K) : + coefficient a b c 39 = a .vertical₀ * b .vertical₁ * c .vertical₀ + a .diagonal₀ * b .vacant * c .diagonal₁ := by + simp [coefficient, fiber] + +theorem coefficient_40 {K : Type*} [CommSemiring K] (a b c : Tile → K) : + coefficient a b c 40 = a .verticalPair * b .vertical₁ * c .verticalPair := by + simp [coefficient, fiber] + +theorem coefficient_41 {K : Type*} [CommSemiring K] (a b c : Tile → K) : + coefficient a b c 41 = a .vertical₀ * b .vertical₁ * c .diagonal₀ + a .diagonal₀ * b .vacant * c .vertical₁ := by + simp [coefficient, fiber] + +theorem coefficient_42 {K : Type*} [CommSemiring K] (a b c : Tile → K) : + coefficient a b c 42 = a .diagonal₀ * b .cup * c .verticalPair := by + simp [coefficient, fiber] + +theorem coefficient_43 {K : Type*} [CommSemiring K] (a b c : Tile → K) : + coefficient a b c 43 = a .vertical₁ * b .cup * c .cap + a .diagonal₁ * b .diagonal₁ * c .vacant := by + simp [coefficient, fiber] + +theorem coefficient_44 {K : Type*} [CommSemiring K] (a b c : Tile → K) : + coefficient a b c 44 = a .vertical₁ * b .cup * c .capCup + a .diagonal₁ * b .diagonal₁ * c .cup := by + simp [coefficient, fiber] + +theorem coefficient_45 {K : Type*} [CommSemiring K] (a b c : Tile → K) : + coefficient a b c 45 = a .vertical₁ * b .vacant * c .diagonal₁ + a .diagonal₁ * b .vertical₁ * c .vertical₀ := by + simp [coefficient, fiber] + +theorem coefficient_46 {K : Type*} [CommSemiring K] (a b c : Tile → K) : + coefficient a b c 46 = a .vertical₁ * b .vacant * c .vertical₁ + a .diagonal₁ * b .vertical₁ * c .diagonal₀ := by + simp [coefficient, fiber] + +theorem coefficient_47 {K : Type*} [CommSemiring K] (a b c : Tile → K) : + coefficient a b c 47 = a .vertical₁ * b .cup * c .verticalPair := by + simp [coefficient, fiber] + +theorem coefficient_48 {K : Type*} [CommSemiring K] (a b c : Tile → K) : + coefficient a b c 48 = a .vacant * b .cup * c .vertical₀ + a .cup * b .diagonal₁ * c .diagonal₁ := by + simp [coefficient, fiber] + +theorem coefficient_49 {K : Type*} [CommSemiring K] (a b c : Tile → K) : + coefficient a b c 49 = a .vacant * b .cup * c .diagonal₀ + a .cup * b .diagonal₁ * c .vertical₁ := by + simp [coefficient, fiber] + +theorem coefficient_50 {K : Type*} [CommSemiring K] (a b c : Tile → K) : + coefficient a b c 50 = a .vacant * b .vacant * c .cup + a .cup * b .vertical₁ * c .verticalPair := by + simp [coefficient, fiber] + +end +end CriticalStrip.Diagram.ThreeBox + +end OAI diff --git a/lean/OAI/Combinatorics/StripMass/TopPadding.lean b/lean/OAI/Combinatorics/StripMass/TopPadding.lean new file mode 100644 index 0000000000000000000000000000000000000000..859113bfd8e97282066e8e26ac6f4cdd3ec45517 --- /dev/null +++ b/lean/OAI/Combinatorics/StripMass/TopPadding.lean @@ -0,0 +1,441 @@ +import Mathlib +import OAI.Combinatorics.StripMass.BottomPadding + +namespace OAI + +/-! Critical honeycomb strip paths, polynomial identities and crossing mass. -/ + + +namespace CriticalStrip.Diagram +noncomputable section +open Finset +theorem realizes_padTop_iff {n : ℕ} (p q : Pairing n) (t : Configuration n) : + Realizes p.padTop q.padTop t.padTop ↔ Realizes p q t := by + constructor + · intro h + have ht : ∀ i, i.val+1=n → ¬(t i).Occupied 3 := by + intro i hi ho + have hg := h.glued i.castSucc (Fin.last n) hi + exact Tile.vacant_not_occupied 0 (by simpa using hg.mp (by simpa using ho)) + refine ⟨?_, ?_, ?_, ht, ?_, ?_, ?_⟩ + · intro i; simpa using h.west i.castSucc + · intro i; simpa using h.east i.castSucc + · intro i hi + simpa using h.south i.castSucc hi + · intro i j hij + simpa using h.glued i.castSucc j.castSucc hij + · intro v w hvw + obtain ⟨j,hj,hr⟩ := h.no_loop _ _ ((wiring_padTop_iff p t v w).2 hvw) + induction j using Fin.lastCases with + | last => exact (q.padTop_not_occupied_last hj).elim + | cast j => + exact ⟨j,(q.padTop_occupied_castSucc j).1 hj, + (reach_padTop_iff p t ht v (j,2)).1 hr⟩ + · intro i j hij + exact (q.padTop_adj_castSucc i j).symm.trans <| + (h.output i.castSucc j.castSucc (fun h' => hij (Fin.castSucc_injective n h'))).trans + (reach_padTop_iff p t ht (i,2) (j,2)) + · intro h + refine ⟨?_, ?_, ?_, ?_, ?_, ?_, ?_⟩ + · intro i + induction i using Fin.lastCases with + | last => simp + | cast i => simpa using h.west i + · intro i + induction i using Fin.lastCases with + | last => simp + | cast i => simpa using h.east i + · intro i hi + induction i using Fin.lastCases with + | last => simp + | cast i => simpa using h.south i hi + · intro i hi + have he : i = Fin.last n := Fin.ext (by change i.val = n; change i.val+1=n+1 at hi; omega) + subst i; simp + · intro i j hij + induction i using Fin.lastCases with + | last => + have hj := j.isLt + change n+1=j.val at hij + omega + | cast i => + induction j using Fin.lastCases with + | last => simp [h.north i hij] + | cast j => simpa using h.glued i j hij + · rintro ⟨i,a⟩ ⟨j,b⟩ hij + induction i using Fin.lastCases with + | last => exact (wiring_padTop_last p t h.north a _ hij).elim + | cast i => + induction j using Fin.lastCases with + | last => exact (wiring_padTop_last_right p t h.north _ b hij).elim + | cast j => + obtain ⟨k,hk,hr⟩ := h.no_loop _ _ ((wiring_padTop_iff p t (i,a) (j,b)).1 hij) + exact ⟨k.castSucc,(q.padTop_occupied_castSucc k).2 hk, + (reach_padTop_iff p t h.north (i,a) (k,2)).2 hr⟩ + · intro i j hij + induction i using Fin.lastCases with + | last => simp [reach_padTop_last_iff p t h.north, hij.symm] + | cast i => + induction j using Fin.lastCases with + | last => simp [reach_padTop_last_right_iff p t h.north] + | cast j => + exact (Pairing.padTop_adj_castSucc q i j).trans <| + (h.output i j (fun h' => hij (congrArg Fin.castSucc h'))).trans + (reach_padTop_iff p t h.north (i,2) (j,2)).symm + +theorem Tile.vacant_of_three_top (t : Tile) (h₃ : ¬ t.Occupied 3) + (h₁ : ¬ t.Occupied 1) (h₂ : ¬ t.Occupied 2) : t = .vacant := by + cases t <;> simp_all [Tile.Occupied, Tile.Adj, Tile.edges] + +theorem Realizes.top_vacant {n : ℕ} {p q : Pairing n} {t : Configuration (n+1)} + (h : Realizes p.padTop q.padTop t) : t (Fin.last n) = .vacant := + Tile.vacant_of_three_top _ (h.north (Fin.last n) rfl) + (fun hc => p.padTop_not_occupied_last ((h.west (Fin.last n)).mp hc)) + (fun hc => q.padTop_not_occupied_last ((h.east (Fin.last n)).mp hc)) + +theorem realizes_snoc_top_iff {n : ℕ} (p q : Pairing n) + (a : Tile) (t : Configuration n) : + Realizes p.padTop q.padTop (Fin.snoc t a) ↔ + a = .vacant ∧ Realizes p q t := by + constructor + · intro h + have ha : a = .vacant := by simpa using h.top_vacant + subst a + exact ⟨rfl, (realizes_padTop_iff p q t).mp h⟩ + · rintro ⟨rfl, h⟩ + exact (realizes_padTop_iff p q t).mpr h + +theorem column_padTop {𝕜 : Type*} [CommRing 𝕜] {n : ℕ} + (w : Fin (n+1) → Weights 𝕜) (p q : Pairing n) : + column w q.padTop p.padTop = column (fun i => w i.castSucc) q p := by + classical + unfold column + rw [← Fintype.sum_equiv (Fin.snocEquiv (fun _ : Fin (n+1) => Tile)) + (fun tt : Tile × Configuration n => + if Realizes p.padTop q.padTop (Fin.snoc tt.2 tt.1) + then ∏ i : Fin (n+1), (w i).tile ((Fin.snoc tt.2 tt.1 : Configuration (n+1)) i) else 0) + _ (fun _ => rfl)] + rw [Fintype.sum_prod_type] + simp only [realizes_snoc_top_iff] + rw [Finset.sum_eq_single Tile.vacant] + · apply Finset.sum_congr rfl + intro t _ + simp [Fin.prod_univ_castSucc, Weights.tile] + · intro a ha hav + simp [hav] + · simp + + +theorem Tile.deletion_zero_of_north_vacant_east_occupied + {𝕜 : Type*} [Zero 𝕜] [One 𝕜] (a : Tile) (hn : ¬a.Occupied 3) + (he : a.Occupied 2) : (deletionWeights : Weights 𝕜).tile a = 0 := by + cases a <;> simp_all [Tile.Occupied, Tile.Adj, Tile.edges, + deletionWeights, Weights.tile] + +theorem Tile.identity_zero_of_north_vacant_west_occupied + {𝕜 : Type*} [Zero 𝕜] [One 𝕜] (a : Tile) (hn : ¬a.Occupied 3) + (hw : a.Occupied 1) : (identityWeights : Weights 𝕜).tile a = 0 := by + cases a <;> simp_all [Tile.Occupied, Tile.Adj, Tile.edges, + identityWeights, Weights.tile] + +theorem column_deletion_top_row {𝕜 : Type*} [CommRing 𝕜] {n : ℕ} + (w : Fin (n+1) → Weights 𝕜) (hw : w (Fin.last n) = deletionWeights) + (p q : Pairing (n+1)) (hq : q.Occupied (Fin.last n)) : column w q p = 0 := by + classical + apply Finset.sum_eq_zero + intro t ht + split_ifs with h + · apply Finset.prod_eq_zero (Finset.mem_univ (Fin.last n)) + rw [hw] + exact Tile.deletion_zero_of_north_vacant_east_occupied _ + (h.north (Fin.last n) rfl) ((h.east (Fin.last n)).mpr hq) + · rfl + +theorem column_identity_top_col {𝕜 : Type*} [CommRing 𝕜] {n : ℕ} + (w : Fin (n+1) → Weights 𝕜) (hw : w (Fin.last n) = identityWeights) + (p q : Pairing (n+1)) (hp : p.Occupied (Fin.last n)) : column w q p = 0 := by + classical + apply Finset.sum_eq_zero + intro t ht + split_ifs with h + · apply Finset.prod_eq_zero (Finset.mem_univ (Fin.last n)) + rw [hw] + exact Tile.identity_zero_of_north_vacant_west_occupied _ + (h.north (Fin.last n) rfl) ((h.west (Fin.last n)).mpr hp) + · rfl + +namespace Pairing + +def nonemptyPadTop {n : ℕ} (p : NonemptyPairing n) : NonemptyPairing (n+1) := + ⟨p.val.padTop, fun h => p.property ((padTop_eq_empty _).mp h)⟩ + +def nonemptyTopVacantEquiv (n : ℕ) : + NonemptyPairing n ≃ {p : NonemptyPairing (n+1) // ¬p.val.Occupied (Fin.last n)} where + toFun p := ⟨nonemptyPadTop p, p.val.padTop_not_occupied_last⟩ + invFun p := ⟨p.val.val.restrict Fin.castSuccOrderEmb, by + intro he + have hp := padTop_restrict p.val.val p.property + rw [he, padTop_empty] at hp + exact p.val.property hp.symm⟩ + left_inv p := Subtype.ext (restrict_map _ _) + right_inv p := Subtype.ext (Subtype.ext (padTop_restrict _ p.property)) + +abbrev TopOccupiedNonempty (n : ℕ) := + {p : NonemptyPairing (n+1) // ¬¬p.val.Occupied (Fin.last n)} + +def nonemptyTopSplit (n : ℕ) : + NonemptyPairing n ⊕ TopOccupiedNonempty n ≃ NonemptyPairing (n+1) := by + classical + exact (Equiv.sumCongr (nonemptyTopVacantEquiv n) (Equiv.refl _)).trans + (Equiv.sumCompl (fun p : NonemptyPairing (n+1) => ¬p.val.Occupied (Fin.last n))) + +@[simp] theorem nonemptyTopSplit_inl {n : ℕ} (p : NonemptyPairing n) : + nonemptyTopSplit n (.inl p) = nonemptyPadTop p := rfl + +@[simp] theorem nonemptyTopSplit_inr {n : ℕ} (p : TopOccupiedNonempty n) : + nonemptyTopSplit n (.inr p) = p.val := rfl + +end Pairing + + +theorem det_flat_top {𝕜 : Type*} [CommRing 𝕜] {n : ℕ} + (w : Fin (n+1) → Weights 𝕜) + (hw : w (Fin.last n) = identityWeights ∨ w (Fin.last n) = deletionWeights) : + (1-restrictedColumn w).det = (1-restrictedColumn (fun i => w i.castSucc)).det := by + classical + let e := Pairing.nonemptyTopSplit n + let M := (restrictedColumn w).submatrix e e + have hblock : M.toBlocks₁₁ = restrictedColumn (fun i => w i.castSucc) := by + ext q p + exact column_padTop w p.val q.val + have hdet : (1-restrictedColumn w).det = (1-M).det := by + rw [← Matrix.det_submatrix_equiv_self e] + congr 1 + simp only [Matrix.submatrix_sub, Pi.sub_apply, Matrix.submatrix_one_equiv] + rfl + rw [hdet] + rcases hw with hi | hd + · rw [det_one_sub_zero_cols M, hblock] + intro q p + exact column_identity_top_col w hi p.val.val (e q).val (not_not.mp p.property) + · rw [det_one_sub_zero_rows M, hblock] + intro q p + exact column_deletion_top_row w hd (e p).val q.val.val (not_not.mp q.property) + + +theorem Pairing.eq_empty_of_le_one {n : ℕ} (hn : n ≤ 1) (p : Pairing n) : + p = empty n := by + apply Subtype.ext + apply Finset.eq_empty_iff_forall_notMem.mpr + intro e he + have hlt := p.property.1 e he + have hi := e.1.isLt + have hj := e.2.isLt + change e.1.val < e.2.val at hlt + omega + +theorem det_column_le_one {𝕜 : Type*} [CommRing 𝕜] {n : ℕ} (hn : n ≤ 1) + (w : Fin n → Weights 𝕜) : (1-restrictedColumn w).det = 1 := by + let : IsEmpty (NonemptyPairing n) := ⟨fun p => p.property (p.val.eq_empty_of_le_one hn)⟩ + exact Matrix.det_isEmpty + +def Weights.IsFlat {𝕜 : Type*} [Zero 𝕜] [One 𝕜] (w : Weights 𝕜) : Prop := + w = identityWeights ∨ w = deletionWeights + + + +theorem det_one_nonflat {𝕜 : Type*} [CommRing 𝕜] (n : ℕ) + (w : Fin n → Weights 𝕜) + (hw : ∀ i j, ¬(w i).IsFlat → ¬(w j).IsFlat → i = j) : + (1-restrictedColumn w).det = 1 := by + classical + induction n with + | zero => exact det_column_le_one (by omega) w + | succ n ih => + by_cases hn : n = 0 + · subst n; exact det_column_le_one (by omega) w + by_cases hb : (w 0).IsFlat + · rw [det_flat_bottom w hb] + apply ih + intro i j hi hj + exact Fin.succ_injective n (hw i.succ j.succ hi hj) + · have ht : (w (Fin.last n)).IsFlat := by + by_contra ht + have he := congrArg Fin.val (hw 0 (Fin.last n) hb ht) + exact hn (by simpa using he.symm) + rw [det_flat_top w ht] + apply ih + intro i j hi hj + exact Fin.castSucc_injective n (hw i.castSucc j.castSucc hi hj) + +theorem vacuumRegular_one_nonflat {𝕜 : Type*} [Field 𝕜] {n : ℕ} + (w : Fin n → Weights 𝕜) (r : Fin n) + (hw : ∀ i, i ≠ r → (w i).IsFlat) : VacuumRegular w := by + unfold VacuumRegular + rw [det_one_nonflat n w] + · exact one_ne_zero + · intro i j hi hj + have hir : i = r := by by_contra h; exact hi (hw i h) + have hjr : j = r := by by_contra h; exact hj (hw j h) + exact hir.trans hjr.symm + +theorem inlinePrivate0_sin_two_lambda : Real.sin (2*lambda) = Real.cos (2*lambda) := by + rw [← Real.sin_pi_div_two_sub] + congr 1 + unfold lambda + ring + +theorem inlinePrivate0_sin_two_lambda_pos : 0 < Real.sin (2*lambda) := by + apply Real.sin_pos_of_pos_of_lt_pi <;> unfold lambda <;> linarith [Real.pi_pos] + +theorem inlinePrivate0_sin_three_lambda_pos : 0 < Real.sin (3*lambda) := by + apply Real.sin_pos_of_pos_of_lt_pi <;> unfold lambda <;> linarith [Real.pi_pos] + + +theorem physicalWeights_zero : physicalWeights 0 = identityWeights := by + have hs₂ := ne_of_gt inlinePrivate0_sin_two_lambda_pos + have hs₃ := ne_of_gt inlinePrivate0_sin_three_lambda_pos + have hd := inlinePrivate0_sin_two_lambda + unfold physicalWeights identityWeights L + simp only [add_zero, sub_zero, Real.sin_zero, mul_zero, zero_mul, zero_div] + congr 1 + · rw [← hd]; exact div_self (mul_ne_zero hs₂ hs₃) + · rw [mul_comm]; exact div_self (mul_ne_zero hs₂ hs₃) + + +theorem physicalWeights_three_lambda : physicalWeights (3*lambda) = deletionWeights := by + have hs₂ := ne_of_gt inlinePrivate0_sin_two_lambda_pos + have hs₃ := ne_of_gt inlinePrivate0_sin_three_lambda_pos + have h₅ : Real.sin (2*lambda+3*lambda) = Real.sin (3*lambda) := by + have harg : 2*lambda+3*lambda = Real.pi-3*lambda := by unfold lambda; ring + rw [harg, Real.sin_pi_sub] + have h₆ : Real.sin (3*lambda+3*lambda) = Real.sin (2*lambda) := by + have harg : 3*lambda+3*lambda = Real.pi-2*lambda := by unfold lambda; ring + rw [harg, Real.sin_pi_sub] + unfold physicalWeights deletionWeights L + simp only [sub_self, Real.sin_zero, mul_zero, zero_mul, zero_div, h₅, h₆] + congr 1 + · rw [← inlinePrivate0_sin_two_lambda, mul_comm]; exact div_self (mul_ne_zero hs₃ hs₂) + · have harg : 3*lambda-lambda = 2*lambda := by ring + rw [harg, mul_comm]; exact div_self (mul_ne_zero hs₃ hs₂) + + + +theorem physical_simultaneous_regular {n : ℕ} (u : Fin n → ℝ) (r : Fin n) + (hu : ∀ i, i ≠ r → u i = 0 ∨ u i = 3*lambda) : + (1-restrictedColumn (fun i => physicalWeights (3*lambda-u i))).det = 1 := by + apply det_one_nonflat + have hf : ∀ i, i ≠ r → (physicalWeights (3*lambda-u i)).IsFlat := by + intro i hi + rcases hu i hi with hz | ht + · rw [hz, sub_zero, physicalWeights_three_lambda] + exact Or.inr rfl + · rw [ht, sub_self, physicalWeights_zero] + exact Or.inl rfl + intro i j hi hj + have hir : i = r := by by_contra h; exact hi (hf i h) + have hjr : j = r := by by_contra h; exact hj (hf j h) + exact hir.trans hjr.symm + +def attachEmpty {𝕜 : Type*} [One 𝕜] {n : ℕ} + (v : NonemptyPairing n → 𝕜) : Pairing n → 𝕜 := by + classical + exact fun p => if h : p = empty n then 1 else v ⟨p,h⟩ + +@[simp] theorem attachEmpty_empty {𝕜 : Type*} [One 𝕜] {n : ℕ} + (v : NonemptyPairing n → 𝕜) : attachEmpty v (empty n) = 1 := by + simp [attachEmpty] + +@[simp] theorem attachEmpty_nonempty {𝕜 : Type*} [One 𝕜] {n : ℕ} + (v : NonemptyPairing n → 𝕜) (p : NonemptyPairing n) : attachEmpty v p.val = v p := by + simp [attachEmpty, p.property] + +def injectionColumn {𝕜 : Type*} [CommRing 𝕜] {n : ℕ} + (w : Fin n → Weights 𝕜) : NonemptyPairing n → 𝕜 := fun p => column w p.val (empty n) + + +def normalizedVacuum {𝕜 : Type*} [Field 𝕜] {n : ℕ} + (w : Fin n → Weights 𝕜) : Pairing n → 𝕜 := + attachEmpty ((1-restrictedColumn w)⁻¹.mulVec (injectionColumn w)) + +def IsNormalizedStationary {𝕜 : Type*} [CommRing 𝕜] {n : ℕ} + (w : Fin n → Weights 𝕜) (v : Pairing n → 𝕜) : Prop := + v (empty n) = 1 ∧ (column w).mulVec v = v + +theorem column_mulVec_empty {𝕜 : Type*} [CommRing 𝕜] {n : ℕ} + (w : Fin n → Weights 𝕜) (v : Pairing n → 𝕜) : + (column w).mulVec v (empty n) = v (empty n) := by + classical + simp [Matrix.mulVec, dotProduct, column_empty_row] + +theorem column_mulVec_nonempty {𝕜 : Type*} [CommRing 𝕜] {n : ℕ} + (w : Fin n → Weights 𝕜) (v : Pairing n → 𝕜) (p : NonemptyPairing n) : + (column w).mulVec v p.val = injectionColumn w p * v (empty n) + + (restrictedColumn w).mulVec (fun q => v q.val) p := by + classical + exact Fintype.sum_eq_add_sum_subtype_ne _ (empty n) + +theorem normalizedVacuum_stationary {𝕜 : Type*} [Field 𝕜] {n : ℕ} + (w : Fin n → Weights 𝕜) (hw : VacuumRegular w) : + IsNormalizedStationary w (normalizedVacuum w) := by + classical + let Q := restrictedColumn w + let v := injectionColumn w + let P := (1-Q)⁻¹.mulVec v + have hsolve : P-Q.mulVec P = v := by + suffices hs : (1-Q).mulVec P = v by simpa [Matrix.sub_mulVec] using hs + change (1-Q).mulVec ((1-Q)⁻¹.mulVec v) = v + rw [Matrix.mulVec_mulVec, Matrix.mul_nonsing_inv _ (isUnit_iff_ne_zero.mpr hw), + Matrix.one_mulVec] + refine ⟨attachEmpty_empty _, ?_⟩ + funext p + by_cases hp : p = empty n + · subst p; exact column_mulVec_empty w _ + · let p' : NonemptyPairing n := ⟨p,hp⟩ + change (column w).mulVec (attachEmpty P) p'.val = attachEmpty P p'.val + rw [column_mulVec_nonempty] + simp only [attachEmpty_empty, mul_one, attachEmpty_nonempty] + have he := congrFun hsolve p' + change P p' - Q.mulVec P p' = v p' at he + exact eq_sub_iff_add_eq.mp he.symm + +theorem normalizedVacuum_unique {𝕜 : Type*} [Field 𝕜] {n : ℕ} + (w : Fin n → Weights 𝕜) (hw : VacuumRegular w) + (v : Pairing n → 𝕜) (hv : IsNormalizedStationary w v) : + v = normalizedVacuum w := by + classical + let x : NonemptyPairing n → 𝕜 := fun p => v p.val + let Q := restrictedColumn w + have heq : (1-Q).mulVec x = injectionColumn w := by + rw [Matrix.sub_mulVec, Matrix.one_mulVec] + funext p + have hp := congrFun hv.2 p.val + rw [column_mulVec_nonempty, hv.1, mul_one] at hp + change x p - Q.mulVec x p = injectionColumn w p + exact (eq_sub_iff_add_eq.mpr (hp.trans (by rfl))).symm + have hx : x = (1-Q)⁻¹.mulVec (injectionColumn w) := by + rw [← heq, Matrix.mulVec_mulVec, + Matrix.nonsing_inv_mul _ (isUnit_iff_ne_zero.mpr hw), Matrix.one_mulVec] + funext p + by_cases hp : p = empty n + · subst p; simpa [normalizedVacuum] using hv.1 + · let p' : NonemptyPairing n := ⟨p,hp⟩ + change x p' = attachEmpty ((1-Q)⁻¹.mulVec (injectionColumn w)) p'.val + rw [attachEmpty_nonempty] + exact congrFun hx p' + +end + +noncomputable section + + +def rawColumn {R : Type*} [CommRing R] {n : ℕ} (w : Fin n → Tile → R) : + Matrix (Pairing n) (Pairing n) R := by + classical + exact fun q p => ∑ t : Configuration n, + if Realizes p q t then ∏ i, w i (t i) else 0 + +end +end CriticalStrip.Diagram + +end OAI diff --git a/lean/OAI/Combinatorics/StripMass/Trigonometry.lean b/lean/OAI/Combinatorics/StripMass/Trigonometry.lean new file mode 100644 index 0000000000000000000000000000000000000000..a0bc5e601a98052bd68caabd68ebbd64650d5e77 --- /dev/null +++ b/lean/OAI/Combinatorics/StripMass/Trigonometry.lean @@ -0,0 +1,431 @@ +import Mathlib +import OAI.Combinatorics.StripMass.StieltjesLimits + +namespace OAI + +/-! Critical honeycomb strip paths, polynomial identities and crossing mass. -/ + + +namespace CriticalStrip +noncomputable section +open Polynomial Set Filter +open scoped Topology +theorem C_c_facts : 0 < c ∧ c < C ∧ C ^ 2 + c ^ 2 = 1 ∧ + C ^ 2 * (1 - C ^ 2) = 1 / 8 ∧ c ^ 2 * (1 - c ^ 2) = 1 / 8 ∧ + 1 - 2 * C ^ 2 ≠ 0 ∧ 1 - 2 * c ^ 2 ≠ 0 := by + have hh := branches_sq (u := (0 : ℝ)) (by constructor <;> norm_num) + rw [highBranch_zero, lowBranch_zero] at hh + simp only [sub_zero, sqrt_half] at hh + have hC : 0 ≤ C := by rw [← highBranch_zero]; exact Real.sqrt_nonneg _ + have hc : 0 ≤ c := by rw [← lowBranch_zero]; exact Real.sqrt_nonneg _ + have hspos : 0 < Real.sqrt 2 := Real.sqrt_pos.2 (by norm_num) + have hs2 := Real.sq_sqrt (by norm_num : (0 : ℝ) ≤ 2) + refine ⟨?_, ?_, ?_, ?_, ?_, ?_, ?_⟩ <;> nlinarith [sqrt_two_lt_two, hh.1, hh.2.1] + +theorem harmonic_eval (b : ℝ) : harmonicCoordinate.eval b = b ^ 2 * (1 - b ^ 2) := by + simp [harmonicCoordinate] + + + +theorem branch_rescaled_tendsto {α : Type*} {l : Filter α} {z b : α → ℝ} {r : ℝ} + (hz : ∀ᶠ t in l, z t ≠ 0) (hb : Tendsto b l (𝓝 r)) + (hh : ∀ᶠ t in l, harmonicCoordinate.eval (b t) = (1 + 1 / z t) / 8) + (hr : r ^ 2 * (1 - r ^ 2) = 1 / 8) (hrn : r ≠ 0) (hrd : 1 - 2 * r ^ 2 ≠ 0) : + Tendsto (fun t => z t * (b t - r)) l (𝓝 ((1 / 8) / ((2 * r) * (1 - 2 * r ^ 2)))) := by + have hd := (hb.add_const r).mul (((hb.pow 2).const_sub 1).sub_const (r ^ 2)) + have hdn : (r + r) * (1 - r ^ 2 - r ^ 2) ≠ 0 := by + convert mul_ne_zero (mul_ne_zero (by norm_num : (2 : ℝ) ≠ 0) hrn) hrd using 1 + ring + have ht := (tendsto_const_nhds : Tendsto (fun _ : α => (1 / 8 : ℝ)) l (𝓝 (1 / 8))).div hd hdn + have hs : (r + r) * (1 - r ^ 2 - r ^ 2) = (2 * r) * (1 - 2 * r ^ 2) := by ring + rw [hs] at ht + apply ht.congr' + filter_upwards [hz, hh, hd.eventually_ne hdn] with t hzt hht hdt + simp only [harmonic_eval] at hht + apply (div_eq_iff hdt).2 + have hbase : (b t - r) * (b t + r) * (1 - b t ^ 2 - r ^ 2) = (1 / z t) / 8 := by + nlinarith [hht, hr] + calc (1 / 8 : ℝ) = z t * ((1 / z t) / 8) := by field_simp + _ = z t * ((b t - r) * (b t + r) * (1 - b t ^ 2 - r ^ 2)) := by rw [hbase] + _ = z t * (b t - r) * ((b t + r) * (1 - b t ^ 2 - r ^ 2)) := by ring + +theorem eventually_small_inverse {α : Type*} {l : Filter α} {z : α → ℝ} + (hz : Tendsto (fun t => 1 / z t) l (𝓝 0)) : + ∀ᶠ t in l, 1 / z t ∈ Ioo (-1 : ℝ) 1 := + hz.eventually (Ioo_mem_nhds (by norm_num) (by norm_num)) + +theorem highBranch_rescaled {α : Type*} {l : Filter α} {z : α → ℝ} + (hz : ∀ᶠ t in l, z t ≠ 0) (hi : Tendsto (fun t => 1 / z t) l (𝓝 0)) : + Tendsto (fun t => z t * (highBranch (1 / z t) - C)) l + (𝓝 ((1 / 8) / ((2 * C) * (1 - 2 * C ^ 2)))) := by + have hf := C_c_facts + apply branch_rescaled_tendsto hz + (by simpa only [highBranch_zero, Function.comp_def] using highBranch_continuous.continuousAt.tendsto.comp hi) + ((eventually_small_inverse hi).mono fun _ ht => (branches_harmonic ht).1) + hf.2.2.2.1 (ne_of_gt (lt_trans hf.1 hf.2.1)) hf.2.2.2.2.2.1 + +theorem lowBranch_rescaled {α : Type*} {l : Filter α} {z : α → ℝ} + (hz : ∀ᶠ t in l, z t ≠ 0) (hi : Tendsto (fun t => 1 / z t) l (𝓝 0)) : + Tendsto (fun t => z t * (lowBranch (1 / z t) - c)) l + (𝓝 ((1 / 8) / ((2 * c) * (1 - 2 * c ^ 2)))) := by + have hf := C_c_facts + apply branch_rescaled_tendsto hz + (by simpa only [lowBranch_zero, Function.comp_def] using lowBranch_continuous.continuousAt.tendsto.comp hi) + ((eventually_small_inverse hi).mono fun _ ht => (branches_harmonic ht).2) + hf.2.2.2.2.1 (ne_of_gt hf.1) hf.2.2.2.2.2.2 + + +theorem lower_rescaling_zero {α : Type*} {l : Filter α} {z v : α → ℝ} {L : ℝ} + (hz : ∀ᶠ t in l, z t ≠ 0) (hi : Tendsto (fun t => 1 / z t) l (𝓝 0)) + {k m : ℕ} (hkm : k < m) (hv : Tendsto (fun t => z t ^ m * v t) l (𝓝 L)) : + Tendsto (fun t => z t ^ k * v t) l (𝓝 0) := by + have hp := (hi.pow (m - k)).mul hv + have hmk : m - k ≠ 0 := Nat.ne_of_gt (Nat.sub_pos_of_lt hkm) + simp only [zero_pow hmk, zero_mul] at hp + apply hp.congr' + filter_upwards [hz] with t ht + rw [one_div, inv_pow, pow_sub₀ (z t) ht hkm.le] + field_simp + + + +theorem homogeneousQ_high_decay {α : Type*} {l : Filter α} {z : α → ℝ} + (hz : ∀ᶠ t in l, z t ≠ 0) (hi : Tendsto (fun t => 1 / z t) l (𝓝 0)) + (N : ℕ) (g : Polynomial ℝ) (k : ℕ) (hk : k < 2 * N + 1) : + Tendsto (fun t => z t ^ k * (homogeneousQ N g).eval (highBranch (1 / z t))) l (𝓝 0) := by + have hb : Tendsto (fun t => highBranch (1 / z t)) l (𝓝 C) := by + simpa only [highBranch_zero, Function.comp_def] using highBranch_continuous.continuousAt.tendsto.comp hi + have hscale := ((highBranch_rescaled hz hi).pow (2 * N + 1)).mul + (((hb.sub_const c).pow N).mul (g.continuous.continuousAt.tendsto.comp hb)) + have hlim : Tendsto (fun t => z t ^ (2 * N + 1) * + (homogeneousQ N g).eval (highBranch (1 / z t))) l + (𝓝 (((1 / 8) / ((2 * C) * (1 - 2 * C ^ 2))) ^ (2 * N + 1) * + ((C - c) ^ N * g.eval C))) := by + apply hscale.congr' + exact Eventually.of_forall fun t => by + simp only [homogeneousQ, eval_mul, eval_pow, eval_sub, eval_C, eval_X, Function.comp_def, mul_pow] + ring + exact lower_rescaling_zero hz hi hk hlim + +theorem homogeneousQ_low_limit {α : Type*} {l : Filter α} {z : α → ℝ} + (hz : ∀ᶠ t in l, z t ≠ 0) (hi : Tendsto (fun t => 1 / z t) l (𝓝 0)) + (N : ℕ) (g : Polynomial ℝ) : + ∃ L : ℝ, Tendsto (fun t => z t ^ N * (homogeneousQ N g).eval (lowBranch (1 / z t))) l (𝓝 L) := by + have hb : Tendsto (fun t => lowBranch (1 / z t)) l (𝓝 c) := by + simpa only [lowBranch_zero, Function.comp_def] using lowBranch_continuous.continuousAt.tendsto.comp hi + have hscale := ((hb.sub_const C).pow (2 * N + 1)).mul + (((lowBranch_rescaled hz hi).pow N).mul (g.continuous.continuousAt.tendsto.comp hb)) + refine ⟨_, hscale.congr' ?_⟩ + exact Eventually.of_forall fun t => by + simp only [homogeneousQ, eval_mul, eval_pow, eval_sub, eval_C, eval_X, Function.comp_def, mul_pow] + ring + + + +theorem tilde_projection_eval (N : ℕ) (P J E : Polynomial ℝ) + (hP : P.natDegree ≤ N) (hJ : J.natDegree ≤ N) (hE : E.natDegree ≤ N) + {z b : ℝ} (hz : z ≠ 0) (hb : harmonicCoordinate.eval b = (1 + 1 / z) / 8) : + (tildePoly N P).eval z + b * (tildePoly N J).eval z + b ^ 2 * (tildePoly N E).eval z = + z ^ N * (P.comp harmonicCoordinate + X * J.comp harmonicCoordinate + + X ^ 2 * E.comp harmonicCoordinate).eval b := by + rw [tildePoly_eval N hP hz, tildePoly_eval N hJ hz, tildePoly_eval N hE hz] + simp only [eval_add, eval_mul, eval_comp, eval_pow, eval_X, hb] + ring + + + +theorem tilde_F_decay (N : ℕ) (g P J E : Polynomial ℝ) + (hP : P.natDegree ≤ N) (hJ : J.natDegree ≤ N) (hE : E.natDegree ≤ N) + (hQ : homogeneousQ N g = P.comp harmonicCoordinate + X * J.comp harmonicCoordinate + + X ^ 2 * E.comp harmonicCoordinate) (j : ℕ) (hj : j ≤ N) : + Tendsto (fun t : ℝ => (-t) ^ j * ((tildePoly N P).eval (-t) + + highBranch (1 / (-t)) * (tildePoly N J).eval (-t) + + highBranch (1 / (-t)) ^ 2 * (tildePoly N E).eval (-t))) atTop (𝓝 0) := by + have hz : ∀ᶠ t : ℝ in atTop, -t ≠ 0 := by + filter_upwards [eventually_gt_atTop (0 : ℝ)] with t ht + exact neg_ne_zero.mpr ht.ne' + have hi : Tendsto (fun t : ℝ => 1 / (-t)) atTop (𝓝 0) := by + simpa only [one_div, inv_neg, neg_zero] using + (tendsto_inv_atTop_zero : Tendsto (fun t : ℝ => t⁻¹) atTop (𝓝 0)).neg + apply (homogeneousQ_high_decay hz hi N g (N + j) (by omega)).congr' + filter_upwards [hz, eventually_small_inverse hi] with t ht hs + have he := tilde_projection_eval N P J E hP hJ hE ht (branches_harmonic hs).1 + rw [← hQ] at he + rw [he, pow_add] + ring + + +theorem tilde_D_limit (N : ℕ) (g P J E : Polynomial ℝ) + (hP : P.natDegree ≤ N) (hJ : J.natDegree ≤ N) (hE : E.natDegree ≤ N) + (hQ : homogeneousQ N g = P.comp harmonicCoordinate + X * J.comp harmonicCoordinate + + X ^ 2 * E.comp harmonicCoordinate) : + ∃ L : ℝ, Tendsto (fun z : ℝ => (tildePoly N J).eval z + + Real.sqrt (1 + Real.sqrt ((1 + 1 / z) / 2)) * (tildePoly N E).eval z) atTop (𝓝 L) := by + have hz : ∀ᶠ z : ℝ in atTop, z ≠ 0 := by + filter_upwards [eventually_gt_atTop (0 : ℝ)] with z hz + exact hz.ne' + have hi : Tendsto (fun z : ℝ => 1 / z) atTop (𝓝 0) := by + simpa only [one_div] using + (tendsto_inv_atTop_zero : Tendsto (fun z : ℝ => z⁻¹) atTop (𝓝 0)) + have hh : Tendsto (fun z : ℝ => highBranch (1 / z)) atTop (𝓝 C) := by + simpa only [highBranch_zero, Function.comp_def] using highBranch_continuous.continuousAt.tendsto.comp hi + have hl : Tendsto (fun z : ℝ => lowBranch (1 / z)) atTop (𝓝 c) := by + simpa only [lowBranch_zero, Function.comp_def] using lowBranch_continuous.continuousAt.tendsto.comp hi + have hdiff := hh.sub hl + have hne : C - c ≠ 0 := sub_ne_zero.mpr (ne_of_gt C_c_facts.2.1) + obtain ⟨L, hL⟩ := homogeneousQ_low_limit hz hi N g + have hhigh := homogeneousQ_high_decay hz hi N g N (by omega) + refine ⟨(0 - L) / (C - c), ((hhigh.sub hL).div hdiff hne).congr' ?_⟩ + filter_upwards [hz, eventually_small_inverse hi, hdiff.eventually_ne hne] with z hzt hs hd + apply (div_eq_iff hd).2 + rw [← branches_sum hs] + have heh := tilde_projection_eval N P J E hP hJ hE hzt (branches_harmonic hs).1 + have hel := tilde_projection_eval N P J E hP hJ hE hzt (branches_harmonic hs).2 + rw [← hQ] at heh hel + linear_combination -heh + hel + +theorem harmonic_natDegree : harmonicCoordinate.natDegree = 4 := by + unfold harmonicCoordinate + compute_degree <;> norm_num + +theorem degree_lt_natDegree_le_pred {N : ℕ} {p : Polynomial ℝ} + (hN : 1 ≤ N) (hp : p.degree < (N : WithBot ℕ)) : p.natDegree ≤ N - 1 := by + by_cases hp0 : p = 0 + · simp [hp0] + have h : p.natDegree < N := (natDegree_lt_iff_degree_lt hp0).2 hp + omega + + +theorem projection_natDegree_le (N : ℕ) (hN : 1 ≤ N) (P J E : Polynomial ℝ) + (hP : P.natDegree ≤ N) (hJ : J.natDegree ≤ N) (hE : E.degree < (N : WithBot ℕ)) : + (P.comp harmonicCoordinate + X * J.comp harmonicCoordinate + + X ^ 2 * E.comp harmonicCoordinate).natDegree ≤ 4 * N + 1 := by + have he := degree_lt_natDegree_le_pred hN hE + have hp' : (P.comp harmonicCoordinate).natDegree ≤ 4 * N + 1 := by + rw [natDegree_comp, harmonic_natDegree] + omega + have hj' : (X * J.comp harmonicCoordinate).natDegree ≤ 4 * N + 1 := by + apply le_trans natDegree_mul_le + rw [natDegree_X, natDegree_comp, harmonic_natDegree] + omega + have he' : (X ^ 2 * E.comp harmonicCoordinate).natDegree ≤ 4 * N + 1 := by + apply le_trans natDegree_mul_le + rw [natDegree_X_pow, natDegree_comp, harmonic_natDegree] + omega + exact le_trans (natDegree_add_le _ _) (max_le (le_trans (natDegree_add_le _ _) (max_le hp' hj')) he') + + + +theorem projection_J_degree_lt (N : ℕ) (hN : 1 ≤ N) (P J E : Polynomial ℝ) + (hP : P.natDegree ≤ N) (hJ : J.natDegree ≤ N) (hE : E.degree < (N : WithBot ℕ)) + (hQ : (P.comp harmonicCoordinate + X * J.comp harmonicCoordinate + + X ^ 2 * E.comp harmonicCoordinate).natDegree ≤ 4 * N) : + J.degree < (N : WithBot ℕ) := by + by_cases hJ0 : J = 0 + · simp [hJ0] + apply (natDegree_lt_iff_degree_lt hJ0).1 + by_contra hj + have hjN : J.natDegree = N := by omega + have he := degree_lt_natDegree_le_pred hN hE + let A : Polynomial ℝ := P.comp harmonicCoordinate + X ^ 2 * E.comp harmonicCoordinate + have hp' : (P.comp harmonicCoordinate).natDegree ≤ 4 * N := by + rw [natDegree_comp, harmonic_natDegree] + omega + have he' : (X ^ 2 * E.comp harmonicCoordinate).natDegree ≤ 4 * N := by + apply le_trans natDegree_mul_le + rw [natDegree_X_pow, natDegree_comp, harmonic_natDegree] + omega + have ha : A.natDegree ≤ 4 * N := le_trans (natDegree_add_le _ _) (max_le hp' he') + have hjcomp : J.comp harmonicCoordinate ≠ 0 := by + intro h + have hd := natDegree_comp (p := J) (q := harmonicCoordinate) + rw [h, natDegree_zero, hjN, harmonic_natDegree] at hd + omega + have hb : (X * J.comp harmonicCoordinate).natDegree = 4 * N + 1 := by + rw [natDegree_X_mul hjcomp, natDegree_comp, hjN, harmonic_natDegree] + omega + have hsum : + (P.comp harmonicCoordinate + X * J.comp harmonicCoordinate + + X ^ 2 * E.comp harmonicCoordinate).natDegree = 4 * N + 1 := by + have heq : P.comp harmonicCoordinate + X * J.comp harmonicCoordinate + + X ^ 2 * E.comp harmonicCoordinate = A + X * J.comp harmonicCoordinate := by + dsimp [A] + ring + rw [heq, natDegree_add_eq_right_of_natDegree_lt (by rw [hb]; omega), hb] + omega + +theorem homogeneousQ_lower_degree (N : ℕ) (hN : 1 ≤ N) {g : Polynomial ℝ} + (hg : g.degree < (N : WithBot ℕ)) : (homogeneousQ N g).natDegree ≤ 4 * N := by + have hg' := degree_lt_natDegree_le_pred hN hg + have h := natDegree_mul_le (p := (X - Polynomial.C C) ^ (2 * N + 1) * + (X - Polynomial.C c) ^ N) (q := g) + have h' := natDegree_mul_le (p := (X - Polynomial.C C) ^ (2 * N + 1)) + (q := (X - Polynomial.C c) ^ N) + simp only [natDegree_pow, natDegree_X_sub_C, mul_one] at h' + exact le_trans h (by omega) + +end + +noncomputable section +open Polynomial Set MeasureTheory Filter +open scoped Topology BigOperators + + +theorem stieltjes_polynomial_basis (N : ℕ) (e : Polynomial ℝ) (he : e.natDegree < N) + {z : ℝ} (hz : 0 < z) : + z * realStieltjes (-1) (fun y => e.eval (-y) * omega y) z = + ∑ k : Fin N, (e.coeff k.val * (-1) ^ k.val) * transformedBasis k.val z := by + have hev (y : ℝ) : e.eval (-y) = + ∑ k : Fin N, (e.coeff k.val * (-1) ^ k.val) * y ^ k.val := by + rw [eval_eq_sum_range' he, ← Fin.sum_univ_eq_sum_range] + apply Finset.sum_congr rfl + intro k _ + rw [neg_eq_neg_one_mul, mul_pow] + ring + have heq : (fun y => z * (e.eval (-y) * omega y / (z - (-1) * y))) = + fun y => ∑ k : Fin N, (e.coeff k.val * (-1) ^ k.val) * + (boundedCauchy z y * momentBasis k.val y) := by + funext y + rw [hev] + simp only [Finset.sum_mul, Finset.sum_div, Finset.mul_sum] + apply Finset.sum_congr rfl + intro k _ + unfold boundedCauchy momentBasis + ring + rw [realStieltjes, ← integral_const_mul, heq, integral_finsetSum] + · simp only [integral_const_mul, transformedBasis] + · intro k _ + exact (integrableOn_boundedCauchy_basis k.val hz).const_mul _ + + + +theorem homogeneous_projection_zero (N : ℕ) (hN : 1 ≤ N) (g P J E : Polynomial ℝ) + (hg : g.degree < (N : WithBot ℕ)) + (hP : P.natDegree ≤ N) (hJ : J.natDegree ≤ N) (hE : E.degree < (N : WithBot ℕ)) + (hQ : homogeneousQ N g = P.comp harmonicCoordinate + X * J.comp harmonicCoordinate + + X ^ 2 * E.comp harmonicCoordinate) : + P = 0 ∧ J = 0 ∧ E = 0 ∧ g = 0 := by + have hEn : E.natDegree ≤ N := (degree_lt_natDegree_le_pred hN hE).trans (Nat.sub_le _ _) + have hJl : J.degree < (N : WithBot ℕ) := projection_J_degree_lt N hN P J E hP hJ hE + (by rw [← hQ]; exact homogeneousQ_lower_degree N hN hg) + have htJ0 := tildePoly_zero_of_degree_lt N hJl + have htE0 := tildePoly_zero_of_degree_lt N hE + have hdiv : X ∣ tildePoly N E := X_dvd_iff.2 (by simpa only [coeff_zero_eq_eval_zero] using htE0) + obtain ⟨e, he⟩ := hdiv + have hen : e.natDegree < N := by + by_cases he0 : e = 0 + · simp [he0]; omega + have hb := tildePoly_natDegree_le N hEn + rw [he, natDegree_X_mul he0] at hb + omega + have hF : ∀ j : ℕ, j ≤ N → Tendsto + (fun t : ℝ => (-t) ^ j * projectionF (tildePoly N P) (tildePoly N J) (tildePoly N E) (-t)) + atTop (𝓝 0) := by + intro j hj + exact tilde_F_decay N g P J E hP hJ hEn hQ j hj + obtain ⟨L, hD⟩ := tilde_D_limit N g P J E hP hJ hEn hQ + change Tendsto (fun z : ℝ => projectionD (tildePoly N J) (tildePoly N E) z) atTop (𝓝 L) at hD + have hDc := projectionD_cauchy (tildePoly N J) e (by simpa only [← he] using hD) + have hm := projection_moments_of_decay N (tildePoly N P) (tildePoly N J) (tildePoly N E) hF + let v : Fin N → ℝ := fun k => -(Real.sqrt 2 / Real.pi) * (e.coeff k.val * (-1) ^ k.val) + have hDv {z : ℝ} (hz : 0 < z) : + projectionD (tildePoly N J) (tildePoly N E) z = cauchyDefect N 0 v z := by + rw [he, hDc z hz, htJ0, zero_add, mul_assoc, stieltjes_polynomial_basis N e hen hz] + simp only [cauchyDefect, zero_sub, v, Finset.mul_sum, neg_mul, Finset.sum_neg_distrib, neg_neg] + apply Finset.sum_congr rfl + intro k _ + ring + have hv : CauchyMomentProblem N 0 v := by + intro j + calc + (∫ x in Ioo (0 : ℝ) 1, momentBasis j.val x * cauchyDefect N 0 v x) = + ∫ x in Ioo (0 : ℝ) 1, x ^ j.val * (projectionD (tildePoly N J) (tildePoly N E) x * omega x) := by + apply setIntegral_congr_fun measurableSet_Ioo + intro x hx + dsimp only + rw [hDv hx.1] + unfold momentBasis + ring + _ = 0 := hm j.val j.isLt + have hv0 := cauchyMomentProblem_zero hv + have he0 : e = 0 := by + ext k + rw [coeff_zero] + by_cases hk : k < N + · have hvk := congrFun hv0 (⟨k, hk⟩ : Fin N) + dsimp [v] at hvk + have hs : -(Real.sqrt 2 / Real.pi) ≠ 0 := neg_ne_zero.mpr + (div_ne_zero (Real.sqrt_ne_zero'.2 (by norm_num)) Real.pi_ne_zero) + have hc := (mul_eq_zero.mp hvk).resolve_left hs + exact (mul_eq_zero.mp hc).resolve_right (pow_ne_zero _ (by norm_num)) + · exact coeff_eq_zero_of_natDegree_lt (by omega) + have hE0 : E = 0 := (tildePoly_eq_zero_iff N E).1 (by simpa only [he0, mul_zero] using he) + have htE : tildePoly N E = 0 := (tildePoly_eq_zero_iff N E).2 hE0 + have htJ : tildePoly N J = 0 := by + have hJlim : Tendsto (fun z : ℝ => (tildePoly N J).eval z) atTop (𝓝 L) := by + simpa only [htE, projectionD, eval_zero, mul_zero, add_zero] using hD + have hc := polynomial_constant_of_limit tendsto_norm_atTop_atTop (tildePoly N J) hJlim + have hL : L = 0 := by simpa only [hc, eval_C] using htJ0 + simpa only [hL, C_0] using hc + have htP : tildePoly N P = 0 := by + have hPlim : Tendsto (fun t : ℝ => (tildePoly N P).eval (-t)) atTop (𝓝 0) := by + simpa only [htJ, htE, projectionF, eval_zero, mul_zero, add_zero, pow_zero, one_mul] using hF 0 (Nat.zero_le N) + simpa only [C_0] using polynomial_constant_of_limit norm_neg_atTop (tildePoly N P) hPlim + have hP0 := (tildePoly_eq_zero_iff N P).1 htP + have hJ0 := (tildePoly_eq_zero_iff N J).1 htJ + refine ⟨hP0, hJ0, hE0, ?_⟩ + have hQ0 : homogeneousQ N g = 0 := by simp [hQ, hP0, hJ0, hE0] + have hroot : (X - Polynomial.C C) ^ (2 * N + 1) * (X - Polynomial.C c) ^ N ≠ 0 := + mul_ne_zero (pow_ne_zero _ (X_sub_C_ne_zero _)) (pow_ne_zero _ (X_sub_C_ne_zero _)) + exact (mul_eq_zero.1 hQ0).resolve_left hroot + + + +def rootPolynomial (N : ℕ) : Polynomial ℝ := + (X - Polynomial.C C) ^ (2 * N + 1) * (X - Polynomial.C c) ^ N + +theorem rootPolynomial_monic (N : ℕ) : (rootPolynomial N).Monic := + ((monic_X_sub_C C).pow _).mul ((monic_X_sub_C c).pow _) + +theorem rootPolynomial_natDegree (N : ℕ) : (rootPolynomial N).natDegree = 3 * N + 1 := by + rw [rootPolynomial, ((monic_X_sub_C C).pow _).natDegree_mul ((monic_X_sub_C c).pow _)] + simp only [natDegree_pow, natDegree_X_sub_C, mul_one] + omega + +theorem rootPolynomial_degree (N : ℕ) : (rootPolynomial N).degree = ((3 * N + 1 : ℕ) : WithBot ℕ) := by + rw [degree_eq_natDegree (rootPolynomial_monic N).ne_zero, rootPolynomial_natDegree] + +abbrev ProjectionSpace (N : ℕ) := + (degreeLT ℝ (N + 1)) × (degreeLT ℝ (N + 1)) × (degreeLT ℝ N) + +def projectionMap (N : ℕ) : ProjectionSpace N →ₗ[ℝ] Polynomial ℝ where + toFun t := t.1.val.comp harmonicCoordinate + X * t.2.1.val.comp harmonicCoordinate + + X ^ 2 * t.2.2.val.comp harmonicCoordinate + map_add' t u := by + simp only [Prod.fst_add, Prod.snd_add, Submodule.coe_add, add_comp] + ring + map_smul' a t := by + simp only [Prod.smul_fst, Prod.smul_snd, Submodule.coe_smul, smul_comp, + smul_add, mul_smul_comm, RingHom.id_apply] + +def projectionRemainder (N : ℕ) : ProjectionSpace N →ₗ[ℝ] degreeLT ℝ (3 * N + 1) where + toFun t := ⟨(projectionMap N t) %ₘ rootPolynomial N, mem_degreeLT.2 (by + have h := degree_modByMonic_lt (projectionMap N t) (rootPolynomial_monic N) + rwa [rootPolynomial_degree] at h)⟩ + map_add' t u := by + apply Subtype.ext + simp only [map_add, add_modByMonic, Submodule.coe_add] + map_smul' a t := by + apply Subtype.ext + simp only [map_smul, smul_modByMonic, Submodule.coe_smul, RingHom.id_apply] + +theorem projectionSpace_finrank (N : ℕ) : Module.finrank ℝ (ProjectionSpace N) = 3 * N + 2 := by + simp only [ProjectionSpace, Module.finrank_prod, + Module.finrank_eq_card_basis (degreeLT.basis ℝ (N + 1)), + Module.finrank_eq_card_basis (degreeLT.basis ℝ N), Fintype.card_fin] + omega + +end +end CriticalStrip + +end OAI diff --git a/lean/OAI/Combinatorics/StripMass/TripleCircuit.lean b/lean/OAI/Combinatorics/StripMass/TripleCircuit.lean new file mode 100644 index 0000000000000000000000000000000000000000..205bd0639bc32ddacaddd1d8af2af365a25e9877 --- /dev/null +++ b/lean/OAI/Combinatorics/StripMass/TripleCircuit.lean @@ -0,0 +1,548 @@ +import Mathlib +import OAI.Combinatorics.StripMass.WireContraction + +namespace OAI + +/-! Critical honeycomb strip paths, polynomial identities and crossing mass. -/ + + + +namespace CriticalStrip.Diagram +noncomputable section +open scoped Classical + +structure TriplePosition (n : ℕ) where + a : Fin n + b : Fin n + c : Fin n + hab : a.val+1=b.val + hbc : b.val+1=c.val + +namespace TriplePosition +variable {n : ℕ} (s : TriplePosition n) + +lemma ab : s.a≠s.b := by intro he; have:=congrArg Fin.val he; have:=s.hab; omega +lemma bc : s.b≠s.c := by intro he; have:=congrArg Fin.val he; have:=s.hbc; omega +lemma ac : s.a≠s.c := by intro he; have:=congrArg Fin.val he; have:=s.hab; have:=s.hbc; omega + +def left : Position n := ⟨s.a,s.b,s.hab⟩ +def right : Position n := ⟨s.b,s.c,s.hbc⟩ + +def rightCircuit (t : ThreeBox.Config) : Circuit n := + .snoc (.snoc (.snoc .nil (s.right.gate t.1)) (s.left.gate t.2.1)) (s.right.gate t.2.2) + +def vertexEquiv : (((Fin n ⊕ Fin 4) ⊕ Fin 4) ⊕ Fin 4) ≃ (Fin n ⊕ Fin 12) := + (Equiv.sumAssoc _ _ _).trans ((Equiv.sumAssoc _ _ _).trans + ((Equiv.sumCongr (Equiv.refl _) (Equiv.sumCongr (Equiv.refl _) finSumFinEquiv)).trans + (Equiv.sumCongr (Equiv.refl _) finSumFinEquiv))) + +def wiring (p : Pairing n) (t : ThreeBox.Config) : (Fin n ⊕ Fin 12) → (Fin n ⊕ Fin 12) → Prop + | .inl i,.inl j => p.Adj i j + | .inr v,.inr w => ThreeBox.Adj t v w + | .inl i,.inr v | .inr v,.inl i => + (i=s.a ∧ v=4 ∧ p.Occupied s.a) ∨ + (i=s.b ∧ v=0 ∧ p.Occupied s.b) ∨ + (i=s.c ∧ v=1 ∧ p.Occupied s.c) + +def boundary (i : Fin n) : Fin n ⊕ Fin 12 := + if i=s.a then .inr 6 else if i=s.b then .inr 10 else if i=s.c then .inr 11 else .inl i + +@[simp] lemma vertex_old (i : Fin n) : vertexEquiv (.inl (.inl (.inl i)))=.inl i := rfl +@[simp] lemma vertex_zero (i : Fin 4) : (vertexEquiv (n:=n) (.inl (.inl (.inr i))))= + .inr ⟨i.val,by omega⟩ := rfl +@[simp] lemma vertex_one (i : Fin 4) : (vertexEquiv (n:=n) (.inl (.inr i)))= + .inr ⟨4+i.val,by omega⟩ := rfl +@[simp] lemma vertex_two (i : Fin 4) : (vertexEquiv (n:=n) (.inr i))= + .inr ⟨4+(4+i.val),by omega⟩ := rfl + +lemma boundary_eq (t : ThreeBox.Config) (i : Fin n) : + vertexEquiv ((s.rightCircuit t).compactBoundary i) = s.boundary i := by + have hab := s.ab; have hbc := s.bc; have hac := s.ac + by_cases ha : i=s.a <;> by_cases hb : i=s.b <;> by_cases hc : i=s.c <;> + simp_all [rightCircuit, Circuit.compactBoundary, CompactGate.boundary, Position.gate, left, + right, boundary] <;> rfl + +lemma edge_0_0 (p : Pairing n) (t : ThreeBox.Config) (i : Fin n) (j : Fin n) : + Circuit.compactWiring p (s.rightCircuit t) (.inl (.inl (.inl i))) (.inl (.inl (.inl j))) ↔ + s.wiring p t (vertexEquiv (.inl (.inl (.inl i)))) (vertexEquiv (.inl (.inl (.inl j)))) := by + all_goals simp [rightCircuit, Circuit.compactWiring, CompactGate.wiring, Position.gate, left, + right, wiring, vertex_old] + +lemma edge_0_1 (p : Pairing n) (t : ThreeBox.Config) (i : Fin n) (w : Fin 4) : + Circuit.compactWiring p (s.rightCircuit t) (.inl (.inl (.inl i))) (.inl (.inl (.inr w))) ↔ + s.wiring p t (vertexEquiv (.inl (.inl (.inl i)))) (vertexEquiv (.inl (.inl (.inr w)))) := by + all_goals fin_cases w + all_goals simp [rightCircuit, Circuit.compactWiring, CompactGate.wiring, Circuit.support, + Circuit.compactBoundary, Position.gate, left, right, wiring, vertex_old, vertex_zero] + all_goals dsimp only [Circuit.CompactVertex] at * + all_goals simp + +lemma edge_0_2 (p : Pairing n) (t : ThreeBox.Config) (i : Fin n) (w : Fin 4) : + Circuit.compactWiring p (s.rightCircuit t) (.inl (.inl (.inl i))) (.inl (.inr w)) ↔ + s.wiring p t (vertexEquiv (.inl (.inl (.inl i)))) (vertexEquiv (.inl (.inr w))) := by + all_goals fin_cases w + all_goals simp [rightCircuit, Circuit.compactWiring, CompactGate.wiring, Circuit.support, + Circuit.compactBoundary, CompactGate.boundary, Position.gate, left, right, wiring, vertex_old, + vertex_one, s.ab, s.ac] + all_goals dsimp only [Circuit.CompactVertex] at * + all_goals simp + +lemma edge_0_3 (p : Pairing n) (t : ThreeBox.Config) (i : Fin n) (w : Fin 4) : + Circuit.compactWiring p (s.rightCircuit t) (.inl (.inl (.inl i))) (.inr w) ↔ + s.wiring p t (vertexEquiv (.inl (.inl (.inl i)))) (vertexEquiv (.inr w)) := by + all_goals fin_cases w + all_goals simp [rightCircuit, Circuit.compactWiring, CompactGate.wiring, Circuit.support, + Circuit.compactBoundary, CompactGate.boundary, Position.gate, left, right, wiring, vertex_old, + vertex_two, s.ab.symm, s.bc.symm, s.ac.symm] + all_goals dsimp only [Circuit.CompactVertex] at * + all_goals simp + +lemma edge_1_0 (p : Pairing n) (t : ThreeBox.Config) (v : Fin 4) (j : Fin n) : + Circuit.compactWiring p (s.rightCircuit t) (.inl (.inl (.inr v))) (.inl (.inl (.inl j))) ↔ + s.wiring p t (vertexEquiv (.inl (.inl (.inr v)))) (vertexEquiv (.inl (.inl (.inl j)))) := by + fin_cases v + all_goals simp [rightCircuit, Circuit.compactWiring, CompactGate.wiring, Circuit.support, + Circuit.compactBoundary, Position.gate, left, right, wiring, vertex_old, vertex_zero] + all_goals dsimp only [Circuit.CompactVertex] at * + all_goals simp + +lemma edge_1_1 (p : Pairing n) (t : ThreeBox.Config) (v : Fin 4) (w : Fin 4) : + Circuit.compactWiring p (s.rightCircuit t) (.inl (.inl (.inr v))) (.inl (.inl (.inr w))) ↔ + s.wiring p t (vertexEquiv (.inl (.inl (.inr v)))) (vertexEquiv (.inl (.inl (.inr w)))) := by + fin_cases v + all_goals fin_cases w + all_goals simp [rightCircuit, Circuit.compactWiring, CompactGate.wiring, Position.gate, left, + right, wiring, vertex_zero, ThreeBox.Adj, ThreeBox.tileEdge, ThreeBox.row, ThreeBox.port, + ThreeBox.atRow, ThreeBox.wireEdge] + +lemma edge_1_2 (p : Pairing n) (t : ThreeBox.Config) (v : Fin 4) (w : Fin 4) : + Circuit.compactWiring p (s.rightCircuit t) (.inl (.inl (.inr v))) (.inl (.inr w)) ↔ + s.wiring p t (vertexEquiv (.inl (.inl (.inr v)))) (vertexEquiv (.inl (.inr w))) := by + fin_cases v + all_goals fin_cases w + all_goals simp [rightCircuit, Circuit.compactWiring, CompactGate.wiring, Circuit.support, + Circuit.compactBoundary, CompactGate.boundary, Position.gate, left, right, wiring, vertex_zero, + vertex_one, ThreeBox.Adj, ThreeBox.tileEdge, ThreeBox.row, ThreeBox.port, ThreeBox.atRow, + ThreeBox.wireEdge, s.ab, s.ac] + all_goals dsimp only [Circuit.CompactVertex] at * + all_goals simp + +lemma edge_1_3 (p : Pairing n) (t : ThreeBox.Config) (v : Fin 4) (w : Fin 4) : + Circuit.compactWiring p (s.rightCircuit t) (.inl (.inl (.inr v))) (.inr w) ↔ + s.wiring p t (vertexEquiv (.inl (.inl (.inr v)))) (vertexEquiv (.inr w)) := by + fin_cases v + all_goals fin_cases w + all_goals simp [rightCircuit, Circuit.compactWiring, CompactGate.wiring, Circuit.support, + Circuit.compactBoundary, CompactGate.boundary, Position.gate, left, right, wiring, vertex_zero, + vertex_two, ThreeBox.Adj, ThreeBox.tileEdge, ThreeBox.row, ThreeBox.port, ThreeBox.atRow, + ThreeBox.wireEdge, s.ab.symm, s.bc.symm, s.ac.symm] + all_goals dsimp only [Circuit.CompactVertex] at * + all_goals simp + +lemma edge_2_0 (p : Pairing n) (t : ThreeBox.Config) (v : Fin 4) (j : Fin n) : + Circuit.compactWiring p (s.rightCircuit t) (.inl (.inr v)) (.inl (.inl (.inl j))) ↔ + s.wiring p t (vertexEquiv (.inl (.inr v))) (vertexEquiv (.inl (.inl (.inl j)))) := by + fin_cases v + all_goals simp [rightCircuit, Circuit.compactWiring, CompactGate.wiring, Circuit.support, + Circuit.compactBoundary, CompactGate.boundary, Position.gate, left, right, wiring, vertex_old, + vertex_one, s.ab, s.ac] + all_goals dsimp only [Circuit.CompactVertex] at * + all_goals simp + +lemma edge_2_1 (p : Pairing n) (t : ThreeBox.Config) (v : Fin 4) (w : Fin 4) : + Circuit.compactWiring p (s.rightCircuit t) (.inl (.inr v)) (.inl (.inl (.inr w))) ↔ + s.wiring p t (vertexEquiv (.inl (.inr v))) (vertexEquiv (.inl (.inl (.inr w)))) := by + fin_cases v + all_goals fin_cases w + all_goals simp [rightCircuit, Circuit.compactWiring, CompactGate.wiring, Circuit.support, + Circuit.compactBoundary, CompactGate.boundary, Position.gate, left, right, wiring, vertex_zero, + vertex_one, ThreeBox.Adj, ThreeBox.tileEdge, ThreeBox.row, ThreeBox.port, ThreeBox.atRow, + ThreeBox.wireEdge, s.ab, s.ac] + all_goals dsimp only [Circuit.CompactVertex] at * + all_goals simp + +lemma edge_2_2 (p : Pairing n) (t : ThreeBox.Config) (v : Fin 4) (w : Fin 4) : + Circuit.compactWiring p (s.rightCircuit t) (.inl (.inr v)) (.inl (.inr w)) ↔ + s.wiring p t (vertexEquiv (.inl (.inr v))) (vertexEquiv (.inl (.inr w))) := by + fin_cases v + all_goals fin_cases w + all_goals simp [rightCircuit, Circuit.compactWiring, CompactGate.wiring, Position.gate, left, + right, wiring, vertex_one, ThreeBox.Adj, ThreeBox.tileEdge, ThreeBox.row, ThreeBox.port, + ThreeBox.atRow, ThreeBox.wireEdge] + +lemma edge_2_3 (p : Pairing n) (t : ThreeBox.Config) (v : Fin 4) (w : Fin 4) : + Circuit.compactWiring p (s.rightCircuit t) (.inl (.inr v)) (.inr w) ↔ + s.wiring p t (vertexEquiv (.inl (.inr v))) (vertexEquiv (.inr w)) := by + fin_cases v + all_goals fin_cases w + all_goals simp [rightCircuit, Circuit.compactWiring, CompactGate.wiring, Circuit.support, + Circuit.compactBoundary, CompactGate.boundary, Position.gate, left, right, wiring, vertex_one, + vertex_two, ThreeBox.Adj, ThreeBox.tileEdge, ThreeBox.row, ThreeBox.port, ThreeBox.atRow, + ThreeBox.wireEdge, s.ab.symm, s.bc.symm, s.ac.symm] + all_goals dsimp only [Circuit.CompactVertex] at * + all_goals simp + +lemma edge_3_0 (p : Pairing n) (t : ThreeBox.Config) (v : Fin 4) (j : Fin n) : + Circuit.compactWiring p (s.rightCircuit t) (.inr v) (.inl (.inl (.inl j))) ↔ + s.wiring p t (vertexEquiv (.inr v)) (vertexEquiv (.inl (.inl (.inl j)))) := by + fin_cases v + all_goals simp [rightCircuit, Circuit.compactWiring, CompactGate.wiring, Circuit.support, + Circuit.compactBoundary, CompactGate.boundary, Position.gate, left, right, wiring, vertex_old, + vertex_two, s.ab.symm, s.bc.symm, s.ac.symm] + all_goals dsimp only [Circuit.CompactVertex] at * + all_goals simp + +lemma edge_3_1 (p : Pairing n) (t : ThreeBox.Config) (v : Fin 4) (w : Fin 4) : + Circuit.compactWiring p (s.rightCircuit t) (.inr v) (.inl (.inl (.inr w))) ↔ + s.wiring p t (vertexEquiv (.inr v)) (vertexEquiv (.inl (.inl (.inr w)))) := by + fin_cases v + all_goals fin_cases w + all_goals simp [rightCircuit, Circuit.compactWiring, CompactGate.wiring, Circuit.support, + Circuit.compactBoundary, CompactGate.boundary, Position.gate, left, right, wiring, vertex_zero, + vertex_two, ThreeBox.Adj, ThreeBox.tileEdge, ThreeBox.row, ThreeBox.port, ThreeBox.atRow, + ThreeBox.wireEdge, s.ab.symm, s.bc.symm, s.ac.symm] + all_goals dsimp only [Circuit.CompactVertex] at * + all_goals simp + +lemma edge_3_2 (p : Pairing n) (t : ThreeBox.Config) (v : Fin 4) (w : Fin 4) : + Circuit.compactWiring p (s.rightCircuit t) (.inr v) (.inl (.inr w)) ↔ + s.wiring p t (vertexEquiv (.inr v)) (vertexEquiv (.inl (.inr w))) := by + fin_cases v + all_goals fin_cases w + all_goals simp [rightCircuit, Circuit.compactWiring, CompactGate.wiring, Circuit.support, + Circuit.compactBoundary, CompactGate.boundary, Position.gate, left, right, wiring, vertex_one, + vertex_two, ThreeBox.Adj, ThreeBox.tileEdge, ThreeBox.row, ThreeBox.port, ThreeBox.atRow, + ThreeBox.wireEdge, s.ab.symm, s.bc.symm, s.ac.symm] + all_goals dsimp only [Circuit.CompactVertex] at * + all_goals simp + +lemma edge_3_3 (p : Pairing n) (t : ThreeBox.Config) (v : Fin 4) (w : Fin 4) : + Circuit.compactWiring p (s.rightCircuit t) (.inr v) (.inr w) ↔ + s.wiring p t (vertexEquiv (.inr v)) (vertexEquiv (.inr w)) := by + fin_cases v + all_goals fin_cases w + all_goals simp [rightCircuit, Circuit.compactWiring, CompactGate.wiring, Position.gate, left, + right, wiring, vertex_two, ThreeBox.Adj, ThreeBox.tileEdge, ThreeBox.row, ThreeBox.port, + ThreeBox.atRow, ThreeBox.wireEdge] + +lemma edge_iff (p : Pairing n) (t : ThreeBox.Config) + (v w : (s.rightCircuit t).CompactVertex) : + Circuit.compactWiring p (s.rightCircuit t) v w ↔ s.wiring p t (vertexEquiv v) (vertexEquiv w) := by + rcases v with ((i|v)|v)|v <;> rcases w with ((j|w)|w)|w + · exact s.edge_0_0 p t _ _ + · exact s.edge_0_1 p t _ _ + · exact s.edge_0_2 p t _ _ + · exact s.edge_0_3 p t _ _ + · exact s.edge_1_0 p t _ _ + · exact s.edge_1_1 p t _ _ + · exact s.edge_1_2 p t _ _ + · exact s.edge_1_3 p t _ _ + · exact s.edge_2_0 p t _ _ + · exact s.edge_2_1 p t _ _ + · exact s.edge_2_2 p t _ _ + · exact s.edge_2_3 p t _ _ + · exact s.edge_3_0 p t _ _ + · exact s.edge_3_1 p t _ _ + · exact s.edge_3_2 p t _ _ + · exact s.edge_3_3 p t _ _ + +end TriplePosition + + + + + +namespace CompactGate +variable {V : Type*} {n : ℕ} (r : V → V → Prop) (old : Fin n → V) + (active : Fin n → Prop) (a b : Fin n) (t : Tile) + +lemma output_used (k : Fin 4) (hk0 : k≠0) (hk1 : k≠1) : + Graph.Used (wiring r old active a b t) (.inr k) ↔ t.Occupied k := by + constructor + · rintro ⟨(v|l),h⟩ + · exact h.elim (fun h => (hk0 h.2.1).elim) (fun h => (hk1 h.2.1).elim) + · exact ⟨l,h⟩ + · rintro ⟨l,h⟩; exact ⟨.inr l,h⟩ + +lemma passed_used (hinj : Function.Injective old) (i : Fin n) (hia : i≠a) (hib : i≠b) : + Graph.Used (wiring r old active a b t) (.inl (old i)) ↔ Graph.Used r (old i) := by + constructor + · rintro ⟨(v|k),h⟩ + · exact ⟨v,h⟩ + · exact h.elim (fun h => (hia (hinj h.1)).elim) (fun h => (hib (hinj h.1)).elim) + · rintro ⟨v,h⟩; exact ⟨.inl v,h⟩ + +lemma boundary_used (hinj : Function.Injective old) (_hab : a≠b) + (ha : ∀ i, Graph.Used r (old i) ↔ active i) (i : Fin n) : + Graph.Used (wiring r old active a b t) (boundary old a b i) ↔ + if i=a then t.Occupied 2 else if i=b then t.Occupied 3 else active i := by + by_cases hia : i=a + · subst i + simp only [boundary] + exact output_used r old active a b t 2 (by decide) (by decide) + · by_cases hib : i=b + · subst i + simp only [boundary, ite_eq_right hia] + exact output_used r old active a b t 3 (by decide) (by decide) + · simp only [boundary,ite_eq_right hia,ite_eq_right hib] + exact (passed_used r old active a b t hinj i hia hib).trans (ha i) +end CompactGate + +namespace Circuit +variable {n : ℕ} +lemma compact_boundary_used (p : Pairing n) (c : Circuit n) (i : Fin n) : + Graph.Used (compactWiring p c) (c.compactBoundary i) ↔ support p c i := by + induction c generalizing i with + | nil => rfl + | snoc c g ih => + have hne : g.left≠g.right := by intro he; have:=congrArg Fin.val he; have:=g.adjacent; omega + exact CompactGate.boundary_used (compactWiring p c) c.compactBoundary (support p c) + g.left g.right g.tile c.compactBoundary_injective hne ih i +end Circuit + + + + + +namespace ThreeBox +instance adjStdSymm (t : Config) : Std.Symm (Adj t) := adj_symm t +end ThreeBox +namespace TriplePosition +variable {n : ℕ} (s : TriplePosition n) + +instance wiring_symm (p : Pairing n) (t : ThreeBox.Config) : Std.Symm (s.wiring p t) := by + constructor + rintro (i|v) (j|w) h + · exact Pairing.adj_symm h + · exact h + · exact h + · exact (ThreeBox.adj_symm t).symm _ _ h + +def equiv (p : Pairing n) (t : ThreeBox.Config) : + Graph.BoundaryEquiv (Circuit.compactWiring p (s.rightCircuit t)) (s.wiring p t) + (s.rightCircuit t).compactBoundary s.boundary := + Graph.BoundaryEquiv.ofEquiv vertexEquiv (s.edge_iff p t) (s.boundary_eq t) + +lemma boundary_injective : Function.Injective s.boundary := by + let t : ThreeBox.Config := (.vacant,.vacant,.vacant) + intro i j hij + apply (s.rightCircuit t).compactBoundary_injective + apply vertexEquiv.injective + simpa only [s.boundary_eq] using hij + +def support (p : Pairing n) (t : ThreeBox.Config) (i : Fin n) : Prop := + if i=s.a then t.2.1.Occupied 2 else if i=s.b then t.2.2.Occupied 2 + else if i=s.c then t.2.2.Occupied 3 else p.Occupied i + +lemma circuit_support (p : Pairing n) (t : ThreeBox.Config) (i : Fin n) : + Circuit.support p (s.rightCircuit t) i ↔ s.support p t i := by + have hab:=s.ab; have hbc:=s.bc; have hac:=s.ac + by_cases ha : i=s.a <;> by_cases hb : i=s.b <;> by_cases hc : i=s.c <;> + simp_all [rightCircuit,Circuit.support,Position.gate,left,right,support] + +lemma boundary_used (p : Pairing n) (t : ThreeBox.Config) (i : Fin n) : + Graph.Used (s.wiring p t) (s.boundary i) ↔ s.support p t i := by + rw [←s.circuit_support p t i,←Circuit.compact_boundary_used] + constructor + · intro h + have hh := (s.equiv p t).inv_used _ h + rwa [(s.equiv p t).inv_boundary] at hh + · intro h + have hh := (s.equiv p t).map_used _ h + rwa [(s.equiv p t).map_boundary] at hh + +lemma compatible_iff (p : Pairing n) (t : ThreeBox.Config) : + Circuit.Compatible p (s.rightCircuit t) ↔ + ThreeBox.Compatible t ∧ (p.Occupied s.a ↔ t.2.1.Occupied 0) ∧ + (p.Occupied s.b ↔ t.1.Occupied 0) ∧ (p.Occupied s.c ↔ t.1.Occupied 1) := by + simp only [rightCircuit, Circuit.Compatible, Circuit.support, Position.gate, left, right, s.ab, + s.bc, s.ac, s.ab.symm, s.bc.symm, s.ac.symm, ThreeBox.Compatible, true_and] + itauto + +lemma eval_iff (p q : Pairing n) (t : ThreeBox.Config) : + Circuit.eval p (s.rightCircuit t)=some q ↔ + Circuit.Compatible p (s.rightCircuit t) ∧ GraphRealizes (s.wiring p t) s.boundary q := by + rw [Circuit.compact_eval_iff,(s.equiv p t).realizes_iff] + +end TriplePosition +end +end CriticalStrip.Diagram + + + + + +namespace CriticalStrip.Diagram.Graph +noncomputable section +namespace Attached +variable {V : Type*} {n : ℕ} + +def wiring (r : V → V → Prop) (old : Fin n → V) (active : Fin n → Prop) : + (V ⊕ Fin n) → (V ⊕ Fin n) → Prop + | .inl v,.inl w => r v w + | .inl v,.inr i | .inr i,.inl v => v=old i ∧ active i + | .inr _,.inr _ => False + +def project (old : Fin n → V) : V ⊕ Fin n → V + | .inl v => v + | .inr i => old i + +instance wiring_symm (r : V → V → Prop) [Std.Symm r] (old : Fin n → V) (active : Fin n → Prop) : + Std.Symm (wiring r old active) := by + constructor + rintro (v|i) (w|j) h + · change r v w at h; change r w v; exact symm h + all_goals exact h + +variable (r : V → V → Prop) (old : Fin n → V) (active : Fin n → Prop) + (ha : ∀ i, active i ↔ Used r (old i)) + +include ha in +lemma map_used (v : V ⊕ Fin n) (h : Used (wiring r old active) v) : Used r (project old v) := by + obtain ⟨w,hw⟩ := h + rcases v with v | i <;> rcases w with w | j + · exact ⟨w,hw⟩ + · obtain ⟨rfl,hj⟩ := hw; exact (ha j).mp hj + · exact (ha i).mp hw.2 + · exact hw.elim + +def contraction (hi : Function.Injective old) : + WireContraction (wiring r old active) r Sum.inr old where + project := project old + core := Sum.inl + section_eq := fun _ => rfl + map_edge := by + rintro (v|i) (w|j) h + · exact .single h + · rw [h.1]; exact .refl + · rw [h.1]; exact .refl + · exact h.elim + core_edge := fun _ _ h => h + map_boundary := fun _ => rfl + boundary_injective := hi + map_used := map_used r old active ha + retract := by + rintro (v|i) ⟨w,hw⟩ + · exact .refl + · cases w with + | inl w => exact .single ⟨rfl,hw.2⟩ + | inr j => exact hw.elim + boundary_retract := fun i hu => .single ⟨rfl,(ha i).mpr hu⟩ + +end Attached +end +end CriticalStrip.Diagram.Graph + + + + + +namespace CriticalStrip.Diagram +noncomputable section +open scoped Classical +namespace TriplePosition +variable {n : ℕ} (s : TriplePosition n) + +def interface : Fin 6 → Fin n ⊕ Fin n := + ![.inl s.a,.inl s.b,.inl s.c,.inr s.a,.inr s.b,.inr s.c] + +def active (p q : Pairing n) : Fin 6 → Prop := + ![p.Occupied s.a,p.Occupied s.b,p.Occupied s.c, + q.Occupied s.a,q.Occupied s.b,q.Occupied s.c] + +def exterior (p q : Pairing n) : (Fin n ⊕ Fin n) → (Fin n ⊕ Fin n) → Prop + | .inl i,.inl j => p.Adj i j + | .inl i,.inr j | .inr j,.inl i => i=j ∧ i≠s.a ∧ i≠s.b ∧ i≠s.c ∧ q.Occupied i + | .inr _,.inr _ => False + +def Outside (p q : Pairing n) : Prop := + ∀ i, i≠s.a → i≠s.b → i≠s.c → (p.Occupied i ↔ q.Occupied i) + +def attached (p q : Pairing n) (t : ThreeBox.Config) := + Graph.Attached.wiring (s.wiring p t) s.boundary q.Occupied + +def patch (p q : Pairing n) (t : ThreeBox.Config) := + Patch.glued (ThreeBox.Adj t) (s.exterior p q) ThreeBox.boundary s.interface (s.active p q) + +def exteriorEquiv : ((Fin n ⊕ Fin 12) ⊕ Fin n) ≃ (Fin 12 ⊕ (Fin n ⊕ Fin n)) where + toFun + | .inl (.inl i) => .inr (.inl i) + | .inl (.inr v) => .inl v + | .inr i => .inr (.inr i) + invFun + | .inl v => .inl (.inr v) + | .inr (.inl i) => .inl (.inl i) + | .inr (.inr i) => .inr i + left_inv := by rintro ((i|v)|i) <;> rfl + right_inv := by rintro (v|(i|i)) <;> rfl + +lemma boundary_old (i j : Fin n) : + ((.inl i : Fin n ⊕ Fin 12)=s.boundary j) ↔ + i=j ∧ i≠s.a ∧ i≠s.b ∧ i≠s.c := by + by_cases ha : j=s.a <;> by_cases hb : j=s.b <;> by_cases hc : j=s.c <;> + simp_all [boundary] + +lemma boundary_new (v : Fin 12) (j : Fin n) : + ((.inr v : Fin n ⊕ Fin 12)=s.boundary j) ↔ + (j=s.a ∧ v=6) ∨ (j=s.b ∧ v=10) ∨ (j=s.c ∧ v=11) := by + have hab:=s.ab; have hbc:=s.bc; have hac:=s.ac + by_cases ha : j=s.a <;> by_cases hb : j=s.b <;> by_cases hc : j=s.c <;> + simp_all [boundary] + +lemma interface_old (p q : Pairing n) (v : Fin 12) (i : Fin n) : + (∃ k, s.active p q k ∧ v=ThreeBox.boundary k ∧ (.inl i : Fin n ⊕ Fin n)=s.interface k) ↔ + (i=s.a ∧ v=4 ∧ p.Occupied s.a) ∨ + (i=s.b ∧ v=0 ∧ p.Occupied s.b) ∨ (i=s.c ∧ v=1 ∧ p.Occupied s.c) := by + simp only [Fin.exists_fin_succ,interface,active,ThreeBox.boundary] + simp only [Matrix.cons_val_zero,Matrix.cons_val_succ,Matrix.cons_val_fin_one, + Sum.inl.injEq,Sum.inl_ne_inr,and_false,or_false,Fin.exists_fin_zero] + itauto + +lemma interface_new (p q : Pairing n) (v : Fin 12) (i : Fin n) : + (∃ k, s.active p q k ∧ v=ThreeBox.boundary k ∧ (.inr i : Fin n ⊕ Fin n)=s.interface k) ↔ + ((i=s.a ∧ v=6) ∨ (i=s.b ∧ v=10) ∨ (i=s.c ∧ v=11)) ∧ q.Occupied i := by + simp only [Fin.exists_fin_succ,interface,active,ThreeBox.boundary] + simp only [Matrix.cons_val_zero,Matrix.cons_val_succ,Matrix.cons_val_fin_one, + Sum.inr.injEq,Sum.inr_ne_inl,and_false,false_or,or_false,Fin.exists_fin_zero] + constructor + · rintro (⟨h,hv,hi⟩ | ⟨h,hv,hi⟩ | ⟨h,hv,hi⟩) <;> subst i + · exact ⟨Or.inl ⟨rfl,hv⟩,h⟩ + · exact ⟨Or.inr (Or.inl ⟨rfl,hv⟩),h⟩ + · exact ⟨Or.inr (Or.inr ⟨rfl,hv⟩),h⟩ + · rintro ⟨(⟨rfl,hv⟩|⟨rfl,hv⟩|⟨rfl,hv⟩),h⟩ + · exact Or.inl ⟨h,hv,rfl⟩ + · exact Or.inr (Or.inl ⟨h,hv,rfl⟩) + · exact Or.inr (Or.inr ⟨h,hv,rfl⟩) + +lemma exterior_edge (p q : Pairing n) (t : ThreeBox.Config) + (v w : (Fin n ⊕ Fin 12) ⊕ Fin n) : + s.attached p q t v w ↔ s.patch p q t (exteriorEquiv v) (exteriorEquiv w) := by + rcases v with (i|v)|i <;> rcases w with (j|w)|j + all_goals dsimp only [attached,Graph.Attached.wiring,patch,Patch.glued,exteriorEquiv,Equiv.coe_fn_mk] + · rfl + · simpa only [wiring,and_comm,and_left_comm,and_assoc] using (s.interface_old p q w i).symm + · rw [s.boundary_old] + change ((i=j ∧ i≠s.a ∧ i≠s.b ∧ i≠s.c) ∧ q.Occupied j) ↔ + i=j ∧ i≠s.a ∧ i≠s.b ∧ i≠s.c ∧ q.Occupied i + constructor + · rintro ⟨⟨rfl,ha,hb,hc⟩,hq⟩; exact ⟨rfl,ha,hb,hc,hq⟩ + · rintro ⟨rfl,ha,hb,hc,hq⟩; exact ⟨⟨rfl,ha,hb,hc⟩,hq⟩ + · exact (s.interface_old p q v j).symm + · rfl + · rw [s.boundary_new] + exact (s.interface_new p q v j).symm + · rw [s.boundary_old] + change ((j=i ∧ j≠s.a ∧ j≠s.b ∧ j≠s.c) ∧ q.Occupied i) ↔ + j=i ∧ j≠s.a ∧ j≠s.b ∧ j≠s.c ∧ q.Occupied j + constructor + · rintro ⟨⟨rfl,ha,hb,hc⟩,hq⟩; exact ⟨rfl,ha,hb,hc,hq⟩ + · rintro ⟨rfl,ha,hb,hc,hq⟩; exact ⟨⟨rfl,ha,hb,hc⟩,hq⟩ + · rw [s.boundary_new] + simpa only [and_comm,and_left_comm,and_assoc] using (s.interface_new p q w i).symm + · rfl + +end TriplePosition +end +end CriticalStrip.Diagram + +end OAI diff --git a/lean/OAI/Combinatorics/StripMass/TriplePatch.lean b/lean/OAI/Combinatorics/StripMass/TriplePatch.lean new file mode 100644 index 0000000000000000000000000000000000000000..2147acb0a9dc7aeae5c8a4463f2412c5a0f7ffe5 --- /dev/null +++ b/lean/OAI/Combinatorics/StripMass/TriplePatch.lean @@ -0,0 +1,484 @@ +import Mathlib +import OAI.Combinatorics.StripMass.ThreeBoxSplitPolynomial +import OAI.Combinatorics.StripMass.TripleCircuit + +namespace OAI + +/-! Critical honeycomb strip paths, polynomial identities and crossing mass. -/ + + + +namespace CriticalStrip.Diagram +noncomputable section +open scoped Classical +namespace TriplePosition +variable {n : ℕ} (s : TriplePosition n) + +def output (q : Pairing n) : Fin n ⊕ Fin n → Prop + | .inl _ => False + | .inr i => q.Occupied i + +def reachTest (q : Pairing n) (r : (Fin n ⊕ Fin n) → (Fin n ⊕ Fin n) → Prop) : Prop := + ∀ i j, r (.inr i) (.inr j) ↔ i=j ∨ q.Adj i j + +def exteriorPredicate (p q : Pairing n) (k : Fin 51) : Prop := + s.Outside p q ∧ ThreeBox.exteriorTest (s.exterior p q) s.interface (s.active p q) + (output q) (reachTest q) k + +def patchEquiv (p q : Pairing n) (t : ThreeBox.Config) : + Graph.BoundaryEquiv (s.attached p q t) (s.patch p q t) Sum.inr + (fun i => .inr (.inr i)) := + Graph.BoundaryEquiv.ofEquiv exteriorEquiv (s.exterior_edge p q t) (fun _ => rfl) + +lemma active_iff (p q : Pairing n) (t : ThreeBox.Config) : + (∀ i, s.active p q i ↔ ThreeBox.boundaryOccupied t i) ↔ + (p.Occupied s.a ↔ t.2.1.Occupied 0) ∧ + (p.Occupied s.b ↔ t.1.Occupied 0) ∧ (p.Occupied s.c ↔ t.1.Occupied 1) ∧ + (q.Occupied s.a ↔ t.2.1.Occupied 2) ∧ + (q.Occupied s.b ↔ t.2.2.Occupied 2) ∧ (q.Occupied s.c ↔ t.2.2.Occupied 3) := by + simp [Fin.forall_fin_succ,active,ThreeBox.boundaryOccupied,ThreeBox.boundary, + ThreeBox.atRow,ThreeBox.row,ThreeBox.port] + +lemma compatible_support_iff (p q : Pairing n) (t : ThreeBox.Config) : + Circuit.Compatible p (s.rightCircuit t) ∧ (∀ i, q.Occupied i ↔ s.support p t i) ↔ + s.Outside p q ∧ ThreeBox.Compatible t ∧ + (∀ i, s.active p q i ↔ ThreeBox.boundaryOccupied t i) := by + rw [s.compatible_iff,s.active_iff] + have hab:=s.ab; have hbc:=s.bc; have hac:=s.ac + constructor + · rintro ⟨⟨hc,ha,hb,hc'⟩,hs⟩ + refine ⟨?_,hc,ha,hb,hc',?_,?_,?_⟩ + · intro i hia hib hic + simpa only [support,ite_eq_right hia,ite_eq_right hib,ite_eq_right hic] using (hs i).symm + · simpa [support] using hs s.a + · simpa [support,hab.symm] using hs s.b + · simpa [support,hac.symm,hbc.symm] using hs s.c + · rintro ⟨ho,hc,ha,hb,hc',hqa,hqb,hqc⟩ + refine ⟨⟨hc,ha,hb,hc'⟩,?_⟩ + intro i + by_cases hia : i=s.a + · subst i; simpa [support] using hqa + · by_cases hib : i=s.b + · subst i; simpa [support,hia] using hqb + · by_cases hic : i=s.c + · subst i; simpa [support,hia,hib] using hqc + · simpa only [support,ite_eq_right hia,ite_eq_right hib,ite_eq_right hic] using (ho i hia hib hic).symm + +lemma patchTest_realizes (p q : Pairing n) (t : ThreeBox.Config) : + ThreeBox.patchTest (s.exterior p q) s.interface (s.active p q) (output q) (reachTest q) t ↔ + ThreeBox.Compatible t ∧ (∀ i, s.active p q i ↔ ThreeBox.boundaryOccupied t i) ∧ + GraphRealizes (s.patch p q t) (fun i => .inr (.inr i)) q := by + unfold ThreeBox.patchTest + refine and_congr_right (fun _ => and_congr_right (fun _ => ?_)) + constructor + · rintro ⟨hd,hr⟩ + refine ⟨?_,hr⟩ + intro v w he + obtain ⟨(x|(i|i)),hi,h⟩ := hd v w he + · exact hi.elim + · exact hi.elim + · exact ⟨i,hi,h⟩ + · intro h + refine ⟨?_,h.reach⟩ + intro v w he + obtain ⟨i,hi,hr⟩ := h.no_loop v w he + exact ⟨.inr (.inr i),hi,hr⟩ + +lemma eval_patch_iff (p q : Pairing n) (t : ThreeBox.Config) : + Circuit.eval p (s.rightCircuit t)=some q ↔ + s.Outside p q ∧ ThreeBox.patchTest (s.exterior p q) s.interface (s.active p q) + (output q) (reachTest q) t := by + rw [s.eval_iff,s.patchTest_realizes] + constructor + · rintro ⟨hc,hr⟩ + have hs : ∀ i, q.Occupied i ↔ s.support p t i := fun i => + (hr.boundary_used_iff s.boundary_injective i).symm.trans (s.boundary_used p t i) + obtain ⟨ho,hc',ha⟩ := (s.compatible_support_iff p q t).mp ⟨hc,hs⟩ + refine ⟨ho,hc',ha,?_⟩ + apply (s.patchEquiv p q t).realizes_iff.mp + exact (Graph.Attached.contraction (s.wiring p t) s.boundary q.Occupied + (fun i => (hs i).trans (s.boundary_used p t i).symm) s.boundary_injective).realizes_inv hr + · rintro ⟨ho,hc,ha,hr⟩ + obtain ⟨hc',hs⟩ := (s.compatible_support_iff p q t).mpr ⟨ho,hc,ha⟩ + refine ⟨hc',?_⟩ + apply (Graph.Attached.contraction (s.wiring p t) s.boundary q.Occupied + (fun i => (hs i).trans (s.boundary_used p t i).symm) s.boundary_injective).realizes + exact (s.patchEquiv p q t).realizes_iff.mpr hr + +lemma eval_profile_iff (p q : Pairing n) (t : ThreeBox.Config) : + Circuit.eval p (s.rightCircuit t)=some q ↔ + ∃ k, ThreeBox.profile t=some k ∧ s.exteriorPredicate p q k := by + rw [s.eval_patch_iff,ThreeBox.patchTest_iff] + unfold exteriorPredicate + constructor + · rintro ⟨ho,k,hk,hp⟩; exact ⟨k,hk,ho,hp⟩ + · rintro ⟨k,hk,ho,hp⟩; exact ⟨ho,k,hk,hp⟩ + +end TriplePosition + + + + + +namespace Tile + +def mirrorPort : Fin 4 → Fin 4 := ![1,0,3,2] +lemma mirrorPort_involutive : Function.Involutive mirrorPort := by intro i; fin_cases i <;> rfl + +def mirrorPortEquiv : Fin 4 ≃ Fin 4 := + ⟨mirrorPort,mirrorPort,mirrorPort_involutive,mirrorPort_involutive⟩ + +def mirror : Tile → Tile + | .vacant => .vacant + | .vertical₀ => .vertical₁ + | .vertical₁ => .vertical₀ + | .diagonal₀ => .diagonal₁ + | .diagonal₁ => .diagonal₀ + | .cap => .cap + | .cup => .cup + | .verticalPair => .verticalPair + | .capCup => .capCup + +lemma mirror_involutive : Function.Involutive mirror := by intro t; cases t <;> rfl + +def mirrorEquiv : Tile ≃ Tile := ⟨mirror,mirror,mirror_involutive,mirror_involutive⟩ + +lemma mirror_adj (t : Tile) (i j : Fin 4) : + t.mirror.Adj i j ↔ t.Adj (mirrorPort i) (mirrorPort j) := by + revert t i j + decide + +lemma mirror_occupied (t : Tile) (i : Fin 4) : + t.mirror.Occupied i ↔ t.Occupied (mirrorPort i) := by + unfold Occupied + simp only [mirror_adj] + exact mirrorPortEquiv.surjective.exists.symm + +lemma weight_mirror {K : Type*} [One K] (w : Weights K) (t : Tile) : + w.tile t.mirror=w.tile t := by cases t <;> rfl + +end Tile + + + + + +namespace TriplePosition +variable {n : ℕ} (s : TriplePosition n) + +def leftCircuit (t : ThreeBox.Config) : Circuit n := + .snoc (.snoc (.snoc .nil (s.left.gate t.1.mirror)) (s.right.gate t.2.1.mirror)) + (s.left.gate t.2.2.mirror) + +def mirrorVertexEquiv : (((Fin n ⊕ Fin 4) ⊕ Fin 4) ⊕ Fin 4) ≃ (Fin n ⊕ Fin 12) := + (Equiv.sumCongr (Equiv.sumCongr (Equiv.sumCongr (Equiv.refl _) Tile.mirrorPortEquiv) + Tile.mirrorPortEquiv) Tile.mirrorPortEquiv).trans vertexEquiv + +def mirrorWiring (p : Pairing n) (t : ThreeBox.Config) : (Fin n ⊕ Fin 12) → (Fin n ⊕ Fin 12) → Prop + | .inl i,.inl j => p.Adj i j + | .inr v,.inr w => ThreeBox.Adj t v w + | .inl i,.inr v | .inr v,.inl i => + (i=s.c ∧ v=4 ∧ p.Occupied s.c) ∨ + (i=s.b ∧ v=0 ∧ p.Occupied s.b) ∨ + (i=s.a ∧ v=1 ∧ p.Occupied s.a) + +def mirrorBoundary (i : Fin n) : Fin n ⊕ Fin 12 := + if i=s.c then .inr 6 else if i=s.b then .inr 10 else if i=s.a then .inr 11 else .inl i + +@[simp] lemma mirror_vertex_old (i : Fin n) : + mirrorVertexEquiv (.inl (.inl (.inl i)))=.inl i := rfl +@[simp] lemma mirror_vertex_zero (i : Fin 4) : + (mirrorVertexEquiv (n:=n) (.inl (.inl (.inr i))))= + .inr ⟨(Tile.mirrorPort i).val,by omega⟩ := rfl +@[simp] lemma mirror_vertex_one (i : Fin 4) : + (mirrorVertexEquiv (n:=n) (.inl (.inr i)))= + .inr ⟨4+(Tile.mirrorPort i).val,by omega⟩ := rfl +@[simp] lemma mirror_vertex_two (i : Fin 4) : + (mirrorVertexEquiv (n:=n) (.inr i))= + .inr ⟨4+(4+(Tile.mirrorPort i).val),by omega⟩ := rfl + +lemma mirror_boundary_eq (t : ThreeBox.Config) (i : Fin n) : + mirrorVertexEquiv ((s.leftCircuit t).compactBoundary i)=s.mirrorBoundary i := by + have hab:=s.ab; have hbc:=s.bc; have hac:=s.ac + by_cases ha : i=s.a <;> by_cases hb : i=s.b <;> by_cases hc : i=s.c <;> + simp_all [leftCircuit, Circuit.compactBoundary, CompactGate.boundary, Position.gate, left, + right, mirrorBoundary] <;> rfl + +lemma mirror_edge_0_0 (p : Pairing n) (t : ThreeBox.Config) + (v : Fin n) (w : Fin n) : + Circuit.compactWiring p (s.leftCircuit t) (.inl (.inl (.inl v))) (.inl (.inl (.inl w))) ↔ + s.mirrorWiring p t (mirrorVertexEquiv (.inl (.inl (.inl v)))) (mirrorVertexEquiv (.inl (.inl (.inl w)))) := by + all_goals simp [leftCircuit, Circuit.compactWiring, CompactGate.wiring, Position.gate, left, + right, mirrorWiring, mirror_vertex_old] + +lemma mirror_edge_0_1 (p : Pairing n) (t : ThreeBox.Config) + (v : Fin n) (w : Fin 4) : + Circuit.compactWiring p (s.leftCircuit t) (.inl (.inl (.inl v))) (.inl (.inl (.inr w))) ↔ + s.mirrorWiring p t (mirrorVertexEquiv (.inl (.inl (.inl v)))) (mirrorVertexEquiv (.inl (.inl (.inr w)))) := by + all_goals fin_cases w + all_goals simp [leftCircuit, Circuit.compactWiring, CompactGate.wiring, Circuit.support, + Circuit.compactBoundary, Position.gate, left, right, mirrorWiring, mirror_vertex_old, + mirror_vertex_zero, Tile.mirrorPort] + all_goals dsimp only [Circuit.CompactVertex] at * + all_goals simp + +lemma mirror_edge_0_2 (p : Pairing n) (t : ThreeBox.Config) + (v : Fin n) (w : Fin 4) : + Circuit.compactWiring p (s.leftCircuit t) (.inl (.inl (.inl v))) (.inl (.inr w)) ↔ + s.mirrorWiring p t (mirrorVertexEquiv (.inl (.inl (.inl v)))) (mirrorVertexEquiv (.inl (.inr w))) := by + all_goals fin_cases w + all_goals simp [leftCircuit, Circuit.compactWiring, CompactGate.wiring, Circuit.support, + Circuit.compactBoundary, CompactGate.boundary, Position.gate, left, right, mirrorWiring, + mirror_vertex_old, mirror_vertex_one, Tile.mirror_occupied, Tile.mirrorPort, s.ab.symm, + s.bc.symm, s.ac.symm] + all_goals try dsimp only [Circuit.CompactVertex] at * + all_goals simp + +lemma mirror_edge_0_3 (p : Pairing n) (t : ThreeBox.Config) + (v : Fin n) (w : Fin 4) : + Circuit.compactWiring p (s.leftCircuit t) (.inl (.inl (.inl v))) (.inr w) ↔ + s.mirrorWiring p t (mirrorVertexEquiv (.inl (.inl (.inl v)))) (mirrorVertexEquiv (.inr w)) := by + all_goals fin_cases w + all_goals simp [leftCircuit, Circuit.compactWiring, CompactGate.wiring, Circuit.support, + Circuit.compactBoundary, CompactGate.boundary, Position.gate, left, right, mirrorWiring, + mirror_vertex_old, mirror_vertex_two, Tile.mirror_occupied, Tile.mirrorPort, s.ab, s.ac] + all_goals try dsimp only [Circuit.CompactVertex] at * + all_goals simp + +lemma mirror_edge_1_0 (p : Pairing n) (t : ThreeBox.Config) + (v : Fin 4) (w : Fin n) : + Circuit.compactWiring p (s.leftCircuit t) (.inl (.inl (.inr v))) (.inl (.inl (.inl w))) ↔ + s.mirrorWiring p t (mirrorVertexEquiv (.inl (.inl (.inr v)))) (mirrorVertexEquiv (.inl (.inl (.inl w)))) := by + fin_cases v + all_goals simp [leftCircuit, Circuit.compactWiring, CompactGate.wiring, Circuit.support, + Circuit.compactBoundary, Position.gate, left, right, mirrorWiring, mirror_vertex_old, + mirror_vertex_zero, Tile.mirrorPort] + all_goals dsimp only [Circuit.CompactVertex] at * + all_goals simp + +lemma mirror_edge_1_1 (p : Pairing n) (t : ThreeBox.Config) + (v : Fin 4) (w : Fin 4) : + Circuit.compactWiring p (s.leftCircuit t) (.inl (.inl (.inr v))) (.inl (.inl (.inr w))) ↔ + s.mirrorWiring p t (mirrorVertexEquiv (.inl (.inl (.inr v)))) (mirrorVertexEquiv (.inl (.inl (.inr w)))) := by + fin_cases v + all_goals fin_cases w + all_goals simp [leftCircuit, Circuit.compactWiring, CompactGate.wiring, Position.gate, left, + right, mirrorWiring, mirror_vertex_zero, Tile.mirror_adj, Tile.mirrorPort, ThreeBox.Adj, + ThreeBox.tileEdge, ThreeBox.row, ThreeBox.port, ThreeBox.atRow, ThreeBox.wireEdge] + all_goals simp [Tile.Adj] + all_goals itauto + +lemma mirror_edge_1_2 (p : Pairing n) (t : ThreeBox.Config) + (v : Fin 4) (w : Fin 4) : + Circuit.compactWiring p (s.leftCircuit t) (.inl (.inl (.inr v))) (.inl (.inr w)) ↔ + s.mirrorWiring p t (mirrorVertexEquiv (.inl (.inl (.inr v)))) (mirrorVertexEquiv (.inl (.inr w))) := by + fin_cases v + all_goals fin_cases w + all_goals simp [leftCircuit, Circuit.compactWiring, CompactGate.wiring, Circuit.support, + Circuit.compactBoundary, CompactGate.boundary, Position.gate, left, right, mirrorWiring, + mirror_vertex_zero, mirror_vertex_one, Tile.mirror_occupied, Tile.mirrorPort, ThreeBox.Adj, + ThreeBox.tileEdge, ThreeBox.row, ThreeBox.port, ThreeBox.atRow, ThreeBox.wireEdge, s.ab.symm, + s.bc.symm, s.ac.symm] + all_goals try dsimp only [Circuit.CompactVertex] at * + all_goals simp + +lemma mirror_edge_1_3 (p : Pairing n) (t : ThreeBox.Config) + (v : Fin 4) (w : Fin 4) : + Circuit.compactWiring p (s.leftCircuit t) (.inl (.inl (.inr v))) (.inr w) ↔ + s.mirrorWiring p t (mirrorVertexEquiv (.inl (.inl (.inr v)))) (mirrorVertexEquiv (.inr w)) := by + fin_cases v + all_goals fin_cases w + all_goals simp [leftCircuit, Circuit.compactWiring, CompactGate.wiring, Circuit.support, + Circuit.compactBoundary, CompactGate.boundary, Position.gate, left, right, mirrorWiring, + mirror_vertex_zero, mirror_vertex_two, Tile.mirror_occupied, Tile.mirrorPort, ThreeBox.Adj, + ThreeBox.tileEdge, ThreeBox.row, ThreeBox.port, ThreeBox.atRow, ThreeBox.wireEdge, s.ab, s.ac] + all_goals try dsimp only [Circuit.CompactVertex] at * + all_goals simp + +lemma mirror_edge_2_0 (p : Pairing n) (t : ThreeBox.Config) + (v : Fin 4) (w : Fin n) : + Circuit.compactWiring p (s.leftCircuit t) (.inl (.inr v)) (.inl (.inl (.inl w))) ↔ + s.mirrorWiring p t (mirrorVertexEquiv (.inl (.inr v))) (mirrorVertexEquiv (.inl (.inl (.inl w)))) := by + fin_cases v + all_goals simp [leftCircuit, Circuit.compactWiring, CompactGate.wiring, Circuit.support, + Circuit.compactBoundary, CompactGate.boundary, Position.gate, left, right, mirrorWiring, + mirror_vertex_old, mirror_vertex_one, Tile.mirror_occupied, Tile.mirrorPort, s.ab.symm, + s.bc.symm, s.ac.symm] + all_goals try dsimp only [Circuit.CompactVertex] at * + all_goals simp + +lemma mirror_edge_2_1 (p : Pairing n) (t : ThreeBox.Config) + (v : Fin 4) (w : Fin 4) : + Circuit.compactWiring p (s.leftCircuit t) (.inl (.inr v)) (.inl (.inl (.inr w))) ↔ + s.mirrorWiring p t (mirrorVertexEquiv (.inl (.inr v))) (mirrorVertexEquiv (.inl (.inl (.inr w)))) := by + fin_cases v + all_goals fin_cases w + all_goals simp [leftCircuit, Circuit.compactWiring, CompactGate.wiring, Circuit.support, + Circuit.compactBoundary, CompactGate.boundary, Position.gate, left, right, mirrorWiring, + mirror_vertex_zero, mirror_vertex_one, Tile.mirror_occupied, Tile.mirrorPort, ThreeBox.Adj, + ThreeBox.tileEdge, ThreeBox.row, ThreeBox.port, ThreeBox.atRow, ThreeBox.wireEdge, s.ab.symm, + s.bc.symm, s.ac.symm] + all_goals try dsimp only [Circuit.CompactVertex] at * + all_goals simp + +lemma mirror_edge_2_2 (p : Pairing n) (t : ThreeBox.Config) + (v : Fin 4) (w : Fin 4) : + Circuit.compactWiring p (s.leftCircuit t) (.inl (.inr v)) (.inl (.inr w)) ↔ + s.mirrorWiring p t (mirrorVertexEquiv (.inl (.inr v))) (mirrorVertexEquiv (.inl (.inr w))) := by + fin_cases v + all_goals fin_cases w + all_goals simp [leftCircuit, Circuit.compactWiring, CompactGate.wiring, Position.gate, left, + right, mirrorWiring, mirror_vertex_one, Tile.mirror_adj, Tile.mirrorPort, ThreeBox.Adj, + ThreeBox.tileEdge, ThreeBox.row, ThreeBox.port, ThreeBox.atRow, ThreeBox.wireEdge] + all_goals simp [Tile.Adj] + all_goals itauto + +lemma mirror_edge_2_3 (p : Pairing n) (t : ThreeBox.Config) + (v : Fin 4) (w : Fin 4) : + Circuit.compactWiring p (s.leftCircuit t) (.inl (.inr v)) (.inr w) ↔ + s.mirrorWiring p t (mirrorVertexEquiv (.inl (.inr v))) (mirrorVertexEquiv (.inr w)) := by + fin_cases v + all_goals fin_cases w + all_goals simp [leftCircuit, Circuit.compactWiring, CompactGate.wiring, Circuit.support, + Circuit.compactBoundary, CompactGate.boundary, Position.gate, left, right, mirrorWiring, + mirror_vertex_one, mirror_vertex_two, Tile.mirror_occupied, Tile.mirrorPort, ThreeBox.Adj, + ThreeBox.tileEdge, ThreeBox.row, ThreeBox.port, ThreeBox.atRow, ThreeBox.wireEdge, s.ab, s.ac] + all_goals try dsimp only [Circuit.CompactVertex] at * + all_goals simp + +lemma mirror_edge_3_0 (p : Pairing n) (t : ThreeBox.Config) + (v : Fin 4) (w : Fin n) : + Circuit.compactWiring p (s.leftCircuit t) (.inr v) (.inl (.inl (.inl w))) ↔ + s.mirrorWiring p t (mirrorVertexEquiv (.inr v)) (mirrorVertexEquiv (.inl (.inl (.inl w)))) := by + fin_cases v + all_goals simp [leftCircuit, Circuit.compactWiring, CompactGate.wiring, Circuit.support, + Circuit.compactBoundary, CompactGate.boundary, Position.gate, left, right, mirrorWiring, + mirror_vertex_old, mirror_vertex_two, Tile.mirror_occupied, Tile.mirrorPort, s.ab, s.ac] + all_goals try dsimp only [Circuit.CompactVertex] at * + all_goals simp + +lemma mirror_edge_3_1 (p : Pairing n) (t : ThreeBox.Config) + (v : Fin 4) (w : Fin 4) : + Circuit.compactWiring p (s.leftCircuit t) (.inr v) (.inl (.inl (.inr w))) ↔ + s.mirrorWiring p t (mirrorVertexEquiv (.inr v)) (mirrorVertexEquiv (.inl (.inl (.inr w)))) := by + fin_cases v + all_goals fin_cases w + all_goals simp [leftCircuit, Circuit.compactWiring, CompactGate.wiring, Circuit.support, + Circuit.compactBoundary, CompactGate.boundary, Position.gate, left, right, mirrorWiring, + mirror_vertex_zero, mirror_vertex_two, Tile.mirror_occupied, Tile.mirrorPort, ThreeBox.Adj, + ThreeBox.tileEdge, ThreeBox.row, ThreeBox.port, ThreeBox.atRow, ThreeBox.wireEdge, s.ab, s.ac] + all_goals try dsimp only [Circuit.CompactVertex] at * + all_goals simp + +lemma mirror_edge_3_2 (p : Pairing n) (t : ThreeBox.Config) + (v : Fin 4) (w : Fin 4) : + Circuit.compactWiring p (s.leftCircuit t) (.inr v) (.inl (.inr w)) ↔ + s.mirrorWiring p t (mirrorVertexEquiv (.inr v)) (mirrorVertexEquiv (.inl (.inr w))) := by + fin_cases v + all_goals fin_cases w + all_goals simp [leftCircuit, Circuit.compactWiring, CompactGate.wiring, Circuit.support, + Circuit.compactBoundary, CompactGate.boundary, Position.gate, left, right, mirrorWiring, + mirror_vertex_one, mirror_vertex_two, Tile.mirror_occupied, Tile.mirrorPort, ThreeBox.Adj, + ThreeBox.tileEdge, ThreeBox.row, ThreeBox.port, ThreeBox.atRow, ThreeBox.wireEdge, s.ab, s.ac] + all_goals try dsimp only [Circuit.CompactVertex] at * + all_goals simp + +lemma mirror_edge_3_3 (p : Pairing n) (t : ThreeBox.Config) + (v : Fin 4) (w : Fin 4) : + Circuit.compactWiring p (s.leftCircuit t) (.inr v) (.inr w) ↔ + s.mirrorWiring p t (mirrorVertexEquiv (.inr v)) (mirrorVertexEquiv (.inr w)) := by + fin_cases v + all_goals fin_cases w + all_goals simp [leftCircuit, Circuit.compactWiring, CompactGate.wiring, Position.gate, left, + right, mirrorWiring, mirror_vertex_two, Tile.mirror_adj, Tile.mirrorPort, ThreeBox.Adj, + ThreeBox.tileEdge, ThreeBox.row, ThreeBox.port, ThreeBox.atRow, ThreeBox.wireEdge] + all_goals simp [Tile.Adj] + all_goals itauto + +lemma mirror_edge_iff (p : Pairing n) (t : ThreeBox.Config) + (v w : (s.leftCircuit t).CompactVertex) : + Circuit.compactWiring p (s.leftCircuit t) v w ↔ + s.mirrorWiring p t (mirrorVertexEquiv v) (mirrorVertexEquiv w) := by + rcases v with ((v|v)|v)|v <;> rcases w with ((w|w)|w)|w + · exact s.mirror_edge_0_0 p t v w + · exact s.mirror_edge_0_1 p t v w + · exact s.mirror_edge_0_2 p t v w + · exact s.mirror_edge_0_3 p t v w + · exact s.mirror_edge_1_0 p t v w + · exact s.mirror_edge_1_1 p t v w + · exact s.mirror_edge_1_2 p t v w + · exact s.mirror_edge_1_3 p t v w + · exact s.mirror_edge_2_0 p t v w + · exact s.mirror_edge_2_1 p t v w + · exact s.mirror_edge_2_2 p t v w + · exact s.mirror_edge_2_3 p t v w + · exact s.mirror_edge_3_0 p t v w + · exact s.mirror_edge_3_1 p t v w + · exact s.mirror_edge_3_2 p t v w + · exact s.mirror_edge_3_3 p t v w + +def mirrorEquiv (p : Pairing n) (t : ThreeBox.Config) : + Graph.BoundaryEquiv (Circuit.compactWiring p (s.leftCircuit t)) (s.mirrorWiring p t) + (s.leftCircuit t).compactBoundary s.mirrorBoundary := + Graph.BoundaryEquiv.ofEquiv mirrorVertexEquiv (s.mirror_edge_iff p t) (s.mirror_boundary_eq t) + + + + + + +instance mirrorWiring_symm (p : Pairing n) (t : ThreeBox.Config) : Std.Symm (s.mirrorWiring p t) := by + constructor + rintro (i|v) (j|w) h + · exact Pairing.adj_symm h + · exact h + · exact h + · exact (ThreeBox.adj_symm t).symm _ _ h + +lemma mirror_boundary_injective : Function.Injective s.mirrorBoundary := by + let t : ThreeBox.Config := (.vacant,.vacant,.vacant) + intro i j hij + apply (s.leftCircuit t).compactBoundary_injective + apply mirrorVertexEquiv.injective + simpa only [s.mirror_boundary_eq] using hij + +def mirrorSupport (p : Pairing n) (t : ThreeBox.Config) (i : Fin n) : Prop := + if i=s.c then t.2.1.Occupied 2 else if i=s.b then t.2.2.Occupied 2 + else if i=s.a then t.2.2.Occupied 3 else p.Occupied i + +lemma mirror_circuit_support (p : Pairing n) (t : ThreeBox.Config) (i : Fin n) : + Circuit.support p (s.leftCircuit t) i ↔ s.mirrorSupport p t i := by + have hab:=s.ab; have hbc:=s.bc; have hac:=s.ac + by_cases ha : i=s.c <;> by_cases hb : i=s.b <;> by_cases hc : i=s.a <;> + simp_all [leftCircuit,Circuit.support,Position.gate,left,right,mirrorSupport,Tile.mirror_occupied,Tile.mirrorPort] + +lemma mirror_boundary_used (p : Pairing n) (t : ThreeBox.Config) (i : Fin n) : + Graph.Used (s.mirrorWiring p t) (s.mirrorBoundary i) ↔ s.mirrorSupport p t i := by + rw [←s.mirror_circuit_support p t i,←Circuit.compact_boundary_used] + constructor + · intro h + have hh := (s.mirrorEquiv p t).inv_used _ h + rwa [(s.mirrorEquiv p t).inv_boundary] at hh + · intro h + have hh := (s.mirrorEquiv p t).map_used _ h + rwa [(s.mirrorEquiv p t).map_boundary] at hh + +lemma mirror_compatible_iff (p : Pairing n) (t : ThreeBox.Config) : + Circuit.Compatible p (s.leftCircuit t) ↔ + ThreeBox.Compatible t ∧ (p.Occupied s.c ↔ t.2.1.Occupied 0) ∧ + (p.Occupied s.b ↔ t.1.Occupied 0) ∧ (p.Occupied s.a ↔ t.1.Occupied 1) := by + simp only [leftCircuit, Circuit.Compatible, Circuit.support, Position.gate, left, right, s.ab, + s.bc, s.ac, s.ab.symm, s.bc.symm, s.ac.symm, ThreeBox.Compatible, true_and, + Tile.mirror_occupied, Tile.mirrorPort, Matrix.cons_val_zero] + itauto + +lemma mirror_eval_iff (p q : Pairing n) (t : ThreeBox.Config) : + Circuit.eval p (s.leftCircuit t)=some q ↔ + Circuit.Compatible p (s.leftCircuit t) ∧ GraphRealizes (s.mirrorWiring p t) s.mirrorBoundary q := by + rw [Circuit.compact_eval_iff,(s.mirrorEquiv p t).realizes_iff] + +end TriplePosition +end +end CriticalStrip.Diagram + +end OAI diff --git a/lean/OAI/Combinatorics/StripMass/TurnDisk.lean b/lean/OAI/Combinatorics/StripMass/TurnDisk.lean new file mode 100644 index 0000000000000000000000000000000000000000..3573aa0b69accbe1864bcb8326571141cdc6cc39 --- /dev/null +++ b/lean/OAI/Combinatorics/StripMass/TurnDisk.lean @@ -0,0 +1,575 @@ +import Mathlib +import OAI.Combinatorics.StripMass.TurnGate + +namespace OAI + +/-! Critical honeycomb strip paths, polynomial identities and crossing mass. -/ + + +namespace CriticalStrip.Diagram +noncomputable section +open scoped Classical + +namespace BoundaryInsert +variable {n m : ℕ} + +def equiv (k : ℕ) (hk : k≤n) : (Fin n ⊕ Fin m) ≃ Fin (n+m) := + Equiv.ofBijective (Sum.elim (old k hk) (fresh k hk)) ⟨by + rintro (i|i) (j|j) h + · exact congrArg Sum.inl ((old k hk).injective h) + · exact (disjoint k hk i j h).elim + · exact (disjoint k hk j i h.symm).elim + · exact congrArg Sum.inr ((fresh k hk).injective h),by + intro i + obtain ⟨j,rfl⟩|⟨j,rfl⟩:=cover k hk i + · exact ⟨.inl j,rfl⟩ + · exact ⟨.inr j,rfl⟩⟩ + +@[simp] lemma equiv_old (k : ℕ) (hk : k≤n) (i : Fin n) : + equiv (m:=m) k hk (.inl i)=old k hk i := rfl +@[simp] lemma equiv_fresh (k : ℕ) (hk : k≤n) (i : Fin m) : + equiv (m:=m) k hk (.inr i)=fresh k hk i := rfl + +lemma pairing_adj (k : ℕ) (hk : k≤n) (p : Pairing n) (t : Pairing m) + (u v : Fin (n+m)) : + (pairing k hk p t).Adj u v ↔ (p.map (old k hk)).Adj u v ∨ + (t.map (fresh k hk)).Adj u v := by + simp only [Pairing.Adj,pairing,Finset.mem_union] + tauto + +@[simp] lemma pairing_old_adj (k : ℕ) (hk : k≤n) (p : Pairing n) (t : Pairing m) + (i j : Fin n) : (pairing k hk p t).Adj (old k hk i) (old k hk j) ↔ p.Adj i j := by + rw [pairing_adj,Pairing.map_adj_image] + constructor + · rintro (h|h) + · exact h + · obtain ⟨a,b,_,ha,_⟩ := (Pairing.map_adj _ _ _ _).mp h + exact (disjoint k hk i a ha.symm).elim + · exact Or.inl + +@[simp] lemma pairing_fresh_adj (k : ℕ) (hk : k≤n) (p : Pairing n) (t : Pairing m) + (i j : Fin m) : (pairing k hk p t).Adj (fresh k hk i) (fresh k hk j) ↔ t.Adj i j := by + rw [pairing_adj,Pairing.map_adj_image] + constructor + · rintro (h|h) + · obtain ⟨a,b,_,ha,_⟩ := (Pairing.map_adj _ _ _ _).mp h + exact (disjoint k hk a i ha).elim + · exact h + · exact Or.inr + +@[simp] lemma pairing_cross_adj (k : ℕ) (hk : k≤n) (p : Pairing n) (t : Pairing m) + (i : Fin n) (j : Fin m) : ¬(pairing k hk p t).Adj (old k hk i) (fresh k hk j) := by + rw [pairing_adj] + rintro (h|h) + · obtain ⟨a,b,_,_,hb⟩ := (Pairing.map_adj _ _ _ _).mp h + exact disjoint k hk b j hb + · obtain ⟨a,b,_,ha,_⟩ := (Pairing.map_adj _ _ _ _).mp h + exact disjoint k hk i a ha.symm + +@[simp] lemma pairing_old_occupied (k : ℕ) (hk : k≤n) (p : Pairing n) (t : Pairing m) + (i : Fin n) : (pairing k hk p t).Occupied (old k hk i) ↔ p.Occupied i := by + constructor + · rintro ⟨j,hj⟩ + obtain ⟨j,rfl⟩|⟨j,rfl⟩ := cover k hk j + · exact ⟨j,(pairing_old_adj k hk p t i j).mp hj⟩ + · exact (pairing_cross_adj k hk p t i j hj).elim + · rintro ⟨j,hj⟩ + exact ⟨old k hk j,(pairing_old_adj k hk p t i j).mpr hj⟩ + +@[simp] lemma pairing_fresh_occupied (k : ℕ) (hk : k≤n) (p : Pairing n) (t : Pairing m) + (i : Fin m) : (pairing k hk p t).Occupied (fresh k hk i) ↔ t.Occupied i := by + constructor + · rintro ⟨j,hj⟩ + obtain ⟨j,rfl⟩|⟨j,rfl⟩ := cover k hk j + · exact (pairing_cross_adj k hk p t j i hj.symm).elim + · exact ⟨j,(pairing_fresh_adj k hk p t i j).mp hj⟩ + · rintro ⟨j,hj⟩ + exact ⟨fresh k hk j,(pairing_fresh_adj k hk p t i j).mpr hj⟩ + + +def unionGraph {V W : Type*} (r : V → V → Prop) (s : W → W → Prop) : + (V ⊕ W) → (V ⊕ W) → Prop + | .inl v,.inl w => r v w + | .inr v,.inr w => s v w + | _,_ => False + +instance {V W : Type*} (r : V → V → Prop) (s : W → W → Prop) [Std.Symm r] [Std.Symm s] : + Std.Symm (unionGraph r s) := ⟨by + rintro (v|v) (w|w) h + · exact (symm h : r w v) + · exact h.elim + · exact h.elim + · exact (symm h : s w v)⟩ + +lemma reach_left {V W : Type*} (r : V → V → Prop) (s : W → W → Prop) + {v : V} {w : V ⊕ W} (h : Relation.ReflTransGen (unionGraph r s) (.inl v) w) : + ∃ u, w=.inl u ∧ Relation.ReflTransGen r v u := by + induction h with + | refl => exact ⟨v,rfl,.refl⟩ + | @tail y z h he ih => + obtain ⟨u,rfl,hu⟩:=ih + cases z with + | inl z => exact ⟨z,rfl,hu.tail he⟩ + | inr z => exact he.elim + +lemma reach_right {V W : Type*} (r : V → V → Prop) (s : W → W → Prop) + {v : W} {w : V ⊕ W} (h : Relation.ReflTransGen (unionGraph r s) (.inr v) w) : + ∃ u, w=.inr u ∧ Relation.ReflTransGen s v u := by + induction h with + | refl => exact ⟨v,rfl,.refl⟩ + | @tail y z h he ih => + obtain ⟨u,rfl,hu⟩:=ih + cases z with + | inl z => exact he.elim + | inr z => exact ⟨z,rfl,hu.tail he⟩ + +def boundary {V W : Type*} (k : ℕ) (hk : k≤n) (a : Fin n → V) (b : Fin m → W) : + Fin (n+m) → (V ⊕ W) := fun i=>Sum.map a b ((equiv k hk).symm i) + +@[simp] lemma boundary_old {V W : Type*} (k : ℕ) (hk : k≤n) + (a : Fin n → V) (b : Fin m → W) (i : Fin n) : + boundary k hk a b (old k hk i)=.inl (a i) := by + change Sum.map a b ((equiv k hk).symm (equiv k hk (.inl i)))=_ + simp only [Equiv.symm_apply_apply,Sum.map_inl] + +@[simp] lemma boundary_fresh {V W : Type*} (k : ℕ) (hk : k≤n) + (a : Fin n → V) (b : Fin m → W) (i : Fin m) : + boundary k hk a b (fresh k hk i)=.inr (b i) := by + change Sum.map a b ((equiv k hk).symm (equiv k hk (.inr i)))=_ + simp only [Equiv.symm_apply_apply,Sum.map_inr] + +lemma boundary_injective {V W : Type*} (k : ℕ) (hk : k≤n) + (a : Fin n → V) (b : Fin m → W) (ha : Function.Injective a) (hb : Function.Injective b) : + Function.Injective (boundary k hk a b) := by + intro i j hij + obtain ⟨i,rfl⟩|⟨i,rfl⟩:=cover k hk i <;> + obtain ⟨j,rfl⟩|⟨j,rfl⟩:=cover k hk j <;> + simp only [boundary_old,boundary_fresh,Sum.inl.injEq,Sum.inr.injEq] at hij + · exact congrArg _ (ha hij) + · cases hij + · cases hij + · exact congrArg _ (hb hij) + +lemma realizes {V W : Type*} (k : ℕ) (hk : k≤n) + {r : V → V → Prop} {s : W → W → Prop} {a : Fin n → V} {b : Fin m → W} + {p : Pairing n} {t : Pairing m} (hp : GraphRealizes r a p) (ht : GraphRealizes s b t) : + GraphRealizes (unionGraph r s) (boundary k hk a b) (pairing k hk p t) := by + constructor + · rintro (v|v) (w|w) h + · obtain ⟨i,hi,hr⟩:=hp.no_loop v w h + refine ⟨old k hk i,(pairing_old_occupied k hk p t i).mpr hi,?_⟩ + rw [boundary_old] + exact Graph.map_reach Sum.inl (fun _ _ h=>.single h) hr + · exact h.elim + · exact h.elim + · obtain ⟨i,hi,hr⟩:=ht.no_loop v w h + refine ⟨fresh k hk i,(pairing_fresh_occupied k hk p t i).mpr hi,?_⟩ + rw [boundary_fresh] + exact Graph.map_reach Sum.inr (fun _ _ h=>.single h) hr + · intro i j + obtain ⟨i,rfl⟩|⟨i,rfl⟩:=cover k hk i <;> + obtain ⟨j,rfl⟩|⟨j,rfl⟩:=cover k hk j <;> + simp only [boundary_old,boundary_fresh] + · rw [pairing_old_adj,(old k hk).injective.eq_iff] + constructor + · intro h + obtain ⟨u,he,hu⟩:=reach_left r s h + cases he + exact (hp.reach i j).mp hu + · intro h + exact Graph.map_reach Sum.inl (fun _ _ h=>.single h) ((hp.reach i j).mpr h) + · simp only [disjoint k hk i j,pairing_cross_adj,false_or,iff_false] + intro h + obtain ⟨u,he,_⟩:=reach_left r s h + cases he + · have hne : fresh k hk i≠old k hk j := (disjoint k hk j i).symm + have hn : ¬(pairing k hk p t).Adj (fresh k hk i) (old k hk j) := + fun h=>pairing_cross_adj k hk p t j i h.symm + simp only [hne,hn,false_or,iff_false] + intro h + obtain ⟨u,he,_⟩:=reach_right r s h + cases he + · rw [pairing_fresh_adj,(fresh k hk).injective.eq_iff] + constructor + · intro h + obtain ⟨u,he,hu⟩:=reach_right r s h + cases he + exact (ht.reach i j).mp hu + · intro h + exact Graph.map_reach Sum.inr (fun _ _ h=>.single h) ((ht.reach i j).mpr h) + +def gauge (k : ℕ) (hk : k≤n) (g : Fin n → ℤ) (h : Fin m → ℤ) : Fin (n+m) → ℤ := + fun i=>Sum.elim g h ((equiv k hk).symm i) + +@[simp] lemma gauge_old (k : ℕ) (hk : k≤n) (g : Fin n → ℤ) (h : Fin m → ℤ) (i : Fin n) : + gauge k hk g h (old k hk i)=g i := by + change Sum.elim g h ((equiv k hk).symm (equiv k hk (.inl i)))=_ + simp only [Equiv.symm_apply_apply,Sum.elim_inl] +@[simp] lemma gauge_fresh (k : ℕ) (hk : k≤n) (g : Fin n → ℤ) (h : Fin m → ℤ) (i : Fin m) : + gauge k hk g h (fresh k hk i)=h i := by + change Sum.elim g h ((equiv k hk).symm (equiv k hk (.inr i)))=_ + simp only [Equiv.symm_apply_apply,Sum.elim_inr] + +lemma potential {V W : Type*} (k : ℕ) (hk : k≤n) + (a : Fin n → V) (b : Fin m → W) (p : Pairing n) (t : Pairing m) + (g : Fin n → ℤ) (h : Fin m → ℤ) (P : V → ℤ) (Q : W → ℤ) + (hP : ∀ i j,p.Adj i j → P (a j)-P (a i)=Pairing.arcTurn g i j) + (hQ : ∀ i j,t.Adj i j → Q (b j)-Q (b i)=Pairing.arcTurn h i j) : + ∀ i j,(pairing k hk p t).Adj i j → + Sum.elim P Q (boundary k hk a b j)-Sum.elim P Q (boundary k hk a b i)= + Pairing.arcTurn (gauge k hk g h) i j := by + intro i j hij + obtain ⟨i,rfl⟩|⟨i,rfl⟩:=cover k hk i <;> + obtain ⟨j,rfl⟩|⟨j,rfl⟩:=cover k hk j + · simp only [pairing_old_adj] at hij + simpa only [boundary_old,Sum.elim_inl,Pairing.arcTurn,gauge_old,Pairing.turnOrder, + (old k hk).lt_iff_lt] using hP i j hij + · exact (pairing_cross_adj k hk p t i j hij).elim + · exact (pairing_cross_adj k hk p t j i hij.symm).elim + · simp only [pairing_fresh_adj] at hij + simpa only [boundary_fresh,Sum.elim_inr,Pairing.arcTurn,gauge_fresh,Pairing.turnOrder, + (fresh k hk).lt_iff_lt] using hQ i j hij + +end BoundaryInsert + + + + + + +namespace GraphRealizes +variable {V : Type*} {n m : ℕ} {r : V → V → Prop} {b : Fin n → V} {p : Pairing n} + +lemma restrict_boundary (hp : GraphRealizes r b p) (f : Fin m ↪o Fin n) + (hf : ∀ i,p.Occupied i → ∃ j,f j=i) : + GraphRealizes r (b ∘ f) (p.restrict f) := by + constructor + · intro v w hvw + obtain ⟨i,hi,hr⟩:=hp.no_loop v w hvw + obtain ⟨j,rfl⟩:=hf i hi + obtain ⟨i,hi⟩:=hi + obtain ⟨k,rfl⟩:=hf i ⟨f j,hi.symm⟩ + exact ⟨j,⟨k,(Pairing.restrict_adj _ _ _ _).mpr hi⟩,hr⟩ + · intro i j + rw [Function.comp_apply,Function.comp_apply,hp.reach,Pairing.restrict_adj,f.injective.eq_iff] + +end GraphRealizes + +namespace BoundaryErase +variable {n : ℕ} + +abbrev keep (k : ℕ) (hk : k≤n) : Fin n ↪o Fin (n+2) := BoundaryInsert.old k hk +abbrev left (k : ℕ) (hk : k≤n) : Fin (n+2) := BoundaryInsert.fresh k hk 0 +abbrev right (k : ℕ) (hk : k≤n) : Fin (n+2) := BoundaryInsert.fresh k hk 1 + +lemma adjacent (k : ℕ) (hk : k≤n) : (left k hk).val+1=(right k hk).val := by + change (k+0)+1=k+1 + omega + +lemma distinct (k : ℕ) (hk : k≤n) : left k hk≠right k hk := by + intro h + have hh:=congrArg Fin.val h + have he:=adjacent k hk + omega + +lemma cover (k : ℕ) (hk : k≤n) (i : Fin (n+2)) : + (∃ j,keep k hk j=i) ∨ i=left k hk ∨ i=right k hk := by + obtain h|⟨j,rfl⟩:=BoundaryInsert.cover (m:=2) k hk i + · exact Or.inl h + · fin_cases j + · exact Or.inr (Or.inl rfl) + · exact Or.inr (Or.inr rfl) + +lemma occupied_cover (k : ℕ) (hk : k≤n) (p : Pairing (n+2)) + (hl : ¬p.Occupied (left k hk)) (hr : ¬p.Occupied (right k hk)) + (i : Fin (n+2)) (hi : p.Occupied i) : ∃ j,keep k hk j=i := by + obtain h|h|h:=cover k hk i + · exact h + · exact (hl (h ▸ hi)).elim + · exact (hr (h ▸ hi)).elim + +lemma restrict_realizes {V : Type*} {r : V → V → Prop} {b : Fin (n+2) → V} + (k : ℕ) (hk : k≤n) (p : Pairing (n+2)) (hp : GraphRealizes r b p) + (hl : ¬p.Occupied (left k hk)) (hr : ¬p.Occupied (right k hk)) : + GraphRealizes r (b ∘ keep k hk) (p.restrict (keep k hk)) := + hp.restrict_boundary (keep k hk) (occupied_cover k hk p hl hr) + +lemma keep_ne_left (k : ℕ) (hk : k≤n) (i : Fin n) : keep k hk i≠left k hk := + BoundaryInsert.disjoint k hk i 0 +lemma keep_ne_right (k : ℕ) (hk : k≤n) (i : Fin n) : keep k hk i≠right k hk := + BoundaryInsert.disjoint k hk i 1 + +lemma potential {V : Type*} (k : ℕ) (hk : k≤n) (b : Fin (n+2) → V) + (p : Pairing (n+2)) (g : Fin (n+2) → ℤ) (P : V → ℤ) + (hP : ∀ i j,p.Adj i j → P (b j)-P (b i)=Pairing.arcTurn g i j) : + ∀ i j,(p.restrict (keep k hk)).Adj i j → + P (b (keep k hk j))-P (b (keep k hk i))=Pairing.arcTurn (g ∘ keep k hk) i j := by + intro i j hij + have h:=hP (keep k hk i) (keep k hk j) ((Pairing.restrict_adj _ _ _ _).mp hij) + simpa only [Pairing.arcTurn,Pairing.turnOrder,(keep k hk).lt_iff_lt,Function.comp_apply] using h + +end BoundaryErase + +namespace BoundarySew +section Wiring +variable {V : Type*} {n : ℕ} {r : V → V → Prop} [Std.Symm r] + {old : Fin (n+2) → V} + + + +def tile (active : Prop) : Tile := if active then .cap else .vacant + +lemma tile_no_outputs (active : Prop) : ¬(tile active).Occupied 2 ∧ ¬(tile active).Occupied 3 := by + by_cases ha : active <;> simp [tile,ha,Tile.Occupied,Tile.Adj,Tile.edges] + +lemma tile_inputs (active : Prop) : ((tile active).Occupied 0 ↔ active) ∧ + ((tile active).Occupied 1 ↔ active) := by + by_cases ha : active <;> simp [tile,ha,Tile.Occupied,Tile.Adj,Tile.edges] + +lemma output_vacant (p q : Pairing (n+2)) (k : ℕ) (hk : k≤n) + (hq : p.tileStep (BoundaryErase.left k hk) (BoundaryErase.right k hk) + (BoundaryErase.adjacent k hk) (tile (p.Occupied (BoundaryErase.left k hk)))=some q) : + ¬q.Occupied (BoundaryErase.left k hk) ∧ ¬q.Occupied (BoundaryErase.right k hk) := by + have hs := p.tileStep_support (BoundaryErase.left k hk) (BoundaryErase.right k hk) + (BoundaryErase.adjacent k hk) (tile (p.Occupied (BoundaryErase.left k hk))) q hq + have ht := tile_no_outputs (p.Occupied (BoundaryErase.left k hk)) + constructor + · rw [hs] + simpa only [Pairing.stepSupport,ite_true] using ht.1 + · rw [hs] + simpa only [Pairing.stepSupport,ite_eq_right (BoundaryErase.distinct k hk).symm,ite_true] using ht.2 + + + +theorem transport (p : Pairing (n+2)) (k : ℕ) (hk : k≤n) + (hp : GraphRealizes r old p) (hinj : Function.Injective old) + (hc : p.Occupied (BoundaryErase.left k hk) ↔ p.Occupied (BoundaryErase.right k hk)) + (g : Fin (n+2) → ℤ) (hg : g (BoundaryErase.right k hk)=g (BoundaryErase.left k hk)-3) + (P : V → ℤ) + (hP : ∀ i j,p.Adj i j → P (old j)-P (old i)=Pairing.arcTurn g i j) + (hd : Graph.DrainsBoundary + (CompactGate.wiring r old p.Occupied (BoundaryErase.left k hk) (BoundaryErase.right k hk) + (tile (p.Occupied (BoundaryErase.left k hk)))) + ((CompactGate.boundary old (BoundaryErase.left k hk) (BoundaryErase.right k hk)) ∘ + BoundaryErase.keep k hk)) : + ∃ (q : Pairing n) (Q : V ⊕ Fin 4 → ℤ), + GraphRealizes + (CompactGate.wiring r old p.Occupied (BoundaryErase.left k hk) (BoundaryErase.right k hk) + (tile (p.Occupied (BoundaryErase.left k hk)))) + ((CompactGate.boundary old (BoundaryErase.left k hk) (BoundaryErase.right k hk)) ∘ + BoundaryErase.keep k hk) q ∧ + (∀ i j,q.Adj i j → + Q (.inl (old (BoundaryErase.keep k hk j)))-Q (.inl (old (BoundaryErase.keep k hk i)))= + Pairing.arcTurn (g ∘ BoundaryErase.keep k hk) i j) ∧ + (∀ v w,r v w → Q (.inl w)-Q (.inl v)=P w-P v) ∧ + Q (.inl (old (BoundaryErase.left k hk)))=Q (.inr 0) ∧ + Q (.inl (old (BoundaryErase.right k hk)))=Q (.inr 1) ∧ + (p.Occupied (BoundaryErase.left k hk) → Q (.inr 1)=Q (.inr 0)) := by + let a:=BoundaryErase.left k hk + let b:=BoundaryErase.right k hk + let t:=tile (p.Occupied a) + have hab : a.val+1=b.val := BoundaryErase.adjacent k hk + have hne : a≠b := BoundaryErase.distinct k hk + have ht : CutPatch.Compatible (p.cutShape a b) t := by + rw [p.cutShape_compatible] + exact ⟨(tile_inputs _).1.symm,hc.symm.trans (tile_inputs _).2.symm⟩ + have hd' : Graph.DrainsBoundary (CompactGate.wiring r old p.Occupied a b t) + (CompactGate.boundary old a b) := by + intro v w hvw + obtain ⟨i,hi⟩:=hd v w hvw + exact ⟨BoundaryErase.keep k hk i,hi⟩ + obtain ⟨q,hq⟩:=graph_gate_step_exists hp a b hab t ht + ((CompactGate.contraction hp hinj a b hne t).drains_inv hd') + have hr : GraphRealizes (CompactGate.wiring r old p.Occupied a b t) + (CompactGate.boundary old a b) q := + (CompactGate.realizes_iff hp hinj a b hne t q).mp ((graph_gate_step_iff hp a b hab t q).mpr hq).2 + obtain ⟨Q,hQ,hOld,hTile,hA,hB⟩:=CompactGate.transport_potential hp a b hab t g g + (fun _ _ _=>rfl) hq P hP + obtain ⟨hqa,hqb⟩:=output_vacant p q k hk hq + refine ⟨q.restrict (BoundaryErase.keep k hk),Q, + BoundaryErase.restrict_realizes k hk q hr hqa hqb,?_,hOld,hA,hB,?_⟩ + · intro i j hij + have hqp : ∀ i j,q.Adj i j → + Q (CompactGate.boundary old a b j)-Q (CompactGate.boundary old a b i)=Pairing.arcTurn g i j := by + intro i j hij + rw [hQ,hQ] + exact Pairing.turnPotential_of_adj g hij + have hh:=BoundaryErase.potential k hk (CompactGate.boundary old a b) q g Q hqp i j hij + simpa only [CompactGate.boundary,a,b,ite_eq_right (BoundaryErase.keep_ne_left k hk i), + ite_eq_right (BoundaryErase.keep_ne_right k hk i),ite_eq_right (BoundaryErase.keep_ne_left k hk j), + ite_eq_right (BoundaryErase.keep_ne_right k hk j)] using hh + · intro ha + have habt : t.Adj 0 1 := by simp [t,a,tile,ha,Tile.Adj,Tile.edges] + have hh:=hTile 0 1 habt + change Q (.inr 1)-Q (.inr 0)=g b-g a+3 at hh + change g b=g a-3 at hg + omega + +end Wiring + + + + + + +variable {V : Type*} {n : ℕ} + + +def graph (r : V → V → Prop) (a b : V) (active : Prop) (v w : V) : Prop := + r v w ∨ active ∧ ((v=a ∧ w=b) ∨ (v=b ∧ w=a)) + +instance (r : V → V → Prop) [Std.Symm r] (a b : V) (active : Prop) : + Std.Symm (graph r a b active) := ⟨by + intro v w h + rcases h with h|⟨h,h'⟩ + · exact Or.inl (symm h) + · exact Or.inr ⟨h,h'.elim (fun h=>Or.inr ⟨h.2,h.1⟩) (fun h=>Or.inl ⟨h.2,h.1⟩)⟩⟩ + +def project (a b : V) : V ⊕ Fin 4 → V + | .inl v => v + | .inr i => if i=1 then b else a + +variable {r : V → V → Prop} [Std.Symm r] {old : Fin (n+2) → V} {p : Pairing (n+2)} + +omit [Std.Symm r] in +lemma project_edge (a b : Fin (n+2)) (_hc : p.Occupied a ↔ p.Occupied b) + {v w : V ⊕ Fin 4} + (h : CompactGate.wiring r old p.Occupied a b (tile (p.Occupied a)) v w) : + Relation.ReflTransGen (graph r (old a) (old b) (p.Occupied a)) + (project (old a) (old b) v) (project (old a) (old b) w) := by + cases v with + | inl v => + cases w with + | inl w => exact .single (Or.inl h) + | inr j => + rcases h with ⟨rfl,rfl,_⟩|⟨rfl,rfl,_⟩ <;> simp only [project] <;> exact .refl + | inr i => + cases w with + | inl w => + rcases h with ⟨rfl,rfl,_⟩|⟨rfl,rfl,_⟩ <;> simp only [project] <;> exact .refl + | inr j => + change (tile (p.Occupied a)).Adj i j at h + by_cases ha : p.Occupied a + · have hh : (i=0 ∧ j=1) ∨ (i=1 ∧ j=0) := by + simpa only [tile,ite_eq_left ha,Tile.Adj,Tile.edges,Finset.mem_singleton,Prod.mk.injEq,and_comm] using h + rcases hh with ⟨rfl,rfl⟩|⟨rfl,rfl⟩ + · exact .single (Or.inr ⟨ha,Or.inl ⟨rfl,rfl⟩⟩) + · exact .single (Or.inr ⟨ha,Or.inr ⟨rfl,rfl⟩⟩) + · simp only [tile,ite_eq_right ha,Tile.vacant_not_adj] at h + +lemma include_edge (a b : Fin (n+2)) (hc : p.Occupied a ↔ p.Occupied b) + {v w : V} (h : graph r (old a) (old b) (p.Occupied a) v w) : + Relation.ReflTransGen (CompactGate.wiring r old p.Occupied a b (tile (p.Occupied a))) + (.inl v) (.inl w) := by + have forward (ha : p.Occupied a) : + Relation.ReflTransGen (CompactGate.wiring r old p.Occupied a b (tile (p.Occupied a))) + (.inl (old a)) (.inl (old b)) := by + have h₁ : CompactGate.wiring r old p.Occupied a b (tile (p.Occupied a)) + (.inl (old a)) (.inr 0) := Or.inl ⟨rfl,rfl,ha⟩ + have h₂ : CompactGate.wiring r old p.Occupied a b (tile (p.Occupied a)) + (.inr 0) (.inr 1) := by simp [CompactGate.wiring,tile,ha,Tile.Adj,Tile.edges] + have h₃ : CompactGate.wiring r old p.Occupied a b (tile (p.Occupied a)) + (.inr 1) (.inl (old b)) := Or.inr ⟨rfl,rfl,hc.mp ha⟩ + exact ((Relation.ReflTransGen.single h₁).tail h₂).tail h₃ + rcases h with h|⟨ha,h⟩ + · exact .single h + · rcases h with ⟨rfl,rfl⟩|⟨rfl,rfl⟩ + · exact forward ha + · exact symm (forward ha) + +omit [Std.Symm r] in +lemma used_port (a b : Fin (n+2)) (hc : p.Occupied a ↔ p.Occupied b) {i : Fin 4} + (hi : Graph.Used (CompactGate.wiring r old p.Occupied a b (tile (p.Occupied a))) (.inr i)) : + p.Occupied a ∧ (i=0 ∨ i=1) := by + obtain ⟨w,hw⟩:=hi + cases w with + | inl w => + rcases hw with ⟨rfl,rfl,ha⟩|⟨rfl,rfl,hb⟩ + · exact ⟨ha,Or.inl rfl⟩ + · exact ⟨hc.mpr hb,Or.inr rfl⟩ + | inr j => + by_cases ha : p.Occupied a + · have hh : (i=0 ∧ j=1) ∨ (i=1 ∧ j=0) := by + simpa only [CompactGate.wiring,tile,ite_eq_left ha,Tile.Adj,Tile.edges, + Finset.mem_singleton,Prod.mk.injEq,and_comm] using hw + exact ⟨ha,hh.elim (fun h=>Or.inl h.1) (fun h=>Or.inr h.1)⟩ + · simp only [CompactGate.wiring,tile,ite_eq_right ha,Tile.vacant_not_adj] at hw + +def equivalence (k : ℕ) (hk : k≤n) (hp : GraphRealizes r old p) + (hinj : Function.Injective old) + (hc : p.Occupied (BoundaryErase.left k hk) ↔ p.Occupied (BoundaryErase.right k hk)) : + Graph.BoundaryEquiv + (CompactGate.wiring r old p.Occupied (BoundaryErase.left k hk) (BoundaryErase.right k hk) + (tile (p.Occupied (BoundaryErase.left k hk)))) + (graph r (old (BoundaryErase.left k hk)) (old (BoundaryErase.right k hk)) + (p.Occupied (BoundaryErase.left k hk))) + (CompactGate.boundary old (BoundaryErase.left k hk) (BoundaryErase.right k hk) ∘ + BoundaryErase.keep k hk) (old ∘ BoundaryErase.keep k hk) := by + let a:=BoundaryErase.left k hk + let b:=BoundaryErase.right k hk + have hup (i : Fin (n+2)) (hi : p.Occupied i) : Graph.Used r (old i) := + (hp.boundary_used_iff hinj i).mpr hi + refine ⟨project (old a) (old b),Sum.inl, + fun _ _=>project_edge a b hc,fun _ _=>include_edge a b hc,?_,?_,?_,?_,?_,?_⟩ + · intro i + simp only [Function.comp_apply,CompactGate.boundary, + ite_eq_right (BoundaryErase.keep_ne_left k hk i),ite_eq_right (BoundaryErase.keep_ne_right k hk i),project] + · intro i + simp only [Function.comp_apply,CompactGate.boundary, + ite_eq_right (BoundaryErase.keep_ne_left k hk i),ite_eq_right (BoundaryErase.keep_ne_right k hk i)] + · rintro (v|i) hv + · obtain ⟨w,hw⟩:=hv + cases w with + | inl w => exact ⟨w,Or.inl hw⟩ + | inr j => + rcases hw with ⟨rfl,rfl,ha⟩|⟨rfl,rfl,hb⟩ + · obtain ⟨w,hw⟩:=hup a ha; exact ⟨w,Or.inl hw⟩ + · obtain ⟨w,hw⟩:=hup b hb; exact ⟨w,Or.inl hw⟩ + · obtain ⟨ha,hi⟩:=used_port a b hc hv + rcases hi with rfl|rfl + · obtain ⟨w,hw⟩:=hup a ha; exact ⟨w,Or.inl hw⟩ + · obtain ⟨w,hw⟩:=hup b (hc.mp ha); exact ⟨w,Or.inl hw⟩ + · rintro v ⟨w,hw⟩ + rcases hw with hw|⟨ha,hw⟩ + · exact ⟨.inl w,hw⟩ + · rcases hw with ⟨rfl,rfl⟩|⟨rfl,rfl⟩ + · exact ⟨.inr 0,Or.inl ⟨rfl,rfl,ha⟩⟩ + · exact ⟨.inr 1,Or.inr ⟨rfl,rfl,hc.mp ha⟩⟩ + · rintro (v|i) hv + · exact .refl + · obtain ⟨ha,hi⟩:=used_port a b hc hv + rcases hi with rfl|rfl + · exact .single (Or.inl ⟨rfl,rfl,ha⟩) + · exact .single (Or.inr ⟨rfl,rfl,hc.mp ha⟩) + · exact fun _ _=>.refl + + +theorem transport_direct (p : Pairing (n+2)) (k : ℕ) (hk : k≤n) + (hp : GraphRealizes r old p) (hinj : Function.Injective old) + (hc : p.Occupied (BoundaryErase.left k hk) ↔ p.Occupied (BoundaryErase.right k hk)) + (g : Fin (n+2) → ℤ) (hg : g (BoundaryErase.right k hk)=g (BoundaryErase.left k hk)-3) + (P : V → ℤ) + (hP : ∀ i j,p.Adj i j → P (old j)-P (old i)=Pairing.arcTurn g i j) + (hd : Graph.DrainsBoundary + (graph r (old (BoundaryErase.left k hk)) (old (BoundaryErase.right k hk)) + (p.Occupied (BoundaryErase.left k hk))) (old ∘ BoundaryErase.keep k hk)) : + ∃ (q : Pairing n) (Q : V → ℤ), + GraphRealizes + (graph r (old (BoundaryErase.left k hk)) (old (BoundaryErase.right k hk)) + (p.Occupied (BoundaryErase.left k hk))) (old ∘ BoundaryErase.keep k hk) q ∧ + (∀ i j,q.Adj i j → Q (old (BoundaryErase.keep k hk j))-Q (old (BoundaryErase.keep k hk i))= + Pairing.arcTurn (g ∘ BoundaryErase.keep k hk) i j) ∧ + (∀ v w,r v w → Q w-Q v=P w-P v) ∧ + (p.Occupied (BoundaryErase.left k hk) → Q (old (BoundaryErase.right k hk))=Q (old (BoundaryErase.left k hk))) := by + let e:=equivalence k hk hp hinj hc + obtain ⟨q,Q,hq,hArc,hOld,ha,hb,hab⟩:=transport p k hk hp hinj hc g hg P hP (e.symm.drains hd) + refine ⟨q,Q ∘ Sum.inl,e.realizes hq,hArc,hOld,?_⟩ + intro hi + change Q (.inl (old (BoundaryErase.right k hk)))=Q (.inl (old (BoundaryErase.left k hk))) + rw [ha,hb,hab hi] + +end BoundarySew +end +end CriticalStrip.Diagram + +end OAI diff --git a/lean/OAI/Combinatorics/StripMass/TurnEvolution.lean b/lean/OAI/Combinatorics/StripMass/TurnEvolution.lean new file mode 100644 index 0000000000000000000000000000000000000000..62cf17c0593e9569bc0d33ec235dd8d02fcee1cf --- /dev/null +++ b/lean/OAI/Combinatorics/StripMass/TurnEvolution.lean @@ -0,0 +1,529 @@ +import Mathlib +import OAI.Combinatorics.StripMass.TurnRhombus + +namespace OAI + +/-! Critical honeycomb strip paths, polynomial identities and crossing mass. -/ + + +namespace CriticalStrip.Diagram +noncomputable section +open scoped Classical + +namespace TurnNetwork +open TurnDisk + + +def lift {n s t : ℕ} (h : s ≤ t) : Node n s → Node n t + | .inl i => .inl i + | .inr (i,v) => .inr (i.castLE h,v) + +lemma lift_refl {n t : ℕ} (v : Node n t) : lift (le_refl t) v=v := by + rcases v with i|⟨i,v⟩ <;> rfl +lemma lift_trans {n r s t : ℕ} (hrs : r ≤ s) (hst : s ≤ t) (v : Node n r) : + lift hst (lift hrs v)=lift (hrs.trans hst) v := by + rcases v with i|⟨i,v⟩ <;> rfl +lemma lift_old {n s t : ℕ} (h : s ≤ t) (v : Node n s) : + old (lift h v)=lift (h.trans (Nat.le_succ t)) v := by + rcases v with i|⟨i,v⟩ <;> rfl +lemma old_eq_lift {n t : ℕ} (v : Node n t) : old v=lift (Nat.le_succ t) v := by + rcases v with i|⟨i,v⟩ <;> rfl +lemma lift_injective {n s t : ℕ} (h : s ≤ t) : Function.Injective (lift (n:=n) h) := by + rintro (i|⟨i,v⟩) (j|⟨j,w⟩) he <;> simp only [lift,Sum.inl.injEq,Sum.inr.injEq,Prod.mk.injEq] at he + · exact congrArg Sum.inl he + · cases he + · cases he + · obtain ⟨he,rfl⟩:=he + have hj : i=j := Fin.ext (congrArg (fun i : Fin t=>i.val) he) + subst j + rfl + +variable {n : ℕ} (p₀ : Pairing n) (g₀ : Fin n → ℤ) + (p q : ℕ → Pairing 6) (k : ℕ → ℕ) (hk : ∀ t,k t+4 ≤ n) + +lemma lift_edge {s t : ℕ} (hst : s ≤ t) {v w : Node n s} + (h : graph p₀ g₀ p q k hk s v w) : + graph p₀ g₀ p q k hk t (lift hst v) (lift hst w) := by + induction t,hst using Nat.le_induction with + | base => simpa only [lift_refl] using h + | succ t hst ih => simpa only [lift_old] using old_edge p₀ g₀ p q k hk t ih + +lemma lift_turn {s t : ℕ} (hst : s ≤ t) {v w : Node n s} + (h : graph p₀ g₀ p q k hk s v w) : + edgeTurn p₀ g₀ p q k hk t (lift hst v) (lift hst w)= + edgeTurn p₀ g₀ p q k hk s v w := by + induction t,hst using Nat.le_induction with + | base => simp only [lift_refl] + | succ t hst ih => + simpa only [lift_old] using (old_turn p₀ g₀ p q k hk t (lift_edge p₀ g₀ p q k hk hst h)).trans ih + +lemma boundary_untouched {s t : ℕ} (hst : s ≤ t) (i : Fin n) + (hi : ∀ u,s ≤ u → u exact (lift_refl _).symm + | succ t hst ih => + rw [boundary_outside p₀ g₀ p q k hk t i (hi t hst (by omega)), + ih (fun u hu hut=>hi u hu (by omega)),lift_old] + +lemma boundary_last {s t : ℕ} (hst : s rfl + | succ t hst ih => + change ((disk p₀ g₀ p q k hk t).gate4 _ _ _).gauge i=_ + rw [Gate4.gauge_outside _ _ _ _ i (hi t hst (by omega))] + exact ih (fun u hu hut=>hi u hu (by omega)) + +lemma gauge_slot (t : ℕ) (i : Fin 4) : + (disk p₀ g₀ p q k hk (t+1)).gauge (Gate4.slot (k t) (hk t) i)= + if i.val<2 then -2 else 0 := by + change ((disk p₀ g₀ p q k hk t).gate4 _ _ _).gauge _=_ + rw [Gate4.gauge_slot,Rhombus.gauge_output] + + +def namedGauge (t : ℕ) : Node n t → ℤ + | .inl i=>g₀ i + | .inr (_, .inl i)=>Rhombus.upGauge i + | .inr (_, .inr i)=>Rhombus.downGauge i + +lemma namedGauge_old (t : ℕ) (v : Node n t) : namedGauge g₀ (t+1) (old v)=namedGauge g₀ t v := by + rcases v with i|⟨i,(v|v)⟩ <;> rfl +lemma namedGauge_lift {s t : ℕ} (hst : s ≤ t) (v : Node n s) : + namedGauge g₀ t (lift hst v)=namedGauge g₀ s v := by + rcases v with i|⟨i,(v|v)⟩ <;> rfl +lemma namedGauge_vertex (t : ℕ) (v : Node n t) : + (disk p₀ g₀ p q k hk t).vertexGauge ((names p₀ g₀ p q k hk t).symm v)=namedGauge g₀ t v := by + induction t with + | zero => rcases v with i|⟨i,v⟩; rfl; exact Fin.elim0 i + | succ t ih => + obtain ⟨v,rfl⟩|⟨v,rfl⟩:=cover v + · rw [inv_old,namedGauge_old] + exact ih v + · rw [inv_fresh] + cases v <;> rfl +lemma namedGauge_boundary (t : ℕ) (i : Fin n) : + namedGauge g₀ t (boundary p₀ g₀ p q k hk t i)=(disk p₀ g₀ p q k hk t).gauge i := by + rw [←namedGauge_vertex p₀ g₀ p q k hk] + simp only [boundary,Equiv.symm_apply_apply,vertexGauge_boundary] + + +def Matches (t : ℕ) : Prop := + (∀ u,uh.1 u (hu.trans_le hst),fun u hu=>h.2 u (hu.trans_le hst)⟩ + +lemma occupied_iff_used (t : ℕ) (hm : Matches p₀ g₀ p q k hk t) (v : Node n t) : + Graph.Used (graph p₀ g₀ p q k hk t) v ↔ Occupied p₀ p q t v := by + induction t with + | zero => + rcases v with i|⟨i,v⟩ + · rw [used_equiv] + rfl + · exact Fin.elim0 i + | succ t ih => + have hm' : ∀ i : Fin 4,Graph.Used (disk p₀ g₀ p q k hk t).wiring + ((disk p₀ g₀ p q k hk t).boundary (Gate4.slot (k t) (hk t) i)) ↔ + Graph.Used (Rhombus.disk (p t) (q t)).wiring + ((Rhombus.disk (p t) (q t)).boundary (Gate4.input i)) := by + intro i + have hu := (used_equiv p₀ g₀ p q k hk t + (boundary p₀ g₀ p q k hk t (Gate4.slot (k t) (hk t) i))) + simp only [boundary,Equiv.symm_apply_apply] at hu + erw [←hu,ih (Matches.mono _ _ _ _ _ _ hm (by omega)),hm.2 t (by omega),Rhombus.input_boundary, + Rhombus.used _ _ (hm.1 t (by omega))] + exact (BoundaryInsert.used_left (p t).Adj (q t).Adj _).symm + obtain ⟨w,rfl⟩|⟨w,rfl⟩:=cover v + · rw [occupied_old,used_equiv,inv_old] + change Graph.Used ((disk p₀ g₀ p q k hk t).gate4 _ _ _).wiring _ ↔ _ + erw [Gate4.used _ _ _ _ hm',BoundaryInsert.used_left,←used_equiv] + exact ih (Matches.mono _ _ _ _ _ _ hm (by omega)) w + · rw [occupied_fresh,used_equiv,inv_fresh] + change Graph.Used ((disk p₀ g₀ p q k hk t).gate4 _ _ _).wiring _ ↔ _ + erw [Gate4.used _ _ _ _ hm',BoundaryInsert.used_right,Rhombus.used _ _ (hm.1 t (by omega))] + cases w with + | inl i => exact BoundaryInsert.used_left _ _ _ + | inr i => exact BoundaryInsert.used_right _ _ _ + +lemma gate_matches (t : ℕ) (hm : Matches p₀ g₀ p q k hk (t+1)) : + ∀ i : Fin 4,Graph.Used (disk p₀ g₀ p q k hk t).wiring + ((disk p₀ g₀ p q k hk t).boundary (Gate4.slot (k t) (hk t) i)) ↔ + Graph.Used (Rhombus.disk (p t) (q t)).wiring + ((Rhombus.disk (p t) (q t)).boundary (Gate4.input i)) := by + intro i + have hu := (used_equiv p₀ g₀ p q k hk t + (boundary p₀ g₀ p q k hk t (Gate4.slot (k t) (hk t) i))) + simp only [boundary,Equiv.symm_apply_apply] at hu + erw [←hu,occupied_iff_used _ _ _ _ _ _ _ (Matches.mono _ _ _ _ _ _ hm (by omega)),hm.2 t (by omega), + Rhombus.input_boundary,Rhombus.used _ _ (hm.1 t (by omega))] + exact (BoundaryInsert.used_left (p t).Adj (q t).Adj _).symm + +lemma compatible (t : ℕ) (hm : Matches p₀ g₀ p q k hk t) + (hg : ∀ u,u trivial + | succ t ih => + apply Gate4.compatible _ _ _ _ (gate_matches p₀ g₀ p q k hk t hm) + (ih (Matches.mono _ _ _ _ _ _ hm (by omega)) (fun u hu=>hg u (by omega))) + (Rhombus.compatible _ _ (hm.1 t (by omega))) + intro i + rw [Rhombus.gauge_input,hg t (by omega)] + split_ifs <;> rfl + +lemma wire_edge (t : ℕ) (hm : Matches p₀ g₀ p q k hk (t+1)) (i : Fin 4) + (hi : (p t).Occupied ⟨3-i.val,by omega⟩) : + graph p₀ g₀ p q k hk (t+1) + (old (boundary p₀ g₀ p q k hk t (Gate4.slot (k t) (hk t) i))) + (fresh (.inl ⟨3-i.val,by omega⟩)) := by + unfold graph + rw [inv_old,inv_fresh] + simp only [boundary,Equiv.symm_apply_apply] + apply (Gate4.wiring _ _ _ _ (gate_matches p₀ g₀ p q k hk t hm) _ _).mpr + right + refine ⟨i,?_,Or.inl ⟨rfl,?_⟩⟩ + · erw [Rhombus.input_boundary,Rhombus.used _ _ (hm.1 t (by omega)),BoundaryInsert.used_left] + exact hi + · rw [Rhombus.input_boundary] + rfl + +end TurnNetwork + + + + + +namespace TurnRectangle +open TurnDisk TurnNetwork +section BoundaryEvolution + +def width (M N : ℕ) : ℕ := 2*(M+N) +def ports (M N : ℕ) : ℕ := 2*width M N + + +def position (M N t : ℕ) : ℕ := width M N+2*(M-1-t/N+t%N) + +lemma position_bound {M N : ℕ} (hM : 1 ≤ M) (hN : 1 ≤ N) (t : ℕ) : + position M N t+4 ≤ ports M N := by + have hs : M-1-t/N ≤ M-1 := Nat.sub_le _ _ + have h:=Nat.mod_lt t (by omega : 0Or.inl (south_initial_untouched hM hN hc hu l)) + exact hh + +lemma west_initial {r : ℕ} (hr : rOr.inr (west_initial_untouched hM hN hr hu l)) + +lemma south_previous {c r : ℕ} (hc : cwest_previous_untouched hM hN hc hc0 hr hu₁ hu₂ l),he,boundary_slot] + rfl + +end BoundaryEvolution + + + + + + +variable {M N : ℕ} (hM : 1 ≤ M) (hN : 1 ≤ N) + (p₀ : Pairing (ports M N)) (g₀ : Fin (ports M N) → ℤ) (p q : ℕ → Pairing 6) + +lemma retained_boundary (t : ℕ) (i : Fin (ports M N)) (hi : i.valOr.inl (east_untouched hM hN hr hu₁ hu₂ l)) + +lemma north_boundary {c : ℕ} (hc : cOr.inr (north_untouched hM hN hc hu₁ hu₂ l)) + refine hh.trans ?_ + apply congrArg Sum.inr + apply congrArg (fun j : Fin 6 => ((⟨c*N+(N-1),time_lt (by omega) hc⟩:Fin (M*N)),Sum.inr j)) + apply Fin.ext + change 2+(2+l.val)=4+l.val + omega + + + +def starterGauge (M N : ℕ) (i : Fin (ports M N)) : ℤ := + if i.val<2*N then -5 else if i.val omega +lemma starterGauge_west {r : ℕ} (hr : r omega + +include p₀ p q +lemma south_gauge {c r : ℕ} (hc : c norm_num [Rhombus.downGauge] +lemma west_gauge {c r : ℕ} (hc : cOr.inr (west_initial_untouched hM hN hr hu l)) + simp only [box, Nat.zero_mul, Nat.zero_add] + exact hh.trans (starterGauge_west hM hN hr l) + · change (disk p₀ (starterGauge M N) p q (position M N) (position_bound hM hN) _).gauge _=_ + rw [← namedGauge_boundary] + change namedGauge (starterGauge M N) _ (bdry hM hN p₀ (starterGauge M N) p q _ _)=_ + have hh := congrArg (namedGauge (starterGauge M N) (c*N+r)) + (west_previous hM hN p₀ (starterGauge M N) p q hc (by omega) hr l) + refine hh.trans ?_ + change Rhombus.downGauge ⟨2+l.val,_⟩= -2 + fin_cases l <;> norm_num [Rhombus.downGauge] +lemma input_gauge {c r : ℕ} (hc : c fin_cases j <;> simp [gateTurn] <;> ring + +lemma cap_arcTurn_general {n : ℕ} {p : Pairing n} {a b x y : Fin n} + (g : Fin n → ℤ) (hab : a.val+1=b.val) + (hx : p.Adj a x) (hy : p.Adj b y) (hn : ¬p.Adj a b) : + arcTurn g x a+(g b-g a+3)+arcTurn g b y=arcTurn g x y := by + have hc:=cap_turn_order hab hx hy hn + simp only [arcTurn] + omega + +lemma arcTurn_congr {n : ℕ} {g h : Fin n → ℤ} {i j : Fin n} + (hi : g i=h i) (hj : g j=h j) : arcTurn g i j=arcTurn h i j := by + simp only [arcTurn,hi,hj] + +lemma turnOrder_embedding {n m : ℕ} (f : Fin n → Fin m) {i j : Fin n} + (hij : f i < f j ↔ i < j) (hji : f j < f i ↔ j < i) : + turnOrder (f i) (f j)=turnOrder i j := by simp only [turnOrder,hij,hji] + + +structure GatePotentials {n : ℕ} (p q : Pairing n) (a b : Fin n) (t : Tile) + (g h : Fin n → ℤ) (B : Fin n → ℤ) (T : Fin 4 → ℤ) : Prop where + old_arc : ∀ i j,p.Adj i j → B j-B i=arcTurn g i j + tile_arc : ∀ i j,t.Adj i j → + T j-T i=gateTurn (g a) (g b) (h a) (h b) i j + input_left : B a=T 0 + input_right : B b=T 1 + output_left : T 2=q.turnPotential h a + output_right : T 3=q.turnPotential h b + outside : ∀ i,i≠a → i≠b → B i=q.turnPotential h i + + +def gateBoundary {n : ℕ} (a b : Fin n) (F : Fin n → ℤ) (x y : ℤ) : Fin n → ℤ := + fun i=>if i=a then x else if i=b then y else F i + +@[simp] lemma gateBoundary_left {n : ℕ} (a b : Fin n) (F : Fin n → ℤ) (x y : ℤ) : + gateBoundary a b F x y a=x := by simp [gateBoundary] +@[simp] lemma gateBoundary_right {n : ℕ} (a b : Fin n) (hab : a≠b) + (F : Fin n → ℤ) (x y : ℤ) : gateBoundary a b F x y b=y := by + simp [gateBoundary,hab.symm] +lemma gateBoundary_other {n : ℕ} (a b : Fin n) (F : Fin n → ℤ) (x y : ℤ) + (i : Fin n) (ha : i≠a) (hb : i≠b) : gateBoundary a b F x y i=F i := by + simp [gateBoundary,ha,hb] + +lemma gatePotentials_vacant {n : ℕ} (p : Pairing n) (a b : Fin n) + (_hab : a.val+1=b.val) (g h : Fin n → ℤ) + (hg : ∀ i,i≠a → i≠b → h i=g i) + (ha : ¬p.Occupied a) (hb : ¬p.Occupied b) : + ∃ B T,GatePotentials p p a b .vacant g h B T := by + refine ⟨p.turnPotential h,![p.turnPotential h a,p.turnPotential h b, + p.turnPotential h a,p.turnPotential h b],?_,?_,?_,?_,?_,?_,?_⟩ + · intro i j hij + rw [turnPotential_of_adj h hij] + apply arcTurn_congr + · exact hg i (fun he=>ha (he ▸ ⟨j,hij⟩)) (fun he=>hb (he ▸ ⟨j,hij⟩)) + · exact hg j (fun he=>ha (he ▸ ⟨i,hij.symm⟩)) (fun he=>hb (he ▸ ⟨i,hij.symm⟩)) + · intro i j hij + exact (Tile.vacant_not_occupied i ⟨j,hij⟩).elim + all_goals simp + +lemma gatePotentials_through {n : ℕ} (p : Pairing n) (a b : Fin n) + (hab : a.val+1=b.val) (g h : Fin n → ℤ) + (hg : ∀ i,i≠a → i≠b → h i=g i) (t : Tile) + (ht : t=.vertical₀ ∨ t=.vertical₁ ∨ t=.verticalPair) + (hc : (t.Occupied 0 ↔ p.Occupied a) ∧ (t.Occupied 1 ↔ p.Occupied b)) : + ∃ B T,GatePotentials p p a b t g h B T := by + let F := p.turnPotential h + let x := F a-(h a-g a) + let y := F b-(h b-g b) + let B := gateBoundary a b F x y + have hab' : a≠b := by omega + have he (i : Fin n) : B i=p.turnPotential g i := by + by_cases hia : i=a + · subst i; simp only [B,gateBoundary_left,x,F,turnPotential]; omega + · by_cases hib : i=b + · subst i; simp only [B,gateBoundary_right _ _ hab',y,F,turnPotential]; omega + · simp only [B,gateBoundary_other _ _ _ _ _ _ hia hib,F,turnPotential,hg i hia hib] + refine ⟨B,![x,y,F a,F b],⟨?_,?_,?_,?_,?_,?_,?_⟩⟩ + · intro i j hij + rw [he i,he j] + exact turnPotential_of_adj g hij + · intro i j hij + rcases ht with rfl|rfl|rfl <;> fin_cases i <;> fin_cases j <;> + simp_all [Tile.Adj,Tile.edges,gateTurn,x,y] + · simp [B] + · simp [B,gateBoundary,hab'.symm] + · rfl + · rfl + · exact fun i hi hj=>gateBoundary_other a b F x y i hi hj + +lemma gatePotentials_cup {n : ℕ} (p : Pairing n) (a b : Fin n) + (hab : a.val+1=b.val) (g h : Fin n → ℤ) + (hg : ∀ i,i≠a → i≠b → h i=g i) + (ha : ¬p.Occupied a) (hb : ¬p.Occupied b) : + ∃ B T,GatePotentials p (p.insertCup a b hab ha hb) a b .cup g h B T := by + let q := p.insertCup a b hab ha hb + let F := q.turnPotential h + have hab' : aha (he ▸ ⟨j,hij⟩)) (fun he=>hb (he ▸ ⟨j,hij⟩)) + · exact hg j (fun he=>ha (he ▸ ⟨i,hij.symm⟩)) (fun he=>hb (he ▸ ⟨i,hij.symm⟩)) + · intro i j hij + fin_cases i <;> fin_cases j <;> simp_all [Tile.Adj,Tile.edges,gateTurn] + omega + all_goals simp [F,q] + +lemma gatePotentials_swap {n : ℕ} (p : Pairing n) (a b : Fin n) + (_hab : a.val+1=b.val) (g h : Fin n → ℤ) + (hg : ∀ i,i≠a → i≠b → h i=g i) (t : Tile) + (ht : t=.diagonal₀ ∨ t=.diagonal₁) + (hf : ∀ i j,p.Occupied i → p.Occupied j → + (Equiv.swap a b i < Equiv.swap a b j ↔ iF (f i)+g i-h (f i) + have hBa : B a=F b+g a-h b := by simp [B,f] + have hBb : B b=F a+g b-h a := by simp [B,f] + refine ⟨B,![B a,B b,F a,F b],⟨?_,?_,?_,?_,?_,?_,?_⟩⟩ + · intro i j hij + have hi : p.Occupied i := ⟨j,hij⟩ + have hj : p.Occupied j := ⟨i,hij.symm⟩ + have hq : q.Adj (f i) (f j) := + (mapOccupied_adj p (Equiv.swap a b).toEmbedding hf i j).mpr hij + have hF : F (f j)-F (f i)=arcTurn h (f i) (f j) := turnPotential_of_adj h hq + have ho : turnOrder (f i) (f j)=turnOrder i j := + turnOrder_embedding f (hf i j hi hj) (hf j i hj hi) + dsimp only [B] + simp only [arcTurn,ho] at hF ⊢ + omega + · intro i j hij + rcases ht with rfl|rfl <;> fin_cases i <;> fin_cases j <;> + simp_all [Tile.Adj,Tile.edges,gateTurn] <;> omega + · rfl + · rfl + · rfl + · rfl + · intro i hi hj + simp [B,f,Equiv.swap_apply_of_ne_of_ne hi hj,hg i hi hj,F,q] + +lemma gatePotentials_cap_general {n : ℕ} (p q : Pairing n) (a b : Fin n) + (hab : a.val+1=b.val) (g h : Fin n → ℤ) + (hg : ∀ i,i≠a → i≠b → h i=g i) (x y : Fin n) + (hx : p.Adj a x) (hy : p.Adj b y) (hn : ¬p.Adj a b) + (hqxy : q.Adj x y) + (hout : ∀ i j,(p.omitTwo a b).Adj i j → q.Adj i j) + (t : Tile) (ht : t=.cap ∨ t=.capCup) + (hcup : t=.capCup → q.Adj a b) : + ∃ B T,GatePotentials p q a b t g h B T := by + let F := q.turnPotential h + let u := F x+arcTurn g x a + let v := u+(g b-g a+3) + let B := gateBoundary a b F u v + have hab' : a≠b := by omega + obtain ⟨hxa,hxb,hya,hyb,hxy⟩ := adjacent_partners hab hx hy hn + have hFxy : F y-F x=arcTurn g x y := + (turnPotential_of_adj h hqxy).trans (arcTurn_congr (hg x hxa hxb) (hg y hya hyb)) + have hcap := cap_arcTurn_general g hab hx hy hn + have hBa : B a=u := gateBoundary_left _ _ _ _ _ + have hBb : B b=v := gateBoundary_right _ _ hab' _ _ _ + have hBx : B x=F x := gateBoundary_other _ _ _ _ _ _ hxa hxb + have hBy : B y=F y := gateBoundary_other _ _ _ _ _ _ hya hyb + have hax : F x-u=arcTurn g a x := by rw [arcTurn_reverse g x a]; dsimp [u]; omega + have hby : F y-v=arcTurn g b y := by dsimp [v,u]; omega + refine ⟨B,![u,v,F a,F b],⟨?_,?_,?_,?_,?_,?_,?_⟩⟩ + · intro i j hij + by_cases hia : i=a + · subst i + have hj : j=x := adj_unique hij hx + subst j + rw [hBa,hBx] + exact hax + · by_cases hja : j=a + · subst j + have hi : i=x := adj_unique hij.symm hx + subst i + rw [hBa,hBx,arcTurn_reverse g a x] + omega + · by_cases hib : i=b + · subst i + have hj : j=y := adj_unique hij hy + subst j + rw [hBb,hBy] + exact hby + · by_cases hjb : j=b + · subst j + have hi : i=y := adj_unique hij.symm hy + subst i + rw [hBb,hBy,arcTurn_reverse g b y] + omega + · rw [show B i=F i from gateBoundary_other _ _ _ _ _ _ hia hib, + show B j=F j from gateBoundary_other _ _ _ _ _ _ hja hjb] + exact (turnPotential_of_adj h (hout i j ((omitTwo_adj _ _ _ _ _).mpr + ⟨hij,hia,hib,hja,hjb⟩))).trans + (arcTurn_congr (hg i hia hib) (hg j hja hjb)) + · intro i j hij + have hablt : a fin_cases i <;> fin_cases j <;> + simp_all [Tile.Adj,Tile.edges,gateTurn,v] <;> omega + · exact hBa + · exact hBb + · rfl + · rfl + · exact fun i hi hj=>gateBoundary_other _ _ _ _ _ _ hi hj + + + +theorem gatePotentials_of_step {n : ℕ} (p q : Pairing n) (a b : Fin n) + (hab : a.val+1=b.val) (g h : Fin n → ℤ) + (hg : ∀ i,i≠a → i≠b → h i=g i) (t : Tile) + (hq : p.tileStep a b hab t=some q) : + ∃ B T,GatePotentials p q a b t g h B T := by + cases t with + | vacant => + simp only [tileStep] at hq + split_ifs at hq with hc + · cases hq + exact gatePotentials_vacant p a b hab g h hg hc.1 hc.2 + | vertical₀ => + simp only [tileStep] at hq + split_ifs at hq with hc + · cases hq + exact gatePotentials_through p a b hab g h hg .vertical₀ (Or.inl rfl) + (by simp [hc.1,hc.2,Tile.Occupied,Tile.Adj,Tile.edges]) + | vertical₁ => + simp only [tileStep] at hq + split_ifs at hq with hc + · cases hq + exact gatePotentials_through p a b hab g h hg .vertical₁ (Or.inr (Or.inl rfl)) + (by simp [hc.1,hc.2,Tile.Occupied,Tile.Adj,Tile.edges]) + | verticalPair => + simp only [tileStep] at hq + split_ifs at hq with hc + · cases hq + exact gatePotentials_through p a b hab g h hg .verticalPair (Or.inr (Or.inr rfl)) + (by simp [hc.1,hc.2,Tile.Occupied,Tile.Adj,Tile.edges]) + | diagonal₀ => + simp only [tileStep] at hq + split_ifs at hq with hc + · cases hq + exact gatePotentials_swap p a b hab g h hg .diagonal₀ (Or.inl rfl) + (fun _ _ hi hj=>swap_adjacent_order hab (fun he=>hc.2 (he ▸ hi)) + (fun he=>hc.2 (he ▸ hj))) + | diagonal₁ => + simp only [tileStep] at hq + split_ifs at hq with hc + · cases hq + exact gatePotentials_swap p a b hab g h hg .diagonal₁ (Or.inr rfl) + (fun _ _ hi hj=>swap_adjacent_order_lower hab (fun he=>hc.1 (he ▸ hi)) + (fun he=>hc.1 (he ▸ hj))) + | cup => + simp only [tileStep] at hq + split_ifs at hq with hc + · cases hq + exact gatePotentials_cup p a b hab g h hg hc.1 hc.2 + | cap => + simp only [tileStep] at hq + split_ifs at hq with ha hb hn; try cases hq + apply gatePotentials_cap_general p _ a b hab g h hg (p.partner a ha) (p.partner b hb) + (p.partner_adj a ha) (p.partner_adj b hb) hn + · simp [capRemove] + · intro i j hij + simp only [capRemove,capSplice_adj] + exact Or.inr (Or.inr hij) + · exact Or.inl rfl + · intro h; cases h + | capCup => + simp only [tileStep] at hq + split_ifs at hq with ha hb hn; try cases hq + apply gatePotentials_cap_general p _ a b hab g h hg (p.partner a ha) (p.partner b hb) + (p.partner_adj a ha) (p.partner_adj b hb) hn + · simp [capRemove] + · intro i j hij + simp only [insertCup_adj,capRemove,capSplice_adj] + exact Or.inr (Or.inr (Or.inr (Or.inr hij))) + · exact Or.inr rfl + · intro _ + simp + +end Pairing + + + + + + +namespace CompactGate +variable {V : Type*} {n : ℕ} {r : V → V → Prop} [Std.Symm r] + {old : Fin n → V} {p q : Pairing n} + + + +theorem transport_potential (hp : GraphRealizes r old p) (a b : Fin n) + (hab : a.val+1=b.val) (t : Tile) (g h : Fin n → ℤ) + (hg : ∀ i,i≠a → i≠b → h i=g i) + (hq : p.tileStep a b hab t=some q) (P : V → ℤ) + (hP : ∀ i j,p.Adj i j → P (old j)-P (old i)=Pairing.arcTurn g i j) : + ∃ Q : Sum V (Fin 4) → ℤ, + (∀ i,Q (boundary old a b i)=q.turnPotential h i) ∧ + (∀ v w,r v w → Q (.inl w)-Q (.inl v)=P w-P v) ∧ + (∀ i j,t.Adj i j → Q (.inr j)-Q (.inr i)= + Pairing.gateTurn (g a) (g b) (h a) (h b) i j) ∧ + Q (.inl (old a))=Q (.inr 0) ∧ Q (.inl (old b))=Q (.inr 1) := by + obtain ⟨B,T,hB⟩ := Pairing.gatePotentials_of_step p q a b hab g h hg t hq + obtain ⟨P',hP',hE⟩ := Graph.renormalize_potential hp P B + (fun i j hij=>(hB.old_arc i j hij).trans (hP i j hij).symm) + refine ⟨Sum.elim P' T,?_,hE,hB.tile_arc,?_,?_⟩ + · intro i + by_cases hia : i=a + · subst i + simpa only [boundary_left,Sum.elim_inr] using hB.output_left + · by_cases hib : i=b + · subst i + simpa only [boundary,ite_eq_right hia,ite_true,Sum.elim_inr] using hB.output_right + · simpa only [boundary,ite_eq_right hia,ite_eq_right hib,Sum.elim_inl,hP'] using hB.outside i hia hib + · simpa only [Sum.elim_inl,Sum.elim_inr,hP'] using hB.input_left + · simpa only [Sum.elim_inl,Sum.elim_inr,hP'] using hB.input_right + +end CompactGate + +namespace Circuit +variable {n : ℕ} + + +inductive TurnGauges : Circuit n → Type + | nil (g : Fin n → ℤ) : TurnGauges .nil + | snoc {c : Circuit n} (gc : TurnGauges c) (a : Gate n) + (h : Fin n → ℤ) : TurnGauges (.snoc c a) + +namespace TurnGauges + +def final : {c : Circuit n} → TurnGauges c → Fin n → ℤ + | .nil,.nil g => g + | .snoc _ _,.snoc _ _ h => h + +def Compatible : {c : Circuit n} → TurnGauges c → Prop + | .nil,.nil _ => True + | .snoc _ a,.snoc gc _ h => gc.Compatible ∧ + ∀ i,i≠a.left → i≠a.right → h i=gc.final i + + +def edgeTurn (p : Pairing n) : {c : Circuit n} → TurnGauges c → + c.CompactVertex → c.CompactVertex → ℤ + | .nil,.nil g,i,j => Pairing.arcTurn g i j + | .snoc _ _a,.snoc gc _ _h,.inl v,.inl w => gc.edgeTurn p v w + | .snoc _ a,.snoc gc _ h,.inr i,.inr j => + Pairing.gateTurn (gc.final a.left) (gc.final a.right) (h a.left) (h a.right) i j + | .snoc _ _,.snoc _ _ _,.inl _,.inr _ => 0 + | .snoc _ _,.snoc _ _ _,.inr _,.inl _ => 0 + + +theorem potential (p : Pairing n) {c : Circuit n} (gc : TurnGauges c) + (hc : gc.Compatible) (q : Pairing n) (hq : eval p c=some q) : + ∃ P : c.CompactVertex → ℤ, + (∀ i,P (c.compactBoundary i)=q.turnPotential gc.final i) ∧ + ∀ v w,compactWiring p c v w → P w-P v=gc.edgeTurn p v w := by + induction gc generalizing q with + | nil g => + have hpq : p=q := Option.some.inj hq + subst q + refine ⟨p.turnPotential g,fun _=>rfl,?_⟩ + exact fun _ _ h=>Pairing.turnPotential_of_adj g h + | @snoc c gc a h ih => + have ⟨hc,hg⟩ := hc + cases hr : eval p c with + | none => simp [eval,hr] at hq + | some r => + have hs : r.tileStep a.left a.right a.adjacent a.tile=some q := by + simpa only [eval,hr,Option.bind_some] using hq + obtain ⟨P,hP,hE⟩ := ih hc r hr + have hPr : ∀ i j,r.Adj i j → + P (c.compactBoundary j)-P (c.compactBoundary i)=Pairing.arcTurn gc.final i j := by + intro i j hij + rw [hP,hP] + exact Pairing.turnPotential_of_adj _ hij + obtain ⟨Q,hQ,hOld,hTile,ha,hb⟩ := CompactGate.transport_potential + (compact_eval_sound p c r hr) a.left a.right a.adjacent a.tile gc.final h hg hs P hPr + refine ⟨Q,hQ,?_⟩ + intro v w hvw + cases v with + | inl v => + cases w with + | inl w => exact (hOld v w hvw).trans (hE v w hvw) + | inr j => + rcases hvw with ⟨rfl,rfl,_⟩ | ⟨rfl,rfl,_⟩ + · change Q (.inr 0)-Q (.inl (c.compactBoundary a.left))=0 + omega + · change Q (.inr 1)-Q (.inl (c.compactBoundary a.right))=0 + omega + | inr i => + cases w with + | inl w => + rcases hvw with ⟨rfl,rfl,_⟩ | ⟨rfl,rfl,_⟩ + · change Q (.inl (c.compactBoundary a.left))-Q (.inr 0)=0 + omega + · change Q (.inl (c.compactBoundary a.right))-Q (.inr 1)=0 + omega + | inr j => exact hTile i j hvw + +end TurnGauges +end Circuit + + + + + + +namespace BoundaryInsert +variable {n m : ℕ} + + +def old (k : ℕ) (_hk : k≤n) : Fin n ↪o Fin (n+m) where + toFun i := ⟨if i.val omega⟩ + inj' := by intro i j hij; apply Fin.ext; have := congrArg Fin.val hij; dsimp at this; split_ifs at this <;> omega + map_rel_iff' := by intro i j; change (if i.val omega + +def fresh (k : ℕ) (hk : k≤n) : Fin m ↪o Fin (n+m) where + toFun j := ⟨k+j.val,by omega⟩ + inj' := by intro i j hij; apply Fin.ext; have := congrArg Fin.val hij; dsimp at this; omega + map_rel_iff' := by intro i j; change k+i.val≤k+j.val ↔ i.val≤j.val; omega + +lemma disjoint (k : ℕ) (hk : k≤n) (i : Fin n) (j : Fin m) : old k hk i≠fresh k hk j := by + intro he + have := congrArg Fin.val he + change (if i.val omega + +lemma cover (k : ℕ) (hk : k≤n) (i : Fin (n+m)) : + (∃ j,old k hk j=i) ∨ (∃ j,fresh k hk j=i) := by + by_cases hi : i.val omega + + +def pairing (k : ℕ) (hk : k≤n) (p : Pairing n) (t : Pairing m) : Pairing (n+m) where + val := (p.map (old k hk)).val ∪ (t.map (fresh k hk)).val + property := by + have hp := (p.map (old (m:=m) k hk)).property + have ht := (t.map (fresh (n:=n) k hk)).property + refine ⟨?_,?_,?_⟩ + · intro a h + rcases Finset.mem_union.mp h with h|h + · exact hp.1 a h + · exact ht.1 a h + · intro a ha b hb + rcases Finset.mem_union.mp ha with ha|ha <;> + rcases Finset.mem_union.mp hb with hb|hb + · exact hp.2.1 a ha b hb + · obtain ⟨⟨i,j⟩,hij,he⟩ := Finset.mem_map.mp ha + obtain ⟨⟨x,y⟩,hxy,hf⟩ := Finset.mem_map.mp hb + subst a; subst b + exact Or.inr ⟨disjoint k hk i x,disjoint k hk i y, + disjoint k hk j x,disjoint k hk j y⟩ + · obtain ⟨⟨i,j⟩,hij,he⟩ := Finset.mem_map.mp ha + obtain ⟨⟨x,y⟩,hxy,hf⟩ := Finset.mem_map.mp hb + subst a; subst b + exact Or.inr ⟨(disjoint k hk x i).symm,(disjoint k hk y i).symm, + (disjoint k hk x j).symm,(disjoint k hk y j).symm⟩ + · exact ht.2.1 a ha b hb + · intro a ha b hb + rcases Finset.mem_union.mp ha with ha|ha <;> + rcases Finset.mem_union.mp hb with hb|hb + · exact hp.2.2 a ha b hb + · obtain ⟨⟨i,j⟩,hij,he⟩ := Finset.mem_map.mp ha + obtain ⟨⟨x,y⟩,hxy,hf⟩ := Finset.mem_map.mp hb + subst a; subst b + intro hh + exact not_cross k hk i j x y (Or.inl hh) + · obtain ⟨⟨i,j⟩,hij,he⟩ := Finset.mem_map.mp ha + obtain ⟨⟨x,y⟩,hxy,hf⟩ := Finset.mem_map.mp hb + subst a; subst b + intro hh + exact not_cross k hk x y i j (Or.inr (Or.inl hh)) + · exact ht.2.2 a ha b hb + +end BoundaryInsert +end +end CriticalStrip.Diagram + +end OAI diff --git a/lean/OAI/Combinatorics/StripMass/TurnRectangleMatching.lean b/lean/OAI/Combinatorics/StripMass/TurnRectangleMatching.lean new file mode 100644 index 0000000000000000000000000000000000000000..3764cd23bf2f00aace8d35b567f6b9fb1529390c --- /dev/null +++ b/lean/OAI/Combinatorics/StripMass/TurnRectangleMatching.lean @@ -0,0 +1,558 @@ +import Mathlib +import OAI.Combinatorics.StripMass.TurnEvolution + +namespace OAI + +/-! Critical honeycomb strip paths, polynomial identities and crossing mass. -/ + + +namespace CriticalStrip.Diagram +noncomputable section +open scoped Classical +namespace TurnRectangle +open TurnDisk TurnNetwork + +variable {M N : ℕ} (hM : 1 ≤ M) (hN : 1 ≤ N) + (p₀ : Pairing (ports M N)) (p q : ℕ → Pairing 6) + + +def PhysicalMatches : Prop := + (∀ c r, c(left w i,right w i))),by + constructor + · intro e he + obtain ⟨i,_,rfl⟩:=Finset.mem_image.mp he + exact left_lt_right w i i + constructor + · intro e he f hf + obtain ⟨i,_,rfl⟩:=Finset.mem_image.mp he + obtain ⟨j,_,rfl⟩:=Finset.mem_image.mp hf + by_cases hij : i=j + · subst j + exact Or.inl rfl + · right + exact ⟨fun h=>hij (left_injective w h),(left_lt_right w i j).ne, + (left_lt_right w j i).ne.symm,fun h=>hij (right_injective w h)⟩ + · intro e he f hf + obtain ⟨i,_,rfl⟩:=Finset.mem_image.mp he + obtain ⟨j,_,rfl⟩:=Finset.mem_image.mp hf + change ¬(left w i congr 3 + dsimp only + omega +lemma horizontal_turn {c : Fin M} {r : Fin N} (hc : 0start_matches_south hM hN p ⟨c,hc⟩, + fun r hr=>start_matches_west hM hN p ⟨r,hr⟩,hm.2⟩ + +omit p q +lemma starter_arc_turn (i : Fin (width M N)) : + Pairing.arcTurn (starterGauge M N) (TurnStarter.left (width M N) i) + (TurnStarter.right (width M N) i)=0 := by + have ho:=TurnStarter.left_lt_right (width M N) i i + dsimp only [Pairing.arcTurn,Pairing.turnOrder] + erw [ite_eq_left ho] + unfold starterGauge TurnStarter.left TurnStarter.right width + dsimp only + have hi : i.val<2*(M+N) := i.isLt + split_ifs <;> omega + +include p q +lemma starter_edge {i : Fin (width M N)} (hi : starterActive p i) : + edges hM hN (startPairing p) p q (.inl (TurnStarter.left (width M N) i)) + (.inl (TurnStarter.right (width M N) i)) := + lift_edge _ _ _ _ _ _ (Nat.zero_le (M*N)) + (show graph (startPairing p) (starterGauge M N) p q (position M N) (position_bound hM hN) 0 + (.inl (TurnStarter.left _ i)) (.inl (TurnStarter.right _ i)) from + TurnStarter.across (width M N) (starterActive p) hi) +lemma starter_turn {i : Fin (width M N)} (hi : starterActive p i) : + turns hM hN (startPairing p) p q (.inl (TurnStarter.left (width M N) i)) + (.inl (TurnStarter.right (width M N) i))=0 := + (lift_turn _ _ _ _ _ _ (Nat.zero_le (M*N)) + (show graph (startPairing p) (starterGauge M N) p q (position M N) (position_bound hM hN) 0 + (.inl (TurnStarter.left _ i)) (.inl (TurnStarter.right _ i)) from + TurnStarter.across (width M N) (starterActive p) hi)).trans (starter_arc_turn i) + +variable (hm : InteriorMatches (M:=M) (N:=N) p q) +include hm +lemma south_edge {c : Fin M} (l : Fin 2) + (hi : (p (c.val*N)).Occupied ⟨3-l.val,by omega⟩) : + edges hM hN (startPairing p) p q + (.inl (southSlot hM hN c.isLt (by omega : 0 exact Pairing.arcTurn_reverse g v w + | insert D k hk p g ih => + rcases v with v|v <;> rcases w with w|w + · exact ih v w + · rfl + · rfl + · exact Pairing.arcTurn_reverse g v w + | attach D E k hk ih ihE => + rcases v with v|v <;> rcases w with w|w + · exact ih v w + · rfl + · rfl + · exact ihE v w + | sew D k hk ih => + change (if D.wiring w v then D.edgeTurn w v else 0)= -(if D.wiring v w then D.edgeTurn v w else 0) + have hs : D.wiring w v ↔ D.wiring v w := ⟨fun h=>(TurnDisk.instSymmVertexWiring D).symm _ _ h, + fun h=>(TurnDisk.instSymmVertexWiring D).symm _ _ h⟩ + simp only [hs] + split_ifs + · exact ih v w + · rfl + +lemma TurnNetwork.edgeTurn_reverse {n : ℕ} (p₀ : Pairing n) (g₀ : Fin n → ℤ) + (p q : ℕ → Pairing 6) (k : ℕ → ℕ) (hk : ∀ t,k t+4≤n) (t : ℕ) + (v w : TurnNetwork.Node n t) : + TurnNetwork.edgeTurn p₀ g₀ p q k hk t w v= -TurnNetwork.edgeTurn p₀ g₀ p q k hk t v w := + TurnDisk.edgeTurn_reverse _ _ _ + +end +end CriticalStrip.Diagram + +end OAI diff --git a/lean/OAI/Combinatorics/StripMass/TurnRhombus.lean b/lean/OAI/Combinatorics/StripMass/TurnRhombus.lean new file mode 100644 index 0000000000000000000000000000000000000000..17b8ee5554fed753a454ea533c988949c742fd93 --- /dev/null +++ b/lean/OAI/Combinatorics/StripMass/TurnRhombus.lean @@ -0,0 +1,422 @@ +import Mathlib +import OAI.Combinatorics.StripMass.GraphPath +import OAI.Combinatorics.StripMass.TurnWideGate + +namespace OAI + +/-! Critical honeycomb strip paths, polynomial identities and crossing mass. -/ + + +namespace CriticalStrip.Diagram +noncomputable section +open scoped Classical + +namespace TurnDisk +lemma sew_edge {n : ℕ} (D : TurnDisk (n+2)) (k : ℕ) (hk : k≤n) + {v w : D.Vertex} (h : D.wiring v w) : (D.sew k hk).wiring v w := Or.inl h +lemma sew_edgeTurn {n : ℕ} (D : TurnDisk (n+2)) (k : ℕ) (hk : k≤n) + {v w : D.Vertex} (h : D.wiring v w) : (D.sew k hk).edgeTurn v w=D.edgeTurn v w := by + change (if D.wiring v w then _ else _)=_ + rw [ite_eq_left h] +lemma sew_zeroTurn {n : ℕ} (D : TurnDisk (n+2)) (k : ℕ) (hk : k≤n) + {v w : D.Vertex} (h : D.edgeTurn v w=0) : (D.sew k hk).edgeTurn v w=0 := by + change (if D.wiring v w then _ else _)=_ + split_ifs <;> first | exact h | rfl + +namespace Gate4 +variable {n : ℕ} (D : TurnDisk n) (k : ℕ) (hk : k+4≤n) (E : TurnDisk 8) +lemma old_edge {v w : D.Vertex} (h : D.wiring v w) : + (D.gate4 k hk E).wiring (.inl v) (.inl w) := + Or.inl (Or.inl (Or.inl (Or.inl h))) +lemma new_edge {v w : E.Vertex} (h : E.wiring v w) : + (D.gate4 k hk E).wiring (.inr v) (.inr w) := + Or.inl (Or.inl (Or.inl (Or.inl h))) +lemma old_edgeTurn {v w : D.Vertex} (h : D.wiring v w) : + (D.gate4 k hk E).edgeTurn (.inl v) (.inl w)=D.edgeTurn v w := by + change (((stage0 D k hk E).sew _ _).sew _ _ |>.sew _ _ |>.sew _ _).edgeTurn _ _=_ + rw [sew_edgeTurn (stage3 D k hk E) k (by omega) (v:=Sum.inl v) (w:=Sum.inl w) (Or.inl (Or.inl (Or.inl h))), + sew_edgeTurn (stage2 D k hk E) (k+1) (by omega) (v:=Sum.inl v) (w:=Sum.inl w) (Or.inl (Or.inl h)), + sew_edgeTurn (stage1 D k hk E) (k+2) (by omega) (v:=Sum.inl v) (w:=Sum.inl w) (Or.inl h), + sew_edgeTurn (stage0 D k hk E) (k+3) (by omega) (v:=Sum.inl v) (w:=Sum.inl w) h] + rfl +lemma new_edgeTurn {v w : E.Vertex} (h : E.wiring v w) : + (D.gate4 k hk E).edgeTurn (.inr v) (.inr w)=E.edgeTurn v w := by + change (((stage0 D k hk E).sew _ _).sew _ _ |>.sew _ _ |>.sew _ _).edgeTurn _ _=_ + rw [sew_edgeTurn (stage3 D k hk E) k (by omega) (v:=Sum.inr v) (w:=Sum.inr w) (Or.inl (Or.inl (Or.inl h))), + sew_edgeTurn (stage2 D k hk E) (k+1) (by omega) (v:=Sum.inr v) (w:=Sum.inr w) (Or.inl (Or.inl h)), + sew_edgeTurn (stage1 D k hk E) (k+2) (by omega) (v:=Sum.inr v) (w:=Sum.inr w) (Or.inl h), + sew_edgeTurn (stage0 D k hk E) (k+3) (by omega) (v:=Sum.inr v) (w:=Sum.inr w) h] + rfl +lemma cross_edgeTurn (v : D.Vertex) (w : E.Vertex) : + (D.gate4 k hk E).edgeTurn (.inl v) (.inr w)=0 := + sew_zeroTurn _ _ _ (sew_zeroTurn _ _ _ (sew_zeroTurn _ _ _ (sew_zeroTurn _ _ _ rfl))) +lemma cross_edgeTurn_reverse (v : E.Vertex) (w : D.Vertex) : + (D.gate4 k hk E).edgeTurn (.inr v) (.inl w)=0 := + sew_zeroTurn _ _ _ (sew_zeroTurn _ _ _ (sew_zeroTurn _ _ _ (sew_zeroTurn _ _ _ rfl))) +end Gate4 + + + +namespace Rhombus + +def upGauge (i : Fin 6) : ℤ := -5+2*(i.val/2 : ℕ) +def downGauge (i : Fin 6) : ℤ := -4+2*(i.val/2 : ℕ) + +def disk (p q : Pairing 6) : TurnDisk 8 := + (((TurnDisk.atom p upGauge).insert 6 (by omega) q downGauge).sew 5 (by omega)).sew 4 (by omega) + +variable (p q : Pairing 6) + +lemma boundary_left (i : Fin 4) : (disk p q).boundary ⟨i.val,by omega⟩= + .inl ⟨i.val,by omega⟩ := by + change BoundaryInsert.boundary (n:=6) (m:=6) 6 (by omega) id id + (BoundaryErase.keep 5 (by omega) (BoundaryErase.keep 4 (by omega) ⟨i.val,by omega⟩))=_ + have he : BoundaryErase.keep 5 (by omega) (BoundaryErase.keep 4 (by omega) + (⟨i.val,by omega⟩:Fin 8))=(⟨i.val,by omega⟩:Fin 12) := by + apply Fin.ext + change Gate4.skip 5 (Gate4.skip 4 i.val)=i.val + simp (disch := omega) only [Gate4.skip,ite_eq_left] + rw [he] + exact BoundaryInsert.boundary_before 6 (by omega) id id _ (by change i.val<6; omega) + +lemma boundary_right (i : Fin 4) : (disk p q).boundary ⟨4+i.val,by omega⟩= + .inr ⟨2+i.val,by omega⟩ := by + change BoundaryInsert.boundary (n:=6) (m:=6) 6 (by omega) id id + (BoundaryErase.keep 5 (by omega) (BoundaryErase.keep 4 (by omega) ⟨4+i.val,by omega⟩))=_ + have he : BoundaryErase.keep 5 (by omega) (BoundaryErase.keep 4 (by omega) + (⟨4+i.val,by omega⟩:Fin 8))=(⟨8+i.val,by omega⟩:Fin 12) := by + apply Fin.ext + change Gate4.skip 5 (Gate4.skip 4 (4+i.val))=8+i.val + simp (disch := omega) only [Gate4.skip,ite_eq_right] + omega + rw [he,BoundaryInsert.boundary_between 6 (by omega) id id _ + (by change 6≤8+i.val; omega) (by change 8+i.val<6+6; omega)] + apply congrArg Sum.inr + apply Fin.ext + change (8+i.val)-6=2+i.val + omega + +lemma input_boundary (i : Fin 4) : (disk p q).boundary (Gate4.input i)= + .inl ⟨3-i.val,by omega⟩ := boundary_left p q ⟨3-i.val,by omega⟩ +lemma output_boundary (i : Fin 4) : (disk p q).boundary (Gate4.output i)= + .inr ⟨2+i.val,by omega⟩ := boundary_right p q i + +lemma gauge_input (i : Fin 4) : (disk p q).gauge (Gate4.input i)= + (if i.val<2 then -3 else -5) := by + rw [←vertexGauge_boundary,input_boundary] + change upGauge ⟨3-i.val,_⟩=_ + fin_cases i <;> decide +lemma gauge_output (i : Fin 4) : (disk p q).gauge (Gate4.output i)= + (if i.val<2 then -2 else 0) := by + rw [←vertexGauge_boundary,output_boundary] + change downGauge ⟨2+i.val,_⟩=_ + fin_cases i <;> decide + +abbrev stage : TurnDisk 12 := (TurnDisk.atom p upGauge).insert 6 (by omega) q downGauge +lemma first_left : (stage p q).boundary (BoundaryErase.left 5 (by omega))=.inl (5:Fin 6) := by + exact BoundaryInsert.boundary_before (n:=6) (m:=6) 6 (by omega) id id _ (by decide) +lemma first_right : (stage p q).boundary (BoundaryErase.right 5 (by omega))=.inr (0:Fin 6) := by + exact BoundaryInsert.boundary_between (n:=6) (m:=6) 6 (by omega) id id _ (by decide) (by decide) +abbrev joined : TurnDisk 10 := (stage p q).sew 5 (by omega) +lemma second_left : (joined p q).boundary + (BoundaryErase.left 4 (by omega))=.inl (4:Fin 6) := by + change BoundaryInsert.boundary (n:=6) (m:=6) 6 (by omega) id id (4:Fin 12)=_ + exact BoundaryInsert.boundary_before (n:=6) (m:=6) 6 (by omega) id id _ (by decide) +lemma second_right : (joined p q).boundary + (BoundaryErase.right 4 (by omega))=.inr (1:Fin 6) := by + change BoundaryInsert.boundary (n:=6) (m:=6) 6 (by omega) id id (7:Fin 12)=_ + exact BoundaryInsert.boundary_between (n:=6) (m:=6) 6 (by omega) id id _ (by decide) (by decide) + +variable (hm : ∀ i : Fin 2,p.Occupied ⟨4+i.val,by omega⟩ ↔ q.Occupied ⟨1-i.val,by omega⟩) +include hm +lemma match1 : Graph.Used (stage p q).wiring ((stage p q).boundary (BoundaryErase.left 5 (by omega))) ↔ + Graph.Used (stage p q).wiring ((stage p q).boundary (BoundaryErase.right 5 (by omega))) := by + rw [first_left,first_right] + change Graph.Used (BoundaryInsert.unionGraph p.Adj q.Adj) (.inl 5) ↔ + Graph.Used (BoundaryInsert.unionGraph p.Adj q.Adj) (.inr 0) + rw [BoundaryInsert.used_left,BoundaryInsert.used_right] + exact hm 1 +lemma stage_used (v : Fin 6⊕Fin 6) : + Graph.Used (joined p q).wiring v ↔ Graph.Used (stage p q).wiring v := + sew_used _ _ _ (match1 p q hm) v +lemma match2 : Graph.Used (joined p q).wiring + ((joined p q).boundary (BoundaryErase.left 4 (by omega))) ↔ + Graph.Used (joined p q).wiring + ((joined p q).boundary (BoundaryErase.right 4 (by omega))) := by + erw [second_left,second_right,stage_used p q hm,stage_used p q hm] + change Graph.Used (BoundaryInsert.unionGraph p.Adj q.Adj) (.inl 4) ↔ + Graph.Used (BoundaryInsert.unionGraph p.Adj q.Adj) (.inr 1) + rw [BoundaryInsert.used_left,BoundaryInsert.used_right] + exact hm 0 +lemma used (v : Fin 6⊕Fin 6) : Graph.Used (disk p q).wiring v ↔ + Graph.Used (stage p q).wiring v := + (sew_used _ _ _ (match2 p q hm) v).trans (stage_used p q hm v) +lemma compatible : (disk p q).Compatible := by + refine ⟨⟨True.intro,match1 p q hm,?_⟩,match2 p q hm,?_⟩ + · rw [←vertexGauge_boundary,←vertexGauge_boundary,first_right,first_left] + change downGauge 0=upGauge 5-3 + decide + · rw [←vertexGauge_boundary,←vertexGauge_boundary,second_right,second_left] + change downGauge 1=upGauge 4-3 + decide + +lemma wiring (v w : Fin 6⊕Fin 6) : (disk p q).wiring v w ↔ + BoundaryInsert.unionGraph p.Adj q.Adj v w ∨ ∃ i : Fin 2,p.Occupied ⟨4+i.val,by omega⟩ ∧ + ((v=.inl ⟨4+i.val,by omega⟩ ∧ w=.inr ⟨1-i.val,by omega⟩) ∨ + (w=.inl ⟨4+i.val,by omega⟩ ∧ v=.inr ⟨1-i.val,by omega⟩)) := by + change BoundarySew.graph (joined p q).wiring _ _ _ v w ↔ _ + simp only [BoundarySew.graph] + erw [second_left,second_right,stage_used p q hm] + change (BoundarySew.graph (stage p q).wiring _ _ _ v w ∨ _) ↔ _ + simp only [BoundarySew.graph] + rw [first_left,first_right] + change ((_ ∨ (Graph.Used (BoundaryInsert.unionGraph p.Adj q.Adj) (.inl 5) ∧ _)) ∨ + (Graph.Used (BoundaryInsert.unionGraph p.Adj q.Adj) (.inl 4) ∧ _)) ↔ _ + rw [BoundaryInsert.used_left,BoundaryInsert.used_left] + simp only [Fin.exists_fin_succ, Fin.exists_fin_zero, or_false] + change ((BoundaryInsert.unionGraph p.Adj q.Adj v w ∨ (p.Occupied 5 ∧ _)) ∨ (p.Occupied 4 ∧ _)) ↔ _ + tauto + +omit hm +lemma up_edge {v w : Fin 6} (h : p.Adj v w) : (disk p q).wiring (.inl v) (.inl w) := + Or.inl (Or.inl h) +lemma down_edge {v w : Fin 6} (h : q.Adj v w) : (disk p q).wiring (.inr v) (.inr w) := + Or.inl (Or.inl h) +lemma up_turn {v w : Fin 6} (h : p.Adj v w) : + (disk p q).edgeTurn (.inl v) (.inl w)=Pairing.arcTurn upGauge v w := by + change ((joined p q).sew 4 (by omega)).edgeTurn _ _=_ + rw [sew_edgeTurn (joined p q) 4 (by omega) (v:=Sum.inl v) (w:=Sum.inl w) (Or.inl h), + sew_edgeTurn (stage p q) 5 (by omega) (v:=Sum.inl v) (w:=Sum.inl w) h] + rfl +lemma down_turn {v w : Fin 6} (h : q.Adj v w) : + (disk p q).edgeTurn (.inr v) (.inr w)=Pairing.arcTurn downGauge v w := by + change ((joined p q).sew 4 (by omega)).edgeTurn _ _=_ + rw [sew_edgeTurn (joined p q) 4 (by omega) (v:=Sum.inr v) (w:=Sum.inr w) (Or.inl h), + sew_edgeTurn (stage p q) 5 (by omega) (v:=Sum.inr v) (w:=Sum.inr w) h] + rfl +lemma cross_turn (v w : Fin 6) : (disk p q).edgeTurn (.inl v) (.inr w)=0 := + sew_zeroTurn _ _ _ (sew_zeroTurn _ _ _ rfl) +lemma cross_turn_reverse (v w : Fin 6) : (disk p q).edgeTurn (.inr v) (.inl w)=0 := + sew_zeroTurn _ _ _ (sew_zeroTurn _ _ _ rfl) +end Rhombus +end TurnDisk + + + + + + +namespace TurnNetwork +open TurnDisk +abbrev Local := Fin 6 ⊕ Fin 6 +abbrev Node (n t : ℕ) := Fin n ⊕ (Fin t × Local) + +def old {n t : ℕ} : Node n t → Node n (t+1) + | .inl i => .inl i + | .inr (i,v) => .inr (i.castSucc,v) +def fresh {n t : ℕ} (v : Local) : Node n (t+1) := .inr (Fin.last t,v) + +lemma old_injective {n t : ℕ} : Function.Injective (old (n:=n) (t:=t)) := by + rintro (i|⟨i,v⟩) (j|⟨j,w⟩) h <;> simp only [old,Sum.inl.injEq,Sum.inr.injEq,Prod.mk.injEq] at h + · exact congrArg Sum.inl h + · cases h + · cases h + · obtain ⟨h,rfl⟩:=h + have h' : i=j := Fin.ext (congrArg (fun i : Fin (t+1)=>i.val) h) + subst j + rfl +lemma fresh_injective {n t : ℕ} : Function.Injective (fresh (n:=n) (t:=t)) := by + intro v w h + simpa only [fresh,Sum.inr.injEq,Prod.mk.injEq,true_and] using h +lemma old_ne_fresh {n t : ℕ} (v : Node n t) (w : Local) : old v≠fresh w := by + cases v with + | inl i => simp only [old,fresh,ne_eq,reduceCtorEq,not_false_eq_true] + | inr x => + intro h + have hz := congrArg (fun z : Node n (t+1)=> match z with + | .inl _ => 0 + | .inr x => x.1.val) h + change x.1.val=t at hz + omega +lemma cover {n t : ℕ} (v : Node n (t+1)) : + (∃ w : Node n t,v=old w) ∨ (∃ w : Local,v=fresh w) := by + cases v with + | inl i => exact Or.inl ⟨.inl i,rfl⟩ + | inr x => + obtain ⟨i,v⟩:=x + by_cases h : i.val .atom p₀ g₀ + | t+1 => (disk t).gate4 (k t) (hk t) (Rhombus.disk (p t) (q t)) + + + +def names : (t : ℕ) → (disk p₀ g₀ p q k hk t).Vertex ≃ Node n t + | 0 => + { toFun := Sum.inl + invFun := fun v=> match v with + | .inl i=>i + | .inr x=>Fin.elim0 x.1 + left_inv := fun _=>rfl + right_inv := by rintro (i|⟨i,v⟩); rfl; exact Fin.elim0 i } + | t+1 => + Equiv.ofBijective (fun v=> match v with + | .inl w=>old (names t w) + | .inr w=>fresh w) ⟨by + rintro (v|v) (w|w) h + · exact congrArg Sum.inl ((names t).injective (old_injective h)) + · exact (old_ne_fresh (names t v) w h).elim + · exact (old_ne_fresh (names t w) v h.symm).elim + · exact congrArg Sum.inr (fresh_injective h),by + intro v + obtain ⟨w,rfl⟩|⟨w,rfl⟩:=cover v + · exact ⟨.inl ((names t).symm w),by simp only [Equiv.apply_symm_apply]⟩ + · exact ⟨.inr w,rfl⟩⟩ + +lemma names_old (t : ℕ) (v : (disk p₀ g₀ p q k hk t).Vertex) : + names p₀ g₀ p q k hk (t+1) (.inl v)=old (names p₀ g₀ p q k hk t v) := rfl +lemma names_fresh (t : ℕ) (v : Local) : + names p₀ g₀ p q k hk (t+1) (.inr v)=fresh v := rfl +lemma inv_old (t : ℕ) (v : Node n t) : + (names p₀ g₀ p q k hk (t+1)).symm (old v)=.inl ((names p₀ g₀ p q k hk t).symm v) := by + apply (names p₀ g₀ p q k hk (t+1)).injective + rw [Equiv.apply_symm_apply,names_old,Equiv.apply_symm_apply] +lemma inv_fresh (t : ℕ) (v : Local) : + (names p₀ g₀ p q k hk (t+1)).symm (fresh v)=.inr v := by + apply (names p₀ g₀ p q k hk (t+1)).injective + rw [Equiv.apply_symm_apply,names_fresh] + +def graph (t : ℕ) (v w : Node n t) : Prop := + (disk p₀ g₀ p q k hk t).wiring ((names p₀ g₀ p q k hk t).symm v) + ((names p₀ g₀ p q k hk t).symm w) +def edgeTurn (t : ℕ) (v w : Node n t) : ℤ := + (disk p₀ g₀ p q k hk t).edgeTurn ((names p₀ g₀ p q k hk t).symm v) + ((names p₀ g₀ p q k hk t).symm w) +def boundary (t : ℕ) (i : Fin n) : Node n t := + names p₀ g₀ p q k hk t ((disk p₀ g₀ p q k hk t).boundary i) + +instance (t : ℕ) : Std.Symm (graph p₀ g₀ p q k hk t) := + ⟨by intro v w h; exact (symm h : (disk p₀ g₀ p q k hk t).wiring _ _)⟩ +lemma boundary_zero (i : Fin n) : boundary p₀ g₀ p q k hk 0 i=.inl i := rfl +lemma boundary_slot (t : ℕ) (i : Fin 4) : + boundary p₀ g₀ p q k hk (t+1) (Gate4.slot (k t) (hk t) i)= + fresh (.inr ⟨2+i.val,by omega⟩) := by + unfold boundary + change names p₀ g₀ p q k hk (t+1) + (((disk p₀ g₀ p q k hk t).gate4 (k t) (hk t) (Rhombus.disk (p t) (q t))).boundary _) = _ + erw [Gate4.boundary_slot,Rhombus.output_boundary] + rfl +lemma boundary_outside (t : ℕ) (i : Fin n) (hi : i.valp₀.Occupied i + | .inr (i,.inl v)=>(p i.val).Occupied v + | .inr (i,.inr v)=>(q i.val).Occupied v + +omit g₀ k hk +lemma occupied_old (t : ℕ) (v : Node n t) : Occupied p₀ p q (t+1) (old v) ↔ Occupied p₀ p q t v := by + cases v with + | inl i=>rfl + | inr x=>obtain ⟨i,(v|v)⟩:=x <;> rfl +lemma occupied_fresh (t : ℕ) (v : Local) : + Occupied p₀ p q (t+1) (fresh v) ↔ match v with + | .inl i=>(p t).Occupied i + | .inr i=>(q t).Occupied i := by cases v <;> rfl + +include g₀ k hk +lemma used_equiv (t : ℕ) (v : Node n t) : + Graph.Used (graph p₀ g₀ p q k hk t) v ↔ + Graph.Used (disk p₀ g₀ p q k hk t).wiring ((names p₀ g₀ p q k hk t).symm v) := by + constructor + · rintro ⟨w,hw⟩ + exact ⟨(names p₀ g₀ p q k hk t).symm w,hw⟩ + · rintro ⟨w,hw⟩ + exact ⟨names p₀ g₀ p q k hk t w,by simpa only [graph,Equiv.symm_apply_apply] using hw⟩ + + + +theorem potential (t : ℕ) (hc : (disk p₀ g₀ p q k hk t).Compatible) + (hd : Graph.DrainsBoundary (graph p₀ g₀ p q k hk t) (boundary p₀ g₀ p q k hk t)) : + ∃ (a : Pairing n) (P : Node n t → ℤ), + (∀ i j,Relation.ReflTransGen (graph p₀ g₀ p q k hk t) + (boundary p₀ g₀ p q k hk t i) (boundary p₀ g₀ p q k hk t j) ↔ i=j ∨ a.Adj i j) ∧ + (∀ i j,a.Adj i j → P (boundary p₀ g₀ p q k hk t j)-P (boundary p₀ g₀ p q k hk t i)= + Pairing.arcTurn (disk p₀ g₀ p q k hk t).gauge i j) ∧ + ∀ v w,graph p₀ g₀ p q k hk t v w → P w-P v=edgeTurn p₀ g₀ p q k hk t v w := by + have hd' : Graph.DrainsBoundary (disk p₀ g₀ p q k hk t).wiring (disk p₀ g₀ p q k hk t).boundary := by + intro v w hvw + have he : graph p₀ g₀ p q k hk t (names p₀ g₀ p q k hk t v) (names p₀ g₀ p q k hk t w) := by + simpa only [graph,Equiv.symm_apply_apply] using hvw + obtain ⟨i,hi⟩:=hd _ _ he + refine ⟨i,?_⟩ + have h:=Graph.map_reach (names p₀ g₀ p q k hk t).symm (fun _ _ h=>.single h) hi + simpa only [boundary,Equiv.symm_apply_apply] using h + obtain ⟨a,P,hr,ha,he⟩:=(disk p₀ g₀ p q k hk t).potential hc hd' + refine ⟨a,P ∘ (names p₀ g₀ p q k hk t).symm,?_,?_,fun v w h=>he _ _ h⟩ + · intro i j + rw [←hr.reach] + constructor + · intro h + have hh:=Graph.map_reach (names p₀ g₀ p q k hk t).symm (fun _ _ h=>.single h) h + simpa only [boundary,Equiv.symm_apply_apply] using hh + · intro h + exact Graph.map_reach (names p₀ g₀ p q k hk t) (fun _ _ h=>by + apply Relation.ReflTransGen.single + simpa only [graph,Equiv.symm_apply_apply] using h) h + · intro i j hij + simpa only [Function.comp_apply,boundary,Equiv.symm_apply_apply] using ha i j hij + +end TurnNetwork +end +end CriticalStrip.Diagram + +end OAI diff --git a/lean/OAI/Combinatorics/StripMass/TurnShelling.lean b/lean/OAI/Combinatorics/StripMass/TurnShelling.lean new file mode 100644 index 0000000000000000000000000000000000000000..5b71078af76aa9344d038ed0d73431802ae56233 --- /dev/null +++ b/lean/OAI/Combinatorics/StripMass/TurnShelling.lean @@ -0,0 +1,234 @@ +import Mathlib +import OAI.Combinatorics.StripMass.TurnDisk + +namespace OAI + +/-! Critical honeycomb strip paths, polynomial identities and crossing mass. -/ + + +namespace CriticalStrip.Diagram +noncomputable section +open scoped Classical + +namespace Graph + + +lemma reach_before_sewing {V I : Type*} {r s : V → V → Prop} (b : I → V) + (hs : ∀ v w,s v w → r v w ∨ ∃ i,v=b i) {v w : V} + (h : Relation.ReflTransGen s v w) : + (∃ i,Relation.ReflTransGen r v (b i)) ∨ Relation.ReflTransGen r v w := by + induction h with + | refl => exact Or.inr .refl + | @tail y z h e ih => + rcases ih with h|h + · exact Or.inl h + · rcases hs _ _ e with he|⟨i,rfl⟩ + · exact Or.inr (h.tail he) + · exact Or.inl ⟨i,h⟩ + +lemma drains_before_sewing {V I J : Type*} {r s : V → V → Prop} + (b : I → V) (c : J → V) + (hrs : ∀ v w,r v w → s v w) + (hs : ∀ v w,s v w → r v w ∨ ∃ i,v=b i) + (hc : ∀ j,∃ i,c j=b i) (hd : DrainsBoundary s c) : DrainsBoundary r b := by + intro v w hvw + obtain ⟨j,hj⟩:=hd v w (hrs _ _ hvw) + rcases reach_before_sewing b hs hj with h|h + · exact h + · obtain ⟨i,hi⟩:=hc j + exact ⟨i,hi ▸ h⟩ + +end Graph + +namespace BoundaryInsert +lemma drains_old {V W : Type*} {n m : ℕ} {r : V → V → Prop} {s : W → W → Prop} + (a : Fin n → V) (b : Fin m → W) (k : ℕ) (hk : k≤n) + (hd : Graph.DrainsBoundary (unionGraph r s) (boundary k hk a b)) : + Graph.DrainsBoundary r a := by + intro v w hvw + obtain ⟨i,hi⟩:=hd (.inl v) (.inl w) hvw + obtain ⟨j,rfl⟩|⟨j,rfl⟩:=cover k hk i + · rw [boundary_old] at hi + obtain ⟨x,hx,h⟩:=reach_left r s hi + cases hx + exact ⟨j,h⟩ + · rw [boundary_fresh] at hi + obtain ⟨x,hx,_⟩:=reach_left r s hi + cases hx +lemma drains_fresh {V W : Type*} {n m : ℕ} {r : V → V → Prop} {s : W → W → Prop} + (a : Fin n → V) (b : Fin m → W) (k : ℕ) (hk : k≤n) + (hd : Graph.DrainsBoundary (unionGraph r s) (boundary k hk a b)) : + Graph.DrainsBoundary s b := by + intro v w hvw + obtain ⟨i,hi⟩:=hd (.inr v) (.inr w) hvw + obtain ⟨j,rfl⟩|⟨j,rfl⟩:=cover k hk i + · rw [boundary_old] at hi + obtain ⟨x,hx,_⟩:=reach_right r s hi + cases hx + · rw [boundary_fresh] at hi + obtain ⟨x,hx,h⟩:=reach_right r s hi + cases hx + exact ⟨j,h⟩ + +end BoundaryInsert + + + +inductive TurnDisk : ℕ → Type + | atom {n : ℕ} (p : Pairing n) (g : Fin n → ℤ) : TurnDisk n + | insert {n m : ℕ} (D : TurnDisk n) (k : ℕ) (hk : k≤n) + (p : Pairing m) (g : Fin m → ℤ) : TurnDisk (n+m) + | attach {n m : ℕ} (D : TurnDisk n) (E : TurnDisk m) (k : ℕ) (hk : k≤n) : TurnDisk (n+m) + | sew {n : ℕ} (D : TurnDisk (n+2)) (k : ℕ) (hk : k≤n) : TurnDisk n + +namespace TurnDisk + +variable {boundarySize : ℕ} + +def Vertex : {n : ℕ} → TurnDisk n → Type + | n,.atom _ _ => Fin n + | _,@TurnDisk.insert n m D _ _ _ _ => D.Vertex ⊕ Fin m + | _,.attach D E _ _ => D.Vertex ⊕ E.Vertex + | _,.sew D _ _ => D.Vertex + +def boundary : {n : ℕ} → (D : TurnDisk n) → Fin n → D.Vertex + | _,.atom _ _ => id + | _,.insert D k hk _ _ => BoundaryInsert.boundary k hk D.boundary id + | _,.attach D E k hk => BoundaryInsert.boundary k hk D.boundary E.boundary + | _,.sew D k hk => D.boundary ∘ BoundaryErase.keep k hk + +def gauge : {n : ℕ} → TurnDisk n → Fin n → ℤ + | _,.atom _ g => g + | _,.insert D k hk _ g => BoundaryInsert.gauge k hk D.gauge g + | _,.attach D E k hk => BoundaryInsert.gauge k hk D.gauge E.gauge + | _,.sew D k hk => D.gauge ∘ BoundaryErase.keep k hk + +def wiring : {n : ℕ} → (D : TurnDisk n) → D.Vertex → D.Vertex → Prop + | _,.atom p _ => p.Adj + | _,.insert D _ _ p _ => BoundaryInsert.unionGraph D.wiring p.Adj + | _,.attach D E _ _ => BoundaryInsert.unionGraph D.wiring E.wiring + | _,.sew D k hk => BoundarySew.graph D.wiring + (D.boundary (BoundaryErase.left k hk)) (D.boundary (BoundaryErase.right k hk)) + (Graph.Used D.wiring (D.boundary (BoundaryErase.left k hk))) + +instance (D : TurnDisk boundarySize) : Std.Symm D.wiring := by + induction D with + | atom p g => exact ⟨fun _ _ h=> Pairing.adj_symm h⟩ + | insert D k hk p g ih => + let := ih + let : Std.Symm p.Adj := ⟨fun _ _ h=>Pairing.adj_symm h⟩ + exact inferInstanceAs (Std.Symm (BoundaryInsert.unionGraph D.wiring p.Adj)) + | attach D E k hk ih ihE => + let := ih + let := ihE + exact inferInstanceAs (Std.Symm (BoundaryInsert.unionGraph D.wiring E.wiring)) + | sew D k hk ih => + let := ih + exact inferInstanceAs (Std.Symm (BoundarySew.graph D.wiring _ _ _)) + +def Compatible : {n : ℕ} → TurnDisk n → Prop + | _,.atom _ _ => True + | _,.insert D _ _ _ _ => D.Compatible + | _,.attach D E _ _ => D.Compatible ∧ E.Compatible + | _,.sew D k hk => D.Compatible ∧ + (Graph.Used D.wiring (D.boundary (BoundaryErase.left k hk)) ↔ + Graph.Used D.wiring (D.boundary (BoundaryErase.right k hk))) ∧ + D.gauge (BoundaryErase.right k hk)=D.gauge (BoundaryErase.left k hk)-3 + + +def edgeTurn : {n : ℕ} → (D : TurnDisk n) → D.Vertex → D.Vertex → ℤ + | _,.atom _ g => Pairing.arcTurn g + | _,.insert D _ _ _ g => fun v w=> match v,w with + | Sum.inl v,Sum.inl w => D.edgeTurn v w + | Sum.inr i,Sum.inr j => Pairing.arcTurn g i j + | _,_ => 0 + | _,.attach D E _ _ => fun v w=> match v,w with + | Sum.inl v,Sum.inl w => D.edgeTurn v w + | Sum.inr i,Sum.inr j => E.edgeTurn i j + | _,_ => 0 + | _,.sew D _ _ => fun v w=> if D.wiring v w then D.edgeTurn v w else 0 + +lemma boundary_injective (D : TurnDisk boundarySize) : Function.Injective D.boundary := by + induction D with + | atom p g => exact Function.injective_id + | insert D k hk p g ih => exact BoundaryInsert.boundary_injective k hk _ _ ih Function.injective_id + | attach D E k hk ih ihE => exact BoundaryInsert.boundary_injective k hk _ _ ih ihE + | sew D k hk ih => exact ih.comp (BoundaryErase.keep k hk).injective + + + +theorem potential (D : TurnDisk boundarySize) (hc : D.Compatible) + (hd : Graph.DrainsBoundary D.wiring D.boundary) : + ∃ (p : Pairing boundarySize) (P : D.Vertex → ℤ), + GraphRealizes D.wiring D.boundary p ∧ + (∀ i j,p.Adj i j → P (D.boundary j)-P (D.boundary i)=Pairing.arcTurn D.gauge i j) ∧ + ∀ v w,D.wiring v w → P w-P v=D.edgeTurn v w := by + induction D with + | atom p g => exact ⟨p,p.turnPotential g,p.graphRealizes, + fun _ _ h=>Pairing.turnPotential_of_adj g h,fun _ _ h=>Pairing.turnPotential_of_adj g h⟩ + | @insert n m D k hk t g ih => + obtain ⟨p,P,hp,ha,he⟩:=ih hc + (BoundaryInsert.drains_old D.boundary id k hk hd) + refine ⟨BoundaryInsert.pairing k hk p t,Sum.elim P (t.turnPotential g), + BoundaryInsert.realizes k hk hp t.graphRealizes, + BoundaryInsert.potential k hk _ _ p t D.gauge g P (t.turnPotential g) ha + (fun _ _ h=>Pairing.turnPotential_of_adj g h),?_⟩ + rintro (v|v) (w|w) hvw + · exact he _ _ hvw + · exact hvw.elim + · exact hvw.elim + · exact Pairing.turnPotential_of_adj g hvw + | @attach n m D E k hk ih ihE => + obtain ⟨p,P,hp,ha,he⟩:=ih hc.1 + (BoundaryInsert.drains_old D.boundary E.boundary k hk hd) + obtain ⟨t,Q,ht,hb,hf⟩:=ihE hc.2 + (BoundaryInsert.drains_fresh D.boundary E.boundary k hk hd) + refine ⟨BoundaryInsert.pairing k hk p t,Sum.elim P Q, + BoundaryInsert.realizes k hk hp ht, + BoundaryInsert.potential k hk _ _ p t D.gauge E.gauge P Q ha hb,?_⟩ + rintro (v|v) (w|w) hvw + · exact he _ _ hvw + · exact hvw.elim + · exact hvw.elim + · exact hf _ _ hvw + | @sew n D k hk ih => + obtain ⟨hc,hmatch,hg⟩:=hc + have hdold : Graph.DrainsBoundary D.wiring D.boundary := by + apply Graph.drains_before_sewing D.boundary _ (s:=(D.sew k hk).wiring) + (fun _ _ h=>Or.inl h) ?_ (fun j=>⟨BoundaryErase.keep k hk j,rfl⟩) hd + intro v w hvw + change D.wiring v w ∨ (_ ∧ _) at hvw + rcases hvw with h|⟨_,h⟩ + · exact Or.inl h + · rcases h with ⟨rfl,_⟩|⟨rfl,_⟩ + · exact Or.inr ⟨BoundaryErase.left k hk,rfl⟩ + · exact Or.inr ⟨BoundaryErase.right k hk,rfl⟩ + obtain ⟨p,P,hp,ha,he⟩:=ih hc hdold + have hpused (i : Fin (n+2)) : + p.Occupied i ↔ Graph.Used D.wiring (D.boundary i) := + (hp.boundary_used_iff D.boundary_injective i).symm + have hm : p.Occupied (BoundaryErase.left k hk) ↔ p.Occupied (BoundaryErase.right k hk) := + (hpused _).trans (hmatch.trans (hpused _).symm) + have hgraph : BoundarySew.graph D.wiring (D.boundary (BoundaryErase.left k hk)) + (D.boundary (BoundaryErase.right k hk)) (p.Occupied (BoundaryErase.left k hk))= + (D.sew k hk).wiring := by + simp only [wiring,hpused] + rfl + obtain ⟨q,Q,hq,hArc,hOld,hWire⟩:=BoundarySew.transport_direct p k hk hp D.boundary_injective + hm D.gauge hg P ha (by rwa [hgraph]) + refine ⟨q,Q,by rwa [hgraph] at hq,hArc,?_⟩ + intro v w hvw + change Q w-Q v=if D.wiring v w then D.edgeTurn v w else 0 + by_cases hv : D.wiring v w + · rw [ite_eq_left hv,hOld v w hv,he v w hv] + · rw [ite_eq_right hv] + change D.wiring v w ∨ (_ ∧ _) at hvw + obtain ⟨hu,hw⟩:=hvw.resolve_left hv + have hh:=hWire ((hpused _).mpr hu) + rcases hw with ⟨rfl,rfl⟩|⟨rfl,rfl⟩ <;> omega + +end TurnDisk +end +end CriticalStrip.Diagram + +end OAI diff --git a/lean/OAI/Combinatorics/StripMass/TurnWideGate.lean b/lean/OAI/Combinatorics/StripMass/TurnWideGate.lean new file mode 100644 index 0000000000000000000000000000000000000000..687cbd28d4641d3c2468f0a5d4ed955d4106aa87 --- /dev/null +++ b/lean/OAI/Combinatorics/StripMass/TurnWideGate.lean @@ -0,0 +1,471 @@ +import Mathlib +import OAI.Combinatorics.StripMass.TurnShelling + +namespace OAI + +/-! Critical honeycomb strip paths, polynomial identities and crossing mass. -/ + + +namespace CriticalStrip.Diagram +noncomputable section +open scoped Classical + +namespace BoundaryInsert +variable {n m : ℕ} + +@[simp] lemma old_val (k : ℕ) (hk : k≤n) (i : Fin n) : + (old (m:=m) k hk i).val=(if i.val exact ⟨w,hw⟩ + | inr w => exact hw.elim + · rintro ⟨w,hw⟩ + exact ⟨.inl w,hw⟩ + +lemma used_right {V W : Type*} (r : V → V → Prop) (s : W → W → Prop) (v : W) : + Graph.Used (unionGraph r s) (.inr v) ↔ Graph.Used s v := by + constructor + · rintro ⟨w,hw⟩ + cases w with + | inl w => exact hw.elim + | inr w => exact ⟨w,hw⟩ + · rintro ⟨w,hw⟩ + exact ⟨.inr w,hw⟩ +end BoundaryInsert + +namespace BoundarySew +lemma used_iff {V : Type*} (r : V → V → Prop) (a b : V) (active : Prop) + (ha : active → Graph.Used r a) (hb : active → Graph.Used r b) (v : V) : + Graph.Used (graph r a b active) v ↔ Graph.Used r v := by + constructor + · rintro ⟨w,hw|⟨ht,hw⟩⟩ + · exact ⟨w,hw⟩ + · rcases hw with ⟨rfl,_⟩|⟨rfl,_⟩ + · exact ha ht + · exact hb ht + · rintro ⟨w,hw⟩ + exact ⟨w,Or.inl hw⟩ +end BoundarySew + +namespace TurnDisk + +lemma sew_used {n : ℕ} (D : TurnDisk (n+2)) (k : ℕ) (hk : k≤n) + (hc : Graph.Used D.wiring (D.boundary (BoundaryErase.left k hk)) ↔ + Graph.Used D.wiring (D.boundary (BoundaryErase.right k hk))) (v : D.Vertex) : + Graph.Used (D.sew k hk).wiring v ↔ Graph.Used D.wiring v := + BoundarySew.used_iff _ _ _ _ (fun h=>h) hc.mp v + + + +def vertexGauge : {n : ℕ} → (D : TurnDisk n) → D.Vertex → ℤ + | _,.atom _ g => g + | _,.insert D _ _ _ g => Sum.elim D.vertexGauge g + | _,.attach D E _ _ => Sum.elim D.vertexGauge E.vertexGauge + | _,.sew D _ _ => D.vertexGauge + +@[simp] lemma vertexGauge_boundary {boundarySize : ℕ} (D : TurnDisk boundarySize) + (i : Fin boundarySize) : + D.vertexGauge (D.boundary i)=D.gauge i := by + induction D with + | atom p g => rfl + | @insert n m D k hk p g ih => + obtain ⟨j,rfl⟩|⟨j,rfl⟩:=BoundaryInsert.cover (m:=m) k hk i + · simp only [boundary,gauge,vertexGauge,BoundaryInsert.boundary_old, + BoundaryInsert.gauge_old,Sum.elim_inl,ih] + · simp only [boundary,gauge,vertexGauge,BoundaryInsert.boundary_fresh, + BoundaryInsert.gauge_fresh,Sum.elim_inr] + rfl + | @attach n m D E k hk ih ihE => + obtain ⟨j,rfl⟩|⟨j,rfl⟩:=BoundaryInsert.cover (m:=m) k hk i + · simp only [boundary,gauge,vertexGauge,BoundaryInsert.boundary_old, + BoundaryInsert.gauge_old,Sum.elim_inl,ih] + · simp only [boundary,gauge,vertexGauge,BoundaryInsert.boundary_fresh, + BoundaryInsert.gauge_fresh,Sum.elim_inr,ihE] + | sew D k hk ih => exact ih _ + + + +def gate4 {n : ℕ} (D : TurnDisk n) (k : ℕ) (hk : k+4≤n) + (E : TurnDisk 8) : TurnDisk n := + (((D.attach E (k+4) hk).sew (k+3) (by omega)).sew (k+2) (by omega)).sew + (k+1) (by omega) |>.sew k (by omega) + +namespace Gate4 +def skip (k i : ℕ) : ℕ := if i + Graph.Used E.wiring (E.boundary (input i)) ∧ ((v=.inl (D.boundary (slot k hk i)) ∧ w=.inr (E.boundary (input i))) ∨ + (v=.inr (E.boundary (input i)) ∧ w=.inl (D.boundary (slot k hk i))))) + +end Gate4 +end TurnDisk +end +end CriticalStrip.Diagram + +end OAI diff --git a/lean/OAI/Combinatorics/StripMass/VacuumClosure.lean b/lean/OAI/Combinatorics/StripMass/VacuumClosure.lean new file mode 100644 index 0000000000000000000000000000000000000000..9136505fbf4ade063d304b99b89af84b0e077e23 --- /dev/null +++ b/lean/OAI/Combinatorics/StripMass/VacuumClosure.lean @@ -0,0 +1,422 @@ +import Mathlib +import OAI.Combinatorics.StripMass.VacuumDegree + +namespace OAI + +/-! Critical honeycomb strip paths, polynomial identities and crossing mass. -/ + + +namespace CriticalStrip.Diagram +noncomputable section +open scoped Classical BigOperators +namespace Graph +lemma closure_drains_local {V : Type*} {n : ℕ} {r : V → V → Prop} + {a : Fin n → V} {q : Pairing n} {root : Fin n} + (h : DrainsAt (boundaryClosure r a q) (a root)) : DrainsBoundary r a := by + intro v w hvw + have hr := h v w (Or.inl hvw) + clear hvw w h + induction hr using Relation.ReflTransGen.head_induction_on with + | refl => exact ⟨root, .refl⟩ + | @head x y hxy hpath ih => + rcases hxy with hxy | ⟨i,j,_,rfl,_⟩ + · obtain ⟨i,hi⟩ := ih + exact ⟨i,hi.head hxy⟩ + · exact ⟨i,.refl⟩ + +end Graph + +namespace Pairing + +def join {n : ℕ} (p q : Pairing n) (i j : Fin n) : Prop := p.Adj i j ∨ q.Adj i j + +instance join_symm {n : ℕ} (p q : Pairing n) : Std.Symm (join p q) := + ⟨fun _ _ h => h.elim (fun h => Or.inl (adj_symm h)) (fun h => Or.inr (adj_symm h))⟩ + + + +def GluesAt {n : ℕ} (root : Fin n) (p q : Pairing n) : Prop := + p.Occupied root ∧ (∀ i, p.Occupied i ↔ q.Occupied i) ∧ Graph.DrainsAt (join p q) root + +lemma GluesAt.symm {n : ℕ} {root : Fin n} {p q : Pairing n} + (h : GluesAt root p q) : GluesAt root q p := by + refine ⟨(h.2.1 root).mp h.1,fun i => (h.2.1 i).symm,?_⟩ + intro i j hij + exact Relation.ReflTransGen.mono (r := p.join q) (p := q.join p) (fun _ _ hh => hh.symm) _ _ (h.2.2 i j hij.symm) + +end Pairing + +namespace GraphRealizes +variable {V : Type*} {n : ℕ} {r : V → V → Prop} {a : Fin n → V} + {p q : Pairing n} + +lemma closure_reach (hp : GraphRealizes r a p) (i j : Fin n) : + Relation.ReflTransGen (Graph.boundaryClosure r a q) (a i) (a j) ↔ + Relation.ReflTransGen (p.join q) i j := by + constructor + · intro h + have hs : ∀ {x}, Relation.ReflTransGen (Graph.boundaryClosure r a q) (a i) x → + ∃ k, Relation.ReflTransGen (p.join q) i k ∧ Relation.ReflTransGen r (a k) x := by + intro x hx + induction hx with + | refl => exact ⟨i,.refl,.refl⟩ + | @tail x y hx hxy ih => + obtain ⟨k,hk,hr⟩ := ih + rcases hxy with hxy | ⟨l,m,hlm,hl,hm⟩ + · exact ⟨k,hk,hr.tail hxy⟩ + · subst x; subst y + have hkl : Relation.ReflTransGen (p.join q) k l := by + rcases (hp.reach k l).mp hr with rfl | hkl + · exact .refl + · exact .single (Or.inl hkl) + exact ⟨m,(hk.trans hkl).tail (Or.inr hlm),.refl⟩ + obtain ⟨k,hk,hr⟩ := hs h + rcases (hp.reach k j).mp hr with rfl | hkj + · exact hk + · exact hk.tail (Or.inl hkj) + · intro h + apply Graph.map_reach a _ h + intro k l hkl + rcases hkl with hkl | hkl + · exact Graph.closure_lift ((hp.reach k l).mpr (Or.inr hkl)) + · exact .single (Or.inr ⟨k,l,hkl,rfl,rfl⟩) + +lemma closure_drains_iff (hp : GraphRealizes r a p) (ha : Function.Injective a) + (root : Fin n) : + Graph.DrainsAt (Graph.boundaryClosure r a q) (a root) ↔ + Graph.DrainsAt (p.join q) root := by + constructor + · intro h i j hij + apply (hp.closure_reach i root).mp + rcases hij with hpij | hqij + · obtain ⟨w,hw⟩ := (hp.boundary_used_iff ha i).mpr ⟨j,hpij⟩ + exact h _ _ (Or.inl hw) + · exact h _ _ (Or.inr ⟨i,j,hqij,rfl,rfl⟩) + · intro h v w hvw + rcases hvw with hvw | ⟨i,j,hij,rfl,rfl⟩ + · obtain ⟨i,⟨j,hij⟩,hi⟩ := hp.no_loop v w hvw + exact (Graph.closure_lift hi).trans ((hp.closure_reach i root).mpr + (h i j (Or.inl hij))) + · exact (hp.closure_reach i root).mpr (h i j (Or.inr hij)) + +end GraphRealizes + +namespace Tile + +def transpose : Tile → Tile + | .diagonal₀ => .diagonal₁ + | .diagonal₁ => .diagonal₀ + | .cap => .cup + | .cup => .cap + | x => x + +def transposePort : Fin 4 → Fin 4 := ![2,3,0,1] + +@[simp] lemma transpose_transpose (t : Tile) : t.transpose.transpose = t := by cases t <;> rfl +@[simp] lemma transposePort_involutive (i : Fin 4) : transposePort (transposePort i)=i := by + fin_cases i <;> rfl +@[simp] lemma transpose_adj (t : Tile) (i j : Fin 4) : + t.transpose.Adj (transposePort i) (transposePort j) ↔ t.Adj i j := by + cases t <;> fin_cases i <;> fin_cases j <;> decide +@[simp] lemma transpose_occupied (t : Tile) (i : Fin 4) : + t.transpose.Occupied (transposePort i) ↔ t.Occupied i := by + cases t <;> fin_cases i <;> decide +@[simp] lemma weight_transpose {K : Type*} [One K] (w : Weights K) (t : Tile) : + w.tile t.transpose = w.tile t := by cases t <;> rfl + +def transposeEquiv : Tile ≃ Tile := + ⟨transpose,transpose,transpose_transpose,transpose_transpose⟩ + +end Tile + +namespace Pairing + + +def GateCompatible {n : ℕ} (p q : Pairing n) (a b : Fin n) (t : Tile) : Prop := + CutPatch.Compatible (p.cutShape a b) t ∧ + ∀ i, p.stepSupport a b t i ↔ q.Occupied i + +def flipStep {n : ℕ} : StepVertex n → StepVertex n + | .old i => .out i + | .out i => .old i + | .box i => .box (Tile.transposePort i) + +@[simp] lemma flipStep_involutive {n : ℕ} (v : StepVertex n) : flipStep (flipStep v)=v := by + cases v <;> simp [flipStep] + +lemma GateCompatible.transpose {n : ℕ} {p q : Pairing n} {a b : Fin n} + (hab : a≠b) {t : Tile} (h : GateCompatible p q a b t) : + GateCompatible q p a b t.transpose := by + have hp := (p.cutShape_compatible a b t).mp h.1 + have hqa : t.Occupied 2 ↔ q.Occupied a := by simpa [stepSupport] using h.2 a + have hqb : t.Occupied 3 ↔ q.Occupied b := by simpa [stepSupport,Ne.symm hab] using h.2 b + refine ⟨(q.cutShape_compatible a b t.transpose).mpr ?_,?_⟩ + · constructor + · exact hqa.symm.trans (t.transpose_occupied (2 : Fin 4)).symm + · exact hqb.symm.trans (t.transpose_occupied (3 : Fin 4)).symm + · intro i + by_cases hia : i=a + · subst i + simp only [stepSupport,ite_true] + exact (t.transpose_occupied (0 : Fin 4)).trans hp.1.symm + · by_cases hib : i=b + · subst i + simp only [stepSupport,ite_eq_right (Ne.symm hab),ite_true] + exact (t.transpose_occupied (1 : Fin 4)).trans hp.2.symm + · simpa [stepSupport,hia,hib] using (h.2 i).symm + + +def closedStep {n : ℕ} (p q : Pairing n) (a b : Fin n) (t : Tile) := + Graph.boundaryClosure (p.stepWiring a b t) StepVertex.out q + +lemma closedStep_flip {n : ℕ} {p q : Pairing n} {a b : Fin n} (hab : a≠b) + {t : Tile} (h : GateCompatible p q a b t) (v w : StepVertex n) : + closedStep q p a b t.transpose (flipStep v) (flipStep w) ↔ + closedStep p q a b t v w := by + have hp := (p.cutShape_compatible a b t).mp h.1 + have hqa : t.Occupied 2 ↔ q.Occupied a := by simpa [stepSupport] using h.2 a + have hqb : t.Occupied 3 ↔ q.Occupied b := by simpa [stepSupport,Ne.symm hab] using h.2 b + have ho (i : Fin n) (hia : i≠a) (hib : i≠b) : q.Occupied i ↔ p.Occupied i := by + simpa [stepSupport,hia,hib] using (h.2 i).symm + have ht0 : t.transpose.Occupied 0 ↔ t.Occupied 2 := t.transpose_occupied 2 + have ht1 : t.transpose.Occupied 1 ↔ t.Occupied 3 := t.transpose_occupied 3 + have ht2 : t.transpose.Occupied 2 ↔ t.Occupied 0 := t.transpose_occupied 0 + have ht3 : t.transpose.Occupied 3 ↔ t.Occupied 1 := t.transpose_occupied 1 + cases v with + | old i => + cases w with + | old j => simp [closedStep,Graph.boundaryClosure,stepWiring,flipStep] + | box k => + fin_cases k <;> + simp [closedStep,Graph.boundaryClosure,stepWiring,flipStep,Tile.transposePort, + ht2,ht3,←hp.1,←hp.2] + | out j => + simp only [closedStep,Graph.boundaryClosure,stepWiring,flipStep] + constructor <;> rintro (⟨hij,hia,hib,hi⟩ | ⟨k,l,_,hk,hl⟩) + · subst j; exact Or.inl ⟨rfl,hia,hib,(ho i hia hib).mp hi⟩ + · cases hl + · subst j; exact Or.inl ⟨rfl,hia,hib,(ho i hia hib).mpr hi⟩ + · cases hk + | box k => + cases w with + | old i => + fin_cases k <;> + simp [closedStep,Graph.boundaryClosure,stepWiring,flipStep,Tile.transposePort, + ht2,ht3,←hp.1,←hp.2] + | box l => simp [closedStep,Graph.boundaryClosure,stepWiring,flipStep] + | out i => + fin_cases k <;> + simp [closedStep,Graph.boundaryClosure,stepWiring,flipStep,Tile.transposePort, + hqa,hqb] + | out i => + cases w with + | old j => + simp only [closedStep,Graph.boundaryClosure,stepWiring,flipStep] + constructor <;> rintro (⟨hij,hia,hib,hi⟩ | ⟨k,l,_,hk,hl⟩) + · subst j; exact Or.inl ⟨rfl,hia,hib,(ho i hia hib).mp hi⟩ + · cases hk + · subst j; exact Or.inl ⟨rfl,hia,hib,(ho i hia hib).mpr hi⟩ + · cases hl + | box k => + fin_cases k <;> + simp [closedStep,Graph.boundaryClosure,stepWiring,flipStep,Tile.transposePort, + hqa,hqb] + | out j => simp [closedStep,Graph.boundaryClosure,stepWiring,flipStep] + + +lemma glues_tile_iff_closedStep {n : ℕ} {p q : Pairing n} {a b root : Fin n} + (hab : a.val+1=b.val) (hra : root ≠ a) (hrb : root ≠ b) (t : Tile) : + (∃ r, p.tileStep a b hab t = some r ∧ GluesAt root r q) ↔ + p.Occupied root ∧ GateCompatible p q a b t ∧ + Graph.DrainsAt (closedStep p q a b t) (.out root) := by + constructor + · rintro ⟨r,hr,hg⟩ + refine ⟨?_,⟨p.tileStep_compatible a b hab t r hr,?_⟩,?_⟩ + · have hh := (p.tileStep_support a b hab t r hr root).mp hg.1 + simpa only [stepSupport,ite_eq_right hra,ite_eq_right hrb] using hh + · intro i + exact (p.tileStep_support a b hab t r hr i).symm.trans (hg.2.1 i) + · exact ((p.stepWiring_realizes a b hab t r hr).closure_drains_iff + (fun _ _ h => StepVertex.out.inj h) root).mpr hg.2.2 + · rintro ⟨hp,hc,hd⟩ + have hn := p.tileStep_ne_none_of_drains a b hab t hc.1 + (Graph.closure_drains_local hd) + obtain ⟨r,hr⟩ := Option.ne_none_iff_exists'.mp hn + refine ⟨r,hr,?_,?_,?_⟩ + · apply (p.tileStep_support a b hab t r hr root).mpr + simpa only [stepSupport,ite_eq_right hra,ite_eq_right hrb] using hp + · intro i + exact (p.tileStep_support a b hab t r hr i).trans (hc.2 i) + · exact ((p.stepWiring_realizes a b hab t r hr).closure_drains_iff + (fun _ _ h => StepVertex.out.inj h) root).mp hd + +lemma glues_tile_flip {n : ℕ} {p q : Pairing n} {a b root : Fin n} + (hab : a.val+1=b.val) (hra : root ≠ a) (hrb : root ≠ b) (t : Tile) + (h : ∃ r, p.tileStep a b hab t = some r ∧ GluesAt root r q) : + ∃ r, q.tileStep a b hab t.transpose = some r ∧ GluesAt root r p := by + obtain ⟨hp,hc,hd⟩ := (glues_tile_iff_closedStep hab hra hrb t).mp h + have hne : a≠b := by intro hh; have := congrArg Fin.val hh; omega + have hq : q.Occupied root := (hc.2 root).mp + (by simpa only [stepSupport,ite_eq_right hra,ite_eq_right hrb] using hp) + apply (glues_tile_iff_closedStep hab hra hrb t.transpose).mpr + refine ⟨hq,hc.transpose hne,?_⟩ + have hf := hd.map (Function.Involutive.toPerm (@flipStep n) flipStep_involutive) + (closedStep_flip hne hc) + apply hf.mono_root + exact .single (Or.inl ⟨rfl,hra,hrb,hq⟩) + + + +theorem glues_tile_adjoint {n : ℕ} {p q : Pairing n} {a b root : Fin n} + (hab : a.val+1=b.val) (hra : root ≠ a) (hrb : root ≠ b) (t : Tile) : + (∃ r, p.tileStep a b hab t = some r ∧ GluesAt root r q) ↔ + (∃ r, q.tileStep a b hab t.transpose = some r ∧ GluesAt root p r) := by + constructor + · intro h + obtain ⟨r,hr,hg⟩ := glues_tile_flip hab hra hrb t h + exact ⟨r,hr,hg.symm⟩ + · rintro ⟨r,hr,hg⟩ + simpa only [Tile.transpose_transpose] using glues_tile_flip hab hra hrb + t.transpose ⟨r,hr,hg.symm⟩ + +lemma gluesAt_comm {n : ℕ} (root : Fin n) (p q : Pairing n) : + GluesAt root p q ↔ GluesAt root q p := ⟨GluesAt.symm,GluesAt.symm⟩ + +end Pairing + + + +def glueMatrix {K : Type*} [Zero K] [One K] {n : ℕ} (root : Fin n) : + Matrix (Pairing n) (Pairing n) K := + fun p q => if Pairing.GluesAt root p q then 1 else 0 + +lemma glueMatrix_transpose {K : Type*} [Zero K] [One K] {n : ℕ} (root : Fin n) : + (glueMatrix root : Matrix _ _ K).transpose = glueMatrix root := by + ext p q + simp only [Matrix.transpose_apply,glueMatrix,Pairing.gluesAt_comm root q p] + +lemma mul_optionMatrix_apply {K P Q R : Type*} [Semiring K] [Fintype Q] + (A : Matrix R Q K) (f : P → Option Q) (r : R) (p : P) : + (A * (optionMatrix f : Matrix Q P K)) r p = (f p).elim 0 (A r) := by + rcases Option.eq_none_or_eq_some (f p) with h | ⟨q,h⟩ + · simp [Matrix.mul_apply,optionMatrix,h] + · simp [Matrix.mul_apply,optionMatrix,h,mul_ite] + +lemma transpose_optionMatrix_mul_apply {K P Q R : Type*} [Semiring K] [Fintype Q] + (A : Matrix Q R K) (f : P → Option Q) (p : P) (r : R) : + ((optionMatrix f : Matrix Q P K).transpose * A) p r = (f p).elim 0 (fun q => A q r) := by + rcases Option.eq_none_or_eq_some (f p) with h | ⟨q,h⟩ + · simp [Matrix.mul_apply,optionMatrix,h] + · simp [Matrix.mul_apply,optionMatrix,h,ite_mul] + +lemma tileMatrix_glue_adjoint {K : Type*} [Semiring K] {n : ℕ} (a : Position n) + (root : Fin n) (hra : root≠a.left) (hrb : root≠a.right) (t : Tile) : + (glueMatrix root : Matrix _ _ K) * + optionMatrix (fun p => p.tileStep a.left a.right a.adjacent t) = + (optionMatrix (fun p => p.tileStep a.left a.right a.adjacent t.transpose)).transpose * + glueMatrix root := by + ext q p + rw [mul_optionMatrix_apply,transpose_optionMatrix_mul_apply] + have hh := Pairing.glues_tile_adjoint (p:=p) (q:=q) a.adjacent hra hrb t + rcases Option.eq_none_or_eq_some (p.tileStep a.left a.right a.adjacent t) with hp | ⟨r,hp⟩ + <;> rcases Option.eq_none_or_eq_some (q.tileStep a.left a.right a.adjacent t.transpose) + with hq | ⟨s,hq⟩ + · simp [hp,hq] + · have hs : ¬ Pairing.GluesAt root p s := by simpa [hp,hq] using hh.symm + simpa [hp,hq,glueMatrix,Pairing.gluesAt_comm root s p] using + (ite_eq_right hs : (if Pairing.GluesAt root p s then (1:K) else 0) = 0).symm + · have hr : ¬ Pairing.GluesAt root r q := by simpa [hp,hq] using hh + simp [hp,hq,glueMatrix,Pairing.gluesAt_comm root q r,hr] + · have he : Pairing.GluesAt root r q ↔ Pairing.GluesAt root p s := by + simpa [hp,hq] using hh + simp only [hp,hq,Option.elim_some,glueMatrix,Pairing.gluesAt_comm root q r, + Pairing.gluesAt_comm root s p,he] + + + +theorem localR_glue_adjoint {K : Type*} [CommRing K] {n : ℕ} (a : Position n) + (root : Fin n) (hra : root≠a.left) (hrb : root≠a.right) (w : Weights K) : + (glueMatrix root : Matrix _ _ K) * localR a w = (localR a w).transpose * glueMatrix root := by + simp only [localR,Finset.mul_sum,Matrix.mul_smul,Finset.sum_mul, + Matrix.transpose_sum,Matrix.transpose_smul,Matrix.smul_mul] + rw [← Equiv.sum_comp Tile.transposeEquiv] + apply Finset.sum_congr rfl + intro t _ + simp only [Tile.transposeEquiv,Equiv.coe_fn_mk,Tile.weight_transpose] + rw [tileMatrix_glue_adjoint a root hra hrb] + simp only [Tile.transpose_transpose] + + + + + + + +def sourceBlock {K : Type*} {n m : ℕ} + (M : Matrix (Pairing (m+1)) (Pairing (n+1)) K) : + Matrix (SourcePairing m) (SourcePairing n) K := fun p q => M p.val q.val + +lemma LastMatrix.source_mulVec {K : Type*} [CommRing K] {n m : ℕ} + {M : Matrix (Pairing (m+1)) (Pairing (n+1)) K} (hM : LastMatrix M) + (V : Pairing (n+1) → K) (p : SourcePairing m) : + M.mulVec V p.val = (sourceBlock M).mulVec (fun q => V q.val) p := by + simp only [Matrix.mulVec, dotProduct, sourceBlock] + symm + apply Fintype.sum_of_injective Subtype.val Subtype.val_injective + · intro q hq + have hn : ¬q.Occupied (Fin.last n) := by + intro h + exact hq ⟨⟨q,h⟩,rfl⟩ + rw [hM p.val q (by simp [p.property, hn]), zero_mul] + · intro q; rfl + +lemma LastMatrix.source_coeff {K : Type*} [CommRing K] {n m : ℕ} + {M : Matrix (Pairing (m+1)) (Pairing (n+1)) K} (hM : LastMatrix M) + (V : Pairing (n+1) → Polynomial K) (p : SourcePairing m) (k : ℕ) : + (matrixPolynomial M V p.val).coeff k = + (sourceBlock M).mulVec (fun q => (V q.val).coeff k) p := by + rw [matrixPolynomial_coeff, hM.source_mulVec] + + +lemma northNumerator_covariance {n : ℕ} (r : ℕ) (hr : r+2≤n) : + northNumerator n = + (sourceBlock (localR (PartialColumn.rowPosition r hr).padTop + (torusWeights (variableF ⟨r+1,by omega⟩ / variableF ⟨r,by omega⟩)))).mulVec + (fun p => permSpectral (Equiv.swap ⟨r,by omega⟩ ⟨r+1,by omega⟩) + (northNumerator n p)) := by + funext p + have hh := congrArg (fun U : Pairing (n+1) → Polynomial (SpectralField n) => + (U p.val).coeff (n-1)) (rationalNodalPolynomial_covariance r hr) + rw [nodalExchangePolynomial_coeff] at hh + change northNumerator n p = _ at hh + exact hh.trans ((LastMatrix.local _ _).source_mulVec _ p) + +lemma northNumerator_parity {n : ℕ} (k : Fin n) (p : SourcePairing n) : + signSpectral k (northNumerator n p) = + occupancySign p.val k.castSucc * northNumerator n p := by + have h := congrArg (fun P : Polynomial (SpectralField n) => P.coeff (n-1)) + (rationalNodalPolynomial_parity k p.val) + simpa [northNumerator] using h + + + +lemma LastDegree.occupied_mul_top {K : Type*} [CommRing K] {n m d : ℕ} + (P : Pairing (n+1) → Polynomial K) (hP : LastDegree m P) + (F : Polynomial K) (hF : F.natDegree ≤ d) (q : Pairing (n+1)) + (hq : q.Occupied (Fin.last n)) (hm : 1 ≤ m) : + (F*P q).coeff (m+d-1) = F.coeff d * (P q).coeff (m-1) := by + rw [show m+d-1=d+(m-1) by omega] + apply Polynomial.coeff_mul_add_eq_of_natDegree_le hF + exact Polynomial.natDegree_le_iff_coeff_eq_zero.mpr + (fun k hk => hP q k (by simp only [hq,ite_true]; omega)) + + +lemma isEmpty_source_zero : IsEmpty (SourcePairing 0) := + ⟨fun p => p.ne_empty (p.val.eq_empty_of_le_one (by omega))⟩ + + + +end +end CriticalStrip.Diagram + +end OAI diff --git a/lean/OAI/Combinatorics/StripMass/VacuumDegree.lean b/lean/OAI/Combinatorics/StripMass/VacuumDegree.lean new file mode 100644 index 0000000000000000000000000000000000000000..1a5f352f5e942e001bee49a22ac788372f28f6ce --- /dev/null +++ b/lean/OAI/Combinatorics/StripMass/VacuumDegree.lean @@ -0,0 +1,420 @@ +import Mathlib +import OAI.Combinatorics.StripMass.NodalEmpty + +namespace OAI + +/-! Critical honeycomb strip paths, polynomial identities and crossing mass. -/ + + + +namespace CriticalStrip.Diagram +noncomputable section +open scoped Classical + +lemma polynomial_eval₂_fin {K L:Type*} [CommRing K] [CommRing L] + (f:K →+* L) (P:Polynomial K) (x:L) (n:ℕ) (h:∀k,n≤k → P.coeff k=0) : + P.eval₂ f x=∑j:Fin n,f (P.coeff j.val)*x^j.val := by + rw [Polynomial.eval₂_eq_sum,Polynomial.sum_def,Fin.sum_univ_eq_sum_range (fun k =>f (P.coeff k)*x^k) n] + apply Finset.sum_subset + · intro k hk + simp only [Finset.mem_range] + by_contra hnot + exact Polynomial.mem_support_iff.mp hk (h k (Nat.le_of_not_gt hnot)) + · intro k hk hnot + rw [(not_ne_iff.mp (fun hne =>hnot (Polynomial.mem_support_iff.mpr hne))),map_zero,zero_mul] + + +def polynomialVacuumVector : (n:ℕ) → Pairing n → Laurent n + | 0 =>fun _ =>1 + | n+1 =>(vacuumData n).W + +lemma polynomialVacuumVector_eval (n:ℕ) (p:Pairing n) : + evalLaurent (polynomialVacuumVector n p)=rationalVacuum n p := by + cases n with + | zero =>rw [rationalVacuum_zero]; exact map_one _ + | succ n =>exact (vacuumData n).eval_P p + +lemma vacuumData_leading (n:ℕ) (p:Pairing n) : + ((vacuumData n).P p.padTop).coeff n=polynomialVacuumVector n p := by + apply IsFractionRing.injective (SpectralRing n) (SpectralField n) + rw [←Polynomial.coeff_map,(vacuumData n).map_P,rationalNodalPolynomial_leading] + exact (polynomialVacuumVector_eval n p).symm + + + +theorem vacuum_degree : PolynomialVacuum := by + refine ⟨polynomialVacuumVector,rfl,?_,?_,?_,?_⟩ + · exact polynomialVacuumVector_eval + · intro n p e he i + cases n with + | zero =>exact Fin.elim0 i + | succ n => + have h:LaurentBox ((vacuumData n).W p) (fun _ =>2*n):=(vacuumData n).box p + exact abs_le.mpr (h e (Finsupp.mem_support_iff.mp he) i) + · intro n p + refine ⟨fun j =>((vacuumData n).P p.padTop).coeff j.val,?_⟩ + change lastLaurent p.padTop ((vacuumData n).P p.padTop)=_ + simp only [lastLaurent,Pairing.padTop_not_occupied_last,ite_false,one_mul] + rw [polynomial_eval₂_fin (liftLaurentHom n) _ _ (n+1) (fun k hk => + (vacuumData n).degree p.padTop k (by simp only [Pairing.padTop_not_occupied_last,ite_false]; omega))] + rw [Fin.sum_univ_castSucc] + simp only [Fin.val_castSucc,Fin.val_last,liftLaurentHom_apply,vacuumData_leading] + exact add_comm _ _ + · intro n p hp + refine ⟨fun j =>((vacuumData n).P p).coeff j.val,?_⟩ + change lastLaurent p ((vacuumData n).P p)=_ + rw [lastLaurent,ite_eq_left hp] + rw [polynomial_eval₂_fin (liftLaurentHom n) _ _ n (fun k hk => + (vacuumData n).degree p k (by simpa only [hp,ite_true] using hk))] + rfl + +end + + + + +theorem vacuum_degree_remaining : PolynomialVacuum := vacuum_degree + + +theorem vacuum_interpolation_stationary_remaining (n : ℕ) : + rationalInterpolationResidual n = 0 := by + funext p + exact vacuum_interpolation_stationary n p + + + + +noncomputable section +open scoped BigOperators Classical + + + +abbrev SourcePairing (n : ℕ) := {p : Pairing (n+1) // p.Occupied (Fin.last n)} + +@[simp] lemma SourcePairing.occupied {n : ℕ} (p : SourcePairing n) : + p.val.Occupied (Fin.last n) := p.property + +lemma SourcePairing.ne_empty {n : ℕ} (p : SourcePairing n) : p.val ≠ empty (n+1) := by + intro h + exact empty_not_occupied (Fin.last n) (h ▸ p.property) + +def sourceTopEquiv (n : ℕ) : SourcePairing n ≃ Pairing.TopOccupiedNonempty n where + toFun p := ⟨⟨p.val, p.ne_empty⟩, not_not.mpr p.property⟩ + invFun p := ⟨p.val.val, not_not.mp p.property⟩ + left_inv _ := rfl + right_inv _ := rfl + +def sourceTopSplit (n : ℕ) : NonemptyPairing n ⊕ SourcePairing n ≃ NonemptyPairing (n+1) := + (Equiv.sumCongr (Equiv.refl _) (sourceTopEquiv n)).trans (Pairing.nonemptyTopSplit n) + +@[simp] lemma sourceTopSplit_inl {n : ℕ} (p : NonemptyPairing n) : + sourceTopSplit n (Sum.inl p) = Pairing.nonemptyPadTop p := rfl + +@[simp] lemma sourceTopSplit_inr_val {n : ℕ} (p : SourcePairing n) : + (sourceTopSplit n (Sum.inr p)).val = p.val := rfl + + + +def horizontalWeights {K : Type*} [Zero K] [One K] : Weights K := ⟨0,1,0,0,0⟩ + +def sourceTransfer {K : Type*} [CommRing K] {n : ℕ} (w : Fin n → Tile → K) : + Matrix (SourcePairing n) (SourcePairing n) K := + fun q p => lastCoefficient w q.val p.val + +def northSource {K : Type*} [CommRing K] {n : ℕ} (w : Fin n → Tile → K) : + Matrix (SourcePairing n) (Pairing n) K := + fun q p => lastCoefficient w q.val p.padTop + +lemma horizontal_column_blocks {K : Type*} [CommRing K] {n : ℕ} + (w : Fin n → Weights K) : + (restrictedColumn (Fin.snoc w horizontalWeights)).submatrix (sourceTopSplit n) (sourceTopSplit n) = + Matrix.fromBlocks (restrictedColumn w) 0 0 (sourceTransfer (fun i => (w i).tile)) := by + ext q p + have hw : (fun i => ((Fin.snoc w horizontalWeights : Fin (n+1) → Weights K) i).tile) = + Fin.snoc (fun i => (w i).tile) (horizontalWeights : Weights K).tile := by + funext i + refine Fin.lastCases ?_ (fun i => ?_) i <;> simp + change rawColumn _ _ _ = _ + rw [hw, rawColumn_last_factor] + cases q with + | inl q => + cases p with + | inl p => simp [lastCoefficient_padTop, lastTile, Weights.tile, + restrictedColumn, sourceTopSplit_inl, Pairing.nonemptyPadTop]; rfl + | inr p => simp [Matrix.fromBlocks, lastTile, p.property, horizontalWeights, Weights.tile, + Pairing.nonemptyPadTop] + | inr q => + cases p with + | inl p => simp [Matrix.fromBlocks, lastTile, q.property, horizontalWeights, Weights.tile, + Pairing.nonemptyPadTop] + | inr p => simp [Matrix.fromBlocks, lastTile, q.property, p.property, horizontalWeights, + Weights.tile, sourceTransfer] + +lemma det_horizontal_column {K : Type*} [CommRing K] {n : ℕ} (w : Fin n → Weights K) : + (1 - restrictedColumn (Fin.snoc w horizontalWeights)).det = + (1 - restrictedColumn w).det * (1 - sourceTransfer (fun i => (w i).tile)).det := by + rw [← Matrix.det_submatrix_equiv_self (sourceTopSplit n)] + simp only [Matrix.submatrix_sub, Pi.sub_apply, Matrix.submatrix_one_equiv, horizontal_column_blocks] + have h : 1 - Matrix.fromBlocks (restrictedColumn w) 0 0 (sourceTransfer (fun i => (w i).tile)) = + Matrix.fromBlocks (1 - restrictedColumn w) 0 0 + (1 - sourceTransfer (fun i => (w i).tile)) := by + ext q p + cases q <;> cases p <;> simp [Matrix.fromBlocks, Matrix.one_apply] + rw [h, Matrix.det_fromBlocks_zero₂₁] + +lemma sourceTransfer_regular_of_horizontal {K : Type*} [Field K] {n : ℕ} + (w : Fin n → Weights K) (h : VacuumRegular (Fin.snoc w horizontalWeights)) : + (1 - sourceTransfer (fun i => (w i).tile)).det ≠ 0 := by + unfold VacuumRegular at h + rw [det_horizontal_column] at h + exact (mul_ne_zero_iff.mp h).2 + +lemma horizontal_spectral_regular (n : ℕ) : + VacuumRegular (Fin.snoc (spectralWeights n) horizontalWeights) := by + apply regular_of_cleared_specialization + (algebraMap (SpectralRing n) (SpectralField n)) (IsFractionRing.injective _ _) + (flatEval n).toRingHom (Fin.snoc rowDenominator 1) + (Fin.snoc rowNumerator (horizontalWeights : Weights (SpectralRing n)).tile) + (Fin.snoc (spectralWeights n) horizontalWeights) + (Fin.snoc (fun _ => deletionWeights) horizontalWeights) + · intro i + refine Fin.lastCases ?_ (fun i => ?_) i + · simp + · simpa using flatEval_rowDenominator_ne_zero i + · intro i + refine Fin.lastCases ?_ (fun i => ?_) i + · intro t; cases t <;> simp [horizontalWeights, Weights.tile] + · intro t; simpa using rowNumerator_map i t + · intro i + refine Fin.lastCases ?_ (fun i => ?_) i + · intro t; cases t <;> simp [horizontalWeights, Weights.tile] + · intro t; simpa using rowNumerator_flatEval i t + · unfold VacuumRegular + rw [det_one_nonflat] + · exact one_ne_zero + · intro i j hi hj + have hh : ∀ k : Fin (n+1), + ¬((Fin.snoc (fun _ : Fin n => (deletionWeights : Weights ℂ)) horizontalWeights : Fin (n+1) → Weights ℂ) k).IsFlat → + k = Fin.last n := by + intro k + refine Fin.lastCases ?_ (fun k => ?_) k + · intro _; rfl + · intro hk; exact (hk (Or.inr (by simp))).elim + exact (hh i hi).trans (hh j hj).symm + + + +lemma spectral_source_regular (n : ℕ) : + (1 - sourceTransfer (fun i => (spectralWeights n i).tile)).det ≠ 0 := + sourceTransfer_regular_of_horizontal _ (horizontal_spectral_regular n) + +lemma rationalResidualCoefficient_zero (n : ℕ) (p : Pairing (n+1)) : + rationalResidualCoefficient n p = 0 := by + have h := rationalInterpolationResidual_factor p + rw [vacuum_interpolation_stationary] at h + have hden : (∏ i : Fin n, evalLaurent (rowDenominator i.castSucc)) / 2 ≠ 0 := + div_ne_zero (Finset.prod_ne_zero_iff.mpr (fun i _ => rowDenominator_map_ne_zero i.castSucc)) + (by norm_num) + have hs : (if p.Occupied (Fin.last n) then torusSin (variableF (Fin.last n)) else 1) ≠ 0 := by + split_ifs + · exact torusSin_monomial_ne_zero _ (by + intro hh + have hh' := congrFun hh (Fin.last n) + simp [variableExponent] at hh') 1 one_ne_zero + · exact one_ne_zero + have hnod : (Lagrange.nodal Finset.univ (@deletionBeta n)).eval₂ + (liftSpectral n) (spectralA (Fin.last n)) ≠ 0 := by + simp only [Lagrange.nodal, Polynomial.eval₂_finsetProd, Polynomial.eval₂_sub, + Polynomial.eval₂_X, Polynomial.eval₂_C] + apply Finset.prod_ne_zero_iff.mpr + intro i _ + have hi : liftSpectral n (deletionBeta i) = deletionBeta i.castSucc := by + simp [deletionBeta, deletionNode, map_div₀] + rw [hi] + exact sub_ne_zero.mpr (spectralA_ne_beta i.castSucc (Fin.last n)) + have hh : liftSpectral n (rationalResidualCoefficient n p) = 0 := by + rcases mul_eq_zero.mp h.symm with h | h + · exact (mul_eq_zero.mp h).resolve_left (mul_ne_zero hden hs) + · exact (hnod h).elim + exact (liftSpectral n).injective (by simpa using hh) + + + +lemma rationalResidualPolynomial_zero (n : ℕ) (p : Pairing (n+1)) : + rationalResidualPolynomial n p = 0 := by + rw [rationalResidualPolynomial_factor, rationalResidualCoefficient_zero] + simp + +def vacantTopEquiv (n : ℕ) : + Pairing n ≃ {p : Pairing (n+1) // ¬p.Occupied (Fin.last n)} where + toFun p := ⟨p.padTop, p.padTop_not_occupied_last⟩ + invFun p := p.val.restrict Fin.castSuccOrderEmb + left_inv _ := Pairing.restrict_map _ _ + right_inv p := Subtype.ext (Pairing.padTop_restrict _ p.property) + +def pairingTopSplit (n : ℕ) : Pairing n ⊕ SourcePairing n ≃ Pairing (n+1) := + (Equiv.sumCongr (vacantTopEquiv n) + (Equiv.subtypeEquivRight (fun _ => not_not.symm))).trans + (Equiv.sumCompl (fun p : Pairing (n+1) => ¬p.Occupied (Fin.last n))) + +@[simp] lemma pairingTopSplit_inl {n : ℕ} (p : Pairing n) : + pairingTopSplit n (Sum.inl p) = p.padTop := rfl + +@[simp] lemma pairingTopSplit_inr {n : ℕ} (p : SourcePairing n) : + pairingTopSplit n (Sum.inr p) = p.val := rfl + + + +lemma lastTransform_source_leading {K : Type*} [CommRing K] {n : ℕ} + (w : Fin n → Tile → K) (d c C : K) (P : Pairing (n+1) → Polynomial K) + (hP : LastDegree n P) (hn : 1 ≤ n) (q : SourcePairing n) : + (lastTransform w d c C P q.val).coeff n = + (sourceTransfer w).mulVec (fun p => (P p.val).coeff (n-1)) q + + (2*d) * (northSource w).mulVec (fun p => (P p.padTop).coeff n) q := by + obtain ⟨k, rfl⟩ := Nat.exists_eq_succ_of_ne_zero (by omega : n ≠ 0) + rw [lastTransform_coeff_succ, ← (pairingTopSplit (k+1)).sum_comp] + simp only [Fintype.sum_sum_type, pairingTopSplit_inl, pairingTopSplit_inr, + q.property, Pairing.padTop_not_occupied_last, ite_true, ite_false] + have hzero (p : SourcePairing (k+1)) : (P p.val).coeff (k+1) = 0 := + hP p.val (k+1) (by simp [p.property]) + simp only [hzero, mul_zero, sub_zero, sourceTransfer, + northSource, Matrix.mulVec, dotProduct, Finset.mul_sum] + simp only [SourcePairing.occupied, ite_true, Nat.succ_sub_one] + rw [add_comm] + congr 1 + apply Finset.sum_congr rfl + intro p _ + ring + + +def northNumerator (n : ℕ) (p : SourcePairing n) : SpectralField n := + (rationalNodalPolynomial n p.val).coeff (n-1) + +lemma northNumerator_equation (n : ℕ) : + (1 - sourceTransfer (fun i => (spectralWeights n i).tile)).mulVec (northNumerator n) = + (2*constF n d) • (northSource (fun i => (spectralWeights n i).tile)).mulVec (rationalVacuum n) := by + classical + by_cases hn : 1 ≤ n + · have hs (q : SourcePairing n) := congrArg (fun p : Polynomial (SpectralField n) => p.coeff n) + (sub_eq_zero.mp (rationalResidualPolynomial_zero n q.val)) + funext q + have hz (k : ℕ) (hk : n ≤ k) : (rationalNodalPolynomial n q.val).coeff k = 0 := + rationalNodalPolynomial_degree n q.val k (by simpa [q.property] using hk) + obtain ⟨k, rfl⟩ := Nat.exists_eq_succ_of_ne_zero (by omega : n ≠ 0) + have hh := hs q + change (lastTransform _ _ _ _ _ q.val).coeff (k+1) = + ((Polynomial.X + Polynomial.C _) * rationalNodalPolynomial (k+1) q.val).coeff (k+1) at hh + rw [lastTransform_source_leading _ _ _ _ _ (rationalNodalPolynomial_degree _) (by omega)] at hh + simp only [rationalNodalPolynomial_leading, add_mul, Polynomial.coeff_add, + Polynomial.coeff_X_mul, Polynomial.coeff_C_mul, hz (k+1) (by omega), mul_zero, add_zero] at hh + simp only [Matrix.sub_mulVec, Matrix.one_mulVec, Pi.sub_apply, Pi.smul_apply, smul_eq_mul, + northNumerator] + change (rationalNodalPolynomial (k+1) q.val).coeff k - + (sourceTransfer (fun i => (spectralWeights (k+1) i).tile)).mulVec + (fun p => (rationalNodalPolynomial (k+1) p.val).coeff k) q = _ + simp only [Nat.add_sub_cancel] at hh + linear_combination -hh + · have hn : n = 0 := by omega + subst n + funext p + exact (p.ne_empty (p.val.eq_empty_of_le_one (by omega))).elim + + + +def integratedNorthSource (n : ℕ) : SourcePairing n → SpectralField n := + (1 - sourceTransfer (fun i => (spectralWeights n i).tile))⁻¹.mulVec + ((northSource (fun i => (spectralWeights n i).tile)).mulVec + (normalizedVacuum (spectralWeights n))) + +lemma northNumerator_eq_integrated (n : ℕ) : + northNumerator n = (2*constF n d * spectralNormalization n) • integratedNorthSource n := by + have h := congrArg (fun v => + (1 - sourceTransfer (fun i => (spectralWeights n i).tile))⁻¹.mulVec v) + (northNumerator_equation n) + rw [Matrix.mulVec_mulVec, Matrix.nonsing_inv_mul _ (isUnit_iff_ne_zero.mpr (spectral_source_regular n)), + Matrix.one_mulVec, Matrix.mulVec_smul] at h + change _ = (2*constF n d) • + (1 - sourceTransfer (fun i => (spectralWeights n i).tile))⁻¹.mulVec + ((northSource (fun i => (spectralWeights n i).tile)).mulVec + (spectralNormalization n • normalizedVacuum (spectralWeights n))) at h + rw [Matrix.mulVec_smul, Matrix.mulVec_smul, smul_smul] at h + exact h + + + +def polynomialNorthSource (n : ℕ) (p : SourcePairing n) : Laurent n := + constantL n (1/(2*(d:ℂ))) * ((vacuumData n).P p.val).coeff (n-1) + +lemma polynomialNorthSource_eval (n : ℕ) (p : SourcePairing n) : + evalLaurent (polynomialNorthSource n p) = + spectralNormalization n * integratedNorthSource n p := by + have hd : constF n d ≠ 0 := + (map_ne_zero (algebraMap ℂ (SpectralField n))).mpr (by exact_mod_cast d_ne_zero) + have ht := congrFun (northNumerator_eq_integrated n) p + simp only [Pi.smul_apply, smul_eq_mul] at ht + unfold polynomialNorthSource + rw [show evalLaurent ((constantL n (1/(2*(d:ℂ)))) * ((vacuumData n).P p.val).coeff (n-1)) = + evalLaurent (constantL n (1/(2*(d:ℂ)))) * evalLaurent (((vacuumData n).P p.val).coeff (n-1)) from + (algebraMap (SpectralRing n) (SpectralField n)).map_mul _ _, show evalLaurent (constantL n (1/(2*(d:ℂ)))) = 1/(2*constF n d) by + rw [evalLaurent, map_constantL] + change (algebraMap ℂ (SpectralField n)) (1/(2*(d:ℂ))) = _ + rw [map_div₀, map_one, map_mul, map_ofNat] + rfl] + have hc : evalLaurent (((vacuumData n).P p.val).coeff (n-1)) = northNumerator n p := by + rw [evalLaurent, ←Polynomial.coeff_map, (vacuumData n).map_P] + rfl + rw [hc, ht] + field_simp + + + +theorem polynomialNorthSource_box (n : ℕ) (p : SourcePairing n) : + LaurentBox (polynomialNorthSource n p) (fun _ => 2*n) := by + simpa only [polynomialNorthSource, zero_add] using (LaurentBox.constant (1/(2*(d:ℂ)))).mul + ((vacuumData n).box_P p.val (n-1)) + +end + + + + +noncomputable section +open scoped Classical BigOperators + +namespace Graph + + +def DrainsAt {V : Type*} (r : V → V → Prop) (root : V) : Prop := + ∀ v w, r v w → Relation.ReflTransGen r v root + +lemma DrainsAt.mono_root {V : Type*} {r : V → V → Prop} {a b : V} + (h : DrainsAt r a) (hab : Relation.ReflTransGen r a b) : DrainsAt r b := + fun _ _ hvw => (h _ _ hvw).trans hab + +lemma DrainsAt.map {V W : Type*} {r : V → V → Prop} {s : W → W → Prop} + (e : V ≃ W) (he : ∀ v w, s (e v) (e w) ↔ r v w) {root : V} + (h : DrainsAt r root) : DrainsAt s (e root) := by + intro x y hxy + obtain ⟨v,rfl⟩ := e.surjective x + obtain ⟨w,rfl⟩ := e.surjective y + exact Graph.map_reach e (fun v w hvw => .single ((he v w).mpr hvw)) + (h v w ((he v w).mp hxy)) + + + +def boundaryClosure {V : Type*} {n : ℕ} (r : V → V → Prop) (a : Fin n → V) + (q : Pairing n) (v w : V) : Prop := + r v w ∨ ∃ i j, q.Adj i j ∧ a i = v ∧ a j = w + +lemma closure_lift {V : Type*} {n : ℕ} {r : V → V → Prop} {a : Fin n → V} + {q : Pairing n} {v w : V} (h : Relation.ReflTransGen r v w) : + Relation.ReflTransGen (boundaryClosure r a q) v w := + Relation.ReflTransGen.mono (fun _ _ hh => Or.inl hh) _ _ h + + + +end Graph +end +end CriticalStrip.Diagram + +end OAI diff --git a/lean/OAI/Combinatorics/StripMass/WeightComparison.lean b/lean/OAI/Combinatorics/StripMass/WeightComparison.lean new file mode 100644 index 0000000000000000000000000000000000000000..cad1fcf9317fe8a7bce89f6efc6e7ad1404f4d79 --- /dev/null +++ b/lean/OAI/Combinatorics/StripMass/WeightComparison.lean @@ -0,0 +1,430 @@ +import Mathlib +import OAI.Combinatorics.StripMass.CoordinateBoxes + +namespace OAI + +/-! Critical honeycomb strip paths, polynomial identities and crossing mass. -/ + + +namespace CriticalStrip +noncomputable section +open scoped BigOperators +open Set MeasureTheory +lemma hasDerivAt_omegaLogHalf {x : ℝ} (hx : x ∈ Ioo 0 1) : + HasDerivAt omegaLogHalf + ((1 - 2 * x - (Real.sqrt ((1 + x) / (2 * x)))⁻¹) / (4 * x * (1 - x))) x := by + have hx0 : x ≠ 0 := hx.1.ne' + have hd : (2 : ℝ) * x ≠ 0 := mul_ne_zero (by norm_num) hx0 + have hr : 1 < (1 + x) / (2 * x) := (lt_div_iff₀ (by linarith [hx.1])).2 (by linarith [hx.2]) + have ht : 1 < Real.sqrt ((1 + x) / (2 * x)) := by + nlinarith [Real.sq_sqrt (by linarith : 0 ≤ (1 + x) / (2 * x)), Real.sqrt_nonneg ((1 + x) / (2 * x))] + have hs : 0 < Real.sqrt (Real.sqrt ((1 + x) / (2 * x)) - 1) := Real.sqrt_pos.mpr (by linarith) + have hs2 := Real.sq_sqrt (by linarith : 0 ≤ Real.sqrt ((1 + x) / (2 * x)) - 1) + have ht2 := Real.sq_sqrt (by linarith : 0 ≤ (1 + x) / (2 * x)) + have ht2' : 2 * x * (Real.sqrt ((1 + x) / (2 * x))) ^ 2 = 1 + x := by + rw [ht2] + exact mul_div_cancel₀ (1 + x) hd + have hdr : HasDerivAt (fun y : ℝ => (1 + y) / (2 * y)) (-1 / (2 * x ^ 2)) x := by + apply (((hasDerivAt_id x).const_add 1).div ((hasDerivAt_id x).const_mul 2) hd).congr_deriv + dsimp + field_simp + ring + have hω := (((hdr.sqrt (by linarith : (1 + x) / (2 * x) ≠ 0)).sub_const 1).sqrt + (by linarith : Real.sqrt ((1 + x) / (2 * x)) - 1 ≠ 0)).const_mul (1 / 2 : ℝ) + have hdω : HasDerivAt omega + (-1 / (16 * x ^ 2 * Real.sqrt ((1 + x) / (2 * x)) * + Real.sqrt (Real.sqrt ((1 + x) / (2 * x)) - 1))) x := by + apply hω.congr_deriv + field_simp + ring + have hdlog := (hdω.log (omega_pos hx).ne').add + (((hasDerivAt_id x).log hx0).const_mul (1 / 2 : ℝ)) + apply hdlog.congr_deriv + dsimp only [omega, id_eq] + have ht0 : Real.sqrt ((1 + x) / (2 * x)) ≠ 0 := by linarith + have hs0 := hs.ne' + have hx1 : 1 - x ≠ 0 := by linarith [hx.2] + generalize htdef : Real.sqrt ((1 + x) / (2 * x)) = t at * + generalize hsdef : Real.sqrt (t - 1) = s at * + field_simp + ring_nf + rw [hs2] + nlinarith [ht2'] + + + +lemma omegaLogHalf_derivative_lower {x : ℝ} (hx : x ∈ Ioc 0 (1 / 2 : ℝ)) : + -4 ≤ (1 - 2 * x - (Real.sqrt ((1 + x) / (2 * x)))⁻¹) / (4 * x * (1 - x)) := by + have hr : 1 ≤ (1 + x) / (2 * x) := (le_div_iff₀ (by linarith [hx.1])).2 (by linarith [hx.2]) + have ht : 1 ≤ Real.sqrt ((1 + x) / (2 * x)) := Real.one_le_sqrt.mpr hr + have hinv : (Real.sqrt ((1 + x) / (2 * x)))⁻¹ ≤ 1 := by + simpa using inv_anti₀ (by norm_num : (0 : ℝ) < 1) ht + have hdp : 0 < 4 * x * (1 - x) := mul_pos (by linarith [hx.1]) (by linarith [hx.2]) + by_cases hsmall : x ≤ 1 / 8 + · have ht4 : (2 : ℝ) ^ 2 ≤ (1 + x) / (2 * x) := + (le_div_iff₀ (by linarith [hx.1])).2 (by nlinarith) + have ht2 : 2 ≤ Real.sqrt ((1 + x) / (2 * x)) := by + nlinarith [Real.sq_sqrt (by linarith : 0 ≤ (1 + x) / (2 * x)), Real.sqrt_nonneg ((1 + x) / (2 * x))] + have hinv2 : (Real.sqrt ((1 + x) / (2 * x)))⁻¹ ≤ 1 / 2 := by + simpa using inv_anti₀ (by norm_num : (0 : ℝ) < 2) ht2 + have : 0 ≤ (1 - 2 * x - (Real.sqrt ((1 + x) / (2 * x)))⁻¹) / (4 * x * (1 - x)) := + div_nonneg (by linarith) hdp.le + linarith + · have hx8 : 1 / 8 ≤ x := le_of_not_ge hsmall + have hden : 1 / 4 ≤ 4 * x * (1 - x) := by nlinarith [mul_nonneg hx.1.le (by linarith [hx.2] : 0 ≤ 1 / 2 - x)] + apply (le_div_iff₀ hdp).2 + nlinarith [hx.2] + + +def upperLikelihoodWeight (β x : ℝ) : ℝ := omega x * x ^ (1 / 2 : ℝ) * Real.exp (β * x) + +lemma upperLikelihoodWeight_exp {x : ℝ} (hx : x ∈ Ioo 0 1) (β : ℝ) : + upperLikelihoodWeight β x = Real.exp (omegaLogHalf x + β * x) := by + rw [omegaLogHalf, Real.exp_add, Real.exp_add, Real.exp_log (omega_pos hx)] + simp only [upperLikelihoodWeight, Real.rpow_def_of_pos hx.1, mul_comm (Real.log x) (1 / 2 : ℝ)] + + + +theorem upperLikelihoodWeight_monotone {β : ℝ} (hb : 4 ≤ β) : + MonotoneOn (upperLikelihoodWeight β) (Ioo 0 (1 / 2 : ℝ)) := by + have hh (x : ℝ) (hx : x ∈ Ioo 0 (1 / 2 : ℝ)) : + HasDerivAt (fun x => omegaLogHalf x + β * x) + ((1 - 2 * x - (Real.sqrt ((1 + x) / (2 * x)))⁻¹) / (4 * x * (1 - x)) + β) x := by + apply ((hasDerivAt_omegaLogHalf ⟨hx.1, by linarith [hx.2]⟩).add ((hasDerivAt_id x).const_mul β)).congr_deriv + simp only [mul_one] + have hmono : MonotoneOn (fun x => omegaLogHalf x + β * x) (Ioo 0 (1 / 2 : ℝ)) := by + apply monotoneOn_of_hasDerivWithinAt_nonneg (convex_Ioo (0 : ℝ) (1 / 2 : ℝ)) + (fun x hx => (hh x hx).continuousAt.continuousWithinAt) + (fun x hx => (hh x (by simpa only [interior_Ioo] using hx)).hasDerivWithinAt) + intro x hx + have hx' : x ∈ Ioo 0 (1 / 2 : ℝ) := by simpa only [interior_Ioo] using hx + linarith [omegaLogHalf_derivative_lower ⟨hx'.1, hx'.2.le⟩] + intro x hx y hy hxy + rw [upperLikelihoodWeight_exp ⟨hx.1, by linarith [hx.2]⟩, + upperLikelihoodWeight_exp ⟨hy.1, by linarith [hy.2]⟩] + exact Real.exp_le_exp.mpr (hmono hx hy hxy) + +end + +noncomputable section +open scoped BigOperators Pointwise +open Set MeasureTheory Filter + + +def scaledLaguerreWeight (a β x : ℝ) : ℝ := x ^ (a - 1) * Real.exp (-(β * x)) + +def scaledLaguerreDensity (N : ℕ) (a β : ℝ) : (Fin N → ℝ) → ℝ := + rawProductDensity N (fun _ => scaledLaguerreWeight a β) + + + +def laguerreDensityScale (N : ℕ) (a β : ℝ) : ℝ := + (∏ _ : Fin N, β ^ (a - 1)) * ∏ i : Fin N, ∏ _j ∈ Finset.Ioi i, β + +lemma laguerreDensityScale_pos (N : ℕ) (a : ℝ) {β : ℝ} (hb : 0 < β) : + 0 < laguerreDensityScale N a β := by + unfold laguerreDensityScale + exact mul_pos (Finset.prod_pos fun _ _ => Real.rpow_pos_of_pos hb _) + (Finset.prod_pos fun _ _ => Finset.prod_pos fun _ _ => hb) + +lemma pairKernel_smul {β : ℝ} (hb : β ≠ 0) (x y : ℝ) : + pairKernel (β * x) (β * y) = β * pairKernel x y := by + unfold pairKernel + rw [← mul_sub, ← mul_add, mul_pow, pow_two β, mul_assoc, + mul_div_mul_left _ _ hb, mul_div_assoc] + +lemma laguerreDensity_scaled {N : ℕ} (a : ℝ) {β : ℝ} (hb : 0 < β) + {y : Fin N → ℝ} (hy : ∀ i, 0 < y i) : + laguerreDensity N a (β • y) = laguerreDensityScale N a β * scaledLaguerreDensity N a β y := by + have hw (i : Fin N) : laguerreWeight a ((β • y) i) = + β ^ (a - 1) * scaledLaguerreWeight a β (y i) := by + simp only [Pi.smul_apply, smul_eq_mul, laguerreWeight, scaledLaguerreWeight, + Real.mul_rpow hb.le (hy i).le, mul_assoc] + have hp (i j : Fin N) : pairKernel ((β • y) i) ((β • y) j) = + β * pairKernel (y i) (y j) := pairKernel_smul hb.ne' _ _ + simp only [laguerreDensity, hw, hp, Finset.prod_mul_distrib, + laguerreDensityScale, scaledLaguerreDensity, rawProductDensity] + ring + +lemma orderedChamber_eq_laguerre_cutoff (N : ℕ) (R : ℝ) : + orderedChamber N (Ioo 0 R) = laguerreDomain N ∩ cutoffEvent N R := by + ext y + constructor + · exact fun h => ⟨⟨h.1, fun i => (h.2 i).1⟩, fun i => (h.2 i).2⟩ + · exact fun h => ⟨h.1.1, fun i => ⟨h.1.2 i, h.2 i⟩⟩ + +lemma measurableSet_orderedChamber_Ioo (N : ℕ) (R : ℝ) : + MeasurableSet (orderedChamber N (Ioo 0 R)) := by + rw [orderedChamber_eq_laguerre_cutoff] + exact (isOpen_laguerreDomain N).measurableSet.inter (measurableSet_cutoffEvent N R) + +lemma orderedChamber_smul {N : ℕ} (R : ℝ) {β : ℝ} (hb : 0 < β) : + β • orderedChamber N (Ioo 0 R) = orderedChamber N (Ioo 0 (β * R)) := by + ext y + constructor + · rintro ⟨x, hx, rfl⟩ + exact ⟨fun i j hij => mul_lt_mul_of_pos_left (hx.1 hij) hb, + fun i => ⟨mul_pos hb (hx.2 i).1, mul_lt_mul_of_pos_left (hx.2 i).2 hb⟩⟩ + · intro hy + refine ⟨β⁻¹ • y, ⟨?_, ?_⟩, smul_inv_smul₀ hb.ne' y⟩ + · exact fun i j hij => mul_lt_mul_of_pos_left (hy.1 hij) (inv_pos.mpr hb) + · intro i + constructor + · exact mul_pos (inv_pos.mpr hb) (hy.2 i).1 + · change β⁻¹ * y i < R + exact (inv_mul_lt_iff₀ hb).2 (hy.2 i).2 + +lemma integral_orderedChamber_scaled {N : ℕ} (R : ℝ) {β : ℝ} (hb : 0 < β) + (f : (Fin N → ℝ) → ℝ) : + (∫ y in orderedChamber N (Ioo 0 R), f (β • y)) = + (β ^ N)⁻¹ * ∫ r in orderedChamber N (Ioo 0 (β * R)), f r := by + simpa only [orderedChamber_smul R hb, Module.finrank_pi, Module.finrank_self, + Finset.sum_const, Finset.card_univ, Fintype.card_fin, smul_eq_mul, smul_eq_mul, mul_one, + Nat.cast_id, nsmul_eq_mul, Nat.cast_one] using + Measure.setIntegral_comp_smul_of_pos (volume : Measure (Fin N → ℝ)) f + (orderedChamber N (Ioo 0 R)) hb + +lemma inverseQuarterSum_smul {N : ℕ} {β : ℝ} (hb : 0 < β) + {y : Fin N → ℝ} (hy : ∀ i, 0 < y i) : + (∑ i, ((β • y) i)⁻¹) ^ (1 / 4 : ℝ) = + (β ^ (1 / 4 : ℝ))⁻¹ * (∑ i, (y i)⁻¹) ^ (1 / 4 : ℝ) := by + simp only [Pi.smul_apply, smul_eq_mul, mul_inv_rev, mul_comm (y _)⁻¹ β⁻¹, + ← Finset.mul_sum] + rw [Real.mul_rpow (inv_nonneg.mpr hb.le) (Finset.sum_nonneg fun i _ => (inv_pos.mpr (hy i)).le), + Real.inv_rpow hb.le] + +lemma measurable_scaledLaguerreWeight (a β : ℝ) : Measurable (scaledLaguerreWeight a β) := by + unfold scaledLaguerreWeight + fun_prop + +lemma continuousOn_scaledLaguerreWeight (a β : ℝ) : + ContinuousOn (scaledLaguerreWeight a β) (Ioi 0) := by + unfold scaledLaguerreWeight + exact (continuousOn_id.rpow_const (fun _ hx => Or.inl (ne_of_gt hx))).mul + ((Real.continuous_exp.comp (continuous_const.mul continuous_id).neg).continuousOn) + +lemma scaledLaguerreWeight_pos (a β : ℝ) {x : ℝ} (hx : 0 < x) : + 0 < scaledLaguerreWeight a β x := by + exact mul_pos (Real.rpow_pos_of_pos hx _) (Real.exp_pos _) + +lemma scaledLaguerreWeight_le (a : ℝ) {β x : ℝ} (hb : 1 ≤ β) (hx : 0 < x) : + scaledLaguerreWeight a β x ≤ laguerreWeight a x := by + apply mul_le_mul_of_nonneg_left _ (Real.rpow_pos_of_pos hx _).le + apply Real.exp_le_exp.mpr + nlinarith + +lemma scaledLaguerreDensity_pos {N : ℕ} (a β : ℝ) {y : Fin N → ℝ} + (hy : y ∈ laguerreDomain N) : 0 < scaledLaguerreDensity N a β y := by + exact mul_pos (Finset.prod_pos fun i _ => scaledLaguerreWeight_pos a β (hy.2 i)) + (Finset.prod_pos fun i _ => Finset.prod_pos fun j hj => + pairKernel_pos (hy.2 i) (hy.1 (Finset.mem_Ioi.1 hj))) + +lemma scaledLaguerreDensity_le {N : ℕ} (a : ℝ) {β : ℝ} (hb : 1 ≤ β) + {y : Fin N → ℝ} (hy : y ∈ laguerreDomain N) : + scaledLaguerreDensity N a β y ≤ laguerreDensity N a y := by + apply mul_le_mul_of_nonneg_right _ + (Finset.prod_nonneg fun i _ => Finset.prod_nonneg fun j _ => + pairKernel_nonneg (hy.2 i).le (hy.2 j).le) + exact Finset.prod_le_prod₀ (fun i _ => (scaledLaguerreWeight_pos a β (hy.2 i)).le) + (fun i _ => scaledLaguerreWeight_le a hb (hy.2 i)) + +lemma measurable_scaledLaguerreDensity (N : ℕ) (a β : ℝ) : + Measurable (scaledLaguerreDensity N a β) := by + unfold scaledLaguerreDensity rawProductDensity pairKernel + apply Measurable.mul + · exact Finset.measurable_prod _ fun i _ => + (measurable_scaledLaguerreWeight a β).comp (measurable_pi_apply i) + · apply Finset.measurable_prod + intro i _ + apply Finset.measurable_prod + intro j _ + fun_prop + +lemma integrableOn_scaledLaguerreDensity {N : ℕ} {a β : ℝ} (ha : 0 < a) (hb : 1 ≤ β) : + IntegrableOn (scaledLaguerreDensity N a β) (laguerreDomain N) := by + apply (integrableOn_laguerreDensity N ha).mono' + (measurable_scaledLaguerreDensity N a β).aestronglyMeasurable + filter_upwards [ae_restrict_mem (isOpen_laguerreDomain N).measurableSet] with y hy + simpa only [Real.norm_eq_abs, abs_of_pos (scaledLaguerreDensity_pos a β hy)] using + scaledLaguerreDensity_le a hb hy + +abbrev inverseQuarterStatistic (N : ℕ) (y : Fin N → ℝ) : ℝ := + (∑ i, (y i)⁻¹) ^ (1 / 4 : ℝ) + +lemma inverseQuarterStatistic_nonneg {N : ℕ} {y : Fin N → ℝ} (hy : ∀ i, 0 < y i) : + 0 ≤ inverseQuarterStatistic N y := + Real.rpow_nonneg (Finset.sum_nonneg fun i _ => (inv_pos.mpr (hy i)).le) _ + +lemma measurable_inverseQuarterStatistic (N : ℕ) : Measurable (inverseQuarterStatistic N) := by + unfold inverseQuarterStatistic + fun_prop + +lemma integrableOn_scaledLaguerre_inverseQuarter {N : ℕ} {a β : ℝ} + (ha : 1 / 4 < a) (hb : 1 ≤ β) : + IntegrableOn (fun y => inverseQuarterStatistic N y * scaledLaguerreDensity N a β y) + (laguerreDomain N) := by + apply (integrableOn_laguerre_inverseQuarterSum ha).mono' + ((measurable_inverseQuarterStatistic N).mul + (measurable_scaledLaguerreDensity N a β)).aestronglyMeasurable + filter_upwards [ae_restrict_mem (isOpen_laguerreDomain N).measurableSet] with y hy + simp only [Pi.mul_apply] + rw [Real.norm_eq_abs, abs_of_nonneg (mul_nonneg (inverseQuarterStatistic_nonneg hy.2) + (scaledLaguerreDensity_pos a β hy).le)] + exact mul_le_mul_of_nonneg_left (scaledLaguerreDensity_le a hb hy) + (inverseQuarterStatistic_nonneg hy.2) + +lemma scaledLaguerre_cutoffNormalizer_pos (N : ℕ) {a β R : ℝ} + (ha : 0 < a) (hb : 1 ≤ β) (hR : 0 < R) : + 0 < ∫ y in orderedChamber N (Ioo 0 R), scaledLaguerreDensity N a β y := by + rw [orderedChamber_eq_laguerre_cutoff] + let S : Set (Fin N → ℝ) := laguerreDomain N ∩ cutoffEvent N R + have hS : IsOpen S := (isOpen_laguerreDomain N).inter (isOpen_cutoffEvent N R) + have hi : IntegrableOn (scaledLaguerreDensity N a β) S := + (integrableOn_scaledLaguerreDensity ha hb).mono_set inter_subset_left + have hn : 0 ≤ᵐ[volume.restrict S] scaledLaguerreDensity N a β := by + filter_upwards [ae_restrict_mem hS.measurableSet] with r hr + exact (scaledLaguerreDensity_pos a β hr.1).le + apply (integral_pos_iff_support_of_nonneg_ae hn hi).2 + calc 0 < volume S := hS.measure_pos volume (laguerreDomain_cutoff_nonempty N hR) + _ = (volume.restrict S) S := (Measure.restrict_apply_self _ _).symm + _ ≤ (volume.restrict S) (Function.support (scaledLaguerreDensity N a β)) := + measure_mono fun _ hr => (scaledLaguerreDensity_pos a β hr.1).ne' + +def upperLikelihood (N : ℕ) (β : ℝ) (y : Fin N → ℝ) : ℝ := + ∏ i, upperLikelihoodWeight β (y i) + +lemma continuousOn_upperLikelihood (N : ℕ) (β : ℝ) : + ContinuousOn (upperLikelihood N β) (coordinateBox (Fin N) (Ioi 0)) := by + unfold upperLikelihood upperLikelihoodWeight + apply continuousOn_finsetProd + intro i _ + apply ContinuousOn.mul + · exact (continuousOn_omega_Ioi.comp (continuous_apply i).continuousOn (show MapsTo (fun y : Fin N → ℝ => y i) (coordinateBox (Fin N) (Ioi 0)) (Ioi 0) from fun _ hy => hy i)).mul + ((continuous_apply i).continuousOn.rpow_const (fun _ hy => Or.inl (hy i).ne')) + · exact (Real.continuous_exp.comp (continuous_const.mul (continuous_apply i))).continuousOn + +lemma upperLikelihood_pos (N : ℕ) (β : ℝ) {y : Fin N → ℝ} + (hy : y ∈ coordinateBox (Fin N) (Ioo 0 1)) : 0 < upperLikelihood N β y := by + apply Finset.prod_pos + intro i _ + exact mul_pos (mul_pos (omega_pos (hy i)) (Real.rpow_pos_of_pos (hy i).1 _)) (Real.exp_pos _) + +lemma upperLikelihood_monotone (N : ℕ) {β : ℝ} (hb : 4 ≤ β) : + MonotoneOn (upperLikelihood N β) (coordinateBox (Fin N) (Ioo 0 (1 / 2 : ℝ))) := by + intro x hx y hy hxy + apply Finset.prod_le_prod₀ + · intro i _ + exact mul_nonneg (mul_nonneg (omega_nonneg _) (Real.rpow_nonneg (hx i).1.le _)) + (Real.exp_pos _).le + · intro i _ + exact upperLikelihoodWeight_monotone hb (hx i) (hy i) (hxy i) + +lemma scaledWeight_mul_upperLikelihoodWeight (β : ℝ) {x : ℝ} (hx : 0 < x) : + scaledLaguerreWeight (1 / 2) β x * upperLikelihoodWeight β x = omega x := by + unfold scaledLaguerreWeight upperLikelihoodWeight + calc + x ^ ((1 / 2 : ℝ) - 1) * Real.exp (-(β * x)) * + (omega x * x ^ (1 / 2 : ℝ) * Real.exp (β * x)) = + omega x * (x ^ ((1 / 2 : ℝ) - 1) * x ^ (1 / 2 : ℝ)) * + (Real.exp (-(β * x)) * Real.exp (β * x)) := by ring + _ = omega x := by + rw [← Real.rpow_add hx, ← Real.exp_add] + norm_num + +lemma scaledDensity_mul_upperLikelihood {N : ℕ} (β : ℝ) {y : Fin N → ℝ} + (hy : ∀ i, 0 < y i) : + scaledLaguerreDensity N (1 / 2) β y * upperLikelihood N β y = density N y := by + have hw : (∏ i, scaledLaguerreWeight (1 / 2) β (y i)) * + (∏ i, upperLikelihoodWeight β (y i)) = ∏ i, omega (y i) := by + rw [← Finset.prod_mul_distrib] + exact Finset.prod_congr rfl fun i _ => scaledWeight_mul_upperLikelihoodWeight β (hy i) + unfold scaledLaguerreDensity rawProductDensity upperLikelihood density + rw [mul_right_comm, hw] + +lemma orderedChamber_eq_positive_cutoff (N : ℕ) {R : ℝ} (hR : R ≤ 1) : + orderedChamber N (Ioo 0 R) = orderedDomain N ∩ cutoffEvent N R := by + ext y + constructor + · exact fun h => ⟨⟨h.1, fun i => ⟨(h.2 i).1, (h.2 i).2.trans_le hR⟩⟩, + fun i => (h.2 i).2⟩ + · exact fun h => ⟨h.1.1, fun i => ⟨(h.1.2 i).1, h.2 i⟩⟩ + +lemma positive_cutoffNormalizer_pos (N : ℕ) {R : ℝ} (hR : 0 < R) (hR1 : R ≤ 1) : + 0 < ∫ y in orderedChamber N (Ioo 0 R), density N y := by + have h := positiveLaw_cutoff_pos N hR + rw [positiveLaw_measureReal N (measurableSet_cutoffEvent N R), + ← orderedChamber_eq_positive_cutoff N hR1] at h + exact (div_pos_iff_of_pos_right (normalizer_pos N)).1 h + + + +theorem positive_half_inverseQuarter_le_scaled_reference (N : ℕ) {β : ℝ} (hb : 4 ≤ β) : + (∫ y in orderedChamber N (Ioo 0 (1 / 2 : ℝ)), inverseQuarterStatistic N y * density N y) / + (∫ y in orderedChamber N (Ioo 0 (1 / 2 : ℝ)), density N y) ≤ + (∫ y in orderedChamber N (Ioo 0 (1 / 2 : ℝ)), inverseQuarterStatistic N y * + scaledLaguerreDensity N (1 / 2) β y) / + (∫ y in orderedChamber N (Ioo 0 (1 / 2 : ℝ)), scaledLaguerreDensity N (1 / 2) β y) := by + let S := orderedChamber N (Ioo 0 (1 / 2 : ℝ)) + have hS := measurableSet_orderedChamber_Ioo N (1 / 2) + have hSl : S ⊆ laguerreDomain N := fun _ hy => ⟨hy.1, fun i => (hy.2 i).1⟩ + have hSt : S ⊆ orderedDomain N := fun _ hy => ⟨hy.1, fun i => + ⟨(hy.2 i).1, (hy.2 i).2.trans (by norm_num)⟩⟩ + have heq : (fun y => scaledLaguerreDensity N (1 / 2) β y * upperLikelihood N β y) =ᵐ[volume.restrict S] + density N := by + filter_upwards [ae_restrict_mem hS] with y hy + exact scaledDensity_mul_upperLikelihood β (fun i => (hy.2 i).1) + have hiT := (integrableOn_density N).mono_set hSt + have hiTF := (integrableOn_inverseQuarterSum_density N).mono_set hSt + have hiB := (integrableOn_scaledLaguerreDensity (N := N) (by norm_num : (0 : ℝ) < 1/2) + (by linarith : 1 ≤ β)).mono_set hSl + have hiBF := (integrableOn_scaledLaguerre_inverseQuarter (N := N) (by norm_num : (1/4 : ℝ) < 1/2) + (by linarith : 1 ≤ β)).mono_set hSl + have heqF : (fun y => scaledLaguerreDensity N (1 / 2) β y * + (-inverseQuarterStatistic N y * upperLikelihood N β y)) =ᵐ[volume.restrict S] + (fun y => -(inverseQuarterStatistic N y * density N y)) := by + filter_upwards [heq] with y hy + calc + _ = - (inverseQuarterStatistic N y * (scaledLaguerreDensity N (1/2) β y * upperLikelihood N β y)) := by ring + _ = _ := by rw [hy] + have h := ordered_density_covariance_Ioo (by norm_num : (0 : ℝ) < 1/2) + (fun _ : Fin N => scaledLaguerreWeight (1 / 2) β) + (fun _ => (continuousOn_scaledLaguerreWeight (1/2) β).mono (fun _ hx => hx.1)) + (fun _ _ hx => (scaledLaguerreWeight_pos (1/2) β hx.1).le) + (fun y => -inverseQuarterStatistic N y) (upperLikelihood N β) + ((continuousOn_inverseQuarterSum.mono (fun _ hx i => (hx i).1)).neg) + ((continuousOn_upperLikelihood N β).mono (fun _ hx i => (hx i).1)) + (fun _ hx _ hy hxy => neg_le_neg (antitoneOn_inverseQuarterSum + (fun i => (hx i).1) (fun i => (hy i).1) hxy)) (upperLikelihood_monotone N hb) + hiB (by simpa only [Pi.neg_def, scaledLaguerreDensity, mul_neg, neg_mul, mul_comm] using hiBF.neg) (hiT.congr heq.symm) + (hiTF.neg.congr heqF.symm) + change _ ≤ _ at h + have hprod : (∫ y in S, inverseQuarterStatistic N y * density N y) * + (∫ y in S, scaledLaguerreDensity N (1/2) β y) ≤ + (∫ y in S, inverseQuarterStatistic N y * scaledLaguerreDensity N (1/2) β y) * + (∫ y in S, density N y) := by + change (∫ y in S, scaledLaguerreDensity N (1/2) β y * -inverseQuarterStatistic N y) * + (∫ y in S, scaledLaguerreDensity N (1/2) β y * upperLikelihood N β y) ≤ + (∫ y in S, scaledLaguerreDensity N (1/2) β y) * + (∫ y in S, scaledLaguerreDensity N (1/2) β y * (-inverseQuarterStatistic N y * upperLikelihood N β y)) at h + rw [integral_congr_ae heq, integral_congr_ae heqF] at h + simpa only [mul_neg, integral_neg, neg_mul, neg_le_neg_iff, mul_comm] using h + exact (div_le_div_iff₀ (positive_cutoffNormalizer_pos N (by norm_num) (by norm_num)) + (scaledLaguerre_cutoffNormalizer_pos N (by norm_num) (by linarith) (by norm_num))).2 hprod + +lemma integral_scaledLaguerre_cutoff (N : ℕ) (a R : ℝ) {β : ℝ} (hb : 0 < β) : + laguerreDensityScale N a β * + (∫ y in orderedChamber N (Ioo 0 R), scaledLaguerreDensity N a β y) = + (β ^ N)⁻¹ * (∫ r in orderedChamber N (Ioo 0 (β * R)), laguerreDensity N a r) := by + rw [← integral_const_mul] + calc + (∫ y in orderedChamber N (Ioo 0 R), laguerreDensityScale N a β * scaledLaguerreDensity N a β y) = + ∫ y in orderedChamber N (Ioo 0 R), laguerreDensity N a (β • y) := by + apply setIntegral_congr_fun (measurableSet_orderedChamber_Ioo N R) + intro y hy + exact (laguerreDensity_scaled a hb (fun i => (hy.2 i).1)).symm + _ = _ := integral_orderedChamber_scaled R hb _ + +end +end CriticalStrip + +end OAI diff --git a/lean/OAI/Combinatorics/StripMass/WireContraction.lean b/lean/OAI/Combinatorics/StripMass/WireContraction.lean new file mode 100644 index 0000000000000000000000000000000000000000..84d9b2ac3614bb9cd47e22d9eb9cf876b4eeb04c --- /dev/null +++ b/lean/OAI/Combinatorics/StripMass/WireContraction.lean @@ -0,0 +1,511 @@ +import Mathlib +import OAI.Combinatorics.StripMass.StepComplete + +namespace OAI + +/-! Critical honeycomb strip paths, polynomial identities and crossing mass. -/ + + + +namespace CriticalStrip.Diagram +noncomputable section + +namespace Graph + + + +structure WireContraction {V W : Type*} {n : ℕ} (r : V → V → Prop) (s : W → W → Prop) + (a : Fin n → V) (b : Fin n → W) where + project : V → W + core : W → V + section_eq : ∀ v, project (core v)=v + map_edge : ∀ v w, r v w → Relation.ReflTransGen s (project v) (project w) + core_edge : ∀ v w, s v w → r (core v) (core w) + map_boundary : ∀ i, project (a i)=b i + boundary_injective : Function.Injective b + map_used : ∀ v, Used r v → Used s (project v) + retract : ∀ v, Used r v → Relation.ReflTransGen r v (core (project v)) + boundary_retract : ∀ i, Used s (b i) → Relation.ReflTransGen r (core (b i)) (a i) + +namespace WireContraction +variable {V W : Type*} {n : ℕ} {r : V → V → Prop} {s : W → W → Prop} + {a : Fin n → V} {b : Fin n → W} [Std.Symm r] [Std.Symm s] + +theorem lift_boundary_reach (e : WireContraction r s a b) {i j : Fin n} + (hij : i≠j) (h : Relation.ReflTransGen s (b i) (b j)) : + Relation.ReflTransGen r (a i) (a j) := by + have hne : b i≠b j := fun hh => hij (e.boundary_injective hh) + have hi := Graph.used_of_reach_ne h hne + have hj := Graph.used_of_reach_ne (symm h) hne.symm + have hm := Graph.map_reach e.core (fun v w hvw => .single (e.core_edge v w hvw)) h + exact ((symm (e.boundary_retract i hi)).trans hm).trans (e.boundary_retract j hj) + +theorem realizes (e : WireContraction r s a b) {p : Pairing n} + (h : GraphRealizes r a p) : GraphRealizes s b p := by + constructor + · intro v w hvw + obtain ⟨i,hi,hr⟩ := h.no_loop (e.core v) (e.core w) (e.core_edge v w hvw) + have hm := Graph.map_reach e.project e.map_edge hr + rw [e.section_eq,e.map_boundary] at hm + exact ⟨i,hi,hm⟩ + · intro i j + constructor + · intro hr + by_cases hij : i=j + · exact Or.inl hij + · exact (h.reach i j).mp (e.lift_boundary_reach hij hr) + · intro hh + have hm := Graph.map_reach e.project e.map_edge ((h.reach i j).mpr hh) + rwa [e.map_boundary,e.map_boundary] at hm + +theorem realizes_inv (e : WireContraction r s a b) {p : Pairing n} + (h : GraphRealizes s b p) : GraphRealizes r a p := by + constructor + · intro v w hvw + obtain ⟨x,hx⟩ := e.map_used v ⟨w,hvw⟩ + obtain ⟨i,hi,hr⟩ := h.no_loop (e.project v) x hx + have hm := Graph.map_reach e.core (fun v w hvw => .single (e.core_edge v w hvw)) hr + have hb := (h.boundary_used_iff e.boundary_injective i).mpr hi + exact ⟨i,hi,((e.retract v ⟨w,hvw⟩).trans hm).trans (e.boundary_retract i hb)⟩ + · intro i j + constructor + · intro hr + have hm := Graph.map_reach e.project e.map_edge hr + rw [e.map_boundary,e.map_boundary] at hm + exact (h.reach i j).mp hm + · intro hh + rcases hh with hij | hadj + · subst j; exact .refl + · have hij : i≠j := by intro hh; subst j; exact p.adj_irrefl i hadj + exact e.lift_boundary_reach hij ((h.reach i j).mpr (Or.inr hadj)) + +theorem realizes_iff (e : WireContraction r s a b) {p : Pairing n} : + GraphRealizes r a p ↔ GraphRealizes s b p := ⟨e.realizes,e.realizes_inv⟩ + +end WireContraction +end Graph + + + + + +section LocalContractions +open scoped Classical + +namespace CompactGate +variable {V : Type*} {n : ℕ} + +def wiring (r : V → V → Prop) (boundary : Fin n → V) (active : Fin n → Prop) + (a b : Fin n) (t : Tile) : Sum V (Fin 4) → Sum V (Fin 4) → Prop + | .inl v, .inl w => r v w + | .inr k, .inr l => t.Adj k l + | .inl v, .inr k | .inr k, .inl v => + (v=boundary a ∧ k=0 ∧ active a) ∨ (v=boundary b ∧ k=1 ∧ active b) + +def boundary (old : Fin n → V) (a b : Fin n) (i : Fin n) : Sum V (Fin 4) := + if i=a then .inr 2 else if i=b then .inr 3 else .inl (old i) + +def project (old : Fin n → V) (a b : Fin n) : Sum V (GateExterior n) → Sum V (Fin 4) + | .inl v => .inl v + | .inr (.inl k) => .inr k + | .inr (.inr i) => boundary old a b i + +def core : Sum V (Fin 4) → Sum V (GateExterior n) + | .inl v => .inl v + | .inr k => .inr (.inl k) + +@[simp] theorem project_core (old : Fin n → V) (a b : Fin n) (v : Sum V (Fin 4)) : + project old a b (core v)=v := by cases v <;> rfl + +@[simp] theorem boundary_left (old : Fin n → V) (a b : Fin n) : boundary old a b a=.inr 2 := by + simp [boundary] +@[simp] theorem boundary_right (old : Fin n → V) (a b : Fin n) (hab : a≠b) : + boundary old a b b=.inr 3 := by simp [boundary,hab.symm] + +theorem boundary_injective (old : Fin n → V) (h : Function.Injective old) + (a b : Fin n) : Function.Injective (boundary old a b) := by + intro i j hij + by_cases hia : i=a <;> by_cases hib : i=b <;> + by_cases hja : j=a <;> by_cases hjb : j=b <;> + simp_all [boundary] + exact h hij + +instance wiring_symm (r : V → V → Prop) [Std.Symm r] (old : Fin n → V) + (active : Fin n → Prop) (a b : Fin n) (t : Tile) : + Std.Symm (wiring r old active a b t) := by + constructor + intro v w h + cases v <;> cases w <;> try exact h + · change r _ _ at h ⊢; exact symm h + · exact h.elim Or.inr Or.inl + +end CompactGate + +namespace Patch +instance glued_symm {A B I : Type*} (r : A → A → Prop) (s : B → B → Prop) + [Std.Symm r] [Std.Symm s] (a : I → A) (b : I → B) (active : I → Prop) : + Std.Symm (glued r s a b active) := by + constructor + intro v w h + cases v with + | inl v => + cases w with + | inl w => change r _ _ at h ⊢; exact symm h + | inr w => obtain ⟨i,hi,rfl,rfl⟩ := h; exact ⟨i,hi,rfl,rfl⟩ + | inr v => + cases w with + | inl w => obtain ⟨i,hi,rfl,rfl⟩ := h; exact ⟨i,hi,rfl,rfl⟩ + | inr w => change s _ _ at h ⊢; exact symm h +end Patch + +instance gateWiring_symm {n : ℕ} (a b : Fin n) (t : Tile) : Std.Symm (gateWiring a b t) := by + constructor + intro v w h + rcases v with k | i <;> rcases w with l | j <;> try exact h + exact h.elim Or.inr Or.inl + +namespace CompactGate +variable {V : Type*} {n : ℕ} {r : V → V → Prop} [Std.Symm r] + {old : Fin n → V} {p : Pairing n} + +abbrev full (a b : Fin n) (t : Tile) := + Patch.glued r (gateWiring a b t) old (gateInput a b) p.Occupied + +omit [Std.Symm r] in +lemma core_edge (a b : Fin n) (hab : a≠b) (t : Tile) (v w : Sum V (Fin 4)) + (h : wiring r old p.Occupied a b t v w) : full (r:=r) (old:=old) (p:=p) a b t (core v) (core w) := by + cases v with + | inl v => + cases w with + | inl w => exact h + | inr k => + rcases h with ⟨rfl,rfl,ha⟩ | ⟨rfl,rfl,hb⟩ + · exact ⟨a,ha,rfl,by simp [gateInput]⟩ + · exact ⟨b,hb,rfl,by simp [gateInput,hab.symm]⟩ + | inr k => + cases w with + | inl v => + rcases h with ⟨rfl,rfl,ha⟩ | ⟨rfl,rfl,hb⟩ + · exact ⟨a,ha,by simp [gateInput],rfl⟩ + · exact ⟨b,hb,by simp [gateInput,hab.symm],rfl⟩ + | inr l => exact h + +omit [Std.Symm r] in +lemma project_edge (a b : Fin n) (hab : a≠b) (t : Tile) + (v w : Sum V (GateExterior n)) (h : full (r:=r) (old:=old) (p:=p) a b t v w) : + Relation.ReflTransGen (wiring r old p.Occupied a b t) (project old a b v) (project old a b w) := by + rcases v with v | (k | i) <;> rcases w with w | (l | j) + · exact .single h + · obtain ⟨i,hi,rfl,he⟩ := h + rcases (gateInput_eq_box a b i hab l).mp he.symm with ⟨rfl,rfl⟩ | ⟨rfl,rfl⟩ + · exact .single (Or.inl ⟨rfl,rfl,hi⟩) + · exact .single (Or.inr ⟨rfl,rfl,hi⟩) + · obtain ⟨i,hi,rfl,he⟩ := h + obtain ⟨rfl,hia,hib⟩ := (gateInput_eq_out a b i j).mp he.symm + simp only [project,boundary,ite_eq_right hia,ite_eq_right hib] + exact .refl + · obtain ⟨i,hi,he,rfl⟩ := h + rcases (gateInput_eq_box a b i hab k).mp he.symm with ⟨rfl,rfl⟩ | ⟨rfl,rfl⟩ + · exact .single (Or.inl ⟨rfl,rfl,hi⟩) + · exact .single (Or.inr ⟨rfl,rfl,hi⟩) + · exact .single h + · rcases h with ⟨hia,rfl,_⟩ | ⟨hib,rfl,_⟩ + · subst j; simp only [project,boundary_left]; exact .refl + · subst j; simp only [project,boundary_right old a b hab]; exact .refl + · obtain ⟨j,hj,he,rfl⟩ := h + obtain ⟨rfl,hia,hib⟩ := (gateInput_eq_out a b j i).mp he.symm + simp only [project,boundary,ite_eq_right hia,ite_eq_right hib] + exact .refl + · rcases h with ⟨hia,rfl,_⟩ | ⟨hib,rfl,_⟩ + · subst i; simp only [project,boundary_left]; exact .refl + · subst i; simp only [project,boundary_right old a b hab]; exact .refl + · exact h.elim + +omit [Std.Symm r] in +lemma used_old_iff (hp : GraphRealizes r old p) (hinj : Function.Injective old) + (a b : Fin n) (t : Tile) (v : V) : + Graph.Used (wiring r old p.Occupied a b t) (.inl v) ↔ Graph.Used r v := by + constructor + · rintro ⟨w,hw⟩ + cases w with + | inl w => exact ⟨w,hw⟩ + | inr k => + rcases hw with ⟨rfl,_,ha⟩ | ⟨rfl,_,hb⟩ + · exact (hp.boundary_used_iff hinj a).mpr ha + · exact (hp.boundary_used_iff hinj b).mpr hb + · rintro ⟨w,hw⟩; exact ⟨.inl w,hw⟩ + +omit [Std.Symm r] in +lemma used_output_iff (hp : GraphRealizes r old p) (hinj : Function.Injective old) + (a b : Fin n) (hab : a≠b) (t : Tile) (i : Fin n) : + Graph.Used (wiring r old p.Occupied a b t) (boundary old a b i) ↔ p.stepSupport a b t i := by + by_cases hia : i=a + · subst i + rw [boundary_left] + simp only [Pairing.stepSupport,ite_true,eq_self] + constructor + · rintro ⟨v,hv⟩ + cases v with + | inl v => rcases hv with ⟨_,h,_⟩ | ⟨_,h,_⟩ <;> have hh := congrArg Fin.val h <;> norm_num at hh + | inr k => exact ⟨k,hv⟩ + · rintro ⟨k,hk⟩; exact ⟨.inr k,hk⟩ + · by_cases hib : i=b + · subst i + rw [boundary_right old a b hab] + simp only [Pairing.stepSupport,ite_eq_right hia,ite_true,eq_self] + constructor + · rintro ⟨v,hv⟩ + cases v with + | inl v => rcases hv with ⟨_,h,_⟩ | ⟨_,h,_⟩ <;> have hh := congrArg Fin.val h <;> norm_num at hh + | inr k => exact ⟨k,hv⟩ + · rintro ⟨k,hk⟩; exact ⟨.inr k,hk⟩ + · simp only [boundary,ite_eq_right hia,ite_eq_right hib,Pairing.stepSupport] + rw [used_old_iff hp hinj,hp.boundary_used_iff hinj] + +omit [Std.Symm r] in +lemma output_edge (a b : Fin n) (hab : a≠b) (t : Tile) (i : Fin n) + (hi : p.stepSupport a b t i) : + full (r:=r) (old:=old) (p:=p) a b t (core (boundary old a b i)) (.inr (.inr i)) := by + by_cases hia : i=a + · subst i + rw [boundary_left] + exact Or.inl ⟨rfl,rfl,by simpa [Pairing.stepSupport] using hi⟩ + · by_cases hib : i=b + · subst i + simp only [Pairing.stepSupport,ite_eq_right hia,ite_true,eq_self] at hi + simpa only [boundary_right old a b hab,core,full,Patch.glued,gateWiring] using + (Or.inr ⟨rfl,rfl,hi⟩ : (b=a ∧ (3:Fin 4)=2 ∧ t.Occupied 2) ∨ (b=b ∧ (3:Fin 4)=3 ∧ t.Occupied 3)) + · simp only [boundary,ite_eq_right hia,ite_eq_right hib,core,full,Patch.glued] + exact ⟨i,by simpa [Pairing.stepSupport,hia,hib] using hi,rfl,by simp [gateInput,hia,hib]⟩ + +omit [Std.Symm r] in +lemma full_used_out (a b : Fin n) (hab : a≠b) (t : Tile) (i : Fin n) + (h : Graph.Used (full (r:=r) (old:=old) (p:=p) a b t) (.inr (.inr i))) : + p.stepSupport a b t i := by + obtain ⟨v,hv⟩ := h + rcases v with v | (k | j) + · obtain ⟨j,hj,he,_⟩ := hv + obtain ⟨rfl,hja,hjb⟩ := (gateInput_eq_out a b j i).mp he.symm + simpa [Pairing.stepSupport,hja,hjb] using hj + · rcases hv with ⟨rfl,_,ht⟩ | ⟨rfl,_,ht⟩ + · simpa [Pairing.stepSupport] using ht + · simpa [Pairing.stepSupport,hab.symm] using ht + · exact hv.elim + +omit [Std.Symm r] in +lemma project_used (hp : GraphRealizes r old p) (hinj : Function.Injective old) + (a b : Fin n) (hab : a≠b) (t : Tile) (v : Sum V (GateExterior n)) + (h : Graph.Used (full (r:=r) (old:=old) (p:=p) a b t) v) : + Graph.Used (wiring r old p.Occupied a b t) (project old a b v) := by + rcases v with v | (k | i) + · apply (used_old_iff hp hinj a b t v).mpr + obtain ⟨w,hw⟩ := h + cases w with + | inl w => exact ⟨w,hw⟩ + | inr w => + obtain ⟨i,hi,rfl,_⟩ := hw + exact (hp.boundary_used_iff hinj i).mpr hi + · obtain ⟨w,hw⟩ := h + rcases w with w | (l | j) + · obtain ⟨i,hi,he,rfl⟩ := hw + rcases (gateInput_eq_box a b i hab k).mp he.symm with ⟨rfl,rfl⟩ | ⟨rfl,rfl⟩ + · exact ⟨.inl (old i),Or.inl ⟨rfl,rfl,hi⟩⟩ + · exact ⟨.inl (old i),Or.inr ⟨rfl,rfl,hi⟩⟩ + · exact ⟨.inr l,hw⟩ + · rcases hw with ⟨_,rfl,ht⟩ | ⟨_,rfl,ht⟩ <;> + obtain ⟨l,hl⟩ := ht <;> exact ⟨.inr l,hl⟩ + · exact (used_output_iff hp hinj a b hab t i).mpr (full_used_out a b hab t i h) + + def contraction (hp : GraphRealizes r old p) (hinj : Function.Injective old) + (a b : Fin n) (hab : a≠b) (t : Tile) : + Graph.WireContraction (full (r:=r) (old:=old) (p:=p) a b t) + (wiring r old p.Occupied a b t) (fun i => .inr (.inr i)) (boundary old a b) where + project := project old a b + core := core + section_eq := project_core old a b + map_edge := project_edge a b hab t + core_edge := core_edge a b hab t + map_boundary := fun _ => rfl + boundary_injective := boundary_injective old hinj a b + map_used := project_used hp hinj a b hab t + retract := by + intro v hv + rcases v with v | (k | i) + · exact .refl + · exact .refl + · exact .single (symm (output_edge a b hab t i (full_used_out a b hab t i hv))) + boundary_retract := fun i hi => .single (output_edge a b hab t i + ((used_output_iff hp hinj a b hab t i).mp hi)) + + theorem realizes_iff (hp : GraphRealizes r old p) (hinj : Function.Injective old) + (a b : Fin n) (hab : a≠b) (t : Tile) (q : Pairing n) : + GraphRealizes (full (r:=r) (old:=old) (p:=p) a b t) (fun i => .inr (.inr i)) q ↔ + GraphRealizes (wiring r old p.Occupied a b t) (boundary old a b) q := + (contraction hp hinj a b hab t).realizes_iff + +end CompactGate +end LocalContractions + +namespace Graph +variable {V W : Type*} {n : ℕ} {r : V → V → Prop} {s : W → W → Prop} + [Std.Symm r] [Std.Symm s] {a : Fin n → V} {b : Fin n → W} + +lemma used_of_reach {v w : V} (h : Relation.ReflTransGen r v w) (hv : Used r v) : Used r w := by + by_cases he : v=w + · exact he ▸ hv + · exact used_of_reach_ne (symm h) (Ne.symm he) + +omit [Std.Symm r] [Std.Symm s] in +lemma WireContraction.drains (e : WireContraction r s a b) (h : DrainsBoundary r a) : + DrainsBoundary s b := by + intro v w hvw + obtain ⟨i,hr⟩ := h (e.core v) (e.core w) (e.core_edge v w hvw) + have hm := Graph.map_reach e.project e.map_edge hr + rw [e.section_eq,e.map_boundary] at hm + exact ⟨i,hm⟩ + +omit [Std.Symm r] in +lemma WireContraction.drains_inv (e : WireContraction r s a b) (h : DrainsBoundary s b) : + DrainsBoundary r a := by + intro v w hvw + obtain ⟨x,hx⟩ := e.map_used v ⟨w,hvw⟩ + obtain ⟨i,hr⟩ := h (e.project v) x hx + have hm := Graph.map_reach e.core (fun v w hvw => .single (e.core_edge v w hvw)) hr + exact ⟨i,((e.retract v ⟨w,hvw⟩).trans hm).trans + (e.boundary_retract i (used_of_reach hr ⟨x,hx⟩))⟩ + +omit [Std.Symm r] in +lemma WireContraction.drains_iff (e : WireContraction r s a b) : + DrainsBoundary r a ↔ DrainsBoundary s b := ⟨e.drains,e.drains_inv⟩ + +end Graph + + + + + +open scoped Classical + +namespace CompactGate +variable {V : Type*} {n : ℕ} (r : V → V → Prop) (old : Fin n → V) + (active : Fin n → Prop) (a b : Fin n) (t : Tile) + +def localEnd (v : V) : Sum V (Fin 4) → Prop + | .inl w => Relation.ReflTransGen r v w + | .inr _ => False + +lemma reach_exit (v : V) {z : Sum V (Fin 4)} + (hr : Relation.ReflTransGen (wiring r old active a b t) (.inl v) z) : + (∃ i, Relation.ReflTransGen r v (old i)) ∨ + localEnd r v z := by + induction hr with + | refl => exact Or.inr .refl + | @tail x y h hxy ih => + rcases ih with hi | hi + · exact Or.inl hi + · cases x with + | inr k => exact hi.elim + | inl w => + cases y with + | inl u => exact Or.inr (hi.tail hxy) + | inr k => + rcases hxy with ⟨rfl,_,_⟩ | ⟨rfl,_,_⟩ + · exact Or.inl ⟨a,hi⟩ + · exact Or.inl ⟨b,hi⟩ + +lemma drains_local (hd : Graph.DrainsBoundary (wiring r old active a b t) (boundary old a b)) : + Graph.DrainsBoundary r old := by + intro v w hvw + obtain ⟨i,hi⟩ := hd (.inl v) (.inl w) hvw + have he := reach_exit r old active a b t v hi + rcases he with he | he + · exact he + · by_cases hia : i=a + · simp only [boundary,ite_eq_left hia,localEnd] at he + · by_cases hib : i=b + · simp only [boundary,ite_eq_right hia,ite_eq_left hib,localEnd] at he + · exact ⟨i,by simpa only [boundary,ite_eq_right hia,ite_eq_right hib,localEnd] using he⟩ + +end CompactGate + +namespace Circuit +variable {n : ℕ} + +def CompactVertex : Circuit n → Type + | .nil => Fin n + | .snoc c _ => Sum c.CompactVertex (Fin 4) + +def compactBoundary : (c : Circuit n) → Fin n → c.CompactVertex + | .nil => id + | .snoc c g => CompactGate.boundary c.compactBoundary g.left g.right + +def compactWiring (p : Pairing n) : (c : Circuit n) → c.CompactVertex → c.CompactVertex → Prop + | .nil => p.Adj + | .snoc c g => CompactGate.wiring (compactWiring p c) c.compactBoundary + (support p c) g.left g.right g.tile + +theorem compactBoundary_injective (c : Circuit n) : Function.Injective c.compactBoundary := by + induction c with + | nil => exact Function.injective_id + | snoc c g ih => exact CompactGate.boundary_injective _ ih _ _ + +instance compactWiring_symm (p : Pairing n) (c : Circuit n) : Std.Symm (compactWiring p c) := by + induction c with + | nil => exact ⟨fun _ _ h => Pairing.adj_symm h⟩ + | snoc c g ih => + let := ih + exact inferInstanceAs (Std.Symm (CompactGate.wiring _ _ _ _ _ _)) + +theorem compact_eval_sound (p : Pairing n) (c : Circuit n) (q : Pairing n) + (h : eval p c=some q) : GraphRealizes (compactWiring p c) c.compactBoundary q := by + induction c generalizing q with + | nil => have he : p=q := Option.some.inj h; subst q; exact p.graphRealizes + | snoc c g ih => + cases hr : eval p c with + | none => simp [eval,hr] at h + | some r => + have hstep : r.tileStep g.left g.right g.adjacent g.tile = some q := by + simpa only [eval,hr,Option.bind_some] using h + have hp := ih r hr + have hs := (eval_sound p c r hr).2.2 + have hne : g.left≠g.right := by have := g.adjacent; intro hh; have := congrArg Fin.val hh; omega + change GraphRealizes (CompactGate.wiring _ _ _ _ _ _) _ q + rw [hs] + exact (CompactGate.realizes_iff hp c.compactBoundary_injective g.left g.right hne g.tile q).mp + ((graph_gate_step_iff hp g.left g.right g.adjacent g.tile q).mpr hstep).2 + +theorem compact_eval_exists (p : Pairing n) (c : Circuit n) (hc : Compatible p c) + (hd : Graph.DrainsBoundary (compactWiring p c) c.compactBoundary) : + ∃ q, eval p c=some q := by + induction c with + | nil => exact ⟨p,rfl⟩ + | snoc c g ih => + obtain ⟨hc,hl,hright⟩ := hc + obtain ⟨r,hr⟩ := ih hc (CompactGate.drains_local + (compactWiring p c) c.compactBoundary (support p c) g.left g.right g.tile hd) + have hp := compact_eval_sound p c r hr + have hs := (eval_sound p c r hr).2.2 + have hne : g.left≠g.right := by have := g.adjacent; intro hh; have := congrArg Fin.val hh; omega + have hcomp : CutPatch.Compatible (r.cutShape g.left g.right) g.tile := by + rw [r.cutShape_compatible] + exact ⟨by simpa only [hs] using hl,by simpa only [hs] using hright⟩ + change Graph.DrainsBoundary (CompactGate.wiring _ _ _ _ _ _) _ at hd + rw [hs] at hd + have hfull := (CompactGate.contraction hp c.compactBoundary_injective g.left g.right hne g.tile).drains_inv hd + obtain ⟨q,hq⟩ := graph_gate_step_exists hp g.left g.right g.adjacent g.tile hcomp hfull + exact ⟨q,by simpa only [eval,hr,Option.bind_some] using hq⟩ + +theorem compact_eval_iff (p : Pairing n) (c : Circuit n) (q : Pairing n) : + eval p c=some q ↔ Compatible p c ∧ GraphRealizes (compactWiring p c) c.compactBoundary q := by + constructor + · intro h; exact ⟨(eval_sound p c q h).1,compact_eval_sound p c q h⟩ + · rintro ⟨hc,hq⟩ + obtain ⟨r,hr⟩ := compact_eval_exists p c hc hq.drainsBoundary + have he := (compact_eval_sound p c r hr).unique hq + exact he ▸ hr + +end Circuit +end +end CriticalStrip.Diagram + +end OAI diff --git a/lean/OAI/Combinatorics/SumProduct/Alignment/AbelianMalcev01.lean b/lean/OAI/Combinatorics/SumProduct/Alignment/AbelianMalcev01.lean new file mode 100644 index 0000000000000000000000000000000000000000..02f37d4e075797dd4906131f80c17a114dd68ba9 --- /dev/null +++ b/lean/OAI/Combinatorics/SumProduct/Alignment/AbelianMalcev01.lean @@ -0,0 +1,287 @@ +import Mathlib +import OAI.Combinatorics.SumProduct.Alignment.FourierObstruction01 +import OAI.Combinatorics.SumProduct.Alignment.PolynomialDephasing01 +import OAI.Geometry.NilpotentCharts.Main + +namespace OAI + +section +section +section +section +noncomputable section +end +end + + + +section + +namespace TorusLeibman +open scoped BigOperators +open PolynomialWeyl WeylCoefficients FourierObstruction MeasureTheory +noncomputable section +variable {ι : Type*} [Fintype ι] + +def polynomialOrbit (p : ι → Polynomial ℝ) (n : ℕ) : UnitAddTorus ι := + fun i => (((p i).eval (n : ℝ) : ℝ) : UnitAddCircle) + +def characterPolynomial (k : ι → ℤ) (p : ι → Polynomial ℝ) : Polynomial ℝ := + ∑ i, (k i : ℝ) • p i + +theorem characterPolynomial_coeff (k : ι → ℤ) (p : ι → Polynomial ℝ) (j : ℕ) : + (characterPolynomial k p).coeff j = ∑ i, (k i : ℝ) * (p i).coeff j := by + simp [characterPolynomial] + +theorem characterPolynomial_degree (k : ι → ℤ) (p : ι → Polynomial ℝ) (d : ℕ) + (hp : ∀ i, (p i).natDegree ≤ d) : (characterPolynomial k p).natDegree ≤ d := by + rw [Polynomial.natDegree_le_iff_coeff_eq_zero] + intro j hj + rw [characterPolynomial_coeff] + apply Finset.sum_eq_zero + intro i _ + rw [Polynomial.coeff_eq_zero_of_natDegree_lt (by exact (hp i).trans_lt hj), mul_zero] + +theorem phase_sum {α : Type*} (s : Finset α) (f : α → ℝ) : + phase (∑ a ∈ s, f a) = ∏ a ∈ s, phase (f a) := by + classical + induction s using Finset.induction_on with + | empty => simp [phase] + | @insert a s ha ih => simp [Finset.sum_insert, Finset.prod_insert, ha, ih] + +theorem character_polynomialOrbit (k : ι → ℤ) (p : ι → Polynomial ℝ) : + (fun n => UnitAddTorus.mFourier k (polynomialOrbit p n)) = + polynomialPhase (characterPolynomial k p) := by + funext n + simp only [UnitAddTorus.mFourier, ContinuousMap.coe_mk, polynomialOrbit, + fourier_coe_apply, Complex.ofReal_one, div_one, + polynomialPhase, characterPolynomial, Polynomial.eval_finsetSum, + Polynomial.eval_smul, smul_eq_mul, phase_sum] + apply Finset.prod_congr rfl + intro i _ + unfold phase + congr 1 + push_cast + ring + + + +theorem quantitative_torus_leibman (d : ℕ) (δ : ℝ) (hδ : 0 < δ) : + ∃ A : ℕ, 0 < A ∧ ∀ N : ℕ, 0 < N → ∀ p : ι → Polynomial ℝ, + (∀ i, (p i).natDegree ≤ d) → + (∃ f : C(UnitAddTorus ι, ℂ), LipschitzWith 1 f ∧ ‖f‖ ≤ 1 ∧ + δ ≤ ‖mean N (fun n => f (polynomialOrbit p n)) - ∫ t, f t ∂torusHaar ι‖) → + ∃ k : ι → ℤ, k ≠ 0 ∧ (∀ i, |(k i : ℝ)| ≤ A) ∧ ∃ m : ℕ → ℤ, + ∀ j : ℕ, 0 < j → j ≤ d → + |(∑ i, (k i : ℝ) * (p i).coeff j) - m j| ≤ (A : ℝ) / (N : ℝ) ^ j := by + classical + obtain ⟨S, η, hη, htest⟩ := torus_character_obstruction ι δ hδ + obtain ⟨B, hB, hinv⟩ := coefficient_inverse d η hη + let M := ∑ k ∈ S, ∑ i, (k i).natAbs + let A := B * (M + 1) + have hBA : B ≤ A := by dsimp [A]; nlinarith + have hA : 0 < A := hB.trans_le hBA + refine ⟨A, hA, ?_⟩ + intro N hN p hp hlarge + obtain ⟨k, hk, hk₀, hcorr⟩ := htest N hN (polynomialOrbit p) hlarge + rw [character_polynomialOrbit] at hcorr + obtain ⟨q, hq, hqB, m, hm⟩ := hinv N hN (characterPolynomial k p) + (characterPolynomial_degree k p d hp) hcorr + let k' : ι → ℤ := fun i => (q : ℤ) * k i + have hk' : k' ≠ 0 := by + intro he + apply hk₀ + funext i + have := congrFun he i + simp only [k', Pi.zero_apply, mul_eq_zero, Nat.cast_eq_zero] at this + exact this.resolve_left (Nat.ne_of_gt hq) + refine ⟨k', hk', ?_, m, ?_⟩ + · intro i + have hki : (k i).natAbs ≤ M := by + have h₁ : (k i).natAbs ≤ ∑ x, (k x).natAbs := + Finset.single_le_sum (f := fun x => (k x).natAbs) (fun x _ => Nat.zero_le _) (Finset.mem_univ i) + have h₂ : (∑ x, (k x).natAbs) ≤ M := + Finset.single_le_sum (f := fun x : ι → ℤ => ∑ i, (x i).natAbs) (fun x (_ : x ∈ S) => Nat.zero_le _) hk + exact h₁.trans h₂ + have hkM : |(k i : ℝ)| ≤ (M : ℝ) := by + simpa only [Nat.cast_natAbs, Int.cast_abs] using (Nat.cast_le.mpr hki : ((k i).natAbs : ℝ) ≤ M) + have hq₀ : (0 : ℝ) ≤ q := Nat.cast_nonneg _ + simp only [k', Int.cast_mul, Int.cast_natCast, abs_mul, abs_of_nonneg hq₀] + have h := mul_le_mul (Nat.cast_le.mpr hqB : (q : ℝ) ≤ B) hkM + (abs_nonneg _) (Nat.cast_nonneg B) + have hMA : (B : ℝ) * M ≤ A := by + dsimp [A] + push_cast + nlinarith [(show (0 : ℝ) ≤ B from Nat.cast_nonneg B)] + exact h.trans hMA + · intro j hj hjd + have he : (∑ i, (k' i : ℝ) * (p i).coeff j) = + (q : ℝ) * (characterPolynomial k p).coeff j := by + simp only [k', Int.cast_mul, Int.cast_natCast, characterPolynomial_coeff, + Finset.mul_sum] + apply Finset.sum_congr rfl + intro i _ + ring + rw [he] + exact (hm j hj hjd).trans (div_le_div_of_nonneg_right (Nat.cast_le.mpr hBA) + (by positivity)) + +end +end TorusLeibman +end + + + +section +noncomputable section +open scoped BigOperators +namespace AbelianMalcevTorus +open RationalLattice RationalQuotientFunctions +variable {G : Type*} [Group G] [TopologicalSpace G] +variable {n : ℕ} (c : RealCoordinates G n) +variable (hadd : ∀ g h : G, ∀ i : Fin n, c.coord (g*h) i=c.coord g i+c.coord h i) +variable (Γ : Subgroup G) (hΓ : ∀ g : G, g∈Γ ↔ ∀ i, ∃ z : ℤ, c.coord g i=z) + + + +def torusProjection (g : G) : UnitAddTorus (Fin n) := fun i => (c.coord g i : UnitAddCircle) + +include hadd in +lemma torusProjection_mul (g h : G) : + torusProjection c (g*h)=torusProjection c g+torusProjection c h := by + ext i + simp only [torusProjection,hadd,AddCircle.coe_add,Pi.add_apply] + +lemma torusProjection_one : torusProjection c (1:G)=0 := by + ext i + simp [torusProjection,c.one_coord] + +include hΓ in +lemma torusProjection_eq_zero (g : G) : torusProjection c g=0 ↔ g∈Γ := by + rw [hΓ] + constructor + · intro h i + have hi : (c.coord g i : UnitAddCircle)=0 := congrFun h i + obtain ⟨z,hz⟩ := (AddCircle.coe_eq_zero_iff (1:ℝ)).mp hi + exact ⟨z,by simpa using hz.symm⟩ + · intro h + ext i + obtain ⟨z,hz⟩ := h i + exact (AddCircle.coe_eq_zero_iff (1:ℝ)).mpr ⟨z,by simpa using hz.symm⟩ + +lemma torusProjection_surjective : Function.Surjective (torusProjection c) := by + intro t + have hh (i : Fin n) : ∃ x : ℝ, (x : UnitAddCircle)=t i := + QuotientAddGroup.mk_surjective (t i) + choose x hx using hh + exact ⟨c.coord.symm x,by ext i; simpa [torusProjection] using hx i⟩ + +lemma continuous_torusProjection : Continuous (torusProjection c) := by + apply continuous_pi + intro i + exact (AddCircle.continuous_mk' (1:ℝ)).comp ((continuous_apply i).comp c.coord.continuous) + + +def quotientTorus : C(G⧸Γ,UnitAddTorus (Fin n)) := + ⟨cosetLift Γ (torusProjection c) (by + intro g a ha + rw [torusProjection_mul c hadd, (torusProjection_eq_zero c Γ hΓ a).mpr ha,add_zero]), + continuous_cosetLift _ _ _ (continuous_torusProjection c)⟩ + +@[simp] lemma quotientTorus_mk (g : G) : + quotientTorus c hadd Γ hΓ (QuotientGroup.mk g)=torusProjection c g := rfl + +lemma quotientTorus_bijective : Function.Bijective (quotientTorus c hadd Γ hΓ) := by + constructor + · intro x y h + induction x using Quotient.inductionOn with | h g => + induction y using Quotient.inductionOn with | h a => + apply QuotientGroup.eq.mpr + apply (torusProjection_eq_zero c Γ hΓ (g⁻¹*a)).mp + have hm := torusProjection_mul c hadd g⁻¹ g + rw [inv_mul_cancel,torusProjection_one] at hm + rw [torusProjection_mul c hadd] + change torusProjection c g=torusProjection c a at h + rw [← h] + exact hm.symm + · intro y + obtain ⟨g,hg⟩ := torusProjection_surjective c y + exact ⟨QuotientGroup.mk g,hg⟩ + +include c hΓ in +lemma quotient_compact : CompactSpace (G⧸Γ) := by + obtain ⟨K,hK,hrep⟩ := compact_reps_of_integerCoordinates c Γ hΓ + exact (show CompactGroupProducts.HasCompactReps ⊤ Γ from + ⟨K,hK,Set.subset_univ _,fun g _ => hrep g⟩).quotient_compactSpace + + + +def quotientHomeomorph : (G⧸Γ) ≃ₜ UnitAddTorus (Fin n) := by + letI := quotient_compact c Γ hΓ + let e := Equiv.ofBijective (quotientTorus c hadd Γ hΓ) (quotientTorus_bijective c hadd Γ hΓ) + exact Continuous.homeoOfEquivCompactToT2 (f:=e) (quotientTorus c hadd Γ hΓ).continuous + +@[simp] lemma quotientHomeomorph_mk (g : G) : + quotientHomeomorph c hadd Γ hΓ (QuotientGroup.mk g)=torusProjection c g := rfl + +lemma quotientHomeomorph_smul (g : G) (x : G⧸Γ) : + quotientHomeomorph c hadd Γ hΓ (g • x)= + torusProjection c g+quotientHomeomorph c hadd Γ hΓ x := by + induction x using Quotient.inductionOn with | h a => + exact torusProjection_mul c hadd g a + +end AbelianMalcevTorus +end +end + + + +section +noncomputable section +namespace AbelianMalcevTorus +open MeasureTheory RationalLattice +variable {G : Type*} [Group G] [TopologicalSpace G] [IsTopologicalGroup G] +variable {n : ℕ} (c : RealCoordinates G n) +variable (hadd : ∀ g h : G, ∀ i : Fin n, c.coord (g*h) i=c.coord g i+c.coord h i) +variable (Γ : Subgroup G) (hΓ : ∀ g : G, g∈Γ ↔ ∀ i, ∃ z : ℤ, c.coord g i=z) +variable [MeasurableSpace (G⧸Γ)] [BorelSpace (G⧸Γ)] + + + +theorem coordinateHaar_map (μ : Measure (G⧸Γ)) [IsProbabilityMeasure μ] + [SMulInvariantMeasure G (G⧸Γ) μ] : + Measure.map (quotientHomeomorph c hadd Γ hΓ) μ = FourierObstruction.torusHaar (Fin n) := by + let e := quotientHomeomorph c hadd Γ hΓ + let ν := Measure.map e μ + let : IsProbabilityMeasure ν := + (Measure.isProbabilityMeasure_map_iff e.measurable.aemeasurable).mpr inferInstance + have hinv : ν.IsAddLeftInvariant := by + constructor + intro t + obtain ⟨g,rfl⟩ := torusProjection_surjective c t + change Measure.map (fun x => torusProjection c g+x) (Measure.map e μ)=Measure.map e μ + rw [Measure.map_map (by fun_prop) e.measurable] + have he : (fun x => torusProjection c g+x) ∘ e=e ∘ (fun x : G⧸Γ => g • x) := by + funext x + exact (quotientHomeomorph_smul c hadd Γ hΓ g x).symm + rw [he,← Measure.map_map e.measurable (by fun_prop),MeasureTheory.map_smul g μ] + let := hinv + let : ν.IsAddHaarMeasure := Measure.isAddHaarMeasure_of_isCompact_nonempty_interior ν Set.univ + isCompact_univ (by simp) (by simp) (by simp) + let : MeasureSpace UnitAddCircle := ⟨AddCircle.haarAddCircle⟩ + let : (volume : Measure UnitAddCircle).IsAddHaarMeasure := + inferInstanceAs (Measure.IsAddHaarMeasure AddCircle.haarAddCircle) + let : (FourierObstruction.torusHaar (Fin n)).IsAddHaarMeasure := by + change (volume : Measure (UnitAddTorus (Fin n))).IsAddHaarMeasure + infer_instance + exact Measure.isAddHaarMeasure_eq_of_isProbabilityMeasure ν (FourierObstruction.torusHaar (Fin n)) + +end AbelianMalcevTorus + +end +end +end +end +end + +end OAI diff --git a/lean/OAI/Combinatorics/SumProduct/Alignment/AbelianMalcev02.lean b/lean/OAI/Combinatorics/SumProduct/Alignment/AbelianMalcev02.lean new file mode 100644 index 0000000000000000000000000000000000000000..1930b8a427859d03d97173d024716564cb23545a --- /dev/null +++ b/lean/OAI/Combinatorics/SumProduct/Alignment/AbelianMalcev02.lean @@ -0,0 +1,275 @@ +import Mathlib +import OAI.Combinatorics.SumProduct.Alignment.AbelianMalcev01 +import OAI.Combinatorics.SumProduct.Alignment.MalcevHorizontal03 +import OAI.Combinatorics.SumProduct.Alignment.RationalTail02 +import OAI.Geometry.NilpotentCharts.Main + +namespace OAI + +section +section +section +section +noncomputable section +end +end + + + +section +noncomputable section +namespace AbelianMalcevTorus +open RationalLattice MeasureTheory +variable {G : Type*} [Group G] [TopologicalSpace G] [IsTopologicalGroup G] +variable {n : ℕ} (c : RealCoordinates G n) +variable (hadd : ∀ g h : G, ∀ i : Fin n, c.coord (g*h) i=c.coord g i+c.coord h i) +variable (Γ : Subgroup G) (hΓ : ∀ g : G, g∈Γ ↔ ∀ i, ∃ z : ℤ, c.coord g i=z) +variable (mtr : MetricSpace (G⧸Γ)) +variable (htop : mtr.toUniformSpace.toTopologicalSpace=(inferInstance : TopologicalSpace (G⧸Γ))) + + + +def metricHomeomorph : @Homeomorph (G⧸Γ) (UnitAddTorus (Fin n)) + mtr.toUniformSpace.toTopologicalSpace inferInstance := by + refine @Homeomorph.mk _ _ mtr.toUniformSpace.toTopologicalSpace inferInstance + ((quotientHomeomorph c hadd Γ hΓ).toEquiv) ?_ ?_ + · rw [htop] + exact (quotientHomeomorph c hadd Γ hΓ).continuous_toFun + · rw [htop] + exact (quotientHomeomorph c hadd Γ hΓ).continuous_invFun + +omit [IsTopologicalGroup G] in +@[simp] lemma metricHomeomorph_apply [IsTopologicalGroup G] (x : G⧸Γ) : + metricHomeomorph c hadd Γ hΓ mtr htop x=quotientHomeomorph c hadd Γ hΓ x := rfl + +include hΓ htop in +omit [IsTopologicalGroup G] in +lemma metric_compact [IsTopologicalGroup G] : + @CompactSpace (G⧸Γ) mtr.toUniformSpace.toTopologicalSpace := by + rw [htop] + exact quotient_compact c Γ hΓ + +variable [MeasurableSpace (G⧸Γ)] [BorelSpace (G⧸Γ)] +include htop in +omit [IsTopologicalGroup G] in +lemma metric_borelSpace [IsTopologicalGroup G] : + @BorelSpace (G⧸Γ) mtr.toUniformSpace.toTopologicalSpace inferInstance := by + rw [htop] + infer_instance + +theorem metric_coordinateHaar_map (μ : Measure (G⧸Γ)) [IsProbabilityMeasure μ] + [SMulInvariantMeasure G (G⧸Γ) μ] : + Measure.map (metricHomeomorph c hadd Γ hΓ mtr htop) μ = FourierObstruction.torusHaar (Fin n) := by + have he : (metricHomeomorph c hadd Γ hΓ mtr htop : (G⧸Γ) → UnitAddTorus (Fin n))= + quotientHomeomorph c hadd Γ hΓ := funext (metricHomeomorph_apply c hadd Γ hΓ mtr htop) + rw [he] + exact coordinateHaar_map c hadd Γ hΓ μ + +end AbelianMalcevTorus +end +end + + + +section +noncomputable section +open scoped BigOperators +open _root_.Polynomial _root_.OAI.Polynomial +namespace AbelianMalcevTorus +open RationalLattice CubeFaces LeibmanSquare MalcevCharacters +variable {G : Type*} [Group G] [TopologicalSpace G] [IsTopologicalGroup G] +variable {n : ℕ} (c : RealCoordinates G n) +variable (hadd : ∀ g h : G, ∀ i : Fin n, c.coord (g*h) i=c.coord g i+c.coord h i) + + + +def additiveCoordinates : RealCoordinates G n where + coord := c.coord + one_coord := c.one_coord + correction _ := 0 + mul_coord g h i := by simpa using hadd g h i + +abbrev integerCharacter (k : Fin n → ℤ) : G →* Multiplicative ℝ := + MalcevHorizontal.character (additiveCoordinates c hadd) le_rfl (fun _ => rfl) k + +omit [IsTopologicalGroup G] in +lemma integerCharacter_apply [IsTopologicalGroup G] (k : Fin n → ℤ) (g : G) : + (integerCharacter c hadd k g).toAdd=∑ i, (k i:ℝ)*c.coord g i := rfl + +lemma basis_integerCharacter (i : Fin n) (g : G) : + (integerCharacter c hadd (Pi.single i 1) g).toAdd=c.coord g i := by + classical + rw [integerCharacter_apply] + simp [Pi.single_apply] + +variable (H : Filtration G) +include hadd in + + +theorem polynomial_coordinates (s : ℕ) (hs : H.level (s+1)=⊥) + (f : ℤ → G) (hf : Polynomial H 0 f) : + ∃ p : Fin n → ℝ[X], (∀ i, (p i).natDegree ≤ s) ∧ + ∀ z : ℤ, ∀ i, (p i).eval (z:ℝ)=c.coord (f z) i := by + have hh (i : Fin n) := character_polynomial H s hs hf (integerCharacter c hadd (Pi.single i 1)) + choose p hp he using hh + exact ⟨p,hp,fun z i => (he i z).trans (basis_integerCharacter c hadd i (f z))⟩ + +variable (hsk : SecondKind c) +include hsk in + + +lemma coordinates_additive_of_commutator_bot (hcomm : _root_.commutator G ≤ (⊥ : Subgroup G)) : + ∀ g h : G, ∀ i : Fin n, c.coord (g*h) i=c.coord g i+c.coord h i := by + intro g h i + apply MalcevCharacters.prefix_coord_mul c hsk ⊥ n hcomm _ i i.isLt g h + intro a ha j _ + have ha' : a=1 := ha + rw [ha',c.one_coord] + +include hsk in +lemma coordinates_additive_of_secondLevel_bot (h1 : H.level 1=⊤) (h2 : H.level 2=⊥) : + ∀ g h : G, ∀ i : Fin n, c.coord (g*h) i=c.coord g i+c.coord h i := by + apply coordinates_additive_of_commutator_bot c hsk + have hc := H.commutator_le 1 1 + simpa only [h1,show 1+1=2 from rfl,h2,← _root_.commutator_def] using hc + +end AbelianMalcevTorus +end +end + + + +section +noncomputable section +open scoped BigOperators +namespace TorusLeibman +open MeasureTheory PolynomialWeyl FourierObstruction +variable {X : Type*} [MetricSpace X] [CompactSpace X] + [MeasurableSpace X] [BorelSpace X] +variable {ι : Type*} [Fintype ι] + + + +theorem quantitative_homeomorphic_torus (e : X ≃ₜ UnitAddTorus ι) + (μ : Measure X) [IsProbabilityMeasure μ] (hmap : Measure.map e μ=torusHaar ι) + (d : ℕ) (δ : ℝ) (hδ : 0<δ) : + ∃ A : ℕ, 0 F (e.symm (polynomialOrbit p n)))-(∫ x, F x ∂μ)‖) → + ∃ k : ι → ℤ, k≠0 ∧ (∀ i, |(k i:ℝ)| ≤ A) ∧ ∃ m : ℕ → ℤ, + ∀ j : ℕ, 0 pull F (polynomialOrbit p n))-_‖ + rw [hint] + exact hdisc + obtain ⟨Φ,hΦ,hdΦ⟩ := htest (discrepancy (torusHaar ι) N (polynomialOrbit p)) + (discrepancy_bound _ N hN _) hlarge + exact ⟨Φ,(hS Φ hΦ).1,(hS Φ hΦ).2,hdΦ⟩ + +end TorusLeibman +end +end + + + +section +noncomputable section +open _root_.Polynomial _root_.OAI.Polynomial +open scoped BigOperators +namespace AbelianMalcevTorus +open RationalLattice CubeFaces LeibmanSquare MeasureTheory MalcevHorizontal +variable {G : Type*} [Group G] [TopologicalSpace G] [IsTopologicalGroup G] +variable {n : ℕ} (c : RealCoordinates G n) +variable (hadd : ∀ g h : G, ∀ i : Fin n, c.coord (g*h) i=c.coord g i+c.coord h i) +variable (Γ : Subgroup G) (hΓ : ∀ g : G, g∈Γ ↔ ∀ i, ∃ z : ℤ, c.coord g i=z) +variable [MeasurableSpace (G⧸Γ)] [hBorel : @BorelSpace (G⧸Γ) (QuotientGroup.instTopologicalSpace Γ) inferInstance] +variable [mtr : MetricSpace (G⧸Γ)] +variable (htop : mtr.toUniformSpace.toTopologicalSpace=QuotientGroup.instTopologicalSpace Γ) +local instance : TopologicalSpace (G⧸Γ) := mtr.toUniformSpace.toTopologicalSpace + +include hadd hΓ htop in + + +theorem quantitative_abelian_producer (H : Filtration G) (s : ℕ) (hs : H.level (s+1)=⊥) + (μ : Measure (G⧸Γ)) [IsProbabilityMeasure μ] [SMulInvariantMeasure G (G⧸Γ) μ] + (δ : ℝ) (hδ : 0<δ) : + letI : CompactSpace (G⧸Γ) := metric_compact c Γ hΓ mtr htop + letI : BorelSpace (G⧸Γ) := metric_borelSpace Γ mtr htop + ∃ U : Finset (G →* Multiplicative ℝ), + (∀ χ∈U, Continuous χ ∧ (∀ g∈Γ, ∃ z : ℤ, (χ g).toAdd=z)) ∧ + ∃ A : ℝ, 0 QuotientGroup.mk (f k)) F‖) → + ∃ χ∈U, χ≠1 ∧ ∃ P : ℝ[X], P.natDegree ≤ s ∧ + (∀ z : ℤ, P.eval (z:ℝ)=(χ (f z)).toAdd) ∧ + ∀ j : ℕ, 0 rfl + let U := boundedCharacters c' le_rfl hz A + refine ⟨U,?_,(A:ℝ),by exact_mod_cast hA,?_⟩ + · intro χ hχ + exact ⟨boundedCharacters_continuous c' le_rfl hz A χ hχ, + boundedCharacters_integral c' le_rfl hz A Γ hΓ χ hχ⟩ + · intro N hN f hf hdisc + obtain ⟨p,hp,hpe⟩ := polynomial_coordinates c hadd H s hs f hf + have heval (k : ℕ) : e.symm (TorusLeibman.polynomialOrbit p k)=QuotientGroup.mk (f k) := by + apply e.injective + rw [e.apply_symm_apply] + change TorusLeibman.polynomialOrbit p k=torusProjection c (f k) + ext i + simp only [TorusLeibman.polynomialOrbit,torusProjection] + rw [← hpe (k:ℤ) i] + simp only [Int.cast_natCast] + obtain ⟨k,hk,hkA,z,hz⟩ := hprod N hN p hp (by + obtain ⟨F,hFL,hFn,hF⟩ := hdisc + refine ⟨F,hFL,hFn,?_⟩ + change δ ≤ ‖PolynomialWeyl.mean N (fun n => F (QuotientGroup.mk (f n)))-(∫ x, F x ∂μ)‖ at hF + simpa only [heval] using hF) + have hkAi : ∀ i, |k i| ≤ (A:ℤ) := by + intro i + exact_mod_cast hkA i + refine ⟨integerCharacter c hadd k,mem_boundedCharacters c' le_rfl _ A k hkAi, + character_ne_one c' le_rfl _ hk,TorusLeibman.characterPolynomial k p, + TorusLeibman.characterPolynomial_degree k p s hp,?_,?_⟩ + · intro t + rw [integerCharacter_apply] + simp only [TorusLeibman.characterPolynomial,eval_finsetSum,eval_smul,smul_eq_mul,hpe] + · intro j hj + by_cases hjs : j ≤ s + · exact ⟨z j,by simpa only [TorusLeibman.characterPolynomial_coeff] using hz j hj hjs⟩ + · refine ⟨0,?_⟩ + have hdeg := TorusLeibman.characterPolynomial_degree k p s hp + rw [coeff_eq_zero_of_natDegree_lt (lt_of_le_of_lt hdeg (Nat.lt_of_not_ge hjs))] + simp only [Int.cast_zero,sub_zero,abs_zero] + positivity + +end AbelianMalcevTorus + +end +end +end +end +end + +end OAI diff --git a/lean/OAI/Combinatorics/SumProduct/Alignment/Admissible01.lean b/lean/OAI/Combinatorics/SumProduct/Alignment/Admissible01.lean new file mode 100644 index 0000000000000000000000000000000000000000..a650977f121ec032c2ce27a0e3416f3e38436b2d --- /dev/null +++ b/lean/OAI/Combinatorics/SumProduct/Alignment/Admissible01.lean @@ -0,0 +1,303 @@ +import Mathlib +import OAI.Combinatorics.SumProduct.Alignment.Blocks01 +import OAI.Geometry.NilpotentCharts.Main + +namespace OAI + +open scoped BigOperators +section +noncomputable section +open Filter MeasureTheory +open scoped BigOperators ENNReal Topology +noncomputable section +open scoped BigOperators Topology BoundedContinuousFunction +noncomputable section +open scoped BigOperators +open MeasureTheory Filter Function +noncomputable section +open scoped BigOperators +noncomputable section +open Filter MeasureTheory +open scoped Topology BoundedContinuousFunction NNReal +noncomputable section +open scoped Topology BigOperators +noncomputable section +open scoped Topology BigOperators commutatorElement +noncomputable section +open scoped Topology BoundedContinuousFunction NNReal +noncomputable section +open scoped BigOperators +noncomputable section +open Filter MeasureTheory +open scoped Topology BigOperators BoundedContinuousFunction NNReal +noncomputable section +open Filter MeasureTheory +open scoped Topology BigOperators +namespace SourceAdmissible +open SourceBlocks SourceChartedAlignment MicrocellScale AdmissibleMicrocellBoundary +open ConstructedWordPlan.GlobalWordPlan +open ConstructedWordPlan.GlobalWordPlan.SourceTerminalArithmetic +open SourceIntegerArrays.GlobalJoint.SourceFrozenFamily +attribute [local instance] Classical.propDecidable + + +def previous {a : ℕ} (X : Fin a → ℕ) (i : Fin a) : ℕ := + ∏ j ∈ Finset.univ.filter (fun j : Fin a => j < i), X j + + + +structure Parameters (a : ℕ) where + M : ℕ → ℕ + ht : ℕ → Fin a → ℤ + H : ℕ → Fin a → ℕ + X : ℕ → Fin a → ℕ + Mpos : ∀ N, 0 < M N + htpos : ∀ N i, 0 < ht N i + Hpos : ∀ N i, 0 < H N i + Xpow : ∀ N i, ∃ k : ℕ, X N i = 2^k + Msmooth : ∀ N, RoughScales.Smooth (N+1) (M N : ℤ) + htsmooth : ∀ N i, RoughScales.Smooth (N+1) (ht N i) + Mdiv : ∀ N, primorial (N+1) ^ (N+1) ∣ M N + htdiv : ∀ N i, (primorial (N+1) : ℤ) ^ (N+1) ∣ ht N i + singleton_bound : ∀ N i, ht N i ≤ M N + block_bound : ∀ N (B : Block a), height (ht N) B.set ≤ M N + ratio : ∀ N (B : Block a) A, Added B.1 B.2.val A → + ∃ d : ℤ, height (ht N) A = height (ht N) B.set * + ((primorial (N+1) : ℤ) ^ (N+1) * d) + Hdiv : ∀ N i, M N ∣ H N i + Hdom : ∀ i, Dominates (fun N => (H N i : ℝ)) + (earlierScale M (fun N => previous (X N) i)) + Xdom : ∀ i, Dominates (fun N => Real.log (X N i : ℝ)) (fun N => (H N i : ℝ)) + +variable {a : ℕ} (A : Parameters a) + +def Parameters.L (N : ℕ) : ℤ := (A.M N : ℤ) * (primorial (N+1) : ℤ)^(N+1) + +lemma Parameters.Xpos (N : ℕ) (i : Fin a) : 0 < A.X N i := by + obtain ⟨k,hk⟩ := A.Xpow N i + rw [hk] + positivity + +lemma Parameters.Wdiv (N : ℕ) : primorial (N+1) ∣ A.M N := + (dvd_pow_self _ (by omega : N+1 ≠ 0)).trans (A.Mdiv N) + +lemma Parameters.Wle (N : ℕ) : primorial (N+1) ≤ A.M N := + Nat.le_of_dvd (A.Mpos N) (A.Wdiv N) + +lemma Parameters.Lpos (N : ℕ) : 0 < A.L N := + (SourceHierarchyRates.source_modulus_size _ _ _ (A.Mpos N) (primorial_pos _) (A.Mdiv N)).1 + +lemma Parameters.Lbound (N : ℕ) : (A.L N : ℝ) ≤ (A.M N : ℝ)^2 := + by simpa [Parameters.L] using + (SourceHierarchyRates.source_modulus_size _ _ _ (A.Mpos N) (primorial_pos _) (A.Mdiv N)).2 + +lemma Parameters.Lsmooth (N : ℕ) : RoughScales.Smooth (N+1) (A.L N) := by + apply RoughRationalBlock.smooth_mul (A.Msmooth N) + intro p hp hd + have hp' : Prime (p:ℤ) := Int.prime_iff_natAbs_prime.mpr (by simpa using hp) + exact IntegerAlignment.primorial_smooth (N+1) p hp (hp'.dvd_of_dvd_pow hd) + +lemma Parameters.Xtendsto (i : Fin a) : Tendsto (fun N => A.X N i) atTop atTop := + SourceHierarchyRates.raw_interval_tendsto (fun N => A.Hpos N i) + (fun N => A.Xpos N i) (A.Xdom i) + +lemma Parameters.XoverL (i : Fin a) : + Tendsto (fun N => (A.X N i : ℝ)/(A.L N : ℝ)) atTop atTop := + SourceHierarchyRates.raw_over_modulus_tendsto (fun N => A.Hpos N i) + (fun N => A.Xpos N i) A.L A.Lpos A.Lbound (A.Hdom i) (A.Xdom i) + +lemma Parameters.eventual_X (i : Fin a) : + ∀ᶠ N in atTop, 4*primorial (N+1) ≤ A.X N i := + SourceHierarchyRates.eventually_interval_four_modulus A.Mpos (fun N => A.Hpos N i) + (fun N => A.Xpos N i) A.Wle (A.Hdom i) (A.Xdom i) + +lemma Parameters.eventual_J (i : Fin a) : + ∀ᶠ N in atTop, 0 < MicrocellScale.length (A.M N) (A.H N i) := + (MicrocellEarlierScale.length_tendsto (Eventually.of_forall A.Mpos) + (A.Hdom i)).eventually_gt_atTop 0 + + +lemma Parameters.exists_tail : ∃ K : ℕ, ∀ N i, + 4*primorial (N+K+1) ≤ A.X (N+K) i ∧ + 0 < MicrocellScale.length (A.M (N+K)) (A.H (N+K) i) := by + have he : ∀ᶠ N in atTop, ∀ i, + 4*primorial (N+1) ≤ A.X N i ∧ + 0 < MicrocellScale.length (A.M N) (A.H N i) := by + apply eventually_all.mpr + intro i + exact (A.eventual_X i).and (A.eventual_J i) + obtain ⟨K,hK⟩ := eventually_atTop.mp he + exact ⟨K, fun N i => hK (N+K) (by omega) i⟩ + + + +structure TailBound (K : ℕ) : Prop where + hX : ∀ N i, 4*primorial (N+K+1) ≤ A.X (N+K) i + hJ : ∀ N i, 0 < MicrocellScale.length (A.M (N+K)) (A.H (N+K) i) + +lemma Parameters.exists_tailBound : ∃ K, TailBound A K := by + obtain ⟨K,hK⟩ := A.exists_tail + exact ⟨K,⟨fun N i => (hK N i).1, fun N i => (hK N i).2⟩⟩ + +variable (K : ℕ) (hK : TailBound A K) + + +def normalized : CommonScales a where + w N := N+K+1 + M N := A.M (N+K) + X N := A.X (N+K) + ht N := A.ht (N+K) + L N := A.L (N+K) + hw := (tendsto_add_atTop_nat 1).comp (tendsto_add_atTop_nat K) + hX := hK.hX + hXt j := (A.Xtendsto j).comp (tendsto_add_atTop_nat K) + hWM N := by exact_mod_cast A.Wdiv (N+K) + hM N := A.Mpos (N+K) + hMs N := A.Msmooth (N+K) + hL N := A.Lpos (N+K) + hLs N := A.Lsmooth (N+K) + hWL N := dvd_mul_of_dvd_left (by exact_mod_cast A.Wdiv (N+K)) _ + hML N := dvd_mul_right _ _ + hLexact N := rfl + hpowWM N := A.Mdiv (N+K) + hht N := A.htpos (N+K) + hXL j := (A.XoverL j).comp (tendsto_add_atTop_nat K) + + +lemma added_is_block {i : Fin a} {T S : Finset (Fin a)} (hT : T.Nonempty) + (h : Added i T S) : ∃ B : Block a, B.set = S := by + obtain ⟨P,j,hP,hPT,hTj,hji,rfl⟩ := h + obtain ⟨t,ht⟩ := hT + exact ⟨⟨j,⟨P,hP, fun p hp => (hPT p hp t ht).trans (hTj t ht)⟩⟩,rfl⟩ + + + +def pivotScales (i : Fin a) : PivotScales (normalized A K hK) (pivot i) where + H N := A.H (N+K) i + J N := MicrocellScale.length (A.M (N+K)) (A.H (N+K) i) + R N := radius (A.M (N+K)) (A.H (N+K) i) + hJ N := hK.hJ N i + hRJ N := (Nat.mul_div_cancel' (MicrocellScale.modulus_dvd _ _)).symm + hH N := A.Hpos (N+K) i + hRrad N := rfl + hdom C hC := (A.Hdom i C hC).comp (tendsto_add_atTop_nat K) + hxdom C hC := (A.Xdom i C hC).comp (tendsto_add_atTop_nat K) + hheight N e := by + obtain ⟨B,hB⟩ := added_is_block + (tailEnum i (pairEnum i e).val.1).property.1 (pairEnum i e).property + have hb := A.block_bound (N+K) B + change height (A.ht (N+K)) (pairEnum i e).val.2 ≤ (A.M (N+K) : ℤ) + simpa only [hB] using hb + hdisj := pivot_disjoint i + hratio N e := by + let B : Block a := ⟨i,tailEnum i (pairEnum i e).val.1⟩ + exact A.ratio (N+K) B _ (pairEnum i e).property + +end SourceAdmissible + + + + + + + +noncomputable section +open Filter MeasureTheory +open scoped Topology BigOperators BoundedContinuousFunction NNReal +namespace SourceAdmissible +open SourceBlocks SourceChartedAlignment MicrocellScale AdmissibleMicrocellBoundary +open ConstructedWordPlan.GlobalWordPlan ConstructedWordPlan.AlignmentScales +open SourceIntegerArrays.GlobalJoint.SourceFrozenFamily +open SourceIntegerArrays.GlobalJoint.SourceExposureSlots ProductExposureLaw +open SourcePivotPaths +variable {a s r : ℕ} + + + +def shiftModel {D : Pivot a} (F : ChartedModels s r D) (K : ℕ) : ChartedModels s r D := + { F with + g := fun t N => F.g t (N+K) + x := fun t N => F.x t (N+K) + obs := fun t N => F.obs t (N+K) + lip := fun t N => F.lip t (N+K) + bound := fun t N => F.bound t (N+K) } + + +def Parameters.models (A : Parameters a) {D : Pivot a} (F : ChartedModels s r D) + (N : ℕ) : ScalarModels D r := + scalarModels D r F.G F.Γ A.M (fun N => A.H N D.index) F.g F.x F.obs N + +lemma shift_models (A : Parameters a) (K : ℕ) (hK : TailBound A K) + (i : Fin a) (F : ChartedModels s r (pivot i)) (N : ℕ) : + (shiftModel F K).scalar (normalized A K hK) (pivotScales A K hK i) N = + A.models F (N+K) := rfl + + + +def Parameters.law (A : Parameters a) (N : ℕ) + (hX : ∀ i, 4*primorial (N+1) ≤ A.X N i) : Measure (Fin a → ℕ) := + outsideLaw (A.X N) (primorial (N+1)) (primorial_pos _) hX + + + +theorem admissible_charted_alignment (s r : ℕ) (hs : 1 ≤ s) : + 0 < delta s r hs (pivots a) ∧ + (∀ b ∈ multipliers (sourcePlan s r hs (pivots a)), ∀ j, 0 < b j) ∧ + ∀ (A : Parameters a) (Ss : ℕ → (D : Pivot a) → ScalarModels D r), + (∀ D ∈ pivots a, ∃ F : ChartedModels s r D, ∀ N, Ss N D = A.models F N) → + ∀ τ : ℝ, 0 < τ → ∀ ε : ℝ, 0 < ε → + ∀ᶠ N in atTop, ∃ hX : ∀ i, 4*primorial (N+1) ≤ A.X N i, + delta s r hs (pivots a) ≤ (A.law N hX).real + {u | ∃ b ∈ multipliers (sourcePlan s r hs (pivots a)), + ∀ D ∈ pivots a, comparison D r (Ss N D) (A.ht N) b u (u D.index) τ} + ε := by + refine ⟨delta_pos s r hs _, source_multipliers_pos s r hs _, ?_⟩ + intro A Ss hSs τ hτ ε hε + obtain ⟨K,hK⟩ := A.exists_tailBound + have hR : ∀ D ∈ pivots a, + Realizes s r (normalized A K hK) D (fun N => Ss (N+K) D) := by + intro D hD + apply Classical.choice + obtain ⟨i,rfl⟩ := List.mem_ofFn.mp hD + obtain ⟨F,hF⟩ := hSs (pivot i) (mem_pivots i) + exact ⟨⟨pivotScales A K hK i, shiftModel F K, + fun N => (hF (N+K)).trans (shift_models A K hK i F N).symm⟩⟩ + have he := (charted_alignment s r hs (pivots a) pivots_ordered).2.2 + (normalized A K hK) (fun N => Ss (N+K)) hR τ hτ ε hε + obtain ⟨N₀,hN₀⟩ := eventually_atTop.mp he + apply eventually_atTop.mpr + refine ⟨N₀+K,?_⟩ + intro N hN + have hNK : N-K+K=N := Nat.sub_add_cancel (by omega) + have hx : ∀ i, 4*primorial (N+1) ≤ A.X N i := by + simpa only [hNK] using hK.hX (N-K) + refine ⟨hx,?_⟩ + have h := hN₀ (N-K) (by omega) + change delta s r hs (pivots a) ≤ + (A.law (N-K+K) (hK.hX (N-K))).real + {u | ∃ b ∈ multipliers (sourcePlan s r hs (pivots a)), + ∀ D ∈ pivots a, comparison D r (Ss (N-K+K) D) (A.ht (N-K+K)) b u (u D.index) τ} + ε at h + simpa only [hNK] using h + +end SourceAdmissible + + + + + + + +end +end +end +end +end +end +end +end +end +end +end +end +end + +end OAI diff --git a/lean/OAI/Combinatorics/SumProduct/Alignment/AffineCoefficient01.lean b/lean/OAI/Combinatorics/SumProduct/Alignment/AffineCoefficient01.lean new file mode 100644 index 0000000000000000000000000000000000000000..31a9cc49d91952a76a577a63717f877aecbc041e --- /dev/null +++ b/lean/OAI/Combinatorics/SumProduct/Alignment/AffineCoefficient01.lean @@ -0,0 +1,317 @@ +import Mathlib +import OAI.Combinatorics.SumProduct.Alignment.DensePolynomial01 +import OAI.Combinatorics.SumProduct.Alignment.FiniteCover01 +import OAI.Geometry.NilpotentCharts.Main + +namespace OAI + +section +section +section +section +noncomputable section +end +end + + + +section +noncomputable section +open scoped BigOperators +namespace FiniteCoverObservable +open MeasureTheory +variable {G X Y : Type*} [Group G] [TopologicalSpace G] [IsTopologicalGroup G] + [MetricSpace X] [CompactSpace X] [MetricSpace Y] [CompactSpace Y] + [MeasurableSpace X] [BorelSpace X] [MeasurableSpace Y] [BorelSpace Y] + [MulAction G X] [ContinuousSMul G X] + + + +omit [IsTopologicalGroup G] in +theorem finite_unit_cover_tests (q : C(Y,X)) (C : Set G) (hC : IsCompact C) + (μ : Measure X) (ν : Measure Y) [IsProbabilityMeasure μ] [IsProbabilityMeasure ν] + [SMulInvariantMeasure G X μ] (hmap : Measure.map q ν=μ) + (δ : ℝ) (hδ : 0<δ) : + ∃ S : Finset C(Y,ℂ), (∀ F∈S, LipschitzWith 1 F ∧ ‖F‖ ≤ 1) ∧ + ∃ η : ℝ, 0<η ∧ ∀ N : ℕ, 0 (QuotientGroup.mk (b z).val : G⧸Γ)) (T:ℤ) → + (∀ z : ℤ, |(z:ℝ)| ≤ N → ‖c.coord (e z)‖ ≤ B) → + (∀ z w : ℤ, |(z:ℝ)| ≤ N → |(w:ℝ)| ≤ N → + ‖c.coord (e z*(e w)⁻¹)‖ ≤ (B/N)*|(z:ℝ)-(w:ℝ)|) → + ∀ F : C(G⧸Γ,ℂ), LipschitzWith 1 F → ‖F‖ ≤ 1 → + δ ≤ ‖FourierObstruction.discrepancy μ N (fun n => QuotientGroup.mk (f n)) F‖ → + let K : ℕ := N/(J*T) + 0 v⁻¹*f' ((T:ℤ)*z+w)*v)∈polynomials L 0 ∧ + ∃ Φ∈S, η ≤ ‖FourierObstruction.discrepancy ν K + (fun n => lift (v⁻¹*f' ((T:ℤ)*n+w)*v)) Φ‖ := by + classical + let D : Set G := (fun p : (H.level 2) × G => p.1.val*p.2) '' + ((c.coord.symm '' Metric.closedBall (0 : Fin m → ℝ) B) ×ˢ C) + have hD : IsCompact D := by + apply IsCompact.image + exact ((isCompact_closedBall (0 : Fin m → ℝ) B).image c.coord.symm.continuous).prod hCc + fun_prop + obtain ⟨S,hS,η,hη,htest⟩ := FiniteCoverObservable.finite_unit_cover_tests q D hD μ ν hmap (δ/4) (by positivity) + obtain ⟨J,hJ,N₀,hN₀,hprog⟩ := factor_progression_obstruction H Γ c B δ hB hδ Tmax hTmax + refine ⟨J,hJ,N₀,hN₀,S,hS,η,hη,?_⟩ + intro N hN T hT hTT L hL f f' e b hfp hfac hper hev hed F hFL hFn hdisc + have hn : 0 (F.norm_coe_le_norm x).trans hFn))) + have hd : δ*N ≤ ‖∑ i∈Finset.range N, (F (QuotientGroup.mk (f i))-(∫ x, F x ∂μ))‖ := + (mean_sum_obstruction hn _ _ δ).mp hdisc + obtain ⟨hK,hKT,hcomp,a,ha,r,hr,v,hv,hev0,hpp,hob⟩ := + hprog N hN T hT hTT C hC L hL f f' e b hfp hfac hper hev hed F hFL hFn _ hμ hd + let K := N/(J*T) + change 0 lift (v⁻¹*f' ((T:ℤ)*n+(a*K*T+r:ℕ))*v)) _ hDv F hFL hFn + have hh := (mean_sum_obstruction hK _ _ (δ/4)).mpr hob + convert hh using 2 + apply congrArg (fun z : ℂ => z-(∫ x, F x ∂μ)) + apply Finset.expect_congr rfl + intro n hn + rw [hq] + simp only [K] + congr 5; push_cast; ring_nf + +end FactorProgression +end +end + + + +section +noncomputable section +open _root_.Polynomial _root_.OAI.Polynomial Finset +open scoped BigOperators +namespace AffineCoefficientTransfer +open DensePolynomialInterpolation + + + +theorem integer_pullback (s T : ℕ) (hT : 0 ?_⟩ + have hTn : (T:ℝ)≠0 := by exact_mod_cast Nat.ne_of_gt hT + simp only [V,Polynomial.map_mul,Polynomial.map_C,map_taylor,eval_mul,eval_C, + taylor_eval,Int.cast_pow,Int.cast_natCast,Int.cast_neg,Int.coe_castRingHom, + eval_comp,eval_sub,eval_X] + rw [eval_map] + have hx : x+ -(r:ℝ)=(T:ℝ)*((T:ℝ)⁻¹*x-(r:ℝ)/(T:ℝ)) := by field_simp; ring + have hscale := scaleRoots_eval₂_mul (p:=U) (Int.castRingHom ℝ) ((T:ℝ)⁻¹*x-(r:ℝ)/(T:ℝ)) (T:ℤ) + simp only [Int.coe_castRingHom,Int.cast_natCast] at hscale + rw [hx,hscale] + rw [← mul_assoc,← pow_add,Nat.sub_add_cancel hU,eval_map] + + + +theorem eval_bound (s : ℕ) (R : ℝ[X]) (hR : R.natDegree ≤ s) + (A K M : ℝ) (hA : 0 ≤ A) (hK : 0 if h : 0 p.coeff j) hid + simp only [coeff_sub,coeff_C_mul,coeff_map,coeff_C,ite_eq_right (Nat.ne_of_gt hj),sub_zero,Int.coe_castRingHom] at hec + rw [hec,abs_mul,abs_of_nonneg (by positivity : 0≤(T:ℝ)^s)] + by_cases hjs : j ≤ s + · have hh := coefficient_bound_span s E hE N ((s+1:ℝ)*A*M^s) hNi (by positivity) hEv j hjs + calc + _ ≤ (T:ℝ)^s*(coefficientConstant s*((s+1:ℝ)*A*M^s)/(N:ℝ)^j) := + mul_le_mul_of_nonneg_left hh (by positivity) + _ = _ := by ring + · rw [coeff_eq_zero_of_natDegree_lt (hE.trans_lt (by omega)),abs_zero,mul_zero] + exact div_nonneg (mul_nonneg (mul_nonneg (by positivity) (coefficientConstant_pos s).le) (by positivity)) (by positivity) + +end AffineCoefficientTransfer + +end +end +end +end +end + +end OAI diff --git a/lean/OAI/Combinatorics/SumProduct/Alignment/AffineOrbit01.lean b/lean/OAI/Combinatorics/SumProduct/Alignment/AffineOrbit01.lean new file mode 100644 index 0000000000000000000000000000000000000000..b7d8d8174f25ab37a997f5ea2e866ca52f6e01e4 --- /dev/null +++ b/lean/OAI/Combinatorics/SumProduct/Alignment/AffineOrbit01.lean @@ -0,0 +1,332 @@ +import Mathlib +import OAI.Combinatorics.SumProduct.Alignment.RationalLattice25 +import OAI.Geometry.NilpotentCharts.Main + +namespace OAI + +open scoped BigOperators +section +section +noncomputable section +open MeasureTheory Filter Topology +end + +end + +section + + +noncomputable section +namespace ConstructedWordPlan.GlobalWordPlan +open AlignmentScales RationalPivotPlan +variable {n : ℕ} (s r : ℕ) (hs : 1 ≤ s) (D : Pivot n) (F : Finset (Scale n)) + + + +def pivotOptions : Finset (Path D) := (uniform_pivot_haar s r hs D F).choose + +lemma pivotOptions_nonempty : (pivotOptions s r hs D F).Nonempty := + (uniform_pivot_haar s r hs D F).choose_spec.1 + +lemma pivotOptions_paths : ∀ p∈pivotOptions s r hs D F, + p.length=D.targets ∧ ∀ o∈p,0 (x:G)) (by + intro x y h + have hh : x⁻¹ * y ∈ Λ.comap J.subtype := QuotientGroup.leftRel_apply.mp h + apply QuotientGroup.leftRel_apply.mpr + exact hh) + +omit [TopologicalSpace G] [IsTopologicalGroup G] in +@[simp] lemma quotientInclusion_mk (J Λ : Subgroup G) (x : J) : + quotientInclusion J Λ (QuotientGroup.mk x) = QuotientGroup.mk (x:G) := rfl + +omit [TopologicalSpace G] [IsTopologicalGroup G] in +lemma quotientInclusion_injective (J Λ : Subgroup G) : + Function.Injective (quotientInclusion J Λ) := by + intro x y + induction x using Quotient.inductionOn with | h x => + induction y using Quotient.inductionOn with | h y => + intro he + apply Quotient.sound + change (QuotientGroup.mk (x:G) : G ⧸ Λ) = QuotientGroup.mk (y:G) at he + have hh : (x:G)⁻¹ * (y:G) ∈ Λ := QuotientGroup.eq.mp he + apply QuotientGroup.leftRel_apply.mpr + exact hh + +omit [IsTopologicalGroup G] in +lemma continuous_quotientInclusion (J Λ : Subgroup G) : + Continuous (quotientInclusion J Λ) := by + rw [(QuotientGroup.isQuotientMap_mk (Λ.comap J.subtype)).continuous_iff] + exact QuotientGroup.continuous_mk.comp continuous_subtype_val + +omit [IsTopologicalGroup G] in +lemma quotientInclusion_embedding (J Λ : Subgroup G) + [CompactSpace (J ⧸ Λ.comap J.subtype)] [T2Space (G ⧸ Λ)] : + IsEmbedding (quotientInclusion J Λ) := + ((continuous_quotientInclusion J Λ).isClosedEmbedding + (quotientInclusion_injective J Λ)).isEmbedding + + + +theorem path_stays_in_subgroup (J Λ : Subgroup G) + [CompactSpace (J ⧸ Λ.comap J.subtype)] [T2Space (G ⧸ Λ)] + (hΛ : IsDiscrete (Λ : Set G)) (γ : C(unitInterval,G)) + (hγ0 : γ 0 ∈ J) + (hγ : ∀ t, ∃ x : J, QuotientGroup.mk (x:G) = (QuotientGroup.mk (γ t) : G ⧸ Λ)) : + ∀ t, γ t ∈ J := by + classical + let Δ := Λ.comap J.subtype + have hΔ : IsDiscrete (Δ : Set J) := + hΛ.preimage continuous_subtype_val.continuousOn Subtype.val_injective + let π := quotientInclusion J Λ + have hπ : IsEmbedding π := quotientInclusion_embedding J Λ + have hex : ∀ t, ∃ x : J ⧸ Δ, π x = (QuotientGroup.mk (γ t) : G ⧸ Λ) := by + intro t + obtain ⟨x,hx⟩ := hγ t + exact ⟨QuotientGroup.mk x,hx⟩ + choose q hq using hex + have hqc : Continuous q := hπ.continuous_iff.mpr (by + have he : π ∘ q = fun t => (QuotientGroup.mk (γ t) : G ⧸ Λ) := funext hq + rw [he] + exact QuotientGroup.continuous_mk.comp γ.continuous) + have hq0 : q 0 = QuotientGroup.mk (⟨γ 0,hγ0⟩ : J) := by + apply hπ.injective + exact hq 0 + obtain ⟨δ,hδ,hδ0⟩ := (Δ.isQuotientCoveringMap hΔ).isCoveringMap.exists_path_lifts + ⟨q,hqc⟩ ⟨γ 0,hγ0⟩ hq0 + have hδγ : (fun t => ((δ t : J) : G)) = γ := by + apply (Λ.isQuotientCoveringMap hΛ).isCoveringMap.eq_of_comp_eq + (continuous_subtype_val.comp δ.continuous) γ.continuous ?_ 0 ?_ + · funext t + have hd := congrArg π (congrFun hδ t) + exact hd.trans (hq t) + · exact congrArg Subtype.val hδ0 + intro t + rw [← congrFun hδγ t] + exact (δ t).property + + + +theorem map_mem_of_projected_orbit (J Λ : Subgroup G) + [PathConnectedSpace J] [CompactSpace (J ⧸ Λ.comap J.subtype)] + [T2Space (G ⧸ Λ)] (hΛ : IsDiscrete (Λ : Set G)) + (ψ : G → G) (hψ : Continuous ψ) (hψ1 : ψ 1 = 1) + (c : J) + (hpres : ∀ y : J, ∃ z : J, + (QuotientGroup.mk (z:G) : G ⧸ Λ) = QuotientGroup.mk (ψ (y:G) * (c:G))) : + ∀ y : J, ψ (y:G) ∈ J := by + intro y + let p := PathConnectedSpace.somePath (1:J) y + let γ : C(unitInterval,G) := ⟨fun t => ψ (p t : G) * (c:G), + (hψ.comp (continuous_subtype_val.comp p.continuous)).mul continuous_const⟩ + have hγ0 : γ 0 ∈ J := by + simpa only [γ, ContinuousMap.coe_mk, Path.source, OneMemClass.coe_one, hψ1, one_mul] + using c.property + have ht := path_stays_in_subgroup J Λ hΛ γ hγ0 (fun t => hpres (p t)) 1 + have hyc : ψ (y:G) * (c:G) ∈ J := by simpa [γ] using ht + simpa using J.mul_mem hyc (J.inv_mem c.property) + +end ClosedOrbitLift + +end + +section + + + + +noncomputable section +namespace AffineOrbitRestriction +open CubeLocalHaar Topology +variable {G : Type} [Group G] [TopologicalSpace G] [IsTopologicalGroup G] +variable (Λ J : Subgroup G) (h σ : G) + +lemma coset_eq_iff (x y : G) : + (QuotientGroup.mk (h*x*σ) : G⧸Λ)=QuotientGroup.mk (h*y*σ) ↔ + (QuotientGroup.mk x : G⧸conjugateLattice Λ σ)=QuotientGroup.mk y := by + simp only [QuotientGroup.eq,mem_conjugateLattice,mul_inv_rev,mul_assoc] + simp + +variable [PathConnectedSpace J] +variable [CompactSpace (J⧸(conjugateLattice Λ σ).comap J.subtype)] +variable [T2Space (G⧸conjugateLattice Λ σ)] +variable (hΛ : IsDiscrete (conjugateLattice Λ σ : Set G)) +variable (S : G →* G) (hS : Continuous S) +variable (hpres : ∀ y : J,∃ z : J, + (QuotientGroup.mk (S (h*(y:G)*σ)) : G⧸Λ)=QuotientGroup.mk (h*(z:G)*σ)) + + +def basedHom : G →* G := + (MulAut.conj (h⁻¹*S h)).toMonoidHom.comp S + +omit [TopologicalSpace G] [IsTopologicalGroup G] in +@[simp] lemma basedHom_apply (y : G) : + basedHom h S y=h⁻¹*S h*S y*(S h)⁻¹*h := by + simp [basedHom,MulAut.conj_apply,mul_assoc] + +include hS in +lemma basedHom_continuous : Continuous (basedHom h S) := by + have he : (basedHom h S : G → G)=(fun y=>h⁻¹*S h*S y*(S h)⁻¹*h) := + funext (basedHom_apply h S) + rw [he] + exact ((continuous_const.mul hS).mul continuous_const).mul continuous_const + + +omit [TopologicalSpace G] [IsTopologicalGroup G] [PathConnectedSpace J] + [CompactSpace (J⧸(conjugateLattice Λ σ).comap J.subtype)] + [T2Space (G⧸conjugateLattice Λ σ)] in +lemma physical_based (a : J) + (ha : (QuotientGroup.mk (S (h*σ)) : G⧸Λ)=QuotientGroup.mk (h*(a:G)*σ)) + (y : G) : + (QuotientGroup.mk (S (h*y*σ)) : G⧸Λ)= + QuotientGroup.mk (h*(basedHom h S y*(a:G))*σ) := by + have hh:=congrArg (fun x : G⧸Λ=>(S h*S y*(S h)⁻¹) • x) ha + change (QuotientGroup.mk ((S h*S y*(S h)⁻¹)*S (h*σ)) : G⧸Λ)= + QuotientGroup.mk ((S h*S y*(S h)⁻¹)*(h*(a:G)*σ)) at hh + convert hh using 1 + · congr 1 + simp [map_mul,mul_assoc] + · congr 1 + simp [basedHom_apply,mul_assoc] + +include hΛ hS hpres in + + +theorem exists_affine_restriction : + ∃ a : J,∃ φ : J →* J,Continuous φ ∧ + ∀ y : J,(QuotientGroup.mk (S (h*(y:G)*σ)) : G⧸Λ)= + QuotientGroup.mk (h*((a*φ y : J):G)*σ) := by + obtain ⟨a,ha⟩:=hpres 1 + simp only [OneMemClass.coe_one,mul_one] at ha + have hψ : ∀ y : J,basedHom h S (y:G)∈J := by + apply ClosedOrbitLift.map_mem_of_projected_orbit J (conjugateLattice Λ σ) hΛ + (basedHom h S) (basedHom_continuous h S hS) (map_one _) a + intro y + obtain ⟨z,hz⟩:=hpres y + refine ⟨z,?_⟩ + apply (coset_eq_iff Λ h σ (z:G) (basedHom h S (y:G)*(a:G))).mp + exact hz.symm.trans (physical_based Λ J h σ S a ha (y:G)) + let φ : J →* J := + { toFun:=fun y=>⟨(a:G)⁻¹*basedHom h S (y:G)*(a:G), + J.mul_mem (J.mul_mem (J.inv_mem a.property) (hψ y)) a.property⟩ + map_one':=by apply Subtype.ext; simp + map_mul':=by intro x y; apply Subtype.ext; simp [map_mul,mul_assoc] } + refine ⟨a,φ,?_,?_⟩ + · exact ((continuous_const.mul ((basedHom_continuous h S hS).comp + continuous_subtype_val)).mul continuous_const).subtype_mk _ + · intro y + convert physical_based Λ J h σ S a ha (y:G) using 1 + congr 1 + simp [φ,mul_assoc] + +end AffineOrbitRestriction +end + +end + +section + + + + +noncomputable section +namespace AffineOrbitRestriction +open CubeLocalHaar CubeFaces RationalLattice Topology +variable {G : Type} [Group G] [TopologicalSpace G] [IsTopologicalGroup G] +variable (Λ J : Subgroup G) (h σ : G) (H : Filtration J) (S : G →* G) (s : ℕ) + + + +def PreservesPhysicalFaces : Prop := + ∀ k ≤ s,∀ f∈cube (ι:=Fin (k+1)) H Finset.univ 0, + ∃ g∈cube (ι:=Fin (k+1)) H Finset.univ 0,∀ w, + (QuotientGroup.mk (if Fin.last k∈w then S (h*(f w:G)*σ) else h*(f w:G)*σ) : G⧸Λ)= + QuotientGroup.mk (h*(g w:G)*σ) + +omit [TopologicalSpace G] [IsTopologicalGroup G] in +lemma point_preservation_of_faces (hH0 : H.level 0=⊤) + (hpres : PreservesPhysicalFaces Λ J h σ H S s) (y : J) : + ∃ z : J,(QuotientGroup.mk (S (h*(y:G)*σ)) : G⧸Λ)= + QuotientGroup.mk (h*(z:G)*σ) := by + have hy : y∈H.level (0+0) := by simp [hH0] + have hf:=face_mem_cube (ι:=Fin 1) H + (Finset.empty_subset (Finset.univ : Finset (Fin 1))) (by simpa using hy) + obtain ⟨g,hg,he⟩:=hpres 0 (Nat.zero_le s) (face ∅ y) hf + refine ⟨g Finset.univ,?_⟩ + simpa [face_apply] using he Finset.univ + +lemma affine_faces_of_physical (a : J) (φ : J →* J) + (hphys : ∀ y : J,(QuotientGroup.mk (S (h*(y:G)*σ)) : G⧸Λ)= + QuotientGroup.mk (h*((a*φ y:J):G)*σ)) + (hpres : PreservesPhysicalFaces Λ J h σ H S s) : + PreservesFaces H ((conjugateLattice Λ σ).comap J.subtype) a φ s := by + intro k hk f hf + obtain ⟨g,hg,he⟩:=hpres k hk f hf + refine ⟨g,hg,?_⟩ + apply QuotientGroup.eq.mpr + intro w + change ((g w:G)⁻¹*(affineUpper (Fin.last k) a φ f w:J):G)∈conjugateLattice Λ σ + apply QuotientGroup.eq.mp + apply (coset_eq_iff Λ h σ (g w:G) (affineUpper (Fin.last k) a φ f w:J)).mp + have hh:=he w + by_cases hw : Fin.last k∈w + · simp only [hw,ite_true] at hh + simpa only [affineUpper,hw,ite_true] using hh.symm.trans (hphys (f w)) + · simpa only [affineUpper,hw,ite_false] using hh.symm + +variable [PathConnectedSpace J] +variable [CompactSpace (J⧸(conjugateLattice Λ σ).comap J.subtype)] +variable [T2Space (G⧸conjugateLattice Λ σ)] + + + +theorem exists_affine_face_restriction (hH0 : H.level 0=⊤) + (hΛ : IsDiscrete (conjugateLattice Λ σ : Set G)) (hS : Continuous S) + (hpres : PreservesPhysicalFaces Λ J h σ H S s) : + ∃ a : J,∃ φ : J →* J,Continuous φ ∧ + (∀ y : J,(QuotientGroup.mk (S (h*(y:G)*σ)) : G⧸Λ)= + QuotientGroup.mk (h*((a*φ y:J):G)*σ)) ∧ + PreservesFaces H ((conjugateLattice Λ σ).comap J.subtype) a φ s := by + obtain ⟨a,φ,hφ,hphys⟩:=exists_affine_restriction Λ J h σ hΛ S hS + (point_preservation_of_faces Λ J h σ H S s hH0 hpres) + exact ⟨a,φ,hφ,hphys,affine_faces_of_physical Λ J h σ H S s a φ hphys hpres⟩ + +end AffineOrbitRestriction + +end +end +end + +end OAI diff --git a/lean/OAI/Combinatorics/SumProduct/Alignment/AlignmentMass01.lean b/lean/OAI/Combinatorics/SumProduct/Alignment/AlignmentMass01.lean new file mode 100644 index 0000000000000000000000000000000000000000..999a45e5c3da540939c2f4319d59ebf8b6301fd7 --- /dev/null +++ b/lean/OAI/Combinatorics/SumProduct/Alignment/AlignmentMass01.lean @@ -0,0 +1,301 @@ +import Mathlib +import OAI.Combinatorics.SumProduct.Alignment.WordPlan01 +import OAI.Geometry.NilpotentCharts.Main + +namespace OAI + +open scoped BigOperators +section +section +noncomputable section +end + +end + +section + + +noncomputable section +namespace OwnTerminal +variable {G H X Y : Type*} [Group G] [Group H] [MulAction G X] [MulAction H Y] + +lemma project_pow (π : X → Y) (g : G) (h : H) + (hp : ∀ x,π (g • x)=h • π x) (k : ℕ) (x : X) : + π (g^k • x)=h^k • π x := by + induction k generalizing x with + | zero => simp + | succ k ih => simp only [pow_succ, mul_smul,ih,hp] + +lemma project_inv (π : X → Y) (g : G) (h : H) + (hp : ∀ x,π (g • x)=h • π x) (x : X) : + π (g⁻¹ • x)=h⁻¹ • π x := by + have he:=congrArg (fun y=>h⁻¹ • y) (hp (g⁻¹ • x)) + simpa using he.symm + +lemma project_zpow (π : X → Y) (g : G) (h : H) + (hp : ∀ x,π (g • x)=h • π x) (k : ℤ) (x : X) : + π (g^k • x)=h^k • π x := by + cases k with + | ofNat k => simpa using project_pow π g h hp k x + | negSucc k => + simpa only [zpow_negSucc,inv_pow] using + project_pow π g⁻¹ h⁻¹ (project_inv π g h hp) (k+1) x + +lemma project_list {E : Type*} (π : X → Y) (a : E → G) (b : E → H) + (l : List E) (hp : ∀ e∈l,∀ x,π (a e • x)=b e • π x) (x : X) : + π ((l.map a).prod • x)=(l.map b).prod • π x := by + induction l generalizing x with + | nil => simp + | cons e l ih => + simp only [List.map_cons,List.prod_cons,mul_smul] + rw [hp e (by simp),ih (fun t ht=>hp t (by simp [ht]))] + +open ConstructedWordPlan GlobalWordPlan RationalPivotPlan +variable {n : ℕ} (D : Pivot n) + + + +lemma terminal_projection (π : X → Y) (L : Fin D.pairs → G) (S : Fin D.pairs → H) + (j : Fin D.targets) (hp : ∀ e,D.owner e=j → ∀ x,π (L e • x)=S e • π x) + (q₀ : ℕ) (b : Scale n) (U : Finset (Fin D.pairs)) + (hU : ∀ e∈U,D.owner e=j) (x : X) : + π (FreeGroup.lift (letter D.index D.tail D.owner D.added L q₀ b) (baseWord D U) • x)= + FreeGroup.lift (letter D.index D.tail D.owner D.added S q₀ b) (baseWord D U) • π x := by + classical + simp only [baseWord,map_list_prod,List.map_map] + apply project_list + intro e he + simpa only [Function.comp_apply,FreeGroup.lift_apply_of,letter] using + project_zpow π (L e) (S e) (hp e (hU e (Finset.mem_toList.mp he))) + (qExponent D.index D.tail D.owner D.added q₀ b (e,1)).num + +end OwnTerminal +end + +end + +section + + + + +namespace AlignmentMass +open MeasureTheory Filter Topology +open scoped ENNReal NNReal +noncomputable section + +variable {X O : Type*} [MeasurableSpace X] [TopologicalSpace X] + [OpensMeasurableSpace X] [HasOuterApproxClosed X] [Fintype O] [Nonempty O] + + + +theorem finite_closed_mass (μ : ProbabilityMeasure X) + (ν : O → ℕ → ProbabilityMeasure X) (F : O → Set X) + (hF : ∀ o, IsClosed (F o)) + (hν : ∀ o, Tendsto (ν o) atTop (𝓝 μ)) + (hcover : ∀ n, 1 ≤ ∑ o, ν o n (F o)) : + ((Fintype.card O : ℝ≥0)⁻¹ : ℝ≥0∞) ≤ (μ : Measure X) (⋃ o, F o) := by + classical + have hq : (Fintype.card O : ℝ≥0) ≠ 0 := by exact_mod_cast Fintype.card_ne_zero + have hsum : (∑ _o : O, (Fintype.card O : ℝ≥0)⁻¹) = 1 := by + simp [nsmul_eq_mul, hq] + have hex : ∀ n, ∃ o, (Fintype.card O : ℝ≥0)⁻¹ ≤ ν o n (F o) := by + intro n + obtain ⟨o,_,ho⟩ := Finset.exists_le_of_sum_le Finset.univ_nonempty + (hsum.symm ▸ hcover n) + exact ⟨o,ho⟩ + have he : ∀ᶠ n in atTop, ∃ o, (Fintype.card O : ℝ≥0)⁻¹ ≤ ν o n (F o) := + Eventually.of_forall hex + obtain ⟨o,ho⟩ := frequently_exists.mp he.frequently + have hf : ∃ᶠ n in atTop, + ((Fintype.card O : ℝ≥0)⁻¹ : ℝ≥0∞) ≤ (ν o n : Measure X) (F o) := by + apply ho.mono + intro n hn + rw [← ProbabilityMeasure.ennreal_coeFn_eq_coeFn_toMeasure] + simpa only [ENNReal.coe_inv hq] using ENNReal.coe_le_coe.mpr hn + exact (le_limsup_of_frequently_le hf).trans + ((ProbabilityMeasure.limsup_measure_closed_le_of_tendsto (hν o) (hF o)).trans + (measure_mono (Set.subset_iUnion F o))) + + + +omit [TopologicalSpace X] [OpensMeasurableSpace X] [HasOuterApproxClosed X] [Nonempty O] in +theorem cover_sum [TopologicalSpace X] [OpensMeasurableSpace X] [HasOuterApproxClosed X] + [Nonempty O] {Z : Type*} [MeasurableSpace Z] (ρ : ProbabilityMeasure Z) + (Y : O → Z → X) (hY : ∀ o, Measurable (Y o)) (F : O → Set X) + (hF : ∀ o, MeasurableSet (F o)) (hcover : ∀ z, ∃ o, Y o z ∈ F o) : + 1 ≤ ∑ o, (ρ.map (Y o)) (F o) := by + have hu : (⋃ o, Y o ⁻¹' F o) = Set.univ := by + ext z + simp only [Set.mem_iUnion, Set.mem_preimage, Set.mem_univ, iff_true] + exact hcover z + have hh : (1:ℝ≥0∞) ≤ ∑ o, (ρ : Measure Z) (Y o ⁻¹' F o) := by + simpa [hu] using measure_iUnion_fintype_le (ρ : Measure Z) (fun o => Y o ⁻¹' F o) + apply ENNReal.coe_le_coe.mp + push_cast + simpa only [ProbabilityMeasure.ennreal_coeFn_eq_coeFn_toMeasure, + ProbabilityMeasure.map_apply' ρ (hY _).aemeasurable (hF _)] using hh + +section Thresholds +variable {J : Type*} + + +def ClosedGood (τ : ℝ) (A T : J → X → ℝ) : Set X := + {x | ∀ j, A j x ≤ 3*τ/2 ∨ 3*τ/2 ≤ T j x} + + +def OpenGood (τ : ℝ) (A T : J → X → ℝ) : Set X := + {x | ∀ j, A j x < 7*τ/4 ∨ 5*τ/4 < T j x} + + +def Success (τ : ℝ) (A T : J → X → ℝ) : Set X := + {x | ∀ j, 2*τ < A j x → τ < T j x} + +omit [MeasurableSpace X] [OpensMeasurableSpace X] [HasOuterApproxClosed X] in +lemma isClosed_closedGood (τ : ℝ) (A T : J → X → ℝ) + (hA : ∀ j, Continuous (A j)) (hT : ∀ j, Continuous (T j)) : + IsClosed (ClosedGood τ A T) := by + simp only [ClosedGood, Set.ofPred_forall, Set.ofPred_or] + exact isClosed_iInter fun j => (isClosed_le (hA j) continuous_const).union + (isClosed_le continuous_const (hT j)) + +omit [MeasurableSpace X] [OpensMeasurableSpace X] [HasOuterApproxClosed X] in +lemma isOpen_openGood [Finite J] (τ : ℝ) (A T : J → X → ℝ) + (hA : ∀ j, Continuous (A j)) (hT : ∀ j, Continuous (T j)) : + IsOpen (OpenGood τ A T) := by + simp only [OpenGood, Set.ofPred_forall, Set.ofPred_or] + exact isOpen_iInter_of_finite fun j => (isOpen_lt (hA j) continuous_const).union + (isOpen_lt continuous_const (hT j)) + +omit [MeasurableSpace X] [TopologicalSpace X] [OpensMeasurableSpace X] [HasOuterApproxClosed X] in +lemma closed_subset_open {τ : ℝ} (hτ : 0 < τ) (A T : J → X → ℝ) : + ClosedGood τ A T ⊆ OpenGood τ A T := by + intro x hx j + rcases hx j with h | h + · exact Or.inl (by linarith) + · exact Or.inr (by linarith) + +omit [MeasurableSpace X] [TopologicalSpace X] [OpensMeasurableSpace X] [HasOuterApproxClosed X] in +lemma open_subset_success {τ : ℝ} (A T A' T' : J → X → ℝ) + (hA : ∀ j x, |A' j x - A j x| ≤ τ/4) + (hT : ∀ j x, |T' j x - T j x| ≤ τ/4) : + OpenGood τ A T ⊆ Success τ A' T' := by + intro x hx j hj + rcases hx j with h | h + · have hb := (abs_le.mp (hA j x)).2 + linarith + · have hb := (abs_le.mp (hT j x)).1 + linarith +end Thresholds + + + +omit [TopologicalSpace X] [OpensMeasurableSpace X] [HasOuterApproxClosed X] in +theorem mixture_lower [TopologicalSpace X] [OpensMeasurableSpace X] [HasOuterApproxClosed X] + {B : Type*} [MeasurableSpace B] + (η : ProbabilityMeasure B) (μ : B → ProbabilityMeasure X) + (ρ : ProbabilityMeasure X) (S : Set X) (a : ℝ≥0∞) + (hmix : (ρ : Measure X) S = ∫⁻ b, (μ b : Measure X) S ∂(η : Measure B)) + (hb : ∀ᵐ b ∂(η : Measure B), a ≤ (μ b : Measure X) S) : + a ≤ (ρ : Measure X) S := by + rw [hmix] + simpa using (lintegral_mono_ae hb : + (∫⁻ _b, a ∂(η : Measure B)) ≤ ∫⁻ b, (μ b : Measure X) S ∂(η : Measure B)) + + + +omit [Fintype O] [Nonempty O] in +theorem eventually_success_mass [Fintype O] [Nonempty O] {J : Type*} [Finite J] + (μ : ProbabilityMeasure X) (ρ : ℕ → ProbabilityMeasure X) + (hρ : Tendsto ρ atTop (𝓝 μ)) {τ : ℝ} (hτ : 0 < τ) + (A T : O → J → X → ℝ) (A' T' : ℕ → O → J → X → ℝ) + (hA : ∀ o j, Continuous (A o j)) (hT : ∀ o j, Continuous (T o j)) + (he : ∀ᶠ n in atTop, ∀ o j x, + |A' n o j x - A o j x| ≤ τ/4 ∧ |T' n o j x - T o j x| ≤ τ/4) + {a δ : ℝ≥0∞} (hδ : δ < a) + (hm : a ≤ (μ : Measure X) (⋃ o, ClosedGood τ (A o) (T o))) : + ∀ᶠ n in atTop, δ < (ρ n : Measure X) (⋃ o, Success τ (A' n o) (T' n o)) := by + let U := ⋃ o, OpenGood τ (A o) (T o) + have hU : IsOpen U := isOpen_iUnion fun o => isOpen_openGood τ _ _ (hA o) (hT o) + have hsub : (⋃ o, ClosedGood τ (A o) (T o)) ⊆ U := + Set.iUnion_mono fun o => closed_subset_open hτ _ _ + have hmU : a ≤ (μ : Measure X) U := hm.trans (measure_mono hsub) + have hlim := ProbabilityMeasure.le_liminf_measure_open_of_tendsto hρ hU + have hev := eventually_lt_of_lt_liminf (hδ.trans_le (hmU.trans hlim)) + filter_upwards [he,hev] with n hen hn + apply hn.trans_le + apply measure_mono + exact Set.iUnion_mono fun o => open_subset_success _ _ _ _ + (fun j x => (hen o j x).1) (fun j x => (hen o j x).2) + + + +theorem conditional_mass {J : Type*} [Finite J] + (μ : ProbabilityMeasure X) (ν : O → ℕ → ProbabilityMeasure X) + (ρ : ℕ → ProbabilityMeasure X) + (hν : ∀ o, Tendsto (ν o) atTop (𝓝 μ)) + (hρ : Tendsto ρ atTop (𝓝 μ)) {τ : ℝ} (hτ : 0 < τ) + (A T : O → J → X → ℝ) (A' T' : ℕ → O → J → X → ℝ) + (hA : ∀ o j, Continuous (A o j)) (hT : ∀ o j, Continuous (T o j)) + (hcover : ∀ n, 1 ≤ ∑ o, ν o n (ClosedGood τ (A o) (T o))) + (he : ∀ᶠ n in atTop, ∀ o j x, + |A' n o j x - A o j x| ≤ τ/4 ∧ |T' n o j x - T o j x| ≤ τ/4) : + ∀ᶠ n in atTop, (Fintype.card O : ℝ≥0)⁻¹ / 2 < + ρ n (⋃ o, Success τ (A' n o) (T' n o)) := by + have hq : 0 < (Fintype.card O : ℝ≥0) := by exact_mod_cast Fintype.card_pos + have hhalf : (Fintype.card O : ℝ≥0)⁻¹ / 2 < (Fintype.card O : ℝ≥0)⁻¹ := + half_lt_self (inv_pos.mpr hq) + have hm := finite_closed_mass μ ν (fun o => ClosedGood τ (A o) (T o)) + (fun o => isClosed_closedGood τ _ _ (hA o) (hT o)) hν hcover + rw [← ENNReal.coe_inv (ne_of_gt hq)] at hm + have hev := eventually_success_mass μ ρ hρ hτ A T A' T' hA hT he + (ENNReal.coe_lt_coe.mpr hhalf) hm + apply hev.mono + intro n hn + rw [← ProbabilityMeasure.ennreal_coeFn_eq_coeFn_toMeasure] at hn + exact ENNReal.coe_lt_coe.mp hn + + + +theorem conditional_mass_mixture {B J : Type*} [MeasurableSpace B] [Finite J] + (η : ProbabilityMeasure B) (μb : B → ProbabilityMeasure X) + (μ : ProbabilityMeasure X) (ν : B → O → ℕ → ProbabilityMeasure X) + (ρ : ℕ → ProbabilityMeasure X) (hρ : Tendsto ρ atTop (𝓝 μ)) + {τ : ℝ} (hτ : 0 < τ) + (A T : O → J → X → ℝ) (A' T' : ℕ → O → J → X → ℝ) + (hA : ∀ o j, Continuous (A o j)) (hT : ∀ o j, Continuous (T o j)) + (hν : ∀ᵐ b ∂(η : Measure B), ∀ o, Tendsto (ν b o) atTop (𝓝 (μb b))) + (hcover : ∀ᵐ b ∂(η : Measure B), ∀ n, + 1 ≤ ∑ o, ν b o n (ClosedGood τ (A o) (T o))) + (hmix : (μ : Measure X) (⋃ o, ClosedGood τ (A o) (T o)) = + ∫⁻ b, (μb b : Measure X) (⋃ o, ClosedGood τ (A o) (T o)) ∂(η : Measure B)) + (he : ∀ᶠ n in atTop, ∀ o j x, + |A' n o j x - A o j x| ≤ τ/4 ∧ |T' n o j x - T o j x| ≤ τ/4) : + ∀ᶠ n in atTop, (Fintype.card O : ℝ≥0)⁻¹ / 2 < + ρ n (⋃ o, Success τ (A' n o) (T' n o)) := by + have hq : 0 < (Fintype.card O : ℝ≥0) := by exact_mod_cast Fintype.card_pos + have hhalf : (Fintype.card O : ℝ≥0)⁻¹ / 2 < (Fintype.card O : ℝ≥0)⁻¹ := + half_lt_self (inv_pos.mpr hq) + have hb : ∀ᵐ b ∂(η : Measure B), + ((Fintype.card O : ℝ≥0)⁻¹ : ℝ≥0∞) ≤ + (μb b : Measure X) (⋃ o, ClosedGood τ (A o) (T o)) := by + filter_upwards [hν,hcover] with b hn hc + exact finite_closed_mass (μb b) (ν b) _ + (fun o => isClosed_closedGood τ _ _ (hA o) (hT o)) hn hc + have hm := mixture_lower η μb μ _ _ hmix hb + rw [← ENNReal.coe_inv (ne_of_gt hq)] at hm + have hev := eventually_success_mass μ ρ hρ hτ A T A' T' hA hT he + (ENNReal.coe_lt_coe.mpr hhalf) hm + apply hev.mono + intro n hn + rw [← ProbabilityMeasure.ennreal_coeFn_eq_coeFn_toMeasure] at hn + exact ENNReal.coe_lt_coe.mp hn + +end +end AlignmentMass + + +end +end + +end OAI diff --git a/lean/OAI/Combinatorics/SumProduct/Alignment/AllLevel01.lean b/lean/OAI/Combinatorics/SumProduct/Alignment/AllLevel01.lean new file mode 100644 index 0000000000000000000000000000000000000000..486a18385975fc87e38883225bc8160c39b753a2 --- /dev/null +++ b/lean/OAI/Combinatorics/SumProduct/Alignment/AllLevel01.lean @@ -0,0 +1,560 @@ +import Mathlib +import OAI.Combinatorics.SumProduct.Alignment.RationalLattice10 +import OAI.Combinatorics.SumProduct.Alignment.TailCharacter01 +import OAI.Geometry.NilpotentCharts.Main + +namespace OAI + +section +section +section +noncomputable section +open scoped BigOperators +namespace IntegerHyperplane +variable {n : ℕ} +lemma split_prefix_zero_iff (k : Fin (n+1) → ℤ) (p : Fin (n+1)) + (hp : k p≠0) (hlast : ∀ j : Fin (n+1),p ?_) j <;> intro hj + · change form k x/(k p:ℝ)=0 + have hf : form k x=0 := by + change (∑ a,(k a:ℝ)*x a)=0 + apply Finset.sum_eq_zero + intro a _ + by_cases hat : a.val c.coord g (embed r j)) (s-r) hpt + have ht (a : Fin (n+1)) : chartHomeomorph c k p hp g (embed r a)= + splitCoordinates k p (fun j => c.coord g (embed r j)) a := blockMap_embed _ _ _ + constructor + · intro hx i hi + by_cases hir : i.val by + rw [← chart_prefix c k p hp g i hi] + exact hx i (by omega)) + refine ⟨⟨g,hg⟩,?_,rfl⟩ + change χ ⟨g,hg⟩=1 + apply Multiplicative.toAdd.injective + have hh:=hx (embed r 0) (by change r+0 mul_comm _ _) + have ha0 : a≠0 := by + intro he + apply hne + ext x + apply Multiplicative.toAdd.injective + change (χ x).toAdd=0 + rw [ha',he] + simp [form] + obtain ⟨q,hq,hlast⟩:=exists_last_nonzero a ha0 + let d:=tailCharacterCoordinates c a q hq hlast hsk H hH χ hconj hχconj ha' + have hpoly : ∀ i,RationalPolynomialMap.IsPolynomial + (fun x : Fin (r+(n+1)) → ℝ => c.coord (d.coord.symm x) i) := + inverse_polynomial c a q hq + obtain ⟨Λ,e,hΛ,hle,hidx,hzero,hrat⟩:=exists_integer_sublattice_rational c d (MonoidHom.id G) + hpoly Γ hΓ continuous_id Function.injective_id + have hd (K : Subgroup G) (s : ℕ) + (hK : ∀ g : G,g∈K ↔ ∀ i : Fin (r+(n+1)),i.val imp_congr_right (fun _ => (hzero g i).symm)) + refine ⟨Λ,secondCoordinates e,secondCoordinates_secondKind e, + expCoordinates_lattice e Λ hΛ,hle,hidx,?_,?_,?_,?_⟩ + · intro g hg + apply rationalHom_rational c d (MonoidHom.id G) hpoly + exact (hrat g).mp ((secondCoordinates_rational e g).mp hg) + · exact hd _ (r+1) (chart_kernel c a q hq H hH χ ha') + · intro K s hs hK + apply hd K s + intro g + exact (hK g).trans (chart_early_zero_iff c a q hq g s hs).symm + · intro K s hK hkill + have hqs:=pivot_lt_of_kills c a q hq H hH χ ha' K s hK hkill + refine ⟨by omega,?_⟩ + apply hd K s + intro g + exact (hK g).trans (chart_late_zero_iff c a q hq hlast g s hqs).symm + +end TailCharacterRechart + +end + +end + +section + + + + +noncomputable section +open scoped commutatorElement +namespace AllLevelFactorization +open CubeFaces CubePolynomials NilpotentTaylor +variable {G : Type*} [Group G] + +section Shrink +variable (H : Filtration G) (h01 : H.level 0=H.level 1) +variable (j : ℕ) (hj : 0 first | rfl | exact h01 + +lemma shrink_at : (shrink H h01 j hj K hK hnext hbr).level j=K := by + simp [shrink,shrinkLevel,Nat.max_eq_right hj] + +lemma shrink_other {k : ℕ} (hk : 0 omega + | succ d ih => + by_cases hn : n=d + · subst n; rfl + · rw [word] + simp only [Pi.mul_apply,Ring.choose_natCast,Nat.choose_eq_zero_of_lt (by omega : n + have hn' : n ih i hi (by omega)) + have he := h n hn + rw [word_node_cutoff a hn',word_node_cutoff b hn',word_node,word_node,hp] at he + exact mul_left_cancel he + + + +theorem corrected_taylor_coefficients {a b : ℕ → G} {d j : ℕ} (hj : j exact K.one_mem + | succ d ih => + exact K.mul_mem (ih (fun i hi => ha i (by omega))) (K.zpow_mem (ha d (by omega)) _) + +end TaylorComparison + +section CharacterCorrection +variable (H : Filtration G) (j : ℕ) (χ : H.level j →* Multiplicative ℝ) +variable (hnext : ∀ x : H.level j, x.val∈H.level (j+1) → χ x=1) + +lemma commutator_next {p x : G} (hp : p∈H.level 1) (hx : x∈H.level j) : + ⁅p,x⁆∈H.level (j+1) := by + simpa only [Nat.add_comm] using H.commutator_le 1 j (Subgroup.commutator_mem_commutator hp hx) + +lemma conjugate_mem {p : G} (hp : p∈H.level 1) (x : H.level j) : + p⁻¹*x.val*p∈H.level j := by + have hc := commutator_next H j ((H.level 1).inv_mem hp) x.property + have he : p⁻¹*x.val*p=⁅p⁻¹,x.val⁆*x.val := by simp [commutatorElement_def,mul_assoc] + rw [he] + exact (H.level j).mul_mem (H.antitone (by omega) hc) x.property + +include hnext in +lemma character_conjugate {p : G} (hp : p∈H.level 1) (x : H.level j) : + χ ⟨p⁻¹*x.val*p,conjugate_mem H j hp x⟩=χ x := by + let z : H.level j := ⟨⁅p⁻¹,x.val⁆, + H.antitone (by omega : j≤j+1) (commutator_next H j ((H.level 1).inv_mem hp) x.property)⟩ + have hz : χ z=1 := hnext z (commutator_next H j ((H.level 1).inv_mem hp) x.property) + have he : (⟨p⁻¹*x.val*p,conjugate_mem H j hp x⟩ : H.level j)=z*x := by + apply Subtype.ext + simp [z,commutatorElement_def,mul_assoc] + rw [he,map_mul,hz,one_mul] + +include hnext in +lemma character_correction {p : G} (hp : p∈H.level 1) (u v a : H.level j) + (hχ : (χ u).toAdd+(χ v).toAdd=(χ a).toAdd) : + (p⁻¹*u.val⁻¹*p*a.val*v.val⁻¹)∈levelKernel H j χ := by + let b : H.level j := ⟨p⁻¹*u.val⁻¹*p,conjugate_mem H j hp (u⁻¹)⟩*a*v⁻¹ + have hb : χ b=1 := by + dsimp only [b] + rw [map_mul,map_mul] + have hc : χ ⟨p⁻¹*u.val⁻¹*p,conjugate_mem H j hp (u⁻¹)⟩=χ (u⁻¹) := + character_conjugate H j χ hnext hp (u⁻¹) + rw [hc,map_inv,map_inv] + change -(χ u).toAdd+(χ a).toAdd+ -(χ v).toAdd=0 + linarith + exact (mem_levelKernel H j χ b).mpr hb + +end CharacterCorrection + +section OneStep +variable (H : Filtration G) (h01 : H.level 0=H.level 1) +variable (j : ℕ) (hj : 0 (u.val^Ring.choose z j)⁻¹*word a d z*(v.val^Ring.choose z j)⁻¹ + have hu : (fun z : ℤ => u.val^Ring.choose z j)∈polynomials H 0 := + binomial_mem j 0 u.val (by simp) + have hv : (fun z : ℤ => v.val^Ring.choose z j)∈polynomials H 0 := + binomial_mem j 0 v.val (by simp) + have hf : f∈polynomials H 0 := + (polynomials H 0).mul_mem + ((polynomials H 0).mul_mem ((polynomials H 0).inv_mem hu) + (word_mem a d (by simpa using ha))) ((polynomials H 0).inv_mem hv) + obtain ⟨b,hb,he⟩ := exists_taylor (H:=H) (k:=0) (d:=d) (by simpa using hd) hf + have he' : ∀ z : ℤ, word b d z=(u.val^Ring.choose z j)⁻¹*word a d z*(v.val^Ring.choose z j)⁻¹ := + fun z => (congrFun he z).symm + obtain ⟨hlow,hjcoef⟩ := corrected_taylor_coefficients hjd u.val v.val he' + have hp : word a j (j:ℤ)∈H.level 1 := by + apply word_mem_subgroup + intro i hi + by_cases hi0 : i=0 + · subst i; rw [ha0]; exact (H.level 1).one_mem + · exact H.antitone (by omega : 1 ≤ i) (ha i (by omega)) + have hkernel : b j∈levelKernel H j χ := by + rw [hjcoef] + exact character_correction H j χ hnext hp u v ⟨a j,ha j hjd⟩ hχ + refine ⟨b,?_,hlow,fun z => congrFun he z⟩ + intro i hi + change b i∈shrinkLevel H j (levelKernel H j χ) i + unfold shrinkLevel + split_ifs with hij + · by_cases hi0 : i=0 + · subst i + rw [hlow 0 hj,ha0] + exact (levelKernel H j χ).one_mem + · have : i=j := by omega + simpa only [this] using hkernel + · simpa using hb i hi + +include h01 hj hnext hbr in + +theorem corrected_polynomial (d : ℕ) (hd : H.level d=⊥) (hjd : j (u.val^Ring.choose z j)⁻¹*word a d z*(v.val^Ring.choose z j)⁻¹)∈ + polynomials (kernelFiltration H h01 j hj χ hnext hbr) 0 := by + obtain ⟨b,hb,_,he⟩ := one_level_descent H h01 j hj χ hnext hbr d hd hjd a ha ha0 u v hχ + rw [show (fun z : ℤ => (u.val^Ring.choose z j)⁻¹*word a d z*(v.val^Ring.choose z j)⁻¹)=word b d from funext he] + exact word_mem b d (by simpa using hb) + +end OneStep + +end AllLevelFactorization + +end +end +end +end + +end OAI diff --git a/lean/OAI/Combinatorics/SumProduct/Alignment/AllLevel02.lean b/lean/OAI/Combinatorics/SumProduct/Alignment/AllLevel02.lean new file mode 100644 index 0000000000000000000000000000000000000000..a4122c6b28a859684cd62a6b3e49a92bd5f3b6b2 --- /dev/null +++ b/lean/OAI/Combinatorics/SumProduct/Alignment/AllLevel02.lean @@ -0,0 +1,337 @@ +import Mathlib +import OAI.Combinatorics.SumProduct.Alignment.AllLevel01 +import OAI.Geometry.NilpotentCharts.Main + +namespace OAI + +section +section +section +noncomputable section +open scoped commutatorElement +end + +end + +section + + + + +noncomputable section +open scoped BigOperators commutatorElement +namespace AllLevelGeometry +open RationalLattice MalcevCharacters RationalTailCoordinates CubeFaces AllLevelFactorization +variable {G : Type*} [Group G] [TopologicalSpace G] [IsTopologicalGroup G] +variable {n : ℕ} (c : RealCoordinates G n) + +omit [IsTopologicalGroup G] in +lemma cutoff_le_of_subgroup_le [IsTopologicalGroup G] (A B : Subgroup G) (r s : ℕ) (hr : r≤n) + (hA : ∀ g : G,g∈A ↔ ∀ i : Fin n,i.val (hH 0 g).mp (h0 ▸ Subgroup.mem_top g)) + +include h1 hr hH in +lemma cutoff_one : r 1=0 := + top_cutoff_zero c (r 1) (hr 1) (fun g=> (hH 1 g).mp (h1 ▸ Subgroup.mem_top g)) + +variable (j : ℕ) (hj : 0 first | omega | exact hr k + +include h0 h1 hr hH hj hnext hbr in + + +theorem refined_chart (hsk : SecondKind c) (Γ : Subgroup G) + (hΓ : ∀ g : G,g∈Γ ↔ ∀ i,∃ z : ℤ,c.coord g i=z) + (hcont : Continuous χ) (hz : ∀ x : H.level j,x.val∈Γ → ∃ z : ℤ,(χ x).toAdd=z) + (hne : χ≠1) : + ∃ Λ : Subgroup G,∃ e : RealCoordinates G n,SecondKind e ∧ + (∀ g : G,g∈Λ ↔ ∀ i,∃ z : ℤ,e.coord g i=z) ∧ + Λ≤Γ ∧ (Λ.subgroupOf Γ).FiniteIndex ∧ + (∀ g : G,IsRational e g → IsRational c g) ∧ + (∀ k,newCutoff r j k≤n) ∧ + (∀ k (g : G),g∈(kernelFiltration H (h0.trans h1.symm) j hj χ hnext hbr).level k ↔ + ∀ i : Fin n,i.valconjugate_mem H j (h1 ▸ Subgroup.mem_top g)) + (fun g x=>character_conjugate H j χ hnext (h1 ▸ Subgroup.mem_top g) x) + refine ⟨Λ,e,hsk',hΛ,hle,hidx,hrat,newCutoff_le r hr j hjr,?_⟩ + intro k g + change g∈shrinkLevel H j (levelKernel H j χ) k ↔ _ + unfold shrinkLevel newCutoff + split_ifs with hk + · exact hker g + · by_cases hkj : khnext x (H.antitone (by omega) hx))).2 g + + +def rank (n s : ℕ) (r : ℕ → ℕ) : ℕ := Finset.univ.sum (fun i : Fin s => n - r (i.val + 1)) + +lemma rank_strict_drop (n s : ℕ) (r : ℕ → ℕ) (j : ℕ) + (hj : 0r k-1)=rank (1+n) s r := by + unfold rank + apply Finset.sum_congr rfl + intro i _ + change n - (r (i.val + 1) - 1) = (1 + n) - r (i.val + 1) + have := hr (i.val + 1) + omega + + + +def comapFiltration {K : Type*} [Group K] (F : K →* G) (H : Filtration G) : Filtration K where + level k:=(H.level k).comap F + antitone:=fun _ _ hab=>Subgroup.comap_mono (H.antitone hab) + commutator_le a b:=by + apply Subgroup.commutator_le.mpr + intro x hx y hy + change F ⁅x,y⁆∈H.level (a+b) + rw [map_commutatorElement] + exact H.commutator_le a b (Subgroup.commutator_mem_commutator hx hy) + +section Restrict +variable {q : ℕ} (d : RealCoordinates G (1+q)) (K : Subgroup G) +variable (hK : ∀ g : G,g∈K ↔ ∀ i : Fin (1+q),i.val<1 → d.coord g i=0) +variable (F : Filtration G) (t : ℕ → ℕ) (ht : ∀ k,1≤t k) +variable (hF : ∀ k (g : G),g∈F.level k ↔ + ∀ i : Fin (1+q),i.valr k-a)=rank (a+n) s r := by + unfold rank + apply Finset.sum_congr rfl + intro i _ + change n - (r (i.val + 1) - a) = (a + n) - r (i.val + 1) + have := hr (i.val + 1) + omega + +include h0 h1 hr hH hj hnext hbr in + + +theorem restricted_refinement (hsk : SecondKind c) (Γ : Subgroup G) + (hΓ : ∀ g : G,g∈Γ ↔ ∀ i,∃ z : ℤ,c.coord g i=z) + (hcont : Continuous χ) (hz : ∀ x : H.level j,x.val∈Γ → ∃ z : ℤ,(χ x).toAdd=z) + (hne : χ≠1) (s : ℕ) (hjs : j ≤ s) : + let F:=kernelFiltration H (h0.trans h1.symm) j hj χ hnext hbr + let K:=F.level 1 + ∃ q : ℕ,∃ d : RealCoordinates K q,∃ Δ : Subgroup K,∃ t : ℕ → ℕ, + SecondKind d ∧ + (∀ x : K,x∈Δ ↔ ∀ i,∃ z : ℤ,d.coord x i=z) ∧ + (∀ x : K,x∈Δ → x.val∈Γ) ∧ + (∀ x : K,IsRational d x → IsRational c x.val) ∧ + (∀ k,t k≤q) ∧ + (∀ k (x : K),x∈(comapFiltration K.subtype F).level k ↔ + ∀ i : Fin q,i.valt k-t 1,tail_secondKind e K hK hsk', + tailCoordinates_lattice e K hK Λ hΛ,?_,?_,?_,?_,?_⟩ + · intro x hx; exact hle hx + · intro x hx + exact hrat x.val (restricted_rational_general e K hK x hx) + · intro k + change t k - t 1 ≤ q + have hb : t k ≤ t 1 + q := ht k + omega + · exact restricted_chart_general e K hK F t he + · rw [rank_restrict_general (t 1) q s t htlo] + exact hrank + +end AllLevelGeometry + +end +end +end +end + +end OAI diff --git a/lean/OAI/Combinatorics/SumProduct/Alignment/AllLevel03.lean b/lean/OAI/Combinatorics/SumProduct/Alignment/AllLevel03.lean new file mode 100644 index 0000000000000000000000000000000000000000..4eee0446ed40476fc624b5fa44ca0cecb2d55862 --- /dev/null +++ b/lean/OAI/Combinatorics/SumProduct/Alignment/AllLevel03.lean @@ -0,0 +1,352 @@ +import Mathlib +import OAI.Combinatorics.SumProduct.Alignment.AllLevel02 +import OAI.Geometry.NilpotentCharts.Main + +namespace OAI + +section +section +section +noncomputable section +open scoped BigOperators commutatorElement +end + +end + +section + + + + +noncomputable section +open Topology +open scoped BigOperators commutatorElement +universe u +namespace AllLevelDomains +open RationalLattice MalcevCharacters CubeFaces AllLevelFactorization AllLevelGeometry +variable {G : Type u} [Group G] [TopologicalSpace G] [IsTopologicalGroup G] +variable {n : ℕ} (c : RealCoordinates G n) (Γ : Subgroup G) (s : ℕ) + +structure Domain where + Carrier : Type u + [group : Group Carrier] + [topology : TopologicalSpace Carrier] + [topGroup : IsTopologicalGroup Carrier] + embed : Carrier →* G + injective : Function.Injective embed + continuous : Continuous embed + closedEmbedding : IsClosedEmbedding embed + dim : ℕ + chart : RealCoordinates Carrier dim + secondKind : SecondKind chart + lattice : Subgroup Carrier + integer_lattice : ∀ x : Carrier,x∈lattice ↔ ∀ i,∃ z : ℤ,chart.coord x i=z + lattice_image : ∀ x : Carrier,x∈lattice → embed x∈Γ + rational_image : ∀ x : Carrier,IsRational chart x → IsRational c (embed x) + filtration : Filtration Carrier + zero_top : filtration.level 0=⊤ + one_top : filtration.level 1=⊤ + terminal : filtration.level (s+1)=⊥ + cutoff : ℕ → ℕ + cutoff_le : ∀ k,cutoff k≤dim + adapted : ∀ k (x : Carrier),x∈filtration.level k ↔ + ∀ i : Fin dim,i.valisClosed_iInter fun _=>isClosed_eq + ((continuous_apply i).comp D.chart.coord.continuous) continuous_const + convert hc using 1 + ext x + exact D.adapted k x + +variable (D : Domain c Γ s) (j : ℕ) (hj : 0D.lattice_image x.val (hle x hx) + rational_image := fun x hx=>D.rational_image x.val (hrat x hx) + filtration := comapFiltration K.subtype F + zero_top := by + change (F.level 0).comap K.subtype=⊤ + rw [h01] + ext x; simp [K] + one_top := by + change (F.level 1).comap K.subtype=⊤ + ext x; simp [K] + terminal := by + change (F.level (s+1)).comap K.subtype=⊥ + rw [hbottom] + ext x + change x.val=1 ↔ x=1 + constructor + · exact fun h=>Subtype.ext h + · exact fun h=>congrArg Subtype.val h + cutoff := t + cutoff_le := ht + adapted := hadapt } + refine ⟨E,K.subtype,continuous_subtype_val,Subtype.val_injective,fun _=>rfl,?_,?_,hrank⟩ + · exact Subgroup.range_subtype K + · intro k x; rfl + +end Domain +end AllLevelDomains +end + +end + +section + + + + +noncomputable section +open scoped Topology +open Filter +namespace LevelCharacterSubsequence +open TriangularLatticeRecovery + +lemma bounded_subsequence_of_not_tendsto {f : ℕ → ℝ} + (h : ¬ Tendsto f atTop atTop) : + ∃ C : ℝ, ∃ φ : ℕ → ℕ, StrictMono φ ∧ ∀ n, f (φ n) ≤ C := by + rw [tendsto_atTop] at h + push Not at h + obtain ⟨C,hC⟩ := h + have hf : ∃ᶠ n in atTop, f n < C := by + simpa only [Filter.Frequently,not_le] using hC + obtain ⟨φ,hφ,hfφ⟩:=extraction_of_frequently_atTop hf + exact ⟨C,φ,hφ,fun n => (hfφ n).le⟩ + + + +theorem small_remainder_subsequence (L x : ℕ → ℝ) (j : ℕ) + (hL : ∀ n,0 |L n|^j*circleNorm (x n)) atTop atTop) : + ∃ φ : ℕ → ℕ, StrictMono φ ∧ ∃ m : ℕ → ℤ, ∃ δ : ℕ → ℝ, + ∃ C : ℝ, 0≤C ∧ ∃ a : ℝ, + (∀ n,x (φ n)=(m n:ℝ)+δ n) ∧ + (∀ n,|δ n| ≤ C/(L (φ n))^j) ∧ + Tendsto (fun n => (L (φ n))^j*δ n) atTop (𝓝 a) := by + obtain ⟨C,φ,hφ,hC⟩:=bounded_subsequence_of_not_tendsto hbad + let δ : ℕ → ℝ:=fun n=>x (φ n)-(round (x (φ n)):ℝ) + have hnorm (n : ℕ) : |δ n|=circleNorm (x (φ n)) := UnitAddCircle.norm_eq.symm + have hbd (n : ℕ) : |(L (φ n))^j*δ n| ≤ max C 0 := by + rw [abs_mul,abs_of_nonneg (pow_nonneg (hL _).le _),hnorm] + have hh:=hC n + rw [abs_of_pos (hL _)] at hh + exact hh.trans (le_max_left _ _) + have hmem (n : ℕ) : (L (φ n))^j*δ n∈Set.Icc (-max C 0) (max C 0) := + abs_le.mp (hbd n) + obtain ⟨a,_,ψ,hψ,ha⟩:=(isCompact_Icc : IsCompact (Set.Icc (-max C 0) (max C 0))).isSeqCompact hmem + refine ⟨φ∘ψ,hφ.comp hψ,fun n=>round (x (φ (ψ n))),δ∘ψ,max C 0, + le_max_right _ _,a,?_,?_,?_⟩ + · intro n; dsimp [δ]; ring + · intro n + apply (le_div_iff₀ (pow_pos (hL _) _)).mpr + simpa only [Function.comp_apply,abs_mul,abs_of_nonneg (pow_nonneg (hL _).le _),mul_comm] + using hbd (ψ n) + · exact ha + +lemma nondivergence_integer_mul (L x : ℕ → ℝ) (j d : ℕ) (hd : 0 |L n|^j*circleNorm (x n)) atTop atTop) : + ¬ Tendsto (fun n => |L n|^j*circleNorm ((d:ℝ)*x n)) atTop atTop := by + intro h + have hdR : (0:ℝ) F (Multiplicative.ofAdd t) + let g : ℝ → G := realPower c (f 1) + have hf : Continuous f := hF.comp continuous_ofAdd + have hg : Continuous g := realPower_continuous c _ + have hfa (s t : ℝ) : f (s+t)=f s*f t := F.map_mul _ _ + have hga (s t : ℝ) : g (s+t)=g s*g t := realPower_add c _ _ _ + have hfg1 : f 1=g 1 := by simp only [g,realPower_one] + have hcoord : ∀ k : ℕ,∀ i : Fin n,i.val=k→∀ t : ℝ, + c.coord (f t) i=c.coord (g t) i := by + intro k + induction k using Nat.strong_induction_on with + | h k ih => + intro i hi + have hl (a : Fin i.val) (s : ℝ) : + c.coord (f s) ⟨a.val,lt_trans a.isLt i.isLt⟩= + c.coord (g s) ⟨a.val,lt_trans a.isLt i.isLt⟩ := + ih a.val (by omega) _ rfl s + let d : ℝ →+ ℝ := + { toFun := fun t => c.coord (f t) i-c.coord (g t) i + map_zero' := by simp [f,g,c.one_coord] + map_add' := by + intro s t + rw [hfa,hga,c.mul_coord,c.mul_coord] + simp_rw [hl] + ring } + have hd : Continuous d := ((continuous_apply i).comp (c.coord.continuous.comp hf)).sub + ((continuous_apply i).comp (c.coord.continuous.comp hg)) + intro t + have he:=map_real_smul d hd t 1 + have h1 : d 1=0 := by change c.coord (f 1) i-c.coord (g 1) i=0; rw [hfg1,sub_self] + simp only [smul_eq_mul,mul_one,h1,mul_zero] at he + exact sub_eq_zero.mp he + exact c.coord.injective (funext (fun i=>hcoord i.val i rfl t)) + +section Tail +variable (hsk : SecondKind c) (Γ H : Subgroup G) +variable (hΓ : ∀ g : G,g∈Γ ↔ ∀ i,∃ z : ℤ,c.coord g i=z) +variable (r : ℕ) (hr : r≤n) +variable (hH : ∀ g : G,g∈H ↔ ∀ i : Fin n,i.valmul_comm _ _) + have hp : HasPivot k 0 := by + by_contra hp + apply hne + ext x + apply Multiplicative.toAdd.injective + change (χ x).toAdd=0 + rw [hk'] + exact form_zero_of_no_pivot k 0 hp _ (by intro i hi; omega) + let v:=tailSection d k 0 1 + have hrat : IsRational d v := by simpa only [Rat.cast_one] using section_rational d k 0 1 + refine ⟨v,?_,?_⟩ + · intro i + by_cases hi : i.valFalse.elim (hn hp)) + +include hsk hΓ hr hH hcont hz hne in + + +theorem exists_unit_flow : ∃ F : Multiplicative ℝ →* H,Continuous F ∧ + (∀ t : ℝ,(χ (F (Multiplicative.ofAdd t))).toAdd=t) ∧ + IsRational c ((F (Multiplicative.ofAdd 1)).val) := by + obtain ⟨v,hv,hχv⟩:=exists_rational_unit c hsk Γ H hΓ r hr hH χ hcont hz hne + let I : Set (Fin n):={i|i.valsubgroupRealPower c H I hHI v t.toAdd + map_one' := subgroupRealPower_zero c H I hHI v + map_mul' := fun s t=>subgroupRealPower_add c H I hHI v s.toAdd t.toAdd } + refine ⟨F,(subgroupRealPower_continuous c H I hHI v).comp continuous_toAdd,?_,?_⟩ + · intro t + change (χ (subgroupRealPower c H I hHI v t)).toAdd=t + rw [character_subgroupRealPower c H I hHI χ hcont,hχv,mul_one] + · change IsRational c ((subgroupRealPower c H I hHI v 1).val) + rw [subgroupRealPower_one] + exact hv + +end Tail + +end RationalLevelFlow + +end +end +end +end + +end OAI diff --git a/lean/OAI/Combinatorics/SumProduct/Alignment/AllLevel04.lean b/lean/OAI/Combinatorics/SumProduct/Alignment/AllLevel04.lean new file mode 100644 index 0000000000000000000000000000000000000000..e0fe3398fe1a6078480bf7e2698951d2ad973e85 --- /dev/null +++ b/lean/OAI/Combinatorics/SumProduct/Alignment/AllLevel04.lean @@ -0,0 +1,356 @@ +import Mathlib +import OAI.Combinatorics.SumProduct.Alignment.AllLevel03 +import OAI.Geometry.NilpotentCharts.Main + +namespace OAI + +section +section +section +noncomputable section +open scoped BigOperators Topology +end + +end + +section + + + + +noncomputable section +open scoped Topology +open Filter +universe u +namespace AllLevelRemovals +open RationalLattice +variable {G : Type u} [Group G] [TopologicalSpace G] [IsTopologicalGroup G] +variable {n : ℕ} (c : RealCoordinates G n) (L : ℕ → ℝ) (s : ℕ) + +structure Removal where + flow : Multiplicative ℝ →* G + continuous : Continuous flow + rational_unit : IsRational c (flow (Multiplicative.ofAdd 1)) + degree : ℕ + degree_pos : 0(L N)^degree*small N) atTop (𝓝 limit) + +namespace Removal +variable {c L s} +def left (W : Removal c L s) (N : ℕ) (z : ℤ) : G := + W.flow (Multiplicative.ofAdd (W.small N)) ^ Ring.choose z W.degree + +def right (W : Removal c L s) (N : ℕ) (z : ℤ) : G := + W.flow (Multiplicative.ofAdd 1) ^ (W.integer N * Ring.choose z W.degree) + +omit [IsTopologicalGroup G] in +lemma flow_int [IsTopologicalGroup G] (W : Removal c L s) (z : ℤ) : + W.flow (Multiplicative.ofAdd (z:ℝ))=W.flow (Multiplicative.ofAdd 1)^z := by + have h:=W.flow.map_zpow (Multiplicative.ofAdd 1) z + change W.flow (Multiplicative.ofAdd (z • (1:ℝ)))=_ at h + simpa only [zsmul_eq_mul,mul_one] using h + +lemma right_eq (W : Removal c L s) (N : ℕ) (z : ℤ) : + W.right N z=W.flow (Multiplicative.ofAdd (W.integer N:ℝ))^Ring.choose z W.degree := by + rw [flow_int,← zpow_mul] + rfl + +def reindex (W : Removal c L s) (φ : ℕ → ℕ) (hφ : StrictMono φ) : + Removal c (L∘φ) s where + flow := W.flow + continuous := W.continuous + rational_unit := W.rational_unit + degree := W.degree + degree_pos := W.degree_pos + degree_le := W.degree_le + integer := W.integer∘φ + small := W.small∘φ + bound := W.bound + bound_nonneg := W.bound_nonneg + small_bound := fun N=>W.small_bound (φ N) + limit := W.limit + scaled_tendsto := W.scaled_tendsto.comp hφ.tendsto_atTop + +omit [IsTopologicalGroup G] in +@[simp] lemma reindex_left [IsTopologicalGroup G] (W : Removal c L s) (φ : ℕ → ℕ) (hφ : StrictMono φ) + (N : ℕ) (z : ℤ) : (W.reindex φ hφ).left N z=W.left (φ N) z := rfl +omit [IsTopologicalGroup G] in +@[simp] lemma reindex_right [IsTopologicalGroup G] (W : Removal c L s) (φ : ℕ → ℕ) (hφ : StrictMono φ) + (N : ℕ) (z : ℤ) : (W.reindex φ hφ).right N z=W.right (φ N) z := rfl +end Removal + +variable {c L s} +def leftWord (W : List (Removal c L s)) (N : ℕ) (z : ℤ) : G := + (W.map (fun w=>w.left N z)).prod + +def rightWord (W : List (Removal c L s)) (N : ℕ) (z : ℤ) : G := + (W.reverse.map (fun w=>w.right N z)).prod + +omit [IsTopologicalGroup G] in +@[simp] lemma leftWord_nil [IsTopologicalGroup G] (N : ℕ) (z : ℤ) : leftWord ([]:List (Removal c L s)) N z=1 := rfl +omit [IsTopologicalGroup G] in +@[simp] lemma rightWord_nil [IsTopologicalGroup G] (N : ℕ) (z : ℤ) : rightWord ([]:List (Removal c L s)) N z=1 := rfl + +omit [IsTopologicalGroup G] in +lemma leftWord_append [IsTopologicalGroup G] (W : List (Removal c L s)) (w : Removal c L s) (N : ℕ) (z : ℤ) : + leftWord (W++[w]) N z=leftWord W N z*w.left N z := by + simp [leftWord] +omit [IsTopologicalGroup G] in +lemma rightWord_append [IsTopologicalGroup G] (W : List (Removal c L s)) (w : Removal c L s) (N : ℕ) (z : ℤ) : + rightWord (W++[w]) N z=w.right N z*rightWord W N z := by + simp [rightWord] + +omit [IsTopologicalGroup G] in +lemma leftWord_reindex [IsTopologicalGroup G] (W : List (Removal c L s)) (φ : ℕ → ℕ) (hφ : StrictMono φ) + (N : ℕ) (z : ℤ) : + leftWord (W.map (fun w=>w.reindex φ hφ)) N z=leftWord W (φ N) z := by + simp only [leftWord,List.map_map] + rfl +omit [IsTopologicalGroup G] in +lemma rightWord_reindex [IsTopologicalGroup G] (W : List (Removal c L s)) (φ : ℕ → ℕ) (hφ : StrictMono φ) + (N : ℕ) (z : ℤ) : + rightWord (W.map (fun w=>w.reindex φ hφ)) N z=rightWord W (φ N) z := by + simp only [rightWord,← List.map_reverse,List.map_map] + rfl + +end AllLevelRemovals +end + +end + +section + + + + +noncomputable section +open scoped BigOperators Topology commutatorElement +open Filter +universe u +namespace AllLevelStates +open RationalLattice CubeFaces NilpotentTaylor AllLevelFactorization +open AllLevelDomains AllLevelRemovals CubeHorizontalIrrationality +variable {G : Type u} [Group G] [TopologicalSpace G] [IsTopologicalGroup G] +variable {n : ℕ} (c : RealCoordinates G n) (Γ : Subgroup G) (s : ℕ) +variable (K : Filtration G) (P : ℕ → ℤ → G) (L : ℕ → ℝ) + +structure State where + domain : Domain c Γ s + subseq : ℕ → ℕ + strictmono : StrictMono subseq + coeff : ℕ → ∀ k : ℕ,domain.filtration.level k + zero : ∀ N,(coeff N 0).val=1 + level_image : ∀ k (x : domain.Carrier),x∈domain.filtration.level k → + domain.embed x∈K.level k + removals : List (Removal c (L∘subseq) s) + realization : ∀ N z,P (subseq N) z=leftWord removals N z * + domain.embed (word (fun k=>(coeff N k).val) (s+1) z)*rightWord removals N z + +namespace State +variable {c Γ s K P L} +variable (S : State c Γ s K P L) + +def Irrational : Prop := ∀ j : ℕ, 0 < j → j ≤ s → + ∀ χ : S.domain.filtration.level j →* Multiplicative ℝ, + χ≠1 → Continuous χ → RationalCharacter S.domain.lattice χ → + (∀ x : S.domain.filtration.level j,x.val∈S.domain.filtration.level (j+1) → χ x=1) → + (∀ a b : ℕ,0|L (S.subseq N)|^j* + TriangularLatticeRecovery.circleNorm ((χ (S.coeff N j)).toAdd)) atTop atTop + +lemma monoidHom_word {A B : Type*} [Group A] [Group B] (f : A →* B) + (a : ℕ → A) (d : ℕ) (z : ℤ) : f (word a d z)=word (fun k=>f (a k)) d z := by + induction d with + | zero => simp [word] + | succ d ih => simp only [word,Pi.mul_apply,map_mul,map_zpow,ih] + + + +omit [IsTopologicalGroup G] in +lemma lift_coefficients [IsTopologicalGroup G] (j : ℕ) (hj : 0 + if hk : k|L (S.subseq N)|^j* + TriangularLatticeRecovery.circleNorm ((χ (S.coeff N j)).toAdd)) atTop atTop) : + ∃ T : State c Γ s K P L,T.domain.rank(χ (S.coeff N j)).toAdd) j (fun N=>hL _) hbad + obtain ⟨flow,hflow,hunit,hrational⟩:=RationalLevelFlow.exists_unit_flow + D.chart D.secondKind D.lattice (D.filtration.level j) D.integer_lattice + (D.cutoff j) (D.cutoff_le j) (D.adapted j) χ hcont hz hne + obtain ⟨E,J,hJcont,hJinj,heembed,hrange,hlevels,hrank⟩:= + D.exists_refinement j hj hjs χ hnext hbr hcont hz hne + let F:=D.refinedFiltration j hj χ hnext hbr + let ν:=S.subseq∘φ + have hν : StrictMono ν:=S.strictmono.comp hφ + let w : Removal c (L∘ν) s:= + { flow := D.embed.comp ((D.filtration.level j).subtype.comp flow) + continuous := D.continuous.comp (continuous_subtype_val.comp hflow) + rational_unit := D.rational_image _ hrational + degree := j + degree_pos := hj + degree_le := hjs + integer := m + small := δ + bound := C + bound_nonneg := hC + small_bound := hbound + limit := a + scaled_tendsto := htendsto } + let u (N : ℕ):=flow (Multiplicative.ofAdd (δ N)) + let v (N : ℕ):=flow (Multiplicative.ofAdd (m N:ℝ)) + have hb (N : ℕ) : ∃ b : ℕ → D.Carrier, + (∀ i(S.coeff (φ N) k).val) (s+1) z * + ((v N).val^Ring.choose z j)⁻¹=word b (s+1) z) := by + apply one_level_descent D.filtration (D.zero_top.trans D.one_top.symm) + j hj χ hnext hbr (s+1) D.terminal (by omega) + (fun k=>(S.coeff (φ N) k).val) (fun i _=>(S.coeff (φ N) i).property) + (S.zero (φ N)) (u N) (v N) + change (χ (flow (Multiplicative.ofAdd (δ N)))).toAdd+ + (χ (flow (Multiplicative.ofAdd (m N:ℝ)))).toAdd=(χ (S.coeff (φ N) j)).toAdd + rw [hunit,hunit,hdecomp N] + ring + choose b hbmem hblow hbword using hb + have hbzero (N : ℕ) : b N 0=1:=(hblow N 0 hj).trans (S.zero (φ N)) + have hac (N : ℕ) : ∃ ac : ∀ k : ℕ,E.filtration.level k, + (ac 0).val=1 ∧ ∀ k(ac N k).val) (s+1) z)=word (b N) (s+1) z := by + rw [monoidHom_word] + exact congrFun (word_congr (s+1) (hac N)) z + have hleft (N : ℕ) (z : ℤ) : + w.left N z=D.embed ((u N).val^Ring.choose z j) := by + simp only [Removal.left,w,u,MonoidHom.coe_comp,Function.comp_apply, + Subgroup.coe_subtype,map_zpow] + have hright (N : ℕ) (z : ℤ) : + w.right N z=D.embed ((v N).val^Ring.choose z j) := by + rw [Removal.right_eq] + simp only [w,v,MonoidHom.coe_comp,Function.comp_apply,Subgroup.coe_subtype,map_zpow] + let W₀ : List (Removal c (L∘ν) s):=S.removals.map (fun w=>w.reindex φ hφ) + let W : List (Removal c (L∘ν) s):=W₀ ++ [w] + let T : State c Γ s K P L:= + { domain := E + subseq := ν + strictmono := hν + coeff := ac + zero := hac0 + level_image := by + intro k x hx + rw [heembed] + apply S.level_image k + have hh:=(hlevels k x).mp hx + exact shrinkLevel_le D.filtration j (levelKernel D.filtration j χ) + (levelKernel_le D.filtration j χ) k hh + removals := W + realization := by + intro N z + change P (S.subseq (φ N)) z=leftWord W N z* + E.embed (word (fun k=>(ac N k).val) (s+1) z)*rightWord W N z + rw [S.realization] + simp only [W,W₀,leftWord_append,rightWord_append,leftWord_reindex,rightWord_reindex] + rw [hleft,hright,heembed,hword] + have he : word (fun k=>(S.coeff (φ N) k).val) (s+1) z= + (u N).val^Ring.choose z j*word (b N) (s+1) z*(v N).val^Ring.choose z j := by + rw [← hbword N z] + group + rw [he,map_mul,map_mul] + dsimp only [D] + group } + exact ⟨T,hrank⟩ + +end State +end AllLevelStates + +end +end +end +end + +end OAI diff --git a/lean/OAI/Combinatorics/SumProduct/Alignment/AllLevel05.lean b/lean/OAI/Combinatorics/SumProduct/Alignment/AllLevel05.lean new file mode 100644 index 0000000000000000000000000000000000000000..16bd6e917fc65c40119fa58d9239b68de6067303 --- /dev/null +++ b/lean/OAI/Combinatorics/SumProduct/Alignment/AllLevel05.lean @@ -0,0 +1,279 @@ +import Mathlib +import OAI.Combinatorics.SumProduct.Alignment.ParametricSmooth01 +import OAI.Geometry.NilpotentCharts.Main + +namespace OAI + +section +section +section +noncomputable section +open scoped BigOperators Topology +open Filter +end + +end + +section + + + + +noncomputable section +open scoped BigOperators Topology +open Filter +universe u +namespace AllLevelRemovals +open RationalLattice +variable {G : Type u} [Group G] [TopologicalSpace G] [IsTopologicalGroup G] +variable {n s : ℕ} {c : RealCoordinates G n} {L : ℕ → ℝ} + +namespace Removal + +def smooth (w : Removal c L s) (N : ℕ) (b : ℝ) : G := + w.flow (Multiplicative.ofAdd (w.small N*Ring.choose b w.degree)) + +omit [IsTopologicalGroup G] in +lemma smooth_integer [IsTopologicalGroup G] (w : Removal c L s) (N : ℕ) (z : ℤ) : + w.smooth N (z:ℝ)=w.left N z := by + have hc:=Ring.map_choose (Int.castRingHom ℝ) z w.degree + change ((Ring.choose z w.degree:ℤ):ℝ)=Ring.choose (z:ℝ) w.degree at hc + rw [smooth,← hc,left,← w.flow.map_zpow] + congr 1 + change Multiplicative.ofAdd (w.small N* ((Ring.choose z w.degree:ℤ):ℝ))= + Multiplicative.ofAdd ((Ring.choose z w.degree:ℤ) • w.small N) + simp only [zsmul_eq_mul,mul_comm] + +end Removal + +def smoothWord (W : List (Removal c L s)) (N : ℕ) (b : ℝ) : G := + (W.map (fun w=>w.smooth N b)).prod +lemma smoothWord_integer (W : List (Removal c L s)) (N : ℕ) (z : ℤ) : + smoothWord W N (z:ℝ)=leftWord W N z := by + simp [smoothWord,leftWord,Removal.smooth_integer] + +section Parameters +variable {l : ℕ} (W : Fin l → Removal c L s) + +def scalarProfile (i : Fin l) (t : Option (Fin l) → ℝ) (x : ℝ) : ℝ := + t (some i) * ((W i).degree.factorial:ℝ)⁻¹ * + ∏ k∈Finset.range (W i).degree,(x-(k:ℝ)*t none) + +def profile (t : Option (Fin l) → ℝ) (x : ℝ) : G := + (List.ofFn (fun i=>(W i).flow (Multiplicative.ofAdd (scalarProfile W i t x)))).prod + +def parameters (N : ℕ) : Option (Fin l) → ℝ + | none => (L N)⁻¹ + | some i => (L N)^(W i).degree*(W i).small N + +def limitParameters : Option (Fin l) → ℝ + | none => 0 + | some i => (W i).limit + +omit [IsTopologicalGroup G] in +lemma parameters_tendsto [IsTopologicalGroup G] (hL : Tendsto L atTop atTop) : + Tendsto (parameters W) atTop (𝓝 (limitParameters W)) := by + apply tendsto_pi_nhds.mpr + intro i + cases i with + | none => exact tendsto_inv_atTop_zero.comp hL + | some i => exact (W i).scaled_tendsto + +omit [IsTopologicalGroup G] in +lemma scalarProfile_parameters [IsTopologicalGroup G] (N : ℕ) (hL : L N≠0) (i : Fin l) (x : ℝ) : + scalarProfile W i (parameters W N) x=(W i).small N*Ring.choose (L N*x) (W i).degree := by + rw [SmoothBinomial.amplitude_identity _ _ _ _ hL,SmoothBinomial.universal_eval] + simp only [scalarProfile,parameters] + ring + +omit [IsTopologicalGroup G] in +lemma scalarProfile_limit [IsTopologicalGroup G] (i : Fin l) (x : ℝ) : + scalarProfile W i (limitParameters W) x= + (W i).limit *((W i).degree.factorial:ℝ)⁻¹*x^(W i).degree := by + simp [scalarProfile,limitParameters] + +omit [IsTopologicalGroup G] in +lemma scalarProfile_polynomial [IsTopologicalGroup G] (i : Fin l) : ParametricSmooth.IsPolynomial (scalarProfile W i) := by + unfold scalarProfile + exact ParametricSmooth.mul + (ParametricSmooth.mul (ParametricSmooth.parameter (some i)) (ParametricSmooth.constant _)) + (ParametricSmooth.finite_prod _ (fun k _=>ParametricSmooth.sub ParametricSmooth.coordinate + (ParametricSmooth.mul (ParametricSmooth.constant _) (ParametricSmooth.parameter none)))) + +omit [IsTopologicalGroup G] in +lemma polynomial_mul [IsTopologicalGroup G] {σ : Type*} {f g : (σ → ℝ) → ℝ → G} + (hf : ∀ i,ParametricSmooth.IsPolynomial (fun t x=>c.coord (f t x) i)) + (hg : ∀ i,ParametricSmooth.IsPolynomial (fun t x=>c.coord (g t x) i)) : + ∀ i,ParametricSmooth.IsPolynomial (fun t x=>c.coord (f t x*g t x) i) := by + intro i + simp only [c.mul_coord] + refine ParametricSmooth.add (ParametricSmooth.add (hf i) (hg i)) ?_ + apply ParametricSmooth.mvpolynomial_eval + intro j + cases j with + | inl j => exact hf _ + | inr j => exact hg _ + +lemma profile_polynomial (i : Fin n) : + ParametricSmooth.IsPolynomial (fun t x=>c.coord (profile W t x) i) := by + have hflow (a : Fin l) (i : Fin n) : ParametricSmooth.IsPolynomial + (fun t x=>c.coord ((W a).flow (Multiplicative.ofAdd (scalarProfile W a t x))) i) := by + have he (t : Option (Fin l) → ℝ) (x : ℝ) : + c.coord ((W a).flow (Multiplicative.ofAdd (scalarProfile W a t x))) i= + (powerPolynomial c ((W a).flow (Multiplicative.ofAdd 1)) i).eval (scalarProfile W a t x) := by + rw [RationalLevelFlow.continuous_flow_eq_realPower c (W a).flow (W a).continuous + (scalarProfile W a t x),realPower_coord] + simp_rw [he] + exact ParametricSmooth.polynomial_eval _ (scalarProfile_polynomial W a) + unfold profile + simp only [List.ofFn_eq_map] + generalize List.finRange l=v + induction v generalizing i with + | nil => simpa [c.one_coord] using ParametricSmooth.constant (σ:=Option (Fin l)) 0 + | cons a v ih => + simp only [List.map_cons,List.prod_cons] + exact polynomial_mul (fun i=>hflow a i) (fun i=>by + exact ih i) i + +lemma profile_smooth (t : Option (Fin l) → ℝ) (i : Fin n) : + ContDiff ℝ (⊤ : ℕ∞) (fun x=>c.coord (profile W t x) i) := by + obtain ⟨p,hp⟩:=profile_polynomial W i + have he : (fun x=>c.coord (profile W t x) i)=fun x=>(ParametricSmooth.family p t).eval x:= + funext (fun x=>(hp t x).symm) + rw [he] + simp only [Polynomial.eval_eq_sum_range] + fun_prop + +end Parameters + +def smoothLimit (W : List (Removal c L s)) (x : ℝ) : G := + profile W.get (limitParameters W.get) x + +lemma smoothWord_eq_profile (W : List (Removal c L s)) (N : ℕ) (hL : L N≠0) (x : ℝ) : + smoothWord W N (L N*x)=profile W.get (parameters W.get N) x := by + unfold smoothWord profile + simp_rw [scalarProfile_parameters W.get N hL] + rw [List.ofFn_eq_map] + conv_lhs => rw [← List.map_get_finRange W,List.map_map] + rfl + + + +theorem smoothWord_limit (W : List (Removal c L s)) + (hL : ∀ N,0iteratedDeriv k (fun x=>c.coord (smoothWord W N (L N*x)) i)) + (iteratedDeriv k (fun x=>c.coord (smoothLimit W x) i)) atTop K := by + simp_rw [smoothWord_eq_profile W _ (ne_of_gt (hL _))] + exact ParametricSmooth.compact_derivative_limit (profile_polynomial W.get i) + (parameters_tendsto W.get ht) k K hK + + + +theorem smoothWord_bounds (W : List (Removal c L s)) + (hL : ∀ N,00,∀ N x,x∈K → + |iteratedDeriv k (fun x=>c.coord (smoothWord W N (L N*x)) i) x|≤B := by + simp_rw [smoothWord_eq_profile W _ (ne_of_gt (hL _))] + exact ParametricSmooth.compact_derivative_bound (profile_polynomial W.get i) + (parameters_tendsto W.get ht) k K hK + +end AllLevelRemovals +end + +end + +section + + + + +noncomputable section +open scoped BigOperators Topology +open Filter +universe u +namespace AllLevelRemovals +open RationalLattice +variable {G : Type u} [Group G] [TopologicalSpace G] [IsTopologicalGroup G] +variable {n s : ℕ} {c : RealCoordinates G n} {L : ℕ → ℝ} +variable {l : ℕ} (W : Fin l → Removal c L s) + +def prefixProfile (t : (Fin n ⊕ Option (Fin l)) → ℝ) (x : ℝ) : G := + c.coord.symm (t∘Sum.inl)*profile W (t∘Sum.inr) x + +lemma prefixProfile_polynomial (i : Fin n) : + ParametricSmooth.IsPolynomial (fun t x=>c.coord (prefixProfile W t x) i) := by + apply polynomial_mul + · intro j + simpa only [Homeomorph.apply_symm_apply,Function.comp_apply] using + ParametricSmooth.parameter (Sum.inl j : Fin n ⊕ Option (Fin l)) + · intro j + exact ParametricSmooth.rename_parameters (profile_polynomial W j) Sum.inr + +def prefixParameters (a : ℕ → G) (N : ℕ) : (Fin n ⊕ Option (Fin l)) → ℝ := + Sum.elim (c.coord (a N)) (parameters W N) +def prefixLimitParameters (a₀ : G) : (Fin n ⊕ Option (Fin l)) → ℝ := + Sum.elim (c.coord a₀) (limitParameters W) + +lemma prefixParameters_tendsto {a : ℕ → G} {a₀ : G} (ha : Tendsto a atTop (𝓝 a₀)) + (hL : Tendsto L atTop atTop) : + Tendsto (prefixParameters W a) atTop (𝓝 (prefixLimitParameters W a₀)) := by + apply tendsto_pi_nhds.mpr + intro i + cases i with + | inl i => exact ((continuous_apply i).comp c.coord.continuous).continuousAt.tendsto.comp ha + | inr i => exact (tendsto_pi_nhds.mp (parameters_tendsto W hL)) i + +omit [IsTopologicalGroup G] in +lemma prefixProfile_parameters [IsTopologicalGroup G] (a : ℕ → G) (N : ℕ) (x : ℝ) : + prefixProfile W (prefixParameters W a N) x=a N*profile W (parameters W N) x := by + simp [prefixProfile,prefixParameters,Function.comp_def] +omit [IsTopologicalGroup G] in +lemma prefixProfile_limit [IsTopologicalGroup G] (a₀ : G) (x : ℝ) : + prefixProfile W (prefixLimitParameters W a₀) x=a₀*profile W (limitParameters W) x := by + simp [prefixProfile,prefixLimitParameters,Function.comp_def] + +theorem prefix_smoothWord_limit (V : List (Removal c L s)) + (hL : ∀ N,0iteratedDeriv k (fun x=>c.coord (a N*smoothWord V N (L N*x)) i)) + (iteratedDeriv k (fun x=>c.coord (a₀*smoothLimit V x) i)) atTop K := by + have h:=ParametricSmooth.compact_derivative_limit (prefixProfile_polynomial V.get i) + (prefixParameters_tendsto V.get ha ht) k K hK + simp_rw [prefixProfile_parameters,prefixProfile_limit] at h + simp_rw [smoothWord_eq_profile V _ (ne_of_gt (hL _))] + exact h + +theorem prefix_smoothWord_bounds (V : List (Removal c L s)) + (hL : ∀ N,00,∀ N x,x∈K → + |iteratedDeriv k (fun x=>c.coord (a N*smoothWord V N (L N*x)) i) x|≤B := by + have h:=ParametricSmooth.compact_derivative_bound (prefixProfile_polynomial V.get i) + (prefixParameters_tendsto V.get ha ht) k K hK + simp_rw [prefixProfile_parameters] at h + simp_rw [smoothWord_eq_profile V _ (ne_of_gt (hL _))] + exact h + +theorem prefix_smoothLimit_smooth (V : List (Removal c L s)) (a₀ : G) (i : Fin n) : + ContDiff ℝ (⊤ : ℕ∞) (fun x=>c.coord (a₀*smoothLimit V x) i) := by + obtain ⟨p,hp⟩:=prefixProfile_polynomial V.get i + have he : (fun x=>c.coord (a₀*smoothLimit V x) i)= + fun x=>(ParametricSmooth.family p (prefixLimitParameters V.get a₀)).eval x := by + funext x + simpa only [prefixProfile_limit,smoothLimit] using (hp (prefixLimitParameters V.get a₀) x).symm + rw [he] + simp only [Polynomial.eval_eq_sum_range] + fun_prop + +end AllLevelRemovals + +end +end +end +end + +end OAI diff --git a/lean/OAI/Combinatorics/SumProduct/Alignment/AllLevel06.lean b/lean/OAI/Combinatorics/SumProduct/Alignment/AllLevel06.lean new file mode 100644 index 0000000000000000000000000000000000000000..11b99095405a04016ccdf190218f18fc818d0ea5 --- /dev/null +++ b/lean/OAI/Combinatorics/SumProduct/Alignment/AllLevel06.lean @@ -0,0 +1,307 @@ +import Mathlib +import OAI.Combinatorics.SumProduct.Alignment.EmbeddedCube01 +import OAI.Geometry.NilpotentCharts.Main + +namespace OAI + +open scoped BigOperators +section +noncomputable section +open scoped Topology + +end + +end + +section + + + + +noncomputable section +open scoped BigOperators Topology +namespace CubeTaylorExpansion +open RationalLattice CubeFaces NilpotentTaylor +variable {G ι : Type*} [Group G] [TopologicalSpace G] [IsTopologicalGroup G] +variable {n : ℕ} (c : RealCoordinates G n) (H : Filtration G) + +lemma choose_cast_int (z : ℤ) (k : ℕ) : + Ring.choose (z:ℝ) k=((Ring.choose z k:ℤ):ℝ) := + (Ring.map_choose (Int.castRingHom ℝ) z k).symm + +omit [TopologicalSpace G] [IsTopologicalGroup G] in +lemma word_eq_list (a : ℕ → G) (d : ℕ) (z : ℤ) : + word a d z=((List.range d).map (fun k=>a k^Ring.choose z k)).prod := by + induction d with + | zero => rfl + | succ d ih => + rw [List.prod_range_succ] + exact congrArg (fun v=>v*a d^Ring.choose z d) ih + +omit [IsTopologicalGroup G] in +lemma taylorPolynomial_int (a : ∀ k : ℕ,H.level k) (s : ℕ) (z : ℤ) : + taylorPolynomial c H a s (z:ℝ)=word (fun k=>(a k).val) (s+1) z := by + rw [word_eq_list] + simp only [taylorPolynomial,choose_cast_int,realPower_int] + +variable [Fintype ι] [DecidableEq ι] +variable (S : ℕ→Set (Fin n)) +variable (hH : ∀ k (g : G),g∈H.level k ↔ ∀ i∈S k,c.coord g i=0) + +omit [IsTopologicalGroup G] in +lemma cubePolynomial_integer_vertex (a : ∀ k : ℕ,H.level k) (s : ℕ) + (b : Option ι→ℤ) (v : Finset ι) : + ((cubePolynomial c H S hH a s (fun i=>(b i:ℝ)) : cube H Finset.univ 0) : Finset ι→G) v= + word (fun k=>(a k).val) (s+1) (b none+∑ i∈v,b (some i)) := by + rw [cubePolynomial_vertex,← taylorPolynomial_int c H] + congr 1 + push_cast + rfl + +end CubeTaylorExpansion +end + +end + +section + + + + +noncomputable section +open scoped BigOperators Topology +open Filter +namespace AllLevelFactorization.Factorization +open AllLevelDomains AllLevelStates RationalLattice CubeFaces MalcevCharacters +variable {G : Type} [Group G] [TopologicalSpace G] [IsTopologicalGroup G] +variable {n s : ℕ} {c : RealCoordinates G n} {Γ : Subgroup G} +variable {K : Filtration G} {P : ℕ → ℤ → G} {L : ℕ → ℝ} +variable (F : Factorization c Γ s K P L) + +lemma smoothLimit_continuous : Continuous F.smoothLimit := by + have hc : Continuous (fun β=>c.coord (F.smoothLimit β)) := + continuous_pi fun i=>(F.limit_smooth i).continuous + simpa only [Function.comp_def,Homeomorph.symm_apply_apply] using c.coord.symm.continuous.comp hc + +lemma smooth_coord_uniform (hL : ∀ N,0 < L N) (ht : Tendsto L atTop atTop) + (A : Set ℝ) (hA : IsCompact A) (ε : ℝ) (hε : 0 < ε) : + ∀ᶠ N : ℕ in atTop,∀ t∈A, + dist (c.coord (F.smoothPart N (L (F.state.subseq N)*t))) + (c.coord (F.smoothLimit t)) < ε := by + have hi (i : Fin n) : ∀ᶠ N : ℕ in atTop,∀ t∈A, + dist (c.coord (F.smoothPart N (L (F.state.subseq N)*t)) i) + (c.coord (F.smoothLimit t) i) < ε := by + have hu := F.smooth_limit hL ht 0 i A hA + simpa only [iteratedDeriv_zero,dist_comm] using (Metric.tendstoUniformlyOn_iff.mp hu ε hε) + filter_upwards [eventually_all.mpr hi] with N hN + intro t ht + rw [dist_pi_lt_iff hε] + exact fun i=>hN i t ht + + + + theorem smooth_neighborhood {κ τ : Type*} [Fintype τ] + (hL : ∀ N,0 < L N) (ht : Tendsto L atTop atTop) + (β : ℝ) (T : ℝ → ℕ → Finset κ) (t : ℝ → ℕ → κ → τ → ℝ) (C : ℝ) + (hpos : ∀ α : ℝ,0 < α → ∀ᶠ N : ℕ in atTop,∀ z∈T α N,∀ w, + dist (t α N z w) β ≤ C*α) : + ∀ U∈𝓝 (fun _ : τ=>F.smoothLimit β),∀ᶠ α : ℝ in 𝓝[>] 0, + ∀ᶠ N : ℕ in atTop,∀ z∈T α N, + (fun w=>F.smoothPart N (L (F.state.subseq N)*t α N z w))∈U := by + let f : (τ → Fin n → ℝ) → (τ → G) := fun u w=>c.coord.symm (u w) + have hf : Continuous f := continuous_pi fun w=>c.coord.symm.continuous.comp (continuous_apply w) + intro U hU + have hpre : f ⁻¹' U∈𝓝 (fun _ : τ=>c.coord (F.smoothLimit β)) := by + apply hf.continuousAt.preimage_mem_nhds + simpa [f] using hU + have hc : ContinuousAt (fun t=>c.coord (F.smoothLimit t)) β := + (c.coord.continuous.comp F.smoothLimit_continuous).continuousAt + have hh (ε : ℝ) (hε : 0 < ε) : ∀ᶠ N : ℕ in atTop,∀ t : ℝ,dist t β < 1 → + dist (c.coord (F.smoothPart N (L (F.state.subseq N)*t))) + (c.coord (F.smoothLimit t)) < ε := by + filter_upwards [F.smooth_coord_uniform hL ht (Set.Icc (β-1) (β+1)) isCompact_Icc ε hε] with N hN + intro t ht + apply hN t + rw [Real.dist_eq,abs_lt] at ht + exact ⟨by linarith [ht.1],by linarith [ht.2]⟩ + have hv:=CubeLocalHaar.smooth_local_freezing + (fun N t=>c.coord (F.smoothPart N (L (F.state.subseq N)*t))) + (fun t=>c.coord (F.smoothLimit t)) β hc 1 zero_lt_one hh T t C hpos + (f ⁻¹' U) hpre + simpa only [Set.mem_preimage,f,Homeomorph.symm_apply_apply] using hv + +end AllLevelFactorization.Factorization +end + +end + +section + + +noncomputable section +open scoped BigOperators Topology +open Filter MeasureTheory +namespace CompactTwoScale +variable {X A κ : Type*} [TopologicalSpace X] [CompactSpace X] +variable [MeasurableSpace X] [BorelSpace X] [TopologicalSpace A] +variable (μ : Measure X) [IsProbabilityMeasure μ] + + + +omit [BorelSpace X] [IsProbabilityMeasure μ] in +theorem freezing (F : A → C(X,ℂ)) (hF : Continuous F) (a₀ : A) + (T : ℝ → ℕ → Finset κ) (p : ℝ → ℕ → κ → X) (a : ℝ → ℕ → κ → A) + (hbase : ∀ α : ℝ,0 < α → ∀ ε : ℝ,0 < ε → ∀ᶠ N : ℕ in atTop, + ‖(𝔼 z∈T α N,F a₀ (p α N z))-(∫ x,F a₀ x ∂μ)‖ < ε) + (hsm : ∀ U∈𝓝 a₀,∀ᶠ α : ℝ in 𝓝[>] 0,∀ᶠ N : ℕ in atTop, + ∀ z∈T α N,a α N z∈U) : + ∀ ε : ℝ,0 < ε → ∀ᶠ α : ℝ in 𝓝[>] 0,∀ᶠ N : ℕ in atTop, + ‖(𝔼 z∈T α N,F (a α N z) (p α N z))-(∫ x,F a₀ x ∂μ)‖ < ε := by + intro ε hε + have hε3 : 0 < ε/3:=by positivity + let U : Set A:=F ⁻¹' Metric.ball (F a₀) (ε/3) + have hU : U∈𝓝 a₀:=hF.continuousAt.preimage_mem_nhds (Metric.ball_mem_nhds _ hε3) + filter_upwards [hsm U hU,(self_mem_nhdsWithin : Set.Ioi (0:ℝ)∈𝓝[>] 0)] with α hα ha + filter_upwards [hα,hbase α ha (ε/3) hε3] with N hN hb + have hp (z : κ) (hz : z∈T α N) : + ‖F (a α N z) (p α N z)-F a₀ (p α N z)‖ ≤ ε/3 := by + apply (ContinuousMap.norm_coe_le_norm (F (a α N z)-F a₀) (p α N z)).trans + exact le_of_lt (by simpa only [U,Set.mem_preimage,Metric.mem_ball,dist_eq_norm] using hN z hz) + have hm : ‖𝔼 z∈T α N,(F (a α N z) (p α N z)-F a₀ (p α N z))‖ ≤ ε/3 := by + by_cases hn : (T α N).Nonempty + · exact (RCLike.norm_expect_le (K:=ℂ)).trans (Finset.expect_le hn hp) + · simp only [Finset.not_nonempty_iff_eq_empty.mp hn,Finset.expect_empty,norm_zero] + positivity + rw [Finset.expect_sub_distrib] at hm + calc + _ = ‖((𝔼 z∈T α N,F (a α N z) (p α N z))-(𝔼 z∈T α N,F a₀ (p α N z)))+ + ((𝔼 z∈T α N,F a₀ (p α N z))-(∫ x,F a₀ x ∂μ))‖:=by congr 1; ring + _ ≤ _ := norm_add_le _ _ + _ < ε := by linarith only [hm,hb,hε] +end CompactTwoScale + +namespace EmbeddedCubeHaar +open CubeFaces CubeLocalHaar RationalLattice +variable {G H ι : Type} [Group G] [Group H] +variable [TopologicalSpace G] [TopologicalSpace H] +variable [IsTopologicalGroup G] [IsTopologicalGroup H] +variable [Fintype ι] [DecidableEq ι] +variable (f : H →* G) (hc : Continuous f) (K : Filtration H) (Λ : Subgroup G) (σ : G) +variable (Δ : Subgroup H) (hle : Δ ≤ inducedLattice f Λ σ) + +def frozenTest (F : C((Finset ι→G⧸Λ),ℂ)) (a : Finset ι→G) : + C(((cube K (Finset.univ : Finset ι) 0)⧸cubeLattice K Δ),ℂ) := + ⟨fun x=>F (haarImage f K Λ σ Δ hle a x),F.continuous.comp + ((haarImage_continuous f hc K Λ σ Δ hle).comp (continuous_const.prodMk continuous_id))⟩ + +omit [IsTopologicalGroup H] in +lemma frozenTest_continuous (F : C((Finset ι→G⧸Λ),ℂ)) : + Continuous (frozenTest f hc K Λ σ Δ hle F) := + (ContinuousMap.curry ⟨_,F.continuous.comp (haarImage_continuous f hc K Λ σ Δ hle)⟩).continuous + +end EmbeddedCubeHaar + +end + +end + +section + + + + +noncomputable section +open scoped BigOperators Topology +open Filter MeasureTheory +namespace AllLevelFactorization.Factorization.ResidueCover +open RationalLattice CubeFaces CubeTaylorExpansion ComparableBoxLeibman CubeLocalHaar +variable {G ι : Type} [Group G] [TopologicalSpace G] [IsTopologicalGroup G] +variable [Fintype ι] [DecidableEq ι] +variable {n s : ℕ} {c : RealCoordinates G n} {Γ : Subgroup G} +variable {K : Filtration G} {P : ℕ → ℤ → G} {L : ℕ → ℝ} +variable {F : Factorization c Γ s K P L} {r : Fin F.period} (C : F.ResidueCover r) + +abbrev CubeGroup := cube F.state.domain.filtration (Finset.univ : Finset ι) 0 +abbrev CubeSpace := (CubeGroup (ι:=ι) (F:=F))⧸cubeLattice F.state.domain.filtration C.lattice + +def cubePoint (N : ℕ) (b : Option ι → ℤ) : C.CubeSpace (ι:=ι) := + QuotientGroup.mk (cubePolynomial C.chart F.state.domain.filtration + (fun k=>{i : Fin F.state.domain.dim | i.val < F.state.domain.cutoff k}) + (fun k g=>C.adapted k g) (F.state.coeff N) s (fun i=>(b i:ℝ))) + +instance compact_cubeSpace : CompactSpace (C.CubeSpace (ι:=ι)) := + CubeLocalHaar.cubeQuotient_compact F.state.domain.filtration C.lattice + (BaseCubeLaw.level_compact_reps C.chart F.state.domain.filtration F.state.domain.cutoff + C.adapted C.lattice C.integer_lattice) + +variable [MeasurableSpace (C.CubeSpace (ι:=ι))] [BorelSpace (C.CubeSpace (ι:=ι))] + +def haar : ProbabilityMeasure (C.CubeSpace (ι:=ι)) := + Classical.choose (BaseCubeLaw.exists_scaled_cube_law (ι:=ι) C.chart F.state.domain.filtration + F.state.domain.cutoff C.adapted C.lattice C.integer_lattice + (F.state.domain.zero_top.trans F.state.domain.one_top.symm) s F.state.domain.terminal) + +instance haar_invariant : SMulInvariantMeasure (CubeGroup (ι:=ι) (F:=F)) _ + (C.haar (ι:=ι) : Measure (C.CubeSpace (ι:=ι))) := + (Classical.choose_spec (BaseCubeLaw.exists_scaled_cube_law (ι:=ι) C.chart F.state.domain.filtration + F.state.domain.cutoff C.adapted C.lattice C.integer_lattice + (F.state.domain.zero_top.trans F.state.domain.one_top.symm) s F.state.domain.terminal)).1 + +omit [IsTopologicalGroup G] in +lemma haar_limit (hL : ∀ N,0 < L N) (ht : Tendsto L atTop atTop) + {v : ℕ} (e : Option ι ≃ Fin v) (c₀ C₀ : ℝ) (hc₀ : 0 < c₀) (hC₀ : 0 < C₀) + (d : ℕ) (hd : 0 < d) (a : Fin v → ℤ) (T : Set C(C.CubeSpace (ι:=ι),ℂ)) + (hT : IsCompact T) : + ∀ ε : ℝ,0 < ε → ∀ᶠ N : ℕ in atTop,∀ lo hi : Fin v → ℝ, + (∀ i,c₀*L (F.state.subseq N) ≤ hi i-lo i) → + (∀ i,-C₀*L (F.state.subseq N) ≤ lo i ∧ hi i ≤ C₀*L (F.state.subseq N)) → + ∀ f : C(C.CubeSpace (ι:=ι),ℂ),f∈T → + ‖(𝔼 x∈integerBox v lo hi,f (C.cubePoint N (fun i=>a (e i)+(d:ℤ)*x (e i))))- + (∫ y,f y ∂(C.haar (ι:=ι) : Measure (C.CubeSpace (ι:=ι))))‖ < ε := by + exact (Classical.choose_spec (BaseCubeLaw.exists_scaled_cube_law (ι:=ι) C.chart + F.state.domain.filtration F.state.domain.cutoff C.adapted C.lattice C.integer_lattice + (F.state.domain.zero_top.trans F.state.domain.one_top.symm) s F.state.domain.terminal)).2 + v e (L∘F.state.subseq) (ht.comp F.state.strictmono.tendsto_atTop) + F.state.coeff (C.irrational hL) c₀ C₀ hc₀ hC₀ d hd a T hT + + + +theorem two_scale (hL : ∀ N,0 < L N) (ht : Tendsto L atTop atTop) + {v : ℕ} (e : Option ι ≃ Fin v) (d : ℕ) (hd : 0 < d) (a : Fin v → ℤ) + (lo hi : ℝ → ℕ → Fin v → ℝ) + (hb : ∀ α : ℝ,0 < α → ∃ c₀ C₀ : ℝ,0 < c₀ ∧ 0 < C₀ ∧ ∀ᶠ N : ℕ in atTop, + (∀ i,c₀*L (F.state.subseq N) ≤ hi α N i-lo α N i) ∧ + (∀ i,-C₀*L (F.state.subseq N) ≤ lo α N i ∧ hi α N i ≤ C₀*L (F.state.subseq N))) + (u : ℝ → ℕ → (Fin v → ℤ) → Finset ι → G) (u₀ : Finset ι → G) + (hu : ∀ U∈𝓝 u₀,∀ᶠ α : ℝ in 𝓝[>] 0,∀ᶠ N : ℕ in atTop, + ∀ z∈integerBox v (lo α N) (hi α N),u α N z∈U) + (f : C((Finset ι → G⧸Γ),ℂ)) : + ∀ ε : ℝ,0 < ε → ∀ᶠ α : ℝ in 𝓝[>] 0,∀ᶠ N : ℕ in atTop, + ‖(𝔼 z∈integerBox v (lo α N) (hi α N), + f (EmbeddedCubeHaar.haarImage F.state.domain.embed F.state.domain.filtration Γ + (F.residue r) C.lattice C.le_induced (u α N z) + (C.cubePoint N (fun i=>a (e i)+(d:ℤ)*z (e i)))))- + (∫ x,EmbeddedCubeHaar.frozenTest F.state.domain.embed F.state.domain.continuous + F.state.domain.filtration Γ (F.residue r) C.lattice C.le_induced f u₀ x + ∂(C.haar (ι:=ι) : Measure (C.CubeSpace (ι:=ι))))‖ < ε := by + apply CompactTwoScale.freezing (C.haar (ι:=ι) : Measure (C.CubeSpace (ι:=ι))) + (EmbeddedCubeHaar.frozenTest F.state.domain.embed F.state.domain.continuous + F.state.domain.filtration Γ (F.residue r) C.lattice C.le_induced f) + (EmbeddedCubeHaar.frozenTest_continuous F.state.domain.embed F.state.domain.continuous + F.state.domain.filtration Γ (F.residue r) C.lattice C.le_induced f) + u₀ (fun α N=>integerBox v (lo α N) (hi α N)) + (fun _ N z=>C.cubePoint N (fun i=>a (e i)+(d:ℤ)*z (e i))) u ?_ hu + intro α hα ε hε + obtain ⟨c₀,C₀,hc₀,hC₀,hbox⟩:=hb α hα + let f₀:=EmbeddedCubeHaar.frozenTest F.state.domain.embed F.state.domain.continuous + F.state.domain.filtration Γ (F.residue r) C.lattice C.le_induced f u₀ + filter_upwards [C.haar_limit hL ht e c₀ C₀ hc₀ hC₀ d hd a {f₀} isCompact_singleton ε hε, + hbox] with N hN hbN + exact hN (lo α N) (hi α N) hbN.1 hbN.2 f₀ rfl + +end AllLevelFactorization.Factorization.ResidueCover + +end +end + +end OAI diff --git a/lean/OAI/Combinatorics/SumProduct/Alignment/AllLevel07.lean b/lean/OAI/Combinatorics/SumProduct/Alignment/AllLevel07.lean new file mode 100644 index 0000000000000000000000000000000000000000..18c7312f41016297e290641290ecfc2f92666f1c --- /dev/null +++ b/lean/OAI/Combinatorics/SumProduct/Alignment/AllLevel07.lean @@ -0,0 +1,333 @@ +import Mathlib +import OAI.Combinatorics.SumProduct.Alignment.AllLevel06 +import OAI.Geometry.NilpotentCharts.Main + +namespace OAI + +open scoped BigOperators +section +noncomputable section +open scoped BigOperators Topology +open Filter MeasureTheory +end + +end + +section + + + + +noncomputable section +open scoped BigOperators Topology +open Filter +namespace AllLevelFactorization.Factorization +open RationalLattice CubeFaces CubeTaylorExpansion CubeLocalHaar +variable {G : Type} [Group G] [TopologicalSpace G] [IsTopologicalGroup G] +variable {n s : ℕ} {c : RealCoordinates G n} {Γ : Subgroup G} +variable {K : Filtration G} {P : ℕ → ℤ → G} {L : ℕ → ℝ} +variable (F : Factorization c Γ s K P L) + +lemma realization_of_residue (N : ℕ) (z : ℤ) (r : Fin F.period) + (hz : z%(F.period:ℤ)=(r.val:ℤ)) : + (QuotientGroup.mk (P (F.state.subseq N) z) : G⧸Γ)= + QuotientGroup.mk (F.smoothPart N z*F.state.domain.embed (F.structuredPart N z)*F.residue r) := by + obtain ⟨r',hr',he⟩:=F.realization N z + have hr : r'=r:=Fin.ext (by exact_mod_cast hr'.trans hz) + simpa only [hr] using he + +variable {ι : Type} [Fintype ι] [DecidableEq ι] + +def vertex (b : Option ι → ℤ) (w : Finset ι) : ℤ:=b none+∑ i∈w,b (some i) + +omit [Fintype ι] [DecidableEq ι] in +lemma vertex_mod (p : ℤ) (b : Option ι → ℤ) (r : ℤ) + (hbase : b none%p=r) (hinc : ∀ i,b (some i)%p=0) (w : Finset ι) : + vertex b w%p=r := by + have hs : p∣∑ i∈w,b (some i):= + Finset.dvd_sum (fun i _=>Int.dvd_of_emod_eq_zero (hinc i)) + simp only [vertex,Int.add_emod,Int.emod_eq_zero_of_dvd hs,add_zero,Int.emod_emod] + exact hbase + +omit [IsTopologicalGroup G] [Fintype ι] [DecidableEq ι] in +lemma affine_vertex_mod {v : ℕ} (e : Option ι ≃ Fin v) (d : ℕ) (a : Fin v → ℤ) + (hdp : F.period∣d) (r : Fin F.period) + (ha0 : a (e none)%(F.period:ℤ)=(r.val:ℤ)) + (hai : ∀ i,a (e (some i))%(F.period:ℤ)=0) + (z : Fin v → ℤ) (w : Finset ι) : + vertex (fun i=>a (e i)+(d:ℤ)*z (e i)) w%(F.period:ℤ)=(r.val:ℤ) := by + have hd : (F.period:ℤ)∣(d:ℤ):=by exact_mod_cast hdp + have hem (x y : ℤ) : (x+(d:ℤ)*y)%(F.period:ℤ)=x%(F.period:ℤ) := by + rw [Int.add_emod,Int.emod_eq_zero_of_dvd (dvd_mul_of_dvd_left hd y),add_zero,Int.emod_emod] + exact vertex_mod _ _ _ (by simpa only [hem] using ha0) + (fun i=>by simpa only [hem] using hai i) w + +namespace ResidueCover +variable {F} {r : Fin F.period} (C : F.ResidueCover r) + +lemma cube_realization (N : ℕ) (b : Option ι → ℤ) + (hb : ∀ w : Finset ι,vertex b w%(F.period:ℤ)=(r.val:ℤ)) : + (fun w : Finset ι=>(QuotientGroup.mk (P (F.state.subseq N) (vertex b w)) : G⧸Γ))= + EmbeddedCubeHaar.haarImage F.state.domain.embed F.state.domain.filtration Γ + (F.residue r) C.lattice C.le_induced + (fun w=>F.smoothPart N (vertex b w)) (C.cubePoint N b) := by + funext w + rw [F.realization_of_residue N _ r (hb w)] + unfold cubePoint + rw [EmbeddedCubeHaar.haarImage_mk,cubePolynomial_integer_vertex] + rfl + +end ResidueCover + +end AllLevelFactorization.Factorization +end + +end + +section + + + + +noncomputable section +open scoped BigOperators Topology +open Filter MeasureTheory +namespace AllLevelFactorization.Factorization.ResidueCover +open RationalLattice CubeFaces CubeTaylorExpansion ComparableBoxLeibman CubeLocalHaar +variable {G ι : Type} [Group G] [TopologicalSpace G] [IsTopologicalGroup G] +variable [Fintype ι] [DecidableEq ι] +variable {n s : ℕ} {c : RealCoordinates G n} {Γ : Subgroup G} +variable {K : Filtration G} {P : ℕ → ℤ → G} {L : ℕ → ℝ} +variable {F : Factorization c Γ s K P L} {r : Fin F.period} (C : F.ResidueCover r) +variable [MeasurableSpace (C.CubeSpace (ι:=ι))] [BorelSpace (C.CubeSpace (ι:=ι))] + +def limitIntegral (f : C((Finset ι → G⧸Γ),ℂ)) (β : ℝ) : ℂ := + ∫ x,EmbeddedCubeHaar.frozenTest F.state.domain.embed F.state.domain.continuous + F.state.domain.filtration Γ (F.residue r) C.lattice C.le_induced f + (fun _=>F.smoothLimit β) x ∂(C.haar (ι:=ι) : Measure (C.CubeSpace (ι:=ι))) + + + +theorem local_integerBox (hL : ∀ N,0 < L N) (ht : Tendsto L atTop atTop) + {v : ℕ} (e : Option ι ≃ Fin v) (d : ℕ) (hd : 0 < d) (a : Fin v → ℤ) + (hdp : F.period∣d) (ha0 : a (e none)%(F.period:ℤ)=(r.val:ℤ)) + (hai : ∀ i,a (e (some i))%(F.period:ℤ)=0) + (lo hi : ℝ → ℕ → Fin v → ℝ) + (hb : ∀ α : ℝ,0 < α → ∃ c₀ C₀ : ℝ,0 < c₀ ∧ 0 < C₀ ∧ ∀ᶠ N : ℕ in atTop, + (∀ i,c₀*L (F.state.subseq N) ≤ hi α N i-lo α N i) ∧ + (∀ i,-C₀*L (F.state.subseq N) ≤ lo α N i ∧ hi α N i ≤ C₀*L (F.state.subseq N))) + (β B : ℝ) + (hgeo : ∀ α : ℝ,0 < α → ∀ᶠ N : ℕ in atTop, + ∀ z∈integerBox v (lo α N) (hi α N),∀ w : Finset ι, + dist ((vertex (fun i=>a (e i)+(d:ℤ)*z (e i)) w:ℝ)/L (F.state.subseq N)) β ≤ B*α) + (f : C((Finset ι → G⧸Γ),ℂ)) : + ∀ ε : ℝ,0 < ε → ∀ᶠ α : ℝ in 𝓝[>] 0,∀ᶠ N : ℕ in atTop, + ‖(𝔼 z∈integerBox v (lo α N) (hi α N), + f (fun w=>QuotientGroup.mk (P (F.state.subseq N) + (vertex (fun i=>a (e i)+(d:ℤ)*z (e i)) w))))-C.limitIntegral f β‖ < ε := by + let T : ℝ → ℕ → Finset (Fin v → ℤ):=fun α N=>integerBox v (lo α N) (hi α N) + let b : (Fin v → ℤ) → Option ι → ℤ:=fun z i=>a (e i)+(d:ℤ)*z (e i) + let t : ℝ → ℕ → (Fin v → ℤ) → Finset ι → ℝ:= + fun _ N z w=>(vertex (b z) w:ℝ)/L (F.state.subseq N) + have hu:=F.smooth_neighborhood hL ht β T t B hgeo + have hm (N : ℕ) (z : Fin v → ℤ) (w : Finset ι) : + L (F.state.subseq N)*((vertex (b z) w:ℝ)/L (F.state.subseq N))=(vertex (b z) w:ℝ) := by + field_simp [ne_of_gt (hL (F.state.subseq N))] + simp only [t,hm] at hu + have he:=C.two_scale hL ht e d hd a lo hi hb + (fun _ N z w=>F.smoothPart N (vertex (b z) w)) (fun _=>F.smoothLimit β) hu f + have himage (N : ℕ) (z : Fin v → ℤ) : + EmbeddedCubeHaar.haarImage F.state.domain.embed F.state.domain.filtration Γ + (F.residue r) C.lattice C.le_induced + (fun w=>F.smoothPart N (vertex (b z) w)) (C.cubePoint N (b z))= + fun w : Finset ι=>QuotientGroup.mk (P (F.state.subseq N) (vertex (b z) w)) := + (C.cube_realization N (b z) (fun w=>F.affine_vertex_mod e d a hdp r ha0 hai z w)).symm + change ∀ ε : ℝ,0 < ε → ∀ᶠ α : ℝ in 𝓝[>] 0,∀ᶠ N : ℕ in atTop, + ‖(𝔼 z∈integerBox v (lo α N) (hi α N),f (EmbeddedCubeHaar.haarImage + F.state.domain.embed F.state.domain.filtration Γ (F.residue r) C.lattice C.le_induced + (fun w=>F.smoothPart N (vertex (b z) w)) (C.cubePoint N (b z))))-C.limitIntegral f β‖ < ε at he + simpa only [himage,b] using he + +end AllLevelFactorization.Factorization.ResidueCover +end + +end + +section + + + +noncomputable section +open scoped BigOperators Topology +open Filter MeasureTheory +namespace CompactTwoScale +variable {X P κ : Type*} [TopologicalSpace X] [CompactSpace X] +variable [MeasurableSpace X] [BorelSpace X] [TopologicalSpace P] +variable (μ : Measure X) [IsProbabilityMeasure μ] +omit [BorelSpace X] [IsProbabilityMeasure μ] in +theorem freezing_uniform (F : P→C(X,ℂ)) (hF : Continuous F) (a₀ : P) + (J : ℝ→ℕ→Type*) + (T : ∀ α N,J α N→Finset κ) (p : ∀ α N,J α N→κ→X) + (a : ∀ α N,J α N→κ→P) + (hbase : ∀ α : ℝ,0<α → ∀ ε : ℝ,0<ε → ∀ᶠ N : ℕ in atTop,∀ j : J α N, + ‖(𝔼 z∈T α N j,F a₀ (p α N j z))-(∫ x,F a₀ x ∂μ)‖<ε) + (hsm : ∀ U∈𝓝 a₀,∀ᶠ α : ℝ in 𝓝[>] 0,∀ᶠ N : ℕ in atTop, + ∀ j : J α N,∀ z∈T α N j,a α N j z∈U) : + ∀ ε : ℝ,0<ε → ∀ᶠ α : ℝ in 𝓝[>] 0,∀ᶠ N : ℕ in atTop,∀ j : J α N, + ‖(𝔼 z∈T α N j,F (a α N j z) (p α N j z))-(∫ x,F a₀ x ∂μ)‖<ε := by + intro ε hε + have hε3 : 0<ε/3 := by positivity + let U : Set P := F ⁻¹' Metric.ball (F a₀) (ε/3) + have hU : U∈𝓝 a₀ := hF.continuousAt.preimage_mem_nhds + (Metric.ball_mem_nhds _ hε3) + filter_upwards [hsm U hU,(self_mem_nhdsWithin : Set.Ioi (0:ℝ)∈𝓝[>] 0)] with α hα ha + filter_upwards [hα,hbase α ha (ε/3) hε3] with N hN hb + intro j + have hb := hb j + have hp (z : κ) (hz : z∈T α N j) : + ‖F (a α N j z) (p α N j z)-F a₀ (p α N j z)‖≤ε/3 := by + apply (ContinuousMap.norm_coe_le_norm (F (a α N j z)-F a₀) (p α N j z)).trans + exact le_of_lt (by simpa only [U,Set.mem_preimage,Metric.mem_ball,dist_eq_norm] using hN j z hz) + have hm : ‖𝔼 z∈T α N j,(F (a α N j z) (p α N j z)-F a₀ (p α N j z))‖≤ε/3 := by + by_cases hn : (T α N j).Nonempty + · exact (RCLike.norm_expect_le (K := ℂ)).trans (Finset.expect_le hn hp) + · simp only [Finset.not_nonempty_iff_eq_empty.mp hn,Finset.expect_empty,norm_zero] + positivity + rw [Finset.expect_sub_distrib] at hm + change ‖(𝔼 z∈T α N j,F a₀ (p α N j z))-(∫ x,F a₀ x ∂μ)‖<ε/3 at hb + calc + _ = ‖((𝔼 z∈T α N j,F (a α N j z) (p α N j z))-(𝔼 z∈T α N j,F a₀ (p α N j z)))+ + ((𝔼 z∈T α N j,F a₀ (p α N j z))-(∫ x,F a₀ x ∂μ))‖ := by congr 1; ring + _ ≤ _ := norm_add_le _ _ + _ < ε := by linarith only [hm,hb,hε] + +end CompactTwoScale + +namespace AllLevelFactorization.Factorization +open AllLevelDomains AllLevelStates RationalLattice CubeFaces MalcevCharacters +variable {G : Type} [Group G] [TopologicalSpace G] [IsTopologicalGroup G] +variable {n s : ℕ} {c : RealCoordinates G n} {Γ : Subgroup G} +variable {K : Filtration G} {P : ℕ → ℤ → G} {L : ℕ → ℝ} +variable (F : Factorization c Γ s K P L) + + theorem smooth_neighborhood_uniform {κ τ : Type*} [Fintype τ] + (hL : ∀ N,0 < L N) (ht : Tendsto L atTop atTop) + (β : ℝ) (J : ℝ → ℕ → Type*) + (T : ∀ α N,J α N → Finset κ) (t : ∀ α N,J α N → κ → τ → ℝ) (C : ℝ) + (hpos : ∀ α : ℝ,0 < α → ∀ᶠ N : ℕ in atTop,∀ j : J α N,∀ z∈T α N j,∀ w, + dist (t α N j z w) β ≤ C*α) : + ∀ U∈𝓝 (fun _ : τ=>F.smoothLimit β),∀ᶠ α : ℝ in 𝓝[>] 0, + ∀ᶠ N : ℕ in atTop,∀ j : J α N,∀ z∈T α N j, + (fun w=>F.smoothPart N (L (F.state.subseq N)*t α N j z w))∈U := by + let f : (τ → Fin n → ℝ) → (τ → G) := fun u w=>c.coord.symm (u w) + have hf : Continuous f := continuous_pi fun w=>c.coord.symm.continuous.comp (continuous_apply w) + intro U hU + have hpre : f ⁻¹' U∈𝓝 (fun _ : τ=>c.coord (F.smoothLimit β)) := by + apply hf.continuousAt.preimage_mem_nhds + simpa [f] using hU + have hc : ContinuousAt (fun t=>c.coord (F.smoothLimit t)) β := + (c.coord.continuous.comp F.smoothLimit_continuous).continuousAt + have hh (ε : ℝ) (hε : 0 < ε) : ∀ᶠ N : ℕ in atTop,∀ t : ℝ,dist t β < 1 → + dist (c.coord (F.smoothPart N (L (F.state.subseq N)*t))) + (c.coord (F.smoothLimit t)) < ε := by + filter_upwards [F.smooth_coord_uniform hL ht (Set.Icc (β-1) (β+1)) isCompact_Icc ε hε] with N hN + intro t ht + apply hN t + rw [Real.dist_eq,abs_lt] at ht + exact ⟨by linarith [ht.1],by linarith [ht.2]⟩ + have hv:=CubeLocalHaar.smooth_local_freezing_uniform + (fun N t=>c.coord (F.smoothPart N (L (F.state.subseq N)*t))) + (fun t=>c.coord (F.smoothLimit t)) β hc 1 zero_lt_one hh J T t C hpos + (f ⁻¹' U) hpre + simpa only [Set.mem_preimage,f,Homeomorph.symm_apply_apply] using hv + +end AllLevelFactorization.Factorization +namespace AllLevelFactorization.Factorization.ResidueCover +open RationalLattice CubeFaces CubeTaylorExpansion ComparableBoxLeibman CubeLocalHaar +variable {G ι : Type} [Group G] [TopologicalSpace G] [IsTopologicalGroup G] +variable [Fintype ι] [DecidableEq ι] +variable {n s : ℕ} {c : RealCoordinates G n} {Γ : Subgroup G} +variable {K : Filtration G} {P : ℕ → ℤ → G} {L : ℕ → ℝ} +variable {F : Factorization c Γ s K P L} {r : Fin F.period} (C : F.ResidueCover r) + +variable [MeasurableSpace (C.CubeSpace (ι:=ι))] [BorelSpace (C.CubeSpace (ι:=ι))] +theorem two_scale_uniform (hL : ∀ N,0 < L N) (ht : Tendsto L atTop atTop) + {v : ℕ} (e : Option ι ≃ Fin v) (d : ℕ) (hd : 0 < d) (a : Fin v → ℤ) + (J : ℝ → ℕ → Type*) (lo hi : ∀ α N,J α N → Fin v → ℝ) + (hb : ∀ α : ℝ,0 < α → ∃ c₀ C₀ : ℝ,0 < c₀ ∧ 0 < C₀ ∧ ∀ᶠ N : ℕ in atTop,∀ j : J α N, + (∀ i,c₀*L (F.state.subseq N) ≤ hi α N j i-lo α N j i) ∧ + (∀ i,-C₀*L (F.state.subseq N) ≤ lo α N j i ∧ hi α N j i ≤ C₀*L (F.state.subseq N))) + (u : ∀ α N,J α N → (Fin v → ℤ) → Finset ι → G) (u₀ : Finset ι → G) + (hu : ∀ U∈𝓝 u₀,∀ᶠ α : ℝ in 𝓝[>] 0,∀ᶠ N : ℕ in atTop, + ∀ j : J α N,∀ z∈integerBox v (lo α N j) (hi α N j),u α N j z∈U) + (f : C((Finset ι → G⧸Γ),ℂ)) : + ∀ ε : ℝ,0 < ε → ∀ᶠ α : ℝ in 𝓝[>] 0,∀ᶠ N : ℕ in atTop,∀ j : J α N, + ‖(𝔼 z∈integerBox v (lo α N j) (hi α N j), + f (EmbeddedCubeHaar.haarImage F.state.domain.embed F.state.domain.filtration Γ + (F.residue r) C.lattice C.le_induced (u α N j z) + (C.cubePoint N (fun i=>a (e i)+(d:ℤ)*z (e i)))))- + (∫ x,EmbeddedCubeHaar.frozenTest F.state.domain.embed F.state.domain.continuous + F.state.domain.filtration Γ (F.residue r) C.lattice C.le_induced f u₀ x + ∂(C.haar (ι:=ι) : Measure (C.CubeSpace (ι:=ι))))‖ < ε := by + apply CompactTwoScale.freezing_uniform (C.haar (ι:=ι) : Measure (C.CubeSpace (ι:=ι))) + (EmbeddedCubeHaar.frozenTest F.state.domain.embed F.state.domain.continuous + F.state.domain.filtration Γ (F.residue r) C.lattice C.le_induced f) + (EmbeddedCubeHaar.frozenTest_continuous F.state.domain.embed F.state.domain.continuous + F.state.domain.filtration Γ (F.residue r) C.lattice C.le_induced f) + u₀ J (fun α N j=>integerBox v (lo α N j) (hi α N j)) + (fun _ N _ z=>C.cubePoint N (fun i=>a (e i)+(d:ℤ)*z (e i))) u ?_ hu + intro α hα ε hε + obtain ⟨c₀,C₀,hc₀,hC₀,hbox⟩:=hb α hα + let f₀:=EmbeddedCubeHaar.frozenTest F.state.domain.embed F.state.domain.continuous + F.state.domain.filtration Γ (F.residue r) C.lattice C.le_induced f u₀ + filter_upwards [C.haar_limit hL ht e c₀ C₀ hc₀ hC₀ d hd a {f₀} isCompact_singleton ε hε, + hbox] with N hN hbN + intro j + exact hN (lo α N j) (hi α N j) (hbN j).1 (hbN j).2 f₀ rfl + +theorem local_integerBox_uniform (hL : ∀ N,0 < L N) (ht : Tendsto L atTop atTop) + {v : ℕ} (e : Option ι ≃ Fin v) (d : ℕ) (hd : 0 < d) (a : Fin v → ℤ) + (hdp : F.period∣d) (ha0 : a (e none)%(F.period:ℤ)=(r.val:ℤ)) + (hai : ∀ i,a (e (some i))%(F.period:ℤ)=0) + (J : ℝ → ℕ → Type*) (lo hi : ∀ α N,J α N → Fin v → ℝ) + (hb : ∀ α : ℝ,0 < α → ∃ c₀ C₀ : ℝ,0 < c₀ ∧ 0 < C₀ ∧ ∀ᶠ N : ℕ in atTop,∀ j : J α N, + (∀ i,c₀*L (F.state.subseq N) ≤ hi α N j i-lo α N j i) ∧ + (∀ i,-C₀*L (F.state.subseq N) ≤ lo α N j i ∧ hi α N j i ≤ C₀*L (F.state.subseq N))) + (β B : ℝ) + (hgeo : ∀ α : ℝ,0 < α → ∀ᶠ N : ℕ in atTop, + ∀ j : J α N,∀ z∈integerBox v (lo α N j) (hi α N j),∀ w : Finset ι, + dist ((vertex (fun i=>a (e i)+(d:ℤ)*z (e i)) w:ℝ)/L (F.state.subseq N)) β ≤ B*α) + (f : C((Finset ι → G⧸Γ),ℂ)) : + ∀ ε : ℝ,0 < ε → ∀ᶠ α : ℝ in 𝓝[>] 0,∀ᶠ N : ℕ in atTop,∀ j : J α N, + ‖(𝔼 z∈integerBox v (lo α N j) (hi α N j), + f (fun w=>QuotientGroup.mk (P (F.state.subseq N) + (vertex (fun i=>a (e i)+(d:ℤ)*z (e i)) w))))-C.limitIntegral f β‖ < ε := by + let T : ∀ α N,J α N → Finset (Fin v → ℤ):=fun α N j=>integerBox v (lo α N j) (hi α N j) + let b : (Fin v → ℤ) → Option ι → ℤ:=fun z i=>a (e i)+(d:ℤ)*z (e i) + let t : ∀ α N,J α N → (Fin v → ℤ) → Finset ι → ℝ:= + fun _ N _ z w=>(vertex (b z) w:ℝ)/L (F.state.subseq N) + have hu:=F.smooth_neighborhood_uniform hL ht β J T t B hgeo + have hm (N : ℕ) (z : Fin v → ℤ) (w : Finset ι) : + L (F.state.subseq N)*((vertex (b z) w:ℝ)/L (F.state.subseq N))=(vertex (b z) w:ℝ) := by + field_simp [ne_of_gt (hL (F.state.subseq N))] + simp only [t,hm] at hu + have he:=C.two_scale_uniform hL ht e d hd a J lo hi hb + (fun _ N _ z w=>F.smoothPart N (vertex (b z) w)) (fun _=>F.smoothLimit β) hu f + have himage (N : ℕ) (z : Fin v → ℤ) : + EmbeddedCubeHaar.haarImage F.state.domain.embed F.state.domain.filtration Γ + (F.residue r) C.lattice C.le_induced + (fun w=>F.smoothPart N (vertex (b z) w)) (C.cubePoint N (b z))= + fun w : Finset ι=>QuotientGroup.mk (P (F.state.subseq N) (vertex (b z) w)) := + (C.cube_realization N (b z) (fun w=>F.affine_vertex_mod e d a hdp r ha0 hai z w)).symm + change ∀ ε : ℝ,0 < ε → ∀ᶠ α : ℝ in 𝓝[>] 0,∀ᶠ N : ℕ in atTop,∀ j : J α N, + ‖(𝔼 z∈integerBox v (lo α N j) (hi α N j),f (EmbeddedCubeHaar.haarImage + F.state.domain.embed F.state.domain.filtration Γ (F.residue r) C.lattice C.le_induced + (fun w=>F.smoothPart N (vertex (b z) w)) (C.cubePoint N (b z))))-C.limitIntegral f β‖ < ε at he + simpa only [himage,b] using he + +end AllLevelFactorization.Factorization.ResidueCover + +end +end + +end OAI diff --git a/lean/OAI/Combinatorics/SumProduct/Alignment/AllLevel08.lean b/lean/OAI/Combinatorics/SumProduct/Alignment/AllLevel08.lean new file mode 100644 index 0000000000000000000000000000000000000000..c5f17b3e530fd4818589fdfafff9d893d98c6658 --- /dev/null +++ b/lean/OAI/Combinatorics/SumProduct/Alignment/AllLevel08.lean @@ -0,0 +1,296 @@ +import Mathlib +import OAI.Combinatorics.SumProduct.Alignment.AllLevel07 +import OAI.Geometry.NilpotentCharts.Main + +namespace OAI + +open scoped BigOperators +section +noncomputable section +open scoped BigOperators Topology +open Filter MeasureTheory +end + +end + +section + + + + +noncomputable section +open scoped BigOperators Topology +open Filter +namespace ComparableBoxLeibman + +lemma halfOpen_bounds_scaled_uniform {v : ℕ} (L : ℕ → ℝ) (hL : Tendsto L atTop atTop) + (c C : ℝ) (hc : 0 < c) (J : ℕ → Type*) (lo hi : ∀ N,J N → Fin v → ℝ) + (hb : ∀ᶠ N : ℕ in atTop,∀ j : J N, + (∀ i,c*L N ≤ hi N j i-lo N j i) ∧ + (∀ i,-C*L N ≤ lo N j i ∧ hi N j i ≤ C*L N)) : + ∀ᶠ N : ℕ in atTop,∀ j : J N, + (∀ i,(c/2)*L N ≤ ((⌈hi N j i⌉:ℝ)-1)-lo N j i) ∧ + (∀ i,-C*L N ≤ lo N j i ∧ ((⌈hi N j i⌉:ℝ)-1) ≤ C*L N) := by + filter_upwards [hb,hL.eventually (eventually_ge_atTop (2/c))] with N hN hn + have hn' : 2 ≤ c*L N := by + have := (div_le_iff₀ hc).mp hn + nlinarith + intro j + have hN:=hN j + constructor + · intro i + have hceil:=Int.le_ceil (hi N j i) + linarith [hN.1 i] + · intro i + constructor + · exact (hN.2 i).1 + · have hceil:=Int.ceil_lt_add_one (hi N j i) + linarith [(hN.2 i).2] + +lemma affine_bounds_scaled_uniform {v : ℕ} (L : ℕ → ℝ) (hL : Tendsto L atTop atTop) + (c C : ℝ) (hc : 0 < c) (hC : 0 < C) (d : ℕ) (hd : 0 < d) + (r : Fin v → ℤ) (J : ℕ → Type*) (lo hi : ∀ N,J N → Fin v → ℝ) + (hb : ∀ᶠ N : ℕ in atTop,∀ j : J N, + (∀ i,c*L N ≤ hi N j i-lo N j i) ∧ + (∀ i,-C*L N ≤ lo N j i ∧ hi N j i ≤ C*L N)) : + ∃ c' C' : ℝ,0 < c' ∧ 0 < C' ∧ ∀ᶠ N : ℕ in atTop,∀ j : J N, + (∀ i,c'*L N ≤ (hi N j i-(r i:ℝ))/(d:ℝ)-(lo N j i-(r i:ℝ))/(d:ℝ)) ∧ + (∀ i,-C'*L N ≤ (lo N j i-(r i:ℝ))/(d:ℝ) ∧ + (hi N j i-(r i:ℝ))/(d:ℝ) ≤ C'*L N) := by + have hdR : 0 < (d:ℝ):=by exact_mod_cast hd + let M : ℝ:=1+∑ i : Fin v,|(r i:ℝ)| + have hM : 0 < M:=by dsimp [M]; positivity + have hr (i : Fin v) : |(r i:ℝ)| ≤ M := by + have hh : |(r i:ℝ)| ≤ ∑ j : Fin v,|(r j:ℝ)|:= + Finset.single_le_sum (f:=fun j : Fin v=>|(r j:ℝ)|) (fun j _=>abs_nonneg _) (Finset.mem_univ i) + dsimp [M] + linarith + refine ⟨c/d,(C+M)/d,div_pos hc hdR,div_pos (add_pos hC hM) hdR,?_⟩ + filter_upwards [hb,hL.eventually (eventually_ge_atTop 1)] with N hN hl + intro j + have hN:=hN j + constructor + · intro i + rw [←sub_div] + have he : (c/(d:ℝ))*L N=(c*L N)/(d:ℝ):=by ring + rw [he] + apply div_le_div_of_nonneg_right _ hdR.le + linarith [hN.1 i] + · intro i + have hri:=abs_le.mp (hr i) + have hML : M ≤ M*L N:=by nlinarith + constructor + · apply (le_div_iff₀ hdR).mpr + have he : (-((C+M)/(d:ℝ))*L N)*(d:ℝ)=-(C+M)*L N:=by field_simp + rw [he] + nlinarith [hri.2,(hN.2 i).1] + · apply (div_le_iff₀ hdR).mpr + have he : ((C+M)/(d:ℝ)*L N)*(d:ℝ)=(C+M)*L N:=by field_simp + rw [he] + nlinarith [hri.1,(hN.2 i).2] + +end ComparableBoxLeibman +end + +end + +section + + + + +noncomputable section +open scoped BigOperators Topology NNReal +open Filter MeasureTheory +namespace AllLevelFactorization.Factorization.ResidueCover +open RationalLattice CubeFaces CubeTaylorExpansion ComparableBoxLeibman CubeLocalHaar +variable {G ι : Type} [Group G] [TopologicalSpace G] [IsTopologicalGroup G] +variable [Fintype ι] [DecidableEq ι] +variable {n s : ℕ} {c : RealCoordinates G n} {Γ : Subgroup G} +variable {K : Filtration G} {P : ℕ → ℤ → G} {L : ℕ → ℝ} +variable {F : Factorization c Γ s K P L} {r : Fin F.period} (C : F.ResidueCover r) +variable [MeasurableSpace (C.CubeSpace (ι:=ι))] [BorelSpace (C.CubeSpace (ι:=ι))] + +theorem local_halfOpen_uniform (hL : ∀ N,0 < L N) (ht : Tendsto L atTop atTop) + {v : ℕ} (e : Option ι ≃ Fin v) (d : ℕ) (hd : 0 < d) (a : Fin v → ℤ) + (hdp : F.period∣d) (ha0 : a (e none)%(F.period:ℤ)=(r.val:ℤ)) + (hai : ∀ i,a (e (some i))%(F.period:ℤ)=0) + (J : ℝ → ℕ → Type*) (lo hi : ∀ α N,J α N → Fin v → ℝ) + (hb : ∀ α : ℝ,0 < α → ∃ c₀ C₀ : ℝ,0 < c₀ ∧ 0 < C₀ ∧ ∀ᶠ N : ℕ in atTop, + ∀ j : J α N,(∀ i,c₀*L (F.state.subseq N) ≤ hi α N j i-lo α N j i) ∧ + (∀ i,-C₀*L (F.state.subseq N) ≤ lo α N j i ∧ hi α N j i ≤ C₀*L (F.state.subseq N))) + (β B : ℝ) + (hgeo : ∀ α : ℝ,0 < α → ∀ᶠ N : ℕ in atTop, + ∀ j : J α N,∀ z∈halfOpenBox v (lo α N j) (hi α N j),∀ w : Finset ι, + dist ((vertex (fun i=>a (e i)+(d:ℤ)*z (e i)) w:ℝ)/L (F.state.subseq N)) β ≤ B*α) + (f : C((Finset ι → G⧸Γ),ℂ)) : + ∀ ε : ℝ,0 < ε → ∀ᶠ α : ℝ in 𝓝[>] 0,∀ᶠ N : ℕ in atTop,∀ j : J α N, + ‖(𝔼 z∈halfOpenBox v (lo α N j) (hi α N j), + f (fun w=>QuotientGroup.mk (P (F.state.subseq N) + (vertex (fun i=>a (e i)+(d:ℤ)*z (e i)) w))))-C.limitIntegral f β‖ < ε := by + apply C.local_integerBox_uniform hL ht e d hd a hdp ha0 hai J lo + (fun α N j i=>(⌈hi α N j i⌉:ℝ)-1) ?_ β B hgeo f + intro α hα + obtain ⟨c₀,C₀,hc₀,hC₀,hb⟩:=hb α hα + exact ⟨c₀/2,C₀,by positivity,hC₀,halfOpen_bounds_scaled_uniform + (L∘F.state.subseq) (ht.comp F.state.strictmono.tendsto_atTop) c₀ C₀ hc₀ (J α) + (lo α) (hi α) hb⟩ + +theorem local_physical_uniform (hL : ∀ N,0 < L N) (ht : Tendsto L atTop atTop) + {v : ℕ} (e : Option ι ≃ Fin v) (d : ℕ) (hd : 0 < d) (a : Fin v → ℤ) + (ha : ∀ i,0 ≤ a i ∧ a i < (d:ℤ)) + (hdp : F.period∣d) (ha0 : a (e none)%(F.period:ℤ)=(r.val:ℤ)) + (hai : ∀ i,a (e (some i))%(F.period:ℤ)=0) + (J : ℝ → ℕ → Type*) (lo hi : ∀ α N,J α N → Fin v → ℝ) + (hb : ∀ α : ℝ,0 < α → ∃ c₀ C₀ : ℝ,0 < c₀ ∧ 0 < C₀ ∧ ∀ᶠ N : ℕ in atTop, + ∀ j : J α N,(∀ i,c₀*L (F.state.subseq N) ≤ hi α N j i-lo α N j i) ∧ + (∀ i,-C₀*L (F.state.subseq N) ≤ lo α N j i ∧ hi α N j i ≤ C₀*L (F.state.subseq N))) + (β B : ℝ) + (hgeo : ∀ α : ℝ,0 < α → ∀ᶠ N : ℕ in atTop, + ∀ j : J α N,∀ b∈physicalResidueRectangle (lo α N j) (hi α N j) a d,∀ w : Finset ι, + dist ((vertex (fun i=>b (e i)) w:ℝ)/L (F.state.subseq N)) β ≤ B*α) + (f : C((Finset ι → G⧸Γ),ℂ)) : + ∀ ε : ℝ,0 < ε → ∀ᶠ α : ℝ in 𝓝[>] 0,∀ᶠ N : ℕ in atTop,∀ j : J α N, + ‖(𝔼 b∈physicalResidueRectangle (lo α N j) (hi α N j) a d, + f (fun w=>QuotientGroup.mk (P (F.state.subseq N) (vertex (fun i=>b (e i)) w))))- + C.limitIntegral f β‖ < ε := by + let lo' : ∀ α N,J α N → Fin v → ℝ:=fun α N j i=>(lo α N j i-(a i:ℝ))/(d:ℝ) + let hi' : ∀ α N,J α N → Fin v → ℝ:=fun α N j i=>(hi α N j i-(a i:ℝ))/(d:ℝ) + have hb' : ∀ α : ℝ,0 < α → ∃ c₀ C₀ : ℝ,0 < c₀ ∧ 0 < C₀ ∧ ∀ᶠ N : ℕ in atTop, + ∀ j : J α N,(∀ i,c₀*L (F.state.subseq N) ≤ hi' α N j i-lo' α N j i) ∧ + (∀ i,-C₀*L (F.state.subseq N) ≤ lo' α N j i ∧ hi' α N j i ≤ C₀*L (F.state.subseq N)) := by + intro α hα + obtain ⟨c₀,C₀,hc₀,hC₀,hb⟩:=hb α hα + exact affine_bounds_scaled_uniform (L∘F.state.subseq) + (ht.comp F.state.strictmono.tendsto_atTop) c₀ C₀ hc₀ hC₀ d hd a (J α) (lo α) (hi α) hb + have hg' : ∀ α : ℝ,0 < α → ∀ᶠ N : ℕ in atTop, + ∀ j : J α N,∀ z∈halfOpenBox v (lo' α N j) (hi' α N j),∀ w : Finset ι, + dist ((vertex (fun i=>a (e i)+(d:ℤ)*z (e i)) w:ℝ)/L (F.state.subseq N)) β ≤ B*α := by + intro α hα + filter_upwards [hgeo α hα] with N hN + intro j z hz + have hz' : (fun i=>a i+(d:ℤ)*z i)∈physicalResidueRectangle (lo α N j) (hi α N j) a d:= + (physicalResidueRectangle_affine (lo α N j) (hi α N j) a d hd ha z).mpr hz + exact hN j (fun i=>a i+(d:ℤ)*z i) hz' + have he:=C.local_halfOpen_uniform hL ht e d hd a hdp ha0 hai J lo' hi' hb' β B hg' f + intro ε hε + filter_upwards [he ε hε] with α hα + filter_upwards [hα] with N hN + intro j + rw [physicalResidueRectangle_expect _ _ a d hd ha] + exact hN j + +variable [CompactSpace (G⧸Γ)] [MeasurableSpace (G⧸Γ)] [BorelSpace (G⧸Γ)] [SecondCountableTopology (G⧸Γ)] + +def cubeHaar (β : ℝ) : ProbabilityMeasure (Finset ι → G⧸Γ) := + EmbeddedCubeHaar.imageProbability F.state.domain.embed + F.state.domain.filtration Γ (F.residue r) C.lattice C.le_induced C.haar + (fun _=>F.smoothLimit β) + +omit [CompactSpace (G⧸Γ)] in +lemma integral_cubeHaar (β : ℝ) (f : C((Finset ι → G⧸Γ),ℂ)) : + (∫ x,f x ∂(C.cubeHaar (ι:=ι) β : Measure (Finset ι → G⧸Γ)))=C.limitIntegral f β := + EmbeddedCubeHaar.integral_imageProbability F.state.domain.embed F.state.domain.continuous + F.state.domain.filtration Γ (F.residue r) C.lattice C.le_induced C.haar + (fun _=>F.smoothLimit β) f + +omit [CompactSpace (G⧸Γ)] in +theorem local_physical_compact (hΓ : ∀ x : G,x∈Γ ↔ ∀ i,∃ z : ℤ,c.coord x i=z) + (hL : ∀ N,0 < L N) (ht : Tendsto L atTop atTop) + {v : ℕ} (e : Option ι ≃ Fin v) (d : ℕ) (hd : 0 < d) (a : Fin v → ℤ) + (ha : ∀ i,0 ≤ a i ∧ a i < (d:ℤ)) + (hdp : F.period∣d) (ha0 : a (e none)%(F.period:ℤ)=(r.val:ℤ)) + (hai : ∀ i,a (e (some i))%(F.period:ℤ)=0) + (J : ℝ → ℕ → Type*) (lo hi : ∀ α N,J α N → Fin v → ℝ) + (hb : ∀ α : ℝ,0 < α → ∃ c₀ C₀ : ℝ,0 < c₀ ∧ 0 < C₀ ∧ ∀ᶠ N : ℕ in atTop, + ∀ j : J α N,(∀ i,c₀*L (F.state.subseq N) ≤ hi α N j i-lo α N j i) ∧ + (∀ i,-C₀*L (F.state.subseq N) ≤ lo α N j i ∧ hi α N j i ≤ C₀*L (F.state.subseq N))) + (β B : ℝ) + (hgeo : ∀ α : ℝ,0 < α → ∀ᶠ N : ℕ in atTop, + ∀ j : J α N,∀ b∈physicalResidueRectangle (lo α N j) (hi α N j) a d,∀ w : Finset ι, + dist ((vertex (fun i=>b (e i)) w:ℝ)/L (F.state.subseq N)) β ≤ B*α) + (T : Set C((Finset ι → G⧸Γ),ℂ)) (hT : IsCompact T) : + ∀ ε : ℝ,0 < ε → ∀ᶠ α : ℝ in 𝓝[>] 0,∀ᶠ N : ℕ in atTop,∀ j : J α N, + ∀ f∈T,‖(𝔼 b∈physicalResidueRectangle (lo α N j) (hi α N j) a d, + f (fun w=>QuotientGroup.mk (P (F.state.subseq N) (vertex (fun i=>b (e i)) w))))- + (∫ x,f x ∂(C.cubeHaar (ι:=ι) β : Measure (Finset ι → G⧸Γ)))‖ < ε := by + let : MetricSpace (G⧸Γ):=coordinateQuotientMetric c Γ hΓ + let : CompactSpace (G⧸Γ):=AbelianMalcevTorus.quotient_compact c Γ hΓ + apply FiniteHaarTests.compact_two_scale_uniform (C.cubeHaar (ι:=ι) β : Measure (Finset ι → G⧸Γ)) + J (fun α N j=>physicalResidueRectangle (lo α N j) (hi α N j) a d) + (fun _ N _ b w=>QuotientGroup.mk (P (F.state.subseq N) (vertex (fun i=>b (e i)) w))) ?_ T hT + intro f + change ∀ ε : ℝ,0 < ε → ∀ᶠ α : ℝ in 𝓝[>] 0,∀ᶠ N : ℕ in atTop,∀ j : J α N, + ‖(𝔼 b∈physicalResidueRectangle (lo α N j) (hi α N j) a d, + f (fun w=>QuotientGroup.mk (P (F.state.subseq N) (vertex (fun i=>b (e i)) w))))- + (∫ x,f x ∂(C.cubeHaar (ι:=ι) β : Measure (Finset ι → G⧸Γ)))‖ < ε + rw [C.integral_cubeHaar] + exact C.local_physical_uniform hL ht e d hd a ha hdp ha0 hai J lo hi hb β B hgeo f + + + +theorem source_physical_cube_law + (hΓ : ∀ x : G,x∈Γ ↔ ∀ i,∃ z : ℤ,c.coord x i=z) + (hL : ∀ N,0 < L N) (ht : Tendsto L atTop atTop) + {v : ℕ} (e : Option ι ≃ Fin v) (d : ℕ) (hd : 0 < d) (a : Fin v → ℤ) + (ha : ∀ i,0 ≤ a i ∧ a i < (d:ℤ)) + (hdp : F.period∣d) (ha0 : a (e none)%(F.period:ℤ)=(r.val:ℤ)) + (hai : ∀ i,a (e (some i))%(F.period:ℤ)=0) + (β cBox CBox B : ℝ) (hcBox : 0 < cBox) (hCBox : 0 < CBox) (hB : 0 ≤ B) + (mtr : MetricSpace (G⧸Γ)) + (hmtr : mtr.toUniformSpace.toTopologicalSpace=QuotientGroup.instTopologicalSpace Γ) + (Lip : ℝ≥0) (Sup : ℝ) : + letI : MetricSpace (G⧸Γ):=MetricSpace.replaceTopology mtr hmtr.symm + ∀ ε : ℝ,0 < ε → ∀ᶠ α : ℝ in 𝓝[>] 0,∀ᶠ N : ℕ in atTop, + ∀ lo hi : Fin v → ℝ, + (∀ i,(cBox*α)*L (F.state.subseq N) ≤ hi i-lo i) → + (∀ i,-CBox*L (F.state.subseq N) ≤ lo i ∧ hi i ≤ CBox*L (F.state.subseq N)) → + (∀ b∈physicalResidueRectangle lo hi a d, + |((b (e none):ℝ)/L (F.state.subseq N))-β| ≤ B*α ∧ + ∀ i : ι,|(b (e (some i)):ℝ)/L (F.state.subseq N)| ≤ B*α) → + ∀ f : C((Finset ι → G⧸Γ),ℂ),LipschitzWith Lip f → ‖f‖ ≤ Sup → + ‖(𝔼 b∈physicalResidueRectangle lo hi a d, + f (fun w=>QuotientGroup.mk (P (F.state.subseq N) (vertex (fun i=>b (e i)) w))))- + (∫ x,f x ∂(C.cubeHaar (ι:=ι) β : Measure (Finset ι → G⧸Γ)))‖ < ε := by + let : MetricSpace (G⧸Γ):=MetricSpace.replaceTopology mtr hmtr.symm + let : CompactSpace (G⧸Γ):=AbelianMalcevTorus.quotient_compact c Γ hΓ + let J : ℝ → ℕ → Type:=fun α N=>{p : (Fin v → ℝ)×(Fin v → ℝ) // + (∀ i,(cBox*α)*L (F.state.subseq N) ≤ p.2 i-p.1 i) ∧ + (∀ i,-CBox*L (F.state.subseq N) ≤ p.1 i ∧ p.2 i ≤ CBox*L (F.state.subseq N)) ∧ + (∀ b∈physicalResidueRectangle p.1 p.2 a d, + |((b (e none):ℝ)/L (F.state.subseq N))-β| ≤ B*α ∧ + ∀ i : ι,|(b (e (some i)):ℝ)/L (F.state.subseq N)| ≤ B*α)} + let lo : ∀ α N,J α N → Fin v → ℝ:=fun _ _ j=>j.val.1 + let hi : ∀ α N,J α N → Fin v → ℝ:=fun _ _ j=>j.val.2 + have hb : ∀ α : ℝ,0 < α → ∃ c₀ C₀ : ℝ,0 < c₀ ∧ 0 < C₀ ∧ ∀ᶠ N : ℕ in atTop, + ∀ j : J α N,(∀ i,c₀*L (F.state.subseq N) ≤ hi α N j i-lo α N j i) ∧ + (∀ i,-C₀*L (F.state.subseq N) ≤ lo α N j i ∧ hi α N j i ≤ C₀*L (F.state.subseq N)) := by + intro α hα + exact ⟨cBox*α,CBox,mul_pos hcBox hα,hCBox,Eventually.of_forall + (fun N j=>⟨j.property.1,j.property.2.1⟩)⟩ + have hgeo : ∀ α : ℝ,0 < α → ∀ᶠ N : ℕ in atTop, + ∀ j : J α N,∀ b∈physicalResidueRectangle (lo α N j) (hi α N j) a d,∀ w : Finset ι, + dist ((vertex (fun i=>b (e i)) w:ℝ)/L (F.state.subseq N)) β ≤ + ((1+(Fintype.card ι:ℝ))*B)*α := by + intro α hα + apply Eventually.of_forall + intro N j b hb w + have hg:=j.property.2.2 b hb + have hw:=normalized_vertex_close + (fun i=>(b (e i):ℝ)/L (F.state.subseq N)) β (B*α) (mul_nonneg hB hα.le) hg.1 hg.2 w + simpa only [vertex,Int.cast_add,Int.cast_sum,add_div,Finset.sum_div,mul_assoc] using hw + obtain ⟨T,hT,hcover⟩:=BoundedLipschitzCompact.compact_envelope (X:=Finset ι → G⧸Γ) Lip Sup + have hlocal:=C.local_physical_compact hΓ hL ht e d hd a ha hdp ha0 hai J lo hi hb β + ((1+(Fintype.card ι:ℝ))*B) hgeo T hT + intro ε hε + filter_upwards [hlocal ε hε] with α hα + filter_upwards [hα] with N hN + intro lo' hi' hs ho hg f hf hsup + exact hN ⟨(lo',hi'),hs,ho,hg⟩ f (hcover f hf hsup) + +end AllLevelFactorization.Factorization.ResidueCover + +end +end + +end OAI diff --git a/lean/OAI/Combinatorics/SumProduct/Alignment/AllLevel09.lean b/lean/OAI/Combinatorics/SumProduct/Alignment/AllLevel09.lean new file mode 100644 index 0000000000000000000000000000000000000000..d8670dde463b0bd79d626d19ff0e2b6ec01f63d4 --- /dev/null +++ b/lean/OAI/Combinatorics/SumProduct/Alignment/AllLevel09.lean @@ -0,0 +1,294 @@ +import Mathlib +import OAI.Combinatorics.SumProduct.Alignment.AllLevel08 +import OAI.Geometry.NilpotentCharts.Main + +namespace OAI + +open scoped BigOperators +section +noncomputable section +open scoped BigOperators Topology NNReal +open Filter MeasureTheory +end + +end + +section + + + + +noncomputable section +open MeasureTheory Filter Topology +open scoped BoundedContinuousFunction +namespace TwoScaleInvariance +variable {Y : Type} [TopologicalSpace Y] [MeasurableSpace Y] [BorelSpace Y] +variable [HasOuterApproxClosed Y] +variable (ν : ProbabilityMeasure Y) (S : C(Y,Y)) +variable (A : ℝ → ℕ → C(Y,ℝ) → ℝ) +variable (hloc : ∀ f : C(Y,ℝ),∀ δ : ℝ,0<δ → + ∀ᶠ α : ℝ in 𝓝[>] 0,∀ᶠ N : ℕ in atTop, + |A α N f-∫ y,f y ∂(ν : Measure Y)|<δ) +variable (hinv : ∀ α : ℝ,0<α → ∀ f : C(Y,ℝ), + Tendsto (fun N=>|A α N (f.comp S)-A α N f|) atTop (𝓝 0)) + +include hloc hinv in +omit [BorelSpace Y] [HasOuterApproxClosed Y] in +lemma integral_eq (f : C(Y,ℝ)) : + (∫ y,f (S y) ∂(ν : Measure Y))=∫ y,f y ∂(ν : Measure Y) := by + let u : ℝ:=∫ y,f (S y) ∂(ν : Measure Y) + let v : ℝ:=∫ y,f y ∂(ν : Measure Y) + change u=v + apply sub_eq_zero.mp + apply abs_eq_zero.mp + apply le_antisymm _ (abs_nonneg _) + apply le_of_forall_pos_le_add + intro δ hδ + have hδ3 : 0<δ/3 := by positivity + have he : ∀ᶠ α : ℝ in 𝓝[>] 0,0<α ∧ + (∀ᶠ N : ℕ in atTop,|A α N f-v|<δ/3) ∧ + (∀ᶠ N : ℕ in atTop,|A α N (f.comp S)-u|<δ/3) := by + filter_upwards [self_mem_nhdsWithin,hloc f (δ/3) hδ3, + hloc (f.comp S) (δ/3) hδ3] with α hα h1 h2 + exact ⟨hα,h1,h2⟩ + obtain ⟨α,hα,h1,h2⟩:=he.exists + have hi:= (hinv α hα f).eventually (gt_mem_nhds hδ3) + obtain ⟨N,h1,h2,hi⟩:=(h1.and (h2.and hi)).exists + have htri:=abs_sub_le u (A α N (f.comp S)) v + have htri2:=abs_sub_le (A α N (f.comp S)) (A α N f) v + have hs : |u-A α N (f.comp S)|<δ/3 := by + simpa only [abs_sub_comm u (A α N (f.comp S))] using h2 + linarith + +include hloc hinv in + + +theorem map_eq : Measure.map S (ν : Measure Y)=(ν : Measure Y) := by + apply ext_of_forall_integral_eq_of_IsFiniteMeasure + intro f + rw [integral_map S.continuous.measurable.aemeasurable f.continuous.aestronglyMeasurable] + exact integral_eq ν S A hloc hinv f.toContinuousMap + +variable {X : Type} [TopologicalSpace X] [CompactSpace X] +variable [MeasurableSpace X] [BorelSpace X] [T2Space Y] +variable (μ : ProbabilityMeasure X) [(μ : Measure X).IsOpenPosMeasure] +variable (q : C(X,Y)) + + + +omit [HasOuterApproxClosed Y] in +theorem range_preservation + (hinv : Measure.map S (Measure.map q (μ : Measure X))=Measure.map q (μ : Measure X)) : + ∀ x : X,∃ y : X,S (q x)=q y := by + intro x + have hc : IsClosed (Set.range q) := (isCompact_range q.continuous).isClosed + let U : Set Y:=(Set.range q)ᶜ + have hU : IsOpen U:=hc.isOpen_compl + have hz : (Measure.map q (μ : Measure X)) U=0 := by + rw [Measure.map_apply q.continuous.measurable hU.measurableSet] + have he : q ⁻¹' U=∅ := by ext z; simp [U] + rw [he,measure_empty] + have hz' : (μ : Measure X) ((S.comp q) ⁻¹' U)=0 := by + have he:=congrArg (fun m : Measure Y=>m U) hinv + rw [Measure.map_apply S.continuous.measurable hU.measurableSet, + Measure.map_apply q.continuous.measurable + (S.continuous.measurable hU.measurableSet),hz] at he + exact he + by_contra! hn + have hm : (S.comp q) ⁻¹' U ≠∅ := by + apply Set.nonempty_iff_ne_empty.mp + refine ⟨x,?_⟩ + change S (q x)∉Set.range q + simpa only [Set.mem_range,not_exists,eq_comm] using hn + exact ((hU.preimage (S.comp q).continuous).measure_ne_zero (μ : Measure X) + (Set.nonempty_iff_ne_empty.mpr hm)) hz' + +end TwoScaleInvariance +end + +end + +section + + + + +noncomputable section +open MeasureTheory Filter Topology +open scoped BigOperators NNReal +namespace AllLevelFactorization.Factorization.ResidueCover +open RationalLattice CubeFaces CubeTaylorExpansion ComparableBoxLeibman CubeLocalHaar +variable {G ι : Type} [Group G] [TopologicalSpace G] [IsTopologicalGroup G] +variable [Fintype ι] [DecidableEq ι] +variable {n s : ℕ} {c : RealCoordinates G n} {Γ : Subgroup G} +variable {K : Filtration G} {P : ℕ → ℤ → G} {L : ℕ → ℝ} +variable {F : Factorization c Γ s K P L} {r : Fin F.period} (C : F.ResidueCover r) +variable [MeasurableSpace (C.CubeSpace (ι:=ι))] [BorelSpace (C.CubeSpace (ι:=ι))] +variable [CompactSpace (G⧸Γ)] [MeasurableSpace (G⧸Γ)] [BorelSpace (G⧸Γ)] +variable [SecondCountableTopology (G⧸Γ)] +variable (hL : ∀ N,0b (e i)) w:ℝ)/L (F.state.subseq N)) β≤B*α) +variable {Y : Type} [TopologicalSpace Y] [MeasurableSpace Y] [BorelSpace Y] +variable [CompactSpace Y] [HasOuterApproxClosed Y] +variable (π : C((Finset ι → G⧸Γ),Y)) + +def marginalBoxAverage (α : ℝ) (N : ℕ) (f : C(Y,ℝ)) : ℝ := + 𝔼 b∈physicalResidueRectangle (lo α N) (hi α N) a d, + f (π (fun w=>QuotientGroup.mk (P (F.state.subseq N) (vertex (fun i=>b (e i)) w)))) + +def marginalCubeHaar : ProbabilityMeasure Y := + (C.cubeHaar (ι:=ι) β).map π + +include hL ht hd ha hdp ha0 hai hb hgeo in +omit [CompactSpace (G⧸Γ)] [CompactSpace Y] [HasOuterApproxClosed Y] in +lemma marginal_local_law (f : C(Y,ℝ)) : + ∀ ε : ℝ,0<ε → ∀ᶠ α : ℝ in 𝓝[>] 0,∀ᶠ N in atTop, + |marginalBoxAverage (F:=F) e d a lo hi π α N f- + ∫ y,f y ∂(marginalCubeHaar C β π : Measure Y)|<ε := by + let ff : C((Finset ι → G⧸Γ),ℂ):= + ⟨fun x=>(f (π x):ℂ),Complex.continuous_ofReal.comp (f.continuous.comp π.continuous)⟩ + have hbb : ∀ α : ℝ,0<α → ∃ c₀ C₀ : ℝ,0h)⟩ + have hgg : ∀ α : ℝ,0<α → ∀ᶠ N in atTop,∀ _ : Unit, + ∀ b∈physicalResidueRectangle (lo α N) (hi α N) a d,∀ w : Finset ι, + dist ((vertex (fun i=>b (e i)) w:ℝ)/L (F.state.subseq N)) β≤B*α := + fun α hα=>(hgeo α hα).mono (fun _ h _=>h) + have H:=C.local_physical_uniform hL ht e d hd a ha hdp ha0 hai + (fun _ _=>Unit) (fun α N _=>lo α N) (fun α N _=>hi α N) hbb β B hgg ff + intro ε hε + filter_upwards [H ε hε] with α hα + filter_upwards [hα] with N hN + have hh:=hN () + rw [←C.integral_cubeHaar β ff] at hh + have hexp : (𝔼 b∈physicalResidueRectangle (lo α N) (hi α N) a d, + ff (fun w=>QuotientGroup.mk (P (F.state.subseq N) (vertex (fun i=>b (e i)) w))))= + (marginalBoxAverage (F:=F) e d a lo hi π α N f:ℂ) := by + exact (map_expect (Complex.ofRealCLM.toLinearMap.restrictScalars ℚ≥0) _ _).symm + rw [hexp] at hh + have hint : (∫ x,ff x ∂(C.cubeHaar (ι:=ι) β : Measure _))= + ((∫ y,f y ∂(marginalCubeHaar C β π : Measure Y) : ℝ):ℂ) := by + change (∫ x,(f (π x):ℂ) ∂(C.cubeHaar (ι:=ι) β : Measure _))=_ + rw [integral_complex_ofReal] + congr 1 + exact (integral_map π.continuous.measurable.aemeasurable f.continuous.aestronglyMeasurable).symm + rw [hint,←Complex.ofReal_sub,Complex.norm_real,Real.norm_eq_abs] at hh + exact hh + +include hL ht hd ha hdp ha0 hai hb hgeo in + + +omit [CompactSpace (G⧸Γ)] [CompactSpace Y] in +theorem marginal_haar_invariant (S : C(Y,Y)) + (hinv : ∀ α : ℝ,0<α → ∀ f : C(Y,ℝ),Tendsto + (fun N=>|marginalBoxAverage (F:=F) e d a lo hi π α N (f.comp S)- + marginalBoxAverage (F:=F) e d a lo hi π α N f|) atTop (𝓝 0)) : + Measure.map S (marginalCubeHaar C β π : Measure Y)= + (marginalCubeHaar C β π : Measure Y) := + TwoScaleInvariance.map_eq (marginalCubeHaar C β π) S + (marginalBoxAverage (F:=F) e d a lo hi π) + (C.marginal_local_law hL ht e d hd a ha hdp ha0 hai lo hi hb β B hgeo π) hinv + +end AllLevelFactorization.Factorization.ResidueCover +end + +end + +section + + + + +noncomputable section +open MeasureTheory Topology +namespace AllLevelFactorization.Factorization.ResidueCover +open RationalLattice CubeFaces +variable {G ι : Type} [Group G] [TopologicalSpace G] [IsTopologicalGroup G] +variable [Fintype ι] [DecidableEq ι] +variable {n s : ℕ} {c : RealCoordinates G n} {Γ : Subgroup G} +variable {K : Filtration G} {P : ℕ → ℤ → G} {L : ℕ → ℝ} +variable {F : Factorization c Γ s K P L} {r : Fin F.period} (C : F.ResidueCover r) +variable [MeasurableSpace (C.CubeSpace (ι:=ι))] [BorelSpace (C.CubeSpace (ι:=ι))] + +instance haar_fullSupport : (C.haar (ι:=ι) : Measure (C.CubeSpace (ι:=ι))).IsOpenPosMeasure := by + constructor + intro U hU hne + exact ne_of_gt (measure_isOpen_pos_of_smulInvariant_of_compact_ne_zero + (CubeGroup (ι:=ι) (F:=F)) isCompact_univ (by simp) hU hne) + +variable [CompactSpace (G⧸Γ)] [MeasurableSpace (G⧸Γ)] [BorelSpace (G⧸Γ)] +variable [SecondCountableTopology (G⧸Γ)] + +def cubePhysical (β : ℝ) : C(C.CubeSpace (ι:=ι),(Finset ι → G⧸Γ)) := + ⟨EmbeddedCubeHaar.haarImage F.state.domain.embed F.state.domain.filtration Γ + (F.residue r) C.lattice C.le_induced (fun _=>F.smoothLimit β), + (EmbeddedCubeHaar.haarImage_continuous F.state.domain.embed F.state.domain.continuous + F.state.domain.filtration Γ (F.residue r) C.lattice C.le_induced).comp + (continuous_const.prodMk continuous_id)⟩ + +omit [MeasurableSpace (C.CubeSpace (ι:=ι))] [BorelSpace (C.CubeSpace (ι:=ι))] + [CompactSpace (G⧸Γ)] [MeasurableSpace (G⧸Γ)] [BorelSpace (G⧸Γ)] + [SecondCountableTopology (G⧸Γ)] in +@[simp] lemma cubePhysical_mk (β : ℝ) (f : CubeGroup (ι:=ι) (F:=F)) (w : Finset ι) : + C.cubePhysical β (QuotientGroup.mk f) w= + QuotientGroup.mk (F.smoothLimit β*F.state.domain.embed (f.val w)*F.residue r) := + by + change EmbeddedCubeHaar.haarImage F.state.domain.embed F.state.domain.filtration Γ + (F.residue r) C.lattice C.le_induced (fun _=>F.smoothLimit β) (QuotientGroup.mk f) w=_ + exact EmbeddedCubeHaar.haarImage_mk _ _ _ _ _ _ _ f w + +variable {Y : Type} [TopologicalSpace Y] [MeasurableSpace Y] [BorelSpace Y] [T2Space Y] [HasOuterApproxClosed Y] +variable (β : ℝ) (π : C((Finset ι → G⧸Γ),Y)) (S : C(Y,Y)) + + + +omit [CompactSpace (G⧸Γ)] [HasOuterApproxClosed Y] in +theorem physical_cube_image_preserved + (hinv : Measure.map S (C.marginalCubeHaar β π : Measure Y)= + (C.marginalCubeHaar β π : Measure Y)) + (f : CubeGroup (ι:=ι) (F:=F)) : + ∃ g : CubeGroup (ι:=ι) (F:=F), + S (π (fun w=>QuotientGroup.mk (F.smoothLimit β*F.state.domain.embed (f.val w)*F.residue r)))= + π (fun w=>QuotientGroup.mk (F.smoothLimit β*F.state.domain.embed (g.val w)*F.residue r)) := by + let q : C(C.CubeSpace (ι:=ι),Y):=π.comp (C.cubePhysical β) + have hm : (C.marginalCubeHaar β π : Measure Y)=Measure.map q (C.haar (ι:=ι) : Measure _) := by + rw [marginalCubeHaar,ProbabilityMeasure.toMeasure_map] + have hc : (C.cubeHaar (ι:=ι) β : Measure (Finset ι → G⧸Γ))= + Measure.map (C.cubePhysical β) (C.haar (ι:=ι) : Measure (C.CubeSpace (ι:=ι))) := by + rw [cubeHaar,EmbeddedCubeHaar.imageProbability,ProbabilityMeasure.toMeasure_map] + rfl + rw [hc] + exact Measure.map_map π.continuous.measurable (C.cubePhysical β).continuous.measurable + rw [hm] at hinv + obtain ⟨y,hy⟩:=TwoScaleInvariance.range_preservation S (C.haar (ι:=ι)) q hinv (QuotientGroup.mk f) + induction y using Quotient.inductionOn with | h g => + refine ⟨g,?_⟩ + have hq (g : CubeGroup (ι:=ι) (F:=F)) : q (QuotientGroup.mk g)= + π (fun w=>QuotientGroup.mk (F.smoothLimit β*F.state.domain.embed (g.val w)*F.residue r)) := by + change π (C.cubePhysical β (QuotientGroup.mk g))=_ + congr 1 + funext w + exact C.cubePhysical_mk β g w + change S (q (QuotientGroup.mk f))=q (QuotientGroup.mk g) at hy + simpa only [hq] using hy + +end AllLevelFactorization.Factorization.ResidueCover + +end +end + +end OAI diff --git a/lean/OAI/Combinatorics/SumProduct/Alignment/AllLevel10.lean b/lean/OAI/Combinatorics/SumProduct/Alignment/AllLevel10.lean new file mode 100644 index 0000000000000000000000000000000000000000..67d0ee1406a13ffc8d0c751a53329e97271e9455 --- /dev/null +++ b/lean/OAI/Combinatorics/SumProduct/Alignment/AllLevel10.lean @@ -0,0 +1,265 @@ +import Mathlib +import OAI.Combinatorics.SumProduct.Alignment.AllLevel06 +import OAI.Combinatorics.SumProduct.Alignment.GlobalPoint01 +import OAI.Geometry.NilpotentCharts.Main + +namespace OAI + +open scoped BigOperators +section +noncomputable section +open scoped BigOperators Topology +open Filter MeasureTheory +end + +section + + + + +noncomputable section +open scoped BigOperators Topology +open Filter +namespace ComparableBoxLeibman + +lemma halfOpen_bounds_scaled {v : ℕ} (L : ℕ → ℝ) (hL : Tendsto L atTop atTop) + (c C : ℝ) (hc : 0 < c) (lo hi : ℕ → Fin v → ℝ) + (hb : ∀ᶠ N : ℕ in atTop, + (∀ i,c*L N ≤ hi N i-lo N i) ∧ + (∀ i,-C*L N ≤ lo N i ∧ hi N i ≤ C*L N)) : + ∀ᶠ N : ℕ in atTop, + (∀ i,(c/2)*L N ≤ ((⌈hi N i⌉:ℝ)-1)-lo N i) ∧ + (∀ i,-C*L N ≤ lo N i ∧ ((⌈hi N i⌉:ℝ)-1) ≤ C*L N) := by + filter_upwards [hb,hL.eventually (eventually_ge_atTop (2/c))] with N hN hn + have hn' : 2 ≤ c*L N := by + have := (div_le_iff₀ hc).mp hn + nlinarith + constructor + · intro i + have hceil:=Int.le_ceil (hi N i) + linarith [hN.1 i] + · intro i + constructor + · exact (hN.2 i).1 + · have hceil:=Int.ceil_lt_add_one (hi N i) + linarith [(hN.2 i).2] + +lemma affine_bounds_scaled {v : ℕ} (L : ℕ → ℝ) (hL : Tendsto L atTop atTop) + (c C : ℝ) (hc : 0 < c) (hC : 0 < C) (d : ℕ) (hd : 0 < d) + (r : Fin v → ℤ) (lo hi : ℕ → Fin v → ℝ) + (hb : ∀ᶠ N : ℕ in atTop, + (∀ i,c*L N ≤ hi N i-lo N i) ∧ + (∀ i,-C*L N ≤ lo N i ∧ hi N i ≤ C*L N)) : + ∃ c' C' : ℝ,0 < c' ∧ 0 < C' ∧ ∀ᶠ N : ℕ in atTop, + (∀ i,c'*L N ≤ (hi N i-(r i:ℝ))/(d:ℝ)-(lo N i-(r i:ℝ))/(d:ℝ)) ∧ + (∀ i,-C'*L N ≤ (lo N i-(r i:ℝ))/(d:ℝ) ∧ + (hi N i-(r i:ℝ))/(d:ℝ) ≤ C'*L N) := by + have hdR : 0 < (d:ℝ):=by exact_mod_cast hd + let M : ℝ:=1+∑ i : Fin v,|(r i:ℝ)| + have hM : 0 < M:=by dsimp [M]; positivity + have hr (i : Fin v) : |(r i:ℝ)| ≤ M := by + have hh : |(r i:ℝ)| ≤ ∑ j : Fin v,|(r j:ℝ)|:= + Finset.single_le_sum (f:=fun j : Fin v=>|(r j:ℝ)|) (fun j _=>abs_nonneg _) (Finset.mem_univ i) + dsimp [M] + linarith + refine ⟨c/d,(C+M)/d,div_pos hc hdR,div_pos (add_pos hC hM) hdR,?_⟩ + filter_upwards [hb,hL.eventually (eventually_ge_atTop 1)] with N hN hl + constructor + · intro i + rw [←sub_div] + have he : (c/(d:ℝ))*L N=(c*L N)/(d:ℝ):=by ring + rw [he] + apply div_le_div_of_nonneg_right _ hdR.le + linarith [hN.1 i] + · intro i + have hri:=abs_le.mp (hr i) + have hML : M ≤ M*L N:=by nlinarith + constructor + · apply (le_div_iff₀ hdR).mpr + have he : (-((C+M)/(d:ℝ))*L N)*(d:ℝ)=-(C+M)*L N:=by field_simp + rw [he] + nlinarith [hri.2,(hN.2 i).1] + · apply (div_le_iff₀ hdR).mpr + have he : ((C+M)/(d:ℝ)*L N)*(d:ℝ)=(C+M)*L N:=by field_simp + rw [he] + nlinarith [hri.1,(hN.2 i).2] + +end ComparableBoxLeibman +end + +end + +section + + + + +noncomputable section +open scoped BigOperators Topology +open Filter +namespace GlobalPointLaw +open CubeLocalHaar ComparableBoxLeibman + +lemma cell_expect_rectangle {N d r : ℕ} (hN : 0 < N) {a b : ℝ} + (ha : 0 ≤ a) (hb : b ≤ 1) (f : ℤ → ℂ) : + (𝔼 k∈cell N d r a b,f (k.val:ℤ))= + (𝔼 z∈physicalResidueRectangle (fun _ : Fin 1=>a*(N:ℝ)) + (fun _=>b*(N:ℝ)) (fun _=>(r:ℤ)) d,f (z 0)) := by + have hNR : 0 < (N:ℝ):=by exact_mod_cast hN + apply Finset.expect_bij (fun k _ _=>(k.val:ℤ)) + · intro k hk + rw [physicalResidueRectangle_mem] + have hh:=mem_cell.mp hk + refine ⟨fun i=>?_,fun i=>?_⟩ + · constructor + · exact (le_div_iff₀ hNR).mp hh.1 + · exact (div_lt_iff₀ hNR).mp hh.2.1 + · exact_mod_cast hh.2.2 + · intro k hk + rfl + · intro k hk l hl he + exact Fin.ext (by exact_mod_cast congrFun he 0) + · intro z hz + have hz':=(physicalResidueRectangle_mem _ _ _ _ z).mp hz + have hz0 : 0 ≤ z 0 := by + have hh : (0:ℝ) ≤ (z 0:ℝ):=le_trans (mul_nonneg ha hNR.le) (hz'.1 0).1 + exact_mod_cast hh + have hzN : z 0 < (N:ℤ) := by + have hh : (z 0:ℝ) < N := + (hz'.1 0).2.trans_le (by nlinarith) + exact_mod_cast hh + let k : Fin N:=⟨(z 0).toNat,by omega⟩ + have hkz : (k.val:ℤ)=z 0:=Int.toNat_of_nonneg hz0 + have he : (fun _ : Fin 1=>(k.val:ℤ))=z := by + funext i + simpa only [Subsingleton.elim i 0] using hkz + refine ⟨k,?_,he⟩ + rw [mem_cell] + have hkR : (k.val:ℝ)=(z 0:ℝ):=by exact_mod_cast hkz + refine ⟨(le_div_iff₀ hNR).mpr ?_,(div_lt_iff₀ hNR).mpr ?_,?_⟩ + · simpa only [hkR] using (hz'.1 0).1 + · simpa only [hkR] using (hz'.1 0).2 + · have hh:=hz'.2 0 + rw [←hkz] at hh + exact_mod_cast hh + +lemma cell_expect_progression {N d : ℕ} (hN : 0 < N) (hd : 0 < d) + (r : Fin d) {a b : ℝ} (ha : 0 ≤ a) (hb : b ≤ 1) (f : ℤ → ℂ) : + (𝔼 k∈cell N d r.val a b,f (k.val:ℤ))= + (𝔼 z∈halfOpenBox 1 (fun _ : Fin 1=>(a*(N:ℝ)-(r.val:ℝ))/(d:ℝ)) + (fun _=>(b*(N:ℝ)-(r.val:ℝ))/(d:ℝ)),f ((r.val:ℤ)+(d:ℤ)*z 0)) := by + rw [cell_expect_rectangle hN ha hb] + exact physicalResidueRectangle_expect _ _ _ d hd + (fun _=>⟨by positivity,by exact_mod_cast r.isLt⟩) (fun z=>f (z 0)) + +lemma floor_rectangle_bounds (L : ℕ → ℝ) (ht : Tendsto L atTop atTop) + {a b : ℝ} (ha : 0 ≤ a) (hab : a < b) (hb : b ≤ 1) : + ∀ᶠ N : ℕ in atTop, + (∀ _index : Fin 1,((b-a)/2)*L N ≤ b*(⌊L N⌋₊:ℝ)-a*(⌊L N⌋₊:ℝ)) ∧ + (∀ _index : Fin 1,-1*L N ≤ a*(⌊L N⌋₊:ℝ) ∧ b*(⌊L N⌋₊:ℝ) ≤ 1*L N) := by + filter_upwards [ht.eventually (eventually_ge_atTop 2)] with N hN + have hf:=Nat.floor_le (show 0 ≤ L N by linarith) + have hf':=Nat.lt_floor_add_one (L N) + have hf0 : 0 ≤ (⌊L N⌋₊:ℝ):=by positivity + have hfhalf : L N/2 ≤ (⌊L N⌋₊:ℝ):=by linarith + refine ⟨fun _=>?_,fun _=>⟨?_,?_⟩⟩ + · nlinarith + · nlinarith + · nlinarith + +end GlobalPointLaw +end + +end + +section + + + + +noncomputable section +open scoped BigOperators Topology +open Filter MeasureTheory +namespace AllLevelFactorization.Factorization.ResidueCover +open RationalLattice CubeFaces CubeTaylorExpansion ComparableBoxLeibman CubeLocalHaar +variable {G : Type} [Group G] [TopologicalSpace G] [IsTopologicalGroup G] +variable {n s : ℕ} {c : RealCoordinates G n} {Γ : Subgroup G} +variable {K : Filtration G} {P : ℕ → ℤ → G} {L : ℕ → ℝ} +variable {F : Factorization c Γ s K P L} {r : Fin F.period} (C : F.ResidueCover r) + +def pointImage : C.CubeSpace (ι:=Empty) → G⧸Γ := + fun x=>EmbeddedCubeHaar.coverImage F.state.domain.embed F.state.domain.filtration Γ + (F.residue r) C.lattice C.le_induced x ∅ + +lemma pointImage_continuous : Continuous C.pointImage := + (continuous_apply ∅).comp (EmbeddedCubeHaar.coverImage_continuous F.state.domain.embed + F.state.domain.continuous F.state.domain.filtration Γ (F.residue r) C.lattice C.le_induced) + +omit [IsTopologicalGroup G] in +lemma pointImage_cubePoint (N : ℕ) (b : Option Empty → ℤ) : + C.pointImage (C.cubePoint N b)= + QuotientGroup.mk (F.state.domain.embed (F.structuredPart N (b none))*F.residue r) := by + unfold pointImage cubePoint + rw [EmbeddedCubeHaar.coverImage_mk,cubePolynomial_integer_vertex] + simp only [Finset.sum_empty,add_zero] + rfl + +variable [MeasurableSpace (C.CubeSpace (ι:=Empty))] [BorelSpace (C.CubeSpace (ι:=Empty))] +variable [MeasurableSpace (G⧸Γ)] [BorelSpace (G⧸Γ)] + +def pointHaar : ProbabilityMeasure (G⧸Γ) := + (C.haar (ι:=Empty)).map C.pointImage + +lemma pointHaar_integral (f : C(G⧸Γ,ℂ)) : + (∫ y,f y ∂(C.pointHaar : Measure _))= + ∫ x,f (C.pointImage x) ∂(C.haar (ι:=Empty) : Measure _) := by + rw [pointHaar,ProbabilityMeasure.toMeasure_map] + exact integral_map C.pointImage_continuous.measurable.aemeasurable f.continuous.aestronglyMeasurable + + + +lemma structured_local_haar (hL : ∀ N,0 < L N) (ht : Tendsto L atTop atTop) + {a b : ℝ} (ha : 0 ≤ a) (hab : a < b) (hb : b ≤ 1) (f : C(G⧸Γ,ℂ)) : + Tendsto (fun N=>𝔼 k∈GlobalPointLaw.cell ⌊L (F.state.subseq N)⌋₊ F.period r.val a b, + f (QuotientGroup.mk (F.state.domain.embed (F.structuredPart N (k.val:ℤ))*F.residue r))) + atTop (𝓝 (∫ y,f y ∂(C.pointHaar : Measure _))) := by + let LL : ℕ → ℝ:=L∘F.state.subseq + have hLL : Tendsto LL atTop atTop:=ht.comp F.state.strictmono.tendsto_atTop + let lo : ℕ → Fin 1 → ℝ:=fun N _=>(a*(⌊LL N⌋₊:ℝ)-(r.val:ℝ))/(F.period:ℝ) + let hi : ℕ → Fin 1 → ℝ:=fun N _=>(b*(⌊LL N⌋₊:ℝ)-(r.val:ℝ))/(F.period:ℝ) + obtain ⟨c₀,C₀,hc₀,hC₀,hbox⟩:=affine_bounds_scaled LL hLL ((b-a)/2) 1 + (by linarith) zero_lt_one F.period F.period_pos (fun _ : Fin 1=>(r.val:ℤ)) + (fun (N : ℕ) (_ : Fin 1)=>a*(⌊LL N⌋₊:ℝ)) (fun (N : ℕ) (_ : Fin 1)=>b*(⌊LL N⌋₊:ℝ)) + (GlobalPointLaw.floor_rectangle_bounds LL hLL ha hab hb) + have hbox':=halfOpen_bounds_scaled LL hLL c₀ C₀ hc₀ lo hi hbox + let e : Option Empty ≃ Fin 1:=Equiv.ofUnique _ _ + let ff : C(C.CubeSpace (ι:=Empty),ℂ):=f.comp ⟨C.pointImage,C.pointImage_continuous⟩ + rw [C.pointHaar_integral] + apply Metric.tendsto_nhds.mpr + intro ε hε + filter_upwards [C.haar_limit hL ht e (c₀/2) C₀ (by positivity) hC₀ F.period + F.period_pos (fun _=>(r.val:ℤ)) {ff} isCompact_singleton ε hε,hbox', + (tendsto_nat_floor_atTop.comp hLL).eventually (eventually_gt_atTop 0)] with N hN hh hpos + have he:=hN (lo N) (fun i=>(⌈hi N i⌉:ℝ)-1) hh.1 hh.2 ff rfl + have hpos' : 0 < ⌊L (F.state.subseq N)⌋₊:=hpos + rw [GlobalPointLaw.cell_expect_progression hpos' F.period_pos r ha hb + (fun z=>f (QuotientGroup.mk (F.state.domain.embed (F.structuredPart N z)*F.residue r)))] + have heq (z : Fin 1 → ℤ) : + ff (C.cubePoint N (fun i=>(r.val:ℤ)+(F.period:ℤ)*z (e i)))= + f (QuotientGroup.mk (F.state.domain.embed + (F.structuredPart N ((r.val:ℤ)+(F.period:ℤ)*z 0))*F.residue r)) := by + dsimp only [ff,ContinuousMap.comp_apply,ContinuousMap.coe_mk] + rw [C.pointImage_cubePoint] + congr 4 + change ‖(𝔼 z∈integerBox 1 (lo N) (fun i=>(⌈hi N i⌉:ℝ)-1), + ff (C.cubePoint N (fun i=>(r.val:ℤ)+(F.period:ℤ)*z (e i))))- + (∫ x,f (C.pointImage x) ∂(C.haar (ι:=Empty) : Measure _))‖ < ε at he + simpa only [dist_eq_norm,halfOpenBox,heq,lo,hi,LL,Function.comp_def] using he + +end AllLevelFactorization.Factorization.ResidueCover + +end +end +end + +end OAI diff --git a/lean/OAI/Combinatorics/SumProduct/Alignment/AllLevel11.lean b/lean/OAI/Combinatorics/SumProduct/Alignment/AllLevel11.lean new file mode 100644 index 0000000000000000000000000000000000000000..fc63cbf59caaa976185ac040de9207ad11740e6a --- /dev/null +++ b/lean/OAI/Combinatorics/SumProduct/Alignment/AllLevel11.lean @@ -0,0 +1,324 @@ +import Mathlib +import OAI.Combinatorics.SumProduct.Alignment.AllLevel07 +import OAI.Combinatorics.SumProduct.Alignment.AllLevel10 +import OAI.Geometry.NilpotentCharts.Main + +namespace OAI + +open scoped BigOperators +section +section +noncomputable section +open scoped BigOperators Topology +open Filter MeasureTheory +end + +end + +section + + + + +noncomputable section +open scoped BigOperators Topology +open Filter +namespace CompactUniformComposition + +lemma compose {X E Y : Type*} [TopologicalSpace X] [PseudoMetricSpace E] + [PseudoMetricSpace Y] (A : Set X) (hA : IsCompact A) + (f : X → E) (hf : Continuous f) (u : ℕ → X → E) + (hu : TendstoUniformlyOn u f atTop A) (g : E → Y) (hg : Continuous g) : + TendstoUniformlyOn (fun N t=>g (u N t)) (fun t=>g (f t)) atTop A := by + apply Metric.tendstoUniformlyOn_iff.mpr + intro ε hε + have hr : {p : Y×Y | dist p.1 p.2 < ε}∈uniformity Y:= + Metric.mem_uniformity_dist.mpr ⟨ε,hε,fun {_ _} h=>h⟩ + have huni := (hA.image hf).uniformContinuousAt_of_continuousAt g + (fun _ _=>hg.continuousAt) hr + obtain ⟨δ,hδ,hδs⟩:=Metric.mem_uniformity_dist.mp huni + filter_upwards [Metric.tendstoUniformlyOn_iff.mp hu δ hδ] with N hN + intro t ht + exact hδs (hN t ht) ⟨t,ht,rfl⟩ + +lemma floor_normalized_close {l : ℝ} (hl : 0 < l) {k : ℕ} (hk : k < ⌊l⌋₊) : + (k:ℝ)/l∈Set.Icc (0:ℝ) 1 ∧ (k:ℝ)/(⌊l⌋₊:ℝ)∈Set.Icc (0:ℝ) 1 ∧ + dist ((k:ℝ)/l) ((k:ℝ)/(⌊l⌋₊:ℝ)) ≤ 1/l := by + have hM : 0 < (⌊l⌋₊:ℝ):=by exact_mod_cast (Nat.zero_lt_of_lt hk) + have hkR : (k:ℝ) < (⌊l⌋₊:ℝ):=by exact_mod_cast hk + have hf := Nat.floor_le hl.le + have hf' := Nat.lt_floor_add_one l + have hu0 : 0 ≤ (k:ℝ)/(⌊l⌋₊:ℝ):=by positivity + have hu1 : (k:ℝ)/(⌊l⌋₊:ℝ) ≤ 1:=(div_le_one hM).mpr hkR.le + have hv0 : 0 ≤ (k:ℝ)/l:=by positivity + have hv1 : (k:ℝ)/l ≤ 1:=(div_le_one hl).mpr (hkR.le.trans hf) + refine ⟨⟨hv0,hv1⟩,⟨hu0,hu1⟩,?_⟩ + have hvu : (k:ℝ)/l ≤ (k:ℝ)/(⌊l⌋₊:ℝ):= + div_le_div_of_nonneg_left (by positivity) hM hf + rw [Real.dist_eq,abs_of_nonpos (sub_nonpos.mpr hvu)] + have he : ((k:ℝ)/(⌊l⌋₊:ℝ)-(k:ℝ)/l)*l= + ((k:ℝ)/(⌊l⌋₊:ℝ))*(l-(⌊l⌋₊:ℝ)):=by field_simp + apply (le_div_iff₀ hl).mpr + have hdiff0 : 0 ≤ l-(⌊l⌋₊:ℝ):=sub_nonneg.mpr hf + have hh:=mul_le_mul_of_nonneg_right hu1 hdiff0 + rw [neg_sub] + rw [he] + nlinarith +end CompactUniformComposition + +namespace AllLevelFactorization.Factorization +open RationalLattice CubeFaces +variable {G : Type} [Group G] [TopologicalSpace G] [IsTopologicalGroup G] +variable {n s : ℕ} {c : RealCoordinates G n} {Γ : Subgroup G} +variable {K : Filtration G} {P : ℕ → ℤ → G} {L : ℕ → ℝ} +variable (F : Factorization c Γ s K P L) +variable {X : Type*} [TopologicalSpace X] [CompactSpace X] + +lemma smooth_composed_uniform {Y : Type*} [PseudoMetricSpace Y] + (hL : ∀ N,0 < L N) (ht : Tendsto L atTop atTop) + (A : Set ℝ) (hA : IsCompact A) (g : G → Y) (hg : Continuous g) : + TendstoUniformlyOn (fun N t=>g (F.smoothPart N (L (F.state.subseq N)*t))) + (fun t=>g (F.smoothLimit t)) atTop A := by + have hu : TendstoUniformlyOn + (fun N t=>c.coord (F.smoothPart N (L (F.state.subseq N)*t))) + (fun t=>c.coord (F.smoothLimit t)) atTop A := by + apply Metric.tendstoUniformlyOn_iff.mpr + intro ε hε + simpa only [dist_comm] using F.smooth_coord_uniform hL ht A hA ε hε + have hh:=CompactUniformComposition.compose A hA + (fun t=>c.coord (F.smoothLimit t)) (c.coord.continuous.comp F.smoothLimit_continuous) + _ hu (g∘c.coord.symm) (hg.comp c.coord.symm.continuous) + simpa only [Function.comp_def,Homeomorph.symm_apply_apply] using hh + + + +lemma smooth_floor_tests (hL : ∀ N,0 < L N) (ht : Tendsto L atTop atTop) + (g : G → C(X,ℂ)) (hg : Continuous g) : + ∀ ε : ℝ,0 < ε → ∀ᶠ N : ℕ in atTop,∀ k : Fin ⌊L (F.state.subseq N)⌋₊, + dist (g (F.smoothPart N (k.val:ℝ))) + (g (F.smoothLimit ((k.val:ℝ)/(⌊L (F.state.subseq N)⌋₊:ℝ)))) < ε := by + intro ε hε + have hlc : Continuous (fun t=>g (F.smoothLimit t)):=hg.comp F.smoothLimit_continuous + have hc : UniformContinuousOn (fun t=>g (F.smoothLimit t)) (Set.Icc (0:ℝ) 1):= + isCompact_Icc.uniformContinuousOn_of_continuous hlc.continuousOn + obtain ⟨δ,hδ,hδs⟩:=Metric.uniformContinuousOn_iff.mp hc (ε/2) (by positivity) + have huv:=F.smooth_composed_uniform hL ht (Set.Icc (0:ℝ) 1) isCompact_Icc g hg + have hbig:=(ht.comp F.state.strictmono.tendsto_atTop).eventually + (eventually_gt_atTop (1/δ)) + filter_upwards [Metric.tendstoUniformlyOn_iff.mp huv (ε/2) (by positivity),hbig] with N hN hb + intro k + have hpoint:=CompactUniformComposition.floor_normalized_close (hL _) k.isLt + have htδ : dist ((k.val:ℝ)/L (F.state.subseq N)) + ((k.val:ℝ)/(⌊L (F.state.subseq N)⌋₊:ℝ)) < δ := by + apply hpoint.2.2.trans_lt + apply (div_lt_iff₀ (hL _)).mpr + have hh:=(div_lt_iff₀ hδ).mp hb + simpa only [Function.comp_apply,mul_comm] using hh + have he : L (F.state.subseq N)*((k.val:ℝ)/L (F.state.subseq N))=k.val:=by + field_simp [ne_of_gt (hL (F.state.subseq N))] + have hfirst:=hN ((k.val:ℝ)/L (F.state.subseq N)) hpoint.1 + rw [he,dist_comm] at hfirst + have hsecond:=hδs _ hpoint.1 _ hpoint.2.1 htδ + exact (dist_triangle _ (g (F.smoothLimit ((k.val:ℝ)/L (F.state.subseq N)))) _).trans_lt + (by linarith only [hfirst,hsecond]) + +end AllLevelFactorization.Factorization +end + +end + +section + + + + +noncomputable section +open scoped BigOperators Topology +open Filter MeasureTheory +namespace AllLevelFactorization.Factorization +open RationalLattice CubeFaces +variable {G : Type} [Group G] [TopologicalSpace G] [IsTopologicalGroup G] +variable {n s : ℕ} {c : RealCoordinates G n} {Γ : Subgroup G} +variable {K : Filtration G} {P : ℕ → ℤ → G} {L : ℕ → ℝ} +variable (F : Factorization c Γ s K P L) + +def natResidue (k : ℕ) : Fin F.period:=⟨k%F.period,Nat.mod_lt _ F.period_pos⟩ +def pointStructured (N k : ℕ) : G⧸Γ := + QuotientGroup.mk (F.state.domain.embed (F.structuredPart N (k:ℤ))*F.residue (F.natResidue k)) + +def leftTest (f : C(G⧸Γ,ℂ)) (a : G) : C(G⧸Γ,ℂ) := + ⟨fun x=>f (a•x),f.continuous.comp ((continuous_const : Continuous (fun _ : G⧸Γ=>a)).smul continuous_id)⟩ + +lemma leftTest_continuous (f : C(G⧸Γ,ℂ)) : Continuous (leftTest f) := by + apply ContinuousMap.continuous_of_continuous_uncurry + exact f.continuous.comp (show Continuous (fun p : G×(G⧸Γ)=>p.1•p.2) from + continuous_fst.smul continuous_snd) + +def limitTest (f : C(G⧸Γ,ℂ)) (β : ℝ) : C(G⧸Γ,ℂ) :=leftTest f (F.smoothLimit β) + +lemma limitTest_continuous (f : C(G⧸Γ,ℂ)) : Continuous (F.limitTest f) := + (leftTest_continuous f).comp F.smoothLimit_continuous + +lemma point_realization (N k : ℕ) : + (QuotientGroup.mk (P (F.state.subseq N) (k:ℤ)) : G⧸Γ)= + F.smoothPart N (k:ℝ) • F.pointStructured N k := by + have hr : (k:ℤ)%(F.period:ℤ)=((F.natResidue k).val:ℤ):=by + simp [natResidue,Int.natCast_emod] + rw [F.realization_of_residue N k (F.natResidue k) hr] + change QuotientGroup.mk (F.smoothPart N (k:ℝ)*F.state.domain.embed + (F.structuredPart N (k:ℤ))*F.residue (F.natResidue k))= + QuotientGroup.mk (F.smoothPart N (k:ℝ)*(F.state.domain.embed + (F.structuredPart N (k:ℤ))*F.residue (F.natResidue k))) + rw [mul_assoc] + +variable (C : (r : Fin F.period) → F.ResidueCover r) +variable [∀ r,MeasurableSpace ((C r).CubeSpace (ι:=Empty))] +variable [∀ r,BorelSpace ((C r).CubeSpace (ι:=Empty))] +variable [MeasurableSpace (G⧸Γ)] [BorelSpace (G⧸Γ)] [CompactSpace (G⧸Γ)] + +omit [CompactSpace (G ⧸ Γ)] in +lemma pointStructured_local (hL : ∀ N,0 < L N) (ht : Tendsto L atTop atTop) + {a b : ℝ} (ha : 0 ≤ a) (hab : a < b) (hb : b ≤ 1) + (r : Fin F.period) (f : C(G⧸Γ,ℂ)) : + Tendsto (fun N=>𝔼 k∈GlobalPointLaw.cell ⌊L (F.state.subseq N)⌋₊ F.period r.val a b, + f (F.pointStructured N k.val)) atTop (𝓝 (∫ y,f y ∂((C r).pointHaar : Measure _))) := by + have he (N : ℕ) : + (𝔼 k∈GlobalPointLaw.cell ⌊L (F.state.subseq N)⌋₊ F.period r.val a b, + f (F.pointStructured N k.val))= + (𝔼 k∈GlobalPointLaw.cell ⌊L (F.state.subseq N)⌋₊ F.period r.val a b, + f (QuotientGroup.mk (F.state.domain.embed (F.structuredPart N (k.val:ℤ))*F.residue r))) := by + apply Finset.expect_congr rfl + intro k hk + have hh:= (GlobalPointLaw.mem_cell.mp hk).2.2 + have hr : F.natResidue k.val=r:=Fin.ext hh + simp only [pointStructured,hr] + simp_rw [he] + exact (C r).structured_local_haar hL ht ha hab hb f + +lemma empirical_eq_expect {X : Type*} [TopologicalSpace X] {M : ℕ} + (q : Fin M → X) (Φ : ℝ → C(X,ℂ)) : + GlobalPointLaw.empirical q Φ=(𝔼 k : Fin M,Φ ((k.val:ℝ)/M) (q k)) := by + rw [Fintype.expect_eq_sum_div_card] + simp [GlobalPointLaw.empirical,Complex.real_smul,div_eq_mul_inv,mul_comm] + + + +theorem global_point_law (hL : ∀ N,0 < L N) (ht : Tendsto L atTop atTop) + (f : C(G⧸Γ,ℂ)) : + Tendsto (fun N=>𝔼 k : Fin ⌊L (F.state.subseq N)⌋₊, + f (QuotientGroup.mk (P (F.state.subseq N) (k.val:ℤ)))) atTop + (𝓝 (GlobalPointLaw.betaMixture (fun r=>(C r).pointHaar) (F.limitTest f))) := by + have hlen:=tendsto_nat_floor_atTop.comp (ht.comp F.state.strictmono.tendsto_atTop) + have hglobal:=GlobalPointLaw.global_point_law_of_local_haar hlen F.period_pos + (fun N k=>F.pointStructured N k.val) (fun r=>(C r).pointHaar) (F.limitTest f) + (F.limitTest_continuous f) (fun _ _ ha hab hb r g=>F.pointStructured_local C hL ht ha hab hb r g) + simp_rw [empirical_eq_expect] at hglobal + apply Metric.tendsto_nhds.mpr + intro ε hε + filter_upwards [Metric.tendsto_nhds.mp hglobal (ε/2) (by positivity), + F.smooth_floor_tests hL ht (leftTest f) (leftTest_continuous f) (ε/4) (by positivity), + hlen.eventually (eventually_gt_atTop 0)] with N hN hs hpos + have : Nonempty (Fin ⌊L (F.state.subseq N)⌋₊):=⟨⟨0,hpos⟩⟩ + have hbound : dist + (𝔼 k : Fin ⌊L (F.state.subseq N)⌋₊,f (QuotientGroup.mk (P (F.state.subseq N) (k.val:ℤ)))) + (𝔼 k : Fin ⌊L (F.state.subseq N)⌋₊, + F.limitTest f ((k.val:ℝ)/(⌊L (F.state.subseq N)⌋₊:ℝ)) (F.pointStructured N k.val)) ≤ ε/4 := by + rw [dist_eq_norm,←Finset.expect_sub_distrib] + apply (RCLike.norm_expect_le (K:=ℂ)).trans + apply Finset.expect_le Finset.univ_nonempty + intro k hk + rw [F.point_realization] + have hh:= (ContinuousMap.dist_apply_le_dist (F.pointStructured N k.val)).trans (hs k).le + simpa only [dist_eq_norm,leftTest,limitTest,ContinuousMap.coe_mk] using hh + simp only [Function.comp_apply] at hN + exact (dist_triangle _ + (𝔼 k : Fin ⌊L (F.state.subseq N)⌋₊, + F.limitTest f ((k.val:ℝ)/(⌊L (F.state.subseq N)⌋₊:ℝ)) (F.pointStructured N k.val)) + _).trans_lt (by linarith only [hbound,hN,hε]) + +end AllLevelFactorization.Factorization +end + +end + +section + + + + +noncomputable section +open scoped BigOperators Topology ENNReal +open MeasureTheory Filter +namespace ProbabilityMixtures +variable {I X Y : Type*} [Fintype I] [Nonempty I] +variable [MeasurableSpace X] [MeasurableSpace Y] + +def finiteAverage (μ : I → ProbabilityMeasure X) : ProbabilityMeasure X := + ⟨(Fintype.card I : ℝ≥0∞)⁻¹ • ∑ i, (μ i : Measure X), by + constructor + simp only [Measure.smul_apply,Measure.finsetSum_apply,measure_univ, + Finset.sum_const,Finset.card_univ,nsmul_eq_mul,mul_one,smul_eq_mul] + exact ENNReal.inv_mul_cancel (by exact_mod_cast Fintype.card_ne_zero) (ENNReal.natCast_ne_top _)⟩ + +lemma finiteAverage_integral (μ : I → ProbabilityMeasure X) (f : X → ℂ) + (hf : ∀ i,Integrable f (μ i : Measure X)) : + (∫ x,f x ∂(finiteAverage μ : Measure X))=(1/(Fintype.card I:ℝ)) • + ∑ i,∫ x,f x ∂(μ i : Measure X) := by + change (∫ x,f x ∂((Fintype.card I:ℝ≥0∞)⁻¹ • ∑ i,(μ i:Measure X)))=_ + rw [integral_smul_measure,integral_finsetSum_measure (fun i _=>hf i)] + simp + +def unitTime : Measure ℝ:=volume.restrict (Set.Icc 0 1) +instance unitTime_probability : IsProbabilityMeasure unitTime := by + constructor + simp [unitTime] + +variable [TopologicalSpace X] [TopologicalSpace Y] [BorelSpace X] [BorelSpace Y] +variable [SecondCountableTopology X] + +def intervalPush (μ : ProbabilityMeasure X) (h : C(ℝ×X,Y)) : ProbabilityMeasure Y := + ⟨(unitTime.prod (μ:Measure X)).map h, inferInstance⟩ + +lemma intervalPush_integral [CompactSpace Y] (μ : ProbabilityMeasure X) + (h : C(ℝ×X,Y)) (f : C(Y,ℂ)) : + (∫ y,f y ∂(intervalPush μ h : Measure Y))= + ∫ β in (0:ℝ)..1,∫ x,f (h (β,x)) ∂(μ:Measure X) := by + change (∫ y,f y ∂(unitTime.prod (μ:Measure X)).map h)=_ + rw [integral_map h.continuous.measurable.aemeasurable f.continuous.aestronglyMeasurable] + have hf : Integrable (fun z : ℝ×X=>f (h z)) (unitTime.prod (μ:Measure X)):= + Integrable.of_bound (f.continuous.comp h.continuous).aestronglyMeasurable ‖f‖ + (Eventually.of_forall fun z=>f.norm_coe_le_norm (h z)) + rw [integral_prod _ hf] + rw [intervalIntegral.integral_of_le zero_le_one] + exact integral_Icc_eq_integral_Ioc + +variable [MeasurableSingletonClass Y] +def empirical (M : ℕ) (q : ℕ → Y) : ProbabilityMeasure Y := + if hM : 0(⟨Measure.dirac (q k.val),inferInstance⟩ : ProbabilityMeasure Y)) + else ⟨Measure.dirac (q 0),inferInstance⟩ + +lemma empirical_integral [CompactSpace Y] (M : ℕ) (hM : 0⟨Measure.dirac (q k.val),inferInstance⟩ + have hμ : ∀ k, Integrable f (μ k : Measure Y) := fun _=> + Integrable.of_bound f.continuous.aestronglyMeasurable ‖f‖ + (Eventually.of_forall f.norm_coe_le_norm) + have H := finiteAverage_integral μ f hμ + calc + (∫ y,f y ∂(empirical M q : Measure Y)) = (∫ y,f y ∂(finiteAverage μ : Measure Y)) := by + congr 1 + simp only [empirical,hM,↓reduceDIte,μ] + _ = (1/(Fintype.card (Fin M):ℝ)) • ∑ k, ∫ y,f y ∂(μ k : Measure Y) := H + _ = 𝔼 k : Fin M,f (q k.val) := by + simp [μ,Fintype.expect_eq_sum_div_card,Complex.real_smul,div_eq_mul_inv,Finset.mul_sum,mul_comm] + +end ProbabilityMixtures + +end +end +end + +end OAI diff --git a/lean/OAI/Combinatorics/SumProduct/Alignment/AllLevel12.lean b/lean/OAI/Combinatorics/SumProduct/Alignment/AllLevel12.lean new file mode 100644 index 0000000000000000000000000000000000000000..cfdc4dde6ffe0ca8c5e728c4cde2ed21a1a252a5 --- /dev/null +++ b/lean/OAI/Combinatorics/SumProduct/Alignment/AllLevel12.lean @@ -0,0 +1,287 @@ +import Mathlib +import OAI.Combinatorics.SumProduct.Alignment.RationalLattice21 +import OAI.Combinatorics.SumProduct.Alignment.RationalLattice25 +import OAI.Geometry.NilpotentCharts.Main + +namespace OAI + +open scoped BigOperators +section +section +noncomputable section +end + +end + +section + + +noncomputable section +namespace RationalLattice +open MalcevCharacters MalcevWeightedCoordinates CubeFaces +variable {G : Type*} [Group G] [TopologicalSpace G] +variable {n : ℕ} (c : RealCoordinates G n) (H : Filtration G) +variable (h0 : H.level 0=⊤) (h1 : H.level 1=⊤) (s : ℕ) (hs : H.level (s+1)=⊥) +variable (q : ℕ → ℕ) +variable (hH : ∀ k (x : G),x∈H.level k ↔ ∀ i : Fin n,i.valc.coord g i) he + simp [axis,c.one_coord] at ee + have hh:=(weight_lt_iff_out c H s hs h0 i (s+1)).mpr ho + change w iha i) _ + +variable [TopologicalSpace X] [TopologicalSpace Y] [BorelSpace X] [BorelSpace Y] +variable [SecondCountableTopology X] + +lemma intervalPush_apply (μ : ProbabilityMeasure X) (h : C(ℝ×X,Y)) + (S : Set Y) (hS : MeasurableSet S) : + (intervalPush μ h : Measure Y) S = + ∫⁻ t,(μ : Measure X) {x | h (t,x)∈S} ∂unitTime := by + change ((unitTime.prod (μ:Measure X)).map h) S=_ + rw [Measure.map_apply h.continuous.measurable hS, + Measure.prod_apply (h.continuous.measurable hS)] + rfl + +lemma intervalPush_lower (μ : ProbabilityMeasure X) (h : C(ℝ×X,Y)) + (S : Set Y) (hS : MeasurableSet S) (a : ℝ≥0∞) + (ha : ∀ᵐ t ∂unitTime,a ≤ (μ : Measure X) {x | h (t,x)∈S}) : + a ≤ (intervalPush μ h : Measure Y) S := by + rw [intervalPush_apply μ h S hS] + simpa using (lintegral_mono_ae ha : + (∫⁻ _t,a ∂unitTime) ≤ ∫⁻ t,(μ:Measure X) {x | h (t,x)∈S} ∂unitTime) + + + +theorem betaResidue_lower (μ : I → ProbabilityMeasure X) + (h : I → C(ℝ×X,Y)) (S : Set Y) (hS : MeasurableSet S) (a : ℝ≥0∞) + (ha : ∀ i,∀ᵐ t ∂unitTime,a ≤ (μ i : Measure X) {x | h i (t,x)∈S}) : + a ≤ (finiteAverage (fun i=>intervalPush (μ i) (h i)) : Measure Y) S := by + exact finiteAverage_lower _ S a (fun i=>intervalPush_lower (μ i) (h i) S hS a (ha i)) + +end ProbabilityMixtures +end + +end + +section + + +noncomputable section +open MeasureTheory Filter Topology +namespace AllLevelFactorization.Factorization.ResidueCover +open RationalLattice CubeFaces CubeLocalHaar MalcevCharacters +variable {G : Type} [Group G] [TopologicalSpace G] [IsTopologicalGroup G] +variable {n s : ℕ} {c : RealCoordinates G n} {Γ : Subgroup G} +variable {K : Filtration G} {P : ℕ → ℤ → G} {L : ℕ → ℝ} +variable {F : Factorization c Γ s K P L} {r : Fin F.period} (C : F.ResidueCover r) + +abbrev pointFiltration (_C : F.ResidueCover r) := CubeMaxFiltration.filtration F.state.domain.filtration + (Finset.univ : Finset Empty) +abbrev pointLattice := cubeLattice (ι:=Empty) F.state.domain.filtration C.lattice + + + +structure PivotChart where + dim : ℕ + chart : RealCoordinates (CubeGroup (ι:=Empty) (F:=F)) dim + secondKind : SecondKind chart + integer_lattice : ∀ g,g∈C.pointLattice ↔ ∀ i,∃ z : ℤ,chart.coord g i=z + weights : Fin dim → ℕ + monotone : Monotone weights + positive : ∀ i,0F.smoothLimit β • C.pointImage x, + (continuous_const : Continuous (fun _ : C.CubeSpace (ι:=Empty)=>F.smoothLimit β)).smul C.pointImage_continuous⟩ + +variable [MeasurableSpace (C.CubeSpace (ι:=Empty))] [BorelSpace (C.CubeSpace (ι:=Empty))] +variable [MeasurableSpace (G⧸Γ)] [BorelSpace (G⧸Γ)] + +lemma pivotImage_event (β : ℝ) (S : Set (G⧸Γ)) (hS : MeasurableSet S) : + ((C.haar (ι:=Empty)).map (C.pivotImage β) : Measure (G⧸Γ)) S = + (C.pointHaar : Measure (G⧸Γ)) {x | F.smoothAction (β,x)∈S} := by + rw [ProbabilityMeasure.toMeasure_map,Measure.map_apply (C.pivotImage β).continuous.measurable hS] + rw [pointHaar,ProbabilityMeasure.toMeasure_map,Measure.map_apply C.pointImage_continuous.measurable] + · rfl + · exact ((continuous_const : Continuous (fun _ : G⧸Γ=>F.smoothLimit β)).smul continuous_id).measurable hS + +end AllLevelFactorization.Factorization.ResidueCover + +end +end +end + +end OAI diff --git a/lean/OAI/Combinatorics/SumProduct/Alignment/AllLevel13.lean b/lean/OAI/Combinatorics/SumProduct/Alignment/AllLevel13.lean new file mode 100644 index 0000000000000000000000000000000000000000..b156363421177dff74bb0ff0d68149e09773c761 --- /dev/null +++ b/lean/OAI/Combinatorics/SumProduct/Alignment/AllLevel13.lean @@ -0,0 +1,329 @@ +import Mathlib +import OAI.Combinatorics.SumProduct.Alignment.RationalLattice22 +import OAI.Combinatorics.SumProduct.Alignment.RationalLattice27 +import OAI.Geometry.NilpotentCharts.Main + +namespace OAI + +open scoped BigOperators +section +section +end + +section + + + + +noncomputable section +namespace RationalLattice +open MalcevCharacters MalcevWeightedCoordinates +variable {G H : Type} [Group G] [Group H] +variable [TopologicalSpace G] [TopologicalSpace H] +variable [IsTopologicalGroup G] [IsTopologicalGroup H] +variable {n m : ℕ} (c : RealCoordinates G n) (d : RealCoordinates H m) +variable (A : CubeFaces.Filtration G) (F : G →* H) + + + +structure ImageGeometry where + dim : ℕ + chart : RealCoordinates F.range dim + secondKind : SecondKind chart + weights : Fin dim → ℕ + positive : ∀ i,0w (E.free i) + positive:=fun i=>hw (E.free i) + monotone:=hmono.comp E.free.monotone + adapted:=QuotientLogImage.imageSecondChart_adapted c d hsk F hF p hp E A w hw hmono hA + rational:=QuotientLogImage.imageEmbedding_rational c d hsk F hF p hp E A w hw hmono hA }⟩ + +namespace ImageGeometry +variable (T : ImageGeometry d A F) +variable (Γ : Subgroup H) (hΓ : ∀ g : H,g∈Γ ↔ ∀ i,∃ z : ℤ,d.coord g i=z) +variable (σ : H) (hσ : IsRational d σ) + +include T hΓ hσ in +omit [TopologicalSpace G] [IsTopologicalGroup G] in +lemma level_compact_reps (l : ℕ) : + CompactGroupProducts.HasCompactReps ((A.level l).map F.rangeRestrict) + ((CubeLocalHaar.conjugateLattice Γ σ).comap F.range.subtype) := + rationalConjugate_compact_reps d T.chart T.secondKind F.range.subtype + continuous_subtype_val Subtype.val_injective T.rational Γ hΓ σ hσ _ + T.weights T.monotone l (T.adapted l) + +include T hΓ hσ in +omit [TopologicalSpace G] [IsTopologicalGroup G] in +lemma quotient_compactSpace : + CompactSpace (F.range⧸(CubeLocalHaar.conjugateLattice Γ σ).comap F.range.subtype) := + rationalConjugate_compactSpace d T.chart T.secondKind F.range.subtype + continuous_subtype_val Subtype.val_injective T.rational Γ hΓ σ hσ + +end ImageGeometry + +end RationalLattice +end + +end + +section +noncomputable section +namespace RationalLattice +variable {G : Type} [Group G] [TopologicalSpace G] [IsTopologicalGroup G] +variable {n : ℕ} (c : RealCoordinates G n) (Γ : Subgroup G) + +namespace ImageGeometry +variable {K : Type} [Group K] [TopologicalSpace K] [IsTopologicalGroup K] +variable (A : CubeFaces.Filtration K) (F : K →* G) (T : ImageGeometry c A F) +variable (B : CoveredLattice c Γ) (σ : G) (hσ : IsRational c σ) +include B T hσ in +omit [TopologicalSpace K] [IsTopologicalGroup K] in +lemma covered_level_compact_reps (l : ℕ) : + CompactGroupProducts.HasCompactReps ((A.level l).map F.rangeRestrict) + ((CubeLocalHaar.conjugateLattice Γ σ).comap F.range.subtype) := by + obtain ⟨C,hC,hCJ,hrep⟩:=T.level_compact_reps c A F B.small B.integer σ hσ l + exact ⟨C,hC,hCJ,fun g hg=>by + obtain ⟨a,ha,hag⟩:=hrep g hg + exact ⟨a,ha,B.le hag⟩⟩ +include B T hσ in +omit [TopologicalSpace K] [IsTopologicalGroup K] in +lemma covered_quotient_compactSpace : + CompactSpace (F.range⧸(CubeLocalHaar.conjugateLattice Γ σ).comap F.range.subtype) := by + let : CompactSpace (F.range⧸(CubeLocalHaar.conjugateLattice B.small σ).comap F.range.subtype):= + T.quotient_compactSpace c A F B.small B.integer σ hσ + let Δ:=(CubeLocalHaar.conjugateLattice B.small σ).comap F.range.subtype + let Θ:=(CubeLocalHaar.conjugateLattice Γ σ).comap F.range.subtype + have hle : Δ≤Θ:=fun _ h=>B.le h + exact (CosetCover.surjective_map Δ Θ hle).compactSpace (CosetCover.continuous_map Δ Θ hle) + +end ImageGeometry +end RationalLattice +end + +end + +section + + + + +noncomputable section +open scoped BigOperators Topology ENNReal +open MeasureTheory Filter +namespace ProbabilityMixtures +variable {X Y : Type*} [MeasurableSpace X] [MeasurableSpace Y] +variable [TopologicalSpace X] [TopologicalSpace Y] [BorelSpace X] [BorelSpace Y] +variable [MeasurableSingletonClass X] [MeasurableSingletonClass Y] +lemma empirical_map (M : ℕ) (q : ℕ → X) (f : C(X,Y)) : + (empirical M q).map f= + empirical M (fun k=>f (q k)) := by + classical + apply Subtype.ext + change Measure.map f (empirical M q : Measure X)= + (empirical M (fun k=>f (q k)) : Measure Y) + by_cases h : 0f (q k)) : Measure Y) S := by + classical + by_cases h : 0QuotientGroup.mk (P (F.state.subseq N) (k:ℤ))) + +omit [IsTopologicalGroup G] [CompactSpace (G⧸Δ)] [SecondCountableTopology (G⧸Δ)] in +lemma coveredEmpiricalPointLaw_eq (N : ℕ) : + F.coveredEmpiricalPointLaw Γ N=CosetCover.probability Δ Γ hle (F.empiricalPointLaw N) := by + change ProbabilityMixtures.empirical ⌊L (F.state.subseq N)⌋₊ + (fun k=>QuotientGroup.mk (P (F.state.subseq N) (k:ℤ))) = + (ProbabilityMixtures.empirical ⌊L (F.state.subseq N)⌋₊ + (fun k=>(QuotientGroup.mk (P (F.state.subseq N) (k:ℤ)) : G⧸Δ))).map + (CosetCover.map Δ Γ hle) + exact (ProbabilityMixtures.empirical_map ⌊L (F.state.subseq N)⌋₊ + (fun k=>(QuotientGroup.mk (P (F.state.subseq N) (k:ℤ)) : G⧸Δ)) + ⟨CosetCover.map Δ Γ hle,CosetCover.continuous_map Δ Γ hle⟩).symm + + + +theorem covered_weak_point_law (hL : ∀ N,0(F.coveredEmpiricalPointLaw_eq Γ hle N).symm) + +variable [CompactSpace (G⧸Γ)] + +omit [MeasurableSingletonClass (G⧸Δ)] [MeasurableSingletonClass (G⧸Γ)] [CompactSpace (G⧸Γ)] in +lemma coveredPointMixture_integral (f : C(G⧸Γ,ℂ)) : + (∫ y,f y ∂(F.coveredPointMixture C Γ hle : Measure _))= + GlobalPointLaw.betaMixture (fun r=>(C r).pointHaar) + (F.limitTest (f.comp ⟨CosetCover.map Δ Γ hle,CosetCover.continuous_map Δ Γ hle⟩)) := by + change (∫ y,f y ∂((F.pointMixture C : Measure _).map (CosetCover.map Δ Γ hle)))=_ + rw [integral_map (CosetCover.continuous_map Δ Γ hle).measurable.aemeasurable + f.continuous.aestronglyMeasurable] + exact F.pointMixture_integral C + (f.comp ⟨CosetCover.map Δ Γ hle,CosetCover.continuous_map Δ Γ hle⟩) + +end AllLevelFactorization.Factorization +end + +end + +section + + + + +noncomputable section +open scoped Topology +open MeasureTheory Filter +namespace AllLevelFactorization +open RationalLattice CubeFaces +variable {G : Type} [Group G] [TopologicalSpace G] [IsTopologicalGroup G] +variable {n s : ℕ} (c : RealCoordinates G n) (Γ : Subgroup G) (B : CoveredLattice c Γ) +variable {K : Filtration G} {P : ℕ → ℤ → G} {L : ℕ → ℝ} +variable (F : Factorization c B.small s K P L) +variable [MeasurableSpace (G⧸Γ)] [BorelSpace (G⧸Γ)] [MeasurableSingletonClass (G⧸Γ)] + +local instance smallMeasurable : MeasurableSpace (G⧸B.small):=borel _ +local instance smallBorel : BorelSpace (G⧸B.small):=⟨rfl⟩ +local instance smallCompact : CompactSpace (G⧸B.small):=by + obtain ⟨S,hS,hrep⟩:=compact_reps_of_integerCoordinates c B.small B.integer + exact (show CompactGroupProducts.HasCompactReps ⊤ B.small from + ⟨S,hS,Set.subset_univ _,fun g _=>hrep g⟩).quotient_compactSpace +local instance smallT2 : T2Space (G⧸B.small):=by + let : T2Space G:=c.coord.symm.t2Space + let : DiscreteTopology B.small:=integerCoordinates_discrete c B.small B.integer + let : IsClosed (B.small:Set G):=Subgroup.isClosed_of_discreteTopology + infer_instance +local instance smallSecond : SecondCountableTopology (G⧸B.small):=by + let : SecondCountableTopology G:=c.coord.secondCountableTopology + infer_instance +local instance residueMeasurable (r : Fin F.period) : + MeasurableSpace ((F.residueCover B.integer r).CubeSpace (ι:=Empty)):=borel _ +local instance residueBorel (r : Fin F.period) : + BorelSpace ((F.residueCover B.integer r).CubeSpace (ι:=Empty)):=⟨rfl⟩ + + +def actualPointMixture : ProbabilityMeasure (G⧸Γ):= + F.coveredPointMixture (fun r=>F.residueCover B.integer r) Γ B.le + + + +lemma actual_weak_point_law (hL : ∀ N,0ProbabilityMixtures.empirical ⌊L (F.state.subseq N)⌋₊ + (fun k=>(QuotientGroup.mk (P (F.state.subseq N) (k:ℤ)) : G⧸Γ))) + atTop (𝓝 (actualPointMixture c Γ B F)) := + F.covered_weak_point_law (fun r=>F.residueCover B.integer r) Γ B.le hL ht + + + +lemma actual_weak_point_law_map {Y : Type*} [TopologicalSpace Y] [MeasurableSpace Y] + [BorelSpace Y] [MeasurableSingletonClass Y] (q : C(G⧸Γ,Y)) + (hL : ∀ N,0ProbabilityMixtures.empirical ⌊L (F.state.subseq N)⌋₊ + (fun k=>q (QuotientGroup.mk (P (F.state.subseq N) (k:ℤ))))) + atTop (𝓝 ((actualPointMixture c Γ B F).map q)) := by + have H:=ProbabilityMeasure.tendsto_map_of_tendsto_of_continuous _ _ + (actual_weak_point_law c Γ B F hL ht) q.continuous + apply H.congr + intro N + exact ProbabilityMixtures.empirical_map _ _ q + + + +omit [MeasurableSingletonClass (G⧸Γ)] in +lemma actualPointMixture_integral (f : C(G⧸Γ,ℂ)) : + (∫ y,f y ∂(actualPointMixture c Γ B F : Measure _))= + GlobalPointLaw.betaMixture (fun r=>(F.residueCover B.integer r).pointHaar) + (F.limitTest (f.comp ⟨CosetCover.map B.small Γ B.le, + CosetCover.continuous_map B.small Γ B.le⟩)) := by + let : CompactSpace (G⧸Γ):=covered_quotient_compact c Γ B + exact F.coveredPointMixture_integral (fun r=>F.residueCover B.integer r) Γ B.le f + +variable (K : Filtration G) (w : Fin n → ℕ) +variable (hsk : MalcevCharacters.SecondKind c) (hmono : Monotone w) +variable (hK : ∀ k (g : G),g∈K.level k ↔ ∀ i,w iProbabilityMixtures.empirical ⌊L (F.state.subseq N)⌋₊ + (fun k=>(QuotientGroup.mk (P (F.state.subseq N) (k:ℤ)) : G⧸Γ))) + atTop (𝓝 (actualPointMixture c Γ B F)) := by + let F:=coveredFactorization c Γ B s K w hsk hmono hK h0 h1 hs P hP L hL + exact ⟨F,actual_weak_point_law c Γ B F hL ht⟩ + +end AllLevelFactorization + +end +end +end + +end OAI diff --git a/lean/OAI/Combinatorics/SumProduct/Alignment/AllLevel14.lean b/lean/OAI/Combinatorics/SumProduct/Alignment/AllLevel14.lean new file mode 100644 index 0000000000000000000000000000000000000000..3c08499a19ae459ef9edad9512cff734ad92fb31 --- /dev/null +++ b/lean/OAI/Combinatorics/SumProduct/Alignment/AllLevel14.lean @@ -0,0 +1,266 @@ +import Mathlib +import OAI.Combinatorics.SumProduct.Alignment.RationalLattice23 +import OAI.Combinatorics.SumProduct.Alignment.WordPlan04 +import OAI.Geometry.NilpotentCharts.Main + +namespace OAI + +open scoped BigOperators +section +section +noncomputable section +open MeasureTheory Filter Topology +open scoped NNReal ENNReal +end + +end + +section + + + + +noncomputable section +namespace AllLevelFactorization.Factorization.ResidueCover +open RationalLattice CubeFaces CubeLocalHaar MalcevCharacters +open ConstructedWordPlan.GlobalWordPlan +variable {G : Type} [Group G] [TopologicalSpace G] [IsTopologicalGroup G] +variable {n s : ℕ} {c : RealCoordinates G n} {Γ : Subgroup G} +variable {K : Filtration G} {P : ℕ → ℤ → G} {L : ℕ → ℝ} +variable {F : Factorization c Γ s K P L} {r : Fin F.period} (C : F.ResidueCover r) + +def pointEvaluation (_C : F.ResidueCover r) : CubeGroup (ι:=Empty) (F:=F) →* F.state.domain.Carrier where + toFun g:=g.val ∅ + map_one':=rfl + map_mul' _ _:=rfl +omit [IsTopologicalGroup G] in +lemma pointEvaluation_continuous : Continuous (C.pointEvaluation):= + (continuous_apply ∅).comp continuous_subtype_val + +lemma pointEvaluation_rational (g : CubeGroup (ι:=Empty) (F:=F)) + (hg : IsRational C.pivotChart.chart g) : IsRational C.chart (C.pointEvaluation g) := by + apply rationalHom_of_lattice C.chart C.pivotChart.chart C.pivotChart.secondKind + C.pointEvaluation C.pointEvaluation_continuous C.pointLattice C.pivotChart.integer_lattice + (fun h hh=>?_) g hg + have he : h.val ∅∈C.lattice:=hh ∅ + intro i + obtain ⟨z,hz⟩:=(C.integer_lattice _).mp he i + exact ⟨(z:ℚ),by simpa only [Rat.cast_intCast,pointEvaluation,MonoidHom.coe_mk,OneHom.coe_mk] using hz.symm⟩ + +def pivotProjection : CubeGroup (ι:=Empty) (F:=F) →* G:= + F.state.domain.embed.comp C.pointEvaluation +omit [IsTopologicalGroup G] in +lemma pivotProjection_continuous : Continuous C.pivotProjection:= + F.state.domain.continuous.comp C.pointEvaluation_continuous +lemma pivotProjection_rational (g : CubeGroup (ι:=Empty) (F:=F)) + (hg : IsRational C.pivotChart.chart g) : IsRational c (C.pivotProjection g):= + F.state.domain.rational_image _ ((C.rational_iff _).mp (C.pointEvaluation_rational g hg)) + +lemma pivotImage_mk (β : ℝ) (g : CubeGroup (ι:=Empty) (F:=F)) : + C.pivotImage β (QuotientGroup.mk g)= + QuotientGroup.mk (F.smoothLimit β*C.pivotProjection g*F.residue r) := by + change F.smoothLimit β • C.pointImage (QuotientGroup.mk g)=_ + rw [pointImage,EmbeddedCubeHaar.coverImage_mk] + change (QuotientGroup.mk (F.smoothLimit β*(C.pivotProjection g*F.residue r)) : G⧸Γ)=_ + rw [mul_assoc] + +lemma pivotImage_expQuotient (β : ℝ) (z : Fin C.pivotChart.dim → ℝ) : + C.pivotImage β (expQuotient C.pivotChart.chart C.pointLattice z)= + QuotientGroup.mk (F.smoothLimit β*C.pivotProjection (canonicalExp C.pivotChart.chart z)*F.residue r) := + C.pivotImage_mk β _ + +end AllLevelFactorization.Factorization.ResidueCover +end + +end + +section + + + + +noncomputable section +namespace AllLevelFactorization.Factorization.ResidueCover +open RationalLattice CubeFaces CubeLocalHaar MalcevCharacters +open ConstructedWordPlan.GlobalWordPlan ConstructedWordPlan.RationalPivotPlan +variable {G : Type} [Group G] [TopologicalSpace G] [IsTopologicalGroup G] +variable {k s : ℕ} {c : RealCoordinates G k} {Γ : Subgroup G} +variable {K : Filtration G} {P : ℕ → ℤ → G} {L : ℕ → ℝ} +variable {E : Factorization c Γ s K P L} {r : Fin E.period} (C : E.ResidueCover r) +variable {n : ℕ} (D : Pivot n) +variable {X : Type} [TopologicalSpace X] +variable {Y : Fin D.targets → Type} [∀ j,MulAction (Shifts D) (Y j)] +variable (π : (j : Fin D.targets) → (G⧸Γ) → Y j) +variable (A : Fin D.targets → Type) [∀ j,Group (A j)] +variable [∀ j,TopologicalSpace (A j)] [∀ j,IsTopologicalGroup (A j)] +variable (dim : Fin D.targets → ℕ) (d : ∀ j,RealCoordinates (A j) (dim j)) +variable (Λ : ∀ j,Subgroup (A j)) (cover : ∀ j,CoveredLattice (d j) (Λ j)) +variable (p : ∀ j,G →* A j) (hp : ∀ j,Continuous (p j)) +variable (hrat : ∀ j g,IsRational c g → IsRational (d j) (p j g)) +variable (read : ∀ j,(A j)⧸Λ j → Y j) +variable (hread : ∀ j g,π j (QuotientGroup.mk g)=read j (QuotientGroup.mk (p j g))) +variable (sym : (e : Fin D.pairs) → A (D.owner e) →* A (D.owner e)) +variable (hsym : ∀ e,Continuous (sym e)) +variable (hown : ∀ e x,read (D.owner e) (QuotientGroup.mk (sym e x))= + unitShift D e • read (D.owner e) (QuotientGroup.mk x)) + + + +def projectedPhysicalData (β : ℝ) + (hfaces : ∀ e,AffineOrbitRestriction.PreservesPhysicalFaces (Λ (D.owner e)) + ((p (D.owner e)).comp C.pivotProjection).range (p (D.owner e) (E.smoothLimit β)) + (p (D.owner e) (E.residue r)) + (LeibmanSquare.mapFiltration C.pointFiltration ((p (D.owner e)).comp C.pivotProjection).rangeRestrict) + (sym e) s) : CoveredPhysicalData D C.pivotChart.chart C.pointFiltration C.pointLattice + π (C.pivotImage β) s where + A:=A + dim:=dim + chart:=d + Λ:=Λ + cover:=cover + offset:=fun j=>p j (E.smoothLimit β) + residue:=fun j=>p j (E.residue r) + residue_rational:=fun j=>hrat j _ (E.residue_rational r) + projection:=fun j=>(p j).comp C.pivotProjection + continuous:=fun j=>(hp j).comp C.pivotProjection_continuous + rational:=fun j g hg=>hrat j _ (C.pivotProjection_rational g hg) + physical:=read + physicalProjection:=by + intro j z + rw [C.pivotImage_expQuotient,hread] + simp only [map_mul,MonoidHom.comp_apply] + symmetry:=sym + symmetryContinuous:=hsym + preservesPhysicalFaces:=hfaces + ownPhysical:=fun e y=>hown e _ + +end AllLevelFactorization.Factorization.ResidueCover +end + +end + +section + + + + +noncomputable section +namespace AffineOrbitRestriction +open CubeFaces +variable {G A : Type} [Group G] [Group A] +variable [TopologicalSpace A] [IsTopologicalGroup A] +variable (H : Filtration G) (p : G →* A) (Λ : Subgroup A) (h σ : A) (S : A →* A) (s : ℕ) + +omit [TopologicalSpace A] [IsTopologicalGroup A] in +lemma physical_faces_of_projected_cubes + (hp : ∀ k ≤ s,∀ f∈cube (ι:=Fin (k+1)) H Finset.univ 0, + ∃ g∈cube (ι:=Fin (k+1)) H Finset.univ 0,∀ w, + (QuotientGroup.mk (if Fin.last k∈w then S (h*p (f w)*σ) else h*p (f w)*σ) : A⧸Λ)= + QuotientGroup.mk (h*p (g w)*σ)) : + PreservesPhysicalFaces Λ p.range h σ (LeibmanSquare.mapFiltration H p.rangeRestrict) S s := by + intro k hk f hf + obtain ⟨a,ha,he⟩:=exists_cube_lift p.rangeRestrict H + (LeibmanSquare.mapFiltration H p.rangeRestrict) (fun _=>rfl) Finset.univ 0 f hf + obtain ⟨b,hb,hphys⟩:=hp k hk a ha + refine ⟨vertexMap p.rangeRestrict b,?_,?_⟩ + · rw [←map_cube p.rangeRestrict H (LeibmanSquare.mapFiltration H p.rangeRestrict) (fun _=>rfl)] + exact ⟨b,hb,rfl⟩ + · intro w + have hw:=congrArg Subtype.val (he w) + change p (a w)=(f w:A) at hw + simpa only [vertexMap_apply,MonoidHom.coe_rangeRestrict,hw] using hphys w + +variable {Q : Type} [Group Q] (T : Filtration Q) (e : Q →* G) + +omit [TopologicalSpace A] [IsTopologicalGroup A] in +lemma physical_faces_of_filtered_cover + (he : ∀ j,(T.level j).map e=H.level j) + (hp : ∀ k ≤ s,∀ f∈cube (ι:=Fin (k+1)) H Finset.univ 0, + ∃ g∈cube (ι:=Fin (k+1)) H Finset.univ 0,∀ w, + (QuotientGroup.mk (if Fin.last k∈w then S (h*p (f w)*σ) else h*p (f w)*σ) : A⧸Λ)= + QuotientGroup.mk (h*p (g w)*σ)) : + PreservesPhysicalFaces Λ (p.comp e).range h σ + (LeibmanSquare.mapFiltration T (p.comp e).rangeRestrict) S s := by + apply physical_faces_of_projected_cubes T (p.comp e) Λ h σ S s + intro k hk f hf + have hmf : vertexMap e f∈cube H Finset.univ 0:=by + rw [←map_cube e T H he] + exact ⟨f,hf,rfl⟩ + obtain ⟨g,hg,hphys⟩:=hp k hk (vertexMap e f) hmf + obtain ⟨b,hb,hbe⟩:=exists_cube_lift e T H he Finset.univ 0 g hg + refine ⟨b,hb,?_⟩ + intro w + simpa only [MonoidHom.comp_apply,vertexMap_apply,hbe] using hphys w + +end AffineOrbitRestriction +end + +end + +section + + + + +noncomputable section +namespace CubeFaces +variable {G : Type*} [Group G] (H : Filtration G) + +lemma empty_cube (k : ℕ) : cube (ι:=Empty) H Finset.univ k= + (H.level k).map (face ∅) := by + have hd : (default : Finset Empty)=∅:=Finset.eq_empty_of_isEmpty _ + simp [cube,Finset.univ_eq_empty,hd] +lemma empty_maxLevel (k : ℕ) : CubeMaxFiltration.level (ι:=Empty) H Finset.univ k= + (H.level k).map (face ∅) := by + have hd : (default : Finset Empty)=∅:=Finset.eq_empty_of_isEmpty _ + simp [CubeMaxFiltration.level,Finset.univ_eq_empty,hd] + +def emptyEvaluation : cube (ι:=Empty) H Finset.univ 0 →* G where + toFun g:=g.val ∅ + map_one' :=rfl + map_mul' _ _:=rfl + +lemma empty_level_iff (k : ℕ) (g : cube (ι:=Empty) H Finset.univ 0) : + g∈(CubeMaxFiltration.filtration H Finset.univ).level k ↔ + emptyEvaluation H g∈H.level k := by + change g.val∈CubeMaxFiltration.level H Finset.univ k ↔ _ + rw [empty_maxLevel] + constructor + · rintro ⟨a,ha,he⟩ + have he':=congrFun he ∅ + simpa only [face_apply,Finset.empty_subset,ite_true,emptyEvaluation,MonoidHom.coe_mk,OneHom.coe_mk] using he' ▸ ha + · intro hg + refine ⟨emptyEvaluation H g,hg,?_⟩ + ext w + have hw : w=∅:=Finset.eq_empty_of_isEmpty w + subst w + simp [face_apply,emptyEvaluation] + +def emptyConstant (h0 : H.level 0=⊤) : G →* cube (ι:=Empty) H Finset.univ 0 where + toFun g:=⟨face ∅ g,by + rw [empty_cube] + exact ⟨g,by simp [h0],rfl⟩⟩ + map_one':=Subtype.ext (map_one (face ∅)) + map_mul' g h:=Subtype.ext (map_mul (face ∅) g h) + +@[simp] lemma emptyEvaluation_constant (h0 : H.level 0=⊤) (g : G) : + emptyEvaluation H (emptyConstant H h0 g)=g := by + simp [emptyEvaluation,emptyConstant,face_apply] + +lemma emptyEvaluation_levels (h0 : H.level 0=⊤) (k : ℕ) : + ((CubeMaxFiltration.filtration H Finset.univ).level k).map (emptyEvaluation H)=H.level k := by + ext g + constructor + · rintro ⟨a,ha,rfl⟩ + exact (empty_level_iff H k a).mp ha + · intro hg + exact ⟨emptyConstant H h0 g,(empty_level_iff H k _).mpr (by simpa using hg), + emptyEvaluation_constant H h0 g⟩ + +end CubeFaces + +end +end +end + +end OAI diff --git a/lean/OAI/Combinatorics/SumProduct/Alignment/AllLevel15.lean b/lean/OAI/Combinatorics/SumProduct/Alignment/AllLevel15.lean new file mode 100644 index 0000000000000000000000000000000000000000..51935e99c18113e046f59bcbea4088439e44f42f --- /dev/null +++ b/lean/OAI/Combinatorics/SumProduct/Alignment/AllLevel15.lean @@ -0,0 +1,283 @@ +import Mathlib +import OAI.Combinatorics.SumProduct.Alignment.AllLevel14 +import OAI.Geometry.NilpotentCharts.Main + +namespace OAI + +open scoped BigOperators +section +section +noncomputable section +end + +end + +section + + + + +noncomputable section +open MeasureTheory Topology +namespace AllLevelFactorization.Factorization.ResidueCover +open RationalLattice CubeFaces PhysicalCubeMaps +variable {G A : Type} [Group G] [TopologicalSpace G] [IsTopologicalGroup G] +variable [Group A] [TopologicalSpace A] [IsTopologicalGroup A] +variable {n s : ℕ} {c : RealCoordinates G n} {Γ : Subgroup G} +variable {K : Filtration G} {P : ℕ → ℤ → G} {L : ℕ → ℝ} +variable {F : Factorization c Γ s K P L} {r : Fin F.period} (C : F.ResidueCover r) + +omit [IsTopologicalGroup G] in +lemma pointEvaluation_levels (j : ℕ) : + (C.pointFiltration.level j).map C.pointEvaluation=F.state.domain.filtration.level j := + emptyEvaluation_levels F.state.domain.filtration F.state.domain.zero_top j + +variable [∀ k : ℕ,MeasurableSpace (C.CubeSpace (ι:=Fin (k+1)))] +variable [∀ k : ℕ,BorelSpace (C.CubeSpace (ι:=Fin (k+1)))] +variable [CompactSpace (G⧸Γ)] [MeasurableSpace (G⧸Γ)] [BorelSpace (G⧸Γ)] +variable [SecondCountableTopology (G⧸Γ)] +variable (Λ : Subgroup A) [MeasurableSpace (A⧸Λ)] [BorelSpace (A⧸Λ)] +variable [T2Space (A⧸Λ)] +variable [SecondCountableTopology (A⧸Λ)] +variable [∀ k : ℕ,HasOuterApproxClosed (Finset (Fin (k+1)) → A⧸Λ)] +variable (p : G →* A) (hp : Continuous p) (hpΓ : ∀ g∈Γ,p g∈Λ) +variable (S : A →* A) (hS : Continuous S) (hSΛ : ∀ g∈Λ,S g∈Λ) +variable (β : ℝ) + + + +omit [IsTopologicalGroup A] [CompactSpace (G⧸Γ)] + [∀ k : ℕ,HasOuterApproxClosed (Finset (Fin (k+1)) → A⧸Λ)] in +theorem physical_faces_of_marginal_haar + (hinv : ∀ k ≤ s,Measure.map + (upperFace (Fin.last k) (NonnormalCoset.map Λ Λ S hS hSΛ)) + (C.marginalCubeHaar β (vertices (ι:=Fin (k+1)) (NonnormalCoset.map Γ Λ p hp hpΓ)) : + Measure (Finset (Fin (k+1)) → A⧸Λ))= + (C.marginalCubeHaar β (vertices (ι:=Fin (k+1)) (NonnormalCoset.map Γ Λ p hp hpΓ)) : + Measure (Finset (Fin (k+1)) → A⧸Λ))) : + AffineOrbitRestriction.PreservesPhysicalFaces Λ (p.comp C.pivotProjection).range + (p (F.smoothLimit β)) (p (F.residue r)) + (LeibmanSquare.mapFiltration C.pointFiltration (p.comp C.pivotProjection).rangeRestrict) S s := by + apply AffineOrbitRestriction.physical_faces_of_filtered_cover F.state.domain.filtration + (p.comp F.state.domain.embed) Λ (p (F.smoothLimit β)) (p (F.residue r)) S s + C.pointFiltration C.pointEvaluation C.pointEvaluation_levels + intro k hk f hf + obtain ⟨g,hg⟩:=C.physical_cube_image_preserved β + (vertices (ι:=Fin (k+1)) (NonnormalCoset.map Γ Λ p hp hpΓ)) + (upperFace (Fin.last k) (NonnormalCoset.map Λ Λ S hS hSΛ)) (hinv k hk) ⟨f,hf⟩ + refine ⟨g.val,g.property,?_⟩ + intro w + have hw:=congrFun hg w + simp only [vertices_apply,upperFace_apply] at hw + dsimp only [NonnormalCoset.map,ContinuousMap.coe_mk,Quotient.lift_mk] at hw + by_cases he : Fin.last k∈w + · simpa only [he,ite_true,MonoidHom.comp_apply,map_mul] using hw + · simpa only [he,ite_false,MonoidHom.comp_apply,map_mul] using hw + +end AllLevelFactorization.Factorization.ResidueCover +end + +end + +section + + + + +noncomputable section +open MeasureTheory Topology +namespace AllLevelFactorization.Factorization.ResidueCover +open RationalLattice CubeFaces CubeLocalHaar MalcevCharacters PhysicalCubeMaps +open ConstructedWordPlan.GlobalWordPlan ConstructedWordPlan.RationalPivotPlan +variable {G : Type} [Group G] [TopologicalSpace G] [IsTopologicalGroup G] +variable {k s : ℕ} {c : RealCoordinates G k} {Γ : Subgroup G} +variable {K : Filtration G} {P : ℕ → ℤ → G} {L : ℕ → ℝ} +variable {E : Factorization c Γ s K P L} {r : Fin E.period} (C : E.ResidueCover r) +variable [∀ k : ℕ,MeasurableSpace (C.CubeSpace (ι:=Fin (k+1)))] +variable [∀ k : ℕ,BorelSpace (C.CubeSpace (ι:=Fin (k+1)))] +variable [CompactSpace (G⧸Γ)] [MeasurableSpace (G⧸Γ)] [BorelSpace (G⧸Γ)] +variable [SecondCountableTopology (G⧸Γ)] +variable {n : ℕ} (D : Pivot n) +variable {Y : Fin D.targets → Type} [∀ j,MulAction (Shifts D) (Y j)] +variable (π : (j : Fin D.targets) → (G⧸Γ) → Y j) +variable (A : Fin D.targets → Type) [∀ j,Group (A j)] +variable [∀ j,TopologicalSpace (A j)] [∀ j,IsTopologicalGroup (A j)] +variable (dim : Fin D.targets → ℕ) (d : ∀ j,RealCoordinates (A j) (dim j)) +variable (Λ : ∀ j,Subgroup (A j)) (cover : ∀ j,CoveredLattice (d j) (Λ j)) +variable [∀ j,MeasurableSpace ((A j)⧸Λ j)] [∀ j,BorelSpace ((A j)⧸Λ j)] +variable [∀ j,T2Space ((A j)⧸Λ j)] [∀ j,SecondCountableTopology ((A j)⧸Λ j)] +variable [∀ j,∀ k : ℕ,HasOuterApproxClosed (Finset (Fin (k+1)) → (A j)⧸Λ j)] +variable (p : ∀ j,G →* A j) (hp : ∀ j,Continuous (p j)) +variable (hpΓ : ∀ j g,g∈Γ → p j g∈Λ j) +variable (hrat : ∀ j g,IsRational c g → IsRational (d j) (p j g)) +variable (read : ∀ j,(A j)⧸Λ j → Y j) +variable (hread : ∀ j g,π j (QuotientGroup.mk g)=read j (QuotientGroup.mk (p j g))) +variable (sym : (e : Fin D.pairs) → A (D.owner e) →* A (D.owner e)) +variable (hsym : ∀ e,Continuous (sym e)) +variable (hsymΛ : ∀ e g,g∈Λ (D.owner e) → sym e g∈Λ (D.owner e)) +variable (hown : ∀ e x,read (D.owner e) (QuotientGroup.mk (sym e x))= + unitShift D e • read (D.owner e) (QuotientGroup.mk x)) + +def physicalData_of_haar (β : ℝ) + (hinv : ∀ e : Fin D.pairs,∀ k ≤ s,Measure.map + (upperFace (Fin.last k) (NonnormalCoset.map (Λ (D.owner e)) (Λ (D.owner e)) + (sym e) (hsym e) (hsymΛ e))) + (C.marginalCubeHaar β (vertices (ι:=Fin (k+1)) + (NonnormalCoset.map Γ (Λ (D.owner e)) (p (D.owner e)) (hp (D.owner e)) (hpΓ (D.owner e)))) : + Measure (Finset (Fin (k+1)) → (A (D.owner e))⧸Λ (D.owner e)))= + (C.marginalCubeHaar β (vertices (ι:=Fin (k+1)) + (NonnormalCoset.map Γ (Λ (D.owner e)) (p (D.owner e)) (hp (D.owner e)) (hpΓ (D.owner e)))) : + Measure (Finset (Fin (k+1)) → (A (D.owner e))⧸Λ (D.owner e)))) : + CoveredPhysicalData D C.pivotChart.chart C.pointFiltration C.pointLattice + π (C.pivotImage β) s := + C.projectedPhysicalData D π A dim d Λ cover p hp hrat read hread sym hsym hown β + (fun e=>C.physical_faces_of_marginal_haar (Λ (D.owner e)) (p (D.owner e)) + (hp (D.owner e)) (hpΓ (D.owner e)) (sym e) (hsym e) (hsymΛ e) β (hinv e)) + +end AllLevelFactorization.Factorization.ResidueCover +end + +end + +section + + + + +noncomputable section +namespace RationalLattice.PolynomialArrays +open CubeFaces MalcevCharacters +variable {G : Type} [Group G] [TopologicalSpace G] [IsTopologicalGroup G] +variable {n q : ℕ} (c : RealCoordinates G n) (hsk : SecondKind c) +variable (A : Filtration G) (w : Fin n → ℕ) +variable (hA : ∀ k g,g∈A.level k ↔ ∀ i,w iv • x) := + shifted_continuous c hsk A w hA Γ (ρ v.toAdd) + +lemma shiftAction_mk (v : Multiplicative (ι → ℤ)) (f : group (q:=q) c hsk A w hA) : + letI := shiftAction c hsk A w hA Γ ρ + v • (QuotientGroup.mk f : (group (q:=q) c hsk A w hA)⧸lattice c hsk A w hA Γ)= + QuotientGroup.mk (shift c hsk A w hA (fun j=>(ρ v.toAdd j:ℝ)) f) := rfl + +lemma readout_shiftAction (u : Fin q → ℤ) (v : Multiplicative (ι → ℤ)) + (x : (group (q:=q) c hsk A w hA)⧸lattice c hsk A w hA Γ) : + letI := shiftAction c hsk A w hA Γ ρ + readout c hsk A w hA Γ u (v • x)=readout c hsk A w hA Γ (u+ρ v.toAdd) x := + readout_shifted c hsk A w hA Γ u (ρ v.toAdd) x + +end RationalLattice.PolynomialArrays +end + +end + +section + + +noncomputable section +open MeasureTheory Filter Topology +open scoped NNReal ENNReal +namespace AllLevelFactorization.Factorization +open RationalLattice CubeFaces ResidueCover MalcevCharacters PhysicalCubeMaps +open ConstructedWordPlan.GlobalWordPlan +open ConstructedWordPlan.AlignmentScales ConstructedWordPlan.RationalPivotPlan +variable {G : Type} [Group G] [TopologicalSpace G] [IsTopologicalGroup G] +variable {k s : ℕ} {c : RealCoordinates G k} {Δ : Subgroup G} +variable {K : Filtration G} {P : ℕ → ℤ → G} {L : ℕ → ℝ} +variable (E : Factorization c Δ s K P L) +variable (C : (r : Fin E.period) → E.ResidueCover r) +variable [∀ r,MeasurableSpace ((C r).CubeSpace (ι:=Empty))] +variable [∀ r,BorelSpace ((C r).CubeSpace (ι:=Empty))] +variable [MeasurableSpace (G⧸Δ)] [BorelSpace (G⧸Δ)] +variable [CompactSpace (G⧸Δ)] [SecondCountableTopology (G⧸Δ)] +variable [HasOuterApproxClosed (G⧸Δ)] [MeasurableSingletonClass (G⧸Δ)] +variable (Γ : Subgroup G) (hle : Δ≤Γ) +variable [MeasurableSpace (G⧸Γ)] [BorelSpace (G⧸Γ)] [MeasurableSingletonClass (G⧸Γ)] +variable {n r : ℕ} (hs : 1 ≤ s) (D : Pivot n) (F B : Finset (Scale n)) +variable (q₀ : ℕ) (hq₀ : pivotModulus s r hs D F B∣q₀) +variable (b : Scale n) (hb : b∈B) {τ : ℝ} (hτ : 0<τ) +variable (Y : Fin D.targets → Type) [∀ j,TopologicalSpace (Y j)] +variable [∀ j,MulAction (Shifts D) (Y j)] +variable (π : (j : Fin D.targets) → (G⧸Γ) → Y j) +variable (Read : (j : Fin D.targets) → ℚ → Y j × Slots D → Fin r → ℝ) +variable (hπ : ∀ j,Continuous (π j)) +variable (hRead : ∀ j a t,Continuous (fun y=>Read j a y t)) +variable (hS : ∀ j (a : Shifts D),Continuous (fun y : Y j=>a • y)) +variable [∀ a k,MeasurableSpace ((C a).CubeSpace (ι:=Fin (k+1)))] +variable [∀ a k,BorelSpace ((C a).CubeSpace (ι:=Fin (k+1)))] +variable (A : Fin D.targets → Type) [∀ j,Group (A j)] +variable [∀ j,TopologicalSpace (A j)] [∀ j,IsTopologicalGroup (A j)] +variable (dim : Fin D.targets → ℕ) (d : ∀ j,RealCoordinates (A j) (dim j)) +variable (Λ : ∀ j,Subgroup (A j)) (cover : ∀ j,CoveredLattice (d j) (Λ j)) +variable [∀ j,MeasurableSpace ((A j)⧸Λ j)] [∀ j,BorelSpace ((A j)⧸Λ j)] +variable [∀ j,T2Space ((A j)⧸Λ j)] [∀ j,SecondCountableTopology ((A j)⧸Λ j)] +variable [∀ j,∀ k : ℕ,HasOuterApproxClosed (Finset (Fin (k+1)) → (A j)⧸Λ j)] +variable (p : ∀ j,G →* A j) (hp : ∀ j,Continuous (p j)) +variable (hpΓ : ∀ j g,g∈Γ → p j g∈Λ j) +variable (hrat : ∀ j g,IsRational c g → IsRational (d j) (p j g)) +variable (read : ∀ j,(A j)⧸Λ j → Y j) +variable (hread : ∀ j g,π j (QuotientGroup.mk g)=read j (QuotientGroup.mk (p j g))) +variable (sym : (e : Fin D.pairs) → A (D.owner e) →* A (D.owner e)) +variable (hsym : ∀ e,Continuous (sym e)) +variable (hsymΛ : ∀ e g,g∈Λ (D.owner e) → sym e g∈Λ (D.owner e)) +variable (hown : ∀ e x,read (D.owner e) (QuotientGroup.mk (sym e x))= + unitShift D e • read (D.owner e) (QuotientGroup.mk x)) +variable (hinv : ∀ a β (e : Fin D.pairs),∀ k ≤ s,Measure.map + (upperFace (Fin.last k) (NonnormalCoset.map (Λ (D.owner e)) (Λ (D.owner e)) + (sym e) (hsym e) (hsymΛ e))) + ((C a).marginalCubeHaar β (vertices (ι:=Fin (k+1)) + (NonnormalCoset.map Δ (Λ (D.owner e)) (p (D.owner e)) (hp (D.owner e)) + (fun g hg=>hpΓ (D.owner e) g (hle hg)))) : + Measure (Finset (Fin (k+1)) → (A (D.owner e))⧸Λ (D.owner e)))= + ((C a).marginalCubeHaar β (vertices (ι:=Fin (k+1)) + (NonnormalCoset.map Δ (Λ (D.owner e)) (p (D.owner e)) (hp (D.owner e)) + (fun g hg=>hpΓ (D.owner e) g (hle hg)))) : + Measure (Finset (Fin (k+1)) → (A (D.owner e))⧸Λ (D.owner e)))) + +include hπ hRead hS hq₀ hb hτ hrat cover hinv hown hread in + + +omit [BorelSpace (G⧸Γ)] + [∀ j,∀ k : ℕ,HasOuterApproxClosed (Finset (Fin (k+1)) → (A j)⧸Λ j)] in +theorem empirical_success_from_marginal_haar + (hL : ∀ N,0hpΓ j g (hle hg)) hrat read + (fun j g=>hread j g) sym hsym hsymΛ hown β (hinv a β) + exact E.actual_lattice_pivot_empirical_success_mass C Γ hle hs D F B q₀ hq₀ b hb hτ + Y π Read hπ hRead hS M hL ht ReadN he + +end AllLevelFactorization.Factorization + +end +end +end + +end OAI diff --git a/lean/OAI/Combinatorics/SumProduct/Alignment/BinomialDifference01.lean b/lean/OAI/Combinatorics/SumProduct/Alignment/BinomialDifference01.lean new file mode 100644 index 0000000000000000000000000000000000000000..07892c79b82a6c3985b0c3a056448b7e650dad4c --- /dev/null +++ b/lean/OAI/Combinatorics/SumProduct/Alignment/BinomialDifference01.lean @@ -0,0 +1,285 @@ +import Mathlib +import OAI.Combinatorics.SumProduct.Alignment.MalcevTail03 +import OAI.Geometry.NilpotentCharts.Main + +namespace OAI + +section +section +section +section +open scoped BigOperators +noncomputable section +end +end + + + +section +open scoped BigOperators commutatorElement +noncomputable section +namespace CharacterFactorization +open CubeFaces CubePolynomials RationalFactorPeriods RationalLattice MalcevCharacters MalcevTailFactor +variable {G : Type*} [Group G] [TopologicalSpace G] [IsTopologicalGroup G] [T2Space G] +variable (H : Filtration G) {n s : ℕ} (c : RealCoordinates (H.level 2) n) (hsk : SecondKind c) +variable (χ : H.level 2 →* Multiplicative ℝ) (k : Fin n → ℤ) +variable (hχ : ∀ x, (χ x).toAdd = IntegerHyperplane.form k (c.coord x)) +variable (r : Fin s → ℕ) +variable (hlevel : ∀ i (x : H.level 2), x.val ∈ H.level (i.val+2) ↔ + ∀ u : Fin n, u.val < r i → c.coord x u = 0) +variable (hcomm : ∀ a b : G, ⁅a,b⁆ ∈ χ.ker.map (H.level 2).subtype) + + + +theorem uniform_gamma_period_of_rational_lattice (Γ : Subgroup G) + [DiscreteTopology (Γ.comap (H.level 2).subtype)] + (hΓ : Γ.comap (H.level 2).subtype ≤ rationalSubgroup c) + (K : Set (H.level 2)) (hK : IsCompact K) + (hrep : ∀ x : H.level 2, ∃ y ∈ K, (y⁻¹*x).val ∈ Γ) : + ∃ T : ℕ, 0 < T ∧ ∀ a : Fin s → H.level 2, + Function.Periodic (fun z => (QuotientGroup.mk (gamma H c χ k r a z) : G ⧸ Γ)) (T:ℤ) := by + let L := Γ.comap (H.level 2).subtype + let : ConnectedSpace (H.level 2) := c.coord.symm.surjective.connectedSpace c.coord.symm.continuous + let : LocallyCompactSpace (H.level 2) := c.coord.locallyCompactSpace_iff.mpr inferInstance + obtain ⟨T,hT,hper⟩ := uniform_rational_word_period c L hΓ K hK hrep + (rationalGenerator c k r) (generator_rational c k r) + (fun i => i.val+2) (s+2) (fun i => by omega) + refine ⟨T,hT,fun a z => ?_⟩ + have hp := hper (numerator χ a) z + have hm := QuotientGroup.eq.mp hp + exact QuotientGroup.eq.mpr hm + +include hsk hχ hlevel in + + +theorem uniform_smooth_factorization (hbot : H.level s = ⊥) + (Γ : Subgroup G) (hΓ : ∀ x : H.level 2, x.val ∈ Γ ↔ ∀ i, ∃ z : ℤ, c.coord x i = z) + (A C : ℝ) (hC : 0 ≤ C) : + ∃ B > 0, ∃ T : ℕ, 0 < T ∧ + ∀ (g : ℤ → G), g ∈ polynomials H 0 → g 0=1 → g 1 ∈ H.level 1 → + ∃ a : Fin s → H.level 2, + (∀ i, (a i).val ∈ H.level (i.val+2)) ∧ + (∀ z, g z = (orderedWord a (fun i => i.val+2) z).val * g 1 ^ z) ∧ + (∀ z, g z = epsilon H c χ k r a z * residual H c χ k r g a z * gamma H c χ k r a z) ∧ + epsilon H c χ k r a 0=1 ∧ + epsilon H c χ k r a ∈ polynomials H 0 ∧ + gamma H c χ k r a ∈ polynomials H 0 ∧ + residual H c χ k r g a ∈ polynomials (H.refine (χ.ker.map (H.level 2).subtype) hcomm) 0 ∧ + Function.Periodic (fun z => (QuotientGroup.mk (gamma H c χ k r a z) : G ⧸ Γ)) (T:ℤ) ∧ + ∀ L : ℝ, 1 ≤ L → (∀ i, L^(i.val+2)*‖(beta χ a i : UnitAddCircle)‖ ≤ C) → + (∀ z : ℤ, |(z:ℝ)| ≤ A*L → + ‖c.coord (orderedWord (smallCoeff c χ k r a) (fun i => i.val+2) z)‖ ≤ B) ∧ + (∀ z w : ℤ, |(z:ℝ)| ≤ A*L → |(w:ℝ)| ≤ A*L → + ‖c.coord (orderedWord (smallCoeff c χ k r a) (fun i => i.val+2) z * + (orderedWord (smallCoeff c χ k r a) (fun i => i.val+2) w)⁻¹)‖ ≤ (B/L)*|(z:ℝ)-(w:ℝ)|) := by + obtain ⟨B,hB,hsmall⟩ := small_word_smooth c hsk χ k r (fun i => i.val+2) A C hC + obtain ⟨T,hT,hper⟩ := uniform_gamma_period H c χ k r Γ hΓ + refine ⟨B,hB,T,hT,?_⟩ + intro g hg h0 h1 + obtain ⟨a,ha,he,hep,hgp,hrp⟩ := normalized_factorization H c hsk χ k hχ r hlevel hcomm hbot g hg h0 h1 + exact ⟨a,ha,he,factorization_identity H c χ k r g a,epsilon_zero H c χ k r a, + hep,hgp,hrp,hper a,fun L hL ha => hsmall L a hL ha⟩ + +end CharacterFactorization +end +end + + + +section +open _root_.Polynomial _root_.OAI.Polynomial +open scoped BigOperators +noncomputable section +namespace BinomialDifference +variable (R : Type*) [CommRing R] + +def step : Module.End R R[X] := taylor 1-LinearMap.id + +def coefficient (j : ℕ) : R[X] →ₗ[R] R := (aeval (0:R)).toLinearMap ∘ₗ (step R)^j + +lemma step_apply (p : R[X]) : step R p=taylor 1 p-p := rfl +lemma coefficient_apply (j : ℕ) (p : R[X]) : coefficient R j p=(((step R)^j) p).eval 0 := rfl +lemma coefficient_zero (p : R[X]) : coefficient R 0 p=p.eval 0 := rfl +lemma coefficient_succ (j : ℕ) (p : R[X]) : coefficient R (j+1) p=coefficient R j (step R p) := by + simp only [coefficient_apply,pow_succ,Module.End.mul_apply] + +lemma iterate_map {S : Type*} [CommRing S] (φ : R →+* S) (j : ℕ) (p : R[X]) : + (((step R)^j) p).map φ=((step S)^j) (p.map φ) := by + induction j generalizing p with + | zero => rfl + | succ j ih => + rw [pow_succ,Module.End.mul_apply,ih,pow_succ,Module.End.mul_apply] + congr 1 + simp only [step_apply,Polynomial.map_sub,map_taylor,map_one] + +lemma coefficient_map {S : Type*} [CommRing S] (φ : R →+* S) (j : ℕ) (p : R[X]) : + φ (coefficient R j p)=coefficient S j (p.map φ) := by + simp only [coefficient_apply,← iterate_map R φ j p] + rw [eval_map] + simpa only [map_zero] using (eval₂_at_apply (p := ((step R)^j) p) φ 0).symm + +lemma step_degree_lt {p : R[X]} (hp : p≠0) : (step R p).degree omega + | succ j ih => + rw [pow_succ,Module.End.mul_apply] + by_cases hp0 : p=0 + · simp [hp0] + by_cases hq0 : step R p=0 + · simp [hq0] + apply ih + have hh := step_degree_lt R hp0 + rw [degree_eq_natDegree hq0,degree_eq_natDegree hp0] at hh + have hh' : (step R p).natDegree arg 2; rw [P.as_sum_range_C_mul_X_pow' (by omega : P.natDegree + rw [coefficient_zero,choosePolynomial_eval,Ring.choose_zero_ite] + | succ j ih => + rw [coefficient_succ] + cases i with + | zero => simp [step_choose_zero] + | succ i => simp only [step_choose,ih,Nat.add_right_cancel_iff] + + + +lemma coefficient_word {G : Type*} [Group G] {l : ℕ} + (χ : G →* Multiplicative ℝ) (a : Fin l → G) (r : ℕ) (i : Fin l) : + coefficient ℝ (i.val+r) (wordCharacterPolynomial χ a (fun j => j.val+r))=(χ (a i)).toAdd := by + classical + rw [wordCharacterPolynomial,map_sum] + simp only [← smul_eq_C_mul,map_smul,smul_eq_mul,coefficient_choose,Nat.add_right_cancel_iff] + simp only [Fin.val_inj, mul_ite, mul_one, mul_zero] + simpa only [Finset.mem_univ, ite_true] using Finset.sum_ite_eq' Finset.univ i (fun x => (χ (a x)).toAdd) + +end BinomialDifference +end +end + + + +section +open _root_.Polynomial _root_.OAI.Polynomial Finset +open scoped BigOperators +noncomputable section +namespace BinomialDifference + +def conversionBound (s : ℕ) : ℝ := + 1+∑ j∈range (s+1), ∑ i∈range (s+1), |(matrix j i:ℝ)| + +lemma conversionBound_pos (s : ℕ) : 0 sum_nonneg (fun _ _ => abs_nonneg _)) + unfold conversionBound + linarith + +lemma row_bound (s j : ℕ) (hj : j ≤ s) : + (∑ i∈range (s+1), |(matrix j i:ℝ)|) ≤ conversionBound s := by + have h := single_le_sum (fun u (_ : u∈range (s+1)) => + sum_nonneg (fun i (_ : i∈range (s+1)) => abs_nonneg (matrix u i:ℝ))) (mem_range.mpr (by omega : j if hi : k ≤ i then (hc i hi).choose else 0 + have hm (i : ℕ) (hi : k ≤ i) : |P.coeff i-m i| ≤ C/L^i := by + simpa only [m,dite_eq_left hi] using (hc i hi).choose_spec + let z : ℤ := ∑ i∈range (s+1), m i*matrix j i + have he : coefficient ℝ j P-z=∑ i∈range (s+1), (P.coeff i-m i)*(matrix j i:ℝ) := by + rw [coefficient_expansion s j P hP] + simp only [z,Int.cast_sum,Int.cast_mul,← sum_sub_distrib,sub_mul] + have ht (i : ℕ) (hi : i∈range (s+1)) : + |(P.coeff i-m i)*(matrix j i:ℝ)| ≤ (C/L^j)*|(matrix j i:ℝ)| := by + by_cases hij : j ≤ i + · rw [abs_mul] + apply mul_le_mul_of_nonneg_right ((hm i (hj.trans hij)).trans ?_) (abs_nonneg _) + exact div_le_div_of_nonneg_left hC (pow_pos hLp _) (pow_le_pow_right₀ hL hij) + · simp only [matrix_low j i (by omega),Int.cast_zero,mul_zero,abs_zero,le_refl] + have hh : ‖(coefficient ℝ j P : UnitAddCircle)‖ ≤ (conversionBound s*C)/L^j := by + calc + _ = |coefficient ℝ j P-round (coefficient ℝ j P)| := UnitAddCircle.norm_eq + _ ≤ |coefficient ℝ j P-z| := round_le _ _ + _ = |∑ i∈range (s+1), (P.coeff i-m i)*(matrix j i:ℝ)| := by rw [he] + _ ≤ ∑ i∈range (s+1), |(P.coeff i-m i)*(matrix j i:ℝ)| := abs_sum_le_sum_abs _ _ + _ ≤ ∑ i∈range (s+1), (C/L^j)*|(matrix j i:ℝ)| := sum_le_sum ht + _ = (C/L^j)*(∑ i∈range (s+1), |(matrix j i:ℝ)|) := (mul_sum _ _ _).symm + _ ≤ (C/L^j)*conversionBound s := mul_le_mul_of_nonneg_left (row_bound s j hjs) (by positivity) + _ = _ := by ring + simpa only [mul_comm] using (le_div_iff₀ (pow_pos hLp j)).mp hh + · rw [coefficient_eq_zero ℝ j P (by omega)] + simp only [AddCircle.coe_zero,norm_zero,mul_zero] + exact mul_nonneg (conversionBound_pos s).le hC + +open RationalFactorPeriods + + +lemma word_coefficient_bound {G : Type*} [Group G] {l : ℕ} + (χ : G →* Multiplicative ℝ) (a : Fin l → G) (r s : ℕ) + (P : ℝ[X]) (hP : P.natDegree ≤ s) + (he : ∀ z : ℤ, P.eval (z:ℝ)=(χ (orderedWord a (fun i => i.val+r) z)).toAdd) + (L C : ℝ) (hL : 1 ≤ L) (hC : 0 ≤ C) + (hc : ∀ j : ℕ, r ≤ j → ∃ m : ℤ, |P.coeff j-m| ≤ C/L^j) : + ∀ i : Fin l, L^(i.val+r)*‖((χ (a i)).toAdd : UnitAddCircle)‖ ≤ conversionBound s*C := by + have hp : P=wordCharacterPolynomial χ a (fun i => i.val+r) := by + apply Polynomial.eq_of_eval_nat_eq + intro z + simpa only [Int.cast_natCast] using (he (z:ℤ)).trans (wordCharacterPolynomial_eval χ a _ (z:ℤ)).symm + intro i + have hh := coefficient_bound s r P hP L C hL hC hc (i.val+r) (by omega) + rwa [hp,coefficient_word] at hh + +end BinomialDifference + +end +end +end +end +end + +end OAI diff --git a/lean/OAI/Combinatorics/SumProduct/Alignment/Blocks01.lean b/lean/OAI/Combinatorics/SumProduct/Alignment/Blocks01.lean new file mode 100644 index 0000000000000000000000000000000000000000..b8b2e876748652acb561285ce18b50c846cfc60f --- /dev/null +++ b/lean/OAI/Combinatorics/SumProduct/Alignment/Blocks01.lean @@ -0,0 +1,325 @@ +import Mathlib +import OAI.Combinatorics.SumProduct.Alignment.FiniteMenu01 +import OAI.Geometry.NilpotentCharts.Main + +namespace OAI + +open scoped BigOperators +section +noncomputable section +open Filter MeasureTheory +open scoped BigOperators ENNReal Topology +noncomputable section +open scoped BigOperators Topology BoundedContinuousFunction +noncomputable section +open scoped BigOperators +open MeasureTheory Filter Function +noncomputable section +open scoped BigOperators +noncomputable section +open Filter MeasureTheory +open scoped Topology BoundedContinuousFunction NNReal +noncomputable section +open scoped Topology BigOperators +noncomputable section +open scoped Topology BigOperators commutatorElement +noncomputable section +open scoped Topology BoundedContinuousFunction NNReal +namespace SourceChartedMenu +open SourceProductChart SourceFiniteMenu + + + +structure Menu (s : ℕ) where + size : ℕ + G : Fin size → Type + [group : ∀ i, Group (G i)] + [topology : ∀ i, TopologicalSpace (G i)] + [topGroup : ∀ i, IsTopologicalGroup (G i)] + Γ : ∀ i, Subgroup (G i) + chart : ∀ i, Chart s (G i) (Γ i) + metric : ∀ i, MetricSpace (G i ⧸ Γ i) + compatible : ∀ i, QuotientGroup.instTopologicalSpace (Γ i) = + (metric i).toUniformSpace.toTopologicalSpace + +attribute [instance] Menu.group Menu.topology Menu.topGroup +variable {s : ℕ} (M : Menu s) + +abbrev Menu.productG := ∀ i, M.G i +abbrev Menu.productΓ : Subgroup M.productG := productLattice M.G M.Γ + +def Menu.productChart : Chart s M.productG M.productΓ := product M.G M.Γ M.chart + +@[instance_reducible] +def Menu.productMetric : MetricSpace (M.productG ⧸ M.productΓ) := + SourceFiniteMenu.productMetric M.G M.Γ M.metric M.compatible + +lemma Menu.productCompatible : QuotientGroup.instTopologicalSpace M.productΓ = + M.productMetric.toUniformSpace.toTopologicalSpace := rfl + + + +structure Piece (K : ℝ≥0) where + index : Fin M.size + g : M.G index + x : M.G index + obs : (M.G index ⧸ M.Γ index) →ᵇ ℝ + lip : letI : MetricSpace (M.G index ⧸ M.Γ index) := + (M.metric index).replaceTopology (M.compatible index) + LipschitzWith K obs + range : ∀ z, obs z ∈ Set.Icc (0:ℝ) 1 + +variable {M} {K : ℝ≥0} (P : Piece M K) + +def Piece.eval (k : ℤ) : ℝ := P.obs (QuotientGroup.mk (P.g^k*P.x)) + +def Piece.padG : M.productG := Pi.mulSingle P.index P.g +def Piece.padX : M.productG := Pi.mulSingle P.index P.x +def Piece.padObs : (M.productG ⧸ M.productΓ) →ᵇ ℝ := + paddedObservable M.G M.Γ P.index P.obs + +lemma Piece.pad_orbit (k : ℤ) : + P.padObs (QuotientGroup.mk (P.padG^k*P.padX)) = P.eval k := + padded_orbit M.G M.Γ P.index P.obs P.g P.x k + +lemma Piece.pad_lip : + letI : MetricSpace (M.productG ⧸ M.productΓ) := + M.productMetric.replaceTopology M.productCompatible + LipschitzWith K P.padObs := by + let : ∀ i, MetricSpace (M.G i ⧸ M.Γ i) := + fun i => (M.metric i).replaceTopology (M.compatible i) + exact padded_lipschitz M.G M.Γ M.metric M.compatible P.index P.obs K P.lip + +lemma Piece.pad_range (z : M.productG ⧸ M.productΓ) : + P.padObs z ∈ Set.Icc (0:ℝ) 1 := P.range _ + +lemma Piece.pad_bound (z : M.productG ⧸ M.productΓ) : |P.padObs z| ≤ 1 := + abs_le.mpr ⟨(by linarith [(P.pad_range z).1]),(P.pad_range z).2⟩ + +end SourceChartedMenu + + + + + + + +noncomputable section +open scoped BigOperators +namespace SourceBlocks +open ConstructedWordPlan.GlobalWordPlan ConstructedWordPlan.RationalPivotPlan +open SourcePivotPaths +attribute [local instance] Classical.propDecidable +variable {a : ℕ} + + +def Tail (i : Fin a) := {T : Finset (Fin a) // T.Nonempty ∧ ∀ j ∈ T, j < i} +instance blocks01TailFintype (i : Fin a) : Fintype (Tail i) := by unfold Tail; infer_instance + + +def Added (i : Fin a) (T A : Finset (Fin a)) : Prop := + ∃ (P : Finset (Fin a)) (j : Fin a), P.Nonempty ∧ + (∀ p ∈ P, ∀ t ∈ T, p < t) ∧ (∀ t ∈ T, t < j) ∧ j < i ∧ A = insert j P + +lemma Added.lt {i : Fin a} {T A : Finset (Fin a)} + (hT : T.Nonempty) (h : Added i T A) : ∀ x ∈ A, x < i := by + obtain ⟨P,j,hP,hPT,hTj,hji,rfl⟩ := h + obtain ⟨t,ht⟩ := hT + intro x hx + rcases Finset.mem_insert.mp hx with rfl | hx + · exact hji + · exact (hPT x hx t ht).trans ((hTj t ht).trans hji) + +lemma Added.before {i : Fin a} {T A : Finset (Fin a)} (h : Added i T A) : + ∃ x ∈ A, ∀ t ∈ T, x < t := by + obtain ⟨P,j,hP,hPT,hTj,hji,rfl⟩ := h + obtain ⟨x,hx⟩ := hP + exact ⟨x,Finset.mem_insert_of_mem hx,hPT x hx⟩ + +lemma Added.disjoint {i : Fin a} {T A : Finset (Fin a)} (h : Added i T A) : + Disjoint A T := by + obtain ⟨P,j,hP,hPT,hTj,hji,rfl⟩ := h + apply Finset.disjoint_left.mpr + intro x hx ht + rcases Finset.mem_insert.mp hx with rfl | hx + · exact lt_irrefl _ (hTj _ ht) + · exact lt_irrefl x (hPT x hx x ht) + +def tailEnum (i : Fin a) : Fin (Fintype.card (Tail i)) ≃ Tail i := (Fintype.equivFin _).symm + +def PairIndex (i : Fin a) := + {z : Fin (Fintype.card (Tail i)) × Finset (Fin a) // Added i (tailEnum i z.1).val z.2} +instance blocks01PairIndexFintype (i : Fin a) : Fintype (PairIndex i) := by unfold PairIndex; infer_instance + +def pairEnum (i : Fin a) : Fin (Fintype.card (PairIndex i)) ≃ PairIndex i := (Fintype.equivFin _).symm + + +def pivot (i : Fin a) : Pivot a where + index := i + targets := Fintype.card (Tail i) + tail t := (tailEnum i t).val + pairs := Fintype.card (PairIndex i) + owner e := (pairEnum i e).val.1 + added e := (pairEnum i e).val.2 + tail_lt t := (tailEnum i t).property.2 + added_lt e := (pairEnum i e).property.lt (tailEnum i (pairEnum i e).val.1).property.1 + before e := (pairEnum i e).property.before + +@[simp] lemma pivot_index (i : Fin a) : (pivot i).index = i := rfl + +lemma pivot_disjoint (i : Fin a) (e : Fin (pivot i).pairs) : + Disjoint ((pivot i).added e) ((pivot i).tail ((pivot i).owner e)) := + (pairEnum i e).property.disjoint + + +def pivots (a : ℕ) : List (Pivot a) := List.ofFn pivot + +lemma pivots_ordered : (pivots a).Pairwise (fun D E => D.index < E.index) := + List.pairwise_ofFn.mpr fun _ _ h => h + +lemma mem_pivots (i : Fin a) : pivot i ∈ pivots a := List.mem_ofFn.mpr ⟨i,rfl⟩ + + + +abbrev Block (a : ℕ) := Σ i : Fin a, Tail i + +def Block.set (B : Block a) : Finset (Fin a) := insert B.1 B.2.val + +def Block.target (B : Block a) : Fin (pivot B.1).targets := (tailEnum B.1).symm B.2 + +@[simp] lemma block_target_tail (B : Block a) : (pivot B.1).tail B.target = B.2.val := by + exact congrArg Subtype.val ((tailEnum B.1).apply_symm_apply B.2) + +lemma block_target_set (B : Block a) : + block (pivot B.1).index (pivot B.1).tail B.target = B.set := by + simp only [block, pivot_index, block_target_tail, Block.set] + + + +lemma added_exists_iff (B : Block a) (A : Finset (Fin a)) : + (∃ e : Fin (pivot B.1).pairs, (pivot B.1).owner e = B.target ∧ (pivot B.1).added e = A) ↔ + Added B.1 B.2.val A := by + constructor + · rintro ⟨e,he,ha⟩ + have hp := (pairEnum B.1 e).property + change Added B.1 ((pivot B.1).tail ((pivot B.1).owner e)) ((pivot B.1).added e) at hp + simpa only [he,ha,block_target_tail] using hp + · intro h + let z : PairIndex B.1 := ⟨(B.target,A),by + change Added B.1 ((pivot B.1).tail B.target) A + rwa [block_target_tail]⟩ + refine ⟨(pairEnum B.1).symm z,?_,?_⟩ + · exact congrArg (fun v : PairIndex B.1 => v.val.1) ((pairEnum B.1).apply_symm_apply z) + · exact congrArg (fun v : PairIndex B.1 => v.val.2) ((pairEnum B.1).apply_symm_apply z) + +end SourceBlocks + + + + + + + +noncomputable section +open Filter MeasureTheory +open scoped Topology BigOperators BoundedContinuousFunction NNReal +namespace SourceChartedAlignment +open ConstructedWordPlan.GlobalWordPlan ConstructedWordPlan.AlignmentScales +open SourceIntegerArrays.GlobalJoint.SourceFrozenFamily SourcePivotPaths SourceRawPrefix +variable {a : ℕ} + + +structure Realizes (s r : ℕ) (C : CommonScales a) (D : Pivot a) + (S : ℕ → ScalarModels D r) where + scales : PivotScales C D + model : ChartedModels s r D + eq_model : ∀ N, S N = model.scalar C scales N + +variable (s r : ℕ) (hs : 1 ≤ s) (C : CommonScales a) + + + +theorem charted_step (D : Pivot a) (Ss : ℕ → ScalarModels D r) + (R : Realizes s r C D Ss) (Fs B : Finset (Scale a)) + (hFs : ∀ b ∈ Fs, ∀ j, 0 < b j) (b : Scale a) (hb : b ∈ B) + (hpos : ∀ j, 0 < b j) (q₀ : ℕ) (hq₀ : 0 < q₀) + (hterm : terminalDenom D s r hs Fs b ∣ q₀) + (hplan : pivotModulus s r hs D Fs B ∣ q₀) (τ : ℝ) (hτ : 0 < τ) + (ε : ℝ) (hε : 0 < ε) : + ∀ᶠ N in atTop, ∀ E : Set (Fin a → ℕ), Earlier D.index E → + gain s r hs D Fs * (C.law N).real E ≤ + (C.law N).real {u | u ∈ E ∧ success D r s hs Fs (Ss N) (C.ht N) b u (u D.index) τ} + ε := by + let F := R.model + let P := R.scales + have he := source_uniform_prefix_extension D s r hs Fs q₀ b F.G F.Γ F.dim F.coords + F.second F.filtration F.weight F.level_iff F.weight_pos F.lattice_iff F.weight_mono + F.level0 F.level1 F.step C.M P.J P.R P.H C.L C.ht F.g F.x F.obs C.w C.X + C.hw C.hX C.hXt C.hWM C.hM C.hMs P.hJ P.hRJ C.hL C.hLs C.hWL C.hML C.hLexact + (fun t j => C.hXL _) P.hH P.hRrad P.hdom P.hxdom C.hpowWM hq₀ C.hht P.hheight + P.hdisj hterm hpos hFs P.hratio F.metric F.compatible F.K F.B F.lip F.bound + B hb hplan τ hτ ε hε + filter_upwards [he] with N hN + rw [R.eq_model N] + exact hN + + + +theorem local_of_charts (Ss : ℕ → (D : Pivot a) → ScalarModels D r) + (Ds : List (Pivot a)) (R : ∀ D ∈ Ds, Realizes s r C D (fun N => Ss N D)) + (B : Finset (Scale a)) (hB : ∀ b ∈ B, ∀ j, 0 < b j) + (q₀ : ℕ) (hq₀ : 0 < q₀) (hq : planModulus s r hs Ds B ∣ q₀) + (b : Scale a) (hb : b ∈ B) (τ : ℝ) (hτ : 0 < τ) : + localEstimates s r hs τ C.law Ss C.ht Ds b := by + induction Ds generalizing B b with + | nil => trivial + | cons D Ds ih => + refine ⟨?_, ?_⟩ + · exact charted_step s r hs C D (fun N => Ss N D) (R D (by simp)) + (multipliers (sourcePlan s r hs Ds)) B (source_multipliers_pos s r hs Ds) + b hb (hB b hb) q₀ hq₀ ((planModulus_terminal s r hs D Ds B b hb).trans hq) + ((planModulus_head s r hs D Ds B).trans hq) τ hτ + · intro p hp + exact ih (fun D hD => R D (List.mem_cons_of_mem _ hD)) + (nextScales s r hs D Ds B) (nextScales_pos s r hs D Ds B hB) + ((planModulus_tail s r hs D Ds B).trans hq) (scaleRun D 0 p b) + (mem_nextScales s r hs D Ds B b hb p hp) + + + +theorem charted_alignment + (Ds : List (Pivot a)) (horder : Ds.Pairwise (fun D E => D.index < E.index)) : + 0 < delta s r hs Ds ∧ + (∀ b ∈ multipliers (sourcePlan s r hs Ds), ∀ j, 0 < b j) ∧ + ∀ (C : CommonScales a) (Ss : ℕ → (D : Pivot a) → ScalarModels D r), + (∀ D ∈ Ds, Realizes s r C D (fun N => Ss N D)) → + ∀ τ : ℝ, 0 < τ → ∀ ε : ℝ, 0 < ε → + ∀ᶠ N in atTop, delta s r hs Ds ≤ + (C.law N).real {u | ∃ b ∈ multipliers (sourcePlan s r hs Ds), + ∀ D ∈ Ds, comparison D r (Ss N D) (C.ht N) b u (u D.index) τ} + ε := by + refine ⟨delta_pos s r hs Ds, source_multipliers_pos s r hs Ds, ?_⟩ + intro C Ss R τ hτ ε hε + apply eventual_final_alignment s r hs τ C.law Ss C.ht Ds horder _ ε hε + exact local_of_charts s r hs C Ss Ds R {1} (by simp) (planModulus s r hs Ds {1}) + (planModulus_pos s r hs Ds {1}) dvd_rfl 1 (by simp) τ hτ + +end SourceChartedAlignment + + + + + + + +end +end +end +end +end +end +end +end +end +end +end + +end OAI diff --git a/lean/OAI/Combinatorics/SumProduct/Alignment/Blocks02.lean b/lean/OAI/Combinatorics/SumProduct/Alignment/Blocks02.lean new file mode 100644 index 0000000000000000000000000000000000000000..b8e3bd2d7138838fc413d780d6d27d6c2429e02a --- /dev/null +++ b/lean/OAI/Combinatorics/SumProduct/Alignment/Blocks02.lean @@ -0,0 +1,391 @@ +import Mathlib +import OAI.Combinatorics.SumProduct.Alignment.Admissible01 +import OAI.Geometry.NilpotentCharts.Main + +namespace OAI + +open scoped BigOperators +section +noncomputable section +open Filter MeasureTheory +open scoped BigOperators ENNReal Topology +noncomputable section +open scoped BigOperators Topology BoundedContinuousFunction +noncomputable section +open scoped BigOperators +open MeasureTheory Filter Function +noncomputable section +open scoped BigOperators +noncomputable section +open Filter MeasureTheory +open scoped Topology BoundedContinuousFunction NNReal +noncomputable section +open scoped Topology BigOperators +noncomputable section +open scoped Topology BigOperators commutatorElement +noncomputable section +open scoped Topology BoundedContinuousFunction NNReal +noncomputable section +open scoped BigOperators +noncomputable section +open Filter MeasureTheory +open scoped Topology BigOperators BoundedContinuousFunction NNReal +noncomputable section +open Filter MeasureTheory +open scoped Topology BigOperators +noncomputable section +open Filter MeasureTheory +open scoped Topology BigOperators BoundedContinuousFunction NNReal +noncomputable section +open scoped Topology BigOperators +namespace SourceBlocks +open ConstructedWordPlan.GlobalWordPlan ConstructedWordPlan.AlignmentScales +open ConstructedWordPlan.GlobalWordPlan.SourceTerminalArithmetic +open ConstructedWordPlan.RationalPivotPlan SourcePivotPaths +attribute [local instance] Classical.propDecidable +variable {a : ℕ} + +def targetBlock (i : Fin a) (t : Fin (pivot i).targets) : Block a := ⟨i,tailEnum i t⟩ + +@[simp] lemma targetBlock_target (i : Fin a) (t : Fin (pivot i).targets) : + (targetBlock i t).target = t := (tailEnum i).symm_apply_apply t + +@[simp] lemma targetBlock_set (i : Fin a) (t : Fin (pivot i).targets) : + (targetBlock i t).set = block (pivot i).index (pivot i).tail t := rfl + +@[simp] lemma targetBlock_block (B : Block a) : targetBlock B.1 B.target = B := by + rcases B with ⟨i,T⟩ + change (⟨i,tailEnum i ((tailEnum i).symm T)⟩ : Block a) = ⟨i,T⟩ + rw [Equiv.apply_symm_apply] + +lemma pair_injective (i : Fin a) : Function.Injective + (fun e : Fin (pivot i).pairs => ((pivot i).owner e,(pivot i).added e)) := by + intro e f h + apply (pairEnum i).injective + exact Subtype.ext h + + +def subsetPairs (B : Block a) (U : Finset (Finset (Fin a))) : OwnSubset (pivot B.1) B.target := + ⟨Finset.univ.filter (fun e => (pivot B.1).owner e = B.target ∧ (pivot B.1).added e ∈ U), + fun pairIndex membership => show (pivot B.1).owner pairIndex = B.target from + (Finset.mem_filter.mp membership).2.1⟩ + +lemma mem_subsetPairs (B : Block a) (U : Finset (Finset (Fin a))) + (e : Fin (pivot B.1).pairs) : + e ∈ (subsetPairs B U).val ↔ (pivot B.1).owner e = B.target ∧ (pivot B.1).added e ∈ U := by + simp [subsetPairs] + +lemma subsetPairs_sum (B : Block a) (U : Finset (Finset (Fin a))) + (hU : ∀ A ∈ U, Added B.1 B.2.val A) (f : Finset (Fin a) → ℚ) : + (∑ e ∈ (subsetPairs B U).val, f ((pivot B.1).added e)) = ∑ A ∈ U, f A := by + apply Finset.sum_bij (fun e _ => (pivot B.1).added e) + · intro e he + exact ((mem_subsetPairs B U e).mp he).2 + · intro e he f hf h + apply pair_injective B.1 + exact Prod.ext (((mem_subsetPairs B U e).mp he).1.trans + ((mem_subsetPairs B U f).mp hf).1.symm) h + · intro A hA + obtain ⟨e,he,hAe⟩ := (added_exists_iff B A).mpr (hU A hA) + exact ⟨e,(mem_subsetPairs B U e).mpr ⟨he,hAe ▸ hA⟩,hAe⟩ + · intro e he + rfl + +abbrev Models (a r : ℕ) := Block a → ℚ → Fin r → ℤ → ℝ + + + +def scalar {r : ℕ} (S : Models a r) (D : Pivot a) : ScalarModels D r := + fun t v c k => if h : (D.tail t).Nonempty then + S ⟨D.index,⟨D.tail t,h,D.tail_lt t⟩⟩ v c k else 0 + +lemma scalar_canonical {r : ℕ} (S : Models a r) (i : Fin a) + (t : Fin (pivot i).targets) (v : ℚ) (c : Fin r) (k : ℤ) : + scalar S (pivot i) t v c k = S (targetBlock i t) v c k := by + have ht := (tailEnum i t).property.1 + simp only [scalar, show (pivot i).tail t = (tailEnum i t).val from rfl, dite_eq_left ht] + rfl + + +def offset (ht : Fin a → ℤ) (b : Scale a) (u : Fin a → ℕ) + (B : Block a) (U : Finset (Finset (Fin a))) : ℚ := + ∑ A ∈ U, ((height ht A : ℚ)*blockProduct b A / + ((height ht B.set : ℚ)*blockProduct b B.set)) * + (height (fun j => (u j : ℤ)) A : ℚ) + + + +def aligned {r : ℕ} (S : Models a r) (ht : Fin a → ℤ) (b : Scale a) + (u : Fin a → ℕ) (τ : ℝ) : Prop := + ∀ (B : Block a) (U : Finset (Finset (Fin a))), + (∀ A ∈ U, Added B.1 B.2.val A) → ∀ c : Fin r, + ∃ Δ : ℤ, (Δ : ℚ) = offset ht b u B U ∧ + (2*τ < S B (blockProduct b B.set) c (height (fun j => (u j : ℤ)) B.set) → + τ < S B (blockProduct b B.set) c (height (fun j => (u j : ℤ)) B.set+Δ)) + + + +theorem aligned_of_canonical {r : ℕ} (S : Models a r) (ht : Fin a → ℤ) + (b : Scale a) (u : Fin a → ℕ) (τ : ℝ) + (h : ∀ D ∈ pivots a, comparison D r (scalar S D) ht b u (u D.index) τ) : + aligned S ht b u τ := by + intro B U hU c + have hc := h (pivot B.1) (mem_pivots B.1) B.target (subsetPairs B U) c + obtain ⟨Δ,hΔ,himp⟩ := hc + refine ⟨Δ,?_,?_⟩ + · rw [hΔ] + calc + _ = ∑ e ∈ (subsetPairs B U).val, + ((height ht ((pivot B.1).added e) : ℚ)*blockProduct b ((pivot B.1).added e)/ + ((height ht B.set : ℚ)*blockProduct b B.set))* + (height (fun j => (u j : ℤ)) ((pivot B.1).added e) : ℚ) := by + apply Finset.sum_congr rfl + intro e he + rw [((mem_subsetPairs B U e).mp he).1, block_target_set] + _ = _ := subsetPairs_sum B U hU (fun A => + ((height ht A : ℚ)*blockProduct b A/((height ht B.set : ℚ)*blockProduct b B.set))* + (height (fun j => (u j : ℤ)) A : ℚ)) + · have hnot : B.1 ∉ B.2.val := by + intro hi + exact lt_irrefl _ (B.2.property.2 B.1 hi) + have hy : height (fun j => (u j : ℤ)) ((pivot B.1).tail B.target)*(u (pivot B.1).index : ℤ) = + height (fun j => (u j : ℤ)) B.set := by + simp only [block_target_tail, pivot_index, Block.set, height, Finset.prod_insert hnot, mul_comm] + simpa only [scalar_canonical, targetBlock_block, block_target_set, hy] using himp + +end SourceBlocks + + + + + + + +noncomputable section +open scoped Topology BoundedContinuousFunction NNReal BigOperators +namespace SourceFiniteMenuModels +open SourceAdmissible SourceBlocks SourceChartedAlignment SourceChartedMenu +open SourcePivotPaths ConstructedWordPlan.GlobalWordPlan ConstructedWordPlan.AlignmentScales +attribute [local instance] Classical.propDecidable +variable {a s r : ℕ} + + + +structure System (A : Parameters a) (values : Finset ℚ) (r : ℕ) (F : Menu s) where + model : ℕ → Models a r + K : ℝ≥0 + piece : ℕ → Block a → ∀ (v : ℚ), v ∈ values → + Fin r → ℤ → ℤ → Piece F K + represents : ∀ N B v hv c k, + model N B v c k = + (piece N B v hv c (k/(A.H N B.1 : ℤ)) (k%(A.M N : ℤ))).eval + ((k-k%(A.M N : ℤ))/(A.M N : ℤ)) + +variable {A : Parameters a} {values : Finset ℚ} {F : Menu s} (S : System A values r F) + +def extended (N : ℕ) : Models a r := fun B v c k => + if v ∈ values then S.model N B v c k else 0 + +lemma extended_eq (N : ℕ) (B : Block a) (v : ℚ) (hv : v ∈ values) (c : Fin r) (k : ℤ) : + extended S N B v c k = S.model N B v c k := ite_eq_left hv + + + +def charted (i : Fin a) : ChartedModels s r (pivot i) where + G _ _ _ := F.productG + group _ _ _ := inferInstance + topology _ _ _ := inferInstance + topGroup _ _ _ := inferInstance + Γ _ _ _ := F.productΓ + dim _ _ _ := F.productChart.dim + coords _ _ _ := F.productChart.coords + second _ _ _ := F.productChart.second + filtration _ _ _ := F.productChart.filtration + weight _ _ _ := F.productChart.weight + level_iff _ _ _ := F.productChart.level_iff + weight_pos _ _ _ := F.productChart.weight_pos + lattice_iff _ _ _ := F.productChart.lattice_iff + weight_mono _ _ _ := F.productChart.weight_mono + level0 _ _ _ := F.productChart.level0 + level1 _ _ _ := F.productChart.level1 + step _ _ _ := F.productChart.step + g t N v c b r' := if hv : v ∈ values then (S.piece N (targetBlock i t) v hv c b r').padG else 1 + x t N v c b r' := if hv : v ∈ values then (S.piece N (targetBlock i t) v hv c b r').padX else 1 + obs t N v c b r' := if hv : v ∈ values then (S.piece N (targetBlock i t) v hv c b r').padObs else 0 + metric _ _ _ := F.productMetric + compatible _ _ _ := F.productCompatible + K := S.K + B := 1 + lip := by + let : MetricSpace (F.productG ⧸ F.productΓ) := + F.productMetric.replaceTopology F.productCompatible + intro t N v c b r' + by_cases hv : v ∈ values + · simp only [dite_eq_left hv] + exact (S.piece N (targetBlock i t) v hv c b r').pad_lip + · simp only [dite_eq_right hv, BoundedContinuousFunction.coe_zero] + exact LipschitzWith.const' 0 + bound := by + intro t N v c b r' z + by_cases hv : v ∈ values + · simp only [dite_eq_left hv] + exact (S.piece N (targetBlock i t) v hv c b r').pad_bound z + · simp only [dite_eq_right hv, BoundedContinuousFunction.coe_zero, Pi.zero_apply, abs_zero, zero_le_one] + + + +lemma charted_models (i : Fin a) (N : ℕ) : + A.models (charted S i) N = scalar (extended S N) (pivot i) := by + funext t v c k + rw [scalar_canonical] + by_cases hv : v ∈ values + · rw [extended_eq S N (targetBlock i t) v hv c k, S.represents] + change (if h : v ∈ values then (S.piece N (targetBlock i t) v h c + (k/(A.H N i : ℤ)) (k%(A.M N : ℤ))).padObs else 0) + (QuotientGroup.mk + ((if h : v ∈ values then (S.piece N (targetBlock i t) v h c + (k/(A.H N i : ℤ)) (k%(A.M N : ℤ))).padG else 1)^((k-k%(A.M N : ℤ))/(A.M N : ℤ))* + (if h : v ∈ values then (S.piece N (targetBlock i t) v h c + (k/(A.H N i : ℤ)) (k%(A.M N : ℤ))).padX else 1))) = _ + simp only [dite_eq_left hv] + exact (S.piece N (targetBlock i t) v hv c + (k/(A.H N i : ℤ)) (k%(A.M N : ℤ))).pad_orbit _ + · simp only [extended, ite_eq_right hv] + simp only [Parameters.models, scalarModels, SourceIntegerArrays.pieceModel, + charted, dite_eq_right hv] + rfl + + + +theorem represents_all : ∀ D ∈ pivots a, ∃ C : ChartedModels s r D, + ∀ N, scalar (extended S N) D = A.models C N := by + intro D hD + obtain ⟨i,rfl⟩ := List.mem_ofFn.mp hD + exact ⟨charted S i,fun N => (charted_models S i N).symm⟩ + +end SourceFiniteMenuModels + + + + + + + +noncomputable section +open Filter MeasureTheory +open scoped Topology BigOperators BoundedContinuousFunction NNReal +namespace SourceMenuAlignment +open SourceAdmissible SourceBlocks SourceChartedAlignment SourceChartedMenu +open SourceFiniteMenuModels SourcePivotPaths +open ConstructedWordPlan.GlobalWordPlan ConstructedWordPlan.AlignmentScales +attribute [local instance] Classical.propDecidable +variable {a : ℕ} + +instance law_probability (A : Parameters a) (N : ℕ) + (hX : ∀ i, 4*primorial (N+1) ≤ A.X N i) : IsProbabilityMeasure (A.law N hX) := by + unfold Parameters.law + infer_instance + +def tuples (s r : ℕ) (hs : 1 ≤ s) : Finset (Scale a) := + multipliers (sourcePlan s r hs (pivots a)) + +def values (s r : ℕ) (hs : 1 ≤ s) : Finset ℚ := + (tuples (a:=a) s r hs).biUnion (fun b => Finset.univ.image (fun B : Block a => blockProduct b B.set)) + +lemma closure (s r : ℕ) (hs : 1 ≤ s) (b : Scale a) (hb : b ∈ tuples s r hs) (B : Block a) : + blockProduct b B.set ∈ values (a:=a) s r hs := + Finset.mem_biUnion.mpr ⟨b,hb,Finset.mem_image.mpr ⟨B,Finset.mem_univ _,rfl⟩⟩ + +lemma tuples_pos (s r : ℕ) (hs : 1 ≤ s) : + ∀ b ∈ tuples (a:=a) s r hs, ∀ j, 0 < b j := + source_multipliers_pos s r hs _ + +lemma values_pos (s r : ℕ) (hs : 1 ≤ s) : + ∀ v ∈ values (a:=a) s r hs, 0 < v := by + intro v hv + obtain ⟨b,hb,hv⟩ := Finset.mem_biUnion.mp hv + obtain ⟨B,hB,rfl⟩ := Finset.mem_image.mp hv + exact Finset.prod_pos (fun j _ => tuples_pos s r hs b hb j) + + + +def event {r : ℕ} (bs : Finset (Scale a)) (S : Models a r) + (ht : Fin a → ℤ) (τ : ℝ) : Set (Fin a → ℕ) := + {u | ∃ b ∈ bs, aligned S ht b u τ} + + + +theorem menu_alignment_eventually (s r : ℕ) (hs : 1 ≤ s) + (A : Parameters a) (F : Menu s) (S : System A (values (a:=a) s r hs) r F) + (τ : ℝ) (hτ : 0 < τ) (ε : ℝ) (hε : 0 < ε) : + ∀ᶠ N in atTop, ∃ hX : ∀ i, 4*primorial (N+1) ≤ A.X N i, + delta s r hs (pivots a) ≤ + (A.law N hX).real (event (tuples s r hs) (S.model N) (A.ht N) τ) + ε := by + have h := (admissible_charted_alignment (a:=a) s r hs).2.2 A + (fun N => scalar (extended S N)) (represents_all S) τ hτ ε hε + filter_upwards [h] with N hN + obtain ⟨hX,hN⟩ := hN + refine ⟨hX,hN.trans (_root_.add_le_add_left (measureReal_mono (μ:=A.law N hX) ?_ (measure_ne_top _ _)) _)⟩ + intro u hu + obtain ⟨b,hb,hb'⟩ := hu + refine ⟨b,hb,?_⟩ + have ha := aligned_of_canonical (extended S N) (A.ht N) b u τ hb' + intro B U hU c + obtain ⟨Δ,hΔ,himp⟩ := ha B U hU c + refine ⟨Δ,hΔ,?_⟩ + simpa only [extended_eq S N B _ (closure s r hs b hb B)] using himp + + + +theorem menu_alignment_liminf (s r : ℕ) (hs : 1 ≤ s) + (A : Parameters a) (F : Menu s) (S : System A (values (a:=a) s r hs) r F) + (μ : ℕ → Measure (Fin a → ℕ)) + (hμ : ∀ N (hX : ∀ i, 4*primorial (N+1) ≤ A.X N i), μ N = A.law N hX) + (τ : ℝ) (hτ : 0 < τ) : + delta s r hs (pivots a) ≤ + Filter.liminf (fun N => (μ N).real (event (tuples s r hs) (S.model N) (A.ht N) τ)) atTop := by + let p : ℕ → ℝ := fun N => (μ N).real (event (tuples s r hs) (S.model N) (A.ht N) τ) + have hb : IsBoundedUnder (· ≥ ·) atTop p := + isBoundedUnder_of_eventually_ge (Eventually.of_forall (fun N => measureReal_nonneg)) + have hu : IsBoundedUnder (· ≤ ·) atTop p := by + apply isBoundedUnder_of_eventually_le (a:=1) + filter_upwards [menu_alignment_eventually s r hs A F S τ hτ 1 zero_lt_one] with N hN + obtain ⟨hX,_⟩ := hN + dsimp [p] + rw [hμ N hX] + exact measureReal_le_one + apply (Filter.le_liminf_iff hu.isCoboundedUnder_ge hb).mpr + intro y hy + have he : 0 < (delta s r hs (pivots a)-y)/2 := by linarith + filter_upwards [menu_alignment_eventually s r hs A F S τ hτ _ he] with N hN + obtain ⟨hX,hN⟩ := hN + change y < (μ N).real _ + rw [hμ N hX] + linarith + +end SourceMenuAlignment + + + + + + + +end +end +end +end +end +end +end +end +end +end +end +end +end +end +end +end + +end OAI diff --git a/lean/OAI/Combinatorics/SumProduct/Alignment/BooleanBinomial01.lean b/lean/OAI/Combinatorics/SumProduct/Alignment/BooleanBinomial01.lean new file mode 100644 index 0000000000000000000000000000000000000000..600e8b15d3d44d1a9d4b498078fc8159d126c2ff --- /dev/null +++ b/lean/OAI/Combinatorics/SumProduct/Alignment/BooleanBinomial01.lean @@ -0,0 +1,480 @@ +import Mathlib +import OAI.Combinatorics.SumProduct.Alignment.CubeFaces01 +import OAI.Combinatorics.SumProduct.Alignment.LeibmanSquare01 +import OAI.Geometry.NilpotentCharts.Main + +namespace OAI + +section +section +section +section +noncomputable section +open scoped BigOperators Topology +end +end + + + +section +open scoped commutatorElement Pointwise + + + +namespace HorizontalCubeCharacter +open CubeFaces +variable {G A ι : Type*} [Group G] [CommGroup A] [DecidableEq ι] + + +def faceLift (H : Filtration G) (I D : Finset ι) (k : ℕ) + (hDI : D ⊆ I) (hDk : D.card ≤ k) : H.level k →* cube H I 0 where + toFun x := ⟨face D (x:G),face_mem_cube H hDI (by + simpa using H.antitone hDk x.property)⟩ + map_one' := by apply Subtype.ext; exact (face D).map_one + map_mul' x y := by apply Subtype.ext; exact (face D).map_mul (x:G) (y:G) + +@[simp] lemma faceLift_coe (H : Filtration G) (I D : Finset ι) (k : ℕ) + (hDI : D ⊆ I) (hDk : D.card ≤ k) (x : H.level k) : + ((faceLift H I D k hDI hDk x : cube H I 0) : Finset ι → G) = face D (x:G) := rfl + + +lemma eq_one_of_faces (H : Filtration G) (I : Finset ι) + (χ : cube H I 0 →* A) + (hχ : ∀ D (hDI : D ⊆ I), χ.comp (faceLift H I D D.card hDI le_rfl) = 1) : χ = 1 := by + let K : Subgroup (Finset ι → G) := χ.ker.map (cube H I 0).subtype + have hle : cube H I 0 ≤ K := by + refine iSup_le fun D => iSup_le fun hDI => ?_ + rintro f ⟨g,hg,rfl⟩ + have hg' : g ∈ H.level D.card := by simpa using hg + refine ⟨faceLift H I D D.card hDI le_rfl ⟨g,hg'⟩,?_,rfl⟩ + change χ (faceLift H I D D.card hDI le_rfl ⟨g,hg'⟩) = 1 + exact DFunLike.congr_fun (hχ D hDI) ⟨g,hg'⟩ + ext x + rcases hle x.property with ⟨y,hy,he⟩ + have he' : y = x := Subtype.ext he + simpa [he'] using hy + + +lemma split_face (D : Finset ι) (i k : ℕ) (hD : D.card ≤ i+k) : + ∃ E F : Finset ι, E ⊆ D ∧ F ⊆ D ∧ E.card ≤ i ∧ F.card ≤ k ∧ E ∪ F = D := by + obtain ⟨E,hED,hE⟩ := Finset.exists_subset_card_eq (s := D) (Nat.min_le_right i D.card) + refine ⟨E,D\E,hED,Finset.sdiff_subset,?_,?_,?_⟩ + · rw [hE]; exact Nat.min_le_left _ _ + · rw [Finset.card_sdiff_of_subset hED,hE] + omega + · exact Finset.union_sdiff_of_subset hED + + +structure MaximalFace (H : Filtration G) (I : Finset ι) + (χ : cube H I 0 →* A) where + level : ℕ + positive : 0 < level + face : Finset ι + subset : face ⊆ I + card_le : face.card ≤ level + nontrivial : χ.comp (faceLift H I face level subset card_le) ≠ 1 + maximal : ∀ k, level < k → ∀ D (hDI : D ⊆ I) (hDk : D.card ≤ k), + χ.comp (faceLift H I D k hDI hDk) = 1 + +noncomputable section + + + +theorem exists_maximalFace (H : Filtration G) (I : Finset ι) + (h01 : H.level 0 = H.level 1) (s : ℕ) (hs : H.level (s+1) = ⊥) + (χ : cube H I 0 →* A) (hne : χ ≠ 1) : Nonempty (MaximalFace H I χ) := by + classical + have hgen : ∃ D, ∃ hDI : D ⊆ I, + χ.comp (faceLift H I D D.card hDI le_rfl) ≠ 1 := by + by_contra! hn + exact hne (eq_one_of_faces H I χ hn) + obtain ⟨D,hDI,hD⟩ := hgen + have hex : ∃ k, 0 < k ∧ ∃ D, ∃ hDI : D ⊆ I, ∃ hDk : D.card ≤ k, + χ.comp (faceLift H I D k hDI hDk) ≠ 1 := by + by_cases hc : D.card = 0 + · refine ⟨1,by omega,D,hDI,by omega,?_⟩ + intro hh + apply hD + ext x + have hx : (x:G) ∈ H.level 1 := by rw [← h01,← hc]; exact x.property + have he := DFunLike.congr_fun hh ⟨(x:G),hx⟩ + exact he + · exact ⟨D.card,by omega,D,hDI,le_rfl,hD⟩ + let P (k : ℕ) : Prop := 0 < k ∧ ∃ D, ∃ hDI : D ⊆ I, ∃ hDk : D.card ≤ k, + χ.comp (faceLift H I D k hDI hDk) ≠ 1 + have hbound : ∀ k, P k → k ≤ s := by + rintro k ⟨hk,D,hDI,hDk,hχ⟩ + by_contra! hsk + apply hχ + ext x + have hx : (x:G) ∈ H.level (s+1) := H.antitone hsk x.property + rw [hs,Subgroup.mem_bot] at hx + have hx' : x = 1 := Subtype.ext hx + simp [hx'] + let S := (Finset.range (s+1)).filter P + have hS : S.Nonempty := by + obtain ⟨k,hk⟩ := hex + exact ⟨k,Finset.mem_filter.mpr ⟨Finset.mem_range.mpr (by have := hbound k hk; omega),hk⟩⟩ + obtain ⟨j,hj,hmax⟩ := S.exists_max_image id hS + have hjP : P j := (Finset.mem_filter.mp hj).2 + rcases hjP with ⟨hj,D,hDI,hDj,hn⟩ + refine ⟨⟨j,hj,D,hDI,hDj,hn,?_⟩⟩ + intro k hjk E hEI hEk + by_contra hke + have hp : P k := ⟨by omega,E,hEI,hEk,hke⟩ + have hh := hmax k (Finset.mem_filter.mpr ⟨Finset.mem_range.mpr (by have := hbound k hp; omega),hp⟩) + change k ≤ j at hh + omega + + + +structure LevelCharacter (H : Filtration G) (j : ℕ) where + value : H.level j →* A + kills_next : ∀ x (hx : x ∈ H.level (j+1)), + value ⟨x,H.antitone (Nat.le_succ j) hx⟩ = 1 + kills_brackets : ∀ i k : ℕ, 0 < i → 0 < k → ∀ hik : i+k=j, + ∀ x (hx : x ∈ H.level i) y (hy : y ∈ H.level k), + value ⟨⁅x,y⁆,by + rw [← hik] + exact H.commutator_le i k (Subgroup.commutator_mem_commutator hx hy)⟩ = 1 + + +def MaximalFace.character {H : Filtration G} {I : Finset ι} + {χ : cube H I 0 →* A} (M : MaximalFace H I χ) : + LevelCharacter (A := A) H M.level where + value := χ.comp (faceLift H I M.face M.level M.subset M.card_le) + kills_next x hx := by + have h := DFunLike.congr_fun + (M.maximal (M.level+1) (Nat.lt_succ_self _) M.face M.subset + (M.card_le.trans (Nat.le_succ _))) ⟨x,hx⟩ + exact h + kills_brackets i k hi hk hik x hx y hy := by + obtain ⟨E,F,hED,hFD,hEi,hFk,hEF⟩ := split_face M.face i k (by rw [hik]; exact M.card_le) + let u := faceLift H I E i (hED.trans M.subset) hEi ⟨x,hx⟩ + let v := faceLift H I F k (hFD.trans M.subset) hFk ⟨y,hy⟩ + have hcomm : ⁅u,v⁆ = faceLift H I M.face M.level M.subset M.card_le + ⟨⁅x,y⁆,by rw [← hik]; exact H.commutator_le i k (Subgroup.commutator_mem_commutator hx hy)⟩ := by + apply Subtype.ext + change ⁅CubeFaces.face E x,CubeFaces.face F y⁆ = CubeFaces.face M.face ⁅x,y⁆ + rw [face_commutator,hEF] + change χ _ = 1 + rw [← hcomm,map_commutatorElement] + exact commutatorElement_eq_one_iff_mul_comm.mpr (mul_comm _ _) + +lemma MaximalFace.character_nontrivial {H : Filtration G} {I : Finset ι} + {χ : cube H I 0 →* A} (M : MaximalFace H I χ) : M.character.value ≠ 1 := + M.nontrivial + +end +end HorizontalCubeCharacter +end + + + +section + + + +namespace BooleanBinomial +open scoped BigOperators +noncomputable section +open MvPolynomial + +variable {ι : Type*} [Fintype ι] [DecidableEq ι] + + +abbrev Exponent (ι : Type*) := Option ι →₀ ℕ + +def degree (e : Exponent ι) : ℕ := e.sum (fun _ n => n) + +def incrementSupport (e : Exponent ι) : Finset ι := + Finset.univ.filter (fun i => e (some i) ≠ 0) + +omit [DecidableEq ι] in +@[simp] lemma mem_incrementSupport (e : Exponent ι) (i : ι) : + i ∈ incrementSupport e ↔ e (some i) ≠ 0 := by simp [incrementSupport] + +def part (D : Finset ι) (p : MvPolynomial (Option ι) ℝ) : + MvPolynomial (Option ι) ℝ := + AddMonoidAlgebra.ofCoeff ((AddMonoidAlgebra.coeff p).filter (fun e => incrementSupport e = D)) + +@[simp] lemma coeff_part (D : Finset ι) (p : MvPolynomial (Option ι) ℝ) + (e : Exponent ι) : + (part D p).coeff e = if incrementSupport e = D then p.coeff e else 0 := rfl + +lemma part_support (D : Finset ι) (p : MvPolynomial (Option ι) ℝ) + {e : Exponent ι} (he : e ∈ (part D p).support) : incrementSupport e = D := by + have hh : (part D p).coeff e ≠ 0 := MvPolynomial.mem_support_iff.mp he + by_contra hn + simp [coeff_part,hn] at hh + +lemma sum_parts (p : MvPolynomial (Option ι) ℝ) : + ∑ D : Finset ι, part D p = p := by + ext e + simp + + +def composeSum {σ : Type*} [Fintype σ] (p : Polynomial ℝ) : MvPolynomial σ ℝ := + p.eval₂ C (∑ i, X i) + +lemma coeff_composeSum {σ : Type*} [Fintype σ] (p : Polynomial ℝ) (e : σ →₀ ℕ) : + (composeSum p).coeff e = p.coeff (e.sum (fun _ n => n)) * e.multinomial := by + classical + simp only [composeSum,Polynomial.eval₂_eq_sum,Polynomial.sum, + coeff_sum,coeff_C_mul,coeff_sum_X_pow_of_fintype,Nat.cast_ite,Nat.cast_zero] + by_cases he : e.sum (fun _ n => n) ∈ p.support + · rw [Finset.sum_eq_single_of_mem _ he] + · simp + · intro b _ hb + simp [Ne.symm hb] + · have hp : p.coeff (e.sum (fun _ n => n)) = 0 := Polynomial.notMem_support_iff.mp he + rw [hp,zero_mul] + apply Finset.sum_eq_zero + intro b hb + have hne : e.sum (fun _ n => n) ≠ b := by rintro rfl; exact he hb + simp [hne] + + +def binomial (j : ℕ) : Polynomial ℝ := + Polynomial.C (j.factorial : ℝ)⁻¹ * descPochhammer ℝ j + +lemma binomial_eval (j : ℕ) (x : ℝ) : (binomial j).eval x = Ring.choose x j := by + rw [Ring.choose_eq_smul,smul_eq_mul,← Polynomial.aeval_eq_smeval, + Polynomial.aeval_def,← Polynomial.eval_map,descPochhammer_map] + simp [binomial] + +lemma binomial_coeff_top (j : ℕ) : (binomial j).coeff j = (j.factorial : ℝ)⁻¹ := by + rw [binomial,Polynomial.coeff_C_mul] + have hh := (monic_descPochhammer ℝ j).coeff_natDegree + rw [descPochhammer_natDegree] at hh + rw [hh,mul_one] + +lemma binomial_coeff_above (j n : ℕ) (hn : j < n) : (binomial j).coeff n = 0 := by + apply Polynomial.coeff_eq_zero_of_natDegree_lt + exact (Polynomial.natDegree_C_mul_le _ _).trans_lt (by simpa using hn) + + +def cubeBinomial (j : ℕ) : MvPolynomial (Option ι) ℝ := composeSum (binomial j) + +def faceBinomial (j : ℕ) (D : Finset ι) : MvPolynomial (Option ι) ℝ := + part D (cubeBinomial j) + +lemma faceBinomial_coeff (j : ℕ) (D : Finset ι) (e : Exponent ι) : + (faceBinomial j D).coeff e = + if incrementSupport e = D then (binomial j).coeff (degree e) * e.multinomial else 0 := by + simp only [faceBinomial,coeff_part,cubeBinomial,coeff_composeSum,degree] + +lemma faceBinomial_support (j : ℕ) (D : Finset ι) {e : Exponent ι} + (he : e ∈ (faceBinomial j D).support) : + incrementSupport e = D ∧ degree e ≤ j := by + have hs : incrementSupport e = D := part_support D _ he + refine ⟨hs,?_⟩ + by_contra! hd + have hh := MvPolynomial.mem_support_iff.mp he + rw [faceBinomial_coeff,ite_eq_left hs,binomial_coeff_above _ _ hd,zero_mul] at hh + exact hh rfl + + +def isolatedExponent (j : ℕ) (D : Finset ι) : Exponent ι := + Finsupp.equivFunOnFinite.symm (fun i => match i with + | none => j-D.card + | some i => if i ∈ D then 1 else 0) + +@[simp] lemma isolatedExponent_none (j : ℕ) (D : Finset ι) : + isolatedExponent j D none = j-D.card := by simp [isolatedExponent] + +@[simp] lemma isolatedExponent_some (j : ℕ) (D : Finset ι) (i : ι) : + isolatedExponent j D (some i) = if i ∈ D then 1 else 0 := by + simp [isolatedExponent] + +@[simp] lemma isolatedExponent_support (j : ℕ) (D : Finset ι) : + incrementSupport (isolatedExponent j D) = D := by + ext i + simp + +omit [DecidableEq ι] in +lemma degree_eq_sum (e : Exponent ι) : degree e = e none + ∑ i, e (some i) := by + rw [degree,Finsupp.sum_of_support_subset e (Finset.subset_univ _) _ (by simp), + Fintype.sum_option] + +lemma isolatedExponent_degree (j : ℕ) (D : Finset ι) (hD : D.card ≤ j) : + degree (isolatedExponent j D) = j := by + rw [degree_eq_sum] + simp only [isolatedExponent_none,isolatedExponent_some] + simp [Nat.sub_add_cancel hD] + +lemma isolatedExponent_multinomial (j : ℕ) (D : Finset ι) (hD : D.card ≤ j) : + (j-D.card).factorial * (isolatedExponent j D).multinomial = j.factorial := by + have hh := Nat.multinomial_spec Finset.univ (isolatedExponent j D) + rw [← Finsupp.multinomial_eq_of_support_subset (Finset.subset_univ _)] at hh + have hs : (∑ i,isolatedExponent j D i) = j := by + rw [Fintype.sum_option] + simpa only [← degree_eq_sum] using isolatedExponent_degree j D hD + rw [hs,Fintype.prod_option] at hh + simpa only [isolatedExponent_none,isolatedExponent_some,apply_ite Nat.factorial, + Nat.factorial_one,Nat.factorial_zero,ite_self,Finset.prod_const_one,mul_one] using hh + + + +theorem isolated_coefficient (j : ℕ) (D : Finset ι) (hD : D.card ≤ j) : + (faceBinomial j D).coeff (isolatedExponent j D) = + ((j-D.card).factorial : ℝ)⁻¹ := by + rw [faceBinomial_coeff,isolatedExponent_support,ite_eq_left rfl, + isolatedExponent_degree j D hD,binomial_coeff_top] + have hh : ((j-D.card).factorial : ℝ) * (isolatedExponent j D).multinomial = j.factorial := + by exact_mod_cast isolatedExponent_multinomial j D hD + have hj : (j.factorial : ℝ) ≠ 0 := by exact_mod_cast (Nat.factorial_ne_zero j) + have hd : ((j-D.card).factorial : ℝ) ≠ 0 := by exact_mod_cast (Nat.factorial_ne_zero _) + field_simp + nlinarith + +lemma coefficient_other_face (ℓ j : ℕ) (D E : Finset ι) (hDE : D ≠ E) : + (faceBinomial ℓ E).coeff (isolatedExponent j D) = 0 := by + rw [faceBinomial_coeff,isolatedExponent_support,ite_eq_right hDE] + +lemma coefficient_lower_order (ℓ j : ℕ) (D E : Finset ι) + (hD : D.card ≤ j) (hℓ : ℓ < j) : + (faceBinomial ℓ E).coeff (isolatedExponent j D) = 0 := by + rw [faceBinomial_coeff,isolatedExponent_degree j D hD,binomial_coeff_above _ _ hℓ] + simp + + + +theorem horizontal_coefficient (j : ℕ) (D : Finset ι) (hD : D.card ≤ j) + (w : ℕ → Finset ι → ℝ) : + (∑ ℓ ∈ Finset.range (j+1), ∑ E : Finset ι, C (w ℓ E) * faceBinomial ℓ E).coeff + (isolatedExponent j D) = + w j D / (j-D.card).factorial := by + simp only [coeff_sum,coeff_C_mul] + rw [Finset.sum_eq_single_of_mem j (Finset.mem_range.mpr (Nat.lt_succ_self _))] + · rw [Finset.sum_eq_single D] + · rw [isolated_coefficient j D hD,div_eq_mul_inv] + · intro E _ hE + rw [coefficient_other_face j j D E (Ne.symm hE),mul_zero] + · simp + · intro ℓ hℓ hne + have hlt : ℓ < j := lt_of_le_of_ne (Nat.le_of_lt_succ (Finset.mem_range.mp hℓ)) hne + apply Finset.sum_eq_zero + intro E _ + rw [coefficient_lower_order ℓ j D E hD hlt,mul_zero] + +def mask (b : Option ι → ℝ) (v : Finset ι) : Option ι → ℝ + | none => b none + | some i => if i ∈ v then b (some i) else 0 + +lemma masked_monomial (b : Option ι → ℝ) (v : Finset ι) (e : Exponent ι) : + e.prod (fun i n => mask b v i ^ n) = + if incrementSupport e ⊆ v then e.prod (fun i n => b i ^ n) else 0 := by + classical + by_cases h : incrementSupport e ⊆ v + · rw [ite_eq_left h] + apply Finset.prod_congr rfl + intro i hi + cases i with + | none => rfl + | some i => + have hv := h ((mem_incrementSupport e i).mpr (Finsupp.mem_support_iff.mp hi)) + simp [mask,hv] + · rw [ite_eq_right h] + obtain ⟨i,hi,hv⟩ := Finset.not_subset.mp h + apply Finset.prod_eq_zero (show some i ∈ e.support from + Finsupp.mem_support_iff.mpr ((mem_incrementSupport e i).mp hi)) + simp [mask,hv,zero_pow ((mem_incrementSupport e i).mp hi)] + +lemma part_mask_eval (b : Option ι → ℝ) (v D : Finset ι) + (p : MvPolynomial (Option ι) ℝ) : + eval (mask b v) (part D p) = if D ⊆ v then eval b (part D p) else 0 := by + by_cases h : D ⊆ v + · rw [ite_eq_left h,eval_eq,eval_eq] + apply Finset.sum_congr rfl + intro e he + change _ * e.prod (fun i n => mask b v i ^ n) = + _ * e.prod (fun i n => b i ^ n) + rw [masked_monomial,part_support D p he,ite_eq_left h] + · rw [ite_eq_right h,eval_eq] + apply Finset.sum_eq_zero + intro e he + change _ * e.prod (fun i n => mask b v i ^ n) = 0 + rw [masked_monomial,part_support D p he,ite_eq_right h,mul_zero] + +lemma eval_composeSum {σ : Type*} [Fintype σ] (p : Polynomial ℝ) (b : σ → ℝ) : + eval b (composeSum p) = p.eval (∑ i,b i) := by + simp [composeSum,Polynomial.eval₂_eq_sum,Polynomial.eval_eq_sum,Polynomial.sum] + +omit [DecidableEq ι] in +lemma cubeBinomial_eval (j : ℕ) (b : Option ι → ℝ) : + eval b (cubeBinomial j) = Ring.choose (b none + ∑ i,b (some i)) j := by + rw [cubeBinomial,eval_composeSum,binomial_eval,Fintype.sum_option] + + +theorem binomial_expansion (j : ℕ) (b : Option ι → ℝ) (v : Finset ι) : + Ring.choose (b none + ∑ i ∈ v,b (some i)) j = + ∑ D : Finset ι, if D ⊆ v then eval b (faceBinomial j D) else 0 := by + have hb : b none + ∑ i ∈ v,b (some i) = + mask b v none + ∑ i,mask b v (some i) := by simp [mask] + rw [hb,← cubeBinomial_eval] + calc + _ = eval (mask b v) (∑ D : Finset ι,part D (cubeBinomial j)) := + congrArg (eval (mask b v)) (sum_parts (cubeBinomial j)).symm + _ = ∑ D : Finset ι, if D ⊆ v then eval b (faceBinomial j D) else 0 := by + rw [map_sum] + apply Finset.sum_congr rfl + intro D _ + exact part_mask_eval b v D _ + +omit [Fintype ι] in +lemma boolean_product (D v : Finset ι) : + (∏ i ∈ D, if i ∈ v then (1:ℝ) else 0) = if D ⊆ v then 1 else 0 := by + by_cases h : D ⊆ v + · rw [ite_eq_left h] + apply Finset.prod_eq_one + intro i hi + exact ite_eq_left (h hi) + · rw [ite_eq_right h] + obtain ⟨i,hi,hv⟩ := Finset.not_subset.mp h + exact Finset.prod_eq_zero hi (ite_eq_right hv) + + +theorem boolean_binomial_expansion (j : ℕ) (b : Option ι → ℝ) (v : Finset ι) : + Ring.choose (b none + ∑ i ∈ v,b (some i)) j = + ∑ D : Finset ι, (∏ i ∈ D,if i ∈ v then (1:ℝ) else 0) * + eval b (faceBinomial j D) := by + rw [binomial_expansion] + apply Finset.sum_congr rfl + intro D _ + rw [boolean_product] + split_ifs <;> simp + +omit [DecidableEq ι] in +lemma incrementSupport_card_le (e : Exponent ι) : (incrementSupport e).card ≤ degree e := by + rw [degree_eq_sum] + calc + _ = ∑ _i ∈ incrementSupport e, 1 := by simp + _ ≤ ∑ i ∈ incrementSupport e,e (some i) := by + apply Finset.sum_le_sum + intro i hi + exact Nat.one_le_iff_ne_zero.mpr ((mem_incrementSupport e i).mp hi) + _ ≤ ∑ i,e (some i) := Finset.sum_le_univ_sum_of_nonneg (fun _ => Nat.zero_le _) + _ ≤ e none + ∑ i,e (some i) := Nat.le_add_left _ _ + + +theorem faceBinomial_vanish (j : ℕ) (D : Finset ι) (hD : j < D.card) : + faceBinomial j D = 0 := by + ext e + rw [AddMonoidAlgebra.coeff_zero] + by_contra h + have he : e ∈ (faceBinomial j D).support := MvPolynomial.mem_support_iff.mpr h + obtain ⟨hs,hd⟩ := faceBinomial_support j D he + have hc := incrementSupport_card_le e + rw [hs] at hc + omega + +end +end BooleanBinomial + +end +end +end +end + +end OAI diff --git a/lean/OAI/Combinatorics/SumProduct/Alignment/BooleanRough01.lean b/lean/OAI/Combinatorics/SumProduct/Alignment/BooleanRough01.lean new file mode 100644 index 0000000000000000000000000000000000000000..90b745a234b56dddcdf2f5e75c6ffbf178ace134 --- /dev/null +++ b/lean/OAI/Combinatorics/SumProduct/Alignment/BooleanRough01.lean @@ -0,0 +1,936 @@ +import Mathlib +import OAI.Geometry.NilpotentCharts.Main + +namespace OAI + + + + + + +section + + + + +noncomputable section +namespace BooleanRough +open Finset +open scoped BigOperators + +variable {α K : Type*} [DecidableEq α] + +def Raise [AddCommMonoid K] (f : Finset α → K) (S : Finset α) : K := + ∑ i ∈ S, f (S.erase i) + + +lemma sum_raise_rank [AddCommMonoid K] (S : Finset α) (k : ℕ) + (f : Finset α → K) : + (∑ T ∈ S.powersetCard (k+1), Raise f T) = + (S.card-k) • (∑ U ∈ S.powersetCard k, f U) := by + unfold Raise + rw [Finset.sum_sigma'] + calc + _ = ∑ p ∈ (S.powersetCard k).sigma (fun U => S \ U), f p.1 := by + apply Finset.sum_bij' + (fun p _ => (⟨p.1.erase p.2, p.2⟩ : (U : Finset α) × α)) + (fun p _ => (⟨insert p.2 p.1, p.2⟩ : (U : Finset α) × α)) + · intro p hp + obtain ⟨hT, hi⟩ := Finset.mem_sigma.mp hp + obtain ⟨hTS, hTk⟩ := Finset.mem_powersetCard.mp hT + apply Finset.mem_sigma.mpr + refine ⟨Finset.mem_powersetCard.mpr ⟨(erase_subset _ _).trans hTS, ?_⟩, ?_⟩ + · rw [card_erase_of_mem hi, hTk]; omega + · exact mem_sdiff.mpr ⟨hTS hi, notMem_erase _ _⟩ + · intro p hp + obtain ⟨hU, hi⟩ := Finset.mem_sigma.mp hp + obtain ⟨hUS, hUk⟩ := Finset.mem_powersetCard.mp hU + obtain ⟨hiS, hiU⟩ := mem_sdiff.mp hi + apply Finset.mem_sigma.mpr + refine ⟨Finset.mem_powersetCard.mpr ⟨insert_subset hiS hUS, ?_⟩, mem_insert_self _ _⟩ + rw [card_insert_of_notMem hiU, hUk] + · intro p hp + have hi := (Finset.mem_sigma.mp hp).2 + exact Sigma.ext (insert_erase hi) (heq_of_eq rfl) + · intro p hp + have hi := (mem_sdiff.mp (Finset.mem_sigma.mp hp).2).2 + exact Sigma.ext (erase_insert hi) (heq_of_eq rfl) + · intro p hp + rfl + _ = ∑ U ∈ S.powersetCard k, (S.card-k) • f U := by + rw [← Finset.sum_sigma' (S.powersetCard k) (fun U => S \ U) (fun U (_ : α) => f U)] + apply sum_congr rfl + intro U hU + obtain ⟨hUS, hUk⟩ := mem_powersetCard.mp hU + rw [sum_const, card_sdiff_of_subset hUS, hUk] + _ = _ := Finset.smul_sum.symm + +lemma sum_raise_rank_zero [Fintype α] [Field K] (k : ℕ) + (hchar : ∀ j : ℕ, 0 < j → j ≤ Fintype.card α → (j : K) ≠ 0) + (f : Finset α → K) (hu : ∀ S, Raise f S = 0) + (S : Finset α) (hS : k < S.card) : + (∑ T ∈ S.powersetCard k, f T) = 0 := by + have he := sum_raise_rank S k f + have hz : (∑ T ∈ S.powersetCard (k+1), Raise f T) = 0 := + sum_eq_zero (fun T _ => hu T) + rw [hz, nsmul_eq_mul] at he + have hne : ((S.card-k : ℕ) : K) ≠ 0 := + hchar _ (Nat.sub_pos_of_lt hS) ((Nat.sub_le _ _).trans (card_le_univ _)) + exact (mul_eq_zero.mp he.symm).resolve_left hne + + +lemma alternating_powerset [Ring K] (S : Finset α) : + (∑ T ∈ S.powerset, (-1 : K)^T.card) = if S = ∅ then 1 else 0 := by + have h := Finset.sum_powerset_neg_one_pow_card (x := S) + have hc := congrArg (Int.castRingHom K) h + simpa only [map_sum, map_pow, map_neg, map_one, map_zero, apply_ite] using hc + +lemma powerset_sdiff_filter [Fintype α] (C : Finset α) : + (univ \ C).powerset = univ.powerset.filter (fun T : Finset α => Disjoint T C) := by + ext T + simp only [mem_powerset, mem_filter, subset_univ, true_and] + simp only [subset_sdiff, subset_univ, true_and, disjoint_left] + + +lemma complement_mobius [Fintype α] [CommRing K] + (f : Finset α → K) (A : Finset α) : + (∑ C ∈ A.powerset, (-1 : K)^C.card * ∑ T ∈ (univ \ C).powerset, f T) = + ∑ T ∈ univ.powerset, if A ⊆ T then f T else 0 := by + simp_rw [powerset_sdiff_filter, sum_filter, mul_sum, mul_ite, mul_zero] + rw [sum_comm] + apply sum_congr rfl + intro T hT + have he : (∑ C ∈ A.powerset, if Disjoint T C then (-1 : K)^C.card * f T else 0) = + (∑ C ∈ (A \ T).powerset, (-1 : K)^C.card) * f T := by + rw [sum_mul, ← sum_filter] + apply sum_congr + · ext C + simp only [mem_filter, mem_powerset, subset_sdiff] + constructor + · rintro ⟨hCA, hd⟩ + exact ⟨hCA, hd.symm⟩ + · rintro ⟨hCA, hd⟩ + exact ⟨hCA, hd.symm⟩ + · intro C hC; rfl + rw [he, alternating_powerset] + by_cases hAT : A ⊆ T + · simp [sdiff_eq_empty_iff_subset.mpr hAT, hAT] + · simp [sdiff_eq_empty_iff_subset, hAT] + + +theorem raise_injective_below_middle [Fintype α] [Field K] + (k : ℕ) (hk : 2*k < Fintype.card α) + (hchar : ∀ j : ℕ, 0 < j → j ≤ Fintype.card α → (j : K) ≠ 0) + (f : Finset α → K) (hf : ∀ S, S.card ≠ k → f S = 0) + (hu : ∀ S, Raise f S = 0) : f = 0 := by + funext A + change f A = 0 + by_cases hAk : A.card = k + · have hFzero (C : Finset α) (hC : C ⊆ A) : + (∑ T ∈ (univ \ C).powerset, f T) = 0 := by + have hCk : C.card ≤ k := hAk ▸ card_le_card hC + have hlarge : k < (univ \ C).card := by + rw [card_sdiff_of_subset (subset_univ _), card_univ] + omega + have he : (∑ T ∈ (univ \ C).powersetCard k, f T) = + ∑ T ∈ (univ \ C).powerset, f T := by + apply sum_subset (fun T hT => mem_powerset.mpr (mem_powersetCard.mp hT).1) + intro T hT hnot + apply hf + intro hTk + exact hnot (mem_powersetCard.mpr ⟨mem_powerset.mp hT, hTk⟩) + rw [← he] + exact sum_raise_rank_zero k hchar f hu _ hlarge + have hleft : (∑ C ∈ A.powerset, + (-1 : K)^C.card * ∑ T ∈ (univ \ C).powerset, f T) = 0 := by + exact sum_eq_zero (fun C hC => by rw [hFzero C (mem_powerset.mp hC), mul_zero]) + rw [complement_mobius] at hleft + have hright : (∑ T ∈ univ.powerset, if A ⊆ T then f T else 0) = f A := by + rw [sum_eq_single A] + · simp + · intro B hB hBA + by_cases hAB : A ⊆ B + · rw [ite_eq_left hAB] + apply hf + intro hBk + have := eq_of_subset_of_card_le hAB (by omega) + exact hBA this.symm + · simp [hAB] + · intro hA + exact False.elim (hA (mem_powerset.mpr (subset_univ _))) + rwa [hright] at hleft + · exact hf A hAk + + +def WeightedRaise [Semiring K] (b : α → K) (f : Finset α → K) (S : Finset α) : K := + ∑ i ∈ S, b i * f (S.erase i) + +lemma weighted_raise_rescale [Field K] (b : α → K) (hb : ∀ i, b i ≠ 0) + (f : Finset α → K) (S : Finset α) : + WeightedRaise b f S = (∏ i ∈ S, b i) * + Raise (fun T => f T / ∏ i ∈ T, b i) S := by + unfold WeightedRaise Raise + rw [mul_sum] + apply sum_congr rfl + intro i hi + rw [← mul_prod_erase S b hi] + have hne : (∏ j ∈ S.erase i, b j) ≠ 0 := prod_ne_zero_iff.mpr (fun j _ => hb j) + field_simp + +lemma weighted_raise_injective [Fintype α] [Field K] + (k : ℕ) (hk : 2*k < Fintype.card α) + (hchar : ∀ j : ℕ, 0 < j → j ≤ Fintype.card α → (j : K) ≠ 0) + (b : α → K) (hb : ∀ i, b i ≠ 0) + (f : Finset α → K) (hf : ∀ S, S.card ≠ k → f S = 0) + (hu : ∀ S, WeightedRaise b f S = 0) : f = 0 := by + let g : Finset α → K := fun T => f T / ∏ i ∈ T, b i + have hg : g = 0 := raise_injective_below_middle k hk hchar g + (fun S hS => by simp [g, hf S hS]) (fun S => by + have he := hu S + rw [weighted_raise_rescale b hb f S] at he + exact (mul_eq_zero.mp he).resolve_left (prod_ne_zero_iff.mpr (fun i _ => hb i))) + funext S + have he := congrFun hg S + change f S / (∏ i ∈ S, b i) = 0 at he + exact (div_eq_zero_iff.mp he).resolve_right (prod_ne_zero_iff.mpr (fun i _ => hb i)) + + + +def LinMul [Semiring K] (a : K) (b : α → K) (f : Finset α → K) (S : Finset α) : K := + (a + ∑ i ∈ S, b i) * f S + WeightedRaise b f S + +def DegreeLE [Zero K] (d : ℕ) (f : Finset α → K) : Prop := + ∀ S, d < S.card → f S = 0 + +lemma weighted_raise_top [Fintype α] [Field K] + (d : ℕ) (a : K) (b : α → K) (f : Finset α → K) + (hf : DegreeLE d f) (hprod : ∀ S, LinMul a b f S = 0) (S : Finset α) : + WeightedRaise b (fun T => if T.card = d then f T else 0) S = 0 := by + by_cases hS : S.card = d+1 + · have hzero : f S = 0 := hf S (by omega) + have he := hprod S + unfold LinMul at he + rw [hzero, mul_zero, zero_add] at he + calc + _ = WeightedRaise b f S := by + apply sum_congr rfl + intro i hi + have hcard : (S.erase i).card = d := by + rw [card_erase_of_mem hi, hS]; omega + simp only [hcard, ite_true] + _ = 0 := he + · apply sum_eq_zero + intro i hi + have hcard : (S.erase i).card ≠ d := by + rw [card_erase_of_mem hi] + have := card_pos.mpr ⟨i, hi⟩ + omega + simp [hcard] + + + +theorem linMul_injective_low_degree [Fintype α] [Field K] + (d : ℕ) (hd : 2*d < Fintype.card α) + (hchar : ∀ j : ℕ, 0 < j → j ≤ Fintype.card α → (j : K) ≠ 0) + (a : K) (b : α → K) (hb : ∀ i, b i ≠ 0) + (f : Finset α → K) (hf : DegreeLE d f) + (hprod : ∀ S, LinMul a b f S = 0) : f = 0 := by + induction d generalizing f with + | zero => + have ht := weighted_raise_injective 0 hd hchar b hb + (fun S => if S.card = 0 then f S else 0) + (fun S hS => by simp [hS]) (weighted_raise_top 0 a b f hf hprod) + funext S + by_cases he : S.card = 0 + · simpa [he] using congrFun ht S + · exact hf S (by omega) + | succ d ih => + have ht := weighted_raise_injective (d+1) hd hchar b hb + (fun S => if S.card = d+1 then f S else 0) + (fun S hS => by simp [hS]) (weighted_raise_top (d+1) a b f hf hprod) + apply ih (by omega) f + intro S hS + by_cases he : S.card = d+1 + · simpa [he] using congrFun ht S + · exact hf S (by omega) + exact hprod + +lemma map_linMul {L : Type*} [Semiring K] [Semiring L] (φ : K →+* L) + (a : K) (b : α → K) (f : Finset α → K) (S : Finset α) : + φ (LinMul a b f S) = LinMul (φ a) (fun i => φ (b i)) (fun T => φ (f T)) S := by + simp only [LinMul, WeightedRaise, map_add, map_mul, map_sum] + +lemma intCast_linMul [Ring K] (a : ℤ) (b : α → ℤ) (f : Finset α → ℤ) + (S : Finset α) : + ((LinMul a b f S : ℤ) : K) = LinMul (a : K) (fun i => (b i : K)) + (fun T => (f T : K)) S := by + simpa only [Int.coe_castRingHom] using map_linMul (Int.castRingHom K) a b f S + +lemma linMul_scalar [CommSemiring K] (c a : K) (b : α → K) + (f : Finset α → K) (S : Finset α) : + LinMul a b (fun T => c * f T) S = c * LinMul a b f S := by + unfold LinMul WeightedRaise + rw [mul_add, mul_sum] + congr 1 + · ring + · apply sum_congr rfl; intro i hi; ring + + +def Clears (D : ℕ) (f : Finset α → ℚ) : Prop := + ∀ S, ∃ z : ℤ, (D : ℚ) * f S = z + +def IntegralCoeffs (f : Finset α → ℚ) : Prop := + ∀ S, ∃ z : ℤ, f S = z + + + +lemma clear_divide_prime [Fintype α] + (d : ℕ) (hd : 2*d < Fintype.card α) + (a : ℤ) (b : α → ℤ) (f : Finset α → ℚ) (hf : DegreeLE d f) + (hprod : IntegralCoeffs (LinMul (a : ℚ) (fun i => (b i : ℚ)) f)) + (D p : ℕ) (hp : p.Prime) (hpD : p ∣ D) + (hlarge : Fintype.card α < p) (hb : ∀ i, ¬ (p : ℤ) ∣ b i) + (hD : Clears D f) : Clears (D/p) f := by + classical + let : Fact (Nat.Prime p) := ⟨hp⟩ + choose c hc using hD + choose g hg using hprod + have hcdeg (S : Finset α) (hS : d < S.card) : c S = 0 := by + have he := hc S + rw [hf S hS, mul_zero] at he + exact_mod_cast he.symm + have hmul (S : Finset α) : LinMul a b c S = (D : ℤ) * g S := by + apply (Int.cast_injective (α := ℚ)) + push_cast + rw [intCast_linMul] + change LinMul (a : ℚ) (fun i => (b i : ℚ)) (fun T => (c T : ℚ)) S = _ + have hfc : (fun T => (c T : ℚ)) = fun T => (D : ℚ) * f T := + funext (fun T => (hc T).symm) + rw [hfc, linMul_scalar, hg S] + have hchar (j : ℕ) (hj : 0 < j) (hjn : j ≤ Fintype.card α) : + (j : ZMod p) ≠ 0 := by + rw [Ne, ZMod.natCast_eq_zero_iff] + exact Nat.not_dvd_of_pos_of_lt hj (hjn.trans_lt hlarge) + have hbc (i : α) : (b i : ZMod p) ≠ 0 := by + rw [Ne, ZMod.intCast_zmod_eq_zero_iff_dvd] + exact hb i + have hzero : (fun S => (c S : ZMod p)) = 0 := by + apply linMul_injective_low_degree d hd hchar (a : ZMod p) + (fun i => (b i : ZMod p)) hbc + · intro S hS; simp [hcdeg S hS] + · intro S + rw [← intCast_linMul, hmul S] + push_cast + rw [(ZMod.natCast_eq_zero_iff D p).mpr hpD, zero_mul] + intro S + have hpCS : (p : ℤ) ∣ c S := + (ZMod.intCast_zmod_eq_zero_iff_dvd (c S) p).mp (congrFun hzero S) + obtain ⟨z, hz⟩ := hpCS + refine ⟨z, ?_⟩ + have hpn : (p : ℚ) ≠ 0 := by exact_mod_cast hp.ne_zero + apply mul_left_cancel₀ hpn + have hDC : ((D/p : ℕ) : ℚ) * (p : ℚ) = D := by + exact_mod_cast Nat.div_mul_cancel hpD + calc + (p : ℚ) * (((D/p : ℕ) : ℚ) * f S) = + (((D/p : ℕ) : ℚ) * (p : ℚ)) * f S := by ring + _ = (D : ℚ) * f S := by rw [hDC] + _ = c S := hc S + _ = (p : ℚ) * z := by exact_mod_cast hz + + +theorem integral_of_linMul_integral [Fintype α] + (d : ℕ) (hd : 2*d < Fintype.card α) + (a : ℤ) (b : α → ℤ) (f : Finset α → ℚ) (hf : DegreeLE d f) + (hprod : IntegralCoeffs (LinMul (a : ℚ) (fun i => (b i : ℚ)) f)) + (D : ℕ) (hDpos : 0 < D) (hD : Clears D f) + (hrough : ∀ p : ℕ, p.Prime → p ∣ D → + Fintype.card α < p ∧ ∀ i, ¬ (p : ℤ) ∣ b i) : IntegralCoeffs f := by + induction D using Nat.strong_induction_on with + | h D ih => + by_cases hD1 : D = 1 + · subst D + intro S + obtain ⟨z, hz⟩ := hD S + exact ⟨z, by simpa using hz⟩ + · obtain ⟨p, hp, hpD⟩ := Nat.exists_prime_and_dvd hD1 + obtain ⟨hlarge, hb⟩ := hrough p hp hpD + have hDsmall : D/p < D := Nat.div_lt_self hDpos hp.one_lt + have hDppos : 0 < D/p := Nat.div_pos (Nat.le_of_dvd hDpos hpD) hp.pos + apply ih (D/p) hDsmall hDppos + (clear_divide_prime d hd a b f hf hprod D p hp hpD hlarge hb hD) + intro q hq hqD + exact hrough q hq (hqD.trans (Nat.div_dvd_of_dvd hpD)) + + +def Eval [AddCommMonoid K] (f : Finset α → K) (S : Finset α) : K := + ∑ T ∈ S.powerset, f T + +lemma eval_weightedRaise [CommSemiring K] (b : α → K) + (f : Finset α → K) (S : Finset α) : + Eval (WeightedRaise b f) S = + ∑ U ∈ S.powerset, (∑ i ∈ S \ U, b i) * f U := by + unfold Eval WeightedRaise + rw [Finset.sum_sigma'] + calc + _ = ∑ p ∈ S.powerset.sigma (fun U => S \ U), b p.2 * f p.1 := by + apply Finset.sum_bij' + (fun p _ => (⟨p.1.erase p.2, p.2⟩ : (U : Finset α) × α)) + (fun p _ => (⟨insert p.2 p.1, p.2⟩ : (U : Finset α) × α)) + · intro p hp + obtain ⟨hT, hi⟩ := Finset.mem_sigma.mp hp + have hTS := mem_powerset.mp hT + exact mem_sigma.mpr ⟨mem_powerset.mpr ((erase_subset _ _).trans hTS), + mem_sdiff.mpr ⟨hTS hi, notMem_erase _ _⟩⟩ + · intro p hp + obtain ⟨hU, hi⟩ := Finset.mem_sigma.mp hp + obtain ⟨hiS, hiU⟩ := mem_sdiff.mp hi + exact mem_sigma.mpr ⟨mem_powerset.mpr (insert_subset hiS (mem_powerset.mp hU)), + mem_insert_self _ _⟩ + · intro p hp + exact Sigma.ext (insert_erase (mem_sigma.mp hp).2) (heq_of_eq rfl) + · intro p hp + exact Sigma.ext (erase_insert (mem_sdiff.mp (mem_sigma.mp hp).2).2) (heq_of_eq rfl) + · intro p hp; rfl + _ = _ := by + rw [← Finset.sum_sigma' S.powerset (fun U => S \ U) (fun U i => b i * f U)] + simp_rw [sum_mul] + +lemma eval_linMul [CommSemiring K] (a : K) (b : α → K) + (f : Finset α → K) (S : Finset α) : + Eval (LinMul a b f) S = (a + ∑ i ∈ S, b i) * Eval f S := by + change (∑ T ∈ S.powerset, ((a + ∑ i ∈ T, b i) * f T + WeightedRaise b f T)) = _ + rw [sum_add_distrib] + change _ + Eval (WeightedRaise b f) S = _ + rw [eval_weightedRaise, ← sum_add_distrib] + unfold Eval + rw [mul_sum] + apply sum_congr rfl + intro T hT + have he : (∑ i ∈ T, b i) + ∑ i ∈ S \ T, b i = ∑ i ∈ S, b i := + by simpa only [add_comm] using (sum_sdiff (f := b) (mem_powerset.mp hT)) + rw [← he] + ring + +omit [DecidableEq α] in +lemma eval_integral_of_coeffs [DecidableEq α] (f : Finset α → ℚ) (hf : IntegralCoeffs f) + (S : Finset α) : ∃ z : ℤ, Eval f S = z := by + choose g hg using hf + refine ⟨∑ T ∈ S.powerset, g T, ?_⟩ + simp only [Eval, hg, Int.cast_sum] + + +lemma integral_coeffs_of_eval (f : Finset α → ℚ) + (hf : ∀ S, ∃ z : ℤ, Eval f S = z) : IntegralCoeffs f := by + intro S + induction S using Finset.strongInductionOn with + | _ S ih => + obtain ⟨z, hz⟩ := hf S + have hi : ∀ T ∈ S.powerset.erase S, ∃ a : ℤ, f T = a := by + intro T hT + obtain ⟨hTS, hT⟩ := mem_erase.mp hT + have hsub := mem_powerset.mp hT + exact ih T (Finset.ssubset_iff_subset_ne.mpr ⟨hsub, hTS⟩) + choose g hg using hi + let v : ℤ := ∑ T : {T // T ∈ S.powerset.erase S}, g T.1 T.2 + have hv : (∑ T ∈ S.powerset.erase S, f T) = (v : ℚ) := by + rw [← sum_attach] + simp only [attach_eq_univ, v, Int.cast_sum] + apply sum_congr rfl + intro T hT + exact hg T.1 T.2 + refine ⟨z-v, ?_⟩ + have he : f S + ∑ T ∈ S.powerset.erase S, f T = Eval f S := by + exact add_sum_erase _ _ (mem_powerset.mpr (Subset.refl _)) + rw [hv, hz] at he + push_cast + linarith + +lemma degree_linMul [Semiring K] (d : ℕ) (a : K) (b : α → K) + (f : Finset α → K) (hf : DegreeLE d f) : DegreeLE (d+1) (LinMul a b f) := by + intro S hS + unfold LinMul WeightedRaise + rw [hf S (by omega), mul_zero, zero_add] + apply sum_eq_zero + intro i hi + have hcard : d < (S.erase i).card := by rw [card_erase_of_mem hi]; omega + rw [hf _ hcard, mul_zero] + +def LinPow [Semiring K] (a : K) (b : α → K) (f : Finset α → K) : ℕ → Finset α → K + | 0 => f + | e+1 => LinMul a b (LinPow a b f e) + +lemma eval_linPow [CommSemiring K] (a : K) (b : α → K) + (f : Finset α → K) (e : ℕ) (S : Finset α) : + Eval (LinPow a b f e) S = (a + ∑ i ∈ S, b i)^e * Eval f S := by + induction e with + | zero => simp [LinPow] + | succ e ih => rw [LinPow, eval_linMul, ih, pow_succ]; ring + +lemma degree_linPow [Semiring K] (d : ℕ) (a : K) (b : α → K) + (f : Finset α → K) (hf : DegreeLE d f) (e : ℕ) : + DegreeLE (d+e) (LinPow a b f e) := by + induction e with + | zero => exact hf + | succ e ih => exact degree_linMul (d+e) a b _ ih + +lemma clears_linMul (D : ℕ) (a : ℤ) (b : α → ℤ) (f : Finset α → ℚ) + (hD : Clears D f) : Clears D (LinMul (a : ℚ) (fun i => (b i : ℚ)) f) := by + choose c hc using hD + intro S + refine ⟨LinMul a b c S, ?_⟩ + rw [intCast_linMul, ← linMul_scalar] + congr 1 + exact funext hc + +lemma clears_linPow (D : ℕ) (a : ℤ) (b : α → ℤ) (f : Finset α → ℚ) + (hD : Clears D f) (e : ℕ) : + Clears D (LinPow (a : ℚ) (fun i => (b i : ℚ)) f e) := by + induction e with + | zero => exact hD + | succ e ih => exact clears_linMul D a b _ ih + + +theorem integral_of_linPow_integral [Fintype α] + (d e : ℕ) (hd : 2*(d+e) < Fintype.card α) + (a : ℤ) (b : α → ℤ) (f : Finset α → ℚ) (hf : DegreeLE d f) + (hprod : IntegralCoeffs (LinPow (a : ℚ) (fun i => (b i : ℚ)) f e)) + (D : ℕ) (hDpos : 0 < D) (hD : Clears D f) + (hrough : ∀ p : ℕ, p.Prime → p ∣ D → + Fintype.card α < p ∧ ∀ i, ¬ (p : ℤ) ∣ b i) : IntegralCoeffs f := by + induction e with + | zero => exact hprod + | succ e ih => + have hg := integral_of_linMul_integral (d+e) (by omega) a b + (LinPow (a : ℚ) (fun i => (b i : ℚ)) f e) + (degree_linPow d _ _ f hf e) hprod D hDpos (clears_linPow D a b f hD e) hrough + exact ih (by omega) hg + + +theorem integral_of_power_vertex_integral [Fintype α] + (d e : ℕ) (hd : 2*(d+e) < Fintype.card α) + (a : ℤ) (b : α → ℤ) (f : Finset α → ℚ) (hf : DegreeLE d f) + (hprod : ∀ S, ∃ z : ℤ, ((a : ℚ) + ∑ i ∈ S, (b i : ℚ))^e * Eval f S = z) + (D : ℕ) (hDpos : 0 < D) (hD : Clears D f) + (hrough : ∀ p : ℕ, p.Prime → p ∣ D → + Fintype.card α < p ∧ ∀ i, ¬ (p : ℤ) ∣ b i) : IntegralCoeffs f := by + apply integral_of_linPow_integral d e hd a b f hf _ D hDpos hD hrough + apply integral_coeffs_of_eval + intro S + rw [eval_linPow] + exact hprod S + + +lemma sum_subset_incidence [AddCommMonoid K] (S : Finset α) + (F : Finset α → Finset α → K) : + (∑ T ∈ S.powerset, ∑ U ∈ T.powerset, F T U) = + ∑ U ∈ S.powerset, ∑ V ∈ (S \ U).powerset, F (U ∪ V) U := by + rw [sum_sigma', sum_sigma'] + apply sum_bij' + (fun p _ => (⟨p.2, p.1 \ p.2⟩ : (U : Finset α) × Finset α)) + (fun p _ => (⟨p.1 ∪ p.2, p.1⟩ : (U : Finset α) × Finset α)) + · intro p hp + obtain ⟨hT, hU⟩ := mem_sigma.mp hp + have hTS := mem_powerset.mp hT + have hUT := mem_powerset.mp hU + exact mem_sigma.mpr ⟨mem_powerset.mpr (hUT.trans hTS), + mem_powerset.mpr (sdiff_subset_sdiff_left _ hTS)⟩ + · intro p hp + obtain ⟨hU, hV⟩ := mem_sigma.mp hp + have hUS := mem_powerset.mp hU + have hVsub := mem_powerset.mp hV + exact mem_sigma.mpr ⟨mem_powerset.mpr (union_subset hUS (hVsub.trans sdiff_subset)), + mem_powerset.mpr subset_union_left⟩ + · intro p hp + have hUT := mem_powerset.mp (mem_sigma.mp hp).2 + exact Sigma.ext (union_sdiff_of_subset hUT) (heq_of_eq rfl) + · intro p hp + have hV := mem_powerset.mp (mem_sigma.mp hp).2 + have hd : Disjoint p.1 p.2 := by + apply disjoint_left.mpr + intro i hiU hiV + exact (mem_sdiff.mp (hV hiV)).2 hiU + exact Sigma.ext rfl (heq_of_eq (union_sdiff_cancel_left hd)) + · intro p hp + have hUT := mem_powerset.mp (mem_sigma.mp hp).2 + rw [union_sdiff_of_subset hUT] + + +def Mobius [Ring K] (g : Finset α → K) (S : Finset α) : K := + ∑ T ∈ S.powerset, (-1 : K)^(S \ T).card * g T + +lemma eval_mobius [CommRing K] (g : Finset α → K) (S : Finset α) : + Eval (Mobius g) S = g S := by + unfold Eval Mobius + rw [sum_subset_incidence] + have hs : (∑ U ∈ S.powerset, ∑ V ∈ (S \ U).powerset, + (-1 : K)^((U ∪ V) \ U).card * g U) = + ∑ U ∈ S.powerset, (if S \ U = ∅ then 1 else 0) * g U := by + apply sum_congr rfl + intro U hU + calc + _ = ∑ V ∈ (S \ U).powerset, (-1 : K)^V.card * g U := by + apply sum_congr rfl + intro V hV + have hd : Disjoint U V := by + apply disjoint_left.mpr + intro i hiU hiV + exact (mem_sdiff.mp (mem_powerset.mp hV hiV)).2 hiU + rw [union_sdiff_cancel_left hd] + _ = _ := by rw [← sum_mul, alternating_powerset] + rw [hs, sum_eq_single S] + · simp + · intro U hU hUS + have hne : S \ U ≠ ∅ := by + intro he + exact hUS (Subset.antisymm (mem_powerset.mp hU) (sdiff_eq_empty_iff_subset.mp he)) + simp [hne] + · intro hS + exact False.elim (hS (mem_powerset.mpr (Subset.refl _))) + +lemma eval_injective [AddCancelCommMonoid K] (f g : Finset α → K) + (h : ∀ S, Eval f S = Eval g S) : f = g := by + funext S + induction S using Finset.strongInductionOn with + | _ S ih => + have he := h S + have hf : Eval f S = f S + ∑ T ∈ S.powerset.erase S, f T := + (add_sum_erase _ _ (mem_powerset.mpr (Subset.refl _))).symm + have hg : Eval g S = g S + ∑ T ∈ S.powerset.erase S, g T := + (add_sum_erase _ _ (mem_powerset.mpr (Subset.refl _))).symm + rw [hf, hg] at he + have hs : (∑ T ∈ S.powerset.erase S, f T) = ∑ T ∈ S.powerset.erase S, g T := by + apply sum_congr rfl + intro T hT + obtain ⟨hne, hsub⟩ := mem_erase.mp hT + exact ih T (Finset.ssubset_iff_subset_ne.mpr ⟨mem_powerset.mp hsub, hne⟩) + rw [hs] at he + exact add_right_cancel he + +lemma mobius_eval [CommRing K] (f : Finset α → K) (S : Finset α) : + Mobius (Eval f) S = f S := by + have he : Mobius (Eval f) = f := eval_injective _ _ (eval_mobius (Eval f)) + exact congrFun he S + + +def Interp [Ring K] (d : ℕ) (g : Finset α → K) (S : Finset α) : K := + if S.card ≤ d then Mobius g S else 0 + +lemma degree_interp [Ring K] (d : ℕ) (g : Finset α → K) : DegreeLE d (Interp d g) := by + intro S hS + simp [Interp, Nat.not_le_of_lt hS] + +lemma eval_interp_low [CommRing K] (d : ℕ) (g : Finset α → K) + (S : Finset α) (hS : S.card ≤ d) : Eval (Interp d g) S = g S := by + rw [← eval_mobius g S] + apply sum_congr rfl + intro T hT + exact ite_eq_left ((card_le_card (mem_powerset.mp hT)).trans hS) + +omit [DecidableEq α] in +lemma map_eval [DecidableEq α] {L : Type*} [AddCommMonoid K] [AddCommMonoid L] (φ : K →+ L) + (f : Finset α → K) (S : Finset α) : φ (Eval f S) = Eval (fun T => φ (f T)) S := by + simp only [Eval, map_sum] + +lemma map_mobius {L : Type*} [Ring K] [Ring L] (φ : K →+* L) + (f : Finset α → K) (S : Finset α) : φ (Mobius f S) = Mobius (fun T => φ (f T)) S := by + simp only [Mobius, map_sum, map_mul, map_pow, map_neg, map_one] + +lemma map_interp {L : Type*} [Ring K] [Ring L] (φ : K →+* L) + (d : ℕ) (f : Finset α → K) (S : Finset α) : + φ (Interp d f S) = Interp d (fun T => φ (f T)) S := by + by_cases hS : S.card ≤ d <;> simp [Interp, hS, map_mobius] + +lemma mobius_scalar [CommRing K] (c : K) (f : Finset α → K) (S : Finset α) : + Mobius (fun T => c * f T) S = c * Mobius f S := by + unfold Mobius + rw [mul_sum] + apply sum_congr rfl + intro T hT + ring + +lemma interp_sub [Ring K] (d : ℕ) (f g : Finset α → K) : + Interp d (fun T => f T - g T) = fun T => Interp d f T - Interp d g T := by + funext S + by_cases hS : S.card ≤ d + · simp only [Interp, hS, ite_true, Mobius, mul_sub, sum_sub_distrib] + · simp [Interp, hS] + +lemma interp_eval_degree [CommRing K] (d : ℕ) (f : Finset α → K) (hf : DegreeLE d f) : + Interp d (Eval f) = f := by + funext S + by_cases hS : S.card ≤ d + · simp [Interp, hS, mobius_eval] + · simp [Interp, hS, hf S (by omega)] + +lemma clears_interp (D d : ℕ) (f : Finset α → ℚ) (hD : Clears D f) : + Clears D (Interp d f) := by + choose c hc using hD + intro S + by_cases hS : S.card ≤ d + · refine ⟨Mobius c S, ?_⟩ + simp only [Interp, hS, ite_true] + have he := map_mobius (Int.castRingHom ℚ) c S + simp only [Int.coe_castRingHom] at he + rw [he, ← mobius_scalar] + congr 1 + exact funext hc + · exact ⟨0, by simp [Interp, hS]⟩ + +lemma abs_mobius_le (g : Finset α → ℝ) (S : Finset α) (δ : ℝ) + (hg : ∀ T ∈ S.powerset, |g T| ≤ δ) : + |Mobius g S| ≤ (2 : ℝ)^S.card * δ := by + unfold Mobius + calc + _ ≤ ∑ T ∈ S.powerset, |(-1 : ℝ)^(S \ T).card * g T| := abs_sum_le_sum_abs _ _ + _ = ∑ T ∈ S.powerset, |g T| := by simp + _ ≤ S.powerset.card • δ := sum_le_card_nsmul _ _ _ hg + _ = _ := by rw [card_powerset, nsmul_eq_mul]; simp + +lemma abs_interp_le [Fintype α] (d : ℕ) (g : Finset α → ℝ) (δ : ℝ) (hδ : 0 ≤ δ) + (hg : ∀ T, T.card ≤ d → |g T| ≤ δ) (S : Finset α) : + |Interp d g S| ≤ (2 : ℝ)^(Fintype.card α) * δ := by + by_cases hS : S.card ≤ d + · rw [Interp, ite_eq_left hS] + exact (abs_mobius_le g S δ (fun T hT => hg T ((card_le_card (mem_powerset.mp hT)).trans hS))).trans + (mul_le_mul_of_nonneg_right (pow_le_pow_right₀ (by norm_num) (card_le_univ S)) hδ) + · simp only [Interp, ite_eq_right hS, abs_zero] + positivity + +lemma abs_eval_interp_le [Fintype α] (d : ℕ) (g : Finset α → ℝ) (δ : ℝ) (hδ : 0 ≤ δ) + (hg : ∀ T, T.card ≤ d → |g T| ≤ δ) (S : Finset α) : + |Eval (Interp d g) S| ≤ ((2 : ℝ)^(Fintype.card α))^2 * δ := by + unfold Eval + calc + _ ≤ ∑ T ∈ S.powerset, |Interp d g T| := abs_sum_le_sum_abs _ _ + _ ≤ S.powerset.card • ((2 : ℝ)^(Fintype.card α) * δ) := + sum_le_card_nsmul _ _ _ (fun T _ => abs_interp_le d g δ hδ hg T) + _ ≤ ((2 : ℝ)^(Fintype.card α))^2 * δ := by + rw [card_powerset, nsmul_eq_mul] + push_cast + calc + _ ≤ (2 : ℝ)^(Fintype.card α) * ((2 : ℝ)^(Fintype.card α) * δ) := + mul_le_mul_of_nonneg_right (pow_le_pow_right₀ (by norm_num) (card_le_univ S)) (by positivity) + _ = _ := by ring + +lemma eval_interp_error [Fintype α] (d : ℕ) (θ : Finset α → ℝ) (hθ : DegreeLE d θ) + (g : Finset α → ℝ) (δ : ℝ) (hδ : 0 ≤ δ) + (hg : ∀ T, T.card ≤ d → |Eval θ T - g T| ≤ δ) (S : Finset α) : + |Eval θ S - Eval (Interp d g) S| ≤ ((2 : ℝ)^(Fintype.card α))^2 * δ := by + have h := abs_eval_interp_le d (fun T => Eval θ T - g T) δ hδ hg S + rw [interp_sub, interp_eval_degree d θ hθ] at h + simpa only [Eval, sum_sub_distrib] using h + +omit [DecidableEq α] in +lemma clears_eval [DecidableEq α] (D : ℕ) (f : Finset α → ℚ) (hD : Clears D f) : + Clears D (Eval f) := by + choose c hc using hD + intro S + refine ⟨∑ T ∈ S.powerset, c T, ?_⟩ + simp only [Eval, mul_sum, hc, Int.cast_sum] + +lemma denominator_clears_div (D e : ℕ) (t k : ℤ) (ht : 0 < t) + (hD : t.natAbs^e ∣ D) : ∃ z : ℤ, (D : ℚ) * ((k : ℚ)/(t : ℚ)^e) = z := by + obtain ⟨c, hc⟩ := hD + refine ⟨(c : ℤ)*k, ?_⟩ + have hcast : ((t.natAbs : ℕ) : ℚ) = (t : ℚ) := by + have he := congrArg (Int.castRingHom ℚ) (Int.natAbs_of_nonneg ht.le) + simpa only [Int.coe_castRingHom, Int.cast_natCast] using he + have hne : (t : ℚ)^e ≠ 0 := pow_ne_zero _ (by exact_mod_cast ht.ne') + rw [hc] + push_cast + rw [hcast] + field_simp + +lemma rational_exact_of_small (D : ℕ) (hD : 0 < D) (q : ℚ) (z : ℤ) + (hc : ∃ c : ℤ, (D : ℚ)*q = c) + (hsmall : (D : ℝ)*|(q : ℝ)-(z : ℝ)| < 1) : q = z := by + obtain ⟨c, hc⟩ := hc + have hcr : (D : ℝ)*(q : ℝ) = c := by exact_mod_cast hc + have hzero : c - (D : ℤ)*z = 0 := by + apply Int.abs_lt_one_iff.mp + have he : |((c - (D : ℤ)*z : ℤ) : ℝ)| = (D : ℝ)*|(q : ℝ)-(z : ℝ)| := by + push_cast + rw [← hcr, ← mul_sub, abs_mul, abs_of_nonneg (Nat.cast_nonneg D)] + exact_mod_cast (he ▸ hsmall) + apply mul_left_cancel₀ (show (D : ℚ) ≠ 0 by exact_mod_cast hD.ne') + rw [hc] + exact_mod_cast (sub_eq_zero.mp hzero) + + + +theorem rough_rounding_local [Fintype α] (d e M : ℕ) (hdim : 2*(d+e) < Fintype.card α) + (a : ℤ) (b : α → ℤ) (θ : Finset α → ℝ) (hθ : DegreeLE d θ) + (htpos : ∀ S : Finset α, 0 < a + ∑ i ∈ S, b i) + (htbound : ∀ S : Finset α, a + ∑ i ∈ S, b i ≤ (M : ℤ)) + (hrough : ∀ p : ℕ, p.Prime → (∃ S : Finset α, (p : ℤ) ∣ a + ∑ i ∈ S, b i) → + Fintype.card α < p ∧ ∀ i, ¬ (p : ℤ) ∣ b i) + (ε : ℝ) (hε : 0 ≤ ε) + (hsmall : (1+(M : ℝ)^e * (2^(Fintype.card α) : ℝ)^2) * ε * + (M : ℝ)^(e*2^(Fintype.card α)) < 1) + (δ : Finset α → ℝ) (hδε : ∀ S, δ S ≤ ε) + (hnear : ∀ S : Finset α, ∃ z : ℤ, + |((a + ∑ i ∈ S, b i : ℤ) : ℝ)^e * Eval θ S - z| ≤ δ S) : + ∃ f : Finset α → ℚ, DegreeLE d f ∧ IntegralCoeffs f ∧ + ∀ S, |Eval θ S - ((Eval f S : ℚ) : ℝ)| ≤ δ S / ((a + ∑ i ∈ S, b i : ℤ) : ℝ)^e := by + classical + let t : Finset α → ℤ := fun S => a + ∑ i ∈ S, b i + choose k hk using hnear + let g : Finset α → ℚ := fun S => (k S : ℚ)/(t S : ℚ)^e + let f : Finset α → ℚ := Interp d g + let D : ℕ := ∏ S : Finset α, (t S).natAbs^e + have ht (S : Finset α) : 0 < t S := htpos S + have htr (S : Finset α) : 0 < (t S : ℝ) := by exact_mod_cast ht S + have htt (S : Finset α) : (t S).natAbs ≤ M := by + have he : ((t S).natAbs : ℤ) ≤ (M : ℤ) := + (Int.natAbs_of_nonneg (ht S).le).trans_le (htbound S) + exact Int.ofNat_le.mp he + have hDpos : 0 < D := prod_pos (fun S _ => pow_pos (Int.natAbs_pos.mpr (ht S).ne') _) + have hDbound : D ≤ M^(e*2^(Fintype.card α)) := by + calc + D ≤ ∏ S : Finset α, M^e := + prod_le_prod (fun S _ => Nat.pow_le_pow_left (htt S) e) + _ = _ := by rw [prod_const, card_univ, Fintype.card_finset, ← pow_mul] + have hDg : Clears D g := by + intro S + exact denominator_clears_div D e (t S) (k S) (ht S) + (dvd_prod_of_mem (fun T : Finset α => (t T).natAbs^e) (mem_univ _)) + have hDf : Clears D f := clears_interp D d g hDg + have hDr : ∀ p : ℕ, p.Prime → p ∣ D → + Fintype.card α < p ∧ ∀ i, ¬ (p : ℤ) ∣ b i := by + intro p hp hpD + obtain ⟨S, _, hpS⟩ := (hp.prime.dvd_finsetProd_iff (fun S : Finset α => (t S).natAbs^e)).mp hpD + exact hrough p hp ⟨S, Int.natCast_dvd.mpr (hp.dvd_of_dvd_pow hpS)⟩ + have hgnear (S : Finset α) : |Eval θ S - (g S : ℝ)| ≤ ε := by + have hp1 : (1 : ℝ) ≤ (t S : ℝ)^e := by + apply one_le_pow₀ + have h1 : (1 : ℤ) ≤ t S := ht S + exact_mod_cast h1 + have he : (t S : ℝ)^e * (Eval θ S - (g S : ℝ)) = + (t S : ℝ)^e * Eval θ S - (k S : ℝ) := by + simp only [g, Rat.cast_div, Rat.cast_intCast, Rat.cast_pow] + field_simp + have hh := (hk S).trans (hδε S) + change |(t S : ℝ)^e * Eval θ S - (k S : ℝ)| ≤ ε at hh + rw [← he, abs_mul, abs_of_pos (pow_pos (htr S) e)] at hh + exact (le_mul_of_one_le_left (abs_nonneg _) hp1).trans hh + have heval (S : Finset α) : ((Eval f S : ℚ) : ℝ) = + Eval (Interp d (fun T => (g T : ℝ))) S := by + simp only [Eval, Rat.cast_sum] + apply sum_congr rfl + intro T hT + exact map_interp (Rat.castHom ℝ) d g T + have herr (S : Finset α) : |Eval θ S - ((Eval f S : ℚ) : ℝ)| ≤ + ((2 : ℝ)^(Fintype.card α))^2 * ε := by + rw [heval] + exact eval_interp_error d θ hθ _ ε hε (fun T _ => hgnear T) S + have hprodnear (S : Finset α) : + |(t S : ℝ)^e * ((Eval f S : ℚ) : ℝ) - (k S : ℝ)| ≤ + (1+(M : ℝ)^e * (2^(Fintype.card α) : ℝ)^2) * ε := by + have htpbound : (t S : ℝ)^e ≤ (M : ℝ)^e := + pow_le_pow_left₀ (htr S).le (by exact_mod_cast htbound S) e + calc + _ = |(t S : ℝ)^e * (((Eval f S : ℚ) : ℝ) - Eval θ S) + + ((t S : ℝ)^e * Eval θ S - (k S : ℝ))| := by congr 1; ring + _ ≤ |(t S : ℝ)^e * (((Eval f S : ℚ) : ℝ) - Eval θ S)| + + |(t S : ℝ)^e * Eval θ S - (k S : ℝ)| := abs_add_le _ _ + _ = (t S : ℝ)^e * |Eval θ S - ((Eval f S : ℚ) : ℝ)| + + |(t S : ℝ)^e * Eval θ S - (k S : ℝ)| := by + rw [abs_mul, abs_of_pos (pow_pos (htr S) e), abs_sub_comm] + _ ≤ (M : ℝ)^e * (((2 : ℝ)^(Fintype.card α))^2 * ε) + ε := + add_le_add (mul_le_mul htpbound (herr S) (abs_nonneg _) (by positivity)) ((hk S).trans (hδε S)) + _ = _ := by ring + have hexact (S : Finset α) : (t S : ℚ)^e * Eval f S = (k S : ℚ) := by + apply rational_exact_of_small D hDpos + · obtain ⟨c, hc⟩ := clears_eval D f hDf S + refine ⟨(t S)^e*c, ?_⟩ + push_cast + rw [← hc] + ring + · push_cast + calc + _ ≤ (D : ℝ) * ((1+(M : ℝ)^e * (2^(Fintype.card α) : ℝ)^2) * ε) := + mul_le_mul_of_nonneg_left (hprodnear S) (Nat.cast_nonneg D) + _ ≤ (M : ℝ)^(e*2^(Fintype.card α)) * + ((1+(M : ℝ)^e * (2^(Fintype.card α) : ℝ)^2) * ε) := + mul_le_mul_of_nonneg_right (by exact_mod_cast hDbound) (by positivity) + _ = (1+(M : ℝ)^e * (2^(Fintype.card α) : ℝ)^2) * ε * + (M : ℝ)^(e*2^(Fintype.card α)) := by ring + _ < 1 := hsmall + refine ⟨f, degree_interp d g, ?_, ?_⟩ + · apply integral_of_power_vertex_integral d e hdim a b f (degree_interp d g) _ D hDpos hDf hDr + intro S + refine ⟨k S, ?_⟩ + simpa only [t, Int.cast_add, Int.cast_sum] using hexact S + · intro S + apply (le_div_iff₀ (pow_pos (htr S) e)).mpr + have hx : (t S : ℝ)^e * ((Eval f S : ℚ) : ℝ) = (k S : ℝ) := by exact_mod_cast hexact S + calc + _ = |(t S : ℝ)^e * Eval θ S - (k S : ℝ)| := by + rw [← hx, ← mul_sub, abs_mul, abs_of_pos (pow_pos (htr S) e)] + ring + _ ≤ δ S := hk S + + +theorem rough_rounding [Fintype α] (d e M : ℕ) (hdim : 2*(d+e) < Fintype.card α) + (a : ℤ) (b : α → ℤ) (θ : Finset α → ℝ) (hθ : DegreeLE d θ) + (htpos : ∀ S : Finset α, 0 < a + ∑ i ∈ S, b i) + (htbound : ∀ S : Finset α, a + ∑ i ∈ S, b i ≤ (M : ℤ)) + (hrough : ∀ p : ℕ, p.Prime → (∃ S : Finset α, (p : ℤ) ∣ a + ∑ i ∈ S, b i) → + Fintype.card α < p ∧ ∀ i, ¬ (p : ℤ) ∣ b i) + (ε : ℝ) (hε : 0 ≤ ε) + (hsmall : (1+(M : ℝ)^e * (2^(Fintype.card α) : ℝ)^2) * ε * + (M : ℝ)^(e*2^(Fintype.card α)) < 1) + (hnear : ∀ S : Finset α, ∃ z : ℤ, + |((a + ∑ i ∈ S, b i : ℤ) : ℝ)^e * Eval θ S - z| ≤ ε) : + ∃ f : Finset α → ℚ, DegreeLE d f ∧ IntegralCoeffs f ∧ + ∀ S, |Eval θ S - ((Eval f S : ℚ) : ℝ)| ≤ ε / ((a + ∑ i ∈ S, b i : ℤ) : ℝ)^e := by + exact rough_rounding_local d e M hdim a b θ hθ htpos htbound hrough ε hε hsmall + (fun _ => ε) (fun _ => le_rfl) hnear + +lemma mobius_sub [Ring K] (f g : Finset α → K) (S : Finset α) : + Mobius (fun T => f T - g T) S = Mobius f S - Mobius g S := by + simp only [Mobius, mul_sub, sum_sub_distrib] + +lemma eval_constant_coeff [Semiring K] (c : K) (S : Finset α) : + Eval (fun T : Finset α => if T = ∅ then c else 0) S = c := by + classical + simp [Eval] + +lemma mobius_const [CommRing K] (c : K) (S : Finset α) : + Mobius (fun _ => c) S = if S = ∅ then c else 0 := by + have he : (fun _ : Finset α => c) = Eval (fun T => if T = ∅ then c else 0) := + funext (fun T => (eval_constant_coeff c T).symm) + rw [he, mobius_eval] + + + +theorem constant_rounding [Fintype α] (d : ℕ) (θ : Finset α → ℝ) (hθ : DegreeLE d θ) + (c δ : ℝ) (hδ : 0 ≤ δ) (hsmall : (2 : ℝ)^(Fintype.card α)*δ < 1) + (hspread : ∀ S : Finset α, |Int.fract (Eval θ S)-c| ≤ δ) : + ∃ m : Finset α → ℤ, DegreeLE d m ∧ ∀ S, Eval m S = ⌊Eval θ S⌋ := by + let k : Finset α → ℤ := fun S => ⌊Eval θ S⌋ + refine ⟨Mobius k, ?_, eval_mobius k⟩ + intro S hS + have hnonempty : S ≠ ∅ := by + intro he + simp only [he, card_empty] at hS + omega + have hbound := abs_mobius_le (fun T => Int.fract (Eval θ T)-c) S δ + (fun T _ => hspread T) + have herr : Mobius (fun T => Int.fract (Eval θ T)-c) S = -((Mobius k S : ℤ) : ℝ) := by + simp only [Int.fract, mobius_sub, mobius_eval, hθ S hS, mobius_const, ite_eq_right hnonempty] + have hc := map_mobius (Int.castRingHom ℝ) k S + simpa only [Int.coe_castRingHom, zero_sub, sub_zero, k] using congrArg Neg.neg hc.symm + have hsmallS : (2 : ℝ)^S.card*δ < 1 := + (mul_le_mul_of_nonneg_right (pow_le_pow_right₀ (by norm_num) (card_le_univ S)) hδ).trans_lt hsmall + rw [herr, abs_neg] at hbound + apply Int.abs_lt_one_iff.mp + exact_mod_cast hbound.trans_lt hsmallS + +end BooleanRough + +end +end + +end OAI diff --git a/lean/OAI/Combinatorics/SumProduct/Alignment/BooleanRough02.lean b/lean/OAI/Combinatorics/SumProduct/Alignment/BooleanRough02.lean new file mode 100644 index 0000000000000000000000000000000000000000..ffc8c8495043a24590c40ecc5aa2980c2b324ff4 --- /dev/null +++ b/lean/OAI/Combinatorics/SumProduct/Alignment/BooleanRough02.lean @@ -0,0 +1,295 @@ +import Mathlib +import OAI.Combinatorics.SumProduct.Alignment.BooleanRough01 +import OAI.Combinatorics.SumProduct.Alignment.CoefficientPeeling01 +import OAI.Geometry.NilpotentCharts.Main + +namespace OAI + +section +section +noncomputable section +end + +end + +end + + +section + +noncomputable section +open Finset +open scoped BigOperators +namespace BooleanPeeling +open BooleanRough CoefficientPeeling +variable {α ι : Type*} [Fintype α] [DecidableEq α] [Fintype ι] [DecidableEq ι] + + +theorem peel_cube (degree : ι → ℕ) (D q M : ℕ) + (hdeg : ∀ i, 1 ≤ degree i ∧ degree i ≤ D) (hdim : 2*(q+D) < Fintype.card α) + (a : ℤ) (b : α → ℤ) (θ : ι → Finset α → ℝ) (hθ : ∀ i, DegreeLE q (θ i)) + (htpos : ∀ S : Finset α, 0 < a + ∑ i ∈ S, b i) + (htbound : ∀ S : Finset α, a + ∑ i ∈ S, b i ≤ (M : ℤ)) + (hrough : ∀ p : ℕ, p.Prime → (∃ S : Finset α, (p : ℤ) ∣ a + ∑ i ∈ S, b i) → + Fintype.card α < p ∧ ∀ i, ¬ (p : ℤ) ∣ b i) + (Z A₀ C₀ : ℝ) (hZ : 0 < Z) (hMZ : (M : ℝ) ≤ Z) (hA₀ : 0 < A₀) (hC₀ : 0 ≤ C₀) + (p : Finset α → ℕ) (hp : ∀ S, p S = 1 ∨ p S = (a+∑ i ∈ S, b i).natAbs) + (c : ι → ι → Finset α → ℤ) + (hc : ∀ i j S, degree i < degree j → + |(c i j S : ℝ)| ≤ C₀*(p S : ℝ)^(degree j-degree i)) + (ho : ∀ i S, NearInteger ((p S : ℝ)^degree i * (Eval (θ i) S + + ∑ j ∈ univ.filter (fun j => degree i < degree j), (c i j S : ℝ)*Eval (θ j) S)) + (A₀*((p S : ℝ)/Z)^degree i)) + (hsmall : let β : ℝ := max 1 (A₀+(Fintype.card ι : ℝ)*C₀) + (1+(M : ℝ)^D*(2^(Fintype.card α) : ℝ)^2)*(β^D*((M : ℝ)/Z))* + (M : ℝ)^(D*2^(Fintype.card α)) < 1) : + let β : ℝ := max 1 (A₀+(Fintype.card ι : ℝ)*C₀) + ∃ f : ι → Finset α → ℚ, ∀ i, DegreeLE q (f i) ∧ IntegralCoeffs (f i) ∧ + ∀ S, |Eval (θ i) S - ((Eval (f i) S : ℚ) : ℝ)| *Z^(degree i) ≤ β^D := by + classical + let J : ℝ := (Fintype.card ι : ℝ)*C₀ + let β : ℝ := max 1 (A₀+J) + change (1+(M : ℝ)^D*(2^(Fintype.card α) : ℝ)^2)*(β^D*((M : ℝ)/Z))* + (M : ℝ)^(D*2^(Fintype.card α)) < 1 at hsmall + change ∃ f : ι → Finset α → ℚ, ∀ i, DegreeLE q (f i) ∧ IntegralCoeffs (f i) ∧ + ∀ S, |Eval (θ i) S - ((Eval (f i) S : ℚ) : ℝ)| *Z^(degree i) ≤ β^D + let t : Finset α → ℤ := fun S => a+∑ i ∈ S, b i + have ht (S : Finset α) : 0 < t S := htpos S + have htn (S : Finset α) : ((t S).natAbs : ℝ) = (t S : ℝ) := by + rw [Nat.cast_natAbs, Int.cast_abs, abs_of_pos (by exact_mod_cast ht S)] + have hM : (1 : ℝ) ≤ M := by + have hh : (1 : ℤ) ≤ (M : ℤ) := (ht ∅).trans_le (htbound ∅) + exact_mod_cast hh + have hb : 1 ≤ β := le_max_left _ _ + have hbpos : 0 < β := zero_lt_one.trans_le hb + have hJ : 0 ≤ J := mul_nonneg (Nat.cast_nonneg _) hC₀ + have hratio : 0 ≤ (M : ℝ)/Z ∧ (M : ℝ)/Z ≤ 1 := + ⟨div_nonneg (Nat.cast_nonneg _) hZ.le, (div_le_one hZ).mpr hMZ⟩ + have hbound (k : ℕ) : A₀+J*β^k ≤ β^(k+1) := by + have hb1 : 1 ≤ β^k := one_le_pow₀ hb + calc + _ ≤ (A₀+J)*β^k := by nlinarith + _ ≤ β*β^k := mul_le_mul_of_nonneg_right (le_max_right _ _) (by positivity) + _ = _ := by rw [pow_succ]; ring + have hsmall_e (e : ℕ) (he : e ≤ D) : + (1+(M : ℝ)^e*(2^(Fintype.card α) : ℝ)^2)*(β^D*((M : ℝ)/Z))* + (M : ℝ)^(e*2^(Fintype.card α)) < 1 := by + apply lt_of_le_of_lt _ hsmall + gcongr + have hpZ (S : Finset α) : (p S : ℝ) ≤ Z := by + rcases hp S with hpS | hpS + · rw [hpS, Nat.cast_one] + exact hM.trans hMZ + · rw [hpS, htn] + exact (show (t S : ℝ) ≤ (M : ℝ) by exact_mod_cast htbound S).trans hMZ + have hstage (k : ℕ) (hk : k ≤ D) : + ∃ f : ι → Finset α → ℚ, ∀ i, D-k < degree i → + DegreeLE q (f i) ∧ IntegralCoeffs (f i) ∧ + ∀ S, |Eval (θ i) S - ((Eval (f i) S : ℚ) : ℝ)| *Z^(degree i) ≤ β^k := by + induction k with + | zero => + exact ⟨fun _ _ => 0, fun i hi => by have := (hdeg i).2; omega⟩ + | succ k ih => + have hkD : k < D := by omega + obtain ⟨f, hf⟩ := ih (by omega) + have hlocal (i : ι) : ∃ fi : Finset α → ℚ, D-(k+1) < degree i → + DegreeLE q fi ∧ IntegralCoeffs fi ∧ + ∀ S, |Eval (θ i) S - ((Eval fi S : ℚ) : ℝ)| *Z^(degree i) ≤ β^(k+1) := by + by_cases hhi : D-k < degree i + · refine ⟨f i, fun _ => ⟨(hf i hhi).1, (hf i hhi).2.1, fun S => ?_⟩⟩ + exact ((hf i hhi).2.2 S).trans (pow_le_pow_right₀ hb (by omega)) + by_cases hnew : D-(k+1) < degree i + · have hei : degree i = D-k := by omega + let T : Finset ι := univ.filter (fun j => degree i < degree j) + have hT (j : ι) (hj : j ∈ T) : D-k < degree j := by + have := (mem_filter.mp hj).2 + omega + have hnear (S : Finset α) : NearInteger ((t S : ℝ)^degree i*Eval (θ i) S) + ((A₀+J*β^k)*((t S : ℝ)/Z)^degree i) := by + have him (j : ι) : ∃ v : ℤ, j ∈ T → Eval (f j) S = (v : ℚ) := by + by_cases hj : j ∈ T + · obtain ⟨v, hv⟩ := eval_integral_of_coeffs (f j) (hf j (hT j hj)).2.1 S + exact ⟨v, fun _ => hv⟩ + · exact ⟨0, fun h => (hj h).elim⟩ + choose z hz using him + have herr (j : ι) (hj : j ∈ T) : + |Eval (θ j) S-(z j : ℝ)| *Z^degree j ≤ β^k := by + have hz' : ((Eval (f j) S : ℚ) : ℝ) = (z j : ℝ) := by exact_mod_cast hz j hj + rw [← hz'] + exact (hf j (hT j hj)).2.2 S + have hp' := CoefficientPeeling.peel T degree (degree i) + (fun j hj => (mem_filter.mp hj).2.le) (p S) hZ (hpZ S) + (by positivity : 0 ≤ β^k) (Eval (θ i) S) (fun j => Eval (θ j) S) z + (fun j => c i j S) (fun _ => C₀) (fun _ _ => hC₀) + (fun j hj => hc i j S (mem_filter.mp hj).2) herr (ho i S) + have hTJ : (∑ j ∈ T, C₀) ≤ J := by + simp only [sum_const, nsmul_eq_mul] + exact mul_le_mul_of_nonneg_right (Nat.cast_le.mpr T.card_le_univ) hC₀ + have hp'' := hp'.mono (show + (A₀+(∑ j ∈ T, C₀)*β^k)*((p S : ℝ)/Z)^degree i ≤ + (A₀+J*β^k)*((p S : ℝ)/Z)^degree i by gcongr) + have hh := unit_or_rough hZ.ne' (hp S) hp'' + change NearInteger ((t S).natAbs ^ degree i * Eval (θ i) S) + ((A₀+J*β^k)*((t S).natAbs / Z)^degree i) at hh + simpa only [htn] using hh + have hδ (S : Finset α) : (A₀+J*β^k)*((t S : ℝ)/Z)^degree i ≤ β^D*((M : ℝ)/Z) := by + have hpow : ((t S : ℝ)/Z)^degree i ≤ (M : ℝ)/Z := by + calc + _ ≤ ((M : ℝ)/Z)^degree i := by + apply pow_le_pow_left₀ (div_nonneg (by exact_mod_cast (ht S).le) hZ.le) + exact div_le_div_of_nonneg_right (by exact_mod_cast htbound S) hZ.le + _ ≤ ((M : ℝ)/Z)^1 := pow_le_pow_of_le_one hratio.1 hratio.2 (hdeg i).1 + _ = _ := pow_one _ + have hAb : A₀+J*β^k ≤ β^D := + (hbound k).trans (pow_le_pow_right₀ hb (by omega)) + exact mul_le_mul hAb hpow (pow_nonneg (div_nonneg (by exact_mod_cast (ht S).le) hZ.le) _) (by positivity) + obtain ⟨fi, hfi, hfint, hferr⟩ := rough_rounding_local q (degree i) M + (by have := (hdeg i).2; omega) a b (θ i) (hθ i) htpos htbound hrough + (β^D*((M : ℝ)/Z)) (by positivity) (hsmall_e _ (hdeg i).2) + (fun S => (A₀+J*β^k)*((t S : ℝ)/Z)^degree i) hδ hnear + refine ⟨fi, fun _ => ⟨hfi, hfint, fun S => ?_⟩⟩ + have htne : (t S : ℝ) ≠ 0 := by exact_mod_cast (ht S).ne' + have he : ((A₀+J*β^k)*((t S : ℝ)/Z)^degree i) / (t S : ℝ)^degree i * Z^degree i = + A₀+J*β^k := by rw [div_pow]; field_simp + have hh := mul_le_mul_of_nonneg_right (hferr S) (pow_nonneg hZ.le (degree i)) + change |Eval (θ i) S - ((Eval fi S : ℚ) : ℝ)| *Z^degree i ≤ + ((A₀+J*β^k)*((t S : ℝ)/Z)^degree i) / (t S : ℝ)^degree i * Z^degree i at hh + exact (hh.trans_eq he).trans (hbound k) + · exact ⟨fun _ => 0, fun h => (hnew h).elim⟩ + choose f' hf' using hlocal + exact ⟨f', hf'⟩ + obtain ⟨f, hf⟩ := hstage D le_rfl + exact ⟨f, fun i => hf i (by have := (hdeg i).1; omega)⟩ + +end BooleanPeeling + +end + +end + + +section + + + +noncomputable section +namespace BooleanRough +open Finset +open scoped BigOperators +variable {α K : Type*} [DecidableEq α] + +def BoolCoeffs [CommRing K] (p : MvPolynomial α K) (S : Finset α) : K := + ∑ m ∈ p.support, if m.support = S then p.coeff m else 0 + +omit [DecidableEq α] in +lemma support_card_le_sum [DecidableEq α] (m : α →₀ ℕ) : + m.support.card ≤ m.sum (fun _ n => n) := by + calc + _ = ∑ _i ∈ m.support, 1 := by simp + _ ≤ ∑ i ∈ m.support, m i := sum_le_sum (fun i hi => + Nat.one_le_iff_ne_zero.mpr (Finsupp.mem_support_iff.mp hi)) + _ = _ := rfl + +lemma degree_boolCoeffs [CommRing K] (p : MvPolynomial α K) : + DegreeLE p.totalDegree (BoolCoeffs p) := by + intro S hS + apply sum_eq_zero + intro m hm + have hmS : m.support ≠ S := by + intro he + have hd := (support_card_le_sum m).trans (MvPolynomial.le_totalDegree hm) + rw [he] at hd + omega + simp [hmS] + +lemma monomial_boolean_eval [CommRing K] (m : α →₀ ℕ) (c : K) (S : Finset α) : + MvPolynomial.eval (fun i => if i ∈ S then 1 else 0) (MvPolynomial.monomial m c) = + if m.support ⊆ S then c else 0 := by + rw [MvPolynomial.eval_monomial] + by_cases h : m.support ⊆ S + · rw [ite_eq_left h] + have hp : m.prod (fun i n => (if i ∈ S then (1 : K) else 0)^n) = 1 := by + apply prod_eq_one + intro i hi + simp [h hi] + rw [hp] + simp + · rw [ite_eq_right h] + obtain ⟨i, hi, hiS⟩ := not_subset.mp h + have hp : m.prod (fun i n => (if i ∈ S then (1 : K) else 0)^n) = 0 := by + apply prod_eq_zero hi + simp [hiS, Finsupp.mem_support_iff.mp hi] + rw [hp] + simp + +lemma eval_boolCoeffs [CommRing K] (p : MvPolynomial α K) (S : Finset α) : + Eval (BoolCoeffs p) S = MvPolynomial.eval (fun i => if i ∈ S then 1 else 0) p := by + unfold Eval BoolCoeffs + rw [sum_comm] + conv_rhs => rw [p.as_sum] + simp only [map_sum, monomial_boolean_eval] + apply sum_congr rfl + intro m hm + simp [mem_powerset] + +theorem exists_boolean_coefficients [CommRing K] (p : MvPolynomial α K) : + ∃ f : Finset α → K, DegreeLE p.totalDegree f ∧ + ∀ S, Eval f S = MvPolynomial.eval (fun i => if i ∈ S then 1 else 0) p := + ⟨BoolCoeffs p, degree_boolCoeffs p, eval_boolCoeffs p⟩ + + +def AsPoly [Fintype α] [CommRing K] (f : Finset α → K) : MvPolynomial α K := + ∑ S : Finset α, MvPolynomial.C (f S) * ∏ i ∈ S, MvPolynomial.X i + +omit [DecidableEq α] in +lemma asPoly_degree [DecidableEq α] [Fintype α] [CommRing K] [Nontrivial K] + (d : ℕ) (f : Finset α → K) + (hf : DegreeLE d f) : (AsPoly f).totalDegree ≤ d := by + apply MvPolynomial.totalDegree_finsetSum_le + intro S _ + by_cases hS : S.card ≤ d + · calc + _ ≤ (MvPolynomial.C (f S) : MvPolynomial α K).totalDegree + + (∏ i ∈ S, MvPolynomial.X i : MvPolynomial α K).totalDegree := + MvPolynomial.totalDegree_mul _ _ + _ = (∏ i ∈ S, MvPolynomial.X i : MvPolynomial α K).totalDegree := by simp + _ ≤ ∑ i ∈ S, (MvPolynomial.X i : MvPolynomial α K).totalDegree := + MvPolynomial.totalDegree_finsetProd _ _ + _ ≤ S.card := by + calc + _ ≤ ∑ _i ∈ S, 1 := sum_le_sum (fun i _ => by simp [MvPolynomial.totalDegree_X]) + _ = _ := by simp + _ ≤ d := hS + · simp [hf S (by omega)] + +lemma prod_boolean [CommRing K] (S T : Finset α) : + (∏ i ∈ T, if i ∈ S then (1 : K) else 0) = if T ⊆ S then 1 else 0 := by + by_cases h : T ⊆ S + · simp only [ite_eq_left h] + exact prod_eq_one (fun i hi => ite_eq_left (h hi)) + · rw [ite_eq_right h] + obtain ⟨i, hi, hiS⟩ := not_subset.mp h + exact prod_eq_zero hi (ite_eq_right hiS) + +lemma eval_asPoly [Fintype α] [CommRing K] (f : Finset α → K) (S : Finset α) : + MvPolynomial.eval (fun i => if i ∈ S then 1 else 0) (AsPoly f) = Eval f S := by + simp only [AsPoly, map_sum, map_mul, MvPolynomial.eval_C, map_prod, MvPolynomial.eval_X, + prod_boolean] + rw [show (∑ T : Finset α, f T * (if T ⊆ S then 1 else 0)) = + ∑ T : Finset α, if T ∈ S.powerset then f T else 0 by + apply sum_congr rfl + intro T _ + simp only [mem_powerset] + split_ifs <;> simp] + change (∑ T : Finset α, if T ∈ S.powerset then f T else 0) = ∑ T ∈ S.powerset, f T + rw [← sum_filter] + congr 1 + ext T + simp + +end BooleanRough + +end +end + +end OAI diff --git a/lean/OAI/Combinatorics/SumProduct/Alignment/BoxPolynomial01.lean b/lean/OAI/Combinatorics/SumProduct/Alignment/BoxPolynomial01.lean new file mode 100644 index 0000000000000000000000000000000000000000..9a8136ee2f35d2b5e89d5b49f566a391e7b74d37 --- /dev/null +++ b/lean/OAI/Combinatorics/SumProduct/Alignment/BoxPolynomial01.lean @@ -0,0 +1,461 @@ +import Mathlib +import OAI.Combinatorics.SumProduct.Alignment.TriangularLattice01 +import OAI.Geometry.NilpotentCharts.Main + +namespace OAI + +section +section +section +section +namespace BoxPolynomialLines +open scoped BigOperators +open PolynomialWeyl +noncomputable section + +def boxMean : (n N : ℕ) → ((Fin n → ℕ) → ℂ) → ℂ + | 0, _, f => f Fin.elim0 + | n + 1, N, f => mean N (fun x => boxMean n N (fun y => f (Fin.cons x y))) + +@[simp] theorem boxMean_zero (N : ℕ) (f : (Fin 0 → ℕ) → ℂ) : + boxMean 0 N f = f Fin.elim0 := rfl +@[simp] theorem boxMean_succ (n N : ℕ) (f : (Fin (n + 1) → ℕ) → ℂ) : + boxMean (n + 1) N f = mean N (fun x => boxMean n N (fun y => f (Fin.cons x y))) := rfl + +theorem boxMean_sub (n N : ℕ) (f g : (Fin n → ℕ) → ℂ) : + boxMean n N (fun x => f x - g x) = boxMean n N f - boxMean n N g := by + induction n with + | zero => rfl + | succ n ih => simp only [boxMean_succ, ih, mean, Finset.expect_sub_distrib] + +theorem boxMean_const (n : ℕ) {N : ℕ} (hN : 0 < N) (z : ℂ) : + boxMean n N (fun _ => z) = z := by + induction n with + | zero => rfl + | succ n ih => simp [boxMean_succ, ih, mean, Finset.nonempty_range_iff.mpr (Nat.ne_of_gt hN)] + +theorem boxMean_comm (n N H : ℕ) (f : (Fin n → ℕ) → ℕ → ℂ) : + boxMean n N (fun x => mean H (f x)) = mean H (fun t => boxMean n N (fun x => f x t)) := by + induction n with + | zero => rfl + | succ n ih => + simp only [boxMean_succ] + simp_rw [ih] + simp only [mean] + rw [Finset.expect_comm] + +theorem boxMean_norm_le (n : ℕ) {N : ℕ} (hN : 0 < N) (f : (Fin n → ℕ) → ℂ) + (C : ℝ) (hf : ∀ x, (∀ i, x i < N) → ‖f x‖ ≤ C) : ‖boxMean n N f‖ ≤ C := by + induction n with + | zero => exact hf _ (fun i => Fin.elim0 i) + | succ n ih => + apply (RCLike.norm_expect_le (K := ℂ)).trans + apply Finset.expect_le (Finset.nonempty_range_iff.mpr (Nat.ne_of_gt hN)) + intro x hx + apply ih + intro y hy + apply hf + intro i + refine Fin.cases ?_ (fun j => ?_) i + · exact Finset.mem_range.mp hx + · exact hy j + +theorem exists_norm_ge (n : ℕ) {N : ℕ} (hN : 0 < N) (f : (Fin n → ℕ) → ℂ) + {δ : ℝ} (hδ : δ ≤ ‖boxMean n N f‖) : + ∃ x : Fin n → ℕ, (∀ i, x i < N) ∧ δ ≤ ‖f x‖ := by + induction n with + | zero => exact ⟨_, (fun i => Fin.elim0 i), hδ⟩ + | succ n ih => + have hle := hδ.trans (RCLike.norm_expect_le (K := ℂ)) + obtain ⟨x, hx, hh⟩ := Finset.exists_le_of_le_expect + (Finset.nonempty_range_iff.mpr (Nat.ne_of_gt hN)) hle + obtain ⟨y, hy, hyδ⟩ := ih (fun y => f (Fin.cons x y)) hh + refine ⟨Fin.cons x y, ?_, hyδ⟩ + intro i + exact Fin.cases (Finset.mem_range.mp hx) hy i + +theorem cons_add (n : ℕ) (x : ℕ) (y : Fin n → ℕ) (h : Fin (n + 1) → ℕ) : + Fin.cons x y + h = Fin.cons (x + h 0) (fun i => y i + h i.succ) := by + ext i + exact Fin.cases rfl (fun _ => rfl) i + +attribute [irreducible] boxMean + +theorem norm_mean_sub_le {N : ℕ} (hN : 0 < N) (f g : ℕ → ℂ) (C : ℝ) + (hf : ∀ x < N, ‖f x - g x‖ ≤ C) : ‖mean N f - mean N g‖ ≤ C := by + rw [mean, mean, ← Finset.expect_sub_distrib] + exact (RCLike.norm_expect_le (K := ℂ)).trans + (Finset.expect_le (Finset.nonempty_range_iff.mpr (Nat.ne_of_gt hN)) + (fun x hx => hf x (Finset.mem_range.mp hx))) + +theorem tail_shift_bound (n N x : ℕ) + (f : (Fin (n + 1) → ℕ) → ℂ) (h : Fin (n + 1) → ℕ) (C : ℝ) + (ih : ‖boxMean n N (fun y => f (Fin.cons (x + h 0) (y + fun i => h i.succ))) - + boxMean n N (fun y => f (Fin.cons (x + h 0) y))‖ ≤ C) : + ‖boxMean n N (fun y => f (Fin.cons x y + h)) - + boxMean n N (fun y => f (Fin.cons (x + h 0) y))‖ ≤ C := by + have heq : (fun y : Fin n → ℕ => f (Fin.cons x y + h)) = + (fun y : Fin n → ℕ => f (Fin.cons (x + h 0) (y + fun i => h i.succ))) := by + funext y + exact congrArg f (cons_add n x y h) + rw [heq] + exact ih + +theorem shift_step (n : ℕ) {N : ℕ} (hN : 0 < N) + (ih : ∀ (f : (Fin n → ℕ) → ℂ), (∀ x, ‖f x‖ ≤ 1) → ∀ (h : Fin n → ℕ), + ‖boxMean n N (fun x => f (x + h)) - boxMean n N f‖ ≤ + 2 * (∑ i, h i : ℕ) / N) + (f : (Fin (n + 1) → ℕ) → ℂ) (hf : ∀ x, ‖f x‖ ≤ 1) (h : Fin (n + 1) → ℕ) : + ‖boxMean (n + 1) N (fun x => f (x + h)) - boxMean (n + 1) N f‖ ≤ + 2 * (∑ i, h i : ℕ) / N := by + let F (x : ℕ) := boxMean n N (fun y => f (Fin.cons x y)) + let A (x : ℕ) := boxMean n N (fun y => f (Fin.cons x y + h)) + let B (x : ℕ) := F (x + h 0) + have hF (x : ℕ) : ‖F x‖ ≤ 1 := boxMean_norm_le n hN _ _ (fun y _ => hf _) + have htail (x : ℕ) : ‖A x - B x‖ ≤ 2 * (∑ i : Fin n, h i.succ : ℕ) / N := + tail_shift_bound n N x f h _ + (ih (fun y => f (Fin.cons (x + h 0) y)) (fun y => hf _) (fun i => h i.succ)) + have he := norm_mean_sub_le hN A B _ (fun x _ => htail x) + have hhead : ‖mean N B - mean N F‖ ≤ 2 * (h 0 : ℝ) / N := + norm_mean_shift_sub_le hN (h 0) F hF + have htriangle : ‖mean N A - mean N F‖ ≤ + 2 * (∑ i : Fin n, h i.succ : ℕ) / N + 2 * (h 0 : ℝ) / N := + (norm_sub_le_norm_sub_add_norm_sub (mean N A) (mean N B) (mean N F)).trans + (add_le_add he hhead) + have hs : (∑ i : Fin (n + 1), h i : ℕ) = h 0 + ∑ i : Fin n, h i.succ := Fin.sum_univ_succ _ + have hc : 2 * (∑ i : Fin n, h i.succ : ℕ) / (N : ℝ) + 2 * (h 0 : ℝ) / N = + 2 * (∑ i : Fin (n + 1), h i : ℕ) / N := by rw [hs, Nat.cast_add]; ring + rw [hc] at htriangle + rw [boxMean_succ, boxMean_succ] + exact htriangle + +theorem norm_shift_error (n : ℕ) {N : ℕ} (hN : 0 < N) + (f : (Fin n → ℕ) → ℂ) (hf : ∀ x, ‖f x‖ ≤ 1) (h : Fin n → ℕ) : + ‖boxMean n N (fun x => f (x + h)) - boxMean n N f‖ ≤ + 2 * (∑ i, h i : ℕ) / N := by + induction n with + | zero => + have he : (Fin.elim0 : Fin 0 → ℕ) + h = Fin.elim0 := by ext i; exact Fin.elim0 i + rw [boxMean_zero, boxMean_zero, he, sub_self, norm_zero] + simp + | succ n ih => exact shift_step n hN ih f hf h + +theorem mean_const {N : ℕ} (hN : 0 < N) (z : ℂ) : mean N (fun _ => z) = z := by + simp [mean, Finset.nonempty_range_iff.mpr (Nat.ne_of_gt hN)] + +theorem line_average_error (n : ℕ) {N H : ℕ} (hN : 0 < N) (hH : 0 < H) + (f : (Fin n → ℕ) → ℂ) (hf : ∀ x, ‖f x‖ ≤ 1) (v : Fin n → ℕ) : + ‖boxMean n N (fun x => mean H (fun t => f (x + fun i => t * v i))) - boxMean n N f‖ ≤ + 2 * (H : ℝ) * (∑ i, v i : ℕ) / N := by + rw [boxMean_comm, ← mean_const hH (boxMean n N f)] + apply norm_mean_sub_le hH + intro t ht + have hs : (∑ i, t * v i : ℕ) = t * ∑ i, v i := (Finset.mul_sum ..).symm + have hb := norm_shift_error n hN f hf (fun i => t * v i) + rw [hs, Nat.cast_mul] at hb + rw [← mul_assoc] at hb + exact hb.trans (by gcongr) + +theorem exists_correlated_line (n : ℕ) {N H : ℕ} (hN : 0 < N) (hH : 0 < H) + (f : (Fin n → ℕ) → ℂ) (hf : ∀ x, ‖f x‖ ≤ 1) (v : Fin n → ℕ) + {δ : ℝ} (hδ : δ ≤ ‖boxMean n N f‖) + (hshort : 2 * (H : ℝ) * (∑ i, v i : ℕ) / N ≤ δ / 2) : + ∃ x : Fin n → ℕ, (∀ i, x i < N) ∧ + δ / 2 ≤ ‖mean H (fun t => f (x + fun i => t * v i))‖ := by + apply exists_norm_ge n hN + have herr := (line_average_error n hN hH f hf v).trans hshort + let A := boxMean n N f + let B := boxMean n N (fun x => mean H (fun t => f (x + fun i => t * v i))) + have htriangle : ‖A‖ ≤ ‖A - B‖ + ‖B‖ := by + simpa only [sub_add_cancel] using norm_add_le (A - B) B + rw [norm_sub_rev] at herr + change ‖A - B‖ ≤ δ / 2 at herr + change δ ≤ ‖A‖ at hδ + change δ / 2 ≤ ‖B‖ + linarith + +end +end BoxPolynomialLines + +namespace BoxCounting +open scoped BigOperators +open PolynomialWeyl BoxPolynomialLines Finset +noncomputable section + +theorem mean_eq_fin (N : ℕ) (f : ℕ → ℂ) : + mean N f = 𝔼 x : Fin N, f x := by + classical + symm + apply Finset.expect_bij (fun x _ => x.val) + · intro x _; exact mem_range.mpr x.isLt + · intro x _; rfl + · intro a _ b _ h; exact Fin.ext h + · intro b hb; exact ⟨⟨b,mem_range.mp hb⟩,mem_univ _,rfl⟩ + +theorem boxMean_eq_fin (n N : ℕ) (f : (Fin n → ℕ) → ℂ) : + boxMean n N f = 𝔼 x : Fin n → Fin N, f (fun i => (x i).val) := by + classical + induction n with + | zero => + have he : (fun x : Fin 0 → Fin N => f (fun i => (x i).val)) = fun _ => f Fin.elim0 := by + funext x + congr 1 + funext i + exact Fin.elim0 i + rw [he] + simp + | succ n ih => + rw [BoxPolynomialLines.boxMean_succ] + simp_rw [ih] + rw [mean_eq_fin,← Finset.expect_product'] + apply Finset.expect_equiv (Fin.consEquiv (fun _ : Fin (n+1) => Fin N)) + · intro x; simp + · intro x _ + congr 1 + funext i + refine Fin.cases ?_ (fun j => ?_) i <;> rfl + +def indicator {α : Type*} (S : Set α) (x : α) : ℂ := by + classical + exact if x ∈ S then 1 else 0 + +def count (n N : ℕ) (S : Set (Fin n → ℕ)) : ℕ := by + classical + exact (univ.filter (fun x : Fin n → Fin N => (fun i => (x i).val) ∈ S)).card + + + +theorem boxMean_indicator (n N : ℕ) (S : Set (Fin n → ℕ)) : + ‖boxMean n N (indicator S)‖ = (count n N S:ℝ)/(N:ℝ)^n := by + classical + rw [boxMean_eq_fin,Finset.expect_eq_sum_div_card] + simp only [indicator,Finset.sum_boole,Finset.card_univ,Fintype.card_fun, + Fintype.card_fin] + rw [norm_div] + norm_cast + +end +end BoxCounting + +namespace DenseBoxModularPolynomial +open scoped BigOperators +open PolynomialWeyl BoxPolynomialLines PolynomialLineCoefficients TriangularLatticeRecovery +open MultivariateCoefficientRecovery Finset +noncomputable section + +def eval {n d : ℕ} (a : Grid n d → ℝ) (x : Fin n → ℕ) : ℝ := + ∑ e, a e * ∏ i, (x i : ℝ) ^ (e i).val + +theorem circleNorm_le_integer_error (a : ℝ) (m : ℤ) : circleNorm a ≤ |a - m| := by + rw [circleNorm, UnitAddCircle.norm_eq] + exact round_le a m + +theorem circleNorm_le_one (a : ℝ) : circleNorm a ≤ 1 := by + rw [circleNorm, UnitAddCircle.norm_eq] + exact (abs_sub_round a).trans (by norm_num) + +theorem division_length {N K : ℕ} (hK : 0 < K) (hKN : K ≤ N) : + 0 < N / K ∧ N / K * K ≤ N ∧ N ≤ 2 * K * (N / K) := by + have hH : 0 < N / K := Nat.div_pos hKN hK + have hmod := Nat.mod_lt N hK + have heq := Nat.mod_add_div N K + have hKH : K ≤ K * (N / K) := by nlinarith + exact ⟨hH, Nat.div_mul_le_self N K, by nlinarith only [heq, hmod, hKH]⟩ + +theorem common_denominator {V : Type*} [Fintype V] (B : ℕ) + (q : V → ℕ) (hq : ∀ v, 0 < q v) (hqB : ∀ v, q v ≤ B) + (b : V → ℕ → ℝ) (N D : ℕ) (A : ℝ) (hA : 0 ≤ A) + (hb : ∀ v j, 0 < j → j ≤ D → circleNorm ((q v : ℝ) * b v j) * (N : ℝ) ^ j ≤ A) : + ∃ Q : ℕ, 0 < Q ∧ Q ≤ B ^ Fintype.card V ∧ + ∀ v j, 0 < j → j ≤ D → + circleNorm ((Q : ℝ) * b v j) * (N : ℝ) ^ j ≤ (B ^ Fintype.card V : ℕ) * A := by + classical + let Q := ∏ v, q v + have hQ : 0 < Q := Finset.prod_pos (fun v _ => hq v) + have hQB : Q ≤ B ^ Fintype.card V := by + calc + _ ≤ ∏ _v : V, B := Finset.prod_le_prod₀ (fun _ _ => Nat.zero_le _) (fun v _ => hqB v) + _ = _ := by simp + refine ⟨Q, hQ, hQB, ?_⟩ + intro v j hj hjD + have hd : q v ∣ Q := Finset.dvd_prod_of_mem q (Finset.mem_univ v) + have hm : Q / q v ≤ B ^ Fintype.card V := (Nat.div_le_self ..).trans hQB + have he : ((Q / q v : ℕ) : ℝ) * ((q v : ℝ) * b v j) = (Q : ℝ) * b v j := by + rw [← mul_assoc, ← Nat.cast_mul, Nat.div_mul_cancel hd] + have hh := scaled_nat_bound (Q / q v) ((q v : ℝ) * b v j) N A + ((B ^ Fintype.card V : ℕ) : ℝ) j (Nat.cast_nonneg _) hA (Nat.cast_le.mpr hm) (hb v j hj hjD) + simpa only [he] using hh + +theorem line_scale_coeff {n d : ℕ} (a : Grid n d → ℝ) (x v : Fin n → ℕ) (q : ℝ) (j : ℕ) : + (line (fun e => q * a e) x v).coeff j = q * (line a x v).coeff j := by + simp only [line_coeff, Finset.mul_sum, mul_assoc] + +def indicator {α : Type*} (S : Set α) (x : α) : ℂ := by + classical + exact if x ∈ S then 1 else 0 + +lemma norm_indicator {α : Type*} (S : Set α) (x : α) : + ‖indicator S x‖ ≤ 1 := by + classical + by_cases h : x ∈ S <;> simp [indicator,h] + +lemma mean_indicator {α : Type*} (S : Set α) [DecidablePred (· ∈ S)] (x : ℕ → α) (H : ℕ) : + ‖mean H (fun t => indicator S (x t))‖ = + ((range H).filter (fun t => x t ∈ S)).card / (H:ℝ) := by + classical + rw [mean,Finset.expect_eq_sum_div_card] + simp only [indicator,Finset.card_range] + rw [norm_div] + norm_cast + simp + +lemma abs_multiplier (q : ℤ) (a : ℝ) : + circleNorm ((q.natAbs:ℝ)*a) = circleNorm ((q:ℝ)*a) := by + rw [Nat.cast_natAbs,Int.cast_abs] + rcases le_total 0 (q:ℝ) with h|h + · rw [abs_of_nonneg h] + · rw [abs_of_nonpos h,neg_mul,circleNorm,AddCircle.coe_neg,norm_neg] + rfl + + + +theorem line_test_constants (n d : ℕ) (δ : ℝ) (hδ : 0 < δ) : + ∃ B N₀ : ℕ, 0 < B ∧ 0 < N₀ ∧ ∃ ε₀ A : ℝ, 0 < ε₀ ∧ 0 < A ∧ + ∀ N : ℕ, N₀ ≤ N → ∀ ε : ℝ, 0 ≤ ε → ε ≤ ε₀ → + ∀ S : Set (Fin n → ℕ), ∀ a : Grid n d → ℝ, + (∀ x ∈ S, ∃ z : ℤ, |eval a x-z| ≤ ε) → + δ ≤ ‖boxMean n N (indicator S)‖ → ∀ v : Grid n d, + ∃ x : Fin n → ℕ, (∀ i, x i ≤ N) ∧ ∃ q : ℕ, 0 < q ∧ q ≤ B ∧ + ∀ j : ℕ, 0 < j → j ≤ n*d → + circleNorm ((q:ℝ)*(line a x (fun i => (v i).val)).coeff j) * + (N:ℝ)^j ≤ A*ε := by + classical + obtain ⟨B,hB,ε₀,hε₀,L,hL,hinv⟩ := + DenseModularPolynomial.lattice_inverse (n*d) (δ/2) (by positivity) + obtain ⟨K,hK⟩ := exists_nat_gt (max (1:ℝ) (4*(n*d:ℕ)/δ)) + have hK₁ : (1:ℝ) ≤ K := (le_max_left _ _).trans hK.le + have hK₀ : 0 < K := by exact_mod_cast (lt_of_lt_of_le zero_lt_one hK₁) + have hshortK : 4*(n*d:ℕ) ≤ δ*K := by + have := (div_le_iff₀ hδ).mp ((le_max_right _ _).trans hK.le) + nlinarith only [this] + let A : ℝ := (B:ℝ)*(2*K:ℕ)^(n*d) + have hA : 0 < A := by dsimp [A]; positivity + refine ⟨B,K*L,hB,Nat.mul_pos hK₀ hL,ε₀,A,hε₀,hA,?_⟩ + intro N hN₀N ε hε hεsmall S a hgood hlarge v + have hKN : K ≤ N := (by nlinarith : K ≤ K*L).trans hN₀N + have hN : 0 < N := hK₀.trans_le hKN + let H := N/K + obtain ⟨hH,hHK,hNH⟩ := division_length hK₀ hKN + have hLH : L ≤ H := (Nat.le_div_iff_mul_le hK₀).mpr (by simpa [Nat.mul_comm] using hN₀N) + have hsum : (∑ i, (v i).val : ℕ) ≤ n*d := totalDegree_le v + have hshort : 2*(H:ℝ)*(∑ i, (v i).val : ℕ)/N ≤ δ/2 := by + apply (div_le_iff₀ (Nat.cast_pos.mpr hN)).mpr + have hHK' : (H:ℝ)*K ≤ N := by exact_mod_cast hHK + have hsum' : ((∑ i, (v i).val : ℕ):ℝ) ≤ (n*d:ℕ) := by exact_mod_cast hsum + have h₁ := mul_le_mul_of_nonneg_left hshortK (Nat.cast_nonneg H : (0:ℝ) ≤ H) + have h₂ := mul_le_mul_of_nonneg_left hHK' hδ.le + have h₃ := mul_le_mul_of_nonneg_left hsum' (Nat.cast_nonneg H : (0:ℝ) ≤ H) + nlinarith only [h₁,h₂,h₃] + obtain ⟨x,hx,hline⟩ := exists_correlated_line n hN hH (indicator S) + (norm_indicator S) (fun i => (v i).val) hlarge hshort + rw [mean_indicator] at hline + let T := (range H).filter (fun t => x + (fun i => t*(v i).val) ∈ S) + have hT : δ/2*(H:ℝ) ≤ (T.card:ℝ) := + (le_div_iff₀ (Nat.cast_pos.mpr hH)).mp hline + have hTgood : ∀ k ∈ T, ∃ z : ℤ, + |(line a x (fun i => (v i).val)).eval (k:ℝ)-z| ≤ ε := by + intro k hk + have hh := hgood _ (mem_filter.mp hk).2 + simpa only [line_eval,eval,Pi.add_apply] using hh + obtain ⟨q,hq,hqB,m,hm⟩ := hinv H hLH ε hε hεsmall T + (filter_subset _ _) hT (line a x (fun i => (v i).val)) (line_degree ..) hTgood + have hqabs : 0 < q.natAbs := Int.natAbs_pos.mpr hq + have hqabsB : q.natAbs ≤ B := by + rw [← Int.natCast_natAbs] at hqB + exact_mod_cast hqB + refine ⟨x,(fun i => (hx i).le),q.natAbs,hqabs,hqabsB,?_⟩ + intro j hj hjd + rw [abs_multiplier] + have hc := (circleNorm_le_integer_error ((q:ℝ)*(line a x (fun i => (v i).val)).coeff j) + (m j)).trans (hm j hj hjd) + have hpow : (N:ℝ)^j ≤ (2*K:ℕ)^(n*d)*(H:ℝ)^j := by + have hNH' : (N:ℝ) ≤ (2*K:ℕ)*(H:ℝ) := by exact_mod_cast hNH + calc + _ ≤ ((2*K:ℕ)*(H:ℝ))^j := pow_le_pow_left₀ (by positivity) hNH' _ + _ = (2*K:ℕ)^j*(H:ℝ)^j := mul_pow _ _ _ + _ ≤ (2*K:ℕ)^(n*d)*(H:ℝ)^j := by + gcongr + exact_mod_cast (by omega : 1 ≤ 2*K) + calc + _ ≤ ((B:ℝ)*ε/(H:ℝ)^j) * ((2*K:ℕ)^(n*d)*(H:ℝ)^j) := + mul_le_mul hc hpow (by positivity) (by positivity) + _ = A*ε := by + dsimp [A] + field_simp [ne_of_gt (Nat.cast_pos.mpr hH : (0:ℝ) < H)] + + + +theorem lattice_inverse (n d : ℕ) (δ : ℝ) (hδ : 0 < δ) : + ∃ C N₀ : ℕ, 0 < C ∧ 0 < N₀ ∧ ∃ ε₀ : ℝ, 0 < ε₀ ∧ + ∀ N : ℕ, N₀ ≤ N → ∀ ε : ℝ, 0 ≤ ε → ε ≤ ε₀ → + ∀ S : Set (Fin n → ℕ), ∀ a : Grid n d → ℝ, + (∀ x ∈ S, ∃ z : ℤ, |eval a x-z| ≤ ε) → + δ ≤ ‖boxMean n N (indicator S)‖ → + ∃ q : ℕ, 0 < q ∧ q ≤ C ∧ ∀ e : Grid n d, 0 < totalDegree e → + circleNorm ((q:ℝ)*a e)*(N:ℝ)^totalDegree e ≤ (C:ℝ)*ε := by + classical + obtain ⟨B,N₀,hB,hN₀,ε₀,A,hε₀,hA,htest⟩ := line_test_constants n d δ hδ + obtain ⟨R,T,hR,hT,hrec⟩ := recovery_constants n d + let B' := B ^ Fintype.card (Grid n d) + have hB' : 0 < B' := pow_pos hB _ + obtain ⟨C,hC⟩ := exists_nat_gt (max ((R*B':ℕ):ℝ) ((T:ℝ)*B'*A)) + have hRC : R*B' ≤ C := by exact_mod_cast (le_max_left _ _).trans hC.le + have hTC : (T:ℝ)*B'*A ≤ C := (le_max_right _ _).trans hC.le + have hCpos : 0 < C := (Nat.mul_pos hR hB').trans_le hRC + refine ⟨C,N₀,hCpos,hN₀,ε₀,hε₀,?_⟩ + intro N hN₀N ε hε hεsmall S a hgood hlarge + have hN : 0 < N := hN₀.trans_le hN₀N + have ht := htest N hN₀N ε hε hεsmall S a hgood hlarge + choose x hx q hq hqB hb using ht + obtain ⟨q',hq',hqB',happrox⟩ := common_denominator B q hq hqB + (fun v j => (line a (x v) (fun i => (v i).val)).coeff j) N (n*d) (A*ε) + (by positivity) hb + have hrec' := hrec N hN x hx (fun e => (q':ℝ)*a e) ((B':ℝ)*(A*ε)) + (by positivity) (by + intro v j hj hjd + rw [line_scale_coeff] + exact happrox v j hj hjd) + refine ⟨R*q',Nat.mul_pos hR hq',(Nat.mul_le_mul_left R hqB').trans hRC,?_⟩ + intro e he + have hh := hrec' e he + simp only [Nat.cast_mul] + rw [mul_assoc] + exact hh.trans (by simpa only [mul_assoc] using mul_le_mul_of_nonneg_right hTC hε) + + + +theorem lattice_inverse_cardinal (n d : ℕ) (δ : ℝ) (hδ : 0 < δ) : + ∃ C N₀ : ℕ, 0 < C ∧ 0 < N₀ ∧ ∃ ε₀ : ℝ, 0 < ε₀ ∧ + ∀ N : ℕ, N₀ ≤ N → ∀ ε : ℝ, 0 ≤ ε → ε ≤ ε₀ → + ∀ S : Set (Fin n → ℕ), ∀ a : Grid n d → ℝ, + (∀ x ∈ S, ∃ z : ℤ, |eval a x-z| ≤ ε) → + δ*(N:ℝ)^n ≤ (BoxCounting.count n N S:ℝ) → + ∃ q : ℕ, 0 < q ∧ q ≤ C ∧ ∀ e : Grid n d, 0 < totalDegree e → + circleNorm ((q:ℝ)*a e)*(N:ℝ)^totalDegree e ≤ (C:ℝ)*ε := by + obtain ⟨C,N₀,hC,hN₀,ε₀,hε₀,h⟩ := lattice_inverse n d δ hδ + refine ⟨C,N₀,hC,hN₀,ε₀,hε₀,?_⟩ + intro N hN ε hε hεsmall S a hgood hcount + apply h N hN ε hε hεsmall S a hgood + change δ ≤ ‖boxMean n N (BoxCounting.indicator S)‖ + rw [BoxCounting.boxMean_indicator] + exact (le_div_iff₀ (pow_pos (Nat.cast_pos.mpr (hN₀.trans_le hN)) _)).mpr hcount + +end +end DenseBoxModularPolynomial + +end +end +end +end + +end OAI diff --git a/lean/OAI/Combinatorics/SumProduct/Alignment/BracketDrift01.lean b/lean/OAI/Combinatorics/SumProduct/Alignment/BracketDrift01.lean new file mode 100644 index 0000000000000000000000000000000000000000..247e3d9652b9e11a501184cc287da882873dd3ed --- /dev/null +++ b/lean/OAI/Combinatorics/SumProduct/Alignment/BracketDrift01.lean @@ -0,0 +1,424 @@ +import Mathlib +import OAI.Combinatorics.SumProduct.Alignment.BracketHyperplanes02 +import OAI.Geometry.NilpotentCharts.Main + +namespace OAI + +section +section +section +section +noncomputable section +open Finset _root_.Polynomial _root_.OAI.Polynomial +open scoped BigOperators +end +end + + + +section +noncomputable section +open Finset Set BracketHyperplanes +open scoped BigOperators +namespace BracketDrift + + + +theorem small_drift_alternative (d : ℕ) (A δ : ℝ) (hA : 0 γ i*n+β i)) → + ∀ S : Finset ℕ, S⊆range N → δ*N≤(S.card:ℝ) → + (∀ n∈S, ‖((b+ρ*n+∑ i,a i*x n i:ℝ):UnitAddCircle)‖≤A/N) → + ‖a‖≤C/N ∨ ∃ k∈F, k≠0 ∧ ∃ m:ℤ, |(∑ i,(k i:ℝ)*γ i)-m|≤C/N := by + classical + obtain ⟨D,hD,N₀,hN₀,hslope⟩ := relative_slope A ((d:ℝ)+1) δ hA (by positivity) hδ + let Jsize := ⌈1+2*A+(d:ℝ)*A⌉₊ + let J : Finset ℤ := Finset.Icc (-(Jsize:ℤ)) Jsize + have hJ : J.Nonempty := ⟨0,by simp [J]⟩ + have hJr : (0:ℝ) p.val.1,continuous_fst.comp continuous_subtype_val⟩ + let cb : C(Q,ℝ) := ⟨fun p => p.val.2,continuous_snd.comp continuous_subtype_val⟩ + have hca (p : Q) : ca p≠0 := by + have hh : ‖ca p‖=1 := by simpa [ca,Metric.mem_sphere,dist_zero_right] using p.property.1 + intro hz; rw [hz,norm_zero] at hh; norm_num at hh + obtain ⟨F,ε₀,C₀,hε₀,hC₀,hF⟩ := compact_bracket_linear_inverse ca hca cb K + (isCompact_closedBall _ _) (δ'/2) (by positivity) + let ε := min ε₀ 1 + have hε : 0<ε := lt_min hε₀ zero_lt_one + have hεsmall : ε≤ε₀ := min_le_left _ _ + have hεone : ε≤1 := min_le_right _ _ + obtain ⟨M,hM⟩ := exists_nat_gt (max 1 (2*D/ε)) + have hMr : (1:ℝ) k n=j) + have hS'S : S'⊆S := filter_subset _ _ + let L := N/M + have hL : 0 γ i*n+(γ i*(s*L:ℕ)+β i)) := by + rw [horbit] + congr 1 + funext i + push_cast + ring + have hsmall' (n : ℕ) (hn : n∈U) : + ‖((∑ i, ca p i*x (s*L+n) i-cb p:ℝ):UnitAddCircle)‖≤ε₀ := by + apply le_trans QuotientAddGroup.norm_mk_le_norm + exact (hnormres n hn).trans hεsmall + obtain ⟨v,hv,hv0,m,hm⟩ := hF L hL p γ (fun i => γ i*(s*L:ℕ)+β i) + (fun n => x (s*L+n)) hx' horbit' U hUL hU hsmall' + refine ⟨v,hv,hv0,m,hm.trans ?_⟩ + calc + C₀/L ≤ (2*(M:ℝ)*C₀)/N := by + apply (div_le_div_iff₀ hLr hNr).mpr + nlinarith only [mul_le_mul_of_nonneg_left hcoverr hC₀.le] + _ ≤ C/N := div_le_div_of_nonneg_right hCF hNr.le + +end BracketDrift +end +end + + + +section +noncomputable section +open Finset Set BracketHyperplanes +open scoped BigOperators +namespace BracketDrift + +lemma circle_sum {ι : Type*} (s : Finset ι) (f : ι → ℝ) : + ((∑ i∈s,f i:ℝ):UnitAddCircle)=∑ i∈s,(f i:UnitAddCircle) := by + classical + induction s using Finset.induction_on with + | empty => simp + | @insert i s hi ih => simp [hi,ih] + +lemma circle_int_mul (r : ℤ) (x : ℝ) : + (((r:ℝ)*x:ℝ):UnitAddCircle)=r • (x:UnitAddCircle) := by + simpa only [zsmul_eq_mul] using (AddCircle.coe_zsmul (1:ℝ) (n:=r) (x:=x)) + +lemma circle_integer (m : ℤ) : ((m:ℝ):UnitAddCircle)=0 := by + apply (AddCircle.coe_eq_zero_iff (1:ℝ)).mpr + exact ⟨m,by simp⟩ + +lemma circle_dot_congr {d : ℕ} (k : Fin d → ℤ) (u v : Fin d → ℝ) + (h : BracketHyperplanes.torusMap u=BracketHyperplanes.torusMap v) : + ((∑ i,(k i:ℝ)*u i:ℝ):UnitAddCircle)=((∑ i,(k i:ℝ)*v i:ℝ):UnitAddCircle) := by + rw [circle_sum,circle_sum] + apply sum_congr rfl + intro i _ + rw [circle_int_mul,circle_int_mul] + exact congrArg (fun z : UnitAddCircle => k i • z) (congrFun h i) + +lemma snoc_norm_le {d : ℕ} (a : Fin d → ℝ) (z A : ℝ) (hA : 0≤A) + (ha : ‖a‖≤A) (hz : |z|≤A) : ‖Fin.snoc (α:=fun _ => ℝ) a z‖≤A := by + apply (pi_norm_le_iff_of_nonneg hA).mpr + intro i + refine Fin.lastCases ?_ (fun j => ?_) i + · simpa using hz + · simpa using (pi_norm_le_iff_of_nonneg hA).mp ha j + +lemma finite_frequency_bound {d : ℕ} (F : Finset (Fin d → ℤ)) : + ∃ B : ℕ, 0 Nat.zero_le ((k j).natAbs)) (mem_univ i) + have h2 : (∑ j,(k j).natAbs)≤∑ k∈F,∑ j,(k j).natAbs := + single_le_sum (fun k _ => Nat.zero_le (∑ j,(k j).natAbs)) hk + have h3 : (k i).natAbs≤B := by dsimp [B]; omega + have := (Int.ofNat_le.mpr h3) + simpa only [Int.natCast_natAbs] using this + + + +theorem arbitrary_drift_alternative (d : ℕ) (A δ : ℝ) (hA : 0 γ i*n+β i)) → + ∀ S : Finset ℕ, S⊆range N → δ*N≤(S.card:ℝ) → + (∀ n∈S, ‖((b+ρ*n+∑ i,a i*x n i:ℝ):UnitAddCircle)‖≤A/N) → + (∃ r : ℤ, r≠0 ∧ |r|≤R ∧ ∀ i, ∃ m : ℤ, |(r:ℝ)*a i-m|≤C/N) ∨ + ∃ k : Fin d → ℤ, k≠0 ∧ (∀ i, |k i|≤R) ∧ + ∃ m : ℤ, |(∑ i,(k i:ℝ)*γ i)-m|≤C/N := by + classical + let A₁ := max A 1 + have hAA₁ : A≤A₁ := le_max_left _ _ + have h1A₁ : 1≤A₁ := le_max_right _ _ + have hA₁ : 0 γ' i*n+β' i) := by + funext i + refine Fin.lastCases ?_ (fun j => ?_) i + · simp [BracketHyperplanes.torusMap,x',γ',β',AddCircle.coe_fract] + · simpa [BracketHyperplanes.torusMap,x',γ',β'] using congrFun (horbit n) j + have heval' (n : ℕ) : + ((b₁+(0:ℝ)*n+∑ i,a' i*x' n i:ℝ):UnitAddCircle)= + ((b+ρ*n+∑ i,a i*x n i:ℝ):UnitAddCircle) := by + rw [Fin.sum_univ_castSucc] + simp only [a',x',Fin.snoc_castSucc,Fin.snoc_last,one_mul,zero_mul,add_zero] + simp only [b₁,AddCircle.coe_add,AddCircle.coe_sub,circle_integer,sub_zero,AddCircle.coe_fract] + abel + have hsmall' (n : ℕ) (hn : n∈S) : + ‖((b₁+(0:ℝ)*n+∑ i,a' i*x' n i:ℝ):UnitAddCircle)‖≤A₁/N := by + rw [heval']; exact (hsmall n hn).trans (div_le_div_of_nonneg_right hAA₁ hNr.le) + rcases hfirst N hN a' γ' β' ha' 0 b₁ (by rw [abs_zero]; positivity) hb₁ x' hx' horbit' S hSN hS hsmall' with htiny | hfreq + · left + refine ⟨1,one_ne_zero,?_,fun i => ⟨0,?_⟩⟩ + · have h1R : 1≤R := hB.trans_le hBR + exact_mod_cast h1R + · have hi := (pi_norm_le_iff_of_nonneg (by positivity : 0≤C₁/(N:ℝ))).mp htiny i.castSucc + simp only [a',Fin.snoc_castSucc,Real.norm_eq_abs] at hi + simpa using hi.trans (div_le_div_of_nonneg_right hC₁C hNr.le) + obtain ⟨k',hk',hk'0,m,hm⟩ := hfreq + let k (i : Fin d) := k' i.castSucc + let r := k' (Fin.last d) + have hkB (i : Fin d) : |k i|≤B := hBF k' hk' i.castSucc + have hrB : |r|≤B := hBF k' hk' (Fin.last d) + have hrel : |(∑ i,(k i:ℝ)*γ i)+(r:ℝ)*ρ-m|≤C₁/N := by + simpa only [Fin.sum_univ_castSucc,γ',Fin.snoc_castSucc,Fin.snoc_last,k,r] using hm + by_cases hr : r=0 + · right + have hk0 : k≠0 := by + intro hz + apply hk'0 + funext i + refine Fin.lastCases ?_ (fun j => ?_) i + · exact hr + · exact congrFun hz j + refine ⟨k,hk0,fun i => (hkB i).trans (by exact_mod_cast hBR),m,?_⟩ + simpa [hr] using hrel.trans (div_le_div_of_nonneg_right hC₁C hNr.le) + let a₂ (i : Fin d) := (r:ℝ)*a i-(k i:ℝ) + let ρ₂ := (∑ i,(k i:ℝ)*γ i)+(r:ℝ)*ρ-m + let b₀ := (r:ℝ)*b+∑ i,(k i:ℝ)*β i + let b₂ := b₀-(round b₀:ℝ) + have hrBr : |(r:ℝ)|≤B := by exact_mod_cast hrB + have hkBr (i : Fin d) : |(k i:ℝ)|≤B := by exact_mod_cast hkB i + have ha₂ : ‖a₂‖≤A₂ := by + apply (pi_norm_le_iff_of_nonneg hA₂.le).mpr + intro i + have hai : |a i|≤A := (pi_norm_le_iff_of_nonneg hA.le).mp ha i + change |(r:ℝ)*a i-(k i:ℝ)|≤A₂ + calc + _ ≤ |(r:ℝ)| * |a i|+|(k i:ℝ)| := by simpa only [abs_mul] using abs_sub ((r:ℝ)*a i) (k i:ℝ) + _ ≤ (B:ℝ)*A+B := add_le_add (mul_le_mul hrBr hai (abs_nonneg _) (Nat.cast_nonneg _)) (hkBr i) + _ = (B:ℝ)*(A+1) := by ring + _ ≤ A₂ := hBA1 + have hρ₂ : |ρ₂|≤A₂/N := hrel.trans (div_le_div_of_nonneg_right hC₁A₂ hNr.le) + have hb₂ : |b₂|≤1 := (abs_sub_round b₀).trans (by norm_num) + have heval₂ (n : ℕ) : + ((b₂+ρ₂*n+∑ i,a₂ i*x n i:ℝ):UnitAddCircle)= + r • ((b+ρ*n+∑ i,a i*x n i:ℝ):UnitAddCircle) := by + have he : b₂+ρ₂*n+∑ i,a₂ i*x n i = + (r:ℝ)*(b+ρ*n+∑ i,a i*x n i)+ + (∑ i,(k i:ℝ)*(γ i*n+β i))-(∑ i,(k i:ℝ)*x n i)- + (m:ℝ)*n-(round b₀:ℝ) := by + dsimp [b₂,b₀,ρ₂,a₂] + simp only [sub_mul,mul_add,add_mul,sum_sub_distrib,sum_add_distrib,mul_sum,sum_mul] + ring_nf + simp only [mul_assoc,mul_comm (n:ℝ)] + ring + rw [he] + have hd := circle_dot_congr k (x n) (fun i => γ i*n+β i) (horbit n) + simp only [AddCircle.coe_add,AddCircle.coe_sub,circle_int_mul,circle_integer] + rw [← hd] + have hn0 : ((n:ℝ):UnitAddCircle)=0 := by exact_mod_cast circle_integer (n:ℤ) + rw [hn0] + simp + have hsmall₂ (n : ℕ) (hn : n∈S) : + ‖((b₂+ρ₂*n+∑ i,a₂ i*x n i:ℝ):UnitAddCircle)‖≤A₂/N := by + rw [heval₂] + calc + _ ≤ ‖r‖*‖((b+ρ*n+∑ i,a i*x n i:ℝ):UnitAddCircle)‖ := norm_zsmul_le _ _ + _ ≤ (B:ℝ)*(A/N) := mul_le_mul (by simpa only [Int.norm_eq_abs] using hrBr) (hsmall n hn) (norm_nonneg _) (Nat.cast_nonneg _) + _ = ((B:ℝ)*A)/N := by ring + _ ≤ A₂/N := div_le_div_of_nonneg_right hBA hNr.le + rcases hsecond N hN a₂ γ β ha₂ ρ₂ b₂ hρ₂ hb₂ x hx horbit S hSN hS hsmall₂ with htiny | hfreq + · left + refine ⟨r,hr,hrB.trans (by exact_mod_cast hBR),fun i => ⟨k i,?_⟩⟩ + have hi := (pi_norm_le_iff_of_nonneg (by positivity : 0≤C₂/(N:ℝ))).mp htiny i + exact hi.trans (div_le_div_of_nonneg_right hC₂C hNr.le) + · right + obtain ⟨k,hk,hk0,m,hm⟩ := hfreq + exact ⟨k,hk0,fun i => (hB₂F k hk i).trans (by exact_mod_cast hB₂R),m, + hm.trans (div_le_div_of_nonneg_right hC₂C hNr.le)⟩ + +end BracketDrift + +end +end +end +end +end + +end OAI diff --git a/lean/OAI/Combinatorics/SumProduct/Alignment/BracketHyperplanes01.lean b/lean/OAI/Combinatorics/SumProduct/Alignment/BracketHyperplanes01.lean new file mode 100644 index 0000000000000000000000000000000000000000..0e246305ba020628115e90defb74db1a3325822f --- /dev/null +++ b/lean/OAI/Combinatorics/SumProduct/Alignment/BracketHyperplanes01.lean @@ -0,0 +1,301 @@ +import Mathlib +import OAI.Combinatorics.SumProduct.Alignment.LeibmanSquare01 +import OAI.Geometry.NilpotentCharts.Main + +namespace OAI + +section +section +section +section +noncomputable section +open Polynomial Finset +open scoped BigOperators +end +end + + + +section + + + +open MeasureTheory Filter +open scoped ENNReal + +namespace PolynomialNullSet +variable {R : Type*} [CommRing R] [IsDomain R] + [TopologicalSpace R] [IsTopologicalRing R] [T2Space R] + [MeasurableSpace R] [BorelSpace R] [SecondCountableTopology R] + +theorem ae_eval_ne_zero : ∀ {n : ℕ} (p : MvPolynomial (Fin n) R) (_hp : p ≠ 0) + (μ : Fin n → Measure R) [∀ i, SigmaFinite (μ i)] [∀ i, NullSingletonClass (μ i)], + ∀ᵐ x ∂Measure.pi μ, MvPolynomial.eval x p ≠ 0 + | 0, p, hp, μ, _, _ => by + rw [p.eq_C_of_isEmpty] at * + simp only [MvPolynomial.eval_C] + exact Filter.Eventually.of_forall fun _ => MvPolynomial.C_ne_zero.mp hp + | n+1, p, hp, μ, _, _ => by + classical + let p' := MvPolynomial.finSuccEquiv R n p + have hp' : p' ≠ 0 := EmbeddingLike.map_ne_zero_iff.mpr hp + have hl : p'.leadingCoeff ≠ 0 := Polynomial.leadingCoeff_ne_zero.mpr hp' + have ih := ae_eval_ne_zero p'.leadingCoeff hl (fun j => μ j.succ) + have hfiber : ∀ᵐ y ∂Measure.pi (fun j : Fin n => μ j.succ), + ∀ᵐ z ∂μ 0, MvPolynomial.eval (Fin.cons z y) p ≠ 0 := by + filter_upwards [ih] with y hy + have hmap : p'.map (MvPolynomial.eval y) ≠ 0 := by + intro hh + apply hy + have hc := congrArg (fun q : Polynomial R => q.coeff p'.natDegree) hh + simpa only [Polynomial.coeff_map, Polynomial.coeff_zero, + Polynomial.leadingCoeff] using hc + have hz := (Polynomial.finite_setOfPred_isRoot hmap).countable.ae_notMem (μ 0) + simpa only [Set.mem_ofPred_eq, Polynomial.IsRoot, + MvPolynomial.eval_eq_eval_mv_eval', p'] using hz + have hm : MeasurableSet {x : R × (Fin n → R) | + MvPolynomial.eval (Fin.cons x.1 x.2) p ≠ 0} := by + apply MeasurableSet.compl + exact isClosed_eq (p.continuous_eval.comp (by fun_prop)) continuous_const |>.measurableSet + have hprod : ∀ᵐ x ∂(μ 0).prod (Measure.pi fun j : Fin n => μ j.succ), + MvPolynomial.eval (Fin.cons x.1 x.2) p ≠ 0 := + (Measure.ae_prod_iff_ae_ae hm).mpr ((Measure.ae_ae_comm hm).mpr hfiber) + have hpres := measurePreserving_piFinSuccAbove μ 0 + have hpull := hpres.quasiMeasurePreserving.tendsto_ae.eventually + (show ∀ᵐ x ∂(μ 0).prod (Measure.pi fun j : Fin n => μ ((0 : Fin (n+1)).succAbove j)), + MvPolynomial.eval (Fin.cons x.1 x.2) p ≠ 0 by simpa using hprod) + simpa only [MeasurableEquiv.piFinSuccAbove_apply, Fin.insertNthEquiv_symm_apply, + Fin.succAbove_zero, Fin.removeNth_zero, Fin.cons_self_tail] using hpull + +theorem measure_zero {n : ℕ} (p : MvPolynomial (Fin n) R) (hp : p ≠ 0) + (μ : Fin n → Measure R) [∀ i, SigmaFinite (μ i)] [∀ i, NullSingletonClass (μ i)] : + Measure.pi μ {x | MvPolynomial.eval x p = 0} = 0 := by + simpa only [ae_iff, not_not] using ae_eval_ne_zero p hp μ +end PolynomialNullSet + +namespace BracketHyperplanes +open MeasureTheory Set +open scoped BigOperators +noncomputable section + +variable {d : ℕ} +def torusMap (x : Fin d → ℝ) : UnitAddTorus (Fin d) := fun i => (x i : UnitAddCircle) +lemma continuous_torusMap : Continuous (torusMap (d := d)) := by + unfold torusMap + fun_prop + +def linearPolynomial (a : Fin d → ℝ) (b : ℝ) : MvPolynomial (Fin d) ℝ := + (∑ i, MvPolynomial.C (a i) * MvPolynomial.X i) - MvPolynomial.C b + +@[simp] lemma eval_linearPolynomial (a x : Fin d → ℝ) (b : ℝ) : + MvPolynomial.eval x (linearPolynomial a b) = (∑ i, a i*x i)-b := by + simp [linearPolynomial] + +lemma linearPolynomial_ne_zero (a : Fin d → ℝ) (ha : a ≠ 0) (b : ℝ) : + linearPolynomial a b ≠ 0 := by + intro he + have hzero := congrArg (MvPolynomial.eval (0 : Fin d → ℝ)) he + have hb : b=0 := by + rw [eval_linearPolynomial, MvPolynomial.eval_zero] at hzero + simpa using hzero + subst b + apply ha + funext i + have hi := congrArg (MvPolynomial.eval (Pi.single i 1)) he + simpa [Pi.single_apply] using hi + +lemma measure_affine_slice_zero (a : Fin d → ℝ) (ha : a ≠ 0) (b : ℝ) + (μ : Fin d → Measure ℝ) [∀ i, SigmaFinite (μ i)] + [∀ i, NullSingletonClass (μ i)] : + Measure.pi μ {x | ∑ i, a i*x i = b} = 0 := by + simpa only [eval_linearPolynomial,sub_eq_zero] using + PolynomialNullSet.measure_zero (linearPolynomial a b) (linearPolynomial_ne_zero a ha b) μ + + + +theorem torus_image_affine_slice_null (a : Fin d → ℝ) (ha : a ≠ 0) + (b : ℝ) (K : Set (Fin d → ℝ)) (hK : IsCompact K) : + volume (torusMap '' (K ∩ {x | ∑ i, a i*x i = b})) = 0 := by + classical + let μ : Fin d → Measure ℝ := fun _ => volume.restrict (Ioc (0:ℝ) 1) + have hm : MeasurePreserving (torusMap (d := d)) (Measure.pi μ) volume := by + convert! measurePreserving_pi + (fun _ : Fin d => volume.restrict (Ioc (0:ℝ) 1)) (fun _ => volume) + (fun _ => by simpa using AddCircle.measurePreserving_mk 1 0) using 1 + have hs : IsClosed {x : Fin d → ℝ | ∑ i, a i*x i = b} := + isClosed_eq (by fun_prop) continuous_const + have hcompact := (hK.inter_right hs).image continuous_torusMap + rw [← hm.measure_preimage hcompact.isClosed.measurableSet.nullMeasurableSet] + have hsub : torusMap ⁻¹' (torusMap '' (K ∩ {x | ∑ i, a i*x i = b})) ⊆ + ⋃ k : Fin d → ℤ, {x | ∑ i, a i*x i = b - ∑ i, a i*(k i:ℝ)} := by + rintro x ⟨y,hy,heq⟩ + have hz (i : Fin d) : ∃ k : ℤ, (k:ℝ) = y i-x i := by + have hh := congrFun heq i + change ((y i:ℝ):UnitAddCircle) = ((x i:ℝ):UnitAddCircle) at hh + have hh' : ((y i-x i : ℝ) : UnitAddCircle) = 0 := by + simpa only [AddCircle.coe_sub,sub_eq_zero] using hh + obtain ⟨k,hk⟩ := (AddCircle.coe_eq_zero_iff 1).mp hh' + exact ⟨k,by simpa using hk⟩ + choose k hk using hz + apply Set.mem_iUnion.mpr + refine ⟨k,?_⟩ + have he (i : Fin d) : y i = x i+(k i:ℝ) := by linarith [hk i] + have hsum := hy.2 + change ∑ i, a i*y i = b at hsum + simp_rw [he,mul_add,Finset.sum_add_distrib] at hsum + exact eq_sub_iff_add_eq.mpr hsum + apply measure_mono_null hsub + exact measure_iUnion_null fun k => measure_affine_slice_zero a ha _ μ + +end +end BracketHyperplanes + + + +namespace CompactNullFamilies +open MeasureTheory Set Topology Filter +noncomputable section + +variable {P Y X : Type*} [TopologicalSpace P] [CompactSpace P] [T2Space P] + [TopologicalSpace Y] [CompactSpace Y] [T2Space Y] + [TopologicalSpace X] [CompactSpace X] [T2Space X] + [MeasurableSpace X] [BorelSpace X] + (μ : Measure X) [IsFiniteMeasure μ] [μ.InnerRegularCompactLTTop] + + + +omit [T2Space Y] in +theorem finite_majorants (q : C(Y,X)) (v : C(P × Y,ℝ)) + (hzero : ∀ p : P, μ (q '' {y | v (p,y) = 0}) = 0) + (δ : ℝ) (hδ : 0 < δ) : + ∃ tests : Finset C(X,ℝ), ∃ ε : ℝ, 0 < ε ∧ + (∀ f ∈ tests, (∀ x, 0 ≤ f x ∧ f x ≤ 1) ∧ (∫ x, f x ∂μ) < δ) ∧ + ∀ p : P, ∃ f ∈ tests, ∀ y : Y, 0 ≤ v (p,y) → v (p,y) ≤ ε → + (1:ℝ)/2 < f (q y) := by + classical + have hp (p : P) : ∃ f : C(X,ℝ), (∀ x, 0 ≤ f x ∧ f x ≤ 1) ∧ + (∫ x, f x ∂μ) < δ ∧ ∀ y, v (p,y)=0 → f (q y)=1 := by + let K := q '' {y | v (p,y)=0} + have hK : IsCompact K := + (isClosed_eq (v.continuous.comp (continuous_const.prodMk continuous_id)) + continuous_const).isCompact.image q.continuous + obtain ⟨U,hKU,hU,hμU⟩ := hK.exists_isOpen_lt_of_lt (ENNReal.ofReal δ) + (by rw [hzero p]; exact ENNReal.ofReal_pos.mpr hδ) + obtain ⟨f,hfK,hfU,hfs,hf⟩ := exists_continuous_one_zero_of_isCompact hK + hU.isClosed_compl (disjoint_compl_right_iff_subset.mpr hKU) + refine ⟨f,hf,?_,fun y hy => hfK ⟨y,hy,rfl⟩⟩ + have hi := (integral_le_measure (fun x _ => (hf x).2) + (fun x hx => (hfU hx).le)).trans_lt hμU + exact (ENNReal.ofReal_lt_ofReal_iff hδ).mp hi + choose f hf hi hfzero using hp + let W : Set ((P × ℝ) × X) := + (fun t : P × Y => ((t.1,v t),q t.2)) '' Set.univ + have hW : IsCompact W := isCompact_univ.image (by + exact (continuous_fst.prodMk v.continuous).prodMk + (q.continuous.comp continuous_snd)) + let B (p : P) : Set (P × ℝ) := Prod.fst '' + (W ∩ {z | f p z.2 ≤ (1:ℝ)/2}) + have hB (p : P) : IsClosed (B p) := + ((hW.inter_right (isClosed_le ((f p).continuous.comp continuous_snd) + continuous_const)).image continuous_fst).isClosed + have hpB (p : P) : (p,0) ∉ B p := by + rintro ⟨⟨⟨p',r⟩,x⟩,⟨⟨⟨a,y⟩,_,he⟩,hfx⟩,hfirst⟩ + have hpa : a=p := by exact (congrArg (fun z => z.1.1) he).trans (congrArg Prod.fst hfirst) + have hr : v (a,y)=0 := by exact (congrArg (fun z => z.1.2) he).trans (congrArg Prod.snd hfirst) + have hx : q y=x := congrArg Prod.snd he + subst a + change f p x ≤ (1:ℝ)/2 at hfx + rw [← hx,hfzero p y hr] at hfx + norm_num at hfx + have hopper (p : P) : ∃ U : Set P, ∃ V : Set ℝ, + IsOpen U ∧ IsOpen V ∧ p ∈ U ∧ 0 ∈ V ∧ U ×ˢ V ⊆ (B p)ᶜ := + isOpen_prod_iff.mp (hB p).isOpen_compl p 0 (hpB p) + choose U V hU hV hpU hzV hUV using hopper + obtain ⟨S,hS⟩ := isCompact_univ.elim_finite_subcover U hU + (fun p _ => Set.mem_iUnion.mpr ⟨p,hpU p⟩) + have hVnhds : (⋂ p ∈ S, V p) ∈ 𝓝 (0:ℝ) := by + exact (Filter.biInter_mem S.finite_toSet).mpr (fun p hp => (hV p).mem_nhds (hzV p)) + obtain ⟨ε,hε,hεV⟩ := Metric.mem_nhds_iff.mp hVnhds + refine ⟨S.image f,ε/2,by positivity,?_,?_⟩ + · intro g hg + obtain ⟨p,hp,rfl⟩ := Finset.mem_image.mp hg + exact ⟨hf p,hi p⟩ + · intro p + obtain ⟨a,ha,hpa⟩ := Set.mem_iUnion₂.mp (hS (Set.mem_univ p)) + refine ⟨f a,Finset.mem_image.mpr ⟨a,ha,rfl⟩,?_⟩ + intro y hv0 hve + have hball : v (p,y) ∈ Metric.ball 0 ε := by + rw [Metric.mem_ball,Real.dist_eq,sub_zero,abs_of_nonneg hv0] + linarith + have hvV : v (p,y) ∈ V a := Set.mem_iInter₂.mp (hεV hball) a ha + have hout : (p,v (p,y)) ∉ B a := hUV a ⟨hpa,hvV⟩ + apply lt_of_not_ge + intro hle + apply hout + exact ⟨((p,v (p,y)),q y),⟨⟨(p,y),Set.mem_univ _,rfl⟩,hle⟩,rfl⟩ + +end +end CompactNullFamilies + +namespace BracketHyperplanes +open MeasureTheory Set +open scoped BigOperators +noncomputable section +variable {d : ℕ} + + +theorem torus_image_mod_affine_null (a : Fin d → ℝ) (ha : a ≠ 0) + (b : ℝ) (K : Set (Fin d → ℝ)) (hK : IsCompact K) : + volume (torusMap '' (K ∩ {x | ‖((∑ i, a i*x i - b : ℝ) : UnitAddCircle)‖ = 0})) = 0 := by + have hs : torusMap '' (K ∩ {x | ‖((∑ i, a i*x i-b : ℝ) : UnitAddCircle)‖ = 0}) ⊆ + ⋃ k : ℤ, torusMap '' (K ∩ {x | ∑ i, a i*x i = b+(k:ℝ)}) := by + rintro t ⟨x,⟨hx,hzero⟩,rfl⟩ + obtain ⟨k,hk⟩ := (AddCircle.coe_eq_zero_iff 1).mp (norm_eq_zero.mp hzero) + have hk' : (k:ℝ) = ∑ i, a i*x i-b := by simpa using hk + exact Set.mem_iUnion.mpr ⟨k,x,⟨hx,by change ∑ i, a i*x i = b+(k:ℝ); linarith only [hk']⟩,rfl⟩ + exact measure_mono_null hs (measure_iUnion_null fun k => + torus_image_affine_slice_null a ha _ K hK) + + + +theorem compact_bracket_tests {P : Type*} [TopologicalSpace P] + [CompactSpace P] [T2Space P] + (a : C(P, Fin d → ℝ)) (ha : ∀ p, a p ≠ 0) (b : C(P, ℝ)) + (K : Set (Fin d → ℝ)) (hK : IsCompact K) (δ : ℝ) (hδ : 0 < δ) : + ∃ tests : Finset C(UnitAddTorus (Fin d),ℝ), ∃ ε : ℝ, 0 < ε ∧ + (∀ f ∈ tests, (∀ t, 0 ≤ f t ∧ f t ≤ 1) ∧ (∫ t, f t) < δ) ∧ + ∀ p : P, ∃ f ∈ tests, ∀ x ∈ K, + ‖((∑ i, a p i*x i-b p : ℝ) : UnitAddCircle)‖ ≤ ε → + (1:ℝ)/2 < f (torusMap x) := by + let : CompactSpace K := isCompact_iff_compactSpace.mp hK + let q : C(K,UnitAddTorus (Fin d)) := + ⟨fun x => torusMap x.val, continuous_torusMap.comp continuous_subtype_val⟩ + let v : C(P × K,ℝ) := ⟨fun t => + ‖((∑ i, a t.1 i*t.2.val i-b t.1 : ℝ) : UnitAddCircle)‖, by + apply Continuous.norm + apply (AddCircle.continuous_mk' 1).comp + exact (continuous_finsetSum Finset.univ (fun i _ => + ((continuous_apply i).comp (a.continuous.comp continuous_fst)).mul + ((continuous_apply i).comp (continuous_subtype_val.comp continuous_snd)))).sub + (b.continuous.comp continuous_fst)⟩ + have hzero (p : P) : volume (q '' {y | v (p,y)=0}) = 0 := by + apply measure_mono_null (μ := volume) _ (torus_image_mod_affine_null (a p) (ha p) (b p) K hK) + rintro t ⟨y,hy,rfl⟩ + exact ⟨y.val,⟨y.property,hy⟩,rfl⟩ + obtain ⟨T,ε,hε,hT,hcover⟩ := CompactNullFamilies.finite_majorants volume q v hzero δ hδ + refine ⟨T,ε,hε,hT,?_⟩ + intro p + obtain ⟨f,hf,hfcover⟩ := hcover p + exact ⟨f,hf,fun x hx hsmall => hfcover ⟨x,hx⟩ (norm_nonneg (((∑ i, a p i*x i-b p : ℝ) : UnitAddCircle))) hsmall⟩ + +end +end BracketHyperplanes + + + +end +end +end +end + +end OAI diff --git a/lean/OAI/Combinatorics/SumProduct/Alignment/BracketHyperplanes02.lean b/lean/OAI/Combinatorics/SumProduct/Alignment/BracketHyperplanes02.lean new file mode 100644 index 0000000000000000000000000000000000000000..d4d49fdd43778f727514e2e9387b94e9aa66dabf --- /dev/null +++ b/lean/OAI/Combinatorics/SumProduct/Alignment/BracketHyperplanes02.lean @@ -0,0 +1,364 @@ +import Mathlib +import OAI.Combinatorics.SumProduct.Alignment.FourierObstruction01 +import OAI.Combinatorics.SumProduct.Alignment.LeibmanSquare03 +import OAI.Geometry.NilpotentCharts.Main + +namespace OAI + +section +section +section +section +open MeasureTheory Filter +open scoped ENNReal +namespace BracketHyperplanes +open MeasureTheory PolynomialWeyl +open scoped BigOperators +noncomputable section +variable {d : ℕ} + +lemma phase_finset_sum {ι : Type*} (s : Finset ι) (f : ι → ℝ) : + phase (∑ i ∈ s, f i) = ∏ i ∈ s, phase (f i) := by + classical + induction s using Finset.induction_on with + | empty => simp [phase] + | @insert i s hi ih => simp [Finset.sum_insert,Finset.prod_insert,hi,ih] + +lemma character_linearOrbit (k : Fin d → ℤ) (α β : Fin d → ℝ) (n : ℕ) : + UnitAddTorus.mFourier k (torusMap (fun i => α i*n+β i)) = + phase ((∑ i, (k i:ℝ)*α i)*n + ∑ i, (k i:ℝ)*β i) := by + calc + _ = ∏ i, phase ((k i:ℝ)*(α i*n+β i)) := by + simp only [UnitAddTorus.mFourier,ContinuousMap.coe_mk,torusMap] + apply Finset.prod_congr rfl + intro i _ + simp only [fourier_coe_apply,Complex.ofReal_one,div_one,phase] + congr 1 + push_cast + ring + _ = phase (∑ i, (k i:ℝ)*(α i*n+β i)) := (phase_finset_sum _ _).symm + _ = _ := by + congr 1 + simp only [mul_add,Finset.sum_add_distrib,Finset.sum_mul,← mul_assoc] + + + +theorem compact_bracket_linear_inverse {P : Type*} [TopologicalSpace P] + [CompactSpace P] [T2Space P] + (a : C(P, Fin d → ℝ)) (ha : ∀ p, a p ≠ 0) (b : C(P, ℝ)) + (K : Set (Fin d → ℝ)) (hK : IsCompact K) (δ : ℝ) (hδ : 0 < δ) : + ∃ frequencies : Finset (Fin d → ℤ), ∃ ε A : ℝ, 0 < ε ∧ 0 < A ∧ + ∀ N : ℕ, 0 < N → ∀ p : P, ∀ α β : Fin d → ℝ, + ∀ x : ℕ → Fin d → ℝ, (∀ n, x n ∈ K) → + (∀ n, torusMap (x n) = torusMap (fun i => α i*n+β i)) → + ∀ S : Finset ℕ, S ⊆ Finset.range N → δ*N ≤ S.card → + (∀ n ∈ S, ‖((∑ i, a p i*x n i-b p : ℝ) : UnitAddCircle)‖ ≤ ε) → + ∃ k ∈ frequencies, k ≠ 0 ∧ ∃ m : ℤ, + |(∑ i, (k i:ℝ)*α i)-m| ≤ A/N := by + obtain ⟨F,ε,η,hε,hη,hF⟩ := compact_bracket_fourier a ha b K hK δ hδ + refine ⟨F,ε,1/η,hε,by positivity,?_⟩ + intro N hN p α β x hx horbit S hS hdens hsmall + obtain ⟨k,hk,hk₀,hlarge⟩ := hF N hN p x hx S hS hdens hsmall + have he : (fun n => UnitAddTorus.mFourier k (torusMap (x n))) = + fun n : ℕ => phase ((∑ i, (k i:ℝ)*α i)*n + ∑ i, (k i:ℝ)*β i) := by + funext n + rw [horbit n,character_linearOrbit] + rw [he] at hlarge + obtain ⟨m,hm⟩ := linear_inverse hN (∑ i, (k i:ℝ)*α i) (∑ i, (k i:ℝ)*β i) η hη hlarge + refine ⟨k,hk,hk₀,m,?_⟩ + simpa only [div_div] using hm + +end +end BracketHyperplanes + +namespace BracketHyperplanes +open MeasureTheory Set +open scoped BigOperators +noncomputable section +variable {d : ℕ} + +lemma abs_dot_le (a x : Fin d → ℝ) (hx : ‖x‖ ≤ 1) : + |∑ i, a i*x i| ≤ (d:ℝ)*‖a‖ := by + calc + _ ≤ ∑ i, |a i*x i| := Finset.abs_sum_le_sum_abs _ _ + _ ≤ ∑ _ : Fin d, ‖a‖ := by + apply Finset.sum_le_sum + intro i _ + rw [abs_mul] + have ha : |a i| ≤ ‖a‖ := norm_le_pi_norm a i + have hxi : |x i| ≤ 1 := (norm_le_pi_norm x i).trans hx + exact (mul_le_mul ha hxi (abs_nonneg _) (norm_nonneg _)).trans_eq (mul_one _) + _ = _ := by simp + + + +theorem scaled_bracket_alternative (d : ℕ) (A δ : ℝ) (hA : 0 ≤ A) (hδ : 0 < δ) : + ∃ frequencies : Finset (Fin d → ℤ), ∃ C : ℝ, 0 < C ∧ + ∀ N : ℕ, 0 < N → ∀ a α β : Fin d → ℝ, ‖a‖ ≤ A → + ∀ b : ℝ, |b| ≤ 1 → ∀ x : ℕ → Fin d → ℝ, (∀ n, ‖x n‖ ≤ 1) → + (∀ n, torusMap (x n) = torusMap (fun i => α i*n+β i)) → + ∀ S : Finset ℕ, S ⊆ Finset.range N → δ*N ≤ S.card → + (∀ n ∈ S, ‖((∑ i, a i*x n i-b : ℝ) : UnitAddCircle)‖ ≤ 1/N) → + ‖a‖ ≤ C/N ∨ ∃ k ∈ frequencies, k ≠ 0 ∧ ∃ m : ℤ, + |(∑ i, (k i:ℝ)*α i)-m| ≤ C/N := by + classical + let K : Set (Fin d → ℝ) := Metric.closedBall 0 1 + have hK : IsCompact K := isCompact_closedBall _ _ + let Q : Set ((Fin d → ℝ) × ℝ) := Metric.sphere 0 1 ×ˢ Icc (-(d:ℝ)-1) (d+1) + have hQ : IsCompact Q := (isCompact_sphere _ _).prod isCompact_Icc + let : CompactSpace Q := isCompact_iff_compactSpace.mp hQ + let ca : C(Q,Fin d → ℝ) := ⟨fun p => p.val.1, continuous_fst.comp continuous_subtype_val⟩ + let cb : C(Q,ℝ) := ⟨fun p => p.val.2, continuous_snd.comp continuous_subtype_val⟩ + have hca (p : Q) : ca p ≠ 0 := by + have hp : ‖ca p‖=1 := by simpa [ca,Metric.mem_sphere,dist_zero_right] using p.property.1 + intro he + rw [he,norm_zero] at hp + norm_num at hp + let L := ⌈(d:ℝ)*A+2⌉₊ + let J : Finset ℤ := Finset.Icc (-(L:ℤ)) L + have hJ : J.Nonempty := ⟨0, by simp [J]⟩ + have hJpos : (0:ℝ) k n=j) + have hS'S : S' ⊆ S := Finset.filter_subset _ _ + have hS' : S'.Nonempty := Finset.card_pos.mp (by + have hp : (0:ℝ) by simpa [K,Metric.mem_closedBall,dist_zero_right] using hx n) + horbit S' (hS'S.trans hS) hjdens hp_small + exact ⟨l,hl,hl₀,m,hm.trans (div_le_div_of_nonneg_right hCC hNr.le)⟩ + +end +end BracketHyperplanes +end + + + +section +noncomputable section +open Finset _root_.Polynomial _root_.OAI.Polynomial +open scoped BigOperators +namespace BracketDrift + + + +lemma dense_block (N L : ℕ) (hL : 0 n/L=a) + let T := F.image (fun n => n%L) + have hinj : Set.InjOn (fun n => n%L) (↑F:Set ℕ) := by + intro n hn m hm he + have hn' := (mem_filter.mp hn).2 + have hm' := (mem_filter.mp hm).2 + have hnmod := Nat.mod_add_div n L + have hmmod := Nat.mod_add_div m L + change n%L=m%L at he + rw [hn'] at hnmod + rw [hm'] at hmmod + omega + have hTcard : T.card=F.card := card_image_of_injOn hinj + refine ⟨a,T,?_,?_,?_⟩ + · intro t ht + obtain ⟨n,hn,rfl⟩ := mem_image.mp ht + exact mem_range.mpr (Nat.mod_lt n hL) + · rw [hTcard]; exact hcard + · intro t ht + obtain ⟨n,hn,rfl⟩ := mem_image.mp ht + have hn' := (mem_filter.mp hn).2 + have he : a*L+n%L=n := by + rw [← hn'] + simpa [Nat.add_comm,Nat.mul_comm] using Nat.mod_add_div n L + rw [he] + exact (mem_filter.mp hn).1 + + + +theorem relative_slope (A K δ : ℝ) (hA : 0 ∫ k : K, f (k • x) ∂ν) + have h : Continuous (Function.uncurry (fun x : X => fun k : K => f (k • x))) := by + exact f.continuous.comp (continuous_snd.smul continuous_fst) + simpa only [Measure.restrict_univ] using + (continuous_parametric_integral_of_continuous (μ := ν) h isCompact_univ) + +omit [CompactSpace K] [T2Space X] [CompactSpace X] [SecondCountableTopology X] + [MeasurableSpace X] [BorelSpace X] [ContinuousSMul K X] in +lemma average_smul [Measure.IsMulRightInvariant ν] (f : C(X,ℝ)) (k : K) (x : X) : + average ν f (k • x) = average ν f x := by + unfold average + simp_rw [← mul_smul] + exact integral_mul_right_eq_self (fun l : K => f (l • x)) k + +omit [IsTopologicalGroup K] in +lemma integral_average [IsProbabilityMeasure ν] (μ : ProbabilityMeasure X) + [SMulInvariantMeasure K X (μ : Measure X)] (f : C(X,ℝ)) : + (∫ x, average ν f x ∂(μ : Measure X)) = ∫ x, f x ∂(μ : Measure X) := by + have hc : Continuous (Function.uncurry (fun x : X => fun k : K => f (k • x))) := + f.continuous.comp (continuous_snd.smul continuous_fst) + have hi : Integrable (Function.uncurry (fun x : X => fun k : K => f (k • x))) + ((μ : Measure X).prod ν) := + hc.integrable_of_hasCompactSupport (HasCompactSupport.of_compactSpace _) + unfold average + rw [integral_integral_swap hi] + simp only [integral_smul_eq_self] + simp + +variable [TopologicalSpace Y] [T2Space Y] + + + +omit [MeasurableSpace X] [BorelSpace X] in +theorem exists_average_descend (ν : Measure K) [IsProbabilityMeasure ν] + [Measure.IsMulRightInvariant ν] (p : C(X,Y)) (hp : Function.Surjective p) + (hfib : ∀ x z, p x = p z → ∃ k : K, k • x = z) (f : C(X,ℝ)) : + ∃ F : C(Y,ℝ), ∀ x, F (p x) = average ν f x := by + classical + let s : Y → X := fun y => Classical.choose (hp y) + have hs : ∀ y, p (s y) = y := fun y => Classical.choose_spec (hp y) + let F : Y → ℝ := fun y => average ν f (s y) + have he : F ∘ p = average ν f := by + funext x + obtain ⟨k,hk⟩ := hfib x (s (p x)) (hs (p x)).symm + change average ν f (s (p x)) = average ν f x + rw [← hk,average_smul] + have hc : Continuous F := + (p.continuous.isClosedMap.isQuotientMap p.continuous hp).continuous_iff.mpr + (he ▸ continuous_average f) + exact ⟨⟨F,hc⟩,fun x => congrFun he x⟩ + +variable [MeasurableSpace Y] [BorelSpace Y] [HasOuterApproxClosed X] + + + +theorem measure_eq_of_map_eq (ν : Measure K) [IsProbabilityMeasure ν] + [Measure.IsMulRightInvariant ν] (p : C(X,Y)) (hp : Function.Surjective p) + (hfib : ∀ x z, p x = p z → ∃ k : K, k • x = z) + (μ₁ μ₂ : ProbabilityMeasure X) + [SMulInvariantMeasure K X (μ₁ : Measure X)] + [SMulInvariantMeasure K X (μ₂ : Measure X)] + (he : Measure.map p (μ₁ : Measure X) = Measure.map p (μ₂ : Measure X)) : + (μ₁ : Measure X) = (μ₂ : Measure X) := by + have hfm : μ₁.toFiniteMeasure = μ₂.toFiniteMeasure := by + apply FiniteMeasure.ext_of_forall_integral_eq + intro f + obtain ⟨F,hF⟩ := exists_average_descend ν p hp hfib f.toContinuousMap + change (∫ x, f.toContinuousMap x ∂(μ₁ : Measure X)) = + ∫ x, f.toContinuousMap x ∂(μ₂ : Measure X) + rw [← integral_average (ν := ν) μ₁ f.toContinuousMap, + ← integral_average (ν := ν) μ₂ f.toContinuousMap] + simp_rw [← hF] + rw [← integral_map p.continuous.measurable.aemeasurable F.continuous.aestronglyMeasurable, + ← integral_map p.continuous.measurable.aemeasurable F.continuous.aestronglyMeasurable,he] + exact congrArg (fun m : FiniteMeasure X => (m : Measure X)) hfm + + +theorem exists_right_probability : ∃ ν : Measure K, IsProbabilityMeasure ν ∧ + Measure.IsMulRightInvariant ν := by + let U : TopologicalSpace.PositiveCompacts K := ⟨⟨univ,isCompact_univ⟩,by simp⟩ + let μ := Measure.haarMeasure U + refine ⟨μ.inv,⟨?_⟩,inferInstance⟩ + rw [Measure.inv_apply] + simp only [Set.inv_univ] + exact Measure.haarMeasure_self + + + +theorem ext_of_map_eq (p : C(X,Y)) (hp : Function.Surjective p) + (hfib : ∀ x z, p x = p z → ∃ k : K, k • x = z) + (μ₁ μ₂ : ProbabilityMeasure X) + [SMulInvariantMeasure K X (μ₁ : Measure X)] + [SMulInvariantMeasure K X (μ₂ : Measure X)] + (he : Measure.map p (μ₁ : Measure X) = Measure.map p (μ₂ : Measure X)) : + (μ₁ : Measure X) = (μ₂ : Measure X) := by + obtain ⟨ν,hν,hνr⟩ := exists_right_probability (K := K) + let := hν + let := hνr + exact measure_eq_of_map_eq ν p hp hfib μ₁ μ₂ he + +end CentralFiberAverage + + + +open MeasureTheory Topology Set +namespace RationalNilmanifoldMeasure +variable {G : Type*} [Group G] [TopologicalSpace G] [IsTopologicalGroup G] + [T2Space G] [SecondCountableTopology G] + +omit [TopologicalSpace G] [IsTopologicalGroup G] [T2Space G] [SecondCountableTopology G] in +lemma normal_of_central (N : Subgroup G) (hN : N ≤ Subgroup.center G) : N.Normal := by + constructor + intro n hn g + rw [Subgroup.mem_center_iff.mp (hN hn) g,mul_assoc,mul_inv_cancel,mul_one] + exact hn + +variable (N Γ : Subgroup G) [N.Normal] + + + +theorem measure_eq_of_central_map_eq + (hN : N ≤ Subgroup.center G) + (hG : CompactGroupProducts.HasCompactReps ⊤ Γ) + (hRN : CompactGroupProducts.HasCompactReps N Γ) + (hΓ : IsDiscrete (Γ : Set G)) + [MeasurableSpace (G ⧸ Γ)] [BorelSpace (G ⧸ Γ)] + [MeasurableSpace ((G ⧸ N) ⧸ Γ.map (QuotientGroup.mk' N))] + [BorelSpace ((G ⧸ N) ⧸ Γ.map (QuotientGroup.mk' N))] + (μ₁ μ₂ : ProbabilityMeasure (G ⧸ Γ)) + [SMulInvariantMeasure G (G ⧸ Γ) (μ₁ : Measure (G ⧸ Γ))] + [SMulInvariantMeasure G (G ⧸ Γ) (μ₂ : Measure (G ⧸ Γ))] + (he : Measure.map (RationalQuotientFunctions.quotientMap N Γ) (μ₁ : Measure (G ⧸ Γ)) = + Measure.map (RationalQuotientFunctions.quotientMap N Γ) (μ₂ : Measure (G ⧸ Γ))) : + (μ₁ : Measure (G ⧸ Γ)) = (μ₂ : Measure (G ⧸ Γ)) := by + let : DiscreteTopology Γ := isDiscrete_iff_discreteTopology.mp hΓ + let : IsClosed (Γ : Set G) := Subgroup.isClosed_of_discreteTopology + let : IsClosed (N : Set G) := hRN.isClosed hΓ + let : CompactSpace (G ⧸ Γ) := hG.quotient_compactSpace + let : (Γ.comap N.subtype).Normal := CentralQuotientAction.central_kernel_normal N Γ hN + let := CentralQuotientAction.action N Γ hN + let := CentralQuotientAction.continuous_action N Γ hN + let := CentralQuotientAction.compact_central_quotient N Γ hRN + let : MeasurableSpace (N ⧸ Γ.comap N.subtype) := borel _ + let : BorelSpace (N ⧸ Γ.comap N.subtype) := ⟨rfl⟩ + let := CentralQuotientAction.invariant_central_action N Γ hN (μ₁ : Measure (G ⧸ Γ)) + let := CentralQuotientAction.invariant_central_action N Γ hN (μ₂ : Measure (G ⧸ Γ)) + let := hRN.discrete_map hΓ + let : IsClosed (Γ.map (QuotientGroup.mk' N) : Set (G ⧸ N)) := + Subgroup.isClosed_of_discreteTopology + exact CentralFiberAverage.ext_of_map_eq + ⟨RationalQuotientFunctions.quotientMap N Γ, + RationalQuotientFunctions.continuous_quotientMap N Γ⟩ + (RationalQuotientFunctions.quotientMap_surjective N Γ) + (CentralQuotientAction.quotientMap_fibers N Γ hN) μ₁ μ₂ he + +end RationalNilmanifoldMeasure + +namespace CompactGroupProducts +open Set +variable {G K : Type*} [Group G] [Group K] [TopologicalSpace G] [TopologicalSpace K] + +lemma HasCompactReps.map {H Γ : Subgroup G} (h : HasCompactReps H Γ) + (φ : G →* K) (hφ : Continuous φ) : HasCompactReps (H.map φ) (Γ.map φ) := by + obtain ⟨C,hC,hCH,hr⟩ := h + refine ⟨φ '' C,hC.image hφ,?_,?_⟩ + · rintro y ⟨c,hc,rfl⟩ + exact ⟨c,hCH hc,rfl⟩ + · rintro y ⟨g,hg,rfl⟩ + obtain ⟨c,hc,hcg⟩ := hr g hg + exact ⟨φ c,⟨c,hc,rfl⟩,⟨c⁻¹*g,hcg,by simp⟩⟩ +end CompactGroupProducts + +namespace RationalNilmanifoldMeasure +open scoped commutatorElement +universe u + + + +theorem invariant_unique_of_series (n : ℕ) + {G : Type u} [Group G] [TopologicalSpace G] [IsTopologicalGroup G] + [T2Space G] [SecondCountableTopology G] + (Γ : Subgroup G) (H : ℕ → Subgroup G) + (h0 : H 0 = ⊤) (hn : H n = ⊥) + (hc : ∀ i (g x : G), x ∈ H i → ⁅g,x⁆ ∈ H (i+1)) + (hr : ∀ i, CompactGroupProducts.HasCompactReps (H i) Γ) + (hΓ : IsDiscrete (Γ : Set G)) + [MeasurableSpace (G ⧸ Γ)] [BorelSpace (G ⧸ Γ)] + (μ₁ μ₂ : ProbabilityMeasure (G ⧸ Γ)) + [SMulInvariantMeasure G (G ⧸ Γ) (μ₁ : Measure (G ⧸ Γ))] + [SMulInvariantMeasure G (G ⧸ Γ) (μ₂ : Measure (G ⧸ Γ))] : + (μ₁ : Measure (G ⧸ Γ)) = (μ₂ : Measure (G ⧸ Γ)) := by + induction n generalizing G with + | zero => + have ht : (⊤ : Subgroup G) = ⊥ := h0.symm.trans hn + have hone : ∀ g : G, g = 1 := fun g => + Subgroup.mem_bot.mp (ht ▸ Subgroup.mem_top g) + let : Subsingleton G := ⟨fun a b => (hone a).trans (hone b).symm⟩ + let : Subsingleton (G ⧸ Γ) := inferInstance + apply Measure.ext + intro s hs + rcases Set.eq_empty_or_nonempty s with he | ⟨x,hx⟩ + · rw [he] + simp + · have he : s = Set.univ := Set.eq_univ_of_forall fun y => + (Subsingleton.elim x y) ▸ hx + rw [he] + simp + | succ n ih => + let N := H n + have hN : N ≤ Subgroup.center G := by + intro x hx + rw [Subgroup.mem_center_iff] + intro g + apply commutatorElement_eq_one_iff_mul_comm.mp + exact Subgroup.mem_bot.mp (hn ▸ hc n g x hx) + let : N.Normal := normal_of_central N hN + have hRN : CompactGroupProducts.HasCompactReps N Γ := hr n + have hG : CompactGroupProducts.HasCompactReps ⊤ Γ := by simpa only [h0] using hr 0 + let : IsClosed (N : Set G) := hRN.isClosed hΓ + let φ : G →* G ⧸ N := QuotientGroup.mk' N + let Γ' := Γ.map φ + let H' : ℕ → Subgroup (G ⧸ N) := fun i => (H i).map φ + have h0' : H' 0 = ⊤ := by + dsimp [H'] + rw [h0,Subgroup.map_top_of_surjective φ (QuotientGroup.mk'_surjective N)] + have hn' : H' n = ⊥ := by + apply le_antisymm _ bot_le + rintro y ⟨x,hx,rfl⟩ + exact Subgroup.mem_bot.mpr ((QuotientGroup.eq_one_iff x).mpr hx) + have hc' : ∀ i (g x : G ⧸ N), x ∈ H' i → ⁅g,x⁆ ∈ H' (i+1) := by + intro i g x hx + obtain ⟨a,rfl⟩ := QuotientGroup.mk'_surjective N g + obtain ⟨b,hb,rfl⟩ := hx + exact ⟨⁅a,b⁆,hc i a b hb,map_commutatorElement φ a b⟩ + have hr' : ∀ i, CompactGroupProducts.HasCompactReps (H' i) Γ' := + fun i => (hr i).map φ QuotientGroup.continuous_mk + let : DiscreteTopology Γ' := hRN.discrete_map hΓ + have hΓ' : IsDiscrete (Γ' : Set (G ⧸ N)) := isDiscrete_iff_discreteTopology.mpr inferInstance + let : MeasurableSpace ((G ⧸ N) ⧸ Γ') := borel _ + let : BorelSpace ((G ⧸ N) ⧸ Γ') := ⟨rfl⟩ + let p := RationalQuotientFunctions.quotientMap N Γ + let ν₁ : ProbabilityMeasure ((G ⧸ N) ⧸ Γ') := μ₁.map p + let ν₂ : ProbabilityMeasure ((G ⧸ N) ⧸ Γ') := μ₂.map p + let : SMulInvariantMeasure (G ⧸ N) _ (ν₁ : Measure ((G ⧸ N) ⧸ Γ')) := + CentralQuotientAction.invariant_quotientMap N Γ (μ₁ : Measure (G ⧸ Γ)) + let : SMulInvariantMeasure (G ⧸ N) _ (ν₂ : Measure ((G ⧸ N) ⧸ Γ')) := + CentralQuotientAction.invariant_quotientMap N Γ (μ₂ : Measure (G ⧸ Γ)) + have he := ih Γ' H' h0' hn' hc' hr' hΓ' ν₁ ν₂ + exact measure_eq_of_central_map_eq N Γ hN hG hRN hΓ μ₁ μ₂ he +end RationalNilmanifoldMeasure + +end +end +end +end + +end OAI diff --git a/lean/OAI/Combinatorics/SumProduct/Alignment/CentralQuotient01.lean b/lean/OAI/Combinatorics/SumProduct/Alignment/CentralQuotient01.lean new file mode 100644 index 0000000000000000000000000000000000000000..c486a060d8ee3152e2761e8033add558eccd7a0a --- /dev/null +++ b/lean/OAI/Combinatorics/SumProduct/Alignment/CentralQuotient01.lean @@ -0,0 +1,298 @@ +import Mathlib +import OAI.Combinatorics.SumProduct.Alignment.RationalQuotient01 +import OAI.Geometry.NilpotentCharts.Main + +namespace OAI + +section +section +section +section +open Topology +open scoped Pointwise +namespace CompactGroupProducts +variable {G : Type*} [Group G] [TopologicalSpace G] + + +def HasCompactReps (H Γ : Subgroup G) : Prop := + ∃ C : Set G, IsCompact C ∧ C ⊆ H ∧ + ∀ g ∈ H, ∃ c ∈ C, c⁻¹ * g ∈ Γ + +variable [IsTopologicalGroup G] [T2Space G] + + +lemma isClosed_subset_lattice (Γ : Subgroup G) (hΓ : IsDiscrete (Γ : Set G)) + {S : Set G} (hS : S ⊆ Γ) : IsClosed S := by + let : DiscreteTopology Γ := isDiscrete_iff_discreteTopology.mp hΓ + have hc : IsClosed (Γ : Set G) := Subgroup.isClosed_of_discreteTopology + have he : Subtype.val '' (Subtype.val ⁻¹' S : Set Γ) = S := by + ext x + exact ⟨fun ⟨y,hy,he⟩ => he ▸ hy,fun hx => ⟨⟨x,hS hx⟩,hx,rfl⟩⟩ + rw [← he] + exact hc.isClosedEmbedding_subtypeVal.isClosedMap _ (isClosed_discrete _) + + + +lemma HasCompactReps.isClosed {H Γ : Subgroup G} + (h : HasCompactReps H Γ) (hΓ : IsDiscrete (Γ : Set G)) : IsClosed (H : Set G) := by + obtain ⟨C,hC,hCH,hr⟩ := h + have hE : IsClosed ((H : Set G) ∩ Γ) := isClosed_subset_lattice Γ hΓ + (fun _ hx => hx.2) + have he : (H : Set G) = C * ((H : Set G) ∩ Γ) := by + ext g + constructor + · intro hg + obtain ⟨c,hc,hcg⟩ := hr g hg + exact ⟨c,hc,c⁻¹*g,⟨H.mul_mem (H.inv_mem (hCH hc)) hg,hcg⟩,by simp⟩ + · rintro ⟨c,hc,e,he,rfl⟩ + exact H.mul_mem (hCH hc) he.1 + rw [he] + exact hE.mul_left_of_isCompact hC + + + +theorem HasCompactReps.discrete_map {N Γ : Subgroup G} [N.Normal] + (h : HasCompactReps N Γ) (hΓ : IsDiscrete (Γ : Set G)) : + DiscreteTopology (Γ.map (QuotientGroup.mk' N)) := by + obtain ⟨C,hC,hCN,hr⟩ := h + let F : Set G := (Γ : Set G) \ N + have hF : IsClosed F := isClosed_subset_lattice Γ hΓ (fun _ hx => hx.1) + let U : Set G := (F * C⁻¹)ᶜ + have hU : IsOpen U := (hF.mul_right_of_isCompact hC.inv).isOpen_compl + have h1U : (1:G) ∈ U := by + rintro ⟨x,hx,y,hy,he⟩ + have hxN : x ∈ N := by + have he' : x = y⁻¹ := (mul_eq_one_iff_eq_inv).mp he + rw [he'] + exact hCN hy + exact hx.2 hxN + let π : G →* G ⧸ N := QuotientGroup.mk' N + let L := Γ.map π + let V : Set (G ⧸ N) := π '' U + have hV : IsOpen V := QuotientGroup.isOpenMap_coe U hU + have h1V : (1:G ⧸ N) ∈ V := ⟨1,h1U,map_one π⟩ + have hev : ∀ z ∈ L, z ∈ V → z = 1 := by + rintro _ ⟨γ,hγ,rfl⟩ ⟨u,hu,heu⟩ + have huγ : u⁻¹*γ ∈ N := QuotientGroup.eq.mp heu + obtain ⟨c,hc,hcγ⟩ := hr _ huγ + let e := c⁻¹*(u⁻¹*γ) + have heΓ : e ∈ Γ := hcγ + have heN : e ∈ N := N.mul_mem (N.inv_mem (hCN hc)) huγ + have hγN : γ ∈ N := by + by_contra hγN + have hf : γ*e⁻¹ ∈ F := by + refine ⟨Γ.mul_mem hγ (Γ.inv_mem heΓ),?_⟩ + intro hn + exact hγN (by simpa [mul_assoc] using N.mul_mem hn heN) + apply hu + refine ⟨γ*e⁻¹,hf,c⁻¹,?_,?_⟩ + · simpa only [Set.mem_inv,inv_inv] using hc + · dsimp [e] + group + exact (QuotientGroup.eq_one_iff γ).mpr hγN + have hpre : Subtype.val ⁻¹' V = ({1} : Set L) := by + ext z + constructor + · intro hz + exact Subtype.ext (hev z z.property hz) + · intro hz + have hz' : z = 1 := hz + simpa [hz'] using h1V + apply discreteTopology_iff_isOpen_singleton_one.mpr + rw [← hpre] + exact hV.preimage continuous_subtype_val + +omit [IsTopologicalGroup G] [T2Space G] in + + +lemma HasCompactReps.quotient_compactSpace {Γ : Subgroup G} + (h : HasCompactReps ⊤ Γ) : CompactSpace (G ⧸ Γ) := by + obtain ⟨C,hC,_,hr⟩ := h + have he : QuotientGroup.mk (s := Γ) '' C = Set.univ := by + apply Set.eq_univ_of_forall + intro x + induction x using Quotient.inductionOn with | h x => + obtain ⟨c,hc,hcx⟩ := hr x (Subgroup.mem_top _) + exact ⟨c,hc,QuotientGroup.eq.mpr hcx⟩ + exact ⟨he ▸ hC.image QuotientGroup.continuous_mk⟩ + +omit [IsTopologicalGroup G] [T2Space G] in + + +lemma HasCompactReps.map_surjective {K : Type*} [Group K] [TopologicalSpace K] + {Γ : Subgroup G} (h : HasCompactReps ⊤ Γ) (φ : G →* K) + (hc : Continuous φ) (hs : Function.Surjective φ) : + HasCompactReps ⊤ (Γ.map φ) := by + obtain ⟨C,hC,_,hr⟩ := h + refine ⟨φ '' C,hC.image hc,Set.subset_univ _,?_⟩ + intro y _ + obtain ⟨x,rfl⟩ := hs y + obtain ⟨c,hc,hcx⟩ := hr x (Subgroup.mem_top _) + exact ⟨φ c,⟨c,hc,rfl⟩,⟨c⁻¹*x,hcx,by simp⟩⟩ + + + +theorem rational_normal_quotient (N Γ : Subgroup G) [N.Normal] + (hG : HasCompactReps ⊤ Γ) (hN : HasCompactReps N Γ) + (hΓ : IsDiscrete (Γ : Set G)) : + IsClosed (N : Set G) ∧ + DiscreteTopology (Γ.map (QuotientGroup.mk' N)) ∧ + CompactSpace ((G ⧸ N) ⧸ Γ.map (QuotientGroup.mk' N)) := by + refine ⟨hN.isClosed hΓ,hN.discrete_map hΓ,?_⟩ + exact (hG.map_surjective (QuotientGroup.mk' N) QuotientGroup.continuous_mk + (QuotientGroup.mk'_surjective N)).quotient_compactSpace + +end CompactGroupProducts + + + +open Topology Set +namespace CentralQuotientAction +variable {G : Type*} [Group G] (N Γ : Subgroup G) + +lemma central_kernel_normal (hN : N ≤ Subgroup.center G) : + (Γ.comap N.subtype).Normal := by + constructor + intro x hx n + change (n:G) * (x:G) * (n:G)⁻¹ ∈ Γ + rw [(Subgroup.mem_center_iff.mp (hN x.property) (n:G)),mul_assoc,mul_inv_cancel,mul_one] + exact hx + +lemma central_action_kernel (hN : N ≤ Subgroup.center G) : + Γ.comap N.subtype ≤ (MulAction.toPermHom N (G ⧸ Γ)).ker := by + intro n hn + apply Equiv.ext + intro x + induction x using Quotient.inductionOn with | h g => + change QuotientGroup.mk ((n:G)*g) = QuotientGroup.mk g + rw [← Subgroup.mem_center_iff.mp (hN n.property) g] + exact QuotientGroup.mk_mul_of_mem _ hn + +@[instance_reducible] +noncomputable def action (hN : N ≤ Subgroup.center G) + [(Γ.comap N.subtype).Normal] : MulAction (N ⧸ Γ.comap N.subtype) (G ⧸ Γ) := + MulAction.compHom _ (QuotientGroup.lift _ (MulAction.toPermHom N (G ⧸ Γ)) + (central_action_kernel N Γ hN)) + +theorem action_mk (hN : N ≤ Subgroup.center G) [(Γ.comap N.subtype).Normal] + (n : N) (x : G ⧸ Γ) : + letI := action N Γ hN + (QuotientGroup.mk n : N ⧸ Γ.comap N.subtype) • x = n • x := rfl + +variable [TopologicalSpace G] [IsTopologicalGroup G] + +lemma continuous_action (hN : N ≤ Subgroup.center G) [(Γ.comap N.subtype).Normal] : + letI := action N Γ hN + ContinuousSMul (N ⧸ Γ.comap N.subtype) (G ⧸ Γ) := by + let := action N Γ hN + constructor + have hq := (QuotientGroup.isOpenQuotientMap_mk (N := Γ.comap N.subtype)).prodMap + (IsOpenQuotientMap.id (X := G ⧸ Γ)) + apply hq.isQuotientMap.continuous_iff.mpr + change Continuous (fun z : N × (G ⧸ Γ) => (z.1:G) • z.2) + exact (continuous_subtype_val.comp continuous_fst).smul continuous_snd + +omit [IsTopologicalGroup G] in +lemma compact_central_quotient (h : CompactGroupProducts.HasCompactReps N Γ) : + CompactSpace (N ⧸ Γ.comap N.subtype) := by + obtain ⟨C,hC,hCN,hr⟩ := h + have hC' : IsCompact (Subtype.val ⁻¹' C : Set N) := by + apply IsInducing.subtypeVal.isCompact_iff.mpr + have he : Subtype.val '' (Subtype.val ⁻¹' C : Set N) = C := by + ext x + exact ⟨fun ⟨_,hx,e⟩ => e ▸ hx,fun hx => ⟨⟨x,hCN hx⟩,hx,rfl⟩⟩ + exact he.symm ▸ hC + apply CompactGroupProducts.HasCompactReps.quotient_compactSpace + refine ⟨Subtype.val ⁻¹' C,hC',fun _ _ => Subgroup.mem_top _,?_⟩ + intro n _ + obtain ⟨c,hc,hcn⟩ := hr n n.property + exact ⟨⟨c,hCN hc⟩,hc,hcn⟩ + +variable [N.Normal] + + + +omit [TopologicalSpace G] [IsTopologicalGroup G] in +theorem quotientMap_fibers (hN : N ≤ Subgroup.center G) + [(Γ.comap N.subtype).Normal] : + letI := action N Γ hN + ∀ x z : G ⧸ Γ, + RationalQuotientFunctions.quotientMap N Γ x = + RationalQuotientFunctions.quotientMap N Γ z → + ∃ k : N ⧸ Γ.comap N.subtype, k • x = z := by + let := action N Γ hN + intro x z + induction x using Quotient.inductionOn with | h g => + induction z using Quotient.inductionOn with | h h => + intro he + have hh : (QuotientGroup.mk' N g)⁻¹ * QuotientGroup.mk' N h ∈ + Γ.map (QuotientGroup.mk' N) := QuotientGroup.eq.mp he + obtain ⟨γ,hγ,heγ⟩ := hh + let n := g⁻¹*h*γ⁻¹ + have hn : n ∈ N := by + apply (QuotientGroup.eq_one_iff _).mp + change QuotientGroup.mk' N (g⁻¹*h*γ⁻¹) = 1 + simp only [map_mul,map_inv] + rw [← heγ,mul_inv_cancel] + refine ⟨QuotientGroup.mk (⟨n,hn⟩ : N),?_⟩ + change QuotientGroup.mk (n*g) = QuotientGroup.mk h + rw [← Subgroup.mem_center_iff.mp (hN hn) g] + have heq : g*n = h*γ⁻¹ := by dsimp [n]; group + rw [heq] + exact QuotientGroup.mk_mul_of_mem _ (Γ.inv_mem hγ) + +open MeasureTheory + + + +omit [TopologicalSpace G] [IsTopologicalGroup G] [N.Normal] in +lemma invariant_central_action (hN : N ≤ Subgroup.center G) + [(Γ.comap N.subtype).Normal] [MeasurableSpace (G ⧸ Γ)] + (μ : Measure (G ⧸ Γ)) [SMulInvariantMeasure G (G ⧸ Γ) μ] : + letI := action N Γ hN + SMulInvariantMeasure (N ⧸ Γ.comap N.subtype) (G ⧸ Γ) μ := by + let := action N Γ hN + constructor + intro k s hs + induction k using Quotient.inductionOn with | h n => + exact SMulInvariantMeasure.measure_preimage_smul (μ := μ) (n:G) hs + +omit [TopologicalSpace G] [IsTopologicalGroup G] in +lemma quotientMap_smul (g : G) (x : G ⧸ Γ) : + RationalQuotientFunctions.quotientMap N Γ (g • x) = + (QuotientGroup.mk' N g) • RationalQuotientFunctions.quotientMap N Γ x := by + induction x using Quotient.inductionOn with | h a => + change QuotientGroup.mk (QuotientGroup.mk' N (g*a)) = + QuotientGroup.mk (QuotientGroup.mk' N g * QuotientGroup.mk' N a) + rw [map_mul] + +lemma invariant_quotientMap [MeasurableSpace (G ⧸ Γ)] [BorelSpace (G ⧸ Γ)] + [MeasurableSpace ((G ⧸ N) ⧸ Γ.map (QuotientGroup.mk' N))] + [BorelSpace ((G ⧸ N) ⧸ Γ.map (QuotientGroup.mk' N))] + (μ : Measure (G ⧸ Γ)) [SMulInvariantMeasure G (G ⧸ Γ) μ] : + SMulInvariantMeasure (G ⧸ N) ((G ⧸ N) ⧸ Γ.map (QuotientGroup.mk' N)) + (Measure.map (RationalQuotientFunctions.quotientMap N Γ) μ) := by + constructor + intro g s hs + induction g using Quotient.inductionOn with | h g => + have hp := (RationalQuotientFunctions.continuous_quotientMap N Γ).measurable + rw [Measure.map_apply hp (hs.preimage (measurable_const_smul _)),Measure.map_apply hp hs] + have he : RationalQuotientFunctions.quotientMap N Γ ⁻¹' ((QuotientGroup.mk' N g • ·) ⁻¹' s) = + (g • ·) ⁻¹' (RationalQuotientFunctions.quotientMap N Γ ⁻¹' s) := by + ext x + simp only [Set.mem_preimage,quotientMap_smul] + change μ (RationalQuotientFunctions.quotientMap N Γ ⁻¹' + ((QuotientGroup.mk' N g • ·) ⁻¹' s)) = _ + rw [he] + exact SMulInvariantMeasure.measure_preimage_smul (μ := μ) g (hs.preimage hp) + +end CentralQuotientAction + + + +end +end +end +end + +end OAI diff --git a/lean/OAI/Combinatorics/SumProduct/Alignment/CharacterFactorization01.lean b/lean/OAI/Combinatorics/SumProduct/Alignment/CharacterFactorization01.lean new file mode 100644 index 0000000000000000000000000000000000000000..1c086ee89017929b28d69b5e41dd3bbd29d82b98 --- /dev/null +++ b/lean/OAI/Combinatorics/SumProduct/Alignment/CharacterFactorization01.lean @@ -0,0 +1,305 @@ +import Mathlib +import OAI.Combinatorics.SumProduct.Alignment.BinomialDifference01 +import OAI.Geometry.NilpotentCharts.Main + +namespace OAI + +section +section +section +section +open _root_.Polynomial _root_.OAI.Polynomial Finset +open scoped BigOperators +noncomputable section +end +end + + + +section +open scoped BigOperators commutatorElement +open _root_.Polynomial _root_.OAI.Polynomial +noncomputable section +namespace CharacterFactorization +open CubeFaces CubePolynomials RationalFactorPeriods RationalLattice MalcevCharacters MalcevTailFactor +open LeibmanSquare +variable {G : Type*} [Group G] [TopologicalSpace G] [IsTopologicalGroup G] [T2Space G] +variable (H : Filtration G) (h0 : H.level 0=⊤) {n s : ℕ} +variable (c : RealCoordinates (H.level 2) n) (hsk : SecondKind c) +variable (χ : H.level 2 →* Multiplicative ℝ) (k : Fin n → ℤ) +variable (hχ : ∀ x, (χ x).toAdd = IntegerHyperplane.form k (c.coord x)) +variable (r : Fin s → ℕ) +variable (hlevel : ∀ i (x : H.level 2), x.val ∈ H.level (i.val+2) ↔ + ∀ u : Fin n, u.val < r i → c.coord x u = 0) +variable (hcomm : ∀ a b : G, ⁅a,b⁆ ∈ χ.ker.map (H.level 2).subtype) + +include hsk hχ hlevel in + + +theorem factorization_from_monomial_bounds (hbot : H.level s=⊥) + (Γ : Subgroup G) (hΓ : ∀ x : H.level 2, x.val∈Γ ↔ ∀ i, ∃ z : ℤ, c.coord x i=z) + (d : ℕ) (A C : ℝ) (hC : 0 ≤ C) : + ∃ B > 0, ∃ T : ℕ, 0 (e z).val) ∈ polynomials H 0 ∧ + (fun z => (b z).val) ∈ polynomials H 0 ∧ + f' ∈ polynomials (H.refine (χ.ker.map (H.level 2).subtype) hcomm) 0 ∧ + Function.Periodic (fun z => (QuotientGroup.mk (b z).val : G ⧸ Γ)) (T:ℤ) ∧ + (∀ z : ℤ, |(z:ℝ)| ≤ A*L → ‖c.coord (e z)‖ ≤ B) ∧ + (∀ z w : ℤ, |(z:ℝ)| ≤ A*L → |(w:ℝ)| ≤ A*L → + ‖c.coord (e z*(e w)⁻¹)‖ ≤ (B/L)*|(z:ℝ)-(w:ℝ)|) := by + obtain ⟨B,hB,T,hT,hfactor⟩ := uniform_smooth_factorization H c hsk χ k hχ r hlevel hcomm + hbot Γ hΓ A (BinomialDifference.conversionBound d*C) + (mul_nonneg (BinomialDifference.conversionBound_pos d).le hC) + refine ⟨B,hB,T,hT,?_⟩ + intro L hL f hf hf0 hf1 P hP hPe hPc + obtain ⟨a,ha,he,hfac,he0,hep,hbp,hfp,hper,hsmooth⟩ := hfactor f + (cube_mem_of_polynomial H hf) hf0 hf1 + have hword (z : ℤ) : P.eval (z:ℝ)=(χ (orderedWord a (fun i => i.val+2) z)).toAdd := by + rw [hPe] + congr 2 + apply Subtype.ext + change f z*(f 1^z)⁻¹=(orderedWord a (fun i => i.val+2) z).val + rw [he z] + group + have hb : ∀ i, L^(i.val+2)*‖(beta χ a i : UnitAddCircle)‖ ≤ BinomialDifference.conversionBound d*C := + BinomialDifference.word_coefficient_bound χ a 2 d P hP hword L C hL hC (fun j hj => hPc j (by omega)) + obtain ⟨hv,hdiff⟩ := hsmooth L hL hb + refine ⟨(fun z => orderedWord (smallCoeff c χ k r a) (fun i => i.val+2) z), + (fun z => orderedWord (rationalCoeff c χ k r a) (fun i => i.val+2) z), + residual H c χ k r f a,hfac,?_,hep,hbp,hfp,hper,hv,hdiff⟩ + apply Subtype.ext + exact he0 + +end CharacterFactorization +end +end + + + +section +noncomputable section +open _root_.Polynomial _root_.OAI.Polynomial +open scoped BigOperators commutatorElement +namespace RealCharacters +variable {G : Type*} [Group G] +def intScale (χ : G →* Multiplicative ℝ) (q : ℤ) : G →* Multiplicative ℝ where + toFun x := Multiplicative.ofAdd ((q:ℝ)*(χ x).toAdd) + map_one' := by simp + map_mul' x y := by simp [mul_add] +@[simp] lemma intScale_apply (χ : G →* Multiplicative ℝ) (q : ℤ) (x : G) : + (intScale χ q x).toAdd=(q:ℝ)*(χ x).toAdd := rfl +lemma intScale_continuous [TopologicalSpace G] (χ : G →* Multiplicative ℝ) + (q : ℤ) (hχ : Continuous χ) : Continuous (intScale χ q) := by + change Continuous (fun x : G => (q:ℝ)*(χ x).toAdd) + exact continuous_const.mul (show Continuous (fun x => (χ x).toAdd) from hχ) +lemma intScale_ne_one (χ : G →* Multiplicative ℝ) {q : ℤ} (hq : q≠0) (hχ : χ≠1) : + intScale χ q≠1 := by + intro hh + apply hχ + apply MonoidHom.ext + intro x + apply Multiplicative.toAdd.injective + have hx := congrArg (fun f : G →* Multiplicative ℝ => (f x).toAdd) hh + change (q:ℝ)*(χ x).toAdd=0 at hx + simpa only [MonoidHom.one_apply,toAdd_one] using (mul_eq_zero.mp hx).resolve_left (Int.cast_ne_zero.mpr hq) +lemma intScale_integral (χ : G →* Multiplicative ℝ) (q : ℤ) (Γ : Subgroup G) + (hχ : ∀ g∈Γ, ∃ z : ℤ, (χ g).toAdd=z) : + ∀ g∈Γ, ∃ z : ℤ, (intScale χ q g).toAdd=z := by + intro g hg + obtain ⟨z,hz⟩ := hχ g hg + exact ⟨q*z,by simp only [intScale_apply,hz,Int.cast_mul]⟩ +lemma intScale_kernel (χ : G →* Multiplicative ℝ) {q : ℤ} (hq : q≠0) : + (intScale χ q).ker=χ.ker := by + ext x + constructor + · intro hx + apply Multiplicative.toAdd.injective + have hh:=congrArg Multiplicative.toAdd hx + change (q:ℝ)*(χ x).toAdd=0 at hh + exact (mul_eq_zero.mp hh).resolve_left (Int.cast_ne_zero.mpr hq) + · intro hx + change Multiplicative.ofAdd ((q:ℝ)*(χ x).toAdd)=1 + change χ x=1 at hx + simp [hx] +end RealCharacters + +namespace SquareHorizontalCharacter +open CubeFaces LeibmanSquare RealCharacters +variable {G : Type*} [Group G] [TopologicalSpace G] [IsTopologicalGroup G] +variable (H : Filtration G) (h0 : H.level 0=⊤) (h1 : H.level 1=⊤) +variable (ξ : level H h0 1 →* Multiplicative ℝ) +omit [IsTopologicalGroup G] in +lemma diagonal_continuous : Continuous (diagonal H h0 h1) := + (continuous_id.prodMk continuous_id).subtype_mk _ +omit [IsTopologicalGroup G] in +lemma lower_continuous : Continuous (lower H h0) := + (continuous_const.prodMk continuous_subtype_val).subtype_mk _ +omit [TopologicalSpace G] [IsTopologicalGroup G] in +lemma diagonal_integral (Γ : Subgroup G) + (hξ : ∀ x : level H h0 1, x.val∈Γ.prod Γ → ∃ z : ℤ, (ξ x).toAdd=z) : + ∀ g∈Γ, ∃ z : ℤ, ((ξ.comp (diagonal H h0 h1)) g).toAdd=z := by + intro g hg + exact hξ _ ⟨hg,hg⟩ +omit [TopologicalSpace G] [IsTopologicalGroup G] in +lemma lower_integral (Γ : Subgroup G) + (hξ : ∀ x : level H h0 1, x.val∈Γ.prod Γ → ∃ z : ℤ, (ξ x).toAdd=z) : + ∀ u : H.level 2, u.val∈Γ → ∃ z : ℤ, ((ξ.comp (lower H h0)) u).toAdd=z := by + intro u hu + exact hξ _ ⟨Γ.one_mem,hu⟩ +omit [TopologicalSpace G] [IsTopologicalGroup G] in +lemma lower_ne_one_of_diagonal (hξ : ξ≠1) (hd : ξ.comp (diagonal H h0 h1)=1) : + ξ.comp (lower H h0)≠1 := by + intro hl + apply hξ + ext x + rw [character_split H h0 h1 ξ x,hd,hl] + simp +omit [TopologicalSpace G] [IsTopologicalGroup G] in +lemma zero_pairing_kernel (q : ℤ) (hp : ∀ a b : G, pairing H h0 h1 ξ a b=1) : + ∀ a b : G, ⁅a,b⁆∈(intScale (ξ.comp (lower H h0)) q).ker.map (H.level 2).subtype := by + intro a b + refine ⟨⟨⁅a,b⁆,commutator_mem H h1 a b⟩,?_,rfl⟩ + change Multiplicative.ofAdd ((q:ℝ)*(pairing H h0 h1 ξ a b).toAdd)=1 + simp [hp] + +end SquareHorizontalCharacter + +namespace CharacterFactorization +open CubeFaces +variable {G : Type*} [Group G] +variable (H : Filtration G) (χ : H.level 2 →* Multiplicative ℝ) +lemma lower_kernel_le : χ.ker.map (H.level 2).subtype ≤ H.level 2 := by + rintro g ⟨u,hu,rfl⟩ + exact u.property +lemma lower_kernel_lt (hχ : χ≠1) : χ.ker.map (H.level 2).subtype < H.level 2 := by + refine lt_iff_le_not_ge.mpr ⟨lower_kernel_le H χ,?_⟩ + intro hh + apply hχ + apply MonoidHom.ext + intro u + obtain ⟨v,hv,hvu⟩ := hh u.property + have hvu' : v=u := Subtype.ext hvu + change χ u=1 + change χ v=1 at hv + simpa only [hvu'] using hv + +end CharacterFactorization +end +end + + + +section +open scoped BigOperators commutatorElement +open _root_.Polynomial _root_.OAI.Polynomial +noncomputable section +namespace CharacterFactorization +open CubeFaces CubePolynomials RationalLattice MalcevCharacters LeibmanSquare +variable {G : Type*} [Group G] [TopologicalSpace G] [IsTopologicalGroup G] [T2Space G] +variable (H : Filtration G) (Γ : Subgroup G) {n : ℕ} (c : RealCoordinates (H.level 2) n) + + + +def SmoothFactorizationAt (χ : H.level 2 →* Multiplicative ℝ) + (hcomm : ∀ a b : G, ⁅a,b⁆∈χ.ker.map (H.level 2).subtype) + (A B L : ℝ) (T : ℕ) (f : ℤ → G) : Prop := + ∃ e b : ℤ → H.level 2, ∃ f' : ℤ → G, + (∀ z, f z=(e z).val*f' z*(b z).val) ∧ e 0=1 ∧ + (fun z => (e z).val) ∈ polynomials H 0 ∧ + (fun z => (b z).val) ∈ polynomials H 0 ∧ + f' ∈ polynomials (H.refine (χ.ker.map (H.level 2).subtype) hcomm) 0 ∧ + Function.Periodic (fun z => (QuotientGroup.mk (b z).val : G ⧸ Γ)) (T:ℤ) ∧ + (∀ z : ℤ, |(z:ℝ)| ≤ A*L → ‖c.coord (e z)‖ ≤ B) ∧ + (∀ z w : ℤ, |(z:ℝ)| ≤ A*L → |(w:ℝ)| ≤ A*L → + ‖c.coord (e z*(e w)⁻¹)‖ ≤ (B/L)*|(z:ℝ)-(w:ℝ)|) + +omit [IsTopologicalGroup G] [T2Space G] in +lemma SmoothFactorizationAt.mono {χ : H.level 2 →* Multiplicative ℝ} + {hc : ∀ a b : G, ⁅a,b⁆∈χ.ker.map (H.level 2).subtype} + {A B B' L : ℝ} {T : ℕ} {f : ℤ → G} (hL : 0 ≤ L) (hB : B ≤ B') + (h : SmoothFactorizationAt H Γ c χ hc A B L T f) : + SmoothFactorizationAt H Γ c χ hc A B' L T f := by + obtain ⟨e,b,f',he,he0,hep,hbp,hfp,hper,hv,hd⟩ := h + refine ⟨e,b,f',he,he0,hep,hbp,hfp,hper,fun z hz => (hv z hz).trans hB,?_⟩ + intro z w hz hw + exact (hd z w hz hw).trans (mul_le_mul_of_nonneg_right + (div_le_div_of_nonneg_right hB hL) (abs_nonneg _)) + +variable (h0 : H.level 0=⊤) (hsk : SecondKind c) +variable (hΓ : ∀ x : H.level 2, x.val∈Γ ↔ ∀ i, ∃ z : ℤ, c.coord x i=z) +variable {s : ℕ} (hbot : H.level s=⊥) (r : Fin s → ℕ) +variable (hlevel : ∀ i (x : H.level 2), x.val∈H.level (i.val+2) ↔ + ∀ u : Fin n, u.val hfac⟩ + · exact ⟨1,by norm_num,1,by norm_num,fun hc' => (hc hc').elim⟩ + choose B hB T hT hfac using hindividual + let Bsum : ℝ := 1+∑ χ : {χ // χ∈Ξ}, B χ + let Tmax : ℕ := 1+∑ χ : {χ // χ∈Ξ}, T χ + have hBsum : 0 (hB χ).le) + change 0 < 1+∑ χ : {χ // χ∈Ξ}, B χ + linarith + refine ⟨Bsum,hBsum,Tmax,by change 0 < 1+∑ χ : {χ // χ∈Ξ}, T χ; omega,?_⟩ + intro χ hχ hc L hL f hf hf0 hf1 P hP hPe hPc + let j : {χ // χ∈Ξ} := ⟨χ,hχ⟩ + have hBB : B j ≤ Bsum := by + have hh := Finset.single_le_sum (fun χ (_ : χ∈Finset.univ) => (hB χ).le) (Finset.mem_univ j) + change B j ≤ 1+∑ χ : {χ // χ∈Ξ}, B χ + linarith + have hTT : T j ≤ Tmax := by + have hh := Finset.single_le_sum (fun χ (_ : χ∈Finset.univ) => Nat.zero_le (T χ)) (Finset.mem_univ j) + change T j ≤ 1+∑ χ : {χ // χ∈Ξ}, T χ + omega + exact ⟨T j,hT j,hTT,(hfac j hc L hL f hf hf0 hf1 P hP hPe hPc).mono H Γ c + (zero_le_one.trans hL) hBB⟩ + +end CharacterFactorization + +end +end +end +end +end + +end OAI diff --git a/lean/OAI/Combinatorics/SumProduct/Alignment/CoefficientPeeling01.lean b/lean/OAI/Combinatorics/SumProduct/Alignment/CoefficientPeeling01.lean new file mode 100644 index 0000000000000000000000000000000000000000..4eaef9df5b7e494645562434a7af5155e15bce8a --- /dev/null +++ b/lean/OAI/Combinatorics/SumProduct/Alignment/CoefficientPeeling01.lean @@ -0,0 +1,333 @@ +import Mathlib +import OAI.Combinatorics.SumProduct.Alignment.DenseRough01 +import OAI.Geometry.NilpotentCharts.Main + +namespace OAI + +section +section +open _root_.Polynomial _root_.OAI.Polynomial Finset +open scoped BigOperators +open _root_.Polynomial _root_.OAI.Polynomial +noncomputable section +open _root_.Polynomial _root_.OAI.Polynomial Filter +open scoped Topology +namespace CoefficientPeeling +open scoped BigOperators +open Finset _root_.Polynomial _root_.OAI.Polynomial +noncomputable section + + +def NearInteger (x ε : ℝ) : Prop := ∃ n : ℤ, |x-(n : ℝ)| ≤ ε + +lemma NearInteger.mul_nat {x ε : ℝ} (h : NearInteger x ε) (t : ℕ) : + NearInteger ((t : ℝ)*x) ((t : ℝ)*ε) := by + obtain ⟨n,hn⟩ := h + refine ⟨(t : ℤ)*n, ?_⟩ + simpa only [Int.cast_mul, Int.cast_natCast, ← mul_sub, abs_mul, + abs_of_nonneg (Nat.cast_nonneg (α := ℝ) t)] using + (mul_le_mul_of_nonneg_left hn (Nat.cast_nonneg t)) + +lemma NearInteger.mono {x ε ε' : ℝ} (h : NearInteger x ε) (hh : ε ≤ ε') : + NearInteger x ε' := by + obtain ⟨n,hn⟩ := h + exact ⟨n,hn.trans hh⟩ + + + +lemma tail_term_bound {e j : ℕ} (hej : e ≤ j) {p Z A C x : ℝ} + (hp : 0 ≤ p) (hZ : 0 < Z) (hpZ : p ≤ Z) (hA : 0 ≤ A) (hC : 0 ≤ C) + (hx : |x| *Z^j ≤ A) {b : ℝ} (hb : |b| ≤ C*p^(j-e)) : + |p^e*b*x| ≤ C*A*(p/Z)^e := by + have hpow : p^(j-e) ≤ Z^(j-e) := pow_le_pow_left₀ hp hpZ _ + calc + |p^e*b*x| = p^e*|b| *|x| := by rw [abs_mul, abs_mul, abs_of_nonneg (pow_nonneg hp _)] + _ ≤ p^e*(C*p^(j-e))*(A/Z^j) := by + apply mul_le_mul + · exact mul_le_mul_of_nonneg_left hb (pow_nonneg hp _) + · exact (le_div_iff₀ (pow_pos hZ _)).mpr hx + · exact abs_nonneg _ + · positivity + _ ≤ p^e*(C*Z^(j-e))*(A/Z^j) := by gcongr + _ = C*A*(p/Z)^e := by + rw [div_pow] + have hz : Z^j = Z^e*Z^(j-e) := by rw [← pow_add, Nat.add_sub_of_le hej] + rw [hz] + field_simp + + + +theorem peel {ι : Type*} [DecidableEq ι] (s : Finset ι) (degree : ι → ℕ) + (e : ℕ) (he : ∀ j ∈ s, e ≤ degree j) (p : ℕ) {Z A A₀ : ℝ} + (hZ : 0 < Z) (hpZ : (p : ℝ) ≤ Z) (hA : 0 ≤ A) + (θ : ℝ) (θj : ι → ℝ) (m : ι → ℤ) (c : ι → ℤ) (C : ι → ℝ) + (hC : ∀ j ∈ s, 0 ≤ C j) + (hc : ∀ j ∈ s, |(c j : ℝ)| ≤ C j*(p : ℝ)^(degree j-e)) + (hθ : ∀ j ∈ s, |θj j-(m j : ℝ)| *Z^(degree j) ≤ A) + (ho : NearInteger ((p : ℝ)^e*(θ+∑ j ∈ s, (c j : ℝ)*θj j)) + (A₀*((p : ℝ)/Z)^e)) : + NearInteger ((p : ℝ)^e*θ) ((A₀+(∑ j ∈ s, C j)*A)*((p : ℝ)/Z)^e) := by + obtain ⟨n,hn⟩ := ho + refine ⟨n-(p : ℤ)^e*∑ j ∈ s, c j*m j, ?_⟩ + have htail : |∑ j ∈ s, (p : ℝ)^e*(c j : ℝ)*(θj j-(m j : ℝ))| ≤ + ((∑ j ∈ s, C j)*A)*((p : ℝ)/Z)^e := by + calc + _ ≤ ∑ j ∈ s, |(p : ℝ)^e*(c j : ℝ)*(θj j-(m j : ℝ))| := abs_sum_le_sum_abs _ _ + _ ≤ ∑ j ∈ s, C j*A*((p : ℝ)/Z)^e := sum_le_sum fun j hj => + tail_term_bound (he j hj) (Nat.cast_nonneg p) hZ hpZ hA (hC j hj) + (hθ j hj) (hc j hj) + _ = _ := by simp only [← sum_mul] + have hid : (p : ℝ)^e*θ - + ((n-(p : ℤ)^e*∑ j ∈ s, c j*m j : ℤ) : ℝ) = + ((p : ℝ)^e*(θ+∑ j ∈ s, (c j : ℝ)*θj j)-(n : ℝ)) - + ∑ j ∈ s, (p : ℝ)^e*(c j : ℝ)*(θj j-(m j : ℝ)) := by + simp only [Int.cast_sub, Int.cast_mul, Int.cast_pow, Int.cast_natCast, + Int.cast_sum, mul_sub, sum_sub_distrib, mul_assoc, ← mul_sum] + ring + rw [hid] + exact (abs_sub _ _).trans (by nlinarith [hn, htail]) + + + +theorem unit_or_rough {t p e : ℕ} {θ A Z : ℝ} (_hZ : Z ≠ 0) + (hp : p = 1 ∨ p = t) + (ho : NearInteger ((p : ℝ)^e*θ) (A*((p : ℝ)/Z)^e)) : + NearInteger ((t : ℝ)^e*θ) (A*((t : ℝ)/Z)^e) := by + rcases hp with rfl | rfl + · have h := ho.mul_nat (t^e) + simp only [Nat.cast_one, one_pow, one_mul, Nat.cast_pow] at h + convert h using 1 + rw [div_pow, one_div_pow] + ring + · exact ho + + +lemma affine_coefficient (f : ℝ[X]) (b p : ℤ) (e : ℕ) : + (f.comp (Polynomial.C (p : ℝ)*Polynomial.X+Polynomial.C (b : ℝ))).coeff e = + (p : ℝ)^e * ∑ j ∈ f.support, (j.choose e : ℝ)*f.coeff j*(b : ℝ)^(j-e) := by + have hid : f.comp (Polynomial.C (p : ℝ)*Polynomial.X+Polynomial.C (b : ℝ)) = + (Polynomial.taylor (b : ℝ) f).comp (Polynomial.C (p : ℝ)*Polynomial.X) := by + rw [Polynomial.taylor_apply, Polynomial.comp_assoc] + simp only [Polynomial.add_comp, Polynomial.X_comp, Polynomial.C_comp] + rw [hid, Polynomial.comp_C_mul_X_coeff, Polynomial.taylor_coeff, + Polynomial.hasseDeriv_apply, Polynomial.eval_sum, Polynomial.sum_def] + simp only [Polynomial.eval_monomial] + exact mul_comm _ _ + +end +end CoefficientPeeling + +namespace PositiveCoefficientDescent +open scoped BigOperators +open _root_.Polynomial _root_.OAI.Polynomial Finset Filter RoughInterpolation RoughScales DenseRoughInterpolation +open DenseRoughScaleCompletion CoefficientPeeling +noncomputable section +variable {ι : Type*} [Fintype ι] [DecidableEq ι] + + + +structure Input (degree : ι → ℕ) (N q w : ℕ) (S Z α A₀ C₀ : ℝ) where + E : Finset ℤ + in_interval : ∀ z ∈ E, 0 ≤ z ∧ z ≤ N + enough_nodes : 2*(q+1) ≤ E.card + dense : α*N ≤ E.card + a : ℤ + b : ℤ + positive_step : 0 < b + smooth_step : Smooth w b + scale : ∀ z : ℤ, 0 ≤ z → z ≤ N → S ≤ (a+b*z : ℤ) ∧ + ((a+b*z : ℤ) : ℝ) < 2*S + rough : ∀ z ∈ E, Rough w (a+b*z) + θ : ι → ℝ[X] + polynomial_degree : ∀ i, ((Polynomial.C (a : ℝ)+Polynomial.C (b : ℝ)*X)^degree i*θ i).natDegree ≤ q + p : ℤ → ℕ + steps : ∀ z ∈ E, p z = 1 ∨ p z = (a+b*z).natAbs + c : ι → ι → ℤ → ℤ + residue_bound : ∀ i j z, z ∈ E → degree i < degree j → + |(c i j z : ℝ)| ≤ C₀*(p z : ℝ)^(degree j-degree i) + obstruction : ∀ i z, z ∈ E → NearInteger + ((p z : ℝ)^degree i * ((θ i).eval (z : ℝ)+ + ∑ j ∈ univ.filter (fun j => degree i < degree j), (c i j z : ℝ)*(θ j).eval (z : ℝ))) + (A₀*((p z : ℝ)/Z)^degree i) + + +def Controlled (q w e : ℕ) (N : ℕ) (E : Finset ℤ) (Z B : ℝ) (θ : ℝ[X]) (M : ℚ[X]) : Prop := + M.natDegree ≤ q-e ∧ + (∀ j p : ℕ, p.Prime → p ∣ (M.coeff j).den → p ≤ w) ∧ + (∀ z ∈ E, Integral (M.eval (z : ℚ))) ∧ + ∀ z : ℤ, 0 ≤ z → z ≤ N → + |θ.eval (z : ℝ)-(M.map (algebraMap ℚ ℝ)).eval (z : ℝ)| *Z^e ≤ B + +lemma Controlled.mono {q w e N : ℕ} {E : Finset ℤ} {Z B B' : ℝ} + {θ : ℝ[X]} {M : ℚ[X]} (h : Controlled q w e N E Z B θ M) (hB : B ≤ B') : + Controlled q w e N E Z B' θ M := + ⟨h.1,h.2.1,h.2.2.1,fun z hz hzN => (h.2.2.2 z hz hzN).trans hB⟩ + +omit [DecidableEq ι] in +lemma step_cast {degree : ι → ℕ} {N q w : ℕ} {S Z α A₀ C₀ : ℝ} + (d : Input degree N q w S Z α A₀ C₀) (hS : 0 ≤ S) + {z : ℤ} (hz : z ∈ d.E) : + ((d.a+d.b*z).natAbs : ℝ) = ((d.a+d.b*z : ℤ) : ℝ) := by + have h := (d.scale z (d.in_interval z hz).1 (d.in_interval z hz).2).1 + have ht : (0 : ℝ) ≤ ((d.a+d.b*z : ℤ) : ℝ) := hS.trans h + simp only [Nat.cast_natAbs, Int.cast_abs, abs_of_nonneg ht] + +omit [DecidableEq ι] in +lemma sample_le {degree : ι → ℕ} {N q w : ℕ} {S Z α A₀ C₀ : ℝ} + (d : Input degree N q w S Z α A₀ C₀) (hS : 1 ≤ S) (hSZ : 2*S ≤ Z) + {z : ℤ} (hz : z ∈ d.E) : (d.p z : ℝ) ≤ Z := by + rcases d.steps z hz with hp | hp + · rw [hp, Nat.cast_one]; linarith + · rw [hp, step_cast d (by linarith) hz] + exact ((d.scale z (d.in_interval z hz).1 (d.in_interval z hz).2).2.le).trans hSZ + + + +theorem eventual_rational_coefficients (degree : ι → ℕ) (D q : ℕ) + (hdeg : ∀ i, 1 ≤ degree i ∧ degree i ≤ D) (hDq : D ≤ q) + {α A₀ C₀ : ℝ} (hα : 0 < α) (hA₀ : 0 < A₀) (hC₀ : 0 ≤ C₀) + {w : ℕ → ℕ} {S Z : ℕ → ℝ} + (hw : Tendsto w atTop atTop) (hS : Tendsto S atTop atTop) + (hZ : ∀ k : ℕ, Tendsto (fun n => Z n/S n^k) atTop atTop) : + ∃ B : ℝ, 1 ≤ B ∧ ∀ N : ℕ, 0 < N → + ∀ᶠ n in atTop, ∀ d : Input degree N q (w n) (S n) (Z n) α A₀ C₀, + ∃ M : ι → ℚ[X], ∀ i, Controlled q (w n) (degree i) N d.E (Z n) B (d.θ i) (M i) := by + let K := uniformBound q α + have hK : 0 ≤ K := by dsimp [K, uniformBound]; positivity + let J : ℝ := (Fintype.card ι : ℝ)*C₀ + have hJ : 0 ≤ J := by dsimp [J]; positivity + let β : ℝ := max 1 (K*2^D*(A₀+J)) + have hβ : 1 ≤ β := le_max_left _ _ + have hβ₀ : 0 < β := lt_of_lt_of_le zero_lt_one hβ + have hβK : K*2^D*(A₀+J) ≤ β := le_max_right _ _ + have hconst (k : ℕ) : 0 < 2^D*(A₀+J*β^k) := by positivity + have hbound (k : ℕ) : K*(2^D*(A₀+J*β^k)) ≤ β^(k+1) := by + have hb1 : 1 ≤ β^k := one_le_pow₀ hβ + have hAA : A₀+J*β^k ≤ (A₀+J)*β^k := by nlinarith + calc + _ ≤ (K*2^D*(A₀+J))*β^k := by nlinarith [mul_le_mul_of_nonneg_left hAA (show 0 ≤ K*2^D by positivity)] + _ ≤ β*β^k := mul_le_mul_of_nonneg_right hβK (by positivity) + _ = _ := by rw [pow_succ]; ring + refine ⟨β^D, one_le_pow₀ hβ, ?_⟩ + intro N hN + have hscale : ∀ᶠ n in atTop, 1 ≤ S n ∧ 0 < Z n ∧ 2*S n ≤ Z n := by + filter_upwards [hS.eventually (eventually_ge_atTop (1 : ℝ)), + (hZ 1).eventually (eventually_ge_atTop (2 : ℝ))] with n hnS hnZ + have hs : 0 < S n := by linarith + simp only [pow_one] at hnZ + have hh : 2*S n ≤ Z n := (le_div_iff₀ hs).mp hnZ + exact ⟨hnS,by linarith,hh⟩ + have hstage (k : ℕ) (hk : k ≤ D) : + ∀ᶠ n in atTop, ∀ d : Input degree N q (w n) (S n) (Z n) α A₀ C₀, + ∃ M : ι → ℚ[X], ∀ i, D-k < degree i → + Controlled q (w n) (degree i) N d.E (Z n) (β^k) (d.θ i) (M i) := by + induction k with + | zero => + exact Filter.Eventually.of_forall fun n d => ⟨fun _ => 0, fun i hi => by + have := (hdeg i).2; omega⟩ + | succ k ih => + have hkD : k < D := by omega + have he : 1 ≤ D-k := by omega + have heq : D-k ≤ q := by omega + have hprev := ih (by omega) + have hex := DenseRoughScaleCompletion.eventually_exact_division he heq hN hα + (hconst k) hw hS hZ + filter_upwards [hprev,hex,hscale] with n hnprev hnex hnscale + intro d + have hnS : 1 ≤ S n := hnscale.1 + have hnZ : 0 < Z n := hnscale.2.1 + obtain ⟨M, hM⟩ := hnprev d + have hlocal (i : ι) : ∃ M' : ℚ[X], D-(k+1) < degree i → + Controlled q (w n) (degree i) N d.E (Z n) (β^(k+1)) (d.θ i) M' := by + by_cases hhi : D-k < degree i + · refine ⟨M i, fun _ => (hM i hhi).mono ?_⟩ + exact pow_le_pow_right₀ hβ (by omega) + by_cases hnew : D-(k+1) < degree i + · have hei : degree i = D-k := by omega + let T : Finset ι := univ.filter (fun j => degree i < degree j) + have hT (j : ι) (hj : j ∈ T) : D-k < degree j := by + have := (mem_filter.mp hj).2 + omega + have hnear (z : ℤ) (hz : z ∈ d.E) : ∃ v : ℤ, + |(((Polynomial.C (d.a : ℝ)+Polynomial.C (d.b : ℝ)*X)^(D-k)*d.θ i).eval (z : ℝ))-(v : ℝ)| ≤ + (2^D*(A₀+J*β^k))*(S n/Z n)^(D-k) := by + have him (j : ι) : ∃ v : ℤ, j ∈ T → + (v : ℚ) = (M j).eval (z : ℚ) := by + by_cases hj : j ∈ T + · obtain ⟨v,hv⟩ := (hM j (hT j hj)).2.2.1 z hz + exact ⟨v, fun _ => hv⟩ + · exact ⟨0, fun h => (hj h).elim⟩ + choose m hm using him + have herr (j : ι) (hj : j ∈ T) : + |(d.θ j).eval (z : ℝ)-(m j : ℝ)| * Z n^degree j ≤ β^k := by + have hcast : (m j : ℝ) = ((M j).map (algebraMap ℚ ℝ)).eval (z : ℝ) := by + have hv := congrArg (algebraMap ℚ ℝ) (hm j hj) + have heval : ((M j).map (algebraMap ℚ ℝ)).eval (z : ℝ) = + (((M j).eval (z : ℚ) : ℚ) : ℝ) := by + rw [eval_map] + simpa only [eq_ratCast, Rat.cast_intCast] using + (eval₂_at_apply (p := M j) (algebraMap ℚ ℝ) (z : ℚ)) + rw [heval] + simpa only [eq_ratCast, Rat.cast_intCast] using hv + rw [hcast] + exact (hM j (hT j hj)).2.2.2 z (d.in_interval z hz).1 (d.in_interval z hz).2 + have hp := peel T degree (degree i) (fun j hj => + (mem_filter.mp hj).2.le) (d.p z) hnscale.2.1 + (sample_le d hnscale.1 hnscale.2.2 hz) (by positivity : 0 ≤ β^k) + ((d.θ i).eval (z : ℝ)) (fun j => (d.θ j).eval (z : ℝ)) m + (fun j => d.c i j z) (fun _ => C₀) (fun _ _ => hC₀) + (fun j hj => d.residue_bound i j z hz (mem_filter.mp hj).2) herr (d.obstruction i z hz) + have hTJ : (∑ j ∈ T, C₀) ≤ J := by + simp only [sum_const, nsmul_eq_mul] + exact mul_le_mul_of_nonneg_right (Nat.cast_le.mpr (T.card_le_univ)) hC₀ + have hp' := hp.mono (show + (A₀+(∑ j ∈ T, C₀)*β^k)*((d.p z : ℝ)/Z n)^degree i ≤ + (A₀+J*β^k)*((d.p z : ℝ)/Z n)^degree i by gcongr) + have ht := unit_or_rough (ne_of_gt hnscale.2.1) (d.steps z hz) hp' + have hstep := step_cast d (by linarith [hnscale.1]) hz + have hscalez := d.scale z (d.in_interval z hz).1 (d.in_interval z hz).2 + have hpowe : (((d.a+d.b*z).natAbs : ℝ)/Z n)^degree i ≤ + 2^D*(S n/Z n)^degree i := by + calc + _ ≤ (2*S n/Z n)^degree i := by + apply pow_le_pow_left₀ (by positivity) + exact div_le_div_of_nonneg_right (by rw [hstep]; exact hscalez.2.le) (le_of_lt hnscale.2.1) + _ = 2^degree i*(S n/Z n)^degree i := by rw [mul_div_assoc, mul_pow] + _ ≤ _ := by + apply mul_le_mul_of_nonneg_right _ (by positivity) + exact pow_le_pow_right₀ (by norm_num) (hdeg i).2 + have ht' := ht.mono (show + (A₀+J*β^k)*(((d.a+d.b*z).natAbs : ℝ)/Z n)^degree i ≤ + (2^D*(A₀+J*β^k))*(S n/Z n)^degree i by + nlinarith [mul_le_mul_of_nonneg_left hpowe (show 0 ≤ A₀+J*β^k by positivity)]) + obtain ⟨v,hv⟩ := ht' + refine ⟨v, ?_⟩ + simpa only [Polynomial.eval_mul, Polynomial.eval_pow, Polynomial.eval_add, + Polynomial.eval_C, Polynomial.eval_X, hstep, Int.cast_add, Int.cast_mul, hei] using hv + obtain ⟨M',hM'deg,hM'sm,hM'int,hM'err⟩ := hnex d.E d.in_interval d.enough_nodes d.dense + d.a d.b (d.θ i) d.positive_step d.smooth_step d.scale d.rough + (by simpa only [hei] using d.polynomial_degree i) hnear + refine ⟨M',fun _ => ?_⟩ + refine ⟨by simpa only [hei] using hM'deg,hM'sm,hM'int,?_⟩ + intro z hz hzN + have hh := (mul_le_mul_of_nonneg_right (hM'err z hz hzN) + (show 0 ≤ Z n^(D-k) by positivity)).trans_eq + (show (uniformBound q α * (2^D*(A₀+J*β^k))/Z n^(D-k))*Z n^(D-k) = + K*(2^D*(A₀+J*β^k)) by dsimp only [K]; field_simp [ne_of_gt hnZ]) + simpa only [hei] using hh.trans (hbound k) + · exact ⟨0, fun h => (hnew h).elim⟩ + choose M' hM' using hlocal + exact ⟨M',hM'⟩ + filter_upwards [hstage D le_rfl] with n hn + intro d + obtain ⟨M,hM⟩ := hn d + exact ⟨M,fun i => hM i (by have := (hdeg i).1; omega)⟩ + +end +end PositiveCoefficientDescent + +end +end +end + +end OAI diff --git a/lean/OAI/Combinatorics/SumProduct/Alignment/CompactConvex01.lean b/lean/OAI/Combinatorics/SumProduct/Alignment/CompactConvex01.lean new file mode 100644 index 0000000000000000000000000000000000000000..59e67341703e599af1e43446a3222abdbcacc6b3 --- /dev/null +++ b/lean/OAI/Combinatorics/SumProduct/Alignment/CompactConvex01.lean @@ -0,0 +1,351 @@ +import Mathlib +import OAI.Combinatorics.SumProduct.Alignment.CentralFiber01 +import OAI.Geometry.NilpotentCharts.Main + +namespace OAI + +section +section +section +section +open Topology +open scoped Pointwise +open Topology Set +open MeasureTheory Set Topology +open MeasureTheory Topology Set + + + +namespace CompactConvexFixedPoint +open Set Filter Topology +open scoped BigOperators + +variable {E : Type*} [AddCommGroup E] [Module ℝ E] [TopologicalSpace E] + [IsTopologicalAddGroup E] [ContinuousSMul ℝ E] [T2Space E] + +noncomputable def average (T : E →L[ℝ] E) (x : E) (n : ℕ) : E := + ((n+1 : ℝ)⁻¹) • ∑ i ∈ Finset.range (n+1), T^[i] x + +omit [IsTopologicalAddGroup E] [ContinuousSMul ℝ E] [T2Space E] in +lemma average_mem (T : E →L[ℝ] E) {C : Set E} (hc : Convex ℝ C) + (hT : MapsTo T C C) {x : E} (hx : x ∈ C) (n : ℕ) : average T x n ∈ C := by + have hi : ∀ i, T^[i] x ∈ C := by + intro i + induction i with + | zero => simpa using hx + | succ i ih => simpa only [Function.iterate_succ_apply'] using hT ih + have hsum : ∑ _i ∈ Finset.range (n+1), (n+1 : ℝ)⁻¹ = 1 := by + simp [mul_inv_cancel₀ (show (n+1 : ℝ) ≠ 0 by positivity)] + simpa only [average, Finset.smul_sum] using hc.sum_mem + (fun i _ => inv_nonneg.mpr (by positivity : (0:ℝ) ≤ n+1)) hsum (fun i _ => hi i) + +omit [IsTopologicalAddGroup E] [ContinuousSMul ℝ E] [T2Space E] in +lemma average_difference (T : E →L[ℝ] E) (x : E) (n : ℕ) : + T (average T x n) - average T x n = + (n+1 : ℝ)⁻¹ • (T^[n+1] x - x) := by + simp only [average, map_smul, map_sum, ← smul_sub, ← Finset.sum_sub_distrib] + have h : ∀ i, T (T^[i] x) = T^[i+1] x := fun i => + (Function.iterate_succ_apply' T i x).symm + simp_rw [h] + rw [Finset.sum_range_sub (fun i => T^[i] x) (n+1)] + rfl + + + +theorem exists_fixed (T : E →L[ℝ] E) {C : Set E} (hk : IsCompact C) + (hc : Convex ℝ C) (hne : C.Nonempty) (hT : MapsTo T C C) : + ∃ x ∈ C, T x = x := by + obtain ⟨x,hx⟩ := hne + have hi : ∀ n, T^[n] x ∈ C := by + intro n + induction n with + | zero => simpa using hx + | succ n ih => simpa only [Function.iterate_succ_apply'] using hT ih + let u : Ultrafilter ℕ := Ultrafilter.of atTop + let f : ℕ → E × E := fun n => (average T x n, T^[n+1] x) + have hm : (u.map f : Filter (E×E)) ≤ 𝓟 (C ×ˢ C) := by + rw [Ultrafilter.coe_map, Filter.map_le_iff_le_comap,Filter.comap_principal] + exact Filter.le_principal_iff.mpr (Eventually.of_forall fun n => + ⟨average_mem T hc hT hx n, hi (n+1)⟩) + obtain ⟨z,hz,hlim⟩ := (hk.prod hk).ultrafilter_le_nhds (u.map f) hm + change Tendsto f (u : Filter ℕ) (𝓝 z) at hlim + have ha : Tendsto (average T x) (u : Filter ℕ) (𝓝 z.1) := + (continuous_fst.tendsto z).comp hlim + have hb : Tendsto (fun n => T^[n+1] x - x) (u : Filter ℕ) (𝓝 (z.2-x)) := + ((continuous_snd.tendsto z).comp hlim).sub_const x + have hz0 : Tendsto (fun n : ℕ => (n+1 : ℝ)⁻¹) (u : Filter ℕ) (𝓝 0) := by + simpa only [one_div] using + (tendsto_one_div_add_atTop_nhds_zero_nat (𝕜 := ℝ)).mono_left + (Ultrafilter.of_le atTop) + have hdiff : Tendsto (fun n => T (average T x n) - average T x n) + (u : Filter ℕ) (𝓝 (0:E)) := by + simpa only [average_difference,zero_smul] using hz0.smul hb + have ht := (T.continuous.tendsto z.1).comp ha + have he : T z.1 - z.1 = 0 := tendsto_nhds_unique (ht.sub ha) hdiff + exact ⟨z.1,hz.1,sub_eq_zero.mp he⟩ + + + +theorem exists_common_fixed {ι : Type*} (T : ι → E →L[ℝ] E) {C : Set E} + (hk : IsCompact C) (hc : Convex ℝ C) (hne : C.Nonempty) + (hT : ∀ i, MapsTo (T i) C C) + (hcomm : ∀ i j x, x ∈ C → T i (T j x) = T j (T i x)) : + ∃ x ∈ C, ∀ i, T i x = x := by + classical + let F : ι → Set E := fun i => {x | T i x = x} + have hclosed : ∀ i, IsClosed (F i) := fun i => + isClosed_eq (T i).continuous continuous_id + have hfinite : ∀ s : Finset ι, (C ∩ ⋂ i ∈ s, F i).Nonempty := by + intro s + induction s using Finset.induction_on with + | empty => simpa using hne + | @insert i s his ih => + let S := C ∩ ⋂ j ∈ s, F j + have hsk : IsCompact S := hk.inter_right (isClosed_iInter fun j => isClosed_iInter fun _ => hclosed j) + have hsc : Convex ℝ S := by + intro x hx y hy a b ha hb hab + refine ⟨hc hx.1 hy.1 ha hb hab, ?_⟩ + simp only [S,mem_inter_iff,mem_iInter,F,mem_ofPred_eq] at hx + simp only [S,mem_inter_iff,mem_iInter,F,mem_ofPred_eq] at hy + simp only [mem_iInter] + intro j hj + change T j (a • x + b • y) = a • x + b • y + simp only [map_add,map_smul,hx.2 j hj,hy.2 j hj] + have hsi : MapsTo (T i) S S := by + intro x hx + refine ⟨hT i hx.1,?_⟩ + simp only [S,mem_inter_iff,mem_iInter,F,mem_ofPred_eq] at hx + simp only [mem_iInter] + intro j hj + change T j (T i x) = T i x + rw [hcomm j i x hx.1,hx.2 j hj] + obtain ⟨x,hxs,hxi⟩ := exists_fixed (T i) hsk hsc ih hsi + refine ⟨x,hxs.1,?_⟩ + simp only [S,mem_inter_iff,mem_iInter,F,mem_ofPred_eq] at hxs + simp only [mem_iInter] + intro j hj + rcases Finset.mem_insert.mp hj with rfl|hj + · exact hxi + · exact hxs.2 j hj + obtain ⟨x,hx,hfix⟩ := hk.inter_iInter_nonempty F hclosed hfinite + exact ⟨x,hx,fun i => mem_iInter.mp hfix i⟩ + +variable {G : Type*} [Group G] + +def fixedSet (ρ : G →* (E →L[ℝ] E)) (C : Set E) (H : Subgroup G) : Set E := + {x | x ∈ C ∧ ∀ g ∈ H, ρ g x = x} + +omit [ContinuousSMul ℝ E] in +lemma fixedSet_compact (ρ : G →* (E →L[ℝ] E)) {C : Set E} (hk : IsCompact C) + (H : Subgroup G) : IsCompact (fixedSet ρ C H) := by + have he : fixedSet ρ C H = C ∩ ⋂ g ∈ H, {x | ρ g x = x} := by + ext x; simp [fixedSet] + rw [he] + apply hk.inter_right + exact isClosed_iInter fun g => isClosed_iInter fun _ => + isClosed_eq (ρ g).continuous continuous_id + +omit [ContinuousSMul ℝ E] [T2Space E] in +lemma fixedSet_convex (ρ : G →* (E →L[ℝ] E)) {C : Set E} (hc : Convex ℝ C) + (H : Subgroup G) : Convex ℝ (fixedSet ρ C H) := by + intro x hx y hy a b ha hb hab + refine ⟨hc hx.1 hy.1 ha hb hab, ?_⟩ + intro g hg + simp only [map_add,map_smul,hx.2 g hg,hy.2 g hg] + +omit [ContinuousSMul ℝ E] [T2Space E] in +lemma fixedSet_invariant (ρ : G →* (E →L[ℝ] E)) {C : Set E} + (hρ : ∀ g, MapsTo (ρ g) C C) (N : Subgroup G) [N.Normal] (g : G) : + MapsTo (ρ g) (fixedSet ρ C N) (fixedSet ρ C N) := by + intro x hx + refine ⟨hρ g hx.1, ?_⟩ + intro h hh + have hi : g⁻¹*h*g ∈ N := (inferInstance : N.Normal).conj_mem' h hh g + have he : h*g = g*(g⁻¹*h*g) := by group + calc + ρ h (ρ g x) = ρ (h*g) x := by simp only [map_mul,mul_apply_eq_comp] + _ = ρ (g*(g⁻¹*h*g)) x := congrArg (fun a => ρ a x) he + _ = ρ g x := by rw [map_mul,mul_apply_eq_comp,hx.2 _ hi] + +lemma fixedSet_step (ρ : G →* (E →L[ℝ] E)) {C : Set E} + (hk : IsCompact C) (hc : Convex ℝ C) (hρ : ∀ g, MapsTo (ρ g) C C) + (H N : Subgroup G) [N.Normal] (hHN : ⁅H,H⁆ ≤ N) + (hne : (fixedSet ρ C N).Nonempty) : (fixedSet ρ C H).Nonempty := by + have hcomm : ∀ (a b : H) x, x ∈ fixedSet ρ C N → + ρ a (ρ b x) = ρ b (ρ a x) := by + intro a b x hx + let c : G := a.val⁻¹*b.val⁻¹*a.val*b.val + have hcm : c ∈ N := by + apply hHN + simpa only [commutatorElement_def,inv_inv] using + Subgroup.commutator_mem_commutator (H.inv_mem a.property) (H.inv_mem b.property) + have he : a.val*b.val = (b.val*a.val)*c := by dsimp [c]; group + calc + ρ a (ρ b x) = ρ (a.val*b.val) x := by simp only [map_mul,mul_apply_eq_comp] + _ = ρ ((b.val*a.val)*c) x := congrArg (fun z => ρ z x) he + _ = ρ b (ρ a x) := by + simp only [map_mul,mul_apply_eq_comp] + rw [hx.2 c hcm] + obtain ⟨x,hx,hfix⟩ := exists_common_fixed (fun g : H => ρ g) + (fixedSet_compact ρ hk N) (fixedSet_convex ρ hc N) hne + (fun g => fixedSet_invariant ρ hρ N g) hcomm + exact ⟨x,hx.1,fun g hg => hfix ⟨g,hg⟩⟩ + + + +theorem exists_solvable_fixed [Group.IsSolvable G] (ρ : G →* (E →L[ℝ] E)) + {C : Set E} (hk : IsCompact C) (hc : Convex ℝ C) (hne : C.Nonempty) + (hρ : ∀ g, MapsTo (ρ g) C C) : ∃ x ∈ C, ∀ g, ρ g x = x := by + obtain ⟨n,hn⟩ := Group.IsSolvable.solvable (G := G) + have hdown : ∀ k, (fixedSet ρ C (derivedSeries G k)).Nonempty → + (fixedSet ρ C (derivedSeries G 0)).Nonempty := by + intro k + induction k with + | zero => exact id + | succ k ih => + intro h + apply ih + exact fixedSet_step ρ hk hc hρ (derivedSeries G k) (derivedSeries G (k+1)) + (by rw [derivedSeries_succ]) h + have hstart : (fixedSet ρ C (derivedSeries G n)).Nonempty := by + obtain ⟨x,hx⟩ := hne + refine ⟨x,hx,?_⟩ + intro g hg + rw [hn,Subgroup.mem_bot] at hg + subst g + simp + obtain ⟨x,hx,hfix⟩ := hdown n hstart + exact ⟨x,hx,fun g => hfix g (by simp)⟩ + +end CompactConvexFixedPoint + +namespace SolvableInvariantMeasure +open Set MeasureTheory Topology + +variable {X : Type*} [TopologicalSpace X] [CompactSpace X] [T2Space X] + [MeasurableSpace X] [BorelSpace X] + +noncomputable def evaluations (μ : ProbabilityMeasure X) : C(X,ℝ) → ℝ := + fun f => ∫ x, f x ∂(μ : Measure X) + +omit [T2Space X] in +lemma continuous_evaluations : Continuous (evaluations (X := X)) := by + apply continuous_pi + intro f + exact ProbabilityMeasure.continuous_integral_continuousMap f + +lemma compact_evaluations : IsCompact (range (evaluations (X := X))) := + isCompact_range continuous_evaluations + +omit [T2Space X] in +lemma convex_evaluations : Convex ℝ (range (evaluations (X := X))) := by + intro v hv w hw a b ha hb hab + obtain ⟨μ,rfl⟩ := hv + obtain ⟨ν,rfl⟩ := hw + let θ : Measure X := ENNReal.ofReal a • (μ : Measure X) + ENNReal.ofReal b • (ν : Measure X) + have hθ : IsProbabilityMeasure θ := by + constructor + simp only [θ,Measure.add_apply,Measure.smul_apply,measure_univ,smul_eq_mul,mul_one] + rw [← ENNReal.ofReal_add ha hb,hab,ENNReal.ofReal_one] + refine ⟨⟨θ,hθ⟩,?_⟩ + ext f + change (∫ x, f x ∂θ) = a * (∫ x, f x ∂(μ : Measure X)) + + b * (∫ x, f x ∂(ν : Measure X)) + dsimp [θ] + rw [integral_add_measure,integral_smul_measure,integral_smul_measure] + · simp only [ENNReal.toReal_ofReal ha,ENNReal.toReal_ofReal hb,smul_eq_mul] + · exact (f.continuous.integrable_of_hasCompactSupport (HasCompactSupport.of_compactSpace f)).smul_measure + ENNReal.ofReal_ne_top + · exact (f.continuous.integrable_of_hasCompactSupport (HasCompactSupport.of_compactSpace f)).smul_measure + ENNReal.ofReal_ne_top + +variable {G : Type*} [Group G] [MulAction G X] [ContinuousConstSMul G X] + + + +noncomputable def pushRep : G →* ((C(X,ℝ) → ℝ) →L[ℝ] (C(X,ℝ) → ℝ)) where + toFun g := ContinuousLinearMap.pi fun f => + ContinuousLinearMap.proj (f.comp ⟨(g • ·),continuous_const_smul g⟩) + map_one' := by + ext L f + change L (f.comp ⟨((1:G) • ·),continuous_const_smul (1:G)⟩) = L f + congr 1 + ext x + simp + map_mul' g h := by + ext L f + change L (f.comp ⟨((g*h) • ·),continuous_const_smul (g*h)⟩) = + L ((f.comp ⟨(g • ·),continuous_const_smul g⟩).comp + ⟨(h • ·),continuous_const_smul h⟩) + congr 1 + ext x + simp [mul_smul] + +omit [CompactSpace X] [T2Space X] in +lemma pushRep_evaluations (g : G) (μ : ProbabilityMeasure X) : + pushRep g (evaluations μ) = + evaluations (μ.map (g • ·)) := by + ext f + change (∫ x, f (g • x) ∂(μ : Measure X)) = + ∫ x, f x ∂(Measure.map (g • ·) (μ : Measure X)) + exact (integral_map (measurable_const_smul g).aemeasurable f.continuous.aestronglyMeasurable).symm + + + +theorem exists_invariant_integrals [Group.IsSolvable G] [Nonempty X] : + ∃ μ : ProbabilityMeasure X, ∀ (g : G) (f : C(X,ℝ)), + (∫ x, f (g • x) ∂(μ : Measure X)) = ∫ x, f x ∂(μ : Measure X) := by + have hne : (range (evaluations (X := X))).Nonempty := by + obtain ⟨x⟩ := ‹Nonempty X› + exact ⟨evaluations ⟨Measure.dirac x,inferInstance⟩,mem_range_self _⟩ + have hm : ∀ g : G, MapsTo (pushRep g) (range (evaluations (X := X))) + (range evaluations) := by + intro g v hv + obtain ⟨μ,rfl⟩ := hv + rw [pushRep_evaluations] + exact mem_range_self _ + obtain ⟨v,⟨μ,rfl⟩,hfix⟩ := CompactConvexFixedPoint.exists_solvable_fixed + (pushRep (G := G) (X := X)) compact_evaluations convex_evaluations hne hm + exact ⟨μ,fun g f => congrFun (hfix g) f⟩ + + + +theorem exists_invariant_measure [Group.IsSolvable G] [Nonempty X] + [HasOuterApproxClosed X] : + ∃ μ : ProbabilityMeasure X, SMulInvariantMeasure G X (μ : Measure X) := by + obtain ⟨μ,hμ⟩ := exists_invariant_integrals (G := G) (X := X) + refine ⟨μ,⟨?_⟩⟩ + intro g s hs + let ν := μ.map (g • ·) + have he : ν.toFiniteMeasure = μ.toFiniteMeasure := by + apply FiniteMeasure.ext_of_forall_integral_eq + intro f + change (∫ x, f x ∂Measure.map (g • ·) (μ : Measure X)) = + ∫ x, f x ∂(μ : Measure X) + rw [integral_map (measurable_const_smul g).aemeasurable f.continuous.aestronglyMeasurable] + exact hμ g f.toContinuousMap + have he' : Measure.map (g • ·) (μ : Measure X) = (μ : Measure X) := + congrArg (fun m : FiniteMeasure X => (m : Measure X)) he + rw [← Measure.map_apply (measurable_const_smul g) hs,he'] + + + +theorem exists_invariant_fullSupport [Group.IsSolvable G] [Nonempty X] + [HasOuterApproxClosed X] [MulAction.IsMinimal G X] : + ∃ μ : ProbabilityMeasure X, SMulInvariantMeasure G X (μ : Measure X) ∧ + (μ : Measure X).IsOpenPosMeasure := by + obtain ⟨μ,hμ⟩ := exists_invariant_measure (G := G) (X := X) + let := hμ + refine ⟨μ,hμ,⟨?_⟩⟩ + intro U hU hne + exact ne_of_gt (measure_isOpen_pos_of_smulInvariant_of_compact_ne_zero G + isCompact_univ (by simp) hU hne) + +end SolvableInvariantMeasure + +end +end +end +end + +end OAI diff --git a/lean/OAI/Combinatorics/SumProduct/Alignment/CompactFamily01.lean b/lean/OAI/Combinatorics/SumProduct/Alignment/CompactFamily01.lean new file mode 100644 index 0000000000000000000000000000000000000000..c5999673c1e781412567da196820cc6f3ef47340 --- /dev/null +++ b/lean/OAI/Combinatorics/SumProduct/Alignment/CompactFamily01.lean @@ -0,0 +1,301 @@ +import Mathlib +import OAI.Combinatorics.SumProduct.Alignment.LeibmanSquare04 +import OAI.Geometry.NilpotentCharts.Main + +namespace OAI + +section +section +section +section +open scoped commutatorElement Pointwise +namespace CompactFamilyDescent +open Set Topology +noncomputable section + + + +theorem finite_tests_of_dense_span {E ι : Type*} [NormedAddCommGroup E] + [NormedSpace ℂ E] (v : ι → E) + (hv : (Submodule.span ℂ (Set.range v)).topologicalClosure = ⊤) + (K : Set E) (hK : IsCompact K) (δ B : ℝ) (hδ : 0 < δ) (hB : 0 < B) : + ∃ S : Finset ι, ∃ η : ℝ, 0 < η ∧ + ∀ L : E →ₗ[ℂ] ℂ, (∀ f, ‖L f‖ ≤ B * ‖f‖) → + (∃ f ∈ K, δ ≤ ‖L f‖) → ∃ i ∈ S, η ≤ ‖L (v i)‖ := by + classical + let ε := δ / (4 * B) + have hε : 0 < ε := by dsimp [ε]; positivity + have happ (f : E) : ∃ c : ι →₀ ℂ, dist f (c.sum fun i a => a • v i) < ε := by + have hf : f ∈ closure (Submodule.span ℂ (Set.range v) : Set E) := by + rw [← Submodule.topologicalClosure_coe, hv] + trivial + obtain ⟨g, hg, hfg⟩ := Metric.mem_closure_iff.mp hf ε hε + obtain ⟨c, rfl⟩ := Finsupp.mem_span_range_iff_exists_finsupp.mp hg + exact ⟨c, hfg⟩ + choose c hc using happ + let P : E → E := fun f => (c f).sum fun i a => a • v i + obtain ⟨t, ht⟩ := hK.elim_finite_subcover (fun f => Metric.ball (P f) ε) + (fun _ => Metric.isOpen_ball) (by + intro f _ + exact Set.mem_iUnion.mpr ⟨f, hc f⟩) + let H := 1 + ∑ f ∈ t, ∑ i ∈ (c f).support, ‖c f i‖ + have hH : 0 < H := by + dsimp [H] + positivity + let η := δ / (4 * H) + have hη : 0 < η := by dsimp [η]; positivity + refine ⟨t.biUnion (fun f => (c f).support), η, hη, ?_⟩ + intro L hL ⟨f, hf, hlarge⟩ + obtain ⟨g, hg, hfg⟩ := Set.mem_iUnion₂.mp (ht hf) + have hfg' : dist f (P g) < ε := hfg + by_contra hno + push Not at hno + have hPg : ‖L (P g)‖ ≤ H * η := by + calc + _ = ‖∑ i ∈ (c g).support, (c g i) • L (v i)‖ := by + simp [P, Finsupp.sum, map_sum] + _ ≤ ∑ i ∈ (c g).support, ‖c g i‖ * ‖L (v i)‖ := by + simpa only [norm_smul] using norm_sum_le (c g).support (fun i => c g i • L (v i)) + _ ≤ ∑ i ∈ (c g).support, ‖c g i‖ * η := by + apply Finset.sum_le_sum + intro i hi + apply mul_le_mul_of_nonneg_left _ (norm_nonneg _) + exact (hno i (Finset.mem_biUnion.mpr ⟨g, hg, hi⟩)).le + _ = (∑ i ∈ (c g).support, ‖c g i‖) * η := by rw [Finset.sum_mul] + _ ≤ H * η := by + apply mul_le_mul_of_nonneg_right _ hη.le + have hsum := Finset.single_le_sum (f := fun x => ∑ i ∈ (c x).support, ‖c x i‖) (fun x (_ : x ∈ t) => + Finset.sum_nonneg (fun i _ => norm_nonneg (c x i))) hg + dsimp [H] + linarith only [hsum] + have hdist : ‖L (f - P g)‖ < B * ε := by + calc + _ ≤ B * ‖f - P g‖ := hL _ + _ < B * ε := mul_lt_mul_of_pos_left (by simpa only [dist_eq_norm] using hfg') hB + have hsum := norm_add_le (L (f - P g)) (L (P g)) + rw [← map_add, sub_add_cancel] at hsum + have he₁ : B * ε = δ / 4 := by dsimp [ε]; field_simp + have he₂ : H * η = δ / 4 := by dsimp [η]; field_simp + rw [he₁] at hdist + rw [he₂] at hPg + linarith + +variable {X Y P : Type*} + + + +theorem continuous_family_descent [TopologicalSpace X] [TopologicalSpace Y] + [TopologicalSpace P] {q : X → Y} (hq : IsOpenQuotientMap q) + (F : P → C(Y, ℂ)) + (hF : Continuous (fun p : P × X => F p.1 (q p.2))) : + Continuous (fun p : P × Y => F p.1 p.2) := by + exact (IsOpenQuotientMap.id.prodMap hq).continuous_comp_iff.mp hF + + + +theorem continuous_family_map [TopologicalSpace X] [TopologicalSpace Y] + [TopologicalSpace P] [LocallyCompactSpace Y] + {q : X → Y} (hq : IsOpenQuotientMap q) (F : P → C(Y, ℂ)) + (hF : Continuous (fun p : P × X => F p.1 (q p.2))) : Continuous F := by + exact (ContinuousMap.curry ⟨_,continuous_family_descent hq F hF⟩).continuous + + + +theorem compact_descended_family [TopologicalSpace X] [TopologicalSpace Y] + [TopologicalSpace P] [LocallyCompactSpace Y] + {q : X → Y} (hq : IsOpenQuotientMap q) (F : P → C(Y, ℂ)) + (hF : Continuous (fun p : P × X => F p.1 (q p.2))) + (K : Set P) (hK : IsCompact K) : IsCompact (F '' K) := + hK.image (continuous_family_map hq F hF) + +section Lipschitz +variable [MetricSpace Y] [CompactSpace Y] + +def lipschitzMaps : Set C(Y,ℂ) := {F | ∃ C : NNReal, LipschitzWith C F} + +lemma lipschitz_mul (F G : C(Y,ℂ)) {C D : NNReal} + (hF : LipschitzWith C F) (hG : LipschitzWith D G) : + LipschitzWith (‖F‖₊ * D + ‖G‖₊ * C) (F*G) := by + apply LipschitzWith.of_dist_le_mul + intro x y + change dist (F x * G x) (F y * G y) ≤ _ + calc + _ = ‖F x * (G x-G y) + (F x-F y) * G y‖ := by + rw [dist_eq_norm]; congr 1; ring + _ ≤ ‖F x‖ * ‖G x-G y‖ + ‖F x-F y‖ * ‖G y‖ := by + simpa only [norm_mul] using norm_add_le (F x * (G x-G y)) ((F x-F y) * G y) + _ ≤ ‖F‖ * (D * dist x y) + (C * dist x y) * ‖G‖ := by + apply add_le_add + · exact mul_le_mul (F.norm_coe_le_norm x) + (by simpa only [dist_eq_norm] using hG.dist_le_mul x y) (norm_nonneg _) (norm_nonneg _) + · exact mul_le_mul (by simpa only [dist_eq_norm] using hF.dist_le_mul x y) + (G.norm_coe_le_norm y) (norm_nonneg _) (by positivity) + _ = _ := by simp only [NNReal.coe_add,NNReal.coe_mul,coe_nnnorm]; ring + + +def lipAlgebra : StarSubalgebra ℂ C(Y,ℂ) where + carrier := lipschitzMaps + zero_mem' := ⟨0,LipschitzWith.const 0⟩ + add_mem' := by + rintro f g ⟨C,hf⟩ ⟨D,hg⟩ + exact ⟨C+D,hf.add hg⟩ + one_mem' := ⟨0,LipschitzWith.const 1⟩ + mul_mem' := by + rintro f g ⟨C,hf⟩ ⟨D,hg⟩ + exact ⟨_,lipschitz_mul f g hf hg⟩ + algebraMap_mem' z := ⟨0,LipschitzWith.const z⟩ + star_mem' := by + rintro f ⟨C,hf⟩ + refine ⟨C,LipschitzWith.of_dist_le_mul ?_⟩ + intro x y + simpa only [ContinuousMap.star_apply,dist_star_star] using hf.dist_le_mul x y + +lemma lipAlgebra_separates : (lipAlgebra (Y := Y)).SeparatesPoints := by + intro x y hxy + let F : C(Y,ℂ) := ⟨fun z => (dist z x : ℂ),by fun_prop⟩ + have hl : LipschitzWith 1 F := by + simpa only [one_mul,F,ContinuousMap.coe_mk,Function.comp_def] using! + Complex.isometry_ofReal.lipschitzWith.comp (LipschitzWith.dist_left x) + refine ⟨_,⟨F,⟨1,hl⟩,rfl⟩,?_⟩ + intro h + have hc : (0 : ℂ) = (dist y x : ℂ) := by + simpa only [F,ContinuousMap.coe_mk,dist_self,Complex.ofReal_zero] using h + exact hxy (dist_eq_zero.mp (Complex.ofReal_eq_zero.mp hc.symm)).symm + +theorem lipschitzMaps_dense : + (Submodule.span ℂ (lipschitzMaps (Y := Y))).topologicalClosure = ⊤ := by + have hs : Submodule.span ℂ (lipschitzMaps (Y := Y)) = + (lipAlgebra (Y := Y)).toSubalgebra.toSubmodule := by + change Submodule.span ℂ ((lipAlgebra (Y := Y)).toSubalgebra.toSubmodule : Set C(Y,ℂ)) = _ + exact Submodule.span_eq ((lipAlgebra (Y := Y)).toSubalgebra.toSubmodule) + rw [hs] + exact congrArg (Subalgebra.toSubmodule ∘ StarSubalgebra.toSubalgebra) + (ContinuousMap.starSubalgebra_topologicalClosure_eq_top_of_separatesPoints + (lipAlgebra (Y := Y)) lipAlgebra_separates) + + + +theorem finite_lipschitz_obstruction (K : Set C(Y,ℂ)) (hK : IsCompact K) + (δ B : ℝ) (hδ : 0 < δ) (hB : 0 < B) : + ∃ S : Finset {F : C(Y,ℂ) // F ∈ lipschitzMaps}, ∃ η : ℝ, 0 < η ∧ + ∀ L : C(Y,ℂ) →ₗ[ℂ] ℂ, (∀ F, ‖L F‖ ≤ B * ‖F‖) → + (∃ F ∈ K, δ ≤ ‖L F‖) → ∃ F ∈ S, η ≤ ‖L F.val‖ := by + apply finite_tests_of_dense_span _ ?_ K hK δ B hδ hB + simpa only [Subtype.range_coe_subtype,Set.ofPred_mem_eq] using + (lipschitzMaps_dense (Y := Y)) + +end Lipschitz +end +end CompactFamilyDescent + +namespace UniformSquareObservable +open CubeFaces LeibmanSquare RationalQuotientFunctions CompactFamilyDescent Topology +noncomputable section +variable {G : Type*} [Group G] [TopologicalSpace G] [IsTopologicalGroup G] +variable (H : Filtration G) (h0 : H.level 0 = ⊤) (Γ : Subgroup G) + (s : ℕ) (hs0 : 1 ≤ s) (hs : H.level (s+1) = ⊥) + +abbrev ReducedSpace := + letI := last_normal H h0 hs0 hs + ((level H h0 1) ⧸ (restricted H h0).level s) ⧸ + ((Γ.prod Γ).comap (level H h0 1).subtype).map + (QuotientGroup.mk' ((restricted H h0).level s)) + +def reducedProjection (x : level H h0 1) : ReducedSpace H h0 Γ s hs0 hs := by + letI := last_normal H h0 hs0 hs + exact QuotientGroup.mk (QuotientGroup.mk' ((restricted H h0).level s) x) + + +def observable (F : C(G ⧸ Γ,ℂ)) (χ : G → ℂ) + (hχ : ∀ n ∈ H.level s, ‖χ n‖ = 1) + (hw : ∀ n ∈ H.level s, ∀ x : G, + F (QuotientGroup.mk (x*n)) = χ n * F (QuotientGroup.mk x)) + (p : G × G) : C(ReducedSpace H h0 Γ s hs0 hs,ℂ) := by + letI := last_normal H h0 hs0 hs + exact { + toFun := normalDescend ((restricted H h0).level s) + ((Γ.prod Γ).comap (level H h0 1).subtype) + (balanced H h0 Γ F p.1 p.2) + (balanced_last H h0 Γ F p.1 p.2 s hs0 hs χ hχ hw) + (balanced_lattice H h0 Γ F p.1 p.2) + continuous_toFun := continuous_normalDescend _ _ _ _ _ + (continuous_balanced H h0 Γ F p.1 p.2) } + +@[simp] lemma observable_apply (F : C(G ⧸ Γ,ℂ)) (χ : G → ℂ) + (hχ : ∀ n ∈ H.level s, ‖χ n‖ = 1) + (hw : ∀ n ∈ H.level s, ∀ x : G, + F (QuotientGroup.mk (x*n)) = χ n * F (QuotientGroup.mk x)) + (p : G × G) (x : level H h0 1) : + observable H h0 Γ s hs0 hs F χ hχ hw p + (reducedProjection H h0 Γ s hs0 hs x) = + F (QuotientGroup.mk (p.1*x.val.1)) * star (F (QuotientGroup.mk (p.2*x.val.2))) := rfl + + + +theorem continuous_observable [LocallyCompactSpace (ReducedSpace H h0 Γ s hs0 hs)] + (F : C(G ⧸ Γ,ℂ)) (χ : G → ℂ) + (hχ : ∀ n ∈ H.level s, ‖χ n‖ = 1) + (hw : ∀ n ∈ H.level s, ∀ x : G, + F (QuotientGroup.mk (x*n)) = χ n * F (QuotientGroup.mk x)) : + Continuous (observable H h0 Γ s hs0 hs F χ hχ hw) := by + let := last_normal H h0 hs0 hs + let N := (restricted H h0).level s + let L := (Γ.prod Γ).comap (level H h0 1).subtype + let q : level H h0 1 → ReducedSpace H h0 Γ s hs0 hs := + fun x => QuotientGroup.mk (QuotientGroup.mk' N x) + have hq : IsOpenQuotientMap q := + QuotientGroup.isOpenQuotientMap_mk.comp QuotientGroup.isOpenQuotientMap_mk + apply continuous_family_map hq + change Continuous (fun p : (G × G) × level H h0 1 => + F (QuotientGroup.mk (p.1.1*p.2.val.1)) * + star (F (QuotientGroup.mk (p.1.2*p.2.val.2)))) + exact (F.continuous.comp (QuotientGroup.continuous_mk.comp + ((continuous_fst.fst).mul (continuous_fst.comp (continuous_subtype_val.comp continuous_snd))))).mul + (continuous_star.comp (F.continuous.comp (QuotientGroup.continuous_mk.comp + ((continuous_fst.snd).mul (continuous_snd.comp (continuous_subtype_val.comp continuous_snd)))))) + + + +theorem compact_observable_family [LocallyCompactSpace (ReducedSpace H h0 Γ s hs0 hs)] + (F : C(G ⧸ Γ,ℂ)) (χ : G → ℂ) + (hχ : ∀ n ∈ H.level s, ‖χ n‖ = 1) + (hw : ∀ n ∈ H.level s, ∀ x : G, + F (QuotientGroup.mk (x*n)) = χ n * F (QuotientGroup.mk x)) + (C : Set G) (hC : IsCompact C) : + IsCompact (observable H h0 Γ s hs0 hs F χ hχ hw '' (C ×ˢ C)) := + (hC.prod hC).image (continuous_observable H h0 Γ s hs0 hs F χ hχ hw) + + + +theorem finite_square_tests [TopologicalSpace.MetrizableSpace (ReducedSpace H h0 Γ s hs0 hs)] + [CompactSpace (ReducedSpace H h0 Γ s hs0 hs)] + (F : C(G ⧸ Γ,ℂ)) (χ : G → ℂ) + (hχ : ∀ n ∈ H.level s, ‖χ n‖ = 1) + (hw : ∀ n ∈ H.level s, ∀ x : G, + F (QuotientGroup.mk (x*n)) = χ n * F (QuotientGroup.mk x)) + (C : Set G) (hC : IsCompact C) (δ B : ℝ) (hδ : 0 < δ) (hB : 0 < B) : + letI := TopologicalSpace.metrizableSpaceMetric (ReducedSpace H h0 Γ s hs0 hs) + ∃ S : Finset {f : C(ReducedSpace H h0 Γ s hs0 hs,ℂ) // + f ∈ lipschitzMaps (Y := ReducedSpace H h0 Γ s hs0 hs)}, + ∃ η : ℝ, 0 < η ∧ + ∀ L : C(ReducedSpace H h0 Γ s hs0 hs,ℂ) →ₗ[ℂ] ℂ, + (∀ f, ‖L f‖ ≤ B * ‖f‖) → + (∃ a ∈ C, ∃ b ∈ C, + δ ≤ ‖L (observable H h0 Γ s hs0 hs F χ hχ hw (a,b))‖) → + ∃ f ∈ S, η ≤ ‖L f.val‖ := by + let := TopologicalSpace.metrizableSpaceMetric (ReducedSpace H h0 Γ s hs0 hs) + obtain ⟨S,η,hη,hS⟩ := finite_lipschitz_obstruction _ + (compact_observable_family H h0 Γ s hs0 hs F χ hχ hw C hC) δ B hδ hB + refine ⟨S,η,hη,?_⟩ + intro L hL ⟨a,ha,b,hb,hab⟩ + exact hS L hL ⟨_,⟨(a,b),⟨ha,hb⟩,rfl⟩,hab⟩ + +end +end UniformSquareObservable + +end +end +end +end + +end OAI diff --git a/lean/OAI/Combinatorics/SumProduct/Alignment/ComparableBox01.lean b/lean/OAI/Combinatorics/SumProduct/Alignment/ComparableBox01.lean new file mode 100644 index 0000000000000000000000000000000000000000..0b8cbb2627d9231d03fc07c980b2cdb9f919098f --- /dev/null +++ b/lean/OAI/Combinatorics/SumProduct/Alignment/ComparableBox01.lean @@ -0,0 +1,311 @@ +import Mathlib +import OAI.Combinatorics.SumProduct.Alignment.CorrectedBox05 +import OAI.Geometry.NilpotentCharts.Main + +namespace OAI + +section +section +section +section +noncomputable section +open scoped BigOperators +end +end + + + +section +noncomputable section +open _root_.Polynomial _root_.OAI.Polynomial +open scoped BigOperators +namespace CorrectedBoxLeibman +open CubeFaces CubePolynomials LeibmanSquare RationalLattice MalcevCharacters +open MeasureTheory PolynomialWeyl AbelianMalcevTorus RationalTailCoordinates UnitAddTorus +variable {G : Type} [Group G] [TopologicalSpace G] [IsTopologicalGroup G] +variable {t d : ℕ} (c : RealCoordinates G (t+d)) (hsk : SecondKind c) +variable (H : Filtration G) (h0 : H.level 0=⊤) (h1 : H.level 1=⊤) +variable [∀ i, (H.level i).Normal] +variable (s : ℕ) (hs : H.level (s+1)=⊥) +variable (q : ℕ→ℕ) (hqbound : ∀ k, q k ≤ t+d) (hq2 : q 2=t) +variable (hq : ∀ k (g : G), g∈H.level k ↔ ∀ i : Fin (t+d), i.val F (QuotientGroup.mk (f (fun i => (x i:ℤ)))))-(∫ y,F y ∂μ)‖) → + ∃ ξ∈U, ξ≠1 ∧ Continuous ξ ∧ (∀ g∈Γ, ∃ z : ℤ, (ξ g).toAdd=z) ∧ + ∃ b : Fin (t+d)→ℤ, b≠0 ∧ (∀ i, |(b i:ℝ)|≤A) ∧ + (∀ a b : G, ξ (a*b*a⁻¹*b⁻¹)=1) ∧ + (∀ g : G, (ξ g).toAdd=∑ i, c.coord g i*(b i:ℝ)) ∧ + ∃ α : Grid v s→ℝ, (∀ x, (ξ (f x)).toAdd=binomialGridEval α x) ∧ + (∀ I, s Finset.sum_nonneg (fun i _ => abs_nonneg _)) + let A : ℝ := 1+S+tensorConversionBound v s*C + have hconv : 0 |(ξ (axis c j 1)).toAdd|) (fun j _ => abs_nonneg _) (Finset.mem_univ i) + have h2 : (∑ j, |(ξ (axis c j 1)).toAdd|)≤S := + Finset.single_le_sum (f := fun χ : G→*Multiplicative ℝ => ∑ j, |(χ (axis c j 1)).toAdd|) (fun χ _ => Finset.sum_nonneg (fun j _ => abs_nonneg _)) hξ + rw [hbi] + dsimp [A] + linarith + · intro a b + apply Multiplicative.toAdd.injective + simp only [map_mul,map_inv,toAdd_mul,toAdd_inv] + change (ξ a).toAdd+(ξ b).toAdd+(-(ξ a).toAdd)+(-(ξ b).toAdd)=0 + ring + · intro x + rw [← ha x,tensor_newton_expansion] + · intro I hI + have hNr : 1≤(N:ℝ) := by exact_mod_cast hN + have hh := tensorNewton_bound a (N:ℝ) C hNr hC.le hac I hI + change ‖(tensorNewton a I:UnitAddCircle)‖*(N:ℝ)^(totalDegree I)≤_ at hh + rw [mul_comm] at hh + exact hh.trans (by dsimp [A]; linarith) + +end CorrectedBoxLeibman +end +end + + + +section +noncomputable section +open scoped BigOperators +namespace ComparableBoxLeibman +open PolynomialWeyl BoxPolynomialLines + + + +def rectMean : (n : ℕ)→(Fin n→ℕ)→((Fin n→ℕ)→ℂ)→ℂ + | 0, _, f => f Fin.elim0 + | n+1, L, f => mean (L 0) (fun x => rectMean n (fun i => L i.succ) (fun y => f (Fin.cons x y))) + +lemma rectMean_eq_fin (n : ℕ) (L : Fin n→ℕ) (f : (Fin n→ℕ)→ℂ) : + rectMean n L f=𝔼 x : (i : Fin n)→Fin (L i), f (fun i => (x i).val) := by + classical + induction n with + | zero => + have he : (fun x : (i : Fin 0)→Fin (L i) => f (fun i => (x i).val))=fun _ => f Fin.elim0 := by + funext x + congr 1 + ext i + exact Fin.elim0 i + rw [he] + simp [rectMean] + | succ n ih => + simp only [rectMean,ih,BoxCounting.mean_eq_fin,← Finset.expect_product'] + apply Finset.expect_equiv (Fin.consEquiv (fun i : Fin (n+1) => Fin (L i))) + · intro x; simp + · intro x _ + congr 1 + ext i + exact Fin.cases rfl (fun _ => rfl) i + +lemma rectMean_const (n : ℕ) {L : Fin n→ℕ} (hL : ∀ i,0 z)=z := by + induction n with + | zero => rfl + | succ n ih => simp only [rectMean,ih (fun i => hL i.succ),mean_const (hL 0)] + +lemma rectMean_sub (n : ℕ) (L : Fin n→ℕ) (f g : (Fin n→ℕ)→ℂ) : + rectMean n L (fun x => f x-g x)=rectMean n L f-rectMean n L g := by + simp only [rectMean_eq_fin,Finset.expect_sub_distrib] + +lemma rectMean_norm_le (n : ℕ) {L : Fin n→ℕ} (hL : ∀ i,0 hf _ (fun i => (x i).isLt))) + +lemma rectMean_norm_sub_le (n : ℕ) {L : Fin n→ℕ} (hL : ∀ i,0 ‖f (fun i => (x i).val)‖) Finset.univ_nonempty + refine ⟨fun i => (x i).val,fun i => (x i).isLt,?_⟩ + apply rectMean_norm_le n hL + intro y hy + exact hx (fun i => ⟨y i,hy i⟩) (Finset.mem_univ _) + + +lemma rectMean_shift (n : ℕ) {L : Fin n→ℕ} (hL : ∀ i,0 f (x+h))-rectMean n L f‖≤∑ i, 2*(h i:ℝ)/(L i:ℝ) := by + induction n with + | zero => + have he : (Fin.elim0 : Fin 0→ℕ)+h=Fin.elim0 := by ext i; exact Fin.elim0 i + simp [rectMean,he] + | succ n ih => + let Lt : Fin n→ℕ := fun i => L i.succ + let F : ℕ→ℂ := fun x => rectMean n Lt (fun y => f (Fin.cons x y)) + let A : ℕ→ℂ := fun x => rectMean n Lt (fun y => f (Fin.cons x y+h)) + let B : ℕ→ℂ := fun x => F (x+h 0) + have hF : ∀ x,‖F x‖≤1 := fun x => rectMean_norm_le n (fun i => hL i.succ) _ _ (fun y _ => hf _) + have htail (x : ℕ) : ‖A x-B x‖≤∑ i : Fin n,2*(h i.succ:ℝ)/(L i.succ:ℝ) := by + dsimp [A,B,F,Lt] + simp only [cons_add] + exact ih (fun i => hL i.succ) (fun y => f (Fin.cons (x+h 0) y)) (fun y => hf _) (fun i => h i.succ) + have he := norm_mean_sub_le (hL 0) A B _ (fun x _ => htail x) + have hh := norm_mean_shift_sub_le (hL 0) (h 0) F hF + have ht := (norm_sub_le_norm_sub_add_norm_sub (mean (L 0) A) (mean (L 0) B) (mean (L 0) F)).trans (add_le_add he hh) + change ‖mean (L 0) A-mean (L 0) F‖≤_ + simpa only [Fin.sum_univ_succ,add_comm] using ht + +lemma rectMean_boxMean_comm (n : ℕ) (L : Fin n→ℕ) (v N : ℕ) + (f : (Fin n→ℕ)→(Fin v→ℕ)→ℂ) : + rectMean n L (fun x => boxMean v N (f x))= + boxMean v N (fun y => rectMean n L (fun x => f x y)) := by + simp only [rectMean_eq_fin,BoxCounting.boxMean_eq_fin] + exact Finset.expect_comm _ _ _ + + + +lemma rectMean_cube_smoothing (n : ℕ) {L : Fin n→ℕ} (hL : ∀ i,0 boxMean n N (fun y => f (x+y)))-rectMean n L f‖≤ + ∑ i,2*(N:ℝ)/(L i:ℝ) := by + rw [rectMean_boxMean_comm,← boxMean_const n hN (rectMean n L f),← boxMean_sub] + apply boxMean_norm_le n hN + intro y hy + exact (rectMean_shift n hL f hf y).trans (Finset.sum_le_sum (fun i _ => + div_le_div_of_nonneg_right (by have hi := hy i; exact_mod_cast (show 2*y i≤2*N by omega)) (Nat.cast_nonneg _))) + +end ComparableBoxLeibman +end +end + + + +section +noncomputable section +open scoped BigOperators +namespace ComparableBoxLeibman +open PolynomialWeyl BoxPolynomialLines + + + +lemma rectMean_bad_cube (n : ℕ) {L : Fin n→ℕ} (hL : ∀ i,0 f (a+y))-I‖ := by + let g : (Fin n→ℕ)→ℂ := fun x => boxMean n N (fun y => f (x+y)) + have hs : ‖rectMean n L g-rectMean n L f‖≤δ/2 := + (rectMean_cube_smoothing n hL N hN f hf).trans hshort + have ht := norm_sub_le_norm_sub_add_norm_sub (rectMean n L f) (rectMean n L g) I + have hsr : ‖rectMean n L f-rectMean n L g‖≤δ/2 := by rw [norm_sub_rev]; exact hs + have hg : 0<δ/2 ∧ δ/2≤‖rectMean n L g-I‖ := + ⟨half_pos hδ, by linarith only [hsr, ht, hd]⟩ + obtain ⟨a,ha,hag⟩ := rectMean_exists_norm_ge n hL (fun x => g x-I) + rw [rectMean_sub,rectMean_const n hL] at hag + exact ⟨a,ha,hg.2.trans hag⟩ + + + +lemma choose_rectangle_scale (v : ℕ) (c δ : ℝ) (hc : 0 hrow i) + _ = (v:ℝ)*(2/((T:ℝ)*c)) := by simp + _ ≤ δ/2 := by + rw [← mul_div_assoc] + apply (div_le_iff₀ (mul_pos hTr hc)).mpr + nlinarith only [hTb] + +end ComparableBoxLeibman + +end +end +end +end +end + +end OAI diff --git a/lean/OAI/Combinatorics/SumProduct/Alignment/ComparableBox02.lean b/lean/OAI/Combinatorics/SumProduct/Alignment/ComparableBox02.lean new file mode 100644 index 0000000000000000000000000000000000000000..ab41994f752d4affcfb837374e4efaa9dc9e69df --- /dev/null +++ b/lean/OAI/Combinatorics/SumProduct/Alignment/ComparableBox02.lean @@ -0,0 +1,281 @@ +import Mathlib +import OAI.Combinatorics.SumProduct.Alignment.CorrectedBox06 +import OAI.Geometry.NilpotentCharts.Main + +namespace OAI + +section +section +section +section +noncomputable section +open _root_.Polynomial _root_.OAI.Polynomial +open scoped BigOperators +end +end + + + +section +noncomputable section +open scoped BigOperators +namespace ComparableBoxLeibman +open MeasureTheory +variable {Y : Type*} [MetricSpace Y] [CompactSpace Y] [MeasurableSpace Y] [BorelSpace Y] + +lemma rectMean_smul (n : ℕ) (L : Fin n→ℕ) (z : ℂ) (f : (Fin n→ℕ)→ℂ) : + rectMean n L (fun x => z*f x)=z*rectMean n L f := by + simp only [rectMean_eq_fin, ← Finset.mul_expect] + +omit [BorelSpace Y] in +lemma normalized_rect_observable [BorelSpace Y] (μ : Measure Y) (v : ℕ) (L : Fin v→ℕ) + (p : (Fin v→ℕ)→Y) (B : NNReal) (hB : 0 F (p x))-(∫ y,F y ∂μ)‖) : + ∃ F' : C(Y,ℂ), LipschitzWith 1 F' ∧ ‖F'‖≤1 ∧ + η/(B:ℝ)≤‖rectMean v L (fun x => F' (p x))-(∫ y,F' y ∂μ)‖ := by + let z : ℂ := ((B:ℝ):ℂ)⁻¹ + have hBr : 0<(B:ℝ) := hB + have hz : ‖z‖=(B:ℝ)⁻¹ := by simp [z] + let F' : C(Y,ℂ) := z • F + refine ⟨F',?_,?_,?_⟩ + · apply LipschitzWith.of_dist_le_mul + intro x y + change dist (z*F x) (z*F y)≤_ + simp only [dist_eq_norm,← mul_sub,norm_mul,hz] + rw [← dist_eq_norm] + calc + _ ≤ (B:ℝ)⁻¹*((B:ℝ)*dist x y) := mul_le_mul_of_nonneg_left (hFL.dist_le_mul x y) (by positivity) + _ = (1:NNReal)*dist x y := by norm_num; field_simp + · change ‖z • F‖≤1 + rw [norm_smul,hz] + exact (mul_le_mul_of_nonneg_left hFn (by positivity)).trans_eq (inv_mul_cancel₀ hBr.ne') + · change η/(B:ℝ)≤‖rectMean v L (fun x => z*F (p x))-(∫ y,z*F y ∂μ)‖ + rw [rectMean_smul,integral_const_mul,← mul_sub,norm_mul,hz] + rw [div_eq_mul_inv,mul_comm] + exact mul_le_mul_of_nonneg_left hd (by positivity) + +end ComparableBoxLeibman +end +end + + + +section +noncomputable section +open _root_.Polynomial _root_.OAI.Polynomial +open scoped BigOperators +namespace ComparableBoxLeibman +open CubeFaces CubePolynomials LeibmanSquare RationalLattice MalcevCharacters +open MeasureTheory PolynomialWeyl AbelianMalcevTorus RationalTailCoordinates UnitAddTorus +variable {G : Type} [Group G] [TopologicalSpace G] [IsTopologicalGroup G] +variable {t d : ℕ} (c : RealCoordinates G (t+d)) (hsk : SecondKind c) +variable (H : Filtration G) (h0 : H.level 0=⊤) (h1 : H.level 1=⊤) +variable [∀ i, (H.level i).Normal] +variable (s : ℕ) (hs : H.level (s+1)=⊥) +variable (q : ℕ→ℕ) (hqbound : ∀ k, q k ≤ t+d) (hq2 : q 2=t) +variable (hq : ∀ k (g : G), g∈H.level k ↔ ∀ i : Fin (t+d), i.val F (QuotientGroup.mk (f (fun i => a₀ i+(x i:ℤ)))))-(∫ y,F y ∂μ)‖) → + ∃ ξ∈U, ξ≠1 ∧ Continuous ξ ∧ (∀ g∈Γ,∃ z : ℤ,(ξ g).toAdd=z) ∧ + ∃ a : PolynomialLineCoefficients.Grid v s→ℝ, + (∀ x,gridEval a (fun i => (x i:ℝ))=(ξ (f x)).toAdd) ∧ + (∀ I,s QuotientGroup.mk (f (fun i => a₀ i+(x i:ℤ)))) B hB η F hFL hFn hdisc + obtain ⟨ξ,hξ,hξne,hξc,hξΓ,a,ha,hat,hac⟩ := hprod Z hZ a₀ L hL hloc f hf ⟨F',hFL',hFn',hdisc'⟩ + refine ⟨ξ,hξ,hξne,hξc,hξΓ,a,ha,hat,?_⟩ + intro I hI + exact (le_div_iff₀ (pow_pos (hZ₀.trans_le hZ) _)).mpr (hac I hI) + +end ComparableBoxLeibman +end +end + + + +section +noncomputable section +open scoped BigOperators +namespace ComparableBoxLeibman + + +def integerLength (lo hi : ℝ) : ℕ := (⌊hi⌋-⌈lo⌉+1).toNat + +lemma integerCoord_bounds (lo hi : ℝ) (k : ℕ) (hk : k < integerLength lo hi) : + lo≤((⌈lo⌉+(k:ℤ):ℤ):ℝ) ∧ ((⌈lo⌉+(k:ℤ):ℤ):ℝ)≤hi := by + have hki : (k:ℤ)<⌊hi⌋-⌈lo⌉+1 := by + dsimp [integerLength] at hk + omega + constructor + · exact (Int.le_ceil lo).trans (by push_cast; exact le_add_of_nonneg_right (Nat.cast_nonneg _)) + · apply Int.le_floor.mp + omega + +lemma integerCoord_exists (lo hi : ℝ) (z : ℤ) (hlo : lo≤(z:ℝ)) (hhi : (z:ℝ)≤hi) : + ∃ k : Fin (integerLength lo hi),⌈lo⌉+(k.val:ℤ)=z := by + have hzlo := Int.ceil_le.mpr hlo + have hzhi := Int.le_floor.mpr hhi + have hn : 0≤z-⌈lo⌉ := sub_nonneg.mpr hzlo + refine ⟨⟨(z-⌈lo⌉).toNat,?_⟩,?_⟩ + · dsimp [integerLength] + exact (Int.toNat_lt_toNat (by omega)).mpr (by omega) + · rw [Int.toNat_of_nonneg hn] + omega + + +def integerBox (v : ℕ) (lo hi : Fin v→ℝ) : Finset (Fin v→ℤ) := + Finset.univ.image (fun x : (i : Fin v)→Fin (integerLength (lo i) (hi i)) => + fun i => ⌈lo i⌉+((x i).val:ℤ)) + +lemma mem_integerBox {v : ℕ} (lo hi : Fin v→ℝ) (z : Fin v→ℤ) : + z∈integerBox v lo hi ↔ ∀ i,lo i≤(z i:ℝ) ∧ (z i:ℝ)≤hi i := by + classical + constructor + · intro hz + obtain ⟨x,_,rfl⟩ := Finset.mem_image.mp hz + exact fun i => integerCoord_bounds _ _ _ (x i).isLt + · intro hz + choose x hx using (fun i => integerCoord_exists (lo i) (hi i) (z i) (hz i).1 (hz i).2) + exact Finset.mem_image.mpr ⟨x,Finset.mem_univ _,funext hx⟩ + +lemma integerBox_average (v : ℕ) (lo hi : Fin v→ℝ) (f : (Fin v→ℤ)→ℂ) : + (𝔼 z∈integerBox v lo hi,f z)= + rectMean v (fun i => integerLength (lo i) (hi i)) + (fun x => f (fun i => ⌈lo i⌉+(x i:ℤ))) := by + classical + rw [integerBox,Finset.expect_image,rectMean_eq_fin] + intro x _ y _ hxy + ext i + have h := congrFun hxy i + exact_mod_cast (add_left_cancel h) + +lemma integerLength_lower (lo hi W : ℝ) (hW : 2≤W) (hside : W≤hi-lo) : + W/2≤(integerLength lo hi:ℝ) := by + have hfl := Int.lt_floor_add_one hi + have hcl := Int.ceil_lt_add_one lo + have hd : 0<(⌊hi⌋-⌈lo⌉+1:ℤ) := by + have hh : (0:ℝ)<((⌊hi⌋:ℤ):ℝ)-((⌈lo⌉:ℤ):ℝ)+1 := by linarith + exact_mod_cast hh + have hc : (integerLength lo hi:ℝ)=((⌊hi⌋-⌈lo⌉+1:ℤ):ℝ) := by + dsimp [integerLength] + rw [← Int.cast_natCast,Int.toNat_of_nonneg hd.le] + rw [hc] + push_cast + linarith + +end ComparableBoxLeibman +end +end + + + +section +noncomputable section +open _root_.Polynomial _root_.OAI.Polynomial +open scoped BigOperators +namespace ComparableBoxLeibman +open CubeFaces CubePolynomials LeibmanSquare RationalLattice MalcevCharacters +open MeasureTheory PolynomialWeyl AbelianMalcevTorus RationalTailCoordinates UnitAddTorus +variable {G : Type} [Group G] [TopologicalSpace G] [IsTopologicalGroup G] +variable {t d : ℕ} (c : RealCoordinates G (t+d)) (hsk : SecondKind c) +variable (H : Filtration G) (h0 : H.level 0=⊤) (h1 : H.level 1=⊤) +variable [∀ i, (H.level i).Normal] +variable (s : ℕ) (hs : H.level (s+1)=⊥) +variable (q : ℕ→ℕ) (hqbound : ∀ k, q k ≤ t+d) (hq2 : q 2=t) +variable (hq : ∀ k (g : G), g∈H.level k ↔ ∀ i : Fin (t+d), i.val (x i:ℝ))=(ξ (f x)).toAdd) ∧ + (∀ I,s ⌈lo i⌉) (fun i => integerLength (lo i) (hi i)) hlength hlocation f hf + obtain ⟨F,hFL,hFn,hdisc⟩ := hd + refine ⟨F,hFL,hFn,?_⟩ + simpa only [integerBox_average] using hdisc + +end ComparableBoxLeibman + +end +end +end +end +end + +end OAI diff --git a/lean/OAI/Combinatorics/SumProduct/Alignment/ComparableBox03.lean b/lean/OAI/Combinatorics/SumProduct/Alignment/ComparableBox03.lean new file mode 100644 index 0000000000000000000000000000000000000000..b2fda41f3a4e0de1b42506e7b5d156f976d8425b --- /dev/null +++ b/lean/OAI/Combinatorics/SumProduct/Alignment/ComparableBox03.lean @@ -0,0 +1,328 @@ +import Mathlib +import OAI.Combinatorics.SumProduct.Alignment.RationalLattice20 +import OAI.Geometry.NilpotentCharts.Main + +namespace OAI + +open scoped BigOperators +section +noncomputable section +open scoped Topology +namespace FiniteCoverCharacters +open CubeHorizontalIrrationality +variable {G : Type*} [Group G] +variable (Λ Γ : Subgroup G) (hle : Λ≤Γ) [(Λ.subgroupOf Γ).FiniteIndex] + +include hle in + + +theorem rationalCharacter_iff {K : Subgroup G} (χ : K →* Multiplicative ℝ) : + RationalCharacter Λ χ ↔ RationalCharacter Γ χ := by + constructor + · rintro ⟨m,hm,hz⟩ + let D:=denominator Λ Γ + refine ⟨m*D,Nat.mul_pos hm (denominator_pos Λ Γ),?_⟩ + intro x hx + have hp : ((x^D : K):G)∈Λ:=pow_denominator_mem Λ Γ hle x.val hx + obtain ⟨z,hz⟩:=hz (x^D) hp + refine ⟨z,?_⟩ + simpa only [map_pow,toAdd_pow,nsmul_eq_mul,Nat.cast_mul,mul_assoc] using hz + · rintro ⟨m,hm,hz⟩ + exact ⟨m,hm,fun x hx=>hz x (hle hx)⟩ +end FiniteCoverCharacters + +end + +end + +section + + + + +section +noncomputable section +open scoped BigOperators Topology +namespace ComparableBoxLeibman +open CubeFaces CubePolynomials LeibmanSquare RationalLattice MalcevCharacters +open MeasureTheory PolynomialWeyl AbelianMalcevTorus RationalTailCoordinates UnitAddTorus +open SquareInduction BoxPolynomialLines PolynomialLineCoefficients CorrectedBoxLeibman TriangularLatticeRecovery +open Filter +variable {G : Type} [Group G] [TopologicalSpace G] [IsTopologicalGroup G] +variable {t d : ℕ} (c : RealCoordinates G (t+d)) (hsk : SecondKind c) +variable (H : Filtration G) (h0 : H.level 0=⊤) (h1 : H.level 1=⊤) +variable [∀ i, (H.level i).Normal] +variable (s : ℕ) (hs : H.level (s+1)=⊥) +variable (q : ℕ→ℕ) (hqbound : ∀ k, q k ≤ t+d) +variable (hq : ∀ k (g : G), g∈H.level k ↔ ∀ i : Fin (t+d), i.val < q k → c.coord g i=0) +variable (Γ : Subgroup G) (hΓ : ∀ g : G, g∈Γ ↔ ∀ i, ∃ z : ℤ, c.coord g i=z) +variable [MeasurableSpace (G⧸Γ)] [hBorel : @BorelSpace (G⧸Γ) (QuotientGroup.instTopologicalSpace Γ) inferInstance] +variable [mtr : MetricSpace (G⧸Γ)] +variable (htop : mtr.toUniformSpace.toTopologicalSpace=QuotientGroup.instTopologicalSpace Γ) +local instance comparableBox03ScaledHaarTopology : TopologicalSpace (G⧸Γ) := + mtr.toUniformSpace.toTopologicalSpace + +include hsk h0 h1 hs hqbound hq hΓ htop in + + +theorem haar_limit_of_horizontal_irrationality_scaled + (L : ℕ→ℝ) (hL : Tendsto L atTop atTop) + (μ : Measure (G⧸Γ)) [IsProbabilityMeasure μ] [SMulInvariantMeasure G (G⧸Γ) μ] + (v : ℕ) (f : ℕ→(Fin v→ℤ)→G) (hf : ∀ N,LeibmanSquare.Polynomial H 0 (f N)) + (hirr : ∀ ξ : G→*Multiplicative ℝ, ξ≠1 → Continuous ξ → + (∀ g∈Γ,∃ z : ℤ,(ξ g).toAdd=z) → + ∃ a : ℕ→PolynomialLineCoefficients.Grid v s→ℝ, + (∀ N x,gridEval (a N) (fun i => (x i:ℝ))=(ξ (f N x)).toAdd) ∧ + ∃ I,0 < totalDegree I ∧ + Tendsto (fun N => circleNorm (a N I)*(L N)^(totalDegree I)) atTop atTop) + (c₀ C₀ : ℝ) (B : NNReal) (hc₀ : 0 (x i:ℝ))=(ξ (f N x)).toAdd) → + ∃ I,0 (ha N x).trans (hb x).symm) + exact ⟨I,hI,by simpa only [hab] using hN⟩ + · exact Filter.Eventually.of_forall (by intro N hne hcont hint; exact (hc ⟨hne,hcont,hint⟩).elim) + have hall : ∀ᶠ N : ℕ in atTop,∀ ξ∈U, + ξ≠1 → Continuous ξ → (∀ g∈Γ,∃ z : ℤ,(ξ g).toAdd=z) → + ∀ a : PolynomialLineCoefficients.Grid v s→ℝ, + (∀ x,gridEval a (fun i => (x i:ℝ))=(ξ (f N x)).toAdd) → + ∃ I,0 hlarge ξ) + have hNlarge : ∀ᶠ N : ℕ in atTop,Z₀≤(L N) := + hL.eventually_ge_atTop Z₀ + filter_upwards [hall,hNlarge] with N hN hNZ + intro lo hi hside hloc F hFL hFn + by_contra hbad + have hdisc : η≤‖(𝔼 x∈integerBox v lo hi,F (QuotientGroup.mk (f N x)))-(∫ y,F y ∂μ)‖ := le_of_not_gt hbad + obtain ⟨ξ,hξ,hξne,hξc,hξΓ,a,ha,hat,hac⟩ := hprod (L N) hNZ lo hi hside hloc (f N) (hf N) ⟨F,hFL,hFn,hdisc⟩ + obtain ⟨I,hI,hIA⟩ := hN ξ hξ hξne hξc hξΓ a ha + have hpow : 0<(L N)^(totalDegree I) := pow_pos (hZ₀.trans_le hNZ) _ + have hbnd := (le_div_iff₀ hpow).mp (hac I hI) + exact (not_lt_of_ge hbnd) hIA + +end ComparableBoxLeibman +end +end + +section +noncomputable section +open scoped BigOperators Topology +namespace ComparableBoxLeibman +open CubeFaces CubePolynomials LeibmanSquare RationalLattice MalcevCharacters +open MeasureTheory PolynomialWeyl AbelianMalcevTorus RationalTailCoordinates UnitAddTorus +open SquareInduction BoxPolynomialLines PolynomialLineCoefficients CorrectedBoxLeibman TriangularLatticeRecovery +open Filter +variable {G : Type} [Group G] [TopologicalSpace G] [IsTopologicalGroup G] +variable {t d : ℕ} (c : RealCoordinates G (t+d)) (hsk : SecondKind c) +variable (H : Filtration G) (h0 : H.level 0=⊤) (h1 : H.level 1=⊤) +variable [∀ i, (H.level i).Normal] +variable (s : ℕ) (hs : H.level (s+1)=⊥) +variable (q : ℕ→ℕ) (hqbound : ∀ k, q k ≤ t+d) +variable (hq : ∀ k (g : G), g∈H.level k ↔ ∀ i : Fin (t+d), i.val < q k → c.coord g i=0) +variable (Γ : Subgroup G) (hΓ : ∀ g : G, g∈Γ ↔ ∀ i, ∃ z : ℤ, c.coord g i=z) +variable [MeasurableSpace (G⧸Γ)] [hBorel : @BorelSpace (G⧸Γ) (QuotientGroup.instTopologicalSpace Γ) inferInstance] +variable [mtr : MetricSpace (G⧸Γ)] +variable (htop : mtr.toUniformSpace.toTopologicalSpace=QuotientGroup.instTopologicalSpace Γ) +local instance scaledProgressionHaarTopology : TopologicalSpace (G⧸Γ) := mtr.toUniformSpace.toTopologicalSpace + +include hsk h0 h1 hs hqbound hq hΓ htop in + + +theorem haar_limit_fixed_progression_scaled + (L : ℕ→ℝ) (hL : Tendsto L atTop atTop) + (μ : Measure (G⧸Γ)) [IsProbabilityMeasure μ] [SMulInvariantMeasure G (G⧸Γ) μ] + (v : ℕ) (f : ℕ→(Fin v→ℤ)→G) (hf : ∀ N,LeibmanSquare.Polynomial H 0 (f N)) + (hirr : ∀ ξ : G→*Multiplicative ℝ, ξ≠1 → Continuous ξ → + (∀ g∈Γ,∃ z : ℤ,(ξ g).toAdd=z) → + ∃ a : ℕ→PolynomialLineCoefficients.Grid v s→ℝ, + (∀ N x,gridEval (a N) (fun i => (x i:ℝ))=(ξ (f N x)).toAdd) ∧ + ∃ I,0 < totalDegree I ∧ + Tendsto (fun N => circleNorm (a N I)*(L N)^(totalDegree I)) atTop atTop) + (c₀ C₀ : ℝ) (B : NNReal) (hc₀ : 0 r i+(d₀:ℤ)*x i))))-(∫ y,F y ∂μ)‖<η := by + classical + let : CompactSpace (G⧸Γ) := metric_compact c Γ hΓ mtr htop + let : BorelSpace (G⧸Γ) := metric_borelSpace Γ mtr htop + intro η hη + obtain ⟨U,A,Z₀,hA,hZ₀,hprod⟩ := comparable_real_box c hsk H h0 h1 s hs q hqbound hq Γ hΓ htop μ v c₀ C₀ B η hc₀ hC₀ hB hη + let D : ℕ := d₀^(v*s) + have hD : 0 abs_nonneg (r i:ℝ))] + have hrC (i : Fin v) : |(r i:ℝ)|≤C := by + have hh := Finset.single_le_sum (f := fun i : Fin v => |(r i:ℝ)|) + (fun i _ => abs_nonneg _) (Finset.mem_univ i) + dsimp [C] + linarith + let E : ℝ := ((s+1:ℕ)^v:ℝ)*(2^s*C^s)^v*((d₀:ℝ)^(v*s)*A) + have hlarge (ξ : G→*Multiplicative ℝ) : ∀ᶠ N : ℕ in atTop, + ξ≠1 → Continuous ξ → (∀ g∈Γ,∃ z : ℤ,(ξ g).toAdd=z) → + ∀ a : PolynomialLineCoefficients.Grid v s→ℝ, + (∀ x,gridEval a (fun i => (x i:ℝ))=(ξ (f N x)).toAdd) → + ∃ I,0 (d₀:ℝ)^(v*s)*b I) := by + apply gridEval_integer_injective + intro x + rw [ha,gridEval_mul,hb,character_pow_toAdd] + simp [D] + exact ⟨I,hI,by simpa only [hab] using hN⟩ + · exact Filter.Eventually.of_forall (by intro N hne hcont hint; exact (hc ⟨hne,hcont,hint⟩).elim) + have hall : ∀ᶠ N : ℕ in atTop,∀ ξ∈U, + ξ≠1 → Continuous ξ → (∀ g∈Γ,∃ z : ℤ,(ξ g).toAdd=z) → + ∀ a : PolynomialLineCoefficients.Grid v s→ℝ, + (∀ x,gridEval a (fun i => (x i:ℝ))=(ξ (f N x)).toAdd) → + ∃ I,0 hlarge ξ) + have hNlarge : ∀ᶠ N : ℕ in atTop,max 1 Z₀≤(L N) := + hL.eventually_ge_atTop (max 1 Z₀) + let φ : (Fin v→ℤ)→+(Fin v→ℤ) := + { toFun := fun x i => (d₀:ℤ)*x i + map_zero' := by ext i; simp + map_add' := by intro x y; ext i; simp [mul_add] } + filter_upwards [hall,hNlarge] with N hN hNZ + have hNZ₀ : Z₀≤(L N) := (le_max_right _ _).trans hNZ + have hN1 : 1≤(L N) := (le_max_left _ _).trans hNZ + intro lo hi hside hloc F hFL hFn + by_contra hbad + have hdisc : η≤‖(𝔼 x∈integerBox v lo hi,F (QuotientGroup.mk + (f N (fun i => r i+(d₀:ℤ)*x i))))-(∫ y,F y ∂μ)‖ := le_of_not_gt hbad + have hgf := polynomial_affine H (hf N) φ r + obtain ⟨ξ,hξ,hξne,hξc,hξΓ,b,hb,hbt,hbc⟩ := hprod (L N) hNZ₀ lo hi hside hloc + (fun x => f N (r+φ x)) hgf ⟨F,hFL,hFn,hdisc⟩ + obtain ⟨a,ha⟩ := character_grid_expansion H s hs (hf N) ξ + have hab : ∀ x : Fin v→ℤ,gridEval b (fun i => (x i:ℝ))= + gridEval a (fun i => ((r i+(d₀:ℤ)*x i:ℤ):ℝ)) := by + intro x + rw [hb,ha] + rfl + have hbnd := gridAffine_recover_bound d₀ hd₀ r a b (L N) C A (zero_le_one.trans hN1) hC hA.le + (fun i => (hrC i).trans (le_mul_of_one_le_right (zero_le_one.trans hC) hN1)) hab + (fun I hI => (le_div_iff₀ (pow_pos (hZ₀.trans_le hNZ₀) _)).mp (hbc I hI)) + obtain ⟨I,hI,hIE⟩ := hN ξ hξ hξne hξc hξΓ a ha + exact (not_lt_of_ge (hbnd I hI)) hIE + +end ComparableBoxLeibman +end +end + +section +noncomputable section +open scoped BigOperators Topology commutatorElement +namespace CubeHorizontalIrrationality +open CubeFaces HorizontalCubeCharacter Filter BooleanBinomial MvPolynomial +open CubeTaylorExpansion CorrectedBoxLeibman PolynomialLineCoefficients PolynomialWeyl TriangularLatticeRecovery +variable {G ι : Type*} [Group G] [TopologicalSpace G] [IsTopologicalGroup G] +variable [Fintype ι] [DecidableEq ι] +omit [IsTopologicalGroup G] in +theorem coefficient_divergence_scaled (L : ℕ→ℝ) (H : Filtration G) (Γ : Subgroup G) + (h01 : H.level 0=H.level 1) (s : ℕ) (hs : H.level (s+1)= ⊥) + (a : ℕ→∀ k : ℕ,H.level k) + (hirr : ∀ j : ℕ,0 < j → j ≤ s → ∀ ξ : H.level j→*Multiplicative ℝ, + ξ≠1 → Continuous ξ → RationalCharacter Γ ξ → + (∀ x (hx : x∈H.level (j+1)),ξ ⟨x,H.antitone (Nat.le_succ _) hx⟩=1) → + (∀ i k : ℕ,0 < i → 0 < k → ∀ h : i+k=j, + ∀ x (hx : x∈H.level i) y (hy : y∈H.level k), + ξ ⟨⁅x,y⁆,by rw [←h]; exact H.commutator_le i k (Subgroup.commutator_mem_commutator hx hy)⟩=1) → + Tendsto (fun N : ℕ => ‖((ξ (a N j)).toAdd:UnitAddCircle)‖*(L N)^j) + atTop atTop) + (χ : cube H (Finset.univ : Finset ι) 0→*Multiplicative ℝ) + (hχne : χ≠1) (hχ : Continuous χ) + (hχΓ : ∀ x : cube H (Finset.univ : Finset ι) 0, + (∀ v,(x:Finset ι→G) v∈Γ) → ∃ z : ℤ,(χ x).toAdd=z) : + ∃ e : Exponent ι,0 < degree e ∧ degree e ≤ s ∧ + Tendsto (fun N : ℕ => ‖(((scalarPolynomial H χ (a N) s).coeff e:ℝ):UnitAddCircle)‖* + (L N)^(degree e)) atTop atTop := by + obtain ⟨M⟩ := exists_maximalFace H Finset.univ h01 s hs χ hχne + obtain ⟨hne,hc,hr,hn,hb⟩ := maximal_scaled_character Γ hχ hχΓ M + refine ⟨isolatedExponent M.level M.face,?_,?_,?_⟩ + · rw [isolatedExponent_degree M.level M.face M.card_le] + exact M.positive + · rw [isolatedExponent_degree M.level M.face M.card_le] + exact maximal_level_le M hs + · have hh := hirr M.level M.positive (maximal_level_le M hs) _ hne hc hr hn hb + simpa only [isolatedExponent_degree M.level M.face M.card_le, + isolated_scalar_coefficient M _ s hs,scaleCharacter,MonoidHom.coe_mk, + OneHom.coe_mk,toAdd_ofAdd,div_eq_mul_inv,mul_comm] using hh + +theorem grid_irrationality_scaled (L : ℕ→ℝ) {n v : ℕ} (c : RationalLattice.RealCoordinates G n) + (H : Filtration G) (S : ℕ→Set (Fin n)) + (hH : ∀ k (g : G),g∈H.level k ↔ ∀ i∈S k,c.coord g i=0) + (Γ : Subgroup G) (h01 : H.level 0=H.level 1) + (s : ℕ) (hs : H.level (s+1)=⊥) (e : Option ι≃Fin v) + (a : ℕ→∀ k : ℕ,H.level k) + (hirr : ∀ j : ℕ,0 < j → j ≤ s → ∀ ξ : H.level j→*Multiplicative ℝ, + ξ≠1 → Continuous ξ → RationalCharacter Γ ξ → + (∀ x (hx : x∈H.level (j+1)),ξ ⟨x,H.antitone (Nat.le_succ _) hx⟩=1) → + (∀ i k : ℕ,0 < i → 0 < k → ∀ h : i+k=j, + ∀ x (hx : x∈H.level i) y (hy : y∈H.level k), + ξ ⟨⁅x,y⁆,by rw [←h]; exact H.commutator_le i k (Subgroup.commutator_mem_commutator hx hy)⟩=1) → + Tendsto (fun N : ℕ => ‖((ξ (a N j)).toAdd:UnitAddCircle)‖*(L N)^j) + atTop atTop) + (χ : cube H (Finset.univ : Finset ι) 0→*Multiplicative ℝ) + (hχne : χ≠1) (hχ : Continuous χ) + (hχΓ : ∀ x : cube H (Finset.univ : Finset ι) 0, + (∀ w,(x:Finset ι→G) w∈Γ) → ∃ z : ℤ,(χ x).toAdd=z) : + ∃ b : ℕ→PolynomialLineCoefficients.Grid v s→ℝ, + (∀ N (x : Fin v→ℤ),gridEval (b N) (fun i => (x i:ℝ))= + (χ (cubePolynomial c H S hH (a N) s (fun i => (x (e i):ℝ)))).toAdd) ∧ + ∃ I,0 < PolynomialLineCoefficients.totalDegree I ∧ + Tendsto (fun N => circleNorm (b N I)*(L N)^(PolynomialLineCoefficients.totalDegree I)) atTop atTop := by + let p (N : ℕ) : MvPolynomial (Fin v) ℝ := rename e (scalarPolynomial H χ (a N) s) + have hp (N : ℕ) : (p N).totalDegree ≤ s := + (MvPolynomial.totalDegree_rename_le _ _).trans (scalarPolynomial_totalDegree H χ (a N) s) + refine ⟨fun N => polynomialGrid (p N),?_,?_⟩ + · intro N x + rw [gridEval_polynomial _ (hp N)] + exact (MvPolynomial.eval_rename _ _ _).trans (scalarPolynomial_eval c H S hH (a N) s _ χ hχ) + · obtain ⟨m,hm,hmS,hlim⟩ := coefficient_divergence_scaled L H Γ h01 s hs a hirr χ hχne hχ hχΓ + have hm' : (m.mapDomain e).sum (fun _ k => k) ≤ s := by rwa [renamed_degree] + refine ⟨exponentGrid (m.mapDomain e) hm',?_,?_⟩ + · rwa [exponentGrid_degree,renamed_degree] + · simpa only [circleNorm,polynomialGrid,gridExponent_exponentGrid,p, + coeff_rename_mapDomain e e.injective,exponentGrid_degree,renamed_degree] using hlim + +end CubeHorizontalIrrationality + +end +end +end + +end OAI diff --git a/lean/OAI/Combinatorics/SumProduct/Alignment/ConstantCoefficient01.lean b/lean/OAI/Combinatorics/SumProduct/Alignment/ConstantCoefficient01.lean new file mode 100644 index 0000000000000000000000000000000000000000..4b495b30b48801767df1021a2f6c367a29f6cc71 --- /dev/null +++ b/lean/OAI/Combinatorics/SumProduct/Alignment/ConstantCoefficient01.lean @@ -0,0 +1,531 @@ +import Mathlib +import OAI.Combinatorics.SumProduct.Alignment.RoughSampling02 +import OAI.Geometry.NilpotentCharts.Main + +namespace OAI + +section +section +section +noncomputable section +open scoped BigOperators +end + +end + +section + + + + +noncomputable section +open scoped BigOperators +open Filter FinitePieceAverages +namespace RoughSamplingWeights +variable {ι : Type*} [Fintype ι] [DecidableEq ι] + + +def jointAffine (u : ι → ℤ) (K : ℕ) (y : Option ι → ℝ) : Option ι → ℝ + | none => y none + | some i => (u i:ℝ)+(K:ℝ)*y (some i) + +omit [Fintype ι] [DecidableEq ι] in +theorem jointAffine_degree {f : (Option ι → ℝ) → ℝ} {d : ℕ} + (hf : RealPolynomialDegree.HasDegree f d) (u : ι → ℤ) (K : ℕ) : + RealPolynomialDegree.HasDegree (fun y=>f (jointAffine u K y)) d := by + have h:=RealPolynomialDegree.affine_comp hf + (fun o=>Option.elim o 0 (fun i=>(u i:ℝ))) + (fun o=>Option.elim o 1 (fun _=>(K:ℝ))) id + convert h using 1 + funext y + congr 1 + funext o + cases o <;> simp [jointAffine] + + + +theorem rescaled_discrepancy (u a : ι → ℤ) (K t : ℕ) (hK : 0∀ i,x i ≡ a i [ZMOD t])) f‖ ↔ + η≤‖mean (boxIndices (rescaledEndpoint lo u K) (rescaledEndpoint hi u K) + (fun _=>0) 1) (fun y=>f (integerAffine u K y))- + mean ((boxIndices (rescaledEndpoint lo u K) (rescaledEndpoint hi u K) + (fun _=>0) 1).filter (fun y=>∀ i,y i ≡ b i [ZMOD t])) + (fun y=>f (integerAffine u K y))‖ := by + obtain ⟨b,hb⟩:=residual_mean u a K t hK h + refine ⟨b,fun lo hi f η=>?_⟩ + rw [residue_mean lo hi u K hK f,hb lo hi f] + + + +theorem fixed_period_preserves_scales {α : Type*} {l : Filter α} + (Z S : α → ℝ) (K : ℕ) (hK : 0Z N/S N^a) l atTop) : + ∀ a : ℕ,Tendsto (fun N=>(Z N/K)/S N^a) l atTop := by + intro a + have hKr : (0:ℝ) Z n / S n ^ k) atTop atTop) : + Tendsto (fun n => S n ^ k / Z n) atTop (𝓝 0) := by + simpa only [Function.comp_def, inv_div] using tendsto_inv_atTop_zero.comp h + +end RoughScales + +end + +section + + + + +noncomputable section +open scoped BigOperators +namespace RoughSamplingWeights +open FinitePieceAverages +variable {ι : Type*} [Fintype ι] [DecidableEq ι] + +lemma period_coprime_of_rough (w K t : ℕ) (hK : 0∀ i,x i ≡ a i [ZMOD t])) f‖ ↔ + η≤‖mean (boxIndices (rescaledEndpoint lo u K) (rescaledEndpoint hi u K) + (fun _=>0) 1) (fun y=>f (integerAffine u K y))- + mean ((boxIndices (rescaledEndpoint lo u K) (rescaledEndpoint hi u K) + (fun _=>0) 1).filter (fun y=>∀ i,y i ≡ b i [ZMOD t])) + (fun y=>f (integerAffine u K y))‖ := + rescaled_discrepancy u a K t hK (period_coprime_of_rough w K t hK hKw ht) + +end RoughSamplingWeights +end + +end + +section + + + + +namespace ConstantCoefficientRationalization +open _root_.Polynomial _root_.OAI.Polynomial Finset Function +open scoped BigOperators fwdDiff +noncomputable section + +lemma fwdDiff_cast (f : ℕ → ℤ) (k n : ℕ) : + (Δ_[1] ^[k] (fun j => (f j : ℝ))) n = (Δ_[1] ^[k] f n : ℤ) := by + induction k generalizing n with + | zero => rfl + | succ k ih => + rw [iterate_succ_apply', iterate_succ_apply'] + simp only [fwdDiff, ih, Int.cast_sub] + +lemma fwdDiff_eval_nat (P : ℝ[X]) (k n : ℕ) : + (Δ_[1] ^[k] (fun j : ℕ => P.eval (j : ℝ))) n = + (Δ_[1] ^[k] P.eval) (n : ℝ) := by + induction k generalizing n with + | zero => rfl + | succ k ih => + rw [iterate_succ_apply', iterate_succ_apply'] + simp only [fwdDiff, ih, Nat.cast_add, Nat.cast_one] + +lemma fwdDiff_sub (f g : ℕ → ℝ) (k n : ℕ) : + (Δ_[1] ^[k] (fun j => f j - g j)) n = + (Δ_[1] ^[k] f) n - (Δ_[1] ^[k] g) n := by + induction k generalizing n with + | zero => rfl + | succ k ih => + rw [iterate_succ_apply', iterate_succ_apply', iterate_succ_apply'] + simp only [fwdDiff, ih] + ring + +lemma fwdDiff_constant (a : ℝ) {k : ℕ} (hk : 0 < k) (n : ℕ) : + (Δ_[1] ^[k] (fun _ : ℕ => a)) n = 0 := by + obtain ⟨k,rfl⟩ := Nat.exists_eq_succ_of_ne_zero (ne_of_gt hk) + clear hk + rw [iterate_succ_apply] + simp only [fwdDiff_const] + induction k generalizing n with + | zero => rfl + | succ k ih => + rw [iterate_succ_apply'] + simp only [fwdDiff, ih, sub_self] + +lemma abs_fwdDiff_le (f : ℕ → ℝ) {ε : ℝ} (_hε : 0 ≤ ε) (k n : ℕ) + (hf : ∀ j ≤ k, |f (n+j)| ≤ ε) : + |(Δ_[1] ^[k] f) n| ≤ 2^k * ε := by + induction k generalizing n with + | zero => simpa using hf 0 (by omega) + | succ k ih => + rw [iterate_succ_apply'] + change |(Δ_[1] ^[k] f) (n+1) - (Δ_[1] ^[k] f) n| ≤ _ + have hshift : ∀ j ≤ k, |f (n+1+j)| ≤ ε := by + intro j hj + simpa only [Nat.add_assoc, Nat.add_left_comm, Nat.add_comm] using + hf (j+1) (by omega) + calc + _ ≤ |(Δ_[1] ^[k] f) (n+1)| + |(Δ_[1] ^[k] f) n| := abs_sub _ _ + _ ≤ 2^k*ε + 2^k*ε := add_le_add + (ih (n+1) hshift) + (ih n (fun j hj => hf j (by omega))) + _ = _ := by rw [pow_succ]; ring + + +theorem floor_difference_zero (P : ℝ[X]) {q N : ℕ} (hP : P.natDegree ≤ q) + {a ε : ℝ} (hε : 0 ≤ ε) (hsmall : 2^(q+1)*ε < 1) + (hfrac : ∀ n ≤ N, |Int.fract (P.eval (n : ℝ)) - a| ≤ ε) + {n : ℕ} (hn : n+q+1 ≤ N) : + (Δ_[1] ^[q+1] (fun j : ℕ => ⌊P.eval (j : ℝ)⌋)) n = 0 := by + let f : ℕ → ℤ := fun j => ⌊P.eval (j : ℝ)⌋ + let r : ℕ → ℝ := fun j => Int.fract (P.eval (j : ℝ)) - a + have heq : (fun j : ℕ => (f j : ℝ)) = fun j : ℕ => P.eval (j : ℝ) - a - r j := by + funext j + dsimp [f,r] + rw [Int.fract] + ring + have hz : (Δ_[1] ^[q+1] (fun j : ℕ => P.eval (j : ℝ))) n = 0 := by + rw [fwdDiff_eval_nat] + rw [Polynomial.fwdDiff_iter_eq_zero_of_degree_lt (by omega : P.natDegree < q+1)] + rfl + have hb := abs_fwdDiff_le r hε (q+1) n (fun j hj => hfrac (n+j) (by omega)) + have hh : ((Δ_[1] ^[q+1] f n : ℤ) : ℝ) = -(Δ_[1] ^[q+1] r) n := by + rw [← fwdDiff_cast, heq, fwdDiff_sub, fwdDiff_sub, hz, + fwdDiff_constant a (by omega)] + ring + have hlt : |((Δ_[1] ^[q+1] f n : ℤ) : ℝ)| < 1 := by + rw [hh, abs_neg] + exact hb.trans_lt hsmall + have hle : -1 < (Δ_[1] ^[q+1] f n : ℤ) ∧ (Δ_[1] ^[q+1] f n : ℤ) < 1 := by + exact_mod_cast abs_lt.mp hlt + change (Δ_[1] ^[q+1] f) n = 0 + omega + + + +lemma higher_difference_zero (f : ℕ → ℤ) {k N : ℕ} + (hf : ∀ n, n+k ≤ N → (Δ_[1] ^[k] f) n = 0) + {j : ℕ} (hkj : k ≤ j) (hj : j ≤ N) : + (Δ_[1] ^[j] f) 0 = 0 := by + have hh : ∀ l n : ℕ, n+(k+l) ≤ N → (Δ_[1] ^[k+l] f) n = 0 := by + intro l + induction l with + | zero => simpa using hf + | succ l ih => + intro n hn + rw [show k+(l+1) = (k+l)+1 by omega, iterate_succ_apply'] + change (Δ_[1] ^[k+l] f) (n+1) - (Δ_[1] ^[k+l] f) n = 0 + rw [ih (n+1) (by omega), ih n (by omega), sub_self] + simpa [Nat.add_sub_of_le hkj] using hh (j-k) 0 (by omega) + + +def newtonPolynomial (q : ℕ) (f : ℕ → ℤ) : ℚ[X] := + ∑ k ∈ range (q+1), + C (((Δ_[1] ^[k] f) 0 : ℤ) / (k.factorial : ℚ)) * descPochhammer ℚ k + +lemma newtonPolynomial_eval (q : ℕ) (f : ℕ → ℤ) (n : ℕ) : + (newtonPolynomial q f).eval (n : ℚ) = + ∑ k ∈ range (q+1), (n.choose k : ℚ) * ((Δ_[1] ^[k] f) 0 : ℤ) := by + simp only [newtonPolynomial, eval_finsetSum, eval_mul, eval_C] + apply sum_congr rfl + intro k hk + rw [Nat.cast_choose_eq_descPochhammer_div] + ring + +lemma newtonPolynomial_degree (q : ℕ) (f : ℕ → ℤ) : + (newtonPolynomial q f).natDegree ≤ q := by + apply natDegree_sum_le_of_forall_le + intro k hk + exact (natDegree_C_mul_le _ _).trans (by simpa using (show k ≤ q by + have := mem_range.mp hk; omega)) + + +theorem newtonPolynomial_agrees (f : ℕ → ℤ) {q N : ℕ} + (hf : ∀ n, n+q+1 ≤ N → (Δ_[1] ^[q+1] f) n = 0) + {n : ℕ} (hn : n ≤ N) : + (newtonPolynomial q f).eval (n : ℚ) = (f n : ℚ) := by + have hNewton := shift_eq_sum_fwdDiff_iter (1 : ℕ) f n 0 + simp only [nsmul_eq_mul, Nat.cast_id, mul_one, zero_add] at hNewton + rw [newtonPolynomial_eval, hNewton] + push_cast + by_cases hnq : n ≤ q + · symm + apply sum_subset (range_mono (by omega : n+1 ≤ q+1)) + intro k hk hkn + have hnk : n < k := by simp only [mem_range] at hkn; omega + simp [Nat.choose_eq_zero_of_lt hnk] + · apply sum_subset (range_mono (by omega : q+1 ≤ n+1)) + intro k hk hkq + have hqk : q+1 ≤ k := by simp only [mem_range] at hkq; omega + have hkN : k ≤ N := (Nat.le_of_lt_succ (mem_range.mp hk)).trans hn + rw [higher_difference_zero f (fun a ha => hf a (by omega)) hqk hkN] + simp + + + +theorem newtonPolynomial_factorial_denominator (q : ℕ) (f : ℕ → ℤ) : + C (q.factorial : ℚ) * newtonPolynomial q f ∈ lifts (algebraMap ℤ ℚ) := by + rw [newtonPolynomial, mul_sum] + apply (lifts (algebraMap ℤ ℚ)).sum_mem + intro k hk + have hkq : k ≤ q := by have := mem_range.mp hk; omega + obtain ⟨l,hl⟩ := Nat.factorial_dvd_factorial hkq + have heq : (q.factorial : ℚ) * (((Δ_[1] ^[k] f) 0 : ℤ) / (k.factorial : ℚ)) = + (((l : ℤ)*((Δ_[1] ^[k] f) 0) : ℤ) : ℚ) := by + rw [hl, Nat.cast_mul, Int.cast_mul, Int.cast_natCast] + have hne : (k.factorial : ℚ) ≠ 0 := by exact_mod_cast k.factorial_ne_zero + field_simp + rw [← mul_assoc, ← C_mul, heq] + apply base_mul_mem_lifts + exact (mem_lifts _).mpr ⟨descPochhammer ℤ k, by simp⟩ + + + +theorem constant_coefficient_rationalization (P : ℝ[X]) {q N : ℕ} + (hP : P.natDegree ≤ q) {a ε : ℝ} (hε : 0 ≤ ε) + (hsmall : 2^(q+1)*ε < 1) + (hfrac : ∀ n ≤ N, |Int.fract (P.eval (n : ℝ))-a| ≤ ε) : + ∃ M : ℚ[X], M.natDegree ≤ q ∧ + C (q.factorial : ℚ)*M ∈ lifts (algebraMap ℤ ℚ) ∧ + (∀ n ≤ N, M.eval (n : ℚ) = (⌊P.eval (n : ℝ)⌋ : ℤ)) ∧ + ∀ n ≤ N, 0 ≤ P.eval (n : ℝ)-(M.map (algebraMap ℚ ℝ)).eval (n : ℝ) ∧ + P.eval (n : ℝ)-(M.map (algebraMap ℚ ℝ)).eval (n : ℝ) < 1 := by + let f : ℕ → ℤ := fun n => ⌊P.eval (n : ℝ)⌋ + let M := newtonPolynomial q f + have heval (n : ℕ) (hn : n ≤ N) : M.eval (n : ℚ) = (f n : ℚ) := + newtonPolynomial_agrees f (fun n hn => + floor_difference_zero P hP hε hsmall hfrac hn) hn + refine ⟨M, newtonPolynomial_degree q f, + newtonPolynomial_factorial_denominator q f, heval, ?_⟩ + intro n hn + have hc : (M.map (algebraMap ℚ ℝ)).eval (n : ℝ) = (f n : ℝ) := by + have h := congrArg (algebraMap ℚ ℝ) (heval n hn) + rw [eval_map] + rw [show (n : ℝ) = algebraMap ℚ ℝ (n : ℚ) by simp] + rw [eval₂_at_apply] + simpa only [eq_ratCast, Rat.cast_intCast] using h + rw [hc] + exact ⟨sub_nonneg.mpr (Int.floor_le _), Int.fract_lt_one _⟩ + + + +theorem finite_van_der_waerden (r H : ℕ) : + ∃ N : ℕ, ∀ χ : Fin (N+1) → Fin r, + ∃ a b : ℕ, 0 < b ∧ ∃ hbound : a+b*H ≤ N, + ∀ j : Fin (H+1), χ ⟨a+b*j.val, Nat.lt_succ_of_le + ((Nat.add_le_add_left (Nat.mul_le_mul_left b + (Nat.le_of_lt_succ j.isLt)) a).trans hbound)⟩ = + χ ⟨a, Nat.lt_succ_of_le ((Nat.le_add_right _ _).trans hbound)⟩ := by + classical + let : TopologicalSpace (Fin r) := ⊥ + let : DiscreteTopology (Fin r) := ⟨rfl⟩ + let O := ℕ × {b : ℕ // 0 < b} + let U (o : O) : Set (ℕ → Fin r) := + {χ | ∀ j : Fin (H+1), χ (o.1+o.2.val*j.val) = χ o.1} + have hopen (o : O) : IsOpen (U o) := by + rw [show U o = ⋂ j : Fin (H+1), {χ : ℕ → Fin r | + χ (o.1+o.2.val*j.val) = χ o.1} by ext χ; simp [U]] + apply isOpen_iInter_of_finite + intro j + change IsOpen ((fun χ : ℕ → Fin r => (χ (o.1+o.2.val*j.val), χ o.1)) ⁻¹' + {z : Fin r × Fin r | z.1 = z.2}) + exact (isOpen_discrete {z : Fin r × Fin r | z.1 = z.2}).preimage + ((continuous_apply (o.1+o.2.val*j.val)).prodMk (continuous_apply o.1)) + have hcover : (Set.univ : Set (ℕ → Fin r)) ⊆ ⋃ o, U o := by + intro χ _ + obtain ⟨b,hb,a,c,hc⟩ := Combinatorics.exists_mono_homothetic_copy + (range (H+1)) χ + have ha : χ a = c := by simpa using hc 0 (mem_range.mpr (by omega)) + refine Set.mem_iUnion.mpr ⟨(a,⟨b,hb⟩),?_⟩ + intro j + have hj := hc j.val (mem_range.mpr j.isLt) + simpa [nsmul_eq_mul, Nat.add_comm, ha] using hj + obtain ⟨T,hT⟩ := isCompact_univ.elim_finite_subcover U hopen hcover + let N : ℕ := T.sup (fun o => o.1+o.2.val*H) + refine ⟨N,?_⟩ + intro χ + let c : ℕ → Fin r := fun n => if hn : n ≤ N then χ ⟨n,by omega⟩ else χ ⟨0,by omega⟩ + obtain ⟨o,ho,hco⟩ := Set.mem_iUnion₂.mp (hT (Set.mem_univ c)) + have hbound : o.1+o.2.val*H ≤ N := le_sup (f := fun o : O => o.1+o.2.val*H) ho + refine ⟨o.1,o.2.val,o.2.property,hbound,?_⟩ + intro j + have ha : o.1 ≤ N := (Nat.le_add_right _ _).trans hbound + have hj : o.1+o.2.val*j.val ≤ N := + (Nat.add_le_add_left (Nat.mul_le_mul_left _ (Nat.le_of_lt_succ j.isLt)) _).trans hbound + simpa only [c, dite_eq_left ha, dite_eq_left hj] using hco j + +lemma fractional_cell_bound {K : ℕ} (hK : 0 < K) (x : ℝ) : + |Int.fract x - (⌊(K : ℝ)*Int.fract x⌋₊ : ℝ)/(K : ℝ)| ≤ 1/(K : ℝ) := by + have hKr : (0 : ℝ) < K := by exact_mod_cast hK + have h0 : 0 ≤ (K : ℝ)*Int.fract x := mul_nonneg hKr.le (Int.fract_nonneg x) + have hl := Nat.floor_le h0 + have hu := Nat.lt_floor_add_one ((K : ℝ)*Int.fract x) + have hl' : (⌊(K : ℝ)*Int.fract x⌋₊ : ℝ)/(K : ℝ) ≤ Int.fract x := + (div_le_iff₀ hKr).mpr (by simpa [mul_comm] using hl) + rw [abs_of_nonneg (sub_nonneg.mpr hl')] + have hu' : Int.fract x < ((⌊(K : ℝ)*Int.fract x⌋₊ : ℝ)+1)/(K : ℝ) := + (lt_div_iff₀ hKr).mpr (by simpa [mul_comm] using hu) + calc + _ ≤ ((⌊(K : ℝ)*Int.fract x⌋₊ : ℝ)+1)/(K : ℝ)- + (⌊(K : ℝ)*Int.fract x⌋₊ : ℝ)/(K : ℝ) := sub_le_sub_right hu'.le _ + _ = 1/(K : ℝ) := by ring + + + +theorem constant_coefficient_after_thinning (q H : ℕ) : + ∃ N : ℕ, ∀ P : ℝ[X], P.natDegree ≤ q → + ∃ a b : ℕ, 0 < b ∧ b ≤ N ∧ a+b*H ≤ N ∧ + ∃ M : ℚ[X], M.natDegree ≤ q ∧ + C (q.factorial : ℚ)*M ∈ lifts (algebraMap ℤ ℚ) ∧ + ∀ n ≤ H, M.eval (n : ℚ) = (⌊P.eval ((a+b*n : ℕ) : ℝ)⌋ : ℤ) := by + classical + let K : ℕ := 2^(q+3) + have hK : 0 < K := by dsimp [K]; positivity + have hKr : (0 : ℝ) < K := by exact_mod_cast hK + obtain ⟨N,hN⟩ := finite_van_der_waerden K (H+1) + refine ⟨N,?_⟩ + intro P hP + let χ : Fin (N+1) → Fin K := fun n => + ⟨⌊(K : ℝ)*Int.fract (P.eval (n.val : ℝ))⌋₊, (Nat.floor_lt + (mul_nonneg hKr.le (Int.fract_nonneg _))).mpr (by + simpa using mul_lt_mul_of_pos_left (Int.fract_lt_one (P.eval (n.val : ℝ))) hKr)⟩ + obtain ⟨a,b,hb,hab,hm⟩ := hN χ + have haN : a < N+1 := by omega + let c : ℕ := (χ ⟨a,haN⟩).val + let T : ℝ[X] := P.comp (C (a : ℝ)+C (b : ℝ)*X) + have hT : T.natDegree ≤ q := by + have hlin : (C (a : ℝ)+C (b : ℝ)*X).natDegree ≤ 1 := + natDegree_add_le_of_degree_le (by simp) ((natDegree_C_mul_le _ _).trans (by simp)) + exact natDegree_comp_le.trans ((Nat.mul_le_mul_left _ hlin).trans (by simpa using hP)) + have heval (n : ℕ) : T.eval (n : ℝ) = P.eval ((a+b*n : ℕ) : ℝ) := by + simp [T, Nat.cast_add, Nat.cast_mul] + have hfrac : ∀ n ≤ H, |Int.fract (T.eval (n : ℝ))-(c : ℝ)/(K : ℝ)| ≤ 1/(K : ℝ) := by + intro n hn + have hn' : n < H+1+1 := by omega + have hh := congrArg Fin.val (hm ⟨n,hn'⟩) + change ⌊(K : ℝ)*Int.fract (P.eval ((a+b*n : ℕ) : ℝ))⌋₊ = c at hh + simpa only [heval, hh] using fractional_cell_bound hK (P.eval ((a+b*n : ℕ) : ℝ)) + have hsmall : (2 : ℝ)^(q+1)*(1/(K : ℝ)) < 1 := by + rw [mul_one_div, div_lt_one hKr] + dsimp [K] + rw [Nat.cast_pow, Nat.cast_ofNat] + exact pow_lt_pow_right₀ (by norm_num) (by omega) + obtain ⟨M,hM,hden,heq,_⟩ := constant_coefficient_rationalization T hT + (by positivity : (0 : ℝ) ≤ 1/(K : ℝ)) hsmall hfrac + refine ⟨a,b,hb,?_,?_,M,hM,hden,?_⟩ + · nlinarith + · nlinarith + · intro n hn + simpa only [heval] using heq n hn + +end +end ConstantCoefficientRationalization + + +end +end +end + +end OAI diff --git a/lean/OAI/Combinatorics/SumProduct/Alignment/CoordinateSubspace01.lean b/lean/OAI/Combinatorics/SumProduct/Alignment/CoordinateSubspace01.lean new file mode 100644 index 0000000000000000000000000000000000000000..0ea93512fc4e5444b91e0d9dab4d8b3faf1bf60a --- /dev/null +++ b/lean/OAI/Combinatorics/SumProduct/Alignment/CoordinateSubspace01.lean @@ -0,0 +1,346 @@ +import Mathlib +import OAI.Combinatorics.SumProduct.Alignment.CompactConvex01 +import OAI.Geometry.NilpotentCharts.Main + +namespace OAI + +section +section +section +section +open Topology +open scoped Pointwise +open Topology Set +open MeasureTheory Set Topology +open MeasureTheory Topology Set +namespace RationalNilmanifoldMeasure +open MeasureTheory Topology Set +open scoped commutatorElement +variable {G : Type*} [Group G] [TopologicalSpace G] [IsTopologicalGroup G] + [T2Space G] [SecondCountableTopology G] + + + +omit [TopologicalSpace G] [IsTopologicalGroup G] [T2Space G] [SecondCountableTopology G] in +lemma nilpotent_of_series (n : ℕ) (H : ℕ → Subgroup G) + (h0 : H 0 = ⊤) (hn : H n = ⊥) + (hc : ∀ i (g x : G), x ∈ H i → ⁅g,x⁆ ∈ H (i+1)) : Group.IsNilpotent G := by + apply (Subgroup.nilpotent_iff_finite_descending_central_series G).mpr + refine ⟨n,H,⟨h0,?_⟩,hn⟩ + intro x i hx g + simpa only [commutatorElement_inv] using (H (i+1)).inv_mem (hc i g x hx) + + + +theorem existsUnique_invariant (n : ℕ) (Γ : Subgroup G) (H : ℕ → Subgroup G) + (h0 : H 0 = ⊤) (hn : H n = ⊥) + (hc : ∀ i (g x : G), x ∈ H i → ⁅g,x⁆ ∈ H (i+1)) + (hr : ∀ i, CompactGroupProducts.HasCompactReps (H i) Γ) + (hΓ : IsDiscrete (Γ : Set G)) + [MeasurableSpace (G ⧸ Γ)] [BorelSpace (G ⧸ Γ)] : + ∃! μ : ProbabilityMeasure (G ⧸ Γ), SMulInvariantMeasure G (G ⧸ Γ) (μ : Measure (G ⧸ Γ)) := by + let : Group.IsNilpotent G := nilpotent_of_series n H h0 hn hc + let : DiscreteTopology Γ := isDiscrete_iff_discreteTopology.mp hΓ + let : IsClosed (Γ : Set G) := Subgroup.isClosed_of_discreteTopology + have hG : CompactGroupProducts.HasCompactReps ⊤ Γ := by simpa only [h0] using hr 0 + let : CompactSpace (G ⧸ Γ) := hG.quotient_compactSpace + obtain ⟨μ,hμ⟩ := SolvableInvariantMeasure.exists_invariant_measure (G := G) (X := G ⧸ Γ) + refine ⟨μ,hμ,?_⟩ + intro ν hν + let := hμ + let := hν + apply ProbabilityMeasure.toMeasure_injective + exact invariant_unique_of_series n Γ H h0 hn hc hr hΓ ν μ + +end RationalNilmanifoldMeasure + +end + + + +section +noncomputable section +namespace RationalLattice +open MeasureTheory +variable {G : Type*} [Group G] [TopologicalSpace G] [IsTopologicalGroup G] {n : ℕ} +variable (c : RealCoordinates G n) (Γ : Subgroup G) +variable (hΓ : ∀ g : G, g ∈ Γ ↔ ∀ i, ∃ z : ℤ, c.coord g i = z) + +include hΓ in + + +theorem existsUnique_coordinateHaar [MeasurableSpace (G ⧸ Γ)] [BorelSpace (G ⧸ Γ)] : + ∃! μ : ProbabilityMeasure (G ⧸ Γ), + SMulInvariantMeasure G (G ⧸ Γ) (μ : Measure (G ⧸ Γ)) := by + let : T2Space G := c.coord.symm.t2Space + let : SecondCountableTopology G := c.coord.secondCountableTopology + let : DiscreteTopology Γ := integerCoordinates_discrete c Γ hΓ + exact RationalNilmanifoldMeasure.existsUnique_invariant n Γ (coordinateTail c) + (coordinateTail_zero c) (coordinateTail_end c n le_rfl) + (coordinateTail_commutator c) (coordinateTail_compact_reps c Γ hΓ) + (isDiscrete_iff_discreteTopology.mpr inferInstance) + +end RationalLattice +end +end + + + +section +noncomputable section +namespace PairTail +open RationalLattice MeasureTheory +variable {G : Type*} [Group G] [TopologicalSpace G] [IsTopologicalGroup G] +variable {t d r : ℕ} (c : RealCoordinates G (t+d)) +variable (K : Subgroup G) [K.Normal] +variable (hK : ∀ g : G, g ∈ K ↔ ∀ i : Fin (t+d), i.val < t → c.coord g i = 0) +variable (hr : r ≤ t+d) (N : Subgroup G) [N.Normal] +variable (hN : ∀ g : G, g ∈ N ↔ ∀ i : Fin (t+d), i.val < r → c.coord g i = 0) +variable (hcent : N ≤ Subgroup.center G) +variable [(diagonal K N).Normal] + + +def squareLattice (Γ : Subgroup G) : Subgroup (square K) := + (Γ.prod Γ).comap (square K).subtype +omit [TopologicalSpace G] [IsTopologicalGroup G] in +@[simp] lemma mem_squareLattice (Γ : Subgroup G) (x : square K) : + x ∈ squareLattice K Γ ↔ x.val.1 ∈ Γ ∧ x.val.2 ∈ Γ := Iff.rfl + +def reducedLattice (Γ : Subgroup G) : Subgroup (square K ⧸ diagonal K N) := + (squareLattice K Γ).map (QuotientGroup.mk' (diagonal K N)) + +variable (Γ : Subgroup G) +variable (hΓ : ∀ g : G, g ∈ Γ ↔ ∀ i, ∃ z : ℤ, c.coord g i = z) + +include hΓ in + + +omit [N.Normal] in +theorem reducedLattice_iff (x : square K ⧸ diagonal K N) : + x ∈ reducedLattice K N Γ ↔ ∀ i, ∃ z : ℤ, + (reducedCoordinates c K hK hr N hN hcent).coord x i = z := by + constructor + · rintro ⟨y,hy,rfl⟩ i + refine Fin.addCases (fun j => ?_) (fun j => ?_) i + · change ∃ z : ℤ, chartHomeomorph c K hK hr N hN hcent (QuotientGroup.mk y) (j.castAdd d) = z + rw [chart_base] + exact (hΓ y.val.1).mp hy.1 (MalcevPrefixQuotient.embed hr j) + · change ∃ z : ℤ, chartHomeomorph c K hK hr N hN hcent (QuotientGroup.mk y) (j.natAdd r) = z + rw [chart_tail] + exact (hΓ (y.val.1⁻¹*y.val.2)).mp (Γ.mul_mem (Γ.inv_mem hy.1) hy.2) + (RationalTailCoordinates.embed t j) + · intro hx + let X := (reducedCoordinates c K hK hr N hN hcent).coord x + let a := MalcevPrefixQuotient.represent c (fun i : Fin r => X (i.castAdd d)) + let u := RationalTailCoordinates.rebuild c K hK (fun i : Fin d => X (i.natAdd r)) + have ha : a ∈ Γ := by + apply (hΓ a).mpr + intro i + simp only [a,MalcevPrefixQuotient.represent,Homeomorph.apply_symm_apply, + MalcevPrefixQuotient.lift] + split_ifs with hi + · exact hx (Fin.castAdd d ⟨i.val,hi⟩) + · exact ⟨0,by simp⟩ + have hu : u.val ∈ Γ := by + apply (hΓ u.val).mpr + intro i + simp only [u,RationalTailCoordinates.rebuild,Homeomorph.apply_symm_apply, + RationalTailCoordinates.lift] + split_ifs with hi + · exact hx (Fin.natAdd r ⟨i.val-t,by have := i.isLt; omega⟩) + · exact ⟨0,by simp⟩ + refine ⟨pair K a u,⟨ha,Γ.mul_mem ha hu⟩,?_⟩ + change (QuotientGroup.mk (pair K a u) : square K ⧸ diagonal K N) = x + have he := chart_rebuild_base c K hK hr N hN hcent X + simpa only [a,u,X,reducedCoordinates,Homeomorph.symm_apply_apply] using he.symm + +include hΓ hK hN hr hcent in +omit [N.Normal] in +theorem reducedLattice_discrete : DiscreteTopology (reducedLattice K N Γ) := + integerCoordinates_discrete (reducedCoordinates c K hK hr N hN hcent) + (reducedLattice K N Γ) (reducedLattice_iff c K hK hr N hN hcent Γ hΓ) + +include hΓ hK hN hr hcent in +omit [N.Normal] in +theorem reducedHaar_existsUnique + [MeasurableSpace ((square K ⧸ diagonal K N) ⧸ reducedLattice K N Γ)] + [BorelSpace ((square K ⧸ diagonal K N) ⧸ reducedLattice K N Γ)] : + ∃! μ : ProbabilityMeasure ((square K ⧸ diagonal K N) ⧸ reducedLattice K N Γ), + SMulInvariantMeasure (square K ⧸ diagonal K N) + ((square K ⧸ diagonal K N) ⧸ reducedLattice K N Γ) (μ : Measure _) := + existsUnique_coordinateHaar (reducedCoordinates c K hK hr N hN hcent) + (reducedLattice K N Γ) (reducedLattice_iff c K hK hr N hN hcent Γ hΓ) + +end PairTail +end +end + + + +section +noncomputable section +namespace CoordinateSubspace +open RationalLattice RationalPolynomialMap +variable {G : Type*} [Group G] [TopologicalSpace G] +variable {n d : ℕ} (c : RealCoordinates G n) (e : Fin d ↪o Fin n) + +def lift (x : Fin d → ℝ) (j : Fin n) : ℝ := + if h : j ∈ Set.range e then x h.choose else 0 + +@[simp] lemma lift_embed (x : Fin d → ℝ) (i : Fin d) : lift e x (e i) = x i := by + unfold lift + split_ifs with h + · congr 1 + exact e.injective h.choose_spec + · exact (h ⟨i,rfl⟩).elim + +lemma lift_outside (x : Fin d → ℝ) (j : Fin n) (hj : j ∉ Set.range e) : + lift e x j = 0 := by simp [lift,hj] + +lemma lift_continuous : Continuous (lift e) := by + apply continuous_pi + intro j + unfold lift + split_ifs + · exact continuous_apply _ + · exact continuous_const + +lemma lift_polynomial (j : Fin n) : IsPolynomial (fun x => lift e x j) := by + unfold lift + split_ifs + · exact coordinate _ + · exact zero + +variable (H : Subgroup G) +variable (hH : ∀ g : G, g ∈ H ↔ ∀ j : Fin n, j ∉ Set.range e → c.coord g j = 0) + +def coordinates (g : H) (i : Fin d) : ℝ := c.coord g.val (e i) + +include hH in +lemma coord_lift (g : H) : lift e (coordinates c e H g) = c.coord g.val := by + funext j + by_cases hj : j ∈ Set.range e + · obtain ⟨i,rfl⟩ := hj + exact lift_embed e _ i + · rw [lift_outside e _ j hj,(hH g.val).mp g.property j hj] + +def rebuild (x : Fin d → ℝ) : H := + ⟨c.coord.symm (lift e x), (hH _).mpr (by + intro j hj + rw [Homeomorph.apply_symm_apply,lift_outside e x j hj])⟩ + +@[simp] lemma coordinates_rebuild (x : Fin d → ℝ) : + coordinates c e H (rebuild c e H hH x) = x := by + funext i + simpa only [coordinates,rebuild,Homeomorph.apply_symm_apply] using lift_embed e x i + +@[simp] lemma rebuild_coordinates (g : H) : + rebuild c e H hH (coordinates c e H g) = g := by + apply Subtype.ext + apply c.coord.injective + simpa only [rebuild,Homeomorph.apply_symm_apply] using coord_lift c e H hH g + +def subspaceHomeomorph : H ≃ₜ (Fin d → ℝ) where + toFun := coordinates c e H + invFun := rebuild c e H hH + left_inv := rebuild_coordinates c e H hH + right_inv := coordinates_rebuild c e H hH + continuous_toFun := continuous_pi (fun _ => + (continuous_apply _).comp (c.coord.continuous.comp continuous_subtype_val)) + continuous_invFun := (c.coord.symm.continuous.comp (lift_continuous e)).subtype_mk _ + +def lowerLift (i : Fin d) (x : Fin i.val → ℝ) (a : Fin (e i).val) : ℝ := + if h : ∃ j : Fin i.val, (e ⟨j.val,lt_trans j.isLt i.isLt⟩).val = a.val + then x h.choose else 0 + +lemma lowerLift_polynomial (i : Fin d) (a : Fin (e i).val) : + IsPolynomial (fun x => lowerLift e i x a) := by + unfold lowerLift + split_ifs + · exact coordinate _ + · exact zero + +include hH in +lemma lowerLift_coordinates (i : Fin d) (g : H) (a : Fin (e i).val) : + lowerLift e i (fun j => coordinates c e H g ⟨j.val,lt_trans j.isLt i.isLt⟩) a = + c.coord g.val ⟨a.val,lt_trans a.isLt (e i).isLt⟩ := by + unfold lowerLift + split_ifs with h + · change c.coord g.val (e _) = _ + exact congrArg (c.coord g.val) (Fin.ext h.choose_spec) + · symm + apply (hH g.val).mp g.property + rintro ⟨j,hj⟩ + have hji : j < i := e.lt_iff_lt.mp (by + rw [hj] + exact a.isLt) + apply h + exact ⟨⟨j.val,hji⟩, congrArg Fin.val hj⟩ + +lemma correction_exists (i : Fin d) : + ∃ P : MvPolynomial (Fin i.val ⊕ Fin i.val) ℚ, + ∀ v : (Fin i.val ⊕ Fin i.val) → ℝ, + MvPolynomial.eval₂ (algebraMap ℚ ℝ) + (Sum.elim (lowerLift e i (fun j => v (.inl j))) + (lowerLift e i (fun j => v (.inr j)))) (c.correction (e i)) = + MvPolynomial.eval₂ (algebraMap ℚ ℝ) v P := by + apply RationalPolynomialMap.eval + intro a + cases a with + | inl a => + exact RationalPolynomialMap.comp (lowerLift_polynomial e i a) (fun j => coordinate (Sum.inl j)) + | inr a => + exact RationalPolynomialMap.comp (lowerLift_polynomial e i a) (fun j => coordinate (Sum.inr j)) + +def correction (i : Fin d) : MvPolynomial (Fin i.val ⊕ Fin i.val) ℚ := + (correction_exists c e i).choose + +include hH in +lemma mul_coord (g h : H) (i : Fin d) : + coordinates c e H (g*h) i = coordinates c e H g i + coordinates c e H h i + + MvPolynomial.eval₂ (algebraMap ℚ ℝ) + (Sum.elim (fun j : Fin i.val => coordinates c e H g ⟨j.val,lt_trans j.isLt i.isLt⟩) + (fun j : Fin i.val => coordinates c e H h ⟨j.val,lt_trans j.isLt i.isLt⟩)) + (correction c e i) := by + unfold correction + rw [← (correction_exists c e i).choose_spec] + change c.coord (g.val*h.val) (e i) = _ + rw [c.mul_coord] + congr 2 + funext a + cases a with + | inl a => exact (lowerLift_coordinates c e H hH i g a).symm + | inr a => exact (lowerLift_coordinates c e H hH i h a).symm + + + +def restrictedCoordinates : RealCoordinates H d where + coord := subspaceHomeomorph c e H hH + one_coord i := c.one_coord (e i) + correction := correction c e + mul_coord := mul_coord c e H hH + +lemma restricted_lattice (Γ : Subgroup G) + (hΓ : ∀ g, g ∈ Γ ↔ ∀ i, ∃ z : ℤ, c.coord g i = z) (g : H) : + g ∈ Γ.comap H.subtype ↔ ∀ i, ∃ z : ℤ, + (restrictedCoordinates c e H hH).coord g i = z := by + constructor + · intro hg i + exact (hΓ g.val).mp hg (e i) + · intro hg + apply (hΓ g.val).mpr + intro j + by_cases hj : j ∈ Set.range e + · obtain ⟨i,rfl⟩ := hj + exact hg i + · exact ⟨0,by simpa using (hH g.val).mp g.property j hj⟩ + +end CoordinateSubspace + +end +end +end +end +end + +end OAI diff --git a/lean/OAI/Combinatorics/SumProduct/Alignment/CorrectedBox01.lean b/lean/OAI/Combinatorics/SumProduct/Alignment/CorrectedBox01.lean new file mode 100644 index 0000000000000000000000000000000000000000..0eb3aa704f1f171ea4c6195e231b2cdc8001a20f --- /dev/null +++ b/lean/OAI/Combinatorics/SumProduct/Alignment/CorrectedBox01.lean @@ -0,0 +1,267 @@ +import Mathlib +import OAI.Combinatorics.SumProduct.Alignment.DenseBox01 +import OAI.Geometry.NilpotentCharts.Main + +namespace OAI + +section +section +section +section +noncomputable section +end +end + + + +section +noncomputable section +open scoped BigOperators +open _root_.Polynomial _root_.OAI.Polynomial +namespace CorrectedBoxLeibman +abbrev Grid := IntegerGridInterpolation.Grid + +def realBasis (s : ℕ) (t : Fin (s+1)) : ℝ[X] := + Lagrange.basis Finset.univ (fun j : Fin (s+1) => (j.val:ℝ)) t + +lemma nat_nodes_injective (s : ℕ) : Set.InjOn (fun j : Fin (s+1) => (j.val:ℝ)) + (↑(Finset.univ : Finset (Fin (s+1))) : Set (Fin (s+1))) := by + intro a _ b _ h + apply Fin.ext + exact_mod_cast (show (a.val : ℝ) = (b.val : ℝ) from h) + +lemma realBasis_degree (s : ℕ) (t : Fin (s+1)) : (realBasis s t).natDegree ≤ s := by + simp only [realBasis,Lagrange.natDegree_basis (nat_nodes_injective s) (Finset.mem_univ t), + Finset.card_univ,Fintype.card_fin,Nat.add_sub_cancel_right,le_refl] + +lemma interpolate_real (s : ℕ) (P : ℝ[X]) (hP : P.natDegree ≤ s) (x : ℝ) : + P.eval x = ∑ t : Fin (s+1), P.eval (t.val:ℝ)*(realBasis s t).eval x := by + have hd : P.degree < (Finset.univ : Finset (Fin (s+1))).card := by + apply lt_of_le_of_lt Polynomial.degree_le_natDegree + simp only [Finset.card_univ, Fintype.card_fin, Nat.cast_lt] + exact Nat.lt_succ_of_le hP + have he := congrArg (fun P : ℝ[X] => P.eval x) + (Lagrange.eq_interpolate (nat_nodes_injective s) hd) + simpa only [Lagrange.interpolate_apply,eval_finsetSum,eval_mul,eval_C,realBasis] using he + + + +def gridEval {v s : ℕ} (a : Grid v s→ℝ) (x : Fin v→ℝ) : ℝ := + ∑ e, a e*∏ i, x i^(e i).val + + +def LinePolynomial (v s : ℕ) (f : (Fin v→ℤ)→ℝ) : Prop := + ∀ x q : Fin v→ℤ, ∃ P : ℝ[X], P.natDegree ≤ s ∧ + ∀ z : ℤ, P.eval (z:ℝ)=f (fun i => x i+z*q i) + +lemma tensor_interpolation (v s : ℕ) (f : (Fin v→ℤ)→ℝ) (hf : LinePolynomial v s f) + (x : Fin v→ℤ) : + f x = ∑ t : Grid v s, f (fun i => ((t i).val:ℤ))* + ∏ i, (realBasis s (t i)).eval (x i:ℝ) := by + classical + induction v with + | zero => + simp only [Fintype.prod_empty, mul_one, Fintype.sum_unique] + congr 1 + ext i + exact Fin.elim0 i + | succ v ih => + let b : Fin (v+1)→ℤ := Fin.cons 0 (fun i => x i.succ) + let q : Fin (v+1)→ℤ := Fin.cons 1 (fun _ => 0) + obtain ⟨P,hP,he⟩ := hf b q + have hline (z : ℤ) : P.eval (z:ℝ)=f (Fin.cons z (fun i => x i.succ)) := by + rw [he] + congr 1 + ext i + refine Fin.cases ?_ (fun j => ?_) i <;> simp [b,q] + have hhead : f x=∑ t : Fin (s+1), f (Fin.cons (t.val:ℤ) (fun i => x i.succ))* + (realBasis s t).eval (x 0:ℝ) := by + have ht := interpolate_real s P hP (x 0:ℝ) + rw [hline] at ht + simp_rw [← Int.cast_natCast (R:=ℝ),hline] at ht + have hx : Fin.cons (x 0) (fun i => x i.succ)=x := by + ext i + exact Fin.cases rfl (fun _ => rfl) i + rw [hx] at ht + exact ht + rw [hhead] + have htail (t : Fin (s+1)) : LinePolynomial v s (fun y => f (Fin.cons (t.val:ℤ) y)) := by + intro y z + obtain ⟨Q,hQ,hQe⟩ := hf (Fin.cons (t.val:ℤ) y) (Fin.cons 0 z) + refine ⟨Q,hQ,?_⟩ + intro a + rw [hQe] + congr 1 + ext i + refine Fin.cases ?_ (fun j => ?_) i <;> simp + simp_rw [ih _ (htail _) (fun i => x i.succ),Finset.sum_mul] + rw [← Fintype.sum_prod_type' ] + apply Fintype.sum_equiv (Fin.consEquiv (fun _ : Fin (v+1) => Fin (s+1))) + intro p + simp only [Fin.consEquiv_apply,Fin.prod_univ_succ,Fin.cons_zero,Fin.cons_succ] + have heq : (fun i => (((Fin.cons p.1 p.2 : Fin (v+1)→Fin (s+1)) i).val:ℤ))= + Fin.cons (p.1.val:ℤ) (fun i => ((p.2 i).val:ℤ)) := by + ext i + exact Fin.cases rfl (fun _ => rfl) i + rw [heq] + ring + + + +theorem exists_grid_expansion (v s : ℕ) (f : (Fin v→ℤ)→ℝ) (hf : LinePolynomial v s f) : + ∃ a : Grid v s→ℝ, ∀ x : Fin v→ℤ, gridEval a (fun i => (x i:ℝ))=f x := by + classical + let a : Grid v s→ℝ := fun e => ∑ t : Grid v s, f (fun i => ((t i).val:ℤ))* + ∏ i, (realBasis s (t i)).coeff (e i).val + refine ⟨a,?_⟩ + intro x + rw [tensor_interpolation v s f hf x] + have hexp (t : Fin (s+1)) (y : ℝ) : + (realBasis s t).eval y=∑ j : Fin (s+1), (realBasis s t).coeff j.val*y^j.val := by + rw [Polynomial.eval_eq_sum_range' (Nat.lt_succ_of_le (realBasis_degree s t))] + exact (Fin.sum_univ_eq_sum_range _ _).symm + simp_rw [hexp] + simp_rw [Fintype.prod_sum] + simp_rw [Finset.mul_sum] + rw [Finset.sum_comm] + apply Finset.sum_congr rfl + intro e _ + dsimp only [a] + rw [Finset.sum_mul] + apply Finset.sum_congr rfl + intro t _ + rw [Finset.prod_mul_distrib] + ring + + + +theorem character_grid_expansion {G : Type*} [Group G] (H : CubeFaces.Filtration G) + (s : ℕ) (hs : H.level (s+1)=⊥) {v : ℕ} {f : (Fin v→ℤ)→G} + (hf : LeibmanSquare.Polynomial H 0 f) (χ : G→*Multiplicative ℝ) : + ∃ a : Grid v s→ℝ, ∀ x : Fin v→ℤ, + gridEval a (fun i => (x i:ℝ))=(χ (f x)).toAdd := by + apply exists_grid_expansion + intro x q + exact LeibmanSquare.character_polynomial H s hs + (LeibmanSquare.polynomial_integer_line H hf x q) χ + +end CorrectedBoxLeibman +end +end + + + +section +noncomputable section +open scoped BigOperators +open _root_.Polynomial _root_.OAI.Polynomial +namespace CorrectedBoxLeibman + + +def lineCoefficient {v s : ℕ} (f : (Fin v→ℤ)→ℝ) (q : Fin v→ℤ) (j : ℕ) + (x : Fin v→ℤ) : ℝ := + ∑ t : Fin (s+1), f (fun i => x i+(t.val:ℤ)*q i)*(realBasis s t).coeff j + +lemma lineCoefficient_eq {v s : ℕ} {f : (Fin v→ℤ)→ℝ} (x q : Fin v→ℤ) + (P : ℝ[X]) (hP : P.natDegree ≤ s) + (he : ∀ z : ℤ, P.eval (z:ℝ)=f (fun i => x i+z*q i)) (j : ℕ) : + lineCoefficient (s:=s) f q j x=P.coeff j := by + have hd : P.degree < (Finset.univ : Finset (Fin (s+1))).card := by + apply lt_of_le_of_lt Polynomial.degree_le_natDegree + simp only [Finset.card_univ,Fintype.card_fin,Nat.cast_lt] + exact Nat.lt_succ_of_le hP + have hh := congrArg (fun Q : ℝ[X] => Q.coeff j) + (Lagrange.eq_interpolate (nat_nodes_injective s) hd) + simp only [Lagrange.interpolate_apply,finsetSum_coeff,coeff_C_mul] at hh + symm + change P.coeff j=∑ t : Fin (s+1), _ + convert hh using 1 + apply Finset.sum_congr rfl + intro t _ + rw [← Int.cast_natCast (R:=ℝ),he] + rfl + +lemma lineCoefficient_polynomial {v s : ℕ} {f : (Fin v→ℤ)→ℝ} + (hf : LinePolynomial v s f) (q : Fin v→ℤ) (j : ℕ) : + LinePolynomial v s (lineCoefficient (s:=s) f q j) := by + classical + intro x z + have hp (t : Fin (s+1)) := hf (fun i => x i+(t.val:ℤ)*q i) z + choose P hP he using hp + refine ⟨∑ t : Fin (s+1), C ((realBasis s t).coeff j)*P t,?_,?_⟩ + · apply natDegree_sum_le_of_forall_le + intro t _ + exact (natDegree_C_mul_le _ _).trans (hP t) + · intro a + simp only [eval_finsetSum,eval_mul,eval_C,lineCoefficient] + apply Finset.sum_congr rfl + intro t _ + rw [he] + have hh : (fun i => x i+(t.val:ℤ)*q i+a*z i)= + (fun i => x i+a*z i+(t.val:ℤ)*q i) := by ext i; ring + rw [hh,mul_comm] + +lemma gridEval_zero {v s : ℕ} (a : Grid v s→ℝ) : gridEval a 0=a 0 := by + classical + rw [gridEval,Finset.sum_eq_single 0] + · simp + · intro e _ he + obtain ⟨i,hi⟩ := Function.ne_iff.mp he + have hp : ∏ j, (0:ℝ)^(e j).val=0 := by + apply Finset.prod_eq_zero (Finset.mem_univ i) + apply zero_pow + intro h + apply hi + exact Fin.ext h + simp only [Pi.zero_apply,hp,mul_zero] + · simp + + + +theorem dense_line_constant (v s : ℕ) (δ : ℝ) (hδ : 0<δ) : + ∃ C N₀ : ℕ, 0 (x i:ℤ)))≤ε) → + δ*(N:ℝ)^v≤(BoxCounting.count v N S:ℝ) → + ∃ r : ℕ, 0 (x i:ℤ)) := by + simpa only [DenseBoxModularPolynomial.eval,gridEval,Int.cast_natCast] using ha (fun i => (x i:ℤ)) + have hnear (x : Fin v→ℕ) (hx : x∈S) : ∃ z : ℤ, + |DenseBoxModularPolynomial.eval a x-z|≤ε := by + refine ⟨round (DenseBoxModularPolynomial.eval a x),?_⟩ + have h := hgood x hx + rw [TriangularLatticeRecovery.circleNorm,UnitAddCircle.norm_eq,← hae] at h + exact h + obtain ⟨r,hr,hrC,hrb⟩ := hinv N hN ε hε hεsmall S a hnear hcount + have hz : a 0=lineCoefficient (s:=s) f q j 0 := by + have hh := ha (0 : Fin v→ℤ) + have hzero : (fun i : Fin v => ((0 : Fin v→ℤ) i:ℝ))=0 := by ext i; simp + rwa [hzero,gridEval_zero] at hh + refine ⟨r,hr,hrC,?_⟩ + have hh := hrb 0 + simpa only [PolynomialLineCoefficients.totalDegree,Pi.zero_apply,Fin.val_zero, + Finset.sum_const_zero,pow_zero,mul_one,hz] using hh + +end CorrectedBoxLeibman +end +end + + + + +end +end +end + +end OAI diff --git a/lean/OAI/Combinatorics/SumProduct/Alignment/CorrectedBox02.lean b/lean/OAI/Combinatorics/SumProduct/Alignment/CorrectedBox02.lean new file mode 100644 index 0000000000000000000000000000000000000000..3612d46f4a354fbf7cd8f0e5a2ef856c475829e7 --- /dev/null +++ b/lean/OAI/Combinatorics/SumProduct/Alignment/CorrectedBox02.lean @@ -0,0 +1,302 @@ +import Mathlib +import OAI.Combinatorics.SumProduct.Alignment.CorrectedBox01 +import OAI.Geometry.NilpotentCharts.Main + +namespace OAI + +section +section +section +section +noncomputable section +open scoped BigOperators +open _root_.Polynomial _root_.OAI.Polynomial +namespace CorrectedBoxLeibman +open PolynomialLineCoefficients + +def originPolynomial {v s : ℕ} (a : Grid v s→ℝ) (q : Fin v→ℕ) : ℝ[X] := + ∑ e, C (a e*∏ i, (q i:ℝ)^(e i).val)*X^(totalDegree e) + +lemma originPolynomial_eval {v s : ℕ} (a : Grid v s→ℝ) (q : Fin v→ℕ) (z : ℤ) : + (originPolynomial a q).eval (z:ℝ)=gridEval a (fun i => (z:ℝ)*(q i:ℝ)) := by + classical + simp only [originPolynomial,eval_finsetSum,eval_mul,eval_C,eval_pow,eval_X,gridEval] + apply Finset.sum_congr rfl + intro e _ + simp only [mul_pow,Finset.prod_mul_distrib,totalDegree] + rw [Finset.prod_pow_eq_pow_sum] + ring + +lemma originPolynomial_coeff {v s : ℕ} (a : Grid v s→ℝ) (q : Fin v→ℕ) (j : ℕ) : + (originPolynomial a q).coeff j= + ∑ e, (if totalDegree e=j then a e else 0)*∏ i, (q i:ℝ)^(e i).val := by + classical + simp only [originPolynomial,finsetSum_coeff,coeff_C_mul,coeff_X_pow] + apply Finset.sum_congr rfl + intro e _ + split_ifs <;> simp_all + + + +theorem lineCoefficient_origin {v s : ℕ} {f : (Fin v→ℤ)→ℝ} + (hf : LinePolynomial v s f) (a : Grid v s→ℝ) + (ha : ∀ x : Fin v→ℤ, gridEval a (fun i => (x i:ℝ))=f x) + (q : Fin v→ℕ) (j : ℕ) : + lineCoefficient (s:=s) f (fun i => (q i:ℤ)) j 0= + ∑ e, (if totalDegree e=j then a e else 0)*∏ i, (q i:ℝ)^(e i).val := by + obtain ⟨P,hP,he⟩ := hf 0 (fun i => (q i:ℤ)) + have hOP : originPolynomial a q=P := by + apply Polynomial.eq_of_eval_nat_eq + intro n + rw [← Int.cast_natCast (R:=ℝ),originPolynomial_eval,he] + have hha := ha (fun i => (0 : Fin v→ℤ) i+(n:ℤ)*(q i:ℤ)) + simpa only [Pi.zero_apply,zero_add,Int.cast_mul,Int.cast_natCast] using hha + rw [lineCoefficient_eq 0 (fun i => (q i:ℤ)) P hP he,← hOP,originPolynomial_coeff] + +lemma lineCoefficient_above {v s : ℕ} {f : (Fin v→ℤ)→ℝ} + (hf : LinePolynomial v s f) (x q : Fin v→ℤ) {j : ℕ} (hj : s (x i:ℤ)))≤A/(H:ℝ)^j) → + ρ*(N:ℝ)^v≤(BoxCounting.count v N S:ℝ) → + ∃ r : ℕ, 0 hgood x hx j.val hj) hcount + refine ⟨r,hr,hrC,fun _ => ?_⟩ + have hh := mul_le_mul_of_nonneg_right hrb (pow_nonneg hHR.le j.val) + have heq : (C:ℝ)*(A/(H:ℝ)^j.val)*(H:ℝ)^j.val=(C:ℝ)*A := by + field_simp + rwa [heq] at hh + · exact ⟨1,by omega,by omega,fun h => (hj h).elim⟩ + choose r hr hrC hrb using hchoice + let R := ∏ j : Fin (s+1), r j + have hR : 0 hr j) + have hRC : R≤C^(s+1) := by + calc + R ≤ ∏ _ : Fin (s+1), C := Finset.prod_le_prod₀ (fun _ _ => Nat.zero_le _) (fun j _ => hrC j) + _ = _ := by simp + refine ⟨R,hR,hRC,?_⟩ + intro j hj + by_cases hjs : j ≤ s + · let k : Fin (s+1) := ⟨j,Nat.lt_succ_of_le hjs⟩ + have hd : r k ∣ R := Finset.dvd_prod_of_mem r (Finset.mem_univ k) + have heR : (R:ℝ)=((R/r k:ℕ):ℝ)*(r k:ℝ) := by exact_mod_cast (Nat.div_mul_cancel hd).symm + rw [heR,mul_assoc] + calc + _ ≤ (((R/r k:ℕ):ℝ)*circleNorm ((r k:ℝ)*lineCoefficient (s:=s) f q j 0))*(H:ℝ)^j := + mul_le_mul_of_nonneg_right (circleNorm_nat_mul _ _) (pow_nonneg hHR.le _) + _ = ((R/r k:ℕ):ℝ)*(circleNorm ((r k:ℝ)*lineCoefficient (s:=s) f q j 0)*(H:ℝ)^j) := by ring + _ ≤ ((R/r k:ℕ):ℝ)*((C:ℝ)*A) := mul_le_mul_of_nonneg_left (hrb k hj) (Nat.cast_nonneg _) + _ ≤ (C:ℝ)^(s+1)*((C:ℝ)*A) := by + apply mul_le_mul_of_nonneg_right _ (mul_nonneg (Nat.cast_nonneg _) hA) + exact_mod_cast (Nat.div_le_self R (r k)).trans hRC + _ = _ := by rw [← mul_assoc,← pow_succ] + · rw [lineCoefficient_above hf 0 q (Nat.lt_of_not_ge hjs),mul_zero,circleNorm_zero,zero_mul] + positivity + +end CorrectedBoxLeibman +end +end + + + +section +noncomputable section +open scoped BigOperators +namespace CorrectedBoxLeibman +open PolynomialWeyl BoxPolynomialLines TriangularLatticeRecovery + +lemma count_finset_image {v N : ℕ} (B : Finset (Fin v→Fin N)) : + BoxCounting.count v N ((fun x : Fin v→Fin N => fun i => (x i).val) '' (B : Set (Fin v→Fin N)))=B.card := by + classical + unfold BoxCounting.count + congr 1 + ext x + simp only [Finset.mem_filter,Finset.mem_univ,true_and,Set.mem_image,Finset.mem_coe] + constructor + · rintro ⟨y,hy,he⟩ + have : y=x := by funext i; exact Fin.ext (congrFun he i) + exact this ▸ hy + · intro hx + exact ⟨x,hx,rfl⟩ + + + +theorem dense_basepoint_characters {v s N H : ℕ} (hN : 0 F (fun i => (x i).val+z*q i))-I‖ → + ∃ ξ∈U, ∀ j : ℕ, 0 (q i:ℤ)) j (fun i => ((x i).val:ℤ)))≤A/(H:ℝ)^j) : + ∃ ξ∈U, ∃ S : Set (Fin v→ℕ), + (δ/8)/((U.card:ℝ)+1)*(N:ℝ)^v≤(BoxCounting.count v N S:ℝ) ∧ + ∀ x∈S, ∀ j : ℕ, 0 (q i:ℤ)) j (fun i => (x i:ℤ)))≤A/(H:ℝ)^j := by + classical + let g : (Fin v→ℕ)→ℂ := fun x => (F x-I)/2 + have hg (x) : ‖g x‖≤1 := by + dsimp [g] + rw [norm_div] + norm_num + have hh := norm_sub_le (F x) I + linarith [hF x] + have heq : boxMean v N g=(boxMean v N F-I)/2 := by + rw [BoxCounting.boxMean_eq_fin,BoxCounting.boxMean_eq_fin] + simp only [g,← Finset.expect_div,Finset.expect_sub_distrib] + have hn : (Finset.univ : Finset (Fin v→Fin N)).Nonempty := by + let : NeZero N := ⟨ne_of_gt hN⟩ + exact Finset.univ_nonempty + rw [Finset.expect_const hn] + have hnorm : δ/2≤‖boxMean v N g‖ := by + rw [heq,norm_div] + norm_num + linarith + have hdense := dense_correlated_lines v hN hH g hg q (δ/2) (by positivity) hnorm (by linarith) + let B := Finset.univ.filter (fun x : Fin v→Fin N => δ/4≤‖mean H (fun z => g (fun i => (x i).val+z*q i))‖) + have hB : δ/8*(N:ℝ)^v≤(B.card:ℝ) := by + simpa only [B,show δ/2/4=δ/8 by ring,show δ/2/2=δ/4 by ring] using hdense + let P (x : Fin v→Fin N) (ξ : α) := ∀ j : ℕ, 0 (q i:ℤ)) j (fun i => ((x i).val:ℤ)))≤A/(H:ℝ)^j + have hget (x) (hx : x∈B) : ∃ ξ∈U, P x ξ := by + apply hprod x + have hh := (Finset.mem_filter.mp hx).2 + have hem : mean H (fun z => g (fun i => (x i).val+z*q i))= + (mean H (fun z => F (fun i => (x i).val+z*q i))-I)/2 := by + simp only [mean,g,← Finset.expect_div,Finset.expect_sub_distrib] + rw [Finset.expect_const (Finset.nonempty_range_iff.mpr (ne_of_gt hH))] + rw [hem,norm_div] at hh + norm_num at hh + linarith + obtain ⟨B',hB'B,hB'ne,hB'c,ξ,hξ,hξB⟩ := SquareInduction.finite_dense_choice_general U B + (δ/8) ((N:ℝ)^v) (by positivity) (pow_pos (Nat.cast_pos.mpr hN) _) hB P hget + refine ⟨ξ,hξ,(fun x : Fin v→Fin N => fun i => (x i).val) '' (B' : Set (Fin v→Fin N)),?_,?_⟩ + · rwa [count_finset_image] + · rintro x ⟨y,hy,rfl⟩ j hj + exact hξB y hy j hj + +end CorrectedBoxLeibman +end +end + + + +section +noncomputable section +open _root_.Polynomial _root_.OAI.Polynomial +open scoped BigOperators +namespace CorrectedBoxLeibman +open CubeFaces CubePolynomials LeibmanSquare RationalLattice MalcevCharacters +open MeasureTheory PolynomialWeyl AbelianMalcevTorus RationalTailCoordinates UnitAddTorus +open SquareInduction TriangularLatticeRecovery BoxPolynomialLines +variable {G : Type} [Group G] [TopologicalSpace G] [IsTopologicalGroup G] +variable {t d : ℕ} (c : RealCoordinates G (t+d)) (hsk : SecondKind c) +variable (H : Filtration G) (h0 : H.level 0=⊤) (h1 : H.level 1=⊤) +variable [∀ i, (H.level i).Normal] +variable (s : ℕ) (hs : H.level (s+1)=⊥) +variable (q : ℕ→ℕ) (hqbound : ∀ k, q k ≤ t+d) (hq2 : q 2=t) +variable (hq : ∀ k (g : G), g∈H.level k ↔ ∀ i : Fin (t+d), i.val F (QuotientGroup.mk (f (fun i => (x i:ℤ)))))-(∫ y,F y ∂μ)‖ → + ∀ z : Fin v→ℕ, 2*(M:ℝ)*(∑ i,z i:ℕ)/N≤δ/8 → + ∃ ξ∈U, ∃ S : Set (Fin v→ℕ), + (δ/8)/((U.card:ℝ)+1)*(N:ℝ)^v≤(BoxCounting.count v N S:ℝ) ∧ + ∀ x∈S, ∀ j : ℕ, 0 (ξ (f x)).toAdd) (fun i => (z i:ℤ)) j + (fun i => (x i:ℤ)))≤A/(M:ℝ)^j := by + classical + let : CompactSpace (G⧸Γ) := metric_compact c Γ hΓ mtr htop + let : BorelSpace (G⧸Γ) := metric_borelSpace Γ mtr htop + obtain ⟨U,A,hA,hprod⟩ := degree_general_metric_producer c hsk H h0 h1 s hs + q hqbound hq Γ hΓ htop μ (δ/2) (by positivity) + let V := U.filter (fun ξ : G→*Multiplicative ℝ => ξ≠1 ∧ Continuous ξ ∧ ∀ g∈Γ, ∃ z : ℤ, (ξ g).toAdd=z) + refine ⟨V,A,hA,fun ξ hξ => (Finset.mem_filter.mp hξ).2,?_⟩ + intro N M hN hM f hf F hFL hFn hd z hz + have hFn' (x : Fin v→ℕ) : ‖F (QuotientGroup.mk (f (fun i => (x i:ℤ))))‖≤1 := + (F.norm_coe_le_norm _).trans hFn + have hI : ‖∫ y,F y ∂μ‖≤1 := by + apply le_trans _ hFn + simpa only [probReal_univ,mul_one] using norm_integral_le_of_norm_le_const (μ:=μ) + (Filter.Eventually.of_forall F.norm_coe_le_norm) + apply dense_basepoint_characters hN hM V A δ hδ _ hFn' _ hI hd z hz + (fun ξ x => (ξ (f x)).toAdd) + intro x hx + let g : ℤ→G := fun n => f (fun i => ((x i).val:ℤ)+n*(z i:ℤ)) + have hg := polynomial_integer_line H hf (fun i => ((x i).val:ℤ)) (fun i => (z i:ℤ)) + have hdisc : δ/2≤‖FourierObstruction.discrepancy μ M (fun k => QuotientGroup.mk (g k)) F‖ := by + convert hx using 1 + simp only [FourierObstruction.discrepancy,g,Nat.cast_add,Nat.cast_mul] + rfl + obtain ⟨ξ,hξ,hξne,hξc,hξZ,P,hP,hPe,hPb⟩ := hprod M hM g hg ⟨F,hFL,hFn,hdisc⟩ + refine ⟨ξ,Finset.mem_filter.mpr ⟨hξ,hξne,hξc,hξZ⟩,?_⟩ + intro j hj + rw [lineCoefficient_eq _ _ P hP hPe j] + obtain ⟨k,hk⟩ := hPb j hj + exact (DenseBoxModularPolynomial.circleNorm_le_integer_error _ k).trans hk + +end CorrectedBoxLeibman + +end +end +end +end +end + +end OAI diff --git a/lean/OAI/Combinatorics/SumProduct/Alignment/CorrectedBox03.lean b/lean/OAI/Combinatorics/SumProduct/Alignment/CorrectedBox03.lean new file mode 100644 index 0000000000000000000000000000000000000000..6294f6fe5c8535b7f1067d7afaf4d4967bc71610 --- /dev/null +++ b/lean/OAI/Combinatorics/SumProduct/Alignment/CorrectedBox03.lean @@ -0,0 +1,345 @@ +import Mathlib +import OAI.Combinatorics.SumProduct.Alignment.BoxPolynomial01 +import OAI.Geometry.NilpotentCharts.Main + +namespace OAI + +section +section +section +section +noncomputable section +open _root_.Polynomial _root_.OAI.Polynomial +open scoped BigOperators +end +end + + + +section +noncomputable section +open scoped BigOperators +namespace CorrectedBoxLeibman + + + +theorem choose_short_scale (v L N₀ : ℕ) (δ ε A : ℝ) (hδ : 0<δ) (hε : 0<ε) (hA : 0≤A) : + ∃ T N₁ : ℕ, 0 Nat.le_of_lt (q i).isLt) + _ = _ := by simp + have hratio : ((N/T:ℕ):ℝ)/(N:ℝ)≤1/(T:ℝ) := by + apply (div_le_div_iff₀ hNr hTr).mpr + simpa only [one_mul,Nat.cast_mul] using (show ((N/T:ℕ):ℝ)*(T:ℝ)≤N by exact_mod_cast hHN) + calc + _ = (2*(∑ i,(q i).val:ℕ):ℝ)*(((N/T:ℕ):ℝ)/(N:ℝ)) := by push_cast; ring + _ ≤ (2*(∑ i,(q i).val:ℕ):ℝ)*(1/(T:ℝ)) := + mul_le_mul_of_nonneg_left hratio (by positivity) + _ ≤ (2*((v*L:ℕ):ℝ))*(1/(T:ℝ)) := by + apply mul_le_mul_of_nonneg_right _ (by positivity) + exact_mod_cast Nat.mul_le_mul_left 2 hsum + _ ≤ δ/8 := by + rw [one_div,← div_eq_mul_inv] + apply (div_le_iff₀ hTr).mpr + push_cast + nlinarith only [hTb] + +end CorrectedBoxLeibman +end +end + + + +section +noncomputable section +open scoped BigOperators +namespace CorrectedBoxLeibman +open MvPolynomial +variable {v : ℕ} {E : Type*} [Fintype E] [DecidableEq E] + +def monomialVector (m : E→(Fin v→₀ℕ)) (x : Fin v→ℚ) : E→ℚ := + fun e => (m e).prod (fun i k => x i^k) + +def monomialPolynomial (m : E→(Fin v→₀ℕ)) (a : E→ℚ) : MvPolynomial (Fin v) ℚ := + ∑ e, monomial (m e) (a e) + +lemma monomialPolynomial_coeff (m : E→(Fin v→₀ℕ)) (hm : Function.Injective m) + (a : E→ℚ) (e : E) : + (monomialPolynomial m a).coeff (m e)=a e := by + classical + simp only [monomialPolynomial,coeff_sum,coeff_monomial] + simp only [hm.eq_iff] + simp + +omit [DecidableEq E] in +lemma monomialPolynomial_eval (m : E→(Fin v→₀ℕ)) (a : E→ℚ) (x : Fin v→ℚ) : + eval x (monomialPolynomial m a)=∑ e, a e*monomialVector m x e := by + simp [monomialPolynomial,monomialVector,eval_monomial] + + + +theorem dense_monomial_unique (m : E→(Fin v→₀ℕ)) (hm : Function.Injective m) + (D : ℕ) (hD : ∀ e, (m e).sum (fun _ k => k)≤D) + (S : Finset ℚ) (Q : Finset (Fin v→ℚ)) + (hQ : Q⊆Fintype.piFinset (fun _ => S)) + (hdense : (D:ℚ≥0)/(S.card:ℚ≥0) < (Q.card:ℚ≥0)/(S.card:ℚ≥0)^v) + (a : E→ℚ) (ha : ∀ x∈Q, ∑ e, a e*monomialVector m x e=0) : a=0 := by + classical + let P := monomialPolynomial m a + have hdeg : P.totalDegree≤D := by + apply MvPolynomial.totalDegree_finsetSum_le + intro e _ + exact (totalDegree_monomial_le _ _).trans (hD e) + have hz : P=0 := by + by_contra hp + have hbound := schwartz_zippel_totalDegree (n:=v) hp S + have hsub : Q⊆(Fintype.piFinset (fun _ : Fin v => S)).filter (fun x => eval x P=0) := by + intro x hx + exact Finset.mem_filter.mpr ⟨hQ hx, (monomialPolynomial_eval m a x).trans (ha x hx)⟩ + have hc : (Q.card:ℚ≥0) ≤ ((Fintype.piFinset (fun _ : Fin v => S)).filter + (fun x => eval x P=0)).card := by exact_mod_cast Finset.card_le_card hsub + have hc' := div_le_div_of_nonneg_right hc (by positivity : (0:ℚ≥0)≤(S.card:ℚ≥0)^v) + have hd' : (P.totalDegree:ℚ≥0)/(S.card:ℚ≥0)≤(D:ℚ≥0)/(S.card:ℚ≥0) := + div_le_div_of_nonneg_right (by exact_mod_cast hdeg) (by positivity) + exact (not_lt_of_ge (hc'.trans (hbound.trans hd'))) hdense + funext e + have hh := monomialPolynomial_coeff m hm a e + change P.coeff (m e)=a e at hh + simpa only [hz,AddMonoidAlgebra.coeff_zero,Finsupp.zero_apply,Pi.zero_apply] using hh.symm + +lemma linear_form_coordinates (l : (E→ℚ)→ₗ[ℚ]ℚ) (x : E→ℚ) : + l x = ∑ e, x e*l (Pi.single e 1) := by + classical + have he : x=∑ e, x e • (Pi.single e (1:ℚ) : E→ℚ) := by + ext i + simp [Finset.sum_apply,Pi.single_apply] + conv_lhs => rw [he] + simp + + + +theorem dense_monomial_span (m : E→(Fin v→₀ℕ)) (hm : Function.Injective m) + (D : ℕ) (hD : ∀ e, (m e).sum (fun _ k => k)≤D) + (S : Finset ℚ) (Q : Finset (Fin v→ℚ)) + (hQ : Q⊆Fintype.piFinset (fun _ => S)) + (hdense : (D:ℚ≥0)/(S.card:ℚ≥0) < (Q.card:ℚ≥0)/(S.card:ℚ≥0)^v) : + Submodule.span ℚ (Set.range (fun x : Q => monomialVector m x.val))=⊤ := by + classical + by_contra hne + obtain ⟨l,hl,hker⟩ := Submodule.exists_le_ker_of_lt_top + (Submodule.span ℚ (Set.range (fun x : Q => monomialVector m x.val))) (lt_top_iff_ne_top.mpr hne) + let a : E→ℚ := fun e => l (Pi.single e 1) + have ha : a=0 := by + apply dense_monomial_unique m hm D hD S Q hQ hdense a + intro x hx + have he : l (monomialVector m x)=0 := hker (Submodule.subset_span ⟨⟨x,hx⟩,rfl⟩) + rw [linear_form_coordinates] at he + simpa only [a,mul_comm] using he + apply hl + apply LinearMap.ext + intro x + change l x=0 + rw [linear_form_coordinates] + change (∑ e, x e*a e)=0 + rw [ha] + simp + +end CorrectedBoxLeibman +end +end + + + +section +noncomputable section +open scoped BigOperators +namespace CorrectedBoxLeibman +variable {E V : Type*} [Fintype E] [DecidableEq E] [Fintype V] + + + +lemma integer_weights_of_span (M : V→E→ℤ) + (hspan : Submodule.span ℚ (Set.range (fun v : V => fun e => (M v e:ℚ)))=⊤) : + ∃ B : ℕ, 0 (M v f:ℚ))=Pi.single e 1 := by + apply (Submodule.mem_span_range_iff_exists_fun ℚ).mp + rw [hspan] + trivial + choose a ha using hex + obtain ⟨B,hB,w,hw⟩ := IntegerGridInterpolation.clear_denominators (fun p : E×V => a p.1 p.2) + refine ⟨B,hB,fun e v => w (e,v),?_⟩ + intro e f + have hid : ∑ v, a e v*(M v f:ℚ)=if e=f then 1 else 0 := by + have hh := congrFun (ha e) f + simpa [Finset.sum_apply,Pi.single_apply,eq_comm] using hh + have hidR : ∑ v, (a e v:ℝ)*(M v f:ℝ)=if e=f then 1 else 0 := by + have hh := congrArg (fun z : ℚ => (z:ℝ)) hid + push_cast at hh + split_ifs at hh ⊢ <;> simpa using hh + have hwR (v : V) : (w (e,v):ℝ)=(B:ℝ)*(a e v:ℝ) := by + exact_mod_cast (hw (e,v)).symm + simp_rw [hwR,mul_assoc] + rw [← Finset.mul_sum,hidR] + split_ifs <;> simp + + + +lemma homogeneous_recovery (deg : E→ℕ) (M : V→E→ℤ) (B : ℕ) (w : E→V→ℤ) + (hw : ∀ e f, ∑ v, (w e v:ℝ)*(M v f:ℝ)=if e=f then (B:ℝ) else 0) + (a : E→ℝ) (X A : ℝ) (hX : 0≤X) + (hline : ∀ v j, 0 + mul_le_mul_of_nonneg_left (hline v (deg e) he) (abs_nonneg _)) + _ = _ := (Finset.sum_mul _ _ _).symm + +end CorrectedBoxLeibman +end +end + + + +section +noncomputable section +open scoped BigOperators +namespace CorrectedBoxLeibman +variable {v : ℕ} {E : Type*} [Fintype E] [DecidableEq E] + +omit [Fintype E] [DecidableEq E] in +lemma monomialVector_eq_prod (m : E→(Fin v→₀ℕ)) (x : Fin v→ℚ) (e : E) : + monomialVector m x e=∏ i, x i^(m e i) := by + exact Finsupp.prod_fintype _ _ (by simp) + +def gridMonomial (m : E→(Fin v→₀ℕ)) {L : ℕ} (x : Fin v→Fin L) (e : E) : ℤ := + ∏ i, ((x i).val:ℤ)^(m e i) + + + +theorem dense_grid_integer_weights (m : E→(Fin v→₀ℕ)) (hm : Function.Injective m) + (D : ℕ) (hD : ∀ e, (m e).sum (fun _ k => k)≤D) + (L : ℕ) (Q : Finset (Fin v→Fin L)) + (hdense : (D:ℚ≥0)/(L:ℚ≥0) < (Q.card:ℚ≥0)/(L:ℚ≥0)^v) : + ∃ B : ℕ, 0 ((x i).val:ℚ) + have hc : Function.Injective c := by + intro x y h + funext i + apply Fin.ext + have hi := congrFun h i + exact_mod_cast (show ((x i).val:ℚ)=((y i).val:ℚ) from hi) + let S := (Finset.univ : Finset (Fin L)).image (fun i => (i.val:ℚ)) + let QR := Q.image c + have hS : S.card=L := by + rw [Finset.card_image_of_injective] + · exact Fintype.card_fin L + · intro a b h + apply Fin.ext + exact_mod_cast (show (a.val:ℚ)=(b.val:ℚ) from h) + have hQR : QR.card=Q.card := Finset.card_image_of_injective Q hc + have hsub : QR⊆Fintype.piFinset (fun _ => S) := by + intro x hx + obtain ⟨y,hy,rfl⟩ := Finset.mem_image.mp hx + apply Fintype.mem_piFinset.mpr + intro i + exact Finset.mem_image.mpr ⟨y i,Finset.mem_univ _,rfl⟩ + have hspan := dense_monomial_span m hm D hD S QR hsub (by simpa only [hS,hQR] using hdense) + apply integer_weights_of_span + apply top_unique + rw [← hspan] + apply Submodule.span_mono + rintro y ⟨x,rfl⟩ + obtain ⟨z,hz,hzx⟩ := Finset.mem_image.mp x.property + refine ⟨⟨z,hz⟩,?_⟩ + ext e + change (gridMonomial m z e:ℚ)=monomialVector m x.val e + rw [monomialVector_eq_prod,← hzx] + simp only [gridMonomial,Int.cast_prod,Int.cast_pow,Int.cast_natCast,c] + + + +theorem uniform_dense_grid_weights (m : E→(Fin v→₀ℕ)) (hm : Function.Injective m) + (D : ℕ) (hD : ∀ e, (m e).sum (fun _ k => k)≤D) (L : ℕ) : + ∃ K : ℕ, 0 B Q+∑ e, ∑ x : Q.val, (w Q e x).natAbs + let K := 1+∑ Q : T, k Q + have hK : 0 Nat.zero_le _) (Finset.mem_univ t)).trans + (Nat.le_add_left _ _) + refine ⟨B t,hB t,?_,w t,hw t,?_⟩ + · exact (Nat.le_add_right _ _).trans hk + · intro e + have he : (∑ x : Q, (w t e x).natAbs)≤k t := by + apply le_trans (Finset.single_le_sum (fun _ _ => Nat.zero_le _) (Finset.mem_univ e)) + exact Nat.le_add_left _ _ + have h := he.trans hk + have hR : ((∑ x : Q, (w t e x).natAbs : ℕ):ℝ)≤K := by exact_mod_cast h + have habs (z : ℤ) : (z.natAbs:ℝ)=|(z:ℝ)| := by + simpa only [Int.cast_natCast,Int.cast_abs] using congrArg (fun z : ℤ => (z:ℝ)) (Int.natCast_natAbs z) + simpa only [Nat.cast_sum,habs] using hR + +end CorrectedBoxLeibman + +end +end +end +end +end + +end OAI diff --git a/lean/OAI/Combinatorics/SumProduct/Alignment/CorrectedBox04.lean b/lean/OAI/Combinatorics/SumProduct/Alignment/CorrectedBox04.lean new file mode 100644 index 0000000000000000000000000000000000000000..5792640d03897739cdeeadff515ca4aac3f4361c --- /dev/null +++ b/lean/OAI/Combinatorics/SumProduct/Alignment/CorrectedBox04.lean @@ -0,0 +1,309 @@ +import Mathlib +import OAI.Combinatorics.SumProduct.Alignment.CorrectedBox02 +import OAI.Combinatorics.SumProduct.Alignment.CorrectedBox03 +import OAI.Geometry.NilpotentCharts.Main + +namespace OAI + +section +section +section +section +noncomputable section +open scoped BigOperators +end +end + + + +section +noncomputable section +open scoped BigOperators +namespace CorrectedBoxLeibman +open TriangularLatticeRecovery +variable {v : ℕ} {E α : Type*} [Fintype E] [DecidableEq E] + + + +theorem direction_character_recovery (m : E→(Fin v→₀ℕ)) (hm : Function.Injective m) + (D : ℕ) (hD : ∀ e, (m e).sum (fun _ k => k)≤D) + (U : Finset α) (B : ℕ) (hB : 0 k)=j then a ξ e else 0)* + (gridMonomial m q e:ℝ))*X^j≤A) → + ∃ ξ∈U, ∃ r : ℕ, 0 k) → + circleNorm ((r:ℝ)*a ξ e)*X^((m e).sum (fun _ k => k))≤(K:ℝ)*A := by + classical + let T := U ×ˢ Finset.range (B+1) + let Z := T.card+1 + let L := D*Z+1 + have hL : 0 k)=j then a p.1 e else 0)* + (gridMonomial m q e:ℝ))*X^j≤A + have hget' (q : Fin v→Fin L) (_ : q∈Finset.univ) : ∃ p∈T, P q p := by + obtain ⟨ξ,hξ,r,hr,hrB,hb⟩ := hget q + exact ⟨(ξ,r),Finset.mem_product.mpr ⟨hξ,Finset.mem_range.mpr (Nat.lt_succ_of_le hrB)⟩,hr,hb⟩ + obtain ⟨Q,hQU,hQne,hQc,p,hp,hP⟩ := SquareInduction.finite_dense_choice_general T + (Finset.univ : Finset (Fin v→Fin L)) 1 ((L:ℝ)^v) (by norm_num) (pow_pos (Nat.cast_pos.mpr hL) _) + (by simp) P hget' + have hcountNat : L^v≤Q.card*Z := by + have hZr : 0<(Z:ℝ) := Nat.cast_pos.mpr hZ + have hQc' : (L:ℝ)^v/(Z:ℝ)≤(Q.card:ℝ) := by + simpa only [Z,Nat.cast_add,Nat.cast_one,one_div,one_mul,mul_comm,div_eq_mul_inv] using hQc + have hh := (div_le_iff₀ hZr).mp hQc' + exact_mod_cast hh + have hLn : (0:ℚ≥0) k)=j then (p.2:ℝ)*a p.1 f else 0)* + (gridMonomial m q.val f:ℝ))*X^j≤A := by + have hh := (hP q.val q.property).2 j hj + have heq : (∑ f, (if (m f).sum (fun _ k => k)=j then (p.2:ℝ)*a p.1 f else 0)* + (gridMonomial m q.val f:ℝ))=(p.2:ℝ)* + ∑ f, (if (m f).sum (fun _ k => k)=j then a p.1 f else 0)*(gridMonomial m q.val f:ℝ) := by + rw [Finset.mul_sum] + apply Finset.sum_congr rfl + intro f _ + split_ifs <;> ring + rwa [heq] + have hh := homogeneous_recovery (fun e => (m e).sum (fun _ k => k)) + (fun q : Q => gridMonomial m q.val) b w hw (fun e => (p.2:ℝ)*a p.1 e) X A hX hline e he + have hBK : (K:ℝ)≤(B*K:ℕ) := by exact_mod_cast Nat.le_mul_of_pos_left K hB + have hfin := hh.trans ((mul_le_mul_of_nonneg_right (hwK e) hA).trans + (mul_le_mul_of_nonneg_right hBK hA)) + simpa only [Nat.cast_mul,mul_assoc] using hfin + +end CorrectedBoxLeibman +end +end + + + +section +noncomputable section +open scoped BigOperators +namespace CorrectedBoxLeibman + +def gridExponent {v s : ℕ} (e : Grid v s) : Fin v→₀ℕ := Finsupp.equivFunOnFinite.symm (fun i => (e i).val) + +@[simp] lemma gridExponent_apply {v s : ℕ} (e : Grid v s) (i : Fin v) : gridExponent e i=(e i).val := rfl +lemma gridExponent_injective (v s : ℕ) : Function.Injective (gridExponent (v:=v) (s:=s)) := by + intro e f h + funext i + apply Fin.ext + exact congrArg (fun g : Fin v→₀ℕ => g i) h +lemma gridExponent_degree {v s : ℕ} (e : Grid v s) : + (gridExponent e).sum (fun _ k => k)=PolynomialLineCoefficients.totalDegree e := by + rw [Finsupp.sum_fintype] + · rfl + · simp +lemma gridMonomial_eq_prod {v s L : ℕ} (q : Fin v→Fin L) (e : Grid v s) : + (gridMonomial gridExponent q e:ℝ)=∏ i, ((q i).val:ℝ)^(e i).val := by + simp only [gridMonomial,Int.cast_prod,Int.cast_pow,Int.cast_natCast,gridExponent_apply] +end CorrectedBoxLeibman +end +end + + + +section +noncomputable section +open scoped BigOperators +namespace CorrectedBoxLeibman +open TriangularLatticeRecovery PolynomialLineCoefficients + +lemma rescale_line_bound {N H T s j : ℕ} (hT : 0 (x i:ℝ))=f ξ x) → + (∀ M : ℕ, 0 (q i:ℤ)) j (fun i => (x i:ℤ)))≤A/(M:ℝ)^j) → + ∃ ξ∈U, ∃ r : ℕ, 0 k)≤v*s := by + rw [gridExponent_degree] + calc + _ ≤ ∑ _ : Fin v, s := Finset.sum_le_sum (fun i _ => Nat.le_of_lt_succ (e i).isLt) + _ = _ := by simp + obtain ⟨L,K,hL,hK,hrecover⟩ := direction_character_recovery gridExponent (gridExponent_injective v s) + (v*s) hdeg U (C^(s+1)) (pow_pos hC _) + obtain ⟨T,N₁,hT,hN₁,hN₀₁,hscale⟩ := choose_short_scale v L N₀ δ ε A hδ hε hA.le + let E := (K:ℝ)*((2*(T:ℝ))^s*((C:ℝ)^(s+2)*A)) + refine ⟨K,N₁,hK,hN₁,E,by dsimp [E]; positivity,?_⟩ + intro N hN f hf a ha hsource + obtain ⟨hH,hsmall,hNH,hshort⟩ := hscale N hN + let M := N/T + have hget (q : Fin v→Fin L) : ∃ ξ∈U, ∃ r : ℕ, 0 k)=j then a ξ e else 0)* + (gridMonomial gridExponent q e:ℝ))*(N:ℝ)^j≤(2*(T:ℝ))^s*((C:ℝ)^(s+2)*A) := by + obtain ⟨ξ,hξ,S,hSc,hS⟩ := hsource M hH (fun i => (q i).val) (hshort q) + obtain ⟨r,hr,hrC,hrb⟩ := horigin N (hN₀₁.trans hN) M hH A hA.le hsmall (f ξ) (hf ξ) + (fun i => ((q i).val:ℤ)) S hS hSc + refine ⟨ξ,hξ,r,hr,hrC,?_⟩ + intro j hj + have heq := lineCoefficient_origin (hf ξ) (a ξ) (ha ξ) (fun i => (q i).val) j + simp only [gridExponent_degree,gridMonomial_eq_prod] + rw [← heq] + by_cases hjs : j ≤ s + · exact rescale_line_bound hT hNH hjs _ _ (by positivity) (hrb j hj) + · rw [lineCoefficient_above (hf ξ) 0 _ (Nat.lt_of_not_ge hjs),mul_zero,circleNorm_zero,zero_mul] + positivity + obtain ⟨ξ,hξ,r,hr,hrK,hb⟩ := hrecover (N:ℝ) ((2*(T:ℝ))^s*((C:ℝ)^(s+2)*A)) + (Nat.cast_nonneg _) (by positivity) a hget + refine ⟨ξ,hξ,r,hr,hrK,?_⟩ + intro e he + simpa only [gridExponent_degree] using hb e (by simpa only [gridExponent_degree] using he) + +end CorrectedBoxLeibman +end +end + + + +section +noncomputable section +open scoped BigOperators +namespace CorrectedBoxLeibman +open CubeFaces CubePolynomials LeibmanSquare RationalLattice MalcevCharacters +open MeasureTheory PolynomialWeyl AbelianMalcevTorus RationalTailCoordinates UnitAddTorus +open SquareInduction TriangularLatticeRecovery BoxPolynomialLines PolynomialLineCoefficients +variable {G : Type} [Group G] [TopologicalSpace G] [IsTopologicalGroup G] +variable {t d : ℕ} (c : RealCoordinates G (t+d)) (hsk : SecondKind c) +variable (H : Filtration G) (h0 : H.level 0=⊤) (h1 : H.level 1=⊤) +variable [∀ i, (H.level i).Normal] +variable (s : ℕ) (hs : H.level (s+1)=⊥) +variable (q : ℕ→ℕ) (hqbound : ∀ k, q k ≤ t+d) (hq2 : q 2=t) +variable (hq : ∀ k (g : G), g∈H.level k ↔ ∀ i : Fin (t+d), i.val (χ g).toAdd) he + rw [character_pow_toAdd] at hh + change (r:ℝ)*(ξ g).toAdd=0 at hh + change (ξ g).toAdd=0 + exact (mul_eq_zero.mp hh).resolve_left (Nat.cast_ne_zero.mpr (ne_of_gt hr)) + +include hsk h0 h1 hs hqbound hq hΓ htop in + + +theorem box_monomial_large + (μ : Measure (G⧸Γ)) [IsProbabilityMeasure μ] [SMulInvariantMeasure G (G⧸Γ) μ] + (v : ℕ) (δ : ℝ) (hδ : 0<δ) : + letI : CompactSpace (G⧸Γ) := metric_compact c Γ hΓ mtr htop + letI : BorelSpace (G⧸Γ) := metric_borelSpace Γ mtr htop + ∃ U : Finset (G→*Multiplicative ℝ), ∃ A : ℝ, 0 F (QuotientGroup.mk (f (fun i => (x i:ℤ)))))-(∫ y,F y ∂μ)‖) → + ∃ ξ∈U, ξ≠1 ∧ Continuous ξ ∧ (∀ g∈Γ, ∃ z : ℤ, (ξ g).toAdd=z) ∧ + ∃ a : Grid v s→ℝ, (∀ x, gridEval a (fun i => (x i:ℝ))=(ξ (f x)).toAdd) ∧ + ∀ e, 0 p.1^p.2) + refine ⟨V,E,hE,N₀,hN₀,?_⟩ + intro N hN f hf ⟨F,hFL,hFn,hd⟩ + have hscalar (ξ : G→*Multiplicative ℝ) : LinePolynomial v s (fun x => (ξ (f x)).toAdd) := by + intro x z + exact character_polynomial H s hs (polynomial_integer_line H hf x z) ξ + have hex (ξ : G→*Multiplicative ℝ) := character_grid_expansion H s hs hf ξ + choose a ha using hex + obtain ⟨ξ,hξ,r,hr,hrK,hb⟩ := hrec N hN (fun ξ x => (ξ (f x)).toAdd) hscalar a ha + (fun M hM z hz => hline N M (hN₀.trans_le hN) hM f hf F hFL hFn hd z hz) + obtain ⟨hξne,hξc,hξΓ⟩ := hU ξ hξ + refine ⟨ξ^r,Finset.mem_image.mpr ⟨(ξ,r),Finset.mem_product.mpr + ⟨hξ,Finset.mem_range.mpr (Nat.lt_succ_of_le hrK)⟩,rfl⟩,character_pow_ne ξ hξne r hr,hξc.pow r,?_, + fun e => (r:ℝ)*a ξ e,?_,hb⟩ + · intro g hg + obtain ⟨z,hz⟩ := hξΓ g hg + refine ⟨(r:ℤ)*z,?_⟩ + rw [character_pow_toAdd,hz] + simp + · intro x + rw [character_pow_toAdd,← ha ξ x] + simp only [gridEval,Finset.mul_sum] + apply Finset.sum_congr rfl + intro e _ + ring + +end CorrectedBoxLeibman + +end +end +end +end +end + +end OAI diff --git a/lean/OAI/Combinatorics/SumProduct/Alignment/CorrectedBox05.lean b/lean/OAI/Combinatorics/SumProduct/Alignment/CorrectedBox05.lean new file mode 100644 index 0000000000000000000000000000000000000000..b44fe38c47c8d3a1bc15d0e2e152d98d844feb95 --- /dev/null +++ b/lean/OAI/Combinatorics/SumProduct/Alignment/CorrectedBox05.lean @@ -0,0 +1,314 @@ +import Mathlib +import OAI.Combinatorics.SumProduct.Alignment.CorrectedBox04 +import OAI.Geometry.NilpotentCharts.Main + +namespace OAI + +section +section +section +section +noncomputable section +open scoped BigOperators +end +end + + + +section +noncomputable section +open scoped BigOperators +namespace CorrectedBoxLeibman +open PolynomialLineCoefficients + +lemma grid_totalDegree_bound {v s : ℕ} (e : Grid v s) : totalDegree e≤v*s := by + calc + _ ≤ ∑ _ : Fin v, s := Finset.sum_le_sum (fun i _ => Nat.le_of_lt_succ (e i).isLt) + _ = _ := by simp + + + +theorem grid_totalDegree {v s : ℕ} {f : (Fin v→ℤ)→ℝ} + (hf : LinePolynomial v s f) (a : Grid v s→ℝ) + (ha : ∀ x, gridEval a (fun i => (x i:ℝ))=f x) : + ∀ e, s k)≤v*s := by + rw [gridExponent_degree] + exact grid_totalDegree_bound e + let Q := (Finset.univ : Finset (Fin v→Fin L)) + have hden : (v*s:ℕ)/(L:ℚ≥0)<(Q.card:ℚ≥0)/(L:ℚ≥0)^v := by + have hLp : (0:ℚ≥0) (q.val i).val) (totalDegree e)] + exact lineCoefficient_above hf 0 _ he + have hrec := TriangularLatticeRecovery.reconstruct_slice totalDegree (fun q : Q => gridMonomial gridExponent q.val) + w B hw a (totalDegree e) e rfl + simp only [hz,mul_zero,Finset.sum_const_zero] at hrec + exact (mul_eq_zero.mp hrec.symm).resolve_left (Nat.cast_ne_zero.mpr (ne_of_gt hB)) + +end CorrectedBoxLeibman +end +end + + + +section +noncomputable section +open scoped BigOperators +namespace CorrectedBoxLeibman +open CubeFaces CubePolynomials LeibmanSquare RationalLattice MalcevCharacters +open MeasureTheory PolynomialWeyl AbelianMalcevTorus RationalTailCoordinates UnitAddTorus +open SquareInduction TriangularLatticeRecovery BoxPolynomialLines PolynomialLineCoefficients +variable {G : Type} [Group G] [TopologicalSpace G] [IsTopologicalGroup G] +variable {t d : ℕ} (c : RealCoordinates G (t+d)) (hsk : SecondKind c) +variable (H : Filtration G) (h0 : H.level 0=⊤) (h1 : H.level 1=⊤) +variable [∀ i, (H.level i).Normal] +variable (s : ℕ) (hs : H.level (s+1)=⊥) +variable (q : ℕ→ℕ) (hqbound : ∀ k, q k ≤ t+d) (hq2 : q 2=t) +variable (hq : ∀ k (g : G), g∈H.level k ↔ ∀ i : Fin (t+d), i.val F (QuotientGroup.mk (f (fun i => (x i:ℤ)))))-(∫ y,F y ∂μ)‖) → + ∃ ξ∈U, ξ≠1 ∧ Continuous ξ ∧ (∀ g∈Γ, ∃ z : ℤ, (ξ g).toAdd=z) ∧ + ∃ a : Grid v s→ℝ, (∀ x, gridEval a (fun i => (x i:ℝ))=(ξ (f x)).toAdd) ∧ + (∀ e, s (ξ (f x)).toAdd) := by + intro x z + exact character_polynomial H s hs (polynomial_integer_line H hf x z) ξ + by_cases hlarge : N₀≤N + · obtain ⟨ξ,hξ,hξne,hξc,hξΓ,a,ha,hb⟩ := hprod N hlarge f hf hd + refine ⟨ξ,hξ,hξne,hξc,hξΓ,a,ha,grid_totalDegree (hscalar ξ) a ha,?_⟩ + intro e he + exact (hb e he).trans (by dsimp [B]; linarith [pow_nonneg (Nat.cast_nonneg N₀ : (0:ℝ)≤N₀) (v*s)]) + · obtain ⟨F,hFL,hFn,hdisc⟩ := hd + let I := ∫ y,F y ∂μ + have hd' : δ≤‖boxMean v N (fun x => F (QuotientGroup.mk (f (fun i => (x i:ℤ))))-I)‖ := by + rw [boxMean_sub,boxMean_const v hN] + exact hdisc + obtain ⟨x,hx,hxd⟩ := exists_norm_ge v hN _ hd' + let g : (Fin v→ℤ)→G := fun _ => f (fun i => (x i:ℤ)) + have hg : LeibmanSquare.Polynomial H 0 g := polynomial_of_cube_mem H (const_mem (by rw [h0]; trivial)) + have hgd : δ≤‖boxMean v N₀ (fun y => F (QuotientGroup.mk (g (fun i => (y i:ℤ)))))-I‖ := by + dsimp [g] + rw [boxMean_const v hN₀] + exact hxd + obtain ⟨ξ,hξ,hξne,hξc,hξΓ,_⟩ := hprod N₀ le_rfl g hg ⟨F,hFL,hFn,hgd⟩ + obtain ⟨a,ha⟩ := character_grid_expansion H s hs hf ξ + refine ⟨ξ,hξ,hξne,hξc,hξΓ,a,ha,grid_totalDegree (hscalar ξ) a ha,?_⟩ + intro e he + have hdeg := grid_totalDegree_bound e + have hNr : 1≤(N:ℝ) := by exact_mod_cast hN + have hNN : (N:ℝ)≤N₀ := by exact_mod_cast (Nat.le_of_lt (Nat.lt_of_not_ge hlarge)) + calc + _ ≤ 1*(N:ℝ)^(totalDegree e) := mul_le_mul_of_nonneg_right + (DenseBoxModularPolynomial.circleNorm_le_one _) (by positivity) + _ ≤ (N₀:ℝ)^(v*s) := by + rw [one_mul] + exact (pow_le_pow_right₀ hNr hdeg).trans (pow_le_pow_left₀ (Nat.cast_nonneg _) hNN _) + _ ≤ B := by dsimp [B]; linarith + +end CorrectedBoxLeibman +end +end + + + +section +noncomputable section +open scoped BigOperators +open _root_.Polynomial _root_.OAI.Polynomial +namespace CorrectedBoxLeibman +open RationalFactorPeriods BinomialDifference + +def chooseSequence : Polynomial.Sequence ℝ where + elems' := choosePolynomial + degree_eq' j := by + rw [choosePolynomial,Polynomial.degree_C_mul (by positivity), + Polynomial.degree_eq_natDegree (monic_descPochhammer ℝ j).ne_zero, + descPochhammer_natDegree] + +lemma newton_expansion (s : ℕ) (P : ℝ[X]) (hP : P.natDegree ≤ s) : + P=∑ j : Fin (s+1), (coefficient ℝ j.val P) • choosePolynomial j.val := by + classical + have hr : Set.range (fun j : Fin (s+1) => choosePolynomial j.val)= + chooseSequence '' Set.Iio (s+1) := by + ext Q + constructor + · rintro ⟨j,rfl⟩ + exact ⟨j.val,j.isLt,rfl⟩ + · rintro ⟨j,hj,rfl⟩ + exact ⟨⟨j,hj⟩,rfl⟩ + have hmem : P∈Submodule.span ℝ (Set.range (fun j : Fin (s+1) => choosePolynomial j.val)) := by + rw [hr,chooseSequence.span_degreeLT (fun i _ => isUnit_iff_ne_zero.mpr + (Polynomial.leadingCoeff_ne_zero.mpr (chooseSequence.ne_zero i))),Polynomial.mem_degreeLT] + exact lt_of_le_of_lt Polynomial.degree_le_natDegree (by exact_mod_cast (Nat.lt_succ_of_le hP)) + obtain ⟨b,hb⟩ := (Submodule.mem_span_range_iff_exists_fun ℝ).mp hmem + have hc (k : Fin (s+1)) : coefficient ℝ k.val P=b k := by + rw [← hb,map_sum] + simp only [map_smul,smul_eq_mul,coefficient_choose,Fin.val_inj,mul_ite,mul_one,mul_zero] + simp + simpa only [hc] using hb.symm + +lemma power_binomial_expansion {s : ℕ} (j : Fin (s+1)) (x : ℤ) : + (x:ℝ)^j.val=∑ i : Fin (s+1), (matrix i.val j.val:ℝ)*(Ring.choose x i.val:ℤ) := by + have he := congrArg (fun P : ℝ[X] => P.eval (x:ℝ)) + (newton_expansion s (X^j.val) (by simpa using Nat.le_of_lt_succ j.isLt)) + simpa only [eval_pow,eval_X,eval_finsetSum,eval_smul,smul_eq_mul, + coefficient_X_pow,choosePolynomial_int] using he + + + +def tensorMatrix {v s : ℕ} (I J : Grid v s) : ℤ := + ∏ i, matrix (I i).val (J i).val + +def tensorNewton {v s : ℕ} (a : Grid v s→ℝ) (I : Grid v s) : ℝ := + ∑ J, a J*(tensorMatrix I J:ℝ) + +def binomialGridEval {v s : ℕ} (α : Grid v s→ℝ) (x : Fin v→ℤ) : ℝ := + ∑ I, α I*∏ i, (Ring.choose (x i) (I i).val:ℤ) + +lemma tensor_newton_expansion {v s : ℕ} (a : Grid v s→ℝ) (x : Fin v→ℤ) : + gridEval a (fun i => (x i:ℝ))=binomialGridEval (tensorNewton a) x := by + classical + simp only [gridEval,binomialGridEval] + simp_rw [power_binomial_expansion,Fintype.prod_sum,Finset.mul_sum] + rw [Finset.sum_comm] + apply Finset.sum_congr rfl + intro I _ + simp only [tensorNewton,Finset.sum_mul] + apply Finset.sum_congr rfl + intro J _ + rw [Finset.prod_mul_distrib] + simp only [tensorMatrix,Int.cast_prod] + ring + +lemma tensorMatrix_low {v s : ℕ} (I J : Grid v s) + (h : ∃ i, (J i).val<(I i).val) : tensorMatrix I J=0 := by + obtain ⟨i,hi⟩ := h + exact Finset.prod_eq_zero (Finset.mem_univ i) (matrix_low _ _ hi) + +lemma tensorMatrix_degree {v s : ℕ} (I J : Grid v s) + (h : tensorMatrix I J≠0) : PolynomialLineCoefficients.totalDegree I ≤ + PolynomialLineCoefficients.totalDegree J := by + apply Finset.sum_le_sum + intro i _ + by_contra hh + exact h (tensorMatrix_low I J ⟨i,by omega⟩) + +lemma tensorNewton_totalDegree {v s : ℕ} (a : Grid v s→ℝ) + (ha : ∀ J, s Finset.sum_nonneg (fun _ _ => abs_nonneg _)) + unfold tensorConversionBound + linarith + +lemma tensor_row_bound {v s : ℕ} (I : Grid v s) : + (∑ J : Grid v s, |(tensorMatrix I J:ℝ)|)≤tensorConversionBound v s := by + have hh := Finset.single_le_sum (f := fun I : Grid v s => ∑ J : Grid v s, |(tensorMatrix I J:ℝ)|) + (fun I _ => Finset.sum_nonneg (fun J _ => abs_nonneg _)) (Finset.mem_univ I) + unfold tensorConversionBound + linarith + + + +lemma tensorNewton_bound {v s : ℕ} (a : Grid v s→ℝ) (N A : ℝ) + (hN : 1≤N) (hA : 0≤A) + (ha : ∀ J, 0 hb J) + _ = (∑ J : Grid v s, |(tensorMatrix I J:ℝ)|)*A := (Finset.sum_mul _ _ _).symm + _ ≤ _ := mul_le_mul_of_nonneg_right (tensor_row_bound I) hA + +end CorrectedBoxLeibman + +end +end +end +end +end + +end OAI diff --git a/lean/OAI/Combinatorics/SumProduct/Alignment/CorrectedBox06.lean b/lean/OAI/Combinatorics/SumProduct/Alignment/CorrectedBox06.lean new file mode 100644 index 0000000000000000000000000000000000000000..9cd56edaea0c52026f0ed13017d23a4df6b346e1 --- /dev/null +++ b/lean/OAI/Combinatorics/SumProduct/Alignment/CorrectedBox06.lean @@ -0,0 +1,284 @@ +import Mathlib +import OAI.Combinatorics.SumProduct.Alignment.ComparableBox01 +import OAI.Geometry.NilpotentCharts.Main + +namespace OAI + +section +section +section +section +noncomputable section +open scoped BigOperators +end +end + + + +section +noncomputable section +open scoped BigOperators +open _root_.Polynomial _root_.OAI.Polynomial +namespace CorrectedBoxLeibman +open PolynomialLineCoefficients TriangularLatticeRecovery + +def translationEntry (b : ℤ) (i j : ℕ) : ℤ := ((X+C b)^j : ℤ[X]).coeff i + +def translationMatrix {v s : ℕ} (b : Fin v→ℤ) (I J : Grid v s) : ℤ := + ∏ k, translationEntry (b k) (I k).val (J k).val + +def gridTranslate {v s : ℕ} (a : Grid v s→ℝ) (b : Fin v→ℤ) (I : Grid v s) : ℝ := + ∑ J, a J*(translationMatrix b I J:ℝ) + +lemma translationEntry_low {b : ℤ} {i j : ℕ} (h : j < i) : translationEntry b i j=0 := by + simp only [translationEntry,coeff_X_add_C_pow,Nat.choose_eq_zero_of_lt h,Nat.cast_zero,mul_zero] + +lemma translationEntry_eval (s : ℕ) (j : Fin (s+1)) (b : ℤ) (x : ℝ) : + (x+(b:ℝ))^j.val=∑ i : Fin (s+1), (translationEntry b i.val j.val:ℝ)*x^i.val := by + have hd : ((X+C (b:ℝ))^j.val : ℝ[X]).natDegree ≤ s := by + have hx : (X+C (b:ℝ) : ℝ[X]).natDegree≤1 := natDegree_add_le_of_degree_le + (by simp) (by simp) + exact (natDegree_pow_le.trans (Nat.mul_le_mul_left _ hx)).trans (by simpa using Nat.le_of_lt_succ j.isLt) + have he := Polynomial.eval_eq_sum_range' (p:=((X+C (b:ℝ))^j.val : ℝ[X])) (Nat.lt_succ_of_le hd) (x:=x) + simp only [eval_pow,eval_add,eval_X,eval_C] at he + rw [← Fin.sum_univ_eq_sum_range] at he + simpa only [translationEntry,coeff_X_add_C_pow,Int.cast_mul,Int.cast_pow,Int.cast_natCast] using he + +lemma gridTranslate_eval {v s : ℕ} (a : Grid v s→ℝ) (b : Fin v→ℤ) (x : Fin v→ℝ) : + gridEval (gridTranslate a b) x=gridEval a (fun i => x i+(b i:ℝ)) := by + classical + symm + simp only [gridEval] + simp_rw [translationEntry_eval s,Fintype.prod_sum,Finset.mul_sum] + rw [Finset.sum_comm] + apply Finset.sum_congr rfl + intro I _ + simp only [gridTranslate,Finset.sum_mul] + apply Finset.sum_congr rfl + intro J _ + rw [Finset.prod_mul_distrib] + simp only [translationMatrix,Int.cast_prod] + ring + +lemma translationMatrix_le {v s : ℕ} (b : Fin v→ℤ) (I J : Grid v s) + (h : translationMatrix b I J≠0) : ∀ i,(I i).val≤(J i).val := by + intro i + by_contra hi + exact h (Finset.prod_eq_zero (Finset.mem_univ i) (translationEntry_low (by omega))) + +lemma gridTranslate_totalDegree {v s : ℕ} (a : Grid v s→ℝ) (b : Fin v→ℤ) + (ha : ∀ J,s translationMatrix_le b I J hm i) + rw [ha J (hI.trans_le hd),zero_mul] + +lemma translationEntry_bound {s : ℕ} (i j : Fin (s+1)) (b : ℤ) (Z C : ℝ) + (hZ : 0≤Z) (hC : 1≤C) (hb : |(b:ℝ)|≤C*Z) : + |(translationEntry b i.val j.val:ℝ)| * Z^i.val≤(2^s*C^s)*Z^j.val := by + by_cases hij : i.val≤j.val + · have hchoose : (j.val.choose i.val:ℝ)≤(2:ℝ)^s := by + exact_mod_cast ((Nat.choose_le_two_pow j.val i.val).trans (Nat.pow_le_pow_right (by omega) (Nat.le_of_lt_succ j.isLt))) + have hd : j.val-i.val+i.val=j.val := Nat.sub_add_cancel hij + have hdle : j.val-i.val ≤ s := (Nat.sub_le _ _).trans (Nat.le_of_lt_succ j.isLt) + simp only [translationEntry,coeff_X_add_C_pow,Int.cast_mul,Int.cast_pow,Int.cast_natCast,abs_mul,abs_pow,abs_of_nonneg (Nat.cast_nonneg (j.val.choose i.val) : (0:ℝ)≤(j.val.choose i.val:ℝ))] + calc + _ ≤ ((C*Z)^(j.val-i.val)*2^s)*Z^i.val := by gcongr + _ = (2^s*C^(j.val-i.val))*Z^j.val := by + have hp : Z^(j.val-i.val)*Z^i.val=Z^j.val := by rw [← pow_add,hd] + rw [mul_pow] + calc + _ = (2^s*C^(j.val-i.val))*(Z^(j.val-i.val)*Z^i.val) := by ring + _ = _ := by rw [hp] + _ ≤ _ := by gcongr + · rw [translationEntry_low (by omega)] + simp only [Int.cast_zero,abs_zero,zero_mul] + positivity + +lemma translationMatrix_bound {v s : ℕ} (b : Fin v→ℤ) (I J : Grid v s) (Z C : ℝ) + (hZ : 0≤Z) (hC : 1≤C) (hb : ∀ i, |(b i:ℝ)|≤C*Z) : + |(translationMatrix b I J:ℝ)| * Z^(totalDegree I)≤(2^s*C^s)^v*Z^(totalDegree J) := by + have hh := Finset.prod_le_prod₀ (fun i (_ : i∈(Finset.univ : Finset (Fin v))) => + mul_nonneg (abs_nonneg (translationEntry (b i) (I i).val (J i).val:ℝ)) (pow_nonneg hZ _)) + (fun i _ => translationEntry_bound (I i) (J i) (b i) Z C hZ hC (hb i)) + simpa only [Finset.prod_mul_distrib,← Finset.prod_pow_eq_pow_sum,translationMatrix, + Int.cast_prod,Finset.abs_prod,totalDegree,Finset.prod_const,Finset.card_univ,Fintype.card_fin,mul_pow] using hh + + + +lemma gridTranslate_bound {v s : ℕ} (a : Grid v s→ℝ) (b : Fin v→ℤ) (Z C A : ℝ) + (hZ : 0≤Z) (hC : 1≤C) (hA : 0≤A) (hb : ∀ i, |(b i:ℝ)|≤C*Z) + (ha : ∀ J,0 translationMatrix_le b I J hm i) + calc + _ = (|(translationMatrix b I J:ℝ)| * Z^(totalDegree I))*circleNorm (a J) := by ring + _ ≤ ((2^s*C^s)^v*Z^(totalDegree J))*circleNorm (a J) := + mul_le_mul_of_nonneg_right (translationMatrix_bound b I J Z C hZ hC hb) (norm_nonneg _) + _ = (2^s*C^s)^v*(circleNorm (a J)*Z^(totalDegree J)) := by ring + _ ≤ _ := mul_le_mul_of_nonneg_left (ha J (hI.trans_le hd)) (by positivity) + have he : gridTranslate a b I=∑ J : Grid v s, (translationMatrix b I J:ℝ)*a J := by simp only [gridTranslate,mul_comm] + rw [he] + calc + _ ≤ (∑ J : Grid v s, |(translationMatrix b I J:ℝ)| * circleNorm (a J))*Z^(totalDegree I) := + mul_le_mul_of_nonneg_right (integer_linear_bound _ _ _) (pow_nonneg hZ _) + _ = ∑ J : Grid v s, |(translationMatrix b I J:ℝ)| * circleNorm (a J)*Z^(totalDegree I) := Finset.sum_mul _ _ _ + _ ≤ ∑ _ : Grid v s, (2^s*C^s)^v*A := Finset.sum_le_sum (fun J _ => hterm J) + _ = _ := by simp [Grid,IntegerGridInterpolation.Grid]; ring + +end CorrectedBoxLeibman +end +end + + + +section +noncomputable section +open scoped BigOperators +namespace CorrectedBoxLeibman +open PolynomialLineCoefficients TriangularLatticeRecovery + +lemma grid_scale_change {v s : ℕ} (a : Grid v s→ℝ) (N Z K A : ℝ) + (hN : 0≤N) (hZ : 0≤Z) (hK : 1≤K) (hA : 0≤A) (hZN : Z≤K*N) + (ha : ∀ J,0 F (QuotientGroup.mk (f (fun i => a₀ i+(x i:ℤ)))))-(∫ y,F y ∂μ)‖) → + ∃ ξ∈U, ξ≠1 ∧ Continuous ξ ∧ (∀ g∈Γ,∃ z : ℤ,(ξ g).toAdd=z) ∧ + ∃ a : PolynomialLineCoefficients.Grid v s→ℝ, (∀ x,gridEval a (fun i => (x i:ℝ))=(ξ (f x)).toAdd) ∧ + (∀ I,s F (QuotientGroup.mk (f (fun i => a₀ i+(x i:ℤ)))) + have hf₀ : ∀ x,‖f₀ x‖≤1 := fun x => (F.norm_coe_le_norm _).trans hFn + obtain ⟨y,hy,hcube⟩ := rectMean_bad_cube v hLp N hN f₀ hf₀ (∫ z,F z ∂μ) δ hδ hdisc (hshort L hL) + let b : Fin v→ℤ := fun i => a₀ i+(y i:ℤ) + let g : (Fin v→ℤ)→G := fun x => f (b+x) + have hg : LeibmanSquare.Polynomial H 0 g := polynomial_affine H hf (AddMonoidHom.id _) b + have hdg : δ/2≤‖boxMean v N (fun x => F (QuotientGroup.mk (g (fun i => (x i:ℤ)))))-(∫ z,F z ∂μ)‖ := by + convert hcube using 1 + congr 3 + funext x + change F (QuotientGroup.mk (f (b+(fun i => (x i:ℤ))))) = F (QuotientGroup.mk (f (fun i => a₀ i+((y i+x i:ℕ):ℤ)))) + congr 3 + ext i + simp [b,Pi.add_apply,add_assoc] + obtain ⟨ξ,hξ,hξne,hξc,hξΓ,a,ha,hat,hac⟩ := hprod N hN g hg ⟨F,hFL,hFn,hdg⟩ + have hAZ : ∀ J,0 -b i),?_,gridTranslate_totalDegree a _ hat,?_⟩ + · intro x + rw [gridTranslate_eval] + have he : (fun i => (x i:ℝ)+((-b i:ℤ):ℝ))=(fun i => ((x i-b i:ℤ):ℝ)) := by + ext i + simp [sub_eq_add_neg] + rw [he,ha] + congr 2 + change f (b+(fun i => x i-b i))=f x + congr 1 + ext i + simp + · intro I hI + exact gridTranslate_bound a (fun i => -b i) Z C (K^(v*s)*A) hZp.le hC (by positivity) hb hAZ I hI + +end ComparableBoxLeibman + +end +end +end +end +end + +end OAI diff --git a/lean/OAI/Combinatorics/SumProduct/Alignment/CorrectedBox07.lean b/lean/OAI/Combinatorics/SumProduct/Alignment/CorrectedBox07.lean new file mode 100644 index 0000000000000000000000000000000000000000..1e8e588fda7ca043a38d4ea51cc8f1e68ff88255 --- /dev/null +++ b/lean/OAI/Combinatorics/SumProduct/Alignment/CorrectedBox07.lean @@ -0,0 +1,359 @@ +import Mathlib +import OAI.Combinatorics.SumProduct.Alignment.ComparableBox02 +import OAI.Geometry.NilpotentCharts.Main + +namespace OAI + +section +section +section +section +noncomputable section +open _root_.Polynomial _root_.OAI.Polynomial +open scoped BigOperators +end +end + + + +section +noncomputable section +open scoped BigOperators +namespace CorrectedBoxLeibman +open PolynomialLineCoefficients + + +lemma gridEval_integer_injective {v s : ℕ} {a b : Grid v s→ℝ} + (hab : ∀ x : Fin v→ℤ,gridEval a (fun i => (x i:ℝ))=gridEval b (fun i => (x i:ℝ))) : a=b := by + classical + let L := v*s+1 + have hL : 0 k)≤v*s := by + rw [gridExponent_degree] + exact grid_totalDegree_bound e + let Q := (Finset.univ : Finset (Fin v→Fin L)) + have hden : (v*s:ℕ)/(L:ℚ≥0)<(Q.card:ℚ≥0)/(L:ℚ≥0)^v := by + have hLp : (0:ℚ≥0) ((q.val i).val:ℤ)) + funext i + have ha := TriangularLatticeRecovery.reconstruct_slice (fun _ : Grid v s => 0) + (fun q : Q => gridMonomial gridExponent q.val) w B hw a 0 i rfl + have hb := TriangularLatticeRecovery.reconstruct_slice (fun _ : Grid v s => 0) + (fun q : Q => gridMonomial gridExponent q.val) w B hw b 0 i rfl + simp only [ite_true,he] at ha hb + have hp : (B:ℝ)≠0 := Nat.cast_ne_zero.mpr (ne_of_gt hB) + exact (mul_left_cancel₀ hp) (ha.symm.trans hb) + +end CorrectedBoxLeibman +end +end + + + +section +noncomputable section +open scoped BigOperators Topology +namespace ComparableBoxLeibman +open CubeFaces CubePolynomials LeibmanSquare RationalLattice MalcevCharacters +open MeasureTheory PolynomialWeyl AbelianMalcevTorus RationalTailCoordinates UnitAddTorus +open SquareInduction BoxPolynomialLines PolynomialLineCoefficients CorrectedBoxLeibman TriangularLatticeRecovery +open Filter +variable {G : Type} [Group G] [TopologicalSpace G] [IsTopologicalGroup G] +variable {t d : ℕ} (c : RealCoordinates G (t+d)) (hsk : SecondKind c) +variable (H : Filtration G) (h0 : H.level 0=⊤) (h1 : H.level 1=⊤) +variable [∀ i, (H.level i).Normal] +variable (s : ℕ) (hs : H.level (s+1)=⊥) +variable (q : ℕ→ℕ) (hqbound : ∀ k, q k ≤ t+d) +variable (hq : ∀ k (g : G), g∈H.level k ↔ ∀ i : Fin (t+d), i.val < q k → c.coord g i=0) +variable (Γ : Subgroup G) (hΓ : ∀ g : G, g∈Γ ↔ ∀ i, ∃ z : ℤ, c.coord g i=z) +variable [MeasurableSpace (G⧸Γ)] [hBorel : @BorelSpace (G⧸Γ) (QuotientGroup.instTopologicalSpace Γ) inferInstance] +variable [mtr : MetricSpace (G⧸Γ)] +variable (htop : mtr.toUniformSpace.toTopologicalSpace=QuotientGroup.instTopologicalSpace Γ) +local instance : TopologicalSpace (G⧸Γ) := mtr.toUniformSpace.toTopologicalSpace + +include hsk h0 h1 hs hqbound hq hΓ htop in + + +theorem haar_limit_of_horizontal_irrationality + (μ : Measure (G⧸Γ)) [IsProbabilityMeasure μ] [SMulInvariantMeasure G (G⧸Γ) μ] + (v : ℕ) (f : ℕ→(Fin v→ℤ)→G) (hf : ∀ N,LeibmanSquare.Polynomial H 0 (f N)) + (hirr : ∀ ξ : G→*Multiplicative ℝ, ξ≠1 → Continuous ξ → + (∀ g∈Γ,∃ z : ℤ,(ξ g).toAdd=z) → + ∃ a : ℕ→PolynomialLineCoefficients.Grid v s→ℝ, + (∀ N x,gridEval (a N) (fun i => (x i:ℝ))=(ξ (f N x)).toAdd) ∧ + ∃ I,0 < totalDegree I ∧ + Tendsto (fun N => circleNorm (a N I)*(N:ℝ)^(totalDegree I)) atTop atTop) + (c₀ C₀ : ℝ) (B : NNReal) (hc₀ : 0 (x i:ℝ))=(ξ (f N x)).toAdd) → + ∃ I,0 (ha N x).trans (hb x).symm) + exact ⟨I,hI,by simpa only [hab] using hN⟩ + · exact Filter.Eventually.of_forall (by intro N hne hcont hint; exact (hc ⟨hne,hcont,hint⟩).elim) + have hall : ∀ᶠ N : ℕ in atTop,∀ ξ∈U, + ξ≠1 → Continuous ξ → (∀ g∈Γ,∃ z : ℤ,(ξ g).toAdd=z) → + ∀ a : PolynomialLineCoefficients.Grid v s→ℝ, + (∀ x,gridEval a (fun i => (x i:ℝ))=(ξ (f N x)).toAdd) → + ∃ I,0 hlarge ξ) + have hNlarge : ∀ᶠ N : ℕ in atTop,Z₀≤(N:ℝ) := + tendsto_natCast_atTop_atTop.eventually_ge_atTop Z₀ + filter_upwards [hall,hNlarge] with N hN hNZ + intro lo hi hside hloc F hFL hFn + by_contra hbad + have hdisc : η≤‖(𝔼 x∈integerBox v lo hi,F (QuotientGroup.mk (f N x)))-(∫ y,F y ∂μ)‖ := le_of_not_gt hbad + obtain ⟨ξ,hξ,hξne,hξc,hξΓ,a,ha,hat,hac⟩ := hprod (N:ℝ) hNZ lo hi hside hloc (f N) (hf N) ⟨F,hFL,hFn,hdisc⟩ + obtain ⟨I,hI,hIA⟩ := hN ξ hξ hξne hξc hξΓ a ha + have hpow : 0<(N:ℝ)^(totalDegree I) := pow_pos (hZ₀.trans_le hNZ) _ + have hbnd := (le_div_iff₀ hpow).mp (hac I hI) + exact (not_lt_of_ge hbnd) hIA + +end ComparableBoxLeibman +end +end + + + +section +noncomputable section +open scoped BigOperators +namespace CorrectedBoxLeibman +open PolynomialLineCoefficients TriangularLatticeRecovery + +lemma gridEval_mul {v s : ℕ} (a : Grid v s→ℝ) (D : ℝ) (x : Fin v→ℝ) : + gridEval (fun I => D*a I) x=D*gridEval a x := by + simp only [gridEval,Finset.mul_sum,mul_assoc] + +lemma gridTranslate_mul {v s : ℕ} (a : Grid v s→ℝ) (D : ℝ) (r : Fin v→ℤ) : + gridTranslate (fun I => D*a I) r=(fun I => D*gridTranslate a r I) := by + funext I + simp only [gridTranslate,Finset.mul_sum,mul_assoc] + +lemma gridTranslate_cancel {v s : ℕ} (a : Grid v s→ℝ) (r : Fin v→ℤ) : + gridTranslate (gridTranslate a r) (fun i => -r i)=a := by + apply gridEval_integer_injective + intro x + rw [gridTranslate_eval,gridTranslate_eval] + congr 1 + funext i + simp + + +def gridDilate {v s : ℕ} (d : ℕ) (a : Grid v s→ℝ) (I : Grid v s) : ℝ := + (d:ℝ)^(totalDegree I)*a I + +lemma gridDilate_eval {v s : ℕ} (d : ℕ) (a : Grid v s→ℝ) (x : Fin v→ℝ) : + gridEval (gridDilate d a) x=gridEval a (fun i => (d:ℝ)*x i) := by + simp only [gridEval,gridDilate] + apply Finset.sum_congr rfl + intro I _ + simp only [mul_pow,Finset.prod_mul_distrib,Finset.prod_pow_eq_pow_sum,totalDegree] + ring + +lemma gridAffine_unique {v s : ℕ} (d : ℕ) (r : Fin v→ℤ) (a b : Grid v s→ℝ) + (hab : ∀ x : Fin v→ℤ,gridEval b (fun i => (x i:ℝ))= + gridEval a (fun i => ((r i+(d:ℤ)*x i:ℤ):ℝ))) : + b=gridDilate d (gridTranslate a r) := by + apply gridEval_integer_injective + intro x + rw [gridDilate_eval,gridTranslate_eval,hab] + congr 1 + funext i + push_cast + ring + + + +theorem gridAffine_recover_bound {v s : ℕ} (d : ℕ) (hd : 0 (x i:ℝ))= + gridEval a (fun i => ((r i+(d:ℤ)*x i:ℤ):ℝ))) + (hb : ∀ I,0 (d:ℝ)^(v*s-totalDegree I)*b I + have ha' : a'=(fun I => (d:ℝ)^(v*s)*gridTranslate a r I) := by + funext I + dsimp [a'] + rw [hab',gridDilate,← mul_assoc,← pow_add,Nat.sub_add_cancel (grid_totalDegree_bound I)] + have hacancel : gridTranslate a' (fun i => -r i)=(fun I => (d:ℝ)^(v*s)*a I) := by + rw [ha',gridTranslate_mul,gridTranslate_cancel] + have ha'bound : ∀ I,0 -r i) Z C ((d:ℝ)^(v*s)*A) + hZ hC (by positivity) (by intro i; simpa using hr i) ha'bound I hI + simpa only [hacancel] using hrec + +end CorrectedBoxLeibman +end +end + + + +section +noncomputable section +open scoped BigOperators Topology +namespace ComparableBoxLeibman +open CubeFaces CubePolynomials LeibmanSquare RationalLattice MalcevCharacters +open MeasureTheory PolynomialWeyl AbelianMalcevTorus RationalTailCoordinates UnitAddTorus +open SquareInduction BoxPolynomialLines PolynomialLineCoefficients CorrectedBoxLeibman TriangularLatticeRecovery +open Filter +variable {G : Type} [Group G] [TopologicalSpace G] [IsTopologicalGroup G] +variable {t d : ℕ} (c : RealCoordinates G (t+d)) (hsk : SecondKind c) +variable (H : Filtration G) (h0 : H.level 0=⊤) (h1 : H.level 1=⊤) +variable [∀ i, (H.level i).Normal] +variable (s : ℕ) (hs : H.level (s+1)=⊥) +variable (q : ℕ→ℕ) (hqbound : ∀ k, q k ≤ t+d) +variable (hq : ∀ k (g : G), g∈H.level k ↔ ∀ i : Fin (t+d), i.val < q k → c.coord g i=0) +variable (Γ : Subgroup G) (hΓ : ∀ g : G, g∈Γ ↔ ∀ i, ∃ z : ℤ, c.coord g i=z) +variable [MeasurableSpace (G⧸Γ)] [hBorel : @BorelSpace (G⧸Γ) (QuotientGroup.instTopologicalSpace Γ) inferInstance] +variable [mtr : MetricSpace (G⧸Γ)] +variable (htop : mtr.toUniformSpace.toTopologicalSpace=QuotientGroup.instTopologicalSpace Γ) +local instance progressionHaarTopology : TopologicalSpace (G⧸Γ) := mtr.toUniformSpace.toTopologicalSpace + +include hsk h0 h1 hs hqbound hq hΓ htop in + + +theorem haar_limit_fixed_progression + (μ : Measure (G⧸Γ)) [IsProbabilityMeasure μ] [SMulInvariantMeasure G (G⧸Γ) μ] + (v : ℕ) (f : ℕ→(Fin v→ℤ)→G) (hf : ∀ N,LeibmanSquare.Polynomial H 0 (f N)) + (hirr : ∀ ξ : G→*Multiplicative ℝ, ξ≠1 → Continuous ξ → + (∀ g∈Γ,∃ z : ℤ,(ξ g).toAdd=z) → + ∃ a : ℕ→PolynomialLineCoefficients.Grid v s→ℝ, + (∀ N x,gridEval (a N) (fun i => (x i:ℝ))=(ξ (f N x)).toAdd) ∧ + ∃ I,0 < totalDegree I ∧ + Tendsto (fun N => circleNorm (a N I)*(N:ℝ)^(totalDegree I)) atTop atTop) + (c₀ C₀ : ℝ) (B : NNReal) (hc₀ : 0 r i+(d₀:ℤ)*x i))))-(∫ y,F y ∂μ)‖<η := by + classical + let : CompactSpace (G⧸Γ) := metric_compact c Γ hΓ mtr htop + let : BorelSpace (G⧸Γ) := metric_borelSpace Γ mtr htop + intro η hη + obtain ⟨U,A,Z₀,hA,hZ₀,hprod⟩ := comparable_real_box c hsk H h0 h1 s hs q hqbound hq Γ hΓ htop μ v c₀ C₀ B η hc₀ hC₀ hB hη + let D : ℕ := d₀^(v*s) + have hD : 0 abs_nonneg (r i:ℝ))] + have hrC (i : Fin v) : |(r i:ℝ)|≤C := by + have hh := Finset.single_le_sum (f := fun i : Fin v => |(r i:ℝ)|) + (fun i _ => abs_nonneg _) (Finset.mem_univ i) + dsimp [C] + linarith + let E : ℝ := ((s+1:ℕ)^v:ℝ)*(2^s*C^s)^v*((d₀:ℝ)^(v*s)*A) + have hlarge (ξ : G→*Multiplicative ℝ) : ∀ᶠ N : ℕ in atTop, + ξ≠1 → Continuous ξ → (∀ g∈Γ,∃ z : ℤ,(ξ g).toAdd=z) → + ∀ a : PolynomialLineCoefficients.Grid v s→ℝ, + (∀ x,gridEval a (fun i => (x i:ℝ))=(ξ (f N x)).toAdd) → + ∃ I,0 (d₀:ℝ)^(v*s)*b I) := by + apply gridEval_integer_injective + intro x + rw [ha,gridEval_mul,hb,character_pow_toAdd] + simp [D] + exact ⟨I,hI,by simpa only [hab] using hN⟩ + · exact Filter.Eventually.of_forall (by intro N hne hcont hint; exact (hc ⟨hne,hcont,hint⟩).elim) + have hall : ∀ᶠ N : ℕ in atTop,∀ ξ∈U, + ξ≠1 → Continuous ξ → (∀ g∈Γ,∃ z : ℤ,(ξ g).toAdd=z) → + ∀ a : PolynomialLineCoefficients.Grid v s→ℝ, + (∀ x,gridEval a (fun i => (x i:ℝ))=(ξ (f N x)).toAdd) → + ∃ I,0 hlarge ξ) + have hNlarge : ∀ᶠ N : ℕ in atTop,max 1 Z₀≤(N:ℝ) := + tendsto_natCast_atTop_atTop.eventually_ge_atTop (max 1 Z₀) + let φ : (Fin v→ℤ)→+(Fin v→ℤ) := + { toFun := fun x i => (d₀:ℤ)*x i + map_zero' := by ext i; simp + map_add' := by intro x y; ext i; simp [mul_add] } + filter_upwards [hall,hNlarge] with N hN hNZ + have hNZ₀ : Z₀≤(N:ℝ) := (le_max_right _ _).trans hNZ + have hN1 : 1≤(N:ℝ) := (le_max_left _ _).trans hNZ + intro lo hi hside hloc F hFL hFn + by_contra hbad + have hdisc : η≤‖(𝔼 x∈integerBox v lo hi,F (QuotientGroup.mk + (f N (fun i => r i+(d₀:ℤ)*x i))))-(∫ y,F y ∂μ)‖ := le_of_not_gt hbad + have hgf := polynomial_affine H (hf N) φ r + obtain ⟨ξ,hξ,hξne,hξc,hξΓ,b,hb,hbt,hbc⟩ := hprod (N:ℝ) hNZ₀ lo hi hside hloc + (fun x => f N (r+φ x)) hgf ⟨F,hFL,hFn,hdisc⟩ + obtain ⟨a,ha⟩ := character_grid_expansion H s hs (hf N) ξ + have hab : ∀ x : Fin v→ℤ,gridEval b (fun i => (x i:ℝ))= + gridEval a (fun i => ((r i+(d₀:ℤ)*x i:ℤ):ℝ)) := by + intro x + rw [hb,ha] + rfl + have hbnd := gridAffine_recover_bound d₀ hd₀ r a b (N:ℝ) C A (Nat.cast_nonneg _) hC hA.le + (fun i => (hrC i).trans (le_mul_of_one_le_right (zero_le_one.trans hC) hN1)) hab + (fun I hI => (le_div_iff₀ (pow_pos (hZ₀.trans_le hNZ₀) _)).mp (hbc I hI)) + obtain ⟨I,hI,hIE⟩ := hN ξ hξ hξne hξc hξΓ a ha + exact (not_lt_of_ge (hbnd I hI)) hIE + +end ComparableBoxLeibman + +end +end +end +end +end + +end OAI diff --git a/lean/OAI/Combinatorics/SumProduct/Alignment/CoveringSubspace01.lean b/lean/OAI/Combinatorics/SumProduct/Alignment/CoveringSubspace01.lean new file mode 100644 index 0000000000000000000000000000000000000000..a83eeaca29e476d285ffda8a6bbe1bee1134a002 --- /dev/null +++ b/lean/OAI/Combinatorics/SumProduct/Alignment/CoveringSubspace01.lean @@ -0,0 +1,262 @@ +import Mathlib +import OAI.Combinatorics.SumProduct.Alignment.WordPlan02 +import OAI.Geometry.NilpotentCharts.Main + +namespace OAI + +open scoped BigOperators +section +section +noncomputable section +open MeasureTheory Filter Topology +open scoped NNReal ENNReal +end + +end + +section + + +noncomputable section +open MeasureTheory Filter Topology +open scoped NNReal ENNReal +namespace ConstructedWordPlan.GlobalWordPlan +open AlignmentScales RationalPivotPlan PolynomialShearPoint +open FilteredShears.PolynomialShears RationalLattice MalcevCharacters +variable {n k r : ℕ} (D : Pivot n) +variable {G : Type*} [Group G] [TopologicalSpace G] [IsTopologicalGroup G] +variable (c : RealCoordinates G k) (hsk : SecondKind c) (H : _root_.OAI.CubeFaces.Filtration G) +variable (w : Fin k → ℕ) (hw : ∀ i,0Read j a y t)) + (hS : ∀ j (a : Shifts D),Continuous (fun y : Y j=>a • y)) + (hown : ∀ j e,D.owner e=j → ∀ z, + π j (q (expQuotient c Γ (A e • z)))= + unitShift D e • π j (q (expQuotient c Γ z))) + (F : Finset (Scale n)) (P : Finset (Path D)) (τ : ℝ) (q₀ : ℕ) (b : Scale n) + (hp : ∀ x : CoverState (σ:=Fin k) (Fin D.pairs), ∃ p∈P,∀ d∈F, + Good D (palette D Y π Read τ (fun z=>q (expQuotient c Γ z))) + (generators D w A) q₀ (scaleRun D 0 p b*d) + (exactRun D.index D.tail D.owner D.added (generators D w A) q₀ 0 p b x).2) : + ((P.card : ℝ≥0)⁻¹ : ℝ≥0∞) ≤ + (μ.map q : Measure X) + (⋃ p∈P,closedOption D π Read F τ q₀ b p) := by + classical + have hPN : P.Nonempty := by + obtain ⟨p,hp,_⟩:=hp (0,0) + exact ⟨p,hp⟩ + let : Nonempty {p // p∈P}:=hPN.to_subtype + let AS (p : {p // p∈P}) : shears (R:=ℝ) w:= + (jump D (generators D w A) q₀ 0 p.val b).1⁻¹ + have hc : ∀ z,∃ p : {p // p∈P},shearedPoint c Γ q (AS p) z∈ + closedOption D π Read F τ q₀ b p.val := by + intro z + obtain ⟨p,hpP,hp⟩:=closed_cover D π Read w A + (fun z=>q (expQuotient c Γ z)) hown F P τ q₀ b hp z + exact ⟨⟨p,hpP⟩,hp⟩ + have hm:=weightedCover_finite_closed_mass c Γ hsk H w hw hH hΓ μ q AS + (fun p=>closedOption D π Read F τ q₀ b p.val) + (fun p=>closedOption_isClosed D π Read hπ hRead hS F τ q₀ b p.val) hc + simpa only [Fintype.card_coe,Set.iUnion_subtype] using hm + +end ConstructedWordPlan.GlobalWordPlan +end + +end + +section + + +noncomputable section +open MeasureTheory Filter Topology +open scoped NNReal ENNReal +namespace ConstructedWordPlan.GlobalWordPlan +open AlignmentScales RationalPivotPlan PolynomialShearPoint +open FilteredShears.PolynomialShears RationalLattice MalcevCharacters +variable {n : ℕ} + + + +def ChartedMassAssertion (D : Pivot n) (F : Finset (Scale n)) + (P : Finset (Path D)) (s r q₀ : ℕ) (b : Scale n) (τ : ℝ) : Prop := + ∀ (k : ℕ) (G : Type) [Group G] [TopologicalSpace G] [IsTopologicalGroup G] + (c : RealCoordinates G k), SecondKind c → + ∀ (H : _root_.OAI.CubeFaces.Filtration G) (w : Fin k → ℕ), + (∀ i,0Read j a y t)) → + (∀ j (a : Shifts D),Continuous (fun y : Y j=>a • y)) → + (∀ j e,D.owner e=j → ∀ z, + π j (q (expQuotient c Γ (A e • z)))= + unitShift D e • π j (q (expQuotient c Γ z))) → + ((P.card : ℝ≥0)⁻¹ : ℝ≥0∞) ≤ + (μ.map q : Measure X) + (⋃ p∈P,closedOption D π Read F τ q₀ b p) + + + +theorem uniform_pivot_haar (s r : ℕ) (hs : 1 ≤ s) (D : Pivot n) + (F : Finset (Scale n)) : + ∃ P : Finset (Path D),P.Nonempty ∧ + (∀ p∈P,p.length=D.targets ∧ ∀ o∈p,0false) (fun _=>PUnit.unit) 1 (by simp) PUnit.unit + exact ⟨p,hp⟩ + refine ⟨P,hPN,hPlen,?_⟩ + intro B + obtain ⟨Q,hQ,hPlanB⟩:=hPlan B + refine ⟨Q,hQ,?_⟩ + intro q₀ hq₀ b hb τ k G ig tg itg c hsk H w hw hws hH Γ mg bg X tx mx bx hx Y ty ay π Read hΓ μ hμ q A hπ + hRead hS hown + apply pivot_haar_mass D c hsk H w hw hH Γ π Read hΓ μ q A hπ hRead hS hown F P τ q₀ b + intro x + exact hPlanB q₀ hq₀ (CoverGroup w (Fin D.pairs)) + (cover_lowerCentralSeries w hs hws) (CoverState (σ:=Fin k) (Fin D.pairs)) + (palette D Y π Read τ (fun z=>q (expQuotient c Γ z))) (generators D w A) b hb x + +end ConstructedWordPlan.GlobalWordPlan +end + +end + +section + + +noncomputable section +open Topology +namespace CubeFaces +variable {G ι : Type} [Group G] [DecidableEq ι] +theorem cube_top_support (H : Filtration G) (I : Finset ι) (k : ℕ) + {f : Finset ι → G} (hf : f∈cube H I k) + (hv : ∀ v,v ⊂ I → f v=1) : f I∈H.level (I.card+k) := + CubeRationalCharts.cube_corner_mem H I k hf _ + (fun v h=>by rw [hv v h]; exact (H.level _).one_mem) le_rfl +end CubeFaces + +namespace CubeFaces +variable {G ι : Type} [Group G] [DecidableEq ι] + + +def affineUpper (a : ι) (c : G) (φ : G →* G) (f : Finset ι → G) : Finset ι → G := + fun v => if a ∈ v then c * φ (f v) else f v + + + +theorem affine_face_displacement (H : Filtration G) (D : Finset ι) (a : ι) + (ha : a ∉ D) (c g : G) (φ : G →* G) + (hc : c ∈ H.level 1) (hg : g ∈ H.level D.card) + (hpres : affineUpper a c φ (face D g) ∈ cube H (insert a D) 0) : + g⁻¹ * φ g ∈ H.level (D.card + 1) := by + have hD : D ⊆ insert a D := Finset.subset_insert _ _ + have hz : face D g ∈ cube H (insert a D) 0 := + face_mem_cube H hD (by simpa using hg) + have hcf : face {a} c ∈ cube H (insert a D) 0 := + face_mem_cube H (by simp) (by simpa using hc) + let f := (face D g)⁻¹ * ((face {a} c)⁻¹ * affineUpper a c φ (face D g)) + have hf : f ∈ cube H (insert a D) 0 := + (cube H _ _).mul_mem ((cube H _ _).inv_mem hz) + ((cube H _ _).mul_mem ((cube H _ _).inv_mem hcf) hpres) + have hv (v : Finset ι) (hvi : v ⊂ insert a D) : f v = 1 := by + have hn : ¬ (a ∈ v ∧ D ⊆ v) := by + rintro ⟨hav, hDv⟩ + exact hvi.not_superset (Finset.insert_subset hav hDv) + dsimp [f, affineUpper] + simp only [Finset.singleton_subset_iff] + by_cases hav : a ∈ v <;> by_cases hDv : D ⊆ v <;> simp_all + have htop := cube_top_support H (insert a D) 0 hf hv + simpa [f, affineUpper, face_apply, hD, Finset.card_insert_of_notMem ha] using htop + +end CubeFaces + +open scoped unitInterval +namespace CoveringSubspace + +variable {E X : Type*} [TopologicalSpace E] [TopologicalSpace X] + + +def imageRestrict (p : E → X) (S : Set E) : S → p '' S := + fun e => ⟨p e, ⟨e, e.property, rfl⟩⟩ + +lemma continuous_imageRestrict {p : E → X} (hp : Continuous p) (S : Set E) : + Continuous (imageRestrict p S) := + (hp.comp continuous_subtype_val).subtype_mk _ + + + +theorem path_mem_subspace {p : E → X} (hp : IsCoveringMap p) (S : Set E) + (hS : IsCoveringMap (imageRestrict p S)) (f : C(I, E)) + (hstart : f 0 ∈ S) (himage : ∀ t, p (f t) ∈ p '' S) : + ∀ t, f t ∈ S := by + let γ : C(I, p '' S) := + ⟨fun t => ⟨p (f t), himage t⟩, (hp.continuous.comp f.continuous).subtype_mk _⟩ + obtain ⟨Γ, hΓ, hΓ0⟩ := hS.exists_path_lifts γ ⟨f 0, hstart⟩ rfl + have heq : (fun t => (Γ t).val) = f := by + refine hp.eq_of_comp_eq (continuous_subtype_val.comp Γ.continuous) f.continuous ?_ 0 ?_ + · exact congrArg (fun g => fun t => (g t).val) hΓ + · exact congrArg Subtype.val hΓ0 + intro t + rw [← congrFun heq t] + exact (Γ t).property + + +theorem isQuotientMap_imageRestrict [T2Space X] {p : E → X} (hp : Continuous p) + {S C : Set E} (hC : IsCompact C) (hCS : C ⊆ S) + (hrep : ∀ s ∈ S, ∃ c ∈ C, p c = p s) : + Topology.IsQuotientMap (imageRestrict p S) := by + let : CompactSpace C := isCompact_iff_compactSpace.mp hC + let incl : C → S := fun c => ⟨c, hCS c.property⟩ + have hinc : Continuous incl := continuous_subtype_val.subtype_mk _ + have hq : Continuous (imageRestrict p S) := continuous_imageRestrict hp S + have hsurj : Function.Surjective (imageRestrict p S ∘ incl) := by + rintro ⟨x, s, hs, rfl⟩ + obtain ⟨c, hc, heq⟩ := hrep s hs + exact ⟨⟨c, hc⟩, Subtype.ext heq⟩ + exact Topology.IsQuotientMap.of_comp hinc hq + ((hq.comp hinc).isClosedMap.isQuotientMap (hq.comp hinc) hsurj) + +end CoveringSubspace + +end +end +end + +end OAI diff --git a/lean/OAI/Combinatorics/SumProduct/Alignment/CubeFaces01.lean b/lean/OAI/Combinatorics/SumProduct/Alignment/CubeFaces01.lean new file mode 100644 index 0000000000000000000000000000000000000000..4ff1d6baf1cd1413a0eceadf86fb57a53b225cb7 --- /dev/null +++ b/lean/OAI/Combinatorics/SumProduct/Alignment/CubeFaces01.lean @@ -0,0 +1,312 @@ +import Mathlib +import OAI.Geometry.NilpotentCharts.Coordinates +import OAI.Geometry.NilpotentCharts.Main + +namespace OAI + +section +section +section +section +noncomputable section +end +end + + + +section +open scoped commutatorElement Pointwise +namespace CubeFaces +variable {G ι : Type*} [Group G] [DecidableEq ι] + +def face (D : Finset ι) : G →* (Finset ι → G) where + toFun g v := if D ⊆ v then g else 1 + map_one' := by funext v; simp + map_mul' g h := by funext v; dsimp; split_ifs <;> simp + +@[simp] lemma face_apply (D v : Finset ι) (g : G) : + face D g v = if D ⊆ v then g else 1 := rfl + +lemma face_commutator (D E : Finset ι) (g h : G) : + ⁅face D g, face E h⁆ = face (D ∪ E) ⁅g,h⁆ := by + funext v + simp only [commutatorElement_def, Pi.mul_apply, Pi.inv_apply, face_apply, + Finset.union_subset_iff] + by_cases hD : D ⊆ v <;> by_cases hE : E ⊆ v <;> simp [hD, hE] + + +def cube (H : Filtration G) (I : Finset ι) (k : ℕ) : Subgroup (Finset ι → G) := + ⨆ D : Finset ι, ⨆ (_ : D ⊆ I), (H.level (D.card + k)).map (face D) + +lemma face_mem_cube (H : Filtration G) {I D : Finset ι} {k : ℕ} + (hD : D ⊆ I) {g : G} (hg : g ∈ H.level (D.card + k)) : + face D g ∈ cube H I k := by + have hle : (H.level (D.card + k)).map (face D) ≤ cube H I k := + le_iSup_of_le D (le_iSup_of_le hD le_rfl) + exact hle ⟨g, hg, rfl⟩ + + +def upper (a : ι) : (Finset ι → G) →* (Finset ι → G) where + toFun f v := if a ∈ v then f v else 1 + map_one' := by funext v; simp + map_mul' f g := by funext v; dsimp; split_ifs <;> simp + +lemma upper_face (a : ι) (D : Finset ι) : + (upper a).comp (face D : G →* (Finset ι → G)) = face (insert a D) := by + ext g v + by_cases ha : a ∈ v <;> by_cases hD : D ⊆ v <;> + simp [upper, face, Finset.insert_subset_iff, ha, hD] + +lemma map_upper_cube (H : Filtration G) (a : ι) (I : Finset ι) (k : ℕ) : + (cube H I (k + 1)).map (upper a) = + ⨆ E : Finset ι, ⨆ (_ : E ⊆ I), + (H.level (E.card + k + 1)).map (face (insert a E)) := by + simp only [cube, Subgroup.map_iSup, Subgroup.map_map, upper_face, Nat.add_assoc] + +@[simp] lemma upper_face_apply (a : ι) (D : Finset ι) (g : G) : + upper a (face D g) = face (insert a D) g := + DFunLike.congr_fun (upper_face a D) g + +lemma face_upper_commutator_mem (H : Filtration G) (a : ι) + {I D E : Finset ι} {k : ℕ} (hD : D ⊆ I) (hE : E ⊆ I) + {g h : G} (hg : g ∈ H.level (D.card + k)) + (hh : h ∈ H.level (E.card + (k + 1))) : + ⁅face D g, upper a (face E h)⁆ ∈ (cube H I (k + 1)).map (upper a) := by + rw [upper_face_apply, face_commutator, Finset.union_insert] + have hdeg : (D ∪ E).card + (k + 1) ≤ (D.card + k) + (E.card + (k + 1)) := by + have := Finset.card_union_le D E + omega + have hc : ⁅g,h⁆ ∈ H.level ((D ∪ E).card + (k + 1)) := + H.antitone hdeg (H.commutator_le _ _ (Subgroup.commutator_mem_commutator hg hh)) + exact ⟨face (D ∪ E) ⁅g,h⁆, face_mem_cube H (Finset.union_subset hD hE) hc, + upper_face_apply a (D ∪ E) ⁅g,h⁆⟩ + +lemma cube_le_normalizer_upper (H : Filtration G) (a : ι) (I : Finset ι) (k : ℕ) : + cube H I k ≤ Subgroup.normalizer ((cube H I (k + 1)).map (upper a)) := by + let R := (cube H I (k + 1)).map (upper a) + change (⨆ D : Finset ι, ⨆ (_ : D ⊆ I), + (H.level (D.card + k)).map (face D)) ≤ Subgroup.normalizer R + refine iSup_le fun D => iSup_le fun hD => ?_ + rintro f ⟨g, hg, rfl⟩ + have hc (g : G) (hg : g ∈ H.level (D.card + k)) : + ∀ z ∈ R, face D g * z * (face D g)⁻¹ ∈ R := by + have hle : cube H I (k + 1) ≤ + R.comap ((MulAut.conj (face D g)).toMonoidHom.comp (upper a)) := by + refine iSup_le fun E => iSup_le fun hE => ?_ + rintro f ⟨h, hh, rfl⟩ + change face D g * upper a (face E h) * (face D g)⁻¹ ∈ R + have hm : upper a (face E h) ∈ R := + ⟨face E h, face_mem_cube H hE hh, rfl⟩ + have hcomm := face_upper_commutator_mem H a hD hE hg hh + have heq : face D g * upper a (face E h) * (face D g)⁻¹ = + ⁅face D g, upper a (face E h)⁆ * upper a (face E h) := by + simp [commutatorElement_def, mul_assoc] + rw [heq] + exact R.mul_mem hcomm hm + rintro z ⟨u, hu, rfl⟩ + exact hle hu + rw [Subgroup.mem_normalizer_iff] + intro z + constructor + · exact hc g hg z + · intro hz + have ht := hc g⁻¹ ((H.level _).inv_mem hg) _ hz + simpa [map_inv, mul_assoc] using ht + +lemma cube_insert_le (H : Filtration G) (a : ι) (I : Finset ι) (k : ℕ) : + cube H (insert a I) k ≤ cube H I k ⊔ (cube H I (k + 1)).map (upper a) := by + refine iSup_le fun D => iSup_le fun hD => ?_ + rintro f ⟨g, hg, rfl⟩ + by_cases haD : a ∈ D + · have hE : D.erase a ⊆ I := by + intro x hx + rcases Finset.mem_erase.mp hx with ⟨hxa, hx⟩ + exact (Finset.mem_insert.mp (hD hx)).resolve_left hxa + have hcard := Finset.card_erase_add_one haD + have hg' : g ∈ H.level ((D.erase a).card + (k + 1)) := by + have he : (D.erase a).card + (k + 1) = D.card + k := by omega + rwa [he] + apply Subgroup.mem_sup_right + refine ⟨face (D.erase a) g, face_mem_cube H hE hg', ?_⟩ + rw [upper_face_apply, Finset.insert_erase haD] + · have hDI : D ⊆ I := by + intro x hx + rcases Finset.mem_insert.mp (hD hx) with hxa | hxi + · exact False.elim (haD (hxa ▸ hx)) + · exact hxi + exact Subgroup.mem_sup_left (face_mem_cube H hDI hg) + + + +lemma cube_decompose (H : Filtration G) (a : ι) (I : Finset ι) (k : ℕ) + {f : Finset ι → G} (hf : f ∈ cube H (insert a I) k) : + ∃ l ∈ cube H I k, ∃ u ∈ cube H I (k + 1), f = l * upper a u := by + have hx := cube_insert_le H a I k hf + change f ∈ (↑(cube H I k ⊔ (cube H I (k + 1)).map (upper a)) : Set _) at hx + rw [Subgroup.coe_mul_of_left_le_normalizer_right _ _ (cube_le_normalizer_upper H a I k)] at hx + rcases hx with ⟨l, hl, z, ⟨u, hu, rfl⟩, hmul⟩ + exact ⟨l, hl, u, hu, hmul.symm⟩ + + +def evaluation (v : Finset ι) : (Finset ι → G) →* G where + toFun f := f v + map_one' := rfl + map_mul' _ _ := rfl + +lemma cube_insert_irrelevant (H : Filtration G) {I : Finset ι} {a : ι} + (ha : a ∉ I) {k : ℕ} {f : Finset ι → G} (hf : f ∈ cube H I k) + (v : Finset ι) : f (insert a v) = f v := by + have hle : cube H I k ≤ (evaluation (insert a v)).eqLocus (evaluation v) := by + refine iSup_le fun D => iSup_le fun hD => ?_ + rintro f ⟨g, hg, rfl⟩ + change face D g (insert a v) = face D g v + have he : D ⊆ insert a v ↔ D ⊆ v := by + constructor + · intro hd x hx + have hxa : x ≠ a := by rintro rfl; exact ha (hD hx) + exact (Finset.mem_insert.mp (hd hx)).resolve_left hxa + · intro hd + exact hd.trans (Finset.subset_insert a v) + simp only [face_apply, he] + exact hle hf + +lemma cube_eval_mem (H : Filtration G) {I : Finset ι} {k : ℕ} + {f : Finset ι → G} (hf : f ∈ cube H I k) (v : Finset ι) : f v ∈ H.level k := by + have hle : cube H I k ≤ (H.level k).comap (evaluation v) := by + refine iSup_le fun D => iSup_le fun hD => ?_ + rintro f ⟨g, hg, rfl⟩ + change face D g v ∈ H.level k + simp only [face_apply] + split_ifs + · exact H.antitone (Nat.le_add_left k D.card) hg + · exact (H.level k).one_mem + exact hle hf + +lemma cube_shift_le (H : Filtration G) (I : Finset ι) {i j : ℕ} (h : i ≤ j) : + cube H I j ≤ cube H I i := by + refine iSup_le fun D => iSup_le fun hD => ?_ + exact (Subgroup.map_mono (H.antitone (Nat.add_le_add_left h _))).trans + (le_iSup_of_le D (le_iSup_of_le hD le_rfl)) + +lemma cube_restrict (H : Filtration G) {I : Finset ι} {k : ℕ} + {f : Finset ι → G} (hf : f ∈ cube H I k) (v : Finset ι) : + f (v ∩ I) = f v := by + have hle : cube H I k ≤ (evaluation (v ∩ I)).eqLocus (evaluation v) := by + refine iSup_le fun D => iSup_le fun hD => ?_ + rintro f ⟨g,hg,rfl⟩ + change face D g (v ∩ I) = face D g v + simp only [face_apply, Finset.subset_inter_iff, hD, and_true] + exact hle hf + +lemma cube_normalizes (H : Filtration G) (I : Finset ι) (k : ℕ) : + cube H I 0 ≤ Subgroup.normalizer (cube H I k) := by + refine iSup_le fun D => iSup_le fun hD => ?_ + rintro f ⟨g,hg,rfl⟩ + have hc (g : G) (hg : g ∈ H.level (D.card + 0)) : + ∀ z ∈ cube H I k, face D g * z * (face D g)⁻¹ ∈ cube H I k := by + have hle : cube H I k ≤ (cube H I k).comap (MulAut.conj (face D g)).toMonoidHom := by + refine iSup_le fun E => iSup_le fun hE => ?_ + rintro f ⟨h,hh,rfl⟩ + change face D g * face E h * (face D g)⁻¹ ∈ cube H I k + have hdeg : (D ∪ E).card + k ≤ (D.card + 0) + (E.card + k) := by + have := Finset.card_union_le D E + omega + have hcomm : ⁅face D g, face E h⁆ ∈ cube H I k := by + rw [face_commutator] + exact face_mem_cube H (Finset.union_subset hD hE) + (H.antitone hdeg (H.commutator_le _ _ (Subgroup.commutator_mem_commutator hg hh))) + have heq : face D g * face E h * (face D g)⁻¹ = ⁅face D g, face E h⁆ * face E h := by + simp [commutatorElement_def, mul_assoc] + rw [heq] + exact (cube H I k).mul_mem hcomm (face_mem_cube H hE hh) + exact fun z hz => hle hz + rw [Subgroup.mem_normalizer_iff] + intro z + constructor + · exact hc g hg z + · intro hz + have hh := hc g⁻¹ ((H.level _).inv_mem hg) _ hz + simpa [map_inv, mul_assoc] using hh + + +def commModulo (N : Subgroup G) (a : G) : Subgroup G where + carrier := {b | b ∈ (Subgroup.normalizer (N : Set G)) ∧ ⁅a,b⁆ ∈ N} + one_mem' := by simp + mul_mem' := by + rintro b c ⟨hb,hbc⟩ ⟨hc,hcc⟩ + change b ∈ Subgroup.normalizer (N : Set G) at hb + change c ∈ Subgroup.normalizer (N : Set G) at hc + refine ⟨Subgroup.mul_mem (Subgroup.normalizer (N : Set G)) hb hc, ?_⟩ + have hconj := (Subgroup.mem_normalizer_iff.mp hb ⁅a,c⁆).mp hcc + have he : ⁅a,b*c⁆ = ⁅a,b⁆ * (b * ⁅a,c⁆ * b⁻¹) := by + simp [commutatorElement_def, mul_assoc] + rw [he] + exact N.mul_mem hbc hconj + inv_mem' := by + rintro b ⟨hb,hbc⟩ + change b ∈ Subgroup.normalizer (N : Set G) at hb + refine ⟨Subgroup.inv_mem (Subgroup.normalizer (N : Set G)) hb, ?_⟩ + have hconj := (Subgroup.mem_normalizer_iff.mp ((Subgroup.normalizer (N : Set G)).inv_mem hb) (⁅a,b⁆)⁻¹).mp + (N.inv_mem hbc) + simpa [commutatorElement_def, mul_assoc] using hconj + +lemma face_cube_commutator_mem (H : Filtration G) (I : Finset ι) {i j : ℕ} + {D : Finset ι} (hD : D ⊆ I) {g : G} (hg : g ∈ H.level (D.card+i)) + {f : Finset ι → G} (hf : f ∈ cube H I j) : + ⁅face D g, f⁆ ∈ cube H I (i+j) := by + have hle : cube H I j ≤ commModulo (cube H I (i+j)) (face D g) := by + refine iSup_le fun E => iSup_le fun hE => ?_ + rintro f ⟨h,hh,rfl⟩ + constructor + · exact cube_normalizes H I _ + (cube_shift_le H I (Nat.zero_le j) (face_mem_cube H hE hh)) + · rw [face_commutator] + have hdeg : (D ∪ E).card + (i+j) ≤ (D.card+i) + (E.card+j) := by + have := Finset.card_union_le D E + omega + exact face_mem_cube H (Finset.union_subset hD hE) + (H.antitone hdeg (H.commutator_le _ _ (Subgroup.commutator_mem_commutator hg hh))) + exact (hle hf).2 + +lemma cube_commutator_mem (H : Filtration G) (I : Finset ι) {i j : ℕ} + {f g : Finset ι → G} (hf : f ∈ cube H I i) (hg : g ∈ cube H I j) : + ⁅f,g⁆ ∈ cube H I (i+j) := by + have hle : cube H I i ≤ commModulo (cube H I (i+j)) g := by + refine iSup_le fun D => iSup_le fun hD => ?_ + rintro f ⟨a,ha,rfl⟩ + constructor + · exact cube_normalizes H I _ + (cube_shift_le H I (Nat.zero_le i) (face_mem_cube H hD ha)) + · have hh := face_cube_commutator_mem H I hD ha hg + have hinv := (cube H I (i+j)).inv_mem hh + simpa [commutatorElement_def, mul_assoc] using hinv + have hinv := (cube H I (i+j)).inv_mem (hle hf).2 + simpa [commutatorElement_def, mul_assoc] using hinv + +lemma cube_mono (H : Filtration G) {I J : Finset ι} (hIJ : I ⊆ J) (k : ℕ) : + cube H I k ≤ cube H J k := by + refine iSup_le fun D => iSup_le fun hD => ?_ + exact le_iSup_of_le D (le_iSup_of_le (hD.trans hIJ) le_rfl) + +lemma upper_cube_mem (H : Filtration G) {I : Finset ι} {a : ι} (ha : a ∉ I) (k : ℕ) + {f : Finset ι → G} (hf : f ∈ cube H I (k+1)) : upper a f ∈ cube H (insert a I) k := by + have hle : cube H I (k+1) ≤ (cube H (insert a I) k).comap (upper a) := by + refine iSup_le fun D => iSup_le fun hD => ?_ + rintro f ⟨g,hg,rfl⟩ + change upper a (face D g) ∈ cube H (insert a I) k + rw [upper_face_apply] + apply face_mem_cube H (Finset.insert_subset_insert a hD) + have haD : a ∉ D := fun h => ha (hD h) + change g ∈ H.level (D.card + (k+1)) at hg + simpa only [Finset.card_insert_of_notMem haD, Nat.add_assoc, Nat.add_comm, + Nat.add_left_comm] using hg + exact hle hf + +end CubeFaces + +end +end +end +end + +end OAI diff --git a/lean/OAI/Combinatorics/SumProduct/Alignment/CubeFaces02.lean b/lean/OAI/Combinatorics/SumProduct/Alignment/CubeFaces02.lean new file mode 100644 index 0000000000000000000000000000000000000000..852416aef7e0a4bee315c18d49bb0d64a16af5fa --- /dev/null +++ b/lean/OAI/Combinatorics/SumProduct/Alignment/CubeFaces02.lean @@ -0,0 +1,306 @@ +import Mathlib +import OAI.Combinatorics.SumProduct.Alignment.CubeTaylor02 +import OAI.Geometry.NilpotentCharts.Main + +namespace OAI + +section +section +section +section +noncomputable section +open scoped BigOperators Topology commutatorElement +end +end + + + +section + + + +noncomputable section +open scoped Pointwise commutatorElement +namespace CompactGroupProducts +variable {G K : Type*} [Group G] [TopologicalSpace G] [IsTopologicalGroup G] + [Group K] [TopologicalSpace K] [IsTopologicalGroup K] +omit [IsTopologicalGroup G] [IsTopologicalGroup K] in +lemma HasCompactReps.map_into {H Γ : Subgroup G} (h : HasCompactReps H Γ) + (f : G →* K) (hf : Continuous f) (Λ : Subgroup K) (hΓ : Γ ≤ Λ.comap f) : + HasCompactReps (H.map f) Λ := by + rcases h with ⟨C, hC, hCH, hrep⟩ + refine ⟨f '' C, hC.image hf, ?_, ?_⟩ + · rintro _ ⟨c, hc, rfl⟩ + exact ⟨c, hCH hc, rfl⟩ + · rintro _ ⟨g, hg, rfl⟩ + obtain ⟨c, hc, hcΓ⟩ := hrep g hg + refine ⟨f c, ⟨c, hc, rfl⟩, ?_⟩ + simpa only [Subgroup.mem_comap, map_mul, map_inv] using hΓ hcΓ + + +lemma HasCompactReps.sup {H J Γ : Subgroup G} + (hH : HasCompactReps H Γ) (hJ : HasCompactReps J Γ) + (hnormal : H ≤ Subgroup.normalizer J) : HasCompactReps (H ⊔ J) Γ := by + rcases hH with ⟨C, hC, hCH, hrepH⟩ + rcases hJ with ⟨D, hD, hDJ, hrepJ⟩ + refine ⟨C * D, hC.mul hD, ?_, ?_⟩ + · rintro _ ⟨c, hc, d, hd, rfl⟩ + exact (H ⊔ J).mul_mem (Subgroup.mem_sup_left (hCH hc)) + (Subgroup.mem_sup_right (hDJ hd)) + · intro g hg + change g ∈ (↑(H ⊔ J) : Set G) at hg + rw [Subgroup.coe_mul_of_left_le_normalizer_right _ _ hnormal] at hg + rcases hg with ⟨h, hh, j, hj, rfl⟩ + obtain ⟨c, hc, hcΓ⟩ := hrepH h hh + let δ := c⁻¹ * h + have hδH : δ ∈ H := H.mul_mem (H.inv_mem (hCH hc)) hh + have hδΓ : δ ∈ Γ := hcΓ + have hvJ : δ * j * δ⁻¹ ∈ J := + (Subgroup.mem_normalizer_iff.mp (hnormal hδH) j).mp hj + obtain ⟨d, hd, hdΓ⟩ := hrepJ _ hvJ + refine ⟨c * d, ⟨c, hc, d, hd, rfl⟩, ?_⟩ + have heq : (c * d)⁻¹ * (h * j) = (d⁻¹ * (δ * j * δ⁻¹)) * δ := by + dsimp [δ] + group + rw [heq] + exact Γ.mul_mem hdΓ hδΓ + +end CompactGroupProducts +namespace CompactGroupProducts +open Topology +variable {G : Type*} [Group G] [TopologicalSpace G] + + + +lemma HasCompactReps.compactSpace {H Γ : Subgroup G} (h : HasCompactReps H Γ) : + CompactSpace (H ⧸ Γ.comap H.subtype) := by + obtain ⟨C,hC,hCH,hr⟩ := h + let D : Set H := Subtype.val ⁻¹' C + have hD : IsCompact D := by + apply IsEmbedding.subtypeVal.isCompact_iff.mpr + have he : Subtype.val '' D = C := by + ext x + exact ⟨fun ⟨y,hy,he⟩ => he ▸ hy,fun hx => ⟨⟨x,hCH hx⟩,hx,rfl⟩⟩ + rwa [he] + have he : QuotientGroup.mk (s := Γ.comap H.subtype) '' D = Set.univ := by + apply Set.eq_univ_of_forall + intro x + induction x using Quotient.inductionOn with | h x => + obtain ⟨c,hc,hcx⟩ := hr x x.property + exact ⟨⟨c,hCH hc⟩,hc,QuotientGroup.eq.mpr hcx⟩ + exact ⟨he ▸ hD.image QuotientGroup.continuous_mk⟩ + +end CompactGroupProducts +namespace CubeFaces +variable {G ι : Type*} [Group G] [DecidableEq ι] +lemma cube_empty (H : Filtration G) (k : ℕ) : + cube H (∅ : Finset ι) k = (H.level k).map (face ∅) := by + apply le_antisymm + · refine iSup_le fun D => iSup_le fun hD => ?_ + have he : D = ∅ := Finset.subset_empty.mp hD + subst D + simp only [Finset.card_empty, zero_add] + exact le_rfl + · intro f hf + rcases hf with ⟨g, hg, rfl⟩ + exact face_mem_cube H (Finset.empty_subset _) (by simpa using hg) + +lemma map_upper_cube_le (H : Filtration G) (a : ι) (I : Finset ι) (k : ℕ) : + (cube H I (k + 1)).map (upper a) ≤ cube H (insert a I) k := by + rw [map_upper_cube] + refine iSup_le fun E => iSup_le fun hE => ?_ + rintro f ⟨g, hg, rfl⟩ + apply face_mem_cube H (Finset.insert_subset_insert a hE) + apply H.antitone _ hg + have := Finset.card_insert_le a E + omega + +lemma cube_insert_eq (H : Filtration G) (a : ι) (I : Finset ι) (k : ℕ) : + cube H (insert a I) k = cube H I k ⊔ (cube H I (k + 1)).map (upper a) := by + apply le_antisymm (cube_insert_le H a I k) + exact sup_le (cube_mono H (Finset.subset_insert a I) k) (map_upper_cube_le H a I k) + + +def latticeArrays (Γ : Subgroup G) : Subgroup (Finset ι → G) where + carrier := {f | ∀ v, f v ∈ Γ} + one_mem' := fun _ => Γ.one_mem + mul_mem' hf hg := fun v => Γ.mul_mem (hf v) (hg v) + inv_mem' hf := fun v => Γ.inv_mem (hf v) + +section CompactCubes +variable [TopologicalSpace G] [IsTopologicalGroup G] + +omit [IsTopologicalGroup G] in +lemma continuous_face (D : Finset ι) : Continuous (face D : G → (Finset ι → G)) := by + apply continuous_pi + intro v + by_cases hD : D ⊆ v + · simp only [face_apply, hD, ite_true] + exact continuous_id + · simpa only [face_apply, hD, ite_false] using + (continuous_const : Continuous (fun _ : G => (1 : G))) + +omit [IsTopologicalGroup G] in +lemma continuous_upper (a : ι) : Continuous (upper a : (Finset ι → G) → (Finset ι → G)) := by + apply continuous_pi + intro v + by_cases ha : a ∈ v + · simpa only [upper, MonoidHom.coe_mk, OneHom.coe_mk, ha, ite_true] using + (continuous_apply v : Continuous (fun f : Finset ι → G => f v)) + · simpa only [upper, MonoidHom.coe_mk, OneHom.coe_mk, ha, ite_false] using + (continuous_const : Continuous (fun _ : Finset ι → G => (1 : G))) + + + +theorem cube_hasCompactReps (H : Filtration G) (Γ : Subgroup G) + (hrep : ∀ k, CompactGroupProducts.HasCompactReps (H.level k) Γ) + (I : Finset ι) (k : ℕ) : + CompactGroupProducts.HasCompactReps (cube H I k) (latticeArrays Γ) := by + induction I using Finset.induction_on generalizing k with + | empty => + rw [cube_empty] + apply (hrep k).map_into (face ∅) (continuous_face ∅) (latticeArrays Γ) + intro g hg v + simpa only [face_apply, Finset.empty_subset, ite_true] using hg + | @insert a I ha ih => + rw [cube_insert_eq] + apply (ih k).sup _ (cube_le_normalizer_upper H a I k) + apply (ih (k + 1)).map_into (upper a) (continuous_upper a) (latticeArrays Γ) + intro f hf v + change (if a ∈ v then f v else 1) ∈ Γ + split_ifs + · exact hf v + · exact Γ.one_mem + +end CompactCubes + +end CubeFaces + +namespace CompactGroupProducts +open Topology +variable {G : Type*} [Group G] [TopologicalSpace G] + + + +lemma HasCompactReps.comap_subtype {A K Γ : Subgroup G} + (h : HasCompactReps A Γ) (hAK : A ≤ K) : + HasCompactReps (A.comap K.subtype) (Γ.comap K.subtype) := by + obtain ⟨C,hC,hCA,hr⟩ := h + let D : Set K := Subtype.val ⁻¹' C + have hD : IsCompact D := by + apply IsEmbedding.subtypeVal.isCompact_iff.mpr + have he : Subtype.val '' D = C := by + ext x + exact ⟨fun ⟨y,hy,he⟩ => he ▸ hy,fun hx => ⟨⟨x,hAK (hCA hx)⟩,hx,rfl⟩⟩ + rwa [he] + refine ⟨D,hD,fun x hx => hCA hx,?_⟩ + intro x hx + obtain ⟨c,hc,hcx⟩ := hr x hx + exact ⟨⟨c,hAK (hCA hc)⟩,hc,hcx⟩ + +lemma HasCompactReps.top_comap_subtype {K Γ : Subgroup G} + (h : HasCompactReps K Γ) : HasCompactReps ⊤ (Γ.comap K.subtype) := by + have he : K.comap K.subtype = ⊤ := by ext x; simp + simpa only [he] using h.comap_subtype (le_refl K) + +end CompactGroupProducts +end +end + + + +section + +noncomputable section +open scoped Topology commutatorElement +namespace CubeMaxFiltration +open CubeFaces CompactGroupProducts +variable {G ι : Type} [Group G] [TopologicalSpace G] [IsTopologicalGroup G] +variable [Fintype ι] [DecidableEq ι] + + + +def clamp (H : Filtration G) (k : ℕ) : Filtration G where + level j := H.level (max k j) + antitone := fun i j hij => H.antitone (max_le_max_left k hij) + commutator_le i j := (H.commutator_le _ _).trans (H.antitone (by omega)) + +omit [TopologicalSpace G] [IsTopologicalGroup G] [Fintype ι] in +lemma level_eq_clamp_cube [TopologicalSpace G] [IsTopologicalGroup G] [Fintype ι] + (H : Filtration G) (I : Finset ι) (k : ℕ) : + level H I k=cube (clamp H k) I 0 := by + simp only [level,cube,clamp,Nat.add_zero] + + + +theorem hasCompactReps_level (H : Filtration G) (Γ : Subgroup G) + (hr : ∀ j,HasCompactReps (H.level j) Γ) (k : ℕ) : + HasCompactReps ((filtration H (Finset.univ : Finset ι)).level k) + (CubeLocalHaar.cubeLattice H Γ) := by + have hh := cube_hasCompactReps (clamp H k) Γ (fun j => hr (max k j)) + (Finset.univ : Finset ι) 0 + rw [←level_eq_clamp_cube] at hh + exact hh.comap_subtype (by + rw [←level_zero] + exact antitone H Finset.univ (Nat.zero_le k)) + +end CubeMaxFiltration + +namespace CubeLocalHaar +open CubeFaces CompactGroupProducts MeasureTheory +variable {G ι : Type} [Group G] [TopologicalSpace G] [IsTopologicalGroup G] +variable [Fintype ι] [DecidableEq ι] + +omit [IsTopologicalGroup G] in +lemma cubeLattice_discrete [IsTopologicalGroup G] (H : Filtration G) (Γ : Subgroup G) + (hΓ : IsDiscrete (Γ:Set G)) : + IsDiscrete (cubeLattice (ι := ι) H Γ : Set (cube H (Finset.univ : Finset ι) 0)) := by + let : DiscreteTopology Γ := isDiscrete_iff_discreteTopology.mp hΓ + let φ : cubeLattice H Γ→(Finset ι→Γ) := fun x w => ⟨(x.val:Finset ι→G) w,x.property w⟩ + have hc : Continuous φ := by + apply continuous_pi + intro w + exact ((continuous_apply w).comp (continuous_subtype_val.comp continuous_subtype_val)).subtype_mk _ + have hi : Function.Injective φ := by + intro x y he + apply Subtype.ext + apply Subtype.ext + funext w + exact congrArg Subtype.val (congrFun he w) + let : DiscreteTopology (cubeLattice H Γ) := DiscreteTopology.of_continuous_injective hc hi + exact isDiscrete_iff_discreteTopology.mpr inferInstance + +variable [T2Space G] [SecondCountableTopology G] + + + +theorem existsUnique_cubeHaar (H : Filtration G) (h01 : H.level 0=H.level 1) + (s : ℕ) (hs : H.level (s+1)=⊥) (Γ : Subgroup G) + (hr : ∀ j,HasCompactReps (H.level j) Γ) (hΓ : IsDiscrete (Γ:Set G)) + [MeasurableSpace ((cube H (Finset.univ : Finset ι) 0)⧸cubeLattice H Γ)] + [BorelSpace ((cube H (Finset.univ : Finset ι) 0)⧸cubeLattice H Γ)] : + ∃! μ : ProbabilityMeasure ((cube H (Finset.univ : Finset ι) 0)⧸cubeLattice H Γ), + SMulInvariantMeasure (cube H (Finset.univ : Finset ι) 0) + ((cube H (Finset.univ : Finset ι) 0)⧸cubeLattice H Γ) + (μ : Measure ((cube H (Finset.univ : Finset ι) 0)⧸cubeLattice H Γ)) := by + let : SecondCountableTopology (cube H (Finset.univ : Finset ι) 0) := + Topology.IsInducing.subtypeVal.secondCountableTopology + let K := CubeMaxFiltration.filtration H (Finset.univ : Finset ι) + apply RationalNilmanifoldMeasure.existsUnique_invariant (s+1) (cubeLattice H Γ) K.level + (CubeMaxFiltration.filtration_zero H Finset.univ) + (CubeMaxFiltration.filtration_bot H Finset.univ hs) + · intro i g x hx + have hg : g∈K.level 1 := by rw [CubeMaxFiltration.filtration_one H Finset.univ h01]; trivial + simpa only [Nat.add_comm] using K.commutator_le 1 i (Subgroup.commutator_mem_commutator hg hx) + · exact fun i => CubeMaxFiltration.hasCompactReps_level H Γ hr i + · exact cubeLattice_discrete H Γ hΓ + +end CubeLocalHaar + +end +end +end +end +end + +end OAI diff --git a/lean/OAI/Combinatorics/SumProduct/Alignment/CubeKernel01.lean b/lean/OAI/Combinatorics/SumProduct/Alignment/CubeKernel01.lean new file mode 100644 index 0000000000000000000000000000000000000000..a012fd0549854e2af4bcba7722ddba5497be7826 --- /dev/null +++ b/lean/OAI/Combinatorics/SumProduct/Alignment/CubeKernel01.lean @@ -0,0 +1,317 @@ +import Mathlib +import OAI.Combinatorics.SumProduct.Alignment.CubeRationalization01 +import OAI.Geometry.NilpotentCharts.Main + +namespace OAI + +section +noncomputable section +open Finset Filter +open scoped BigOperators Topology +end + +end + + +section + + + +noncomputable section +open Finset +open scoped BigOperators +namespace CubeKernel +open CubeSplitProducer CubeCoefficients CubeParameter RealPolynomialDegree RoughPolynomialDegree +open RationalLattice MalcevCharacters RoughKernelFactorization PolynomialLineCoefficients CorrectedBoxLeibman + +lemma value_sub {n v s : ℕ} (θ m : PolynomialLineCoefficients.Grid v s → (Fin n → ℝ) → ℝ) + (y : Fin (n+v) → ℝ) : + value (fun I z => θ I z-m I z) y = value θ y-value m y := by + simp only [value, gridEval, sub_mul, sum_sub_distrib] + +lemma integer_spatial {n v s : ℕ} (m : PolynomialLineCoefficients.Grid v s → (Fin n → ℝ) → ℝ) + (z : Fin n → Bool) (hm : ∀ I, ∃ k : ℤ, m I (realVertex z) = k) : + ∃ p : MvPolynomial (Fin v) ℤ, ∀ x : Fin v → ℤ, + ((MvPolynomial.eval x p:ℤ):ℝ) = value m (Fin.append (realVertex z) (fun i => (x i:ℝ))) := by + classical + choose a ha using hm + let p : MvPolynomial (Fin v) ℤ := ∑ I, MvPolynomial.monomial (gridExponent I) (a I) + refine ⟨p, ?_⟩ + intro x + simp only [p, MvPolynomial.eval_sum, MvPolynomial.eval_monomial, Int.cast_sum, value_append, gridEval] + apply sum_congr rfl + intro I _ + rw [ha] + push_cast + congr 1 + rw [Finsupp.prod_fintype _ _ (by intro i; simp)] + rfl + +lemma spatial_affine {n v d : ℕ} {f : (Fin (n+v) → ℝ) → ℝ} (hf : HasDegree f d) + (u : Fin v → ℝ) (K : ℝ) : + HasDegree (fun y : Fin (n+v) → ℝ => + f (Fin.append (fun i => y (i.castAdd v)) (fun i => u i+K*y (i.natAdd n)))) d := by + have hT (i : Fin (n+v)) : HasDegree (fun y : Fin (n+v) → ℝ => + Fin.append (fun i => y (i.castAdd v)) (fun i => u i+K*y (i.natAdd n)) i) 1 := by + refine Fin.addCases ?_ ?_ i + · intro j + simpa only [Fin.append_left] using coordinate (j.castAdd v) + · intro j + simpa only [Fin.append_right, max_self] using RealPolynomialDegree.add + (RealPolynomialDegree.const (σ:=Fin (n+v)) (u j) 1) + (RealPolynomialDegree.scale (coordinate (j.natAdd n)) K) + simpa only [one_mul] using compose hf _ hT + +lemma split_subspace {G : Type} [Group G] {n N v q s : ℕ} + {P : (Fin (N+v) → ℝ) → G} {ξ : G →* Multiplicative ℝ} {Z B : ℝ} + (h : Split q s P ξ Z B) (l : Combinatorics.Subspace (Fin n) Bool (Fin N)) : + Split q s (fun y => P (lift l y)) ξ Z B := by + obtain ⟨θ,m,hθ,hm,he,hi,herr⟩ := h + refine ⟨fun I z => θ I (parameterLift l z), fun I z => m I (parameterLift l z), + fun I => degree_parameterLift l (hθ I), fun I => degree_parameterLift l (hm I), ?_, ?_, ?_⟩ + · intro z x + simpa only [lift_append] using he (parameterLift l z) x + · intro I z + simpa only [parameterLift_vertex] using hi I (l z) + · intro I z + simpa only [parameterLift_vertex] using herr I (l z) + +variable {G : Type} [Group G] [TopologicalSpace G] [IsTopologicalGroup G] +variable {r : ℕ} (c : RealCoordinates G (r+1)) (hsk : SecondKind c) +variable (χ : G →* Multiplicative ℝ) (Γ : Subgroup G) (R : Reduction c hsk χ Γ) + + +theorem kernel_polynomial : ∃ E : ℕ, 0 < E ∧ ∀ n v D q s : ℕ, + ∀ P : (Fin (n+v) → ℝ) → G, + ∀ θ m : PolynomialLineCoefficients.Grid v s → (Fin n → ℝ) → ℝ, + (∀ i, HasDegree (fun y => canonicalLog c (P y) i) D) → + (∀ I, HasDegree (θ I) q) → (∀ I, HasDegree (m I) q) → + (∀ z x, gridEval (fun I => θ I z) x = (χ (P (Fin.append z x))).toAdd) → + ∃ Q : (Fin (n+v) → ℝ) → χ.ker, + (∀ y, P y = R.flow c hsk χ Γ (Multiplicative.ofAdd (value (fun I z => θ I z-m I z) y))* + (Q y).val*R.flow c hsk χ Γ (Multiplicative.ofAdd (value m y))) ∧ + ∀ i, HasDegree (fun y => canonicalLog (R.chart c hsk χ Γ) (Q y) i) + (E*max D (q+v*s)) := by + obtain ⟨E,hE,hfactor⟩ := R.logarithmic_factorization c hsk χ Γ + refine ⟨E,hE,?_⟩ + intro n v D q s P θ m hP hθ hm he + apply hfactor (n+v) (max D (q+v*s)) P (value (fun I z => θ I z-m I z)) (value m) + · intro y + rw [value_sub, sub_add_cancel] + simpa only [value, Fin.append_castAdd_natAdd] using + (he (fun i => y (i.castAdd v)) (fun i => y (i.natAdd n))).symm + · exact fun i => RealPolynomialDegree.mono (hP i) (le_max_left _ _) + · apply RealPolynomialDegree.mono _ (le_max_right _ _) + apply value_degree + intro I + simpa only [max_self, sub_eq_add_neg] using RealPolynomialDegree.add (hθ I) (RealPolynomialDegree.neg (hm I)) + · exact RealPolynomialDegree.mono (value_degree m hm) (le_max_right _ _) + +end CubeKernel + +end + +end + + +section + + + +noncomputable section +open Finset +open scoped BigOperators +namespace CubeReduction +open RationalLattice MalcevCharacters RoughKernelFactorization RealPolynomialDegree +open RoughCubeBlock CubeSplitProducer CubeKernel CubeParameter CubeCoefficients +open RoughScales RoughCommonKernelDiscrepancy RoughCommonKernelCover +open RoughSamplingWeights FinitePieceAverages PolynomialLineCoefficients CorrectedBoxLeibman +open DenseBooleanCubes Combinatorics +variable {G : Type} [Group G] [TopologicalSpace G] [IsTopologicalGroup G] +variable {r : ℕ} (c : RealCoordinates G (r+1)) (hsk : SecondKind c) +variable (χ : G →* Multiplicative ℝ) (Γ : Subgroup G) (R : Reduction c hsk χ Γ) +variable (hΓ : ∀ g : G, g ∈ Γ ↔ ∀ i, ∃ z : ℤ, c.coord g i=z) +variable (hcont : Continuous χ) (hZint : ∀ g ∈ Γ, ∃ z : ℤ, (χ g).toAdd=z) +variable [mtr : MetricSpace (G⧸Γ)] +variable (htop : mtr.toUniformSpace.toTopologicalSpace = QuotientGroup.instTopologicalSpace Γ) +local instance : TopologicalSpace (G⧸Γ) := mtr.toUniformSpace.toTopologicalSpace + +private def metricIdentity : + @Homeomorph (G⧸Γ) (G⧸Γ) (QuotientGroup.instTopologicalSpace Γ) mtr.toUniformSpace.toTopologicalSpace := by + refine @Homeomorph.mk _ _ (QuotientGroup.instTopologicalSpace Γ) mtr.toUniformSpace.toTopologicalSpace + (Equiv.refl _) ?_ ?_ + · rw [htop]; exact @continuous_id (G⧸Γ) (QuotientGroup.instTopologicalSpace Γ) + · rw [htop]; exact @continuous_id (G⧸Γ) (QuotientGroup.instTopologicalSpace Γ) + +include hΓ hcont hZint htop in +theorem reduce_split_cubes (v D q s : ℕ) (c₀ C₀ A : ℝ) (B : NNReal) (η : ℝ) + (hc₀ : 0 < c₀) (hC₀ : 0 < C₀) (hA : 0 ≤ A) (hη : 0 < η) : + ∃ Λ : Subgroup χ.ker, ∃ d : RealCoordinates χ.ker r, SecondKind d ∧ + ∃ hΛ : ∀ g : χ.ker, g ∈ Λ ↔ ∀ i, ∃ z : ℤ, d.coord g i=z, + ∃ D' : ℕ, ∃ c' : ℝ, 0 < c' ∧ ∃ B' : NNReal, 0 < B' ∧ ∃ δ : ℝ, 0 < δ ∧ + letI := coordinateQuotientMetric d Λ hΛ + ∀ H : ℕ, ∃ N : ℕ, ∀ (w K : ℕ) (S Z : ℝ), R.period ≤ w → + 0 < S → (R.period:ℝ) ≤ Z → 1+2*S ≤ δ*Z → + ∀ b : Block c Γ v D c₀ C₀ B η w S Z N K, Split q s b.P χ Z A → + Nonempty (Block d Λ v D' c' (C₀+1) B' (η/2) w S (Z/R.period) H (N*K)) := by + classical + obtain ⟨Λ,d,hd,hΛ,hle,E,hE,hdegree⟩ := common_kernel_cover c hsk χ Γ R hΓ + let := coordinateQuotientMetric d Λ hΛ + obtain ⟨J,hJ,hkernel⟩ := CubeKernel.kernel_polynomial c hsk χ Γ R + let ε : ℝ := η/14 + have hε : 0 < ε := by dsimp [ε]; positivity + obtain ⟨M₀,hM₀,B',hB',δ,hδ,hdisc⟩ := source_common_kernel_discrepancy c hsk χ Γ R hΓ hcont hZint + Λ d hΛ hle (metricIdentity Γ htop) (fun (I : PolynomialLineCoefficients.Grid v s) i => (I i).val) + A C₀ c₀ (B:ℝ) hA hC₀.le hc₀ B.coe_nonneg B ε hε + let D' := E*(J*max D (q+v*s)) + refine ⟨Λ,d,hd,hΛ,D',c₀/(M₀:ℝ),div_pos hc₀ (by exact_mod_cast hM₀),B',hB',δ,hδ,?_⟩ + intro H + obtain ⟨N,hN⟩ := colored_subcube H (Fin v → Fin R.period) + refine ⟨N,?_⟩ + intro w K S Z hwp hS hZ hsmall b hsplit + obtain ⟨θ,m,hθ,hm,he,hmi,hmerr⟩ := hsplit + obtain ⟨Q,hQP,hQdeg⟩ := hkernel N v D q s b.P θ m b.degree hθ hm he + have hQd : ∀ i, HasDegree (fun y => canonicalLog d (Q y) i) D' := + hdegree (N+v) _ Q hQdeg + have hfib (z : Fin N → Bool) : + ∃ u : Fin v → Fin R.period, ∃ (lo hi : Fin v → ℝ) (res : Fin v → ℤ) (f : (χ.ker⧸Λ) → ℂ), + LipschitzWith B' f ∧ (∀ y, ‖f y‖ ≤ B') ∧ + (∀ i, -(C₀+1)*(Z/R.period) ≤ lo i ∧ hi i ≤ (C₀+1)*(Z/R.period)) ∧ + (∀ i, (c₀/M₀)*(Z/R.period) ≤ hi i-lo i) ∧ + η/2 ≤ ‖mean (boxIndices lo hi (fun _ => 0) 1) + (fun y => f (QuotientGroup.mk (Q (Fin.append (realVertex z) + (fun i => ((integerAffine (fun i => ((u i).val:ℤ)) R.period y i:ℤ):ℝ)))))) - + mean (physicalResidueBox lo hi res (time b.start b.step b.weight z).natAbs) + (fun y => f (QuotientGroup.mk (Q (Fin.append (realVertex z) + (fun i => ((integerAffine (fun i => ((u i).val:ℤ)) R.period y i:ℤ):ℝ))))))‖ := by + have htpos : 0 < time b.start b.step b.weight z := by exact_mod_cast hS.trans_le (b.scales z).1 + have hcast : ((time b.start b.step b.weight z).natAbs:ℝ) = (time b.start b.step b.weight z:ℝ) := by + rw [Nat.cast_natAbs, Int.cast_abs, abs_of_pos (by exact_mod_cast htpos)] + have htK : (time b.start b.step b.weight z).natAbs.Coprime R.period := + (RoughSamplingWeights.period_coprime_of_rough w R.period _ R.period_pos hwp + ((rough_iff_coprime w _).mp (b.rough z))).symm + obtain ⟨p,hp⟩ := integer_spatial m z (fun I => hmi I z) + have hfactor (x : Fin v → ℤ) : b.P (Fin.append (realVertex z) (fun i => (x i:ℝ))) = + R.flow c hsk χ Γ (Multiplicative.ofAdd (UniformSlowPolynomials.form + (fun (I : PolynomialLineCoefficients.Grid v s) i => (I i).val) + (fun I => θ I (realVertex z)-m I (realVertex z)) (fun i => (x i:ℝ)))) * + (Q (Fin.append (realVertex z) (fun i => (x i:ℝ)))).val * + R.flow c hsk χ Γ (Multiplicative.ofAdd ((MvPolynomial.eval x p:ℤ):ℝ)) := by + rw [hp] + simpa only [value_append, UniformSlowPolynomials.form, gridEval] using hQP (Fin.append (realVertex z) (fun i => (x i:ℝ))) + obtain ⟨u,lo,hi,res,f,hf,hfB,hbox,hside,hbad⟩ := hdisc Z hZ + (fun I => θ I (realVertex z)-m I (realVertex z)) (fun I => hmerr I z) + (b.lo z) (b.hi z) (by simpa only [neg_mul] using b.box z) (b.side z) + (b.res z) _ (Int.natAbs_pos.mpr htpos.ne') htK (by rw [hcast]; linarith [(b.scales z).2]) + (b.test z) (b.lip z) (b.bound z) + (fun x => b.P (Fin.append (realVertex z) (fun i => (x i:ℝ)))) + (fun x => Q (Fin.append (realVertex z) (fun i => (x i:ℝ)))) p hfactor η (b.bad z) + refine ⟨u,lo,hi,res,f,hf,hfB,hbox,hside,?_⟩ + convert hbad using 1 + dsimp [ε] + ring + choose u lo hi res f hf hfB hbox hside hbad using hfib + obtain ⟨l,u₀,hu⟩ := hN u + let b₁ := b.subspace l + let Q' : (Fin (N+v) → ℝ) → χ.ker := fun y => + Q (Fin.append (fun i => y (i.castAdd v)) (fun i => ((u₀ i).val:ℝ)+(R.period:ℝ)*y (i.natAdd N))) + let P' : (Fin (H+v) → ℝ) → χ.ker := fun y => Q' (lift l y) + have hP' (i) : HasDegree (fun y => canonicalLog d (P' y) i) D' := + degree_lift l (spatial_affine (hQd i) (fun i => ((u₀ i).val:ℝ)) R.period) + refine ⟨{ + start := b₁.start + step := b₁.step + positive := b₁.positive + smooth := b₁.smooth + weight := b₁.weight + weight_pos := b₁.weight_pos + weight_bound := b₁.weight_bound + scales := b₁.scales + rough := b₁.rough + P := P' + degree := hP' + lo := fun z => lo (l z) + hi := fun z => hi (l z) + res := fun z => res (l z) + test := fun z => f (l z) + side := fun z => hside _ + box := fun z => hbox _ + lip := fun z => hf _ + bound := fun z => hfB _ + bad := ?_ }⟩ + intro z + simpa only [P', Q', lift_vertex, Fin.append_left, Fin.append_right, integerAffine, + hu z, Int.cast_add, Int.cast_mul, Int.cast_natCast, b₁, Block.subspace, time_subspace] + using hbad (l z) + +end CubeReduction + +end + +end + + +section + +noncomputable section +namespace CubeZero +open RationalLattice RoughCubeBlock RoughSamplingWeights FinitePieceAverages Filter +variable {G : Type} [Group G] [TopologicalSpace G] +variable (c : RealCoordinates G 0) (Γ : Subgroup G) [mtr : MetricSpace (G⧸Γ)] +local instance : TopologicalSpace (G⧸Γ) := mtr.toUniformSpace.toTopologicalSpace + +theorem no_cube_at (v D w n K : ℕ) (c₀ C₀ S Z η : ℝ) (B : NNReal) + (hη : 0 < η) (hS : 1 ≤ S) (hZ : 8*S ≤ c₀*Z) : + IsEmpty (Block c Γ v D c₀ C₀ B η w S Z n K) := by + classical + let : Subsingleton G := ⟨fun g h => c.coord.injective (Subsingleton.elim _ _)⟩ + let : Subsingleton (G⧸Γ) := inferInstance + refine ⟨fun b => ?_⟩ + let z : Fin n → Bool := fun _ => false + let t := time b.start b.step b.weight z + have hscale := b.scales z + have ht0 : 0 < t := by exact_mod_cast (show (0:ℝ) < t by exact zero_lt_one.trans_le (hS.trans hscale.1)) + have ht : 0 < t.natAbs := Int.natAbs_pos.mpr ht0.ne' + have hcast : (t.natAbs:ℝ) = (t:ℝ) := by + rw [Nat.cast_natAbs, Int.cast_abs, abs_of_pos (by exact_mod_cast ht0)] + have hside (i) : 4*(t.natAbs:ℝ) ≤ b.hi z i-b.lo z i := by + rw [hcast] + have hh := b.side z i + dsimp only [t] + linarith + have hlarge (i) : 4*(1:ℝ) ≤ b.hi z i-b.lo z i := by + have hh : (1:ℝ) ≤ t.natAbs := by exact_mod_cast ht + linarith [hside i] + have h₁ := box_nonempty (b.lo z) (b.hi z) (fun _ => 0) 1 zero_lt_one hlarge + have h₂ := RoughZeroDimension.physical_nonempty (b.lo z) (b.hi z) (b.res z) t.natAbs ht hside + have hF : (fun x : Fin v → ℤ => b.test z (QuotientGroup.mk + (b.P (Fin.append (CubeParameter.realVertex z) (fun i => (x i:ℝ)))))) = + (fun _ => b.test z (QuotientGroup.mk (1:G))) := by + funext x + exact congrArg (b.test z) (Subsingleton.elim _ _) + have hb := b.bad z + rw [hF, RoughZeroDimension.constant_mean _ h₁, RoughZeroDimension.constant_mean _ h₂, + sub_self, norm_zero] at hb + exact (not_le_of_gt hη) hb + +theorem eventually_no_zero_cubes (v D : ℕ) (c₀ C₀ : ℝ) (B : NNReal) (η : ℝ) + (hc₀ : 0 < c₀) (hη : 0 < η) {w : ℕ → ℕ} {S Z : ℕ → ℝ} + (hS : Tendsto S atTop atTop) + (hZ : ∀ k : ℕ, Tendsto (fun j => Z j/S j^k) atTop atTop) : + ∀ᶠ j in atTop, ∀ n K : ℕ, IsEmpty (Block c Γ v D c₀ C₀ B η (w j) (S j) (Z j) n K) := by + have hr : ∀ᶠ j in atTop, 8/c₀ ≤ Z j/S j := by + simpa only [pow_one] using (hZ 1).eventually (eventually_ge_atTop (8/c₀)) + filter_upwards [hS.eventually (eventually_ge_atTop 1),hr] with j hj hjZ + intro n K + apply no_cube_at c Γ v D (w j) n K c₀ C₀ (S j) (Z j) η B hη hj + have hh : (8/c₀)*S j ≤ Z j := (le_div_iff₀ (by linarith)).mp hjZ + have hhh := mul_le_mul_of_nonneg_left hh hc₀.le + field_simp at hhh + nlinarith + +end CubeZero + +end +end + +end OAI diff --git a/lean/OAI/Combinatorics/SumProduct/Alignment/CubeLocal01.lean b/lean/OAI/Combinatorics/SumProduct/Alignment/CubeLocal01.lean new file mode 100644 index 0000000000000000000000000000000000000000..45845fd2881229bcba1244c109086f4384956471 --- /dev/null +++ b/lean/OAI/Combinatorics/SumProduct/Alignment/CubeLocal01.lean @@ -0,0 +1,332 @@ +import Mathlib +import OAI.Combinatorics.SumProduct.Alignment.CubeFaces02 +import OAI.Geometry.NilpotentCharts.Main + +namespace OAI + +section +section +section +section +noncomputable section +open scoped Topology commutatorElement +end +end + + + +section + +noncomputable section +open scoped Topology +namespace CubeLocalHaar +open CubeFaces MeasureTheory +variable {G ι : Type} [Group G] [TopologicalSpace G] [IsTopologicalGroup G] +variable [Fintype ι] [DecidableEq ι] + + +def conjugateLattice (Λ : Subgroup G) (σ : G) : Subgroup G := + Λ.comap (MulAut.conj σ⁻¹).toMonoidHom + +omit [TopologicalSpace G] [IsTopologicalGroup G] in +@[simp] lemma mem_conjugateLattice [TopologicalSpace G] [IsTopologicalGroup G] + (Λ : Subgroup G) (σ g : G) : + g∈conjugateLattice Λ σ ↔ σ⁻¹*g*σ∈Λ := by + simp [conjugateLattice,mul_assoc] + + + +def baseImage (H : Filtration G) (Λ : Subgroup G) (σ : G) : + ((cube H (Finset.univ : Finset ι) 0)⧸cubeLattice H (conjugateLattice Λ σ)) → + (Finset ι→G⧸Λ) := + Quotient.lift (fun g w => QuotientGroup.mk ((g.val w)*σ)) (by + intro g h he + funext w + apply QuotientGroup.eq.mpr + have hh := (QuotientGroup.leftRel_apply.mp he) w + change (g.val w)⁻¹*h.val w∈conjugateLattice Λ σ at hh + simpa only [mem_conjugateLattice,mul_inv_rev,inv_inv,mul_assoc] using hh) + +@[simp] lemma baseImage_mk (H : Filtration G) (Λ : Subgroup G) (σ : G) + (g : cube H (Finset.univ : Finset ι) 0) (w : Finset ι) : + baseImage H Λ σ (QuotientGroup.mk g) w=QuotientGroup.mk (g.val w*σ) := rfl + +lemma baseImage_continuous (H : Filtration G) (Λ : Subgroup G) (σ : G) : + Continuous (baseImage (ι := ι) H Λ σ) := by + apply (QuotientGroup.isQuotientMap_mk _).continuous_iff.mpr + apply continuous_pi + intro w + exact QuotientGroup.continuous_mk.comp + (((continuous_apply w).comp continuous_subtype_val).mul continuous_const) + +lemma baseImage_injective (H : Filtration G) (Λ : Subgroup G) (σ : G) : + Function.Injective (baseImage (ι := ι) H Λ σ) := by + intro x y he + induction x using Quotient.inductionOn with | h g => + induction y using Quotient.inductionOn with | h h => + apply QuotientGroup.eq.mpr + intro w + have hh := QuotientGroup.eq.mp (congrFun he w) + change (g.val w*σ)⁻¹*(h.val w*σ)∈Λ at hh + change (g.val w)⁻¹*h.val w∈conjugateLattice Λ σ + simpa only [mem_conjugateLattice,mul_inv_rev,inv_inv,mul_assoc] using hh + + + +def haarImage (H : Filtration G) (Λ : Subgroup G) (σ : G) (a : Finset ι→G) + (x : (cube H (Finset.univ : Finset ι) 0)⧸cubeLattice H (conjugateLattice Λ σ)) : + Finset ι→G⧸Λ := fun w => a w • baseImage H Λ σ x w + +@[simp] lemma haarImage_mk (H : Filtration G) (Λ : Subgroup G) (σ : G) + (a : Finset ι→G) (g : cube H (Finset.univ : Finset ι) 0) (w : Finset ι) : + haarImage H Λ σ a (QuotientGroup.mk g) w=QuotientGroup.mk (a w*g.val w*σ) := by + change QuotientGroup.mk (a w*(g.val w*σ))=QuotientGroup.mk (a w*g.val w*σ) + rw [mul_assoc] + +lemma haarImage_continuous (H : Filtration G) (Λ : Subgroup G) (σ : G) : + Continuous (fun p : (Finset ι→G)× + ((cube H (Finset.univ : Finset ι) 0)⧸cubeLattice H (conjugateLattice Λ σ)) => + haarImage H Λ σ p.1 p.2) := by + apply continuous_pi + intro w + exact ((continuous_apply w).comp continuous_fst).smul + ((continuous_apply w).comp ((baseImage_continuous H Λ σ).comp continuous_snd)) + +end CubeLocalHaar +end +end + + + +section + +noncomputable section +open scoped BigOperators Topology +namespace FiniteHaarTests +open MeasureTheory Filter +variable {X κ : Type*} [MetricSpace X] [CompactSpace X] +variable [MeasurableSpace X] [BorelSpace X] +variable (μ : Measure X) [IsProbabilityMeasure μ] + +def discrepancy (T : Finset κ) (p : κ→X) : C(X,ℂ)→ₗ[ℂ]ℂ where + toFun F := (𝔼 z∈T,F (p z))-(∫ x,F x ∂μ) + map_add' F G := by + change (𝔼 z∈T,(F (p z)+G (p z)))-(∫ x,F x+G x ∂μ)=_ + rw [Finset.expect_add_distrib,integral_add + (F.continuous.integrable_of_hasCompactSupport (HasCompactSupport.of_compactSpace F)) + (G.continuous.integrable_of_hasCompactSupport (HasCompactSupport.of_compactSpace G))] + ring + map_smul' z F := by + change (𝔼 x∈T,z • F (p x))-(∫ x,z • F x ∂μ)=_ + rw [←Finset.smul_expect,integral_smul] + simp only [RingHom.id_apply,smul_sub] + +lemma discrepancy_bound (T : Finset κ) (p : κ→X) (F : C(X,ℂ)) : + ‖discrepancy μ T p F‖≤2*‖F‖ := by + have hm : ‖𝔼 z∈T,F (p z)‖≤‖F‖ := by + by_cases hT : T.Nonempty + · exact (RCLike.norm_expect_le (K := ℂ)).trans + (Finset.expect_le hT (fun _ _ => F.norm_coe_le_norm _)) + · simp only [Finset.not_nonempty_iff_eq_empty.mp hT,Finset.expect_empty,norm_zero] + exact norm_nonneg _ + have hi : ‖∫ x,F x ∂μ‖≤‖F‖ := by + simpa only [probReal_univ,mul_one] using norm_integral_le_of_norm_le_const (μ := μ) + (Eventually.of_forall F.norm_coe_le_norm) + exact (norm_sub_le _ _).trans (by linarith only [hm,hi]) + + + +theorem compact_tests (K : Set C(X,ℂ)) (hK : IsCompact K) (ε : ℝ) (hε : 0<ε) : + ∃ η : ℝ,0<η ∧ ∀ (T : Finset κ) (p : κ→X), + (∀ F : C(X,ℂ),LipschitzWith 1 F → ‖F‖≤1 → ‖discrepancy μ T p F‖<η) → + ∀ F∈K,‖discrepancy μ T p F‖<ε := by + obtain ⟨S,hS,η,hη,htest⟩ := CompactFamilyDescent.finite_unit_lipschitz_obstruction + K hK ε 2 hε (by norm_num) + refine ⟨η,hη,?_⟩ + intro T p hh F hF + by_contra he + obtain ⟨φ,hφ,hdisc⟩ := htest (discrepancy μ T p) (discrepancy_bound μ T p) + ⟨F,hF,le_of_not_gt he⟩ + exact (not_le_of_gt (hh φ (hS φ hφ).1 (hS φ hφ).2)) hdisc + + + +theorem continuous_test {l : Filter ℕ} (T : ℕ→Finset κ) (p : ℕ→κ→X) + (hu : ∀ ε : ℝ,0<ε → ∀ᶠ N in l, + ∀ F : C(X,ℂ),LipschitzWith 1 F → ‖F‖≤1 → ‖discrepancy μ (T N) (p N) F‖<ε) + (F : C(X,ℂ)) : Tendsto (fun N => discrepancy μ (T N) (p N) F) l (𝓝 0) := by + rw [Metric.tendsto_nhds] + intro ε hε + obtain ⟨η,hη,hηtest⟩ := compact_tests (κ := κ) μ {F} (isCompact_singleton) ε hε + filter_upwards [hu η hη] with N hN + simpa only [dist_zero_right] using hηtest (T N) (p N) hN F (Set.mem_singleton F) + +end FiniteHaarTests +end +end + + + +section +noncomputable section +open scoped BigOperators Topology commutatorElement +namespace CubeLocalHaar +open CubeFaces LeibmanSquare CubeTaylorExpansion CubeHorizontalIrrationality +open RationalLattice MeasureTheory Filter ComparableBoxLeibman MalcevCharacters AbelianMalcevTorus +variable {G ι : Type} [Group G] [TopologicalSpace G] [IsTopologicalGroup G] +variable [Fintype ι] [DecidableEq ι] +variable {n t d v : ℕ} (c : RealCoordinates G n) (H : Filtration G) +variable (S : ℕ→Set (Fin n)) +variable (hH : ∀ k (g : G),g∈H.level k ↔ ∀ i∈S k,c.coord g i=0) +variable (Γ : Subgroup G) (h01 : H.level 0=H.level 1) +variable (s : ℕ) (hs : H.level (s+1)=⊥) (e : Option ι≃Fin v) +variable (cc : RealCoordinates (cube H (Finset.univ : Finset ι) 0) (t+d)) +variable (hsk : SecondKind cc) +variable (q : ℕ→ℕ) (hqbound : ∀ k,q k ≤ t+d) +variable (hq : ∀ k (g : cube H (Finset.univ : Finset ι) 0), + g∈(CubeMaxFiltration.filtration H Finset.univ).level k ↔ + ∀ i : Fin (t+d),i.val < q k → cc.coord g i=0) +variable (hΓ : ∀ g : cube H (Finset.univ : Finset ι) 0, + g∈cubeLattice H Γ ↔ ∀ i,∃ z : ℤ,cc.coord g i=z) +variable [MeasurableSpace ((cube H (Finset.univ : Finset ι) 0)⧸cubeLattice H Γ)] +variable [hBorel : @BorelSpace ((cube H (Finset.univ : Finset ι) 0)⧸cubeLattice H Γ) (QuotientGroup.instTopologicalSpace (cubeLattice H Γ)) inferInstance] +variable [mtr : MetricSpace ((cube H (Finset.univ : Finset ι) 0)⧸cubeLattice H Γ)] +variable (htop : mtr.toUniformSpace.toTopologicalSpace=QuotientGroup.instTopologicalSpace (cubeLattice H Γ)) +local instance compactCubeTopology : TopologicalSpace ((cube H (Finset.univ : Finset ι) 0)⧸cubeLattice H Γ) := + mtr.toUniformSpace.toTopologicalSpace + +include h01 hs hsk hqbound hq hΓ htop in + + +theorem haar_limit_compact + (μ : Measure ((cube H (Finset.univ : Finset ι) 0)⧸cubeLattice H Γ)) + [IsProbabilityMeasure μ] + [SMulInvariantMeasure (cube H (Finset.univ : Finset ι) 0) _ μ] + (a : ℕ→∀ k : ℕ,H.level k) + (hirr : ∀ j : ℕ,0 < j → j ≤ s → ∀ ξ : H.level j→*Multiplicative ℝ, + ξ≠1 → Continuous ξ → RationalCharacter Γ ξ → + (∀ x (hx : x∈H.level (j+1)),ξ ⟨x,H.antitone (Nat.le_succ _) hx⟩=1) → + (∀ i k : ℕ,0 < i → 0 < k → ∀ h : i+k=j, + ∀ x (hx : x∈H.level i) y (hy : y∈H.level k), + ξ ⟨⁅x,y⁆,by rw [←h]; exact H.commutator_le i k (Subgroup.commutator_mem_commutator hx hy)⟩=1) → + Tendsto (fun N : ℕ => ‖((ξ (a N j)).toAdd:UnitAddCircle)‖*(N:ℝ)^j) + atTop atTop) + (c₀ C₀ : ℝ) (hc₀ : 0 ((r (e i)+(d₀:ℤ)*x (e i):ℤ):ℝ)))))-(∫ y,F y ∂μ)‖<η := by + let : CompactSpace ((cube H (Finset.univ : Finset ι) 0)⧸cubeLattice H Γ) := + metric_compact cc (cubeLattice H Γ) hΓ mtr htop + let : BorelSpace ((cube H (Finset.univ : Finset ι) 0)⧸cubeLattice H Γ) := + metric_borelSpace (cubeLattice H Γ) mtr htop + intro η hη + obtain ⟨δ,hδ,htest⟩ := FiniteHaarTests.compact_tests (κ := Fin v→ℤ) μ K hK η hη + have hh := haar_limit c H S hH Γ h01 s hs e cc hsk q hqbound hq hΓ htop μ a hirr + c₀ C₀ 1 hc₀ hC₀ (by norm_num) d₀ hd₀ r δ hδ + filter_upwards [hh] with N hN + intro lo hi hlo hhi F hF + apply htest (integerBox v lo hi) + (fun x => QuotientGroup.mk (cubePolynomial c H S hH (a N) s + (fun i => ((r (e i)+(d₀:ℤ)*x (e i):ℤ):ℝ)))) _ F hF + intro φ hφ hφn + exact hN lo hi hlo hhi φ hφ hφn + +end CubeLocalHaar +end +end + + + +section + +noncomputable section +open scoped Topology +namespace CubeLocalHaar +open CubeFaces CompactGroupProducts MeasureTheory Filter +variable {G ι : Type} [Group G] [TopologicalSpace G] [IsTopologicalGroup G] +variable [Fintype ι] [DecidableEq ι] + +lemma cubeQuotient_compact (H : Filtration G) (Γ : Subgroup G) + (hr : ∀ j,HasCompactReps (H.level j) Γ) : + CompactSpace ((cube H (Finset.univ : Finset ι) 0)⧸cubeLattice H Γ) := by + have hh : HasCompactReps ⊤ (cubeLattice (ι := ι) H Γ) := by + simpa only [CubeMaxFiltration.filtration_zero] using + CubeMaxFiltration.hasCompactReps_level (ι := ι) H Γ hr 0 + exact hh.quotient_compactSpace + +variable (H : Filtration G) (Λ : Subgroup G) (σ : G) + + + +def frozenTest (F : C((Finset ι→G⧸Λ),ℂ)) (a : Finset ι→G) : + C(((cube H (Finset.univ : Finset ι) 0)⧸cubeLattice H (conjugateLattice Λ σ)),ℂ) := + ⟨fun x => F (haarImage H Λ σ a x),F.continuous.comp + ((haarImage_continuous H Λ σ).comp (continuous_const.prodMk continuous_id))⟩ + +lemma frozenTest_continuous (F : C((Finset ι→G⧸Λ),ℂ)) : + Continuous (frozenTest H Λ σ F) := by + exact (ContinuousMap.curry ⟨_,F.continuous.comp (haarImage_continuous H Λ σ)⟩).continuous + +variable [CompactSpace ((cube H (Finset.univ : Finset ι) 0)⧸cubeLattice H (conjugateLattice Λ σ))] + + + +theorem uniform_freezing (F : C((Finset ι→G⧸Λ),ℂ)) (a₀ : Finset ι→G) + (ε : ℝ) (hε : 0<ε) : + ∀ᶠ a in 𝓝 a₀,∀ x, + ‖F (haarImage H Λ σ a x)-F (haarImage H Λ σ a₀ x)‖<ε := by + have he := (frozenTest_continuous H Λ σ F).continuousAt.preimage_mem_nhds + (Metric.ball_mem_nhds (frozenTest H Λ σ F a₀) hε) + filter_upwards [he] with a ha + intro x + exact (ContinuousMap.norm_coe_le_norm + (frozenTest H Λ σ F a-frozenTest H Λ σ F a₀) x).trans_lt + (by simpa only [Set.mem_preimage,Metric.mem_ball,dist_eq_norm] using ha) + +variable [MeasurableSpace ((cube H (Finset.univ : Finset ι) 0)⧸cubeLattice H (conjugateLattice Λ σ))] +variable [BorelSpace ((cube H (Finset.univ : Finset ι) 0)⧸cubeLattice H (conjugateLattice Λ σ))] +variable [MeasurableSpace (G⧸Λ)] [BorelSpace (G⧸Λ)] +variable [SecondCountableTopology (G⧸Λ)] + + + +def imageProbability (μ : ProbabilityMeasure + ((cube H (Finset.univ : Finset ι) 0)⧸cubeLattice H (conjugateLattice Λ σ))) + (a : Finset ι→G) : ProbabilityMeasure (Finset ι→G⧸Λ) := + μ.map (haarImage H Λ σ a) + +omit [CompactSpace ((cube H (Finset.univ : Finset ι) 0)⧸cubeLattice H (conjugateLattice Λ σ))] in +lemma integral_imageProbability + [CompactSpace ((cube H (Finset.univ : Finset ι) 0)⧸cubeLattice H (conjugateLattice Λ σ))] + (μ : ProbabilityMeasure + ((cube H (Finset.univ : Finset ι) 0)⧸cubeLattice H (conjugateLattice Λ σ))) + (a : Finset ι→G) (F : C((Finset ι→G⧸Λ),ℂ)) : + (∫ y,F y ∂(imageProbability H Λ σ μ a : Measure (Finset ι→G⧸Λ)))= + ∫ x,frozenTest H Λ σ F a x ∂(μ : Measure _) := by + exact integral_map (φ := haarImage H Λ σ a) (μ := (μ : Measure _)) + (((haarImage_continuous H Λ σ).comp + (continuous_const.prodMk continuous_id)).measurable.aemeasurable) + F.continuous.aestronglyMeasurable + +end CubeLocalHaar + +end +end +end +end +end + +end OAI diff --git a/lean/OAI/Combinatorics/SumProduct/Alignment/CubeLocal02.lean b/lean/OAI/Combinatorics/SumProduct/Alignment/CubeLocal02.lean new file mode 100644 index 0000000000000000000000000000000000000000..8ae84b9f5dbb458908cca2cd2abdb8e22b246020 --- /dev/null +++ b/lean/OAI/Combinatorics/SumProduct/Alignment/CubeLocal02.lean @@ -0,0 +1,318 @@ +import Mathlib +import OAI.Combinatorics.SumProduct.Alignment.CubeLocal01 +import OAI.Geometry.NilpotentCharts.Main + +namespace OAI + +section +section +section +section +noncomputable section +open scoped Topology +end +end + + + +section + +noncomputable section +open scoped BigOperators Topology +namespace FiniteHaarTests +open Filter MeasureTheory +variable {X P κ : Type*} [MetricSpace X] [CompactSpace X] +variable [MeasurableSpace X] [BorelSpace X] [TopologicalSpace P] +variable (μ : Measure X) [IsProbabilityMeasure μ] + + + +theorem two_scale_freezing (F : P→C(X,ℂ)) (hF : Continuous F) (a₀ : P) + (T : ℝ→ℕ→Finset κ) (p : ℝ→ℕ→κ→X) (a : ℝ→ℕ→κ→P) + (hbase : ∀ α : ℝ,0<α → ∀ ε : ℝ,0<ε → ∀ᶠ N : ℕ in atTop, + ‖discrepancy μ (T α N) (p α N) (F a₀)‖<ε) + (hsm : ∀ U∈𝓝 a₀,∀ᶠ α : ℝ in 𝓝[>] 0,∀ᶠ N : ℕ in atTop, + ∀ z∈T α N,a α N z∈U) : + ∀ ε : ℝ,0<ε → ∀ᶠ α : ℝ in 𝓝[>] 0,∀ᶠ N : ℕ in atTop, + ‖(𝔼 z∈T α N,F (a α N z) (p α N z))-(∫ x,F a₀ x ∂μ)‖<ε := by + intro ε hε + have hε3 : 0<ε/3 := by positivity + let U : Set P := F ⁻¹' Metric.ball (F a₀) (ε/3) + have hU : U∈𝓝 a₀ := hF.continuousAt.preimage_mem_nhds + (Metric.ball_mem_nhds _ hε3) + filter_upwards [hsm U hU,(self_mem_nhdsWithin : Set.Ioi (0:ℝ)∈𝓝[>] 0)] with α hα ha + filter_upwards [hα,hbase α ha (ε/3) hε3] with N hN hb + have hp (z : κ) (hz : z∈T α N) : + ‖F (a α N z) (p α N z)-F a₀ (p α N z)‖≤ε/3 := by + apply (ContinuousMap.norm_coe_le_norm (F (a α N z)-F a₀) (p α N z)).trans + exact le_of_lt (by simpa only [U,Set.mem_preimage,Metric.mem_ball,dist_eq_norm] using hN z hz) + have hm : ‖𝔼 z∈T α N,(F (a α N z) (p α N z)-F a₀ (p α N z))‖≤ε/3 := by + by_cases hn : (T α N).Nonempty + · exact (RCLike.norm_expect_le (K := ℂ)).trans (Finset.expect_le hn hp) + · simp only [Finset.not_nonempty_iff_eq_empty.mp hn,Finset.expect_empty,norm_zero] + positivity + rw [Finset.expect_sub_distrib] at hm + change ‖(𝔼 z∈T α N,F a₀ (p α N z))-(∫ x,F a₀ x ∂μ)‖<ε/3 at hb + calc + _ = ‖((𝔼 z∈T α N,F (a α N z) (p α N z))-(𝔼 z∈T α N,F a₀ (p α N z)))+ + ((𝔼 z∈T α N,F a₀ (p α N z))-(∫ x,F a₀ x ∂μ))‖ := by congr 1; ring + _ ≤ _ := norm_add_le _ _ + _ < ε := by linarith only [hm,hb,hε] + +end FiniteHaarTests +end +end + + + +section +noncomputable section +open scoped BigOperators Topology commutatorElement +namespace CubeLocalHaar +open CubeFaces LeibmanSquare CubeTaylorExpansion CubeHorizontalIrrationality +open RationalLattice MeasureTheory Filter ComparableBoxLeibman MalcevCharacters AbelianMalcevTorus +variable {G ι : Type} [Group G] [TopologicalSpace G] [IsTopologicalGroup G] +variable [Fintype ι] [DecidableEq ι] +variable {n t d v : ℕ} (c : RealCoordinates G n) (H : Filtration G) +variable (S : ℕ→Set (Fin n)) +variable (hH : ∀ k (g : G),g∈H.level k ↔ ∀ i∈S k,c.coord g i=0) +variable (Λ : Subgroup G) (σ : G) (h01 : H.level 0=H.level 1) +variable (s : ℕ) (hs : H.level (s+1)=⊥) (e : Option ι≃Fin v) +variable (cc : RealCoordinates (cube H (Finset.univ : Finset ι) 0) (t+d)) +variable (hsk : SecondKind cc) +variable (q : ℕ→ℕ) (hqbound : ∀ k,q k ≤ t+d) +variable (hq : ∀ k (g : cube H (Finset.univ : Finset ι) 0), + g∈(CubeMaxFiltration.filtration H Finset.univ).level k ↔ + ∀ i : Fin (t+d),i.val < q k → cc.coord g i=0) +variable (hΓ : ∀ g : cube H (Finset.univ : Finset ι) 0, + g∈cubeLattice H (conjugateLattice Λ σ) ↔ ∀ i,∃ z : ℤ,cc.coord g i=z) +variable [MeasurableSpace ((cube H (Finset.univ : Finset ι) 0)⧸cubeLattice H (conjugateLattice Λ σ))] +variable [hBorel : @BorelSpace ((cube H (Finset.univ : Finset ι) 0)⧸cubeLattice H (conjugateLattice Λ σ)) (QuotientGroup.instTopologicalSpace (cubeLattice H (conjugateLattice Λ σ))) inferInstance] +variable (mtr : MetricSpace ((cube H (Finset.univ : Finset ι) 0)⧸cubeLattice H (conjugateLattice Λ σ))) +variable (htop : mtr.toUniformSpace.toTopologicalSpace=QuotientGroup.instTopologicalSpace (cubeLattice H (conjugateLattice Λ σ))) + +include h01 hs hsk hqbound hq hΓ htop in + + +theorem two_scale_cube_haar + (μ : Measure ((cube H (Finset.univ : Finset ι) 0)⧸cubeLattice H (conjugateLattice Λ σ))) + [IsProbabilityMeasure μ] + [SMulInvariantMeasure (cube H (Finset.univ : Finset ι) 0) _ μ] + (a : ℕ→∀ k : ℕ,H.level k) + (hirr : ∀ j : ℕ,0 < j → j ≤ s → ∀ ξ : H.level j→*Multiplicative ℝ, + ξ≠1 → Continuous ξ → RationalCharacter (conjugateLattice Λ σ) ξ → + (∀ x (hx : x∈H.level (j+1)),ξ ⟨x,H.antitone (Nat.le_succ _) hx⟩=1) → + (∀ i k : ℕ,0 < i → 0 < k → ∀ h : i+k=j, + ∀ x (hx : x∈H.level i) y (hy : y∈H.level k), + ξ ⟨⁅x,y⁆,by rw [←h]; exact H.commutator_le i k (Subgroup.commutator_mem_commutator hx hy)⟩=1) → + Tendsto (fun N : ℕ => ‖((ξ (a N j)).toAdd:UnitAddCircle)‖*(N:ℝ)^j) + atTop atTop) + + (d₀ : ℕ) (hd₀ : 0] 0,∀ᶠ N : ℕ in atTop, + ∀ z∈integerBox v (lo α N) (hi α N),u α N z∈U) + (F : C((Finset ι→G⧸Λ),ℂ)) : + ∀ ε : ℝ,0<ε → ∀ᶠ α : ℝ in 𝓝[>] 0,∀ᶠ N : ℕ in atTop, + ‖(𝔼 z∈integerBox v (lo α N) (hi α N), + F (haarImage H Λ σ (u α N z) (QuotientGroup.mk + (cubePolynomial c H S hH (a N) s + (fun i => ((r (e i)+(d₀:ℤ)*z (e i):ℤ):ℝ))))))- + (∫ x,frozenTest H Λ σ F u₀ x ∂μ)‖<ε := by + let : MetricSpace ((cube H (Finset.univ : Finset ι) 0)⧸cubeLattice H (conjugateLattice Λ σ)) := + MetricSpace.replaceTopology mtr htop.symm + let : CompactSpace ((cube H (Finset.univ : Finset ι) 0)⧸cubeLattice H (conjugateLattice Λ σ)) := + metric_compact cc (cubeLattice H (conjugateLattice Λ σ)) hΓ inferInstance rfl + let p : ℝ→ℕ→(Fin v→ℤ)→((cube H (Finset.univ : Finset ι) 0)⧸cubeLattice H (conjugateLattice Λ σ)) := + fun _ N z => QuotientGroup.mk (cubePolynomial c H S hH (a N) s + (fun i => ((r (e i)+(d₀:ℤ)*z (e i):ℤ):ℝ))) + apply FiniteHaarTests.two_scale_freezing μ (frozenTest H Λ σ F) + (frozenTest_continuous H Λ σ F) u₀ + (fun α N => integerBox v (lo α N) (hi α N)) p u _ hu + intro α hα ε hε + obtain ⟨c₀,C₀,hc₀,hC₀,hbox⟩ := hb α hα + have he := haar_limit_compact c H S hH (conjugateLattice Λ σ) h01 s hs e cc hsk q hqbound hq hΓ + rfl μ a hirr c₀ C₀ hc₀ hC₀ d₀ hd₀ r + {frozenTest H Λ σ F u₀} isCompact_singleton ε hε + filter_upwards [he,hbox] with N he hbox + exact he (lo α N) (hi α N) hbox.1 hbox.2 _ (Set.mem_singleton _) + +end CubeLocalHaar +end +end + + + +section + +noncomputable section +open scoped Topology BigOperators +open Filter +namespace CubeLocalHaar + + + +theorem smooth_local_freezing {G κ τ : Type*} [PseudoMetricSpace G] [Fintype τ] + (g : ℕ→ℝ→G) (h : ℝ→G) (β : ℝ) (hh : ContinuousAt h β) + (ρ : ℝ) (hρ : 0<ρ) + (hg : ∀ ε : ℝ,0<ε → ∀ᶠ N : ℕ in atTop, + ∀ t : ℝ,dist t β<ρ → dist (g N t) (h t)<ε) + (T : ℝ→ℕ→Finset κ) (t : ℝ→ℕ→κ→τ→ℝ) (C : ℝ) + (ht : ∀ α : ℝ,0<α → ∀ᶠ N : ℕ in atTop, + ∀ z∈T α N,∀ w,dist (t α N z w) β≤C*α) : + ∀ U∈𝓝 (fun _ : τ => h β),∀ᶠ α : ℝ in 𝓝[>] 0, + ∀ᶠ N : ℕ in atTop,∀ z∈T α N,(fun w => g N (t α N z w))∈U := by + intro U hU + obtain ⟨ε,hε,hball⟩ := Metric.mem_nhds_iff.mp hU + have hε2 : 0<ε/2 := by positivity + obtain ⟨δ,hδ,hcont⟩ := Metric.continuousAt_iff.mp hh (ε/2) hε2 + have hlim : Tendsto (fun α : ℝ => C*α) (𝓝[>] 0) (𝓝 0) := by + have hc : Continuous (fun α : ℝ => C*α) := continuous_const.mul continuous_id + simpa only [mul_zero] using (hc.tendsto 0).mono_left (nhdsWithin_le_nhds (s := Set.Ioi (0:ℝ))) + filter_upwards [hlim.eventually_lt_const (lt_min hδ hρ), + (self_mem_nhdsWithin : Set.Ioi (0:ℝ)∈𝓝[>] 0)] with α hα ha + filter_upwards [hg (ε/2) hε2,ht α ha] with N hgN htN + intro z hz + apply hball + rw [Metric.mem_ball,dist_pi_lt_iff hε] + intro w + have hd := (htN z hz w).trans_lt hα + have hg' := hgN (t α N z w) ((lt_min_iff.mp hd).2) + have hh' := hcont ((lt_min_iff.mp hd).1) + exact (dist_triangle _ _ _).trans_lt (by linarith only [hg',hh']) + + + +lemma normalized_vertex_close {ι : Type*} [Fintype ι] [DecidableEq ι] + (b : Option ι→ℝ) (β α : ℝ) (hα : 0≤α) + (hb : |b none-β|≤α) (hi : ∀ i,|b (some i)|≤α) (w : Finset ι) : + dist (b none+∑ i∈w,b (some i)) β≤(1+(Fintype.card ι:ℝ))*α := by + rw [Real.dist_eq] + calc + _ = |(b none-β)+∑ i∈w,b (some i)| := by congr 1; ring + _ ≤ |b none-β|+|∑ i∈w,b (some i)| := abs_add_le _ _ + _ ≤ α+∑ i∈w,|b (some i)| := add_le_add hb (Finset.abs_sum_le_sum_abs _ _) + _ ≤ α+∑ _i∈w,α := add_le_add le_rfl (Finset.sum_le_sum (fun i _ => hi i)) + _ = (1+(w.card:ℝ))*α := by simp; ring + _ ≤ (1+(Fintype.card ι:ℝ))*α := by + apply mul_le_mul_of_nonneg_right _ hα + exact add_le_add le_rfl (by exact_mod_cast Finset.card_le_univ w) + +end CubeLocalHaar +end +end + + + +section +noncomputable section +open scoped BigOperators Topology commutatorElement +namespace CubeLocalHaar +open CubeFaces LeibmanSquare CubeTaylorExpansion CubeHorizontalIrrationality +open RationalLattice MeasureTheory Filter ComparableBoxLeibman MalcevCharacters AbelianMalcevTorus +variable {G ι : Type} [Group G] [PseudoMetricSpace G] [IsTopologicalGroup G] +variable [Fintype ι] [DecidableEq ι] +variable {n t d v : ℕ} (c : RealCoordinates G n) (H : Filtration G) +variable (S : ℕ→Set (Fin n)) +variable (hH : ∀ k (g : G),g∈H.level k ↔ ∀ i∈S k,c.coord g i=0) +variable (Λ : Subgroup G) (σ : G) (h01 : H.level 0=H.level 1) +variable (s : ℕ) (hs : H.level (s+1)=⊥) (e : Option ι≃Fin v) +variable (cc : RealCoordinates (cube H (Finset.univ : Finset ι) 0) (t+d)) +variable (hsk : SecondKind cc) +variable (q : ℕ→ℕ) (hqbound : ∀ k,q k ≤ t+d) +variable (hq : ∀ k (g : cube H (Finset.univ : Finset ι) 0), + g∈(CubeMaxFiltration.filtration H Finset.univ).level k ↔ + ∀ i : Fin (t+d),i.val < q k → cc.coord g i=0) +variable (hΓ : ∀ g : cube H (Finset.univ : Finset ι) 0, + g∈cubeLattice H (conjugateLattice Λ σ) ↔ ∀ i,∃ z : ℤ,cc.coord g i=z) +variable [MeasurableSpace ((cube H (Finset.univ : Finset ι) 0)⧸cubeLattice H (conjugateLattice Λ σ))] +variable [hBorel : @BorelSpace ((cube H (Finset.univ : Finset ι) 0)⧸cubeLattice H (conjugateLattice Λ σ)) (QuotientGroup.instTopologicalSpace (cubeLattice H (conjugateLattice Λ σ))) inferInstance] +variable (mtr : MetricSpace ((cube H (Finset.univ : Finset ι) 0)⧸cubeLattice H (conjugateLattice Λ σ))) +variable (htop : mtr.toUniformSpace.toTopologicalSpace=QuotientGroup.instTopologicalSpace (cubeLattice H (conjugateLattice Λ σ))) + +include S hH h01 hs hsk hqbound hq hΓ htop in + + +theorem smooth_two_scale_cube_haar + (μ : Measure ((cube H (Finset.univ : Finset ι) 0)⧸cubeLattice H (conjugateLattice Λ σ))) + [IsProbabilityMeasure μ] + [SMulInvariantMeasure (cube H (Finset.univ : Finset ι) 0) _ μ] + (a : ℕ→∀ k : ℕ,H.level k) + (hirr : ∀ j : ℕ,0 < j → j ≤ s → ∀ ξ : H.level j→*Multiplicative ℝ, + ξ≠1 → Continuous ξ → RationalCharacter (conjugateLattice Λ σ) ξ → + (∀ x (hx : x∈H.level (j+1)),ξ ⟨x,H.antitone (Nat.le_succ _) hx⟩=1) → + (∀ i k : ℕ,0 < i → 0 < k → ∀ h : i+k=j, + ∀ x (hx : x∈H.level i) y (hy : y∈H.level k), + ξ ⟨⁅x,y⁆,by rw [←h]; exact H.commutator_le i k (Subgroup.commutator_mem_commutator hx hy)⟩=1) → + Tendsto (fun N : ℕ => ‖((ξ (a N j)).toAdd:UnitAddCircle)‖*(N:ℝ)^j) + atTop atTop) + + (d₀ : ℕ) (hd₀ : 0] 0,∀ᶠ N : ℕ in atTop, + ‖(𝔼 z∈integerBox v (lo α N) (hi α N), + F (fun w : Finset ι => QuotientGroup.mk + (g N (((r (e none)+(d₀:ℤ)*z (e none):ℤ):ℝ)/(N:ℝ)+ + ∑ i∈w,(((r (e (some i))+(d₀:ℤ)*z (e (some i)):ℤ):ℝ)/(N:ℝ))) * + taylorPolynomial c H (a N) s + (((r (e none)+(d₀:ℤ)*z (e none):ℤ):ℝ)+ + ∑ i∈w,((r (e (some i))+(d₀:ℤ)*z (e (some i)):ℤ):ℝ)) * σ)))- + (∫ x,frozenTest H Λ σ F (fun _ => h β) x ∂μ)‖<ε := by + let T : ℝ→ℕ→Finset (Fin v→ℤ) := fun α N => integerBox v (lo α N) (hi α N) + let b : (Fin v→ℤ)→Option ι→ℝ := fun z i => ((r (e i)+(d₀:ℤ)*z (e i):ℤ):ℝ) + let t : ℝ→ℕ→(Fin v→ℤ)→Finset ι→ℝ := + fun _ N z w => b z none/(N:ℝ)+∑ i∈w,b z (some i)/(N:ℝ) + have ht : ∀ α : ℝ,0<α → ∀ᶠ N : ℕ in atTop, + ∀ z∈T α N,∀ w,dist (t α N z w) β≤(1+(Fintype.card ι:ℝ))*α := by + intro α hα + filter_upwards [hgeo α hα] with N hN + intro z hz w + exact normalized_vertex_close (fun i => b z i/(N:ℝ)) β α hα.le + (hN z hz).1 (hN z hz).2 w + have hu := smooth_local_freezing g h β hh ρ hρ hg T t (1+(Fintype.card ι:ℝ)) ht + have hlimit := two_scale_cube_haar c H S hH Λ σ h01 s hs e cc hsk q hqbound hq hΓ mtr htop + μ a hirr d₀ hd₀ r lo hi hb (fun α N z w => g N (t α N z w)) (fun _ => h β) hu F + have himage (α : ℝ) (N : ℕ) (z : Fin v→ℤ) : + haarImage H Λ σ (fun w => g N (t α N z w)) + (QuotientGroup.mk (cubePolynomial c H S hH (a N) s (b z))) = + fun w : Finset ι => QuotientGroup.mk + (g N (t α N z w)*taylorPolynomial c H (a N) s + (b z none+∑ i∈w,b z (some i))*σ) := by + funext w + rw [haarImage_mk,cubePolynomial_vertex] + change ∀ ε : ℝ,0<ε → ∀ᶠ α : ℝ in 𝓝[>] 0,∀ᶠ N : ℕ in atTop, + ‖(𝔼 z∈integerBox v (lo α N) (hi α N), + F (haarImage H Λ σ (fun w => g N (t α N z w)) + (QuotientGroup.mk (cubePolynomial c H S hH (a N) s (b z)))))- + (∫ x,frozenTest H Λ σ F (fun _ => h β) x ∂μ)‖<ε at hlimit + simp_rw [himage] at hlimit + exact hlimit + +end CubeLocalHaar + +end +end +end +end +end + +end OAI diff --git a/lean/OAI/Combinatorics/SumProduct/Alignment/CubeLocal03.lean b/lean/OAI/Combinatorics/SumProduct/Alignment/CubeLocal03.lean new file mode 100644 index 0000000000000000000000000000000000000000..584122e644686628b8ef4146b75649c7c146b99d --- /dev/null +++ b/lean/OAI/Combinatorics/SumProduct/Alignment/CubeLocal03.lean @@ -0,0 +1,321 @@ +import Mathlib +import OAI.Combinatorics.SumProduct.Alignment.CubeLocal02 +import OAI.Geometry.NilpotentCharts.Main + +namespace OAI + +section +section +section +section +noncomputable section +open scoped BigOperators Topology commutatorElement +end +end + + + +section + +noncomputable section +open scoped Topology +open Filter +namespace ComparableBoxLeibman + + + +def halfOpenBox (v : ℕ) (lo hi : Fin v→ℝ) : Finset (Fin v→ℤ) := + integerBox v lo (fun i => (⌈hi i⌉:ℝ)-1) + +lemma mem_halfOpenBox {v : ℕ} (lo hi : Fin v→ℝ) (z : Fin v→ℤ) : + z∈halfOpenBox v lo hi ↔ ∀ i,lo i≤(z i:ℝ) ∧ (z i:ℝ) ‖((ξ (a N j)).toAdd:UnitAddCircle)‖*(N:ℝ)^j) + atTop atTop) + + (d₀ : ℕ) (hd₀ : 0] 0,∀ᶠ N : ℕ in atTop, + ‖(𝔼 z∈halfOpenBox v (lo α N) (hi α N), + F (fun w : Finset ι => QuotientGroup.mk + (g N (((r (e none)+(d₀:ℤ)*z (e none):ℤ):ℝ)/(N:ℝ)+ + ∑ i∈w,(((r (e (some i))+(d₀:ℤ)*z (e (some i)):ℤ):ℝ)/(N:ℝ))) * + taylorPolynomial c H (a N) s + (((r (e none)+(d₀:ℤ)*z (e none):ℤ):ℝ)+ + ∑ i∈w,((r (e (some i))+(d₀:ℤ)*z (e (some i)):ℤ):ℝ)) * σ)))- + (∫ x,frozenTest H Λ σ F (fun _ => h β) x ∂μ)‖<ε := by + have hb' : ∀ α : ℝ,0<α → ∃ c₀ C₀ : ℝ,0 (⌈hi α N i⌉:ℝ)-1) hb' + g h β hh ρ hρ hg hgeo F + +end CubeLocalHaar +end +end + + + +section + +noncomputable section +open scoped Topology +open Filter +namespace CubeLocalHaar +open ComparableBoxLeibman + + + +def progressionLo {v : ℕ} (a : Fin v→ℝ) (r : Fin v→ℤ) (d : ℕ) + (N : ℕ) (i : Fin v) : ℝ := (a i*(N:ℝ)-(r i:ℝ))/(d:ℝ) +def progressionHi {v : ℕ} (a : Fin v→ℝ) (r : Fin v→ℤ) (d : ℕ) + (α : ℝ) (N : ℕ) (i : Fin v) : ℝ := ((a i+α)*(N:ℝ)-(r i:ℝ))/(d:ℝ) + +lemma progression_box_bounds {v : ℕ} (a : Fin v→ℝ) (r : Fin v→ℤ) + (d : ℕ) (hd : 0 simp_all + · intro i + have hd' : (0:ℤ) simp_all + +omit [Fintype ι] [DecidableEq ι] in +lemma source_box_geometry (e : Option ι≃Fin v) (β : ℝ) + (d r : ℕ) (hd : 0 ‖((ξ (a N j)).toAdd:UnitAddCircle)‖*(N:ℝ)^j) + atTop atTop) + + (d₀ r₀ : ℕ) (hd₀ : 0] 0,∀ᶠ N : ℕ in atTop, + ‖(𝔼 z∈halfOpenBox v + (progressionLo (sourceCenter e β) (sourceResidue e r₀) d₀ N) + (progressionHi (sourceCenter e β) (sourceResidue e r₀) d₀ α N), + F (fun w : Finset ι => QuotientGroup.mk + (g N ((sourceVertex e d₀ r₀ z w:ℝ)/(N:ℝ)) * + taylorPolynomial c H (a N) s (sourceVertex e d₀ r₀ z w:ℝ) * σ)))- + (∫ x,frozenTest H Λ σ F (fun _ => h β) x ∂μ)‖<ε := by + have he := smooth_halfOpen_cube_haar c H S hH Λ σ h01 s hs e cc hsk q hqbound hq hΓ mtr htop + μ a hirr d₀ hd₀ (sourceResidue e r₀) + (fun _ N => progressionLo (sourceCenter e β) (sourceResidue e r₀) d₀ N) + (fun α N => progressionHi (sourceCenter e β) (sourceResidue e r₀) d₀ α N) + (fun α hα => source_box_bounds e β hβ d₀ r₀ hd₀ hr₀ α hα) + g h β hh ρ hρ hg (fun α _ => source_box_geometry e β d₀ r₀ hd₀ α) F + simpa only [sourceVertex_real,sourceVertex_normalized] using he + +end CubeLocalHaar +end +end + + + +section +noncomputable section +open scoped BigOperators Topology commutatorElement +namespace CubeLocalHaar +open CubeFaces LeibmanSquare CubeTaylorExpansion CubeHorizontalIrrationality +open RationalLattice MeasureTheory Filter ComparableBoxLeibman MalcevCharacters AbelianMalcevTorus +variable {G ι : Type} [Group G] [PseudoMetricSpace G] [IsTopologicalGroup G] +variable [Fintype ι] [DecidableEq ι] +variable {n t d v : ℕ} (c : RealCoordinates G n) (H : Filtration G) +variable (S : ℕ→Set (Fin n)) +variable (hH : ∀ k (g : G),g∈H.level k ↔ ∀ i∈S k,c.coord g i=0) +variable (Λ : Subgroup G) (σ : G) (h01 : H.level 0=H.level 1) +variable (s : ℕ) (hs : H.level (s+1)=⊥) (e : Option ι≃Fin v) +variable (cc : RealCoordinates (cube H (Finset.univ : Finset ι) 0) (t+d)) +variable (hsk : SecondKind cc) +variable (q : ℕ→ℕ) (hqbound : ∀ k,q k ≤ t+d) +variable (hq : ∀ k (g : cube H (Finset.univ : Finset ι) 0), + g∈(CubeMaxFiltration.filtration H Finset.univ).level k ↔ + ∀ i : Fin (t+d),i.val < q k → cc.coord g i=0) +variable (hΓ : ∀ g : cube H (Finset.univ : Finset ι) 0, + g∈cubeLattice H (conjugateLattice Λ σ) ↔ ∀ i,∃ z : ℤ,cc.coord g i=z) +variable [MeasurableSpace ((cube H (Finset.univ : Finset ι) 0)⧸cubeLattice H (conjugateLattice Λ σ))] +variable [hBorel : @BorelSpace ((cube H (Finset.univ : Finset ι) 0)⧸cubeLattice H (conjugateLattice Λ σ)) (QuotientGroup.instTopologicalSpace (cubeLattice H (conjugateLattice Λ σ))) inferInstance] +variable (mtr : MetricSpace ((cube H (Finset.univ : Finset ι) 0)⧸cubeLattice H (conjugateLattice Λ σ))) +variable (htop : mtr.toUniformSpace.toTopologicalSpace=QuotientGroup.instTopologicalSpace (cubeLattice H (conjugateLattice Λ σ))) + +variable [MeasurableSpace (G⧸Λ)] [BorelSpace (G⧸Λ)] +variable [SecondCountableTopology (G⧸Λ)] + +include S hH h01 hs hsk hqbound hq hΓ htop in + + +theorem source_factored_cube_haar + (μ : Measure ((cube H (Finset.univ : Finset ι) 0)⧸cubeLattice H (conjugateLattice Λ σ))) + [IsProbabilityMeasure μ] + [SMulInvariantMeasure (cube H (Finset.univ : Finset ι) 0) _ μ] + (a : ℕ→∀ k : ℕ,H.level k) + (hirr : ∀ j : ℕ,0 < j → j ≤ s → ∀ ξ : H.level j→*Multiplicative ℝ, + ξ≠1 → Continuous ξ → RationalCharacter (conjugateLattice Λ σ) ξ → + (∀ x (hx : x∈H.level (j+1)),ξ ⟨x,H.antitone (Nat.le_succ _) hx⟩=1) → + (∀ i k : ℕ,0 < i → 0 < k → ∀ h : i+k=j, + ∀ x (hx : x∈H.level i) y (hy : y∈H.level k), + ξ ⟨⁅x,y⁆,by rw [←h]; exact H.commutator_le i k (Subgroup.commutator_mem_commutator hx hy)⟩=1) → + Tendsto (fun N : ℕ => ‖((ξ (a N j)).toAdd:UnitAddCircle)‖*(N:ℝ)^j) + atTop atTop) + + (d₀ r₀ : ℕ) (hd₀ : 0 h β) + ∀ ε : ℝ,0<ε → ∀ᶠ α : ℝ in 𝓝[>] 0,∀ᶠ N : ℕ in atTop, + ‖(𝔼 z∈halfOpenBox v + (progressionLo (sourceCenter e β) (sourceResidue e r₀) d₀ N) + (progressionHi (sourceCenter e β) (sourceResidue e r₀) d₀ α N), + F (fun w : Finset ι => QuotientGroup.mk (P N (sourceVertex e d₀ r₀ z w))))- + (∫ y,F y ∂(m:Measure (Finset ι→G⧸Λ)))‖<ε := by + let : CompactSpace ((cube H (Finset.univ : Finset ι) 0)⧸cubeLattice H (conjugateLattice Λ σ)) := by + let := MetricSpace.replaceTopology mtr htop.symm + exact metric_compact cc (cubeLattice H (conjugateLattice Λ σ)) hΓ inferInstance rfl + intro m + have hm : (∫ y,F y ∂(m:Measure (Finset ι→G⧸Λ))) = + ∫ x,frozenTest H Λ σ F (fun _ => h β) x ∂μ := + integral_imageProbability H Λ σ ⟨μ,inferInstance⟩ (fun _ => h β) F + rw [hm] + have hv (N : ℕ) (z : Fin v→ℤ) (w : Finset ι) : + QuotientGroup.mk (P N (sourceVertex e d₀ r₀ z w)) = + (QuotientGroup.mk (g N ((sourceVertex e d₀ r₀ z w:ℝ)/(N:ℝ))* + taylorPolynomial c H (a N) s (sourceVertex e d₀ r₀ z w:ℝ)*σ):G⧸Λ) := by + rw [hfactor] + exact congrArg (fun x : G⧸Λ => + (g N ((sourceVertex e d₀ r₀ z w:ℝ)/(N:ℝ))* + taylorPolynomial c H (a N) s (sourceVertex e d₀ r₀ z w:ℝ)) • x) + (hperiod N _ (sourceVertex_emod e d₀ r₀ hr₀ z w)) + simp_rw [hv] + exact source_local_cube_haar c H S hH Λ σ h01 s hs e cc hsk q hqbound hq hΓ mtr htop + μ a hirr d₀ r₀ hd₀ hr₀ β hβ g h hh ρ hρ hg F + +end CubeLocalHaar +end +end + + + +section + +noncomputable section +open scoped Topology BigOperators +namespace FiniteHaarTests +open Filter MeasureTheory +variable {X κ : Type*} [MetricSpace X] [CompactSpace X] +variable [MeasurableSpace X] [BorelSpace X] +variable (μ : Measure X) [IsProbabilityMeasure μ] + + + +theorem compact_two_scale + (T : ℝ→ℕ→Finset κ) (p : ℝ→ℕ→κ→X) + (hl : ∀ F : C(X,ℂ),∀ ε : ℝ,0<ε → + ∀ᶠ α : ℝ in 𝓝[>] 0,∀ᶠ N : ℕ in atTop, + ‖discrepancy μ (T α N) (p α N) F‖<ε) + (K : Set C(X,ℂ)) (hK : IsCompact K) : + ∀ ε : ℝ,0<ε → ∀ᶠ α : ℝ in 𝓝[>] 0,∀ᶠ N : ℕ in atTop, + ∀ F∈K,‖discrepancy μ (T α N) (p α N) F‖<ε := by + intro ε hε + obtain ⟨S,hS,η,hη,htest⟩ := CompactFamilyDescent.finite_unit_lipschitz_obstruction + K hK ε 2 hε (by norm_num) + have hα : ∀ᶠ α : ℝ in 𝓝[>] 0,∀ F∈S,∀ᶠ N : ℕ in atTop, + ‖discrepancy μ (T α N) (p α N) F‖<η := + (Filter.eventually_all_finset S).mpr (fun F _ => hl F η hη) + filter_upwards [hα] with α hα + have hN : ∀ᶠ N : ℕ in atTop,∀ F∈S, + ‖discrepancy μ (T α N) (p α N) F‖<η := + (Filter.eventually_all_finset S).mpr hα + filter_upwards [hN] with N hN + intro F hF + by_contra he + obtain ⟨φ,hφ,hdisc⟩ := htest (discrepancy μ (T α N) (p α N)) + (discrepancy_bound μ (T α N) (p α N)) ⟨F,hF,le_of_not_gt he⟩ + exact (not_le_of_gt (hN φ hφ)) hdisc + +end FiniteHaarTests +end +end + + + +section +noncomputable section +open scoped BigOperators Topology commutatorElement +namespace CubeLocalHaar +open CubeFaces LeibmanSquare CubeTaylorExpansion CubeHorizontalIrrationality +open RationalLattice MeasureTheory Filter ComparableBoxLeibman MalcevCharacters AbelianMalcevTorus +variable {G ι : Type} [Group G] [PseudoMetricSpace G] [IsTopologicalGroup G] +variable [Fintype ι] [DecidableEq ι] +variable {n t d v : ℕ} (c : RealCoordinates G n) (H : Filtration G) +variable (S : ℕ→Set (Fin n)) +variable (hH : ∀ k (g : G),g∈H.level k ↔ ∀ i∈S k,c.coord g i=0) +variable (Λ : Subgroup G) (σ : G) (h01 : H.level 0=H.level 1) +variable (s : ℕ) (hs : H.level (s+1)=⊥) (e : Option ι≃Fin v) +variable (cc : RealCoordinates (cube H (Finset.univ : Finset ι) 0) (t+d)) +variable (hsk : SecondKind cc) +variable (q : ℕ→ℕ) (hqbound : ∀ k,q k ≤ t+d) +variable (hq : ∀ k (g : cube H (Finset.univ : Finset ι) 0), + g∈(CubeMaxFiltration.filtration H Finset.univ).level k ↔ + ∀ i : Fin (t+d),i.val < q k → cc.coord g i=0) +variable (hΓ : ∀ g : cube H (Finset.univ : Finset ι) 0, + g∈cubeLattice H (conjugateLattice Λ σ) ↔ ∀ i,∃ z : ℤ,cc.coord g i=z) +variable [MeasurableSpace ((cube H (Finset.univ : Finset ι) 0)⧸cubeLattice H (conjugateLattice Λ σ))] +variable [hBorel : @BorelSpace ((cube H (Finset.univ : Finset ι) 0)⧸cubeLattice H (conjugateLattice Λ σ)) (QuotientGroup.instTopologicalSpace (cubeLattice H (conjugateLattice Λ σ))) inferInstance] +variable (mtr : MetricSpace ((cube H (Finset.univ : Finset ι) 0)⧸cubeLattice H (conjugateLattice Λ σ))) +variable (htop : mtr.toUniformSpace.toTopologicalSpace=QuotientGroup.instTopologicalSpace (cubeLattice H (conjugateLattice Λ σ))) + +variable [MeasurableSpace (G⧸Λ)] [BorelSpace (G⧸Λ)] +variable [SecondCountableTopology (G⧸Λ)] + +variable [CompactSpace (G⧸Λ)] +variable (qmtr : MetricSpace (G⧸Λ)) +variable (hqtop : qmtr.toUniformSpace.toTopologicalSpace=QuotientGroup.instTopologicalSpace Λ) + +include S hH h01 hs hsk hqbound hq hΓ htop hqtop in + + +theorem source_compact_cube_haar + (μ : Measure ((cube H (Finset.univ : Finset ι) 0)⧸cubeLattice H (conjugateLattice Λ σ))) + [IsProbabilityMeasure μ] + [SMulInvariantMeasure (cube H (Finset.univ : Finset ι) 0) _ μ] + (a : ℕ→∀ k : ℕ,H.level k) + (hirr : ∀ j : ℕ,0 < j → j ≤ s → ∀ ξ : H.level j→*Multiplicative ℝ, + ξ≠1 → Continuous ξ → RationalCharacter (conjugateLattice Λ σ) ξ → + (∀ x (hx : x∈H.level (j+1)),ξ ⟨x,H.antitone (Nat.le_succ _) hx⟩=1) → + (∀ i k : ℕ,0 < i → 0 < k → ∀ h : i+k=j, + ∀ x (hx : x∈H.level i) y (hy : y∈H.level k), + ξ ⟨⁅x,y⁆,by rw [←h]; exact H.commutator_le i k (Subgroup.commutator_mem_commutator hx hy)⟩=1) → + Tendsto (fun N : ℕ => ‖((ξ (a N j)).toAdd:UnitAddCircle)‖*(N:ℝ)^j) + atTop atTop) + + (d₀ r₀ : ℕ) (hd₀ : 0 h β) + ∀ ε : ℝ,0<ε → ∀ᶠ α : ℝ in 𝓝[>] 0,∀ᶠ N : ℕ in atTop,∀ F∈K, + ‖(𝔼 z∈halfOpenBox v + (progressionLo (sourceCenter e β) (sourceResidue e r₀) d₀ N) + (progressionHi (sourceCenter e β) (sourceResidue e r₀) d₀ α N), + F (fun w : Finset ι => QuotientGroup.mk (P N (sourceVertex e d₀ r₀ z w))))- + (∫ y,F y ∂(m:Measure (Finset ι→G⧸Λ)))‖<ε := by + let : MetricSpace (G⧸Λ) := MetricSpace.replaceTopology qmtr hqtop.symm + intro m + apply FiniteHaarTests.compact_two_scale (m:Measure (Finset ι→G⧸Λ)) + (fun α N => halfOpenBox v + (progressionLo (sourceCenter e β) (sourceResidue e r₀) d₀ N) + (progressionHi (sourceCenter e β) (sourceResidue e r₀) d₀ α N)) + (fun _ N z w => QuotientGroup.mk (P N (sourceVertex e d₀ r₀ z w))) _ K hK + intro F + exact source_factored_cube_haar c H S hH Λ σ h01 s hs e cc hsk q hqbound hq hΓ mtr htop + μ a hirr d₀ r₀ hd₀ hr₀ β hβ g h hh ρ hρ hg P γ hfactor hperiod F + +end CubeLocalHaar + +end +end +end +end +end + +end OAI diff --git a/lean/OAI/Combinatorics/SumProduct/Alignment/CubeLocal05.lean b/lean/OAI/Combinatorics/SumProduct/Alignment/CubeLocal05.lean new file mode 100644 index 0000000000000000000000000000000000000000..c5b8f30a3a31437876da7dbc4c1648f517f268e7 --- /dev/null +++ b/lean/OAI/Combinatorics/SumProduct/Alignment/CubeLocal05.lean @@ -0,0 +1,331 @@ +import Mathlib +import OAI.Combinatorics.SumProduct.Alignment.CubeLocal04 +import OAI.Geometry.NilpotentCharts.Main + +namespace OAI + +section +section +section +section +noncomputable section +open scoped BigOperators Topology commutatorElement +end +end + + + +section + +noncomputable section +open scoped Topology NNReal BoundedContinuousFunction +namespace BoundedLipschitzCompact +variable {X : Type*} [MetricSpace X] [CompactSpace X] + + + +theorem compact_envelope (L : ℝ≥0) (B : ℝ) : + ∃ K : Set C(X,ℂ), IsCompact K ∧ + ∀ F : C(X,ℂ), LipschitzWith L F → ‖F‖ ≤ B → F ∈ K := by + let E := ContinuousMap.isometryEquivBoundedOfCompact X ℂ + let A : Set (X →ᵇ ℂ) := {F | LipschitzWith L F ∧ ‖F‖ ≤ B} + have hA : IsCompact (closure A) := by + apply BoundedContinuousFunction.arzela_ascoli (Metric.closedBall 0 B) + (isCompact_closedBall _ _) A + · intro F x hF + simpa only [Metric.mem_closedBall, dist_zero_right] using + (BoundedContinuousFunction.norm_coe_le_norm F x).trans hF.2 + · exact (LipschitzWith.uniformEquicontinuous + (fun F : A => (F.val : X → ℂ)) L (fun F => F.property.1)).equicontinuous + refine ⟨E.symm '' closure A, hA.image E.symm.continuous, ?_⟩ + intro F hL hB + refine ⟨E F, subset_closure ?_, E.symm_apply_apply F⟩ + change LipschitzWith L (E F) ∧ ‖E F‖ ≤ B + constructor + · exact hL + · change ‖BoundedContinuousFunction.mkOfCompact F‖ ≤ B + simpa only [BoundedContinuousFunction.norm_mkOfCompact] using hB + +end BoundedLipschitzCompact +end +end + + + +section +noncomputable section +open scoped BigOperators Topology commutatorElement NNReal +namespace CubeLocalHaar +open CubeFaces LeibmanSquare CubeTaylorExpansion CubeHorizontalIrrationality +open RationalLattice MeasureTheory Filter ComparableBoxLeibman MalcevCharacters AbelianMalcevTorus +variable {G ι : Type} [Group G] [PseudoMetricSpace G] [IsTopologicalGroup G] +variable [Fintype ι] [DecidableEq ι] +variable {n t d v : ℕ} (c : RealCoordinates G n) (H : Filtration G) +variable (S : ℕ→Set (Fin n)) +variable (hH : ∀ k (g : G),g∈H.level k ↔ ∀ i∈S k,c.coord g i=0) +variable (Λ : Subgroup G) (σ : G) (h01 : H.level 0=H.level 1) +variable (s : ℕ) (hs : H.level (s+1)=⊥) (e : Option ι≃Fin v) +variable (cc : RealCoordinates (cube H (Finset.univ : Finset ι) 0) (t+d)) +variable (hsk : SecondKind cc) +variable (q : ℕ→ℕ) (hqbound : ∀ k,q k ≤ t+d) +variable (hq : ∀ k (g : cube H (Finset.univ : Finset ι) 0), + g∈(CubeMaxFiltration.filtration H Finset.univ).level k ↔ + ∀ i : Fin (t+d),i.val < q k → cc.coord g i=0) +variable (hΓ : ∀ g : cube H (Finset.univ : Finset ι) 0, + g∈cubeLattice H (conjugateLattice Λ σ) ↔ ∀ i,∃ z : ℤ,cc.coord g i=z) +variable [MeasurableSpace ((cube H (Finset.univ : Finset ι) 0)⧸cubeLattice H (conjugateLattice Λ σ))] +variable [hBorel : @BorelSpace ((cube H (Finset.univ : Finset ι) 0)⧸cubeLattice H (conjugateLattice Λ σ)) (QuotientGroup.instTopologicalSpace (cubeLattice H (conjugateLattice Λ σ))) inferInstance] +variable (mtr : MetricSpace ((cube H (Finset.univ : Finset ι) 0)⧸cubeLattice H (conjugateLattice Λ σ))) +variable (htop : mtr.toUniformSpace.toTopologicalSpace=QuotientGroup.instTopologicalSpace (cubeLattice H (conjugateLattice Λ σ))) + +variable [MeasurableSpace (G⧸Λ)] [BorelSpace (G⧸Λ)] +variable [SecondCountableTopology (G⧸Λ)] + +variable [CompactSpace (G⧸Λ)] +variable (qmtr : MetricSpace (G⧸Λ)) +variable (hqtop : qmtr.toUniformSpace.toTopologicalSpace=QuotientGroup.instTopologicalSpace Λ) + +include S hH h01 hs hsk hqbound hq hΓ htop hqtop in + + +theorem source_bounded_lipschitz_cube_haar + (μ : Measure ((cube H (Finset.univ : Finset ι) 0)⧸cubeLattice H (conjugateLattice Λ σ))) + [IsProbabilityMeasure μ] + [SMulInvariantMeasure (cube H (Finset.univ : Finset ι) 0) _ μ] + (a : ℕ→∀ k : ℕ,H.level k) + (hirr : ∀ j : ℕ,0 < j → j ≤ s → ∀ ξ : H.level j→*Multiplicative ℝ, + ξ≠1 → Continuous ξ → RationalCharacter (conjugateLattice Λ σ) ξ → + (∀ x (hx : x∈H.level (j+1)),ξ ⟨x,H.antitone (Nat.le_succ _) hx⟩=1) → + (∀ i k : ℕ,0 < i → 0 < k → ∀ h : i+k=j, + ∀ x (hx : x∈H.level i) y (hy : y∈H.level k), + ξ ⟨⁅x,y⁆,by rw [←h]; exact H.commutator_le i k (Subgroup.commutator_mem_commutator hx hy)⟩=1) → + Tendsto (fun N : ℕ => ‖((ξ (a N j)).toAdd:UnitAddCircle)‖*(N:ℝ)^j) + atTop atTop) + + (d₀ r₀ : ℕ) (hd₀ : 0 h β) + ∀ ε : ℝ,0<ε → ∀ᶠ α : ℝ in 𝓝[>] 0,∀ᶠ N : ℕ in atTop,∀ F : C((Finset ι→G⧸Λ),ℂ), + LipschitzWith L F → ‖F‖≤B → + ‖(𝔼 z∈halfOpenBox v + (progressionLo (sourceCenter e β) (sourceResidue e r₀) d₀ N) + (progressionHi (sourceCenter e β) (sourceResidue e r₀) d₀ α N), + F (fun w : Finset ι => QuotientGroup.mk (P N (sourceVertex e d₀ r₀ z w))))- + (∫ y,F y ∂(m:Measure (Finset ι→G⧸Λ)))‖<ε := by + let : MetricSpace (G⧸Λ) := MetricSpace.replaceTopology qmtr hqtop.symm + intro m + obtain ⟨K,hK,hcover⟩ := BoundedLipschitzCompact.compact_envelope + (X := Finset ι→G⧸Λ) L B + have hhK := source_compact_cube_haar c H S hH Λ σ h01 s hs e cc hsk q hqbound hq hΓ + mtr htop qmtr hqtop μ a hirr d₀ r₀ hd₀ hr₀ β hβ g h hh ρ hρ hg P γ hfactor hperiod K hK + intro ε hε + filter_upwards [hhK ε hε] with α hα + filter_upwards [hα] with N hN + intro F hL hB + exact hN F (hcover F hL hB) + +end CubeLocalHaar +end +end + + + +section + +noncomputable section +open scoped BigOperators +namespace CubeLocalHaar +open ComparableBoxLeibman + + + +def physicalProgressionBox {v : ℕ} (a : Fin v→ℝ) (r : Fin v→ℤ) (d : ℕ) + (α : ℝ) (N : ℕ) : Finset (Fin v→ℤ) := + (halfOpenBox v (fun i => a i*(N:ℝ)) (fun i => (a i+α)*(N:ℝ))).filter + (fun b => ∀ i,b i%(d:ℤ)=r i) + +lemma physicalProgressionBox_mem {v : ℕ} (a : Fin v→ℝ) (r : Fin v→ℤ) + (d : ℕ) (α : ℝ) (N : ℕ) (b : Fin v→ℤ) : + b∈physicalProgressionBox a r d α N ↔ + (∀ i,a i*(N:ℝ)≤(b i:ℝ) ∧ (b i:ℝ)<(a i+α)*(N:ℝ)) ∧ + ∀ i,b i%(d:ℤ)=r i := by + simp only [physicalProgressionBox,Finset.mem_filter,mem_halfOpenBox] + +lemma physicalProgressionBox_affine {v : ℕ} (a : Fin v→ℝ) (r : Fin v→ℤ) + (d : ℕ) (hd : 0 r i+(d:ℤ)*z i)∈physicalProgressionBox a r d α N ↔ + z∈halfOpenBox v (progressionLo a r d N) (progressionHi a r d α N) := by + have hd' : 0<(d:ℝ) := by exact_mod_cast hd + rw [physicalProgressionBox_mem,mem_halfOpenBox] + have hmod : ∀ i,(r i+(d:ℤ)*z i)%(d:ℤ)=r i := by + intro i + simp only [Int.add_mul_emod_self_left] + exact Int.emod_eq_of_lt (hr i).1 (hr i).2 + simp only [hmod,implies_true,and_true,Int.cast_add,Int.cast_mul,Int.cast_natCast] + apply forall_congr' + intro i + dsimp only [progressionLo,progressionHi] + rw [div_le_iff₀ hd',lt_div_iff₀ hd'] + constructor <;> intro h <;> constructor <;> linarith [h.1,h.2] + + + +theorem physicalProgressionBox_expect {v : ℕ} (a : Fin v→ℝ) (r : Fin v→ℤ) + (d : ℕ) (hd : 0 r i+(d:ℤ)*z i)) := by + classical + symm + apply Finset.expect_bij (fun z _ i => r i+(d:ℤ)*z i) + · intro z hz + exact (physicalProgressionBox_affine a r d hd hr α N z).mpr hz + · intro z hz + rfl + · intro z₁ hz₁ z₂ hz₂ he + funext i + have hi := congrFun he i + have hdne : (d:ℤ)≠0 := by exact_mod_cast (ne_of_gt hd) + exact mul_left_cancel₀ hdne (add_left_cancel hi) + · intro b hb + let z : Fin v→ℤ := fun i => b i/(d:ℤ) + have he : (fun i => r i+(d:ℤ)*z i)=b := by + funext i + have hh := Int.emod_add_ediv_mul (b i) (d:ℤ) + rw [(physicalProgressionBox_mem a r d α N b).mp hb |>.2 i] at hh + simpa only [z,mul_comm] using hh + refine ⟨z,(physicalProgressionBox_affine a r d hd hr α N z).mp ?_,he⟩ + rw [he] + exact hb + +end CubeLocalHaar +end +end + + + +section +noncomputable section +open scoped BigOperators Topology commutatorElement NNReal +namespace CubeLocalHaar +open CubeFaces LeibmanSquare CubeTaylorExpansion CubeHorizontalIrrationality +open RationalLattice MeasureTheory Filter ComparableBoxLeibman MalcevCharacters AbelianMalcevTorus +variable {G ι : Type} [Group G] [PseudoMetricSpace G] [IsTopologicalGroup G] +variable [Fintype ι] [DecidableEq ι] +variable {n t d v : ℕ} (c : RealCoordinates G n) (H : Filtration G) +variable (S : ℕ→Set (Fin n)) +variable (hH : ∀ k (g : G),g∈H.level k ↔ ∀ i∈S k,c.coord g i=0) +variable (Λ : Subgroup G) (σ : G) (h01 : H.level 0=H.level 1) +variable (s : ℕ) (hs : H.level (s+1)=⊥) (e : Option ι≃Fin v) +variable (cc : RealCoordinates (cube H (Finset.univ : Finset ι) 0) (t+d)) +variable (hsk : SecondKind cc) +variable (q : ℕ→ℕ) (hqbound : ∀ k,q k ≤ t+d) +variable (hq : ∀ k (g : cube H (Finset.univ : Finset ι) 0), + g∈(CubeMaxFiltration.filtration H Finset.univ).level k ↔ + ∀ i : Fin (t+d),i.val < q k → cc.coord g i=0) +variable (hΓ : ∀ g : cube H (Finset.univ : Finset ι) 0, + g∈cubeLattice H (conjugateLattice Λ σ) ↔ ∀ i,∃ z : ℤ,cc.coord g i=z) +variable [MeasurableSpace ((cube H (Finset.univ : Finset ι) 0)⧸cubeLattice H (conjugateLattice Λ σ))] +variable [hBorel : @BorelSpace ((cube H (Finset.univ : Finset ι) 0)⧸cubeLattice H (conjugateLattice Λ σ)) (QuotientGroup.instTopologicalSpace (cubeLattice H (conjugateLattice Λ σ))) inferInstance] +variable (mtr : MetricSpace ((cube H (Finset.univ : Finset ι) 0)⧸cubeLattice H (conjugateLattice Λ σ))) +variable (htop : mtr.toUniformSpace.toTopologicalSpace=QuotientGroup.instTopologicalSpace (cubeLattice H (conjugateLattice Λ σ))) + +variable [MeasurableSpace (G⧸Λ)] [BorelSpace (G⧸Λ)] +variable [SecondCountableTopology (G⧸Λ)] + +variable [CompactSpace (G⧸Λ)] +variable (qmtr : MetricSpace (G⧸Λ)) +variable (hqtop : qmtr.toUniformSpace.toTopologicalSpace=QuotientGroup.instTopologicalSpace Λ) + +include S hH h01 hs hsk hqbound hq hΓ htop hqtop in + + +theorem source_physical_cube_haar + (μ : Measure ((cube H (Finset.univ : Finset ι) 0)⧸cubeLattice H (conjugateLattice Λ σ))) + [IsProbabilityMeasure μ] + [SMulInvariantMeasure (cube H (Finset.univ : Finset ι) 0) _ μ] + (a : ℕ→∀ k : ℕ,H.level k) + (hirr : ∀ j : ℕ,0 < j → j ≤ s → ∀ ξ : H.level j→*Multiplicative ℝ, + ξ≠1 → Continuous ξ → RationalCharacter (conjugateLattice Λ σ) ξ → + (∀ x (hx : x∈H.level (j+1)),ξ ⟨x,H.antitone (Nat.le_succ _) hx⟩=1) → + (∀ i k : ℕ,0 < i → 0 < k → ∀ h : i+k=j, + ∀ x (hx : x∈H.level i) y (hy : y∈H.level k), + ξ ⟨⁅x,y⁆,by rw [←h]; exact H.commutator_le i k (Subgroup.commutator_mem_commutator hx hy)⟩=1) → + Tendsto (fun N : ℕ => ‖((ξ (a N j)).toAdd:UnitAddCircle)‖*(N:ℝ)^j) + atTop atTop) + + (d₀ r₀ : ℕ) (hd₀ : 0 h β) + ∀ ε : ℝ,0<ε → ∀ᶠ α : ℝ in 𝓝[>] 0,∀ᶠ N : ℕ in atTop,∀ F : C((Finset ι→G⧸Λ),ℂ), + LipschitzWith L F → ‖F‖≤B → + ‖(𝔼 b∈physicalProgressionBox (sourceCenter e β) (sourceResidue e r₀) d₀ α N, + F (fun w : Finset ι => QuotientGroup.mk + (P N (b (e none)+∑ i∈w,b (e (some i))))))- + (∫ y,F y ∂(m:Measure (Finset ι→G⧸Λ)))‖<ε := by + let : MetricSpace (G⧸Λ) := MetricSpace.replaceTopology qmtr hqtop.symm + intro m + have he := source_bounded_lipschitz_cube_haar c H S hH Λ σ h01 s hs e cc hsk q hqbound hq hΓ + mtr htop qmtr hqtop μ a hirr d₀ r₀ hd₀ hr₀ β hβ g h hh ρ hρ hg P γ hfactor hperiod L B + have hr : ∀ i : Fin v,0 ≤ sourceResidue e r₀ i ∧ sourceResidue e r₀ i<(d₀:ℤ) := by + intro i + have hd' : (0:ℤ)] 0,∀ᶠ N : ℕ in atTop, + ∀ j : J α N,∀ z∈T α N j,a α N j z∈U) : + ∀ ε : ℝ,0<ε → ∀ᶠ α : ℝ in 𝓝[>] 0,∀ᶠ N : ℕ in atTop,∀ j : J α N, + ‖(𝔼 z∈T α N j,F (a α N j z) (p α N j z))-(∫ x,F a₀ x ∂μ)‖<ε := by + intro ε hε + have hε3 : 0<ε/3 := by positivity + let U : Set P := F ⁻¹' Metric.ball (F a₀) (ε/3) + have hU : U∈𝓝 a₀ := hF.continuousAt.preimage_mem_nhds + (Metric.ball_mem_nhds _ hε3) + filter_upwards [hsm U hU,(self_mem_nhdsWithin : Set.Ioi (0:ℝ)∈𝓝[>] 0)] with α hα ha + filter_upwards [hα,hbase α ha (ε/3) hε3] with N hN hb + intro j + have hb := hb j + have hp (z : κ) (hz : z∈T α N j) : + ‖F (a α N j z) (p α N j z)-F a₀ (p α N j z)‖≤ε/3 := by + apply (ContinuousMap.norm_coe_le_norm (F (a α N j z)-F a₀) (p α N j z)).trans + exact le_of_lt (by simpa only [U,Set.mem_preimage,Metric.mem_ball,dist_eq_norm] using hN j z hz) + have hm : ‖𝔼 z∈T α N j,(F (a α N j z) (p α N j z)-F a₀ (p α N j z))‖≤ε/3 := by + by_cases hn : (T α N j).Nonempty + · exact (RCLike.norm_expect_le (K := ℂ)).trans (Finset.expect_le hn hp) + · simp only [Finset.not_nonempty_iff_eq_empty.mp hn,Finset.expect_empty,norm_zero] + positivity + rw [Finset.expect_sub_distrib] at hm + change ‖(𝔼 z∈T α N j,F a₀ (p α N j z))-(∫ x,F a₀ x ∂μ)‖<ε/3 at hb + calc + _ = ‖((𝔼 z∈T α N j,F (a α N j z) (p α N j z))-(𝔼 z∈T α N j,F a₀ (p α N j z)))+ + ((𝔼 z∈T α N j,F a₀ (p α N j z))-(∫ x,F a₀ x ∂μ))‖ := by congr 1; ring + _ ≤ _ := norm_add_le _ _ + _ < ε := by linarith only [hm,hb,hε] + +end FiniteHaarTests +end +end + + + +section +noncomputable section +open scoped BigOperators Topology commutatorElement +namespace CubeLocalHaar +open CubeFaces LeibmanSquare CubeTaylorExpansion CubeHorizontalIrrationality +open RationalLattice MeasureTheory Filter ComparableBoxLeibman MalcevCharacters AbelianMalcevTorus +variable {G ι : Type} [Group G] [TopologicalSpace G] [IsTopologicalGroup G] +variable [Fintype ι] [DecidableEq ι] +variable {n t d v : ℕ} (c : RealCoordinates G n) (H : Filtration G) +variable (S : ℕ→Set (Fin n)) +variable (hH : ∀ k (g : G),g∈H.level k ↔ ∀ i∈S k,c.coord g i=0) +variable (Λ : Subgroup G) (σ : G) (h01 : H.level 0=H.level 1) +variable (s : ℕ) (hs : H.level (s+1)=⊥) (e : Option ι≃Fin v) +variable (cc : RealCoordinates (cube H (Finset.univ : Finset ι) 0) (t+d)) +variable (hsk : SecondKind cc) +variable (q : ℕ→ℕ) (hqbound : ∀ k,q k ≤ t+d) +variable (hq : ∀ k (g : cube H (Finset.univ : Finset ι) 0), + g∈(CubeMaxFiltration.filtration H Finset.univ).level k ↔ + ∀ i : Fin (t+d),i.val < q k → cc.coord g i=0) +variable (hΓ : ∀ g : cube H (Finset.univ : Finset ι) 0, + g∈cubeLattice H (conjugateLattice Λ σ) ↔ ∀ i,∃ z : ℤ,cc.coord g i=z) +variable [MeasurableSpace ((cube H (Finset.univ : Finset ι) 0)⧸cubeLattice H (conjugateLattice Λ σ))] +variable [hBorel : @BorelSpace ((cube H (Finset.univ : Finset ι) 0)⧸cubeLattice H (conjugateLattice Λ σ)) (QuotientGroup.instTopologicalSpace (cubeLattice H (conjugateLattice Λ σ))) inferInstance] +variable (mtr : MetricSpace ((cube H (Finset.univ : Finset ι) 0)⧸cubeLattice H (conjugateLattice Λ σ))) +variable (htop : mtr.toUniformSpace.toTopologicalSpace=QuotientGroup.instTopologicalSpace (cubeLattice H (conjugateLattice Λ σ))) + +include h01 hs hsk hqbound hq hΓ htop in + + +theorem two_scale_cube_haar_uniform + (μ : Measure ((cube H (Finset.univ : Finset ι) 0)⧸cubeLattice H (conjugateLattice Λ σ))) + [IsProbabilityMeasure μ] + [SMulInvariantMeasure (cube H (Finset.univ : Finset ι) 0) _ μ] + (a : ℕ→∀ k : ℕ,H.level k) + (hirr : ∀ j : ℕ,0 < j → j ≤ s → ∀ ξ : H.level j→*Multiplicative ℝ, + ξ≠1 → Continuous ξ → RationalCharacter (conjugateLattice Λ σ) ξ → + (∀ x (hx : x∈H.level (j+1)),ξ ⟨x,H.antitone (Nat.le_succ _) hx⟩=1) → + (∀ i k : ℕ,0 < i → 0 < k → ∀ h : i+k=j, + ∀ x (hx : x∈H.level i) y (hy : y∈H.level k), + ξ ⟨⁅x,y⁆,by rw [←h]; exact H.commutator_le i k (Subgroup.commutator_mem_commutator hx hy)⟩=1) → + Tendsto (fun N : ℕ => ‖((ξ (a N j)).toAdd:UnitAddCircle)‖*(N:ℝ)^j) + atTop atTop) + + (d₀ : ℕ) (hd₀ : 0] 0,∀ᶠ N : ℕ in atTop, + ∀ j : J α N,∀ z∈integerBox v (lo α N j) (hi α N j),u α N j z∈U) + (F : C((Finset ι→G⧸Λ),ℂ)) : + ∀ ε : ℝ,0<ε → ∀ᶠ α : ℝ in 𝓝[>] 0,∀ᶠ N : ℕ in atTop,∀ j : J α N, + ‖(𝔼 z∈integerBox v (lo α N j) (hi α N j), + F (haarImage H Λ σ (u α N j z) (QuotientGroup.mk + (cubePolynomial c H S hH (a N) s + (fun i => ((r (e i)+(d₀:ℤ)*z (e i):ℤ):ℝ))))))- + (∫ x,frozenTest H Λ σ F u₀ x ∂μ)‖<ε := by + let : MetricSpace ((cube H (Finset.univ : Finset ι) 0)⧸cubeLattice H (conjugateLattice Λ σ)) := + MetricSpace.replaceTopology mtr htop.symm + let : CompactSpace ((cube H (Finset.univ : Finset ι) 0)⧸cubeLattice H (conjugateLattice Λ σ)) := + metric_compact cc (cubeLattice H (conjugateLattice Λ σ)) hΓ inferInstance rfl + let p : ∀ α N,J α N→(Fin v→ℤ)→((cube H (Finset.univ : Finset ι) 0)⧸cubeLattice H (conjugateLattice Λ σ)) := + fun _ N _ z => QuotientGroup.mk (cubePolynomial c H S hH (a N) s + (fun i => ((r (e i)+(d₀:ℤ)*z (e i):ℤ):ℝ))) + apply FiniteHaarTests.two_scale_freezing_uniform μ (frozenTest H Λ σ F) + (frozenTest_continuous H Λ σ F) u₀ J + (fun α N j => integerBox v (lo α N j) (hi α N j)) p u _ hu + intro α hα ε hε + obtain ⟨c₀,C₀,hc₀,hC₀,hbox⟩ := hb α hα + have he := haar_limit_compact c H S hH (conjugateLattice Λ σ) h01 s hs e cc hsk q hqbound hq hΓ + rfl μ a hirr c₀ C₀ hc₀ hC₀ d₀ hd₀ r + {frozenTest H Λ σ F u₀} isCompact_singleton ε hε + filter_upwards [he,hbox] with N he hbox + intro j + have hbox := hbox j + exact he (lo α N j) (hi α N j) hbox.1 hbox.2 _ (Set.mem_singleton _) + +end CubeLocalHaar +end +end + + + +section + +noncomputable section +open scoped Topology BigOperators +open Filter +namespace CubeLocalHaar + + + +theorem smooth_local_freezing_uniform {G κ τ : Type*} [PseudoMetricSpace G] [Fintype τ] + (g : ℕ→ℝ→G) (h : ℝ→G) (β : ℝ) (hh : ContinuousAt h β) + (ρ : ℝ) (hρ : 0<ρ) + (hg : ∀ ε : ℝ,0<ε → ∀ᶠ N : ℕ in atTop, + ∀ t : ℝ,dist t β<ρ → dist (g N t) (h t)<ε) + (J : ℝ→ℕ→Type*) + (T : ∀ α N,J α N→Finset κ) (t : ∀ α N,J α N→κ→τ→ℝ) (C : ℝ) + (ht : ∀ α : ℝ,0<α → ∀ᶠ N : ℕ in atTop, + ∀ j : J α N,∀ z∈T α N j,∀ w,dist (t α N j z w) β≤C*α) : + ∀ U∈𝓝 (fun _ : τ => h β),∀ᶠ α : ℝ in 𝓝[>] 0, + ∀ᶠ N : ℕ in atTop,∀ j : J α N,∀ z∈T α N j,(fun w => g N (t α N j z w))∈U := by + intro U hU + obtain ⟨ε,hε,hball⟩ := Metric.mem_nhds_iff.mp hU + have hε2 : 0<ε/2 := by positivity + obtain ⟨δ,hδ,hcont⟩ := Metric.continuousAt_iff.mp hh (ε/2) hε2 + have hlim : Tendsto (fun α : ℝ => C*α) (𝓝[>] 0) (𝓝 0) := by + have hc : Continuous (fun α : ℝ => C*α) := continuous_const.mul continuous_id + simpa only [mul_zero] using (hc.tendsto 0).mono_left (nhdsWithin_le_nhds (s := Set.Ioi (0:ℝ))) + filter_upwards [hlim.eventually_lt_const (lt_min hδ hρ), + (self_mem_nhdsWithin : Set.Ioi (0:ℝ)∈𝓝[>] 0)] with α hα ha + filter_upwards [hg (ε/2) hε2,ht α ha] with N hgN htN + intro j z hz + apply hball + rw [Metric.mem_ball,dist_pi_lt_iff hε] + intro w + have hd := (htN j z hz w).trans_lt hα + have hg' := hgN (t α N j z w) ((lt_min_iff.mp hd).2) + have hh' := hcont ((lt_min_iff.mp hd).1) + exact (dist_triangle _ _ _).trans_lt (by linarith only [hg',hh']) + +end CubeLocalHaar +end +end + + + +section +noncomputable section +open scoped BigOperators Topology commutatorElement +namespace CubeLocalHaar +open CubeFaces LeibmanSquare CubeTaylorExpansion CubeHorizontalIrrationality +open RationalLattice MeasureTheory Filter ComparableBoxLeibman MalcevCharacters AbelianMalcevTorus +variable {G ι : Type} [Group G] [PseudoMetricSpace G] [IsTopologicalGroup G] +variable [Fintype ι] [DecidableEq ι] +variable {n t d v : ℕ} (c : RealCoordinates G n) (H : Filtration G) +variable (S : ℕ→Set (Fin n)) +variable (hH : ∀ k (g : G),g∈H.level k ↔ ∀ i∈S k,c.coord g i=0) +variable (Λ : Subgroup G) (σ : G) (h01 : H.level 0=H.level 1) +variable (s : ℕ) (hs : H.level (s+1)=⊥) (e : Option ι≃Fin v) +variable (cc : RealCoordinates (cube H (Finset.univ : Finset ι) 0) (t+d)) +variable (hsk : SecondKind cc) +variable (q : ℕ→ℕ) (hqbound : ∀ k,q k ≤ t+d) +variable (hq : ∀ k (g : cube H (Finset.univ : Finset ι) 0), + g∈(CubeMaxFiltration.filtration H Finset.univ).level k ↔ + ∀ i : Fin (t+d),i.val < q k → cc.coord g i=0) +variable (hΓ : ∀ g : cube H (Finset.univ : Finset ι) 0, + g∈cubeLattice H (conjugateLattice Λ σ) ↔ ∀ i,∃ z : ℤ,cc.coord g i=z) +variable [MeasurableSpace ((cube H (Finset.univ : Finset ι) 0)⧸cubeLattice H (conjugateLattice Λ σ))] +variable [hBorel : @BorelSpace ((cube H (Finset.univ : Finset ι) 0)⧸cubeLattice H (conjugateLattice Λ σ)) (QuotientGroup.instTopologicalSpace (cubeLattice H (conjugateLattice Λ σ))) inferInstance] +variable (mtr : MetricSpace ((cube H (Finset.univ : Finset ι) 0)⧸cubeLattice H (conjugateLattice Λ σ))) +variable (htop : mtr.toUniformSpace.toTopologicalSpace=QuotientGroup.instTopologicalSpace (cubeLattice H (conjugateLattice Λ σ))) + +include S hH h01 hs hsk hqbound hq hΓ htop in + + +theorem smooth_cube_haar_uniform + (μ : Measure ((cube H (Finset.univ : Finset ι) 0)⧸cubeLattice H (conjugateLattice Λ σ))) + [IsProbabilityMeasure μ] + [SMulInvariantMeasure (cube H (Finset.univ : Finset ι) 0) _ μ] + (a : ℕ→∀ k : ℕ,H.level k) + (hirr : ∀ j : ℕ,0 < j → j ≤ s → ∀ ξ : H.level j→*Multiplicative ℝ, + ξ≠1 → Continuous ξ → RationalCharacter (conjugateLattice Λ σ) ξ → + (∀ x (hx : x∈H.level (j+1)),ξ ⟨x,H.antitone (Nat.le_succ _) hx⟩=1) → + (∀ i k : ℕ,0 < i → 0 < k → ∀ h : i+k=j, + ∀ x (hx : x∈H.level i) y (hy : y∈H.level k), + ξ ⟨⁅x,y⁆,by rw [←h]; exact H.commutator_le i k (Subgroup.commutator_mem_commutator hx hy)⟩=1) → + Tendsto (fun N : ℕ => ‖((ξ (a N j)).toAdd:UnitAddCircle)‖*(N:ℝ)^j) + atTop atTop) + + (d₀ : ℕ) (hd₀ : 0] 0,∀ᶠ N : ℕ in atTop,∀ j : J α N, + ‖(𝔼 z∈integerBox v (lo α N j) (hi α N j), + F (fun w : Finset ι => QuotientGroup.mk + (g N (((r (e none)+(d₀:ℤ)*z (e none):ℤ):ℝ)/(N:ℝ)+ + ∑ i∈w,(((r (e (some i))+(d₀:ℤ)*z (e (some i)):ℤ):ℝ)/(N:ℝ))) * + taylorPolynomial c H (a N) s + (((r (e none)+(d₀:ℤ)*z (e none):ℤ):ℝ)+ + ∑ i∈w,((r (e (some i))+(d₀:ℤ)*z (e (some i)):ℤ):ℝ)) * σ)))- + (∫ x,frozenTest H Λ σ F (fun _ => h β) x ∂μ)‖<ε := by + let T : ∀ α N,J α N→Finset (Fin v→ℤ) := fun α N j => integerBox v (lo α N j) (hi α N j) + let b : (Fin v→ℤ)→Option ι→ℝ := fun z i => ((r (e i)+(d₀:ℤ)*z (e i):ℤ):ℝ) + let t : ∀ α N,J α N→(Fin v→ℤ)→Finset ι→ℝ := + fun _ N _ z w => b z none/(N:ℝ)+∑ i∈w,b z (some i)/(N:ℝ) + have ht : ∀ α : ℝ,0<α → ∀ᶠ N : ℕ in atTop, + ∀ j : J α N,∀ z∈T α N j,∀ w,dist (t α N j z w) β≤((1+(Fintype.card ι:ℝ))*C)*α := by + intro α hα + filter_upwards [hgeo α hα] with N hN + intro j z hz w + simpa only [mul_assoc] using normalized_vertex_close (fun i => b z i/(N:ℝ)) β (C*α) (mul_nonneg hC hα.le) + (hN j z hz).1 (hN j z hz).2 w + have hu := smooth_local_freezing_uniform g h β hh ρ hρ hg J T t ((1+(Fintype.card ι:ℝ))*C) ht + have hlimit := two_scale_cube_haar_uniform c H S hH Λ σ h01 s hs e cc hsk q hqbound hq hΓ mtr htop + μ a hirr d₀ hd₀ r J lo hi hb (fun α N j z w => g N (t α N j z w)) (fun _ => h β) hu F + have himage (α : ℝ) (N : ℕ) (j : J α N) (z : Fin v→ℤ) : + haarImage H Λ σ (fun w => g N (t α N j z w)) + (QuotientGroup.mk (cubePolynomial c H S hH (a N) s (b z))) = + fun w : Finset ι => QuotientGroup.mk + (g N (t α N j z w)*taylorPolynomial c H (a N) s + (b z none+∑ i∈w,b z (some i))*σ) := by + funext w + rw [haarImage_mk,cubePolynomial_vertex] + change ∀ ε : ℝ,0<ε → ∀ᶠ α : ℝ in 𝓝[>] 0,∀ᶠ N : ℕ in atTop,∀ j : J α N, + ‖(𝔼 z∈integerBox v (lo α N j) (hi α N j), + F (haarImage H Λ σ (fun w => g N (t α N j z w)) + (QuotientGroup.mk (cubePolynomial c H S hH (a N) s (b z)))))- + (∫ x,frozenTest H Λ σ F (fun _ => h β) x ∂μ)‖<ε at hlimit + simp_rw [himage] at hlimit + exact hlimit + +end CubeLocalHaar + +end +end +end +end +end + +end OAI diff --git a/lean/OAI/Combinatorics/SumProduct/Alignment/CubeLocal07.lean b/lean/OAI/Combinatorics/SumProduct/Alignment/CubeLocal07.lean new file mode 100644 index 0000000000000000000000000000000000000000..a2c48c15bda8aa0aae611579d91057d0979c9f80 --- /dev/null +++ b/lean/OAI/Combinatorics/SumProduct/Alignment/CubeLocal07.lean @@ -0,0 +1,330 @@ +import Mathlib +import OAI.Combinatorics.SumProduct.Alignment.CubeLocal03 +import OAI.Combinatorics.SumProduct.Alignment.CubeLocal06 +import OAI.Geometry.NilpotentCharts.Main + +namespace OAI + +section +section +section +section +noncomputable section +open scoped BigOperators Topology commutatorElement +end +end + + + +section +noncomputable section +open scoped Topology +open Filter +namespace ComparableBoxLeibman + + +lemma halfOpen_bounds_uniform {v : ℕ} (c C : ℝ) (hc : 0 ‖((ξ (a N j)).toAdd:UnitAddCircle)‖*(N:ℝ)^j) + atTop atTop) + + (d₀ : ℕ) (hd₀ : 0] 0,∀ᶠ N : ℕ in atTop,∀ j : J α N, + ‖(𝔼 z∈halfOpenBox v (lo α N j) (hi α N j), + F (fun w : Finset ι => QuotientGroup.mk + (g N (((r (e none)+(d₀:ℤ)*z (e none):ℤ):ℝ)/(N:ℝ)+ + ∑ i∈w,(((r (e (some i))+(d₀:ℤ)*z (e (some i)):ℤ):ℝ)/(N:ℝ))) * + taylorPolynomial c H (a N) s + (((r (e none)+(d₀:ℤ)*z (e none):ℤ):ℝ)+ + ∑ i∈w,((r (e (some i))+(d₀:ℤ)*z (e (some i)):ℤ):ℝ)) * σ)))- + (∫ x,frozenTest H Λ σ F (fun _ => h β) x ∂μ)‖<ε := by + have hb' : ∀ α : ℝ,0<α → ∃ c₀ C₀ : ℝ,0 (⌈hi α N j i⌉:ℝ)-1) hb' + C hC g h β hh ρ hρ hg hgeo F + +end CubeLocalHaar +end +end + + + +section +noncomputable section +open scoped BigOperators Topology commutatorElement +namespace CubeLocalHaar +open CubeFaces LeibmanSquare CubeTaylorExpansion CubeHorizontalIrrationality +open RationalLattice MeasureTheory Filter ComparableBoxLeibman MalcevCharacters AbelianMalcevTorus +variable {G ι : Type} [Group G] [PseudoMetricSpace G] [IsTopologicalGroup G] +variable [Fintype ι] [DecidableEq ι] +variable {n t d v : ℕ} (c : RealCoordinates G n) (H : Filtration G) +variable (S : ℕ→Set (Fin n)) +variable (hH : ∀ k (g : G),g∈H.level k ↔ ∀ i∈S k,c.coord g i=0) +variable (Λ : Subgroup G) (σ : G) (h01 : H.level 0=H.level 1) +variable (s : ℕ) (hs : H.level (s+1)=⊥) (e : Option ι≃Fin v) +variable (cc : RealCoordinates (cube H (Finset.univ : Finset ι) 0) (t+d)) +variable (hsk : SecondKind cc) +variable (q : ℕ→ℕ) (hqbound : ∀ k,q k ≤ t+d) +variable (hq : ∀ k (g : cube H (Finset.univ : Finset ι) 0), + g∈(CubeMaxFiltration.filtration H Finset.univ).level k ↔ + ∀ i : Fin (t+d),i.val < q k → cc.coord g i=0) +variable (hΓ : ∀ g : cube H (Finset.univ : Finset ι) 0, + g∈cubeLattice H (conjugateLattice Λ σ) ↔ ∀ i,∃ z : ℤ,cc.coord g i=z) +variable [MeasurableSpace ((cube H (Finset.univ : Finset ι) 0)⧸cubeLattice H (conjugateLattice Λ σ))] +variable [hBorel : @BorelSpace ((cube H (Finset.univ : Finset ι) 0)⧸cubeLattice H (conjugateLattice Λ σ)) (QuotientGroup.instTopologicalSpace (cubeLattice H (conjugateLattice Λ σ))) inferInstance] +variable (mtr : MetricSpace ((cube H (Finset.univ : Finset ι) 0)⧸cubeLattice H (conjugateLattice Λ σ))) +variable (htop : mtr.toUniformSpace.toTopologicalSpace=QuotientGroup.instTopologicalSpace (cubeLattice H (conjugateLattice Λ σ))) + +include S hH h01 hs hsk hqbound hq hΓ htop in + + +theorem source_box_family_local_cube_haar + (μ : Measure ((cube H (Finset.univ : Finset ι) 0)⧸cubeLattice H (conjugateLattice Λ σ))) + [IsProbabilityMeasure μ] + [SMulInvariantMeasure (cube H (Finset.univ : Finset ι) 0) _ μ] + (a : ℕ→∀ k : ℕ,H.level k) + (hirr : ∀ j : ℕ,0 < j → j ≤ s → ∀ ξ : H.level j→*Multiplicative ℝ, + ξ≠1 → Continuous ξ → RationalCharacter (conjugateLattice Λ σ) ξ → + (∀ x (hx : x∈H.level (j+1)),ξ ⟨x,H.antitone (Nat.le_succ _) hx⟩=1) → + (∀ i k : ℕ,0 < i → 0 < k → ∀ h : i+k=j, + ∀ x (hx : x∈H.level i) y (hy : y∈H.level k), + ξ ⟨⁅x,y⁆,by rw [←h]; exact H.commutator_le i k (Subgroup.commutator_mem_commutator hx hy)⟩=1) → + Tendsto (fun N : ℕ => ‖((ξ (a N j)).toAdd:UnitAddCircle)‖*(N:ℝ)^j) + atTop atTop) + + (d₀ r₀ : ℕ) (hd₀ : 0] 0,∀ᶠ N : ℕ in atTop,∀ j : J α N, + ‖(𝔼 z∈halfOpenBox v (lo α N j) (hi α N j), + F (fun w : Finset ι => QuotientGroup.mk + (g N ((sourceVertex e d₀ r₀ z w:ℝ)/(N:ℝ)) * + taylorPolynomial c H (a N) s (sourceVertex e d₀ r₀ z w:ℝ) * σ)))- + (∫ x,frozenTest H Λ σ F (fun _ => h β) x ∂μ)‖<ε := by + intro _ β _ J lo hi hb C hC hgeo g h hh ρ hρ hg F + have he := smooth_halfOpen_cube_haar_uniform c H S hH Λ σ h01 s hs e cc hsk q hqbound hq hΓ mtr htop + μ a hirr d₀ hd₀ (sourceResidue e r₀) J lo hi hb C hC + g h β hh ρ hρ hg hgeo F + simpa only [sourceVertex_real,sourceVertex_normalized] using he + +end CubeLocalHaar +end +end + + + +section +noncomputable section +open scoped BigOperators Topology commutatorElement +namespace CubeLocalHaar +open CubeFaces LeibmanSquare CubeTaylorExpansion CubeHorizontalIrrationality +open RationalLattice MeasureTheory Filter ComparableBoxLeibman MalcevCharacters AbelianMalcevTorus +variable {G ι : Type} [Group G] [PseudoMetricSpace G] [IsTopologicalGroup G] +variable [Fintype ι] [DecidableEq ι] +variable {n t d v : ℕ} (c : RealCoordinates G n) (H : Filtration G) +variable (S : ℕ→Set (Fin n)) +variable (hH : ∀ k (g : G),g∈H.level k ↔ ∀ i∈S k,c.coord g i=0) +variable (Λ : Subgroup G) (σ : G) (h01 : H.level 0=H.level 1) +variable (s : ℕ) (hs : H.level (s+1)=⊥) (e : Option ι≃Fin v) +variable (cc : RealCoordinates (cube H (Finset.univ : Finset ι) 0) (t+d)) +variable (hsk : SecondKind cc) +variable (q : ℕ→ℕ) (hqbound : ∀ k,q k ≤ t+d) +variable (hq : ∀ k (g : cube H (Finset.univ : Finset ι) 0), + g∈(CubeMaxFiltration.filtration H Finset.univ).level k ↔ + ∀ i : Fin (t+d),i.val < q k → cc.coord g i=0) +variable (hΓ : ∀ g : cube H (Finset.univ : Finset ι) 0, + g∈cubeLattice H (conjugateLattice Λ σ) ↔ ∀ i,∃ z : ℤ,cc.coord g i=z) +variable [MeasurableSpace ((cube H (Finset.univ : Finset ι) 0)⧸cubeLattice H (conjugateLattice Λ σ))] +variable [hBorel : @BorelSpace ((cube H (Finset.univ : Finset ι) 0)⧸cubeLattice H (conjugateLattice Λ σ)) (QuotientGroup.instTopologicalSpace (cubeLattice H (conjugateLattice Λ σ))) inferInstance] +variable (mtr : MetricSpace ((cube H (Finset.univ : Finset ι) 0)⧸cubeLattice H (conjugateLattice Λ σ))) +variable (htop : mtr.toUniformSpace.toTopologicalSpace=QuotientGroup.instTopologicalSpace (cubeLattice H (conjugateLattice Λ σ))) + +variable [MeasurableSpace (G⧸Λ)] [BorelSpace (G⧸Λ)] +variable [SecondCountableTopology (G⧸Λ)] + +include S hH h01 hs hsk hqbound hq hΓ htop in + + +theorem source_box_family_factored_cube_haar + (μ : Measure ((cube H (Finset.univ : Finset ι) 0)⧸cubeLattice H (conjugateLattice Λ σ))) + [IsProbabilityMeasure μ] + [SMulInvariantMeasure (cube H (Finset.univ : Finset ι) 0) _ μ] + (a : ℕ→∀ k : ℕ,H.level k) + (hirr : ∀ j : ℕ,0 < j → j ≤ s → ∀ ξ : H.level j→*Multiplicative ℝ, + ξ≠1 → Continuous ξ → RationalCharacter (conjugateLattice Λ σ) ξ → + (∀ x (hx : x∈H.level (j+1)),ξ ⟨x,H.antitone (Nat.le_succ _) hx⟩=1) → + (∀ i k : ℕ,0 < i → 0 < k → ∀ h : i+k=j, + ∀ x (hx : x∈H.level i) y (hy : y∈H.level k), + ξ ⟨⁅x,y⁆,by rw [←h]; exact H.commutator_le i k (Subgroup.commutator_mem_commutator hx hy)⟩=1) → + Tendsto (fun N : ℕ => ‖((ξ (a N j)).toAdd:UnitAddCircle)‖*(N:ℝ)^j) + atTop atTop) + + (d₀ r₀ : ℕ) (hd₀ : 0 h β) + ∀ ε : ℝ,0<ε → ∀ᶠ α : ℝ in 𝓝[>] 0,∀ᶠ N : ℕ in atTop,∀ j : J α N, + ‖(𝔼 z∈halfOpenBox v (lo α N j) (hi α N j), + F (fun w : Finset ι => QuotientGroup.mk (P N (sourceVertex e d₀ r₀ z w))))- + (∫ y,F y ∂(m:Measure (Finset ι→G⧸Λ)))‖<ε := by + let : CompactSpace ((cube H (Finset.univ : Finset ι) 0)⧸cubeLattice H (conjugateLattice Λ σ)) := by + let := MetricSpace.replaceTopology mtr htop.symm + exact metric_compact cc (cubeLattice H (conjugateLattice Λ σ)) hΓ inferInstance rfl + intro m + have hm : (∫ y,F y ∂(m:Measure (Finset ι→G⧸Λ))) = + ∫ x,frozenTest H Λ σ F (fun _ => h β) x ∂μ := + integral_imageProbability H Λ σ ⟨μ,inferInstance⟩ (fun _ => h β) F + rw [hm] + have hv (N : ℕ) (z : Fin v→ℤ) (w : Finset ι) : + QuotientGroup.mk (P N (sourceVertex e d₀ r₀ z w)) = + (QuotientGroup.mk (g N ((sourceVertex e d₀ r₀ z w:ℝ)/(N:ℝ))* + taylorPolynomial c H (a N) s (sourceVertex e d₀ r₀ z w:ℝ)*σ):G⧸Λ) := by + rw [hfactor] + exact congrArg (fun x : G⧸Λ => + (g N ((sourceVertex e d₀ r₀ z w:ℝ)/(N:ℝ))* + taylorPolynomial c H (a N) s (sourceVertex e d₀ r₀ z w:ℝ)) • x) + (hperiod N _ (sourceVertex_emod e d₀ r₀ hr₀ z w)) + simp_rw [hv] + exact source_box_family_local_cube_haar c H S hH Λ σ h01 s hs e cc hsk q hqbound hq hΓ mtr htop + μ a hirr d₀ r₀ hd₀ hr₀ β hβ J lo hi hb C hC hgeo g h hh ρ hρ hg F + +end CubeLocalHaar + +end +end +end +end +end + +end OAI diff --git a/lean/OAI/Combinatorics/SumProduct/Alignment/CubeLocal08.lean b/lean/OAI/Combinatorics/SumProduct/Alignment/CubeLocal08.lean new file mode 100644 index 0000000000000000000000000000000000000000..65b0466f522a8cc37c31c7b5ceb4d8409cd7f5c4 --- /dev/null +++ b/lean/OAI/Combinatorics/SumProduct/Alignment/CubeLocal08.lean @@ -0,0 +1,262 @@ +import Mathlib +import OAI.Combinatorics.SumProduct.Alignment.CubeLocal05 +import OAI.Combinatorics.SumProduct.Alignment.CubeLocal07 +import OAI.Geometry.NilpotentCharts.Main + +namespace OAI + +section +section +section +section +noncomputable section +open scoped BigOperators Topology commutatorElement +end +end + + + +section + +noncomputable section +open scoped Topology BigOperators +namespace FiniteHaarTests +open Filter MeasureTheory +variable {X κ : Type*} [MetricSpace X] [CompactSpace X] +variable [MeasurableSpace X] [BorelSpace X] +variable (μ : Measure X) [IsProbabilityMeasure μ] + + + +theorem compact_two_scale_uniform + (J : ℝ→ℕ→Type*) + (T : ∀ α N,J α N→Finset κ) (p : ∀ α N,J α N→κ→X) + (hl : ∀ F : C(X,ℂ),∀ ε : ℝ,0<ε → + ∀ᶠ α : ℝ in 𝓝[>] 0,∀ᶠ N : ℕ in atTop,∀ j : J α N, + ‖discrepancy μ (T α N j) (p α N j) F‖<ε) + (K : Set C(X,ℂ)) (hK : IsCompact K) : + ∀ ε : ℝ,0<ε → ∀ᶠ α : ℝ in 𝓝[>] 0,∀ᶠ N : ℕ in atTop,∀ j : J α N, + ∀ F∈K,‖discrepancy μ (T α N j) (p α N j) F‖<ε := by + intro ε hε + obtain ⟨S,hS,η,hη,htest⟩ := CompactFamilyDescent.finite_unit_lipschitz_obstruction + K hK ε 2 hε (by norm_num) + have hα : ∀ᶠ α : ℝ in 𝓝[>] 0,∀ F∈S,∀ᶠ N : ℕ in atTop,∀ j : J α N, + ‖discrepancy μ (T α N j) (p α N j) F‖<η := + (Filter.eventually_all_finset S).mpr (fun F _ => hl F η hη) + filter_upwards [hα] with α hα + have hN : ∀ᶠ N : ℕ in atTop,∀ F∈S,∀ j : J α N, + ‖discrepancy μ (T α N j) (p α N j) F‖<η := + (Filter.eventually_all_finset S).mpr hα + filter_upwards [hN] with N hN + intro j F hF + by_contra he + obtain ⟨φ,hφ,hdisc⟩ := htest (discrepancy μ (T α N j) (p α N j)) + (discrepancy_bound μ (T α N j) (p α N j)) ⟨F,hF,le_of_not_gt he⟩ + exact (not_le_of_gt (hN φ hφ j)) hdisc + +end FiniteHaarTests +end +end + + + +section +noncomputable section +open scoped BigOperators Topology commutatorElement +namespace CubeLocalHaar +open CubeFaces LeibmanSquare CubeTaylorExpansion CubeHorizontalIrrationality +open RationalLattice MeasureTheory Filter ComparableBoxLeibman MalcevCharacters AbelianMalcevTorus +variable {G ι : Type} [Group G] [PseudoMetricSpace G] [IsTopologicalGroup G] +variable [Fintype ι] [DecidableEq ι] +variable {n t d v : ℕ} (c : RealCoordinates G n) (H : Filtration G) +variable (S : ℕ→Set (Fin n)) +variable (hH : ∀ k (g : G),g∈H.level k ↔ ∀ i∈S k,c.coord g i=0) +variable (Λ : Subgroup G) (σ : G) (h01 : H.level 0=H.level 1) +variable (s : ℕ) (hs : H.level (s+1)=⊥) (e : Option ι≃Fin v) +variable (cc : RealCoordinates (cube H (Finset.univ : Finset ι) 0) (t+d)) +variable (hsk : SecondKind cc) +variable (q : ℕ→ℕ) (hqbound : ∀ k,q k ≤ t+d) +variable (hq : ∀ k (g : cube H (Finset.univ : Finset ι) 0), + g∈(CubeMaxFiltration.filtration H Finset.univ).level k ↔ + ∀ i : Fin (t+d),i.val < q k → cc.coord g i=0) +variable (hΓ : ∀ g : cube H (Finset.univ : Finset ι) 0, + g∈cubeLattice H (conjugateLattice Λ σ) ↔ ∀ i,∃ z : ℤ,cc.coord g i=z) +variable [MeasurableSpace ((cube H (Finset.univ : Finset ι) 0)⧸cubeLattice H (conjugateLattice Λ σ))] +variable [hBorel : @BorelSpace ((cube H (Finset.univ : Finset ι) 0)⧸cubeLattice H (conjugateLattice Λ σ)) (QuotientGroup.instTopologicalSpace (cubeLattice H (conjugateLattice Λ σ))) inferInstance] +variable (mtr : MetricSpace ((cube H (Finset.univ : Finset ι) 0)⧸cubeLattice H (conjugateLattice Λ σ))) +variable (htop : mtr.toUniformSpace.toTopologicalSpace=QuotientGroup.instTopologicalSpace (cubeLattice H (conjugateLattice Λ σ))) + +variable [MeasurableSpace (G⧸Λ)] [BorelSpace (G⧸Λ)] +variable [SecondCountableTopology (G⧸Λ)] + +variable [CompactSpace (G⧸Λ)] +variable (qmtr : MetricSpace (G⧸Λ)) +variable (hqtop : qmtr.toUniformSpace.toTopologicalSpace=QuotientGroup.instTopologicalSpace Λ) + +include S hH h01 hs hsk hqbound hq hΓ htop hqtop in + + +theorem source_box_family_compact_cube_haar + (μ : Measure ((cube H (Finset.univ : Finset ι) 0)⧸cubeLattice H (conjugateLattice Λ σ))) + [IsProbabilityMeasure μ] + [SMulInvariantMeasure (cube H (Finset.univ : Finset ι) 0) _ μ] + (a : ℕ→∀ k : ℕ,H.level k) + (hirr : ∀ j : ℕ,0 < j → j ≤ s → ∀ ξ : H.level j→*Multiplicative ℝ, + ξ≠1 → Continuous ξ → RationalCharacter (conjugateLattice Λ σ) ξ → + (∀ x (hx : x∈H.level (j+1)),ξ ⟨x,H.antitone (Nat.le_succ _) hx⟩=1) → + (∀ i k : ℕ,0 < i → 0 < k → ∀ h : i+k=j, + ∀ x (hx : x∈H.level i) y (hy : y∈H.level k), + ξ ⟨⁅x,y⁆,by rw [←h]; exact H.commutator_le i k (Subgroup.commutator_mem_commutator hx hy)⟩=1) → + Tendsto (fun N : ℕ => ‖((ξ (a N j)).toAdd:UnitAddCircle)‖*(N:ℝ)^j) + atTop atTop) + + (d₀ r₀ : ℕ) (hd₀ : 0 h β) + ∀ ε : ℝ,0<ε → ∀ᶠ α : ℝ in 𝓝[>] 0,∀ᶠ N : ℕ in atTop,∀ j : J α N,∀ F∈K, + ‖(𝔼 z∈halfOpenBox v (lo α N j) (hi α N j), + F (fun w : Finset ι => QuotientGroup.mk (P N (sourceVertex e d₀ r₀ z w))))- + (∫ y,F y ∂(m:Measure (Finset ι→G⧸Λ)))‖<ε := by + let : MetricSpace (G⧸Λ) := MetricSpace.replaceTopology qmtr hqtop.symm + intro m + apply FiniteHaarTests.compact_two_scale_uniform (m:Measure (Finset ι→G⧸Λ)) J + (fun α N j => halfOpenBox v (lo α N j) (hi α N j)) + (fun _ N _ z w => QuotientGroup.mk (P N (sourceVertex e d₀ r₀ z w))) _ K hK + intro F + exact source_box_family_factored_cube_haar c H S hH Λ σ h01 s hs e cc hsk q hqbound hq hΓ mtr htop + μ a hirr d₀ r₀ hd₀ hr₀ β hβ J lo hi hb C hC hgeo g h hh ρ hρ hg P γ hfactor hperiod F + +end CubeLocalHaar +end +end + + + +section +noncomputable section +open scoped BigOperators Topology commutatorElement NNReal +namespace CubeLocalHaar +open CubeFaces LeibmanSquare CubeTaylorExpansion CubeHorizontalIrrationality +open RationalLattice MeasureTheory Filter ComparableBoxLeibman MalcevCharacters AbelianMalcevTorus +variable {G ι : Type} [Group G] [PseudoMetricSpace G] [IsTopologicalGroup G] +variable [Fintype ι] [DecidableEq ι] +variable {n t d v : ℕ} (c : RealCoordinates G n) (H : Filtration G) +variable (S : ℕ→Set (Fin n)) +variable (hH : ∀ k (g : G),g∈H.level k ↔ ∀ i∈S k,c.coord g i=0) +variable (Λ : Subgroup G) (σ : G) (h01 : H.level 0=H.level 1) +variable (s : ℕ) (hs : H.level (s+1)=⊥) (e : Option ι≃Fin v) +variable (cc : RealCoordinates (cube H (Finset.univ : Finset ι) 0) (t+d)) +variable (hsk : SecondKind cc) +variable (q : ℕ→ℕ) (hqbound : ∀ k,q k ≤ t+d) +variable (hq : ∀ k (g : cube H (Finset.univ : Finset ι) 0), + g∈(CubeMaxFiltration.filtration H Finset.univ).level k ↔ + ∀ i : Fin (t+d),i.val < q k → cc.coord g i=0) +variable (hΓ : ∀ g : cube H (Finset.univ : Finset ι) 0, + g∈cubeLattice H (conjugateLattice Λ σ) ↔ ∀ i,∃ z : ℤ,cc.coord g i=z) +variable [MeasurableSpace ((cube H (Finset.univ : Finset ι) 0)⧸cubeLattice H (conjugateLattice Λ σ))] +variable [hBorel : @BorelSpace ((cube H (Finset.univ : Finset ι) 0)⧸cubeLattice H (conjugateLattice Λ σ)) (QuotientGroup.instTopologicalSpace (cubeLattice H (conjugateLattice Λ σ))) inferInstance] +variable (mtr : MetricSpace ((cube H (Finset.univ : Finset ι) 0)⧸cubeLattice H (conjugateLattice Λ σ))) +variable (htop : mtr.toUniformSpace.toTopologicalSpace=QuotientGroup.instTopologicalSpace (cubeLattice H (conjugateLattice Λ σ))) + +variable [MeasurableSpace (G⧸Λ)] [BorelSpace (G⧸Λ)] +variable [SecondCountableTopology (G⧸Λ)] + +variable [CompactSpace (G⧸Λ)] +variable (qmtr : MetricSpace (G⧸Λ)) +variable (hqtop : qmtr.toUniformSpace.toTopologicalSpace=QuotientGroup.instTopologicalSpace Λ) + +include S hH h01 hs hsk hqbound hq hΓ htop hqtop in + + +theorem source_box_family_bounded_cube_haar + (μ : Measure ((cube H (Finset.univ : Finset ι) 0)⧸cubeLattice H (conjugateLattice Λ σ))) + [IsProbabilityMeasure μ] + [SMulInvariantMeasure (cube H (Finset.univ : Finset ι) 0) _ μ] + (a : ℕ→∀ k : ℕ,H.level k) + (hirr : ∀ j : ℕ,0 < j → j ≤ s → ∀ ξ : H.level j→*Multiplicative ℝ, + ξ≠1 → Continuous ξ → RationalCharacter (conjugateLattice Λ σ) ξ → + (∀ x (hx : x∈H.level (j+1)),ξ ⟨x,H.antitone (Nat.le_succ _) hx⟩=1) → + (∀ i k : ℕ,0 < i → 0 < k → ∀ h : i+k=j, + ∀ x (hx : x∈H.level i) y (hy : y∈H.level k), + ξ ⟨⁅x,y⁆,by rw [←h]; exact H.commutator_le i k (Subgroup.commutator_mem_commutator hx hy)⟩=1) → + Tendsto (fun N : ℕ => ‖((ξ (a N j)).toAdd:UnitAddCircle)‖*(N:ℝ)^j) + atTop atTop) + + (d₀ r₀ : ℕ) (hd₀ : 0 h β) + ∀ ε : ℝ,0<ε → ∀ᶠ α : ℝ in 𝓝[>] 0,∀ᶠ N : ℕ in atTop,∀ j : J α N,∀ F : C((Finset ι→G⧸Λ),ℂ), + LipschitzWith L F → ‖F‖≤B → + ‖(𝔼 z∈halfOpenBox v (lo α N j) (hi α N j), + F (fun w : Finset ι => QuotientGroup.mk (P N (sourceVertex e d₀ r₀ z w))))- + (∫ y,F y ∂(m:Measure (Finset ι→G⧸Λ)))‖<ε := by + let : MetricSpace (G⧸Λ) := MetricSpace.replaceTopology qmtr hqtop.symm + intro m + obtain ⟨K,hK,hcover⟩ := BoundedLipschitzCompact.compact_envelope + (X := Finset ι→G⧸Λ) L B + have hhK := source_box_family_compact_cube_haar c H S hH Λ σ h01 s hs e cc hsk q hqbound hq hΓ + mtr htop qmtr hqtop μ a hirr d₀ r₀ hd₀ hr₀ β hβ J lo hi hb C hC hgeo g h hh ρ hρ hg P γ hfactor hperiod K hK + intro ε hε + filter_upwards [hhK ε hε] with α hα + filter_upwards [hα] with N hN + intro j F hL hB + exact hN j F (hcover F hL hB) + +end CubeLocalHaar + +end +end +end +end +end + +end OAI diff --git a/lean/OAI/Combinatorics/SumProduct/Alignment/CubeLocal09.lean b/lean/OAI/Combinatorics/SumProduct/Alignment/CubeLocal09.lean new file mode 100644 index 0000000000000000000000000000000000000000..91ed467f71aaad90b7cf92540104f3199fd14a44 --- /dev/null +++ b/lean/OAI/Combinatorics/SumProduct/Alignment/CubeLocal09.lean @@ -0,0 +1,287 @@ +import Mathlib +import OAI.Combinatorics.SumProduct.Alignment.CubeLocal08 +import OAI.Geometry.NilpotentCharts.Main + +namespace OAI + +section +section +section +section +noncomputable section +open scoped BigOperators Topology commutatorElement NNReal +end +end + + + +section +noncomputable section +open scoped BigOperators Topology commutatorElement NNReal +namespace CubeLocalHaar +open CubeFaces LeibmanSquare CubeTaylorExpansion CubeHorizontalIrrationality +open RationalLattice MeasureTheory Filter ComparableBoxLeibman MalcevCharacters AbelianMalcevTorus +variable {G ι : Type} [Group G] [PseudoMetricSpace G] [IsTopologicalGroup G] +variable [Fintype ι] [DecidableEq ι] +variable {n t d v : ℕ} (c : RealCoordinates G n) (H : Filtration G) +variable (S : ℕ→Set (Fin n)) +variable (hH : ∀ k (g : G),g∈H.level k ↔ ∀ i∈S k,c.coord g i=0) +variable (Λ : Subgroup G) (σ : G) (h01 : H.level 0=H.level 1) +variable (s : ℕ) (hs : H.level (s+1)=⊥) (e : Option ι≃Fin v) +variable (cc : RealCoordinates (cube H (Finset.univ : Finset ι) 0) (t+d)) +variable (hsk : SecondKind cc) +variable (q : ℕ→ℕ) (hqbound : ∀ k,q k ≤ t+d) +variable (hq : ∀ k (g : cube H (Finset.univ : Finset ι) 0), + g∈(CubeMaxFiltration.filtration H Finset.univ).level k ↔ + ∀ i : Fin (t+d),i.val < q k → cc.coord g i=0) +variable (hΓ : ∀ g : cube H (Finset.univ : Finset ι) 0, + g∈cubeLattice H (conjugateLattice Λ σ) ↔ ∀ i,∃ z : ℤ,cc.coord g i=z) +variable [MeasurableSpace ((cube H (Finset.univ : Finset ι) 0)⧸cubeLattice H (conjugateLattice Λ σ))] +variable [hBorel : @BorelSpace ((cube H (Finset.univ : Finset ι) 0)⧸cubeLattice H (conjugateLattice Λ σ)) (QuotientGroup.instTopologicalSpace (cubeLattice H (conjugateLattice Λ σ))) inferInstance] +variable (mtr : MetricSpace ((cube H (Finset.univ : Finset ι) 0)⧸cubeLattice H (conjugateLattice Λ σ))) +variable (htop : mtr.toUniformSpace.toTopologicalSpace=QuotientGroup.instTopologicalSpace (cubeLattice H (conjugateLattice Λ σ))) + +variable [MeasurableSpace (G⧸Λ)] [BorelSpace (G⧸Λ)] +variable [SecondCountableTopology (G⧸Λ)] + +variable [CompactSpace (G⧸Λ)] +variable (qmtr : MetricSpace (G⧸Λ)) +variable (hqtop : qmtr.toUniformSpace.toTopologicalSpace=QuotientGroup.instTopologicalSpace Λ) + +include S hH h01 hs hsk hqbound hq hΓ htop hqtop in + + +theorem source_comparable_boxes_cube_haar + (μ : Measure ((cube H (Finset.univ : Finset ι) 0)⧸cubeLattice H (conjugateLattice Λ σ))) + [IsProbabilityMeasure μ] + [SMulInvariantMeasure (cube H (Finset.univ : Finset ι) 0) _ μ] + (a : ℕ→∀ k : ℕ,H.level k) + (hirr : ∀ j : ℕ,0 < j → j ≤ s → ∀ ξ : H.level j→*Multiplicative ℝ, + ξ≠1 → Continuous ξ → RationalCharacter (conjugateLattice Λ σ) ξ → + (∀ x (hx : x∈H.level (j+1)),ξ ⟨x,H.antitone (Nat.le_succ _) hx⟩=1) → + (∀ i k : ℕ,0 < i → 0 < k → ∀ h : i+k=j, + ∀ x (hx : x∈H.level i) y (hy : y∈H.level k), + ξ ⟨⁅x,y⁆,by rw [←h]; exact H.commutator_le i k (Subgroup.commutator_mem_commutator hx hy)⟩=1) → + Tendsto (fun N : ℕ => ‖((ξ (a N j)).toAdd:UnitAddCircle)‖*(N:ℝ)^j) + atTop atTop) + + (d₀ r₀ : ℕ) (hd₀ : 0 h β) + ∀ ε : ℝ,0<ε → ∀ᶠ α : ℝ in 𝓝[>] 0,∀ᶠ N : ℕ in atTop, + ∀ lo hi : Fin v→ℝ, + (∀ i,(cBox*α)*(N:ℝ)≤hi i-lo i) → + (∀ i,-CBox*(N:ℝ)≤lo i ∧ hi i≤CBox*(N:ℝ)) → + (∀ z∈halfOpenBox v lo hi, + |(((sourceResidue e r₀ (e none)+(d₀:ℤ)*z (e none):ℤ):ℝ)/(N:ℝ))-β|≤C*α ∧ + ∀ i : ι,|(((sourceResidue e r₀ (e (some i))+(d₀:ℤ)*z (e (some i)):ℤ):ℝ)/(N:ℝ))|≤C*α) → + ∀ F : C((Finset ι→G⧸Λ),ℂ), + LipschitzWith L F → ‖F‖≤B → + ‖(𝔼 z∈halfOpenBox v lo hi, + F (fun w : Finset ι => QuotientGroup.mk (P N (sourceVertex e d₀ r₀ z w))))- + (∫ y,F y ∂(m:Measure (Finset ι→G⧸Λ)))‖<ε := by + let : MetricSpace (G⧸Λ) := MetricSpace.replaceTopology qmtr hqtop.symm + intro m + let J (α : ℝ) (N : ℕ) := {b : (Fin v→ℝ)×(Fin v→ℝ) // + (∀ i,(cBox*α)*(N:ℝ)≤b.2 i-b.1 i) ∧ + (∀ i,-CBox*(N:ℝ)≤b.1 i ∧ b.2 i≤CBox*(N:ℝ)) ∧ + ∀ z∈halfOpenBox v b.1 b.2, + |(((sourceResidue e r₀ (e none)+(d₀:ℤ)*z (e none):ℤ):ℝ)/(N:ℝ))-β|≤C*α ∧ + ∀ i : ι,|(((sourceResidue e r₀ (e (some i))+(d₀:ℤ)*z (e (some i)):ℤ):ℝ)/(N:ℝ))|≤C*α} + let lo : ∀ α N,J α N→Fin v→ℝ := fun _ _ j => j.val.1 + let hi : ∀ α N,J α N→Fin v→ℝ := fun _ _ j => j.val.2 + have hb (α : ℝ) (hα : 0<α) : ∃ c₀ C₀ : ℝ,0 ⟨j.property.1,j.property.2.1⟩)⟩ + have hgbox (α : ℝ) (_ha : 0<α) : ∀ᶠ N : ℕ in atTop, + ∀ j : J α N,∀ z∈halfOpenBox v (lo α N j) (hi α N j), + |(((sourceResidue e r₀ (e none)+(d₀:ℤ)*z (e none):ℤ):ℝ)/(N:ℝ))-β|≤C*α ∧ + ∀ i : ι,|(((sourceResidue e r₀ (e (some i))+(d₀:ℤ)*z (e (some i)):ℤ):ℝ)/(N:ℝ))|≤C*α := + Filter.Eventually.of_forall (fun N j => j.property.2.2) + have he := source_box_family_bounded_cube_haar c H S hH Λ σ h01 s hs e cc hsk q hqbound hq hΓ + mtr htop qmtr hqtop μ a hirr d₀ r₀ hd₀ hr₀ β hβ J lo hi hb C hC hgbox + g h hh ρ hρ hg P γ hfactor hperiod L B + intro ε hε + filter_upwards [he ε hε] with α hα + filter_upwards [hα] with N hN + intro l u hside horigin hlocal F hL hB + exact hN ⟨(l,u),hside,horigin,hlocal⟩ F hL hB + +end CubeLocalHaar +end +end + + + +section + +noncomputable section +open scoped Topology BoundedContinuousFunction +namespace CubeLocalHaar +open CubeFaces MeasureTheory +variable {G ι : Type} [Group G] [TopologicalSpace G] [IsTopologicalGroup G] [FirstCountableTopology G] +variable [Fintype ι] [DecidableEq ι] +variable (H : Filtration G) (Λ : Subgroup G) (σ : G) +variable [CompactSpace ((cube H (Finset.univ : Finset ι) 0)⧸cubeLattice H (conjugateLattice Λ σ))] +variable [MeasurableSpace ((cube H (Finset.univ : Finset ι) 0)⧸cubeLattice H (conjugateLattice Λ σ))] +variable [BorelSpace ((cube H (Finset.univ : Finset ι) 0)⧸cubeLattice H (conjugateLattice Λ σ))] +variable [MeasurableSpace (G⧸Λ)] [BorelSpace (G⧸Λ)] +variable [SecondCountableTopology (G⧸Λ)] + + + +omit [CompactSpace ((cube H (Finset.univ : Finset ι) 0)⧸cubeLattice H (conjugateLattice Λ σ))] in +theorem imageProbability_continuous + [CompactSpace ((cube H (Finset.univ : Finset ι) 0)⧸cubeLattice H (conjugateLattice Λ σ))] + (μ : ProbabilityMeasure + ((cube H (Finset.univ : Finset ι) 0)⧸cubeLattice H (conjugateLattice Λ σ))) : + Continuous (imageProbability (ι := ι) H Λ σ μ) := by + apply ProbabilityMeasure.continuous_iff_forall_continuous_integral.mpr + intro F + have he (a : Finset ι→G) : + (∫ y,F y ∂(imageProbability H Λ σ μ a : Measure (Finset ι→G⧸Λ)))= + ∫ x,F (haarImage H Λ σ a x) ∂(μ : Measure _) := by + exact integral_map + (((haarImage_continuous H Λ σ).comp + (continuous_const.prodMk continuous_id)).measurable.aemeasurable) + F.continuous.aestronglyMeasurable + simp_rw [he] + apply continuous_of_dominated (bound := fun _ => ‖F‖) + · intro a + exact (F.continuous.comp ((haarImage_continuous H Λ σ).comp + (continuous_const.prodMk continuous_id))).aestronglyMeasurable + · intro a + exact Filter.Eventually.of_forall (fun x => F.norm_coe_le_norm _) + · exact integrable_const _ + · exact Filter.Eventually.of_forall (fun x => F.continuous.comp + ((haarImage_continuous H Λ σ).comp (continuous_id.prodMk continuous_const))) + +variable [CompactSpace (G⧸Λ)] + + +omit [FirstCountableTopology G] in +theorem haar_image_integral_continuous [FirstCountableTopology G] (μ : ProbabilityMeasure + ((cube H (Finset.univ : Finset ι) 0)⧸cubeLattice H (conjugateLattice Λ σ))) + {X : Type} [TopologicalSpace X] [FirstCountableTopology X] (h : X→G) (hh : Continuous h) + (F : C((Finset ι→G⧸Λ),ℂ)) : + Continuous (fun β => ∫ y,F y ∂(imageProbability H Λ σ μ + (fun _ => h β) : Measure (Finset ι→G⧸Λ))) := by + simp_rw [integral_imageProbability] + apply continuous_of_dominated (bound := fun _ => ‖F‖) + · intro β + exact (frozenTest H Λ σ F (fun _ => h β)).continuous.aestronglyMeasurable + · intro β + exact Filter.Eventually.of_forall (fun x => ContinuousMap.norm_coe_le_norm F _) + · exact integrable_const _ + · refine Filter.Eventually.of_forall (fun x => ?_) + exact F.continuous.comp ((haarImage_continuous H Λ σ).comp + ((continuous_pi (fun _ => hh)).prodMk continuous_const)) + + +theorem haar_image_intervalIntegrable (μ : ProbabilityMeasure + ((cube H (Finset.univ : Finset ι) 0)⧸cubeLattice H (conjugateLattice Λ σ))) + (h : ℝ→G) (hh : Continuous h) (F : C((Finset ι→G⧸Λ),ℂ)) : + IntervalIntegrable (fun β => ∫ y,F y ∂(imageProbability H Λ σ μ + (fun _ => h β) : Measure (Finset ι→G⧸Λ))) volume 0 1 := + (haar_image_integral_continuous H Λ σ μ h hh F).intervalIntegrable 0 1 + +end CubeLocalHaar +end +end + + + +section + +noncomputable section +open scoped BigOperators +namespace CubeLocalHaar +open ComparableBoxLeibman + + + +def physicalResidueRectangle {v : ℕ} (lo hi : Fin v→ℝ) (r : Fin v→ℤ) (d : ℕ) : + Finset (Fin v→ℤ) := + (halfOpenBox v lo hi).filter (fun b => ∀ i,b i%(d:ℤ)=r i) + +lemma physicalResidueRectangle_mem {v : ℕ} (lo hi : Fin v→ℝ) (r : Fin v→ℤ) + (d : ℕ) (b : Fin v→ℤ) : + b∈physicalResidueRectangle lo hi r d ↔ + (∀ i,lo i≤(b i:ℝ) ∧ (b i:ℝ) r i+(d:ℤ)*z i)∈physicalResidueRectangle lo hi r d ↔ + z∈halfOpenBox v (fun i => (lo i-(r i:ℝ))/(d:ℝ)) + (fun i => (hi i-(r i:ℝ))/(d:ℝ)) := by + have hd' : 0<(d:ℝ) := by exact_mod_cast hd + rw [physicalResidueRectangle_mem,mem_halfOpenBox] + have hmod : ∀ i,(r i+(d:ℤ)*z i)%(d:ℤ)=r i := by + intro i + simp only [Int.add_mul_emod_self_left] + exact Int.emod_eq_of_lt (hr i).1 (hr i).2 + simp only [hmod,implies_true,and_true,Int.cast_add,Int.cast_mul,Int.cast_natCast] + apply forall_congr' + intro i + rw [div_le_iff₀ hd',lt_div_iff₀ hd'] + constructor <;> intro h <;> constructor <;> linarith [h.1,h.2] + + +theorem physicalResidueRectangle_expect {v : ℕ} (lo hi : Fin v→ℝ) (r : Fin v→ℤ) + (d : ℕ) (hd : 0 (lo i-(r i:ℝ))/(d:ℝ)) + (fun i => (hi i-(r i:ℝ))/(d:ℝ)),F (fun i => r i+(d:ℤ)*z i)) := by + classical + symm + apply Finset.expect_bij (fun z _ i => r i+(d:ℤ)*z i) + · intro z hz + exact (physicalResidueRectangle_affine lo hi r d hd hr z).mpr hz + · intro z hz + rfl + · intro z₁ hz₁ z₂ hz₂ he + funext i + have hi := congrFun he i + have hdne : (d:ℤ)≠0 := by exact_mod_cast (ne_of_gt hd) + exact mul_left_cancel₀ hdne (add_left_cancel hi) + · intro b hb + let z : Fin v→ℤ := fun i => b i/(d:ℤ) + have he : (fun i => r i+(d:ℤ)*z i)=b := by + funext i + have hh := Int.emod_add_ediv_mul (b i) (d:ℤ) + rw [(physicalResidueRectangle_mem lo hi r d b).mp hb |>.2 i] at hh + simpa only [z,mul_comm] using hh + refine ⟨z,(physicalResidueRectangle_affine lo hi r d hd hr z).mp ?_,he⟩ + rw [he] + exact hb + +end CubeLocalHaar + +end +end +end +end +end + +end OAI diff --git a/lean/OAI/Combinatorics/SumProduct/Alignment/CubeParameter01.lean b/lean/OAI/Combinatorics/SumProduct/Alignment/CubeParameter01.lean new file mode 100644 index 0000000000000000000000000000000000000000..1d516cee3fa2bee03205ee770e7b13794f5fda67 --- /dev/null +++ b/lean/OAI/Combinatorics/SumProduct/Alignment/CubeParameter01.lean @@ -0,0 +1,262 @@ +import Mathlib +import OAI.Combinatorics.SumProduct.Alignment.BooleanRough02 +import OAI.Combinatorics.SumProduct.Alignment.RoughRational01 +import OAI.Geometry.NilpotentCharts.Main + +namespace OAI + +section +noncomputable section +open Finset +open scoped BigOperators +end + +end + + +section + + + +noncomputable section +open Finset +open scoped BigOperators +namespace CubeParameter +open RealPolynomialDegree RoughPolynomialDegree Combinatorics + +def realVertex {n : ℕ} (z : Fin n → Bool) : Fin n → ℝ := fun i => if z i then 1 else 0 + +def vertexSet {n : ℕ} (z : Fin n → Bool) : Finset (Fin n) := univ.filter (fun i => z i) + +lemma mem_vertexSet {n : ℕ} (z : Fin n → Bool) (i : Fin n) : i ∈ vertexSet z ↔ z i := by + simp [vertexSet] + +lemma vertex_to_set {n : ℕ} (z : Fin n → Bool) : + realVertex z = fun i => if i ∈ vertexSet z then 1 else 0 := by + ext i + simp [realVertex, mem_vertexSet] + +lemma realVertex_set {n : ℕ} (S : Finset (Fin n)) : + realVertex (fun i => decide (i ∈ S)) = fun i => if i ∈ S then 1 else 0 := by + ext i + simp [realVertex] + +lemma realVertex_degree {n : ℕ} (f : (Fin n → ℝ) → ℝ) (q : ℕ) (hf : HasDegree f q) : + ∃ θ : Finset (Fin n) → ℝ, BooleanRough.DegreeLE q θ ∧ + ∀ z, BooleanRough.Eval θ (vertexSet z) = f (realVertex z) := by + obtain ⟨p, hp, he⟩ := hf + refine ⟨BooleanRough.BoolCoeffs p, ?_, ?_⟩ + · intro S hS + exact BooleanRough.degree_boolCoeffs p S (by omega) + · intro z + rw [BooleanRough.eval_boolCoeffs, ← vertex_to_set, ← he] + +lemma degree_append {n v : ℕ} (x : Fin v → ℝ) (i : Fin (n+v)) : + HasDegree (fun z : Fin n → ℝ => Fin.append z x i) 1 := by + refine Fin.addCases ?_ ?_ i + · intro j + simpa using coordinate j + · intro j + simpa using RealPolynomialDegree.const (σ:=Fin n) (x j) 1 + +lemma degree_parameter_restrict {n v q : ℕ} {f : (Fin (n+v) → ℝ) → ℝ} + (hf : HasDegree f q) (x : Fin v → ℝ) : + HasDegree (fun z : Fin n → ℝ => f (Fin.append z x)) q := by + simpa using compose hf (fun i z => Fin.append z x i) (degree_append x) + +lemma degree_space_restrict {n v q : ℕ} {f : (Fin (n+v) → ℝ) → ℝ} + (hf : HasDegree f q) (z : Fin n → ℝ) : + HasDegree (fun x : Fin v → ℝ => f (Fin.append z x)) q := by + have hh := compose hf (fun i (x : Fin v → ℝ) => Fin.append z x i) (e:=1) (by + intro i + refine Fin.addCases ?_ ?_ i + · intro j + simpa using RealPolynomialDegree.const (σ:=Fin v) (z j) 1 + · intro j + simpa using coordinate j) + simpa using hh + +def lift {n N v : ℕ} (l : Subspace (Fin n) Bool (Fin N)) + (y : Fin (n+v) → ℝ) : Fin (N+v) → ℝ := + Fin.append (fun i => match l.idxFun i with + | Sum.inl b => if b then 1 else 0 + | Sum.inr j => y (j.castAdd v)) (fun i => y (i.natAdd n)) + +lemma lift_degree {n N v : ℕ} (l : Subspace (Fin n) Bool (Fin N)) (i : Fin (N+v)) : + HasDegree (fun y => lift (v:=v) l y i) 1 := by + refine Fin.addCases ?_ ?_ i + · intro j + simp only [lift, Fin.append_left] + cases hj : l.idxFun j with + | inl b => exact RealPolynomialDegree.const _ _ + | inr k => exact coordinate _ + · intro j + simpa [lift] using coordinate (j.natAdd n) + +lemma lift_vertex {n N v : ℕ} (l : Subspace (Fin n) Bool (Fin N)) + (z : Fin n → Bool) (x : Fin v → ℝ) : + lift l (Fin.append (realVertex z) x) = Fin.append (realVertex (l z)) x := by + ext i + refine Fin.addCases ?_ ?_ i + · intro j + simp only [lift, Fin.append_left, Fin.append_right, realVertex, Subspace.coe_apply] + split <;> rename_i h <;> simp [h] + · intro j + simp [lift] + +lemma degree_lift {n N v q : ℕ} (l : Subspace (Fin n) Bool (Fin N)) + {f : (Fin (N+v) → ℝ) → ℝ} (hf : HasDegree f q) : + HasDegree (fun y : Fin (n+v) → ℝ => f (lift l y)) q := by + simpa using compose hf (fun i y => lift l y i) (lift_degree l) + +lemma vertexSet_decide {n : ℕ} (S : Finset (Fin n)) : + vertexSet (fun i => decide (i ∈ S)) = S := by + ext i + simp [vertexSet] + +def parameterLift {n N : ℕ} (l : Subspace (Fin n) Bool (Fin N)) + (z : Fin n → ℝ) (i : Fin N) : ℝ := + (l.idxFun i).elim (fun b => if b then 1 else 0) z + +lemma parameterLift_degree {n N : ℕ} (l : Subspace (Fin n) Bool (Fin N)) (i : Fin N) : + HasDegree (fun z => parameterLift l z i) 1 := by + unfold parameterLift + cases l.idxFun i with + | inl b => exact RealPolynomialDegree.const _ _ + | inr j => exact coordinate _ + +lemma parameterLift_vertex {n N : ℕ} (l : Subspace (Fin n) Bool (Fin N)) (z : Fin n → Bool) : + parameterLift l (realVertex z) = realVertex (l z) := by + ext i + change (l.idxFun i).elim (fun b => if b then (1 : ℝ) else 0) (fun i => if z i then 1 else 0) = + if (l.idxFun i).elim id z then 1 else 0 + rcases hi : l.idxFun i with b | j <;> rfl + +lemma degree_parameterLift {n N q : ℕ} (l : Subspace (Fin n) Bool (Fin N)) + {f : (Fin N → ℝ) → ℝ} (hf : HasDegree f q) : + HasDegree (fun z => f (parameterLift l z)) q := by + simpa using compose hf (fun i z => parameterLift l z i) (parameterLift_degree l) + +lemma lift_append {n N v : ℕ} (l : Subspace (Fin n) Bool (Fin N)) + (z : Fin n → ℝ) (x : Fin v → ℝ) : + lift l (Fin.append z x) = Fin.append (parameterLift l z) x := by + ext i + refine Fin.addCases ?_ ?_ i + · intro j + simp only [lift, Fin.append_left, parameterLift] + cases l.idxFun j <;> rfl + · intro j + simp [lift] + +end CubeParameter + +end + +end + + +section + + + +noncomputable section +open Finset +open scoped BigOperators +namespace CubeCoefficients +open CubeParameter RealPolynomialDegree RoughPolynomialDegree +open PolynomialLineCoefficients CorrectedBoxLeibman RoughRealCharacterIdentity + + +def coefficients {n v s : ℕ} (f : (Fin (n+v) → ℝ) → ℝ) + (I : PolynomialLineCoefficients.Grid v s) (z : Fin n → ℝ) : ℝ := + ∑ t : PolynomialLineCoefficients.Grid v s, f (Fin.append z (fun i => ((t i).val : ℝ))) * + ∏ i, (realBasis s (t i)).coeff (I i).val + +lemma coefficients_degree {n v s q : ℕ} {f : (Fin (n+v) → ℝ) → ℝ} + (hf : HasDegree f q) (I : PolynomialLineCoefficients.Grid v s) : HasDegree (coefficients (s:=s) f I) q := by + apply finite_sum + intro t _ + simpa only [mul_comm] using RealPolynomialDegree.scale + (degree_parameter_restrict hf (fun i => ((t i).val : ℝ))) + (∏ i, (realBasis s (t i)).coeff (I i).val) + +lemma coefficients_grid_integer {n v s : ℕ} (f : (Fin (n+v) → ℝ) → ℝ) + (z : Fin n → ℝ) + (hf : LinePolynomial v s (fun x => f (Fin.append z (fun i => (x i : ℝ))))) + (x : Fin v → ℤ) : + gridEval (fun I => coefficients (s:=s) f I z) (fun i => (x i : ℝ)) = + f (Fin.append z (fun i => (x i : ℝ))) := by + rw [tensor_interpolation v s _ hf x] + have hexp (t : Fin (s+1)) (y : ℝ) : + (realBasis s t).eval y = ∑ j : Fin (s+1), (realBasis s t).coeff j.val*y^j.val := by + rw [Polynomial.eval_eq_sum_range' (Nat.lt_succ_of_le (realBasis_degree s t))] + exact (Fin.sum_univ_eq_sum_range _ _).symm + simp_rw [hexp, Fintype.prod_sum, Finset.mul_sum] + rw [Finset.sum_comm] + unfold gridEval coefficients + apply Finset.sum_congr rfl + intro I _ + rw [Finset.sum_mul] + apply Finset.sum_congr rfl + intro t _ + rw [Finset.prod_mul_distrib] + push_cast + ring + +lemma coefficients_grid_real {n v s q : ℕ} (f : (Fin (n+v) → ℝ) → ℝ) + (hf : HasDegree f q) (z : Fin n → ℝ) + (hline : LinePolynomial v s (fun x => f (Fin.append z (fun i => (x i : ℝ))))) + (x : Fin v → ℝ) : gridEval (fun I => coefficients (s:=s) f I z) x = f (Fin.append z x) := by + have hleft : HasDegree (fun x => gridEval (fun I => coefficients (s:=s) f I z) x) + (gridMv (fun I => coefficients (s:=s) f I z)).totalDegree := + ⟨gridMv (fun I => coefficients (s:=s) f I z), le_rfl, fun x => (eval_gridMv _ x).symm⟩ + have he := eq_of_integer_agree hleft (degree_space_restrict hf z) + (coefficients_grid_integer f z hline) + exact congrFun he x + +def value {n v s : ℕ} (θ : PolynomialLineCoefficients.Grid v s → (Fin n → ℝ) → ℝ) (y : Fin (n+v) → ℝ) : ℝ := + gridEval (fun I => θ I (fun i => y (i.castAdd v))) (fun i => y (i.natAdd n)) + +lemma value_degree {n v s q : ℕ} (θ : PolynomialLineCoefficients.Grid v s → (Fin n → ℝ) → ℝ) + (hθ : ∀ I, HasDegree (θ I) q) : HasDegree (value θ) (q+v*s) := by + unfold value gridEval + apply finite_sum + intro I _ + have ht : HasDegree (fun y : Fin (n+v) → ℝ => θ I (fun i => y (i.castAdd v))) q := by + simpa using compose (hθ I) (fun i (y : Fin (n+v) → ℝ) => y (i.castAdd v)) (fun i => coordinate _) + have hx : HasDegree (fun y : Fin (n+v) → ℝ => ∏ i, y (i.natAdd n)^(I i).val) + (totalDegree I) := by + simpa only [one_mul, totalDegree] using finite_prod univ + (fun i (y : Fin (n+v) → ℝ) => y (i.natAdd n)^(I i).val) (fun i => 1*(I i).val) + (fun i _ => power (coordinate _) _) + exact RealPolynomialDegree.mono (RealPolynomialDegree.mul ht hx) + (Nat.add_le_add_left (PolynomialLineCoefficients.totalDegree_le I) q) + +lemma value_append {n v s : ℕ} (θ : PolynomialLineCoefficients.Grid v s → (Fin n → ℝ) → ℝ) + (z : Fin n → ℝ) (x : Fin v → ℝ) : value θ (Fin.append z x) = gridEval (fun I => θ I z) x := by + simp [value] + +lemma realize_boolean_rational {n q : ℕ} (f : Finset (Fin n) → ℚ) + (hf : BooleanRough.DegreeLE q f) : + ∃ m : (Fin n → ℝ) → ℝ, HasDegree m q ∧ + ∀ z, m (realVertex z) = ((BooleanRough.Eval f (vertexSet z) : ℚ) : ℝ) := by + let p := BooleanRough.AsPoly (fun S => (f S : ℝ)) + have hp : p.totalDegree ≤ q := BooleanRough.asPoly_degree q _ (by + intro S hS + simp only [hf S hS, Rat.cast_zero]) + refine ⟨fun z => MvPolynomial.eval z p, ⟨p, hp, fun _ => rfl⟩, ?_⟩ + intro z + rw [vertex_to_set] + change MvPolynomial.eval _ (BooleanRough.AsPoly (fun T => (f T : ℝ))) = _ + rw [BooleanRough.eval_asPoly] + simp only [BooleanRough.Eval, Rat.cast_sum] + +end CubeCoefficients + +end + +end + + + +end OAI diff --git a/lean/OAI/Combinatorics/SumProduct/Alignment/CubePolynomials01.lean b/lean/OAI/Combinatorics/SumProduct/Alignment/CubePolynomials01.lean new file mode 100644 index 0000000000000000000000000000000000000000..c8eebf1a69c12248b1533c7fa323d6642510bc34 --- /dev/null +++ b/lean/OAI/Combinatorics/SumProduct/Alignment/CubePolynomials01.lean @@ -0,0 +1,445 @@ +import Mathlib +import OAI.Combinatorics.SumProduct.Alignment.CubeFaces01 +import OAI.Combinatorics.SumProduct.Alignment.LeibmanSquare01 +import OAI.Geometry.NilpotentCharts.Main + +namespace OAI + +section +section +section +section +open scoped commutatorElement Pointwise +namespace CubePolynomials + +variable {A : Type*} [AddCommGroup A] +open CubeFaces +noncomputable section +variable {G : Type*} [Group G] + +def pattern (I : Finset ℕ) (h : ℕ → A) (n : A) : (A → G) →* (Finset ℕ → G) where + toFun f v := f (n + ∑ i ∈ v ∩ I, h i) + map_one' := rfl + map_mul' _ _ := rfl + +def polynomials (H : Filtration G) (k : ℕ) : Subgroup (A → G) := + ⨅ (I : Finset ℕ) (h : ℕ → A) (n : A), (cube H I k).comap (pattern I h n) + +lemma mem_polynomials (H : Filtration G) (k : ℕ) (f : A → G) : + f ∈ polynomials H k ↔ ∀ I h n, pattern I h n f ∈ cube H I k := by + simp [polynomials] + +lemma polynomials_antitone (H : Filtration G) : Antitone (polynomials (A := A) H) := by + intro i j hij f hf + rw [mem_polynomials] at hf ⊢ + intro I h n + exact cube_shift_le H I hij (hf I h n) + +lemma eval_mem {H : Filtration G} {k : ℕ} {f : A → G} + (hf : f ∈ polynomials H k) (n : A) : f n ∈ H.level k := by + have h := (mem_polynomials H k f).mp hf ∅ (fun _ => 0) n + simpa [pattern] using cube_eval_mem H h ∅ + +lemma const_mem {H : Filtration G} {k : ℕ} {g : G} (hg : g ∈ H.level k) : + (fun _ : A => g) ∈ polynomials H k := by + rw [mem_polynomials] + intro I h n + have he : pattern I h n (fun _ : A => g) = face ∅ g := by ext v; simp [pattern, face] + rw [he] + exact face_mem_cube H (Finset.empty_subset I) (by simpa using hg) + +lemma polynomials_eq_bot {H : Filtration G} {k : ℕ} (hk : H.level k = ⊥) : + polynomials (A := A) H k = ⊥ := by + apply le_antisymm _ bot_le + intro f hf + apply Subgroup.mem_bot.mpr + funext n + have h := eval_mem hf n + simpa [hk] using h + +def shift (t : A) : (A → G) ≃* (A → G) where + toFun f n := f (n+t) + invFun f n := f (n-t) + left_inv f := by ext n; simp + right_inv f := by ext n; simp + map_mul' _ _ := rfl + +lemma shift_mem {H : Filtration G} {k : ℕ} {f : A → G} + (hf : f ∈ polynomials H k) (t : A) : shift t f ∈ polynomials H k := by + rw [mem_polynomials] at hf ⊢ + intro I h n + convert hf I h (n+t) using 1 + ext v + change f ((n + ∑ i ∈ v ∩ I, h i) + t) = f ((n+t) + ∑ i ∈ v ∩ I, h i) + congr 1 + abel + +lemma derivative_mem {H : Filtration G} {k : ℕ} {f : A → G} + (hf : f ∈ polynomials H k) (t : A) : f⁻¹ * shift t f ∈ polynomials H (k+1) := by + rw [mem_polynomials] at hf ⊢ + intro I h n + let a := I.sup id + 1 + have ha : a ∉ I := by + intro ha + have hle : a ≤ I.sup id := Finset.le_sup (f := id) ha + dsimp [a] at hle + omega + let h' := Function.update h a t + have hcube := hf (insert a I) h' n + obtain ⟨l,hl,u,hu,he⟩ := cube_decompose H a I k hcube + have heq : pattern I h n (f⁻¹ * shift t f) = u := by + funext v + let V := v ∩ I + have hVI : V ⊆ I := Finset.inter_subset_right + have haV : a ∉ V := fun h => ha (hVI h) + have hs : ∑ j ∈ V, h' j = ∑ j ∈ V, h j := by + apply Finset.sum_congr rfl + intro j hj + have hjne : j ≠ a := by rintro rfl; exact haV hj + exact Function.update_of_ne hjne t h + have hVa : V ∩ insert a I = V := Finset.inter_eq_left.mpr (hVI.trans (Finset.subset_insert a I)) + have hVai : insert a V ∩ insert a I = insert a V := + Finset.inter_eq_left.mpr (Finset.insert_subset_insert a hVI) + have hlo := congrFun he V + have hhi := congrFun he (insert a V) + change f (n + ∑ j ∈ V ∩ insert a I, h' j) = l V * (if a ∈ V then u V else 1) at hlo + change f (n + ∑ j ∈ insert a V ∩ insert a I, h' j) = + l (insert a V) * (if a ∈ insert a V then u (insert a V) else 1) at hhi + simp only [hVa, haV, ite_false, mul_one, hs] at hlo + simp only [hVai, Finset.mem_insert_self, ite_true, + cube_insert_irrelevant H ha hl, cube_insert_irrelevant H ha hu, + Finset.sum_insert haV, show h' a = t from Function.update_self a t h, hs] at hhi + change (f (n + ∑ j ∈ V, h j))⁻¹ * f ((n + ∑ j ∈ V, h j) + t) = u v + rw [show (n + ∑ j ∈ V, h j) + t = n + (t + ∑ j ∈ V, h j) by abel, + hlo, hhi, inv_mul_cancel_left] + exact cube_restrict H hu v + rw [heq] + exact hu + + + +lemma mem_of_derivatives {H : Filtration G} {k : ℕ} {f : A → G} + (hvalue : ∀ n, f n ∈ H.level k) + (hd : ∀ t, f⁻¹ * shift t f ∈ polynomials H (k+1)) : f ∈ polynomials H k := by + rw [mem_polynomials] + intro I + induction I using Finset.induction_on with + | empty => + intro h n + have he : pattern ∅ h n f = face ∅ (f n) := by ext v; simp [pattern, face] + rw [he] + exact face_mem_cube H (Finset.empty_subset ∅) (by simpa using hvalue n) + | @insert a I ha ih => + intro h n + let l := pattern I h n f + let u := pattern I h n (f⁻¹ * shift (h a) f) + have hl : l ∈ cube H I k := ih h n + have hu : u ∈ cube H I (k+1) := (mem_polynomials H (k+1) _).mp (hd (h a)) I h n + have he : pattern (insert a I) h n f = l * upper a u := by + funext v + have haV : a ∉ v ∩ I := fun hh => ha (Finset.mem_inter.mp hh).2 + by_cases hav : a ∈ v + · have hv : v ∩ insert a I = insert a (v ∩ I) := by + ext b + simp only [Finset.mem_inter, Finset.mem_insert] + aesop + change f (n + ∑ i ∈ v ∩ insert a I, h i) = + f (n + ∑ i ∈ v ∩ I, h i) * (if a ∈ v then + (f (n + ∑ i ∈ v ∩ I, h i))⁻¹ * f ((n + ∑ i ∈ v ∩ I, h i) + h a) else 1) + rw [hv, Finset.sum_insert haV, ite_eq_left hav, mul_inv_cancel_left] + congr 1 + abel + · have hv : v ∩ insert a I = v ∩ I := by + ext b + simp only [Finset.mem_inter, Finset.mem_insert] + aesop + change f (n + ∑ i ∈ v ∩ insert a I, h i) = + f (n + ∑ i ∈ v ∩ I, h i) * (if a ∈ v then u v else 1) + rw [hv, ite_eq_right hav, mul_one] + rw [he] + exact (cube H (insert a I) k).mul_mem + (cube_mono H (Finset.subset_insert a I) k hl) (upper_cube_mem H ha k hu) + +end +end CubePolynomials + +end + + + +section +open scoped commutatorElement +namespace CubePolynomials +open CubeFaces +noncomputable section +variable {G : Type*} [Group G] +lemma commutator_mem {H : Filtration G} {i j : ℕ} {f g : ℤ → G} + (hf : f ∈ polynomials H i) (hg : g ∈ polynomials H j) : + ⁅f,g⁆ ∈ polynomials H (i+j) := by + rw [mem_polynomials] at hf hg ⊢ + intro I h n + rw [map_commutatorElement] + exact cube_commutator_mem H I (hf I h n) (hg I h n) + +lemma normalizes (H : Filtration G) (k : ℕ) : + polynomials (A := ℤ) H 0 ≤ (Subgroup.normalizer (polynomials (A := ℤ) H k)) := by + intro f hf + apply Subgroup.mem_normalizer_iff.mpr + intro g + have hconj {f : ℤ → G} (hf : f ∈ polynomials H 0) {g : ℤ → G} + (hg : g ∈ polynomials H k) : f*g*f⁻¹ ∈ polynomials H k := by + have hc : ⁅f,g⁆ ∈ polynomials H k := by simpa using commutator_mem hf hg + have he : f*g*f⁻¹ = ⁅f,g⁆ * g := by simp [commutatorElement_def, mul_assoc] + rw [he] + exact (polynomials H k).mul_mem hc hg + constructor + · exact hconj hf + · intro hg + have hh := hconj ((polynomials H 0).inv_mem hf) hg + simpa [mul_assoc] using hh + +open Polynomial in +lemma power_polynomial_mem {H : Filtration G} (e k : ℕ) (a : G) + (ha : a ∈ H.level (e+k)) (p : ℤ[X]) (hp : p.natDegree ≤ e) : + (fun n : ℤ => a ^ p.eval n) ∈ polynomials H k := by + induction e generalizing k p with + | zero => + have he : p = C (p.coeff 0) := eq_C_of_natDegree_eq_zero (Nat.eq_zero_of_le_zero hp) + rw [he] + simp only [eval_C] + apply const_mem + simpa only [Nat.zero_add] using (H.level (0+k)).zpow_mem ha (p.coeff 0) + | succ e ih => + apply mem_of_derivatives + · intro n + exact (H.level k).zpow_mem (H.antitone (Nat.le_add_left k (e+1)) ha) _ + · intro t + let q := taylor t p - p + have hq : q.natDegree ≤ e := by + by_cases hp0 : p = 0 + · simp [q,hp0] + by_cases hq0 : q = 0 + · simp [hq0] + have hd : q.degree < p.degree := + degree_sub_lt_right (degree_taylor p t) hp0 (leadingCoeff_taylor t p) + have hd' : q.natDegree < p.natDegree := (natDegree_lt_natDegree_iff hq0).mpr hd + omega + have ha' : a ∈ H.level (e+(k+1)) := by simpa only [Nat.add_assoc, Nat.add_comm, + Nat.add_left_comm] using ha + have h := ih (k+1) ha' q hq + convert h using 1 + funext n + change (a ^ p.eval n)⁻¹ * a ^ p.eval (n+t) = a ^ q.eval n + rw [← zpow_neg, ← zpow_add] + congr 1 + simp [q, taylor_apply, eval_comp] + ring + +end + +end CubePolynomials +namespace NilpotentTaylor +open CubeFaces CubePolynomials +open scoped BigOperators +noncomputable section +variable {G : Type*} [Group G] + + +lemma all_derivatives_of_unit {H : Filtration G} {k : ℕ} {f : ℤ → G} + (hf : f⁻¹ * shift 1 f ∈ polynomials H k) : + ∀ t : ℤ, f⁻¹ * shift t f ∈ polynomials H k := by + let S : AddSubgroup ℤ := + { carrier := {t | f⁻¹ * shift t f ∈ polynomials H k} + zero_mem' := by + change f⁻¹ * shift 0 f ∈ polynomials H k + have he : f⁻¹ * shift 0 f = 1 := by ext n; simp [shift] + rw [he] + exact (polynomials H k).one_mem + add_mem' := by + intro u v hu hv + change f⁻¹ * shift (u+v) f ∈ polynomials H k + have he : f⁻¹ * shift (u+v) f = (f⁻¹ * shift u f) * + shift u (f⁻¹ * shift v f) := by + ext n + change (f n)⁻¹ * f (n+(u+v)) = + ((f n)⁻¹ * f (n+u)) * ((f (n+u))⁻¹ * f ((n+u)+v)) + rw [add_assoc] + group + rw [he] + exact (polynomials H k).mul_mem hu (shift_mem hv u) + neg_mem' := by + intro u hu + change f⁻¹ * shift (-u) f ∈ polynomials H k + have he : f⁻¹ * shift (-u) f = (shift (-u) (f⁻¹ * shift u f))⁻¹ := by + ext n + simp [shift] + rw [he] + exact (polynomials H k).inv_mem (shift_mem hu (-u)) } + intro t + have h1 : (1 : ℤ) ∈ S := hf + change t ∈ S + simpa using S.zsmul_mem h1 t + +lemma mem_of_unit_derivative {H : Filtration G} {k : ℕ} {f : ℤ → G} + (hvalue : ∀ n, f n ∈ H.level k) + (hd : f⁻¹ * shift 1 f ∈ polynomials H (k+1)) : f ∈ polynomials H k := + mem_of_derivatives hvalue (all_derivatives_of_unit hd) + + +lemma binomial_mem {H : Filtration G} (d k : ℕ) (a : G) + (ha : a ∈ H.level (d+k)) : + (fun n : ℤ => a ^ Ring.choose n d) ∈ polynomials H k := by + induction d generalizing k with + | zero => + simpa only [Ring.choose_zero_right, zpow_one, Nat.zero_add] using + (const_mem (k := k) (by simpa using ha)) + | succ d ih => + apply mem_of_unit_derivative + · intro n + exact (H.level k).zpow_mem (H.antitone (by omega) ha) _ + · have ha' : a ∈ H.level (d+(k+1)) := by simpa only [Nat.add_assoc, Nat.add_comm, Nat.add_left_comm] using ha + have h := ih (k+1) ha' + convert h using 1 + ext n + change (a ^ Ring.choose n (d+1))⁻¹ * a ^ Ring.choose (n+1) (d+1) = + a ^ Ring.choose n d + rw [Ring.choose_succ_succ, ← zpow_neg, ← zpow_add] + congr 1 + omega + + + +lemma initial_value_mem {H : Filtration G} {k : ℕ} {f : ℤ → G} + (hf : f ∈ polynomials H k) (d : ℕ) + (hz : ∀ n < d, f (n : ℤ) = 1) : f (d : ℤ) ∈ H.level (d+k) := by + induction d generalizing k f with + | zero => simpa using eval_mem hf 0 + | succ d ih => + have hd := derivative_mem hf 1 + have hz' : ∀ n < d, (f⁻¹ * shift 1 f) (n : ℤ) = 1 := by + intro n hn + change (f (n : ℤ))⁻¹ * f ((n : ℤ)+1) = 1 + rw [hz n (by omega), ← Nat.cast_add_one, hz (n+1) (by omega)] + simp + have h := ih hd hz' + change (f (d : ℤ))⁻¹ * f ((d : ℤ)+1) ∈ H.level (d+(k+1)) at h + rw [hz d (by omega), inv_one, one_mul, ← Nat.cast_add_one] at h + simpa only [Nat.add_assoc, Nat.add_comm, Nat.add_left_comm] using h + +lemma zero_of_initial {H : Filtration G} {k d : ℕ} {f : ℤ → G} + (hterm : H.level (d+k) = ⊥) (hf : f ∈ polynomials H k) + (hz : ∀ n < d, f (n : ℤ) = 1) : f = 1 := by + induction d generalizing k f with + | zero => + ext n + have h := eval_mem hf n + simpa [show H.level k = ⊥ by simpa using hterm] using h + | succ d ih => + have hd := derivative_mem hf 1 + have hz' : ∀ n < d, (f⁻¹ * shift 1 f) (n : ℤ) = 1 := by + intro n hn + change (f (n : ℤ))⁻¹ * f ((n : ℤ)+1) = 1 + rw [hz n (by omega), ← Nat.cast_add_one, hz (n+1) (by omega)] + simp + have hterm' : H.level (d+(k+1)) = ⊥ := by simpa only [Nat.add_assoc, Nat.add_comm, Nat.add_left_comm] using hterm + have he := ih hterm' hd hz' + have hstep (n : ℤ) : f (n+1) = f n := by + have h := congrFun he n + change (f n)⁻¹ * f (n+1) = 1 at h + exact (inv_mul_eq_one.mp h).symm + ext n + change f n = 1 + have hp : Function.Periodic f 1 := hstep + have hn : f n = f 0 := by simpa using hp.int_mul n 0 + exact hn.trans (hz 0 (by omega)) + + + +theorem determined_by_initial {H : Filtration G} {k d : ℕ} {f g : ℤ → G} + (hterm : H.level (d+k) = ⊥) + (hf : f ∈ polynomials H k) (hg : g ∈ polynomials H k) + (he : ∀ n < d, f (n : ℤ) = g n) : f = g := by + have hz : f⁻¹ * g = 1 := zero_of_initial hterm + ((polynomials H k).mul_mem ((polynomials H k).inv_mem hf) hg) (by + intro n hn + change (f (n : ℤ))⁻¹ * g (n : ℤ) = 1 + rw [he n hn, inv_mul_cancel]) + exact inv_mul_eq_one.mp hz + + +def word (a : ℕ → G) : ℕ → (ℤ → G) + | 0 => 1 + | d+1 => word a d * fun n : ℤ => a d ^ Ring.choose n d + +lemma word_mem {H : Filtration G} {k : ℕ} (a : ℕ → G) (d : ℕ) + (ha : ∀ j < d, a j ∈ H.level (j+k)) : word a d ∈ polynomials H k := by + induction d with + | zero => exact (polynomials H k).one_mem + | succ d ih => + exact (polynomials H k).mul_mem (ih (fun j hj => ha j (by omega))) + (binomial_mem d k (a d) (ha d (by omega))) + +lemma word_congr {a b : ℕ → G} (d : ℕ) (hab : ∀ j < d, a j = b j) : + word a d = word b d := by + induction d with + | zero => rfl + | succ d ih => + rw [word,word, ih (fun j hj => hab j (by omega)),hab d (by omega)] + +lemma word_update (a : ℕ → G) (d : ℕ) (g : G) : + word (Function.update a d g) d = word a d := by + apply word_congr + intro j hj + exact Function.update_of_ne (show j ≠ d by omega) g a + +lemma partial_taylor {H : Filtration G} {k : ℕ} {f : ℤ → G} + (hf : f ∈ polynomials H k) (d : ℕ) : + ∃ a : ℕ → G, (∀ j < d, a j ∈ H.level (j+k)) ∧ + ∀ n < d, word a d (n : ℤ) = f n := by + induction d with + | zero => exact ⟨fun _ => 1,by simp,by simp⟩ + | succ d ih => + obtain ⟨a,ha,he⟩ := ih + let r : ℤ → G := (word a d)⁻¹ * f + have hr : r ∈ polynomials H k := + (polynomials H k).mul_mem ((polynomials H k).inv_mem (word_mem a d ha)) hf + have hz : ∀ n < d, r (n : ℤ) = 1 := by + intro n hn + change (word a d (n : ℤ))⁻¹ * f (n : ℤ) = 1 + rw [he n hn,inv_mul_cancel] + have hg : r (d : ℤ) ∈ H.level (d+k) := initial_value_mem hr d hz + refine ⟨Function.update a d (r d),?_,?_⟩ + · intro j hj + by_cases h : j = d + · simpa [h] using hg + · rw [Function.update_of_ne h] + exact ha j (by omega) + · intro n hn + change (word (Function.update a d (r d)) d (n : ℤ)) * + (Function.update a d (r d) d) ^ Ring.choose (n : ℤ) d = f n + rw [word_update,Function.update_self,Ring.choose_natCast] + by_cases h : n = d + · subst n + rw [Nat.choose_self,Nat.cast_one,zpow_one] + change word a d (d : ℤ) * ((word a d (d : ℤ))⁻¹ * f d) = f d + group + · rw [Nat.choose_eq_zero_of_lt (by omega : n < d),Nat.cast_zero,zpow_zero,mul_one] + exact he n (by omega) + + + +theorem exists_taylor {H : Filtration G} {k d : ℕ} {f : ℤ → G} + (hterm : H.level (d+k) = ⊥) (hf : f ∈ polynomials H k) : + ∃ a : ℕ → G, (∀ j < d, a j ∈ H.level (j+k)) ∧ f = word a d := by + obtain ⟨a,ha,he⟩ := partial_taylor hf d + exact ⟨a,ha,determined_by_initial hterm hf (word_mem a d ha) (fun n hn => (he n hn).symm)⟩ + +end +end NilpotentTaylor + +end +end +end +end + +end OAI diff --git a/lean/OAI/Combinatorics/SumProduct/Alignment/CubeRational01.lean b/lean/OAI/Combinatorics/SumProduct/Alignment/CubeRational01.lean new file mode 100644 index 0000000000000000000000000000000000000000..8298d4a79fbb3f05308a7a093e1909b1408b46a0 --- /dev/null +++ b/lean/OAI/Combinatorics/SumProduct/Alignment/CubeRational01.lean @@ -0,0 +1,1100 @@ +import Mathlib +import OAI.Combinatorics.SumProduct.Alignment.ComparableBox03 +import OAI.Geometry.NilpotentCharts.Main + +namespace OAI + +open scoped BigOperators +section +section +noncomputable section +open scoped BigOperators Topology commutatorElement +end +end + +section +noncomputable section +open scoped BigOperators Topology commutatorElement +namespace CubeLocalHaar +open CubeFaces LeibmanSquare CubeTaylorExpansion CubeHorizontalIrrationality +open RationalLattice MeasureTheory Filter ComparableBoxLeibman MalcevCharacters AbelianMalcevTorus +variable {G ι : Type} [Group G] [TopologicalSpace G] [IsTopologicalGroup G] +variable [Fintype ι] [DecidableEq ι] +variable {n t d v : ℕ} (c : RealCoordinates G n) (H : Filtration G) +variable (S : ℕ→Set (Fin n)) +variable (hH : ∀ k (g : G),g∈H.level k ↔ ∀ i∈S k,c.coord g i=0) +variable (Γ : Subgroup G) (h01 : H.level 0=H.level 1) +variable (s : ℕ) (hs : H.level (s+1)=⊥) (e : Option ι≃Fin v) +variable (cc : RealCoordinates (cube H (Finset.univ : Finset ι) 0) (t+d)) +variable (hsk : SecondKind cc) +variable (q : ℕ→ℕ) (hqbound : ∀ k,q k ≤ t+d) +variable (hq : ∀ k (g : cube H (Finset.univ : Finset ι) 0), + g∈(CubeMaxFiltration.filtration H Finset.univ).level k ↔ + ∀ i : Fin (t+d),i.val < q k → cc.coord g i=0) +variable (hΓ : ∀ g : cube H (Finset.univ : Finset ι) 0, + g∈cubeLattice H Γ ↔ ∀ i,∃ z : ℤ,cc.coord g i=z) +variable [MeasurableSpace ((cube H (Finset.univ : Finset ι) 0)⧸cubeLattice H Γ)] +variable [hBorel : @BorelSpace ((cube H (Finset.univ : Finset ι) 0)⧸cubeLattice H Γ) (QuotientGroup.instTopologicalSpace (cubeLattice H Γ)) inferInstance] +variable [mtr : MetricSpace ((cube H (Finset.univ : Finset ι) 0)⧸cubeLattice H Γ)] +variable (htop : mtr.toUniformSpace.toTopologicalSpace=QuotientGroup.instTopologicalSpace (cubeLattice H Γ)) +local instance : TopologicalSpace ((cube H (Finset.univ : Finset ι) 0)⧸cubeLattice H Γ) := + mtr.toUniformSpace.toTopologicalSpace + +include h01 hs hsk hqbound hq hΓ htop in + + +theorem haar_limit_scaled + (L : ℕ→ℝ) (hL : Tendsto L atTop atTop) + (μ : Measure ((cube H (Finset.univ : Finset ι) 0)⧸cubeLattice H Γ)) + [IsProbabilityMeasure μ] + [SMulInvariantMeasure (cube H (Finset.univ : Finset ι) 0) _ μ] + (a : ℕ→∀ k : ℕ,H.level k) + (hirr : ∀ j : ℕ,0 < j → j ≤ s → ∀ ξ : H.level j→*Multiplicative ℝ, + ξ≠1 → Continuous ξ → RationalCharacter Γ ξ → + (∀ x (hx : x∈H.level (j+1)),ξ ⟨x,H.antitone (Nat.le_succ _) hx⟩=1) → + (∀ i k : ℕ,0 < i → 0 < k → ∀ h : i+k=j, + ∀ x (hx : x∈H.level i) y (hy : y∈H.level k), + ξ ⟨⁅x,y⁆,by rw [←h]; exact H.commutator_le i k (Subgroup.commutator_mem_commutator hx hy)⟩=1) → + Tendsto (fun N : ℕ => ‖((ξ (a N j)).toAdd:UnitAddCircle)‖*(L N)^j) + atTop atTop) + (c₀ C₀ : ℝ) (B : NNReal) (hc₀ : 0 ((r (e i)+(d₀:ℤ)*x (e i):ℤ):ℝ)))))-(∫ y,F y ∂μ)‖<η := by + let K := CubeMaxFiltration.filtration H (Finset.univ : Finset ι) + have hK0 : K.level 0=⊤ := CubeMaxFiltration.filtration_zero H Finset.univ + have hK1 : K.level 1=⊤ := CubeMaxFiltration.filtration_one H Finset.univ h01 + let : ∀ k,(K.level k).Normal := fun k => LeibmanSquare.level_normal K hK0 k + let φ : (Fin v→ℤ)→+(Option ι→ℝ) := + { toFun := fun x i => (x (e i):ℝ) + map_zero' := by ext; simp + map_add' := by intros; ext; simp } + let f (N : ℕ) (x : Fin v→ℤ) := cubePolynomial c H S hH (a N) s (φ x) + have hf (N : ℕ) : LeibmanSquare.Polynomial K 0 (f N) := + polynomial_comp K (cubePolynomial_adapted c H S hH (a N) s) φ + exact haar_limit_fixed_progression_scaled cc hsk K hK0 hK1 s + (CubeMaxFiltration.filtration_bot H Finset.univ hs) q hqbound hq + (cubeLattice H Γ) hΓ htop L hL μ v f hf + (fun χ hn hc hχΓ => grid_irrationality_scaled L c H S hH Γ h01 s hs e a hirr χ hn hc hχΓ) + c₀ C₀ B hc₀ hC₀ hB d₀ hd₀ r + +end CubeLocalHaar +end +end + +end + +section + + +section +noncomputable section +open scoped BigOperators Topology commutatorElement +namespace CubeLocalHaar +open CubeFaces LeibmanSquare CubeTaylorExpansion CubeHorizontalIrrationality +open RationalLattice MeasureTheory Filter ComparableBoxLeibman MalcevCharacters AbelianMalcevTorus +variable {G ι : Type} [Group G] [TopologicalSpace G] [IsTopologicalGroup G] +variable [Fintype ι] [DecidableEq ι] +variable {n t d v : ℕ} (c : RealCoordinates G n) (H : Filtration G) +variable (S : ℕ→Set (Fin n)) +variable (hH : ∀ k (g : G),g∈H.level k ↔ ∀ i∈S k,c.coord g i=0) +variable (Γ : Subgroup G) (h01 : H.level 0=H.level 1) +variable (s : ℕ) (hs : H.level (s+1)=⊥) (e : Option ι≃Fin v) +variable (cc : RealCoordinates (cube H (Finset.univ : Finset ι) 0) (t+d)) +variable (hsk : SecondKind cc) +variable (q : ℕ→ℕ) (hqbound : ∀ k,q k ≤ t+d) +variable (hq : ∀ k (g : cube H (Finset.univ : Finset ι) 0), + g∈(CubeMaxFiltration.filtration H Finset.univ).level k ↔ + ∀ i : Fin (t+d),i.val < q k → cc.coord g i=0) +variable (hΓ : ∀ g : cube H (Finset.univ : Finset ι) 0, + g∈cubeLattice H Γ ↔ ∀ i,∃ z : ℤ,cc.coord g i=z) +variable [MeasurableSpace ((cube H (Finset.univ : Finset ι) 0)⧸cubeLattice H Γ)] +variable [hBorel : @BorelSpace ((cube H (Finset.univ : Finset ι) 0)⧸cubeLattice H Γ) (QuotientGroup.instTopologicalSpace (cubeLattice H Γ)) inferInstance] +variable [mtr : MetricSpace ((cube H (Finset.univ : Finset ι) 0)⧸cubeLattice H Γ)] +variable (htop : mtr.toUniformSpace.toTopologicalSpace=QuotientGroup.instTopologicalSpace (cubeLattice H Γ)) +local instance scaledCompactCubeTopology : TopologicalSpace ((cube H (Finset.univ : Finset ι) 0)⧸cubeLattice H Γ) := + mtr.toUniformSpace.toTopologicalSpace + +include h01 hs hsk hqbound hq hΓ htop in + + +theorem haar_limit_compact_scaled + (L : ℕ→ℝ) (hL : Tendsto L atTop atTop) + (μ : Measure ((cube H (Finset.univ : Finset ι) 0)⧸cubeLattice H Γ)) + [IsProbabilityMeasure μ] + [SMulInvariantMeasure (cube H (Finset.univ : Finset ι) 0) _ μ] + (a : ℕ→∀ k : ℕ,H.level k) + (hirr : ∀ j : ℕ,0 < j → j ≤ s → ∀ ξ : H.level j→*Multiplicative ℝ, + ξ≠1 → Continuous ξ → RationalCharacter Γ ξ → + (∀ x (hx : x∈H.level (j+1)),ξ ⟨x,H.antitone (Nat.le_succ _) hx⟩=1) → + (∀ i k : ℕ,0 < i → 0 < k → ∀ h : i+k=j, + ∀ x (hx : x∈H.level i) y (hy : y∈H.level k), + ξ ⟨⁅x,y⁆,by rw [←h]; exact H.commutator_le i k (Subgroup.commutator_mem_commutator hx hy)⟩=1) → + Tendsto (fun N : ℕ => ‖((ξ (a N j)).toAdd:UnitAddCircle)‖*(L N)^j) + atTop atTop) + (c₀ C₀ : ℝ) (hc₀ : 0 ((r (e i)+(d₀:ℤ)*x (e i):ℤ):ℝ)))))-(∫ y,F y ∂μ)‖<η := by + let : CompactSpace ((cube H (Finset.univ : Finset ι) 0)⧸cubeLattice H Γ) := + metric_compact cc (cubeLattice H Γ) hΓ mtr htop + let : BorelSpace ((cube H (Finset.univ : Finset ι) 0)⧸cubeLattice H Γ) := + metric_borelSpace (cubeLattice H Γ) mtr htop + intro η hη + obtain ⟨δ,hδ,htest⟩ := FiniteHaarTests.compact_tests (κ := Fin v→ℤ) μ K hK η hη + have hh := haar_limit_scaled c H S hH Γ h01 s hs e cc hsk q hqbound hq hΓ htop L hL μ a hirr + c₀ C₀ 1 hc₀ hC₀ (by norm_num) d₀ hd₀ r δ hδ + filter_upwards [hh] with N hN + intro lo hi hlo hhi F hF + apply htest (integerBox v lo hi) + (fun x => QuotientGroup.mk (cubePolynomial c H S hH (a N) s + (fun i => ((r (e i)+(d₀:ℤ)*x (e i):ℤ):ℝ)))) _ F hF + intro φ hφ hφn + exact hN lo hi hlo hhi φ hφ hφn + +end CubeLocalHaar +end +end + +end + +section + + + + +noncomputable section +open scoped BigOperators Topology +namespace CubeRationalCharts +open CubeFaces +variable {G ι : Type} [Group G] [DecidableEq ι] + + +theorem cube_corner_mem (H : Filtration G) (I : Finset ι) (k : ℕ) + {f : Finset ι → G} (hf : f ∈ cube H I k) (Γ : Subgroup G) + (hv : ∀ v, v ⊂ I → f v ∈ Γ) (hlevel : H.level (I.card + k) ≤ Γ) : + f I ∈ Γ := by + induction I using Finset.induction_on generalizing k f with + | empty => + exact hlevel (by simpa using cube_eval_mem H hf ∅) + | @insert a I ha ih => + obtain ⟨l, hl, u, hu, rfl⟩ := cube_decompose H a I k hf + have hnot (v : Finset ι) (hvI : v ⊆ I) : a ∉ v := fun hav => ha (hvI hav) + have hlv (v : Finset ι) (hvI : v ⊆ I) : l v ∈ Γ := by + have hproper : v ⊂ insert a I := by + refine Finset.ssubset_iff_subset_ne.mpr ⟨hvI.trans (Finset.subset_insert a I), ?_⟩ + intro he + exact hnot v hvI (he.symm ▸ Finset.mem_insert_self a I) + simpa [upper, hnot v hvI] using hv v hproper + have huv (v : Finset ι) (hvI : v ⊂ I) : u v ∈ Γ := by + have hproper : insert a v ⊂ insert a I := by + exact Finset.ssubset_iff_subset_ne.mpr ⟨Finset.insert_subset_insert a hvI.subset, + fun he => hvI.ne (by simpa [ha, hnot v hvI.subset] using congrArg (fun s => s.erase a) he)⟩ + have hm := hv (insert a v) hproper + simp only [Pi.mul_apply, upper, MonoidHom.coe_mk, OneHom.coe_mk, + Finset.mem_insert_self, ite_true] at hm + rw [cube_insert_irrelevant H ha hl, cube_insert_irrelevant H ha hu] at hm + exact (Γ.mul_mem_cancel_left (hlv v hvI.subset)).mp hm + have huI : u I ∈ Γ := ih (k + 1) hu huv (by + simpa [Finset.card_insert_of_notMem ha, Nat.add_assoc, Nat.add_comm, + Nat.add_left_comm] using hlevel) + simpa [upper, cube_insert_irrelevant H ha hl, cube_insert_irrelevant H ha hu] using + Γ.mul_mem (hlv I le_rfl) huI + + +def restrict (D : Finset ι) : (Finset ι → G) →* (Finset ι → G) where + toFun f v := f (v ∩ D) + map_one' := rfl + map_mul' _ _ := rfl + +lemma restrict_mem (H : Filtration G) {I : Finset ι} {k : ℕ} + {f : Finset ι → G} (hf : f ∈ cube H I k) (D : Finset ι) : + restrict D f ∈ cube H D k := by + have hle : cube H I k ≤ (cube H D k).comap (restrict D) := by + refine iSup_le fun E => iSup_le fun hE => ?_ + rintro f ⟨g,hg,rfl⟩ + change restrict D (face E g) ∈ cube H D k + by_cases hED : E ⊆ D + · have he : restrict D (face E g) = face E g := by + funext v + simp [restrict,face_apply,Finset.subset_inter_iff,hED] + rw [he] + exact face_mem_cube H hED hg + · have he : restrict D (face E g) = 1 := by + funext v + simp [restrict,face_apply,Finset.subset_inter_iff,hED] + rw [he] + exact (cube H D k).one_mem + exact hle hf + +lemma supported_value_mem (H : Filtration G) {I D : Finset ι} {k : ℕ} + {f : Finset ι → G} (hf : f ∈ cube H I k) + (hv : ∀ E, E ⊂ D → f E = 1) : f D ∈ H.level (D.card+k) := by + have hh := cube_corner_mem H D k (restrict_mem H hf D) (H.level (D.card+k)) + (fun E hE => by + change f (E ∩ D) ∈ H.level (D.card+k) + rw [Finset.inter_eq_left.mpr hE.subset,hv E hE] + exact (H.level _).one_mem) le_rfl + simpa [restrict] using hh + +variable {M : ℕ} (e : Fin M ≃ Finset ι) + +def Compatible : Prop := ∀ i j : Fin M, e i ⊂ e j → i < j + +lemma not_subset_of_lt (he : Compatible e) {i j : Fin M} (hij : i < j) : + ¬ e j ⊆ e i := by + intro hji + by_cases heq : e j = e i + · have := e.injective heq + omega + · have := he j i (Finset.ssubset_iff_subset_ne.mpr ⟨hji,heq⟩) + omega + + +def residual (f : Finset ι → G) : ℕ → (Finset ι → G) + | 0 => f + | j+1 => if h : j < M then + (face (e ⟨j,h⟩) (residual f j (e ⟨j,h⟩)))⁻¹ * residual f j + else residual f j + +def coefficients (f : Finset ι → G) (i : Fin M) : G := residual e f i.val (e i) + + + +def prefixProduct (a : Fin M → G) : ℕ → (Finset ι → G) + | 0 => 1 + | j+1 => if h : j < M then prefixProduct a j * face (e ⟨j,h⟩) (a ⟨j,h⟩) + else prefixProduct a j + +def assemble (a : Fin M → G) : Finset ι → G := prefixProduct e a M + +lemma residual_prior (he : Compatible e) (f : Finset ι → G) (k : ℕ) + (i : Fin M) (hi : i.val < k) : residual e f k (e i) = 1 := by + induction k with + | zero => omega + | succ k ih => + rw [residual] + split_ifs with hk + · change (face (e ⟨k,hk⟩) (residual e f k (e ⟨k,hk⟩)) (e i))⁻¹ * + residual e f k (e i) = 1 + rcases lt_or_eq_of_le (Nat.le_of_lt_succ hi) with hik | hik + · rw [face_apply,ite_eq_right (not_subset_of_lt e he (show i < ⟨k,hk⟩ from hik)),ih hik] + simp + · have heq : (⟨k,hk⟩ : Fin M) = i := Fin.ext hik.symm + subst heq + simp [face_apply] + · exact ih (by omega) + +lemma residual_final (he : Compatible e) (f : Finset ι → G) : residual e f M = 1 := by + funext D + obtain ⟨i,rfl⟩ := e.surjective D + exact residual_prior e he f M i i.isLt + +lemma prefixProduct_residual (f : Finset ι → G) (k : ℕ) : + prefixProduct e (coefficients e f) k * residual e f k = f := by + induction k with + | zero => simp [prefixProduct,residual] + | succ k ih => + rw [prefixProduct,residual] + split_ifs with hk + · simpa only [coefficients,mul_assoc,mul_inv_cancel_left] using ih + · exact ih + +lemma assemble_coefficients (he : Compatible e) (f : Finset ι → G) : + assemble e (coefficients e f) = f := by + have hh := prefixProduct_residual e f M + simpa only [residual_final e he f,mul_one,assemble] using hh + +lemma prefixProduct_eval_after (he : Compatible e) (a : Fin M → G) (i : Fin M) + (k : ℕ) (hik : i.val < k) : + prefixProduct e a k (e i) = prefixProduct e a (i.val+1) (e i) := by + induction k with + | zero => omega + | succ k ih => + rcases lt_or_eq_of_le (Nat.le_of_lt_succ hik) with hik' | hik' + · rw [prefixProduct] + split_ifs with hk + · change prefixProduct e a k (e i) * face (e ⟨k,hk⟩) (a ⟨k,hk⟩) (e i) = _ + rw [face_apply,ite_eq_right (not_subset_of_lt e he (show i < ⟨k,hk⟩ from hik')),mul_one] + exact ih hik' + · exact ih hik' + · subst k + rfl + +lemma assemble_eval (he : Compatible e) (a : Fin M → G) (i : Fin M) : + assemble e a (e i) = prefixProduct e a i.val (e i) * a i := by + rw [assemble,prefixProduct_eval_after e he a i M i.isLt,prefixProduct,dite_eq_left i.isLt] + simp [face_apply] + +lemma assemble_injective (he : Compatible e) : Function.Injective (assemble (G:=G) e) := by + intro a b hab + have hp : ∀ k, prefixProduct e a k = prefixProduct e b k := by + intro k + induction k with + | zero => rfl + | succ k ih => + rw [prefixProduct,prefixProduct] + split_ifs with hk + · have hv := congrFun hab (e ⟨k,hk⟩) + rw [assemble_eval e he,assemble_eval e he] at hv + change prefixProduct e a k (e ⟨k,hk⟩) * a ⟨k,hk⟩ = + prefixProduct e b k (e ⟨k,hk⟩) * b ⟨k,hk⟩ at hv + rw [ih] at hv + rw [ih,mul_left_cancel hv] + · exact ih + funext i + have hv := congrFun hab (e i) + rw [assemble_eval e he,assemble_eval e he,hp i.val] at hv + exact mul_left_cancel hv + +lemma coefficients_assemble (he : Compatible e) (a : Fin M → G) : + coefficients e (assemble e a) = a := + assemble_injective e he (assemble_coefficients e he (assemble e a)) + +lemma coefficients_mem (he : Compatible e) (H : Filtration G) (I : Finset ι) + (hI : ∀ D : Finset ι, D ⊆ I) (k : ℕ) {f : Finset ι → G} (hf : f ∈ cube H I k) : + ∀ i : Fin M, coefficients e f i ∈ H.level ((e i).card+k) := by + have hr : ∀ j, residual e f j ∈ cube H I k := by + intro j + induction j with + | zero => exact hf + | succ j ih => + rw [residual] + split_ifs with hj + · apply (cube H I k).mul_mem _ ih + apply (cube H I k).inv_mem + apply face_mem_cube H (hI _) + apply supported_value_mem H ih + intro E hE + obtain ⟨i,rfl⟩ := e.surjective E + exact residual_prior e he f j i (he i ⟨j,hj⟩ hE) + · exact ih + intro i + apply supported_value_mem H (hr i.val) + intro E hE + obtain ⟨j,rfl⟩ := e.surjective E + exact residual_prior e he f i.val j (he j i hE) + +lemma assemble_mem (H : Filtration G) (I : Finset ι) + (hI : ∀ D : Finset ι, D ⊆ I) (k : ℕ) (a : Fin M → G) + (ha : ∀ i, a i ∈ H.level ((e i).card+k)) : assemble e a ∈ cube H I k := by + have hp : ∀ j, prefixProduct e a j ∈ cube H I k := by + intro j + induction j with + | zero => exact (cube H I k).one_mem + | succ j ih => + rw [prefixProduct] + split_ifs with hj + · exact (cube H I k).mul_mem ih (face_mem_cube H (hI _) (ha _)) + · exact ih + exact hp M + +lemma coefficients_lattice (he : Compatible e) (Γ : Subgroup G) (f : Finset ι → G) : + (∀ D, f D ∈ Γ) ↔ ∀ i, coefficients e f i ∈ Γ := by + constructor + · intro hf + have hr : ∀ k D, residual e f k D ∈ Γ := by + intro k + induction k with + | zero => exact hf + | succ k ih => + intro D + rw [residual] + split_ifs with hk + · apply Γ.mul_mem _ (ih D) + apply Γ.inv_mem + simp only [face_apply] + split_ifs + · exact ih _ + · exact Γ.one_mem + · exact ih D + exact fun i => hr i.val (e i) + · intro hf + have hp : ∀ k D, prefixProduct e (coefficients e f) k D ∈ Γ := by + intro k + induction k with + | zero => exact fun _ => Γ.one_mem + | succ k ih => + intro D + rw [prefixProduct] + split_ifs with hk + · apply Γ.mul_mem (ih D) + simp only [face_apply] + split_ifs + · exact hf _ + · exact Γ.one_mem + · exact ih D + intro D + rw [← assemble_coefficients e he f] + exact hp M D + +section Topology +variable [TopologicalSpace G] [IsTopologicalGroup G] + +lemma residual_continuous (k : ℕ) : Continuous (fun f : Finset ι → G => residual e f k) := by + induction k with + | zero => exact continuous_id + | succ k ih => + simp only [residual] + split_ifs with hk + · exact ((continuous_face _).comp ((continuous_apply _).comp ih)).inv.mul ih + · exact ih + +lemma coefficients_continuous : Continuous (coefficients (G:=G) e) := by + apply continuous_pi + intro i + exact (continuous_apply _).comp (residual_continuous e i.val) + +lemma prefixProduct_continuous (k : ℕ) : + Continuous (fun a : Fin M → G => prefixProduct e a k) := by + induction k with + | zero => exact continuous_const + | succ k ih => + simp only [prefixProduct] + split_ifs with hk + · exact ih.mul ((continuous_face _).comp (continuous_apply _)) + · exact ih + +lemma assemble_continuous : Continuous (assemble (G:=G) e) := prefixProduct_continuous e M + +variable [Fintype ι] + + + +def faceHomeomorph (he : Compatible e) (H : Filtration G) (k : ℕ) : + (∀ i : Fin M, H.level ((e i).card+k)) ≃ₜ cube H (Finset.univ : Finset ι) k where + toFun a := ⟨assemble e (fun i => (a i).val), + assemble_mem e H Finset.univ (fun _ => Finset.subset_univ _) k _ (fun i => (a i).property)⟩ + invFun f i := ⟨coefficients e f.val i, + coefficients_mem e he H Finset.univ (fun _ => Finset.subset_univ _) k f.property i⟩ + left_inv a := by + funext i + apply Subtype.ext + exact congrFun (coefficients_assemble e he (fun i => (a i).val)) i + right_inv f := by + apply Subtype.ext + exact assemble_coefficients e he f.val + continuous_toFun := by + apply Continuous.subtype_mk + exact (assemble_continuous e).comp (continuous_pi (fun i => + continuous_subtype_val.comp (continuous_apply i))) + continuous_invFun := by + apply continuous_pi + intro i + apply Continuous.subtype_mk + exact ((continuous_apply i).comp (coefficients_continuous e)).comp continuous_subtype_val + +lemma faceHomeomorph_lattice (he : Compatible e) (H : Filtration G) (k : ℕ) + (Γ : Subgroup G) (a : ∀ i : Fin M, H.level ((e i).card+k)) : + (∀ D, (faceHomeomorph e he H k a).val D ∈ Γ) ↔ ∀ i, (a i).val ∈ Γ := by + rw [coefficients_lattice e he] + change (∀ i, coefficients e (assemble e (fun i => (a i).val)) i ∈ Γ) ↔ _ + rw [coefficients_assemble e he] + +end Topology + + +omit [DecidableEq ι] in +theorem exists_compatible_order [Fintype ι] : + ∃ e : Fin (Fintype.card (Finset ι)) ≃ Finset ι, Compatible e := by + classical + let code := Fintype.equivFin (Finset ι) + let key : Finset ι → Lex (ℕ × Fin (Fintype.card (Finset ι))) := + fun D => toLex (D.card,code D) + have hi : Function.Injective key := by + intro D E h + exact code.injective (congrArg (fun x => (ofLex x).2) h) + let ord : LinearOrder (Finset ι) := LinearOrder.lift' key hi + let e := Fintype.orderIsoFinOfCardEq (Finset ι) rfl + refine ⟨e.toEquiv,?_⟩ + intro i j hij + apply (@OrderIso.lt_iff_lt _ _ _ ord.toPartialOrder.toPreorder e).mp + change key (e i) < key (e j) + exact Prod.Lex.left _ _ (Finset.card_lt_card hij) + +section Homomorphisms +variable {K : Type} [Group K] + +lemma residual_map (φ : G →* K) (f : Finset ι → G) (k : ℕ) : + residual e (fun D => φ (f D)) k = fun D => φ (residual e f k D) := by + induction k with + | zero => rfl + | succ k ih => + rw [residual,residual] + split_ifs with hk + · funext D + simp only [Pi.mul_apply,Pi.inv_apply,ih,face_apply,map_mul,map_inv] + split_ifs <;> simp + · exact ih + +lemma coefficients_map (φ : G →* K) (f : Finset ι → G) (i : Fin M) : + coefficients e (fun D => φ (f D)) i = φ (coefficients e f i) := by + exact congrFun (residual_map e φ f i.val) (e i) + +lemma prefixProduct_map (φ : G →* K) (a : Fin M → G) (k : ℕ) : + prefixProduct e (fun i => φ (a i)) k = fun D => φ (prefixProduct e a k D) := by + induction k with + | zero => ext D; exact φ.map_one.symm + | succ k ih => + rw [prefixProduct,prefixProduct] + split_ifs with hk + · funext D + simp only [Pi.mul_apply,ih,face_apply,map_mul] + split_ifs <;> simp + · exact ih + +lemma assemble_map (φ : G →* K) (a : Fin M → G) (D : Finset ι) : + assemble e (fun i => φ (a i)) D = φ (assemble e a D) := + congrFun (prefixProduct_map e φ a M) D + +lemma coefficients_map_product (φ : G →* K) (a b : Fin M → G) (i : Fin M) : + φ (coefficients e (assemble e a * assemble e b) i) = + coefficients e (assemble e (fun j => φ (a j)) * assemble e (fun j => φ (b j))) i := by + rw [← coefficients_map] + congr 1 + funext D + simp only [Pi.mul_apply,map_mul,assemble_map] + +end Homomorphisms + +section Commutative +variable {K : Type} [CommGroup K] + +lemma assemble_mul (a b : Fin M → K) : + assemble e (a*b) = assemble e a * assemble e b := by + have hp : ∀ k, prefixProduct e (a*b) k = prefixProduct e a k * prefixProduct e b k := by + intro k + induction k with + | zero => simp [prefixProduct] + | succ k ih => + rw [prefixProduct,prefixProduct,prefixProduct] + split_ifs with hk + · funext D + simp only [Pi.mul_apply,ih,face_apply] + split_ifs <;> simp [mul_assoc,mul_comm,mul_left_comm] + · exact ih + exact hp M + +lemma coefficients_mul (he : Compatible e) (f g : Finset ι → K) : + coefficients e (f*g) = coefficients e f * coefficients e g := by + calc + _ = coefficients e (assemble e (coefficients e f) * assemble e (coefficients e g)) := by + rw [assemble_coefficients e he,assemble_coefficients e he] + _ = _ := by rw [← assemble_mul,coefficients_assemble e he] + +lemma coefficients_hom_product (he : Compatible e) (φ : G →* K) + (a b : Fin M → G) (i : Fin M) : + φ (coefficients e (assemble e a * assemble e b) i) = φ (a i)*φ (b i) := by + rw [coefficients_map_product,coefficients_mul e he, + coefficients_assemble e he,coefficients_assemble e he] + rfl +end Commutative + +section Triangular +open RationalLattice +variable [TopologicalSpace G] {n : ℕ} (c : RealCoordinates G n) + + +def lowerPairs (i : Fin n) : Subgroup (G × G) where + carrier := {g | ∀ j : Fin n, j < i → c.coord g.1 j=c.coord g.2 j} + one_mem' := fun _ _ => rfl + mul_mem' := by + intro g h hg hh + exact mul_lower_congr c i hg hh + inv_mem' := by + intro g hg j hj + have haux : ∀ k (hk : k < i.val), + c.coord g.1⁻¹ ⟨k,lt_trans hk i.isLt⟩=c.coord g.2⁻¹ ⟨k,lt_trans hk i.isLt⟩ := by + intro k + induction k using Nat.strong_induction_on with + | h k ih => + intro hk + let u : Fin n := ⟨k,lt_trans hk i.isLt⟩ + have hcorr := correction_eq_of_lower_eq c u + (g:=g.1) (g':=g.2) (h:=g.1⁻¹) (h':=g.2⁻¹) + (fun j hj => hg j (lt_trans hj hk)) + (fun j hj => ih j.val hj (lt_trans hj hk)) + rw [mul_inv_cancel,mul_inv_cancel,c.one_coord] at hcorr + have he := hg u hk + dsimp [u] at he hcorr ⊢ + linarith + exact haux j.val hj + + + +def differenceCharacter (i : Fin n) : lowerPairs c i →* Multiplicative ℝ where + toFun g := Multiplicative.ofAdd (c.coord g.val.1 i-c.coord g.val.2 i) + map_one' := by apply Multiplicative.toAdd.injective; simp [c.one_coord] + map_mul' g h := by + apply Multiplicative.toAdd.injective + change c.coord (g.val.1*h.val.1) i-c.coord (g.val.2*h.val.2) i = + (c.coord g.val.1 i-c.coord g.val.2 i)+(c.coord h.val.1 i-c.coord h.val.2 i) + have he := correction_eq_of_lower_eq c i g.property h.property + linarith + + + +theorem cube_mul_correction_lower (he : Compatible e) (i : Fin n) + (a a' b b' : Fin M → G) + (ha : ∀ D j, j < i → c.coord (a D) j=c.coord (a' D) j) + (hb : ∀ D j, j < i → c.coord (b D) j=c.coord (b' D) j) (D : Fin M) : + c.coord (coefficients e (assemble e a * assemble e b) D) i- + c.coord (a D) i-c.coord (b D) i = + c.coord (coefficients e (assemble e a' * assemble e b') D) i- + c.coord (a' D) i-c.coord (b' D) i := by + let A : Fin M → lowerPairs c i := fun D => ⟨(a D,a' D),ha D⟩ + let B : Fin M → lowerPairs c i := fun D => ⟨(b D,b' D),hb D⟩ + let fst : lowerPairs c i →* G := (MonoidHom.fst G G).comp (lowerPairs c i).subtype + let snd : lowerPairs c i →* G := (MonoidHom.snd G G).comp (lowerPairs c i).subtype + have hfst := coefficients_map_product e fst A B D + have hsnd := coefficients_map_product e snd A B D + have hdiff := coefficients_hom_product e he (differenceCharacter c i) A B D + apply_fun Multiplicative.toAdd at hdiff + change c.coord (fst (coefficients e (assemble e A * assemble e B) D)) i- + c.coord (snd (coefficients e (assemble e A * assemble e B) D)) i = + (c.coord (a D) i-c.coord (a' D) i)+(c.coord (b D) i-c.coord (b' D) i) at hdiff + change fst (coefficients e (assemble e A * assemble e B) D) = + coefficients e (assemble e a * assemble e b) D at hfst + change snd (coefficients e (assemble e A * assemble e B) D) = + coefficients e (assemble e a' * assemble e b') D at hsnd + rw [hfst,hsnd] at hdiff + linarith + +end Triangular + +section Polynomial +open RationalLattice RationalPolynomialMap +variable [TopologicalSpace G] {n : ℕ} (c : RealCoordinates G n) {σ : Type*} + +lemma residual_polynomial {F : (σ → ℝ) → (Finset ι → G)} + (hF : ∀ D, IsPolynomialMap c (fun x => F x D)) (k : ℕ) : + ∀ D, IsPolynomialMap c (fun x => residual e (F x) k D) := by + induction k with + | zero => exact hF + | succ k ih => + intro D + by_cases hk : k < M + · by_cases hD : e ⟨k,hk⟩ ⊆ D + · simpa only [residual,dite_eq_left hk,Pi.mul_apply,Pi.inv_apply,face_apply,ite_eq_left hD] using + polynomialMap_mul c (polynomialMap_inv c (ih (e ⟨k,hk⟩))) (ih D) + · simpa only [residual,dite_eq_left hk,Pi.mul_apply,Pi.inv_apply,face_apply,ite_eq_right hD, + inv_one,one_mul] using ih D + · simpa only [residual,dite_eq_right hk] using ih D + +lemma coefficients_polynomial {F : (σ → ℝ) → (Finset ι → G)} + (hF : ∀ D, IsPolynomialMap c (fun x => F x D)) (i : Fin M) : + IsPolynomialMap c (fun x => coefficients e (F x) i) := + residual_polynomial e c hF i.val (e i) + +lemma prefixProduct_polynomial {A : (σ → ℝ) → (Fin M → G)} + (hA : ∀ i, IsPolynomialMap c (fun x => A x i)) (k : ℕ) : + ∀ D, IsPolynomialMap c (fun x => prefixProduct e (A x) k D) := by + induction k with + | zero => exact fun _ => polynomialMap_one c + | succ k ih => + intro D + by_cases hk : k < M + · by_cases hD : e ⟨k,hk⟩ ⊆ D + · simpa only [prefixProduct,dite_eq_left hk,Pi.mul_apply,face_apply,ite_eq_left hD] using + polynomialMap_mul c (ih D) (hA ⟨k,hk⟩) + · simpa only [prefixProduct,dite_eq_left hk,Pi.mul_apply,face_apply,ite_eq_right hD,mul_one] using ih D + · simpa only [prefixProduct,dite_eq_right hk] using ih D + +lemma assemble_polynomial {A : (σ → ℝ) → (Fin M → G)} + (hA : ∀ i, IsPolynomialMap c (fun x => A x i)) (D : Finset ι) : + IsPolynomialMap c (fun x => assemble e (A x) D) := + prefixProduct_polynomial e c hA M D +end Polynomial + + +abbrev FreeIndex (n : ℕ) (q : ℕ → ℕ) (k : ℕ) := + {p : Fin M × Fin n // q ((e p.1).card+k) ≤ p.2.val} + +section FreeCoordinates +open RationalLattice RationalPolynomialMap +variable [TopologicalSpace G] {n : ℕ} (c : RealCoordinates G n) +variable (q : ℕ → ℕ) (k : ℕ) + +def expand (x : FreeIndex e n q k → ℝ) (D : Fin M) : G := + c.coord.symm (fun j => if h : q ((e D).card+k) ≤ j.val then x ⟨(D,j),h⟩ else 0) + +omit [DecidableEq ι] in +@[simp] lemma expand_coord (x : FreeIndex e n q k → ℝ) (D : Fin M) (j : Fin n) : + c.coord (expand e c q k x D) j = + if h : q ((e D).card+k) ≤ j.val then x ⟨(D,j),h⟩ else 0 := by + simp only [expand,Homeomorph.apply_symm_apply] + +omit [DecidableEq ι] in +lemma expand_polynomial (D : Fin M) : + IsPolynomialMap c (fun x : FreeIndex e n q k → ℝ => expand e c q k x D) := by + intro j + simp only [expand_coord] + split_ifs + · exact coordinate _ + · exact zero + +omit [DecidableEq ι] in +lemma expand_continuous : Continuous (expand e c q k) := by + apply continuous_pi + intro D + apply c.coord.symm.continuous.comp + apply continuous_pi + intro j + split_ifs + · exact continuous_apply _ + · exact continuous_const + +variable (H : Filtration G) +variable (hq : ∀ d (g : G), g ∈ H.level d ↔ ∀ j : Fin n, j.val < q d → c.coord g j=0) + +include hq in +omit [DecidableEq ι] in +lemma expand_mem (x : FreeIndex e n q k → ℝ) (D : Fin M) : + expand e c q k x D ∈ H.level ((e D).card+k) := by + apply (hq _ _).mpr + intro j hj + simp only [expand_coord,dite_eq_right (not_le_of_gt hj)] + +variable [IsTopologicalGroup G] [Fintype ι] (he : Compatible e) + + +def freeHomeomorph : cube H (Finset.univ : Finset ι) k ≃ₜ (FreeIndex e n q k → ℝ) where + toFun f u := c.coord (coefficients e f.val u.val.1) u.val.2 + invFun x := ⟨assemble e (expand e c q k x), + assemble_mem e H Finset.univ (fun _ => Finset.subset_univ _) k _ + (expand_mem e c q k H hq x)⟩ + left_inv f := by + apply Subtype.ext + have hexp : expand e c q k (fun u => c.coord (coefficients e f.val u.val.1) u.val.2) = + coefficients e f.val := by + funext D + apply c.coord.injective + funext j + rw [expand_coord] + split_ifs with hj + · rfl + · have hm := coefficients_mem e he H Finset.univ (fun _ => Finset.subset_univ _) k f.property D + exact ((hq _ _).mp hm j (Nat.lt_of_not_ge hj)).symm + change assemble e (expand e c q k (fun u => c.coord (coefficients e f.val u.val.1) u.val.2)) = f.val + rw [hexp,assemble_coefficients e he] + right_inv x := by + funext u + change c.coord (coefficients e (assemble e (expand e c q k x)) u.val.1) u.val.2 = x u + rw [coefficients_assemble e he,expand_coord,dite_eq_left u.property] + continuous_toFun := by + apply continuous_pi + intro u + exact (continuous_apply u.val.2).comp (c.coord.continuous.comp + ((continuous_apply u.val.1).comp ((coefficients_continuous e).comp continuous_subtype_val))) + continuous_invFun := by + apply Continuous.subtype_mk + exact (assemble_continuous e).comp (expand_continuous e c q k) + +lemma freeHomeomorph_apply (f : cube H (Finset.univ : Finset ι) k) (u : FreeIndex e n q k) : + freeHomeomorph e c q k H hq he f u = c.coord (coefficients e f.val u.val.1) u.val.2 := rfl + +lemma expand_freeHomeomorph (f : cube H (Finset.univ : Finset ι) k) : + expand e c q k (freeHomeomorph e c q k H hq he f) = coefficients e f.val := by + funext D + apply c.coord.injective + funext j + rw [expand_coord] + split_ifs with hj + · rfl + · have hm := coefficients_mem e he H Finset.univ (fun _ => Finset.subset_univ _) k f.property D + exact ((hq _ _).mp hm j (Nat.lt_of_not_ge hj)).symm + +lemma freeHomeomorph_lattice (Γ : Subgroup G) + (hΓ : ∀ g : G, g ∈ Γ ↔ ∀ j, ∃ z : ℤ, c.coord g j=z) + (f : cube H (Finset.univ : Finset ι) k) : + (∀ D, f.val D ∈ Γ) ↔ ∀ u, ∃ z : ℤ, freeHomeomorph e c q k H hq he f u=z := by + rw [coefficients_lattice e he] + simp_rw [hΓ] + constructor + · intro hf u + exact hf u.val.1 u.val.2 + · intro hf D j + by_cases hj : q ((e D).card+k) ≤ j.val + · exact hf ⟨(D,j),hj⟩ + · refine ⟨0,?_⟩ + have hm := coefficients_mem e he H Finset.univ (fun _ => Finset.subset_univ _) k f.property D + simpa using (hq _ _).mp hm j (Nat.lt_of_not_ge hj) + +end FreeCoordinates + +section RankedCoordinates +open RationalLattice RationalPolynomialMap +variable [TopologicalSpace G] {n : ℕ} (c : RealCoordinates G n) +variable (q : ℕ → ℕ) (k : ℕ) + + +def BaseFirst {N : ℕ} (r : Fin N ≃ FreeIndex e n q k) : Prop := + ∀ i j, (r i).val.2 < (r j).val.2 → i < j + +omit [DecidableEq ι] in +theorem exists_baseFirst_order : + ∃ r : Fin (Fintype.card (FreeIndex e n q k)) ≃ FreeIndex e n q k, + BaseFirst e q k r := by + classical + let key : FreeIndex e n q k → Lex (Fin n × Fin M) := fun u => toLex (u.val.2,u.val.1) + have hi : Function.Injective key := by + intro u v h + apply Subtype.ext + apply Prod.ext + · exact congrArg (fun x => (ofLex x).2) h + · exact congrArg (fun x => (ofLex x).1) h + let ord : LinearOrder (FreeIndex e n q k) := LinearOrder.lift' key hi + let r := Fintype.orderIsoFinOfCardEq (FreeIndex e n q k) rfl + refine ⟨r.toEquiv,?_⟩ + intro i j hij + apply (@OrderIso.lt_iff_lt _ _ _ ord.toPartialOrder.toPreorder r).mp + change key (r i) < key (r j) + exact Prod.Lex.left _ _ hij + +variable {N : ℕ} (r : Fin N ≃ FreeIndex e n q k) + +def truncate (i : Fin N) (x : Fin i.val → ℝ) (u : FreeIndex e n q k) : ℝ := + if h : r.symm u < i then x ⟨(r.symm u).val,h⟩ else 0 + +omit [DecidableEq ι] in +lemma truncate_polynomial (i : Fin N) (u : FreeIndex e n q k) : + IsPolynomial (fun x : Fin i.val → ℝ => truncate e q k r i x u) := by + unfold truncate + split_ifs + · exact coordinate _ + · exact zero + +omit [DecidableEq ι] in +lemma expand_truncate_lower (hr : BaseFirst e q k r) (i : Fin N) + (x : FreeIndex e n q k → ℝ) (D : Fin M) (j : Fin n) (hj : j < (r i).val.2) : + c.coord (expand e c q k x D) j = + c.coord (expand e c q k (truncate e q k r i + (fun t => x (r ⟨t.val,lt_trans t.isLt i.isLt⟩))) D) j := by + simp only [expand_coord] + split_ifs with hqj + · have hlt : r.symm ⟨(D,j),hqj⟩ < i := by + apply hr + rw [r.apply_symm_apply] + exact hj + simp only [truncate,dite_eq_left hlt] + congr 1 + exact (r.apply_symm_apply ⟨(D,j),hqj⟩).symm + · rfl + +variable (H : Filtration G) +variable (hq : ∀ d (g : G), g ∈ H.level d ↔ ∀ j : Fin n, j.val < q d → c.coord g j=0) +variable [IsTopologicalGroup G] [Fintype ι] (he : Compatible e) + +def rankedHomeomorph : cube H (Finset.univ : Finset ι) k ≃ₜ (Fin N → ℝ) := + (freeHomeomorph e c q k H hq he).trans (Homeomorph.piCongrLeft r).symm + +@[simp] lemma rankedHomeomorph_apply (f : cube H (Finset.univ : Finset ι) k) (i : Fin N) : + rankedHomeomorph e c q k r H hq he f i = c.coord (coefficients e f.val (r i).val.1) (r i).val.2 := rfl + + +def correctionFunction (i : Fin N) (x : Fin i.val ⊕ Fin i.val → ℝ) : ℝ := + let A := expand e c q k (truncate e q k r i (fun j => x (.inl j))) + let B := expand e c q k (truncate e q k r i (fun j => x (.inr j))) + c.coord (coefficients e (assemble e A * assemble e B) (r i).val.1) (r i).val.2 - + c.coord (A (r i).val.1) (r i).val.2 - c.coord (B (r i).val.1) (r i).val.2 + +omit [IsTopologicalGroup G] [Fintype ι] in +lemma correctionFunction_polynomial (i : Fin N) : + IsPolynomial (correctionFunction e c q k r i) := by + have hA (D : Fin M) : IsPolynomialMap c (fun x : Fin i.val ⊕ Fin i.val → ℝ => + expand e c q k (truncate e q k r i (fun j => x (.inl j))) D) := by + apply polynomialMap_comp c (expand_polynomial e c q k D) + intro u + unfold truncate + split_ifs + · exact coordinate _ + · exact zero + have hB (D : Fin M) : IsPolynomialMap c (fun x : Fin i.val ⊕ Fin i.val → ℝ => + expand e c q k (truncate e q k r i (fun j => x (.inr j))) D) := by + apply polynomialMap_comp c (expand_polynomial e c q k D) + intro u + unfold truncate + split_ifs + · exact coordinate _ + · exact zero + exact sub (sub (coefficients_polynomial e c + (fun D => polynomialMap_mul c (assemble_polynomial e c hA D) + (assemble_polynomial e c hB D)) (r i).val.1 (r i).val.2) + (hA (r i).val.1 (r i).val.2)) (hB (r i).val.1 (r i).val.2) + +lemma ranked_mul_correction (hr : BaseFirst e q k r) + (f g : cube H (Finset.univ : Finset ι) k) (i : Fin N) : + rankedHomeomorph e c q k r H hq he (f*g) i = + rankedHomeomorph e c q k r H hq he f i + rankedHomeomorph e c q k r H hq he g i + + correctionFunction e c q k r i (Sum.elim + (fun j => rankedHomeomorph e c q k r H hq he f ⟨j.val,lt_trans j.isLt i.isLt⟩) + (fun j => rankedHomeomorph e c q k r H hq he g ⟨j.val,lt_trans j.isLt i.isLt⟩)) := by + let x := freeHomeomorph e c q k H hq he f + let y := freeHomeomorph e c q k H hq he g + have hx : expand e c q k x = coefficients e f.val := expand_freeHomeomorph e c q k H hq he f + have hy : expand e c q k y = coefficients e g.val := expand_freeHomeomorph e c q k H hq he g + have h := cube_mul_correction_lower e c he (r i).val.2 + (expand e c q k x) (expand e c q k (truncate e q k r i (fun j => x (r ⟨j.val,lt_trans j.isLt i.isLt⟩)))) + (expand e c q k y) (expand e c q k (truncate e q k r i (fun j => y (r ⟨j.val,lt_trans j.isLt i.isLt⟩)))) + (expand_truncate_lower e c q k r hr i x) (expand_truncate_lower e c q k r hr i y) (r i).val.1 + rw [hx,hy,assemble_coefficients e he,assemble_coefficients e he] at h + change c.coord (coefficients e (f.val*g.val) (r i).val.1) (r i).val.2 - + c.coord (coefficients e f.val (r i).val.1) (r i).val.2 - + c.coord (coefficients e g.val (r i).val.1) (r i).val.2 = + correctionFunction e c q k r i (Sum.elim + (fun j => rankedHomeomorph e c q k r H hq he f ⟨j.val,lt_trans j.isLt i.isLt⟩) + (fun j => rankedHomeomorph e c q k r H hq he g ⟨j.val,lt_trans j.isLt i.isLt⟩)) at h + simp only [rankedHomeomorph_apply] at h ⊢ + change c.coord (coefficients e (f.val*g.val) (r i).val.1) (r i).val.2 = _ + linarith + + +def realCoordinates (hr : BaseFirst e q k r) : RealCoordinates (cube H (Finset.univ : Finset ι) k) N where + coord := rankedHomeomorph e c q k r H hq he + one_coord i := by + rw [rankedHomeomorph_apply] + have hres (j : ℕ) : residual e (1 : Finset ι → G) j=1 := by + induction j with + | zero => rfl + | succ j ih => + rw [residual] + split_ifs <;> simp [ih] + have hone : coefficients e (1 : Finset ι → G) = 1 := by + funext i + simp [coefficients,hres] + simp only [OneMemClass.coe_one,hone,Pi.one_apply,c.one_coord] + correction i := (correctionFunction_polynomial e c q k r i).choose + mul_coord f g i := by + rw [ranked_mul_correction e c q k r H hq he hr] + congr 1 + exact (correctionFunction_polynomial e c q k r i).choose_spec _ + +lemma realCoordinates_lattice (hr : BaseFirst e q k r) (Γ : Subgroup G) + (hΓ : ∀ g : G, g ∈ Γ ↔ ∀ j, ∃ z : ℤ, c.coord g j=z) + (f : cube H (Finset.univ : Finset ι) k) : + (∀ D, f.val D ∈ Γ) ↔ ∀ i, ∃ z : ℤ, (realCoordinates e c q k r H hq he hr).coord f i=z := by + rw [freeHomeomorph_lattice e c q k H hq he Γ hΓ] + constructor + · intro hf i + exact hf (r i) + · intro hf u + simpa only [realCoordinates,rankedHomeomorph_apply,freeHomeomorph_apply,r.apply_symm_apply] using hf (r.symm u) + +end RankedCoordinates + +section AdaptedCubeChart +open RationalLattice MalcevCharacters +variable [TopologicalSpace G] [IsTopologicalGroup G] [Fintype ι] +variable {n : ℕ} (c : RealCoordinates G n) (q : ℕ → ℕ) +variable (H : Filtration G) +variable (hq : ∀ d (g : G), g ∈ H.level d ↔ ∀ j : Fin n, j.val < q d → c.coord g j=0) +variable (he : Compatible e) + +include he in +omit [TopologicalSpace G] [IsTopologicalGroup G] in +lemma cube_mem_iff_coefficients (J : Filtration G) (k : ℕ) (f : Finset ι → G) : + f ∈ cube J (Finset.univ : Finset ι) k ↔ ∀ D, coefficients e f D∈J.level ((e D).card+k) := by + constructor + · exact fun hf => coefficients_mem e he J Finset.univ (fun _ => Finset.subset_univ _) k hf + · intro hf + rw [← assemble_coefficients e he f] + exact assemble_mem e J Finset.univ (fun _ => Finset.subset_univ _) k _ hf + +variable {N : ℕ} (r : Fin N ≃ FreeIndex e n q 0) (hr : BaseFirst e q 0 r) + +lemma realCoordinates_max_level (l : ℕ) (f : cube H (Finset.univ : Finset ι) 0) : + f ∈ (CubeMaxFiltration.filtration H Finset.univ).level l ↔ + ∀ i : Fin N, (r i).val.2.val < q (max l (e (r i).val.1).card) → + (realCoordinates e c q 0 r H hq he hr).coord f i=0 := by + change f.val ∈ CubeMaxFiltration.level H Finset.univ l ↔ _ + rw [CubeMaxFiltration.level_eq_clamp_cube,cube_mem_iff_coefficients e he] + simp only [CubeMaxFiltration.clamp,Nat.add_zero,hq] + constructor + · intro hf i hi + exact hf (r i).val.1 (r i).val.2 hi + · intro hf D j hj + by_cases hfree : q ((e D).card+0) ≤ j.val + · simpa only [realCoordinates,rankedHomeomorph_apply,r.apply_symm_apply] using + hf (r.symm ⟨(D,j),hfree⟩) (by simpa only [r.apply_symm_apply] using hj) + · have hm := coefficients_mem e he H Finset.univ (fun _ => Finset.subset_univ _) 0 f.property D + exact (hq _ _).mp hm j (Nat.lt_of_not_ge hfree) + +include hq he in + + +theorem exists_adapted_cube_coordinates + (h01 : H.level 0=H.level 1) (s : ℕ) (hs : H.level (s+1)=⊥) + (Γ : Subgroup G) (hΓ : ∀ g : G, g∈Γ ↔ ∀ j, ∃ z : ℤ, c.coord g j=z) : + ∃ N : ℕ, ∃ cc : RealCoordinates (cube H (Finset.univ : Finset ι) 0) N, + SecondKind cc ∧ + (∀ f : cube H (Finset.univ : Finset ι) 0, + f ∈ CubeLocalHaar.cubeLattice H Γ ↔ ∀ i, ∃ z : ℤ, cc.coord f i=z) ∧ + ∀ l : ℕ, ∃ t : ℕ, t ≤ N ∧ ∀ f : cube H (Finset.univ : Finset ι) 0, + f ∈ (CubeMaxFiltration.filtration H Finset.univ).level l ↔ + ∀ i : Fin N, i.val < t → cc.coord f i=0 := by + obtain ⟨r,hr⟩ := exists_baseFirst_order e (n:=n) q 0 + let d := realCoordinates e c q 0 r H hq he hr + have hdΓ : ∀ f : cube H (Finset.univ : Finset ι) 0, + f ∈ CubeLocalHaar.cubeLattice H Γ ↔ ∀ i, ∃ z : ℤ, d.coord f i=z := + realCoordinates_lattice e c q 0 r H hq he hr Γ hΓ + have hdH : ∀ l, ∃ I : Set (Fin (Fintype.card (FreeIndex e n q 0))), + ∀ f : cube H (Finset.univ : Finset ι) 0, + f ∈ (CubeMaxFiltration.filtration H Finset.univ).level l ↔ + ∀ i ∈ I, d.coord f i=0 := by + intro l + exact ⟨{i | (r i).val.2.val < q (max l (e (r i).val.1).card)}, + realCoordinates_max_level e c q H hq he r hr l⟩ + obtain ⟨cc,hcc,hcΓ,hcH⟩ := MalcevWeightedCoordinates.exists_adapted_secondKind_coordinates d + (CubeMaxFiltration.filtration H Finset.univ) (CubeMaxFiltration.filtration_zero H Finset.univ) + (CubeMaxFiltration.filtration_one H Finset.univ h01) s + (CubeMaxFiltration.filtration_bot H Finset.univ hs) hdH + (CubeLocalHaar.cubeLattice H Γ) hdΓ + exact ⟨_,cc,hcc,hcΓ,hcH⟩ + +include hq in + +theorem cube_chart_from_base + (h01 : H.level 0=H.level 1) (s : ℕ) (hs : H.level (s+1)=⊥) + (Γ : Subgroup G) (hΓ : ∀ g : G, g∈Γ ↔ ∀ j, ∃ z : ℤ, c.coord g j=z) : + ∃ N : ℕ, ∃ cc : RealCoordinates (cube H (Finset.univ : Finset ι) 0) N, + SecondKind cc ∧ + (∀ f : cube H (Finset.univ : Finset ι) 0, + f ∈ CubeLocalHaar.cubeLattice H Γ ↔ ∀ i, ∃ z : ℤ, cc.coord f i=z) ∧ + ∀ l : ℕ, ∃ t : ℕ, t ≤ N ∧ ∀ f : cube H (Finset.univ : Finset ι) 0, + f ∈ (CubeMaxFiltration.filtration H Finset.univ).level l ↔ + ∀ i : Fin N, i.val < t → cc.coord f i=0 := by + obtain ⟨e,he⟩ := exists_compatible_order (ι:=ι) + exact exists_adapted_cube_coordinates e c q H hq he h01 s hs Γ hΓ + +end AdaptedCubeChart + +end CubeRationalCharts + +end +end + +end OAI diff --git a/lean/OAI/Combinatorics/SumProduct/Alignment/CubeRationalization01.lean b/lean/OAI/Combinatorics/SumProduct/Alignment/CubeRationalization01.lean new file mode 100644 index 0000000000000000000000000000000000000000..6b1ce964386399188c2d92a919abecde4ad3a043 --- /dev/null +++ b/lean/OAI/Combinatorics/SumProduct/Alignment/CubeRationalization01.lean @@ -0,0 +1,353 @@ +import Mathlib +import OAI.Combinatorics.SumProduct.Alignment.RoughCube01 +import OAI.Geometry.NilpotentCharts.Main + +namespace OAI + +section +noncomputable section +open scoped BigOperators +end + +end + + +section + + + +noncomputable section +open Finset +open scoped BigOperators +namespace CubeRationalization +open BooleanRough BooleanPeeling CubeParameter CubeCoefficients +open RealPolynomialDegree PolynomialLineCoefficients RoughCoefficientDescentBridge +open RoughJointCoefficients CoefficientPeeling CorrectedBoxLeibman + +def bound (v s : ℕ) (A : ℝ) : ℝ := + (max 1 (A+(Fintype.card (PositiveGrid v s) : ℝ)*((2:ℝ)^s)^v))^(v*s) + +lemma one_le_bound (v s : ℕ) (A : ℝ) : 1 ≤ bound v s A := + one_le_pow₀ (le_max_left _ _) + + + +theorem peel_coefficients {n v s q M : ℕ} + (θ : PolynomialLineCoefficients.Grid v s → (Fin n → ℝ) → ℝ) + (hθ : ∀ I, HasDegree (θ I) q) + (m₀ : (Fin n → ℝ) → ℝ) (hm₀ : HasDegree m₀ q) + (hmfloor : ∀ z, m₀ (realVertex z) = (⌊θ 0 (realVertex z)⌋ : ℤ)) + (hdim : 2*(q+v*s) < n) (a : ℤ) (b : Fin n → ℤ) + (htpos : ∀ S : Finset (Fin n), 0 < a+∑ i ∈ S, b i) + (htbound : ∀ S : Finset (Fin n), a+∑ i ∈ S, b i ≤ (M : ℤ)) + (hrough : ∀ p : ℕ, p.Prime → (∃ S : Finset (Fin n), (p:ℤ) ∣ a+∑ i ∈ S, b i) → + n < p ∧ ∀ i, ¬ (p:ℤ) ∣ b i) + (Z A : ℝ) (hZ : 0 < Z) (hMZ : (M:ℝ) ≤ Z) (hA : 0 < A) + (p : (Fin n → Bool) → ℕ) (u : (Fin n → Bool) → Fin v → ℤ) + (hp : ∀ z, p z = 1 ∨ p z = (a+∑ i ∈ vertexSet z, b i).natAbs) + (hu : ∀ z i, 0 ≤ u z i ∧ u z i < p z) + (hobs : ∀ z I, 0 < totalDegree I → + TriangularLatticeRecovery.circleNorm (gridDilate (p z) + (gridTranslate (fun I => θ I (realVertex z)) (u z)) I) ≤ A*((p z:ℝ)/Z)^totalDegree I) + (hsmall : (1+(M:ℝ)^(v*s)*(2^n:ℝ)^2)*(bound v s A*((M:ℝ)/Z))* + (M:ℝ)^(v*s*2^n) < 1) : + ∃ m : PolynomialLineCoefficients.Grid v s → (Fin n → ℝ) → ℝ, + (∀ I, HasDegree (m I) q) ∧ + (∀ I z, ∃ k : ℤ, m I (realVertex z) = k) ∧ + ∀ I z, |θ I (realVertex z)-m I (realVertex z)| *Z^totalDegree I ≤ bound v s A := by + classical + choose c hc hce using fun I : PositiveGrid v s => realVertex_degree (θ I.val) q (hθ I.val) + let zS : Finset (Fin n) → (Fin n → Bool) := fun S i => decide (i ∈ S) + have hceS (I : PositiveGrid v s) (S : Finset (Fin n)) : + Eval (c I) S = θ I.val (realVertex (zS S)) := by + simpa only [zS, vertexSet_decide] using hce I (zS S) + have hps (S : Finset (Fin n)) : p (zS S) = 1 ∨ p (zS S) = (a+∑ i ∈ S, b i).natAbs := by + simpa only [zS, vertexSet_decide] using hp (zS S) + have hpPos (S : Finset (Fin n)) : 0 < p (zS S) := by + rcases hps S with he | he + · omega + · rw [he] + exact Int.natAbs_pos.mpr (htpos S).ne' + have hcBound (I J : PositiveGrid v s) (S : Finset (Fin n)) + (hIJ : totalDegree I.val < totalDegree J.val) := + translationMatrix_degree_bound (u (zS S)) (p (zS S)) (hpPos S) (hu (zS S)) I.val J.val hIJ + have hnear (I : PositiveGrid v s) (S : Finset (Fin n)) : + NearInteger ((p (zS S):ℝ)^totalDegree I.val * (Eval (c I) S + + ∑ J ∈ univ.filter (fun J : PositiveGrid v s => totalDegree I.val < totalDegree J.val), + (translationMatrix (u (zS S)) I.val J.val:ℝ)*Eval (c J) S)) + (A*((p (zS S):ℝ)/Z)^totalDegree I.val) := by + simpa only [gridDilate, positive_peeling, hceS] using + circleNorm_nearInteger (hobs (zS S) I.val I.property) + obtain ⟨f, hf⟩ := peel_cube (fun I : PositiveGrid v s => totalDegree I.val) (v*s) q M + (fun I => ⟨I.property, RoughCoefficientDescentBridge.totalDegree_le I.val⟩) + (by simpa using hdim) a b c hc htpos htbound (by simpa using hrough) + Z A (((2:ℝ)^s)^v) hZ hMZ hA (by positivity) (fun S => p (zS S)) hps + (fun I J S => translationMatrix (u (zS S)) I.val J.val) hcBound hnear + (by simpa only [Fintype.card_fin, bound] using hsmall) + choose m hm hem using fun I : PositiveGrid v s => realize_boolean_rational (f I) (hf I).1 + let m' : PolynomialLineCoefficients.Grid v s → (Fin n → ℝ) → ℝ := fun I => + if hI : 0 < totalDegree I then m ⟨I,hI⟩ else m₀ + refine ⟨m', ?_, ?_, ?_⟩ + · intro I + dsimp only [m'] + split_ifs with hI + · exact hm _ + · exact hm₀ + · intro I z + dsimp only [m'] + split_ifs with hI + · obtain ⟨k, hk⟩ := eval_integral_of_coeffs (f ⟨I,hI⟩) (hf ⟨I,hI⟩).2.1 (vertexSet z) + refine ⟨k, ?_⟩ + rw [hem] + exact_mod_cast hk + · have hI0 : I = 0 := (DenseBoxComplete.degree_eq_zero I).mp (by omega) + subst I + exact ⟨_, hmfloor z⟩ + · intro I z + dsimp only [m'] + split_ifs with hI + · rw [hem, ← hce ⟨I,hI⟩] + exact (hf ⟨I,hI⟩).2.2 (vertexSet z) + · have hI0 : I = 0 := (DenseBoxComplete.degree_eq_zero I).mp (by omega) + subst I + rw [hmfloor, show totalDegree (0 : PolynomialLineCoefficients.Grid v s)=0 by simp [totalDegree], pow_zero, mul_one] + change |Int.fract (θ 0 (realVertex z))| ≤ bound v s A + rw [abs_of_nonneg (Int.fract_nonneg _)] + exact (Int.fract_lt_one _).le.trans (one_le_bound v s A) + +end CubeRationalization + +end + +end + + +section + + + +noncomputable section +open Filter +open scoped Topology +namespace CubeRoundingScales + +theorem eventual_small (d n : ℕ) (B : ℝ) (hB : 0 ≤ B) + {S Z : ℕ → ℝ} (hS : Tendsto S atTop atTop) + (hZ : ∀ k : ℕ, Tendsto (fun j => Z j/S j^k) atTop atTop) : + ∀ᶠ j in atTop, 1 ≤ S j ∧ 0 < Z j ∧ (⌈2*S j⌉₊ : ℝ) ≤ Z j ∧ + (1+(⌈2*S j⌉₊ : ℝ)^d*(2^n:ℝ)^2)*(B*((⌈2*S j⌉₊ : ℝ)/Z j))* + (⌈2*S j⌉₊ : ℝ)^(d*2^n) < 1 := by + let e := d+1+d*2^n + let C : ℝ := (1+(2^n:ℝ)^2)*B*3^e + have hlim : Tendsto (fun j => C*(S j^e/Z j)) atTop (𝓝 0) := by + simpa using (RoughScales.inverse_ratio_tendsto (hZ e)).const_mul C + have hsmall : ∀ᶠ j in atTop, C*(S j^e/Z j) < 1 := + hlim.eventually (gt_mem_nhds (by norm_num)) + have hlarge : ∀ᶠ j in atTop, 3 ≤ Z j/S j := by + simpa only [pow_one] using (hZ 1).eventually (eventually_ge_atTop 3) + filter_upwards [hS.eventually (eventually_ge_atTop 1), hlarge, hsmall] with j hs hz hh + have hspos : 0 < S j := by linarith + have hz3 : 3*S j ≤ Z j := (le_div_iff₀ hspos).mp hz + have hzpos : 0 < Z j := (by positivity : 0 < 3*S j).trans_le hz3 + have hM : (⌈2*S j⌉₊ : ℝ) ≤ 3*S j := by + have hc := Nat.ceil_lt_add_one (by positivity : (0:ℝ) ≤ 2*S j) + linarith + refine ⟨hs, hzpos, hM.trans hz3, lt_of_le_of_lt ?_ hh⟩ + have hp : 1 ≤ (3*S j)^d := one_le_pow₀ (by linarith) + have hfirst : 1+(⌈2*S j⌉₊ : ℝ)^d*(2^n:ℝ)^2 ≤ (1+(2^n:ℝ)^2)*(3*S j)^d := by + calc + _ ≤ (3*S j)^d+(3*S j)^d*(2^n:ℝ)^2 := by gcongr + _ = _ := by ring + calc + _ ≤ ((1+(2^n:ℝ)^2)*(3*S j)^d)*(B*((3*S j)/Z j))*(3*S j)^(d*2^n) := by + gcongr + _ = C*(S j^e/Z j) := by + dsimp [C, e] + simp only [pow_add, pow_succ, mul_pow] + ring + +end CubeRoundingScales + +end + +end + + +section + +noncomputable section +open Finset +open scoped BigOperators +namespace CubeArithmetic +open RoughCubeBlock RoughScales CubeParameter + +lemma time_set {n : ℕ} (a m : ℤ) (h : Fin n → ℕ) (z : Fin n → Bool) : + time a m h z = a+∑ i ∈ vertexSet z, m*(h i:ℤ) := by + simp only [time, vertexSet, sum_filter, Nat.cast_sum, Nat.cast_ite, Nat.cast_zero, mul_sum] + congr 1 + apply sum_congr rfl + intro i _ + cases z i <;> simp + +variable {G : Type*} [Group G] [TopologicalSpace G] {r : ℕ} +variable {c : RationalLattice.RealCoordinates G r} {Γ : Subgroup G} [mtr : MetricSpace (G⧸Γ)] +local instance : TopologicalSpace (G⧸Γ) := mtr.toUniformSpace.toTopologicalSpace +variable {v D n K w : ℕ} {c₀ C₀ : ℝ} {B : NNReal} {η S Z : ℝ} + +lemma block_prime_slopes (b : Block c Γ v D c₀ C₀ B η w S Z n K) + (hn : n ≤ w) (hK : K ≤ w) : + ∀ p : ℕ, p.Prime → + (∃ E : Finset (Fin n), (p:ℤ) ∣ b.start+∑ i ∈ E, b.step*(b.weight i:ℤ)) → + n < p ∧ ∀ i, ¬ (p:ℤ) ∣ b.step*(b.weight i:ℤ) := by + intro p hp ⟨E, hE⟩ + have ht : (p:ℤ) ∣ time b.start b.step b.weight (fun i => decide (i ∈ E)) := by + simpa only [time_set, vertexSet_decide] using hE + have hpw : w < p := Nat.lt_of_not_ge (fun h => b.rough _ p hp h ht) + refine ⟨hn.trans_lt hpw, ?_⟩ + intro i hi + have hh : Smooth w (b.weight i:ℤ) := smooth_of_abs_le (by exact_mod_cast (b.weight_pos i).ne') + (by simpa using (b.weight_bound i).trans hK) + have hm : Smooth w (b.step*(b.weight i:ℤ)) := RoughRationalBlock.smooth_mul b.smooth hh + exact (not_le_of_gt hpw) (hm p hp hi) + +lemma block_time_bounds (b : Block c Γ v D c₀ C₀ B η w S Z n K) (hS : 0 < S) : + (∀ E : Finset (Fin n), 0 < b.start+∑ i ∈ E, b.step*(b.weight i:ℤ)) ∧ + (∀ E : Finset (Fin n), b.start+∑ i ∈ E, b.step*(b.weight i:ℤ) ≤ (⌈2*S⌉₊ : ℤ)) := by + have he (E : Finset (Fin n)) : time b.start b.step b.weight (fun i => decide (i ∈ E)) = + b.start+∑ i ∈ E, b.step*(b.weight i:ℤ) := by simp only [time_set, vertexSet_decide] + constructor + · intro E + rw [← he] + exact_mod_cast hS.trans_le (b.scales _).1 + · intro E + rw [← he] + exact_mod_cast (b.scales _).2.le.trans (Nat.le_ceil (2*S)) + +end CubeArithmetic + +end + +end + + +section + + + +noncomputable section +open Finset Filter +open scoped BigOperators Topology +namespace CubeSplitProducer +open RationalLattice MalcevCharacters RealPolynomialDegree RoughScales +open CubeParameter CubeCoefficients RoughCubeBlock CubeRationalization CubeArithmetic +open DenseBooleanCubes Combinatorics PolynomialLineCoefficients CorrectedBoxLeibman +open RoughAnalyticExtraction + +variable {G : Type} [Group G] [TopologicalSpace G] {r : ℕ} + +def GoodCharacter (Γ : Subgroup G) (ξ : G →* Multiplicative ℝ) : Prop := + ξ ≠ 1 ∧ Continuous ξ ∧ ∀ g ∈ Γ, ∃ z : ℤ, (ξ g).toAdd = z + +def Split {n v : ℕ} (q s : ℕ) (P : (Fin (n+v) → ℝ) → G) + (ξ : G →* Multiplicative ℝ) (Z B : ℝ) : Prop := + ∃ θ m : PolynomialLineCoefficients.Grid v s → (Fin n → ℝ) → ℝ, + (∀ I, HasDegree (θ I) q) ∧ (∀ I, HasDegree (m I) q) ∧ + (∀ z x, gridEval (fun I => θ I z) x = (ξ (P (Fin.append z x))).toAdd) ∧ + (∀ I z, ∃ k : ℤ, m I (realVertex z) = k) ∧ + ∀ I z, |θ I (realVertex z)-m I (realVertex z)| *Z^totalDegree I ≤ B + +variable [IsTopologicalGroup G] +variable (c : RealCoordinates G r) (hsk : SecondKind c) (Γ : Subgroup G) +variable (hΓ : ∀ g : G, g ∈ Γ ↔ ∀ i, ∃ z : ℤ, c.coord g i=z) +variable [mtr : MetricSpace (G⧸Γ)] +variable (htop : mtr.toUniformSpace.toTopologicalSpace = QuotientGroup.instTopologicalSpace Γ) +local instance : TopologicalSpace (G⧸Γ) := mtr.toUniformSpace.toTopologicalSpace + +include hsk hΓ htop in +theorem split_producer (v D : ℕ) (c₀ C₀ : ℝ) (B : NNReal) (η : ℝ) + (hc₀ : 0 < c₀) (hC₀ : 0 < C₀) (hB : 0 < B) (hη : 0 < η) + {w : ℕ → ℕ} {S Z : ℕ → ℝ} (hw : Tendsto w atTop atTop) + (hS : Tendsto S atTop atTop) + (hZ : ∀ k : ℕ, Tendsto (fun j => Z j/S j^k) atTop atTop) : + ∃ q s : ℕ, ∃ U : Finset (G →* Multiplicative ℝ), + (∀ ξ ∈ U, GoodCharacter Γ ξ) ∧ ∃ A : ℝ, 1 ≤ A ∧ + ∀ n : ℕ, 2*(q+v*s) < n → ∃ N L : ℕ, ∀ K : ℕ, ∀ᶠ j in atTop, + ∀ _ : Block c Γ v D c₀ C₀ B η (w j) (S j) (Z j) N K, + ∃ b' : Block c Γ v D c₀ C₀ B η (w j) (S j) (Z j) n (L*(N*K)), + ∃ ξ ∈ U, Split q s b'.P ξ (Z j) A := by + classical + obtain ⟨q,s,U,A,T,hA,hT,hcoeff,hdetect⟩ := CubeCharacter.character_tools c hsk Γ hΓ htop + v D c₀ C₀ B η hc₀ hC₀ hB hη + let V := U.filter (GoodCharacter Γ) + have hV (ξ) (hξ : ξ ∈ V) : GoodCharacter Γ ξ := (mem_filter.mp hξ).2 + refine ⟨q,s,V,hV,bound v s A,one_le_bound v s A,?_⟩ + intro n hn + obtain ⟨N₀,hN₀⟩ := CubeConstant.constant_thinning n q + obtain ⟨N₁,hN₁⟩ := colored_subcube N₀ {ξ // ξ ∈ V} + refine ⟨N₁,N₀,fun K => ?_⟩ + have hlarge : ∀ᶠ j in atTop, 2*T ≤ Z j/S j := by + simpa only [pow_one] using (hZ 1).eventually (eventually_ge_atTop (2*T)) + filter_upwards [CubeRoundingScales.eventual_small (v*s) n (bound v s A) + (zero_le_one.trans (one_le_bound v s A)) hS hZ, + hw.eventually (eventually_ge_atTop (max n (N₀*(N₁*K)))), hlarge] + with j hj hwj hlargej + intro b + have hSj : 0 < S j := zero_lt_one.trans_le hj.1 + have hscale (z : Fin N₁ → Bool) : 0 < (time b.start b.step b.weight z).natAbs ∧ + T ≤ Z j/(time b.start b.step b.weight z).natAbs := by + have ht : 0 < time b.start b.step b.weight z := by exact_mod_cast hSj.trans_le (b.scales z).1 + have habs : ((time b.start b.step b.weight z).natAbs:ℝ) = (time b.start b.step b.weight z:ℝ) := by + rw [Nat.cast_natAbs, Int.cast_abs, abs_of_pos (by exact_mod_cast ht)] + refine ⟨Int.natAbs_pos.mpr ht.ne', ?_⟩ + apply (le_div_iff₀ (by exact_mod_cast Int.natAbs_pos.mpr ht.ne')).mpr + rw [habs] + calc + _ ≤ T*(2*S j) := mul_le_mul_of_nonneg_left (b.scales z).2.le (zero_le_one.trans hT) + _ ≤ Z j := by have hh := (le_div_iff₀ hSj).mp hlargej; nlinarith + choose p u hp hu ξ hξ hobs using hdetect N₁ K (w j) (S j) (Z j) b hscale + have hξV (z) : ξ z ∈ V := mem_filter.mpr ⟨hξ z, (hobs z).1, (hobs z).2.1, (hobs z).2.2.1⟩ + obtain ⟨l,χ,hχ⟩ := hN₁ (fun z => (⟨ξ z,hξV z⟩ : {ξ // ξ ∈ V})) + have hχeq (z) : ξ (l z) = χ.val := congrArg Subtype.val (hχ z) + let b₀ := b.subspace l + let θ : PolynomialLineCoefficients.Grid v s → (Fin N₀ → ℝ) → ℝ := CubeCharacter.coefficients b₀.P χ.val + obtain ⟨hθ,heθ⟩ := hcoeff N₀ b₀.P b₀.degree χ.val (hV χ.val χ.property).2.1 + obtain ⟨l₀,m₀,hm₀,hmfloor⟩ := hN₀ (θ 0) (hθ 0) + let b₁ := b₀.subspace l₀ + let θ' : PolynomialLineCoefficients.Grid v s → (Fin n → ℝ) → ℝ := fun I z => θ I (parameterLift l₀ z) + have hθ' (I) : HasDegree (θ' I) q := degree_parameterLift l₀ (hθ I) + have heθ' (z : Fin n → ℝ) (x : Fin v → ℝ) : + gridEval (fun I => θ' I z) x = (χ.val (b₁.P (Fin.append z x))).toAdd := by + simpa only [θ', b₁, Block.subspace, lift_append] using heθ (parameterLift l₀ z) x + have hobs₁ (z : Fin n → Bool) : CharacterObstruction (s:=s) Γ + (fun x => b₁.P (Fin.append (realVertex z) (fun i => (x i:ℝ)))) χ.val + (u (l (l₀ z))) (p (l (l₀ z))) (Z j) A := by + simpa only [b₁, b₀, Block.subspace, lift_vertex, hχeq] using hobs (l (l₀ z)) + have hcoeffobs (z : Fin n → Bool) (I : PolynomialLineCoefficients.Grid v s) (hI : 0 < totalDegree I) : + TriangularLatticeRecovery.circleNorm (gridDilate (p (l (l₀ z))) + (gridTranslate (fun I => θ' I (realVertex z)) (u (l (l₀ z)))) I) ≤ + A*((p (l (l₀ z)):ℝ)/Z j)^totalDegree I := by + obtain ⟨_,_,_,a,ha,_,ho⟩ := hobs₁ z + have he : a = fun I => θ' I (realVertex z) := gridEval_integer_injective + (fun x => (ha x).trans (heθ' (realVertex z) (fun i => (x i:ℝ))).symm) + simpa only [he] using ho I hI + obtain ⟨htpos,htbound⟩ := block_time_bounds b₁ hSj + have hprime := block_prime_slopes b₁ ((le_max_left _ _).trans hwj) ((le_max_right _ _).trans hwj) + have hp₁ (z : Fin n → Bool) : p (l (l₀ z)) = 1 ∨ + p (l (l₀ z)) = (b₁.start+∑ i ∈ vertexSet z, b₁.step*(b₁.weight i:ℤ)).natAbs := by + simpa only [← time_set, b₁, b₀, Block.subspace, time_subspace] using hp (l (l₀ z)) + obtain ⟨m,hm,hmi,hmerr⟩ := peel_coefficients θ' hθ' m₀ hm₀ + (fun z => by simpa only [θ', parameterLift_vertex] using hmfloor z) + hn b₁.start (fun i => b₁.step*(b₁.weight i:ℤ)) htpos htbound hprime + (Z j) A hj.2.1 hj.2.2.1 hA (fun z => p (l (l₀ z))) (fun z => u (l (l₀ z))) + hp₁ (fun z => hu (l (l₀ z))) hcoeffobs hj.2.2.2 + have hfinal : ∃ b' : Block c Γ v D c₀ C₀ B η (w j) (S j) (Z j) n (N₀*(N₁*K)), + ∃ ξ ∈ V, Split q s b'.P ξ (Z j) (bound v s A) := + ⟨b₁,χ.val,χ.property,θ',m,hθ',hm,heθ',hmi,hmerr⟩ + exact hfinal + +end CubeSplitProducer + +end +end + +end OAI diff --git a/lean/OAI/Combinatorics/SumProduct/Alignment/CubeTaylor01.lean b/lean/OAI/Combinatorics/SumProduct/Alignment/CubeTaylor01.lean new file mode 100644 index 0000000000000000000000000000000000000000..72eb3a5c12d3fab1f1dc5610f886c1213902c0f6 --- /dev/null +++ b/lean/OAI/Combinatorics/SumProduct/Alignment/CubeTaylor01.lean @@ -0,0 +1,375 @@ +import Mathlib +import OAI.Combinatorics.SumProduct.Alignment.BooleanBinomial01 +import OAI.Combinatorics.SumProduct.Alignment.RationalLattice03 +import OAI.Geometry.NilpotentCharts.Main + +namespace OAI + +section +section +section +section +end + + + +section + +noncomputable section +open scoped BigOperators Topology commutatorElement +namespace CubeHorizontalIrrationality +open CubeFaces HorizontalCubeCharacter Filter BooleanBinomial MvPolynomial +variable {G ι : Type*} [Group G] [TopologicalSpace G] [IsTopologicalGroup G] +variable [Fintype ι] [DecidableEq ι] + + +def RationalCharacter {K : Subgroup G} (Γ : Subgroup G) + (ξ : K →* Multiplicative ℝ) : Prop := + ∃ m : ℕ, 0 < m ∧ ∀ x : K, (x:G)∈Γ → ∃ z : ℤ, (m:ℝ)*(ξ x).toAdd=z + +omit [IsTopologicalGroup G] [Fintype ι] in +lemma faceLift_continuous (H : Filtration G) (I D : Finset ι) (k : ℕ) + (hDI : D⊆I) (hDk : D.card ≤ k) : + Continuous (faceLift H I D k hDI hDk) := by + apply Continuous.subtype_mk + apply continuous_pi + intro v + change Continuous (fun x : H.level k => if D⊆v then (x:G) else 1) + split_ifs + · exact continuous_subtype_val + · exact continuous_const + + + +def weight (H : Filtration G) (χ : cube H (Finset.univ : Finset ι) 0 →* Multiplicative ℝ) + (a : ∀ k : ℕ, H.level k) (k : ℕ) (D : Finset ι) : ℝ := + if h : D.card ≤ k then (χ (faceLift H Finset.univ D k + (Finset.subset_univ D) h (a k))).toAdd else 0 + + + +def scalarPolynomial (H : Filtration G) + (χ : cube H (Finset.univ : Finset ι) 0 →* Multiplicative ℝ) + (a : ∀ k : ℕ, H.level k) (s : ℕ) : MvPolynomial (Option ι) ℝ := + ∑ k∈Finset.range (s+1),∑ D : Finset ι, C (weight H χ a k D)*faceBinomial k D + +omit [TopologicalSpace G] [IsTopologicalGroup G] in +lemma maximal_level_le {H : Filtration G} + {χ : cube H (Finset.univ : Finset ι) 0 →* Multiplicative ℝ} + (M : MaximalFace H Finset.univ χ) {s : ℕ} (hs : H.level (s+1)= ⊥) : + M.level ≤ s := by + by_contra! hn + apply M.nontrivial + ext x + have hx : (x:G)∈H.level (s+1) := H.antitone hn x.property + rw [hs,Subgroup.mem_bot] at hx + have hx' : x=1 := Subtype.ext hx + simp [hx'] + +omit [TopologicalSpace G] [IsTopologicalGroup G] in +lemma weight_above {H : Filtration G} + {χ : cube H (Finset.univ : Finset ι) 0 →* Multiplicative ℝ} + (M : MaximalFace H Finset.univ χ) (a : ∀ k : ℕ,H.level k) + (k : ℕ) (hk : M.level < k) (D : Finset ι) : weight H χ a k D=0 := by + unfold weight + split_ifs with h + · have hh := DFunLike.congr_fun (M.maximal k hk D (Finset.subset_univ D) h) (a k) + change χ (faceLift H Finset.univ D k (Finset.subset_univ D) h (a k))=1 at hh + rw [hh] + rfl + · rfl + + + +omit [TopologicalSpace G] [IsTopologicalGroup G] in +theorem isolated_scalar_coefficient {H : Filtration G} + {χ : cube H (Finset.univ : Finset ι) 0 →* Multiplicative ℝ} + (M : MaximalFace H Finset.univ χ) (a : ∀ k : ℕ,H.level k) + (s : ℕ) (hs : H.level (s+1)= ⊥) : + (scalarPolynomial H χ a s).coeff (isolatedExponent M.level M.face)= + (M.character.value (a M.level)).toAdd/(M.level-M.face.card).factorial := by + classical + simp only [scalarPolynomial,coeff_sum,coeff_C_mul] + rw [Finset.sum_eq_single_of_mem M.level + (Finset.mem_range.mpr (Nat.lt_succ_of_le (maximal_level_le M hs)))] + · rw [Finset.sum_eq_single M.face] + · rw [isolated_coefficient M.level M.face M.card_le] + simp only [weight,dite_eq_left M.card_le,div_eq_mul_inv] + rfl + · intro E _ hE + rw [coefficient_other_face M.level M.level M.face E (Ne.symm hE),mul_zero] + · simp + · intro k _ hk + apply Finset.sum_eq_zero + intro D _ + rcases lt_or_gt_of_ne hk with hlt|hgt + · rw [coefficient_lower_order k M.level M.face D M.card_le hlt,mul_zero] + · rw [weight_above M a k hgt D,zero_mul] + + +def scaleCharacter {K : Type*} [Group K] (r : ℝ) + (ξ : K →* Multiplicative ℝ) : K →* Multiplicative ℝ where + toFun x := Multiplicative.ofAdd (r*(ξ x).toAdd) + map_one' := by simp + map_mul' x y := by simp [mul_add] + +lemma scaleCharacter_ne {K : Type*} [Group K] {r : ℝ} (hr : r≠0) + {ξ : K →* Multiplicative ℝ} (hξ : ξ≠1) : scaleCharacter r ξ≠1 := by + intro hh + apply hξ + ext x + have hx := congrArg Multiplicative.toAdd (DFunLike.congr_fun hh x) + change r*(ξ x).toAdd=0 at hx + have hz := (mul_eq_zero.mp hx).resolve_left hr + exact hz + + + +omit [IsTopologicalGroup G] in +theorem maximal_scaled_character {H : Filtration G} (Γ : Subgroup G) + {χ : cube H (Finset.univ : Finset ι) 0 →* Multiplicative ℝ} + (hχ : Continuous χ) + (hχΓ : ∀ x : cube H (Finset.univ : Finset ι) 0, + (∀ v,(x:Finset ι→G) v∈Γ) → ∃ z : ℤ,(χ x).toAdd=z) + (M : MaximalFace H Finset.univ χ) : + let ξ := scaleCharacter ((M.level-M.face.card).factorial:ℝ)⁻¹ M.character.value + ξ≠1 ∧ Continuous ξ ∧ RationalCharacter Γ ξ ∧ + (∀ x (hx : x∈H.level (M.level+1)), + ξ ⟨x,H.antitone (Nat.le_succ _) hx⟩=1) ∧ + (∀ i k : ℕ,0 < i → 0 < k → ∀ h : i+k=M.level, + ∀ x (hx : x∈H.level i) y (hy : y∈H.level k), + ξ ⟨⁅x,y⁆,by rw [←h]; exact H.commutator_le i k (Subgroup.commutator_mem_commutator hx hy)⟩=1) := by + classical + dsimp only + have hn : ((M.level-M.face.card).factorial:ℝ)≠0 := by + exact_mod_cast Nat.factorial_ne_zero (M.level-M.face.card) + refine ⟨scaleCharacter_ne (inv_ne_zero hn) M.character_nontrivial,?_,?_,?_,?_⟩ + · change Continuous (fun x : H.level M.level => + Multiplicative.ofAdd (((M.level-M.face.card).factorial:ℝ)⁻¹* + (χ (faceLift H Finset.univ M.face M.level M.subset M.card_le x)).toAdd)) + have hh : Continuous (fun x : H.level M.level => + (χ (faceLift H Finset.univ M.face M.level M.subset M.card_le x)).toAdd) := + hχ.comp (faceLift_continuous H Finset.univ M.face M.level M.subset M.card_le) + exact continuous_ofAdd.comp (continuous_const.mul hh) + · refine ⟨(M.level-M.face.card).factorial,Nat.factorial_pos _,?_⟩ + intro x hx + obtain ⟨z,hz⟩ := hχΓ (faceLift H Finset.univ M.face M.level M.subset M.card_le x) (by + intro v + change (if M.face⊆v then (x:G) else 1)∈Γ + split_ifs + · exact hx + · exact Γ.one_mem) + refine ⟨z,?_⟩ + change _*((((M.level-M.face.card).factorial:ℝ)⁻¹)* + (χ (faceLift H Finset.univ M.face M.level M.subset M.card_le x)).toAdd)=z + rw [←mul_assoc,mul_inv_cancel₀ hn,one_mul,hz] + · intro x hx + change Multiplicative.ofAdd (_*(M.character.value _).toAdd)=1 + rw [M.character.kills_next x hx] + simp + · intro i k hi hk hik x hx y hy + change Multiplicative.ofAdd (_*(M.character.value _).toAdd)=1 + rw [M.character.kills_brackets i k hi hk hik x hx y hy] + simp + + + +omit [IsTopologicalGroup G] in +theorem coefficient_divergence (H : Filtration G) (Γ : Subgroup G) + (h01 : H.level 0=H.level 1) (s : ℕ) (hs : H.level (s+1)= ⊥) + (a : ℕ→∀ k : ℕ,H.level k) + (hirr : ∀ j : ℕ,0 < j → j ≤ s → ∀ ξ : H.level j→*Multiplicative ℝ, + ξ≠1 → Continuous ξ → RationalCharacter Γ ξ → + (∀ x (hx : x∈H.level (j+1)),ξ ⟨x,H.antitone (Nat.le_succ _) hx⟩=1) → + (∀ i k : ℕ,0 < i → 0 < k → ∀ h : i+k=j, + ∀ x (hx : x∈H.level i) y (hy : y∈H.level k), + ξ ⟨⁅x,y⁆,by rw [←h]; exact H.commutator_le i k (Subgroup.commutator_mem_commutator hx hy)⟩=1) → + Tendsto (fun N : ℕ => ‖((ξ (a N j)).toAdd:UnitAddCircle)‖*(N:ℝ)^j) + atTop atTop) + (χ : cube H (Finset.univ : Finset ι) 0→*Multiplicative ℝ) + (hχne : χ≠1) (hχ : Continuous χ) + (hχΓ : ∀ x : cube H (Finset.univ : Finset ι) 0, + (∀ v,(x:Finset ι→G) v∈Γ) → ∃ z : ℤ,(χ x).toAdd=z) : + ∃ e : Exponent ι,0 < degree e ∧ degree e ≤ s ∧ + Tendsto (fun N : ℕ => ‖(((scalarPolynomial H χ (a N) s).coeff e:ℝ):UnitAddCircle)‖* + (N:ℝ)^(degree e)) atTop atTop := by + obtain ⟨M⟩ := exists_maximalFace H Finset.univ h01 s hs χ hχne + obtain ⟨hne,hc,hr,hn,hb⟩ := maximal_scaled_character Γ hχ hχΓ M + refine ⟨isolatedExponent M.level M.face,?_,?_,?_⟩ + · rw [isolatedExponent_degree M.level M.face M.card_le] + exact M.positive + · rw [isolatedExponent_degree M.level M.face M.card_le] + exact maximal_level_le M hs + · have hh := hirr M.level M.positive (maximal_level_le M hs) _ hne hc hr hn hb + simpa only [isolatedExponent_degree M.level M.face M.card_le, + isolated_scalar_coefficient M _ s hs,scaleCharacter,MonoidHom.coe_mk, + OneHom.coe_mk,toAdd_ofAdd,div_eq_mul_inv,mul_comm] using hh + +end CubeHorizontalIrrationality +end +end + + + +section + +noncomputable section +open scoped BigOperators Topology commutatorElement +namespace CubeTaylorExpansion +open MvPolynomial CubeFaces HorizontalCubeCharacter BooleanBinomial CubeHorizontalIrrationality RationalLattice +variable {G ι : Type*} [Group G] [TopologicalSpace G] [IsTopologicalGroup G] +variable [Fintype ι] [DecidableEq ι] {n : ℕ} +variable (c : RealCoordinates G n) (H : Filtration G) +variable (S : ℕ→Set (Fin n)) +variable (hH : ∀ k (g : G),g∈H.level k ↔ ∀ i∈S k,c.coord g i=0) + + +def levelPower (k : ℕ) (a : H.level k) (t : ℝ) : H.level k := + ⟨realPower c (a:G) t,realPower_mem_of_coordinates c (H.level k) (S k) (hH k) a.property t⟩ + +omit [IsTopologicalGroup G] in +@[simp] lemma levelPower_zero (k : ℕ) (a : H.level k) : levelPower c H S hH k a 0=1 := by + apply Subtype.ext + exact realPower_zero c _ + +omit [IsTopologicalGroup G] in +@[simp] lemma levelPower_one (k : ℕ) (a : H.level k) : levelPower c H S hH k a 1=a := by + apply Subtype.ext + exact realPower_one c _ + +omit [IsTopologicalGroup G] in +lemma levelPower_add (k : ℕ) (a : H.level k) (t u : ℝ) : + levelPower c H S hH k a (t+u)=levelPower c H S hH k a t*levelPower c H S hH k a u := by + apply Subtype.ext + exact realPower_add c _ _ _ + +omit [IsTopologicalGroup G] in +lemma levelPower_continuous (k : ℕ) (a : H.level k) : Continuous (levelPower c H S hH k a) := + (realPower_continuous c _).subtype_mk _ + +omit [IsTopologicalGroup G] in +lemma character_levelPower (k : ℕ) (a : H.level k) + (ξ : H.level k→*Multiplicative ℝ) (hξ : Continuous ξ) (t : ℝ) : + (ξ (levelPower c H S hH k a t)).toAdd=t*(ξ a).toAdd := by + let p : ℝ→+ℝ := + { toFun := fun t => (ξ (levelPower c H S hH k a t)).toAdd + map_zero' := by simp + map_add' := by intro t u; rw [levelPower_add,map_mul]; rfl } + have hp : Continuous p := hξ.comp (levelPower_continuous c H S hH k a) + have hh := map_real_smul p hp t 1 + simpa [p] using hh + + +def faceFactor (k : ℕ) (a : H.level k) (D : Finset ι) (b : Option ι→ℝ) : + cube H (Finset.univ : Finset ι) 0 := + if h : D.card ≤ k then faceLift H Finset.univ D k (Finset.subset_univ D) h + (levelPower c H S hH k a (eval b (faceBinomial k D))) else 1 + +omit [IsTopologicalGroup G] in +lemma faceFactor_vertex (k : ℕ) (a : H.level k) (D v : Finset ι) (b : Option ι→ℝ) : + ((faceFactor c H S hH k a D b : cube H Finset.univ 0) : Finset ι→G) v= + realPower c (a:G) (if D⊆v then eval b (faceBinomial k D) else 0) := by + by_cases h : D.card ≤ k + · simp only [faceFactor,dite_eq_left h,faceLift_coe,face_apply,levelPower] + split_ifs <;> simp + · rw [faceFactor,dite_eq_right h,faceBinomial_vanish k D (lt_of_not_ge h)] + simp + +omit [IsTopologicalGroup G] in +lemma faceFactor_character (k : ℕ) (a : ∀ k : ℕ,H.level k) (D : Finset ι) + (b : Option ι→ℝ) (χ : cube H (Finset.univ : Finset ι) 0→*Multiplicative ℝ) + (hχ : Continuous χ) : + (χ (faceFactor c H S hH k (a k) D b)).toAdd=weight H χ a k D*eval b (faceBinomial k D) := by + by_cases h : D.card ≤ k + · let ξ := χ.comp (faceLift H Finset.univ D k (Finset.subset_univ D) h) + have hc : Continuous ξ := hχ.comp (faceLift_continuous H Finset.univ D k (Finset.subset_univ D) h) + simpa only [faceFactor,dite_eq_left h,weight,MonoidHom.comp_apply,ξ,mul_comm] using + character_levelPower c H S hH k (a k) ξ hc (eval b (faceBinomial k D)) + · simp [faceFactor,weight,h] + + + +def cubeFactor (k : ℕ) (a : H.level k) (b : Option ι→ℝ) : + cube H (Finset.univ : Finset ι) 0 := + ((Finset.univ : Finset (Finset ι)).toList.map (fun D => faceFactor c H S hH k a D b)).prod + +omit [IsTopologicalGroup G] in +lemma cubeFactor_vertex (k : ℕ) (a : H.level k) (b : Option ι→ℝ) (v : Finset ι) : + ((cubeFactor c H S hH k a b : cube H Finset.univ 0) : Finset ι→G) v= + realPower c (a:G) (Ring.choose (b none+∑ i∈v,b (some i)) k) := by + have hh (L : List (Finset ι)) : + ((((L.map (fun D => faceFactor c H S hH k a D b)).prod) : cube H Finset.univ 0) : + Finset ι→G) v=realPower c (a:G) + ((L.map (fun D => if D⊆v then eval b (faceBinomial k D) else 0)).sum) := by + induction L with + | nil => simp + | cons D L ih => + simp only [List.map_cons,List.prod_cons,List.sum_cons,Subgroup.coe_mul,Pi.mul_apply] + rw [faceFactor_vertex,ih,realPower_add] + simpa only [cubeFactor,Finset.sum_map_toList,←binomial_expansion] using + hh (Finset.univ : Finset (Finset ι)).toList + +lemma character_list_prod {K : Type*} [Group K] (χ : K→*Multiplicative ℝ) (L : List K) : + (χ L.prod).toAdd=(L.map (fun x => (χ x).toAdd)).sum := by + induction L with + | nil => simp + | cons x L ih => simp only [List.prod_cons,map_mul,toAdd_mul,List.map_cons,List.sum_cons,ih] + +omit [IsTopologicalGroup G] in +lemma cubeFactor_character (k : ℕ) (a : ∀ k : ℕ,H.level k) (b : Option ι→ℝ) + (χ : cube H (Finset.univ : Finset ι) 0→*Multiplicative ℝ) (hχ : Continuous χ) : + (χ (cubeFactor c H S hH k (a k) b)).toAdd= + ∑ D : Finset ι,weight H χ a k D*eval b (faceBinomial k D) := by + rw [cubeFactor,character_list_prod,List.map_map] + simp only [Function.comp_def,faceFactor_character c H S hH k a _ b χ hχ,Finset.sum_map_toList] + + + +def cubePolynomial (a : ∀ k : ℕ,H.level k) (s : ℕ) (b : Option ι→ℝ) : + cube H (Finset.univ : Finset ι) 0 := + ((List.range (s+1)).map (fun k => cubeFactor c H S hH k (a k) b)).prod + +def taylorPolynomial (a : ∀ k : ℕ,H.level k) (s : ℕ) (t : ℝ) : G := + ((List.range (s+1)).map (fun k => realPower c (a k:G) (Ring.choose t k))).prod + + + +omit [IsTopologicalGroup G] in +theorem cubePolynomial_vertex (a : ∀ k : ℕ,H.level k) (s : ℕ) (b : Option ι→ℝ) (v : Finset ι) : + ((cubePolynomial c H S hH a s b : cube H Finset.univ 0) : Finset ι→G) v= + taylorPolynomial c H a s (b none+∑ i∈v,b (some i)) := by + have hh (L : List ℕ) : + ((((L.map (fun k => cubeFactor c H S hH k (a k) b)).prod) : cube H Finset.univ 0) : + Finset ι→G) v= + ((L.map (fun k => realPower c (a k:G) (Ring.choose (b none+∑ i∈v,b (some i)) k))).prod) := by + induction L with + | nil => rfl + | cons k L ih => + simp only [List.map_cons,List.prod_cons,Subgroup.coe_mul,Pi.mul_apply] + rw [cubeFactor_vertex,ih] + exact hh (List.range (s+1)) + +lemma sum_list_range {A : Type*} [AddCommMonoid A] (f : ℕ→A) (n : ℕ) : + ((List.range n).map f).sum=∑ k∈Finset.range n,f k := by + induction n with + | zero => simp + | succ n ih => rw [List.sum_range_succ,Finset.sum_range_succ,ih] + + +omit [IsTopologicalGroup G] in +theorem scalarPolynomial_eval (a : ∀ k : ℕ,H.level k) (s : ℕ) (b : Option ι→ℝ) + (χ : cube H (Finset.univ : Finset ι) 0→*Multiplicative ℝ) (hχ : Continuous χ) : + eval b (scalarPolynomial H χ a s)=(χ (cubePolynomial c H S hH a s b)).toAdd := by + rw [cubePolynomial,character_list_prod,List.map_map] + simp only [scalarPolynomial,map_sum,map_mul,eval_C,Function.comp_def, + cubeFactor_character c H S hH _ a b χ hχ,sum_list_range] + +end CubeTaylorExpansion + +end +end +end +end +end + +end OAI diff --git a/lean/OAI/Combinatorics/SumProduct/Alignment/CubeTaylor02.lean b/lean/OAI/Combinatorics/SumProduct/Alignment/CubeTaylor02.lean new file mode 100644 index 0000000000000000000000000000000000000000..6450482df74e0d0536c47833e1baa4796140fc50 --- /dev/null +++ b/lean/OAI/Combinatorics/SumProduct/Alignment/CubeTaylor02.lean @@ -0,0 +1,366 @@ +import Mathlib +import OAI.Combinatorics.SumProduct.Alignment.CorrectedBox07 +import OAI.Combinatorics.SumProduct.Alignment.CubeTaylor01 +import OAI.Combinatorics.SumProduct.Alignment.ScalarDifference01 +import OAI.Geometry.NilpotentCharts.Main + +namespace OAI + +section +section +section +section +noncomputable section +open scoped BigOperators +end +end + + + +section + +noncomputable section +open scoped BigOperators Topology +namespace CubeTaylorExpansion +open MvPolynomial CubeFaces HorizontalCubeCharacter BooleanBinomial CubeHorizontalIrrationality RationalLattice +variable {G ι : Type*} [Group G] [TopologicalSpace G] [IsTopologicalGroup G] +variable [Fintype ι] [DecidableEq ι] {n : ℕ} +variable (c : RealCoordinates G n) (H : Filtration G) +variable (S : ℕ→Set (Fin n)) +variable (hH : ∀ k (g : G),g∈H.level k ↔ ∀ i∈S k,c.coord g i=0) + +lemma faceBinomial_totalDegree (k : ℕ) (D : Finset ι) : (faceBinomial k D).totalDegree≤k := by + apply Finset.sup_le + intro e he + exact (faceBinomial_support k D he).2 + + + +def facePower (k : ℕ) (a : H.level k) (D : Finset ι) (hD : D.card≤k) : + Multiplicative ℝ→*cube H (Finset.univ : Finset ι) 0 where + toFun t := faceLift H Finset.univ D k (Finset.subset_univ D) hD (levelPower c H S hH k a t.toAdd) + map_one' := by simp + map_mul' t u := by simp only [toAdd_mul,levelPower_add,map_mul] + +omit [IsTopologicalGroup G] in +lemma facePower_mem [IsTopologicalGroup G] + (k : ℕ) (a : H.level k) (D : Finset ι) (hD : D.card≤k) (t : ℝ) : + facePower c H S hH k a D hD (Multiplicative.ofAdd t)∈ + (CubeMaxFiltration.filtration H (Finset.univ : Finset ι)).level k := by + change face D (levelPower c H S hH k a t : G)∈CubeMaxFiltration.level H Finset.univ k + exact CubeMaxFiltration.taylor_face_mem H Finset.univ (Finset.subset_univ D) + le_rfl hD (levelPower c H S hH k a t).property + + +theorem faceFactor_polynomial (k : ℕ) (a : H.level k) (D : Finset ι) : + LeibmanSquare.Polynomial (CubeMaxFiltration.filtration H (Finset.univ : Finset ι)) 0 + (faceFactor c H S hH k a D) := by + change LeibmanSquare.Polynomial _ 0 (fun b => faceFactor c H S hH k a D b) + by_cases hD : D.card≤k + · have hp := ScalarDifferenceDegree.polynomial_power + (CubeMaxFiltration.filtration H (Finset.univ : Finset ι)) (facePower c H S hH k a D hD) + k (facePower_mem c H S hH k a D hD) + (ScalarDifferenceDegree.eval_polynomial (faceBinomial k D) (faceBinomial_totalDegree k D)) + simpa only [faceFactor,dite_eq_left hD,facePower,MonoidHom.coe_mk,OneHom.coe_mk,toAdd_ofAdd] using hp + · have hp := LeibmanSquare.polynomial_of_cube_mem (CubeMaxFiltration.filtration H (Finset.univ : Finset ι)) + (CubePolynomials.polynomials (A:=Option ι→ℝ) (CubeMaxFiltration.filtration H Finset.univ) 0).one_mem + simpa only [faceFactor,dite_eq_right hD,Pi.one_def] using hp + +lemma polynomial_list_prod {A K T : Type*} [AddCommGroup A] [Group K] + (F : Filtration K) (L : List T) (f : T→A→K) + (hf : ∀ t∈L,LeibmanSquare.Polynomial F 0 (f t)) : + LeibmanSquare.Polynomial F 0 (fun x => (L.map (fun t => f t x)).prod) := by + apply LeibmanSquare.polynomial_of_cube_mem + induction L with + | nil => exact (CubePolynomials.polynomials F 0).one_mem + | cons t L ih => + have ht := LeibmanSquare.cube_mem_of_polynomial F (hf t List.mem_cons_self) + have hl := ih (fun u hu => hf u (List.mem_cons_of_mem _ hu)) + exact (CubePolynomials.polynomials F 0).mul_mem ht hl + +lemma cubeFactor_polynomial (k : ℕ) (a : H.level k) : + LeibmanSquare.Polynomial (CubeMaxFiltration.filtration H (Finset.univ : Finset ι)) 0 + (cubeFactor c H S hH k a) := by + apply polynomial_list_prod + intro D _ + exact faceFactor_polynomial c H S hH k a D + + + +theorem cubePolynomial_adapted (a : ∀ k : ℕ,H.level k) (s : ℕ) : + LeibmanSquare.Polynomial (CubeMaxFiltration.filtration H (Finset.univ : Finset ι)) 0 + (cubePolynomial c H S hH a s) := by + apply polynomial_list_prod + intro k _ + exact cubeFactor_polynomial c H S hH k (a k) + +end CubeTaylorExpansion +end +end + + + +section + +noncomputable section +open scoped BigOperators +namespace CorrectedBoxLeibman +open MvPolynomial PolynomialLineCoefficients + +lemma exponent_le_sum {σ : Type*} [Fintype σ] (e : σ →₀ ℕ) (i : σ) : + e i≤e.sum (fun _ k => k) := by + classical + rw [Finsupp.sum_fintype _ _ (by simp)] + exact Finset.single_le_sum (fun j hj => Nat.zero_le _) (Finset.mem_univ i) + +def exponentGrid {v s : ℕ} (e : Fin v →₀ ℕ) (he : e.sum (fun _ k => k) ≤ s) : Grid v s := + fun i => ⟨e i,Nat.lt_succ_of_le ((exponent_le_sum e i).trans he)⟩ + +@[simp] lemma gridExponent_exponentGrid {v s : ℕ} (e : Fin v →₀ ℕ) (he : e.sum (fun _ k => k) ≤ s) : + gridExponent (exponentGrid e he)=e := by ext i; rfl + +lemma exponentGrid_degree {v s : ℕ} (e : Fin v →₀ ℕ) (he : e.sum (fun _ k => k) ≤ s) : + totalDegree (exponentGrid e he)=e.sum (fun _ k => k) := by + rw [←gridExponent_degree,gridExponent_exponentGrid] + + + +def polynomialGrid {v s : ℕ} (p : MvPolynomial (Fin v) ℝ) : Grid v s → ℝ := + fun e => p.coeff (gridExponent e) + +lemma polynomial_eq_grid {v s : ℕ} (p : MvPolynomial (Fin v) ℝ) (hp : p.totalDegree ≤ s) : + p=∑ e : Grid v s,monomial (gridExponent e) (polynomialGrid p e) := by + classical + ext m + simp only [coeff_sum,coeff_monomial] + by_cases hm : ∀ i,m i ≤ s + · let e : Grid v s := fun i => ⟨m i,Nat.lt_succ_of_le (hm i)⟩ + have he : gridExponent e=m := by ext i; rfl + rw [Finset.sum_eq_single e] + · simp only [he,ite_true,polynomialGrid] + · intro f _ hfe + have hh : gridExponent f≠m := by + intro h + exact hfe (gridExponent_injective v s (h.trans he.symm)) + simp only [hh,ite_false] + · simp + · have hc : p.coeff m=0 := by + by_contra hn + have hmem := MvPolynomial.mem_support_iff.mpr hn + exact hm (fun i => (le_degreeOf_of_mem_support i hmem).trans ((degreeOf_le_totalDegree p i).trans hp)) + rw [hc] + symm + apply Finset.sum_eq_zero + intro e _ + have hh : gridExponent e≠m := by + intro h + apply hm + intro i + have he := congrArg (fun x : Fin v →₀ ℕ => x i) h + rw [←he] + exact Nat.le_of_lt_succ (e i).isLt + simp only [hh,ite_false] + +lemma gridEval_polynomial {v s : ℕ} (p : MvPolynomial (Fin v) ℝ) (hp : p.totalDegree ≤ s) + (x : Fin v → ℝ) : gridEval (polynomialGrid p : Grid v s → ℝ) x=eval x p := by + have he := congrArg (eval x) (polynomial_eq_grid p hp) + classical + have hm (e : Grid v s) : (gridExponent e).prod (fun i k => x i^k)=∏ i,x i^(e i).val := by + rw [Finsupp.prod_fintype _ _ (by intro i; simp)] + rfl + simpa only [map_sum,eval_monomial,hm,gridEval] using he.symm + +end CorrectedBoxLeibman +end +end + + + +section + +noncomputable section +open scoped BigOperators Topology commutatorElement +namespace CubeHorizontalIrrationality +open CubeFaces HorizontalCubeCharacter Filter BooleanBinomial MvPolynomial +open CubeTaylorExpansion CorrectedBoxLeibman PolynomialLineCoefficients PolynomialWeyl TriangularLatticeRecovery +variable {G ι : Type*} [Group G] [TopologicalSpace G] [IsTopologicalGroup G] +variable [Fintype ι] [DecidableEq ι] + +omit [TopologicalSpace G] [IsTopologicalGroup G] in +lemma scalarPolynomial_totalDegree [TopologicalSpace G] [IsTopologicalGroup G] (H : Filtration G) + (χ : cube H (Finset.univ : Finset ι) 0→*Multiplicative ℝ) + (a : ∀ k : ℕ,H.level k) (s : ℕ) : (scalarPolynomial H χ a s).totalDegree ≤ s := by + apply MvPolynomial.totalDegree_finsetSum_le + intro k hk + apply MvPolynomial.totalDegree_finsetSum_le + intro D _ + exact (MvPolynomial.totalDegree_mul _ _).trans (by + simpa only [MvPolynomial.totalDegree_C,zero_add] using + (faceBinomial_totalDegree k D).trans (Nat.le_of_lt_succ (Finset.mem_range.mp hk))) + +omit [Fintype ι] [DecidableEq ι] in +lemma renamed_degree [Fintype ι] [DecidableEq ι] + {v : ℕ} (e : Option ι ≃ Fin v) (m : Exponent ι) : + (m.mapDomain e).sum (fun _ k => k)=degree m := by + exact Finsupp.sum_mapDomain_index (fun _ => rfl) (fun _ _ _ => rfl) + + + +theorem grid_irrationality {n v : ℕ} (c : RationalLattice.RealCoordinates G n) + (H : Filtration G) (S : ℕ→Set (Fin n)) + (hH : ∀ k (g : G),g∈H.level k ↔ ∀ i∈S k,c.coord g i=0) + (Γ : Subgroup G) (h01 : H.level 0=H.level 1) + (s : ℕ) (hs : H.level (s+1)=⊥) (e : Option ι≃Fin v) + (a : ℕ→∀ k : ℕ,H.level k) + (hirr : ∀ j : ℕ,0 < j → j ≤ s → ∀ ξ : H.level j→*Multiplicative ℝ, + ξ≠1 → Continuous ξ → RationalCharacter Γ ξ → + (∀ x (hx : x∈H.level (j+1)),ξ ⟨x,H.antitone (Nat.le_succ _) hx⟩=1) → + (∀ i k : ℕ,0 < i → 0 < k → ∀ h : i+k=j, + ∀ x (hx : x∈H.level i) y (hy : y∈H.level k), + ξ ⟨⁅x,y⁆,by rw [←h]; exact H.commutator_le i k (Subgroup.commutator_mem_commutator hx hy)⟩=1) → + Tendsto (fun N : ℕ => ‖((ξ (a N j)).toAdd:UnitAddCircle)‖*(N:ℝ)^j) + atTop atTop) + (χ : cube H (Finset.univ : Finset ι) 0→*Multiplicative ℝ) + (hχne : χ≠1) (hχ : Continuous χ) + (hχΓ : ∀ x : cube H (Finset.univ : Finset ι) 0, + (∀ w,(x:Finset ι→G) w∈Γ) → ∃ z : ℤ,(χ x).toAdd=z) : + ∃ b : ℕ→PolynomialLineCoefficients.Grid v s→ℝ, + (∀ N (x : Fin v→ℤ),gridEval (b N) (fun i => (x i:ℝ))= + (χ (cubePolynomial c H S hH (a N) s (fun i => (x (e i):ℝ)))).toAdd) ∧ + ∃ I,0 < PolynomialLineCoefficients.totalDegree I ∧ + Tendsto (fun N => circleNorm (b N I)*(N:ℝ)^(PolynomialLineCoefficients.totalDegree I)) atTop atTop := by + let p (N : ℕ) : MvPolynomial (Fin v) ℝ := rename e (scalarPolynomial H χ (a N) s) + have hp (N : ℕ) : (p N).totalDegree ≤ s := + (MvPolynomial.totalDegree_rename_le _ _).trans (scalarPolynomial_totalDegree H χ (a N) s) + refine ⟨fun N => polynomialGrid (p N),?_,?_⟩ + · intro N x + rw [gridEval_polynomial _ (hp N)] + exact (MvPolynomial.eval_rename _ _ _).trans (scalarPolynomial_eval c H S hH (a N) s _ χ hχ) + · obtain ⟨m,hm,hmS,hlim⟩ := coefficient_divergence H Γ h01 s hs a hirr χ hχne hχ hχΓ + have hm' : (m.mapDomain e).sum (fun _ k => k) ≤ s := by rwa [renamed_degree] + refine ⟨exponentGrid (m.mapDomain e) hm',?_,?_⟩ + · rwa [exponentGrid_degree,renamed_degree] + · simpa only [circleNorm,polynomialGrid,gridExponent_exponentGrid,p, + coeff_rename_mapDomain e e.injective,exponentGrid_degree,renamed_degree] using hlim + +end CubeHorizontalIrrationality +end +end + + + +section + +noncomputable section +open scoped BigOperators Topology commutatorElement +namespace CubeLocalHaar +open CubeFaces LeibmanSquare CubeTaylorExpansion CubeHorizontalIrrationality +open RationalLattice MeasureTheory Filter ComparableBoxLeibman MalcevCharacters AbelianMalcevTorus +variable {G ι : Type} [Group G] [TopologicalSpace G] [IsTopologicalGroup G] +variable [Fintype ι] [DecidableEq ι] + +lemma iterDiff_comp {A B K : Type*} [AddCommGroup A] [AddCommGroup B] [Group K] + (φ : A→+B) (f : B→K) (L : List A) : + iterDiff L (fun x => f (φ x))=fun x => iterDiff (L.map φ) f (φ x) := by + induction L generalizing f with + | nil => rfl + | cons h L ih => + rw [iterDiff,List.map_cons,iterDiff] + have he : diff h (fun x => f (φ x))=fun x => diff (φ h) f (φ x) := by + funext x + simp only [diff,map_add] + rw [he,ih] + +lemma polynomial_comp {A B K : Type*} [AddCommGroup A] [AddCommGroup B] [Group K] + (H : Filtration K) {k : ℕ} {f : B→K} (hf : LeibmanSquare.Polynomial H k f) + (φ : A→+B) : LeibmanSquare.Polynomial H k (fun x => f (φ x)) := by + intro L x + rw [iterDiff_comp] + simpa only [List.length_map] using hf (L.map φ) (φ x) + + + +def cubeLattice (H : Filtration G) (Γ : Subgroup G) : + Subgroup (cube H (Finset.univ : Finset ι) 0) where + carrier := {x | ∀ w,(x:Finset ι→G) w∈Γ} + one_mem' := fun _ => Γ.one_mem + mul_mem' hx hy := fun w => Γ.mul_mem (hx w) (hy w) + inv_mem' hx := fun w => Γ.inv_mem (hx w) + +variable {n t d v : ℕ} (c : RealCoordinates G n) (H : Filtration G) +variable (S : ℕ→Set (Fin n)) +variable (hH : ∀ k (g : G),g∈H.level k ↔ ∀ i∈S k,c.coord g i=0) +variable (Γ : Subgroup G) (h01 : H.level 0=H.level 1) +variable (s : ℕ) (hs : H.level (s+1)=⊥) (e : Option ι≃Fin v) +variable (cc : RealCoordinates (cube H (Finset.univ : Finset ι) 0) (t+d)) +variable (hsk : SecondKind cc) +variable (q : ℕ→ℕ) (hqbound : ∀ k,q k ≤ t+d) +variable (hq : ∀ k (g : cube H (Finset.univ : Finset ι) 0), + g∈(CubeMaxFiltration.filtration H Finset.univ).level k ↔ + ∀ i : Fin (t+d),i.val < q k → cc.coord g i=0) +variable (hΓ : ∀ g : cube H (Finset.univ : Finset ι) 0, + g∈cubeLattice H Γ ↔ ∀ i,∃ z : ℤ,cc.coord g i=z) +variable [MeasurableSpace ((cube H (Finset.univ : Finset ι) 0)⧸cubeLattice H Γ)] +variable [hBorel : @BorelSpace ((cube H (Finset.univ : Finset ι) 0)⧸cubeLattice H Γ) (QuotientGroup.instTopologicalSpace (cubeLattice H Γ)) inferInstance] +variable [mtr : MetricSpace ((cube H (Finset.univ : Finset ι) 0)⧸cubeLattice H Γ)] +variable (htop : mtr.toUniformSpace.toTopologicalSpace=QuotientGroup.instTopologicalSpace (cubeLattice H Γ)) +local instance : TopologicalSpace ((cube H (Finset.univ : Finset ι) 0)⧸cubeLattice H Γ) := + mtr.toUniformSpace.toTopologicalSpace + +include h01 hs hsk hqbound hq hΓ htop in + + +theorem haar_limit + (μ : Measure ((cube H (Finset.univ : Finset ι) 0)⧸cubeLattice H Γ)) + [IsProbabilityMeasure μ] + [SMulInvariantMeasure (cube H (Finset.univ : Finset ι) 0) _ μ] + (a : ℕ→∀ k : ℕ,H.level k) + (hirr : ∀ j : ℕ,0 < j → j ≤ s → ∀ ξ : H.level j→*Multiplicative ℝ, + ξ≠1 → Continuous ξ → RationalCharacter Γ ξ → + (∀ x (hx : x∈H.level (j+1)),ξ ⟨x,H.antitone (Nat.le_succ _) hx⟩=1) → + (∀ i k : ℕ,0 < i → 0 < k → ∀ h : i+k=j, + ∀ x (hx : x∈H.level i) y (hy : y∈H.level k), + ξ ⟨⁅x,y⁆,by rw [←h]; exact H.commutator_le i k (Subgroup.commutator_mem_commutator hx hy)⟩=1) → + Tendsto (fun N : ℕ => ‖((ξ (a N j)).toAdd:UnitAddCircle)‖*(N:ℝ)^j) + atTop atTop) + (c₀ C₀ : ℝ) (B : NNReal) (hc₀ : 0 ((r (e i)+(d₀:ℤ)*x (e i):ℤ):ℝ)))))-(∫ y,F y ∂μ)‖<η := by + let K := CubeMaxFiltration.filtration H (Finset.univ : Finset ι) + have hK0 : K.level 0=⊤ := CubeMaxFiltration.filtration_zero H Finset.univ + have hK1 : K.level 1=⊤ := CubeMaxFiltration.filtration_one H Finset.univ h01 + let : ∀ k,(K.level k).Normal := fun k => LeibmanSquare.level_normal K hK0 k + let φ : (Fin v→ℤ)→+(Option ι→ℝ) := + { toFun := fun x i => (x (e i):ℝ) + map_zero' := by ext; simp + map_add' := by intros; ext; simp } + let f (N : ℕ) (x : Fin v→ℤ) := cubePolynomial c H S hH (a N) s (φ x) + have hf (N : ℕ) : LeibmanSquare.Polynomial K 0 (f N) := + polynomial_comp K (cubePolynomial_adapted c H S hH (a N) s) φ + exact haar_limit_fixed_progression cc hsk K hK0 hK1 s + (CubeMaxFiltration.filtration_bot H Finset.univ hs) q hqbound hq + (cubeLattice H Γ) hΓ htop μ v f hf + (fun χ hn hc hχΓ => grid_irrationality c H S hH Γ h01 s hs e a hirr χ hn hc hχΓ) + c₀ C₀ B hc₀ hC₀ hB d₀ hd₀ r + +end CubeLocalHaar + +end +end +end +end +end + +end OAI diff --git a/lean/OAI/Combinatorics/SumProduct/Alignment/DenseBoolean01.lean b/lean/OAI/Combinatorics/SumProduct/Alignment/DenseBoolean01.lean new file mode 100644 index 0000000000000000000000000000000000000000..5079619651c98e00ec4de8d19cd99fab93c4a45a --- /dev/null +++ b/lean/OAI/Combinatorics/SumProduct/Alignment/DenseBoolean01.lean @@ -0,0 +1,277 @@ +import Mathlib +import OAI.Combinatorics.SumProduct.Alignment.RoughExtremal01 +import OAI.Geometry.NilpotentCharts.Main + +namespace OAI + +section +noncomputable section +end + +end + + +section + + + +noncomputable section +open Finset +open scoped BigOperators +namespace DenseBooleanCubes + +def PositiveCube (n : ℕ) (A : Finset ℕ) : Prop := + ∃ a : ℕ, ∃ h : Fin n → ℕ, (∀ i, 0 < h i) ∧ + ∀ z : Fin n → Bool, a + ∑ i, (if z i then h i else 0) ∈ A + + +lemma dense_shift (ε : ℝ) (hε : 0 < ε) (K : ℕ) (hK : 0 < K) + (A : Finset ℕ) (hA : A ⊆ range K) (hden : ε*K ≤ (A.card : ℝ)) + (hlarge : 2 ≤ ε*K) : + ∃ d : ℕ, 0 < d ∧ d ≤ K ∧ + (ε^2/4)*(K : ℝ) ≤ ((A.filter (fun x => x+d ∈ A)).card : ℝ) := by + let P := (A ×ˢ A).filter (fun p => p.1 < p.2) + have hmaps : ∀ p ∈ P, p.2-p.1 ∈ Icc 1 K := by + intro p hp + obtain ⟨hp, hlt⟩ := mem_filter.mp hp + obtain ⟨hx, hy⟩ := mem_product.mp hp + have hyK : p.2 < K := mem_range.mp (hA hy) + exact mem_Icc.mpr ⟨by omega, by omega⟩ + have hcount : (Icc 1 K).card • ((ε^2/4)*(K : ℝ)) ≤ (P.card : ℝ) := by + have hcard : (Icc 1 K).card = K := by simp + rw [hcard, nsmul_eq_mul] + dsimp only [P] + rw [card_product_filter_lt, Nat.cast_choose_two] + have ha2 : (2 : ℝ) ≤ A.card := hlarge.trans hden + have hsquare : (ε*(K : ℝ))^2 ≤ (A.card : ℝ)^2 := + pow_le_pow_left₀ (mul_nonneg hε.le (Nat.cast_nonneg K)) hden 2 + have harith : (K : ℝ) * (ε^2/4*K) = (ε*(K : ℝ))^2/4 := by ring + rw [harith] + nlinarith + obtain ⟨d, hd, hdb⟩ := exists_le_card_fiber_of_nsmul_le_card_of_maps_to + hmaps (nonempty_Icc.mpr hK) hcount + obtain ⟨hdpos, hdK⟩ := mem_Icc.mp hd + refine ⟨d, hdpos, hdK, ?_⟩ + have he : (P.filter (fun p => p.2-p.1=d)).card = (A.filter (fun x => x+d ∈ A)).card := by + apply card_bij (fun p _ => p.1) + · intro p hp + obtain ⟨hp, he⟩ := mem_filter.mp hp + obtain ⟨hp, hlt⟩ := mem_filter.mp hp + obtain ⟨hx, hy⟩ := mem_product.mp hp + apply mem_filter.mpr + refine ⟨hx, ?_⟩ + have hh : p.1+d=p.2 := by omega + rwa [hh] + · intro p hp q hq he + obtain ⟨hp, hpD⟩ := mem_filter.mp hp + obtain ⟨hq, hqD⟩ := mem_filter.mp hq + have hplt := (mem_filter.mp hp).2 + have hqlt := (mem_filter.mp hq).2 + exact Prod.ext he (by omega) + · intro x hx + obtain ⟨hx, hxd⟩ := mem_filter.mp hx + refine ⟨(x,x+d), ?_, rfl⟩ + exact mem_filter.mpr ⟨mem_filter.mpr ⟨mem_product.mpr ⟨hx,hxd⟩, by omega⟩, by simp⟩ + rwa [he] at hdb + + +lemma cube_of_shift (n : ℕ) (A : Finset ℕ) (d : ℕ) (hd : 0 < d) + (h : PositiveCube n (A.filter (fun x => x+d ∈ A))) : PositiveCube (n+1) A := by + obtain ⟨a, b, hb, hcube⟩ := h + refine ⟨a, Fin.cons d b, ?_, ?_⟩ + · intro i + refine Fin.cases hd (fun j => ?_) i + exact hb j + · intro z + have hx := mem_filter.mp (hcube (fun j => z j.succ)) + rw [Fin.sum_univ_succ] + simp only [Fin.cons_zero, Fin.cons_succ] + cases hz : z 0 + · simpa [hz] using hx.1 + · simpa [hz, add_assoc, add_comm, add_left_comm] using hx.2 + +theorem dense_positive_cube (n : ℕ) (ε : ℝ) (hε : 0 < ε) : + ∃ N : ℕ, 0 < N ∧ ∀ K : ℕ, N ≤ K → ∀ A : Finset ℕ, A ⊆ range K → + ε*K ≤ (A.card : ℝ) → PositiveCube n A := by + induction n generalizing ε with + | zero => + refine ⟨1, by omega, ?_⟩ + intro K hK A hA hden + have hc : 0 < A.card := by + have hkr : (0 : ℝ) < K := by exact_mod_cast hK + have hc : (0 : ℝ) < A.card := (mul_pos hε hkr).trans_le hden + exact_mod_cast hc + obtain ⟨a, ha⟩ := card_pos.mp hc + refine ⟨a, Fin.elim0, (fun i => Fin.elim0 i), ?_⟩ + intro z + simpa using ha + | succ n ih => + have hδ : 0 < ε^2/4 := by positivity + obtain ⟨N, hN, hn⟩ := ih (ε^2/4) hδ + obtain ⟨L, hL⟩ := exists_nat_gt (2/ε) + refine ⟨max N L, lt_of_lt_of_le hN (le_max_left _ _), ?_⟩ + intro K hK A hA hden + have hKN : N ≤ K := (le_max_left _ _).trans hK + have hKL : L ≤ K := (le_max_right _ _).trans hK + have hKpos : 0 < K := hN.trans_le hKN + have hlarge : 2 ≤ ε*(K : ℝ) := by + have hLK : (L : ℝ) ≤ K := by exact_mod_cast hKL + have hh := (div_lt_iff₀ hε).mp hL + nlinarith + obtain ⟨d, hd, hdK, hdb⟩ := dense_shift ε hε K hKpos A hA hden hlarge + apply cube_of_shift n A d hd + exact hn K hKN _ ((filter_subset _ _).trans hA) hdb + + + + +def blockResidues (A : Finset ℕ) (K q : ℕ) : Finset ℕ := + (A.filter (fun i=>i/K=q)).image (fun i=>i%K) + +lemma blockResidues_subset (A : Finset ℕ) {K : ℕ} (hK : 0i/K=q)).card:=by + classical + apply card_image_iff.mpr + intro i hi j hj he + have hiq: i/K=q:=(mem_filter.mp hi).2 + have hjq: j/K=q:=(mem_filter.mp hj).2 + have hh:=Nat.mod_add_div i K + have hh':=Nat.mod_add_div j K + change i%K=j%K at he + rw [hiq] at hh + rw [hjq] at hh' + omega + +lemma mem_from_residue {A : Finset ℕ} {K q a : ℕ} + (ha : a∈blockResidues A K q) : q*K+a∈A:=by + obtain ⟨i,hi,he⟩:=mem_image.mp ha + obtain ⟨hiA,hiq⟩:=mem_filter.mp hi + have hx : q*K+a=i:=by nlinarith [Nat.mod_add_div i K] + rwa [hx] + +lemma dense_block (ε : ℝ) (hε : 0 < ε) (K N : ℕ) (_ : 0 < K) (hKN : K ≤ N) + (A : Finset ℕ) (hA : A ⊆ range N) (hden : ε*N ≤ (A.card : ℝ)) : + ∃ q : ℕ, (ε/2)*(K : ℝ) ≤ ((blockResidues A K q).card : ℝ) := by + have hmaps : ∀ i ∈ A, i/K ∈ range (N/K+1) := by + intro i hi + exact mem_range.mpr (Nat.lt_succ_of_le (Nat.div_le_div_right (mem_range.mp (hA hi)).le)) + have hcount : (range (N/K+1)).card • ((ε/2)*(K : ℝ)) ≤ (A.card : ℝ) := by + rw [card_range, nsmul_eq_mul] + have hdiv : ((N/K : ℕ) : ℝ)*(K : ℝ) ≤ N := by exact_mod_cast Nat.div_mul_le_self N K + have hkn : (K : ℝ) ≤ N := by exact_mod_cast hKN + have h := mul_le_mul_of_nonneg_left (add_le_add hdiv hkn) hε.le + push_cast + nlinarith + obtain ⟨q, _, hq⟩ := exists_le_card_fiber_of_nsmul_le_card_of_maps_to + hmaps (show (range (N/K+1)).Nonempty from ⟨0, mem_range.mpr (Nat.zero_lt_succ _)⟩) hcount + refine ⟨q, ?_⟩ + rwa [blockResidues_card] + +theorem dense_bounded_positive_cube (n : ℕ) (ε : ℝ) (hε : 0 < ε) : + ∃ K : ℕ, 0 < K ∧ ∀ N : ℕ, K ≤ N → ∀ A : Finset ℕ, A ⊆ range N → + ε*N ≤ (A.card : ℝ) → ∃ a : ℕ, ∃ h : Fin n → ℕ, + (∀ i, 0 < h i ∧ h i ≤ K) ∧ + ∀ z : Fin n → Bool, a + ∑ i, (if z i then h i else 0) ∈ A := by + obtain ⟨K, hK, hcube⟩ := dense_positive_cube n (ε/2) (by positivity) + refine ⟨K, hK, ?_⟩ + intro N hKN A hA hden + obtain ⟨q, hq⟩ := dense_block ε hε K N hK hKN A hA hden + obtain ⟨a, h, hh, hverts⟩ := hcube K le_rfl (blockResidues A K q) + (blockResidues_subset A hK q) hq + refine ⟨q*K+a, h, ?_, ?_⟩ + · intro i + refine ⟨hh i, ?_⟩ + have hv := hverts (fun j => decide (j=i)) + have hvK := mem_range.mp (blockResidues_subset A hK q hv) + have he : (∑ j : Fin n, if decide (j=i) then h j else 0) = h i := by simp + rw [he] at hvK + omega + · intro z + have hv := mem_from_residue (hverts z) + simpa only [Nat.add_assoc] using hv + +namespace CubeSubspace +open Combinatorics +variable {n N : ℕ} (l : Subspace (Fin n) Bool (Fin N)) (h : Fin N → ℕ) + +def offset : ℕ := ∑ i, if l.idxFun i = Sum.inl true then h i else 0 + +def weight (j : Fin n) : ℕ := ∑ i, if l.idxFun i = Sum.inr j then h i else 0 + +lemma value (z : Fin n → Bool) : + (∑ i, if l z i then h i else 0) = offset l h + ∑ j, if z j then weight l h j else 0 := by + have hs : (∑ j, if z j then weight l h j else 0) = + ∑ i, ∑ j, if l.idxFun i = Sum.inr j then (if z j then h i else 0) else 0 := by + rw [sum_comm] + apply sum_congr rfl + intro j _ + cases hz : z j <;> simp [weight] + rw [hs, offset, ← sum_add_distrib] + apply sum_congr rfl + intro i _ + cases hi : l.idxFun i with + | inl b => cases b <;> simp [Subspace.coe_apply, hi] + | inr j => simp [Subspace.coe_apply, hi] + +lemma weight_pos (hh : ∀ i, 0 < h i) (j : Fin n) : 0 < weight l h j := by + obtain ⟨i, hi⟩ := l.proper j + have hv : h i ≤ weight l h j := by + dsimp [weight] + have hv := single_le_sum (fun k (_ : k ∈ (univ : Finset (Fin N))) => + Nat.zero_le (if l.idxFun k = Sum.inr j then h k else 0)) (mem_univ i) + simpa [hi] using hv + exact (hh i).trans_le hv + +lemma weight_le (K : ℕ) (hh : ∀ i, h i ≤ K) (j : Fin n) : weight l h j ≤ N*K := by + calc + _ ≤ ∑ _i : Fin N, K := sum_le_sum (fun i _ => by + split_ifs + · exact hh i + · exact Nat.zero_le _) + _ = N*K := by simp + +end CubeSubspace + + +theorem colored_subcube (n : ℕ) (κ : Type*) [Finite κ] : + ∃ N : ℕ, ∀ C : (Fin N → Bool) → κ, + ∃ l : Combinatorics.Subspace (Fin n) Bool (Fin N), l.IsMono C := + Combinatorics.Subspace.exists_mono_in_high_dimension_fin Bool κ (Fin n) + +theorem dense_colored_bounded_cube (n : ℕ) (κ : Type*) [Finite κ] + (ε : ℝ) (hε : 0 < ε) : + ∃ K : ℕ, 0 < K ∧ ∀ N : ℕ, K ≤ N → ∀ A : Finset ℕ, A ⊆ range N → + ε*N ≤ (A.card : ℝ) → ∀ C : ℕ → κ, + ∃ a : ℕ, ∃ h : Fin n → ℕ, ∃ c : κ, + (∀ i, 0 < h i ∧ h i ≤ K) ∧ + ∀ z : Fin n → Bool, a + ∑ i, (if z i then h i else 0) ∈ A ∧ + C (a + ∑ i, (if z i then h i else 0)) = c := by + obtain ⟨m, hm⟩ := colored_subcube n κ + obtain ⟨K, hK, hcube⟩ := dense_bounded_positive_cube m ε hε + refine ⟨(m+1)*K, by positivity, ?_⟩ + intro N hN A hA hden C + have hKN : K ≤ N := (by nlinarith : K ≤ (m+1)*K).trans hN + obtain ⟨a, h, hh, hverts⟩ := hcube N hKN A hA hden + obtain ⟨l, c, hc⟩ := hm (fun z => C (a+∑ i, if z i then h i else 0)) + refine ⟨a+CubeSubspace.offset l h, CubeSubspace.weight l h, c, ?_, ?_⟩ + · intro j + exact ⟨CubeSubspace.weight_pos l h (fun i => (hh i).1) j, + (CubeSubspace.weight_le l h K (fun i => (hh i).2) j).trans (by nlinarith)⟩ + · intro z + have he : a+CubeSubspace.offset l h + ∑ j, (if z j then CubeSubspace.weight l h j else 0) = + a + ∑ i, if l z i then h i else 0 := by rw [CubeSubspace.value, Nat.add_assoc] + rw [he] + exact ⟨hverts (l z), hc z⟩ + +end DenseBooleanCubes + +end +end + +end OAI diff --git a/lean/OAI/Combinatorics/SumProduct/Alignment/DenseBox01.lean b/lean/OAI/Combinatorics/SumProduct/Alignment/DenseBox01.lean new file mode 100644 index 0000000000000000000000000000000000000000..350d943e3418221a94dc0c987ba049d0e169432c --- /dev/null +++ b/lean/OAI/Combinatorics/SumProduct/Alignment/DenseBox01.lean @@ -0,0 +1,278 @@ +import Mathlib +import OAI.Combinatorics.SumProduct.Alignment.BoxPolynomial01 +import OAI.Geometry.NilpotentCharts.Main + +namespace OAI + +section +section +section +section +namespace DenseBoxComplete +open scoped BigOperators +open Finset PolynomialLineCoefficients TriangularLatticeRecovery DenseBoxModularPolynomial +noncomputable section + +lemma degree_eq_zero {n d : ℕ} (e : Grid n d) : totalDegree e = 0 ↔ e = 0 := by + constructor + · intro h + funext i + apply Fin.ext + have hh := Finset.single_le_sum (f := fun i => (e i).val) + (fun j _ => Nat.zero_le _) (Finset.mem_univ i) + change _ ≤ totalDegree e at hh + simpa [h] using hh + · rintro rfl + simp [totalDegree] + +lemma monomial_bound {n d N : ℕ} (e : Grid n d) (x : Fin n → ℕ) + (hx : ∀ i, x i ≤ N) : (∏ i, (x i : ℝ)^(e i).val) ≤ (N:ℝ)^totalDegree e := by + rw [totalDegree,← Finset.prod_pow_eq_pow_sum] + exact Finset.prod_le_prod₀ (fun i _ => pow_nonneg (Nat.cast_nonneg _) _) + (fun i _ => pow_le_pow_left₀ (Nat.cast_nonneg _) (Nat.cast_le.mpr (hx i)) _) + +lemma constant_coefficient {n d N q : ℕ} (a : Grid n d → ℝ) (x : Fin n → ℕ) + (hx : ∀ i, x i ≤ N) (ε A : ℝ) (hA : 0 ≤ A) (hnear : circleNorm (eval a x) ≤ ε) + (hcoeff : ∀ e : Grid n d, 0 < totalDegree e → + circleNorm ((q:ℝ)*a e)*(N:ℝ)^totalDegree e ≤ A) : + circleNorm ((q:ℝ)*a 0) ≤ (q:ℝ)*ε + (Fintype.card (Grid n d):ℝ)*A := by + classical + let b : Grid n d → ℝ := fun e => (q:ℝ)*a e + let S := (Finset.univ : Finset (Grid n d)).erase 0 + have heval : eval b x = (q:ℝ)*eval a x := by + simp only [DenseBoxModularPolynomial.eval,b,Finset.mul_sum,mul_assoc] + have heq : b 0 = eval b x - ∑ e ∈ S, b e * ∏ i, (x i:ℝ)^(e i).val := by + have h := Finset.sum_erase_add (s := (Finset.univ : Finset (Grid n d))) + (fun e => b e*∏ i, (x i:ℝ)^(e i).val) (Finset.mem_univ (0:Grid n d)) + simp only [Pi.zero_apply,Fin.val_zero,pow_zero,Finset.prod_const_one,mul_one] at h + change (∑ e ∈ S, b e*∏ i, (x i:ℝ)^(e i).val) + b 0 = eval b x at h + linarith only [h] + have hsum : circleNorm (∑ e ∈ S, b e*∏ i, (x i:ℝ)^(e i).val) ≤ + (S.card:ℝ)*A := by + apply (circleNorm_sum_le S _).trans + calc + _ ≤ ∑ _e ∈ S, A := by + apply Finset.sum_le_sum + intro e he + have hepos : 0 < totalDegree e := Nat.pos_of_ne_zero (mt (degree_eq_zero e).mp + (Finset.mem_erase.mp he).1) + have hc := circleNorm_nat_mul (∏ i, x i^(e i).val) (b e) + simp only [Nat.cast_prod,Nat.cast_pow] at hc + rw [mul_comm (b e)] + exact hc.trans ((mul_le_mul_of_nonneg_right (monomial_bound e x hx) + (circleNorm_nonneg _)).trans (by simpa only [b, mul_comm] using hcoeff e hepos)) + _ = _ := by simp + have hsum' : circleNorm (∑ e ∈ S, b e*∏ i, (x i:ℝ)^(e i).val) ≤ + (Fintype.card (Grid n d):ℝ)*A := + hsum.trans (mul_le_mul_of_nonneg_right (by exact_mod_cast S.card_le_univ) hA) + change circleNorm (b 0) ≤ _ + rw [heq] + calc + _ ≤ circleNorm (eval b x) + circleNorm (∑ e ∈ S, b e*∏ i, (x i:ℝ)^(e i).val) := + circleNorm_sub_le _ _ + _ ≤ (q:ℝ)*ε + (Fintype.card (Grid n d):ℝ)*A := by + apply add_le_add _ hsum' + rw [heval] + exact (circleNorm_nat_mul q _).trans (mul_le_mul_of_nonneg_left hnear (Nat.cast_nonneg _)) + + + +theorem lattice_inverse_all (n d : ℕ) (δ : ℝ) (hδ : 0 < δ) : + ∃ C N₀ : ℕ, 0 < C ∧ 0 < N₀ ∧ ∃ ε₀ : ℝ, 0 < ε₀ ∧ + ∀ N : ℕ, N₀ ≤ N → ∀ ε : ℝ, 0 ≤ ε → ε ≤ ε₀ → + ∀ S : Set (Fin n → ℕ), ∀ a : Grid n d → ℝ, + (∀ x ∈ S, ∃ z : ℤ, |eval a x-z| ≤ ε) → + δ*(N:ℝ)^n ≤ (BoxCounting.count n N S:ℝ) → + ∃ q : ℕ, 0 < q ∧ q ≤ C ∧ ∀ e : Grid n d, + circleNorm ((q:ℝ)*a e)*(N:ℝ)^totalDegree e ≤ (C:ℝ)*ε := by + classical + obtain ⟨C,N₀,hC,hN₀,ε₀,hε₀,h⟩ := lattice_inverse_cardinal n d δ hδ + let C' := C*(1+Fintype.card (Grid n d)) + have hCC' : C ≤ C' := by + dsimp [C'] + simpa only [mul_one] using Nat.mul_le_mul_left C + (Nat.le_add_right 1 (Fintype.card (Grid n d))) + refine ⟨C',N₀,hC.trans_le hCC',hN₀,ε₀,hε₀,?_⟩ + intro N hN ε hε hεsmall S a hgood hcount + obtain ⟨q,hq,hqC,hqa⟩ := h N hN ε hε hεsmall S a hgood hcount + have hcountpos : 0 < BoxCounting.count n N S := by + exact_mod_cast (lt_of_lt_of_le (mul_pos hδ (pow_pos + (Nat.cast_pos.mpr (hN₀.trans_le hN)) _)) hcount) + obtain ⟨x,hx⟩ := Finset.card_pos.mp hcountpos + change x ∈ (univ.filter (fun x : Fin n → Fin N => (fun i => (x i).val) ∈ S)) at hx + obtain ⟨z,hz⟩ := hgood (fun i => (x i).val) (Finset.mem_filter.mp hx).2 + have hnear := (circleNorm_le_integer_error (eval a (fun i => (x i).val)) z).trans hz + have hc := constant_coefficient a (fun i => (x i).val) (fun i => (x i).isLt.le) + ε ((C:ℝ)*ε) (by positivity) hnear hqa + refine ⟨q,hq,hqC.trans hCC',?_⟩ + intro e + by_cases he : e = 0 + · subst e + simp only [(degree_eq_zero (0:Grid n d)).mpr rfl,pow_zero,mul_one] + calc + _ ≤ (q:ℝ)*ε + (Fintype.card (Grid n d):ℝ)*((C:ℝ)*ε) := hc + _ ≤ (C:ℝ)*ε + (Fintype.card (Grid n d):ℝ)*((C:ℝ)*ε) := by gcongr + _ = (C':ℝ)*ε := by dsimp [C']; push_cast; ring + · exact (hqa e (Nat.pos_of_ne_zero (mt (degree_eq_zero e).mp he))).trans + (mul_le_mul_of_nonneg_right (Nat.cast_le.mpr hCC') hε) + +end +end DenseBoxComplete +end + + + +section +noncomputable section +namespace SquareInduction + +theorem finite_dense_choice_general {α β : Type*} (U : Finset α) (S : Finset β) + (ρ T : ℝ) (hρ : 0<ρ) (hT : 0 if hh : h∈S then a h hh else a₀ + have hmap : ∀ h∈S, f h∈U := by + intro h hh + simpa only [f,dite_eq_left hh] using ha h hh + have hcard : U.card • (ρ/((U.card:ℝ)+1)*T) ≤ (S.card:ℝ) := by + rw [nsmul_eq_mul] + have hu : (U.card:ℝ)/((U.card:ℝ)+1) ≤ 1 := by + apply (div_le_one (by positivity)).mpr + linarith + calc + _ = ((U.card:ℝ)/((U.card:ℝ)+1))*(ρ*T) := by ring + _ ≤ 1*(ρ*T) := mul_le_mul_of_nonneg_right hu (mul_pos hρ hT).le + _ ≤ _ := by simpa only [one_mul] using hS + obtain ⟨a',ha',hfiber⟩ := Finset.exists_le_card_fiber_of_nsmul_le_card_of_maps_to hmap ⟨a₀,ha₀⟩ hcard + let B := S.filter (fun h => f h=a') + refine ⟨B,Finset.filter_subset _ _,?_,hfiber,a',ha',?_⟩ + · apply Finset.card_pos.mp + have hp : 0<ρ/((U.card:ℝ)+1)*T := by positivity + exact_mod_cast hp.trans_le hfiber + · intro h hh + have hhS := (Finset.mem_filter.mp hh).1 + have he : a h hhS=a' := by simpa only [f,dite_eq_left hhS] using (Finset.mem_filter.mp hh).2 + exact he ▸ hPa h hhS + +end SquareInduction +end +end + + + +section +noncomputable section +open scoped BigOperators +namespace CorrectedBoxLeibman +open PolynomialWeyl BoxPolynomialLines + + +lemma dense_large_values {α : Type*} [Fintype α] [Nonempty α] + (f : α→ℂ) (hf : ∀ x, ‖f x‖≤1) (δ : ℝ) (hδ : 0<δ) + (hm : 3*δ/4 ≤ ‖𝔼 x : α, f x‖) : + δ/4*(Fintype.card α:ℝ) ≤ + ((Finset.univ.filter (fun x => δ/2≤‖f x‖)).card:ℝ) := by + classical + let S := Finset.univ.filter (fun x => δ/2≤‖f x‖) + have hsum : (∑ x : α, ‖f x‖) ≤ (Fintype.card α:ℝ)*(δ/2)+(S.card:ℝ) := by + calc + _ ≤ ∑ x : α, (δ/2+(if x∈S then (1:ℝ) else 0)) := by + apply Finset.sum_le_sum + intro x _ + by_cases hx : x∈S + · rw [ite_eq_left hx]; linarith [hf x] + · rw [ite_eq_right hx]; have hn : ¬δ/2≤‖f x‖ := by simpa [S] using hx + linarith + _ = _ := by simp [Finset.sum_add_distrib,S,Finset.sum_boole] + have hnorm := hm.trans (RCLike.norm_expect_le (K:=ℂ) (s:=Finset.univ) (f:=f)) + rw [Finset.expect_eq_sum_div_card,Finset.card_univ] at hnorm + have hc : 0<(Fintype.card α:ℝ) := Nat.cast_pos.mpr Fintype.card_pos + have hlow := (le_div_iff₀ hc).mp hnorm + change δ/4*(Fintype.card α:ℝ) ≤ (S.card:ℝ) + nlinarith only [hsum,hlow] + + + +theorem dense_correlated_lines (v : ℕ) {N H : ℕ} (hN : 0 + δ/2≤‖mean H (fun z => f (fun i => (x i).val+z*q i))‖)).card:ℝ) := by + classical + let : NeZero N := ⟨ne_of_gt hN⟩ + let F (x : Fin v→Fin N) := mean H (fun z => f (fun i => (x i).val+z*q i)) + have hF (x) : ‖F x‖≤1 := by + apply (RCLike.norm_expect_le (K:=ℂ)).trans + exact Finset.expect_le (Finset.nonempty_range_iff.mpr (ne_of_gt hH)) (fun z _ => hf _) + have her := (line_average_error v hN hH f hf q).trans hshort + rw [BoxCounting.boxMean_eq_fin] at her + have htri := norm_sub_le_norm_sub_add_norm_sub (boxMean v N f) (𝔼 x : Fin v→Fin N, F x) 0 + simp only [sub_zero] at htri + rw [norm_sub_rev] at her + have hav : 3*δ/4 ≤ ‖𝔼 x : Fin v→Fin N, F x‖ := by + change ‖boxMean v N f-(𝔼 x : Fin v→Fin N, F x)‖≤δ/4 at her + linarith only [htri,her,hdisc] + simpa only [Fintype.card_fun,Fintype.card_fin,Nat.cast_pow] using + dense_large_values F hF δ hδ hav + +end CorrectedBoxLeibman +end +end + + + +section +noncomputable section +namespace LeibmanSquare +open CubeFaces +variable {A B G : Type*} [AddCommGroup A] [AddCommGroup B] [Group G] + + +lemma iterDiff_affine (φ : A→+B) (x : B) (hs : List A) (f : B→G) : + iterDiff hs (fun z => f (x+φ z)) = fun z => iterDiff (hs.map φ) f (x+φ z) := by + induction hs generalizing f with + | nil => rfl + | cons h hs ih => + change iterDiff hs (diff h (fun z => f (x+φ z))) = _ + have he : diff h (fun z => f (x+φ z)) = fun z => diff (φ h) f (x+φ z) := by + funext z + simp only [diff,map_add] + rw [add_assoc] + rw [he,ih] + rfl + +lemma polynomial_affine (H : Filtration G) {k : ℕ} {f : B→G} + (hf : Polynomial H k f) (φ : A→+B) (x : B) : + Polynomial H k (fun z => f (x+φ z)) := by + intro hs z + rw [iterDiff_affine] + simpa only [List.length_map] using hf (hs.map φ) (x+φ z) + + +def integerDirection {v : ℕ} (q : Fin v→ℤ) : ℤ→+(Fin v→ℤ) where + toFun z := fun i => z*q i + map_zero' := by ext i; simp + map_add' a b := by ext i; simp [add_mul] + +lemma polynomial_integer_line (H : Filtration G) {v k : ℕ} {f : (Fin v→ℤ)→G} + (hf : Polynomial H k f) (x q : Fin v→ℤ) : + Polynomial H k (fun z => f (fun i => x i+z*q i)) := + polynomial_affine H hf (integerDirection q) x + +end LeibmanSquare + +end +end +end +end +end + +end OAI diff --git a/lean/OAI/Combinatorics/SumProduct/Alignment/DensePolynomial01.lean b/lean/OAI/Combinatorics/SumProduct/Alignment/DensePolynomial01.lean new file mode 100644 index 0000000000000000000000000000000000000000..93e1e57edbc5a7891a86d9fecdfec02ee2946ab3 --- /dev/null +++ b/lean/OAI/Combinatorics/SumProduct/Alignment/DensePolynomial01.lean @@ -0,0 +1,324 @@ +import Mathlib +import OAI.Combinatorics.SumProduct.Alignment.FejerDetection01 +import OAI.Geometry.NilpotentCharts.Main + +namespace OAI + +section +section +section +section +open _root_.Polynomial _root_.OAI.Polynomial Finset +open scoped BigOperators +namespace DensePolynomialInterpolation +open _root_.Polynomial _root_.OAI.Polynomial Finset +noncomputable section + +def uniformBound (q : ℕ) (α : ℝ) : ℝ := (q+1) * (2*(q+1)/α)^q + +lemma nodes_injective {q N : ℕ} {α : ℝ} (hN : 0 < N) (hα : 0 < α) + (v : Fin (q+1) → ℤ) + (hsep : ∀ i j, i ≠ j → α * N / (2 * (q+1)) ≤ |(v i : ℝ) - v j|) : + Function.Injective (fun i => (v i : ℝ)) := by + intro i j hij + by_contra hne + have h := hsep i j hne + dsimp only at hij + rw [hij, sub_self, abs_zero] at h + have : 0 < α * N / (2 * (q+1)) := by positivity + linarith + +lemma interpolation_error {q N : ℕ} {α : ℝ} (hN : 0 < N) (hα : 0 < α) + (v : Fin (q+1) → ℤ) (hv : ∀ i, (v i : ℝ) ∈ Set.Icc 0 (N : ℝ)) + (hsep : ∀ i j, i ≠ j → α * N / (2 * (q+1)) ≤ |(v i : ℝ) - v j|) + (T : ℝ[X]) (hT : T.natDegree ≤ q) (r : Fin (q+1) → ℝ) + {ε : ℝ} (hε : 0 ≤ ε) (hr : ∀ i, |r i - T.eval (v i : ℝ)| ≤ ε) + {x : ℝ} (hx : x ∈ Set.Icc 0 (N : ℝ)) : + |(Lagrange.interpolate univ (fun i => (v i : ℝ)) r).eval x - T.eval x| ≤ + uniformBound q α * ε := by + have hdeg : T.degree < ((univ : Finset (Fin (q+1))).card : WithBot ℕ) := by + simp only [card_univ, Fintype.card_fin] + exact lt_of_le_of_lt (degree_le_natDegree.trans + (show (T.natDegree : WithBot ℕ) ≤ (q : WithBot ℕ) by exact_mod_cast hT)) + (by exact_mod_cast Nat.lt_succ_self q) + have h := LagrangeBounds.interpolate_error univ (fun i => (v i : ℝ)) + (nodes_injective hN hα v hsep).injOn + (by positivity : (0 : ℝ) < α * N / (2 * (q+1))) hε + (fun i _ => hv i) (fun i _ j _ hji => hsep i j hji.symm) hx T hdeg r (fun i _ => hr i) + have heq : ((N : ℝ) - 0) / (α * N / (2 * (q+1))) = 2 * (q+1) / α := by + have hn : (N : ℝ) ≠ 0 := by positivity + field_simp + simp + rw [heq] at h + simpa only [uniformBound, card_univ, Fintype.card_fin, Nat.cast_add, Nat.cast_one, + Nat.add_sub_cancel] using h + + +def normalizedNode (d : ℕ) (i : Fin (d+1)) : ℝ := i.val / (d+1) + +lemma normalizedNode_injective (d : ℕ) : Function.Injective (normalizedNode d) := by + intro i j hij + apply Fin.ext + have hden : (d:ℝ)+1 ≠ 0 := by positivity + have h : (i.val:ℝ) = j.val := (div_left_inj' hden).mp hij + exact_mod_cast h + +lemma normalizedNode_mem (d : ℕ) (i : Fin (d+1)) : + normalizedNode d i ∈ Set.Icc (0:ℝ) 1 := by + constructor + · dsimp [normalizedNode]; positivity + · dsimp [normalizedNode] + apply (div_le_one (by positivity : (0:ℝ) < d+1)).mpr + exact_mod_cast i.isLt.le + +def coefficientConstant (d : ℕ) : ℝ := 1 + + ∑ j ∈ range (d+1), ∑ i : Fin (d+1), + |(Lagrange.basis univ (normalizedNode d) i).coeff j| + +lemma coefficientConstant_pos (d : ℕ) : 0 < coefficientConstant d := by + have h : 0 ≤ ∑ j ∈ range (d+1), ∑ i : Fin (d+1), + |(Lagrange.basis univ (normalizedNode d) i).coeff j| := + sum_nonneg (fun _ _ => sum_nonneg (fun _ _ => abs_nonneg _)) + dsimp [coefficientConstant] + linarith + +lemma coefficient_bound_unit (d : ℕ) (p : ℝ[X]) (hp : p.natDegree ≤ d) + (ε : ℝ) (hε : 0 ≤ ε) (hv : ∀ x ∈ Set.Icc (0:ℝ) 1, |p.eval x| ≤ ε) + (j : ℕ) (hj : j ≤ d) : |p.coeff j| ≤ coefficientConstant d * ε := by + have hdeg : p.degree < ((univ : Finset (Fin (d+1))).card : WithBot ℕ) := by + simp only [card_univ,Fintype.card_fin] + exact lt_of_le_of_lt (degree_le_natDegree.trans (show (p.natDegree : WithBot ℕ) ≤ (d : WithBot ℕ) by exact_mod_cast hp)) + (by exact_mod_cast Nat.lt_succ_self d) + have he := Lagrange.eq_interpolate (normalizedNode_injective d).injOn hdeg + conv_lhs => rw [he] + rw [Lagrange.interpolate_apply,finsetSum_coeff] + calc + _ ≤ ∑ i : Fin (d+1), ε * |(Lagrange.basis univ (normalizedNode d) i).coeff j| := by + apply (abs_sum_le_sum_abs _ _).trans + apply sum_le_sum + intro i _ + rw [coeff_C_mul,abs_mul] + exact mul_le_mul_of_nonneg_right (hv _ (normalizedNode_mem d i)) (abs_nonneg _) + _ = (∑ i : Fin (d+1), |(Lagrange.basis univ (normalizedNode d) i).coeff j|)*ε := by + rw [← mul_sum,mul_comm] + _ ≤ coefficientConstant d * ε := by + refine mul_le_mul_of_nonneg_right ?_ hε + have h : (∑ i : Fin (d+1), |(Lagrange.basis univ (normalizedNode d) i).coeff j|) ≤ + ∑ k ∈ range (d+1), ∑ i : Fin (d+1), + |(Lagrange.basis univ (normalizedNode d) i).coeff k| := + single_le_sum (fun (k : ℕ) (_ : k ∈ range (d+1)) => + sum_nonneg (fun (i:Fin (d+1)) _ => + abs_nonneg ((Lagrange.basis univ (normalizedNode d) i).coeff k))) + (mem_range.mpr (Nat.lt_succ_of_le hj)) + exact h.trans (le_add_of_nonneg_left zero_le_one) + +lemma coefficient_bound_span (d : ℕ) (p : ℝ[X]) (hp : p.natDegree ≤ d) + (N ε : ℝ) (hN : 0 < N) (hε : 0 ≤ ε) + (hv : ∀ x ∈ Set.Icc 0 N, |p.eval x| ≤ ε) (j : ℕ) (hj : j ≤ d) : + |p.coeff j| ≤ coefficientConstant d * ε / N^j := by + let P := p.comp (C N * X) + have hP : P.natDegree ≤ d := by + have hdeg : (C N * X : ℝ[X]).natDegree = 1 := natDegree_C_mul_X N hN.ne' + exact (natDegree_comp_le.trans (by rw [hdeg,Nat.mul_one])).trans hp + have h := coefficient_bound_unit d P hP ε hε (by + intro x hx + simp only [P,eval_comp,eval_mul,eval_C,eval_X] + apply hv + constructor + · exact mul_nonneg hN.le hx.1 + · nlinarith [hx.2]) j hj + have hcoef : P.coeff j = p.coeff j * N^j := by + simp only [P,comp_C_mul_X_coeff] + rw [hcoef,abs_mul,abs_of_nonneg (pow_nonneg hN.le j)] at h + exact (le_div_iff₀ (pow_pos hN j)).mpr h + + +theorem dense_coefficient_bound (d N : ℕ) (hN : 0 < N) (α ε : ℝ) + (hα : 0 < α) (hε : 0 ≤ ε) (E : Finset ℤ) + (hlarge : 2*(d+1) ≤ E.card) (hdens : α*N ≤ (E.card:ℝ)) + (hEN : ∀ n ∈ E, (n:ℝ) ∈ Set.Icc 0 (N:ℝ)) + (p : ℝ[X]) (hp : p.natDegree ≤ d) + (hsmall : ∀ n ∈ E, |p.eval (n:ℝ)| ≤ ε) + (j : ℕ) (hj : j ≤ d) : + |p.coeff j| ≤ coefficientConstant d * uniformBound d α * ε / (N:ℝ)^j := by + obtain ⟨v,hv,hsep⟩ := DenseIntegerNodes.separated_of_density E d hlarge hdens + have hub : 0 ≤ uniformBound d α := by dsimp [uniformBound]; positivity + have hsup : ∀ x ∈ Set.Icc 0 (N:ℝ), |p.eval x| ≤ uniformBound d α * ε := by + intro x hx + have h := interpolation_error hN hα v (fun i => hEN _ (hv i)) + hsep p hp (fun _ => 0) hε (by intro i; simpa using hsmall _ (hv i)) hx + simpa [Lagrange.interpolate_apply] using h + have h := coefficient_bound_span d p hp N _ (Nat.cast_pos.mpr hN) + (mul_nonneg hub hε) hsup j hj + simpa only [mul_assoc] using h + + + +theorem bounded_lattice_coefficients (d N B : ℕ) (hN : 0 < N) (δ ε : ℝ) + (hδ : 0 < δ) (hε : 0 ≤ ε) (hεone : ε ≤ 1) + (hlarge : (2*(d+1):ℝ) ≤ δ*N/(2*B+3)) + (S : Finset ℤ) (hdens : δ*N ≤ (S.card:ℝ)) + (hSN : ∀ n ∈ S, (n:ℝ) ∈ Set.Icc 0 (N:ℝ)) + (p : ℝ[X]) (hp : p.natDegree ≤ d) + (hbound : ∀ n ∈ S, |p.eval (n:ℝ)| ≤ B) + (hgood : ∀ n ∈ S, ∃ z : ℤ, |p.eval (n:ℝ)-z| ≤ ε) + (j : ℕ) (hj : 0 < j) (hjd : j ≤ d) : + |p.coeff j| ≤ coefficientConstant d * uniformBound d (δ/(2*B+3)) * ε / (N:ℝ)^j := by + classical + choose z hz using (fun n : S => hgood n.val n.property) + let Z : ℤ → ℤ := fun n => if hn : n ∈ S then z ⟨n,hn⟩ else 0 + have hZ : ∀ n ∈ S, |p.eval (n:ℝ)-(Z n:ℝ)| ≤ ε := by + intro n hn + simpa only [Z,dite_eq_left hn] using hz ⟨n,hn⟩ + let T : Finset ℤ := Icc (-(B+1):ℤ) (B+1) + have hT : T.Nonempty := by refine ⟨0, ?_⟩; simp only [T,mem_Icc]; constructor <;> omega + have hTcard : (T.card:ℝ) = 2*B+3 := by + simp only [T,Int.card_Icc] + have he : ((B:ℤ)+1+1 - -((B:ℤ)+1)) = (2*B+3:ℕ) := by push_cast; ring + rw [he,Int.toNat_natCast] + push_cast + ring + have hZT : ∀ n ∈ S, Z n ∈ T := by + intro n hn + have hh := abs_sub_le (Z n:ℝ) (p.eval (n:ℝ)) 0 + rw [sub_zero,sub_zero,abs_sub_comm] at hh + have hb : |(Z n:ℝ)| ≤ (B:ℝ)+1 := by linarith [hZ n hn,hbound n hn] + have hb' := abs_le.mp hb + have hlo : (-(B+1):ℤ) ≤ Z n := by exact_mod_cast hb'.1 + have hhi : Z n ≤ (B+1:ℤ) := by exact_mod_cast hb'.2 + exact mem_Icc.mpr ⟨hlo,hhi⟩ + have hcard : T.card • (δ*N/(2*B+3)) ≤ (S.card:ℝ) := by + rw [nsmul_eq_mul,hTcard] + have hb : (2*(B:ℝ)+3) ≠ 0 := by positivity + rw [mul_div_cancel₀ _ hb] + exact hdens + obtain ⟨k,hk,hfiber⟩ := exists_le_card_fiber_of_nsmul_le_card_of_maps_to hZT hT hcard + let E := S.filter (fun n => Z n=k) + have hElarge : 2*(d+1) ≤ E.card := by + exact_mod_cast hlarge.trans hfiber + have hEden : (δ/(2*B+3)) * N ≤ (E.card:ℝ) := by + simpa only [div_mul_eq_mul_div] using hfiber + have hα : 0 < δ/(2*B+3) := by positivity + have hdeg : (p-C (k:ℝ)).natDegree ≤ d := + (natDegree_sub_le _ _).trans (max_le hp (by simp)) + have h := dense_coefficient_bound d N hN (δ/(2*B+3)) ε hα hε E hElarge + hEden (fun n hn => hSN n (mem_filter.mp hn).1) (p-C (k:ℝ)) hdeg (by + intro n hn + obtain ⟨hn,hZk⟩ := mem_filter.mp hn + simpa only [eval_sub,eval_C,hZk] using hZ n hn) j hjd + simpa only [coeff_sub,coeff_C,ite_eq_right (Nat.ne_of_gt hj),sub_zero] using h + +end +end DensePolynomialInterpolation + + +namespace PolynomialIntegralResidual +open _root_.Polynomial _root_.OAI.Polynomial Finset +open scoped BigOperators +noncomputable section + +def integerPart (d : ℕ) (m : ℕ → ℤ) : ℤ[X] := + ∑ j ∈ range (d+1), monomial j (m j) + +lemma integerPart_coeff (d : ℕ) (m : ℕ → ℤ) (j : ℕ) (hj : j ≤ d) : + (integerPart d m).coeff j = m j := by + simp [integerPart,finsetSum_coeff,coeff_monomial,mem_range.mpr (Nat.lt_succ_of_le hj)] + +lemma integerPart_degree (d : ℕ) (m : ℕ → ℤ) : (integerPart d m).natDegree ≤ d := by + apply natDegree_sum_le_of_forall_le + intro j hj + exact (natDegree_monomial_le _).trans (Nat.le_of_lt_succ (mem_range.mp hj)) + +lemma integerPart_eval (d : ℕ) (m : ℕ → ℤ) (n : ℤ) : + ((integerPart d m).map (Int.castRingHom ℝ)).eval (n:ℝ) = + ((integerPart d m).eval n : ℤ) := by + rw [eval_map] + exact eval₂_at_apply (Int.castRingHom ℝ) n + + + +lemma eval_bound (d N A : ℕ) (hN : 0 < N) (p : ℝ[X]) (hp : p.natDegree ≤ d) + (hzero : |p.coeff 0| ≤ 1) + (hcoeff : ∀ j : ℕ, 0 < j → j ≤ d → |p.coeff j| ≤ (A:ℝ)/(N:ℝ)^j) + (x : ℝ) (hx : x ∈ Set.Icc 0 (N:ℝ)) : + |p.eval x| ≤ ((d+1)*(A+1):ℕ) := by + rw [eval_eq_sum_range' (Nat.lt_succ_of_le hp)] + calc + _ ≤ ∑ j ∈ range (d+1), ((A:ℝ)+1) := by + apply (abs_sum_le_sum_abs _ _).trans + apply sum_le_sum + intro j hj + by_cases hz : j=0 + · subst j + simp only [pow_zero,mul_one] + exact hzero.trans (by have := Nat.cast_nonneg (α := ℝ) A; linarith) + · have hjpos : 0 < j := Nat.pos_of_ne_zero hz + have hd : j ≤ d := Nat.le_of_lt_succ (mem_range.mp hj) + have h := (le_div_iff₀ (pow_pos (Nat.cast_pos.mpr hN) j)).mp (hcoeff j hjpos hd) + rw [abs_mul,abs_of_nonneg (pow_nonneg hx.1 j)] + have hh := mul_le_mul_of_nonneg_left (pow_le_pow_left₀ hx.1 hx.2 j) + (abs_nonneg (p.coeff j)) + have ha := Nat.cast_nonneg (α := ℝ) A + linarith + _ = _ := by simp only [sum_const,card_range,nsmul_eq_mul,Nat.cast_mul, + Nat.cast_add,Nat.cast_one] + + + +theorem residual (d N A : ℕ) (hN : 0 < N) (p : ℝ[X]) (hp : p.natDegree ≤ d) + (q : ℤ) (m : ℕ → ℤ) + (hm : ∀ j : ℕ, 0 < j → j ≤ d → + |(q:ℝ)*p.coeff j - m j| ≤ (A:ℝ)/(N:ℝ)^j) : + ∃ u : ℤ[X], ∃ r : ℝ[X], + r = C (q:ℝ)*p - u.map (Int.castRingHom ℝ) ∧ r.natDegree ≤ d ∧ + (∀ j : ℕ, 0 < j → j ≤ d → r.coeff j = (q:ℝ)*p.coeff j-m j) ∧ + (∀ x ∈ Set.Icc (0:ℝ) (N:ℝ), |r.eval x| ≤ ((d+1)*(A+1):ℕ)) := by + let m' : ℕ → ℤ := fun j => if j=0 then ⌊(q:ℝ)*p.coeff 0⌋ else m j + let u := integerPart d m' + let r := C (q:ℝ)*p - u.map (Int.castRingHom ℝ) + have hdeg : r.natDegree ≤ d := by + apply (natDegree_sub_le _ _).trans + apply max_le + · exact (natDegree_mul_le.trans (by simp)).trans hp + · exact natDegree_map_le.trans (integerPart_degree d m') + have hcoef (j : ℕ) (hjd : j ≤ d) : r.coeff j = (q:ℝ)*p.coeff j - m' j := by + dsimp only [r,u] + rw [coeff_sub,coeff_C_mul,coeff_map,integerPart_coeff d m' j hjd] + rfl + have hcoeff (j : ℕ) (hj : 0 < j) (hjd : j ≤ d) : + r.coeff j = (q:ℝ)*p.coeff j - m j := by + rw [hcoef j hjd] + simp only [m',ite_eq_right (Nat.ne_of_gt hj)] + refine ⟨u,r,rfl,hdeg,hcoeff,?_⟩ + intro x hx + apply eval_bound d N A hN r hdeg ?_ (fun j hj hjd => by rw [hcoeff j hj hjd]; exact hm j hj hjd) x hx + rw [hcoef 0 (Nat.zero_le _)] + simp only [m',ite_eq_left rfl] + rw [abs_of_nonneg (sub_nonneg.mpr (Int.floor_le _))] + linarith [Int.lt_floor_add_one ((q:ℝ)*p.coeff 0)] + + +lemma residual_near_integer (p r : ℝ[X]) (u : ℤ[X]) (q n z : ℤ) (ε : ℝ) + (hr : r = C (q:ℝ)*p - u.map (Int.castRingHom ℝ)) + (hz : |p.eval (n:ℝ)-z| ≤ ε) : + ∃ z' : ℤ, |r.eval (n:ℝ)-z'| ≤ |(q:ℝ)| * ε := by + refine ⟨q*z-u.eval n,?_⟩ + have he : r.eval (n:ℝ) - ((q*z-u.eval n:ℤ):ℝ) = (q:ℝ)*(p.eval (n:ℝ)-z) := by + rw [hr,eval_sub,eval_mul,eval_C,eval_map] + have hu : eval₂ (Int.castRingHom ℝ) (n:ℝ) u = ((u.eval n:ℤ):ℝ) := + eval₂_at_apply (Int.castRingHom ℝ) n + rw [hu] + push_cast + ring + rw [he,abs_mul] + exact mul_le_mul_of_nonneg_left hz (abs_nonneg _) + +end +end PolynomialIntegralResidual + +end +end +end +end + +end OAI diff --git a/lean/OAI/Combinatorics/SumProduct/Alignment/DenseRough01.lean b/lean/OAI/Combinatorics/SumProduct/Alignment/DenseRough01.lean new file mode 100644 index 0000000000000000000000000000000000000000..0b65ea59337034216f9e16f7ad8afba1e9397355 --- /dev/null +++ b/lean/OAI/Combinatorics/SumProduct/Alignment/DenseRough01.lean @@ -0,0 +1,380 @@ +import Mathlib +import OAI.Combinatorics.SumProduct.Alignment.RoughInterpolation01 +import OAI.Geometry.NilpotentCharts.Main + +namespace OAI + +section +section +open _root_.Polynomial _root_.OAI.Polynomial Finset +open scoped BigOperators +open _root_.Polynomial _root_.OAI.Polynomial +noncomputable section +namespace DenseRoughInterpolation +open LagrangeBounds RoughInterpolation ExactInterpolation +noncomputable section + +def uniformBound (q : ℕ) (α : ℝ) : ℝ := + (q + 1 : ℝ) * (2 * (q+1) / α) ^ q + +def derivativeBound {q : ℕ} (v : Fin (q+1) → ℤ) : ℝ := + 1 + ∑ j ∈ range q, ∑ i : Fin (q+1), coefficientBound + (derivative^[j] (Lagrange.basis univ (fun i => (v i : ℝ)) i)) q + +lemma derivativeBound_pos {q : ℕ} (v : Fin (q+1) → ℤ) : 0 < derivativeBound v := by + have : 0 ≤ ∑ j ∈ range q, ∑ i : Fin (q+1), coefficientBound + (derivative^[j] (Lagrange.basis univ (fun i => (v i : ℝ)) i)) q := + sum_nonneg (fun _ _ => sum_nonneg (fun _ _ => coefficientBound_nonneg _ _)) + unfold derivativeBound + linarith + +lemma derivative_sum_le {q j : ℕ} (v : Fin (q+1) → ℤ) (hj : j < q) : + (∑ i : Fin (q+1), coefficientBound + (derivative^[j] (Lagrange.basis univ (fun i => (v i : ℝ)) i)) q) ≤ + derivativeBound v := by + have h := single_le_sum (s := range q) + (f := fun j => ∑ i : Fin (q+1), coefficientBound + (derivative^[j] (Lagrange.basis univ (fun i => (v i : ℝ)) i)) q) + (fun _ _ => sum_nonneg (fun _ _ => coefficientBound_nonneg _ _)) (mem_range.mpr hj) + unfold derivativeBound + linarith + +lemma nodes_injective {q N : ℕ} {α : ℝ} (hN : 0 < N) (hα : 0 < α) + (v : Fin (q+1) → ℤ) + (hsep : ∀ i j, i ≠ j → α * N / (2 * (q+1)) ≤ |(v i : ℝ) - v j|) : + Function.Injective (fun i => (v i : ℝ)) := by + intro i j hij + by_contra hne + have h := hsep i j hne + dsimp only at hij + rw [hij, sub_self, abs_zero] at h + have : 0 < α * N / (2 * (q+1)) := by positivity + linarith + +lemma interpolation_error {q N : ℕ} {α : ℝ} (hN : 0 < N) (hα : 0 < α) + (v : Fin (q+1) → ℤ) (hv : ∀ i, (v i : ℝ) ∈ Set.Icc 0 (N : ℝ)) + (hsep : ∀ i j, i ≠ j → α * N / (2 * (q+1)) ≤ |(v i : ℝ) - v j|) + (T : ℝ[X]) (hT : T.natDegree ≤ q) (r : Fin (q+1) → ℝ) + {ε : ℝ} (hε : 0 ≤ ε) (hr : ∀ i, |r i - T.eval (v i : ℝ)| ≤ ε) + {x : ℝ} (hx : x ∈ Set.Icc 0 (N : ℝ)) : + |(Lagrange.interpolate univ (fun i => (v i : ℝ)) r).eval x - T.eval x| ≤ + uniformBound q α * ε := by + have hdeg : T.degree < ((univ : Finset (Fin (q+1))).card : WithBot ℕ) := by + simp only [card_univ, Fintype.card_fin] + exact lt_of_le_of_lt (degree_le_natDegree.trans + (show (T.natDegree : WithBot ℕ) ≤ (q : WithBot ℕ) by exact_mod_cast hT)) + (by exact_mod_cast Nat.lt_succ_self q) + have h := LagrangeBounds.interpolate_error univ (fun i => (v i : ℝ)) + (nodes_injective hN hα v hsep).injOn + (by positivity : (0 : ℝ) < α * N / (2 * (q+1))) hε + (fun i _ => hv i) (fun i _ j _ hji => hsep i j hji.symm) hx T hdeg r (fun i _ => hr i) + have heq : ((N : ℝ) - 0) / (α * N / (2 * (q+1))) = 2 * (q+1) / α := by + have hn : (N : ℝ) ≠ 0 := by positivity + field_simp + simp + rw [heq] at h + simpa only [uniformBound, card_univ, Fintype.card_fin, Nat.cast_add, Nat.cast_one, + Nat.add_sub_cancel] using h + + + +theorem quantitative_exact_division {N q : ℕ} {α : ℝ} (hN : 0 < N) (hα : 0 < α) + (E : Finset ℤ) (hE : ∀ z ∈ E, 0 ≤ z ∧ z ≤ N) + (v : Fin (q+1) → ℤ) (hv : ∀ i, v i ∈ E) + (hsep : ∀ i j, i ≠ j → α * N / (2 * (q+1)) ≤ |(v i : ℝ) - v j|) : + ∃ D : ℤ, D ≠ 0 ∧ ∃ K : ℝ, 0 < K ∧ + ∀ (a b : ℤ) (e : ℕ) (θ : ℝ[X]) (ε : ℝ), + b ≠ 0 → IsCoprime a b → e ≤ q → 0 ≤ ε → + ((C (a : ℝ) + C (b : ℝ) * X) ^ e * θ).natDegree ≤ q → + (∀ z ∈ E, ∃ n : ℤ, + |((C (a : ℝ) + C (b : ℝ) * X) ^ e * θ).eval (z : ℝ) - (n : ℝ)| ≤ ε) → + (∀ z ∈ E, IsCoprime D (a + b * z)) → + (uniformBound q α + 1) * ε < 1 / |(D : ℝ)| → + ε * K * (1 + |-(a : ℝ) / b|) ^ q < + 1 / (|(D : ℝ)| * |(b : ℝ)| ^ q) → + ∃ M : ℚ[X], M.natDegree ≤ q - e ∧ + C (D : ℚ) * M ∈ lifts (algebraMap ℤ ℚ) ∧ + (∀ z ∈ E, Integral (M.eval (z : ℚ))) ∧ + ∀ x : ℝ, x ∈ Set.Icc 0 (N : ℝ) → + |((M.map (algebraMap ℚ ℝ)).eval x - θ.eval x) * ((a : ℝ) + b * x) ^ e| ≤ + uniformBound q α * ε := by + obtain ⟨D, hD, hden⟩ := interpolation_common_denominator + (univ : Finset (Fin (q+1))) (fun i => (v i : ℚ)) + refine ⟨D, hD, derivativeBound v, derivativeBound_pos v, ?_⟩ + intro a b e θ ε hb hab he hε hT hnear hcop hsmall hderiv + let T : ℝ[X] := (C (a : ℝ) + C (b : ℝ) * X) ^ e * θ + have hnear' : ∀ i : Fin (q+1), ∃ n : ℤ, |T.eval (v i : ℝ) - n| ≤ ε := + fun i => hnear (v i) (hv i) + choose r hr using hnear' + let R : ℚ[X] := Lagrange.interpolate univ (fun i => (v i : ℚ)) (fun i => (r i : ℚ)) + have hRlifts : C (D : ℚ) * R ∈ lifts (algebraMap ℤ ℚ) := hden r + have hvreal : ∀ i, (v i : ℝ) ∈ Set.Icc 0 (N : ℝ) := by + intro i + exact ⟨by exact_mod_cast (hE (v i) (hv i)).1, + by exact_mod_cast (hE (v i) (hv i)).2⟩ + have hvinj := nodes_injective hN hα v hsep + have hinj : Function.Injective (fun i : Fin (q+1) => (v i : ℚ)) := by + intro i j hij + apply hvinj + dsimp only at hij ⊢ + have hz : v i = v j := by exact_mod_cast hij + exact_mod_cast hz + have hRdeg : R.natDegree ≤ q := by + apply natDegree_le_of_degree_le + have h := Lagrange.degree_interpolate_le (s := univ) (fun i => (r i : ℚ)) hinj.injOn + simpa only [card_univ, Fintype.card_fin, Nat.add_sub_cancel] using h + have hRmap : R.map (algebraMap ℚ ℝ) = + Lagrange.interpolate univ (fun i => (v i : ℝ)) (fun i => (r i : ℝ)) := by + change (Lagrange.interpolate univ (fun i => (v i : ℚ)) (fun i => (r i : ℚ))).map _ = _ + rw [map_interpolate] + simp only [map_intCast] + have herr (x : ℝ) (hx : x ∈ Set.Icc 0 (N : ℝ)) : + |(R.map (algebraMap ℚ ℝ)).eval x - T.eval x| ≤ uniformBound q α * ε := by + rw [hRmap] + apply interpolation_error hN hα v hvreal hsep T hT _ hε _ hx + intro i + simpa only [abs_sub_comm] using hr i + have hzero : ∀ j < e, (derivative^[j] R).eval (-(a : ℚ) / b) = 0 := by + intro j hj + apply derivative_eq_zero_of_small (a := -a) hRlifts hRdeg hD hb j + have hTd : T.degree < ((univ : Finset (Fin (q+1))).card : WithBot ℕ) := by + simp only [card_univ, Fintype.card_fin] + exact lt_of_le_of_lt (degree_le_natDegree.trans + (show (T.natDegree : WithBot ℕ) ≤ (q : WithBot ℕ) by exact_mod_cast hT)) + (by exact_mod_cast Nat.lt_succ_self q) + have h := derivative_interpolation_error univ (fun i => (v i : ℝ)) + hvinj.injOn (q := q) (by simp) T hTd (fun i => (r i : ℝ)) + hε (fun i _ => by simpa only [abs_sub_comm] using hr i) j (-(a : ℝ) / b) + rw [← hRmap, iterate_derivative_sub, eval_sub, + linear_power_derivative_zero (by exact_mod_cast hb) θ hj, sub_zero] at h + have h' : |(derivative^[j] (R.map (algebraMap ℚ ℝ))).eval (-(a : ℝ) / b)| < + 1 / (|(D : ℝ)| * |(b : ℝ)| ^ q) := by + apply lt_of_le_of_lt h + exact (mul_le_mul_of_nonneg_right + (mul_le_mul_of_nonneg_left (derivative_sum_le v (by omega : j < q)) hε) + (by positivity)).trans_lt hderiv + rw [iterate_derivative_map] at h' + have heval : ((derivative^[j] R).map (algebraMap ℚ ℝ)).eval (-(a : ℝ) / b) = + (((derivative^[j] R).eval (-(a : ℚ) / b) : ℚ) : ℝ) := by + rw [eval_map] + simpa only [eq_ratCast, Rat.cast_div, Rat.cast_neg, Rat.cast_intCast] using + (eval₂_at_apply (p := derivative^[j] R) (algebraMap ℚ ℝ) (-(a : ℚ) / b)) + rw [heval] at h' + exact_mod_cast h' + obtain ⟨M, hdiv⟩ := exact_linear_division (by exact_mod_cast hb) hzero + refine ⟨M, quotient_degree (by exact_mod_cast hb) hRdeg hdiv, + integral_scaled_quotient hab e hRlifts hdiv, ?_, ?_⟩ + · intro z hz + apply quotient_integral_at hab (hcop z hz) e hRlifts _ hdiv + have hx : (z : ℝ) ∈ Set.Icc 0 (N : ℝ) := + ⟨by exact_mod_cast (hE z hz).1, by exact_mod_cast (hE z hz).2⟩ + obtain ⟨n, hn⟩ := hnear z hz + have hscaled := integral_eval_of_lifts hRlifts z + simp only [eval_mul, eval_C] at hscaled + have hRn : |(R.map (algebraMap ℚ ℝ)).eval (z : ℝ) - (n : ℝ)| < 1 / |(D : ℝ)| := by + calc + _ ≤ |(R.map (algebraMap ℚ ℝ)).eval (z : ℝ) - T.eval (z : ℝ)| + + |T.eval (z : ℝ) - (n : ℝ)| := abs_sub_le _ _ _ + _ ≤ uniformBound q α * ε + ε := add_le_add (herr _ hx) hn + _ = (uniformBound q α + 1) * ε := by ring + _ < _ := hsmall + have heval : (R.map (algebraMap ℚ ℝ)).eval (z : ℝ) = ((R.eval (z : ℚ) : ℚ) : ℝ) := by + rw [eval_map] + simpa only [eq_ratCast, Rat.cast_intCast] using + (eval₂_at_apply (p := R) (algebraMap ℚ ℝ) (z : ℚ)) + rw [heval] at hRn + have heq := integral_eq_of_near hD hscaled n (by exact_mod_cast hRn) + exact ⟨n, heq.symm⟩ + · intro x hx + have h := herr x hx + rw [hdiv] at h + simp [T] at h + simp only [eval_map_algebraMap] + convert h using 1 + ring_nf + +end +end DenseRoughInterpolation + + + +open _root_.Polynomial _root_.OAI.Polynomial Filter +open scoped Topology + + +namespace DenseRoughScaleCompletion +open DenseRoughInterpolation RoughScales RoughInterpolation Filter +open scoped Topology + + + +theorem eventually_exact_division_fixed_set {e q N : ℕ} (he : 1 ≤ e) (heq : e ≤ q) + (hN : 0 < N) {α A : ℝ} (hα : 0 < α) (hA : 0 < A) + (E : Finset ℤ) (hE : ∀ z ∈ E, 0 ≤ z ∧ z ≤ N) + (hcard : 2*(q+1) ≤ E.card) (hdens : α*N ≤ E.card) + {w : ℕ → ℕ} {S Z : ℕ → ℝ} + (hw : Tendsto w atTop atTop) (hS : Tendsto S atTop atTop) + (hZ : ∀ k : ℕ, Tendsto (fun n => Z n / S n ^ k) atTop atTop) : + ∀ᶠ n in atTop, ∀ (a b : ℤ) (θ : ℝ[X]), + 0 < b → Smooth (w n) b → + (∀ z : ℤ, 0 ≤ z → z ≤ N → S n ≤ (a + b * z : ℤ) ∧ + ((a + b * z : ℤ) : ℝ) < 2 * S n) → + (∀ z ∈ E, Rough (w n) (a + b * z)) → + ((C (a : ℝ) + C (b : ℝ) * X) ^ e * θ).natDegree ≤ q → + (∀ z ∈ E, ∃ k : ℤ, + |((C (a : ℝ) + C (b : ℝ) * X) ^ e * θ).eval (z : ℝ) - (k : ℝ)| ≤ + A * (S n / Z n) ^ e) → + ∃ M : ℚ[X], M.natDegree ≤ q - e ∧ + (∀ j p : ℕ, p.Prime → p ∣ (M.coeff j).den → p ≤ w n) ∧ + (∀ z ∈ E, Integral (M.eval (z : ℚ))) ∧ + ∀ z : ℤ, 0 ≤ z → z ≤ N → + |θ.eval (z : ℝ) - (M.map (algebraMap ℚ ℝ)).eval (z : ℝ)| ≤ + uniformBound q α * A / Z n ^ e := by + obtain ⟨v,hv,hsep⟩ := DenseIntegerNodes.separated_of_density E q hcard hdens + obtain ⟨D,hD,K,hK,hquant⟩ := DenseRoughInterpolation.quantitative_exact_division + hN hα E hE v hv hsep + have hDr : (D : ℝ) ≠ 0 := by exact_mod_cast hD + have hDa : 0 < |(D : ℝ)| := abs_pos.mpr hDr + have hC : 0 ≤ uniformBound q α := by unfold uniformBound; positivity + have hsmall := (inverse_ratio_tendsto (hZ 1)).const_mul + ((uniformBound q α + 1) * A) + simp only [pow_one, mul_zero] at hsmall + have hderiv := (inverse_ratio_tendsto (hZ (2 * q + 1))).const_mul + (A * K * |(D : ℝ)| * 3 ^ q) + simp only [mul_zero] at hderiv + filter_upwards [hS.eventually (eventually_ge_atTop (1 : ℝ)), + (hZ 1).eventually (eventually_ge_atTop (1 : ℝ)), + hw.eventually (eventually_ge_atTop D.natAbs), + hsmall.eventually (gt_mem_nhds (by positivity : (0 : ℝ) < 1 / |(D : ℝ)|)), + hderiv.eventually (gt_mem_nhds (by norm_num : (0 : ℝ) < 1))] + with n hnS hnZ hnw hnsmall hnderiv + intro a b θ hb hbs hp hr hdeg hnear + have hSn : 0 < S n := by linarith + have hZn : S n ≤ Z n := by + have h := hnZ + simp only [pow_one] at h + simpa only [one_mul] using (le_div_iff₀ hSn).mp h + have hZpos : 0 < Z n := hSn.trans_le hZn + have hb0 : b ≠ 0 := ne_of_gt hb + have hbr : 0 < (b : ℝ) := by exact_mod_cast hb + have hbr1 : 1 ≤ |(b : ℝ)| := by + rw [abs_of_pos hbr] + exact_mod_cast hb + have hp0 := hp 0 (by norm_num) (by omega) + have hp1 := hp 1 (by norm_num) (by omega) + simp only [mul_zero, add_zero] at hp0 + simp only [mul_one, Int.cast_add] at hp1 + have hbS : |(b : ℝ)| ≤ S n := by + rw [abs_of_pos hbr] + linarith [hp0.1, hp1.2] + have ha : |(a : ℝ)| ≤ 2 * S n := by + rw [abs_of_nonneg (hSn.le.trans hp0.1)] + exact hp0.2.le + have hDs : Smooth (w n) D := smooth_of_abs_le hD hnw + have hcop : IsCoprime a b := by + have h := coprime_smooth_rough hbs (hr (v 0) (hv 0)) + exact h.symm.of_add_mul_left_left + have hε : 0 ≤ A * (S n / Z n) ^ e := by positivity + have hratio : 0 ≤ S n / Z n := by positivity + have hratio1 : S n / Z n ≤ 1 := (div_le_one hZpos).mpr hZn + have hpow : (S n / Z n) ^ e ≤ S n / Z n := by + simpa only [pow_one] using pow_le_pow_of_le_one hratio hratio1 he + have hsmall' : (uniformBound q α + 1) * (A * (S n / Z n) ^ e) < + 1 / |(D : ℝ)| := by + apply lt_of_le_of_lt _ hnsmall + rw [← mul_assoc] + exact mul_le_mul_of_nonneg_left hpow (by positivity) + have hderiv' : A * (S n / Z n) ^ e * K * + (1 + |-(a : ℝ) / b|) ^ q < 1 / (|(D : ℝ)| * |(b : ℝ)| ^ q) := by + apply (lt_div_iff₀ (by positivity)).mpr + exact (derivative_error_bound hA.le hK.le hDa.le hnS hZn ha hbr1 hbS he).trans_lt + hnderiv + obtain ⟨M,hMdeg,hMD,hMint,hMerr⟩ := hquant a b e θ (A*(S n/Z n)^e) + hb0 hcop heq hε hdeg hnear + (fun z hz => coprime_smooth_rough hDs (hr z hz)) hsmall' hderiv' + refine ⟨M,hMdeg,coefficients_smooth hD hDs hMD,hMint,?_⟩ + intro z hz0 hzN + have htz : S n ≤ (a : ℝ) + b*(z : ℝ) := by + simpa only [Int.cast_add, Int.cast_mul] using (hp z hz0 hzN).1 + have htpos : 0 < (a : ℝ) + b*(z : ℝ) := hSn.trans_le htz + have hx : (z : ℝ) ∈ Set.Icc 0 (N : ℝ) := + ⟨by exact_mod_cast hz0, by exact_mod_cast hzN⟩ + apply (mul_le_mul_iff_left₀ (pow_pos hSn e)).mp + calc + _ ≤ |θ.eval (z : ℝ)-(M.map (algebraMap ℚ ℝ)).eval (z : ℝ)| * + ((a : ℝ)+b*(z : ℝ))^e := by gcongr + _ = |((M.map (algebraMap ℚ ℝ)).eval (z : ℝ)-θ.eval (z : ℝ)) * + ((a : ℝ)+b*(z : ℝ))^e| := by + rw [abs_mul, abs_of_pos (pow_pos htpos e), abs_sub_comm] + _ ≤ uniformBound q α * (A*(S n/Z n)^e) := hMerr _ hx + _ = (uniformBound q α*A/Z n^e)*S n^e := by rw [div_pow]; ring + + + +theorem eventually_exact_division {e q N : ℕ} (he : 1 ≤ e) (heq : e ≤ q) + (hN : 0 < N) {α A : ℝ} (hα : 0 < α) (hA : 0 < A) + {w : ℕ → ℕ} {S Z : ℕ → ℝ} + (hw : Tendsto w atTop atTop) (hS : Tendsto S atTop atTop) + (hZ : ∀ k : ℕ, Tendsto (fun n => Z n / S n ^ k) atTop atTop) : + ∀ᶠ n in atTop, ∀ E : Finset ℤ, + (∀ z ∈ E, 0 ≤ z ∧ z ≤ N) → + 2*(q+1) ≤ E.card → α*N ≤ E.card → + ∀ (a b : ℤ) (θ : ℝ[X]), + 0 < b → Smooth (w n) b → + (∀ z : ℤ, 0 ≤ z → z ≤ N → S n ≤ (a + b * z : ℤ) ∧ + ((a + b * z : ℤ) : ℝ) < 2 * S n) → + (∀ z ∈ E, Rough (w n) (a + b * z)) → + ((C (a : ℝ) + C (b : ℝ) * X) ^ e * θ).natDegree ≤ q → + (∀ z ∈ E, ∃ k : ℤ, + |((C (a : ℝ) + C (b : ℝ) * X) ^ e * θ).eval (z : ℝ) - (k : ℝ)| ≤ + A * (S n / Z n) ^ e) → + ∃ M : ℚ[X], M.natDegree ≤ q - e ∧ + (∀ j p : ℕ, p.Prime → p ∣ (M.coeff j).den → p ≤ w n) ∧ + (∀ z ∈ E, Integral (M.eval (z : ℚ))) ∧ + ∀ z : ℤ, 0 ≤ z → z ≤ N → + |θ.eval (z : ℝ) - (M.map (algebraMap ℚ ℝ)).eval (z : ℝ)| ≤ + uniformBound q α * A / Z n ^ e := by + classical + let P : Finset ℤ → ℕ → Prop := fun E n => + ∀ (a b : ℤ) (θ : ℝ[X]), + 0 < b → Smooth (w n) b → + (∀ z : ℤ, 0 ≤ z → z ≤ N → S n ≤ (a + b * z : ℤ) ∧ + ((a + b * z : ℤ) : ℝ) < 2 * S n) → + (∀ z ∈ E, Rough (w n) (a + b * z)) → + ((C (a : ℝ) + C (b : ℝ) * X) ^ e * θ).natDegree ≤ q → + (∀ z ∈ E, ∃ k : ℤ, + |((C (a : ℝ) + C (b : ℝ) * X) ^ e * θ).eval (z : ℝ) - (k : ℝ)| ≤ + A * (S n / Z n) ^ e) → + ∃ M : ℚ[X], M.natDegree ≤ q - e ∧ + (∀ j p : ℕ, p.Prime → p ∣ (M.coeff j).den → p ≤ w n) ∧ + (∀ z ∈ E, Integral (M.eval (z : ℚ))) ∧ + ∀ z : ℤ, 0 ≤ z → z ≤ N → + |θ.eval (z : ℝ) - (M.map (algebraMap ℚ ℝ)).eval (z : ℝ)| ≤ + uniformBound q α * A / Z n ^ e + change ∀ᶠ n in atTop, ∀ E : Finset ℤ, + (∀ z ∈ E, 0 ≤ z ∧ z ≤ N) → 2*(q+1) ≤ E.card → α*N ≤ E.card → P E n + have hs : ∀ E ∈ (Finset.Icc (0 : ℤ) (N : ℤ)).powerset, + ∀ᶠ n in atTop, 2*(q+1) ≤ E.card → α*N ≤ E.card → P E n := by + intro E hE + by_cases hc : 2*(q+1) ≤ E.card + · by_cases hd : α*N ≤ E.card + · have hb : ∀ z ∈ E, 0 ≤ z ∧ z ≤ N := fun z hz => + Finset.mem_Icc.mp (Finset.mem_powerset.mp hE hz) + have h := eventually_exact_division_fixed_set he heq hN hα hA E hb hc hd hw hS hZ + filter_upwards [h] with n hn + exact fun _ _ => hn + · exact Filter.Eventually.of_forall (fun n _ hd' => (hd hd').elim) + · exact Filter.Eventually.of_forall (fun n hc' _ => (hc hc').elim) + have hh := (Filter.eventually_all_finset _).mpr hs + filter_upwards [hh] with n hn E hE hc hd + exact hn E (Finset.mem_powerset.mpr (fun z hz => Finset.mem_Icc.mpr (hE z hz))) hc hd + +end DenseRoughScaleCompletion + + + +end +end +end + +end OAI diff --git a/lean/OAI/Combinatorics/SumProduct/Alignment/DyadicHarmonic01.lean b/lean/OAI/Combinatorics/SumProduct/Alignment/DyadicHarmonic01.lean new file mode 100644 index 0000000000000000000000000000000000000000..da69b70c7ea6bedc491f032c45ec8ca142501b94 --- /dev/null +++ b/lean/OAI/Combinatorics/SumProduct/Alignment/DyadicHarmonic01.lean @@ -0,0 +1,277 @@ +import Mathlib +import OAI.Combinatorics.SumProduct.Alignment.UnitInterval01 +import OAI.Geometry.NilpotentCharts.Main + +namespace OAI + +section +section RawSuccessInlineScope6 +end RawSuccessInlineScope6 + + + + + +section RawSuccessInlineScope7 +noncomputable section +open scoped BigOperators +open Finset +namespace UnitNeighborhoodCost +open UnitIntervalCounts +variable {J:Type*} [DecidableEq J] + + + +omit [DecidableEq J] in +theorem cover_count (T:Finset J) (a:J→ℕ) (R W:ℕ) (hW:0units (a j) R W)) : + (E.card:ℝ) ≤ T.card*W.totient*((R:ℝ)/W+2) := by + have hcard:= (card_le_card hE).trans (card_biUnion_le (s:=T) (t:=fun j=>units (a j) R W)) + have hreal:(E.card:ℝ) ≤ ∑ j∈T,((units (a j) R W).card:ℝ) := by exact_mod_cast hcard + calc + _ ≤ _ := hreal + _ ≤ ∑ _j∈T,(W.totient:ℝ)*((R:ℝ)/W+2) := + sum_le_sum (fun j _=>card_upper (a j) R W hW) + _ = _ := by simp only [sum_const,nsmul_eq_mul]; ring + + + +omit [DecidableEq J] in +theorem harmonic_cover (T:Finset J) (a:J→ℕ) (R W Y:ℕ) (hW:0units (a j) R W)) : + (∑ n∈E,(n:ℝ)⁻¹)/(∑ n∈units Y Y W,(n:ℝ)⁻¹) ≤ + 4*T.card*((R:ℝ)+2*W)/Y := by + have hw:(0:ℝ)t*(p-R)/H ≠ t*(p+R)/H) + +lemma cover (Y W t H R:ℕ) (ht:0units (k*H/t-R) (2*R+2) W) := by + intro p hp + obtain ⟨hp,hbad⟩:=mem_filter.mp hp + have hbox:Y≤p ∧ pk*H/t-R) (2*R+2) W Y hW hY + (bad Y W t H R) (filter_subset _ _) (cover Y W t H R ht hH hR) + simp only [card_range,Nat.cast_add,Nat.cast_mul,Nat.cast_ofNat] at hc + calc + _ ≤ 4*(((3*Y*t/H:ℕ):ℝ)+2)*(2*(R:ℝ)+2+2*(W:ℝ))/(Y:ℝ) := hc + _ ≤ 4*(3*(Y:ℝ)*(t:ℝ)/(H:ℝ)+2)*(2*(R:ℝ)+2+2*(W:ℝ))/(Y:ℝ) := by + gcongr + _ = _ := by field_simp; ring + +end MicrocellBoundary +end +end RawSuccessInlineScope8 + + + + + +section RawSuccessInlineScope9 +noncomputable section +open scoped BigOperators +open Finset +namespace DyadicHarmonicBoundary +open UnitIntervalCounts MicrocellBoundary + +def mass (A B W:ℕ) : ℝ := ∑ n∈Ico A B,if W.Coprime n then (n:ℝ)⁻¹ else 0 +def badMass (A B W t H R:ℕ) : ℝ := + ∑ n∈Ico A B,if W.Coprime n ∧ t*(n-R)/H≠t*(n+R)/H then (n:ℝ)⁻¹ else 0 + +lemma mass_units (Y W:ℕ) : mass Y (Y+Y) W=∑ n∈units Y Y W,(n:ℝ)⁻¹ := by + simp only [mass,units,sum_filter] +lemma badMass_units (Y W t H R:ℕ) : badMass Y (Y+Y) W t H R= + ∑ n∈bad Y W t H R,(n:ℝ)⁻¹ := by + simp only [badMass,bad,units,sum_filter,←ite_and] + +lemma mass_nonneg (A B W:ℕ) : 0 ≤ mass A B W := by unfold mass; positivity +lemma badMass_nonneg (A B W t H R:ℕ) : 0 ≤ badMass A B W t H R := by unfold badMass; positivity + +lemma mass_mono {A B C W:ℕ} (h:B ≤ C) : mass A B W ≤ mass A C W := + sum_le_sum_of_subset_of_nonneg (Ico_subset_Ico le_rfl h) (fun _ _ _=>by positivity) +lemma badMass_mono {A B C W t H R:ℕ} (h:B ≤ C) : badMass A B W t H R ≤ badMass A C W t H R := + sum_le_sum_of_subset_of_nonneg (Ico_subset_Ico le_rfl h) (fun _ _ _=>by positivity) + +lemma dyadic_lower (Y W:ℕ) (hW:0simp + | succ K ih=> + rw [sum_range_succ,ih] + apply sum_Ico_consecutive + · have h:=Nat.one_le_pow K 2 (by omega) + nlinarith + · rw [pow_succ,←mul_assoc] + omega + + + +theorem dyadic_transfer (X W t H R:ℕ) (hW:0 nlinarith + have hfirst:X+X ≤ X^2:=by nlinarith + have hlow:(W.totient:ℝ)/(4*W) ≤ mass X (X^2) W := + (dyadic_lower X W hW hX).trans (mass_mono hfirst) + have hm:0< mass X (X^2) W:=lt_of_lt_of_le (by positivity) hlow + have htail:mass (X^2) (X^2+X^2) W ≤ 6*mass X (X^2) W := by + have hs:=dyadic_upper (X^2) W hW (by positivity) + have hb:(W.totient:ℝ)/W+2*W.totient/(X^2:ℕ) ≤ 6*((W.totient:ℝ)/(4*W)) := by + have hxx:(4:ℝ)*W ≤ (X^2:ℕ):=by exact_mod_cast (show 4*W ≤ X^2 by nlinarith) + have hdiv:2*(W.totient:ℝ)/(X^2:ℕ) ≤ (W.totient:ℝ)/(2*W) := by + calc + _ ≤ 2*(W.totient:ℝ)/(4*W) := + div_le_div_of_nonneg_left (by positivity) (by positivity) hxx + _ = _ := by ring + linear_combination hdiv + exact hs.trans (hb.trans (mul_le_mul_of_nonneg_left hlow (by norm_num))) + have hcover:mass X (X*2^K) W ≤ 7*mass X (X^2) W := by + calc + _ ≤ mass X (X^2+X^2) W := mass_mono (by omega) + _ = mass X (X^2) W+mass (X^2) (X^2+X^2) W := by + symm + exact sum_Ico_consecutive _ (by nlinarith) (by omega) + _ ≤ _ := by linarith + have hsum:badMass X (X*2^K) W t H R ≤ ε*mass X (X*2^K) W := by + unfold badMass mass + rw [←dyadic_sum X K,←dyadic_sum X K,Finset.mul_sum] + apply sum_le_sum + intro k _ + have hend:X*2^(k+1)=X*2^k+X*2^k:=by rw [pow_succ]; ring + rw [hend] + exact hlocal k + apply (div_le_iff₀ hm).mpr + calc + _ ≤ badMass X (X*2^K) W t H R:=badMass_mono hends.1 + _ ≤ ε*mass X (X*2^K) W:=hsum + _ ≤ ε*(7*mass X (X^2) W):=mul_le_mul_of_nonneg_left hcover he + _ = _:=by ring + +end DyadicHarmonicBoundary + +end +end RawSuccessInlineScope9 +end + +end OAI diff --git a/lean/OAI/Combinatorics/SumProduct/Alignment/EmbeddedCube01.lean b/lean/OAI/Combinatorics/SumProduct/Alignment/EmbeddedCube01.lean new file mode 100644 index 0000000000000000000000000000000000000000..9e72b7ee4af94421a2ea26803e599519e70a98c7 --- /dev/null +++ b/lean/OAI/Combinatorics/SumProduct/Alignment/EmbeddedCube01.lean @@ -0,0 +1,364 @@ +import Mathlib +import OAI.Combinatorics.SumProduct.Alignment.CubeRational01 +import OAI.Geometry.NilpotentCharts.Main + +namespace OAI + +open scoped BigOperators +section +noncomputable section +open scoped BigOperators Topology +end + +end + +section + + + + +noncomputable section +open scoped BigOperators Topology commutatorElement +open Filter MeasureTheory +namespace BaseCubeLaw +open CubeFaces CubeLocalHaar RationalLattice MalcevCharacters +open CubeHorizontalIrrationality ComparableBoxLeibman CubeTaylorExpansion +variable {G ι : Type} [Group G] [TopologicalSpace G] [IsTopologicalGroup G] +variable [Fintype ι] [DecidableEq ι] +variable {n : ℕ} (c : RealCoordinates G n) (H : Filtration G) +variable (q : ℕ → ℕ) (hq : ∀ k,q k ≤ n) +variable (hH : ∀ k (x : G),x∈H.level k ↔ ∀ i : Fin n,i.val < q k → c.coord x i=0) +variable (Γ : Subgroup G) (hΓ : ∀ g : G,g∈Γ ↔ ∀ i,∃ z : ℤ,c.coord g i=z) + +include hH hΓ in +omit [IsTopologicalGroup G] in +lemma level_compact_reps (k : ℕ) : CompactGroupProducts.HasCompactReps (H.level k) Γ := by + have he : H.level k=coordinateTail c (q k) := by + ext g + exact hH k g + rw [he] + exact coordinateTail_compact_reps c Γ hΓ (q k) + + +def Irrational (s : ℕ) (a : ℕ→∀ k : ℕ,H.level k) (L : ℕ→ℝ) : Prop := + ∀ j : ℕ,0 < j → j ≤ s → ∀ ξ : H.level j→*Multiplicative ℝ, + ξ≠1 → Continuous ξ → RationalCharacter Γ ξ → + (∀ x (hx : x∈H.level (j+1)),ξ ⟨x,H.antitone (Nat.le_succ _) hx⟩=1) → + (∀ i k : ℕ,0 < i → 0 < k → ∀ h : i+k=j, + ∀ x (hx : x∈H.level i) y (hy : y∈H.level k), + ξ ⟨⁅x,y⁆,by rw [←h]; exact H.commutator_le i k (Subgroup.commutator_mem_commutator hx hy)⟩=1) → + Tendsto (fun N : ℕ=>‖((ξ (a N j)).toAdd:UnitAddCircle)‖*(L N)^j) atTop atTop + +variable [MeasurableSpace ((cube H (Finset.univ : Finset ι) 0)⧸cubeLattice H Γ)] +variable [BorelSpace ((cube H (Finset.univ : Finset ι) 0)⧸cubeLattice H Γ)] + +include hΓ in + + +theorem exists_scaled_cube_law (h01 : H.level 0=H.level 1) + (s : ℕ) (hs : H.level (s+1)=⊥) : + ∃ μ : ProbabilityMeasure ((cube H (Finset.univ : Finset ι) 0)⧸cubeLattice H Γ), + SMulInvariantMeasure (cube H (Finset.univ : Finset ι) 0) _ (μ : Measure ((cube H (Finset.univ : Finset ι) 0)⧸cubeLattice H Γ)) ∧ + ∀ (v : ℕ) (e : Option ι≃Fin v) (L : ℕ→ℝ),Tendsto L atTop atTop → + ∀ (a : ℕ→∀ k : ℕ,H.level k),Irrational H Γ s a L → + ∀ (c₀ C₀ : ℝ),0 < c₀ → 0 < C₀ → + ∀ (d₀ : ℕ),0 < d₀ → ∀ (r : Fin v→ℤ) + (T : Set C(((cube H (Finset.univ : Finset ι) 0)⧸cubeLattice H Γ),ℂ)), + IsCompact T → ∀ η : ℝ,0 < η → ∀ᶠ N : ℕ in atTop, + ∀ lo hi : Fin v→ℝ, + (∀ i,c₀*L N ≤ hi i-lo i) → + (∀ i,-C₀*L N ≤ lo i ∧ hi i ≤ C₀*L N) → + ∀ f : C(((cube H (Finset.univ : Finset ι) 0)⧸cubeLattice H Γ),ℂ), + f∈T → + ‖(𝔼 x∈integerBox v lo hi,f (QuotientGroup.mk + (cubePolynomial c H (fun k=> {i : Fin n | i.val < q k}) + (fun k g=>hH k g) (a N) s + (fun i=>((r (e i)+(d₀:ℤ)*x (e i):ℤ):ℝ)))))- + (∫ y,f y ∂(μ : Measure ((cube H (Finset.univ : Finset ι) 0)⧸cubeLattice H Γ)))‖ < η := by + let : T2Space G:=c.coord.symm.t2Space + let : SecondCountableTopology G:=c.coord.secondCountableTopology + let : DiscreteTopology Γ:=integerCoordinates_discrete c Γ hΓ + obtain ⟨μ,hμ,_⟩:=existsUnique_cubeHaar (ι:=ι) H h01 s hs Γ + (level_compact_reps c H q hH Γ hΓ) (isDiscrete_iff_discreteTopology.mpr inferInstance) + let : SMulInvariantMeasure (cube H (Finset.univ : Finset ι) 0) _ (μ : Measure ((cube H (Finset.univ : Finset ι) 0)⧸cubeLattice H Γ)):=hμ + obtain ⟨D,cc,hsk,hcc,hlevels⟩:=CubeRationalCharts.cube_chart_from_base (ι:=ι) + c q H hH h01 s hs Γ hΓ + choose p hp hp' using hlevels + let : MetricSpace ((cube H (Finset.univ : Finset ι) 0)⧸cubeLattice H Γ):= + coordinateQuotientMetric cc (cubeLattice H Γ) hcc + refine ⟨μ,hμ,?_⟩ + intro v e L ht a hirr c₀ C₀ hc₀ hC₀ d₀ hd₀ r T hT η hη + exact haar_limit_compact_scaled (t:=D) (d:=0) c H + (fun k=> {i : Fin n | i.val < q k}) (fun k g=>hH k g) Γ h01 s hs e + cc hsk p hp hp' hcc rfl L ht (μ : Measure ((cube H (Finset.univ : Finset ι) 0)⧸cubeLattice H Γ)) a hirr c₀ C₀ hc₀ hC₀ d₀ hd₀ r T hT η hη + +end BaseCubeLaw +end + +end + +section + + + + +noncomputable section +open scoped Topology commutatorElement +open Filter +namespace AllLevelFactorization.Factorization +open AllLevelDomains AllLevelStates RationalLattice CubeFaces MalcevCharacters +variable {G : Type} [Group G] [TopologicalSpace G] [IsTopologicalGroup G] +variable {n s : ℕ} {c : RealCoordinates G n} {Γ : Subgroup G} +variable {K : Filtration G} {P : ℕ → ℤ → G} {L : ℕ → ℝ} +variable (F : Factorization c Γ s K P L) + +structure ResidueCover (r : Fin F.period) where + lattice : Subgroup F.state.domain.Carrier + chart : RealCoordinates F.state.domain.Carrier F.state.domain.dim + secondKind : SecondKind chart + integer_lattice : ∀ x,x∈lattice ↔ ∀ i,∃ z : ℤ,chart.coord x i=z + le_old : lattice ≤ F.state.domain.lattice + le_induced : lattice ≤ Γ.comap (conjugateEmbedding F.state.domain.embed (F.residue r)) + finite_old : (lattice.subgroupOf F.state.domain.lattice).FiniteIndex + finite_induced : (lattice.subgroupOf + (Γ.comap (conjugateEmbedding F.state.domain.embed (F.residue r)))).FiniteIndex + adapted : ∀ k (x : F.state.domain.Carrier),x∈F.state.domain.filtration.level k ↔ + ∀ i : Fin F.state.domain.dim,i.val < F.state.domain.cutoff k → chart.coord x i=0 + rational_iff : ∀ x,IsRational chart x ↔ IsRational F.state.domain.chart x + +theorem residueCover_exists + (hΓ : ∀ x : G,x∈Γ ↔ ∀ i,∃ z : ℤ,c.coord x i=z) (r : Fin F.period) : + Nonempty (F.ResidueCover r) := by + let D:=F.state.domain + obtain ⟨Δ,e,he,hΔ,hle,hconj,hfinite,hfinite',hadapt,hrat⟩:= + rational_conjugate_cover c D.chart D.secondKind D.embed D.continuous D.injective + D.rational_image Γ D.lattice hΓ D.integer_lattice (F.residue r) (F.residue_rational r) + exact ⟨{ lattice:=Δ + chart:=e + secondKind:=he + integer_lattice:=hΔ + le_old:=hle + le_induced:=hconj + finite_old:=hfinite + finite_induced:=hfinite' + adapted:=fun k=>hadapt (D.filtration.level k) (D.cutoff k) (D.adapted k) + rational_iff:=hrat }⟩ + +def residueCover + (hΓ : ∀ x : G,x∈Γ ↔ ∀ i,∃ z : ℤ,c.coord x i=z) (r : Fin F.period) : + F.ResidueCover r := Classical.choice (F.residueCover_exists hΓ r) + +namespace ResidueCover +variable {F} {r : Fin F.period} (C : F.ResidueCover r) + +omit [IsTopologicalGroup G] in +theorem irrational (hL : ∀ N,0 < L N) : + BaseCubeLaw.Irrational F.state.domain.filtration C.lattice s F.state.coeff + (L∘F.state.subseq) := by + let := C.finite_old + intro j hj hjs ξ hne hc hrat hnext hbr + have hr:= (FiniteCoverCharacters.rationalCharacter_iff C.lattice + F.state.domain.lattice C.le_old ξ).mp hrat + have hn (x : F.state.domain.filtration.level j) + (hx : x.val∈F.state.domain.filtration.level (j+1)) : ξ x=1 := hnext x.val hx + have hb (a b : ℕ) (ha : 0 < a) (hb : 0 < b) (hab : a+b=j) + (x : F.state.domain.Carrier) (hx : x∈F.state.domain.filtration.level a) + (y : F.state.domain.Carrier) (hy : y∈F.state.domain.filtration.level b) + (hh : ⁅x,y⁆∈F.state.domain.filtration.level j) : ξ ⟨⁅x,y⁆,hh⟩=1 := + hbr a b ha hb hab x hx y hy + have hi:=F.irrational j hj hjs ξ hne hc hr hn hb + simpa only [Function.comp_apply,abs_of_pos (hL _),TriangularLatticeRecovery.circleNorm,mul_comm] using hi + +end ResidueCover + +end AllLevelFactorization.Factorization +end + +end + +section + + + + +noncomputable section +open scoped Topology +namespace CosetCover +variable {G : Type*} [Group G] [TopologicalSpace G] [IsTopologicalGroup G] +variable (Δ Θ : Subgroup G) (hle : Δ≤Θ) + +def map : G⧸Δ → G⧸Θ := Quotient.lift QuotientGroup.mk (by + intro x y h + exact QuotientGroup.eq.mpr (hle (QuotientGroup.leftRel_apply.mp h))) + +omit [TopologicalSpace G] [IsTopologicalGroup G] in +@[simp] lemma map_mk (x : G) : map Δ Θ hle (QuotientGroup.mk x)=QuotientGroup.mk x := rfl + +omit [IsTopologicalGroup G] in +lemma continuous_map : Continuous (map Δ Θ hle) := + (QuotientGroup.isQuotientMap_mk Δ).continuous_iff.mpr QuotientGroup.continuous_mk + +omit [TopologicalSpace G] [IsTopologicalGroup G] in +lemma surjective_map : Function.Surjective (map Δ Θ hle) := by + intro x + induction x using Quotient.inductionOn with | h x => exact ⟨QuotientGroup.mk x,rfl⟩ + +omit [TopologicalSpace G] [IsTopologicalGroup G] in +lemma map_smul (g : G) (x : G⧸Δ) : map Δ Θ hle (g • x)=g • map Δ Θ hle x := by + induction x using Quotient.inductionOn with | h x => rfl + +variable [MeasurableSpace (G⧸Δ)] [BorelSpace (G⧸Δ)] +variable [MeasurableSpace (G⧸Θ)] [BorelSpace (G⧸Θ)] + +def probability (μ : MeasureTheory.ProbabilityMeasure (G⧸Δ)) : + MeasureTheory.ProbabilityMeasure (G⧸Θ) := + μ.map (map Δ Θ hle) + +lemma probability_invariant (μ : MeasureTheory.ProbabilityMeasure (G⧸Δ)) + [MeasureTheory.SMulInvariantMeasure G (G⧸Δ) (μ : MeasureTheory.Measure _)] : + MeasureTheory.SMulInvariantMeasure G (G⧸Θ) + (probability Δ Θ hle μ : MeasureTheory.Measure _) := by + rw [probability, MeasureTheory.ProbabilityMeasure.toMeasure_map] + exact MeasureTheory.smulInvariantMeasure_map (μ : MeasureTheory.Measure _) _ + (map_smul Δ Θ hle) (continuous_map Δ Θ hle).measurable +end CosetCover + +namespace EmbeddedCubeHaar +open CubeFaces CubeLocalHaar RationalLattice MeasureTheory +variable {G H ι : Type} [Group G] [Group H] +variable [TopologicalSpace G] [TopologicalSpace H] +variable [IsTopologicalGroup G] [IsTopologicalGroup H] +variable [Fintype ι] [DecidableEq ι] +variable (F : H →* G) (hc : Continuous F) (K : Filtration H) (Λ : Subgroup G) (σ : G) + +abbrev inducedLattice : Subgroup H := Λ.comap (conjugateEmbedding F σ) + +def baseImage : ((cube K (Finset.univ : Finset ι) 0)⧸cubeLattice K (inducedLattice F Λ σ)) → + (Finset ι→G⧸Λ) := + Quotient.lift (fun g w=>QuotientGroup.mk (F (g.val w)*σ)) (by + intro g h he + funext w + apply QuotientGroup.eq.mpr + have hh := (QuotientGroup.leftRel_apply.mp he) w + change conjugateEmbedding F σ ((g.val w)⁻¹*h.val w)∈Λ at hh + simpa [conjugateEmbedding_apply,mul_assoc] using hh) + +omit [TopologicalSpace G] [TopologicalSpace H] [IsTopologicalGroup G] [IsTopologicalGroup H] in +@[simp] lemma baseImage_mk (g : cube K (Finset.univ : Finset ι) 0) (w : Finset ι) : + baseImage F K Λ σ (QuotientGroup.mk g) w=QuotientGroup.mk (F (g.val w)*σ) := rfl + +include hc in +omit [IsTopologicalGroup H] in +lemma baseImage_continuous : Continuous (baseImage (ι:=ι) F K Λ σ) := by + apply (QuotientGroup.isQuotientMap_mk _).continuous_iff.mpr + apply continuous_pi + intro w + exact QuotientGroup.continuous_mk.comp + ((hc.comp ((continuous_apply w).comp continuous_subtype_val)).mul continuous_const) + +omit [TopologicalSpace G] [TopologicalSpace H] [IsTopologicalGroup G] [IsTopologicalGroup H] in +lemma baseImage_injective : Function.Injective (baseImage (ι:=ι) F K Λ σ) := by + intro x y h + induction x using Quotient.inductionOn with | h x => + induction y using Quotient.inductionOn with | h y => + apply QuotientGroup.eq.mpr + intro w + have hh:=QuotientGroup.eq.mp (congrFun h w) + change (F (x.val w)*σ)⁻¹*(F (y.val w)*σ)∈Λ at hh + change conjugateEmbedding F σ ((x.val w)⁻¹*y.val w)∈Λ + simpa [conjugateEmbedding_apply,mul_assoc] using hh + +variable (Δ : Subgroup H) (hle : Δ ≤ inducedLattice F Λ σ) + +include hle in +omit [TopologicalSpace G] [TopologicalSpace H] [IsTopologicalGroup G] [IsTopologicalGroup H] in +theorem cubeInclusion : cubeLattice (ι:=ι) K Δ ≤ cubeLattice K (inducedLattice F Λ σ) := + fun _ hx w=>hle (hx w) + +def coverImage : ((cube K (Finset.univ : Finset ι) 0)⧸cubeLattice K Δ) → (Finset ι→G⧸Λ) := + baseImage F K Λ σ ∘ CosetCover.map _ _ (cubeInclusion F K Λ σ Δ hle) + +omit [TopologicalSpace G] [TopologicalSpace H] [IsTopologicalGroup G] [IsTopologicalGroup H] in +@[simp] lemma coverImage_mk (g : cube K (Finset.univ : Finset ι) 0) (w : Finset ι) : + coverImage F K Λ σ Δ hle (QuotientGroup.mk g) w=QuotientGroup.mk (F (g.val w)*σ) := rfl + +include hc in +omit [IsTopologicalGroup H] in +lemma coverImage_continuous : Continuous (coverImage (ι:=ι) F K Λ σ Δ hle) := + (baseImage_continuous F hc K Λ σ).comp (CosetCover.continuous_map _ _ _) + +def haarImage (a : Finset ι→G) + (x : (cube K (Finset.univ : Finset ι) 0)⧸cubeLattice K Δ) : Finset ι→G⧸Λ := + fun w=>a w • coverImage F K Λ σ Δ hle x w + +omit [TopologicalSpace G] [TopologicalSpace H] [IsTopologicalGroup G] [IsTopologicalGroup H] in +@[simp] lemma haarImage_mk (a : Finset ι→G) (g : cube K (Finset.univ : Finset ι) 0) (w : Finset ι) : + haarImage F K Λ σ Δ hle a (QuotientGroup.mk g) w= + QuotientGroup.mk (a w*F (g.val w)*σ) := by + change QuotientGroup.mk (a w*(F (g.val w)*σ))=QuotientGroup.mk (a w*F (g.val w)*σ) + rw [mul_assoc] + +include hc in +omit [IsTopologicalGroup H] in +lemma haarImage_continuous : Continuous (fun p : (Finset ι→G)× + ((cube K (Finset.univ : Finset ι) 0)⧸cubeLattice K Δ)=> + haarImage F K Λ σ Δ hle p.1 p.2) := by + apply continuous_pi + intro w + exact ((continuous_apply w).comp continuous_fst).smul + ((continuous_apply w).comp ((coverImage_continuous F hc K Λ σ Δ hle).comp continuous_snd)) + +variable [MeasurableSpace ((cube K (Finset.univ : Finset ι) 0)⧸cubeLattice K Δ)] +variable [BorelSpace ((cube K (Finset.univ : Finset ι) 0)⧸cubeLattice K Δ)] +variable [MeasurableSpace (G⧸Λ)] [BorelSpace (G⧸Λ)] [SecondCountableTopology (G⧸Λ)] + +def imageProbability (μ : ProbabilityMeasure + ((cube K (Finset.univ : Finset ι) 0)⧸cubeLattice K Δ)) (a : Finset ι→G) : + ProbabilityMeasure (Finset ι→G⧸Λ) := + μ.map (haarImage F K Λ σ Δ hle a) + +include hc in +omit [IsTopologicalGroup H] in +lemma integral_imageProbability (μ : ProbabilityMeasure + ((cube K (Finset.univ : Finset ι) 0)⧸cubeLattice K Δ)) + (a : Finset ι→G) (f : C((Finset ι→G⧸Λ),ℂ)) : + (∫ y,f y ∂(imageProbability F K Λ σ Δ hle μ a : Measure _))= + ∫ x,f (haarImage F K Λ σ Δ hle a x) ∂(μ : Measure _) := + integral_map + (((haarImage_continuous F hc K Λ σ Δ hle).comp + (continuous_const.prodMk continuous_id)).measurable.aemeasurable) + f.continuous.aestronglyMeasurable + +variable [FirstCountableTopology G] + +include hc in +omit [IsTopologicalGroup H] in +lemma imageProbability_continuous (μ : ProbabilityMeasure + ((cube K (Finset.univ : Finset ι) 0)⧸cubeLattice K Δ)) : + Continuous (imageProbability F K Λ σ Δ hle μ) := by + apply ProbabilityMeasure.continuous_iff_forall_continuous_integral.mpr + intro f + have he (a : Finset ι→G) : + (∫ y,f y ∂(imageProbability F K Λ σ Δ hle μ a : Measure _))= + ∫ x,f (haarImage F K Λ σ Δ hle a x) ∂(μ : Measure _) := + integral_map + (((haarImage_continuous F hc K Λ σ Δ hle).comp + (continuous_const.prodMk continuous_id)).measurable.aemeasurable) + f.continuous.aestronglyMeasurable + simp_rw [he] + apply continuous_of_dominated (bound:=fun _=>‖f‖) + · intro a + exact (f.continuous.comp ((haarImage_continuous F hc K Λ σ Δ hle).comp + (continuous_const.prodMk continuous_id))).aestronglyMeasurable + · intro a + exact Filter.Eventually.of_forall (fun x=>f.norm_coe_le_norm _) + · exact integrable_const _ + · exact Filter.Eventually.of_forall (fun x=>f.continuous.comp + ((haarImage_continuous F hc K Λ σ Δ hle).comp (continuous_id.prodMk continuous_const))) + +end EmbeddedCubeHaar + +end +end + +end OAI diff --git a/lean/OAI/Combinatorics/SumProduct/Alignment/FactorCoefficient01.lean b/lean/OAI/Combinatorics/SumProduct/Alignment/FactorCoefficient01.lean new file mode 100644 index 0000000000000000000000000000000000000000..5ee94cd5775bf4ca27844911372f22603ee34430 --- /dev/null +++ b/lean/OAI/Combinatorics/SumProduct/Alignment/FactorCoefficient01.lean @@ -0,0 +1,331 @@ +import Mathlib +import OAI.Combinatorics.SumProduct.Alignment.AffineCoefficient01 +import OAI.Combinatorics.SumProduct.Alignment.SquareHorizontal01 +import OAI.Geometry.NilpotentCharts.Main + +namespace OAI + +section +section +section +section +noncomputable section +open _root_.Polynomial _root_.OAI.Polynomial Finset +open scoped BigOperators +end +end + + + +section +noncomputable section +open _root_.Polynomial _root_.OAI.Polynomial Finset +open scoped BigOperators +namespace LagrangeBounds +variable {ι : Type*} [DecidableEq ι] + +lemma common_denominator (s : Finset ι) (p : ι → ℚ[X]) : + ∃ D : ℤ, D ≠ 0 ∧ ∀ i ∈ s, C (D : ℚ) * p i ∈ lifts (algebraMap ℤ ℚ) := by + induction s using Finset.induction_on with + | empty => exact ⟨1, one_ne_zero, by simp⟩ + | @insert i s hi ih => + obtain ⟨D, hD, hs⟩ := ih + obtain ⟨b, hb, hp⟩ := IsLocalization.integerNormalization_spec + (nonZeroDivisors ℤ) (p i) + have hbi : C (b : ℚ) * p i ∈ lifts (algebraMap ℤ ℚ) := by + apply (mem_lifts _).mpr + refine ⟨IsLocalization.integerNormalization (nonZeroDivisors ℤ) (p i), ?_⟩ + rw [hp, ← algebraMap_smul ℚ, smul_eq_C_mul] + rfl + refine ⟨b * D, mul_ne_zero (mem_nonZeroDivisors_iff_ne_zero.mp hb) hD, ?_⟩ + intro j hj + rcases mem_insert.mp hj with rfl | hj + · simpa [Int.cast_mul, map_mul, mul_assoc, mul_left_comm, mul_comm] using + base_mul_mem_lifts D hbi + · simpa [Int.cast_mul, map_mul, mul_assoc] using base_mul_mem_lifts b (hs j hj) + + +theorem interpolation_common_denominator (s : Finset ι) (v : ι → ℚ) : + ∃ D : ℤ, D ≠ 0 ∧ ∀ r : ι → ℤ, + C (D : ℚ) * Lagrange.interpolate s v (fun i => (r i : ℚ)) ∈ + lifts (algebraMap ℤ ℚ) := by + obtain ⟨D, hD, hbasis⟩ := common_denominator s (Lagrange.basis s v) + refine ⟨D, hD, fun r => ?_⟩ + rw [Lagrange.interpolate_apply, mul_sum] + apply (lifts (algebraMap ℤ ℚ)).sum_mem + intro i hi + simpa [mul_assoc, mul_left_comm, mul_comm] using base_mul_mem_lifts (r i) (hbasis i hi) + +lemma map_interpolate {F K : Type*} [Field F] [Field K] (f : F →+* K) + (s : Finset ι) (v r : ι → F) : + (Lagrange.interpolate s v r).map f = + Lagrange.interpolate s (fun i => f (v i)) (fun i => f (r i)) := by + simp [Lagrange.interpolate_apply, Lagrange.basis, Lagrange.basisDivisor, + Polynomial.map_sum, Polynomial.map_prod] + +end LagrangeBounds + +namespace PeriodicCoefficients + + + +theorem denominator (s T : ℕ) (hT : 0 (T:ℚ)*i.val + obtain ⟨D,hD,hd⟩ := LagrangeBounds.interpolation_common_denominator Finset.univ nodes + refine ⟨D,hD,?_⟩ + intro P hP hv + let R := P-C (P.eval 0) + have hR : R.natDegree ≤ s := by + exact (natDegree_sub_le P (C (P.eval 0))).trans (max_le hP (by simp)) + let m : Fin (s+1) → ℤ := fun i => (hv i.val).choose + have hm (i : Fin (s+1)) : R.eval ((T:ℝ)*i.val)=(m i:ℝ) := by + simpa [R,m] using (hv i.val).choose_spec + have hinj : Function.Injective (fun i : Fin (s+1) => (T:ℝ)*i.val) := by + intro i k he + apply Fin.ext + exact_mod_cast (mul_left_cancel₀ (by exact_mod_cast Nat.ne_of_gt hT : (T:ℝ)≠0) he) + have hdeg : R.degree < ((Finset.univ : Finset (Fin (s+1))).card:WithBot ℕ) := by + simp only [Finset.card_univ,Fintype.card_fin] + exact (degree_le_natDegree (p:=R)).trans_lt (WithBot.coe_lt_coe.mpr (Nat.lt_succ_of_le hR)) + have he : R=Lagrange.interpolate Finset.univ (fun i : Fin (s+1) => (T:ℝ)*i.val) (fun i => (m i:ℝ)) := by + simpa only [hm] using (Lagrange.eq_interpolate hinj.injOn hdeg) + obtain ⟨U,hU⟩ := (mem_lifts _).mp (hd m) + have hh := congrArg (fun q : ℚ[X] => q.map (Rat.castHom ℝ)) hU + have hhom : (Rat.castHom ℝ).comp (algebraMap ℤ ℚ)=Int.castRingHom ℝ := by ext; simp + have hh' : U.map (Int.castRingHom ℝ)=C (D:ℝ)*R := by + simpa only [Polynomial.map_map,hhom,Polynomial.map_mul,Polynomial.map_C,LagrangeBounds.map_interpolate, + Rat.coe_castHom,Rat.cast_intCast,nodes,Rat.cast_mul,Rat.cast_natCast,← he] using hh + intro j hj + refine ⟨U.coeff j,?_⟩ + have hc := congrArg (fun q : ℝ[X] => q.coeff j) hh' + simpa [R,coeff_sub,coeff_C,show j≠0 by omega] using hc.symm + +end PeriodicCoefficients +end +end + + + +section +noncomputable section +open _root_.Polynomial _root_.OAI.Polynomial Finset +namespace SmoothCharacterCoefficients +open RationalLattice DensePolynomialInterpolation + + + +theorem interval_coefficients (s N : ℕ) (hN : 2*(s+1) ≤ N) + (B : ℝ) (hB : 0 ≤ B) (P : ℝ[X]) (hP : P.natDegree ≤ s) + (hb : ∀ z : ℤ, |(z:ℝ)| ≤ N → |P.eval (z:ℝ)| ≤ B) : + ∀ j : ℕ, |P.coeff j| ≤ coefficientConstant s * uniformBound s 1 * B/(N:ℝ)^j := by + classical + let E : Finset ℤ := (range N).image (fun k : ℕ => (k:ℤ)) + have hcard : E.card=N := by + rw [Finset.card_image_of_injective _ (Nat.cast_injective : Function.Injective (fun k : ℕ => (k:ℤ))),Finset.card_range] + have hNp : 0 (χ g).toAdd) := hχ + obtain ⟨A,hA⟩ := hK.exists_bound_of_continuousOn hc.continuousOn + refine ⟨|A|+1,by positivity,?_⟩ + intro g hg + have hm : g∈K := ⟨c.coord g,by simpa only [Metric.mem_closedBall,dist_zero_right] using hg,c.coord.symm_apply_apply g⟩ + have hh := hA g hm + rw [Real.norm_eq_abs] at hh + exact hh.trans ((le_abs_self A).trans (by linarith)) + +end SmoothCharacterCoefficients +end +end + + + +section +noncomputable section +open _root_.Polynomial _root_.OAI.Polynomial Finset +namespace FactorCoefficientTransfer +open DensePolynomialInterpolation + + + +theorem factorized_coefficients (s T : ℕ) (hT : 0 (z:ℝ)))).mono + rintro x ⟨z,rfl⟩ + exact h z + +variable {G : Type*} [Group G] + +lemma periodic_character_values (Γ : Subgroup G) (χ : G →* Multiplicative ℝ) + (hint : ∀ g∈Γ, ∃ z : ℤ, (χ g).toAdd=z) + (T : ℕ) (b : ℤ → G) + (hp : Function.Periodic (fun z => (QuotientGroup.mk (b z) : G⧸Γ)) (T:ℤ)) + (P : ℝ[X]) (he : ∀ z : ℤ, P.eval (z:ℝ)=(χ (b z)).toAdd) : + ∀ k : ℕ, ∃ z : ℤ, P.eval ((T:ℝ)*k)-P.eval 0=z := by + intro k + have hq : (QuotientGroup.mk (b ((T:ℤ)*k)) : G⧸Γ)=QuotientGroup.mk (b 0) := by + simpa only [zero_add,nsmul_eq_mul,mul_comm] using (hp.nat_mul k) 0 + have hg : (b 0)⁻¹*b ((T:ℤ)*k)∈Γ := QuotientGroup.eq.mp hq.symm + obtain ⟨z,hz⟩ := hint _ hg + refine ⟨z,?_⟩ + have he1 := he ((T:ℤ)*k) + have he0 := he 0 + simp only [Int.cast_mul,Int.cast_natCast] at he1 + simp only [Int.cast_zero] at he0 + rw [he1,he0] + simpa only [map_mul,map_inv,toAdd_mul,toAdd_inv,sub_eq_add_neg,add_comm] using hz + +variable [TopologicalSpace G] [IsTopologicalGroup G] + + + +omit [IsTopologicalGroup G] in +theorem uniform_character_transfer (H : Filtration G) (_h0 : H.level 0=⊤) + (Γ : Subgroup G) {m : ℕ} (c : RealCoordinates (H.level 2) m) + (s : ℕ) (hs : H.level (s+1)=⊥) (T : ℕ) (hT : 0 (e z).val) → + Polynomial H 0 (fun z => (b z).val) → + (∀ z, f z=(e z).val*f' z*(b z).val) → + Function.Periodic (fun z => (QuotientGroup.mk (b z).val : G⧸Γ)) (T:ℤ) → + (∀ z : ℤ, |(z:ℝ)| ≤ N → ‖c.coord (e z)‖ ≤ B) → + ∀ v : G, ∀ R : ℝ[X], + (∀ z : ℤ, R.eval (z:ℝ)=(χ (v⁻¹*f' ((T:ℤ)*z+r)*v)).toAdd) → + (∀ j : ℕ, 0 (b z).val) hper W hWe + · simpa only [hQR] using hRc + +end FactorCoefficientTransfer + +end +end +end +end +end + +end OAI diff --git a/lean/OAI/Combinatorics/SumProduct/Alignment/FejerDetection01.lean b/lean/OAI/Combinatorics/SumProduct/Alignment/FejerDetection01.lean new file mode 100644 index 0000000000000000000000000000000000000000..eb834b828adb7762b20d2b895d2b99a64fc1b975 --- /dev/null +++ b/lean/OAI/Combinatorics/SumProduct/Alignment/FejerDetection01.lean @@ -0,0 +1,272 @@ +import Mathlib +import OAI.Combinatorics.SumProduct.Alignment.PolynomialDephasing01 +import OAI.Geometry.NilpotentCharts.Main + +namespace OAI + +section +section +section +section +namespace FejerDetection +open PolynomialWeyl +open scoped BigOperators ComplexConjugate +noncomputable section + +lemma mean_near_one (R : ℕ) (hR : 0 < R) (f : ℕ → ℂ) + (hf : ∀ a ∈ Finset.range R, ‖f a - 1‖ ≤ (1:ℝ)/2) : + (1:ℝ)/4 ≤ ‖mean R f‖^2 := by + have he : mean R f - 1 = mean R (fun a => f a - 1) := by + simp [mean,Finset.expect_sub_distrib,Finset.expect_const + (Finset.nonempty_range_iff.mpr (Nat.ne_of_gt hR))] + have h : ‖mean R f - 1‖ ≤ (1:ℝ)/2 := by + rw [he] + exact (RCLike.norm_expect_le (K := ℂ)).trans + (Finset.expect_le (Finset.nonempty_range_iff.mpr (Nat.ne_of_gt hR)) hf) + have ht := norm_le_norm_add_norm_sub (mean R f) (1:ℂ) + norm_num at ht + nlinarith [norm_nonneg (mean R f)] + +lemma near_integer_phase (x ε : ℝ) (z : ℤ) (R : ℕ) + (hx : |x-z| ≤ ε) (hε : 0 ≤ ε) (hsmall : 2*Real.pi*R*ε ≤ (1:ℝ)/2) + (a : ℕ) (ha : a < R) : + ‖phase ((a:ℝ)*x) - 1‖ ≤ (1:ℝ)/2 := by + have h := PolynomialDephasing.norm_phase_sub_le ((a:ℝ)*x) ((a:ℝ)*(z:ℝ)) + rw [show (a:ℝ)*(z:ℝ) = ((a:ℤ)*z:ℤ) by push_cast; rfl,phase_int] at h + push_cast at h + have he : (a:ℝ)*x - (a:ℝ)*(z:ℝ) = (a:ℝ)*(x-z) := by ring + have hr : ‖phase ((a:ℝ)*x) - 1‖ ≤ 2*Real.pi*((a:ℝ)*|x-z|) := by + simpa only [he,abs_mul,abs_of_nonneg (Nat.cast_nonneg a : (0:ℝ) ≤ a)] using h + have hbound : (a:ℝ)*|x-z| ≤ (R:ℝ)*ε := + (mul_le_mul_of_nonneg_left hx (Nat.cast_nonneg a)).trans + (mul_le_mul_of_nonneg_right (by exact_mod_cast ha.le) hε) + exact hr.trans ((mul_le_mul_of_nonneg_left hbound (by positivity)).trans (by nlinarith)) + +lemma energy_identity (N R : ℕ) (f : ℕ → ℝ) : + (𝔼 n ∈ Finset.range N, ‖mean R (fun a => phase ((a:ℝ)*f n))‖^2) = + 𝔼 a ∈ Finset.range R, 𝔼 b ∈ Finset.range R, + (mean N (fun n => phase (((a:ℝ)-b)*f n))).re := by + simp only [mean,norm_expect_sq_eq] + have hre {ι : Type} (S : Finset ι) (F : ι → ℂ) : + (𝔼 i ∈ S, F i).re = 𝔼 i ∈ S, (F i).re := + map_expect (Complex.reLm.restrictScalars ℚ≥0) F S + simp_rw [hre] + rw [Finset.expect_comm] + apply Finset.expect_congr rfl + intro a ha + rw [Finset.expect_comm] + apply Finset.expect_congr rfl + intro b hb + apply Finset.expect_congr rfl + intro n hn + rw [sub_mul,phase_sub] + + + +theorem detect (N R : ℕ) (hN : 0 < N) (hR : 0 < R) + (δ ε : ℝ) (hδ : 0 < δ) (hRδ : 16 ≤ δ*R) (hε : 0 ≤ ε) + (hsmall : 2*Real.pi*R*ε ≤ (1:ℝ)/2) + (S : Finset ℕ) (hSN : S ⊆ Finset.range N) (hS : δ*N ≤ (S.card:ℝ)) + (f : ℕ → ℝ) (hgood : ∀ n ∈ S, ∃ z : ℤ, |f n-z| ≤ ε) : + ∃ a ∈ Finset.range R, ∃ b ∈ Finset.range R, a ≠ b ∧ + δ/16 ≤ ‖mean N (fun n => phase (((a:ℝ)-b)*f n))‖ := by + classical + let E (n : ℕ) := ‖mean R (fun a => phase ((a:ℝ)*f n))‖^2 + have hgoodE : ∀ n ∈ S, (1:ℝ)/4 ≤ E n := by + intro n hn + obtain ⟨z,hz⟩ := hgood n hn + exact mean_near_one R hR _ (fun a ha => + near_integer_phase (f n) ε z R hz hε hsmall a (Finset.mem_range.mp ha)) + have hlow : δ/4 ≤ 𝔼 n ∈ Finset.range N, E n := by + rw [Finset.expect_eq_sum_div_card,Finset.card_range] + apply (le_div_iff₀ (Nat.cast_pos.mpr hN)).mpr + have h₁ := Finset.sum_le_sum hgoodE + have h₂ := Finset.sum_le_sum_of_subset_of_nonneg hSN + (fun n _ _ => sq_nonneg ‖mean R (fun a => phase ((a:ℝ)*f n))‖) + simp only [Finset.sum_const,nsmul_eq_mul] at h₁ + dsimp only [E] at h₁ + nlinarith + by_contra hx + push Not at hx + have hub (a : ℕ) (ha : a ∈ Finset.range R) (b : ℕ) (hb : b ∈ Finset.range R) : + (mean N (fun n => phase (((a:ℝ)-b)*f n))).re ≤ + (if a=b then (1:ℝ) else 0) + δ/16 := by + by_cases he : a=b + · subst b + simp [phase,mean,Finset.expect_const + (Finset.nonempty_range_iff.mpr (Nat.ne_of_gt hN))] + positivity + · exact (Complex.re_le_norm _).trans (by simpa [he] using (hx a ha b hb he).le) + have hup := Finset.expect_le_expect (fun a ha => + Finset.expect_le_expect (fun b hb => hub a ha b hb)) + have he (a : ℕ) (ha : a ∈ Finset.range R) : + (𝔼 b ∈ Finset.range R, ((if a=b then (1:ℝ) else 0)+δ/16)) = 1/(R:ℝ)+δ/16 := by + rw [Finset.expect_add_distrib, + Finset.expect_const (Finset.nonempty_range_iff.mpr (Nat.ne_of_gt hR)), + Finset.expect_eq_sum_div_card] + simp [Finset.sum_ite_eq,ha] + have he' : (𝔼 a ∈ Finset.range R, 𝔼 b ∈ Finset.range R, + ((if a=b then (1:ℝ) else 0)+δ/16)) = 1/(R:ℝ)+δ/16 := by + rw [Finset.expect_congr rfl he, + Finset.expect_const (Finset.nonempty_range_iff.mpr (Nat.ne_of_gt hR))] + rw [he'] at hup + have henergy := energy_identity N R f + change (𝔼 n ∈ Finset.range N, E n) = _ at henergy + rw [← henergy] at hup + have hrecip : 1/(R:ℝ) ≤ δ/16 := by + apply (div_le_iff₀ (Nat.cast_pos.mpr hR)).mpr + nlinarith + linarith + +end +end FejerDetection + + + +open _root_.Polynomial _root_.OAI.Polynomial Finset +open scoped BigOperators + +namespace LagrangeBounds + +variable {ι : Type*} [DecidableEq ι] + + +lemma basis_bound (s : Finset ι) (v : ι → ℝ) {i : ι} (hi : i ∈ s) + {a b d x : ℝ} (hd : 0 < d) (hv : ∀ j ∈ s, v j ∈ Set.Icc a b) + (hsep : ∀ j ∈ s, j ≠ i → d ≤ |v i - v j|) (hx : x ∈ Set.Icc a b) : + |(Lagrange.basis s v i).eval x| ≤ ((b - a) / d) ^ (s.card - 1) := by + rw [Lagrange.basis, eval_prod, Finset.abs_prod] + calc + (∏ j ∈ s.erase i, |eval x (Lagrange.basisDivisor (v i) (v j))|) ≤ + ∏ _j ∈ s.erase i, (b - a) / d := by + apply prod_le_prod₀ + · intro _ _; positivity + · intro j hj + obtain ⟨hji, hjs⟩ := mem_erase.mp hj + simp only [Lagrange.basisDivisor, eval_mul, eval_C, eval_sub, eval_X, + abs_mul, abs_inv] + rw [mul_comm, ← div_eq_mul_inv] + have hnum : |x - v j| ≤ b - a := by + rw [abs_le] + have := hv j hjs + constructor <;> linarith [hx.1, hx.2, this.1, this.2] + exact div_le_div₀ (by linarith [hx.1, hx.2]) hnum hd (hsep j hjs hji) + _ = _ := by rw [prod_const, card_erase_of_mem hi] + + +theorem interpolate_error (s : Finset ι) (v : ι → ℝ) (hv_inj : Set.InjOn v s) + {a b d ε x : ℝ} (hd : 0 < d) (hε : 0 ≤ ε) + (hv : ∀ j ∈ s, v j ∈ Set.Icc a b) + (hsep : ∀ i ∈ s, ∀ j ∈ s, j ≠ i → d ≤ |v i - v j|) + (hx : x ∈ Set.Icc a b) (T : ℝ[X]) (hT : T.degree < s.card) + (r : ι → ℝ) (hr : ∀ i ∈ s, |r i - T.eval (v i)| ≤ ε) : + |(Lagrange.interpolate s v r).eval x - T.eval x| ≤ + (s.card : ℝ) * ((b - a) / d) ^ (s.card - 1) * ε := by + have heq : Lagrange.interpolate s v (fun i => T.eval (v i)) = T := + (Lagrange.eq_interpolate hv_inj hT).symm + rw [← heq, ← eval_sub, ← map_sub] + rw [Lagrange.interpolate_apply, eval_finsetSum] + calc + |∑ i ∈ s, eval x (C ((r - fun i => T.eval (v i)) i) * Lagrange.basis s v i)| ≤ + ∑ i ∈ s, ε * ((b - a) / d) ^ (s.card - 1) := by + apply (abs_sum_le_sum_abs _ _).trans + apply sum_le_sum + intro i hi + simp only [eval_mul, eval_C, Pi.sub_apply, abs_mul] + exact mul_le_mul (hr i hi) (basis_bound s v hi hd hv (hsep i hi) hx) + (abs_nonneg _) hε + _ = _ := by simp [mul_left_comm, mul_comm] + +end LagrangeBounds + + + +namespace DenseIntegerNodes +open Finset + +lemma strictMono_int_gap {N : ℕ} (f : Fin N → ℤ) (hf : StrictMono f) + {i j : Fin N} (hij : i ≤ j) : (j.val : ℤ) - i.val ≤ f j - f i := by + cases N with + | zero => exact Fin.elim0 i + | succ N => + have hg : Monotone (fun i : Fin (N+1) => f i - (i.val : ℤ)) := by + apply Fin.monotone_iff_le_succ.mpr + intro k + have h := hf (Fin.castSucc_lt_succ (i := k)) + simp only [Fin.val_castSucc, Fin.val_succ, Nat.cast_add, Nat.cast_one] + omega + have h := hg hij + dsimp only at h + omega + + +theorem separated (E : Finset ℤ) (q : ℕ) (hE : 2 * (q+1) ≤ E.card) : + ∃ v : Fin (q+1) → ℤ, (∀ i, v i ∈ E) ∧ + ∀ i j, i ≠ j → (E.card : ℝ) / (2 * (q+1)) ≤ |(v i : ℝ) - v j| := by + let K := E.card + let h := K / (q+1) + have hq : 0 < q+1 := by omega + have hh : 1 ≤ h := by + dsimp [h, K] + exact (Nat.le_div_iff_mul_le hq).mpr (by omega) + have hmul : h * (q+1) ≤ K := Nat.div_mul_le_self K (q+1) + have hrem := Nat.mod_lt K hq + have hdiv : K % (q+1) + (q+1) * h = K := Nat.mod_add_div K (q+1) + have hhalf : K ≤ 2 * (q+1) * h := by + have htwo : 2 ≤ h := by + dsimp [h, K] + exact (Nat.le_div_iff_mul_le hq).mpr (by omega) + have hd : K < (q+1) * (h+1) := by nlinarith + have hh' : h+1 ≤ 2*h := by omega + have := Nat.mul_le_mul_left (q+1) hh' + nlinarith + let idx : Fin (q+1) → Fin K := fun i => ⟨h * i.val, by + have hi : i.val ≤ q := by omega + have hlt : h * i.val < h * (q+1) := Nat.mul_lt_mul_of_pos_left i.isLt (by omega) + exact hlt.trans_le hmul⟩ + let v : Fin (q+1) → ℤ := fun i => E.orderEmbOfFin rfl (idx i) + refine ⟨v, fun i => E.orderEmbOfFin_mem rfl (idx i), ?_⟩ + have hbound : (K : ℝ) / (2 * (q+1)) ≤ (h : ℝ) := by + apply (div_le_iff₀ (by positivity : (0 : ℝ) < 2 * (q+1))).mpr + exact_mod_cast (show K ≤ h * (2 * (q+1)) by nlinarith) + have hsep (i j : Fin (q+1)) (hij : i < j) : (h : ℝ) ≤ (v j : ℝ) - v i := by + have hj : i.val + 1 ≤ j.val := hij + have hidx : idx i ≤ idx j := by + change h * i.val ≤ h * j.val + exact Nat.mul_le_mul_left h (by omega) + have hgap := strictMono_int_gap (E.orderEmbOfFin rfl) (E.orderEmbOfFin rfl).strictMono hidx + change (h * j.val : ℕ) - (h * i.val : ℤ) ≤ v j - v i at hgap + have hmulij := Nat.mul_le_mul_left h hj + have hhgap : (h : ℤ) ≤ (h * j.val : ℕ) - (h * i.val : ℤ) := by + have hm : ((h + h * i.val : ℕ) : ℤ) ≤ (h * j.val : ℕ) := by + exact_mod_cast (show h + h * i.val ≤ h * j.val by nlinarith) + push_cast at hm ⊢ + omega + have hx : (h : ℤ) ≤ v j - v i := hhgap.trans hgap + exact_mod_cast hx + intro i j hij + rcases lt_or_gt_of_ne hij with hij | hij + · have hj := hsep i j hij + rw [abs_sub_comm, abs_of_nonneg (by linarith : (0 : ℝ) ≤ v j - v i)] + exact hbound.trans hj + · have hi := hsep j i hij + rw [abs_of_nonneg (by linarith : (0 : ℝ) ≤ v i - v j)] + exact hbound.trans hi + + +theorem separated_of_density (E : Finset ℤ) (q : ℕ) {H α : ℝ} + (hE : 2 * (q+1) ≤ E.card) (hdens : α * H ≤ E.card) : + ∃ v : Fin (q+1) → ℤ, (∀ i, v i ∈ E) ∧ + ∀ i j, i ≠ j → α * H / (2 * (q+1)) ≤ |(v i : ℝ) - v j| := by + obtain ⟨v, hv, hs⟩ := separated E q hE + exact ⟨v, hv, fun i j hij => (div_le_div_of_nonneg_right hdens (by positivity)).trans + (hs i j hij)⟩ + +end DenseIntegerNodes + +end +end +end +end + +end OAI diff --git a/lean/OAI/Combinatorics/SumProduct/Alignment/FilteredShears01.lean b/lean/OAI/Combinatorics/SumProduct/Alignment/FilteredShears01.lean new file mode 100644 index 0000000000000000000000000000000000000000..378d6209c40a7e6ad7d2788577db41739fa9b731 --- /dev/null +++ b/lean/OAI/Combinatorics/SumProduct/Alignment/FilteredShears01.lean @@ -0,0 +1,441 @@ +import Mathlib +import OAI.Combinatorics.SumProduct.Alignment.WeightedPolynomial01 +import OAI.Geometry.NilpotentCharts.Main + +namespace OAI + +section +section + + +noncomputable section +open _root_.Polynomial _root_.OAI.Polynomial +namespace RationalLattice +open MalcevCharacters CubePolynomials WeightedPolynomial +variable {G : Type*} [Group G] [TopologicalSpace G] [IsTopologicalGroup G] +variable {n : ℕ} (c : RealCoordinates G n) (hsk : SecondKind c) +variable (H : CubeFaces.Filtration G) (w : Fin n → ℕ) +variable (hH : ∀ k (g : G),g∈H.level k ↔ ∀ i : Fin n,w i < k → c.coord g i=0) + +def realUniversalPowerPolynomial (i : Fin n) : Polynomial (MvPolynomial (Fin n) ℝ) := + (universalPowerPolynomial c i).map (MvPolynomial.map (algebraMap ℚ ℝ)) + +omit [IsTopologicalGroup G] in +lemma realUniversalPowerPolynomial_eval (i : Fin n) (x : Fin n → ℝ) (t : ℝ) : + MvPolynomial.eval x ((realUniversalPowerPolynomial c i).eval (MvPolynomial.C t))= + (universalPowerPolynomial c i).eval₂ (parameterEval x) t := by + rw [← Polynomial.eval₂_at_apply,realUniversalPowerPolynomial,Polynomial.eval₂_map] + have hc : (MvPolynomial.eval x).comp (MvPolynomial.map (algebraMap ℚ ℝ))=parameterEval x := by + ext a <;> simp [parameterEval] + rw [hc] + simp + +include hsk hH in +omit [IsTopologicalGroup G] in +lemma realUniversalPowerPolynomial_nat_weighted (i : Fin n) (a : ℕ) : + Bounded w (w i) ((realUniversalPowerPolynomial c i).eval (MvPolynomial.C (a:ℝ))) := by + apply (bounded_iff_ray w (w i) _).mpr + intro x + let Q := (realUniversalPowerPolynomial c i).eval (MvPolynomial.C (a:ℝ)) + have ht (t : ℝ) : (ray w x Q).eval t=c.coord ((c.coord.symm (scale w t x))^a) i := by + rw [ray_eval,realUniversalPowerPolynomial_eval] + convert universalPowerPolynomial_nat c (c.coord.symm (scale w t x)) i a using 1 + rw [Homeomorph.apply_symm_apply] + have hp : (fun t : ℝ=>(c.coord.symm (scale w t x))^a)∈polynomials H 0 := + (polynomials H 0).pow_mem (scale_path_mem c hsk H w hH x) a + exact coordinate_natDegree c hsk H w hH _ hp + (fun j=>ray w x ((realUniversalPowerPolynomial c j).eval (MvPolynomial.C (a:ℝ)))) + (fun t j=>by + rw [ray_eval,realUniversalPowerPolynomial_eval] + convert universalPowerPolynomial_nat c (c.coord.symm (scale w t x)) j a using 1 + rw [Homeomorph.apply_symm_apply]) i + +include hsk hH in + + +omit [IsTopologicalGroup G] in +theorem canonicalLog_weighted (i : Fin n) : + ∃ p : MvPolynomial (Fin n) ℝ,Bounded w (w i) p ∧ + ∀ x,canonicalLog c (c.coord.symm x) i=MvPolynomial.eval x p := by + refine ⟨(realUniversalPowerPolynomial c i).coeff 1, + bounded_coeff_of_nat_evals w (w i) _ + (realUniversalPowerPolynomial_nat_weighted c hsk H w hH i) 1,?_⟩ + intro x + simp only [realUniversalPowerPolynomial,Polynomial.coeff_map,MvPolynomial.eval_map, + canonicalLog,powerPolynomial_eq_universal,Polynomial.coeff_map, + Homeomorph.apply_symm_apply] + rfl + +end RationalLattice +end + +end + +section + + + + +open scoped commutatorElement + +namespace FilteredShears + +variable {R V : Type*} [CommRing R] [AddCommGroup V] [Module R V] + + +def filtrationAut (F : ℕ → Submodule R V) : Subgroup (V ≃ₗ[R] V) where + carrier := {g | ∀ d x, x ∈ F d → g x ∈ F d ∧ g⁻¹ x ∈ F d} + one_mem' := by intro d x hx; exact ⟨hx, hx⟩ + mul_mem' := by + intro g h hg hh d x hx + exact ⟨(hg d (h x) (hh d x hx).1).1, + (hh d (g⁻¹ x) (hg d x hx).2).2⟩ + inv_mem' := by + intro g hg d x hx + exact ⟨(hg d x hx).2, (hg d x hx).1⟩ + +variable (F : ℕ → Submodule R V) + + +def Lowers (a : ℕ) (g : filtrationAut F) : Prop := + ∀ d x, x ∈ F d → (g.val x - x) ∈ F (d - a) + + +def lowering (a : ℕ) : Subgroup (filtrationAut F) where + carrier := {g | Lowers F a g} + one_mem' := by intro d x hx; simp + mul_mem' := by + intro g h hg hh d x hx + have h₁ := hg d (h.val x) (h.property d x hx).1 + have h₂ := hh d x hx + convert (F (d - a)).add_mem h₁ h₂ using 1 + simp + inv_mem' := by + intro g hg d x hx + have h := hg d (g.val⁻¹ x) (g.property d x hx).2 + convert (F (d - a)).neg_mem h using 1 + simp + +lemma commutator_lowers {a b : ℕ} {g h : filtrationAut F} + (hg : Lowers F a g) (hh : Lowers F b h) : Lowers F (a + b) ⁅g, h⁆ := by + intro d x hx + let z := g.val⁻¹ (h.val⁻¹ x) + have hz : z ∈ F d := (g.property d _ (h.property d x hx).2).2 + have h₁ := hg (d - b) (h.val z - z) (hh d z hz) + have h₂ := hh (d - a) (g.val z - z) (hg d z hz) + rw [Nat.sub_sub] at h₁ h₂ + rw [Nat.add_comm b a] at h₁ + have ht := (F (d - (a + b))).sub_mem h₁ h₂ + simpa [commutatorElement_def, z, map_sub, sub_eq_add_neg, add_assoc, + add_left_comm, add_comm] using ht + +lemma commutator_lowering_le (a b : ℕ) : + ⁅lowering F a, lowering F b⁆ ≤ lowering F (a + b) := by + apply Subgroup.commutator_le.mpr + intro g hg h hh + exact commutator_lowers F hg hh + +lemma lowerCentralSeries_le (n : ℕ) : + (lowering F 1).lowerCentralSeries n ≤ lowering F (n + 1) := by + induction n with + | zero => exact le_rfl + | succ n hn => + exact (Subgroup.commutator_mono hn le_rfl).trans (commutator_lowering_le F (n + 1) 1) + +lemma lowering_eq_bot {s : ℕ} (hzero : F 0 = ⊥) (htop : F s = ⊤) : + lowering F s = ⊥ := by + apply le_antisymm _ bot_le + intro g hg + have he : g.val = 1 := by + ext x + have h := hg s x (by simp [htop]) + rw [Nat.sub_self, hzero, Submodule.mem_bot] at h + exact sub_eq_zero.mp h + exact (Subgroup.mem_bot).mpr (Subtype.ext he) + + + +theorem lowering_nilpotent {s : ℕ} (hzero : F 0 = ⊥) (htop : F (s + 1) = ⊤) : + Group.IsNilpotent (lowering F 1) := by + apply Subgroup.isNilpotent_of_lowerCentralSeries_eq_bot (n := s) + apply le_antisymm _ bot_le + exact (lowerCentralSeries_le F s).trans (by rw [lowering_eq_bot F hzero htop]) + +theorem lowering_class_le {s : ℕ} (hzero : F 0 = ⊥) (htop : F (s + 1) = ⊤) : + Group.nilpotencyClass (lowering F 1) ≤ s := by + let := lowering_nilpotent F hzero htop + apply Subgroup.lowerCentralSeries_eq_bot_iff_nilpotencyClass_le.mp + rw [← Subgroup.map_subtype_inj, Subgroup.map_bot, Subgroup.top_subtype_lowerCentralSeries] + apply le_antisymm _ bot_le + exact (lowerCentralSeries_le F s).trans (by rw [lowering_eq_bot F hzero htop]) + +namespace PolynomialShears + +open MvPolynomial + +variable {σ : Type*} (w : σ → ℕ) + + +def degreeLT (d : ℕ) : Submodule R (MvPolynomial σ R) where + carrier := {p | ∀ m, p.coeff m ≠ 0 → Finsupp.weight w m < d} + zero_mem' := by simp + add_mem' := by + intro p q hp hq m hm + by_cases hpm : p.coeff m = 0 + · exact hq m (by simpa [AddMonoidAlgebra.coeff_add, Finsupp.add_apply, hpm] using hm) + · exact hp m hpm + smul_mem' := by + intro r p hp m hm + apply hp m + contrapose! hm + simp [hm] + +lemma degreeLT_mono : Monotone (degreeLT (R := R) w) := by + intro a b hab p hp m hm + exact lt_of_lt_of_le (hp m hm) hab + +lemma degreeLT_zero : degreeLT (R := R) w 0 = ⊥ := by + apply le_antisymm _ bot_le + intro p hp + apply (Submodule.mem_bot R).mpr + ext m + by_contra hm + exact (Nat.not_lt_zero _ (hp m (by simpa using hm))) + +lemma monomial_mem (m : σ →₀ ℕ) (c : R) : + monomial m c ∈ degreeLT (R := R) w (Finsupp.weight w m + 1) := by + classical + intro n hn + by_cases hmn : m = n + · simp [hmn] + · simp [coeff_monomial, hmn] at hn + +lemma C_mem (c : R) : C c ∈ degreeLT (R := R) w 1 := by + simpa using monomial_mem w 0 c + +lemma X_mem (i : σ) : X i ∈ degreeLT (R := R) w (w i + 1) := by + simpa [X, Finsupp.weight_single] using monomial_mem w (Finsupp.single i 1) 1 + +lemma mul_mem {a b : ℕ} {p q : MvPolynomial σ R} + (hp : p ∈ degreeLT w a) (hq : q ∈ degreeLT w (b + 1)) : + p * q ∈ degreeLT w (a + b) := by + classical + intro m hm + rw [coeff_mul] at hm + obtain ⟨⟨u,v⟩, huv, hval⟩ := Finset.exists_ne_zero_of_sum_ne_zero hm + have hu := hp u (left_ne_zero_of_mul hval) + have hv := hq v (right_ne_zero_of_mul hval) + rw [← Finset.HasAntidiagonal.mem_antidiagonal.mp huv, map_add] + change Finsupp.weight w u + Finsupp.weight w v < a + b + omega + +lemma image_mem {g : MvPolynomial σ R →ₐ[R] MvPolynomial σ R} + {p : MvPolynomial σ R} {d : ℕ} + (hp : p ∈ degreeLT w (d + 1)) (hd : g p - p ∈ degreeLT w d) : + g p ∈ degreeLT w (d + 1) := by + have := (degreeLT w (d + 1)).add_mem + (degreeLT_mono w (Nat.le_succ d) hd) hp + simpa using this + +lemma product_drop {g : MvPolynomial σ R →ₐ[R] MvPolynomial σ R} + {p q : MvPolynomial σ R} {a b : ℕ} + (hp : p ∈ degreeLT w (a + 1)) (hq : q ∈ degreeLT w (b + 1)) + (hdp : g p - p ∈ degreeLT w a) (hdq : g q - q ∈ degreeLT w b) : + g (p * q) - p * q ∈ degreeLT w (a + b) := by + have h₁ := mul_mem w hdp (image_mem w hq hdq) + have h₂ := mul_mem w hdq hp + rw [Nat.add_comm b a] at h₂ + convert (degreeLT w (a + b)).add_mem h₁ h₂ using 1 + rw [map_mul] + ring + +lemma monomial_one_drop (g : MvPolynomial σ R →ₐ[R] MvPolynomial σ R) + (hg : ∀ i, g (X i) - X i ∈ degreeLT w (w i)) (m : σ →₀ ℕ) : + g (monomial m 1) - monomial m 1 ∈ degreeLT w (Finsupp.weight w m) := by + induction m using Finsupp.induction_linear with + | zero => simp + | add m n hm hn => + have h := product_drop w (monomial_mem w m 1) (monomial_mem w n 1) hm hn + simpa [monomial_mul_monomial, map_add] using h + | single i n => + induction n with + | zero => simp + | succ n hn => + have h := product_drop w (monomial_mem w (Finsupp.single i n) 1) + (X_mem w (R := R) i) hn (hg i) + simpa [X, monomial_mul_monomial, ← Finsupp.single_add, Finsupp.weight_single, + add_mul, Nat.succ_eq_add_one] using h + +lemma monomial_drop (g : MvPolynomial σ R →ₐ[R] MvPolynomial σ R) + (hg : ∀ i, g (X i) - X i ∈ degreeLT w (w i)) (m : σ →₀ ℕ) (c : R) : + g (monomial m c) - monomial m c ∈ degreeLT w (Finsupp.weight w m) := by + have hc : g (C c) - C c ∈ degreeLT w 0 := by simp + have h := product_drop w (C_mem w c) (monomial_mem w m 1) hc + (monomial_one_drop w g hg m) + simpa [C_mul_monomial] using h + + + +theorem substitution_lowers (g : MvPolynomial σ R →ₐ[R] MvPolynomial σ R) + (hg : ∀ i, g (X i) - X i ∈ degreeLT w (w i)) {d : ℕ} + {p : MvPolynomial σ R} (hp : p ∈ degreeLT w d) : + g p - p ∈ degreeLT w (d - 1) := by + classical + have h : ∑ m ∈ p.support, (g (monomial m (p.coeff m)) - monomial m (p.coeff m)) + ∈ degreeLT w (d - 1) := by + apply Submodule.sum_mem + intro m hm + exact degreeLT_mono w (Nat.le_sub_one_of_lt (hp m (mem_support_iff.mp hm))) + (monomial_drop w g hg m (p.coeff m)) + simpa [Finset.sum_sub_distrib, ← map_sum, support_sum_monomial_coeff] using h + +lemma exists_degree_bound (p : MvPolynomial σ R) : ∃ d, p ∈ degreeLT w d := by + classical + refine ⟨p.support.sup (Finsupp.weight w) + 1, ?_⟩ + intro m hm + exact Nat.lt_succ_of_le (Finset.le_sup (f := Finsupp.weight w) (mem_support_iff.mpr hm)) + +lemma injective_of_lowers (g : MvPolynomial σ R →ₐ[R] MvPolynomial σ R) + (hg : ∀ i, g (X i) - X i ∈ degreeLT w (w i)) : Function.Injective g := by + have hker : ∀ d (p : MvPolynomial σ R), p ∈ degreeLT w d → g p = 0 → p = 0 := by + intro d + induction d with + | zero => intro p hp _; simpa [degreeLT_zero] using hp + | succ d ih => + intro p hp hgp + have hd := substitution_lowers w g hg hp + have hp' : p ∈ degreeLT w d := by + simpa [hgp] using (degreeLT w d).neg_mem hd + exact ih p hp' hgp + intro p q he + obtain ⟨d, hd⟩ := exists_degree_bound w (p - q) + exact sub_eq_zero.mp (hker d _ hd (by simp [map_sub, he])) + +lemma surjective_of_lowers (g : MvPolynomial σ R →ₐ[R] MvPolynomial σ R) + (hg : ∀ i, g (X i) - X i ∈ degreeLT w (w i)) : Function.Surjective g := by + have hs : ∀ d (p : MvPolynomial σ R), p ∈ degreeLT w d → ∃ q, g q = p := by + intro d + induction d with + | zero => + intro p hp + have hp' : p = 0 := by simpa [degreeLT_zero] using hp + exact ⟨0, by simp [hp']⟩ + | succ d ih => + intro p hp + obtain ⟨q, hq⟩ := ih (g p - p) (by simpa using substitution_lowers w g hg hp) + exact ⟨p - q, by simp [map_sub, hq]⟩ + intro p + obtain ⟨d, hd⟩ := exists_degree_bound w p + exact hs d p hd + + + +noncomputable def ofDisplacements (p : σ → MvPolynomial σ R) + (hp : ∀ i, p i ∈ degreeLT w (w i)) : MvPolynomial σ R ≃ₐ[R] MvPolynomial σ R := + let g := aeval (fun i => X i + p i) + have hg : ∀ i, g (X i) - X i ∈ degreeLT w (w i) := by + intro i + simpa [g] using hp i + AlgEquiv.ofBijective g ⟨injective_of_lowers w g hg, surjective_of_lowers w g hg⟩ + +@[simp] lemma ofDisplacements_X (p : σ → MvPolynomial σ R) + (hp : ∀ i, p i ∈ degreeLT w (w i)) (i : σ) : + ofDisplacements w p hp (X i) = X i + p i := by + simp [ofDisplacements] + + +theorem inverse_lowers (g : MvPolynomial σ R ≃ₐ[R] MvPolynomial σ R) + (hg : ∀ i, g (X i) - X i ∈ degreeLT w (w i)) {d : ℕ} + {p : MvPolynomial σ R} (hp : p ∈ degreeLT w d) : + g.symm p - p ∈ degreeLT w (d - 1) := by + induction d generalizing p with + | zero => + rw [degreeLT_zero, Submodule.mem_bot] at hp + simp [hp] + | succ d ih => + have hδ : g p - p ∈ degreeLT w d := by + simpa using substitution_lowers w g.toAlgHom hg hp + have hi := ih hδ + have hv := (degreeLT w d).add_mem + (degreeLT_mono w (Nat.sub_le d 1) hi) hδ + have he : g.symm (g p - p) = -(g.symm p - p) := by + simp [map_sub] + rw [sub_add_cancel, he] at hv + simpa using (degreeLT w d).neg_mem hv + + +def shears : Subgroup (MvPolynomial σ R ≃ₐ[R] MvPolynomial σ R) where + carrier := {g | ∀ i, g (X i) - X i ∈ degreeLT w (w i)} + one_mem' := by intro i; simp + mul_mem' := by + intro g h hg hh i + have h₁ : g (h (X i) - X i) ∈ degreeLT w (w i) := by + have ht := substitution_lowers w g.toAlgHom hg (hh i) + have := (degreeLT w (w i)).add_mem + (degreeLT_mono w (Nat.sub_le (w i) 1) ht) (hh i) + simpa using this + convert (degreeLT w (w i)).add_mem h₁ (hg i) using 1 + simp [map_sub] + inv_mem' := by + intro g hg i + simpa using inverse_lowers w g hg (X_mem w (R := R) i) + + +noncomputable def shearAction : shears (R := R) w →* filtrationAut (degreeLT (R := R) w) where + toFun g := ⟨g.val.toLinearEquiv, by + intro d p hp + constructor + · have hd := substitution_lowers w g.val.toAlgHom g.property hp + have := (degreeLT w d).add_mem (degreeLT_mono w (Nat.sub_le d 1) hd) hp + simpa using this + · have hd := inverse_lowers w g.val g.property hp + have := (degreeLT w d).add_mem (degreeLT_mono w (Nat.sub_le d 1) hd) hp + simpa using this⟩ + map_one' := by rfl + map_mul' := by intro g h; rfl + +lemma shearAction_lowers (g : shears (R := R) w) : + Lowers (degreeLT w) 1 (shearAction w g) := + fun _ _ hp => substitution_lowers w g.val.toAlgHom g.property hp + +lemma shear_lowerCentralSeries_eq_bot {s : ℕ} (hw : ∀ i, w i ≤ s) : + (⊤ : Subgroup (shears (R := R) w)).lowerCentralSeries s = ⊥ := by + let f := shearAction (R := R) w + have hm : Subgroup.map f ⊤ ≤ lowering (degreeLT w) 1 := by + rintro _ ⟨g, _, rfl⟩ + exact shearAction_lowers w g + have hc : Subgroup.map f ((⊤ : Subgroup (shears (R := R) w)).lowerCentralSeries s) ≤ lowering (degreeLT w) (s + 1) := by + rw [Subgroup.map_lowerCentralSeries] + exact (Subgroup.lowerCentralSeries_mono s hm).trans (lowerCentralSeries_le (degreeLT w) s) + apply le_antisymm _ bot_le + intro g hg + have hl := hc (Subgroup.mem_map.mpr ⟨g, hg, rfl⟩) + apply Subgroup.mem_bot.mpr + apply Subtype.ext + apply AlgEquiv.coe_toAlgHom_injective + apply MvPolynomial.algHom_ext + intro i + have hd := hl (w i + 1) (X i) (X_mem w (R := R) i) + have hw' : w i + 1 - (s + 1) = 0 := Nat.sub_eq_zero_of_le (Nat.add_le_add_right (hw i) 1) + rw [hw', degreeLT_zero, Submodule.mem_bot] at hd + exact sub_eq_zero.mp hd + + +theorem shears_nilpotent {s : ℕ} (hw : ∀ i, w i ≤ s) : + Group.IsNilpotent (shears (R := R) w) := + Subgroup.nilpotent_iff_lowerCentralSeries.mpr ⟨s, shear_lowerCentralSeries_eq_bot w hw⟩ + +theorem shears_class_le {s : ℕ} (hw : ∀ i, w i ≤ s) : + Group.nilpotencyClass (shears (R := R) w) ≤ s := by + have := shears_nilpotent (R := R) w hw + exact Subgroup.lowerCentralSeries_eq_bot_iff_nilpotencyClass_le.mp + (shear_lowerCentralSeries_eq_bot w hw) + +end PolynomialShears + +end FilteredShears + +end +end + +end OAI diff --git a/lean/OAI/Combinatorics/SumProduct/Alignment/FiniteCover01.lean b/lean/OAI/Combinatorics/SumProduct/Alignment/FiniteCover01.lean new file mode 100644 index 0000000000000000000000000000000000000000..f530b0aba1eb0a091089e9f1b22a3434b795ae4d --- /dev/null +++ b/lean/OAI/Combinatorics/SumProduct/Alignment/FiniteCover01.lean @@ -0,0 +1,280 @@ +import Mathlib +import OAI.Combinatorics.SumProduct.Alignment.FourierObstruction01 +import OAI.Combinatorics.SumProduct.Alignment.ProgressionPartition01 +import OAI.Geometry.NilpotentCharts.Main + +namespace OAI + +section +section +section +section +end + + + +section +noncomputable section +open scoped BigOperators +namespace FactorProgression +open CubeFaces CubePolynomials RationalLattice ProgressionPartition +variable {G : Type*} [Group G] [TopologicalSpace G] [IsTopologicalGroup G] +variable (H : Filtration G) (Γ : Subgroup G) {m : ℕ} (c : RealCoordinates (H.level 2) m) +variable [mtr : MetricSpace (G⧸Γ)] +local instance metricQuotientTopology : TopologicalSpace (G⧸Γ) := mtr.toUniformSpace.toTopologicalSpace +variable [hcpt : CompactSpace (G⧸Γ)] [hcsm : ContinuousSMul G (G⧸Γ)] + +lemma cell_smooth_bound (B : ℝ) (hB : 0 ≤ B) {J K T N a n r : ℕ} + (hJ : 0 (QuotientGroup.mk (b z).val : G⧸Γ)) (T:ℤ) → + (∀ z : ℤ, |(z:ℝ)| ≤ N → ‖c.coord (e z)‖ ≤ B) → + (∀ z w : ℤ, |(z:ℝ)| ≤ N → |(w:ℝ)| ≤ N → + ‖c.coord (e z*(e w)⁻¹)‖ ≤ (B/N)*|(z:ℝ)-(w:ℝ)|) → + ∀ F : C(G⧸Γ,ℂ), LipschitzWith 1 F → ‖F‖ ≤ 1 → + ∀ μ : ℂ, ‖μ‖ ≤ 1 → δ*N ≤ ‖∑ i∈Finset.range N, (F (QuotientGroup.mk (f i))-μ)‖ → + let K : ℕ := N/(J*T) + 0 v⁻¹*f' ((T:ℤ)*z+(a*K*T+r:ℕ))*v)∈polynomials L 0 ∧ + δ/4*K ≤ ‖∑ n∈Finset.range K, + (F (((e ((a*K*T+r:ℕ):ℤ)).val*v) • + (QuotientGroup.mk (v⁻¹*f' (((a*K+n)*T+r:ℕ):ℤ)*v) : G⧸Γ))-μ)‖ := by + let : ContinuousSMul (H.level 2) (G⧸Γ) := ⟨by + change Continuous (fun p : H.level 2 × (G⧸Γ) => (p.1.val:G) • p.2) + fun_prop⟩ + obtain ⟨u,hu,hsmall⟩ := CompactActionFreeze.small_displacement (X:=G⧸Γ) c.coord (funext c.one_coord) (δ/4) (by positivity) + obtain ⟨J,hJreal⟩ := exists_nat_gt (B/u) + have hJ : 0 hC (b (r:ℤ)).val) + let g : ℕ → ℕ → ℕ → ℂ := fun a r n => + F (((e ((a*K*T+r:ℕ):ℤ)).val*v r) • (QuotientGroup.mk ((v r)⁻¹*f' (((a*K+n)*T+r:ℕ):ℤ)*v r) : G⧸Γ)) + have harg {a n r : ℕ} (ha : a (e z).val) f' (fun z => (b z).val) + hfac (T:ℤ) hper (r:ℤ) (v r) (hvq r) ((a*K+n):ℕ) + have heq : (T:ℤ)*((a*K+n:ℕ):ℤ)+(r:ℤ)=(((a*K+n)*T+r:ℕ):ℤ) := by push_cast; ring + rw [heq] at hh + change (QuotientGroup.mk (f (((a*K+n)*T+r:ℕ):ℤ)) : G⧸Γ)=(d.val:G) • x + rw [hh] + dsimp only [d,x,Subgroup.coe_mul,Subgroup.coe_inv] + rw [smul_smul] + congr 1 + group + calc + _ = dist (F (QuotientGroup.mk (f (((a*K+n)*T+r:ℕ):ℤ)))) (F x) := by rw [dist_eq_norm] + _ ≤ dist (QuotientGroup.mk (f (((a*K+n)*T+r:ℕ):ℤ))) x := by simpa using hFL.dist_le_mul _ _ + _ = dist (d • x) x := by rw [hex] + _ ≤ δ/4 := hsmall d hs x + obtain ⟨a,ha,r,hr,hobs⟩ := ProgressionPartition.obstruction + (fun i => F (QuotientGroup.mk (f i))) g μ J K T N δ hδ hn hM + (fun i => (F.norm_coe_le_norm _).trans hF) hμ htail hfreeze hlarge + refine ⟨hK,hM,hcomp,a,ha,r,hr,v r,hv r,?_,?_,hobs⟩ + · change ‖c.coord (e ((a*K*T+r:ℕ):ℤ))‖ ≤ B + apply hev + simpa only [Nat.add_zero] using harg (n:=0) ha hK hr + · exact affine_conjugate_polynomial L hL hfp (T:ℤ) (a*K*T+r) (v r) + +end FactorProgression +end +end + + + +section +noncomputable section +open scoped Topology BigOperators +namespace FiniteCoverObservable +open MeasureTheory +variable {G X Y : Type*} [Group G] [TopologicalSpace G] [IsTopologicalGroup G] + [MetricSpace X] [CompactSpace X] [MetricSpace Y] [CompactSpace Y] + [MulAction G X] [ContinuousSMul G X] + + + +def translated (q : C(Y,X)) (g : G) (F : C(X,ℂ)) : C(Y,ℂ) := + ⟨fun y => F (g • q y), by fun_prop⟩ + +omit [IsTopologicalGroup G] [CompactSpace Y] in +lemma continuous_translated (q : C(Y,X)) : + Continuous (fun p : G × C(X,ℂ) => translated q p.1 p.2) := by + let A : C((G × C(X,ℂ)) × Y,ℂ) := + ⟨fun p => p.1.2 (p.1.1 • q p.2),by fun_prop⟩ + exact A.curry.continuous + + + +omit [IsTopologicalGroup G] [CompactSpace Y] in +theorem compact_translated_family (q : C(Y,X)) (C : Set G) (hC : IsCompact C) : + ∃ K : Set C(Y,ℂ), IsCompact K ∧ ∀ g∈C, ∀ F : C(X,ℂ), + LipschitzWith 1 F → ‖F‖ ≤ 1 → translated q g F ∈ K := by + obtain ⟨K,hK,hunit⟩ := FourierObstruction.compact_superset_unit_lipschitz X + refine ⟨(fun p : G × C(X,ℂ) => translated q p.1 p.2) '' (C ×ˢ K), + (hC.prod hK).image (continuous_translated q),?_⟩ + intro g hg F hF hFn + exact ⟨(g,F),⟨hg,hunit F hF hFn⟩,rfl⟩ + +variable [MeasurableSpace X] [BorelSpace X] [MeasurableSpace Y] [BorelSpace Y] + +omit [IsTopologicalGroup G] [CompactSpace Y] in +lemma integral_translated (q : C(Y,X)) (μ : Measure X) (ν : Measure Y) + [IsProbabilityMeasure μ] [IsProbabilityMeasure ν] [SMulInvariantMeasure G X μ] + (hmap : Measure.map q ν = μ) (g : G) (F : C(X,ℂ)) : + (∫ y, translated q g F y ∂ν) = ∫ x, F x ∂μ := by + change (∫ y, F (g • q y) ∂ν) = _ + rw [← integral_map q.continuous.aemeasurable (by fun_prop : AEStronglyMeasurable (fun x : X => F (g • x)) (Measure.map q ν)),hmap] + exact integral_smul_eq_self F + + + +omit [IsTopologicalGroup G] in +theorem finite_cover_tests (q : C(Y,X)) (C : Set G) (hC : IsCompact C) + (μ : Measure X) (ν : Measure Y) [IsProbabilityMeasure μ] [IsProbabilityMeasure ν] + [SMulInvariantMeasure G X μ] (hmap : Measure.map q ν=μ) + (δ : ℝ) (hδ : 0<δ) : + ∃ S : Finset {F : C(Y,ℂ) // F ∈ CompactFamilyDescent.lipschitzMaps}, + ∃ η : ℝ, 0<η ∧ ∀ N : ℕ, 0 ‖φ.val‖₊+C φ) (fun φ (_ : φ∈S) => by positivity) hφ + constructor + · exact (le_add_of_nonneg_left (by positivity)).trans (hh.trans (le_add_of_nonneg_left (by positivity))) + · exact (le_add_of_nonneg_right (by positivity)).trans (hh.trans (le_add_of_nonneg_left (by positivity))) + let normalize (φ : {F : C(Y,ℂ) // F∈lipschitzMaps}) : C(Y,ℂ) := ((D:ℂ)⁻¹) • φ.val + have hn (φ) (hφ : φ∈S) : LipschitzWith 1 (normalize φ) ∧ ‖normalize φ‖ ≤ 1 := by + have hnorm : ‖(D:ℂ)⁻¹‖ = (D:ℝ)⁻¹ := by simp + constructor + · apply LipschitzWith.of_dist_le_mul + intro x y + change dist ((D:ℂ)⁻¹ * φ.val x) ((D:ℂ)⁻¹ * φ.val y) ≤ _ + simp only [dist_eq_norm,← mul_sub,norm_mul,hnorm] + rw [← dist_eq_norm] + have hh := (hC φ).dist_le_mul x y + calc + _ ≤ (D:ℝ)⁻¹*((C φ:ℝ)*dist x y) := mul_le_mul_of_nonneg_left hh (by positivity) + _ ≤ (D:ℝ)⁻¹*((D:ℝ)*dist x y) := mul_le_mul_of_nonneg_left + (mul_le_mul_of_nonneg_right (show (C φ:ℝ) ≤ D from (hc φ hφ).1) dist_nonneg) (by positivity) + _ = (1:NNReal)*dist x y := by norm_num; field_simp + · change ‖(D:ℂ)⁻¹ • φ.val‖ ≤ _ + rw [norm_smul,hnorm] + have hh : ‖φ.val‖ ≤ (D:ℝ) := (hc φ hφ).2 + calc + _ ≤ (D:ℝ)⁻¹*(D:ℝ) := mul_le_mul_of_nonneg_left hh (by positivity) + _ = 1 := inv_mul_cancel₀ hDreal.ne' + refine ⟨S.image normalize,?_,η/D,div_pos hη hDreal,?_⟩ + · intro F hF + obtain ⟨φ,hφ,rfl⟩ := Finset.mem_image.mp hF + exact hn φ hφ + · intro L hL hlarge + obtain ⟨φ,hφ,hdisc⟩ := ht L hL hlarge + refine ⟨normalize φ,Finset.mem_image.mpr ⟨φ,hφ,rfl⟩,?_⟩ + change η/(D:ℝ) ≤ ‖L ((D:ℂ)⁻¹ • φ.val)‖ + rw [map_smul,norm_smul] + have hnorm : ‖(D:ℂ)⁻¹‖=(D:ℝ)⁻¹ := by simp + rw [hnorm,div_eq_inv_mul] + exact mul_le_mul_of_nonneg_left hdisc (by positivity) + +end CompactFamilyDescent + +end +end +end +end +end + +end OAI diff --git a/lean/OAI/Combinatorics/SumProduct/Alignment/FiniteMenu01.lean b/lean/OAI/Combinatorics/SumProduct/Alignment/FiniteMenu01.lean new file mode 100644 index 0000000000000000000000000000000000000000..de1b2051f77ca1f0de75afe9bb5be860f2120fa6 --- /dev/null +++ b/lean/OAI/Combinatorics/SumProduct/Alignment/FiniteMenu01.lean @@ -0,0 +1,387 @@ +import Mathlib +import OAI.Combinatorics.SumProduct.Alignment.PivotPaths03 +import OAI.Geometry.NilpotentCharts.Main + +namespace OAI + +open scoped BigOperators +section +noncomputable section +open Filter MeasureTheory +open scoped BigOperators ENNReal Topology +noncomputable section +open scoped BigOperators Topology BoundedContinuousFunction +noncomputable section +open scoped BigOperators +open MeasureTheory Filter Function +noncomputable section +open scoped BigOperators +noncomputable section +open Filter MeasureTheory +open scoped Topology BoundedContinuousFunction NNReal +noncomputable section +open scoped Topology BigOperators +noncomputable section +open scoped Topology BoundedContinuousFunction NNReal +open Topology +namespace SourceFiniteMenu +variable {ι : Type*} (G : ι → Type*) [∀ i, Group (G i)] + [∀ i, TopologicalSpace (G i)] [∀ i, IsTopologicalGroup (G i)] + (Γ : ∀ i, Subgroup (G i)) + +abbrev productLattice : Subgroup (∀ i, G i) := Subgroup.pi Set.univ Γ + + + +def quotientPi : ((∀ i, G i) ⧸ productLattice G Γ) → ∀ i, G i ⧸ Γ i := + Quotient.lift (fun g i => QuotientGroup.mk (g i)) (by + intro g h hgh + funext i + apply QuotientGroup.eq.mpr + exact (Subgroup.mem_pi Set.univ).mp + (QuotientGroup.leftRel_apply.mp hgh) i (Set.mem_univ i)) + +omit [∀ i, IsTopologicalGroup (G i)] in +@[simp] lemma quotientPi_mk [∀ i, IsTopologicalGroup (G i)] (g : ∀ i, G i) (i : ι) : + quotientPi G Γ (QuotientGroup.mk g) i = QuotientGroup.mk (g i) := rfl + +omit [∀ i, IsTopologicalGroup (G i)] in +lemma quotientPi_bijective [∀ i, IsTopologicalGroup (G i)] : Function.Bijective (quotientPi G Γ) := by + constructor + · intro g h hgh + obtain ⟨g, rfl⟩ := QuotientGroup.mk_surjective g + obtain ⟨h, rfl⟩ := QuotientGroup.mk_surjective h + apply QuotientGroup.eq.mpr + apply (Subgroup.mem_pi Set.univ).mpr + intro i hi + exact QuotientGroup.eq.mp (congrFun hgh i) + · intro x + choose g hg using fun i => QuotientGroup.mk_surjective (x i) + exact ⟨QuotientGroup.mk g, funext hg⟩ + +omit [∀ i, IsTopologicalGroup (G i)] in +lemma quotientPi_continuous [∀ i, IsTopologicalGroup (G i)] : Continuous (quotientPi G Γ) := by + exact (continuous_pi (fun i => QuotientGroup.continuous_mk.comp (continuous_apply i))).quotient_lift _ + + +def quotientPiHomeomorph : + ((∀ i, G i) ⧸ productLattice G Γ) ≃ₜ (∀ i, G i ⧸ Γ i) := by + let e := Equiv.ofBijective (quotientPi G Γ) (quotientPi_bijective G Γ) + refine { e with continuous_toFun := quotientPi_continuous G Γ, continuous_invFun := ?_ } + apply (IsOpenQuotientMap.piMap (fun i => QuotientGroup.isOpenQuotientMap_mk (N := Γ i))).isQuotientMap.continuous_iff.mpr + have he : e.symm ∘ Pi.map (fun i => (QuotientGroup.mk : G i → G i ⧸ Γ i)) = + (QuotientGroup.mk : (∀ i, G i) → (∀ i, G i) ⧸ productLattice G Γ) := by + funext g + exact e.symm_apply_eq.mpr rfl + change Continuous (e.symm ∘ Pi.map (fun i => (QuotientGroup.mk : G i → G i ⧸ Γ i))) + rw [he] + exact QuotientGroup.continuous_mk + +@[simp] lemma quotientPiHomeomorph_mk (g : ∀ i, G i) (i : ι) : + quotientPiHomeomorph G Γ (QuotientGroup.mk g) i = QuotientGroup.mk (g i) := rfl + + +omit [∀ i, IsTopologicalGroup (G i)] in +lemma product_step [∀ i, IsTopologicalGroup (G i)] [Fintype ι] [∀ i, Group.IsNilpotent (G i)] + (s : ℕ) (hs : ∀ i, Group.nilpotencyClass (G i) ≤ s) : + Group.nilpotencyClass (∀ i, G i) ≤ s := by + rw [Group.nilpotencyClass_pi] + exact Finset.sup_le fun i _ => hs i + +section Metric +variable [Fintype ι] + (metric : ∀ i, MetricSpace (G i ⧸ Γ i)) + (hmetric : ∀ i, QuotientGroup.instTopologicalSpace (Γ i) = + (metric i).toUniformSpace.toTopologicalSpace) + + + +@[instance_reducible] def productMetric : MetricSpace ((∀ i, G i) ⧸ productLattice G Γ) := + letI : ∀ i, MetricSpace (G i ⧸ Γ i) := fun i => (metric i).replaceTopology (hmetric i) + (quotientPiHomeomorph G Γ).isEmbedding.comapMetricSpace (quotientPiHomeomorph G Γ) + +lemma productMetric_compatible : + QuotientGroup.instTopologicalSpace (productLattice G Γ) = + (productMetric G Γ metric hmetric).toUniformSpace.toTopologicalSpace := rfl + +lemma quotientPi_isometry : + letI : ∀ i, MetricSpace (G i ⧸ Γ i) := fun i => (metric i).replaceTopology (hmetric i) + letI : MetricSpace ((∀ i, G i) ⧸ productLattice G Γ) := productMetric G Γ metric hmetric + Isometry (quotientPi G Γ) := by + let : ∀ i, MetricSpace (G i ⧸ Γ i) := fun i => (metric i).replaceTopology (hmetric i) + let : MetricSpace ((∀ i, G i) ⧸ productLattice G Γ) := productMetric G Γ metric hmetric + intro x y + rfl + +lemma projection_lipschitz (i : ι) : + letI : ∀ i, MetricSpace (G i ⧸ Γ i) := fun i => (metric i).replaceTopology (hmetric i) + letI : MetricSpace ((∀ i, G i) ⧸ productLattice G Γ) := productMetric G Γ metric hmetric + LipschitzWith 1 (fun z => quotientPi G Γ z i) := by + let : ∀ i, MetricSpace (G i ⧸ Γ i) := fun i => (metric i).replaceTopology (hmetric i) + let : MetricSpace ((∀ i, G i) ⧸ productLattice G Γ) := productMetric G Γ metric hmetric + simpa only [one_mul, Function.comp_def, Function.eval] using (LipschitzWith.eval i).comp (quotientPi_isometry G Γ metric hmetric).lipschitzWith + +end Metric + + + +def paddedObservable (i : ι) (F : (G i ⧸ Γ i) →ᵇ ℝ) : + ((∀ i, G i) ⧸ productLattice G Γ) →ᵇ ℝ := + F.compContinuous ⟨fun z => quotientPi G Γ z i, + (continuous_apply i).comp (quotientPi_continuous G Γ)⟩ + +@[simp] lemma paddedObservable_apply (i : ι) (F : (G i ⧸ Γ i) →ᵇ ℝ) + (z : (∀ i, G i) ⧸ productLattice G Γ) : + paddedObservable G Γ i F z = F (quotientPi G Γ z i) := rfl + + +lemma padded_orbit [DecidableEq ι] (i : ι) (F : (G i ⧸ Γ i) →ᵇ ℝ) + (g x : G i) (k : ℤ) : + paddedObservable G Γ i F (QuotientGroup.mk ((Pi.mulSingle i g)^k * Pi.mulSingle i x)) = + F (QuotientGroup.mk (g^k*x)) := by + simp [Pi.mul_apply, Pi.pow_apply] + +lemma padded_lipschitz [Fintype ι] + (metric : ∀ i, MetricSpace (G i ⧸ Γ i)) + (hmetric : ∀ i, QuotientGroup.instTopologicalSpace (Γ i) = + (metric i).toUniformSpace.toTopologicalSpace) : + letI : ∀ i, MetricSpace (G i ⧸ Γ i) := fun i => (metric i).replaceTopology (hmetric i) + letI : MetricSpace ((∀ i, G i) ⧸ productLattice G Γ) := productMetric G Γ metric hmetric + ∀ (i : ι) (F : (G i ⧸ Γ i) →ᵇ ℝ) (K : ℝ≥0), LipschitzWith K F → + LipschitzWith K (paddedObservable G Γ i F) := by + let : ∀ i, MetricSpace (G i ⧸ Γ i) := fun i => (metric i).replaceTopology (hmetric i) + let : MetricSpace ((∀ i, G i) ⧸ productLattice G Γ) := productMetric G Γ metric hmetric + intro i F K hF + change LipschitzWith K (fun z => F (quotientPi G Γ z i)) + simpa only [mul_one, Function.comp_def] using hF.comp (projection_lipschitz G Γ metric hmetric i) + + + +theorem finite_menu_padding [Fintype ι] + (metric : ∀ i, MetricSpace (G i ⧸ Γ i)) + (hmetric : ∀ i, QuotientGroup.instTopologicalSpace (Γ i) = + (metric i).toUniformSpace.toTopologicalSpace) + {κ : Type*} (select : κ → ι) (g x : ∀ p, G (select p)) + (F : ∀ p, (G (select p) ⧸ Γ (select p)) →ᵇ ℝ) (K : ℝ≥0) (B : ℝ) : + letI : ∀ i, MetricSpace (G i ⧸ Γ i) := fun i => (metric i).replaceTopology (hmetric i) + letI : MetricSpace ((∀ i, G i) ⧸ productLattice G Γ) := productMetric G Γ metric hmetric + (∀ p, LipschitzWith K (F p)) → (∀ p z, |F p z| ≤ B) → + ∃ (g' x' : κ → ∀ i, G i) + (F' : κ → ((∀ i, G i) ⧸ productLattice G Γ) →ᵇ ℝ), + (∀ p, LipschitzWith K (F' p)) ∧ (∀ p z, |F' p z| ≤ B) ∧ + (∀ (p : κ) (k : ℤ), F' p (QuotientGroup.mk ((g' p)^k*x' p)) = + F p (QuotientGroup.mk ((g p)^k*x p))) := by + let : ∀ i, MetricSpace (G i ⧸ Γ i) := fun i => (metric i).replaceTopology (hmetric i) + let : MetricSpace ((∀ i, G i) ⧸ productLattice G Γ) := productMetric G Γ metric hmetric + intro hLip hBound + classical + refine ⟨fun p => Pi.mulSingle (select p) (g p), + fun p => Pi.mulSingle (select p) (x p), + fun p => paddedObservable G Γ (select p) (F p), ?_, ?_, ?_⟩ + · intro p + exact padded_lipschitz G Γ metric hmetric _ _ K (hLip p) + · intro p z + exact hBound p _ + · intro p k + exact padded_orbit G Γ (select p) (F p) (g p) (x p) k + + +lemma product_compact [∀ i, CompactSpace (G i ⧸ Γ i)] : + CompactSpace ((∀ i, G i) ⧸ productLattice G Γ) := + (quotientPiHomeomorph G Γ).symm.compactSpace + + + +def subgroupPiHomeomorph : productLattice G Γ ≃ₜ (∀ i, Γ i) where + toFun g i := ⟨g.val i, (Subgroup.mem_pi Set.univ).mp g.property i (Set.mem_univ i)⟩ + invFun g := ⟨fun i => (g i).val, (Subgroup.mem_pi Set.univ).mpr (fun i _ => (g i).property)⟩ + left_inv g := by rfl + right_inv g := by rfl + continuous_toFun := continuous_pi (fun i => + ((continuous_apply i).comp continuous_subtype_val).subtype_mk _) + continuous_invFun := (continuous_pi (fun i => + continuous_subtype_val.comp (continuous_apply i))).subtype_mk _ + +omit [∀ i, IsTopologicalGroup (G i)] in +lemma product_discrete [∀ i, IsTopologicalGroup (G i)] [Finite ι] [∀ i, DiscreteTopology (Γ i)] : + DiscreteTopology (productLattice G Γ) := + (subgroupPiHomeomorph G Γ).symm.discreteTopology + +end SourceFiniteMenu +end + + + + + + + +noncomputable section +open scoped Topology BigOperators commutatorElement +namespace SourceProductChart +open RationalLattice MalcevCharacters CubeFaces SourceProductCoordinates +attribute [local instance] Classical.propDecidable +variable {d : ℕ} + + + +variable (n : Fin d → ℕ) (wt : ∀ i, Fin (n i) → ℕ) + +def key (z : Σ i, Fin (n i)) : ℕ ×ₗ (Fin d ×ₗ ℕ) := + toLex (wt z.1 z.2, toLex (z.1,z.2.val)) + +lemma key_injective : Function.Injective (key n wt) := by + rintro ⟨i,j⟩ ⟨i',j'⟩ h + have hi : i=i' := congrArg (fun z => (ofLex (ofLex z).2).1) h + subst i' + have hj : j.val = j'.val := congrArg (fun z => (ofLex (ofLex z).2).2) h + exact congrArg (Sigma.mk i) (Fin.ext hj) + + + +def Index := Σ i, Fin (n i) +instance : Fintype (Index n) := inferInstanceAs (Fintype (Σ i, Fin (n i))) + +@[instance_reducible] def sortedOrder : LinearOrder (Index n) := + LinearOrder.lift' (key n wt) (key_injective n wt) + +def orderedEnumeration : letI := sortedOrder n wt + Fin (Fintype.card (Index n)) ≃o Index n := by + letI := sortedOrder n wt + exact Fintype.orderIsoFinOfCardEq (Index n) rfl + + +def enumeration : Fin (Fintype.card (Σ i, Fin (n i))) ≃ Σ i, Fin (n i) := by + exact (orderedEnumeration n wt).toEquiv + +lemma enumeration_local (hw : ∀ i, Monotone (wt i)) (i : Fin d) : + StrictMono (fun j : Fin (n i) => (enumeration n wt).symm ⟨i,j⟩) := by + let := sortedOrder n wt + intro j k hjk + change (orderedEnumeration n wt).symm ⟨i,j⟩ < + (orderedEnumeration n wt).symm ⟨i,k⟩ + apply (orderedEnumeration n wt).symm.strictMono + change key n wt ⟨i,j⟩ < key n wt ⟨i,k⟩ + rw [key, key, Prod.Lex.toLex_lt_toLex] + rcases lt_or_eq_of_le (hw i hjk.le) with h | h + · exact Or.inl h + · refine Or.inr ⟨h,?_⟩ + exact Prod.Lex.right i hjk + +lemma enumeration_weights : + Monotone (fun k => wt (enumeration n wt k).1 (enumeration n wt k).2) := by + let := sortedOrder n wt + intro k l hkl + have h := (orderedEnumeration n wt).monotone hkl + change key n wt (enumeration n wt k) ≤ key n wt (enumeration n wt l) at h + rw [key,key,Prod.Lex.toLex_le_toLex] at h + exact h.elim (fun h => h.le) (fun h => h.1.le) + +section Product +variable (G : Fin d → Type) [∀ i, Group (G i)] [∀ i, TopologicalSpace (G i)] + (Γ : ∀ i, Subgroup (G i)) (H : ∀ i, Filtration (G i)) + +def filtration : Filtration (∀ i, G i) where + level k := Subgroup.pi Set.univ (fun i => (H i).level k) + antitone := by + intro k l hkl g hg + apply (Subgroup.mem_pi _).mpr + intro i hi + exact (H i).antitone hkl ((Subgroup.mem_pi _).mp hg i hi) + commutator_le k l := Subgroup.commutator_le.mpr (by + intro g hg h hh + apply (Subgroup.mem_pi _).mpr + intro i hi + have hc := (H i).commutator_le k l (Subgroup.commutator_mem_commutator + ((Subgroup.mem_pi _).mp hg i hi) ((Subgroup.mem_pi _).mp hh i hi)) + simpa only [commutatorElement_def, Pi.mul_apply, Pi.inv_apply] using hc) + +omit [∀ i, TopologicalSpace (G i)] in +@[simp] lemma filtration_mem [∀ i, TopologicalSpace (G i)] (k : ℕ) (g : ∀ i, G i) : + g ∈ (filtration G H).level k ↔ ∀ i, g i ∈ (H i).level k := by + simp [filtration, Subgroup.mem_pi] + +lemma filtration_top (k : ℕ) (hk : ∀ i, (H i).level k = ⊤) : + (filtration G H).level k = ⊤ := by + ext g + simp [filtration_mem, hk] + +lemma filtration_bot (k : ℕ) (hk : ∀ i, (H i).level k = ⊥) : + (filtration G H).level k = ⊥ := by + ext g + simp only [filtration_mem, hk, Subgroup.mem_bot] + exact ⟨fun h => funext h, fun h i => congrFun h i⟩ + +variable {s : ℕ} (C : ∀ i, Chart s (G i) (Γ i)) + + +def product : Chart s (∀ i, G i) (SourceFiniteMenu.productLattice G Γ) := by + let n := fun i => (C i).dim + let wt := fun i => (C i).weight + let e := enumeration n wt + have he := enumeration_local n wt (fun i => (C i).weight_mono) + let c := coordinates n G (fun i => (C i).coords) e he + refine { + dim := Fintype.card (Σ i, Fin (n i)) + coords := c + second := secondKind n G (fun i => (C i).coords) e he (fun i => (C i).second) + filtration := filtration G (fun i => (C i).filtration) + weight := fun k => wt (e k).1 (e k).2 + weight_pos := fun k => (C (e k).1).weight_pos (e k).2 + weight_mono := enumeration_weights n wt + level0 := filtration_top G _ 0 (fun i => (C i).level0) + level1 := filtration_top G _ 1 (fun i => (C i).level1) + step := filtration_bot G _ (s+1) (fun i => (C i).step) + level_iff := ?_ + lattice_iff := ?_ } + · intro k g + rw [filtration_mem] + constructor + · intro h j hj + exact ((C (e j).1).level_iff k _).mp (h (e j).1) (e j).2 hj + · intro h i + apply ((C i).level_iff k _).mpr + intro j hj + have hh := h (e.symm ⟨i,j⟩) + change wt (e (e.symm ⟨i,j⟩)).1 (e (e.symm ⟨i,j⟩)).2 < k → + (C (e (e.symm ⟨i,j⟩)).1).coords.coord (g (e (e.symm ⟨i,j⟩)).1) + (e (e.symm ⟨i,j⟩)).2 = 0 at hh + have hwj := congrArg (fun z : Σ i, Fin (n i) => wt z.1 z.2) (e.apply_symm_apply ⟨i,j⟩) + have hcj := congrArg (fun z : Σ i, Fin (n i) => (C z.1).coords.coord (g z.1) z.2) + (e.apply_symm_apply ⟨i,j⟩) + rw [hwj, hcj] at hh + exact hh hj + · intro g + change (∀ i ∈ Set.univ, g i ∈ Γ i) ↔ _ + constructor + · intro h j + exact ((C (e j).1).lattice_iff _).mp (h (e j).1 (Set.mem_univ _)) (e j).2 + · intro h i hi + apply ((C i).lattice_iff _).mpr + intro j + have hh := h (e.symm ⟨i,j⟩) + change ∃ z : ℤ, (C (e (e.symm ⟨i,j⟩)).1).coords.coord + (g (e (e.symm ⟨i,j⟩)).1) (e (e.symm ⟨i,j⟩)).2 = z at hh + have hcj := congrArg (fun z : Σ i, Fin (n i) => (C z.1).coords.coord (g z.1) z.2) + (e.apply_symm_apply ⟨i,j⟩) + rwa [hcj] at hh + +end Product +end SourceProductChart + + + + + + + +end +end +end +end +end +end +end +end + +end OAI diff --git a/lean/OAI/Combinatorics/SumProduct/Alignment/FinitePiece01.lean b/lean/OAI/Combinatorics/SumProduct/Alignment/FinitePiece01.lean new file mode 100644 index 0000000000000000000000000000000000000000..7abe77d201604b4312ddc951ca06f2325453c6b1 --- /dev/null +++ b/lean/OAI/Combinatorics/SumProduct/Alignment/FinitePiece01.lean @@ -0,0 +1,323 @@ +import Mathlib +import OAI.Combinatorics.SumProduct.Alignment.IntegerHyperplane01 +import OAI.Combinatorics.SumProduct.Alignment.RoughSampling01 +import OAI.Geometry.NilpotentCharts.Main + +namespace OAI + +section +section +section +noncomputable section +open scoped BigOperators +end + +end + +section + + + + +noncomputable section +open scoped BigOperators +namespace ConvexDiscrepancy +variable {ι : Type*} [Fintype ι] + +def average (p : ι → ℝ) (f : ι → ℂ) : ℂ:=∑ i,(p i:ℂ)*f i + +lemma weight_error (p q : ι → ℝ) (f : ι → ℂ) (B : ℝ) + (hB : 0≤B) (hf : ∀ i,‖f i‖≤B) : + ‖average p f-average q f‖≤B*∑ i,|p i-q i| := by + have he : average p f-average q f=∑ i,((p i-q i:ℝ):ℂ)*f i:=by + simp only [average,Complex.ofReal_sub,sub_mul,Finset.sum_sub_distrib] + rw [he] + calc + _≤∑ i,‖((p i-q i:ℝ):ℂ)*f i‖:=norm_sum_le _ _ + _≤∑ i,|p i-q i| *B:=by + apply Finset.sum_le_sum + intro i _ + rw [norm_mul,Complex.norm_real,Real.norm_eq_abs] + simpa only [mul_comm] using + mul_le_mul (hf i) (le_refl |p i-q i|) (abs_nonneg _) hB + _=B*∑ i,|p i-q i|:=by rw [Finset.mul_sum]; apply Finset.sum_congr rfl; intros; ring + +lemma positive_piece (p : ι → ℝ) (hp : ∀ i,0≤p i) (hp1 : ∑ i,p i=1) + (f g : ι → ℂ) (δ : ℝ) (hδ : δ≤‖average p f-average p g‖) : + ∃ i,0

h i) + rw [hp1] at hs + norm_num at hs + by_contra h + push Not at h + obtain ⟨j,hj⟩:=hpos + have hs : ∑ i,p i*‖f i-g i‖<∑ i,p i*δ:=by + apply Finset.sum_lt_sum + · intro i _ + by_cases hi : 0

label x=i) +def weight (s : Finset α) (label : α → ι) (i : ι) : ℝ:= + (fiber s label i).card/(s.card:ℝ) +def mean (s : Finset α) (f : α → ℂ) : ℂ:= + (s.card:ℂ)⁻¹ * ∑ x∈s,f x + +omit [Fintype ι] in +lemma weight_nonneg [Fintype ι] (s : Finset α) (label : α → ι) (i : ι) : + 0≤weight s label i:=by unfold weight; positivity + +lemma sum_weights (s : Finset α) (hs : s.Nonempty) (label : α → ι) : + ∑ i,weight s label i=1 := by + have hc : ∑ i,(fiber s label i).card=s.card:=by + simpa only [fiber,Finset.card_eq_sum_ones] using + (Finset.sum_fiberwise s label (fun _=>1:α → ℕ)) + simp only [weight,←Finset.sum_div,←Nat.cast_sum,hc] + exact div_self (by exact_mod_cast hs.card_pos.ne' : (s.card:ℝ)≠0) + +lemma decomposition (s : Finset α) (label : α → ι) (f : α → ℂ) : + mean s f=ConvexDiscrepancy.average (weight s label) (fun i=>mean (fiber s label i) f) := by + have hfiber (i : ι) : + (weight s label i:ℂ)*mean (fiber s label i) f= + (s.card:ℂ)⁻¹ * ∑ x∈fiber s label i,f x:=by + by_cases hi : (fiber s label i).card=0 + · have he : fiber s label i=∅:=Finset.card_eq_zero.mp hi + simp [weight,mean,he] + · have hi' : ((fiber s label i).card:ℂ)≠0:=by exact_mod_cast hi + simp only [weight,mean] + push_cast + field_simp + rw [ConvexDiscrepancy.average] + simp_rw [hfiber] + rw [←Finset.mul_sum] + unfold mean + congr 1 + exact (Finset.sum_fiberwise s label f).symm + +lemma norm_mean_le (s : Finset α) (f : α → ℂ) (B : ℝ) (hB : 0≤B) + (hf : ∀ x∈s,‖f x‖≤B) : ‖mean s f‖≤B := by + by_cases hs : s.Nonempty + · have hc : 0<(s.card:ℝ):=by exact_mod_cast hs.card_pos + rw [mean,norm_mul,norm_inv,Complex.norm_natCast] + apply (mul_le_mul_of_nonneg_left (norm_sum_le _ _) (inv_nonneg.mpr hc.le)).trans + have hb : (∑ x∈s,‖f x‖) ≤ (s.card:ℝ)*B:=by + calc + _≤∑ _x∈s,B:=Finset.sum_le_sum hf + _=_:=by simp + calc + _≤(s.card:ℝ)⁻¹*(s.card*B):=mul_le_mul_of_nonneg_left hb (inv_nonneg.mpr hc.le) + _=B:=by field_simp + · have he : s=∅:=Finset.not_nonempty_iff_eq_empty.mp hs + simpa [he,mean] using hB + +lemma mean_difference (s : Finset α) (f g : α → ℂ) : + mean s f-mean s g=mean s (fun x=>f x-g x) := by + simp only [mean,Finset.sum_sub_distrib,mul_sub] + + + +lemma mean_error (s : Finset α) (f g : α → ℂ) (ε : ℝ) (hε : 0≤ε) + (h : ∀ x∈s,‖f x-g x‖≤ε) : ‖mean s f-mean s g‖≤ε := by + rw [mean_difference] + exact norm_mean_le s _ ε hε h + + + +theorem select (s : Finset α) (t : Finset β) (hs : s.Nonempty) + (a : α → ι) (b : β → ι) (f : α → ℂ) (g : β → ℂ) + (B : ℝ) (hB : 0≤B) (hg : ∀ y∈t,‖g y‖≤B) + (η τ : ℝ) (hd : η≤‖mean s f-mean t g‖) + (hw : B*(∑ i,|weight s a i-weight t b i|)≤τ) : + ∃ i,(fiber s a i).Nonempty ∧ + η-τ≤‖mean (fiber s a i) f-mean (fiber t b i) g‖ := by + rw [decomposition s a f,decomposition t b g] at hd + obtain ⟨i,hi,hd⟩:=ConvexDiscrepancy.select_piece (weight s a) (weight t b) + (weight_nonneg s a) (sum_weights s hs a) + (fun i=>mean (fiber s a i) f) (fun i=>mean (fiber t b i) g) + B hB (fun i=>norm_mean_le _ _ B hB (fun x hx=>hg x (Finset.mem_filter.mp hx).1)) + η τ hd hw + refine ⟨i,?_,hd⟩ + rw [weight] at hi + have hc : 0<((fiber s a i).card:ℝ):=(div_pos_iff.mp hi).elim And.left + (fun h=>False.elim (not_lt_of_ge (by positivity) h.1)) + exact Finset.card_pos.mp (by exact_mod_cast hc) + +end FinitePieceAverages +end + +end + +section + + + + +noncomputable section +open scoped BigOperators +namespace RoughSamplingWeights +variable {ι : Type*} [Fintype ι] [DecidableEq ι] + +def boxIndices (lo hi a : ι → ℝ) (q : ℝ) : Finset (ι → ℤ):= + Fintype.piFinset (fun i=>indices (lo i) (hi i) (a i) q) + +lemma mem_boxIndices (lo hi a : ι → ℝ) (q : ℝ) (hq : 0a i+q*j i) (q*K)).image + (fun x i=>j i+(K:ℤ)*x i) + +omit [Fintype ι] [DecidableEq ι] in +lemma affine_injective [Fintype ι] [DecidableEq ι] (j : ι → ℤ) (K : ℕ) (hK : 0fun i=>j i+(K:ℤ)*x i) := by + have hKi : (K:ℤ)≠0:=by exact_mod_cast hK.ne' + intro x y h + funext i + exact mul_left_cancel₀ hKi (add_left_cancel (congrFun h i)) + +lemma card_refinedSet (lo' hi' a : ι → ℝ) (q : ℝ) (j : ι → ℤ) (K : ℕ) (hK : 0(hy i).symm)⟩ + rw [mem_boxIndices _ _ _ _ (mul_pos hq hKr)] + intro i + have he : a i+q*(x i:ℝ)=a i+q*j i+(q*K)*y i:=by rw [hy i]; push_cast; ring + simpa only [he] using (hx i).1 + +lemma refined_subset (lo hi lo' hi' a : ι → ℝ) (q : ℝ) (hq : 0 a • v i) < ε := by + have hf : f ∈ closure (Submodule.span ℂ (Set.range v) : Set E) := by + rw [← Submodule.topologicalClosure_coe, hv] + trivial + obtain ⟨g, hg, hfg⟩ := Metric.mem_closure_iff.mp hf ε hε + obtain ⟨c, rfl⟩ := Finsupp.mem_span_range_iff_exists_finsupp.mp hg + exact ⟨c, hfg⟩ + choose c hc using happ + let P : E → E := fun f => (c f).sum fun i a => a • v i + obtain ⟨t, ht⟩ := hK.elim_finite_subcover (fun f => Metric.ball (P f) ε) + (fun _ => Metric.isOpen_ball) (by + intro f _ + exact Set.mem_iUnion.mpr ⟨f, hc f⟩) + let H := 1 + ∑ f ∈ t, ∑ i ∈ (c f).support, ‖c f i‖ + have hH : 0 < H := by + dsimp [H] + positivity + let η := δ / (4 * H) + have hη : 0 < η := by dsimp [η]; positivity + refine ⟨t.biUnion (fun f => (c f).support), η, hη, ?_⟩ + intro L hL ⟨f, hf, hlarge⟩ + obtain ⟨g, hg, hfg⟩ := Set.mem_iUnion₂.mp (ht hf) + have hfg' : dist f (P g) < ε := hfg + by_contra hno + push Not at hno + have hPg : ‖L (P g)‖ ≤ H * η := by + calc + _ = ‖∑ i ∈ (c g).support, (c g i) • L (v i)‖ := by + simp [P, Finsupp.sum, map_sum] + _ ≤ ∑ i ∈ (c g).support, ‖c g i‖ * ‖L (v i)‖ := by + simpa only [norm_smul] using norm_sum_le (c g).support (fun i => c g i • L (v i)) + _ ≤ ∑ i ∈ (c g).support, ‖c g i‖ * η := by + apply Finset.sum_le_sum + intro i hi + apply mul_le_mul_of_nonneg_left _ (norm_nonneg _) + exact (hno i (Finset.mem_biUnion.mpr ⟨g, hg, hi⟩)).le + _ = (∑ i ∈ (c g).support, ‖c g i‖) * η := by rw [Finset.sum_mul] + _ ≤ H * η := by + apply mul_le_mul_of_nonneg_right _ hη.le + have hsum := Finset.single_le_sum (f := fun x => ∑ i ∈ (c x).support, ‖c x i‖) (fun x (_ : x ∈ t) => + Finset.sum_nonneg (fun i _ => norm_nonneg (c x i))) hg + dsimp [H] + linarith only [hsum] + have hdist : ‖L (f - P g)‖ < B * ε := by + calc + _ ≤ B * ‖f - P g‖ := hL _ + _ < B * ε := mul_lt_mul_of_pos_left (by simpa only [dist_eq_norm] using hfg') hB + have hsum := norm_add_le (L (f - P g)) (L (P g)) + rw [← map_add, sub_add_cancel] at hsum + have he₁ : B * ε = δ / 4 := by dsimp [ε]; field_simp + have he₂ : H * η = δ / 4 := by dsimp [η]; field_simp + rw [he₁] at hdist + rw [he₂] at hPg + linarith + + + +theorem compact_superset_unit_lipschitz (X : Type*) [MetricSpace X] [CompactSpace X] : + ∃ K : Set C(X, ℂ), IsCompact K ∧ + ∀ f : C(X, ℂ), LipschitzWith 1 f → ‖f‖ ≤ 1 → f ∈ K := by + let e := ContinuousMap.isometryEquivBoundedOfCompact X ℂ + let A : Set (BoundedContinuousFunction X ℂ) := {f | LipschitzWith 1 f ∧ ‖f‖ ≤ 1} + have heqc : Equicontinuous ((↑) : A → X → ℂ) := by + intro x + rw [Metric.equicontinuousAt_iff] + intro ε hε + refine ⟨ε, hε, ?_⟩ + intro y hxy f + have h := f.property.1.dist_le_mul x y + simp only [NNReal.coe_one, one_mul, dist_comm x y] at h + exact h.trans_lt hxy + have hc : IsCompact (closure A) := BoundedContinuousFunction.arzela_ascoli + (Metric.closedBall (0 : ℂ) 1) (isCompact_closedBall _ _) A (by + intro f x hf + simp only [Metric.mem_closedBall, dist_zero_right] + exact (f.norm_coe_le_norm x).trans hf.2) heqc + refine ⟨e.symm '' closure A, hc.image e.symm.continuous, ?_⟩ + intro f hl hn + refine ⟨e f, subset_closure ⟨hl, ?_⟩, e.symm_apply_apply f⟩ + simpa only [e, ContinuousMap.isometryEquivBoundedOfCompact_apply, + BoundedContinuousFunction.norm_mkOfCompact] using hn + +open MeasureTheory + +section Probability +variable {X : Type*} [TopologicalSpace X] [CompactSpace X] + [MeasurableSpace X] [BorelSpace X] (μ : Measure X) [IsProbabilityMeasure μ] + + + +def discrepancy (N : ℕ) (x : ℕ → X) : C(X, ℂ) →ₗ[ℂ] ℂ where + toFun f := (𝔼 n ∈ Finset.range N, f (x n)) - ∫ t, f t ∂μ + map_add' f g := by + change (𝔼 n ∈ Finset.range N, (f (x n) + g (x n))) - + ∫ t, f t + g t ∂μ = _ + rw [Finset.expect_add_distrib, integral_add + (f.continuous.integrable_of_hasCompactSupport (HasCompactSupport.of_compactSpace f)) + (g.continuous.integrable_of_hasCompactSupport (HasCompactSupport.of_compactSpace g))] + ring + map_smul' z f := by + change (𝔼 n ∈ Finset.range N, z • f (x n)) - ∫ t, z • f t ∂μ = _ + rw [← Finset.smul_expect, integral_smul] + simp only [RingHom.id_apply, smul_sub] + +theorem discrepancy_bound (N : ℕ) (hN : 0 < N) (x : ℕ → X) (f : C(X, ℂ)) : + ‖discrepancy μ N x f‖ ≤ 2 * ‖f‖ := by + have hm : ‖𝔼 n ∈ Finset.range N, f (x n)‖ ≤ ‖f‖ := + (RCLike.norm_expect_le (K := ℂ)).trans (Finset.expect_le + (Finset.nonempty_range_iff.mpr (Nat.ne_of_gt hN)) (fun n _ => f.norm_coe_le_norm _)) + have hi : ‖∫ t, f t ∂μ‖ ≤ ‖f‖ := by + simpa only [probReal_univ, mul_one] using norm_integral_le_of_norm_le_const (μ := μ) + (Filter.Eventually.of_forall (f.norm_coe_le_norm)) + exact (norm_sub_le _ _).trans (by linarith only [hm, hi]) + +theorem discrepancy_const (N : ℕ) (hN : 0 < N) (x : ℕ → X) (z : ℂ) : + discrepancy μ N x (ContinuousMap.const _ z) = 0 := by + simp only [discrepancy, LinearMap.coe_mk, AddHom.coe_mk, ContinuousMap.const_apply, + Finset.expect_const (Finset.nonempty_range_iff.mpr (Nat.ne_of_gt hN)), + integral_const, probReal_univ, one_smul, sub_self] +end Probability + +section Torus +variable (d : Type*) [Fintype d] +local instance : MeasureSpace UnitAddCircle := ⟨AddCircle.haarAddCircle⟩ +local instance : Measure.IsAddHaarMeasure (volume : Measure UnitAddCircle) := + inferInstanceAs (Measure.IsAddHaarMeasure AddCircle.haarAddCircle) +local instance : IsProbabilityMeasure (volume : Measure UnitAddCircle) := + inferInstanceAs (IsProbabilityMeasure AddCircle.haarAddCircle) + + +def torusHaar : Measure (UnitAddTorus d) := volume + +instance torusHaar_probability : IsProbabilityMeasure (torusHaar d) := + inferInstanceAs (IsProbabilityMeasure (volume : Measure (UnitAddTorus d))) + +theorem integral_character (k : d → ℤ) : + ∫ t, UnitAddTorus.mFourier k t ∂torusHaar d = if k = 0 then 1 else 0 := by + have h := orthonormal_iff_ite.mp (UnitAddTorus.orthonormal_mFourier (d := d)) 0 k + simpa only [UnitAddTorus.mFourierLp, ContinuousMap.inner_toLp, + UnitAddTorus.mFourier_zero, ContinuousMap.one_apply, map_one, mul_one, eq_comm, + torusHaar] using h + + + +theorem torus_character_obstruction (δ : ℝ) (hδ : 0 < δ) : + ∃ S : Finset (d → ℤ), ∃ η : ℝ, 0 < η ∧ + ∀ N : ℕ, 0 < N → ∀ x : ℕ → UnitAddTorus d, + (∃ f : C(UnitAddTorus d, ℂ), LipschitzWith 1 f ∧ ‖f‖ ≤ 1 ∧ + δ ≤ ‖(𝔼 n ∈ Finset.range N, f (x n)) - ∫ t, f t ∂torusHaar d‖) → + ∃ k ∈ S, k ≠ 0 ∧ η ≤ ‖𝔼 n ∈ Finset.range N, UnitAddTorus.mFourier k (x n)‖ := by + obtain ⟨K, hK, hmem⟩ := compact_superset_unit_lipschitz (UnitAddTorus d) + obtain ⟨S, η, hη, htest⟩ := finite_tests_of_dense_span UnitAddTorus.mFourier + UnitAddTorus.span_mFourier_closure_eq_top K hK δ 2 hδ (by norm_num) + refine ⟨S, η, hη, ?_⟩ + intro N hN x ⟨f, hf, hfn, hlarge⟩ + obtain ⟨k, hk, hcorr⟩ := htest (discrepancy (torusHaar d) N x) + (discrepancy_bound (torusHaar d) N hN x) ⟨f, hmem f hf hfn, hlarge⟩ + have hk₀ : k ≠ 0 := by + intro hzero + subst k + rw [UnitAddTorus.mFourier_zero] at hcorr + have he : (1 : C(UnitAddTorus d, ℂ)) = ContinuousMap.const _ 1 := rfl + rw [he, discrepancy_const (torusHaar d) N hN x 1, norm_zero] at hcorr + linarith + refine ⟨k, hk, hk₀, ?_⟩ + have hi := integral_character d k + rw [ite_eq_right hk₀] at hi + simpa only [discrepancy, LinearMap.coe_mk, AddHom.coe_mk, hi, sub_zero] using hcorr + +end Torus +end +end FourierObstruction + +namespace BracketHyperplanes +open MeasureTheory FourierObstruction +open scoped BigOperators +noncomputable section +variable {d : ℕ} + +def complexify (f : C(UnitAddTorus (Fin d),ℝ)) : C(UnitAddTorus (Fin d),ℂ) := + ⟨fun x => (f x : ℂ), by fun_prop⟩ + +lemma torusHaar_eq_volume : torusHaar (Fin d) = volume := by + simp [torusHaar,volume,AddCircle.haarAddCircle] + +lemma re_discrepancy (f : C(UnitAddTorus (Fin d),ℝ)) (N : ℕ) + (x : ℕ → UnitAddTorus (Fin d)) : + (discrepancy (torusHaar (Fin d)) N x (complexify f)).re = + (𝔼 n ∈ Finset.range N, f (x n)) - ∫ t, f t := by + simp only [discrepancy,LinearMap.coe_mk,AddHom.coe_mk,complexify, + ContinuousMap.coe_mk,Complex.sub_re, + torusHaar_eq_volume,Finset.expect_eq_sum_div_card] + simp [integral_complex_ofReal] + + + +theorem finite_real_character_obstruction (T : Finset C(UnitAddTorus (Fin d),ℝ)) + (δ : ℝ) (hδ : 0 < δ) : + ∃ S : Finset (Fin d → ℤ), ∃ η : ℝ, 0 < η ∧ + ∀ N : ℕ, 0 < N → ∀ x : ℕ → UnitAddTorus (Fin d), + (∃ f ∈ T, δ ≤ (𝔼 n ∈ Finset.range N, f (x n)) - ∫ t, f t) → + ∃ k ∈ S, k ≠ 0 ∧ η ≤ ‖𝔼 n ∈ Finset.range N, UnitAddTorus.mFourier k (x n)‖ := by + classical + let K : Set C(UnitAddTorus (Fin d),ℂ) := (T.image complexify : Finset _) + have hK : IsCompact K := (T.image complexify).finite_toSet.isCompact + obtain ⟨S,η,hη,htest⟩ := finite_tests_of_dense_span UnitAddTorus.mFourier + UnitAddTorus.span_mFourier_closure_eq_top K hK δ 2 hδ (by norm_num) + refine ⟨S,η,hη,?_⟩ + intro N hN x ⟨f,hf,hlarge⟩ + have hlarge' : δ ≤ ‖discrepancy (torusHaar (Fin d)) N x (complexify f)‖ := by + rw [← re_discrepancy] at hlarge + exact hlarge.trans (Complex.re_le_norm _) + obtain ⟨k,hk,hcorr⟩ := htest (discrepancy (torusHaar (Fin d)) N x) + (discrepancy_bound (torusHaar (Fin d)) N hN x) + ⟨complexify f,Finset.mem_image.mpr ⟨f,hf,rfl⟩,hlarge'⟩ + have hk₀ : k ≠ 0 := by + intro he + subst k + rw [UnitAddTorus.mFourier_zero] at hcorr + change η ≤ ‖discrepancy (torusHaar (Fin d)) N x (ContinuousMap.const _ 1)‖ at hcorr + rw [discrepancy_const _ _ hN,norm_zero] at hcorr + linarith + refine ⟨k,hk,hk₀,?_⟩ + have hi := integral_character (Fin d) k + rw [ite_eq_right hk₀] at hi + simpa only [discrepancy,LinearMap.coe_mk,AddHom.coe_mk,hi,sub_zero] using hcorr + +lemma half_dense_mean {N : ℕ} (hN : 0 < N) (S : Finset ℕ) + (hS : S ⊆ Finset.range N) (g : ℕ → ℝ) (hg : ∀ n, 0 ≤ g n) + (hgood : ∀ n ∈ S, (1:ℝ)/2 ≤ g n) (δ : ℝ) + (hdens : δ*N ≤ S.card) : δ/2 ≤ (𝔼 n ∈ Finset.range N, g n) := by + have h₁ : (S.card:ℝ)/2 ≤ ∑ n ∈ S, g n := by + calc + _ = ∑ _ ∈ S, (1:ℝ)/2 := by simp [div_eq_mul_inv] + _ ≤ _ := Finset.sum_le_sum hgood + have h₂ : (∑ n ∈ S, g n) ≤ ∑ n ∈ Finset.range N, g n := + Finset.sum_le_sum_of_subset_of_nonneg hS (fun n _ _ => hg n) + rw [Finset.expect_eq_sum_div_card,Finset.card_range] + apply (le_div_iff₀ (Nat.cast_pos.mpr hN)).mpr + linarith + + + +theorem compact_bracket_fourier {P : Type*} [TopologicalSpace P] + [CompactSpace P] [T2Space P] + (a : C(P, Fin d → ℝ)) (ha : ∀ p, a p ≠ 0) (b : C(P, ℝ)) + (K : Set (Fin d → ℝ)) (hK : IsCompact K) (δ : ℝ) (hδ : 0 < δ) : + ∃ frequencies : Finset (Fin d → ℤ), ∃ ε η : ℝ, 0 < ε ∧ 0 < η ∧ + ∀ N : ℕ, 0 < N → ∀ p : P, ∀ x : ℕ → Fin d → ℝ, + (∀ n, x n ∈ K) → ∀ S : Finset ℕ, S ⊆ Finset.range N → δ*N ≤ S.card → + (∀ n ∈ S, ‖((∑ i, a p i*x n i-b p : ℝ) : UnitAddCircle)‖ ≤ ε) → + ∃ k ∈ frequencies, k ≠ 0 ∧ + η ≤ ‖𝔼 n ∈ Finset.range N, UnitAddTorus.mFourier k (torusMap (x n))‖ := by + obtain ⟨T,ε,hε,hT,hcover⟩ := compact_bracket_tests a ha b K hK (δ/4) (by positivity) + obtain ⟨F,η,hη,hF⟩ := finite_real_character_obstruction T (δ/4) (by positivity) + refine ⟨F,ε,η,hε,hη,?_⟩ + intro N hN p x hx S hS hdens hsmall + obtain ⟨f,hf,hfc⟩ := hcover p + apply hF N hN (fun n => torusMap (x n)) + have hmean := half_dense_mean hN S hS (fun n => f (torusMap (x n))) + (fun n => (hT f hf).1 _ |>.1) + (fun n hn => (hfc _ (hx n) (hsmall n hn)).le) δ hdens + refine ⟨f,hf,?_⟩ + have hi := (hT f hf).2 + linarith + +end +end BracketHyperplanes + +end +end +end +end + +end OAI diff --git a/lean/OAI/Combinatorics/SumProduct/Alignment/GlobalPoint01.lean b/lean/OAI/Combinatorics/SumProduct/Alignment/GlobalPoint01.lean new file mode 100644 index 0000000000000000000000000000000000000000..547ba5c832857e084059c42982bb3eb1cce52f18 --- /dev/null +++ b/lean/OAI/Combinatorics/SumProduct/Alignment/GlobalPoint01.lean @@ -0,0 +1,485 @@ +import Mathlib +import OAI.Combinatorics.SumProduct.Alignment.PointLaw02 +import OAI.Geometry.NilpotentCharts.Main + +namespace OAI + +open scoped BigOperators +noncomputable section +end + + + +section + + + + +noncomputable section +open scoped BigOperators Topology +open Filter MeasureTheory + +namespace GlobalPointLaw + + +def cell (N d r : ℕ) (a b : ℝ) : Finset (Fin N) := + Finset.univ.filter fun k => a ≤ (k.val : ℝ) / N ∧ (k.val : ℝ) / N < b ∧ k.val % d = r + +@[simp] lemma mem_cell {N d r : ℕ} {a b : ℝ} {k : Fin N} : + k ∈ cell N d r a b ↔ + a ≤ (k.val : ℝ) / N ∧ (k.val : ℝ) / N < b ∧ k.val % d = r := by + simp [cell] + +lemma normalized_mem {N : ℕ} (k : Fin N) : + (k.val : ℝ) / N ∈ Set.Ico (0 : ℝ) 1 := by + have hN : (0 : ℝ) < N := by exact_mod_cast (Nat.zero_lt_of_lt k.isLt) + constructor + · positivity + · exact (div_lt_one hN).mpr (by exact_mod_cast k.isLt) + + +lemma exists_unique_partition_cell {n : ℕ} (hn : 0 < n) {x : ℝ} + (hx : x ∈ Set.Ico (0 : ℝ) 1) : + ∃! i : Fin n, (i.val : ℝ) / n ≤ x ∧ x < ((i.val : ℝ) + 1) / n := by + have hnR : (0 : ℝ) < n := by exact_mod_cast hn + have hnx : 0 ≤ x * n := mul_nonneg hx.1 hnR.le + have hlt : ⌊x * (n : ℝ)⌋₊ < n := by + apply (Nat.floor_lt hnx).mpr + simpa using (mul_lt_mul_of_pos_right hx.2 hnR) + let i : Fin n := ⟨⌊x * (n : ℝ)⌋₊, hlt⟩ + refine ⟨i, ⟨?_, ?_⟩, ?_⟩ + · exact (div_le_iff₀ hnR).mpr (Nat.floor_le hnx) + · exact (lt_div_iff₀ hnR).mpr (Nat.lt_floor_add_one (x * (n : ℝ))) + · intro j hj + apply Fin.ext + change j.val = ⌊x * (n : ℝ)⌋₊ + symm + apply (Nat.floor_eq_iff hnx).mpr + exact ⟨(div_le_iff₀ hnR).mp hj.1, (lt_div_iff₀ hnR).mp hj.2⟩ + + +lemma sum_cells {A : Type*} [AddCommMonoid A] {n d N : ℕ} + (hn : 0 < n) (hd : 0 < d) (f : Fin N → A) : + (∑ i : Fin n, ∑ r : Fin d, + ∑ k ∈ cell N d r.val ((i.val : ℝ) / n) (((i.val : ℝ) + 1) / n), f k) = + ∑ k : Fin N, f k := by + simp only [cell, Finset.sum_filter] + calc + _ = ∑ i : Fin n, ∑ k : Fin N, ∑ r : Fin d, + if (i.val : ℝ) / n ≤ (k.val : ℝ) / N ∧ + (k.val : ℝ) / N < ((i.val : ℝ) + 1) / n ∧ k.val % d = r.val + then f k else 0 := by + apply Finset.sum_congr rfl + intro i hi + rw [Finset.sum_comm] + _ = ∑ k : Fin N, ∑ i : Fin n, ∑ r : Fin d, + if (i.val : ℝ) / n ≤ (k.val : ℝ) / N ∧ + (k.val : ℝ) / N < ((i.val : ℝ) + 1) / n ∧ k.val % d = r.val + then f k else 0 := Finset.sum_comm + _ = _ := by + apply Finset.sum_congr rfl + intro k hk + obtain ⟨j, hj, hjunique⟩ := exists_unique_partition_cell hn (normalized_mem k) + let r₀ : Fin d := ⟨k.val % d, Nat.mod_lt _ hd⟩ + have hiff (i : Fin n) (r : Fin d) : + ((i.val : ℝ) / n ≤ (k.val : ℝ) / N ∧ + (k.val : ℝ) / N < ((i.val : ℝ) + 1) / n ∧ k.val % d = r.val) ↔ + i = j ∧ r = r₀ := by + constructor + · intro h + exact ⟨hjunique i ⟨h.1, h.2.1⟩, Fin.ext h.2.2.symm⟩ + · rintro ⟨rfl, rfl⟩ + exact ⟨hj.1, hj.2, rfl⟩ + simp_rw [hiff, ite_and] + simp + + +def riemann (n : ℕ) (f : ℝ → ℂ) : ℂ := + ∑ i : Fin n, (1 / (n : ℝ)) • f ((i.val : ℝ) / n) + +lemma partition_endpoints {n : ℕ} (hn : 0 < n) (i : Fin n) : + 0 ≤ (i.val : ℝ) / n ∧ + (i.val : ℝ) / n ≤ ((i.val : ℝ) + 1) / n ∧ + ((i.val : ℝ) + 1) / n ≤ 1 := by + have hnR : (0 : ℝ) < n := by exact_mod_cast hn + refine ⟨by positivity, div_le_div_of_nonneg_right (by linarith) hnR.le, ?_⟩ + apply (div_le_one hnR).mpr + exact_mod_cast i.isLt + + + +lemma riemann_error {n : ℕ} (hn : 0 < n) (f : ℝ → ℂ) (hf : Continuous f) + {ε : ℝ} (_hε : 0 ≤ ε) + (hosc : ∀ x ∈ Set.Icc (0 : ℝ) 1, ∀ y ∈ Set.Icc (0 : ℝ) 1, + |x - y| ≤ 1 / (n : ℝ) → ‖f x - f y‖ ≤ ε) : + ‖riemann n f - ∫ x in (0 : ℝ)..1, f x‖ ≤ ε := by + have hnR : (0 : ℝ) < n := by exact_mod_cast hn + have hsum : (∑ i : Fin n, + ∫ x in (i.val : ℝ) / n..((i.val : ℝ) + 1) / n, f x) = + ∫ x in (0 : ℝ)..1, f x := by + rw [Fin.sum_univ_eq_sum_range (fun k : ℕ => + ∫ x in (k : ℝ) / n..((k : ℝ) + 1) / n, f x) n] + have ht := intervalIntegral.sum_integral_adjacent_intervals + (a := fun k : ℕ => (k : ℝ) / n) (f := f) + (n := n) (μ := volume) (fun k hk => hf.intervalIntegrable _ _) + simpa only [Nat.cast_add, Nat.cast_one, Nat.cast_zero, zero_div, + div_self hnR.ne'] using ht + have hterm (i : Fin n) : + ‖(1 / (n : ℝ)) • f ((i.val : ℝ) / n) - + ∫ x in (i.val : ℝ) / n..((i.val : ℝ) + 1) / n, f x‖ ≤ ε / n := by + obtain ⟨hleft, hle, hright⟩ := partition_endpoints hn i + have hlen : ((i.val : ℝ) + 1) / n - (i.val : ℝ) / n = 1 / n := by ring + have hc : (1 / (n : ℝ)) • f ((i.val : ℝ) / n) = + ∫ _x in (i.val : ℝ) / n..((i.val : ℝ) + 1) / n, + f ((i.val : ℝ) / n) := by + rw [intervalIntegral.integral_const, hlen] + rw [hc, ← intervalIntegral.integral_sub + (intervalIntegrable_const) (hf.intervalIntegrable _ _)] + have hb := intervalIntegral.norm_integral_le_of_norm_le_const (C := ε) + (a := (i.val : ℝ) / n) (b := ((i.val : ℝ) + 1) / n) + (f := fun x => f ((i.val : ℝ) / n) - f x) (by + intro x hx + rw [Set.uIoc_of_le hle] at hx + apply hosc _ ⟨hleft, hle.trans hright⟩ _ ⟨hleft.trans hx.1.le, hx.2.trans hright⟩ + rw [abs_of_nonpos (sub_nonpos.mpr hx.1.le)] + linarith only [hx.2, hlen]) + rw [hlen, abs_of_pos (one_div_pos.mpr hnR)] at hb + simpa only [div_eq_mul_inv, one_mul] using hb + rw [← hsum, riemann, ← Finset.sum_sub_distrib] + calc + _ ≤ ∑ i : Fin n, ‖(1 / (n : ℝ)) • f ((i.val : ℝ) / n) - + ∫ x in (i.val : ℝ) / n..((i.val : ℝ) + 1) / n, f x‖ := norm_sum_le _ _ + _ ≤ ∑ _i : Fin n, ε / (n : ℝ) := Finset.sum_le_sum (fun i _ => hterm i) + _ = ε := by simp only [Finset.sum_const, Finset.card_univ, Fintype.card_fin, nsmul_eq_mul]; field_simp + + +lemma prefix_count_error {d r : ℕ} (hd : 0 < d) (hr : r < d) (M : ℕ) : + |(Nat.count (fun k => k % d = r) M : ℝ) - (M : ℝ) / d| ≤ 1 := by + have hdR : (0 : ℝ) < d := by exact_mod_cast hd + have he : Nat.count (fun k => k % d = r) M = + M / d + if r < M % d then 1 else 0 := by + simpa only [Nat.ModEq, Nat.mod_eq_of_lt hr] using Nat.count_modEq_card M hd r + have hmod : ((M % d : ℕ) : ℝ) < d := by exact_mod_cast Nat.mod_lt M hd + have hmod0 : (0 : ℝ) ≤ ((M % d : ℕ) : ℝ) := by positivity + have hdiv : ((M / d : ℕ) : ℝ) * d + ((M % d : ℕ) : ℝ) = M := by + exact_mod_cast (by simpa only [Nat.mul_comm] using Nat.div_add_mod M d : M / d * d + M % d = M) + have hquot : (M : ℝ) / d = ((M / d : ℕ) : ℝ) + ((M % d : ℕ) : ℝ) / d := by + apply (div_eq_iff hdR.ne').mpr + field_simp + nlinarith [hdiv] + have hlo := div_nonneg hmod0 hdR.le + have hhi : ((M % d : ℕ) : ℝ) / d < 1 := (div_lt_one hdR).mpr hmod + rw [he, hquot, abs_le] + split_ifs <;> push_cast <;> constructor <;> linarith + +lemma interval_filter_card (A B : ℕ) (hAB : A ≤ B) (p : ℕ → Prop) [DecidablePred p] : + ((Finset.Ico A B).filter p).card = Nat.count p B - Nat.count p A := by + have he : (Finset.Ico A B).filter p = + (Finset.range B).filter p \ (Finset.range A).filter p := by + ext k + simp only [Finset.mem_filter, Finset.mem_Ico, Finset.mem_sdiff, Finset.mem_range] + by_cases hp : p k + · simp only [hp, and_true]; omega + · simp only [hp, and_false, not_false_eq_true, false_and] + have hsub : (Finset.range A).filter p ⊆ (Finset.range B).filter p := by + intro k hk + simp only [Finset.mem_filter, Finset.mem_range] at hk ⊢ + exact ⟨hk.1.trans_le hAB, hk.2⟩ + rw [he, Finset.card_sdiff_of_subset hsub, Nat.count_eq_card_filter_range, Nat.count_eq_card_filter_range] + + +lemma cell_card {N d r : ℕ} (hN : 0 < N) {a b : ℝ} + (_ha : 0 ≤ a) (hab : a ≤ b) (hb : b ≤ 1) : + (cell N d r a b).card = + Nat.count (fun k => k % d = r) ⌈b * N⌉₊ - + Nat.count (fun k => k % d = r) ⌈a * N⌉₊ := by + have hN' : (0 : ℝ) < N := by exact_mod_cast hN + rw [← interval_filter_card ⌈a * N⌉₊ ⌈b * N⌉₊ + (Nat.ceil_mono (mul_le_mul_of_nonneg_right hab hN'.le))] + apply Finset.card_bij (fun k _ => k.val) + · intro k hk + have hk' := mem_cell.mp hk + simp only [Finset.mem_filter, Finset.mem_Ico, Nat.ceil_le, Nat.lt_ceil] + exact ⟨⟨(le_div_iff₀ hN').mp hk'.1, (div_lt_iff₀ hN').mp hk'.2.1⟩, hk'.2.2⟩ + · intro k hk k' hk' he + exact Fin.ext he + · intro k hk + simp only [Finset.mem_filter, Finset.mem_Ico, Nat.ceil_le, Nat.lt_ceil] at hk + have hkN : k < N := by + have := hk.1.2.trans_le (mul_le_of_le_one_left hN'.le hb) + exact_mod_cast this + refine ⟨⟨k, hkN⟩, ?_, rfl⟩ + apply mem_cell.mpr + exact ⟨(le_div_iff₀ hN').mpr hk.1.1, (div_lt_iff₀ hN').mpr hk.1.2, hk.2⟩ + + +lemma prefix_density {d r : ℕ} (hd : 0 < d) (hr : r < d) {β : ℝ} (hβ : 0 ≤ β) : + Tendsto (fun N : ℕ => + (Nat.count (fun k => k % d = r) ⌈β * N⌉₊ : ℝ) / N) atTop (𝓝 (β / d)) := by + have hmain : Tendsto (fun N : ℕ => ((⌈β * N⌉₊ : ℝ) / d) / N) + atTop (𝓝 (β / d)) := by + convert (((tendsto_nat_ceil_mul_div_atTop hβ).comp + tendsto_natCast_atTop_atTop).div_const (d : ℝ)) using 1 + ext N + simp only [Function.comp_apply] + ring + have hz : Tendsto (fun N : ℕ => (1 : ℝ) / N) atTop (𝓝 0) := + tendsto_one_div_atTop_nhds_zero_nat + apply tendsto_of_tendsto_of_tendsto_of_le_of_le' + (by simpa only [sub_zero] using hmain.sub hz) + (by simpa only [add_zero] using hmain.add hz) + · exact Filter.Eventually.of_forall (fun N => by + have hlo := (abs_le.mp (prefix_count_error hd hr ⌈β * N⌉₊)).1 + have h := div_le_div_of_nonneg_right hlo (show (0 : ℝ) ≤ N by positivity) + rw [sub_div] at h + simp only [neg_div] at h + linarith) + · exact Filter.Eventually.of_forall (fun N => by + have hhi := (abs_le.mp (prefix_count_error hd hr ⌈β * N⌉₊)).2 + have h := div_le_div_of_nonneg_right hhi (show (0 : ℝ) ≤ N by positivity) + rw [sub_div] at h + linarith) + + +lemma cell_density {d r : ℕ} (hd : 0 < d) (hr : r < d) {a b : ℝ} + (ha : 0 ≤ a) (hab : a ≤ b) (hb : b ≤ 1) : + Tendsto (fun N : ℕ => ((cell N d r a b).card : ℝ) / N) + atTop (𝓝 ((b - a) / d)) := by + have hlim := (prefix_density hd hr (ha.trans hab)).sub (prefix_density hd hr ha) + rw [← sub_div] at hlim + apply hlim.congr' + filter_upwards [eventually_gt_atTop 0] with N hN + rw [cell_card hN ha hab hb, Nat.cast_sub, sub_div] + exact Nat.count_monotone _ (Nat.ceil_mono (mul_le_mul_of_nonneg_right hab (by positivity))) + +section Tests +variable {X : Type*} [TopologicalSpace X] [CompactSpace X] + [MeasurableSpace X] [OpensMeasurableSpace X] + +lemma test_integrable (μ : Measure X) [IsFiniteMeasure μ] (f : C(X, ℂ)) : + Integrable f μ := + Integrable.of_bound f.continuous.aestronglyMeasurable ‖f‖ + (Filter.Eventually.of_forall f.norm_coe_le_norm) + + + +lemma integral_lipschitz (μ : Measure X) [IsProbabilityMeasure μ] : + LipschitzWith 1 (fun f : C(X, ℂ) => ∫ x, f x ∂μ) := by + apply LipschitzWith.of_dist_le_mul + intro f g + simp only [NNReal.coe_one, one_mul, dist_eq_norm] + rw [← integral_sub (test_integrable μ f) (test_integrable μ g)] + have hb := norm_integral_le_of_norm_le_const (μ := μ) (C := ‖f - g‖) + (Filter.Eventually.of_forall fun x => (f - g).norm_coe_le_norm x) + simpa using hb + +lemma continuous_integral (μ : Measure X) [IsProbabilityMeasure μ] + (Φ : ℝ → C(X, ℂ)) (hΦ : Continuous Φ) : + Continuous (fun β => ∫ x, Φ β x ∂μ) := + (integral_lipschitz μ).continuous.comp hΦ + + +def empirical {N : ℕ} (q : Fin N → X) (Φ : ℝ → C(X, ℂ)) : ℂ := + (1 / (N : ℝ)) • ∑ k : Fin N, Φ ((k.val : ℝ) / N) (q k) + + +def frozen (n d : ℕ) {N : ℕ} (q : Fin N → X) (Φ : ℝ → C(X, ℂ)) : ℂ := + (1 / (N : ℝ)) • ∑ i : Fin n, ∑ r : Fin d, + ∑ k ∈ cell N d r.val ((i.val : ℝ) / n) (((i.val : ℝ) + 1) / n), + Φ ((i.val : ℝ) / n) (q k) + +omit [MeasurableSpace X] [OpensMeasurableSpace X] in +lemma empirical_frozen_error {n d N : ℕ} (hn : 0 < n) (hd : 0 < d) + (hN : 0 < N) (q : Fin N → X) (Φ : ℝ → C(X, ℂ)) {ε : ℝ} + (hosc : ∀ x ∈ Set.Icc (0 : ℝ) 1, ∀ y ∈ Set.Icc (0 : ℝ) 1, + |x - y| ≤ 1 / (n : ℝ) → ‖Φ x - Φ y‖ ≤ ε) : + ‖empirical q Φ - frozen n d q Φ‖ ≤ ε := by + have hN' : (0 : ℝ) < N := by exact_mod_cast hN + have hsum := sum_cells hn hd (fun k : Fin N => Φ ((k.val : ℝ) / N) (q k)) + rw [empirical, frozen, ← hsum, ← smul_sub, norm_smul, + Real.norm_eq_abs, abs_of_pos (one_div_pos.mpr hN')] + simp only [← Finset.sum_sub_distrib] + have hterm (i : Fin n) (r : Fin d) + (k : Fin N) (hk : k ∈ cell N d r.val + ((i.val : ℝ) / n) (((i.val : ℝ) + 1) / n)) : + ‖Φ ((k.val : ℝ) / N) (q k) - Φ ((i.val : ℝ) / n) (q k)‖ ≤ ε := by + obtain ⟨hleft, hle, hright⟩ := partition_endpoints hn i + have hk' := mem_cell.mp hk + have hk01 := normalized_mem k + apply ((Φ ((k.val : ℝ) / N) - Φ ((i.val : ℝ) / n)).norm_coe_le_norm (q k)).trans + apply hosc _ ⟨hk01.1, hk01.2.le⟩ _ ⟨hleft, hle.trans hright⟩ + rw [abs_of_nonneg (sub_nonneg.mpr hk'.1)] + have hlen : ((i.val : ℝ) + 1) / n - (i.val : ℝ) / n = 1 / n := by ring + linarith only [hk'.2.1, hlen] + calc + _ ≤ (1 / (N : ℝ)) * ∑ i : Fin n, ∑ r : Fin d, + ∑ k ∈ cell N d r.val ((i.val : ℝ) / n) (((i.val : ℝ) + 1) / n), ε := by + apply mul_le_mul_of_nonneg_left _ (one_div_nonneg.mpr hN'.le) + apply (norm_sum_le _ _).trans + apply Finset.sum_le_sum + intro i hi + apply (norm_sum_le _ _).trans + apply Finset.sum_le_sum + intro r hr + apply (norm_sum_le _ _).trans + exact Finset.sum_le_sum (fun k hk => hterm i r k hk) + _ = ε := by + rw [sum_cells hn hd (fun _k : Fin N => ε)] + simp only [Finset.sum_const, Finset.card_univ, Fintype.card_fin, nsmul_eq_mul] + field_simp + + +def betaMixture {d : ℕ} (μ : Fin d → Measure X) (Φ : ℝ → C(X, ℂ)) : ℂ := + (1 / (d : ℝ)) • ∑ r : Fin d, ∫ β in (0 : ℝ)..1, ∫ x, Φ β x ∂μ r + +def mixedRiemann {d : ℕ} (n : ℕ) (μ : Fin d → Measure X) + (Φ : ℝ → C(X, ℂ)) : ℂ := + (1 / (d : ℝ)) • ∑ r : Fin d, riemann n (fun β => ∫ x, Φ β x ∂μ r) + +lemma mixed_riemann_error {n d : ℕ} (hn : 0 < n) (hd : 0 < d) + (μ : Fin d → Measure X) [∀ r, IsProbabilityMeasure (μ r)] + (Φ : ℝ → C(X, ℂ)) (hΦ : Continuous Φ) {ε : ℝ} (hε : 0 ≤ ε) + (hosc : ∀ x ∈ Set.Icc (0 : ℝ) 1, ∀ y ∈ Set.Icc (0 : ℝ) 1, + |x - y| ≤ 1 / (n : ℝ) → ‖Φ x - Φ y‖ ≤ ε) : + ‖mixedRiemann n μ Φ - betaMixture μ Φ‖ ≤ ε := by + have hdR : (0 : ℝ) < d := by exact_mod_cast hd + rw [mixedRiemann, betaMixture, ← smul_sub, norm_smul, + Real.norm_eq_abs, abs_of_pos (one_div_pos.mpr hdR), ← Finset.sum_sub_distrib] + calc + _ ≤ (1 / (d : ℝ)) * ∑ _r : Fin d, ε := by + apply mul_le_mul_of_nonneg_left _ (one_div_nonneg.mpr hdR.le) + apply (norm_sum_le _ _).trans + apply Finset.sum_le_sum + intro r hr + apply riemann_error hn _ (continuous_integral (μ r) Φ hΦ) hε + intro x hx y hy hxy + have hb := (integral_lipschitz (μ r)).dist_le_mul (Φ x) (Φ y) + simp only [NNReal.coe_one, one_mul, dist_eq_norm] at hb + exact hb.trans (hosc x hx y hy hxy) + _ = ε := by + simp only [Finset.sum_const, Finset.card_univ, Fintype.card_fin, nsmul_eq_mul] + field_simp + +omit [CompactSpace X] [OpensMeasurableSpace X] in + + +lemma frozen_tendsto {ι : Type*} {l : Filter ι} {N : ι → ℕ} + {d n : ℕ} (_hd : 0 < d) (hn : 0 < n) + (q : (j : ι) → Fin (N j) → X) (μ : Fin d → Measure X) + (Φ : ℝ → C(X, ℂ)) + (hlocal : ∀ a b : ℝ, 0 ≤ a → a < b → b ≤ 1 → + ∀ (r : Fin d) (f : C(X, ℂ)), + Tendsto (fun j => (1 / (N j : ℝ)) • + ∑ k ∈ cell (N j) d r.val a b, f (q j k)) l + (𝓝 (((b - a) / d) • ∫ x, f x ∂μ r))) : + Tendsto (fun j => frozen n d (q j) Φ) l (𝓝 (mixedRiemann n μ Φ)) := by + have hnR : (0 : ℝ) < n := by exact_mod_cast hn + have hpart (i : Fin n) (r : Fin d) := + hlocal ((i.val : ℝ) / n) (((i.val : ℝ) + 1) / n) + (partition_endpoints hn i).1 + (div_lt_div_of_pos_right (by linarith) hnR) + (partition_endpoints hn i).2.2 r (Φ ((i.val : ℝ) / n)) + have hlim := tendsto_finsetSum Finset.univ (fun i _ => + tendsto_finsetSum Finset.univ (fun r _ => hpart i r)) + have heq : (∑ i : Fin n, ∑ r : Fin d, + (((((i.val : ℝ) + 1) / n - (i.val : ℝ) / n) / d) • + ∫ x, Φ ((i.val : ℝ) / n) x ∂μ r)) = mixedRiemann n μ Φ := by + rw [mixedRiemann] + simp only [riemann, Finset.smul_sum] + rw [Finset.sum_comm] + apply Finset.sum_congr rfl + intro i hi + apply Finset.sum_congr rfl + intro r hr + rw [smul_smul] + congr 1 + ring + rw [heq] at hlim + simpa only [frozen, Finset.smul_sum] using hlim + + + +omit [CompactSpace X] [OpensMeasurableSpace X] in +lemma local_mass_limit {ι : Type*} {l : Filter ι} {N : ι → ℕ} + (hN : Tendsto N l atTop) {d : ℕ} (hd : 0 < d) + (q : (j : ι) → Fin (N j) → X) (μ : Fin d → Measure X) + {a b : ℝ} (ha : 0 ≤ a) (hab : a ≤ b) (hb : b ≤ 1) + (r : Fin d) (f : C(X, ℂ)) + (hlocal : Tendsto (fun j => 𝔼 k ∈ cell (N j) d r.val a b, f (q j k)) l + (𝓝 (∫ x, f x ∂μ r))) : + Tendsto (fun j => (1 / (N j : ℝ)) • + ∑ k ∈ cell (N j) d r.val a b, f (q j k)) l + (𝓝 (((b - a) / d) • ∫ x, f x ∂μ r)) := by + have hmass := (cell_density hd r.isLt ha hab hb).comp hN + have ht := hmass.smul hlocal + apply ht.congr + intro j + dsimp only [Function.comp_apply] + set S := cell (N j) d r.val a b + rw [← Finset.card_smul_expect S (fun k => f (q j k)), + ← Nat.cast_smul_eq_nsmul ℝ, smul_smul] + congr 1 + ring + + + +theorem global_point_law {ι : Type*} {l : Filter ι} {N : ι → ℕ} + (hN : ∀ᶠ j in l, 0 < N j) {d : ℕ} (hd : 0 < d) + (q : (j : ι) → Fin (N j) → X) (μ : Fin d → Measure X) + [∀ r, IsProbabilityMeasure (μ r)] + (Φ : ℝ → C(X, ℂ)) (hΦ : Continuous Φ) + (hlocal : ∀ a b : ℝ, 0 ≤ a → a < b → b ≤ 1 → + ∀ (r : Fin d) (f : C(X, ℂ)), + Tendsto (fun j => (1 / (N j : ℝ)) • + ∑ k ∈ cell (N j) d r.val a b, f (q j k)) l + (𝓝 (((b - a) / d) • ∫ x, f x ∂μ r))) : + Tendsto (fun j => empirical (q j) Φ) l (𝓝 (betaMixture μ Φ)) := by + apply Metric.tendsto_nhds.mpr + intro ε hε + have huc : UniformContinuousOn Φ (Set.Icc (0 : ℝ) 1) := + isCompact_Icc.uniformContinuousOn_of_continuous hΦ.continuousOn + obtain ⟨δ, hδ, huniform⟩ := Metric.uniformContinuousOn_iff.mp huc (ε / 4) (by positivity) + obtain ⟨n, hnδ⟩ := exists_nat_one_div_lt hδ + have hnunit : 1 / ((n + 1 : ℕ) : ℝ) < δ := by simpa using hnδ + have hosc : ∀ x ∈ Set.Icc (0 : ℝ) 1, ∀ y ∈ Set.Icc (0 : ℝ) 1, + |x - y| ≤ 1 / ((n + 1 : ℕ) : ℝ) → ‖Φ x - Φ y‖ ≤ ε / 4 := by + intro x hx y hy hxy + have ht := huniform x hx y hy (by simpa only [Real.dist_eq] using hxy.trans_lt hnunit) + simpa only [dist_eq_norm] using ht.le + have he := mixed_riemann_error (Nat.succ_pos n) hd μ Φ hΦ (by positivity) hosc + have ht := frozen_tendsto hd (Nat.succ_pos n) q μ Φ hlocal + have hevent := Metric.tendsto_nhds.mp ht (ε / 2) (by positivity) + filter_upwards [hN, hevent] with j hj hjdist + have hfreeze := empirical_frozen_error (Nat.succ_pos n) hd hj (q j) Φ hosc + have htri := dist_triangle (empirical (q j) Φ) (frozen (n + 1) d (q j) Φ) + (betaMixture μ Φ) + have htri' := dist_triangle (frozen (n + 1) d (q j) Φ) + (mixedRiemann (n + 1) μ Φ) (betaMixture μ Φ) + rw [← dist_eq_norm] at he hfreeze + linarith + + + +theorem global_point_law_of_local_haar {ι : Type*} {l : Filter ι} {N : ι → ℕ} + (hN : Tendsto N l atTop) {d : ℕ} (hd : 0 < d) + (q : (j : ι) → Fin (N j) → X) (μ : Fin d → Measure X) + [∀ r, IsProbabilityMeasure (μ r)] + (Φ : ℝ → C(X, ℂ)) (hΦ : Continuous Φ) + (hlocal : ∀ a b : ℝ, 0 ≤ a → a < b → b ≤ 1 → + ∀ (r : Fin d) (f : C(X, ℂ)), + Tendsto (fun j => 𝔼 k ∈ cell (N j) d r.val a b, f (q j k)) l + (𝓝 (∫ x, f x ∂μ r))) : + Tendsto (fun j => empirical (q j) Φ) l (𝓝 (betaMixture μ Φ)) := by + apply global_point_law (hN.eventually (eventually_gt_atTop 0)) hd q μ Φ hΦ + intro a b ha hab hb r f + exact local_mass_limit hN hd q μ ha hab.le hb r f (hlocal a b ha hab hb r f) + +end Tests + +end GlobalPointLaw + + +end +end + +end OAI diff --git a/lean/OAI/Combinatorics/SumProduct/Alignment/HarmonicExposure01.lean b/lean/OAI/Combinatorics/SumProduct/Alignment/HarmonicExposure01.lean new file mode 100644 index 0000000000000000000000000000000000000000..b82e737a53b4da2efd9e7948ff7ca590b11b0aaf --- /dev/null +++ b/lean/OAI/Combinatorics/SumProduct/Alignment/HarmonicExposure01.lean @@ -0,0 +1,274 @@ +import Mathlib +import OAI.Combinatorics.SumProduct.Alignment.RoughFace01 +import OAI.Geometry.NilpotentCharts.Main + +namespace OAI + +section +noncomputable section +end +end + + +section + +noncomputable section +namespace RoughFaceShift +open RationalLattice MalcevCharacters RealPolynomialDegree RoughScales Filter +open RoughSamplingWeights FinitePieceAverages RoughSourceExceptional RoughProductRemoval +open scoped BigOperators Topology +variable {G : Type} [Group G] [TopologicalSpace G] {dim : ℕ} +variable (Γ : Subgroup G) [MetricSpace (G⧸Γ)] +variable [IsTopologicalGroup G] (c : RealCoordinates G dim) + + + +theorem source_face_decay (hsk : SecondKind c) + (hΓ : ∀ g : G,g∈Γ ↔ ∀ i,∃ z : ℤ,c.coord g i=z) + (htop : (inferInstance : MetricSpace (G⧸Γ)).toUniformSpace.toTopologicalSpace = + QuotientGroup.instTopologicalSpace Γ) + (m v D d : ℕ) (hd : 0S n j) atTop atTop) + (hZ : ∀ a : ℝ,0Z n/(1+∑ j,S n j)^a) atTop atTop) + (hH : ∀ n,0≤H n) (hHZ : Tendsto (fun n=>H n/Z n) atTop (𝓝 0)) + (hM : ∀ n,0S n j/(L n:ℝ)) atTop atTop) : + ∀ ε : ℝ,0<ε →∀ᶠ n in atTop, + ∀ (A : Fin v → ℤ) (P : (Fin (m+v)→ℝ)→G), + (∀ i,HasDegree (fun y=>canonicalLog c (P y) i) D) → + ∀ (σ : (G⧸Γ) → (G⧸Γ)),LipschitzWith K σ → + ∀ h : (Fin m → ℤ) → Fin v → ℤ, + (∀ t∈productTimes (S n) (r n) (L n),∀ i,(d:ℤ)∣h t i ∧ |(h t i:ℝ)|≤H n) → + (∀ t∈productTimes (S n) (r n) (L n),∀ x : Fin v → ℤ, + σ (QuotientGroup.mk (P (Fin.append (fun j=>(t j:ℝ)) (fun i=>(x i:ℝ)))))= + QuotientGroup.mk (P (Fin.append (fun j=>(t j:ℝ)) (fun i=>((x i+h t i:ℤ):ℝ))))) → + ((exceptionalFace Γ m v c₀ C₀ B η (Z n) d (M n) A P σ (S n) (r n) (L n)).card:ℝ)/ + ((productTimes (S n) (r n) (L n)).card:ℝ)<ε := by + classical + let B' : NNReal := B*(K+1) + have hB' : 01) (T:=fun n=>totalScale (S n)) + (by filter_upwards [] with n; norm_num) (totalScale_pos_eventually S hS) hZ + simpa using h 1 zero_lt_one + have herr : Tendsto (fun n=>(8*(B:ℝ)*(v:ℝ)/c₀)*(H n/Z n)) atTop (𝓝 0) := by + simpa using hHZ.const_mul (8*(B:ℝ)*(v:ℝ)/c₀) + intro ε hε + have hp := source_product_decay c Γ hsk hΓ htop m v D d hd c₀ C₀ B' (η/4) + hc₀ hC₀ hB' (by positivity) w M S Z r L hw hS hZ hM hMs hL hsm hWL hr hSL ε hε + filter_upwards [hp,hz.eventually (eventually_ge_atTop (4*(d:ℝ)/c₀)), + herr.eventually (gt_mem_nhds (by positivity : (0:ℝ)<η/4))] with n hpn hzn hen + intro A P hP σ hσ h hh hid + have hW : 4*(d:ℝ)≤c₀*Z n := by + have ht := (div_le_iff₀ hc₀).mp hzn + nlinarith + have hsub : exceptionalFace Γ m v c₀ C₀ B η (Z n) d (M n) A P σ (S n) (r n) (L n) ⊆ + exceptionalProduct Γ m v c₀ C₀ B' (η/4) (Z n) d (M n) A P (S n) (r n) (L n) := by + intro t ht + obtain ⟨ht,hbad⟩ := Finset.mem_filter.mp ht + apply Finset.mem_filter.mpr + refine ⟨ht,?_⟩ + by_contra hgood + obtain ⟨lo,hi,res,test,hside,hbox,hLip,hnorm,hlarge⟩ := hbad + have hcompare (F : (G⧸Γ) → ℂ) (hFL : LipschitzWith B' F) (hFn : ∀ y,‖F y‖≤B') : + ‖mean (physicalResidueBox lo hi res d) + (fun x=>F (QuotientGroup.mk (P (Fin.append (fun j=>(t j:ℝ)) (fun i=>(x i:ℝ))))))- + mean (nestedBox lo hi res A d (M n) (∏ j,t j)) + (fun x=>F (QuotientGroup.mk (P (Fin.append (fun j=>(t j:ℝ)) (fun i=>(x i:ℝ))))))‖<η/4 := by + apply lt_of_not_ge + intro hh + exact hgood ⟨lo,hi,res,F,hside,hbox,hFL,hFn,hh⟩ + have hplain := hcompare test (hLip.weaken hBB) + (fun y=>(hnorm y).trans (by exact_mod_cast hBB)) + have hface := hcompare (fun y=>test (σ y)) ((hLip.comp hσ).weaken hBK) + (fun y=>(hnorm (σ y)).trans (by exact_mod_cast hBB)) + let f : (Fin v → ℤ) → ℂ := fun x=>test + (QuotientGroup.mk (P (Fin.append (fun j=>(t j:ℝ)) (fun i=>(x i:ℝ))))) + have hshift := residueMean_translation lo hi res (h t) d hd (B:ℝ) (c₀*Z n) (H n) + hB hW hside (hH n) (hh t ht) f (fun x=>hnorm _) + have he : (fun x : Fin v → ℤ=>test + (σ (QuotientGroup.mk (P (Fin.append (fun j=>(t j:ℝ)) (fun i=>(x i:ℝ)))))))= + fun x=>f (x+h t) := by + funext x + rw [hid t ht x] + rfl + have hsmall : ‖mean (physicalResidueBox lo hi res d) (fun x=>f (x+h t))- + mean (physicalResidueBox lo hi res d) f‖<η/4 := by + apply hshift.trans_lt + convert hen using 1 + ring + rw [← he] at hsmall + let X := mean (nestedBox lo hi res A d (M n) (∏ j,t j)) + (fun x=>test (σ (QuotientGroup.mk (P (Fin.append (fun j=>(t j:ℝ)) (fun i=>(x i:ℝ))))))) + let Y := mean (physicalResidueBox lo hi res d) + (fun x=>test (σ (QuotientGroup.mk (P (Fin.append (fun j=>(t j:ℝ)) (fun i=>(x i:ℝ))))))) + let U := mean (physicalResidueBox lo hi res d) f + let V := mean (nestedBox lo hi res A d (M n) (∏ j,t j)) f + have htri : ‖X-V‖≤‖X-Y‖+‖Y-U‖+‖U-V‖ := by + calc + _≤‖X-U‖+‖U-V‖ := norm_sub_le_norm_sub_add_norm_sub X U V + _≤_ := add_le_add (norm_sub_le_norm_sub_add_norm_sub X Y U) (le_refl ‖U-V‖) + change η≤‖X-V‖ at hlarge + change ‖U-V‖<η/4 at hplain + change ‖Y-X‖<η/4 at hface + rw [norm_sub_rev] at hface + change ‖Y-U‖<η/4 at hsmall + linarith + exact (div_le_div_of_nonneg_right (by exact_mod_cast Finset.card_le_card hsub) + (Nat.cast_nonneg _)).trans_lt (hpn A P hP) + +end RoughFaceShift +end +end + + +section + +noncomputable section +namespace HarmonicExposure +open RoughSamplingWeights RoughSourceExceptional RoughProductRemoval +open scoped BigOperators + + +def pivotMass (Q Δ τ : ℝ) (a M : ℤ) : ℝ := + ∑ k∈indices (Q/τ) ((Q+Δ)/τ) a M, ((a:ℝ)+(M:ℝ)*(k:ℝ))⁻¹ + +def exposedWeight {m : ℕ} (Q Δ : ℝ) (a M : ℤ) (t : Fin m → ℤ) : ℝ := + (∏ j,(t j:ℝ)⁻¹) * pivotMass Q Δ (∏ j,(t j:ℝ)) a M + +lemma pivot_bounds (Q Δ τ : ℝ) (a M : ℤ) (hM : 0(hpoint k hk).1) + have hhi : pivotMass Q Δ τ a M≤(2*ν)*(τ/Q) := by + calc + _≤∑ _k∈T,τ/Q := Finset.sum_le_sum (fun k hk=>(hpoint k hk).2) + _=(T.card:ℝ)*(τ/Q) := by simp + _≤_ := mul_le_mul_of_nonneg_right hNu (by positivity) + constructor + · apply LE.le.trans ?_ hlo + have hid : (ν/2)*(τ/(Q+Δ))=Δ/(2*(M:ℝ)*(Q+Δ)) := by + dsimp [ν] + field_simp + rw [hid] + apply div_le_div_of_nonneg_left hΔ.le (by positivity) + nlinarith + · apply hhi.trans_eq + dsimp [ν] + field_simp + ring + +lemma exposed_weight_bounds (m : ℕ) (S : Fin m → ℝ) (r : Fin m → ℤ) (L a M : ℤ) + (Q Δ : ℝ) (hS : ∀ j,0(hS j).trans_le (hb j).1 + have hsp : (0:ℝ)<∏ j,S j := Finset.prod_pos (fun j _=>hS j) + have hτ : (0:ℝ)<∏ j,(t j:ℝ) := Finset.prod_pos (fun j _=>htp j) + have hlo : (∏ j,S j)≤∏ j,(t j:ℝ) := Finset.prod_le_prod₀ + (fun j _=>(hS j).le) (fun j _=>(hb j).1) + have hhi : (∏ j,(t j:ℝ))≤2^m*∏ j,S j := by + calc + _≤∏ j,2*S j := Finset.prod_le_prod₀ (fun j _=>(htp j).le) (fun j _=>(hb j).2.le) + _=_ := by rw [Finset.prod_mul_distrib]; simp + have hsz : 4*(M:ℝ)*(∏ j,(t j:ℝ))≤Δ := + (mul_le_mul_of_nonneg_left hhi (by positivity)).trans hsize + have hmass := pivot_bounds Q Δ (∏ j,(t j:ℝ)) a M hM hQ hΔ hτ hΔQ hsz + have he : exposedWeight Q Δ a M t=pivotMass Q Δ (∏ j,(t j:ℝ)) a M/(∏ j,(t j:ℝ)) := by + dsimp [exposedWeight] + rw [Finset.prod_inv_distrib,div_eq_mul_inv,mul_comm] + rw [he] + constructor + · calc + _≤(Δ/(4*(M:ℝ)*Q))/(∏ j,(t j:ℝ)) := div_le_div_of_nonneg_left (by positivity) hτ hhi + _≤_ := div_le_div_of_nonneg_right hmass.1 hτ.le + · calc + _≤(8*(Δ/(4*(M:ℝ)*Q)))/(∏ j,(t j:ℝ)) := div_le_div_of_nonneg_right hmass.2 hτ.le + _≤(8*(Δ/(4*(M:ℝ)*Q)))/(∏ j,S j) := div_le_div_of_nonneg_left (by positivity) hsp hlo + _=_ := by field_simp + +lemma weighted_fraction_bound {α : Type*} (T E : Finset α) (hT : T.Nonempty) + (hE : E⊆T) (f : α → ℝ) (A K : ℝ) (hA : 0(hf t ht).1) + have htotal : (0:ℝ)<∑ t∈T,f t := (mul_pos hcard hA).trans_le hlo + have hhi : (∑ t∈E,f t)≤(E.card:ℝ)*(K*A) := by + calc + _≤∑ _t∈E,K*A := Finset.sum_le_sum (fun t ht=>(hf t (hE ht)).2) + _=_ := by simp + apply (div_le_iff₀ htotal).mpr + calc + _≤(E.card:ℝ)*(K*A) := hhi + _=(K*((E.card:ℝ)/(T.card:ℝ)))*((T.card:ℝ)*A) := by field_simp + _≤_ := mul_le_mul_of_nonneg_left hlo (by positivity) + +theorem conditional_fraction_le (m : ℕ) (S : Fin m → ℝ) (r : Fin m → ℤ) (L a M : ℤ) + (Q Δ : ℝ) (hS : ∀ j,0hS j) + apply weighted_fraction_bound _ E hT hE _ ((Δ/(4*(M:ℝ)*Q))/(2^m*∏ j,S j)) (8*2^m) + (by positivity) (by positivity) + exact exposed_weight_bounds m S r L a M Q Δ hS hL hM hQ hΔ hΔQ hsize + +end HarmonicExposure + +end +end + +end OAI diff --git a/lean/OAI/Combinatorics/SumProduct/Alignment/HarmonicExposure02.lean b/lean/OAI/Combinatorics/SumProduct/Alignment/HarmonicExposure02.lean new file mode 100644 index 0000000000000000000000000000000000000000..812d9bde58b7d7fcb93171c5f18fcd907f4e7ade --- /dev/null +++ b/lean/OAI/Combinatorics/SumProduct/Alignment/HarmonicExposure02.lean @@ -0,0 +1,332 @@ +import Mathlib +import OAI.Combinatorics.SumProduct.Alignment.HarmonicExposure01 +import OAI.Geometry.NilpotentCharts.Main + +namespace OAI + +section +noncomputable section +end +end + + +section + +noncomputable section +namespace RoughFaceShift +open RationalLattice MalcevCharacters RealPolynomialDegree RoughScales Filter +open RoughSamplingWeights FinitePieceAverages RoughSourceExceptional RoughProductRemoval +open scoped BigOperators Topology +variable {G : Type} [Group G] [TopologicalSpace G] {dim : ℕ} +variable (Γ : Subgroup G) [MetricSpace (G⧸Γ)] +variable [IsTopologicalGroup G] (c : RealCoordinates G dim) + + + +theorem source_conditional_face_decay (hsk : SecondKind c) + (hΓ : ∀ g : G,g∈Γ ↔ ∀ i,∃ z : ℤ,c.coord g i=z) + (htop : (inferInstance : MetricSpace (G⧸Γ)).toUniformSpace.toTopologicalSpace = + QuotientGroup.instTopologicalSpace Γ) + (m v D d : ℕ) (hd : 0S n j) atTop atTop) + (hZ : ∀ a : ℝ,0Z n/(1+∑ j,S n j)^a) atTop atTop) + (hH : ∀ n,0≤H n) (hHZ : Tendsto (fun n=>H n/Z n) atTop (𝓝 0)) + (hM : ∀ n,0S n j/(L n:ℝ)) atTop atTop) + (hbin : ∀ᶠ n in atTop,0canonicalLog c (P y) i) D) → + ∀ (σ : (G⧸Γ) → (G⧸Γ)),LipschitzWith K σ → + ∀ h : (Fin m → ℤ) → Fin v → ℤ, + (∀ t∈productTimes (S n) (r n) (L n),∀ i,(d:ℤ)∣h t i ∧ |(h t i:ℝ)|≤H n) → + (∀ t∈productTimes (S n) (r n) (L n),∀ x : Fin v → ℤ, + σ (QuotientGroup.mk (P (Fin.append (fun j=>(t j:ℝ)) (fun i=>(x i:ℝ)))))= + QuotientGroup.mk (P (Fin.append (fun j=>(t j:ℝ)) (fun i=>((x i+h t i:ℤ):ℝ))))) → + (∑ t∈exceptionalFace Γ m v c₀ C₀ B η (Z n) d (M n) A P σ (S n) (r n) (L n), + HarmonicExposure.exposedWeight (Q n) (Δ n) (a n) (M n) t)/ + (∑ t∈productTimes (S n) (r n) (L n), + HarmonicExposure.exposedWeight (Q n) (Δ n) (a n) (M n) t)<ε := by + classical + have hK : (0:ℝ)<8*2^m := by positivity + intro ε hε + have hf := source_face_decay (Γ:=Γ) (c:=c) hsk hΓ htop m v D d hd c₀ C₀ B K η + hc₀ hC₀ hB hη w M S Z H r L hw hS hZ hH hHZ hM hMs hL hsm hWL hr hSL + (ε/(8*2^m)) (div_pos hε hK) + have hpos : ∀ᶠ n in atTop,∀ j,0(hS j).eventually (eventually_gt_atTop 0)) + have hne := productTimes_nonempty_eventually S r L hL hS hSL + filter_upwards [hf,hpos,hne,hbin] with n hfn hsn htn hbn + intro A P hP σ hσ h hh hid + have hfrac := hfn A P hP σ hσ h hh hid + have hdom := HarmonicExposure.conditional_fraction_le m (S n) (r n) (L n) (a n) (M n) + (Q n) (Δ n) hsn (hL n) (by exact_mod_cast hM n) hbn.1 hbn.2.1 hbn.2.2.1 hbn.2.2.2 + htn (exceptionalFace Γ m v c₀ C₀ B η (Z n) d (M n) A P σ (S n) (r n) (L n)) + (Finset.filter_subset _ _) + apply hdom.trans_lt + have hh := mul_lt_mul_of_pos_left hfrac hK + simpa only [mul_div_cancel₀ _ hK.ne'] using hh + +end RoughFaceShift + +end +end + + +section +noncomputable section +namespace RoughFaceShift +open RationalLattice MalcevCharacters RealPolynomialDegree RoughScales Filter +open RoughSamplingWeights FinitePieceAverages RoughSourceExceptional RoughProductRemoval +open scoped BigOperators Topology +variable {G : Type} [Group G] [TopologicalSpace G] {dim : ℕ} +variable (Γ : Subgroup G) [MetricSpace (G⧸Γ)] +variable [IsTopologicalGroup G] (c : RealCoordinates G dim) + +structure Exposure (m : ℕ) where + S : Fin m → ℝ + r : Fin m → ℤ + Z : ℝ + Q : ℝ + Δ : ℝ + a : ℤ + +def Exposure.Legal {m : ℕ} (b : Exposure m) (U V : Fin m → ℝ) + (Z0 : ℝ) (w M : ℕ) : Prop := + (∀ j,U j≤b.S j ∧ b.S j≤V j) ∧ Z0≤b.Z ∧ + (∀ j,(b.r j).natAbs.Coprime (primorial w)) ∧ + 0U n j) atTop atTop) + (hUV : ∀ n j,U n j≤V n j) + (hZ : ∀ a : ℝ,0Z0 n/(1+∑ j,V n j)^a) atTop atTop) + (hH : ∀ n,0≤H n) (hHZ : Tendsto (fun n=>H n/Z0 n) atTop (𝓝 0)) + (hM : ∀ n,0U n j/(L n:ℝ)) atTop atTop) : + ∀ ε : ℝ,0<ε →∀ᶠ n in atTop, + ∀ b : Exposure m,b.Legal (U n) (V n) (Z0 n) (w n) (M n) → + ∀ (A : Fin v → ℤ) (P : (Fin (m+v)→ℝ)→G), + (∀ i,HasDegree (fun y=>canonicalLog c (P y) i) D) → + ∀ (σ : (G⧸Γ) → (G⧸Γ)),LipschitzWith K σ → + ∀ h : (Fin m → ℤ) → Fin v → ℤ, + (∀ t∈productTimes b.S b.r (L n),∀ i,(d:ℤ)∣h t i ∧ |(h t i:ℝ)|≤H n) → + (∀ t∈productTimes b.S b.r (L n),∀ x : Fin v → ℤ, + σ (QuotientGroup.mk (P (Fin.append (fun j=>(t j:ℝ)) (fun i=>(x i:ℝ)))))= + QuotientGroup.mk (P (Fin.append (fun j=>(t j:ℝ)) (fun i=>((x i+h t i:ℤ):ℝ))))) → + (∑ t∈exceptionalFace Γ m v c₀ C₀ B η b.Z d (M n) A P σ b.S b.r (L n), + HarmonicExposure.exposedWeight b.Q b.Δ b.a (M n) t)/ + (∑ t∈productTimes b.S b.r (L n), + HarmonicExposure.exposedWeight b.Q b.Δ b.a (M n) t)<ε + := by + classical + intro ε hε + let succeeds (n : ℕ) (b : Exposure m) : Prop := + ∀ (A : Fin v → ℤ) (P : (Fin (m+v)→ℝ)→G), + (∀ i,HasDegree (fun y=>canonicalLog c (P y) i) D) → + ∀ (σ : (G⧸Γ) → (G⧸Γ)),LipschitzWith K σ → + ∀ h : (Fin m → ℤ) → Fin v → ℤ, + (∀ t∈productTimes b.S b.r (L n),∀ i,(d:ℤ)∣h t i ∧ |(h t i:ℝ)|≤H n) → + (∀ t∈productTimes b.S b.r (L n),∀ x : Fin v → ℤ, + σ (QuotientGroup.mk (P (Fin.append (fun j=>(t j:ℝ)) (fun i=>(x i:ℝ)))))= + QuotientGroup.mk (P (Fin.append (fun j=>(t j:ℝ)) (fun i=>((x i+h t i:ℤ):ℝ))))) → + (∑ t∈exceptionalFace Γ m v c₀ C₀ B η b.Z d (M n) A P σ b.S b.r (L n), + HarmonicExposure.exposedWeight b.Q b.Δ b.a (M n) t)/ + (∑ t∈productTimes b.S b.r (L n), + HarmonicExposure.exposedWeight b.Q b.Δ b.a (M n) t)<ε + + change ∀ᶠ n in atTop,∀ b : Exposure m, + b.Legal (U n) (V n) (Z0 n) (w n) (M n) → succeeds n b + have hchoice (n : ℕ) : ∃ b : Exposure m, + b.Legal (U n) (V n) (Z0 n) (w n) (M n) ∧ + ((∃ b : Exposure m,b.Legal (U n) (V n) (Z0 n) (w n) (M n) ∧ ¬succeeds n b) + → ¬succeeds n b) := by + by_cases he : ∃ b : Exposure m, + b.Legal (U n) (V n) (Z0 n) (w n) (M n) ∧ ¬succeeds n b + · obtain ⟨b,hb,hf⟩ := he + exact ⟨b,hb,fun _=>hf⟩ + · let Δ : ℝ := max 1 (4*(M n:ℝ)*(2^m*∏ j,U n j)) + refine ⟨⟨U n,fun _=>1,Z0 n,Δ,Δ,0⟩,?_,fun hh=>(he hh).elim⟩ + refine ⟨fun j=>⟨le_refl _,hUV n j⟩,le_refl _,?_,?_,?_,le_refl _,?_⟩ + · intro j + simp + · exact zero_lt_one.trans_le (le_max_left _ _) + · exact zero_lt_one.trans_le (le_max_left _ _) + · exact le_max_right _ _ + choose b hb hfail using hchoice + have hS : ∀ j,Tendsto (fun n=>(b n).S j) atTop atTop := fun j=> + tendsto_atTop_mono (fun n=>(hb n).1 j |>.1) (hU j) + have hV : ∀ j,Tendsto (fun n=>V n j) atTop atTop := fun j=> + tendsto_atTop_mono (fun n=>hUV n j) (hU j) + have hspos := totalScale_pos_eventually (fun n=>(b n).S) hS + have hvpos := totalScale_pos_eventually V hV + have hzsmall := domination_smaller (S:=fun _=>1) + (by filter_upwards [] with n; norm_num) hvpos hZ + have hz0 : Tendsto Z0 atTop atTop := by + simpa using hzsmall 1 zero_lt_one + have hZs : ∀ a : ℝ,0(b n).Z/(1+∑ j,(b n).S j)^a) atTop atTop := by + have hh := domination_smaller (S:=fun n=>totalScale (b n).S) + (by filter_upwards [hspos] with n hn; linarith) + (by filter_upwards [] with n + dsimp [totalScale] + have hh := Finset.sum_le_sum (s:=Finset.univ) (fun j _=>(hb n).1 j |>.2) + linarith) hZ + intro a ha + apply tendsto_atTop_mono' atTop ?_ (hh a ha) + filter_upwards [hspos] with n hn + exact div_le_div_of_nonneg_right (hb n).2.1 (Real.rpow_nonneg (by linarith) _) + have hHsmall : Tendsto (fun n=>H n/(b n).Z) atTop (𝓝 0) := by + apply squeeze_zero' ?_ ?_ hHZ + · filter_upwards [hz0.eventually (eventually_gt_atTop 0)] with n hn + exact div_nonneg (hH n) (hn.le.trans (hb n).2.1) + · filter_upwards [hz0.eventually (eventually_gt_atTop 0)] with n hn + exact div_le_div_of_nonneg_left (hH n) hn (hb n).2.1 + have hSL : ∀ j,Tendsto (fun n=>(b n).S j/(L n:ℝ)) atTop atTop := by + intro j + apply tendsto_atTop_mono (fun n=>?_) (hUL j) + exact div_le_div_of_nonneg_right ((hb n).1 j).1 (by exact_mod_cast (hL n).le) + have hbin : ∀ᶠ n in atTop,0<(b n).Q ∧ 0<(b n).Δ ∧ (b n).Δ≤(b n).Q ∧ + 4*(M n:ℝ)*(2^m*∏ j,(b n).S j)≤(b n).Δ := by + filter_upwards [] with n + exact (hb n).2.2.2 + have hh := source_conditional_face_decay (Γ:=Γ) (c:=c) hsk hΓ htop m v D d hd + c₀ C₀ B K η hc₀ hC₀ hB hη w M (fun n=>(b n).S) (fun n=>(b n).Z) H + (fun n=>(b n).Q) (fun n=>(b n).Δ) (fun n=>(b n).a) + (fun n=>(b n).r) L hw hS hZs hH hHsmall hM hMs hL hsm hWL + (fun n=>(hb n).2.2.1) hSL hbin ε hε + filter_upwards [hh] with n hn + intro z hz + by_contra he + exact hfail n ⟨z,hz,he⟩ hn + +end RoughFaceShift +end +end + +section +noncomputable section +namespace HarmonicExposure +open RoughSamplingWeights RoughSourceExceptional RoughProductRemoval Finset +open scoped BigOperators + +def pivotFiber (X : ℕ) (Q Δ τ : ℝ) (a M : ℤ) : Finset ℕ := + (Ico X (X^2)).filter (fun p=> M∣(p:ℤ)-a ∧ Q≤τ*p ∧ τ*p(a+M*k).toNat) + · intro k hk + have hh := (mem_indices (Q/τ) ((Q+Δ)/τ) a M hMr k).mp hk + apply mem_filter.mpr + constructor + · apply mem_Ico.mpr + constructor + · have hh' := hlo.trans hh.1 + rw [←hnr k hk] at hh' + exact_mod_cast hh' + · have hh' := hh.2.trans_le hhi + rw [←hnr k hk] at hh' + exact_mod_cast hh' + · refine ⟨?_,?_,?_⟩ + · rw [hn k hk] + exact ⟨k,by ring⟩ + · rw [hnr k hk] + simpa only [mul_comm] using (div_le_iff₀ hτ).mp hh.1 + · rw [hnr k hk] + simpa only [mul_comm] using (lt_div_iff₀ hτ).mp hh.2 + · intro k hk l hl he + have hh := congrArg (fun n : ℕ=>(n:ℤ)) he + rw [hn k hk,hn l hl] at hh + nlinarith + · intro p hp + obtain ⟨hpx,hcond⟩ := mem_filter.mp hp + obtain ⟨k,hk⟩ := hcond.1 + have hpz : (p:ℤ)=a+M*k := by linarith + have hpr : (p:ℝ)=(a:ℝ)+(M:ℝ)*(k:ℝ) := by exact_mod_cast hpz + have hidx : k∈indices (Q/τ) ((Q+Δ)/τ) a M := by + rw [mem_indices _ _ _ _ hMr] + rw [←hpr] + constructor + · apply (div_le_iff₀ hτ).mpr + nlinarith [hcond.2.1] + · apply (lt_div_iff₀ hτ).mpr + nlinarith [hcond.2.2] + refine ⟨k,hidx,?_⟩ + rw [←hpz] + simp + · intro k hk + rw [hnr k hk] + +lemma residue_unit (W p : ℕ) (a M : ℤ) (hWM : (W:ℤ)∣M) + (ha : a.natAbs.Coprime W) (hp : M∣(p:ℤ)-a) : W.Coprime p := by + obtain ⟨b,hb⟩ := hWM + obtain ⟨k,hk⟩ := hp + have hc : IsCoprime a (W:ℤ) := Int.isCoprime_iff_nat_coprime.mpr (by simpa using ha) + have hd := hc.add_mul_left_left (b*k) + have he : a+(W:ℤ)*(b*k)=(p:ℤ) := by rw [hb] at hk; nlinarith + rw [he] at hd + have hh := Int.isCoprime_iff_nat_coprime.mp hd + simpa only [Int.natAbs_natCast] using hh.symm + +def rawFiberMass {m : ℕ} (T : Finset (Fin m→ℤ)) (X W : ℕ) + (Q Δ : ℝ) (a M : ℤ) : ℝ := + ∑ t∈T, (∏ j,(t j:ℝ)⁻¹) * + ∑ p∈pivotFiber X Q Δ (∏ j,(t j:ℝ)) a M, if W.Coprime p then (p:ℝ)⁻¹ else 0 + +theorem rawFiberMass_eq_exposed {m : ℕ} (T : Finset (Fin m→ℤ)) (X W : ℕ) + (Q Δ : ℝ) (a M : ℤ) (hM : 0 a) +def eval (p : ι →₀ ℝ) (f : ι → ℝ) : ℝ := p.sum (fun i a => a*f i) +def l1 (p : ι →₀ ℝ) : ℝ := p.sum (fun _ a => |a|) + +omit [DecidableEq ι] in +lemma mass_sub (p q : ι →₀ ℝ) : mass (p-q) = mass p-mass q := + Finsupp.sum_sub_index (fun _ _ _ => rfl) + +omit [DecidableEq ι] in +lemma eval_sub (p q : ι →₀ ℝ) (f : ι → ℝ) : eval (p-q) f = eval p f-eval q f := + Finsupp.sum_sub_index (fun _ _ _ => sub_mul _ _ _) + +omit [DecidableEq ι] in +lemma mass_nonneg (p : ι →₀ ℝ) (hp : ∀ i, 0 ≤ p i) : 0 ≤ mass p := + Finset.sum_nonneg (fun i _ => hp i) + +omit [DecidableEq ι] in +lemma eval_bound (p : ι →₀ ℝ) (f : ι → ℝ) {B : ℝ} (hf : ∀ i, |f i| ≤ B) : + |eval p f| ≤ l1 p * B := by + apply (Finset.abs_sum_le_sum_abs _ _).trans + calc + _ ≤ ∑ i ∈ p.support, |p i| * B := by + apply Finset.sum_le_sum + intro i _ + rw [abs_mul] + exact mul_le_mul_of_nonneg_left (hf i) (abs_nonneg _) + _ = _ := (Finset.sum_mul ..).symm + + + +theorem l1_le_twice_edge (p q : ι →₀ ℝ) (E : Finset ι) + (hp : ∀ i, 0 ≤ p i) (hq : ∀ i, 0 ≤ q i) (hm : mass q = mass p) + (hedge : ∀ i, i ∉ E → p i ≤ q i) : + l1 (q-p) ≤ 2 * ∑ i ∈ E, p i := by + let S := p.support ∪ q.support ∪ E + have hpS : p.support ⊆ S := fun i hi => Finset.mem_union_left _ (Finset.mem_union_left _ hi) + have hqS : q.support ⊆ S := fun i hi => Finset.mem_union_left _ (Finset.mem_union_right _ hi) + have hdS : (q-p).support ⊆ S := (Finsupp.support_sub ..).trans (by + intro i hi + rcases Finset.mem_union.mp hi with h|h + · exact hqS h + · exact hpS h) + have hmass : (∑ i ∈ S, (q i - p i)) = 0 := by + rw [Finset.sum_sub_distrib,← q.sum_of_support_subset hqS (fun _ a => a) (by simp), + ← p.sum_of_support_subset hpS (fun _ a => a) (by simp)] + exact sub_eq_zero.mpr hm + have hpoint (i : ι) : |q i-p i| ≤ q i-p i + 2*(if i ∈ E then p i else 0) := by + by_cases hi : i ∈ E + · simp only [hi,ite_true] + rw [abs_le] + constructor <;> linarith [hp i,hq i] + · simp only [hi,ite_false,mul_zero,add_zero] + exact le_of_eq (abs_of_nonneg (sub_nonneg.mpr (hedge i hi))) + rw [l1,(q-p).sum_of_support_subset hdS (fun _ a => |a|) (by simp)] + calc + _ ≤ ∑ i ∈ S, (q i-p i + 2*(if i ∈ E then p i else 0)) := by + apply Finset.sum_le_sum + intro i _ + exact hpoint i + _ = 2 * ∑ i ∈ E, p i := by + rw [Finset.sum_add_distrib,hmass,zero_add,← Finset.mul_sum] + congr 1 + rw [← Finset.sum_filter] + apply Finset.sum_congr + · ext i + simp only [Finset.mem_filter,Finset.mem_union,S] + tauto + · intro _ _; rfl + +end FiniteWeights + +def shift (h : ℤ) (p : ℤ →₀ ℝ) : ℤ →₀ ℝ := p.mapDomain (fun n => n+h) + +@[simp] lemma shift_apply (h n : ℤ) (p : ℤ →₀ ℝ) : shift h p n = p (n-h) := by + have hh := Finsupp.mapDomain_apply_of_injective (f := fun n : ℤ => n+h) + (fun a b hab => add_right_cancel hab) p (n-h) + simpa only [shift,sub_add_cancel] using hh + +@[simp] lemma mass_shift (h : ℤ) (p : ℤ →₀ ℝ) : mass (shift h p) = mass p := by + exact Finsupp.sum_mapDomain_index (fun _ => rfl) (fun _ _ _ => rfl) + +lemma eval_shift (h : ℤ) (p : ℤ →₀ ℝ) (f : ℤ → ℝ) : + eval (shift h p) f = eval p (fun n => f (n+h)) := by + exact Finsupp.sum_mapDomain_index (fun _ => zero_mul _) (fun _ _ _ => add_mul ..) + +@[simp] lemma shift_zero (p : ℤ →₀ ℝ) : shift 0 p = p := by ext n; simp +@[simp] lemma shift_shift (h k : ℤ) (p : ℤ →₀ ℝ) : shift h (shift k p) = shift (h+k) p := by + ext n + simp only [shift_apply] + congr 1 + ring + +lemma shift_sub (h : ℤ) (p q : ℤ →₀ ℝ) : shift h (p-q) = shift h p-shift h q := by + ext n + simp + +lemma l1_shift (h : ℤ) (p : ℤ →₀ ℝ) : l1 (shift h p) = l1 p := by + unfold l1 shift + rw [Finsupp.sum_mapDomain_index_inj (fun a b hab => add_right_cancel hab)] + + +def raw (X W : ℕ) : ℤ →₀ ℝ := by + classical + exact Finsupp.onFinset (Finset.Ico (X : ℤ) (X^2 : ℤ)) + (fun n => if (X : ℤ) ≤ n ∧ n < (X^2 : ℤ) ∧ IsCoprime n (W : ℤ) + then (n : ℝ)⁻¹ else 0) (by + intro n hn + split_ifs at hn with h + · exact Finset.mem_Ico.mpr ⟨h.1,h.2.1⟩ + · exact (hn rfl).elim) + +@[simp] lemma raw_apply (X W : ℕ) (n : ℤ) : raw X W n = + if (X : ℤ) ≤ n ∧ n < (X^2 : ℤ) ∧ IsCoprime n (W : ℤ) then (n : ℝ)⁻¹ else 0 := by + classical + rfl + +lemma raw_nonneg {X W : ℕ} (_hX : 0 < X) (n : ℤ) : 0 ≤ raw X W n := by + classical + rw [raw_apply] + split_ifs with h + · exact inv_nonneg.mpr (by exact_mod_cast le_trans (Int.natCast_nonneg _) h.1) + · exact le_rfl + +lemma raw_le_inv {X W : ℕ} (hX : 0 < X) (n : ℤ) : raw X W n ≤ (X : ℝ)⁻¹ := by + classical + rw [raw_apply] + split_ifs with h + · exact inv_anti₀ (by exact_mod_cast hX) (by exact_mod_cast h.1) + · positivity + +lemma raw_outside_lower {X W : ℕ} {n : ℤ} (hn : n < X) : raw X W n = 0 := by + classical + simp only [raw_apply,not_le.mpr hn,false_and,ite_false] + + + +lemma outside_edge {X W : ℕ} (hX : 0 < X) {h : ℤ} (hh : 0 ≤ h) (hW : (W : ℤ) ∣ h) + (n : ℤ) (hn : n ∉ Finset.Ico (X : ℤ) ((X : ℤ)+h)) : + raw X W n ≤ shift h (raw X W) n := by + classical + rw [shift_apply,raw_apply] + split_ifs with hgood + · have hnL : (X : ℤ)+h ≤ n := by + have := mt Finset.mem_Ico.mpr hn + omega + have hprev : (X : ℤ) ≤ n-h ∧ n-h < (X^2 : ℤ) ∧ IsCoprime (n-h) (W : ℤ) := by + obtain ⟨t,rfl⟩ := hW + refine ⟨by omega,by omega,?_⟩ + have hi := hgood.2.2.add_mul_right_left (-t) + rw [show n-(W : ℤ)*t = n+(-t)*(W : ℤ) by ring] + exact hi + rw [raw_apply,ite_eq_left hprev] + exact inv_anti₀ (by exact_mod_cast (show (0:ℤ) < n-h by omega)) (by exact_mod_cast (show n-h ≤ n by omega)) + · exact raw_nonneg hX _ + + +theorem raw_translation_nonneg {X W : ℕ} (hX : 0 < X) {h : ℤ} + (hh : 0 ≤ h) (hW : (W : ℤ) ∣ h) : + l1 (shift h (raw X W)-raw X W) ≤ 2 * (h : ℝ) / X := by + have hb := l1_le_twice_edge (raw X W) (shift h (raw X W)) + (Finset.Ico (X : ℤ) ((X : ℤ)+h)) (raw_nonneg hX) + (fun n => by simpa using raw_nonneg (W := W) hX (n-h)) (mass_shift ..) + (outside_edge hX hh hW) + have hs : (∑ n ∈ Finset.Ico (X : ℤ) ((X : ℤ)+h), raw X W n) ≤ + (h : ℝ) / X := by + apply (Finset.sum_le_sum (fun n _ => raw_le_inv hX n)).trans_eq + simp only [Finset.sum_const,nsmul_eq_mul,Int.card_Ico,add_sub_cancel_left] + rw [show (h.toNat : ℝ) = (h : ℝ) by exact_mod_cast Int.toNat_of_nonneg hh] + rw [div_eq_mul_inv] + simpa only [mul_div_assoc] using hb.trans (mul_le_mul_of_nonneg_left hs (by norm_num)) + +lemma l1_neg (p : ℤ →₀ ℝ) : l1 (-p) = l1 p := by + unfold l1 + rw [Finsupp.sum_neg_index (fun _ => abs_zero)] + simp only [abs_neg] + +lemma l1_sub_comm (p q : ℤ →₀ ℝ) : l1 (p-q) = l1 (q-p) := by + rw [← l1_neg,neg_sub] + +lemma l1_translation_neg (p : ℤ →₀ ℝ) (h : ℤ) : + l1 (shift (-h) p-p) = l1 (shift h p-p) := by + rw [← l1_shift h,shift_sub,shift_shift,add_neg_cancel,shift_zero,l1_sub_comm] + +theorem raw_translation {X W : ℕ} (hX : 0 < X) {h : ℤ} (hW : (W : ℤ) ∣ h) : + l1 (shift h (raw X W)-raw X W) ≤ 2 * |(h : ℝ)| / X := by + rcases le_total 0 h with hh|hh + · simpa only [abs_of_nonneg (show (0:ℝ) ≤ h by exact_mod_cast hh)] using + raw_translation_nonneg hX hh hW + · have hi := raw_translation_nonneg hX (neg_nonneg.mpr hh) (dvd_neg.mpr hW) + rw [l1_translation_neg] at hi + simpa only [Int.cast_neg,abs_of_nonpos (show (h : ℝ) ≤ 0 by exact_mod_cast hh)] using hi + +lemma sum_le_mass (p : ℤ →₀ ℝ) (hp : ∀ n, 0 ≤ p n) (E : Finset ℤ) : + (∑ n ∈ E, p n) ≤ mass p := by + rw [mass,p.sum_of_support_subset (Finset.subset_union_left (s₂ := E)) + (fun _ a => a) (by simp)] + exact Finset.sum_le_sum_of_subset_of_nonneg Finset.subset_union_right (fun n _ _ => hp n) + + + +theorem raw_mass_lower {X W : ℕ} (hW : 0 < W) (hX : 2*W+2 ≤ X) : + (2*(W : ℝ))⁻¹ ≤ mass (raw X W) := by + classical + have hX0 : 0 < X := by omega + let f : ℕ → ℤ := fun k => 1+(W : ℤ)*((X : ℤ)+k) + have hf : Function.Injective f := by + intro a b hab + have hWi : (W : ℤ) ≠ 0 := by exact_mod_cast hW.ne' + have hh : (a : ℤ) = b := by + apply add_left_cancel (a := (X : ℤ)) + apply mul_left_cancel₀ hWi + exact add_left_cancel hab + exact_mod_cast hh + have hwR : (0 : ℝ) < W := by exact_mod_cast hW + have hxR : (0 : ℝ) < X := by exact_mod_cast hX0 + have hpoint (k : ℕ) (hk : k ∈ Finset.range X) : + (2*(W : ℝ)*X)⁻¹ ≤ raw X W (f k) := by + have hkX := Finset.mem_range.mp hk + have hL : (X : ℤ) ≤ f k := by + dsimp [f] + have hi : (1:ℤ) ≤ W := by exact_mod_cast hW + have hj : (0:ℤ) ≤ k := Int.natCast_nonneg k + have hn : (0:ℤ) ≤ X := Int.natCast_nonneg X + nlinarith + have hU : f k ≤ 2*(W : ℤ)*X := by + dsimp [f] + have hi : (1:ℤ) ≤ W := by exact_mod_cast hW + have hj : (k : ℤ)+1 ≤ X := by exact_mod_cast hkX + nlinarith + have hUX : 2*(W : ℤ)*X < (X : ℤ)^2 := by + have hi : 2*(W : ℤ)+2 ≤ X := by exact_mod_cast hX + have hj : (0:ℤ) < X := by exact_mod_cast hX0 + nlinarith + have hc : IsCoprime (f k) (W : ℤ) := by + have hi := (isCoprime_one_left (x := (W : ℤ))).add_mul_right_left ((X : ℤ)+k) + simpa only [f,mul_comm] using hi + rw [raw_apply,ite_eq_left ⟨hL,hU.trans_lt hUX,hc⟩] + exact inv_anti₀ (by exact_mod_cast (show (0:ℤ) < f k by omega)) + (by exact_mod_cast hU) + calc + _ = (X : ℝ) * (2*(W : ℝ)*X)⁻¹ := by field_simp + _ = ∑ k ∈ Finset.range X, (2*(W : ℝ)*X)⁻¹ := by simp + _ ≤ ∑ k ∈ Finset.range X, raw X W (f k) := Finset.sum_le_sum hpoint + _ = ∑ n ∈ (Finset.range X).image f, raw X W n := + (Finset.sum_image (fun _ _ _ _ h => hf h)).symm + _ ≤ mass (raw X W) := sum_le_mass _ (raw_nonneg hX0) _ + + + +def law (X W : ℕ) : ℤ →₀ ℝ := (mass (raw X W))⁻¹ • raw X W + +lemma mass_smul (c : ℝ) (p : ℤ →₀ ℝ) : mass (c • p) = c * mass p := by + unfold mass + rw [Finsupp.sum_smul_index (fun _ => rfl)] + exact Finset.mul_sum .. |>.symm + +lemma l1_smul (c : ℝ) (p : ℤ →₀ ℝ) : l1 (c • p) = |c| * l1 p := by + unfold l1 + rw [Finsupp.sum_smul_index (fun _ => abs_zero)] + simp only [abs_mul] + exact Finset.mul_sum .. |>.symm + +lemma shift_smul (h : ℤ) (c : ℝ) (p : ℤ →₀ ℝ) : shift h (c • p) = c • shift h p := by + ext n + simp + +lemma mass_law {X W : ℕ} (hW : 0 < W) (hX : 2*W+2 ≤ X) : mass (law X W) = 1 := by + have hp : 0 < mass (raw X W) := + (inv_pos.mpr (by positivity : (0:ℝ) < 2*W)).trans_le (raw_mass_lower hW hX) + rw [law,mass_smul,inv_mul_cancel₀ hp.ne'] + + + +theorem law_translation {X W : ℕ} (hW : 0 < W) (hX : 2*W+2 ≤ X) + {h : ℤ} (hh : (W : ℤ) ∣ h) : + l1 (shift h (law X W)-law X W) ≤ 4*(W : ℝ)*|(h : ℝ)|/X := by + have hX0 : 0 < X := by omega + have hm := raw_mass_lower hW hX + have hp : 0 < mass (raw X W) := + (inv_pos.mpr (by positivity : (0:ℝ) < 2*W)).trans_le hm + have hinv : (mass (raw X W))⁻¹ ≤ 2*(W : ℝ) := by + have hi := inv_anti₀ (by positivity : (0:ℝ) < (2*(W : ℝ))⁻¹) hm + simpa only [inv_inv] using hi + rw [law,shift_smul,← smul_sub,l1_smul,abs_of_pos (inv_pos.mpr hp)] + calc + _ ≤ (2*(W : ℝ)) * (2*|(h : ℝ)|/X) := + mul_le_mul hinv (raw_translation hX0 hh) (Finset.sum_nonneg (fun _ _ => abs_nonneg _)) + (by positivity) + _ = _ := by ring + +end +end HarmonicTranslation + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SumProduct/Alignment/HierarchyRates01.lean b/lean/OAI/Combinatorics/SumProduct/Alignment/HierarchyRates01.lean new file mode 100644 index 0000000000000000000000000000000000000000..bf59843519891ca596bd4d1f766301c1e285976a --- /dev/null +++ b/lean/OAI/Combinatorics/SumProduct/Alignment/HierarchyRates01.lean @@ -0,0 +1,311 @@ +import Mathlib +import OAI.Combinatorics.SumProduct.Alignment.IntegerArrays15 +import OAI.Combinatorics.SumProduct.Alignment.PivotExtension02 +import OAI.Geometry.NilpotentCharts.Main + +namespace OAI + +open scoped BigOperators +section +noncomputable section +open scoped BigOperators BoundedContinuousFunction Topology NNReal ENNReal +end + + + + + + + +noncomputable section +open Filter +open scoped Topology +namespace SourceHierarchyRates +open MicrocellScale AdmissibleMicrocellBoundary + + + +lemma source_modulus_size (M W w : ℕ) (hM : 0 < M) (hW : 0 < W) + (hdiv : W^w ∣ M) : + 0 < (M : ℤ)*(W : ℤ)^w ∧ ((M : ℤ)*(W : ℤ)^w : ℝ) ≤ (M : ℝ)^2 := by + have hp : 0 < W^w := pow_pos hW _ + have hb : W^w ≤ M := Nat.le_of_dvd hM hdiv + constructor + · exact mul_pos (by exact_mod_cast hM) (by positivity) + · have hbr : (W : ℝ)^w ≤ M := by exact_mod_cast hb + push_cast + nlinarith [Nat.cast_nonneg (α := ℝ) M] + +variable {M P H X W : ℕ → ℕ} + +lemma earlier_dominates_modulus (hM : ∀ N, 0 < M N) + (hd : Dominates (fun N => (H N : ℝ)) (earlierScale M P)) (k : ℕ) (hk : 0 < k) : + Tendsto (fun N => (M N : ℝ)^k/(H N : ℝ)) atTop (𝓝 0) := by + have hh : Tendsto (fun N => (earlierScale M P N)^k/(H N : ℝ)) atTop (𝓝 0) := by + simpa only [Function.comp_def, inv_div, Real.rpow_natCast] using + tendsto_inv_atTop_zero.comp (hd (k : ℝ) (by exact_mod_cast hk)) + apply squeeze_zero (fun N => by positivity) (fun N => ?_) hh + apply div_le_div_of_nonneg_right _ (by positivity) + apply pow_le_pow_left₀ (by exact_mod_cast (hM N).le) + unfold earlierScale + linarith [Nat.cast_nonneg (α := ℝ) (P N)] + +lemma eventually_height_ge_modulus_sq + (hd : Dominates (fun N => (H N : ℝ)) (earlierScale M P)) : + ∀ᶠ N in atTop, (M N : ℝ)^2 ≤ H N := by + filter_upwards [(hd 2 (by norm_num)).eventually_ge_atTop 1] with N hn + rw [Real.rpow_two] at hn + have hs : 0 < earlierScale M P N := by + unfold earlierScale + positivity + have hm : (M N : ℝ) ≤ earlierScale M P N := by + unfold earlierScale + linarith [Nat.cast_nonneg (α := ℝ) (P N)] + have hh := (le_div_iff₀ (sq_pos_of_pos hs)).mp hn + nlinarith [Nat.cast_nonneg (α := ℝ) (M N)] + + + +lemma eventually_interval_four_modulus (hM : ∀ N, 0 < M N) + (hH : ∀ N, 0 < H N) (hX : ∀ N, 0 < X N) + (hWM : ∀ N, W N ≤ M N) + (hd : Dominates (fun N => (H N : ℝ)) (earlierScale M P)) + (hx : Dominates (fun N => Real.log (X N : ℝ)) (fun N => (H N : ℝ))) : + ∀ᶠ N in atTop, 4*W N ≤ X N := by + have hl : Tendsto (fun N => Real.log (X N : ℝ)/(H N : ℝ)) atTop atTop := by + simpa only [Real.rpow_one] using hx 1 zero_lt_one + filter_upwards [eventually_height_ge_modulus_sq hd, hl.eventually_ge_atTop 4] with N hMN hn + have hm : (1 : ℝ) ≤ M N := by exact_mod_cast hM N + have hh : (0 : ℝ) < H N := by exact_mod_cast hH N + have hw : (W N : ℝ) ≤ M N := by exact_mod_cast hWM N + have hlog : Real.log (X N : ℝ) ≤ X N := Real.log_le_self (by exact_mod_cast (hX N).le) + have hi := (le_div_iff₀ hh).mp hn + have hhX : (4 : ℝ)*W N ≤ X N := by nlinarith + exact_mod_cast hhX + +lemma raw_interval_tendsto (hH : ∀ N, 0 < H N) (hX : ∀ N, 0 < X N) + (hx : Dominates (fun N => Real.log (X N : ℝ)) (fun N => (H N : ℝ))) : + Tendsto X atTop atTop := by + have hl : Tendsto (fun N => Real.log (X N : ℝ)/(H N : ℝ)) atTop atTop := by + simpa only [Real.rpow_one] using hx 1 zero_lt_one + apply (tendsto_natCast_atTop_iff (R := ℝ)).mp + apply tendsto_atTop_mono' atTop _ hl + apply Eventually.of_forall + intro N + have hh : (1 : ℝ) ≤ H N := by exact_mod_cast hH N + calc + Real.log (X N : ℝ)/(H N : ℝ) ≤ (X N : ℝ)/(H N : ℝ) := + div_le_div_of_nonneg_right (Real.log_le_self (by exact_mod_cast (hX N).le)) (by positivity) + _ ≤ X N := div_le_self (by positivity) hh + +lemma raw_over_modulus_tendsto (hH : ∀ N, 0 < H N) (hX : ∀ N, 0 < X N) + (L : ℕ → ℤ) (hL : ∀ N, 0 < L N) (hLM : ∀ N, (L N : ℝ) ≤ (M N : ℝ)^2) + (hd : Dominates (fun N => (H N : ℝ)) (earlierScale M P)) + (hx : Dominates (fun N => Real.log (X N : ℝ)) (fun N => (H N : ℝ))) : + Tendsto (fun N => (X N : ℝ)/(L N : ℝ)) atTop atTop := by + have hl : Tendsto (fun N => Real.log (X N : ℝ)/(H N : ℝ)) atTop atTop := by + simpa only [Real.rpow_one] using hx 1 zero_lt_one + apply tendsto_atTop_mono' atTop _ hl + filter_upwards [eventually_height_ge_modulus_sq hd] with N hMH + calc + Real.log (X N : ℝ)/(H N : ℝ) ≤ (X N : ℝ)/(H N : ℝ) := + div_le_div_of_nonneg_right (Real.log_le_self (by exact_mod_cast (hX N).le)) + (by exact_mod_cast (hH N).le) + _ ≤ (X N : ℝ)/(L N : ℝ) := div_le_div_of_nonneg_left (by positivity) + (by exact_mod_cast hL N) ((hLM N).trans hMH) + + + +theorem source_translation_error (hM : ∀ N, 0 < M N) + (hH : ∀ N, 0 < H N) (hX : ∀ N, 0 < X N) (hWM : ∀ N, W N ≤ M N) + (L : ℕ → ℤ) (hL : ∀ N, 0 ≤ L N) (hLM : ∀ N, (L N : ℝ) ≤ (M N : ℝ)^2) + (hd : Dominates (fun N => (H N : ℝ)) (earlierScale M P)) + (hx : Dominates (fun N => Real.log (X N : ℝ)) (fun N => (H N : ℝ))) (K : ℝ) : + Tendsto (fun N => 4*(W N : ℝ)*K*(L N : ℝ)/(X N : ℝ)) atTop (𝓝 0) := by + have hl : Tendsto (fun N => Real.log (X N : ℝ)/(H N : ℝ)) atTop atTop := by + simpa only [Real.rpow_one] using hx 1 zero_lt_one + have hHX : ∀ᶠ N in atTop, (H N : ℝ) ≤ X N := by + filter_upwards [hl.eventually_ge_atTop 1] with N hn + have hh : (0 : ℝ) < H N := by exact_mod_cast hH N + have he := (le_div_iff₀ hh).mp hn + have hlog := Real.log_le_self (show (0 : ℝ) ≤ X N by exact_mod_cast (hX N).le) + linarith + have hb : Tendsto (fun N => (W N : ℝ)*(L N : ℝ)/(X N : ℝ)) atTop (𝓝 0) := by + apply squeeze_zero' (Eventually.of_forall (fun N => + div_nonneg (mul_nonneg (by positivity) (by exact_mod_cast hL N)) (by positivity))) ?_ + (earlier_dominates_modulus hM hd 3 (by norm_num)) + filter_upwards [hHX] with N hn + have hm : (0 : ℝ) ≤ M N := by positivity + have hw : (W N : ℝ) ≤ M N := by exact_mod_cast hWM N + have hLn : (0 : ℝ) ≤ L N := by exact_mod_cast hL N + have hbound : (W N : ℝ)*(L N : ℝ) ≤ (M N : ℝ)^3 := by + calc + _ ≤ (M N : ℝ)*(M N : ℝ)^2 := mul_le_mul hw (hLM N) hLn hm + _ = _ := by ring + calc + _ ≤ (M N : ℝ)^3/(X N : ℝ) := div_le_div_of_nonneg_right hbound (by positivity) + _ ≤ (M N : ℝ)^3/(H N : ℝ) := div_le_div_of_nonneg_left (by positivity) + (by exact_mod_cast hH N) hn + convert hb.const_mul (4*K) using 1 <;> try simp + funext N + ring + +end SourceHierarchyRates +end + + + + + + + +noncomputable section +open scoped BigOperators BoundedContinuousFunction Topology NNReal ENNReal +namespace SourceIntegerArrays.GlobalJoint.SourceFrozenFamily +open ProductExposureLabels ProductExposureLaw SourceExposureSlots SourceResidueAlignment +open ConstructedWordPlan.GlobalWordPlan ConstructedWordPlan.AlignmentScales +open ConstructedWordPlan.RationalPivotPlan +open ConstructedWordPlan.GlobalWordPlan.SourceTerminalArithmetic +open RawHarmonicProbability +attribute [local instance] Classical.propDecidable +variable {a : ℕ} (D : Pivot a) + +variable (s r : ℕ) (hs : 1 ≤ s) (Fs : Finset (Scale a)) (q₀ : ℕ) (b₀ : Scale a) +local notation "I" => FiniteModelSlots.Index D s r hs Fs q₀ b₀ + +open Filter MeasureTheory RationalLattice MalcevCharacters +open MicrocellScale AdmissibleMicrocellBoundary RoughScales IntegerAlignment +open RoughSamplingWeights SourceMacroSelection + +section Harmonic +variable (G₀ : Fin D.targets → ℚ → Fin r → Type) +variable [∀ t v c, Group (G₀ t v c)] [∀ t v c, TopologicalSpace (G₀ t v c)] +variable [∀ t v c, IsTopologicalGroup (G₀ t v c)] +variable (Γ₀ : ∀ t v c, Subgroup (G₀ t v c)) +variable (n₀ : Fin D.targets → ℚ → Fin r → ℕ) +variable (c₀ : ∀ t v c, RealCoordinates (G₀ t v c) (n₀ t v c)) +variable (hsk : ∀ t v c, SecondKind (c₀ t v c)) +variable (A₀ : ∀ t v c, CubeFaces.Filtration (G₀ t v c)) +variable (weight : ∀ t v c, Fin (n₀ t v c) → ℕ) +variable (hA : ∀ t v c k (g : G₀ t v c), g ∈ (A₀ t v c).level k ↔ + ∀ j, weight t v c j < k → (c₀ t v c).coord g j = 0) +variable (hw : ∀ t v c j, 0 < weight t v c j) +include hsk hA hw + +theorem source_uniform_extension + (hΓ : ∀ t v c g, g ∈ Γ₀ t v c ↔ ∀ j, ∃ z : ℤ, (c₀ t v c).coord g j = z) + (hmono : ∀ t v c, Monotone (weight t v c)) + (h0 : ∀ t v c, (A₀ t v c).level 0 = ⊤) + (h1 : ∀ t v c, (A₀ t v c).level 1 = ⊤) + (hstep : ∀ t v c, (A₀ t v c).level (s+1) = ⊥) + (M J R H : ℕ → ℕ) (L : ℕ → ℤ) (ht : ℕ → Fin a → ℤ) + (g₀ x₀ : ∀ t, ℕ → (Fin (h D t) → ℕ) → ∀ v c, ℤ → ℤ → G₀ t v c) + (obs₀ : ∀ t, ℕ → (Fin (h D t) → ℕ) → ∀ v c, ℤ → ℤ → ((G₀ t v c) ⧸ Γ₀ t v c) →ᵇ ℝ) + (w0 Xp : ℕ → ℕ) (X : ℕ → Fin a → ℕ) + (hw0 : Tendsto w0 atTop atTop) + (hX : ∀ N j, 4*primorial (w0 N) ≤ X N j) + (hXp : ∀ N, 4*primorial (w0 N) ≤ Xp N) + (hXt : ∀ j, Tendsto (fun N => X N j) atTop atTop) + (hXpt : Tendsto Xp atTop atTop) + (hWM : ∀ N, (primorial (w0 N) : ℤ) ∣ (M N : ℤ)) + (hM : ∀ N, 0 < M N) (hMs : ∀ N, RoughScales.Smooth (w0 N) (M N : ℤ)) + (hJ : ∀ N, 0 < J N) (hRJ : ∀ N, R N = M N*J N) + (hL : ∀ N, 0 < L N) (hsm : ∀ N, RoughScales.Smooth (w0 N) (L N)) + (hWL : ∀ N, (primorial (w0 N) : ℤ) ∣ L N) (hML : ∀ N, (M N : ℤ) ∣ L N) + (hLexact : ∀ N, L N = (M N : ℤ)*(primorial (w0 N) : ℤ)^(w0 N)) + (hXL : ∀ t (j : Fin (m D t)), Tendsto (fun N => + (X N (perm D t (j.castAdd (h D t))) : ℝ)/(L N : ℝ)) atTop atTop) + (hH : ∀ N, 0 < H N) (hRrad : ∀ N, R N = radius (M N) (H N)) + (hdom : Dominates (fun N => (H N : ℝ)) (earlierScale M (fun N => previousProduct D (X N)))) + (hxdom : Dominates (fun N => Real.log (Xp N : ℝ)) (fun N => (H N : ℝ))) + (hpowWM : ∀ N, primorial (w0 N)^(w0 N) ∣ M N) + (hq₀ : 0 < q₀) (hht : ∀ N j, 0 < ht N j) + (hheight : ∀ N e, height (ht N) (D.added e) ≤ M N) + (hd : ∀ e, Disjoint (D.added e) (D.tail (D.owner e))) + (hQq : terminalDenom D s r hs Fs b₀ ∣ q₀) + (hb₀ : ∀ j, 0 < b₀ j) (hFs : ∀ b ∈ Fs, ∀ j, 0 < b j) + (hratio : ∀ N e, ∃ d : ℤ, height (ht N) (D.added e) = + height (ht N) (block D.index D.tail (D.owner e)) * ((primorial (w0 N) : ℤ)^(w0 N) * d)) + (metric : ∀ t v c, MetricSpace ((G₀ t v c) ⧸ Γ₀ t v c)) + (hmetric : ∀ t v c, QuotientGroup.instTopologicalSpace (Γ₀ t v c) = + (metric t v c).toUniformSpace.toTopologicalSpace) : + letI : ∀ t v c, MetricSpace ((G₀ t v c) ⧸ Γ₀ t v c) := + fun t v c => (metric t v c).replaceTopology (hmetric t v c) + ∀ (Kobs : ℝ≥0) (Bobs : ℝ), + (∀ t N y v c b r', LipschitzWith Kobs (obs₀ t N y v c b r')) → + (∀ t N y v c b r' z, |obs₀ t N y v c b r' z| ≤ Bobs) → + ∀ (Bs : Finset (Scale a)), b₀ ∈ Bs → + pivotModulus s r hs D Fs Bs ∣ q₀ → ∀ (τ : ℝ), 0 < τ → + ∀ ε : ℝ, 0 < ε → ∀ᶠ N in atTop, ∀ E : Set (Fin a → ℕ), + let μ := jointLaw (X N) (Xp N) (primorial (w0 N)) (primorial_pos _) (hX N) (hXp N) + (((pivotOptions s r hs D Fs).card : ℝ)⁻¹/3)*μ.real {z | z.1 ∈ E} ≤ + (slotCount D s r hs Fs q₀ b₀ : ℝ)*μ.real {z | z.1 ∈ E ∧ + pivotProperty D s r hs Fs b₀ G₀ Γ₀ M H g₀ x₀ obs₀ ht N z.1 z.2 τ} + ε := by + let : ∀ t v c, MetricSpace ((G₀ t v c) ⧸ Γ₀ t v c) := + fun t v c => (metric t v c).replaceTopology (hmetric t v c) + intro Kobs Bobs hLip hBound Bs hb hq τ hτ ε hε + let c : ℝ := ((pivotOptions s r hs D Fs).card : ℝ)⁻¹/3 + let V : ℝ := slotCount D s r hs Fs q₀ b₀ + let μ := fun N => jointLaw (X N) (Xp N) (primorial (w0 N)) (primorial_pos _) (hX N) (hXp N) + let d := family D s r hs Fs q₀ b₀ G₀ Γ₀ M J R H L (heightCoeff D q₀ ht) g₀ x₀ obs₀ + let bad := fun N => {z | cellRatio (Xp N) (primorial (w0 N)) (M N) (J N) z.2 + (primorial_pos _) (hXp N) {k | ((d.atTime N).localModel z).modelSuccess (coord D) + (k : ℤ) s r hs (FiniteModelSlots.formula D s r hs Fs q₀ b₀) Fs q₀ b₀ τ} ≤ c} + let err := fun N => 4*(primorial (w0 N) : ℝ)*(slotBudget D s r hs Fs q₀ b₀ : ℝ)*(L N : ℝ)/(Xp N : ℝ) + have hLsize : ∀ N, (L N : ℝ) ≤ (M N : ℝ)^2 := by + intro N + rw [hLexact N] + simpa only [Int.cast_mul, Int.cast_pow] using (SourceHierarchyRates.source_modulus_size (M N) (primorial (w0 N)) (w0 N) + (hM N) (primorial_pos _) (hpowWM N)).2 + have hbad : Tendsto (fun N => μ N (bad N)) atTop (𝓝 0) := + source_actual_harmonic D s r hs Fs q₀ b₀ G₀ Γ₀ n₀ c₀ hsk A₀ weight hA hw + hΓ hmono h0 h1 hstep M J R H L ht g₀ x₀ obs₀ w0 Xp X hw0 hX hXp hXt hXpt + hWM hM hMs hJ hRJ hL hsm hWL hML hLexact hXL hH hRrad hdom hxdom + (Eventually.of_forall hLsize) hq₀ hht hheight hd metric hmetric + Kobs Bobs hLip hBound Bs hb hq τ hτ + have hbadR : Tendsto (fun N => (μ N).real (bad N)) atTop (𝓝 0) := by + simpa only [measureReal_def, ENNReal.toReal_zero, Function.comp_def] using + (ENNReal.tendsto_toReal (by simp : (0 : ℝ≥0∞) ≠ ⊤)).comp hbad + have hp : ∀ N, 0 < Xp N := by + intro N + have := hXp N + have := primorial_pos (w0 N) + omega + have hWMle : ∀ N, primorial (w0 N) ≤ M N := by + intro N + exact Nat.le_of_dvd (hM N) (Int.natCast_dvd_natCast.mp (hWM N)) + have herr : Tendsto err atTop (𝓝 0) := + SourceHierarchyRates.source_translation_error hM hH hp hWMle L + (fun N => (hL N).le) hLsize hdom hxdom (slotBudget D s r hs Fs q₀ b₀ : ℝ) + have htotal : Tendsto (fun N => c*(μ N).real (bad N)+V*err N) atTop (𝓝 0) := by + simpa using (hbadR.const_mul c).add (herr.const_mul V) + have hXLp : Tendsto (fun N => (Xp N : ℝ)/(L N : ℝ)) atTop atTop := + SourceHierarchyRates.raw_over_modulus_tendsto hH hp L hL hLsize hdom hxdom + have hlarge : ∀ᶠ N in atTop, + slotBudget D s r hs Fs q₀ b₀*L N < (Xp N : ℤ) := by + filter_upwards [hXLp.eventually_gt_atTop (slotBudget D s r hs Fs q₀ b₀ : ℝ)] with N hN + have hl : (0 : ℝ) < L N := by exact_mod_cast hL N + have hh := (lt_div_iff₀ hl).mp hN + exact_mod_cast hh + filter_upwards [htotal.eventually_lt_const hε, hlarge, + hw0.eventually_ge_atTop (q₀+1)] with N hN hlargeN hwN + intro E + have hc : 0 ≤ c := by dsimp [c]; positivity + have he := source_actual_extension D s r hs Fs q₀ b₀ G₀ Γ₀ M J R H L + g₀ x₀ obs₀ ht N (w0 N) (X N) (Xp N) (primorial_pos _) (hX N) (hXp N) + (hM N) (hJ N) hq₀ hQq hwN (hL N) (hsm N) (hWL N) (hML N) + hd hb₀ hFs (hht N) (hratio N) hlargeN τ c hc E + change c*((μ N).real {z | z.1 ∈ E}-(μ N).real (bad N)) ≤ + V*((μ N).real {z | z.1 ∈ E ∧ pivotProperty D s r hs Fs b₀ G₀ Γ₀ M H + g₀ x₀ obs₀ ht N z.1 z.2 τ}+err N) at he + change c*(μ N).real {z | z.1 ∈ E} ≤ V*(μ N).real {z | z.1 ∈ E ∧ + pivotProperty D s r hs Fs b₀ G₀ Γ₀ M H g₀ x₀ obs₀ ht N z.1 z.2 τ}+ε + nlinarith + +end Harmonic +end SourceIntegerArrays.GlobalJoint.SourceFrozenFamily + +end +end + +end OAI diff --git a/lean/OAI/Combinatorics/SumProduct/Alignment/IntegerAlignment01.lean b/lean/OAI/Combinatorics/SumProduct/Alignment/IntegerAlignment01.lean new file mode 100644 index 0000000000000000000000000000000000000000..455c441d6f81d232002edeb67c6fa8f1369b0490 --- /dev/null +++ b/lean/OAI/Combinatorics/SumProduct/Alignment/IntegerAlignment01.lean @@ -0,0 +1,305 @@ +import Mathlib +import OAI.Combinatorics.SumProduct.Alignment.RoughArray03 +import OAI.Geometry.NilpotentCharts.Main + +namespace OAI + +noncomputable section +end + +noncomputable section +namespace RoughArrayFace +open RationalLattice MalcevCharacters RoughFaceShift RoughTopologicalFace RoughArrayCoordinates +open RoughScales RoughSamplingWeights FinitePieceAverages RoughSourceExceptional RoughProductRemoval +open ProductExposureLabels ProductExposureLaw ProductExposureCutoff MeasureTheory Filter +open scoped BigOperators Topology +attribute [local instance] Classical.propDecidable +variable {ι : Type} [Fintype ι] (G : ι→Type) [∀ i,Group (G i)] +variable [∀ i,TopologicalSpace (G i)] [∀ i,IsTopologicalGroup (G i)] +variable (n : ι→ℕ) (q : ℕ) (c : ∀ i,RealCoordinates (G i) (n i)) +variable (hsk : ∀ i,SecondKind (c i)) (A : ∀ i,CubeFaces.Filtration (G i)) +variable (w : ∀ i,Fin (n i)→ℕ) +variable (hA : ∀ i k (g : G i),g∈(A i).level k ↔ ∀ j,w i jX N j) atTop atTop) (hXpt : Tendsto Xp atTop atTop) + (hR : ∀ N,0R N/(Xp N:ℝ)) atTop (𝓝 0)) + (hZ : ∀ a : ℝ,0(R N/(M N:ℝ))/ + (1+∑ j,(X N j:ℝ)^2)^a) atTop atTop) + (hH : ∀ N,0≤H N) (hHZ : Tendsto (fun N=>H N/(R N/(M N:ℝ))) atTop (𝓝 0)) + (hWM : ∀ N,(primorial (w0 N):ℤ)∣(M N:ℤ)) + (hM : ∀ N,0(X N j:ℝ)/(L N:ℝ)) atTop atTop) + (pattern : ι→Fin (v+1)→ℤ) (e : Fin q) (j : Fin (v+1)) + (g x : ℕ→Label m→∀ i,G i) (b0 b1 : ℕ→Label m→ι→ℝ) + (a0 a1 : ℕ→Label m→Fin q→ℝ) + (δ : ℕ→Label m→(Fin m→ℤ)→ℤ) + (hδ : ∀ N b,b∈(fullDomain (X N) (Xp N) (primorial (w0 N))).image + (expose (L N) (M N:ℤ) (R N)) → Good (X N) (Xp N) (R N) b → + ∀ t∈productTimes b.scales b.residue (L N), + (δ N b t:ℝ)=a0 N b e+a1 N b e*∏ l,(t l:ℝ) ∧ + (d:ℤ)∣δ N b t ∧ |(δ N b t:ℝ)|≤H N) : + Tendsto (fun N=>(jointLaw (X N) (Xp N) (primorial (w0 N)) (primorial_pos _) + (hX N) (hXp N)).real (rawPhysicalEvent (lattice G n q c hsk A w hA Γ) m v c₀ C₀ B η (R N) d (M N) (L N) + (fun b=>actualData G n q c hsk A w hA hw Γ pattern (g N b) (x N b) + (b0 N b) (b1 N b) (a0 N b) (a1 N b) e j (coarseOrigin v (M N) (R N) b) (δ N b)))) + atTop (𝓝 0) + := by + let C' : ℝ:=(2:ℝ)^m+2+C₀*2^m + let F : ℕ→Label m→FaceData m (v+1) (Carrier G n q c hsk A w hA) + (lattice G n q c hsk A w hA Γ) := fun N b=> + actualData G n q c hsk A w hA hw Γ pattern (g N b) (x N b) + (b0 N b) (b1 N b) (a0 N b) (a1 N b) e j (coarseOrigin v (M N) (R N) b) (δ N b) + have hC' : 0coarseOrigin v (M N) (R N) b) δ hδ + have hMr (N : ℕ) : (0:ℝ)R N/(M N:ℝ)) atTop atTop := by + apply tendsto_atTop_mono (fun N=>?_) (hZ 1 (by norm_num)) + rw [Real.rpow_one] + exact div_le_self (div_nonneg (hR N).le (hMr N).le) + (by have:=Finset.sum_nonneg (fun j (_ : j∈Finset.univ)=>sq_nonneg (X N j:ℝ));linarith) + apply squeeze_zero' (Eventually.of_forall (fun _=>measureReal_nonneg)) ?_ hraw + filter_upwards [hw0.eventually (eventually_ge_atTop d),hZtop.eventually (eventually_ge_atTop 1)] + with N hdw hRM + change (jointLaw (X N) (Xp N) (primorial (w0 N)) (primorial_pos _) (hX N) (hXp N)).real + (rawPhysicalEvent (lattice G n q c hsk A w hA Γ) m v c₀ C₀ B η (R N) d (M N) (L N) (F N))≤_ + rw [←joint_restrict_fullDomain (X N) (Xp N) (primorial (w0 N)) (primorial_pos _) (hX N) (hXp N)] + refine measureReal_mono ?_ (by finiteness) + exact rawPhysical_subset (lattice G n q c hsk A w hA Γ) m v (w0 N) (M N) d hd hdw + (X N) (Xp N) (fun l=>by have:=hX N l;have:=primorial_pos (w0 N);omega) + (hM N) (hMs N) (R N) (hR N) hRM (L N) (hML N) c₀ C₀ hc₀.le hC₀.le B η (F N) + (fun _=>rfl) + +end RoughArrayFace +end + + + +open scoped BigOperators +namespace IntegerAlignment + + +lemma fixed_dvd_primorial_pow {n w k : ℕ} (hn : 0 < n) (hnw : n ≤ w) (hnk : n ≤ k) : + n ∣ primorial w ^ k := by + have hW : primorial w ≠ 0 := (primorial_pos w).ne' + have h : n ∣ primorial w ^ n := by + apply (Nat.dvd_pow_self_iff hn.ne' hW).mpr + intro p hp + obtain ⟨hpp,hpn,_⟩ := Nat.mem_primeFactors.mp hp + exact Nat.mem_primeFactors.mpr ⟨hpp, + hpp.dvd_primorial_iff.mpr ((Nat.le_of_dvd hn hpn).trans hnw),hW⟩ + exact h.trans (pow_dvd_pow _ hnk) + + +lemma fixed_mul_primorial_dvd {n w : ℕ} (hn : 0 < n) (hw : n + 1 ≤ w) : + n * primorial w ∣ primorial w ^ w := by + have h := fixed_dvd_primorial_pow hn (by omega : n ≤ w) (by omega : n ≤ w - 1) + have h' := mul_dvd_mul_right h (primorial w) + simpa [← pow_succ, show w - 1 + 1 = w by omega] using h' + + +lemma finite_absorption (S : Finset ℕ) (hS : ∀ n ∈ S, 0 < n) : + ∃ w₀ : ℕ, ∀ w ≥ w₀, ∀ n ∈ S, n * primorial w ∣ primorial w ^ w := by + refine ⟨S.sup id + 1,?_⟩ + intro w hw n hn + exact fixed_mul_primorial_dvd (hS n hn) (by + have := Finset.le_sup (f := id) hn + simp only [id_eq] at this + omega) + +def Smooth (w : ℕ) (b : ℤ) : Prop := ∀ p : ℕ, p.Prime → (p : ℤ) ∣ b → p ≤ w + +def Rough (w : ℕ) (t : ℤ) : Prop := ∀ p : ℕ, p.Prime → p ≤ w → ¬ (p : ℤ) ∣ t + +lemma coprime_smooth_rough {w : ℕ} {b t : ℤ} (hb : Smooth w b) (ht : Rough w t) : + IsCoprime b t := by + rw [Int.isCoprime_iff_nat_coprime] + apply Nat.coprime_of_dvd + intro p hp hpb hpt + exact ht p hp (hb p hp (Int.natCast_dvd.mpr hpb)) (Int.natCast_dvd.mpr hpt) + +lemma primorial_smooth (w : ℕ) : Smooth w (primorial w : ℤ) := by + intro p hp hpd + exact hp.dvd_primorial_iff.mp (by exact_mod_cast hpd) + +lemma coprime_modulus {w : ℕ} {M t : ℤ} (hM : Smooth w M) (ht : Rough w t) : + IsCoprime t (M * (primorial w : ℤ) ^ w) := by + exact (coprime_smooth_rough hM ht).symm.mul_right + (coprime_smooth_rough (primorial_smooth w) ht).symm.pow_right + + +lemma integral_translation {q₀ W H a : ℤ} (hq₀ : q₀ ≠ 0) + (hH : q₀ * W ∣ H) : + ∃ q : ℤ, (q : ℚ) = (H : ℚ) / q₀ * a ∧ W ∣ q := by + obtain ⟨b, rfl⟩ := hH + refine ⟨W * b * a,?_,dvd_mul_of_dvd_left (dvd_mul_right W b) a⟩ + have hq : (q₀ : ℚ) ≠ 0 := by exact_mod_cast hq₀ + push_cast + field_simp + + + +lemma residue_shift {M W t q : ℤ} {w : ℕ} (hM : 0 < M) (hW : 0 < W) + (hw : 1 ≤ w) (ht : IsCoprime t (M * W ^ w)) (hq : W ∣ q) : + ∃ r Δ : ℤ, 0 ≤ r ∧ r < M * W ^ w ∧ + t * r ≡ q [ZMOD M * W ^ w] ∧ + Δ = (q - t * r) / M ∧ W ∣ r ∧ W ^ w ∣ Δ ∧ + ∀ p m : ℤ, t * (p + m * r) + m * M * Δ = t * p + m * q := by + let L := M * W ^ w + have hL : 0 < L := mul_pos hM (pow_pos hW w) + obtain ⟨a,b,hab⟩ := ht + let r := (a * q) % L + have hc : t * r ≡ q [ZMOD L] := by + have h₁ : t * r ≡ t * (a * q) [ZMOD L] := (Int.mod_modEq _ _).mul_left t + apply h₁.trans + rw [Int.modEq_iff_dvd] + refine ⟨b * q,?_⟩ + change q - t * (a * q) = M * W ^ w * (b * q) + nlinarith [congrArg (fun x : ℤ => x * q) hab] + obtain ⟨k,hk⟩ := Int.modEq_iff_dvd.mp hc + have hWL : W ∣ L := (dvd_pow_self W (by omega : w ≠ 0)).trans (dvd_mul_left _ M) + have hWt : IsCoprime W t := (IsCoprime.of_isCoprime_of_dvd_right + (show IsCoprime t L from ⟨a,b,hab⟩) hWL).symm + have hWr : W ∣ r := by + apply hWt.dvd_of_dvd_mul_left + have hd : W ∣ q - t * r := hWL.trans (Int.modEq_iff_dvd.mp hc) + have := dvd_sub hq hd + simpa using this + refine ⟨r,W ^ w * k,Int.emod_nonneg _ hL.ne',Int.emod_lt_of_pos _ hL, + hc,?_,hWr,dvd_mul_right _ k,?_⟩ + · rw [hk] + change W ^ w * k = M * W ^ w * k / M + rw [mul_assoc,Int.mul_ediv_cancel_left _ hM.ne'] + · intro p m + change q - t * r = M * W ^ w * k at hk + nlinarith [congrArg (fun x : ℤ => m * x) hk] + + +lemma residue_unique {L t q r r' : ℤ} (_hL : 0 < L) (ht : IsCoprime t L) + (hr : 0 ≤ r) (hrL : r < L) (hr' : 0 ≤ r') (hrL' : r' < L) + (hc : t * r ≡ q [ZMOD L]) (hc' : t * r' ≡ q [ZMOD L]) : r = r' := by + have hd : L ∣ r' - r := by + apply ht.symm.dvd_of_dvd_mul_left + simpa only [mul_sub] using Int.modEq_iff_dvd.mp (hc.trans hc'.symm) + have hm := Int.modEq_iff_dvd.mpr hd + change r % L = r' % L at hm + simpa only [Int.emod_eq_of_lt hr hrL,Int.emod_eq_of_lt hr' hrL'] using hm + + + +lemma own_target_reading {E : Type*} (S : Finset E) (t p : ℤ) + (r Δ q m v : E → ℤ) (M : ℤ) + (hid : ∀ e ∈ S, q e - t * r e = M * Δ e) : + t * (p + ∑ e ∈ S, v e * r e + ∑ e ∈ S, m e * r e) + + M * ∑ e ∈ S, m e * Δ e = + t * (p + ∑ e ∈ S, v e * r e) + ∑ e ∈ S, m e * q e := by + have hs : ∑ e ∈ S, m e * q e = + t * ∑ e ∈ S, m e * r e + M * ∑ e ∈ S, m e * Δ e := by + rw [Finset.mul_sum,Finset.mul_sum,← Finset.sum_add_distrib] + apply Finset.sum_congr rfl + intro e he + nlinarith [congrArg (fun x : ℤ => m e * x) (hid e he)] + rw [hs] + ring + + + +lemma terminal_translation {q₀ hA hB bA bB dA dB tA : ℚ} {m q : ℤ} + (hq₀ : q₀ ≠ 0) (hB0 : hB ≠ 0) (hbB : bB ≠ 0) (hdB : dB ≠ 0) + (hm : (m : ℚ) = q₀ * (bA / bB) * (dA / dB)) + (hq : (q : ℚ) = (hA / (q₀ * hB)) * tA) : + ((m * q : ℤ) : ℚ) = (hA * bA * dA / (hB * bB * dB)) * tA := by + push_cast + rw [hm,hq] + field_simp + + + +structure ResidueData (q₀ M W H a t : ℤ) (w : ℕ) where + q : ℤ + r : ℤ + Δ : ℤ + q_value : (q : ℚ) = (H : ℚ) / q₀ * a + r_nonneg : 0 ≤ r + r_lt : r < M * W ^ w + congruence : t * r ≡ q [ZMOD M * W ^ w] + Δ_value : Δ = (q - t * r) / M + W_dvd_q : W ∣ q + W_dvd_r : W ∣ r + pow_dvd_Δ : W ^ w ∣ Δ + identity : ∀ p m : ℤ, t * (p + m * r) + m * M * Δ = t * p + m * q + + + +theorem residue_system {E : Type*} (q₀ w : ℕ) (hq₀ : 0 < q₀) (hw : q₀ + 1 ≤ w) + (M : ℤ) (hM : 0 < M) (hSM : Smooth w M) + (H a t : E → ℤ) (hH : ∀ e, (primorial w : ℤ) ^ w ∣ H e) + (ht : ∀ e, Rough w (t e)) : + Nonempty (∀ e, ResidueData q₀ M (primorial w) (H e) (a e) (t e) w) := by + classical + have hbase : (q₀ : ℤ) * (primorial w : ℤ) ∣ (primorial w : ℤ) ^ w := by + exact_mod_cast fixed_mul_primorial_dvd hq₀ hw + have hq0 : (q₀ : ℤ) ≠ 0 := by exact_mod_cast hq₀.ne' + have hW : (0 : ℤ) < primorial w := by exact_mod_cast primorial_pos w + have hdata : ∀ e, Nonempty (ResidueData q₀ M (primorial w) (H e) (a e) (t e) w) := by + intro e + obtain ⟨q,hq,hqd⟩ := integral_translation hq0 (hbase.trans (hH e)) (a := a e) + obtain ⟨r,Δ,h0,hr,hc,hΔ,hrd,hΔd,hid⟩ := + residue_shift hM hW (by omega : 1 ≤ w) (coprime_modulus hSM (ht e)) hqd + exact ⟨⟨q,r,Δ,hq,h0,hr,hc,hΔ,hqd,hrd,hΔd,hid⟩⟩ + exact ⟨fun e => Classical.choice (hdata e)⟩ + +lemma fixed_dvd_delta {q₀ M H a t : ℤ} {w n : ℕ} + (D : ResidueData q₀ M (primorial w) H a t w) (hn : 0 < n) (hnw : n ≤ w) : + (n : ℤ) ∣ D.Δ := by + have h : (n : ℤ) ∣ (primorial w : ℤ) ^ w := by + exact_mod_cast fixed_dvd_primorial_pow hn hnw hnw + exact h.trans D.pow_dvd_Δ + + +lemma rough_slot {E : Type*} (S : Finset E) (v r : E → ℤ) {w : ℕ} {p : ℤ} + (hp : Rough w p) (hr : ∀ e ∈ S, (primorial w : ℤ) ∣ r e) : + Rough w (p + ∑ e ∈ S, v e * r e) := by + have hs : (primorial w : ℤ) ∣ ∑ e ∈ S, v e * r e := + Finset.dvd_sum (fun e he => dvd_mul_of_dvd_right (hr e he) (v e)) + intro ℓ hℓ hℓw hd + have hℓW : (ℓ : ℤ) ∣ (primorial w : ℤ) := by + exact_mod_cast hℓ.dvd_primorial_iff.mpr hℓw + have : (ℓ : ℤ) ∣ p := by + simpa using dvd_sub hd (hℓW.trans hs) + exact hp ℓ hℓ hℓw this + + + +lemma model_array_exponent {G : Type*} [Group G] (g : G) (n M d : ℤ) (hM : M ≠ 0) : + g ^ ((n + M * d - (n + M * d) % M) / M) = + g ^ ((n - n % M) / M) * g ^ d := by + have hmod : (n + M * d) % M = n % M := Int.add_mul_emod_self_left n M d + rw [hmod] + have he : (n + M * d - n % M) / M = (n - n % M) / M + d := by + rw [show n + M * d - n % M = (n - n % M) + d * M by ring] + exact Int.add_mul_ediv_right _ _ hM + rw [he,zpow_add] + +end IntegerAlignment + + +end OAI diff --git a/lean/OAI/Combinatorics/SumProduct/Alignment/IntegerArrays01.lean b/lean/OAI/Combinatorics/SumProduct/Alignment/IntegerArrays01.lean new file mode 100644 index 0000000000000000000000000000000000000000..705f461cda428cac7ba9a5ad6d2f020d7244d4b6 --- /dev/null +++ b/lean/OAI/Combinatorics/SumProduct/Alignment/IntegerArrays01.lean @@ -0,0 +1,270 @@ +import Mathlib +import OAI.Combinatorics.SumProduct.Alignment.ResidueAlignment01 +import OAI.Geometry.NilpotentCharts.Main + +namespace OAI + +open scoped BigOperators +noncomputable section +end + +noncomputable section +namespace SourceIntegerArrays +open RationalLattice MalcevCharacters RoughArrayFace RoughArrayCoordinates SourceResidueAlignment +open ProductExposureLabels +open scoped BigOperators + +def rSlot {m : ℕ} (M : ℕ) (b : Label m) (slot : ℤ) : ℤ := + ((∏ j,b.residue j)*(b.pivotResidue+slot))%(M:ℤ) + +def offset0 {m : ℕ} (M : ℕ) (R : ℝ) (b : Label m) (slot : ℤ) : ℝ := + (yStar M R b:ℝ)+((rStar M b:ℝ)-(rSlot M b slot:ℝ))/(M:ℝ) + +def offset1 (M : ℕ) (slot : ℤ) : ℝ := (slot:ℝ)/(M:ℝ) + + + +def exponent {m v q : ℕ} (M : ℕ) (L : ℤ) (b : Label m) + (tail : Fin m→ℤ) (pstar slot : ℤ) (pattern : Fin (v+1)→ℤ) + (β : Fin (v+1)→ℤ) (qval u : Fin q→ℤ) : ℤ := + ((∏ j,tail j)*(pstar+(M:ℤ)*(∑ j,pattern j*β j)+slot)-rSlot M b slot)/(M:ℤ)+ + ∑ e,shift M L (qval e) b tail*u e +end SourceIntegerArrays +end + +noncomputable section +namespace SourceIntegerArrays +open RationalLattice MalcevCharacters RoughArrayFace RoughArrayCoordinates SourceResidueAlignment +open ProductExposureLabels +open scoped BigOperators + +lemma rSlot_expose {m : ℕ} (M : ℕ) (L : ℤ) (hML : (M:ℤ)∣L) + (R : ℝ) (z : (Fin m→ℕ)×ℕ) (slot : ℤ) : + rSlot M (expose L (M:ℤ) R z) slot= + ((∏ j,(z.1 j:ℤ))*((z.2:ℤ)+slot))%(M:ℤ) := by + unfold rSlot expose + have hmod (j : Fin m) : ((z.1 j:ℤ)%L)%(M:ℤ)=(z.1 j:ℤ)%(M:ℤ) := + Int.emod_emod_of_dvd _ hML + rw [Int.mul_emod,Int.add_emod,Int.emod_emod,Finset.prod_int_mod] + simp only [hmod] + rw [←Int.add_emod,←Finset.prod_int_mod,←Int.mul_emod] + +lemma shift_mul {m : ℕ} (M : ℕ) (L : ℤ) (hL : 0(z.1 j:ℤ))= + qval-(∏ j,(z.1 j:ℤ))*residueData L qval (expose L (M:ℤ) R z) := by + have hres := (residue_spec L (∏ j,(expose L (M:ℤ) R z).residue j) qval hL hcop).2.2 + have ht : (∏ j,(expose L (M:ℤ) R z).residue j) ≡ (∏ j,(z.1 j:ℤ)) [ZMOD L] := by + apply Int.ModEq.prod + intro j _ + change (z.1 j:ℤ)%L ≡ (z.1 j:ℤ) [ZMOD L] + show ((z.1 j:ℤ)%L)%L=(z.1 j:ℤ)%L + exact Int.emod_emod _ _ + have hdiv : L∣qval-(∏ j,(z.1 j:ℤ))*residueData L qval (expose L (M:ℤ) R z) := + Int.modEq_iff_dvd.mp ((ht.symm.mul_right _).trans hres) + exact Int.mul_ediv_cancel' (hML.trans hdiv) + +lemma slot_numerator_div {m : ℕ} (M : ℕ) (L : ℤ) (hML : (M:ℤ)∣L) + (R : ℝ) (z : (Fin m→ℕ)×ℕ) (pstar : ℤ) + (hpstar : (M:ℤ)∣pstar-(z.2:ℤ)) (slot β : ℤ) : + (M:ℤ)∣(∏ j,(z.1 j:ℤ))*(pstar+(M:ℤ)*β+slot)- + rSlot M (expose L (M:ℤ) R z) slot := by + rw [rSlot_expose M L hML R z slot] + let t : ℤ:=∏ j,(z.1 j:ℤ) + have h1 : (M:ℤ)∣t*(pstar-(z.2:ℤ)+(M:ℤ)*β) := + dvd_mul_of_dvd_right (dvd_add hpstar (dvd_mul_right _ _)) t + have h2 : (M:ℤ)∣t*((z.2:ℤ)+slot)-(t*((z.2:ℤ)+slot))%(M:ℤ) := by + rw [Int.dvd_iff_emod_eq_zero,Int.sub_emod,Int.emod_emod] + simp + have he : t*(pstar+(M:ℤ)*β+slot)-(t*((z.2:ℤ)+slot))%(M:ℤ)= + t*(pstar-(z.2:ℤ)+(M:ℤ)*β)+(t*((z.2:ℤ)+slot)-(t*((z.2:ℤ)+slot))%(M:ℤ)) := by ring + change (M:ℤ)∣t*(pstar+(M:ℤ)*β+slot)-(t*((z.2:ℤ)+slot))%(M:ℤ) + rw [he] + exact dvd_add h1 h2 + +lemma exponent_cast {m v q : ℕ} (M : ℕ) (hM : 0(z.1 j:ℤ)) pstar slot pat β qval u:ℝ) := by + let b:=expose L (M:ℤ) R z + let t : ℤ:=∏ j,(z.1 j:ℤ) + let V : ℤ:=∑ j,pat j*β j + let K : ℤ:=(t*pstar-rStar M b)/(M:ℤ)-yStar M R b + let E : ℤ:=(t*(pstar+(M:ℤ)*V+slot)-rSlot M b slot)/(M:ℤ) + have hm : (M:ℝ)≠0 := by exact_mod_cast (Nat.ne_of_gt hM) + have hdiv : (M:ℤ)∣t*pstar-rStar M b := by + have hh:=slot_numerator_div M L hML R z pstar hpstar 0 0 + simpa [rSlot,rStar] using hh + have hK : (M:ℤ)*(K+yStar M R b)=t*pstar-rStar M b := by + dsimp [K] + rw [sub_add_cancel,Int.mul_ediv_cancel' hdiv] + have hE : (M:ℤ)*E=t*(pstar+(M:ℤ)*V+slot)-rSlot M b slot := + Int.mul_ediv_cancel' (slot_numerator_div M L hML R z pstar hpstar slot V) + have hKR : (M:ℝ)*((K:ℝ)+(yStar M R b:ℝ))=(t:ℝ)*(pstar:ℝ)-(rStar M b:ℝ) := by exact_mod_cast hK + have hER : (M:ℝ)*(E:ℝ)=(t:ℝ)*((pstar:ℝ)+(M:ℝ)*(V:ℝ)+(slot:ℝ))-(rSlot M b slot:ℝ) := by exact_mod_cast hE + have hsum : (∑ j,(pat j:ℝ)*(affine (physicalOrigin v M R b t pstar) t β j:ℝ))=(K:ℝ)+(t:ℝ)*(V:ℝ) := by + simp only [affine,physicalOrigin,Int.cast_add,Int.cast_mul,mul_add,Finset.sum_add_distrib] + have hk : (∑ j,(pat j:ℝ)*((Pi.single 0 K : Fin (v+1)→ℤ) j:ℝ))=(K:ℝ) := by simp [Pi.single_apply,hpat] + change (∑ j,(pat j:ℝ)*((Pi.single 0 K : Fin (v+1)→ℤ) j:ℝ))+ + (∑ j,(pat j:ℝ)*((t:ℝ)*(β j:ℝ)))=(K:ℝ)+(t:ℝ)*(V:ℝ) + rw [hk] + dsimp [V] + push_cast + rw [Finset.mul_sum] + congr 1 + apply Finset.sum_congr rfl + intro j _ + ring + have hshift (e : Fin q) : (qval e:ℝ)/(M:ℝ)+(-(residueData L (qval e) b:ℝ)/(M:ℝ))*(∏ j,(z.1 j:ℝ))= + (shift M L (qval e) b (fun j=>(z.1 j:ℤ)):ℝ) := by + have hh:=shift_mul M L hL hML R z hcop (qval e) + have hhR : (M:ℝ)*(shift M L (qval e) b (fun j=>(z.1 j:ℤ)):ℝ)= + (qval e:ℝ)-(∏ j,(z.1 j:ℝ))*(residueData L (qval e) b:ℝ) := by exact_mod_cast hh + field_simp [hm] + linear_combination -hhR + change offset0 M R b slot+offset1 M slot*(∏ j,(z.1 j:ℝ))+ + (∑ j,(pat j:ℝ)*(affine (physicalOrigin v M R b t pstar) t β j:ℝ))+ + (∑ e,((qval e:ℝ)/(M:ℝ)+(-(residueData L (qval e) b:ℝ)/(M:ℝ))*(∏ j,(z.1 j:ℝ)))*(u e:ℝ))= + (exponent M L b (fun j=>(z.1 j:ℤ)) pstar slot pat β qval u:ℝ) + rw [hsum] + simp_rw [hshift] + change offset0 M R b slot+offset1 M slot*(∏ j,(z.1 j:ℝ))+((K:ℝ)+(t:ℝ)*(V:ℝ))+ + (∑ e,(shift M L (qval e) b (fun j=>(z.1 j:ℤ)):ℝ)*(u e:ℝ))= + ((E+∑ e,shift M L (qval e) b (fun j=>(z.1 j:ℤ))*u e:ℤ):ℝ) + push_cast + congr 1 + dsimp [offset0,offset1] + have ht : (∏ j,(z.1 j:ℝ))=(t:ℝ) := by dsimp [t];simp + rw [ht] + field_simp [hm] + nlinarith [hKR,hER] + +end SourceIntegerArrays +end + +noncomputable section +namespace SourceIntegerArrays +open RationalLattice MalcevCharacters RoughArrayFace RoughArrayCoordinates SourceResidueAlignment +open ProductExposureLabels +open scoped BigOperators +variable {ι : Type} [Fintype ι] (G : ι→Type) [∀ i,Group (G i)] +variable [∀ i,TopologicalSpace (G i)] [∀ i,IsTopologicalGroup (G i)] +variable (n : ι→ℕ) (q : ℕ) (c : ∀ i,RealCoordinates (G i) (n i)) +variable (hsk : ∀ i,SecondKind (c i)) (A : ∀ i,CubeFaces.Filtration (G i)) +variable (w : ∀ i,Fin (n i)→ℕ) +variable (hA : ∀ i k (g : G i),g∈(A i).level k ↔ ∀ j,w i joffset0 M R b (slot i)) (fun i=>offset1 M (slot i)) + (fun e=>(qval e:ℝ)/(M:ℝ)) (fun e=>-(residueData L (qval e) b:ℝ)/(M:ℝ)) + (Fin.append (fun j=>(z.1 j:ℝ)) + (fun j=>(affine (physicalOrigin v M R b t pstar) t β j:ℝ))) i).val (fun e=>(u e:ℝ))= + (g i)^(exponent M L b (fun j=>(z.1 j:ℤ)) pstar (slot i) (pattern i) β qval u)*x i + := by + dsimp only + rw [←realPower_int (c i) (g i)] + dsimp only [sourceState,PolynomialArrays.sourceElement] + simp only [Fin.append_left,Fin.append_right] + apply congrArg (fun a=>realPower (c i) (g i) a*x i) + exact exponent_cast M hM L hL hML R z hcop pstar hpstar (pattern i) (hpat i) (slot i) β qval u + +end SourceIntegerArrays +end + +noncomputable section +namespace SourceIntegerArrays +open RationalLattice MalcevCharacters RoughArrayFace RoughArrayCoordinates SourceResidueAlignment +open ProductExposureLabels +open scoped BigOperators +variable {ι : Type} [Fintype ι] (G : ι→Type) [∀ i,Group (G i)] +variable [∀ i,TopologicalSpace (G i)] [∀ i,IsTopologicalGroup (G i)] +variable (n : ι→ℕ) (q : ℕ) (c : ∀ i,RealCoordinates (G i) (n i)) +variable (hsk : ∀ i,SecondKind (c i)) (A : ∀ i,CubeFaces.Filtration (G i)) +variable (w : ∀ i,Fin (n i)→ℕ) +variable (hA : ∀ i k (g : G i),g∈(A i).level k ↔ ∀ j,w i jPolynomialArrays.sourceElement (c i) (hsk i) (A i) (w i) (hA i) (hw i) + (g i) (x i) (exponent M L b tail pstar (slot i) (pattern i) β qval 0:ℝ) + (fun e=>(shift M L (qval e) b tail:ℝ)) +end SourceIntegerArrays +end + +noncomputable section +namespace SourceIntegerArrays +open RationalLattice MalcevCharacters RoughArrayFace RoughArrayCoordinates SourceResidueAlignment +open ProductExposureLabels +open scoped BigOperators +variable {ι : Type} [Fintype ι] (G : ι→Type) [∀ i,Group (G i)] +variable [∀ i,TopologicalSpace (G i)] [∀ i,IsTopologicalGroup (G i)] +variable (n : ι→ℕ) (q : ℕ) (c : ∀ i,RealCoordinates (G i) (n i)) +variable (hsk : ∀ i,SecondKind (c i)) (A : ∀ i,CubeFaces.Filtration (G i)) +variable (w : ∀ i,Fin (n i)→ℕ) +variable (hA : ∀ i k (g : G i),g∈(A i).level k ↔ ∀ j,w i joffset0 M R b (slot i)) (fun i=>offset1 M (slot i)) + (fun e=>(qval e:ℝ)/(M:ℝ)) (fun e=>-(residueData L (qval e) b:ℝ)/(M:ℝ)) + (Fin.append (fun j=>(z.1 j:ℝ)) + (fun j=>(affine (physicalOrigin v M R b t pstar) t β j:ℝ))) = + literalState G n q c hsk A w hA hw M L b (fun j=>(z.1 j:ℤ)) + pstar pattern g x slot qval β + := by + dsimp only + funext i + apply congrArg₂ (fun b vs=>PolynomialArrays.sourceElement (c i) (hsk i) (A i) (w i) (hA i) (hw i) (g i) (x i) b vs) + · have he:=exponent_cast M hM L hL hML R z hcop pstar hpstar (pattern i) (hpat i) (slot i) β qval 0 + simpa only [Pi.zero_apply,Int.cast_zero,mul_zero,Finset.sum_const_zero,add_zero, + Fin.append_left,Fin.append_right] using he + · funext e + simp only [Fin.append_left] + have hh:=shift_mul M L hL hML R z hcop (qval e) + have hhR : (M:ℝ)*(shift M L (qval e) (expose L (M:ℤ) R z) (fun j=>(z.1 j:ℤ)):ℝ)= + (qval e:ℝ)-(∏ j,(z.1 j:ℝ))*(residueData L (qval e) (expose L (M:ℤ) R z):ℝ) := by exact_mod_cast hh + have hm : (M:ℝ)≠0 := by exact_mod_cast (Nat.ne_of_gt hM) + field_simp [hm] + linear_combination -hhR + +end SourceIntegerArrays + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SumProduct/Alignment/IntegerArrays02.lean b/lean/OAI/Combinatorics/SumProduct/Alignment/IntegerArrays02.lean new file mode 100644 index 0000000000000000000000000000000000000000..2613fcc13b62916fb0f3b074c18b17202d379027 --- /dev/null +++ b/lean/OAI/Combinatorics/SumProduct/Alignment/IntegerArrays02.lean @@ -0,0 +1,323 @@ +import Mathlib +import OAI.Combinatorics.SumProduct.Alignment.IntegerArrays01 +import OAI.Combinatorics.SumProduct.Alignment.RoughArray04 +import OAI.Geometry.NilpotentCharts.Main + +namespace OAI + +open scoped BigOperators +noncomputable section +end + +noncomputable section +namespace SourceIntegerArrays +open RoughArrayFace +open RationalLattice MalcevCharacters RoughFaceShift RoughTopologicalFace RoughArrayCoordinates SourceResidueAlignment +open RoughScales RoughSamplingWeights FinitePieceAverages RoughSourceExceptional RoughProductRemoval +open ProductExposureLabels ProductExposureLaw ProductExposureCutoff MeasureTheory Filter +open scoped BigOperators Topology ENNReal +attribute [local instance] Classical.propDecidable +variable {τ : Type} [Fintype τ] {ι : τ→Type} [∀ t,Fintype (ι t)] +variable (G : ∀ t,ι t→Type) [∀ t i,Group (G t i)] +variable [∀ t i,TopologicalSpace (G t i)] [∀ t i,IsTopologicalGroup (G t i)] +variable (n : ∀ t,ι t→ℕ) (q : τ→ℕ) (c : ∀ t i,RealCoordinates (G t i) (n t i)) +variable (hsk : ∀ t i,SecondKind (c t i)) (A : ∀ t i,CubeFaces.Filtration (G t i)) +variable (w : ∀ t i,Fin (n t i)→ℕ) +variable (hA : ∀ t i k (g : G t i),g∈(A t i).level k ↔ ∀ j,w t i jX N j) atTop atTop) (hXpt : Tendsto Xp atTop atTop) + (hR : ∀ N,0R N/(Xp N:ℝ)) atTop (𝓝 0)) + (hZ : ∀ t (u : ℝ),0(R N/(M N:ℝ))/ + (1+∑ j : Fin (m t),(X N (perm t (j.castAdd (h t))):ℝ)^2)^u) atTop atTop) + (hQ0 : ∀ N,0≤Q N) + (hSize : ∀ t,Tendsto (fun N=>(Q N+(∏ l : Fin (m t),(X N (perm t (l.castAdd (h t))):ℝ)^2)*(L N:ℝ))/R N) atTop (𝓝 0)) + (hWM : ∀ N,(primorial (w0 N):ℤ)∣(M N:ℤ)) + (hM : ∀ N,0(X N (perm t (j.castAdd (h t))):ℝ)/(L N:ℝ)) atTop atTop) + (pattern : ∀ t,ι t→Fin (v t+1)→ℤ) (hpat : ∀ t i,pattern t i 0=1) + (g x : ∀ t,ℕ→(Fin (h t)→ℕ)→Label (m t)→∀ i,G t i) + (slot : ∀ t,ℕ→(Fin (h t)→ℕ)→Label (m t)→ι t→ℤ) + (qval : ∀ t,ℕ→(Fin (h t)→ℕ)→Label (m t)→Fin (q t)→ℤ) + (hQ : ∀ t N y,y∈outsideDomain (fun l : Fin (h t)=>X N (perm t (l.natAdd (m t)))) (primorial (w0 N)) → + ∀ b,b∈(fullDomain (fun l : Fin (m t)=>X N (perm t (l.castAdd (h t)))) (Xp N) (primorial (w0 N))).image + (expose (L N) (M N:ℤ) (R N)) →∀ k,|(qval t N y b k:ℝ)|≤Q N) + (E : ℕ→Set ((Fin a→ℕ)×ℕ)) (ε : ℝ≥0∞) (hε : 0<ε) + (hE : ∀ N,ε≤(jointLaw (X N) (Xp N) (primorial (w0 N)) (primorial_pos _) + (hX N) (hXp N)) (E N)) : + ∃ φ : ℕ→ℕ,StrictMono φ ∧ ∃ z : ℕ→(Fin a→ℕ)×ℕ, + (∀ k,z k∈E (φ k) ∧ z k∈fullDomain (X (φ k)) (Xp (φ k)) (primorial (w0 (φ k)))) ∧ + ∀ t, + let zout := fun k l=>(z k).1 (perm t (l.natAdd (m t))) + let zin := fun k=>((fun l=>(z k).1 (perm t (l.castAdd (h t)))),(z k).2) + let label := fun k=>expose (L (φ k)) (M (φ k):ℤ) (R (φ k)) (zin k) + let Z := fun k=>R (φ k)/(M (φ k):ℝ) + ∀ (e : Fin (q t)) (j : Fin (v t+1)) (d : ℕ),0literalState (G t) (n t) (q t) (c t) (hsk t) (A t) (w t) (hA t) (hw t) + (M (φ k)) (L (φ k)) (label k) (fun l=>((zin k).1 l:ℤ)) (pstar k) (pattern t) + (g t (φ k) (zout k) (label k)) (x t (φ k) (zout k) (label k)) + (slot t (φ k) (zout k) (label k)) (qval t (φ k) (zout k) (label k)) β + ∀ (c₀ C₀ : ℝ),0mean (physicalResidueBox (lo k) (hi k) (res k) d) + (fun β=>F (faceAction (G t) (n t) (q t) (c t) (hsk t) (A t) (w t) (hA t) (Γ t) + (pattern t) e j (QuotientGroup.mk (state k β))))- + mean (physicalResidueBox (lo k) (hi k) (res k) d) + (fun β=>F (QuotientGroup.mk (state k β)))) atTop (𝓝 0) + := by + classical + obtain ⟨φ,hφ,z,hz,hgood⟩ := source_global_selected_faces G n q c hsk A w hA hw Γ hΓ htop + a m h v perm w0 M Xp X R Q L hw0 hX hXp hXt hXpt hR hRX hZ hQ0 hSize hWM hM hMs + hL hsm hWL hML hLexact hXL pattern g x + (fun t N y b i=>offset0 (M N) (R N) b (slot t N y b i)) + (fun t N y b i=>offset1 (M N) (slot t N y b i)) qval hQ E ε hε hE + refine ⟨φ,hφ,z,hz,?_⟩ + intro t + dsimp only + intro e j d hd pstar hpstar hpclose c₀ C₀ hc₀ hC₀ lo hi res hbox F + let zout (k : ℕ) (l : Fin (h t)) := (z k).1 (perm t (l.natAdd (m t))) + let zin (k : ℕ) : (Fin (m t)→ℕ)×ℕ := + (fun l=>(z k).1 (perm t (l.castAdd (h t))),(z k).2) + let label (k : ℕ) := expose (L (φ k)) (M (φ k):ℤ) (R (φ k)) (zin k) + let D (k : ℕ) := actualData (G t) (n t) (q t) (c t) (hsk t) (A t) (w t) (hA t) (hw t) (Γ t) + (pattern t) (g t (φ k) (zout k) (label k)) (x t (φ k) (zout k) (label k)) + (fun i=>offset0 (M (φ k)) (R (φ k)) (label k) (slot t (φ k) (zout k) (label k) i)) + (fun i=>offset1 (M (φ k)) (slot t (φ k) (zout k) (label k) i)) + (fun u=>(qval t (φ k) (zout k) (label k) u:ℝ)/(M (φ k):ℝ)) + (fun u=>-(residueData (L (φ k)) (qval t (φ k) (zout k) (label k) u) (label k):ℝ)/(M (φ k):ℝ)) + e j (coarseOrigin (v t) (M (φ k)) (R (φ k)) (label k)) + (shift (M (φ k)) (L (φ k)) (qval t (φ k) (zout k) (label k) e) (label k)) + obtain ⟨chart,grid,hgridpos,hgrid,J,hJ,hdegree⟩ := + source_joint_geometry (G t) (n t) (q t) (c t) (hsk t) (A t) (w t) (hA t) (hw t) (Γ t) (hΓ t) + obtain ⟨Λ,ec,hec,hΛ,hle,D',hD,hdeg⟩ := RoughCoveredFace.grid_second_degree_cover chart + (lattice (G t) (n t) (q t) (c t) (hsk t) (A t) (w t) (hA t) (Γ t)) grid hgridpos hgrid + have hcompact : @CompactSpace ((Carrier (G t) (n t) (q t) (c t) (hsk t) (A t) (w t) (hA t))⧸ + lattice (G t) (n t) (q t) (c t) (hsk t) (A t) (w t) (hA t) (Γ t)) + (QuotientGroup.instTopologicalSpace (lattice (G t) (n t) (q t) (c t) (hsk t) (A t) (w t) (hA t) (Γ t))) := by + obtain ⟨S,hS,hrep⟩ := compact_reps_of_integerCoordinates ec Λ hΛ + apply CompactGroupProducts.HasCompactReps.quotient_compactSpace + refine ⟨S,hS,fun _ _=>Subgroup.mem_top _,?_⟩ + intro u _ + obtain ⟨s,hs,hsa⟩ := hrep u + exact ⟨s,hs,hle hsa⟩ + let := hcompact + have hgridgood (b : ℕ) : ∀ᶠ k in atTop, + ¬badPhysical (lattice (G t) (n t) (q t) (c t) (hsk t) (A t) (w t) (hA t) (Γ t)) + (m t) (v t+1) (1/((b:ℝ)+1)) ((b:ℝ)+1) (b+1) (1/((b:ℝ)+1)) + (R (φ k)/(M (φ k):ℝ)) d + (physicalOrigin (v t) (M (φ k)) (R (φ k)) (label k) (∏ l,((zin k).1 l:ℤ)) (pstar k)) + (D k).P (D k).σ (fun l=>((zin k).1 l:ℤ)) := by + filter_upwards [hgood t e j d hd b] with k hk + intro hbad + exact hk ⟨pstar k,hpstar k,hpclose k,hbad⟩ + have hh := physical_grid_continuous + (lattice (G t) (n t) (q t) (c t) (hsk t) (A t) (w t) (hA t) (Γ t)) (htop t) + (m t) (v t+1) (fun k=>R (φ k)/(M (φ k):ℝ)) + (fun k=>div_nonneg (hR _).le (by positivity)) d + (fun k=>physicalOrigin (v t) (M (φ k)) (R (φ k)) (label k) (∏ l,((zin k).1 l:ℤ)) (pstar k)) + (fun k=>(D k).P) (fun k=>(D k).σ) (fun k l=>((zin k).1 l:ℤ)) + hgridgood c₀ C₀ hc₀ hC₀ lo hi res hbox F + have hzin (k : ℕ) : zin k∈fullDomain (fun l : Fin (m t)=>X (φ k) (perm t (l.castAdd (h t)))) + (Xp (φ k)) (primorial (w0 (φ k))) := by + rcases Finset.mem_filter.mp (hz k).2 with ⟨hraw,hcop⟩ + rcases Finset.mem_product.mp hraw with ⟨ht,hp⟩ + apply Finset.mem_filter.mpr + refine ⟨Finset.mem_product.mpr ⟨?_,hp⟩,hcop⟩ + exact Fintype.mem_piFinset.mpr (fun l=>(Fintype.mem_piFinset.mp ht) _) + have hcop (k : ℕ) : IsCoprime (∏ l,(label k).residue l) (L (φ k)) := by + have hr := image_residues (fun l : Fin (m t)=>X (φ k) (perm t (l.castAdd (h t)))) + (Xp (φ k)) (primorial (w0 (φ k))) (L (φ k)) (M (φ k):ℤ) (R (φ k)) (hL (φ k)) + (by exact_mod_cast hM (φ k)) (hWL (φ k)) (hWM (φ k)) _ + (Finset.mem_image.mpr ⟨zin k,hzin k,rfl⟩) + exact IsCoprime.prod_left (fun l _=> + (IntegerAlignment.coprime_smooth_rough (hsm (φ k)) + ((rough_iff_coprime _ _).mpr (hr.2.2.1 l))).symm) + have hstate (k : ℕ) (β : Fin (v t+1)→ℤ) := + source_literal_entire_array (G t) (n t) (q t) (c t) (hsk t) (A t) (w t) (hA t) (hw t) + (M (φ k)) (hM (φ k)) (L (φ k)) (hL (φ k)) (hML (φ k)) (R (φ k)) (zin k) (hcop k) + (pstar k) (hpstar k) (pattern t) (hpat t) + (g t (φ k) (zout k) (label k)) (x t (φ k) (zout k) (label k)) + (slot t (φ k) (zout k) (label k)) (qval t (φ k) (zout k) (label k)) β + dsimp only at hstate + simpa only [D,actualData,Int.cast_natCast,label,hstate] using hh + +end SourceIntegerArrays +end + +noncomputable section +namespace SourceIntegerArrays +open RationalLattice MalcevCharacters RoughArrayFace RoughArrayCoordinates SourceResidueAlignment +open ProductExposureLabels +open scoped BigOperators +attribute [local instance] Classical.propDecidable +variable {ι : Type} [Fintype ι] (G : ι→Type) [∀ i,Group (G i)] +variable [∀ i,TopologicalSpace (G i)] [∀ i,IsTopologicalGroup (G i)] +variable (n : ι→ℕ) (q : ℕ) (c : ∀ i,RealCoordinates (G i) (n i)) +variable (hsk : ∀ i,SecondKind (c i)) (A : ∀ i,CubeFaces.Filtration (G i)) +variable (w : ∀ i,Fin (n i)→ℕ) +variable (hA : ∀ i k (g : G i),g∈(A i).level k ↔ ∀ j,w i jif j∈S then 1 else 0) + +abbrev CubeIndex := ι×Finset (Fin v) +abbrev DG (a : CubeIndex (ι:=ι) v) := G a.1 +abbrev Dn (a : CubeIndex (ι:=ι) v) := n a.1 +section +variable {G n} +abbrev Dc (a : CubeIndex (ι:=ι) v) := c a.1 +end +section +variable {G n c} +abbrev Dhsk (a : CubeIndex (ι:=ι) v) := hsk a.1 +end +section +variable {G} +abbrev DA (a : CubeIndex (ι:=ι) v) := A a.1 +end +section +variable {n} +abbrev Dw (a : CubeIndex (ι:=ι) v) := w a.1 +end +section +variable {G n c A w} +abbrev DhA (a : CubeIndex (ι:=ι) v) := hA a.1 +end +section +variable {n w} +abbrev Dhw (a : CubeIndex (ι:=ι) v) := hw a.1 +end +section +variable {G} +abbrev DΓ (a : CubeIndex (ι:=ι) v) := Γ a.1 +end +abbrev CSpace := Carrier G n q c hsk A w hA +abbrev CLattice := lattice G n q c hsk A w hA Γ +abbrev DCspace := Carrier (DG G v) (Dn n v) q (Dc c v) (Dhsk hsk v) (DA A v) (Dw w v) (DhA hA v) +abbrev DClattice := lattice (DG G v) (Dn n v) q (Dc c v) (Dhsk hsk v) (DA A v) (Dw w v) (DhA hA v) (DΓ Γ v) + +lemma cubePattern_dot (β : Fin (v+1)→ℤ) (S : Finset (Fin v)) : + ∑ j,cubePattern v S j*β j=cubeVertex v β S := by + rw [Fin.sum_univ_succ] + simp [cubePattern,cubeVertex,Finset.sum_ite_mem] + + +def cubeProjection : C((DCspace G n q c hsk A w hA v)⧸DClattice G n q c hsk A w hA Γ v, + Finset (Fin v)→(CSpace G n q c hsk A w hA)⧸CLattice G n q c hsk A w hA Γ) where + toFun z S:=Quotient.map (fun f i=>f (i,S)) (by + intro f g hfg + apply QuotientGroup.leftRel_apply.mpr + intro i + exact (QuotientGroup.leftRel_apply.mp hfg) (i,S)) z + continuous_toFun:=by + apply continuous_pi + intro S + apply (QuotientGroup.isQuotientMap_mk _).continuous_iff.mpr + exact QuotientGroup.continuous_mk.comp (continuous_pi (fun i=>continuous_apply (i,S))) + +omit [Fintype ι] in +lemma cubeProjection_mk (f : DCspace G n q c hsk A w hA v) (S : Finset (Fin v)) : + cubeProjection G n q c hsk A w hA Γ v (QuotientGroup.mk f) S= + QuotientGroup.mk (fun i=>f (i,S)) := rfl + +omit [Fintype ι] in +lemma cubeProjection_face (e : Fin q) (j : Fin v) + (y : (DCspace G n q c hsk A w hA v)⧸DClattice G n q c hsk A w hA Γ v) + (S : Finset (Fin v)) : + cubeProjection G n q c hsk A w hA Γ v + (faceAction (DG G v) (Dn n v) q (Dc c v) (Dhsk hsk v) (DA A v) (Dw w v) (DhA hA v) + (DΓ Γ v) (fun a=>cubePattern v a.2) e j.succ y) S= + if j∈S then faceAction G n q c hsk A w hA Γ (fun _ (_ : Fin 1)=>1) e 0 + (cubeProjection G n q c hsk A w hA Γ v y S) + else cubeProjection G n q c hsk A w hA Γ v y S := by + induction y using Quotient.inductionOn with + | h f => + by_cases hj : j∈S + · simp only [hj,ite_true] + apply congrArg QuotientGroup.mk + funext i + simp [faceMap,inputShift,cubePattern,hj,DG,Dn,Dc,DA,Dw] + · simp only [hj,ite_false] + apply congrArg QuotientGroup.mk + funext i + apply Subtype.ext + funext u + change (f (i,S)).val (u+fun k=>(((Pi.single e (cubePattern v S j.succ) : Fin q→ℤ) k):ℝ))=(f (i,S)).val u + simp only [cubePattern,Fin.cases_succ,hj,ite_false,Pi.single_zero,Pi.zero_apply,Int.cast_zero] + change (f (i,S)).val (u+0)=(f (i,S)).val u + rw [add_zero] + +omit [Fintype ι] in +lemma cubeProjection_literal {m : ℕ} (M : ℕ) (L : ℤ) (b : Label m) (tail : Fin m→ℤ) + (pstar : ℤ) (g x : ∀ i,G i) (slot : ι→ℤ) (qval : Fin q→ℤ) + (β : Fin (v+1)→ℤ) (S : Finset (Fin v)) : + cubeProjection G n q c hsk A w hA Γ v + (QuotientGroup.mk (literalState (DG G v) (Dn n v) q (Dc c v) (Dhsk hsk v) (DA A v) + (Dw w v) (DhA hA v) (Dhw hw v) M L b tail pstar (fun a=>cubePattern v a.2) + (fun a=>g a.1) (fun a=>x a.1) (fun a=>slot a.1) qval β)) S= + QuotientGroup.mk (literalState G n q c hsk A w hA hw M L b tail pstar + (fun _ (_ : Fin 1)=>1) g x slot qval (fun _=>cubeVertex v β S)) := by + rw [cubeProjection_mk] + apply congrArg QuotientGroup.mk + funext i + change PolynomialArrays.sourceElement (c i) (hsk i) (A i) (w i) (hA i) (hw i) (g i) (x i) + (exponent M L b tail pstar (slot i) (cubePattern v S) β qval 0:ℝ) _ = _ + simp [literalState,exponent,cubePattern_dot] + + +omit [Fintype ι] in +theorem literal_cube_interpretation : + ∃ π : C((DCspace G n q c hsk A w hA v)⧸DClattice G n q c hsk A w hA Γ v, + Finset (Fin v)→(CSpace G n q c hsk A w hA)⧸CLattice G n q c hsk A w hA Γ), + (∀ f S,π (QuotientGroup.mk f) S=QuotientGroup.mk (fun i=>f (i,S))) ∧ + (∀ (e : Fin q) (j : Fin v) y S, + π (faceAction (DG G v) (Dn n v) q (Dc c v) (Dhsk hsk v) (DA A v) (Dw w v) (DhA hA v) + (DΓ Γ v) (fun a=>cubePattern v a.2) e j.succ y) S= + if j∈S then faceAction G n q c hsk A w hA Γ (fun _ (_ : Fin 1)=>1) e 0 (π y S) + else π y S) ∧ + (∀ {m : ℕ} (M : ℕ) (L : ℤ) (b : Label m) (tail : Fin m→ℤ) (pstar : ℤ) + (g x : ∀ i,G i) (slot : ι→ℤ) (qval : Fin q→ℤ) (β : Fin (v+1)→ℤ) S, + π (QuotientGroup.mk (literalState (DG G v) (Dn n v) q (Dc c v) (Dhsk hsk v) (DA A v) + (Dw w v) (DhA hA v) (Dhw hw v) M L b tail pstar (fun a=>cubePattern v a.2) + (fun a=>g a.1) (fun a=>x a.1) (fun a=>slot a.1) qval β)) S= + QuotientGroup.mk (literalState G n q c hsk A w hA hw M L b tail pstar + (fun _ (_ : Fin 1)=>1) g x slot qval (fun _=>cubeVertex v β S))) + := by + exact ⟨cubeProjection G n q c hsk A w hA Γ v, + cubeProjection_mk G n q c hsk A w hA Γ v, + cubeProjection_face G n q c hsk A w hA Γ v, + by + intro m M L b tail pstar g x slot qval β S + exact cubeProjection_literal G n q c hsk A w hA hw Γ v M L b tail pstar g x slot qval β S⟩ + +end SourceIntegerArrays + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SumProduct/Alignment/IntegerArrays03.lean b/lean/OAI/Combinatorics/SumProduct/Alignment/IntegerArrays03.lean new file mode 100644 index 0000000000000000000000000000000000000000..9bde84d7f743653de3bdd7dedb80c43bac0b73b1 --- /dev/null +++ b/lean/OAI/Combinatorics/SumProduct/Alignment/IntegerArrays03.lean @@ -0,0 +1,342 @@ +import Mathlib +import OAI.Combinatorics.SumProduct.Alignment.PhysicalDecay01 +import OAI.Combinatorics.SumProduct.Alignment.RationalLattice22 +import OAI.Geometry.NilpotentCharts.Main + +namespace OAI + +open scoped BigOperators +noncomputable section +open scoped BigOperators +end + +noncomputable section +namespace SourceIntegerArrays.GlobalJoint +open RationalLattice MalcevCharacters RoughArrayFace RoughArrayCoordinates SourceResidueAlignment +open ProductExposureLabels AllLevelFactorization AllLevelFactorization.Factorization +open PhysicalCubeMaps CubeLocalHaar MeasureTheory +open scoped Topology BigOperators +attribute [local instance] Classical.propDecidable +variable {τ : Type} [Fintype τ] {ι : τ→Type} [∀ t,Fintype (ι t)] +variable (G : ∀ t,ι t→Type) [∀ t i,Group (G t i)] +variable [∀ t i,TopologicalSpace (G t i)] [∀ t i,IsTopologicalGroup (G t i)] +variable (n : ∀ t,ι t→ℕ) (q m : τ→ℕ) (c : ∀ t i,RealCoordinates (G t i) (n t i)) +variable (hsk : ∀ t i,SecondKind (c t i)) (A : ∀ t i,CubeFaces.Filtration (G t i)) +variable (w : ∀ t i,Fin (n t i)→ℕ) +variable (hA : ∀ t i k (g : G t i),g∈(A t i).level k ↔ ∀ j,w t i jfun i=>f ⟨t,i⟩) + exact continuous_pi (fun i=>continuous_apply (Sigma.mk t i)) + +omit [Fintype τ] [∀ t,Fintype (ι t)] in +lemma targetHom_lattice (t : τ) (f : Full G n q c hsk A w hA) + (hf : f∈FullLattice G n q c hsk A w hA Γ) : + targetHom G n q c hsk A w hA t f∈lattice (G t) (n t) (q t) (c t) (hsk t) (A t) (w t) (hA t) (Γ t) := + fun i=>hf ⟨t,i⟩ + + + +def targetCoset (Λ : Subgroup (Full G n q c hsk A w hA)) + (hle : Λ≤FullLattice G n q c hsk A w hA Γ) (t : τ) : + C((Full G n q c hsk A w hA)⧸Λ, + (Carrier (G t) (n t) (q t) (c t) (hsk t) (A t) (w t) (hA t))⧸ + lattice (G t) (n t) (q t) (c t) (hsk t) (A t) (w t) (hA t) (Γ t)) := + NonnormalCoset.map Λ _ (targetHom G n q c hsk A w hA t) + (targetHom_continuous G n q c hsk A w hA t) + (fun f hf=>targetHom_lattice G n q c hsk A w hA Γ t f (hle hf)) + +def rawJoint (M : ℕ) (L : ℤ) (b : ∀ t,Label (m t)) (tail : ∀ t,Fin (m t)→ℤ) + (pstar : τ→ℤ) (slot : ∀ t,ι t→ℤ) (qval : ∀ t,Fin (q t)→ℤ) + (g x : ∀ t i,G t i) (u : ℤ) : Full G n q c hsk A w hA := + literalJoint (FlatG G) (FlatN n) (FlatQ q) (FlatM m) (FlatC c) (FlatSk hsk) (FlatA A) (FlatW w) (FlatHA hA) (FlatHw hw) + M L (fun a=>b a.1) (fun a=>tail a.1) (fun a=>pstar a.1) (fun a=>slot a.1 a.2) + (fun a=>qval a.1) (fun a=>g a.1 a.2) (fun a=>x a.1 a.2) u + +omit [Fintype τ] [∀ t,Fintype (ι t)] in +lemma target_rawJoint (M : ℕ) (L : ℤ) (b : ∀ t,Label (m t)) (tail : ∀ t,Fin (m t)→ℤ) + (pstar : τ→ℤ) (slot : ∀ t,ι t→ℤ) (qval : ∀ t,Fin (q t)→ℤ) + (g x : ∀ t i,G t i) (u : ℤ) (t : τ) : + targetHom G n q c hsk A w hA t (rawJoint G n q m c hsk A w hA hw M L b tail pstar slot qval g x u)= + literalState (G t) (n t) (q t) (c t) (hsk t) (A t) (w t) (hA t) (hw t) + M L (b t) (tail t) (pstar t) (fun _ (_ : Fin 1)=>1) (g t) (x t) (slot t) (qval t) (fun _=>u) := rfl + + + +def FactorizedHaar (s : ℕ) (v : τ→ℕ) (P : ℕ→ℤ→Full G n q c hsk A w hA) (Z : ℕ→ℝ) : Prop := + ∃ d : RealCoordinates (Full G n q c hsk A w hA) (FullDim n q w), + ∃ B : CoveredLattice d (FullLattice G n q c hsk A w hA Γ), + SecondKind d ∧ + (∀ k f,f∈(FullFiltration G n q c hsk A w hA).level k ↔ + ∀ j,JointArrays.jointWeight (FlatN n) (FlatQ q) (FlatW w) j(u j:ℝ)))) ∧ + ∃ F : Factorization d B.small s (FullFiltration G n q c hsk A w hA) P Z, + letI : SecondCountableTopology (Full G n q c hsk A w hA):=coordinates_secondCountable d + letI : CompactSpace ((Full G n q c hsk A w hA)⧸B.small):=AbelianMalcevTorus.quotient_compact d B.small B.integer + letI : MeasurableSpace ((Full G n q c hsk A w hA)⧸B.small):=borel _ + letI : BorelSpace ((Full G n q c hsk A w hA)⧸B.small):=⟨rfl⟩ + ∀ t (r : Fin F.period) (C : F.ResidueCover r), + letI : MeasurableSpace (C.CubeSpace (ι:=Fin (v t))):=borel _ + letI : BorelSpace (C.CubeSpace (ι:=Fin (v t))):=⟨rfl⟩ + let Y := (Carrier (G t) (n t) (q t) (c t) (hsk t) (A t) (w t) (hA t))⧸ + lattice (G t) (n t) (q t) (c t) (hsk t) (A t) (w t) (hA t) (Γ t) + letI : MeasurableSpace (Finset (Fin (v t))→Y):=borel _ + letI : BorelSpace (Finset (Fin (v t))→Y):=⟨rfl⟩ + ∀ (e : Fin (q t)) (j : Fin (v t)) (β : ℝ), + Measure.map (upperFace j (faceAction (G t) (n t) (q t) (c t) (hsk t) (A t) (w t) (hA t) (Γ t) + (fun _ (_ : Fin 1)=>1) e 0)) + (C.marginalCubeHaar (ι:=Fin (v t)) β (vertices (targetCoset G n q c hsk A w hA Γ B.small B.le t)) : Measure (Finset (Fin (v t))→Y))= + (C.marginalCubeHaar (ι:=Fin (v t)) β (vertices (targetCoset G n q c hsk A w hA Γ B.small B.le t)) : Measure (Finset (Fin (v t))→Y)) +end SourceIntegerArrays.GlobalJoint +end + +noncomputable section +open MeasureTheory Filter +open scoped Topology BigOperators +namespace SourcePhysicalDecay +open RationalLattice AllLevelFactorization AllLevelFactorization.Factorization +open CubeFaces CubeLocalHaar PhysicalCubeMaps SourceIntegerArrays +attribute [local instance] Classical.propDecidable +variable {Y : Type} [TopologicalSpace Y] +def AllCenteredHaar (L : ℕ→ℝ) (state : ℕ→ℤ→Y) (v : ℕ) (j : Fin v) (S : C(Y,Y)) : Prop := + letI : MeasurableSpace (Finset (Fin v)→Y):=borel _ + letI : BorelSpace (Finset (Fin v)→Y):=⟨rfl⟩ + ∀ (H : Type) [Group H] [TopologicalSpace H] [IsTopologicalGroup H], + ∀ (n s : ℕ) (c : RealCoordinates H n) (Λ : Subgroup H) + [CompactSpace (H⧸Λ)] [SecondCountableTopology (H⧸Λ)], + letI : MeasurableSpace (H⧸Λ):=borel _ + letI : BorelSpace (H⧸Λ):=⟨rfl⟩ + ∀ (K : Filtration H) (P : ℕ→ℤ→H) (F : Factorization c Λ s K P L) + (p : C(H⧸Λ,Y)), (∀ N b,p (QuotientGroup.mk (P N b))=state N b) → + ∀ (r : Fin F.period) (C : F.ResidueCover r), + letI : MeasurableSpace (C.CubeSpace (ι:=Fin v)):=borel _ + letI : BorelSpace (C.CubeSpace (ι:=Fin v)):=⟨rfl⟩ + ∀ β : ℝ, + Measure.map (upperFace j S) (C.marginalCubeHaar (ι:=Fin v) β (vertices (ι:=Fin v) p) : Measure (Finset (Fin v)→Y))= + (C.marginalCubeHaar (ι:=Fin v) β (vertices (ι:=Fin v) p) : Measure (Finset (Fin v)→Y)) + + + +theorem compatible_haar_allCenters (L : ℕ→ℝ) (hL : ∀ N,00) + have ha : ∀ i,0≤a i ∧ a i<(F.period:ℤ) := by + intro i + refine Fin.cases ?_ (fun _=>?_) i + · change 0≤(r.val:ℤ) ∧ (r.val:ℤ)<(F.period:ℤ) + exact ⟨Int.natCast_nonneg _,by exact_mod_cast r.isLt⟩ + · change (0:ℤ)≤0 ∧ (0:ℤ)<(F.period:ℤ) + exact ⟨le_rfl,by exact_mod_cast F.period_pos⟩ + let lo : ℝ→ℕ→Fin (v+1)→ℝ:=fun α N i=>(if i=0 then β-α else -α)*L (F.state.subseq N) + let hi : ℝ→ℕ→Fin (v+1)→ℝ:=fun α N i=>(if i=0 then β+α else α)*L (F.state.subseq N) + have hb : ∀ α : ℝ,0<α →∃ c₀ C₀ : ℝ,0 nlinarith + · intro i + dsimp only [lo,hi] + have hβ₁:=mul_le_mul_of_nonneg_right (le_abs_self β) hz + have hβ₂:=mul_le_mul_of_nonneg_right (neg_abs_le β) hz + have hβ₀:=mul_nonneg (abs_nonneg β) hz + split_ifs <;> constructor <;> nlinarith + have hgeo : ∀ α : ℝ,0<α →∀ᶠ N in atTop, + ∀ b∈physicalResidueRectangle (lo α N) (hi α N) a F.period,∀ u : Finset (Fin v), + dist ((cubeVertex v b u:ℝ)/L (F.state.subseq N)) β≤(v+1:ℝ)*α := by + intro α hα + apply Filter.Eventually.of_forall + intro N b hb u + have hbd:=(physicalResidueRectangle_mem _ _ _ _ _).mp hb |>.1 + have hz:=hL (F.state.subseq N) + have hbase : |(b 0:ℝ)/L (F.state.subseq N)-β|≤α := by + have hl:= (hbd 0).1 + have hh:= (hbd 0).2.le + simp [lo,hi] at hl hh + rw [abs_le] + constructor + · have hh':= (le_div_iff₀ hz).mpr hl + linarith + · have hh':= (div_le_iff₀ hz).mpr hh + linarith + have hinc (i : Fin v) : |(b i.succ:ℝ)/L (F.state.subseq N)|≤α := by + have hl:=(hbd i.succ).1 + have hh:=(hbd i.succ).2.le + simp only [lo,hi,Fin.succ_ne_zero,ite_false] at hl hh + exact abs_le.mpr ⟨(le_div_iff₀ hz).mpr hl,(div_le_iff₀ hz).mpr hh⟩ + have hsum : |∑ i∈u,(b i.succ:ℝ)/L (F.state.subseq N)|≤(v:ℝ)*α := by + calc + _ ≤ ∑ i∈u,|(b i.succ:ℝ)/L (F.state.subseq N)|:=Finset.abs_sum_le_sum_abs _ _ + _ ≤ ∑ i∈u,α:=Finset.sum_le_sum (fun i _=>hinc i) + _ = (u.card:ℝ)*α:=by simp + _ ≤ (v:ℝ)*α:=mul_le_mul_of_nonneg_right (by exact_mod_cast (show u.card≤v by simpa using Finset.card_le_univ u)) hα.le + rw [Real.dist_eq] + have he : (cubeVertex v b u:ℝ)/L (F.state.subseq N)-β= + ((b 0:ℝ)/L (F.state.subseq N)-β)+∑ i∈u,(b i.succ:ℝ)/L (F.state.subseq N) := by + simp only [cubeVertex,Int.cast_add,Int.cast_sum,add_div,Finset.sum_div] + ring + rw [he] + calc + _ ≤ |(b 0:ℝ)/L (F.state.subseq N)-β|+|∑ i∈u,(b i.succ:ℝ)/L (F.state.subseq N)|:=abs_add_le _ _ + _ ≤ α+(v:ℝ)*α:=add_le_add hbase hsum + _ = (v+1:ℝ)*α:=by ring + apply h H n s c Λ K P F p hp r C F.period F.period_pos a ha (dvd_refl _) ?_ ?_ lo hi hb β (v+1) hgeo + · simp only [a,Fin.cases_zero] + exact Int.emod_eq_of_lt (Int.natCast_nonneg _) (by exact_mod_cast r.isLt) + · intro i + simp [a] + +end SourcePhysicalDecay +end + +noncomputable section +namespace SourceIntegerArrays +open RoughArrayFace +open RationalLattice MalcevCharacters RoughFaceShift RoughTopologicalFace RoughArrayCoordinates SourceResidueAlignment +open RoughScales RoughSamplingWeights FinitePieceAverages RoughSourceExceptional RoughProductRemoval +open ProductExposureLabels ProductExposureLaw ProductExposureCutoff MeasureTheory Filter +open scoped BigOperators Topology ENNReal +attribute [local instance] Classical.propDecidable +variable {τ : Type} [Fintype τ] {ι : τ→Type} [∀ t,Fintype (ι t)] +variable (G : ∀ t,ι t→Type) [∀ t i,Group (G t i)] +variable [∀ t i,TopologicalSpace (G t i)] [∀ t i,IsTopologicalGroup (G t i)] +variable (n : ∀ t,ι t→ℕ) (q : τ→ℕ) (c : ∀ t i,RealCoordinates (G t i) (n t i)) +variable (hsk : ∀ t i,SecondKind (c t i)) (A : ∀ t i,CubeFaces.Filtration (G t i)) +variable (w : ∀ t i,Fin (n t i)→ℕ) +variable (hA : ∀ t i k (g : G t i),g∈(A t i).level k ↔ ∀ j,w t i jX N j) atTop atTop) (hXpt : Tendsto Xp atTop atTop) + (hR : ∀ N,0R N/(Xp N:ℝ)) atTop (𝓝 0)) + (hZ : ∀ t (u : ℝ),0(R N/(M N:ℝ))/ + (1+∑ j : Fin (m t),(X N (perm t (j.castAdd (h t))):ℝ)^2)^u) atTop atTop) + (hQ0 : ∀ N,0≤Q N) + (hSize : ∀ t,Tendsto (fun N=>(Q N+(∏ l : Fin (m t),(X N (perm t (l.castAdd (h t))):ℝ)^2)*(L N:ℝ))/R N) atTop (𝓝 0)) + (hWM : ∀ N,(primorial (w0 N):ℤ)∣(M N:ℤ)) + (hM : ∀ N,0(X N (perm t (j.castAdd (h t))):ℝ)/(L N:ℝ)) atTop atTop) + (g x : ∀ t,ℕ→(Fin (h t)→ℕ)→Label (m t)→∀ i,G t i) + (slot : ∀ t,ℕ→(Fin (h t)→ℕ)→Label (m t)→ι t→ℤ) + (qval : ∀ t,ℕ→(Fin (h t)→ℕ)→Label (m t)→Fin (q t)→ℤ) + (hQ : ∀ t N y,y∈outsideDomain (fun l : Fin (h t)=>X N (perm t (l.natAdd (m t)))) (primorial (w0 N)) → + ∀ b,b∈(fullDomain (fun l : Fin (m t)=>X N (perm t (l.castAdd (h t)))) (Xp N) (primorial (w0 N))).image + (expose (L N) (M N:ℤ) (R N)) →∀ k,|(qval t N y b k:ℝ)|≤Q N) + (E : ℕ→Set ((Fin a→ℕ)×ℕ)) (ε : ℝ≥0∞) (hε : 0<ε) + (hE : ∀ N,ε≤(jointLaw (X N) (Xp N) (primorial (w0 N)) (primorial_pos _) + (hX N) (hXp N)) (E N)) : + ∃ φ : ℕ→ℕ,StrictMono φ ∧ ∃ z : ℕ→(Fin a→ℕ)×ℕ, + (∀ k,z k∈E (φ k) ∧ z k∈fullDomain (X (φ k)) (Xp (φ k)) (primorial (w0 (φ k)))) ∧ + ∀ t (k : Fin (s+1)), + let zout := fun k l=>(z k).1 (perm t (l.natAdd (m t))) + let zin := fun k=>((fun l=>(z k).1 (perm t (l.castAdd (h t)))),(z k).2) + let label := fun k=>expose (L (φ k)) (M (φ k):ℤ) (R (φ k)) (zin k) + let Z := fun k=>R (φ k)/(M (φ k):ℝ) + ∀ (e : Fin (q t)) (j : Fin (k.val+1)) (pstar : ℕ→ℤ), + (∀ k,(M (φ k):ℤ)∣pstar k-((z k).2:ℤ)) → + (∀ k,|(pstar k:ℝ)-((z k).2:ℝ)|≤R (φ k)) → + let state := fun k b=>QuotientGroup.mk + (literalState (G t) (n t) (q t) (c t) (hsk t) (A t) (w t) (hA t) (hw t) + (M (φ k)) (L (φ k)) (label k) (fun l=>((zin k).1 l:ℤ)) (pstar k) + (fun _ (_ : Fin 1)=>1) + (g t (φ k) (zout k) (label k)) (x t (φ k) (zout k) (label k)) + (slot t (φ k) (zout k) (label k)) (qval t (φ k) (zout k) (label k)) (fun _=>b)) + SourcePhysicalDecay.AllCenteredHaar Z state (k.val+1) j + (faceAction (G t) (n t) (q t) (c t) (hsk t) (A t) (w t) (hA t) (Γ t) + (fun _ (_ : Fin 1)=>1) e 0) + := by + classical + obtain ⟨φ,hφ,z,hz,hgood⟩:=source_global_literal_haar + (τ:=τ×Fin (s+1)) (ι:=fun t=>ι t.1) + (fun t=>G t.1) (fun t=>n t.1) (fun t=>q t.1) (fun t=>c t.1) + (fun t=>hsk t.1) (fun t=>A t.1) (fun t=>w t.1) (fun t=>hA t.1) (fun t=>hw t.1) (fun t=>Γ t.1) + (fun t=>hΓ t.1) a (fun t=>m t.1) (fun t=>h t.1) (fun t=>t.2.val+1) + (fun t=>perm t.1) w0 M Xp X R Q L hw0 hX hXp hXt hXpt hR hRX + (fun t=>hZ t.1) hQ0 (fun t=>hSize t.1) hWM hM hMs hL hsm hWL hML hLexact + (fun t=>hXL t.1) (fun t=>g t.1) (fun t=>x t.1) (fun t=>slot t.1) (fun t=>qval t.1) + (fun t=>hQ t.1) E ε hε hE + refine ⟨φ,hφ,z,hz,?_⟩ + intro t k + dsimp only + intro e j pstar hpstar hpclose + apply SourcePhysicalDecay.compatible_haar_allCenters _ (fun N=>div_pos (hR _) (by exact_mod_cast hM _)) + exact hgood (t,k) e j pstar hpstar hpclose + +end SourceIntegerArrays + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SumProduct/Alignment/IntegerArrays04.lean b/lean/OAI/Combinatorics/SumProduct/Alignment/IntegerArrays04.lean new file mode 100644 index 0000000000000000000000000000000000000000..dc820eb39921e2c7f803a705de8959445dff11da --- /dev/null +++ b/lean/OAI/Combinatorics/SumProduct/Alignment/IntegerArrays04.lean @@ -0,0 +1,369 @@ +import Mathlib +import OAI.Combinatorics.SumProduct.Alignment.IntegerArrays03 +import OAI.Geometry.NilpotentCharts.Main + +namespace OAI + +open scoped BigOperators +noncomputable section +end + +noncomputable section +namespace SourceIntegerArrays.GlobalJoint +open RationalLattice MalcevCharacters RoughArrayFace RoughArrayCoordinates SourceResidueAlignment +open ProductExposureLabels AllLevelFactorization AllLevelFactorization.Factorization +open PhysicalCubeMaps CubeLocalHaar MeasureTheory +open scoped Topology BigOperators +attribute [local instance] Classical.propDecidable +variable {τ : Type} [Fintype τ] {ι : τ→Type} [∀ t,Fintype (ι t)] +variable (G : ∀ t,ι t→Type) [∀ t i,Group (G t i)] +variable [∀ t i,TopologicalSpace (G t i)] [∀ t i,IsTopologicalGroup (G t i)] +variable (n : ∀ t,ι t→ℕ) (q m : τ→ℕ) (c : ∀ t i,RealCoordinates (G t i) (n t i)) +variable (hsk : ∀ t i,SecondKind (c t i)) (A : ∀ t i,CubeFaces.Filtration (G t i)) +variable (w : ∀ t i,Fin (n t i)→ℕ) +variable (hA : ∀ t i k (g : G t i),g∈(A t i).level k ↔ ∀ j,w t i j(u j:ℝ)))) ∧ + ∃ F : Factorization d B.small s (FullFiltration G n q c hsk A w hA) P Z, + letI : SecondCountableTopology (Full G n q c hsk A w hA):=coordinates_secondCountable d + letI : CompactSpace ((Full G n q c hsk A w hA)⧸B.small):=AbelianMalcevTorus.quotient_compact d B.small B.integer + letI : MeasurableSpace ((Full G n q c hsk A w hA)⧸B.small):=borel _ + letI : BorelSpace ((Full G n q c hsk A w hA)⧸B.small):=⟨rfl⟩ + ∀ t (r : Fin F.period) (C : F.ResidueCover r) (ν : Fin (s+1)), + letI : MeasurableSpace (C.CubeSpace (ι:=Fin (ν.val+1))):=borel _ + letI : BorelSpace (C.CubeSpace (ι:=Fin (ν.val+1))):=⟨rfl⟩ + let Y := (Carrier (G t) (n t) (q t) (c t) (hsk t) (A t) (w t) (hA t))⧸ + lattice (G t) (n t) (q t) (c t) (hsk t) (A t) (w t) (hA t) (Γ t) + letI : MeasurableSpace (Finset (Fin (ν.val+1))→Y):=borel _ + letI : BorelSpace (Finset (Fin (ν.val+1))→Y):=⟨rfl⟩ + ∀ (e : Fin (q t)) (j : Fin (ν.val+1)) (β : ℝ), + Measure.map (upperFace j (faceAction (G t) (n t) (q t) (c t) (hsk t) (A t) (w t) (hA t) (Γ t) + (fun _ (_ : Fin 1)=>1) e 0)) + (C.marginalCubeHaar (ι:=Fin (ν.val+1)) β (vertices (targetCoset G n q c hsk A w hA Γ B.small B.le t)) : Measure (Finset (Fin (ν.val+1))→Y))= + (C.marginalCubeHaar (ι:=Fin (ν.val+1)) β (vertices (targetCoset G n q c hsk A w hA Γ B.small B.le t)) : Measure (Finset (Fin (ν.val+1))→Y)) +end SourceIntegerArrays.GlobalJoint +end + +noncomputable section +namespace SourceIntegerArrays +open GlobalJoint +open RoughArrayFace +open RationalLattice MalcevCharacters RoughFaceShift RoughTopologicalFace RoughArrayCoordinates SourceResidueAlignment +open RoughScales RoughSamplingWeights FinitePieceAverages RoughSourceExceptional RoughProductRemoval +open ProductExposureLabels ProductExposureLaw ProductExposureCutoff MeasureTheory Filter +open scoped BigOperators Topology ENNReal +attribute [local instance] Classical.propDecidable +variable {τ : Type} [Fintype τ] {ι : τ→Type} [∀ t,Fintype (ι t)] +variable (G : ∀ t,ι t→Type) [∀ t i,Group (G t i)] +variable [∀ t i,TopologicalSpace (G t i)] [∀ t i,IsTopologicalGroup (G t i)] +variable (n : ∀ t,ι t→ℕ) (q : τ→ℕ) (c : ∀ t i,RealCoordinates (G t i) (n t i)) +variable (hsk : ∀ t i,SecondKind (c t i)) (A : ∀ t i,CubeFaces.Filtration (G t i)) +variable (w : ∀ t i,Fin (n t i)→ℕ) +variable (hA : ∀ t i k (g : G t i),g∈(A t i).level k ↔ ∀ j,w t i jX N j) atTop atTop) (hXpt : Tendsto Xp atTop atTop) + (hR : ∀ N,0R N/(Xp N:ℝ)) atTop (𝓝 0)) + (hZ : ∀ t (u : ℝ),0(R N/(M N:ℝ))/ + (1+∑ j : Fin (m t),(X N (perm t (j.castAdd (h t))):ℝ)^2)^u) atTop atTop) + (hQ0 : ∀ N,0≤Q N) + (hSize : ∀ t,Tendsto (fun N=>(Q N+(∏ l : Fin (m t),(X N (perm t (l.castAdd (h t))):ℝ)^2)*(L N:ℝ))/R N) atTop (𝓝 0)) + (hWM : ∀ N,(primorial (w0 N):ℤ)∣(M N:ℤ)) + (hM : ∀ N,0(X N (perm t (j.castAdd (h t))):ℝ)/(L N:ℝ)) atTop atTop) + (g x : ∀ t,ℕ→(Fin (h t)→ℕ)→Label (m t)→∀ i,G t i) + (slot : ∀ t,ℕ→(Fin (h t)→ℕ)→Label (m t)→ι t→ℤ) + (qval : ∀ t,ℕ→(Fin (h t)→ℕ)→Label (m t)→Fin (q t)→ℤ) + (hQ : ∀ t N y,y∈outsideDomain (fun l : Fin (h t)=>X N (perm t (l.natAdd (m t)))) (primorial (w0 N)) → + ∀ b,b∈(fullDomain (fun l : Fin (m t)=>X N (perm t (l.castAdd (h t)))) (Xp N) (primorial (w0 N))).image + (expose (L N) (M N:ℤ) (R N)) →∀ k,|(qval t N y b k:ℝ)|≤Q N) + (E : ℕ→Set ((Fin a→ℕ)×ℕ)) (ε : ℝ≥0∞) (hε : 0<ε) + (hE : ∀ N,ε≤(jointLaw (X N) (Xp N) (primorial (w0 N)) (primorial_pos _) + (hX N) (hXp N)) (E N)) : + ∃ φ : ℕ→ℕ,StrictMono φ ∧ ∃ z : ℕ→(Fin a→ℕ)×ℕ, + (∀ k,z k∈E (φ k) ∧ z k∈fullDomain (X (φ k)) (Xp (φ k)) (primorial (w0 (φ k)))) ∧ + ∀ pstar : τ→ℕ→ℤ, + (∀ t k,(M (φ k):ℤ)∣pstar t k-((z k).2:ℤ)) → + (∀ t k,|(pstar t k:ℝ)-((z k).2:ℝ)|≤R (φ k)) → + let zout := fun t k l=>(z k).1 (perm t (l.natAdd (m t))) + let zin := fun t k=>((fun l=>(z k).1 (perm t (l.castAdd (h t)))),(z k).2) + let label := fun t k=>expose (L (φ k)) (M (φ k):ℤ) (R (φ k)) (zin t k) + FactorizedAllHaar G n q c hsk A w hA Γ s + (fun k=>rawJoint G n q m c hsk A w hA hw (M (φ k)) (L (φ k)) + (fun t=>label t k) (fun t l=>((zin t k).1 l:ℤ)) (fun t=>pstar t k) + (fun t=>slot t (φ k) (zout t k) (label t k)) + (fun t=>qval t (φ k) (zout t k) (label t k)) + (fun t=>g t (φ k) (zout t k) (label t k)) + (fun t=>x t (φ k) (zout t k) (label t k))) + (fun k=>R (φ k)/(M (φ k):ℝ)) + := by + classical + obtain ⟨φ,hφ,z,hz,hgood⟩:=source_global_all_order_haar G n q c hsk A w hA hw Γ hΓ + a s m h perm w0 M Xp X R Q L hw0 hX hXp hXt hXpt hR hRX hZ hQ0 hSize hWM hM hMs + hL hsm hWL hML hLexact hXL g x slot qval hQ E ε hε hE + refine ⟨φ,hφ,z,hz,?_⟩ + intro pstar hpstar hpclose + let zout := fun t k (l : Fin (h t))=>(z k).1 (perm t (l.natAdd (m t))) + let zin := fun t k=>((fun l : Fin (m t)=>(z k).1 (perm t (l.castAdd (h t)))),(z k).2) + let label := fun t k=>expose (L (φ k)) (M (φ k):ℤ) (R (φ k)) (zin t k) + let Z := fun k=>R (φ k)/(M (φ k):ℝ) + have hZp (k : ℕ) : 0rawJoint G n q m c hsk A w hA hw (M (φ k)) (L (φ k)) + (fun t=>label t k) (fun t l=>((zin t k).1 l:ℤ)) (fun t=>pstar t k) + (fun t=>slot t (φ k) (zout t k) (label t k)) + (fun t=>qval t (φ k) (zout t k) (label t k)) + (fun t=>g t (φ k) (zout t k) (label t k)) + (fun t=>x t (φ k) (zout t k) (label t k)) + change FactorizedAllHaar G n q c hsk A w hA Γ s P Z + obtain ⟨d,B,hskd,hf,hr,⟨F⟩⟩:=literal_joint_factorization + (FlatG G) (FlatN n) (FlatQ q) (FlatM m) (FlatC c) (FlatSk hsk) (FlatA A) (FlatW w) (FlatHA hA) (FlatHw hw) + (fun a=>hmono a.1 a.2) (FlatΓ Γ) (fun a=>hΓ a.1 a.2) s + (fun a=>h0 a.1 a.2) (fun a=>h1 a.1 a.2) (fun a=>hs a.1 a.2) + (fun k=>M (φ k)) (fun k=>hM (φ k)) (fun k=>L (φ k)) + (fun k b=>label b.1 k) (fun k b l=>((zin b.1 k).1 l:ℤ)) + (fun k b=>pstar b.1 k) (fun k b=>slot b.1 (φ k) (zout b.1 k) (label b.1 k) b.2) + (fun k b=>qval b.1 (φ k) (zout b.1 k) (label b.1 k)) + (fun k b=>g b.1 (φ k) (zout b.1 k) (label b.1 k) b.2) + (fun k b=>x b.1 (φ k) (zout b.1 k) (label b.1 k) b.2) Z hZp + refine ⟨d,B,hskd,hf,?_,F,?_⟩ + · intro f hf t i u + exact hr f hf ⟨t,i⟩ u + · let : SecondCountableTopology (Full G n q c hsk A w hA):=coordinates_secondCountable d + let : CompactSpace ((Full G n q c hsk A w hA)⧸B.small):=AbelianMalcevTorus.quotient_compact d B.small B.integer + let : MeasurableSpace ((Full G n q c hsk A w hA)⧸B.small):=borel _ + let : BorelSpace ((Full G n q c hsk A w hA)⧸B.small):=⟨rfl⟩ + intro t r C ν + let : MeasurableSpace (C.CubeSpace (ι:=Fin (ν.val+1))):=borel _ + let : BorelSpace (C.CubeSpace (ι:=Fin (ν.val+1))):=⟨rfl⟩ + let Y := (Carrier (G t) (n t) (q t) (c t) (hsk t) (A t) (w t) (hA t))⧸ + lattice (G t) (n t) (q t) (c t) (hsk t) (A t) (w t) (hA t) (Γ t) + let : MeasurableSpace (Finset (Fin (ν.val+1))→Y):=borel _ + let : BorelSpace (Finset (Fin (ν.val+1))→Y):=⟨rfl⟩ + dsimp only + intro e j β + have hh:=hgood t ν e j (pstar t) (hpstar t) (hpclose t) + exact hh (Full G n q c hsk A w hA) (FullDim n q w) s d B.small + (FullFiltration G n q c hsk A w hA) P F + (targetCoset G n q c hsk A w hA Γ B.small B.le t) (fun _ _=>rfl) r C β + +end SourceIntegerArrays +end + +section + + + + +noncomputable section +open Filter Topology +open scoped BoundedContinuousFunction NNReal +namespace FiniteObservableCompactness +variable {I : Type} [Fintype I] +variable (X : I → Type) [∀ i,MetricSpace (X i)] [∀ i,CompactSpace (X i)] +variable (F : ℕ → (i : I) → X i →ᵇ ℝ) (K : ℝ≥0) (B : ℝ) +variable (hLip : ∀ N i,LipschitzWith K (F N i)) +variable (hbound : ∀ N i x,|F N i x|≤B) + +include hLip hbound in + + +theorem exists_common_uniform_subsequence : + ∃ f : (i : I) → X i →ᵇ ℝ,∃ φ : ℕ → ℕ,StrictMono φ ∧ + (∀ i,TendstoUniformly (fun N=>F (φ N) i) (f i) atTop) ∧ + ∀ ε : ℝ,0<ε → ∀ᶠ N in atTop,∀ i x,|F (φ N) i x-f i x|<ε := by + let A (i : I):=Set.range (fun N=>F N i) + have hc (i : I) : IsCompact (closure (A i)) := by + apply BoundedContinuousFunction.arzela_ascoli (Set.Icc (-B) B) isCompact_Icc (A i) + · intro f x hf + obtain ⟨N,rfl⟩:=hf + exact abs_le.mp (hbound N i x) + · apply (LipschitzWith.uniformEquicontinuous (fun f : A i=> (f.val : X i → ℝ)) K ?_).equicontinuous + intro f + obtain ⟨N,hN⟩:=f.property + simpa only [←hN] using hLip N i + obtain ⟨f,hf,φ,hφ,hconv⟩:=(isCompact_pi_infinite hc).tendsto_subseq + (fun N i=>subset_closure (Set.mem_range_self N)) + have huni (i : I) : TendstoUniformly (fun N=>F (φ N) i) (f i) atTop := by + apply BoundedContinuousFunction.tendsto_iff_tendstoUniformly.mp + exact (tendsto_pi_nhds.mp hconv) i + refine ⟨f,φ,hφ,huni,?_⟩ + intro ε hε + have hi (i : I) : ∀ᶠ N in atTop,∀ x,|F (φ N) i x-f i x|<ε := by + simpa only [Real.dist_eq,abs_sub_comm] using (Metric.tendstoUniformly_iff.mp (huni i)) ε hε + exact Filter.eventually_all.mpr hi + +end FiniteObservableCompactness +end + +end + +noncomputable section +namespace SourceIntegerArrays +open RoughArrayFace +open RationalLattice MalcevCharacters RoughFaceShift RoughTopologicalFace RoughArrayCoordinates SourceResidueAlignment +open RoughScales RoughSamplingWeights FinitePieceAverages RoughSourceExceptional RoughProductRemoval +open ProductExposureLabels ProductExposureLaw ProductExposureCutoff MeasureTheory Filter +open scoped BigOperators Topology ENNReal BoundedContinuousFunction NNReal +attribute [local instance] Classical.propDecidable +variable {τ : Type} [Fintype τ] {ι : τ→Type} [∀ t,Fintype (ι t)] +variable (G : ∀ t,ι t→Type) [∀ t i,Group (G t i)] +variable [∀ t i,TopologicalSpace (G t i)] [∀ t i,IsTopologicalGroup (G t i)] +variable (n : ∀ t,ι t→ℕ) (q : τ→ℕ) (c : ∀ t i,RealCoordinates (G t i) (n t i)) +variable (hsk : ∀ t i,SecondKind (c t i)) (A : ∀ t i,CubeFaces.Filtration (G t i)) +variable (w : ∀ t i,Fin (n t i)→ℕ) +variable (hA : ∀ t i k (g : G t i),g∈(A t i).level k ↔ ∀ j,w t i jX N j) atTop atTop) (hXpt : Tendsto Xp atTop atTop) + (hR : ∀ N,0R N/(Xp N:ℝ)) atTop (𝓝 0)) + (hZ : ∀ t (u : ℝ),0(R N/(M N:ℝ))/ + (1+∑ j : Fin (m t),(X N (perm t (j.castAdd (h t))):ℝ)^2)^u) atTop atTop) + (hQ0 : ∀ N,0≤Q N) + (hSize : ∀ t,Tendsto (fun N=>(Q N+(∏ l : Fin (m t),(X N (perm t (l.castAdd (h t))):ℝ)^2)*(L N:ℝ))/R N) atTop (𝓝 0)) + (hWM : ∀ N,(primorial (w0 N):ℤ)∣(M N:ℤ)) + (hM : ∀ N,0(X N (perm t (j.castAdd (h t))):ℝ)/(L N:ℝ)) atTop atTop) + (g x : ∀ t,ℕ→(Fin (h t)→ℕ)→Label (m t)→∀ i,G t i) + (slot : ∀ t,ℕ→(Fin (h t)→ℕ)→Label (m t)→ι t→ℤ) + (qval : ∀ t,ℕ→(Fin (h t)→ℕ)→Label (m t)→Fin (q t)→ℤ) + (hQ : ∀ t N y,y∈outsideDomain (fun l : Fin (h t)=>X N (perm t (l.natAdd (m t)))) (primorial (w0 N)) → + ∀ b,b∈(fullDomain (fun l : Fin (m t)=>X N (perm t (l.castAdd (h t)))) (Xp N) (primorial (w0 N))).image + (expose (L N) (M N:ℤ) (R N)) →∀ k,|(qval t N y b k:ℝ)|≤Q N) + {κ : Type} [Fintype κ] (Yobs : κ→Type) [∀ i,MetricSpace (Yobs i)] [∀ i,CompactSpace (Yobs i)] + (Obs : ℕ→((Fin a→ℕ)×ℕ)→(i : κ)→Yobs i →ᵇ ℝ) (Kobs : ℝ≥0) (Bobs : ℝ) + (hLip : ∀ N z i,LipschitzWith Kobs (Obs N z i)) + (hBound : ∀ N z i y,|Obs N z i y|≤Bobs) + (E : ℕ→Set ((Fin a→ℕ)×ℕ)) (ε : ℝ≥0∞) (hε : 0<ε) + (hE : ∀ N,ε≤(jointLaw (X N) (Xp N) (primorial (w0 N)) (primorial_pos _) + (hX N) (hXp N)) (E N)) : + ∃ φ : ℕ→ℕ,StrictMono φ ∧ ∃ z : ℕ→(Fin a→ℕ)×ℕ, + (∀ k,z k∈E (φ k) ∧ z k∈fullDomain (X (φ k)) (Xp (φ k)) (primorial (w0 (φ k)))) ∧ + ∃ f : (i : κ)→Yobs i →ᵇ ℝ, + (∀ i,TendstoUniformly (fun k=>Obs (φ k) (z k) i) (f i) atTop) ∧ + (∀ η : ℝ,0<η →∀ᶠ k in atTop,∀ i y,|Obs (φ k) (z k) i y-f i y|<η) ∧ + ∀ t (k : Fin (s+1)), + let zout := fun k l=>(z k).1 (perm t (l.natAdd (m t))) + let zin := fun k=>((fun l=>(z k).1 (perm t (l.castAdd (h t)))),(z k).2) + let label := fun k=>expose (L (φ k)) (M (φ k):ℤ) (R (φ k)) (zin k) + let Z := fun k=>R (φ k)/(M (φ k):ℝ) + ∀ (e : Fin (q t)) (j : Fin (k.val+1)) (pstar : ℕ→ℤ), + (∀ k,(M (φ k):ℤ)∣pstar k-((z k).2:ℤ)) → + (∀ k,|(pstar k:ℝ)-((z k).2:ℝ)|≤R (φ k)) → + let state := fun k b=>QuotientGroup.mk + (literalState (G t) (n t) (q t) (c t) (hsk t) (A t) (w t) (hA t) (hw t) + (M (φ k)) (L (φ k)) (label k) (fun l=>((zin k).1 l:ℤ)) (pstar k) + (fun _ (_ : Fin 1)=>1) + (g t (φ k) (zout k) (label k)) (x t (φ k) (zout k) (label k)) + (slot t (φ k) (zout k) (label k)) (qval t (φ k) (zout k) (label k)) (fun _=>b)) + SourcePhysicalDecay.AllCenteredHaar Z state (k.val+1) j + (faceAction (G t) (n t) (q t) (c t) (hsk t) (A t) (w t) (hA t) (Γ t) + (fun _ (_ : Fin 1)=>1) e 0) + := by + classical + obtain ⟨φ,hφ,z,hz,hgood⟩:=source_global_literal_cube_faces + (τ:=τ×Fin (s+1)) (ι:=fun t=>ι t.1) + (fun t=>G t.1) (fun t=>n t.1) (fun t=>q t.1) (fun t=>c t.1) + (fun t=>hsk t.1) (fun t=>A t.1) (fun t=>w t.1) (fun t=>hA t.1) (fun t=>hw t.1) (fun t=>Γ t.1) + (fun t=>hΓ t.1) a (fun t=>m t.1) (fun t=>h t.1) (fun t=>t.2.val+1) + (fun t=>perm t.1) w0 M Xp X R Q L hw0 hX hXp hXt hXpt hR hRX + (fun t=>hZ t.1) hQ0 (fun t=>hSize t.1) hWM hM hMs hL hsm hWL hML hLexact + (fun t=>hXL t.1) (fun t=>g t.1) (fun t=>x t.1) (fun t=>slot t.1) (fun t=>qval t.1) + (fun t=>hQ t.1) E ε hε hE + obtain ⟨f,ψ,hψ,huniform,herror⟩:=FiniteObservableCompactness.exists_common_uniform_subsequence + Yobs (fun k=>Obs (φ k) (z k)) Kobs Bobs (fun k=>hLip (φ k) (z k)) (fun k=>hBound (φ k) (z k)) + refine ⟨φ∘ψ,hφ.comp hψ,z∘ψ,fun k=>hz (ψ k),f,huniform,herror,?_⟩ + intro t ν + dsimp only + intro e j pstar hpstar hpclose + let pstar' : ℕ→ℤ:=Function.extend ψ pstar (fun k=>(z k).2) + have hext (k : ℕ) : pstar' (ψ k)=pstar k:=hψ.injective.extend_apply _ _ _ + have hcong (k : ℕ) : (M (φ k):ℤ)∣pstar' k-((z k).2:ℤ) := by + by_cases hn : ∃ l,ψ l=k + · obtain ⟨l,rfl⟩:=hn + rw [hext] + exact hpstar l + · have he : pstar' k=((z k).2:ℤ):=Function.extend_apply' _ _ _ hn + rw [he,sub_self] + exact dvd_zero _ + have hnear (k : ℕ) : |(pstar' k:ℝ)-((z k).2:ℝ)|≤R (φ k) := by + by_cases hn : ∃ l,ψ l=k + · obtain ⟨l,rfl⟩:=hn + rw [hext] + exact hpclose l + · have he : pstar' k=((z k).2:ℤ):=Function.extend_apply' _ _ _ hn + rw [he,Int.cast_natCast,sub_self,abs_zero] + exact (hR _).le + let zout := fun k (l : Fin (h t))=>(z k).1 (perm t (l.natAdd (m t))) + let zin := fun k=>((fun l : Fin (m t)=>(z k).1 (perm t (l.castAdd (h t)))),(z k).2) + let lab := fun k=>expose (L (φ k)) (M (φ k):ℤ) (R (φ k)) (zin k) + let Y := (Carrier (G t) (n t) (q t) (c t) (hsk t) (A t) (w t) (hA t))⧸ + lattice (G t) (n t) (q t) (c t) (hsk t) (A t) (w t) (hA t) (Γ t) + let state : ℕ→ℤ→Y := fun k b=>QuotientGroup.mk + (literalState (G t) (n t) (q t) (c t) (hsk t) (A t) (w t) (hA t) (hw t) + (M (φ k)) (L (φ k)) (lab k) (fun l=>((zin k).1 l:ℤ)) (pstar' k) + (fun _ (_ : Fin 1)=>1) (g t (φ k) (zout k) (lab k)) (x t (φ k) (zout k) (lab k)) + (slot t (φ k) (zout k) (lab k)) (qval t (φ k) (zout k) (lab k)) (fun _=>b)) + let S:=faceAction (G t) (n t) (q t) (c t) (hsk t) (A t) (w t) (hA t) (Γ t) + (fun _ (_ : Fin 1)=>1) e 0 + let Z := fun k=>R (φ k)/(M (φ k):ℝ) + have hZp (k : ℕ) : 0(R N/(M N:ℝ))/ + (1+∑ j : Fin (m t),(X N (perm t (j.castAdd (h t))):ℝ)^2)) atTop atTop := by + simpa only [Real.rpow_one] using hZ t 1 zero_lt_one + have ht' := ht.comp hφ.tendsto_atTop + apply tendsto_atTop.mpr + intro B + filter_upwards [ht'.eventually (eventually_ge_atTop B)] with N hN + apply hN.trans + apply div_le_self (hZp N).le + have hn : 0≤∑ j : Fin (m t),(X (φ N) (perm t (j.castAdd (h t))):ℝ)^2:= + Finset.sum_nonneg (fun _ _=>sq_nonneg _) + linarith + have hboxes : SourcePhysicalDecay.AllBoxes Z + (fun N b w=>state N (cubeVertex (ν.val+1) b w)) (PhysicalCubeMaps.upperFace j S) := by + intro d hd c₀ C₀ hc₀ hC₀ lo hi res hbox F + exact hgood (t,ν) e j d hd pstar' hcong hnear c₀ C₀ hc₀ hC₀ lo hi res hbox F + have hsub:=SourcePhysicalDecay.allBoxes_subsequence Z (fun k=>(hZp k).le) _ _ hboxes ψ hψ + have htop:=joint_array_topology (G t) (n t) (q t) (c t) (hsk t) (A t) (w t) (hA t) (hw t) (Γ t) (hΓ t) + let : CompactSpace Y:=htop.2.2.1 + let : TopologicalSpace.MetrizableSpace Y:=htop.2.2.2 + have hhaar:=SourcePhysicalDecay.compatible_haar_of_allBoxes (Z∘ψ) (fun k=>hZp (ψ k)) + (hZT.comp hψ.tendsto_atTop) (state∘ψ) (ν.val+1) j S hsub + have hcent:=SourcePhysicalDecay.compatible_haar_allCenters (Z∘ψ) (fun k=>hZp (ψ k)) + (state∘ψ) (ν.val+1) j S hhaar + simpa only [Function.comp_def,state,zout,zin,lab,Z,S,hext] using hcent + +end SourceIntegerArrays + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SumProduct/Alignment/IntegerArrays05.lean b/lean/OAI/Combinatorics/SumProduct/Alignment/IntegerArrays05.lean new file mode 100644 index 0000000000000000000000000000000000000000..523247757da4bb8d5077f4eaac5ed7a445db3366 --- /dev/null +++ b/lean/OAI/Combinatorics/SumProduct/Alignment/IntegerArrays05.lean @@ -0,0 +1,338 @@ +import Mathlib +import OAI.Combinatorics.SumProduct.Alignment.RationalLattice23 +import OAI.Combinatorics.SumProduct.Alignment.WordPlan04 +import OAI.Combinatorics.SumProduct.Alignment.AllLevel15 +import OAI.Geometry.NilpotentCharts.Main + +namespace OAI + +open scoped BigOperators +section +section +noncomputable section +open MeasureTheory Filter Topology +open scoped NNReal ENNReal +end + +end + +noncomputable section +namespace SourceIntegerArrays.GlobalJoint +open RationalLattice MalcevCharacters RoughArrayFace RoughArrayCoordinates +open ConstructedWordPlan.GlobalWordPlan +open scoped BigOperators +attribute [local instance] Classical.propDecidable +variable {a : ℕ} (D : Pivot a) {ι : Fin D.targets→Type} [∀ t,Fintype (ι t)] +variable (G : ∀ t,ι t→Type) [∀ t i,Group (G t i)] +variable [∀ t i,TopologicalSpace (G t i)] [∀ t i,IsTopologicalGroup (G t i)] +variable (n : ∀ t,ι t→ℕ) (q : Fin D.targets→ℕ) (c : ∀ t i,RealCoordinates (G t i) (n t i)) +variable (hsk : ∀ t i,SecondKind (c t i)) (A : ∀ t i,CubeFaces.Filtration (G t i)) +variable (w : ∀ t i,Fin (n t i)→ℕ) +variable (hA : ∀ t i k (g : G t i),g∈(A t i).level k ↔ ∀ j,w t i j(v j:ℝ)) (f i) + map_one':=by funext i;exact map_one _ + map_mul' _ _:=by funext i;exact map_mul _ _ _ + +omit [∀ t, Fintype (ι t)] in +private lemma shiftAll_continuous (t : Fin D.targets) (v : Fin (q t)→ℤ) : + Continuous (shiftAll D G n q c hsk A w hA t v) := + continuous_pi (fun i=>(PolynomialArrays.shift_continuous (c t i) (hsk t i) (A t i) (w t i) (hA t i) _).comp + (continuous_apply i)) + +private def translateTarget (t : Fin D.targets) (v : Fin (q t)→ℤ) : + Target D G n q c hsk A w hA Γ t → Target D G n q c hsk A w hA Γ t := + Quotient.map (shiftAll D G n q c hsk A w hA t v) (by + intro f g hfg + apply QuotientGroup.leftRel_apply.mpr + rw [← map_inv,← map_mul] + intro i + exact (PolynomialArrays.shift_lattice (c t i) (hsk t i) (A t i) (w t i) (hA t i) (Γ t i) v _).mpr + ((QuotientGroup.leftRel_apply.mp hfg) i)) + +omit [∀ t,Fintype (ι t)] in +private lemma translateTarget_continuous (t : Fin D.targets) (v : Fin (q t)→ℤ) : + Continuous (translateTarget D G n q c hsk A w hA Γ t v) := + (QuotientGroup.isQuotientMap_mk _).continuous_iff.mpr + (QuotientGroup.continuous_mk.comp (shiftAll_continuous D G n q c hsk A w hA t v)) + +omit [∀ t, Fintype (ι t)] in +private lemma translateTarget_add (t : Fin D.targets) (v z : Fin (q t)→ℤ) + (x : Target D G n q c hsk A w hA Γ t) : + translateTarget D G n q c hsk A w hA Γ t (v+z) x= + translateTarget D G n q c hsk A w hA Γ t v (translateTarget D G n q c hsk A w hA Γ t z x) := by + induction x using Quotient.inductionOn with | h f => + apply congrArg QuotientGroup.mk + funext i + apply Subtype.ext + funext u + change (f i).val (u+(fun j=>((v+z) j:ℝ)))=(f i).val ((u+(fun j=>(v j:ℝ)))+(fun j=>(z j:ℝ))) + apply congrArg (f i).val + funext j + simp only [Pi.add_apply,Int.cast_add] + ring + +omit [∀ t, Fintype (ι t)] in +private lemma translateTarget_zero (t : Fin D.targets) (x : Target D G n q c hsk A w hA Γ t) : + translateTarget D G n q c hsk A w hA Γ t 0 x=x := by + induction x using Quotient.inductionOn with | h f => + apply congrArg QuotientGroup.mk + funext i + apply Subtype.ext + funext u + change (f i).val (u+(fun _=>((0:ℤ):ℝ)))=(f i).val u + apply congrArg (f i).val + funext j + simp + +@[instance_reducible] +private def targetAction (t : Fin D.targets) : MulAction (Shifts D) (Target D G n q c hsk A w hA Γ t) where + smul v x:=translateTarget D G n q c hsk A w hA Γ t (slotProjection D q coord t v.toAdd) x + one_smul x:=by + change translateTarget D G n q c hsk A w hA Γ t (slotProjection D q coord t 0) x=x + rw [map_zero,translateTarget_zero] + mul_smul v z x:=by + change translateTarget D G n q c hsk A w hA Γ t (slotProjection D q coord t (v.toAdd+z.toAdd)) x=_ + rw [map_add,translateTarget_add] + rfl + + +omit [∀ t,Fintype (ι t)] in +theorem target_actions : + ∃ act : ∀ t,MulAction (Shifts D) (Target D G n q c hsk A w hA Γ t), + (∀ t (v : Shifts D),letI:=act t;Continuous (fun x : Target D G n q c hsk A w hA Γ t=>v • x)) ∧ + (∀ e x,letI:=act (D.owner e); + unitShift D e • x = faceAction (G (D.owner e)) (n (D.owner e)) (q (D.owner e)) + (c (D.owner e)) (hsk (D.owner e)) (A (D.owner e)) (w (D.owner e)) (hA (D.owner e)) (Γ (D.owner e)) + (fun _ (_ : Fin 1)=>1) (coord e) 0 x) + := by + classical + refine ⟨targetAction D G n q c hsk A w hA Γ coord,?_,?_⟩ + · intro t v + exact translateTarget_continuous D G n q c hsk A w hA Γ t _ + · intro e x + change translateTarget D G n q c hsk A w hA Γ (D.owner e) + (slotProjection D q coord (D.owner e) (Pi.single e 1)) x=_ + rw [slotProjection_unit] + induction x using Quotient.inductionOn with | h f => rfl + +end SourceIntegerArrays.GlobalJoint +end + +noncomputable section +namespace SourceIntegerArrays.GlobalJoint +open RationalLattice MalcevCharacters RoughArrayFace RoughArrayCoordinates +open ConstructedWordPlan.GlobalWordPlan +open AllLevelFactorization AllLevelFactorization.Factorization MeasureTheory +open scoped BigOperators Topology +attribute [local instance] Classical.propDecidable +variable {a : ℕ} (D : Pivot a) {ι : Fin D.targets→Type} [∀ t,Fintype (ι t)] +variable (G : ∀ t,ι t→Type) [∀ t i,Group (G t i)] +variable [∀ t i,TopologicalSpace (G t i)] [∀ t i,IsTopologicalGroup (G t i)] +variable (n : ∀ t,ι t→ℕ) (q : Fin D.targets→ℕ) (c : ∀ t i,RealCoordinates (G t i) (n t i)) +variable (hsk : ∀ t i,SecondKind (c t i)) (A : ∀ t i,CubeFaces.Filtration (G t i)) +variable (w : ∀ t i,Fin (n t i)→ℕ) +variable (hA : ∀ t i k (g : G t i),g∈(A t i).level k ↔ ∀ j,w t i j(u j:ℝ)))) ∧ + ∃ F : Factorization d B.small s (FullFiltration G n q c hsk A w hA) P Z, + ∃ act : ∀ t,MulAction (Shifts D) (Target D G n q c hsk A w hA Γ t), + (∀ t (v : Shifts D),letI:=act t;Continuous (fun x : Target D G n q c hsk A w hA Γ t=>v • x)) ∧ + (∀ e x,letI:=act (D.owner e); + unitShift D e • x = faceAction (G (D.owner e)) (n (D.owner e)) (q (D.owner e)) + (c (D.owner e)) (hsk (D.owner e)) (A (D.owner e)) (w (D.owner e)) (hA (D.owner e)) (Γ (D.owner e)) + (fun _ (_ : Fin 1)=>1) (coord e) 0 x) ∧ + letI : ∀ t,MulAction (Shifts D) (Target D G n q c hsk A w hA Γ t):=act + ∀ (r : Fin F.period) (C : F.ResidueCover r) (β : ℝ), + Nonempty (CoveredPhysicalData D C.pivotChart.chart C.pointFiltration C.pointLattice + (fun t=>targetCoset G n q c hsk A w hA Γ B.small B.le t) (C.pivotImage β) s) +include hw coord in + + +theorem factorized_physical + (hmono : ∀ t i,Monotone (w t i)) + (hΓ : ∀ t i g,g∈Γ t i ↔ ∀ j,∃ z : ℤ,(c t i).coord g j=z) + (s : ℕ) (P : ℕ→ℤ→Full G n q c hsk A w hA) (Z : ℕ→ℝ) + (hh : FactorizedAllHaar G n q c hsk A w hA Γ s P Z) : + FactorizedPhysical D G n q c hsk A w hA Γ coord s P Z + := by + classical + obtain ⟨d,B,hd,hfil,hrational,F,hhaar⟩:=hh + obtain ⟨dc,cover,hdc,hrat⟩:=target_geometry G n q c hsk A w hA hw Γ hmono hΓ d B hd + obtain ⟨act,hcont,hunit⟩:=target_actions D G n q c hsk A w hA Γ coord + refine ⟨d,B,hd,hfil,hrational,F,act,hcont,hunit,?_⟩ + let : ∀ t,MulAction (Shifts D) (Target D G n q c hsk A w hA Γ t):=act + let : SecondCountableTopology (Full G n q c hsk A w hA):=coordinates_secondCountable d + let : CompactSpace ((Full G n q c hsk A w hA)⧸B.small):=AbelianMalcevTorus.quotient_compact d B.small B.integer + let : MeasurableSpace ((Full G n q c hsk A w hA)⧸B.small):=borel _ + let : BorelSpace ((Full G n q c hsk A w hA)⧸B.small):=⟨rfl⟩ + let Y:=Target D G n q c hsk A w hA Γ + have htop (t) := joint_array_topology (G t) (n t) (q t) (c t) (hsk t) (A t) (w t) (hA t) (hw t) (Γ t) (hΓ t) + let : ∀ t,SecondCountableTopology (Y t):=fun t=>(htop t).1 + let : ∀ t,T2Space (Y t):=fun t=>(htop t).2.1 + let : ∀ t,CompactSpace (Y t):=fun t=>(htop t).2.2.1 + let : ∀ t,TopologicalSpace.MetrizableSpace (Y t):=fun t=>(htop t).2.2.2 + let : ∀ t,MeasurableSpace (Y t):=fun t=>borel _ + let : ∀ t,BorelSpace (Y t):=fun t=>⟨rfl⟩ + intro r C β + let : ∀ k : ℕ,MeasurableSpace (C.CubeSpace (ι:=Fin (k+1))):=fun _=>borel _ + let : ∀ k : ℕ,BorelSpace (C.CubeSpace (ι:=Fin (k+1))):=fun _=>⟨rfl⟩ + let TG t:=Carrier (G t) (n t) (q t) (c t) (hsk t) (A t) (w t) (hA t) + let Λ t:=lattice (G t) (n t) (q t) (c t) (hsk t) (A t) (w t) (hA t) (Γ t) + let sym (e : Fin D.pairs) := faceMap (G (D.owner e)) (n (D.owner e)) (q (D.owner e)) + (c (D.owner e)) (hsk (D.owner e)) (A (D.owner e)) (w (D.owner e)) (hA (D.owner e)) + (fun _ (_ : Fin 1)=>1) (coord e) 0 + have hsym (e) : Continuous (sym e):=faceMap_continuous _ _ _ _ _ _ _ _ _ _ _ + have hsymΛ (e) (g : TG (D.owner e)) (hg : g∈Λ (D.owner e)) : sym e g∈Λ (D.owner e) := by + intro i + exact (PolynomialArrays.shift_lattice _ _ _ _ _ _ _ _).mpr (hg i) + have hown (e) (f : TG (D.owner e)) : + (QuotientGroup.mk (sym e f) : Y (D.owner e))=unitShift D e • (QuotientGroup.mk f : Y (D.owner e)) := by + exact (hunit e (QuotientGroup.mk f)).symm + refine ⟨C.physicalData_of_haar D (fun t=>targetCoset G n q c hsk A w hA Γ B.small B.le t) + TG (fun t=>Fintype.card (FiniteProducts.Index (JointArrays.dimension (n t) (fun _=>q t) (w t)))) + dc Λ cover (targetHom G n q c hsk A w hA) (targetHom_continuous G n q c hsk A w hA) + (fun t g hg=>targetHom_lattice G n q c hsk A w hA Γ t g (B.le hg)) hrat + (fun _ x=>x) (fun _ _=>rfl) sym hsym hsymΛ hown β ?_⟩ + intro e k hk + have ht (m : MeasurableSpace (Finset (Fin (k+1))→Y (D.owner e))) + (hm : @BorelSpace (Finset (Fin (k+1))→Y (D.owner e)) _ m) : + letI:=m + letI:=hm + Measure.map (PhysicalCubeMaps.upperFace (Fin.last k) + (faceAction (G (D.owner e)) (n (D.owner e)) (q (D.owner e)) (c (D.owner e)) + (hsk (D.owner e)) (A (D.owner e)) (w (D.owner e)) (hA (D.owner e)) (Γ (D.owner e)) + (fun _ (_ : Fin 1)=>1) (coord e) 0)) + (C.marginalCubeHaar (ι:=Fin (k+1)) β (PhysicalCubeMaps.vertices (ι:=Fin (k+1)) (targetCoset G n q c hsk A w hA Γ B.small B.le (D.owner e))) + : Measure (Finset (Fin (k+1))→Y (D.owner e)))= + (C.marginalCubeHaar (ι:=Fin (k+1)) β (PhysicalCubeMaps.vertices (ι:=Fin (k+1)) (targetCoset G n q c hsk A w hA Γ B.small B.le (D.owner e))) + : Measure (Finset (Fin (k+1))→Y (D.owner e))) := by + have he:=hm.measurable_eq + subst m + exact hhaar (D.owner e) r C ⟨k,Nat.lt_succ_of_le hk⟩ (coord e) (Fin.last k) β + exact ht _ inferInstance + +end SourceIntegerArrays.GlobalJoint +end + +noncomputable section +namespace SourceIntegerArrays +open GlobalJoint +open RoughArrayFace +open RationalLattice MalcevCharacters RoughFaceShift RoughTopologicalFace RoughArrayCoordinates SourceResidueAlignment +open RoughScales RoughSamplingWeights FinitePieceAverages RoughSourceExceptional RoughProductRemoval +open ProductExposureLabels ProductExposureLaw ProductExposureCutoff MeasureTheory Filter +open scoped BigOperators Topology ENNReal BoundedContinuousFunction NNReal +attribute [local instance] Classical.propDecidable +open ConstructedWordPlan.GlobalWordPlan +variable {a₀ : ℕ} (D : Pivot a₀) {ι : Fin D.targets→Type} [∀ t,Fintype (ι t)] +variable (G : ∀ t,ι t→Type) [∀ t i,Group (G t i)] +variable [∀ t i,TopologicalSpace (G t i)] [∀ t i,IsTopologicalGroup (G t i)] +variable (n : ∀ t,ι t→ℕ) (q : Fin D.targets→ℕ) (c : ∀ t i,RealCoordinates (G t i) (n t i)) +variable (hsk : ∀ t i,SecondKind (c t i)) (A : ∀ t i,CubeFaces.Filtration (G t i)) +variable (w : ∀ t i,Fin (n t i)→ℕ) +variable (hA : ∀ t i k (g : G t i),g∈(A t i).level k ↔ ∀ j,w t i jX N j) atTop atTop) (hXpt : Tendsto Xp atTop atTop) + (hR : ∀ N,0R N/(Xp N:ℝ)) atTop (𝓝 0)) + (hZ : ∀ t (u : ℝ),0(R N/(M N:ℝ))/ + (1+∑ j : Fin (m t),(X N (perm t (j.castAdd (h t))):ℝ)^2)^u) atTop atTop) + (hQ0 : ∀ N,0≤Q N) + (hSize : ∀ t,Tendsto (fun N=>(Q N+(∏ l : Fin (m t),(X N (perm t (l.castAdd (h t))):ℝ)^2)*(L N:ℝ))/R N) atTop (𝓝 0)) + (hWM : ∀ N,(primorial (w0 N):ℤ)∣(M N:ℤ)) + (hM : ∀ N,0(X N (perm t (j.castAdd (h t))):ℝ)/(L N:ℝ)) atTop atTop) + (g x : ∀ t,ℕ→(Fin (h t)→ℕ)→Label (m t)→∀ i,G t i) + (slot : ∀ t,ℕ→(Fin (h t)→ℕ)→Label (m t)→ι t→ℤ) + (qval : ∀ t,ℕ→(Fin (h t)→ℕ)→Label (m t)→Fin (q t)→ℤ) + (hQ : ∀ t N y,y∈outsideDomain (fun l : Fin (h t)=>X N (perm t (l.natAdd (m t)))) (primorial (w0 N)) → + ∀ b,b∈(fullDomain (fun l : Fin (m t)=>X N (perm t (l.castAdd (h t)))) (Xp N) (primorial (w0 N))).image + (expose (L N) (M N:ℤ) (R N)) →∀ k,|(qval t N y b k:ℝ)|≤Q N) + {κ : Type} [Fintype κ] (Yobs : κ→Type) [∀ i,MetricSpace (Yobs i)] [∀ i,CompactSpace (Yobs i)] + (Obs : ℕ→((Fin a→ℕ)×ℕ)→(i : κ)→Yobs i →ᵇ ℝ) (Kobs : ℝ≥0) (Bobs : ℝ) + (hLip : ∀ N z i,LipschitzWith Kobs (Obs N z i)) + (hBound : ∀ N z i y,|Obs N z i y|≤Bobs) + (E : ℕ→Set ((Fin a→ℕ)×ℕ)) (ε : ℝ≥0∞) (hε : 0<ε) + (hE : ∀ N,ε≤(jointLaw (X N) (Xp N) (primorial (w0 N)) (primorial_pos _) + (hX N) (hXp N)) (E N)) : + ∃ φ : ℕ→ℕ,StrictMono φ ∧ ∃ z : ℕ→(Fin a→ℕ)×ℕ, + (∀ k,z k∈E (φ k) ∧ z k∈fullDomain (X (φ k)) (Xp (φ k)) (primorial (w0 (φ k)))) ∧ + ∃ f : (i : κ)→Yobs i →ᵇ ℝ, + (∀ i,TendstoUniformly (fun k=>Obs (φ k) (z k) i) (f i) atTop) ∧ + (∀ η : ℝ,0<η →∀ᶠ k in atTop,∀ i y,|Obs (φ k) (z k) i y-f i y|<η) ∧ + ∀ pstar : Fin D.targets→ℕ→ℤ, + (∀ t k,(M (φ k):ℤ)∣pstar t k-((z k).2:ℤ)) → + (∀ t k,|(pstar t k:ℝ)-((z k).2:ℝ)|≤R (φ k)) → + let zout := fun t k l=>(z k).1 (perm t (l.natAdd (m t))) + let zin := fun t k=>((fun l=>(z k).1 (perm t (l.castAdd (h t)))),(z k).2) + let label := fun t k=>expose (L (φ k)) (M (φ k):ℤ) (R (φ k)) (zin t k) + FactorizedPhysical D G n q c hsk A w hA Γ coord s + (fun k=>rawJoint G n q m c hsk A w hA hw (M (φ k)) (L (φ k)) + (fun t=>label t k) (fun t l=>((zin t k).1 l:ℤ)) (fun t=>pstar t k) + (fun t=>slot t (φ k) (zout t k) (label t k)) + (fun t=>qval t (φ k) (zout t k) (label t k)) + (fun t=>g t (φ k) (zout t k) (label t k)) + (fun t=>x t (φ k) (zout t k) (label t k))) + (fun k=>R (φ k)/(M (φ k):ℝ)) := by + classical + obtain ⟨φ,hφ,z,hz,f,huniform,herror,hgood⟩:=source_compact_factorized_haar G n q c hsk A w hA hw Γ + hΓ hmono s h0 h1 hs a m h perm w0 M Xp X R Q L hw0 hX hXp hXt hXpt hR hRX hZ hQ0 + hSize hWM hM hMs hL hsm hWL hML hLexact hXL g x slot qval hQ Yobs Obs Kobs Bobs hLip hBound E ε hε hE + refine ⟨φ,hφ,z,hz,f,huniform,herror,?_⟩ + intro pstar hpstar hpclose + exact factorized_physical D G n q c hsk A w hA hw Γ coord hmono hΓ s _ _ (hgood pstar hpstar hpclose) + +end SourceIntegerArrays + +end +end + +end OAI diff --git a/lean/OAI/Combinatorics/SumProduct/Alignment/IntegerArrays06.lean b/lean/OAI/Combinatorics/SumProduct/Alignment/IntegerArrays06.lean new file mode 100644 index 0000000000000000000000000000000000000000..42187fcbb16faec3eafec33c1cd4113233b35ca3 --- /dev/null +++ b/lean/OAI/Combinatorics/SumProduct/Alignment/IntegerArrays06.lean @@ -0,0 +1,297 @@ +import Mathlib +import OAI.Combinatorics.SumProduct.Alignment.IntegerArrays05 +import OAI.Geometry.NilpotentCharts.Main + +namespace OAI + +open scoped BigOperators +section +noncomputable section +end + +noncomputable section +namespace SourceIntegerArrays.GlobalJoint +open RationalLattice MalcevCharacters RoughArrayFace RoughArrayCoordinates +open ConstructedWordPlan.GlobalWordPlan +open AllLevelFactorization AllLevelFactorization.Factorization MeasureTheory +open ConstructedWordPlan.AlignmentScales ConstructedWordPlan.RationalPivotPlan +open Filter +open scoped BigOperators Topology NNReal ENNReal BoundedContinuousFunction +attribute [local instance] Classical.propDecidable +variable {a : ℕ} (D : Pivot a) {ι : Fin D.targets→Type} [∀ t,Fintype (ι t)] +variable (G : ∀ t,ι t→Type) [∀ t i,Group (G t i)] +variable [∀ t i,TopologicalSpace (G t i)] [∀ t i,IsTopologicalGroup (G t i)] +variable (n : ∀ t,ι t→ℕ) (q : Fin D.targets→ℕ) (c : ∀ t i,RealCoordinates (G t i) (n t i)) +variable (hsk : ∀ t i,SecondKind (c t i)) (A : ∀ t i,CubeFaces.Filtration (G t i)) +variable (w : ∀ t i,Fin (n t i)→ℕ) +variable (hA : ∀ t i k (g : G t i),g∈(A t i).level k ↔ ∀ j,w t i j(f i).val (fun j=>(u j:ℝ)),map_one':=rfl,map_mul':=fun _ _=>rfl} + ((PolynomialArrays.evaluate_continuous (c t i) (hsk t i) (A t i) (w t i) (hA t i) _).comp (continuous_apply i)) + (fun _ hf=>hf i u) + + + +def modelRead {r : ℕ} + (formula : ∀ t,ℚ→Slots D→Fin r→ι t) + (f : ∀ t i,((G t i)⧸Γ t i) →ᵇ ℝ) : + (t : Fin D.targets)→ℚ→Target D G n q c hsk A w hA Γ t × Slots D→Fin r→ℝ := + fun t a y col=>f t (formula t a y.2 col) + (modelEval D G n q c hsk A w hA Γ t (formula t a y.2 col) 0 y.1) + +omit [∀ t,Fintype (ι t)] in +lemma modelRead_continuous {r : ℕ} (formula : ∀ t,ℚ→Slots D→Fin r→ι t) + (f : ∀ t i,((G t i)⧸Γ t i) →ᵇ ℝ) (t : Fin D.targets) (a : ℚ) (col : Fin r) : + Continuous (fun y=>modelRead D G n q c hsk A w hA Γ formula f t a y col) := by + apply continuous_prod_of_discrete_right.mpr + intro v + exact (f t (formula t a v col)).continuous.comp (modelEval D G n q c hsk A w hA Γ t (formula t a v col) 0).continuous + +def FactorizedEmpirical (coord : ∀ e,Fin (q (D.owner e))) (s : ℕ) (P : ℕ→ℤ→Full G n q c hsk A w hA) (Z : ℕ→ℝ) + (Obs : ℕ→∀ t i,((G t i)⧸Γ t i) →ᵇ ℝ) : Prop := + ∃ d : RealCoordinates (Full G n q c hsk A w hA) (FullDim n q w), + ∃ B : CoveredLattice d (FullLattice G n q c hsk A w hA Γ), + SecondKind d ∧ + (∀ k f,f∈(FullFiltration G n q c hsk A w hA).level k ↔ + ∀ j,JointArrays.jointWeight (FlatN n) (FlatQ q) (FlatW w) j(u j:ℝ)))) ∧ + ∃ F : Factorization d B.small s (FullFiltration G n q c hsk A w hA) P Z, + ∃ act : ∀ t,MulAction (Shifts D) (Target D G n q c hsk A w hA Γ t), + (∀ t (v : Shifts D),letI:=act t;Continuous (fun x : Target D G n q c hsk A w hA Γ t=>v • x)) ∧ + (∀ e x,letI:=act (D.owner e); + unitShift D e • x = faceAction (G (D.owner e)) (n (D.owner e)) (q (D.owner e)) + (c (D.owner e)) (hsk (D.owner e)) (A (D.owner e)) (w (D.owner e)) (hA (D.owner e)) (Γ (D.owner e)) + (fun _ (_ : Fin 1)=>1) (coord e) 0 x) ∧ + letI : ∀ t,MulAction (Shifts D) (Target D G n q c hsk A w hA Γ t):=act + letI : MeasurableSpace ((Full G n q c hsk A w hA)⧸FullLattice G n q c hsk A w hA Γ):=borel _ + ∀ (r : ℕ) (hs : 1 ≤ s) (formula : ∀ t,ℚ→Slots D→Fin r→ι t) + (Fs Bs : Finset (Scale a)) (q₀ : ℕ) (_hq₀ : pivotModulus s r hs D Fs Bs∣q₀) + (b : Scale a) (_hb : b∈Bs) (τ : ℝ) (_hτ : 0<τ), + let π:=fun t z=>targetCoset G n q c hsk A w hA Γ (FullLattice G n q c hsk A w hA Γ) le_rfl t z + let RN:=fun N=>modelRead D G n q c hsk A w hA Γ formula (Obs (F.state.subseq N)) + ∀ᶠ N in atTop, (((((pivotOptions s r hs D Fs).card : ℝ≥0)⁻¹/2) : ℝ≥0) : ℝ≥0∞) < + (F.coveredEmpiricalPointLaw (FullLattice G n q c hsk A w hA Γ) N : Measure ((Full G n q c hsk A w hA)⧸FullLattice G n q c hsk A w hA Γ)) + (⋃ p∈pivotOptions s r hs D Fs,AlignmentMass.Success τ + (centerReading D (Target D G n q c hsk A w hA Γ) π (RN N) Fs q₀ b p) + (translatedReading D (Target D G n q c hsk A w hA Γ) π (RN N) Fs q₀ b p)) + + + +theorem factorized_empirical + (s : ℕ) (P : ℕ→ℤ→Full G n q c hsk A w hA) (Z : ℕ→ℝ) + (hh : FactorizedPhysical D G n q c hsk A w hA Γ coord s P Z) + (hZ : ∀ N,0isClosed_singleton.measurableSet⟩ + let : MeasurableSingletonClass (J⧸Λ):=⟨fun _=>isClosed_singleton.measurableSet⟩ + let C:=F.residueCover B.integer + let : ∀ r,MeasurableSpace ((C r).CubeSpace (ι:=Empty)):=fun _=>borel _ + let : ∀ r,BorelSpace ((C r).CubeSpace (ι:=Empty)):=fun _=>⟨rfl⟩ + intro r hs formula Fs Bs q₀ hq₀ b hb τ hτ + dsimp only + let Y:=Target D G n q c hsk A w hA Γ + let π:=fun t z=>targetCoset G n q c hsk A w hA Γ Λ le_rfl t z + let R:=modelRead D G n q c hsk A w hA Γ formula f + let RN:=fun N=>modelRead D G n q c hsk A w hA Γ formula (Obs (F.state.subseq N)) + have hproj : (fun t (z : J⧸B.small)=>π t (CosetCover.map B.small Λ B.le z))= + (fun t=>(targetCoset G n q c hsk A w hA Γ B.small B.le t : (J⧸B.small)→Y t)) := by + funext t z + induction z using Quotient.inductionOn with | h g=>rfl + by_cases hn : Nonempty (Fin D.targets) + · apply F.actual_lattice_pivot_empirical_success_mass C Λ B.le hs D Fs Bs q₀ hq₀ b hb hτ + Y π R (fun t=>(targetCoset G n q c hsk A w hA Γ Λ le_rfl t).continuous) + (modelRead_continuous D G n q c hsk A w hA Γ formula f) hcont + (fun r β=>by rw [hproj];exact Classical.choice (hphysical r (C r) β)) hZ (hZT hn) RN + have he' := F.state.strictmono.tendsto_atTop.eventually (he (τ/4) (by positivity)) + filter_upwards [he'] with N hN + intro p hp i x + constructor + · exact (hN _ _ _).le + · exact (hN _ _ _).le + · let : IsEmpty (Fin D.targets):=not_nonempty_iff.mp hn + have hempty : IsEmpty (Comparison D Fs r) := inferInstance + have hS (N : ℕ) : + (⋃ p∈pivotOptions s r hs D Fs,AlignmentMass.Success τ + (centerReading D Y π (RN N) Fs q₀ b p) + (translatedReading D Y π (RN N) Fs q₀ b p))=Set.univ := by + ext x + simp only [Set.mem_iUnion,Set.mem_univ,iff_true] + obtain ⟨p,hp⟩:=pivotOptions_nonempty s r hs D Fs + exact ⟨p,hp,fun i=>isEmptyElim i⟩ + have hcard : (1:ℝ≥0)≤((pivotOptions s r hs D Fs).card:ℝ≥0) := by + exact_mod_cast (pivotOptions_nonempty s r hs D Fs).card_pos + have hbnd : (((((pivotOptions s r hs D Fs).card : ℝ≥0)⁻¹/2) : ℝ≥0) : ℝ≥0∞)<1 := by + exact_mod_cast lt_of_le_of_lt (div_le_div_of_nonneg_right (inv_le_one_of_one_le₀ hcard) (by norm_num)) (by norm_num : (1:ℝ≥0)/2<1) + exact Filter.Eventually.of_forall (fun N=>by rw [hS N];simpa using hbnd) + +end SourceIntegerArrays.GlobalJoint +end + +noncomputable section +namespace SourceIntegerArrays.GlobalJoint +open RationalLattice MalcevCharacters RoughArrayFace RoughArrayCoordinates +open ConstructedWordPlan.GlobalWordPlan +open AllLevelFactorization AllLevelFactorization.Factorization MeasureTheory +open ConstructedWordPlan.AlignmentScales ConstructedWordPlan.RationalPivotPlan +open Filter +open scoped BigOperators Topology NNReal ENNReal BoundedContinuousFunction +attribute [local instance] Classical.propDecidable +variable {a : ℕ} (D : Pivot a) {ι : Fin D.targets→Type} [∀ t,Fintype (ι t)] +variable (G : ∀ t,ι t→Type) [∀ t i,Group (G t i)] +variable [∀ t i,TopologicalSpace (G t i)] [∀ t i,IsTopologicalGroup (G t i)] +variable (n : ∀ t,ι t→ℕ) (q : Fin D.targets→ℕ) (c : ∀ t i,RealCoordinates (G t i) (n t i)) +variable (hsk : ∀ t i,SecondKind (c t i)) (A : ∀ t i,CubeFaces.Filtration (G t i)) +variable (w : ∀ t i,Fin (n t i)→ℕ) +variable (hA : ∀ t i k (g : G t i),g∈(A t i).level k ↔ ∀ j,w t i jf (u+v.toAdd) + one_smul f:=by funext u;change f (u+0)=f u;rw [add_zero] + mul_smul v z f:=by funext u;change f (u+(v.toAdd+z.toAdd))=f ((u+v.toAdd)+z.toAdd);rw [add_assoc] + +omit [∀ t,Fintype (ι t)] in +private lemma eval_face (t : Fin D.targets) (e : Fin (q t)) (i : ι t) + (u : Fin (q t)→ℤ) (x : Target D G n q c hsk A w hA Γ t) : + modelEval D G n q c hsk A w hA Γ t i u + (faceAction (G t) (n t) (q t) (c t) (hsk t) (A t) (w t) (hA t) (Γ t) + (fun _ (_ : Fin 1)=>1) e 0 x)= + modelEval D G n q c hsk A w hA Γ t i (u+Pi.single e 1) x := by + classical + induction x using Quotient.inductionOn with | h f => + apply congrArg QuotientGroup.mk + change (f i).val ((fun j=>(u j:ℝ))+(fun j=>((Pi.single e (1:ℤ) : Fin (q t)→ℤ) j:ℝ)))=(f i).val (fun j=>((u+Pi.single e 1 : Fin (q t)→ℤ) j:ℝ)) + apply congrArg (f i).val + funext j + by_cases he : j=e + · subst j;simp + · simp [Pi.single_eq_of_ne he] + +omit [∀ t,Fintype (ι t)] in +private lemma eval_terminal + [act : ∀ t,MulAction (Shifts D) (Target D G n q c hsk A w hA Γ t)] + (hunit : ∀ e x, + unitShift D e • x = faceAction (G (D.owner e)) (n (D.owner e)) (q (D.owner e)) + (c (D.owner e)) (hsk (D.owner e)) (A (D.owner e)) (w (D.owner e)) (hA (D.owner e)) (Γ (D.owner e)) + (fun _ (_ : Fin 1)=>1) (coord e) 0 x) + (t : Fin D.targets) (i : ι t) (q₀ : ℕ) (b : Scale a) + (U : Finset (Fin D.pairs)) (hU : ∀ e∈U,D.owner e=t) + (x : Target D G n q c hsk A w hA Γ t) : + modelEval D G n q c hsk A w hA Γ t i 0 (terminalShift D q₀ b U • x)= + modelEval D G n q c hsk A w hA Γ t i + (ownInput D q coord t (terminalShift D q₀ b U).toAdd) x := by + let := inputAction (X:=(G t i)⧸Γ t i) (q t) + let π : Target D G n q c hsk A w hA Γ t → ((Fin (q t)→ℤ)→(G t i)⧸Γ t i):= + fun x u=>modelEval D G n q c hsk A w hA Γ t i u x + have he:=OwnTerminal.terminal_projection D π (unitShift D) + (fun e=>inputHom D q coord t (unitShift D e)) t (fun e he x=>by + subst t + rw [inputHom_unit,hunit] + funext u + exact eval_face D G n q c hsk A w hA Γ (D.owner e) (coord e) i u x) + q₀ b U hU x + have hm:=lift_map (inputHom D q coord t) + (letter D.index D.tail D.owner D.added (unitShift D) q₀ b) (baseWord D U) + have hf : (fun e=>inputHom D q coord t (letter D.index D.tail D.owner D.added (unitShift D) q₀ b e))= + letter D.index D.tail D.owner D.added (fun e=>inputHom D q coord t (unitShift D e)) q₀ b := by + funext e + simp [letter] + rw [hf] at hm + rw [←hm] at he + have hz:=congrFun he 0 + change modelEval D G n q c hsk A w hA Γ t i 0 (terminalShift D q₀ b U • x)= + modelEval D G n q c hsk A w hA Γ t i + (0+ownInput D q coord t (terminalShift D q₀ b U).toAdd) x at hz + simpa only [zero_add] using hz + + +omit [∀ t,Fintype (ι t)] in +theorem own_terminal_model_reading + [act : ∀ t,MulAction (Shifts D) (Target D G n q c hsk A w hA Γ t)] + (hunit : ∀ e x, + unitShift D e • x = faceAction (G (D.owner e)) (n (D.owner e)) (q (D.owner e)) + (c (D.owner e)) (hsk (D.owner e)) (A (D.owner e)) (w (D.owner e)) (hA (D.owner e)) (Γ (D.owner e)) + (fun _ (_ : Fin 1)=>1) (coord e) 0 x) + {r : ℕ} (formula : ∀ t,ℚ→Slots D→Fin r→ι t) + (obs : ∀ t i,((G t i)⧸Γ t i) →ᵇ ℝ) + (t : Fin D.targets) (a₀ : ℚ) (col : Fin r) (q₀ : ℕ) (b : Scale a) + (U : Finset (Fin D.pairs)) (hU : ∀ e∈U,D.owner e=t) + (x : Target D G n q c hsk A w hA Γ t) (v : Slots D) : + let z:=terminalShift D q₀ b U + modelRead D G n q c hsk A w hA Γ formula obs t a₀ (z • (x,v)) col= + obs t (formula t a₀ (z.toAdd+v) col) + (modelEval D G n q c hsk A w hA Γ t (formula t a₀ (z.toAdd+v) col) + (ownInput D q coord t z.toAdd) x) + := by + dsimp only + change obs t (formula t a₀ ((terminalShift D q₀ b U).toAdd+v) col) + (modelEval D G n q c hsk A w hA Γ t (formula t a₀ ((terminalShift D q₀ b U).toAdd+v) col) 0 + (terminalShift D q₀ b U • x))=_ + rw [eval_terminal D G n q c hsk A w hA Γ coord hunit t _ q₀ b U hU x] + +end SourceIntegerArrays.GlobalJoint + +end +end + +end OAI diff --git a/lean/OAI/Combinatorics/SumProduct/Alignment/IntegerArrays07.lean b/lean/OAI/Combinatorics/SumProduct/Alignment/IntegerArrays07.lean new file mode 100644 index 0000000000000000000000000000000000000000..7407a94feba934d4063eb5d0a3f72ed17c7a5a1a --- /dev/null +++ b/lean/OAI/Combinatorics/SumProduct/Alignment/IntegerArrays07.lean @@ -0,0 +1,380 @@ +import Mathlib +import OAI.Combinatorics.SumProduct.Alignment.IntegerArrays06 +import OAI.Geometry.NilpotentCharts.Main + +namespace OAI + +open scoped BigOperators +section +noncomputable section +end + +noncomputable section +namespace SourceIntegerArrays.GlobalJoint +open RationalLattice MalcevCharacters RoughArrayFace RoughArrayCoordinates +open ConstructedWordPlan.GlobalWordPlan +open AllLevelFactorization AllLevelFactorization.Factorization MeasureTheory +open ConstructedWordPlan.AlignmentScales ConstructedWordPlan.RationalPivotPlan +open Filter +open scoped BigOperators Topology NNReal ENNReal BoundedContinuousFunction +attribute [local instance] Classical.propDecidable +variable {a : ℕ} (D : Pivot a) {ι : Fin D.targets→Type} [∀ t,Fintype (ι t)] +variable (G : ∀ t,ι t→Type) [∀ t i,Group (G t i)] +variable [∀ t i,TopologicalSpace (G t i)] [∀ t i,IsTopologicalGroup (G t i)] +variable (n : ∀ t,ι t→ℕ) (q : Fin D.targets→ℕ) (c : ∀ t i,RealCoordinates (G t i) (n t i)) +variable (hsk : ∀ t i,SecondKind (c t i)) (A : ∀ t i,CubeFaces.Filtration (G t i)) +variable (w : ∀ t i,Fin (n t i)→ℕ) +variable (hA : ∀ t i k (g : G t i),g∈(A t i).level k ↔ ∀ j,w t i jtargetCoset G n q c hsk A w hA Γ (FullLattice G n q c hsk A w hA Γ) le_rfl t x + ⋃ p∈pivotOptions s r hs D Fs,AlignmentMass.Success τ + (centerReading D (Target D G n q c hsk A w hA Γ) π (modelRead D G n q c hsk A w hA Γ formula obs) Fs q₀ b p) + (intrinsicTerminal D G n q c hsk A w hA Γ coord formula obs Fs q₀ b p) + +omit [∀ t,Fintype (ι t)] in +private lemma intrinsicTerminal_eq + [act : ∀ t,MulAction (Shifts D) (Target D G n q c hsk A w hA Γ t)] + (hunit : ∀ e x, + unitShift D e • x = faceAction (G (D.owner e)) (n (D.owner e)) (q (D.owner e)) + (c (D.owner e)) (hsk (D.owner e)) (A (D.owner e)) (w (D.owner e)) (hA (D.owner e)) (Γ (D.owner e)) + (fun _ (_ : Fin 1)=>1) (coord e) 0 x) + {r : ℕ} (formula : ∀ t,ℚ→Slots D→Fin r→ι t) + (obs : ∀ t i,((G t i)⧸Γ t i) →ᵇ ℝ) (Fs : Finset (Scale a)) + (q₀ : ℕ) (b : Scale a) (p : Path D) (i : Comparison D Fs r) + (x : (Full G n q c hsk A w hA)⧸FullLattice G n q c hsk A w hA Γ) : + translatedReading D (Target D G n q c hsk A w hA Γ) + (fun t x=>targetCoset G n q c hsk A w hA Γ (FullLattice G n q c hsk A w hA Γ) le_rfl t x) + (modelRead D G n q c hsk A w hA Γ formula obs) Fs q₀ b p i x= + intrinsicTerminal D G n q c hsk A w hA Γ coord formula obs Fs q₀ b p i x := by + exact own_terminal_model_reading D G n q c hsk A w hA Γ coord hunit formula obs + i.2.1.1 _ i.2.2 q₀ (scaleRun D 0 p b*i.1.val) i.2.1.2.val i.2.1.2.property _ _ + + +theorem array_empirical_subsequence + (s : ℕ) (P : ℕ→ℤ→Full G n q c hsk A w hA) (Z : ℕ→ℝ) + (Obs : ℕ→∀ t i,((G t i)⧸Γ t i) →ᵇ ℝ) + (hh : FactorizedEmpirical D G n q c hsk A w hA Γ coord s P Z Obs) : + ∃ ψ : ℕ→ℕ,StrictMono ψ ∧ + ∀ (r : ℕ) (hs : 1 ≤ s) (formula : ∀ t,ℚ→Slots D→Fin r→ι t) + (Fs Bs : Finset (Scale a)) (q₀ : ℕ) (_hq₀ : pivotModulus s r hs D Fs Bs∣q₀) + (b : Scale a) (_hb : b∈Bs) (τ : ℝ) (_hτ : 0<τ), + ∀ᶠ N in atTop, (((((pivotOptions s r hs D Fs).card : ℝ≥0)⁻¹/2) : ℝ≥0) : ℝ≥0∞) < + (ProbabilityMixtures.empirical ⌊Z (ψ N)⌋₊ (fun k : ℕ=>k) : Measure ℕ) + {k | (QuotientGroup.mk (P (ψ N) (k:ℤ)))∈ + intrinsicSuccess D G n q c hsk A w hA Γ coord s r hs formula (Obs (ψ N)) Fs q₀ b τ} + := by + classical + obtain ⟨d,B,hd,hfil,hrational,F,act,hcont,hunit,hgood⟩:=hh + refine ⟨F.state.subseq,F.state.strictmono,?_⟩ + let : ∀ t,MulAction (Shifts D) (Target D G n q c hsk A w hA Γ t):=act + let J:=Full G n q c hsk A w hA + let Λ:=FullLattice G n q c hsk A w hA Γ + let : T2Space J:=d.coord.symm.t2Space + let : SecondCountableTopology J:=d.coord.secondCountableTopology + let : DiscreteTopology Λ:=B.discrete + let : IsClosed (Λ : Set J):=Λ.isClosed_of_discreteTopology + let : T2Space (J⧸Λ):=inferInstance + let : MeasurableSpace (J⧸Λ):=borel _ + let : BorelSpace (J⧸Λ):=⟨rfl⟩ + let : MeasurableSingletonClass (J⧸Λ):=⟨fun _=>isClosed_singleton.measurableSet⟩ + intro r hs formula Fs Bs q₀ hq₀ b hb τ hτ + have H:=hgood r hs formula Fs Bs q₀ hq₀ b hb τ hτ + filter_upwards [H] with N hN + let π:=fun t x=>targetCoset G n q c hsk A w hA Γ Λ le_rfl t x + let RN:=modelRead D G n q c hsk A w hA Γ formula (Obs (F.state.subseq N)) + have ht : (translatedReading D (Target D G n q c hsk A w hA Γ) π RN Fs q₀ b)= + intrinsicTerminal D G n q c hsk A w hA Γ coord formula (Obs (F.state.subseq N)) Fs q₀ b := by + funext p i x + exact intrinsicTerminal_eq D G n q c hsk A w hA Γ coord hunit formula _ Fs q₀ b p i x + change _ < (F.coveredEmpiricalPointLaw Λ N : Measure (J⧸Λ)) + (⋃ p∈pivotOptions s r hs D Fs,AlignmentMass.Success τ + (centerReading D (Target D G n q c hsk A w hA Γ) π RN Fs q₀ b p) + (translatedReading D (Target D G n q c hsk A w hA Γ) π RN Fs q₀ b p)) at hN + rw [ht] at hN + have he:=ProbabilityMixtures.empirical_preimage ⌊Z (F.state.subseq N)⌋₊ (fun k : ℕ=>k) + (fun k : ℕ=>(QuotientGroup.mk (P (F.state.subseq N) (k:ℤ)) : J⧸Λ)) + (intrinsicSuccess D G n q c hsk A w hA Γ coord s r hs formula (Obs (F.state.subseq N)) Fs q₀ b τ) + exact hN.trans_eq he.symm + +end SourceIntegerArrays.GlobalJoint +end + +noncomputable section +namespace SourceIntegerArrays +open GlobalJoint +open RoughArrayFace +open RationalLattice MalcevCharacters RoughFaceShift RoughTopologicalFace RoughArrayCoordinates SourceResidueAlignment +open RoughScales RoughSamplingWeights FinitePieceAverages RoughSourceExceptional RoughProductRemoval +open ProductExposureLabels ProductExposureLaw ProductExposureCutoff MeasureTheory Filter +open scoped BigOperators Topology ENNReal BoundedContinuousFunction NNReal +attribute [local instance] Classical.propDecidable +open ConstructedWordPlan.GlobalWordPlan +variable {a₀ : ℕ} (D : Pivot a₀) {ι : Fin D.targets→Type} [∀ t,Fintype (ι t)] +variable (G : ∀ t,ι t→Type) [∀ t i,Group (G t i)] +variable [∀ t i,TopologicalSpace (G t i)] [∀ t i,IsTopologicalGroup (G t i)] +variable (n : ∀ t,ι t→ℕ) (q : Fin D.targets→ℕ) (c : ∀ t i,RealCoordinates (G t i) (n t i)) +variable (hsk : ∀ t i,SecondKind (c t i)) (A : ∀ t i,CubeFaces.Filtration (G t i)) +variable (w : ∀ t i,Fin (n t i)→ℕ) +variable (hA : ∀ t i k (g : G t i),g∈(A t i).level k ↔ ∀ j,w t i jX N j) atTop atTop) (hXpt : Tendsto Xp atTop atTop) + (hR : ∀ N,0R N/(Xp N:ℝ)) atTop (𝓝 0)) + (hZ : ∀ t (u : ℝ),0(R N/(M N:ℝ))/ + (1+∑ j : Fin (m t),(X N (perm t (j.castAdd (h t))):ℝ)^2)^u) atTop atTop) + (hQ0 : ∀ N,0≤Q N) + (hSize : ∀ t,Tendsto (fun N=>(Q N+(∏ l : Fin (m t),(X N (perm t (l.castAdd (h t))):ℝ)^2)*(L N:ℝ))/R N) atTop (𝓝 0)) + (hWM : ∀ N,(primorial (w0 N):ℤ)∣(M N:ℤ)) + (hM : ∀ N,0(X N (perm t (j.castAdd (h t))):ℝ)/(L N:ℝ)) atTop atTop) + (g x : ∀ t,ℕ→(Fin (h t)→ℕ)→Label (m t)→∀ i,G t i) + (slot : ∀ t,ℕ→(Fin (h t)→ℕ)→Label (m t)→ι t→ℤ) + (qval : ∀ t,ℕ→(Fin (h t)→ℕ)→Label (m t)→Fin (q t)→ℤ) + (hQ : ∀ t N y,y∈outsideDomain (fun l : Fin (h t)=>X N (perm t (l.natAdd (m t)))) (primorial (w0 N)) → + ∀ b,b∈(fullDomain (fun l : Fin (m t)=>X N (perm t (l.castAdd (h t)))) (Xp N) (primorial (w0 N))).image + (expose (L N) (M N:ℤ) (R N)) →∀ k,|(qval t N y b k:ℝ)|≤Q N) + (metric : ∀ t i,MetricSpace ((G t i)⧸Γ t i)) + (hmetric : ∀ t i,QuotientGroup.instTopologicalSpace (Γ t i)=(metric t i).toUniformSpace.toTopologicalSpace) : + letI : ∀ t i,MetricSpace ((G t i)⧸Γ t i):=fun t i=>(metric t i).replaceTopology (hmetric t i) + ∀ (Obs : ℕ→((Fin a→ℕ)×ℕ)→∀ t i,((G t i)⧸Γ t i) →ᵇ ℝ) (Kobs : ℝ≥0) (Bobs : ℝ) + (_hLip : ∀ N z t i,LipschitzWith Kobs (Obs N z t i)) + (_hBound : ∀ N z t i y,|Obs N z t i y|≤Bobs) + (E : ℕ→Set ((Fin a→ℕ)×ℕ)) (ε : ℝ≥0∞) (_hε : 0<ε) + (_hE : ∀ N,ε≤(jointLaw (X N) (Xp N) (primorial (w0 N)) (primorial_pos _) + (hX N) (hXp N)) (E N)), + ∃ φ : ℕ→ℕ,StrictMono φ ∧ ∃ z : ℕ→(Fin a→ℕ)×ℕ, + (∀ k,z k∈E (φ k) ∧ z k∈fullDomain (X (φ k)) (Xp (φ k)) (primorial (w0 (φ k)))) ∧ + ∃ f : ∀ t i,((G t i)⧸Γ t i) →ᵇ ℝ, + (∀ t i,TendstoUniformly (fun k=>Obs (φ k) (z k) t i) (f t i) atTop) ∧ + (∀ η : ℝ,0<η →∀ᶠ k in atTop,∀ t i y,|Obs (φ k) (z k) t i y-f t i y|<η) ∧ + ∀ pstar : Fin D.targets→ℕ→ℤ, + (∀ t k,(M (φ k):ℤ)∣pstar t k-((z k).2:ℤ)) → + (∀ t k,|(pstar t k:ℝ)-((z k).2:ℝ)|≤R (φ k)) → + let zout := fun t k l=>(z k).1 (perm t (l.natAdd (m t))) + let zin := fun t k=>((fun l=>(z k).1 (perm t (l.castAdd (h t)))),(z k).2) + let label := fun t k=>expose (L (φ k)) (M (φ k):ℤ) (R (φ k)) (zin t k) + FactorizedEmpirical D G n q c hsk A w hA Γ coord s + (fun k=>rawJoint G n q m c hsk A w hA hw (M (φ k)) (L (φ k)) + (fun t=>label t k) (fun t l=>((zin t k).1 l:ℤ)) (fun t=>pstar t k) + (fun t=>slot t (φ k) (zout t k) (label t k)) + (fun t=>qval t (φ k) (zout t k) (label t k)) + (fun t=>g t (φ k) (zout t k) (label t k)) + (fun t=>x t (φ k) (zout t k) (label t k))) + (fun k=>R (φ k)/(M (φ k):ℝ)) (fun k=>Obs (φ k) (z k)) := by + classical + let : ∀ t i,MetricSpace ((G t i)⧸Γ t i):=fun t i=>(metric t i).replaceTopology (hmetric t i) + intro Obs Kobs Bobs hLip hBound E ε hε hE + let Yobs (u : Sigma ι):=(G u.1 u.2)⧸Γ u.1 u.2 + let : ∀ u,MetricSpace (Yobs u):=fun u=>inferInstanceAs (MetricSpace ((G u.1 u.2)⧸Γ u.1 u.2)) + let : ∀ u,CompactSpace (Yobs u):=fun u=>AbelianMalcevTorus.quotient_compact (c u.1 u.2) (Γ u.1 u.2) (hΓ u.1 u.2) + obtain ⟨φ,hφ,z,hz,f,hu,he,hgood⟩:=source_compact_physical D G n q c hsk A w hA hw Γ coord + hΓ hmono s h0 h1 hs a m h perm w0 M Xp X R Q L hw0 hX hXp hXt hXpt hR hRX hZ hQ0 + hSize hWM hM hMs hL hsm hWL hML hLexact hXL g x slot qval hQ Yobs + (fun N z u=>Obs N z u.1 u.2) Kobs Bobs (fun N z u=>hLip N z u.1 u.2) + (fun N z u=>hBound N z u.1 u.2) E ε hε hE + refine ⟨φ,hφ,z,hz,(fun t i=>f ⟨t,i⟩),(fun t i=>hu ⟨t,i⟩),?_,?_⟩ + · intro η hη + filter_upwards [he η hη] with k hk + exact fun t i y=>hk ⟨t,i⟩ y + · intro pstar hpstar hpclose + refine factorized_empirical D G n q c hsk A w hA Γ coord s _ _ (hgood pstar hpstar hpclose) + (fun k=>div_pos (hR _) (by exact_mod_cast hM _)) ?_ (fun k=>Obs (φ k) (z k)) (fun t i=>f ⟨t,i⟩) ?_ + · rintro ⟨t⟩ + have ht : Tendsto (fun N=>(R N/(M N:ℝ))/ + (1+∑ j : Fin (m t),(X N (perm t (j.castAdd (h t))):ℝ)^2)) atTop atTop := by + simpa only [Real.rpow_one] using hZ t 1 zero_lt_one + have hT : Tendsto (fun N=>R N/(M N:ℝ)) atTop atTop := by + apply tendsto_atTop.mpr + intro B + filter_upwards [ht.eventually (eventually_ge_atTop B)] with N hN + apply hN.trans + apply div_le_self (le_of_lt (div_pos (hR N) (by exact_mod_cast hM N))) + have hn : 0≤∑ j : Fin (m t),(X N (perm t (j.castAdd (h t))):ℝ)^2:= + Finset.sum_nonneg (fun _ _=>sq_nonneg _) + linarith + exact hT.comp hφ.tendsto_atTop + · intro η hη + filter_upwards [he η hη] with k hk + exact fun t i y=>hk ⟨t,i⟩ y + +end SourceIntegerArrays +end + +noncomputable section +namespace SourceIntegerArrays +open GlobalJoint +open RoughArrayFace +open RationalLattice MalcevCharacters RoughFaceShift RoughTopologicalFace RoughArrayCoordinates SourceResidueAlignment +open RoughScales RoughSamplingWeights FinitePieceAverages RoughSourceExceptional RoughProductRemoval +open ProductExposureLabels ProductExposureLaw ProductExposureCutoff MeasureTheory Filter +open scoped BigOperators Topology ENNReal BoundedContinuousFunction NNReal +attribute [local instance] Classical.propDecidable +open ConstructedWordPlan.GlobalWordPlan +open ConstructedWordPlan.AlignmentScales ConstructedWordPlan.RationalPivotPlan +variable {a₀ : ℕ} (D : Pivot a₀) {ι : Fin D.targets→Type} [∀ t,Fintype (ι t)] +variable (G : ∀ t,ι t→Type) [∀ t i,Group (G t i)] +variable [∀ t i,TopologicalSpace (G t i)] [∀ t i,IsTopologicalGroup (G t i)] +variable (n : ∀ t,ι t→ℕ) (q : Fin D.targets→ℕ) (c : ∀ t i,RealCoordinates (G t i) (n t i)) +variable (hsk : ∀ t i,SecondKind (c t i)) (A : ∀ t i,CubeFaces.Filtration (G t i)) +variable (w : ∀ t i,Fin (n t i)→ℕ) +variable (hA : ∀ t i k (g : G t i),g∈(A t i).level k ↔ ∀ j,w t i jz.1 (perm t (l.natAdd (m t))) + let zin:=fun t=>((fun l=>z.1 (perm t (l.castAdd (h t)))),z.2) + let label:=fun t=>expose L (M:ℤ) R (zin t) + rawJoint G n q m c hsk A w hA hw M L label (fun t l=>((zin t).1 l:ℤ)) + (fun _=>firstPivot M J z.2) (fun t=>slot t (zout t) (label t)) + (fun t=>qval t (zout t) (label t)) (fun t=>g t (zout t) (label t)) + (fun t=>x t (zout t) (label t)) k + +lemma firstPivot_congruent (M N p : ℕ) : (M:ℤ)∣firstPivot M N p-(p:ℤ) := by + refine ⟨-(((p/M)%N:ℕ):ℤ),?_⟩ + unfold firstPivot + ring + +lemma firstPivot_close (M N p : ℕ) (hN : 0X N j) atTop atTop) (hXpt : Tendsto Xp atTop atTop) + (hR : ∀ N,0R N/(Xp N:ℝ)) atTop (𝓝 0)) + (hZ : ∀ t (u : ℝ),0(R N/(M N:ℝ))/ + (1+∑ j : Fin (m t),(X N (perm t (j.castAdd (h t))):ℝ)^2)^u) atTop atTop) + (hQ0 : ∀ N,0≤Q N) + (hSize : ∀ t,Tendsto (fun N=>(Q N+(∏ l : Fin (m t),(X N (perm t (l.castAdd (h t))):ℝ)^2)*(L N:ℝ))/R N) atTop (𝓝 0)) + (hWM : ∀ N,(primorial (w0 N):ℤ)∣(M N:ℤ)) + (hM : ∀ N,0(X N (perm t (j.castAdd (h t))):ℝ)/(L N:ℝ)) atTop atTop) + (g x : ∀ t,ℕ→(Fin (h t)→ℕ)→Label (m t)→∀ i,G t i) + (slot : ∀ t,ℕ→(Fin (h t)→ℕ)→Label (m t)→ι t→ℤ) + (qval : ∀ t,ℕ→(Fin (h t)→ℕ)→Label (m t)→Fin (q t)→ℤ) + (hQ : ∀ t N y,y∈outsideDomain (fun l : Fin (h t)=>X N (perm t (l.natAdd (m t)))) (primorial (w0 N)) → + ∀ b,b∈(fullDomain (fun l : Fin (m t)=>X N (perm t (l.castAdd (h t)))) (Xp N) (primorial (w0 N))).image + (expose (L N) (M N:ℤ) (R N)) →∀ k,|(qval t N y b k:ℝ)|≤Q N) + (metric : ∀ t i,MetricSpace ((G t i)⧸Γ t i)) + (hmetric : ∀ t i,QuotientGroup.instTopologicalSpace (Γ t i)=(metric t i).toUniformSpace.toTopologicalSpace) : + letI : ∀ t i,MetricSpace ((G t i)⧸Γ t i):=fun t i=>(metric t i).replaceTopology (hmetric t i) + ∀ (Obs : ℕ→((Fin a→ℕ)×ℕ)→∀ t i,((G t i)⧸Γ t i) →ᵇ ℝ) (Kobs : ℝ≥0) (Bobs : ℝ) + (_hLip : ∀ N z t i,LipschitzWith Kobs (Obs N z t i)) + (_hBound : ∀ N z t i y,|Obs N z t i y|≤Bobs) + (J : ℕ→ℕ) (_hJ : ∀ N,0k) : Measure ℕ) + {k | QuotientGroup.mk (rawLocalOrbit D G n q c hsk A w hA hw m h perm + (M N) (J N) (L N) (R N) (fun t=>g t N) (fun t=>x t N) + (fun t=>slot t N) (fun t=>qval t N) z (k:ℤ)) ∈ + intrinsicSuccess D G n q c hsk A w hA Γ coord s r hs1 formula (Obs N z) Fs q₀ b τ} + := by + classical + let : ∀ t i,MetricSpace ((G t i)⧸Γ t i):=fun t i=>(metric t i).replaceTopology (hmetric t i) + intro Obs Kobs Bobs hLip hBound J hJ hRJ r hs1 formula Fs Bs q₀ hq₀ b hb τ hτ E ε hε hE + obtain ⟨φ,hφ,z,hz,f,hu,he,hgood⟩:=source_compact_empirical D G n q c hsk A w hA hw Γ coord + hΓ hmono s h0 h1 hs a m h perm w0 M Xp X R Q L hw0 hX hXp hXt hXpt hR hRX hZ hQ0 + hSize hWM hM hMs hL hsm hWL hML hLexact hXL g x slot qval hQ metric hmetric + Obs Kobs Bobs hLip hBound E ε hε hE + let pstar : Fin D.targets→ℕ→ℤ:=fun _ k=>firstPivot (M (φ k)) (J (φ k)) (z k).2 + have hpstar : ∀ t k,(M (φ k):ℤ)∣pstar t k-((z k).2:ℤ):=fun t k=>firstPivot_congruent _ _ _ + have hpclose : ∀ t k,|(pstar t k:ℝ)-((z k).2:ℝ)|≤R (φ k) := by + intro t k + rw [hRJ] + exact firstPivot_close _ _ _ (hJ _) + have hh:=hgood pstar hpstar hpclose + obtain ⟨ψ,hψ,hψgood⟩:=array_empirical_subsequence D G n q c hsk A w hA Γ coord s _ _ _ hh + obtain ⟨N,hN⟩:=(hψgood r hs1 formula Fs Bs q₀ hq₀ b hb τ hτ).exists + refine ⟨φ (ψ N),z (ψ N),(hz _).1,(hz _).2,?_⟩ + have hlen : ⌊R (φ (ψ N))/(M (φ (ψ N)):ℝ)⌋₊=J (φ (ψ N)) := by + rw [hRJ,mul_div_cancel_left₀ _ (by exact_mod_cast (hM _).ne')] + exact Nat.floor_natCast _ + simpa only [hlen,pstar,rawLocalOrbit] using hN + +end SourceIntegerArrays + +end +end + +end OAI diff --git a/lean/OAI/Combinatorics/SumProduct/Alignment/IntegerArrays08.lean b/lean/OAI/Combinatorics/SumProduct/Alignment/IntegerArrays08.lean new file mode 100644 index 0000000000000000000000000000000000000000..c81ed75f37925fce7315b8251629cf3e43b7389f --- /dev/null +++ b/lean/OAI/Combinatorics/SumProduct/Alignment/IntegerArrays08.lean @@ -0,0 +1,273 @@ +import Mathlib +import OAI.Combinatorics.SumProduct.Alignment.IntegerArrays07 +import OAI.Geometry.NilpotentCharts.Main + +namespace OAI + +open scoped BigOperators +section +noncomputable section +end + +noncomputable section +namespace SourceIntegerArrays +open GlobalJoint +open RoughArrayFace +open RationalLattice MalcevCharacters RoughFaceShift RoughTopologicalFace RoughArrayCoordinates SourceResidueAlignment +open RoughScales RoughSamplingWeights FinitePieceAverages RoughSourceExceptional RoughProductRemoval +open ProductExposureLabels ProductExposureLaw ProductExposureCutoff MeasureTheory Filter +open scoped BigOperators Topology ENNReal BoundedContinuousFunction NNReal +attribute [local instance] Classical.propDecidable +open ConstructedWordPlan.GlobalWordPlan +open ConstructedWordPlan.AlignmentScales ConstructedWordPlan.RationalPivotPlan +variable {a₀ : ℕ} (D : Pivot a₀) {ι : Fin D.targets→Type} [∀ t,Fintype (ι t)] +variable (G : ∀ t,ι t→Type) [∀ t i,Group (G t i)] +variable [∀ t i,TopologicalSpace (G t i)] [∀ t i,IsTopologicalGroup (G t i)] +variable (n : ∀ t,ι t→ℕ) (q : Fin D.targets→ℕ) (c : ∀ t i,RealCoordinates (G t i) (n t i)) +variable (hsk : ∀ t i,SecondKind (c t i)) (A : ∀ t i,CubeFaces.Filtration (G t i)) +variable (w : ∀ t i,Fin (n t i)→ℕ) +variable (hA : ∀ t i k (g : G t i),g∈(A t i).level k ↔ ∀ j,w t i jX N j) atTop atTop) (hXpt : Tendsto Xp atTop atTop) + (hR : ∀ N,0R N/(Xp N:ℝ)) atTop (𝓝 0)) + (hZ : ∀ t (u : ℝ),0(R N/(M N:ℝ))/ + (1+∑ j : Fin (m t),(X N (perm t (j.castAdd (h t))):ℝ)^2)^u) atTop atTop) + (hQ0 : ∀ N,0≤Q N) + (hSize : ∀ t,Tendsto (fun N=>(Q N+(∏ l : Fin (m t),(X N (perm t (l.castAdd (h t))):ℝ)^2)*(L N:ℝ))/R N) atTop (𝓝 0)) + (hWM : ∀ N,(primorial (w0 N):ℤ)∣(M N:ℤ)) + (hM : ∀ N,0(X N (perm t (j.castAdd (h t))):ℝ)/(L N:ℝ)) atTop atTop) + (g x : ∀ t,ℕ→(Fin (h t)→ℕ)→Label (m t)→∀ i,G t i) + (slot : ∀ t,ℕ→(Fin (h t)→ℕ)→Label (m t)→ι t→ℤ) + (qval : ∀ t,ℕ→(Fin (h t)→ℕ)→Label (m t)→Fin (q t)→ℤ) + (hQ : ∀ t N y,y∈outsideDomain (fun l : Fin (h t)=>X N (perm t (l.natAdd (m t)))) (primorial (w0 N)) → + ∀ b,b∈(fullDomain (fun l : Fin (m t)=>X N (perm t (l.castAdd (h t)))) (Xp N) (primorial (w0 N))).image + (expose (L N) (M N:ℤ) (R N)) →∀ k,|(qval t N y b k:ℝ)|≤Q N) + (metric : ∀ t i,MetricSpace ((G t i)⧸Γ t i)) + (hmetric : ∀ t i,QuotientGroup.instTopologicalSpace (Γ t i)=(metric t i).toUniformSpace.toTopologicalSpace) : + letI : ∀ t i,MetricSpace ((G t i)⧸Γ t i):=fun t i=>(metric t i).replaceTopology (hmetric t i) + ∀ (Obs : ℕ→((Fin a→ℕ)×ℕ)→∀ t i,((G t i)⧸Γ t i) →ᵇ ℝ) (Kobs : ℝ≥0) (Bobs : ℝ) + (_hLip : ∀ N z t i,LipschitzWith Kobs (Obs N z t i)) + (_hBound : ∀ N z t i y,|Obs N z t i y|≤Bobs) + (J : ℕ→ℕ) (_hJ : ∀ N,0(jointLaw (X N) (Xp N) (primorial (w0 N)) (primorial_pos _) + (hX N) (hXp N)) {z | + (ProbabilityMixtures.empirical (J N) (fun k : ℕ=>k) : Measure ℕ) + {k | QuotientGroup.mk (rawLocalOrbit D G n q c hsk A w hA hw m h perm + (M N) (J N) (L N) (R N) (fun t=>g t N) (fun t=>x t N) + (fun t=>slot t N) (fun t=>qval t N) z (k:ℤ)) ∈ + intrinsicSuccess D G n q c hsk A w hA Γ coord s r hs1 formula (Obs N z) Fs q₀ b τ} + ≤ (((((pivotOptions s r hs1 D Fs).card : ℝ≥0)⁻¹/2) : ℝ≥0) : ℝ≥0∞)}) atTop (𝓝 0) + := by + classical + let : ∀ t i,MetricSpace ((G t i)⧸Γ t i):=fun t i=>(metric t i).replaceTopology (hmetric t i) + intro Obs Kobs Bobs hLip hBound J hJ hRJ r hs1 formula Fs Bs q₀ hq₀ b hb τ hτ + apply tendsto_order.mpr + constructor + · intro ε hε + exact (not_lt_of_ge bot_le hε).elim + · intro ε hε + by_contra hnot + have hfreq : ∃ᶠ N in atTop, ε≤(jointLaw (X N) (Xp N) (primorial (w0 N)) (primorial_pos _) + (hX N) (hXp N)) {z | + (ProbabilityMixtures.empirical (J N) (fun k : ℕ=>k) : Measure ℕ) + {k | QuotientGroup.mk (rawLocalOrbit D G n q c hsk A w hA hw m h perm + (M N) (J N) (L N) (R N) (fun t=>g t N) (fun t=>x t N) + (fun t=>slot t N) (fun t=>qval t N) z (k:ℤ)) ∈ + intrinsicSuccess D G n q c hsk A w hA Γ coord s r hs1 formula (Obs N z) Fs q₀ b τ} + ≤ (((((pivotOptions s r hs1 D Fs).card : ℝ≥0)⁻¹/2) : ℝ≥0) : ℝ≥0∞)} := by + simpa only [Filter.Frequently,not_le] using hnot + obtain ⟨ρ,hρ,hρE⟩:=Filter.extraction_of_frequently_atTop hfreq + obtain ⟨N,z,hzE,hz,hgood⟩:=source_intrinsic_selection D G n q c hsk A w hA hw Γ coord + hΓ hmono s h0 h1 hs a m h perm (w0∘ρ) (M∘ρ) (Xp∘ρ) (X∘ρ) (R∘ρ) (Q∘ρ) (L∘ρ) + (hw0.comp hρ.tendsto_atTop) (fun N=>hX (ρ N)) (fun N=>hXp (ρ N)) + (fun j=>(hXt j).comp hρ.tendsto_atTop) (hXpt.comp hρ.tendsto_atTop) + (fun N=>hR (ρ N)) (hRX.comp hρ.tendsto_atTop) + (fun t u hu=>(hZ t u hu).comp hρ.tendsto_atTop) (fun N=>hQ0 (ρ N)) + (fun t=>(hSize t).comp hρ.tendsto_atTop) + (fun N=>hWM (ρ N)) (fun N=>hM (ρ N)) (fun N=>hMs (ρ N)) + (fun N=>hL (ρ N)) (fun N=>hsm (ρ N)) (fun N=>hWL (ρ N)) (fun N=>hML (ρ N)) + (fun N=>hLexact (ρ N)) (fun t j=>(hXL t j).comp hρ.tendsto_atTop) + (fun t N=>g t (ρ N)) (fun t N=>x t (ρ N)) (fun t N=>slot t (ρ N)) + (fun t N=>qval t (ρ N)) (fun t N=>hQ t (ρ N)) metric hmetric + (Obs∘ρ) Kobs Bobs (fun N=>hLip (ρ N)) (fun N=>hBound (ρ N)) + (J∘ρ) (fun N=>hJ (ρ N)) (fun N=>hRJ (ρ N)) r hs1 formula Fs Bs q₀ hq₀ b hb τ hτ + _ ε hε hρE + exact (not_lt_of_ge hzE) hgood + +end SourceIntegerArrays +end + +noncomputable section +namespace SourceIntegerArrays +open GlobalJoint +open RoughArrayFace +open RationalLattice MalcevCharacters RoughFaceShift RoughTopologicalFace RoughArrayCoordinates SourceResidueAlignment +open RoughScales RoughSamplingWeights FinitePieceAverages RoughSourceExceptional RoughProductRemoval +open ProductExposureLabels ProductExposureLaw ProductExposureCutoff MeasureTheory Filter +open scoped BigOperators Topology ENNReal BoundedContinuousFunction NNReal +attribute [local instance] Classical.propDecidable +open ConstructedWordPlan.GlobalWordPlan +open ConstructedWordPlan.AlignmentScales ConstructedWordPlan.RationalPivotPlan +variable {a₀ : ℕ} (D : Pivot a₀) {ι : Fin D.targets→Type} [∀ t,Fintype (ι t)] +variable (G : ∀ t,ι t→Type) [∀ t i,Group (G t i)] +variable [∀ t i,TopologicalSpace (G t i)] [∀ t i,IsTopologicalGroup (G t i)] +variable (n : ∀ t,ι t→ℕ) (q : Fin D.targets→ℕ) (c : ∀ t i,RealCoordinates (G t i) (n t i)) +variable (hsk : ∀ t i,SecondKind (c t i)) (A : ∀ t i,CubeFaces.Filtration (G t i)) +variable (w : ∀ t i,Fin (n t i)→ℕ) +variable (hA : ∀ t i k (g : G t i),g∈(A t i).level k ↔ ∀ j,w t i jk) : Measure ℕ) S) : + (c:ℝ)/3k) f (f '' S) + rw [hpre] at he + have huni : (ProbabilityMixtures.empirical J f : Measure ℕ)= + (MicrocellProbability.uniformLaw (fun k : Fin J=>f k.val) : Measure ℕ) := by + simp only [ProbabilityMixtures.empirical,hJ,↓reduceDIte] + rfl + rw [huni] at he + have hsreal : (c:ℝ)/2< + (MicrocellProbability.uniformLaw (fun k : Fin J=>f k.val) : Measure ℕ).real (f '' S) := by + rw [he] at hS + have hl:= (ENNReal.toReal_lt_toReal (by finiteness) (by finiteness)).mpr hS + simpa only [measureReal_def,ENNReal.coe_toReal,NNReal.coe_div,NNReal.coe_ofNat] using hl + have hr : W.Coprime (p%M) := by + apply (UnitIntervalCounts.coprime_mod W (p%M)).mp + rw [Nat.mod_mod_of_dvd p hWM] + exact (UnitIntervalCounts.coprime_mod W p).mpr hp + exact MicrocellFibers.raw_fiber_success X W M J (J*(p/(M*J))) (p%M) hW hX hM hJ + (Nat.mod_lt p hM) hr hWM hcell.1 hcell.2 (c:ℝ) (f '' S) hsmall hsreal + + +theorem source_harmonic_decay + (hΓ : ∀ t i g,g∈Γ t i ↔ ∀ j,∃ z : ℤ,(c t i).coord g j=z) + (hmono : ∀ t i,Monotone (w t i)) (s : ℕ) + (h0 : ∀ t i,(A t i).level 0=⊤) (h1 : ∀ t i,(A t i).level 1=⊤) + (hs : ∀ t i,(A t i).level (s+1)=⊥) + (a : ℕ) (m h : Fin D.targets→ℕ) (perm : ∀ t,Fin (m t+h t)≃Fin a) + (w0 M Xp : ℕ→ℕ) (X : ℕ→Fin a→ℕ) (R Q : ℕ→ℝ) (L : ℕ→ℤ) + (hw0 : Tendsto w0 atTop atTop) + (hX : ∀ N j,4*primorial (w0 N)≤X N j) (hXp : ∀ N,4*primorial (w0 N)≤Xp N) + (hXt : ∀ j,Tendsto (fun N=>X N j) atTop atTop) (hXpt : Tendsto Xp atTop atTop) + (hR : ∀ N,0R N/(Xp N:ℝ)) atTop (𝓝 0)) + (hZ : ∀ t (u : ℝ),0(R N/(M N:ℝ))/ + (1+∑ j : Fin (m t),(X N (perm t (j.castAdd (h t))):ℝ)^2)^u) atTop atTop) + (hQ0 : ∀ N,0≤Q N) + (hSize : ∀ t,Tendsto (fun N=>(Q N+(∏ l : Fin (m t),(X N (perm t (l.castAdd (h t))):ℝ)^2)*(L N:ℝ))/R N) atTop (𝓝 0)) + (hWM : ∀ N,(primorial (w0 N):ℤ)∣(M N:ℤ)) + (hM : ∀ N,0(X N (perm t (j.castAdd (h t))):ℝ)/(L N:ℝ)) atTop atTop) + (g x : ∀ t,ℕ→(Fin (h t)→ℕ)→Label (m t)→∀ i,G t i) + (slot : ∀ t,ℕ→(Fin (h t)→ℕ)→Label (m t)→ι t→ℤ) + (qval : ∀ t,ℕ→(Fin (h t)→ℕ)→Label (m t)→Fin (q t)→ℤ) + (hQ : ∀ t N y,y∈outsideDomain (fun l : Fin (h t)=>X N (perm t (l.natAdd (m t)))) (primorial (w0 N)) → + ∀ b,b∈(fullDomain (fun l : Fin (m t)=>X N (perm t (l.castAdd (h t)))) (Xp N) (primorial (w0 N))).image + (expose (L N) (M N:ℤ) (R N)) →∀ k,|(qval t N y b k:ℝ)|≤Q N) + (metric : ∀ t i,MetricSpace ((G t i)⧸Γ t i)) + (hmetric : ∀ t i,QuotientGroup.instTopologicalSpace (Γ t i)=(metric t i).toUniformSpace.toTopologicalSpace) : + letI : ∀ t i,MetricSpace ((G t i)⧸Γ t i):=fun t i=>(metric t i).replaceTopology (hmetric t i) + ∀ (Obs : ℕ→((Fin a→ℕ)×ℕ)→∀ t i,((G t i)⧸Γ t i) →ᵇ ℝ) (Kobs : ℝ≥0) (Bobs : ℝ) + (_hLip : ∀ N z t i,LipschitzWith Kobs (Obs N z t i)) + (_hBound : ∀ N z t i y,|Obs N z t i y|≤Bobs) + (J : ℕ→ℕ) (_hJ : ∀ N,0(jointLaw (X N) (Xp N) (primorial (w0 N)) (primorial_pos _) + (hX N) (hXp N)) {z | fullCell (Xp N) (M N) (J N) z.2 ∧ + cellRatio (Xp N) (primorial (w0 N)) (M N) (J N) z.2 (primorial_pos _) (hXp N) + {k | QuotientGroup.mk (rawLocalOrbit D G n q c hsk A w hA hw m h perm + (M N) (J N) (L N) (R N) (fun t=>g t N) (fun t=>x t N) + (fun t=>slot t N) (fun t=>qval t N) z (k:ℤ)) ∈ + intrinsicSuccess D G n q c hsk A w hA Γ coord s r hs1 formula (Obs N z) Fs q₀ b τ} + ≤ ((pivotOptions s r hs1 D Fs).card : ℝ)⁻¹/3}) atTop (𝓝 0) + := by + classical + let : ∀ t i,MetricSpace ((G t i)⧸Γ t i):=fun t i=>(metric t i).replaceTopology (hmetric t i) + intro Obs Kobs Bobs hLip hBound J hJ hRJ r hs1 formula Fs Bs q₀ hq₀ b hb τ hτ + have hd:=source_intrinsic_decay D G n q c hsk A w hA hw Γ coord + hΓ hmono s h0 h1 hs a m h perm w0 M Xp X R Q L hw0 hX hXp hXt hXpt hR hRX hZ hQ0 + hSize hWM hM hMs hL hsm hWL hML hLexact hXL g x slot qval hQ metric hmetric + Obs Kobs Bobs hLip hBound J hJ hRJ r hs1 formula Fs Bs q₀ hq₀ b hb τ hτ + let c₀ : ℝ≥0:=((pivotOptions s r hs1 D Fs).card : ℝ≥0)⁻¹ + have hc₀ : (0:ℝ)<(c₀:ℝ) := by + dsimp [c₀] + simp only [NNReal.coe_natCast] + exact inv_pos.mpr (by exact_mod_cast Finset.card_pos.mpr (pivotOptions_nonempty s r hs1 D Fs)) + have hsmall : ∀ᶠ N in atTop,R N/(Xp N:ℝ)≤(c₀:ℝ)/6:= + hRX.eventually_le_const (by positivity) + apply tendsto_order.mpr + constructor + · intro ε hε + exact (not_lt_of_ge bot_le hε).elim + · intro ε hε + filter_upwards [hsmall,(tendsto_order.mp hd).2 ε hε] with N hN hεN + apply lt_of_le_of_lt ?_ hεN + apply measure_mono_ae + filter_upwards [joint_ae_fullDomain (X N) (Xp N) (primorial (w0 N)) + (primorial_pos _) (hX N) (hXp N)] with z hz + intro hbad + by_contra hgood + have hgood := lt_of_not_ge hgood + have hdvd : primorial (w0 N)∣M N := by exact_mod_cast hWM N + have hp : (primorial (w0 N)).Coprime z.2:=(Finset.mem_filter.mp hz).2 + have hsize' : ((M N*J N:ℕ):ℝ)/(Xp N:ℝ)≤(c₀:ℝ)/6 := by + simpa only [Nat.cast_mul,hRJ] using hN + have ht:=scalar_to_harmonic (Xp N) (primorial (w0 N)) (M N) (J N) z.2 + (primorial_pos _) (hXp N) (hM N) (hJ N) hdvd hp hbad.1 c₀ hsize' _ hgood + dsimp [c₀] at ht + simp only [NNReal.coe_natCast] at ht + exact (not_lt_of_ge hbad.2) ht + +end SourceIntegerArrays + +end +end + +end OAI diff --git a/lean/OAI/Combinatorics/SumProduct/Alignment/IntegerArrays09.lean b/lean/OAI/Combinatorics/SumProduct/Alignment/IntegerArrays09.lean new file mode 100644 index 0000000000000000000000000000000000000000..a11bff702fdf297753beb34f53c141bdc07c7c33 --- /dev/null +++ b/lean/OAI/Combinatorics/SumProduct/Alignment/IntegerArrays09.lean @@ -0,0 +1,274 @@ +import Mathlib +import OAI.Combinatorics.SumProduct.Alignment.MacroSelection01 +import OAI.Geometry.NilpotentCharts.Main + +namespace OAI + +open scoped BigOperators +section +noncomputable section +namespace SourceIntegerArrays +open SourceResidueAlignment ProductExposureLabels +open scoped BigOperators +lemma number_mod {m v q : ℕ} (M : ℕ) (L : ℤ) (hML : (M:ℤ)∣L) + (R : ℝ) (z : (Fin m→ℕ)×ℕ) (pstar : ℤ) + (hpstar : (M:ℤ)∣pstar-(z.2:ℤ)) (slot : ℤ) (pat : Fin (v+1)→ℤ) + (β : Fin (v+1)→ℤ) (qval u : Fin q→ℤ) : + number M L (expose L (M:ℤ) R z) (fun j=>(z.1 j:ℤ)) pstar slot pat β qval u%(M:ℤ)= + rSlot M (expose L (M:ℤ) R z) slot := by + have hd:=slot_numerator_div M L hML R z pstar hpstar slot (∑j,pat j*β j) + have he : (M:ℤ)∣number M L (expose L (M:ℤ) R z) (fun j=>(z.1 j:ℤ)) pstar slot pat β qval u- + rSlot M (expose L (M:ℤ) R z) slot := by + unfold number + rw [add_sub_right_comm] + exact dvd_add hd (dvd_mul_right _ _) + have hh := (Int.modEq_iff_dvd.mpr he).symm + simpa only [rSlot,Int.ModEq,Int.emod_emod] using hh + +lemma number_index {m v q : ℕ} (M : ℕ) (hM : 0(z.1 j:ℤ)) pstar (slot i) (pattern i) β qval u + left R b-(C:ℤ)*width R b≤N ∧ N≤left R b+((C:ℤ)+1)*width R b) : + let b:=expose L (M:ℤ) (R:ℝ) z + pieceModel (Γ i) M H (g i) (x i) (obs i) + (number M L b (fun j=>(z.1 j:ℤ)) pstar (slot i) (pattern i) β qval u)= + obs i (modelBin H R b) (rSlot M b (slot i)) + (QuotientGroup.mk ((literalState G n q c hsk A w hA hw M L b (fun j=>(z.1 j:ℤ)) + pstar pattern (fun j=>g j (modelBin H R b) (rSlot M b (slot j))) + (fun j=>x j (modelBin H R b) (rSlot M b (slot j))) slot qval β i).val (fun e=>(u e:ℝ)))) + := by + dsimp only + rw [pieceModel] + rw [stable_value C H R hH _ hs _ hbound] + rw [number_mod M L hML (R:ℝ) z pstar hpstar (slot i) (pattern i) β qval u] + rw [number_index M hM] + dsimp only [literalState,PolynomialArrays.sourceElement] + rw [←realPower_int (c i)] + congr 4 + simp [exponent] + +end SourceIntegerArrays +end + +noncomputable section +namespace SourceIntegerArrays +open SourceResidueAlignment ProductExposureLabels SourceMacroSelection +open scoped BigOperators + + +theorem source_numeric_window {m v q : ℕ} (M : ℕ) (L : ℤ) + (hL : 0(z.1 j:ℤ)) pstar slot pat β qval u + left R b-((2^m+1:ℕ):ℤ)*width R b≤N ∧ + N≤left R b+(((2^m+1:ℕ):ℤ)+1)*width R b + := by + let b:=expose L (M:ℤ) (R:ℝ) z + let t : ℝ:=∏ j,(z.1 j:ℝ) + let N:=number M L b (fun j=>(z.1 j:ℤ)) pstar slot pat β qval u + have htpos : 0by exact_mod_cast ht j) + have hlpos : (0:ℝ)(z.1 j:ℤ)):ℝ)|≤Q+t*(L:ℝ) := by + have he:=shift_mul M L hL hML (R:ℝ) z hcop (qval e) + have heR : (M:ℝ)*(shift M L (qval e) b (fun j=>(z.1 j:ℤ)):ℝ)= + (qval e:ℝ)-t*(residueData L (qval e) b:ℝ) := by + dsimp [t,b] + exact_mod_cast he + have hrr:=residue_spec L (∏ j,b.residue j) (qval e) hL hcop + have hr0 : (0:ℝ)≤residueData L (qval e) b := by exact_mod_cast hrr.1 + have hrl : (residueData L (qval e) b:ℝ)≤L := by exact_mod_cast hrr.2.1.le + rw [heR] + calc + _ ≤ |(qval e:ℝ)|+|t*(residueData L (qval e) b:ℝ)| := abs_sub _ _ + _ ≤ Q+t*(L:ℝ) := by + rw [abs_of_nonneg (mul_nonneg htpos.le hr0)] + exact add_le_add (hq e) (mul_le_mul_of_nonneg_left hrl htpos.le) + have hsum : |(M:ℝ)*(∑ e,(shift M L (qval e) b (fun j=>(z.1 j:ℤ)):ℝ)*(u e:ℝ))|≤K*(Q+t*(L:ℝ)) := by + rw [Finset.mul_sum] + calc + _ ≤ ∑ e,|(M:ℝ)*((shift M L (qval e) b (fun j=>(z.1 j:ℤ)):ℝ)*(u e:ℝ))| := Finset.abs_sum_le_sum_abs _ _ + _ ≤ ∑ e,(Q+t*(L:ℝ))*|(u e:ℝ)| := by + apply Finset.sum_le_sum + intro e _ + rw [←mul_assoc,abs_mul] + exact mul_le_mul_of_nonneg_right (hs e) (abs_nonneg _) + _ = (Q+t*(L:ℝ))*(∑ e,|(u e:ℝ)|) := (Finset.mul_sum _ _ _).symm + _ ≤ (Q+t*(L:ℝ))*K := mul_le_mul_of_nonneg_left hinput (by positivity) + _ = _ := mul_comm _ _ + have hdiff : |(N:ℝ)-t*(z.2:ℝ)|≤t*(R:ℝ)+R := by + have he : (N:ℝ)-t*(z.2:ℝ)= + t*(((pstar+(M:ℤ)*(∑ j,pat j*β j)):ℝ)-(z.2:ℝ))+ + t*(slot:ℝ)+(M:ℝ)*(∑ e,(shift M L (qval e) b (fun j=>(z.1 j:ℤ)):ℝ)*(u e:ℝ)) := by + dsimp [N,number,t] + push_cast + ring + rw [he] + have hbasereal : |t*(((pstar+(M:ℤ)*(∑ j,pat j*β j)):ℝ)-(z.2:ℝ))|≤t*(R:ℝ) := by + rw [abs_mul,abs_of_pos htpos] + exact mul_le_mul_of_nonneg_left hbase htpos.le + have hslotreal : |t*(slot:ℝ)|≤K*(t*(L:ℝ)) := by + rw [abs_mul,abs_of_pos htpos] + calc + _ ≤ t*(K*(L:ℝ)) := mul_le_mul_of_nonneg_left hslot htpos.le + _ = _ := by ring + have hext : K*(t*(L:ℝ))+K*(Q+t*(L:ℝ))≤R := by + have htd := mul_le_mul_of_nonneg_right hD hlpos.le + have hkt := mul_le_mul_of_nonneg_left htd hK + have hkq : 0≤K*Q := mul_nonneg hK hQ + nlinarith + exact (abs_add_le _ _).trans ((add_le_add ((abs_add_le _ _).trans + (add_le_add hbasereal hslotreal)) hsum).trans (by linarith)) + obtain ⟨hdy,hlo,hhi⟩:=expose_bounds L (M:ℤ) (R:ℝ) hrpos z ht + obtain ⟨htlo,htup⟩:=product_dyadic_bounds b z.1 hdy + have hwidth : (R:ℝ)≤(width R b:ℝ) := by + rw [width_cast] + change (R:ℝ)≤(∏ j : Fin m,(2:ℝ)^(b.dyadic j))*(R:ℝ) + have hh : (1:ℝ)≤∏ j : Fin m,(2:ℝ)^(b.dyadic j) := by + apply Finset.one_le_prod₀ + intro j _ + exact one_le_pow₀ (by norm_num) + nlinarith + have htw : t*(R:ℝ)≤(2:ℝ)^m*(width R b:ℝ) := by + rw [width_cast] + change t*(R:ℝ)≤(2:ℝ)^m*((∏ j,b.scales j)*(R:ℝ)) + have hh:=mul_le_mul_of_nonneg_right htup hrpos.le + change t*(R:ℝ)≤_ at hh + nlinarith + have hh : |(N:ℝ)-t*(z.2:ℝ)|≤((2:ℝ)^m+1)*(width R b:ℝ) := by + nlinarith + obtain ⟨hnlo,hnhi⟩:=abs_le.mp hh + change b.left (R:ℝ)≤t*(z.2:ℝ) at hlo + change t*(z.2:ℝ)(z.1 j:ℤ)) pstar + (slot+∑ e,residueData L (qval e) (expose L (M:ℤ) R z)*u e) pat β qval u= + (∏ j,(z.1 j:ℤ))*(pstar+(M:ℤ)*(∑ j,pat j*β j)+slot)+∑ e,qval e*u e := by + let b:=expose L (M:ℤ) R z + let t : ℤ:=∏ j,(z.1 j:ℤ) + have hh : (M:ℤ)*(∑ e,shift M L (qval e) b (fun j=>(z.1 j:ℤ))*u e)= + (∑ e,qval e*u e)-t*(∑ e,residueData L (qval e) b*u e) := by + rw [Finset.mul_sum,Finset.mul_sum,←Finset.sum_sub_distrib] + apply Finset.sum_congr rfl + intro e _ + rw [←mul_assoc,shift_mul M L hL hML R z hcop] + dsimp [t,b] + ring + change t*(pstar+(M:ℤ)*(∑ j,pat j*β j)+(slot+∑ e,residueData L (qval e) b*u e))+ + (M:ℤ)*(∑ e,shift M L (qval e) b (fun j=>(z.1 j:ℤ))*u e)=_ + rw [hh] + ring + + +omit [Fintype ι] in +theorem source_terminal_model_reading {m v : ℕ} (M : ℕ) (hM : 0slot i+∑ e,residueData L (qval e) b*u e + pieceModel (Γ i) M H (g i) (x i) (obs i) + ((∏ j,(z.1 j:ℤ))*(pstar+(M:ℤ)*(∑ j,pattern i j*β j)+slot i)+∑ e,qval e*u e)= + obs i (modelBin H R b) (rSlot M b (newslot i)) + (QuotientGroup.mk ((literalState G n q c hsk A w hA hw M L b (fun j=>(z.1 j:ℤ)) + pstar pattern (fun j=>g j (modelBin H R b) (rSlot M b (newslot j))) + (fun j=>x j (modelBin H R b) (rSlot M b (newslot j))) newslot qval β i).val (fun e=>(u e:ℝ)))) + := by + dsimp only + rw [←source_number_terminal M L hL hML (R:ℝ) z hcop pstar (slot i) (pattern i) β qval u] + apply source_literal_model_reading G n q c hsk A w hA hw M hM L hML (2^m+1) H R hH z hst + pstar hpstar pattern (fun j=>slot j+∑ e,residueData L (qval e) (expose L (M:ℤ) (R:ℝ) z)*u e) + qval β u Γ g x obs i + exact source_numeric_window M L hL hML R hR z ht hcop pstar _ (pattern i) β qval u + K Q D hK hQ hD hbase (by simpa only [Int.cast_add] using hslot) hinput hq hsmall + +end SourceIntegerArrays + +end +end + +end OAI diff --git a/lean/OAI/Combinatorics/SumProduct/Alignment/IntegerArrays10.lean b/lean/OAI/Combinatorics/SumProduct/Alignment/IntegerArrays10.lean new file mode 100644 index 0000000000000000000000000000000000000000..e0b777af5ce8fa9773191678f1be9a3f4c8e9441 --- /dev/null +++ b/lean/OAI/Combinatorics/SumProduct/Alignment/IntegerArrays10.lean @@ -0,0 +1,311 @@ +import Mathlib +import OAI.Combinatorics.SumProduct.Alignment.IntegerArrays09 +import OAI.Geometry.NilpotentCharts.Main + +namespace OAI + +open scoped BigOperators +section +noncomputable section +end + +noncomputable section +namespace SourceIntegerArrays.GlobalJoint +open SourceResidueAlignment ProductExposureLabels SourceMacroSelection +open RationalLattice MalcevCharacters RoughArrayFace RoughArrayCoordinates +open ConstructedWordPlan.GlobalWordPlan +open AllLevelFactorization AllLevelFactorization.Factorization MeasureTheory +open ConstructedWordPlan.AlignmentScales ConstructedWordPlan.RationalPivotPlan +open Filter +open scoped BigOperators Topology NNReal ENNReal BoundedContinuousFunction +attribute [local instance] Classical.propDecidable +variable {a : ℕ} (D : Pivot a) {ι : Fin D.targets→Type} [∀ t,Fintype (ι t)] +variable (G : ∀ t,ι t→Type) [∀ t i,Group (G t i)] +variable [∀ t i,TopologicalSpace (G t i)] [∀ t i,IsTopologicalGroup (G t i)] +variable (n : ∀ t,ι t→ℕ) (q : Fin D.targets→ℕ) (c : ∀ t i,RealCoordinates (G t i) (n t i)) +variable (hsk : ∀ t i,SecondKind (c t i)) (A : ∀ t i,CubeFaces.Filtration (G t i)) +variable (w : ∀ t i,Fin (n t i)→ℕ) +variable (hA : ∀ t i k (g : G t i),g∈(A t i).level k ↔ ∀ j,w t i j((d.z t).1 j:ℤ)) d.pstar d.slot d.qval + (fun t i=>d.g t i (d.bin t) (d.residue t i)) + (fun t i=>d.x t i (d.bin t) (d.residue t i)) k + +def value (k : ℤ) (t : Fin D.targets) (i : ι t) (u : Fin (q t)→ℤ) : ℝ := + pieceModel (Γ t i) d.M (d.H t) (d.g t i) (d.x t i) (fun b r=>d.obs t i b r) + ((∏ j,((d.z t).1 j:ℤ))*(d.pstar t+(d.M:ℤ)*k+d.slot t i)+ + (d.M:ℤ)*(∑ e,shift d.M d.L (d.qval t e) (d.label t) (fun j=>((d.z t).1 j:ℤ))*u e)) + + +def modelSuccess (k : ℤ) (s r : ℕ) (hs1 : 1 ≤ s) + (formula : ∀ t,ℚ→Slots D→Fin r→ι t) (Fs : Finset (Scale a)) + (q₀ : ℕ) (b : Scale a) (τ : ℝ) : Prop := + ∃ p∈pivotOptions s r hs1 D Fs,∀ i : Comparison D Fs r, + let t:=i.2.1.1 + let a₀:=blockProduct (scaleRun D 0 p b*i.1.val) (block D.index D.tail t) + let v:=jumpSlot D q₀ p b + let z:=terminalShift D q₀ (scaleRun D 0 p b*i.1.val) i.2.1.2.val + 2*τ1) (fun _=>k) (d.qval t) u K Q V hK hQ hV + (by simpa only [Fin.sum_univ_one,one_mul,Finset.sum_const,Finset.card_univ,Fintype.card_fin,Nat.zero_add,one_nsmul] using hbase) + hslot hinput hq hsmall + have he:=source_literal_model_reading (v:=0) (G t) (n t) (q t) (c t) (hsk t) (A t) (w t) (hA t) (hw t) + d.M hM d.L hML (2^(d.m t)+1) (d.H t) d.R hH (d.z t) hst (d.pstar t) hpstar + (fun _ (_ : Fin 1)=>1) (d.slot t) (d.qval t) (fun _=>k) u (Γ t) (d.g t) (d.x t) + (fun i b r=>d.obs t i b r) i hb + change d.frozenObs t i (QuotientGroup.mk + ((targetHom G n q c hsk A w hA t (d.state n c hsk A w hA hw k) i).val + (fun e=>(u e:ℝ))))=d.value k t i u + rw [state,target_rawJoint] + simpa only [frozenObs,bin,residue,label,value,number,Fin.sum_univ_one,one_mul, + Finset.sum_const,Finset.card_univ,Fintype.card_fin,Nat.zero_add,one_nsmul] using he.symm +end LocalModels + + + +omit [∀ t,Fintype (ι t)] in +theorem source_model_event (d : LocalModels D G q Γ) (k : ℤ) + (hM : 0targetCoset G n q c hsk A w hA Γ (FullLattice G n q c hsk A w hA Γ) le_rfl t x) + (modelRead D G n q c hsk A w hA Γ formula d.frozenObs) Fs q₀ b p i + (QuotientGroup.mk (d.state n c hsk A w hA hw k)) = + d.value k i.2.1.1 + (formula i.2.1.1 (blockProduct (scaleRun D 0 p b*i.1.val) (block D.index D.tail i.2.1.1)) + (jumpSlot D q₀ p b) i.2.2) 0 := by + apply d.actual_reading n c hsk A w hA hw k _ _ _ hM hR hL hML (hH _) (ht _) (hst _) (hcop _) + (hpstar _) K Q (V _) hK hQ (hV _) (hbase _) (hslot _ _) (hq _) (hsmall _) + simpa using hK + have ht' (p : Path D) (hp : p∈pivotOptions s r hs1 D Fs) (i : Comparison D Fs r) : + intrinsicTerminal D G n q c hsk A w hA Γ coord formula d.frozenObs Fs q₀ b p i + (QuotientGroup.mk (d.state n c hsk A w hA hw k)) = + d.value k i.2.1.1 + (formula i.2.1.1 (blockProduct (scaleRun D 0 p b*i.1.val) (block D.index D.tail i.2.1.1)) + ((terminalShift D q₀ (scaleRun D 0 p b*i.1.val) i.2.1.2.val).toAdd+jumpSlot D q₀ p b) i.2.2) + (ownInput D q coord i.2.1.1 (terminalShift D q₀ (scaleRun D 0 p b*i.1.val) i.2.1.2.val).toAdd) := by + exact d.actual_reading n c hsk A w hA hw k _ _ _ hM hR hL hML (hH _) (ht _) (hst _) (hcop _) + (hpstar _) K Q (V _) hK hQ (hV _) (hbase _) (hslot _ _) (hq _) (hsmall _) (hinput p hp i) + simp only [intrinsicSuccess,Set.mem_iUnion,AlignmentMass.Success,Set.mem_ofPred_eq, + LocalModels.modelSuccess] + apply exists_congr + intro p + rw [exists_prop] + apply and_congr_right + intro hp + apply forall_congr' + intro i + rw [hc p i,ht' p hp i] + +end SourceIntegerArrays.GlobalJoint +end + +noncomputable section +namespace SourceIntegerArrays.GlobalJoint +open SourceResidueAlignment ProductExposureLabels SourceMacroSelection +open RationalLattice MalcevCharacters RoughArrayFace RoughArrayCoordinates +open ConstructedWordPlan.GlobalWordPlan +open AllLevelFactorization AllLevelFactorization.Factorization MeasureTheory +open ConstructedWordPlan.AlignmentScales ConstructedWordPlan.RationalPivotPlan +open Filter +open scoped BigOperators Topology NNReal ENNReal BoundedContinuousFunction +attribute [local instance] Classical.propDecidable +variable {a₀ : ℕ} (D : Pivot a₀) {ι : Fin D.targets→Type} [∀ t,Fintype (ι t)] +variable (G : ∀ t,ι t→Type) [∀ t i,Group (G t i)] +variable [∀ t i,TopologicalSpace (G t i)] [∀ t i,IsTopologicalGroup (G t i)] +variable (n : ∀ t,ι t→ℕ) (q : Fin D.targets→ℕ) (c : ∀ t i,RealCoordinates (G t i) (n t i)) +variable (hsk : ∀ t i,SecondKind (c t i)) (A : ∀ t i,CubeFaces.Filtration (G t i)) +variable (w : ∀ t i,Fin (n t i)→ℕ) +variable (hA : ∀ t i k (g : G t i),g∈(A t i).level k ↔ ∀ j,w t i jz.1 (d.perm t (j.castAdd (d.h t))),z.2) +def exposure (z : (Fin a→ℕ)×ℕ) (t : Fin D.targets) := + expose d.L (d.M:ℤ) (d.R:ℝ) (d.inner z t) +def localModel (z : (Fin a→ℕ)×ℕ) : LocalModels D G q Γ := + ⟨d.m,d.M,d.R,d.L,d.H,d.inner z,fun _=>firstPivot d.M d.J z.2, + fun t=>d.slot t (d.outer z t) (d.exposure z t), + fun t=>d.qval t (d.outer z t) (d.exposure z t), + fun t=>d.g t (d.outer z t),fun t=>d.x t (d.outer z t),fun t=>d.obs t (d.outer z t)⟩ +def selectedG (t : Fin D.targets) (y : Fin (d.h t)→ℕ) (b : Label (d.m t)) (i : ι t) : G t i := + d.g t y i (modelBin (d.H t) d.R b) (rSlot d.M b (d.slot t y b i)) +def selectedX (t : Fin D.targets) (y : Fin (d.h t)→ℕ) (b : Label (d.m t)) (i : ι t) : G t i := + d.x t y i (modelBin (d.H t) d.R b) (rSlot d.M b (d.slot t y b i)) +def orbit (z : (Fin a→ℕ)×ℕ) (k : ℤ) : Full G n q c hsk A w hA := + rawLocalOrbit D G n q c hsk A w hA hw d.m d.h d.perm d.M d.J d.L (d.R:ℝ) + d.selectedG d.selectedX d.slot d.qval z k +end RawModels + +private lemma cellRatio_congr_on_cell (X W M J p : ℕ) (hW : 0 nlinarith + + +omit [∀ t,Fintype (ι t)] in +theorem source_cell_model {a : ℕ} (d : RawModels D G q Γ a) (z : (Fin a→ℕ)×ℕ) + (hM : 0firstPivot_congruent d.M d.J z.2) + K Q V hK hQ hV (by simpa only [Int.cast_add,Int.cast_mul,Int.cast_natCast] using hbase) hslot hq hsmall s r hs1 formula Fs q₀ b τ hinput + exact he + +end SourceIntegerArrays.GlobalJoint + +end +end + +end OAI diff --git a/lean/OAI/Combinatorics/SumProduct/Alignment/IntegerArrays11.lean b/lean/OAI/Combinatorics/SumProduct/Alignment/IntegerArrays11.lean new file mode 100644 index 0000000000000000000000000000000000000000..3cba25c5fa209d8fda212ed7f9106cfd41f1bfc4 --- /dev/null +++ b/lean/OAI/Combinatorics/SumProduct/Alignment/IntegerArrays11.lean @@ -0,0 +1,266 @@ +import Mathlib +import OAI.Combinatorics.SumProduct.Alignment.IntegerArrays10 +import OAI.Combinatorics.SumProduct.Alignment.MacroSelection02 +import OAI.Geometry.NilpotentCharts.Main + +namespace OAI + +open scoped BigOperators +section +noncomputable section +open Filter Topology +open scoped BigOperators +end + +noncomputable section +namespace SourceIntegerArrays.GlobalJoint +open SourceResidueAlignment ProductExposureLabels SourceMacroSelection +open RationalLattice MalcevCharacters RoughArrayFace RoughArrayCoordinates +open ConstructedWordPlan.GlobalWordPlan +open AllLevelFactorization AllLevelFactorization.Factorization MeasureTheory +open ConstructedWordPlan.AlignmentScales ConstructedWordPlan.RationalPivotPlan +open Filter RoughFaceShift RoughScales IntegerAlignment +open RoughSamplingWeights RoughSourceExceptional RoughProductRemoval ProductExposureLaw +open RawHarmonicProbability +open MicrocellScale AdmissibleMicrocellBoundary +open scoped BigOperators Topology NNReal ENNReal BoundedContinuousFunction +attribute [local instance] Classical.propDecidable +variable {a₀ : ℕ} (D : Pivot a₀) {ι : Fin D.targets→Type} [∀ t,Fintype (ι t)] +variable (G : ∀ t,ι t→Type) [∀ t i,Group (G t i)] +variable [∀ t i,TopologicalSpace (G t i)] [∀ t i,IsTopologicalGroup (G t i)] +variable (n : ∀ t,ι t→ℕ) (q : Fin D.targets→ℕ) (c : ∀ t i,RealCoordinates (G t i) (n t i)) +variable (hsk : ∀ t i,SecondKind (c t i)) (A : ∀ t i,CubeFaces.Filtration (G t i)) +variable (w : ∀ t i,Fin (n t i)→ℕ) +variable (hA : ∀ t i k (g : G t i),g∈(A t i).level k ↔ ∀ j,w t i jd.H N, + fun t=>d.slot t N,fun t=>d.qval t N,fun t=>d.g t N,fun t=>d.x t N,fun t=>d.obs t N⟩ +end ModelFamily +include hsk hA hw + + + +theorem source_model_harmonic + (hΓ : ∀ t i g,g∈Γ t i ↔ ∀ j,∃ z : ℤ,(c t i).coord g j=z) + (hmono : ∀ t i,Monotone (w t i)) (s : ℕ) + (h0 : ∀ t i,(A t i).level 0=⊤) (h1 : ∀ t i,(A t i).level 1=⊤) + (hs : ∀ t i,(A t i).level (s+1)=⊥) + (a : ℕ) (d : ModelFamily D G q Γ a) + (w0 Xp P : ℕ→ℕ) (X : ℕ→Fin a→ℕ) (Q : ℕ→ℝ) + (hw0 : Tendsto w0 atTop atTop) + (hX : ∀ N j,4*primorial (w0 N)≤X N j) (hXp : ∀ N,4*primorial (w0 N)≤Xp N) + (hXt : ∀ j,Tendsto (fun N=>X N j) atTop atTop) (hXpt : Tendsto Xp atTop atTop) + (hWM : ∀ N,(primorial (w0 N):ℤ)∣(d.M N:ℤ)) + (hM : ∀ N,0(X N (d.perm t (j.castAdd (d.h t))):ℝ)/(d.L N:ℝ)) atTop atTop) + (hH : ∀ N,0(d.H N:ℝ)) (earlierScale d.M P)) + (hx : Dominates (fun N=>Real.log (Xp N:ℝ)) (fun N=>(d.H N:ℝ))) + (hprod : ∀ t,∀ᶠ N in atTop,(∀ j : Fin (d.m t),X N (d.perm t (j.castAdd (d.h t)))≤P N) ∧ + (∏ j : Fin (d.m t),(X N (d.perm t (j.castAdd (d.h t))):ℝ)^2)≤(P N:ℝ)^2) + (hQ0 : ∀ N,0≤Q N) (hQsize : ∀ᶠ N in atTop,Q N≤(d.M N:ℝ)*(P N:ℝ)^2) + (hLsize : ∀ᶠ N in atTop,(d.L N:ℝ)≤(d.M N:ℝ)^2) + (K : ℝ) (hK : 0≤K) + (hslot : ∀ t N y,y∈outsideDomain (fun l : Fin (d.h t)=>X N (d.perm t (l.natAdd (d.m t)))) (primorial (w0 N)) → + ∀ b,b∈(fullDomain (fun l : Fin (d.m t)=>X N (d.perm t (l.castAdd (d.h t)))) (Xp N) (primorial (w0 N))).image + (expose (d.L N) (d.M N:ℤ) (d.R N:ℝ)) →∀ i,|(d.slot t N y b i:ℝ)|≤K*(d.L N:ℝ)) + (hQ : ∀ t N y,y∈outsideDomain (fun l : Fin (d.h t)=>X N (d.perm t (l.natAdd (d.m t)))) (primorial (w0 N)) → + ∀ b,b∈(fullDomain (fun l : Fin (d.m t)=>X N (d.perm t (l.castAdd (d.h t)))) (Xp N) (primorial (w0 N))).image + (expose (d.L N) (d.M N:ℤ) (d.R N:ℝ)) →∀ k,|(d.qval t N y b k:ℝ)|≤Q N) + (metric : ∀ t i,MetricSpace ((G t i)⧸Γ t i)) + (hmetric : ∀ t i,QuotientGroup.instTopologicalSpace (Γ t i)=(metric t i).toUniformSpace.toTopologicalSpace) : + letI : ∀ t i,MetricSpace ((G t i)⧸Γ t i):=fun t i=>(metric t i).replaceTopology (hmetric t i) + ∀ (Kobs : ℝ≥0) (Bobs : ℝ) + (_hLip : ∀ t N y i b r,LipschitzWith Kobs (d.obs t N y i b r)) + (_hBound : ∀ t N y i b r z,|d.obs t N y i b r z|≤Bobs) + (r : ℕ) (hs1 : 1 ≤ s) (formula : ∀ t,ℚ→Slots D→Fin r→ι t) + (Fs Bs : Finset (Scale a₀)) (q₀ : ℕ) (_hq₀ : pivotModulus s r hs1 D Fs Bs∣q₀) + (b : Scale a₀) (_hb : b∈Bs) (τ : ℝ) (_hτ : 0<τ) + (_hinput : ∀ p∈pivotOptions s r hs1 D Fs,∀ i : Comparison D Fs r, + ∑ e,|(ownInput D q coord i.2.1.1 + (terminalShift D q₀ (scaleRun D 0 p b*i.1.val) i.2.1.2.val).toAdd e:ℝ)|≤K), + Tendsto (fun N=>(jointLaw (X N) (Xp N) (primorial (w0 N)) (primorial_pos _) (hX N) (hXp N)) + {z | cellRatio (Xp N) (primorial (w0 N)) (d.M N) (d.J N) z.2 (primorial_pos _) (hXp N) + {k | ((d.atTime N).localModel z).modelSuccess coord (k:ℤ) s r hs1 formula Fs q₀ b τ} + ≤((pivotOptions s r hs1 D Fs).card:ℝ)⁻¹/3}) atTop (𝓝 0) + := by + classical + let : ∀ t i,MetricSpace ((G t i)⧸Γ t i):=fun t i=>(metric t i).replaceTopology (hmetric t i) + intro Kobs Bobs hLip hBound r hs1 formula Fs Bs q₀ hq₀ b hb τ hτ hinput + have hR (N : ℕ) : 0X N (d.perm t (j.castAdd (d.h t)))) Q (fun N=>(d.L N:ℝ)) + (Filter.Eventually.of_forall (fun N=>⟨hM N,hP N,hH N⟩)) hd hx (hprod t) + (hQsize.mono (fun N hn=>⟨hQ0 N,hn⟩)) + (hLsize.mono (fun N hn=>⟨by exact_mod_cast (hL N).le,hn⟩)) + have hRX : Tendsto (fun N=>(d.R N:ℝ)/(Xp N:ℝ)) atTop (𝓝 0) := by + have hh:=(enlarged_rates 1 (Filter.Eventually.of_forall hM) + (Filter.Eventually.of_forall hH) hd hx).2 + simpa only [Nat.one_mul,←hRrad] using hh + have hZ : ∀ t (u : ℝ),0((d.R N:ℝ)/(d.M N:ℝ))/ + (1+∑ j : Fin (d.m t),(X N (d.perm t (j.castAdd (d.h t))):ℝ)^2)^u) atTop atTop := by + intro t u hu + simpa only [←hRrad] using (hrates t).2.2.1 u hu + have hSize : ∀ t,Tendsto (fun N=>(Q N+(∏ j : Fin (d.m t),(X N (d.perm t (j.castAdd (d.h t))):ℝ)^2)*(d.L N:ℝ))/(d.R N:ℝ)) + atTop (𝓝 0) := by + intro t + simpa only [←hRrad] using (hrates t).2.2.2 + let Obs := fun N z=>( (d.atTime N).localModel z).frozenObs + let I : ℕ→Set ((Fin a→ℕ)×ℕ) := fun N=> + {z | cellRatio (Xp N) (primorial (w0 N)) (d.M N) (d.J N) z.2 (primorial_pos _) (hXp N) + {k | QuotientGroup.mk ((d.atTime N).orbit n c hsk A w hA hw z (k:ℤ))∈ + intrinsicSuccess D G n q c hsk A w hA Γ coord s r hs1 formula (Obs N z) Fs q₀ b τ} + ≤((pivotOptions s r hs1 D Fs).card:ℝ)⁻¹/3} + let S : ℕ→Set ((Fin a→ℕ)×ℕ) := fun N=> + {z | ∃ t,¬Stable (2^(d.m t)+1) (d.H N) (d.R N) ((d.atTime N).exposure z t)} + let B : ℕ→Set ((Fin a→ℕ)×ℕ) := fun N=> + {z | cellRatio (Xp N) (primorial (w0 N)) (d.M N) (d.J N) z.2 (primorial_pos _) (hXp N) + {k | ((d.atTime N).localModel z).modelSuccess coord (k:ℤ) s r hs1 formula Fs q₀ b τ} + ≤((pivotOptions s r hs1 D Fs).card:ℝ)⁻¹/3} + have hi:=source_harmonic_final D G n q c hsk A w hA hw Γ coord hΓ hmono s h0 h1 hs + a d.m d.h d.perm w0 d.M Xp X (fun N=>(d.R N:ℝ)) Q d.L hw0 hX hXp hXt hXpt + hRreal hRX hZ hQ0 hSize hWM hM hMs hL hsm hWL hML hLexact hXL + (fun t N=>(d.atTime N).selectedG t) (fun t N=>(d.atTime N).selectedX t) d.slot d.qval hQ + metric hmetric Obs Kobs Bobs + (fun N z t i=>hLip t N _ i _ _) (fun N z t i y=>hBound t N _ i _ _ y) + d.J hJ (fun N=>by exact_mod_cast hRJ N) r hs1 formula Fs Bs q₀ hq₀ b hb τ hτ + change Tendsto (fun N=>(jointLaw (X N) (Xp N) (primorial (w0 N)) (primorial_pos _) (hX N) (hXp N)) (I N)) + atTop (𝓝 0) at hi + have hiReal : Tendsto (fun N=>(jointLaw (X N) (Xp N) (primorial (w0 N)) (primorial_pos _) (hX N) (hXp N)).real (I N)) + atTop (𝓝 0) := by + simpa only [ENNReal.toReal_zero,measureReal_def,Function.comp_def] using (ENNReal.tendsto_toReal (show (0:ℝ≥0∞)≠⊤ by simp)).comp hi + have hbase : ∀ᶠ N in atTop,02^(d.m t)+1) + (fun N=>primorial (w0 N)) d.M P d.H Xp X d.L (fun N=>primorial_pos _) hX hXp hbase hd hx hp' + have hsReal : Tendsto (fun N=>(jointLaw (X N) (Xp N) (primorial (w0 N)) (primorial_pos _) (hX N) (hXp N)).real (S N)) + atTop (𝓝 0) := by + apply hm.congr + intro N + congr 1 + ext z + simp only [S,Set.mem_ofPred_eq,RawModels.exposure,RawModels.inner,ModelFamily.atTime,←hRrad] + rfl + have hsmall : ∀ᶠ N in atTop,∀ t,2*K*(Q N+(∏ j : Fin (d.m t),(X N (d.perm t (j.castAdd (d.h t))):ℝ)^2)*(d.L N:ℝ))≤d.R N := by + apply Filter.eventually_all.mpr + intro t + have hh : Tendsto (fun N=>2*K*((Q N+(∏ j : Fin (d.m t),(X N (d.perm t (j.castAdd (d.h t))):ℝ)^2)*(d.L N:ℝ))/(d.R N:ℝ))) + atTop (𝓝 0) := by simpa using (hSize t).const_mul (2*K) + filter_upwards [hh.eventually_lt_const (show (0:ℝ)<1 by norm_num)] with N hn + have hh' : (2*K*(Q N+(∏ j : Fin (d.m t),(X N (d.perm t (j.castAdd (d.h t))):ℝ)^2)*(d.L N:ℝ)))/(d.R N:ℝ)<1 := by + simpa only [mul_div_assoc] using hn + exact ((div_lt_iff₀ (hRreal N)).mp hh').le.trans_eq (one_mul _) + have hbound : ∀ᶠ N in atTop, + (jointLaw (X N) (Xp N) (primorial (w0 N)) (primorial_pos _) (hX N) (hXp N)).real (B N)≤ + (jointLaw (X N) (Xp N) (primorial (w0 N)) (primorial_pos _) (hX N) (hXp N)).real (S N)+ + (jointLaw (X N) (Xp N) (primorial (w0 N)) (primorial_pos _) (hX N) (hXp N)).real (I N) := by + filter_upwards [hsmall] with N hn + rw [←joint_restrict_fullDomain (X N) (Xp N) (primorial (w0 N)) (primorial_pos _) (hX N) (hXp N) (B N)] + apply le_trans (measureReal_mono ?_) (measureReal_union_le (S N) (I N)) + rintro z ⟨hzB,hz⟩ + by_cases hstable : ∀ t,Stable (2^(d.m t)+1) (d.H N) (d.R N) ((d.atTime N).exposure z t) + · apply Or.inr + obtain ⟨hzraw,hzunit⟩:=Finset.mem_filter.mp hz + obtain ⟨hzT,hzP⟩ : (∀ j,z.1 j∈units (X N j) (primorial (w0 N))) ∧ + z.2∈Finset.Ico (Xp N) ((Xp N)^2) := by + simpa [rawDomain,Finset.product_eq_sprod] using hzraw + have htail : ∀ t j,0<((d.atTime N).inner z t).1 j := by + intro t j + have hh:= (Finset.mem_Ico.mp (Finset.mem_filter.mp (hzT (d.perm t (j.castAdd (d.h t))))).1).1 + have hxj:=hX N (d.perm t (j.castAdd (d.h t))) + have hw':=primorial_pos (w0 N) + change 0by positivity) + intro j _ + exact_mod_cast (Finset.mem_Ico.mp (Finset.mem_filter.mp (hzT (d.perm t (j.castAdd (d.h t))))).1).2.le + have ho (t : Fin D.targets) : (d.atTime N).outer z t∈ + outsideDomain (fun j : Fin (d.h t)=>X N (d.perm t (j.natAdd (d.m t)))) (primorial (w0 N)) := by + apply Fintype.mem_piFinset.mpr + intro j + exact hzT _ + have hi' (t : Fin D.targets) : (d.atTime N).inner z t∈ + fullDomain (fun j : Fin (d.m t)=>X N (d.perm t (j.castAdd (d.h t)))) (Xp N) (primorial (w0 N)) := by + apply Finset.mem_filter.mpr + refine ⟨?_,hzunit⟩ + exact Finset.mem_product.mpr ⟨Fintype.mem_piFinset.mpr + (fun j : Fin (d.m t)=>hzT (d.perm t (j.castAdd (d.h t)))),hzP⟩ + have hb' (t : Fin D.targets) : (d.atTime N).exposure z t∈ + (fullDomain (fun j : Fin (d.m t)=>X N (d.perm t (j.castAdd (d.h t)))) (Xp N) (primorial (w0 N))).image + (expose (d.L N) (d.M N:ℤ) (d.R N:ℝ)) := + Finset.mem_image.mpr ⟨(d.atTime N).inner z t,hi' t,rfl⟩ + have he:=source_cell_model D G n q c hsk A w hA hw Γ coord (d.atTime N) z + (hM N) (hJ N) (hRJ N) (hL N) (hML N) (fun _=>hH N) htail hstable hc + K (Q N) (fun t=>∏ j : Fin (d.m t),(X N (d.perm t (j.castAdd (d.h t))):ℝ)^2) + hK (hQ0 N) hv (fun t i=>hslot t N _ (ho t) _ (hb' t) i) + (fun t e=>hQ t N _ (ho t) _ (hb' t) e) hn s r hs1 formula Fs q₀ b τ hinput + (Xp N) (primorial (w0 N)) (primorial_pos _) (hXp N) + dsimp only [I,B,Obs,Set.mem_ofPred_eq] at hzB ⊢ + exact he.le.trans hzB + · exact Or.inl (not_forall.mp hstable) + have hout : Tendsto (fun N=>(jointLaw (X N) (Xp N) (primorial (w0 N)) (primorial_pos _) (hX N) (hXp N)).real (B N)) + atTop (𝓝 0) := + squeeze_zero' (Filter.Eventually.of_forall (fun _=>measureReal_nonneg)) hbound + (by simpa only [zero_add] using hsReal.add hiReal) + exact (ENNReal.tendsto_toReal_zero_iff (fun _=>by finiteness)).mp hout + +end SourceIntegerArrays.GlobalJoint + +end +end + +end OAI diff --git a/lean/OAI/Combinatorics/SumProduct/Alignment/IntegerArrays12.lean b/lean/OAI/Combinatorics/SumProduct/Alignment/IntegerArrays12.lean new file mode 100644 index 0000000000000000000000000000000000000000..79f73baac9bbe14ba4a241c966068bba208b6d2e --- /dev/null +++ b/lean/OAI/Combinatorics/SumProduct/Alignment/IntegerArrays12.lean @@ -0,0 +1,329 @@ +import Mathlib +import OAI.Combinatorics.SumProduct.Alignment.IntegerArrays10 +import OAI.Geometry.NilpotentCharts.Main + +namespace OAI + +open scoped BigOperators +section +noncomputable section +end + +noncomputable section +namespace SourceIntegerArrays.GlobalJoint +open SourceResidueAlignment ProductExposureLabels SourceMacroSelection +open ConstructedWordPlan.GlobalWordPlan +open ConstructedWordPlan.AlignmentScales ConstructedWordPlan.RationalPivotPlan +open scoped BigOperators BoundedContinuousFunction +attribute [local instance] Classical.propDecidable +namespace FiniteModelSlots +variable {a : ℕ} (D : Pivot a) (s r : ℕ) (hs : 1 ≤ s) +variable (Fs : Finset (Scale a)) (q₀ : ℕ) (b : Scale a) + +def centerAV (p : Path D) (i : Comparison D Fs r) : ℚ×Slots D := + (blockProduct (scaleRun D 0 p b*i.1.val) (block D.index D.tail i.2.1.1),jumpSlot D q₀ p b) +def terminalAV (p : Path D) (i : Comparison D Fs r) : ℚ×Slots D := + ((centerAV D r Fs q₀ b p i).1, + (terminalShift D q₀ (scaleRun D 0 p b*i.1.val) i.2.1.2.val).toAdd+(centerAV D r Fs q₀ b p i).2) + + +def required : Finset (ℚ×Slots D) := + {(1,0)} ∪ (pivotOptions s r hs D Fs).biUnion (fun p=>Finset.univ.biUnion + (fun i : Comparison D Fs r=>{centerAV D r Fs q₀ b p i,terminalAV D r Fs q₀ b p i})) +abbrev Index := {av : ℚ×Slots D // av∈required D s r hs Fs q₀ b} × Fin r + +def formula (_t : Fin D.targets) (a₀ : ℚ) (v : Slots D) (col : Fin r) : Index D s r hs Fs q₀ b := + if h : (a₀,v)∈required D s r hs Fs q₀ b then (⟨(a₀,v),h⟩,col) + else (⟨(1,0),by simp [required]⟩,col) + +variable (G : Fin D.targets→Index D s r hs Fs q₀ b→Type) +variable [∀ t i,Group (G t i)] [∀ t i,TopologicalSpace (G t i)] +variable (q : Fin D.targets→ℕ) (Γ : ∀ t i,Subgroup (G t i)) +variable (coord : ∀ e,Fin (q (D.owner e))) +variable (d : LocalModels D G q Γ) + +def coefficient (e : Fin D.pairs) : ℤ := d.qval (D.owner e) (coord e) +def residue (e : Fin D.pairs) : ℤ := residueData d.L + (coefficient D s r hs Fs q₀ b G q Γ coord d e) (d.label (D.owner e)) +def slotSum (v : Slots D) : ℤ := ∑ e,v e*residue D s r hs Fs q₀ b G q Γ coord d e + +def compile : LocalModels D G q Γ := + { d with slot:=fun _ i=>slotSum D s r hs Fs q₀ b G q Γ coord d i.1.val.2 } +def scalar (t : Fin D.targets) (i : Index D s r hs Fs q₀ b) (N : ℤ) : ℝ := + pieceModel (Γ t i) d.M (d.H t) (d.g t i) (d.x t i) (fun j l=>d.obs t i j l) N + + +def numericSuccess (k : ℤ) (τ : ℝ) : Prop := + ∃ p∈pivotOptions s r hs D Fs,∀ i : Comparison D Fs r, + let t:=i.2.1.1 + let av:=centerAV D r Fs q₀ b p i + let av':=terminalAV D r Fs q₀ b p i + let z:=(terminalShift D q₀ (scaleRun D 0 p b*i.1.val) i.2.1.2.val).toAdd + let N:=(∏ j,((d.z t).1 j:ℤ))*(d.pstar t+(d.M:ℤ)*k+slotSum D s r hs Fs q₀ b G q Γ coord d av.2) + 2*τMultiplicative.ofAdd (v.toAdd e),map_one':=rfl,map_mul':=fun _ _=>rfl} + have hh : π (terminalShift D q₀ b U)=1 := by + simp only [terminalShift,baseWord,map_list_prod,List.map_map] + apply List.prod_eq_one + intro z hz + obtain ⟨f,hf,rfl⟩:=List.mem_map.mp hz + simp only [Function.comp_apply,FreeGroup.lift_apply_of,letter] + change π ((unitShift D f)^(qExponent D.index D.tail D.owner D.added q₀ b (f,1)).num)=1 + rw [map_zpow] + have hfe : e≠f := by + intro hef + subst f + exact he (hU e (Finset.mem_toList.mp hf)) + have hπ : π (unitShift D f)=1 := by + change (Pi.single f (1:ℤ) : Slots D) e=0 + simp [hfe] + rw [hπ,one_zpow] + exact hh + +private lemma input_pairing (t : Fin D.targets) (v : Slots D) + (hv : ∀ e,D.owner e≠t → v e=0) (f : Fin (q t)→ℤ) (A : Fin D.pairs→ℤ) + (ha : ∀ e (h : D.owner e=t),A e=f (h ▸ coord e)) : + (∑ j,f j*ownInput D q coord t v j)=∑ e,v e*A e := by + classical + simp only [ownInput,Finset.sum_apply,zsmul_eq_mul,Finset.mul_sum] + rw [Finset.sum_comm] + apply Finset.sum_congr rfl + intro e _ + calc + (∑ j,f j*(v e*ownBasis D q coord t e j)) = v e*∑ j,f j*ownBasis D q coord t e j := by + rw [Finset.mul_sum] + apply Finset.sum_congr rfl + intro j _ + ring + _ = v e*A e := by + by_cases he : D.owner e=t + · subst t + rw [ha e rfl] + simp [ownBasis,Pi.single_apply] + · rw [hv e he] + simp + +private lemma slotSum_add (v z : Slots D) : + slotSum D s r hs Fs q₀ b G q Γ coord d (v+z)= + slotSum D s r hs Fs q₀ b G q Γ coord d v+slotSum D s r hs Fs q₀ b G q Γ coord d z := by + simp [slotSum,add_mul,Finset.sum_add_distrib] + +private lemma compile_value (k : ℤ) (t : Fin D.targets) (av : ℚ×Slots D) + (hav : av∈required D s r hs Fs q₀ b) (col : Fin r) (u : Fin (q t)→ℤ) : + (compile D s r hs Fs q₀ b G q Γ coord d).value k t + (formula D s r hs Fs q₀ b t av.1 av.2 col) u = + scalar D s r hs Fs q₀ b G q Γ d t (formula D s r hs Fs q₀ b t av.1 av.2 col) + ((∏ j,((d.z t).1 j:ℤ))*(d.pstar t+(d.M:ℤ)*k+slotSum D s r hs Fs q₀ b G q Γ coord d av.2)+ + (d.M:ℤ)*∑ e,shift d.M d.L (d.qval t e) (d.label t) (fun j=>((d.z t).1 j:ℤ))*u e) := by + change scalar D s r hs Fs q₀ b G q Γ d t (formula D s r hs Fs q₀ b t av.1 av.2 col) + ((∏ j,((d.z t).1 j:ℤ))*(d.pstar t+(d.M:ℤ)*k+ + slotSum D s r hs Fs q₀ b G q Γ coord d (formula D s r hs Fs q₀ b t av.1 av.2 col).1.val.2)+ + (d.M:ℤ)*∑ e,shift d.M d.L (d.qval t e) (d.label t) (fun j=>((d.z t).1 j:ℤ))*u e)=_ + rw [formula_val D s r hs Fs q₀ b t av hav col] + +private lemma numeric_shift (t : Fin D.targets) (k : ℤ) (v z : Slots D) + (hz : ∀ e,D.owner e≠t → z e=0) (hL : 0((d.z t).1 j:ℤ))*ownInput D q coord t z e = + (∏ j,((d.z t).1 j:ℤ))*(d.pstar t+(d.M:ℤ)*k+slotSum D s r hs Fs q₀ b G q Γ coord d v)+ + ∑ e,z e*coefficient D s r hs Fs q₀ b G q Γ coord d e := by + have hr : (∑ j,residueData d.L (d.qval t j) (d.label t)*ownInput D q coord t z j)= + slotSum D s r hs Fs q₀ b G q Γ coord d z := by + apply input_pairing D q coord t z hz + intro e he + subst t + rfl + have hq : (∑ j,d.qval t j*ownInput D q coord t z j)= + ∑ e,z e*coefficient D s r hs Fs q₀ b G q Γ coord d e := by + apply input_pairing D q coord t z hz + intro e he + subst t + rfl + have he:=source_number_terminal (v:=0) d.M d.L hL hML (d.R:ℝ) (d.z t) hcop + (d.pstar t) (slotSum D s r hs Fs q₀ b G q Γ coord d v) (fun _ : Fin 1=>1) (fun _=>k) + (d.qval t) (ownInput D q coord t z) + simp only [number,Finset.sum_const,Finset.card_univ,Fintype.card_fin,Nat.zero_add,one_nsmul,one_mul] at he + change (∏ j,((d.z t).1 j:ℤ))*(d.pstar t+(d.M:ℤ)*k+ + (slotSum D s r hs Fs q₀ b G q Γ coord d v+ + ∑ j,residueData d.L (d.qval t j) (d.label t)*ownInput D q coord t z j))+ + (d.M:ℤ)*∑ e,shift d.M d.L (d.qval t e) (d.label t) (fun j=>((d.z t).1 j:ℤ))*ownInput D q coord t z e = + (∏ j,((d.z t).1 j:ℤ))*(d.pstar t+(d.M:ℤ)*k+slotSum D s r hs Fs q₀ b G q Γ coord d v)+ + ∑ j,d.qval t j*ownInput D q coord t z j at he + rw [hr,hq] at he + rw [slotSum_add,add_comm (slotSum D s r hs Fs q₀ b G q Γ coord d z)] + exact he + + + +theorem source_numeric_success (k : ℤ) (τ : ℝ) (hL : 0hu j) + have hr (e : Fin D.pairs) : rValue D L c u' e=rValue D L c u e := by + apply residue_congr hL (htail e) + · exact Int.ModEq.prod (fun j _=>hh j) + · exact (Int.ModEq.prod (s:=D.added e) (fun j _=>hh j)).mul_left (c e) + refine ⟨hr,?_,?_⟩ + · intro e he + unfold qValue + congr 1 + apply Finset.prod_congr rfl + intro j hj + apply hout j + intro hjt + exact Finset.disjoint_left.mp (hd e) hj (by simpa [he] using hjt) + · intro v + refine ⟨?_,?_,?_⟩ + · exact Finset.sum_congr rfl (fun e _=>congrArg (fun x=>v e*x) (hr e)) + · apply Finset.dvd_sum + intro e _ + exact dvd_mul_of_dvd_right (residue_dvd hL hWL (htail e) (dvd_mul_of_dvd_left (hc e) _)) _ + · calc + |slotValue D L c u v| ≤ ∑ e,|v e*rValue D L c u e| := Finset.abs_sum_le_sum_abs _ _ + _ ≤ ∑ e,|v e| * L := by + apply Finset.sum_le_sum + intro e _ + have hs:=residue_spec L (tailValue D u e) (qValue D c u e) hL (htail e) + have hr0 : 0≤rValue D L c u e:=hs.1 + rw [abs_mul,abs_of_nonneg hr0] + exact mul_le_mul_of_nonneg_left hs.2.1.le (abs_nonneg _) + _ = (∑ e,|v e|)*L := by rw [Finset.sum_mul] + +end SourceIntegerArrays.GlobalJoint.SourceExposureSlots + +end +end + +end OAI diff --git a/lean/OAI/Combinatorics/SumProduct/Alignment/IntegerArrays13.lean b/lean/OAI/Combinatorics/SumProduct/Alignment/IntegerArrays13.lean new file mode 100644 index 0000000000000000000000000000000000000000..18e6196830713e9151a53676173095fa23f679a7 --- /dev/null +++ b/lean/OAI/Combinatorics/SumProduct/Alignment/IntegerArrays13.lean @@ -0,0 +1,252 @@ +import Mathlib +import OAI.Combinatorics.SumProduct.Alignment.IntegerArrays11 +import OAI.Combinatorics.SumProduct.Alignment.IntegerArrays12 +import OAI.Geometry.NilpotentCharts.Main + +namespace OAI + +open scoped BigOperators +section +noncomputable section +end + +noncomputable section +namespace SourceIntegerArrays.GlobalJoint.SourceFrozenFamily +open ProductExposureLabels SourceExposureSlots +open ConstructedWordPlan.GlobalWordPlan ConstructedWordPlan.AlignmentScales +open scoped BigOperators BoundedContinuousFunction +attribute [local instance] Classical.propDecidable +variable {a : ℕ} (D : Pivot a) +abbrev m (t : Fin D.targets) := Fintype.card {j : Fin a // j∈D.tail t} +abbrev h (t : Fin D.targets) := Fintype.card {j : Fin a // j∉D.tail t} +def perm (t : Fin D.targets) : Fin (m D t+h D t)≃Fin a := + finSumFinEquiv.symm.trans + (((Fintype.equivFin {j : Fin a // j∈D.tail t}).symm.sumCongr + (Fintype.equivFin {j : Fin a // j∉D.tail t}).symm).trans + (Equiv.sumCompl (fun j : Fin a=>j∈D.tail t))) +def outer (t : Fin D.targets) (u : Fin a→ℕ) (j : Fin (h D t)) : ℕ := + u (perm D t (j.natAdd (m D t))) +def inner (t : Fin D.targets) (u : Fin a→ℕ) (j : Fin (m D t)) : ℕ := + u (perm D t (j.castAdd (h D t))) + + +def reconstruct (t : Fin D.targets) (y : Fin (h D t)→ℕ) (b : Label (m D t)) : Fin a→ℤ := + fun j=>Fin.append b.residue (fun k=>(y k:ℤ)) ((perm D t).symm j) +abbrev qdim (t : Fin D.targets) := Fintype.card {e : Fin D.pairs // D.owner e=t} +def coord (e : Fin D.pairs) : Fin (qdim D (D.owner e)) := + Fintype.equivFin {f : Fin D.pairs // D.owner f=D.owner e} ⟨e,rfl⟩ +def ownPair (t : Fin D.targets) (k : Fin (qdim D t)) : {e : Fin D.pairs // D.owner e=t} := + (Fintype.equivFin {e : Fin D.pairs // D.owner e=t}).symm k +variable (s r : ℕ) (hs : 1 ≤ s) (Fs : Finset (Scale a)) (q₀ : ℕ) (b₀ : Scale a) +local notation "I" => FiniteModelSlots.Index D s r hs Fs q₀ b₀ +variable (G₀ : Fin D.targets→ℚ→Fin r→Type) +variable [∀ t v c,Group (G₀ t v c)] [∀ t v c,TopologicalSpace (G₀ t v c)] +variable (Γ₀ : ∀ t v c,Subgroup (G₀ t v c)) +variable (M J R H : ℕ→ℕ) (L : ℕ→ℤ) (C : ℕ→Fin D.pairs→ℤ) +variable (g₀ x₀ : ∀ t,ℕ→(Fin (h D t)→ℕ)→∀ v c,ℤ→ℤ→G₀ t v c) +variable (obs₀ : ∀ t,ℕ→(Fin (h D t)→ℕ)→∀ v c,ℤ→ℤ→((G₀ t v c)⧸Γ₀ t v c) →ᵇ ℝ) + + +def family : ModelFamily D (fun t (i : I)=>G₀ t i.1.val.1 i.2) + (qdim D) (fun t i=>Γ₀ t i.1.val.1 i.2) a where + m:=m D + h:=h D + perm:=perm D + M:=M + J:=J + R:=R + L:=L + H:=H + slot:=fun t N y b i=>slotValue D (L N) (C N) (reconstruct D t y b) i.1.val.2 + qval:=fun t N y b k=>qValue D (C N) (reconstruct D t y b) (ownPair D t k).val + g:=fun t N y i=>g₀ t N y i.1.val.1 i.2 + x:=fun t N y i=>x₀ t N y i.1.val.1 i.2 + obs:=fun t N y i=>obs₀ t N y i.1.val.1 i.2 + +private lemma inside_mem (t : Fin D.targets) (j : Fin (m D t)) : + perm D t (j.castAdd (h D t))∈D.tail t := by + unfold perm + rw [Equiv.trans_apply,finSumFinEquiv_symm_apply_castAdd,Equiv.trans_apply] + exact ((Fintype.equivFin {j : Fin a // j∈D.tail t}).symm j).property +private lemma outside_notMem (t : Fin D.targets) (j : Fin (h D t)) : + perm D t (j.natAdd (m D t))∉D.tail t := by + unfold perm + rw [Equiv.trans_apply,finSumFinEquiv_symm_apply_natAdd,Equiv.trans_apply] + exact ((Fintype.equivFin {j : Fin a // j∉D.tail t}).symm j).property +private lemma reconstruct_inside (t : Fin D.targets) (y : Fin (h D t)→ℕ) + (b : Label (m D t)) (j : Fin (m D t)) : + reconstruct D t y b (perm D t (j.castAdd (h D t)))=b.residue j := by + simp [reconstruct] +private lemma reconstruct_outside (t : Fin D.targets) (y : Fin (h D t)→ℕ) + (b : Label (m D t)) (j : Fin (h D t)) : + reconstruct D t y b (perm D t (j.natAdd (m D t)))=(y j:ℤ) := by + simp [reconstruct] +private def representative (L M : ℤ) (R : ℝ) (t : Fin D.targets) (z : (Fin a→ℕ)×ℕ) : Fin a→ℤ := + reconstruct D t (outer D t z.1) (expose L M R (inner D t z.1,z.2)) +private lemma representative_data (L M : ℤ) (R : ℝ) (t : Fin D.targets) (z : (Fin a→ℕ)×ℕ) : + (∀ j∈D.tail t,representative D L M R t z j≡(z.1 j:ℤ) [ZMOD L]) ∧ + (∀ j,j∉D.tail t → representative D L M R t z j=(z.1 j:ℤ)) := by + constructor + · intro j hj + obtain ⟨i,rfl⟩:=(perm D t).surjective j + revert hj + refine Fin.addCases ?_ ?_ i + · intro k hk + rw [representative,reconstruct_inside] + exact Int.mod_modEq _ _ + · intro k hk + exact False.elim ((outside_notMem D t k) hk) + · intro j hj + obtain ⟨i,rfl⟩:=(perm D t).surjective j + revert hj + refine Fin.addCases ?_ ?_ i + · intro k hk + exact False.elim (hk (inside_mem D t k)) + · intro k hk + rw [representative,reconstruct_outside] + rfl +private lemma ownPair_coord (e : Fin D.pairs) : + (ownPair D (D.owner e) (coord D e)).val=e := by + simp [ownPair,coord] + + +theorem source_frozen_family (N W : ℕ) (z : (Fin a→ℕ)×ℕ) + (hL : 0(z.1 j:ℤ)) i.1.val.2 ∧ + (W:ℤ)∣l.slot t i ∧ + |l.slot t i|≤(∑ e,|i.1.val.2 e|)*L N) ∧ + (∀ e,l.qval (D.owner e) (coord D e)=qValue D (C N) (fun j=>(z.1 j:ℤ)) e) ∧ + (∀ t (i : I),l.g t i=g₀ t N (outer D t z.1) i.1.val.1 i.2 ∧ + l.x t i=x₀ t N (outer D t z.1) i.1.val.1 i.2 ∧ + l.obs t i=obs₀ t N (outer D t z.1) i.1.val.1 i.2) + := by + dsimp only + have hf (t : Fin D.targets) := source_exposure_slots D (L N) (W:ℤ) hL hWL (C N) hc + (fun j=>(z.1 j:ℤ)) (representative D (L N) (M N:ℤ) (R N:ℝ) t z) hu t + (representative_data D (L N) (M N:ℤ) (R N:ℝ) t z).1 + (representative_data D (L N) (M N:ℤ) (R N:ℝ) t z).2 hd + refine ⟨?_,?_,?_⟩ + · intro t i + change slotValue D (L N) (C N) (representative D (L N) (M N:ℤ) (R N:ℝ) t z) i.1.val.2= _ ∧ _ + have hh:=(hf t).2.2 i.1.val.2 + refine ⟨hh.1,?_,?_⟩ + · change (W:ℤ)∣slotValue D (L N) (C N) (representative D (L N) (M N:ℤ) (R N:ℝ) t z) i.1.val.2 + rw [hh.1] + exact hh.2.1 + · change |slotValue D (L N) (C N) (representative D (L N) (M N:ℤ) (R N:ℝ) t z) i.1.val.2|≤_ + rw [hh.1] + exact hh.2.2 + · intro e + change qValue D (C N) (representative D (L N) (M N:ℤ) (R N:ℝ) (D.owner e) z) + (ownPair D (D.owner e) (coord D e)).val= _ + rw [ownPair_coord] + exact (hf (D.owner e)).2.1 e rfl + · intro t i + exact ⟨rfl,rfl,rfl⟩ + +end SourceIntegerArrays.GlobalJoint.SourceFrozenFamily +end + +noncomputable section +namespace SourceIntegerArrays.GlobalJoint.SourceFrozenFamily +open ProductExposureLabels SourceExposureSlots SourceResidueAlignment +open ConstructedWordPlan.GlobalWordPlan ConstructedWordPlan.AlignmentScales +open scoped BigOperators BoundedContinuousFunction +attribute [local instance] Classical.propDecidable +variable {a : ℕ} (D : Pivot a) +variable (s r : ℕ) (hs : 1 ≤ s) (Fs : Finset (Scale a)) (q₀ : ℕ) (b₀ : Scale a) +local notation "I" => FiniteModelSlots.Index D s r hs Fs q₀ b₀ +variable (G₀ : Fin D.targets→ℚ→Fin r→Type) +variable [∀ t v c,Group (G₀ t v c)] [∀ t v c,TopologicalSpace (G₀ t v c)] +variable (Γ₀ : ∀ t v c,Subgroup (G₀ t v c)) +variable (M J R H : ℕ→ℕ) (L : ℕ→ℤ) (C : ℕ→Fin D.pairs→ℤ) +variable (g₀ x₀ : ∀ t,ℕ→(Fin (h D t)→ℕ)→∀ v c,ℤ→ℤ→G₀ t v c) +variable (obs₀ : ∀ t,ℕ→(Fin (h D t)→ℕ)→∀ v c,ℤ→ℤ→((G₀ t v c)⧸Γ₀ t v c) →ᵇ ℝ) +private lemma canonical_inner_product (t : Fin D.targets) (u : Fin a→ℕ) : + (∏ j : Fin (m D t),(inner D t u j:ℤ))=∏ j∈D.tail t,(u j:ℤ) := by + have hi (j : Fin (m D t)) : perm D t (j.castAdd (h D t))= + ((Fintype.equivFin {j : Fin a // j∈D.tail t}).symm j).val := by + unfold perm + rw [Equiv.trans_apply,finSumFinEquiv_symm_apply_castAdd,Equiv.trans_apply] + rfl + simp only [inner,hi] + calc + _ = ∏ j : {j : Fin a // j∈D.tail t},(u j.val:ℤ) := + (Fintype.equivFin {j : Fin a // j∈D.tail t}).symm.prod_comp _ + _ = ∏ j∈D.tail t,(u j:ℤ) := Finset.prod_coe_sort (D.tail t) (fun j : Fin a=>(u j:ℤ)) +private lemma coprime_of_mod_congr {L t t' : ℤ} (ht : IsCoprime t L) (he : t'≡t [ZMOD L]) : + IsCoprime t' L := by + obtain ⟨k,hk⟩:=Int.modEq_iff_dvd.mp he + obtain ⟨a,b,hab⟩:=ht + refine ⟨a,b+a*k,?_⟩ + linear_combination hab-a*hk +private lemma source_residue_congr {L t t' q : ℤ} (hL : 0G₀ t i.1.val.1 i.2) (qdim D) + (fun t i=>Γ₀ t i.1.val.1 i.2) (coord D) l k τ + := by + let d:=family D s r hs Fs q₀ b₀ G₀ Γ₀ M J R H L C g₀ x₀ obs₀ + let l:=(d.atTime N).localModel z + let G:=fun t (i : I)=>G₀ t i.1.val.1 i.2 + let Γ:=fun t (i : I)=>Γ₀ t i.1.val.1 i.2 + change l.modelSuccess (coord D) k s r hs (FiniteModelSlots.formula D s r hs Fs q₀ b₀) Fs q₀ b₀ τ ↔ + FiniteModelSlots.numericSuccess D s r hs Fs q₀ b₀ G (qdim D) Γ (coord D) l k τ + have hf:=source_frozen_family D s r hs Fs q₀ b₀ G₀ Γ₀ M J R H L C g₀ x₀ obs₀ + N W z hL hWL hc hu hd + have hmod (t : Fin D.targets) : + (∏ j,(l.label t).residue j)≡(∏ j∈D.tail t,(z.1 j:ℤ)) [ZMOD L N] := by + rw [←canonical_inner_product D t z.1] + apply Int.ModEq.prod + intro j hj + exact Int.mod_modEq _ _ + have hcop (t : Fin D.targets) : IsCoprime (∏ j,(l.label t).residue j) (L N) := + coprime_of_mod_congr (IsCoprime.prod_left (fun j _=>hu j)) (hmod t) + have hr (e : Fin D.pairs) : FiniteModelSlots.residue D s r hs Fs q₀ b₀ G (qdim D) Γ (coord D) l e= + rValue D (L N) (C N) (fun j=>(z.1 j:ℤ)) e := by + unfold FiniteModelSlots.residue FiniteModelSlots.coefficient + rw [hf.2.1 e] + apply source_residue_congr hL + · exact IsCoprime.prod_left (fun j _=>hu j) + · exact hmod (D.owner e) + have hslot (v : Slots D) : FiniteModelSlots.slotSum D s r hs Fs q₀ b₀ G (qdim D) Γ (coord D) l v= + slotValue D (L N) (C N) (fun j=>(z.1 j:ℤ)) v := by + unfold FiniteModelSlots.slotSum slotValue + simp_rw [hr] + have hslots : (fun t (i : I)=>FiniteModelSlots.slotSum D s r hs Fs q₀ b₀ G (qdim D) Γ (coord D) l i.1.val.2)=l.slot := by + funext t i + exact (hslot i.1.val.2).trans (hf.1 t i).1.symm + have he : FiniteModelSlots.compile D s r hs Fs q₀ b₀ G (qdim D) Γ (coord D) l=l := by + unfold FiniteModelSlots.compile + rw [hslots] + have hn:=FiniteModelSlots.source_numeric_success D s r hs Fs q₀ b₀ G (qdim D) Γ (coord D) l k τ + hL hML hcop + rw [he] at hn + exact hn + +end SourceIntegerArrays.GlobalJoint.SourceFrozenFamily +end + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SumProduct/Alignment/IntegerArrays14.lean b/lean/OAI/Combinatorics/SumProduct/Alignment/IntegerArrays14.lean new file mode 100644 index 0000000000000000000000000000000000000000..bcaf2014c2d3dce0d92e54fc0d997451f2901e85 --- /dev/null +++ b/lean/OAI/Combinatorics/SumProduct/Alignment/IntegerArrays14.lean @@ -0,0 +1,348 @@ +import Mathlib +import OAI.Combinatorics.SumProduct.Alignment.IntegerArrays13 +import OAI.Geometry.NilpotentCharts.Main + +namespace OAI + +open scoped BigOperators +section +noncomputable section +namespace ConstructedWordPlan.GlobalWordPlan.SourceTerminalArithmetic +open AlignmentScales RationalPivotPlan +open scoped BigOperators +attribute [local instance] Classical.propDecidable +variable {a : ℕ} (D : Pivot a) +def height (h : Fin a→ℤ) (S : Finset (Fin a)) : ℤ := ∏ j∈S,h j + + +def coefficient (q₀ : ℕ) (h u : Fin a→ℤ) (e : Fin D.pairs) : ℤ := + height h (D.added e)/((q₀:ℤ)*height h (block D.index D.tail (D.owner e)))*height u (D.added e) + +private lemma pairing (q₀ : ℕ) (b : Scale a) (U : Finset (Fin D.pairs)) (q : Fin D.pairs→ℤ) : + (∑ e,(terminalShift D q₀ b U).toAdd e*q e)= + ∑ e∈U,(qExponent D.index D.tail D.owner D.added q₀ b (e,1)).num*q e := by + let π : Shifts D →* Multiplicative ℤ := + {toFun:=fun v=>Multiplicative.ofAdd (∑ e,v.toAdd e*q e) + map_one':=by simp + map_mul':=by intro x y; change Multiplicative.ofAdd (∑ e,(x.toAdd e+y.toAdd e)*q e)=_ + simp [add_mul,Finset.sum_add_distrib] } + have hπ (e : Fin D.pairs) : π (unitShift D e)=Multiplicative.ofAdd (q e) := by + change Multiplicative.ofAdd (∑ f,(Pi.single e (1:ℤ) : Slots D) f*q f)=_ + simp [Pi.single_apply] + have hlist (l : List (Fin D.pairs)) : + π (FreeGroup.lift (letter D.index D.tail D.owner D.added (unitShift D) q₀ b) + ((l.map (fun e=>FreeGroup.of (e,(1:ℚ)))).prod)) = + Multiplicative.ofAdd ((l.map (fun e=>(qExponent D.index D.tail D.owner D.added q₀ b (e,1)).num*q e)).sum) := by + induction l with + | nil => simp + | cons e l ih => + simp only [List.map_cons,List.prod_cons,map_mul,FreeGroup.lift_apply_of,letter,map_zpow,hπ,ih,List.sum_cons] + rfl + have he:=congrArg Multiplicative.toAdd (hlist U.toList) + change (∑ e,(terminalShift D q₀ b U).toAdd e*q e) = _ at he + rw [←List.sum_toFinset _ U.nodup_toList] at he + simpa [mul_comm] using he + +private lemma coefficient_exact (q₀ w : ℕ) (hq₀ : 0hpos j) + have hn : (q₀:ℤ)*height h (block D.index D.tail (D.owner e))≠0 := mul_ne_zero (by exact_mod_cast hq₀.ne') hp.ne' + have he : height h (D.added e)=((q₀:ℤ)*height h (block D.index D.tail (D.owner e)))*((primorial w:ℤ)*d*k) := by + rw [hk,hd] + ring + have hco : coefficient D q₀ h u e=((primorial w:ℤ)*d*k)*height u (D.added e) := by + unfold coefficient + rw [he,Int.mul_ediv_cancel_left _ hn] + rw [hco] + refine ⟨dvd_mul_of_dvd_left (dvd_mul_of_dvd_left (dvd_mul_right _ _) _) _,?_⟩ + rw [he] + push_cast + have hq : (q₀:ℚ)≠0 := by exact_mod_cast hq₀.ne' + have hhp : (height h (block D.index D.tail (D.owner e)):ℚ)≠0 := by exact_mod_cast hp.ne' + field_simp + + + +theorem source_terminal_arithmetic (B : Finset (Scale a)) : + ∃ Q : ℕ,0blockProduct be.1 (D.added be.2)/blockProduct be.1 (block D.index D.tail (D.owner be.2))) + refine ⟨Q,hQ,?_⟩ + intro q₀ hq₀ hQq w hw b hb hbpos h u hh hratio + have hc (e : Fin D.pairs):=coefficient_exact D q₀ w hq₀ hw h u hh e (hratio e) + refine ⟨fun e=>(hc e).1,?_⟩ + intro U + rw [pairing] + push_cast + apply Finset.sum_congr rfl + intro e he + obtain ⟨m,hm⟩:=hclear (b,e) (Finset.mem_product.mpr ⟨hb,Finset.mem_univ _⟩) + obtain ⟨d,hd⟩:=hQq + have hint : qExponent D.index D.tail D.owner D.added q₀ b (e,1)=((d:ℤ)*m:ℤ) := by + dsimp [qExponent] + rw [hd] + push_cast + calc + (Q:ℚ)*d*1*(blockProduct b (D.added e)/blockProduct b (block D.index D.tail (D.owner e))) = + (d:ℚ)*((Q:ℚ)*(blockProduct b (D.added e)/blockProduct b (block D.index D.tail (D.owner e)))) := by ring + _ = _ := by rw [hm] + have hn : ((qExponent D.index D.tail D.owner D.added q₀ b (e,1)).num:ℚ)= + (q₀:ℚ)*(blockProduct b (D.added e)/blockProduct b (block D.index D.tail (D.owner e))) := by + rw [hint,Rat.num_intCast] + simpa [qExponent] using hint.symm + rw [hn,(hc e).2] + have hq : (q₀:ℚ)≠0 := by exact_mod_cast hq₀.ne' + have hh0 : (height h (block D.index D.tail (D.owner e)):ℚ)≠0 := by + exact_mod_cast (Finset.prod_pos (fun j _=>hh j) : 0hbpos j)).ne' + field_simp + +end ConstructedWordPlan.GlobalWordPlan.SourceTerminalArithmetic +end + +noncomputable section +namespace SourceIntegerArrays.GlobalJoint.SourceFrozenFamily +open ProductExposureLabels SourceExposureSlots SourceResidueAlignment ConstructedWordPlan.GlobalWordPlan.SourceTerminalArithmetic +open ConstructedWordPlan.GlobalWordPlan ConstructedWordPlan.AlignmentScales ConstructedWordPlan.RationalPivotPlan +open scoped BigOperators BoundedContinuousFunction +attribute [local instance] Classical.propDecidable +variable {a : ℕ} (D : Pivot a) +variable (s r : ℕ) (hs : 1 ≤ s) (Fs : Finset (Scale a)) (q₀ : ℕ) (b₀ : Scale a) +local notation "I" => FiniteModelSlots.Index D s r hs Fs q₀ b₀ +variable (G₀ : Fin D.targets→ℚ→Fin r→Type) +variable [∀ t v c,Group (G₀ t v c)] [∀ t v c,TopologicalSpace (G₀ t v c)] +variable (Γ₀ : ∀ t v c,Subgroup (G₀ t v c)) +variable (M J R H : ℕ→ℕ) (L : ℕ→ℤ) (C : ℕ→Fin D.pairs→ℤ) +variable (g₀ x₀ : ∀ t,ℕ→(Fin (h D t)→ℕ)→∀ v c,ℤ→ℤ→G₀ t v c) +variable (obs₀ : ∀ t,ℕ→(Fin (h D t)→ℕ)→∀ v c,ℤ→ℤ→((G₀ t v c)⧸Γ₀ t v c) →ᵇ ℝ) +variable (ht : ℕ→Fin a→ℤ) +def heightCoeff (N : ℕ) (e : Fin D.pairs) : ℤ := + height (ht N) (D.added e)/((q₀:ℤ)*height (ht N) (block D.index D.tail (D.owner e))) +def readOriginal (N : ℕ) (u : Fin a→ℕ) (t : Fin D.targets) (v : ℚ) (col : Fin r) (n : ℤ) : ℝ := + pieceModel (Γ₀ t v col) (M N) (H N) (g₀ t N (outer D t u) v col) + (x₀ t N (outer D t u) v col) (fun b r=>obs₀ t N (outer D t u) v col b r) n +def outcomeScales : Finset (Scale a) := + {1} ∪ (pivotOptions s r hs D Fs).biUnion (fun p=>Fs.image (fun d=>scaleRun D 0 p b₀*d)) +def terminalDenom : ℕ := + (source_terminal_arithmetic D (outcomeScales D s r hs Fs b₀)).choose +def slots : Finset (Slots D) := + (pivotOptions s r hs D Fs).image (fun p=>jumpSlot D q₀ p b₀) + + +def pivotProperty (N : ℕ) (u : Fin a→ℕ) (x : ℕ) (τ : ℝ) : Prop := + ∃ p∈pivotOptions s r hs D Fs,∀ i : Comparison D Fs r, + let t:=i.2.1.1 + let b:=scaleRun D 0 p b₀*i.1.val + let av:=blockProduct b (block D.index D.tail t) + ∃ Δ : ℤ, + (Δ:ℚ)=∑ e∈i.2.1.2.val, + ((height (ht N) (D.added e):ℚ)*blockProduct b (D.added e)/ + ((height (ht N) (block D.index D.tail (D.owner e)):ℚ)* + blockProduct b (block D.index D.tail (D.owner e))))* + (height (fun j=>(u j:ℤ)) (D.added e):ℚ) ∧ + (2*τ(u j:ℤ)) (D.tail t))*(x:ℤ)) → + τ(u j:ℤ)) (D.tail t))*(x:ℤ)+Δ)) +private lemma reading_inner_product (t : Fin D.targets) (u : Fin a→ℕ) : + (∏ j : Fin (m D t),(inner D t u j:ℤ))=∏ j∈D.tail t,(u j:ℤ) := by + have hi (j : Fin (m D t)) : perm D t (j.castAdd (h D t))= + ((Fintype.equivFin {j : Fin a // j∈D.tail t}).symm j).val := by + unfold perm + rw [Equiv.trans_apply,finSumFinEquiv_symm_apply_castAdd,Equiv.trans_apply] + rfl + simp only [inner,hi] + calc + _ = ∏ j : {j : Fin a // j∈D.tail t},(u j.val:ℤ) := + (Fintype.equivFin {j : Fin a // j∈D.tail t}).symm.prod_comp _ + _ = ∏ j∈D.tail t,(u j:ℤ) := Finset.prod_coe_sort (D.tail t) (fun j : Fin a=>(u j:ℤ)) +private lemma reading_coprime_mod {L t t' : ℤ} (ht : IsCoprime t L) (he : t'≡t [ZMOD L]) : + IsCoprime t' L := by + obtain ⟨k,hk⟩:=Int.modEq_iff_dvd.mp he + obtain ⟨a,b,hab⟩:=ht + refine ⟨a,b+a*k,?_⟩ + linear_combination hab-a*hk +private lemma reading_residue_congr {L t t' q : ℤ} (hL : 0G₀ t i.1.val.1 i.2) (qdim D) + (fun t i=>Γ₀ t i.1.val.1 i.2) (coord D) ((d.atTime N).localModel z) v= + slotValue D (L N) (C N) (fun j=>(z.1 j:ℤ)) v := by + let d:=family D s r hs Fs q₀ b₀ G₀ Γ₀ M J R H L C g₀ x₀ obs₀ + let l:=(d.atTime N).localModel z + let G:=fun t (i : I)=>G₀ t i.1.val.1 i.2 + let Γ:=fun t (i : I)=>Γ₀ t i.1.val.1 i.2 + have hf:=source_frozen_family D s r hs Fs q₀ b₀ G₀ Γ₀ M J R H L C g₀ x₀ obs₀ + N W z hL hWL hc hu hd + have hmod (t : Fin D.targets) : + (∏ j,(l.label t).residue j)≡(∏ j∈D.tail t,(z.1 j:ℤ)) [ZMOD L N] := by + rw [←reading_inner_product D t z.1] + apply Int.ModEq.prod + intro j hj + exact Int.mod_modEq _ _ + have hr (e : Fin D.pairs) : FiniteModelSlots.residue D s r hs Fs q₀ b₀ G (qdim D) Γ (coord D) l e= + rValue D (L N) (C N) (fun j=>(z.1 j:ℤ)) e := by + unfold FiniteModelSlots.residue FiniteModelSlots.coefficient + rw [hf.2.1 e] + apply reading_residue_congr hL + · exact IsCoprime.prod_left (fun j _=>hu j) + · exact hmod (D.owner e) + change FiniteModelSlots.slotSum D s r hs Fs q₀ b₀ G (qdim D) Γ (coord D) l v=_ + unfold FiniteModelSlots.slotSum slotValue + simp_rw [hr] +private lemma reading_slot_bound (L : ℤ) (hL : 0hu j)) + have hr0 : 0≤rValue D L c u e:=hr.1 + rw [abs_mul,abs_of_nonneg hr0] + exact mul_le_mul_of_nonneg_left hr.2.1.le (abs_nonneg _) + _=(∑ e, |v e|)*L:=by rw [Finset.sum_mul] +private lemma reading_scaleRun_pos (p : Path D) (hp : ∀o∈p,0 exact hb + | cons o p ih => + apply ih (fun o ho=>hp o (List.mem_cons_of_mem _ ho)) + intro l + exact mul_pos (hb l) (multiplier_pos D.index (tailAt D.tail j) (by exact_mod_cast hp o (List.mem_cons_self)) l) +private lemma reading_av_mem (p : Path D) (hp : p∈pivotOptions s r hs D Fs) (i : Comparison D Fs r) : + FiniteModelSlots.centerAV D r Fs q₀ b₀ p i∈FiniteModelSlots.required D s r hs Fs q₀ b₀ ∧ + FiniteModelSlots.terminalAV D r Fs q₀ b₀ p i∈FiniteModelSlots.required D s r hs Fs q₀ b₀ := by + constructor <;> apply Finset.mem_union_right <;> apply Finset.mem_biUnion.mpr <;> + refine ⟨p,hp,Finset.mem_biUnion.mpr ⟨i,Finset.mem_univ _,?_⟩⟩ <;> simp +private lemma reading_scalar (N : ℕ) (z : (Fin a→ℕ)×ℕ) (t : Fin D.targets) (av : ℚ×Slots D) + (hav : av∈FiniteModelSlots.required D s r hs Fs q₀ b₀) (col : Fin r) (n : ℤ) : + let d:=family D s r hs Fs q₀ b₀ G₀ Γ₀ M J R H L C g₀ x₀ obs₀ + FiniteModelSlots.scalar D s r hs Fs q₀ b₀ (fun t (i : I)=>G₀ t i.1.val.1 i.2) (qdim D) + (fun t i=>Γ₀ t i.1.val.1 i.2) ((d.atTime N).localModel z) t + (FiniteModelSlots.formula D s r hs Fs q₀ b₀ t av.1 av.2 col) n= + readOriginal D r G₀ Γ₀ M H g₀ x₀ obs₀ N z.1 t av.1 col n := by + unfold FiniteModelSlots.formula + rw [dite_eq_left hav] + rfl + + +theorem source_pivot_reading (N w : ℕ) (z : (Fin a→ℕ)×ℕ) (k p : ℕ) + (hq₀ : 0(z.1 j:ℤ)) v + 0G₀ t i.1.val.1 i.2 + let Γ:=fun t (i : I)=>Γ₀ t i.1.val.1 i.2 + have ht₁:=(source_terminal_arithmetic D (outcomeScales D s r hs Fs b₀)).choose_spec.2 + q₀ hq₀ hQq w hw 1 (by simp [outcomeScales]) (by intro j;exact zero_lt_one) + (ht N) (fun _=>1) hht hratio + have hc : ∀ e,(primorial w:ℤ)∣C N e := by + intro e + simpa [C,heightCoeff,coefficient,height] using ht₁.1 e + have hf:=source_frozen_family D s r hs Fs q₀ b₀ G₀ Γ₀ M J R H L C g₀ x₀ obs₀ + N (primorial w) z hL hWL hc hu hd + have hslt:=reading_slotSum D s r hs Fs q₀ b₀ G₀ Γ₀ M J R H L C g₀ x₀ obs₀ + N (primorial w) z hL hWL hc hu hd + intro hsuc + have hn:=(source_family_numeric D s r hs Fs q₀ b₀ G₀ Γ₀ M J R H L C g₀ x₀ obs₀ + N (primorial w) z hL hWL hc hu hd hML (k:ℤ) τ).mp hsuc + rcases hn with ⟨o,ho,hnum⟩ + let v:=jumpSlot D q₀ o b₀ + have hv : v∈slots D s r hs Fs q₀ b₀:=Finset.mem_image.mpr ⟨o,ho,rfl⟩ + let x:=(p:ℤ)+slotValue D (L N) (C N) (fun j=>(z.1 j:ℤ)) v + have hbound:=reading_slot_bound D (L N) hL (C N) (fun j=>(z.1 j:ℤ)) hu v + have hx : 0(z.1 j:ℤ)) v) + dsimp [x] + linarith + refine ⟨v,hv,hx,o,ho,?_⟩ + intro i + let b:=scaleRun D 0 o b₀*i.1.val + have hb : b∈outcomeScales D s r hs Fs b₀:=Finset.mem_union_right _ + (Finset.mem_biUnion.mpr ⟨o,ho,Finset.mem_image.mpr ⟨i.1.val,i.1.property,rfl⟩⟩) + have hbpos (j : Fin a) : 0(z.1 j:ℤ)) hht hratio + let Δ:=∑e,(terminalShift D q₀ b i.2.1.2.val).toAdd e*coefficient D q₀ (ht N) (fun j=>(z.1 j:ℤ)) e + refine ⟨Δ,ht₂.2 i.2.1.2.val,?_⟩ + have hco (e : Fin D.pairs) : FiniteModelSlots.coefficient D s r hs Fs q₀ b₀ G (qdim D) Γ (coord D) l e= + coefficient D q₀ (ht N) (fun j=>(z.1 j:ℤ)) e := hf.2.1 e + have hN : (∏j,((l.z i.2.1.1).1 j:ℤ))*(l.pstar i.2.1.1+(l.M:ℤ)*(k:ℤ)+ + FiniteModelSlots.slotSum D s r hs Fs q₀ b₀ G (qdim D) Γ (coord D) l v)= + height (fun j=>(z.1 j:ℤ)) (D.tail i.2.1.1)*(x.toNat:ℤ) := by + change (∏j,(inner D i.2.1.1 z.1 j:ℤ))*(firstPivot (M N) (J N) z.2+(M N:ℤ)*(k:ℤ)+ + FiniteModelSlots.slotSum D s r hs Fs q₀ b₀ G (qdim D) Γ (coord D) l v)=_ + rw [reading_inner_product,←hp,hslt,Int.toNat_of_nonneg hx.le] + rfl + have hi:=hnum i + dsimp only at hi + rw [reading_scalar D s r hs Fs q₀ b₀ G₀ Γ₀ M J R H L C g₀ x₀ obs₀ N z i.2.1.1 + (FiniteModelSlots.centerAV D r Fs q₀ b₀ o i) (reading_av_mem D s r hs Fs q₀ b₀ o ho i).1] at hi + rw [reading_scalar D s r hs Fs q₀ b₀ G₀ Γ₀ M J R H L C g₀ x₀ obs₀ N z i.2.1.1 + (FiniteModelSlots.terminalAV D r Fs q₀ b₀ o i) (reading_av_mem D s r hs Fs q₀ b₀ o ho i).2] at hi + simp only [FiniteModelSlots.centerAV,FiniteModelSlots.terminalAV] at hi + rw [hN] at hi + dsimp only [G,Γ,l,d] at hco + simp_rw [hco] at hi + exact hi + +end SourceIntegerArrays.GlobalJoint.SourceFrozenFamily + +end +end + +end OAI diff --git a/lean/OAI/Combinatorics/SumProduct/Alignment/IntegerArrays15.lean b/lean/OAI/Combinatorics/SumProduct/Alignment/IntegerArrays15.lean new file mode 100644 index 0000000000000000000000000000000000000000..47a4427e7256c915d00857386a8ae28bb983d01e --- /dev/null +++ b/lean/OAI/Combinatorics/SumProduct/Alignment/IntegerArrays15.lean @@ -0,0 +1,324 @@ +import Mathlib +import OAI.Combinatorics.SumProduct.Alignment.IntegerArrays14 +import OAI.Geometry.NilpotentCharts.Main + +namespace OAI + +open scoped BigOperators +section +noncomputable section +end + + + + + + + +noncomputable section +open scoped BigOperators BoundedContinuousFunction Topology NNReal ENNReal +namespace SourceIntegerArrays.GlobalJoint.SourceFrozenFamily +open ProductExposureLabels ProductExposureLaw SourceExposureSlots SourceResidueAlignment +open ConstructedWordPlan.GlobalWordPlan ConstructedWordPlan.AlignmentScales +open ConstructedWordPlan.RationalPivotPlan +open ConstructedWordPlan.GlobalWordPlan.SourceTerminalArithmetic +open RawHarmonicProbability +attribute [local instance] Classical.propDecidable +variable {a : ℕ} (D : Pivot a) + + + +lemma residue_abs_le (L t q : ℤ) (hL : 0 < L) : + |SourceResidueAlignment.residue L t q| ≤ L := by + by_cases hc : IsCoprime t L + · have h := SourceResidueAlignment.residue_spec L t q hL hc + rw [abs_of_nonneg h.1] + exact h.2.1.le + · simp only [SourceResidueAlignment.residue, hc, and_false, ↓reduceDIte, abs_zero] + exact hL.le + +lemma actual_slot_bound (L : ℤ) (hL : 0 < L) (C : Fin D.pairs → ℤ) + (u : Fin a → ℤ) (v : Slots D) : + |slotValue D L C u v| ≤ (∑ e, |v e|) * L := by + calc + |slotValue D L C u v| ≤ ∑ e, |v e * rValue D L C u e| := + Finset.abs_sum_le_sum_abs _ _ + _ ≤ ∑ e, |v e| * L := by + apply Finset.sum_le_sum + intro e he + rw [abs_mul] + exact mul_le_mul_of_nonneg_left (residue_abs_le L _ _ hL) (abs_nonneg _) + _ = (∑ e, |v e|) * L := by rw [Finset.sum_mul] + +lemma source_heightCoeff_bound (q₀ : ℕ) (hq₀ : 0 < q₀) + (ht : ℕ → Fin a → ℤ) (N M : ℕ) (hpos : ∀ j, 0 < ht N j) + (hheight : ∀ e, height (ht N) (D.added e) ≤ M) (e : Fin D.pairs) : + |heightCoeff D q₀ ht N e| ≤ M := by + have hA : 0 ≤ height (ht N) (D.added e) := + (Finset.prod_pos (fun j _ => hpos j)).le + have hB : 0 ≤ (q₀ : ℤ) * height (ht N) (block D.index D.tail (D.owner e)) := by + exact mul_nonneg (by omega) (Finset.prod_pos (fun j _ => hpos j)).le + unfold heightCoeff + rw [abs_of_nonneg (Int.ediv_nonneg hA hB)] + exact (Int.ediv_le_self _ hA).trans (hheight e) + +lemma perm_inside (t : Fin D.targets) (j : Fin (m D t)) : + perm D t (j.castAdd (h D t)) ∈ D.tail t := by + unfold perm + rw [Equiv.trans_apply, finSumFinEquiv_symm_apply_castAdd, Equiv.trans_apply] + exact ((Fintype.equivFin {j : Fin a // j ∈ D.tail t}).symm j).property + + + +lemma reconstruct_outside_bound (t : Fin D.targets) (X : Fin a → ℕ) (W : ℕ) + (y : Fin (h D t) → ℕ) + (hy : y ∈ outsideDomain (fun j => X (perm D t (j.natAdd (m D t)))) W) + (b : Label (m D t)) (j : Fin a) (hj : j ∉ D.tail t) : + |reconstruct D t y b j| ≤ (X j : ℤ)^2 := by + obtain ⟨k, rfl⟩ := (perm D t).surjective j + revert hj + refine Fin.addCases ?_ ?_ k + · intro i hi + exact False.elim (hi (perm_inside D t i)) + · intro i hi + have h := Fintype.mem_piFinset.mp hy i + have hh := (Finset.mem_Ico.mp (Finset.mem_filter.mp h).1).2.le + simpa [reconstruct, abs_of_nonneg (Int.natCast_nonneg _)] using + (show (y i : ℤ) ≤ (X (perm D t (i.natAdd (m D t))) : ℤ)^2 by exact_mod_cast hh) + + + +lemma source_qValue_bound (q₀ : ℕ) (hq₀ : 0 < q₀) + (ht : ℕ → Fin a → ℤ) (N M : ℕ) (hpos : ∀ j, 0 < ht N j) + (hheight : ∀ e, height (ht N) (D.added e) ≤ M) + (hd : ∀ e, Disjoint (D.added e) (D.tail (D.owner e))) + (X : Fin a → ℕ) (hX : ∀ j, 1 ≤ X j) (W : ℕ) + (t : Fin D.targets) (y : Fin (h D t) → ℕ) + (hy : y ∈ outsideDomain (fun j => X (perm D t (j.natAdd (m D t)))) W) + (b : Label (m D t)) (k : Fin (qdim D t)) : + |qValue D (heightCoeff D q₀ ht N) (reconstruct D t y b) (ownPair D t k).val| ≤ + (M : ℤ) * (∏ j ∈ Finset.univ.filter (fun j : Fin a => j < D.index), (X j : ℤ))^2 := by + let e := (ownPair D t k).val + have he : D.owner e = t := (ownPair D t k).property + have hpoint (j : Fin a) (hj : j ∈ D.added e) : + |reconstruct D t y b j| ≤ (X j : ℤ)^2 := by + apply reconstruct_outside_bound D t X W y hy b j + intro ht + exact Finset.disjoint_left.mp (hd e) hj (by simpa [he] using ht) + have hprod : |∏ j ∈ D.added e, reconstruct D t y b j| ≤ + (∏ j ∈ Finset.univ.filter (fun j : Fin a => j < D.index), (X j : ℤ))^2 := by + rw [Finset.abs_prod] + calc + _ ≤ ∏ j ∈ D.added e, (X j : ℤ)^2 := + Finset.prod_le_prod₀ (fun j _ => abs_nonneg _) (fun j hj => hpoint j hj) + _ ≤ ∏ j ∈ Finset.univ.filter (fun j : Fin a => j < D.index), (X j : ℤ)^2 := by + apply Finset.prod_le_prod_of_subset_of_one_le₀ + (by intro j hj; exact Finset.mem_filter.mpr ⟨Finset.mem_univ _, D.added_lt e j hj⟩) + (fun j _ => sq_nonneg _) + intro j _ _ + have hx : (1 : ℤ) ≤ X j := by exact_mod_cast hX j + nlinarith + _ = (∏ j ∈ Finset.univ.filter (fun j : Fin a => j < D.index), (X j : ℤ))^2 := by + rw [Finset.prod_pow] + unfold qValue + rw [abs_mul] + exact mul_le_mul (source_heightCoeff_bound D q₀ hq₀ ht N M hpos hheight e) + hprod (abs_nonneg _) (by omega) + + +def previousProduct (X : Fin a → ℕ) : ℕ := + ∏ j ∈ Finset.univ.filter (fun j : Fin a => j < D.index), X j + +lemma previousProduct_pos (X : Fin a → ℕ) (hX : ∀ j, 1 ≤ X j) : + 0 < previousProduct D X := + Finset.prod_pos (fun j _ => lt_of_lt_of_le Nat.zero_lt_one (hX j)) + +lemma le_previousProduct (X : Fin a → ℕ) (hX : ∀ j, 1 ≤ X j) + (j : Fin a) (hj : j < D.index) : X j ≤ previousProduct D X := + Finset.single_le_prod (fun j _ => hX j) (Finset.mem_filter.mpr ⟨Finset.mem_univ _, hj⟩) + +lemma tail_product_le_previous (X : Fin a → ℕ) (hX : ∀ j, 1 ≤ X j) + (t : Fin D.targets) : + (∏ j : Fin (m D t), X (perm D t (j.castAdd (h D t)))) ≤ previousProduct D X := by + let e : Fin (m D t) ↪ Fin a := + ⟨fun j => perm D t (j.castAdd (h D t)), by + intro j k he + apply Fin.ext + exact congrArg (fun z : Fin (m D t + h D t) => z.val) ((perm D t).injective he)⟩ + have hsub : Finset.univ.map e ⊆ Finset.univ.filter (fun j : Fin a => j < D.index) := by + intro j hj + obtain ⟨k, hk, rfl⟩ := Finset.mem_map.mp hj + exact Finset.mem_filter.mpr ⟨Finset.mem_univ _, D.tail_lt t _ (perm_inside D t k)⟩ + calc + _ = ∏ j ∈ Finset.univ.map e, X j := (Finset.prod_map _ _ _).symm + _ ≤ previousProduct D X := Finset.prod_le_prod_of_subset_of_one_le₀ hsub + (fun j _ => Nat.zero_le _) (fun j _ _ => hX j) + +variable (s r : ℕ) (hs : 1 ≤ s) (Fs : Finset (Scale a)) (q₀ : ℕ) (b₀ : Scale a) +local notation "I" => FiniteModelSlots.Index D s r hs Fs q₀ b₀ + + + +def modelBudget : ℝ := + (∑ av ∈ FiniteModelSlots.required D s r hs Fs q₀ b₀, + ∑ e, |(av.2 e : ℝ)|) + + ∑ p ∈ pivotOptions s r hs D Fs, ∑ i : Comparison D Fs r, + ∑ e, |(ownInput D (qdim D) (coord D) i.2.1.1 + (terminalShift D q₀ (scaleRun D 0 p b₀ * i.1.val) i.2.1.2.val).toAdd e : ℝ)| + +lemma modelBudget_nonneg : 0 ≤ modelBudget D s r hs Fs q₀ b₀ := by + unfold modelBudget + positivity + +lemma modelBudget_slot (i : I) : + (∑ e, |(i.1.val.2 e : ℝ)|) ≤ modelBudget D s r hs Fs q₀ b₀ := by + unfold modelBudget + apply le_trans ?_ (le_add_of_nonneg_right (by positivity)) + exact Finset.single_le_sum (f := fun av : ℚ × Slots D => ∑ e, |(av.2 e : ℝ)|) + (fun av _ => Finset.sum_nonneg (fun e _ => abs_nonneg _)) i.1.property + +lemma modelBudget_input (p : Path D) (hp : p ∈ pivotOptions s r hs D Fs) + (i : Comparison D Fs r) : + (∑ e, |(ownInput D (qdim D) (coord D) i.2.1.1 + (terminalShift D q₀ (scaleRun D 0 p b₀ * i.1.val) i.2.1.2.val).toAdd e : ℝ)|) ≤ + modelBudget D s r hs Fs q₀ b₀ := by + apply le_trans ?_ (le_add_of_nonneg_left (by positivity)) + apply le_trans (Finset.single_le_sum + (fun i _ => Finset.sum_nonneg (fun e _ => abs_nonneg _)) (Finset.mem_univ i)) + apply Finset.single_le_sum _ hp + intro p hp + positivity + +open Filter MeasureTheory RationalLattice MalcevCharacters +open MicrocellScale AdmissibleMicrocellBoundary RoughScales IntegerAlignment +open RoughSamplingWeights SourceMacroSelection + +section Harmonic +variable (G₀ : Fin D.targets → ℚ → Fin r → Type) +variable [∀ t v c, Group (G₀ t v c)] [∀ t v c, TopologicalSpace (G₀ t v c)] +variable [∀ t v c, IsTopologicalGroup (G₀ t v c)] +variable (Γ₀ : ∀ t v c, Subgroup (G₀ t v c)) +variable (n₀ : Fin D.targets → ℚ → Fin r → ℕ) +variable (c₀ : ∀ t v c, RealCoordinates (G₀ t v c) (n₀ t v c)) +variable (hsk : ∀ t v c, SecondKind (c₀ t v c)) +variable (A₀ : ∀ t v c, CubeFaces.Filtration (G₀ t v c)) +variable (weight : ∀ t v c, Fin (n₀ t v c) → ℕ) +variable (hA : ∀ t v c k (g : G₀ t v c), g ∈ (A₀ t v c).level k ↔ + ∀ j, weight t v c j < k → (c₀ t v c).coord g j = 0) +variable (hw : ∀ t v c j, 0 < weight t v c j) +include hsk hA hw + + + +theorem source_actual_harmonic + (hΓ : ∀ t v c g, g ∈ Γ₀ t v c ↔ ∀ j, ∃ z : ℤ, (c₀ t v c).coord g j = z) + (hmono : ∀ t v c, Monotone (weight t v c)) + (h0 : ∀ t v c, (A₀ t v c).level 0 = ⊤) + (h1 : ∀ t v c, (A₀ t v c).level 1 = ⊤) + (hstep : ∀ t v c, (A₀ t v c).level (s+1) = ⊥) + (M J R H : ℕ → ℕ) (L : ℕ → ℤ) (ht : ℕ → Fin a → ℤ) + (g₀ x₀ : ∀ t, ℕ → (Fin (h D t) → ℕ) → ∀ v c, ℤ → ℤ → G₀ t v c) + (obs₀ : ∀ t, ℕ → (Fin (h D t) → ℕ) → ∀ v c, ℤ → ℤ → ((G₀ t v c) ⧸ Γ₀ t v c) →ᵇ ℝ) + (w0 Xp : ℕ → ℕ) (X : ℕ → Fin a → ℕ) + (hw0 : Tendsto w0 atTop atTop) + (hX : ∀ N j, 4*primorial (w0 N) ≤ X N j) + (hXp : ∀ N, 4*primorial (w0 N) ≤ Xp N) + (hXt : ∀ j, Tendsto (fun N => X N j) atTop atTop) + (hXpt : Tendsto Xp atTop atTop) + (hWM : ∀ N, (primorial (w0 N) : ℤ) ∣ (M N : ℤ)) + (hM : ∀ N, 0 < M N) (hMs : ∀ N, RoughScales.Smooth (w0 N) (M N : ℤ)) + (hJ : ∀ N, 0 < J N) (hRJ : ∀ N, R N = M N*J N) + (hL : ∀ N, 0 < L N) (hsm : ∀ N, RoughScales.Smooth (w0 N) (L N)) + (hWL : ∀ N, (primorial (w0 N) : ℤ) ∣ L N) (hML : ∀ N, (M N : ℤ) ∣ L N) + (hLexact : ∀ N, L N = (M N : ℤ)*(primorial (w0 N) : ℤ)^(w0 N)) + (hXL : ∀ t (j : Fin (m D t)), Tendsto (fun N => + (X N (perm D t (j.castAdd (h D t))) : ℝ)/(L N : ℝ)) atTop atTop) + (hH : ∀ N, 0 < H N) (hRrad : ∀ N, R N = radius (M N) (H N)) + (hdom : Dominates (fun N => (H N : ℝ)) (earlierScale M (fun N => previousProduct D (X N)))) + (hxdom : Dominates (fun N => Real.log (Xp N : ℝ)) (fun N => (H N : ℝ))) + (hLsize : ∀ᶠ N in atTop, (L N : ℝ) ≤ (M N : ℝ)^2) + (hq₀ : 0 < q₀) (hht : ∀ N j, 0 < ht N j) + (hheight : ∀ N e, height (ht N) (D.added e) ≤ M N) + (hd : ∀ e, Disjoint (D.added e) (D.tail (D.owner e))) + (metric : ∀ t v c, MetricSpace ((G₀ t v c) ⧸ Γ₀ t v c)) + (hmetric : ∀ t v c, QuotientGroup.instTopologicalSpace (Γ₀ t v c) = + (metric t v c).toUniformSpace.toTopologicalSpace) : + letI : ∀ t v c, MetricSpace ((G₀ t v c) ⧸ Γ₀ t v c) := + fun t v c => (metric t v c).replaceTopology (hmetric t v c) + ∀ (Kobs : ℝ≥0) (Bobs : ℝ), + (∀ t N y v c b r', LipschitzWith Kobs (obs₀ t N y v c b r')) → + (∀ t N y v c b r' z, |obs₀ t N y v c b r' z| ≤ Bobs) → + ∀ (Bs : Finset (Scale a)), b₀ ∈ Bs → + pivotModulus s r hs D Fs Bs ∣ q₀ → ∀ (τ : ℝ), 0 < τ → + let d := family D s r hs Fs q₀ b₀ G₀ Γ₀ M J R H L (heightCoeff D q₀ ht) g₀ x₀ obs₀ + Tendsto (fun N => (jointLaw (X N) (Xp N) (primorial (w0 N)) (primorial_pos _) (hX N) (hXp N)) + {z | cellRatio (Xp N) (primorial (w0 N)) (M N) (J N) z.2 (primorial_pos _) (hXp N) + {k | ((d.atTime N).localModel z).modelSuccess (coord D) (k : ℤ) s r hs + (FiniteModelSlots.formula D s r hs Fs q₀ b₀) Fs q₀ b₀ τ} ≤ + ((pivotOptions s r hs D Fs).card : ℝ)⁻¹/3}) atTop (𝓝 0) := by + let : ∀ t v c, MetricSpace ((G₀ t v c) ⧸ Γ₀ t v c) := + fun t v c => (metric t v c).replaceTopology (hmetric t v c) + intro Kobs Bobs hLip hBound Bs hb hq τ hτ + let d := family D s r hs Fs q₀ b₀ G₀ Γ₀ M J R H L (heightCoeff D q₀ ht) g₀ x₀ obs₀ + let P := fun N => previousProduct D (X N) + let Q := fun N => (M N : ℝ)*(P N : ℝ)^2 + have hx1 (N j) : 1 ≤ X N j := by + have hW := primorial_pos (w0 N) + have hh := hX N j + omega + have hP (N) : 0 < P N := previousProduct_pos D (X N) (hx1 N) + have hprod : ∀ t, ∀ᶠ N in atTop, + (∀ j : Fin (m D t), X N (perm D t (j.castAdd (h D t))) ≤ P N) ∧ + (∏ j : Fin (m D t), (X N (perm D t (j.castAdd (h D t))) : ℝ)^2) ≤ (P N : ℝ)^2 := by + intro t + apply Filter.Eventually.of_forall + intro N + constructor + · intro j + exact le_previousProduct D (X N) (hx1 N) _ (D.tail_lt t _ (perm_inside D t j)) + · rw [Finset.prod_pow] + apply pow_le_pow_left₀ (by positivity) + exact_mod_cast tail_product_le_previous D (X N) (hx1 N) t + have hslot : ∀ t N y, + y ∈ outsideDomain (fun j : Fin (h D t) => X N (perm D t (j.natAdd (m D t)))) (primorial (w0 N)) → + ∀ (b : Label (m D t)) (i : I), |(d.slot t N y b i : ℝ)| ≤ modelBudget D s r hs Fs q₀ b₀*(L N : ℝ) := by + intro t N y hy b i + have hn : (0 : ℝ) ≤ L N := by exact_mod_cast (hL N).le + apply le_trans _ (mul_le_mul_of_nonneg_right (modelBudget_slot D s r hs Fs q₀ b₀ i) hn) + exact_mod_cast actual_slot_bound D (L N) (hL N) (heightCoeff D q₀ ht N) (reconstruct D t y b) i.1.val.2 + have hQ : ∀ t N y, + y ∈ outsideDomain (fun j : Fin (h D t) => X N (perm D t (j.natAdd (m D t)))) (primorial (w0 N)) → + ∀ (b : Label (m D t)) k, |(d.qval t N y b k : ℝ)| ≤ Q N := by + intro t N y hy b k + have hb := source_qValue_bound D q₀ hq₀ ht N (M N) (hht N) (hheight N) hd + (X N) (hx1 N) (primorial (w0 N)) t y hy b k + dsimp only [Q, P, previousProduct] + exact_mod_cast hb + exact source_model_harmonic D (fun t (i : I) => G₀ t i.1.val.1 i.2) + (fun t i => n₀ t i.1.val.1 i.2) (qdim D) + (fun t i => c₀ t i.1.val.1 i.2) (fun t i => hsk t i.1.val.1 i.2) + (fun t i => A₀ t i.1.val.1 i.2) (fun t i => weight t i.1.val.1 i.2) + (fun t i => hA t i.1.val.1 i.2) (fun t i => hw t i.1.val.1 i.2) + (fun t i => Γ₀ t i.1.val.1 i.2) (coord D) + (fun t i => hΓ t i.1.val.1 i.2) (fun t i => hmono t i.1.val.1 i.2) s + (fun t i => h0 t i.1.val.1 i.2) (fun t i => h1 t i.1.val.1 i.2) + (fun t i => hstep t i.1.val.1 i.2) a d w0 Xp P X Q hw0 hX hXp hXt hXpt + hWM hM hMs hJ hRJ hL hsm hWL hML hLexact hXL hH hP hRrad hdom hxdom hprod + (fun _ => by dsimp [Q]; positivity) (Eventually.of_forall (fun _ => le_rfl)) hLsize + (modelBudget D s r hs Fs q₀ b₀) (modelBudget_nonneg D s r hs Fs q₀ b₀) + (fun t N y hy b _ i => hslot t N y hy b i) + (fun t N y hy b _ k => hQ t N y hy b k) + (fun t i => metric t i.1.val.1 i.2) (fun t i => hmetric t i.1.val.1 i.2) + Kobs Bobs (fun t N y i => hLip t N y i.1.val.1 i.2) + (fun t N y i => hBound t N y i.1.val.1 i.2) + r hs (FiniteModelSlots.formula D s r hs Fs q₀ b₀) Fs Bs q₀ hq b₀ hb τ hτ + (modelBudget_input D s r hs Fs q₀ b₀) + +end Harmonic + +end SourceIntegerArrays.GlobalJoint.SourceFrozenFamily + +end +end + +end OAI diff --git a/lean/OAI/Combinatorics/SumProduct/Alignment/IntegerHyperplane01.lean b/lean/OAI/Combinatorics/SumProduct/Alignment/IntegerHyperplane01.lean new file mode 100644 index 0000000000000000000000000000000000000000..82bc77f01f0b92a5bf40ecef1383d30a585af853 --- /dev/null +++ b/lean/OAI/Combinatorics/SumProduct/Alignment/IntegerHyperplane01.lean @@ -0,0 +1,386 @@ +import Mathlib +import OAI.Combinatorics.SumProduct.Alignment.RationalLattice05 +import OAI.Geometry.NilpotentCharts.Main + +namespace OAI + +section +section +section +section +open _root_.Polynomial _root_.OAI.Polynomial +noncomputable section +end +end + + + +section +open scoped BigOperators +noncomputable section +namespace IntegerHyperplane +variable {n : ℕ} + +def form (k : Fin n → ℤ) : (Fin n → ℝ) →ₗ[ℝ] ℝ where + toFun x := ∑ i, (k i : ℝ) * x i + map_add' x y := by simp [mul_add,Finset.sum_add_distrib] + map_smul' r x := by simp [Finset.mul_sum]; apply Finset.sum_congr rfl; intros; ring + + +def generator (k : Fin n → ℤ) (p j : Fin n) : Fin n → ℤ := + k p • Pi.single j 1 - k j • Pi.single p 1 + +def realGenerator (k : Fin n → ℤ) (p j : Fin n) : Fin n → ℝ := fun i => generator k p j i + +lemma realGenerator_eq (k : Fin n → ℤ) (p j : Fin n) : + realGenerator k p j = (k p : ℝ) • Pi.single j 1 - (k j : ℝ) • Pi.single p 1 := by + classical + ext i + simp [realGenerator,generator,Pi.single_apply] + +lemma generator_mem (k : Fin n → ℤ) (p j : Fin n) : realGenerator k p j ∈ (form k).ker := by + classical + change form k (realGenerator k p j) = 0 + rw [realGenerator_eq,map_sub,map_smul,map_smul] + simp [form,Pi.single_apply,mul_comm] + +lemma decomposition (k : Fin n → ℤ) {p : Fin n} (hp : k p ≠ 0) + (x : Fin n → ℝ) : + (∑ j, (x j / (k p : ℝ)) • realGenerator k p j) = + x - (form k x / (k p : ℝ)) • Pi.single p 1 := by + classical + have hpR : (k p : ℝ) ≠ 0 := by exact_mod_cast hp + ext i + simp only [Finset.sum_apply, Pi.smul_apply, smul_eq_mul, realGenerator_eq, + Pi.sub_apply, Pi.single_apply] + by_cases hi : i = p + · subst i + simp only [↓reduceIte, mul_one] + simp_rw [mul_sub] + rw [Finset.sum_sub_distrib] + have hfirst : ∑ j : Fin n, x j / (k p : ℝ) * ((k p : ℝ) * if p = j then 1 else 0) = x p := by + simp [mul_ite,hpR] + rw [hfirst] + congr 1 + change (∑ j, x j / (k p : ℝ) * (k j : ℝ)) = (∑ j, (k j : ℝ) * x j) / (k p : ℝ) + rw [Finset.sum_div] + apply Finset.sum_congr rfl + intro j _ + ring + · simp only [hi, ↓reduceIte, mul_zero, sub_zero] + simp [mul_ite,hpR] + + + +theorem kernel_span (k : Fin n → ℤ) {p : Fin n} (hp : k p ≠ 0) : + (form k).ker = Submodule.span ℝ (Set.range (realGenerator k p)) := by + apply le_antisymm + · intro x hx + have he := decomposition k hp x + have hx0 : form k x = 0 := hx + rw [hx0, zero_div,zero_smul,sub_zero] at he + rw [← he] + apply Submodule.sum_mem + intro j _ + exact Submodule.smul_mem _ _ (Submodule.subset_span ⟨j,rfl⟩) + · apply Submodule.span_le.mpr + rintro _ ⟨j,rfl⟩ + exact generator_mem k p j + +lemma generator_bound (k : Fin n → ℤ) (A : ℝ) (hA : 0 ≤ A) + (hk : ∀ i, |(k i : ℝ)| ≤ A) (p j i : Fin n) : + |(generator k p j i : ℝ)| ≤ A := by + classical + by_cases hj : j = p + · subst j; simpa [generator] using hA + · by_cases hij : i = j + · subst i + simpa [generator,Pi.single_apply,hj] using hk p + · by_cases hip : i = p + · subst i + simpa [generator,Pi.single_apply,Ne.symm hj] using hk j + · simpa [generator,Pi.single_apply,hij,hip] using hA + +theorem form_surjective (k : Fin n → ℤ) {p : Fin n} (hp : k p ≠ 0) : + Function.Surjective (form k) := by + classical + intro y + refine ⟨Pi.single p (y / (k p : ℝ)), ?_⟩ + have hpR : (k p : ℝ) ≠ 0 := by exact_mod_cast hp + simp only [form,LinearMap.coe_mk,AddHom.coe_mk,Pi.single_apply] + simp only [mul_ite,mul_zero,Finset.sum_ite_eq',Finset.mem_univ,ite_true] + field_simp + + +theorem kernel_finrank (k : Fin n → ℤ) (hk : k ≠ 0) : + Module.finrank ℝ (form k).ker = n-1 := by + classical + obtain ⟨p,hp⟩ : ∃ p, k p ≠ 0 := by + by_contra! h + exact hk (funext h) + have hr : (form k).range = ⊤ := LinearMap.range_eq_top.mpr (form_surjective k hp) + have h := LinearMap.finrank_range_add_finrank_ker (form k) + rw [hr] at h + simp at h + omega + +end IntegerHyperplane +end +end + + + +section +open scoped BigOperators +noncomputable section +namespace IntegerHyperplane +variable {n : ℕ} + +def lift (k : Fin (n+1) → ℤ) (p : Fin (n+1)) (x : Fin n → ℝ) : Fin (n+1) → ℝ := + p.insertNth (-(∑ j, (k (p.succAbove j):ℝ)*x j)/(k p:ℝ)) x + +@[simp] lemma lift_succAbove (k : Fin (n+1) → ℤ) (p : Fin (n+1)) + (x : Fin n → ℝ) (j : Fin n) : lift k p x (p.succAbove j) = x j := + Fin.insertNth_apply_succAbove _ _ _ _ + +@[simp] lemma lift_pivot (k : Fin (n+1) → ℤ) (p : Fin (n+1)) (x : Fin n → ℝ) : + lift k p x p = -(∑ j, (k (p.succAbove j):ℝ)*x j)/(k p:ℝ) := + Fin.insertNth_apply_same _ _ _ + +lemma form_lift (k : Fin (n+1) → ℤ) (p : Fin (n+1)) (hp : k p ≠ 0) (x : Fin n → ℝ) : + form k (lift k p x) = 0 := by + change (∑ j, (k j:ℝ)*lift k p x j) = 0 + rw [Fin.sum_univ_succAbove _ p,lift_pivot] + simp only [lift_succAbove] + have hpR : (k p:ℝ) ≠ 0 := by exact_mod_cast hp + field_simp + ring + +lemma lift_remove (k : Fin (n+1) → ℤ) (p : Fin (n+1)) (hp : k p ≠ 0) + (x : Fin (n+1) → ℝ) (hx : form k x = 0) : lift k p (p.removeNth x) = x := by + funext i + rcases Fin.eq_self_or_eq_succAbove p i with he | ⟨j,he⟩ + · subst i + rw [lift_pivot] + have he := Fin.sum_univ_succAbove (fun j => (k j:ℝ)*x j) p + change (∑ j, (k j:ℝ)*x j) = 0 at hx + have hpR : (k p:ℝ) ≠ 0 := by exact_mod_cast hp + apply (div_eq_iff hpR).mpr + change -(∑ j, (k (p.succAbove j):ℝ)*x (p.succAbove j)) = x p*(k p:ℝ) + linarith + · subst i + exact lift_succAbove k p (p.removeNth x) j + +lemma lift_continuous (k : Fin (n+1) → ℤ) (p : Fin (n+1)) : Continuous (lift k p) := by + apply continuous_pi + intro i + rcases Fin.eq_self_or_eq_succAbove p i with he | ⟨j,he⟩ + · subst i + simp only [lift_pivot] + apply Continuous.div_const + apply Continuous.neg + exact continuous_finsetSum _ (fun j _ => continuous_const.mul (continuous_apply j)) + · subst i + simp only [lift_succAbove] + exact continuous_apply j + +lemma lift_zero (k : Fin (n+1) → ℤ) (p : Fin (n+1)) : lift k p 0 = 0 := by + funext i + rcases Fin.eq_self_or_eq_succAbove p i with he | ⟨j,he⟩ <;> subst i <;> simp + +lemma lift_polynomial (k : Fin (n+1) → ℤ) (p : Fin (n+1)) (i : Fin (n+1)) : + RationalPolynomialMap.IsPolynomial (fun x => lift k p x i) := by + rcases Fin.eq_self_or_eq_succAbove p i with he | ⟨j,he⟩ + · subst i + simp only [lift_pivot] + have hs : RationalPolynomialMap.IsPolynomial (fun x : Fin n → ℝ => + ∑ j, (k (p.succAbove j):ℝ)*x j) := by + have ha (S : Finset (Fin n)) : RationalPolynomialMap.IsPolynomial (fun x : Fin n → ℝ => + ∑ j ∈ S, (k (p.succAbove j):ℝ)*x j) := by + induction S using Finset.induction_on with + | empty => simpa using RationalPolynomialMap.zero (σ:=Fin n) + | @insert j S hj ih => + simp only [Finset.sum_insert hj] + apply RationalPolynomialMap.add _ ih + simpa only [Rat.cast_intCast] using RationalPolynomialMap.mul + (RationalPolynomialMap.const (σ:=Fin n) (k (p.succAbove j):ℚ)) + (RationalPolynomialMap.coordinate j) + simpa using ha Finset.univ + have hm := RationalPolynomialMap.mul (RationalPolynomialMap.neg hs) + (RationalPolynomialMap.const (σ:=Fin n) ((k p:ℚ)⁻¹)) + simpa only [Rat.cast_inv,Rat.cast_intCast,div_eq_mul_inv] using hm + · subst i + simp only [lift_succAbove] + exact RationalPolynomialMap.coordinate j + + + +lemma lift_lower_dep (k : Fin (n+1) → ℤ) (p : Fin (n+1)) + (hlast : ∀ j : Fin (n+1), p < j → k j = 0) (i : Fin n) + (x y : Fin n → ℝ) (hxy : ∀ j : Fin n, j < i → x j = y j) + (a : Fin (n+1)) (ha : a < p.succAbove i) : lift k p x a = lift k p y a := by + rcases Fin.eq_self_or_eq_succAbove p a with he | ⟨j,he⟩ + · subst a + simp only [lift_pivot] + congr 2 + apply Finset.sum_congr rfl + intro j _ + by_cases hj : j < i + · rw [hxy j hj] + · have hk : k (p.succAbove j) = 0 := hlast _ + (lt_of_lt_of_le ha ((Fin.succAboveOrderEmb p).monotone (le_of_not_gt hj))) + simp [hk] + · subst a + simp only [lift_succAbove] + exact hxy j (Fin.succAbove_lt_succAbove_iff.mp ha) + +end IntegerHyperplane + +namespace RationalCharacterKernel +open RationalLattice IntegerHyperplane RationalPolynomialMap +variable {G : Type*} [Group G] [TopologicalSpace G] {n : ℕ} +variable (c : RealCoordinates G (n+1)) (χ : G →* Multiplicative ℝ) +variable (k : Fin (n+1) → ℤ) (p : Fin (n+1)) (hp : k p ≠ 0) +variable (hχ : ∀ g : G, Multiplicative.toAdd (χ g) = form k (c.coord g)) + +def coordinates (g : χ.ker) (i : Fin n) : ℝ := c.coord g.val (p.succAbove i) + +include hχ in +lemma form_coord_kernel (g : χ.ker) : form k (c.coord g.val) = 0 := by + rw [← hχ] + have hg : χ g.val = 1 := g.property + rw [hg] + rfl + +include hp hχ in +lemma coord_lift (g : χ.ker) : c.coord g.val = lift k p (coordinates c χ p g) := by + exact (lift_remove k p hp (c.coord g.val) (form_coord_kernel c χ k hχ g)).symm + +def rebuild (x : Fin n → ℝ) : χ.ker := + ⟨c.coord.symm (lift k p x),by + change χ _ = 1 + apply Multiplicative.toAdd.injective + rw [hχ,c.coord.apply_symm_apply,form_lift k p hp] + rfl⟩ + +lemma coordinates_rebuild (x : Fin n → ℝ) : + coordinates c χ p (rebuild c χ k p hp hχ x) = x := by + funext i + simp only [coordinates,rebuild,Homeomorph.apply_symm_apply,lift_succAbove] + +lemma rebuild_coordinates (g : χ.ker) : + rebuild c χ k p hp hχ (coordinates c χ p g) = g := by + apply Subtype.ext + apply c.coord.injective + simp only [rebuild,Homeomorph.apply_symm_apply] + exact (coord_lift c χ k p hp hχ g).symm + +lemma coordinates_continuous : Continuous (coordinates c χ p) := by + apply continuous_pi + intro i + exact (continuous_apply _).comp (c.coord.continuous.comp continuous_subtype_val) + +lemma rebuild_continuous : Continuous (rebuild c χ k p hp hχ) := by + apply Continuous.subtype_mk + exact c.coord.symm.continuous.comp (lift_continuous k p) + +def kernelHomeomorph : χ.ker ≃ₜ (Fin n → ℝ) where + toFun := coordinates c χ p + invFun := rebuild c χ k p hp hχ + left_inv := rebuild_coordinates c χ k p hp hχ + right_inv := coordinates_rebuild c χ k p hp hχ + continuous_toFun := coordinates_continuous c χ p + continuous_invFun := rebuild_continuous c χ k p hp hχ + +lemma exists_kernel_correction (i : Fin n) : + ∃ P : MvPolynomial (Fin i.val ⊕ Fin i.val) ℚ, + ∀ v : (Fin i.val ⊕ Fin i.val) → ℝ, + MvPolynomial.eval₂ (algebraMap ℚ ℝ) + (Sum.elim + (fun a => lift k p (lowerExtend i (fun j => v (Sum.inl j))) + ⟨a.val,lt_trans a.isLt (p.succAbove i).isLt⟩) + (fun a => lift k p (lowerExtend i (fun j => v (Sum.inr j))) + ⟨a.val,lt_trans a.isLt (p.succAbove i).isLt⟩)) (c.correction (p.succAbove i)) = + MvPolynomial.eval₂ (algebraMap ℚ ℝ) v P := by + apply RationalPolynomialMap.eval + intro a + cases a with + | inl a => + apply RationalPolynomialMap.comp (lift_polynomial k p _) + intro j + unfold lowerExtend + split_ifs + · exact RationalPolynomialMap.coordinate _ + · exact RationalPolynomialMap.zero + | inr a => + apply RationalPolynomialMap.comp (lift_polynomial k p _) + intro j + unfold lowerExtend + split_ifs + · exact RationalPolynomialMap.coordinate _ + · exact RationalPolynomialMap.zero + +def kernelCorrection (i : Fin n) : MvPolynomial (Fin i.val ⊕ Fin i.val) ℚ := + (exists_kernel_correction c k p i).choose + +variable (hlast : ∀ j : Fin (n+1), p < j → k j = 0) + +include hp hχ hlast in +lemma kernel_mul_coord (g h : χ.ker) (i : Fin n) : + coordinates c χ p (g*h) i = coordinates c χ p g i + coordinates c χ p h i + + MvPolynomial.eval₂ (algebraMap ℚ ℝ) + (Sum.elim (fun j => coordinates c χ p g ⟨j.val,lt_trans j.isLt i.isLt⟩) + (fun j => coordinates c χ p h ⟨j.val,lt_trans j.isLt i.isLt⟩)) (kernelCorrection c k p i) := by + change c.coord (g.val*h.val) (p.succAbove i) = _ + rw [c.mul_coord] + change coordinates c χ p g i + coordinates c χ p h i + _ = _ + congr 1 + let v : (Fin i.val ⊕ Fin i.val) → ℝ := + Sum.elim (fun j => coordinates c χ p g ⟨j.val,lt_trans j.isLt i.isLt⟩) + (fun j => coordinates c χ p h ⟨j.val,lt_trans j.isLt i.isLt⟩) + unfold kernelCorrection + rw [← (exists_kernel_correction c k p i).choose_spec v] + congr 1 + funext a + have hl (u : χ.ker) (a : Fin (p.succAbove i).val) : + c.coord u.val ⟨a.val,lt_trans a.isLt (p.succAbove i).isLt⟩ = + lift k p (lowerExtend i (fun j => coordinates c χ p u ⟨j.val,lt_trans j.isLt i.isLt⟩)) + ⟨a.val,lt_trans a.isLt (p.succAbove i).isLt⟩ := by + rw [coord_lift c χ k p hp hχ] + apply lift_lower_dep k p hlast i + · intro j hj + simp [lowerExtend,hj] + · exact a.isLt + cases a with + | inl a => exact hl g a + | inr a => exact hl h a + + + +def kernelCoordinates : RealCoordinates χ.ker n where + coord := kernelHomeomorph c χ k p hp hχ + one_coord i := c.one_coord (p.succAbove i) + correction := kernelCorrection c k p + mul_coord := kernel_mul_coord c χ k p hp hχ hlast + +lemma kernelCoordinates_rational (g : χ.ker) : + IsRational (kernelCoordinates c χ k p hp hχ hlast) g ↔ IsRational c g.val := by + constructor + · intro hg i + obtain ⟨P,hP⟩ := lift_polynomial k p i + obtain ⟨q,hq⟩ := eval_rational P (coordinates c χ p g) hg + refine ⟨q,?_⟩ + rw [hq,← hP] + exact congrFun (coord_lift c χ k p hp hχ g).symm i + · intro hg i + exact hg (p.succAbove i) + +end RationalCharacterKernel + +end +end +end +end +end + +end OAI diff --git a/lean/OAI/Combinatorics/SumProduct/Alignment/IntegerHyperplane02.lean b/lean/OAI/Combinatorics/SumProduct/Alignment/IntegerHyperplane02.lean new file mode 100644 index 0000000000000000000000000000000000000000..b47515e8d0b244d16f89a0a6ae1a2ffa23cb2cc4 --- /dev/null +++ b/lean/OAI/Combinatorics/SumProduct/Alignment/IntegerHyperplane02.lean @@ -0,0 +1,283 @@ +import Mathlib +import OAI.Combinatorics.SumProduct.Alignment.CharacterFactorization01 +import OAI.Combinatorics.SumProduct.Alignment.FactorCoefficient01 +import OAI.Geometry.NilpotentCharts.Main + +namespace OAI + +section +section +section +section +noncomputable section +open _root_.Polynomial _root_.OAI.Polynomial +end +end + + + +section +noncomputable section +namespace FiniteCoverCharacter +variable {G : Type*} [Group G] {Λ Γ : Subgroup G} + + + +theorem uniform_power_mem (_h : Λ ≤ Γ) [(Λ.subgroupOf Γ).FiniteIndex] : + ∃ M : ℕ, 0 Multiplicative.toAdd (ψ g)) he + have hn : (M:ℝ) ≠ 0 := by exact_mod_cast Nat.ne_of_gt hM + simpa [MonoidHom.pow_apply,hn] using hh + · intro H hH g hg + change (χ^M) g=1 + have he : χ g=1 := hH hg + simp only [MonoidHom.pow_apply,he,one_pow] + +end FiniteCoverCharacter +end +end + + + +section +noncomputable section +open _root_.Polynomial _root_.OAI.Polynomial +open scoped BigOperators +namespace FactorCoefficientTransfer +open CubeFaces CubePolynomials RationalLattice RealCharacters LeibmanSquare +variable {G : Type*} [Group G] [TopologicalSpace G] [IsTopologicalGroup G] + + + +omit [IsTopologicalGroup G] in +theorem finite_cover_factor_transfer [IsTopologicalGroup G] + (H : Filtration G) (h0 : H.level 0=⊤) + (Λ Γ : Subgroup G) (hle : Λ ≤ Γ) [(Λ.subgroupOf Γ).FiniteIndex] + {m : ℕ} (c : RealCoordinates (H.level 2) m) + (s : ℕ) (hs : H.level (s+1)=⊥) (Tmax : ℕ) + (Ξ : Finset (G →* Multiplicative ℝ)) + (hcont : ∀ χ∈Ξ, Continuous χ) + (hint : ∀ χ∈Ξ, ∀ g∈Λ, ∃ z : ℤ, (χ g).toAdd=z) + (A B M : ℝ) (hA : 0≤A) (hM : 1≤M) : + ∃ U : Finset (G →* Multiplicative ℝ), + (∀ ψ∈U, Continuous ψ ∧ (∀ g∈Γ, ∃ z : ℤ, (ψ g).toAdd=z)) ∧ + ∃ C : ℝ, 0 (e z).val) → + Polynomial H 0 (fun z => (b z).val) → + (∀ z, f z=(e z).val*f' z*(b z).val) → + Function.Periodic (fun z => (QuotientGroup.mk (b z).val : G⧸Γ)) (T:ℤ) → + (∀ z : ℤ, |(z:ℝ)| ≤ N → ‖c.coord (e z)‖ ≤ B) → + ∀ v : G, ∀ χ∈Ξ, χ≠1 → ∀ R : ℝ[X], + (∀ z : ℤ, R.eval (z:ℝ)=(χ (v⁻¹*f' ((T:ℤ)*z+r)*v)).toAdd) → + (∀ j : ℕ, 0 intScale (i.1.val^d) (q i)) + let Cmax := 1+∑ i : I, C i + have hCm : 0 (hC i).le) + dsimp only [Cmax] + linarith + refine ⟨U,?_,Cmax,hCm,?_⟩ + · intro ψ hψ + obtain ⟨i,hiU,rfl⟩ := Finset.mem_image.mp hψ + exact ⟨intScale_continuous _ _ (hc i.1),intScale_integral _ _ Γ (hi i.1)⟩ + · intro N K hN hK hNM T hT hTT r hr hrN f f' e b hf he hb hfac hper hB v χ hχ hnχ R hRe hRc + let i : I := (⟨χ,hχ⟩,⟨T,Finset.mem_Icc.mpr ⟨hT,hTT⟩⟩) + let R' := Polynomial.C (d:ℝ)*R + have hR'e : ∀ z : ℤ, R'.eval (z:ℝ)=((χ^d) (v⁻¹*f' ((T:ℤ)*z+r)*v)).toAdd := by + intro z + simp only [R',eval_mul,eval_C,hRe,MonoidHom.pow_apply,toAdd_pow,nsmul_eq_mul] + have hR'c : ∀ j : ℕ, 0 (hC j).le) (Finset.mem_univ i) + dsimp only [Cmax] + linarith + refine ⟨intScale (χ^d) (q i),Finset.mem_image.mpr ⟨i,Finset.mem_univ _,rfl⟩, + intScale_ne_one _ (hq i) hn,Polynomial.C (q i:ℝ)*P, + (natDegree_C_mul_le _ _).trans hP,?_,?_⟩ + · intro z + simp only [eval_mul,eval_C,hPe,intScale_apply] + rfl + · intro j hj + obtain ⟨z,hz⟩ := hPc j hj + refine ⟨z,?_⟩ + simp only [coeff_C_mul] + exact hz.trans (div_le_div_of_nonneg_right hCi (by positivity)) + +end FactorCoefficientTransfer +end +end + + + +section +noncomputable section +open scoped BigOperators +namespace IntegerHyperplane +variable {n : ℕ} + + + +def splitLift (k : Fin (n+1) → ℤ) (p : Fin (n+1)) (x : Fin (n+1) → ℝ) : Fin (n+1) → ℝ := + lift k p (Fin.tail x) + Pi.single p (x 0) + +def splitCoordinates (k : Fin (n+1) → ℤ) (p : Fin (n+1)) (x : Fin (n+1) → ℝ) : Fin (n+1) → ℝ := + Fin.cons (form k x / (k p:ℝ)) (p.removeNth x) + +@[simp] lemma splitLift_succAbove (k : Fin (n+1) → ℤ) (p : Fin (n+1)) + (x : Fin (n+1) → ℝ) (i : Fin n) : splitLift k p x (p.succAbove i) = x i.succ := by + classical + simp [splitLift,Fin.tail] + +@[simp] lemma splitLift_pivot (k : Fin (n+1) → ℤ) (p : Fin (n+1)) + (x : Fin (n+1) → ℝ) : + splitLift k p x p = -(∑ j, (k (p.succAbove j):ℝ)*x j.succ)/(k p:ℝ)+x 0 := by + classical + simp [splitLift,Fin.tail] + +lemma form_splitLift (k : Fin (n+1) → ℤ) (p : Fin (n+1)) (hp : k p ≠ 0) + (x : Fin (n+1) → ℝ) : form k (splitLift k p x) = (k p:ℝ)*x 0 := by + classical + rw [splitLift,map_add,form_lift k p hp] + simp [form,Pi.single_apply] + +lemma splitCoordinates_splitLift (k : Fin (n+1) → ℤ) (p : Fin (n+1)) (hp : k p ≠ 0) + (x : Fin (n+1) → ℝ) : splitCoordinates k p (splitLift k p x) = x := by + have hpR : (k p:ℝ) ≠ 0 := by exact_mod_cast hp + ext i + refine Fin.cases ?_ (fun j => ?_) i + · simp [splitCoordinates,form_splitLift k p hp,hpR] + · simp [splitCoordinates,Fin.removeNth] + +lemma splitLift_splitCoordinates (k : Fin (n+1) → ℤ) (p : Fin (n+1)) (hp : k p ≠ 0) + (x : Fin (n+1) → ℝ) : splitLift k p (splitCoordinates k p x) = x := by + have hpR : (k p:ℝ) ≠ 0 := by exact_mod_cast hp + ext i + rcases Fin.eq_self_or_eq_succAbove p i with he | ⟨j,he⟩ + · subst i + rw [splitLift_pivot] + simp only [splitCoordinates,Fin.cons_succ,Fin.cons_zero,Fin.removeNth] + have hs := Fin.sum_univ_succAbove (fun j => (k j:ℝ)*x j) p + change (∑ j, (k j:ℝ)*x j) = _ at hs + change -(∑ j, (k (p.succAbove j):ℝ)*x (p.succAbove j))/(k p:ℝ)+ + (∑ j, (k j:ℝ)*x j)/(k p:ℝ) = x p + rw [hs] + field_simp + ring + · subst i + simp [splitCoordinates,Fin.removeNth] + +lemma splitLift_continuous (k : Fin (n+1) → ℤ) (p : Fin (n+1)) : + Continuous (splitLift k p) := by + apply continuous_pi + intro i + rcases Fin.eq_self_or_eq_succAbove p i with he | ⟨j,he⟩ + · subst i + simp only [splitLift_pivot] + exact ((continuous_finsetSum _ (fun j _ => continuous_const.mul (continuous_apply j.succ))).neg.div_const _).add (continuous_apply 0) + · subst i + simp only [splitLift_succAbove] + exact continuous_apply j.succ + +lemma splitCoordinates_continuous (k : Fin (n+1) → ℤ) (p : Fin (n+1)) : + Continuous (splitCoordinates k p) := by + apply continuous_pi + intro i + refine Fin.cases ?_ (fun j => ?_) i + · change Continuous (fun x => form k x / (k p:ℝ)) + change Continuous (fun x : Fin (n+1) → ℝ => (∑ j, (k j:ℝ)*x j)/(k p:ℝ)) + exact (continuous_finsetSum _ (fun j _ => continuous_const.mul (continuous_apply j))).div_const _ + · exact continuous_apply _ + +def splitHomeomorph (k : Fin (n+1) → ℤ) (p : Fin (n+1)) (hp : k p ≠ 0) : + (Fin (n+1) → ℝ) ≃ₜ (Fin (n+1) → ℝ) where + toFun := splitCoordinates k p + invFun := splitLift k p + left_inv := splitLift_splitCoordinates k p hp + right_inv := splitCoordinates_splitLift k p hp + continuous_toFun := splitCoordinates_continuous k p + continuous_invFun := splitLift_continuous k p + +lemma splitLift_polynomial (k : Fin (n+1) → ℤ) (p : Fin (n+1)) (i : Fin (n+1)) : + RationalPolynomialMap.IsPolynomial (fun x => splitLift k p x i) := by + classical + unfold splitLift + apply RationalPolynomialMap.add + · exact RationalPolynomialMap.comp (lift_polynomial k p i) + (fun j => RationalPolynomialMap.coordinate j.succ) + · by_cases hi : i = p + · subst i + simpa using RationalPolynomialMap.coordinate (0 : Fin (n+1)) + · simpa [Pi.single_apply,hi] using RationalPolynomialMap.zero (σ:=Fin (n+1)) + +lemma splitLift_lower_dep (k : Fin (n+1) → ℤ) (p : Fin (n+1)) + (hlast : ∀ j : Fin (n+1), p < j → k j = 0) (i : Fin n) + (x y : Fin (n+1) → ℝ) (hxy : ∀ j : Fin (n+1), j < i.succ → x j = y j) + (a : Fin (n+1)) (ha : a < p.succAbove i) : splitLift k p x a = splitLift k p y a := by + have h0 : x 0=y 0 := hxy 0 (by change 0 < i.val+1; omega) + have he := lift_lower_dep k p hlast i (Fin.tail x) (Fin.tail y) + (fun j hj => hxy j.succ (by change j.val+1 < i.val+1; exact Nat.add_lt_add_right hj 1)) a ha + simp only [splitLift,Pi.add_apply,h0,he] + +end IntegerHyperplane + +end +end +end +end +end + +end OAI diff --git a/lean/OAI/Combinatorics/SumProduct/Alignment/LagrangeBounds01.lean b/lean/OAI/Combinatorics/SumProduct/Alignment/LagrangeBounds01.lean new file mode 100644 index 0000000000000000000000000000000000000000..aadb67f366ca7cec78404d914c04fe4f299a9e4c --- /dev/null +++ b/lean/OAI/Combinatorics/SumProduct/Alignment/LagrangeBounds01.lean @@ -0,0 +1,286 @@ +import Mathlib +import OAI.Combinatorics.SumProduct.Alignment.ConstantCoefficient01 +import OAI.Combinatorics.SumProduct.Alignment.RoughJoint01 +import OAI.Geometry.NilpotentCharts.Main + +namespace OAI + +section +section +noncomputable section +open scoped BigOperators +end + +end + +section + + + + +noncomputable section +open scoped BigOperators +namespace RoughCharacterThinning +open RoughAnalyticExtraction RoughJointCoefficients +open FinitePieceAverages RoughSamplingWeights ComparableBoxLeibman +open CorrectedBoxLeibman PolynomialLineCoefficients TriangularLatticeRecovery +open _root_.Polynomial _root_.OAI.Polynomial + +def progressionIndex {N H : ℕ} (a b : ℕ) (h : a+b*H ≤ N) (j : Fin (H+1)) : Fin (N+1) := + ⟨a+b*j.val,Nat.lt_succ_of_le + ((Nat.add_le_add_left (Nat.mul_le_mul_left b (Nat.le_of_lt_succ j.isLt)) a).trans h)⟩ + +@[simp] lemma progressionIndex_val {N H : ℕ} (a b : ℕ) (h : a+b*H≤N) (j : Fin (H+1)) : + (progressionIndex a b h j).val = a+b*j.val := rfl + +section Nilmanifold +open CubeFaces CubePolynomials LeibmanSquare RationalLattice MalcevCharacters +open MeasureTheory PolynomialWeyl AbelianMalcevTorus RationalTailCoordinates UnitAddTorus +variable {G : Type} [Group G] [TopologicalSpace G] [IsTopologicalGroup G] +variable {t d : ℕ} (c : RealCoordinates G (t+d)) (hsk : SecondKind c) +variable (H : Filtration G) (h0 : H.level 0 = ⊤) (h1 : H.level 1 = ⊤) +variable [∀ i, (H.level i).Normal] +variable (s : ℕ) (hs : H.level (s+1) = ⊥) +variable (q : ℕ → ℕ) (hqbound : ∀ k, q k ≤ t+d) +variable (hq : ∀ k (g : G), g ∈ H.level k ↔ ∀ i : Fin (t+d), i.val < q k → c.coord g i = 0) +variable (Γ : Subgroup G) (hΓ : ∀ g : G, g ∈ Γ ↔ ∀ i, ∃ z : ℤ, c.coord g i = z) +variable [MeasurableSpace (G⧸Γ)] +variable [hBorel : @BorelSpace (G⧸Γ) (QuotientGroup.instTopologicalSpace Γ) inferInstance] +variable [mtr : MetricSpace (G⧸Γ)] +variable (htop : mtr.toUniformSpace.toTopologicalSpace = QuotientGroup.instTopologicalSpace Γ) +local instance : TopologicalSpace (G⧸Γ) := mtr.toUniformSpace.toTopologicalSpace + +include hsk h0 h1 hs hqbound hq hΓ htop in + + +theorem common_character_from_discrepancies + (μ : Measure (G⧸Γ)) [IsProbabilityMeasure μ] [SMulInvariantMeasure G (G⧸Γ) μ] + (v : ℕ) (c₀ C₀ : ℝ) (B : NNReal) (η : ℝ) + (hc₀ : 00) 1) + (fun x=>F n (QuotientGroup.mk (f (Fin.cons (n.val:ℤ) x)))) - + mean (physicalResidueBox (lo n) (hi n) (res n) (k n)) + (fun x=>F n (QuotientGroup.mk (f (Fin.cons (n.val:ℤ) x))))‖) → + ∃ a b : ℕ, 0(θ I).eval (z:ℝ)) (fun i=>(x i:ℝ)) = + (ξ (f (Fin.cons ((a:ℤ)+(b:ℤ)*z) x))).toAdd) ∧ + ∀ j : Fin (Hlen+1),∃ p : ℕ,∃ u : Fin v → ℤ, + (p=1 ∨ p=k (progressionIndex a b hbound j)) ∧ + (∀ i,0≤u i ∧ u i(θ I).eval (j.val:ℝ)) u) I) + ≤ A*((p:ℝ)/Z)^totalDegree I := by + classical + let : CompactSpace (G⧸Γ) := metric_compact c Γ hΓ mtr htop + let : BorelSpace (G⧸Γ) := metric_borelSpace Γ mtr htop + obtain ⟨U,A,T,hA,hT,hprod⟩ := discrepancy_character c hsk H h0 h1 s hs q hqbound hq Γ hΓ htop + μ v c₀ C₀ B η hc₀ hC₀ hB hη + refine ⟨U,A,T,hA,hT,?_⟩ + intro Hlen + obtain ⟨N,hN⟩ := ConstantCoefficientRationalization.finite_van_der_waerden (Fintype.card U) Hlen + refine ⟨N,?_⟩ + intro Z k hk hscale f hf lo hi res F hside hbox hF hbad + have hex (n : Fin (N+1)) := hprod Z (k n) (hk n) (hscale n) (lo n) (hi n) (res n) + (hside n) (hbox n) (fun x=>f (Fin.cons (n.val:ℤ) x)) (fibre_polynomial H hf (n.val:ℤ)) + ⟨F n,(hF n).1,(hF n).2,hbad n⟩ + choose p u hp hu ξ hξ hobs using hex + let χ : Fin (N+1) → U := fun n=>⟨ξ n,hξ n⟩ + let e := Fintype.equivFin U + obtain ⟨a,b,hb,hbound,hmono⟩ := hN (fun n=>e (χ n)) + let n₀ : Fin (N+1) := ⟨a,Nat.lt_succ_of_le ((Nat.le_add_right _ _).trans hbound)⟩ + have hcommon (j : Fin (Hlen+1)) : ξ (progressionIndex a b hbound j)=ξ n₀ := by + exact congrArg Subtype.val (e.injective (hmono j)) + obtain ⟨θ,hθdeg,hθ⟩ := joint_character_coefficients H s hs hf (ξ n₀) + let θ' : PolynomialLineCoefficients.Grid v s → ℝ[X] := + fun I=>(θ I).comp (C (a:ℝ)+C (b:ℝ)*X) + have hθ'deg (I) : (θ' I).natDegree ≤ s := by + have hlin : (C (a:ℝ)+C (b:ℝ)*X).natDegree ≤ 1 := + natDegree_add_le_of_degree_le (by simp) ((natDegree_C_mul_le _ _).trans (by simp)) + exact natDegree_comp_le.trans ((Nat.mul_le_mul_left _ hlin).trans (by simpa using hθdeg I)) + have heval (z : ℤ) (I) : (θ' I).eval (z:ℝ)=(θ I).eval (((a:ℤ)+(b:ℤ)*z):ℝ) := by + simp [θ'] + refine ⟨a,b,hb,hbound,ξ n₀,hξ n₀,(hobs n₀).1,(hobs n₀).2.1,(hobs n₀).2.2.1, + θ',hθ'deg,?_,?_⟩ + · intro z x + simp only [heval] + simpa only [Int.cast_add, Int.cast_mul] using hθ ((a:ℤ)+(b:ℤ)*z) x + · intro j + let n := progressionIndex a b hbound j + refine ⟨p n,u n,hp n,hu n,?_⟩ + have hobs' : CharacterObstruction (s:=s) Γ (fun x=>f (Fin.cons (n.val:ℤ) x)) + (ξ n₀) (u n) (p n) Z A := by + simpa only [n,hcommon j] using hobs n + apply obstruction_on_coefficients hobs' (fun I=>(θ' I).eval (j.val:ℝ)) + intro x + have he (I) : (θ' I).eval (j.val:ℝ)=(θ I).eval (n.val:ℝ) := by + simp only [θ',eval_comp,eval_add,eval_C,eval_mul,eval_X,n,progressionIndex_val, + Nat.cast_add,Nat.cast_mul] + simp only [he] + exact hθ (n.val:ℤ) x + +end Nilmanifold +end RoughCharacterThinning + +end + +end + +section + + + + +open _root_.Polynomial _root_.OAI.Polynomial Finset +open scoped BigOperators + +namespace LagrangeBounds + +variable {ι : Type*} [DecidableEq ι] + + +def nodes (N q : ℕ) (i : Fin (q + 1)) : ℤ := (N / q : ℕ) * i.val + +lemma nodes_mem {N q : ℕ} (i : Fin (q + 1)) : + (nodes N q i : ℝ) ∈ Set.Icc 0 (N : ℝ) := by + have hv : N / q * i.val ≤ N := + (Nat.mul_le_mul_left _ (by omega : i.val ≤ q)).trans (Nat.div_mul_le_self N q) + constructor + · simp only [nodes, Int.cast_mul, Int.cast_natCast]; positivity + · simp only [nodes, Int.cast_mul, Int.cast_natCast] + exact_mod_cast hv + +lemma nodes_separated {N q : ℕ} (hq : 0 < q) (hN : 2 * q ≤ N) + (i j : Fin (q + 1)) (hji : j ≠ i) : + (N : ℝ) / (2 * q) ≤ |(nodes N q i : ℝ) - nodes N q j| := by + have hd : 1 ≤ N / q := (Nat.le_div_iff_mul_le hq).mpr (by omega) + have hbound : N ≤ 2 * (N / q * q) := by + have := Nat.lt_mul_div_succ N hq + nlinarith + have hbound' : (N : ℝ) / (2 * q) ≤ (N / q : ℕ) := by + apply (div_le_iff₀ (by positivity : (0 : ℝ) < 2 * q)).mpr + exact_mod_cast (show N ≤ N / q * (2 * q) by nlinarith [hbound]) + have hdiff : (1 : ℝ) ≤ |(i.val : ℝ) - j.val| := by + have hne : i.val ≠ j.val := fun h => hji (Fin.ext h.symm) + rcases lt_or_gt_of_ne hne with hij | hij + · have hh : i.val + 1 ≤ j.val := hij + have hh' : (i.val : ℝ) + 1 ≤ j.val := by exact_mod_cast hh + rw [abs_of_nonpos (by linarith)] + linarith + · have hh : j.val + 1 ≤ i.val := hij + have hh' : (j.val : ℝ) + 1 ≤ i.val := by exact_mod_cast hh + rw [abs_of_nonneg (by linarith)] + linarith + simp only [nodes, Int.cast_mul, Int.cast_natCast, ← mul_sub, abs_mul, + abs_of_nonneg (show (0 : ℝ) ≤ (N / q : ℕ) by positivity)] + exact hbound'.trans (by nlinarith [show (0 : ℝ) ≤ (N / q : ℕ) by positivity]) + +lemma nodes_injective {N q : ℕ} (hq : 0 < q) (hN : 2 * q ≤ N) : + Function.Injective (fun i => (nodes N q i : ℝ)) := by + intro i j hij + by_contra hne + have hh := nodes_separated hq hN i j (Ne.symm hne) + change (nodes N q i : ℝ) = nodes N q j at hij + rw [hij, sub_self, abs_zero] at hh + have : (0 : ℝ) < (N : ℝ) / (2 * q) := by + have hN' : 0 < N := by omega + positivity + linarith + + +theorem uniform_integer_interpolation {N q : ℕ} (hq : 0 < q) (hN : 2 * q ≤ N) + (T : ℝ[X]) (hT : T.natDegree ≤ q) (r : Fin (q + 1) → ℝ) + {ε : ℝ} (hε : 0 ≤ ε) + (hr : ∀ i, |r i - T.eval (nodes N q i : ℝ)| ≤ ε) + {x : ℝ} (hx : x ∈ Set.Icc 0 (N : ℝ)) : + |(Lagrange.interpolate univ (fun i => (nodes N q i : ℝ)) r).eval x - T.eval x| ≤ + (q + 1 : ℝ) * (2 * q) ^ q * ε := by + have hNpos : 0 < N := by omega + have hdeg : T.degree < ((univ : Finset (Fin (q + 1))).card : WithBot ℕ) := by + simp only [card_univ, Fintype.card_fin] + exact lt_of_le_of_lt (degree_le_natDegree.trans (show (T.natDegree : WithBot ℕ) ≤ (q : WithBot ℕ) by exact_mod_cast hT)) + (by exact_mod_cast Nat.lt_succ_self q) + have h := interpolate_error univ (fun i => (nodes N q i : ℝ)) + (nodes_injective hq hN).injOn + (by positivity : (0 : ℝ) < (N : ℝ) / (2 * q)) hε + (fun i _ => nodes_mem i) + (fun i _ j _ hji => nodes_separated hq hN i j hji) hx T hdeg r (fun i _ => hr i) + have heq : ((N : ℝ) - 0) / ((N : ℝ) / (2 * q)) = 2 * q := by + rw [sub_zero] + field_simp + rw [heq] at h + simpa only [card_univ, Fintype.card_fin, Nat.cast_add, Nat.cast_one, + Nat.add_sub_cancel] using h + +def coefficientBound (p : ℝ[X]) (q : ℕ) : ℝ := + ∑ k ∈ range (q + 1), |p.coeff k| + +lemma coefficientBound_nonneg (p : ℝ[X]) (q : ℕ) : 0 ≤ coefficientBound p q := by + exact sum_nonneg (fun _ _ => abs_nonneg _) + +lemma polynomial_growth (p : ℝ[X]) {q : ℕ} (hq : p.natDegree ≤ q) (x : ℝ) : + |p.eval x| ≤ coefficientBound p q * (1 + |x|) ^ q := by + rw [eval_eq_sum_range' (Nat.lt_succ_of_le hq)] + calc + |∑ k ∈ range (q + 1), p.coeff k * x ^ k| ≤ + ∑ k ∈ range (q + 1), |p.coeff k| * (1 + |x|) ^ q := by + apply (abs_sum_le_sum_abs _ _).trans + apply sum_le_sum + intro k hk + rw [abs_mul, abs_pow] + apply mul_le_mul_of_nonneg_left _ (abs_nonneg _) + exact (pow_le_pow_left₀ (abs_nonneg x) (by linarith) k).trans + (pow_le_pow_right₀ (by linarith [abs_nonneg x]) (by simpa using mem_range.mp hk)) + _ = _ := by rw [coefficientBound, sum_mul] + + +theorem derivative_interpolation_error (s : Finset ι) (v : ι → ℝ) + (hv : Set.InjOn v s) {q : ℕ} (hcard : s.card - 1 ≤ q) + (T : ℝ[X]) (hT : T.degree < s.card) (r : ι → ℝ) + {ε : ℝ} (hε : 0 ≤ ε) (hr : ∀ i ∈ s, |r i - T.eval (v i)| ≤ ε) + (j : ℕ) (x : ℝ) : + |(derivative^[j] (Lagrange.interpolate s v r - T)).eval x| ≤ + ε * (∑ i ∈ s, coefficientBound (derivative^[j] (Lagrange.basis s v i)) q) * + (1 + |x|) ^ q := by + have heq := Lagrange.eq_interpolate hv hT + have hinterp : Lagrange.interpolate s v r - T = + Lagrange.interpolate s v (fun i => r i - T.eval (v i)) := by + conv_lhs => rw [heq] + exact (map_sub (Lagrange.interpolate s v) _ _).symm + rw [hinterp, Lagrange.interpolate_apply, iterate_derivative_sum, eval_finsetSum] + calc + |∑ i ∈ s, eval x (derivative^[j] (C (r i - T.eval (v i)) * Lagrange.basis s v i))| ≤ + ∑ i ∈ s, ε * coefficientBound (derivative^[j] (Lagrange.basis s v i)) q * + (1 + |x|) ^ q := by + apply (abs_sum_le_sum_abs _ _).trans + apply sum_le_sum + intro i hi + rw [iterate_derivative_C_mul, eval_mul, eval_C, abs_mul] + exact (mul_le_mul (hr i hi) + (polynomial_growth _ ((natDegree_iterate_derivative _ _).trans + ((Nat.sub_le _ _).trans (by rw [Lagrange.natDegree_basis hv hi]; exact hcard))) x) + (abs_nonneg _) hε).trans_eq (mul_assoc _ _ _).symm + _ = _ := by rw [← sum_mul, ← mul_sum] + +end LagrangeBounds + + + +end +end + +end OAI diff --git a/lean/OAI/Combinatorics/SumProduct/Alignment/LeibmanSquare01.lean b/lean/OAI/Combinatorics/SumProduct/Alignment/LeibmanSquare01.lean new file mode 100644 index 0000000000000000000000000000000000000000..60a828e85f74c730878b970ced5ccd45aff7f6a6 --- /dev/null +++ b/lean/OAI/Combinatorics/SumProduct/Alignment/LeibmanSquare01.lean @@ -0,0 +1,427 @@ +import Mathlib +import OAI.Geometry.NilpotentCharts.Coordinates +import OAI.Geometry.NilpotentCharts.Main + +namespace OAI + +section +section +section +section +open scoped commutatorElement +namespace LeibmanSquare +open CubeFaces +variable {G : Type*} [Group G] + +lemma level_normal (H : Filtration G) (h0 : H.level 0 = ⊤) (i : ℕ) : + (H.level i).Normal where + conj_mem x hx g := by + have hg : g ∈ H.level 0 := by rw [h0]; trivial + have hc := H.commutator_le 0 i (Subgroup.commutator_mem_commutator hg hx) + simp only [zero_add] at hc + have := (H.level i).mul_mem hc hx + simpa [commutatorElement_def, mul_assoc] using this + + +def level (H : Filtration G) (h0 : H.level 0 = ⊤) (i : ℕ) : Subgroup (G × G) where + carrier := {x | x.1 ∈ H.level i ∧ x.2 ∈ H.level i ∧ x.1⁻¹*x.2 ∈ H.level (i+1)} + one_mem' := by simp + mul_mem' := by + rintro a b ⟨ha,hb,hab⟩ ⟨hc,hd,hcd⟩ + refine ⟨(H.level i).mul_mem ha hc, (H.level i).mul_mem hb hd, ?_⟩ + have hh := (level_normal H h0 (i+1)).conj_mem _ hab b.1⁻¹ + have hmul := (H.level (i+1)).mul_mem hh hcd + simpa [mul_assoc] using hmul + inv_mem' := by + rintro a ⟨ha,hb,hab⟩ + refine ⟨(H.level i).inv_mem ha, (H.level i).inv_mem hb, ?_⟩ + have hh := (level_normal H h0 (i+1)).conj_mem _ + ((H.level (i+1)).inv_mem hab) a.1 + simpa [mul_assoc] using hh + +lemma mem_level (H : Filtration G) (h0 : H.level 0 = ⊤) (i : ℕ) (x : G × G) : + x ∈ level H h0 i ↔ x.1 ∈ H.level i ∧ x.2 ∈ H.level i ∧ + x.1⁻¹*x.2 ∈ H.level (i+1) := Iff.rfl + +lemma level_antitone (H : Filtration G) (h0 : H.level 0 = ⊤) : + Antitone (level H h0) := by + intro i j hij x ⟨ha,hb,hab⟩ + exact ⟨H.antitone hij ha,H.antitone hij hb,H.antitone (by omega) hab⟩ + +lemma commutator_mem_level (H : Filtration G) (h0 : H.level 0 = ⊤) + (i j : ℕ) {x y : G × G} (hx : x ∈ level H h0 i) (hy : y ∈ level H h0 j) : + ⁅x,y⁆ ∈ level H h0 (i+j) := by + rcases hx with ⟨hx1,hx2,hxd⟩ + rcases hy with ⟨hy1,hy2,hyd⟩ + refine ⟨H.commutator_le _ _ (Subgroup.commutator_mem_commutator hx1 hy1), + H.commutator_le _ _ (Subgroup.commutator_mem_commutator hx2 hy2), ?_⟩ + let N := H.level (i+j+1) + let : N.Normal := level_normal H h0 _ + let q : G →* G ⧸ N := QuotientGroup.mk' N + have qx : q ⁅x.1⁻¹*x.2,y.2⁆ = 1 := by + apply (QuotientGroup.eq_one_iff _).mpr + exact H.antitone (by omega) (H.commutator_le _ _ + (Subgroup.commutator_mem_commutator hxd hy2)) + have qy : q ⁅x.1,y.1⁻¹*y.2⁆ = 1 := by + apply (QuotientGroup.eq_one_iff _).mpr + exact H.antitone (by omega) (H.commutator_le _ _ + (Subgroup.commutator_mem_commutator hx1 hyd)) + have he : q ⁅x.2,y.2⁆ = q ⁅x.1,y.1⁆ := by + calc + _ = q ⁅x.1*(x.1⁻¹*x.2),y.2⁆ := by simp + _ = q ⁅x.1,y.2⁆ := by + rw [commutatorElement_mul_left_eq_conj_mul] + simp only [map_mul,map_inv,qx,mul_one,mul_inv_cancel,one_mul] + _ = q ⁅x.1,y.1*(y.1⁻¹*y.2)⁆ := by simp + _ = q ⁅x.1,y.1⁆ := by + rw [commutatorElement_mul_right_eq_mul_conj] + simp [map_mul,map_inv,qy,mul_assoc] + change ⁅x.1,y.1⁆⁻¹*⁅x.2,y.2⁆ ∈ N + apply (QuotientGroup.eq_one_iff _).mp + change q (⁅x.1,y.1⁆⁻¹*⁅x.2,y.2⁆) = 1 + rw [map_mul,map_inv,he,inv_mul_cancel] + + +def filtration (H : Filtration G) (h0 : H.level 0 = ⊤) : Filtration (G × G) where + level := level H h0 + antitone := level_antitone H h0 + commutator_le i j := Subgroup.commutator_le.mpr fun _ hx _ hy => + commutator_mem_level H h0 i j hx hy + +lemma level_zero (H : Filtration G) (h0 : H.level 0 = ⊤) (h1 : H.level 1 = ⊤) : + level H h0 0 = ⊤ := by + ext x + simp [mem_level,h0,h1] + + +lemma last_level (H : Filtration G) (h0 : H.level 0 = ⊤) (s : ℕ) + (hs : H.level (s+1) = ⊥) (x : G × G) : + x ∈ level H h0 s ↔ x.1 ∈ H.level s ∧ x.1 = x.2 := by + rw [mem_level,hs] + simp only [Subgroup.mem_bot,inv_mul_eq_one] + constructor + · tauto + · rintro ⟨hx,he⟩ + exact ⟨hx,he ▸ hx,he⟩ + + +lemma last_central (H : Filtration G) (h0 : H.level 0 = ⊤) (s : ℕ) + (hs : H.level (s+1) = ⊥) {x y : G × G} + (hx : x ∈ level H h0 1) (hy : y ∈ level H h0 s) : Commute x y := by + apply commutatorElement_eq_one_iff_commute.mp + have hh := commutator_mem_level H h0 1 s hx hy + have hbot : level H h0 (1+s) = ⊥ := by + apply le_antisymm _ bot_le + intro z ⟨hz1,hz2,_⟩ + have hz1' : z.1 = 1 := by simpa [Nat.add_comm,hs] using hz1 + have hz2' : z.2 = 1 := by simpa [Nat.add_comm,hs] using hz2 + exact Prod.ext hz1' hz2' + simpa [hbot] using hh + + +def restricted (H : Filtration G) (h0 : H.level 0 = ⊤) : + Filtration (level H h0 1) where + level i := (level H h0 (max 1 i)).comap (level H h0 1).subtype + antitone := by + intro i j hij + exact Subgroup.comap_mono (level_antitone H h0 (max_le_max_left 1 hij)) + commutator_le i j := by + apply Subgroup.commutator_le.mpr + intro x hx y hy + change (↑⁅x,y⁆ : G × G) ∈ level H h0 (max 1 (i+j)) + have hc := commutator_mem_level H h0 (max 1 i) (max 1 j) hx hy + exact level_antitone H h0 (by omega) hc + +lemma restricted_zero (H : Filtration G) (h0 : H.level 0 = ⊤) : + (restricted H h0).level 0 = ⊤ := by + ext x + simp only [restricted, max_eq_left (by omega : 0 ≤ 1), Subgroup.mem_comap, + Subgroup.coe_subtype, Subgroup.mem_top, iff_true] + exact x.property + +lemma restricted_one (H : Filtration G) (h0 : H.level 0 = ⊤) : + (restricted H h0).level 1 = ⊤ := by + ext x + simp only [restricted, max_self, Subgroup.mem_comap, + Subgroup.coe_subtype, Subgroup.mem_top, iff_true] + exact x.property + + + +lemma last_normal (H : Filtration G) (h0 : H.level 0 = ⊤) + {s : ℕ} (hs0 : 1 ≤ s) (hs : H.level (s+1) = ⊥) : + ((restricted H h0).level s).Normal where + conj_mem x hx y := by + change (↑(y*x*y⁻¹) : G × G) ∈ level H h0 (max 1 s) + change (x : G × G) ∈ level H h0 (max 1 s) at hx + rw [max_eq_right hs0] at hx ⊢ + have hc := last_central H h0 s hs y.property hx + change (y : G × G) * x * (y : G × G)⁻¹ ∈ _ + rw [hc.eq, mul_assoc, mul_inv_cancel, mul_one] + exact hx + + +def mapFiltration {K : Type*} [Group K] (H : Filtration G) (φ : G →* K) : + Filtration K where + level i := (H.level i).map φ + antitone := by + intro i j hij + exact Subgroup.map_mono (H.antitone hij) + commutator_le i j := by + rw [← Subgroup.map_commutator] + exact Subgroup.map_mono (H.commutator_le i j) + + + +theorem quotient_lowers_degree (H : Filtration G) (h0 : H.level 0 = ⊤) + {s : ℕ} (hs0 : 1 ≤ s) (hs : H.level (s+1) = ⊥) : + let R := restricted H h0 + letI := last_normal H h0 hs0 hs + let Q := mapFiltration R (QuotientGroup.mk' (R.level s)) + Q.level 0 = ⊤ ∧ Q.level 1 = ⊤ ∧ Q.level s = ⊥ := by + let : ((restricted H h0).level s).Normal := last_normal H h0 hs0 hs + dsimp only + constructor + · change ((restricted H h0).level 0).map _ = _ + rw [restricted_zero, Subgroup.map_top_of_surjective _ (QuotientGroup.mk'_surjective _)] + constructor + · change ((restricted H h0).level 1).map _ = _ + rw [restricted_one, Subgroup.map_top_of_surjective _ (QuotientGroup.mk'_surjective _)] + · change ((restricted H h0).level s).map _ = _ + rw [Subgroup.map_eq_bot_iff, QuotientGroup.ker_mk'] + + + +def pairConj (a b : G) : (G × G) ≃* (G × G) := + (MulAut.conj a).prodCongr (MulAut.conj b) + +lemma conjugate_mod_next (H : Filtration G) (h0 : H.level 0 = ⊤) + (h1 : H.level 1 = ⊤) (i : ℕ) {x : G} (hx : x ∈ H.level i) (a : G) : + x⁻¹*(a*x*a⁻¹) ∈ H.level (i+1) := by + have ha : a ∈ H.level 1 := by rw [h1]; trivial + have hc := H.commutator_le 1 i (Subgroup.commutator_mem_commutator ha hx) + have hc' : ⁅a,x⁆ ∈ H.level (i+1) := by simpa [Nat.add_comm] using hc + have hh := (level_normal H h0 (i+1)).conj_mem _ hc' x⁻¹ + simpa [commutatorElement_def,mul_assoc] using hh + +lemma pairConj_mem (H : Filtration G) (h0 : H.level 0 = ⊤) + (h1 : H.level 1 = ⊤) (i : ℕ) (a b : G) {x : G × G} + (hx : x ∈ level H h0 i) : pairConj a b x ∈ level H h0 i := by + rcases hx with ⟨hx1,hx2,hxd⟩ + refine ⟨(level_normal H h0 i).conj_mem _ hx1 a, + (level_normal H h0 i).conj_mem _ hx2 b,?_⟩ + have ha := conjugate_mod_next H h0 h1 i hx1 a + have hb := conjugate_mod_next H h0 h1 i hx2 b + have hh := (H.level (i+1)).mul_mem + ((H.level (i+1)).mul_mem ((H.level (i+1)).inv_mem ha) hxd) hb + change (a*x.1*a⁻¹)⁻¹*(b*x.2*b⁻¹) ∈ H.level (i+1) + simpa only [mul_inv_rev,inv_inv,mul_assoc,inv_mul_cancel_left, + mul_inv_cancel_left] using hh + +lemma pairConj_last_fixed (H : Filtration G) (h0 : H.level 0 = ⊤) + (h1 : H.level 1 = ⊤) (s : ℕ) (hs : H.level (s+1) = ⊥) + (a b : G) {x : G × G} (hx : x ∈ level H h0 s) : pairConj a b x = x := by + have ha := conjugate_mod_next H h0 h1 s hx.1 a + have hb := conjugate_mod_next H h0 h1 s hx.2.1 b + have he1 : a*x.1*a⁻¹ = x.1 := by + symm + simpa only [hs,Subgroup.mem_bot,inv_mul_eq_one] using ha + have he2 : b*x.2*b⁻¹ = x.2 := by + symm + simpa only [hs,Subgroup.mem_bot,inv_mul_eq_one] using hb + exact Prod.ext he1 he2 + + + +lemma pairConj_lattice (Γ : Subgroup G) {a b : G} (ha : a ∈ Γ) (hb : b ∈ Γ) + {x : G × G} (hx : x ∈ Γ.prod Γ) : pairConj a b x ∈ Γ.prod Γ := + ⟨Γ.mul_mem (Γ.mul_mem ha hx.1) (Γ.inv_mem ha), + Γ.mul_mem (Γ.mul_mem hb hx.2) (Γ.inv_mem hb)⟩ + + + +lemma orbit_normalization (Γ : Subgroup G) {a u γ : G} + (ha : a = u*γ) (hγ : γ ∈ Γ) (x : G) : + (QuotientGroup.mk (u * MulAut.conj γ (a⁻¹*x)) : G ⧸ Γ) = + QuotientGroup.mk x := by + subst a + have he : u * MulAut.conj γ ((u*γ)⁻¹*x) = x*γ⁻¹ := by + simp [MulAut.conj_apply,mul_assoc] + rw [he] + exact QuotientGroup.mk_mul_of_mem x (Γ.inv_mem hγ) + +variable {A : Type*} [AddCommGroup A] + + +def diff (h : A) (f : A → G) (n : A) : G := (f n)⁻¹*f (n+h) + +def iterDiff : List A → (A → G) → (A → G) + | [], f => f + | h::hs, f => iterDiff hs (diff h f) + + + +def Polynomial (H : Filtration G) (k : ℕ) (f : A → G) : Prop := + ∀ hs n, iterDiff hs f n ∈ H.level (k+hs.length) + +lemma iterDiff_append (hs ts : List A) (f : A → G) : + iterDiff (hs++ts) f = iterDiff ts (iterDiff hs f) := by + induction hs generalizing f with + | nil => rfl + | cons h hs ih => exact ih _ + +lemma iterDiff_shift (hs : List A) (f : A → G) (t : A) : + iterDiff hs (fun n => f (n+t)) = fun n => iterDiff hs f (n+t) := by + induction hs generalizing f with + | nil => rfl + | cons h hs ih => + change iterDiff hs (diff h (fun n => f (n+t))) = _ + have he : diff h (fun n => f (n+t)) = fun n => diff h f (n+t) := by + funext n + simp only [diff] + congr 2; abel + rw [he,ih] + rfl + +lemma iterDiff_hom {K : Type*} [Group K] (φ : G →* K) (hs : List A) (f : A → G) : + iterDiff hs (fun n => φ (f n)) = fun n => φ (iterDiff hs f n) := by + induction hs generalizing f with + | nil => rfl + | cons h hs ih => + change iterDiff hs (diff h (fun n => φ (f n))) = _ + have he : diff h (fun n => φ (f n)) = fun n => φ (diff h f n) := by + funext n + simp [diff] + rw [he,ih] + rfl + +lemma iterDiff_pair {K : Type*} [Group K] (hs : List A) (f : A → G) (g : A → K) : + iterDiff hs (fun n => (f n,g n)) = fun n => (iterDiff hs f n,iterDiff hs g n) := by + induction hs generalizing f g with + | nil => rfl + | cons h hs ih => exact ih (diff h f) (diff h g) + + + +theorem polynomial_pair (H : Filtration G) (h0 : H.level 0 = ⊤) + {k : ℕ} {f : A → G} (hf : Polynomial H k f) (t : A) : + Polynomial (filtration H h0) k (fun n => (f n,f (n+t))) := by + intro hs n + rw [iterDiff_pair,iterDiff_shift] + refine ⟨hf hs n,hf hs (n+t),?_⟩ + have hh := hf (hs++[t]) n + rw [iterDiff_append] at hh + simpa [iterDiff,diff,List.length_append,Nat.add_assoc] using hh + +lemma iterDiff_left_mul (hs : List A) (hne : hs ≠ []) (a : G) (f : A → G) : + iterDiff hs (fun n => a*f n) = iterDiff hs f := by + obtain ⟨h,ts,rfl⟩ := List.exists_cons_of_ne_nil hne + change iterDiff ts (diff h (fun n => a*f n)) = _ + have he : diff h (fun n => a*f n) = diff h f := by + funext n + simp [diff,mul_assoc] + rw [he] + rfl + + + +def normalizedPair (H : Filtration G) (h0 : H.level 0 = ⊤) + {f : A → G} (hf : Polynomial H 0 f) (t : A) : A → level H h0 1 := fun n => + ⟨(f 0,f t)⁻¹*(f n,f (n+t)), by + have hh := polynomial_pair H h0 hf t [n] 0 + simpa [iterDiff,diff,filtration] using hh⟩ + + +theorem normalizedPair_polynomial (H : Filtration G) (h0 : H.level 0 = ⊤) + {f : A → G} (hf : Polynomial H 0 f) (t : A) : + Polynomial (restricted H h0) 0 (normalizedPair H h0 hf t) := by + intro hs n + by_cases he : hs = [] + · subst hs + rw [List.length_nil,add_zero,restricted_zero] + trivial + · have hh := polynomial_pair H h0 hf t hs n + change (↑(iterDiff hs (normalizedPair H h0 hf t) n) : G × G) ∈ + level H h0 (max 1 (0+hs.length)) + have hv := congrFun (iterDiff_hom (level H h0 1).subtype hs + (normalizedPair H h0 hf t)) n + simp only [Subgroup.coe_subtype] at hv + rw [← hv] + change iterDiff hs (fun n => (f 0,f t)⁻¹*(f n,f (n+t))) n ∈ _ + rw [iterDiff_left_mul hs he] + have hlen : 1 ≤ hs.length := Nat.succ_le_of_lt (List.length_pos_iff.mpr he) + simpa only [zero_add, max_eq_right hlen,filtration] using hh + +lemma polynomial_map {K : Type*} [Group K] (H : Filtration G) (φ : G →* K) + {k : ℕ} {f : A → G} (hf : Polynomial H k f) : + Polynomial (mapFiltration H φ) k (fun n => φ (f n)) := by + intro hs n + rw [iterDiff_hom] + exact ⟨iterDiff hs f n,hf hs n,rfl⟩ + + +lemma polynomial_filtered_map {K : Type*} [Group K] (H : Filtration G) + (J : Filtration K) (φ : G →* K) + (hφ : ∀ i, (H.level i).map φ ≤ J.level i) + {k : ℕ} {f : A → G} (hf : Polynomial H k f) : + Polynomial J k (fun n => φ (f n)) := by + intro hs n + rw [iterDiff_hom] + exact hφ _ ⟨iterDiff hs f n,hf hs n,rfl⟩ + + +def restrictedConj (H : Filtration G) (h0 : H.level 0 = ⊤) + (h1 : H.level 1 = ⊤) (a b : G) : level H h0 1 →* level H h0 1 := + ((pairConj a b).toMonoidHom.comp (level H h0 1).subtype).codRestrict _ + (fun x => pairConj_mem H h0 h1 1 a b x.property) + +lemma restrictedConj_filtered (H : Filtration G) (h0 : H.level 0 = ⊤) + (h1 : H.level 1 = ⊤) (a b : G) (i : ℕ) : + ((restricted H h0).level i).map (restrictedConj H h0 h1 a b) ≤ + (restricted H h0).level i := by + rintro _ ⟨x,hx,rfl⟩ + exact pairConj_mem H h0 h1 (max 1 i) a b hx + + + +theorem normalized_conjugate_polynomial (H : Filtration G) (h0 : H.level 0 = ⊤) + (h1 : H.level 1 = ⊤) {f : A → G} (hf : Polynomial H 0 f) (t : A) (a b : G) : + Polynomial (restricted H h0) 0 + (fun n => restrictedConj H h0 h1 a b (normalizedPair H h0 hf t n)) := + polynomial_filtered_map _ _ _ (restrictedConj_filtered H h0 h1 a b) + (normalizedPair_polynomial H h0 hf t) + + + +theorem reduced_pair_polynomial (H : Filtration G) (h0 : H.level 0 = ⊤) + (h1 : H.level 1 = ⊤) {s : ℕ} (hs0 : 1 ≤ s) (hs : H.level (s+1) = ⊥) + {f : A → G} (hf : Polynomial H 0 f) (t : A) (a b : G) : + let R := restricted H h0 + letI := last_normal H h0 hs0 hs + let π := QuotientGroup.mk' (R.level s) + let Q := mapFiltration R π + let p := fun n => π (restrictedConj H h0 h1 a b (normalizedPair H h0 hf t n)) + Polynomial Q 0 p ∧ ∀ hs' : List A, s ≤ hs'.length → ∀ n, iterDiff hs' p n = 1 := by + let : ((restricted H h0).level s).Normal := last_normal H h0 hs0 hs + dsimp only + have hp := polynomial_map (restricted H h0) (QuotientGroup.mk' ((restricted H h0).level s)) + (normalized_conjugate_polynomial H h0 h1 hf t a b) + refine ⟨hp,?_⟩ + intro ts hts n + have hh := hp ts n + have hz : (mapFiltration (restricted H h0) + (QuotientGroup.mk' ((restricted H h0).level s))).level s = ⊥ := + (quotient_lowers_degree H h0 hs0 hs).2.2 + have hmem := (mapFiltration (restricted H h0) + (QuotientGroup.mk' ((restricted H h0).level s))).antitone + (by omega : s ≤ 0+ts.length) hh + simpa only [hz,Subgroup.mem_bot] using hmem + +end LeibmanSquare + +end +end +end +end + +end OAI diff --git a/lean/OAI/Combinatorics/SumProduct/Alignment/LeibmanSquare02.lean b/lean/OAI/Combinatorics/SumProduct/Alignment/LeibmanSquare02.lean new file mode 100644 index 0000000000000000000000000000000000000000..7746f1ad07e2bdcd3f22d91b90235778c8ab47e6 --- /dev/null +++ b/lean/OAI/Combinatorics/SumProduct/Alignment/LeibmanSquare02.lean @@ -0,0 +1,347 @@ +import Mathlib +import OAI.Combinatorics.SumProduct.Alignment.LeibmanSquare01 +import OAI.Combinatorics.SumProduct.Alignment.PairTail03 +import OAI.Geometry.NilpotentCharts.Main + +namespace OAI + +section +section +section +section +open scoped commutatorElement + +end + + + +section +noncomputable section +namespace LeibmanSquare +open CubeFaces RationalLattice +variable {G : Type*} [Group G] [TopologicalSpace G] [IsTopologicalGroup G] +variable (H : Filtration G) (h0 : H.level 0 = ⊤) (h1 : H.level 1 = ⊤) +variable [∀ i, (H.level i).Normal] + +include h1 in +omit [TopologicalSpace G] [IsTopologicalGroup G] in +lemma first_eq_pairTail : level H h0 1 = PairTail.square (H.level 2) := by + ext x + change (x.1 ∈ H.level 1 ∧ x.2 ∈ H.level 1 ∧ x.1⁻¹*x.2 ∈ H.level (1+1)) ↔ _ + simp only [h1,Subgroup.mem_top,true_and] + rfl + +def firstPairEquiv : level H h0 1 ≃* PairTail.square (H.level 2) := + MulEquiv.subgroupCongr (first_eq_pairTail H h0 h1) + +omit [TopologicalSpace G] [IsTopologicalGroup G] in +@[simp] lemma firstPairEquiv_val (x : level H h0 1) : + (firstPairEquiv H h0 h1 x).val = x.val := rfl + +omit [IsTopologicalGroup G] in +lemma firstPairEquiv_continuous : Continuous (firstPairEquiv H h0 h1) := + continuous_subtype_val.subtype_mk _ +omit [IsTopologicalGroup G] in +lemma firstPairEquiv_symm_continuous : Continuous (firstPairEquiv H h0 h1).symm := + continuous_subtype_val.subtype_mk _ + +omit [TopologicalSpace G] [IsTopologicalGroup G] in +lemma restricted_map_pairLevel (i : ℕ) : + ((restricted H h0).level i).map (firstPairEquiv H h0 h1).toMonoidHom = + PairTail.pairLevel (H.level 2) (H.level (max 1 i)) (H.level (max 1 i+1)) := by + ext x + constructor + · rintro ⟨y,hy,rfl⟩ + exact ⟨hy.1,hy.2.2⟩ + · rintro ⟨hx,hxy⟩ + change x.val.1 ∈ H.level (max 1 i) at hx + refine ⟨(firstPairEquiv H h0 h1).symm x,?_,(firstPairEquiv H h0 h1).apply_symm_apply x⟩ + change x.val.1 ∈ H.level (max 1 i) ∧ x.val.2 ∈ H.level (max 1 i) ∧ + x.val.1⁻¹*x.val.2 ∈ H.level (max 1 i+1) + refine ⟨hx,?_,hxy⟩ + have hh := (H.level (max 1 i)).mul_mem hx (H.antitone (by omega) hxy) + simpa using hh + +variable (s : ℕ) (hs0 : 1 ≤ s) (hs : H.level (s+1) = ⊥) + +include hs0 hs in +omit [TopologicalSpace G] [IsTopologicalGroup G] in +lemma last_map_diagonal : + ((restricted H h0).level s).map (firstPairEquiv H h0 h1).toMonoidHom = + PairTail.diagonal (H.level 2) (H.level s) := by + ext x + constructor + · rintro ⟨y,hy,rfl⟩ + change (y : G × G) ∈ level H h0 (max 1 s) at hy + rw [max_eq_right hs0] at hy + have hh := (last_level H h0 s hs y.val).mp hy + exact ⟨hh.1,hh.2.symm⟩ + · rintro ⟨hx,he⟩ + refine ⟨(firstPairEquiv H h0 h1).symm x,?_,(firstPairEquiv H h0 h1).apply_symm_apply x⟩ + change x.val ∈ level H h0 (max 1 s) + rw [max_eq_right hs0,last_level H h0 s hs] + exact ⟨hx,he.symm⟩ + +include h1 hs in +omit [TopologicalSpace G] [IsTopologicalGroup G] [∀ levelIndex, (H.level levelIndex).Normal] in +lemma last_central_ambient : H.level s ≤ Subgroup.center G := by + intro x hx + rw [Subgroup.mem_center_iff] + intro y + have hy : y ∈ H.level 1 := by rw [h1]; trivial + have hh := H.commutator_le s 1 (Subgroup.commutator_mem_commutator hx hy) + rw [hs,Subgroup.mem_bot] at hh + exact (commutatorElement_eq_one_iff_commute.mp hh).eq.symm + +variable [((restricted H h0).level s).Normal] +variable [(PairTail.diagonal (H.level 2) (H.level s)).Normal] + + + +def reducedPairEquiv : + ((level H h0 1) ⧸ (restricted H h0).level s) ≃* + (PairTail.square (H.level 2) ⧸ PairTail.diagonal (H.level 2) (H.level s)) := + QuotientGroup.congr _ _ (firstPairEquiv H h0 h1) (last_map_diagonal H h0 h1 s hs0 hs) + +omit [TopologicalSpace G] [IsTopologicalGroup G] in +@[simp] lemma reducedPairEquiv_mk (x : level H h0 1) : + reducedPairEquiv H h0 h1 s hs0 hs (QuotientGroup.mk x) = + QuotientGroup.mk (firstPairEquiv H h0 h1 x) := rfl + +omit [IsTopologicalGroup G] in +lemma reducedPairEquiv_continuous : Continuous (reducedPairEquiv H h0 h1 s hs0 hs) := by + rw [(QuotientGroup.isQuotientMap_mk ((restricted H h0).level s)).continuous_iff] + change Continuous (fun x => QuotientGroup.mk (firstPairEquiv H h0 h1 x)) + exact QuotientGroup.continuous_mk.comp (firstPairEquiv_continuous H h0 h1) + +omit [IsTopologicalGroup G] in +lemma reducedPairEquiv_symm_continuous : Continuous (reducedPairEquiv H h0 h1 s hs0 hs).symm := by + rw [(QuotientGroup.isQuotientMap_mk (PairTail.diagonal (H.level 2) (H.level s))).continuous_iff] + change Continuous (fun x => QuotientGroup.mk ((firstPairEquiv H h0 h1).symm x)) + exact QuotientGroup.continuous_mk.comp (firstPairEquiv_symm_continuous H h0 h1) + +def reducedPairHomeomorph : + ((level H h0 1) ⧸ (restricted H h0).level s) ≃ₜ + (PairTail.square (H.level 2) ⧸ PairTail.diagonal (H.level 2) (H.level s)) where + toEquiv := (reducedPairEquiv H h0 h1 s hs0 hs).toEquiv + continuous_toFun := reducedPairEquiv_continuous H h0 h1 s hs0 hs + continuous_invFun := reducedPairEquiv_symm_continuous H h0 h1 s hs0 hs + +end LeibmanSquare +end +end + + + +section +noncomputable section +namespace RationalLattice +variable {G K : Type*} [Group G] [Group K] [TopologicalSpace G] [TopologicalSpace K] {n : ℕ} + +def pullCoordinates (c : RealCoordinates K n) (e : G ≃* K) + (hc : Continuous e) (hci : Continuous e.symm) : RealCoordinates G n where + coord := ({toEquiv := e.toEquiv, continuous_toFun := hc, continuous_invFun := hci} : G ≃ₜ K).trans c.coord + one_coord i := by change c.coord (e 1) i = 0; rw [map_one,c.one_coord] + correction := c.correction + mul_coord g h i := by + change c.coord (e (g*h)) i = _ + rw [map_mul] + exact c.mul_coord _ _ _ +end RationalLattice + +namespace LeibmanSquare +open CubeFaces RationalLattice PairTail +variable {G : Type*} [Group G] [TopologicalSpace G] [IsTopologicalGroup G] +variable (H : Filtration G) (h0 : H.level 0 = ⊤) (h1 : H.level 1 = ⊤) +variable [∀ i, (H.level i).Normal] +variable (s : ℕ) (hs0 : 1 ≤ s) (hs : H.level (s+1) = ⊥) +variable [((restricted H h0).level s).Normal] +variable [(PairTail.diagonal (H.level 2) (H.level s)).Normal] + +omit [TopologicalSpace G] [IsTopologicalGroup G] in +lemma squareLattice_map (Γ : Subgroup G) : + ((Γ.prod Γ).comap (level H h0 1).subtype).map (firstPairEquiv H h0 h1).toMonoidHom = + PairTail.squareLattice (H.level 2) Γ := by + ext x + constructor + · rintro ⟨y,hy,rfl⟩ + exact hy + · intro hx + exact ⟨(firstPairEquiv H h0 h1).symm x,hx,(firstPairEquiv H h0 h1).apply_symm_apply x⟩ + +omit [TopologicalSpace G] [IsTopologicalGroup G] in +lemma reducedLattice_map (Γ : Subgroup G) : + (((Γ.prod Γ).comap (level H h0 1).subtype).map + (QuotientGroup.mk' ((restricted H h0).level s))).map + (reducedPairEquiv H h0 h1 s hs0 hs).toMonoidHom = + PairTail.reducedLattice (H.level 2) (H.level s) Γ := by + rw [Subgroup.map_map] + have he : (reducedPairEquiv H h0 h1 s hs0 hs).toMonoidHom.comp + (QuotientGroup.mk' ((restricted H h0).level s)) = + (QuotientGroup.mk' (PairTail.diagonal (H.level 2) (H.level s))).comp + (firstPairEquiv H h0 h1).toMonoidHom := by ext x; rfl + rw [he,← Subgroup.map_map,squareLattice_map] + rfl + +omit [TopologicalSpace G] [IsTopologicalGroup G] in +lemma reducedLevel_map (i : ℕ) : + (((restricted H h0).level i).map (QuotientGroup.mk' ((restricted H h0).level s))).map + (reducedPairEquiv H h0 h1 s hs0 hs).toMonoidHom = + PairTail.reducedLevel (H.level 2) (H.level s) + (H.level (max 1 i)) (H.level (max 1 i+1)) := by + rw [Subgroup.map_map] + have he : (reducedPairEquiv H h0 h1 s hs0 hs).toMonoidHom.comp + (QuotientGroup.mk' ((restricted H h0).level s)) = + (QuotientGroup.mk' (PairTail.diagonal (H.level 2) (H.level s))).comp + (firstPairEquiv H h0 h1).toMonoidHom := by ext x; rfl + rw [he,← Subgroup.map_map,restricted_map_pairLevel] + rfl + +variable {t d r : ℕ} (c : RealCoordinates G (t+d)) +variable (h2 : ∀ g : G, g ∈ H.level 2 ↔ ∀ i : Fin (t+d), i.val < t → c.coord g i = 0) +variable (hr : r ≤ t+d) +variable (hS : ∀ g : G, g ∈ H.level s ↔ ∀ i : Fin (t+d), i.val < r → c.coord g i = 0) + + + +def sourceReducedCoordinates : RealCoordinates + ((level H h0 1) ⧸ (restricted H h0).level s) (r+d) := + pullCoordinates (PairTail.reducedCoordinates c (H.level 2) h2 hr (H.level s) hS + (last_central_ambient H h1 s hs)) + (reducedPairEquiv H h0 h1 s hs0 hs) + (reducedPairEquiv_continuous H h0 h1 s hs0 hs) + (reducedPairEquiv_symm_continuous H h0 h1 s hs0 hs) + +lemma sourceReduced_integer_lattice (Γ : Subgroup G) + (hΓ : ∀ g : G, g ∈ Γ ↔ ∀ i, ∃ z : ℤ, c.coord g i = z) + (x : (level H h0 1) ⧸ (restricted H h0).level s) : + x ∈ ((Γ.prod Γ).comap (level H h0 1).subtype).map + (QuotientGroup.mk' ((restricted H h0).level s)) ↔ + ∀ i, ∃ z : ℤ, (sourceReducedCoordinates H h0 h1 s hs0 hs c h2 hr hS).coord x i = z := by + have hm : x ∈ ((Γ.prod Γ).comap (level H h0 1).subtype).map + (QuotientGroup.mk' ((restricted H h0).level s)) ↔ + reducedPairEquiv H h0 h1 s hs0 hs x ∈ PairTail.reducedLattice (H.level 2) (H.level s) Γ := by + rw [← reducedLattice_map H h0 h1 s hs0 hs Γ] + constructor + · intro hx; exact ⟨x,hx,rfl⟩ + · rintro ⟨y,hy,he⟩ + have hh : y = x := (reducedPairEquiv H h0 h1 s hs0 hs).injective he + exact hh ▸ hy + rw [hm,PairTail.reducedLattice_iff c (H.level 2) h2 hr (H.level s) hS + (last_central_ambient H h1 s hs) Γ hΓ] + rfl + +end LeibmanSquare +end +end + + + +section +noncomputable section +namespace MalcevSubspaceQuotient +open RationalLattice MalcevCharacters +variable {G : Type*} [Group G] [TopologicalSpace G] [IsTopologicalGroup G] +variable {n : ℕ} (c : RealCoordinates G n) (hsk : SecondKind c) +variable (N : Subgroup G) [N.Normal] (I : Set (Fin n)) +variable (hN : ∀ g : G, g ∈ N ↔ ∀ i ∈ I, c.coord g i = 0) + +def mask (x : Fin n → ℝ) (i : Fin n) : ℝ := by + classical + exact if i∈I then x i else 0 + +def strip (g : G) : G := c.coord.symm (mask I (c.coord g)) + +include hN in +omit [IsTopologicalGroup G] [N.Normal] in +lemma axis_mem {i : Fin n} (hi : i∉I) (t : ℝ) : axis c i t ∈ N := by + apply (hN _).mpr + intro j hj + have hji : j≠i := by intro he; exact hi (he ▸ hj) + simp [hji] + +include hsk in +omit [IsTopologicalGroup G] in +lemma mk_coordinates (x : Fin n → ℝ) : + (QuotientGroup.mk (c.coord.symm x) : G ⧸ N) = + (List.ofFn (fun i => QuotientGroup.mk (axis c i (x i)) : Fin n → G ⧸ N)).prod := by + conv_lhs => rw [hsk.ordered (c.coord.symm x)] + change (QuotientGroup.mk' N) (List.ofFn _ |>.prod) = _ + rw [map_list_prod,List.map_ofFn] + simp only [Homeomorph.apply_symm_apply] + rfl + +include hN hsk in +omit [IsTopologicalGroup G] in +lemma mk_strip (g : G) : (QuotientGroup.mk (strip c I g) : G ⧸ N)=QuotientGroup.mk g := by + have hg : (QuotientGroup.mk g : G ⧸ N) = QuotientGroup.mk (c.coord.symm (c.coord g)) := by simp + rw [hg,strip,mk_coordinates c hsk N,mk_coordinates c hsk N] + congr 1 + apply List.ofFn_inj.mpr + funext i + by_cases hi : i∈I + · simp [mask,hi] + · simp only [mask,ite_eq_right hi,axis_zero,QuotientGroup.mk_one] + exact ((QuotientGroup.eq_one_iff _).mpr (axis_mem c N I hN hi _)).symm + +include hN in +omit [IsTopologicalGroup G] [N.Normal] in +lemma strip_unique (g h : G) + (hg : ∀ i∉I, c.coord g i=0) (hh : ∀ i∉I, c.coord h i=0) + (he : (QuotientGroup.mk g : G ⧸ N)=QuotientGroup.mk h) : g=h := by + have hn := (hN _).mp (QuotientGroup.eq.mp he) + apply c.coord.injective + funext i + suffices hf : ∀ k : ℕ, ∀ hk : k + intro hk + let j : Fin n := ⟨k,hk⟩ + by_cases hj : j∈I + · have hpre : ∀ u : Fin n, u.val c.coord a i) he' + simpa [strip,mask,hi] using hf + · intro he + have he' : strip c I g=strip c I h := by + unfold strip + congr 1 + funext i + by_cases hi : i∈I + · simpa [mask,hi] using he i hi + · simp [mask,hi] + rw [← mk_strip c hsk N I hN g,← mk_strip c hsk N I hN h,he'] + +end MalcevSubspaceQuotient + +end +end +end +end +end + +end OAI diff --git a/lean/OAI/Combinatorics/SumProduct/Alignment/LeibmanSquare03.lean b/lean/OAI/Combinatorics/SumProduct/Alignment/LeibmanSquare03.lean new file mode 100644 index 0000000000000000000000000000000000000000..842214c5d9ba3adc8503444de636f23b05a2a377 --- /dev/null +++ b/lean/OAI/Combinatorics/SumProduct/Alignment/LeibmanSquare03.lean @@ -0,0 +1,261 @@ +import Mathlib +import OAI.Combinatorics.SumProduct.Alignment.DensePolynomial01 +import OAI.Geometry.NilpotentCharts.Main + +namespace OAI + +section +section +section +section +open _root_.Polynomial _root_.OAI.Polynomial Finset +open scoped BigOperators + +namespace DenseModularPolynomial +open PolynomialWeyl _root_.Polynomial _root_.OAI.Polynomial Finset +open scoped BigOperators +noncomputable section + +theorem rough_lattice_inverse (d : ℕ) (δ : ℝ) (hδ : 0 < δ) : + ∃ A : ℕ, 0 < A ∧ ∃ ε₀ : ℝ, 0 < ε₀ ∧ + ∀ N : ℕ, 0 < N → ∀ ε : ℝ, 0 ≤ ε → ε ≤ ε₀ → + ∀ S : Finset ℕ, S ⊆ range N → δ*N ≤ (S.card:ℝ) → + ∀ p : ℝ[X], p.natDegree ≤ d → + (∀ n ∈ S, ∃ z : ℤ, |p.eval (n:ℝ)-z| ≤ ε) → + ∃ q : ℤ, q ≠ 0 ∧ |q| ≤ A ∧ ∃ m : ℕ → ℤ, + ∀ j : ℕ, 0 < j → j ≤ d → + |(q:ℝ)*p.coeff j - m j| ≤ (A:ℝ)/(N:ℝ)^j := by + obtain ⟨R,hR⟩ := exists_nat_gt (max (1:ℝ) (16/δ)) + have hRone : (1:ℝ) ≤ R := (le_max_left _ _).trans hR.le + have hRpos : 0 < R := by exact_mod_cast (lt_of_lt_of_le zero_lt_one hRone) + have hδR : 16 ≤ δ*(R:ℝ) := by + have h := (div_le_iff₀ hδ).mp ((le_max_right _ _).trans hR.le) + nlinarith only [h] + obtain ⟨A,hA,hInverse⟩ := WeylCoefficients.coefficient_inverse d (δ/16) (by positivity) + let ε₀ := 1/(4*Real.pi*R) + have hε₀ : 0 < ε₀ := by dsimp [ε₀]; positivity + refine ⟨A*R,by positivity,ε₀,hε₀,?_⟩ + intro N hN ε hε hεsmall S hSN hS p hp hgood + have hsmall : 2*Real.pi*R*ε ≤ (1:ℝ)/2 := by + have h := mul_le_mul_of_nonneg_left hεsmall (by positivity : 0 ≤ 2*Real.pi*R) + have he : 2*Real.pi*R*ε₀ = (1:ℝ)/2 := by + dsimp [ε₀] + field_simp + ring + rwa [he] at h + obtain ⟨a,ha,b,hb,hab,hm⟩ := FejerDetection.detect N R hN hRpos δ ε hδ hδR hε + hsmall S hSN hS (fun n => p.eval (n:ℝ)) hgood + let c : ℤ := (a:ℤ)-b + have hc : c ≠ 0 := by + dsimp [c] + exact sub_ne_zero.mpr (by exact_mod_cast hab) + let P := C (c:ℝ)*p + have hP : P.natDegree ≤ d := by + exact (natDegree_mul_le.trans (by simp)).trans hp + have hmean : δ/16 ≤ ‖mean N (polynomialPhase P)‖ := by + change δ/16 ≤ ‖mean N (fun n => phase (P.eval (n:ℝ)))‖ + simpa only [P,eval_mul,eval_C,c,Int.cast_sub,Int.cast_natCast] using hm + obtain ⟨q,hq,hqA,m,hm⟩ := hInverse N hN P hP hmean + have habound : a < R := mem_range.mp ha + have hbbound : b < R := mem_range.mp hb + have hcR : |c| ≤ (R:ℤ) := by + rw [abs_le] + dsimp [c] + constructor <;> omega + have hqbound : |(q:ℤ)*c| ≤ (A*R:ℕ) := by + rw [abs_mul,abs_of_nonneg (Int.natCast_nonneg q)] + exact_mod_cast mul_le_mul (Int.ofNat_le.mpr hqA) hcR (abs_nonneg c) + (Int.natCast_nonneg A) + refine ⟨(q:ℤ)*c,mul_ne_zero (by exact_mod_cast Nat.ne_of_gt hq) hc,hqbound,m,?_⟩ + intro j hj hjd + have h := hm j hj hjd + have hAA : (A:ℝ) ≤ A*R := by nlinarith [Nat.cast_nonneg (α := ℝ) A] + have h' := h.trans (div_le_div_of_nonneg_right hAA (by positivity)) + simpa only [P,coeff_C_mul,Int.cast_mul,Int.cast_natCast,Nat.cast_mul,mul_assoc] using h' + + + +theorem lattice_inverse (d : ℕ) (δ : ℝ) (hδ : 0 < δ) : + ∃ C : ℕ, 0 < C ∧ ∃ ε₀ : ℝ, 0 < ε₀ ∧ ∃ N₀ : ℕ, 0 < N₀ ∧ + ∀ N : ℕ, N₀ ≤ N → ∀ ε : ℝ, 0 ≤ ε → ε ≤ ε₀ → + ∀ S : Finset ℕ, S ⊆ range N → δ*N ≤ (S.card:ℝ) → + ∀ p : ℝ[X], p.natDegree ≤ d → + (∀ n ∈ S, ∃ z : ℤ, |p.eval (n:ℝ)-z| ≤ ε) → + ∃ q : ℤ, q ≠ 0 ∧ |q| ≤ C ∧ ∃ m : ℕ → ℤ, + ∀ j : ℕ, 0 < j → j ≤ d → + |(q:ℝ)*p.coeff j - m j| ≤ (C:ℝ)*ε/(N:ℝ)^j := by + classical + obtain ⟨A,hA,η,hη,hinv⟩ := rough_lattice_inverse d δ hδ + let B := (d+1)*(A+1) + let α : ℝ := δ/(2*B+3) + have hα : 0 < α := by dsimp [α]; positivity + let K := DensePolynomialInterpolation.coefficientConstant d * + DensePolynomialInterpolation.uniformBound d α + have hK : 0 ≤ K := by + dsimp [K,DensePolynomialInterpolation.uniformBound] + exact mul_nonneg (DensePolynomialInterpolation.coefficientConstant_pos d).le (by positivity) + obtain ⟨C,hC⟩ := exists_nat_gt (max (A:ℝ) (K*A)) + have hAC : (A:ℝ) ≤ C := (le_max_left _ _).trans hC.le + have hKC : K*A ≤ (C:ℝ) := (le_max_right _ _).trans hC.le + have hCpos : 0 < C := by exact_mod_cast (Nat.cast_pos.mpr hA : (0:ℝ) (n:ℤ)) + have hEcard : E.card = S.card := card_image_of_injective _ (by intro a b h; change (a:ℤ) = b at h; exact_mod_cast h) + have hEden : δ*N ≤ (E.card:ℝ) := by rwa [hEcard] + have hEN : ∀ n ∈ E, (n:ℝ) ∈ Set.Icc 0 (N:ℝ) := by + intro n hn + obtain ⟨k,hk,rfl⟩ := mem_image.mp hn + simp only [Int.cast_natCast,Set.mem_Icc] + exact ⟨Nat.cast_nonneg _, by exact_mod_cast (mem_range.mp (hSN hk)).le⟩ + have hlarge : (2*(d+1):ℝ) ≤ δ*N/(2*B+3) := by + have h := (div_le_iff₀ hα).mp ((le_max_right _ _).trans hN₀.le) + have hNcast : (N₀:ℝ) ≤ N := by exact_mod_cast hN₀N + have hh := mul_le_mul_of_nonneg_right hNcast hα.le + have h' : (2*(d+1):ℝ) ≤ α*N := by nlinarith only [h,hh] + simpa only [α,div_mul_eq_mul_div] using h' + have hEgood : ∀ n ∈ E, ∃ z : ℤ, |r.eval (n:ℝ)-z| ≤ |(q:ℝ)| * ε := by + intro n hn + obtain ⟨k,hk,rfl⟩ := mem_image.mp hn + obtain ⟨z,hz⟩ := hgood k hk + exact PolynomialIntegralResidual.residual_near_integer p r u q k z ε hr + (by simpa only [Int.cast_natCast] using hz) + have hqC : |q| ≤ (C:ℤ) := hqA.trans (by exact_mod_cast hAC) + refine ⟨q,hq,hqC,m,?_⟩ + intro j hj hjd + have hc := DensePolynomialInterpolation.bounded_lattice_coefficients d N B hN + δ (|(q:ℝ)| * ε) hδ (by positivity) hsmall hlarge E hEden hEN r hrdeg + (fun n hn => hrbound _ (hEN n hn)) hEgood j hj hjd + rw [hrcoeff j hj hjd] at hc + change |(q:ℝ)*p.coeff j-m j| ≤ K*(|(q:ℝ)| * ε)/(N:ℝ)^j at hc + apply hc.trans + apply div_le_div_of_nonneg_right _ (by positivity) + have hqK := (mul_le_mul_of_nonneg_left hqA' hK).trans hKC + simpa only [mul_assoc] using mul_le_mul_of_nonneg_right hqK hε + +end +end DenseModularPolynomial + +end + + + +section + + + +open scoped commutatorElement Pointwise +namespace LeibmanSquare +open CubeFaces +variable {G A : Type*} [Group G] [AddCommGroup A] + + +lemma polynomial_of_cube_mem (H : Filtration G) {k : ℕ} {f : A → G} + (hf : f ∈ CubePolynomials.polynomials H k) : Polynomial H k f := by + intro hs + induction hs generalizing k f with + | nil => + intro n + exact CubePolynomials.eval_mem hf n + | cons h hs ih => + have hd : diff h f ∈ CubePolynomials.polynomials H (k+1) := + CubePolynomials.derivative_mem hf h + have hh := ih hd + intro n + simpa only [iterDiff, List.length_cons, Nat.add_assoc, Nat.add_comm, + Nat.add_left_comm] using hh n + +lemma cube_mem_of_polynomial (H : Filtration G) {k : ℕ} {f : A → G} + (hf : Polynomial H k f) : f ∈ CubePolynomials.polynomials H k := by + rw [CubePolynomials.mem_polynomials] + intro I + induction I using Finset.induction_on generalizing k f with + | empty => + intro h n + have he : CubePolynomials.pattern ∅ h n f = face ∅ (f n) := by + ext v + simp [CubePolynomials.pattern, face] + rw [he] + exact face_mem_cube H (Finset.empty_subset ∅) (by simpa [iterDiff] using hf [] n) + | @insert a I ha ih => + intro h n + let l := CubePolynomials.pattern I h n f + let u := CubePolynomials.pattern I h n (diff (h a) f) + have hd : Polynomial H (k+1) (diff (h a) f) := by + intro hs n + simpa only [iterDiff,List.length_cons,Nat.add_assoc,Nat.add_comm, + Nat.add_left_comm] using hf ((h a)::hs) n + have hl : l ∈ cube H I k := ih hf h n + have hu : u ∈ cube H I (k+1) := ih hd h n + have he : CubePolynomials.pattern (insert a I) h n f = l * upper a u := by + funext v + have haV : a ∉ v ∩ I := fun hh => ha (Finset.mem_inter.mp hh).2 + by_cases hav : a ∈ v + · have hv : v ∩ insert a I = insert a (v ∩ I) := by + ext b + simp only [Finset.mem_inter, Finset.mem_insert] + aesop + change f (n + ∑ i ∈ v ∩ insert a I, h i) = + f (n + ∑ i ∈ v ∩ I, h i) * (if a ∈ v then + (f (n + ∑ i ∈ v ∩ I, h i))⁻¹ * f ((n + ∑ i ∈ v ∩ I, h i) + h a) else 1) + rw [hv, Finset.sum_insert haV, ite_eq_left hav, mul_inv_cancel_left] + congr 1 + abel + · have hv : v ∩ insert a I = v ∩ I := by + ext b + simp only [Finset.mem_inter, Finset.mem_insert] + aesop + change f (n + ∑ i ∈ v ∩ insert a I, h i) = + f (n + ∑ i ∈ v ∩ I, h i) * (if a ∈ v then u v else 1) + rw [hv, ite_eq_right hav, mul_one] + rw [he] + exact (cube H (insert a I) k).mul_mem + (cube_mono H (Finset.subset_insert a I) k hl) (upper_cube_mem H ha k hu) + +theorem polynomial_iff_cube_mem (H : Filtration G) (k : ℕ) (f : A → G) : + Polynomial H k f ↔ f ∈ CubePolynomials.polynomials H k := + ⟨cube_mem_of_polynomial H,polynomial_of_cube_mem H⟩ + + + +theorem reduced_cube_polynomial (H : Filtration G) (h0 : H.level 0 = ⊤) + (h1 : H.level 1 = ⊤) {s : ℕ} (hs0 : 1 ≤ s) (hs : H.level (s+1) = ⊥) + {f : A → G} (hf : f ∈ CubePolynomials.polynomials H 0) (t : A) (a b : G) : + let R := restricted H h0 + letI := last_normal H h0 hs0 hs + let π := QuotientGroup.mk' (R.level s) + let Q := mapFiltration R π + let p := fun n => π (restrictedConj H h0 h1 a b + (normalizedPair H h0 (polynomial_of_cube_mem H hf) t n)) + p ∈ CubePolynomials.polynomials Q 0 ∧ + ∀ ts : List A, s ≤ ts.length → ∀ n, iterDiff ts p n = 1 := by + dsimp only + let := last_normal H h0 hs0 hs + have hp := reduced_pair_polynomial H h0 h1 hs0 hs (polynomial_of_cube_mem H hf) t a b + exact ⟨cube_mem_of_polynomial _ hp.1,hp.2⟩ + +end LeibmanSquare + +end +end +end +end + +end OAI diff --git a/lean/OAI/Combinatorics/SumProduct/Alignment/LeibmanSquare04.lean b/lean/OAI/Combinatorics/SumProduct/Alignment/LeibmanSquare04.lean new file mode 100644 index 0000000000000000000000000000000000000000..fa50fb3e26410c4146ed816033faf8a26e3ba303 --- /dev/null +++ b/lean/OAI/Combinatorics/SumProduct/Alignment/LeibmanSquare04.lean @@ -0,0 +1,336 @@ +import Mathlib +import OAI.Combinatorics.SumProduct.Alignment.RationalQuotient01 +import OAI.Combinatorics.SumProduct.Alignment.WeylInverse01 +import OAI.Geometry.NilpotentCharts.Main + +namespace OAI + +section +section +section +section +open scoped commutatorElement Pointwise +namespace LeibmanSquare +open CubeFaces RationalQuotientFunctions +open scoped ComplexConjugate +variable {G : Type*} [Group G] [TopologicalSpace G] [IsTopologicalGroup G] + + +noncomputable def balanced (H : Filtration G) (h0 : H.level 0 = ⊤) (Γ : Subgroup G) + (F : C(G ⧸ Γ,ℂ)) (a b : G) (x : level H h0 1) : ℂ := + F (QuotientGroup.mk (a*x.val.1)) * conj (F (QuotientGroup.mk (b*x.val.2))) + +lemma continuous_balanced (H : Filtration G) (h0 : H.level 0 = ⊤) (Γ : Subgroup G) + (F : C(G ⧸ Γ,ℂ)) (a b : G) : Continuous (balanced H h0 Γ F a b) := by + exact (F.continuous.comp (QuotientGroup.continuous_mk.comp + (continuous_const.mul (continuous_fst.comp continuous_subtype_val)))).mul + (continuous_star.comp (F.continuous.comp (QuotientGroup.continuous_mk.comp + (continuous_const.mul (continuous_snd.comp continuous_subtype_val))))) + +omit [IsTopologicalGroup G] in +lemma balanced_lattice (H : Filtration G) (h0 : H.level 0 = ⊤) (Γ : Subgroup G) + (F : C(G ⧸ Γ,ℂ)) (a b : G) (x γ : level H h0 1) + (hγ : γ ∈ (Γ.prod Γ).comap (level H h0 1).subtype) : + balanced H h0 Γ F a b (x*γ) = balanced H h0 Γ F a b x := by + change F (QuotientGroup.mk (a*(x.val.1*γ.val.1))) * + conj (F (QuotientGroup.mk (b*(x.val.2*γ.val.2)))) = _ + rw [← mul_assoc,← mul_assoc] + have he1 := QuotientGroup.mk_mul_of_mem (s := Γ) (a*x.val.1) hγ.1 + have he2 := QuotientGroup.mk_mul_of_mem (s := Γ) (b*x.val.2) hγ.2 + exact congrArg₂ (fun (u v : G ⧸ Γ) => F u * conj (F v)) he1 he2 + +omit [IsTopologicalGroup G] in + + +lemma balanced_last (H : Filtration G) (h0 : H.level 0 = ⊤) (Γ : Subgroup G) + (F : C(G ⧸ Γ,ℂ)) (a b : G) (s : ℕ) (hs0 : 1 ≤ s) + (hs : H.level (s+1) = ⊥) (χ : G → ℂ) + (hχ : ∀ n ∈ H.level s, ‖χ n‖ = 1) + (hw : ∀ n ∈ H.level s, ∀ x : G, + F (QuotientGroup.mk (x*n)) = χ n * F (QuotientGroup.mk x)) + (x n : level H h0 1) (hn : n ∈ (restricted H h0).level s) : + balanced H h0 Γ F a b (x*n) = balanced H h0 Γ F a b x := by + change n.val ∈ level H h0 (max 1 s) at hn + rw [max_eq_right hs0] at hn + obtain ⟨hnS,he⟩ := (last_level H h0 s hs n.val).mp hn + have hnχ : χ n.val.1 * conj (χ n.val.1) = 1 := by + rw [Complex.mul_conj,Complex.normSq_eq_norm_sq,hχ _ hnS] + norm_num + change F (QuotientGroup.mk (a*(x.val.1*n.val.1))) * + conj (F (QuotientGroup.mk (b*(x.val.2*n.val.2)))) = _ + rw [← he,← mul_assoc,← mul_assoc,hw _ hnS,hw _ hnS,map_mul] + calc + _ = (χ n.val.1 * conj (χ n.val.1)) * balanced H h0 Γ F a b x := by + simp only [balanced]; ring + _ = _ := by rw [hnχ,one_mul] + +omit [IsTopologicalGroup G] in +lemma balanced_bound (H : Filtration G) (h0 : H.level 0 = ⊤) (Γ : Subgroup G) + (F : C(G ⧸ Γ,ℂ)) (a b : G) (hF : ∀ x, ‖F x‖ ≤ 1) (x : level H h0 1) : + ‖balanced H h0 Γ F a b x‖ ≤ 1 := by + rw [balanced,norm_mul,RCLike.norm_conj] + exact (mul_le_of_le_one_left (norm_nonneg _) (hF _)).trans (hF _) + + + +theorem exists_reduced_observable (H : Filtration G) (h0 : H.level 0 = ⊤) + (Γ : Subgroup G) (F : C(G ⧸ Γ,ℂ)) (a b : G) (hF : ∀ x, ‖F x‖ ≤ 1) + (s : ℕ) (hs0 : 1 ≤ s) (hs : H.level (s+1) = ⊥) (χ : G → ℂ) + (hχ : ∀ n ∈ H.level s, ‖χ n‖ = 1) + (hw : ∀ n ∈ H.level s, ∀ x : G, + F (QuotientGroup.mk (x*n)) = χ n * F (QuotientGroup.mk x)) : + let R := restricted H h0 + let L := (Γ.prod Γ).comap (level H h0 1).subtype + letI := last_normal H h0 hs0 hs + let π := QuotientGroup.mk' (R.level s) + ∃ Ψ : C(((level H h0 1) ⧸ R.level s) ⧸ L.map π,ℂ), + (∀ x, ‖Ψ x‖ ≤ 1) ∧ + ∀ x : level H h0 1, Ψ (QuotientGroup.mk (π x)) = balanced H h0 Γ F a b x := by + let R := restricted H h0 + let L := (Γ.prod Γ).comap (level H h0 1).subtype + let := last_normal H h0 hs0 hs + let B : C(level H h0 1,ℂ) := ⟨balanced H h0 Γ F a b, + continuous_balanced H h0 Γ F a b⟩ + have hN := balanced_last H h0 Γ F a b s hs0 hs χ hχ hw + have hL := balanced_lattice H h0 Γ F a b + obtain ⟨Ψ,hΨ,_⟩ := existsUnique_normalDescend (R.level s) L B hN hL + refine ⟨Ψ,?_,hΨ⟩ + intro x + induction x using Quotient.inductionOn with | h y => + induction y using Quotient.inductionOn with | h z => + change ‖Ψ (QuotientGroup.mk (QuotientGroup.mk' (R.level s) z))‖ ≤ 1 + rw [hΨ] + exact balanced_bound H h0 Γ F a b hF z + +variable {A : Type*} [AddCommGroup A] + +omit [IsTopologicalGroup G] in + + +lemma balanced_normalized (H : Filtration G) (h0 : H.level 0 = ⊤) + (h1 : H.level 1 = ⊤) (Γ : Subgroup G) (F : C(G ⧸ Γ,ℂ)) + {f : A → G} (hf : Polynomial H 0 f) (t : A) (a b γ δ : G) + (hγ : γ ∈ Γ) (hδ : δ ∈ Γ) (ha : f 0 = a*γ) (hb : f t = b*δ) (n : A) : + balanced H h0 Γ F a b + (restrictedConj H h0 h1 γ δ (normalizedPair H h0 hf t n)) = + F (QuotientGroup.mk (f n)) * conj (F (QuotientGroup.mk (f (n+t)))) := by + change F (QuotientGroup.mk (a*MulAut.conj γ ((f 0)⁻¹*f n))) * + conj (F (QuotientGroup.mk (b*MulAut.conj δ ((f t)⁻¹*f (n+t))))) = _ + rw [orbit_normalization Γ ha hγ,orbit_normalization Γ hb hδ] + +end LeibmanSquare + +namespace LeibmanSquare +open CubeFaces MeasureTheory +open scoped ComplexConjugate +variable {G : Type*} [Group G] [TopologicalSpace G] [IsTopologicalGroup G] + + + +theorem reduced_observable_mean_zero (H : Filtration G) (h0 : H.level 0 = ⊤) + (h1 : H.level 1 = ⊤) (Γ : Subgroup G) (F : C(G ⧸ Γ,ℂ)) (a b : G) + (s : ℕ) (hs2 : 2 ≤ s) (hs : H.level (s+1) = ⊥) (χ : G → ℂ) + (hw : ∀ n ∈ H.level s, ∀ x : G, + F (QuotientGroup.mk (x*n)) = χ n * F (QuotientGroup.mk x)) + (z : G) (hz : z ∈ H.level s) (hχz : χ z ≠ 1) : + let R := restricted H h0 + let L := (Γ.prod Γ).comap (level H h0 1).subtype + letI := last_normal H h0 (by omega : 1 ≤ s) hs + let π := QuotientGroup.mk' (R.level s) + let X := ((level H h0 1) ⧸ R.level s) ⧸ L.map π + letI : MeasurableSpace X := borel X + ∀ (μ : Measure X), SMulInvariantMeasure ((level H h0 1) ⧸ R.level s) X μ → + ∀ Ψ : C(X,ℂ), + (∀ x : level H h0 1, Ψ (QuotientGroup.mk (π x)) = balanced H h0 Γ F a b x) → + (∫ x, Ψ x ∂μ) = 0 := by + let R := restricted H h0 + let L := (Γ.prod Γ).comap (level H h0 1).subtype + let := last_normal H h0 (by omega : 1 ≤ s) hs + let π := QuotientGroup.mk' (R.level s) + let X := ((level H h0 1) ⧸ R.level s) ⧸ L.map π + let : MeasurableSpace X := borel X + let : BorelSpace X := ⟨rfl⟩ + dsimp only + intro μ hμ Ψ hΨ + let := hμ + have hzC : ∀ x : G, Commute z x := by + intro x + apply commutatorElement_eq_one_iff_commute.mp + have hx : x ∈ H.level 1 := by rw [h1]; trivial + have hc := H.commutator_le s 1 (Subgroup.commutator_mem_commutator hz hx) + simpa only [hs,Subgroup.mem_bot] using hc + let Z : level H h0 1 := ⟨(z,1),⟨H.antitone (by omega) hz, + (H.level 1).one_mem, by simpa using (H.level 2).inv_mem (H.antitone hs2 hz)⟩⟩ + have hweight : ∀ x : X, Ψ (π Z • x) = χ z * Ψ x := by + intro x + induction x using Quotient.inductionOn with | h y => + induction y using Quotient.inductionOn with | h v => + change Ψ (QuotientGroup.mk (π Z * π v)) = χ z * Ψ (QuotientGroup.mk (π v)) + rw [← map_mul,hΨ,hΨ] + change F (QuotientGroup.mk (a*(z*v.val.1))) * + conj (F (QuotientGroup.mk (b*(1*v.val.2)))) = + χ z * (F (QuotientGroup.mk (a*v.val.1)) * conj (F (QuotientGroup.mk (b*v.val.2)))) + rw [one_mul,(hzC v.val.1).eq,← mul_assoc,hw z hz,mul_assoc] + have hi := integral_smul_eq_self (μ := μ) (fun x => Ψ x) (g := π Z) + simp only [hweight,integral_const_mul] at hi + have he : (χ z - 1) * (∫ x, Ψ x ∂μ) = 0 := by rw [sub_mul,one_mul,hi,sub_self] + exact (mul_eq_zero.mp he).resolve_left (sub_ne_zero.mpr hχz) +end LeibmanSquare + +namespace SquareDifferences +open PolynomialWeyl +open scoped BigOperators ComplexConjugate +noncomputable section + + +theorem density_of_large_average {ι : Type*} (S : Finset ι) (hS : S.Nonempty) + (f : ι → ℝ) (t : ℝ) (ht : 0 ≤ t) (hf : ∀ x ∈ S, f x ≤ 1) + (havg : 2 * t ≤ 𝔼 x ∈ S, f x) : + t * S.card ≤ ((S.filter (fun x => t ≤ f x)).card : ℝ) := by + classical + have h : (∑ x ∈ S, f x) ≤ ∑ x ∈ S, (t + if t ≤ f x then (1 : ℝ) else 0) := by + apply Finset.sum_le_sum + intro x hx + split_ifs with htx + · linarith [hf x hx] + · linarith + simp only [Finset.sum_add_distrib, Finset.sum_const, nsmul_eq_mul, + Finset.sum_boole] at h + rw [Finset.expect_eq_sum_div_card] at havg + have hc : 0 < (S.card : ℝ) := Nat.cast_pos.mpr (Finset.card_pos.mpr hS) + have havg' := (le_div_iff₀ hc).mp havg + nlinarith + + + +theorem exists_dense_derivatives {N H : ℕ} (hN : 0 < N) (hH : 0 < H) + (f : ℕ → ℂ) (hf : ∀ x, ‖f x‖ ≤ 1) (δ : ℝ) (hδ : 0 < δ) + (hlarge : δ ≤ ‖mean N f‖) (hboundary : 4 * (H : ℝ) / N ≤ δ ^ 2 / 2) : + ∃ b ∈ Finset.range H, ∃ S : Finset ℕ, + (∀ a ∈ S, a < H) ∧ δ ^ 2 / 4 * H ≤ (S.card : ℝ) ∧ + (∀ a ∈ S, δ ^ 2 / 4 ≤ ‖mean N (derivative a b f)‖) := by + classical + have hv := van_der_corput hN hH f hf + rw [Finset.expect_comm] at hv + have havg : δ ^ 2 / 2 ≤ + 𝔼 b ∈ Finset.range H, 𝔼 a ∈ Finset.range H, ‖mean N (derivative a b f)‖ := by + nlinarith [norm_nonneg (mean N f)] + have hs := Finset.nonempty_range_iff.mpr (Nat.ne_of_gt hH) + obtain ⟨b, hb, hbavg⟩ := Finset.exists_le_of_le_expect hs havg + let t := δ ^ 2 / 4 + let S := (Finset.range H).filter (fun a => t ≤ ‖mean N (derivative a b f)‖) + refine ⟨b, hb, S, ?_, ?_, ?_⟩ + · intro a ha + exact Finset.mem_range.mp (Finset.mem_filter.mp ha).1 + · have h := density_of_large_average (Finset.range H) hs + (fun a => ‖mean N (derivative a b f)‖) t (by dsimp [t]; positivity) + (fun a _ => norm_mean_le_one _ (norm_derivative_le_one a b f hf)) + (by dsimp [t]; linarith) + simpa only [Finset.card_range] using h + · intro a ha + exact (Finset.mem_filter.mp ha).2 + +end +end SquareDifferences + +namespace LeibmanSquare +open CubeFaces PolynomialWeyl +open scoped BigOperators ComplexConjugate +variable {G : Type*} [Group G] [TopologicalSpace G] [IsTopologicalGroup G] + + + +theorem dense_reduced_square_orbits_tracked (H : Filtration G) (h0 : H.level 0 = ⊤) + (h1 : H.level 1 = ⊤) (Γ : Subgroup G) (F : C(G ⧸ Γ,ℂ)) + (hF : ∀ x, ‖F x‖ ≤ 1) (s : ℕ) (hs2 : 2 ≤ s) + (hs : H.level (s+1) = ⊥) (χ : G → ℂ) + (hχ : ∀ n ∈ H.level s, ‖χ n‖ = 1) + (hw : ∀ n ∈ H.level s, ∀ x : G, + F (QuotientGroup.mk (x*n)) = χ n * F (QuotientGroup.mk x)) + (C : Set G) (hC : ∀ g : G, ∃ c ∈ C, c⁻¹*g ∈ Γ) + (f : ℤ → G) (hf : Polynomial H 0 f) + (N T : ℕ) (hN : 0 < N) (hT : 0 < T) (δ : ℝ) (hδ : 0 < δ) + (hlarge : δ ≤ ‖mean N (fun n => F (QuotientGroup.mk (f n)))‖) + (hboundary : 4 * (T : ℝ) / N ≤ δ^2 / 2) : + let R := restricted H h0 + let L := (Γ.prod Γ).comap (level H h0 1).subtype + letI := last_normal H h0 (by omega : 1 ≤ s) hs + let π := QuotientGroup.mk' (R.level s) + let Q := mapFiltration R π + ∃ b ∈ Finset.range T, ∃ S : Finset ℕ, + (∀ a ∈ S, a < T) ∧ δ^2 / 4 * T ≤ (S.card : ℝ) ∧ + ∀ a ∈ S, ∃ u ∈ C, ∃ v ∈ C, + ∃ Ψ : C(((level H h0 1) ⧸ R.level s) ⧸ L.map π,ℂ), + ∃ p : ℤ → (level H h0 1) ⧸ R.level s, + ∃ γ ∈ Γ, ∃ ε ∈ Γ, + f a = u*γ ∧ f b = v*ε ∧ + (∀ n : ℤ, ∃ x : level H h0 1, p n = π x ∧ + x.val = (u⁻¹*f (n+a)*γ⁻¹, v⁻¹*f (n+b)*ε⁻¹)) ∧ + (∀ x, ‖Ψ x‖ ≤ 1) ∧ + (∀ x : level H h0 1, Ψ (QuotientGroup.mk (π x)) = balanced H h0 Γ F u v x) ∧ + Polynomial Q 0 p ∧ + (∀ ts : List ℤ, s ≤ ts.length → ∀ n, iterDiff ts p n = 1) ∧ + (∀ n : ℤ, Ψ (QuotientGroup.mk (p n)) = + F (QuotientGroup.mk (f (n+a))) * conj (F (QuotientGroup.mk (f (n+b))))) ∧ + δ^2/4 ≤ ‖mean N (fun n => Ψ (QuotientGroup.mk (p n)))‖ := by + classical + let R := restricted H h0 + let L := (Γ.prod Γ).comap (level H h0 1).subtype + let := last_normal H h0 (by omega : 1 ≤ s) hs + let π := QuotientGroup.mk' (R.level s) + let Q := mapFiltration R π + obtain ⟨b,hb,S,hST,hSc,hSd⟩ := SquareDifferences.exists_dense_derivatives hN hT + (fun n => F (QuotientGroup.mk (f n))) (fun n => hF _) δ hδ hlarge hboundary + refine ⟨b,hb,S,hST,hSc,?_⟩ + intro a ha + let f' : ℤ → G := fun n => f (n+a) + have hf' : Polynomial H 0 f' := by + intro ts n + simpa only [f',iterDiff_shift] using hf ts (n+a) + obtain ⟨u,hu,hγ⟩ := hC (f a) + obtain ⟨v,hv,hε⟩ := hC (f b) + let γ := u⁻¹*f a + let ε := v⁻¹*f b + have hfa : f' 0 = u*γ := by simp [f',γ] + have hfb : f' ((b:ℤ)-a) = v*ε := by simp [f',ε] + obtain ⟨Ψ,hΨBound,hΨ⟩ := exists_reduced_observable H h0 Γ F u v hF s + (by omega) hs χ hχ hw + let p : ℤ → (level H h0 1) ⧸ R.level s := fun n => + π (restrictedConj H h0 h1 γ ε (normalizedPair H h0 hf' ((b:ℤ)-a) n)) + have hp := reduced_pair_polynomial H h0 h1 (by omega : 1 ≤ s) hs hf' ((b:ℤ)-a) γ ε + have heval : ∀ n : ℤ, Ψ (QuotientGroup.mk (p n)) = + F (QuotientGroup.mk (f (n+a))) * conj (F (QuotientGroup.mk (f (n+b)))) := by + intro n + rw [show p n = π (restrictedConj H h0 h1 γ ε + (normalizedPair H h0 hf' ((b:ℤ)-a) n)) from rfl,hΨ] + rw [balanced_normalized H h0 h1 Γ F hf' ((b:ℤ)-a) u v γ ε hγ hε hfa hfb] + dsimp only [f'] + congr 3 + abel_nf + have hlift : ∀ n : ℤ, ∃ x : level H h0 1, p n = π x ∧ + x.val = (u⁻¹*f (n+a)*γ⁻¹, v⁻¹*f (n+b)*ε⁻¹) := by + intro n + refine ⟨restrictedConj H h0 h1 γ ε + (normalizedPair H h0 hf' ((b:ℤ)-a) n), rfl, ?_⟩ + change (γ * ((f' 0)⁻¹ * f' n) * γ⁻¹, + ε * ((f' ((b:ℤ)-a))⁻¹ * f' (n+((b:ℤ)-a))) * ε⁻¹) = _ + rw [hfa, hfb] + have hn : n + ((b:ℤ)-a) + a = n+b := by abel + simp [f', mul_inv_rev, mul_assoc, hn] + refine ⟨u,hu,v,hv,Ψ,p,γ,hγ,ε,hε,by simpa [f'] using hfa, + by simpa [f'] using hfb,hlift,hΨBound,hΨ,hp.1,hp.2,heval,?_⟩ + have he : mean N (fun n => Ψ (QuotientGroup.mk (p n))) = + mean N (derivative a b (fun n => F (QuotientGroup.mk (f n)))) := by + apply Finset.expect_congr rfl + intro n hn + simp only [derivative,heval,Nat.cast_add] + rw [he] + exact hSd a ha +end LeibmanSquare + +end +end +end +end + +end OAI diff --git a/lean/OAI/Combinatorics/SumProduct/Alignment/LeibmanSquare05.lean b/lean/OAI/Combinatorics/SumProduct/Alignment/LeibmanSquare05.lean new file mode 100644 index 0000000000000000000000000000000000000000..0338ab374a3b87b4826ecc7e6568efacbd53bbda --- /dev/null +++ b/lean/OAI/Combinatorics/SumProduct/Alignment/LeibmanSquare05.lean @@ -0,0 +1,300 @@ +import Mathlib +import OAI.Combinatorics.SumProduct.Alignment.BracketDrift01 +import OAI.Combinatorics.SumProduct.Alignment.PolynomialCharacter01 +import OAI.Geometry.NilpotentCharts.Main + +namespace OAI + +section +section +section +section +noncomputable section +open Finset Set BracketHyperplanes +open scoped BigOperators +end +end + + + +section +noncomputable section +open Finset BracketHyperplanes +open scoped BigOperators +namespace BracketDrift + +def matrixContraction {d : ℕ} (M : Matrix (Fin d) (Fin d) ℤ) (γ : Fin d → ℝ) (j : Fin d) : ℝ := + ∑ i, γ i*(M i j:ℝ) + +lemma matrixContraction_bound {d : ℕ} (M : Matrix (Fin d) (Fin d) ℤ) + (B : ℝ) (hB : 0≤B) (hM : ∀ i j, |(M i j:ℝ)|≤B) + (γ : Fin d → ℝ) (hγ : ‖γ‖≤1) : ‖matrixContraction M γ‖≤(d:ℝ)*B := by + apply (pi_norm_le_iff_of_nonneg (by positivity)).mpr + intro j + change |∑ i,γ i*(M i j:ℝ)|≤(d:ℝ)*B + calc + _ ≤ ∑ i,|γ i*(M i j:ℝ)| := abs_sum_le_sum_abs _ _ + _ ≤ ∑ _i : Fin d,B := by + apply sum_le_sum + intro i _ + rw [abs_mul] + have hi : |γ i|≤1 := (pi_norm_le_iff_of_nonneg (by norm_num : (0:ℝ)≤1)).mp hγ i + exact (mul_le_mul hi (hM i j) (abs_nonneg _) zero_le_one).trans_eq (one_mul B) + _ = _ := by simp + + + +theorem matrix_bracket_alternative (d : ℕ) (B : ℕ) (A δ : ℝ) (hA : 0 γ i*n+β i)) → + ∀ S : Finset ℕ, S⊆range N → δ*N≤(S.card:ℝ) → + (∀ n∈S, ‖((b+ρ*n+∑ i,matrixContraction M γ i*x n i:ℝ):UnitAddCircle)‖≤A/N) → + M=0 ∨ ∃ k : Fin d → ℤ, k≠0 ∧ (∀ i, |k i|≤R) ∧ + ∃ m : ℤ, |(∑ i,(k i:ℝ)*γ i)-m|≤C/N := by + classical + let A' := A+(d:ℝ)*B+1 + have hAA' : A≤A' := by dsimp [A']; nlinarith [Nat.cast_nonneg (d*B) (α:=ℝ)] + have hBnd : (d:ℝ)*B≤A' := by dsimp [A']; linarith + have hA' : 0 M i j)≠0 := by + by_contra! hh + apply hzero + ext i j + exact congrFun (hh j) i + obtain ⟨j,hj⟩ := hex + let k (i : Fin d) := r*M i j + have hk : k≠0 := by + intro hz + apply hj + funext i + exact (mul_eq_zero.mp (congrFun hz i)).resolve_left hr + obtain ⟨m,hm⟩ := hcoeff j + refine ⟨k,hk,?_,m,?_⟩ + · intro i + calc + |k i| = |r| * |M i j| := abs_mul _ _ + _ ≤ (R:ℤ)*B := mul_le_mul hrR (hM i j) (abs_nonneg _) (Int.natCast_nonneg _) + _ ≤ R*(B+1) := by nlinarith [Int.natCast_nonneg R] + · convert hm using 2 + simp only [k,matrixContraction,Int.cast_mul,mul_sum] + congr 1 + apply sum_congr rfl + intro i _ + ring + · obtain ⟨k,hk,hkR,m,hm⟩ := hfreq + refine ⟨k,hk,?_,m,hm⟩ + intro i + apply (hkR i).trans + have h0 : 0≤(R:ℤ)*B := by positivity + push_cast + linarith + +end BracketDrift +end +end + + + +section +noncomputable section +open _root_.Polynomial _root_.OAI.Polynomial Finset BracketHyperplanes +open scoped BigOperators +namespace NonabelianCharacterDescent +open BracketDrift PolynomialCharacterDescent + + + +theorem scalar_descent (d s B : ℕ) (hs : 2≤ s) (δ A : ℝ) (hδ : 0<δ) (hA : 0≤A) : + ∃ R : ℕ, 0 γ i*n+β i)) → + ∀ P Q : ℝ[X], P.natDegree≤ s → Q.natDegree≤ s → + ∀ S : Finset ℕ, S⊆range N → δ*N≤(S.card:ℝ) → + (∀ h∈S, ∀ j : ℕ, 0 q*M i j + have hM' (i j : Fin d) : |M' i j|≤R₁*B := by + change |q*M i j|≤((R₁*B:ℕ):ℤ) + rw [abs_mul,Nat.cast_mul] + exact mul_le_mul hqR (hM i j) (abs_nonneg _) (Int.natCast_nonneg _) + have he (h : ℕ) : (q:ℝ)*P.coeff 1+(2*(q:ℝ)*Q.coeff 2)*(h:ℝ)+ + ∑ i,matrixContraction M' γ i*x h i = + (q:ℝ)*P.coeff 1+2*(q:ℝ)*Q.coeff 2*h+(q:ℝ)*σ h := by + have hcoeff (j : Fin d) : matrixContraction M' γ j=(q:ℝ)*matrixContraction M γ j := by + simp only [matrixContraction,M',Int.cast_mul,mul_sum] + apply sum_congr rfl + intro i _ + ring + simp only [hcoeff,σ,mul_sum] + congr 1 + apply sum_congr rfl + intro i _ + ring + have hsmall' (h : ℕ) (hh : h∈S) : + ‖(((q:ℝ)*P.coeff 1+(2*(q:ℝ)*Q.coeff 2)*(h:ℝ)+ + ∑ i,matrixContraction M' γ i*x h i:ℝ):UnitAddCircle)‖≤C₁/N := by + rw [he] + obtain ⟨z,hz⟩ := hlinear h hh + rw [UnitAddCircle.norm_eq] + exact (round_le _ z).trans hz + rcases hmat N hN M' hM' γ β hγ (2*(q:ℝ)*Q.coeff 2) ((q:ℝ)*P.coeff 1) + x hx horbit S hSN hS hsmall' with hz | hf + · right + have hMz : M=0 := by + ext i j + apply (mul_eq_zero.mp (congrFun (congrFun hz i) j)).resolve_left hq + refine ⟨hMz,?_⟩ + obtain ⟨r,hr,hrR,hP',hQ'⟩ := hzero N hL₃N P Q hP hQ S hSN hS (by + intro h hh j hj hjs + simpa [hMz,matrixContraction] using hsmall h hh j hj hjs) + refine ⟨r,hr,hrR.trans hR₃',?_,?_⟩ + · intro j hj + obtain ⟨m,hm⟩ := hP' j hj + exact ⟨m,hm.trans (div_le_div_of_nonneg_right hC₃' (by positivity))⟩ + · intro j hj + obtain ⟨m,hm⟩ := hQ' j hj + exact ⟨m,hm.trans (div_le_div_of_nonneg_right hC₃' (by positivity))⟩ + · left + obtain ⟨k,hk,hkR,m,hm⟩ := hf + exact ⟨k,hk,fun i => (hkR i).trans hR₂',m, + hm.trans (div_le_div_of_nonneg_right hC₂' (Nat.cast_nonneg _))⟩ + +end NonabelianCharacterDescent +end +end + + + +section +noncomputable section +open scoped commutatorElement BigOperators +namespace LeibmanSquare +open CubeFaces CubePolynomials SquareHorizontalCharacter _root_.Polynomial _root_.OAI.Polynomial +variable {G : Type*} [Group G] [TopologicalSpace G] [IsTopologicalGroup G] +variable (H : Filtration G) (h0 : H.level 0=⊤) (h1 : H.level 1=⊤) +variable [∀ i, (H.level i).Normal] +variable (ξ : level H h0 1 →* Multiplicative ℝ) + +def pairTailCharacter : PairTail.square (H.level 2) →* Multiplicative ℝ := + ξ.comp (firstPairEquiv H h0 h1).symm.toMonoidHom + +omit [TopologicalSpace G] [IsTopologicalGroup G] in +lemma pairTailCharacter_base : + PairTail.baseCharacter (H.level 2) (pairTailCharacter H h0 h1 ξ)= + ξ.comp (diagonal H h0 h1) := by + apply MonoidHom.ext + intro g + change ξ _ = ξ _ + apply congrArg ξ + apply Subtype.ext + change (g,g*1)=(g,g) + simp +omit [TopologicalSpace G] [IsTopologicalGroup G] in +lemma pairTailCharacter_lower : + PairTail.lowerCharacter (H.level 2) (pairTailCharacter H h0 h1 ξ)= + ξ.comp (lower H h0) := by + apply MonoidHom.ext + intro g + change ξ _ = ξ _ + apply congrArg ξ + apply Subtype.ext + change (1,1*(g:G))=(1,(g:G)) + simp +omit [TopologicalSpace G] [IsTopologicalGroup G] in +lemma pairTailCharacter_bracket (a b : G) : + PairTail.lowerCharacter (H.level 2) (pairTailCharacter H h0 h1 ξ) + (PairTail.bracket (H.level 2) (SquareHorizontalCharacter.commutator_mem H h1) a b)=pairing H h0 h1 ξ a b := by + rw [pairTailCharacter_lower] + rfl + + + +lemma actual_square_character_identity {f : ℤ → G} (hf : Polynomial H 0 f) + (hf0 : f 0=1) (h n : ℤ) (v : G) : + (ξ (linearNormalizedPair H h0 h1 hf (linearRemainder H h0 hf hf0 h) h v n)).toAdd= + ((ξ.comp (diagonal H h0 h1)) (f n)).toAdd+ + (((ξ.comp (lower H h0)) (linearRemainder H h0 hf hf0 (n+h))).toAdd- + ((ξ.comp (lower H h0)) (linearRemainder H h0 hf hf0 n)).toAdd)+ + (n:ℝ)*(pairing H h0 h1 ξ (f 1) v).toAdd := by + have he := PairTail.square_orbit_identity (H.level 2) (pairTailCharacter H h0 h1 ξ) + (SquareHorizontalCharacter.commutator_mem H h1) (f 1) v (linearRemainder H h0 hf hf0) h n + rw [← linearNormalizedPair_eq_pairTail H h0 h1 hf hf0 (f 1) + (linearRemainder H h0 hf hf0) (linearRemainder_mul H h0 hf hf0) + (SquareHorizontalCharacter.commutator_mem H h1) h n v] at he + rw [pairTailCharacter_base,pairTailCharacter_bracket,pairTailCharacter_lower, + ← linearRemainder_mul H h0 hf hf0 n] at he + simpa only [pairTailCharacter,MonoidHom.comp_apply,MulEquiv.coe_toMonoidHom, + MulEquiv.symm_apply_apply] using he + + + +theorem exists_actual_square_polynomials (s : ℕ) (hs : H.level (s+1)=⊥) + {f : ℤ → G} (hf : Polynomial H 0 f) (hf0 : f 0=1) : + ∃ P Q : ℝ[X], P.natDegree ≤ s ∧ Q.natDegree ≤ s ∧ Q.eval 0=0 ∧ Q.eval 1=0 ∧ + (∀ n : ℤ, P.eval (n:ℝ)=((ξ.comp (diagonal H h0 h1)) (f n)).toAdd) ∧ + (∀ n : ℤ, Q.eval (n:ℝ)=((ξ.comp (lower H h0)) (linearRemainder H h0 hf hf0 n)).toAdd) ∧ + ∀ h n : ℤ, ∀ v : G, + (P+taylor (h:ℝ) Q-Q+C ((pairing H h0 h1 ξ (f 1) v).toAdd)*X).eval (n:ℝ)= + (ξ (linearNormalizedPair H h0 h1 hf (linearRemainder H h0 hf hf0 h) h v n)).toAdd := by + obtain ⟨P,hP,hPe⟩ := character_polynomial H s hs hf (ξ.comp (diagonal H h0 h1)) + obtain ⟨Q,hQ,hQ0,hQ1,hQe⟩ := remainder_character_polynomial H h0 h1 s hs hf hf0 + (ξ.comp (lower H h0)) + refine ⟨P,Q,hP,hQ,hQ0,hQ1,hPe,hQe,?_⟩ + intro h n v + rw [eval_add,eval_sub,eval_add,eval_mul,eval_C,eval_X,taylor_eval, + ← Int.cast_add,hPe,hQe,hQe,actual_square_character_identity H h0 h1 ξ hf hf0 h n v] + ring + +end LeibmanSquare + +end +end +end +end +end + +end OAI diff --git a/lean/OAI/Combinatorics/SumProduct/Alignment/MacroSelection01.lean b/lean/OAI/Combinatorics/SumProduct/Alignment/MacroSelection01.lean new file mode 100644 index 0000000000000000000000000000000000000000..d2155e1d257f5bbffea4b4ef4458c045a305cc10 --- /dev/null +++ b/lean/OAI/Combinatorics/SumProduct/Alignment/MacroSelection01.lean @@ -0,0 +1,254 @@ +import Mathlib +import OAI.Combinatorics.SumProduct.Alignment.IntegerArrays08 +import OAI.Geometry.NilpotentCharts.Main + +namespace OAI + +open scoped BigOperators +section +noncomputable section +end + +noncomputable section +namespace SourceIntegerArrays +open GlobalJoint +open RoughArrayFace +open RationalLattice MalcevCharacters RoughFaceShift RoughTopologicalFace RoughArrayCoordinates SourceResidueAlignment +open RoughScales RoughSamplingWeights FinitePieceAverages RoughSourceExceptional RoughProductRemoval +open ProductExposureLabels ProductExposureLaw ProductExposureCutoff MeasureTheory Filter +open scoped BigOperators Topology ENNReal BoundedContinuousFunction NNReal +attribute [local instance] Classical.propDecidable +open ConstructedWordPlan.GlobalWordPlan +open ConstructedWordPlan.AlignmentScales ConstructedWordPlan.RationalPivotPlan +variable {a₀ : ℕ} (D : Pivot a₀) {ι : Fin D.targets→Type} [∀ t,Fintype (ι t)] +variable (G : ∀ t,ι t→Type) [∀ t i,Group (G t i)] +variable [∀ t i,TopologicalSpace (G t i)] [∀ t i,IsTopologicalGroup (G t i)] +variable (n : ∀ t,ι t→ℕ) (q : Fin D.targets→ℕ) (c : ∀ t i,RealCoordinates (G t i) (n t i)) +variable (hsk : ∀ t i,SecondKind (c t i)) (A : ∀ t i,CubeFaces.Filtration (G t i)) +variable (w : ∀ t i,Fin (n t i)→ℕ) +variable (hA : ∀ t i k (g : G t i),g∈(A t i).level k ↔ ∀ j,w t i j((M N*J N:ℕ):ℝ)/(Xp N:ℝ)) atTop (𝓝 0)) : + Tendsto (fun N=>(jointLaw (X N) (Xp N) (W N) (hW N) (hX N) (hXp N)) + {z | ¬ fullCell (Xp N) (M N) (J N) z.2}) atTop (𝓝 0) := by + have hb : ∀ N,(jointLaw (X N) (Xp N) (W N) (hW N) (hX N) (hXp N)).real + {z | ¬ fullCell (Xp N) (M N) (J N) z.2} ≤ 24*(((M N*J N:ℕ):ℝ)/(Xp N:ℝ)) := by + intro N + have heq : (jointLaw (X N) (Xp N) (W N) (hW N) (hX N) (hXp N)).real + {z | ¬ fullCell (Xp N) (M N) (J N) z.2} = + (RawHarmonicProbability.law (Xp N) (W N) (hW N) (hXp N) : Measure ℕ).real + (RawSmallCells.partialCells (Xp N) (W N) (M N*J N) : Set ℕ) := by + rw [←pivot_marginal (X N) (Xp N) (W N) (hW N) (hX N) (hXp N)] + apply measureReal_congr + filter_upwards [joint_ae_fullDomain (X N) (Xp N) (W N) (hW N) (hX N) (hXp N)] with z hz + obtain ⟨hz,hcop⟩:=Finset.mem_filter.mp hz + have hp : z.2∈RawHarmonicProbability.units (Xp N) (W N):= + Finset.mem_filter.mpr ⟨(Finset.mem_product.mp hz).2,hcop⟩ + change (¬fullCell (Xp N) (M N) (J N) z.2) = + (z.2∈RawSmallCells.partialCells (Xp N) (W N) (M N*J N)) + simp only [fullCell,RawSmallCells.partialCells,Finset.mem_filter,hp,true_and] + congr 3 <;> ring + rw [heq] + have hm : W N≤M N*J N := (Nat.le_of_dvd (hM N) (hWM N)).trans + (Nat.le_mul_of_pos_right _ (hJ N)) + simpa only [mul_div_assoc] using RawSmallCells.partial_cost_simple + (Xp N) (W N) (M N*J N) (hW N) (hXp N) hm + have ht : Tendsto (fun N=>(jointLaw (X N) (Xp N) (W N) (hW N) (hX N) (hXp N)).real + {z | ¬ fullCell (Xp N) (M N) (J N) z.2}) atTop (𝓝 0) := + squeeze_zero (fun _=>measureReal_nonneg) hb (by simpa using hr.const_mul 24) + apply (ENNReal.tendsto_toReal_iff (by intro N;finiteness) (by simp)).mp + simpa only [measureReal_def,ENNReal.toReal_zero] using ht + + + +theorem source_harmonic_final + (hΓ : ∀ t i g,g∈Γ t i ↔ ∀ j,∃ z : ℤ,(c t i).coord g j=z) + (hmono : ∀ t i,Monotone (w t i)) (s : ℕ) + (h0 : ∀ t i,(A t i).level 0=⊤) (h1 : ∀ t i,(A t i).level 1=⊤) + (hs : ∀ t i,(A t i).level (s+1)=⊥) + (a : ℕ) (m h : Fin D.targets→ℕ) (perm : ∀ t,Fin (m t+h t)≃Fin a) + (w0 M Xp : ℕ→ℕ) (X : ℕ→Fin a→ℕ) (R Q : ℕ→ℝ) (L : ℕ→ℤ) + (hw0 : Tendsto w0 atTop atTop) + (hX : ∀ N j,4*primorial (w0 N)≤X N j) (hXp : ∀ N,4*primorial (w0 N)≤Xp N) + (hXt : ∀ j,Tendsto (fun N=>X N j) atTop atTop) (hXpt : Tendsto Xp atTop atTop) + (hR : ∀ N,0R N/(Xp N:ℝ)) atTop (𝓝 0)) + (hZ : ∀ t (u : ℝ),0(R N/(M N:ℝ))/ + (1+∑ j : Fin (m t),(X N (perm t (j.castAdd (h t))):ℝ)^2)^u) atTop atTop) + (hQ0 : ∀ N,0≤Q N) + (hSize : ∀ t,Tendsto (fun N=>(Q N+(∏ l : Fin (m t),(X N (perm t (l.castAdd (h t))):ℝ)^2)*(L N:ℝ))/R N) atTop (𝓝 0)) + (hWM : ∀ N,(primorial (w0 N):ℤ)∣(M N:ℤ)) + (hM : ∀ N,0(X N (perm t (j.castAdd (h t))):ℝ)/(L N:ℝ)) atTop atTop) + (g x : ∀ t,ℕ→(Fin (h t)→ℕ)→Label (m t)→∀ i,G t i) + (slot : ∀ t,ℕ→(Fin (h t)→ℕ)→Label (m t)→ι t→ℤ) + (qval : ∀ t,ℕ→(Fin (h t)→ℕ)→Label (m t)→Fin (q t)→ℤ) + (hQ : ∀ t N y,y∈outsideDomain (fun l : Fin (h t)=>X N (perm t (l.natAdd (m t)))) (primorial (w0 N)) → + ∀ b,b∈(fullDomain (fun l : Fin (m t)=>X N (perm t (l.castAdd (h t)))) (Xp N) (primorial (w0 N))).image + (expose (L N) (M N:ℤ) (R N)) →∀ k,|(qval t N y b k:ℝ)|≤Q N) + (metric : ∀ t i,MetricSpace ((G t i)⧸Γ t i)) + (hmetric : ∀ t i,QuotientGroup.instTopologicalSpace (Γ t i)=(metric t i).toUniformSpace.toTopologicalSpace) : + letI : ∀ t i,MetricSpace ((G t i)⧸Γ t i):=fun t i=>(metric t i).replaceTopology (hmetric t i) + ∀ (Obs : ℕ→((Fin a→ℕ)×ℕ)→∀ t i,((G t i)⧸Γ t i) →ᵇ ℝ) (Kobs : ℝ≥0) (Bobs : ℝ) + (_hLip : ∀ N z t i,LipschitzWith Kobs (Obs N z t i)) + (_hBound : ∀ N z t i y,|Obs N z t i y|≤Bobs) + (J : ℕ→ℕ) (_hJ : ∀ N,0(jointLaw (X N) (Xp N) (primorial (w0 N)) (primorial_pos _) + (hX N) (hXp N)) {z | cellRatio (Xp N) (primorial (w0 N)) (M N) (J N) z.2 (primorial_pos _) (hXp N) + {k | QuotientGroup.mk (rawLocalOrbit D G n q c hsk A w hA hw m h perm + (M N) (J N) (L N) (R N) (fun t=>g t N) (fun t=>x t N) + (fun t=>slot t N) (fun t=>qval t N) z (k:ℤ)) ∈ + intrinsicSuccess D G n q c hsk A w hA Γ coord s r hs1 formula (Obs N z) Fs q₀ b τ} + ≤ ((pivotOptions s r hs1 D Fs).card : ℝ)⁻¹/3}) atTop (𝓝 0) + := by + classical + let : ∀ t i,MetricSpace ((G t i)⧸Γ t i):=fun t i=>(metric t i).replaceTopology (hmetric t i) + intro Obs Kobs Bobs hLip hBound J hJ hRJ r hs1 formula Fs Bs q₀ hq₀ b hb τ hτ + have hd:=source_harmonic_decay D G n q c hsk A w hA hw Γ coord + hΓ hmono s h0 h1 hs a m h perm w0 M Xp X R Q L hw0 hX hXp hXt hXpt hR hRX hZ hQ0 + hSize hWM hM hMs hL hsm hWL hML hLexact hXL g x slot qval hQ metric hmetric + Obs Kobs Bobs hLip hBound J hJ hRJ r hs1 formula Fs Bs q₀ hq₀ b hb τ hτ + have hr : Tendsto (fun N=>((M N*J N:ℕ):ℝ)/(Xp N:ℝ)) atTop (𝓝 0) := by + simpa only [Nat.cast_mul,←hRJ] using hRX + have he:=endpoint_joint_decay X Xp (fun N=>primorial (w0 N)) M J + (fun N=>primorial_pos _) hX hXp hM hJ (fun N=>by exact_mod_cast hWM N) hr + refine tendsto_of_tendsto_of_tendsto_of_le_of_le tendsto_const_nhds + (by simpa only [zero_add] using he.add hd) (fun N=>bot_le) ?_ + intro N + apply le_trans (measure_mono ?_) (measure_union_le _ _) + intro z hz + by_cases hf : fullCell (Xp N) (M N) (J N) z.2 + · exact Or.inr ⟨hf,hz⟩ + · exact Or.inl hf + +end SourceIntegerArrays +end + +noncomputable section +namespace SourceMacroSelection +open ProductExposureLabels +open scoped BigOperators + +def width {m : ℕ} (R : ℕ) (b : Label m) : ℤ := (∏ j,(2:ℤ)^(b.dyadic j))*(R:ℤ) +def left {m : ℕ} (R : ℕ) (b : Label m) : ℤ := b.bin*width R b + + +def Stable {m : ℕ} (C H R : ℕ) (b : Label m) : Prop := + (left R b-(C:ℤ)*width R b)/(H:ℤ)= + (left R b+((C:ℤ)+1)*width R b)/(H:ℤ) +def modelBin {m : ℕ} (H R : ℕ) (b : Label m) : ℤ := left R b/(H:ℤ) +end SourceMacroSelection +end + +noncomputable section +namespace SourceMacroSelection +open ProductExposureLabels +open scoped BigOperators + +lemma width_cast {m : ℕ} (R : ℕ) (b : Label m) : (width R b:ℝ)=b.width (R:ℝ) := by + simp [width,ProductExposureLabels.Label.width,ProductExposureLabels.Label.scales] +lemma left_cast {m : ℕ} (R : ℕ) (b : Label m) : (left R b:ℝ)=b.left (R:ℝ) := by + simp [left,ProductExposureLabels.Label.left,width_cast] +lemma width_nonneg {m : ℕ} (R : ℕ) (b : Label m) : 0≤width R b := by + unfold width + positivity + +lemma stable_value {m : ℕ} (C H R : ℕ) (hH : 0(law (X j) W hW (hX j):Measure ℕ)) + let ν : Measure ℕ := law Xp W hW hXp + have htail : ∀ᵐ t ∂μ,∀ j,t j∈units (X j) W := by + apply ae_all_iff.mpr + intro j + exact (Measure.tendsto_eval_ae_ae (i:=j)).eventually (law_ae_units (X j) W hW (hX j)) + have hcond : ∀ᵐ t ∂μ,ν {p | ¬Stable C H R (expose L M (R:ℝ) (t,p))}≤ENNReal.ofReal ε := by + filter_upwards [htail] with t ht + have htp : ∀ j,0(H n:ℝ)) (earlierScale M P)) + (hx : Dominates (fun n=>Real.log (Xp n:ℝ)) (fun n=>(H n:ℝ))) + (hprod : ∀ᶠ n in atTop,(∏ j : Fin m,(X n j)^2)≤(P n)^2) : + Tendsto (fun n=>(jointLaw (X n) (Xp n) (W n) (hW n) (hX n) (hXp n)).real + {z | ¬Stable C (H n) (radius (M n) (H n)) + (expose (L n) (M n:ℤ) (radius (M n) (H n):ℝ) z)}) atTop (𝓝 0) + := by + have hbase' : ∀ᶠ n in atTop,0max (ε n) 0) atTop (𝓝 0) := by + simpa using hε.max (tendsto_const_nhds (x := (0:ℝ))) + have hM : ∀ᶠ n in atTop,0h.1) + have hH : ∀ᶠ n in atTop,0h.2.2) + have hr := (enlarged_rates (C+1) hM hH hd hx).2 + have hRX : ∀ᶠ n in atTop,(C+1)*radius (M n) (H n)≤Xp n := by + filter_upwards [hr.eventually_lt_const (show (0:ℝ)<1 by norm_num)] with n hn + have hp : (0:ℝ)⟨h.1,h.2.1⟩)) hd + apply squeeze_zero' (Filter.Eventually.of_forall (fun _=>measureReal_nonneg)) ?_ hlimit + filter_upwards [hbase,hbound,hRX,hR,hprod] with n hbase hb hr hn hprod + apply raw_coarse_bound C (H n) (radius (M n) (H n)) (Xp n) (W n) (X n) + (hW n) (hX n) (hXp n) hbase.2.2 (by have:=hW n; omega) hr (L n) (M n:ℤ) + (max (ε n) 0) (le_max_right _ _) + intro t ht + have htp : ∀ j,0htp j)) htbound).trans (le_max_left _ _) + +end SourceMacroSelection +end + +noncomputable section +namespace SourceMacroSelection +open ProductExposureLabels ProductExposureLaw RawHarmonicProbability +open MicrocellScale AdmissibleMicrocellBoundary +open MeasureTheory Filter Topology +open scoped BigOperators +attribute [local instance] Classical.propDecidable + +private lemma tail_mass {m h a : ℕ} (perm : Fin (m+h)≃Fin a) + (X : Fin a→ℕ) (Xp W : ℕ) (hW : 0z.1 (perm (j.castAdd h))),z.2)∈E} = + (jointLaw (fun j=>X (perm (j.castAdd h))) Xp W hW (fun _=>hX _) hXp).real E := by + rw [joint_outside_disintegration perm X Xp W hW hX hXp] + have hh (y : Fin h→ℕ) : + {z | ((fun j=> (reassemble perm y z).1 (perm (j.castAdd h))),(reassemble perm y z).2)∈E}=E := by + ext z + simp [reassemble] + simp_rw [Set.mem_ofPred_eq,hh] + rw [←Finset.sum_mul,outside_weights_sum,one_mul] + + +theorem source_joint_macro_decay {T : Type} [Fintype T] {a : ℕ} + (m h : T→ℕ) (perm : ∀ t,Fin (m t+h t)≃Fin a) (C : T→ℕ) + (W M P H Xp : ℕ→ℕ) (X : ℕ→Fin a→ℕ) (L : ℕ→ℤ) + (hW : ∀ N,0(H N:ℝ)) (earlierScale M P)) + (hx : Dominates (fun N=>Real.log (Xp N:ℝ)) (fun N=>(H N:ℝ))) + (hprod : ∀ t,∀ᶠ N in atTop,(∏ j : Fin (m t),(X N (perm t (j.castAdd (h t))))^2)≤(P N)^2) : + Tendsto (fun N=>(jointLaw (X N) (Xp N) (W N) (hW N) (hX N) (hXp N)).real + {z | ∃ t,¬Stable (C t) (H N) (radius (M N) (H N)) + (expose (L N) (M N:ℤ) (radius (M N) (H N):ℝ) + ((fun j : Fin (m t)=>z.1 (perm t (j.castAdd (h t)))),z.2))}) atTop (𝓝 0) + + := by + let E : ℕ→T→Set ((Fin a→ℕ)×ℕ):=fun N t=> + {z | ¬Stable (C t) (H N) (radius (M N) (H N)) + (expose (L N) (M N:ℤ) (radius (M N) (H N):ℝ) + ((fun j : Fin (m t)=>z.1 (perm t (j.castAdd (h t)))),z.2))} + have he (t : T) : Tendsto (fun N=>(jointLaw (X N) (Xp N) (W N) (hW N) (hX N) (hXp N)).real (E N t)) + atTop (𝓝 0) := by + have hm:=source_macro_selection_decay (C t) W M P H Xp + (fun N j=>X N (perm t (j.castAdd (h t)))) L hW (fun N j=>hX N _) hXp hbase hd hx (hprod t) + apply hm.congr + intro N + exact (tail_mass (perm t) (X N) (Xp N) (W N) (hW N) (hX N) (hXp N) _).symm + have hsum : Tendsto (fun N=>∑ t,(jointLaw (X N) (Xp N) (W N) (hW N) (hX N) (hXp N)).real (E N t)) + atTop (𝓝 0) := by + simpa using tendsto_finsetSum Finset.univ (fun t _=>he t) + apply squeeze_zero' (Filter.Eventually.of_forall (fun _=>measureReal_nonneg)) ?_ hsum + apply Filter.Eventually.of_forall + intro N + have hset : {z | ∃ t,¬Stable (C t) (H N) (radius (M N) (H N)) + (expose (L N) (M N:ℤ) (radius (M N) (H N):ℝ) + ((fun j : Fin (m t)=>z.1 (perm t (j.castAdd (h t)))),z.2))}=⋃ t,E N t := by + ext z + simp [E] + rw [hset] + exact measureReal_iUnion_fintype_le _ + +end SourceMacroSelection +end + +noncomputable section +open Filter Topology +open scoped BigOperators +namespace AdmissibleArrayScales +open MicrocellScale AdmissibleMicrocellBoundary MicrocellEarlierScale + + +theorem source_array_scales {m : ℕ} (M P H Xp : ℕ→ℕ) + (X : ℕ→Fin m→ℕ) (Q L : ℕ→ℝ) + (hbase : ∀ᶠ n in atTop,0(H n:ℝ)) (earlierScale M P)) + (hx : Dominates (fun n=>Real.log (Xp n:ℝ)) (fun n=>(H n:ℝ))) + (hX : ∀ᶠ n in atTop,(∀ j,X n j≤P n) ∧ (∏ j : Fin m,(X n j:ℝ)^2)≤(P n:ℝ)^2) + (hQ : ∀ᶠ n in atTop,0≤Q n ∧ Q n≤(M n:ℝ)*(P n:ℝ)^2) + (hL : ∀ᶠ n in atTop,0≤L n ∧ L n≤(M n:ℝ)^2) : + (∀ᶠ n in atTop,0(radius (M n) (H n):ℝ)/(Xp n:ℝ)) atTop (𝓝 0) ∧ + (∀ a : ℝ,0((radius (M n) (H n):ℝ)/(M n:ℝ))/ + (1+∑ j : Fin m,(X n j:ℝ)^2)^a) atTop atTop) ∧ + Tendsto (fun n=>(Q n+(∏ j : Fin m,(X n j:ℝ)^2)*L n)/ + (radius (M n) (H n):ℝ)) atTop (𝓝 0) + := by + have hM : ∀ᶠ n in atTop,0h.1) + have hH : ∀ᶠ n in atTop,0h.2.2) + let T : ℕ→ℝ := fun n=>(M n:ℝ)+(P n:ℝ)^2 + have hT : ∀ᶠ n in atTop,1≤T n := by + filter_upwards [hM] with n hn + have hm : (1:ℝ)≤M n := by exact_mod_cast hn + dsimp [T] + nlinarith + have hr := radius_dominates_square hM hd + have hR : ∀ᶠ n in atTop,0(T n)^3/(radius (M n) (H n):ℝ)) atTop (𝓝 0) := by + simpa only [Function.comp_def,inv_div,Real.rpow_natCast] using + tendsto_inv_atTop_zero.comp (hr (3:ℕ) (by norm_num)) + apply squeeze_zero' ?_ ?_ (by simpa using hh.const_mul 2) + · filter_upwards [hQ,hL] with n hq hl + exact div_nonneg (add_nonneg hq.1 (mul_nonneg (Finset.prod_nonneg (fun j _=>sq_nonneg _)) hl.1)) (by positivity) + · filter_upwards [hT,hX,hQ,hL] with n ht hx hq hl + have hmn : (0:ℝ)≤M n := by positivity + have hmT : (M n:ℝ)≤T n := by dsimp [T]; nlinarith + have hpT : (P n:ℝ)^2≤T n := by dsimp [T]; linarith [Nat.cast_nonneg (α:=ℝ) (M n)] + have ht0 : 0≤T n := by linarith + have hb1 : Q n≤(T n)^2 := by + calc + _ ≤ (M n:ℝ)*(P n:ℝ)^2 := hq.2 + _ ≤ T n*T n := mul_le_mul hmT hpT (sq_nonneg _) ht0 + _ = _ := by ring + have hb2 : (∏ j : Fin m,(X n j:ℝ)^2)*L n≤(T n)^3 := by + calc + _ ≤ (P n:ℝ)^2*(M n:ℝ)^2 := mul_le_mul hx.2 hl.2 hl.1 (sq_nonneg _) + _ ≤ T n*(T n)^2 := mul_le_mul hpT (pow_le_pow_left₀ hmn hmT 2) (sq_nonneg _) ht0 + _ = _ := by ring + have ht23 : (T n)^2≤(T n)^3 := by nlinarith [sq_nonneg (T n),mul_nonneg (sq_nonneg (T n)) (sub_nonneg.mpr ht)] + calc + _ ≤ (2*(T n)^3)/(radius (M n) (H n):ℝ) := by + apply div_le_div_of_nonneg_right _ (by positivity) + linarith + _ = _ := by ring + +end AdmissibleArrayScales + +end +end + +end OAI diff --git a/lean/OAI/Combinatorics/SumProduct/Alignment/Main.lean b/lean/OAI/Combinatorics/SumProduct/Alignment/Main.lean new file mode 100644 index 0000000000000000000000000000000000000000..ab4e72c8c3b8c850c951cf5f5aa4298636c87a8a --- /dev/null +++ b/lean/OAI/Combinatorics/SumProduct/Alignment/Main.lean @@ -0,0 +1,258 @@ +import OAI.Combinatorics.SumProduct.Alignment.BooleanRough01 +import OAI.Combinatorics.SumProduct.Alignment.TriangularDenominators01 +import OAI.Combinatorics.SumProduct.Alignment.RationalLattice01 +import OAI.Combinatorics.SumProduct.Alignment.RationalLattice02 +import OAI.Combinatorics.SumProduct.Alignment.RationalLattice03 +import OAI.Combinatorics.SumProduct.Alignment.RationalLattice04 +import OAI.Combinatorics.SumProduct.Alignment.PairTail01 +import OAI.Combinatorics.SumProduct.Alignment.RationalLattice05 +import OAI.Combinatorics.SumProduct.Alignment.IntegerHyperplane01 +import OAI.Combinatorics.SumProduct.Alignment.RationalLattice06 +import OAI.Combinatorics.SumProduct.Alignment.RationalTail01 +import OAI.Combinatorics.SumProduct.Alignment.RationalLattice07 +import OAI.Combinatorics.SumProduct.Alignment.PairTail02 +import OAI.Combinatorics.SumProduct.Alignment.RationalQuotient01 +import OAI.Combinatorics.SumProduct.Alignment.CentralQuotient01 +import OAI.Combinatorics.SumProduct.Alignment.CentralFiber01 +import OAI.Combinatorics.SumProduct.Alignment.CompactConvex01 +import OAI.Combinatorics.SumProduct.Alignment.CoordinateSubspace01 +import OAI.Combinatorics.SumProduct.Alignment.PairTail03 +import OAI.Combinatorics.SumProduct.Alignment.LeibmanSquare01 +import OAI.Combinatorics.SumProduct.Alignment.LeibmanSquare02 +import OAI.Combinatorics.SumProduct.Alignment.MalcevWeighted01 +import OAI.Combinatorics.SumProduct.Alignment.MalcevWeighted02 +import OAI.Combinatorics.SumProduct.Alignment.PairTail04 +import OAI.Combinatorics.SumProduct.Alignment.CubeFaces01 +import OAI.Combinatorics.SumProduct.Alignment.CubePolynomials01 +import OAI.Combinatorics.SumProduct.Alignment.RationalFactor01 +import OAI.Combinatorics.SumProduct.Alignment.PolynomialWeyl01 +import OAI.Combinatorics.SumProduct.Alignment.NearLattice01 +import OAI.Combinatorics.SumProduct.Alignment.WeylInverse01 +import OAI.Combinatorics.SumProduct.Alignment.PolynomialDephasing01 +import OAI.Combinatorics.SumProduct.Alignment.FejerDetection01 +import OAI.Combinatorics.SumProduct.Alignment.DensePolynomial01 +import OAI.Combinatorics.SumProduct.Alignment.LeibmanSquare03 +import OAI.Combinatorics.SumProduct.Alignment.LeibmanSquare04 +import OAI.Combinatorics.SumProduct.Alignment.CompactFamily01 +import OAI.Combinatorics.SumProduct.Alignment.PairTail05 +import OAI.Combinatorics.SumProduct.Alignment.PairTail06 +import OAI.Combinatorics.SumProduct.Alignment.SquareHorizontal01 +import OAI.Combinatorics.SumProduct.Alignment.MalcevHorizontal01 +import OAI.Combinatorics.SumProduct.Alignment.MalcevHorizontal02 +import OAI.Combinatorics.SumProduct.Alignment.PolynomialCharacter01 +import OAI.Combinatorics.SumProduct.Alignment.BracketHyperplanes01 +import OAI.Combinatorics.SumProduct.Alignment.FourierObstruction01 +import OAI.Combinatorics.SumProduct.Alignment.BracketHyperplanes02 +import OAI.Combinatorics.SumProduct.Alignment.BracketDrift01 +import OAI.Combinatorics.SumProduct.Alignment.LeibmanSquare05 +import OAI.Combinatorics.SumProduct.Alignment.MalcevTail01 +import OAI.Combinatorics.SumProduct.Alignment.MalcevTail02 +import OAI.Combinatorics.SumProduct.Alignment.SmoothBinomial01 +import OAI.Combinatorics.SumProduct.Alignment.MalcevTail03 +import OAI.Combinatorics.SumProduct.Alignment.BinomialDifference01 +import OAI.Combinatorics.SumProduct.Alignment.CharacterFactorization01 +import OAI.Combinatorics.SumProduct.Alignment.MalcevHorizontal03 +import OAI.Combinatorics.SumProduct.Alignment.ProgressionPartition01 +import OAI.Combinatorics.SumProduct.Alignment.FiniteCover01 +import OAI.Combinatorics.SumProduct.Alignment.AffineCoefficient01 +import OAI.Combinatorics.SumProduct.Alignment.FactorCoefficient01 +import OAI.Combinatorics.SumProduct.Alignment.IntegerHyperplane02 +import OAI.Combinatorics.SumProduct.Alignment.RationalLattice08 +import OAI.Combinatorics.SumProduct.Alignment.MalcevCharacters01 +import OAI.Combinatorics.SumProduct.Alignment.RationalTail02 +import OAI.Combinatorics.SumProduct.Alignment.AbelianMalcev01 +import OAI.Combinatorics.SumProduct.Alignment.AbelianMalcev02 +import OAI.Combinatorics.SumProduct.Alignment.SquareInduction01 +import OAI.Combinatorics.SumProduct.Alignment.SquareInduction02 +import OAI.Combinatorics.SumProduct.Alignment.TorusVertical01 +import OAI.Combinatorics.SumProduct.Alignment.MalcevCentral01 +import OAI.Combinatorics.SumProduct.Alignment.RationalLattice09 +import OAI.Combinatorics.SumProduct.Alignment.SquareInduction03 +import OAI.Combinatorics.SumProduct.Alignment.SquareInduction04 +import OAI.Combinatorics.SumProduct.Alignment.SquareInduction05 +import OAI.Combinatorics.SumProduct.Alignment.SquareInduction06 +import OAI.Combinatorics.SumProduct.Alignment.SquareInduction07 +import OAI.Combinatorics.SumProduct.Alignment.SquareInduction08 +import OAI.Combinatorics.SumProduct.Alignment.SquareInduction09 +import OAI.Combinatorics.SumProduct.Alignment.SquareInduction10 +import OAI.Combinatorics.SumProduct.Alignment.SquareInduction11 +import OAI.Combinatorics.SumProduct.Alignment.SquareInduction12 +import OAI.Combinatorics.SumProduct.Alignment.SquareInduction13 +import OAI.Combinatorics.SumProduct.Alignment.SquareInduction14 +import OAI.Combinatorics.SumProduct.Alignment.PolynomialLine01 +import OAI.Combinatorics.SumProduct.Alignment.TriangularLattice01 +import OAI.Combinatorics.SumProduct.Alignment.BoxPolynomial01 +import OAI.Combinatorics.SumProduct.Alignment.DenseBox01 +import OAI.Combinatorics.SumProduct.Alignment.CorrectedBox01 +import OAI.Combinatorics.SumProduct.Alignment.CorrectedBox02 +import OAI.Combinatorics.SumProduct.Alignment.CorrectedBox03 +import OAI.Combinatorics.SumProduct.Alignment.CorrectedBox04 +import OAI.Combinatorics.SumProduct.Alignment.CorrectedBox05 +import OAI.Combinatorics.SumProduct.Alignment.ComparableBox01 +import OAI.Combinatorics.SumProduct.Alignment.CorrectedBox06 +import OAI.Combinatorics.SumProduct.Alignment.ComparableBox02 +import OAI.Combinatorics.SumProduct.Alignment.CorrectedBox07 +import OAI.Combinatorics.SumProduct.Alignment.BooleanBinomial01 +import OAI.Combinatorics.SumProduct.Alignment.CubeTaylor01 +import OAI.Combinatorics.SumProduct.Alignment.ScalarDifference01 +import OAI.Combinatorics.SumProduct.Alignment.CubeTaylor02 +import OAI.Combinatorics.SumProduct.Alignment.CubeFaces02 +import OAI.Combinatorics.SumProduct.Alignment.CubeLocal01 +import OAI.Combinatorics.SumProduct.Alignment.CubeLocal02 +import OAI.Combinatorics.SumProduct.Alignment.CubeLocal03 +import OAI.Combinatorics.SumProduct.Alignment.CubeLocal04 +import OAI.Combinatorics.SumProduct.Alignment.CubeLocal05 +import OAI.Combinatorics.SumProduct.Alignment.CubeLocal06 +import OAI.Combinatorics.SumProduct.Alignment.CubeLocal07 +import OAI.Combinatorics.SumProduct.Alignment.CubeLocal08 +import OAI.Combinatorics.SumProduct.Alignment.CubeLocal09 +import OAI.Combinatorics.SumProduct.Alignment.RationalLattice10 +import OAI.Combinatorics.SumProduct.Alignment.TailCharacter01 +import OAI.Combinatorics.SumProduct.Alignment.AllLevel01 +import OAI.Combinatorics.SumProduct.Alignment.AllLevel02 +import OAI.Combinatorics.SumProduct.Alignment.AllLevel03 +import OAI.Combinatorics.SumProduct.Alignment.AllLevel04 +import OAI.Combinatorics.SumProduct.Alignment.ParametricSmooth01 +import OAI.Combinatorics.SumProduct.Alignment.AllLevel05 +import OAI.Combinatorics.SumProduct.Alignment.RationalTriangular01 +import OAI.Combinatorics.SumProduct.Alignment.RationalLattice11 +import OAI.Combinatorics.SumProduct.Alignment.RationalLattice12 +import OAI.Combinatorics.SumProduct.Alignment.RoughKernel01 +import OAI.Combinatorics.SumProduct.Alignment.RoughKernel02 +import OAI.Combinatorics.SumProduct.Alignment.RoughKernel03 +import OAI.Combinatorics.SumProduct.Alignment.UniformSlow01 +import OAI.Combinatorics.SumProduct.Alignment.RoughSampling01 +import OAI.Combinatorics.SumProduct.Alignment.FinitePiece01 +import OAI.Combinatorics.SumProduct.Alignment.RegularResidue01 +import OAI.Combinatorics.SumProduct.Alignment.RoughKernel04 +import OAI.Combinatorics.SumProduct.Alignment.RoughSampling02 +import OAI.Combinatorics.SumProduct.Alignment.ConstantCoefficient01 +import OAI.Combinatorics.SumProduct.Alignment.RoughJoint01 +import OAI.Combinatorics.SumProduct.Alignment.LagrangeBounds01 +import OAI.Combinatorics.SumProduct.Alignment.RoughInterpolation01 +import OAI.Combinatorics.SumProduct.Alignment.DenseRough01 +import OAI.Combinatorics.SumProduct.Alignment.CoefficientPeeling01 +import OAI.Combinatorics.SumProduct.Alignment.RoughLog01 +import OAI.Combinatorics.SumProduct.Alignment.RoughReal01 +import OAI.Combinatorics.SumProduct.Alignment.RoughDyadic01 +import OAI.Combinatorics.SumProduct.Alignment.RoughRational01 +import OAI.Combinatorics.SumProduct.Alignment.RoughPhysical01 +import OAI.Combinatorics.SumProduct.Alignment.RoughKernel05 +import OAI.Combinatorics.SumProduct.Alignment.RoughSplit01 +import OAI.Combinatorics.SumProduct.Alignment.RoughDimension01 +import OAI.Combinatorics.SumProduct.Alignment.RoughExtremal01 +import OAI.Combinatorics.SumProduct.Alignment.RoughLiteral01 +import OAI.Combinatorics.SumProduct.Alignment.BooleanRough02 +import OAI.Combinatorics.SumProduct.Alignment.DenseBoolean01 +import OAI.Combinatorics.SumProduct.Alignment.CubeParameter01 +import OAI.Combinatorics.SumProduct.Alignment.RoughCube01 +import OAI.Combinatorics.SumProduct.Alignment.CubeRationalization01 +import OAI.Combinatorics.SumProduct.Alignment.CubeKernel01 +import OAI.Combinatorics.SumProduct.Alignment.RoughCube02 +import OAI.Combinatorics.SumProduct.Alignment.RoughProduct01 +import OAI.Combinatorics.SumProduct.Alignment.RoughProduct02 +import OAI.Combinatorics.SumProduct.Alignment.RoughProduct03 +import OAI.Combinatorics.SumProduct.Alignment.RoughFace01 +import OAI.Combinatorics.SumProduct.Alignment.HarmonicExposure01 +import OAI.Combinatorics.SumProduct.Alignment.HarmonicExposure02 +import OAI.Combinatorics.SumProduct.Alignment.MicrocellHarmonic01 +import OAI.Combinatorics.SumProduct.Alignment.PointLaw01 +import OAI.Combinatorics.SumProduct.Alignment.PointLaw02 +import OAI.Combinatorics.SumProduct.Alignment.MicrocellScale01 +import OAI.Combinatorics.SumProduct.Alignment.UnitInterval01 +import OAI.Combinatorics.SumProduct.Alignment.DyadicHarmonic01 +import OAI.Combinatorics.SumProduct.Alignment.RawHarmonic01 +import OAI.Combinatorics.SumProduct.Alignment.MicrocellFibers01 +import OAI.Combinatorics.SumProduct.Alignment.MicrocellSaturation01 +import OAI.Combinatorics.SumProduct.Alignment.ProductExposure01 +import OAI.Combinatorics.SumProduct.Alignment.ProductExposure02 +import OAI.Combinatorics.SumProduct.Alignment.ProductExposure03 +import OAI.Combinatorics.SumProduct.Alignment.RoughFace02 +import OAI.Combinatorics.SumProduct.Alignment.RoughFace03 +import OAI.Combinatorics.SumProduct.Alignment.RoughCovered01 +import OAI.Combinatorics.SumProduct.Alignment.RoughCovered02 +import OAI.Combinatorics.SumProduct.Alignment.RoughTopological01 +import OAI.Combinatorics.SumProduct.Alignment.RoughTopological02 +import OAI.Combinatorics.SumProduct.Alignment.RoughTopological03 +import OAI.Combinatorics.SumProduct.Alignment.RationalLattice13 +import OAI.Combinatorics.SumProduct.Alignment.WeightedPolynomial01 +import OAI.Combinatorics.SumProduct.Alignment.FilteredShears01 +import OAI.Combinatorics.SumProduct.Alignment.WeightedPolynomial02 +import OAI.Combinatorics.SumProduct.Alignment.RationalLattice14 +import OAI.Combinatorics.SumProduct.Alignment.RationalLattice15 +import OAI.Combinatorics.SumProduct.Alignment.PolynomialArray01 +import OAI.Combinatorics.SumProduct.Alignment.RationalLattice16 +import OAI.Combinatorics.SumProduct.Alignment.RationalLattice17 +import OAI.Combinatorics.SumProduct.Alignment.RationalLattice18 +import OAI.Combinatorics.SumProduct.Alignment.RationalLattice19 +import OAI.Combinatorics.SumProduct.Alignment.RoughArray01 +import OAI.Combinatorics.SumProduct.Alignment.RoughArray02 +import OAI.Combinatorics.SumProduct.Alignment.RoughArray03 +import OAI.Combinatorics.SumProduct.Alignment.IntegerAlignment01 +import OAI.Combinatorics.SumProduct.Alignment.ResidueAlignment01 +import OAI.Combinatorics.SumProduct.Alignment.ProductExposure04 +import OAI.Combinatorics.SumProduct.Alignment.RoughArray04 +import OAI.Combinatorics.SumProduct.Alignment.IntegerArrays01 +import OAI.Combinatorics.SumProduct.Alignment.IntegerArrays02 +import OAI.Combinatorics.SumProduct.Alignment.RationalLattice20 +import OAI.Combinatorics.SumProduct.Alignment.ComparableBox03 +import OAI.Combinatorics.SumProduct.Alignment.CubeRational01 +import OAI.Combinatorics.SumProduct.Alignment.EmbeddedCube01 +import OAI.Combinatorics.SumProduct.Alignment.AllLevel06 +import OAI.Combinatorics.SumProduct.Alignment.AllLevel07 +import OAI.Combinatorics.SumProduct.Alignment.AllLevel08 +import OAI.Combinatorics.SumProduct.Alignment.AllLevel09 +import OAI.Combinatorics.SumProduct.Alignment.PhysicalDecay01 +import OAI.Combinatorics.SumProduct.Alignment.RationalLattice21 +import OAI.Combinatorics.SumProduct.Alignment.RationalLattice22 +import OAI.Combinatorics.SumProduct.Alignment.IntegerArrays03 +import OAI.Combinatorics.SumProduct.Alignment.IntegerArrays04 +import OAI.Combinatorics.SumProduct.Alignment.RationalLattice23 +import OAI.Combinatorics.SumProduct.Alignment.GlobalPoint01 +import OAI.Combinatorics.SumProduct.Alignment.AllLevel10 +import OAI.Combinatorics.SumProduct.Alignment.AllLevel11 +import OAI.Combinatorics.SumProduct.Alignment.WordPlan01 +import OAI.Combinatorics.SumProduct.Alignment.WeightedBoxes01 +import OAI.Combinatorics.SumProduct.Alignment.WeightedLinear01 +import OAI.Combinatorics.SumProduct.Alignment.RationalLattice24 +import OAI.Combinatorics.SumProduct.Alignment.AlignmentMass01 +import OAI.Combinatorics.SumProduct.Alignment.WordPlan02 +import OAI.Combinatorics.SumProduct.Alignment.CoveringSubspace01 +import OAI.Combinatorics.SumProduct.Alignment.RationalLattice25 +import OAI.Combinatorics.SumProduct.Alignment.AllLevel12 +import OAI.Combinatorics.SumProduct.Alignment.AffineOrbit01 +import OAI.Combinatorics.SumProduct.Alignment.WordPlan03 +import OAI.Combinatorics.SumProduct.Alignment.RationalEchelon01 +import OAI.Combinatorics.SumProduct.Alignment.RationalEchelon02 +import OAI.Combinatorics.SumProduct.Alignment.RationalLattice26 +import OAI.Combinatorics.SumProduct.Alignment.RationalLattice27 +import OAI.Combinatorics.SumProduct.Alignment.AllLevel13 +import OAI.Combinatorics.SumProduct.Alignment.WordPlan04 +import OAI.Combinatorics.SumProduct.Alignment.AllLevel14 +import OAI.Combinatorics.SumProduct.Alignment.AllLevel15 +import OAI.Combinatorics.SumProduct.Alignment.IntegerArrays05 +import OAI.Combinatorics.SumProduct.Alignment.IntegerArrays06 +import OAI.Combinatorics.SumProduct.Alignment.IntegerArrays07 +import OAI.Combinatorics.SumProduct.Alignment.IntegerArrays08 +import OAI.Combinatorics.SumProduct.Alignment.MacroSelection01 +import OAI.Combinatorics.SumProduct.Alignment.IntegerArrays09 +import OAI.Combinatorics.SumProduct.Alignment.IntegerArrays10 +import OAI.Combinatorics.SumProduct.Alignment.MacroSelection02 +import OAI.Combinatorics.SumProduct.Alignment.IntegerArrays11 +import OAI.Combinatorics.SumProduct.Alignment.IntegerArrays12 +import OAI.Combinatorics.SumProduct.Alignment.IntegerArrays13 +import OAI.Combinatorics.SumProduct.Alignment.IntegerArrays14 +import OAI.Combinatorics.SumProduct.Alignment.HarmonicTranslation01 +import OAI.Combinatorics.SumProduct.Alignment.PivotExtension01 +import OAI.Combinatorics.SumProduct.Alignment.PivotExtension02 +import OAI.Combinatorics.SumProduct.Alignment.IntegerArrays15 +import OAI.Combinatorics.SumProduct.Alignment.HierarchyRates01 +import OAI.Combinatorics.SumProduct.Alignment.PivotPaths01 +import OAI.Combinatorics.SumProduct.Alignment.PivotPaths02 +import OAI.Combinatorics.SumProduct.Alignment.PivotPaths03 +import OAI.Combinatorics.SumProduct.Alignment.FiniteMenu01 +import OAI.Combinatorics.SumProduct.Alignment.Blocks01 +import OAI.Combinatorics.SumProduct.Alignment.Admissible01 +import OAI.Combinatorics.SumProduct.Alignment.Blocks02 +import OAI.Combinatorics.SumProduct.Alignment.MenuLiteral01 +import OAI.Combinatorics.SumProduct.Alignment.RawMenu diff --git a/lean/OAI/Combinatorics/SumProduct/Alignment/MalcevCentral01.lean b/lean/OAI/Combinatorics/SumProduct/Alignment/MalcevCentral01.lean new file mode 100644 index 0000000000000000000000000000000000000000..38d28e5c36c4a6d6deea500715d5358bbe30ba1a --- /dev/null +++ b/lean/OAI/Combinatorics/SumProduct/Alignment/MalcevCentral01.lean @@ -0,0 +1,275 @@ +import Mathlib +import OAI.Combinatorics.SumProduct.Alignment.AbelianMalcev02 +import OAI.Combinatorics.SumProduct.Alignment.TorusVertical01 +import OAI.Geometry.NilpotentCharts.Main + +namespace OAI + +section +section +section +section + +end + + + +section +noncomputable section +namespace AbelianMalcevTorus +open RationalLattice +variable {G : Type*} [Group G] [TopologicalSpace G] [IsTopologicalGroup G] +variable {n : ℕ} (c : RealCoordinates G n) +variable (hadd : ∀ g h : G, ∀ i : Fin n, c.coord (g*h) i=c.coord g i+c.coord h i) +variable (Γ : Subgroup G) (hΓ : ∀ g : G, g∈Γ ↔ ∀ i, ∃ z : ℤ, c.coord g i=z) +variable [Γ.Normal] + +omit [IsTopologicalGroup G] in +lemma quotientHomeomorph_one : quotientHomeomorph c hadd Γ hΓ 1=0 := + torusProjection_one c + +omit [IsTopologicalGroup G] in +lemma quotientHomeomorph_mul (x y : G⧸Γ) : + quotientHomeomorph c hadd Γ hΓ (x*y)= + quotientHomeomorph c hadd Γ hΓ x+quotientHomeomorph c hadd Γ hΓ y := by + induction x using Quotient.inductionOn with | h g => + induction y using Quotient.inductionOn with | h a => + exact torusProjection_mul c hadd g a + +omit [IsTopologicalGroup G] in +lemma quotientHomeomorph_symm_zero : (quotientHomeomorph c hadd Γ hΓ).symm 0=1 := by + apply (quotientHomeomorph c hadd Γ hΓ).injective + rw [Homeomorph.apply_symm_apply,quotientHomeomorph_one] + +omit [IsTopologicalGroup G] in +lemma quotientHomeomorph_symm_add (x y : UnitAddTorus (Fin n)) : + (quotientHomeomorph c hadd Γ hΓ).symm (x+y)= + (quotientHomeomorph c hadd Γ hΓ).symm x*(quotientHomeomorph c hadd Γ hΓ).symm y := by + apply (quotientHomeomorph c hadd Γ hΓ).injective + rw [quotientHomeomorph_mul] + simp only [Homeomorph.apply_symm_apply] +end AbelianMalcevTorus + +namespace MalcevCentralTorus +open RationalLattice AbelianMalcevTorus MeasureTheory +variable {G : Type*} [Group G] [TopologicalSpace G] [IsTopologicalGroup G] +variable (N Γ : Subgroup G) (hN : N ≤ Subgroup.center G) +variable [(Γ.comap N.subtype).Normal] +variable {d : ℕ} (c : RealCoordinates N d) +variable (hadd : ∀ g h : N, ∀ i, c.coord (g*h) i=c.coord g i+c.coord h i) +variable (hΓ : ∀ g : N, g∈Γ.comap N.subtype ↔ ∀ i, ∃ z : ℤ, c.coord g i=z) + + + +@[instance_reducible] +def addAction : AddAction (UnitAddTorus (Fin d)) (G⧸Γ) := by + letI := CentralQuotientAction.action N Γ hN + let e := quotientHomeomorph c hadd (Γ.comap N.subtype) hΓ + exact { vadd := fun t x => e.symm t • x + zero_vadd := fun x => by + change e.symm 0 • x=x + rw [quotientHomeomorph_symm_zero,one_smul] + add_vadd := fun s t x => by + change e.symm (s+t) • x=e.symm s • (e.symm t • x) + rw [quotientHomeomorph_symm_add,mul_smul] } + +lemma continuous_addAction : + letI := addAction N Γ hN c hadd hΓ + ContinuousVAdd (UnitAddTorus (Fin d)) (G⧸Γ) := by + let := addAction N Γ hN c hadd hΓ + let := CentralQuotientAction.action N Γ hN + let := CentralQuotientAction.continuous_action N Γ hN + constructor + exact ((quotientHomeomorph c hadd (Γ.comap N.subtype) hΓ).symm.continuous.comp continuous_fst).smul continuous_snd + +omit [IsTopologicalGroup G] in +lemma torusProjection_vadd (n : N) (g : G) : + letI := addAction N Γ hN c hadd hΓ + torusProjection c n +ᵥ (QuotientGroup.mk g : G⧸Γ) = QuotientGroup.mk (g*n.val) := by + let := addAction N Γ hN c hadd hΓ + let := CentralQuotientAction.action N Γ hN + change (quotientHomeomorph c hadd (Γ.comap N.subtype) hΓ).symm + (quotientHomeomorph c hadd (Γ.comap N.subtype) hΓ (QuotientGroup.mk n)) • QuotientGroup.mk g = _ + rw [Homeomorph.symm_apply_apply] + change QuotientGroup.mk (n.val*g)=QuotientGroup.mk (g*n.val) + rw [Subgroup.mem_center_iff.mp (hN n.property) g] + +omit [IsTopologicalGroup G] in +lemma invariant_addAction [MeasurableSpace (G⧸Γ)] + (μ : Measure (G⧸Γ)) [SMulInvariantMeasure G (G⧸Γ) μ] : + letI := addAction N Γ hN c hadd hΓ + VAddInvariantMeasure (UnitAddTorus (Fin d)) (G⧸Γ) μ := by + let := addAction N Γ hN c hadd hΓ + let := CentralQuotientAction.action N Γ hN + let : N.Normal := ⟨fun x hx g => by + rw [Subgroup.mem_center_iff.mp (hN hx) g,mul_assoc,mul_inv_cancel,mul_one] + exact hx⟩ + let := CentralQuotientAction.invariant_central_action N Γ hN μ + constructor + intro t s hs + exact SMulInvariantMeasure.measure_preimage_smul (μ:=μ) + ((quotientHomeomorph c hadd (Γ.comap N.subtype) hΓ).symm t) hs + +end MalcevCentralTorus +end +end + + + +section +noncomputable section +namespace MalcevCentralTorus +open RationalLattice MalcevCharacters RationalTailCoordinates AbelianMalcevTorus +variable {G : Type*} [Group G] [TopologicalSpace G] [IsTopologicalGroup G] +variable {r d : ℕ} (c : RealCoordinates G (r+d)) (hsk : SecondKind c) +variable (N Γ : Subgroup G) (hcent : N ≤ Subgroup.center G) +variable (hN : ∀ g : G, g∈N ↔ ∀ i : Fin (r+d), i.val Subtype.ext ((Subgroup.mem_center_iff.mp (hcent a.property) b.val).symm)) + +include hcent in +omit [TopologicalSpace G] [IsTopologicalGroup G] in +lemma central_lattice_normal : (Γ.comap N.subtype).Normal := by + constructor + intro a ha b + have he : b*a=a*b := Subtype.ext ((Subgroup.mem_center_iff.mp (hcent b.property) a.val).symm) + rw [he,mul_assoc,mul_inv_cancel,mul_one] + exact ha + +include hsk hcent hN in +lemma tail_additive : ∀ a b : N, ∀ i, + (tailCoordinates c N hN).coord (a*b) i= + (tailCoordinates c N hN).coord a i+(tailCoordinates c N hN).coord b i := by + apply coordinates_additive_of_commutator_bot (tailCoordinates c N hN) (tail_secondKind c N hN hsk) + exact ((commutator_eq_bot_iff N).mpr (central_commutative N hcent)).le + +@[instance_reducible] +def tailAction : AddAction (UnitAddTorus (Fin d)) (G⧸Γ) := + letI := central_lattice_normal N Γ hcent + addAction N Γ hcent (tailCoordinates c N hN) (tail_additive c hsk N hcent hN) + (tailCoordinates_lattice c N hN Γ hΓ) + +lemma continuous_tailAction : + letI := tailAction c hsk N Γ hcent hN hΓ + ContinuousVAdd (UnitAddTorus (Fin d)) (G⧸Γ) := by + let := central_lattice_normal N Γ hcent + exact continuous_addAction N Γ hcent (tailCoordinates c N hN) (tail_additive c hsk N hcent hN) + (tailCoordinates_lattice c N hN Γ hΓ) + +lemma tailProjection_vadd (a : N) (g : G) : + letI := tailAction c hsk N Γ hcent hN hΓ + torusProjection (tailCoordinates c N hN) a +ᵥ (QuotientGroup.mk g : G⧸Γ)=QuotientGroup.mk (g*a.val) := by + let := central_lattice_normal N Γ hcent + exact torusProjection_vadd N Γ hcent (tailCoordinates c N hN) (tail_additive c hsk N hcent hN) + (tailCoordinates_lattice c N hN Γ hΓ) a g + +lemma invariant_tailAction [MeasurableSpace (G⧸Γ)] (μ : MeasureTheory.Measure (G⧸Γ)) + [MeasureTheory.SMulInvariantMeasure G (G⧸Γ) μ] : + letI := tailAction c hsk N Γ hcent hN hΓ + MeasureTheory.VAddInvariantMeasure (UnitAddTorus (Fin d)) (G⧸Γ) μ := by + let := central_lattice_normal N Γ hcent + exact invariant_addAction N Γ hcent (tailCoordinates c N hN) (tail_additive c hsk N hcent hN) + (tailCoordinates_lattice c N hN Γ hΓ) μ + +end MalcevCentralTorus +end +end + + + +section +noncomputable section +namespace TorusVerticalFourier +open UnitAddTorus AddCircle +variable {d : Type*} [Fintype d] + +lemma character_norm (k : d→ℤ) (s : UnitAddTorus d) : ‖mFourier k s‖=1 := by + simp only [mFourier,ContinuousMap.coe_mk,norm_prod,fourier_apply,Circle.norm_coe,Finset.prod_const_one] + +lemma character_nontrivial {k : d→ℤ} (hk : k≠0) : ∃ s : UnitAddTorus d, mFourier k s≠1 := by + classical + obtain ⟨i,hi⟩ : ∃ i, k i≠0 := by + contrapose! hk + exact funext hk + let s : UnitAddTorus d := Pi.single i (((1 / 2 / (k i : ℝ) : ℝ) : UnitAddCircle)) + have hs : mFourier k s = -1 := by + rw [mFourier] + simp only [ContinuousMap.coe_mk] + rw [Finset.prod_eq_single i] + · simp only [s,Pi.single_eq_same] + simpa only [zero_add,fourier_eval_zero] using + (fourier_add_half_inv_index (T := 1) hi (by norm_num) (0 : UnitAddCircle)) + · intro j _ hji + simp [s,Pi.single_eq_of_ne hji] + · simp + exact ⟨s,by rw [hs]; norm_num⟩ + +variable {X : Type*} [MetricSpace X] [CompactSpace X] + [AddAction (UnitAddTorus d) X] [ContinuousVAdd (UnitAddTorus d) X] +omit [CompactSpace X] [ContinuousVAdd (UnitAddTorus d) X] in +lemma HasWeight.smul {k : d→ℤ} {F : C(X,ℂ)} (hF : HasWeight k F) (z : ℂ) : HasWeight k (z • F) := by + intro s x + change z*F (s+ᵥx)=mFourier k s*(z*F x) + rw [hF] + ring + +end TorusVerticalFourier +end +end + + + +section +noncomputable section +open _root_.Polynomial _root_.OAI.Polynomial +open scoped BigOperators +namespace AbelianMalcevTorus +open RationalLattice CubeFaces LeibmanSquare MeasureTheory MalcevHorizontal +variable {G : Type*} [Group G] [TopologicalSpace G] [IsTopologicalGroup G] +variable {n : ℕ} (c : RealCoordinates G n) +variable (hadd : ∀ g h : G, ∀ i : Fin n, c.coord (g*h) i=c.coord g i+c.coord h i) +variable (Γ : Subgroup G) (hΓ : ∀ g : G, g∈Γ ↔ ∀ i, ∃ z : ℤ, c.coord g i=z) +variable [MeasurableSpace (G⧸Γ)] [hBorel : @BorelSpace (G⧸Γ) (QuotientGroup.instTopologicalSpace Γ) inferInstance] +variable [mtr : MetricSpace (G⧸Γ)] +variable (htop : mtr.toUniformSpace.toTopologicalSpace=QuotientGroup.instTopologicalSpace Γ) +local instance : TopologicalSpace (G⧸Γ) := mtr.toUniformSpace.toTopologicalSpace + +include hadd hΓ htop in + + +theorem quantitative_abelian_compact_producer (H : Filtration G) (s : ℕ) (hs : H.level (s+1)=⊥) + (μ : Measure (G⧸Γ)) [IsProbabilityMeasure μ] [SMulInvariantMeasure G (G⧸Γ) μ] + (K : Set C(G⧸Γ,ℂ)) (hK : IsCompact K) (δ : ℝ) (hδ : 0<δ) : + letI : CompactSpace (G⧸Γ) := metric_compact c Γ hΓ mtr htop + letI : BorelSpace (G⧸Γ) := metric_borelSpace Γ mtr htop + ∃ U : Finset (G →* Multiplicative ℝ), + (∀ χ∈U, Continuous χ ∧ (∀ g∈Γ, ∃ z : ℤ, (χ g).toAdd=z)) ∧ + ∃ A : ℝ, 0 QuotientGroup.mk (f k)) F‖) → + ∃ χ∈U, χ≠1 ∧ ∃ P : ℝ[X], P.natDegree ≤ s ∧ + (∀ z : ℤ, P.eval (z:ℝ)=(χ (f z)).toAdd) ∧ + ∀ j : ℕ, 0 QuotientGroup.mk (f k))) + (FourierObstruction.discrepancy_bound μ N hN _) hdisc + exact ⟨F,(hS F hF).1,(hS F hF).2,hlarge⟩ + +end AbelianMalcevTorus + +end +end +end +end +end + +end OAI diff --git a/lean/OAI/Combinatorics/SumProduct/Alignment/MalcevCharacters01.lean b/lean/OAI/Combinatorics/SumProduct/Alignment/MalcevCharacters01.lean new file mode 100644 index 0000000000000000000000000000000000000000..fccdb7a7acdaf04932b498a2eccc73a197cee9a6 --- /dev/null +++ b/lean/OAI/Combinatorics/SumProduct/Alignment/MalcevCharacters01.lean @@ -0,0 +1,320 @@ +import Mathlib +import OAI.Combinatorics.SumProduct.Alignment.RationalLattice08 +import OAI.Geometry.NilpotentCharts.Main + +namespace OAI + +section +section +section +section +open scoped BigOperators +noncomputable section +end +end + + + +section +noncomputable section +open scoped BigOperators +namespace RationalLattice +variable {G K : Type*} [Group G] [Group K] [TopologicalSpace G] [TopologicalSpace K] +variable {m n : ℕ} (c : RealCoordinates G m) (d : RealCoordinates K n) +variable (F : K →* G) +variable (hpoly : ∀ i, RationalPolynomialMap.IsPolynomial (fun x : Fin n → ℝ => c.coord (F (d.coord.symm x)) i)) + +include hpoly in + + +theorem rationalHom_origin_grid : ∃ E : ℕ, 0 < E ∧ ∀ x : Fin n → ℝ, + (∀ j, ∃ z : ℤ, x j = (E:ℝ)*(z:ℝ)) → + ∀ i, ∃ z : ℤ, c.coord (F (d.coord.symm x)) i = z := by + classical + choose P hP using hpoly + choose D hD hgrid using (fun i => TriangularDenominators.polynomial_origin_grid_real (P i)) + let E := ∏ i, D i + have hE : 0 < E := Finset.prod_pos (fun i _ => hD i) + refine ⟨E,hE,?_⟩ + intro x hx i + have hDi : D i ∣ E := Finset.dvd_prod_of_mem D (Finset.mem_univ i) + have hzero : d.coord.symm (fun _ => 0) = 1 := by + apply d.coord.injective + funext j + rw [Homeomorph.apply_symm_apply,d.one_coord] + have hP0 : MvPolynomial.eval₂ (algebraMap ℚ ℝ) (fun _ => 0) (P i) = 0 := by + rw [← hP i] + change c.coord (F (d.coord.symm (fun _ => 0))) i = 0 + rw [hzero,map_one,c.one_coord] + obtain ⟨z,hz⟩ := hgrid i 1 x (by + intro j + obtain ⟨a,ha⟩ := hx j + obtain ⟨b,hb⟩ := hDi + refine ⟨(b:ℤ)*a,?_⟩ + rw [ha,hb] + push_cast + ring) + refine ⟨z,?_⟩ + change ((fun x => c.coord (F (d.coord.symm x)) i) x) = (z:ℝ) + rw [hP i] + simpa only [hP0,sub_zero,Nat.cast_one,one_mul] using hz + +variable [IsTopologicalGroup G] [IsTopologicalGroup K] +variable (Γ : Subgroup G) +variable (hΓ : ∀ g : G, g ∈ Γ ↔ ∀ i, ∃ z : ℤ, c.coord g i = z) +variable (hc : Continuous F) (hinj : Function.Injective F) +include hpoly hΓ hc hinj in + + +theorem exists_integer_sublattice : + ∃ Λ : Subgroup K, ∃ e : RealCoordinates K n, + (∀ g : K, g ∈ Λ ↔ ∀ i, ∃ z : ℤ, e.coord g i = z) ∧ + Λ ≤ Γ.comap F ∧ (Λ.subgroupOf (Γ.comap F)).FiniteIndex ∧ + (∀ g : K, ∀ i, e.coord g i = 0 ↔ d.coord g i = 0) := by + classical + obtain ⟨E,hE,hgrid⟩ := rationalHom_origin_grid c d F hpoly + obtain ⟨w,hpos,hEw,hw⟩ := exists_lattice_weights d E hE + let Λ := weightedLattice d w hw + let e := scaledCoordinates d w hpos + have hΛ : ∀ g : K, g ∈ Λ ↔ ∀ i, ∃ z : ℤ, e.coord g i = z := + weightedLattice_iff d w hw hpos + have hle : Λ ≤ Γ.comap F := by + intro g hg + apply (hΓ (F g)).mpr + have hx : ∀ j, ∃ z : ℤ, d.coord g j = (E:ℝ)*(z:ℝ) := by + intro j + obtain ⟨a,ha⟩ := hg j + obtain ⟨b,hb⟩ := hEw j + refine ⟨(b:ℤ)*a,?_⟩ + rw [ha,hb] + push_cast + ring + simpa using hgrid (d.coord g) hx + let : T2Space K := d.coord.symm.t2Space + let : DiscreteTopology Γ := integerCoordinates_discrete c Γ hΓ + let : DiscreteTopology (Γ.comap F) := + DiscreteTopology.preimage_of_continuous_injective (Γ : Set G) hc hinj + obtain ⟨C,hC,hrep⟩ := compact_reps_of_integerCoordinates e Λ hΛ + have hi := TriangularDenominators.finiteIndex_of_compact_reps Λ (Γ.comap F) hle C hC hrep + refine ⟨Λ,e,hΛ,hle,hi,?_⟩ + intro g i + change d.coord g i/(w i:ℝ) = 0 ↔ d.coord g i = 0 + rw [div_eq_zero_iff] + have hne : (w i:ℝ) ≠ 0 := by exact_mod_cast (hpos i).ne' + simp [hne] + +end RationalLattice + +namespace FiniteCoverCharacters +variable {G : Type*} [Group G] +variable (Λ Γ : Subgroup G) (hle : Λ ≤ Γ) [(Λ.subgroupOf Γ).FiniteIndex] + + + +def denominator : ℕ := (Λ.subgroupOf Γ).index.factorial + +omit [(Λ.subgroupOf Γ).FiniteIndex] in +lemma denominator_pos [(Λ.subgroupOf Γ).FiniteIndex] : + 0 < denominator Λ Γ := Nat.factorial_pos _ + +include hle in +lemma pow_denominator_mem (g : G) (hg : g ∈ Γ) : g^(denominator Λ Γ) ∈ Λ := by + have he := (Λ.subgroupOf Γ).pow_mem_of_index_ne_zero_of_dvd + (Subgroup.FiniteIndex.index_ne_zero) (⟨g,hg⟩ : Γ) + (n:=denominator Λ Γ) (fun m hm hmi => Nat.dvd_factorial hm hmi) + exact (Subgroup.subgroupOfEquivOfLe hle ⟨_,he⟩).property + +include hle in +lemma integral_after_scaling (χ : G →* Multiplicative ℝ) + (hz : ∀ g ∈ Λ, ∃ z : ℤ, Multiplicative.toAdd (χ g) = z) : + ∀ g ∈ Γ, ∃ z : ℤ, (denominator Λ Γ:ℝ)*Multiplicative.toAdd (χ g) = z := by + intro g hg + obtain ⟨z,hz⟩ := hz _ (pow_denominator_mem Λ Γ hle g hg) + refine ⟨z,?_⟩ + simpa only [map_pow,toAdd_pow,nsmul_eq_mul] using hz + +end FiniteCoverCharacters + +end +end + + + +section +noncomputable section +open scoped BigOperators commutatorElement +namespace MalcevCharacters +open RationalLattice +variable {G : Type*} [Group G] [TopologicalSpace G] [IsTopologicalGroup G] +variable {n : ℕ} (c : RealCoordinates G n) (hsk : SecondKind c) +variable (N : Subgroup G) [N.Normal] (hcomm : _root_.commutator G ≤ N) + +include hsk hcomm in + + +omit [IsTopologicalGroup G] in +lemma quotient_coord_add [IsTopologicalGroup G] (x y : Fin n → ℝ) : + (QuotientGroup.mk (c.coord.symm (x+y)) : G ⧸ N) = + QuotientGroup.mk (c.coord.symm x) * QuotientGroup.mk (c.coord.symm y) := by + let : IsMulCommutative (G ⧸ N) := + Subgroup.Normal.quotient_commutative_iff_commutator_le.mpr hcomm + let : CommGroup (G ⧸ N) := { (inferInstance : Group (G ⧸ N)) with mul_comm := mul_comm' } + have he (v : Fin n → ℝ) : (QuotientGroup.mk (c.coord.symm v) : G ⧸ N) = + (List.ofFn (fun i => QuotientGroup.mk (axis c i (v i)) : Fin n → G ⧸ N)).prod := by + conv_lhs => rw [hsk.ordered (c.coord.symm v)] + change (QuotientGroup.mk' N) (List.ofFn _ |>.prod) = _ + rw [map_list_prod,List.map_ofFn] + simp only [Homeomorph.apply_symm_apply] + rfl + rw [he,he,he] + simp_rw [Pi.add_apply,hsk.axis_add,QuotientGroup.mk_mul] + simp only [List.prod_ofFn,Finset.prod_mul_distrib] + + + +def quotientParameterHom : Multiplicative (Fin n → ℝ) →* G ⧸ N where + toFun x := QuotientGroup.mk (c.coord.symm x.toAdd) + map_one' := by + have h0 : c.coord.symm (0 : Fin n → ℝ) = 1 := by + apply c.coord.injective + ext i + simp only [Homeomorph.apply_symm_apply,Pi.zero_apply,c.one_coord] + change QuotientGroup.mk (c.coord.symm 0) = 1 + rw [h0] + rfl + map_mul' x y := quotient_coord_add c hsk N hcomm x.toAdd y.toAdd + +lemma quotientParameterHom_surjective : Function.Surjective (quotientParameterHom c hsk N hcomm) := by + intro x + obtain ⟨g,rfl⟩ := QuotientGroup.mk'_surjective N x + exact ⟨Multiplicative.ofAdd (c.coord g),by simp [quotientParameterHom]⟩ + +variable (k : Fin n → ℝ) +def linearParameterHom : Multiplicative (Fin n → ℝ) →* Multiplicative ℝ where + toFun x := Multiplicative.ofAdd (∑ i, x.toAdd i * k i) + map_one' := by apply Multiplicative.toAdd.injective; simp + map_mul' x y := by + apply Multiplicative.toAdd.injective + change (∑ i, (x.toAdd i+y.toAdd i)*k i) = _ + simp [add_mul,Finset.sum_add_distrib] + +variable (hzero : ∀ g ∈ N, ∑ i, c.coord g i * k i = 0) +include hzero in +lemma parameter_kernel_le : (quotientParameterHom c hsk N hcomm).ker ≤ (linearParameterHom k).ker := by + intro x hx + have hxN : c.coord.symm x.toAdd ∈ N := (QuotientGroup.eq_one_iff _).mp hx + apply Multiplicative.toAdd.injective + have hz := hzero _ hxN + simpa [linearParameterHom] using hz + +def abelianCoordinateCharacter : G →* Multiplicative ℝ := + ((quotientParameterHom c hsk N hcomm).liftOfSurjective + (quotientParameterHom_surjective c hsk N hcomm) + ⟨linearParameterHom k,parameter_kernel_le c hsk N hcomm k hzero⟩).comp (QuotientGroup.mk' N) + +lemma abelianCoordinateCharacter_apply (g : G) : + Multiplicative.toAdd (abelianCoordinateCharacter c hsk N hcomm k hzero g) = + ∑ i, c.coord g i * k i := by + let x := Multiplicative.ofAdd (c.coord g) + have hx : quotientParameterHom c hsk N hcomm x = QuotientGroup.mk g := by + simp [quotientParameterHom,x] + have hh := (quotientParameterHom c hsk N hcomm).liftOfRightInverse_comp_apply + (Function.surjInv (quotientParameterHom_surjective c hsk N hcomm)) + (Function.rightInverse_surjInv (quotientParameterHom_surjective c hsk N hcomm)) + (⟨linearParameterHom k,parameter_kernel_le c hsk N hcomm k hzero⟩) x + have hh' := congrArg Multiplicative.toAdd hh + change Multiplicative.toAdd ((quotientParameterHom c hsk N hcomm).liftOfSurjective + (quotientParameterHom_surjective c hsk N hcomm) + ⟨linearParameterHom k,parameter_kernel_le c hsk N hcomm k hzero⟩ + (QuotientGroup.mk g)) = _ + simpa only [hx,linearParameterHom,MonoidHom.coe_mk,OneHom.coe_mk,toAdd_ofAdd,x] using hh' + +lemma abelianCoordinateCharacter_continuous : + Continuous (abelianCoordinateCharacter c hsk N hcomm k hzero) := by + change Continuous (fun g => Multiplicative.ofAdd (Multiplicative.toAdd + (abelianCoordinateCharacter c hsk N hcomm k hzero g))) + simp_rw [abelianCoordinateCharacter_apply] + exact continuous_ofAdd.comp (continuous_finsetSum _ (fun i _ => + ((continuous_apply i).comp c.coord.continuous).mul_const (k i))) + +include hsk hcomm hzero in +lemma coordinate_form_mul (g h : G) : + (∑ i, c.coord (g*h) i * k i) = (∑ i, c.coord g i * k i) + (∑ i, c.coord h i * k i) := by + simp only [← abelianCoordinateCharacter_apply c hsk N hcomm k hzero,map_mul] + rfl + +end MalcevCharacters +end +end + + + +section +noncomputable section +open scoped BigOperators +namespace RationalTailCoordinates +open RationalLattice MalcevCharacters +variable {G : Type*} [Group G] [TopologicalSpace G] [IsTopologicalGroup G] +variable {r n : ℕ} (c : RealCoordinates G (r+n)) (H : Subgroup G) +variable (hH : ∀ g : G, g ∈ H ↔ ∀ i : Fin (r+n), i.val < r → c.coord g i = 0) + +lemma lift_single (i : Fin n) (t : ℝ) : lift r (Pi.single i t) = Pi.single (embed r i) t := by + classical + funext j + by_cases hj : r ≤ j.val + · simp only [lift,dite_eq_left hj,Pi.single_apply] + have he : (⟨j.val-r,by have := j.isLt; omega⟩ : Fin n) = i ↔ j = embed r i := by + constructor <;> intro he + · apply Fin.ext + have hh := congrArg Fin.val he + change j.val-r = i.val at hh + change j.val = r+i.val + omega + · have hh := congrArg Fin.val he + apply Fin.ext + change j.val = r+i.val at hh + change j.val-r = i.val + omega + simp only [he] + · have hne : j ≠ embed r i := by intro he; have hh := congrArg Fin.val he; simp [embed] at hh; omega + simp [lift,hj,hne] + +omit [IsTopologicalGroup G] in +lemma axis_val [IsTopologicalGroup G] (i : Fin n) (t : ℝ) : + (axis (tailCoordinates c H hH) i t).val = axis c (embed r i) t := by + change c.coord.symm (lift r (Pi.single i t)) = c.coord.symm (Pi.single (embed r i) t) + rw [lift_single] + + + +lemma tail_secondKind (hsk : SecondKind c) : SecondKind (tailCoordinates c H hH) where + axis_add i s t := by + apply Subtype.ext + simp only [Subgroup.coe_mul,axis_val,hsk.axis_add] + ordered g := by + apply Subtype.ext + change g.val = H.subtype (List.ofFn (fun i => axis (tailCoordinates c H hH) i + ((tailCoordinates c H hH).coord g i)) |>.prod) + rw [map_list_prod,List.map_ofFn] + change g.val = (List.ofFn (fun i => (axis (tailCoordinates c H hH) i + ((tailCoordinates c H hH).coord g i)).val)).prod + simp only [axis_val] + conv_lhs => rw [hsk.ordered g.val,List.ofFn_add,List.prod_append] + have he : (List.ofFn (fun i : Fin r => axis c (i.castLE (Nat.le_add_right r n)) (c.coord g.val (i.castLE (Nat.le_add_right r n))))).prod = 1 := by + have hzero : (fun i : Fin r => axis c (i.castLE (Nat.le_add_right r n)) (c.coord g.val (i.castLE (Nat.le_add_right r n)))) = fun _ => (1:G) := by + funext i + rw [(hH g.val).mp g.property _ i.isLt,axis_zero] + rw [hzero] + simp + rw [he,one_mul] + rfl + +end RationalTailCoordinates + +end +end +end +end +end + +end OAI diff --git a/lean/OAI/Combinatorics/SumProduct/Alignment/MalcevHorizontal01.lean b/lean/OAI/Combinatorics/SumProduct/Alignment/MalcevHorizontal01.lean new file mode 100644 index 0000000000000000000000000000000000000000..9f7a4c6e362a1cee4d1bc1de990950703edd6e8f --- /dev/null +++ b/lean/OAI/Combinatorics/SumProduct/Alignment/MalcevHorizontal01.lean @@ -0,0 +1,356 @@ +import Mathlib +import OAI.Combinatorics.SumProduct.Alignment.SquareHorizontal01 +import OAI.Geometry.NilpotentCharts.Main + +namespace OAI + +section +section +section +section +open scoped commutatorElement +end + + + +section + + + +namespace IntegralBilinear +open scoped BigOperators +noncomputable section +variable {d : ℕ} +abbrev V (d : ℕ) := Fin d → ℝ + +def basisVector (i : Fin d) : V d := Pi.single i 1 + +lemma basis_expansion (x : V d) : x = ∑ i, x i • basisVector i := by + classical + ext j + simp [basisVector,Finset.sum_apply,Pi.single_apply] + +def leftHom (B : V d →+ (V d →+ ℝ)) (y : V d) : V d →+ ℝ where + toFun x := B x y + map_zero' := by simp + map_add' x z := by simp + +lemma continuous_left (B : V d →+ (V d →+ ℝ)) + (hB : Continuous (fun p : V d × V d => B p.1 p.2)) (y : V d) : + Continuous (leftHom B y) := hB.comp (continuous_id.prodMk continuous_const) + +lemma continuous_right (B : V d →+ (V d →+ ℝ)) + (hB : Continuous (fun p : V d × V d => B p.1 p.2)) (x : V d) : + Continuous (B x) := hB.comp (continuous_const.prodMk continuous_id) + +lemma coordinate_expansion (B : V d →+ (V d →+ ℝ)) + (hB : Continuous (fun p : V d × V d => B p.1 p.2)) (x y : V d) : + B x y = ∑ i, ∑ j, x i * B (basisVector i) (basisVector j) * y j := by + classical + have left : B x y = ∑ i, x i * B (basisVector i) y := by + change leftHom B y x = _ + conv_lhs => rw [basis_expansion x] + rw [map_sum] + apply Finset.sum_congr rfl + intro i _ + rw [map_real_smul _ (continuous_left B hB y)] + rfl + rw [left] + apply Finset.sum_congr rfl + intro i _ + have right : B (basisVector i) y = ∑ j, y j * B (basisVector i) (basisVector j) := by + conv_lhs => rw [basis_expansion y] + rw [map_sum] + apply Finset.sum_congr rfl + intro j _ + rw [map_real_smul _ (continuous_right B hB (basisVector i))] + rfl + rw [right,Finset.mul_sum] + apply Finset.sum_congr rfl + intro j _ + ring + + + +theorem integer_matrix (B : V d →+ (V d →+ ℝ)) + (hB : Continuous (fun p : V d × V d => B p.1 p.2)) + (hZ : ∀ u v : Fin d → ℤ, ∃ m : ℤ, B (fun i => u i) (fun i => v i) = m) : + ∃ M : Matrix (Fin d) (Fin d) ℤ, + ∀ x y : V d, B x y = ∑ i, ∑ j, x i * (M i j:ℝ) * y j := by + classical + have he (i j : Fin d) : ∃ m : ℤ, B (basisVector i) (basisVector j) = m := by + obtain ⟨m,hm⟩ := hZ (Pi.single i 1) (Pi.single j 1) + refine ⟨m,?_⟩ + have hsingle (v : Fin d) : (fun k => ((Pi.single v 1 : Fin d → ℤ) k : ℝ)) = + basisVector v := by + ext k + simp [basisVector,Pi.single_apply] + rw [hsingle,hsingle] at hm + exact hm + choose M hM using he + refine ⟨M,?_⟩ + intro x y + rw [coordinate_expansion B hB] + simp_rw [hM] + +theorem alternating_integer_matrix (B : V d →+ (V d →+ ℝ)) + (hB : Continuous (fun p : V d × V d => B p.1 p.2)) + (hZ : ∀ u v : Fin d → ℤ, ∃ m : ℤ, B (fun i => u i) (fun i => v i) = m) + (halt : ∀ x, B x x = 0) : + ∃ M : Matrix (Fin d) (Fin d) ℤ, + (∀ i, M i i = 0) ∧ (∀ i j, M j i = -(M i j)) ∧ + ∀ x y : V d, B x y = ∑ i, ∑ j, x i * (M i j:ℝ) * y j := by + classical + obtain ⟨M,hM⟩ := integer_matrix B hB hZ + have hentry (i j : Fin d) : B (basisVector i) (basisVector j) = (M i j:ℝ) := by + rw [hM] + simp [basisVector,Pi.single_apply] + refine ⟨M,?_,?_,hM⟩ + · intro i + have hi := halt (basisVector i) + rw [hentry] at hi + exact_mod_cast hi + · intro i j + have h := halt (basisVector i + basisVector j) + simp only [map_add,AddMonoidHom.add_apply] at h + rw [halt,halt,zero_add,add_zero,hentry,hentry] at h + exact_mod_cast (show (M j i:ℝ) = -(M i j:ℝ) by linarith) + + +def contraction (M : Matrix (Fin d) (Fin d) ℤ) (x : V d) : V d := + fun j => ∑ i, x i*(M i j:ℝ) + +lemma contraction_pairing (M : Matrix (Fin d) (Fin d) ℤ) (x y : V d) : + (∑ i, ∑ j, x i*(M i j:ℝ)*y j) = ∑ j, contraction M x j*y j := by + simp only [contraction,Finset.sum_mul] + exact Finset.sum_comm + +lemma contraction_add (M : Matrix (Fin d) (Fin d) ℤ) (x y : V d) : + contraction M (x+y) = contraction M x+contraction M y := by + ext j + simp [contraction,add_mul,Finset.sum_add_distrib] + +lemma contraction_integer (M : Matrix (Fin d) (Fin d) ℤ) (x : Fin d → ℤ) (j : Fin d) : + contraction M (fun i => x i) j = ((∑ i, x i*M i j : ℤ):ℝ) := by + simp [contraction] + + + +lemma lattice_correction (M : Matrix (Fin d) (Fin d) ℤ) (x : V d) + (u : Fin d → ℤ) : + contraction M (x + fun i => (u i:ℝ)) = + contraction M x + fun j => ((∑ i, u i*M i j:ℤ):ℝ) := by + rw [contraction_add] + congr 1 + ext j + exact contraction_integer M u j + +end +end IntegralBilinear +end + + + +section + +open scoped BigOperators commutatorElement +noncomputable section +namespace MalcevHorizontal +open RationalLattice CubeFaces LeibmanSquare SquareHorizontalCharacter +variable {G : Type*} [Group G] [TopologicalSpace G] +variable {n d : ℕ} (c : RealCoordinates G n) (hd : d ≤ n) + + +def horizontal (g : G) : Fin d → ℝ := fun i => c.coord g (Fin.castLE hd i) + + + +def coordSection (_hd : d ≤ n) (x : Fin d → ℝ) : G := + c.coord.symm (fun i => if h : i.val < d then x ⟨i.val,h⟩ else 0) + +lemma horizontal_one : horizontal c hd 1 = 0 := by + ext i + exact c.one_coord _ + +lemma continuous_horizontal : Continuous (horizontal c hd) := by + exact continuous_pi (fun i => (continuous_apply _).comp c.coord.continuous) + +lemma continuous_section : Continuous (coordSection c hd) := by + apply c.coord.symm.continuous.comp + apply continuous_pi + intro i + by_cases h : i.val < d + · simpa only [h, dite_true] using (continuous_apply (⟨i.val,h⟩ : Fin d)) + · simpa only [h, dite_false] using (continuous_const : Continuous (fun _ : Fin d → ℝ => (0 : ℝ))) + +@[simp] lemma horizontal_section (x : Fin d → ℝ) : + horizontal c hd (coordSection c hd x) = x := by + ext i + simp [horizontal, coordSection, i.isLt] + +@[simp] lemma section_zero : coordSection c hd 0 = 1 := by + apply c.coord.injective + ext i + simp [coordSection, c.one_coord] + +variable (hlin : ∀ i : Fin d, c.correction (Fin.castLE hd i) = 0) +include hlin + +lemma horizontal_mul (a b : G) : + horizontal c hd (a*b) = horizontal c hd a + horizontal c hd b := by + ext i + simp only [horizontal, c.mul_coord, hlin, MvPolynomial.eval₂_zero, add_zero, Pi.add_apply] + +lemma horizontal_inv (a : G) : horizontal c hd a⁻¹ = - horizontal c hd a := by + have h := horizontal_mul c hd hlin a a⁻¹ + rw [mul_inv_cancel, horizontal_one] at h + exact eq_neg_of_add_eq_zero_right h.symm + + +def quotientHom : G →* Multiplicative (Fin d → ℝ) where + toFun g := Multiplicative.ofAdd (horizontal c hd g) + map_one' := horizontal_one c hd + map_mul' := horizontal_mul c hd hlin + +lemma continuous_quotientHom : Continuous (quotientHom c hd hlin) := + continuous_horizontal c hd + +variable (H : Filtration G) (h0 : H.level 0 = ⊤) (h1 : H.level 1 = ⊤) +variable (hlevel : ∀ g : G, g ∈ H.level 2 ↔ horizontal c hd g = 0) +variable (ξ : level H h0 1 →* Multiplicative ℝ) +include hlevel + +lemma pairing_eq_right {a b e : G} (he : horizontal c hd b = horizontal c hd e) : + pairing H h0 h1 ξ a b = pairing H h0 h1 ξ a e := by + have hb : b*e⁻¹ ∈ H.level 2 := by + rw [hlevel, horizontal_mul c hd hlin, horizontal_inv c hd hlin, he, add_neg_cancel] + have hz := lower_commutator H h0 h1 ξ a ⟨b*e⁻¹,hb⟩ + change pairing H h0 h1 ξ a (b*e⁻¹) = 1 at hz + change (pairingHom H h0 h1 ξ a) (b*e⁻¹) = 1 at hz + rw [map_mul, map_inv] at hz + exact mul_inv_eq_one.mp hz + +lemma pairing_eq_left {a b e : G} (he : horizontal c hd a = horizontal c hd b) : + pairing H h0 h1 ξ a e = pairing H h0 h1 ξ b e := by + rw [pairing_swap H h0 h1 ξ e a, pairing_swap H h0 h1 ξ e b] + rw [pairing_eq_right c hd hlin H h0 h1 hlevel ξ he] + +lemma pairing_projection (a b : G) : + pairing H h0 h1 ξ a b = pairing H h0 h1 ξ + (coordSection c hd (horizontal c hd a)) (coordSection c hd (horizontal c hd b)) := by + rw [pairing_eq_left c hd hlin H h0 h1 hlevel ξ (horizontal_section c hd _).symm] + exact pairing_eq_right c hd hlin H h0 h1 hlevel ξ (horizontal_section c hd _).symm + +lemma section_add_pairing_left (x y z : Fin d → ℝ) : + pairing H h0 h1 ξ (coordSection c hd (x+y)) (coordSection c hd z) = + pairing H h0 h1 ξ (coordSection c hd x) (coordSection c hd z) * + pairing H h0 h1 ξ (coordSection c hd y) (coordSection c hd z) := by + rw [pairing_eq_left c hd hlin H h0 h1 hlevel ξ (show + horizontal c hd (coordSection c hd (x+y)) = + horizontal c hd (coordSection c hd x * coordSection c hd y) by + simp [horizontal_mul c hd hlin])] + exact pairing_mul_left H h0 h1 ξ _ _ _ + +lemma section_add_pairing_right (x y z : Fin d → ℝ) : + pairing H h0 h1 ξ (coordSection c hd x) (coordSection c hd (y+z)) = + pairing H h0 h1 ξ (coordSection c hd x) (coordSection c hd y) * + pairing H h0 h1 ξ (coordSection c hd x) (coordSection c hd z) := by + rw [pairing_eq_right c hd hlin H h0 h1 hlevel ξ (show + horizontal c hd (coordSection c hd (y+z)) = + horizontal c hd (coordSection c hd y * coordSection c hd z) by + simp [horizontal_mul c hd hlin])] + exact pairing_mul_right H h0 h1 ξ _ _ _ + + + +def bilinear : (Fin d → ℝ) →+ ((Fin d → ℝ) →+ ℝ) where + toFun x := { + toFun y := Multiplicative.toAdd (pairing H h0 h1 ξ (coordSection c hd x) (coordSection c hd y)) + map_zero' := by + simp only [section_zero] + exact congrArg Multiplicative.toAdd (map_one (pairingHom H h0 h1 ξ _)) + map_add' y z := congrArg Multiplicative.toAdd + (section_add_pairing_right c hd hlin H h0 h1 hlevel ξ x y z) } + map_zero' := by + apply AddMonoidHom.ext + intro y + change Multiplicative.toAdd (pairing H h0 h1 ξ (coordSection c hd 0) (coordSection c hd y)) = 0 + rw [section_zero, pairing_swap H h0 h1 ξ (coordSection c hd y) 1] + change Multiplicative.toAdd ((pairingHom H h0 h1 ξ (coordSection c hd y)) 1)⁻¹ = 0 + simp + map_add' x y := by + apply AddMonoidHom.ext + intro z + exact congrArg Multiplicative.toAdd + (section_add_pairing_left c hd hlin H h0 h1 hlevel ξ x y z) + +section +variable [IsTopologicalGroup G] + +lemma bilinear_continuous (hξ : Continuous ξ) : + Continuous (fun p : (Fin d → ℝ) × (Fin d → ℝ) => + bilinear c hd hlin H h0 h1 hlevel ξ p.1 p.2) := by + exact (continuous_pairing H h0 h1 ξ hξ).comp + ((continuous_section c hd).comp continuous_fst |>.prodMk + ((continuous_section c hd).comp continuous_snd)) + +end + +variable (Γ : Subgroup G) +variable (hΓ : ∀ g : G, g ∈ Γ ↔ ∀ i, ∃ z : ℤ, c.coord g i = z) + +omit hlin hlevel in +include hΓ in +lemma integer_section (z : Fin d → ℤ) : coordSection c hd (fun i => (z i : ℝ)) ∈ Γ := by + rw [hΓ] + intro i + by_cases h : i.val < d + · exact ⟨z ⟨i.val,h⟩, by simp [coordSection,h]⟩ + · exact ⟨0, by simp [coordSection,h]⟩ + +include hΓ + + + +lemma bilinear_integer + (hξΓ : ∀ x : level H h0 1, x.val ∈ Γ.prod Γ → ∃ z : ℤ, + Multiplicative.toAdd (ξ x) = z) (u v : Fin d → ℤ) : + ∃ z : ℤ, bilinear c hd hlin H h0 h1 hlevel ξ + (fun i => (u i : ℝ)) (fun i => (v i : ℝ)) = z := by + apply hξΓ + constructor + · exact Γ.one_mem + · exact Γ.mul_mem (Γ.mul_mem (Γ.mul_mem + (integer_section c hd Γ hΓ u) (integer_section c hd Γ hΓ v)) + (Γ.inv_mem (integer_section c hd Γ hΓ u))) + (Γ.inv_mem (integer_section c hd Γ hΓ v)) + + + +variable [IsTopologicalGroup G] + +theorem square_integer_matrix (hξ : Continuous ξ) + (hξΓ : ∀ x : level H h0 1, x.val ∈ Γ.prod Γ → ∃ z : ℤ, + Multiplicative.toAdd (ξ x) = z) : + ∃ M : Matrix (Fin d) (Fin d) ℤ, + (∀ i, M i i = 0) ∧ (∀ i j, M j i = - M i j) ∧ + ∀ a b : G, Multiplicative.toAdd (pairing H h0 h1 ξ a b) = + ∑ i, ∑ j, horizontal c hd a i * (M i j : ℝ) * horizontal c hd b j := by + obtain ⟨M,hdiag,halt,hM⟩ := IntegralBilinear.alternating_integer_matrix + (bilinear c hd hlin H h0 h1 hlevel ξ) + (bilinear_continuous c hd hlin H h0 h1 hlevel ξ hξ) + (bilinear_integer c hd hlin H h0 h1 hlevel ξ Γ hΓ hξΓ) + (fun x => congrArg Multiplicative.toAdd (pairing_self H h0 h1 ξ (coordSection c hd x))) + refine ⟨M,hdiag,halt,fun a b => ?_⟩ + rw [pairing_projection c hd hlin H h0 h1 hlevel ξ a b] + exact hM _ _ + +end MalcevHorizontal + +end +end +end +end +end + +end OAI diff --git a/lean/OAI/Combinatorics/SumProduct/Alignment/MalcevHorizontal02.lean b/lean/OAI/Combinatorics/SumProduct/Alignment/MalcevHorizontal02.lean new file mode 100644 index 0000000000000000000000000000000000000000..86b108ed1310965f425b7d6451d356c27514fd58 --- /dev/null +++ b/lean/OAI/Combinatorics/SumProduct/Alignment/MalcevHorizontal02.lean @@ -0,0 +1,310 @@ +import Mathlib +import OAI.Combinatorics.SumProduct.Alignment.MalcevHorizontal01 +import OAI.Geometry.NilpotentCharts.Main + +namespace OAI + +section +section +section +section +open scoped BigOperators commutatorElement +noncomputable section +end +end + + + +section +open scoped BigOperators commutatorElement +noncomputable section +namespace MalcevHorizontal +open RationalLattice CubeFaces LeibmanSquare SquareHorizontalCharacter +variable {G : Type*} [Group G] [TopologicalSpace G] +variable {n d : ℕ} (c : RealCoordinates G n) (hd : d ≤ n) +variable (hlin : ∀ i : Fin d, c.correction (Fin.castLE hd i) = 0) + + + +def character (k : Fin d → ℤ) : G →* Multiplicative ℝ where + toFun g := Multiplicative.ofAdd (∑ i, (k i : ℝ) * horizontal c hd g i) + map_one' := by simp [horizontal_one c hd] + map_mul' a b := by + change (∑ i, (k i : ℝ) * horizontal c hd (a*b) i) = + (∑ i, (k i : ℝ) * horizontal c hd a i) + (∑ i, (k i : ℝ) * horizontal c hd b i) + simp [horizontal_mul c hd hlin, mul_add, Finset.sum_add_distrib] + +lemma character_continuous (k : Fin d → ℤ) : Continuous (character c hd hlin k) := by + change Continuous (fun g => ∑ i, (k i : ℝ) * horizontal c hd g i) + exact continuous_finsetSum _ fun i _ => continuous_const.mul + ((continuous_apply i).comp (continuous_horizontal c hd)) + +@[simp] lemma character_basis (k : Fin d → ℤ) (j : Fin d) : + Multiplicative.toAdd (character c hd hlin k + (coordSection c hd (IntegralBilinear.basisVector j))) = (k j : ℝ) := by + classical + simp [character, horizontal_section, IntegralBilinear.basisVector, Pi.single_apply] + +lemma character_ne_one {k : Fin d → ℤ} (hk : k ≠ 0) : character c hd hlin k ≠ 1 := by + intro h + apply hk + funext j + have hj := congrArg (fun f : G →* Multiplicative ℝ => + Multiplicative.toAdd (f (coordSection c hd (IntegralBilinear.basisVector j)))) h + rw [character_basis] at hj + change (k j : ℝ) = 0 at hj + exact_mod_cast hj + +lemma character_injective : Function.Injective (character c hd hlin) := by + intro k l h + funext j + have hj := congrArg (fun f : G →* Multiplicative ℝ => + Multiplicative.toAdd (f (coordSection c hd (IntegralBilinear.basisVector j)))) h + simp only [character_basis] at hj + exact_mod_cast hj + +variable (Γ : Subgroup G) +variable (hΓ : ∀ g : G, g ∈ Γ ↔ ∀ i, ∃ z : ℤ, c.coord g i = z) +include hΓ in +lemma character_integer (k : Fin d → ℤ) {g : G} (hg : g ∈ Γ) : + ∃ z : ℤ, Multiplicative.toAdd (character c hd hlin k g) = z := by + classical + choose z hz using (hΓ g).mp hg + refine ⟨∑ i, k i * z (Fin.castLE hd i), ?_⟩ + change (∑ i, (k i : ℝ) * horizontal c hd g i) = _ + simp only [Int.cast_sum, Int.cast_mul, horizontal, hz] + +variable (H : Filtration G) (h0 : H.level 0 = ⊤) (h1 : H.level 1 = ⊤) +variable (ξ : level H h0 1 →* Multiplicative ℝ) +variable (M : Matrix (Fin d) (Fin d) ℤ) +variable (hM : ∀ a b : G, Multiplicative.toAdd (pairing H h0 h1 ξ a b) = + ∑ i, ∑ j, horizontal c hd a i * (M i j : ℝ) * horizontal c hd b j) + +include hM in +lemma matrix_entry (i j : Fin d) : (M i j : ℝ) = + Multiplicative.toAdd (pairing H h0 h1 ξ + (coordSection c hd (IntegralBilinear.basisVector i)) + (coordSection c hd (IntegralBilinear.basisVector j))) := by + classical + rw [hM] + simp [horizontal_section, IntegralBilinear.basisVector, Pi.single_apply] + +include hM in +lemma column_character (j : Fin d) (g : G) : + character c hd hlin (fun i => M i j) g = + pairing H h0 h1 ξ g (coordSection c hd (IntegralBilinear.basisVector j)) := by + classical + apply Multiplicative.toAdd.injective + rw [hM] + change (∑ i, (M i j : ℝ) * horizontal c hd g i) = _ + simp only [horizontal_section, IntegralBilinear.basisVector, Pi.single_apply] + simp [mul_comm] + +include hM in +lemma matrix_zero_iff : M = 0 ↔ ∀ a b : G, pairing H h0 h1 ξ a b = 1 := by + constructor + · intro hz a b + apply Multiplicative.toAdd.injective + rw [hM, hz] + simp + · intro h + ext i j + have hij := matrix_entry c hd H h0 h1 ξ M hM i j + rw [h] at hij + change (M i j : ℝ) = 0 at hij + exact_mod_cast hij + +include hM hΓ in + + +theorem nonzero_column (hM0 : M ≠ 0) (A : ℝ) (hA : 0 ≤ A) + (hbound : ∀ i j, |(M i j : ℝ)| ≤ A) : + ∃ j : Fin d, character c hd hlin (fun i => M i j) ≠ 1 ∧ + Continuous (character c hd hlin (fun i => M i j)) ∧ + (∀ g ∈ Γ, ∃ z : ℤ, Multiplicative.toAdd + (character c hd hlin (fun i => M i j) g) = z) ∧ + ‖(fun i => (M i j : ℝ))‖ ≤ A ∧ + ∀ g, character c hd hlin (fun i => M i j) g = + pairing H h0 h1 ξ g (coordSection c hd (IntegralBilinear.basisVector j)) := by + classical + have hex : ∃ j : Fin d, (fun i => M i j) ≠ 0 := by + by_contra! h + apply hM0 + ext i j + exact congrFun (h j) i + obtain ⟨j,hj⟩ := hex + exact ⟨j,character_ne_one c hd hlin hj, character_continuous c hd hlin _, + fun g hg => character_integer c hd hlin Γ hΓ _ hg, + (pi_norm_le_iff_of_nonneg hA).mpr (fun i => hbound i j), + column_character c hd hlin H h0 h1 ξ M hM j⟩ + + + +def squareMatrixBound (Ξ : Finset (level H h0 1 →* Multiplicative ℝ)) : ℝ := + ∑ χ ∈ Ξ, ∑ i : Fin d, ∑ j : Fin d, + |Multiplicative.toAdd (pairing H h0 h1 χ + (coordSection c hd (IntegralBilinear.basisVector i)) + (coordSection c hd (IntegralBilinear.basisVector j)))| + +lemma squareMatrixBound_nonneg (Ξ : Finset (level H h0 1 →* Multiplicative ℝ)) : + 0 ≤ squareMatrixBound c hd H h0 h1 Ξ := by + exact Finset.sum_nonneg fun _ _ => Finset.sum_nonneg fun _ _ => + Finset.sum_nonneg fun _ _ => abs_nonneg _ + +include hM in +lemma matrix_bound (Ξ : Finset (level H h0 1 →* Multiplicative ℝ)) (hξ : ξ ∈ Ξ) + (i j : Fin d) : |(M i j : ℝ)| ≤ squareMatrixBound c hd H h0 h1 Ξ := by + let b (χ : level H h0 1 →* Multiplicative ℝ) (i j : Fin d) := + |Multiplicative.toAdd (pairing H h0 h1 χ + (coordSection c hd (IntegralBilinear.basisVector i)) + (coordSection c hd (IntegralBilinear.basisVector j)))| + have hb (χ : level H h0 1 →* Multiplicative ℝ) (i j : Fin d) : 0 ≤ b χ i j := abs_nonneg _ + rw [matrix_entry c hd H h0 h1 ξ M hM] + change b ξ i j ≤ ∑ χ ∈ Ξ, ∑ a : Fin d, ∑ b' : Fin d, b χ a b' + calc + _ ≤ ∑ b' : Fin d, b ξ i b' := Finset.single_le_sum (fun j _ => hb ξ i j) (Finset.mem_univ j) + _ ≤ ∑ a : Fin d, ∑ b' : Fin d, b ξ a b' := + Finset.single_le_sum (fun a _ => Finset.sum_nonneg fun j _ => hb ξ a j) (Finset.mem_univ i) + _ ≤ _ := Finset.single_le_sum (fun χ _ => Finset.sum_nonneg fun a _ => + Finset.sum_nonneg fun j _ => hb χ a j) hξ + +end MalcevHorizontal +end +end + + + +section +noncomputable section +open _root_.Polynomial _root_.OAI.Polynomial Finset +open scoped BigOperators +namespace PolynomialCharacterDescent + + + +def shiftCoefficient (r : ℕ) (P Q : ℝ[X]) : ℝ[X] := + hasseDeriv r Q + C (P.coeff r-Q.coeff r) + +lemma shiftCoefficient_eval (r : ℕ) (P Q : ℝ[X]) (h : ℝ) : + (shiftCoefficient r P Q).eval h = (P+taylor h Q-Q).coeff r := by + simp only [shiftCoefficient, eval_add, eval_C, coeff_sub, coeff_add, taylor_coeff] + ring + +lemma shiftCoefficient_degree (r : ℕ) (P Q : ℝ[X]) (d : ℕ) (hQ : Q.natDegree ≤ d) : + (shiftCoefficient r P Q).natDegree ≤ d := by + apply natDegree_add_le_of_degree_le + · exact (natDegree_hasseDeriv_le Q r).trans ((Nat.sub_le _ _).trans hQ) + · simp + +lemma shiftCoefficient_coeff (r : ℕ) (P Q : ℝ[X]) (j : ℕ) (hj : 0 < j) : + (shiftCoefficient r P Q).coeff j = ((j+r).choose r:ℝ)*Q.coeff (j+r) := by + simp [shiftCoefficient,coeff_add,hasseDeriv_coeff,coeff_C,ne_of_gt hj] + +lemma choose_dvd_factorial (r j d : ℕ) (hj : r ≤ j) (hjd : j ≤ d) : + j.choose r ∣ d.factorial := by + apply dvd_trans _ (Nat.factorial_dvd_factorial hjd) + refine ⟨r.factorial*(j-r).factorial,?_⟩ + symm + simpa only [Nat.mul_assoc] using Nat.choose_mul_factorial_mul_factorial hj + + + +theorem shift_coefficients (d r : ℕ) (hr : 0 < r) (δ A : ℝ) (hδ : 0 < δ) (hA : 0 ≤ A) : + ∃ B : ℕ, 0 < B ∧ ∃ C : ℝ, 0 < C ∧ ∃ N₀ : ℕ, 0 < N₀ ∧ + ∀ N : ℕ, N₀ ≤ N → ∀ P Q : ℝ[X], Q.natDegree ≤ d → + ∀ S : Finset ℕ, S ⊆ range N → δ*N ≤ (S.card:ℝ) → + (∀ h ∈ S, ∃ z : ℤ, |(P+taylor (h:ℝ) Q-Q).coeff r-z| ≤ A/(N:ℝ)^r) → + ∃ q : ℤ, q ≠ 0 ∧ |q| ≤ B ∧ ∀ j : ℕ, r < j → j ≤ d → + ∃ m : ℤ, |(q:ℝ)*Q.coeff j-m| ≤ C/(N:ℝ)^j := by + obtain ⟨B,hB,ε,hε,L,hL,hinv⟩ := DenseModularPolynomial.lattice_inverse d δ hδ + obtain ⟨T,hT⟩ := exists_nat_gt (max 1 (A/ε)) + let N₀ := max L T + let D := d.factorial + have hD : 0 < D := Nat.factorial_pos _ + let C : ℝ := (B:ℝ)*A*D+1 + have hC : 0 < C := by dsimp [C]; positivity + refine ⟨B*D,Nat.mul_pos hB hD,C,hC,N₀,hL.trans_le (le_max_left _ _),?_⟩ + intro N hN₀ P Q hQ S hSN hS hsmall + have hLN : L ≤ N := (le_max_left _ _).trans hN₀ + have hTN : T ≤ N := (le_max_right _ _).trans hN₀ + have hN : 0 < N := hL.trans_le hLN + have hNr : (0:ℝ)