# Computation tree logic

(Redirected from Computational tree logic)

Computation tree logic (CTL) is a branching-time logic, meaning that its model of time is a tree-like structure in which the future is not determined; there are different paths in the future, any one of which might be an actual path that is realized. It is used in formal verification of software or hardware artifacts, typically by software applications known as model checkers which determine if a given artifact possesses safety or liveness properties. For example, CTL can specify that when some initial condition is satisfied (e.g., all program variables are positive or no cars on a highway straddle two lanes), then all possible executions of a program avoid some undesirable condition (e.g., dividing a number by zero or two cars colliding on a highway). In this example, the safety property could be verified by a model checker that explores all possible transitions out of program states satisfying the initial condition and ensures that all such executions satisfy the property. Computation tree logic is in a class of temporal logics that includes linear temporal logic (LTL). Although there are properties expressible only in CTL and properties expressible only in LTL, all properties expressible in either logic can also be expressed in CTL*.

CTL was first proposed by Edmund M. Clarke and E. Allen Emerson in 1981, who used it to synthesize so-called synchronisation skeletons, i.e abstractions of concurrent programs.

## Syntax of CTL

The language of well formed formulas for CTL is generated by the following grammar:

{\displaystyle {\begin{aligned}\phi &::=\bot \mid \top \mid p\mid (\neg \phi )\mid (\phi \land \phi )\mid (\phi \lor \phi )\mid (\phi \Rightarrow \phi )\mid (\phi \Leftrightarrow \phi )\\&\mid \quad {\mbox{AX }}\phi \mid {\mbox{EX }}\phi \mid {\mbox{AF }}\phi \mid {\mbox{EF }}\phi \mid {\mbox{AG }}\phi \mid {\mbox{EG }}\phi \mid {\mbox{A }}[\phi {\mbox{ U }}\phi ]\mid {\mbox{E }}[\phi {\mbox{ U }}\phi ]\end{aligned}}}

where ${\displaystyle p}$ ranges over a set of atomic formulas. It is not necessary to use all connectives  – for example, ${\displaystyle \{\neg ,\land ,{\mbox{AX}},{\mbox{AU}},{\mbox{EU}}\}}$ comprises a complete set of connectives, and the others can be defined using them.

• ${\displaystyle {\mbox{A}}}$ means 'along All paths' (Inevitably)
• ${\displaystyle {\mbox{E}}}$ means 'along at least (there Exists) one path' (possibly)

For example, the following is a well-formed CTL formula:

${\displaystyle {\mbox{EF }}({\mbox{EG }}p\Rightarrow {\mbox{AF }}r}$)

The following is not a well-formed CTL formula:

${\displaystyle {\mbox{EF }}{\big (}r{\mbox{ U }}q{\big )}}$

The problem with this string is that ${\displaystyle U}$ can occur only when paired with an ${\displaystyle A}$ or an ${\displaystyle E}$. It uses atomic propositions as its building blocks to make statements about the states of a system. CTL then combines these propositions into formulas using logical operators and temporal logics.

## Operators

### Logical operators

The logical operators are the usual ones: ${\displaystyle \neg ,\lor ,\land ,\Rightarrow }$ and ${\displaystyle \Leftrightarrow }$. Along with these operators CTL formulas can also make use of the boolean constants true and false.

### Temporal operators

The temporal operators are the following:

• Quantifiers over paths
• A ${\displaystyle \phi }$ – All: ${\displaystyle \phi }$ has to hold on all paths starting from the current state.
• E ${\displaystyle \phi }$ – Exists: there exists at least one path starting from the current state where ${\displaystyle \phi }$ holds.
• Path-specific quantifiers
• X ${\displaystyle \phi }$ – Next: ${\displaystyle \phi }$ has to hold at the next state (this operator is sometimes noted N instead of X).
• G ${\displaystyle \phi }$ – Globally: ${\displaystyle \phi }$ has to hold on the entire subsequent path.
• F ${\displaystyle \phi }$ – Finally: ${\displaystyle \phi }$ eventually has to hold (somewhere on the subsequent path).
• ${\displaystyle \phi }$ U ${\displaystyle \psi }$ – Until: ${\displaystyle \phi }$ has to hold at least until at some position ${\displaystyle \psi }$ holds. This implies that ${\displaystyle \psi }$ will be verified in the future.
• ${\displaystyle \phi }$ W ${\displaystyle \psi }$ – Weak until: ${\displaystyle \phi }$ has to hold until ${\displaystyle \psi }$ holds. The difference with U is that there is no guarantee that ${\displaystyle \psi }$ will ever be verified. The W operator is sometimes called "unless".

