The same way that equations or memberships expressed in their fullest possible generality cannot be executed by the Maude engine except in a controlled way at the metalevel, conditional rewrite rules in their fullest generality cannot be executed either, except with a strategy at the metalevel. Nonexecutable rules should be identified by giving them the nonexec attribute.
As for functional modules, the question now becomes: what are the executability requirements on the executable statements (i.e., those without the nonexec attribute) of a system module? It turns out that a quite general class of system modules, called admissible modules, are executable by Maude's default interpreter using the rewrite, frewrite, and search commands, that will be introduced and illustrated in Section 5.4 and are further explained in Sections 16.2 and 16.4.
The admissibility requirements for the module's equations and memberships are exactly as for functional modules; they were explained in Section 4.6 and are further discussed below. Two more requirements are needed:
We explain each of these requirements below.
Given a system module
, a conditional5.2 rule of the form
Operationally, we try to satisfy
such a rewrite condition by reducing the
substitution instance
to its canonical form
with respect
to the equations, and then trying to find a rewrite proof
(perhaps after many steps of rewriting) with
in
canonical form with respect to the equations and such that
is a substitution instance of
. Search for such a
is
performed by the Maude engine using a breadth-first strategy.
As for functional modules, when executing an admissible conditional rule in a system module, the satisfaction of all its conditions is attempted sequentially from left to right; but notice that now, besides the fact that many matches for the equational conditions may be possible due to the presence of equational attributes, we also have to deal with the fact that solving rewrite conditions requires search, including searching for new solutions when previous ones fail to satisfy subsequent conditions.
We now explain the coherence requirement. A rewrite theory has both rules and equations, so that rewriting is performed modulo such equations. However, this does not mean that the Maude implementation must have a matching algorithm for each equational theory that a user might specify, which is impossible, since matching modulo an arbitrary equational theory is undecidable.
The equations and memberships specified in a system module
are
divided into a set
of axioms corresponding to equational
attributes such as associativity, commutativity, idempotency, and
(left-, right- or two-sided) identity declared for different operators
in the module (see Section 4.4.1), for which matching
algorithms exist in the Maude implementation, and a set
of
equations and memberships specified in the ordinary way. As already
mentioned, for
to be executable, the set of executable statements
in
must be Church-Rosser and terminating modulo
, or at
least ground Church-Rosser and terminating modulo
; that is, we
require that the equational part must be equivalent to an executable
functional module.
Moreover, we require that the rules
in the module are
coherent [72] with respect to the equations
modulo
,
or at least ground coherent. Coherence means that, given a
term
, for each one-step rewrite of it with
some rule in
modulo the axioms
to some term
, which we denote
, if
is the canonical term
we obtain by rewriting
with the equations and memberships in
to canonical form modulo
, denoted
,
then there is a one-step rewrite of
with some rule
in
modulo
,
, such that
, which by the Church-Rosser and termination
properties of
modulo
is equivalent to
and
having the same
canonical form modulo
by
. This requirement is described
graphically in Figure 5.1.
Ground coherence
is a weaker requirement: we require the exact
same diagram to exist only for ground terms, and
only needs to be ground Church-Rosser and terminating modulo
.
As explained in [72] (for the free case and for coherence
modulo associativity and commutativity), for unconditional rules
,
coherence can be checked by checking
``critical pairs'' between rules
and equations
, and showing that the corresponding instance of
the coherence diagram can be filled in for all such pairs. That is,
we have to look for appropriate overlaps between lefthand sides of rules
and equations using an
-unification algorithm, generate the
corresponding critical pairs, and check their coherence. In the case
of ground coherence, it is not necessary that the critical pairs can
be filled in: it is enough to show that each ground instance of
such pairs can be filled in.
See Section 7.8 of [16]
for an example of a system module that is not coherent, a
discussion of the critical pairs involved, and a method to make the
specification coherent. See also Section 13.4 of [16] for
an example of how coherence can be checked by critical pair analysis.
Similarly, for ground coherence and how to
check it, see the example in Section 9.4.
Why is coherence so important? What does it mean intuitively?
Rewriting modulo
an equational theory
, which is what a
rewrite theory
really does, is
in general undecidable. The undecidability has to do with the fact
that we may need to search an entire
-equivalence class before
we can know if a class representative can be rewritten with
, that
is, if the
-equivalence class can be rewritten. Coherence
makes the problem decidable: all we need to do is to reduce the term
to its canonical form by
modulo
, and then rewrite with
such a canonical form. In a sense, coherence reduces rewriting with
modulo
to rewriting with
and
modulo
, which is
decidable, because we assume we have an
-matching algorithm.
Could we miss any rewrites that way? Coherence guarantees to us that
we could not, since any rewrite of a term
with
must also be
possible with
's canonical form. Maude implicitly assumes this
coherence property. For example, the rewrite
command will at
each step first reduce the term to canonical form with
modulo
,
and then perform a rewrite step with
in a rule-fair manner. The
frewrite
command uses a somewhat different rewrite strategy
to ensure both local fairness and rule fairness, but assumes the
same coherence (or ground coherence) property
(see Section 16.2 and examples in
Section 5.4 below).
A last point about the execution of system modules regards frozen argument positions in operators (see Section 4.4.9). This poses a general constraint on any rewriting strategy whatsoever, including those directly supported by Maude for the rewrite and frewrite commands (see Section 5.4). The general constraint is that rewriting will never happen below one of the frozen argument positions in an operator. That is, even though many rewritings may be possible and there can be a large amount of nondeterminism (so that different rewriting strategies may lead to quite different results) rewriting under frozen arguments is always forbidden. In fact, this does not only belong to the module's operational semantics, but also to the latest initial model semantics for rewrite theories developed in [8]; we give a brief informal summary of this semantics below.
Mathematically, a system module, when ``flattened'' with its imported
submodules, exactly specifies a (generalized) rewrite theory in the
sense of [8],
that is, a four-tuple
Intuitively, such a rewrite theory specifies a concurrent system. The
equational theory
specifies the ``statics'' of the system,
that is, the algebraic structure of the set5.3 of states, which is specified by the initial
algebra
. The rules
and the freezing information
specify the concurrent system's ``dynamics,'' that is, the possible
concurrent transitions that the system can perform. In rewriting logic, such,
possibly complex, concurrent transitions exactly correspond to rewrite
proofs;
but since several rewrite proofs
can indeed correspond to the same concurrent computation (describing, for
example, different semantically equivalent interleavings), rewriting logic has
an equational theory of proof equivalence
[57,8].
The initial model
of the rewrite theory
associates to each kind
a labeled transition system (in fact, a
category) whose set of states is
, and whose
labeled transitions have the form
,
with
, and with
an equivalence
class of rewrite proofs modulo the equational theory of proof equivalence.
Indeed what the different
represent are the different
``truly concurrent'' computations of the system specified by
.