DisSysLab · Computation Tree Logic

Computation Tree Logic

Part 2. Colored graphs and fairness

Part 1 defined AX, AG, AF, EX, EF, EG and until as sets of vertices of a directed graph G = (V, E) in which every vertex has an outgoing edge. This part uses the same example graph. It colors the edges and restricts attention to fair paths. It ends with the rules for showing that every fair path from one set reaches another: the basis rule, transitivity, disjunction and induction.

Notation. As in part 1, we write AG Z for the set ⟦AG Z⟧ of vertices at which the CTL formula AG Z holds, and likewise for the fair operators of this part. Part 3 uses the brackets.

1. Fairness

AF Z asks that every infinite path reach Z. Fairness lets us ignore some infinite paths. To say which, give every edge a color.

Colored graph
Cfair ⊆ C

Every edge has a color in a set C of colors. The colors in a subset Cfair of C are the fair colors. For every vertex v and every fair color c, there is at least one edge of color c from v; the edge could be from v to itself. A color that is not fair has no such requirement: a vertex may have no edge of that color.

In our examples the fair colors are red (R) and blue (B). Edges whose color is not in Cfair are drawn grey and dashed. When we describe a colored graph, a vertex that has no edge of a fair color c listed has a self-loop of color c.

Infinite path, with colors
(v0, c0, v1, c1, v2, c2, …)

An infinite path from a vertex v is a sequence in which v0 = v and, for each i, there is an edge from vi to vi+1 with color ci ∈ C.

Fair path
every color in Cfair appears infinitely often among c0, c1, c2, …

A fair path is an infinite path in which every fair color appears infinitely often. So, in a fair path, after any number of steps along the path, for every fair color c, there is a later edge in the path that has color c. Edges whose color is not fair, grey in our examples, may appear infinitely often, a few times, or never.

Figure 1. Fair and unfair paths. The example graph has vertices 0 to 7 and two fair colors, red (R) and blue (B). Its edges are 0 → 1 (R), 0 → 3 (R), 1 → 2 (R), 2 → 1 (B), 3 → 4 (B), 4 → 5 (B), 4 → 7 (R), 5 → 4 (B), 5 → 6 (R), 6 → 7 (B), 7 → 6 (R), and a self-loop of every color a vertex lacks. It also has two grey edges, whose color is not fair: 1 → 0 and 2 → 7, drawn dashed. Each button walks one path and counts its red, blue and grey edges. From 6, red only takes the red self-loop forever: it never reaches 7, but it is not fair, because blue never appears. From 6, a fair path must take blue at some point, and blue goes to 7. From 4, a fair path avoiding 5 goes to 7 and then cycles 7 → 6 → 7 using both colors: a fair path that never visits 5. From 2, grey not forced goes back and forth between 2 and 1 using both fair colors, and never takes the grey edge to 7. From 0, grey forever takes the grey edge 1 → 0 in every round, and is still fair.
AfF: on all fair paths, eventually
AfF Z = {v | for every fair path (v0, c0, v1, c1, …) with v0 = v, exists k where vk ∈ Z}

For a set Z of vertices, AfF Z is the set of vertices v such that every fair path from v reaches a vertex in Z. The first vertex of the path counts, so a vertex in Z is in AfF Z.

To show that v is not in AfF Z, it is enough to give one fair path from v that never visits Z. From 6, the path that takes the red self-loop forever never reaches 7, but it is not fair, so 6 ∈ AfF {7}, although 6 ∉ AF {7}.

Grey edges. A grey edge into Z does not help. The grey edge 2 → 7 goes straight to 7, but the fair path 2 → 1 → 2 → 1 → … never takes it, so 2 ∉ AfF {7}. And a grey edge may be taken forever. The path 0 → 1 → 0 → 0 → 1 → 0 → 0 → … takes red 0 → 1, grey 1 → 0 and blue 0 → 0 in every round. It uses both fair colors infinitely often, so it is fair, and it never visits {2, 3}. So 0 ∉ AfF {2, 3}. Without the grey edge 1 → 0, every fair path from 0 would reach {2, 3}.

