Module

AddCommGroupMvPolynomialTotalDegreeLeEvalEq.lean

Nyll.SchemeTheory.RingTheory.Polynomial.AddCommGroupMvPolynomialTotalDegreeLeEvalEq
8 declarations indexed from sourceView source ↗

Add Comm Group exists mv Polynomial total Degree le eval eq of forall exists polynomial

zsmul add

Imports10
Imported by3

Declarations

AlgebraicCurves.Foundations.Polynomial.Proofs.PolynomialAdditiveInterpolation.P2mPolyLines.mvPolynomial_eq_of_forall_eval_intCast_eq
Source context 6 commands

Surrounding namespaces, section variables, and local commands at this declaration.

@[expose] public section
section ProofImplementation
namespace AlgebraicCurves.Foundations.Polynomial.Proofs.PolynomialAdditiveInterpolation
open MvPolynomial Finset
namespace P2mPolyLines
variable {R : Type*}
theorem mvPolynomial_eq_of_forall_eval_intCast_eq [CommRing R] [IsDomain R] [CharZero R]
    {ι : Type*} {p q : MvPolynomial ι R}
    (h : ∀ c : ι → ℤ, eval (fun i => (c i : R)) p = eval (fun i => (c i : R)) q) : p = q :=
  open MvPolynomial_isHomogeneous_of_forall_eval_intCast_mul_eq_pow_mul.P2mPolyLines
    renaming mvPolynomial_eq_of_forall_eval_intCast_eq → integerEvaluationExt in
  integerEvaluationExt h
AlgebraicCurves.Foundations.Polynomial.Proofs.PolynomialAdditiveInterpolation.P2mPolyLines.eval_mul_of_isHomogeneous
Source context 6 commands

Surrounding namespaces, section variables, and local commands at this declaration.

@[expose] public section
section ProofImplementation
namespace AlgebraicCurves.Foundations.Polynomial.Proofs.PolynomialAdditiveInterpolation
open MvPolynomial Finset
namespace P2mPolyLines
variable {R : Type*}
theorem eval_mul_of_isHomogeneous [CommRing R] {ι : Type*} {φ : MvPolynomial ι R} {n : ℕ}
    (hφ : φ.IsHomogeneous n) (t : R) (x : ι → R) :
    eval (fun i => t * x i) φ = t ^ n * eval x φ :=
  open MvPolynomial_isHomogeneous_of_forall_eval_intCast_mul_eq_pow_mul.P2mPolyLines
    renaming eval_mul_of_isHomogeneous → homogeneousEvaluationMul in
  homogeneousEvaluationMul hφ t x
AlgebraicCurves.Foundations.Polynomial.Proofs.PolynomialAdditiveInterpolation.P2mPolyLines.LinePoly

A function whose restriction to every integral affine line is polynomial of degree at most d.

Source context 9 commands

Surrounding namespaces, section variables, and local commands at this declaration.

@[expose] public section
section ProofImplementation
namespace AlgebraicCurves.Foundations.Polynomial.Proofs.PolynomialAdditiveInterpolation
open MvPolynomial Finset
namespace P2mPolyLines
variable {R : Type*}
section Lines
variable [Field R]
variable {M : Type*} [AddCommGroup M]
def LinePoly (f : M → R) (d : ℕ) : Prop
AlgebraicCurves.Foundations.Polynomial.Proofs.PolynomialAdditiveInterpolation.P2mPolyLines.LinePoly.shift
Source context 9 commands

Surrounding namespaces, section variables, and local commands at this declaration.

@[expose] public section
section ProofImplementation
namespace AlgebraicCurves.Foundations.Polynomial.Proofs.PolynomialAdditiveInterpolation
open MvPolynomial Finset
namespace P2mPolyLines
variable {R : Type*}
section Lines
variable [Field R]
variable {M : Type*} [AddCommGroup M]
theorem LinePoly.shift {f : M → R} {d : ℕ} (hf : LinePoly f d) (a : M) :
    LinePoly (fun y => f (a + y)) d := by
  intro x y
  obtain ⟨p, hp, hpf⟩ := hf x (a + y)
  refine ⟨p, hp, fun n => ?_⟩
  rw [← hpf n, add_left_comm]
