Trace Abstraction (Recap) Andreas Podelski University of Freiburg, - - PowerPoint PPT Presentation

trace abstraction recap
SMART_READER_LITE
LIVE PREVIEW

Trace Abstraction (Recap) Andreas Podelski University of Freiburg, - - PowerPoint PPT Presentation

Trace Abstraction (Recap) Andreas Podelski University of Freiburg, Germany Tuesday, December 15, 2011 Preliminaries: Programs program = graph if (x==0) 0 : 0 x==0 x!=0 y:=1 1 : 2 : 1 3 else y:=1 y:=2 3 : y:=2


slide-1
SLIDE 1

Trace Abstraction (Recap)

Andreas Podelski

University of Freiburg, Germany

Tuesday, December 15, 2011

slide-2
SLIDE 2

Preliminaries: Programs

program = graph ℓ0:

if (x==0)

ℓ1:

y:=1

ℓ2:

else

ℓ3:

y:=2

ℓ4:

ℓ0 ℓ3 ℓ1 ℓ2 ℓ4 x!=0 x==0 y:=1 y:=2

◮ nodes = control locations

two special nodes: initial location ℓ0 error location ℓerr

◮ edges labeled by statements

  • nly two kinds of statements:

update e.g.,

y:=1 , y:=2

assume e.g.,

x==0 , x!=0

slide-3
SLIDE 3

Running Example: Program P

ℓ0:

x:=0

ℓ1:

y:=0

ℓ2:

while(nondet) {x++} assert x!= -1 assert y!= -1

program P ℓ0 ℓ1 ℓ2 ℓerr x:=0 y:=0 x++ x==-1 y==-1 program P

slide-4
SLIDE 4

Trace = Word over an Alphabet

alphabet Σ = set of statements Σ =

  • x:=0 , y:=0 , x++ , x==-1 , y==-1
  • examples

w1 = y==-1 . x++ . x++ . x:=0 . x==-1 w2 = x:=0 . y:=0 . x++ . x++ . y==-1 ℓ0 ℓ1 ℓ2 ℓerr x:=0 y:=0 x++ x==-1 y==-1 program P

slide-5
SLIDE 5

Error Trace

error trace = word w along path from ℓ0 to ℓerr w1 = x:=0 . y:=0 . y==-1 w2 = x:=0 . y:=0 . x++ . x++ . y==-1 ℓ0 ℓ1 ℓ2 ℓerr x:=0 y:=0 x++ x==-1 y==-1 program P

slide-6
SLIDE 6

Feasible Trace

feasible trace = word w formed by letter of an possible execution path w1 = x==-1 . x:=0 feasible w2 = x:=0 . x==-1 not feasible w3 = x>=0 . x-- . x-- . . . . . x-- . x--

  • finitely many

feasible w4 = x>=0 . x-- . x-- . x-- . x-- . . . .

  • infinitely many

not feasible

slide-7
SLIDE 7

Automata over Alphabet Σ of Statements

◮ automaton AP defines set of error traces ◮ note: set of feasible traces can not be

defined by automaton ℓ0 ℓ1 ℓ2 ℓerr x:=0 y:=0 x++ x==-1 y==-1 automaton AP

slide-8
SLIDE 8

Correctness of Program P

all traces Σ∗ traces of P error traces of P feasible traces

slide-9
SLIDE 9

Incorrectness of Program P

all traces Σ∗ traces of P error traces of P feasible traces

slide-10
SLIDE 10

Decomposition of Correctness Proof

all traces Σ∗ traces of P error traces of P feasible traces

slide-11
SLIDE 11

Decomposition of Correctness Proof

all traces Σ∗ traces of P error traces of P feasible traces

slide-12
SLIDE 12

Decomposition of Correctness Proof

all traces Σ∗ traces of P error traces of P feasible traces

slide-13
SLIDE 13

program P alphabet Σ = set of statements automaton AP = set of error traces for program P Proof Rule AP ⊆ A1 ∪ · · · ∪ An A1, . . . , An ⊆ Σ∗\FEASIBLE ⇒ program P is correct “A1, . . . , An are a decomposition of a correctness proof for program P”

slide-14
SLIDE 14

How?

how do we obtain a decomposition A1, . . . , An of a correctness proof for program P? next:

  • 1. specific algorithm `

a la CEGAR

  • 2. generalization
slide-15
SLIDE 15

How?

how do we obtain a decomposition A1, . . . , An of a correctness proof for program P? next:

  • 1. specific algorithm `

a la CEGAR

  • 2. generalization
slide-16
SLIDE 16

