Documentation

CslibFrontier.Foundations.Data.Code.JustesenFamily

Justesen codewords for finite labels #

Pack the binary digits of each label into the coefficients of a Reed–Solomon polynomial over the explicit binary field. Apply the Justesen encoder to its evaluations at the nonzero field elements. For the coding step of [Hoza2026NLUL, §2.1], we take the least field degree in the Justesen family whose message capacity is at least 512 times the bit count 1 + log₂ (w * (n + 1)). Consecutive capacities have bounded ratio, so the block length is proportional to that bit count. The relative distance bound gives at least four times that bit count in differing coordinates for each pair of distinct labels.

The executable coordinate evaluators use Horner's rule over lists of field coefficient bits. indexedCodewordMod computes the same indexed bits using modular shifts, without building a multiplication table. A native logspace implementation is tracked in cslib-frontier #6747.

Main definitions #

Main results #

The binary field degree at scale s.

The number of field coefficients in a message at scale s.

Moving to the next scale multiplies the message dimension by 2 ^ 16.

There are twice as many field elements as coefficients in the message at this scale.

Degree of the binary field at the least scale with sufficient message capacity.

The selected field has positive degree.

theorem Cslib.Code.JustesenFamily.fieldDegree_spec (w n : ℕ) :
have threshold := 512 * ((w * (n + 1)).log2 + 1); ∃ s ≤ threshold, fieldDegree w n = scaleDegree s ∧ threshold ≤ dimension s * scaleDegree s ∧ ∀ j < s, dimension j * scaleDegree j < threshold

The chosen degree is the first 16 * (s + 1) whose message capacity meets the required threshold. The threshold also bounds the number of unsuccessful scales.

Number of coefficient blocks in the outer Reed–Solomon message at the selected scale.

The coefficient count is the power of two retained by the capacity loop.

@[reducible, inline]

Code coordinates are a nonzero evaluation point, a Wozencraft half, and a bit within it.

noncomputable def Cslib.Code.JustesenFamily.codeword {w n : ℕ} (v : Fin w) :

The Justesen encoding of the binary digits of a label, in least-significant-first order.

Different finite labels give different Justesen words.

theorem Cslib.Code.JustesenFamily.length_bounds (w n : ℕ) :
512 * (Nat.log 2 (w * (n + 1)) + 1) ≤ Fintype.card (Coordinate w n) ∧ Fintype.card (Coordinate w n) ≤ 268435456 * (Nat.log 2 (w * (n + 1)) + 1)

The block length is bounded above and below by constant multiples of the target bit count.

Distinct labels differ on at least one hundred twenty-eighth of the coordinates.

theorem Cslib.Code.JustesenFamily.log_le_hammingDist {w n : ℕ} {v v' : Fin w} (hne : v ≠ v') :
4 * (Nat.log 2 (w * (n + 1)) + 1) ≤ hammingDist (codeword v) (codeword v')

Distinct codewords have enough separation for the union bound over the tie events in [Hoza2026NLUL, §2.2].

def Cslib.Code.JustesenFamily.codewordBit {w n : ℕ} (v : Fin w) (point : BitString (fieldDegree w n)) (half : Fin 2) (j : Fin (fieldDegree w n)) :

Evaluate one coordinate using the power-basis bits of its field point. Half zero returns the Reed–Solomon evaluation, and half one returns the evaluation multiplied by the point.

theorem Cslib.Code.JustesenFamily.codewordBit_eq {w n : ℕ} (v : Fin w) (u : (BinaryField (fieldDegree w n))ˣ) (half : Fin 2) (j : Fin (fieldDegree w n)) :
codewordBit v ((BinaryField.equivBits ⋯) ↑u) half j = codeword v (u, half, j)

Executable coordinate evaluation agrees with the algebraic Justesen word.

Length of the coordinate list in evaluation-point, half, and bit order.

Unrank an executable codeword index in point, half, then bit order.

The numeric fields of one executable Justesen codeword coordinate.

  • point : ℕ

    The positive binary number of the field point.

  • half : ℕ

    The zero-based Wozencraft half.

  • bit : ℕ

    The zero-based bit within that half.

Decode a binary index at the supplied degree. The index runs through all bits in a half, then both halves at a point, before advancing to the next nonzero point.

theorem Cslib.Code.JustesenFamily.decodeIndex_eq_decodeCoordinate {w n : ℕ} (j : Fin (codeLength w n)) :
decodeIndex (fieldDegree w n) ↑j = match (decodeCoordinate w n) j with | (point, half, bit) => { point := ↑point + 1, half := ↑half, bit := ↑bit }

On valid indices the numeric decoder reads the same coordinate as the equivalence used by the indexed evaluator. The point field uses the positive numbering of the field words.

The power-basis bits of the positively numbered field point at zero-based rank i.

On a valid index the little-endian word of the decoded point is the exact power-basis word passed to the indexed evaluator.

The codeword in executable coordinate order. Points are numbered as positive binary integers in power-basis coordinates.

Evaluate one indexed coordinate with modular shifts and XORs, holding only the modulus and individual field words. The multiplication kernel uses no precomputed table.

theorem Cslib.Code.JustesenFamily.indexedCodewordMod_eq_hornerBits {w n : ℕ} (v : Fin w) (j : Fin (codeLength w n)) :
indexedCodewordMod v j = match (decodeCoordinate w n) j with | (point, half, bit) => have mul := BinaryField.fieldMulMod (BinaryField.modulusBitsScan (fieldDegree w n)); have x := List.ofFn (nonzeroPointBits point); have y := BinaryField.hornerBits (fieldDegree w n) mul x fun (i : Fin (coefficientCount w n)) => BitString.lowBits (fieldDegree w n) (↑v >>> (fieldDegree w n * ↑i)); wozencraftBitWith mul x y ↑half ↑bit

The table-free indexed bit selects a Wozencraft bit of the Horner evaluation of the binary label's fixed-width coefficient blocks.

Table-free evaluation returns the same bit in the existing indexed coordinate order.

theorem Cslib.Code.JustesenFamily.codeLength_bounds (w n : ℕ) :
512 * (Nat.log 2 (w * (n + 1)) + 1) ≤ codeLength w n ∧ codeLength w n ≤ 268435456 * (Nat.log 2 (w * (n + 1)) + 1)

The executable block length has the same quantitative bounds as the algebraic one.

The executable coordinate order preserves the distance needed for Hoza's union bound.