math / data /lean /OAI /Algebra /Determinantal /Model.lean
introvoyz045's picture
Migrated from GitHub
4a56cd6 verified
Raw History Blame Contribute Delete
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