introduction to formal methods - uniroma1.itdegiacom/didattica/...introduction to formal methods 08...

30
Introduction to Formal Methods 08 - Automata-Theoretic LTL Model Checking Roberto Sebastiani - [email protected] Stefano Tonetta - [email protected] A.A. 2008-2009 Last update: February 14, 2009 Roberto Sebastiani, Stefano Tonetta () Introduction to Formal Methods A.A. 2008-2009 Last update: February 14, 2 / 93 Content 1 Automata-Theory Overview Language Containment Automata on Finite Words Automata on Infinite Words Emptiness Checking 2 The Automata-Theoretic Approach to Model Checking Automata-Theoretic LTL Model Checking From Kripke Structures to B¨ uchi Automata From LTL Formulas to B¨ uchi Automata Exponential construction of Bu¨ chi Automata On-the-fly construction of Bu¨ chi Automata Complexity Roberto Sebastiani, Stefano Tonetta () Introduction to Formal Methods A.A. 2008-2009 Last update: February 14, 2 / 93

Upload: others

Post on 08-Jun-2020

4 views

Category:

Documents


3 download

TRANSCRIPT

Page 1: Introduction to Formal Methods - uniroma1.itdegiacom/didattica/...Introduction to Formal Methods 08 - Automata-Theoretic LTL Model Checking Roberto Sebastiani - rseba@disi.unitn.it

Introduction to Formal Methods08 - Automata-Theoretic LTL Model Checking

Roberto Sebastiani - [email protected] Tonetta - [email protected]

A.A. 2008-2009

Last update: February 14, 2009

Roberto Sebastiani, Stefano Tonetta () Introduction to Formal MethodsA.A. 2008-2009 Last update: February 14, 2009 1

/ 93

Content

1 Automata-Theory OverviewLanguage ContainmentAutomata on Finite WordsAutomata on Infinite WordsEmptiness Checking

2 The Automata-Theoretic Approach to Model CheckingAutomata-Theoretic LTL Model CheckingFrom Kripke Structures to Buchi AutomataFrom LTL Formulas to Buchi AutomataExponential construction of Buchi AutomataOn-the-fly construction of Buchi AutomataComplexity

Roberto Sebastiani, Stefano Tonetta () Introduction to Formal MethodsA.A. 2008-2009 Last update: February 14, 2009 2

/ 93

Page 2: Introduction to Formal Methods - uniroma1.itdegiacom/didattica/...Introduction to Formal Methods 08 - Automata-Theoretic LTL Model Checking Roberto Sebastiani - rseba@disi.unitn.it

Content

1 Automata-Theory OverviewLanguage ContainmentAutomata on Finite WordsAutomata on Infinite WordsEmptiness Checking

2 The Automata-Theoretic Approach to Model CheckingAutomata-Theoretic LTL Model CheckingFrom Kripke Structures to Buchi AutomataFrom LTL Formulas to Buchi AutomataExponential construction of Buchi AutomataOn-the-fly construction of Buchi AutomataComplexity

Roberto Sebastiani, Stefano Tonetta () Introduction to Formal MethodsA.A. 2008-2009 Last update: February 14, 2009 3

/ 93

System’s computations

The behaviors (computations) of a system can be seen as sequencesof propositions.

MODULE mainVAR done: Boolean;ASSIGNinit(done):=0;next(done):= case

!done: {0,1};done: done;

esac;

Since the state space is finite, the set of computations can berepresented by a finite automaton.

or

Roberto Sebastiani, Stefano Tonetta () Introduction to Formal MethodsA.A. 2008-2009 Last update: February 14, 2009 5

/ 93

Page 3: Introduction to Formal Methods - uniroma1.itdegiacom/didattica/...Introduction to Formal Methods 08 - Automata-Theoretic LTL Model Checking Roberto Sebastiani - rseba@disi.unitn.it

Correct computations

Some computations are correct and others are not acceptable.

We can build an automaton for the set of all acceptable computations.

Example: eventually, done will be true forever.

Roberto Sebastiani, Stefano Tonetta () Introduction to Formal MethodsA.A. 2008-2009 Last update: February 14, 2009 6

/ 93

Language Containment Problem

Solution to the verification problem=! Check if language of the system automaton is contained in the

language accepted by the property automaton.

The language containment problem is the problem of deciding if alanguage is a subset of another language.

L(A1) " L(A2) #! L(A1) $ L(A2) = {}

To solve the language containment problem, we need to know:

1 how to complement an automaton,

2 how to intersect two automata,

3 how to check the language emptiness of an automaton.

Roberto Sebastiani, Stefano Tonetta () Introduction to Formal MethodsA.A. 2008-2009 Last update: February 14, 2009 7

/ 93

Page 4: Introduction to Formal Methods - uniroma1.itdegiacom/didattica/...Introduction to Formal Methods 08 - Automata-Theoretic LTL Model Checking Roberto Sebastiani - rseba@disi.unitn.it

Content

1 Automata-Theory OverviewLanguage ContainmentAutomata on Finite WordsAutomata on Infinite WordsEmptiness Checking

