Download data/lean/OAI/Algebra/Determinantal/Model.lean from introvoyz045/math: direct link, hf CLI and curl.
- Browser
- Download file 15.1 kB
-
https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/Algebra/Determinantal/Model.lean
- Command line
-
hf download hf://datasets/introvoyz045/math/data/lean/OAI/Algebra/Determinantal/Model.lean
-
curl -L -o Model.lean https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/Algebra/Determinantal/Model.lean
15.1 kB
| import OAI.Algebra.Determinantal.RankTransfer | |
| namespace OAI | |
| namespace PermanentBorder.Polar | |
| open scoped Classical | |
| variable {ΞΉ : Type*} [Fintype ΞΉ] | |
| lemma isInvertible_of_injective (D : (ΞΉ β β) βL[β] (ΞΉ β β)) | |
| (hD : Function.Injective D) : D.IsInvertible := by | |
| have hs : Function.Surjective D := (LinearMap.injective_iff_surjective).mp hD | |
| let e := LinearEquiv.ofBijective D.toLinearMap β¨hD,hsβ© | |
| exact β¨e.toContinuousLinearEquiv, rflβ© | |
| lemma normalizer_simple_restrict | |
| (e : (Option ΞΉ β β) βL[β] (Option ΞΉ β β)) | |
| (F : (Option ΞΉ β β) β (Option ΞΉ β β)) | |
| (hfirst : β y, F y none = e y none - 1) (z : ΞΉ β β) | |
| (hF : DifferentiableAt β F (affineNormChart e z)) | |
| (hs : (fderiv β F (affineNormChart e z)).IsInvertible) : | |
| (fderiv β (fun z i => F (affineNormChart e z) (some i)) z).IsInvertible := by | |
| let D := (fderiv β F (affineNormChart e z)).comp | |
| (e.symm.toContinuousLinearMap.comp optionInsert) | |
| have hfull : HasFDerivAt (fun z => F (affineNormChart e z)) D z := | |
| hF.hasFDerivAt.comp z (affineNormChart_hasFDerivAt e z) | |
| let E : (ΞΉ β β) βL[β] (ΞΉ β β) := | |
| ContinuousLinearMap.pi (fun i => (ContinuousLinearMap.proj (some i)).comp D) | |
| have hred : HasFDerivAt (fun z i => F (affineNormChart e z) (some i)) E z := | |
| hasFDerivAt_pi.mpr (fun i => (ContinuousLinearMap.proj (some i) : (Option ΞΉ β β) βL[β] β).hasFDerivAt.comp z hfull) | |
| have hzero : (fun z => F (affineNormChart e z) none) = fun _ => (0 : β) := by | |
| funext z | |
| rw [hfirst, affineNormChart, e.apply_symm_apply] | |
| simp | |
| have hnone : (ContinuousLinearMap.proj none).comp D = 0 := by | |
| have hd := (ContinuousLinearMap.proj none : (Option ΞΉ β β) βL[β] β).hasFDerivAt.comp z hfull | |
| change HasFDerivAt (fun z => F (affineNormChart e z) none) _ z at hd | |
| rw [hzero] at hd | |
| exact hd.unique (hasFDerivAt_const _ _) | |
| rw [hred.fderiv] | |
| apply isInvertible_of_injective | |
| apply LinearMap.ker_eq_bot.mp | |
| apply LinearMap.ker_eq_bot'.mpr | |
| intro v hv | |
| have hd : D v = 0 := by | |
| funext i | |
| cases i with | |
| | none => exact congrArg (fun T : (ΞΉ β β) βL[β] β => T v) hnone | |
| | some i => exact congrFun hv i | |
| have he : e.symm (optionInsert v) = 0 := hs.injective (hd.trans (map_zero _).symm) | |
| have hi : optionInsert v = 0 := e.symm.injective (he.trans (map_zero _).symm) | |
| exact funext (fun i => congrFun hi (some i)) | |
| end PermanentBorder.Polar | |
| namespace PermanentBorder.Polar | |
| open MvPolynomial | |
| open scoped Classical | |
| variable {Ο : Type*} [Fintype Ο] | |
| theorem smooth_polar_affine_certificate (f : MvPolynomial (PolarVars Ο) β) | |
| {r : β} (hr : 2 β€ r) (hh : f.IsHomogeneous r) | |
| (hs : β y : PolarVars Ο β β, eval y f = 0 β | |
| (β j, eval y (pderiv j f) = 0) β y = 0) : | |
| β w : Ο β PolarVars Ο β β, | |
| β e : (PolarVars Ο β β) βL[β] (PolarVars Ο β β), | |
| β x : Fin (r * (r-1)^Fintype.card Ο) β Option Ο β β, | |
| Function.Injective x β§ | |
| β i, (fun j => eval (affineNormChart e (x i)) (hypersurfacePolars w f j)) = 0 β§ | |
| (fderiv β (fun z j => eval (affineNormChart e z) | |
| (hypersurfacePolars w f j)) (x i)).IsInvertible := by | |
| classical | |
| obtain β¨w,l,hg,hcardβ© := smooth_polar_count f hr hh hs | |
| let R := CI.Roots (hypersurfacePolars w f) l | |
| have hpos : 0 < Nat.card R := by | |
| rw [show Nat.card R = _ from hcard] | |
| exact Nat.mul_pos (by omega) (Nat.pow_pos (by omega)) | |
| have : Finite R := (Nat.card_pos_iff.mp hpos).2 | |
| let : Fintype R := Fintype.ofFinite R | |
| have hcard' : Fintype.card R = r * (r-1)^Fintype.card Ο := by | |
| simpa only [Nat.card_eq_fintype_card] using hcard | |
| let q : Fin (r * (r-1)^Fintype.card Ο) β R := (Fintype.equivFinOfCardEq hcard').symm | |
| have hl : l β 0 := by | |
| intro hz | |
| obtain β¨yβ© := (Nat.card_pos_iff.mp hpos).1 | |
| have hy := y.property.2 | |
| simp [CI.eval_linear, hz] at hy | |
| obtain β¨e,heβ© := exists_normalizer_equiv l hl | |
| have hy (i : Fin (r * (r-1)^Fintype.card Ο)) : e (q i).val none = 1 := by | |
| rw [he, β CI.eval_linear] | |
| exact (q i).property.2 | |
| choose x hx using fun i => exists_chart_preimage e (hy i) | |
| refine β¨w,e,x,?_,?_β© | |
| Β· intro i j hij | |
| apply q.injective | |
| apply Subtype.ext | |
| rw [β hx i, β hx j, hij] | |
| Β· intro i | |
| have hz : (fun j => eval (q i).val (CI.normalized (hypersurfacePolars w f) l j)) = 0 := | |
| (CI.normalized_eval_zero_iff _ _ _).mpr (q i).property | |
| constructor | |
| Β· rw [hx i] | |
| exact funext (q i).property.1 | |
| Β· have hfirst (y : PolarVars Ο β β) : | |
| eval y (CI.normalized (hypersurfacePolars w f) l none) = e y none - 1 := by | |
| change eval y (CI.linear l - 1) = _ | |
| rw [map_sub, map_one, CI.eval_linear, he] | |
| apply normalizer_simple_restrict e | |
| (fun y j => eval y (CI.normalized (hypersurfacePolars w f) l j)) hfirst (x i) | |
| Β· exact ((contDiff_pi.mpr (fun j => CI.contDiff_eval | |
| (CI.normalized (hypersurfacePolars w f) l j))).differentiable (by decide)) _ | |
| Β· rw [hx i] | |
| exact CI.good_derivative_invertible _ _ _ hg hz | |
| end PermanentBorder.Polar | |
| namespace PermanentBorder | |
| open Filter | |
| open scoped Topology | |
| abbrev Variables (m : β) := Fin m Γ Fin m | |
| abbrev Poly (Ο : Type*) := MvPolynomial Ο β | |
| noncomputable def permanentPolynomial (m : β) : Poly (Variables m) := | |
| β Ο : Equiv.Perm (Fin m), β i : Fin m, MvPolynomial.X (i, Ο i) | |
| noncomputable def affineMatrixPolynomial {Ο : Type*} [Fintype Ο] (n : β) | |
| (Aβ : Matrix (Fin n) (Fin n) β) | |
| (A : Ο β Matrix (Fin n) (Fin n) β) : Poly Ο := | |
| Matrix.det (fun i j => MvPolynomial.C (Aβ i j) + | |
| β v : Ο, MvPolynomial.C (A v i j) * MvPolynomial.X v) | |
| def HasBorderDeterminant {Ο : Type*} [Fintype Ο] (n : β) (p : Poly Ο) : Prop := | |
| 0 < n β§ β (Aβ : β β Matrix (Fin n) (Fin n) β) | |
| (A : β β Ο β Matrix (Fin n) (Fin n) β), | |
| β d : Ο ββ β, Tendsto | |
| (fun j => (affineMatrixPolynomial n (Aβ j) (A j)).coeff d) | |
| atTop (π (p.coeff d)) | |
| def HasExactDeterminant {Ο : Type*} [Fintype Ο] (n : β) (p : Poly Ο) : Prop := | |
| 0 < n β§ β (Aβ : Matrix (Fin n) (Fin n) β) | |
| (A : Ο β Matrix (Fin n) (Fin n) β), affineMatrixPolynomial n Aβ A = p | |
| theorem HasExactDeterminant.hasBorderDeterminant {Ο : Type*} [Fintype Ο] | |
| {n : β} {p : Poly Ο} (h : HasExactDeterminant n p) : | |
| HasBorderDeterminant n p := by | |
| rcases h with β¨hn, Aβ, A, hpβ© | |
| refine β¨hn, (fun _ => Aβ), (fun _ => A), ?_β© | |
| intro d | |
| simpa only [hp] using | |
| (tendsto_const_nhds : Tendsto (fun _ : β => p.coeff d) atTop (π (p.coeff d))) | |
| end PermanentBorder | |
| namespace PermanentBorder | |
| open MvPolynomial Filter | |
| open scoped Topology | |
| section FixedCoefficientSpace | |
| variable {Ο Ο : Type*} [Fintype Ο] | |
| noncomputable def exponentCube (n : β) : Finset (Ο ββ β) := | |
| by | |
| classical | |
| exact Finset.Iic (Finsupp.equivFunOnFinite.symm (fun _ : Ο => n)) | |
| @[simp] theorem mem_exponentCube (n : β) (d : Ο ββ β) : | |
| d β exponentCube (Ο := Ο) n β β i, d i β€ n := by | |
| classical | |
| simp only [exponentCube, Finset.mem_Iic, Finsupp.le_def] | |
| rfl | |
| theorem support_subset_exponentCube {P : Poly Ο} {n : β} (hP : P.totalDegree β€ n) : | |
| P.support β exponentCube n := by | |
| intro d hd | |
| rw [mem_exponentCube] | |
| intro i | |
| exact (monomial_le_degreeOf i hd).trans ((degreeOf_le_totalDegree P i).trans hP) | |
| theorem sum_over_exponentCube {P : Poly Ο} {n : β} | |
| (hP : P.support β exponentCube n) : | |
| P = β d β exponentCube n, monomial d (P.coeff d) := by | |
| calc | |
| P = β d β P.support, monomial d (P.coeff d) := MvPolynomial.as_sum P | |
| _ = _ := ?_ | |
| apply Finset.sum_subset hP | |
| intro d _ hd | |
| simp only [notMem_support_iff.mp hd, map_zero] | |
| theorem coeff_linear_map_cube (F : Poly Ο ββ[β] Poly Ο) {P : Poly Ο} {n : β} | |
| (hP : P.support β exponentCube n) (e : Ο ββ β) : | |
| (F P).coeff e = β d β exponentCube n, | |
| P.coeff d * (F (monomial d 1)).coeff e := by | |
| conv_lhs => rw [sum_over_exponentCube hP] | |
| simp only [map_sum, coeff_sum] | |
| apply Finset.sum_congr rfl | |
| intro d _ | |
| rw [show monomial d (P.coeff d) = P.coeff d β’ monomial d (1 : β) by simp [smul_monomial], | |
| map_smul, coeff_smul, smul_eq_mul] | |
| theorem support_subset_cube_of_limit {P : β β Poly Ο} {p : Poly Ο} {n : β} | |
| (hP : β j, (P j).support β exponentCube n) | |
| (hp : β d, Tendsto (fun j => (P j).coeff d) atTop (π (p.coeff d))) : | |
| p.support β exponentCube n := by | |
| classical | |
| intro d hd | |
| by_contra hn | |
| have hz : β j, (P j).coeff d = 0 := by | |
| intro j | |
| apply notMem_support_iff.mp | |
| exact fun hj => hn (hP j hj) | |
| have ht : Tendsto (fun _ : β => (0 : β)) atTop (π (p.coeff d)) := by | |
| simpa only [hz] using hp d | |
| have he : p.coeff d = 0 := (tendsto_nhds_unique tendsto_const_nhds ht).symm | |
| exact mem_support_iff.mp hd he | |
| theorem coefficientwise_linear_map_limit (F : Poly Ο ββ[β] Poly Ο) | |
| {P : β β Poly Ο} {p : Poly Ο} {n : β} | |
| (hP : β j, (P j).support β exponentCube n) | |
| (hp : β d, Tendsto (fun j => (P j).coeff d) atTop (π (p.coeff d))) : | |
| β e, Tendsto (fun j => (F (P j)).coeff e) atTop (π ((F p).coeff e)) := by | |
| intro e | |
| have hc := support_subset_cube_of_limit hP hp | |
| have ht := tendsto_finsetSum (exponentCube (Ο := Ο) n) | |
| (fun d _ => (hp d).mul (tendsto_const_nhds (x := (F (monomial d 1)).coeff e))) | |
| convert ht using 1 | |
| Β· funext j | |
| exact coeff_linear_map_cube F (hP j) e | |
| Β· congr 1 | |
| exact coeff_linear_map_cube F hc e | |
| end FixedCoefficientSpace | |
| section DeterminantDegree | |
| variable {Ο : Type*} [Fintype Ο] | |
| theorem degree_affine_form (b : β) (a : Ο β β) : | |
| (C b + β v : Ο, C (a v) * X v : Poly Ο).totalDegree β€ 1 := by | |
| apply (totalDegree_add _ _).trans | |
| apply max_le | |
| Β· simp | |
| Β· apply totalDegree_finsetSum_le | |
| intro v _ | |
| exact (totalDegree_mul _ _).trans (by simp) | |
| theorem degree_affineMatrixPolynomial (n : β) | |
| (Aβ : Matrix (Fin n) (Fin n) β) (A : Ο β Matrix (Fin n) (Fin n) β) : | |
| (affineMatrixPolynomial n Aβ A).totalDegree β€ n := by | |
| classical | |
| unfold affineMatrixPolynomial | |
| have he := Matrix.det_apply (show Matrix (Fin n) (Fin n) (Poly Ο) from | |
| fun i j => C (Aβ i j) + β v, C (A v i j) * X v) | |
| rw [he] | |
| apply totalDegree_finsetSum_le | |
| intro s _ | |
| apply (totalDegree_smul_le _ _).trans | |
| apply (totalDegree_finsetProd _ _).trans | |
| calc | |
| _ β€ β _ : Fin n, 1 := Finset.sum_le_sum fun i _ => degree_affine_form _ _ | |
| _ = n := by simp | |
| end DeterminantDegree | |
| section AffineSubstitution | |
| variable {Ο Ο : Type*} [Fintype Ο] [Fintype Ο] | |
| noncomputable def affineSubstitution (b : Ο β β) (B : Ο β Ο β β) : | |
| Poly Ο ββ[β] Poly Ο := | |
| MvPolynomial.aeval (fun v => C (b v) + β w : Ο, C (B v w) * X w) | |
| theorem affineSubstitution_matrix (b : Ο β β) (B : Ο β Ο β β) | |
| (n : β) (Aβ : Matrix (Fin n) (Fin n) β) (A : Ο β Matrix (Fin n) (Fin n) β) : | |
| affineSubstitution b B (affineMatrixPolynomial n Aβ A) = | |
| affineMatrixPolynomial n | |
| (fun i j => Aβ i j + β v : Ο, A v i j * b v) | |
| (fun w i j => β v : Ο, A v i j * B v w) := by | |
| classical | |
| unfold affineMatrixPolynomial | |
| have he := RingHom.map_det (affineSubstitution b B).toRingHom | |
| (show Matrix (Fin n) (Fin n) (Poly Ο) from | |
| fun i j => C (Aβ i j) + β v, C (A v i j) * X v) | |
| refine he.trans ?_ | |
| apply congrArg Matrix.det | |
| funext i j | |
| change (affineSubstitution b B) (C (Aβ i j) + β v, C (A v i j) * X v) = | |
| C (Aβ i j + β v, A v i j * b v) + β w, C (β v, A v i j * B v w) * X w | |
| simp only [affineSubstitution, map_add, map_sum, map_mul, | |
| aeval_C, aeval_X, algebraMap_eq] | |
| simp only [mul_add, Finset.mul_sum, Finset.sum_add_distrib, β map_mul] | |
| rw [β add_assoc] | |
| congr 1 | |
| rw [Finset.sum_comm] | |
| simp only [Finset.sum_mul, map_mul, mul_assoc] | |
| theorem HasBorderDeterminant.affineSubstitution {n : β} {p : Poly Ο} | |
| (h : HasBorderDeterminant n p) (b : Ο β β) (B : Ο β Ο β β) : | |
| HasBorderDeterminant n (affineSubstitution b B p) := by | |
| classical | |
| obtain β¨hn, Aβ, A, hlimβ© := h | |
| refine β¨hn, | |
| (fun l i j => Aβ l i j + β v : Ο, A l v i j * b v), | |
| (fun l w i j => β v : Ο, A l v i j * B v w), ?_β© | |
| have hf := coefficientwise_linear_map_limit (PermanentBorder.affineSubstitution b B).toLinearMap | |
| (fun l => support_subset_exponentCube (degree_affineMatrixPolynomial n (Aβ l) (A l))) hlim | |
| intro e | |
| simpa only [AlgHom.toLinearMap_apply, affineSubstitution_matrix] using hf e | |
| end AffineSubstitution | |
| end PermanentBorder | |
| namespace PermanentBorder | |
| open MvPolynomial Filter | |
| open scoped Topology | |
| section ScalarNormalization | |
| variable {Ο : Type*} [Fintype Ο] | |
| theorem affineMatrixPolynomial_scaleRow (n : β) (iβ : Fin n) (a : β) | |
| (Aβ : Matrix (Fin n) (Fin n) β) (A : Ο β Matrix (Fin n) (Fin n) β) : | |
| affineMatrixPolynomial n (Aβ.updateRow iβ (a β’ Aβ iβ)) | |
| (fun v => (A v).updateRow iβ (a β’ A v iβ)) = | |
| a β’ affineMatrixPolynomial n Aβ A := by | |
| classical | |
| let M : Matrix (Fin n) (Fin n) (Poly Ο) := | |
| fun i j => C (Aβ i j) + β v, C (A v i j) * X v | |
| let M' : Matrix (Fin n) (Fin n) (Poly Ο) := fun i j => | |
| C ((Aβ.updateRow iβ (a β’ Aβ iβ)) i j) + | |
| β v, C (((A v).updateRow iβ (a β’ A v iβ)) i j) * X v | |
| have hM : M' = M.updateRow iβ ((C a : Poly Ο) β’ M iβ) := by | |
| funext i j | |
| change C ((Aβ.updateRow iβ (a β’ Aβ iβ)) i j) + (β v, | |
| C (((A v).updateRow iβ (a β’ A v iβ)) i j) * X v) = _ | |
| by_cases hi : i = iβ | |
| Β· subst i | |
| rw [Matrix.updateRow_self, Matrix.updateRow_self] | |
| simp only [Matrix.updateRow_self, Pi.smul_apply, smul_eq_mul, map_mul] | |
| change _ = C a * (C (Aβ iβ j) + β v, C (A v iβ j) * X v) | |
| simp only [mul_add, Finset.mul_sum, mul_assoc] | |
| Β· rw [Matrix.updateRow_ne hi, Matrix.updateRow_ne hi] | |
| simp only [Matrix.updateRow_ne hi] | |
| rfl | |
| change M'.det = a β’ M.det | |
| rw [hM] | |
| rw [Matrix.det_updateRow_smul] | |
| rw [Matrix.updateRow_eq_self] | |
| exact (MvPolynomial.smul_eq_C_mul M.det a).symm | |
| theorem HasBorderDeterminant.smul {n : β} {p : Poly Ο} | |
| (h : HasBorderDeterminant n p) (a : β) : HasBorderDeterminant n (a β’ p) := by | |
| classical | |
| obtain β¨hn, Aβ, A, hlimβ© := h | |
| let iβ : Fin n := β¨0, hnβ© | |
| refine β¨hn, (fun l => (Aβ l).updateRow iβ (a β’ Aβ l iβ)), | |
| (fun l v => (A l v).updateRow iβ (a β’ A l v iβ)), ?_β© | |
| intro e | |
| simp only [affineMatrixPolynomial_scaleRow, coeff_smul, smul_eq_mul] | |
| exact tendsto_const_nhds.mul (hlim e) | |
| theorem HasBorderDeterminant.affineSubstitution_smul | |
| {Ο : Type*} [Fintype Ο] {n : β} {p : Poly Ο} | |
| (h : HasBorderDeterminant n p) (b : Ο β β) (B : Ο β Ο β β) (a : β) : | |
| HasBorderDeterminant n (a β’ PermanentBorder.affineSubstitution b B p) := | |
| (h.affineSubstitution b B).smul a | |
| end ScalarNormalization | |
| end PermanentBorder | |
| end OAI | |