Positive Boolean Functions as Multiheaded Clauses Jacob Howe
Positive Boolean Functions as * Multiheaded Clauses Jacob Howe City University, London, UK jacob@soi. city. ac. uk Andy King University of Kent, Canterbury, UK a. m. king@kent. ac. uk International Conference on Logic Programming, Cyprus, 2001 Keywords: Abstract interpretation, (constraint) logic programs, Boolean functions, groundness analysis *Funded 2/16/2022 by EPSRC grant GR/MO 8769 1
Applications Context n n n 2/16/2022 Dependency analysis takes, as input, a program and produces, as output, dependencies such as x y z which means that variable x satisfies some property if both y and z satisfy the property. Dependencies arise in CLP in rigidity analysis [Giacobazzi 95], finiteness analysis [Bigot 92], BTA [Glynn 01], groundness analysis. From a logic programming point of view, groundness analysis is the most practical strength test of Boolean function manipulation. 2
Positive and Definite Boolean functions n n n 2/16/2022 Let [[f]] denote the set of models for a propositional formulae over X. Then [[x y]] = {{x}, {y}, {x, y}} where X = {x, y} A function f is positive iff X [[f]]; Pos. X denotes the set of positive Boolean functions over X A function f is definite iff M M' [[f]] for all M, M' [[f]]; Def. X denotes the set of positive functions over X that are definite 3
Examples of Positive and Definite functions n Let X = {x, y, z} and consider the following table, which states, for some Boolean functions, whether they are in Pos. X or Def. X f false x y Def Pos Ø {x} {y} {z} {x, y} {x, z} {y, z} {x, y, z} x y x (y z) true 2/16/2022 4
Implementation Context n n n 2/16/2022 Traditionally, Boolean function manipulation has been performed using BDDs [Bagnara 98, Fecht 97]. There has been a stream of work on representations amenable to Prolog implementation [Codish 95], in particular for the subclass of definite positive functions, Def, [Garciadela. Banda 96, Genaim 01]. Most of these implementations, included those based on BDDs, require widening for large benchmarks. 5
Implementation Methodology n A Def-based groundness analyser [Howe. King 03] that does not require widening, was constructed by ensuring that frequent operations are the most lightweight. file meet aqua_c 2198 7063 8406 15483 112455 536 632 2742 1668 4663 35007 2 185 26 177 693 5173 equiv 536 632 2742 1668 4663 35007 project 788 805 3230 2035 5523 38163 rename 2052 2149 8963 5738 14540 103795 join (diff) 2/16/2022 chat_80 2192 join n sim_v 5 -2 peval aircraft essln This suggests that a Pos-based groundness analysis should represent functions as multiheaded clauses (CNF). 6
Subtlety of Representation n n 2/16/2022 In fact [Armstrong 98] investigated Reduced Conjunctive Normal Form (RCNF), concluding that it “performed reasonably well”, but RCNF was ultimately rejected because BDDs performed 40% faster. The subtlety of domain representation is illustrated by considering CNF and RNCF. RCNF is reduced so that no clause subsumes another; CNF can include redundant clauses. Meet in O(n 2) in RNCF; O(1) in CNF. [Message 1] 7
Subtlety of Stratification n n 2/16/2022 Neither RCNF nor CNF is canonical, so that equivalence cannot by checked syntactically. [Armstrong 98] compute the dual Blake canonical form (DBCF) of a function, and then test for syntactic identity. DBCF may be exponentially larger than RNCF and it must be completely computed, so cannot filter. Entailment of formulae can be detected using a hierarchy of incomplete algorithms (filters) of increasing complexity. Last complete. [Message 2] 8
Pos as Multiheaded Clauses n n 2/16/2022 A multiheaded clause y 1 . . . yn x 1 . . xm collapses to true if xi and yj overlap. A Boolean function is positive if and only if every clause in its CNF representation contains at least one positive literal. If m=1, the multiheaded clause is a propositional Horn clause, which suggests that entailment checking might be specialised (filtered). Multiheaded clauses can be widened in linear time by discarding clauses with more than, say k, heads. 9
Join for Multiheaded Clauses n n n 2/16/2022 If f 1 = c 1 … cn and f 2 = d 1 … dm then f 1 f 2 = i=1 n( j=1 m(ci dj)) Suppose ci = y 1 . . . yk x 1 . . . xl and di = u 1 . . . up v 1 . . . vq Then ci / di = y 1 . . . yk u 1 . . . up x 1 . . . xl v 1 . . . vq so join is quadratic. 10
Entailment for Multiheaded Clauses n A sound but incomplete test (entailslite) checks for i=1 l (Bi Hi) |= (B H) where B = b 1 . . . bn and H = h 1 … hm n n 2/16/2022 n It binds each hi to false, each bj to true, and then propagates deterministic bindings in an attempt to find a solution to i=1 l (Bi Hi). It contains forward chaining for Horn clauses as a special case. It terminates either when a contradiction is found in i=1 l (Bi Hi) (then entailment follows) or when no more bindings can be propagated. Running-time is O(n) in variable occurrences. 11
Entailment for Multiheaded Clauses (cont’) n n n 2/16/2022 The sound and complete algorithm entailsheavy applies case splitting if entailslite does not detect entailment. The number of cases is potentially exponential in the number of variables left unbound by entailslite. However, propagation occurs after each binding, and deep case splitting is rarely required. 12
Projection for Multiheaded Clauses n n n 2/16/2022 Projection is calculated using a Fourier-Motzkin style algorithm. Projection of a single variable, z, out of a pair of clauses (syllogising) is performed by: $ z. ((y 1 . . . yp z x 1 . . . xq) (z yp+1 . . . yn xq+1 . . . xm)) = (y 1 . . . yn x 1 . . . xm) Syllogising gives a O(n 2) blow-up and thus it is followed by a compaction step, based on entailslite, so the overall running time is O(n 4). 13
Experimental Results 2/16/2022 file sim rubik parser read MHC RNCF 0. 22 1. 09 24. 78 0. 21 0. 22 25. 32 0. 36 0. 29 1. 75 BDD 0. 25 0. 20 0. 26 GI 0. 62 0. 16 0. 30 sim_v 5 -2 0. 23 0. 07 0. 33 0. 16 0. 10 peval aircraft essln chat_80 aqua_c 0. 18 0. 54 0. 48 1. 43 3. 55 0. 64 4. 63 0. 15 0. 70 0. 19 20. 72 0. 88 4. 28 7. 68 67. 04 0. 16 0. 41 0. 37 0. 84 > 120 1. 30 0. 12 0. 30 0. 64 6. 59 14
Experimental Results (cont’) n n n 2/16/2022 Multiheaded clauses perform consistently better than RCNF. This is not surprising given the cost of meet and equivalence checking. MHC compares favourably with BDDs, especially considering that the BDD operations exploit memoisation and are coded in C. In terms of runtime, MHC and BDDs give similar results, although BDDs perform well on sim. pl, whereas MHC perform well on sim_v 5 -2. pl. 15
Instrumentation Results n n 2/16/2022 Instrumentation has revealed that the total number of times entailslite is invoked in checking F |= f almost never exceeds |var(F)|. Therefore in practice entailsheavy exhibits cubic behaviour in the size of the input formulae. Further instrumentation has shown that the maximum number of heads observed in a clause is four. So only a few bindings typically need to be made to check entailment. 16
Conclusio ns n n n 2/16/2022 n Illustrates the subtlety of choosing a representation and its associated operations, even for a well known domain (Pos). Success due to O(1) meet and stratified entailment. Analysers do not fire widening (for reasonable programs). Can code analysers in Prolog. 17
- Slides: 17