In CTL*, the temporal operators can be freely mixed. In CTL, the operator must always be grouped in two: one path operator followed by a state operator. See the examples below. CTL* is strictly more expressive than CTL.

### Minimal set of operators

In CTL there is a minimal set of operators. All CTL formulas can be transformed to use only those operators. This is useful in model checking. One minimal set of operators is: {true, ${\displaystyle \lor ,\neg }$, EG, EU, EX}.

Some of the transformation used for temporal operator are:

• EF${\displaystyle \phi }$ == E[trueU(${\displaystyle \phi }$)] ( because F${\displaystyle \phi }$ == [trueU(${\displaystyle \phi }$)] )
• AX${\displaystyle \phi }$ == ${\displaystyle \neg }$EX(${\displaystyle \neg }$${\displaystyle \phi }$)
• AG${\displaystyle \phi }$ == ${\displaystyle \neg }$EF(${\displaystyle \neg }$${\displaystyle \phi }$) == ${\displaystyle \neg }$ E[trueU(${\displaystyle \neg }$${\displaystyle \phi }$)]
• AF${\displaystyle \phi }$ == A[trueU${\displaystyle \phi }$] == ${\displaystyle \neg }$EG(${\displaystyle \neg }$${\displaystyle \phi }$)
• A[${\displaystyle \phi }$U${\displaystyle \psi }$] == ${\displaystyle \neg }$( E[(${\displaystyle \neg }$${\displaystyle \psi }$)U${\displaystyle \neg }$(${\displaystyle \phi }$${\displaystyle \lor }$${\displaystyle \psi }$)] ${\displaystyle \lor }$ EG(${\displaystyle \neg }$${\displaystyle \psi }$) )

## Semantics of CTL

### Definition

CTL formulae are interpreted over Transition Systems. A transition system is a triple ${\displaystyle {\mathcal {M}}=(S,\rightarrow ,L)}$, where ${\displaystyle S}$ is a set of states, ${\displaystyle \rightarrow \subseteq S\times S}$ is a transition relation, assumed to be serial, i.e. every state has at least one successor, and ${\displaystyle L}$ is a labelling function, assigning propositional letters to states. Let ${\displaystyle {\mathcal {M}}=(S,\rightarrow ,L)}$ be such a transition model

with ${\displaystyle s\in S,\phi \in F}$ where F is the set of wffs over the Language of ${\displaystyle {\mathcal {M}}}$.

Then the relation of semantic entailment ${\displaystyle ({\mathcal {M}},s\models \phi )}$ is defined recursively on ${\displaystyle \phi }$:

1. ${\displaystyle {\Big (}({\mathcal {M}},s)\models \top {\Big )}\Leftrightarrow {\Big (}({\mathcal {M}},s)\not \models \bot {\Big )}}$
2. ${\displaystyle {\Big (}({\mathcal {M}},s)\models p{\Big )}\Leftrightarrow {\Big (}p\in L(s){\Big )}}$
3. ${\displaystyle {\Big (}({\mathcal {M}},s)\models \neg \phi {\Big )}\Leftrightarrow {\Big (}({\mathcal {M}},s)\not \models \phi {\Big )}}$
4. ${\displaystyle {\Big (}({\mathcal {M}},s)\models \phi _{1}\land \phi _{2}{\Big )}\Leftrightarrow {\Big (}{\big (}({\mathcal {M}},s)\models \phi _{1}{\big )}\land {\big (}({\mathcal {M}},s)\models \phi _{2}{\big )}{\Big )}}$
5. ${\displaystyle {\Big (}({\mathcal {M}},s)\models \phi _{1}\lor \phi _{2}{\Big )}\Leftrightarrow {\Big (}{\big (}({\mathcal {M}},s)\models \phi _{1}{\big )}\lor {\big (}({\mathcal {M}},s)\models \phi _{2}{\big )}{\Big )}}$
6. ${\displaystyle {\Big (}({\mathcal {M}},s)\models \phi _{1}\Rightarrow \phi _{2}{\Big )}\Leftrightarrow {\Big (}{\big (}({\mathcal {M}},s)\not \models \phi _{1}{\big )}\lor {\big (}({\mathcal {M}},s)\models \phi _{2}{\big )}{\Big )}}$
7. ${\displaystyle {\bigg (}({\mathcal {M}},s)\models \phi _{1}\Leftrightarrow \phi _{2}{\bigg )}\Leftrightarrow {\bigg (}{\Big (}{\big (}({\mathcal {M}},s)\models \phi _{1}{\big )}\land {\big (}({\mathcal {M}},s)\models \phi _{2}{\big )}{\Big )}\lor {\Big (}\neg {\big (}({\mathcal {M}},s)\models \phi _{1}{\big )}\land \neg {\big (}({\mathcal {M}},s)\models \phi _{2}{\big )}{\Big )}{\bigg )}}$
8. ${\displaystyle {\Big (}({\mathcal {M}},s)\models AX\phi {\Big )}\Leftrightarrow {\Big (}\forall \langle s\rightarrow s_{1}\rangle {\big (}({\mathcal {M}},s_{1})\models \phi {\big )}{\Big )}}$
9. ${\displaystyle {\Big (}({\mathcal {M}},s)\models EX\phi {\Big )}\Leftrightarrow {\Big (}\exists \langle s\rightarrow s_{1}\rangle {\big (}({\mathcal {M}},s_{1})\models \phi {\big )}{\Big )}}$
10. ${\displaystyle {\Big (}({\mathcal {M}},s)\models AG\phi {\Big )}\Leftrightarrow {\Big (}\forall \langle s_{1}\rightarrow s_{2}\rightarrow \ldots \rangle (s=s_{1})\forall i{\big (}({\mathcal {M}},s_{i})\models \phi {\big )}{\Big )}}$
11. ${\displaystyle {\Big (}({\mathcal {M}},s)\models EG\phi {\Big )}\Leftrightarrow {\Big (}\exists \langle s_{1}\rightarrow s_{2}\rightarrow \ldots \rangle (s=s_{1})\forall i{\big (}({\mathcal {M}},s_{i})\models \phi {\big )}{\Big )}}$
12. ${\displaystyle {\Big (}({\mathcal {M}},s)\models AF\phi {\Big )}\Leftrightarrow {\Big (}\forall \langle s_{1}\rightarrow s_{2}\rightarrow \ldots \rangle (s=s_{1})\exists i{\big (}({\mathcal {M}},s_{i})\models \phi {\big )}{\Big )}}$
13. ${\displaystyle {\Big (}({\mathcal {M}},s)\models EF\phi {\Big )}\Leftrightarrow {\Big (}\exists \langle s_{1}\rightarrow s_{2}\rightarrow \ldots \rangle (s=s_{1})\exists i{\big (}({\mathcal {M}},s_{i})\models \phi {\big )}{\Big )}}$
14. ${\displaystyle {\bigg (}({\mathcal {M}},s)\models A[\phi _{1}U\phi _{2}]{\bigg )}\Leftrightarrow {\bigg (}\forall \langle s_{1}\rightarrow s_{2}\rightarrow \ldots \rangle (s=s_{1})\exists i{\Big (}{\big (}({\mathcal {M}},s_{i})\models \phi _{2}{\big )}\land {\big (}\forall (j
15. ${\displaystyle {\bigg (}({\mathcal {M}},s)\models E[\phi _{1}U\phi _{2}]{\bigg )}\Leftrightarrow {\bigg (}\exists \langle s_{1}\rightarrow s_{2}\rightarrow \ldots \rangle (s=s_{1})\exists i{\Big (}{\big (}({\mathcal {M}},s_{i})\models \phi _{2}{\big )}\land {\big (}\forall (j

### Characterisation of CTL

Rules 10–15 above refer to computation paths in models and are what ultimately characterise the "Computation Tree"; they are assertions about the nature of the infinitely deep computation tree rooted at the given state ${\displaystyle s}$.

### Semantic equivalences

The formulae ${\displaystyle \phi }$ and ${\displaystyle \psi }$ are said to be semantically equivalent if any state in any model which satisfies one also satisfies the other. This is denoted ${\displaystyle \phi \equiv \psi }$

It can be seen that A and E are duals, being universal and existential computation path quantifiers respectively: ${\displaystyle \neg A\phi \equiv E\neg \phi }$.

Furthermore, so are G and F.

Hence an instance of De Morgan's Laws can be formulated in CTL:

${\displaystyle \neg AF\phi \equiv EG\neg \phi }$
${\displaystyle \neg EF\phi \equiv AG\neg \phi }$
${\displaystyle \neg AX\phi \equiv EX\neg \phi }$

It can be shown using such identities that a subset of the CTL temporal connectives is adequate if it contains ${\displaystyle EU}$, at least one of ${\displaystyle \{AX,EX\}}$ and at least one of ${\displaystyle \{EG,AF,AU\}}$ and the boolean connectives.

The important equivalences below are called the expansion laws; they allow to unfold the verification of a CTL connective towards its successors in time.

${\displaystyle AG\phi \equiv \phi \land AXAG\phi }$
${\displaystyle EG\phi \equiv \phi \land EXEG\phi }$
${\displaystyle AF\phi \equiv \phi \lor AXAF\phi }$
${\displaystyle EF\phi \equiv \phi \lor EXEF\phi }$
${\displaystyle A[\phi U\psi ]\equiv \psi \lor (\phi \land AXA[\phi U\psi ])}$
${\displaystyle E[\phi U\psi ]\equiv \psi \lor (\phi \land EXE[\phi U\psi ])}$

## Examples

Let "P" mean "I like chocolate" and Q mean "It's warm outside."

• AG.P
"I will like chocolate from now on, no matter what happens."
• EF.P
"It's possible I may like chocolate some day, at least for one day."
• AF.EG.P
"It's always possible (AF) that I will suddenly start liking chocolate for the rest of time." (Note: not just the rest of my life, since my life is finite, while G is infinite).
• EG.AF.P
"This is a critical time in my life. Depending on what happens next (E), it's possible that for the rest of time (G), there will always be some time in the future (AF) when I will like chocolate. However, if the wrong thing happens next, then all bets are off and there's no guarantee about whether I'll ever like chocolate."

The two following examples show the difference between CTL and CTL*, as they allow for the until operator to not be qualified with any path operator (A or E):

• AG(PUQ)
"From now until it's warm outside, I will like chocolate every single day. Once it's warm outside, all bets are off as to whether I'll like chocolate anymore. Oh, and it's guaranteed to be warm outside eventually, even if only for a single day."
• EF((EX.P)U(AG.Q))
"It's possible that: there will eventually come a time when it will be warm forever (AG.Q) and that before that time there will always be some way to get me to like chocolate the next day (EX.P)."

## Relations with other logics

Computation tree logic (CTL) is a subset of CTL* as well as of the modal µ calculus. CTL is also a fragment of Alur, Henzinger and Kupferman's Alternating-time Temporal Logic (ATL).

Computation tree logic (CTL) and Linear temporal logic (LTL) are both a subset of CTL*. CTL and LTL are not equivalent and they have a common subset, which is a proper subset of both CTL and LTL.

• FG.P exists in LTL but not in CTL.
• AG(P${\displaystyle \Rightarrow }$((EX.Q)${\displaystyle \land }$(EX¬Q))) and AG.EF.P exist in CTL but not in LTL.