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 ofR.SturmCertificate.fromCoeffList: computes the factor that clears the denominators of a coefficient list, and theSturmCertificatefor 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 #
The derivative of the polynomial that p represents.
ofCoeffList (coeffDerivative p) = derivative (ofCoeffList p)
Equations
Instances For
The coefficient list of c • p + q.
ofCoeffList (coeffAddSmul c p q) = c • ofCoeffList p + ofCoeffList q
Equations
- Mathlib.Tactic.RealRootCount.coeffAddSmul c [] x✝ = x✝
- Mathlib.Tactic.RealRootCount.coeffAddSmul c (x_2 :: p) [] = c * x_2 :: Mathlib.Tactic.RealRootCount.coeffAddSmul c p []
- Mathlib.Tactic.RealRootCount.coeffAddSmul c (x_2 :: p) (y :: q) = (c * x_2 + y) :: Mathlib.Tactic.RealRootCount.coeffAddSmul c p q
Instances For
The coefficient list of p * q.
ofCoeffList (coeffMul p q) = ofCoeffList p * ofCoeffList q
Equations
- Mathlib.Tactic.RealRootCount.coeffMul p q = List.foldr (fun (c : R) (acc : List R) => Mathlib.Tactic.RealRootCount.coeffAddSmul c q (0 :: acc)) [] p
Instances For
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.
- a : R
The positive scalar that multiplies
p. - b : List R
The coefficient list of the polynomial that multiplies
q. - c : R
The positive scalar that multiplies
r. - r : List R
The coefficient list of a positive multiple of the next entry of the Sturm sequence.
Instances For
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.
Equations
- One or more equations did not get rendered due to their size.
Instances For
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.
Equations
Instances For
The sequence of polynomials of the Sturm sequence that the certificate describes.
The function returns none if the certificate is invalid.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Compute the number of distinct real roots of the polynomial in the SturmCertificate. The
function returns none if the certificate is invalid.
Equations
- One or more equations did not get rendered due to their size.
Instances For
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)
Equations
- Mathlib.Tactic.RealRootCount.evalScaled n d [] = 0
- Mathlib.Tactic.RealRootCount.evalScaled n d (c :: p_2) = c * d ^ p_2.length + n * Mathlib.Tactic.RealRootCount.evalScaled n d p_2
Instances For
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.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Computing a certificate #
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.
Equations
- One or more equations did not get rendered due to their size.