View
232
Download
1
Tags:
Embed Size (px)
Citation preview
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
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
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.
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).
Partial Order Constraints Examples
• Let F = {f, g, h}
• The following are partial order constraints on F:
))()(()(
)()()(
))()(()(
3
2
1
hfghgf
fhhggf
hghfgf
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?
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
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
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)
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
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 Φ.
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.
“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
Encoding of Axioms:Examples
For a set F• Reflexivity of = is encoded by:
• Transitivity of < is encoded by:
ffFf
hfhggfFhgf
)(,,
“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).
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.
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
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.
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.
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
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
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
A symbol-based propositional encoding, cont.
• We encode a constraint Φ by replacing each atom (e.g. (f < g)) with its k-bit encoding.
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
A symbol-based encoding Example, cont.
2
2 2 2 2 1
|| ( ) ||
( ) (( ) || ( ) || )
f g
g f f g f g
111||)(|| gfgf
)()(||)(|| 22112 hghghg
A symbol-based encoding Example, cont.
Putting it all together:
A satisfying assignment:
))()((
)))()(()((
1122
112222
hghg
gfgfgf
1
0
1222
11
ffhg
hg
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
Theorem 2
• A partial order constraint Φ on symbols F is satisfiable if and only if its symbol-based propositional encoding is satisfiable.
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.
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.
Alternative encodingExample
• The constraint:
is encoded as follows: (a1, a2 are the special variables)
))()(()( gfhggf
21
))(())((
)(
22212
1211
hgagfa
aaa
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
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
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.
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
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))
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?
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.
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
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
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.
Experimentation results
poSATTTT
Total8.983647.48
Average0.0120.86
Max0.477317.63
• Running time in seconds for strict-LPO termination