2 The Automata-Theoretic Approach to Model CheckingAutomata-Theoretic LTL Model CheckingFrom Kripke Structures to Buchi AutomataFrom LTL Formulas to Buchi AutomataExponential construction of Buchi AutomataOn-the-fly construction of Buchi AutomataComplexity

Roberto Sebastiani, Stefano Tonetta () Introduction to Formal MethodsA.A. 2008-2009 Last update: February 14, 2009 8

/ 93

Finite Word Languages

An Alphabet ! is a collection of symbols (letters).E.g. ! = {a, b}.A finite word is a finite sequence of letters. (E.g. aabb.)The set of all finite words is denoted by !!.

A language U is a set of words, i.e. U " !!.

Example: Words over ! = {a, b} with equal number of a’s and b’s.(E.g. aabb or abba.)

Language recognition problem:determine whether a word belongs to a language.

Automata are computational devices able to solve language recognitionproblems.

Roberto Sebastiani, Stefano Tonetta () Introduction to Formal MethodsA.A. 2008-2009 Last update: February 14, 2009 9

/ 93

Page 5: Introduction to Formal Methods - uniroma1.itdegiacom/didattica/...Introduction to Formal Methods 08 - Automata-Theoretic LTL Model Checking Roberto Sebastiani - rseba@disi.unitn.it

Finite State Automata

Basic model of computational systems with finite memory.

Widely applicable

Embedded System Controllers.Languages: Ester-el, Lustre, Verilog.

Synchronous Circuits.

Regular Expression Pattern MatchingGrep, Lex, Emacs.

ProtocolsNetwork ProtocolsArchitecture: Bus, Cache Coherence, Telephony,...

Roberto Sebastiani, Stefano Tonetta () Introduction to Formal MethodsA.A. 2008-2009 Last update: February 14, 2009 10

/ 93

Notation

a, b % ! finite alphabet.u, v ,w % !! finite words.

! empty word.u.v catenation.ui = u.u. .u repeated i-times.

U,V " !! Finite word languages.

Roberto Sebastiani, Stefano Tonetta () Introduction to Formal MethodsA.A. 2008-2009 Last update: February 14, 2009 11

/ 93

Page 6: Introduction to Formal Methods - uniroma1.itdegiacom/didattica/...Introduction to Formal Methods 08 - Automata-Theoretic LTL Model Checking Roberto Sebastiani - rseba@disi.unitn.it

FSA Definition

Nondeterministic Finite State Automaton (NFA):NFA is (Q,!, ", I ,F )

Q Finite set of states.! is a finite alphabetI " Q set of initial states.F " Q set of final states." " Q & !& Q transition relation (edges).

We use qa'( q" to denote (q, a, q") % ".

Deterministic Finite State Automaton (DFA):

DFA has " : Q & ! ( Q, a total function.Single initial state I = {q0}.

Roberto Sebastiani, Stefano Tonetta () Introduction to Formal MethodsA.A. 2008-2009 Last update: February 14, 2009 12

/ 93

Regular Languages

A run of NFA A on u = a0, a1, . . . , an#1 is a finite sequence of states

q0, q1, . . . , qn s.t. q0 % I and qiai'( qi+1 for 0 ) i < n.

An accepting run is one where the last state qn % F .

The language accepted by AL(A) = {u % !! | A has an accepting run on u}The languages accepted by a NFA are called regular languages.

Roberto Sebastiani, Stefano Tonetta () Introduction to Formal MethodsA.A. 2008-2009 Last update: February 14, 2009 13

/ 93

Page 7: Introduction to Formal Methods - uniroma1.itdegiacom/didattica/...Introduction to Formal Methods 08 - Automata-Theoretic LTL Model Checking Roberto Sebastiani - rseba@disi.unitn.it

Finite State Automata

Example: DFA A1 over ! = {a, b}.Recognizes words which do not end in b.

NFA A2. Recognizes words which end in b.

Roberto Sebastiani, Stefano Tonetta () Introduction to Formal MethodsA.A. 2008-2009 Last update: February 14, 2009 14

/ 93

Determinisation

Theorem (determinisation) Given a NFA A we can construct a DFA A" s.t.L(A) = L(A"). Size |A"| = 2O(|A|).

Each state of A" corresponds to a set {s1, ..., sj} of states in A(Q " " 2Q), with the intended meaning that :

A! is in the state {s1, .., sj} if A is in one of the states s1, ..., sj

