Content uploaded by Johnjules Meyer
Author content
All content in this area was uploaded by Johnjules Meyer
Content may be subject to copyright.
27

I/OCOMPUTABLE DATA STRUCTURE
S
J
. A
. Bergstra and J
.J . Ch
. Meye
r
Department of Computer Scienc
e
University of Leide
n
Wassenaarseweg 8
0
Postbus 951
2
2300 RA LEIDE
N
The Netherland
s
According to ADO [6] a data structure is a manysorted algebra tha
t
satisfies various equations and conditional equations
. Several author
s
[3], [4], [5], [8], [9] have emphasised that visible and nonvisible sort
s
should be distinguished ;objects that belong to an invisible sort show
a
socalled observable behaviour and all of the authors mentioned point ou
t
that on these sorts terminal equivalence rather than initial equivalenc
e
is the more interesting congruence relation
. Objects that have indistin
guishable observable behaviour are made equivalent in this terminal congruence
.
We have in mind to present the reader with a survey of some terminolog
y
and several new definitions, notably that of an I/0computable data structure
.
We shall define I/0equivalence and prove that for each data structure A ther
e
is a computable data structure B that is I/Oequivalent to A
. This very simpl
e
result may prove to be significant
. First of all it shows the adequacy of th
e
concept of an I/0computable data structure, as in principle all such dat
a
structures can practically exist
. Moreover this fact suggests that both initia
l
and terminal semantics of equations may differ from what actually occurs in a
n
implementation
. This means that both should be considered as theoretica
l
concepts that can be used to describe a data structure, given certain purposes
.
Certainly this result gives a post facto justification of the restrictio
n
to computable algebras that was made in 11] and l2]
.
Some technical terms have to be introduced in our discussion now
. Let
A
be an algebra with sort
s
We assume A to be finitely generated by its finite signature E (i
.e . A i
s
minimal)
. Se,
. .
.,Sk1 are the visible sorts, Sk,
. .
.,5g1 the invisible ones
.
The terminology visibleinvisible being not so pleasant in the long run, w
e
propose to call the visible sorts
I/Osorts
and the invisible sorts
interna
l
sorts
. Elements of I/Osorts can be seen as
tokens
on which an equalit y
relation is fixed
. Elements of the internal sorts are the true data structures
.
It is on the internal sorts that investigating the variety of congruenc
e
relations that respect the I/0behaviour (i
.e
. the word problem on the I/0

sorts) is interesting
.
28

Coming back to the structure A the sorts SO,
.
.
.,Sk1 are I/Osorts an
d
Sk,
. .
.,Se1
are internal sorts
. We choose
03
0 , . .
.,03
81
as disjoint copies o
f
w,
the nonnegative integers . A coordinatization of A is a tuple of mapping
s
ao,
. .
.,ae1
plus a collection of tracking functions
o
f
for all f
E
,
that satisfy the following conditions
:
a
i : w
. + S
i
a surjective mapping for each f E Z,f
: S
i1
x
. .
.xS
ik
b S
µ
the diagram
f
S x
.
.
.
. x S
S
i
1
i
k
a
. X
. .
.Xa
.
a
1
1
l
k
w
x
. . .
. x
w
.
i
1
1
k
f
a
commutes
. Moreover, the functionsa
f
are computable
.
On each of the
w
i
a congruence  . is induced as follows
:
n
=a
m
p
a.(n)
= a
.(m)
.
Two important definitions can now be stated
.
DEFINITION
I
.
A
is
computable if there is a coordinatization
a
.,
6
r
(f
E
z
)
of A such that for each i the congruence relation
a
is computable
.
DEFINITION
II
.
A
is _I/0computable if there is a coordinatization
ai,
Qf
(f E E
)
of A such that for each i < k (i
.e
. for all I/0sorts)
E .
is computable
.
These definitions are compatible with the definitions in [1] and [2]
.
We propose that a
data
structure
is an arbitrary I/0computable minima
l
algebra
. The condition that the I/Obehaviour of a data structure is computabl
e
is justified in a deterministic context, as it is inconceivable that any othe
r
data structures have an effective implementation (realization)
.
An algebra A is semicomputable if for all sorts the word problem is semi

