Skip to content

Cook-Levin: generator machine for the transition clause families

58 fully proved

Draft C3 variable layout

StructureVariable layout of the transition clauses#✓fully proved

A layout consists of four natural numbers derived from the verifier: the size \(A\) of the label/state block of a row, the number \(K\) of stacks, the number \(g\) of symbol codes (code \(0\) is the empty cell), and the window depth \(d\).

structure Layout where
  /-- Size of the label/state block of a row. -/
  A : ℕ
  /-- Number of stacks. -/
  KK : ℕ
  /-- Number of symbol codes (code `0` is the empty cell). -/
  g : ℕ
  /-- Window depth. -/
  d : ℕ
Used by 186
Used byExplicit time bound of the accept generator · The accept generator's time bound on the uniform layout · Constant of the accept generator's time bound · The accept family of a layout · Time bound of the accept generator for a concrete machine · Correctness of the accept generator, with its explicit time bound · Polynomial time bound of the accept generator · The accept generator as a finite multi-stack machine · Literals of an accept cell clause · Run of the accept cell chain · One clause of the accept generator · Literals of an accept code clause · Run of the code-clause chain of the accept generator · Literal routine of the accept generator · Run of the literal routine of the accept generator · Cost of the precomputation of the accept generator · Counters after the precomputation of the accept generator · Run of the accept generator's precomputation · Generator machine for the accept family · Loop body of the cell-shift generator · Counter state at the start of a block · Encoded blocks of one situation · Encoded blocks of one time step · Counter state of a loop body · One clause of the cell-shift generator · Constant offset of a literal in a block · Correctness of the shift generator on one block · Correctness of the shift generator on the situation chain · First cell variable of a block · Correctness of the shift generator on the stack chain of a situation · Labels of the shift generator · Literal routine of the cell-shift generator · One literal routine of the cell-shift generator · The literal routines of one clause of the cell-shift generator · One iteration of the overflow loop of the cell-shift generator · Literals of an overflow clause · Literal positions of an overflow clause · Literals of a pushed-fill clause · Literal positions of a pushed-fill clause · The pushed-fill chain of the cell-shift generator · Cost of the precomputation of the cell-shift generator · Counters after the precomputation of the cell-shift generator · The cell-shift generator · The decrement chain takes \(n\) steps · One iteration of the in-range loop of the cell-shift generator · The shift block of a situation and a stack · Explicit time bound of the shift generator · Time bound of the shift generator on uniform layouts · Constant of the shift-generator time bound · The cell-shift clause family · Literals of an in-range shift clause · The shift-generator time bound as a polynomial · Literal positions of an in-range shift clause · Correctness of the shift generator, with its explicit time bound · Polynomial time bound for the shift generator · The cell-shift generator as a finite stack machine · Block stages of the cell-shift generator · Step budget for one time step of the shift generator · One iteration of the time loop of the shift generator · Well-formed situation tables for the cell-shift family · The in-range chain of the cell-shift generator · One phase-loop iteration of the initial-row generator · Run of one clause (initial-row generator) · Codes of input symbols · Certificate clauses of the initial row (I4) · Start-code clause of the initial row (I1) · Input clauses of the initial row (I3) · Row-0 clauses for the other stacks · Row-0 prefix clauses · Row-0 tail clauses · The I3 loop on the whole input · The I3 loop · Counter part of one I3 iteration · Time bound of the init generator · Time bound of the init generator at uniform parameters · Constant of the init generator's time bound · The init family · The init family of an encoding is a layout-level init family · The init generator at the stack cap · Time and output of the init generator for an encoding · Correctness of the init generator, with its explicit time bound · Polynomial time bound for the init generator · The init generator as a finite multi-stack machine · The initial-row generator · Labels of the initial-row generator for a layout · The literal routine of the initial-row generator · Run of one literal routine (initial-row generator) · Run of the literal routines of a clause (initial-row generator) · One phase loop · Step bound for the precomputation · Counters after the precomputation · Run of the precomputation (initial-row generator) · The counter part of the initial-row generator · Row-0 cells fit in the variable range · Empty-cell variable of the initial row · Resting counter values in the transition-family time loop · Encoded transition clauses of one time step · Boundary before a literal of a transition clause · Step bound for one time-loop iteration of the transition-family generator · Index of a cell variable in the transition-family layout · Step bound for one clause of the transition-family generator · Run of the transition-family generator on one clause · Constant offset of a literal position · The transition clause family · Time bound of the generator · Uniform bound on the generator's time · Constant of the generator's time bound · Correctness of the clause-family generator · Time-bound polynomial of the clause-family generator · Correctness of the clause-family generator, with its explicit time bound · Polynomial time bound for the clause-family generator · The clause-family generator as a finite stack machine · Stack index of a literal in a transition clause · Row offset of a literal in a transition clause · Per-literal time bound of the transition-clause generator · Literal routine of the transition-clause generator · Position of a literal in a transition clause · Run of one literal routine (transition-clause generator) · Literals of a transition clause · Run of the literal routines of a clause (transition-clause generator) · Time-loop invariant of the transition-family generator · Number of literals of a transition clause · Number of variables of the transition-clause formula · Generator output after part of the time loop · Step bound for the transition-clause generator's precomputation · Generator machine for the transition clause families · Variables per time step · Polarity of a transition-clause literal · One iteration of the time loop · Uniform layout · Well-formed situation tables for the transition clauses · Index of a label/state variable · The reduction machine halts with the emitted formula · The reduction machine · Clause layout of a machine encoding · Time bound of the shift generator on the tables of a machine · The situation-definition tables of a machine are well formed · The cell-shift tables of a machine are well formed · The transition tables of a machine are well formed · In-range shift forcing (L1) · Transition clauses force the next label · Transition clauses force the next label, stack-and-depth form · Overflow forcing · Pushed-fill forcing · L2 (S-definition, positive) · Update forcing (positive) · The all-true assignment violates the accept family · The init family is faithful with positive literals · Variables of rows up to the time bound · The all-true assignment satisfies the transition, shift and init families · Completeness of the accept family · Transition families with a run-literal head are satisfied by the run · Completeness of the init family · Situation variables lie in the label/state block · The run assignment satisfies the cell-shift family · Encoded one-hot clauses of one stack at one time step · Encoded one-hot clauses of one time step · Generator run for one cell · One clause of the one-hot generator · One stack iteration of the one-hot generator · One-hot generator: the routine for one literal · Run of one literal routine (one-hot generator) · Run of the literal routines of a clause (one-hot generator) · Explicit time bound of the one-hot generator · Time bound of the one-hot generator on a uniform layout · Constant of the one-hot time bound · The one-hot cell family · The one-hot time bound as a polynomial · Correctness of the one-hot generator, with its explicit time bound · Polynomial time bound for the one-hot generator · The one-hot generator as a finite multi-stack machine · Step budget of the one-hot precomputation · Counter values after the one-hot precomputation · The one-hot generator · Generator run over one row of at-most-one clauses · Generator run over the first rows and the at-least-one clause · Step budget for one time step of the one-hot generator · Generator run over one time step · The host on the real generators of a machine · The assembled generator, after the precomputation · The full program on the real generators · The composed machine, raw input to formula · Polynomial time bound of the composed machine · The full machine as a finite multi-stack Turing machine · Initial configuration of the full machine · Every clause of the Cook–Levin formula has one slot per variable

DefinitionVariables per time step#✓fully proved

For a layout with label/state block size \(A\), \(K\) stacks and \(g\) symbol codes, and a height \(H\), the row width is \(W = A + K \cdot (H \cdot g)\): the label/state block of \(A\) variables, followed by \(K \cdot H \cdot g\) cell variables.

def rowW (H : ℕ) : ℕ := L.A + L.KK * (H * L.g)
Uses 1 · Used by 55
Used byThe accept generator's time bound on the uniform layout · Correctness of the accept generator, with its explicit time bound · Polynomial time bound of the accept generator · Cost of the precomputation of the accept generator · Counters after the precomputation of the accept generator · Run of the accept generator's precomputation · Counter state of a loop body · Correctness of the shift generator on one block · First cell variable of a block · One iteration of the overflow loop of the cell-shift generator · The pushed-fill chain of the cell-shift generator · Cost of the precomputation of the cell-shift generator · Counters after the precomputation of the cell-shift generator · One iteration of the in-range loop of the cell-shift generator · Time bound of the shift generator on uniform layouts · Correctness of the shift generator, with its explicit time bound · Polynomial time bound for the shift generator · One iteration of the time loop of the shift generator · The in-range chain of the cell-shift generator · Time bound of the init generator at uniform parameters · Correctness of the init generator, with its explicit time bound · Polynomial time bound for the init generator · Counters after the precomputation · Run of the precomputation (initial-row generator) · Row-0 cells fit in the variable range · Resting counter values in the transition-family time loop · Step bound for one time-loop iteration of the transition-family generator · Index of a cell variable in the transition-family layout · Run of the transition-family generator on one clause · Uniform bound on the generator's time · Correctness of the clause-family generator, with its explicit time bound · Polynomial time bound for the clause-family generator · Per-literal time bound of the transition-clause generator · Run of the literal routines of a clause (transition-clause generator) · Time-loop invariant of the transition-family generator · Number of variables of the transition-clause formula · Step bound for the transition-clause generator's precomputation · One iteration of the time loop · Index of a label/state variable · The all-true assignment violates the accept family · The init family is faithful with positive literals · Variables of rows up to the time bound · The all-true assignment satisfies the transition, shift and init families · Completeness of the accept family · Transition families with a run-literal head are satisfied by the run · Completeness of the init family · The run assignment satisfies the cell-shift family · One stack iteration of the one-hot generator · Time bound of the one-hot generator on a uniform layout · Correctness of the one-hot generator, with its explicit time bound · Polynomial time bound for the one-hot generator · Step budget of the one-hot precomputation · Counter values after the one-hot precomputation · Step budget for one time step of the one-hot generator · Generator run over one time step

DefinitionNumber of variables of the transition-clause formula#✓fully proved

For a layout \(L\) and bounds \(T\) and \(H\), the number of variables is \(V = (T + 1) \cdot W\), where \(W\) is the number of variables per time step at height \(H\).