The deterministic transition relation "" : 2Q & ! *'( 2Q is{s} a'( {si | s

a'( si}{s1, ..., sj , ..., sn}

a'(!n

j=1{si | sja'( si}

The (unique) initial state is I " =def {si | si % I}The set of final states F " is such that{s1, ..., sn} % F " i" si % F for some i % {1, ..., n}

Roberto Sebastiani, Stefano Tonetta () Introduction to Formal MethodsA.A. 2008-2009 Last update: February 14, 2009 15

/ 93

Page 8: Introduction to Formal Methods - uniroma1.itdegiacom/didattica/...Introduction to Formal Methods 08 - Automata-Theoretic LTL Model Checking Roberto Sebastiani - rseba@disi.unitn.it

Determinisation [cont.]

NFA A2: Words which end in b.

A2 can be determinised into the automaton DA2 below.States = 2Q .

There are NFAs of size n for which the size of the minimum sized DFAmust have size O(2n).

Roberto Sebastiani, Stefano Tonetta () Introduction to Formal MethodsA.A. 2008-2009 Last update: February 14, 2009 16

/ 93

Closure Properties

Theorem (Boolean closure) Given NFA A1,A2 over ! we can constructNFA A over ! s.t.

L(A) = L(A1) (Complement). |A| = 2O(|A1|).

L(A) = L(A1) + L(A2) (union). |A| = |A1| + |A2|.L(A) = L(A1) $ L(A2) (intersection). |A| = |A1| · |A2|.

Roberto Sebastiani, Stefano Tonetta () Introduction to Formal MethodsA.A. 2008-2009 Last update: February 14, 2009 17

/ 93

Page 9: Introduction to Formal Methods - uniroma1.itdegiacom/didattica/...Introduction to Formal Methods 08 - Automata-Theoretic LTL Model Checking Roberto Sebastiani - rseba@disi.unitn.it

Complementation of a NFA

A NFA A = (Q,!, ", I ,F ) is complemented by:

determinizing it into a DFA A" = (Q ",!", "", I ",F ")

complementing it: A" = (Q ",!", "", I ",F ")

|A"| = |A"| = 2O(|A|)

Roberto Sebastiani, Stefano Tonetta () Introduction to Formal MethodsA.A. 2008-2009 Last update: February 14, 2009 18

/ 93

Union of two NFAs

Two NFAs A1 = (Q1,!1, "1, I1,F1), A2 = (Q2,!2, "2, I2,F2),A = A1 + A2 = (Q,!, ", I ,F ) is defined as follows

Q := Q1 + Q2, I := I1 + I2, F := F1 + F2

R(s, s ") :=

"R1(s, s ") if s % Q1

R2(s, s ") if s % Q2

=!A is an automaton which just runs nondeterministically either A1

or A2

L(A) = L(A1) + L(A2)

|A| = |A1| + |A2|

Roberto Sebastiani, Stefano Tonetta () Introduction to Formal MethodsA.A. 2008-2009 Last update: February 14, 2009 19

/ 93

Page 10: Introduction to Formal Methods - uniroma1.itdegiacom/didattica/...Introduction to Formal Methods 08 - Automata-Theoretic LTL Model Checking Roberto Sebastiani - rseba@disi.unitn.it

Synchronous Product Construction

Let A1 = (Q1,!, "1, I1,F1) and A2 = (Q2,!, "2, I2,F2). Then,A1 & A2 = (Q,!, ", I ,F ) where

Q = Q1 & Q2. I = I1 & I2.F = F1 & F2.

< p, q >a'(< p", q" > i" p

a'( p" and qa'( q".

Theorem L(A1 & A2) = L(A1) $ L(A2).

Roberto Sebastiani, Stefano Tonetta () Introduction to Formal MethodsA.A. 2008-2009 Last update: February 14, 2009 20

/ 93

Example

A1 recognizes words with an even number of b’s.

A2 recognizes words with a number of a’s multiple of 3.

The Product Automaton A1 & A2 with F = {s0, t0}.

Roberto Sebastiani, Stefano Tonetta () Introduction to Formal MethodsA.A. 2008-2009 Last update: February 14, 2009 21

/ 93

Page 11: Introduction to Formal Methods - uniroma1.itdegiacom/didattica/...Introduction to Formal Methods 08 - Automata-Theoretic LTL Model Checking Roberto Sebastiani - rseba@disi.unitn.it

Regular Expressions

Syntax: , | ! | a | reg1.reg2 | reg1|reg2 | reg!.

Every regular expression reg denotes a language L(reg).

Example: a!.(b|bb).a!. The words with either 1 b or 2 consecutive b’s.

Theorem: For every regular expression reg we can construct a languageequivalent NFA of size O(|reg |).

Theorem: For every DFA A we can construct a language equivalent regularexpression reg(A).

Roberto Sebastiani, Stefano Tonetta () Introduction to Formal MethodsA.A. 2008-2009 Last update: February 14, 2009 22

/ 93

Content

1 Automata-Theory OverviewLanguage ContainmentAutomata on Finite WordsAutomata on Infinite WordsEmptiness Checking

2 The Automata-Theoretic Approach to Model CheckingAutomata-Theoretic LTL Model CheckingFrom Kripke Structures to Buchi AutomataFrom LTL Formulas to Buchi AutomataExponential construction of Buchi AutomataOn-the-fly construction of Buchi AutomataComplexity

Roberto Sebastiani, Stefano Tonetta () Introduction to Formal MethodsA.A. 2008-2009 Last update: February 14, 2009 23

/ 93

Page 12: Introduction to Formal Methods - uniroma1.itdegiacom/didattica/...Introduction to Formal Methods 08 - Automata-Theoretic LTL Model Checking Roberto Sebastiani - rseba@disi.unitn.it

Infinite Word Languages

Modeling infinite computations of reactive systems.

An #-word $ over ! is an infinite sequencea0, a1, a2 . . ..

Formally, $ : N ( !.The set of all infinite words is denoted by !!.

A #-language L is collection of #-words, i.e. L " !!.

Example All words over {a, b} with infinitely many a’s.

Notationomega words $, %, & % !!.omega-languages L, L1 " !!

For u % !+, let u! = u.u.u . . .

Roberto Sebastiani, Stefano Tonetta () Introduction to Formal MethodsA.A. 2008-2009 Last update: February 14, 2009 24

/ 93

Omega-Automata

We consider automaton running over infinite words.

Let $ = aabbbb . . .. There are several possible runs.Run '1 = s1, s1, s1, s1, s2, s2 . . .Run '2 = s1, s1, s1, s1, s1, s1 . . .Acceptance Conditions Buchi, (Muller, Rabin, Street).Acceptance is based on states occurring infinitely oftenNotation Let ' % Q!. Then,

Inf (') = {s % Q | -$i % N. '(i) = s}.(The set of states occurring infinitely many times in '.)

Roberto Sebastiani, Stefano Tonetta () Introduction to Formal MethodsA.A. 2008-2009 Last update: February 14, 2009 25

/ 93

Page 13: Introduction to Formal Methods - uniroma1.itdegiacom/didattica/...Introduction to Formal Methods 08 - Automata-Theoretic LTL Model Checking Roberto Sebastiani - rseba@disi.unitn.it

Buchi Automata

Nondeterministic Buchi AutomatonA = (Q,!, ", I ,F ), where F " Q is the set of accepting states.

A run ' of A on omega word $ is an infinite sequence' = qo , q1, q2, . . . s.t. q0 % I and qi

ai'( qi+1 for 0 ) i .

The run ' is accepting if

Inf (') $ F .= ,.The language accepted by AL(A) = {$ % !! | A has an accepting run on $}

Roberto Sebastiani, Stefano Tonetta () Introduction to Formal MethodsA.A. 2008-2009 Last update: February 14, 2009 26

/ 93

Buchi Automaton: Example

Let ! = {a, b}.Let a Deterministic Buchi Automaton (DBA) A1 be

With F = {s1} the automaton recognizes words with infinitely manya’s.

With F = {s2} the automaton recognizes words with infinitely manyb’s.

Roberto Sebastiani, Stefano Tonetta () Introduction to Formal MethodsA.A. 2008-2009 Last update: February 14, 2009 27

/ 93

Page 14: Introduction to Formal Methods - uniroma1.itdegiacom/didattica/...Introduction to Formal Methods 08 - Automata-Theoretic LTL Model Checking Roberto Sebastiani - rseba@disi.unitn.it

Buchi Automaton: Example (2)

Let a Nondeterministic Buchi Automaton (NBA) A2 be

With F = {s2}, automaton A2 recognizes words with finitely many a.Thus, L(A2) = L(A1).

Roberto Sebastiani, Stefano Tonetta () Introduction to Formal MethodsA.A. 2008-2009 Last update: February 14, 2009 28

/ 93

Deterministic vs. Nondeterministic Buchi Automata

Theorem DBAs are strictly less powerful than NBAs.

The subset construction does not work: let DA2 be

DA2 is not equivalent to A2

(e.g., it recognizes (b.a)!)

There is no DBA equivalent to A2

Roberto Sebastiani, Stefano Tonetta () Introduction to Formal MethodsA.A. 2008-2009 Last update: February 14, 2009 29

/ 93

Page 15: Introduction to Formal Methods - uniroma1.itdegiacom/didattica/...Introduction to Formal Methods 08 - Automata-Theoretic LTL Model Checking Roberto Sebastiani - rseba@disi.unitn.it

Closure Properties

Theorem (union, intersection)For the NBAs A1,A2 we can construct– the NBA A s.t. L(A) = L(A1) + L(A2). |A| = |A1| + |A2|– the NBA A s.t. L(A) = L(A1) $ L(A2). |A| = |A1| · |A2| · 2.

Roberto Sebastiani, Stefano Tonetta () Introduction to Formal MethodsA.A. 2008-2009 Last update: February 14, 2009 30

/ 93

Union of two NBAs

Two NBAs A1 = (Q1,!1, "1, I1,F1), A2 = (Q2,!2, "2, I2,F2),A = A1 + A2 = (Q,!, ", I ,F ) is defined as follows

Q := Q1 + Q2, I := I1 + I2, F := F1 + F2

R(s, s ") :=

"R1(s, s ") if s % Q1

R2(s, s ") if s % Q2

=!A is an automaton which just runs nondeterministically either A1

or A2

L(A) = L(A1) + L(A2)

|A| = |A1| + |A2|(same construction as with ordinary automata)

Roberto Sebastiani, Stefano Tonetta () Introduction to Formal MethodsA.A. 2008-2009 Last update: February 14, 2009 31

/ 93

Page 16: Introduction to Formal Methods - uniroma1.itdegiacom/didattica/...Introduction to Formal Methods 08 - Automata-Theoretic LTL Model Checking Roberto Sebastiani - rseba@disi.unitn.it

Synchronous Product of NBAs

Let A1 = (Q1,!, "1, I1,F1) and A2 = (Q2,!, "2, I2,F2).Then, A1 & A2 = (Q,!, ", I ,F ), where

Q = Q1 & Q2 & {1, 2}.I = I1 & I2 & {1}.F = F1 & Q2 & {1}.

< p, q, 1 >a'(< p", q", 1 > i" p

a'( p" and qa'( q" and p .% F1.

< p, q, 1 >a'(< p", q", 2 > i" p

a'( p" and qa'( q" and p % F1.

< p, q, 2 >a'(< p", q", 2 > i" p

a'( p" and qa'( q" and q .% F2.

< p, q, 2 >a'(< p", q", 1 > i" p

a'( p" and qa'( q" and q % F2.

Theorem L(A1 & A2) = L(A1) $ L(A2).

Roberto Sebastiani, Stefano Tonetta () Introduction to Formal MethodsA.A. 2008-2009 Last update: February 14, 2009 32

/ 93

Product of NBAs: Intuition

The automaton remembers two tracks, one for each source NBA, andit points to one of the two tracks

As soon as it goes through an accepting state of the current track, itswitches to the other track=!to visit infinitely often a state in F (i.e., F1), it must visitinfinitely often some state also in F2

Important subcase: If F2 = Q2, thenQ = Q1 & Q2.I = I1 & I2.F = F1 & Q2.

Roberto Sebastiani, Stefano Tonetta () Introduction to Formal MethodsA.A. 2008-2009 Last update: February 14, 2009 33

/ 93

Page 17: Introduction to Formal Methods - uniroma1.itdegiacom/didattica/...Introduction to Formal Methods 08 - Automata-Theoretic LTL Model Checking Roberto Sebastiani - rseba@disi.unitn.it

Product of NBAs: Example

Roberto Sebastiani, Stefano Tonetta () Introduction to Formal MethodsA.A. 2008-2009 Last update: February 14, 2009 34

/ 93

Closure Properties (2)

Theorem (complementation)For the NBA A1 we can construct an NBA A2 such that L(A2) = L(A1).|A2| = O(2|A1|·log(|A1|)).

Method: (hint)(1) convert a Buchi automaton into a Non-Deterministic Rabin automaton.(2) determinize and Complement the Rabin automaton(3) convert the Rabin automaton into a Buchi automaton

Roberto Sebastiani, Stefano Tonetta () Introduction to Formal MethodsA.A. 2008-2009 Last update: February 14, 2009 35

/ 93

Page 18: Introduction to Formal Methods - uniroma1.itdegiacom/didattica/...Introduction to Formal Methods 08 - Automata-Theoretic LTL Model Checking Roberto Sebastiani - rseba@disi.unitn.it

Omega Regular Expressions

A language is called #-regular if it has the form +ni=1 Ui .(Vi )! where

Ui ,Vi are regular languages.Theorem A language L is #-regular i" it is NBA-recognizable.

Roberto Sebastiani, Stefano Tonetta () Introduction to Formal MethodsA.A. 2008-2009 Last update: February 14, 2009 38

/ 93

Content

1 Automata-Theory OverviewLanguage ContainmentAutomata on Finite WordsAutomata on Infinite WordsEmptiness Checking

2 The Automata-Theoretic Approach to Model CheckingAutomata-Theoretic LTL Model CheckingFrom Kripke Structures to Buchi AutomataFrom LTL Formulas to Buchi AutomataExponential construction of Buchi AutomataOn-the-fly construction of Buchi AutomataComplexity

Roberto Sebastiani, Stefano Tonetta () Introduction to Formal MethodsA.A. 2008-2009 Last update: February 14, 2009 39

/ 93

Page 19: Introduction to Formal Methods - uniroma1.itdegiacom/didattica/...Introduction to Formal Methods 08 - Automata-Theoretic LTL Model Checking Roberto Sebastiani - rseba@disi.unitn.it

!"#$%&'#$(()"*)!+,),-."%/./)•! 01$)!"!#$%&!#''(&2"34$%)*"2)/#)/-."%/."#)5().")6$756$)81$.1$2).1$2$)5()/.)4$/(.)"#$)

8"26)*"2)81571).1$2$)5()/#)/77$&'#9)2-#:)

•! +"2)!+,);5:$:<)(./#6/26)#"#6$.$2%5#5('7)=#5.$)/-."%/./><)#"#$%&'#$(()/49"25.1%()/2$)3/($6)"#)!"#$%#&'(')*+

•! ?#)@/./4"9AB2"4"9)#"./'"#C)

nonempty :- initial(X),cn(X,Y),final(Y).

cn(X,Y) :- r(X,A,Y). cn(X,Y) :- r(X,A,Z),cn(Z,Y).

81$2$)initial(X))6$#".$().1/.)X 5()/#)5#5'/4)(./.$D))final(X) 6$#".$().1/.)X 5()/)=#/4)(./.$D)r(X,A,Y))6$#".$().1/.)/).2/#(5'"#)*2"%)X).")Y)2$/65#9)AD)/#6)cn(.,.) 5())%"+)!#,-'./"+$(0-1!"+"*)r(X,A,Y))&2"E$7.$6)"#)X<Y:

!"'7$).1/.)cn(.,.)5()#".)$F&2$((534$)5#)+GH:)

•! I$/71/3545.J)5()/)8$44KL#"8#)&2"34$%)"#)92/&1(<)5.()7"%&4$F5.J)5()!HGMNB,OPK7"%&4$.$:)!)

2%34)!"#$%&'#$(()*"+)!,-).)/())*+,-./0101"%&2$3$4)

B2/7'7/4)/49"25.1%()1/Q$)/)(',"#!+7"(.:)

!"#$%&'#$(()"*)RS715),-."%/./)•! +"2)RS715)/-."%/./<)#"#$%&'#$(()/49"25.1%()/2$)3/($6)"#)5#'!+!"#$%#&'(')*+

•! ?#)@/./4"9AB2"4"9)#"./'"#C)

nonempty :- initial(X),cn(X,Y),final(Y),cn(Y,Y).

cn(X,Y) :- r(X,A,Y). cn(X,Y) :- r(X,A,Z),cn(Z,Y).

81$2$<)/()3$*"2$<)initial(X))6$#".$().1/.)X 5()/#)5#5'/4)(./.$D))final(X) 6$#".$().1/.)X 5()/)=#/4)(./.$D)r(X,A,Y))6$#".$().1/.)/).2/#(5'"#)*2"%)X).")Y)2$/65#9)AD)/#6)cn(.,.) 5())%"+)!#,-'./"+$(0-1!"+"*)r(X,A,Y))&2"E$7.$6)"#)X<Y:

