Title: Positive Boolean Functions as Multiheaded Clauses*
1Positive Boolean Functions asMultiheaded Clauses
- Jacob Howe
- City University, London, UK
- jacob_at_soi.city.ac.uk
- Andy King
- University of Kent, Canterbury, UK
- a.m.king_at_kent.ac.uk
International Conference on Logic Programming,
Cyprus, 2001 Keywords Abstract interpretation,
(constraint) logic programs, Boolean functions,
groundness analysis Funded by EPSRC grant
GR/MO8769
2Applications Context
- 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
Giacobazzi95, finiteness analysis Bigot92,
BTA Glynn01, groundness analysis. - From a logic programming point of view,
groundness analysis is the most practical
strength test of Boolean function manipulation.
3Positive and Definite Boolean functions
- 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 PosX
denotes the set of positive Boolean functions
over X - A function f is definite iff M ? M' ? f for
all M, M' ? f DefX denotes the set of
positive functions over X that are definite
4Examples of Positive and Definite functions
- Let X x, y, z and consider the following
table, which states, for some Boolean functions,
whether they are in PosX or DefX
f Def Pos Ø x y z x,y x,z y,z x,y,z
false
x?y ? ? ? ?
x?y ? ? ? ? ? ? ?
x?y ? ? ? ? ? ? ? ?
x?(y?z) ? ? ? ? ? ? ? ?
true ? ? ? ? ? ? ? ? ? ?
5Implementation Context
- Traditionally, Boolean function manipulation has
been performed using BDDs Bagnara98,Fecht97. - There has been a stream of work on
representations amenable to Prolog implementation
Codish95, in particular for the subclass of
definite positive functions, Def,
GarciadelaBanda96,Genaim01. - Most of these implementations, included those
based on BDDs, require widening for large
benchmarks.
6Implementation Methodology
- A Def-based groundness analyser HoweKing03 that
does not require widening, was constructed by
ensuring that frequent operations are the most
lightweight. - This suggests that a Pos-based groundness
analysis should represent functions as
multiheaded clauses (CNF).
file sim_v5-2 peval aircraft essln chat_80 aqua_c
meet 2192 2198 7063 8406 15483 112455
join 536 632 2742 1668 4663 35007
join (diff) 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
7Subtlety of Representation
- In fact Armstrong98 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(n2) in RNCF O(1) in CNF. Message 1
8Subtlety of Stratification
- Neither RCNF nor CNF is canonical, so that
equivalence cannot by checked syntactically. - Armstrong98 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
9Pos as Multiheaded Clauses
- A multiheaded clause y1 ? ... ? yn ? x1 ? .. ? 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 m1, 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.
10Join for Multiheaded Clauses
- If f1 c1?? cn and f2 d1?? dm then
- f1 ? f2 ?i1n(?j1m(ci ? dj))
- Suppose ci y1 ? ... ? yk ? x1 ? ... ? xl and di
u1 ? ... ? up ? v1 ? ... ? vq - Then ci \/ di y1 ? ... ? yk ? u1 ? ... ? up ?
x1 ? ... ? xl ? v1 ? ... ? vq so join is
quadratic.
11Entailment for Multiheaded Clauses
- A sound but incomplete test (entailslite) checks
for - ? i1l (Bi ? Hi) (B ? H) where B b1 ? ...
? bn and H h1 ? ? hm - It binds each hi to false, each bj to true, and
then propagates deterministic bindings in an
attempt to find a solution to ?i1l (Bi ? Hi). It
contains forward chaining for Horn clauses as a
special case. - It terminates either when a contradiction is
found in ?i1l (Bi ? Hi) (then entailment
follows) or when no more bindings can be
propagated. - Running-time is O(n) in variable occurrences.
12Entailment for Multiheaded Clauses (cont)
- 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.
13Projection for Multiheaded Clauses
- 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 . ((y1 ? ... ? yp ? z ? x1 ? ... ? xq) ?
- (z ? yp1 ? ... ? yn ? xq1 ?
... ? xm)) - (y1 ? ... ? yn ? x1 ? ... ? xm)
- Syllogising gives a O(n2) blow-up and thus it is
followed by a compaction step, based on
entailslite, so the overall running time is
O(n4).
14Experimental Results
file read MHC RNCF BDD GI
sim 0.22 1.09 24.78 0.25 0.62
rubik 0.21 0.22 25.32 0.20 0.16
parser 0.36 0.29 1.75 0.26 0.30
sim_v5-2 0.23 0.07 0.33 0.16 0.10
peval 0.18 0.64 4.63 0.16 1.30
aircraft 0.54 0.15 0.70 0.41 0.12
essln 0.48 0.19 20.72 0.37 0.30
chat_80 1.43 0.88 4.28 0.84 0.64
aqua_c 3.55 7.68 67.04 gt 120 6.59
15Experimental Results (cont)
- 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_v5-2.pl.
16Instrumentation Results
- 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.
17Conclusions
- 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.