def numVars (T H : ℕ) : ℕ := (T + 1) * L.rowW H
Uses 2 · Used by 86
Used byExplicit time bound of the accept generator · The accept generator's time bound on the uniform layout · The accept family of a layout · Correctness of the accept generator, with its explicit time bound · Polynomial time bound of the accept generator · Counters after the precomputation of the accept generator · Counter state of a loop body · Correctness of the shift generator on one block · Correctness of the shift generator on the situation chain · Correctness of the shift generator on the stack chain of a situation · One iteration of the overflow loop of the cell-shift generator · The pushed-fill chain of the cell-shift generator · Counters after the precomputation of the cell-shift generator · One iteration of the in-range loop of the cell-shift generator · The shift block of a situation and a stack · Time bound of the shift generator on uniform layouts · Correctness of the shift generator, with its explicit time bound · Polynomial time bound for the shift generator · Step budget for one time step of the shift generator · One iteration of the time loop of the shift generator · The in-range chain of the cell-shift generator · Certificate clauses of the initial row (I4) · Start-code clause of the initial row (I1) · Input clauses of the initial row (I3) · Row-0 clauses for the other stacks · Row-0 prefix clauses · Row-0 tail clauses · Time bound of the init generator · Time bound of the init generator at uniform parameters · The init family of an encoding is a layout-level init family · Correctness of the init generator, with its explicit time bound · Polynomial time bound for the init generator · Counters after the precomputation · Row-0 cells fit in the variable range · Resting counter values in the transition-family time loop · Encoded transition clauses of one time step · Boundary before a literal of a transition clause · Step bound for one clause of the transition-family generator · Run of the transition-family generator on one clause · The transition clause family · Uniform bound on the generator's time · Correctness of the clause-family generator, with its explicit time bound · Polynomial time bound for the clause-family generator · Per-literal time bound of the transition-clause generator · Run of the literal routines of a clause (transition-clause generator) · Time-loop invariant of the transition-family generator · One iteration of the time loop · In-range shift forcing (L1) · Transition clauses force the next label · Overflow forcing · Pushed-fill forcing · Certificate clauses of the init family · Start-code clause of the init family · Input clauses of the init family · Empty-stack clauses of the init family · Prefix clauses of the init family · Init semantics · Length-bound clauses of the init family · Accept-cell clauses · Accept-cell clauses pin the top output symbol · Accept-code clauses · Accept-code clauses pin the (label, state) code · The all-true assignment violates the accept family · The init family is faithful with positive literals · Variables of rows up to the time bound · The all-true assignment satisfies the transition, shift and init families · Completeness of the accept family · Completeness of the five clause families · Transition families with a run-literal head are satisfied by the run · Completeness of the init family · The assignment of the real run's literals · Faithful clauses with a literal agreeing with the real run are satisfied · Unit clauses on run literals are satisfied · The run assignment satisfies the cell-shift family · The five Cook–Levin clause families are satisfiable iff some certificate is accepted · Encoded one-hot clauses of one stack at one time step · One stack iteration of the one-hot generator · Time bound of the one-hot generator on a uniform layout · The one-hot cell family · Correctness of the one-hot generator, with its explicit time bound · Polynomial time bound for the one-hot generator · Counter values after the one-hot precomputation · Step budget for one time step of the one-hot generator · Generator run over one time step · Every clause of the Cook–Levin formula has one slot per variable · Every NP problem reduces to binary-index CNF-SAT

DefinitionIndex of a label/state variable#✓fully proved

For height \(H\), time \(t\) and \(a \in \mathbb{N}\), the index of label/state variable \(a\) at time \(t\) is \(t \cdot W + a\), where \(W\) is the row width (variables per time step) at height \(H\). It is used for \(a < A\), the size of the label/state block.

def xIdx (H t a : ℕ) : ℕ := t * L.rowW H + a
Uses 2 · Used by 51
Used byCorrectness of the accept generator, with its explicit time bound · Literals of an accept code clause · One iteration of the overflow loop of the cell-shift generator · Literals of an overflow clause · Literal positions of an overflow clause · Literals of a pushed-fill clause · Literal positions of a pushed-fill clause · The pushed-fill chain of the cell-shift generator · Literals of an in-range shift clause · Literal positions of an in-range shift clause · The in-range chain of the cell-shift generator · Start-code clause of the initial row (I1) · Correctness of the init generator, with its explicit time bound · Run of the transition-family generator on one clause · Position of a literal in a transition clause · Run of the literal routines of a clause (transition-clause generator) · In-range shift forcing (L1) · Positive core of the shift step (L2⁺) · Exact shift step (L2) · Exact shift step on a real run (L3) · Positive shift step on a real run (L3⁺) · The code of a configuration holds in a row · Transition clauses force the next label · Transition clauses force the next label, stack-and-depth form · Overflow forcing · Overflow cells of the next row hold the table value · Overflow cells of the next row on a real run · Pushed-fill forcing · Pushed-fill forcing for a good configuration · Pushed-fill forcing on a real run · L2 (S-definition, positive) · L3 (S-definition, real run) · Update forcing (positive) · Update forcing, real run · Cell literals propagate one step along the real run · Start-code clause of the init family · Init semantics · Accept-code clauses · Accept-code clauses pin the (label, state) code · The all-true assignment violates the accept family · The init family is faithful with positive literals · The all-true assignment satisfies the transition, shift and init families · Completeness of the accept family · Transition families with a run-literal head are satisfied by the run · Completeness of the init family · Row-0 cells of the start configuration are run literals · The real run's literals · The run assignment satisfies the situation-definition family · The run assignment satisfies the cell-shift family · The run assignment satisfies the update family · Every clause of the Cook–Levin formula has one slot per variable

DefinitionIndex of a cell variable in the transition-family layout#✓fully proved

For a layout \(L\) with label/state block size \(A\), \(K\) stacks and \(g\) symbol codes, and natural numbers \(H\), \(t\), \(k\), \(j\), \(x\), the variable for stack \(k\), depth \(j\) from the top and symbol code \(x\) at time \(t\) has index \(tW + A + (kH + j)g + x\), where \(W = A + KHg\) is the number of variables per time step. It is meant for \(k < K\), \(j < H\) and \(x < g\) but is defined for all values.

def cIdx (H t k j x : ℕ) : ℕ := t * L.rowW H + L.A + (k * H + j) * L.g + x
Uses 2 · Used by 63
Used byCorrectness of the accept generator, with its explicit time bound · Literals of an accept cell clause · Counters after the precomputation of the accept generator · One iteration of the overflow loop of the cell-shift generator · Literals of an overflow clause · Literal positions of an overflow clause · Literals of a pushed-fill clause · Literal positions of a pushed-fill clause · The pushed-fill chain of the cell-shift generator · Literals of an in-range shift clause · Literal positions of an in-range shift clause · The in-range chain of the cell-shift generator · Certificate clauses of the initial row (I4) · Input clauses of the initial row (I3) · Row-0 clauses for the other stacks · The init family of an encoding is a layout-level init family · Correctness of the init generator, with its explicit time bound · Counters after the precomputation · Empty-cell variable of the initial row · Run of the transition-family generator on one clause · Position of a literal in a transition clause · Run of the literal routines of a clause (transition-clause generator) · Cell block of a row equal to an array · Cell literals of an array hold in a row · In-range shift forcing (L1) · Positive core of the shift step (L2⁺) · Exact shift step (L2) · Exact shift step on a real run (L3) · Positive shift step on a real run (L3⁺) · Transition clauses force the next label · Transition clauses force the next label, stack-and-depth form · Overflow forcing · Overflow cells of the next row hold the table value · Overflow cells of the next row on a real run · Pushed-fill forcing · Pushed-fill forcing for a good configuration · Pushed-fill forcing on a real run · L2 (S-definition, positive) · Composition with the shift family · Update forcing (positive) · Cell literals propagate one step along the real run · Certificate clauses of the init family · Input clauses of the init family · Empty-stack clauses of the init family · Init semantics · Index of the empty-cell variable of the input stack · Accept-cell clauses · Accept-cell clauses pin the top output symbol · The init family is faithful with positive literals · The all-true assignment satisfies the transition, shift and init families · Completeness of the accept family · Transition families with a run-literal head are satisfied by the run · Completeness of the init family · Row-0 cells of the start configuration are run literals · The real run's literals · The run assignment satisfies the situation-definition family · The run assignment satisfies the cell-shift family · The run assignment satisfies the update family · Encoded one-hot clauses of one stack at one time step · One stack iteration of the one-hot generator · The one-hot cell family · Correctness of the one-hot generator, with its explicit time bound · Every clause of the Cook–Levin formula has one slot per variable

DefinitionNumber of literals of a transition clause#✓fully proved

For a layout \(L\) with \(KK\) stacks and window depth \(d\), a label-transition clause has \(KK \cdot d + 2\) literals: the current label, the \(KK \cdot d\) window cells and the next label.

def nLits : ℕ := L.KK * L.d + 2
Uses 1 · Used by 29
Used byBoundary before a literal of a transition clause · Step bound for one clause of the transition-family generator · Run of the transition-family generator on one clause · Uniform bound on the generator's time · Correctness of the clause-family generator · Correctness of the clause-family generator, with its explicit time bound · Polynomial time bound for the clause-family generator · The clause-family generator as a finite stack machine · Literal routine of the transition-clause generator · Run of one literal routine (transition-clause generator) · Literals of a transition clause · Run of the literal routines of a clause (transition-clause generator) · Generator machine for the transition clause families · Polarity of a transition-clause literal · One iteration of the time loop · The reduction machine halts with the emitted formula · The reduction machine · Time bound of the situation-definition generator on the tables of a machine · Time bound of the transition-clause generator on the tables of a machine · Transition clauses force the next label · The all-true assignment satisfies the transition, shift and init families · Transition families with a run-literal head are satisfied by the run · The host on the real generators of a machine · The assembled generator, after the precomputation · The full program on the real generators · The composed machine, raw input to formula · Polynomial time bound of the composed machine · The full machine as a finite multi-stack Turing machine · Initial configuration of the full machine

The clause family (pure specification)

DefinitionPosition of a literal in a transition clause#✓fully proved

