Stack alphabet of the SAT verifier to A clause has at most as many tokens as code bits

InductiveStack alphabet of the SAT verifier#✓fully proved

The symbols of the token and table stacks are a name bit \(b\) for each boolean \(b\), a polarity marker for each polarity \(p\), a clause end marker, a value marker for each boolean \(b\), and a dead marker. Equality of symbols is decidable.

inductive Sym
  | bit (b : Bool) | lit (p : Bool) | cl | val (b : Bool) | dead
  deriving DecidableEq
Used by 410
Used byUnary-to-binary converter as a host component · Program of the unary-to-binary converter · Converter turns a unary count into a canonical binary frame · Converter turns a unary count into a raw canonical binary payload · Reading a symbol as a name bit · Tokens of a clause · A clause has at most as many tokens as code bits · Symbols of a table entry · Tokens of a literal · Closing marker of a table entry · Table stack of an entry list · Tokenizer of the SAT verifier · Token sequence of a CNF formula · Calling the lookup · Configurations of the clause-check machine · A clause's tokens on the token stack · Clause loop of the clause check · The clause-check driver · A literal's tokens on the token stack · Literal loop of the clause check · The lookup contract · Moving a table marker between stacks · Moving a symbol between stacks · The lookup program · The clause check · Next label of the lookup scan · Clause-check statements · Token count is bounded by the encoding length · The return loop of the lookup machine · A name bit reads as itself · Serving a live table entry · One scan step of the lookup · Initialization step of the lookup machine · The tokenizer program · Rejection of the SAT tokenizer within a step bound · One step to rejection · Correctness of the SAT-verifier lookup machine · The scan loop of the lookup machine · Tokenizer stack contents · Stack contents of the lookup machine · Restoring and stashing after a comparison in the lookup machine · Testing whether the top symbol is a given bit · Reading a unary count · Instruction for reading a unary count · Tokenizer run on one clause · Tokenizer rejects undecodable clauses · Tokenizer run on all clauses · The tokenizer accepts when the formula stack is empty · Stack alphabets of the SAT verifier host · Tokenizer rejects an undecodable literal · Tokenizer run on one literal · Tokenizer rejects undecodable literals · Reading the literals of a clause · Rejecting an unterminated name block · Reading a name block · Reading a polarity · Rejecting run · Accepting run of the SAT tokenizer · An unterminated unary count is rejected · Stack embedding of the clause-check driver into the host · Stack embedding of the clause-length filter into the host · Stack embedding of the lookup into the clause-check driver · Stack embedding of the tokenizer into the host · Program of the SAT verifier host · The embedded lookup program · Driver stacks after tokenization · The tokenizer embeds in the SAT verifier host · The embedded lookup meets the lookup contract · Phase 0 of the SAT verifier host · Tokenizer stacks after phase 0 · The TM2 SAT verifier · Clause token length bound for the SAT verifier (moved alias) · Finiteness of the SAT verifier alphabet (moved alias) · Token length bound for the SAT verifier (moved alias) · Literal-marker test · Quiescent states of the 3-COLOR emitter · The 3-COLOR emitter machine · Unit symbol of a counter · Reading unary units · Stack alphabets of the 3-coloring emitter · Running a sequence of copy sites of the 3-COLOR emitter · The 3-COLOR emitter clears its OR-output counter · Name comparison in the 3-COLOR emitter · Encoding of an earlier occurrence on stack \(D\) · Moving \(U\) onto \(E\) · Copying a counter through \(W\) · Adding the vertex counter to the OR output · Walk tokens · Moving an earlier name from \(D\) to \(E\) · Moving an earlier literal vertex from \(D\) to \(U\) · Name of a variable · Moving the current name from \(T\) to \(A\) · Running a copy site of the 3-COLOR emitter · Skipping an earlier literal vertex · Stacks of a quiescent state · 3-COLOR emitter: moving the walk side back · One more token preserves the 3-COLOR emitter's size invariant · The 3-COLOR emitter processes one clause · The emitter state of a construction state · One step of the walk over earlier occurrences · The emitter on a list of clauses · Size invariant of the 3-coloring emitter · The emitter processes the remaining literals of a clause · The size invariant survives a new literal occurrence · Emitting one literal occurrence · Recording the current occurrence · Walking the earlier occurrences · Correctness and step bound of the 3-COLOR emitter · Edge-loop start of the 3-COLOR verifier · Load step of the 3-COLOR verifier · Moving one color code in the 3-COLOR verifier · The 3-COLOR verifier machine · Unary reader of the 3-COLOR verifier · One step of the 3-COLOR verifier · Statements of the 3-COLOR verifier · Interleaved updates of two stacks of the 3-COLOR verifier · One step of the joint walk of the 3-COLOR verifier · One step of the walk towards the farther endpoint · Restoring the color stack in the 3-COLOR verifier · The 3-COLOR verifier as a host component · Correctness and running time of the edge loop · Run of the load phase of the 3-COLOR verifier · The unary reader rejects an unterminated number · The unary reader on a terminated number · Correctness and time bound of the 3-coloring verifier machine · Moving one color code from the color stack · The color-moving block rejects on an empty color stack · Joint-walk step with both counters nonempty · Joint-walk step when the second endpoint counter runs out first · Joint-walk step when the first endpoint counter runs out first · Joint-walk step with both counters exhausted · Walk-on step with a unit on the counter · Walk-on step with the counter exhausted · The joint walk of the 3-COLOR verifier decides one edge · The walk towards the farther endpoint decides the edge · 3-COLOR is in NP · The 3-COLOR emitter · The SAT-to-3-COLOR reduction is polynomial-time · Run of the load phase · Load step of the CLIQUE verifier · Program of the clique verifier · The clique verifier's unary reader · Reading an unterminated unary number rejects · The clique verifier's unary reader succeeds · One row of the clique verifier's walk · All rows of the clique verifier's walk · The verifier machine for clique, independent set and vertex cover · One step of a clique-verifier program to a known label · Statements of the clique verifier · Walking the pairs of one row of the clique verifier · Walk step of the clique verifier · Rest of a walk step of the clique verifier · Polarity-first tokens of a literal · Tokens moved by the walk · Tokens of an item on the walked stack · Moving a walked name from \(D\) to \(E\) · Name bits of a variable in the CLIQUE emitter · CLIQUE emitter: reading a variable name · The CLIQUE emitter machine · Configuration stacks of the CLIQUE emitter · CLIQUE emitter: recognizing a standard state · Stack alphabets of the CLIQUE emitter · Clique emitter: moving the walk side back · Clique emitter: one clause · Clique emitter: comparing two names · Clique emitter: the instance prefix · Emitter run over a formula's clauses · Test for the input bit true · Test for the moved bit true · Emitter run over one literal occurrence · Emitter run over a clause's literals · CLIQUE emitter: putting the current occurrence on the walked stack · The CLIQUE emitter computes Karp's instance in cubic time · Counter unit symbol of the clique reduction machine · Stack alphabets of the clique reduction machine · Walk over the occurrence stack in the CLIQUE emitter · The CLIQUE emitter · CLIQUE ≤ INDEPENDENT-SET is polynomial-time · INDEPENDENT-SET ≤ VERTEX-COVER is polynomial-time · SAT ≤ CLIQUE is polynomial-time · The CLIQUE-to-INDEPENDENT-SET and INDEPENDENT-SET-to-VERTEX-COVER map as a host component · Moving the pair bits onto stack \(Y\) · Output phase of the KG-map machine · Output loop for the pair bits of the KG-map machine · The KG-map machine · Unterminated first unary number in the KG-map machine · Reading the first unary number in the KG-map machine · Unterminated second unary number in the KG-map machine · Reading the second unary number in the KG-map machine · Correctness and running time of the KG-map machine · Failed subtraction in the KG-map machine · Subtraction loop of the clique reduction machine · Number output of the clique reduction machine · The CLIQUE, INDEPENDENT-SET and VERTEX-COVER verifier as a host component · NP membership from the CLIQUE, INDEPENDENT-SET and VERTEX-COVER verifier · Raw-input SUBSET-SUM to PARTITION machine as a host component · SUBSET-SUM to PARTITION padding machine as a host component · Canonical PARTITION membership transducer as a host component · Padding machine embeds the summation machine · Membership transducer embeds the summation machine · SUBSET-SUM to PARTITION map is polynomial-time · Program of the raw-input SUBSET-SUM to PARTITION machine · Program of the SUBSET-SUM to PARTITION padding machine · Program of the canonical PARTITION membership transducer · Quadratic run of the raw-input SUBSET-SUM to PARTITION machine · Quadratic run of the padding machine on canonical instances · Raw-input PARTITION membership machine runs in quadratic time · Canonical PARTITION membership transducer runs in quadratic time · Summation-machine stack embedding in the padding machine · Summation-machine stack embedding in the membership transducer · Stack alphabets of the canonical PARTITION membership transducer · Test for the input bit true (SUBSET-SUM reduction machine) · Test for the value symbol true (SUBSET-SUM reduction machine) · Counter unit of the subset-sum emitter · Stack alphabets of the subset-sum emitter · Reading a pair bit or vertex mark · Edge-number phase (SUBSET-SUM reduction machine) · One halving step of the binary conversion (SUBSET-SUM reduction machine) · Testing a popped input bit · Testing a popped input bit · Testing a popped input bit · Subset-sum emitter: moving the pair bits · Subset-sum emitter: one row of the pair walk · The subset-sum emitter machine · Subset-sum emitter: unterminated unary prefix at rdK · Subset-sum emitter: reading the unary k · Subset-sum emitter: unterminated unary prefix at rdN · Subset-sum emitter: reading the unary n · Subset-sum emitter: one vertex number · Subset-sum emitter: moving unmarked vertices back to L · Run of the mark-return loop of the subset-sum emitter · Run of the pair-counting loop of the subset-sum emitter · Run of the vertex-number phase of the subset-sum emitter · Run of the subset-sum emitter's pair walk · Binary conversion (SUBSET-SUM reduction machine) · Run of the VERTEX-COVER to SUBSET-SUM machine · Statements of the SUBSET-SUM verifier · Run of the target-bit loop of the subset-sum emitter · Run of the target-output phase of the subset-sum emitter · The verifier rejects an unterminated chosen block · The verifier rejects a chosen block that ends in false · Adding a canonical chosen block · Adding one payload bit to the sum · Moving the new sum back · Comparing the sum with the target · Carry phase of the SUBSET-SUM verifier · Carry step of the SUBSET-SUM verifier · Moving the final sum for the comparison · Starting the next number · The SUBSET-SUM verifier program · Reading one pair of a block · Rejection by the SUBSET-SUM verifier within a step bound · Rejecting in one step · The verifier rejects an unterminated skipped block · Skipping a number block · Stack contents of the SUBSET-SUM verifier · The verifier rejects an unterminated target block · Reading the target block · The VERTEX-COVER to SUBSET-SUM machine as a host component · Identity embedding of the verifier stacks · The VERTEX-COVER to SUBSET-SUM reduction is polynomial-time · The summing loop of the SUBSET-SUM verifier · Binary addition program built on the SUBSET-SUM machine · The SUBSET-SUM verifier machine · Binary addition of framed numbers in quadratic time · The SUBSET-SUM verifier machine as a host component · SUBSET-SUM is in NP · SUBSET-SUM verifier computes the mask-selected sum · Embedded SUBSET-SUM summing component reaches the mapped label · Embedded run of the binary addition component · Unit symbol of an emitter counter · Stack alphabets of the HAMPATH emitter · HAMPATH emitter, phase A: moving the walk stack back onto the variable stack · HAMPATH emitter, phase A: copying a reversed name onto two stacks · HAMPATH emitter, phase A: searching the variable stack for a name · A symbol that reads as a name bit is that bit · Running a chain of copy sites in the HAMPATH emitter · Comparing a name with the top entry of the variable stack · Copying a counter in the HAMPATH emitter · Variable-stack symbols of the HAMPATH emitter · Quiescent states of the HAMPATH emitter · Name of a variable in the HAMPATH emitter · The HAMPATH emitter machine · Run of a HAMPATH copy site · Stacks of a quiescent emitter state · Variable stack of the HAMPATH emitter · HAMPATH emitter, phase A: one clause · HAMPATH emitter, phase A: the clauses of a formula · HAMPATH emitter, phase A: one literal · HAMPATH emitter, phase A: the literals of a clause · One clause of the detour walk · Front of a diamond · The emitter state before the diamonds · One literal of the detour walk · The literals of a clause in the detour walk · The row loop of a diamond in the HAMPATH emitter · The detour walk of a diamond in the HAMPATH emitter · Initial state of the HAMPATH emitter · Token symbols of the HAMPATH emitter · The tokens of a literal do not start with a clause end · Phase A of the HAMPATH emitter · Moving the tokens back in the HAMPATH emitter · End of a diamond · The detours of a diamond · One diamond · The diamonds · The row of a diamond in the HAMPATH emitter · The output phase of the HAMPATH emitter · Correctness and running time of the HAMPATH emitter · Step of the HAMPATH verifier's unary comparison loop · Emptiness test · The unary reader of the Hamiltonian path verifier · The unary mover of the Hamiltonian path verifier · Statements of the Hamiltonian-path verifier · Extending a reversed unary block · Run of the HAMPATH verifier's unary comparison loop · Run of a HAMPATH-verifier counter comparison · HAMPATH-verifier unary comparison with the counter restored · One step of the emptiness test · Moving a stack of bits · The Hamiltonian path verifier machine · The unary reader of the Hamiltonian path verifier rejects an unterminated number · The unary reader of the Hamiltonian path verifier reads a terminated number · The edge scan of the Hamiltonian path verifier · The unary mover of the Hamiltonian path verifier rejects an unterminated number · The unary mover of the Hamiltonian path verifier moves a terminated number · A single step of the Hamiltonian-path verifier · Interleaved stack updates in the Hamiltonian-path verifier · The edge-list check of the Hamiltonian-path verifier · The witness check of the Hamiltonian-path verifier · The HAMPATH emitter · HAMPATH is in NP · The HAMPATH verifier as a host component · Running the head-or-edge check · SAT ≤ HAMPATH is polynomial-time · Stack layout between vertex steps · Running the vertex loop · Stack layout during a vertex step · The repeat scan of the Hamiltonian path verifier · Correctness and running time of the Hamiltonian path verifier · One vertex step of the Hamiltonian-path verifier · The rest of a vertex step in the Hamiltonian-path verifier · The return phase ends on an empty side stack · The 3SAT filter's return phase moves the side stack back · One step of the 3SAT filter's return phase · A clause with more than three literals makes the capped 3SAT filter fail · The 3SAT filter walks one clause within the cap · The 3SAT emitter processes one clause · A long clause makes the capped 3SAT filter fail on a list of clauses · The 3SAT filter walks a list of clauses within the cap · The tokenize-then-emit machine as a host component · Name copy loop of the 3SAT emitter · Embedding the tokenizer's stacks into tokenize-then-emit · The SAT-to-3SAT emitter · Emitter · The 3SAT emitter processes a whole formula · Fresh-literal subroutine of the 3SAT emitter · The 3SAT emitter reads a literal marker · Initial stacks of the tokenize-then-emit machine · Literal-marker test of the 3SAT emitter · Emitter reductions out of SAT are polynomial-time · The SAT-to-3SAT reduction is polynomial-time · Token symbols of the 3SAT filter · One literal of the emitter · The capped filter fails on a clause with too many literals · The filter walks a clause's literals within the cap · The literals of a clause in the emitter · Conditional move between stacks · Copying a renamed name · The SAT-to-3SAT emitter machine · The clause-length filter program · Program of the tokenize-then-emit machine · The SAT-to-3SAT emitter writes the encoded translation in quadratic time · Correctness of the clause-length filter · Tokenize, then emit · Stack contents of the SAT-to-3SAT emitter · Filter stacks from two lists · Statements of the filter · Closing an output clause in the SAT-to-3SAT emitter · Label after a token · Initial stacks of the tokenizer · Stack alphabets of the SAT-to-3SAT emitter · Alphabets of the tokenize-then-emit machine · One step of the clause-length walk · Walking over name bits keeps the label · An empty token stack ends the walk · Walking over a literal advances the literal count · A capped walk fails on a literal past the third · One step of the clause-length walk on a token · Reading the mark of vertex \(j\) · The edge loop of a pass · The marking algorithm is polynomial-time · The counter unit of the PATH marking machine · The pass loop of the marking machine · The marking machine as a host component · The marking machine for PATH · The unary read instruction · Reading a cut-off unary number · Reading a unary number · Reading the mark of a vertex · Restoring the parked marks · Running time and output of the marking machine · Mark-setting step · Walking to a vertex and setting its mark · Effect of the mark-setting step · A walk step with an exhausted counter · Stack alphabets of the PATH marking machine · Validation phase of the PATH marking machine · Walking along the marks of the PATH marking machine · Walk step of the PATH marking machine

