SET-THEORETIC FOUNDATIONS OF DATA-STRUCTURE REPRESENTATION STEPHEN J. HEGNER Lawrence Livermore Laboratory, P.O. Box 808, Livetmore. CA 94550.U.S.A.
and NTH ANNE MAULU~CI Krusen ResearchCenter. Moss Rehabiii~tion Hospital, 12th St. & Tabor Rd., Philadelphia,PA 19141,U.S.A. {Received 17 September 1975;in revised form 1November 1977: received for publication ii Februap 1978) Abstract-A formal set-theoreticmodel for the computer representationof data is developed.The key idea of the model is the concept of the distinguishedurelement. A Zermelo-Fraenkel set theory ZF is the starting point. This theory containsall the fundamental sets which are required. A new Zermelo-Fraenkel theory ZF’ is then formed which is identicalto ZF except that it containsan additionalconstant o, interpreted as a urelement. Working in ZF’, new definitionsfor the usual constructionsin mathematics(e.g. permutation,projection. join. composition) are developed for the elements in ZE These definitions are far better suited for computer representationsthan are the usual definitions. In particular, the new definition of ordered n-tuple possessesa symmetry not found in the usual definition. To insure rapid and accurate computer implementationof common set-theoreticoperations such as union, intersection, difference, etc.. it is extremely useful to have a canonical well ordering on the set of computerrepresentableelemenls. Using an extremely large class of sets from Zf” (one whichcontains ZF) as the basic sets, such an ordering theory is developed.Computat~n of the ordering involves simplechecks on trees in a top&own
manner. Finally. using the frameworkdeveloped,a new definitionof Cod&s first normal form is presented.In contrastto previousdefinitions,this one allaws setsas well as urelementsas domainelements,while being perfectly consistent with the axioms of ZF
lNTRODUCTlON
In a data-base-management system, it is important that the representation of the data presented to the user be independent of the internal storage structure of the data in order to permit application programs to remain unchanged when the internal representation of the data is aitered. The reIational model of Codd[I, 21 provides an external representation of the data which consists of a set of time-varying relations, which is internal-representation independent. However, relations are not primitives in the usual mathematical sense, and to try to reinterpret them as such leads to serious difficulties. Since relations are sets. it seems reasonable to develop a data-manipulation language which represents them as sets. To avoid certain anomalies. these relations must be cast in specified normal forms. The set-theoretic framework upon which this model is based must provide a convenient method for expressing these normal forms. The use of set theory as a basis for a language for data manipulation was first proposed by Chifds[3-51. Sets and set operations are used as the buiiding blocks of the storage representation of data. The overall scope of this approach is general enough to insure that the only restrictions imposed upon sets are those of the storage limitations of the machine; the usual set operations can be applied without restriction. A specific goal of this report is to express the basic ideas of Chifds and expand upon them, rigorously and generally, yet as simply as possible, operating completely within the domain of an accepted axiomatic set theory.
As such, many of the basic definitions of this paper are suggestive of concepts in Childs’ work. However, they are very diierent in their exact development. A key feature of the work presented here is that it is framed tithin Zermeto-Fraenkel set theory, so that a guarantee of consistency is as sure as the consistency of the ~~el~F~nkef system. ALSO,it allows ail of the standard axioms of set theory as weil as the standard definition of set to be retained; in particular, the definitions of all the usual sets of mathematics (e.g. 2, V/2) are not altered. Another feature is the extremely general definition of first normal form for a relation; sets which are not themselves relations are unambiguously allowed as domain elements. While mathematical rigor has been emphasized throughout, this paper is most definitely not intended to be a new foundation for set theory. Rather, it is intended to be a framework in which some of the set-theoretic questions and cons~ctions in data structures can be concisely and precisely discussed. In an effort to keep the mathematics as simple as possible, many definitions are not given in the most general possible way. To guide the more mathematically inclined reader, generalizations are offered in a few points in the text. These are clearly marked, and may be omitted without loss of continuity. 1. FwNDmoNbxm
srRucTuRE
OF !aTs
the common axiomatic set theories, the intuitive idea is that a collection of primitive elements is given, In
193
S. J. HEGNER and
194
and that sets are those entities which can be built up from these primitive elements by repeated applications of the usual set-theoretic operations (e.g. union, powerset, subset, replacement), together with a few specialized axioms (e.g. an infinite set exists). Surprisingly, the whole of pure mathematics can be (and usually is) developed in this fashion but without the use of any primitive elements. Instead, it is developed from the empty collections of primitive elements, i.e. all sets are built up from the empty set alone. Because of this, it is customary to axiomatize in such a way that primitive elements do not exist, in both Zermelo-Fraenkel type theories (see e.g. Cohen[6]) and von Neumann-GiidelBemays type theories (see e.g. Mendelson(71). However, for the purposes of this paper, it is convenient to allow the existence of primitive elements for at least two reasons. Fist, many of the objects which are to be represented in a data structure are not mathematical objects, but rather more primitive notions such as people, places, etc. It seems somewhat artificial to assign some set as their representative. Second (and most important), the introduction of primitive elements permits a simple definition of ordered n-tuple in which the level of collection is independent of m (see Section 3 for more detail). It is possible to present both Zermelo-Fraenkel (see Neumann-Giidel-Bernays (see von suppes I81) Mostowski[9]) in such a way that prifiitive elements are permitted. For convenience, the Zermelo-Fraenkel type theory as presented in [8] will be used in this paper. However, the system of Mostowski may be substituted with at most trivial alterations at a few points. The salient features of the Zermelo-Fraenkel type system to be used will now be given. This system will be abbreviated ZF. For details, consult Suppes’ book[8]. In the system, 0 is taken to be an individual constant and represents the empty set. The following definitions are then made. x is an element (j (3y)(x E y)
xisasefe(3y)(yExorx=O) x is a urelemenr ($ x is an element and x is not a set. x is an atom e x is a urelement or x = 0. The axioms of the system are the usual ones: the axiom of extensionality, the pairing axiom, the sum axiom, the power-set axiom, the axiom of infinity, the axiom of regularity, the axiom of choice, and the axiom schema of separation. Again, refer to Suppes’ book for precise statements. While ZF permits the existence of urelements, it does not explicitly axiomatize their existence. In this paper, the existence of at least one urelement is required. To achieve this, a new system is given, denoted ZF’. This system is identical to ZF except that another individual constant a distinct from 0 is added, and this constant is taken to be a urelement, i.e. -(3x)(x E a). The consistency of ZF’ is no problem, for the tech-
R. A. MAIJLIJCCI niques of Mostowski[9] or L&y[lO] may easily be modified to show that if ZF is consistent, then so is ZF’. The intuitive idea that sets are built up from atoms may be made precise. One way to do this is to build up in ordinal-valued “layers” (see Mendelson(71, p. 202). However, it is possible to say from which atoms a set is built up without recourse to ordinals. 1.1 Definirion. Let x be an element. (a) An E-chain on x is a finite sequence of elements x1 . . . . x. suchthatx,ExzE...Ex. andx.=x. (b) An E-chain XI.. .x. on x is founding if x, is a urelement or 0. (c) SPW = {xtlx,. . . . , x. is a founding E-chain on x}. sp(x) is called the support of x. It is possible to show that all E-chains may be extended to founding chains, so no such infinite chains exist. Hence, the element x is “built up” from the set of atoms sp(x), thus lending rigor to the intuitive idea of built up. Additionalremark (for those familiar with ordinal numbers): let A be a nonempty set of atoms. Define by transtinite induction 11,(O) = A. U,&
J = 9f8ya U,(p)).
(P = power set operator)
x is d&ted over A if there is an ordinal o such that y E II,(n). The least such (I such that y E &(x) is called the rank of y. The smallest A over which x is defined is sp(x). Thus x is indeed built up from sp(x) by repeated application of the union, power-set, and subset operations.
Within ZF’, an element x is called a pure set if sp(x) ={O}. An element x is called a ZF element if a gsp(x). A ZF element which is also a set is called a ZF set. The ZF elements are those which were already present in ZF, and include at least the pure sets. The elements x with a Esp(x) arise because the new urelement a was added to ZF. The motivation for introducing a can now be. seen. ZF represents the “universe” of elements which are the basic elements to be represented: they will in a sense be the “atoms” of a new theory imbedded in ZF’. Elements based upon a will be used to construct elements in ZF’ from the elements of ZF. 2. NOTATtON AND PRELIMINARY
DEFINITIONS
In this section, notations and definitions which will be used throughout the paper are given. N, denotes the set {O,1,2. . .} of natural numbers, with 0 the empty set and n t I = n U{n}; for m,n E NJ(m, n) = {x ENlm 5x s n}; P. denotes the set of positive integers, i.e. P = N/{O};Z, denotes the set of integers; Q, denotes the set of rational numbers; R, denotes the set of real numbers; 1x1,denotes the cardinal number of the set X; p(X), denotes the power set of the set X; RX) = {x E p(X)lIXl is finite}. Let X be a set: A relation r on X is said to be (a) fdexiue if (Vx E X)((x, x) E r). (b) anrisymmerric if t.Vx)(Vy)((x,y) E r and (y, X)E rjx=y). (c) rransiriue if (Vx)(Vy)(Vz)((x,Y)E r and (y, Z)E r + (x, z) E r). (d) a partial order if it is reflexive, antisymmetric, and transitive.
Set-theoreticfoundationsof data-structurerepresentation
(e) a linear order
if it is a partial order and (VXE or (Y, x) E r). (f) a well order if it is a linear order and (VY)(Y c X and YtOj (3yE YMVzE Y)((y,z)Er)). Let X be a subset of P. (a) Y: 8(P) x N+Z is defined by
XMVy E XMx,
WX,n)=
(b) 0:
Y) E r
the nth smallest element of X, if 0 C n 5 1x1, Oifn=O. i - 1 otherwise. g(P) x P+Z is defined by k.
where n is the kth smallest element of X, WX, n) = when n E X. i 0 otherwise. The symbol = means “is defined to be”. 3. BASK DEFwTlorw
AND oPEuAnoNs
In this section, the fundamental definitions of the theory are presented. Throughout the rest of the paper, the domain of discourse is ZF’. 3.1 Definifion. Let f,,, be the function with domain N inductively defined f,(n+l)= by L.(O)= a, fJn)UCf.,(n)}. The range of f is called the set of anumbers and is denoted N’; f.,(n) is denoted n’, and N/(a) is denoted P’, and is called the set of positive a -numbers. The o-numbers are clearly founded on {a}, in the sense of Section 1. Thus. no o-number is a ZF-element, and conversely. This property permits the use of anumbers for the indexing the ZF elements. 3.2 Definition. (a) Let x be a set and let n EN. Inductively, x is a 9(n):sef if (Vy Ex)@w)@rEP’)(y = {w, z} and (w is a ZF-element or (3k E N)(k < n and w is a F(k):set))). (b) x is a Fz’sef ($ (3n)(x is a F(n):&). (c) If x is a Fset. the least n such that x is a F(n):set is called the 5”:rank of x, and is denoted Frank(x). (d) y is a F(n):element @(3x)(y Ex and x is a F(n):set). (e) y is a F:elemmr W (3n)(y is a F(n):eIement). (f) The Erank of the Felement y is the rank of {y}. In words, the F(O):sets are just sets of unordered pairs in which one element is a ZF-element and the other is a positive o-number. F(n):sets are sets of unordered pairs in which one element is a ZF element or a F(k):set for k < n and the other is a positive a-number. An example should help to clarify. 3.3 Example. Let x, y. and z be ZF elements. (a) {{x,l’}, {y, 2’},{z,2’},{x,3’}}is a F(O):set. (b) {{x,n’}/n’ E P’} is also a F(O):set. (c) {1x,3’1,My, l’),C7,10% 683, {2,1220’}}is a F(l):set. (d) Mw, 12’1, Ix. 13%. 23, {y,4%, where w is the F( 1):set of (c), is a F(3):set. (e) 0 is a F(O):set. Remark: (for those familiar with ordinal numbers).The above definitions may clearly he generalixed by using ordinals instead of natural numbers. For any ordinal a, define f. on o by for B>O. ~,,(a) is called the o-
195
ordinal correspondingto a, and is denoted a’. An a-ordinal which is not a is called posiriw Now define for x a set and (t an ordinal, x is a Y(a):set * (Vy ExW3w)(Llz)ty = (w, z) and (IV is a ZF element or (38 < a)(w is a Y@):set)) and 2 is a positive a-ordinal). A generalized tT:set is a r(a):set for some a. A generalized Pelement is just an element of a pneraiii Y:set. The definitionof rank is the obviousextensionof that in 3.2. Essentially all of the results in this paper which apply to Psets apply also to generafixed*sets. However, in some cases, the use of ordinal arithmetic and other properties of ordinals hcyond the scopeof this paper may he required. For this reason, the theory of this paper is developed using’only the natural numbers.Readersfamiliarwith ordinals shouldhave no difficulty making the appropriategenerahxations.
3.4 Defvtirion. Let y be a Y:element. (a) Ind(y) 4 U{n E Hn’E y}. Ind(y) is called the index of y. (b) Val(y) G U{z(z E y and ZQ P’} Val(y) is called the value of y. 3.5 Definition. Let A be a F:set. (a) Num(A) G {n E p)@x E AHn = Ind(x))}. (b) El(A) k {y/(3x E A)(y = Val(x))}. (c) For n E P, El,(A) g (y((3x E A)(y = Vat(x) and n = Iud(x)U. (d) For
n E P, Elnum.(A) 4 {xix E A and Ind(x) = n}. The concepts of the preceding two definitions are best illustrated by example. 3.6 Erample. Let A ={{x,2’}, {y,6’}, {y. l’}, {z.6’}}, where x, y, z are ZF elements’or Fzsets. A is a Tset. Ind({x, 2’))= Ix. 2’1, (y, 6’1, {y, 13, {z, 63 are *elements. Val({x,23) = x, 2, Wty, 6’1) = Y, Ind({y, 61) = 6, Ind({z, 6% = 6, Ind({y, 1% = 1, W{Y, 1% = Y, Val({z,6’))= z. Num(A) = {1,2,6}. El(A) = 1x, Y, I), for E&(A) = (~1, J%(A) = {xl, EL(A) = IY, 4; M.(A) = 0. n6E Num(A), Elnumt(A) = {{Y, 1% Elnuma(A) = {ix, 2% Elnuma(A) = {{y,63, {r 6’}}; for nE Num(A), Elnum.(A) = 0. 3.1 Example. Let 82 = B, = {{x, l’}(xE Z}, {{x, n’)\x E Q\Z and n EP and n is even}, B3 = {ix, n’}lx ER\Q and n E P and n is odd}. L.et A = BI UBaUBs. A is a *set. El(A)= R, El,(A) = (R\Q)UZ; for n odd and n#l, EI.(A)=R\Q; for n even, n E P, Elnum.(A) = El.(A) = Q\Z. For {1x,n’Hx E El.(A)}. The fact that Fzsets are defined to be sets enables the usual set operations to be performed on them. Furthermore, F:sets are closed with respect to these operations in the sense of the following theorem. 3.8 Theorem. (a) If A is a 9:set and DC A, then D is also a *act. (b) If A and B are F:sets so are A\B, A U B, and A n B. There is a canonical representation of every ZF element and every set of F:sets as a single Fzset, namely the one given below. 3.9 L&$nirion. Let x be a ZF element or a set of Fzsets. Tab(x) G {z((3y E x)(z = {y, I?)}. Tab(x) is clearly a F:set, namely that which indexes each yEx by 1. 3.10 Example. Let A, and At be the F:sets defined in Examples 3.6 and 3.7 respectively. Let a = IAt, AS. {Ix, ~1, {z, 2% xl. TaMA) = {{AI, 1’1, L42, 1% {{Ix* Yl, Iz. 2’11, 13, Ix, 1’11.
3.11 Theorem. Let A and B be ZF elements or sets of Fsets with A nonempty.
S. J. HE~NER and R. A. MAIJLUCCI
1%
(a) Tab(nA) = rl{Tab(o)(n E A}. (b) Tab(lJA) = U{Tab(a)(a E A}. (c) Tab(A\B) = TabtA)\Tab@). Since a relational approach to data structures has currently received much attention, it is necessary to give serious consideration to the idea of n-tuple. The usual definition of n-tuple in set theory is awkward for computer applications since the number of times an entry in an n-tuple is used atomically depends upon its position. For example, in the usual definition of ordered pair, (a, b) = {{~},{a,b}}, the first element appears atomically two times, whereas the. second element appears atomically only one time. This produces an asymmetry of representation which makes computer handling diacult. The Zset, however, admits a symmetric definition of n-tuple, thus overcoming this difficulty. 3.12 Definition. Let n E P. A is a 9:n-tuple e ((A is a Tset) and (Vz E N(1, n)H3yMEMA) = {y}) and (Vr E P\X(l,n)MEI,(A)=O)). Note: If A is a .T:n-tuple, A is sometimes denoted by (y,, . . . , y.), where {yJ = El,(A) for zE~Y(l,n). Thus, a %n-tuple is a Y:set which has exactly one Yzelement with index i for i = 1,2.. . , n. and no other elements. The i-indexed element is interpreted to be the ith element in the n-tuple. 3.13 Theonm. Let n EP. Let (x1,. . . ,x.) and (Y,, . . . , y.) by Tn-tuples. (x,, . . . ,x.) i (y,, . . . , y_) @ WiENl, n)Hxi = yr). 3.14 Example LA A = {{x, l’}, {y, 2’},{z, 3’},{y, 4’)) be a Y:set. A is a YMuple. A is also denoted by (x, y, I, y). Remark: In general. angle brackets 0 will be used for Entuples while parentheses () will be used for ordinary n-tuples.
4.RBLATtoNsAJmoPgWTlWsoNlMMtoNs Since relations are the basis of one of the modern approaches to data representation (see Codd[ 1,2]), a set-theoretic formalism should consider relations and relational operators (e.g. permutation, projection, join, composition, restriction, etc.). It is natural to seek a definition of a relation on a set of R Tsets such that the relation is also a .T:set. In addition, it is desirable that the relation be the representation of a set of Y:n-tuples if each of the Y:sets is the representation of a set, i.e. Tab(X) for some set X. 4.1 Wnition. Let (y,,. . . ,y,) be an n-tuple of *elements. Tuple(t,. . . . , y.) is defined to be the Fset {{zhmI1,. . .. {z,, m;}}, where Zi = Val(yi) and mi = i Ind(y,) for i = 1,. . . , R. i-l 4.2 D&ition. Let B = AI, . . . , A. be a finite sequence of Tsets. The FCartesiun product of B is defined to be where x= Tab(X), {Tuple(y,, . . . , y.)((Vi EJW, n)WYiE Ad). This product isdenotedA,B...BA.or
iA,.
i-l
The idea behind the Y:Cartesian product is that the usual indexing process is generalized. The index of the ith element in the value of a typical entry is the sum of the indices of the lirst i elements in that value. If the index of each element in Ai is 1, then the value of a
typical
entry in the product is a Tn-tuple, as will be illustrated shortly. 4.3 Example. Let B = A,, AZ, A, be a sequence of Tsets. where A, = {{w, 6’}, {y, l’}, {x. 1’)). A2 = {{x, I’}. {yq2’}, {z, 2’11, A, = {{u, 2’}}. Let P = {{{{w. 6’}, {x.7’). {a9% 1’1,{t{W6’), {Y*8% {a 10’11, I’). {{{w. 6’). {z. 8’). {U. 10%. 1% NY. 1’1, Ix, 2’1, Iu. 4%. 1’1, {{{y,I’}, {y, 3’). {u,S’}}, 1’1, MY, 1’). {z. 3’1, Ia 5’11, 1’1, {{Ix,I’}, {x, 2’1, Ia4% 1’1, {{Ix,1’1, {z.3% {u, 5% 1’1, Mx, I’). {z,3’). {u,5’}}. 1’). P is the Y:Cartesian product of B and is denoted by A, E3A2 fl As. 4.4 Definition. Let B = A,, . . ., A,, be a finite
sequence of psets. A subset of i A, is called an n-ary i-, Frelation (or just a Trelation) on B. A S:set R is called an n-ary prelation (or just a T:relation) if there is a B such that R is an n-ary 5:relation of B. 4.5 Example. Let B = A,, AZ. A3, and P be as in Example 4.3. Let R ={{{{w,6’}, {z,8’}, {u, lo’}}, I’}, MY, 1% {Y.3’1, {u. 5% 11, MY, 1’1, Is 3’1, {u.5’)1, I’), {{{x.1’).{x.2’). {u, 4’}},I’}}.R is a Trelation on B. Remark: Using the concept of generalized %set as outlined following 3.3, it is possible to define arbitrary 9:Cartesian products and a-ary Frelations for any ordinal cr.
Note that the values of the YZ elements of Y:relations need not be %n-tuples. However, the following theorem shows that Y:n-tuples are a special case. 4.6 Theorem. Let B = A,.. . . , A. be a finite sequence of %sets such that (Vi E x( 1, n))(YX)(A, = Tab(X)). Let i? be a Frelation on B. (Vx E El(R)) (x is a .T:ntuple). 4.7 Example. Let X,=X2= X,=X,=R. Let A, = AZ = A3 = Ad = Tab(R) = {{x,l’}lx E R}. Let B = A,, AZ, AS, Ad. For any T:relation R on 8, El(R) is a set of .T&uples. For example, R = {{{{x,l’}, {y, 2’). {z, 3’}, {~4’}}. l’~x,y,z,w~R and xZ+y2+z2+w’=1} is a Trelation on B which represents the four-dimensional unit circle. The following is a treatment of selected operations on prelations. The permutation operation provides a means of interchanging selected columns of a relation and of recomputing the indices so that the resulting set is a relation on B. The following generalizes this to Y:relations. 4.8 Dejkition. Let R be an n-ary F:relation. and p be permutation on Perm(R, p) = jv(l, n). ;abW(Y I.. . . . Y.)MTuple(y,, . . . , y,,) E El(R) and z = Perm(R,p) is called the Tuple(Y,,,,, . . . . y&I}. Fpennutation of R by p. 4.9 Theorem. Let R be an n-ary .T:relation, and let p and u be permutations on N( 1, n). (a) Perm(R, u) is an n-ary Fzrelation. (b) Perm(R, pa) = Perm(Perm(R, m), p). 4.10 Example. Let B and R be as in Example 4.5. Let p be the permutation on ,V(l, n) such that p(l) = 2, p(2) = 3. p(3) = 1. Perm(R, PI = {{I{z,2’). {s 4’). {w. IO’}}, 1% MY* 2’1, Iu. 4% IY. 5’11, 1’1, {{{z. 23, Iu. 4’1, {Y,5’}}, I’). WG 13. {u, 33. Ix, 4%. 1% The usual concept of projection on an n-ary relation is generalized to n-ary Trelations using the Tadjustedprojection operator.
I!97
Set-theoretic foundations of data-structure representation
Let R be an n-ary .T:relation, and let a nonempty subset of N(l, n). Adproj (R. L) k Tab(W(y,, . . ., y,N (Tuple(Y,, . . . . Y.) E El(R) and z = TUjMYW.,,, . . ., YW_.IL J)H. AdproXR, U is called the T:adjusred projection of R by L. 4.12 Theorem. Let R be an nary T:relation and let L be a nonempty subset of X(1, n). Adproj(R, L) is an IL/-ary F:relation. The idea behind the adjusted-projection operator is most easily illustrated by example. 4.13 Example. Let B = A,, A*, A3, and R be as in Example 4.5. Let L = { 1.3). Adproj(R. L) = INN 6’1. {a. 8% I’), {{{Y, 1% {u, 3% I’}, {{{x.1’). {u.3’}}, I’}}. Adproj(R, L) is a T:relation on S = D,, Dz where D, = A,, 4= A3. The next theorem shows that the F:adj&ted-projection operator carries the usual meaning of a projection operator when it is applied lo n-tuples. 4.14 Theorem. Let R be an n-ary T:relation such that (Vx E EI(R))(x is a F:n-tuple). Let Z_.be a nonempty subset of X(1, n). (Vx E El(Adproj(R, L)))(x is a F$(tuple). 4.15 Example. Let R be as in Example 4.7. Let L = (2.3). Adproj(R, L) = {{{{y,I’}, {z, 2’)). I’}ly,z E R and YZ+ z’ c 1) represents the two-dimensional unit disc. The T:domain operator gives the ith domain of the elements of an n-ary T:relation, and corresponds to the usual concept of domain. 4.16 Dejinition. Let R be an n-ary F:relation. Let i E A’(I, n ). Dom(R, i) g UEI(Adproj(R. {i})). Dom(R, i) is called the T:ith domain of R. The join operations allow two relations R and S to be coupled. The result is a relation which consists of elements formed by joining an element from R to an element from S when the last k components of the R element match the first k components of the S element (for some specified integer k), and eliminating the duplication of the k common elements. The F:join operator given below generalizes this usual set-theoretic join. 4. I7 Definition. Let R be a p-ary T:reiation and let S be a q-ary Frelation. Let k E~V(O,min((p, q}) (where min( ) is the minimum operator). Join(R, S, K) = and Tab((z((3y1,. . , Y,,+,-t)(Tuple(y,, . . . , y,) E R Tuple(YP--k+l.. . , Y~-,++~)E S and z = Tuple(y,, . . . , Y~+~-~)}).Join(R, S. k) is called the F:k-join of R and S. Join(R. S. 0) is called the concatenation of R and S. Join(R. S. k) is termed natural when ‘Adproj(Join (R.S.k).N(l,p))=R and Adproj(Join(R, S, k), _I‘@- k + 1. p + q - k)) = S. 4.18 Theorem. Let R be a p-ary Frelation, let S be a q-ary F:relation and let k E NO, min(p, q}). Join(R, S, k) is a (p + q - k)-ary F:relation. 4.19 Theorem. (Associativity of the join). Let R be a p-ary F:relation. let S be a q-ary T:relation, and let T be an r-ary F:relation. Let k E N(0. min(p, q}) and let m E .+.(O.min{q. r}). Join(Join(R, S. k). T, m) = Join(R, join (S. 7. m I. k). 4.20 Theorem. Let R = {{{{x. I’}. {Y.3’},{z,4’). {a 6’}},I’}, {{k. I’}. !‘*5’1.!w, 6’). {t. 8’11,I’}, {{{h. I’}, {t. S’}.{r 6’). {w,8’}},I’}. 4.11
L
be
Definition.
I{{x, I’), I1.5’1,{z.6’1,IW 8% I’}, II{&3’1,Ih. 6% {1,9?, {u. IO’]), I’}}. Let s = {{{Is,2’). {I, 3% {u, 4’},Iv, 5% I’). IGz. 1’1,{W 3’1,{h, 6’1,{g, 8%. I’), {Hz. I’), tm 3’1,Ih. 6’). {g, 7’1). I’), {{It.3’1,{u, 4’). III, 5’1,0.9’)). 1’1). Join(R, S, 2) = {{Ix,I’), {y. 3’1,{z,4% {w,6’). {h, 9% {g, 1I’)). I’). {{Ix, I’). {y, 3’1,{z,4’), {w, 6’). {h, 9’1,{g, lo’)), I’). IIIh, 1’1,k5’1, Iz. 6’). Iw. 8’). {h, I I’), {a 13’11,I’), {{{II,1’1,(1.5’1,{z,63. tw, 8% {a 1I’}. {g, 12%. 1’1, I{{x,I’), It,5’), Iz, 63, {w.a), {h, I I’}, 1% l3’H. I’), {{Ix.I’), If, 5’1,Iz.63, Iw. 8’1,Ih, I I’), {g, 12%. I’), I&, 3’). Ih, 6’1,It, 9% Iu. IO’),Ih, I I’). 0, 15’11,1’)). Join(S, R, 2) = {{I{t.3’1.{u,43, {h, 5’1,{I, 9’). {z. lo?, {w, P}), I’)). 4.21 Example. Let R = #Ix, I’), IY. 33, {z,4’1,I w, 6% I’}, Mh, 13. {1,5’),{z,6% {w.8% 1’). WI, 13. {1,5’),{u. 63, {u, 9% I’), I& 3’1,Ih, 6’1,{t,9?. {u, lo’))* I’). Let S = {{{{z,1’1,{w.3% {h, 6% {g. 8’)). I’), Mz. 1’).{w. 3’1,{h, 6’1,Is, 7% 1’1, Mt, 3% Ii&43. #I, 5’1,{t,9'H, 1% I&, 13, iv, 4’),0I. 73, {g,9% I’H. Join(R, S, 2) = Mx, I’), {Y. 3’1,Iz. 43, {w,6% {h, 9’). (g, 11’)). I’), {{Ix,1% {Y.33, Iz, 4’1.IW 61, {a 9% (s, 10’11,‘I’}, W. 1’).it, 5’1,{z,6% {w,83, {h, 113, Cs, 13% I’), I#. I’), It, 5’1,{z. 6’). {w,83, {h. I l’), {g, 12’}),I’), Mh, 1% D.53, {u, 6’1,{u. 9’1,{h. 12% (g. 14% I’), {Q, 33, th, 61. It. 9% {u, lo’), Ih, I I’}, ti, 15% 1’)) is the F:2-join of R and S, which is natural. The tie operation applied to a relation seeks to match the first k and the last k components of an element of the relation; an element is retained (minus its last k components) if and only if such a match is found. The F&-tie operation on F:relations generalizes this idea. 4.22 Drfnition. Let R be an n-ary F:relation. Let k EX(I, n - I) Tie(R, k) g Tab({z)3x E EI(R))(Adproj ({{Ix,1% N(l, k)) = AdproMx, 1% N(n - k + 1, n)) and z = Adproj({{x, I’}},X(1, n - k))))). Tie(R, k) is called the F:k-rie of R. 4.23 Theorem. Let R be an n-ary Trelation and let k E N( 1, n - 1). Tie(R, k) is an (n - k)-ary Prelation. 4.24 Example. Let R = {Mx. 13, {Y, 3’1, {y. 43, Ix, 5’1,{Y, 79, I’), NY? 3’). IY, 4’). IY. 9, {Y. 6’1, IY, 9% 1’1, Nx. 1% Ix. 2’). ix, 3’1,Ix, 4’). {x, 5’11,I’), {{{z.38’1.{Y, 56’1, If. 60% k 98’1, ty, 116’1, I’)). Tie(R. 1) = IMY. 3’1, {Y. 4’),{y. 5’1, IY, 6%
I’),
{{Ix.I’]. Ix, 2’). {x, 3’). Ix, 4’}},I’}}.
S.
198
1. HEWER and R. A. MAULUCCI
Tie(R, 2) = {{{Ix.13, {y. 3’). {y. 4% 1% Mx, I’), ix. 2% Ix. 3’11,1’1,
Tie(R, 3) = {{{Ix.I’}, 1.x.2%. I’}}. Tie(R, 4) = {{{{x.I%. 1%. The composition of two relations, R and S, produces a relation which consists of elements formed by attaching an element from R to an element from S when the last k components of the R element match the first k components of the S element (for some specified integer k), and eliminating the k common elements. The Fcomposition operator generalizes this idea. 4.25 Definition. Let R be a p-ary Frelation and let S be a q-ary Frelation. Let J be a S:k-join of R and S. Comp(R, S, J) A Adproj(J, N(1, p - k) UN(p + I, p + q - k)).
Comp(R, S, .I) is called the Y:composition of R and S with respect to J. If J is natural, Comp(R, S. /) is also called natural. 4.26 Theorem. Let R be a p-ary Prelation and let S be a q-ary Frelation, and let J be a Fk-join of R and S. Comp(R, S, J) is a (p + q - 2k)-ary srelation. 4.27 Example. (a) Let R and S be as in Example 4.20. Comp(R, S. Join(R, S, 2)) = Mx. 1’).{Y. 3% Ih;6’), I& 8% 1’1. {{{Ix, 1% IY, 3% Ih, 6% (g, 7’11,1’1. {{Uh, 1’1.It. 5’1. {h, 8’). b 10% 1’1, I{{#. 1’1. {tv5’1. {h, 83, lg. 9%. 1“). {Nx, 1’1. It, 5’1. {h, 8’1, (g, 10% 1’1, {{I{x, 1’1,It. 5’1. {h. 8’1, {g. 9% 1’1. Wg, 3’1, {h. 63, {h. 7’1,It. 11%. 1%
(b) Let R and S be as in Example 4.23. Comp(R, S, Join(R, S, 2)) =
is the %composition of R and S with respect to Join(R, S, 2). which is natural. 4.28 Example. Let G be a group. Let R = {{{{a, I’}, ab = c}. and I’}la, b, c E G Ic. 3% Ib, 2’1, Comp(R, R. Join(R, 1.1)) = {{{{a, 1’). Ib, 2’1, {c. 3’1. id, 4’11, l’)(a, b, c, d E G and abc = d}. The restriction operation applied to a relation R makes it possible to retain only those elements of R which satisfy certain criteria. The restriction is with respect to a specified relation S. An element of R is retained if and only if certain of its components match certain other components of some element of S. Again, this is generalized to Frelations by the construction given below. 4.29 Definition. Let R be a p-ary F:relation and let S be a q-ary Trelation. Let L C X(1, p) and let M G X(1, q). Res(R, L, S, M) g Tab({zl@x E EI(S))(z E El(R) and Adproj({{z. I’)},L) = AdprojNx, l’}},MN}).
Res(R, L, S, M) is called the Y:L - M restriction of R S. 4.30 Theorem. Let R be a p-ary F:relation. let S be a q-ary F:relation, let LEN(1.p) and let M cN(1, q). Res(R, L. S, M) is a p-ary Frelation. 4.3I Example. Let R = {{{{x. I’}, {y. 3’). {z. 6’11, 1’). by
NW, 47, Iy, 5’1, {x. 6’}}, I’}. {{{h, 6’1, Ih, 7’1, Ih, IO%, 1’1. {{IY. 1’1, Ih, 10’1,Ih, 2091, 1%
Let S = {{{{x.I’}, {z.4’}}.I’}, {{Ih, 6’1, {h, 9% 1’)).
Res(R, (1.3). S, {I, 2)) = I{{{x. 1’1,IY, 3’). {z* 6%. I’), Nh. 6’). {h, 7’). {h. 10’11,1’11.
4.32 Example. Let R be as in Example 4.7. Let S = MO, 1% {0,2’H, 1%. Res(R. {I. 41,S, {1,2)) = IMO. 1’1. {y. 2’). {z. 3’). {O.4’)). l’}ly,z E R and yz t z2= I} represents the twodimensional unit circle lying in the Y-Z plane in Cspace. The concept of function together with injection, surjection, bijection, etc. may easily be generalized to the framework under consideration, the definitions being the obvious ones. Only the definition of F:function is given here. 4.33 Definition. Let B = A,, A2 be sequence of 2 tabulets. Let R be a Trelation on B. R is a Y:function on B@(Dom(R,l)=A, and (Vx E EI(R))(Vy E El(R))((Elnum~,u(N,,(~,.*,(x)= Elnum~c~umcy,.l,(y))+ x = Y)).
5. THE ORDERING
Implementing set-theoretic operations on a computer requires that the operations be algorithmically-efficient. Suppose that for any two sets X and Y which are to be computer-represented, there are canonical and algorithmically-computable well orderings on X. Y and X U Y such that the ordering on X U Y, when restricted to X, yields the ordering on X, and when restricted to Y, yields the ordering on Y. In this case, the routines required for set operations will consist basically of sorts and merges. These are known to be algorithmically-efficient. Furthermore, such well orderings will allow rapid execution of set operations. In the context of the present paper, this is achieved as follows. Fist, a universe U of ZF-sets which is assumed to be well-ordered is given. The concepts of finitary Y:set and Y:element over CJ are precisely defined. A recursive technique for ordering these F:elements over U is then given. An important property of Telements is that they have natural representations as trees. This representation is developed, and it is shown that the process of comparing these elements under the induced order amounts to a “top-down” type parsing of the trees. The precise details are now developed. 5.1 Definition. (a) Let x be a F:element. The
Set-theoretic
Y:support ductively
of
x.
denoted
of data-structure
is defined
in-
If
= 0, T:supp(x)
T:rank({x})
>O,
Let
A
be a F:set.
= U{F:supp(p)/y
E
A is
of
be a ZF-set.
x be a F:element.
Y:supp(x)
F:support
The
X
is defined over
V if
Alepho, the cardinality
general,
of the set of all rank-one Y:elements
over V if each of its
and so on. Thus, the F:uni-
V is always very large. In
ZF-set
it is easy to see that over a ZF
Funiverse
be a Y:set. A is defined
From the above discussion, which are defined over V.
of all F:elements
(d) F(n):U(V)
struction
consis-
is no known
of the
technique
it is clear that the conon F:lI(V)
of a well-ordering
ordering on V is a hopelessly
denotes the subset of F:lI(V)
the cardinality
set V is always very much larger
of V.
than the cardinality
elements is. (c) The 2T:universe over V. denoted F:U( II), is the set
with a one-
V, it is easy to see that the cardinality of the set of all rank-zero Fzelements defined over V is
verse over a nonempty
c v.
(b) Let A
many sons. In fact, even starting
element universe
defined over V is (9(AIeph,,),
UI.7:supp(y)ly E El(A)}. 5.2 Definition. Let V (a) Let
It must of course, be pointed out that not all such trees infinitely
= {Vahx)}.
F:supp(x)
Val(x )}. (b)
199
representation
are as simple as those of 5.4, since a node may have
as follows.
(i) If .Y:rank({x}) (ii)
Y:supp(x),
foundations
ambitious
from
for constructing
on
P(X),
Remark: All of the above generalize IO F:sets and F:elements. except 5.2(c). Here one must stop at some ordinal o to keep the
that only those Y:elements
whose representative
trees
.T:universea set.
are finite will be of any use. Thus, it is reasonable
to try
The F:support over
of the F:element
from which
is just the set of all
it is built up, while the Yuniverse
V is just the set of all Y:elements
which
5.3 Example.
can be
Let V = {a, b, c, d} be a ZF-set.
The
defined over V.
are each F:elements
xI={a,lO’}, x2={{{b,2’},
{d,4’}}, 6’}, x,={c,2’}, x4= {a. 6’1, {{Id, 2% 3’11, 4’1, Ic,6’11, 12’1. S:supp(x,) = {a}, Fsupp(x2) = {b, d}, %supp(xl) = {c}, Fzsupp(x4) = {a, b, c, d}. {xl. x2, x3, x4} and 0 are Y:sets defined over V.
NI{d. I’},
Note that while the S:support 9:support
of a F:element
The natural
may now be made explicit. not be explicitly
of a F:set may be 0, the
is always nonempty.
representation
nique for visualization
as a tree
Since the tree structure
used in the theory, and computer
discussion
will be somewhat
informal.
as follows.
Given a Y:element
is the only
tree. If Val(x) Val(x) 5.4
son of Ind(x),
Example.
represented
of these
The
F:elements
elements
x
then
is itself
a
Example
5.3 are
by trees as follows.
is now x is a
Y((k):set) and IwI is finite))). (b)
is a finitary
x
S:set
G
(3n)(x
is a finitary
F(n):set).
Y:element
(c) u is a finitary finitary
comparing
immediate
the above
that
Y(‘(n):elements)
trary
~3 (3x)(y E x and x is a
9:set). finitary
definition
Y((n):sets
to 3.2, it is (resp.
finitary
are F((n):sets (resp. F((n):elements).
requirement
prevents
any “infinite
The
construc-
from taking place. It is easy to see that an arbiYzelement
is finitary
if and only if the tree which
represents it has a finite number of nodes and edges. 5.6 Definition.
Let V be a ZF set.
(a) The finitary Funiverse the set of all finitary
over V, denoted Eg(V),
Yzelements
is
which are defined over
V. denotes the subset of F:g(V)
consis-
ting of those elements which are F((n):elements. It is not difficult
to see that JY$(V)I
= AIepho if )VI is
12\6
6 X2=7
development
(a) Let x be a set and let n EN.
(b) F(n):g(V)
by recursion. of
5.5 Definition.
tions”
the
The basic rule is
This in fact can
reflects “top-down”
finitary F(n):set if (Vy E x)@w)@z E P’)(y = {w, z} and (w is a ZF element or ((3k E N) (k < n and w is a finitary
representation,
has each element of
so the process continues
of the trees. The formal
additional
and this is the entire
is a F:set, then lnd(x)
as a son. ‘Each
F:element,
will
x, the tree representing
Y:elements.
to conjecture
presented.
but is only a tech-
has Ind(x) as its root. If Val(x) is a ZF-element, Val(x)
parsing
set X. However,
it is reasonable
to well order these “finite”
Upon
of a F:element
applications,
be done, in a way which essentially
built up from V. An example should help make this clear. following
in computer
on an infinite
a well-order
ting of those elements which are F((n):elements.
ZF-sets
given a well-order
a well
task, since there
x2=
I 4.
x4=
a
I c
//1
b
d
i”i t d
a
I d It is clear that the representation
is unique,
and con-
versely. any tree whose leaves are ZF-elements non-leaves
are positive
with F:support
integers represents
and
a 9:element
just the set of leaves of the tree.
finite and IF:g( V)I = IV I if IV) is infinite. Therefore, it is reasonable to try to construct a well. order of Y:fJ(V) based upon a well order of V. This in fact can be done, as is now shown.
200
S. J. HEGNERand R. A. MAULUCCI
5.7 De~nition. Let x be a set and let 4 be a well order onx.Define~on&)by YaZ~lYI 1, put B, = UA,, A I,..., A. Put An+, = u, = min(b E B&S E A,)(bE c)). (YE A./A, E yt If A.+r has one element, it is minimal. Now clearly /At/ > 0 3 /Ar,,f < IAil for each i, hence this process cannot continue forever, and eventually some r4, will consist of one element. In this case, UAr is the minimal element of A0 under 2. Now if Y 22 and Za W, it is clear that Y is the minimal element of {Y, Z, w), and in particular Y 2 W. 5.9 copse. Consider the usual ordering s on &, which is clearly a well ordering. Let A = {{l, 2,%, 2101, {1,2,3,6,71, {1,2,3,4,9I, {2,3,4,5,61, W,6)3.
This ordering technique will now be used to well order the finitary y:universe over a well-ordered ZF set U. The ordering is first of all based upon Frank with the elements of lesser y:rank being lesser under the induced order ti*. The elements of each Erank are then ordered inductively. First, the indices of the elements are compared, the lesser indices icicle the lesser elements. If the indices are equal, the elements are compared by comparing their values. %rank 0 elements
(b) Define 4* = *;, +. 5.11 I%eorem. Let U be a set. If B is a well order of V, then a* is a well order of S:jj( U). Proof: If . . . a*X,BI* , . . 4*X24*X,+*X0 is a descending chain in pjj(LT). it must be that Erank({Xk+& I ~r~k(~X~~) for all k E N. Hence, after some m E N, the rank remains constant at p. Now Cidy 4k (r4k+, for each k EN. Hence it foliows easily by induction from 5.8 and the fact that I well orders P that QI, well orders Q)):S(U). Thus, c(* well orders F;NU). 5.12 Example. Let x ={(I, b, c, d} be a ZF set and define @ on x by u 4 b +i c 4 d. Clearly 4 well orders x. The y:elements of Example 5.3 are ordered x34*x, 4* x2 4*x*. detail, Trank({x,}) = In ~rank({x& = 0, and Ind(x3) = 2 < Ind(x,) = IO, so x34*x1. Fzrank({x2})= I, %rank({x4}) = 3, so x2 < x4. x3 < x2. xi
n+l
I (0 ==
are compared by direct comparison of their values. as these values are in U. F:rank n >O elements are compared by inductively ~suming that elements of Frank < n (i.e. their sons) can be compared; the sons are compared under the previously constructed ordering. The formal definition is now given. 5.10 Definition. Let lJ be a ZF set, and let g be a well ordering of U. (a) For each k EN, define Q, on ~~n):~(~) inductively by for a, b E Y(O):8 U), a a,b ca Ind(n) < Ind(b) or (Ind(a) = Ind(b) and Val(a)eVal(b)): for o, b E 3Vc + 1):3(U), a%.,,b e a%b or Erank({a}) < *rank({b}) or (r:rank({a}) = Fzrank({b}) and (Ind(o) < Ind(b) or (Ind(a) = Ind(b) and Vai(a)
;foreachnEP,t,“= 1
X
,foreachxEU. I t",-1
That is, to” = lx, I’), t: = {{t:+}, d). Let
f sd=l;foreachnEP,s.“= 1
X
That
/ii.
In
SLl
n-11
s"n-2
isso== ({{x, I’}}, 2’), LX ={(sL},
r0I=
;foreachnEP,r”“= I
I~
n+l
for each x E CJ. so=
k’#rEAf(l,n)),
(n + 1)‘).Finally. let
for each x E U.
Set-theoreticfoundationsof data-structurerepresentation
That is rox = {x, 1’1, r’,+, ={~r*“(kE-N(1,n-II),(n+lf’}. To order these elements by 6*, lkst note that for any x E U, n EN. T:rank(~f”x}) = Y’zrank({r,“))= n, while
Yzrank((s,,}) = 2n + 1. The elements are first of all compared according to root value. Finally, sons of the roots are compared. The resulting order is (9:rank = 0) (to” = roP)6*(tob = rob)+ (SC”= t,O = rt’)ce*fsob = 1,* = r,*)+* iS:rank= t2’ me*tzb Q* rza 4* rzb Q* (*rank = 2) ~~~‘~~,*4*f~~~*t,*9*r~~g*r~* (5rank=3).
1)
‘fngeneral, for n 2 2, n even, the T:eIements df F:rank n are ordered as
and for n 2 3, n odd, the Telements ordered as
of Y:rank n are
Two comments are in order regarding the construction of the order +. First of all, the construction of the ordering is not meant to imply any specific algorithm for its implementation (assuming that the base U is finite, so that it can bc constructed). Indeed, the best aigo~~rn for its computation would probabiy depend upon the kinds of 9:elements which are most likely to occur in a given implementation. The second comment regards the use of Frank in the ordering. It might appear that this would be an unnecessary extra step in any procedure for computing 4*. However. if the rank condition is omitted from the construction of 4*, infinite descending chains of increasing rank can be constructed, in a situation where the maximum rank of a Tzelement is finite (such as in an actual computer implementation), omission of the Y:rank condition will not give rise to any infinite descending chains. (A well order other than *g*will arise, of course.) However, elements of high rank could then occur at the beginning of the order, which could in fact increase computational wofk under certain circumstances. 6.FlRmNoRMALmRM
According to Codd[2]: “A relation is in first normal form if it has the property that none of its domains has
201
elements which are themselves sets.” Thus, each domain must consist entirely of ~elements. This presents a problem, since under any of the usual definitions, many objects necessary as domain eiements are sets and not individuals. For example. each natural number is a set and hence cannot be used as a domain element. In the theory presented in the present paper, a more useful definition of first normal form is possible, as iliustrated in the following. 6.1 ~nirjoa. An n-ary Rrelation R is in first normal form if and only if Wi E N 1,n)#x E DomM i) 3 Val(x) is a ZF element). Within this definition, a domain of a reiation in first normal form may contain any ZF eiement; however, it may not contain any Eretation. This provides a far more general definition of tirst normal form than that which restricts domain elements to urelements, while still preserving the intent of first normal, namely, preventing relations from being domain elements. Acknowkdgements-The authors wish to thank Dr. Robert W. Taylor for his continual interest, advice, and enco~men~ during the course of this research. This work was supportedin part by tbc Nationat Sconce Foundation under gt&OJ41829 and DCR72-03733A01 while tbe authorswere at tbe Universityof Massachusetts.Preparationof the tiaal monascriptwas supported
for the U.S. Dept.of Eaergyby LawrenceLivermoreLaboratory under coatract W-7~5-ENG~. [l] 9. F. Codd: A relational model of data for large shareddata banks. Commun. ACM 136). 377-387 (1970). [2] E. F. Cod& Further normalization of tbe data base relational model. In Data Base Systems (Edited by R. Rustin), pp. 33-64. Prentice Hall, EngIewoodCliffs. NJ. (1972). 131 _ D. L. Childs: Descriution of a set-theoreticdata structure. Proc. AFIPS FoflJo& Comptttct Conf...pp. 557-364 (1968). f4] D. L. ChiIds: Feasibiiity of a set-theoreticdata structure: a general structure hased on a reconstituteddefinit~n of a relation. Pm. fFlP Coup., pp. 420-431 (1968). [3] D. L. CbiMs: Extended set theory: a formalism for the &sign, implementation and operation of information systims. *IS Corp., Ann ~.-~~~~ (1974). I61 Hvmtitesis. W. - _ P. J. Cohen: scl ~&WY md Ihe ~~fi~~ .. A. Benjamin, New Y&k (1966). [7] E. MendeIson: introduction to ~ath~atical Logic. Van Nostrand, New York (1964). [S] P. Suppes:Axiantatic Set Theory.Dover, New York (1972). [9] A. Mostowski: fiber die Unabh@igkeit des Woblordnungssatlcsvom Ordnungsprinzip.Fund. Math. 32,2014!52
11939). 1101A. Levy: The interdependenceof certain consequencesof tbe axiom of choice. Fund. Mufh. 54, 135-137 (1%5).