{ P:x1/v1,...,xn/vn }
x1, ..., xn := v1, ..., vn
{ P }
x, y, x, z := t, w+3, w+t, kbecomes
y, x, z := w+3, w+t, k
{ 12 > 0 and 15 > 0 }
x, y := 12, 15
{ x > 0 and y > 0 }
{ b > a } /* a swap */
a, b := b, a
{ a > b }
{ m * 5 = 50 and t + 1 = 26 }
m, t := m * 5, t + 1
{ m = 50 and t = 26 }
/* assignment sequence */
{ a = b = c = 10 }
a := 12
b := a+4
c := b*2
{ a = 12 and b = 16 and c = 32 }
/* multi-assignment */
{ a = b = c = 10 }
a, b, c := 12, a+4, b*2
{ a = 12 and b = 14 and c = 20 }
{ a[3] = 4 } a[i] := 9 { a[3] = 4 }
This assertion is obtained with our current assignment axiom schema:
{ a[3] = 4 } a[i] := 9 { a[3] = 4 }
Since there is no textual occurrance of "a[i]" in the postcondition,
it does not change to become the given precondition.
Our assignment axiom says this should be a tautology, a true assertion... However, once a[i] := 9 is executed, we cannot be sure a[3] is still 4... it depends on what value the subscript "i" has when the assignment is executed. So something is wrong here...
a[i] := 12produces a mapping almost exactly like the mapping "a" except that the new mapping takes subscript "i" to the value "12"
alpha(a,i,12)
is our notation for saying:
Formal definition:
| i != k then x[k]
alpha(x,i,f)[k] = -|
| i = k then f
a[i] := 12;
a[k] := 27;
produces a new mapping
alpha( alpha(a,i,12), k, 27 )
alpha(a,i:12,k:27)
For assignment statements with an array element on the left-side:
{ P x/alpha(x,i,f) } x[i] := f { P }
Good mnemonic:
alpha(x,i,f)
/ | \
x [i] := f
{ Q: alpha(r,j,14)[j] < alpha(r,j,14)[k] }
r[j] := 14
{ P: r[j] < r[k] }
Note: the substitution that has occurred is to
replace "r" by "alpha(r,j,14)"
Successive assignments:
{ alpha(alpha(b,i,k),j,j+1)[m] = f(x) }
b[i] := k
{ alpha(b,j,j+1)[m] = f(x) } by A.A. axiom
and
{ alpha(b,j,j+1)[m] = f(x) }
b[j] := j + 1
{ b[m] = f(x) } by A.A. axiom
so,
{ alpha(alpha(b,i,k),j,j+1)[m] = f(x) }
b[i] := k
b[j] := j + 1
{ b[m] = f(x) } by Composition