20.03.2013 Views

II. Notes on Data Structuring * - Cornell University

II. Notes on Data Structuring * - Cornell University

II. Notes on Data Structuring * - Cornell University

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

172 c.A.R. HOARE<br />

(23) x down succ (n) = (x down n) down 1<br />

(24) T( )downl = T( )<br />

(25) (x v T(a))down 1 = (x down 1 v<br />

if a -~ To. min then T(pred (a)) else T( )<br />

(26)-(28) up is similarly defined, with succ for pred and max for min.<br />

(29) b < a D range (a, b) = T( )<br />

(30) a ~< b D range (a, b) = T(a)<br />

(31) a < b = range (a, b) = range (a, pred (b)) v T(b)<br />

(32) j in {i:D l B(i)} ~ B(j)<br />

Abbreviati<strong>on</strong>s:<br />

(33) T(al, a2,..., an)stands for T(al) v T(a2) v ... v T(a,,)<br />

(34) {al, a2,..., an} stands for T(al, a2 ..... an)<br />

(35) x: ^ y stands for x: = x ^ y<br />

(36) x:vy .... x:= x v y<br />

(37) a from x stands for a:= <strong>on</strong>e of (x); x:- (a}<br />

(38) if x = (al, a2, . . . , an} then<br />

Theorems:<br />

for a in x do S stands for<br />

S a • S a • . S a<br />

air a2 ~ " " • ~ an<br />

where the ai are in natural order if the base type is ordered, and are in<br />

arbitrary order otherwise; and they do not c<strong>on</strong>tain repetiti<strong>on</strong>s.<br />

12.6 SEQUENCES<br />

x =y ~Va:To(ainx~ainy)<br />

ain(x v y) ~ (ainx v ainy)<br />

ain(x ^y) ~ (a in x & a in y)<br />

a in (x - y) ~. (a in x & -3 a in y)<br />

The general form of a sequence definiti<strong>on</strong> is:<br />

type T = sequence D;<br />

(1) T( )isa T<br />

(2) IfxisaTanddisaD<br />

thenx T(d) is a T<br />

(3) The <strong>on</strong>ly elements of T are as specified in (1) and (2)<br />

(4) (x-'T(d)). last = d

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!