Program Synthesis is a Game

Slides:



Advertisements
Similar presentations
1 Verification by Model Checking. 2 Part 1 : Motivation.
Advertisements

Model Checking Lecture 3. Specification Automata Syntax, given a set A of atomic observations: Sfinite set of states S 0 Sset of initial states S S transition.
Model Checking Lecture 2. Three important decisions when choosing system properties: 1automata vs. logic 2branching vs. linear time 3safety vs. liveness.
Algorithmic Software Verification VII. Computation tree logic and bisimulations.
CS 267: Automated Verification Lecture 8: Automata Theoretic Model Checking Instructor: Tevfik Bultan.
Partial Order Reduction: Main Idea
1 Model checking. 2 And now... the system How do we model a reactive system with an automaton ? It is convenient to model systems with Transition systems.
Automatic Verification Book: Chapter 6. What is verification? Traditionally, verification means proof of correctness automatic: model checking deductive:
CS6133 Software Specification and Verification
UPPAAL Introduction Chien-Liang Chen.
Nir Piterman Department of Computer Science TexPoint fonts used in EMF. Read the TexPoint manual before you delete this box.: AAAAA Bypassing Complexity.
CIS 540 Principles of Embedded Computation Spring Instructor: Rajeev Alur
CSE 555 Protocol Engineering Dr. Mohammed H. Sqalli Computer Engineering Department King Fahd University of Petroleum & Minerals Credits: Dr. Abdul Waheed.
Temporal Logic Model- checking with SPIN COMP6004 Stéphane Lo Presti Part 4: Specifications.
Model Checking. Used in studying behaviors of reactive systems Typically involves three steps: Create a finite state model (FSM) of the system design.
Lecture 4&5: Model Checking: A quick introduction Professor Aditya Ghose Director, Decision Systems Lab School of IT and Computer Science University of.
Modeling Software Systems Lecture 2 Book: Chapter 4.
Witness and Counterexample Li Tan Oct. 15, 2002.
Specification Formalisms Book: Chapter 5. Properties of formalisms Formal. Unique interpretation. Intuitive. Simple to understand (visual). Succinct.
Review of the automata-theoretic approach to model-checking.
ESE601: Hybrid Systems Introduction to verification Spring 2006.
Witness and Counterexample Li Tan Oct. 15, 2002.
Automata and Formal Lanugages Büchi Automata and Model Checking Ralf Möller based on slides by Chang-Beom Choi Provable Software Lab, KAIST.
1 Formal Engineering of Reliable Software LASER 2004 school Tutorial, Lecture1 Natasha Sharygina Carnegie Mellon University.
The Model Checker SPIN Written by Gerard J. Holzmann Presented by Chris Jensen.
1 Lecture 11 – Partial Programs, Program Repair, and Sketching Eran Yahav.
Flavio Lerda 1 LTL Model Checking Flavio Lerda. 2 LTL Model Checking LTL –Subset of CTL* of the form: A f where f is a path formula LTL model checking.
Presenter : Cheng-Ta Wu Vijay D’silva, S. Ramesh Indian Institute of Technology Bombay Arcot Sowmya University of New South Wales, Sydney.
Cheng/Dillon-Software Engineering: Formal Methods Model Checking.
Institute for Applied Information Processing and Communications 1 Karin Greimel Semmering, Open Implication.
Benjamin Gamble. What is Time?  Can mean many different things to a computer Dynamic Equation Variable System State 2.
Model Checking Lecture 3 Tom Henzinger. Model-Checking Problem I |= S System modelSystem property.
Copyright 2001, Matt Dwyer, John Hatcliff, and Radu Iosif. The syllabus and all lectures for this course are copyrighted materials and may not be used.
CIS 842: Specification and Verification of Reactive Systems Lecture Specifications: LTL Model Checking Copyright , Matt Dwyer, John Hatcliff,
CIS 540 Principles of Embedded Computation Spring Instructor: Rajeev Alur
CS5270 Lecture 41 Timed Automata I CS 5270 Lecture 4.
Graz University of Technology Professor Horst Cerjak, Barbara Jobstmann San Jose, Nov 15Optimizations for LTL Synthesis Barbara Jobstmann.
2015 Concurrency: logical properties 1 ©Magee/Kramer 2 nd Edition Chapter 14 Logical Properties Satisfied? Not satisfied?
Verification & Validation By: Amir Masoud Gharehbaghi
Constraints Assisted Modeling and Validation Presented in CS294-5 (Spring 2007) Thomas Huining Feng Based on: [1]Constraints Assisted Modeling and Validation.
CIS 540 Principles of Embedded Computation Spring Instructor: Rajeev Alur
Properties as Processes : FORTE slide Properties as Processes: their Specification and Verification Joel Kelso and George Milne School of Computer.
1 Temporal logic. 2 Prop. logic: model and reason about static situations. Example: Are there truth values that can be assigned to x,y simultaneously.
Model Checking Lecture 1. Model checking, narrowly interpreted: Decision procedures for checking if a given Kripke structure is a model for a given formula.
Software Systems Verification and Validation Laboratory Assignment 4 Model checking Assignment date: Lab 4 Delivery date: Lab 4, 5.
Variants of LTL Query Checking Hana ChocklerArie Gurfinkel Ofer Strichman IBM Research SEI Technion Technion - Israel Institute of Technology.
Specify, Compile, Run: Hardware from PSL Speaker: Chen-Hsuan Adonis Lin Advisor: Jie-Hong Roland Jiang 2016年2月22日星期一 2016年2月22日星期一 2016年2月22日星期一 1.
From Natural Language to LTL: Difficulties Capturing Natural Language Specification in Formal Languages for Automatic Analysis Elsa L Gunter NJIT.
Today’s Agenda  Quiz 4  Temporal Logic Formal Methods in Software Engineering1.
Model Checking Lecture 1: Specification Tom Henzinger.
6/12/20161 a.a.2015/2016 Prof. Anna Labella Formal Methods in software development.
CIS 540 Principles of Embedded Computation Spring Instructor: Rajeev Alur
Model Checking Lecture 2. Model-Checking Problem I |= S System modelSystem property.
CS5270 Lecture 41 Timed Automata I CS 5270 Lecture 4.
Model Checking Lecture 2 Tom Henzinger. Model-Checking Problem I |= S System modelSystem property.
Formal methods: Lecture
CIS 842: Specification and Verification of Reactive Systems
Concurrency Specification
CSEP590 – Model Checking and Automated Verification
Automatic Verification of Industrial Designs
Generating Optimal Linear Temporal Logic Monitors by Coinduction
Formal Methods in software development
CSCI1600: Embedded and Real Time Software
Translating Linear Temporal Logic into Büchi Automata
Introduction to verification
Predicate Abstraction
Formal Methods in software development
Formal Methods in software development
COMP60621 Designing for Parallelism
Presentation transcript:

