Documentation

HexGFqMathlib.Basic

Interpret the first degree coefficients of an FpPoly as a base-p index.

This is the encoder half of the bijection between degree-< degree polynomials and Fin (p ^ degree); ofIndexBelowDegree is its inverse on bounded inputs (coeffIndex_ofIndexBelowDegree, ofIndexBelowDegree_coeffIndex), and the value is always below p ^ degree (coeffIndex_lt).

Equations
Instances For

    Decode a base-p index into a polynomial with at most degree coefficients.

    The decoder half of the coeffIndex bijection. Its coefficients are characterised by coeff_ofIndexBelowDegree_of_lt (in range, a simp normal form) and coeff_ofIndexBelowDegree_of_ge (beyond the width, zero), and its FpPoly.degree stays below degree when the width is positive (ofIndexBelowDegree_degree_lt).

    Equations
    Instances For
      theorem HexGFqMathlib.FpPoly.coeffIndex_succ {p : } [Hex.ZMod64.Bounds p] (degree : ) (f : Hex.FpPoly p) :
      coeffIndex (degree + 1) f = coeffIndex degree f + (Hex.DensePoly.coeff f degree).toNat * p ^ degree

      Peeling the top position of the base-p encoding.

      coeffIndex is the base-p interpretation of the per-position residue digits, exposing Mathlib's Nat.ofDigits API.

      theorem HexGFqMathlib.FpPoly.coeffIndex_lt {p : } [Hex.ZMod64.Bounds p] (degree : ) (f : Hex.FpPoly p) :
      coeffIndex degree f < p ^ degree

      A base-p positional sum of degree residue digits stays below p ^ degree.

      theorem HexGFqMathlib.FpPoly.ofDigits_div_pow_mod {p : } (hp : 0 < p) (L : List ) (hL : xL, x < p) (j : ) (hj : j < L.length) :
      Nat.ofDigits p L / p ^ j % p = L.getD j 0

      Extracting digit j of a base-p number presented through Nat.ofDigits.

      theorem HexGFqMathlib.FpPoly.ofDigits_range_map_div_pow_mod {p : } (hp : 0 < p) (degree n : ) :
      n < p ^ degreeNat.ofDigits p (List.map (fun (i : ) => n / p ^ i % p) (List.range degree)) = n

      Reconstructing a number below p ^ degree from its fixed-width base-p digits.

      @[simp]
      theorem HexGFqMathlib.FpPoly.coeff_ofIndexBelowDegree_of_lt {p : } [Hex.ZMod64.Bounds p] (degree index i : ) (hi : i < degree) :

      Coefficients below the width read back the encoded base-p digit.

      @[simp]
      theorem HexGFqMathlib.FpPoly.coeff_ofIndexBelowDegree_of_ge {p : } [Hex.ZMod64.Bounds p] (degree index i : ) (hi : degree i) :

      Coefficients at or beyond the width vanish.

      theorem HexGFqMathlib.FpPoly.degree_lt_of_size_le {p : } [Hex.ZMod64.Bounds p] (g : Hex.FpPoly p) (d : ) (hsz : Hex.DensePoly.size g d) (hd : 0 < d) :
      g.degree < d

      The width-degree decoder produces a polynomial of size at most degree, hence degree below degree whenever the width is positive.

      A polynomial's stored size is at most one more than its FpPoly.degree.

      theorem HexGFqMathlib.FpPoly.coeffIndex_lt_of_degree_lt {p : } [Hex.ZMod64.Bounds p] {degree : } {f : Hex.FpPoly p} (_hdeg : f.degree < degree) :
      coeffIndex degree f < p ^ degree

      Bounded reduced polynomials encode to indices below p ^ degree.

      theorem HexGFqMathlib.FpPoly.ofIndexBelowDegree_degree_lt {p : } [Hex.ZMod64.Bounds p] (degree index : ) (hd : 0 < degree) :
      (ofIndexBelowDegree degree index).degree < degree

      Decoded indices are represented by polynomials with degree below the requested bound. The positivity hypothesis is necessary: at degree = 0 the index type Fin (p ^ 0) = Fin 1 is inhabited but the decoder returns the zero polynomial, whose FpPoly.degree is 0.

      @[simp]
      theorem HexGFqMathlib.FpPoly.coeffIndex_ofIndexBelowDegree {p : } [Hex.ZMod64.Bounds p] (degree : ) (index : Fin (p ^ degree)) :
      coeffIndex degree (ofIndexBelowDegree degree index) = index

      Encoding after decoding recovers the bounded index.

      @[simp]
      theorem HexGFqMathlib.FpPoly.ofIndexBelowDegree_coeffIndex {p : } [Hex.ZMod64.Bounds p] {degree : } {f : Hex.FpPoly p} (hdeg : f.degree < degree) :
      ofIndexBelowDegree degree (coeffIndex degree f) = f

      Decoding after encoding recovers a polynomial already below the degree bound.

      @[instance_reducible]
      noncomputable instance HexGFqMathlib.FiniteField.field {p : } [Hex.ZMod64.Bounds p] [Hex.ZMod64.PrimeModulus p] {f : Hex.FpPoly p} {hf : 0 < f.degree} {hp : Hex.Nat.Prime p} {hirr : f.Irreducible} :

      The executable finite-field wrapper carries Mathlib's Field structure through the field laws already proved for the implementation-facing Lean.Grind.Field hierarchy.

      Equations
      • One or more equations did not get rendered due to their size.
      @[reducible, inline]

      Reduced polynomial representatives for the quotient by f.

      Equations
      Instances For

        The executable finite-field wrapper is equivalent to its canonical reduced polynomial representatives.

        Equations
        • One or more equations did not get rendered due to their size.
        Instances For

          Reduced representatives are indexed by Fin (p ^ degree f). The positive-degree hypothesis is needed for the decoder's degree bound (see FpPoly.ofIndexBelowDegree_degree_lt); it is supplied at every call site by the nonconstant-modulus assumption.

          Equations
          • One or more equations did not get rendered due to their size.
          Instances For

            Generic finite-field elements are equivalent to the expected finite index type.

            Equations
            Instances For
              @[instance_reducible]
              noncomputable instance HexGFqMathlib.FiniteField.fintype {p : } [Hex.ZMod64.Bounds p] {f : Hex.FpPoly p} {hf : 0 < f.degree} {hp : Hex.Nat.Prime p} {hirr : f.Irreducible} :

              The generic executable finite-field wrapper is finite.

              Equations
              @[simp]

              The generic executable finite-field wrapper has the expected cardinality.

              @[instance_reducible]
              noncomputable instance HexGFqMathlib.GFq.fintype {p n : } [Hex.ZMod64.Bounds p] (h : Hex.Conway.SupportedEntry p n) :

              Canonical Conway-backed GFq values inherit the generic finite-field enumeration.

              Equations

              Cardinality of the canonical Conway-backed GFq in terms of its selected modulus degree.

              The committed Conway modulus has the requested extension degree.

              @[simp]

              The committed Conway polynomial has the requested extension degree. This is the Conway.conwayPoly-phrased twin of modulus_degree: it is the form simp needs once the @[simp] lemma modulus_eq_conway has normalised GFq.modulus h to Conway.conwayPoly p n h, and together with FiniteField.fintype_card it drives Fintype.card (GFq p n h) to p ^ n.

              @[simp]

              Cardinality of canonical GFq p n as p ^ n.

              Canonical Hex.GFq and Mathlib's GaloisField have matching cardinalities.

              Canonical Hex.GFq values are ring-equivalent to Mathlib's GaloisField with the same characteristic and extension degree.

              Equations
              Instances For