import Mathlib import OAI.NumberTheory.PiExponent.Approximation.AdmissibleParameters import OAI.NumberTheory.PiExponent.Approximation.Comparison import OAI.NumberTheory.PiExponent.Approximation.MatrixArithmetic import OAI.NumberTheory.PiExponent.Approximation.MatrixCounting import OAI.NumberTheory.PiExponent.Statement namespace OAI open Filter open scoped Topology namespace PiExponent.DeterminantContradiction noncomputable def collisionConstant : ℝ := Real.log 2 / 4 theorem collisionConstant_pos : 0 < collisionConstant := by unfold collisionConstant exact div_pos (Real.log_pos (by norm_num)) (by norm_num) abbrev FixedData (nu : ℝ) := AdmissibleParameters nu Arithmetic.lcmConstant collisionConstant noncomputable def finiteNumerators {nu : ℝ} (d : FixedData nu) : Fin d.m → ℤ := fun i => d.p i.val noncomputable def finiteDenominators {nu : ℝ} (d : FixedData nu) : Fin d.m → ℕ := fun i => d.q i.val theorem finiteDenominators_two_le {nu : ℝ} (d : FixedData nu) (i : Fin d.m) : 2 ≤ finiteDenominators d i := (d.approximations i.val).1 theorem logWeights_eq {nu : ℝ} (d : FixedData nu) (i : Fin d.m) : MatrixArithmetic.logWeights (finiteDenominators d) i = d.x (i.val + 1) := (d.x_log i.val).symm abbrev Row {nu : ℝ} (d : FixedData nu) (H : ℝ) := InterpolationMatrix.Row d.K d.v0 d.base.theta (MatrixArithmetic.logWeights (finiteDenominators d)) H abbrev Column {nu : ℝ} (d : FixedData nu) (H : ℝ) := InterpolationMatrix.Column d.w0 (MatrixArithmetic.logWeights (finiteDenominators d)) H noncomputable def actualMatrix {nu : ℝ} (d : FixedData nu) (H : ℝ) : Matrix (Row d H) (Column d H) ℂ := InterpolationMatrix.truncatedLogMatrix d.K d.w0 d.v0 d.base.theta (MatrixArithmetic.logWeights (finiteDenominators d)) H (MatrixArithmetic.rationalCenters (finiteNumerators d) (finiteDenominators d)) (MatrixArithmetic.truncationOrders (finiteDenominators d) d.F0 d.v0) noncomputable def actualMinor {nu : ℝ} (d : FixedData nu) (H : ℝ) (selection : Row d H → Column d H) : Matrix (Row d H) (Row d H) ℂ := MatrixArithmetic.selectedMinor d.K d.w0 d.v0 d.base.theta d.F0 H (finiteNumerators d) (finiteDenominators d) selection noncomputable def actualMean {nu : ℝ} (d : FixedData nu) (H : ℝ) : ℝ := MatrixArithmetic.meanRowWeight d.K d.v0 d.base.theta (finiteDenominators d) H noncomputable def actualRowCount {nu : ℝ} (d : FixedData nu) (H : ℝ) : ℕ := Fintype.card (Row d H) noncomputable def lowIndexCount {nu : ℝ} (d : FixedData nu) (H : ℝ) : ℕ := (realWeightedSimplex (MatrixArithmetic.logWeights (finiteDenominators d)) ((d.base.A : ℝ) * H)).card noncomputable def collisionRate {nu : ℝ} (d : FixedData nu) (H : ℝ) : ℝ := collisionConstant * d.base.eta ^ 2 * (actualRowCount d H : ℝ) / (H * (lowIndexCount d H : ℝ)) noncomputable def collisionLimit {nu : ℝ} (d : FixedData nu) : ℝ := collisionConstant * (d.base.eta ^ 2 * (d.K : ℝ) * (d.base.theta : ℝ) ^ d.m / (((d.m : ℝ) + 1) * (d.v0 : ℝ) * (d.base.A : ℝ) ^ d.m)) theorem actual_minor_arithmetic_lower_bound {nu : ℝ} (d : FixedData nu) (H : ℝ) (hH : 0 < H) (selection : Row d H → Column d H) (hdet : (actualMinor d H selection).det ≠ 0) : -(1 - actualMean d H) - d.arithmeticError ≤ Real.log ‖(actualMinor d H selection).det‖ / ((actualRowCount d H : ℝ) * H) := by have hh := MatrixArithmetic.selectedMinor_arithmetic_lower_bound (finiteNumerators d) (finiteDenominators d) (finiteDenominators_two_le d) (Nat.zero_lt_of_lt d.K_pos) d.w0_pos d.v0_pos d.base.theta_pos d.F0_pos.le hH d.wstar_pos (fun i => by rw [logWeights_eq]; exact d.wstar_lower i) selection hdet simpa only [actualMinor, actualMean, actualRowCount, AdmissibleParameters.arithmeticError, logWeights_eq] using hh theorem actualMean_bounds {nu : ℝ} (d : FixedData nu) (H : ℝ) (hH : 0 < H) : 0 ≤ actualMean d H ∧ actualMean d H ≤ (d.base.theta : ℝ) := by exact ⟨MatrixArithmetic.meanRowWeight_nonneg _ _ _ _ hH.le, MatrixArithmetic.meanRowWeight_le_theta (finiteDenominators d) (finiteDenominators_two_le d) (Nat.zero_lt_of_lt d.K_pos) d.v0_pos d.base.theta_pos hH⟩ def GlobalInterpolationStatement : Prop := ∀ nu : ℝ, 2 < nu → ∀ d : FixedData nu, ∀ L : ℝ, ∃ H : ℝ, L ≤ H ∧ Function.Surjective (actualMatrix d H).mulVecLin def AnalyticAggregateStatement : Prop := ∀ nu : ℝ, 2 < nu → ∀ d : FixedData nu, ∃ error : ℝ → ℝ, Tendsto error atTop (𝓝 0) ∧ ∀ᶠ H : ℝ in atTop, ∀ selection : Row d H → Column d H, (actualMinor d H selection).det ≠ 0 → Real.log ‖(actualMinor d H selection).det‖ / ((actualRowCount d H : ℝ) * H) ≤ d.analyticError + error H + max (-collisionRate d H) (-nu * ((d.base.A : ℝ) * (1 - d.base.eta) - actualMean d H)) theorem tendsto_collisionRate {nu : ℝ} (d : FixedData nu) : Tendsto (collisionRate d) atTop (𝓝 (collisionLimit d)) := by have hv : 0 < d.v0 := by exact_mod_cast d.v0_pos have ht : 0 < d.base.theta := by exact_mod_cast d.base.theta_pos have hA : 0 < d.base.A := by exact_mod_cast d.base.A_pos have hh := MatrixCounting.tendsto_collisionRatio d.K d.v0 d.base.theta d.base.A (finiteDenominators d) hv ht hA (finiteDenominators_two_le d) collisionConstant d.base.eta have he : collisionConstant * d.base.eta ^ 2 * (d.K : ℝ) * (d.base.theta : ℝ) ^ d.m / (((d.m : ℝ) + 1) * (d.v0 : ℝ) * (d.base.A : ℝ) ^ d.m) = collisionLimit d := by unfold collisionLimit ring rw [he] at hh exact hh theorem no_fixed_data_of_interpolation_and_analytic_aggregate (hgeometry : GlobalInterpolationStatement) (hanalytic : AnalyticAggregateStatement) (nu : ℝ) (hnu : 2 < nu) (d : FixedData nu) : False := by classical obtain ⟨error, herror, hupper⟩ := hanalytic nu hnu d have hsum : Tendsto (fun H : ℝ => d.arithmeticError + d.analyticError + error H) atTop (𝓝 (d.arithmeticError + d.analyticError + 0)) := tendsto_const_nhds.add herror have hsmall : ∀ᶠ H : ℝ in atTop, d.arithmeticError + d.analyticError + error H < nu * ((d.base.A : ℝ) * (1 - d.base.eta) - d.base.theta) - (1 - d.base.theta) := hsum.eventually (Iio_mem_nhds (by simpa using d.error_sum_lt_gap)) have hdiff : Tendsto (fun H : ℝ => collisionRate d H - (1 + d.arithmeticError + d.analyticError + error H)) atTop (𝓝 (collisionLimit d - (1 + d.arithmeticError + d.analyticError + 0))) := (tendsto_collisionRate d).sub (tendsto_const_nhds.add herror) have hlarge : ∀ᶠ H : ℝ in atTop, 0 < collisionRate d H - (1 + d.arithmeticError + d.analyticError + error H) := by apply hdiff.eventually (Ioi_mem_nhds ?_) have hh := d.collision_exceeds_error_sum change 1 + d.arithmeticError + d.analyticError < collisionLimit d at hh linarith have hcontradiction : ∀ᶠ H : ℝ in atTop, Function.Surjective (actualMatrix d H).mulVecLin → False := by filter_upwards [hsmall, hlarge, hupper, eventually_gt_atTop (0 : ℝ)] with H hsmall hlarge hupper hH intro hsurj obtain ⟨selection, _hselection, hdet⟩ := InterpolationMatrix.exists_full_row_minor_of_surjective (actualMatrix d H) hsurj have hdet' : (actualMinor d H selection).det ≠ 0 := hdet have hlower := actual_minor_arithmetic_lower_bound d H hH selection hdet' have hb := actualMean_bounds d H hH exact determinant_bounds_inconsistent nu d.base.theta ((d.base.A : ℝ) * (1 - d.base.eta)) (actualMean d H) d.arithmeticError d.analyticError (error H) (collisionRate d H) (Real.log ‖(actualMinor d H selection).det‖ / ((actualRowCount d H : ℝ) * H)) (by linarith) hb.1 hb.2 hsmall (by linarith) hlower (hupper selection hdet') obtain ⟨L, hL⟩ := Filter.eventually_atTop.mp hcontradiction obtain ⟨H, hLH, hsurj⟩ := hgeometry nu hnu d L exact hL H hLH hsurj theorem piEventualLowerBound_of_interpolation_and_analytic_aggregate (hgeometry : GlobalInterpolationStatement) (hanalytic : AnalyticAggregateStatement) : PiEventualLowerBound := by intro nu hnu by_contra h push Not at h have hbad : ∀ Q : ℕ, ∃ p : ℤ, ∃ q : ℕ, Q ≤ q ∧ |Real.pi - (p : ℝ) / q| ≤ (q : ℝ) ^ (-nu) := by intro Q obtain ⟨p, q, hq, herr⟩ := h (max Q 2) (le_max_right _ _) exact ⟨p, q, (le_max_left _ _).trans hq, herr.le⟩ obtain ⟨d⟩ := exists_admissible_parameters nu Arithmetic.lcmConstant collisionConstant hnu Arithmetic.lcmConstant_pos collisionConstant_pos hbad exact no_fixed_data_of_interpolation_and_analytic_aggregate hgeometry hanalytic nu hnu d end PiExponent.DeterminantContradiction end OAI