22
Electronic Notes in Theoretical Computer Science 64 (2002) URL: http://www.elsevier.nl/locate/entcs/volume64.html 22 pages Comparing Meseguer’s Rewriting Logic with the Logic CRWL Miguel Palomino Tarjuelo 1,2 Dpto. Sistemas Inform´ aticos y Programaci´ on Facultad de Matem´ aticas, Universidad Complutense Madrid, Spain Abstract Meseguer’s rewriting logic and the rewriting logic CRWL are two well-known ap- proaches to rewriting as logical deduction that, despite some clear similarities, were designed with different objectives. Here we study the relationships between them, both at a syntactic and at a semantic level. It is not possible to establish an en- tailment system map between them, but both can be naturally simulated in each other. Semantically, there is no embedding between the corresponding institutions. We also use the syntactic results to prove reflective properties of CRWL and to extend those already known for Meseguer’s rewriting logic. 1 Introduction The aim of this paper is to study in detail, and to clarify to some extent, the relationships between two well-known approaches to rewriting as logical deduction, namely, Jos´ e Meseguer’s rewriting logic [14], and the constructor- based rewriting logic (CRWL) developed by Mario Rodr´ ıguez-Artalejo’s re- search group in Madrid [10]. The first of these was proposed as a logical framework wherein to rep- resent other logics, and also as a semantic framework for the specification of languages and systems. The experience accumulated throughout the last years has come to support that original intention; in particular, it has been shown that rewriting logic is a very flexible framework in which many other logics, including first-order logic, intuitionistic logic, linear logic, Horn logic with equality, as well as any other logic with a sequent calculus, can be rep- resented. An important characteristic of these representations that should 1 Supported by a postgraduate fellowship from the Spanish Ministry for Education, Cul- ture, and Sports. 2 Email: [email protected] c 2002 Published by Elsevier Science B. V.

Comparing Meseguer’s Rewriting Logic with the Logic CRWLmaude.sip.ucm.es/~miguelpt/papers/wflp01.pdf · extend those already known for Meseguer’s rewriting logic. 1 Introduction

  • Upload
    others

  • View
    0

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Comparing Meseguer’s Rewriting Logic with the Logic CRWLmaude.sip.ucm.es/~miguelpt/papers/wflp01.pdf · extend those already known for Meseguer’s rewriting logic. 1 Introduction

Electronic Notes in Theoretical Computer Science 64 (2002)URL: http://www.elsevier.nl/locate/entcs/volume64.html 22 pages

Comparing Meseguer’s Rewriting Logicwith the Logic CRWL

Miguel Palomino Tarjuelo 1,2

Dpto. Sistemas Informaticos y ProgramacionFacultad de Matematicas, Universidad Complutense

Madrid, Spain

Abstract

Meseguer’s rewriting logic and the rewriting logic CRWL are two well-known ap-proaches to rewriting as logical deduction that, despite some clear similarities, weredesigned with different objectives. Here we study the relationships between them,both at a syntactic and at a semantic level. It is not possible to establish an en-tailment system map between them, but both can be naturally simulated in eachother. Semantically, there is no embedding between the corresponding institutions.We also use the syntactic results to prove reflective properties of CRWL and toextend those already known for Meseguer’s rewriting logic.

1 Introduction

The aim of this paper is to study in detail, and to clarify to some extent,the relationships between two well-known approaches to rewriting as logicaldeduction, namely, Jose Meseguer’s rewriting logic [14], and the constructor-based rewriting logic (CRWL) developed by Mario Rodrıguez-Artalejo’s re-search group in Madrid [10].

The first of these was proposed as a logical framework wherein to rep-resent other logics, and also as a semantic framework for the specificationof languages and systems. The experience accumulated throughout the lastyears has come to support that original intention; in particular, it has beenshown that rewriting logic is a very flexible framework in which many otherlogics, including first-order logic, intuitionistic logic, linear logic, Horn logicwith equality, as well as any other logic with a sequent calculus, can be rep-resented. An important characteristic of these representations that should

1 Supported by a postgraduate fellowship from the Spanish Ministry for Education, Cul-ture, and Sports.2 Email: [email protected]

c©2002 Published by Elsevier Science B. V.

Page 2: Comparing Meseguer’s Rewriting Logic with the Logic CRWLmaude.sip.ucm.es/~miguelpt/papers/wflp01.pdf · extend those already known for Meseguer’s rewriting logic. 1 Introduction

Palomino Tarjuelo

be stressed is that they are usually quite simple and natural, so that theirmathematical properties are often straightforward to derive.

On the other hand, the goal of the constructor-based rewriting logic isto serve as a logical basis for declarative programming languages involvinglazy evaluation, offering support, in addition, to non-strict and possibly non-deterministic functions.

Despite these differences, there is a clear resemblance between both logics,namely, the fact that logical deduction is based on rewriting. It seems natural,then, to ask about the relationships between deduction in these logics, and toextend the question so as to encompass whether the corresponding models arealso related.

A suitable framework in which to carry out this study is the theory ofgeneral logics developed by Meseguer [12]. There, a logic is described in avery abstract manner and two separated components are distinguished in it:an entailment system and an institution, corresponding with the syntactic andthe semantic parts of the logic, respectively.

We will begin by studying derivability and, for that, we will try to associateentailment systems to both logics. Unfortunately, it will be proven that thereis none corresponding to deduction in CRWL, and so we will be forced to leavethe formal framework and undertake more informal simulations of the logicsin each other. Although such simulations could be possible by making use ofsuitable down-level encodings, relying on the analogies between both logicsour interest resides in finding natural and simple simulations which at leastshow that their expressive power is the same. In addition, these results willbe used to study reflective properties of both logics.

After the comparison at the syntactic level, the next step is the study ofthe corresponding models. Now we will be able to associate an institution toeach logic, so this study will take place within the formal framework of thetheory of institutions. The main result we will obtain is that models in theselogics bear no relation at all, and through its way we will clarify some subtlepoints regarding the definition of models in Meseguer’s rewriting logic.

A detailed account of all the results presented here (together with an in-terpreter for CRWL in Maude—a language based on rewriting logic) can befound in [18].

2 Relations at the Syntactic Level

In the first part of the paper we focus on the syntactic aspects of the logics,and try to abstractly study derivability in them at the level of entailmentsystems. After ruling out this possibility, we develop some simulations thatwill allow us to prove some reflective properties of the logics. We start byreviewing the main concepts and definitions that we will use.

2

Page 3: Comparing Meseguer’s Rewriting Logic with the Logic CRWLmaude.sip.ucm.es/~miguelpt/papers/wflp01.pdf · extend those already known for Meseguer’s rewriting logic. 1 Introduction

Palomino Tarjuelo

2.1 Entailment systems

Syntax is typically given by a signature Σ providing a grammar on whichsentences, collected in a set sen(Σ), are built. For a given signature Σ, entail-ment (also called provability) of a sentence ϕ ∈ sen(Σ) from a set of axiomsΓ ⊆ sen(Σ) is a relation Γ ` ϕ which holds if and only if we can prove ϕ fromthe axioms Γ using the rules of the logic. We make this relation relative to asignature. In the rest of the paper, let |C| denote the collection of objects ofa category C.

An entailment system [12] is a triple E = (Sign, sen,`) such that

• Sign is a category whose objects are called signatures,

• sen : Sign→ Set is a functor associating to each signature Σ a correspond-ing set of Σ-sentences, and

• ` is a function which associates to each Σ ∈ |Sign| a binary relation `Σ⊆P(sen(Σ))× sen(Σ) called Σ-entailment such that the following propertiesare satisfied:

