diff --git a/RealRooted.lean b/RealRooted.lean index 45c9fd20e..54cf6e191 100644 --- a/RealRooted.lean +++ b/RealRooted.lean @@ -1793,6 +1793,7 @@ public import RealRooted.VeroneseSectionPair.HermiteBiehler public import RealRooted.Wagner public import RealRooted.Wagner.LeftSum public import RealRooted.Wagner.NonpositiveRoots +public import RealRooted.Wagner.ThreeStateRecurrence public import RealRooted.WagnerRightSum public import RealRooted.WagnerRightSum.Sign public import RealRooted.WagnerX diff --git a/RealRooted/Production.lean b/RealRooted/Production.lean index 8f0faed98..4d19d003b 100644 --- a/RealRooted/Production.lean +++ b/RealRooted/Production.lean @@ -1758,6 +1758,7 @@ public import RealRooted.VeroneseSectionPair.HermiteBiehler public import RealRooted.Wagner public import RealRooted.Wagner.LeftSum public import RealRooted.Wagner.NonpositiveRoots +public import RealRooted.Wagner.ThreeStateRecurrence public import RealRooted.WagnerRightSum public import RealRooted.WagnerRightSum.Sign public import RealRooted.WagnerX diff --git a/RealRooted/Wagner/ThreeStateRecurrence.lean b/RealRooted/Wagner/ThreeStateRecurrence.lean new file mode 100644 index 000000000..5ca439b5d --- /dev/null +++ b/RealRooted/Wagner/ThreeStateRecurrence.lean @@ -0,0 +1,167 @@ +module + +public import RealRooted.Recurrence.CubicTransition +import RealRooted.OperatorMatrix.Directed + +/-! +# A three-state Wagner-cone recurrence + +We prove preservation of `C ≼ B`, `C ≼ F`, and `B ≼ F` under +`B⁺ = B + F`, `C⁺ = C + w (B + F)`, and `F⁺ = F + X (C + w B)`. +Here `≼` is the zero-aware weak oriented relation `Interl`, and every state is +PF: it has nonnegative coefficients and splits with nonpositive roots. +Every nonzero state consequently has positive leading coefficient. Shared and +repeated roots are allowed; no assertion of distinct roots is made. + +The recurrence comes from nesting-free marked matchings with positive mark +weights (unpublished manuscript, section "Theorem: no nested arcs"). We formalize +only the recurrence and its invariant, independently of that combinatorial model. +-/ + +@[expose] public section + +open Polynomial + +namespace RealRooted +namespace Wagner + +/-- A positive weighted step preserves the three-state cone and interlaces +consecutive return states, including when some input states vanish. -/ +theorem isOrderedPFTriple_threeState_step {F B C : ℝ[X]} (h : IsOrderedPFTriple C B F) + {w : ℝ} (hw : 0 < w) : + IsOrderedPFTriple (C + Polynomial.C w * (B + F)) (B + F) + (F + X * (C + Polynomial.C w * B)) ∧ + Interl F (F + X * (C + Polynomial.C w * B)) := by + rcases h with ⟨hC, hB, hF, hCB, hCF, hBF⟩ + let D := B + F + let K := C + Polynomial.C w * B + have hD : IsPFPolynomial D := hB.add_of_interl hF hBF + have hwB := hB.const_mul hw + have hwF := hF.const_mul hw + have hK : IsPFPolynomial K := + hC.add_of_interl hwB (hCB.C_mul_right_of_nonneg hw.le) + have hKB : Interl K B := + interl_add_left_of_common_right_of_nonneg hCB + (hB.interl_self.C_mul_left_of_nonneg hw.le) + hC.hasNonnegCoeffs hwB.hasNonnegCoeffs + have hKF : Interl K F := + interl_add_left_of_common_right_of_nonneg hCF + (hBF.C_mul_left_of_nonneg hw.le) + hC.hasNonnegCoeffs hwB.hasNonnegCoeffs + have hKD : Interl K D := + interl_add_right_of_common_left_of_nonneg hKB hKF + hB.hasNonnegCoeffs hF.hasNonnegCoeffs + have hDF : Interl D F := + interl_add_left_of_common_right_of_nonneg hBF hF.interl_self + hB.hasNonnegCoeffs hF.hasNonnegCoeffs + have hCD : Interl C D := + interl_add_right_of_common_left_of_nonneg hCB hCF + hB.hasNonnegCoeffs hF.hasNonnegCoeffs + have hnextC : IsPFPolynomial (C + Polynomial.C w * D) := + hC.add_of_interl (hD.const_mul hw) (hCD.C_mul_right_of_nonneg hw.le) + have hnextCD : Interl (C + Polynomial.C w * D) D := + interl_add_left_of_common_right_of_nonneg hCD + (hD.interl_self.C_mul_left_of_nonneg hw.le) + hC.hasNonnegCoeffs (hD.const_mul hw).hasNonnegCoeffs + have hnextCF : Interl (C + Polynomial.C w * D) F := + interl_add_left_of_common_right_of_nonneg hCF + (hDF.C_mul_left_of_nonneg hw.le) + hC.hasNonnegCoeffs (hD.const_mul hw).hasNonnegCoeffs + have hform : C + Polynomial.C w * D = K + Polynomial.C w * F := by + dsimp [D, K] + ring + have hKnextC : Interl K (C + Polynomial.C w * D) := by + rw [hform] + exact interl_add_right_of_common_left_of_nonneg hK.interl_self + (hKF.C_mul_right_of_nonneg hw.le) hK.hasNonnegCoeffs hwF.hasNonnegCoeffs + have hDXK : Interl D (X * K) := + interl_mul_X_of_interl hKD hK.hasNonnegCoeffs hD.hasNonnegCoeffs + have hnextCXK : Interl (C + Polynomial.C w * D) (X * K) := + interl_mul_X_of_interl hKnextC hK.hasNonnegCoeffs hnextC.hasNonnegCoeffs + have hFXK : Interl F (X * K) := + interl_mul_X_of_interl hKF hK.hasNonnegCoeffs hF.hasNonnegCoeffs + have hnextF := hF.add_of_interl hK.X_mul hFXK + refine ⟨⟨hnextC, hD, hnextF, hnextCD, ?_, ?_⟩, ?_⟩ + · exact interl_add_right_of_common_left_of_nonneg hnextCF hnextCXK + hF.hasNonnegCoeffs hK.X_mul.hasNonnegCoeffs + · exact interl_add_right_of_common_left_of_nonneg hDF hDXK + hF.hasNonnegCoeffs hK.X_mul.hasNonnegCoeffs + · exact interl_add_right_of_common_left_of_nonneg hF.interl_self hFXK + hF.hasNonnegCoeffs hK.X_mul.hasNonnegCoeffs + +/-- A three-state recurrence with rank-zero data `(1, 0, 0)`. +The arbitrary weights are required to be positive by the theorems below. -/ +structure ThreeStateRecurrence (w : ℕ → ℝ) (F B C : ℕ → ℝ[X]) : Prop where + /-- The initial return state. -/ + F_zero : F 0 = 1 + /-- The initial unmarked state. -/ + B_zero : B 0 = 0 + /-- The initial marked state. -/ + C_zero : C 0 = 0 + /-- The return-state update. -/ + F_succ : ∀ n, F (n + 1) = F n + X * (C n + Polynomial.C (w n) * B n) + /-- The unmarked-state update. -/ + B_succ : ∀ n, B (n + 1) = B n + F n + /-- The marked-state update. -/ + C_succ : ∀ n, C (n + 1) = C n + Polynomial.C (w n) * (B n + F n) + +/-- A recurrence with positive weights preserves the cone from any initial rank. -/ +theorem isOrderedPFTriple_of_threeState_recurrence {w : ℕ → ℝ} {F B C : ℕ → ℝ[X]} + (hw : ∀ n, 0 < w n) (h₀ : IsOrderedPFTriple (C 0) (B 0) (F 0)) + (hF : ∀ n, F (n + 1) = F n + X * (C n + Polynomial.C (w n) * B n)) + (hB : ∀ n, B (n + 1) = B n + F n) + (hC : ∀ n, C (n + 1) = C n + Polynomial.C (w n) * (B n + F n)) + (n : ℕ) : IsOrderedPFTriple (C n) (B n) (F n) := by + induction n with + | zero => exact h₀ + | succ n ih => + rw [hF n, hB n, hC n] + exact (isOrderedPFTriple_threeState_step ih (hw n)).1 + +/-- Every rank of the recurrence satisfies the zero-aware interlacing invariant. -/ +theorem ThreeStateRecurrence.isOrderedPFTriple {w : ℕ → ℝ} {F B C : ℕ → ℝ[X]} + (h : ThreeStateRecurrence w F B C) (hw : ∀ n, 0 < w n) (n : ℕ) : + IsOrderedPFTriple (C n) (B n) (F n) := by + apply isOrderedPFTriple_of_threeState_recurrence hw ?_ h.F_succ h.B_succ h.C_succ n + rw [h.F_zero, h.B_zero, h.C_zero] + exact ⟨IsPFPolynomial.zero, IsPFPolynomial.zero, IsPFPolynomial.one, + interl_zero_left 0, interl_zero_left 1, interl_zero_left 1⟩ + +/-- Consecutive return states weakly interlace in the zero-aware convention. -/ +theorem ThreeStateRecurrence.interl_succ {w : ℕ → ℝ} {F B C : ℕ → ℝ[X]} + (h : ThreeStateRecurrence w F B C) (hw : ∀ n, 0 < w n) (n : ℕ) : + Interl (F n) (F (n + 1)) := by + rw [h.F_succ n] + exact (isOrderedPFTriple_threeState_step (h.isOrderedPFTriple hw n) (hw n)).2 + +/-- Every return state retains constant coefficient one. -/ +theorem ThreeStateRecurrence.coeff_zero {w : ℕ → ℝ} {F B C : ℕ → ℝ[X]} + (h : ThreeStateRecurrence w F B C) (n : ℕ) : (F n).coeff 0 = 1 := by + induction n with + | zero => simp [h.F_zero] + | succ n ih => simp [h.F_succ n, ih] + +/-- Return states are nonzero, so their interlacing is also expressed by `StrictInterl`. +Despite its name, this predicate allows shared and repeated roots. -/ +theorem ThreeStateRecurrence.strictInterl_succ {w : ℕ → ℝ} {F B C : ℕ → ℝ[X]} + (h : ThreeStateRecurrence w F B C) (hw : ∀ n, 0 < w n) (n : ℕ) : + StrictInterl (F n) (F (n + 1)) := by + have hne (k : ℕ) : F k ≠ 0 := by + intro hk + have := h.coeff_zero k + simp [hk] at this + exact (h.interl_succ hw n).toStrictInterl_of_ne (hne n) (hne (n + 1)) + +/-- Every return state splits with nonpositive roots and positive leading coefficient. -/ +theorem ThreeStateRecurrence.splits_roots_nonpos_posLeadingCoeff + {w : ℕ → ℝ} {F B C : ℕ → ℝ[X]} + (h : ThreeStateRecurrence w F B C) (hw : ∀ n, 0 < w n) (n : ℕ) : + (F n).Splits ∧ (∀ r ∈ (F n).roots, r ≤ 0) ∧ HasPosLeadingCoeff (F n) := by + have hp := (h.isOrderedPFTriple hw n).2.2.1 + refine ⟨hp.splits, hp.roots_nonpos, hp.hasNonnegCoeffs.pos_leadingCoeff ?_⟩ + intro hn + have := h.coeff_zero n + simp [hn] at this + +end Wagner +end RealRooted diff --git a/docs/WORKHORSES.md b/docs/WORKHORSES.md index 9eb9a8782..868130fe9 100644 --- a/docs/WORKHORSES.md +++ b/docs/WORKHORSES.md @@ -16,7 +16,7 @@ Counts are lexical estimates: distinctive leaves count unqualified references; g | uses | theorem | module | doc | |---:|---|---|---| | 72 | `RealRooted.StrictInterl.refl` | `RealRooted.Basic.ProperPosition` | A nonzero real-rooted polynomial is in same-degree proper position with itself. | -| 58 | `RealRooted.Interl.toStrictInterl_of_ne` | `RealRooted.Basic.ProperPosition` | | +| 59 | `RealRooted.Interl.toStrictInterl_of_ne` | `RealRooted.Basic.ProperPosition` | | | 42 | `RealRooted.strictInterl_mul_X_of_strictInterl_of_nonneg` | `RealRooted.WagnerX.NonnegativeRoots` | Nonnegative-coefficients form of Wagner (3): if `f ≪ g` and both polynomials have nonnegative coefficients, then `g ≪ X * f`. | | 34 | `RealRooted.StrictInterl.C_mul_left` | `RealRooted.Basic.ProperPosition` | Multiplying the left polynomial in a proper-position relation by a nonzero real scalar preserves proper position. | | 33 | `RealRooted.StrictInterl.C_mul_right` | `RealRooted.Basic.ProperPosition` | Multiplying the right polynomial in a proper-position relation by a nonzero real scalar preserves proper position. | @@ -47,18 +47,18 @@ Counts are lexical estimates: distinctive leaves count unqualified references; g |---:|---|---|---| | 101 | `RealRooted.StrictInterl.toInterlaces` | `RealRooted.Basic.ProperPosition` | | | 64 | `RealRooted.StrictInterl.toInterl` | `RealRooted.Basic.ProperPosition` | | -| 48 | `RealRooted.interl_zero_left` | `RealRooted.Basic.ProperPosition` | | +| 49 | `RealRooted.interl_zero_left` | `RealRooted.Basic.ProperPosition` | | | 46 | `RealRooted.interlaces_one_linear` | `RealRooted.Linear` | | | 45 | `RealRooted.interl_zero_right` | `RealRooted.Basic.ProperPosition` | | | 43 | `RealRooted.derivative_interlaces_of_natDegree_ne_zero` | `RealRooted.Derivative.Interlacing` | **Derivative interlacing**: the derivative of a nonconstant real-rooted polynomial `f` interlaces `f`. | | 36 | `RealRooted.Interl.refl` | `RealRooted.Basic.ProperPosition` | A polynomial that splits whenever it is nonzero is zero-aware interlacing with itself. | -| 28 | `RealRooted.Interl.C_mul_right_of_nonneg` | `RealRooted.Basic.ProperPosition` | Multiplying the right polynomial in a zero-aware interlacing relation by a nonnegative scalar preserves the relation. | -| 26 | `RealRooted.Interl.C_mul_left_of_nonneg` | `RealRooted.Basic.ProperPosition` | Multiplying the left polynomial in a zero-aware interlacing relation by a nonnegative scalar preserves the relation. | -| 26 | `RealRooted.IsPFPolynomial.interl_self` | `RealRooted.PFPolynomial` | A PF polynomial is in zero-aware proper position with itself. | +| 29 | `RealRooted.Interl.C_mul_right_of_nonneg` | `RealRooted.Basic.ProperPosition` | Multiplying the right polynomial in a zero-aware interlacing relation by a nonnegative scalar preserves the relation. | +| 27 | `RealRooted.Interl.C_mul_left_of_nonneg` | `RealRooted.Basic.ProperPosition` | Multiplying the left polynomial in a zero-aware interlacing relation by a nonnegative scalar preserves the relation. | +| 27 | `RealRooted.IsPFPolynomial.interl_self` | `RealRooted.PFPolynomial` | A PF polynomial is in zero-aware proper position with itself. | | 22 | `RealRooted.isInterlacingSeq0_iff_pairwise` | `RealRooted.InterlacingSequenceBasic` | `IsInterlacingSeq0` is exactly pairwise `Interl`. | -| 20 | `RealRooted.interl_add_right_of_common_left_of_nonneg` | `RealRooted.PFPolynomial` | Fixed-left cone closure in the two-summand form used downstream: if a polynomial is a common left interleaver for two nonnegative-coefficient summands, it is also a common left interleaver for their s | -| 20 | `RealRooted.interl_mul_X_of_interl` | `RealRooted.WagnerX.NonnegativeRoots` | Zero-aware Wagner (3): if `f ≪₀ g` and both polynomials have nonnegative coefficients, then `g ≪₀ X * f`. | -| 19 | `RealRooted.interl_add_left_of_common_right_of_nonneg` | `RealRooted.PFPolynomial` | Fixed-right cone closure in the two-summand form used downstream: if two nonnegative-coefficient summands have a common right interleaver, their sum has that same right interleaver. | +| 21 | `RealRooted.interl_add_right_of_common_left_of_nonneg` | `RealRooted.PFPolynomial` | Fixed-left cone closure in the two-summand form used downstream: if a polynomial is a common left interleaver for two nonnegative-coefficient summands, it is also a common left interleaver for their s | +| 21 | `RealRooted.interl_mul_X_of_interl` | `RealRooted.WagnerX.NonnegativeRoots` | Zero-aware Wagner (3): if `f ≪₀ g` and both polynomials have nonnegative coefficients, then `g ≪₀ X * f`. | +| 20 | `RealRooted.interl_add_left_of_common_right_of_nonneg` | `RealRooted.PFPolynomial` | Fixed-right cone closure in the two-summand form used downstream: if two nonnegative-coefficient summands have a common right interleaver, their sum has that same right interleaver. | | 18 | `RealRooted.interlaces_derivative_of_pos_natDegree` | `RealRooted.Derivative.Interlacing` | The derivative of any nonconstant positive-leading real-rooted polynomial interlaces the original polynomial, including the degree-one boundary case. | | 11 | `RealRooted.interl_of_pf_coeff_tendsto_of_natDegree_le` | `RealRooted.PFPolynomial.Closure` | Uniformly bounded-degree coefficientwise limits preserve zero-aware interlacing for Pólya-frequency polynomial pairs. | | 10 | `RealRooted.Interl.finsetSum_left_of_nonneg` | `RealRooted.PosCombo` | Left cone for `Interl` over finite sums of nonnegative-coefficient polynomials. | @@ -137,8 +137,8 @@ Counts are lexical estimates: distinctive leaves count unqualified references; g |---:|---|---|---| | 79 | `RealRooted.IsPFPolynomial.of_realRooted_nonneg` | `RealRooted.PFPolynomial` | A split polynomial with nonnegative coefficients is PF. | | 43 | `RealRooted.IsPFPolynomial.of_nonnegCoeffs_eq_zero_or_splits` | `RealRooted.PFPolynomial` | Construct a PF polynomial from nonnegative coefficients and a zero-or-splits certificate. | -| 41 | `RealRooted.IsPFPolynomial.zero` | `RealRooted.PFPolynomial` | The zero polynomial is PF. | -| 32 | `RealRooted.IsPFPolynomial.one` | `RealRooted.PFPolynomial` | The constant polynomial `1` is PF. | +| 42 | `RealRooted.IsPFPolynomial.zero` | `RealRooted.PFPolynomial` | The zero polynomial is PF. | +| 33 | `RealRooted.IsPFPolynomial.one` | `RealRooted.PFPolynomial` | The constant polynomial `1` is PF. | | 27 | `RealRooted.isPFPolynomial_X_add_C` | `RealRooted.PFPolynomial` | The polynomial `X + C a` is PF when `a` is nonnegative. | | 21 | `RealRooted.IsPFPolynomial.of_C_nonneg` | `RealRooted.PFPolynomial` | A nonnegative constant polynomial is PF. | | 15 | `RealRooted.IsPFPolynomial.of_coeff_tendsto` | `RealRooted.PFPolynomial.Closure` | Coefficientwise limits of Pólya-frequency polynomials are Pólya-frequency. | @@ -148,7 +148,7 @@ Counts are lexical estimates: distinctive leaves count unqualified references; g | 11 | `RealRooted.IsPolyaFreqSeq.natCauchyConvolution` | `RealRooted.PolyaFrequencyConvolution.Basic` | Pólya-frequency sequences are closed under Cauchy convolution. | | 10 | `RealRooted.polarTheta_preserves_pf` | `RealRooted.EulerOperator` | The polar-theta operator `N - theta` preserves the polynomial PF cone for polynomials of degree at most `N`. | | 10 | `RealRooted.theta_preserves_pf` | `RealRooted.EulerOperator` | `theta` preserves the polynomial PF cone. | -| 8 | `RealRooted.IsPFPolynomial.add_of_interl` | `RealRooted.OperatorMatrix.Directed` | The sum of an interlacing PF pair is PF. | +| 9 | `RealRooted.IsPFPolynomial.add_of_interl` | `RealRooted.OperatorMatrix.Directed` | The sum of an interlacing PF pair is PF. | | 8 | `RealRooted.isPFPolynomial_jensenPolynomial_of_PFMultiplierSequence` | `RealRooted.MultiplierSequence.Infinite` | Every Jensen polynomial of a PF multiplier sequence is PF. | | 8 | `RealRooted.isPFPolynomial_jensenPolynomial_of_finitePFMultiplierSequence` | `RealRooted.MultiplierSequence` | The easy PF direction: a finite PF multiplier sequence has a PF Jensen polynomial. | | 7 | `RealRooted.IsPFMultiplierSequence.diagonalOperator_isPF` | `RealRooted.MultiplierSequence.Infinite` | | @@ -236,7 +236,7 @@ Counts are lexical estimates: distinctive leaves count unqualified references; g | uses | theorem | module | doc | |---:|---|---|---| | 91 | `RealRooted.roots_nonpos_of_hasNonnegCoeffs` | `RealRooted.Basic.Coefficients` | A real polynomial with nonnegative coefficients has no positive real roots. | -| 45 | `RealRooted.IsPFPolynomial.roots_nonpos` | `RealRooted.PFPolynomial` | | +| 46 | `RealRooted.IsPFPolynomial.roots_nonpos` | `RealRooted.PFPolynomial` | | | 20 | `RealRooted.hasNonnegCoeffs_iff_pos_leadingCoeff_and_roots_nonpos` | `RealRooted.WagnerX.NonnegativeRoots` | | | 17 | `RealRooted.roots_neg_of_hasNonnegCoeffs_of_coeff_zero_ne` | `RealRooted.Basic.Coefficients` | A nonnegative-coefficient polynomial with nonzero constant coefficient has strictly negative roots. | | 15 | `RealRooted.StrictInterl.roots_le_of_right` | `RealRooted.Basic.ProperPosition` | Every root of the left-hand polynomial is bounded by any common upper bound for the roots of the right-hand polynomial in a `StrictInterl` witness. | diff --git a/scripts/import_architecture.json b/scripts/import_architecture.json index f4b7a6aa0..65ceec7f8 100644 --- a/scripts/import_architecture.json +++ b/scripts/import_architecture.json @@ -16,10 +16,10 @@ ], "budgets": { "RealRooted": { - "max_modules": 2421 + "max_modules": 2422 }, "RealRooted.Production": { - "max_modules": 2349 + "max_modules": 2350 }, "RealRooted.Tactic.Examples": { "max_modules": 844