AlgebraicCurves.Foundations.Polynomial.Proofs.PolynomialAdditiveInterpolation.P2mPolyLines.exists_mvPolynomial_fin
Source context 10 commands

Surrounding namespaces, section variables, and local commands at this declaration.

@[expose] public section
section ProofImplementation
namespace AlgebraicCurves.Foundations.Polynomial.Proofs.PolynomialAdditiveInterpolation
open MvPolynomial Finset
namespace P2mPolyLines
variable {R : Type*}
section Lines
variable [Field R]
variable {M : Type*} [AddCommGroup M]
variable [CharZero R]
theorem exists_mvPolynomial_fin (d : ℕ) :
    ∀ (m : ℕ) (f : M → R), LinePoly f d → ∀ e : Fin m → M,
      ∃ P : MvPolynomial (Fin m) R, ∀ c : Fin m → ℤ,
        eval (fun i => (c i : R)) P = f (∑ i, c i • e i) := by
  intro m
  induction m with
  | zero =>
    intro f _ e
    refine ⟨C (f 0), fun c => ?_⟩
    rw [eval_C, Finset.univ_eq_empty, Finset.sum_empty]
  | succ m ih =>
    intro f hf e
    classical
    set s : Finset ℕ := range (d + 1) with hs
    set v : ℕ → R := fun j => (j : R) with hv
    have hvs : Set.InjOn v s := fun a _ b _ hab => by
      have hab' : (a : R) = (b : R) := hab
      exact_mod_cast hab'
    have hcard : #s = d + 1 := Finset.card_range _
    have hg : ∀ j : ℕ, LinePoly (fun y => f ((j : ℤ) • e 0 + y)) d := fun j => hf.shift _
    choose Q hQ using fun j : ℕ => ih (fun y => f ((j : ℤ) • e 0 + y)) (hg j) (fun i => e i.succ)
    refine ⟨∑ j ∈ s, (Lagrange.basis s v j).toMvPolynomial 0 * rename Fin.succ (Q j), fun c => ?_⟩
    set y : M := ∑ i : Fin m, c i.succ • e i.succ with hy
    have hsplit : (∑ i, c i • e i) = c 0 • e 0 + y := Fin.sum_univ_succ _
    obtain ⟨p, hp, hpf⟩ := hf (e 0) y
    have hpdeg : p.degree < #s := by
      rw [hcard]
      exact lt_of_le_of_lt (Polynomial.degree_le_of_natDegree_le hp)
        (by exact_mod_cast Nat.lt_succ_self d)
    have hLag := Lagrange.eq_interpolate (f := p) hvs hpdeg
    have hpc : p.eval (c 0 : R) = ∑ j ∈ s, p.eval (v j) * (Lagrange.basis s v j).eval (c 0 : R) :=
      by
      conv_lhs => rw [hLag]
      rw [Lagrange.interpolate_apply, Polynomial.eval_finsetSum]
      refine Finset.sum_congr rfl fun j _ => ?_
      rw [Polynomial.eval_mul, Polynomial.eval_C]
    rw [hsplit, hpf (c 0), hpc, map_sum]
    refine Finset.sum_congr rfl fun j _ => ?_
    rw [map_mul, eval_toMvPolynomial, eval_rename, mul_comm]
    congr 1
    have h1 : p.eval (v j) = f ((j : ℤ) • e 0 + y) := by
      rw [hpf (j : ℤ), hv, Int.cast_natCast]
    rw [h1, ← hQ j (fun i => c i.succ)]
    rfl
AlgebraicCurves.Foundations.Polynomial.Proofs.PolynomialAdditiveInterpolation.P2mPolyLines.exists_mvPolynomial_totalDegree_le
Source context 10 commands

Surrounding namespaces, section variables, and local commands at this declaration.