•! +/52)2$/71/3545.J)/%"-#.().").8")($&/2/.$)2$/71/3545.J)&2"34$%(C);T>)2$/71)/)=#/4)(./.$)*2"%).1$)5#5'/4)(./.$<);U>)*2"%).1/.)=#/4)(./.$)2$/71)5.($4*).12"-91)/)4""&:)

•! +/52)2$/71/3545.J)1/().1$)(/%$)7"%&4$F5.J)/()2$/71/3545.JC))!HGMNB,OPK7"%&4$.$:)!)

2%34)!"#$%&'#$(()*"+)5617/).83"%.3.)/())*+,-./0101"%&2$3$4)

B2/7'7/4)/49"25.1%()1/Q$)/)(',"#!+7"(.:)

Page 20: Introduction to Formal Methods - uniroma1.itdegiacom/didattica/...Introduction to Formal Methods 08 - Automata-Theoretic LTL Model Checking Roberto Sebastiani - rseba@disi.unitn.it

NFA emptiness checking

Equivalent of finding a final state reachable from an initial state.

It can be solved with a DFS or a BFS.

A DFS finds a counterexample on the fly (it is stored in the stack ofthe procedure).

A BFS finds a final state reachable with a shortest counterexample,but it requires a further backward search to reproduce the path.

