II. Notes on Data Structuring * - Cornell University
II. Notes on Data Structuring * - Cornell University
II. Notes on Data Structuring * - Cornell University
Create successful ePaper yourself
Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.
170 c.A.R. HOARE<br />
(3) If X = T(xx, x2,..., x,, ki(x'i) ) for each i between 1 and m<br />
X.S 1 ~. X 1 X.S 2 X 2 t~... & X.S n = X n<br />
& x.k~ = x'i<br />
Note: x.kz is undefined for l 4: i.<br />
Abbreviati<strong>on</strong>s:<br />
(4) Under the same c<strong>on</strong>diti<strong>on</strong> as (3)<br />
with x do {kl :$1, k2:$2 . . . . , kn:Sn} means<br />
withx , i ao(S),,,~ i x~,x2 ..... ~. x, , .<br />
and similarly with take instead of do.<br />
(5) If n = O, k,(x',) stands for T(k,(x'i)).<br />
12.4. ARRAYS<br />
The general form of an array definiti<strong>on</strong> is:<br />
type T = array D of R<br />
(1) If r is an R then T(r) is a T<br />
(2) IfxisaT, disaD, andrisanR<br />
then T(x, d: r) is a T<br />
(3) The <strong>on</strong>ly elements of T are as specified in (1) and (2).<br />
(4) T(T(x, d:r), d':r') =<br />
if d = d' then T(x, d':r')<br />
(5) T(r)[d] = r.<br />
else T( T(x, d' : r'), d : r ).<br />
(6) T(x, d: r)[d'] = if d' = d then r else x [d'].<br />
(7) (for i:D take E(i))[j] = E(j).<br />
Abbreviati<strong>on</strong>s:<br />
(8) x[d]: = r means x: = T(x, d: r).<br />
(9) T(x, dx :rl, d2:r2, ..., d,:v,,) stands for<br />
T(T(. . . T(T(x), d, :v,), d2 : v2). . . ), d,, : r,,).<br />
(10) in (9), the x may be omitted, if dl, d2,..., d, exhaust the domain<br />
type. Similarly, the T may be omitted in suitable c<strong>on</strong>texts.<br />
If the array type is ordered, the following axiom applies:<br />
(11) x ~. y _= V d:D(y[d] < x[d] ~ ~ d':D(d' < d& x[d'] < y[d']))<br />
Theorem:<br />
x = y ~ V d:D(x[d] = y[d])