Observations.

  1. Z ⊆ AfF Z
  2. (Y ⊆ Z) ⟹ (AfF Y ⊆ AfF Z)
  3. AfF Y ∪ AfF Z ⊆ AfF (Y ∪ Z), and the two sides can differ. In figure 2, 0 is not in AfF {1, 2}, because of the fair path that goes 0 → 3 and then cycles between 6 and 7; and 0 is not in AfF {3, 4, 5, 6, 7}, because of the fair path that goes 0 → 1 and then cycles between 1 and 2. But 0 is in AfF {1, 2, 3, 4, 5, 6, 7}: a fair path must take red from 0, and both red edges leave 0.
Figure 2. Exploring AfF Z. Z has a thick outline; the vertices of AfF Z are shaded green. Choose Z with a preset button, or switch the clicks to editing Z. Then click a start vertex. If it is not in AfF Z, the figure shows an adversary’s fair path that never visits Z: a path to a cycle that avoids Z and uses both fair colors, repeated forever. If it is in AfF Z, the figure walks random fair paths from it, and every one of them reaches Z.

Steps into, and leads-to

Three relations between sets of vertices describe everything that follows. The first two are about single edges; the third is about fair paths. The names, and the rules for proving leads-to in this part, come from UNITY, a notation for programs and their proofs.

Steps into, and leads-to
P ▷ Q    P ▷c Q    P ↦ Q

P ▷ Q, read “P steps into Q”: every edge from a vertex of P, of every color, fair or grey, ends in Q. P ▷c Q: every edge of color c from a vertex of P ends in Q. P ↦ Q, read “P leads to Q”: every fair path from a vertex of P reaches Q.

In terms of the operators:

P ▷ Q ≡ P ⊆ AX Q     P ▷c Q ≡ P ⊆ AXc Q     P ↦ Q ≡ P ⊆ AfF Q

where AXc Q is the set of vertices all of whose edges of color c end in Q. Note the quantifier. v → w says that there is an edge from v to w; P ▷ Q says that every edge from P ends in Q.

Safety properties are statements about ▷:

PropertyDefinitionMeaning
stable PP ▷ Pno edge leaves P (part 1)
P unless QP ∩ ¬Q ▷ P ∪ Qa path in P stays in P until it reaches Q, if it ever does
invariant PI ⊆ P ∧ P ▷ Pwith initial vertices I (part 3)

Laws of ▷, each read straight off the definition:

  1. P ▷ Q ∧ Q ⊆ Q′ ⟹ P ▷ Q′: an edge that ends in Q ends in Q′.
  2. P ▷ Q ∧ P ▷ R ⟹ P ▷ Q ∩ R: an edge that ends in both ends in the intersection.
  3. Pi ▷ Q for every i ⟹ (∪i Pi) ▷ Q, for any family of sets: an edge from the union starts in some Pi.
  4. P ▷ Q ⟹ P ▷c Q for every color c: an edge of color c is an edge.

Laws 1–3 hold for ▷c too.

The basic way to prove P ↦ Q uses one fair color.

A proof rule for P ↦ Q
(∃ fair color c : P ▷c ¬P) ∧ P ▷ P ∪ Q ⟹ P ↦ Q

If every edge from P ends in P or Q, and every edge of one fair color c from P leaves P, then every fair path from P reaches Q.

Proof

Take a fair path from a vertex of P. It takes an edge of color c at some step, because c is fair. If every vertex of the path up to that step is in P, that edge starts in P, so it leaves P. Either way the path leaves P. Its first vertex outside P is reached by an edge from P, and every edge from P ends in P ∪ Q, so that vertex is in Q.

With Q = ¬P the second part always holds, and the rule says that one fair color leaving P is enough for every fair path to leave P.

Figure 3. One fair color leaves P. P = {p, q, r}, and all three colors are fair. Blue and green edges stay inside P; every red edge from P leaves it, and these edges are drawn thick from the start. Play walks a random fair path from p: it may go round inside P for a while, but it must take red, and red leaves P. Here Q = ¬P = {s, t}.

The color must be fair: a fair path need not take a grey edge at all. In the graph of Figure 2: {3} ▷ {3, 4} and {3} ▷blue ¬{3}, so {3} ↦ {4}; {4, 5} ▷ {4, 5, 6, 7} and {4, 5} ▷red ¬{4, 5}, so {4, 5} ↦ {6, 7}; and {6} ▷ {6, 7} and {6} ▷blue ¬{6}, so {6} ↦ {7}. Figure 4 shows each of them.

