Documentation

CslibFrontier.Computability.Circuit.Boolean.Tableau.Decoder.Assembly

The decoder circuit of the succinct tableau #

The three stages of the decoder of the tableau formula on bit-field labels (CslibFrontier/Computability/Circuit/Boolean/Tableau/Decoder/Circuit.lean) composed into one De Morgan circuit (decoder). From the bits of a clause number below 2 ^ clauseBits, it computes the bits of Cslib.Circuits.Boolean.Tableau.clauseAt (ofFn_eval_decoder). It has O(colBits T + timeBits T + x.length) gates (size_decoder_le): the field stage has 2 + N + 14 P + (2 ^ (Nat.size x.length + 1) - 1) + x.length gates for N = clauseBits and P = N - 4, the constant stage a number depending only on the machine, and the output stage 63 gates per output bit. There is no carry-lookahead adder, whose size is not linear in the width.

Its code is decoderCode, written with the code combinators compCode, appendCode, appendCodes and formulaCode on the explicit gate list of the field stage and the constant code of the constant stage (code_decoder). This is the decoder of the sketch of Williams, Theorem 6.1, p. 20: the variables of the clauses of a cell differ from cell to cell only by the block and the column, which enter through comparisons, increments and decrements of fields. The sketch first converts the machine to a single-tape machine; this decoder is built for the multi-tape tableau directly.

Main definitions #

Main results #

References #

There is at least one slot bit.

def Cslib.Circuits.Boolean.Tableau.Decoder.keySel (s cb tb : ℕ) (x : List Bool) (n T : ℕ) :
Fin (4 + s + 14) → Fin (aWidth s cb tb x n T)

The selection of the inputs of the constant stage among the wires of the field stage.

noncomputable def Cslib.Circuits.Boolean.Tableau.Decoder.middleCircuit {k : ℕ} {State : Type} [Fintype State] [DecidableEq State] (tm : Turing.MultiTapeTM k Bool State) (x : List Bool) (n T : ℕ) :
Circuit signature (aWidth (slotBits k State) (colBits T) (timeBits T) x n T) (aWidth (slotBits k State) (colBits T) (timeBits T) x n T + 3 * (13 + slotBits k State))

The constant stage on the wires of the field stage, beside those wires.

def Cslib.Circuits.Boolean.Tableau.Decoder.outputCircuit (s cb tb : ℕ) (x : List Bool) (n T : ℕ) :
Circuit signature (aWidth s cb tb x n T + 3 * (13 + s)) (3 * (2 + (s + cb + tb) + 1))

The output stage: one copy of outTemplate per output bit, on the wires wireNat.

noncomputable def Cslib.Circuits.Boolean.Tableau.Decoder.decoder {k : ℕ} {State : Type} [Fintype State] [DecidableEq State] (tm : Turing.MultiTapeTM k Bool State) {x : List Bool} {n T : ℕ} (hm : x.length.size ≤ slotBits k State + colBits T + timeBits T) :
Circuit signature (4 + (slotBits k State + colBits T + timeBits T)) (3 * (2 + (slotBits k State + colBits T + timeBits T) + 1))

The decoder circuit of the tableau formula of tm on bit-field labels, for the fixed prefix x, n inputs and T steps.

The code #

The code of the decoder, written with the code combinators compCode, appendCode, appendCodes and formulaCode: the field stage, the constant code of the constant stage, and one instance of outTemplate per output bit (code_decoder).

theorem Cslib.Circuits.Boolean.Tableau.Decoder.code_decoder {k : ℕ} {State : Type} [Fintype State] [DecidableEq State] (tm : Turing.MultiTapeTM k Bool State) {x : List Bool} {n T : ℕ} (hm : x.length.size ≤ slotBits k State + colBits T + timeBits T) :
(decoder tm hm).code = decoderCode tm (x, n, T)

The code of the decoder circuit is decoderCode.

Size #

theorem Cslib.Circuits.Boolean.Tableau.Decoder.size_outputCircuit_le (s cb tb : ℕ) (x : List Bool) (n T : ℕ) :
(outputCircuit s cb tb x n T).size ≤ 3 * (2 + (s + cb + tb) + 1) * 63
theorem Cslib.Circuits.Boolean.Tableau.Decoder.size_decoder_le {k : ℕ} {State : Type} [Fintype State] [DecidableEq State] (tm : Turing.MultiTapeTM k Bool State) {x : List Bool} {n T : ℕ} (hm : x.length.size ≤ slotBits k State + colBits T + timeBits T) :
(decoder tm hm).size ≤ (204 * slotBits k State + 600 + (tableCircuit tm).size) * (colBits T + timeBits T + x.length + 1)