Complexity: O(n).

Henceafter, assume w.l.o.g. that there is only one initial state.

Roberto Sebastiani, Stefano Tonetta () Introduction to Formal MethodsA.A. 2008-2009 Last update: February 14, 2009 41

/ 93

NBA emptiness checking

Equivalent of finding an accepting cycle reachable from an initialstate.

A naive algorithm:a DFS finds the final states f reachable from an initial state;for each f , a DFS finds if there exists a loop.Complexity: O(n2).

SCC-based algorithm:the Tarjan’s algorithm uses a DFS to finds the SCCs of a graph inlinear time;another DFS finds if a non-trivial final SCC is reachable from an initialstate.Complexity: O(n).It stores too much information and does not find directly acounterexample.

Roberto Sebastiani, Stefano Tonetta () Introduction to Formal MethodsA.A. 2008-2009 Last update: February 14, 2009 45

/ 93

Page 21: Introduction to Formal Methods - uniroma1.itdegiacom/didattica/...Introduction to Formal Methods 08 - Automata-Theoretic LTL Model Checking Roberto Sebastiani - rseba@disi.unitn.it

Content

1 Automata-Theory OverviewLanguage ContainmentAutomata on Finite WordsAutomata on Infinite WordsEmptiness Checking

2 The Automata-Theoretic Approach to Model CheckingAutomata-Theoretic LTL Model CheckingFrom Kripke Structures to Buchi AutomataFrom LTL Formulas to Buchi AutomataExponential construction of Buchi AutomataOn-the-fly construction of Buchi AutomataComplexity