Figure 4. One fair color, in the graph of Figure 2. The vertices of P are shaded, the vertices of Q have a thick green outline, and the edges of the color that leaves P are drawn thick. {3} ↦ {4}: every edge from 3 ends in {3, 4}, and the blue edge goes to 4. {4, 5} ↦ {6, 7}: every edge from 4 and 5 ends in {4, 5, 6, 7}, and the red edges go to 7 and 6. {6} ↦ {7}: every edge from 6 ends in {6, 7}, and the blue edge goes to 7. Play walks a random fair path from P until it leaves; it always arrives in Q.

AX and AG are independent of fairness, because every finite path can be continued to a fair path: from its last vertex, take the fair colors in turn. AF is a subset of AfF: AF Z ⊆ AfF Z.

The dual of AfF is (EfG Z) = (¬AfF ¬Z): the set of vertices from which some fair path stays in Z forever. Figure 2 shows such a path whenever it shows a vertex outside AfF Z.

AG AfF Y and AfF AG Y

The two operators can be combined, and the order matters. Here is the smallest example: two vertices, a and b, and two fair colors.

VertexRed edgeBlue edge
aa → ba → a
bb → bb → a

Take Y = {a}.

Figure 5. Visiting Y forever, without staying in Y. The fair path a →R b →B a →R b →B … uses both colors forever. It returns to a again and again, so every vertex is in AG AfF {a}. But it can never stay at a, because red always leads away, so no vertex is in AfF AG {a}.

Observation. AfF AG Y ⊆ AG AfF Y, and figure 5 shows that the two sides can differ.

Proof

Let v ∈ AfF AG Y, let v →* w, and let P be a fair path from w. Putting the path from v to w in front of P gives a fair path from v, so it reaches some u ∈ AG Y.

If u comes before w, then u →* w, so w ∈ Y. If not, u is on P, and u ∈ Y, because AG Y ⊆ Y. Either way P reaches Y, so w ∈ AfF Y. This holds for every w with v →* w, so v ∈ AG AfF Y.

Composing the operators

AX, AG and AfF each take a set of vertices and give a set of vertices, so they can be composed. Read a composition from the right: AX AG AfF Y first computes AfF Y, then AG of that, then AX of that. The examples use the colored graph of figures 1 and 2.

Y = {7}SetMeaning
AfF Y{3, 4, 5, 6, 7} every fair path reaches 7
AG AfF Y{3, 4, 5, 6, 7} no edge leaves {3, …, 7}, so every fair path reaches 7 again and again
AX AG AfF Y{3, 4, 5, 6, 7} every edge leads to a vertex of the line above
Y = {4}SetMeaning
AfF Y{3, 4} from 3, a fair path must take blue, to 4
AG AfF Y∅ from 4, the edges to 5 and 7 leave {3, 4}
AX AG AfF Y∅ AX ∅ = ∅, because every vertex has an edge

In both examples the last step changes nothing. That is no accident:

Observation AX AG AfF Y = AG AfF Y, for every Y. Visiting Y infinitely often can be neither gained nor lost in one step.

Proof

Let W = AG AfF Y. W is stable, so W ⊆ AX W.

Conversely, let v ∈ AX W. Every fair path from v is in W ⊆ AfF Y after one step, and the rest of the path is still fair, so it reaches Y: v ∈ AfF Y. Every other vertex reachable from v is reachable from a vertex of W, so it is in AfF Y too. So v ∈ AG AfF Y = W.

The order matters. Take Y = {6}. No vertex has all its edges going to 6, so AX {6} = ∅ and AfF AX {6} = ∅. But AfF {6} = {3, 4, 5, 6, 7}, and no edge leaves that set, so AX AfF {6} = {3, 4, 5, 6, 7}. And with Y = {4}, AX AfF {4} = {3}: vertex 4 is in AfF {4}, but its edges go to 5 and 7.

Figure 6. Composing AX, AG and AfF. Click vertices to choose Y (thick outline). Each button applies one operator to the current set; the new set is shaded green, and its line is added to the list. The list reads the composition from the inside out. Example builds AX AG AfF {7} one step at a time. Try Y = {6} with AX then AfF, and then with AfF then AX.

2. Four facts about fair paths