The decoder has O(colBits T + timeBits T + x.length) gates, with a constant depending only on the machine.

Correctness #

theorem Cslib.Circuits.Boolean.Tableau.Decoder.outBit_congr {s cb tb : ℕ} {ts ts' sel sel' : ℕ → Bool} (hts : ∀ f < 2 + s, ts f = ts' f) (hsel : ∀ q < 11, sel q = sel' q) (p c t T : ℕ) (lk : Bool) (i : ℕ) :
outBit s cb tb ts sel p c t T lk i = outBit s cb tb ts' sel' p c t T lk i
theorem Cslib.Circuits.Boolean.Tableau.Decoder.eval_middle_field {k : ℕ} {State : Type} [Fintype State] [DecidableEq State] (tm : Turing.MultiTapeTM k Bool State) {x : List Bool} {n T : ℕ} (hm : x.length.size ≤ slotBits k State + colBits T + timeBits T) (idx : ℕ) (w : Fin (aWidth (slotBits k State) (colBits T) (timeBits T) x n T + 3 * (13 + slotBits k State))) :
((middleCircuit tm x n T).comp (fieldCircuit hm)).eval interpretation (fun (i : Fin (4 + (slotBits k State + colBits T + timeBits T))) => idx.testBit ↑i) w = if h : ↑w < aWidth (slotBits k State) (colBits T) (timeBits T) x n T then fieldVal (slotBits k State) (colBits T) (timeBits T) x n T idx ↑w else tableFn tm (fun (i : Fin (4 + slotBits k State + 14)) => fieldVal (slotBits k State) (colBits T) (timeBits T) x n T idx (keyWire (slotBits k State) (colBits T) (timeBits T) ↑i)) ⟨↑w - aWidth (slotBits k State) (colBits T) (timeBits T) x n T, ⋯⟩

The values of the wires of the field and constant stages.

theorem Cslib.Circuits.Boolean.Tableau.Decoder.ofFn_eval_decoder {k : ℕ} {State : Type} [Fintype State] [DecidableEq State] (tm : Turing.MultiTapeTM k Bool State) {x : List Bool} {n T : ℕ} (hn : n < 2 * T) (hx : x.length ≤ n) (hm : x.length.size ≤ slotBits k State + colBits T + timeBits T) {idx : ℕ} (hidx : idx < 2 ^ (4 + (slotBits k State + colBits T + timeBits T))) :
List.ofFn ((decoder tm hm).eval interpretation fun (i : Fin (4 + (slotBits k State + colBits T + timeBits T))) => idx.testBit ↑i) = List.flatMap (litBits (2 + (slotBits k State + colBits T + timeBits T))) (clauseAt tm x n T idx)

The decoder computes the clause with a given number: its outputs are the bits of the three literals of clauseAt, for n < 2 T and a fixed prefix of length at most n.

The decoder of the succinct tableau #

noncomputable def Cslib.Circuits.Boolean.Tableau.Decoder.sizeConst {k : ℕ} {State : Type} [Fintype State] [DecidableEq State] (tm : Turing.MultiTapeTM k Bool State) :

The constant of the size bound of the decoder, which depends only on the machine.

theorem Cslib.Circuits.Boolean.Tableau.Decoder.exists_decoder {k : ℕ} {State : Type} [Fintype State] [DecidableEq State] (tm : Turing.MultiTapeTM k Bool State) (x : List Bool) {n T : ℕ} (hn : n < 2 * T) (hx : x.length ≤ n) :
∃ (c : Circuit signature (clauseBits k State T) (3 * (labelBits k State T + 1))), c.code = decoderCode tm (x, n, T) ∧ c.size ≤ sizeConst tm * (colBits T + timeBits T + x.length + 1) ∧ ∀ idx < 2 ^ clauseBits k State T, List.ofFn (c.eval interpretation fun (i : Fin (clauseBits k State T)) => idx.testBit ↑i) = List.flatMap (litBits (labelBits k State T)) (clauseAt tm x n T idx)

The decoder of the succinct tableau formula: for n < 2 T and a fixed prefix x of length at most n, a De Morgan circuit with code decoderCode tm (x, n, T) and at most sizeConst tm * (colBits T + timeBits T + x.length + 1) gates computes, from the bits of a clause number below 2 ^ clauseBits, the bits of the clause clauseAt tm x n T idx of Cslib.Circuits.Boolean.Tableau.succinctCNF: the label of each of its three literals in labelBits bits, least significant first, then its sign.