(i) reflexivity: for any ϕ ∈ sen(Σ), ϕ `Σ ϕ,(ii) monotonicity: if Γ `Σ ϕ and Γ′ ⊇ Γ then Γ′ `Σ ϕ,(iii) transitivity: if Γ `Σ ϕi, for all i ∈ I, and Γ ∪ ϕi | i ∈ I `Σ ψ, then

Γ `Σ ψ,(iv) `-translation: if Γ `Σ ϕ, then for any H : Σ→ Σ′ in Sign, sen(H)(Γ) `Σ′

sen(H)(ϕ).

Given an entailment system E , its category Th of theories has as objectspairs T = (Σ,Γ), with Σ a signature and Γ ⊆ sen(Σ). A theory morphismH : (Σ,Γ)→ (Σ′,Γ′) is a signature morphism H : Σ→ Σ′ such that if ϕ ∈ Γ,then Γ′ `Σ′ sen(H)(ϕ). A theory morphism is axiom-preserving if, in addition,it satisfies the condition sen(H)(Γ) ⊆ Γ′. This defines a subcategory Th0 withthe same objects as Th but with morphisms restricted to be axiom-preservingtheory morphisms, that does not depend on the entailment relation.

There is also a notion of map of entailment systems, allowing us to relatelogics in a general and systematic way. Basically, a map of entailment systemsE → E ′ maps signatures of E to signatures of E ′ (or, more generally, theoriesto theories), and sentences of E to sentences of E ′, respecting the entailmentrelations ` of E and `′ of E ′.

2.2 Rewriting logic

Rewriting logic is parameterized with respect to the version of the underly-ing equational logic; in this paper we concentrate on the version which usesunsorted and unconditional equational logic as its underlying logic, and writeRL for it.

A signature in RL is a pair (Σ, E) with Σ a ranked alphabet of func-tion symbols and E a set of Σ-equations. Rewriting operates on equivalenceclasses of terms modulo the set of equations E. We denote by TΣ(X ) the

3

Page 4: Comparing Meseguer’s Rewriting Logic with the Logic CRWLmaude.sip.ucm.es/~miguelpt/papers/wflp01.pdf · extend those already known for Meseguer’s rewriting logic. 1 Introduction

Palomino Tarjuelo

[t]→ [t][t1]→ [t′1] . . . [tn]→ [t′n]

[f(t1, . . . , tn)]→ [f(t′1, . . . , t′n)]

[t]→ [t′] [t′]→ [t′′][t]→ [t′′]

[w1]→ [w′1] . . . [wn]→ [w′n]

[a1(w/x)]→ [b1(w/x)] . . . [am(w/x)]→ [bm(w/x)][t(w/x)]→ [t′(w′/x)]

if r : [t]→ [t′] if [a1]→ [b1] ∧ . . . ∧ [am]→ [bm] ∈ Γ

Fig. 1. Rules of deduction for an RL-theory (Σ, E, L,Γ)

Σ-algebra of Σ-terms with variables in a set X , and by [t]E or just [t] theE-equivalence class of t ∈ TΣ(X ). To indicate that x1, . . . , xn is the set ofvariables occurring in t we write t(x1, . . . , xn). Given t(x1, . . . , xn), and termsu1, . . . , un, t(u1/x1, . . . , un/xn) denotes the term obtained from t by simulta-neously substituting ui for xi, i = 1, . . . , n. To simplify notation we denotea sequence of objects a1, . . . , an by a; with this notation, t(u1/x1, . . . , un/xn)can be abbreviated to t(u/x).

An RL-theory R is a 4-tuple R = (Σ, E, L,Γ), where (Σ, E) is a signatureand Γ is a set of rewrite rules, labelled with elements of L, of the form

r : [t]→ [t′] if [a1]→ [b1] ∧ . . . ∧ [am]→ [bm].

The rules of deduction of the logic are shown in Fig. 1; for a complete expo-sition of RL we refer the reader to [14].

2.3 CRWL

CRWL uses signatures with constructors Σ = CΣ ∪ FΣ, where CΣ and FΣ aredisjoint sets of constructor and defined function symbols, respectively. Σ⊥refers to the signature which is obtained from Σ by adding a new constructor⊥ of arity 0. Given a set X of variables, we will write Expr(Σ,X ) for the setof expressions which can be built with Σ and X , and Term(Σ,X ) for thoseterms which only make use of CΣ and X . Expr⊥(Σ,X ) and Term⊥(Σ,X ), thesets of partial expressions and terms, are defined analogously using Σ⊥. Asignature morphism [17] σ : Σ→ Σ′ from a signature Σ = CΣ ∪FΣ to anotherΣ′ = CΣ′ ∪ FΣ′ is a pair of functions (denoted with the same σ)

σ : CΣ → CΣ′ and σ : FΣ → FΣ′ ,

mapping n-ary symbols to n-ary symbols.

A CRWL-theory is a pair (Σ,Γ), where Σ is a signature with constructors,and Γ is a set of conditional rewrite rules of the form

f(t1, . . . , tn)→ r ⇐ a1 ./ b1, . . . , am ./ bm (m ≥ 0),

with f a function symbol, and t1, . . . , tn ∈ Term(Σ,X ). ¿From a given theorytwo kinds of sentences are derived using the calculus in Fig. 2: reductionstatements of the form a→ b, and joinability statements a ./ b (meaning that

4

Page 5: Comparing Meseguer’s Rewriting Logic with the Logic CRWLmaude.sip.ucm.es/~miguelpt/papers/wflp01.pdf · extend those already known for Meseguer’s rewriting logic. 1 Introduction

Palomino Tarjuelo

e→ ⊥ e→ ee1 → e′1 . . . en → e′n

h(e1, . . . , en)→ h(e′1, . . . , e′n)

Cl→ r

for l→ r ⇐ C an instance of a rule of Γ with partial terms

e→ e′ e′ → e′′

e→ e′′a→ t b→ t

a ./ bif t is a total term

Fig. 2. Rules of deduction for a CRWL-theory (Σ,Γ)

there exists a total term to which both a and b reduce). Again, we refer to [10]for a complete presentation of CRWL. (Note that in [10] the names “term”and “constructor term” are used instead of “expression” and “term”.)

2.4 Entailment systems for RL and CRWL

Our goal in this section is to associate entailment systems to both RL andCRWL, and then to relate them by means of suitable maps of entailmentsystems.

Assigning an entailment system to RL is a relatively straightforward task,and we have two possibilities: either we restrict to unconditional rewrite rulesand define `Σ by means of derivation in the RL-calculus, or we also considerconditional rules, in which case the RL-calculus in Fig. 1 must be extendedto be able to derive them. This extension is carried out in [18], where it isproved to be sound and complete with respect to a corresponding extensionof the notion of satisfaction (see also Sect. 3.5).

At first sight, the same two possibilities hold for CRWL. However, a closerlook reveals that derivation in the CRWL-calculus is not transitive. Consider,for example, a signature Σ with c, d, h ∈ Σ, function symbols of arities 0, 0,and 1, respectively. Then it can be proved that

c→ h(c), h(x)→ h(d), h(x)→ h(d)⇐ x ./ x `CRWL c→ h(d)

c→ h(c), h(x)→ h(d)⇐ x ./ x `CRWL h(x)→ h(d),

but

c→ h(c), h(x)→ h(d)⇐ x ./ x 6`CRWL c→ h(d).

The first statement is proved by instantiating h(x) → h(d) with ⊥ and ap-plying transitivity (note that c cannot be used to instantiate this rule, as itis not a term); for the second, simply instantiate h(x) → h(d) ⇐ x ./ x withx. The third statement is formally proved by induction on derivations: let usjust note that the crucial point is that the rule h(x)→ h(d) cannot be instan-tiated with ⊥. What lies behind is the fact that the CRWL-calculus is soundand complete with respect to validity in models only under totally definedvaluations [10]. In particular, in the second entailment above, h(x) → h(d)means that h(t) rewrites to h(d) just for those instances where a total term t

5

