Temporal logic describes how a system can behave over time. The possible behaviors of a system are the paths in a directed graph: a vertex is a state, and an edge is a step. This lecture defines the operators of the temporal logic CTL as sets of vertices of a graph, where they can be seen. Part 2 adds colored edges and fairness; part 3 brings in initial states, looks at single paths, and explains the logic LTL.
Notation. In CTL, AG Z is a formula, and the set
of vertices at which it holds is written
⟦AG Z⟧. Parts 1 and 2 are only about these
sets, so we drop the brackets: we write AG Z for the set
⟦AG Z⟧, and likewise for the other
operators. Part 3 brings in initial states and uses the brackets:
there AG Z is the formula and
⟦AG Z⟧ is its set.
A directed graph G = (V, E) has a set V of
vertices and a set E of edges. We write
v → v′ for the edge (v, v′),
and v →* v′ when there is a
path from v to v′: a sequence
v = v0 → v1 → … →
vk = v′. A path may have length 0
(k = 0), so v →* v for every
vertex v.
We consider only graphs in which every vertex has at least one outgoing edge, so that a path can always be continued. Standard temporal logic makes the same assumption.
An infinite path from v is an infinite sequence of vertices with v0 = v and an edge vi → vi+1 for every i. Because every vertex has an outgoing edge, every path can be continued to an infinite path.
For a set X of vertices:
The out-neighborhood of X is the set N(X) of vertices reached from X by one edge.
The set reachable from X is the set of vertices, R(X), reached from X by a path.
The out-neighborhood of the empty set ∅ is the empty set:
N(∅) = ∅ and R(∅) = ∅.
Because a path may have length 0, X ⊆ R(X); and
N(X) ⊆ R(X). But X need not be a subset
of N(X).
X (orange). Step follows
one more edge from everything reached so far. After the first step,
the vertices with a thick blue ring are N(X): the
vertices one edge away from X. When no new vertex
appears, everything colored is R(X), including
X itself (paths of length 0). The number on a vertex is
the length of the shortest path to it from X.
For predicates P and Q, ∧ is and, ∨ is or, and ¬ is not. A set Z of vertices is also the predicate “v ∈ Z”, so ¬Z is the complement of Z: ¬Z = V ∖ Z, the vertices not in Z.
P ≡ Q, read “P equivales Q”, is a predicate. It is true when P and Q are both true or both false. For example, it is false when P is true and Q is false.
P ⟹ Q, read “P implies Q”, is a predicate. It is false only when P is true and Q is false.
Dijkstra’s square brackets: [X] means that the predicate X holds everywhere in the domain. For example, in the domain of integers, [k > 0 ≡ k ≥ 1]. In these lectures the domain is the set V of vertices. For example, [v ∈ Y ⟹ v ∈ Z] says that every vertex of Y is in Z: it is Y ⊆ Z.
A predicate on vertices is true at some vertices and false at others.
Its truth set is the set of vertices at which it is true. We use
the same name for both: a set Z of vertices is the
predicate “v ∈ Z”, and a predicate
P is the set of vertices at which P holds.
Each operator on predicates is then an operation on truth sets:
| Predicate | Truth set | True at v when |
|---|---|---|
¬P | V ∖ P | v is not in P |
P ∧ Q | P ∩ Q | v is in both |
P ∨ Q | P ∪ Q | v is in either |
P ⟹ Q | ¬P ∪ Q | v is outside P, or in Q |
P ≡ Q | (P ∩ Q) ∪ (¬P ∩ ¬Q) | P and Q agree at v |
Notice that P ⟹ Q is true
at every vertex outside P. It is false exactly at the
vertices that are in P but not in Q.
With and without brackets
P ⟹ Q, without brackets,
is a predicate: it is true at some vertices and false at others, and its
truth set is ¬P ∪ Q.
[P ⟹ Q], with brackets, is
a single truth value: it is true when
P ⟹ Q holds at every
vertex, that is, when no vertex is in P but not in
Q.
P (tag P) and, after switching the
clicks, Q (tag Q). Choose a predicate. Fill the
table evaluates it one vertex at a time: each column of the table
is one vertex, and the vertex turns green when the predicate is true
there. The green vertices are the truth set. The lamp on the right is
the bracketed predicate: it is green only if every vertex is green.
Otherwise the vertices where the predicate is false get a red ring;
they are the counterexamples. At the start,
P = {a, b, c} and Q = {b, c, d, e}, and
[P ⟹ Q] fails only at
a. Remove a from P, or add it
to Q, and the lamp turns green.
V, and the circles are the truth sets of
P and Q. They divide V into four
regions: in both, in P only, in Q only, and
in neither. The truth set of the chosen predicate is shaded green; the
regions where it is false are red. For
P ⟹ Q, only the region in
P but not in Q is red. Slide P into
Q moves P until that region is empty: then
P ⊆ Q, and the lamp for
[P ⟹ Q] turns green.
Precedence. ¬ binds most tightly, then
∧ and ∨, then
⟹, and ≡
binds least tightly. So P ∧ Q ⟹ R ≡ S
means ((P ∧ Q) ⟹ R) ≡ S.
CTL names each operator with two letters. The first says which paths
from a vertex: A, all of them, or E, at least one
(there exists one). The second says what happens on them:
X, at the next vertex; G, globally, at
every vertex; F, finally, at some vertex. Each operator
takes a set Z of vertices and gives a set of vertices.
This section is about A, and section 3 about E.
For a set Z of vertices, AX Z is the set of vertices all of whose edges end in Z.
So every edge from a set Y ends in Z exactly
when Y ⊆ AX Z:
A vertex can be in AX Z without being in Z:
AX Z says where the path goes next, not where it
is now.
Z (thick green outline). The
vertices of AX Z are shaded blue: all their edges
(green) end in Z. A vertex outside AX Z
has at least one red edge, which leaves Z. At the start,
Z = {b, c, f} and AX Z = {a, d}: neither
a nor d is in Z, but every edge
from them is.
A vertex set Z is stable exactly when no edge leaves Z: every vertex of Z is in AX Z.
Equivalently, stable(Z) ≡ (N(Z) ⊆ Z). In graph
theory a stable set is called closed, because there is no path
from a vertex in a stable set to a vertex outside it.
In the bracket notation, stable(Z) ≡ [Z ⟹ AX Z].
For example, with Z = {b, c, f}, AX Z = {a, d},
so the truth set of Z ⟹ AX Z
is ¬Z ∪ AX Z = {a, d, e, g, h, i, j}. It is false
at b, c and f, and each of them
has an edge leaving Z: b → d,
c → e and f → g. So
[Z ⟹ AX Z] is false, and
Z is not stable.
Observation. stable(Z) ≡ (R(Z) = Z).
Z (shaded green). Edges that
leave Z are red: Z is stable exactly when
there are none. Release walkers puts six walkers on vertices of
Z; at each step every walker follows a random edge out of
its vertex. If Z is stable, no
walker ever leaves, however long they walk. Try {f, g, h},
then add e.
AG Z is the set of vertices from which every path stays in Z.
Observations.
AG Z ⊆ Z, because
v ∈ R({v}).stable(AG Z)(Y ⊆ Z) ∧ stable(Y) ⟹ (Y ⊆ AG Z)AG Z is the largest stable subset of
Z, and
stable(Z) ≡ (AG Z = Z).AG Z can be the empty set.AG Z is the largest set W with
W ⊆ Z ∩ AX W. Figure 6 computes it this way:
start with W = Z, and remove vertices that are not in
AX W until none is left to remove.Z. Start with
W = Z. At each step, remove from W one vertex
that has an edge leaving W (the red edge). When no such
vertex is left, W is stable, and it is
AG Z: from each remaining vertex, every path stays in
Z. Try Z = {a, b, c, d}: everything is
peeled away, and AG Z is empty.
AF Z is the set of vertices from which every infinite path reaches a vertex of Z. The first vertex of the path counts, so a vertex of Z is in AF Z.
In the example graph, AF {g, h} = {f, g, h}: the only
edge from f goes to g. The vertex
e is not in it, because the infinite path
e → j → i → j → i → … never
visits {g, h}; nor is d, because of
d → b → d → b → ….
To show that v is not in AF Z, it is
enough to give one infinite path from v that never visits
Z. In a finite graph such a path can always be chosen as a
lasso: a path to a cycle outside Z, and then round
the cycle forever.
Observations.
AG Z ⊆ Z ⊆ AF Z(Y ⊆ Z) ⟹ (AF Y ⊆ AF Z)AF Z is the smallest set W with
Z ∪ AX W ⊆ W. Figure 7 computes it this way:
start with W = Z, and add vertices of AX W
until none is left to add. AG is computed from above, by
peeling; AF from below, by growing.Z (thick green outline). Start
with W = Z. At each step, add to W one
vertex all of whose edges end in W (its edges turn
green). When no such vertex is left, W is
AF Z. Then switch the clicks to choose a start vertex.
From a vertex outside AF Z, the figure walks a lasso
(red) that never visits Z. From a vertex inside, it walks
a random path (blue), which always reaches Z. At the
start, Z = {f, j}, and AF Z = {c, e, f, i, j}.
The E operators ask for one path rather than all of them.
EX Z is the set of vertices with at least one edge that ends in Z.
EF Z is the set of vertices from which some path reaches Z.
EG Z is the set of vertices from which some infinite path has every one of its vertices in Z.
In the example graph, EX {b, c, f} = {a, d, e}, and
EF {g, h} = {a, b, c, d, e, f, g, h}: only
i and j cannot reach {g, h}.
And EG {a, b, c, d} = {a, b, d}: the path
a → b → d → b → d → … stays
in the set, but the only edge from c goes to
e.
AG Z asks that every path stay in Z;
EG Z asks only for one. Here is a small graph in
which they differ. It has four vertices, p,
q, r, s, and edges
p → q, q → p,
p → r, r → s and
s → r. Take Z = {p, q}.
EG Z = {p, q}: the path
p → q → p → q → … stays in
Z forever.AG Z = ∅: from p, the edge
p → r leaves Z, and from
q, the path q → p → r does.Z = {p, q} has a thick green outline, and
EG Z is shaded blue. A path that stays in Z walks
p → q → p → … (green): one path is
enough for EG. A path that leaves Z walks
q → p → r → s → … (red): one
such path is enough to take q out of AG Z,
and its tail, from p, takes p out too.
Some path does something exactly when not every path does the
opposite. Recall that ¬Z is the set of vertices not in
Z.
For example, v ∈ EF Z ≡ some path from
v reaches Z ≡ not every path from
v stays in ¬Z ≡
v ∉ AG ¬Z. Check the third line on the example,
with Z = {a, b, c, d}: ¬Z = {e, f, g, h, i, j},
AF ¬Z = {c, e, f, g, h, i, j}, and
¬AF ¬Z = {a, b, d} = EG Z.
The same equations, with A and E exchanged, give each A operator from
an E operator.
The E operators are computed like the A operators.
EF Z grows from W = Z by adding a vertex with
some edge into W; EG Z peels from
W = Z by removing a vertex with no edge into
W.
Z has a
thick green outline; switch the clicks to edit it. Click a start
vertex to see why it is or is not in the set. A green path or edge is
a witness: a path that reaches Z or stays in it.
A red one is a counterexample to a claim about every path. A
claim about every path that holds is shown by random paths: click the
vertex again for another. The line below the graph computes the same
set from its dual. At the start, Z = {b, d, g, h}, on
which all six sets differ: compare AG Z = {g, h} with
EG Z = {b, d, g, h}, and click d with each.
EF Z says that some path reaches Z, and
nothing about the vertices on the way. Until adds a condition on
them: the path stays in a set Y until it reaches
Z.
Some path from v reaches Z, and every vertex before it is in Y.
Every infinite path from v reaches Z, and every vertex before it is in Y.
k may be 0, so Z is a subset of both. With
Y = V there is no condition on the way:
In the figure below, let Y = {a, b, c, d} and Z = {f}. Then
E[Y U Z] = {a, b, d, f}, because of
a → b → d → f; c is not in it,
because its only edge goes to e, which is in neither set.
And A[Y U Z] = {f}. Two kinds of path show it:
a, the path a → c → e
leaves Y before it reaches Z;d, the infinite path
d → b → d → b → … stays in
Y and never reaches Z.
Every counterexample to v ∈ A[Y U Z] is one of these
two kinds: a path through Y ∖ Z to a vertex
outside Y ∪ Z, or an infinite path that stays in
Y ∖ Z. Both sets grow from W = Z:
add a vertex of Y with some edge into
W for E[Y U Z], or with all its edges
into W for A[Y U Z].
Y has a dashed orange outline and Z a thick
green one; the chosen set, E[Y U Z] or
A[Y U Z], is shaded blue. The clicks button cycles
through choosing a start vertex, editing Y and editing
Z. Start at a and at d with
A[Y U Z] to see the two kinds of counterexample.
Reset restores Y = {a, b, c, d} and
Z = {f}.
CTL (computation tree logic) is due to Clarke and Emerson. Its
formulas are usually written with propositions, such as
AG ¬crash, and the meaning of a formula is the set of
vertices, or states, at which it holds. These lectures work with those
sets directly: a proposition is a set of vertices, and each operator
maps sets to sets.
Every operator in this lecture is the largest or the smallest set
W that satisfies a condition. Model checkers compute
them this way: the largest by peeling from above, the smallest by
growing from below.