Download data/lean/OAI/Combinatorics/Distances/PolynomialIsolation.lean from introvoyz045/math: direct link, hf CLI and curl.
- Browser
- Download file 17.4 kB
-
https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/Combinatorics/Distances/PolynomialIsolation.lean
- Command line
-
hf download hf://datasets/introvoyz045/math/data/lean/OAI/Combinatorics/Distances/PolynomialIsolation.lean
-
curl -L -o PolynomialIsolation.lean https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/Combinatorics/Distances/PolynomialIsolation.lean
17.4 kB
| import Mathlib | |
| namespace OAI | |
| /-! Polynomial separators, finite-point isolation and elementary bounds for distinct Euclidean distances. -/ | |
| noncomputable section | |
| open scoped BigOperators Topology | |
| namespace ErdosDistinctDistances | |
| abbrev Point (d : β) := EuclideanSpace β (Fin d) | |
| def distances {d : β} (P : Finset (Point d)) : Finset β := by | |
| classical | |
| exact P.offDiag.image (fun pq => dist pq.1 pq.2) | |
| variable {d : β} {P Q : Finset (Point d)} | |
| @[simp] theorem mem_distances {r : β} : | |
| r β distances P β β p β P, β q β P, p β q β§ dist p q = r := by | |
| classical | |
| simp only [distances, Finset.mem_image, Finset.mem_offDiag] | |
| constructor | |
| Β· rintro β¨β¨p, qβ©, β¨hp, hq, hpqβ©, hrβ© | |
| exact β¨p, hp, q, hq, hpq, hrβ© | |
| Β· rintro β¨p, hp, q, hq, hpq, hrβ© | |
| exact β¨(p, q), β¨hp, hq, hpqβ©, hrβ© | |
| theorem coe_distances (P : Finset (Point d)) : | |
| (distances P : Set β) = | |
| {r | β p β P, β q β P, p β q β§ βp - qβ = r} := by | |
| ext r | |
| simp [mem_distances, dist_eq_norm] | |
| theorem distance_pos {r : β} (hr : r β distances P) : 0 < r := by | |
| obtain β¨p, _, q, _, hpq, rflβ© := mem_distances.mp hr | |
| exact dist_pos.mpr hpq | |
| @[simp] theorem zero_not_mem_distances (P : Finset (Point d)) : | |
| (0 : β) β distances P := by | |
| intro h | |
| exact (lt_irrefl (0 : β)) (distance_pos h) | |
| theorem distances_mono (h : P β Q) : distances P β distances Q := by | |
| intro r hr | |
| obtain β¨p, hp, q, hq, hpq, rflβ© := mem_distances.mp hr | |
| exact mem_distances.mpr β¨p, h hp, q, h hq, hpq, rflβ© | |
| theorem distances_nonempty (hP : 2 β€ P.card) : (distances P).Nonempty := by | |
| classical | |
| obtain β¨p, hp, q, hq, hpqβ© := Finset.one_lt_card.mp hP | |
| exact β¨dist p q, mem_distances.mpr β¨p, hp, q, hq, hpq, rflβ©β© | |
| theorem one_le_card_distances (hP : 2 β€ P.card) : 1 β€ (distances P).card := | |
| (distances_nonempty hP).card_pos | |
| theorem failure_gives_regime (hd : 3 β€ d) | |
| (hfail : Β¬ β c : β, 0 < c β§ | |
| β P : Finset (Point d), 2 β€ P.card β | |
| c * (P.card : β) ^ (2 / (d : β)) β€ (distances P).card) : | |
| β P : β β Finset (Point d), | |
| (β k, 2 β€ (P k).card) β§ | |
| Filter.Tendsto (fun k => (P k).card) Filter.atTop Filter.atTop β§ | |
| Filter.Tendsto | |
| (fun k => (1 + ((distances (P k)).card : β)) / | |
| ((P k).card : β) ^ (2 / (d : β))) | |
| Filter.atTop (π 0) := by | |
| classical | |
| have hf : β c : β, 0 < c β β P : Finset (Point d), | |
| 2 β€ P.card β§ (distances P).card < c * (P.card : β) ^ (2 / (d : β)) := by | |
| push Not at hfail | |
| exact hfail | |
| have hchoice : β k : β, β P : Finset (Point d), 2 β€ P.card β§ | |
| (distances P).card < (1 / ((k : β) + 1)) * | |
| (P.card : β) ^ (2 / (d : β)) := by | |
| intro k | |
| exact hf _ (by positivity) | |
| choose P hP hm using hchoice | |
| have hn (k : β) : (2 : β) β€ (P k).card := by exact_mod_cast hP k | |
| have hA (k : β) : 0 < ((P k).card : β) ^ (2 / (d : β)) := | |
| Real.rpow_pos_of_pos (by linarith [hn k]) _ | |
| have hM (k : β) : (1 : β) β€ (distances (P k)).card := by | |
| exact_mod_cast one_le_card_distances (hP k) | |
| have he : 2 / (d : β) β€ 1 := by | |
| have hd' : (3 : β) β€ d := by exact_mod_cast hd | |
| apply (div_le_one (by linarith : (0 : β) < d)).mpr | |
| linarith | |
| have hkA (k : β) : (k : β) + 1 < ((P k).card : β) ^ (2 / (d : β)) := by | |
| have h : (1 : β) < ((P k).card : β) ^ (2 / (d : β)) / ((k : β) + 1) := by | |
| simpa [div_eq_mul_inv, mul_comm] using lt_of_le_of_lt (hM k) (hm k) | |
| simpa using (lt_div_iffβ (by positivity : (0 : β) < (k : β) + 1)).mp h | |
| have hkn (k : β) : k β€ (P k).card := by | |
| have hpow := Real.rpow_le_self_of_one_le (by linarith [hn k] : (1 : β) β€ (P k).card) he | |
| have : (k : β) β€ (P k).card := by linarith [hkA k] | |
| exact_mod_cast this | |
| refine β¨P, hP, Filter.tendsto_atTop_mono hkn Filter.tendsto_id, ?_β© | |
| apply squeeze_zero | |
| Β· intro k | |
| exact div_nonneg (by positivity) (hA k).le | |
| Β· intro k | |
| apply le_of_lt | |
| apply (div_lt_iffβ (hA k)).mpr | |
| calc | |
| 1 + ((distances (P k)).card : β) β€ 2 * (distances (P k)).card := by | |
| linarith [hM k] | |
| _ < 2 * ((1 / ((k : β) + 1)) * ((P k).card : β) ^ (2 / (d : β))) := | |
| mul_lt_mul_of_pos_left (hm k) (by norm_num) | |
| _ = (2 / ((k : β) + 1)) * ((P k).card : β) ^ (2 / (d : β)) := by ring | |
| Β· convert tendsto_one_div_add_atTop_nhds_zero_nat.const_mul (2 : β) using 1 <;> | |
| simp [div_eq_mul_inv] | |
| theorem regime_precludes_bound (P : β β Finset (Point d)) | |
| (hP : β k, 2 β€ (P k).card) | |
| (hlim : Filter.Tendsto | |
| (fun k => (1 + ((distances (P k)).card : β)) / | |
| ((P k).card : β) ^ (2 / (d : β))) Filter.atTop (π 0)) : | |
| Β¬ β c : β, 0 < c β§ | |
| β Q : Finset (Point d), 2 β€ Q.card β | |
| c * (Q.card : β) ^ (2 / (d : β)) β€ (distances Q).card := by | |
| rintro β¨c, hc, hbβ© | |
| have hcle : c β€ 0 := ge_of_tendsto' hlim fun k => by | |
| have hn : (0 : β) < (P k).card := by | |
| exact_mod_cast lt_of_lt_of_le (by decide : 0 < 2) (hP k) | |
| apply (le_div_iffβ (Real.rpow_pos_of_pos hn _)).mpr | |
| linarith [hb (P k) (hP k)] | |
| exact (not_le_of_gt hc) hcle | |
| def complexPoint (p : Point d) : Fin d β β := fun i => (p i : β) | |
| def squaredDistancePolynomial (p : Point d) : MvPolynomial (Fin d) β := | |
| β i : Fin d, (MvPolynomial.X i - MvPolynomial.C ((p i : β) : β)) ^ 2 | |
| theorem eval_squaredDistancePolynomial (p q : Point d) : | |
| MvPolynomial.eval (complexPoint q) (squaredDistancePolynomial p) = | |
| (dist p q : β) ^ 2 := by | |
| simp only [squaredDistancePolynomial, map_sum, map_pow, map_sub, | |
| MvPolynomial.eval_X, MvPolynomial.eval_C, complexPoint] | |
| norm_cast | |
| simp [EuclideanSpace.dist_sq_eq, Real.dist_eq, sub_sq_comm] | |
| theorem degree_squaredDistancePolynomial (p : Point d) : | |
| (squaredDistancePolynomial p).totalDegree β€ 2 := by | |
| apply MvPolynomial.totalDegree_finsetSum_le | |
| intro i _ | |
| have h : (MvPolynomial.X i - MvPolynomial.C ((p i : β) : β)).totalDegree β€ 1 := by | |
| simpa using MvPolynomial.totalDegree_sub | |
| (MvPolynomial.X i) (MvPolynomial.C ((p i : β) : β)) | |
| calc | |
| _ β€ 2 * (MvPolynomial.X i - MvPolynomial.C ((p i : β) : β)).totalDegree := | |
| MvPolynomial.totalDegree_pow _ _ | |
| _ β€ 2 * 1 := Nat.mul_le_mul_left _ h | |
| _ = 2 := rfl | |
| def separatorFactor (p : Point d) (r : β) : MvPolynomial (Fin d) β := | |
| (squaredDistancePolynomial p - MvPolynomial.C ((r : β) ^ 2)) * | |
| MvPolynomial.C ((-((r : β) ^ 2))β»ΒΉ) | |
| def physicalSeparator (P : Finset (Point d)) (p : Point d) : MvPolynomial (Fin d) β := | |
| β r β distances P, separatorFactor p r | |
| theorem degree_separatorFactor (p : Point d) (r : β) : | |
| (separatorFactor p r).totalDegree β€ 2 := by | |
| have h := MvPolynomial.totalDegree_sub (squaredDistancePolynomial p) | |
| (MvPolynomial.C ((r : β) ^ 2)) | |
| simp only [MvPolynomial.totalDegree_C, max_eq_left (Nat.zero_le _)] at h | |
| calc | |
| _ β€ (squaredDistancePolynomial p - MvPolynomial.C ((r : β) ^ 2)).totalDegree + | |
| (MvPolynomial.C ((-((r : β) ^ 2))β»ΒΉ)).totalDegree := | |
| MvPolynomial.totalDegree_mul _ _ | |
| _ = (squaredDistancePolynomial p - MvPolynomial.C ((r : β) ^ 2)).totalDegree := by | |
| simp | |
| _ β€ (squaredDistancePolynomial p).totalDegree := h | |
| _ β€ 2 := degree_squaredDistancePolynomial p | |
| theorem degree_physicalSeparator (P : Finset (Point d)) (p : Point d) : | |
| (physicalSeparator P p).totalDegree β€ 2 * (distances P).card := by | |
| calc | |
| _ β€ β r β distances P, (separatorFactor p r).totalDegree := | |
| MvPolynomial.totalDegree_finsetProd _ _ | |
| _ β€ β _ β distances P, 2 := Finset.sum_le_sum fun r _ => degree_separatorFactor p r | |
| _ = 2 * (distances P).card := by simp [Nat.mul_comm] | |
| theorem eval_physicalSeparator_self (P : Finset (Point d)) (p : Point d) : | |
| MvPolynomial.eval (complexPoint p) (physicalSeparator P p) = 1 := by | |
| classical | |
| rw [physicalSeparator, map_prod] | |
| apply Finset.prod_eq_one | |
| intro r hr | |
| have hr0 : (r : β) β 0 := by exact_mod_cast ne_of_gt (distance_pos hr) | |
| simp [separatorFactor, eval_squaredDistancePolynomial, hr0] | |
| theorem eval_physicalSeparator_ne {p q : Point d} (hp : p β P) (hq : q β P) (hpq : p β q) : | |
| MvPolynomial.eval (complexPoint q) (physicalSeparator P p) = 0 := by | |
| classical | |
| rw [physicalSeparator, map_prod] | |
| apply Finset.prod_eq_zero (mem_distances.mpr β¨p, hp, q, hq, hpq, rflβ©) | |
| simp [separatorFactor, eval_squaredDistancePolynomial] | |
| theorem eval_physicalSeparator {p q : Point d} (hp : p β P) (hq : q β P) : | |
| MvPolynomial.eval (complexPoint q) (physicalSeparator P p) = if p = q then 1 else 0 := by | |
| classical | |
| by_cases h : p = q | |
| Β· subst q | |
| simp [eval_physicalSeparator_self] | |
| Β· simp [h, eval_physicalSeparator_ne hp hq h] | |
| def isolationPolynomials (P : Finset (Point d)) : Finset (MvPolynomial (Fin d) β) := by | |
| classical | |
| exact insert (1 - β p β P, physicalSeparator P p) | |
| ((P.product Finset.univ).image (fun pj => | |
| (MvPolynomial.X pj.2 - MvPolynomial.C (complexPoint pj.1 pj.2)) * | |
| physicalSeparator P pj.1)) | |
| theorem degree_isolationPolynomials {f : MvPolynomial (Fin d) β} | |
| (hf : f β isolationPolynomials P) : | |
| f.totalDegree β€ 2 * (distances P).card + 1 := by | |
| classical | |
| rcases Finset.mem_insert.mp hf with rfl | hf | |
| Β· have hs : (β p β P, physicalSeparator P p).totalDegree β€ 2 * (distances P).card := | |
| MvPolynomial.totalDegree_finsetSum_le fun p _ => degree_physicalSeparator P p | |
| have ht := MvPolynomial.totalDegree_sub (1 : MvPolynomial (Fin d) β) | |
| (β p β P, physicalSeparator P p) | |
| simp only [MvPolynomial.totalDegree_one, zero_le, max_eq_right] at ht | |
| exact (ht.trans hs).trans (Nat.le_add_right _ _) | |
| Β· obtain β¨β¨p, jβ©, _, rflβ© := Finset.mem_image.mp hf | |
| have hl : (MvPolynomial.X j - MvPolynomial.C (complexPoint p j)).totalDegree β€ 1 := by | |
| simpa using MvPolynomial.totalDegree_sub (MvPolynomial.X j) | |
| (MvPolynomial.C (complexPoint p j)) | |
| calc | |
| _ β€ (MvPolynomial.X j - MvPolynomial.C (complexPoint p j)).totalDegree + | |
| (physicalSeparator P p).totalDegree := MvPolynomial.totalDegree_mul _ _ | |
| _ β€ 1 + 2 * (distances P).card := Nat.add_le_add hl (degree_physicalSeparator P p) | |
| _ = 2 * (distances P).card + 1 := Nat.add_comm _ _ | |
| theorem isolation_zero_iff (P : Finset (Point d)) (z : Fin d β β) : | |
| (β f β isolationPolynomials P, MvPolynomial.eval z f = 0) β | |
| β p β P, complexPoint p = z := by | |
| classical | |
| constructor | |
| Β· intro hzero | |
| have hsum : β p β P, MvPolynomial.eval z (physicalSeparator P p) = 1 := by | |
| have hz := hzero _ (Finset.mem_insert_self _ _) | |
| simp only [map_sub, map_one, map_sum] at hz | |
| exact (sub_eq_zero.mp hz).symm | |
| have hsum0 : β p β P, MvPolynomial.eval z (physicalSeparator P p) β 0 := by | |
| rw [hsum] | |
| exact one_ne_zero | |
| obtain β¨p, hp, hsβ© := Finset.exists_ne_zero_of_sum_ne_zero hsum0 | |
| refine β¨p, hp, ?_β© | |
| funext j | |
| have hj : (MvPolynomial.X j - MvPolynomial.C (complexPoint p j)) * | |
| physicalSeparator P p β isolationPolynomials P := by | |
| apply Finset.mem_insert_of_mem | |
| apply Finset.mem_image.mpr | |
| exact β¨(p, j), Finset.mem_product.mpr β¨hp, Finset.mem_univ jβ©, rflβ© | |
| have hz := hzero _ hj | |
| simp only [map_mul, map_sub, MvPolynomial.eval_X, MvPolynomial.eval_C] at hz | |
| exact (sub_eq_zero.mp ((mul_eq_zero.mp hz).resolve_right hs)).symm | |
| Β· rintro β¨p, hp, rflβ© f hf | |
| rcases Finset.mem_insert.mp hf with rfl | hf | |
| Β· rw [map_sub, map_one, map_sum] | |
| have hsum : β q β P, MvPolynomial.eval (complexPoint p) (physicalSeparator P q) = 1 := by | |
| rw [Finset.sum_eq_single p] | |
| Β· exact eval_physicalSeparator_self P p | |
| Β· intro q hq hqp | |
| exact eval_physicalSeparator_ne hq hp hqp | |
| Β· exact fun h => (h hp).elim | |
| simp [hsum] | |
| Β· obtain β¨β¨q, jβ©, hqj, rflβ© := Finset.mem_image.mp hf | |
| have hq : q β P := (Finset.mem_product.mp hqj).1 | |
| by_cases hqp : q = p | |
| Β· subst q | |
| simp | |
| Β· simp [eval_physicalSeparator_ne hq hp hqp] | |
| theorem linearIndependent_physicalSeparator (P : Finset (Point d)) : | |
| LinearIndependent β (fun p : P => physicalSeparator P p) := by | |
| classical | |
| rw [linearIndependent_iff'] | |
| intro s a hs p hp | |
| have h := congrArg (MvPolynomial.eval (complexPoint (p : Point d))) hs | |
| simp only [map_sum, MvPolynomial.smul_eval, map_zero] at h | |
| have heq : β q β s, a q * | |
| MvPolynomial.eval (complexPoint (p : Point d)) (physicalSeparator P q) = a p := by | |
| rw [Finset.sum_eq_single p] | |
| Β· simp [eval_physicalSeparator_self] | |
| Β· intro q _ hqp | |
| have hqp' : (q : Point d) β (p : Point d) := fun h => hqp (Subtype.ext h) | |
| simp [eval_physicalSeparator_ne q.property p.property hqp'] | |
| Β· exact fun h => (h hp).elim | |
| exact heq.symm.trans h | |
| theorem finrank_restrictDegree (d L : β) : | |
| Module.finrank β (MvPolynomial.restrictDegree (Fin d) β L) = (L + 1) ^ d := by | |
| classical | |
| let e : {n : Fin d ββ β // β i, n i β€ L} β (Fin d β Fin (L + 1)) := | |
| { toFun := fun n i => β¨n.1 i, Nat.lt_succ_iff.mpr (n.2 i)β© | |
| invFun := fun n => β¨Finsupp.equivFunOnFinite.symm (fun i => (n i).val), | |
| fun i => by simpa using Nat.lt_succ_iff.mp (n i).isLtβ© | |
| left_inv := fun n => by | |
| apply Subtype.ext | |
| ext i | |
| simp | |
| right_inv := fun n => by | |
| funext i | |
| apply Fin.ext | |
| simp } | |
| let : Fintype {n : Fin d ββ β // β i, n i β€ L} := Fintype.ofEquiv _ e.symm | |
| calc | |
| _ = Fintype.card {n : Fin d ββ β // β i, n i β€ L} := | |
| Module.finrank_eq_card_basis (MvPolynomial.basisRestrictSupport β _) | |
| _ = Fintype.card (Fin d β Fin (L + 1)) := Fintype.card_congr e | |
| _ = (L + 1) ^ d := by simp | |
| theorem elementary_card_bound (P : Finset (Point d)) : | |
| P.card β€ (2 * (distances P).card + 1) ^ d := by | |
| classical | |
| let V := MvPolynomial.restrictDegree (Fin d) β (2 * (distances P).card) | |
| have hv (p : P) : physicalSeparator P p β V := | |
| MvPolynomial.restrictTotalDegree_le_restrictDegree _ _ _ | |
| ((MvPolynomial.mem_restrictTotalDegree _ _ _).mpr (degree_physicalSeparator P p)) | |
| let v : P β V := fun p => β¨physicalSeparator P p, hv pβ© | |
| have hlin : LinearIndependent β v := | |
| LinearIndependent.of_comp V.subtype (linearIndependent_physicalSeparator P) | |
| have hcard := hlin.fintype_card_le_finrank | |
| simpa [V, finrank_restrictDegree] using hcard | |
| def lengthFiber (S : Finset (Point d Γ Point d)) (r : β) : Finset (Point d Γ Point d) := by | |
| classical | |
| exact S.filter (fun pq => dist pq.1 pq.2 = r) | |
| def equalLengthPairs (S : Finset (Point d Γ Point d)) : | |
| Finset ((Point d Γ Point d) Γ (Point d Γ Point d)) := by | |
| classical | |
| exact (S.product S).filter (fun ab => dist ab.1.1 ab.1.2 = dist ab.2.1 ab.2.2) | |
| theorem sum_lengthFiber_card (S : Finset (Point d Γ Point d)) (hS : S β P.offDiag) : | |
| β r β distances P, (lengthFiber S r).card = S.card := by | |
| classical | |
| change β r β distances P, (S.filter (fun pq => dist pq.1 pq.2 = r)).card = S.card | |
| rw [Finset.sum_card_fiberwise_eq_card_filter] | |
| congr 1 | |
| apply Finset.filter_eq_self.mpr | |
| intro pq hpq | |
| exact Finset.mem_image.mpr β¨pq, hS hpq, rflβ© | |
| theorem equalLengthPairs_card (S : Finset (Point d Γ Point d)) (hS : S β P.offDiag) : | |
| (equalLengthPairs S).card = β r β distances P, (lengthFiber S r).card ^ 2 := by | |
| classical | |
| have hfib (r : β) : | |
| ((equalLengthPairs S).filter (fun ab => dist ab.1.1 ab.1.2 = r)) = | |
| (lengthFiber S r).product (lengthFiber S r) := by | |
| ext ab | |
| simp only [equalLengthPairs, lengthFiber, Finset.mem_filter] | |
| aesop | |
| have hcover : ((equalLengthPairs S).filter | |
| (fun ab => dist ab.1.1 ab.1.2 β distances P)) = equalLengthPairs S := by | |
| apply Finset.filter_eq_self.mpr | |
| intro ab hab | |
| have ha : ab.1 β S := (Finset.mem_product.mp (Finset.mem_filter.mp hab).1).1 | |
| exact Finset.mem_image.mpr β¨ab.1, hS ha, rflβ© | |
| have hsum := Finset.sum_card_fiberwise_eq_card_filter (equalLengthPairs S) | |
| (distances P) (fun ab => dist ab.1.1 ab.1.2) | |
| rw [hcover] at hsum | |
| rw [β hsum] | |
| apply Finset.sum_congr rfl | |
| intro r _ | |
| rw [hfib r] | |
| exact (Finset.card_product _ _).trans (pow_two _).symm | |
| theorem equalLengthPairs_lower_bound (S : Finset (Point d Γ Point d)) (hS : S β P.offDiag) : | |
| S.card ^ 2 β€ (distances P).card * (equalLengthPairs S).card := by | |
| classical | |
| have h := Finset.sum_mul_sq_le_sq_mul_sq (distances P) | |
| (fun _ => (1 : β)) (fun r => (lengthFiber S r).card) | |
| simpa only [one_mul, one_pow, Finset.sum_const, smul_eq_mul, mul_one, | |
| sum_lengthFiber_card S hS, β equalLengthPairs_card S hS] using h | |
| theorem equalLengthPairs_lower_bound_real (S : Finset (Point d Γ Point d)) (hS : S β P.offDiag) : | |
| (S.card : β) ^ 2 / (1 + ((distances P).card : β)) β€ (equalLengthPairs S).card := by | |
| have h : (S.card : β) ^ 2 β€ (distances P).card * (equalLengthPairs S).card := by | |
| exact_mod_cast equalLengthPairs_lower_bound S hS | |
| apply (div_le_iffβ (by positivity : (0 : β) < 1 + ((distances P).card : β))).mpr | |
| nlinarith [Nat.cast_nonneg (Ξ± := β) (equalLengthPairs S).card] | |
| end ErdosDistinctDistances | |
| end | |
| end OAI | |