Page 6: Comparing Meseguer’s Rewriting Logic with the Logic CRWLmaude.sip.ucm.es/~miguelpt/papers/wflp01.pdf · extend those already known for Meseguer’s rewriting logic. 1 Introduction

Palomino Tarjuelo

is substituted for x.

This proves that the relation `CRWL is not transitive and, therefore, weare not going to be able to build an entailment system based on the CRWLrewriting calculus, as any sensible one should contain, at least, the conditionalrewrite rules among its sentences. (We will have, however, an entailmentsystem corresponding to the institution that will be associated to CRWL inSect. 3.4.)

2.5 Simulating CRWL in RL

As there does not exist an entailment system associated to the CRWL-calculus,we cannot define a map of entailment systems as intended. In the following wewill be pleased just with presenting how entailment in CRWL can be simulatedin RL. The set of labels of an RL-theory does not take part in the entailmentprocess, and so it is omitted; the same convention will also be adopted inSects. 2.6 and 2.7.

Of course, every CRWL-theory T can be trivially “simulated” in RL bymeans of an RL-theory T ′ with a constant ct for each term (and each expres-sion) t in T , and with axioms ct → ct′ whenever t → t′. But such a T ′ is notcomputable in general, and this is a property that will be required in Sect. 2.8when we apply the simulation to the study of reflection in CRWL. And so wemust look for another construction.

The idea is to associate to every CRWL-theory T = (Σ,Γ) a theory T ′ inRL (whose set of equational axioms will be empty) in which all the operationsin T , together with a new constant ⊥, are available, plus one rule for each ax-iom in T and, perhaps, some more rules coping with the rules of deduction ofthe CRWL-calculus. Since rules in CRWL can only be instantiated with termsand not expressions, we introduce a unary relation pterm (technically, a unaryfunction) and a constant true to distinguish them in RL. One immediate ruledefining pterm is pterm(⊥) → true; however, how to express that variablesare also partial terms? The obvious rule pterm(x)→ true is clearly not valid:everything would be a partial term! This means that we must add the CRWLvariables to the signature of T ′ as constants, and use a new set X of variablesfor RL. Although simulating variables by constants may seem counterintu-itive at first sight, note that, actually, the only requirement the simulatingterms must satisfy is that of capturing those properties we are interested in(the entailment relation in the theory). Using constants for variables we willbe able to distinguish those terms in RL representing terms in CRWL fromthose representing expressions, and hence allowing us to capture, by carefullytranslating the rules of deduction of the CRWL-calculus (using, perhaps, adifferent representation for the terms appearing in them), the correspondingentailment relation. A similar situation will occur in Sect. 2.7.

Then, assuming variables in CRWL belong to a set V , the rules defining

6

Page 7: Comparing Meseguer’s Rewriting Logic with the Logic CRWLmaude.sip.ucm.es/~miguelpt/papers/wflp01.pdf · extend those already known for Meseguer’s rewriting logic. 1 Introduction

Palomino Tarjuelo

pterm will be

pterm(⊥)→ true

pterm(vi)→ true (∀vi ∈ V)

pterm(h(x1, . . . , xn))→ true

if pterm(x1)→ true ∧ . . . ∧ pterm(xn)→ true (∀h ∈ CnΣ, n ∈ N),

In a similar way, two more predicates, pexpr and tterm, dealing with partialexpressions and total terms, are defined [18].

As a side effect, rewriting in CRWL can no longer be simulated in RLdirectly through the rewriting relation. Consider, for example, the theory ofnatural numbers in CRWL, with 0 a constructor and + a function symbol. InRL, pterm(0 + 0) should not rewrite to true; however, with the usual defini-tions, 0+0→ 0 and by congruence pterm(0+0)→ pterm(0), and this last termmust reduce to true. Therefore, a rewrite in CRWL will be simulated througha binary relation R so that e → e′ in CRWL if and only if R(e, e′) → truein RL. In a similar way, strict equalities a ./ b will be simulated through abinary relation ./.

It just remains to translate the rules of deduction of the CRWL-calculus,which is straightforward. For example, the bottom rule stating that everyexpression is reducible to ⊥ is written

R(x,⊥)→ true if pexpr(x)→ true,

whereas the joinability rule

a→ t b→ t

a ./ bif t is a total term

results in

x ./ y → true if R(x, z)→ true ∧R(y, z)→ true ∧ tterm(z)→ true.

Finally, to every rule l(v) → r(v) ⇐ a1(v) ./ b1(v), . . . , am(v) ./ bm(v) in theCRWL-theory, we associate the following rule in RL

R(l(x), r(x))→ true

if a1(x) ./ b1(x)→ true ∧ . . . ∧ am(x) ./ bm(x)→ true ∧

pterm(x1)→ true ∧ . . . ∧ pterm(xn)→ true,

where each CRWL variable vi (a constant in the RL-theory) has been substi-tuted by the variable xi. This last rule corresponds with the reduction rule inthe CRWL-calculus, and the condition that program rules in CRWL can onlybe instantiated with terms is taken care of by demanding pterm(x)→ true forall the variables appearing in it.

We will write α(T ) for the RL-theory associated to a CRWL-theory T .The following proposition ensures us that the translation is correct.

7

Page 8: Comparing Meseguer’s Rewriting Logic with the Logic CRWLmaude.sip.ucm.es/~miguelpt/papers/wflp01.pdf · extend those already known for Meseguer’s rewriting logic. 1 Introduction

Palomino Tarjuelo

Proposition 2.1 Given a CRWL-theory T = (Σ,Γ) with α(T ) = (Σ′, ∅,Γ′),then, if l, r, a, b ∈ TΣ′(X ):

l, r ∈ Expr⊥(Σ,V) and T `CRWL l→ r ⇐⇒ α(T ) `RL R(l, r)→ true;

a, b ∈ Expr⊥(Σ,V) and T `CRWL a ./ b ⇐⇒ α(T ) `RL a ./ b→ true.

2.6 Simulating RL in CRWL

We now embark ourselves on findind the converse simulation of RL in CRWL.We are still interested in a computable and simple translation, and the ideafor this is very similar to that of the previous section. Now, however, thereare no terms and expressions to distinguish, and so predicates such as ptermare no longer necessary; as a consequence, we will be able to use the sameset X of variables for both logics. The fact that only joinability statementsare allowed to appear in the condition of a rewrite rule in CRWL forces usto represent, as in Sect. 2.5, the rewriting relation in RL through a binaryrelation R in CRWL, so that t → t′ in RL if and only if R(t, t′) → true inCRWL; rewriting modulo a set of equations will be handled by transformingeach equation t = t′ into the rewrites t→ t′ and t′ → t.

More precisely, given a signature (Σ, E) in RL we associate to it a CRWL-theory over the signature Σ′ with CΣ′ = Σ∪ true and FΣ′ = R, with trueand R of arities 0 and 2, respectively. The rules in the theory are

R(x1, x2)→ true ⇐ x1 ./ x2,

R(x, y)→ true ⇐ R(x, z) ./ true, R(z, y) ./ true,

and, for each f ∈ Σ of arity n ∈ N,

R(f(x1, . . . , xn), f(y1, . . . , yn))→ true

⇐ R(x1, y1) ./ true, . . . , R(xn, yn) ./ true,

mimicking the reflexivity, transitivity, and congruence rules in the RL-calculus,together with

R(t, t′)→ true and R(t′, t)→ true,

for every t = t′ ∈ E. The goal of the condition in the rule corresponding toreflexivity is to avoid instantiating it with terms containing ⊥, which have nomeaning in RL.

A conditional rewrite rule

[l]→ [r] if [a1]→ [b1] ∧ . . . ∧ [am]→ [bm]

over (Σ, E) in RL is then translated to

R(l, r)→ true⇐ R(a1, b1) ./ true, . . . , R(am, bm) ./ true,

where l, r, ai, bi are arbitrary members of [l], [r], [ai] and [bi], respectively.

In fact, the previous definitions must be slightly modified due to sometechnical details. In a conditional rewrite rule l → r ⇐ C in CRWL, l must

8

Page 9: Comparing Meseguer’s Rewriting Logic with the Logic CRWLmaude.sip.ucm.es/~miguelpt/papers/wflp01.pdf · extend those already known for Meseguer’s rewriting logic. 1 Introduction

Palomino Tarjuelo

be linear, and it is obvious that with the above definitions this property isnot ensured for the translation of equations and rewrite rules; therefore, thoserules must be “linearised” (see [1,18]).

In what follows, we write β(T ) for the CRWL-theory associated to a RL-theory T . The next proposition guarantees the correctness of the translation.

Proposition 2.2 Given any RL-theory T = (Σ, E,Γ), and l, r ∈ TΣ(X ):

T `RL [l]→ [r] ⇐⇒ (∃l′ ∈ [l],∃r′ ∈ [r]) β(T ) `CRWL R(l′, r′)→ true

⇐⇒ (∀l′ ∈ [l],∀r′ ∈ [r]) β(T ) `CRWL R(l′, r′)→ true.