@[expose] public section
section ProofImplementation
namespace AlgebraicCurves.Foundations.Polynomial.Proofs.PolynomialAdditiveInterpolation
open MvPolynomial Finset
namespace P2mPolyLines
variable {R : Type*}
section Lines
variable [Field R]
variable {M : Type*} [AddCommGroup M]
variable [CharZero R]
theorem exists_mvPolynomial_totalDegree_le {ι : Type*} [Fintype ι] (f : M → R) (d : ℕ)
    (hf : LinePoly f d) (e : ι → M) (P : MvPolynomial ι R)
    (hP : ∀ c : ι → ℤ, eval (fun i => (c i : R)) P = f (∑ i, c i • e i)) :
    ∃ P' : MvPolynomial ι R, P'.totalDegree ≤ d ∧
      ∀ c : ι → ℤ, eval (fun i => (c i : R)) P' = f (∑ i, c i • e i) := by
  classical
  set N := P.totalDegree with hN
  have hcomp : ∀ k, d < k → homogeneousComponent k P = 0 := by
    intro k hdk
    by_cases hkN : N < k
    · exact homogeneousComponent_eq_zero k P hkN
    push Not at hkN
    apply mvPolynomial_eq_of_forall_eval_intCast_eq (R := R)
    intro c
    rw [map_zero]
    obtain ⟨p, hp, hpf⟩ := hf (∑ i, c i • e i) 0
    set q : Polynomial R :=
      ∑ j ∈ range (N + 1), Polynomial.C (eval (fun i => (c i : R)) (homogeneousComponent j P)) *
        Polynomial.X ^ j with hq
    have hqp : q = p := by
      apply Polynomial.eq_of_infinite_eval_eq
      refine Set.Infinite.mono (s := Set.range (Int.cast : ℤ → R)) ?_
        (Set.infinite_range_of_injective Int.cast_injective)
      rintro _ ⟨n, rfl⟩
      change Polynomial.eval (n : R) q = Polynomial.eval (n : R) p
      rw [← hpf n, add_zero, Finset.smul_sum]
      simp_rw [smul_smul]
      rw [← hP (fun i => n * c i), hq, Polynomial.eval_finsetSum]
      conv_rhs => rw [← sum_homogeneousComponent P, map_sum]
      refine Finset.sum_congr rfl fun j _ => ?_
      rw [Polynomial.eval_mul, Polynomial.eval_C, Polynomial.eval_pow, Polynomial.eval_X, mul_comm]
      have e1 : (fun i => ((n * c i : ℤ) : R)) = fun i => (n : R) * (c i : R) := by
        funext i; push_cast; ring
      rw [e1, eval_mul_of_isHomogeneous (homogeneousComponent_isHomogeneous j P)]
    have hcq : q.coeff k = eval (fun i => (c i : R)) (homogeneousComponent k P) := by
      rw [hq, Polynomial.finsetSum_coeff]
      simp only [Polynomial.coeff_C_mul_X_pow]
      rw [Finset.sum_ite_eq, ite_eq_left (Finset.mem_range.mpr (Nat.lt_succ_of_le hkN))]
    have hcp : p.coeff k = 0 := Polynomial.coeff_eq_zero_of_natDegree_lt (lt_of_le_of_lt hp hdk)
    rw [← hcq, hqp, hcp]
  refine ⟨∑ k ∈ range (d + 1), homogeneousComponent k P, ?_, fun c => ?_⟩
  · refine (totalDegree_finsetSum _ _).trans (Finset.sup_le fun k hk => ?_)
    exact (homogeneousComponent_isHomogeneous k P).totalDegree_le.trans
      (Nat.lt_succ_iff.mp (Finset.mem_range.mp hk))
  · rw [← hP c]
    conv_rhs => rw [← sum_homogeneousComponent P]
    rw [map_sum, map_sum]
    have key : ∀ k, eval (fun i => (c i : R)) (homogeneousComponent k P) =
        if k ≤ d ∧ k ≤ N then eval (fun i => (c i : R)) (homogeneousComponent k P) else 0 := by
      intro k
      split_ifs with hk
      · rfl
      · rw [not_and_or, not_le, not_le] at hk
        rcases hk with hk | hk
        · rw [hcomp k hk, map_zero]
        · rw [homogeneousComponent_eq_zero k P hk, map_zero]
    have hL : ∑ k ∈ range (d + 1), eval (fun i => (c i : R)) (homogeneousComponent k P) =
        ∑ k ∈ range (min d N + 1), eval (fun i => (c i : R)) (homogeneousComponent k P) := by
      rw [eq_comm]
      apply Finset.sum_subset (Finset.range_subset_range.mpr (by omega))
      intro k hk hk'
      rw [Finset.mem_range] at hk hk'
      rw [key, ite_eq_right]
      omega
    have hR : ∑ k ∈ range (N + 1), eval (fun i => (c i : R)) (homogeneousComponent k P) =
        ∑ k ∈ range (min d N + 1), eval (fun i => (c i : R)) (homogeneousComponent k P) := by
      rw [eq_comm]
      apply Finset.sum_subset (Finset.range_subset_range.mpr (by omega))
      intro k hk hk'
      rw [Finset.mem_range] at hk hk'
      rw [key, ite_eq_right]
      omega
    rw [hL, hR]
