💎 Reusable layer
← all 82R0014

The Budan–Fourier theorem

API

Use this theorem

  1. Create a project

    Shell
    lake +leanprover/lean4:v4.35.0 new myproject std.toml
    cd myproject

    Standard template, not math: the math template adds its own Mathlib requirement pinned to the Lean release tag, not to the Mathlib commit this package is built and tested with, so you would get a second, different Mathlib. Mathlib comes in through this package. Skip this step in an existing project with the same Lean and Mathlib.

  2. Add the dependency to lakefile.toml

    TOML
    [[require]]
    name = "formalizations"
    git = "https://github.com/karlesmarin/formalizations"
    rev = "v0.15.0"
  3. Import the minimal module

    Lean 4
    import Formalizations.Reusable.Polynomial

    In a file of the project, e.g. Example.lean.

  4. Paste the example

    Lean 4
    open Formalizations.Reusable Polynomial
    
    /-- Budan–Fourier: if the derivative tower loses exactly one sign variation from `a` to `b`, then
    `p` has a root in `(a, b]` (the parity forbids zero roots). -/
    example (p : Polynomial ℝ) (hp : p ≠ 0) {a b : ℝ} (hab : a < b) (ha : p.eval a ≠ 0)
        (hb : p.eval b ≠ 0)
        (h1 : ((List.range (p.natDegree + 1)).map (fun k => ((derivative^[k]) p).eval a)).signVariations -
            ((List.range (p.natDegree + 1)).map (fun k => ((derivative^[k]) p).eval b)).signVariations = 1) :
        ∃ x ∈ Set.Ioc a b, p.IsRoot x := by
      obtain ⟨-, hev⟩ := budan_fourier_card_roots_le p hp hab ha hb
      rw [h1] at hev
      have hne : (p.roots.filter (fun x => a < x ∧ x ≤ b)).card ≠ 0 := by
        intro h0
        rw [h0] at hev
        simp at hev
      obtain ⟨x, hx⟩ := Multiset.card_pos_iff_exists_mem.1 (Nat.pos_of_ne_zero hne)
      rw [Multiset.mem_filter] at hx
      exact ⟨x, ⟨hx.2.1, hx.2.2⟩, (mem_roots hp).1 hx.1⟩

    Steps 3 and 4 together are a complete Lean file:FormalizationsTest/ReusablePolynomialExample.lean at v0.15.0, compiled by the CI.

  5. Fetch and check

    Shell
    lake update
    lake lean Example.lean

    lake update fetches this package and Mathlib, and Mathlib's update hook downloads the compiled Mathlib (lake exe cache get). lake lean Example.lean builds the imports of the file (steps 3 and 4) and checks it. If the file belongs to a lean_lib of your project, lake build <lib> does the same. Avoid a bare lake build in a project from the standard template: its default target is the executable, whose link compiles every imported Mathlib module to native code. Same versions required: Lean v4.35.0, Mathlib f0b4c81.

Alternative: import Formalizations.Reusable imports the whole layer (all areas).

The Budan–Fourier theorem: for nonzero p ∈ ℝ[X] and a < b with p(a), p(b) ≠ 0, the number of roots of p in (a, b] counted with multiplicity is at most V(a) − V(b), with even difference, where V(x) is the number of sign variations of p, p′, …, p^(deg p) at x.

Lean statement

Lean 4
theorem budan_fourier_card_roots_le (p : Polynomial ℝ) (hp : p ≠ 0) {a b : ℝ} (hab : a < b)
    (ha : p.eval a ≠ 0) (hb : p.eval b ≠ 0) :
    (p.roots.filter (fun x => a < x ∧ x ≤ b)).card ≤
        ((List.range (p.natDegree + 1)).map (fun k => ((derivative^[k]) p).eval a)).signVariations -
          ((List.range (p.natDegree + 1)).map (fun k => ((derivative^[k]) p).eval b)).signVariations ∧
      Even (((List.range (p.natDegree + 1)).map
          (fun k => ((derivative^[k]) p).eval a)).signVariations -
        ((List.range (p.natDegree + 1)).map (fun k => ((derivative^[k]) p).eval b)).signVariations -
        (p.roots.filter (fun x => a < x ∧ x ≤ b)).card)
Name
Formalizations.Reusable.budan_fourier_card_roots_le
Import
import Formalizations.Reusable.Polynomial
Version
formalizations 0.15.0Lean v4.35.0Mathlib f0b4c81
Role
API a lemma to import and build other proofs on
Provenance
BudanFourier.budan_fourier, BudanFourier.fourierVar_eq_signVarAt, Sturm.signVarAt_eq_signVariations in Formalizations.Analysis.Polynomial.RealRoots.BudanFourier
Paper: none
Classical reference
F. D. Budan (1807), J. Fourier (1820); S. Basu, R. Pollack, M.-F. Roy, Algorithms in Real Algebraic Geometry, ch. 2
Trust
standard axioms only propext, Classical.choice, Quot.sound
#print axioms in FormalizationsTest/Axioms.lean, audited by scripts/check_axioms.sh (2758 results), which the CI build workflow runs and passed at this commit.
Status
reusable upstream candidate
Area
Polynomial

Links

Lean docstring

The Budan–Fourier theorem. For a nonzero real polynomial p and a < b with p a ≠ 0 and p b ≠ 0, let V x be the number of sign variations (Mathlib's List.signVariations, zeros skipped) of the derivative tower p, p', p'', …, p^{(deg p)} evaluated at x. Then the number of real roots of p in (a, b], counted with multiplicity, is at most V a − V b, and the difference is even. Descartes' rule of signs is the case (0, ∞).

  • Archive: BudanFourier.budan_fourier (Formalizations.Analysis.Polynomial.RealRoots.BudanFourier), restated with List.signVariations through the archive bridges BudanFourier.fourierVar_eq_signVarAt and Sturm.signVarAt_eq_signVariations.
  • Classical reference: F. D. Budan (1807), J. Fourier (1820); S. Basu, R. Pollack, M.-F. Roy, Algorithms in Real Algebraic Geometry, ch. 2.
  • Example: for p = X² − 1 on (0, 2], the theorem bounds the number of roots (one, at 1) by the drop of sign variations of (X² − 1, 2X, 2) from 0 to 2, which is 1.

Upstream

Mathlib has Descartes' rule of signs (roots_countP_pos_le_signVariations) and List.signVariations, not Budan–Fourier

Depends on, in this repository

Formalizations.Analysis.Polynomial.RealRoots.Sturm