2

For some restricted classes of logical formulae, the satisfiability problem can be solved efficiently in polynomial time or even linear. One such class is that of Horn formulae, which consist only of Horn clauses with at most one positive literal. I've heard that it is possible to solve Horn SAT in linear time using graphs, but couldn't find any implementation of such solution. Now I'm really interested whether it is possible and if it is, how would algorithm look like?

Meta
  • 25
  • 3

1 Answers1

2

If you're familiar with Davis–Putnam–Logemann–Loveland, Horn clauses are a class of formulae that can be solved using one round of unit propagation, with no backtracking.

In graph terms, we do the obvious thing and set up a bipartite graph with variables on one side, clauses on the other, and edges to represent a variable appearing as a negative literal in a clause. We also have a work queue of clauses consisting of a single positive literal. While the work queue is not empty, pop any element, identify the node corresponding to the variable, and delete it and its neighbors. For each clause vertex that now has degree zero, one of two things happens. If that clause has a positive literal, then we add it to the work queue. Otherwise, we've proved that the formula is unsatisfiable. If we reach the end of the work queue without finding such a clause, then the formula is satisfiable, and one satisfying assignment is to set all variables that entered the work queue to true, and all others to false.

David Eisenstat
  • 64,237
  • 7
  • 60
  • 120
  • Sounds clear and logical, but here is the problem. Let's assume that we have such formula: (w ∧ y ∧ z ⇒ x) ∧ (x ∧ z ⇒ w) ∧ (x ⇒ y) ∧ (⇒ x) ∧ (x ∧ y ⇒ w) ∧ (!w ∨ !x ∨ !y) ∧ !z ('!' means negation). It is unsat and algorithm will establish it. To make it sat we can make a little change: (w ∧ y ∧ z ⇒ x) ∧ (x ∧ z ⇒ w) ∧ (x ⇒ y) ∧ (⇒ x) ∧ (x ∧ y ⇒ w) ∧ (!w ∨ !x ∨ !y ∨ !z). However, in this case algorithm will fail and state it as unsat (solution is: w = true, y = true, x = true, z = false). – Meta Nov 23 '20 at 15:59
  • @Meta I don't follow. In the unsatisfiable example, we deduce x from (⇒ x), then y from (x ⇒ y) because propagating x simplified it to (⇒ y), then w from (x ∧ y ⇒ w), which leaves (!w ∨ !x ∨ !y) empty. In the satisfiable example, (!w ∨ !x ∨ !y ∨ !z) still has !z, so we terminate with that satisfying assignment. – David Eisenstat Nov 23 '20 at 16:07
  • Sorry, I just confused myself somehow, but now I truly understand. Thanks a lot! – Meta Nov 23 '20 at 23:15