Documentation

CslibFrontier.Algorithms.WordRAM.ClauseCode

Clauses as words #

The word-RAM SAT programs store a literal (v, b) as the word 2 f(v) + b, where f numbers the variables (Cslib.Algorithms.WordRAM.ClauseCode.litCodeBy), and a clause as its length followed by the codes of its literals (Cslib.Algorithms.WordRAM.ClauseCode.encodeClauseBy). The variable's number of a code is its shift right by one bit and the sign its low bit, so for injective f the codes determine the literals (Cslib.Algorithms.WordRAM.ClauseCode.litCodeBy_injective), and flipping the low bit negates the literal (Cslib.Algorithms.WordRAM.ClauseCode.litCodeBy_xor_one).

Programs over the variables ℕ, such as the LRAT checker, number them by id (Cslib.Algorithms.WordRAM.ClauseCode.litCode, Cslib.Algorithms.WordRAM.ClauseCode.encodeClause); programs over Fin n, such as Schöning's and PPSZ's, by Fin.val.

Main definitions #

Main results #

@[inline]

The word code 2 f(v) + b of the literal (v, b). Inlined, so that compiled code computes the code without a call through f.

A clause is stored as its length followed by the codes of its literals.

@[reducible, inline]

The code of a literal over the variables ℕ.

@[reducible, inline]

The words of a clause over the variables ℕ.

Shifting a literal code right recovers the number of its variable.

The low bit of a literal code is its sign.

theorem Cslib.Algorithms.WordRAM.ClauseCode.litCodeBy_le {α : Type u_1} (f : α → ℕ) (l : Logic.PL.Literal α) :
litCodeBy f l ≤ 2 * f l.1 + 1

A literal code is at most twice the number of its variable plus one.

The codes determine the literals when f is injective.

The codes of literals over ℕ determine the literals.

Flipping the low bit negates: the code of the negation of a literal.

Negating a literal raises its code by at most one.