Documentation

CslibFrontier.Computability.Circuit.Boolean.Tableau.Succinct

The tableau formula on bit-field labels #

The Tseitin formula (CslibFrontier/Computability/Circuit/Boolean/Tseitin.lean) of the uniform tableau circuit of a multi-tape machine (CslibFrontier/Computability/Circuit/Boolean/Tableau/Basic.lean), written with variables that are labels made of fixed-width binary fields rather than wire numbers. Each clause is computed from its number by bit-field arithmetic (Cslib.Circuits.Boolean.Tableau.clauseAt), with no multiplication by the block size, so that a circuit of size linear in the field widths can decode it. This is the succinct tableau formula of the sketch of Williams, Theorem 6.1, p. 20: the clauses of a cell are the same for every cell, except that the block and the column enter the labels of their variables. The sketch first converts the machine to a single-tape one; this formula uses the multi-tape tableau directly.

A label is a two-bit tag followed by a payload (label = tag + 4 * payload):

A reference of the tableau (Ref), relative to the block and the column of its gate, becomes the label Ref.label: the block t or t - 1, the column c, c - 1, c + 1 or 2 T (0 for the global positions, which are not repeated across the columns), and the slot of the position. A clause number is j + 4 * (tag + 4 * payload): clause j < 3 of the gate of a constant or a position, the unit clause fixing an input, or (tag 3, payload 0) the unit clause fixing the output; every other number gives a tautology. The formula succinctCNF tm x n T lists the clauses of all numbers below 2 ^ clauseBits k State T.

The formula is satisfiable exactly when, on some input of length n extending x, the machine has written exactly [true] after T steps (satisfiable_succinctCNF_iff). The proof compares it with tseitinSatCNF of the tableau gate list, through the labelling of wires (wireLabel) and the inverse decoding of labels (wireOf); the labels of references agree with their resolved wire numbers (wireLabel_resolve, wireOf_label).

Main definitions #

Main results #

References #

Fields #

noncomputable def Cslib.Circuits.Boolean.Tableau.Loc.slot {k : ℕ} {State : Type} [Fintype State] (l : Loc k State) :

The slot of a position: its number among the positions of a block.

noncomputable def Cslib.Circuits.Boolean.Tableau.Loc.ofSlot {k : ℕ} {State : Type} [Fintype State] (s : ℕ) :
Option (Loc k State)

The position with a slot number, if any.

theorem Cslib.Circuits.Boolean.Tableau.Loc.slot_lt {k : ℕ} {State : Type} [Fintype State] (l : Loc k State) :
l.slot < Fintype.card (Loc k State)

Slots are below the number of positions.

@[simp]
theorem Cslib.Circuits.Boolean.Tableau.Loc.ofSlot_slot {k : ℕ} {State : Type} [Fintype State] (l : Loc k State) :

Decoding a slot gives its position.

noncomputable def Cslib.Circuits.Boolean.Tableau.slotBits (k : ℕ) (State : Type) [Fintype State] :

The width of the slot field.

The width of the column field, for the columns c ≤ 2 T.

The width of the time field, for the blocks t ≤ T.

theorem Cslib.Circuits.Boolean.Tableau.slot_lt_two_pow {k : ℕ} {State : Type} [Fintype State] (l : Loc k State) :
l.slot < 2 ^ slotBits k State

The slots fit in their field.

The columns fit in their field.

The blocks fit in their field.

Labels #

The label of the constant gate b: tag 0.

The label of the input i: tag 1.

noncomputable def Cslib.Circuits.Boolean.Tableau.posLabel (k : ℕ) (State : Type) [Fintype State] (T t c : ℕ) (l : Loc k State) :

The label of the position l of block t in column c: tag 2, and the slot, the column and the block in fields of widths slotBits k State, colBits T and the remaining high bits.

def Cslib.Circuits.Boolean.Tableau.Loc.labelCol {k : ℕ} {State : Type} [Fintype State] :
Loc k State → ℕ → ℕ

The column under which a position is labelled: 0 for the global positions, which do not depend on the column.

theorem Cslib.Circuits.Boolean.Tableau.Loc.offset_labelCol {k : ℕ} {State : Type} [Fintype State] (l : Loc k State) (T c : ℕ) :
offset T (l.labelCol c) l = offset T c l

Labelling a column does not change the offset of a position.

theorem Cslib.Circuits.Boolean.Tableau.Loc.colOK_labelCol {k : ℕ} {State : Type} [Fintype State] {l : Loc k State} {T c : ℕ} (hc : c < numCols T) :
ColOK T (l.labelCol c) l

The labelled column of a column of the window is admissible.

