Post on 06-Nov-2021
CTL Model Checking
Sayan MitraVerifying cyberphysical systems
mitras@illinois.edu
Verification thus far: Invariants and safety
Given a hybrid automaton ๐ = โจ๐, ฮ, ๐ด,๐, ๐ปโฉ and a candidate invariant ๐ผ โ ๐ฃ๐๐(๐) we can check whether ๐ผ is an inductive invariant.
In which case ๐ ๐๐๐โ๐ ฮ โ ๐ผ
Given an unsafe set ๐ โ ๐ฃ๐๐(๐) we can check whether ๐ผ โฉ ๐ = โ to infer that ๐ ๐๐๐โ๐ ฮ โฉ ๐ = โ
Lecture Slides by Sayan Mitra mitras@illinois.edu
What about more general types of requirements, e.g.,
โEventually the light turns red and prior to that the orange light blinksโ
โAfter failures, eventually there is just one token in the systemโ
How to express and verify such properties?
Lecture Slides by Sayan Mitra mitras@illinois.edu
Outline
โข Temporal logicsโข Computational Tree Logic (CTL)
โข CTL model checkingโข Setupโข CTL syntax and semanticsโข Model checking algorithmsโข Example
โข References: Model Checking, Second Edition, by Edmund M. Clarke, Jr., Orna Grumberg, Daniel Kroening, Doron Peled and Helmut Veith
โข Principles of Model Checking, by Christel Baier and Joost-Pieter Katoen
Lecture Slides by Sayan Mitra mitras@illinois.edu
Introduction to temporal logicsTemporal logics give a formal language for representing, and reasoning about, propositions qualified in terms of time or in a sequence
Amir Pnueli received the ACM Turing Award (1996) for seminal work introducing temporal logic into computer science and for outstanding contributions to program and systems verification.
Large follow-up literature, e.g., different temporal logics MTL, MITL, PCTL, ACTL, STL, applications in synthesis and monitoring
Lecture Slides by Sayan Mitra mitras@illinois.edu
Setup: States are labeled
We have a set of atomic propositions (AP)
These are the properties that hold in each state, e.g., โlight is greenโ, โhas 2 tokensโ
We have a labeling function that assigns to each state, a set of propositions that hold at that state
๐ฟ: ๐ โ 2>?
Lecture Slides by Sayan Mitra mitras@illinois.edu
Notations
Automata with state labels but no action labels
๐ = ๐,๐@, ๐, ๐ฟ
Executions (have no actions) ๐ผ = ๐@ ๐D โฆ๐F = ๐ผ. ๐๐ ๐ก๐๐ก๐
๐ผ[๐] = ๐M๐ธ๐ฅ๐๐๐ set of all executions
๐ด๐ = ๐, ๐, ๐
๐ฟ ๐@ = {๐, ๐}
๐@{๐, ๐}
๐D{๐, ๐}
๐T{๐}
Lecture Slides by Sayan Mitra mitras@illinois.edu
Computational tree logic (CTL)
Unfolding the automaton
We get a tree
A CTL formula allows us to specify subsets of paths in this tree
๐@{๐, ๐}
๐D{๐, ๐}
๐T{๐}
{๐, ๐}
{๐, ๐} {๐}
{๐, ๐} {๐} {๐}
{๐, ๐} {๐} {๐} {๐}Lecture Slides by Sayan Mitra mitras@illinois.edu
CTL quantifiers
Path quantifiersE: Exists some pathA: All paths
Temporal operatorsX: Next stateU: UntilF: EventuallyG: Globally (Always)
Lecture Slides by Sayan Mitra mitras@illinois.edu
CTL syntaxCTL syntax๐๐ก๐๐ก๐ ๐น๐๐๐๐ข๐๐ ๐๐น โท= ๐ก๐๐ข๐ ๐ ยฌ๐D ๐D โง ๐T ๐ธ ๐ | ๐ด ๐๐๐๐กโ ๐น๐๐๐๐ข๐๐ ๐๐น โท= ๐๐D ๐D๐ ๐T ๐บ๐D| ๐น ๐D
where ๐ โ ๐ด๐, ๐D, ๐T โ ๐๐น, ๐ โ ๐๐น
Depth of formula: number of production rules used
Examples (depth)E๐ ๐; AXE๐ ๐; AXE๐๐ U b; AG AF green; AF AG single tokenDepth 3, 5, โฆ
Non-examplesAX๐ ๐; path and state operators must alternate in CTL
Lecture Slides by Sayan Mitra mitras@illinois.edu
CTL semanticsGiven automaton ๐ = ๐,Q@, ๐, ๐ฟ , ๐ โ ๐ and a CTL formula ๐, ๐ โจ ๐denotes that ๐ satisfies ๐; ๐ผ โจ ๐ denotes that path (execution) ๐ผ satisfies ๐.The relation โจ is defined inductively as:
๐, ๐ โจ ๐ โ ๐ โ ๐ฟ(๐) for ๐ โ ๐ด๐๐, ๐ โจ ยฌ๐D โ ๐, ๐ โจ ๐D๐, ๐ โจ ๐D โง ๐T โ ๐, ๐ โจ ๐D โง ๐, ๐ โจ ๐T๐, ๐ โจ ๐ธ๐ โ โ ๐ผ, ๐ผ. ๐๐ ๐ก๐๐ก๐ = ๐,๐, ๐ผ โจ ๐๐, ๐ โจ ๐ด๐ โ โ ๐ผ, ๐ผ. ๐๐ ๐ก๐๐ก๐ = ๐,๐, ๐ผ โจ ๐๐, ๐ โจ ๐๐ โ ๐, ๐ผ 1 โจ ๐๐, ๐ผ โจ ๐D ๐ ๐T โ โ๐ โฅ 0,๐, ๐ผ ๐ โจ ๐T ๐๐๐ โ๐ < ๐ ๐ผ ๐ โจ ๐D๐, ๐ผ โจ ๐น ๐D โ โ๐ โฅ 0,๐, ๐ผ ๐ โจ ๐D๐, ๐ผ โจ ๐บ ๐D โ โ๐ โฅ 0,๐, ๐ผ ๐ โจ ๐D
Automaton satisfies property: ๐ โจ ๐ iff โ๐ โ ๐@,๐, ๐ โจ ๐Lecture Slides by Sayan Mitra mitras@illinois.edu
Universal CTL operators๐ฟ,๐ผ, ๐ฎ can be used to derive other operators
๐ก๐๐ข๐ ๐ ๐ โก ๐น ๐
๐บ๐ โก ยฌ๐น(ยฌ๐)
All ten combinations can be expressed using ๐ฌ๐ฟ, ๐ฌ๐ผ, ๐ฌ๐ฎ
๐ด๐๐ ๐ด๐บ๐ ๐ด๐น๐ ๐ด๐๐ ๐ด๐ ๐ยฌ๐ธ๐(ยฌ๐) ยฌ๐ธ๐น(ยฌ๐) ยฌ๐ธ๐บ(ยฌ๐)
๐ธ๐ ๐ธ๐บ ๐ธ๐น ๐ธ๐ ๐ธ๐ ๐ธ๐ ๐ธ๐บ ๐ธ(๐ก๐๐ข๐ ๐ ๐) ๐ธ๐
Lecture Slides by Sayan Mitra mitras@illinois.edu
Visualizing semantics
๐ ๐
๐๐
๐ โจ ๐ด๐บ ๐๐๐
๐ โจ ๐ธ๐บ ๐๐๐
๐ โจ ๐ด๐น ๐๐๐
๐ โจ ๐ธ๐น ๐๐๐
Lecture Slides by Sayan Mitra mitras@illinois.edu
Algorithm for deciding ๐ โจ ๐
Algorithm works by structural induction on the depth of the formula
Explicit state model checking
Compute the subset ๐๏ฟฝ โ ๐ such that โ๐ โ ๐๏ฟฝ ๐ค๐ โ๐๐ฃ๐ ๐, q โจ ๐
If ๐@โ ๐๏ฟฝ then we can conclude ๐ โจ ๐
Lecture Slides by Sayan Mitra mitras@illinois.edu
Induction on depth of formula
Algorithm computes a function ๐๐๐๐๐: ๐ โ ๐ถ๐๐ฟ(๐ด๐) that labels each state with a CTL formula
โข Initially, ๐๐๐๐๐ ๐ = ๐ฟ(๐) for each ๐ โ Q
โข At ๐๏ฟฝ๏ฟฝ iteration ๐๐๐๐๐(๐) contains all sub-formulas of ๐ of depth (๐ โ 1) that ๐satisfies
At termination ๐ โ ๐๐๐๐๐ ๐ โ ๐, ๐ โจ ๐
Lecture Slides by Sayan Mitra mitras@illinois.edu
Structural induction on formulaSix cases to consider based on structure of ๐
Lecture Slides by Sayan Mitra mitras@illinois.edu
๐ = ๐, for some ๐ โ ๐ด๐, โ๐, ๐๐๐๐๐ ๐ โ ๐๐๐๐๐ ๐ โช ๐๐ = ยฌ๐D if ๐D โ ๐๐๐๐๐(๐) then ๐๐๐๐๐ ๐ โ ๐๐๐๐๐ ๐ โช ๐๐ = ๐D โง ๐T if ๐D, ๐T โ ๐๐๐๐๐(๐) then ๐๐๐๐๐ ๐ โ ๐๐๐๐๐ ๐ โช ๐๐ = ๐ธ๐๐D if โ๐๏ฟฝ โ Q such that ๐, ๐๏ฟฝ โ ๐ and ๐D โ ๐๐๐๐๐ ๐๏ฟฝ then ๐๐๐๐๐ ๐ โ ๐๐๐๐๐ ๐ โช ๐
๐ = ๐ธ ๐D๐๐T ๐ถโ๐๐๐๐ธ๐(๐D, ๐T, ๐, ๐, ๐ฟ) [next slide]๐ = ๐ธ๐บ๐D ๐ถโ๐๐๐๐ธ๐บ(๐D, ๐, ๐, ๐ฟ) [next slide]
๐ถโ๐๐๐๐ธ๐(๐D, ๐T, ๐, ๐, ๐ฟ)Let ๐ = ๐ โ ๐ ๐T โ ๐๐๐๐๐(๐)}for each ๐ โ ๐๐๐๐๐๐ ๐ โ ๐๐๐๐๐ ๐ โช {๐ธ[๐D๐๐T]}
while ๐ โ โ for each ๐โฒ โ ๐๐ โ ๐ โ ๐๏ฟฝ
for each ๐ โ ๐๏ฟฝD(๐๏ฟฝ)if ๐D โ ๐๐๐๐๐(๐) then ๐๐๐๐๐ ๐ โ ๐๐๐๐๐ ๐ โช {๐ธ[๐D๐๐T]}
๐ โ ๐ โช {๐}
Proposition. For any state ๐๐๐๐๐ ๐ โ ๐ธ[๐D๐๐T] iff ๐ โจ ๐ธ[๐D๐๐T].
Proposition. Finite ๐ therefore terminates and in ๐ ๐ + ๐ steps.
Lecture Slides by Sayan Mitra mitras@illinois.edu
๐ถโ๐๐๐๐ธ๐บ(๐D, ๐, ๐, ๐ฟ)
From ๐ we construct a new automaton ๐๏ฟฝ = โจ๐๏ฟฝ, ๐๏ฟฝ, ๐ฟ๏ฟฝโฉ such that
๐๏ฟฝ = ๐ โ ๐ ๐D โ ๐๐๐๐๐ ๐ }
๐๏ฟฝ = ๐D, ๐T โ ๐ ๐D โ ๐๏ฟฝ} = ๐ | ๐๏ฟฝ
๐ฟ๏ฟฝ: ๐๏ฟฝ โ 2>? โ ๐๏ฟฝ โ ๐๏ฟฝ, ๐ฟ๏ฟฝ ๐๏ฟฝ : = ๐ฟ ๐๏ฟฝ
Claim. ๐, q โจ ๐ธ๐บ๐D iff(1) ๐ โ ๐๏ฟฝ(2) โ๐ผ โ ๐ธ๐ฅ๐๐๐ ๐๏ฟฝ with ๐ผ. ๐๐ ๐ก๐๐ก๐ = ๐ and ๐ผ. ๐๐ ๐ก๐๐ก๐ is in a nontrivial Strongly Connected
Components ๐ถ of the graph โจ๐๏ฟฝ, ๐๏ฟฝโฉ
Lecture Slides by Sayan Mitra mitras@illinois.edu
Claim. ๐, q โจ ๐ธ๐บ๐D iff(1) ๐ โ ๐๏ฟฝ and(2) โ๐ผ โ ๐ธ๐ฅ๐๐๐ ๐๏ฟฝ with ๐ผ. ๐๐ ๐ก๐๐ก๐ = ๐ and ๐ผ. ๐๐ ๐ก๐๐ก๐ is in a nontrivial SCC ๐ถ of the
graph ๐๏ฟฝ, ๐๏ฟฝ
Proof. Suppose ๐, q โจ ๐ธ๐บ๐DConsider any execution ๐ผ with ๐ผ. ๐๐ ๐ก๐๐ก๐ = ๐. Obviously, ๐ โจ ๐D and so, ๐ โ ๐๏ฟฝ.Since ๐ is finite ๐ผ can be written as ๐ผ = ๐ผ@๐ผD where ๐ผ@ is finite and every state in ๐ผDrepeats infinitely many times. Let ๐ถ be the states in ๐ผD. ๐ถ โ ๐๏ฟฝ.Consider any two ๐D and ๐T states in ๐ถ, we observe that ๐D โ ๐T, and therefore ๐ถ is a SCC.
Consider (1) and (2). We will construct a path ๐ผ = ๐ผ@๐ผD such that ๐ผ@. ๐๐ ๐ก๐๐ก๐ = ๐ and ๐ผ@ โ ๐๏ฟฝand ๐ผDvisits some states infinitely often.
Lecture Slides by Sayan Mitra mitras@illinois.edu
๐ถโ๐๐๐๐ธ๐บ(๐D, ๐, ๐, ๐ฟ)Let ๐โฒ = ๐ โ ๐ ๐D โ ๐๐๐๐๐(๐)}Let โ be the set of nontrivial SCCs of โจ๐๏ฟฝ, ๐๏ฟฝโฉ๐ป = โช๏ฟฝ โ โ ๐ ๐ โ ๐ถ}for each ๐ โ ๐ป๐๐๐๐๐ ๐ โ ๐๐๐๐๐ ๐ โช {๐ธ๐บ๐D}
while ๐ป โ โ for each ๐โฒ โ ๐ป๐ป โ ๐ป โ ๐๏ฟฝ
for each ๐โฒ โ ๐๏ฟฝ such that ๐๏ฟฝ, ๐ โ ๐โฒif E๐บ๐D โ ๐๐๐๐๐(๐โฒ) then ๐๐๐๐๐ ๐โฒ โ ๐๐๐๐๐ ๐๏ฟฝ โช {๐ธ๐บ๐D}
๐ป โ ๐ป โช {๐}
Proposition. For any state ๐๐๐๐๐ ๐ โ ๐ธ๐บ๐D iff ๐ โจ ๐ธ๐บ๐D.
Proposition. Finite ๐ therefore terminates and in ๐ ๐ + ๐ steps.Lecture Slides by Sayan Mitra mitras@illinois.edu
Summary
๐ = ๐, for some ๐ โ ๐ด๐, โ๐, ๐๐๐๐๐ ๐ โ ๐๐๐๐๐ ๐ โช {๐}๐ = ยฌ๐D if ๐D โ ๐๐๐๐๐(๐) then ๐๐๐๐๐ ๐ โ ๐๐๐๐๐ ๐ โช ๐๐ = ๐D โง ๐T if ๐D, ๐T โ ๐๐๐๐๐(๐) then ๐๐๐๐๐ ๐ โ ๐๐๐๐๐ ๐ โช ๐๐ = ๐ธ๐๐D if โ๐๏ฟฝ โ Q such that ๐, ๐๏ฟฝ โ ๐ and ๐D โ ๐๐๐๐๐ ๐๏ฟฝ
then ๐๐๐๐๐ ๐ โ ๐๐๐๐๐ ๐ โช ๐๐ = ๐ธ ๐D๐๐T ๐ถโ๐๐๐๐ธ๐(๐D, ๐T, ๐, ๐, ๐ฟ)๐ = ๐ธ๐บ๐D ๐ถโ๐๐๐๐ธ๐บ(๐D, ๐, ๐, ๐ฟ)
Explicit model checking algorithm input๐ โจ ๐?Structural induction over CTL formula
Proposition. Overall complexity of CTL model checkign ๐( ๐ ๐ + ๐ ) steps.
Lecture Slides by Sayan Mitra mitras@illinois.edu
1!Start!Close!Heat !Error
2Start
!Close!Heat Error
3! StartClose!Heat !Error
4!StartCloseHeat !Error
6StartClose!Heat !Error
5StartClose!Heat Error
7StartCloseHeat !Error
Start oven Open door
Close doorOpen door
Start oven
Warmup
Start cookingReset
Open door
Close door
1!Start!Close!Heat !Error
2Start
!Close!Heat Error
3! StartClose!Heat !Error
4!StartCloseHeat !Error
6StartClose!Heat !Error
5StartClose!Heat Error
7StartCloseHeat !Error
Start oven Open door
Close doorOpen door
Start oven
Warmup
Start cookingReset
Open door
Close door
AG (Start -> AF Heat)
1!Start!Close!Heat !Error
2Start
!Close!Heat Error
3! StartClose!Heat !Error
4!StartCloseHeat !Error
6StartClose!Heat !Error
5StartClose!Heat Error
7StartCloseHeat !Error
Start oven Open door
Close doorOpen door
Start oven
Warmup
Start cookingReset
Open door
Close door
! EF (Start โง EG ! Heat)
! [True EU (Start โง EG ! Heat)]
1!Start!Close!Heat !Error
2Start
!Close!Heat Error
3! StartClose!Heat !Error
4!StartCloseHeat !Error
6StartClose!Heat !Error
5StartClose!Heat Error
7StartCloseHeat !Error
Start oven Open door
Close doorOpen door
Start oven
Warmup
Start cookingReset
Open door
Close door
! EF (Start โง EG ! Heat)
! [True EU (Start โง EG ! Heat)]
1!Start!Close!Heat !Error
2Start
!Close!Heat Error
3! StartClose!Heat !Error
4!StartCloseHeat !Error
6StartClose!Heat !Error
5StartClose!Heat Error
7StartCloseHeat !Error
Start oven Open door
Close doorOpen door
Start oven
Warmup
Start cookingReset
Open door
Close door
! EF (Start โง EG ! Heat)Start, ! HeatEG ! Heat
Nontrivial SCC of ! Heat
1!Start!Close!Heat !Error
2Start
!Close!Heat Error
3! StartClose!Heat !Error
4!StartCloseHeat !Error
6StartClose!Heat !Error
5StartClose!Heat Error
7StartCloseHeat !Error
Start oven Open door
Close doorOpen door
Start oven
Warmup
Start cookingReset
Open door
Close door
! EF (Start โง EG ! Heat)Start, ! HeatEG ! Heat
Set of states that can reach nnontrivial SCC of ! Heat
EG ! Heat
EG ! Heat
EG ! Heat
EG ! Heat
Start โง EG ! Heat
1!Start!Close!Heat !Error
2Start
!Close!Heat Error
3! StartClose!Heat !Error
4!StartCloseHeat !Error
6StartClose!Heat !Error
5StartClose!Heat Error
7StartCloseHeat !Error
Start oven Open door
Close doorOpen door
Start oven
Warmup
Start cookingReset
Open door
Close door
! EF (Start โง EG ! Heat)Start, ! HeatEG ! Heat
EG ! Heat
EG ! Heat
EG ! Heat
EG ! Heat
Start โง EG ! Heat
Start โง EG ! Heat
Start โง EG ! Heat
1!Start!Close!Heat !Error
2Start
!Close!Heat Error
3! StartClose!Heat !Error
4!StartCloseHeat !Error
6StartClose!Heat !Error
5StartClose!Heat Error
7StartCloseHeat !Error
Start oven Open door
Close doorOpen door
Start oven
Warmup
Start cookingReset
Open door
Close door
! EF (Start โง EG ! Heat)Start, ! HeatEG ! Heat
EG ! Heat
EG ! Heat
EG ! Heat
EG ! Heat
Start โง EG ! Heat
Start โง EG ! Heat
Start โง EG ! Heat
EF (Start โง EG ! Heat)
1!Start!Close!Heat !Error
2Start
!Close!Heat Error
3! StartClose!Heat !Error
4!StartCloseHeat !Error
6StartClose!Heat !Error
5StartClose!Heat Error
7StartCloseHeat !Error
Start oven Open door
Close doorOpen door
Start oven
Warmup
Start cookingReset
Open door
Close door
! EF (Start โง EG ! Heat)Start, ! HeatEG ! Heat
EG ! Heat
EG ! Heat
EG ! Heat
EG ! Heat
Start โง EG ! Heat
Start โง EG ! Heat
Start โง EG ! Heat
EF (Start โง EG ! Heat)
1!Start!Close!Heat !Error
2Start
!Close!Heat Error
3! StartClose!Heat !Error
4!StartCloseHeat !Error
6StartClose!Heat !Error
5StartClose!Heat Error
7StartCloseHeat !Error
Start oven Open door
Close doorOpen door
Start oven
Warmup
Start cookingReset
Open door
Close door
! EF (Start โง EG ! Heat)Start, ! HeatEG ! Heat
EG ! Heat
EG ! Heat
EG ! Heat
EG ! Heat
Start โง EG ! Heat
Start โง EG ! Heat
Start โง EG ! Heat
EF (Start โง EG ! Heat)
EF (Start โง EG ! Heat)
EF (Start โง EG ! Heat)
EF (Start โง EG ! Heat)
EF (Start โง EG ! Heat)EF (Start โง EG ! Heat)
EF (Start โง EG ! Heat)EF (Start โง EG ! Heat)
Set of states that can reach Start โง EG ! Heat
1!Start!Close!Heat !Error
2Start
!Close!Heat Error
3! StartClose!Heat !Error
4!StartCloseHeat !Error
6StartClose!Heat !Error
5StartClose!Heat Error
7StartCloseHeat !Error
Start oven Open door
Close doorOpen door
Start oven
Warmup
Start cookingReset
Open door
Close door
! EF (Start โง EG ! Heat)Start, ! HeatEG ! Heat
EG ! Heat
EG ! Heat
EG ! Heat
EG ! Heat
Start โง EG ! Heat
Start โง EG ! Heat
Start โง EG ! Heat
EF (Start โง EG ! Heat)
EF (Start โง EG ! Heat)
EF (Start โง EG ! Heat)
EF (Start โง EG ! Heat)
EF (Start โง EG ! Heat)EF (Start โง EG ! Heat)
EF (Start โง EG ! Heat)EF (Start โง EG ! Heat)
None of the states are labeled with ! EF (Start โง EG ! Heat)