This class describes the computation model and logic used
in proving programs using UNITY which uses
the concepts of safety AG and progress
AfF, from parts 1 and 2.
A system is represented by a set S of states, a set
I ⊆ S of initial states, and a set of actions. An
action c is represented by a binary relation
→c on states, where s →c s′
means that execution of action c in state s
causes a transition to state s′. For every fair action
c and every state s there is a state
s′ with s →c s′: every fair
action can be executed in every state.
The set of actions is partitioned into a set of fair actions and a
set of unfair actions. A computation from a state
s is a sequence
(s0, c0, s1, c1, …)
with s0 = s and
si →ci si+1
for every i. A computation may be infinite. In an infinite
computation, each fair action occurs infinitely often. An
execution is an infinite computation that starts from an initial
state.
A UNITY program is represented by a colored graph, as in
part 2. The vertices represent states
and the colored edges represent state transitions: action c
is represented by an edge with color c, unfair
actions are represented by edges colored grey. For convenience, the
proof rules for UNITY that were given in part 2 are repeated here.
P ▷ Q, “P steps
into Q”: every transition, by every action, fair or
unfair, from a state in P ends in Q.
P ▷c Q: every transition by action
c from a state in P ends in Q;
this is the Hoare triple {P} c {Q}.
P ↦ Q, “P leads to
Q”: every infinite computation from a state in
P reaches Q, that is,
[P ⟹ AfF Q].
P, Q, R and W are
predicates on states. As in part 1, [X] means that
X holds in every state.
| Property | Definition | Meaning |
|---|---|---|
stable P | P ▷ P | no transition leaves P |
P unless Q | (P ∧ ¬Q) ▷ (P ∨ Q) | a computation in P stays in P until it reaches Q, if it ever does |
invariant P | [I ⟹ P] ∧ (P ▷ P) | every state of every execution satisfies P |
Each rule is proved in part 2; the line under it gives the idea.
Every transition from P ends in P
or Q, and the fair action c takes every state
of P out of P. Since c is
executed eventually, every computation leaves P, and it
leaves into Q.
The general form of ensures: any proof that no computation
stays in P for ever will do.
A computation from P reaches Q;
from there it goes on to reach R.
For any family of predicates, finite or infinite: a
computation from a state that satisfies some Pi
reaches Q.
A computation from P reaches Q or
R; if it reaches R, it goes on to reach
W.
Here (L, <) is a well-founded set: every
decreasing chain k0 > k1 > …
in L is finite. M is a function from states
to L, the measure. If, from every state of
P outside Q, every computation either reaches
Q or reaches a state of P with a smaller
measure, then every computation from P reaches
Q: the measure cannot decrease for ever.
And three simple laws:
Q ↦ Q.[P′ ⟹ P] ∧ (P ↦ Q) ⟹ (P′ ↦ Q): a stronger predicate on the left.(P ↦ Q) ∧ [Q ⟹ Q′] ⟹ (P ↦ Q′): a weaker predicate on the right.