Documentation

CslibFrontier.Algorithms.WordRAM.TwoSAT

Linear-time 2-SAT on the word RAM #

The Aspvall–Plass–Tarjan linear-time 2-SAT decision and satisfying-assignment algorithm on the standard-basis word RAM (Cslib.WordRAM.Basis.standard), running in O(n + |φ|) instructions on formulas φ : CNF (Fin n).

Representation #

An instance (Cslib.Algorithms.WordRAM.TwoSAT.Instance) consists of a variable count n : ℕ and a formula φ : CNF (Fin n). Its input word list (Instance.encode) stores n, the clause count |φ|, and each clause via Cslib.Algorithms.WordRAM.ClauseCode.encodeClauseBy Fin.val (its length followed by literal codes 2 * v.val + b.toNat).

Under Cslib.WordRAM.ExecutesList, the output word list (answerWords G) is:

The implication graph is built in compressed sparse row form in the scratch layout of CslibFrontier.Algorithms.WordRAM.DFS, whose sccIndexCode computes the topological component index of every literal (forward iterative DFS, CSR transposition, and Kosaraju peeling).

Main definitions #

Main results #

References #