Equality Logic and Uninterpreted Functions

advertisement
Decision Procedures in
First Order Logic
Decision Procedures for
Equality Logic
Range Allocation
Daniel Kroening and Ofer Strichman
1
Part III – Decision Procedures for Equality
Logic and Uninterpreted Functions
Algorithm I – From Equality to Propositional Logic
 
 



Adding transitivity constraints
 Making the graph chordal
 An improved procedure: consider polarity
Algorithm II – Range-Allocation
 What
is the small-model property?
 Finding a small adequate range (domain) to each variable
 Reducing to Propositional Logic
Decision Procedures
An algorithmic point of view
2
Range allocation

The small model property

Range Allocation
Decision Procedures
An algorithmic point of view
3
Uninterpreted functions
From a general formula:
u1  x1  y1  u2  x2  y2  z  u1  u2 
z  ( x1  y1 )  ( x2  y2 )
To a formula with uninterpreted functions
u1  F ( x1 , y1 )  u2  F ( x2 , y2 )  z  G (u1 , u2 ) 
z  G ( F ( x1 , y1 ), F ( x2 , y2 ))
Decision Procedures
An algorithmic point of view
4
Ackerman’s reduction
From a formula with uninterpreted functions:
u1  F ( x1 , y1 )  u2  F ( x2 , y2 )  z  G (u1 , u2 ) 
z  G ( F ( x1 , y1 ), F ( x2 , y2 ))
To a formula in the theory of equality
 x1  x2  y1  y 2  f1  f 2   




u

f

u

f

g

g

1
2
2
1
2
 1
  z  g2
u1  f1  u 2  f 2  z  g1 

Decision Procedures
An algorithmic point of view
5
The Small Model Property

Equality Logic enjoys the Small Model Property

This means that if a formula in this logic is
satisfiable, then there is a finite, bounded in size,
model that satisfies it.

It gets better: in Equality Logic we can compute this
bound, which suggests a decision procedure.

What is this bound?
Decision Procedures
An algorithmic point of view
6
The Small Model Property

Claim: the range 1..n is adequate, where n is the
number of variables in 

Proof:
 Every
satisfying assignment defines a partition of the
variables
 Every assignment that results in the same partitioning
also satisfies the formula
 The range 1..n allows all partitionings
Decision Procedures
An algorithmic point of view
7
Complexity

We need log n variables to encode the range 1…n

For n variables we need n log n bits.

This is already better than the worst-case O(n2) bits
required by the Boolean encoding method …
Decision Procedures
An algorithmic point of view
8
Finite Instantiations revisited
 x1  x2  y1  y 2  f1  f 2   


u1  f1  u 2  f 2  g1  g 2     z  g 2
u1  f1  u 2  f 2  z  g1 

Instead of giving the range [1..11], analyze connectivity:
x1
x2
y1
y2
u1
f1
f2
u2
x1, y1, x2, y2 :{0-1} u1, f1, f2, u2 : {0-3}
g1
g2
z
g1, g2, z: {0-2}
The state-space: from 1111 to ~105
Decision Procedures
An algorithmic point of view
9
Or even better:
{0}
x1
{0-1}
x2
y1
y2
u1
f1
f2
u2
x1, y1, g1 , u1 : {0}
f2, z
: {0-2}
g1
g2
z
x2, y2 , g2 , f1 : {0-1}
u2
: {0-3}
The state-space: from ~105 to 576
An Upper-bound: State-space  n!
Decision Procedures
An algorithmic point of view
10
Choosing a minimal range for the integer variables
E: :((a = b) Ç :(b = c)) !((d  e))
0. a,b,c,d,e : {1}
(1)
1. a,b,c,d,e : {1..5}
(3125)
(1..n)
(108)
(connectivity
analysis)
(12)
(factorial
reduction)
2. a,b,c
d,e
: {1..3}
: {1..2}
3. a: {1}, b:{1-2}, c: {1-3}
d: {1}, e: {1-2}
4.
...
...
Decision Procedures
An algorithmic point of view
(normal)
...
11
Before and after, in SMV
MODULE main
MODULE main
VAR
H_zN1_693_c
zN1_693_c
N1_643_c
T1_c
T1_644_c
N1_c
f_plus1
f_plus2
f_minus1
f_minus2
f_minus3
f_minus4
f_mul1
f_mul2
f_div1
f_div2
f_div3
f_div4
sqrt_1
sqrt_2
POSM_c
POSM_33_c
H0_99_c
VAR
H_zN1_693_c
zN1_693_c
N1_643_c
T1_c
T1_644_c
:0..31;
:0..31;
:0..31;
:0..31;
:0..31;
:0..31;
:0..31;
:0..31;
:0..31;
:0..31;
:0..31;
:0..31;
:0..31;
:0..31;
:0..31;
:0..31;
:0..31;
:0..31;
:0..31;
:0..31;
:boolean;
:boolean;
:boolean;
N
1
_
c
f_plus1
f_plus2
f_minus1
f_minus2
f_minus3
f_minus4
f_mul1
f_mul2
f_div1
f_div2
f_div3
f_div4
sqrt_1
sqrt_2
POSM_c
POSM_33_c
H0_99_c
Decision Procedures
An algorithmic point of view
:{‎
33}‎
‎
:{‎
33}‎
‎
:{‎
19}‎
‎
:{‎
‎
:{‎
27,28}‎
‎
;
;
;
2
7
}
‎;
;
:
{
1
9
}
;
:{‎
0,21,22‎
‎
:{‎
21,0}‎
‎
‎
:{‎
8,9,10,11}‎
‎
‎
:{‎
8,9,10,11}‎
‎
‎
:{‎
8,9,10,11}‎
‎
‎
:{‎
8,9,10,11}‎
‎
‎
:{‎
16}‎
‎
:{‎
16}‎
‎
:{‎
23,24,25}‎
‎
:{‎
23,24,25}‎
‎
:{‎
24,23}‎
‎
:{‎
23}‎
‎
:{‎
29}‎
‎
:{‎
29,30}‎
‎
:boolean;
:boolean;
:boolean;
}
;
;
;
;
;
;
;
;
;
;
;
;
;
;
12
The Range-Minimization Problem
Given an Equality formula E, find in polynomial time a small
domain D* sufficient to preserve its satisfiability
In other words: find D* such that
E is satisfiable under an infinite domain D !
E is satisfiable under the finite domain D*
Decision Procedures
An algorithmic point of view
13
The strategy
1. Determine a range allocation R, mapping each variable
xiE into a small set of integers, s.t. E is satisfiable iff it is
satisfiable over some R-interpretation.
2. Encode each variable xi as an enumerated type over R(xi),
and use a standard satisfiability checker as a decision
procedure.
Decision Procedures
An algorithmic point of view
14
What range is adequate ?

