inductive verification of hybrid automata with strongest ...ishii/pub/06-12_ifm.pdf · hybrid...

60
Inductive Verification of Hybrid Automata with Strongest Postcondition Calculus June 12, 2013 @ iFM Daisuke Ishii Tokyo Institute of Technology Guillaume Melquiond INRIA Saclay / LRI, Université Paris Sud 11 Shin Nakajima National Institute of Informatics, Tokyo 1

Upload: others

Post on 27-Jun-2020

0 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Inductive Verification of Hybrid Automata with Strongest ...ishii/pub/06-12_ifm.pdf · Hybrid Automata with Strongest Postcondition Calculus June 12, 2013 @ iFM Daisuke Ishii Tokyo

Inductive Verification of Hybrid Automata with

Strongest Postcondition Calculus

June 12, 2013 @ iFM

Daisuke IshiiTokyo Institute of Technology

Guillaume MelquiondINRIA Saclay / LRI, Université Paris Sud 11

Shin NakajimaNational Institute of Informatics, Tokyo

1

Page 2: Inductive Verification of Hybrid Automata with Strongest ...ishii/pub/06-12_ifm.pdf · Hybrid Automata with Strongest Postcondition Calculus June 12, 2013 @ iFM Daisuke Ishii Tokyo

Hybrid Systems

•Systems whose states can make both continuous and discrete changes

•Example: Water-level monitor

2

maxhigh

lowmin

level sensor

pump

x

on/off

x = rateout・

Page 3: Inductive Verification of Hybrid Automata with Strongest ...ishii/pub/06-12_ifm.pdf · Hybrid Automata with Strongest Postcondition Calculus June 12, 2013 @ iFM Daisuke Ishii Tokyo

x = ratein・

Hybrid Systems

•Systems whose states can make both continuous and discrete changes

•Example: Water-level monitor

2

maxhigh

lowmin

level sensor

pump

x

on/off

Page 4: Inductive Verification of Hybrid Automata with Strongest ...ishii/pub/06-12_ifm.pdf · Hybrid Automata with Strongest Postcondition Calculus June 12, 2013 @ iFM Daisuke Ishii Tokyo

Verification of Hybrid Systems•Model-checking approach

-Based on hybrid automata -Many practical automated tools: e.g. HyTech

[Henzinger+ 96] and PHAVer [Frehse 02]

-Tractable problems are limited: small linear models, without uncertain parameters

3

Page 5: Inductive Verification of Hybrid Automata with Strongest ...ishii/pub/06-12_ifm.pdf · Hybrid Automata with Strongest Postcondition Calculus June 12, 2013 @ iFM Daisuke Ishii Tokyo

Verification of Hybrid Systems•Model-checking approach

-Based on hybrid automata -Many practical automated tools: e.g. HyTech

[Henzinger+ 96] and PHAVer [Frehse 02]

-Tractable problems are limited: small linear models, without uncertain parameters

•Logical analytic approach-Based on annotated imperative programs-Theoretically studied but few practical tools-KeYmaera [Platzer+ 08] has been successful-Applicable to larger class of systems

✴systems with symbolic parameters, nonlinear systems-Verification process is not fully automatic 3

Page 6: Inductive Verification of Hybrid Automata with Strongest ...ishii/pub/06-12_ifm.pdf · Hybrid Automata with Strongest Postcondition Calculus June 12, 2013 @ iFM Daisuke Ishii Tokyo

•We propose an algorithmic logical analytic method built on top of symbolic arithmetic solvers-Clear and correct scheme: conjunction of simple transformations

-Applicable to a large class of hybrid automata✴with nonlinear flows and uncertain parameters

Talk Overview

4

safety verification of hybrid automaton

□P

dx=...

… …

Page 7: Inductive Verification of Hybrid Automata with Strongest ...ishii/pub/06-12_ifm.pdf · Hybrid Automata with Strongest Postcondition Calculus June 12, 2013 @ iFM Daisuke Ishii Tokyo

•We propose an algorithmic logical analytic method built on top of symbolic arithmetic solvers-Clear and correct scheme: conjunction of simple transformations

-Applicable to a large class of hybrid automata✴with nonlinear flows and uncertain parameters

Talk Overview

4

safety verification of hybrid automaton

□P

dx=...

… …ImpHA program

trans; evolve ti; …

Page 8: Inductive Verification of Hybrid Automata with Strongest ...ishii/pub/06-12_ifm.pdf · Hybrid Automata with Strongest Postcondition Calculus June 12, 2013 @ iFM Daisuke Ishii Tokyo

•We propose an algorithmic logical analytic method built on top of symbolic arithmetic solvers-Clear and correct scheme: conjunction of simple transformations

-Applicable to a large class of hybrid automata✴with nonlinear flows and uncertain parameters

Talk Overview

4

safety verification of hybrid automaton

□P

dx=...

… …ImpHA program

trans; evolve ti; …

verification condition

VC1, ..., VCm+n

inductionSP calculus

Page 9: Inductive Verification of Hybrid Automata with Strongest ...ishii/pub/06-12_ifm.pdf · Hybrid Automata with Strongest Postcondition Calculus June 12, 2013 @ iFM Daisuke Ishii Tokyo

•We propose an algorithmic logical analytic method built on top of symbolic arithmetic solvers-Clear and correct scheme: conjunction of simple transformations

