binary decision diagrams for first order predicate logic by: jan friso groote afsaneh shirazi

53
Binary Decision Diagrams for First Order Predicate Logic By: Jan Friso Groote Afsaneh Shirazi

Upload: virgil-gregory

Post on 23-Dec-2015

227 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Binary Decision Diagrams for First Order Predicate Logic By: Jan Friso Groote Afsaneh Shirazi

Binary Decision Diagrams for First Order Predicate Logic

By: Jan Friso Groote

Afsaneh Shirazi

Page 2: Binary Decision Diagrams for First Order Predicate Logic By: Jan Friso Groote Afsaneh Shirazi

2

BDDs for FOL

First order predicate logic Binary Decision Diagrams Simple operations on BDDs Advanced operations on BDDs Algorithm Example

Page 3: Binary Decision Diagrams for First Order Predicate Logic By: Jan Friso Groote Afsaneh Shirazi

3

First Order Predicate Logic

V : variables , F : functions , Pr : predicate symbols Terms:

x V is a term If f F is a function symbol of arity r and t1,…, tr are terms,

then f(t1,…, tr) is a term Set of all terms over F and V is denoted by T(F,V) Set of all predicates of the form P(t1,…,tr) is denoted

by P(Pr, F, V)

Page 4: Binary Decision Diagrams for First Order Predicate Logic By: Jan Friso Groote Afsaneh Shirazi

4

Substitution

Substitution is a mapping :V T(F,V) [x1:=t]: maps each variable x to (x), except

x1 to t Composition: o (t) = ((t)) We assume that is extended : term to term,

predicates to predicates

Page 5: Binary Decision Diagrams for First Order Predicate Logic By: Jan Friso Groote Afsaneh Shirazi

5

Formulas

Formulas are defined by: t, f P(t1, …, tr) P(Pr, F, V) is a formula is a formula and are formulas is a formula is a formula, and x V is a variable x. and x. are formulas

Set of all formulas: F (Pr, F, V)

Page 6: Binary Decision Diagrams for First Order Predicate Logic By: Jan Friso Groote Afsaneh Shirazi

6

Structure and Interpretation

A Structure is a ,multi-tuple = <A; R1, R2,…;F1, F2,…> where A is a non empty set R1, R2,… are relations on A F1, F2,… are functions on A

Herbrand structures have the form H = <T(F,); R1, R2,…;f1, f2,…>

