Documentation

QedShare.Poly.Basic

Polynomials over GF(2⁸) #

A polynomial is a list of coefficients, lowest degree first: [c₀, c₁, …, c_d] stands for c₀ + c₁·x + … + c_d·x^d. Trailing zeros are allowed (they don't change the value), so a list of length k is a polynomial of degree < k.

Evaluation uses Horner's method: c₀ + x·(c₁ + x·(c₂ + …)).

@[reducible, inline]

A polynomial over GF(2⁸), as its coefficient list, lowest degree first.

Equations
Instances For

    Evaluate a polynomial at x with Horner's method.

    Equations
    Instances For

      x ^ n in GF(2⁸), by repeated multiplication.

      Equations
      Instances For

        The textbook "sum of powers" value of a polynomial whose first coefficient multiplies xⁱ: Σⱼ cⱼ · x^(i+j). With i = 0 this is the usual Σⱼ cⱼ · xʲ.

        Equations
        Instances For
          @[simp]
          theorem QedShare.Poly.eval_nil (x : GF256) :
          eval [] x = 0

          The empty (zero) polynomial is 0 everywhere.

          @[simp]
          theorem QedShare.Poly.eval_cons (c : GF256) (cs : Poly) (x : GF256) :
          eval (c :: cs) x = c + x * cs.eval x

          Horner's rule: (c + X·q)(x) = c + x·q(x).

          theorem QedShare.Poly.eval_zero (s : GF256) (cs : Poly) :
          eval (s :: cs) 0 = s

          A polynomial with constant term s evaluates to s at x = 0.

          theorem QedShare.Poly.sumPowers_succ (cs : Poly) (i : Nat) (x : GF256) :
          cs.sumPowers (i + 1) x = x * cs.sumPowers i x

          Shifting the starting power by one multiplies the sum by x.

          theorem QedShare.Poly.horner_eq_sum (p : Poly) (x : GF256) :
          p.eval x = p.sumPowers 0 x

          Horner evaluation equals the sum-of-powers definition Σⱼ cⱼ · xʲ.