Fix a layout with \(K\) stacks and window depth \(d\), a height bound \(H\), and tables giving for each situation \(i\) a current label \(a(i)\), a next label \(a'(i)\) and window symbol codes \(w(i, k, r)\). The position of literal \(j\) of clause \((t, i)\) is: for \(j = 0\), the index of the label/state variable \(a(i)\) at time \(t\); for \(1 \le j \le Kd\), writing \(j - 1 = kd + r\) with \(r < d\), the index of the cell variable for stack \(k\), depth \(r\) from the top and symbol code \(w(i, k, r)\) at time \(t\); for \(j > Kd\), the index of the label/state variable \(a'(i)\) at time \(t + 1\).

The literals of a clause are numbered \(0, \dots, Kd + 1\), so the last case is the next label.

def litPos (H t i j : ℕ) : ℕ :=
  if j = 0 then L.xIdx H t (la i)
  else if j ≤ L.KK * L.d then
    L.cIdx H t ((j - 1) / L.d) ((j - 1) % L.d) (wa i ((j - 1) / L.d) ((j - 1) % L.d))
  else L.xIdx H (t + 1) (na i)
Uses 3 · Used by 7

DefinitionLiterals of a transition clause#✓fully proved

For a layout \(L\) with \(KK\) stacks and window depth \(d\), tables \(la\), \(na\), \(wa\), a height \(H\), a time \(t\) and a situation \(i\), the literals of clause \((t, i)\) form the list of pairs \((p_j, b_j)\) for \(j = 0, 1, \dots, n - 1\), where \(n = KK \cdot d + 2\) is the number of literals, \(p_j\) is the position of literal \(j\) of clause \((t, i)\), and the polarity \(b_j\) is true exactly when \(j = n - 1\). So every literal is negative except the last one, the next label.

def lits (H t i : ℕ) : List (ℕ × Bool) :=
  (List.range L.nLits).map fun j => (litPos L la na wa H t i j, decide (j = L.nLits - 1))
Uses 3 · Used by 10

DefinitionDense clause from a list of literals#✓fully proved

Given \(V \in \mathbb{N}\) and a list \(\ell\) of pairs \((p, b)\) of a variable index \(p\) and a sign \(b\), the dense clause over \(V\) variables has, for each \(v < V\), slot \(v\) equal to the literal \(x_v\) if the first pair in \(\ell\) with index \(v\) is \((v, \mathrm{true})\), the literal \(\neg x_v\) if it is \((v, \mathrm{false})\), and empty if \(\ell\) has no pair with index \(v\). Pairs with index at least \(V\) are ignored.

def denseClause (V : ℕ) (ls : List (ℕ × Bool)) : Clause :=
  (List.range V).map fun v => ls.lookup v
Uses 1 · Used by 68
Statement usesDense clause
Used byThe accept family of a layout · Correctness of the accept generator, with its explicit time bound · Run of the accept cell chain · One clause of the accept generator · Run of the code-clause chain of the accept generator · One clause of the cell-shift generator · Correctness of the shift generator on one block · One iteration of the overflow loop of the cell-shift generator · The pushed-fill chain of the cell-shift generator · One iteration of the in-range loop of the cell-shift generator · The shift block of a situation and a stack · The in-range chain of the cell-shift generator · One phase-loop iteration of the initial-row generator · Run of one clause (initial-row generator) · Dense clauses of positive literals depend only on their positions · Certificate clauses of the initial row (I4) · Start-code clause of the initial row (I1) · Input clauses of the initial row (I3) · Row-0 clauses for the other stacks · Row-0 prefix clauses · Row-0 tail clauses · The I3 loop on the whole input · The I3 loop · The init family of an encoding is a layout-level init family · Correctness of the init generator, with its explicit time bound · One phase loop · Encoded transition clauses of one time step · Run of the transition-family generator on one clause · Encoding a dense clause block by block · The transition clause family · Correctness of the clause-family generator, with its explicit time bound · One iteration of the time loop · L0 (a satisfied dense clause has a satisfied listed literal) · In-range shift forcing (L1) · Transition clauses force the next label · Overflow forcing · Pushed-fill forcing · Certificate clauses of the init family · Start-code clause of the init family · Input clauses of the init family · Empty-stack clauses of the init family · Prefix clauses of the init family · Init semantics · Length-bound clauses of the init family · Positive dense unit clauses force their variable · Accept-cell clauses · Accept-cell clauses pin the top output symbol · Accept-code clauses · Accept-code clauses pin the (label, state) code · Exact clause semantics · Faithful dense clause family · Faithful dense clause family with positive literals · The init family is faithful with positive literals · The all-true assignment satisfies a faithful clause with a positive literal · The all-true assignment satisfies the transition, shift and init families · Completeness of the accept family · Transition families with a run-literal head are satisfied by the run · Completeness of the init family · Faithful clauses with a literal agreeing with the real run are satisfied · Unit clauses on run literals are satisfied · The run assignment satisfies the cell-shift family · One-hot clauses of a cell · Generator run for one cell · One clause of the one-hot generator · Generator run over one row of at-most-one clauses · At-most-one clauses of the first rows of a cell · Generator run over the first rows and the at-least-one clause · Every clause of the Cook–Levin formula has one slot per variable

DefinitionThe transition clause family#✓fully proved

Fix a layout with label block size \(A\), \(K\) stacks, \(g\) symbol codes and window depth \(d\), tables \(\mathrm{la}, \mathrm{na} : \mathbb{N} \to \mathbb{N}\) and \(\mathrm{wa} : \mathbb{N} \to \mathbb{N} \to \mathbb{N} \to \mathbb{N}\), and \(T, H, N \in \mathbb{N}\). Let \(W = A + KHg\), let \(X[t, a]\) be the variable \(tW + a\), and let \(C[t, k, j, x]\) be the variable \(tW + A + (kH + j)g + x\). The family is the CNF formula that lists, for each time \(t < T\) and within it each situation \(i < N\), the dense clause over \((T + 1)W\) variables built from the literal list \(\neg X[t, \mathrm{la}(i)]\), then \(\neg C[t, k, j, \mathrm{wa}(i, k, j)]\) for \(k < K\) and \(j < d\) in lexicographic order, then \(X[t + 1, \mathrm{na}(i)]\).

def family (T H N : ℕ) : CNF :=
  (List.range T).flatMap fun t =>
    (List.range N).map fun i => denseClause (L.numVars T H) (lits L la na wa H t i)
Uses 6 · Used by 31
Used byCorrectness of the clause-family generator · Correctness of the clause-family generator, with its explicit time bound · Polynomial time bound for the clause-family generator · Time bound of the situation-definition generator on the tables of a machine · Time bound of the transition-clause generator on the tables of a machine · Transition clauses force the next label · Transition clauses force the next label, stack-and-depth form · L2 (S-definition, positive) · L3 (S-definition, real run) · Composition with the shift family · Update forcing (positive) · Update forcing, real run · Cell literals propagate one step along the real run · One-step invariant at the stack cap · One-step invariant · Row induction at the stack cap · Run tracking from the init obligation · Row-\(t\) induction · Satisfying assignments yield accepting runs · A satisfying assignment tracks a certified run · The all-true assignment satisfies the transition, shift and init families · No accepting certificate, no satisfying assignment · Completeness of the five clause families · Transition families with a run-literal head are satisfied by the run · The run assignment satisfies the situation-definition family · The run assignment satisfies the update family · The five Cook–Levin clause families are satisfiable iff some certificate is accepted · The formula emitted by the host · Correctness of the assembled formula · The assembled generator, after the precomputation · Every clause of the Cook–Levin formula has one slot per variable

Block decomposition of a dense clause

DefinitionGap encoding of a dense clause#✓fully proved

For a starting slot \(m\), a list \(\ell\) of literals \((p, b)\) (variable index \(p\), sign \(b\)) and a number of variables \(V\), the gap encoding of \(\ell\) from slot \(m\) to \(V\) is defined by recursion on \(\ell\). For the empty list it is \(V - m\) copies of the absent-slot block \(01\). For a list whose first literal is \((p, b)\) and whose remaining literals form the list \(r\), it is \(p - m\) copies of \(01\), then the two-bit slot encoding of the literal with sign \(b\) (the bit \(1\) followed by the negation of \(b\)), then the gap encoding of \(r\) from slot \(p + 1\) to \(V\). Subtraction is truncated at \(0\).

When the positions in \(\ell\) are strictly increasing, at least \(m\) and less than \(V\), this is the encoding of the slots \(m, \dots, V - 1\) of the dense clause over \(V\) variables with literals \(\ell\).

def gapEnc : ℕ → List (ℕ × Bool) → ℕ → List Bool
  | lo, [], V => rep [false, true] (V - lo)
  | lo, (p, b) :: r, V => rep [false, true] (p - lo) ++ encodeSlot (some b) ++ gapEnc (p + 1) r V
Uses 2 · Used by 11

DefinitionIncreasing literal positions#✓fully proved

For \(\mathit{lo}, V \in \mathbb{N}\), a list of literals \((p_1, b_1), \dots, (p_n, b_n)\) with positions \(p_k \in \mathbb{N}\) and signs \(b_k\) has increasing literal positions from \(\mathit{lo}\) below \(V\) when \(\mathit{lo} \le p_1 < p_2 < \dots < p_n < V\); for the empty list (\(n = 0\)) the condition is \(\mathit{lo} \le V\).

def Inc : ℕ → List (ℕ × Bool) → ℕ → Prop
  | lo, [], V => lo ≤ V
  | lo, (p, _) :: r, V => lo ≤ p ∧ Inc (p + 1) r V
Used by 18

TheoremLowering the lower bound keeps a literal list increasing#✓fully proved

For natural numbers \(lo' \le lo\) and \(V\) and a list \(ls\) of literals, if the positions in \(ls\) are strictly increasing, at least \(lo\) and below \(V\) (with \(lo \le V\) if \(ls\) is empty), then the same holds with \(lo'\) in place of \(lo\).

theorem Inc.mono_lo {lo lo' : ℕ} {ls : List (ℕ × Bool)} {V : ℕ} (h : lo' ≤ lo) (hi : Inc lo ls V) :
    Inc lo' ls V
Uses 1 · Used by 3

TheoremEncoding a dense clause block by block#✓fully proved

