Professional Documents
Culture Documents
net/publication/234765113
CITATIONS READS
13 206
1 author:
Bruce Maclennan
University of Tennessee
172 PUBLICATIONS 1,785 CITATIONS
SEE PROFILE
Some of the authors of this publication are also working on these related projects:
All content following this page was uploaded by Bruce Maclennan on 29 December 2014.
NPS52-81-008
Bruce J. MacLennan
June 1981
Prepared for:
NPS52-81-008
4. TITLE (and Subtitle) 5. TYPE OF REPORT & PERIOO COVERED
Technical Report
Introduction to Relational Programming
6. PERFORMING ORG. REPORT NUMBER
Bruce J. MacLennan
9. PERFORMING ORGANIZATION NAME AND ADDRESS 10. PROGRAM ELEMENT. PROJECT. TASK
AREA 4 WORK UNIT NUMBERS
Naval Postgraduate School 61152N,RR000-01-10
Monterey, CA 93940 N0001481WR10034
11. CONTROLLING OFFICE NAME AND ADDRESS 12. REPORT OATE
Naval Postgraduate School June 1981
Monterey, CA 93940 13. NUMBER OF PAGES
14. MONITORING AGENCY NAME 4 ADORESSf// different from Controlling Office) IS. SECURITY CLASS, (of thla report)
UNCLASSIFIED
15a. DECLASSIFICATION/ DOWNGRADING
SCHEDULE
17. DISTRIBUTION STATEMENT (of the abatract entered In Block 20, It different from Report)
19. KEY WORDS (Continue on revarae aide If necessary and Identify by block number)
20. ABSTRACT (Continue on reveraa aide il necessary and Identify by block number)
UNCLASSIFIED
SECURITY CLASSIFICATION OF THIS P KGE.(Wh«n Datm Ente
- 1 -
B. J. MacLennan. 81/02/24.
Monterey, CA 93940
1 . Introduction
x Lm R «—» }y(xRy)
Right - member and member (Rm and Mm) are defined analogously.
3. Functions
such that yFx (if such a y exists). This differs from the usual
convention, in which y=F:x means xFy, but agrees with [8] and
- 4 -
F!:C is the set of all y such that yFx for some x in C, i.e.,
right members of F.
and is defined:
Like the plural description, R and R are defined for all R and
4 . Combining Relations
so that:
Mm can be written:
Mm = Lm V Rm
x
is a function then t~" is the inverse of f.
then we will write sin>S for the sine function with its arguments
r8s = s<r>s
to positive numbers.
rormally ,
gener al
Rx = R
R n+1 = (R
n )R = R(R n )
R -n = (R
n)-l = (R" 1 )"
R° = =*(Mm:R)
(rs)t = r(st)
r(sVt) = rsVrt
(r V s) t = rs V rt
r(sAt) C rs A rt
(r A s) t C rt A st
(r-V 1 = i
-1
(rs) (s" 1 ) (r' 1 )
r
mt n _ r
m+ n ( ra , n>0 )
/ m n
\ _ t
mn (m,n>0, or r6bun)
t
mr n £ t
m+n (t6 bun)
rt" 1 = t~ l t = r° (rSbun)
7. Structures
d iagr am:
> «<
-1
Since a=R:g and g=R :a it can be seen that R follows an arrow
and R goes against an arrow. Now, notice that the left and right
members of R are:
—
Lm:R = {a f f,g}
b,c,d, e,
_^
term:R = (Rm-Lm):R = (h, i}
the structure:
s " a a a a a
l 2 3 n-l n
->* • • • >« >
In this case init:S is the unit class containing the first ele-
ment ot the sequence (i.e., a-^) and term:S is the unit class con-
be deiined:
of the tree, and term:T is set of the leaves of the tree. The
F! term:F.
set. Now note that oc: (<SS) and ui: (<SS) are the minimum and max-
can select the maximum and minimum based on any telation that is
r" 1
ini t : r = term: ( )
term: r = init : ( r )
8 . Sequences
8. 1 pairs
begun in the last section. We saw that it was easy to define the
two objects, then 'x,y' is the relation that relates x and y but
no other objects.
(x,y) = • ->-•
x y
Observe that
oc: (x,y) = x
ui: (x,y) = y
- 12 -
vertical format:
= (**y>
(y)
The class of all the ordinal couples (or pairs) that can be made
sequence? The "cons left" and "cons right" operations are easy
to define:
x cl s = (x, cc:s) V s
s cr y = s V (iu:s, y)
cc: (x cl s) = x
.Q: (x cl s) = s
m: (s cr y) = y
A: (s cry) = s
oc:s = uks" 1
ai: s = oc: s
Azs"" 1 = (Urs)" 1
a-.s' 1 = (Ars)" 1
_1
(s^t)"* 1 = t" l4 s
x
(x cl s)"" = s" 1 cr x
(s cr x)~ x = x cl s
(x^)" 1 = (y,x)
(3 H) - (z)
9. Binary Operations
x s urn ( y,z
'sum 1
, for each operation, such as '+'. Hence, we will adopt a
(A) !:SXS
- 15 -
Hence ,
functions
(-l):x = x-1
f+1) :x = x+1
10. Combinators
(x,):y = (x,y)
(,y):x = (x,y)
x
If '
:R = R~* then, since S~ x is the reverse of a sequence,
= (-):(y,x)
= y-x
Thus (-) ' can be read "subtract from" and (/) ' can be read
tary permutator .
(v)(§)(y)
<-» uRxAvSy
- 17 -
:
=
(g~) (y) (giy)
so that
(W: r) : x = f : (x ,x)
2
(x)A:n = (x) : (A:n) = (x):(n,n) = nxn = n
^A,, since
Hence, :x = (|j*)
§j
R T RT
S TX str
n
fl) -
T
RT
ST
R Tj RTJ
s o] SO]
£R §1
©' S
R
_
(§
a
oc R> (Rm:g)
UJ S> (Rm:f
R
S sun
1
cl
Si"
ct
f = (+J-UIA
23T
= 2
is the function f:t t +2t
For instance, [(!)'] ::init is the operation that gives the set of
11. Ar tays
A by P.
x=A:i). Then A:x is the set of all indices for which x=A:i.
1
xSy 4-> (A^rx) = (A"" ^)-!
«-> (Arl :x) (-1) (A^ry)
«-» 1
x[A| (-1) |A"" ]y
Hence, S = Ai-IJA" 1
this amounts to APL ' s reduce operator and Backus' insert opera-
read head has moved to that node over each edge which leads into
the node (as first parameter) and the union of the state informa-
tion of each of the read heads (as second parameter). The result
with a new set of read heads which are advanced along each edge
the root. Hence, repeated applications of ElB and (ElB) ' will
13. Examples
programs.
records, where r = |:n is the record for the employee with the
r :N = employee name
roll file $•
Then, it h 1
represents the new value of the H field, the new
employee record is
r = Md: (r , (h 1
,H)
slice of the payroll file: the hours worked for each employee.
Therefore ,
(+)liHli : n
from the previous example and generate checks for the employees.
= c './(:N)$:n\ = r (;N)S
u I p:n / '
{T — |.*
I
n
checks
f = c-USli
nr
H£i*
F =
—
C_iiL
nr
*4S1
out of line.
available.
15. Conclusions
Feldman and Rovner [5], Codd [3] and Childs [2]. What does dis-
[7].
16. References
[3] Codd , E.F. A relational model for large shared data banks,
Code 01 2A
Naval Postgraduate School
Monterey, CA 93940