From 56bd3c831006a1f342a4dd2072d8f0935c3748bd Mon Sep 17 00:00:00 2001 From: Per Alexandersson Date: Sat, 14 Nov 2026 11:20:34 +0000 Subject: [PATCH] Affine PF successors, associated Bell rows, real Euler lag, affine-derivative criteria - #1809 OperatorMatrix/AffineSuccessor: no positive D term in affine PF successors (capped and unrestricted iff). - #1875 DerivativeRecurrence/AssociatedBell: half-step lag windows and PF rows for the associated Bell recurrence. - #1837 DerivativeRecurrence/RealEulerLag: real Euler-shift preserver and the weighted derivative-lag invariant. - #1774 OperatorMatrix/AffineDerivative: affine-derivative row and column iff criteria with the zero-aware directed anchor. Co-Authored-By: Claude Opus 5.5 --- RealRooted.lean | 4 + .../DerivativeRecurrence/AssociatedBell.lean | 90 +++++++ .../DerivativeRecurrence/RealEulerLag.lean | 183 +++++++++++++++ .../OperatorMatrix/AffineDerivative.lean | 222 ++++++++++++++++++ .../OperatorMatrix/AffineSuccessor.lean | 129 ++++++++++ RealRooted/Production.lean | 4 + scripts/import_architecture.json | 4 +- 7 files changed, 634 insertions(+), 2 deletions(-) create mode 100644 RealRooted/DerivativeRecurrence/AssociatedBell.lean create mode 100644 RealRooted/DerivativeRecurrence/RealEulerLag.lean create mode 100644 RealRooted/OperatorMatrix/AffineDerivative.lean create mode 100644 RealRooted/OperatorMatrix/AffineSuccessor.lean diff --git a/RealRooted.lean b/RealRooted.lean index a23969389..5ccb2218c 100644 --- a/RealRooted.lean +++ b/RealRooted.lean @@ -2248,3 +2248,7 @@ public import RealRooted.Applications.OEIS.A124324 public import RealRooted.Applications.OEIS.A144438 public import RealRooted.MatrixInterlacing.ThreeBidiagonalProduction public import RealRooted.Applications.PeakPolynomials.SignedStaircase +public import RealRooted.DerivativeRecurrence.AssociatedBell +public import RealRooted.DerivativeRecurrence.RealEulerLag +public import RealRooted.OperatorMatrix.AffineDerivative +public import RealRooted.OperatorMatrix.AffineSuccessor diff --git a/RealRooted/DerivativeRecurrence/AssociatedBell.lean b/RealRooted/DerivativeRecurrence/AssociatedBell.lean new file mode 100644 index 000000000..9b99a2ef3 --- /dev/null +++ b/RealRooted/DerivativeRecurrence/AssociatedBell.lean @@ -0,0 +1,90 @@ +module + +public import RealRooted.DerivativeRecurrence.HalfStepLag +import Mathlib.Data.Nat.Choose.Cast + +/-! +# Associated Bell rows + +Normalized associated Bell rows satisfy the seeded Euler recurrence with weight +`choose (q + 2 k - 1) (k - 1)`. For positive `k`, these weights are positive, +so the uniform half-step theorem gives PF rows, degree `m / k`, and directed +interlacing at every distance at most `k`. + +Source: *Uniform half-step lag windows* +([source](https://github.com/PerAlexandersson/real-zero-preservers/tree/9cccd381)), +`weyl-operators/notes/uniform-half-step-lag-windows.md`. +-/ + +public section + +open Polynomial + +noncomputable section + +namespace RealRooted + +/-- The associated Bell binomial weights are positive. -/ +theorem associatedBell_weight_pos {k : ℕ} (q : ℕ) : + 0 < (((q + 2 * k - 1).choose (k - 1) : ℕ) : ℝ) := by + exact_mod_cast Nat.choose_pos (show k - 1 ≤ q + 2 * k - 1 by lia) + +/-- The normalized associated Bell recurrence is a seeded half-step recurrence. -/ +theorem associatedBell_halfStepRows {A : ℕ → ℝ[X]} {k : ℕ} (hk : k ≠ 0) + (hseed : ∀ m, m < k → A m = 1) + (hstep : ∀ q, A (q + k) = thetaPlusOne (A (q + k - 1)) + + C (((q + 2 * k - 1).choose (k - 1) : ℕ) : ℝ) * X * A q) : + HalfStepRows A k (fun q ↦ (((q + 2 * k - 1).choose (k - 1) : ℕ) : ℝ)) := by + exact ⟨hk, hseed, hstep, associatedBell_weight_pos⟩ + +/-- Associated Bell rows are PF, have degree `m / k` and positive leading coefficient, +and every `k + 1` consecutive rows form a directed interlacing clique. -/ +theorem associatedBell_rows {A : ℕ → ℝ[X]} {k : ℕ} (hk : k ≠ 0) + (hseed : ∀ m, m < k → A m = 1) + (hstep : ∀ q, A (q + k) = thetaPlusOne (A (q + k - 1)) + + C (((q + 2 * k - 1).choose (k - 1) : ℕ) : ℝ) * X * A q) (m : ℕ) : + IsPFPolynomial (A m) ∧ (A m).natDegree = m / k ∧ HasPosLeadingCoeff (A m) ∧ + ∀ r, r ≤ k → StrictInterl (A m) (A (m + r)) := by + have h := associatedBell_halfStepRows hk hseed hstep + exact ⟨h.isPFPolynomial m, h.natDegree_eq_div m, h.hasPosLeadingCoeff m, + fun _ hr ↦ h.strictInterl_add_of_le m hr⟩ + +/-- The quadratic weight in the lag-three associated Bell recurrence. -/ +theorem associatedBell_weight_three (q : ℕ) : + (((q + 5).choose 2 : ℕ) : ℝ) = ((q : ℝ) + 4) * ((q : ℝ) + 5) / 2 := by + rw [Nat.cast_choose_two] + push_cast + ring + +/-- The cubic weight in the lag-four associated Bell recurrence. -/ +theorem associatedBell_weight_four (q : ℕ) : + (((q + 7).choose 3 : ℕ) : ℝ) = + ((q : ℝ) + 5) * ((q : ℝ) + 6) * ((q : ℝ) + 7) / 6 := by + have h := Nat.add_one_mul_choose_eq (q + 6) 2 + have hc : ((q : ℝ) + 7) * (((q + 6).choose 2 : ℕ) : ℝ) = + (((q + 7).choose 3 : ℕ) : ℝ) * 3 := by exact_mod_cast h + rw [Nat.cast_choose_two] at hc + push_cast at hc + linarith + +example {A : ℕ → ℝ[X]} (hseed : ∀ m, m < 1 → A m = 1) + (hstep : ∀ q, A (q + 1) = thetaPlusOne (A q) + X * A q) (m : ℕ) : + IsPFPolynomial (A m) ∧ (A m).natDegree = m ∧ StrictInterl (A m) (A (m + 1)) := by + have h := associatedBell_halfStepRows (k := 1) (by decide) hseed (by simpa using hstep) + exact ⟨h.isPFPolynomial m, by simpa using h.natDegree_eq_div m, + h.strictInterl_add_of_le m le_rfl⟩ + +example {A : ℕ → ℝ[X]} {k : ℕ} {c : ℕ → ℝ} (h : HalfStepRows A k c) : + A k = 1 + C (c 0) * X := by + simpa using h.halfStepSeq_two_mul_k + +example {A : ℕ → ℝ[X]} {k : ℕ} {c : ℕ → ℝ} (h : HalfStepRows A k c) (m n : ℕ) : + HalfStepWindow (halfStepSeq A) k n ∧ StrictInterl (A m) (A (m + k)) := by + exact ⟨h.halfStepWindow n, h.strictInterl_add_of_le m le_rfl⟩ + +example {A : ℕ → ℝ[X]} {k : ℕ} {c : ℕ → ℝ} {q : ℕ} (hc : c q < 0) : + ¬ HalfStepRows A k c := by + intro h + exact (not_lt_of_ge (h.pos q).le) hc + +end RealRooted diff --git a/RealRooted/DerivativeRecurrence/RealEulerLag.lean b/RealRooted/DerivativeRecurrence/RealEulerLag.lean new file mode 100644 index 000000000..b8889d592 --- /dev/null +++ b/RealRooted/DerivativeRecurrence/RealEulerLag.lean @@ -0,0 +1,183 @@ +module + +public import RealRooted.EulerOperator +public import RealRooted.EulerOperator.Shift +public import RealRooted.PFPolynomial +import RealRooted.MultiplierSequence.Laguerre +import RealRooted.MultiplierSequence.ProperPosition +import RealRooted.OperatorMatrix.Directed +import RealRooted.Wronskian.WeakForward + +/-! +# Real Euler shifts and weighted derivative lags + +For a fixed nonnegative real shift `s`, the decorated state consists of PF inputs +`p ≼ q` and `q ≼ X (θ + s + 1) p`. It is invariant under independently +nonnegative current and lag weights. The equations `B = s A` and +`D = (s + 1) C` recognize the displayed differential recurrence exactly. + +Source: *Derivative squared-variable lag invariant* +([source](https://github.com/PerAlexandersson/real-zero-preservers/tree/1bd277e)), +`weyl-operators/notes/derivative-x2-lag-invariant.md`. +-/ + +@[expose] public section + +open Polynomial + +noncomputable section + +namespace RealRooted + +/-- A nonnegative real Euler shift preserves the PF cone. -/ +theorem IsPFPolynomial.eulerShift_of_nonneg {p : ℝ[X]} (hp : IsPFPolynomial p) + {s : ℝ} (hs : 0 ≤ s) : IsPFPolynomial (eulerShift s p) := by + simpa only [diagonalOperator_natCast_add_eq_eulerShift] using + (isPFMultiplierSequence_natCast_add hs).diagonalOperator_isPF hp + +/-- Nonnegative real Euler shifts preserve directed PF pairs, including zero inputs. -/ +theorem eulerShift_orderedPF {s : ℝ} (hs : 0 ≤ s) {p q : ℝ[X]} + (hp : IsPFPolynomial p) (hq : IsPFPolynomial q) (hpq : Interl p q) : + IsPFPolynomial (eulerShift s p) ∧ IsPFPolynomial (eulerShift s q) ∧ + Interl (eulerShift s p) (eulerShift s q) := by + refine ⟨hp.eulerShift_of_nonneg hs, hq.eulerShift_of_nonneg hs, ?_⟩ + rcases hpq with rfl | rfl | hstrict + · simp only [eulerShift_zero_polynomial] + exact interl_zero_left _ + · simp only [eulerShift_zero_polynomial] + exact interl_zero_right _ + · exact eulerShift_interl_of_nonneg hs hstrict + +/-- Every PF polynomial precedes its nonnegative real Euler shift. -/ +theorem IsPFPolynomial.interl_eulerShift {p : ℝ[X]} (hp : IsPFPolynomial p) + {s : ℝ} (hs : 0 ≤ s) : Interl p (eulerShift s p) := by + exact interl_add_right_of_common_left_of_nonneg hp.interl_theta + (hp.interl_self.C_mul_right_of_nonneg hs) (theta_preserves_pf hp).hasNonnegCoeffs + (hasNonnegCoeffs_C_mul hs hp.hasNonnegCoeffs) + +/-- A shifted Euler image precedes its decorated image. -/ +theorem IsPFPolynomial.interl_eulerShift_X_eulerShift {p : ℝ[X]} + (hp : IsPFPolynomial p) {s : ℝ} (hs : 0 ≤ s) : + Interl (eulerShift s p) (X * eulerShift (s + 1) p) := by + have hcomm : eulerShift s (X * p) = X * eulerShift (s + 1) p := by + simp only [eulerShift, derivative_mul, derivative_X, one_mul, map_add, map_one] + ring + rw [← hcomm] + exact (eulerShift_orderedPF hs hp hp.X_mul + ((interl_iff_interl_X_mul hp hp).mp hp.interl_self)).2.2 + +/-- The decorated PF state for a fixed real Euler shift. -/ +def EulerLagState (s : ℝ) (p q : ℝ[X]) : Prop := + IsPFPolynomial p ∧ IsPFPolynomial q ∧ Interl p q ∧ + Interl q (X * eulerShift (s + 1) p) + +/-- A decorated Euler state is closed under nonnegative current and lag weights. -/ +theorem EulerLagState.step {s a b : ℝ} (hs : 0 ≤ s) (ha : 0 ≤ a) (hb : 0 ≤ b) + {p q : ℝ[X]} (h : EulerLagState s p q) : + EulerLagState s q + (C a * eulerShift s q + C b * (X * eulerShift (s + 1) p)) := by + obtain ⟨hp, hq, hpq, hdecor⟩ := h + have hs1 : 0 ≤ s + 1 := by linarith + have hT := hq.eulerShift_of_nonneg hs + have hU := (hp.eulerShift_of_nonneg hs1).X_mul + have hnn := (hasNonnegCoeffs_C_mul ha hT.hasNonnegCoeffs).add + (hasNonnegCoeffs_C_mul hb hU.hasNonnegCoeffs) + have hleft := interl_nonneg_combo_right_of_common_left_of_pf + (hq.interl_eulerShift hs) hdecor hT hU ha hb + refine ⟨hq, ?_, hleft, ?_⟩ + · by_cases hq0 : q = 0 + · simpa [hq0] using (IsPFPolynomial.of_C_nonneg hb).mul hU + apply IsPFPolynomial.of_nonnegCoeffs_eq_zero_or_splits hnn + by_cases hr : C a * eulerShift s q + C b * (X * eulerShift (s + 1) p) = 0 + · exact Or.inl hr + · exact Or.inr (hleft.toStrictInterl_of_ne hq0 hr).2.1.2 + · exact interl_add_left_of_common_right_of_nonneg + ((hq.interl_eulerShift_X_eulerShift hs).C_mul_left_of_nonneg ha) + (((eulerShift_orderedPF hs1 hp hq hpq).2.2.mul_X_both).C_mul_left_of_nonneg hb) + (hasNonnegCoeffs_C_mul ha hT.hasNonnegCoeffs) + (hasNonnegCoeffs_C_mul hb hU.hasNonnegCoeffs) + +/-- Arbitrary nonnegative weights preserve the decorated state along the recurrence. -/ +theorem EulerLagState.all {s : ℝ} (hs : 0 ≤ s) {a b : ℕ → ℝ} + (ha : ∀ n, 0 ≤ a n) (hb : ∀ n, 0 ≤ b n) {P : ℕ → ℝ[X]} + (hstart : EulerLagState s (P 0) (P 1)) + (hrec : ∀ n, P (n + 2) = C (a n) * eulerShift s (P (n + 1)) + + C (b n) * (X * eulerShift (s + 1) (P n))) : + ∀ n, EulerLagState s (P n) (P (n + 1)) := by + intro n + induction n with + | zero => exact hstart + | succ n ih => + rw [show n + 1 + 1 = n + 2 by lia, hrec n] + exact ih.step hs (ha n) (hb n) + +/-- The coefficient equations give the exact current and lag operator identity. -/ +theorem eulerLag_recognizer (s A B C₀ D : ℝ) (hB : B = s * A) + (hD : D = (s + 1) * C₀) (p q : ℝ[X]) : + C A * theta q + C B * q + C C₀ * X * theta p + C D * X * p = + C A * eulerShift s q + C C₀ * (X * eulerShift (s + 1) p) := by + simp only [hB, hD, eulerShift, theta, map_mul, map_add, map_one] + ring + +private theorem eulerLagState_one {s : ℝ} (hs : 0 ≤ s) : EulerLagState s 1 1 := by + refine ⟨IsPFPolynomial.one, IsPFPolynomial.one, IsPFPolynomial.one.interl_self, ?_⟩ + have hx := (interl_iff_interl_X_mul IsPFPolynomial.one IsPFPolynomial.one).mp + IsPFPolynomial.one.interl_self + simpa [eulerShift, mul_comm] using hx.C_mul_right_of_nonneg (show 0 ≤ s + 1 by linarith) + +example : EulerLagState (1 / 2 : ℝ) 1 (C (1 / 2 : ℝ) * (1 + C 3 * X)) := by + convert (eulerLagState_one (s := (1 / 2 : ℝ)) (by norm_num)).step + (by norm_num) zero_le_one zero_le_one using 1 + ext n + rcases n with _ | _ | n <;> norm_num [coeff_X_mul, coeff_mul_X, coeff_one] + +example {p q : ℝ[X]} (s : ℝ) (hs : s = 0 ∨ s = 1 ∨ s = 2) + (h : EulerLagState s p q) : + EulerLagState s q (eulerShift s q + X * eulerShift (s + 1) p) := by + have hs0 : 0 ≤ s := by rcases hs with rfl | rfl | rfl <;> norm_num + simpa using h.step hs0 zero_le_one zero_le_one + +example {s : ℝ} (hs : 0 ≤ s) {p q : ℝ[X]} (h : EulerLagState s p q) : + EulerLagState s q 0 := by + simpa using h.step hs le_rfl le_rfl + +example {s a b : ℝ} (hs : 0 ≤ s) (ha : 0 ≤ a) (hb : 0 ≤ b) : + EulerLagState s 0 (C a * eulerShift s 0 + C b * (X * eulerShift (s + 1) 0)) := by + exact (show EulerLagState s 0 0 from + ⟨IsPFPolynomial.zero, IsPFPolynomial.zero, interl_zero_left _, interl_zero_left _⟩).step + hs ha hb + +example : C (1 : ℝ) * eulerShift (1 / 2 : ℝ) 1 + + C (1 : ℝ) * (X * eulerShift (1 / 2 + 1 : ℝ) 1) = + C (1 / 2 : ℝ) * (1 + C 3 * X) := by + ext n + rcases n with _ | _ | n <;> norm_num [coeff_X_mul, coeff_mul_X, coeff_one] + +example : eulerShift (1 / 2 : ℝ) (C (1 / 2) * (1 + C 3 * X)) + + X * eulerShift (1 / 2 + 1 : ℝ) 1 = C (1 / 4 : ℝ) * (1 + C 15 * X) := by + ext n + rcases n with _ | _ | n <;> norm_num [coeff_X_mul, coeff_mul_X, coeff_one] + +example {s : ℝ} (hs : s < 0) : ¬ IsPFPolynomial (eulerShift s 1) := by + intro h + have := h.hasNonnegCoeffs 0 + simp only [coeff_eulerShift, Nat.cast_zero, zero_add, coeff_one_zero, mul_one] at this + exact (not_le_of_gt hs) this + +example : ¬ Interl (X ^ 2 + 4 * X + 3 : ℝ[X]) (X ^ 2 + 4 * X) := by + intro h + have hp : HasPosLeadingCoeff (X ^ 2 + 4 * X + 3 : ℝ[X]) := by + change 0 < (X ^ 2 + 4 * X + 3 : ℝ[X]).coeff + (X ^ 2 + 4 * X + 3 : ℝ[X]).natDegree + rw [show (X ^ 2 + 4 * X + 3 : ℝ[X]).natDegree = 2 by compute_degree!] + norm_num [coeff_X] + have hq : HasPosLeadingCoeff (X ^ 2 + 4 * X : ℝ[X]) := by + change 0 < (X ^ 2 + 4 * X : ℝ[X]).coeff + (X ^ 2 + 4 * X : ℝ[X]).natDegree + rw [show (X ^ 2 + 4 * X : ℝ[X]).natDegree = 2 by compute_degree!] + norm_num [coeff_X] + have hw := wronskian_eval_nonneg_of_strictInterl hq hp + (h.toStrictInterl_of_ne hp.ne_zero hq.ne_zero) (-3) + norm_num [Polynomial.wronskian, derivative_add, derivative_mul, derivative_pow] at hw + +end RealRooted diff --git a/RealRooted/OperatorMatrix/AffineDerivative.lean b/RealRooted/OperatorMatrix/AffineDerivative.lean new file mode 100644 index 000000000..0a2f17c3b --- /dev/null +++ b/RealRooted/OperatorMatrix/AffineDerivative.lean @@ -0,0 +1,222 @@ +module + +public import RealRooted.PFPolynomial +import RealRooted.FiniteFreeAdditive.FiniteDegreeCompanions +import RealRooted.OperatorMatrix.Directed +import RealRooted.QuadraticRoot +import RealRooted.Wronskian.WeakForward + +/-! +# Affine-derivative rows and columns + +Nonnegative affine-derivative rows preserve directed PF inputs exactly when +`a B ≤ A b`; their output precedes the derivative-weighted input sum. +Same-input columns have the opposite cross inequality `A c ≤ a C`. +Degree-two and degree-one witnesses give the same criteria at finite caps. + +Source: *General affine-derivative matrices* +([source](https://github.com/PerAlexandersson/real-zero-preservers/tree/3255043)), +`weyl-operators/notes/general-affine-derivative-matrices.md`. +-/ + +@[expose] public section + +open Polynomial + +noncomputable section + +namespace RealRooted + +/-- An affine combination of the derivative and the identity. -/ +def affineD (a A : ℝ) (p : ℝ[X]) : ℝ[X] := C a * p.derivative + C A * p + +/-- A row with two affine-derivative entries. -/ +def affineDRow (a b A B : ℝ) (p q : ℝ[X]) : ℝ[X] := + affineD a A p + affineD b B q + +private theorem pf_combo {p q : ℝ[X]} (hp : IsPFPolynomial p) (hq : IsPFPolynomial q) + (hpq : Interl p q) {a b : ℝ} (ha : 0 ≤ a) (hb : 0 ≤ b) : + IsPFPolynomial (C a * p + C b * q) := by + exact ((IsPFPolynomial.of_C_nonneg ha).mul hp).add_of_interl + ((IsPFPolynomial.of_C_nonneg hb).mul hq) + ((hpq.C_mul_left_of_nonneg ha).C_mul_right_of_nonneg hb) + +/-- Nonnegative affine-derivative operators preserve PF polynomials. -/ +theorem IsPFPolynomial.affineD {p : ℝ[X]} (hp : IsPFPolynomial p) + {a A : ℝ} (ha : 0 ≤ a) (hA : 0 ≤ A) : IsPFPolynomial (RealRooted.affineD a A p) := by + exact pf_combo hp.derivative hp hp.derivative_interl_self ha hA + +private theorem affineDRow_pf_anchor {a b A B : ℝ} + (h : 0 ≤ a ∧ 0 ≤ b ∧ 0 ≤ A ∧ 0 ≤ B) (hc : a * B ≤ A * b) + {p q : ℝ[X]} (hp : IsPFPolynomial p) (hq : IsPFPolynomial q) (hpq : Interl p q) : + IsPFPolynomial (affineDRow a b A B p q) ∧ + Interl (affineDRow a b A B p q) (C a * p + C b * q) := by + let H := C a * p + C b * q + let K := C A * p + C B * q + have hH : IsPFPolynomial H := pf_combo hp hq hpq h.1 h.2.1 + have hK : IsPFPolynomial K := pf_combo hp hq hpq h.2.2.1 h.2.2.2 + have hKH : Interl K H := interl_nonneg_combos_of_cross hp hq hpq + h.1 h.2.2.1 h.2.1 h.2.2.2 hc + have heq : affineDRow a b A B p q = H.derivative + K := by + simp only [affineDRow, affineD, H, K, derivative_add, derivative_mul, derivative_C, + zero_mul, zero_add] + ring + have hedge := interl_add_left_of_common_right_of_nonneg + hH.derivative_interl_self hKH hH.derivative.hasNonnegCoeffs hK.hasNonnegCoeffs + rw [heq] + refine ⟨?_, hedge⟩ + by_cases hH0 : H = 0 + · simpa [hH0] using hK + apply IsPFPolynomial.of_nonnegCoeffs_eq_zero_or_splits + (hH.derivative.hasNonnegCoeffs.add hK.hasNonnegCoeffs) + by_cases hout : H.derivative + K = 0 + · exact Or.inl hout + · exact Or.inr (hedge.toStrictInterl_of_ne hout hH0).1.2 + +/-- A safe affine-derivative row precedes its derivative-weighted input sum. -/ +theorem affineDRow_anchor {a b A B : ℝ} + (h : 0 ≤ a ∧ 0 ≤ b ∧ 0 ≤ A ∧ 0 ≤ B) (hc : a * B ≤ A * b) + {p q : ℝ[X]} (hp : IsPFPolynomial p) (hq : IsPFPolynomial q) (hpq : Interl p q) : + Interl (affineDRow a b A B p q) (C a * p + C b * q) := by + exact (affineDRow_pf_anchor h hc hp hq hpq).2 + +private theorem affineD_natDegree_le (a A : ℝ) (p : ℝ[X]) : + (affineD a A p).natDegree ≤ p.natDegree := by + exact (natDegree_add_le _ _).trans (max_le + ((natDegree_C_mul_le _ _).trans ((natDegree_derivative_le p).trans (Nat.sub_le _ _))) + (natDegree_C_mul_le _ _)) + +/-- An affine-derivative row does not raise the common degree cap. -/ +theorem affineDRow_natDegree_le (a b A B : ℝ) (p q : ℝ[X]) : + (affineDRow a b A B p q).natDegree ≤ max p.natDegree q.natDegree := by + exact (natDegree_add_le _ _).trans + (max_le_max (affineD_natDegree_le a A p) (affineD_natDegree_le b B q)) + +private theorem row_cross_of_cap_two {a b A B : ℝ} + (h : 0 ≤ a ∧ 0 ≤ b ∧ 0 ≤ A ∧ 0 ≤ B) + (hall : ∀ p q : ℝ[X], IsPFPolynomial p → IsPFPolynomial q → Interl p q → + p.natDegree ≤ 2 → q.natDegree ≤ 2 → IsPFPolynomial (affineDRow a b A B p q)) : + a * B ≤ A * b := by + by_contra hn + have hh : 0 < a * B - A * b := sub_pos.mpr (lt_of_not_ge hn) + have hB : 0 < B := by + by_contra hB + nlinarith [mul_nonneg h.2.2.1 h.2.1, + mul_nonpos_of_nonneg_of_nonpos h.1 (le_of_not_gt hB)] + let l : ℝ := (b ^ 2 + 1) / (a * B - A * b) + let r : ℝ := A * l / B + have hl : 0 < l := div_pos (by positivity) hh + have hr : 0 ≤ r := div_nonneg (mul_nonneg h.2.2.1 hl.le) hB.le + have hleq : (a * B - A * b) * l = b ^ 2 + 1 := by + dsimp [l] + field_simp + have hreq : B * r = A * l := by + dsimp [r] + field_simp + have hf := isPFPolynomial_X_add_C hr + have hfx : Interl (X + C r) (X * (X + C r)) := + interl_mul_X_of_interl hf.interl_self hf.hasNonnegCoeffs hf.hasNonnegCoeffs + have hout := hall (C l * (X + C r)) (X * (X + C r)) + (hf.const_mul hl) hf.X_mul (hfx.C_mul_left_of_nonneg hl.le) + (by rw [natDegree_C_mul hl.ne', natDegree_X_add_C]; norm_num) + (by rw [natDegree_X_mul (monic_X_add_C r).ne_zero, natDegree_X_add_C]) + have heq : affineDRow a b A B (C l * (X + C r)) (X * (X + C r)) = + C B * X ^ 2 + C (A * l + 2 * b + B * r) * X + C (a * l + b * r + A * l * r) := by + simp only [affineDRow, affineD, derivative_mul, derivative_X, + derivative_C, mul_one, zero_mul, zero_add, add_zero, map_add, map_mul, map_ofNat] + ring + have hd : discrim B (A * l + 2 * b + B * r) (a * l + b * r + A * l * r) = -4 := by + calc + _ = (A * l - B * r) ^ 2 - 4 * (a * B - A * b) * l + 4 * b ^ 2 := by + unfold discrim + ring + _ = -4 := by rw [hreq, sub_self, zero_pow (by decide), mul_assoc, hleq]; ring + exact quadraticPoly_not_splits_of_discrim_neg hB.ne' (by rw [hd]; norm_num) + (heq ▸ hout.splits) + +/-- At every common cap at least two, row safety is the cross inequality. -/ +theorem affineDRow_pf_through_iff {a b A B : ℝ} {N : ℕ} (hN : 2 ≤ N) + (h : 0 ≤ a ∧ 0 ≤ b ∧ 0 ≤ A ∧ 0 ≤ B) : + (∀ p q : ℝ[X], IsPFPolynomial p → IsPFPolynomial q → Interl p q → + p.natDegree ≤ N → q.natDegree ≤ N → + IsPFPolynomial (affineDRow a b A B p q)) ↔ a * B ≤ A * b := by + constructor + · intro hall + exact row_cross_of_cap_two h (fun p q hp hq hi hd he ↦ + hall p q hp hq hi (hd.trans hN) (he.trans hN)) + · intro hc p q hp hq hi _ _ + exact (affineDRow_pf_anchor h hc hp hq hi).1 + +/-- The unrestricted affine-derivative row criterion. -/ +theorem affineDRow_pf_iff {a b A B : ℝ} + (h : 0 ≤ a ∧ 0 ≤ b ∧ 0 ≤ A ∧ 0 ≤ B) : + (∀ p q : ℝ[X], IsPFPolynomial p → IsPFPolynomial q → Interl p q → + IsPFPolynomial (affineDRow a b A B p q)) ↔ a * B ≤ A * b := by + constructor + · intro hall + exact row_cross_of_cap_two h (fun p q hp hq hi _ _ ↦ hall p q hp hq hi) + · intro hc p q hp hq hi + exact (affineDRow_pf_anchor h hc hp hq hi).1 + +private theorem column_cross_of_linear {a c A C₀ : ℝ} + (hcol : IsPFPolynomial (affineD a A (X + 1)) ∧ + IsPFPolynomial (affineD c C₀ (X + 1)) ∧ + Interl (affineD a A (X + 1)) (affineD c C₀ (X + 1))) : A * c ≤ a * C₀ := by + have hw : 0 ≤ (Polynomial.wronskian (affineD a A (X + 1)) + (affineD c C₀ (X + 1))).eval 0 := by + rcases hcol.2.2 with hz | hz | hi + · simp [hz, Polynomial.wronskian] + · simp [hz, Polynomial.wronskian] + · exact wronskian_eval_nonneg_of_strictInterl + (hcol.2.1.hasNonnegCoeffs.pos_leadingCoeff hi.2.1.1) + (hcol.1.hasNonnegCoeffs.pos_leadingCoeff hi.1.1) hi 0 + simp [affineD, Polynomial.wronskian, derivative_mul] at hw + nlinarith + +private theorem affineD_column {a c A C₀ : ℝ} + (h : 0 ≤ a ∧ 0 ≤ c ∧ 0 ≤ A ∧ 0 ≤ C₀) (hc : A * c ≤ a * C₀) + {p : ℝ[X]} (hp : IsPFPolynomial p) : + IsPFPolynomial (affineD a A p) ∧ IsPFPolynomial (affineD c C₀ p) ∧ + Interl (affineD a A p) (affineD c C₀ p) := by + exact ⟨hp.affineD h.1 h.2.2.1, hp.affineD h.2.1 h.2.2.2, + interl_nonneg_combos_of_cross hp.derivative hp hp.derivative_interl_self + h.2.1 h.1 h.2.2.2 h.2.2.1 (by nlinarith)⟩ + +/-- The affine-derivative column criterion at every positive degree cap. -/ +theorem affineD_column_through_iff {a c A C₀ : ℝ} {N : ℕ} (hN : 1 ≤ N) + (h : 0 ≤ a ∧ 0 ≤ c ∧ 0 ≤ A ∧ 0 ≤ C₀) : + (∀ p : ℝ[X], IsPFPolynomial p → p.natDegree ≤ N → + IsPFPolynomial (affineD a A p) ∧ IsPFPolynomial (affineD c C₀ p) ∧ + Interl (affineD a A p) (affineD c C₀ p)) ↔ A * c ≤ a * C₀ := by + constructor + · intro hall + exact column_cross_of_linear (hall (X + 1) isPFPolynomial_X_add_one (by simpa using hN)) + · intro hc p hp _ + exact affineD_column h hc hp + +/-- The unrestricted same-input affine-derivative column criterion, including PF images. -/ +theorem affineD_column_iff {a c A C₀ : ℝ} + (h : 0 ≤ a ∧ 0 ≤ c ∧ 0 ≤ A ∧ 0 ≤ C₀) : + (∀ p : ℝ[X], IsPFPolynomial p → + IsPFPolynomial (affineD a A p) ∧ IsPFPolynomial (affineD c C₀ p) ∧ + Interl (affineD a A p) (affineD c C₀ p)) ↔ A * c ≤ a * C₀ := by + constructor + · intro hall + exact column_cross_of_linear (hall (X + 1) isPFPolynomial_X_add_one) + · intro hc p hp + exact affineD_column h hc hp + +example : ∀ p q : ℝ[X], IsPFPolynomial p → IsPFPolynomial q → Interl p q → + IsPFPolynomial (affineDRow 0 1 1 0 p q) := by + exact (affineDRow_pf_iff (by norm_num)).mpr (by norm_num) + +example : ¬ (∀ p q : ℝ[X], IsPFPolynomial p → IsPFPolynomial q → Interl p q → + IsPFPolynomial (affineDRow 1 0 0 1 p q)) := by + rw [affineDRow_pf_iff (by norm_num)] + norm_num + +example {p : ℝ[X]} (hp : IsPFPolynomial p) : + Interl (affineD 1 0 p) (affineD 0 1 p) := by + exact ((affineD_column_iff (by norm_num)).mpr (by norm_num) p hp).2.2 + +end RealRooted diff --git a/RealRooted/OperatorMatrix/AffineSuccessor.lean b/RealRooted/OperatorMatrix/AffineSuccessor.lean new file mode 100644 index 000000000..9821b2af0 --- /dev/null +++ b/RealRooted/OperatorMatrix/AffineSuccessor.lean @@ -0,0 +1,129 @@ +module + +public import RealRooted.EulerOperator +public import RealRooted.PFPolynomial +import RealRooted.OperatorMatrix.Directed +import RealRooted.Wronskian.WeakForward + +/-! +# Affine PF successors + +For nonnegative coefficients, an affine combination of the identity, Euler derivative, +ordinary derivative and multiplication by `X` sends every PF input to a PF successor +exactly when its ordinary derivative coefficient vanishes. The obstruction already +occurs on `X`; degree-zero inputs impose no such restriction. + +Source: *Affine PF successor derivative boundary* +([source](https://github.com/PerAlexandersson/real-zero-preservers/tree/f7e16ee)), +`weyl-operators/notes/affine-successor-derivative-boundary.md`. +-/ + +@[expose] public section + +open Polynomial + +noncomputable section + +namespace RealRooted + +/-- An affine combination of the identity, Euler derivative, derivative and `X`. -/ +def affinePFStep (a α δ ξ : ℝ) (p : ℝ[X]) : ℝ[X] := + C a * p + C α * theta p + C δ * p.derivative + C ξ * X * p + +/-- A PF polynomial following `X` has zero constant term. -/ +theorem eval_zero_eq_zero_of_interl_X {q : ℝ[X]} (hq : IsPFPolynomial q) + (h : Interl (X : ℝ[X]) q) : q.eval 0 = 0 := by + by_cases hq0 : q = 0 + · simp [hq0] + have hw := wronskian_eval_nonneg_of_strictInterl + (hq.hasNonnegCoeffs.pos_leadingCoeff hq0) + (isPFPolynomial_X.hasNonnegCoeffs.pos_leadingCoeff X_ne_zero) + (h.toStrictInterl_of_ne X_ne_zero hq0) 0 + have hn := hq.hasNonnegCoeffs.eval_nonneg (show (0 : ℝ) ≤ 0 from le_rfl) + simp only [Polynomial.wronskian, eval_sub, eval_mul, eval_X, derivative_X, + zero_mul, one_mul, zero_sub] at hw + linarith + +/-- Without an ordinary derivative term, nonnegative affine steps are PF successors. -/ +theorem IsPFPolynomial.interl_affinePFStep {p : ℝ[X]} (hp : IsPFPolynomial p) + {a α ξ : ℝ} (ha : 0 ≤ a) (hα : 0 ≤ α) (hξ : 0 ≤ ξ) : + IsPFPolynomial (affinePFStep a α 0 ξ p) ∧ Interl p (affinePFStep a α 0 ξ p) := by + have hθ := theta_preserves_pf hp + have hnn : HasNonnegCoeffs (affinePFStep a α 0 ξ p) := by + simpa [affinePFStep, mul_assoc] using + ((hasNonnegCoeffs_C_mul ha hp.hasNonnegCoeffs).add + (hasNonnegCoeffs_C_mul hα hθ.hasNonnegCoeffs)).add + (hasNonnegCoeffs_C_mul hξ hp.X_mul.hasNonnegCoeffs) + have hedge : Interl p (affinePFStep a α 0 ξ p) := by + simpa [affinePFStep, mul_assoc] using + interl_add_right_of_common_left_of_nonneg + (interl_nonneg_combo_right_of_common_left_of_pf hp.interl_self hp.interl_theta + hp hθ ha hα) + (((interl_iff_interl_X_mul hp hp).mp hp.interl_self).C_mul_right_of_nonneg hξ) + ((hasNonnegCoeffs_C_mul ha hp.hasNonnegCoeffs).add + (hasNonnegCoeffs_C_mul hα hθ.hasNonnegCoeffs)) + (hasNonnegCoeffs_C_mul hξ hp.X_mul.hasNonnegCoeffs) + refine ⟨?_, hedge⟩ + by_cases hp0 : p = 0 + · simpa [affinePFStep, hp0, theta] using IsPFPolynomial.zero + apply IsPFPolynomial.of_nonnegCoeffs_eq_zero_or_splits hnn + by_cases hout : affinePFStep a α 0 ξ p = 0 + · exact Or.inl hout + · exact Or.inr (hedge.toStrictInterl_of_ne hp0 hout).2.1.2 + +/-- At every positive degree cap, universal PF succession excludes a derivative term. -/ +theorem affinePFStep_through_iff {a α δ ξ : ℝ} {N : ℕ} (hN : 1 ≤ N) + (h : 0 ≤ a ∧ 0 ≤ α ∧ 0 ≤ δ ∧ 0 ≤ ξ) : + (∀ p : ℝ[X], IsPFPolynomial p → p.natDegree ≤ N → + IsPFPolynomial (affinePFStep a α δ ξ p) ∧ + Interl p (affinePFStep a α δ ξ p)) ↔ δ = 0 := by + constructor + · intro hall + obtain ⟨hpf, hedge⟩ := hall X isPFPolynomial_X (by simpa using hN) + have hz := eval_zero_eq_zero_of_interl_X hpf hedge + simpa [affinePFStep, theta] using hz + · rintro rfl p hp _ + exact hp.interl_affinePFStep h.1 h.2.1 h.2.2.2 + +/-- The unrestricted affine PF successor criterion. -/ +theorem affinePFStep_all_iff {a α δ ξ : ℝ} + (h : 0 ≤ a ∧ 0 ≤ α ∧ 0 ≤ δ ∧ 0 ≤ ξ) : + (∀ p : ℝ[X], IsPFPolynomial p → + IsPFPolynomial (affinePFStep a α δ ξ p) ∧ + Interl p (affinePFStep a α δ ξ p)) ↔ δ = 0 := by + constructor + · intro hall + exact (affinePFStep_through_iff (N := 1) le_rfl h).mp (fun p hp _ ↦ hall p hp) + · rintro rfl p hp + exact hp.interl_affinePFStep h.1 h.2.1 h.2.2.2 + +/-- Degree-zero inputs admit arbitrary nonnegative derivative coefficients. -/ +theorem affinePFStep_cap_zero {a α δ ξ : ℝ} + (h : 0 ≤ a ∧ 0 ≤ α ∧ 0 ≤ δ ∧ 0 ≤ ξ) + {p : ℝ[X]} (hp : IsPFPolynomial p) (hdeg : p.natDegree ≤ 0) : + IsPFPolynomial (affinePFStep a α δ ξ p) ∧ Interl p (affinePFStep a α δ ξ p) := by + have hd : p.derivative = 0 := derivative_eq_zero.mpr (by lia) + simpa [affinePFStep, hd] using hp.interl_affinePFStep h.1 h.2.1 h.2.2.2 + +example {p : ℝ[X]} (hp : IsPFPolynomial p) : + IsPFPolynomial (affinePFStep 0 1 0 1 p) ∧ Interl p (affinePFStep 0 1 0 1 p) := by + exact hp.interl_affinePFStep le_rfl zero_le_one zero_le_one + +example : ¬ (IsPFPolynomial (affinePFStep 1 0 1 0 X) ∧ + Interl X (affinePFStep 1 0 1 0 X)) := by + rintro ⟨hp, hi⟩ + have := eval_zero_eq_zero_of_interl_X hp hi + norm_num [affinePFStep, theta] at this + +example : ¬ (IsPFPolynomial (affinePFStep 1 0 1 1 X) ∧ + Interl X (affinePFStep 1 0 1 1 X)) := by + rintro ⟨hp, hi⟩ + have := eval_zero_eq_zero_of_interl_X hp hi + norm_num [affinePFStep, theta] at this + +example : IsPFPolynomial (affinePFStep 1 1 1 1 1) ∧ + Interl 1 (affinePFStep 1 1 1 1 1) := by + exact affinePFStep_cap_zero ⟨zero_le_one, zero_le_one, zero_le_one, zero_le_one⟩ + IsPFPolynomial.one (by simp) + +end RealRooted diff --git a/RealRooted/Production.lean b/RealRooted/Production.lean index 06f15b37c..7aeca10da 100644 --- a/RealRooted/Production.lean +++ b/RealRooted/Production.lean @@ -2173,6 +2173,10 @@ public import RealRooted.Applications.OEIS.A124324 public import RealRooted.Applications.OEIS.A144438 public import RealRooted.MatrixInterlacing.ThreeBidiagonalProduction public import RealRooted.Applications.PeakPolynomials.SignedStaircase +public import RealRooted.DerivativeRecurrence.AssociatedBell +public import RealRooted.DerivativeRecurrence.RealEulerLag +public import RealRooted.OperatorMatrix.AffineDerivative +public import RealRooted.OperatorMatrix.AffineSuccessor /-! # RealRooted production umbrella diff --git a/scripts/import_architecture.json b/scripts/import_architecture.json index 9032bfb32..b2e087d98 100644 --- a/scripts/import_architecture.json +++ b/scripts/import_architecture.json @@ -16,10 +16,10 @@ ], "budgets": { "RealRooted": { - "max_modules": 2238 + "max_modules": 2242 }, "RealRooted.Production": { - "max_modules": 2166 + "max_modules": 2170 }, "RealRooted.Tactic.Examples": { "max_modules": 844