Program Synthesis is a Game Presented by: Sumit Nain Slides Credit: Barbara Jobstmann (CNRS/Verimag)

Outline Synthesis using automata-based game theory Lecture 2 Lecture 1 High Level Overview Motivate Model Checking, program repair/synthesis by analyzing example code Connection to games Not covered today: formal syntax, details of algorithms Lecture 2 Deeper dive into Automata-based game theory Formal terminology Reachability/safety, Buchi, parity games Algorithms for solving games

Analyze, Verify, and Synthesize Synthesis System Implementation Algorithm “How” Specification Properties Model “What” Verification Here is my picture of what the different techniques try to do Analysis Synthesis translates a high-level system description into an executable implementation Benefits: implementation and reward for writing specs (no double effort) Techniques vary depending on specification language and target implementation.

Reactive Systems Synthesis Verification Analysis Specifications Systems (e.g., servers) Interact with environment Infinite duration (non-terminating) Finite data (or data abstractions) Control-oriented Specifications Set of good behaviors (a language) Temporal logic (which includes safety and liveness) Verification How “good” does a system satisfies its spec Analysis [Z. Manna and A. Pnueli. The Temporal Logic of Reactive and Concurrent Systems., 1992] [N. Halbwachs. Synchronous Programming of Reactive Systems. 1993]

