import OAI.Geometry.PinnedDistances.ArithmeticContradiction namespace OAI universe u1 u2 u3 u4 u5 u6 u7 u8 u9 u10 u11 section noncomputable section namespace WeakPinned open Filter open scoped Topology BigOperators /-- Diagonalized extraction of genuine configurations. The errors tend to zero and vertex numbers tend to infinity. -/ theorem graph_sequence_of_failure (hfail : ¬ MainStatement) : ∃ c s γ : ℝ, 0 (C j).card) atTop atTop := tendsto_atTop_mono (fun j => (hC j).le) tendsto_id lemma graph_error_tendsto (θ : ℝ) : Tendsto (fun j : ℕ => θ/((j:ℝ)+2)) atTop (𝓝 0) := by have ht : Tendsto (fun j : ℕ => (j:ℝ)+2) atTop atTop := tendsto_atTop_add_const_right _ _ tendsto_natCast_atTop_atTop exact tendsto_const_nhds.div_atTop ht end WeakPinned /- Algebraic representation of the finite rational polynomial pattern of a real configuration in a number field. -/ noncomputable section namespace WeakPinned.Transfer open MvPolynomial /-- A system of rational polynomial equations with a complex solution has an algebraic solution. No finite set assumption on the equations is needed. -/ theorem equations {ι : Type u1} [Finite ι] (S : Set (MvPolynomial ι ℚ)) (x : ι → ℂ) (hx : ∀ p ∈ S, aeval x p = 0) : ∃ y : ι → AlgebraicClosure ℚ, ∀ p ∈ S, aeval y p = 0 := by let I : Ideal (MvPolynomial ι ℚ) := vanishingIdeal ℚ {x} have hI : I ≠ ⊤ := by intro h have h1 : (1 : MvPolynomial ι ℚ) ∈ I := by rw [h]; trivial have hz := (mem_vanishingIdeal_singleton_iff x 1).mp h1 simp at hz obtain ⟨M, hM, hIM⟩ := Ideal.exists_le_maximal I hI obtain ⟨y, hy⟩ := eq_vanishingIdeal_singleton_of_isMaximal (AlgebraicClosure ℚ) hM refine ⟨y, fun p hp => ?_⟩ apply (mem_vanishingIdeal_singleton_iff y p).mp rw [← hy] exact hIM ((mem_vanishingIdeal_singleton_iff x p).mpr (hx p hp)) /-- Simultaneous equations and finitely many inequations transfer to algebraic coordinates. The inverse-variable equation enforces every inequation. -/ theorem equations_and_inequations {ι : Type u2} [Finite ι] (S : Set (MvPolynomial ι ℚ)) (T : Finset (MvPolynomial ι ℚ)) (x : ι → ℂ) (hx : ∀ p ∈ S, aeval x p = 0) (hT : ∀ p ∈ T, aeval x p ≠ 0) : ∃ y : ι → AlgebraicClosure ℚ, (∀ p ∈ S, aeval y p = 0) ∧ (∀ p ∈ T, aeval y p ≠ 0) := by let q : MvPolynomial ι ℚ := ∏ p ∈ T, p let r : MvPolynomial (Option ι) ℚ := X none * rename some q - 1 let S' : Set (MvPolynomial (Option ι) ℚ) := (rename some) '' S ∪ {r} let x' : Option ι → ℂ := fun j => j.elim (aeval x q)⁻¹ x have hq : aeval x q ≠ 0 := by simpa [q] using Finset.prod_ne_zero_iff.mpr hT have hl (p : MvPolynomial ι ℚ) : aeval x' (rename some p) = aeval x p := by simp [aeval_rename, Function.comp_def, x'] have hx' : ∀ p ∈ S', aeval x' p = 0 := by intro p hp rcases hp with ⟨p, hp, rfl⟩ | rfl · rw [hl] exact hx p hp · simp [r, hl, x', hq] obtain ⟨y', hy'⟩ := equations S' x' hx' let y : ι → AlgebraicClosure ℚ := fun i => y' (some i) have hl' (p : MvPolynomial ι ℚ) : aeval y' (rename some p) = aeval y p := by simp [aeval_rename, Function.comp_def, y] refine ⟨y, ?_, ?_⟩ · intro p hp rw [← hl'] exact hy' _ (Or.inl ⟨p, hp, rfl⟩) · have hr := hy' r (Or.inr rfl) have hq' : aeval y q ≠ 0 := by intro hz simp [r, hl', hz] at hr have hprod : (∏ p ∈ T, aeval y p) ≠ 0 := by simpa [q] using hq' exact Finset.prod_ne_zero_iff.mp hprod /-- The algebraic realization lies in a single number field generated by its finitely many coordinates. The field is not fixed in advance. -/ theorem numberField_pattern {ι : Type u3} [Finite ι] (S : Set (MvPolynomial ι ℚ)) (T : Finset (MvPolynomial ι ℚ)) (x : ι → ℂ) (hx : ∀ p ∈ S, aeval x p = 0) (hT : ∀ p ∈ T, aeval x p ≠ 0) : ∃ K : IntermediateField ℚ (AlgebraicClosure ℚ), NumberField K ∧ ∃ y : ι → K, (∀ p ∈ S, aeval y p = 0) ∧ (∀ p ∈ T, aeval y p ≠ 0) := by obtain ⟨y, hy, hTy⟩ := equations_and_inequations S T x hx hT let K := IntermediateField.adjoin ℚ (Set.range y) have : Finite (Set.range y) := (Set.finite_range y).to_subtype have : Algebra.IsAlgebraic ℚ (AlgebraicClosure ℚ) := AlgebraicClosure.isAlgebraic ℚ have : Algebra.IsIntegral ℚ (AlgebraicClosure ℚ) := Algebra.IsAlgebraic.isIntegral have hfd : FiniteDimensional ℚ K := IntermediateField.finiteDimensional_adjoin (fun z _ => Algebra.IsIntegral.isIntegral z) have hnf : NumberField K := { to_charZero := inferInstance, to_finiteDimensional := hfd } let z : ι → K := fun i => ⟨y i, IntermediateField.subset_adjoin ℚ (Set.range y) ⟨i, rfl⟩⟩ have he (p : MvPolynomial ι ℚ) : K.val (aeval z p) = aeval y p := comp_aeval_apply z K.val p refine ⟨K, hnf, z, ?_, ?_⟩ · intro p hp apply K.val.injective change K.val (aeval z p) = K.val 0 rw [he, map_zero, hy p hp] · intro p hp hz apply hTy p hp rw [← he, hz, map_zero] /-- Preservation of an arbitrary finite zero-pattern, simultaneously, in one number field. In particular this preserves all selected equalities exactly. -/ theorem numberField_zero_pattern {ι : Type u4} [Finite ι] (T : Finset (MvPolynomial ι ℚ)) (x : ι → ℂ) : ∃ K : IntermediateField ℚ (AlgebraicClosure ℚ), NumberField K ∧ ∃ y : ι → K, ∀ p ∈ T, aeval y p = 0 ↔ aeval x p = 0 := by classical let S : Set (MvPolynomial ι ℚ) := {p | p ∈ T ∧ aeval x p = 0} let U := T.filter (fun p => aeval x p ≠ 0) obtain ⟨K, hK, y, hy, hUy⟩ := numberField_pattern S U x (fun _ hp => hp.2) (fun p hp => (Finset.mem_filter.mp hp).2) refine ⟨K, hK, y, fun p hp => ⟨?_, ?_⟩⟩ · intro h by_contra h' exact hUy p (Finset.mem_filter.mpr ⟨hp, h'⟩) h · intro h exact hy p ⟨hp, h⟩ abbrev Plane := EuclideanSpace ℝ (Fin 2) /-- Complexified variables; the extra variable forces a square root of -1 into the field, so every archimedean place is complex. -/ abbrev Variables (ι : Type u5) := Option (Bool × ι) def secondCoord (b : Bool) (z : Plane) : ℂ := if b then ⟨z 0, -z 1⟩ else ⟨z 0, z 1⟩ def complexAssignment {ι : Type u6} (x : ι → Plane) : Variables ι → ℂ := fun j => j.elim Complex.I (fun bi => secondCoord bi.1 (x bi.2)) def distancePoly {ι : Type u7} (a b : ι) : MvPolynomial (Variables ι) ℚ := (X (some (false, a)) - X (some (false, b))) * (X (some (true, a)) - X (some (true, b))) lemma eval_distancePoly {ι : Type u8} (x : ι → Plane) (a b : ι) : aeval (complexAssignment x) (distancePoly a b) = ((dist (x a) (x b)) ^ 2 : ℝ) := by simp only [distancePoly, map_mul, map_sub, aeval_X, complexAssignment, Option.elim_some, secondCoord, Bool.false_eq_true, reduceIte] rw [EuclideanSpace.dist_sq_eq] simp only [Fin.sum_univ_two, Real.dist_eq, sq_abs] apply Complex.ext <;> simp [-Complex.ofReal_pow] <;> ring /-- Every finite real planar configuration has a faithful number-field model for BOTH distance factors. The real configuration is not restricted or replaced: the exact equality pattern of ALL its distances is retained. The factorization at every place does not require conjugacy in the new field. -/ theorem planar_factor_model {ι : Type u9} [Finite ι] (x : ι → Plane) (hx : Function.Injective x) : ∃ K : IntermediateField ℚ (AlgebraicClosure ℚ), NumberField K ∧ ∃ (ii : K) (Z₁ Z₂ : ι → K), ii ^ 2 = -1 ∧ Function.Injective Z₁ ∧ Function.Injective Z₂ ∧ ∀ a b c d, (Z₁ a - Z₁ b) * (Z₂ a - Z₂ b) = (Z₁ c - Z₁ d) * (Z₂ c - Z₂ d) ↔ dist (x a) (x b) = dist (x c) (x d) := by classical let := Fintype.ofFinite ι let D := @distancePoly ι let root : MvPolynomial (Variables ι) ℚ := X none ^ 2 + 1 let pairs := Finset.univ.image (fun t : ι × ι => D t.1 t.2) let quadruples := Finset.univ.image (fun t : (ι × ι) × (ι × ι) => D t.1.1 t.1.2 - D t.2.1 t.2.2) let T := pairs ∪ quadruples ∪ {root} obtain ⟨K, hK, y, hy⟩ := numberField_zero_pattern T (complexAssignment x) let Z₁ : ι → K := fun a => y (some (false, a)) let Z₂ : ι → K := fun a => y (some (true, a)) have he (a b : ι) : aeval y (D a b) = (Z₁ a - Z₁ b) * (Z₂ a - Z₂ b) := by simp [D, distancePoly, Z₁, Z₂] have hp (a b : ι) : D a b ∈ T := by apply Finset.mem_union.mpr left apply Finset.mem_union.mpr left exact Finset.mem_image.mpr ⟨(a,b), Finset.mem_univ _, rfl⟩ have h0 (a b : ι) : (Z₁ a - Z₁ b) * (Z₂ a - Z₂ b) = 0 ↔ a = b := by rw [← he, hy _ (hp a b), eval_distancePoly] simp [hx.eq_iff] have hdist (a b c d : ι) : D a b - D c d ∈ T := by apply Finset.mem_union.mpr left apply Finset.mem_union.mpr right exact Finset.mem_image.mpr ⟨((a,b),(c,d)), Finset.mem_univ _, rfl⟩ have hroot : y none ^ 2 + 1 = 0 := by have hm : root ∈ T := Finset.mem_union.mpr (Or.inr (Finset.mem_singleton_self _)) have hc : aeval (complexAssignment x) root = 0 := by simp [root, complexAssignment, Complex.I_sq] simpa [root] using (hy root hm).mpr hc refine ⟨K, hK, y none, Z₁, Z₂, eq_neg_of_add_eq_zero_left hroot, ?_, ?_, ?_⟩ · intro a b hab apply (h0 a b).mp rw [hab, sub_self, zero_mul] · intro a b hab apply (h0 a b).mp rw [hab, sub_self, mul_zero] · intro a b c d rw [← he, ← he] have h := hy _ (hdist a b c d) rw [map_sub, sub_eq_zero, map_sub, sub_eq_zero, eval_distancePoly, eval_distancePoly, Complex.ofReal_inj] at h exact h.trans (sq_eq_sq₀ dist_nonneg dist_nonneg) end WeakPinned.Transfer namespace WeakPinned open scoped BigOperators /-- The exact arithmetic model for each extracted real graph. No point is assumed algebraic; the original graph's complete distance-equality pattern is preserved by the proved finite specialization theorem. -/ theorem core_arithmetic_model (P : Finset Plane) (s : ℝ) (C : Finset P) (hne : ∀ e, ((coreGraph P s C).targets e).Nonempty) : ∃ K : IntermediateField ℚ (AlgebraicClosure ℚ), NumberField K ∧ ∃ (ii : K) (Z₁ Z₂ : C → K) (t : (planarFibers P s).Active (cutoff s P.card) C → K), ii^2 = -1 ∧ Function.Injective Z₁ ∧ Function.Injective Z₂ ∧ (∀ e, t e ≠ 0) ∧ (∀ e y, y ∈ (coreGraph P s C).targets e → (Z₁ ((coreGraph P s C).source e)-Z₁ y)*(Z₂ ((coreGraph P s C).source e)-Z₂ y)=t e) ∧ (∀ a b c d : C, (Z₁ a-Z₁ b)*(Z₂ a-Z₂ b)=(Z₁ c-Z₁ d)*(Z₂ c-Z₂ d) ↔ dist a.val.val b.val.val=dist c.val.val d.val.val) := by classical let x : C → Plane := fun a => a.val.val have hx : Function.Injective x := Subtype.val_injective.comp Subtype.val_injective obtain ⟨K,hK,ii,Z₁,Z₂,hii,h₁,h₂,hpat⟩ := Transfer.planar_factor_model x hx choose y hy using hne let G := coreGraph P s C let t := fun e => (Z₁ (G.source e)-Z₁ (y e))*(Z₂ (G.source e)-Z₂ (y e)) refine ⟨K,hK,ii,Z₁,Z₂,t,hii,h₁,h₂,?_,?_,hpat⟩ · intro e have hxy : G.source e ≠ y e := by intro he; exact G.no_loop e (he ▸ hy e) exact mul_ne_zero (sub_ne_zero.mpr (h₁.ne hxy)) (sub_ne_zero.mpr (h₂.ne hxy)) · intro e z hz apply (hpat _ _ _ _).mpr have hz' := (Finset.mem_filter.mp hz).2 have hy' := (Finset.mem_filter.mp (hy e)).2 have hzdist := (planar_target_iff P s e.val z.val).mp hz' have hydist := (planar_target_iff P s e.val (y e).val).mp hy' change dist e.val.val.1 z.val.val=dist e.val.val.1 (y e).val.val rw [dist_comm,dist_comm e.val.val.1,hzdist,hydist] lemma PreparedGraph.targets_nonempty {V : Type u10} {I : Type u11} [Fintype V] [Fintype I] [DecidableEq V] {G : Core.Fibers V I} {θ γ c η : ℝ} (h : PreparedGraph V I G θ γ c η) : ∀ e, (G.targets e).Nonempty := by intro e have hn : (0:ℝ)