2.7 Simulating rewriting logic over membership equational logic in CRWL

Membership equational logic is an expressive version of equational logic; a fulltreatment of its syntax and semantics can be found in [15]. A signature inmembership equational logic is a triple Ω = (K,Σ, S) with K a set of kinds, Σa K-kinded signature and S = Skk∈K a pairwise disjoint K-kinded familyof sets. We call Sk the set of sorts of kind k. The pair (K,Σ) is what isusually called a many-sorted signature of function symbols; however, we callthe elements of K kinds because each kind k now has a set Sk of associatedsorts. Also, we denote by TΣ(X )k the set of terms of kind k with variablesin a K-kinded set X . The atomic formulae of membership equational logicare either equations t = t′, where t and t′ are Σ-terms of the same kind, ormembership assertions of the form t : s, where the term t has kind k ands ∈ Sk. Sentences are Horn clauses on these atomic formulas, i.e., sentencesof the form

∀(x1, . . . , xm). A1 ∧ . . . ∧ An ⇒ A0,

where each Ai is either an equation or a membership assertion, and each xj isa K-kinded variable.

The results presented in Sect. 2.6 can be extended to the case in whichthe underlying equational logic for Meseguer’s rewriting logic is membershipequational logic; we write MERL for it. As there, a binary function symbolR can be used to simulate the rewriting relation in CRWL: the goal in mindis having t → t′ in MERL if and only if R(t, t′) → true in CRWL. Now,in addition, a binary function symbol I is needed to represent equality inmembership equational logic (t = t′ ⇐⇒ I(t, t′) → true), as well as anotherone M to simulate memberships (t : s ⇐⇒ M(t, s)→ true).

A further distinction concerns the treatment of variables. CRWL has notypes so, given the function symbols of a membership equational signature,we could use them to build more terms than those that we would have in theoriginal logic and, moreover, the use of such terms would enlarge the set ofprovable statements in a theory. So it will be necessary to distinguish somehowthe well-typed terms and, for that, we are forced again to represent variables

9

Page 10: Comparing Meseguer’s Rewriting Logic with the Logic CRWLmaude.sip.ucm.es/~miguelpt/papers/wflp01.pdf · extend those already known for Meseguer’s rewriting logic. 1 Introduction

Palomino Tarjuelo

in MERL as constants in CRWL. The task of recognising well-typed termswill be carried out by a binary function symbol wtterm in such a way thatwtterm(t, k)→ true if and only if the term t has kind k. We can use V for theset of variables in MERL and X for the variables in CRWL.

Let then ((K,Σ, S), E) be a MERL signature, i.e., a membership equa-tional logic theory. We associate to it a CRWL-theory with signature Σ′ suchthat CΣ′ = Σ∪true∪K ∪S ∪V (the elements of K, S and V are constants)and FΣ′ = wtterm, R, I,M. The rules defining wtterm are:

wtterm(v, k)→ true (∀v ∈ V of kind k ∈ K),

wtterm(c, k)→ true (∀c : k ∈ Σ),

and, for all f : k1 . . . kn → k ∈ Σ,

wtterm(f(x1, . . . , xn), k)→ true

⇐ wtterm(x1, k1) ./ true, . . . ,wtterm(xn, kn) ./ true.

The translation of the rules of deduction of the equational and rewritingcalculi goes along the same lines as that of Sect. 2.6. For example, the modusponens rule in the equational calculus: for each sentence in the set E of axioms

(∀W) t(v) = t′(v) ⇐ a1(v) = b1(v) ∧ . . . ∧ am(v) = bm(v) ∧

w1(v) : s1 ∧ . . . ∧ wp(v) : sp,

with W ⊆ V containing all variables in v, and given a K-kinded assignmentθ :W → TΣ(W ′), then

E ` (∀W ′) θ(ai) = θ(bi) 1 ≤ i ≤ m E ` (∀W ′) θ(wj) : sj 1 ≤ j ≤ p

E ` (∀W ′) θ(t) = θ(t′),

is simulated by means of (the linearised version of) the rule

I(t(x), t′(x))→ true ⇐ I(a1(x), b1(x)) ./ true, . . . , I(am(x), bm(x)) ./ true,

M(w1(x), s1) ./ true, . . . ,M(wp(x), sp) ./ true,

wtterm(x1, k1) ./ true, . . . ,wtterm(xn, kn) ./ true,

where ki is the kind of vi; and similarly (replacing I with M) for memberships.

The translation of a rewrite rule

[l(v)]→ [r(v)] if [a1(v)]→ [b1(v)] ∧ . . . [am(v)]→ [bm(v)]

is

R(l(x), r(x))→ true ⇐ R(a1(x), b1(x)) ./ true, . . . , R(am(x), bm(x)) ./ true,

wtterm(x1, k1) ./ true, . . . ,wtterm(xn, kn) ./ true,

with ki the kind of vi.

In what follows, we will write δ(T ) for the CRWL-theory associated to aMERL-theory T . We have the following two main results.

10

Page 11: Comparing Meseguer’s Rewriting Logic with the Logic CRWLmaude.sip.ucm.es/~miguelpt/papers/wflp01.pdf · extend those already known for Meseguer’s rewriting logic. 1 Introduction

Palomino Tarjuelo

Proposition 2.3 Let T be a MERL-theory with signature ((K,Σ, S), E), andsuch that δ(T ) = (Σ′,Γ′), and let t, t′, s ∈ Expr⊥(Σ′,X ):

δ(T ) `CRWL I(t, t′)→ true ⇐⇒ (∃k ∈ K) t, t′ ∈ TΣ(V)k and

E ` (∀V) t = t′;

δ(T ) `CRWL M(t, s)→ true ⇐⇒ (∃k ∈ K) t ∈ TΣ(V)k, s ∈ Sk and

E ` (∀V) t : s.

Proposition 2.4 Given any MERL-theory T with signature ((K,Σ, S), E)and set of rules Γ, and given l, r ∈ TΣ(V), the following are equivalent:

(i) T `MERL [l]→ [r];

(ii) (∃l′ ∈ [l],∃r′ ∈ [r]) δ(T ) `CRWL R(l′, r′)→ true;

(iii) (∀l′ ∈ [l],∀r′ ∈ [r]) δ(T ) `CRWL R(l′, r′)→ true.

2.8 Reflection in CRWL and in RL

Intuitively, a reflective logic is a logic in which important aspects of its metathe-ory, such as the concepts of theory and entailment, can be represented andreasoned about in the logic. A general axiomatic notion of reflective logic wasproposed by Clavel and Meseguer [3,4]. The notion is itself expressed in termsof the notion of an entailment system.

Given an entailment system E and a nonempty set of theories C in it, atheory U is C-universal if there is a function, called a representation function,