-Applicable to a large class of hybrid automata✴with nonlinear flows and uncertain parameters

Talk Overview

4

safety verification of hybrid automaton

□P

dx=...

… …ImpHA program

trans; evolve ti; …

safety proof

Mathematica

verification condition

VC1, ..., VCm+n

inductionSP calculus

Page 10: Inductive Verification of Hybrid Automata with Strongest ...ishii/pub/06-12_ifm.pdf · Hybrid Automata with Strongest Postcondition Calculus June 12, 2013 @ iFM Daisuke Ishii Tokyo

•We propose an algorithmic logical analytic method built on top of symbolic arithmetic solvers-Clear and correct scheme: conjunction of simple transformations

-Applicable to a large class of hybrid automata✴with nonlinear flows and uncertain parameters

Talk Overview

4

safety verification of hybrid automaton

□P

dx=...

… …ImpHA program

trans; evolve ti; …

loop invariantP+

safety proof

Mathematica

verification condition

VC1, ..., VCm+n

inductionSP calculus

Page 11: Inductive Verification of Hybrid Automata with Strongest ...ishii/pub/06-12_ifm.pdf · Hybrid Automata with Strongest Postcondition Calculus June 12, 2013 @ iFM Daisuke Ishii Tokyo

•We propose an algorithmic logical analytic method built on top of symbolic arithmetic solvers-Clear and correct scheme: conjunction of simple transformations

Talk Overview

4

safety verification of hybrid automaton

□P

dx=...

… …ImpHA program

trans; evolve ti; …

loop invariantP+

safety proof

Mathematica

verification condition

VC1, ..., VCm+n

inductionSP calculus

Page 12: Inductive Verification of Hybrid Automata with Strongest ...ishii/pub/06-12_ifm.pdf · Hybrid Automata with Strongest Postcondition Calculus June 12, 2013 @ iFM Daisuke Ishii Tokyo

•We propose an algorithmic logical analytic method built on top of symbolic arithmetic solvers-Clear and correct scheme: conjunction of simple transformations

-Applicable to a large class of hybrid automata✴with nonlinear flows and uncertain parameters

Talk Overview

4

safety verification of hybrid automaton

□P

dx=...

… …ImpHA program

trans; evolve ti; …

loop invariantP+

safety proof

Mathematica

verification condition

VC1, ..., VCm+n

inductionSP calculus

Page 13: Inductive Verification of Hybrid Automata with Strongest ...ishii/pub/06-12_ifm.pdf · Hybrid Automata with Strongest Postcondition Calculus June 12, 2013 @ iFM Daisuke Ishii Tokyo

Talk Outline

1.Hybrid Automata

2. ImpHA and Strongest Postcondition Calculus

3. Inductive Verification

4.Experimental Results

5

Page 14: Inductive Verification of Hybrid Automata with Strongest ...ishii/pub/06-12_ifm.pdf · Hybrid Automata with Strongest Postcondition Calculus June 12, 2013 @ iFM Daisuke Ishii Tokyo

Hybrid Automata (HA)

•Mathematical model of hybrid systems-Discrete aspect is described by an automaton-Continuous dynamics is described by a differential equation indexed by locations of the automaton

6

Page 15: Inductive Verification of Hybrid Automata with Strongest ...ishii/pub/06-12_ifm.pdf · Hybrid Automata with Strongest Postcondition Calculus June 12, 2013 @ iFM Daisuke Ishii Tokyo

Hybrid Automata (HA)•A hybrid automaton is a septetHA =〈Loc, Var, Init, Grd, Rst, Flow, Inv〉 that consists of:- Finite set Loc = {L1,...,Lp} of locations- Finite set Var = {x1,...,xq} of real-valued variables- Initial condition Init in L×RVar

- Family Grd = {GrdL,L’}L∈Loc,L’∈Loc of guard conditions GrdL,L’ in RVar

- Family Rst = {RstL,L’}L∈Loc,L’∈Loc of reset functions RstL,L’ : RVar → RVar

- Family Flow = {FlowL}L∈Loc of vector fields FlowL : RVar → RVar

- Family Inv = {InvL}L∈Loc of location invariants InvL in RVar

7

Page 16: Inductive Verification of Hybrid Automata with Strongest ...ishii/pub/06-12_ifm.pdf · Hybrid Automata with Strongest Postcondition Calculus June 12, 2013 @ iFM Daisuke Ishii Tokyo

Example: Water-level Monitor

8

onx1=rate_inx1≦high

sw_offx1=rate_in & x2=1

x2≦delay

offx1=rate_outx1≦low

sw_onx1=rate_out & x2=1

x2≦delay

x2=delay ⇒ x2:=0

x2=delay ⇒ x2:=0

x1=low ⇒ x2:=0

x1=high ⇒ x2:=0x1:=low

x1: analog, x2: stopwatch

・ ・ ・

・ ・ ・

Page 17: Inductive Verification of Hybrid Automata with Strongest ...ishii/pub/06-12_ifm.pdf · Hybrid Automata with Strongest Postcondition Calculus June 12, 2013 @ iFM Daisuke Ishii Tokyo

Example: Water-level Monitor

8

onx1=rate_inx1≦high

sw_offx1=rate_in & x2=1

x2≦delay

offx1=rate_outx1≦low

sw_onx1=rate_out & x2=1

x2≦delay

x2=delay ⇒ x2:=0