Let be a structure and : V A be a valuation. The interpretation : T(F, V) A of a term t is defined: if x V

)(][ xx

][t

)][,...,]([)],...,([ 11

rjrj ttFttf

Page 7: Binary Decision Diagrams for First Order Predicate Logic By: Jan Friso Groote Afsaneh Shirazi

7

Interpretation of a formula

F (Pr, F, V) {0,1}:][

)]([max].[

)]([min].[

)][,]min([][

][1][

otherwise 0

][,...,][ if 1)],...,([

1][

0][

]:[

]:[

11

axAa

axAa

irri

x

x

Rttttp

t

f

Page 8: Binary Decision Diagrams for First Order Predicate Logic By: Jan Friso Groote Afsaneh Shirazi

8

FOL

, ╞ iff ╞ iff , ╞ unsatisifiable iff for each there is a

valuation , , ╞

1][

Page 9: Binary Decision Diagrams for First Order Predicate Logic By: Jan Friso Groote Afsaneh Shirazi

9

equivalency

strongly (logically) equivalent (,╞ iff ,╞ )

logically equivalent (╞ iff ╞ ) weakly (logically) equivalent

,╞ iff ,╞ No free variables: strong logical equivalence

and logical equivalence coincide

Page 10: Binary Decision Diagrams for First Order Predicate Logic By: Jan Friso Groote Afsaneh Shirazi

10

Binary Decision Diagrams

A BDD, is an acyclic, node labeled graph where Q : finite set of nodes l : Q {0, 1} P(Pr, F, V) {0, 1} is a node

labeling, that l(q) 0, 1 for all qQ is the false continuation of a node is the true continuation of a node s Q {0, 1} is a start node 0 is a symbol representing false, and 1 representing

truth Each sequence q0 q1 … is bounded

f

t

0

1

)1,0,,,,,( slQBtf

Page 11: Binary Decision Diagrams for First Order Predicate Logic By: Jan Friso Groote Afsaneh Shirazi

11

Interpretation of a BDD

Let B be a BDD, be a structure and be a valuation. A , -path of a node q0 Q is the sequence

where qn {0,1} and for each i, i = f if , ╞ l(qi) and i = t if , ╞ l(qi)

If q0 ends in 1 we say that q0 holds, , ╞ q0

So, A BDD yields a truth value.

nqqqn 110

...10

Page 12: Binary Decision Diagrams for First Order Predicate Logic By: Jan Friso Groote Afsaneh Shirazi

12

0 Bt = 1Bf = P(t1,…,tr)BP(t1, …, tr) =

0 1

0 1 1 0

0 1 0 1 0 1

0 1

If B =

If B =

then B =

and B = then B =

Page 13: Binary Decision Diagrams for First Order Predicate Logic By: Jan Friso Groote Afsaneh Shirazi

13

Example

)()( xPxP

P(x)

0

0

P(x)

1

P(x)

Q(y)

1

R(z)

0

)())()(( zRyQxP

Page 14: Binary Decision Diagrams for First Order Predicate Logic By: Jan Friso Groote Afsaneh Shirazi

14

BDD

Let be a (quantifier free) formula and B its corresponding BDD. For each structure and each valuation we find that

, ╞ iff , ╞ B Proof: Straightforward on the structure of

Page 15: Binary Decision Diagrams for First Order Predicate Logic By: Jan Friso Groote Afsaneh Shirazi

15

BDDs for FOL

First order predicate logic Binary Decision Diagrams Simple operations on BDDs Advanced operations on BDDs Algorithm Example

Page 16: Binary Decision Diagrams for First Order Predicate Logic By: Jan Friso Groote Afsaneh Shirazi

16

Neglect Operator

Let be a BDD. Neglect operator is defined for some q,p q, p q by:

)1,0,,,,,( slQBtf

t

}|,{},|,{'

}{\'

if

if '

112121 prqrprprrr

pQQ

psq

psss

where

f

)1,0,',',',,'()( slQBN

tf

p

Page 17: Binary Decision Diagrams for First Order Predicate Logic By: Jan Friso Groote Afsaneh Shirazi

17

p,q-join Operator

If then

}|,{}|,{'

}{\'

if

if '

11221 qrprqrrr

qQQ

qsp

qsss

where

)1,0,',',',,'()(, slQBJtf

qp

',,',),()( rqrqrprpqlpltftf

Page 18: Binary Decision Diagrams for First Order Predicate Logic By: Jan Friso Groote Afsaneh Shirazi

18

f-merge and f-sort operators

f-merge and f-sort operators, sort the BDD such that labels occur in ascending order.

Sorting a BDD is NP-hard Avoid sorting a BDD

Page 19: Binary Decision Diagrams for First Order Predicate Logic By: Jan Friso Groote Afsaneh Shirazi

19

f-merge Operator

If then

}|,{},|,{'

removed) are parts reachablenon ('

2121 qprpqrprrr

QQ

where

fff

)()(, qlplqpf

)1,0,,,',,'()( slQBMtf

fp

Page 20: Binary Decision Diagrams for First Order Predicate Logic By: Jan Friso Groote Afsaneh Shirazi

20

f-sort Operator If then

}|,'{}',''{

}|'',{}|,{'

}|,{}|,'{},''{

}|'',{}or |,{'

removed) are parts reachablenon }('','{'

otherwise )(

'' if )(

' if )(

)('

221

2121

rprppp

prprprrr

rqrprqrppp

prprprprrr

ppQQ

rl

prql

prpl

rl

where

t

ttt

ft

fff

)()(, qlplqpf

)1,0,',',',','()( slQBSft

