Documentation

CslibFrontier.Computability.TreeEval.Ary.Packed

Packed gate extensions for Cook–Mertz #

Bit strings are grouped into chunks and embedded in a finite field, so one register coordinate can hold several bits. A final partial chunk is zero-padded. The gate extension interpolates on the chunk alphabet rather than separately on each bit.

This is the algebraic packing step of [Wil25], Appendix A, equation (6). The field may have arbitrary characteristic: signed recursive calls and unit sums replace the source's characteristic-two cancellations. With r chunks and alphabet H, the strict degree condition is d * r * (|H| - 1) < |K| - 1.

Main definitions #

Main results #

Scope #

The results here establish algebraic correctness only. They do not certify native packing, implicit gate queries, the refined space bound, or Williams's time-to-space simulation.

def Cslib.TreeEval.Ary.Packed.pack {r m : ℕ} (v : Fin (r * m) → Bool) :
Fin r → Fin (2 ^ m)

Read an exactly aligned bit string as r chunks of m bits.

def Cslib.TreeEval.Ary.Packed.unpack {r m : ℕ} (v : Fin r → Fin (2 ^ m)) :
Fin (r * m) → Bool

Concatenate the binary representations of the chunks.

@[simp]
theorem Cslib.TreeEval.Ary.Packed.unpack_pack {r m : ℕ} (v : Fin (r * m) → Bool) :
unpack (pack v) = v

Chunking preserves every bit, including zero-valued chunks.

@[simp]
theorem Cslib.TreeEval.Ary.Packed.pack_unpack {r m : ℕ} (v : Fin r → Fin (2 ^ m)) :
pack (unpack v) = v

All tuples of chunks are valid aligned encodings.

def Cslib.TreeEval.Ary.Packed.packBits {b r m : ℕ} (_hb : b ≤ r * m) (v : Fin b → Bool) :
Fin r → Fin (2 ^ m)

Pack a bit string after zero-padding a final partial chunk.

def Cslib.TreeEval.Ary.Packed.unpackBits {b r m : ℕ} (hb : b ≤ r * m) (v : Fin r → Fin (2 ^ m)) :
Fin b → Bool

Decode the original prefix of a padded chunk tuple.

@[simp]
theorem Cslib.TreeEval.Ary.Packed.unpackBits_packBits {b r m : ℕ} (hb : b ≤ r * m) (v : Fin b → Bool) :
unpackBits hb (packBits hb v) = v

Decoding padded chunks recovers the original bit string.

noncomputable def Cslib.TreeEval.Ary.Packed.gateExtension {K : Type u_1} {H : Type u_2} [Field K] [Fintype H] [DecidableEq H] {b d r : ℕ} (h : H ↪ K) (encode : (Fin b → Bool) → Fin r → H) (decode : (Fin r → H) → Fin b → Bool) (f : Gate d b) (x : Fin d → Fin r → K) (i : Fin r) :
K

Extend a Boolean gate after encoding each value in r alphabet symbols. On symbols outside the encoding's image, the caller's decoder determines a total table.

theorem Cslib.TreeEval.Ary.Packed.gateExtension_embed {K : Type u_1} {H : Type u_2} [Field K] [Fintype H] [DecidableEq H] {b d r : ℕ} (h : H ↪ K) (encode : (Fin b → Bool) → Fin r → H) (decode : (Fin r → H) → Fin b → Bool) (hdecode : Function.LeftInverse decode encode) (f : Gate d b) (v : Fin d → Fin b → Bool) (i : Fin r) :
gateExtension h encode decode f (fun (j : Fin d) (k : Fin r) => h (encode (v j) k)) i = h (encode (f v) i)

On encoded child values the gate extension agrees with the encoded gate output.

theorem Cslib.TreeEval.Ary.Packed.sum_units_gateExtension {K : Type u_1} {H : Type u_2} [Field K] [Fintype H] [DecidableEq H] {b d r : ℕ} [Fintype K] [DecidableEq K] (h : H ↪ K) (encode : (Fin b → Bool) → Fin r → H) (decode : (Fin r → H) → Fin b → Bool) (hdecode : Function.LeftInverse decode encode) (hD : d * r * (Fintype.card H - 1) < Fintype.card K - 1) (f : Gate d b) (τ : Fin d → Fin r → K) (v : Fin d → Fin b → Bool) (i : Fin r) :
∑ u : Kˣ, gateExtension h encode decode f (fun (j : Fin d) (k : Fin r) => ↑u * τ j k + h (encode (v j) k)) i = -h (encode (f v) i)

Packed interpolation satisfies the signed unmasking law needed by Cook–Mertz, with only d*r field coordinates and degree at most d*r*(|H|-1).

theorem Cslib.TreeEval.Ary.Packed.procWith_gateExtension_eq {K : Type u_1} {H : Type u_2} [Field K] [Fintype H] [DecidableEq H] {b d r : ℕ} [Fintype K] (h : H ↪ K) (encode : (Fin b → Bool) → Fin r → H) (decode : (Fin r → H) → Fin b → Bool) (hdecode : Function.LeftInverse decode encode) (hD : d * r * (Fintype.card H - 1) < Fintype.card K - 1) {us : List Kˣ} (hnd : us.Nodup) (hmem : ∀ (u : Kˣ), u ∈ us) {height : ℕ} (T : Tree d b height) (c : K) (t : Fin (d + 1)) (S : State K d r) :
procWith (fun (v : Fin b → Bool) (i : Fin r) => h (encode v i)) (gateExtension h encode decode) us T c t S = Function.update S t (S t + c • fun (i : Fin r) => h (encode T.eval i))

The Cook–Mertz procedure on packed registers adds the encoded root value and restores every other register. The representation need only have a left inverse, so a partial last chunk is allowed. This is an algebraic specification, without a native-machine space claim.