The rest of this part shows how to prove that every fair path from a set P reaches a set Q. It uses four facts. Fact 1 was used in the proofs above, and fact 2 is one of the observations of section 1. Facts 3 and 4 are new: fact 3 is proved here, and fact 4, the basis rule, in section 3.

  1. A suffix of a fair path is fair. Drop the first k vertices of a fair path from v: what is left is a fair path from vk, because finitely many steps do not change which colors appear infinitely often.
  2. Monotonicity: Y ⊆ Z ⟹ AfF Y ⊆ AfF Z.
  3. Idempotence: AfF AfF R = AfF R. Reaching a vertex from which every fair path reaches R is as good as reaching R. Proof. ⊇: Z ⊆ AfF Z for every set Z; take Z = AfF R. ⊆: a fair path from a vertex of AfF AfF R reaches some w ∈ AfF R. The rest of the path, from w on, is a fair path from w (fact 1), so it reaches R.
  4. Basis: P ▷ P ∪ Q ∧ P ↦ ¬P ⟹ P ↦ Q. Proved in section 3.

3. The basis rule

Basis rule (fact 4)
P ▷ P ∪ Q ∧ P ↦ ¬P ⟹ P ↦ Q

If every edge from P ends in P or Q, and no fair path stays in P for ever, then every fair path from P reaches Q.

The second part, P ↦ ¬P, is P ⊆ AfF ¬P = ¬EfG P: no fair path from P stays in P for ever. A path from outside P does not stay in P either, so it is the same as EfG P = ∅.

Proof

Let v ∈ P, and take a fair path from v. Since P ↦ ¬P, the path reaches ¬P. Let w be its first vertex outside P, and u the vertex before w. Then u ∈ P and P ▷ P ∪ Q, so w ∈ P ∪ Q. Since w ∉ P, w ∈ Q. So every fair path from v reaches Q.

Both parts are needed. Without fairness, a path could go round a cycle inside P for ever. Without the first part, a path could leave P to a vertex outside P ∪ Q and never come to Q. Figure 7 shows both.

Figure 7. The basis rule. Red edges inside P form a cycle, and every blue edge from P goes to Q. So every edge from P ends in P ∪ Q, and a fair path, which must take blue, cannot stay in P. A fair path walks a random fair path from the start vertex (click a vertex of P to change it); the edge on which it first leaves P is drawn thick, and it always ends in Q. Red forever stays in P, but it is not fair. Break the first part sends the blue edge from a to f, outside P ∪ Q (dashed), and shows a fair path that never reaches Q.

Ensures

The rule of section 1 is the basis rule with the second part proved by one fair color: P ▷c ¬P gives P ↦ ¬P. It is the case used most. In UNITY its condition, P ▷ P ∪ Q and P ▷c ¬P for a fair color c, is written P ensures Q. Given P ▷ P ∪ Q, P ▷c ¬P is the same as P ▷c Q: the c-edges from P end in (P ∪ Q) ∩ ¬P ⊆ Q.

Three uses of ensures in the graph of Figure 2:

PQEdges from PP ▷ P ∪ Qc with P ▷c ¬PConclusion
{3}{4}3 → 3 red, 3 → 4 blueyesblue{3} ↦ {4}
{4, 5}{6, 7}4 → 7, 5 → 6 red; 4 → 5, 5 → 4 blueyesred{4, 5} ↦ {6, 7}
{6}{7}6 → 6 red, 6 → 7 blueyesblue{6} ↦ {7}

Grey edges count in P ▷ P ∪ Q. From 2 the edges are 2 → 2 red, 2 → 1 blue and 2 → 7 grey. So {2} ▷blue {1}, but not {2} ▷ {1, 2}, because of the grey edge. And indeed {2} ↦ {1} is false: a fair path may take the grey edge to 7 and then stay in {6, 7} for ever.

4. Transitivity

Transitivity
P ↦ Q ∧ Q ↦ R ⟹ P ↦ R

If every fair path from P reaches Q, and every fair path from Q reaches R, then every fair path from P reaches R.

Proof
P ⊆ AfF Q ⊆ AfF AfF R = AfF R

The first step is the first assumption. The second is monotonicity (fact 2) applied to the second assumption, Q ⊆ AfF R. The third is idempotence (fact 3). All the reasoning about paths is in fact 3; the rule itself is set algebra.

Figure 8. Transitivity. Red edges keep a path in P and blue edges take it to Q, so P ⊆ AfF Q. Blue edges keep a path in Q and red edges take it to R, so Q ⊆ AfF R. Play walks a random fair path from the start vertex (click a or b to change it). When it first reaches Q, at the vertex marked w, the steps before w fade: the rest of the path is a fair path from w, and the counts above show both colors still being used. Since w ∈ AfF R, it reaches R.

