Top Banner
Solving Partial Order Constraints for LPO termination
44

Solving Partial Order Constraints for LPO termination

Feb 01, 2016

Download

Documents

powa

Solving Partial Order Constraints for LPO termination. Outline. We are given a partial order constraint, which is a formula of the form The constraint is satisfiable if there exists a partial order on the symbols of the formula (f, g, h in the example above) that makes the formula true. - PowerPoint PPT Presentation
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Solving Partial Order Constraints for LPO termination

Solving Partial Order Constraints for LPO termination

Page 2: Solving Partial Order Constraints for LPO termination

Outline

• We are given a partial order constraint, which is a formula of the form

• The constraint is satisfiable if there exists a partial order on the symbols of the formula (f, g, h in the example above) that makes the formula true.

• The partial order h<f=g makes the above formula true, hence it is satisfiable.

• The problem is NP-complete.

))()(()( fhhggf

Page 3: Solving Partial Order Constraints for LPO termination

SAT formulaeand SAT-solver

• Logic formulae in propositional logic:

• Satisfiability: Is there an assignment of truth values to the variables in the formula, which makes the formula true?

• SAT solvers test for satisfiability of a formula.• Can handle hundreds of thousands of clauses.• A practical way to handle NP-hard problems, up to

some extent.

)()( 241321 xxxxxx

Page 4: Solving Partial Order Constraints for LPO termination

Outline, cont.

• To decide satisfiability of a constraint Φ:– Encode it as a SAT formula Φ’;– Use SAT-solver to the satisfiability of Φ’ .

• Running time of a SAT solver depends upon the formula’s length and number of variables.

• We want to encode the constraint in a compact way – to reduce the running time of the SAT solver.

Page 5: Solving Partial Order Constraints for LPO termination

Partial order constraints

• A partial order constraint is just like a formula in propositional logic, except that propositions are atoms of the form(f < g) or (f = g).

Page 6: Solving Partial Order Constraints for LPO termination

Partial Order Constraints Examples

• Let F = {f, g, h}

• The following are partial order constraints on F:

))()(()(

)()()(

))()(()(

3

2

1

hfghgf

fhhggf

hghfgf

Page 7: Solving Partial Order Constraints for LPO termination

Partial Order Constraints Examples (cont.)

• Φ1 can be satisfied by the orders:

– g < f < h

– g = h < f

• Φ2 cannot be satisfied.

• Can Φ3 be satisfied?

Page 8: Solving Partial Order Constraints for LPO termination

Total Order

≤ is a total order if it is:

• Transitive.

• Reflexive.

• Anti-symmetric.

• Total on a set F: for every a,b in F, a ≤b or b ≤a.

Example: g<f=d<h=e

Page 9: Solving Partial Order Constraints for LPO termination

Partial Order Constraints Satisfiabilty

• The definition of satisfiabilty is changed.

• A constraint Φ on a set F is satisfiable if there exists an total order ≤ on F such that Φ is true when atoms in Φ are interpreted as follows:– (a < b) in Φ is true iff (a ≤ b) and ¬(b ≤ a) in

the total order– (a = b) in Φ is true iff (a ≤ b) and (b ≤ a) in the

total order

Page 10: Solving Partial Order Constraints for LPO termination

Axioms on the derived relations < and=

For every f, g and h in F:

• Reflexivity: (f = f)

• Symmetry: (f = g) implies (g = f)

• Asymmetry: ¬((f > g) and (g < f))

• Transitivity:((f > g) and (g > h)) implies (f > h)((f = g) and (g = h)) implies (f = h)

Page 11: Solving Partial Order Constraints for LPO termination

More Axioms on < and =

• Identity: ((f > g) and (g = h)) implies (f > h) ((f = g) and (g > h)) implies (f > h)

• Comparability:(f > g) or (f < g) or (f = g)

• Comment: Comparability is required from a total order

Page 12: Solving Partial Order Constraints for LPO termination

Partial and Total orders

• Recall that any partial order can be extended into a total order.

• For negation-free constraints: If there exists an partial order such that Φ is satisfied, then there exists a total order as well.

• We are concerned with the question of satisfiability of partial order constraints. Not, for example, the number of possible partial orders satisfying Φ.

Page 13: Solving Partial Order Constraints for LPO termination

Solving Partial Order ConstraintsUsing SAT-solvers

• Encoding: A partial order constraint Φ on a set of symbols F is encoded by a propositional formula Φ’ such that Φ is satisfiable if and only if Φ’ is.

• A good encoding yields short formulae with a small number of variables.

Page 14: Solving Partial Order Constraints for LPO termination

“Atom-based” Encoding

• First approach: atom-based encoding. Encode each atom as a propositional variable.

• Notation: denotes the propositional variable corresponding to atom a.

• Enforce the axioms of order and equality by adding propositions to the formula.

a

Page 15: Solving Partial Order Constraints for LPO termination

Encoding of Axioms:Examples

For a set F• Reflexivity of = is encoded by:

• Transitivity of < is encoded by:

ffFf

hfhggfFhgf

)(,,

Page 16: Solving Partial Order Constraints for LPO termination

“Atom-based” encoding: Size of the resulting formulae

• For |F| = n, the resulting formula involves:

• O(n2) variables.

• O(n3) connectives.

• This bound is always met.

• Even if the formula is short, we still need – A variable for every pair of symbols in F.– A few connectives for every three symbols in

F. (just to encode transitivity, for example).

Page 17: Solving Partial Order Constraints for LPO termination

Integer assignment and solution

Let Φ be a partial order constraint on F, and let |F |=n.

• An integer assignment for Φ is a mapping μ : F→{1,…,n}

• An integer solution for Φ is an assignment θ which makes Φ true under the natural interpretations of < and = on the natural numbers.

Page 18: Solving Partial Order Constraints for LPO termination

Integer assignment and solutionExample

• Consider again the constraint:

• The assignment f = 2, g=1, h=1 is an integer solution for Φ1.

• So is: f=2, g=1, h=3.

))()(()(1 hghfgf

Page 19: Solving Partial Order Constraints for LPO termination

Theorem 1

• A partial order constraint is satisfiable if and only if it has an integer solution.

• Reminder: a constraint is satisfiable if there exists a total order that makes it true.

Page 20: Solving Partial Order Constraints for LPO termination

A symbol-based propositional encoding

• Encoding: A partial order constraint Φ on a set of symbols F is encoded by a propositional formula Φ’ such that Φ is satisfiable if and only if Φ’ is.

• Our approach: Symbol-based. we encode the values of the symbols in F in an integer solution.

Page 21: Solving Partial Order Constraints for LPO termination

A symbol-based propositional encoding, cont.

• Each symbol is modeled using propositional variables that

encode the binary representation of its value.

• Constraints of the form (f < g) or (f = g) are interpreted as constraints on integers, encoded in k-bit arithmetic.

• Denote the encoding by: ||(f < g)||k

nk 2log

Page 22: Solving Partial Order Constraints for LPO termination

A symbol-based propositional encoding, cont.

• For a symbol f in F, the k-bit representation of its value is:

• A constraint of the form (f = g) is encoded by:

1,..., fff k

)(||)(||1

ii

k

ik gfgf

Page 23: Solving Partial Order Constraints for LPO termination

A symbol-based propositional encoding, cont.

• A constraint of the form (f > g) is encoded recursively by:

for k > 1

111||)(|| gfgf

1

|| ( ) ||

( ) (( ) || ( ) || )

k

k k k k k

f g

f g f g f g

Page 24: Solving Partial Order Constraints for LPO termination

A symbol-based propositional encoding, cont.

• We encode a constraint Φ by replacing each atom (e.g. (f < g)) with its k-bit encoding.

Page 25: Solving Partial Order Constraints for LPO termination

A symbol-based encodingExample

The constraint on F={g,f,h}:

The propositional variables are:

)()( hggf

121212 ,,,,, hhggff

23log

3

2 k

n

222)()( hggf

Page 26: Solving Partial Order Constraints for LPO termination

A symbol-based encoding Example, cont.

2

2 2 2 2 1

|| ( ) ||

( ) (( ) || ( ) || )

f g

g f f g f g

111||)(|| gfgf

)()(||)(|| 22112 hghghg

Page 27: Solving Partial Order Constraints for LPO termination

A symbol-based encoding Example, cont.

Putting it all together:

A satisfying assignment:

))()((

)))()(()((

1122

112222

hghg

gfgfgf

1

0

1222

11

ffhg

hg

Page 28: Solving Partial Order Constraints for LPO termination

A symbol-based encodingSolution of the Example

• We found the satisfying assignment:

• The corresponding integer solution is:f=3, h=2, g=2

• The corresponding total order is: h=g<f

1 1

2 2 2 1

0

1

g h

g h f f

Page 29: Solving Partial Order Constraints for LPO termination

Theorem 2

• A partial order constraint Φ on symbols F is satisfiable if and only if its symbol-based propositional encoding is satisfiable.

Page 30: Solving Partial Order Constraints for LPO termination

A symbol-based encoding:Size

• The encoding of a constraint Φ with n symbols involves:

– O(nlog(n)) variables.

– O(|Φ|log(n)) connectives.

• Recall that in the first approach, the encoding involved:

– O(n2) variables.

– O(n3) connectives.

Page 31: Solving Partial Order Constraints for LPO termination

What if Φ is long? Alternative encoding

• Encode symbols as k-bit representation (as in symbol-based encoding).

• Encode each atom that appears in Φ as a special variable.

• Add propositions to connect atoms of the formula (just once!) with the symbol-based encoding of their meanings.

Page 32: Solving Partial Order Constraints for LPO termination

Alternative encodingExample

• The constraint:

is encoded as follows: (a1, a2 are the special variables)

))()(()( gfhggf

21

))(())((

)(

22212

1211

hgagfa

aaa

Page 33: Solving Partial Order Constraints for LPO termination

Alternative symbol-based encodingSize

• The encoding of a constraint Φ with on a set F with n symbols involves

–O(n2) variables.(for each unique atom in Φ)

–O(|Φ|+ n2log(n)) connectives.

• Good for long constraints

Page 34: Solving Partial Order Constraints for LPO termination

Motivation Term Rewrite Systems

• A term rewrite system is a set of rules of the form

where l and r are terms constructed from function symbols and variables.

rl

Page 35: Solving Partial Order Constraints for LPO termination

Term Rewrite Systems

• The rules of a TRS are used to rewrite expressions.

• A rule s→t can be applied on an expression e if e matches a sub-term of s.

Page 36: Solving Partial Order Constraints for LPO termination

Term Rewrite SystemsExample

• Fibonacci:

1

2

3

4

5

: 0

: ( ) ( )

: (0) 0

: ( (0)) (0)

: ( ( ( ))) ( ( )) ( )

r x x

r s x y s x y

r fib

r fib s s

r fib s s x fib s x fib x

Page 37: Solving Partial Order Constraints for LPO termination

Term Rewrite SystemsExample, cont.

Computing fib(3):• fib(s(s(s(0))) →5 fib(s(s(0))+fib(s(o))• fib(s(s(0))+fib(s(o)) →4 fib(s(s(0))+s(0)• fib(s(s(0))+s(0) →5 fib(s(0))+fib(0)+s(0)• fib(s(0))+fib(0)+s(0) →3 fib(s(0))+0+s(0)• fib(s(0))+0+s(0) →1 fib(s(0))+s(0)• fib(s(0))+s(0) →4 s(0)+s(0)• s(0)+s(0) →2 s(s(0))

Page 38: Solving Partial Order Constraints for LPO termination

Term Rewrite SystemsImportance

• A subject of theoretical interest.

• Many applications, for example:– Automatic theorem proving.– Verifications of programs and chips.

• Termination of a TRS: does the rewrite stop after a finite number of steps, for every expression?

Page 39: Solving Partial Order Constraints for LPO termination

LPO Termination of Term Rewrite Systems

• In general, termination of terms rewrite systems is undecidable.

• Lexicographic path order (LPO) is an order on the terms, that is induced by a partial order on the function symbols.

• The partial order on functions can be thought of as “precedence” order.

Page 40: Solving Partial Order Constraints for LPO termination

LPO Termination of Term Rewrite Systems, cont.

• LPO termination problem:

is there a partial order >F over function symbols, such that for every rule it hold that Where is the order induced by >F

• LPO termination implies termination of the rewrite system.

rl lpo

lpo

Page 41: Solving Partial Order Constraints for LPO termination

Partial Order Constraintsand LPO Termination

• The lexicographic path order (LPO) is induced by a partial order on the function symbols.

• The rules of the TRS unfolds a partial order constrain on the function symbols.

• Example: consider the rule s(x)+y → s(x+y):

)()()( syxsyxs Flpo

Page 42: Solving Partial Order Constraints for LPO termination

Experimentation

• Termination tools are tested against benchmarks.

• Benchmarks used: 751 rewrite systems.

• Our method, poSAT, is compared with another method called TTT.

• TTT: a fast and powerful tool with a convenient interface.

Page 43: Solving Partial Order Constraints for LPO termination

Experimentation results

poSATTTT

Total8.983647.48

Average0.0120.86

Max0.477317.63

• Running time in seconds for strict-LPO termination

Page 44: Solving Partial Order Constraints for LPO termination

Thank you!