( ` ) :⋃

T∈C

(T × sen(T ))→ sen(U),

such that for each T ∈ C, ϕ ∈ sen(T ),

T ` ϕ iff U ` T ` ϕ.If, in addition, U ∈ C, then the entailment system E is called C-reflective.Finally, a reflective logic is a logic whose entailment system is C-reflective for Cthe class of all finitely presentable theories in the logic. Recently, the conditionthat the representation function be computable and injective has also beenrequired [6] in order to rule out some degenerate examples of representationfunctions.

RL has been proved to be reflective in [3,4,6] and we will use this result toobtain an analogous one for CRWL. Strictly speaking, the notion of reflectiondoes not apply to CRWL as it was observed in Sect. 2.5 that the CRWL-calculus does not have an associated entailment system. Even in the case ofRL, except for the original result in [3], subsequent generalizations do not im-mediately fit within the formal definition of reflection as they allow conditionalsentences on the left of the entailment relation but not on the right. For thisreason, in what follows we consider a “loose” definition of reflection (makinguse of some kind of “weak” entailment system) general enough to encompass

11

Page 12: Comparing Meseguer’s Rewriting Logic with the Logic CRWLmaude.sip.ucm.es/~miguelpt/papers/wflp01.pdf · extend those already known for Meseguer’s rewriting logic. 1 Introduction

Palomino Tarjuelo

all the cases just discussed.

Let U be a universal theory for RL; we will use it to prove that CRWL isalso reflective. In Sects. 2.5 and 2.6 we defined mappings α and β that mapa theory T in CRWL, respectively in RL, to a theory in RL, respectively inCRWL, which simulates the behaviour of T . By abuse of notation we will alsouse α and β to name the translations of sequents defined in those sections.(Recall that α(T ) is not obtained by simply applying α to every ϕ ∈ T , andanalogously for β.) Then, given an arbitrary CRWL-theory T and a statementϕ, we have the following chain of equivalences:

T `CRWL ϕ ⇐⇒ α(T ) `RL α(ϕ)

⇐⇒ U `RL α(T ) ` α(ϕ)

⇐⇒ β(U) `CRWL β(α(T ) ` α(ϕ)),

which proves that β(U) is universal in CRWL (and, since β was quite simple,not much more complicated than the original U).

As it has been pointed out previously, the reflective results about RLhave been proved only for special cases. The one we need here is that inwhich the underlying equational logic is unsorted and the rules are conditional[6]. Moreover, the results presented here allow us to extend the reflectiveresults to the full power of MERL. For that we can consider that α yieldstheories in MERL, because unsorted equational logic is naturally embeddablein membership equational logic, and let δ be the function defined in Sect. 2.7such that, for T a MERL-theory, T `MERL ϕ ⇐⇒ δ(T ) `CRWL δ(ϕ). Then,for W any universal theory in CRWL (like β(U), for example),

T `MERL ϕ ⇐⇒ δ(T ) `CRWL δ(ϕ)

⇐⇒ W `CRWL δ(T ) ` δ(ϕ)

⇐⇒ α(W) `RL α(δ(T ) ` δ(ϕ)),

which proves that α(W) is universal in MERL.

In Maude, a specification and programming language based on RL, reflec-tion is exploited systematically to extend the language with program transfor-mation methods and internal strategies [5]. In particular, a flexible and robustmodule algebra incorporating parameterisation and object-oriented featuresinto the language has been built in [8]. In T OY, an experimental languageand system that implements the CRWL paradigm, up til now reflection hasplayed no role at all. A possible reason could be that reflection on its ownwere not a sufficient condition for many results, but required the existenceof other logical properties. On the other hand, it could simply be that moreattention has to be paid to it, so that a closer look may reveal some possibleapplications.

12

Page 13: Comparing Meseguer’s Rewriting Logic with the Logic CRWLmaude.sip.ucm.es/~miguelpt/papers/wflp01.pdf · extend those already known for Meseguer’s rewriting logic. 1 Introduction

Palomino Tarjuelo

3 Relations at the Semantic Level

In this section we leave behind our study of the entailment relations and turnour attention to models and satisfaction. Our interest consists in associatingsuitable institutions to both CRWL and RL and, thereafter, to relate themvia maps of institutions with “good” properties.

3.1 Institutions

The notion of model is based on Goguen and Burstall’s pioneering work oninstitutions (see [9]). An institution is a 4-tuple I = (Sign, sen,Mod, |=)such that

• Sign is a category whose objects are called signatures,

• sen : Sign → Set is a functor associating to each signature Σ a set ofΣ-sentences,

• Mod : Signop → Cat is a functor that gives for each signature Σ a categorywhose objects are called Σ-models, and

• |= is a function associating to each Σ ∈ |Sign| a binary relation |=Σ ⊆|Mod(Σ)| × sen(Σ) called Σ-satisfaction, in such a way that the followingproperty holds for any H : Σ→ Σ′, M ′ ∈ |Mod(Σ′)| and all ϕ ∈ sen(Σ):

M ′ |=Σ′ sen(H)(ϕ) ⇐⇒ Mod(H)(M ′) |=Σ ϕ.

Given a set of Σ-sentences Γ, the category Mod(Σ,Γ) is defined as thefull subcategory of Mod(Σ) determined by those models M ∈ |Mod(Σ)|that satisfy all the sentences in Γ. A relation between sets of sentences andsentences, also denoted as |=, can be defined by

Γ |=Σ ϕ ⇐⇒ M |=Σ ϕ for each M ∈ |Mod(Σ,Γ)|.

We can then associate an entailment system to each institution I = (Sign, sen,Mod, |=) in a natural way by means of the triple I+ = (Sign, sen, |=), where|= now denotes the previously defined relation between sets of sentences andsentences; I+ is easily seen to satisfy the conditions to be an entailment sys-tem.

Given an institution I, its category Th of theories is defined as the categoryof theories associated to the entailment system I+. If H : (Σ,Γ) → (Σ′,Γ′)is a theory morphism and M ′ ∈Mod(Σ′,Γ′), it is not difficult to check thatMod(H)(M ′) ∈Mod(Σ,Γ). The model functor Mod can then be extendedto a functor Mod : Thop → Cat.

Given institutions I = (Sign, sen,Mod, |=) and I ′ = (Sign′, sen′,Mod′,|=′), a map of institutions (Φ, α, β) : I → I ′ consists of a natural transfor-mation α : sen ⇒ sen′ Φ, an α-sensible functor 3 Φ : Th0 → Th′0, and a

3 Essentially, this means that Φ is completely determined by its restriction to theories andα. See [12] for more details.

13

Page 14: Comparing Meseguer’s Rewriting Logic with the Logic CRWLmaude.sip.ucm.es/~miguelpt/papers/wflp01.pdf · extend those already known for Meseguer’s rewriting logic. 1 Introduction

Palomino Tarjuelo

natural transformation β : Mod′ Φop ⇒Mod such that for each Σ ∈ |Sign|,ϕ ∈ sen(Σ), and M ′ ∈ |Mod′(Φ(Σ, ∅))| the following property is satisfied:

M ′ |=′Σ′ αΣ(ϕ) ⇐⇒ β(Σ,∅)(M′) |=Σ ϕ.

3.2 The models of RL

Before proceeding to R-systems, the models of RL, we need the categori-cal notion of subequalizer [11], a notion generalizing that of equalizer of twofunctors 4 .

Given a family of pairs of functors Fi, Gi : A → Bi | i ∈ I, the (simul-taneous) subequalizer of this family is a category Subeq((Fi, Gi)i∈I) togetherwith a functor

J : Subeq((Fi, Gi)i∈I)→ Aand a family of natural transformations αi : Fi J ⇒ Gi J | i ∈ I satisfyingthe following universal property: Given a functor H : C → A and a family ofnatural transformations βi : Fi H ⇒ Gi H | i ∈ I, there exists a uniquefunctor (H, βii∈I) : C → Subeq((Fi, Gi)i∈I) such that

