Documentation

Mathlib.Tactic.RealRootCount.SturmCertificate

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 #

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 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

    Equations
    Instances For
      def Mathlib.Tactic.RealRootCount.coeffAddSmul {R : Type u_1} [Semiring R] (c : R) :
      List R → List R → List R

      The coefficient list of c • p + q.

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

      Equations
      Instances For

        The coefficient list of p * q.

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

        Equations
        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

              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.

              • p : List R

                The coefficient list of the polynomial.

              • steps : List (SturmStep R)

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

              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
                      def Mathlib.Tactic.RealRootCount.evalScaled {R : Type u_1} [Semiring R] (n d : R) (p : 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)

                      Equations
                      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.
                          Instances For