Verification Model Checking: Synthesis: Does system satisfy given specification Synthesis: Find a system that “satisfies” given specification

Example Specification Real life example from a specification for a high performance on-chip bus with multiple masters and an arbiter (ARM’s AMBA AHB bus) Specification: “When a locked unspecified length burst starts, a new access does not start until the current master (i) releases the bus by lowering HBUSREQi.”

Example: Formal Specification using Linear Temporal Logic (LTL) “When a locked unspecified length burst starts, a new access does not start until the current master (i) releases the bus by lowering HBUSREQi.” Formal specification: for all masters i: always((HMASTLOCK and HBURST=INCRand START and HMASTER=i) ➝ (not START until not HBUSREQi))‏ Time progresses with clock tick

Example: Software unsigned int got_lock = 0; ... while(*) { if (*) { lock(); got_lock++; } if (got_lock != 0) { unlock(); got_lock--; lock() {LOCK:=1;} unlock() {LOCK:=0;} Specifications P1: do not acquire a lock twice P2: do not call unlock without holding the lock reactive systems can also describe aspects of a concurrent software

Example: Software unsigned int got_lock = 0; ... 1: while(*) { 2: if (*) { 3: lock(); 4: got_lock++; } 5: if (got_lock != 0) { 6: unlock(); 7: got_lock--; lock() lock: {LOCK:=1;} unlock() unlock: {LOCK:=0;} Specifications P1: do not acquire a lock twice P2: do not call unlock without holding the lock P1: always( line=lock implies next( line!=lock wait-until line=unlock )) P2: ( line!=unlock wait-until line=lock )) and always( line=unlock implies next( line!=unlock wait-until line=lock )) Time progresses with change of line

How to verify a Reactive System? Core algorithm for Model Checking linear-time temporal logic: Source code modeled as transition system M (an FSM) Specification modeled as FSM A that accepts violations of the spec. 3. Check if model has a violating trace product of trans. system M and monitor A check for existence of a trace in product (check emptiness of M x A )

Source Code unsigned int got_lock = 0; ... 1: while(*) { 2: if (*) { 3: lock(); 4: got_lock++; } 5: if (got_lock != 0) { 6: unlock(); 7: got_lock--; lock() lock: {LOCK:=1;} unlock() unlock: {LOCK:=0;}

Step 1: Transition System Trans. system variables: line (l), got_lock (gl) int[0,1,2] got_lock = 0; ... 1: while(*) { 2: if (*) { 3: lock(); lock: {LOCK:=1;} 4: got_lock++; } 5: if (got_lock != 0) { 6: unlock(); unlock: {LOCK:=0;} 7: got_lock--; 8: l=1, gl=0 l=1, gl=1 l=1, gl=2 l=2, gl=0 .... l=2, gl=2 l=3, gl=0 l=3, gl=2 l=lock,gl=0 l=lock,gl=2 l=4, gl=0 l=4, gl=2 l=5, gl=0 l=5, gl=1 l=5, gl=2 l=6, gl=1 l=6, gl=2 l=unlock,gl=1 l=unlock,gl=2 l=7, gl=0 l=7, gl=1 l=7, gl=2 l=8, gl=0 .... ....

Specification P1: always( line=lock implies P1: do not acquire a lock twice P2: do not call unlock without holding the lock P1: always( line=lock implies next(line!=lock wait-until line=unlock)) P2: ( line!=unlock wait-until line=lock )) and always( line=unlock implies next( line!=unlock wait-until line=lock ))

Linear-Time Temporal Logic [Pnueli77] Syntax: Atomic propositions, e.g., line=1, line!=1, got_lock=0 Boolean operators: not, and, or, implies,... Temporal operators: next (ϕ) ... ϕ holds in the next step ϕ1 until ϕ2 ... ϕ1 holds until at some point ϕ2 holds Used in industrial spec languages PSL/SVA Can express many interesting properties, e.g., mutual exclusion, deadlock freedom, termination

Linear-Time Temporal Logic Semantics defined with respect to infinite traces in each step atomic propositions holds or not E.g., line=1, got_lock≤1 line=1 line=1 got_lock≤1 .....

Linear-Time Temporal Logic Semantics next (ϕ) ... ϕ holds in the next step ϕ1 until ϕ2 ... ϕ1 holds until at some point ϕ2 holds System S satisfies/models ϕ, if all its behaviors satisfy ϕ ϕ ..... ϕ1 ϕ1 ϕ1 ϕ1 ϕ2 ..... .....

Linear-Time Temporal Logic Many useful abbreviations true = p or not p false = not true eventually(ϕ) = true until ϕ always(ϕ) = not (eventually(not ϕ)) ϕ1 wait-until ϕ2 = (ϕ1 until ϕ2) or always(ϕ1)

How to verify a Reactive System? Core algorithm for linear-time temporal logic: Source code ➝auto/manual transition system M Specification ➝auto/manual monitor violations A Check if model has a violating trace Compute product of M and A Check product for emptiness

Step 2: Monitor for Violations P1: always( line=lock implies next( line!=lock wait-until line=unlock )) = not eventually( line=lock and next( line!=unlock until line=lock )) line!=unlock line=lock line=lock 1 2 3 s1: non-deterministic choice s2: no edge with line=unlock Automaton accepts trace/behavior is a blue state is visited infinitely often (Büchi )

Step 3: Product l=1, gl=0 l=1, gl=1 l=1, gl=2 l=2, gl=0 .... l=2, gl=2 l=lock,gl=0 l=lock,gl=2 l=4, gl=0 l=4, gl=2 l=5, gl=0 l=5, gl=1 l=5, gl=2 l=6, gl=1 l=6, gl=2 l=unlock,gl=1 l=unlock,gl=2 l=7, gl=0 l=7, gl=1 l=7, gl=2 line!=unlock line=lock line=lock 1 2 3 l=8, gl=0 .... ....

Step 3: Product l=1, gl=0 l=1, gl=1 l=1, gl=2 l=2, gl=0 .... l=2, gl=2 l=lock,gl=0 1 l=lock,gl=2 1 l=4, gl=0 l=4, gl=0 2 1 l=4, gl=2 1 l=5, gl=0 1 l=5, gl=1 l=5, gl=1 2 1 l=5, gl=2 1 l=6, gl=1 l=6, gl=1 2 1 l=6, gl=2 1 unlock,1 unlock,1 2 1 l=unlock,gl=2 1 l=7, gl=0 1 l=7, gl=1 1 l=7, gl=2 line!=unlock line=lock line=lock 1 2 3 1 l=8, gl=0 1 .... 1 ....

Recall, we want to show a violation: Step 3: Product 1 l=1, gl=0 1 l=1, gl=1 1 l=1, gl=2 l=1, gl=2 2 1 l=2, gl=0 1 .... 1 l=2, gl=2 l=2, gl=2 2 1 l=3, gl=0 1 l=3, gl=2 l=3, gl=2 2 1 l=lock,gl=0 1 l=lock,gl=2 l=lock,gl=2 2 1 l=4, gl=0 l=4, gl=0 2 1 l=4, gl=2 l=4, gl=2 2 l=4, gl=2 3 1 l=5, gl=0 l=5, gl=0 2 1 l=5, gl=1 l=5, gl=1 2 1 l=5, gl=2 1 l=6, gl=1 l=6, gl=1 2 1 l=6, gl=2 1 unlock,1 unlock,1 2 1 l=unlock,gl=2 1 l=7, gl=0 l=7, gl=0 2 1 l=7, gl=1 1 l=7, gl=2 line!=unlock line=lock line=lock 1 2 3 1 l=8, gl=0 1 .... 1 .... Recall, we want to show a violation:

Step 3: Product 1 l=1, gl=0 1 l=1, gl=1 1 l=1, gl=2 l=1, gl=2 2 1 l=2, gl=0 1 .... 1 l=2, gl=2 l=2, gl=2 2 1 l=3, gl=0 1 l=3, gl=2 l=3, gl=2 2 1 l=lock,gl=0 1 l=lock,gl=2 l=lock,gl=2 2 1 l=4, gl=0 l=4, gl=0 2 1 l=4, gl=2 l=4, gl=2 2 l=4, gl=2 3 1 l=5, gl=0 l=5, gl=0 2 1 l=5, gl=1 l=5, gl=1 2 1 l=5, gl=2 1 l=6, gl=1 l=6, gl=1 2 1 l=6, gl=2 1 unlock,1 unlock,1 2 1 l=unlock,gl=2 1 l=7, gl=0 l=7, gl=0 2 1 l=7, gl=1 1 l=7, gl=2 line!=unlock line=lock line=lock 1 2 3 1 l=8, gl=0 1 .... 1 .... Recall, we want to show a violation: non-determinism in transition system and in monitor pull in the same direction (both can be used to violate property)

Source Code line = 1 line = 2 line = 5 line = 7 line = 3 line = lock int[0,1,2] got_lock = 0; ... 1: while(*) { 2: if (*) { 3: lock(); lock: {LOCK:=1;} 4: got_lock++; } 5: if (got_lock != 0) { 6: unlock(); unlock: {LOCK:=0;} 7: got_lock--; 8:

How to verify a Reactive System? Core algorithm for linear-time temporal logic: Source code ➝auto/manual transition system M Specification ➝auto/manual monitor violations A Check if model has a violating trace Compute product of M and A Check product for emptiness But how to repair it?

How to repair a Reactive System? Add freedom (choice for the system, allowed ways to modify system) Source code ➝a/m transition system (game) Specification ➝a/m monitor acceptance Check if we can find system choices s.t. model is accepted by monitor product of trans. system and monitor search for winning strategy in game

Step 1: Freedom (We can also extend to fault localization) int[0,1,2] got_lock = 0; int[0,1,2] freedom; ... 1: while(*) { 2: if (*) { 3: lock(); lock: {LOCK:=1;} 4: got_lock:=freedom; } 5: if (got_lock != 0) { 6: unlock(); unlock: {LOCK:=0;} 7: got_lock:=freedom; 8: (We can also extend to fault localization)

Step 2: Game Trans. system variables: line (l), got_lock (gl) int[0,1,2] got_lock = 0; int[0,1,2] freedom; ... 1: while(*) { 2: if (*) { 3: lock(); lock: {LOCK:=1;} 4: got_lock:=freedom; } 5: if (got_lock != 0) { 6: unlock(); unlock: {LOCK:=0;} 7: got_lock:=freedom; 8: Trans. system variables: line (l), got_lock (gl) l=1, gl=0 l=1, gl=1 l=1, gl=2 l=2, gl=0 .... l=2, gl=2 l=3, gl=0 l=3, gl=2 l=lock,gl=0 l=lock,gl=2 f=0 f=2 f=1 l=4, gl=0 l=4, gl=2 l=5, gl=0 l=5, gl=1 l=5, gl=2 l=6, gl=1 l=6, gl=2 l=unlock,gl=1 l=unlock,gl=2 l=7, gl=0 l=7, gl=1 l=7, gl=2 l=8, gl=0 .... ....

Step 2: Game Trans. system variables: line (l), got_lock (gl) int[0,1,2] got_lock = 0; int[0,1,2] freedom; ... 1: while(*) { 2: if (*) { 3: lock(); lock: {LOCK:=1;} 4: got_lock:=freedom; } 5: if (got_lock != 0) { 6: unlock(); unlock: {LOCK:=0;} 7: got_lock:=freedom; 8: Trans. system variables: line (l), got_lock (gl) l=1, gl=0 l=1, gl=1 l=1, gl=2 l=2, gl=0 .... l=2, gl=2 l=3, gl=0 l=3, gl=2 l=lock,gl=0 l=lock,gl=2 f=0 f=2 f=1 l=4, gl=0 l=4, gl=2 l=5, gl=0 l=5, gl=1 l=5, gl=2 l=6, gl=1 l=6, gl=2 l=unlock,gl=1 l=unlock,gl=2 l=7, gl=0 l=7, gl=1 l=7, gl=2 l=8, gl=0 .... .... Two types of non-determinism!

Step 2: Game Trans. system variables: line (l), got_lock (gl) int[0,1,2] got_lock = 0; int[0,1,2] freedom; ... 1: while(*) { 2: if (*) { 3: lock(); lock: {LOCK:=1;} 4: got_lock:=freedom; } 5: if (got_lock != 0) { 6: unlock(); unlock: {LOCK:=0;} 7: got_lock:=freedom; 8: Trans. system variables: line (l), got_lock (gl) l=1, gl=0 l=1, gl=1 l=1, gl=2 l=2, gl=0 .... l=2, gl=2 l=3, gl=0 l=lock, gl=0 l=3, gl=2 l=lock, gl=2 f=0 f=2 f=1 l=4, gl=0 l=4, gl=2 l=5, gl=0 l=5, gl=1 l=6, gl=1 l=unlock, gl=1 l=5, gl=2 l=6, gl=2 l=unlock, gl=2 l=7, gl=0 l=7, gl=1 l=7, gl=2 l=8, gl=0 .... .... Two types of non-determinism!

Step 3: Monitor for Acceptance P1: always( line=lock implies next( line!=lock wait-until line=unlock )) line!=lock & line!=unlock line!=lock line=lock line=unlock line=lock

Step 3: Product TS for got_lock in {0,1} Deterministic automaton l=1, gl=0 l=1, gl=1 l=2, gl=0 l=1, gl=2 l=3, gl=0 l=lock, gl=0 l=3, gl=0 l=lock, gl=0 l!=lock & l!=unlock l!=lock l=lock l=4, gl=0 l=4, gl=0 1 2 3 1 1 l=5, gl=0 l=5, gl=1 l=6, gl=1 l=unlock, gl=1 l=unlock l=lock 1 1 l=7, gl=0 l=7, gl=1 l=8, gl=0 ....

Step 3: Product l=1, gl=0 l=1, gl=1 l=1, gl=0 l=1, gl=1 l=2, gl=0 l=lock, gl=0 1 l=3, gl=0 l=lock, gl=0 1 l=3, gl=0 l=lock, gl=0 2 l=3, gl=0 l=lock, gl=0 2 l=4, gl=0 1 l=4, gl=1 1 l=4, gl=0 2 l=4, gl=1 2 l=4, gl=.. 3 1 1 l=5, gl=0 1 l=5, gl=1 l=6, gl=1 l=unlock, gl=1 1 l=5, gl=0 2 l=5, gl=1 l=6, gl=1 l=unlock, gl=1 2 1 l=7, gl=0 1 l=7, gl=1 1 l=7, gl=0 2 l=7, gl=1 2 l=8, gl=0 1 l=8, gl=1 1 l=8, gl=0 2 l=8, gl=1 2 l!=lock & l!=unlock l!=lock l=lock 1 2 3 l=lock l=unlock

Step 4: Winning States l=1, gl=0 l=1, gl=1 l=1, gl=0 l=1, gl=1 2 l=1, gl=1 2 l=2, gl=0 1 l=2, gl=1 1 l=2, gl=0 2 l=2, gl=1 2 l=3, gl=0 l=lock, gl=0 1 l=3, gl=0 l=lock, gl=0 1 l=3, gl=0 l=lock, gl=0 2 l=3, gl=0 l=lock, gl=0 2 l=4, gl=0 1 l=4, gl=1 1 l=4, gl=0 2 l=4, gl=1 2 l=4, gl=.. 3 1 1 l=5, gl=0 1 l=5, gl=1 l=6, gl=1 l=unlock, gl=1 1 l=5, gl=0 2 l=5, gl=1 l=6, gl=1 l=unlock, gl=1 2 1 l=7, gl=0 1 l=7, gl=1 1 l=7, gl=0 2 l=7, gl=1 2 l=8, gl=0 1 l=8, gl=1 1 l=8, gl=0 2 l=8, gl=1 2 l!=lock & l!=unlock l!=lock l=lock 1 2 3 l=lock l=unlock

Step 4: Winning States l=1, gl=0 l=1, gl=1 l=1, gl=0 l=1, gl=1 2 l=1, gl=1 2 l=2, gl=0 1 l=2, gl=1 1 l=2, gl=0 2 l=2, gl=1 2 l=3, gl=0 l=lock, gl=0 1 l=3, gl=0 l=lock, gl=0 1 l=3, gl=0 l=lock, gl=0 2 l=3, gl=0 l=lock, gl=0 2 l=4, gl=0 1 l=4, gl=1 1 l=4, gl=0 2 l=4, gl=1 2 l=4, gl=.. 3 1 1 l=5, gl=0 1 l=5, gl=1 l=6, gl=1 l=unlock, gl=1 1 l=5, gl=0 2 l=5, gl=1 l=6, gl=1 l=unlock, gl=1 2 1 l=7, gl=0 1 l=7, gl=1 1 l=7, gl=0 2 l=7, gl=1 2 l=8, gl=0 1 l=8, gl=1 1 l=8, gl=0 2 l=8, gl=1 2 l!=lock & l!=unlock l!=lock l=lock 1 2 3 l=lock l=unlock

Step 4: Winning States l=1, gl=0 l=1, gl=1 l=1, gl=0 l=1, gl=1 2 l=1, gl=1 2 l=2, gl=0 1 l=2, gl=1 1 l=2, gl=0 2 l=2, gl=1 2 l=3, gl=0 l=lock, gl=0 1 l=3, gl=0 l=lock, gl=0 1 l=3, gl=0 l=lock, gl=0 2 l=3, gl=0 l=lock, gl=0 2 l=4, gl=0 1 l=4, gl=1 1 l=4, gl=0 2 l=4, gl=1 2 l=4, gl=.. 3 1 1 l=5, gl=0 1 l=5, gl=1 l=6, gl=1 l=unlock, gl=1 1 l=5, gl=0 2 l=5, gl=1 l=6, gl=1 l=unlock, gl=1 2 1 l=7, gl=0 1 l=7, gl=1 1 l=7, gl=0 2 l=7, gl=1 2 l=8, gl=0 1 l=8, gl=1 1 l=8, gl=0 2 l=8, gl=1 2 l!=lock & l!=unlock l!=lock l=lock 1 2 3 l=lock l=unlock

Step 4: Winning States l=1, gl=0 l=1, gl=1 l=2, gl=0 l=2, gl=1 l=lock, gl=0 1 l=3, gl=0 l=lock, gl=0 1 l=4, gl=0 1 l=4, gl=1 1 l=4, gl=0 2 l=4, gl=1 2 1 1 1 l=5, gl=0 1 l=5, gl=1 l=6, gl=1 l=unlock, gl=1 1 l=5, gl=1 l=6, gl=1 l=unlock, gl=1 2 1 l=7, gl=0 1 l=7, gl=1 1 l=8, gl=0 1 l=8, gl=1 1

Step 4: Winning Strategy In general: strategy is function of program and monitor state l=1, gl=0 1 l=1, gl=1 1 l=2, gl=0 1 l=2, gl=1 1 Strategy to Repair: if (l=4 & gl=0 & s=1) freedom:=0 if (l=4 & gl=1 & s=1) freedom:=1 if (l=4 & gl=0 & s=0) freedom:=1 if (l=7 & gl=0 & s=1) freedom:=0 if (l=7 & gl=1 & s=1) freedom:=0 .. freedom := f(l,gl,s) if (line=4) freedom := (gl=1) | (s=2) if (line=7) freedom := 0 l=3, gl=0 l=lock, gl=0 1 l=3, gl=0 l=lock, gl=0 1 l=4, gl=0 1 l=4, gl=1 1 l=4, gl=0 2 l=4, gl=1 2 1 1 1 l=5, gl=0 1 l=5, gl=1 l=6, gl=1 l=unlock, gl=1 1 l=5, gl=1 l=6, gl=1 l=unlock, gl=1 2 l=7, gl=0 1 l=7, gl=1 1 l=8, gl=0 1 l=8, gl=1 1 What we actually do: merge states before picking the strategy

Step 4: Winning Strategy l=1, gl=0 l=2, gl=0 l=3, gl=0 l=lock, gl=0 l=4, gl=0 l=5, gl=1 l=6, gl=1 l=unlock, gl=1 l=7, gl=1 l=8, gl=0 l=5, gl=0 l=7, gl=0 l=1, gl=1 l=2, gl=1 l=8, gl=1 l=4, gl=1 1 l=1, gl=0 1 l=1, gl=1 1 l=2, gl=0 1 l=2, gl=1 1 l=3, gl=0 l=lock, gl=0 1 l=3, gl=0 l=lock, gl=0 1 l=4, gl=0 1 l=4, gl=1 1 l=4, gl=0 2 l=4, gl=1 2 1 1 1 l=5, gl=0 1 l=5, gl=1 l=6, gl=1 l=unlock, gl=1 1 l=5, gl=1 l=6, gl=1 l=unlock, gl=1 2 1 l=7, gl=0 1 l=7, gl=1 1 l=8, gl=0 1 l=8, gl=1 1

Step 4: Winning Strategy l=1, gl=0 l=1, gl=1 l=2, gl=0 l=2, gl=1 l=3, gl=0 l=lock, gl=0 l=3, gl=0 l=lock, gl=0 (line=4): freedom= 1 (line=7): freedom= 0 l=4, gl=0 l=4, gl=1 1 1 l=5, gl=0 l=5, gl=1 l=6, gl=1 l=unlock, gl=1 l=7, gl=0 l=7, gl=1 l=8, gl=0 l=8, gl=1

Repaired Program unsigned int got_lock = 0; ... 1: while(*) { 2: if (*) { 3: lock(); 4: got_lock = 1; } 5: if (got_lock != 0) { 6: unlock(); 7: got_lock = 0; lock() lock: {LOCK = 1;} unlock() unlock: {LOCK = 0;}

Original Program unsigned int got_lock = 0; ... 1: while(*) { 2: if (*) { 3: lock(); 4: got_lock++; } 5: if (got_lock != 0) { 6: unlock(); 7: got_lock--; lock() lock: {LOCK = 1;} unlock() unlock: {LOCK = 0;}

Program Repair Program Finite-state program Game TS: program with freedom Solve game Monitor Monitor TS: Winning condition (Simple) Strategy Specification Correct Program with Bloem, Griesmayer, Staber in CAV 2005, CHARME 2005 (+ext to fault localization)

Synthesis from Temporal Logics Game Solve game Monitor + interface definition Monitor TS: Winning condition (Simple) Strategy Specification Correct Program Church (1962), Büchi/Landweber (1969, games), Rabin (1972, trees), Pnueli/Rosner (1989, LTL)

Program Synthesis Program FSM + freedom Game TS Solve game Monitor Monitor TS: Winning condition (Simple) Strategy Specification Correct Program Modern Controller Synthesis, see overview papers by Walukiewicz et al., Rutten & Girault, ...

Issues? Program FSM + freedom Game TS Solve game Monitor TS: Winning How to abstract? Game Size? How to solve efficiently? FSM + freedom Game TS Solve game How to construct efficiently? How expressive?Size? How to pick a strategy? Monitor Monitor TS: Winning condition (Simple) Strategy Quantitative Program Synthesis Specification How to map back? Correct Program How to specify? Related research areas: PL, AV, Control Theory, Game and Automata Theory LTL

Next Lecture Basic of automata-based game theory terminology reachability/safety, Buchi, parity games Algorithms for solving games