Notas - Algebras

Embed Size (px)

Citation preview

  • 8/13/2019 Notas - Algebras

    1/4

    Many-sorted Algebras

    Alberto Pardo

    Grupo de Metodos Formales

    Instituto de Computacion

    Facultad de Ingeniera

    [email protected]

    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 setif it is a family of sets indexed by S, i.e.{Xs}sS.

    Definition 1 Asignature is a pairS, FwhereSis a set ofsortsand Fis a set offunctionsymbolssuch thatFis equipped with a mappingtype: F S S, which expresses thetype(or functionality) of each function symbol. One often writes f: s1 sn s to meanthat fF withtype(f) = (s1 sn,s).

    Example 1 LetNat be a signature for natural numbers

    Nat= {nat}, {zero, succ}where zero: nat

    succ: nat nat

    Definition 2 Let Xbe an S-sorted set of variables. For every sort s Swe define the setT(X)s, of terms of sort s with variables in X, as the least set containing:

    (i) every variable of sorts, i.e., Xs T(X)s

    (ii) every nullary function symbol (constant) c F with c: s

    (iii) every termf(t1, . . . , tn) wheref: s1 sn s Fand each tiis a term inT(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=, obtainingT(), which will be written simply as T. We assume the signatures are sensiblein the sensethat each sort admits at least one ground term.

    Definition 3 Given a signature = S,F, a -algebra A consists of an S-sorted familyof nonempty carrier sets{As}sSand a total function fA: As1 Asn As for each

    function symbol f: s1 sn s F.

    1

  • 8/13/2019 Notas - Algebras

    2/4

    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 fT(X)

    : T(X)s1 T(X)sn T(X)s for each f: s1 sn s F suchthat

    fT(X)(t1, . . . , tn)def

    = f(t1, . . . , tn)

    whereti T(X)si , i = 1, n. Once again, ifX= then we obtain the so-called ground termsalgebraT.

    Definition 4 A -homomorphismh : A Bbetween two -algebras A and Bis a family ofmaps {hs: As Bs}sSthat preserve the operations, i.e. for each f: s1 sn s Fand ai Asi (i= 1, n),

    hs(fA(a1, . . . , an)) =f

    B(hs1(a1), . . . , hsn(an))

    A -homomorphism that happens to be bijective is called a -isomorphism. Two -algebrasA and Bare said to be isomorphic (denoted by A=B) when there exists a -isomorphismbetween them, in other words, there are -homomorphisms h: A Band h :B A suchthat h h= idA and h h

    = idB, where idA and idB are the -homomorphisms identity forthe -algebras Aand B, respectively.

    Theclassof all -algebras is denotedAlg. Given a class C of -algebras, a -algebraIin C is called initialiff 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. IfI andJare both initial in a classC of-algebras, thenI=J.

    2. LetI andK be algebras inC such thatK=I. IfI is initial inC then so isK.

    Proof.

    1. If I and J are initial then there exist (unique) -homomorphisms h : I J andh :J Ibetween them. By composing we obtain, h h: I Iand h h :J J.But the identities idI : I I and idJ : J J are also -homomorphisms, so byuniqueness we have that h h= idI and h h

    =idJ.

    2. IfI is initial and K = I, then let hK : I K be the -isomorphism. For every -algebraA in C, there is an unique -homomorphismhA: I A. So,hAh

    1K

    :K Ais 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 thereforeg= hA h

    1K

    . In summary, there exists a unique -homomorphism fromK to any otheralgebra ofC, soK is initial.

    This proposition captures, in some sense, a notion of abstraction: it does not matter whatrepresentative of the class of initial algebras is being considered, it is only important the factthat it is initial.

    Given an S-sorted set of variables X and a -algebra A, a map v : X A is called avaluation(or assignment) of values in A to the variables ofX. The interpretationof a termt T(X) inA (with respect to a valuation v) is a map v

    :T(X) A such that:1

    also called the algebra of words or Herbrand universe

    2

  • 8/13/2019 Notas - Algebras

    3/4

    (i) v(x)def

    = v(x), for each x X

    (ii) v

    (f(t1, . . . , tn))

    def

    = fA

    (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 theunique homomorphic extension ofv to T(X).

    Proof. From the definitions ofT(X) andv, it turns out thatv is indeed a -homomorphism.

    Hence, it remains to show that v is the unique extension of v, that is, the unique -homomorphism that satisfies the diagram,

    X i T(X)

    v

    A

    v

    wherei: X T(X) is the embedding defined by i(x) =x. To prove this fact let us assumethe existence of another -homomorphism h: T(X) A which also satisfies that h i= v.We show that h= v by induction on the structure of terms.

    a) for every variablex X, v(x) =v(x) =h(x) by definition.

    b) for every constantc T(X),v

    (c) =cA

    =h(c) becausev

    andhare -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)) = fA(v(t1), . . . , v

    (tn)) (by def. v)

    = fA(h(t1), . . . , h(tn)) (by hypothesis)

    = h(f(t1, . . . , tn)) (h -homomorphism)

    Corollary 1 There is a unique-homomorphismh: T A from the ground terms algebrato any other-algebraA. In other words,T is initial in the classAlg.

    References

    [1] H. Ehrig and B. Mahr. Fundamentals of algebraic Specifications 1: Equations and InitialSemantics. EATCS Monographs on Theoretical Computer Science, 6, 1985.

    [2] J. A. Goguen, J. W. Thatcher, and E. G. Wagner. An Initial Approach to the Specification,Correctness and Implementation of Abstract Data Types. In R. Yeh, editor, CurrentTrends in Programming Methodology. Prentice Hall, 1978.

    3

  • 8/13/2019 Notas - Algebras

    4/4

    [3] J. A. Goguen, J. W. Thatcher, E. G. Wagner, and J. B. Wright. Initial Algebra Semanticsand Continuous Algebras. JACM, 24(1):6895, Janeiro 1977.

    [4] M. Wirsing. Algebraic Specifications: Semantics, Parameterization and Refinement. InLecture Notes of the State of the Art Seminar on Formal Description of Programming

    Concepts., Petropolis, 1989. IFIP TC2 WG 2.2.

    4