Horn-satisfiability
In formal logic, Horn-satisfiability, or HORNSAT, is the problem of deciding whether a given conjunction of propositional Horn clauses is satisfiable or not. Horn-satisfiability and Horn clauses are named after Alfred Horn.
A Horn clause is a clause with at most one positive literal, called the head of the clause, and any number of negative literals, forming the body of the clause. A Horn formula is a propositional formula formed by conjunction of Horn clauses.
Horn satisfiability is actually one of the "hardest" or "most expressive" problems which is known to be computable in polynomial time, in the sense that it is a P-complete problem. The extension of the problem for quantified Horn formulae can be also solved in polynomial time.
The Horn satisfiability problem can also be asked for propositional many-valued logics. The algorithms are not usually linear, but some are polynomial; see Hähnle for a survey.
Algorithm
The problem of Horn satisfiability is solvable in linear time.A polynomial-time algorithm for Horn satisfiability is recursive:
- A first termination condition is a formula in which all the clauses currently existing contain negative literals. In this case, all the variables currently in the clauses can be set to false.
- A second termination condition is an empty clause. In this case, the formula has no solutions.
- In the other cases, the formula contains a positive unit clause, so we do a unit propagation: the literal is set to true, all the clauses containing are removed, and all clauses containing have this literal removed. The result is a new Horn formula, so we reiterate.
Using a linear algorithm for unit propagation, the algorithm is linear in the size of the formula.
Examples
Trivial case
In the Horn formulaeach clause has a negated literal. Therefore, setting each variable to false satisfies all clauses, hence it is a solution.
Solvable case
In the Horn formulaone clause forces f to be true. Setting f to true and simplifying gives
Now b must be true. Simplification gives
Now it is a trivial case, so the remaining variables can all be set to false. Thus, a satisfying assignment is
Unsolvable case
In the Horn formulaone clause forces f to be true. Subsequent simplification gives
Now b has to be true. Simplification gives
We obtained an empty clause, hence the formula is unsatisfiable.