computable
. A is called
cosemicomputable if for all sorts the complement o
f
the word problem is semicomputable
. Clearly if
A
is a data structure thes
e
definitions refer to the internal sorts only
.
29

Two data structures A and B are called
comparable,
according to KAMIN [3
]
if they have the same signature
.
DEFINITION III
.
Let A,B be comparable data structures . A and B are calle
d
I/0equivalent if for all I/Osorts S and for all terms
t
1 s
,
t2s
of sort S
:
A
I=
t1s
t25
B
t
1
s
=
t2
s
I/Oequivalence of A and B implies that both have identical word problems o
n
the I/0sorts
.
A
data abstraction
K is a collection of I/Oequivalent data structures
. A E
K
is called an
implementation
of K
.
Given a data structure A we denote with G
I/0
(A) the set of all close
d
term identities t
1 s
= t2s that hold true in A for I/Osorts S
. Obviously ou
r
convention implies that G
I/0
(A) is a decidable set of pairs of terms
.
Suppose that A satisfies equations (or conditional equations) E
. This lead
s
to a natural data abstraction
:
DA(G
I/0
(A) U E) =
{BIB
is
I/Oequivalent
with A, and
B
I=
E}
.
TERMINAL SEMANTICS
.
PROPOSITION
I
.
Let A be a data structure of signature E
. There exists a dat
a
structure B, I/0equivalent to A with the following property
:
If C is I/Oequivalent to A then there is a homomorphism (p
: C ) B
.
B is isomorphic to A/= for a congruence = that is usually called the termina
l
congruence on A
.
PROOF
.
See [4], [5], [7], [8]
.
T
z
denotes the term algebra of signature E
.
PROPOSITION
II
.
The terminal congruence on
A,E,
seen as a congruence on
T
z
,
is cosemicomputable
.
PROOF
.
Straightforward
.
30

On the other hand, given
GI/0
(A) and a finite set of (conditional) equation
s
E the initial algebra of
GI/0
U E is semicomputable, as are all initia
l
algebras of decidable sets of axioms
.
In a forthcoming note we will show that a data structure A exists fo
r
which DA(G
I/0
(A) U E) has no computable element with E a set of equation
s
such that T
z,E
A
.
Here T
z'E
is the initial algebra in ALG(Z,E), or, differently
:
y=
E
wher
e
= E
is the congruence of Eprovable equality on T
z
.
In this case there is no computable congruence between the initial and th
e
terminal one
.
COMPUTABLE IMPLEMENTATIONS
.
We will next consider the case, where G
I/0
(A) is given but E = 0
.
The question is
: must there exist a computable implementation of DA(GI/0(A))
?
This is indeed the case
:
PROPOSITION III
.
Let A be a data structure then T ,
is a computabl
e
algebra in DA(GI/0(A))
.
G
I/0
(
A
)
PROOF
.
Choose for each I/Osort S a sequence tl such that all elements of
S
occur as the value of tS for exactly one i
. Moreover, the sequence ti must b
e
uniformly given from i . If S happens to be finite in A then the sequence i
s
finite as well
.
Introduce a function
f
s
for each S such that in a computable way
f s
:
T
z
)