x2=delay ⇒ x2:=0

x1=low ⇒ x2:=0

x1=high ⇒ x2:=0x1:=low

x1: analog, x2: stopwatch

location

transition

initial condition

variables

・ ・ ・

・ ・ ・

Page 18: Inductive Verification of Hybrid Automata with Strongest ...ishii/pub/06-12_ifm.pdf · Hybrid Automata with Strongest Postcondition Calculus June 12, 2013 @ iFM Daisuke Ishii Tokyo

Example: Water-level Monitor

8

onx1=rate_inx1≦high

sw_offx1=rate_in & x2=1

x2≦delay

offx1=rate_outx1≦low

sw_onx1=rate_out & x2=1

x2≦delay

x2=delay ⇒ x2:=0

x2=delay ⇒ x2:=0

x1=low ⇒ x2:=0

x1=high ⇒ x2:=0x1:=low

vector field

location invariantguard

reset

x1: analog, x2: stopwatch

location

transition

initial condition

variables

・ ・ ・

・ ・ ・

Page 19: Inductive Verification of Hybrid Automata with Strongest ...ishii/pub/06-12_ifm.pdf · Hybrid Automata with Strongest Postcondition Calculus June 12, 2013 @ iFM Daisuke Ishii Tokyo

Execution of Water-level Monitor

•Two rates of the water flow: rate_in and rate_out•The controller tries to turn on/off the pump when the water level reaches low/high

•It takes delay seconds to turn on/off the pump

9

maxhigh

lowmin

onsw_off

off onsw_on

x1(t)

x2(t)

Page 20: Inductive Verification of Hybrid Automata with Strongest ...ishii/pub/06-12_ifm.pdf · Hybrid Automata with Strongest Postcondition Calculus June 12, 2013 @ iFM Daisuke Ishii Tokyo

Execution of HA•(Finite- or infinite-length) execution of a HA is a valuation of variables as functions over time

10

〈on,(3,0)〉 → 〈on,(high,0)〉 → 〈sw_off,(high,0)〉 →

〈sw_off,(5.5,delay)〉 → …

3.5 0 delay

0

x1(t)

x2(t)

maxhigh

lowmin

on sw_off off onsw_on3.5 delay

3

5.5

delay0

Page 21: Inductive Verification of Hybrid Automata with Strongest ...ishii/pub/06-12_ifm.pdf · Hybrid Automata with Strongest Postcondition Calculus June 12, 2013 @ iFM Daisuke Ishii Tokyo

Execution of HA•(Finite- or infinite-length) execution of a HA is a valuation of variables as functions over time

10

〈on,(3,0)〉 → 〈on,(high,0)〉 → 〈sw_off,(high,0)〉 →

〈sw_off,(5.5,delay)〉 → …

3.5 0 delay

0

Loc×RVar

continuous evolution for duration 3.5

discrete transition

x1(t)

x2(t)

maxhigh

lowmin

on sw_off off onsw_on3.5 delay

3

5.5

delay0

Page 22: Inductive Verification of Hybrid Automata with Strongest ...ishii/pub/06-12_ifm.pdf · Hybrid Automata with Strongest Postcondition Calculus June 12, 2013 @ iFM Daisuke Ishii Tokyo

Operational Semantics of HA

•Continuous evolution

•Discrete transition

11

t>0 φ(0)=v ∀t∈[0,t] = FlowL(φ(t)) ∧ InvL[φ(t)]dtdφ~

~ ~~

GrdL1,L2[v1] v2 = RstL1,L2(v1) InvL2[v2]

〈L1,v1〉 → 〈L2,v2〉

〈L,v〉 → 〈L,φ(t)〉t

0

Page 23: Inductive Verification of Hybrid Automata with Strongest ...ishii/pub/06-12_ifm.pdf · Hybrid Automata with Strongest Postcondition Calculus June 12, 2013 @ iFM Daisuke Ishii Tokyo

Safety Verification of HA

•Safety property □P means:

-P holds initially, and is preserved by every continuous evolution and discrete transition

-i.e. invariance-Example: □(min≤x1 ∧ x1≤max)

12

Page 24: Inductive Verification of Hybrid Automata with Strongest ...ishii/pub/06-12_ifm.pdf · Hybrid Automata with Strongest Postcondition Calculus June 12, 2013 @ iFM Daisuke Ishii Tokyo

Talk Outline

1.Hybrid Automata

2. ImpHA and Strongest Postcondition Calculus

3. Inductive Verification

4.Experimental Results

13

Page 25: Inductive Verification of Hybrid Automata with Strongest ...ishii/pub/06-12_ifm.pdf · Hybrid Automata with Strongest Postcondition Calculus June 12, 2013 @ iFM Daisuke Ishii Tokyo

Modeling HA Executions with Programs

•Given a HA, we consider a simple imperative language ImpHA-Program’s states correspond to the states in the HA executions

-Motivation: reuse of traditional program verification tools

14

Page 26: Inductive Verification of Hybrid Automata with Strongest ...ishii/pub/06-12_ifm.pdf · Hybrid Automata with Strongest Postcondition Calculus June 12, 2013 @ iFM Daisuke Ishii Tokyo

Modeling HA Executions with Programs

•Given a HA, we consider a simple imperative language ImpHA-Program’s states correspond to the states in the HA executions

-Motivation: reuse of traditional program verification tools

