Program Repair without Regret
Barbara Jobstmann EPFL and Jasper DA CNRS, Verimag Joint Work with Christian von Essen UJF, Verimag Google Zurich
4th April 2014
- B. Jobstmann
1
without Regret Barbara Jobstmann EPFL and Jasper DA CNRS, Verimag - - PowerPoint PPT Presentation
Program Repair without Regret Barbara Jobstmann EPFL and Jasper DA CNRS, Verimag Joint Work with Christian von Essen UJF, Verimag Google Zurich 4th April 2014 B. Jobstmann 1 Agenda Introduction Motivation Program Repair,
4th April 2014
1
4th April 2014
2
4th April 2014
3
4th April 2014
4
4th April 2014
5
4th April 2014
6
4th April 2014
7
mainLight = Red; sideLight = Red; always @(posedge clock) begin case (mainLight) Red: if (mainSensor) mainLight = Yellow; Yellow: mainLight = Green; Green: mainLight = Red; endcase // case (mainLight) case (sideLight) Red: if (sideSensor) sideLight = Yellow; Yellow: sideLight = Green; Green: sideLight = Red; endcase // case (sideLight) end
4th April 2014 8
State variables: mainLight in {Red, Yellow, Green} sideLight in {Red, Yellow, Green} Input variables: mainSensor in {True, False} sideSensor in {True, False} Behavior represented as (infinite) sequence of evaluations of state and input variables:w ∈ 𝐹(𝑊)𝜕
Step 1 2 3 4 … mL Red Yellow Green Red … sL Red Red Red Yellow … mS True True False … … sS False False True … …
Program represented as set of behaviors: 𝑀 𝑄
mainLight = Red; sideLight = Red; always @(posedge clock) begin case (mainLight) Red: if (mainSensor) mainLight = Yellow; Yellow: mainLight = Green; Green: mainLight = Red; endcase // case (mainLight) case (sideLight) Red: if (sideSensor) sideLight = Yellow; Yellow: sideLight = Green; Green: sideLight = Red; endcase // case (sideLight) end
4th April 2014 9
State variables: mainLight in {Red, Yellow, Green} sideLight in {Red, Yellow, Green} Input variables: mainSensor in {True, False} sideSensor in {True, False} Specification represented as set of behaviors: 𝑀(φ) Program represented as set of behaviors: 𝑀 𝑄 Specification: never(mainLight == Green and sideLight == Green) Behavior represented as (infinite) sequence of evaluations of state and input variables:w ∈ 𝐹(𝑊)𝜕
mainLight = Red; sideLight = Red; always @(posedge clock) begin case (mainLight) Red: if (mainSensor) mainLight = Yellow; Yellow: mainLight = Green; Green: mainLight = Red; endcase // case (mainLight) case (sideLight) Red: if (sideSensor) sideLight = Yellow; Yellow: sideLight = Green; Green: sideLight = Red; endcase // case (sideLight) end
4th April 2014 10
State variables: mainLight in {Red, Yellow, Green} sideLight in {Red, Yellow, Green} Input variables: mainSensor in {True, False} sideSensor in {True, False}
Specification: never(mainLight == Green and sideLight == Green)
??? Allowed modifications: function over state and input variables Specification represented as set of behaviors: 𝑀(φ) Program represented as set of behaviors: 𝑀 𝑄 Behavior represented as (infinite) sequence of evaluations of state and input variables:w ∈ 𝐹(𝑊)𝜕
mainLight = Red; sideLight = Red; always @(posedge clock) begin case (mainLight) Red: if (mainSensor) mainLight = Yellow; Yellow: mainLight = Green; Green: mainLight = Red; endcase // case (mainLight) case (sideLight) Red: if (sideSensor) sideLight = Yellow; Yellow: sideLight = Green; Green: sideLight = Red; endcase // case (sideLight) end
4th April 2014 11
State variables: mainLight in {Red, Yellow, Green} sideLight in {Red, Yellow, Green} Input variables: mainSensor in {True, False} sideSensor in {True, False}
Specification: never(mainLight == Green and sideLight == Green)
??? Allowed modifications: function over state and input variables Input variables: mainSensor in {True, False} sideSensor in {True, False} Winning objective: repaired program is correct, i.e., 𝑀 𝑄′ ⊆ 𝑀(φ) Specification represented as set of behaviors: 𝑀(φ) Program represented as set of behaviors: 𝑀 𝑄 Behavior represented as (infinite) sequence of evaluations of state and input variables:w ∈ 𝐹(𝑊)𝜕
mainLight = Red; sideLight = Red; always @(posedge clock) begin case (mainLight) Red: if (mainSensor) mainLight = Yellow; Yellow: mainLight = Green; Green: mainLight = Red; endcase // case (mainLight) case (sideLight) Red: if (sideSensor) sideLight = Yellow; Yellow: sideLight = Green; Green: sideLight = Red; endcase // case (sideLight) end
4th April 2014 12
State variables: mainLight in {Red, Yellow, Green} sideLight in {Red, Yellow, Green} Input variables: mainSensor in {True, False} sideSensor in {True, False} ??? Allowed modifications: “simple” function over state and input variables Input variables: mainSensor in {True, False} sideSensor in {True, False}
Specification: never(mainLight == Green and sideLight == Green)
Specification represented as set of behaviors: 𝑀(φ) Program represented as set of behaviors: 𝑀 𝑄 Winning objective: repaired program is correct, i.e., 𝑀 𝑄′ ⊆ 𝑀(φ) Behavior represented as (infinite) sequence of evaluations of state and input variables:w ∈ 𝐹(𝑊)𝜕
mainLight = Red; sideLight = Red; always @(posedge clock) begin case (mainLight) Red: if (mainSensor) mainLight = Yellow; Yellow: mainLight = Green; Green: mainLight = Red; endcase // case (mainLight) case (sideLight) Red: if (sideSensor) sideLight = Yellow; Yellow: sideLight = Green; Green: sideLight = Red; endcase // case (sideLight) end
4th April 2014
false
Specification: never(mainLight == Green and sideLight == Green)
No car crash: correct repair Main street blocked What went wrong? Lost intended behavior; changed behaviors unnecessarily Idea: semantic similarity
effect correct behaviors
Extend objective: repair keeps correct behaviors 𝑀 𝑄 ∩ 𝑀 φ ⊆ 𝑀 𝑄′ (mainSensor & !(sideLight == Red & sideSensor)) Winning objective: repaired program is correct, i.e., 𝑀 𝑄′ ⊆ 𝑀(φ)
[Angelic debugging, Chandra et al.]
4th April 2014
14
4th April 2014
15
P’ Ideal but sometimes too restrictive:
Behaviors that do not satisfy φ𝑏 are correct but might not need to be preserved φ P
4th April 2014
16
P’ φ P ψ
4th April 2014
17
4th April 2014
18
(All behaviors with a sequence of inputs for which P violates the spec)
4th April 2014
19
4th April 2014
20
4th April 2014
21
P faulty program P* P extended with allowed modifications 𝐵𝜒 𝐵¬𝜔 𝐵𝑓𝑟 Inputs New Repair Approach: 𝐵¬𝜔 … checks when P’ can deviate from P 𝐵𝑓𝑟 … checks when the output
Classical Repair Approach: 𝐵𝜒 … defines objective of synthesis/repair game New Objective: 𝐵𝜒 and (𝐵¬𝜔 or 𝐵𝑓𝑟)
memoryless strategies)
repair.
4th April 2014
22
4th April 2014
23
4th April 2014
24
4th April 2014
25
4th April 2014
26
4th April 2014
27
4th April 2014
28
4th April 2014
29