DefinitionReading a symbol as a name bit#✓fully proved

A symbol of the token and table stacks that is the name bit \(b\) reads as the bit \(b\); every other symbol reads as no bit, and so ends a name block.

def Sym.bit? : Sym → Option Bool
  | .bit b => some b
  | _ => none
Uses 1 · Used by 135
Used byProgram of the unary-to-binary converter · Converter turns a unary count into a canonical binary frame · Converter turns a unary count into a raw canonical binary payload · The clause-check driver · Literal loop of the clause check · The lookup contract · The lookup program · The return loop of the lookup machine · A name bit reads as itself · Serving a live table entry · One scan step of the lookup · The tokenizer program · Correctness of the SAT-verifier lookup machine · The scan loop of the lookup machine · Restoring and stashing after a comparison in the lookup machine · Tokenizer rejects an undecodable literal · Rejecting an unterminated name block · Reading a name block · Reading a polarity · Program of the SAT verifier host · The tokenizer embeds in the SAT verifier host · The embedded lookup meets the lookup contract · Phase 0 of the SAT verifier host · The 3-COLOR emitter machine · Name comparison in the 3-COLOR emitter · Moving an earlier name from \(D\) to \(E\) · Moving the current name from \(T\) to \(A\) · The 3-COLOR emitter processes one clause · One step of the walk over earlier occurrences · The emitter processes the remaining literals of a clause · Emitting one literal occurrence · Recording the current occurrence · Walking the earlier occurrences · Load step of the 3-COLOR verifier · Moving one color code in the 3-COLOR verifier · The 3-COLOR verifier machine · Unary reader of the 3-COLOR verifier · Restoring the color stack in the 3-COLOR verifier · Run of the load phase of the 3-COLOR verifier · The unary reader rejects an unterminated number · The unary reader on a terminated number · Correctness and time bound of the 3-coloring verifier machine · Moving one color code from the color stack · The color-moving block rejects on an empty color stack · The joint walk of the 3-COLOR verifier decides one edge · The walk towards the farther endpoint decides the edge · Run of the load phase · Load step of the CLIQUE verifier · Program of the clique verifier · The clique verifier's unary reader · Reading an unterminated unary number rejects · The clique verifier's unary reader succeeds · One row of the clique verifier's walk · All rows of the clique verifier's walk · Walking the pairs of one row of the clique verifier · Walk step of the clique verifier · Rest of a walk step of the clique verifier · Moving a walked name from \(D\) to \(E\) · CLIQUE emitter: reading a variable name · The CLIQUE emitter machine · Clique emitter: one clause · Clique emitter: comparing two names · Emitter run over one literal occurrence · Emitter run over a clause's literals · CLIQUE emitter: putting the current occurrence on the walked stack · Walk over the occurrence stack in the CLIQUE emitter · Padding machine embeds the summation machine · Membership transducer embeds the summation machine · Program of the SUBSET-SUM to PARTITION padding machine · Program of the canonical PARTITION membership transducer · Quadratic run of the raw-input SUBSET-SUM to PARTITION machine · Quadratic run of the padding machine on canonical instances · Raw-input PARTITION membership machine runs in quadratic time · Canonical PARTITION membership transducer runs in quadratic time · The verifier rejects an unterminated chosen block · The verifier rejects a chosen block that ends in false · Adding a canonical chosen block · Adding one payload bit to the sum · Moving the new sum back · Comparing the sum with the target · Carry phase of the SUBSET-SUM verifier · Carry step of the SUBSET-SUM verifier · Moving the final sum for the comparison · Starting the next number · The SUBSET-SUM verifier program · Reading one pair of a block · The verifier rejects an unterminated skipped block · Skipping a number block · The verifier rejects an unterminated target block · Reading the target block · The summing loop of the SUBSET-SUM verifier · Binary addition program built on the SUBSET-SUM machine · Binary addition of framed numbers in quadratic time · SUBSET-SUM verifier computes the mask-selected sum · HAMPATH emitter, phase A: copying a reversed name onto two stacks · HAMPATH emitter, phase A: searching the variable stack for a name · A symbol that reads as a name bit is that bit · Comparing a name with the top entry of the variable stack · The HAMPATH emitter machine · HAMPATH emitter, phase A: one clause · HAMPATH emitter, phase A: one literal · HAMPATH emitter, phase A: the literals of a clause · One literal of the detour walk · Moving the tokens back in the HAMPATH emitter · End of a diamond · The output phase of the HAMPATH emitter · Step of the HAMPATH verifier's unary comparison loop · The unary reader of the Hamiltonian path verifier · The unary mover of the Hamiltonian path verifier · Run of the HAMPATH verifier's unary comparison loop · Moving a stack of bits · The Hamiltonian path verifier machine · The unary reader of the Hamiltonian path verifier rejects an unterminated number · The unary reader of the Hamiltonian path verifier reads a terminated number · The unary mover of the Hamiltonian path verifier rejects an unterminated number · The unary mover of the Hamiltonian path verifier moves a terminated number · The 3SAT emitter processes one clause · Name copy loop of the 3SAT emitter · One literal of the emitter · The literals of a clause in the emitter · Copying a renamed name · The SAT-to-3SAT emitter machine · Reading the mark of vertex \(j\) · The pass loop of the marking machine · The marking machine for PATH · The unary read instruction · Reading a cut-off unary number · Reading a unary number · Reading the mark of a vertex · Restoring the parked marks · Running time and output of the marking machine · Walking to a vertex and setting its mark · A walk step with an exhausted counter · Walking along the marks of the PATH marking machine · Walk step of the PATH marking machine