•We provide a notion of strongest-postcondition (SP) for each ImpHA statements-Cf. forward reachability analysis

14

Page 27: Inductive Verification of Hybrid Automata with Strongest ...ishii/pub/06-12_ifm.pdf · Hybrid Automata with Strongest Postcondition Calculus June 12, 2013 @ iFM Daisuke Ishii Tokyo

ImpHA Language•ImpHA is a simple imperative language for sketching an execution of the HA-s := skip | s; s | evolve t | trans

•Consider implicit variables xs =〈xL, xv〉=〈xL, (x1,...,xq)〉

that express the “current state” in Loc×RVar of the HA execution

•Program state S is a map from variable names to program values-Example: S = {xL ↦ on, x1 ↦ 3.1, x2 ↦ 0} 15

Page 28: Inductive Verification of Hybrid Automata with Strongest ...ishii/pub/06-12_ifm.pdf · Hybrid Automata with Strongest Postcondition Calculus June 12, 2013 @ iFM Daisuke Ishii Tokyo

ImpHA Language•ImpHA is a simple imperative language for sketching an execution of the HA-s := skip | s; s | evolve t | trans

•Consider implicit variables xs =〈xL, xv〉=〈xL, (x1,...,xq)〉

that express the “current state” in Loc×RVar of the HA execution

•Program state S is a map from variable names to program values-Example: S = {xL ↦ on, x1 ↦ 3.1, x2 ↦ 0} 15

continuous evolution for the duration t

discrete transition

Page 29: Inductive Verification of Hybrid Automata with Strongest ...ishii/pub/06-12_ifm.pdf · Hybrid Automata with Strongest Postcondition Calculus June 12, 2013 @ iFM Daisuke Ishii Tokyo

ImpHA Language•ImpHA is a simple imperative language for sketching an execution of the HA-s := skip | s; s | evolve t | trans

•Consider implicit variables xs =〈xL, xv〉=〈xL, (x1,...,xq)〉

that express the “current state” in Loc×RVar of the HA execution

15

continuous evolution for the duration t

discrete transition

Page 30: Inductive Verification of Hybrid Automata with Strongest ...ishii/pub/06-12_ifm.pdf · Hybrid Automata with Strongest Postcondition Calculus June 12, 2013 @ iFM Daisuke Ishii Tokyo

ImpHA Language•ImpHA is a simple imperative language for sketching an execution of the HA-s := skip | s; s | evolve t | trans

•Consider implicit variables xs =〈xL, xv〉=〈xL, (x1,...,xq)〉

that express the “current state” in Loc×RVar of the HA execution

•Program state S is a map from variable names to program values-Example: S = {xL ↦ on, x1 ↦ 3.1, x2 ↦ 0} 15

continuous evolution for the duration t

discrete transition

Page 31: Inductive Verification of Hybrid Automata with Strongest ...ishii/pub/06-12_ifm.pdf · Hybrid Automata with Strongest Postcondition Calculus June 12, 2013 @ iFM Daisuke Ishii Tokyo

GrdL’,xL[xv’] ∧ xv=RstL’,xL(xv’) ∧ InvxL[xv]

SP(P, skip) := P

SP(P, s1;s2) := SP(SP(P, s1), s2)

SP(P,evolve t) := ∃φ P[xv←φ(0)] ∧

SP(P, trans) := ∃〈L’,xv’〉P[xs←〈L’,xv’〉] ∧

φ(t)=xv ∧(∀t∈[0,t] =FlowxL(φ(t)) ∧ InvxL[φ(t)])dtdφ~

~ ~~

Strongest Postcondition Calculus•Lemma 3. For any program s in ImpHA, if the initial state satisfies P, the final state satisfies SP(P,s) with SP defined as follows:

16

Page 32: Inductive Verification of Hybrid Automata with Strongest ...ishii/pub/06-12_ifm.pdf · Hybrid Automata with Strongest Postcondition Calculus June 12, 2013 @ iFM Daisuke Ishii Tokyo

GrdL’,xL[xv’] ∧ xv=RstL’,xL(xv’) ∧ InvxL[xv]

SP(P, skip) := P

SP(P, s1;s2) := SP(SP(P, s1), s2)

SP(P,evolve t) := ∃φ P[xv←φ(0)] ∧

SP(P, trans) := ∃〈L’,xv’〉P[xs←〈L’,xv’〉] ∧

φ(t)=xv ∧(∀t∈[0,t] =FlowxL(φ(t)) ∧ InvxL[φ(t)])dtdφ~

~ ~~

Strongest Postcondition Calculus•Lemma 3. For any program s in ImpHA, if the initial state satisfies P, the final state satisfies SP(P,s) with SP defined as follows:

16

derived from the operational semantics of HA

Page 33: Inductive Verification of Hybrid Automata with Strongest ...ishii/pub/06-12_ifm.pdf · Hybrid Automata with Strongest Postcondition Calculus June 12, 2013 @ iFM Daisuke Ishii Tokyo

Example: Water-level Monitor1.Consider

17

SP((xL=on ∧ x1=low), evolve t) ⇒ x1≤max

Page 34: Inductive Verification of Hybrid Automata with Strongest ...ishii/pub/06-12_ifm.pdf · Hybrid Automata with Strongest Postcondition Calculus June 12, 2013 @ iFM Daisuke Ishii Tokyo

Example: Water-level Monitor1.Consider

