Date and Time: 12/01/2017, Tuesday at 9:50 - 11:20
Presenter: Hyeyoung Shin
###The papers
This presentation is based on A temporal logic of nested calls and returns by Rajeev Alur, Kousha Etessami, and P. Madhusudan. and two other papers by Rajeev Alur, which will be mentioned in the reference section.
###How does my presentation fit into this course?
In the course of this semester, we have studied various implementation techniques for formal static analysis such as abstract interpretation, data-flow analysis, type system, etc. Today, I would like to talk about another useful tool in static analysis, model checking.
Model checking is an automatic verification technique for finite state concurrent systems developed by Clarke and Emerson in early 1980's.
Model checking has two components, model of computation and specification language. A model checking problem then is
Given a model of a system, exhaustively and automatically check whether this model meets a given specification formulated in logic. -wiki
In traditional model checking, the model is a finite state machine and specifications are written in propositional temporal logic. However, model checking is also available when the model is a recursive state machine, which is more appropriate for the purpose of the special specification language I am going to introduce to you today.
Advantages of model checking are no proofs, fast, counterexamples (Clarke). The main disadvantage is combinatorial blow up if the state space known as state explosion problem.
###What is Temporal Logic?
Temporal logic is a special kind of modal logic. Modal logic studies different "modes" of truth and temporal logic provides ways to describe and reason about how the truth values of assertions change over time.
Applications of temporal logic are many. One in computer science is that it is a tool for specifying and verifying correctness of computer programs [Pnueli 83]. Especially, it has been proved its usefulness in nonterminating or continuously operating concurrent programs such as operating systems and network communication protocols. In this sense, it differentiates itself from Hoare Logic, which is another well-known specification and verification tool in computer science.
Temporal logic can be categorized along a number of axes: propositional vs first-order, global vs compositional, branching vs linear, point vs interval, and past vs future. The most popular and widely used temporal logic in computer science is the linear temporal logic. Also, it is closely related to the main topic of my presentation today. Thus, it is worthwhile to overview its syntax and semantics.
###What is the syntax and semantics of Linear Temporal Logic?
The underlying structure of time is discrete, infinite into the future, and has an initial moment. We can formalize this by
The formulae of LTL are built from
-
$\diamond$ $ F$\phi$ "eventually$\phi$ " -
$\square$ G$\phi$ "always$\phi$ " -
$\bigcirc$ X$\phi$ "nexttime$\phi$ "" -
$\phi$ U$\psi$ "$\phi$ until$\psi$ ""
In the formal syntax X and U are the only primitive operators because the others can be written in abbreviation using X and U.
The binding precedence is all the temporal operators,
==========================================
Exercise 2: What is the difference between GF $\phi$ and FG $\phi$ ?
We define semantics of a formula
###Can we extend LTL so that we can express truth of the past?
Yes, with past tense operator -.
-
F-
$\phi$ "sometime in the past$\phi$ holds" -
G-
$\phi$ "always in the past$\phi$ holds" -
X-
$\phi$ "lasttime$\phi$ holds" (at$s_0$ false) -
$\phi$ U-$$ "sometime in the past$\psi$ holds and$\phi$ holds until then"
The special specification language of interest is called Nested Word Temporal Logic. While LTL is good for capturing regular sequencing requirements such as "between successive write operations to a variable, a read operation should occur," it cannot express requirements such as "if the pre-condition
Rajeev Alur, Kousha Etessami, and P. Madhusudan introduce CARET, a temporal logic that can express matching calls and returns. Calls here represent invocations of a program module and returns are the exit from the called module.
Besides global temporal modalities, CARET has abstract and caller counterparts for all the temporal modalities. Moreover, there are three kinds of paths each obtained by repetitive applications of global, abstract, and caller succ^b
-
The global paths is the usual path in the state space.
-
The abstract paths removes computation corresponding to calls to other blocks capturing the local computation within a module.
-
The caller path can be interpreted as the contents of the call-stack at a position.
CARET mixes global, abstract, and caller modalities allowing integrated and more expressive specification properties such as "variable
The computation model of CARET is a combination of structured computation, recursive state machine, and Kripke structure, which will be defined soon.
The authors of the paper claim that CARET is the first specification language that allows specification of partial and total correctness with respect to pre and post conditions, e.g. total correctness w.r.t. the pre and post condition is the formula
and has a decidable model checking problem.
Model checking problem of CARET is to check whether all computations of an RSM S satisfy a CARET specification
-
Structured computations
Execution of a program is typically modeled as a word over an alphabet. We can then represent an infinite sequence of states of a structured computation with an infinite word
$\alpha$ over alphabet$\hat{\Gamma}$ where$\Gamma = 2^{AP}$ and$\hat{\Gamma} = \Gamma \times {call, ret, int}$ .For a word
$\alpha$ over$\hat{\Gamma}$ , there is a natural notion of a matching between calls and returns: if$\alpha_i = (\sigma, call)$ and$\alpha_j = (\sigma', ret)$ , then$j$ is the matching return for$i$ if$j$ is the return corresponding to the call at$i$ . More formally, we can define a function$R_{\alpha}$ that maps any$i \in \mathbb{N}$ to the first unmatched return after$i$ . Otherwise,$R_{\alpha} = \bot$ $succ^g_{\alpha}(i) = i+1$ -
$succ^a_{\alpha}(i) = j > i$ the matching return otherwise$\bot$ -
$succ^{-}_{\alpha}(i) = j < i$ the innermost call otherwise$\bot$
-
Recursive state machines
Recursive state machines model the interprocedural control flow in recursive programs. An RSM
$S = (M, {S_m}_{m\in M}, Start)$ .For each
$m \in M$ $S_m$ is a module where$S_m = (N_m, B_m, Y_m, En_m, Ex_m, \delta_m, \eta_m)$ .
-
$N_m$ the finite nonempty set of nodes -
$B_m$ the finite set of boxes -
$En_m \subseteq N_m$ the nonempty set of entry nodes -
$Ex_m \subseteq N_m$ the nonempty set of exist nodes -
$\delta_m : N_m \cup Retns_m \rightarrow 2^{N_m \cup Calls_m}$ is a transition function where
$Calls_m = {(b, e) \mid b \in B_m, e \in En_{Y_m(b)}}$ the set of calls of m
$Retns_m = {(b, x) \mid b \in B_m, e \in Ex_{Y_m(b)}}$ the set of returns of m -
$\eta_m : V_m \rightarrow 2^{AP}$ where
$V_m = N_m \cup Calls_m \cup Retns_m$ is a labeling function that associates a set of propositions to each vertex$V = \bigcup_{m \in M} V_m$
$B = \bigcup_{m \in M} B_m$
$\eta : V \rightarrow 2^{AP}$
$Y : B \rightarrow M$
- Global Kripke structure
$K_s = (Q, Init, \kappa, \delta)$ .
-
$Q = {(\gamma, u) \mid \gamma \in B*, u \in V}$ such that
either
$\gamma = \epsilon$ and$u \in V$ $\gamma = b_1.b_2...b_k (k \geq 1)$ and$\forall i \in [a, k-1] (b_{i+1} \in B_{Y(b_i)}$ and$u \in V_{Y(b_i)}$ $Init = {(\epsilon, u) \in Q \mid u \in start}$ -
$\kappa((\gamma,u)) = (\eta(u), z)$ where
$z = int$ if$u$ is a node
$z = call$ if$u$ is a call
$z = ret$ if$u$ is a return -
$\delta : Q \rightarrow 2^Q$ is defined by$(\gamma, u) \mapsto (\gamma', u')$ if
1. internal move:$u \in (N_m \cup Retns_m) \ Ex_m \rightarrow u' \in \delta_m(u)$ and$\gamma' = \gamma$
2. call a module:$u = (b,e) \in Calls \rightarrow u' = e$ and$\gamma' = \gamma.b$
3. return from a call:$u \in Ex_m \rightarrow \gamma = \gamma'.b$ and$u' = (b,u)$
For a word
###Finally CARET
Let
For a word
-
$(\alpha, n) \vDash p$ iff$\alpha_ n = (X, d)$ and$p \in X$ or$p = d$ (where$p \in P$ ) -
$(\alpha, n) \vDash \phi_1 \vee \phi_2$ iff (\alpha, n) \vDash \phi$ or$(\alpha, n) \vDash \phi_2$ -
$(\alpha, n) \vDash \neg \phi$ iff$(\alpha, n) \nvDash \phi$ -
$(\alpha, n) \vDash \bigcirc^g \phi$ iff$(\alpha, succ^g_{\alpha}(n)) \vDash \phi$ , i.e., iff$(\alpha, n+1) \vDash \phi$ -
$(\alpha, n) \vDash \bigcirc^a \phi$ iff$succ^a_{\alpha(n)} \neq \bot$ and$(\alpha, succ^a_{\alpha}(n)) \vDash \phi$ -
$(\alpha, n) \vDash \bigcirc^- \phi$ iff $succ^{-}{\alpha} \neq \bot$ and $(\alpha, succ^{-}{\alpha}(n)) \vDash \phi$ -
$(\alpha, n) \vDash \phi_1 U^b \phi_2$ for any$b \in {g, a, -}$ iff there is a sequence of positions$i_0, i_1, ..., i_k$ , where$i_0 = n$ ,$(\alpha, i_k) \vDash \phi_2$ and for every$0 \leq j \leq k-1$ ,$i_{j+1} = succ^b_{\alpha}(i_j)$ and$(\alpha, i_j) \vDash \phi_1$
Then the model-checking problem statement is
Given an RSM S and a formula
$\phi$ of CARET, does$S \vDash \phi$ ?
================================================
Exercise 3. Consider the RSM S. Assume
$S \vDash \square^g (d \rightarrow \diamond^g z)?
How about
How about
================================================
###The expressiveness of CARET
-
Pre and Post conditions
$\phi_{total} : \square [(call \wedge p \wedge p_A) \rightarrow \bigcirc^a q]$ $\phi_{partial} : \square [(call \wedge p \wedge p_A) \rightarrow \neq \bigcirc^a \neq q]$
-
Boundedness
$\phi_{empty} : \square (call \rightarrow \bigcirc^a ret)$ - $\phi_{rep-bounded} : \diamond\square (call \rightarrow \bigcirc^a ret)
-
Local Properties
$\phi_{local-response} : \square [(t_A \wedge p) \rightarrow \diamond^a q]$
-
Stack Inspection Properties
$\phi_{stack} : \square (call \wedge p_A \rightarrow (\neg p_C) U^- p_B)$
Of course, the expressiveness of CARET is limited. For example, we won't be able to express the halting problem in CARET. In return, we have decidable model checking problems.