theorem Cslib.Circuits.Boolean.Tableau.Loc.labelCol_le {k : ℕ} {State : Type} [Fintype State] (l : Loc k State) (c : ℕ) :

The labelled column is at most the column.

noncomputable def Cslib.Circuits.Boolean.Tableau.Ref.label {k : ℕ} {State : Type} [Fintype State] (n T t c : ℕ) :
Ref k State → ℕ

The label of a reference from block t and column c: Ref.resolve with labels in place of wire numbers.

From labels to wires #

noncomputable def Cslib.Circuits.Boolean.Tableau.wireOf {k : ℕ} {State : Type} [Fintype State] (n T lab : ℕ) :

The wire with a label: inverts the labelling on the labels of wires.

@[simp]
theorem Cslib.Circuits.Boolean.Tableau.wireOf_constLabel {k : ℕ} {State : Type} [Fintype State] (n T : ℕ) (b : Bool) :
wireOf n T (constLabel b) = n + b.toNat

Decoding the label of a constant gives its wire.

@[simp]
theorem Cslib.Circuits.Boolean.Tableau.wireOf_inputLabel {k : ℕ} {State : Type} [Fintype State] (n T i : ℕ) :
wireOf n T (inputLabel i) = i

Decoding the label of an input gives its wire.

theorem Cslib.Circuits.Boolean.Tableau.wireOf_posLabel {k : ℕ} {State : Type} [Fintype State] {n T t c : ℕ} (l : Loc k State) (hc : c < 2 ^ colBits T) :
wireOf n T (posLabel k State T t c l) = wire n T t l c

Decoding the label of a position gives its wire.

From wires to labels #

noncomputable def Cslib.Circuits.Boolean.Tableau.wireLabel (k : ℕ) (State : Type) [Fintype State] (n T w : ℕ) :

The label of a wire of the tableau on n inputs: an input, a constant, or the position of a gate decoded from its number.

theorem Cslib.Circuits.Boolean.Tableau.wireLabel_of_lt {k : ℕ} {State : Type} [Fintype State] {n T w : ℕ} (hw : w < n) :
wireLabel k State n T w = inputLabel w

The label of an input wire.

theorem Cslib.Circuits.Boolean.Tableau.wireLabel_const {k : ℕ} {State : Type} [Fintype State] (n T : ℕ) (b : Bool) :
wireLabel k State n T (n + b.toNat) = constLabel b

The labels of the constant wires.

theorem Cslib.Circuits.Boolean.Tableau.wireLabel_wire {k : ℕ} {State : Type} [Fintype State] {n T t c : ℕ} {l : Loc k State} (hl : Loc.ColOK T c l) :
wireLabel k State n T (wire n T t l c) = posLabel k State T t c l

The label of the wire of a position is the label of the position.

Labels of references #

def Cslib.Circuits.Boolean.Tableau.Ref.InWindow {k : ℕ} {State : Type} [Fintype State] (n T c : ℕ) :
Ref k State → Prop

A reference reads a column of the window whenever its guard holds.

theorem Cslib.Circuits.Boolean.Tableau.wireLabel_resolve {k : ℕ} {State : Type} [Fintype State] {n T t c : ℕ} {r : Ref k State} (hr : Ref.InWindow n T c r) :
wireLabel k State n T (Ref.resolve n T t c r) = Ref.label n T t c r

The label of a reference is the label of its wire.

theorem Cslib.Circuits.Boolean.Tableau.wireOf_label {k : ℕ} {State : Type} [Fintype State] {n T t c : ℕ} {r : Ref k State} (hr : Ref.InWindow n T c r) :
wireOf n T (Ref.label n T t c r) = Ref.resolve n T t c r

Decoding the label of a reference gives its wire.

theorem Cslib.Circuits.Boolean.Tableau.table_inWindow {k : ℕ} {State : Type} [Fintype State] [DecidableEq State] {n T c : ℕ} (hc : c < numCols T) (tm : Turing.MultiTapeTM k Bool State) (l : Loc k State) :
match table tm l with | (fst, left, right) => Ref.InWindow n T c left ∧ Ref.InWindow n T c right

The references of the gates of the tableau read the window.

The clauses #

A clause that every assignment satisfies.

@[instance_reducible]
instance Cslib.Circuits.Boolean.Tableau.Loc.decidableColOK {k : ℕ} {State : Type} [Fintype State] (T c : ℕ) (l : Loc k State) :

Admissibility of a column is decidable.

noncomputable def Cslib.Circuits.Boolean.Tableau.posClause {k : ℕ} {State : Type} [Fintype State] [DecidableEq State] (tm : Turing.MultiTapeTM k Bool State) (n T t c : ℕ) (l : Loc k State) (j : Fin 3) :