J (H, βii∈I) = H and αi (H, βii∈I) = βi (i ∈ I).

Then, given an RL-theory R = (Σ, E, L,Γ), an R-system S is a categoryS together with:

• a (Σ, E)-algebra structure given by a family of functors

fS : Sn → S | f ∈ Σn, n ∈ Nsatisfying the equations E, i.e., for any t(x1, . . . , xn) = t′(x1, . . . , xn) in Ewe have an identity of functors tS = t′S , where the functor tS is definedinductively from the functors fS in the obvious way.

• for each rewrite rule

r : [t(x)]→ [t′(x)] if [a1(x)]→ [b1(x)] ∧ . . . ∧ [am(x)]→ [bm(x)]

in Γ, a natural transformation

rS : tS JS ⇒ t′S JS ,

where JS : Subeq((ajS , bjS)1≤j≤m)→ Sn is the subequalizer functor.

An R-homomorphism F : S → S ′ between two R-systems is then a functorF : S → S ′ such that

• it is a Σ-algebra homomorphism, i.e., F fS = fS′ Fn, for each f in Σn,

n ∈ N, and

• “F preserves Γ” (see [14]).

This defines a category R-Sys in the obvious way.

4 In [16], subequalizers are shown to coincide with inserters, a special kind of weighted limit,in the 2-category Cat. This allows the author to generalize the models of RL, building themover arbitrary 2-categories and even enriched categories.

14

Page 15: Comparing Meseguer’s Rewriting Logic with the Logic CRWLmaude.sip.ucm.es/~miguelpt/papers/wflp01.pdf · extend those already known for Meseguer’s rewriting logic. 1 Introduction

Palomino Tarjuelo

A sequent [t(x1, . . . , xn)]→ [t′(x1, . . . , xn)] is satisfied by an R-system S ifthere exists a natural transformation

α : tS ⇒ t′S

between the functors tS , t′S : Sn → S. We use the notation

S |= [t(x1, . . . , tn)]→ [t′(x1, . . . , xn)].

With respect to this definition of satisfaction, the proof calculus is soundand complete [14]. Completeness is obtained by means of an initial modelconstruction.

3.3 The models of CRWL

Before defining models we review some definitions. A partially ordered set (inshort, poset) with bottom ⊥ is a set S equipped with a partial order v anda least element ⊥. We say that an element x ∈ S is totally defined if x ismaximal with respect to v. The set of all totally defined elements of S willbe denoted Def (S). D ⊆ S is a directed set if for all x, y ∈ D there existsz ∈ D with x v z, y v z. A subset A ⊆ S is a cone if ⊥ ∈ D and, for allx ∈ A, y ∈ S, if y v x then y ∈ A. An ideal I ⊆ S is a directed cone. Forx ∈ S, the principal ideal generated by x is 〈x〉 = y ∈ S | y v x. We writeC(S) for the set of cones of S.

Given a signature Σ, a CRWL-algebra over Σ is a triple

A = (DA, cAc∈CΣ, fAf∈FΣ

),

where DA is a poset with bottom, and cA and fA are monotone mappings from(DA)n to C(DA), with n the corresponding arity. In addition, for c ∈ Cn

Σ andfor all u1, . . . , un ∈ DA, there exists a v ∈ DA such that cA(u1, . . . , un) = 〈v〉.Moreover, v ∈ Def (DA) in case that all ui ∈ Def (DA).

Note that any h : S → C(S ′) can be extended to a function h : C(S) →C(S ′) defined by h(x) =

x∈S h(x). By an abuse of notation, we will write halso as h in the sequel.

A valuation over A is any mapping η : X → DA, and we say that ηis totally defined if η(x) ∈ Def (DA) for all x ∈ X . The evaluation of anexpression e ∈ Expr⊥(Σ,X ) in A under η yields [[e]]Aη ∈ C(DA) which isdefined recursively as follows:

• [[⊥]]Aη = 〈⊥A〉.• [[x]]Aη = 〈η(x)〉, for x ∈ X .

• [[h(e1, . . . , en)]]Aη = hA([[e1]]Aη, . . . , [[e1]]Aη), for all h ∈ CnΣ ∪ F n

Σ .

We are now prepared to define models. Assume a program Γ and a CRWL-algebra A. We define:

• A satisfies a reduction statement a→ b under a valuation η, (A, η) |= a→ b,if [[a]]Aη ⊇ [[b]]Aη.

• A satisfies a joinability statement a ./ b under η, (A, η) |= a ./ b, if [[a]]Aη ∩15

Page 16: Comparing Meseguer’s Rewriting Logic with the Logic CRWLmaude.sip.ucm.es/~miguelpt/papers/wflp01.pdf · extend those already known for Meseguer’s rewriting logic. 1 Introduction

Palomino Tarjuelo

[[b]]Aη ∩ Def (DA) 6= ∅.• A satisfies a rule l → r ⇐ C if every valuation η such that (A, η) |= C

verifies (A, η) |= l→ r.

• A is a model of Γ, A |= Γ if A satisfies all the rules is Γ.

With respect to this notion of satisfaction, the CRWL-calculus is partiallysound and complete [10].

Finally, we can also define homomorphisms between CRWL-algebras. LetA, B be two CRWL-algebras over a signature Σ. A CRWL-homomorphismH : A → B is a monotone function H : DA → C(DB) which satisfies thefollowing conditions:

(i) H is element-valued: for all u ∈ DA there exists v ∈ DB such thatH(u) = 〈v〉.

(ii) H is strict: H(⊥A) = 〈⊥B〉.(iii) H preserves constructors: for all c ∈ Cn

Σ, ui ∈ DA, is H(cA(u1, . . . , un)) =cB(H(u1), . . . , H(un)).

(iv) H loosely preserves defined functions: that is, for all f ∈ F nΣ , ui ∈ DA,

H(fA(u1, . . . , un)) ⊆ fB(H(u1), . . . , H(un)).

CRWL-algebras as objects with CRWL-homomorphisms as arrows form a cat-egory.

3.4 An institution for CRWL

An institution for CRWL was first defined in [17]. This institution, however,was defined with the goal of providing a basis for the semantics of modules inCRWL, and restricts its attention to a class of particular term algebras. Sinceour objective is more general, we do not place such a limitation and defineICRWL = (Sign, sen,Mod, |=) as follows:

• Sign: the category of signatures with constructors and signature mor-phisms;

• sen : Sign → Set the functor assigning to each signature Σ the set ofall conditional rewrite rules over it, and to each signature morphism, itsobvious extension to rewrite rules;

• Mod : Signop → Cat the functor assigning to each signature the categoryof CRWL-algebras and homomorphisms over it, and to each σ : Σ→ Σ′ theforgetful functor taking A′ ∈ |Mod(Σ′)| to the CRWL-algebra A′σ with thesame underlying poset and such that hA

′σ = σ(h)A

′for all h ∈ Σ, and which

is the identity over homomorphisms;

• |= the satisfaction relation in CRWL.

Proposition 3.1 ICRWL is an institution.

16

Page 17: Comparing Meseguer’s Rewriting Logic with the Logic CRWLmaude.sip.ucm.es/~miguelpt/papers/wflp01.pdf · extend those already known for Meseguer’s rewriting logic. 1 Introduction

Palomino Tarjuelo

Proof. It is not difficult to check that Sign is a category, and that sen andMod are indeed functors. As for the satisfaction condition, let σ : Σ → Σ′

be a signature morphism, A′ ∈ |Mod(Σ′)|, and ϕ ∈ sen(Σ); we have to provethat

A′ |= σ(ϕ) ⇐⇒ A′σ |= ϕ.

It can be shown by structural induction on e that

[[e]]A′ση = [[σ(e)]]A

′η

