Sei sulla pagina 1di 4

Many-sorted Algebras

Alberto Pardo Grupo de M etodos Formales Instituto de Computaci on Facultad de Ingenier a pardo@fing.edu.uy
The aim of these brief notes is to review the fundamental concepts of many-sorted algebras. We follow the approach presented in [4]. Further details can be found in [3, 2, 1]. For any set S , we say that X is an S -sorted set if it is a family of sets indexed by S , i.e. {Xs }sS . Denition 1 A signature is a pair S, F where S is a set of sorts and F is a set of function symbols such that F is equipped with a mapping type: F S S , which expresses the type (or functionality) of each function symbol. One often writes f : s1 sn s to mean that f F with type(f ) = (s1 sn ,s). Example 1 Let Nat be a signature for natural numbers Nat = {nat}, {zero, succ} where zero: nat succ: nat nat

Denition 2 Let X be an S -sorted set of variables. For every sort s S we dene the set T (X )s , of terms of sort s with variables in X , as the least set containing: (i) every variable of sort s, i.e., Xs T (X )s (ii) every nullary function symbol (constant) c F with c : s (iii) every term f (t1 , . . . , tn ) where f : s1 sn s F and each ti is a term in T (X )si , i = 1, n. These sets form the family of sets {T (X )s }sS , which we shall refer to as T (X ). Note that the terms in the family {T (X )s }sS are elements (words, strings) of the set (F X { (, ),, }) . In case we want terms without variables (called ground terms) we take X = , obtaining T (), which will be written simply as T . We assume the signatures are sensible in the sense that each sort admits at least one ground term. Denition 3 Given a signature = S, F , a -algebra A consists of an S -sorted family of nonempty carrier sets {As }sS and a total function f A : As1 Asn As for each function symbol f : s1 sn s F . 1

From the family of sets of terms with variables in X , T (X ), we can build a -algebra, called the algebra of terms1 and denoted by T (X ), with carrier sets {T (X )s }sS and a function f T (X ) : T (X )s1 T (X )sn T (X )s for each f : s1 sn s F such that f T (X ) (t1 , . . . , tn ) = f (t1 , . . . , tn ) where ti T (X )si , i = 1, n. Once again, if X = then we obtain the so-called ground terms algebra T . Denition 4 A -homomorphism h : A B between two -algebras A and B is a family of maps {hs : As Bs }sS that preserve the operations, i.e. for each f : s1 sn s F and ai Asi (i = 1, n), hs (f A (a1 , . . . , an )) = f B (hs1 (a1 ), . . . , hsn (an )) A -homomorphism that happens to be bijective is called a -isomorphism. Two -algebras A and B are said to be isomorphic (denoted by A = B ) when there exists a -isomorphism between them, in other words, there are -homomorphisms h : A B and h : B A such that h h = idA and h h = idB , where idA and idB are the -homomorphisms identity for the -algebras A and B , respectively. The class of all -algebras is denoted Alg . Given a class C of -algebras, a -algebra I in C is called initial i for every A in C there exists a unique -homomorphism h : I A. The following proposition states that initial algebras are unique up to isomorphism. Proposition 1 1. If I and J are both initial in a class C of -algebras, then I = J. 2. Let I and K be algebras in C such that K = I . If I is initial in C then so is K. Proof. 1. If I and J are initial then there exist (unique) -homomorphisms h : I J and h : J I between them. By composing we obtain, h h : I I and h h : J J . But the identities idI : I I and idJ : J J are also -homomorphisms, so by uniqueness we have that h h = idI and h h = idJ . 2. If I is initial and K = I , then let hK : I K be the -isomorphism. For every 1 algebra A in C, there is an unique -homomorphism hA : I A. So, hA h K :KA is a -homomorphism as well. If g : K A is any other -homomorphism then we can compose g hK : I A, but by initiality we have that g hK = hA and therefore 1 g = hA h K . In summary, there exists a unique -homomorphism from K to any other algebra of C, so K is initial. 2 This proposition captures, in some sense, a notion of abstraction: it does not matter what representative of the class of initial algebras is being considered, it is only important the fact that it is initial. Given an S -sorted set of variables X and a -algebra A, a map v : X A is called a valuation (or assignment) of values in A to the variables of X . The interpretation of a term t T (X ) in A (with respect to a valuation v ) is a map v : T (X ) A such that:
1

def

also called the algebra of words or Herbrand universe

(i) v (x) = v (x), for each x X (ii) v (f (t1 , . . . , tn )) = f A (v (t1 ), . . . , v (tn )), for each f : s1 sn s F and ti T (X )si , i = 1, n Proposition 2 Given a valuation v : X A, the interpretation v : T (X ) A is the unique homomorphic extension of v to T (X ). Proof. From the denitions of T (X ) and v , it turns out that v is indeed a -homomorphism. Hence, it remains to show that v is the unique extension of v , that is, the unique homomorphism that satises the diagram, X iT (X ) v A
?
def

def

@ @ @ v @ @ R

where i : X T (X ) is the embedding dened by i(x) = x. To prove this fact let us assume the existence of another -homomorphism h : T (X ) A which also satises that h i = v . We show that h = v by induction on the structure of terms. a) for every variable x X , v (x) = v (x) = h(x) by denition. b) for every constant c T (X ), v (c) = cA = h(c) because v and h are -homomorphisms. c) for every composite term f (t1 , . . . , tn ) T (X )s , with f :1 sn s F and ti T (X )si , assume as induction hypothesis that v (ti ) = h(ti ), for i = 1, n. Then, we can calculate the following: v (f (t1 , . . . , tn )) = = = f A (v (t1 ), . . . , v (tn )) f A (h(t1 ), . . . , h(tn )) h(f (t1 , . . . , tn )) (by def. v ) (by hypothesis) (h -homomorphism) 2 Corollary 1 There is a unique -homomorphism h : T A from the ground terms algebra to any other -algebra A. In other words, T is initial in the class Alg .

References
[1] H. Ehrig and B. Mahr. Fundamentals of algebraic Specications 1: Equations and Initial Semantics. EATCS Monographs on Theoretical Computer Science, 6, 1985. [2] J. A. Goguen, J. W. Thatcher, and E. G. Wagner. An Initial Approach to the Specication, Correctness and Implementation of Abstract Data Types. In R. Yeh, editor, Current Trends in Programming Methodology. Prentice Hall, 1978.

[3] J. A. Goguen, J. W. Thatcher, E. G. Wagner, and J. B. Wright. Initial Algebra Semantics and Continuous Algebras. JACM, 24(1):6895, Janeiro 1977. [4] M. Wirsing. Algebraic Specications: Semantics, Parameterization and Renement. In Lecture Notes of the State of the Art Seminar on Formal Description of Programming Concepts., Petr opolis, 1989. IFIP TC2 WG 2.2.

Potrebbero piacerti anche