Clause j of the gate at the position l of block t in column c, on labels: the initial constant in block 0, and otherwise the gate of table on the labels of its references.

noncomputable def Cslib.Circuits.Boolean.Tableau.outLabel (k : ℕ) (State : Type) [Fintype State] (T : ℕ) :

The label of the output wire: the output view [true] at time T.

noncomputable def Cslib.Circuits.Boolean.Tableau.clauseOf {k : ℕ} {State : Type} [Fintype State] [DecidableEq State] (tm : Turing.MultiTapeTM k Bool State) (x : List Bool) (n T j tag p : ℕ) :

The clause with the fields j, tag and p of its number j + 4 * (tag + 4 * p): clause j of the constant gate p (tag 0), the unit clause fixing input p to x[p] (tag 1, j = 0), clause j of the gate at the position whose slot, column and block are the fields of p (tag 2), or the unit clause fixing the output (tag 3, j = p = 0). Every other number gives a tautology.

noncomputable def Cslib.Circuits.Boolean.Tableau.clauseAt {k : ℕ} {State : Type} [Fintype State] [DecidableEq State] (tm : Turing.MultiTapeTM k Bool State) (x : List Bool) (n T idx : ℕ) :

The clause with number idx, from the fields of idx.

noncomputable def Cslib.Circuits.Boolean.Tableau.clauseBits (k : ℕ) (State : Type) [Fintype State] (T : ℕ) :

The width of a clause number: the clause and the tag, then the slot, the column and the block.

noncomputable def Cslib.Circuits.Boolean.Tableau.succinctCNF {k : ℕ} {State : Type} [Fintype State] [DecidableEq State] (tm : Turing.MultiTapeTM k Bool State) (x : List Bool) (n T : ℕ) :

The tableau formula on bit-field labels: the clauses of all numbers below 2 ^ clauseBits k State T, for the tableau of tm for T steps on n inputs, with the inputs i < x.length fixed to x[i] and the output fixed to true.

Clauses at their numbers #

theorem Cslib.Circuits.Boolean.Tableau.clauseAt_fields {k : ℕ} {State : Type} [Fintype State] [DecidableEq State] (tm : Turing.MultiTapeTM k Bool State) (x : List Bool) (n T : ℕ) {j tag : ℕ} (p : ℕ) (hj : j < 4) (htag : tag < 4) :
clauseAt tm x n T (j + 4 * (tag + 4 * p)) = clauseOf tm x n T j tag p

The clause of a number with the fields j, tag and p.

theorem Cslib.Circuits.Boolean.Tableau.fields_lt_clauseBits {k : ℕ} {State : Type} [Fintype State] {T j tag p : ℕ} (hj : j < 4) (htag : tag < 4) (hp : p < 2 ^ (slotBits k State + colBits T + timeBits T)) :
j + 4 * (tag + 4 * p) < 2 ^ clauseBits k State T

The numbers of the clauses with a payload of slotBits + colBits + timeBits bits are below 2 ^ clauseBits.

theorem Cslib.Circuits.Boolean.Tableau.clauseOf_pos {k : ℕ} {State : Type} [Fintype State] [DecidableEq State] (tm : Turing.MultiTapeTM k Bool State) (x : List Bool) {n T t c : ℕ} {l : Loc k State} (j : Fin 3) (ht : t ≤ T) (hl : Loc.ColOK T c l) :
clauseOf tm x n T (↑j) 2 (l.slot + 2 ^ slotBits k State * (c + 2 ^ colBits T * t)) = posClause tm n T t c l j

The clauses of a position.

theorem Cslib.Circuits.Boolean.Tableau.forall_eval_posClause_iff {k : ℕ} {State : Type} [Fintype State] [DecidableEq State] (tm : Turing.MultiTapeTM k Bool State) (σ : ℕ → Bool) (n T t c : ℕ) (l : Loc k State) :
(∀ (j : Fin 3), Logic.PL.Clause.eval σ (posClause tm n T t c l j) = true) ↔ σ (posLabel k State T t c l) = if t = 0 then initBit tm T c l else match table tm l with | (op, left, right) => op.value (σ (Ref.label n T t c left)) (σ (Ref.label n T t c right))

The clauses of a position hold exactly when its label carries the value of its gate.