Roberto Sebastiani, Stefano Tonetta () Introduction to Formal MethodsA.A. 2008-2009 Last update: February 14, 2009 53

/ 93

Automata-Theoretic LTL Model Checking

M |= A( (CTL!)

#! M |= ( (LTL)

#! L(M) " L(()

#! L(M) $ L(() = {}#! L(AM) $ L(A¬") = {}#! L(AM & A¬") = {}

AM is a Buchi Automaton equivalent to M (which represents all andonly the executions of M)

A¬" is a Buchi Automaton which represents all and only the pathsthat satisfy ¬( (do not satisfy ()

=! AM & A¬" represents all and only the paths appearing in M and notin (.

Roberto Sebastiani, Stefano Tonetta () Introduction to Formal MethodsA.A. 2008-2009 Last update: February 14, 2009 54

/ 93

Page 22: Introduction to Formal Methods - uniroma1.itdegiacom/didattica/...Introduction to Formal Methods 08 - Automata-Theoretic LTL Model Checking Roberto Sebastiani - rseba@disi.unitn.it

Automata-Theoretic LTL M.C. (dual version)

M |= E)

#! M .|= A¬)

#! ...

#! L(AM & A#) .= {}AM is a Buchi Automaton equivalent to M (which represents all andonly the executions of M)

