1 Definition
- A state machine is nothing more than a binary relation on a set, except that the elements of the set are called “states,”
- The relation is called the transition relation, and an arrow in the graph of the transition relation is called a transition.
2 The Invariant Principle
- A preserved invariant of a state machine is a predicate, P , on states, such that whenever P(q) is true of a state, q, and q → r for some state, r, then P(r) holds.
- The Invariant Principle:
If a preserved invariant of a state machine is true for the start state, then it is true for all reachable states. - The Invariant Principle is nothing more than the Induction Principle reformulated in a convenient form for state machines.
3 Two required properties to verify a program
- Partial correctness:
Partial correctness means that when there is a result, it is correct, but the process might not always produce a result, perhaps because it gets stuck in a loop. - Termination:
Termination is that the process does always produce some final value. - Partial correctness can commonly be proved using the Invariant Principle.
- Termination can commonly be proved using the Well Ordering Principle.
4 Derived Variables
- Strickly decreasing and weakly decreasing.
- If f is a strictly decreasing N-valued derived variable of a state machine, then the length of any execution starting at state q is at most f(q).
- If there exists a strictly decreasing derived variable whose range is a well ordered set, then every execution terminates
Reference
[1] Lehman E, Leighton F H, Meyer A R. Mathematics for Computer Science[J]. 2015.