2.From the definition of SP

17

SP((xL=on ∧ x1=low), evolve t) ⇒ x1≤max

(∃φ (xL=on ∧ φx1(0)=low) ∧

φ(t)=(x1,x2) ∧ (∀t∈[0,t] =FlowxL(φ(t)) ∧ InvxL[φ(t)]))

⇒ x1≤maxdtdφ~

~ ~ ~

Page 35: Inductive Verification of Hybrid Automata with Strongest ...ishii/pub/06-12_ifm.pdf · Hybrid Automata with Strongest Postcondition Calculus June 12, 2013 @ iFM Daisuke Ishii Tokyo

Example: Water-level Monitor1.Consider

2.From the definition of SP

3.We can solve the ODE into a closed form and simplify as

17

SP((xL=on ∧ x1=low), evolve t) ⇒ x1≤max

(∃φ (xL=on ∧ φx1(0)=low) ∧

φ(t)=(x1,x2) ∧ (∀t∈[0,t] =FlowxL(φ(t)) ∧ InvxL[φ(t)]))

⇒ x1≤maxdtdφ~

~ ~ ~

∀t∈[0,t] InvxL[(low + ratein t, x2)]

⇒ low + ratein t ≤ max

~ ~

Page 36: Inductive Verification of Hybrid Automata with Strongest ...ishii/pub/06-12_ifm.pdf · Hybrid Automata with Strongest Postcondition Calculus June 12, 2013 @ iFM Daisuke Ishii Tokyo

Talk Outline

1.Hybrid Automata

2. ImpHA and Strongest Postcondition Calculus

3. Inductive Verification

4.Experimental Results

18

Page 37: Inductive Verification of Hybrid Automata with Strongest ...ishii/pub/06-12_ifm.pdf · Hybrid Automata with Strongest Postcondition Calculus June 12, 2013 @ iFM Daisuke Ishii Tokyo

Inductive Verification

•Encoding safety obligation for all the (infinitely-many) executions of the HA into a bounded number of verification conditions

19

Page 38: Inductive Verification of Hybrid Automata with Strongest ...ishii/pub/06-12_ifm.pdf · Hybrid Automata with Strongest Postcondition Calculus June 12, 2013 @ iFM Daisuke Ishii Tokyo

Inductive Verification

•Encoding safety obligation for all the (infinitely-many) executions of the HA into a bounded number of verification conditions

•Induction strategy-Inspired by deductive program verification technique for handling loops

-Construction of a lasso-shaped structure✴Assume a loop invariant P+

19

Init P+

length-mexecution length-n

execution

Page 39: Inductive Verification of Hybrid Automata with Strongest ...ishii/pub/06-12_ifm.pdf · Hybrid Automata with Strongest Postcondition Calculus June 12, 2013 @ iFM Daisuke Ishii Tokyo

Induction Strategy (Simplest Case)•Theorem 1. Given a predicate P+ such that P+ ⇒ P, the following inference rule is correct

20

HA ⊨ □P

VC0: Init ⇒ P+

VC1: ∀t≥0 SP(P+, evolve t) ⇒ P

VC-1: ∀t≥0 SP(P+, evolve t; trans) ⇒ P+

Page 40: Inductive Verification of Hybrid Automata with Strongest ...ishii/pub/06-12_ifm.pdf · Hybrid Automata with Strongest Postcondition Calculus June 12, 2013 @ iFM Daisuke Ishii Tokyo

Induction Strategy (Simplest Case)•Theorem 1. Given a predicate P+ such that P+ ⇒ P, the following inference rule is correct

•Proof sketch-VC0 checks that all the initial states satisfy P+

-VC-1 verifies that all the two step executions from a state σi that satisfies P+ evolve for a duration ti+1 to a state σi+2 that again satisfies P+

-VC1 ensures that P was not broken during the continuous evolution 20

HA ⊨ □P

VC0: Init ⇒ P+

VC1: ∀t≥0 SP(P+, evolve t) ⇒ P

VC-1: ∀t≥0 SP(P+, evolve t; trans) ⇒ P+

σi → σi+1 → σi+2ti+1 0

Page 41: Inductive Verification of Hybrid Automata with Strongest ...ishii/pub/06-12_ifm.pdf · Hybrid Automata with Strongest Postcondition Calculus June 12, 2013 @ iFM Daisuke Ishii Tokyo

Induction Strategy (Simplest Case)•Theorem 1. Given a predicate P+ such that P+ ⇒ P, the following inference rule is correct

•Proof sketch-VC0 checks that all the initial states satisfy P+

-VC-1 verifies that all the two step executions from a state σi that satisfies P+ evolve for a duration ti+1 to a state σi+2 that again satisfies P+

-VC1 ensures that P was not broken during the continuous evolution 20

HA ⊨ □P

VC0: Init ⇒ P+

VC1: ∀t≥0 SP(P+, evolve t) ⇒ P

VC-1: ∀t≥0 SP(P+, evolve t; trans) ⇒ P+

σi → σi+1 → σi+2ti+1 0P+ P+

Page 42: Inductive Verification of Hybrid Automata with Strongest ...ishii/pub/06-12_ifm.pdf · Hybrid Automata with Strongest Postcondition Calculus June 12, 2013 @ iFM Daisuke Ishii Tokyo

Example: Water-level Monitor

•Verification is possible with the inference rule where the loop invariant is set as

21

