The Mathlib Handbook

The volumes of the handbook are not written yet. This site shows the map of Mathlib that they will follow, at Mathlib 4472534b60.

The areas / V34. The tactics of Mathlib

Mathlib.Tactic.RealRootCount.SturmCertificate

27 declarations. Mathlib docs · Source

A certificate for a Sturm sequence

A SturmCertificate R describes the Sturm sequence of a polynomial with coefficients in R and its derivative, up to positive factors. realRootCount? validates the certificate and returns the number of distinct real roots of the polynomial.

SturmCertificate.fromCoeffList computes the certificate for a polynomial with rational coefficients, after clearing the denominators of its coefficients, as a SturmCertificate ℤ.

Main definitions

  • SturmCertificate: the certificate.
  • SturmCertificate.entries?: validate the certificate and compute the entries of the Sturm sequence that it describes.
  • realRootCount?: validate the certificate and compute the number of distinct real roots of the certificate's polynomial.
  • realRootCountIoo?: validate the certificate and compute the number of distinct real roots in an open interval of the certificate's polynomial, with endpoints given as fractions of elements of R.
  • SturmCertificate.fromCoeffList: computes the factor that clears the denominators of a coefficient list, and the SturmCertificate for the resulting polynomial.

Implementation Notes

The definitions that validate a certificate are exposed because realRootCount? d = some n is intended to be unfolded in a kernel computation.

Representation of polynomials

A polynomial is represented by the list of its coefficients, constant term first, as in Polynomial.ofCoeffList. For example the list [2, -4, 0, 0, 0, 1] represents X ^ 5 - 4 * X + 2. A list may end in zeros, so coeffLead p is the leading coefficient only when it is nonzero.

Validating a certificate

Computing a certificate

theorem Mathlib.Tactic.RealRootCount.SturmStep.mk.injEq E0 #

∀ {R : Type u_1} (a : R) (b : List R) (c : R) (r : List R) (a_1 : R) (b_1 : List R) (c_1 : R) (r_1 : List R),
  ({ a := a, b := b, c := c, r := r } = { a := a_1, b := b_1, c := c_1, r := r_1 }) =
    (a = a_1 ∧ b = b_1 ∧ c = c_1 ∧ r = r_1)

theorem Mathlib.Tactic.RealRootCount.SturmCertificate.mk.inj E1 #

∀ {R : Type u_1} {p : List R} {steps : List (Mathlib.Tactic.RealRootCount.SturmStep R)} {p_1 : List R}
  {steps_1 : List (Mathlib.Tactic.RealRootCount.SturmStep R)},
  { p := p, steps := steps } = { p := p_1, steps := steps_1 } → p = p_1 ∧ steps = steps_1

def Mathlib.Tactic.RealRootCount.SturmStep.ctorIdx E1 #

{R : Type u_1} → Mathlib.Tactic.RealRootCount.SturmStep R → ℕ

theorem Mathlib.Tactic.RealRootCount.SturmCertificate.mk.injEq E0 #

∀ {R : Type u_1} (p : List R) (steps : List (Mathlib.Tactic.RealRootCount.SturmStep R)) (p_1 : List R)
  (steps_1 : List (Mathlib.Tactic.RealRootCount.SturmStep R)),
  ({ p := p, steps := steps } = { p := p_1, steps := steps_1 }) = (p = p_1 ∧ steps = steps_1)

theorem Mathlib.Tactic.RealRootCount.SturmStep.mk.inj E1 #

∀ {R : Type u_1} {a : R} {b : List R} {c : R} {r : List R} {a_1 : R} {b_1 : List R} {c_1 : R} {r_1 : List R},
  { a := a, b := b, c := c, r := r } = { a := a_1, b := b_1, c := c_1, r := r_1 } →
    a = a_1 ∧ b = b_1 ∧ c = c_1 ∧ r = r_1

def Mathlib.Tactic.RealRootCount.SturmCertificate.ctorIdx E1 #

{R : Type u_1} → Mathlib.Tactic.RealRootCount.SturmCertificate R → ℕ

def Mathlib.Tactic.RealRootCount.coeffDerivative E1 #

{R : Type u_1} → [Semiring R] → List R → List R

The derivative of the polynomial that p represents.

ofCoeffList (coeffDerivative p) = derivative (ofCoeffList p)

def Mathlib.Tactic.RealRootCount.coeffLead E1 #

{R : Type u_1} → [Zero R] → List R → R

The last entry of p, or 0 for []. When it is nonzero, it is the leading coefficient of the polynomial that p represents.

coeffLead p ≠ 0 → (ofCoeffList p).leadingCoeff = coeffLead p

def Mathlib.Tactic.RealRootCount.coeffAddSmul E1 #

{R : Type u_1} → [Semiring R] → R → List R → List R → List R

The coefficient list of c • p + q.

ofCoeffList (coeffAddSmul c p q) = c • ofCoeffList p + ofCoeffList q

def Mathlib.Tactic.RealRootCount.coeffMul E1 #

{R : Type u_1} → [Semiring R] → List R → List R → List R

The coefficient list of p * q.

ofCoeffList (coeffMul p q) = ofCoeffList p * ofCoeffList q

structure Mathlib.Tactic.RealRootCount.SturmStep E1 #

Type u_1 → Type u_1

A step of a Sturm sequence.

Let p and q be positive multiples of two consecutive entries of a Sturm sequence. SturmStep stores a, b, c and r that satisfy a • p + b * q + c • r = 0, where a and c are positive and r is of lower degree than q.

