Documentation

CslibFrontier.Computability.TreeEval.Ary.IterativeEncoding

Binary encodings for iterative Cook–Mertz #

The register bank is stored once as a flat finite table. A continuation frame contains binary round and register indices, a phase bit and one coefficient. No register bank, tree or path is stored in a frame. The final bound charges list and pair framing, including the current mode.

These are bounds on an actual injective representation. Native computation of the controller's components and implicit node queries remain separate obligations.

Main definitions #

Main results #

Finite indices use binary values, rather than unary enumeration ranks.

@[simp]
theorem Cslib.TreeEval.Ary.Iter.length_encIndex (n : ℕ) (i : Fin n) :
((encIndex n) i).length = (↑i).size
noncomputable def Cslib.TreeEval.Ary.Iter.encRegs {K : Type} {d r : ℕ} (encK : K ↪ List Bool) :

Flatten the two register indices before storing the bank, avoiding nested list framing.

Frames contain only their five control fields, with binary indices.

Return is empty; call stores its coefficient and binary target after a tag.

noncomputable def Cslib.TreeEval.Ary.Iter.encCfg {K : Type} {d r : ℕ} (encK : K ↪ List Bool) :

The bank is global; the stack and current mode are stored beside it.

Binary residues give logarithmic scalar storage, including the zero residue.

theorem Cslib.TreeEval.Ary.Iter.length_encRegs_le {K : Type} {d r : ℕ} (encK : K ↪ List Bool) (S : State K d r) {L : ℕ} (hK : ∀ (x : K), (encK x).length ≤ L) :
((encRegs encK) S).length ≤ (d + 1) * r * (2 * L + 1)

The flattened bank charges each scalar and its list framing once.

The exact linear allowance for one bounded continuation frame.

theorem Cslib.TreeEval.Ary.Iter.length_encFrame_le {K : Type} {d : ℕ} (encK : K ↪ List Bool) (fr : Frame K d) {rounds L : ℕ} (hK : ∀ (x : K), (encK x).length ≤ L) (hround : fr.round < rounds) :
((encFrame encK) fr).length ≤ frameBits d rounds L
theorem Cslib.TreeEval.Ary.Iter.length_encMode_le {K : Type} {d : ℕ} (encK : K ↪ List Bool) (mode : Mode K d) {L : ℕ} (hK : ∀ (x : K), (encK x).length ≤ L) :
((encMode encK) mode).length ≤ 2 * L + (d + 1).size + 2
theorem Cslib.TreeEval.Ary.Iter.length_encCfg_le {K : Type} {d r H : ℕ} (encK : K ↪ List Bool) (q : Cfg K d r) {rounds L : ℕ} (hK : ∀ (x : K), (encK x).length ≤ L) (hq : ControlBounds H rounds q) :
((encCfg encK) q).length ≤ 2 * ((d + 1) * r * (2 * L + 1)) + 2 * (H * (2 * frameBits d rounds L + 1)) + 2 * L + (d + 1).size + 4

Every frame and every separator is charged; the register bank is charged only once.

theorem Cslib.TreeEval.Ary.Iter.length_encCfg_runFrom_le {K : Type} {d r b H : ℕ} [Field K] (encK : K ↪ List Bool) {L : ℕ} (hK : ∀ (x : K), (encK x).length ≤ L) (T : Tree d b H) (hd : 0 < d) (e : (Fin b → Bool) → Fin r → K) (E : Gate d b → (Fin d → Fin r → K) → Fin r → K) (us : List Kˣ) (S : State K d r) (c : K) (t : Fin (d + 1)) (n : ℕ) :
((encCfg encK) (runFrom hd e E us T.nodeAt (initialCfg S c t) n)).length ≤ 2 * ((d + 1) * r * (2 * L + 1)) + 2 * (H * (2 * frameBits d us.length L + 1)) + 2 * L + (d + 1).size + 4

The compact representation bound holds at every clock of a root call.

Binary encoding in the modulus selected by the packed parameter construction.

theorem Cslib.TreeEval.Ary.Iter.length_encRegs_packed_le {d b : ℕ} (hd : 0 < d) (hb : 0 < b) (S : State (ZMod (Packed.fieldModulus d b)) d (Packed.chunkCount d b)) :
((encRegs (encPackedField d b)) S).length ≤ 9 * (d + 1) * (b + Packed.chunkWidth d b)

The actual flat bank encoding has linear payload size for the selected parameters.