fp

Page 21: Binary Decision Diagrams for First Order Predicate Logic By: Jan Friso Groote Afsaneh Shirazi

21

Page 22: Binary Decision Diagrams for First Order Predicate Logic By: Jan Friso Groote Afsaneh Shirazi

22

Simple Operations on BDDs

Lemma: (Soundness) Let B be a BDD. In case O is applicable to B, O(B) B

(O is one of )

Proof: check that for all structures and valuations , ╞ O(B) iff , ╞ B

Definition: B is reduced iff non of the operators is applicable

fp

tp

fp

tpqpp SSMMJN and ,,,, ,

Page 23: Binary Decision Diagrams for First Order Predicate Logic By: Jan Friso Groote Afsaneh Shirazi

23

Simple Operations on BDDs

Lemma: Let B, C be BDDs pQB and qQC .Let be a structure and a valuation such that , ╞ p and , ╞ q. P(t1,…,tn) : label not occurring in subdags p and q. Then Exists a structure and a valuation , ╞ p, , ╞ q and , ╞ P(t1,…,tn) Exists a structure and a valuation , ╞ p, , ╞ q and , ╞ P(t1,…,tn)

Page 24: Binary Decision Diagrams for First Order Predicate Logic By: Jan Friso Groote Afsaneh Shirazi

24

Simple Operations on BDDs

Lemma: Let B and C be reduced BDDs. pQB and qQC such that p q. Then, l(p) = l(q) pf qf

pt qt

If B,C are the same, then p=q

back

Page 25: Binary Decision Diagrams for First Order Predicate Logic By: Jan Friso Groote Afsaneh Shirazi

25

Isomorphism

Let B and C be BDDs.

f: QB{0B,1B} QC{0C,1C} is called homomorphism iff lC(f(p))=lB(p), f(pf ) = f(p)f and f(pt) = f(p)t . In case f is bijective, f is called isomorphism.

B = C (isomorphic) if there exists an isomorphism f.

Page 26: Binary Decision Diagrams for First Order Predicate Logic By: Jan Friso Groote Afsaneh Shirazi

26