for every e ∈ Expr⊥(Σ,X ) and valuation η over A′. Let ϕ = e → e′ be areduction statement. Then, for any valuation η,

(A′, η) |= σ(ϕ) ⇐⇒ [[σ(e′)]]A′η ⊆ [[σ(e)]]A

′η

⇐⇒ [[e′]]A′ση ⊆ [[e]]A

′σ ⇐⇒ (A′σ, η) |= ϕ,

and analogously for ϕ a joinability statement. Now, if l → r ⇐ C is aconditional rewrite rule, it follows that A′σ |= C ⇐⇒ A′ |= σ(C) andA′σ |= l → r ⇐⇒ A′ |= σ(l → r), and thus the satisfaction condition isindeed verified. 2

It can be proved that the category Mod(T ) has products for every CRWL-theory T ; it is not complete, however, as in Sect. 3.6 it is shown that, in general,Mod(T ) does not have equalizers. ICRWL is also a semiexact institution [18].

3.5 An institution for RL

The task of assigning an institution to RL is harder than expected. The firstand more natural idea is to define the category of signatures Sign as thecategory of equational theories and theory morphisms, and the functor sento map any such theory to the set of conditional rewrite rules over it. Sincethere are also notions of model and satisfaction in RL, the desired institutionseems to be at hand. However, when one tries to put together the variouscomponents of the institution, problems start to arise. In the first place, thenotion of satisfaction in RL is defined only for unconditional rewrite rules,so our first task must be to extend its definition so as to encompass theconditional ones. Although there are at least two possible ways in which thiscould be done, this is a relatively minor problem which can be solved bymirroring the definition of R-systems (see [18]).

A far more serious problem is posed by the functor Mod : Signop →Cat, mapping signatures to models. The difficulty resides in the fact that,in RL, models are assigned directly to RL-theories instead of signatures, asit is customary in other logics. One obvious solution would be to consider asignature (Σ, E) as a theory R = (Σ, E, ∅, ∅) with empty set of axioms (andlabels), and to map (Σ, E) to the category R-Sys of models of R. But thisapproach presents an important drawback. Up to this point in the paper,we have omitted any explicit mention of the set of labels of an RL-theory.Although this was a safe convention when talking about deduction, it is not

17

Page 18: Comparing Meseguer’s Rewriting Logic with the Logic CRWLmaude.sip.ucm.es/~miguelpt/papers/wflp01.pdf · extend those already known for Meseguer’s rewriting logic. 1 Introduction

Palomino Tarjuelo

longer the case when our interest shifts to models. Due to the set of labels Lin an RL-theory R = (Σ, E, L,Γ), the elements of Γ become special, labelledrewrite rules. These rules force R-systems to have a certain internal structure:not only must R-systems satisfy them, but also must associate to them adistinguished interpretation (natural transformation) that must be preservedby homomorphisms 5 . When considering a signature as a theory with emptysets of axioms, we are not taking into account labelled rewrite rules. Thisway, homomorphisms are not subjected to preserve any rewrite rule and thecategory Mod(Γ) of models of Γ, and the category R-Sys of R-systems, turnout to be different, in opposition to our original intention.

Keeping Sign as the category of equational theories, there are other pos-sibilities as to how to define Mod (and even |=) but, since they cannot re-flect the distinction between labelled rules belonging to RL-theories and un-labelled rules, all of them are bound to failure (see [18] for a detailed dis-cussion). For this reason we are led to an institution in which the categorySign subsumes all the information of an RL-theory. More precisely, we defineIRL = (Sign, sen,Mod, |=) where:

• Sign is the discrete category of RL-theories;

• sen : Sign → Set maps each RL-theory to its corresponding set of condi-tional rewrite rules;

• Mod : Signop → Cat maps an RL-theory R to the category R-Sys;

• |= the satisfaction relation conveniently extended to conditional rewriterules as discussed above.

Since Sign is discrete, this trivially defines an institution. Admittedly, thisrestriction seems to be not justified. In fact, two types of morphisms of RL-theories are proposed in [13]. Basically, they are equational theory morphisms“preserving” the rules in the RL-theories; a complete study of the institutionIRL extended with these morphisms will be undertaken in a future occasion.For our purposes, the present definition is general enough as it stands, and itsextension would not modify the use we will make of it in the next section.

There exist other institutions associated to (varieties of) RL in the liter-ature, e.g., [2,7]; in these papers, the objects in the category of signaturesare the sets of function symbols, without any rules. As a consequence of thissimplicity and because of the reasons we have mentioned above, the generalcategorical models of RL must be somehow restricted, and the choice in thesetwo papers is to require them to be preorders instead of general categories.

5 In particular, the same rule can appear twice in an RL-theory R under two differentlabels. R-systems are then forced to provide two, possibly different, interpretations for thesame rule, each of them to be preserved by the homomorphisms.

18

Page 19: Comparing Meseguer’s Rewriting Logic with the Logic CRWLmaude.sip.ucm.es/~miguelpt/papers/wflp01.pdf · extend those already known for Meseguer’s rewriting logic. 1 Introduction

Palomino Tarjuelo

3.6 Searching for embeddings

We would like to relate the institutions ICRWL and IRL by means of a mapof institutions (Φ, α, β) : ICRWL → IRL having nice properties, in such away that it indicated that ICRWL could be considered as a subinstitution ofIRL. The formal definition of subinstitution appeared originally in [12] andhas been further generalized in subsequent articles. One of those extensionswas introduced by Meseguer in [15], where it is called an embedding. Theonly requirement imposed on a map of institutions (Φ, α, β) : I → I ′ to bean embedding is that for each T ∈ |ThI |, the functor βT : Mod′(Φ(T )) →Mod(T ) must be an equivalence of categories.

We will show, however, that there is no embedding from ICRWL intoIRL. For that it will be enough to find a categorical property which is pre-served by an equivalence of categories and a theory T ∈ |ThCRWL| such thatModRL(Φ(T )), but not ModCRWL(T ), has the property.

Let Σ be a signature with constructors such that CΣ = ∅ and FΣ consistsof just two constants f1 and f2, Γ = f2 → x ⇐ f1 ./ f1, and considerthe CRWL-theory T = (Σ,Γ). We define two CRWL-algebras over Σ: Agiven by the set DA = ⊥, a1, a2 with partial order ⊥ v a1 v a2 and thecones fA1 = 〈a1〉 and fA2 = 〈⊥〉; and B with DB = ⊥, b1 and the conesfB1 = fB2 = 〈⊥〉. A,B ∈ |ModCRWL(T )| trivially, because they do not satisfythe condition f1 ./ f1.

Let us now define two CRWL-homomorphisms F,G : A → B, given by:

F (x) = 〈⊥〉 and G(x) =

〈⊥〉 if x = ⊥, a1

〈b1〉 if x = a2.

Clearly, F and G preserve both f1 and f2, so that they are actually homomor-phisms; in [18] it is shown that they do not have an equalizer.

In contrast with what happens in CRWL, equalizers can be built in R-Sysby mimicking the construction in Cat [18]. Since an equivalence of categoriespreserves limits, we have:

Proposition 3.2 ICRWL is not embeddable in IRL.

What about the other way around? Can we embed IRL in ICRWL? In orderto prove that RL cannot be embedded in CRWL we have to find an RL-theoryT such that ModRL(T ) has a categorical property that no category of modelsin CRWL has. In what follows, two such theories are shown.

For the first one, note that for any CRWL-theory T there exists a CRWL-algebra A ∈ |ModCRWL(T )| with an infinite number of automorphisms. Sim-ply considerA given by DA = ⊥, a, b1, b2, . . . with ⊥ v a, ⊥ v b1 v b2 v . . .,the image of all functions associated to constructor symbols to be 〈a〉, andthe corresponding one of defined function symbols to be DA. This way Ais clearly a CRWL-algebra, satisfies all conditional rewrite rules, and the set