P+ ≡ xL=sw_off ⇒ x1=high ∧ xL=sw_on ⇒ x1=low

Page 43: Inductive Verification of Hybrid Automata with Strongest ...ishii/pub/06-12_ifm.pdf · Hybrid Automata with Strongest Postcondition Calculus June 12, 2013 @ iFM Daisuke Ishii Tokyo

Example: Water-level Monitor

•Verification is possible with the inference rule where the loop invariant is set as

•This loop invariant is necessary to verify the safety during the continuous evolution-Example (xL=sw_off):

21

P+ ≡ xL=sw_off ⇒ x1=high ∧ xL=sw_on ⇒ x1=low

~

xL=sw_off ∧ x1 = high

σ

σ’

timet

σ’’

t~

xL=sw_off ∧ x1 = high + ratein t

□min≤x1≤max

~

Page 44: Inductive Verification of Hybrid Automata with Strongest ...ishii/pub/06-12_ifm.pdf · Hybrid Automata with Strongest Postcondition Calculus June 12, 2013 @ iFM Daisuke Ishii Tokyo

Example: Water-level Monitor

22

onx1=rate_inx1≦high

sw_offx1=rate_in & x2=1

x2≦delay

offx1=rate_outx1≦low

sw_onx1=rate_out & x2=1

x2≦delay

x2=delay ⇒ x2:=0

x2=delay ⇒ x2:=0

x1=low ⇒ x2:=0

x1=high ⇒ x2:=0x1:=low ・ ・ ・

・ ・ ・

□min≤x1≤max

Page 45: Inductive Verification of Hybrid Automata with Strongest ...ishii/pub/06-12_ifm.pdf · Hybrid Automata with Strongest Postcondition Calculus June 12, 2013 @ iFM Daisuke Ishii Tokyo

Induction Strategy (Unrolled Case)•Theorem 2. Given a predicate P+ such that P+ ⇒ P, consider the following m+n+2 SPs...

23

SP1 ≡ SP(Init, evolve t1)

SP2 ≡ SP(SP(SP1, trans), evolve t2)

⋮SPm ≡ SP(SP(SPm-1, trans), evolve tm)

SP0 ≡ SP(SPm, trans)

SPm+1 ≡ SP(P+, trans), evolve t1)

SPm+2 ≡ SP(SP(SPm+1, trans), evolve t2)

⋮SPm+n ≡ SP(SP(SPm+n-1, trans), evolve tn)

SP-1 ≡ SP(SPm+n, trans)

Page 46: Inductive Verification of Hybrid Automata with Strongest ...ishii/pub/06-12_ifm.pdf · Hybrid Automata with Strongest Postcondition Calculus June 12, 2013 @ iFM Daisuke Ishii Tokyo

Induction Strategy (Unrolled Case)•Theorem 2 (cont). Then, the following inference rule is correct

24HA ⊨ □P

VC1: ∀t1≥0 SP1 ⇒ P

VC2: ∀t1,t2≥0 SP2 ⇒ P

⋮VCm: ∀t1..tm≥0 SPm ⇒ P

VC0: ∀t1..tm≥0 SP0 ⇒ P+

VCm+1: ∀t1≥0 SPm+1 ⇒ P

⋮VCm+n: ∀t1..tn≥0 SPm+n ⇒ P

VC-1: ∀t1..tn≥0 SP-1 ⇒ P+

Page 47: Inductive Verification of Hybrid Automata with Strongest ...ishii/pub/06-12_ifm.pdf · Hybrid Automata with Strongest Postcondition Calculus June 12, 2013 @ iFM Daisuke Ishii Tokyo

Induction Strategy (Unrolled Case)

•Proof sketch-VC0 checks that all the initial states σ0 reach a state σ2m

that satisfy P+ after m steps

-VC-1 verifies that all the n step executions

from a state σ2m that satisfies P+ reaches a state σ2m+2n that again satisfies P+

-Other VCs i.e. VC1,...,VCm+n ensure that P was not broken before/after a discrete transition and during a continuous evolution

25

σ0 → … → σ2mt1 0

σ2m → … → σ2m+2nt1 0

Page 48: Inductive Verification of Hybrid Automata with Strongest ...ishii/pub/06-12_ifm.pdf · Hybrid Automata with Strongest Postcondition Calculus June 12, 2013 @ iFM Daisuke Ishii Tokyo

Induction Strategy (Unrolled Case)

•Proof sketch-VC0 checks that all the initial states σ0 reach a state σ2m

that satisfy P+ after m steps

-VC-1 verifies that all the n step executions

from a state σ2m that satisfies P+ reaches a state σ2m+2n that again satisfies P+

-Other VCs i.e. VC1,...,VCm+n ensure that P was not broken before/after a discrete transition and during a continuous evolution

25

σ0 → … → σ2mt1 0

σ2m → … → σ2m+2nt1 0

Init P+

Page 49: Inductive Verification of Hybrid Automata with Strongest ...ishii/pub/06-12_ifm.pdf · Hybrid Automata with Strongest Postcondition Calculus June 12, 2013 @ iFM Daisuke Ishii Tokyo

Induction Strategy (Unrolled Case)

•Proof sketch-VC0 checks that all the initial states σ0 reach a state σ2m

that satisfy P+ after m steps

-VC-1 verifies that all the n step executions

from a state σ2m that satisfies P+ reaches a state σ2m+2n that again satisfies P+