Example

)()( xQxP

P(x)

0

0

Q(x)

1

P(x)

Q(x)

B C

f

Page 27: Binary Decision Diagrams for First Order Predicate Logic By: Jan Friso Groote Afsaneh Shirazi

27

Theorem

B and C are reduced BDDs, B C. Then B = C (isomorphic).

Proof

back

Page 28: Binary Decision Diagrams for First Order Predicate Logic By: Jan Friso Groote Afsaneh Shirazi

28

Theorem

Operators can be applied a finite number of times to B.

Proof

fp

tp

fp

tpqpp SSMMJN and ,,,, ,

back

Page 29: Binary Decision Diagrams for First Order Predicate Logic By: Jan Friso Groote Afsaneh Shirazi

29

R(B)

Let B be a BDD, C be a reduced BDD, B C. According to theorem C is unique up to an isomorphism and It can be efficiently obtained (Thrm) R(B) for C

R(B) = Bt ( tautology)

R(B) = Bf ( contradiction) Basis for Propositional Logic

Page 30: Binary Decision Diagrams for First Order Predicate Logic By: Jan Friso Groote Afsaneh Shirazi

30

Advanced Operations on BDDs Copying Operator C(B): puts B in conjunction

with a copy of itself (different variables) Unification Operator U(B): instantiate B

according to ( is a relevant unifier)

Page 31: Binary Decision Diagrams for First Order Predicate Logic By: Jan Friso Groote Afsaneh Shirazi

31

Copy Operator

Let B be a BDD in which variables occur.

not occurring in B

x

]:[)( 1

xxBBBC

1

x

Page 32: Binary Decision Diagrams for First Order Predicate Logic By: Jan Friso Groote Afsaneh Shirazi

32

Unifier

A substitution is called a unifier of P(t1, …, tn) and Q(u1, …, um) iff (P(t1,…, tn))=(Q(u1,…,um))

A unifier is most general (MGU) iff for each unifier ’ of P(t1,…, tn) and Q(u1,…,um) there is a substitution such that o = ’

Idempotent MGU: ((x)) = x Linear time

Page 33: Binary Decision Diagrams for First Order Predicate Logic By: Jan Friso Groote Afsaneh Shirazi

33

Relevant Unifier

A node p of B is redundant iff pt pf A path

is allowed iff there are no i, j such that l(pi)=l(pj) and i j

A node is truth-truth capable iff there is an allowed path

lpppnn

n

110

...10

1...11

1

nn

n

t

ppp

Page 34: Binary Decision Diagrams for First Order Predicate Logic By: Jan Friso Groote Afsaneh Shirazi

34

Relevant Unifier

A valuation is a relevant unifier iff

pi is not redundant, if i = f, pi is not truth-truth capable, and for some i, j, i = f, j = t and is an idempotent MGU of l(pi) and l(pj).

1...110

1

nn

npps

Page 35: Binary Decision Diagrams for First Order Predicate Logic By: Jan Friso Groote Afsaneh Shirazi

35

Lemma

Let B be a reduced BDD. No redundant nodes Every path allowed If pi is not truth-truth capable pit = 0

is a relevant unifier iff for some i, j, i=f, j=t and is the MGU of l(pi) and l(pj) on the rightmost path of B

1...110

10

nn

nppp

Page 36: Binary Decision Diagrams for First Order Predicate Logic By: Jan Friso Groote Afsaneh Shirazi

36

MGU

y = a

Page 37: Binary Decision Diagrams for First Order Predicate Logic By: Jan Friso Groote Afsaneh Shirazi

37

Unification Operator

If is a relevant unifier of B

Lemma: (Soundness) B C(B) B B U(B)

Proof: easy logical consequence

)()( BBU

back

Page 38: Binary Decision Diagrams for First Order Predicate Logic By: Jan Friso Groote Afsaneh Shirazi

38

BDDs for FOL

First order predicate logic Binary Decision Diagrams Simple operations on BDDs Advanced operations on BDDs Algorithm Example

Page 39: Binary Decision Diagrams for First Order Predicate Logic By: Jan Friso Groote Afsaneh Shirazi

39

Algorithm

)))((e(TryToReduc of unifiersrelevant allFor

stop and ble'unsatisfia'report , If

)e(TryToReduc

Endrepeat

))((:

)e(TryToReduc

Repeat

)(:

)Solve(

BURB

BB

B

BCRB

B

BRB

f

Avoid expensive sorting operator

All pairs of pi, pj in the rightmost path, with pit=0 and pjt0 Linearly in size of terms

Page 40: Binary Decision Diagrams for First Order Predicate Logic By: Jan Friso Groote Afsaneh Shirazi

40

Algorithm

)))((e(TryToReduc of unifiersrelevant allFor

stop and ble'unsatisfia'report , If

)e(TryToReduc

Endrepeat

))((:

)e(TryToReduc

Repeat

)(:

)Solve(

BURB

BB

B

BCRB

B

BRB

f

Avoid sorting by grouping predicates with the same predicate symbol

The depth of recursive calls is limited by the number of free variables

Page 41: Binary Decision Diagrams for First Order Predicate Logic By: Jan Friso Groote Afsaneh Shirazi

41

Algorithm

)))((e(TryToReduc of unifiersrelevant allFor

stop and ble'unsatisfia'report , If

)e(TryToReduc

Endrepeat

))((:

)e(TryToReduc

Repeat

)(:

)Solve(

BURB

BB

B

BCRB

B

BRB

f

))))))))(((...((...(((21 BCRCRURUR

Page 42: Binary Decision Diagrams for First Order Predicate Logic By: Jan Friso Groote Afsaneh Shirazi

42

Algorithm

The program is browsing through larger and larger BDDs of the form

We stop: Bf Lemma

Bt

))))))))(((...((...(((21 BCRCRURUR

Page 43: Binary Decision Diagrams for First Order Predicate Logic By: Jan Friso Groote Afsaneh Shirazi

43

Russel’s Paradox

A set which contains those sets that are not members of themselves

F(x,y): x is a member of y Problem: negated and Skolemised formula

)),(),(( yyFxyFyx

),(),( yyFayF

Page 44: Binary Decision Diagrams for First Order Predicate Logic By: Jan Friso Groote Afsaneh Shirazi

44

Russel’s Paradox

(y) = a

),(),( yyFayF

Example

Page 45: Binary Decision Diagrams for First Order Predicate Logic By: Jan Friso Groote Afsaneh Shirazi

45

Thank You

Page 46: Binary Decision Diagrams for First Order Predicate Logic By: Jan Friso Groote Afsaneh Shirazi

46

Appendix A

Thrm: B and C are reduced BDDs, B C. Then B = C (isomorphic).

Proof: Define f: QBQC and g: QCQB

f(p) = q such that p q

g(q) = p such that p q

f is a homomorphism, g is the inverse of f

f is an isomorphism

We assumed f and g are well defined.

Page 47: Binary Decision Diagrams for First Order Predicate Logic By: Jan Friso Groote Afsaneh Shirazi

47

Proof

B C and all nodes in B are reachable from the root each node in B is related via to 1 node in C

p related to q1,q2 q1 q2

q1 = q2

(using thrm)

back

Page 48: Binary Decision Diagrams for First Order Predicate Logic By: Jan Friso Groote Afsaneh Shirazi

48

Appendix B

Proof: The transformation operators can be formulated as rewrite rules.l1 and l2 are predicates. l1 > l2

tp

fp

p

tp

fp

Mzxlzylxl

Mzxlzyxll

Nxxxl

Szylzxllzylxl

Szylzxllzyxll

),()),(,(

),()),,((

),(

)),(),,(()),(,(

)),(),,(()),,((

111

111

1

11221

11221

Page 49: Binary Decision Diagrams for First Order Predicate Logic By: Jan Friso Groote Afsaneh Shirazi

49

Proof

To each DAG we can obtain its canonical tree by undoing the sharing of subdags. Application of these rules must terminate on these trees.

Each rewrite of the DAG corresponds to one or more rewrite of canonical tree.

In Join operator the number of nodes are strictly decreasing It should terminate

back

Page 50: Binary Decision Diagrams for First Order Predicate Logic By: Jan Friso Groote Afsaneh Shirazi

50

Appendix C

A set is circular if it is a member of another set, which in turn is a member of the original.

There is no set containing all non circular sets.

Problem: negated and Skolemised formula (a, f are

skolem functions)

))),(),((),(( xzFzxFzyxFxy

)),())),(())(,(((

))),(),((),((

axFxxfFxfxF

xzFzxFaxF

Page 51: Binary Decision Diagrams for First Order Predicate Logic By: Jan Friso Groote Afsaneh Shirazi

51

There are no circular sets

Two relevant unifier:1. Mapping z and x to a2. Mapping x to z

)),())),(())(,(((

))),(),((),((

axFxxfFxfxF

xzFzxFaxF

Page 52: Binary Decision Diagrams for First Order Predicate Logic By: Jan Friso Groote Afsaneh Shirazi

52

There are no circular sets

We must apply copying operator.6 relevant unifier:1. x:=a z:=a2. u:=a v:=a3. x:=v u:=a4. u:=z x:=a5. z:=x6. v:=u

Page 53: Binary Decision Diagrams for First Order Predicate Logic By: Jan Friso Groote Afsaneh Shirazi

53

There are no circular sets

We apply first unifier.4 relevant unifier:1. u:=f(a) v:=a2. u:=a v:=a3. u:=a4. v:=u

back