530 likes | 657 Views
Compact Propositional Encoding of First Order Theories. Eyal Amir University of Illinois at Urbana-Champaign (Joint with Deepak Ramachandran and Igor Gammer ). Example: Pigeonhole Principle. p 1. H 1. p 2. H 2. p 3. H 3. p 4. H 4. Pigeonhole: Classical Encoding.
E N D
Compact Propositional Encoding ofFirst Order Theories Eyal Amir University of Illinois at Urbana-Champaign (Joint with Deepak Ramachandran and Igor Gammer) Compact Encoding of FOL Eyal Amir, Cambridge Present., May 2006
Example: Pigeonhole Principle p1 H1 p2 H2 p3 H3 p4 H4 Compact Encoding of FOL Eyal Amir, Cambridge Present., May 2006
Pigeonhole: Classical Encoding H1(pi) H2(pi) H3(pi) H4(pi) [H1(pi) H2(pi)] p,q (pq Hi(p) Hi(q)) Every i: O(n2) props Compact Encoding of FOL Eyal Amir, Cambridge Present., May 2006
A Reformulation Hi+(p) : pigeon p is not in a hole in the subtree rooted at i. H1+ p1 p3 H2+ H3+ p4 p2 1 2 3 4 Compact Encoding of FOL Eyal Amir, Cambridge Present., May 2006
A Reformulation Hi+(p) : pigeon p is not in a hole in the subtree rooted at i. p[H1+(p) (H2+(p) H3+(p)) H1+ p1 p3 p[H2+(p) (-H1(p) -H2(p)) p[H1+(p) (-H3(p)-H4(p)) p4 p2 1 2 3 4 Compact Encoding of FOL Eyal Amir, Cambridge Present., May 2006
A Reformulation Hi+(p) : pigeon p is not in a hole in the subtree rooted at i. p[H1+(p) H2+(p)] p1 p3 p[H1(p) H2(p)] p[H3(p)H4(p)] p4 p2 1 2 3 4 Compact Encoding of FOL Eyal Amir, Cambridge Present., May 2006
A Reformulation Hi+(p) : pigeon p is not in a hole in the subtree rooted at i. H1+ p1 p3 H2+ H3+ p,q[Hi(p)Hi(q) (p=q)] p4 p2 Compact Encoding of FOL Eyal Amir, Cambridge Present., May 2006
A Reformulation Hi+(p) : pigeon p is not in a hole in the subtree rooted at i. p[H1+(p)] p1 p3 H2+ H3+ O(n·logn) props p4 p2 Compact Encoding of FOL Eyal Amir, Cambridge Present., May 2006
Propositional Encodings: Motivation • How do we do this in general? – scientific curiosity • Applications: • Formal verification, BMC – specification in FOL • AI: planning, diagnosis, spatial reasoning, question answering from knowledge – specified in FOL • Useful with many objects, predicates, time steps, etc. • Can use efficient SAT solvers Compact Encoding of FOL Eyal Amir, Cambridge Present., May 2006
Outline • Algorithm for compact prop. encoding • Analysis • Interpolants – correctness of algorithm • A different Treewidth – number of props. • Towards automatic partitioning • Related work & open questions Compact Encoding of FOL Eyal Amir, Cambridge Present., May 2006
Naïve Propositional Encoding • Tasks converted into propositional logic • P(a) Pa x P(x) PaPb Pc (Naive Propositionalization) • Problem: Very many propositions: |P||C|k for |P| predicates of arity k, and |C| constant symbols • Note: Assumes Domain Closure (DCA) • constant symbols name all domain objects Compact Encoding of FOL Eyal Amir, Cambridge Present., May 2006
Our Results • New method for propositioal encoding • Size depends on optimal tree decomposition (e.g., O(|P|+|C|) sometimes; O(n logn) instead of O(n2) for Pigeonhole Principle) • Applications: • Machine scheduling problem • Board-Level Routing Problem for FPGA’s Compact Encoding of FOL Eyal Amir, Cambridge Present., May 2006
Our New Algorithm Rough algorithm (given theory T): • Partition theory T into T1…Tr (*1) • Encode every Ti in propositional logic Ti’ separately (create proposition Pa for constant a and predicate P in L(Ti)) (*2) • Return Ui≤rTi’ Compact Encoding of FOL Eyal Amir, Cambridge Present., May 2006
Partitioned Theory T … Compact Encoding of FOL Eyal Amir, Cambridge Present., May 2006
Partitioned Theory T1 T2 … … Compact Encoding of FOL Eyal Amir, Cambridge Present., May 2006
Propositional Encoding T1 T2 … … Compact Encoding of FOL Eyal Amir, Cambridge Present., May 2006
Propositional Encoding T1 T2 … … Compact Encoding of FOL Eyal Amir, Cambridge Present., May 2006
Propositional Encoding T1 T2 … … Compact Encoding of FOL Eyal Amir, Cambridge Present., May 2006
Propositional Encoding T1 T2 … … Compact Encoding of FOL Eyal Amir, Cambridge Present., May 2006
Propositional Encoding T1 T2 … … Compact Encoding of FOL Eyal Amir, Cambridge Present., May 2006
Propositional Encoding T1 T2 … … Compact Encoding of FOL Eyal Amir, Cambridge Present., May 2006
# props. in partitioned encoding 1 # props. in naïve encoding #partitions Partitioned Propositional Encoding Algorithm: • Partition theory T into T1…Tr • Propositionalize each Ti separately • Return the propositional encoding Ui≤rTi |Pi||Ci| props. an exponential speed-up for SAT solver How to make this sound+complete? Compact Encoding of FOL Eyal Amir, Cambridge Present., May 2006
Experiments: Board-Level Routing #prop. vars per problem SAT Running time (sec.) per problem Compact Encoding of FOL Eyal Amir, Cambridge Present., May 2006
Experiments: Machine Scheduling #prop. vars per problem SAT Running time (sec.) per problem Compact Encoding of FOL Eyal Amir, Cambridge Present., May 2006
Outline • Algorithm for compact prop. encoding • Analysis • Interpolants – correctness of algorithm • A different Treewidth – number of props. • Towards automatic partitioning • Related work & open questions Compact Encoding of FOL Eyal Amir, Cambridge Present., May 2006
Key to Exact Encoding • Craig’s interpolation theorem (First-Order Logic): • If T1 T2, then there is a formula C including only symbols from L(T1) L(T2) such that T1 C and C T2 ^ ^ ^ T1 T2 ^ P(x) Compact Encoding of FOL Eyal Amir, Cambridge Present., May 2006
T1T2 has no model, iff T1 T2 ^ Key to Exact Encoding • Craig’s interpolation theorem (First-Order Logic): • If T1 T2, then there is a formula C including only symbols from L(T1) L(T2) such that T1 C and C T2 ^ ^ ^ T1 T2 ^ The only interpolants (the C’s) can be xP(x),xP(x),… (+6 others) P(x) Compact Encoding of FOL Eyal Amir, Cambridge Present., May 2006
T1T2 has no model, iff T1 T2 ^ Key to Exact Encoding • Key idea: If our prop. encoding of T1 [T2] implies all possible interpolants in L(T1)L(T2), then the combined encoding is SAT iff T (in FOL) is SAT. T1 T2 ^ The only interpolants (the C’s) can be xP(x),xP(x),… (+6 others) P(x) Compact Encoding of FOL Eyal Amir, Cambridge Present., May 2006
The only interpolants (the C’s) can be xP(x),xP(x),… (+6 others) Propositional Encoding T1 T2 … … Compact Encoding of FOL Eyal Amir, Cambridge Present., May 2006
Correctness of Encoding Alg. • Encoding of each partition needs to include encodings of all possible interpolants (detailed next) • When there are more than two partitions, the partitions are arranged in a tree decomposition (in next section) Compact Encoding of FOL Eyal Amir, Cambridge Present., May 2006
Outline • Algorithm for compact prop. encoding • Analysis • Interpolants – correctness of algorithm • A different Treewidth – number of props. • Towards automatic partitioning • Related work & open questions Compact Encoding of FOL Eyal Amir, Cambridge Present., May 2006
The only interpolants (the C’s) can be xP(x),xP(x),… (+6 others) Propositional Encoding Size T1 T2 … … Compact Encoding of FOL Eyal Amir, Cambridge Present., May 2006
Propositional encoding of Monadic FOL Factor = single-variable existentially quantified formula Theorem : Can convert any monadic FOL formula to a conjunction of disjunctions of factors Example: Compact Encoding of FOL Eyal Amir, Cambridge Present., May 2006
Propositionalizing a Partition in Monadic FOL • Convert Ti to factorized form • Replace factors in Τi with prop. symbols • Add meaning of new propositions ε(Ti) = This approach creates |Pi||Ci|+3|Pi| propositional symbols. Compact Encoding of FOL Eyal Amir, Cambridge Present., May 2006
Outline • Algorithm for compact prop. encoding • Analysis • Interpolants – correctness of algorithm • A different Treewidth – number of props. • Towards automatic partitioning • Related work & open questions Compact Encoding of FOL Eyal Amir, Cambridge Present., May 2006
Automatic Partitioning and Propositional Encoding • Optimization criteria • Tree of partitions of axioms that satisfies the running intersection property • Minimize |Pi||Ci|+3|Pi| (contrast with treewidth, where we minimize |Pi|) • Can use current algorithms for treewidth and decomposition as a starting point • Sometime need reformulation of axioms Compact Encoding of FOL Eyal Amir, Cambridge Present., May 2006
Automatic Partitioning • Find a tree decomposition G of minimum width: • Every node in G is a set of symbols from T • G satisfies the running intersection property: if P appears in both v,u in G, then P appears in all the nodes on the path connecting them • Choose G with minimum width (width(G) is the size of its largest node v) Compact Encoding of FOL Eyal Amir, Cambridge Present., May 2006
Outline • Algorithm for compact prop. encoding • Analysis • Interpolants – correctness of algorithm • A different Treewidth – number of props. • Towards automatic partitioning • Related work & open questions Compact Encoding of FOL Eyal Amir, Cambridge Present., May 2006
Related Work • [McMillan 2005] – some ground (QF) FOL theories have ground interpolants • May use his results for similar results on compact prop. for those theories • McMillan’s talk yesterday – may use our compact prop. method to generate all interpolants Compact Encoding of FOL Eyal Amir, Cambridge Present., May 2006
Related Work • [Pnueli, Rodeh, Strichman, Siegel ’99, ’02] – equational theories (no predicates), and weak(er?) bound where R = resulting universe size, and others are problem dependent (worst case n!, for n variables/constants) Compact Encoding of FOL Eyal Amir, Cambridge Present., May 2006
Conclusion • Created efficient propositional encodings: • Monadic FOL – Sound + Complete • Ramsey class – Sound, Incomplete without DCA • Applies to general FOL (with DCA) • Speedup in SAT solving • Exploits the structure of real world problems • Future work: Classes beyond Monadic FOL • Right now: ground FOL with equality • 2-var fragment • Some software on http://reason.cs.uiuc.edu/eyal Compact Encoding of FOL Eyal Amir, Cambridge Present., May 2006
THE END Compact Encoding of FOL Eyal Amir, Cambridge Present., May 2006
Problems with Naïve Prop. • Problem 1: Very large number of propositions: |P||C|k for |P| predicates of arity k, and |C| constant symbols • Problem 2: Assumes Domain Closure Assumption (DCA) – only elements are those with constant symbols Compact Encoding of FOL Eyal Amir, Cambridge Present., May 2006
General FOL (with DCA) Use DCA repeatedly until we get a formula in Monadic FOL • Replace x1Qx2…Qxn(x1,…, xn) with cCQx2…Qxn(x1,…, xn) • Replace x1Qx2…Qxn(x1,…, xn) with cCQx2…Qxn(x1,…, xn) Compact Encoding of FOL Eyal Amir, Cambridge Present., May 2006
Automatic Partitioning • Begin with logical Knowledge Base in FOL • Construct symbol graph • vertex = symbol • edge = axiom uses both symbols • Find a tree decomposition • Partition axioms using clusters in tree decomposition Compact Encoding of FOL Eyal Amir, Cambridge Present., May 2006
Automatic Partitioning key locked can_open can_open Ù try_open open open Ù fetch broom key open try_open open broom fetch broom Ù dry can_clean can_clean clean broom Ù let_dry dry time let_dry drier let_dry time drier Compact Encoding of FOL Eyal Amir, Cambridge Present., May 2006
Automatic Partitioning key locked can_open can_open Ù try_open open open Ù fetch broom key open try_open open broom fetch broom Ù dry can_clean can_clean clean broom Ù let_dry dry time let_dry drier let_dry time drier Compact Encoding of FOL Eyal Amir, Cambridge Present., May 2006
Automatic Partitioning key locked can_open can_open Ù try_open open open Ù fetch broom key open try_open open broom fetch broom Ù dry can_clean can_clean clean broom Ù let_dry dry time let_dry drier let_dry time drier Compact Encoding of FOL Eyal Amir, Cambridge Present., May 2006
Automatic Partitioning key locked can_open try_open can_clean clean open fetch dry time broom let_dry drier Compact Encoding of FOL Eyal Amir, Cambridge Present., May 2006
Automatic Partitioning key locked can_open try_open can_clean clean open fetch dry time broom let_dry drier Compact Encoding of FOL Eyal Amir, Cambridge Present., May 2006