Documentation

CslibFrontier.Foundations.FieldTheory.Finite.BinaryField.Native

Executable bytes for the degree-eight binary field #

Cslib.GF256.Byte is the canonical little-endian polynomial-basis byte for F₂[X] / (X⁸ + X⁴ + X³ + X + 1). Its operations are executable list algorithms: addition is byte XOR and multiplication folds the existing Cslib.modStep reduction by the source modulus 0x11b. Exponentiation is the little-endian square-and-multiply fold; inversion is exponentiation by 254, with 0⁻¹ = 0, and division inherits that total convention.

The semantic theorems identify every operation with the existing Cslib.BinaryField 8. The native compiler section retains concrete finite-control transition tables rather than selecting machines from finite-domain computability. Binary-operation inputs are exactly the two raw eight-bit words concatenated; their fixed widths make framing unnecessary.

Main definitions #

Main results #

@[reducible, inline]

A polynomial-basis byte, numbered by its eight coefficients least significant first.

The eight little-endian coefficients of a byte.

@[simp]

Read the first eight little-endian coefficients, padding a short word and truncating a long word.

@[simp]

Encoding and then decoding a byte is exact.

theorem Cslib.GF256.bits_ofBits {word : List Bool} (hword : word.length = 8) :
bits (ofBits word) = word

Decoding and re-encoding an exact eight-bit word is exact.

Canonical raw eight-bit encoding of a byte.

Two canonical bytes concatenated without a delimiter: bits 0…7 are the left operand and bits 8…15 are the right operand.

@[simp]
theorem Cslib.GF256.length_pairBits (input : Byte × Byte) :
(pairBits input).length = 16

Canonical raw sixteen-bit encoding of a pair of bytes.

A byte followed by a little-endian, unframed binary exponent. The first eight bits are always the base, so the variable-length suffix is unambiguous.

@[simp]
theorem Cslib.GF256.length_powBits (input : Byte × ℕ) :
(powBits input).length = 8 + input.2.bits.length

Canonical encoding of a byte and a natural exponent.

Coefficients of X⁸ + X⁴ + X³ + X + 1, constant term first.

Byte addition is coefficient-wise XOR.

theorem Cslib.GF256.bits_add (input : Byte × Byte) :
bits (add input) = List.zipWith xor (bits input.1) (bits input.2)

The byte representation of addition is exactly pointwise XOR.

Byte multiplication: shift-and-reduce the first operand once for every coefficient of the second, accumulating the selected powers by XOR.

theorem Cslib.GF256.bits_mul (input : Byte × Byte) :
bits (mul input) = modMulBits modulusBits (bits input.1) (bits input.2)

The byte representation of multiplication is modMulBits modulo modulusBits.

def Cslib.GF256.powStep (state : Byte × Byte) (bit : Bool) :

One little-endian square-and-multiply round: square the current power and optionally multiply it into the accumulator.

def Cslib.GF256.pow (input : Byte × ℕ) :

Exponentiation by the little-endian binary digits of the exponent.

Total inversion, with inv 0 = 0, by the finite-field exponent 254.

Total division, with division by zero returning zero.

The source modulus and semantic field refinement #

The executable coefficient list is the modulus of BinaryField 8.

The existing power-basis numbering of BinaryField 8 by bytes.

noncomputable def Cslib.GF256.field (a : Byte) :

Interpret a byte as the corresponding element of BinaryField 8.

theorem Cslib.GF256.field_add (input : Byte × Byte) :
field (add input) = field input.1 + field input.2

Executable byte addition refines addition in BinaryField 8.

theorem Cslib.GF256.field_mul (input : Byte × Byte) :
field (mul input) = field input.1 * field input.2

Executable shift-and-reduce multiplication refines multiplication in BinaryField 8.

theorem Cslib.GF256.field_pow (input : Byte × ℕ) :
field (pow input) = field input.1 ^ input.2

Executable square-and-multiply exponentiation refines exponentiation in BinaryField 8.

Executable exponent-254 inversion refines field inversion, including 0⁻¹ = 0.

theorem Cslib.GF256.field_div (input : Byte × Byte) :
field (div input) = field input.1 / field input.2

Executable total division refines field division, with division by zero equal to zero.

Retained native byte machines #

The three phases of a fixed-width binary byte operation: read the left word, read the right word, then emit the result.

Instances For

    Constructive numeric encoding of every fixed-width binary-operation control state.

    Retained tidy table for a fixed-width binary byte operation: execute the direct core, then return the input head to its canonical starting position.

    The retained binary byte table consumes sixteen input bits, emits eight result bits, uses no work tape and halts within forty-one steps.

    Named compiler retaining the direct fixed-width operation table, its exact state encoding and the core-plus-rewind table. In particular, staticBits charges the table hardwired by f.

    Every retained fixed-width binary byte compiler gives an asymptotic polynomial-time witness; the concrete witness remains binaryCompiler f, including its exact staticBits charge.

    Retained native compiler for executable GF(256) multiplication.

    Retained native compiler for executable total GF(256) division.

    Retained unary byte operations #

    The two phases of a fixed-width unary byte operation: read its byte, then emit the result.

    Instances For

      Constructive numeric encoding of every unary-operation control state.

      Retained tidy table for a fixed-width unary byte operation.

      A retained unary byte table consumes eight bits, emits eight bits, uses no work tape and halts within twenty-five steps.

      Named compiler retaining a fixed-width unary byte table and its exact resources.

      Every retained fixed-width unary byte compiler gives an asymptotic polynomial-time witness; the concrete witness remains unaryCompiler f, including its exact staticBits charge.

      Retained native compiler for executable total GF(256) inversion, including its concrete clock, zero workspace bound and exact staticBits program-description charge.

      Retained streaming exponentiation #

      The phases of streaming exponentiation: read the base, fold exponent bits, then emit.

      Instances For

        Constructive numeric encoding of every streaming-exponentiation control state.

        Retained tidy table that reads a raw base byte and streams the little-endian exponent bits.

        The retained exponentiation table streams its unframed exponent, emits eight result bits, uses no work tape and has exact affine time in the encoded input length.

        Named compiler retaining the streaming exponentiation table and its concrete affine clock, zero workspace bound and exact staticBits program-description charge.

        The inversion compiler takes 25 steps and zero workspace, has 4,098 states and 12,294 transition rows. Its final inequality charges the complete encoded program without expanding the large finite table to a decimal.

        The exponentiation compiler takes twice the encoded input length plus 10 steps and zero workspace, and has 69,634 states and 208,902 transition rows. Its final inequality charges the complete encoded program without expanding the large finite table to a decimal.

        Streaming GF(256) exponentiation is computable in polynomial time by powCompiler.