A# is a Buchi Automaton which represents all and only the paths thatsatisfy )

=! AM & A# represents all and only the paths appearing in both AM andA#.

Roberto Sebastiani, Stefano Tonetta () Introduction to Formal MethodsA.A. 2008-2009 Last update: February 14, 2009 55

/ 93

Automata-Theoretic LTL Model Checking

Four steps:

1 Compute AM

2 Compute A#

3 Compute the product AM & A#

4 Check the emptiness of L(AM & A#)

Roberto Sebastiani, Stefano Tonetta () Introduction to Formal MethodsA.A. 2008-2009 Last update: February 14, 2009 56

/ 93

Page 23: Introduction to Formal Methods - uniroma1.itdegiacom/didattica/...Introduction to Formal Methods 08 - Automata-Theoretic LTL Model Checking Roberto Sebastiani - rseba@disi.unitn.it

Content

1 Automata-Theory OverviewLanguage ContainmentAutomata on Finite WordsAutomata on Infinite WordsEmptiness Checking

2 The Automata-Theoretic Approach to Model CheckingAutomata-Theoretic LTL Model CheckingFrom Kripke Structures to Buchi AutomataFrom LTL Formulas to Buchi AutomataExponential construction of Buchi AutomataOn-the-fly construction of Buchi AutomataComplexity

Roberto Sebastiani, Stefano Tonetta () Introduction to Formal MethodsA.A. 2008-2009 Last update: February 14, 2009 57

/ 93

Computing an NBA AM from a Kripke Structure M

Transforming a K.S. M = /S ,S0,R, L,AP0 into an NBAAM = /Q,!, ", I ,F 0 s.t.:

States: Q := S + {init}, init being a new initial stateAlphabet: ! := 2AP

Initial State: I := {init}Accepting States: F := Q = S + {init}Transitions:

" : qa'( q! i" (q, q!) % R and L(q!) = a

inita'( q i" q % S0 and L(q) = a

L(AM) = L(M)

|AM | = |M| + 1

Roberto Sebastiani, Stefano Tonetta () Introduction to Formal MethodsA.A. 2008-2009 Last update: February 14, 2009 58

/ 93

Page 24: Introduction to Formal Methods - uniroma1.itdegiacom/didattica/...Introduction to Formal Methods 08 - Automata-Theoretic LTL Model Checking Roberto Sebastiani - rseba@disi.unitn.it

Computing a NBA AM from a Kripke Structure M :Example

{p,q}

{p,q}

{p,q}

Kripke Structure Buechi Auromaton

{p,q} {p}

{q}

{p,!q}

{p,!q}

{!p,q}

=!Substantially, add one initial state, move labels from states toincoming edges, set all states as accepting states

Roberto Sebastiani, Stefano Tonetta () Introduction to Formal MethodsA.A. 2008-2009 Last update: February 14, 2009 59

/ 93

Labels on Kripke Structures and BA’s - Remark

Note that the labels of a Buchi Automaton are di"erent from the labels ofa Kripke Structure. Also graphically, they are interpreted di"erently:

p

in a Kripke Structure, it means that p is true and all otherpropositions are false;

in a Buchi Automaton, it means that p is true and all otherpropositions are uncertain (they can be either true or false).

Roberto Sebastiani, Stefano Tonetta () Introduction to Formal MethodsA.A. 2008-2009 Last update: February 14, 2009 60

/ 93

Page 25: Introduction to Formal Methods - uniroma1.itdegiacom/didattica/...Introduction to Formal Methods 08 - Automata-Theoretic LTL Model Checking Roberto Sebastiani - rseba@disi.unitn.it

Content

1 Automata-Theory OverviewLanguage ContainmentAutomata on Finite WordsAutomata on Infinite WordsEmptiness Checking

2 The Automata-Theoretic Approach to Model CheckingAutomata-Theoretic LTL Model CheckingFrom Kripke Structures to Buchi AutomataFrom LTL Formulas to Buchi AutomataExponential construction of Buchi AutomataOn-the-fly construction of Buchi AutomataComplexity

Roberto Sebastiani, Stefano Tonetta () Introduction to Formal MethodsA.A. 2008-2009 Last update: February 14, 2009 63

/ 93

Translation problem

ProblemGiven an LTL formula *, find a Buchi Automaton that accepts the samelanguage of *.

It is a fundamental problem in LTL model checking (in other words,every model checking algorithm that verifies the correctness of anLTL formula translates it in some sort of finite-state machine).

We will translate LTL in a (equivalent) variant of Buchi Automatacalled Labeled Generalized Buchi Automata (LGBA).

Roberto Sebastiani, Stefano Tonetta () Introduction to Formal MethodsA.A. 2008-2009 Last update: February 14, 2009 64

/ 93

Page 26: Introduction to Formal Methods - uniroma1.itdegiacom/didattica/...Introduction to Formal Methods 08 - Automata-Theoretic LTL Model Checking Roberto Sebastiani - rseba@disi.unitn.it

!"#$%&#'($)*"(+),!,)-()./012)34-(+#-#5)67#+8&6%)

•! !9))

L :)-"46;)9)-"46<))