theorem Cslib.TreeEval.Ary.Iter.length_encCfg_packed_le {d b H : ℕ} (hd : 0 < d) (hb : 0 < b) (q : Cfg (ZMod (Packed.fieldModulus d b)) d (Packed.chunkCount d b)) {rounds : ℕ} (hq : ControlBounds H rounds q) :
((encCfg (encPackedField d b)) q).length ≤ 18 * (d + 1) * (b + Packed.chunkWidth d b) + 2 * (H * (2 * frameBits d rounds (2 * Packed.chunkWidth d b + 2) + 1)) + 4 * Packed.chunkWidth d b + (d + 1).size + 8

The concrete packed representation has linear bank cost and small per-level control cost. For fixed fan-in, chunkWidth d b = (d*b).size, so the first term is linear in b and each frame uses logarithmically many bits in b and the round count.

theorem Cslib.TreeEval.Ary.Iter.length_encCfg_packed_runFrom_le {d b H : ℕ} [Fact (Nat.Prime (Packed.fieldModulus d b))] (hd : 0 < d) (hb : 0 < b) (T : Tree d b H) (e : (Fin b → Bool) → Fin (Packed.chunkCount d b) → ZMod (Packed.fieldModulus d b)) (E : Gate d b → (Fin d → Fin (Packed.chunkCount d b) → ZMod (Packed.fieldModulus d b)) → Fin (Packed.chunkCount d b) → ZMod (Packed.fieldModulus d b)) (us : List (ZMod (Packed.fieldModulus d b))ˣ) (S : State (ZMod (Packed.fieldModulus d b)) d (Packed.chunkCount d b)) (c : ZMod (Packed.fieldModulus d b)) (t : Fin (d + 1)) (n : ℕ) :
((encCfg (encPackedField d b)) (runFrom hd e E us T.nodeAt (initialCfg S c t) n)).length ≤ 18 * (d + 1) * (b + Packed.chunkWidth d b) + 2 * (H * (2 * frameBits d us.length (2 * Packed.chunkWidth d b + 2) + 1)) + 4 * Packed.chunkWidth d b + (d + 1).size + 8

The selected packed representation satisfies the bound at every root-call clock.

theorem Cslib.TreeEval.Ary.Iter.frameBits_packed_le {d b : ℕ} (hd : 0 < d) (hb : 0 < b) {rounds : ℕ} (hrounds : rounds ≤ Packed.fieldModulus d b) :
frameBits d rounds (2 * Packed.chunkWidth d b + 2) ≤ 8 * Packed.chunkWidth d b + 2 * d.size + (d + 1).size + 14

At most one round per field element keeps each frame logarithmic in the value width.

theorem Cslib.TreeEval.Ary.Iter.length_encCfg_packed_le_of_rounds_le {d b H : ℕ} (hd : 0 < d) (hb : 0 < b) (q : Cfg (ZMod (Packed.fieldModulus d b)) d (Packed.chunkCount d b)) {rounds : ℕ} (hq : ControlBounds H rounds q) (hrounds : rounds ≤ Packed.fieldModulus d b) :
((encCfg (encPackedField d b)) q).length ≤ 18 * (d + 1) * (b + Packed.chunkWidth d b) + 2 * (H * (16 * Packed.chunkWidth d b + 4 * d.size + 2 * (d + 1).size + 29)) + 4 * Packed.chunkWidth d b + (d + 1).size + 8

The complete packed state has linear bank size plus logarithmic control per tree level. The explicit round-count premise holds for an enumeration without repeated field units.

theorem Cslib.TreeEval.Ary.Iter.length_encCfg_packed_runFrom_le_of_rounds_le {d b H : ℕ} [Fact (Nat.Prime (Packed.fieldModulus d b))] (hd : 0 < d) (hb : 0 < b) (T : Tree d b H) (e : (Fin b → Bool) → Fin (Packed.chunkCount d b) → ZMod (Packed.fieldModulus d b)) (E : Gate d b → (Fin d → Fin (Packed.chunkCount d b) → ZMod (Packed.fieldModulus d b)) → Fin (Packed.chunkCount d b) → ZMod (Packed.fieldModulus d b)) (us : List (ZMod (Packed.fieldModulus d b))ˣ) (hus : us.length ≤ Packed.fieldModulus d b) (S : State (ZMod (Packed.fieldModulus d b)) d (Packed.chunkCount d b)) (c : ZMod (Packed.fieldModulus d b)) (t : Fin (d + 1)) (n : ℕ) :
((encCfg (encPackedField d b)) (runFrom hd e E us T.nodeAt (initialCfg S c t) n)).length ≤ 18 * (d + 1) * (b + Packed.chunkWidth d b) + 2 * (H * (16 * Packed.chunkWidth d b + 4 * d.size + 2 * (d + 1).size + 29)) + 4 * Packed.chunkWidth d b + (d + 1).size + 8

At every clock, the packed state has linear bank size plus logarithmic control per tree level when the rounds fit the field.