theorem Cslib.Circuits.Boolean.Tableau.eval_clauseOf {k : ℕ} {State : Type} [Fintype State] [DecidableEq State] (tm : Turing.MultiTapeTM k Bool State) {x : List Bool} {n T : ℕ} {σ : ℕ → Bool} (hconst : ∀ (b : Bool), σ (constLabel b) = b) (hin : ∀ (i : ℕ) (hi : i < x.length), σ (inputLabel i) = x[i]) (hout : σ (outLabel k State T) = true) (hpos : ∀ t ≤ T, ∀ (c : ℕ) (l : Loc k State), Loc.ColOK T c l → σ (posLabel k State T t c l) = if t = 0 then initBit tm T c l else match table tm l with | (op, left, right) => op.value (σ (Ref.label n T t c left)) (σ (Ref.label n T t c right))) (j tag p : ℕ) :
Logic.PL.Clause.eval σ (clauseOf tm x n T j tag p) = true

Every clause holds under an assignment of labels that gives the constants their values, the fixed inputs the bits of x and the output true, and every position the value of its gate on the labels of its references.

Comparison with the Tseitin formula of the tableau #

theorem Cslib.Circuits.Boolean.Tableau.satisfiable_succinctCNF_iff_tseitin {k : ℕ} {State : Type} [Fintype State] [DecidableEq State] (tm : Turing.MultiTapeTM k Bool State) {n T : ℕ} (hn : n < 2 * T) {x : List Bool} (hx : x.length ≤ n) :
(succinctCNF tm x n T).Satisfiable ↔ (tseitinSatCNF x n (gates tm n T) (outWire k State n T)).Satisfiable

The tableau formula on labels is equisatisfiable with the Tseitin formula of the tableau with the same fixed inputs and output.

The tableau formula on labels is satisfiable exactly when, on some input of length n extending x, the machine tm has written exactly [true] after T steps, whether or not it has halted, for n < 2 T and x of length at most n.

Size #

theorem Cslib.Circuits.Boolean.Tableau.length_of_mem_succinctCNF {k : ℕ} {State : Type} [Fintype State] [DecidableEq State] (tm : Turing.MultiTapeTM k Bool State) {x : List Bool} {n T : ℕ} {C : Logic.PL.Clause ℕ} (hC : C ∈ succinctCNF tm x n T) :

Every clause of the formula has three literals.

theorem Cslib.Circuits.Boolean.Tableau.length_succinctCNF {k : ℕ} {State : Type} [Fintype State] [DecidableEq State] (tm : Turing.MultiTapeTM k Bool State) (x : List Bool) (n T : ℕ) :
List.length (succinctCNF tm x n T) = 2 ^ clauseBits k State T

The formula has 2 ^ clauseBits k State T clauses.

noncomputable def Cslib.Circuits.Boolean.Tableau.labelBits (k : ℕ) (State : Type) [Fintype State] (T : ℕ) :

The width of a label: the tag, then the slot, the column and the block.

theorem Cslib.Circuits.Boolean.Tableau.posLabel_lt {k : ℕ} {State : Type} [Fintype State] {T t c : ℕ} (l : Loc k State) (hc : c < 2 ^ colBits T) (ht : t ≤ T) :
posLabel k State T t c l < 2 ^ labelBits k State T

The labels of positions of blocks t ≤ T fit in labelBits bits.

theorem Cslib.Circuits.Boolean.Tableau.inputLabel_lt {k : ℕ} {State : Type} [Fintype State] {T i : ℕ} (hi : i < 2 * T) :
inputLabel i < 2 ^ labelBits k State T

The labels of the inputs i < 2 T fit in labelBits bits.

theorem Cslib.Circuits.Boolean.Tableau.constLabel_lt {k : ℕ} {State : Type} [Fintype State] {T : ℕ} (hT : 1 ≤ T) (b : Bool) :
constLabel b < 2 ^ labelBits k State T

The labels of the constants fit in labelBits bits, for 1 ≤ T.

theorem Cslib.Circuits.Boolean.Tableau.Ref.label_lt {k : ℕ} {State : Type} [Fintype State] {n T t c : ℕ} (hn : n < 2 * T) (ht : t ≤ T) {r : Ref k State} (hr : InWindow n T c r) :
label n T t c r < 2 ^ labelBits k State T

The labels of the references of a gate in a column of the window fit in labelBits bits.

theorem Cslib.Circuits.Boolean.Tableau.lt_two_pow_labelBits_of_mem_vars {k : ℕ} {State : Type} [Fintype State] [DecidableEq State] (tm : Turing.MultiTapeTM k Bool State) {n T : ℕ} (hn : n < 2 * T) {x : List Bool} (hx : x.length ≤ n) {v : ℕ} (hv : v ∈ (succinctCNF tm x n T).vars) :
v < 2 ^ labelBits k State T

Every variable of the formula is below 2 ^ labelBits k State T, for n < 2 T: labels have labelBits k State T bits.