Documentation

CslibFrontier.Algorithms.WordRAM.LRAT.Program

An LRUP (RUP-only LRAT) checker on the word RAM: encoding and program #

This file states the input encoding and the program of a word-RAM LRUP (RUP-only LRAT) checker that agrees with Cslib.Logic.PL.CNF.checkLRUP (accepting RUP additions, empty-clause steps and deletions, and rejecting RAT steps; full LRAT with RAT steps CNF.checkLRATRat is not checked here).

Encoding #

A literal (v, b) is the word 2 v + b (Cslib.Algorithms.WordRAM.ClauseCode.litCode), and a clause is its length followed by the codes of its literals (Cslib.Algorithms.WordRAM.ClauseCode.encodeClause), the encoding the word-RAM Schöning scan uses. The input is the number of clauses of the formula, the clauses, then the steps of the certificate (Cslib.Algorithms.WordRAM.LRAT.encode). A step is a tag followed by its fields:

The encoding keeps exactly what checkLRUP reads: it drops the number of an empty-clause step and the contents of a RAT step, which the checker rejects, and it encodes a clause of DIMACS integers by the literals Cslib.Logic.PL.Clause.ofDIMACS names, dropping 0s.

Memory #

With the input of length L at addresses 1, …, L, let T = L + 1. The clause numbered i is found through the table cell T + 2 i, which holds the address of its encoding (0 when there is none); formula clauses and added clauses are both read in place in the input. The literal with code c is true in the current step when the cell T + 2 c + 1 holds the current step's stamp. The assignment is indexed by literal rather than by variable because the trail of checkLRUP may hold a literal and its negation at once, when an added clause is a tautology. The stamp starts at 1 and increases after every accepted step, so the assignment never needs to be cleared, and since word-RAM memory starts at zero (Cslib.WordRAM.Data.init), neither the table nor the assignment needs to be initialised.

Main definitions #

Its correctness and instruction bound are Cslib.Algorithms.WordRAM.LRAT.program_spec.

Encoding #

A list of numbers is stored as its length followed by its entries.

The words of a certificate step; see the module docstring.

The input of the checker: the number of clauses of φ, its clauses, and the steps of cert.

Registers #

@[reducible, inline]

Constant 0.

@[reducible, inline]

Constant 1.

@[reducible, inline]

Constant 2, the tag of a RAT step.

@[reducible, inline]

Constant 3, the tag of a deletion.

@[reducible, inline]

One past the last input address.

@[reducible, inline]

The base T of the table and the assignment.

@[reducible, inline]

The input cursor.

@[reducible, inline]

The number of formula clauses.

@[reducible, inline]

Loop counter.

@[reducible, inline]

A clause number.

@[reducible, inline]

A length read from the input.

@[reducible, inline]

The stamp of the current step.

@[reducible, inline]

Output.

@[reducible, inline]

The tag of the current step.

@[reducible, inline]

End of the hints of the current step.

@[reducible, inline]

The current hint.

@[reducible, inline]

Scratch address.

@[reducible, inline]

Address of the hinted clause.

@[reducible, inline]

Address of the current literal.

@[reducible, inline]

End address of the current clause.

@[reducible, inline]

The current literal code.

@[reducible, inline]

Scratch value.

@[reducible, inline]

Whether a non-false literal was found in the hinted clause.

@[reducible, inline]

The non-false literal found.

@[reducible, inline]

Whether two different non-false literals were found.

@[reducible, inline]

The result of unit propagation.

@[reducible, inline]

Address of the encoding of the clause added by the current step.

@[reducible, inline]

The complementary literal code.

Unit propagation along hints #

One literal of a hinted clause: skip it when false, and otherwise record it as the unit, or note a second, different non-false literal.

Scan the clause at cl: its non-false literals are none (has = 0), all equal to unit (has = 1, bad = 0), or not all equal (bad = 1).

After scanning a hinted clause: a conflict ends propagation with success, a unit is assigned, and anything else ends propagation with failure.

One hint: look up its clause; a missing clause ends propagation with failure.

Unit propagation along the hints at ptr, which start with their number: res is 1 exactly when propagation reaches a conflict, and ptr ends past the hints.

Steps #

Assume the negation of a literal of the added clause.

Assume the negations of the literals in [lptr, lend).

An empty-clause step: its result is the answer.

A RUP step: assume the negated clause, propagate, and on success record the clause's address in the table and advance the stamp.

One deleted clause number: clear its table cell.

One step of the certificate, dispatched on its tag.

The steps in [ptr, endp); running out of steps leaves the output 0.

The checker #

One formula clause: record its address under the next clause number.

Set up the registers: constants, the end of the input, the table base, and the cursor at the first clause.

The LRAT checker on the input encode φ cert, leaving its answer in out.

The LRAT checker as a flat program halting with out.