Solving Temporal Problems using SMT: Strong Controllability Alessandro Cimatti
Andrea Micheli
Marco Roveri
Embedded Systems Unit, Fondazione Bruno Kessler Trento, Italy
[email protected]
12 October 2012
Constraint Programming 2012
Outline
1
The Strong Controllability Problem
2
SMT-based encodings DTPU encodings TCSPU specific encodings
3
Experimental Evaluation
4
Conclusion
Outline
1
The Strong Controllability Problem
2
SMT-based encodings DTPU encodings TCSPU specific encodings
3
Experimental Evaluation
4
Conclusion
The Strong Controllability Problem
SMT-based encodings
Experimental Evaluation
Conclusion
Scheduling for planning applications The motivating problem Planning subject to temporal constraints, when the agent cannot control on the actual duration of all the activities.
1/17
The Strong Controllability Problem
SMT-based encodings
Experimental Evaluation
Conclusion
Scheduling for planning applications The motivating problem Planning subject to temporal constraints, when the agent cannot control on the actual duration of all the activities. Uncertainty Type No Uncertainty Uncertainty 20 0
7 8
11
16
19 t
As
Activities
Ae Bs
Be
TimePoints 1/17
The Strong Controllability Problem
SMT-based encodings
Experimental Evaluation
Conclusion
Scheduling for planning applications The motivating problem Planning subject to temporal constraints, when the agent cannot control on the actual duration of all the activities. Uncertainty Type No Uncertainty Uncertainty 20 0
7 8
11
16
19 t
As
Ae
Activities
Bs
As
Be [7, 11]
[0, ∞)
[0, 20]
TimePoints
Be
Ae
[8, 11]
Bs 1/17
The Strong Controllability Problem
SMT-based encodings
Experimental Evaluation
Conclusion
Scheduling for planning applications The motivating problem Planning subject to temporal constraints, when the agent cannot control on the actual duration of all the activities. Uncertainty Type No Uncertainty Uncertainty 20 0
7 8
11
16
20
19
0
7 8
11
16
19
t
As
Ae
Activities
As
Bs
As
Be [7, 11]
Be
Ae Bs
Be
Ae [0, ∞)
[0, 20]
TimePoints
t
[8, 11]
Bs 1/17
The Strong Controllability Problem
SMT-based encodings
Experimental Evaluation
Conclusion
Scheduling for planning applications The motivating problem Planning subject to temporal constraints, when the agent cannot control on the actual duration of all the activities. Uncertainty Type No Uncertainty Uncertainty 20 0
7 8
11
16
20
19
0
7 8
11
16
19
t
As
Ae
Activities
As
Bs
As
Be
Ae
Be [7, 11]
Ae [0, ∞)
[0, 20]
TimePoints
t
[8, 11]
Bs
Bs
As
Be [7, 11]
[0, ∞)
[0, 20]
Be
Ae
[8, 11]
Bs 1/17
The Strong Controllability Problem
SMT-based encodings
Experimental Evaluation
Conclusion
Temporal Problems with Uncertainty Example As
[7, 11]
As , Ae , Bs are Controllable Time Points (Xc ) Be is an Uncontrollable Time Point (Xu )
[0, ∞)
[0, 20]
Be
Ae
[8, 11]
Bs
represents Free Constraints (Cf ) represents Contingent Constraints (Cc )
2/17
The Strong Controllability Problem
SMT-based encodings
Experimental Evaluation
Conclusion
Temporal Problems with Uncertainty Example As
[7, 11]
As , Ae , Bs are Controllable Time Points (Xc ) Be is an Uncontrollable Time Point (Xu )
[0, ∞)
[0, 20]
Be
Ae
[8, 11]
represents Free Constraints (Cf ) represents Contingent Constraints (Cc )
Bs
Taxonomy Let {x1 , ..., xk } = ˙ Xc ∪ Xu . STPU No disjunctions (xi − xj ) ∈ [l, u]
TCSPU Interval disjunctions S (xi − xj ) ∈ w [lw , uw ]
DTPU Arbitrary disjunctions W ((x − x iw jw ) ∈ [lw , uw ]) w 2/17
The Strong Controllability Problem
SMT-based encodings
Experimental Evaluation
Conclusion
Strong Controllability Intuition Search for a Fixed Schedule that fulfills all free the constraints in every situation.
3/17
The Strong Controllability Problem
SMT-based encodings
Experimental Evaluation
Conclusion
Strong Controllability Example Intuition Search for a Fixed Schedule that fulfills all free the constraints in every situation.
As
[7, 11]
[0, ∞)
[0, 20]
Be
Ae
[8, 11]
Bs
Var As Ae Bs
Time 0 8 9
3/17
The Strong Controllability Problem
SMT-based encodings
Experimental Evaluation
Conclusion
Strong Controllability Example Intuition Search for a Fixed Schedule that fulfills all free the constraints in every situation.
As
[7, 11]
[0, ∞)
[0, 20]
Be
Ae
[8, 11]
Bs
Var As Ae Bs
Time 0 8 9
Definition A temporal problem with uncertainty is Strongly Controllable if ~ c .∀X ~ u .(Cc (X ~c, X ~ u ) → Cf (X ~c, X ~ u )) ∃X ~ c and X ~ u are the vectors of controllable and uncontrollable where X ~c, X ~ u ) are the contingent constraints time points respectively, Cc (X ~ ~ and Cf (Xc , Xu ) are the free constraints. 3/17
The Strong Controllability Problem
SMT-based encodings
Experimental Evaluation
Conclusion
Contributions
First comprehensive implemented solver for Strong Controllability
Logic-based framework for Temporal Problems with Uncertainty Efficient encodings of Strong Controllability problems in SMT Extensive experimental evaluation of the approach
4/17
Outline
1
The Strong Controllability Problem
2
SMT-based encodings DTPU encodings TCSPU specific encodings
3
Experimental Evaluation
4
Conclusion
The Strong Controllability Problem
SMT-based encodings
Experimental Evaluation
Conclusion
Satisfiability Modulo Theory (SMT) SMT is the problem of deciding satisfiability of a first-order Boolean combination of theory atoms in a given theory T . Given a formula φ, φ is satisfiable if there exists a model µ such that µ |= φ.
5/17
The Strong Controllability Problem
SMT-based encodings
Experimental Evaluation
Conclusion
Satisfiability Modulo Theory (SMT) SMT is the problem of deciding satisfiability of a first-order Boolean combination of theory atoms in a given theory T . Given a formula φ, φ is satisfiable if there exists a model µ such that µ |= φ. Example φ= ˙ (∀x .(x > 0) ∨ (y ≥ x )) ∧ (z ≥ y ) is satisfiable in the theory of real arithmetic because µ = {(y , 6), (z, 8)} is a model that satisfies φ. 5/17
The Strong Controllability Problem
SMT-based encodings
Experimental Evaluation
Conclusion
Satisfiability Modulo Theory (SMT) SMT is the problem of deciding satisfiability of a first-order Boolean combination of theory atoms in a given theory T . Given a formula φ, φ is satisfiable if there exists a model µ such that µ |= φ. Example
Theories
φ= ˙ (∀x .(x > 0) ∨ (y ≥ x )) ∧ (z ≥ y ) is satisfiable in the theory of real arithmetic because
Various theories can be used.
µ = {(y , 6), (z, 8)} is a model that satisfies φ.
In this work: LRA (Linear Real Arithmetic) QF LRA (Quantifier-Free Linear Real Arithmetic) 5/17
The Strong Controllability Problem
SMT-based encodings
Experimental Evaluation
Conclusion
Quantifier Elimination in LRA Quantifier Elimination Definition A theory T has quantifier elimination if for every formula Φ , there exists another formula ΦQF without quantifiers which is equivalent to it (modulo the theory T )
6/17
The Strong Controllability Problem
SMT-based encodings
Experimental Evaluation
Conclusion
Quantifier Elimination in LRA Quantifier Elimination Definition A theory T has quantifier elimination if for every formula Φ , there exists another formula ΦQF without quantifiers which is equivalent to it (modulo the theory T )
LRA theory admits quantifier elimination, but elimination algorithms are very costly (doubly exponential in the size of the original formula). Example (∃x .(x ≥ 2y + z) ∧ (x ≤ 3z + 5)) ↔ (2y − 2z − 5 ≤ 0) 6/17
The Strong Controllability Problem
SMT-based encodings
Experimental Evaluation
Conclusion
First step: Uncontrollability Isolation Let e ∈ Xu and b ∈ Xc . For every contingent constraint (e − b) ∈ [l, u], we introduce an offset y = ˙ b + u − e. y
b
b+l
e
b+u
Time
7/17
The Strong Controllability Problem
SMT-based encodings
Experimental Evaluation
Conclusion
First step: Uncontrollability Isolation Let e ∈ Xu and b ∈ Xc . For every contingent constraint (e − b) ∈ [l, u], we introduce an offset y = ˙ b + u − e. y
b
b+l
e
b+u
Time
Definition ~ u be the offsets for a given Temporal Problem with Uncertainty Let Y ~ u ) be the rewritten Contingent Constraints Let Γ(Y ~c, Y ~ u ) the rewritten Free Constraints. Let Ψ(X 7/17
The Strong Controllability Problem
SMT-based encodings
Experimental Evaluation
Conclusion
Uncontrollability Isolation: example Original formulation ∃As , Ae , Bs . ∀Be . ((Be − Bs ) ∈ [8, 11]) → (((Ae − As ) ∈ [7, 11]) ∧ ((Be − As ) ∈ [0, 20])
As
[7, 11]
[0, ∞)
[0, 20]
Be
Ae
∧ ((Bs − Ae ) ∈ [0, ∞)))
[8, 11]
Bs
8/17
The Strong Controllability Problem
SMT-based encodings
Experimental Evaluation
Conclusion
Uncontrollability Isolation: example Original formulation ∃As , Ae , Bs . ∀Be . ((Be − Bs ) ∈ [8, 11]) → (((Ae − As ) ∈ [7, 11]) ∧ ((Be − As ) ∈ [0, 20])
As
[7, 11]
Ae [0, ∞)
[0, 20]
∧ ((Bs − Ae ) ∈ [0, ∞)))
Rewritten formulation with YBe offset ∃As , Ae , Bs . ∀YBe .
Be
[8, 11]
Bs
(YBe ∈ [0, 3]) →(((Ae − As ) ∈ [7, 11]) ∧ (((Bs + 11 − YBe ) − As ) ∈ [0, 20]) ∧ ((Bs − Ae ) ∈ [0, ∞))) ~ u = [YB ] Y e ~ u ) = (YB ∈ [0, 3]) Γ(Y e ~c, Y ~ u ) = (((Ae − As ) ∈ [7, 11]) ∧ ... ∈ [0, ∞))) Ψ(X 8/17
Outline
1
The Strong Controllability Problem
2
SMT-based encodings DTPU encodings TCSPU specific encodings
3
Experimental Evaluation
4
Conclusion
The Strong Controllability Problem
SMT-based encodings
Experimental Evaluation
Conclusion
DTPU encodings
Direct and Na¨ıve encodings Direct Encoding Strong Controllability definition is by itself an encoding in SMT(LRA) ~ c .∀X ~ u .(Cc (X ~c, X ~ u ) → Cf (X ~c, X ~ u )) ∃X
9/17
The Strong Controllability Problem
SMT-based encodings
Experimental Evaluation
Conclusion
DTPU encodings
Direct and Na¨ıve encodings Direct Encoding Strong Controllability definition is by itself an encoding in SMT(LRA) ~ c .∀X ~ u .(Cc (X ~c, X ~ u ) → Cf (X ~c, X ~ u )) ∃X
Na¨ıve Encoding Thanks to uncontrollability isolation, Strong Controllability can be rewritten as follows. ~ c .∀Y ~ u .(Γ(Y ~ u ) → Ψ(X ~c, Y ~ u )) ∃X
9/17
The Strong Controllability Problem
SMT-based encodings
Experimental Evaluation
Conclusion
DTPU encodings
Distributed Encoding Idea: because of the cost of quantifier elimination, many small quantifications can be solved more efficiently than a big single one.
10/17
The Strong Controllability Problem
SMT-based encodings
Experimental Evaluation
Conclusion
DTPU encodings
Distributed Encoding Idea: because of the cost of quantifier elimination, many small quantifications can be solved more efficiently than a big single one. Starting Point ~c, Y ~u) We assume Ψ(X ~c, Y ~u) = Ψ(X ˙
^
~c , Y ~u ) ψh (X h h
h
10/17
The Strong Controllability Problem
SMT-based encodings
Experimental Evaluation
Conclusion
DTPU encodings
Distributed Encoding Idea: because of the cost of quantifier elimination, many small quantifications can be solved more efficiently than a big single one. Starting Point ~c, Y ~u) We assume Ψ(X ~c, Y ~u) = Ψ(X ˙
^
~c , Y ~u ) ψh (X h h
h
Distributed Encoding From the Na¨ıve Encoding we can derive a Distributed Encoding, by pushing the quantifications: ~c. ∃X
^
~ u .(¬Γ(Y ~ u )|Y ∨ ψh (X ~c , Y ~ u )) ∀Y uh h h h
h 10/17
The Strong Controllability Problem
SMT-based encodings
Experimental Evaluation
Conclusion
DTPU encodings
Eager ∀ Elimination Encoding Idea: Starting from Distributed Encoding, we can eliminate quantifiers during the encoding, producing a QF LRA formula.
11/17
The Strong Controllability Problem
SMT-based encodings
Experimental Evaluation
Conclusion
DTPU encodings
Eager ∀ Elimination Encoding Idea: Starting from Distributed Encoding, we can eliminate quantifiers during the encoding, producing a QF LRA formula. Encoding Let ~c ) = ~ u .(Γ(Y ~ u )|Y ∧ ¬ψh (X ~c , Y ~ u )) ψhΓ (X ˙ ¬∃Y uh h h h h h 1
2
~ c ) for every clause independently using a Resolve ψhΓ (X h quantifier elimination procedure Solve the QF LRA encoding: ~c. ∃X
^
~c ) ψhΓ (X h
h
11/17
Outline
1
The Strong Controllability Problem
2
SMT-based encodings DTPU encodings TCSPU specific encodings
3
Experimental Evaluation
4
Conclusion
The Strong Controllability Problem
SMT-based encodings
Experimental Evaluation
Conclusion
TCSPU specific encodings
Exploit TCSPU structure Consider a single TCSPU constraint: B−A ∈
[0, 20]
0
[25, 50]
[60, 75] time
12/17
The Strong Controllability Problem
SMT-based encodings
Experimental Evaluation
Conclusion
TCSPU specific encodings
Exploit TCSPU structure Consider a single TCSPU constraint: B−A ∈
[0, 20]
[25, 50]
[60, 75] time
0
Encoding TCSPU constraints in 2-CNF (Hole Encoding) ((B − A) > 0) ∧ ((B − A) < 20) ∨ ((B − A) > 25) ∧ ((B − A) < 50) ∨ ((B − A) > 60) ∧ ((B − A) < 75) 12/17
The Strong Controllability Problem
SMT-based encodings
Experimental Evaluation
Conclusion
TCSPU specific encodings
Static quantification TCSPU Idea: Exploit Hole Encoding for TCSPU to statically resolve quantifiers in the Eager ∀ elimination encoding.
13/17
The Strong Controllability Problem
SMT-based encodings
Experimental Evaluation
Conclusion
TCSPU specific encodings
Static quantification TCSPU Idea: Exploit Hole Encoding for TCSPU to statically resolve quantifiers in the Eager ∀ elimination encoding. Approach Hole Encoding gives us a 2-CNF formula. We can enumerate all the possible (8) cases and statically resolve the quantification.
13/17
The Strong Controllability Problem
SMT-based encodings
Experimental Evaluation
Conclusion
TCSPU specific encodings
Static quantification TCSPU Idea: Exploit Hole Encoding for TCSPU to statically resolve quantifiers in the Eager ∀ elimination encoding. Approach Hole Encoding gives us a 2-CNF formula. We can enumerate all the possible (8) cases and statically resolve the quantification. Cases Let bi , bj ∈ Xc , ei , ej ∈ Xu . The only possible clauses in the Hole Encoding are in the form: (bi − bj ) ≤ k
(bi −bj ) ≤ k1 ∨(bi −bj ) ≥ k2
(ei − bj ) ≤ k
(ei −bj ) ≤ k1 ∨(ei −bj ) ≥ k2
(bi − ej ) ≤ k
(bi −ej ) ≤ k1 ∨(bi −ej ) ≥ k2
(ei − ej ) ≤ k
(ei − ej ) ≤ k1 ∨ (ei − ej ) ≥ k2 13/17
The Strong Controllability Problem
SMT-based encodings
Experimental Evaluation
Conclusion
TCSPU specific encodings
Static quantification TCSPU (Example) Let b ∈ Xc , e ∈ Xu and let ye be the offset for e. Let C be a hole-encoded clause of the TCSPU problem. C= ˙ (b − e) ≤ u ∨ (b − e) ≥ l
14/17
The Strong Controllability Problem
SMT-based encodings
Experimental Evaluation
Conclusion
TCSPU specific encodings
Static quantification TCSPU (Example) Let b ∈ Xc , e ∈ Xu and let ye be the offset for e. Let C be a hole-encoded clause of the TCSPU problem. C= ˙ (b − e) ≤ u ∨ (b − e) ≥ l In the eager ∀ elimination encoding we have ¬∃ye .((y ≥ 0) ∧ (y ≤ ue − le )∧ ¬(((b − (be + u − ye )) ≤ u) ∨ ((b − (be + u − ye )) ≥ l)).
14/17
The Strong Controllability Problem
SMT-based encodings
Experimental Evaluation
Conclusion
TCSPU specific encodings
Static quantification TCSPU (Example) Let b ∈ Xc , e ∈ Xu and let ye be the offset for e. Let C be a hole-encoded clause of the TCSPU problem. C= ˙ (b − e) ≤ u ∨ (b − e) ≥ l In the eager ∀ elimination encoding we have ¬∃ye .((y ≥ 0) ∧ (y ≤ ue − le )∧ ¬(((b − (be + u − ye )) ≤ u) ∨ ((b − (be + u − ye )) ≥ l)). The formula can be statically simplified R= ˙ ((l − b + be + ue ≤ 0) ∨ (l − b + be + le > 0))∧ ((l − b + be + le < 0) ∨ (b − be − u − le ≤ 0))
14/17
The Strong Controllability Problem
SMT-based encodings
Experimental Evaluation
Conclusion
TCSPU specific encodings
Static quantification TCSPU (Example) Let b ∈ Xc , e ∈ Xu and let ye be the offset for e. Let C be a hole-encoded clause of the TCSPU problem. C= ˙ (b − e) ≤ u ∨ (b − e) ≥ l In the eager ∀ elimination encoding we have ¬∃ye .((y ≥ 0) ∧ (y ≤ ue − le )∧ ¬(((b − (be + u − ye )) ≤ u) ∨ ((b − (be + u − ye )) ≥ l)). The formula can be statically simplified R= ˙ ((l − b + be + ue ≤ 0) ∨ (l − b + be + le > 0))∧ ((l − b + be + le < 0) ∨ (b − be − u − le ≤ 0)) ~ c ) by Whenever a clause matches the structure of C we can derive ψhΓ (X h substituting appropriate values for l, u, be , le and ue in R. 14/17
Outline
1
The Strong Controllability Problem
2
SMT-based encodings DTPU encodings TCSPU specific encodings
3
Experimental Evaluation
4
Conclusion
The Strong Controllability Problem
SMT-based encodings
Experimental Evaluation
Conclusion
Strong Controllability Results
Random instance generator SMT solvers: Z3 (QF LRA, LRA) MathSAT5 (QF LRA)
Quantification techniques: Z3 simplifier Fourier-Motzkin Loos-Weispfenning Static quantification for TCSPU
15/17
The Strong Controllability Problem
SMT-based encodings
Experimental Evaluation
Conclusion
Strong Controllability Results STPU Results
1000 100
Z3 (QF LRA, LRA) MathSAT5 (QF LRA)
10
Z3 Direct Z3 Naive Z3 Distributed Z3 EFE Z3qe Z3 EFE M5fm Z3 EFE M5lw MathSAT5 EFE Z3qe MathSAT5 EFE M5fm MathSAT5 EFE M5lw
1
Cumulative time (sec)
10000
Random instance generator SMT solvers:
0
200
400 # of instances
600
800
Quantification techniques: Z3 simplifier Fourier-Motzkin Loos-Weispfenning Static quantification for TCSPU
15/17
The Strong Controllability Problem
SMT-based encodings
Experimental Evaluation
Conclusion
Strong Controllability Results TCSPU Results
1000 100
Z3 (QF LRA, LRA) MathSAT5 (QF LRA)
10
Z3 Direct Z3 Naive Z3 Distributed Z3 EFE Z3qe Z3 EFE M5fm Z3 EFE M5lw Z3 EFE Static MathSAT5 EFE Z3qe MathSAT5 EFE M5fm MathSAT5 EFE M5lw MathSAT5 EFE Static
1
Cumulative time (sec)
10000
Random instance generator SMT solvers:
0
200
400
600
# of instances
800
1000
Quantification techniques: Z3 simplifier Fourier-Motzkin Loos-Weispfenning Static quantification for TCSPU
15/17
The Strong Controllability Problem
SMT-based encodings
Experimental Evaluation
Conclusion
Strong Controllability Results DTPU Results
1000 100
Z3 (QF LRA, LRA) MathSAT5 (QF LRA)
10
Z3 Direct Z3 Naive Z3 Distributed Z3 EFE Z3qe Z3 EFE M5lw Z3 EFE M5fm MathSAT5 EFE Z3qe MathSAT5 EFE M5fm MathSAT5 EFE M5lw
1
Cumulative time (sec)
10000
Random instance generator SMT solvers:
0
200
400
600
# of instances
800
1000
Quantification techniques: Z3 simplifier Fourier-Motzkin Loos-Weispfenning Static quantification for TCSPU
15/17
Outline
1
The Strong Controllability Problem
2
SMT-based encodings DTPU encodings TCSPU specific encodings
3
Experimental Evaluation
4
Conclusion
The Strong Controllability Problem
SMT-based encodings
Experimental Evaluation
Conclusion
Conclusions Contributions First comprehensive implemented solver for DTPU Strong Controllability Efficient encodings of Strong Controllability problems in SMT framework Tailored constant-time quantification technique for TCSPU Extensive experimental evaluation of the approach
16/17
The Strong Controllability Problem
SMT-based encodings
Experimental Evaluation
Conclusion
Conclusions Contributions First comprehensive implemented solver for DTPU Strong Controllability Efficient encodings of Strong Controllability problems in SMT framework Tailored constant-time quantification technique for TCSPU Extensive experimental evaluation of the approach Future works Dynamic Controllability Cost function optimization Incrementality 16/17
Thanks
Thanks for your attention!