•! =)!)9)

L :)=;)9)-"46<))

•! "9)

L :)9<))

•! =)!)##9)

L :)=;)-"46)-"46)9)-"46<))

-"46)

9)

-"46)

=)

9)

-"46)

9)

$(-)9)

-"46) 9)

(884"6)

=)

9)

-"46)

-"46)-"46)

•! ">9)?@)!=A)L :)>$(-)9;)9)-"46)=)-"46A<)B)

))))))>$(-)9;)9)-"46)=)-"46A;)$(-)9<))

•! "!9))

L :)>-"46;9A<))

•! !"9))L :)-"46;9<))

!"#$%&#'($)*"(+),!,)-()./012)34-(+#-#5)67#+8&6%)

-"46)

9)9)

9)9)

$(-)9)

$(-)9)

9)-"46)$(-)9)

=)

Page 27: Introduction to Formal Methods - uniroma1.itdegiacom/didattica/...Introduction to Formal Methods 08 - Automata-Theoretic LTL Model Checking Roberto Sebastiani - rseba@disi.unitn.it

Content

1 Automata-Theory OverviewLanguage ContainmentAutomata on Finite WordsAutomata on Infinite WordsEmptiness Checking

2 The Automata-Theoretic Approach to Model CheckingAutomata-Theoretic LTL Model CheckingFrom Kripke Structures to Buchi AutomataFrom LTL Formulas to Buchi AutomataExponential construction of Buchi AutomataOn-the-fly construction of Buchi AutomataComplexity

Roberto Sebastiani, Stefano Tonetta () Introduction to Formal MethodsA.A. 2008-2009 Last update: February 14, 2009 91

/ 93

Automata-Theoretic LTL Model Checking: complexity

Four steps:

1 Compute AM :

2 Compute A#:

3 Compute the product AM & A#:

4 Check the emptiness of L(AM & A#):

Roberto Sebastiani, Stefano Tonetta () Introduction to Formal MethodsA.A. 2008-2009 Last update: February 14, 2009 92

/ 93

Page 28: Introduction to Formal Methods - uniroma1.itdegiacom/didattica/...Introduction to Formal Methods 08 - Automata-Theoretic LTL Model Checking Roberto Sebastiani - rseba@disi.unitn.it

Automata-Theoretic LTL Model Checking: complexity

Four steps:

1 Compute AM : |AM | = O(|M|)2 Compute A#:

3 Compute the product AM & A#:

4 Check the emptiness of L(AM & A#):

Roberto Sebastiani, Stefano Tonetta () Introduction to Formal MethodsA.A. 2008-2009 Last update: February 14, 2009 92

/ 93

Automata-Theoretic LTL Model Checking: complexity

Four steps:

1 Compute AM : |AM | = O(|M|)2 Compute A#: |A#| = O(2|#|)

3 Compute the product AM & A#:

4 Check the emptiness of L(AM & A#):

Roberto Sebastiani, Stefano Tonetta () Introduction to Formal MethodsA.A. 2008-2009 Last update: February 14, 2009 92

/ 93

Page 29: Introduction to Formal Methods - uniroma1.itdegiacom/didattica/...Introduction to Formal Methods 08 - Automata-Theoretic LTL Model Checking Roberto Sebastiani - rseba@disi.unitn.it

Automata-Theoretic LTL Model Checking: complexity

Four steps:

1 Compute AM : |AM | = O(|M|)2 Compute A#: |A#| = O(2|#|)

3 Compute the product AM & A#:|AM & A#| = |AM | · |A#| = O(|M| · 2|#|)

4 Check the emptiness of L(AM & A#):

Roberto Sebastiani, Stefano Tonetta () Introduction to Formal MethodsA.A. 2008-2009 Last update: February 14, 2009 92

/ 93

Automata-Theoretic LTL Model Checking: complexity

Four steps:

1 Compute AM : |AM | = O(|M|)2 Compute A#: |A#| = O(2|#|)

3 Compute the product AM & A#:|AM & A#| = |AM | · |A#| = O(|M| · 2|#|)

4 Check the emptiness of L(AM & A#): O(|AM & A#|) = O(|M| · 2|#|)

=!the complexity of LTL M.C. grows linearly wrt. the size of the modelM and exponentially wrt. the size of the property )

Roberto Sebastiani, Stefano Tonetta () Introduction to Formal MethodsA.A. 2008-2009 Last update: February 14, 2009 92

/ 93

Page 30: Introduction to Formal Methods - uniroma1.itdegiacom/didattica/...Introduction to Formal Methods 08 - Automata-Theoretic LTL Model Checking Roberto Sebastiani - rseba@disi.unitn.it

Final Remarks

Buchi automata are in general more expressive than LTL!=!Some tools (e.g., Spin, ObjectGEODE) allow specifications to beexpressed directly as NBAs=!complementation of NBA important!

for every LTL formula, there are many possible equivalent NBAs=!lots of research for finding “the best” conversion algorithm

performing the product and checking emptiness very relevant=!lots of techniques developed (e.g., partial order reduction)=!lots on ongoing research

Roberto Sebastiani, Stefano Tonetta () Introduction to Formal MethodsA.A. 2008-2009 Last update: February 14, 2009 93

/ 93