An On-Line Satisfiability Algorithm for Conjunctive Normal Form

An On-Line Satisfiability Algorithm for Conjunctive Normal Form

From: FLAIRS-02 Proceedings. Copyright © 2002, AAAI (www.aaai.org). All rights reserved. An On-Line Satisfiability Algorithm for Conjunctive Normal Form Expressions with Two Literals John F. Kolen Institute of Human and Machine Cognition University of West Florida Pensacola, Florida 32501 [email protected] Abstract so far. For instance, an on-line convex hull algorithm incre- mentally maintains the convex hull of a sequence of coplanar This paper describes two algorithms for determining points (Preparata 1979). the satisfiability of Boolean conjunctive normal form In this paper, I first describe an on-line algorithm for 2- expressions limited to two literals per clause (2-SAT) SAT. At each insertion of a clause, the algorithm condition- extending the classic effort of Aspvall, Plass, and Tar- jan. The first algorithm differs from the original in ally performs a depth first search of subset of the dual impli- that satisfiability is determined upon the presentation of cation graph and checks affected components for inclusion each clause rather than the entire clause set. This on- of literal pairs (x and x). A large performance savings is line algorithm experimentally exhibits average run-time made by not searching on pure variables, by making oppor- linear to the number of variables. This performance tunistic variable assignments, especially during depth first is achieved by performing a single depth first search search of the graph. These techniques are used to construct of one of the incoming literals. Additional search is an off-line algorithm, as well. The performance of the algo- avoided by excluding clauses containing pure variables rithms are demonstrated experimentally. or variables whose truth value has been explicitly pro- vided or can be inferred. An off-line algorithm is also described that incorporates these strategies. Preliminaries During the course of this paper, the following terms are used to describe satisfiability problems and their graph theoretic Introduction equivalents. Let X = x1, ..., xn be a set of Boolean vari- A conjunctive normal form Boolean expression (CNF) is a ables. A literal is either a variable or it’s negation, hence L = {x , ..., x }∪{x , ..., x } conjunction of disjunctive clauses. Determining the exis- 1 n 1 n is the set of literals. A c k tance of an assignment of truth values to the variables of clause, ,isamultiset representing the disjunction of L the CNF expression that makes it evaluate as true is the sat- members of .For this paper, we are only interested in the k =2 isfiability problem. When the clause size is greater than case where . This restriction implies that clauses will a, b ∈ L a ∨ a two, the problem is NP-Complete (Cook 1971). A linear exhibit one of three forms ( ): i) unit clauses , a ∨ a a ∨ b algorithm for 2-SAT was originally developed by Aspvall, ii) tautological clauses, , iii) and regular clauses, . C Lk Plass, and Tarjan (Aspvall, Plass, & Tarjan 1979) (APT al- A clause set is the multiset drawn from .Aninstance k F =(X, C) a gorithm). Consider a directed graph where the vertices are of a -SAT problem is .Aliteral, ,ispure, if C the set of literals from a 2-CNF formula. One could con- it’s negation does not appear in any clause in . struct a digraph on these vertices from the formula by in- The 2-SAT decision problem is intimately related to deci- terpreting each clause a ∨ b as a pair of directed edges sions problems on graphs (Aspvall, Plass, & Tarjan 1979). All graphs are assumed to be directed. Let G =(V,E) a → b and b → a on the graph. They proved that a designate a graph with V vertices and E edges. The graph formula is satisfiable if, and only if, no pair of literals, x dual, or implication graph, G,ofa2-SAT problem instance and x, appear in the same strongly connected component. (X, C) directly represents the implication relationship be- Since a linear time algorithm for determining the strongly tween literals of X induced by the disjunctive clauses of C. connected components of a digraph existed (Tarjan 1972; The vertices, V ,ofthe graph are the literals, L.Anedge Aho, Hopcroft, & Ullman 1974), the 2-SAT question could exists in the graph if and only if the implication relation- be answered in linear time as well. ship holds between the two vertices. Hence, E = {(a, b) | The APT algorithm requires the entire expression before (a ∨ b) ∈ C}. Note that both (a, b) ∈ E if and only if it can begin processing–an off-line algorithm. An on-line b, a ∈ E. Literal and vertex will be used interchangeably algorithm, on the other hand, is one receives a sequence of through out the paper. inputs and performs some computation on the sequence seen Avertex b is reachable from vertex a if there exists a set Copyright c 2002, American Association for Artificial Intelli- (xi,xi+1) ⊂ V of vertices such that a → x1, x1 → x2, gence (www.aaai.org). All rights reserved. ..., xi → b. Reachability of two vertices is represented as FLAIRS 2002 187 proc 2-SAT APT(F ) G.Either P = P or there exist two components S1,S2 ∈ P Construct the dual graph G=(V,E) of F such that S1,S2 ∈ P but S1 ∪ S2 ⊆ S, and S ∈ P . foreach v ∈ E do if not(w.Mark) then SearchAPT(v); fi Theorem 3 Let a b and a b. There exists a path from return not(SearchFailed()) od. a to a through b (and b) with length | a b | + | a b |. proc SearchAPT(v) Theorem 4 S is a contradictory component if and only if Push(v); ∀b ∈ S, b ∈ S. v.Lowlink := v.Dfnum := count; count := count +1; v.Mark := true; Algorithms foreach w where (v, w) ∈ E do While the APT algorithm performs well–linear run time if not(w.Mark) with respect to the number of variables and edges–it requires then SearchAPT(w); the entire formula to begin it’s processing. There are situa- v.Lowlink := min(v.Lowlink, w.Lowlink) tions, however, that this may not be feasible or, at least, in- elsif w.Dfnum<v.Dfnum ∧ OnStack(w) convenient. For instance, the 2-SAT instance could be gen- then v.Lowlink := erated by some other procedure as the byproduct of a com- min(v.Lowlink, w.Dfnum) plex computation (e.g. a planner) that might benefit from fi od knowing the formula it is building is unsatisfiable. if v.Lowlink = v.Dfnum An on-line algorithm for 2-SAT must manipulate the un- then repeat derlying data structures to allow efficient clause insertion u := Pop(); and satisfiability queries. Recent developments in dynamic if u is on the stack after v graph algorithms suggest that on-line 2-SAT may have a then Fail(); fi quadratic run time (Khanna, Motwani, & Wilson 1996). For- until u = v; fi. tunately, 2-SAT does not require such certificates during pro- cessing due to the existential nature of it’s query. The re- Figure 1: The 2-SAT algorithm of Aspvall, Plass, and mainder of this section discusses the benefits of such a view Tarjan (Aspvall, Plass, & Tarjan 1979) embedded into a in the form of two algorithms. First, an on-line algorithm strongly connected connected components algorithm (Aho, for incrementally processing a sequence of binary clauses Hopcroft, & Ullman 1974). is presented. A new off-line version is described, as well. Analysis and experimental results will follow. a b. The set S ⊂ V such that for all a, b ∈ S, a b The On-Line Algorithm and b a is a strongly connected component (SCC). A The on-line algorithm consists of three cooperative proce- maximal strongly connected component is known as a strong dures (Figure 2). The procedure InsertClause receives component. Components throughout this paper will refer to the clause stream. Two recursive functions, Search and strong components. The set of all components partitions the AssignT rue perform most of the work of the algorithm by graph vertices. A contradictory component contains vertex, exploring components and maintaining truth values of the a, and it’s negation, a. literals. The Valuefield of a literal can take on one of three When the graph is an implication graph, the partition values: true, false, and unassigned.Two forms of negation gives rise to an equivalence relation for literal truth values. appear below. An overbar (a) indicates a negated literal, This view justifies (Aspvall, Plass, & Tarjan 1979) observa- while ¬ is a Boolean operator. tion that if an some strong component of implication graph The procedure InsertClause(a, b) translates the disjunc- contains a literal and it’s negation, the dual 2-SAT formula tive clause a ∨ b into its equivalent implications. If both is unsatisfiable. Figure 1 illustrates the APT algorithm along literals are known to be false, then processing can stop, as with Tarjan’s connected components algorithm from (Aho, this clause, as well as the entire formula, can not be sat- Hopcroft, & Ullman 1974). This algorithm was much more isfied. Discovering a true variable allows the algorithm to amenable to the optimization than Tarjan’s version (Tarjan avoid processing this clause. Tautologies (a ∨ a) can be 1972). Since SearchAP T (v) is called once for each literal safely ignored, as well. If one and only one of the literals in the dual graph and all edges must be examined, the run is false, then the other must be true, and it can then recur- | | | | time is Θ( V + E ) when an edge list is used. sively assign true to that literal and all of its implicants. If Before discussing the new algorithms, four theorems will none of these conditions hold, the algorithm can finally in- be needed.

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    5 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us