A parameterization process, functorially

The parameterization process used in the symbolic computation systems Kenzo and EAT is studied here as a general construction in a categorical framework. This parameterization process starts from a given specification and builds a parameterized speci…

Authors: Cesar Dominguez, Dominique Duval (LJK)

A parameterization process, functorially
A parameterization pro cess, functorially C ´ esar Dom ´ ınguez ∗ Dominique Duv al † August 31., 2009 Abstract. The parameteriza tion pro cess used in the symbolic computation systems K enzo and EA T is studied her e as a general constr uction in a categoric a l fr a mework. This par ameterization pro cess starts from a given sp ecification and builds a parameter ized sp ecification by adding a par ameter a s a new v ar iable to some op erations. Given a mo del of the parameter ized sp ecification, each in terpreta tio n of the para meter, called an ar gument, pr ovides a mo del of the given specifica tion. Moreover, under some relev ant termina lity a ssumption, this cor resp ondence b etw een the a rguments and the models of the giv en specifica tion is a bijection. It is prov ed in this pap er that the parameterization proce s s is pro vided b y a functor and the subsequent para meter passing pro cess by a natural transformation. V arious categor ical notions are used, mainly adjoint functors, pushouts and lax colimits. 1 In tro duction Kenzo [8] and its pre de c e ssor EA T [16] are soft ware systems developed b y F. Serger aert. They a re dev oted to Symbolic Computatio n in Alge br aic T opo logy . In particular , they ca rry out calculatio ns of homology groups of complex topo logical space s , namely iterated lo op spa ces. B y means of EA T a nd Kenzo, some homology g roups that ha d never been obtained with an y other method, neither theoretical nor automatic, hav e b een computed. In view o f the obta ine d results, so me years ago , the firs t author of this pa p er b ega n the formal study of the pr o grams, in order to rea ch a go o d understanding on the in ternal calculatio n pro ce sses of these s oft ware sy stems. In particular, our study of the data types used in E A T a nd Kenzo [11, 6, 7 ] shows that there are tw o different lay ers of data structures in the systems. In the first lay er, one finds the usual abs tr act data types, like the type of in tegers . In the s econd lay er, one deals with algebra ic s tructures, like the str ucture o f gr oups, which are implemen ted thanks to the abstract data types b e longing to the first lay er. In addition, we rea liz e d that in a system s uc h as EA T, we do not simply implement one g roup, but more gener ally p ar ameterize d families of gr o ups. In [11] a n op eration is defined, which is called the imp construction b eca us e o f its role in the implemen tation pro cess in the system EA T. Sta rting from a sp ecification Σ in whic h some op era tions are lab elled as “pure” [7], the imp construction builds a new sp ecification Σ A with a distinguished sort A whic h is added to the domain of each non-pure opera tion. It follows tha t each implementation of Σ A defines a family of implementations o f Σ dep ending on the choice o f a v a lue in the interpretation of A . B esides, working with the imp construction in [11] we w ere a ble to prove that the implementations of EA T algebra ic structures are as g eneral a s po ssible, in the sense that they are ingredients of terminal o b jects in certa in ca tegories o f mo dels; this re sult is ca lled the exact p ar ameterization pr op erty . Later on, led b y this c har a cterization of EA T algebr a ic structures, in [11] we reinterpreted our results in terms o f ob ject-or ient ed technologies like hidden alg ebras [9] or coa lgebras [17]. This pape r dea ls with genera lization by parameter iz a tion in the sens e of Kenzo and EA T, so that our p ar ameters are sym b olic co nstants of a given type, that will b e replaced by ar guments which a re elements in ∗ Departamen to de Matem´ aticas y Computaci´ on, Universidad de La Rio ja, Edificio Vives, Luis de Ulloa s/n, E-26004 Logro˜ no, La Rio ja, Spain, cesar.domi nguez@unirio ja.es. † Laboratoire Jean K un tzmann, Unive rsi t ´ e de Grenoble, 51 r ue des m ath ´ ematiques, BP 53, F-38041 Grenoble C´ edex 9, F rance, Dominique.Duv al@imag.fr. 1 a given set. The notion of parameter ization in programming a nd sp ecification lang uages bea rs se v era l mean- ings, where the para meter ma y b e a type o r a spec ification. F or instance, in ob ject-oriented pro g ramming, parametric p olymo rphism is c alled g eneric prog r amming, in C++ it is characterized by the use o f template parameters to represent abs tract data types . On the other hand, in algebra ic sp ecifications , a parameterized sp ecification is defined as a morphism o f sp ecifica tio ns wher e the para meter is the source and the para meter passing is defined as a pushout [2]. The framework for this pap er is pr ovided by e quational lo gic , considered from a categorical p oint of view. An eq ua tional theory , o r simply a theory , is a ca tegory with chosen finite pro ducts. A mo del M of a theor y Θ is a functor M : Θ → Set which maps the chosen pro ducts to cartesia n pro ducts. A theory Θ ca n be presented by a sp ecificatio n Σ, this means that Σ generates Θ. In this paper , w e a re not interested in sp e cifications for themselves, but as pres en tations of theo r ies. So, sp ecifications are used mainly in the examples, and we feel fre e to modify a sp ecifica tio n whenever needed as long a s the presented theory is not changed. The p ar ameterization pr o c ess studied in this pap er is essentially the “ imp construction” of [11]. Sta rting from a theory Θ it provides a p ar ameterize d the ory Θ A by a dding a t yp e of p ar ameters A and by transfor ming each term f : X → Y in Θ int o a parameterized term f ′ : A × X → Y in Θ A . Then clea r ly Θ A generalizes Θ: the models o f Θ can b e identified to the mo dels of Θ A which interpret the t yp e of parameters A as a singleton. Ther e is another way to r elate Θ a nd Θ A , called the p ar ameter p assing pr o c ess , which runs as follows. By a dding to Θ A a constant a (called the p ar ameter ) of type A we get a the ory with p ar ameter Θ a , such that for each para meterized term f ′ : A × X → Y in Θ A there is a term f ′ ( a, − ): X → Y in Θ a . Then the p ar ameter p assing morphism j : Θ → Θ a maps ea ch term f : X → Y in Θ to f ′ ( a, − ): X → Y in Θ a . Given a mo del M A of Θ A an ar gu ment α is a n element of the set M A ( A ), it provides a model M A,α of Θ a which extends M A and satisfies M A,α ( a ) = α . Tha nks to the para meter passing morphism, the mo del M A,α of Θ a gives rise to a mo del M of Θ such that M ( f ) = M A ( f ′ )( α, − ) for each ter m f in Θ. Moreover, under some relev a n t terminality as s umption on M A , this corr esp ondence b etw een the arguments α ∈ M A ( A ) and the mo dels of Θ is a bijection: this is the ex act p ar ameterization pr op ert y . The parameteriza tion pro cess and its asso ciated par ameter passing pro cess hav e been de s crib ed for each given theory Θ , but in fact they hav e the prop erty of pres erving the theory structure, which can be stated precisely in a categorica l framework: this is the a im of this paper . The par ameterization pro ce s s is defined as a functor : the constructio n of the par ameterized theory Θ A from the given theory Θ is a functor, whic h in addition is left adjo int to the construction of a co K leisli ca tegory . The par ameter pass ing pro ce ss is de fined as a natur al tr ansformation , along the following lines. Firs t, the construc tio n of the theory w ith parameter Θ a from the para meterized theory Θ A is s imply a pushout c o nstruction, such that the constr uction of Θ a from Θ is a functor . Then, each parameter passing morphism j : Θ → Θ A is defined from a lax colimit of theories, in s uch a wa y that the par ameter passing morphisms a re (essent ially) the comp onents of a natural transformatio n from the iden tity functor to this functor. A first v ers ion of this a pproach can be found in [3], and a more a bs tract p oint of view, relying o n diagr ammatic lo gic , is prese n ted in [5]. With resp ect to the previous pap ers like [11], we pr ovide a new int erpr etation of the par ameterization pro ces s a nd in addition a n int erpr etation of the par ameter passing pro cess. More ov er, we take into acco un t the fact that there is a pur e pa rt in the given theory , and w e derive the exact parameter ization pro per t y from a more general result which do e s not rely on the exis tence of a terminal mo del. Equational theories are defined in section 2, then the pa r ameterization pro cess and the par a meter pa ssing pro cess are studied in section 3. V arious examples are presen ted. Mo s t of the categ orical notions used in this pap e r can b e found in [14] or in [1 ]. W e omit the size issues: for instance mo st colimits should b e small. A gr aph is a directed multigraph, and in or der to distinguish betw een v ario us k inds of structures with an underlying graph, we sp eak ab out the obje cts a nd morphi sms of a category , the typ es and terms of a theory or a sp ecification a nd the p oints and arr ows of a limit sketc h. 2 2 Definitions 2.1 Equational theories and sp ecifications In this pap er, eq uational logic is s e e n from a categor ical po int of view, as for instance in [15]. Definition 2.1 The catego ry T e q of e qu ational the ories is made of the ca tegories w ith chosen finite pro ducts together with the functors whic h preserve the c hosen finite pro ducts. In addition, T e q can b e seen as a 2- category with the natural tra nsformations as 2 -cells. Equational theories ar e c a lled s imply the ories . F or instance, the theo r y Set is made o f the categor y of sets with the ca rtesian pr o ducts as chosen pro ducts. Remark 2.2 The cor resp ondence b etw een equationa l theo ries in the universal alg ebra style (as in [1 3]) and equational theories in the c ategorica l st yle (as defined here) can b e found in [15]. B asically , the sorts and pro ducts of so r ts be c o me o b jects, still called t yp es, the op er ations and t erms b eco me mor phisms, s till ca lle d terms (the variables co rresp ond to pro jections, a s in example 2.6) a nd the e quations b ecome equalities: for instance a co mm utative square g 1 ◦ f 1 = g 2 ◦ f 2 means that there is a term h s uch that g 1 ◦ f 1 = h and g 2 ◦ f 2 = h . A more subtle p oint of vie w on equatio ns is presented in [4]. Definition 2.3 A (strict) mo del M of a theory Θ is a morphism of theories M : Θ → Set and a morphism m : M → M ′ of mo dels o f Θ is a natural trans formation. This forms the categor y Mo d (Θ) o f mo dels of Θ. F or every morphism of equational theories θ : Θ 1 → Θ , w e denote by θ ∗ : Mo d (Θ) → Mo d (Θ 1 ) the functor which maps each mo del M of Θ to the mo del θ ∗ ( M ) = M ◦ θ of Θ 1 and each morphism m : M → M ′ to m ◦ θ . In addition, for ea ch mo del M 1 of Θ 1 , the categor y of mo dels of Θ ex tending M 1 is denoted Mo d (Θ) | M 1 , it is the sub categ ory of Mo d (Θ) ma de o f the models M suc h that θ ∗ ( M ) = M 1 and the morphisms m such that θ ∗ ( m ) = id M 1 . Whenever θ is surjective on types , the ca tegory Mo d (Θ) | M 1 is discrete. A theory Θ can b e descr ibed by some pre sent ation: a pr esent ation of an equational theory Θ is a n equational sp ecificatio n Σ which generates Θ; this is denoted Θ ⊣ Σ. Two sp ecifications are called e quivalent when they prese nt the sa me theory . An equational sp ecification ca n b e defined either in the universal alge br a style as a signature (made of sor ts and op erations) together with equa tio nal axioms, or eq uiv alently , in a more categor ical style, as a finite pro duct sket ch, see [12], [1 ]. The corres po ndence b etw een the universal algebra a nd the categorical p oints of view runs as in remark 2.2. Definition 2.4 The catego ry S e q of e qu ational sp e cific ations is the ca teg ory o f finite pro duct sketches. With (generalized) natural tra ns formations as 2 - cells, S e q can be seen a s a 2- category . Equational sp ecifica tions are called simply sp e cific ations . The category T e q can be identified to a sub- category of S e q (more precisely , to a reflec tive sub c ategory of S e q ). When Σ is a presentation o f Θ, a mo del of Θ is determined by its restriction to Σ, which is called a mo del of Σ, a nd in fact Mo d (Θ) can be identified to the category Mo d (Σ) o f mo dels of Σ. W e will rep eatedly use the fac t that T e q and S e q , as well a s other catego ries of theories and of sp eci- fications, hav e colimits, and tha t left adjoint functors preser ve colimits. In addition every s pecifica tion is the colimit of a diag r am of elemen tary sp ecificatio ns. The element ary sp e cific ations are the sp ecificatio ns resp ectively made of: a t yp e, a term, an identit y term, a comp osed term, a n -ary pro duct and a n -ary tuple for all n ≥ 0, or only for n = 0 and n = 2 , as in fig ur e 1. Let us consider a theo ry Θ pre sent ed by a sp ecification Σ, then Σ is the colimit of a dia gram ∆ of elementary sp ecifications, and Θ is the colimit of the diag ram of theories gener a ted by ∆. 3 subscript E Σ E t yp e (o r sort) Type X term (or op eration) Term X f Y selection o f identit y Selid X id X X comp osition Comp X f g ◦ f = Y g Z terminal type 0-Pro d 1 collapsing 0-Tuple X h i X 1 binary pro duct 2-Prod X X × Y p X p Y Y pairing 2-Tuple X Z f g h f ,g i = = X × Y p X p Y Y Figure 1 : Elementary sp ecifications 2.2 Examples Example 2.5 Let us consider the theor y Θ op , 0 presented b y tw o types X, Y , and the three following the- ories ex tending Θ op , 0 (the subscript op stands for “op eration”, since Θ op is pr e sent ed by the ele mentary sp ecification for ter ms or op erations Σ Term ). The unit t yp e is denoted 1 and the pro jections are not giv en any name. Θ op ,A ⊣ A A × X f ′ X Y Θ op ,a ⊣ A A × X f ′ 1 a X Y Θ op ⊣ X f Y These theories are related by v a rious morphisms (a ll of them preserving Θ op , 0 ): θ op ,A : Θ op ,A → Θ op maps A to 1 and θ op ,a : Θ op ,a → Θ op extends θ op ,A by ma pping a to id 1 , while j op ,A : Θ op ,A → Θ op ,a is the inclusion. In addition, here are tw o o ther presentations o f the theory Θ op ,a (the pro jectio ns are omitted and 1 × X is ide ntified to X ): A A × X f ′ 1 a X = a × id X f ′′ Y A A × X f ′ = Y 1 a X a × id X f ′′ Y id Y 4 It is clear fr o m these pr esentations o f Θ op ,a that there is a mor phism j op : Θ op → Θ op ,a which maps f to f ′′ . In a ddition, θ op ,a ◦ j op ,A = θ op ,A and there is a natural transfor mation t op : j op ◦ θ op ,A ⇒ j op ,A defined by ( t op ) X = id X , ( t op ) Y = id Y and ( t op ) A = a : 1 → A . Θ op ,A θ op ,A Θ op Θ op ,A j op ,A θ op ,A = Θ op ,a θ op ,a Θ op Θ op ,A j op ,A θ op ,A ⇑ t op Θ op ,a Θ op j op P arameterization pro cess (construction of Θ op ,A from Θ op ). The theory Θ op ,A is obtained fro m Θ op by adding a type A , ca lled the typ e of p ar ameters , to the domain of the unique term in Θ op . Then Θ op ,A can be seen as a gener alization of Θ op , since each mo del M o f Θ op can be identified to a mo del of Θ op ,A where M ( A ) is a singleton. P arameter passi ng pro cess (co nstruction of Θ op ,a from Θ op ,A and of a mor phism from Θ op to Θ op ,a ). The theory Θ op ,a is obtained fr o m Θ op ,A by a dding a constant term a : 1 → A , ca lled the p ar ameter . A mo del M a of Θ op ,a is made of a mo del M A of Θ op ,A together with an element α = M a ( a ) ∈ M A ( A ), so that w e c an denote M a = ( M A , α ). Now, let M A be some fixed mo del of Θ op ,A , then the mo dels M a of Θ op ,a extending M A corres p ond bijectively to the elemen ts o f M A ( A ) by M a 7→ M a ( a ), so that we g et the p ar ameter adding bijection (the categor y Mo d (Θ op ,a ) | M A is discrete): Mo d (Θ op ,a ) | M A ≃ → M A ( A ) by M a = ( M A , α ) 7→ M a ( a ) = α . On the o ther hand, each mo de l M a = ( M A , α ) of Θ op ,a gives r ise to a mo del j op ∗ ( M a ) of Θ op such that j op ∗ ( M a )( X ) = M a ( X ) = M A ( X ), j op ∗ ( M a )( Y ) = M a ( Y ) = M A ( Y ) and j op ∗ ( M a )( f ) = M a ( f ′′ ) = M A ( f ′ )( α, − ). Now, let M A be some fixed mo del o f Θ op ,A and M 0 its restrictio n to Θ op , 0 , then for each mo del M a = ( M A , α ) of Θ op ,a extending M A the model j op ∗ ( M a ) of Θ op extends M 0 . This y ields the p ar ameter p assing function (the c a tegories Mo d (Θ op ,a ) | M A and Mo d (Θ op ) | M 0 are dis crete): Mo d (Θ op ,a ) | M A → Mo d (Θ op ) | M 0 by M a 7→ j op ∗ ( M a ) . Exact parameterization. Let M 0 be any fixed mo del of Θ op , 0 , it is made of tw o sets X = M 0 ( X ) and Y = M 0 ( Y ). Let M A be the model of Θ op ,A extending M 0 such that M A ( A ) = Y X and M A ( f ′ ): Y X × X → Y is the application. It can be noted that M A is the terminal mode l of Θ op ,A extending M 0 . Then the parameter passing function is a bijection, and c o mpo sing it with the par ameter adding bijection w e g et (where p M ( f ) q ∈ Y X corres p onds by curry ing to M ( f ): X → Y ): Mo d (Θ op ) | M 0 ∼ = M A ( A ) by M ↔ p M ( f ) q . Example 2.6 Let Θ sgp be the theory for semigroups pr esented b y one type G , one term pr d : G 2 → G and one equa tion pr d ( x, pr d ( y , z )) = pr d ( pr d ( x, y ) , z ) where x , y , z are v ariables o f type G . As usual w ith the categoric al p oint o f view, in fact the variables are pro jections; here, x, y , z : G 3 → G are the three pro jections and pr d ( x, y ) is pr d ◦ h x, y i : G 3 → G , comp osed of the pair h x, y i : G 3 → G 2 and of pr d : G 2 → G , and so on. P arameterization pro cess . In order to get para meterized families of se mig roups, we conside r the theor y Θ sgp ,A presented by tw o types A and G , one term pr d ′ : A × G 2 → G and one equation pr d ′ ( p, x, pr d ′ ( p, y , z )) = pr d ′ ( p, pr d ′ ( p, x, y ) , z ) where x , y , z a re v ariables of sort G and p is a v ariable of sort A . P arameter passing pro cess . The theory Θ sgp ,a is Θ sgp ,A together with a par a meter a : 1 → A , hence with pr d ′′ = pr d ′ ◦ ( a × id G 2 ): G 2 → G (where 1 × G 2 is ide ntified to G 2 ). Each mo del M A of Θ sgp ,A gives rise to a family of mo dels of Θ sgp ,a , all of them with the same underlying set M A ( G ) but with differen t int erpr etations of a in M A ( A ). Mapping pr d to pr d ′′ defines a mo rphism from Θ sgp to Θ sgp ,a . So, each mo del M a of Θ sgp ,a gives r ise to a mo del M of Θ sgp such that M ( G ) = M a ( G ) a nd M ( pr d )( x, y ) = M a ( pr d ′ )( α, x, y ) for ea ch x, y ∈ M a ( G ), where α = M a ( a ) is called the argument. 5 Example 2.7 This example motiv ates the existence of pure terms in the given theory . Let us cons ider the theory Θ nat “of naturals” presented by a type N and t wo terms z : 1 → N and s : N → N , and let us say that z is pure. Let Θ nat , 0 be the subtheory pres en ted by N and z , it is called the pure s ubtheo ry of Θ nat . W e define the theory Θ nat , A as made of tw o t yp es A and N and tw o ter ms z : 1 → N and s ′ : A × N → N . It should b e noted that Θ nat , A contains ε 1 : A × 1 → 1 and z ′ = z ◦ ε 1 : A × 1 → N . Then Θ nat ,A is a theory “of lists of A ”, with z for the empty lis t and s ′ for concatenating an element to a list. In this way , the theor y of lists of A is built as a generalizatio n of the theory of na turals; indeed the naturals c an be identified to the lists o ver a single ton. Example 2.8 Here is another example where pure terms ar e requir ed, this is a simplified version of many structures in K enzo/EA T. Le t Θ mon be the theor y for monoids pres en ted by one type G , tw o ter ms pr d : G 2 → G and e : → G , a nd the equations pr d ( x, pr d ( y , z )) = pr d ( pr d ( x, y ) , z ), pr d ( x, e ) = x , pr d ( e, x ) = x where x , y , z are v ariables of type G . Let Θ dm be the theory for differ en t ial monoids , presented by Θ mon together with one term dif : G → G and the e q uations dif ( pr d ( x, y )) = pr d ( dif ( x ) , dif ( y )), dif ( e ) = e , dif ( dif ( x )) = e , and with the terms in Θ mon as its pure terms. In or der to get par ameterized families of differential s tructures on o ne monoid, we define the theory Θ dm , A presented b y t wo t yp es G and A , three terms pr d : G 2 → G , e : 1 → G a nd dif ′ : A × G → G , the three eq uations from Θ mon and the equa tions dif ′ ( p, ( pr d ( x, y ))) = pr d ( dif ′ ( p, x ) , dif ′ ( p, y )), dif ′ ( p, e ) = e , dif ′ ( p, dif ′ ( p, x )) = e . Each mo del M A of Θ dm , A gives ris e to a family o f mo dels of Θ dm , all of them with the same underly ing mo noid ( M A ( G ) , M A ( pr d ) , M A ( e )): there is a mo del M a of Θ dm extending M A for ea c h element α in M A ( A ), with its differential structure defined b y M a ( dif ) = M A ( dif ′ )( α, − ). Example 2.9 In the next sectio ns we will use the theories with the fo llowing pre s ent ations : Π A ⊣ A Π a ⊣ A 1 a Π ⊣ 1 These theories are rela ted by se veral mo rphisms: π A : Π A → Π maps A to 1, b oth i : Π → Π a and i A : Π A → Π a are the inclusions, a nd π a : Π a → Π extends π A by mapping a to id 1 , so that π A and π a are epimorphis ms . In a ddition, π a ◦ i A = π A and there is a natural transfor mation p : i ◦ π A ⇒ i A defined by p A = a : 1 → A . The dia gram b elow on the r ight is the lax c olimit of π A , which mea ns that it enjoys the following univ ers al prop erty: for each Π ′ a with i ′ A : Π A → Π ′ a , i ′ : Π → Π ′ a and p ′ : i ′ ◦ π A ⇒ i ′ A , there is a unique h : Π a → Π ′ a such that h ◦ i A = i ′ A , h ◦ i = i ′ and h ◦ p = p ′ . F or instance, given Π, π A : Π A → Π, id Π : Π → Π and id π A : π A ⇒ π A , then π a : Π a → Π is the unique morphism such that π a ◦ i A = π A , π a ◦ i = id Π and π a ◦ p = id π A . Π A π A Π Π A i A π A = Π a π a Π Π A i A π A ⇑ p Π a Π i 2.3 Some ot her kinds of theories F or every theory Θ, the co slice categor y of the ories under Θ is denoted Θ ↓ T e q . It ca n b e seen as a 2 -categor y , with the natural transformations which extend the identit y on Θ a s 2-cells . Definition 2.10 A p ar ameterize d the ory Θ A is a theor y Θ with a dis ting uished type, called the typ e of p ar ameters and usually denoted A . The 2- category of para meterized theor ies is the coslice 2-ca tegory T A = Π A ↓ T e q of theo ries under Π A . A the ory with a p ar ameter Θ a is a par ameterized theory with a disting uished 6 constant o f t yp e A , called the p ar ameter and usually denoted a : 1 → A . The 2-ca tegory of theor ies with a parameter is the coslice 2-categ ory T a = Π a ↓ T e q of theo ries under Π a . According to the context, Θ A denotes either the para meter ized theory γ A : Π A → Θ A , or the equational theory Θ A itself. Similarly for Θ a , which denotes either γ a : Π a → Θ a or Θ a itself. In addition, it ca n b e noted that Π is the initial theory (which may also b e pr esented by the empty sp ecificatio n) so that Π ↓ T e q is isomorphic to T e q . The 2-ca tegories S A and S a of p ar ameterize d sp e cific ations and sp e cific ations with a p ar ameter , resp ectively , are defined in a similar w ay . On the other hand, the input of the pa rameterizatio n pro cess is a theory Θ to g ether with a wide subtheory Θ 0 ( wide mea ns: with the same t yp es), such a structur e is called a de c o rated theory . Definition 2.11 A de c or ate d the ory is made of a theor y Θ with a wide subtheo ry Θ 0 called the pur e subtheory of Θ. A morphism of decora ted theo r ies is a mo rphism of theories θ : Θ → Θ ′ which maps the pure part of Θ to the pure part of Θ ′ . This forms the categ ory T de c of dec orated theories . So, a decorated theory Θ is endo wed with a distinguis he d family of terms, called the pur e terms, such that all the identities and pro jections are pure and ev ery comp osition or tuple o f pure terms is pure. Pure terms are denoted with “ ” . When there is no ambiguit y we often use the same notation Θ for the theory Θ itself and for the decorated theor y made of Θ and Θ 0 . The decorated specifica tions ar e defined in a straightforward way . F or instance, we may consider the decorated s pecifica tion made o f a type N , a pure term z : 1 N and a term s : N → N (see exa mple 2.7). 3 Constructions 3.1 The parameterization proc ess is a functor In this section w e prov e that the para meterization pro cess is functorial, by defining a functor F p ar : T de c → T A , ca lled the p ar ameterization functor , whic h adds the type of parameters to the domain o f every no n-pure term. In a ddition, theorem 3.2 states that F p ar is left adjoint to the functor G p ar : T A → T de c , which builds the co Kleisli ca teg ory of the comona d A × − . In or der to define the functor F p ar we use the fac t that it should pr eserve colimits. It has bee n se e n in section 2.1 that every sp ecificatio n is the co limit of a diagra m of elementary sp ecifica tions. Similarly , every decorated specifica tion is the c olimit of a diagram o f elementary decor ated sp ecifications , denoted Σ E . x where x = p for “pure” or x = g for “gener al”. Informally , the functor F p ar explicits the fact that every genera l feature in a decorated sp ecification gets parameter ized, while e very pure fea ture remains unparameterized. Figur e 2 defines the pa rameterized sp ecification F p ar (Σ E . x ) for each elemen tary decor ated sp ecification Σ E . x (many pr o jection arr ows are omitted, when needed the pr o jections from A × X a r e denoted pr X : A × X → A a nd ε X : A × X → X ). The morphis ms of par ameterized spe cifications F p ar ( σ ), for σ betw een elemen tary deco r ated sp ecifications, are straightforw ar d. F or instance, le t σ c : Σ Term . g → Σ Term . p be the conv ersion morphism, which corr esp onds to the fact that every pure term ca n b e seen as a general ter m, then F p ar ( σ c ) maps f ′ : A × X → Y in F p ar (Σ Term . g ) to f ◦ ε X : A × X → Y in F p ar (Σ Term . p ). Now, given a decor a ted theor y Θ presented b y the co limit of a diagra m ∆ of element ar y decorated sp ecifications, we define F p ar (Θ) as the para meterized theo ry pr esented by the colimit of the diag r am F p ar (∆) of para meter ized sp ecifications. Definition 3.1 The functor F p ar : T de c → T A defined a bove is called the p ar ameterization functor . Clearly the parameteriza tion functor preserves co limits. I n addition, let Θ A be the parameter ized theory F p ar (Θ), it follows from the definition of F p ar that the equational theory Θ A is a theory under Θ 0 . Now the functor G p ar is de fined indep endently fro m F p ar . Let Θ A be a parameterized theory . T he endofunctor of pro duct with A forms a comona d on Θ A with the counit ε made o f the pro jections ε X : A × X → X a nd the comultiplication made of the terms δ X : A × X → A × A × X induced by the diagona l o n A . L et 7 index E . x Σ E . x F p ar Σ E . x t yp e Type . p X X pure term Term . p X f Y X f Y term Term . g X f Y A × X f ′ Y selection o f identit y Selid . p X id X X X id X X pure compo sition Comp . p X f g ◦ f = Y g Z X f g ◦ f = Y g Z comp osition Com p . g X f g ◦ f = Y g Z A × X h pr X ,f ′ i g ′ ◦h pr X ,f ′ i = A × Y g ′ Z terminal t yp e 0-Prod . p 1 1 pure collapsing 0- Tu ple . p X h i X 1 X h i X 1 binary pr o duct 2-Prod . p X X × Y p X p Y Y X X × Y p X p Y Y pure pairing 2-Tuple . p X Z f g h f ,g i = = X × Y p X p Y Y X Z f g h f ,g i = = X × Y p X p Y Y pairing 2-Tupl e . g X Z f g h f ,g i = = X × Y p X p Y Y X A × Z f ′ g ′ h f ′ ,g ′ i = = X × Y p X p Y Y Figure 2 : The functor F p ar on elementary decorated spec ifications Θ b e the co K leisli categor y of this comonad: it has the sa me t yp es as Θ A and a term [ f ]: X → Y for each term f : A × X → Y in Θ A . Ther e is a functor from Θ A to Θ whic h is the identit y on types a nd maps every g : X → Y in Θ A to [ g ◦ ε X ]: X → Y in Θ. Then every finite pro duct in Θ A is mapp ed to a finite pr o duct in Θ, whic h makes Θ a theory . Let Θ 0 denote the ima ge of Θ A in Θ , it is a wide subtheory of Θ . In this wa y , any parameterized theory yields a deco rated theor y . The definition o f G p ar on morphisms is str a ightf or w ar d, and the next r esult follows easily . Theorem 3.2 The p ar ameterization functor F p ar and the functor G p ar form an adjunction F p ar ⊣ G p ar : T de c F par ⊥ T A G par The next result states that Θ can be easily recov ered from Θ A , by mapping A to 1 . Prop ositio n 3.3 L et Θ b e a de c or ate d the ory with pur e subthe ory Θ 0 and γ A : Π A → Θ A the p ar ameterize d the ory F p ar (Θ) . L et γ : Π → Θ b e the unique morphism fr om the initial the ory Π to the the ory Θ . Then ther e 8 is a morphism θ A : Θ A → Θ under Θ 0 such that the fol lowing squar e is a pushout: Π A [ P. O. ] π A γ A Θ A θ A Π γ Θ Pr o of. It can easily b e c heck ed that this prop erty is satisfied by ea c h elementary sp ecification. Then the result follows by co mm uting tw o colimits: on the o ne hand the colimit that defines the given theor y from its elementary comp onents, and on the other ha nd the pushout.  When there is an epimorphism of theories θ : Θ 1 → Θ 2 , we s ay that Θ 1 is the gener alization of Θ 2 along θ . Indeed, since θ is a n epimorphism, the functor θ ∗ : Mo d (Θ 2 ) → Mo d (Θ 1 ) is a monomorphism, which ca n be used for identifying Mo d (Θ 2 ) to a s ubca tegory of Mo d (Θ 1 ). Corollary 3.4 With notations as in pr op osition 3.3, Θ A is the gener alization of Θ along θ A . Pr o of. Clearly π A : Π A → Π is an epimorphism. Since epimorphisms are stable under pusho uts, prop osition 3.3 prov es that θ A : Θ A → Θ is als o an epimorphism.  Let F p ar : T de c → T A be the parameter ization functor and let U : T A → T e q be the functor which s imply forgets that the t yp e A is distinguis hed, so that U ◦ F p ar : T de c → T e q maps the decorated theory Θ to the equational theory Θ A . T de c F par T A U T e q Every theory Θ can b e seen as a decorated theor y where the pure ter ms are defined inductively a s the ident ities, the pro jections, a nd the co mp ositio ns and tuples of pure terms. Let I : T e q → T de c denote the corres p onding inclusio n functor. Then the endofunctor U ◦ F p ar ◦ I : T e q → T e q corres p onds to the “ imp construction” o f [11], which tr ansforms each term f : X → Y in Θ into f ′ : A × X → Y for a new type A . 3.2 The parameter passing pro cess is a natural transformation A theory Θ a with a parameter is built simply by adding a consta n t a of type A to a parameterized theory Θ A . O b viously , this can b e seen as a pus hout. Definition 3.5 Let γ A : Π A → Θ A be a parameterized theory . The theo r y with para meter ex tending γ A is γ a : Π a → Θ a given b y the pushout of γ A and i A : Π A [ P. O. ] i A γ A Θ A j A Π a γ a Θ a This pushout of theories g ives ris e to a pullback o f categories of models , hence for each mo del M A of Θ A the function whic h maps each model M a of Θ a extending M A to the element M a ( a ) ∈ M A ( A ) defines a bijection: Mo d (Θ a ) | M A ≃ → M A ( A ) . (1) Let us assume that the parameterized theory γ A : Π A → Θ A is F p ar (Θ) fo r some dec orated theory Θ with pure subtheory Θ 0 . Then the pusho ut prop erty in definitio n 3 .5 ensur es the existence of a unique θ a : Θ a → Θ such that θ a ◦ γ a = γ ◦ π a and θ a ◦ j A = θ A , which means that θ a maps A to 1 and a to id 1 and the θ a extends θ A . Then Θ A is a theory under Θ 0 and the compo sition by j A makes Θ a a theor y under Θ 0 with j A preserving Θ 0 . 9 Θ A j A θ A = Θ a θ a Θ Definition 3.6 F or each decorated theor y Θ with pure sub catego ry Θ 0 , let Θ A = F p ar (Θ) a nd θ A : Θ A → Θ as in prop os itio n 3.3, and let Θ a and j A : Θ A → Θ a as in definition 3.5. Then j : Θ → Θ a is the mor phism under Θ 0 which maps each type X to X a nd each term f : X → Y to f ′ ◦ ( a × id X ): X → Y . And t : j ◦ θ A ⇒ j A is the natural tr a nsformation under Θ 0 such that t A = a : 1 → A . Lax co cones a nd lax co limits in 2-catego ries generalize co cones a nd colimits in catego ries, s o that the following diagram is a lax c o c one with b ase θ A in the 2- category Θ 0 ↓ T e q , for short it is denoted (Θ a , j A , j, t ), and it is ca lled the lax c olimit asso ciate d to Θ b ecause of le mma 3.7. Θ A j A θ A ⇑ t Θ a Θ j Lemma 3.7 L et Θ b e a de c or ate d the ory with pur e sub c ate gory Θ 0 . The lax c o c one (Θ a , j A , j, t ) with b ase θ A define d ab ove is a lax c olimit in t he 2-c ate gory of the ories u nder Θ 0 . Pr o of. This means that the g iven lax co cone is initial amo ng the lax co cone s with base θ A in Θ 0 ↓ Θ, in the following sense: for every lax co co ne (Θ ′ a , j ′ A , j ′ , t ′ ) with base θ A under Θ 0 there is a unique mor phism h : Θ a → Θ ′ a such that h ◦ j A = j ′ A , h ◦ j = j ′ and h ◦ t = t ′ . Indeed, h is defined fro m the pusho ut in definition 3 .5 by h ◦ j A = j ′ A , so that h ( A ) = A , and h ◦ γ a ( a ) = t ′ A : 1 → A .  F or instance, given Θ , θ A : Θ A → Θ , id Θ : Θ → Θ and id θ A : θ A ⇒ θ A , then θ a is the unique mor phism such that θ a ◦ j A = θ A , θ a ◦ j = id Θ and θ a ◦ t = id θ A . Let Θ be a decorated theo ry with pure subtheory Θ 0 and let (Θ a , j A , j, t ) b e its asso cia ted la x colimit, with base θ A : Θ A → Θ . Let M A be a mo del o f Θ A and M 0 its restriction to Θ 0 , and let { ( M , m ) | m : θ A ∗ M → M A }| M 0 (where as b efore θ A ∗ M = M ◦ θ A ) denote the set of pair s ( M , m ) with M a mo del of Θ extending M 0 and m a mor phism o f mo dels of Θ A extending id M 0 . A consequence of the lax co limit prop erty is that the function whic h maps ea ch mo del M a of Θ a extending M A to the pa ir ( j ∗ M a , t ∗ M a ) = ( M a ◦ j, M a ◦ t ) defines a bijection: Mo d (Θ a ) | M A ∼ = { ( M , m ) | m : θ A ∗ M → M A }| M 0 . (2) The bijections 1 and 2 pr ovide the next result, which do es no t inv olve Θ a . Prop ositio n 3.8 L et Θ b e a de c or ate d t he ory with pure subthe ory Θ 0 and let Θ A = F p ar (Θ) and θ A : Θ A → Θ . Then for e ach mo del M A of Θ A , with M 0 denoting the re striction of M A to Θ 0 , the function which maps e ach element α ∈ M A ( A ) to the p air ( M , m ) , wher e M is t he mo del of Θ such that M ( f ) = M A ( f ′ )( α, − ) and wher e m : θ A ∗ M → M A is the morphi sm of mo dels of Θ A such that m A : M (1 ) → M A ( A ) is the c onstant function α , defines a bije ction: M A ( A ) ∼ = { ( M , m ) | m : θ A ∗ M → M A }| M 0 . (3) As an immediate conseq uence, we get the exact p ar ameterization pro per t y from [11]. Corollary 3.9 L et Θ b e a de c or ate d the ory with pur e sub c ate gory Θ 0 , and let Θ A = F p ar (Θ) . L et M 0 b e a mo del of Θ 0 and M A a terminal mo del of Θ A extending M 0 . Then ther e is a bije ction: M A ( A ) ∼ = Mo d (Θ) | M 0 (4) 10 which maps e ach α ∈ M A ( A ) to the mo del M A,α of Θ define d by M A,α ( X ) = M 0 ( X ) for e ach typ e X and M A,α ( f ) = M A ( f ′ )( α, − ) for e ach t erm f , so that M A,α ( f ) = M A ( f ) for e ach pur e term f . The existence o f a terminal model o f Θ A extending M 0 is a co nsequence of [17] and [10]. Corolla ry 3.9 corres p onds to the way algebra ic s tructures are implemented in the systems Ke nzo/EA T. In these systems the parameter set is enco ded by means of a recor d of Common Lisp functions, which has a field for each op eration in the algebr aic structure to be implement ed. The pure terms corresp ond to functions whic h can be obta ine d from the fixed data and do not require an explicit s torage. Then, each particular instance of the r ecord gives rise to an a lgebraic structur e. Clearly the construction o f γ a from γ A is a functor , which is left a djoin t to the functor which simply for gets that the co nstant a is distinguished. So, by co mpo sing this adjunction with the adjunction F p ar ⊣ G p ar from theorem 3.2 w e get an a djunction F ′ p ar ⊣ G ′ p ar where F ′ p ar maps each decorated theory Θ to Θ a , as defined ab ov e: T de c F ′ par ⊥ T a G ′ par Let U ′ : T a → T e q be the functor whic h simply forgets that the type A and the consta n t a a re distinguished. Then the functor U ′ ◦ F ′ p ar : T de c → T e q maps the decorated theor y Θ to the equational theory Θ a . T de c F ′ par T a U ′ T e q The morphism of theo r ies j : Θ → Θ a from definition 3.6 depends o n the decora ted theory Θ, let us denote it j = J Θ . Let H : T de c → T e q be the functor which maps each deco rated theory Θ to the equational theory Θ. The next r esult is easy to chec k. Theorem 3.10 The morphisms of the ories J Θ : Θ → Θ a form the c omp onents of a natura l tr ansformation J : H ⇒ U ′ ◦ F ′ p ar : T de c → T e q . T de c F ′ par H ⇑ J T a U ′ T e q Definition 3.11 The natural tra nsformation J : H ⇒ U ′ ◦ F ′ p ar : T de c → T e q in theorem 3 .10 is ca lle d the p ar ameter p assing n atur al t r ansformation . 3.3 Examples Example 3.12 Sta rting from Θ op and Θ op , 0 as in example 2.5, the pushouts of theorie s fro m pr op osition 3.3 and definition 3.5 a re res pectively: A − → A A × X f ′ X Y A − → A A × X f ′ X Y ↓ ↓ ↓ ↓ 1 − → X f Y A 1 a − → A A × X f ′ 1 a X Y W e ha ve seen in e xample 2.5 tw o other presentations of the vertex Θ op ,a of the second pushout, with f ′′ = f ′ ◦ ( a × id X ) : X → Y . F or each decor a ted theo ry Θ, the mor phism o f equa tio nal theories j op = J Θ op : Θ → Θ a maps f to f ′′ , a s in example 2.5. 11 A mo del M 0 of Θ op , 0 is simply made of t wo sets X = M 0 ( X ) and Y = M 0 ( Y ). On the one ha nd, a mo del of Θ extending M 0 is c hara cterized by a function ϕ : X → Y . On the other hand, the terminal mo del M A of Θ op ,A extending M 0 is such that M A ( A ) = Y X and M A ( f ′ ): Y X × X → Y is the application. The bijection Mo d (Θ) | M 0 ∼ = M A ( A ) then corr esp onds to the currying bijection ϕ 7→ p ϕ q . Example 3.13 L et Θ dm be the theor y for differential monoids from example 2 .8, with the pure subtheory Θ dm , 0 = Θ mon of monoids. They generate the pa rameterized theor y Θ dm , A as in example 2 .8. Let M 0 be some fixed monoid and M A any mo del of Θ dm ,A extending M 0 , then each element o f M A ( A ) corresp onds to a differential str ucture on the monoid M 0 . If in a ddition M A is the terminal mo del of Θ dm , A extending M 0 , then this corr e spo ndence is bijective. Example 3.14 When dea ling with a n imp erative language , the states for the memory ar e endow ed with an op eration lo okup for observing the state and an op eratio n up date for mo difying it. There are tw o points of view on this situation: either the state is hidden, or it is explicit. Let us chec k that the para meterization pro cess allows to generate the theory with explicit state fro m the theo ry with hidden sta te. First, le t us focus on observ ation: the theory Θ st is made of t wo types L and Z (for lo cations and int eger s, respectively) a nd a term v : L → Z for obser ving the v alues of the v ariables. The pure subtheory Θ st , 0 is made of L a nd Z . W e choo se a model M 0 of Θ st , 0 made of a co untable set of lo cations (or adr esses, or “v aria bles ”) L = M 0 ( L ) and of the set of integers Z = M 0 ( Z ). Let A = Z L , then a s in ex ample 3.12 the terminal mo del M A of Θ st ,A extending M 0 is such that M A ( A ) = A and M st ,A ( v ′ ): A × L → Z is the application, denoted lo okup . The terminal mo del M A do es corresp ond to an “optimal” implementation of the sta te. Now, let us lo ok a t another mo del N A of Θ st ,A extending M 0 , defined as follows: N A ( A ) = A × L × Z and N A ( v ′ ): A × L × Z × L → Z maps ( p, x, n, y ) to n if x = y and to lo okup ( p, y ) otherwis e. The terminality prop erty of M A ensures that there is a unique function up date : A × L × Z → A such that lo okup ( up date ( p, x, n ) , y ) is n if x = y and is lo okup ( p, y ) other w is e. So, the op er a tion u p date is defined coinductively from the op eration lo okup . 4 Conclusion This pape r pr ovides a neat categor ical formalization for the pa rameterizatio n pro c ess in Ke nzo and EA T. An additional level of abstraction allows to s ee the parameter ization pr o c ess as a morphism of log ics and the par ameter passing pro ces s as a 2-mor phism of logics, in a rele v ant 2 - category of log ics [5]. F uture work includes the gener alization o f this approach from equational theor ies to other families of theor ies, like distributive categories, a nd to mo re gener al kinds of parameter s, like data types. References [1] Michael Bar r, Char le s W ells. Category Theor y for Computing Science. Centre de Recherches Math´ ema- tiques (CRM) Publications, 3 rd Edition, 199 9 . [2] Hartmut Ehr ig, Hans-J¨ org Kr eowski, James Thatcher, E ric W agner, Je sse W righ t. Parameterized Data Types in Algebra ic Sp ecification Languages . Springer. L e cture Notes in Computer Science 8 5, p. 1 5 7–168 (1980). [3] C´ esar Dom ´ ınguez, Dominique Duv al, La ureano Lamb´ an, Julio Rubio. T o wards Diagra m- matic Specifica tions of Symbolic Computatio n Systems. In: Mathematics, Algorithms, Pro ofs. T. Co quand, H. Lombardi, M. Roy (Eds.). Dagstuhl Seminar 0 5021 (2005). http:/ /drops .dagstuhl.de/portals/index.php?semnr=05021 . [4] C´ esar Dom ´ ınguez, Dominique Duv al. A parameterizatio n pro cess as a ca tegorical construction. arXiv: 0908.3 634 (200 9). 12 [5] C´ esar Dom ´ ıng uez, Dominique Duv al. Diagrammatic log ic a pplied to a parameter ization pro c e ss. arXiv: 0908.3 737 (200 9). [6] C´ esar Dom ´ ınguez, Laur eano Lamb´ an, Julio Rubio. O b ject-Oriented Institutions to Specify Symbolic Computation Systems. Rairo - Theoretical Informatics a nd Applications 41, p. 191–2 14 (20 07). [7] C´ esar Dom ´ ıng uez, Julio Rubio, F rancis Ser geraer t. Mo deling Inheritance as Co er cion in the K e nzo System. Jour nal of Universal Computer Science 1 2 (12), p. 17 01–17 30 (20 06). [8] Xavier Dous son, F rancis Serger aert, Yvon Siret. The Ke nzo Pr ogram. Institut F ourier, Gr enoble (19 9 9). http:/ /www- four ier.ujf- grenoble.fr/ ~ serger ar/Ken zo . [9] Joseph Goguen, Gra nt Malc o lm. A Hidden Agenda. Theoretical Computer Science 245 (1), p. 55 –101 (2000). [10] Ulrich Hensel, Hor st Reichel Defining Equations in T erminal Coalgebr as. In Recen tr T rends in Data Type Sp ecifications, Springer . Lecture Notes in Computer Science 9 06, p. 307– 318 (1995). [11] Laurena no Lamb´ an, Vico Pascual, J ulio Rubio. An Ob ject-Or iented Int erpr etation of the EAT System. Applicable Algebra in E ngineering, Communication and Computing, 14 (3), p. 187–2 15 (2003). [12] S.K. L e llahi. Catego rical Abstract Data Type (CADT). Diag rammes 21, SKL1-SKL23 (19 8 9). [13] Jacq ues Lo eckx, Hans-Dieter Ehr ich, Markus W olf. Sp ecification of Abstract Data Types. Wiley and T eubner, New Y ork (1996). [14] Saunders Ma c La ne. Categor ies for the W orking Mathematician. Spr ing er, 2th edition, 19 98. [15] Andrew M. P itts. Catego rical Logic. Chapter 2 of S. Abramsk y and D. M. Gabbay and T. S. E. Maibaum (Eds). Handbo o k of Logic in Computer Science, V olume 5. Algebra ic a nd Logical Structures. Oxfor d Univ ers it y Pr e ss, 2000. [16] Julio Rubio, F rancis Sergeraert, Yv on Sire t. EA T: Symbolic Soft ware for Effective Homolog y Compu- tation. Institut F o urier, Grenoble (1997). f tp://f ourier .ujf- gr enoble.fr/pub/EAT . [17] J.J.M.M. Rutten. Universal Coalgebra: a Theor y of Systems. Theo retical Computer Science 249 (1), p. 3 –80 (2000). 13

Original Paper

Loading high-quality paper...

Comments & Academic Discussion

Loading comments...

Leave a Comment