Download data/lean/OAI/NumberTheory/PowerFree/HilbertSimplex.lean from introvoyz045/math: direct link, hf CLI and curl.
- Browser
- Download file 14.6 kB
-
https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/NumberTheory/PowerFree/HilbertSimplex.lean
- Command line
-
hf download hf://datasets/introvoyz045/math/data/lean/OAI/NumberTheory/PowerFree/HilbertSimplex.lean
-
curl -L -o HilbertSimplex.lean https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/NumberTheory/PowerFree/HilbertSimplex.lean
14.6 kB
| import OAI.NumberTheory.PowerFree.ResidueRelations | |
| namespace OAI | |
| open scoped BigOperators | |
| open Matrix | |
| open scoped BigOperators | |
| open scoped BigOperators | |
| namespace QuarticPowerFree | |
| section | |
| open scoped BigOperators | |
| theorem extend_independent_finset {K V ΞΉ : Type*} [Field K] | |
| [AddCommGroup V] [Module K V] (v : ΞΉ β V) (S A : Finset ΞΉ) | |
| (hAS : A β S) (hA : LinearIndepOn K v (A : Set ΞΉ)) (m : β) | |
| (hAm : A.card β€ m) (hm : m β€ Module.finrank K (Submodule.span K (v '' (S : Set ΞΉ)))) : | |
| β B : Finset ΞΉ, A β B β§ B β S β§ B.card = m β§ LinearIndepOn K v (B : Set ΞΉ) := by | |
| classical | |
| have hsub : (A : Set ΞΉ) β (S : Set ΞΉ) := hAS | |
| let T := hA.extend hsub | |
| have hTs : T β (S : Set ΞΉ) := hA.extend_subset hsub | |
| have hfin : T.Finite := S.finite_toSet.subset hTs | |
| let B := hfin.toFinset | |
| have hli : LinearIndepOn K v (B : Set ΞΉ) := by | |
| simpa only [B, Set.Finite.coe_toFinset] using hA.linearIndepOn_extend hsub | |
| have hspan : Submodule.span K (v '' (B : Set ΞΉ)) = | |
| Submodule.span K (v '' (S : Set ΞΉ)) := by | |
| simpa only [B, Set.Finite.coe_toFinset] using hA.span_image_extend_eq_span_image hsub | |
| have hcard : Module.finrank K (Submodule.span K (v '' (B : Set ΞΉ))) = B.card := by | |
| have hh := finrank_span_eq_card (hli.linearIndependent_restrict) | |
| change Module.finrank K (Submodule.span K (Set.range (fun a : B => v a))) = _ at hh | |
| have hr : Set.range (fun a : B => v a) = v '' (B : Set ΞΉ) := by | |
| ext x | |
| constructor | |
| Β· rintro β¨a,rflβ©; exact β¨a,a.property,rflβ© | |
| Β· rintro β¨a,ha,rflβ©; exact β¨β¨a,haβ©,rflβ© | |
| rw [hr] at hh | |
| simpa using hh | |
| have hAB : A β B := fun a ha => hfin.mem_toFinset.mpr (hA.subset_extend hsub ha) | |
| have hBS : B β S := fun a ha => hTs (hfin.mem_toFinset.mp ha) | |
| have hmB : m β€ B.card := by rw [β hcard,hspan]; exact hm | |
| obtain β¨C,hAC,hCB,hCβ© := Finset.exists_subsuperset_card_eq hAB hAm hmB | |
| exact β¨C,hAC,hCB.trans hBS,hC,hli.mono hCBβ© | |
| theorem hilbert_simplex_shift (h : β) (hh : 0 < h) (Ξ΄ c : β) | |
| (hΞ΄ : 0 < Ξ΄) (hc : 0 β€ c) : | |
| β C : β, 1 β€ C β§ β t : β, | |
| ((t+h).choose h : β) β€ (Ξ΄*t+C)^h / ((h.factorial : β)*Ξ΄^h) - | |
| c*(Ξ΄*t+C)^(h-1) := by | |
| let a : β := (h.factorial : β)*c*Ξ΄^(h-1) + 1/Ξ΄ | |
| let C : β := Ξ΄*((h : β)+a) | |
| have hf : (0 : β) < h.factorial := by exact_mod_cast h.factorial_pos | |
| have ha0 : 0 β€ a := by dsimp [a]; positivity | |
| have hC : 1 β€ C := by | |
| dsimp [C,a] | |
| rw [mul_add, mul_add, div_eq_mul_inv, one_mul, mul_inv_cancelβ hΞ΄.ne'] | |
| have hN : 0 β€ Ξ΄*(h:β)+Ξ΄*((h.factorial:β)*c*Ξ΄^(h-1)) := by positivity | |
| linarith | |
| refine β¨C,hC,fun t => ?_β© | |
| let x : β := (t+h : β)+a | |
| have hx : 0 β€ x := by dsimp [x]; positivity | |
| have hlow : ((t+h : β) : β) β€ x := by dsimp [x]; linarith | |
| have hT : Ξ΄*t+C = Ξ΄*x := by dsimp [C,x]; push_cast; ring | |
| have hpow : x^h = x^(h-1)*x := by rw [β pow_succ,Nat.sub_add_cancel hh] | |
| have hnum : ((t+h : β) : β)^h β€ x^h - (h.factorial : β)*c*Ξ΄^(h-1)*x^(h-1) := by | |
| have hq : ((t+h : β) : β)^(h-1) β€ x^(h-1) := | |
| pow_le_pow_leftβ (Nat.cast_nonneg _) hlow _ | |
| have hb : ((t+h : β) : β) β€ x - (h.factorial : β)*c*Ξ΄^(h-1) := by | |
| dsimp [x,a] | |
| linarith [div_nonneg (by norm_num : (0:β) β€ 1) hΞ΄.le] | |
| calc | |
| _ = ((t+h : β) : β)^(h-1)*((t+h : β) : β) := by | |
| rw [β pow_succ,Nat.sub_add_cancel hh] | |
| _ β€ x^(h-1)*(x-(h.factorial : β)*c*Ξ΄^(h-1)) := | |
| mul_le_mul hq hb (Nat.cast_nonneg _) (pow_nonneg hx _) | |
| _ = _ := by rw [hpow]; ring | |
| have hb := (Nat.choose_le_pow_div h (t+h) : ((t+h).choose h : β) β€ | |
| ((t+h : β) : β)^h / (h.factorial : β)) | |
| apply hb.trans | |
| rw [hT,mul_pow,mul_pow] | |
| have he : Ξ΄^h*x^h / ((h.factorial:β)*Ξ΄^h) - c*(Ξ΄^(h-1)*x^(h-1)) = | |
| (x^h-(h.factorial:β)*c*Ξ΄^(h-1)*x^(h-1))/(h.factorial:β) := by | |
| field_simp | |
| rw [he] | |
| exact div_le_div_of_nonneg_right hnum hf.le | |
| theorem simplex_order_step (h t : β) : | |
| h*((t+1+h).choose (h+1)) + (t+1)*((t+h).choose h) = | |
| h*((t+h).choose (h+1)) + (t+1)*((t+1+h).choose h) := by | |
| have hβ := Nat.choose_succ_succ (t+h) h | |
| have hβ := Nat.choose_mul_succ_eq (t+h) h | |
| rw [show t+h+1-h = t+1 by omega] at hβ | |
| rw [show t+1+h = t+h+1 by omega] | |
| nlinarith | |
| theorem independent_weighted_simplex {K V ΞΉ : Type*} [Field K] | |
| [AddCommGroup V] [Module K V] (v : ΞΉ β V) (S : β β Finset ΞΉ) | |
| (hS : β t, S t β S (t+1)) (w : ΞΉ β β) (Ξ΄ C : β) | |
| (hweight : β t a, a β S t β w a β€ Ξ΄*t+C) | |
| (h : β) (hrank : β t, (t+h).choose h β€ | |
| Module.finrank K (Submodule.span K (v '' (S t : Set ΞΉ)))) (t : β) : | |
| β A : Finset ΞΉ, A β S t β§ A.card = (t+h).choose h β§ | |
| LinearIndepOn K v (A : Set ΞΉ) β§ | |
| β a β A, w a β€ Ξ΄*(h*((t+h).choose (h+1)) : β) + C*((t+h).choose h) := by | |
| classical | |
| induction t with | |
| | zero => | |
| obtain β¨A,_,hA,hcard,hliβ© := extend_independent_finset v (S 0) β | |
| (Finset.empty_subset _) (by simp) | |
| ((0+h).choose h) (by simp) (hrank 0) | |
| refine β¨A,hA,hcard,hli,?_β© | |
| have hb := Finset.sum_le_sum (s := A) (fun a ha => hweight 0 a (hA ha)) | |
| simpa only [Nat.cast_zero,mul_zero,zero_add,Finset.sum_const, nsmul_eq_mul, | |
| hcard,Nat.choose_self,Nat.cast_one,mul_one,one_mul,Nat.choose_eq_zero_of_lt (Nat.lt_succ_self h), | |
| Nat.mul_zero] using hb | |
| | succ t ih => | |
| obtain β¨A,hA,hcard,hli,hsumβ© := ih | |
| have hcount : A.card β€ (t+1+h).choose h := by | |
| rw [hcard] | |
| exact Nat.choose_le_choose h (by omega) | |
| obtain β¨B,hAB,hB,hBcard,hlBβ© := extend_independent_finset v (S (t+1)) A | |
| (hA.trans (hS t)) hli ((t+1+h).choose h) hcount (hrank (t+1)) | |
| refine β¨B,hB,hBcard,hlB,?_β© | |
| have hnew : β a β B \ A, w a β€ ((B \ A).card : β)*(Ξ΄*(t+1)+C) := by | |
| calc | |
| _ β€ β _a β B \ A, (Ξ΄*(t+1)+C) := by | |
| apply Finset.sum_le_sum | |
| intro a ha | |
| have haW := hweight (t+1) a (hB (Finset.mem_sdiff.mp ha).1) | |
| simpa only [Nat.cast_add,Nat.cast_one] using haW | |
| _ = _ := by rw [Finset.sum_const,nsmul_eq_mul] | |
| have hsplit : (β a β B \ A, w a) + (β a β A, w a) = β a β B, w a := | |
| Finset.sum_sdiff hAB | |
| have hcarddiff : ((B \ A).card : β) = (B.card : β)-(A.card : β) := by | |
| rw [Finset.card_sdiff_of_subset hAB,Nat.cast_sub (Finset.card_le_card hAB)] | |
| have hstep : (h*((t+1+h).choose (h+1)) : β) + | |
| ((t+1)*((t+h).choose h) : β) = | |
| (h*((t+h).choose (h+1)) : β) + ((t+1)*((t+1+h).choose h) : β) := | |
| simplex_order_step h t | |
| have hstepR : (h*((t+1+h).choose (h+1)) : β) + | |
| ((t:β)+1)*((t+h).choose h) = | |
| (h*((t+h).choose (h+1)) : β) + ((t:β)+1)*((t+1+h).choose h) := by | |
| exact_mod_cast hstep | |
| rw [hcarddiff,hcard,hBcard] at hnew | |
| push_cast at hsum β’ | |
| have he : (Ξ΄*(t+1)+C)*(((t+1+h).choose h : β)-((t+h).choose h : β)) + | |
| (Ξ΄*(h:β)*((t+h).choose (h+1))) + C*((t+h).choose h) = | |
| Ξ΄*(h:β)*((t+1+h).choose (h+1)) + C*((t+1+h).choose h) := by | |
| nlinarith [congrArg (fun x : β => Ξ΄*x) hstepR] | |
| rw [β hsplit] | |
| calc | |
| _ β€ (( (t+1+h).choose h : β)-((t+h).choose h : β))*(Ξ΄*(t+1)+C) + | |
| (Ξ΄*((h:β)*((t+h).choose (h+1))) + C*((t+h).choose h)) := add_le_add hnew hsum | |
| _ = _ := by nlinarith [he] | |
| open scoped BigOperators | |
| open MvPolynomial | |
| noncomputable def monomialWeight {Ο : Type*} [Fintype Ο] | |
| (Ο : Ο β β) (a : Ο ββ β) : β := β i, Ο i*(a i : β) | |
| theorem monomialWeight_nonneg {Ο : Type*} [Fintype Ο] | |
| (Ο : Ο β β) (hΟ : β i, 0 β€ Ο i) (a : Ο ββ β) : 0 β€ monomialWeight Ο a := | |
| Finset.sum_nonneg (fun i _ => mul_nonneg (hΟ i) (Nat.cast_nonneg _)) | |
| noncomputable def weightedExponentBound {Ο : Type*} [Fintype Ο] | |
| (Ο : Ο β β) (T : β) : Ο ββ β := Finsupp.equivFunOnFinite.symm (fun i => βT/Ο iββ) | |
| noncomputable def weightedMonomials {Ο : Type*} [Fintype Ο] | |
| (Ο : Ο β β) (T : β) : Finset (Ο ββ β) := by | |
| classical | |
| exact (Finset.Iic (weightedExponentBound Ο T)).filter fun a => monomialWeight Ο a β€ T | |
| theorem mem_weightedMonomials {Ο : Type*} [Fintype Ο] | |
| (Ο : Ο β β) (hΟ : β i, 0 < Ο i) (T : β) (a : Ο ββ β) : | |
| a β weightedMonomials Ο T β monomialWeight Ο a β€ T := by | |
| classical | |
| constructor | |
| Β· exact fun h => (Finset.mem_filter.mp h).2 | |
| Β· intro ha | |
| refine Finset.mem_filter.mpr β¨Finset.mem_Iic.mpr ?_,haβ© | |
| intro i | |
| change a i β€ βT/Ο iββ | |
| apply Nat.le_floor | |
| apply (le_div_iffβ (hΟ i)).mpr | |
| have hi := Finset.single_le_sum | |
| (fun j _ => mul_nonneg (hΟ j).le (Nat.cast_nonneg (a j))) (Finset.mem_univ i) | |
| simpa only [mul_comm (a i : β)] using hi.trans ha | |
| theorem weightedMonomials_mono {Ο : Type*} [Fintype Ο] | |
| (Ο : Ο β β) (hΟ : β i, 0 < Ο i) {S T : β} (h : S β€ T) : | |
| weightedMonomials Ο S β weightedMonomials Ο T := by | |
| intro a ha | |
| exact (mem_weightedMonomials Ο hΟ T a).mpr | |
| (((mem_weightedMonomials Ο hΟ S a).mp ha).trans h) | |
| noncomputable def weightedDegreeBound {Ο : Type*} [Fintype Ο] | |
| (Ο : Ο β β) (T : β) : β := β i, βT/Ο iββ | |
| theorem weighted_monomial_degree_bound {Ο : Type*} [Fintype Ο] | |
| (Ο : Ο β β) (hΟ : β i, 0 < Ο i) (T : β) (a : Ο ββ β) | |
| (ha : monomialWeight Ο a β€ T) : a.sum (fun _ e => e) β€ weightedDegreeBound Ο T := by | |
| classical | |
| have hs := (Finset.mem_filter.mp ((mem_weightedMonomials Ο hΟ T a).mpr ha)).1 | |
| have hb : a β€ weightedExponentBound Ο T := Finset.mem_Iic.mp hs | |
| rw [Finsupp.sum_fintype _ _ (by simp)] | |
| exact Finset.sum_le_sum (fun i _ => hb i) | |
| noncomputable def weightedFunctions {Ο K : Type*} [Fintype Ο] [Field K] | |
| (I : Ideal (MvPolynomial Ο K)) (Ο : Ο β β) (T : β) : | |
| Submodule K (MvPolynomial Ο K β§Έ I) := | |
| Submodule.span K ((fun a => Ideal.Quotient.mk I (monomial a (1:K))) '' | |
| (weightedMonomials Ο T : Set (Ο ββ β))) | |
| instance weightedFunctions_finite {Ο K : Type*} [Fintype Ο] [Field K] | |
| (I : Ideal (MvPolynomial Ο K)) (Ο : Ο β β) (T : β) : | |
| Module.Finite K (weightedFunctions I Ο T) := by | |
| classical | |
| exact Module.Finite.span_of_finite K ((weightedMonomials Ο T).finite_toSet.image _) | |
| noncomputable def weightedHilbert {Ο K : Type*} [Fintype Ο] [Field K] | |
| (I : Ideal (MvPolynomial Ο K)) (Ο : Ο β β) (T : β) : β := | |
| Module.finrank K (weightedFunctions I Ο T) | |
| theorem integer_monomial_abs_le {Ο : Type*} [Fintype Ο] | |
| (Ο : Ο β β) (C X : β) (hC : 1 β€ C) (hX : 0 < X) | |
| (z : Ο β β€) (hz : β i, |(z i : β)| β€ C * X^(Ο i)) (a : Ο ββ β) | |
| (D : β) (hD : a.sum (fun _ e => e) β€ D) : | |
| |((eval z (monomial a (1:β€)) : β€) : β)| β€ C^D * X^(monomialWeight Ο a) := by | |
| classical | |
| have hprod : |((eval z (monomial a (1:β€)) : β€) : β)| = β i, |(z i : β)|^(a i) := by | |
| rw [eval_monomial,one_mul,Finsupp.prod_fintype _ _ (by simp)] | |
| simp only [Int.cast_prod,Int.cast_pow,Finset.abs_prod,abs_pow] | |
| have hexp : (β i, (X^(Ο i))^(a i)) = X^(monomialWeight Ο a) := by | |
| simp_rw [β Real.rpow_mul_natCast hX.le] | |
| rw [β Real.rpow_sum_of_pos hX] | |
| rfl | |
| calc | |
| _ = β i, |(z i : β)|^(a i) := hprod | |
| _ β€ β i, (C*X^(Ο i))^(a i) := Finset.prod_le_prodβ | |
| (fun i _ => pow_nonneg (abs_nonneg _) _) (fun i _ => pow_le_pow_leftβ (abs_nonneg _) (hz i) _) | |
| _ = C^(a.sum (fun _ e => e)) * X^(monomialWeight Ο a) := by | |
| simp_rw [mul_pow] | |
| rw [Finset.prod_mul_distrib,Finset.prod_pow_eq_pow_sum,hexp] | |
| rw [Finsupp.sum_fintype _ _ (by simp)] | |
| _ β€ _ := mul_le_mul_of_nonneg_right (pow_le_pow_rightβ hC hD) (Real.rpow_nonneg hX.le _) | |
| end | |
| open scoped BigOperators | |
| open MvPolynomial | |
| theorem select_weighted_monomials {Ο K : Type*} [Fintype Ο] [Field K] | |
| (I : Ideal (MvPolynomial Ο K)) (Ο : Ο β β) (hΟ : β i, 0 < Ο i) | |
| (h : β) (hh : 0 < h) (Ξ΄ c : β) (hΞ΄ : 0 < Ξ΄) (hc : 0 β€ c) | |
| (hH : β T : β, 1 β€ T β T^h / ((h.factorial : β)*Ξ΄^h)-c*T^(h-1) β€ | |
| weightedHilbert I Ο T) : | |
| β C : β, 1 β€ C β§ β t : β, β A : Finset (Ο ββ β), | |
| A.card = (t+h).choose h β§ | |
| LinearIndepOn K (fun a => Ideal.Quotient.mk I (monomial a (1:K))) (A : Set _) β§ | |
| (β a β A, monomialWeight Ο a β€ Ξ΄*t+C) β§ | |
| (β a β A, a.sum (fun _ e => e) β€ weightedDegreeBound Ο (Ξ΄*t+C)) β§ | |
| β a β A, monomialWeight Ο a β€ Ξ΄*(h*((t+h).choose (h+1)) : β)+C*((t+h).choose h) := by | |
| obtain β¨C,hC,hshiftβ© := hilbert_simplex_shift h hh Ξ΄ c hΞ΄ hc | |
| refine β¨C,hC,?_β© | |
| intro t | |
| let S := fun t : β => weightedMonomials Ο (Ξ΄*t+C) | |
| have hS : β t, S t β S (t+1) := by | |
| intro t | |
| apply weightedMonomials_mono Ο hΟ | |
| push_cast | |
| linarith | |
| have hw : β t a, a β S t β monomialWeight Ο a β€ Ξ΄*t+C := by | |
| intro t a ha | |
| exact (mem_weightedMonomials Ο hΟ _ a).mp ha | |
| have hr : β t, (t+h).choose h β€ Module.finrank K | |
| (Submodule.span K ((fun a => Ideal.Quotient.mk I (monomial a (1:K))) '' (S t : Set _))) := by | |
| intro t | |
| have hT : 1 β€ Ξ΄*(t:β)+C := by nlinarith [mul_nonneg hΞ΄.le (Nat.cast_nonneg t)] | |
| have hb := (hshift t).trans (hH _ hT) | |
| exact_mod_cast hb | |
| obtain β¨A,hA,hcard,hli,hsumβ© := independent_weighted_simplex | |
| (fun a => Ideal.Quotient.mk I (monomial a (1:K))) S hS (monomialWeight Ο) Ξ΄ C hw h hr t | |
| refine β¨A,hcard,hli,fun a ha => hw t a (hA ha),?_,hsumβ© | |
| exact fun a ha => weighted_monomial_degree_bound Ο hΟ _ a (hw t a (hA ha)) | |
| theorem exists_simplex_margin (h : β) (hh : 0 < h) (Ξ½ C : β) (hΞ½ : 0 < Ξ½) : | |
| β t : β, 0 < (t+h).choose h β§ | |
| (C+1)*((t+h).choose h : β) β€ Ξ½*(h*((t+h).choose (h+1)) : β) := by | |
| obtain β¨t,htβ© := exists_nat_gt (((C+1)*((h:β)+1))/(Ξ½*h)) | |
| have hp : 0 < Ξ½*(h:β) := mul_pos hΞ½ (by exact_mod_cast hh) | |
| have ht' := (div_lt_iffβ hp).mp ht | |
| have hchoose : (h+1)*((t+h).choose (h+1)) = t*((t+h).choose h) := by | |
| have hc := Nat.add_one_mul_choose_eq (t+h) h | |
| rw [Nat.choose_succ_succ] at hc | |
| nlinarith | |
| have hr : ((h:β)+1)*((t+h).choose (h+1) : β) = (t:β)*((t+h).choose h) := by | |
| exact_mod_cast hchoose | |
| have hL : 0 < (t+h).choose h := Nat.choose_pos (by omega) | |
| refine β¨t,hL,?_β© | |
| have hb := mul_le_mul_of_nonneg_right ht'.le (show (0:β) β€ (t+h).choose h by positivity) | |
| push_cast | |
| nlinarith | |
| end QuarticPowerFree | |
| end OAI | |