A Constraint-based Approach to Solving Games onInfinite Graphs
Tewodros Beyene1, Swarat Chaudhuri3, Corneliu Popeea1, andAndrey Rybalchenko1,2
1Technische Universitat Munchen
2Microsoft Research Cambridge
3Rice University
PUMA workshopAlacati, Turkey
October 1, 2013
Tewodros Beyene (PUMA, TUM) Solving Games on Infinite Graphs October 1, 2013 1 / 1
Motivation
Many fundamental questions reduce to solving turn-based graphgames:
modeling interactions between a controller and its environmentverifying a branching-time property of a systemsynthesizing a reactive system from a temporal specification. . .
In turn-based graph games
two players take turnsa token is moved along the edges of a graph
Do the visited nodes satisfy a certain winning condition?
Tewodros Beyene (PUMA, TUM) Solving Games on Infinite Graphs October 1, 2013 2 / 1
Motivation
Many fundamental questions reduce to solving turn-based graphgames:
modeling interactions between a controller and its environmentverifying a branching-time property of a systemsynthesizing a reactive system from a temporal specification. . .
In turn-based graph games
two players take turnsa token is moved along the edges of a graph
Do the visited nodes satisfy a certain winning condition?
Tewodros Beyene (PUMA, TUM) Solving Games on Infinite Graphs October 1, 2013 2 / 1
Motivation
Many fundamental questions reduce to solving turn-based graphgames:
modeling interactions between a controller and its environmentverifying a branching-time property of a systemsynthesizing a reactive system from a temporal specification. . .
In turn-based graph games
two players take turnsa token is moved along the edges of a graph
Do the visited nodes satisfy a certain winning condition?
Tewodros Beyene (PUMA, TUM) Solving Games on Infinite Graphs October 1, 2013 2 / 1
Motivation (cont)
Majority of algorithmic approaches focus on decidable classes.
such as games on finite graphslimits the scope of the applications
To analyse and synthese infinite-state systems:
symbolic, abstraction-based algorithmssolve games on infinite state spaces
The talk is about an algorithmic approach based on automateddeduction for solving games over infinite-state symbolic transitionsystems.
Tewodros Beyene (PUMA, TUM) Solving Games on Infinite Graphs October 1, 2013 3 / 1
Motivation (cont)
Majority of algorithmic approaches focus on decidable classes.
such as games on finite graphslimits the scope of the applications
To analyse and synthese infinite-state systems:
symbolic, abstraction-based algorithmssolve games on infinite state spaces
The talk is about an algorithmic approach based on automateddeduction for solving games over infinite-state symbolic transitionsystems.
Tewodros Beyene (PUMA, TUM) Solving Games on Infinite Graphs October 1, 2013 3 / 1
A ’Challenge’ Example: Cinderella-Stepmother game
Between Cinderella and her Stepmother.
Involves 5 buckets arranged in a circle.
With a constant c bucket capacityall buckets empty initially
Stepmother starts each round of play.
Splits 1 unit of additional water among the five bucketsIf overflow in any one of the buckets - Stepmother wins
If not, Cinderella empties two adjacent buckets.
If the game goes on forever without overflow - Cinderella wins
More challenging for 1.5 ≤ c < 3.
Tewodros Beyene (PUMA, TUM) Solving Games on Infinite Graphs October 1, 2013 4 / 1
A ’Challenge’ Example: Modeling the game
Set of variables: v = (b1, b2, b3, b4, b5).
Initial condition:
¯init(v) = (b1 = 0 ∧ · · · ∧ b5 = 0).
Transition relation of Stepmother:
stepmother(v , v ′) = (b′1 + · · ·+ b′5 = b1 + · · ·+ b5 + 1
∧ b′1 ≥ b1 ∧ · · · ∧ b′5 ≥ b5).
Transition relation of Cinderella:
cinderella(v , v ′) =
∨i∈{1...5}
b′i = 0 ∧ b′(i+1)%5 = 0
∧(∧
j∈{1..5}
(j 6= i ∧ j 6= (i + 1)%5→ b′j = bj
)) .
Overflow condition:
overflow(v) = (b1 > c ∨ · · · ∨ b5 > c).
Tewodros Beyene (PUMA, TUM) Solving Games on Infinite Graphs October 1, 2013 5 / 1
A ’Challenge’ Example: Type of games
Depending on the objective of the player we compute a strategy for.
Safety games:
requires only states with a certain property to be visited by all the playse.g. the property G (¬overflow(v)) for Cinderella
Reachability games:
requires a state with a certain property to be visited eventually by allthe playse.g. the property F (overflow(v)) for Stepmother
Tewodros Beyene (PUMA, TUM) Solving Games on Infinite Graphs October 1, 2013 6 / 1
A ’Challenge’ Example: Type of games
Depending on the objective of the player we compute a strategy for.
Safety games:
requires only states with a certain property to be visited by all the playse.g. the property G (¬overflow(v)) for Cinderella
Reachability games:
requires a state with a certain property to be visited eventually by allthe playse.g. the property F (overflow(v)) for Stepmother
Tewodros Beyene (PUMA, TUM) Solving Games on Infinite Graphs October 1, 2013 6 / 1
A ’Challenge’ Example: Type of games
Depending on the objective of the player we compute a strategy for.
Safety games:
requires only states with a certain property to be visited by all the playse.g. the property G (¬overflow(v)) for Cinderella
Reachability games:
requires a state with a certain property to be visited eventually by allthe playse.g. the property F (overflow(v)) for Stepmother
Tewodros Beyene (PUMA, TUM) Solving Games on Infinite Graphs October 1, 2013 6 / 1
A ’Challenge’ Example: Type of games (cont)
LTL and Parity games:
winning condition is an LTL propertyLTL games are an extremely challenging
solving them on finite graphs is 2EXPTIME-complete
Parity games - an important special caseeach state is assigned a color (a number in {1, . . . ,N}).the winning condition - the minimum color seen infinitely often is odde.g. no overflow or bucket2 is the only bucket where overflow occursinfinitely often.
Tewodros Beyene (PUMA, TUM) Solving Games on Infinite Graphs October 1, 2013 7 / 1
Overview
Game syntax and semantics.
Proof rules for each type of game.
Case study on the ’challenge’ example.
Implementation and Experimental results.
Summary and future work.
Tewodros Beyene (PUMA, TUM) Solving Games on Infinite Graphs October 1, 2013 8 / 1
Game syntax
A (two-player, turn-based, graph) game is a pair consisting of a symbolictransition system and a winning condition.
The symbolic transition system
consists of two players; Adam and Evelet v be a tuple of variables of the systemsystem states are valuations of vassertion init(v) represents the initial statesthe transition relations of Adam and Eve are given by assertionsadam(v , v ′) and eve(v , v ′)
The winning condition
given by a set of infinite sequences of system statesdecides the type of game
Tewodros Beyene (PUMA, TUM) Solving Games on Infinite Graphs October 1, 2013 9 / 1
Game syntax
A (two-player, turn-based, graph) game is a pair consisting of a symbolictransition system and a winning condition.
The symbolic transition system
consists of two players; Adam and Evelet v be a tuple of variables of the systemsystem states are valuations of vassertion init(v) represents the initial statesthe transition relations of Adam and Eve are given by assertionsadam(v , v ′) and eve(v , v ′)
The winning condition
given by a set of infinite sequences of system statesdecides the type of game
Tewodros Beyene (PUMA, TUM) Solving Games on Infinite Graphs October 1, 2013 9 / 1
Game syntax
A (two-player, turn-based, graph) game is a pair consisting of a symbolictransition system and a winning condition.
The symbolic transition system
consists of two players; Adam and Evelet v be a tuple of variables of the systemsystem states are valuations of vassertion init(v) represents the initial statesthe transition relations of Adam and Eve are given by assertionsadam(v , v ′) and eve(v , v ′)
The winning condition
given by a set of infinite sequences of system statesdecides the type of game
Tewodros Beyene (PUMA, TUM) Solving Games on Infinite Graphs October 1, 2013 9 / 1
Game semantics
A strategy σ for Eve is a set of infinite trees such that:
each root in σ coincide with the set of initial states(roots are assumed to be on the first level of the tree)the set of successors of each tree node s at an odd level consists of thefollowing set of states.
{s ′ | (s, s ′) |= adam(v , v ′)}
the set of successors of each tree node s at an even level consists of anon-empty subset of the following set of states.
{s ′ | (s, s ′) |= eve(v , v ′)}
Such an infinite sequence is called a play π determined by σ.
Alternates between universal choices of Adam and existential choicesof Eve.
Tewodros Beyene (PUMA, TUM) Solving Games on Infinite Graphs October 1, 2013 10 / 1
Game semantics (cont)
A strategy σ is winning if every play of σ is in the winning condition.
For the given system and a winning condition formula ϕ, we write
(init(v), eve(v , v ′), adam(v , v ′)) |= ϕ
when Eve has a winning strategy.
Tewodros Beyene (PUMA, TUM) Solving Games on Infinite Graphs October 1, 2013 11 / 1
Proof rules
3 proof rules - one for each type of game.
Conclude that Eve has a winning strategy.
Imposes implication and well-foundedness conditions on auxiliaryassertions.
Sound and relatively complete.
Tewodros Beyene (PUMA, TUM) Solving Games on Infinite Graphs October 1, 2013 12 / 1
Proof rules: Safety games
Only states from safe(v) are visited by all plays.
Requires an invariant assertion inv(v).
S1 : init(v)→ inv(v)
S2 : inv(v) ∧ adam(v , v ′)→ safe(v ′) ∧ ∃v ′′ : eve(v ′, v ′′) ∧ inv(v ′′)
S3 : inv(v)→ safe(v)
(init(v), eve(v , v ′), adam(v , v ′)) |= G safe(v)
Tewodros Beyene (PUMA, TUM) Solving Games on Infinite Graphs October 1, 2013 13 / 1
Proof rules: Reachability games
A certain set of states called dst(v) is eventually reached by each play.
Requires an invariant assertion inv(v) together with a binary relationround(v , v ′).
R1 : init(v)→ inv(v)
R2 : inv(v) ∧ ¬dst(v) ∧ adam(v , v ′) ∧ ¬dst(v ′)→∃v ′′ : eve(v ′, v ′′) ∧ inv(v ′′) ∧ round(v , v ′′)
R3 : well-founded(round(v , v ′))
(init(v), eve(v , v ′), adam(v , v ′)) |= F dst(v)
Tewodros Beyene (PUMA, TUM) Solving Games on Infinite Graphs October 1, 2013 14 / 1
Proof rules: Parity/LTL games
To state the winning condition we assume:
the set of all states is partitioned into N subsets p1(v), . . . , pN (v)N is an odd numberp1(v) ∨ · · · ∨ pN (v) is validfor each 1 ≤ i < j ≤ N, pi (v) ∧ pj (v) is unsatisfiable.
The parity winning condition:
the subsets of states that are visited infinitely often are given aspi1 (v), . . . , piK (v), andthe minimal identifier is odd, i.e., min{i1, . . . , iK} is odd.
... or formally as the LTL formula ϕ.
ϕ = GFp1(v)
∨ GFp3(v) ∧ FG¬(p1(v) ∨ p2(v))
· · ·∨ GFpN(v) ∧ FG¬(p1(v) ∨ · · · ∨ pN−1(v))
Tewodros Beyene (PUMA, TUM) Solving Games on Infinite Graphs October 1, 2013 15 / 1
Proof rules: Parity/LTL games (cont)
Negate ϕ and translate ¬ϕ to the Buchi automaton B.
represented using assertions over the program counter of theautomaton pcB and the system variables vinitial condition given by initB(pcB)transition relation given by nextB(pcB, v , pc ′B).accB(pcB) represents the accepting states.
Given a play π = s1, s2, . . . , run of B on π is defined as q0, q1, q2, . . .such that:
q0 |= initB(pcB),(qi−1, si , qi ) |= nextB(pcB, v , pc ′B) for each i ≥ 1.
Apply Buchi acceptance condition
B accepts a play π if there exists an accepting run on π.
here, if B accepts π then π 6|= ϕ.
Tewodros Beyene (PUMA, TUM) Solving Games on Infinite Graphs October 1, 2013 16 / 1
Proof rules: Parity/LTL games (cont)
Find assertions inv(w), aux(w ,w ′, v ′′), round(w ,w ′,w ′′), and fair(w ,w ′)where w = (v , pcB) such that:
B1 : init(v) ∧ initB(pcB) ∧ nextB(pcB, v , pc ′B)→ inv(v , pc ′B)
B2 : inv(w) ∧ adam(v , v ′) ∧ nextB(pcB, v′, pc ′B)→
∃v ′′ : eve(v ′, v ′′) ∧ aux(w ,w ′, v ′′)
B3 : aux(w ,w ′, v ′′) ∧ nextB(pc ′B, v′′, pc ′′B)→ inv(w ′′) ∧ round(w ,w ′,w ′′)
B4 : round(w ,w ′,w ′′) ∧ (accB(pcB) ∨ accB(pc ′B))→ fair(w ,w ′′)
B5 : fair(w ,w ′) ∧ round(w ′,w ′′,w ′′′)→ fair(w ,w ′′′)
B6 : well-founded(fair(w ,w ′))
(init(v), eve(v , v ′), adam(v , v ′)) |= ϕ
Tewodros Beyene (PUMA, TUM) Solving Games on Infinite Graphs October 1, 2013 17 / 1
Case Study: Cinderella-Stepmother gameSafety objective: Round strategy
c = 3 for the bucket capacity.
An auxiliary variable r for a pair of buckets to be emptied.
A user-provided template for Cinderella adds guard for each disjunctand updates the round variable.
init(v , r) = ( ¯init(v) ∧ r = 1)
eve(v , r , v ′, r ′) = cinderella(v , v ′) ∧RelT(rel)(v , r , v ′, r ′)
adam(v , r , v ′, r ′) = (stepmother(v , v ′) ∧ r ′ = r)
Tewodros Beyene (PUMA, TUM) Solving Games on Infinite Graphs October 1, 2013 18 / 1
Case Study: Cinderella-Stepmother gameSafety objective: Round strategy (cont)
RelT(rel)(v , r , v ′, r ′) = (r = 1 ∧ r ′ =?1 ∧ c1(v , v ′) ∨r = 2 ∧ r ′ =?2 ∧ c2(v , v ′) ∨r = 3 ∧ r ′ =?3 ∧ c3(v , v ′) ∨r = 4 ∧ r ′ =?4 ∧ c4(v , v ′) ∨r = 5 ∧ r ′ =?5 ∧ c5(v , v ′))
Template parameters are denoted by “?”-marks.
Our tool returns a solution ?1 = 4, ?2 = 1, ?3 = 1, ?4 = 3, ?5 = 1.
The corresponding strategy is 1&2 - 4&5 - 3&4 - 1&2,. . .
Tewodros Beyene (PUMA, TUM) Solving Games on Infinite Graphs October 1, 2013 19 / 1
Case Study: Cinderella-Stepmother gameSafety objective: Second strategy
c = 2 for the bucket capacity.
Template based on the previous move of Cinderella and Stepmother.
inv(v) ∧ stepmother(v , v ′)→ safe(v ′) ∧ ∃v ′′ : cinderella(v ′, v ′′)
∧ inv(v ′′)
The template looks like
RelT(rel)(v , v ′, v ′′) = (b1 = 0 ∧ b2 = 0 ∧ T12(v ′, v ′′) ∨b2 = 0 ∧ b3 = 0 ∧ T23(v ′, v ′′) ∨b3 = 0 ∧ b4 = 0 ∧ T34(v ′, v ′′) ∨b4 = 0 ∧ b5 = 0 ∧ T45(v ′, v ′′) ∨b5 = 0 ∧ b1 = 0 ∧ T51(v ′, v ′′)).
Tewodros Beyene (PUMA, TUM) Solving Games on Infinite Graphs October 1, 2013 20 / 1
Case Study: Cinderella-Stepmother gameSafety objective: Second strategy (cont)
Let us see one part of the template, e.g., T12
In the previous round emptied buckets 1 and 2. (b1 = 0 ∧ b2 = 0)
During the next round empty another pair of buckets.
either the pair of buckets 3 and 4 (b′′3 = 0 ∧ b′′4 = 0)or the pair of buckets 4 and 5 (b′′4 = 0 ∧ b′′5 = 0)
Deciding between the two is not straightforward.
The game solving approach handles it using the specified template.
Formalized the formula T12 is provided as follows.
T12(v ′, v ′′) = (b′′3 = 0 ∧ b′′4 = 0∧?5 ∗ b′5+?2 ∗ b′2 ≤?6 ∗ 1 ∨b′′4 = 0 ∧ b′′5 = 0∧?1 ∗ b′1+?3 ∗ b′3 ≤?6 ∗ 1)
Our tool returns a solution ?1 = 1, ?2 = 1, ?3 = 1, ?5 = 1, ?6 = 1.
Tewodros Beyene (PUMA, TUM) Solving Games on Infinite Graphs October 1, 2013 21 / 1
Case Study: Cinderella-Stepmother gameReachability objective
c = 1.4 for the bucket capacity.
Instantiate the proof rule as follows:
eve(v , v ′) = stepmother(v , v ′)
adam(v , v ′) = cinderella(v , v ′)
A template corresponding to the existentially quantified clause.
RelT(rel)(v , v ′, v ′′) = (?1 + · · ·+?5 = 1 ∧∧i∈{1..5}
(b′′i = b′i +?i ) ∧∧
i∈{1..5}?i ≥ 0)
Our tool returns a solution?1 = 0.8, ?2 = 0, ?3 = 0.1, ?4 = 0, ?5 = 0.1.
Tewodros Beyene (PUMA, TUM) Solving Games on Infinite Graphs October 1, 2013 22 / 1
Case Study: Cinderella-Stepmother gameParity objective
A state without overflow: (color = 0)↔ ¬overflow(v).
A state with overflow such that i is the smallest index from those thatcorrespond to buckets that have overflown: (color = i).
The resulting state-partitioning groups states with different prioritylevels indicated by p(i):
p(i) = (color = i), for i ∈ {0, . . . , 2}p(3) = (color = 3 ∨ color = 4 ∨ color = 5).
The winning condition win(i) is defined as follows.
win(i) = (GF p(i) ∧∧
j∈{0,..,i−1}
FG¬p(j))
Tewodros Beyene (PUMA, TUM) Solving Games on Infinite Graphs October 1, 2013 23 / 1
Case Study: Cinderella-Stepmother gameParity objective (cont)
we define the objective for the Cinderella player win(0) ∨ win(2).
The formula corresponding to the Cinderella’s objective:
ϕ = (GF p(0) ∨ (GF p(2) ∧ FG ¬p(1) ∧ FG ¬p(0))).
Our tool finds the same strategy as the second winning strategy forthe Cinderella player.
Tewodros Beyene (PUMA, TUM) Solving Games on Infinite Graphs October 1, 2013 24 / 1
Other applications
Synthesis of reactive programs from temporal specifications.
Program repair game with safety objective.
Concurrent program repair game with safety and response objectives.
Synthesis of synchronization game with safety objective.
Tewodros Beyene (PUMA, TUM) Solving Games on Infinite Graphs October 1, 2013 25 / 1
The EHSF engine
Proof rules are automated using the Ehsf engine
Resolves forall-exists Horn-like clauses extended with well-foundednesscriteria
Example:
x ≥ 0→ ∃y : x ≥ y ∧ rank(x , y), rank(x , y)→ ti(x , y),
ti(x , y) ∧ rank(y , z)→ ti(x , z), dwf (ti).
Maps each predicate symbol into a constraint over v .
Maps both rank(x , y) and ti(x , y)) to the constraint(x ≥ 0 ∧ y ≥ x − 1) for the example.
Tewodros Beyene (PUMA, TUM) Solving Games on Infinite Graphs October 1, 2013 26 / 1
The EHSF engine (cont)
Resolves clauses using a CEGAR scheme to discover witnesses forexistentially quantified variables.
space of witnesses is provided by some ’template’
Refinement loop collects a global constraint that declarativelydetermines which witnesses to choose.
a chosen witnesses replace existential quantificationthe resulting universally quantified clauses are passed to a solver forsuch clauses. e.g.,HSF
Such a solver either finds a solution or returns a counterexample.
counterexample are turned into an additional constraint on the set ofwitness candidates, andcontinues with the next iteration of the refinement loop
Refinement loop conjoins constraints that are obtained for alldiscovered counterexamples.
wrong choice of witnesses can be mendedpreviously handled counterexamples are not rediscovered
Tewodros Beyene (PUMA, TUM) Solving Games on Infinite Graphs October 1, 2013 27 / 1
Experiment
GSolve: a proof-of-concept implementation of the approach.
Implemented in SICStus Prolog.
Relies on an implementation of the E-HSF algorithm to solve Hornclauses over linear inequalities.
Uses SMT solvers for handling non-linear constraints, i.e., the Z3 andthe Barcelogic solvers.
Experiments run on an Intel Core 2 Duo machine, clocked at 2.53GHz, with 4 GB of RAM.
Tewodros Beyene (PUMA, TUM) Solving Games on Infinite Graphs October 1, 2013 28 / 1
Results
Id Game Player p Objective for player p Time (z3) Time (Barcelogic)P1 Cinderella (c = 3) Cinderella G ¬overflow 3.2s 1.2sP2 Cinderella (c = 2) Cinderella G ¬overflow 1m52s 1m52sP3 Cinderella (c = 1.4) Stepmother F overflow 18s 1m14sP4 Cinderella (c = 1.4) Cinderella win(0) 7m16s SysErrorP5 Cinderella (c = 1.4) Cinderella win(0) ∨ win(2) 4.7s 4.7sP6 Robot-1d (yr0,yh0,ydst,e=10) Robot F at−dest T/O 1sP7 Repair-Lock Program G ¬error 0.3s 0.3sP8 Repair-Critical Program G ¬error 17.7s 16.9sP9 Repair-Critical Program G (at p → F ¬at p) 53.3s 3m6sP10 Synth-Synchronization Program G ¬error T/O 1s
GSolve has always succeeded in finding a strategy using one of thetwo solvers.
Tewodros Beyene (PUMA, TUM) Solving Games on Infinite Graphs October 1, 2013 29 / 1
Summary and Future work
A new algorithmic approach which comprises:
a set of sound and relatively complete proof rules; andautomation on top of an existing automated deduction engine
Demonstrate the practical promise through a few case studies.
Prototypic and many avenues for future work remain open.
engineering it for greater scalabilityapplying to reactive synthesis questions in embedded systems androbotics.synergy between our approach and abstraction-based andautomata-theoretic approaches.
Tewodros Beyene (PUMA, TUM) Solving Games on Infinite Graphs October 1, 2013 30 / 1