-Other VCs i.e. VC1,...,VCm+n ensure that P was not broken before/after a discrete transition and during a continuous evolution

25

σ0 → … → σ2mt1 0

σ2m → … → σ2m+2nt1 0

Init P+

P+ P+

Page 50: Inductive Verification of Hybrid Automata with Strongest ...ishii/pub/06-12_ifm.pdf · Hybrid Automata with Strongest Postcondition Calculus June 12, 2013 @ iFM Daisuke Ishii Tokyo

Example: Water-level Monitor

•Verification is also possible with the inference rule for m=0 and n=2 where the loop invariant is set as

26

time

xL = On

xL = Off

t1 t2

P+ ≡ xL=on ∨ xL=off

xL = On

xL = Off

Page 51: Inductive Verification of Hybrid Automata with Strongest ...ishii/pub/06-12_ifm.pdf · Hybrid Automata with Strongest Postcondition Calculus June 12, 2013 @ iFM Daisuke Ishii Tokyo

Algorithm for Inductive Verification•Following algorithm generates VCs for (m,n)∈[0,mmax]×[1,nmax] and discharges the VCs

27

Input: HA; P ; mmax 2 N�0; nmax 2 N>0

Output: true: HA |= ⇤P ; false: cannot decide ⇤P within mmax + nmax steps1: for m 2 {0, . . . ,mmax}; n 2 {1, · · · , nmax} do2: P

+ := P

3: while P

+ 6⌘ false do4: if ¬8i 2 {0, . . . ,m} Validate(VC

i

) then5: break6: end if7: if 9j 2 {m+ 1, . . . ,m+ n,�1} ¬Validate(VC

j

) then8: P

+ := P

+ ^ Learn(VCj

)9: else

10: return true11: end if12: end while13: end for14: return false

Fig. 4. Algorithm for inductive verification.

Learn computes Q by using a quantifier elimination (QE) method, such as theResolve procedure of Mathematica:

Q := QE(8xs

8t1 . . . ti (SP((P+ ^ x0 = x

s

), s) ) P ))[x0 x

s

].

To simplify the loop invariant, the other local variables in VCi

, i.e., �, t̃, l0, x0v

introduced in the SP calculus in Lemma 3 and t

i

introduced in Theorem 2,should also be removed. Unfortunately, QE with mixed quantifiers and functionquantifiers is a hard problem in general. See Remark 1 and the next section fordetails on how we perform this simplification.

The formula computed for Q is often a large disjunctive formula that isunusable as a loop invariant. For instance, some sub-formulas ofQ describe statesthat are never accepted by the HA. Such sub-formulas are not only useless butmake the verification process expensive. So we strengthen Q according to thefollowing strategies:

– Lemma separation. We split Q at the (top-most) disjunction operators andemploy one (or several) of the resulting sub-formulas.

– Location disabling. When we remove a sub-formula of Q that is related tosome location l, we insert the constraint x

l

6= l. The resulting loop invariantmight be e↵ective when combined with loop unrolling.

5 Implementation

We have implemented the method presented in the previous sections using Math-ematica 8.0.45, which can perform the computations in a fully symbolic manner.

5http://www.wolfram.com/mathematica/

Page 52: Inductive Verification of Hybrid Automata with Strongest ...ishii/pub/06-12_ifm.pdf · Hybrid Automata with Strongest Postcondition Calculus June 12, 2013 @ iFM Daisuke Ishii Tokyo

Algorithm for Inductive Verification•Following algorithm generates VCs for (m,n)∈[0,mmax]×[1,nmax] and discharges the VCs

27

Input: HA; P ; mmax 2 N�0; nmax 2 N>0

Output: true: HA |= ⇤P ; false: cannot decide ⇤P within mmax + nmax steps1: for m 2 {0, . . . ,mmax}; n 2 {1, · · · , nmax} do2: P

+ := P

3: while P

+ 6⌘ false do4: if ¬8i 2 {0, . . . ,m} Validate(VC

i

) then5: break6: end if7: if 9j 2 {m+ 1, . . . ,m+ n,�1} ¬Validate(VC

j

) then8: P

+ := P

+ ^ Learn(VCj

)9: else

10: return true11: end if12: end while13: end for14: return false

Fig. 4. Algorithm for inductive verification.

Learn computes Q by using a quantifier elimination (QE) method, such as theResolve procedure of Mathematica:

Q := QE(8xs

8t1 . . . ti (SP((P+ ^ x0 = x

s

), s) ) P ))[x0 x

s

].

To simplify the loop invariant, the other local variables in VCi

, i.e., �, t̃, l0, x0v

introduced in the SP calculus in Lemma 3 and t

i

introduced in Theorem 2,should also be removed. Unfortunately, QE with mixed quantifiers and functionquantifiers is a hard problem in general. See Remark 1 and the next section fordetails on how we perform this simplification.

The formula computed for Q is often a large disjunctive formula that isunusable as a loop invariant. For instance, some sub-formulas ofQ describe statesthat are never accepted by the HA. Such sub-formulas are not only useless butmake the verification process expensive. So we strengthen Q according to thefollowing strategies:

– Lemma separation. We split Q at the (top-most) disjunction operators andemploy one (or several) of the resulting sub-formulas.

– Location disabling. When we remove a sub-formula of Q that is related tosome location l, we insert the constraint x

