2SAT is in PTIME, by a Horn program for the implication graph #
2SAT is SO-Horn definable (DescriptiveComplexity.twoSat_sigmaSOHornDefinable), hence in
DescriptiveComplexity.PTIME. This is what makes the inclusion NL ⊆ PTIME available:
the inclusion has no syntactic route, a Krom kernel not being a Horn kernel, so
it goes through the complete problem of the Krom fragment.
The program guesses the reachability relation of the implication graph
(DescriptiveComplexity.TwoSatImpl), as one binary relation variable per pair of
signs, and constrains it by Horn clauses:
- reflexivity, and transitivity
Reach s t x y ∧ Reach t r y z → Reach s r x z; - one clause per pair of signs whose guard recognizes a clause covered by the
occurrences
(x, s)and(y, u), emitting the two implicationsReach (!s) u x yandReach (!u) s y x– the edges of the implication graph; - the goal clauses:
Reach s (!s) x x ∧ Reach (!s) s x x → ⊥(no variable reaches its own negation and back), plus the two guards that reject an empty clause and a violated width promise.
An assignment satisfies the program exactly when it contains reachability and
has no bad cycle, so correctness is the classical criterion
DescriptiveComplexity.TwoSatImpl.satisfiable_of_no_bad_cycle in one direction and
DescriptiveComplexity.TwoSatImpl.no_bad_cycle_of_satisfiable in the other.
Note the shape of the argument: the acceptance condition of 2SAT is negative ("no bad cycle"), which a Horn program can state because a goal clause is exactly a negative constraint on the guessed relation.
The block and its atoms #
The block of the Horn program: one binary relation variable per pair of
signs, holding reachability in the implication graph. An abbrev, so that the
arity reduces when tuples are written as ![x, y].
Equations
Instances For
Dependency graph
The atom Reach s t (v i) (v j).
Instances For
Dependency graph
Reachability as read off an assignment of the block.
Instances For
Dependency graph
Dependency graph
The guards over four variables #
The membership program of DescriptiveComplexity.Problems.TwoSat.Membership uses three
universally quantified variables (c, x, y); this program needs a fourth
one for transitivity, so its covering-pair guard is that formula relabelled.
The injection of the three variables of the covering-pair guard into the four variables of this program.
Equations
Instances For
Dependency graph
The covering-pair guard, over four variables.
Equations
Instances For
Dependency graph
The covering-pair guard says exactly that the clause v 0 is covered by
the occurrences (v 1, s) and (v 2, u).
Dependency graph
The program #
Reflexivity of reachability.
Equations
- DescriptiveComplexity.TwoSatHorn.reflClause s = { guard := ⊤, body := [], head := some (DescriptiveComplexity.TwoSatHorn.reachAtom s s 1 1) }
Instances For
Dependency graph
The implication ¬ℓ(x, s) → ℓ(y, u) of a clause covered by (x, s) and
(y, u).
Equations
- DescriptiveComplexity.TwoSatHorn.edgeClause₁ s u = { guard := DescriptiveComplexity.TwoSatHorn.pairGuard4 s u, body := [], head := some (DescriptiveComplexity.TwoSatHorn.reachAtom (!s) u 1 2) }
Instances For
Dependency graph
The implication ¬ℓ(y, u) → ℓ(x, s) of the same clause.
Equations
- DescriptiveComplexity.TwoSatHorn.edgeClause₂ s u = { guard := DescriptiveComplexity.TwoSatHorn.pairGuard4 s u, body := [], head := some (DescriptiveComplexity.TwoSatHorn.reachAtom (!u) s 2 1) }
Instances For
Dependency graph
Transitivity of reachability.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Dependency graph
The goal clause forbidding a bad cycle: a variable reaching its own negation and back.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Dependency graph
The goal clause rejecting an empty clause.
Equations
- DescriptiveComplexity.TwoSatHorn.emptyGoal = { guard := DescriptiveComplexity.SatOcc.emptyClF 0, body := [], head := none }
Instances For
Dependency graph
The goal clause rejecting a violated width promise.
Equations
- DescriptiveComplexity.TwoSatHorn.wideGoal = { guard := DescriptiveComplexity.wideTwoOrdF, body := [], head := none }
Instances For
Dependency graph
The Horn program defining 2SAT: reachability in the implication graph,
constrained to have no bad cycle. The sign combinations are spelled out, so
that membership of a clause is decided by simp.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Dependency graph
Dependency graph
Dependency graph
Dependency graph
Dependency graph
Dependency graph
Dependency graph
Dependency graph
A yes-instance satisfies the program #
The assignment induced by the actual reachability relation.
Equations
Instances For
Dependency graph
Dependency graph
Dependency graph
Dependency graph
Dependency graph
Dependency graph
Dependency graph
Dependency graph
Dependency graph
A yes-instance satisfies the program: the reachability relation itself is a satisfying assignment.
Dependency graph
A satisfying assignment describes a yes-instance #
A satisfying assignment contains reachability: it is closed under the reflexivity, edge and transitivity clauses.
Dependency graph
A satisfying assignment makes the instance a yes-instance.
Dependency graph
Correctness of the program: it is satisfiable exactly on the yes-instances of 2SAT.
Dependency graph
2SAT is SO-Horn definable: guess the reachability relation of the
implication graph, constrain it by reflexivity, the clause edges and
transitivity, and reject the instances where a variable reaches its own
negation and back. Since PTIME is defined as SO-Horn definability, this is
the statement TwoSAT ∈ PTIME.