Let \(\ell = [(p_1, b_1), \dots, (p_n, b_n)]\) be a list of literals with \(p_1 < p_2 < \dots < p_n < V\). Then the bit encoding of the dense clause over \(V\) variables with literals \(\ell\) is the gap encoding of \(\ell\) from slot \(0\) to \(V\), followed by the clause terminator \(00\).

theorem encodeClause_denseClause {ls : List (ℕ × Bool)} {V : ℕ} (h : Inc 0 ls V) :
    encodeClause (denseClause V ls) = gapEnc 0 ls V ++ [false, false]
Uses 7 · Used by 5

TheoremShifting the start of a gap encoding#✓fully proved

Let \(m \le m'\) and let \(\ell = [(p_1, b_1), \dots, (p_n, b_n)]\) be a list of literals with \(m' \le p_1 < \dots < p_n < V\) (if \(\ell\) is empty, require \(m' \le V\)). Then the gap encoding of \(\ell\) from slot \(m\) to \(V\) is \(m' - m\) copies of the absent-slot block \(01\) followed by the gap encoding of \(\ell\) from slot \(m'\) to \(V\).

theorem gapEnc_shift {lo lo' : ℕ} {ls : List (ℕ × Bool)} {V : ℕ} (hlo : lo ≤ lo')
    (h : Inc lo' ls V) : gapEnc lo ls V = rep [false, true] (lo' - lo) ++ gapEnc lo' ls V
Uses 4 · Used by 8

The literal positions are strictly increasing

TheoremSuccessor of a number with a non-maximal remainder#✓fully proved

Let \(c\) and \(d\) be natural numbers with \(0 < d\) and \((c \bmod d) + 1 < d\). Then \(\lfloor (c + 1) / d \rfloor = \lfloor c / d \rfloor\) and \((c + 1) \bmod d = (c \bmod d) + 1\).

theorem div_mod_succ_of_lt {c d : ℕ} (hd : 0 < d) (h : c % d + 1 < d) :
    (c + 1) / d = c / d ∧ (c + 1) % d = c % d + 1
Used by 4

TheoremIncreasing literal sequences#✓fully proved

Let \(f\) assign to each \(j \in \mathbb{N}\) a literal \(f(j) = (p_j, b_j)\) with position \(p_j \in \mathbb{N}\), and let \(m, V \in \mathbb{N}\). Suppose \(p_j < p_{j+1}\) whenever \(j + 1 < m\), and \(p_j < V\) when \(j + 1 = m\). Then for all \(n, a, \mathit{lo} \in \mathbb{N}\) with \(a + n = m\) such that \(\mathit{lo} \le V\) if \(n = 0\) and \(\mathit{lo} \le p_a\) if \(n > 0\), the list \(f(a), f(a + 1), \dots, f(a + n - 1)\) has increasing literal positions from \(\mathit{lo}\) below \(V\).

theorem inc_of_mono (f : ℕ → ℕ × Bool) (m V : ℕ)
    (hmono : ∀ j, j + 1 < m → (f j).1 < (f (j + 1)).1) (hlast : ∀ j, j + 1 = m → (f j).1 < V) :
    ∀ n a lo, a + n = m → (n = 0 → lo ≤ V) → (0 < n → lo ≤ (f a).1) →
      Inc lo ((List.range' a n).map f) V
Uses 1 · Used by 11

StructureWell-formed situation tables for the transition clauses#✓fully proved

Given a layout with label/state block size \(A\), \(K\) stacks, \(g\) symbol codes and window depth \(d\), a current-code table \(\ell\), a next-code table \(\nu\) and a window table \(w\), the tables are well formed for situation \(i\) at height \(H\) when \(\ell(i) < A\), \(\nu(i) < A\), \(w(i, k, j) < g\) for all \(k < K\) and \(j < d\), and \(d \le H\).

structure WF (H i : ℕ) : Prop where
  la_lt : la i < L.A
  na_lt : na i < L.A
  wa_lt : ∀ k < L.KK, ∀ j < L.d, wa i k j < L.g
  d_le : L.d ≤ H
Uses 1 · Used by 10

The generator machine

InductiveCounters of the transition-family generator#✓fully proved

The generator for the transition clause families keeps fifteen unit counters, each on its own stack: \(\mathrm{Tn}\), \(\mathrm{Ti}\), \(\mathrm{Hs}\), \(\mathrm{Gc}\), \(\mathrm{HG}\), \(\mathrm{Ka}\), \(\mathrm{Wc}\), \(\mathrm{Vc}\), \(\mathrm{TW}\), \(\mathrm{P}\), \(\mathrm{Q}\), \(\mathrm{tmp}\), \(\mathrm{md}\), \(\mathrm{c1}\) and \(\mathrm{c2}\).

inductive CK
  | Tn | Ti | Hs | Gc | HG | Ka | Wc | Vc | TW | P | Q | tmp | md | c1 | c2
  deriving DecidableEq
Used by 45
Used byResting counter values in the transition-family time loop · Run of the transition-family generator on one clause · Stack alphabets of the generator · Correctness of the clause-family generator · Correctness of the clause-family generator, with its explicit time bound · Polynomial time bound for the clause-family generator · The clause-family generator as a finite stack machine · Stacks of the clause-family generator · Initial counters of the transition-clause generator · Literal routine of the transition-clause generator · Run of one literal routine (transition-clause generator) · Run of the literal routines of a clause (transition-clause generator) · Time-loop invariant of the transition-family generator · Generator machine for the transition clause families · Scratch counters at rest in the clause-family generator · One iteration of the time loop · Stacks to drain · Only the output stack survives the drain · The reduction machine halts with the emitted formula · Running a program, then the drain · The reduction machine · Time bound of the situation-definition generator on the tables of a machine · Time bound of the transition-clause generator on the tables of a machine · Host stack renaming for the situation-definition generator · Host stack renaming for the update generator · Embedding of the accept generator into the host · Embedding of the shift generator into the host · Embedding of the init generator into the host · Embedding of the situation-definition generator into the host · Embedding of the update generator's stacks into the host · Alphabets of the Cook–Levin host machine · Stacks of the Cook–Levin host machine · The host as a finite multi-stack Turing machine · The host program · The assembled generator, after the precomputation · Sequencing · Embedding of the counter program's stacks · Stacks during the read loop · The composed machine, raw input to formula · Polynomial time bound of the composed machine · The full machine as a finite multi-stack Turing machine · Initial configuration of the full machine · The precomputation · The read loop's run · Host counter of each target

AbbreviationStacks of the clause-family generator#✓fully proved

The stacks of the counter machine over the generator's counters: one stack of Booleans for the output and one unit counter for each of the generator's fifteen counters.

abbrev GK := SK CK
Uses 2 · Used by 3

AbbreviationStack alphabets of the generator#✓fully proved

The generator has an output stack and one counter stack for each of its counter names; the output stack has the alphabet \(\{\mathrm{false}, \mathrm{true}\}\) and every counter stack has a one-element alphabet.

abbrev GΓ := SΓ CK
Uses 3 · Used by 18

InductiveStages of the transition-clause generator's precomputation#✓fully proved

The control stages of the precomputation of the transition-clause generator. There are eight plain stages \(eg\), \(ew\), \(ek\), \(dk\), \(cp_1\), \(cp_2\), \(inc\) and \(dk_2\), and three families \(hg(s)\), \(w(s)\) and \(v(s)\) indexed by the four stages \(s\) of a multiplication site.

inductive PS
  | eg | hg (s : MS) | ew | ek | w (s : MS) | dk | cp1 | cp2 | inc | v (s : MS) | dk2
  deriving DecidableEq, Fintype
Uses 1 · Used by 14

InductiveStages of the transition-clause generator's literal routine#✓fully proved

The control stages of the routine of the transition-clause generator that emits one literal. There are thirteen plain stages: two copy stages \(cp_1\), \(cp_2\) and the stages \(ea\), \(da\), \(eb\), \(db\), \(ec\), \(dec\), \(cmp\), \(emL\), \(bad\), \(slot\) and \(dq\); two families \(ma(s)\) and \(mb(s)\) indexed by the four stages \(s\) of a multiplication site; and two families \(r(o)\) and \(rB(o)\) indexed by the three comparison outcomes \(o\) (less, equal, greater).

inductive LS
  | cp1 | cp2 | ea | ma (s : MS) | da | eb | mb (s : MS) | db | ec
  | dec | cmp | r (o : Ordering) | rB (o : Ordering) | emL | bad | slot | dq
  deriving DecidableEq, Fintype
Uses 1 · Used by 13

InductiveLabels of the clause-family generator#✓fully proved

For \(N, m \in \mathbb{N}\), a label is one of: a precomputation stage; the head or the tail of the time loop; a stage of the multiplication routine of a time step; for a situation \(i < N\), one of three labels that start clause \(i\), a stage of the routine emitting literal \(j\) of clause \(i\) for some \(j < m\), or the label that finishes clause \(i\); the label that ends a time step; or the final label \(\mathsf{done}\), where a successful run halts. There are finitely many labels; the generator uses \(m\) equal to the number of literals of a clause.

inductive GL (N m : ℕ)
  | pre (s : PS)
  | tHead | tRest
  | tw (s : MS)
  | e00 (i : Fin N) | cv1 (i : Fin N) | cv2 (i : Fin N)
  | lit (i : Fin N) (j : Fin m) (s : LS)
  | fin (i : Fin N)
  | dtw | done
  deriving DecidableEq, Fintype
Uses 3 · Used by 24

DefinitionEntry label of a literal routine (transition-clause generator)#✓fully proved

Among the labels of the generator with \(N\) situations and \(m\) literal numbers, the entry label of literal \(j \in \mathbb{N}\) of situation \(i < N\) is the first stage of the routine for literal \(j\) of situation \(i\) when \(j < m\), and the halting label \(\mathrm{done}\) when \(j \ge m\).

The generator never uses it with \(j \ge m\).

def litL (i : Fin N) (j : ℕ) : GL N m := if h : j < m then .lit i ⟨j, h⟩ .cp1 else .done
Uses 2 · Used by 4

DefinitionLabel after a literal routine in the transition-family generator#✓fully proved

Let \(N\) be the number of situations and \(m\) the number of literals per clause, let \(i < N\) be a situation and \(j\) a natural number. After the routine for literal \(j\) of the clause of situation \(i\), the generator moves to the label that emits the leading gap of that clause if \(j = 0\). Otherwise it moves to the first label of the routine for literal \(j - 1\) if \(j - 1 < m\), and to the halting label if \(j - 1 \ge m\).

def after (i : Fin N) (j : ℕ) : GL N m := if j = 0 then .fin i else litL i (j - 1)
Uses 2 · Used by 4

DefinitionEntry label of the clause routine for situation \(i\)#✓fully proved

For \(i < N\), the generator label \(\mathrm{e00}_i\) at which the routine emitting the clause of situation \(i\) starts; for \(i \ge N\), the end-of-time-step label \(\mathrm{dtw}\).

def sitL (i : ℕ) : GL N m := if h : i < N then .e00 ⟨i, h⟩ else .dtw
Uses 1 · Used by 2

DefinitionLabel after a situation clause in the transition-family generator#✓fully proved

Let \(N\) be the number of situations. For a natural number \(i\), the label the generator moves to after the clause of situation \(i\) is the end-of-time-step label if \(i = 0\). Otherwise it is the first label of the clause routine for situation \(i - 1\) if \(i - 1 < N\), and the end-of-time-step label again if \(i - 1 \ge N\).

def afterS (i : ℕ) : GL N m := if i = 0 then .dtw else sitL (i - 1)
Uses 2 · Used by 3

DefinitionStack index of a literal in a transition clause#✓fully proved

For a layout with \(K\) stacks and window depth \(d\), the stack index \(k_A(j)\) of literal \(j\) is \(\lfloor (j - 1)/d \rfloor\) when \(1 \le j \le Kd\), and \(0\) when \(j = 0\) or \(j > Kd\).

With the row offset \(k_B\) and the constant offset \(c_i\) of situation \(i\), the position of literal \(j\) of clause \((t, i)\) at height \(H\) is \(tW + k_A(j)\,Hg + k_B(j)\,W + c_i(j)\), where \(g\) is the number of symbol codes and \(W\) the number of variables per time step.

def kA (j : ℕ) : ℕ := if j = 0 then 0 else if j ≤ L.KK * L.d then (j - 1) / L.d else 0
Uses 1 · Used by 3

DefinitionRow offset of a literal in a transition clause#✓fully proved

For a layout with \(K\) stacks and window depth \(d\), the row offset \(k_B(j)\) of literal \(j\) is \(0\) when \(j \le Kd\) and \(1\) when \(j > Kd\).

Among the literals \(0, \dots, Kd + 1\) of a transition clause it is \(1\) only for the last one, the next-label literal, which refers to the following time step.

def kB (j : ℕ) : ℕ := if j = 0 then 0 else if j ≤ L.KK * L.d then 0 else 1
Uses 1 · Used by 3

DefinitionConstant offset of a literal position#✓fully proved

For a layout with label block size \(A\), \(K\) stacks, \(g\) symbol codes and window depth \(d\), and tables \(\mathrm{la}, \mathrm{na} : \mathbb{N} \to \mathbb{N}\) and \(\mathrm{wa} : \mathbb{N} \to \mathbb{N} \to \mathbb{N} \to \mathbb{N}\), the constant part of the position of literal \(j\) of situation \(i\) is \(\mathrm{la}(i)\) if \(j = 0\), is \(A + ((j - 1) \bmod d)\,g + \mathrm{wa}(i, \lfloor (j - 1)/d \rfloor, (j - 1) \bmod d)\) if \(1 \le j \le Kd\), and is \(\mathrm{na}(i)\) if \(j > Kd\).

def cst (i j : ℕ) : ℕ :=
  if j = 0 then la i
  else if j ≤ L.KK * L.d then L.A + (j - 1) % L.d * L.g + wa i ((j - 1) / L.d) ((j - 1) % L.d)
  else na i
Uses 1 · Used by 3

DefinitionPolarity of a transition-clause literal#✓fully proved

For a layout with \(K\) stacks and window depth \(d\), a label-transition clause has \(n = K d + 2\) literals, and literal \(j\) is positive (polarity \(\mathrm{true}\)) exactly when \(j = n - 1\): only the last (next-code) literal is positive.

def sgn (j : ℕ) : Bool := decide (j = L.nLits - 1)
Uses 2 · Used by 3

DefinitionLiteral routine of the transition-clause generator#✓fully proved

Fix a layout with label/state block size \(A\), \(K\) stacks, \(g\) symbol codes and window depth \(d\), tables \(\mathrm{la}\), \(\mathrm{na}\), \(\mathrm{wa}\) and a number \(N\) of situations, and let \(n = Kd + 2\) be the number of literals of a clause. For a situation \(i < N\) and a literal number \(j < n\), this assigns a generator instruction to each stage of the routine that emits literal \(j\) of the clause of situation \(i\); all stages named below are stages of this routine, and moving a counter onto targets means popping it until it is empty and pushing one unit onto every target for each unit popped. Stage \(cp_1\) moves \(\mathsf{TW}\) onto \(\mathsf{Q}\) and \(\mathsf{tmp}\) and goes to \(cp_2\), which moves \(\mathsf{tmp}\) onto \(\mathsf{TW}\) and goes to \(ea\). Stage \(ea\) pushes \(k_A(j)\) units onto \(\mathsf{Ka}\), where \(k_A(j)\) is the stack index of literal \(j\), and goes to \(ma(\mathrm{head})\); the stages \(ma(s)\) run the multiplication routine, stage \(s\) at \(ma(s)\), with multiplier \(\mathsf{Ka}\), index counter \(\mathsf{md}\), multiplicand \(\mathsf{HG}\), target \(\mathsf{Q}\) and scratch \(\mathsf{tmp}\), ending at \(da\); and \(da\) empties \(\mathsf{Ka}\) and goes to \(eb\). Stage \(eb\) pushes \(k_B(j)\) units onto \(\mathsf{Ka}\), where \(k_B(j)\) is the row offset of literal \(j\), and goes to \(mb(\mathrm{head})\); the stages \(mb(s)\) run the multiplication routine, stage \(s\) at \(mb(s)\), with multiplier \(\mathsf{Ka}\), index counter \(\mathsf{md}\), multiplicand \(\mathsf{Wc}\), target \(\mathsf{Q}\) and scratch \(\mathsf{tmp}\), ending at \(db\); and \(db\) empties \(\mathsf{Ka}\) and goes to \(ec\). Stage \(ec\) pushes \(c_i(j)\) units onto \(\mathsf{Q}\), where \(c_i(j)\) is the constant offset of literal \(j\) of situation \(i\), and goes to \(dec\). Stage \(dec\) pops \(\mathsf{P}\) and goes to \(bad\) if \(\mathsf{P}\) was empty and to \(cmp\) otherwise. Stage \(cmp\) pops \(\mathsf{P}\) and then \(\mathsf{Q}\), pushing a unit onto \(\mathsf{c1}\) if the pop of \(\mathsf{P}\) found one and onto \(\mathsf{c2}\) if the pop of \(\mathsf{Q}\) found one; it returns to \(cmp\) if both pops found a unit, and otherwise goes to \(r(\mathrm{gt})\) if only \(\mathsf{P}\) had one, to \(r(\mathrm{lt})\) if only \(\mathsf{Q}\) had one, and to \(r(\mathrm{eq})\) if neither had one. Stage \(r(o)\) moves \(\mathsf{c1}\) onto \(\mathsf{P}\) and goes to \(rB(o)\), which moves \(\mathsf{c2}\) onto \(\mathsf{Q}\) and goes to \(slot\) if \(o = \mathrm{eq}\) and to \(emL\) otherwise. Stage \(emL\) prepends \([\mathrm{false}, \mathrm{true}]\) to the output and goes to \(dec\), and stage \(bad\) halts. Stage \(slot\) prepends the two-bit code \(10\) to the output if \(j = n - 1\) and \(11\) otherwise, and goes to \(dq\), which empties \(\mathsf{Q}\) and then goes to the label that finishes the clause of situation \(i\) if \(j = 0\), and to the first stage of the routine for literal \(j - 1\) otherwise.

Cslib.Complexity.CookLevin.Family.litP · 20 lines
def litP (i : Fin N) (j : Fin L.nLits) : LS → TM2.Stmt GΓ (GL N L.nLits) Bool
  | .cp1 => xfer (.c .TW) [⟨.c .Q, ()⟩, ⟨.c .tmp, ()⟩] (.lit i j .cp1) (.lit i j .cp2)
  | .cp2 => xfer (.c .tmp) [⟨.c .TW, ()⟩] (.lit i j .cp2) (.lit i j .ea)
  | .ea => emitR (.c .Ka) (List.replicate (kA L j) ()) (.lit i j (.ma .head))
  | .ma s => mulS .Ka .md .HG .Q .tmp (fun s => .lit i j (.ma s)) (.lit i j .da) s
  | .da => xfer (.c .Ka) [] (.lit i j .da) (.lit i j .eb)
  | .eb => emitR (.c .Ka) (List.replicate (kB L j) ()) (.lit i j (.mb .head))
  | .mb s => mulS .Ka .md .Wc .Q .tmp (fun s => .lit i j (.mb s)) (.lit i j .db) s
  | .db => xfer (.c .Ka) [] (.lit i j .db) (.lit i j .ec)
  | .ec => emitR (.c .Q) (List.replicate (cst L la na wa i j) ()) (.lit i j .dec)
  | .dec => decr (.c .P) (.lit i j .bad) (.lit i j .cmp)
  | .cmp => cmpStep (.c .P) (.c .Q) (.c .c1) (.c .c2) () () (.lit i j .cmp)
      (.lit i j (.r .lt)) (.lit i j (.r .eq)) (.lit i j (.r .gt))
  | .r o => xfer (.c .c1) [⟨.c .P, ()⟩] (.lit i j (.r o)) (.lit i j (.rB o))
  | .rB o => xfer (.c .c2) [⟨.c .Q, ()⟩] (.lit i j (.rB o))
      (if o = .eq then .lit i j .slot else .lit i j .emL)
  | .emL => emitR .out [false, true] (.lit i j .dec)
  | .bad => .halt
  | .slot => emitR .out (encodeSlot (some (sgn L j))) (.lit i j .dq)
  | .dq => xfer (.c .Q) [] (.lit i j .dq) (GL.after i j)
Uses 20 · Used by 1

DefinitionGenerator machine for the transition clause families#✓fully proved

Fix a layout \(L\) with label/state block size \(A\), \(K\) stacks and \(g\) symbol codes, tables \(\mathrm{la}\), \(\mathrm{na}\), \(\mathrm{wa}\), and a number \(N\) of situations, and let \(n = Kd + 2\) be the number of literals of a clause, where \(d\) is the window depth. The generator is a multi-stack machine with a Boolean output stack, the unit counters of the generator, and a Boolean internal state; below, moving a counter onto targets means popping it until it is empty and pushing one unit onto every target for each unit popped, and each multiplication uses \(\mathsf{md}\) as its index counter and \(\mathsf{tmp}\) as scratch. Its precomputation pushes \(g\) units on \(\mathsf{Gc}\), adds \(\mathsf{Hs} \cdot \mathsf{Gc}\) to \(\mathsf{HG}\), pushes \(A\) units on \(\mathsf{Wc}\), pushes \(K\) units on \(\mathsf{Ka}\), adds \(\mathsf{Ka} \cdot \mathsf{HG}\) to \(\mathsf{Wc}\), empties \(\mathsf{Ka}\), moves \(\mathsf{Tn}\) onto \(\mathsf{Ka}\) and \(\mathsf{tmp}\) and then \(\mathsf{tmp}\) onto \(\mathsf{Tn}\), pushes one unit on \(\mathsf{Ka}\), adds \(\mathsf{Ka} \cdot \mathsf{Wc}\) to \(\mathsf{Vc}\), empties \(\mathsf{Ka}\) and goes to the loop head. At the loop head it pops \(\mathsf{Tn}\); if a unit was popped it pushes a unit on \(\mathsf{Ti}\), adds \(\mathsf{Tn} \cdot \mathsf{Wc}\) to \(\mathsf{TW}\) and goes to the clause routine of situation \(N - 1\) (to the end of the time step if \(N = 0\)); if \(\mathsf{Tn}\) was empty it moves \(\mathsf{Ti}\) onto \(\mathsf{Tn}\) and goes to its final label, where it halts. The clause routine of situation \(i < N\) prepends \([\mathrm{false}, \mathrm{false}]\) to the output, moves \(\mathsf{Vc}\) onto \(\mathsf{P}\) and \(\mathsf{tmp}\) and then \(\mathsf{tmp}\) onto \(\mathsf{Vc}\), runs the literal routines of situation \(i\) for literals \(n - 1, n - 2, \dots, 0\) in turn, drains \(\mathsf{P}\) while prepending \([\mathrm{false}, \mathrm{true}]\) to the output once per unit, and goes to the clause routine of situation \(i - 1\), or to the end of the time step if \(i = 0\). At the end of a time step it empties \(\mathsf{TW}\) and returns to the loop head.

It is meant to be started with \(T\) on \(\mathsf{Tn}\), \(H\) on \(\mathsf{Hs}\) and every other counter empty.

Cslib.Complexity.CookLevin.Family.prog · 22 lines
def prog : GL N L.nLits → TM2.Stmt GΓ (GL N L.nLits) Bool
  | .pre .eg => emitR (.c .Gc) (List.replicate L.g ()) (.pre (.hg .head))
  | .pre (.hg s) => mulS .Hs .md .Gc .HG .tmp (fun s => .pre (.hg s)) (.pre .ew) s
  | .pre .ew => emitR (.c .Wc) (List.replicate L.A ()) (.pre .ek)
  | .pre .ek => emitR (.c .Ka) (List.replicate L.KK ()) (.pre (.w .head))
  | .pre (.w s) => mulS .Ka .md .HG .Wc .tmp (fun s => .pre (.w s)) (.pre .dk) s
  | .pre .dk => xfer (.c .Ka) [] (.pre .dk) (.pre .cp1)
  | .pre .cp1 => xfer (.c .Tn) [⟨.c .Ka, ()⟩, ⟨.c .tmp, ()⟩] (.pre .cp1) (.pre .cp2)
  | .pre .cp2 => xfer (.c .tmp) [⟨.c .Tn, ()⟩] (.pre .cp2) (.pre .inc)
  | .pre .inc => incr (.c .Ka) () (.pre (.v .head))
  | .pre (.v s) => mulS .Ka .md .Wc .Vc .tmp (fun s => .pre (.v s)) (.pre .dk2) s
  | .pre .dk2 => xfer (.c .Ka) [] (.pre .dk2) .tHead
  | .tHead => forHead (.c .Tn) (.c .Ti) () (.tw .head) .tRest
  | .tRest => xfer (.c .Ti) [⟨.c .Tn, ()⟩] .tRest .done
  | .tw s => mulS .Tn .md .Wc .TW .tmp .tw (GL.afterS N) s
  | .e00 i => emitR .out [false, false] (.cv1 i)
  | .cv1 i => xfer (.c .Vc) [⟨.c .P, ()⟩, ⟨.c .tmp, ()⟩] (.cv1 i) (.cv2 i)
  | .cv2 i => xfer (.c .tmp) [⟨.c .Vc, ()⟩] (.cv2 i) (GL.litL i (L.nLits - 1))
  | .lit i j s => litP L la na wa N i j s
  | .fin i => xferE (.c .P) .out [false, true] (.fin i) (GL.afterS i)
  | .dtw => xfer (.c .TW) [] .dtw .tHead
  | .done => .halt
Uses 19 · Used by 12

DefinitionThe clause-family generator as a finite stack machine#✓fully proved

For a layout \(L\), tables \(\mathit{la}\), \(\mathit{na}\), \(\mathit{wa}\) and \(N\) situations, the generator program for these data, bundled as a multi-stack Turing machine with finitely many stacks, labels and states: its stacks are the generator's stacks (the Boolean output stack and the counters), its input stack is the time counter and its output stack is the Boolean output stack, its alphabets are the generator's alphabets, its labels are the generator's labels for \(N\) situations and literal numbers below the number of literals of a clause, execution starts at the first precomputation stage, and its internal state is a Boolean, initially false.

def genTM : FinTM2 where
  K := GK
  k₀ := .c .Tn
  k₁ := .out
  Γ := GΓ
  Λ := GL N L.nLits
  main := .pre .eg
  σ := Bool
  initialState := false
  m := prog L la na wa N
Uses 11

Correctness: one literal

StructureScratch counters at rest in the clause-family generator#✓fully proved

A counter assignment \(F\) of the generator (a natural number for each of its counters) is at rest when its six scratch counters \(Q\), \(K_a\), \(\mathit{tmp}\), \(\mathit{md}\), \(c_1\) and \(c_2\) all hold \(0\).

structure Rest (F : CK → ℕ) : Prop where
  Q : F .Q = 0
  Ka : F .Ka = 0
  tmp : F .tmp = 0
  md : F .md = 0
  c1 : F .c1 = 0
  c2 : F .c2 = 0
Uses 1 · Used by 7

TheoremRun of one literal routine (transition-clause generator)#✓fully proved

Let \(i < N\) be a situation, \(j\) less than the number of literals, and \(F\) a counter assignment whose scratch counters \(Q\), \(\mathrm{Ka}\), \(\mathrm{tmp}\), \(\mathrm{md}\), \(c_1\), \(c_2\) are \(0\). Let \(q = F(\mathrm{TW}) + k_A(j) F(\mathrm{HG}) + k_B(j) F(\mathrm{Wc}) + c_i(j)\), where \(k_A\), \(k_B\) and \(c_i(j)\) are the stack index, the row offset and the constant part of the position of literal \(j\), and suppose \(F(P) = q + m + 1\) for a natural number \(m\). Let \(K\) be the number of stacks of the layout. Then for every output \(o\) and every state \(v\), the generator runs in at most

\[m(3q + 6) + 2F(\mathrm{TW}) + K(2F(\mathrm{HG}) + 3) + 2K + 2F(\mathrm{Wc}) + 4q + 22\]

steps from the first stage of the routine for literal \(j\) of situation \(i\), with state \(v\), counters \(F\) and output \(o\), to the label that follows literal \(j\), with state false, counters \(F\) except that \(P = q\), and output \(s\,(01)^m\,o\), where \(s\) is the slot code of a literal with polarity \(\mathrm{sgn}(j)\).

theorem lit_run (i : Fin N) (j : Fin L.nLits) (F : CK → ℕ) (hF : Rest F) (q gap : ℕ)
    (hq : q = F .TW + kA L j * F .HG + kB L j * F .Wc + cst L la na wa i j)
    (hp : F .P = q + gap + 1) (o : List Bool) (v : Bool) :
    RunLe (prog L la na wa N)
      (gap * (3 * q + 6) + 2 * F .TW + L.KK * (2 * F .HG + 3) + 2 * L.KK + 2 * F .Wc + 4 * q + 22)
      ⟨some (.lit i j .cp1), v, st F o⟩
      ⟨some (GL.after i j), false,
        st (update F .P q) (encodeSlot (some (sgn L j)) ++ rep [false, true] gap ++ o)⟩
Uses 33 · Used by 1

Correctness: one clause

DefinitionBoundary before a literal of a transition clause#✓fully proved

Let \(L\) be a layout with \(K\) stacks and window depth \(d\), let \(la\), \(na\), \(wa\) be the tables and \(T\), \(H\), \(t\), \(i\), \(j\) natural numbers. If \(j\) is less than the number \(m = Kd + 2\) of literals of a transition clause, this is the position of literal \(j\) of clause \((t, i)\); otherwise it is the number \(V\) of variables of \(L\) for \(T\) and \(H\).

def bnd (L : Layout) (la na : ℕ → ℕ) (wa : ℕ → ℕ → ℕ → ℕ) (T H t i j : ℕ) : ℕ :=
  if j < L.nLits then litPos L la na wa H t i j else L.numVars T H
Uses 4 · Used by 2

StructureResting counter values in the transition-family time loop#✓fully proved

Let \(L\) be a layout with label/state block size \(A\), \(K\) stacks and \(g\) symbol codes, let \(T\), \(H\), \(t\) be natural numbers, and write \(W = A + KHg\) for the number of variables per time step and \(V = (T + 1)W\) for the total number of variables. Counter values \(F\) of the generator are at rest at time \(t\) when the scratch counters \(\mathrm{Q}\), \(\mathrm{Ka}\), \(\mathrm{tmp}\), \(\mathrm{md}\), \(\mathrm{c1}\), \(\mathrm{c2}\) are all \(0\), \(F(\mathrm{TW}) = tW\), \(F(\mathrm{HG}) = Hg\), \(F(\mathrm{Wc}) = W\) and \(F(\mathrm{Vc}) = V\).

structure Base (L : Layout) (T H t : ℕ) (F : CK → ℕ) : Prop extends Rest F where
  TW : F .TW = t * L.rowW H
  HG : F .HG = H * L.g
  Wc : F .Wc = L.rowW H
  Vc : F .Vc = L.numVars T H
Uses 5 · Used by 3

DefinitionPer-literal time bound of the transition-clause generator#✓fully proved

For a layout with label/state block size \(A\), \(K\) stacks and \(g\) symbol codes, and for \(T, H \in \mathbb{N}\), let \(W = A + KHg\) be the number of variables per time step and \(V = (T + 1)W\) the number of variables. The per-literal time bound is \(6V + K(2Hg + 3) + 2K + 2W + 22\).

It bounds the steps spent on one literal apart from the loop that emits the gap before it.

def litE (L : Layout) (T H : ℕ) : ℕ :=
  6 * L.numVars T H + L.KK * (2 * (H * L.g) + 3) + 2 * L.KK + 2 * L.rowW H + 22
Uses 3 · Used by 5

DefinitionStep bound for one clause of the transition-family generator#✓fully proved

Let \(L\) be a layout with label/state block size \(A\), \(K\) stacks, \(g\) symbol codes and window depth \(d\), and let \(T\), \(H\) be natural numbers. With \(W = A + KHg\), \(V = (T + 1)W\), \(m = Kd + 2\) and \(E = 6V + K(2Hg + 3) + 2K + 2W + 22\), the bound is \(V(3V + 6) + mE + 3V + 4\).

def clauseB (L : Layout) (T H : ℕ) : ℕ :=
  L.numVars T H * (3 * L.numVars T H + 6) + L.nLits * litE L T H + 3 * L.numVars T H + 4
Uses 4 · Used by 5

TheoremRun of the literal routines of a clause (transition-clause generator)#✓fully proved

Let \(t < T\), let the tables be well formed for situation \(i < N\) at height \(H\), and let \(F\) be a counter assignment resting at time \(t\): its scratch counters \(Q\), \(\mathrm{Ka}\), \(\mathrm{tmp}\), \(\mathrm{md}\), \(c_1\), \(c_2\) are \(0\), \(F(\mathrm{TW}) = tW\), \(F(\mathrm{HG}) = Hg\), \(F(\mathrm{Wc}) = W\) and \(F(\mathrm{Vc}) = V\), where \(g\) is the number of symbol codes of the layout, \(W\) is the number of variables per time step and \(V = (T + 1)W\). Let \(n\) be the number of literals of a clause. For \(j \le n\) let \(b_j\) be the position of literal \(j\) of clause \((t, i)\) when \(j < n\), and \(b_n = V\); let \(e_j\) be the gap encoding of the slots \(b_j, \dots, V - 1\) whose literals are those of clause \((t, i)\) numbered \(j\) or more. Then for every output \(o\), every \(j \le n\) and every state \(v\) there is a state \(v'\) such that the generator runs in at most \(b_j(3V + 6) + jE\) steps, where \(E\) is the per-literal time bound, from the label that follows literal \(j\) with state \(v\), counters \(F\) except that \(P = b_j\), and output \(e_j\,00\,o\), to the leading-gap stage of situation \(i\) with state \(v'\), counters \(F\) except that \(P = b_0\), and output \(e_0\,00\,o\).

The label that follows literal \(j\) is the routine for literal \(j - 1\), or the leading-gap stage when \(j = 0\).

theorem lits_run {T H t : ℕ} {i : Fin N} (ht : t < T) (hwf : WF L la na wa H i) (F : CK → ℕ)
    (hF : Base L T H t F) (o : List Bool) :
    ∀ j, j ≤ L.nLits → ∀ v : Bool, ∃ v' : Bool,
      RunLe (prog L la na wa N)
        (bnd L la na wa T H t i j * (3 * L.numVars T H + 6) + j * litE L T H)
        ⟨some (GL.after i j), v,
          st (update F .P (bnd L la na wa T H t i j))
            (gapEnc (bnd L la na wa T H t i j) ((lits L la na wa H t i).drop j)
              (L.numVars T H) ++ [false, false] ++ o)⟩
        ⟨some (.fin i), v',
          st (update F .P (bnd L la na wa T H t i 0))
            (gapEnc (bnd L la na wa T H t i 0) (lits L la na wa H t i)
              (L.numVars T H) ++ [false, false] ++ o)⟩
Uses 38 · Used by 1

TheoremRun of the transition-family generator on one clause#✓fully proved

Let \(L\) be a layout with tables \(la\), \(na\), \(wa\), let \(N\) be the number of situations, let \(T\), \(H\), \(t\) be natural numbers with \(t < T\), and let \(i < N\) be a situation whose tables are well formed at height \(H\). Let \(F\) be counter values at rest in the time loop at time \(t\) (for \(T\) and \(H\)) with \(F(\mathrm{P}) = 0\), let \(o\) be a bit string and \(v\) a Boolean machine state. Started at the first label of the clause routine for situation \(i\) with state \(v\), counter values \(F\) and output stack \(o\), the generator reaches, in at most \(C\) steps, the label after the clause of situation \(i\) with state false, counter values \(F\), and output stack the encoding of the dense clause over \(V\) variables with the literals of clause \((t, i)\) followed by \(o\). Here \(V\) is the number of variables of \(L\) for \(T\) and \(H\), and \(C\) is the step bound for one whole clause of \(L\) for \(T\) and \(H\).

theorem clause_run {T H t : ℕ} {i : Fin N} (ht : t < T) (hwf : WF L la na wa H i) (F : CK → ℕ)
    (hF : Base L T H t F) (hP : F .P = 0) (o : List Bool) (v : Bool) :
    RunLe (prog L la na wa N) (clauseB L T H) ⟨some (.e00 i), v, st F o⟩
      ⟨some (GL.afterS i), false,
        st F (encodeClause (denseClause (L.numVars T H) (lits L la na wa H t i)) ++ o)⟩
Uses 45 · Used by 1

Correctness: situations, time steps, the whole generator

DefinitionEncoded transition clauses of one time step#✓fully proved

Given a layout \(L\), tables \(la, na : \mathbb{N} \to \mathbb{N}\) and \(wa : \mathbb{N} \to \mathbb{N} \to \mathbb{N} \to \mathbb{N}\), and natural numbers \(N\), \(T\), \(H\), \(t\), this is the bit string obtained by concatenating, for \(i = 0, 1, \dots, N - 1\) in this order, the encoding of the dense clause over \(V\) variables whose literals are the literals of clause \((t, i)\), where \(V\) is the number of variables of \(L\) for \(T\) and \(H\).

def blk (L : Layout) (la na : ℕ → ℕ) (wa : ℕ → ℕ → ℕ → ℕ) (N T H t : ℕ) : List Bool :=
  (List.range N).flatMap fun i => encodeClause (denseClause (L.numVars T H) (lits L la na wa H t i))
Uses 5 · Used by 3

StructureTime-loop invariant of the transition-family generator#✓fully proved

Let \(L\) be a layout with label/state block size \(A\), \(K\) stacks and \(g\) symbol codes, let \(T, H \in \mathbb{N}\), and write \(W = A + KHg\) for the number of variables per time step and \(V = (T + 1)W\) for the total number of variables. Counter values \(f\) of the generator satisfy the time-loop invariant when the scratch counters \(\mathrm{Q}\), \(\mathrm{Ka}\), \(\mathrm{tmp}\), \(\mathrm{md}\), \(\mathrm{c1}\), \(\mathrm{c2}\) are all \(0\), \(f(\mathrm{P}) = 0\), \(f(\mathrm{TW}) = 0\), \(f(\mathrm{HG}) = Hg\), \(f(\mathrm{Wc}) = W\) and \(f(\mathrm{Vc}) = V\).

The counters \(\mathrm{Tn}\), \(\mathrm{Ti}\), \(\mathrm{Hs}\) and \(\mathrm{Gc}\) are not constrained.

structure LoopP (L : Layout) (T H : ℕ) (f : CK → ℕ) : Prop extends Rest f where
  P : f .P = 0
  TW : f .TW = 0
  HG : f .HG = H * L.g
  Wc : f .Wc = L.rowW H
  Vc : f .Vc = L.numVars T H
Uses 5 · Used by 2

DefinitionStep bound for one time-loop iteration of the transition-family generator#✓fully proved

For a layout \(L\) and natural numbers \(N\), \(T\), \(H\), let \(W\) be the number of variables per time step of \(L\) at height \(H\) and \(C\) the step bound for one whole clause of \(L\) for \(T\) and \(H\). The bound is \(T(2W + 3) + TW + T + 3 + NC\).

def bodyB (L : Layout) (N T H : ℕ) : ℕ :=
  T * (2 * L.rowW H + 3) + T * L.rowW H + T + 3 + N * clauseB L T H
Uses 3 · Used by 5

DefinitionStep bound for the transition-clause generator's precomputation#✓fully proved

For a layout \(L\) with \(KK\) stacks and \(g\) symbol codes and bounds \(T\) and \(H\), the bound is \(H (2g + 3) + KK (2Hg + 3) + (T + 1)(2W + 3) + H + 2 KK + 4T + 16\), where \(W\) is the number of variables per time step at height \(H\).

def preB (L : Layout) (T H : ℕ) : ℕ :=
  H * (2 * L.g + 3) + L.KK * (2 * (H * L.g) + 3) + (T + 1) * (2 * L.rowW H + 3) + H + 2 * L.KK +
    4 * T + 16
Uses 2 · Used by 4

DefinitionTime bound of the generator#✓fully proved

For a layout \(L\) and \(N, T, H \in \mathbb{N}\), the time bound of the whole generator is \(P + T(B + 1) + T + 2\), where \(P\) is the time bound of the precomputation for \(L\), \(T\) and \(H\), and \(B\) is the time bound of one iteration of the time loop for \(L\), \(N\), \(T\) and \(H\).

The bound is explicit; that it is at most \(C\,(T + H + 1)^5\) for a constant \(C\) depending only on \(L\) and \(N\) is proved separately.

def genBound (L : Layout) (N T H : ℕ) : ℕ :=
  preB L T H + (T * (bodyB L N T H + 1) + T + 2)
Uses 3 · Used by 4

TheoremOne iteration of the time loop#✓fully proved

Let \(t < T\), suppose the tables are well formed at height \(H\) for every situation \(i < N\), and let \(f\) be a counter assignment that satisfies the time-loop invariant for \(T\) and \(H\) and has counter \(T_n\) equal to \(t\). Then for every output word \(o\), the generator started at the head label of the time-step multiplication, with state \(\mathrm{true}\), counters \(f\) and output \(o\), reaches the time-loop head label with state \(\mathrm{false}\), the same counters \(f\) and output \(b_t o\) in at most \(B\) steps. Here \(b_t\) is the concatenation of the encoded clauses of time step \(t\) for situations \(0, \dots, N-1\), and \(B\) is the time-loop body bound for \(N\), \(T\) and \(H\).

theorem time_body {T H t : ℕ} (ht : t < T) (hwf : ∀ i < N, WF L la na wa H i) (f : CK → ℕ)
    (hf : LoopP L T H f) (hTn : f .Tn = t) (o : List Bool) :
    RunLe (prog L la na wa N) (bodyB L N T H) ⟨some (.tw .head), Flag.tag true, st f o⟩
      ⟨some .tHead, Flag.tag false, st f (blk L la na wa N T H t ++ o)⟩
Uses 33 · Used by 1

DefinitionGenerator output after part of the time loop#✓fully proved

For a layout \(L\), tables \(la\), \(na\), \(wa\), sizes \(N\), \(T\), \(H\), a number \(m\) of iterations and a Boolean list \(o\), the output after \(m\) iterations is the concatenation, over the \(m\) consecutive time steps \(s\) starting at \(T - m\) in increasing order, of the encoded clauses of time step \(s\), followed by \(o\). Here \(T - m\) is truncated subtraction, so for \(m \le T\) these are the time steps \(T - m, \dots, T - 1\).

def outAfter (L : Layout) (la na : ℕ → ℕ) (wa : ℕ → ℕ → ℕ → ℕ) (N T H ii : ℕ)
    (o : List Bool) : List Bool :=
  (List.range' (T - ii) ii).flatMap (blk L la na wa N T H) ++ o
Uses 2 · Used by 1

DefinitionInitial counters of the transition-clause generator#✓fully proved

For natural numbers \(T\) and \(H\), the initial counter assignment gives the counter \(\mathrm{Tn}\) the value \(T\), the counter \(\mathrm{Hs}\) the value \(H\), and every other counter of the generator the value \(0\).

def initF (T H : ℕ) : CK → ℕ
  | .Tn => T
  | .Hs => H
  | _ => 0
Uses 1 · Used by 7

TheoremCorrectness of the clause-family generator, with its explicit time bound#✓fully proved

Let \(L\) be a layout, \(\mathit{la}, \mathit{na} : \mathbb{N} \to \mathbb{N}\) and \(\mathit{wa} : \mathbb{N}^3 \to \mathbb{N}\) tables, and \(N, T, H \in \mathbb{N}\), and suppose the tables are well formed at height \(H\) for every situation \(i < N\). Start the generator for \(L\), \(\mathit{la}\), \(\mathit{na}\), \(\mathit{wa}\) and \(N\) at its first precomputation stage, in state false, with \(T\) on the time counter and \(H\) on the height counter in unary, all other counters empty, and an arbitrary list \(o\) of bits on the output stack. Then within \(B(L, N, T, H)\) steps, where \(B\) is the generator's explicit time bound, it reaches its final label \(\mathsf{done}\) (not the error stage of the literal routine, which also halts), in some state, with stacks whose output stack holds the encoding of the clause family for \(L\), \(\mathit{la}\), \(\mathit{na}\), \(\mathit{wa}\), \(T\), \(H\) and \(N\), followed by \(o\).

theorem gen_run (T H : ℕ) (hwf : ∀ i < N, WF L la na wa H i) (o : List Bool) :
    ∃ (v : Bool) (S : ∀ k, List (GΓ k)),
      RunLe (prog L la na wa N) (genBound L N T H)
        ⟨some (.pre .eg), false, st (initF T H) o⟩ ⟨some .done, v, S⟩ ∧
        S .out = encodeCNF (family L la na wa T H N) ++ o
Uses 44 · Used by 2

TheoremCorrectness of the clause-family generator#✓fully proved

Let \(L\) be a layout, \(\mathit{la}, \mathit{na} : \mathbb{N} \to \mathbb{N}\) and \(\mathit{wa} : \mathbb{N}^3 \to \mathbb{N}\) tables, and \(N, T, H \in \mathbb{N}\), and suppose the tables are well formed at height \(H\) for every situation \(i < N\). Start the generator for \(L\), \(\mathit{la}\), \(\mathit{na}\), \(\mathit{wa}\) and \(N\) at its first precomputation stage, in state false, with \(T\) on the time counter and \(H\) on the height counter in unary, all other counters empty, and an arbitrary list \(o\) of bits on the output stack. Then after finitely many steps it reaches its final label \(\mathsf{done}\) (not the error stage of the literal routine, which also halts), in some state, with stacks whose output stack holds the encoding of the clause family for \(L\), \(\mathit{la}\), \(\mathit{na}\), \(\mathit{wa}\), \(T\), \(H\) and \(N\), followed by \(o\).

theorem gen_correct (T H : ℕ) (hwf : ∀ i < N, WF L la na wa H i) (o : List Bool) :
    ∃ (v : Bool) (S : ∀ k, List (GΓ k)),
      Reach (prog L la na wa N) ⟨some (.pre .eg), false, st (initF T H) o⟩ ⟨some .done, v, S⟩ ∧
        S .out = encodeCNF (family L la na wa T H N) ++ o
Uses 18

The time bound is polynomial: genBound ≤ genC · (T + H + 1)^5

DefinitionUniform layout#✓fully proved

For \(k \in \mathbb{N}\), the layout whose label/state block size, number of stacks, number of symbol codes and window depth are all equal to \(k\).

def Layout.uni (k : ℕ) : Layout := ⟨k, k, k, k⟩
Uses 1 · Used by 10

TheoremUniform bound on the generator's time#✓fully proved

For natural numbers \(k \ge 1\) and \(y \ge 1\), the explicit time bound of the generator for the layout whose label block size, number of stacks, number of symbol codes and window depth all equal \(k\), with \(N = k\) situations and \(T = H = y\), is at most \(323\,k^5 y^5\).

Every monomial of the bound is at most \(k^5 y^5\), and its coefficients sum to \(323\), its value at \(k = y = 1\).

theorem genBound_uni (k y : ℕ) (hk : 1 ≤ k) (hy : 1 ≤ y) :
    genBound (Layout.uni k) k y y ≤ 323 * k ^ 5 * y ^ 5
Uses 10 · Used by 1

DefinitionConstant of the generator's time bound#✓fully proved

For a layout \(L\) with label/state block size \(A\), \(K\) stacks, \(g\) symbol codes and window depth \(d\), and for \(N\) situations, the constant is \(323\,(A + K + g + d + N + 1)^5\).

def genC (L : Layout) (N : ℕ) : ℕ := 323 * (L.A + L.KK + L.g + L.d + N + 1) ^ 5
Uses 1 · Used by 9

DefinitionTime-bound polynomial of the clause-family generator#✓fully proved

For a layout \(L\) and a number \(N\) of situations, this is the polynomial \(c\,(X + 1)^5\) with natural-number coefficients, where \(c\) is the constant of the generator's time bound for \(L\) and \(N\).

Evaluated at \(T + H\) it is \(c\,(T + H + 1)^5\), the generator's time bound, in the polynomial form that polynomial-time computability of a multi-stack machine uses.

noncomputable def genPoly (L : Layout) (N : ℕ) : Polynomial ℕ := C (genC L N) * (X + 1) ^ 5
Uses 2

TheoremPolynomial time bound for the clause-family generator#✓fully proved

Let \(L\) be a layout, \(\mathit{la}, \mathit{na} : \mathbb{N} \to \mathbb{N}\) and \(\mathit{wa} : \mathbb{N}^3 \to \mathbb{N}\) tables, and \(N, T, H \in \mathbb{N}\), and suppose the tables are well formed at height \(H\) for every situation \(i < N\). Start the generator for \(L\), \(\mathit{la}\), \(\mathit{na}\), \(\mathit{wa}\) and \(N\) at its first precomputation stage, in state false, with \(T\) on the time counter and \(H\) on the height counter in unary, all other counters empty, and an arbitrary list \(o\) of bits on the output stack. Then within \(c\,(T + H + 1)^5\) steps, where \(c\) is the constant of the generator's time bound for \(L\) and \(N\), it reaches its final label \(\mathsf{done}\) (not the error stage of the literal routine, which also halts), in some state, with stacks whose output stack holds the encoding of the clause family for \(L\), \(\mathit{la}\), \(\mathit{na}\), \(\mathit{wa}\), \(T\), \(H\) and \(N\), followed by \(o\).

theorem gen_time {L : Layout} {la na : ℕ → ℕ} {wa : ℕ → ℕ → ℕ → ℕ} {N : ℕ} (T H : ℕ)
    (hwf : ∀ i < N, WF L la na wa H i) (o : List Bool) :
    ∃ (v : Bool) (S : ∀ k, List (GΓ k)),
      RunLe (prog L la na wa N) (genC L N * (T + H + 1) ^ 5)
        ⟨some (.pre .eg), false, st (initF T H) o⟩ ⟨some .done, v, S⟩ ∧
        S .out = encodeCNF (family L la na wa T H N) ++ o
Uses 26 · Used by 2

The dependency explorer needs JavaScript and its graph data.

Download the complete graph data.