foundations of computational agents
Chapter 4 shows how to reason with constraints. Logical formulas provide a concise form of constraints with structure that can be exploited.
There are a number of reasons for using propositions for specifying constraints and queries:
It is often more concise and readable to give a logical statement about the relationship among some variables than to use an extensional representation.
The form of the knowledge can be exploited to make reasoning more efficient.
They are modular, so small changes to the problem result in small changes to the knowledge base. This also means that a knowledge base is easier to debug than other representations.
The kind of queries may be richer than single assignments of values to variables.
This language can be extended to reason about individuals (things, entities) and relations; see Chapter 15.
The class of propositional satisfiability or SAT problems have
Boolean variable. A Boolean variable is a variable with domain . If is a Boolean variable, is written as its lower-case equivalent, , and as .
For example, the proposition means Boolean variable is true (), and means .
Clausal constraints. A clause is an expression of the form , where each is a literal. A literal is an atom or the negation of an atom; thus a literal is an assignment of a value to a Boolean variable. A clause is true in an interpretation if and only if at least one of the literals that make up the clause is true in that interpretation.
If appears in a clause, the atom is said to appear negatively in the clause. If appears unnegated in a clause, it is said to appear positively in a clause.
In terms of the propositional calculus, a set of clauses is a restricted form of logical formula. Any propositional formula can be converted into clausal form. A total assignment corresponds to an interpretation.
In terms of constraints, a clause is a constraint on a set of Boolean variables that rules out one of the assignments of the literals in the clause. The clause corresponds to the statement , which says that not all of the are false.
The clause is a constraint among the variables , , and , which is true if has value , has value , or has value . The atoms and appear positively in the clause, and appears negatively in the clause.
The assignment , , violates the constraint of clause . It is the only assignment of these three variables that violates this clause.
It is possible to convert any finite constraint satisfaction problem (CSP) into a propositional satisfiable problem:
A variable with domain can be converted into Boolean variables , where is true when has value and is false otherwise. Each is called an indicator variable. Thus, atoms, , are used to represent the CSP variable.
There are constraints that specify that and cannot both be true when , namely the clause for . There is also a constraint that one of the must be true, namely the clause .
To translate the constraints, notice that is equivalent to for any atoms . One way to represent a constraint is to use a clause for each assignment of values that violates the constraint. Thus, for example, the clause represents that and is a combination that violates a constraint.
Often we can use many fewer clauses than by applying this naively.
Consider two variables and each with domain . For the variable , construct four Boolean variables , , , and , where is true just when , is true just when , etc. Variables , , , and are disjoint and covering which leads to the seven clauses
Similarly for .
The constraint implies that is false, is false, and the pairs that violate the constraint are also false, which gives the five clauses
Note that you don’t need the clause because this is implied by .
Consistency algorithms can be made more efficient for propositional satisfiability problems than for general CSPs. When there are only two values, pruning a value from a domain is equivalent to assigning the opposite value. Thus, if has domain , pruning from the domain of is the same as assigning to have value .
Arc consistency can be used to prune the set of values and the set of constraints. Assigning a value to a Boolean variable can simplify the set of constraints:
If is assigned , all of the clauses with become redundant; they are automatically satisfied. These clauses can be removed from consideration. Similarly, if is assigned , clauses containing can be removed.
If is assigned , any clause with can be simplified by removing from the clause. Similarly, if is assigned , then can be removed from any clause it appears in. This step is called unit resolution.
If, after pruning the clauses, there is a clause that contains just one assignment, , the other value can be removed from the domain of . This is a form of arc consistency. If all of the assignments are removed from a clause, the constraints are unsatisfiable.
Consider the clause . If is assigned to , the clause can be simplified to . If is then assigned to , the clause can be simplified to . Thus, can be pruned from the domain of .
If, instead, is assigned to , the clause can be removed.
If a variable has the same value in all remaining clauses, and the algorithm must only find one model, it can assign that value to that variable. For example, if variable only appears as (i.e., is not in any clause), then can be assigned the value . That assignment does not remove all of the models; it only simplifies the problem because the set of clauses remaining after setting is a subset of the clauses that would remain if were assigned the value . A variable that only has one value in all of the clauses is called a pure literal.
Pruning the domains and constraints, domain splitting, and assigning pure literals is the Davis–Putnam–Logemann–Loveland (DPLL) algorithm. It is a very efficient algorithm, as long as the data structures are indexed to carry out these tasks efficiently.
Stochastic local search can be faster for CSPs in the form of propositional satisfiability problems than for general CSPs, for the following reasons:
Because only one alternative value exists for each assignment to a variable, the algorithm does not have to search through the alternative values.
Changing any value in an unsatisfied clause makes the clause satisfied. As a result, it is easy to satisfy a clause, but this may make other clauses unsatisfied.
If a variable is changed to be true, all of the clauses where it appears positively become satisfied, and only clauses where it appears negatively can become unsatisfied. Conversely, if a variable is changed to be false, all of the clauses where it appears negatively become satisfied, and only those clauses where it appears positively can become unsatisfied. This enables fast indexing of clauses.
The search space is expanded. In particular, before a solution has been found, more than one of the indicator variables for a variable could be true (which corresponds to having multiple values) or all of the indicator variables could be false (which corresponds to having no values). This can mean that some assignments that were local minima in the original problem may not be local minima in the new representation.
Satisfiability has been studied much more extensively than most other types of CSPs and more efficient solvers exist because more of the space of potential algorithms has been explored by researchers.
Whether converting a particular CSP to a satisfiability problem makes search performance better is an empirical question, depending on the problem and the tools available.