u www.iaik.tugraz.at
Reactive Synthesis
24.09.2013 Swen Jacobs <swen.jacobs@iaik.tugraz.at> VTSA 2013 Nancy, France
Reactive Synthesis Swen Jacobs <swen.jacobs@iaik.tugraz.at> - - PowerPoint PPT Presentation
Reactive Synthesis Swen Jacobs <swen.jacobs@iaik.tugraz.at> VTSA 2013 Nancy, France 24.09.2013 u www.iaik.tugraz.at 2 Property Synthesis (You Will Never Code Again) VTSA 2013 Swen Jacobs Construct Correct Systems Automatically 3
u www.iaik.tugraz.at
24.09.2013 Swen Jacobs <swen.jacobs@iaik.tugraz.at> VTSA 2013 Nancy, France
Swen Jacobs VTSA 2013 2
Swen Jacobs VTSA 2013 3
Requirements Specification Implementation Verification
Synthesis
Don’t do the same thing twice! Use synthesis!
Swen Jacobs VTSA 2013 4
applications and hardware
Machine code ⇒ Assembly ⇒ C ⇒ Java ⇒ Ruby? ⇒ … Silicon ⇒ Gates ⇒ RTL ⇒ Transactions? ⇒ …
Swen Jacobs VTSA 2013 5
(temporal logic, automata)
protocols
Swen Jacobs VTSA 2013 6
Swen Jacobs VTSA 2013 7
Swen Jacobs VTSA 2013 8
Swen Jacobs VTSA 2013 9
Given
Determine
that realizes the specification?
?
Swen Jacobs VTSA 2013 10
Two player graph-based, turn-based games with infinitary winning conditions
graph-based, turn-based with infinitary winning conditions Two player
Swen Jacobs VTSA 2013 11
Swen Jacobs VTSA 2013 12
𝒋𝒐𝒒𝒗𝒖 𝒄𝒗𝒖𝒖𝒑𝒐 𝒑𝒗𝒖𝒒𝒗𝒖 𝒅𝒑𝒈𝒈𝒇𝒇 𝐇(𝒄𝒗𝒖𝒖𝒑𝒐 𝐆 𝒅𝒑𝒈𝒈𝒇𝒇)
¬𝑑 𝑐 ∧ ¬𝑑 ¬𝑐 ∨ 𝑑
1 𝑟0 𝑟1
𝑑
Possible strategy: serve coffee iff automaton is in state 𝑟1 In this case, LTL game reduces to Büchi game
LTL game Büchi game
red moves first green moves second green’s objective: visit 𝑟0 infinitely often
Swen Jacobs VTSA 2013 13
¬𝑐 𝑑 ¬𝑑 𝑐 𝑑 ¬𝑑
¬𝑑 𝑐 ∧ ¬𝑑 ¬𝑐 ∨ 𝑑
1 𝑟0 𝑟1
𝑑
Swen Jacobs VTSA 2013 14
A B C D
0/-,1/0
0/1,1/0 1/1 0/0,1/1 Find all states from which system can force visit to goal state (= winning region / attractor) + a strategy Label on edges:
dash (–) means don‘t care
0/- 1/-
A
0/0,1/1
0/- 1/-
Winning region B
0/-,1/0
0/1,1/0 1/1
C A
0/0,1/1
0/- 1/-
D D C
0/-,1/0
0/1,1/0 1/1
B
Swen Jacobs VTSA 2013 15
𝑮𝒑𝒔𝒅𝒇𝟐(𝑮) = set of states from which system can force visit to 𝑇 in one step 𝑮𝒑𝒔𝒅𝒇𝟐 𝑮 = 𝒓 ∈ 𝑹 ∀𝑗 ∈ 𝐽 ∃𝑝 ∈ 𝑃: 𝜀 𝑟, 𝑗, 𝑝 ∈ 𝐺 }
¬𝑐 𝑑 ¬𝑑 𝑐 𝑑 ¬𝑑
Swen Jacobs VTSA 2013 16
𝑮𝒑𝒔𝒅𝒇𝟐(𝑮) = set of states from which system can force visit to 𝐺 in one step 𝑮𝒑𝒔𝒅𝒇∗ 𝑮 = set of states from which system can force visit to 𝐺 in any number of steps (least fixpoint of applying 𝐺𝑝𝑠𝑑𝑓1 to 𝐺) 𝑺𝒇𝒅𝒗𝒔(𝑮) = set of states from which system can repeatedly force visit to 𝐺 in any number of steps (nested fixpoint operation)
¬𝑐 𝑑 ¬𝑑 𝑐 𝑑 ¬𝑑
Swen Jacobs VTSA 2013 17
Winning region is 𝑮𝒑𝒔𝒅𝒇∗ 𝑮 for reachability game, 𝑺𝒇𝒅𝒗𝒔 𝑮 for Büchi game. (Safety defined with dual 𝐺𝑝𝑠𝑑𝑓 operator for environment) For reachability, safety and Büchi games, memoryless strategies are sufficient, i.e., strategies 𝑅 × 𝐽 → 𝑃
¬𝑐 𝑑 ¬𝑑 𝑐 𝑑 ¬𝑑
Swen Jacobs VTSA 2013 18
Swen Jacobs VTSA 2013 19
Swen Jacobs VTSA 2013 20
LTL Synthesis [PnueliRosner89] 1. Specify
2. Obtain a game
Büchi automaton 𝐵 (exponential blowup)
Rabin or Parity automaton (=game) (exponential blowup)
3. Solve the game
in polynomial time
4. Construct Circuit
Swen Jacobs VTSA 2013 21
Input: 𝑠
1, 𝑠 2 (requests)
Output: 1, 2 (grants) Specification: 𝐇 𝑠
1 → 𝐆 1
𝐇 𝑠
2 → 𝐆 2
𝐇¬ 1 ∧ 2 Arbiter
𝑠
1, 𝑠 2
1, 2
1. Specify 2. Obtain a game 3. Solve the game 4. Construct circuit
Swen Jacobs VTSA 2013 22
1. Specify 2. Obtain a game 3. Solve the game 4. Construct circuit
Swen Jacobs VTSA 2013 23
Input: 𝑠
1, 𝑠 2 (requests)
Output: 1, 2 (grants) Specification: 𝐇 𝑠
1 → 𝐆 1
𝐇 𝑠
2 → 𝐆 2
𝐇¬ 1 ∧ 2 Arbiter
𝑠
1, 𝑠 2
1, 2
1. Specify 2. Obtain a game 3. Solve the game 4. Construct circuit
Swen Jacobs VTSA 2013 24
input button, water
𝐇𝐆 𝒙𝒃𝒖𝒇𝒔 𝐇 𝒄𝒗𝒖𝒖𝒑𝒐 𝐆 𝒅𝒑𝒈𝒈𝒇𝒇 ∧ 𝐇(𝒙𝒃𝒖𝒇𝒔 𝒅𝒑𝒈𝒈𝒇𝒇)
¬𝑥 ∧ ¬𝑑 𝑐 ∧ ¬𝑑 ¬𝑐 ∨ 𝑑 ∧ 𝑥
1 1
¬𝑑 𝑑 ∧ 𝑥
1 1 LTL game Büchi game
No winning strategy because of nondeterminism, even though LTL game is won
won? won?
Note: not complete!
Swen Jacobs VTSA 2013 25
1 , … , 𝐹𝑜, 𝐺 𝑜
Swen Jacobs VTSA 2013 26
1. Specify
2. Obtain a game
size 2𝑜
(=game), size 22𝑜
3. Solve the parity game, time 22𝑜 Will not consider this approach in detail. It is complex and not very scalable.
Swen Jacobs VTSA 2013 27
Synthesis problem can also be solved by
[SohailSomenzi09, MorgensternSchneider10] (not in this tutorial)
[ScheweFinkbeiner07,FiliotJinRaskin11, Ehlers12] (Later!)
Swen Jacobs VTSA 2013 28
Swen Jacobs VTSA 2013 29
LTL Synthesis [PnueliRosner89] 1. Specify
Logic
2. Obtain a game
nondeterministic Büchi Automaton 𝐵 (exponential blowup)
deterministic Rabin or Parity automaton (=game) (exponential blowup)
3. Solve the game
can be done in polynomial time
4. Construct Circuit GR(1) Synthesis [PitermanPnueliSa’ar06] 1. Specify
automata, for environment and system
2. Specification = game
3. Solve the game
4. Construct Circuit
Swen Jacobs VTSA 2013 30
1. Specification:
Both encoded symbolically
2. Specification = Game 3. Solve the game 4. Determine circuit from winning strategy (…) Advantages of this setting:
But: not all LTL properties can be expressed this way(!)
Swen Jacobs VTSA 2013 31 Obtaining a GR(1) Specification
Symbolic: Introduce 𝑦 as variable for state space initial 𝑗𝐵 = ¬𝑦 transition relation 𝑈𝐵 = ¬𝑦 ∧ (¬𝑠 ∨ ) 𝑦’ ¬𝑦 ∧ 𝑠 ∧ ¬ 𝑦’ 𝑦 ∧ ¬ 𝑦’ 𝑦 ∧ 𝑦’ fairness 𝐺𝐵: 𝐇𝐆 𝑡𝑢𝑏𝑢𝑓’
1
𝑠 ∧ ¬
¬𝑠 ∨
¬
Example: G(r F g)
Swen Jacobs VTSA 2013 32
𝑗 𝐇𝐆 𝐵𝑗 → 𝑘 𝐇𝐆 𝐻
𝑘
To solve: compute nested fixpoints of states from which system can force visit to 𝐻j if environment satisfies assumptions 𝐵𝑗 Direct symbolic implementation. Complexity: 𝑃 𝑅 2 ⋅ 𝑈 ⋅ 𝑛 ⋅ 𝑜
[KestenPitermanPnueli05,PitermanPnueliSa’ar06]
G0
… G1
…
Swen Jacobs VTSA 2013 33
Solve using Jurdzinki’s algorithm in 𝑃 𝑅 ⋅ 𝑈 time
[d’AlfaroFaella09]
better because 𝑛, 𝑜 << 𝑅
counting construction blowup: O(m) counting construction blowup:O(n) [PPS06] Streett reduction algorithm
time
𝑃 𝑅 2 ⋅ 𝑈 ⋅𝑛 ⋅𝑜 𝑃 𝑅 ⋅ 𝑈 ⋅ 𝑛 ⋅ 𝑜 2
Note: counting construction on G introduces memory of size n
Swen Jacobs VTSA 2013 34
LTL Synthesis [PnueliRosner89] 1. Specify
Logic
2. Obtain a game
nondeterministic Büchi Automaton 𝐵 (exponential blowup)
deterministic Rabin or Parity automaton (=game) (exponential blowup)
3. Solve the game
can be done in polynomial time
4. Construct Circuit GR(1) Synthesis [PitermanPnueliSa’ar06] 1. Specify
automata, for environment and system
2. Specification = game
3. Solve the game
4. Construct Circuit
Swen Jacobs VTSA 2013 35
Specification = Set of sequential circuits Strategy = Set of combinational circuits One combinational circuit
GR(1) Synthesis (fix memory elements) Construction of circuit Less freedom Fewer circuits More complexity
Swen Jacobs VTSA 2013 36 Constructing Circuit
|inputs|
FFs |outputs| FFs
Comb. Logic
sequential inputs sequential
|vars| FFs
combinational inputs I combinational outputs O
R I X O
Swen Jacobs VTSA 2013 37
1
Swen Jacobs VTSA 2013 38
Swen Jacobs VTSA 2013 39
Swen Jacobs VTSA 2013 40 AMBA Bus
AMBA AHB Master 0 Master 1 Master 15 Client 0 Client 1 Client 15
... ...
Arbiter
Swen Jacobs VTSA 2013 41
Swen Jacobs VTSA 2013 42
“When a locked unspecified length burst starts, new access does not start until current master (i) releases bus by lowering HBUSREQi.”
X(¬START U ¬HBUSREQi) )
Swen Jacobs VTSA 2013 43
Assumption that master must eventually release locked bus
can also be written as
G((HMASTLOCK HBURST=INCR) F HBUSREQ[HMASTER])
(We know that bus master does not change) Now, instead of n automata with n fairness constraints, we have one!
Swen Jacobs VTSA 2013 44
200 400 600 800 1000 1200 1400 1 2 3 4 5 6 7 8 9 10 KS cofactors new spec manual
#masters Circuit size
Swen Jacobs VTSA 2013 45
Swen Jacobs VTSA 2013 46
not be (easily) expressible
Swen Jacobs VTSA 2013 47
(see manual implementation)
Swen Jacobs VTSA 2013 48
Swen Jacobs VTSA 2013 49
Swen Jacobs VTSA 2013 50
Swen Jacobs VTSA 2013 51
Swen Jacobs VTSA 2013 52
Swen Jacobs VTSA 2013 53
Swen Jacobs VTSA 2013 54
Swen Jacobs VTSA 2013 55
Specification Automaton
∧1≤𝑗≤2 𝐇(𝑠
𝑗 → 𝐆𝑗)
𝐇¬ 1 ∧ 2
Swen Jacobs VTSA 2013 56
System Automaton 12 12 12 𝑠
1
𝑠2 𝑠
1𝑠2
𝑠
1𝑠 2
𝑠
1
𝑠2 𝑠
1𝑠2
𝑠
1𝑠 2 ∨
𝑠
1𝑠 2
(implicit self-loops in remaining cases)
Swen Jacobs VTSA 2013 57
: 𝑈 → , representing reachable states
𝑢 is true if partial run of system that ends in 𝑢 can
#: 𝑈 → ℕ, representing
Swen Jacobs VTSA 2013 58
Annotation Automaton 𝜇1
𝑢0
𝜇1
# 𝑢0 = 0
∀𝐽 ∀𝑢: 𝜇1
𝑢
→ 𝜇1
𝜐 𝑢, 𝐽
∧ 𝜇1
# 𝜐 𝑢, 𝐽
≥ 𝜇1
# 𝑢
∀𝐽 ∀𝑢: 𝜇1
𝑢 ∧ 𝑠 1 ∈ 𝐽
→ 𝜇2
𝜐 𝑢, 𝐽
∧ 𝜇2
# 𝜐 𝑢, 𝐽
> 𝜇1
# 𝑢
… …
For given system 𝑇 and UCT 𝐵, satisfying annotation exists iff 𝐵 accepts 𝑇.
Swen Jacobs VTSA 2013 59
Swen Jacobs VTSA 2013 60
Swen Jacobs VTSA 2013 61
Swen Jacobs VTSA 2013 62
[PnueliRosner89] A. Pnueli, R. Rosner: On the Synthesis of a Reactive Module. POPL 89. [SohailSomenzi09] S. Sohail, F. Somenzi: Safety First: A Two-Stage Algorithm for LTL
[MorgensternSchneider10] A. Morgenstern, K. Schneider: Exploiting the Temporal Logic Hierarchy and the Non-Confluence Property for Efficient LTL Synthesis. GANDALF 10. [ScheweFinkbeiner07] S. Schewe, B. Finkbeiner: Bounded Synthesis. ATVA 07. [FiliotJinRaskin11] E. Filiot, N. Jin, J.F. Raskin: Antichains and compositional algorithms for LTL synthesis. FMSD 11. [Ehlers12] R. Ehlers: Symbolic Bounded Synthesis. FMSD 12. [VardiWolper86] M. Vardi, P. Wolper: Automata-theoretic techniques for modal logics of
[KestenPitermanPnueli05] Y. Kesten, N. Piterman, A. Pnueli: Bridging the Gap between Fair Simulation and Trace Inclusion. I&C 05. [PitermanPnueliSa’ar06] N. Piterman, A. Pnueli, Y. Sa'ar: Synthesis of Reactive(1)