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 in only one of CTL and LTL, all properties expressible in either logic can also be expressed in CTL*.
where ranges over a set of atomic formulas. It is not necessary to use all connectives – for example, comprises a complete set of connectives, and the others can be defined using them.
means 'along All paths' (Inevitably)
means 'along at least (there Exists) one path' (possibly)
For example, the following is a well-formed CTL formula:
The following is not a well-formed CTL formula:
The problem with this string is that can occur only when paired with an or an . 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.
A – All: has to hold on all paths starting from the current state.
E – Exists: there exists at least one path starting from the current state where holds.
X – Next: has to hold at the next state (this operator is sometimes noted N instead of X).
G – Globally: has to hold on the entire subsequent path.
F – Finally: eventually has to hold (somewhere on the subsequent path).
U – Until: has to hold at least until at some position holds. This implies that will be verified in the future.
W – Weak until: has to hold until holds. The difference with U is that there is no guarantee that 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.
CTL formulae are interpreted over Transition Systems. A transition system is a triple , where is a set of states, is a transition relation, assumed to be serial, i.e. every state has at least one successor, and is a labelling function, assigning propositional letters to states. Let be such a transition model
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 .
Let "P" mean "I like chocolate" and Q mean "It's warm outside."
"I will like chocolate from now on, no matter what happens."
"It's possible I may like chocolate some day, at least for one day."
"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).
"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):
"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."
"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)."
E.M. Clarke; E.A. Emerson (1981). "Design and synthesis of synchronisation skeletons using branching time temporal logic". Logic of Programs, Proceedings of Workshop, Lecture Notes in Computer Science, vol. 131. Springer, Berlin: 52–71.
Michael Huth; Mark Ryan (2004). "Logic in Computer Science (Second Edition)". Cambridge University Press: 207. ISBN0-521-54310-X.
Emerson, E. A.; Halpern, J. Y. (1985). "Decision procedures and expressiveness in the temporal logic of branching time". Journal of Computer and System Sciences. 30 (1): 1–24. doi:10.1016/0022-0000(85)90001-7.
Clarke, E. M.; Emerson, E. A. & Sistla, A. P. (1986). "Automatic verification of finite-state concurrent systems using temporal logic specifications". ACM Transactions on Programming Languages and Systems. 8 (2): 244–263. doi:10.1145/5397.5399.
Emerson, E. A. (1990). "Temporal and modal logic". In Jan van Leeuwen. Handbook of Theoretical Computer Science, vol. B. MIT Press. pp. 955–1072. ISBN0-262-22039-3.