Unit propagation (UP) or boolean constraint propagation (BCP) or the one-literal rule (OLR) is a procedure of automated theorem proving that can simplify a set of (usually propositional) clauses.
The procedure is based on unit clauses, i.e. clauses that are composed of a single literal, in conjunctive normal form. Because each clause needs to be satisfied, we know that this literal must be true. If a set of clauses contains the unit clause
l
l
l
\negl
\negl
The application of these two rules lead to a new set of clauses that is equivalent to the old one.
For example, the following set of clauses can be simplified by unit propagation because it contains the unit clause
a
\{a\veeb,\nega\veec,\negc\veed,a\}
Since
a\veeb
a
\nega\veec
a
\{ a\veeb, \nega\veec, \negc\veed, a \} | ||||
(removed) | ( \nega | (unchanged) | (unchanged) | |
\{ c, \negc\veed, a \} |
The resulting set of clauses
\{c,\negc\veed,a\}
c
\negc\veed
d
The second rule of unit propagation can be seen as a restricted form of resolution, in which one of the two resolvents must always be a unit clause. As for resolution, unit propagation is a correct inference rule, in that it never produces a new clause that was not entailed by the old ones. The differences between unit propagation and resolution are:
Resolution calculi that include subsumption can model rule one by subsumption and rule two by a unit resolution step, followed by subsumption.
Unit propagation, applied repeatedly as new unit clauses are generated, is a complete satisfiability algorithm for sets of propositional Horn clauses; it also generates a minimal model for the set if satisfiable: see Horn-satisfiability.
The unit clauses that are present in a set of clauses or can be derived from it can be stored in form of a partial model (this partial model may also contain other literals, depending on the application). In this case, unit propagation is performed based on the literals of the partial model, and unit clauses are removed if their literal is in the model. In the example above, the unit clause
a
a
The direct implementation of unit propagation takes time quadratic in the total size of the set to check, which is defined to be the sum of the size of all clauses, where the size of each clause is the number of literals it contains.
Unit propagation can however be done in linear time by storing, for each variable, the list of clauses in which each literal is contained. For example, the set above can be represented by numbering each clause as follows:
\{1:a\veeb,2:\nega\veec,3:\negc\veed,4:a\}
and then storing, for each variable, the list of clauses containing the variable or its negation:
a:1 2 4
b:1
c:2 3
d:3
This simple data structure can be built in time linear in the size of the set, and allows finding all clauses containing a variable very easily. Unit propagation of a literal can be performed efficiently by scanning only the list of clauses containing the variable of the literal. More precisely, the total running time for doing unit propagation for all unit clauses is linear in the size of the set of clauses.