l

6= l. The resulting loop invariantmight be e↵ective when combined with loop unrolling.

5 Implementation

We have implemented the method presented in the previous sections using Math-ematica 8.0.45, which can perform the computations in a fully symbolic manner.

5http://www.wolfram.com/mathematica/

initialize P+

loop invariant generation

Page 53: Inductive Verification of Hybrid Automata with Strongest ...ishii/pub/06-12_ifm.pdf · Hybrid Automata with Strongest Postcondition Calculus June 12, 2013 @ iFM Daisuke Ishii Tokyo

Loop Invariant Generation

•When verification ofVCi : ∀t1..ti ≥0 (SP(P+∧s) ⇒ P) fails, we can generate a loop invariant using a quantifier elimination (QE) method

28

QE(∀xs ∀t1..ti VCi)[x0 ← xs]

Page 54: Inductive Verification of Hybrid Automata with Strongest ...ishii/pub/06-12_ifm.pdf · Hybrid Automata with Strongest Postcondition Calculus June 12, 2013 @ iFM Daisuke Ishii Tokyo

Loop Invariant Generation

•When verification ofVCi : ∀t1..ti ≥0 (SP(P+∧s) ⇒ P) fails, we can generate a loop invariant using a quantifier elimination (QE) method

•This process is hard in general-VCi should be simplified by assuming a class of

problems✴Otherwise QE might not succeed

-Generated invariant might be too large.They should be simplified manually✴Two strategies for the simplification

28

QE(∀xs ∀t1..ti VCi)[x0 ← xs]

Page 55: Inductive Verification of Hybrid Automata with Strongest ...ishii/pub/06-12_ifm.pdf · Hybrid Automata with Strongest Postcondition Calculus June 12, 2013 @ iFM Daisuke Ishii Tokyo

Implementation

•We have implemented the verification algorithm using Mathematica (i.e. algebraic formula manipulation system)-ODEs are solved into closed forms with DSolve-Validate is implemented using built-in functions,

FullSimplify, Reduce, and FindInstance-Learn is implemented using a built-in function Resolve

that performs QE

29

Page 56: Inductive Verification of Hybrid Automata with Strongest ...ishii/pub/06-12_ifm.pdf · Hybrid Automata with Strongest Postcondition Calculus June 12, 2013 @ iFM Daisuke Ishii Tokyo

Implementation

•We have implemented the verification algorithm using Mathematica (i.e. algebraic formula manipulation system)-ODEs are solved into closed forms with DSolve-Validate is implemented using built-in functions,

FullSimplify, Reduce, and FindInstance-Learn is implemented using a built-in function Resolve

that performs QE

•Several optimizations-Separation of formulas wrt HA locations-Reutilization of simplification process of sub-formulas

29

Page 57: Inductive Verification of Hybrid Automata with Strongest ...ishii/pub/06-12_ifm.pdf · Hybrid Automata with Strongest Postcondition Calculus June 12, 2013 @ iFM Daisuke Ishii Tokyo

Talk Outline

1.Hybrid Automata

2. ImpHA and Strongest Postcondition Calculus

3. Inductive Verification

4.Experimental Results

30

Page 58: Inductive Verification of Hybrid Automata with Strongest ...ishii/pub/06-12_ifm.pdf · Hybrid Automata with Strongest Postcondition Calculus June 12, 2013 @ iFM Daisuke Ishii Tokyo

Experimental Results

31

Problem #Loc#Var m/n Our

methodMC

toolsKeYma

eraWLM 4/2 0/1 0.85s N/A 1.8s

Gas burner 2/3 4/2 2.22s 0.004s N/A

Temp. ctrl 4/3 1/1 2.82s 0.012s N/A

Bouncing ball 1/2 0/1 0.49s N/A 0.9s

ETCS 2/3 0/1 4.48s N/A 3.1s

Highway 9 10/9 0/2 0.22s 0.22s N/A

Highway 19 20/19 0/2 3.64s N/A N/A

Page 59: Inductive Verification of Hybrid Automata with Strongest ...ishii/pub/06-12_ifm.pdf · Hybrid Automata with Strongest Postcondition Calculus June 12, 2013 @ iFM Daisuke Ishii Tokyo

Comparison with Other Tools

•MC tools-HyTech [Henzinger+ 96] and PHAVer [Frahse 02]-Solve three problems quite efficiently (Ex.2,3,6)-Cannot handle instances with uncertain parameters

(Ex.1,4)-Some scaling issues (Ex.6,7)

•KeYmaera [Platzer+ 08]-Handles various hybrid programs automatically-However, does not succeed on most of programs

translated from HA (Ex.2,3,6,7)✴Models should be annotated manually✴Otherwise, users need to interact with underlying

theorem prover32

Page 60: Inductive Verification of Hybrid Automata with Strongest ...ishii/pub/06-12_ifm.pdf · Hybrid Automata with Strongest Postcondition Calculus June 12, 2013 @ iFM Daisuke Ishii Tokyo

Conclusion

•Automated logical analytic method for a large class of linear and nonlinear HA-Algorithmic verification with SP calculus and limited

derivation rules, i.e., induction and loop unrolling

- Loop invariant generation guided by the response from the decision process

-Promising experimental results with several HA

•Future work-Automation of generation process of efficient loop

invariants-Support for larger class of HA,

e.g., with unsolvable ODEs, parallel composition33