Decision Procedures for Equality Logic 1 1 Equality

  • Slides: 20
Download presentation
Decision Procedures for Equality Logic 1 1

Decision Procedures for Equality Logic 1 1

Equality logic Def. An equality logic formula is defined by the following grammar: formula

Equality logic Def. An equality logic formula is defined by the following grammar: formula : : = formula ^ formula | : formula | atom : : = term : : = identifier | constant where the identifiers are variables over a single infinite domain like the reals or integers. Constants are elements from the same domain as identifiers. 2

Complexity Equality logic and propositional logic are both NPcomplete. Thus they model the same

Complexity Equality logic and propositional logic are both NPcomplete. Thus they model the same decision problems. Why to study both? - convenience of modeling - efficiency Extensions: different domains, Boolean variables 3

Basic assumptions and notations Input formulas are in NNF Input formulas are checked for

Basic assumptions and notations Input formulas are in NNF Input formulas are checked for satisfiability Equality formula: E 4

Removing constants: A simplification Thm. Given an equality logic formula E, there is an

Removing constants: A simplification Thm. Given an equality logic formula E, there is an algorithm that generates an equisatisfiable formula E' without constants, in polynomial time. Algorithm: Input: An equality logic formula E with constants c 1, . . . , cn Output: An equality logic formula E' such that E and E' are equisatisfiable and E' has no constants. 5

Removing constants: A simplification 1. E' : = E 2. In E', replace each

Removing constants: A simplification 1. E' : = E 2. In E', replace each constant ci, 1·i·n, with a new variable Cci. 3. For each pair of constants ci, cj such that 1·i<j·n, add the constraint Cci Ccj to E'. In the following we assume that the input equality formulas do not have constants. 6

Uninterpreted functions Def. An equality logic formula with uninterpreted functions and uninterpreted predicates is

Uninterpreted functions Def. An equality logic formula with uninterpreted functions and uninterpreted predicates is defined by the following grammar: formula : : = formula ^ formula | : formula | (formula) | atom : : = term | predicate-symbol(list of terms) term : : = identifier | function-symbol(list of terms) Example: F(x)=F(G(x)) Congruence: x=G(x) ) F(x) = F(G(x)) 7

Usage of uninterpreted functions Replacing functions by uninterpreted functions in a given formula is

Usage of uninterpreted functions Replacing functions by uninterpreted functions in a given formula is a common technique to make reasoning easier. Makes the formula weaker: |= UF ) |= Ignore the semantics of the function, but: Functional congruence: Instances of the same function return the same value for equal arguments. 8

From uninterpreted functions to equality logic Two possible reductions: - Ackermann's reduction - Bryant's

From uninterpreted functions to equality logic Two possible reductions: - Ackermann's reduction - Bryant's reduction Ackermann's reduction: Given an input formula UF, add explicit constraints for functional congruence and transform the formula to an equality logic formula of the form FCE ) flat. E where FCE is a conjunction of functional-consistency constraints, and flat. E is a flattening of UF. 9

 Algoritm: Ackermann's reduction Input: UF with m instances of an uninterpreted function F

Algoritm: Ackermann's reduction Input: UF with m instances of an uninterpreted function F Output: such that is valid iff UF is valid 1. Assign indices to the UF-instances. 2. flat. E= T( UF) where T replaces each Fi by a fresh fi 3. FCE : = ^i=1. . m-1 ^j=i+1. . m (T(arg(Fi)) = T(arg(Fj))) ) fi=fj 4. Return : = FCE ) flat. E 10

Ackermann's reduction: Example (x 1 x 2) _ (F(x 1) = F(x 2)) _

Ackermann's reduction: Example (x 1 x 2) _ (F(x 1) = F(x 2)) _ (F(x 1) F(x 3)) flat. E = (x 1 x 2) _ (f 1 = f 2) _ (f 1 f 3)) FCE = (x 1=x 2 ) f 1=f 2) ^ (x 1=x 3 ) f 1=f 3) ^ (x 2=x 3 ) f 2=f 3) : = FCE ) flat. E 11