5. Disjunction

Disjunction
Pi ↦ Q for every i ⟹ (∪i Pi) ↦ Q

For any family of sets Pi, finite or infinite: if each leads to Q, so does their union.

Proof

Each Pi ⊆ AfF Q, so their union is a subset of AfF Q. This is set algebra; no paths are needed.

Three more laws are just as short:

  1. Q ↦ Q, because Q ⊆ AfF Q.
  2. P′ ⊆ P ∧ P ↦ Q ⟹ P′ ↦ Q: a smaller set on the left.
  3. P ↦ Q ∧ Q ⊆ Q′ ⟹ P ↦ Q′: a larger set on the right (monotonicity, fact 2).

For example, {6} ↦ {7} (ensures, above) and {7} ↦ {7} give {6, 7} ↦ {7}.

Substitution
P ↦ Q ∪ R ∧ R ↦ W ⟹ P ↦ Q ∪ W

Every fair path from P reaches Q or R. If it reaches R, it goes on to reach W. So it reaches Q or W.

For example, with Q = {7}, R = {6} and W = {7}: {4, 5} ↦ {6, 7} and {6} ↦ {7} give {4, 5} ↦ {7}: {6} is replaced by what it leads to. The proof is in the addendum.

Transitivity and substitution prove {3} ↦ {7} in the graph of Figure 2, using the three uses of ensures in section 3:

  1. {3} ↦ {4}, by ensures (blue).
  2. {3} ↦ {4, 5}, from 1 with a larger set on the right.
  3. {4, 5} ↦ {6, 7}, by ensures (red).
  4. {3} ↦ {6, 7}, by transitivity from 2 and 3.
  5. {6} ↦ {7}, by ensures (blue).
  6. {3} ↦ {7}, by substitution from 4 and 5, with Q = {7}, R = {6} and W = {7}: {3} ↦ {7} ∪ {6} and {6} ↦ {7} give {3} ↦ {7} ∪ {7} = {7}.

6. Induction on a measure

Progress proofs in UNITY usually go by induction. Give each vertex of interest a level, a natural number, with the target Q at level 0, and show that every level leads to the levels below it.

Induction
L0 = Q ∧ (∀k ≥ 1 : Lk ↦ L0 ∪ … ∪ Lk−1) ⟹ (∪k Lk) ↦ Q

If every level leads to the lower levels, everything leads to Q.

Proof

We show Lk ↦ Q by induction on k. L0 = Q ↦ Q. If Lj ↦ Q for every j < k, then L0 ∪ … ∪ Lk−1 ↦ Q by disjunction, and Lk ↦ Q by transitivity. Then disjunction over all k gives the union. Only transitivity and disjunction are used.

In the graph of Figure 2, take Q = {7} and levels L1 = {6}, L2 = {4, 5}, L3 = {3}. Ensures gives each step down, and the rule gives {3, 4, 5, 6, 7} ↦ {7}. That is all of AfF {7}: vertices 0, 1 and 2 are not in it. Figure 9 goes through the proof.

Figure 9. Induction on a measure. Each vertex of {3, 4, 5, 6, 7} is labelled with its level. Each step of the proof is one rule: ensures, disjunction or transitivity. The left side of the current step is shaded orange, the right side has a thick green outline, and for ensures the edges of the fair color that takes P into Q are drawn thick. The lines of the proof collect below the graph.

Addendum: proofs

Substitution

Proof from the rules
  1. Q ↦ Q (section 5, law 1).
  2. Q ↦ Q ∪ W, from 1 with a larger set on the right (law 3).
  3. R ↦ Q ∪ W, from R ↦ W with a larger set on the right.
  4. Q ∪ R ↦ Q ∪ W, by disjunction of 2 and 3.
  5. P ↦ Q ∪ W, by transitivity from P ↦ Q ∪ R and 4.
The same proof in sets

Q ⊆ AfF (Q ∪ W) and R ⊆ AfF W ⊆ AfF (Q ∪ W), so Q ∪ R ⊆ AfF (Q ∪ W). Then

P ⊆ AfF (Q ∪ R) ⊆ AfF AfF (Q ∪ W) = AfF (Q ∪ W)

by monotonicity (fact 2) and idempotence (fact 3).