Presentation is loading. Please wait.

Presentation is loading. Please wait.

Solving Partial Order Constraints for LPO termination.

Similar presentations


Presentation on theme: "Solving Partial Order Constraints for LPO termination."— Presentation transcript:

1 Solving Partial Order Constraints for LPO termination

2 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.

3 SAT formulae and 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.

4 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.

5 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).

6 Partial Order Constraints Examples Let F = {f, g, h} The following are partial order constraints on F:

7 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?

8 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

9 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

10 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)

11 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

12 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 Φ.

13 Solving Partial Order Constraints Using 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.

14 “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.

15 Encoding of Axioms: Examples For a set F Reflexivity of = is encoded by: Transitivity of < is encoded by:

16 “Atom-based” encoding: Size of the resulting formulae For |F| = n, the resulting formula involves: O(n 2 ) variables. O(n 3 ) 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).

17 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.

18 Integer assignment and solution Example 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.

19 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.

20 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.

21 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

22 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:

23 A symbol-based propositional encoding, cont. A constraint of the form (f > g) is encoded recursively by: for k > 1

24 A symbol-based propositional encoding, cont. We encode a constraint Φ by replacing each atom (e.g. (f < g)) with its k-bit encoding.

25 A symbol-based encoding Example The constraint on F={g,f,h}: The propositional variables are:

26 A symbol-based encoding Example, cont.

27 Putting it all together: A satisfying assignment:

28 A symbol-based encoding Solution 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

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

30 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(n 2 ) variables. –O(n 3 ) connectives.

31 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.

32 Alternative encoding Example The constraint: is encoded as follows: (a 1, a 2 are the special variables)

33 Alternative symbol-based encoding Size The encoding of a constraint Φ with on a set F with n symbols involves –O(n 2 ) variables. (for each unique atom in Φ) –O(|Φ|+ n 2 log(n)) connectives. Good for long constraints

34 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.

35 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.

36 Term Rewrite Systems Example Fibonacci:

37 Term Rewrite Systems Example, 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))

38 Term Rewrite Systems Importance 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?

39 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.

40 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.

41 Partial Order Constraints and 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):

42 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.

43 Experimentation results TTTpoSAT 647.488.983Total 0.860.012Average 317.630.477Max Running time in seconds for strict-LPO termination

44 Thank you!


Download ppt "Solving Partial Order Constraints for LPO termination."

Similar presentations


Ads by Google