DefinitionTokens of a literal#✓fully proved

For a literal \((n, p)\) with variable index \(n\) and polarity \(p\), the token list is one bit symbol for each bit of the canonical binary representation of \(n\) (least significant bit first, empty for \(n = 0\)), in order, followed by the polarity marker symbol for \(p\).

def litToks (l : ℕ × Bool) : List Sym := (encodeNat l.1).map .bit ++ [.lit l.2]
Uses 1 · Used by 22

DefinitionTokens of a clause#✓fully proved

The tokens of a CNF clause are the tokens of its literals, in order, followed by the clause-end symbol.

def clauseToks (C : CNFClause) : List Sym := C.flatMap litToks ++ [.cl]
Uses 3 · Used by 23

DefinitionToken sequence of a CNF formula#✓fully proved

For a CNF formula \(\varphi\) with clauses \(C_1, \dots, C_k\) (in order), the token sequence of \(\varphi\) is the concatenation of the token sequences of \(C_1, \dots, C_k\). The token sequence of a clause is the concatenation of the token sequences of its literals, in order, followed by a clause-end symbol; the token sequence of a literal with variable index \(n \in \mathbb{N}\) and polarity \(p\) is the bits of the binary encoding of \(n\) (Mathlib's encodeNat), each as a name-bit symbol, followed by a polarity marker for \(p\).

The verifier's token stack holds this sequence in reverse order.

def toks (φ : CNF) : List Sym := φ.flatMap clauseToks
Uses 4 · Used by 29

DefinitionClosing marker of a table entry#✓fully proved

The marker closing a table entry whose value is the boolean \(b\) is the value symbol for \(b\); for an entry with no value it is the dead symbol.

def markOf : Option Bool → Sym
  | some b => .val b
  | none => .dead
Uses 1 · Used by 7

DefinitionSymbols of a table entry#✓fully proved

The symbols of a table entry with name \(q\) and value \(v\) are the bits of \(q\) as name-bit symbols, in order, followed by one closing marker: the value marker of \(b\) if \(v\) is a bit \(b\), and the dead marker if \(v\) is absent.

def entToks (e : Ent) : List Sym := e.1.map .bit ++ [markOf e.2]
Uses 3 · Used by 10

DefinitionTable stack of an entry list#✓fully proved

Write each table entry as one bit symbol per bit of its name followed by its closing marker (the value symbol for its value, or the dead symbol if it has no value), and concatenate these in the order of the list. The table stack is the reverse of this sequence, with the head as the top of the stack, so the first entry lies at the bottom.

def tblStk (es : List Ent) : List Sym := (es.flatMap entToks).reverse
Uses 3 · Used by 18

DefinitionOccurrence table of a list of variables#✓fully proved

Given natural numbers \(n_0, \dots, n_{k-1}\) and a list \(w\) of bits, the occurrence table is the list of \(k\) table entries whose \(i\)-th entry has as name the binary code of \(n_i\) (Mathlib's encoding of natural numbers as bit lists) and as value the bit \(w_i\) if \(i\) is less than the length of \(w\), and no value otherwise.

def entsOf : List ℕ → List Bool → List Ent
  | [], _ => []
  | n :: ns, [] => (encodeNat n, none) :: entsOf ns []
  | n :: ns, b :: bs => (encodeNat n, some b) :: entsOf ns bs
Uses 1 · Used by 11

DefinitionOccurrence table of a formula and a witness#✓fully proved

Let \(\varphi\) be a CNF formula, \(w\) a list of booleans, and \(n_0, \dots, n_{k-1}\) the variable indices of the literals of \(\varphi\) in reading order, with repetitions. The occurrence table is the list of \(k\) entries whose \(i\)-th entry pairs the binary name of \(n_i\) (its canonical binary representation, least significant bit first, empty for \(0\)) with the value \(w_i\) if \(i\) is less than the length of \(w\), and with no value otherwise.

def ents (φ : CNF) (w : List Bool) : List Ent := entsOf (varsOf φ) w
Uses 4 · Used by 10

DefinitionLive value of a name in a table#✓fully proved

Given a list of table entries, each pairing a name (a bit string) with either a boolean value or no value, and a bit string \(q\), the live value of \(q\) is the value of the first entry whose name is \(q\) and which carries a value, or false if there is no such entry.

def liveVal (es : List Ent) (q : List Bool) : Bool :=
  (es.findSome? fun e => if e.1 = q then e.2 else none).getD false
Uses 1 · Used by 11

DefinitionClause check against an occurrence table#✓fully proved

For a CNF formula \(\varphi\) and a list \(es\) of table entries, the clause check is true exactly when every clause of \(\varphi\) contains a literal \((x, p)\) whose live value equals its polarity \(p\). Here the live value of \(x\) is the value of the first entry of \(es\) that is named by the binary code of \(x\) and has a value, and false if there is no such entry.

def checkSpec (φ : CNF) (es : List Ent) : Bool :=
  φ.all fun C => C.any fun l => liveVal es (encodeNat l.1) == l.2
Uses 4 · Used by 7

DefinitionTokenizer of the SAT verifier#✓fully proved

Given bit strings \(x\) and \(w\), the tokenizer rejects (returns no result) if \(x\) does not decode to a CNF formula. If \(x\) decodes to a formula \(\varphi\), it returns the pair consisting of the token stack, the reverse of the tokens of \(\varphi\) in reading order, and the table stack of the occurrence table of \(\varphi\) and \(w\).

def tokenize (x w : List Bool) : Option (List Sym × List Sym) :=
  (decodeCNF x).map fun φ => ((toks φ).reverse, tblStk (ents φ w))
Uses 6

TheoremThe binary code of natural numbers is injective#✓fully proved

For natural numbers \(m\) and \(n\), the binary codes of \(m\) and \(n\) (Mathlib's encoding of natural numbers as bit lists) are equal if and only if \(m = n\).

theorem encodeNat_inj {m n : ℕ} : encodeNat m = encodeNat n ↔ m = n
Used by 6

TheoremCanonical binary names#✓fully proved

For every list \(l\) of bits, encoding the natural number that \(l\) decodes to (Mathlib's binary code of natural numbers, least significant bit first) gives back \(l\) if and only if \(l\) is empty or its last bit is true.

theorem encodeNat_decodeNat_eq_iff (l : List Bool) :
    encodeNat (decodeNat l) = l ↔ l = [] ∨ l.getLast? = some true
Used by 2

TheoremTable lookup agrees with the verifier's variable lookup#✓fully proved

Let \(n = (n_0, \dots, n_{k-1})\) be a list of natural numbers, \(w\) a list of booleans and \(x\) a natural number. Write \([m]\) for the binary name of a natural number \(m\): its canonical binary representation, least significant bit first, empty for \(m = 0\). Form the table whose \(i\)-th entry, for \(i < k\), pairs \([n_i]\) with \(w_i\) if \(i\) is less than the length of \(w\), and with no value otherwise. Then the live value of \([x]\) in this table (the value of the first entry named \([x]\) that carries a value, or false if there is none) equals the return value of the verifier's lookup of \(x\) in the lists \(n\) and \(w\): the value \(w_i\) for the first \(i\) below both \(k\) and the length of \(w\) with \(n_i = x\), or false if there is none.

theorem liveVal_entsOf (ns : List ℕ) (w : List Bool) (x : ℕ) :
    liveVal (entsOf ns w) (encodeNat x) = (lookupVar ns w x).ret
Uses 5 · Used by 1

TheoremThe clause check on the occurrence table is the formula check#✓fully proved

For every CNF formula \(\varphi\) and every list \(w\) of bits, the clause check of \(\varphi\) against the occurrence table of \(\varphi\) and \(w\) equals the value returned (ignoring the time count) by the formula check of \(\varphi\) against \(w\) that uses the variable occurrences of \(\varphi\), in order, as its variable list.

theorem checkSpec_ents (φ : CNF) (w : List Bool) :
    checkSpec φ (ents φ w) = (checkCNF (varsOf φ) w φ).ret
Uses 12 · Used by 1

TheoremThe SAT verifier's answer through the occurrence table#✓fully proved

For all lists \(x\) and \(w\) of bits, the value returned by the SAT verifier on \((x, w)\), ignoring the time count, is false if the complete length-prefixed CNF decoder fails on \(x\), and is the clause check of \(\varphi\) against the occurrence table of \(\varphi\) and \(w\) if \(x\) decodes to the CNF formula \(\varphi\).

theorem satVerifier_ret_eq (x w : List Bool) :
    (satVerifier (x, w)).ret = ((decodeCNF x).map fun φ => checkSpec φ (ents φ w)).getD false
Uses 10 · Used by 2

TheoremA clause has at most as many tokens as code bits#✓fully proved

For every CNF clause \(C\), the number of tokens of \(C\) is at most the length of the binary code of \(C\).

theorem clauseToks_length_le (C : CNFClause) :
    (clauseToks C).length ≤ (encodeClause C).length
Uses 7 · Used by 2
20 fully proved

The dependency explorer needs JavaScript and its graph data.

Download the complete graph data.