and A
I=
r = i
s
for
all
terms r of sort S
.
fs
(
r
)
Now one defines the congruence = on T
z
as follows
:
for an I/Osort S
: i
s
r
s
iff A
1=
i
s
= r
s
( G
I/0
(A)
i
s
= r
s
fS(tS) = f
s
(r
s
)
.
Notice that f
s (t
s
) is a unique normal form of i
s
under the rewrite rul
e
is 
fs
(
ts
)
for an internal sort S one
also introduces
a
unique
notation
F(T
s
)
fo
r
each term
T
s
.
F(T
s
)
results from
T
s
by
replacing
each of its
subterms t
To f
an I/Osort T by f
T (t
T
)
.
We put i
s
= r
s
iff
F(T
s
)
= F(r
s
) (syntactic
equality
is meant here)
.
is a computable congruence relation that extends G
I/0
(A)
.
In fac
t
Tz /
E
=
Tz
GI/O(A)
E DA(GI/0(A))
.
31

CONCLUDING REMARKS
.
In [1] and [2] a fruitful format of mathematical problems is as
follows
:
Given a computable algebra, allow the addition of hidden enrichmen
t
functionsand then investigate initial algebra specifications of the enriche
d
algebra
.
The present situation rather suggests to start with
G
110
(A) for some dat
a
structure A of signature E which has a specification (Z,E) with (conditional
)
equationsE
. The
problem
is now to find another specification (E,E
0
)
(of
a n
algebra B,1/0equivalent to A) such that E
O
has some
additional
propertie
s
(for instance being sufficiently powerful to prove some partial correctnes
s
conditions)
.
The interesting issue here is that several of such requirements may b
e
incompatible
. This is the case with two specifications E
O
and E
1
of I/0

equivalent data structures A and B such that DA(G
1/0
(A)
E O
U E
1
)  0
.
Of course this can only happen if E
O
or E
1
contain conditional equation
s
that are not preserved under homomorphisms
.
Mathematically speaking one introduces a collection SPEC(G
I/0 (A)) of al
l
finite sets of conditional equations E such that
T
7,E
is I/Oequivalent to A
.
On this collection there is a partial order C defined by E
0
C E
1
if
al
l
axioms in E
O
can be proved from E
1
. In the general case E will neither sho w
a smallest nor a largest element
. This setting seems appropriate for us fo
r
the mathematical investigation of specifications not allowing hidden functions
.
REFERENCE
S
[1] Bergstra, J
.A
. & J
.V
. Tucker, Algebraic specifications of computabl
e
and semicomputable data structures, Mathematical Centre, Depart
ment of Computer Science Research Report IW 115, Amsterdam 1979
.
[2] Bergstra, J
.A
. & J
.V
. Tucker, Equational specifications for computabl
e
data types
: six hidden functions suffice and other sufficienc
y
bounds, Mathematical Centre, Department of Computer Science Researc
h
Report IW 128, Amsterdam 1980
.
[3] Botha, K
. Institutsbericht, Humboldt Universitat zu Berlin [1979]
.
[4]
Broy, M
. & M
. Wirsing, The theory of recursive functions as an abstrac
t
type and its semantical models
. Report, Institut fur Informatik
,
Technische Universitat Munchen [1980]
.
[5] Giarattana, F
. Gimona & V
. Montanari, Observability concepts in abstrac
t
data types specification, Proc
. of 5th MFCS symposium, LNCS 4
5
(576587) 1976
.
32

[6] Goguen, J
.A
., J
.W
. Thatcher & E
.G
. Wagner, An initial algebra approac
h
to the specification, correctness and implementation of abstrac
t
data types, in R
.T
. Yeh (ed
.)
. Current trends in programmin
g
methodology IV, Data Structures, Prentice Hall, Engelwood Cliffs
,
New Jersey, 1978, 80149
.
[7] Hornung, G
. & P
. Raulefs, Terminal algebra semantics and retractions fo
r
abstract data types . Proceedings of ICALP '80, Spr
. LNCS 85
.
[8]
Kamin, S
., Final data type specifications : a new data type specificatio
n
method, 7th POPL Conference, Las Vegas, ACM 1980, 131138
.
[9]
Kapur, D
. & M
.K
. Srivas, Expressiveness of the operation set of a dat
a
abstraction, in 7th ACM POPL Conference, Las Vegas, ACM 1980
.