AlgebraicCurves.Foundations.Polynomial.Proofs.PolynomialAdditiveInterpolation.P2mPolyLines.exists_mvPolynomial_totalDegree_le_of_linePoly
Source context 10 commands

Surrounding namespaces, section variables, and local commands at this declaration.

@[expose] public section
section ProofImplementation
namespace AlgebraicCurves.Foundations.Polynomial.Proofs.PolynomialAdditiveInterpolation
open MvPolynomial Finset
namespace P2mPolyLines
variable {R : Type*}
section Lines
variable [Field R]
variable {M : Type*} [AddCommGroup M]
variable [CharZero R]
theorem exists_mvPolynomial_totalDegree_le_of_linePoly {ι : Type*} [Fintype ι] (f : M → R) (d : ℕ)
    (hf : LinePoly f d) (e : ι → M) :
    ∃ P : MvPolynomial ι R, P.totalDegree ≤ d ∧
      ∀ c : ι → ℤ, eval (fun i => (c i : R)) P = f (∑ i, c i • e i) := by
  classical
  set σ := Fintype.equivFin ι with hσ
  obtain ⟨P₀, hP₀⟩ := exists_mvPolynomial_fin d (Fintype.card ι) f hf (fun j => e (σ.symm j))
  refine exists_mvPolynomial_totalDegree_le f d hf e (rename σ.symm P₀) fun c => ?_
  rw [eval_rename]
  have h1 := hP₀ (fun j => c (σ.symm j))
  have h2 : (∑ j, c (σ.symm j) • e (σ.symm j)) = ∑ i, c i • e i :=
    Equiv.sum_comp σ.symm (fun i => c i • e i)
  rw [h2] at h1
  rw [← h1]
  rfl
AddCommGroup.exists_mvPolynomial_totalDegree_le_eval_eq_of_forall_exists_polynomial_zsmul_add
Source context 5 commands

Surrounding namespaces, section variables, and local commands at this declaration.

@[expose] public section
section ProofImplementation
namespace AddCommGroup
open _root_.AlgebraicCurves.Foundations.Polynomial.Proofs.PolynomialAdditiveInterpolation
open _root_.MvPolynomial _root_.Finset
theorem exists_mvPolynomial_totalDegree_le_eval_eq_of_forall_exists_polynomial_zsmul_add
    {M : Type*} [AddCommGroup M] {R : Type*} [Field R] [CharZero R] (f : M → R) (d : ℕ)
    (hf : ∀ x y : M, ∃ p : Polynomial R, p.natDegree ≤ d ∧
      ∀ n : ℤ, f (n • x + y) = p.eval (n : R))
    {ι : Type*} [Fintype ι] (e : ι → M) :
    ∃ P : MvPolynomial ι R, P.totalDegree ≤ d ∧
      ∀ c : ι → ℤ, MvPolynomial.eval (fun i => (c i : R)) P = f (∑ i, c i • e i) :=
  P2mPolyLines.exists_mvPolynomial_totalDegree_le_of_linePoly f d hf e