Recall that a subgraph of an E-Graph GE(E) is
unsatisfiable iff it contains a contradictory cycle.

Dfn: A Range Allocation R is adequate for GE(E) if
every satisfiable subgraph can be satisfied under R.

Now we need an algorithm to find adequate ranges
Decision Procedures
An algorithmic point of view
15
Examples:
E
Predicates in E
R
(x 1=x 2)  (x 2=x 3)
{(x 1=x 2),(x 2=x 3)} x 1,x 2,x 3  {0}
(x 1x 2)  (x 2x 3)
{(x 1x 2),(x 2x 3)} x 1  {0}
x 2  {1}
x 3  {2}
(x1x2)  ( False  (x1=x2))
{(x1x2),(x1=x2)}
(x 1=x 2)  ( False  (x 1x 2))
{(x 1x 2),(x 1=x 2)} x 1  {0}
x 2  {0,1}
x 1  {0}
x 2  {0,1}
The price of a polynomial procedure:
The predicates of E hold less information than E .
Decision Procedures
An algorithmic point of view
16
Building the E-Graph
E : {( x1  x2 ), ( y1  y2 ), (u1  f1 ), (u2  f 2 ), ( g2  z )}
E= : {( f1  f 2 ), ( g1  g2 ), (u1  f1 ), (u2  f 2 ), ( g1  z)}
x1
x2
y1
y2
u1
f1
f2
u2
g1
g2
z
Note: 1. Inconsistent subsets appear as contradictory cycles
2. Some of the vertices are mixed
Decision Procedures
An algorithmic point of view
17
The Range-Allocation Algorithm
Step I - pre-processing:
A. Remove all solid edges not belonging to contradictory
cycles.
B. Add a single unique value to singleton vertices, and
remove them from the graph.
{0}
x1
{1}
x2
{2}
y1
{3}
y2
u1
f1
f2
u2
Decision Procedures
An algorithmic point of view
g1
g2
z
18
Step II - Set construction:
A. For each mixed vertex xi:
1. Add a unique value ui to R(xi)
2. Broadcast ui on G=
3. Remove xi from the graph
B. Add a unique value to each remaining G= component
{4}
{4}
g1
{4}
g2
z
1.
{4, 5}
g1
{4, 5} z
{4, 5}
g1
{4}
g2
{4, 5} z
2.
Decision Procedures
An algorithmic point of view
19
1.
2.
3.
{6}
u1
{6}
f1
{6}
f2
{6}
u2
{6,7} {6,7} {6,7}
f1
f2
u2
{6,7, 8}
f1
{6,7, 9}
u2
{6} {6,7, 8} {6,7} {6,7, 9}
u1
f1
f2
u2
Decision Procedures
An algorithmic point of view
20
Is the allocated range adequate?

We have to satisfy every consistent subset B :
all xB, assign the smallest value allocated in step A
to a mixed vertex which is G=(B) connected to x.
 If there isn’t any, choose the value given in step B.
 For
{0}
x1
{1}
x2
{2}
y1
{3}
y2
u1
f1
f2
u2
{4, 5}
g1
{6} {6,7,8} {6,7} {6,7, 9}
Decision Procedures
An algorithmic point of view
{4}
g2
z
{4,5}
21
Further optimizations

The order in which mixed vertices are eliminated has
a strong effect.

Not all mixed vertices need to start from a unique
value. An analysis that involves solving a coloring
problem can help here…

… (see lecture notes)
Decision Procedures
An algorithmic point of view
22
A state-space story
1..n
1..i
1111
11!
connectivity basic
72
576
{0}
x1
{1}
x2
{2}
y1
{3}
y2
u1
f1
f2
u2
{6,7} {6}
order
48
{4,5}
g1
{6} {6,8}
Decision Procedures
An algorithmic point of view
color
16
?
{4}
g2
z
{4,5}
23
Download