19

Page 20: Comparing Meseguer’s Rewriting Logic with the Logic CRWLmaude.sip.ucm.es/~miguelpt/papers/wflp01.pdf · extend those already known for Meseguer’s rewriting logic. 1 Introduction

Palomino Tarjuelo

Fi : A → Ai∈N, where

Fi(x) =

〈⊥〉 if x = ⊥

〈a〉 if x = a

〈bi〉 if x = bj (j ∈ N)

is an infinite family of automorphisms of A. On the other hand, in RL, if Ris the RL-theory given by (c, x = c, ∅, ∅) then, for all R-systems S, theequality idS = cS , where cS is a constant functor, forces S to be a categorywith just one object and one arrow, and no infinite family of homomorphismscan exist. Therefore (as an equivalence of categories is full and faithful),ModRL(R) is not categorically equivalent to ModCRWL(Φ(R)), whatever Φmight be.

For the second one note that, ifR = (Σ, E, L,Γ) is an RL-theory and thereare no constants in Σ, then ∅ is the initial R-system. In addition, for eachother R-system S we have ∅ × S = ∅ (products in R-Sys follow the samestructure as in Cat). In CRWL, however, the initial algebra I is never emptyfor any CRWL-theory (⊥ ∈ DI , see the construction in [10]) and, if we choosea CRWL-algebra A whose underlying poset has a greater cardinality than thatof I (generalizing, if necessary, the construction in the previous paragraph),we will have that A × I is not even isomorphic to I. Since equivalences ofcategories should preserve both limits and colimits, we conclude the following

Proposition 3.3 IRL is not embeddable in ICRWL.

Admittedly, although these two counterexamples formally solve the prob-lem, they are so particular that they cannot be considered to truly reflect thereal differences between RL and CRWL. Future work should concentrate onfinding a more illustrative example.

4 Conclusions

The main outcome of the research carried out in this paper has been theclarification of the relationship between RL and CRWL. Both logics have beenproved to be expressive enough to simulate deduction in each other in a simpleway, though resorting to binary predicates. On the other hand, the resultson institutions have shown that neither can RL be considered as a sublogic ofCRWL, nor can CRWL with respect to RL.

During the preparation of this work we have been forced to take a closelook at the notions of entailment system and institution, and the difficultieswe have found have shown us that intuition can be misleading in this field.The conclusion we have reached is that it would be very convenient to developsome kind of generalization of these concepts. One reason supporting thisclaim is the fact that, although it seems clear that CRWL should fit withinthe frame of entailment systems, the lack of the transitivity property forbids it

20

Page 21: Comparing Meseguer’s Rewriting Logic with the Logic CRWLmaude.sip.ucm.es/~miguelpt/papers/wflp01.pdf · extend those already known for Meseguer’s rewriting logic. 1 Introduction

Palomino Tarjuelo

to be considered so. In addition, there have been several occasions wherein wehave had to make a distinction between two types of sentences within the samelogic. The most outstanding case was that of labelled and unlabelled rewriterules in RL, but we should also emphasize that rules in CRWL-programsare a restricted class of the more general class of reduction statements, andthat, when we talked about reflection, we had to “weaken” its definition inorder to encompass some of the results about RL, due to conditional sentencesnot being treated like unconditional ones. What all these examples have incommon is that sentences belonging to a theory are given a different treatmentfrom the rest of sentences and, with the current definitions of entailmentsystem and institution, there is no way of taking this distinction into account.

For future work, besides the generalizations just mentioned, it would beinteresting to complete the definition of the institution IRL with signaturemorphisms (morphisms of RL-theories), as well as finding a more illustrativeexample showing the reasons why RL is not embeddable in CRWL.

Acknowledgments

The author is indebted to Narciso Martı-Oliet, Mario Rodrıguez-Artalejo, JoseMeseguer and the anonymous referees, for their valuable comments.

References

[1] Arenas-Sanchez, P. and M. Rodrıguez-Artalejo, A general framework for lazyfunctional logic programming with algebraic polymorphic types, Theory andPractice of Logic Programming 1 (2001), pp.185–245.

[2] Cengarle, M. V., The rewriting logic institution, Technical Report 9801, Ludwig-Maximilians-Universitat Munchen, Institut fur Informatik (1998).

[3] Clavel, M., “Reflection in General Logics and in Rewriting Logic, withApplications to the Maude Language,” Ph.D. thesis, Universidad de Navarra,Spain (1998).

[4] Clavel, M., “Reflection in Rewriting Logic: Metalogical Foundations andMetaprogramming Applications,” CSLI Publications, 2000.

[5] Clavel, M., F. Duran, S. Eker, P. Lincoln, N. Martı-Oliet, J. Meseguer and J. F.Quesada, Maude: Specification and programming in rewriting logic, TheoreticalComputer Science (2002), to appear.

[6] Clavel, M. and J. Meseguer, Reflection in conditional rewriting logic, TheoreticalComputer Science (2002), to appear.

[7] Diaconescu, R. and K. Futatsugi, Logical foundations of CafeOBJ, TheoreticalComputer Science (2002), to appear.

21

Page 22: Comparing Meseguer’s Rewriting Logic with the Logic CRWLmaude.sip.ucm.es/~miguelpt/papers/wflp01.pdf · extend those already known for Meseguer’s rewriting logic. 1 Introduction

Palomino Tarjuelo

[8] Duran, F., “A Reflective Module Algebra with Applications to the MaudeLanguage,” Ph.D. thesis, Universidad de Malaga, Spain (1999), http://maude.csl.sri.com.papers.

[9] Goguen, J. and R. Burstall, Institutions: Abstract model theory for specificationand Programming, Journal of the Association for Computing Machinery 39(1992), pp. 95–146.

[10] Gonzalez-Moreno, J. C., M. T. Hortala-Gonzalez, F. J. Lopez-Fraguas andM. Rodrıguez-Artalejo, An approach to declarative programming based on arewriting logic, Journal of Logic Programming 40 (1999), pp. 47–87.

[11] Lambek, J., Subequalizers, Canadian Mathematical Bulletin 13 (1970), pp. 337–349.

[12] Meseguer, J., General logics, in: H.-D. Ebbinghaus, J. Fernandez-Prida,M. Garrido, D. Lascar and M. Rodrıguez-Artalejo, editors, Logic Colloquium’87(1989), pp. 275–329.

[13] Meseguer, J., Rewriting as a unified model of concurrency, Technical ReportSRI-CSL-90-02, SRI International, Computer Science Laboratory (1990), revisedJune 1990.

[14] Meseguer, J., Conditional rewriting logic as a unified model of concurrency,Theoretical Computer Science 96 (1992), pp. 73–155.

[15] Meseguer, J., Membership algebra as a logical framework for equationalspecification, in: F. Parisi-Presicce, editor, Recent Trends in AlgebraicDevelopment Techniques, 12th International Workshop, WADT’97, Tarquinia,Italy, June 3–7, 1997, Selected Papers, Lecture Notes in Computer Science 1376(1998), pp. 18–61.

[16] Miyoshi, H., Modelling Conditional Rewriting Logic in Structured Categories,in: J. Meseguer, editor, Proceedings First International Workshop on RewritingLogic and its Applications, WRLA’96, Asilomar, California, September 3–6,1996, Electronic Notes in Theoretical Computer Science 4 (1996), pp. 20–34,http://www.elsevier.nl/locate/entcs/volume4.html.

[17] Molina-Bravo, J. M., “Modularidad en Programacion Logico-Funcional dePrimer Orden,” Ph.D. thesis, Universidad de Malaga, Spain (2000).

[18] Palomino Tarjuelo, M., “Relating Meseguer’s rewriting logic with theconstructor-based rewriting logic,” Master’s thesis, Facultad de Matematicas,Universidad Complutense de Madrid (2001), http://maude.csl.sri.com/papers.

22