Unreachability as 2SAT #
An instance I of directed s–t connectivity becomes the formula
Cslib.Complexity.TwoSAT.reachabilityFormula I whose variables are the vertices: the unit
clauses x_s and ¬x_t, and a clause ¬x_u ∨ x_v for each arc from u to v. In a satisfying
assignment every vertex reachable from s is true, so t is not reachable; conversely, making
exactly the reachable vertices true satisfies the formula when t is not reachable
(Cslib.Complexity.TwoSAT.reachabilityFormula_mem_TwoSAT_iff). This is the reduction from the
complement of reachability in the proof that 2SAT is NL-complete
Papadimitriou, Theorem 16.3.
The formula is written in logarithmic space by a counter program with output
(Cslib.Complexity.TwoSAT.writer), which reads the header of the encoded instance and then the
matrix entry by entry, keeping the header values, two vertices and a copy of one of them whose
binary digits it writes (Cslib.Complexity.TwoSAT.computableInLogSpace_reachabilityFormula).
Main definitions #
Cslib.Complexity.TwoSAT.reachabilityFormula: the formula of an instance.Cslib.Complexity.TwoSAT.writer: the counter program writing its encoding.
Main results #
Cslib.Complexity.TwoSAT.reachabilityFormula_mem_TwoSAT_iff: the formula is inTwoSATexactly whentis not reachable froms.Cslib.Complexity.TwoSAT.computableInLogSpace_reachabilityFormula: the formula is computed in logarithmic space.
References #
The arcs of an instance on natural numbers, with no arc outside the vertices.
Instances For
The formula of an instance: a variable for each vertex, true when the vertex is reachable
from s; the unit clauses x_s and ¬x_t, and the clause ¬x_u ∨ x_v for each arc from u to
v, row by row.
Instances For
The formula is in TwoSAT exactly when t is not reachable from s.
The writer #
The code writing the literal of register r with the polarity sign, placed at the label
b, through register 5, and continuing at exit: the digits of the register, least
significant first, each after seven markers, then the fixed end of the literal.
Instances For
The code of a literal writes it, through register 5, which ends at 0.
The encoding of the formula #
The encoded formula: the two unit clauses, then the clauses of the arcs row by row.
The program #
The writer of the encoded formula, on the encoded instance. Registers 0, 1 and 2
receive the header values n, s and t; registers 3 and 4 run over the rows and columns
of the matrix; register 5 holds the number whose digits are written. Labels 0 to 5 read the
header, labels 6 to 53 write the unit clauses, the nested loops at labels 54 and 57 write
the clause of every arc, and label 108 halts.
Instances For
The formula is computed in logarithmic space from the encoded instance.