These conditions give r = (a / c) • (-p % q), i.e. r is a positive multiple of the next entry in the sequence.

ctor Mathlib.Tactic.RealRootCount.SturmStep.mk E0 #

{R : Type u_1} → R → List R → R → List R → Mathlib.Tactic.RealRootCount.SturmStep R

abbrev Mathlib.Tactic.RealRootCount.SturmStep.a E1 #

{R : Type u_1} → Mathlib.Tactic.RealRootCount.SturmStep R → R

The positive scalar that multiplies p.

abbrev Mathlib.Tactic.RealRootCount.SturmStep.b E1 #

{R : Type u_1} → Mathlib.Tactic.RealRootCount.SturmStep R → List R

The coefficient list of the polynomial that multiplies q.

abbrev Mathlib.Tactic.RealRootCount.SturmStep.c E1 #

{R : Type u_1} → Mathlib.Tactic.RealRootCount.SturmStep R → R

The positive scalar that multiplies r.

abbrev Mathlib.Tactic.RealRootCount.SturmStep.r E1 #

{R : Type u_1} → Mathlib.Tactic.RealRootCount.SturmStep R → List R

The coefficient list of a positive multiple of the next entry of the Sturm sequence.

def Mathlib.Tactic.RealRootCount.SturmStep.check E1 #

{R : Type u_1} →
  [Semiring R] →
    [DecidableEq R] →
      [inst : LT R] → [DecidableLT R] → Mathlib.Tactic.RealRootCount.SturmStep R → List R → List R → Bool

Check that the SturmStep is valid for the two previous Sturm sequence entries p and q: a and c are positive, r is of lower degree than q and a • p + b * q + c • r = 0. The equation is checked by computing the coefficient list of its left-hand side.

structure Mathlib.Tactic.RealRootCount.SturmCertificate E3 #

Type u_1 → Type u_1

A certificate that a list of polynomials is the Sturm sequence of the polynomial with coefficient list p and its derivative up to positive scaling factors.

ctor Mathlib.Tactic.RealRootCount.SturmCertificate.mk E0 #

{R : Type u_1} →
  List R → List (Mathlib.Tactic.RealRootCount.SturmStep R) → Mathlib.Tactic.RealRootCount.SturmCertificate R

abbrev Mathlib.Tactic.RealRootCount.SturmCertificate.p E1 #

{R : Type u_1} → Mathlib.Tactic.RealRootCount.SturmCertificate R → List R

The coefficient list of the polynomial.

abbrev Mathlib.Tactic.RealRootCount.SturmCertificate.steps E1 #

{R : Type u_1} → Mathlib.Tactic.RealRootCount.SturmCertificate R → List (Mathlib.Tactic.RealRootCount.SturmStep R)

The steps that give the entries of the Sturm sequence after p and its derivative.

def Mathlib.Tactic.RealRootCount.sturmEntries? E1 #

{R : Type u_1} →
  [Semiring R] →
    [DecidableEq R] →
      [inst : LT R] →
        [DecidableLT R] → List R → List R → List (Mathlib.Tactic.RealRootCount.SturmStep R) → Option (List (List R))

Reconstruct the entries of a Sturm sequence from its first two entries p and q and the list steps, without the final zero remainder. The function returns none if a step is invalid or the sequence does not end with a zero remainder.

def Mathlib.Tactic.RealRootCount.SturmCertificate.entries? E3 #

{R : Type u_1} →
  [Semiring R] →
    [DecidableEq R] →
      [inst : LT R] → [DecidableLT R] → Mathlib.Tactic.RealRootCount.SturmCertificate R → Option (List (List R))

The sequence of polynomials of the Sturm sequence that the certificate describes. The function returns none if the certificate is invalid.

def Mathlib.Tactic.RealRootCount.realRootCount? E3 #

{R : Type u_1} → [Ring R] → [LinearOrder R] → Mathlib.Tactic.RealRootCount.SturmCertificate R → Option ℕ

Compute the number of distinct real roots of the polynomial in the SturmCertificate. The function returns none if the certificate is invalid.

def Mathlib.Tactic.RealRootCount.evalScaled E1 #

{R : Type u_1} → [Semiring R] → R → R → List R → R

Compute d ^ (p.length - 1) * f (n / d), where f is the polynomial that p represents and d > 0, without dividing by d.

evalScaled n d p = ∑ i : Fin p.length, p[i] * n ^ (i : ℕ) * d ^ (p.length - 1 - i)

def Mathlib.Tactic.RealRootCount.realRootCountIoo? E3 #

{R : Type u_1} →
  [Semiring R] → [LinearOrder R] → Mathlib.Tactic.RealRootCount.SturmCertificate R → R → R → R → R → Option ℕ

Compute the number of distinct real roots of the polynomial in the SturmCertificate that are in the open interval from an / ad to bn / bd. The function returns none if the certificate is invalid, ad or bd is not positive, an / ad < bn / bd is false, or an endpoint is a root of the certificate's polynomial.

Each endpoint is given by a separate numerator and denominator instead of an element of a field because we want the kernel computation to use arithmetic in R only (e.g. integer arithmetic when R = ℤ), and the result does not depend on the numerator and denominator being coprime.

def Mathlib.Tactic.RealRootCount.SturmCertificate.fromCoeffList E3 #

List ℚ → ℕ × Mathlib.Tactic.RealRootCount.SturmCertificate ℤ

For the coefficient list p of a nonzero polynomial, compute k > 0 such that the elements of k • p are integers, and the SturmCertificate for the polynomial with the coefficient list k • p.