Ackermann's reduction: validity vs. satisfiability : = FCE ) flat. E is valid iff

Ackermann's reduction: validity vs. satisfiability : = FCE ) flat. E is valid iff UF is valid Validity check of UF: check for validity or : for unsatisfiability What if we want to check satisfiability of UF? Ackermann's reduction in the above form maintains validity, not satisfiability! Solution: check satisfiability of : = FCE ^ flat. E 12

Bryant's reduction Case expression: Fi* = case x 1=xi : f 1 x 2=xi

Bryant's reduction Case expression: Fi* = case x 1=xi : f 1 x 2=xi : f 2. . . true : fi where xi is the argument arg(Fi) of Fi for all i Semantics: _j=1, . . . , i (Fi* = fj ^ (xj=xi) ^ ^ k=1, . . . , j-1 (xk xi)) 13

Bryant's reduction: Algorithm Input: An EUF formula UF with m instances of an uninterpreted

Bryant's reduction: Algorithm Input: An EUF formula UF with m instances of an uninterpreted function F Output: An EF formula such that is valid iff UF is valid 1. Assign indices to the uninterpreted-function instances from subexpressions outwards. 2. Return E : = T *( UF) where T * replaces each Fi(arg(Fi)) by case T *(arg(F 1)) = T *(arg(Fi)) : f 1. . . T *(arg(Fi-1)) = T *(arg(Fi)) : fi-1 true : fi 14

Bryant's reduction: Example int power 3_con (int in) { int i, out; out =

Bryant's reduction: Example int power 3_con (int in) { int i, out; out = in; for (i = 0; i < 2; i++) out = out * in; return out; } int power 3_con_new (int in) { return ((in * in); } 15

Bryant's reduction: Example int power 3_con (int in) { int i, out; out =

Bryant's reduction: Example int power 3_con (int in) { int i, out; out = in; for (i = 0; i < 2; i++) out = out * in; return out; } int power 3_con_new (int in) { return (in * in) * in; } : = out 0 = in ^ out 1 = out 0 * in ^ out 2 = out 1 * in 2 : = out 0_new = (in * in) * in ^ ) out 2 = out 0_new 16

 : = (out 0 = in ^ out 1 = out 0 *

: = (out 0 = in ^ out 1 = out 0 * in ^ out 2 = out 1 * in ^ out 0_new = (in * in) ) out 2 = out 0_new UF : = (out 0 = in ^ out 1 = G(out 0, in) ^ out 2 = G(out 1, in) ^ out 0_new = G(G(in, in)) ) out 2 = out 0_new 17

 UF : = (out 0 = in ^ out 1 = G(out 0,

UF : = (out 0 = in ^ out 1 = G(out 0, in) ^ out 2 = G(out 1, in) ^ out 0_new = G(G(in, in)) ) out 2 = out 0_new E : = (out 0 = in ^ out 1 = G 1* ^ out 2 = G 2* ^ out 0_new = G 4* ) out 2 = out 0_new with G 1* = g 1 G 2* = case out 0=out 1^ in=in : g 1 true : g 2 G 3* = case out 0=in ^ in=in : g 1 case out 1=in ^ in=in : g 2 true : g 3 18

 UF : = (out 0 = in ^ out 1 = G(out 0,

UF : = (out 0 = in ^ out 1 = G(out 0, in) ^ out 2 = G(out 1, in) ^ out 0_new = G(G(in, in)) ) out 2 = out 0_new E : = (out 0 = in ^ out 1 = G 1* ^ out 2 = G 2* ^ out 0_new = G 4* ) out 2 = out 0_new and with G 4* = case out 0=G 3* ^ in=in : g 1 case out 1= G 3* ^ in=in : g 2 case in= G 3* ^ in=in : g 3 true : g 4 19

EUF: where are we now? We introduced equality logic and uninterpreted functions We showed

EUF: where are we now? We introduced equality logic and uninterpreted functions We showed how to eliminate constants We used Ackermann's and Bryant's algorithms to reduce the validity question in equality logic with uninterpreted functions to validity questions in equality logic Next: Decision procedures for equality logic and uninterpreted functions 20