Sumit Nain - Rice Universitysc40/COMP607/13/comp607-2013-games.pdf · Sumit Nain (Rice University)...
Transcript of Sumit Nain - Rice Universitysc40/COMP607/13/comp607-2013-games.pdf · Sumit Nain (Rice University)...
Infinite Games
Sumit Nain
Department of Computer ScienceRice University
28 January 2013
Slides Credit:Barbara Jobstmann (CNRS/Verimag)
Motivation
Abstract games are of fundamental importance in
mathematics logic (particularly set theory and logic)
economics
computer science.
In computer science, games are very well suited to model reactive, ongoingcomputation between a system and an adversarial environment.
Sumit Nain (Rice University) Infinite Games 28 January 2013 2 / 32
Outline
Define 2-player games formally.
Basic concepts: winning conditions, strategies, determinacy.
Show how to solve simple Reachability games.
Overview of Buchi and Parity games with main results.
Sumit Nain (Rice University) Infinite Games 28 January 2013 3 / 32
Two-Player Games
Two-player games between Player 0 and 1
An infinite game 〈G , φ〉 consists of
a game graph G and
a winning condition φ.
G defines the “playground”, in which the two players compete.
φ defines which plays are won by Player 0.
If a play does not satisfy φ, then Player 1 wins on this play.
Sumit Nain (Rice University) Infinite Games 28 January 2013 4 / 32
Game Graphs
A game graph or arena is a tuple G = 〈S ,S0,T 〉 where:
S is a finite set of states
S0 ⊆ S is the set of Player-0 statesS1 = S \ S0 are the Player-1 states
T ⊆ S × S is a transition relation (set of moves).We assume that each state has at least one successor.
s0
s4
s1 s2
s3Player 0
Player 1
Sumit Nain (Rice University) Infinite Games 28 January 2013 5 / 32
Plays
A play is an infinite sequence of states ρ = s0s1s2 · · · ∈ Sω such that for alli ≥ 0 〈si , si+1〉 ∈ T .
It starts in s0 and it is built up as follows:If si ∈ S0, then Player 0 chooses an edge starting in si , otherwise Player 1picks such an edge.
Intuitively, a token is moved from state to state via edges: From S0-statesPlayer 0 moves the token, from S1-states Player 1 moves the token.
s0
s4
s1 s2
s3
Sumit Nain (Rice University) Infinite Games 28 January 2013 6 / 32
Winning Condition
Winning condition describes plays won by Player 0.A winning condition or objective φ is a subset of plays, i.e., φ ⊆ Sω.
We use logical conditions (e.g., LTL formulas) or automata theoreticacceptance conditions to describe φ.Example:
always eventually s for some state s ∈ S
All plays that stay within a safe region F ⊆ S are in φ.
Games are named after their winning condition, e.g., Safety game,Reachability game, LTL game, Parity game,...
Sumit Nain (Rice University) Infinite Games 28 January 2013 7 / 32
Types of Games
Muller, Rabin, Streett, parity, Buchi objectives can be defined.
Muller is the most general.
Muller can be converted to parity (see Theorem 2.7).
We will focus on parity and simpler conditions.
Sumit Nain (Rice University) Infinite Games 28 January 2013 8 / 32
Types of Games
Given a play ρ, we define
Occ(ρ) = {s ∈ S | ∃i ≥ 0 : si = s}
Inf(ρ) = {s ∈ S | ∀i ≥ 0∃j > i : sj = s}
Given a set F ⊆ S ,Reachability Game φ = {ρ ∈ Sω | Occ(ρ) ∩ F 6= ∅}Safety Game φ = {ρ ∈ Sω | Occ(ρ) ⊆ F}Buchi Game φ = {ρ ∈ Sω | Inf(ρ) ∩ F 6= ∅}Co-Buchi Game φ = {ρ ∈ Sω | Inf(ρ) ⊆ F}
Sumit Nain (Rice University) Infinite Games 28 January 2013 9 / 32
Types of Games
Given a function p : S → {0, 1, . . . , d}
Parity Game φ = {ρ ∈ Sω | mins∈Inf(ρ) p(s) is even}
40 1 2 3
More general objectives can be converted into equivalent (larger) paritygame.
Sumit Nain (Rice University) Infinite Games 28 January 2013 10 / 32
Hierarchy
Reachability Safety
co-BuchiBuchi
Parity
Sumit Nain (Rice University) Infinite Games 28 January 2013 11 / 32
Strategies
A strategy for Player 0 from state s is a (partial) function
f : S∗S0 → S
specifying for any sequence of states s0, s1, . . . sk with s0 = s and sk ∈ S0 asuccessor state sj such that (sk , sj ) ∈ T .
A play ρ = s0s1 . . . is compatible with strategy f if for all si ∈ S0 we havethat si+1 = f (s0s1 . . . si).(Definitions for Player 1 are analogous.)
Given strategies f and g from s for Player 0 and 1, respectively. Wedenote by Gf ,g the (unique) play that is compatible with f and g .
Sumit Nain (Rice University) Infinite Games 28 January 2013 12 / 32
Winning Strategies and Regions
A strategy f for Player 0 from s is called a winning strategy if for allPlayer-1 strategies g from s, Gf ,g ∈ φ holds.
Analogously, a Player-1 strategy g is winning if for all Player-0 strategiesf , Gf ,g 6∈ φ holds.Player 0 (resp. 1) wins from s if they have a winning strategy from s.
Sumit Nain (Rice University) Infinite Games 28 January 2013 13 / 32
Winning Strategies and Regions
A strategy f for Player 0 from s is called a winning strategy if for allPlayer-1 strategies g from s, Gf ,g ∈ φ holds.
Analogously, a Player-1 strategy g is winning if for all Player-0 strategiesf , Gf ,g 6∈ φ holds.Player 0 (resp. 1) wins from s if they have a winning strategy from s.
The winning regions of Player 0 and 1 are the sets
W0 = {s ∈ S | Player 0 wins from s}
W1 = {s ∈ S | Player 1 wins from s}
Note each state s belongs at most to W0 or W1.
Sumit Nain (Rice University) Infinite Games 28 January 2013 13 / 32
Questions About Games
Solve a game (G , φ) with G = (S ,S0,T ):
Decide for each state s ∈ S if s ∈ W0.
If yes, construct a suitable winning strategy from s.
Sumit Nain (Rice University) Infinite Games 28 January 2013 14 / 32
Questions About Games
Solve a game (G , φ) with G = (S ,S0,T ):
Decide for each state s ∈ S if s ∈ W0.
If yes, construct a suitable winning strategy from s.
Further interesting question:
Optimize construction of winning strategy (e.g., time complexity)
Optimize parameters of winning strategy (e.g., size of memory)
Sumit Nain (Rice University) Infinite Games 28 January 2013 14 / 32
Example
s0
s4
s1 s2
s3
Safety game (G ,F ) with F = {s0, s1, s3, s4}, i.e., Occ(ρ) ⊆ F
A winning strategy for Player 0 (from state s0, s3, and s4):
From s0 choose s3 and from s4 choose s3
A winning strategy for Player 1 (from state s1 and s2):
From s1 choose s2, from s2 choose s4, and from s3 choose s4
Sumit Nain (Rice University) Infinite Games 28 January 2013 15 / 32
Example
s0
s4
s1 s2
s3
Safety game (G ,F ) with F = {s0, s1, s3, s4}, i.e., Occ(ρ) ⊆ F
A winning strategy for Player 0 (from state s0, s3, and s4):
From s0 choose s3 and from s4 choose s3
A winning strategy for Player 1 (from state s1 and s2):
From s1 choose s2, from s2 choose s4, and from s3 choose s4
W0 = {s0, s3, s4}, W1 = {s1, s2}
Sumit Nain (Rice University) Infinite Games 28 January 2013 15 / 32
Determinacy
Recall: the winning regions are disjoint, i.e., W0 ∩W1 = ∅
Question: Is every state winning for some player?
A game (G , φ) with G = (S ,S0,E ) is called determined if W0 ∪W1 = S
holds.
Remarks:
All automata theoretic games we discuss here are determined.
There are games which are not determined (e.g., concurrent games:even/odd sum, paper-rock-scissors)
Determinacy of infinite games is a deep question in logic!
Sumit Nain (Rice University) Infinite Games 28 January 2013 16 / 32
Strategy Types
In general, a strategy is a (partial) function f : S+ → S .
Computable or recursive strategies: f is computable
Finite-state strategies: f is computable with a finite-state automatonmeaning that f has bounded information about the past (history).
Memoryless or positional strategies: f only depends on the currentstate of the game (no knowledge about history of play)
A memoryless strategy for Player 0 is a function f : S0 → S
Sumit Nain (Rice University) Infinite Games 28 January 2013 17 / 32
Memoryless Determinacy
In what situations do memoryless strategies suffice to win?
Muller games — both players need memory to win.
Rabin games — Player 0 does not need memory to win.
Streett games — Player 1 does not need memory to win.
Parity games — neither player needs memory to win.
Parity game have memoryless determinacy!
Every game that requires finite memory can be converted into a largergame with memoryless determinacy.
Sumit Nain (Rice University) Infinite Games 28 January 2013 18 / 32
Finite State to Memoryless
s0
s4s3
s1 s2
Objective: visit s0 and s4, i.e, {s0, s4} ⊆ Occ(ρ)
Sumit Nain (Rice University) Infinite Games 28 January 2013 19 / 32
Finite State to Memoryless
s0
s4s3
s1 s2
Objective: visit s0 and s4, i.e, {s0, s4} ⊆ Occ(ρ)
Winning strategy for Player 0 from s0, s3 and s4:
From s0 to s3, from s4 to s3, and from s3 to s0 on first visit, otherwiseto s4.
m0 m1
s0/s3s1/−s2/−s4/s3
s0/s3s1/−s2/−s3/s4s4/s3
s3/s0
Sumit Nain (Rice University) Infinite Games 28 January 2013 19 / 32
Extended Game
m0 m1
s0/s3s1/−s2/−s4/s3
s0/s3s1/−s2/−s3/s4s4/s3
s3/s0
Sumit Nain (Rice University) Infinite Games 28 January 2013 20 / 32
Extended Game
m0 m1
s0/s3s1/−s2/−s4/s3
s0/s3s1/−s2/−s3/s4s4/s3
s3/s0
m0
s0
s4s3
s1 s2
Sumit Nain (Rice University) Infinite Games 28 January 2013 20 / 32
Extended Game
m0 m1
s0/s3s1/−s2/−s4/s3
s0/s3s1/−s2/−s3/s4s4/s3
s3/s0
m0
s0
s4s3
s1 s2 s0
s4s3
m1
s1 s2
Sumit Nain (Rice University) Infinite Games 28 January 2013 20 / 32
Extended Game
m0 m1
s0/s3s1/−s2/−s4/s3
s0/s3s1/−s2/−s3/s4s4/s3
s3/s0
m0
s0
s4s3
s1 s2 s0
s4s3
m1
s1 s2
Note: the strategy in the extended grame graph is memoryless.
Sumit Nain (Rice University) Infinite Games 28 January 2013 20 / 32
Reachability Games
Theorem
In a reachability game (G ,F ) with G = (S ,S0,E ) and F ⊆ S, the winning
regions W0 and W1 are computable. Both players have corresponding
memoryless winning strategies.
Proof.W0 are all the states from which Player 0 can “force” a visit to F .Key Idea: define the i-attractor of Player 0, which are all the states fromwhich Player 0 can “force” a visit to F in i steps.Then define the attractor of Player 0 as union of i-attractor for all i .
Sumit Nain (Rice University) Infinite Games 28 January 2013 21 / 32
Reachability Games
Theorem
In a reachability game (G ,F ) with G = (S ,S0,E ) and F ⊆ S, the winning
regions W0 and W1 are computable. Both players have corresponding
memoryless winning strategies.
Proof.W0 are all the states from which Player 0 can “force” a visit to F .Key Idea: define the i-attractor of Player 0, which are all the states fromwhich Player 0 can “force” a visit to F in i steps.Then define the attractor of Player 0 as union of i-attractor for all i .
Claim (1): Attractor of Player 0 is computableClaim (2): W0 = Attractor and W1 = S \ Attractor
Sumit Nain (Rice University) Infinite Games 28 January 2013 21 / 32
“Forced” Visit in Next Step (“Controlled Next”)
Given F , compute the set of states CNext0(F ) from which Player 0 canforce a visit to F in the next step.
CNext0(F ) = {s ∈ S0 | ∃s′ ∈ S : (s, s ′) ∈ E ∧ s ′ ∈ Attri0(F )}∪
{s ∈ S1 | ∀s′ ∈ S : (s, s ′) ∈ E → s ′ ∈ Attri0(F )}
Sumit Nain (Rice University) Infinite Games 28 January 2013 22 / 32
Observations about CNext0(F )
Player 0 has a memoryless winning strategy from CNext0(F ) to reachF in the next step.
Player 1 has a memoryless winning strategy from S \ CNext0(F ) toavoid F in the next step.
S \ CNext0(F ) is a sub-game, i.e., every state has at least onesuccessor.
Sumit Nain (Rice University) Infinite Games 28 January 2013 23 / 32
Computing the Attractor
Construction of i−Attractor Attri0(F ):
Attr00(F ) = F
Attri+10 (F ) = Attri0(F ) ∪ CNext0(Attr
i0(F ))
Attr0(F ) =⋃∞
i=0 Attri0(F )=
⋃|S|i=0 Attr
i0(F )
Sumit Nain (Rice University) Infinite Games 28 January 2013 24 / 32
Computing the Attractor
Construction of i−Attractor Attri0(F ):
Attr00(F ) = F
Attri+10 (F ) = Attri0(F ) ∪ CNext0(Attr
i0(F ))
Attr0(F ) =⋃∞
i=0 Attri0(F )=
⋃|S|i=0 Attr
i0(F )
Since S is finite, there exists k ≤ |S | s.t. Attrk0(F ) = Attrk+10 (F ).
The attractor of Player 0 can be computed as
Attr0(F ) =
|S|⋃
i=0
Attri0(F )
Sumit Nain (Rice University) Infinite Games 28 January 2013 24 / 32
Computing the Attractor
Construction of i−Attractor Attri0(F ):
Attr00(F ) = F
Attri+10 (F ) = Attri0(F ) ∪ CNext0(Attr
i0(F ))
Attr0(F ) =⋃∞
i=0 Attri0(F ) =
⋃|S|i=0 Attr
i0(F )
Claim (1): proved.
Sumit Nain (Rice University) Infinite Games 28 January 2013 25 / 32
Example
s0
s4
s6
s1 s2
s3
s5 s7
Sumit Nain (Rice University) Infinite Games 28 January 2013 26 / 32
Example
s0
s4
s6
s1 s2
s3
s5 s7 Attr00 = {s3, s4}
Sumit Nain (Rice University) Infinite Games 28 January 2013 26 / 32
Example
s0
s4
s6
s1 s2
s3
s5 s7 Attr00 = {s3, s4}
Attr10 = {s0, s3, s4}
Sumit Nain (Rice University) Infinite Games 28 January 2013 26 / 32
Example
s0
s4
s6
s1 s2
s3
s5 s7 Attr00 = {s3, s4}
Attr10 = {s0, s3, s4}
Attr20 = {s0, s3, s4, s7}
Sumit Nain (Rice University) Infinite Games 28 January 2013 26 / 32
Example
s0
s4
s6
s1 s2
s3
s5 s7 Attr00 = {s3, s4}
Attr10 = {s0, s3, s4}
Attr20 = {s0, s3, s4, s7}
Attr30 = {s0, s3, s4, s6, s7}
Attr40 = {s0, s3, s4, s5, s6, s7}
Attr50 = Attr40
Sumit Nain (Rice University) Infinite Games 28 January 2013 26 / 32
Example
s0
s4
s6
s1 s2
s3
s5 s7 Attr00 = {s3, s4}
Attr10 = {s0, s3, s4}
Attr20 = {s0, s3, s4, s7}
Attr30 = {s0, s3, s4, s6, s7}
Attr40 = {s0, s3, s4, s5, s6, s7}
Attr50 = Attr40
Sumit Nain (Rice University) Infinite Games 28 January 2013 26 / 32
Proving Claim 2
Claim (2): W0 = Attr0(F ) and W1 = S \ Attr0(F )
Since we know that W0 ∩W1 = ∅ holds, it is sufficient to proveAttr0(F ) ⊆ W0 and S \ Attr0(F ) ⊆ W1.
This follows easily from construction of Attr0(F ) We can constructstrategies, s.t. Player 0 reaches F in finitely many steps from Attr0(F ) andPlayer 1 avoids F for infinitely many steps from S \ Attr0(F ).
Sumit Nain (Rice University) Infinite Games 28 January 2013 27 / 32
Safety as Dual of Reachability
Given a safety game (G ,F ) with G = (S ,S0,E ), i.e.,
φS = {ρ ∈ Sω | Occ(ρ) ⊆ F},
consider the reachability game (G ,S \ F ), i.e.,
φR = {ρ ∈ Sω | Occ(ρ) ∩ (S \ F ) 6= ∅}.
Then, Sω \ φR = {ρ ∈ Sω | Occ(ρ) ⊆ F}.Player 0 has a safety objective in (G ,F ).Player 1 has a reachability objective in (G ,F ).
So, W0 in the safety game (G ,F ) corresponds to W1 in the reachabilitygame (G ,S \ F ).
Sumit Nain (Rice University) Infinite Games 28 January 2013 28 / 32
Summary
We know how to solve reachability and safety games by memorylesswinning strategies.
The strategies are
Player 0: Decrease distance to F (called attractor strategy)
Player 1: Stay outside of Attr0(F )
In LTL, eventually(F ) = reachability and always(F ) = safety.
Sumit Nain (Rice University) Infinite Games 28 January 2013 29 / 32
Exercise
Given a reachability game (G ,F ) with G = (S ,S0,E ) and F ⊆ Q,give an algorithm that computes the attractor(F) of Player 0 in timeO(|E |).
Sumit Nain (Rice University) Infinite Games 28 January 2013 30 / 32
Exercise
Given a reachability game (G ,F ) with G = (S ,S0,E ) and F ⊆ Q,give an algorithm that computes the attractor(F) of Player 0 in timeO(|E |).
Solution:
Preprocessing: Compute for every state s ∈ S1 outdegree out(s)
Set n(s) := out(s) for each s ∈ S1
To breadth-first search backwards from F with the followingconventions
mark all s ∈ F
mark s ∈ S0 if reached from marked statemark s ∈ S1 if n(s) = 0, other set n(s) := n(s)− 1.
The marked vertices are the ones of Attr0(F ).
Sumit Nain (Rice University) Infinite Games 28 January 2013 30 / 32
Buchi Games
φ = {ρ ∈ Sω | Inf(ρ) ∩ F 6= ∅}
Winning condition: The play must visit F infinitely often.
Buchi games are determined.
Memoryless strategies suffice for Buchi games.
Can be solved in O(nm), where n is number of vertices and m isnumber of edges in game graph.
co-Buchi games are the dual of Buchi games.
LTL equivalent for Buchi: always eventually F
LTL equivalent for co-Buchi: eventually always¬F
Sumit Nain (Rice University) Infinite Games 28 January 2013 31 / 32
Parity Games
Given a priority function p : S → {0, 1, . . . , d},we have φ = {ρ ∈ Sω | min
s∈Inf(ρ) p(s) is even}
Winning condition: The lowest priority visited infinitely often must beeven.
Parity games are determined.
Memoryless strategies suffice for parity games.
Solving them is in NP and coNP.
Is solving parity games in P? Major open problem in computer science.
LTL games can be transformed into equivalent but larger paritygames.
Sumit Nain (Rice University) Infinite Games 28 January 2013 32 / 32