Compute Decomposition of Correctness Proof ` a la CEGAR

program P P is correct P is incorrect AP ⊆ A1 ∪ · · · ∪ An ? w ∈ Σ∗\FEASIBLE ? no take w such that w ∈ AP\A1 ∪ · · · ∪ An yes construct An+1 such that w ∈ An+1 yes no

slide-17
SLIDE 17

next: generalization of counterexamples given trace w such that

  • 1. w ∈ AP\A1 ∪ · · · ∪ An

(“ w is counterexample”)

  • 2. w ∈ Σ∗\FEASIBLE

(“w is infeasible”)

slide-18
SLIDE 18

next: generalization of counterexamples given trace w such that

  • 1. w ∈ AP\A1 ∪ · · · ∪ An

(“ w is counterexample”)

  • 2. w ∈ Σ∗\FEASIBLE

(“w is infeasible”) construct automaton An+1 such that

  • 1. w ∈ An+1
  • 2. w ∈ Σ∗\FEASIBLE
slide-19
SLIDE 19

First Iteration of Algorithm for Example Program P

n=0, i.e. A1 ∪ · · · ∪ An = ∅ take w1 ∈ AP\A1 ∪ · · · ∪ An w1 = x:=0 . y:=0 . y==-1 w1 is not feasible ℓ0 ℓ1 ℓ2 ℓerr x:=0 y:=0 x++ x==-1 y==-1 automaton AP

slide-20
SLIDE 20

First Iteration of Algorithm for Example Program P

w1 = x:=0 . y:=0 . y==-1 construct automaton A1 such that

  • 1. w ∈ A1
  • 2. w ∈ Σ∗\FEASIBLE

trivial solution: A1 = {w1} q0 q1 q2 q3 x:=0 y:=0 y==-1

slide-21
SLIDE 21

First Iteration of Algorithm for Example Program P

w1 = x:=0 . y:=0 . y==-1 construct automaton A1 such that

  • 1. w ∈ A1
  • 2. w ∈ Σ∗\FEASIBLE

trivial solution: A1 = {w1}

  • bserve:

statement x:++ does not affect variable y therefore x:=0 . y:=0 . x:++ . y==-1 is also infeasible q0 q1 q2 q3 x:=0 y:=0 y==-1 x++

slide-22
SLIDE 22

Second Iteration of Algorithm for Example Program P

n=1 w2 ∈ AP\A1 w2 = x:=0 . y:=0 . x==-1 construct automaton A2 such that

  • 1. w ∈ A2
  • 2. w ∈ Σ∗\FEASIBLE

trivial solution: A2 = {w2} q0 q1 q2 q3 x:=0 y:=0 x==-1

slide-23
SLIDE 23
  • bserve:

proof of infeasiblity of w2 = x:=0 . y:=0 . x==-1 is correctness proof of Hoare triple {true} w2 {false}

slide-24
SLIDE 24

Second Iteration of Algorithm for Example Program P

{true} x:=0 {x ≥ 0} {x ≥ 0} y:=0 {x ≥ 0} {x ≥ 0} x==-1 {false} q0 q1 q2 q3 x:=0 y:=0 x==-1 {true} {x ≥ 0} {x ≥ 0} {false}

slide-25
SLIDE 25

Second Iteration of Algorithm for Example Program P

{true} x:=0 {x ≥ 0} {x ≥ 0} y:=0 {x ≥ 0} {x ≥ 0} x==-1 {false}

  • bserve:

{x ≥ 0} x++ {x ≥ 0} is a valid Hoare triple q0 q1 q2 q3 x:=0 y:=0 x==-1 {true} {x ≥ 0} {x ≥ 0} {false} x++

slide-26
SLIDE 26

A1 and A2 are Decomposition of a Correctness Proof for Program P

ℓ0 ℓ1 ℓ2 ℓerr x:=0 y:=0 x++ x==-1 y==-1 automaton AP

AP ⊆ A1 ∪ A2

q0 q1 q2 q3 x:=0 y:=0 y==-1 x++ automaton A1

A1 ⊆ Σ∗\FEASIBLE

q0 q1 q2 q3 x:=0 y:=0 x==-1 x++ automaton A2

A2 ⊆ Σ∗\FEASIBLE

Proof Rule AP ⊆ A1 ∪ · · · ∪ An A1, . . . , An ⊆ Σ∗\FEASIBLE ⇒ program P is correct

slide-27
SLIDE 27

Interpolant Automaton AI

Definition (Interpolant Automaton AI)

I = I0, I1, . . . , In sequence of state predicates (“Interpolants”) AI = QI, δI, Qinit

I , Qfin I

QI = {q0, . . . , qn} (qi, st, qj) ∈ δI

  • nly if

{Ii} st {Ij} qi ∈ Qinit

  • nly if

Ii = true qi ∈ Qfin

  • nly if

Ii = false

slide-28
SLIDE 28

Interpolant Automaton AI

Definition (Interpolant Automaton AI)

I = I0, I1, . . . , In sequence of state predicates (“Interpolants”) AI = QI, δI, Qinit

I , Qfin I

QI = {q0, . . . , qn} (qi, st, qj) ∈ δI

  • nly if

{Ii} st {Ij} qi ∈ Qinit

  • nly if

Ii = true qi ∈ Qfin

  • nly if

Ii = false

Theorem

An interpolant automaton AI recognizes a subset of infeasible traces. L(AI) ⊆ Infeasible

slide-29
SLIDE 29

CEGAR with Database of Interpolant Automata

program P P is correct P is incorrect AP ⊆ A1 ∪ · · · ∪ An ? exists A that accepts π? no take w such that w ∈ AP\A1 ∪ · · · ∪ An yes An+1 := A yes no