Graded Quantitative Rewriting Theory
- Graded quantitative rewriting is a framework that embeds quantitative measurements into rewriting systems using quantales and graded contexts.
- It refines classical rewriting by replacing traditional notions like convertibility and confluence with quantitative analogues that support modal, coeffectful, and trace-based interpretations.
- The theory employs graded substitution, balanced rule conditions, and coalgebraic semantics to precisely manage resource usage and distance metrics in computational systems.
Graded quantitative rewriting is a theory of rewriting in which reduction steps carry quantitative information—such as distance, cost, degree, or resource usage—valued in a quantale, and in which contexts act on these quantities through an explicit graded structure, typically given by quantale homomorphisms or change-of-base endomorphisms. In its contemporary form, the subject combines several strands: quantale-enriched abstract rewriting and term rewriting, graded context sensitivity and balanced substitution, coalgebraic graded semantics via graded monads, and quantitative narrowing for solving equations modulo graded rewrite theories. The resulting framework refines classical rewriting theory by replacing reachability, convertibility, and confluence with quantitative analogues, while also supporting modal, coeffectful, and trace-based interpretations of computation (Gavazzo et al., 2022, Ayala-Rincón et al., 25 Jul 2025, Forster et al., 2023).
1. Quantitative foundations
The underlying quantitative domain is a quantale. One standard presentation writes a quantale as
where is a complete lattice, is a commutative monoid, and distributes over arbitrary joins. A closely related notation uses
with the same structural requirements. The graded rewriting literature concentrates on commutative, integral, cointegral, non-trivial quantales, often called Lawvereian; the guiding example is the Lawvere quantale
where the order is reversed so that smaller metric distances correspond to larger elements (Gavazzo et al., 2022, Ayala-Rincón et al., 25 Jul 2025).
A quantitative relation is a quantale-valued relation. In one formulation, a -relation is a map
with relational composition
In another, equivalent ternary presentation, one works with 0, where the middle component records the degree of the step. The diagonal relation
1
or
2
acts as identity. Reflexivity, symmetry, and transitivity then generalize the usual metric or preorder axioms. In the Lawvere case, equivalence 3-relations are exactly pseudometrics (Gavazzo et al., 2022).
A quantitative abstract rewriting system is therefore a pair 4 with 5. Its closures are defined by the standard relational operations: 6 The symmetric and convertibility closures yield quantitative analogues of bidirectional rewriting. For a path
7
the induced degree is bounded by 8; in the Lawvere quantale this is 9. Quantitative rewriting thus treats the distance between objects as a closure of one-step reductions rather than as a separate semantic layer (Gavazzo et al., 2022).
2. Grades, contexts, and the structure of term rewriting
The specifically graded component is introduced through quantale endomorphisms. A change-of-base endomorphism 0 preserves unit, tensor, and arbitrary joins: 1 These endomorphisms, called CBEs, form a structure
2
closed under composition and pointwise tensor. They describe how a context amplifies a degree (Ayala-Rincón et al., 25 Jul 2025).
A graded signature assigns such grades to argument positions. If 3 is 4-ary, its modal arity is a tuple
5
The grade of a position 6 in a term 7 is defined compositionally: 8 when 9. The grade of a variable 0 in 1 is then
2
An equivalent notation in the earlier formulation writes these quantities as 3 and 4 (Gavazzo et al., 2022, Ayala-Rincón et al., 25 Jul 2025).
A graded quantitative term rewriting system is a pair 5, or in the earlier notation 6, where rewrite rules have degrees and are closed under graded contexts. The one-step rewrite relation is generated by
7
so the step degree is the rule degree 8 amplified by the grade of the redex position. In the context-hole formulation, the contextual rule is
9
where 0 is the grade of the hole in 1. The non-expansive case is recovered by taking all grades to be the identity, so that contexts do not amplify distances (Gavazzo et al., 2022, Ayala-Rincón et al., 25 Jul 2025).
Balancedness is the central well-formedness condition for graded rules. A rule 2 is balanced if, for every variable 3,
4
This prevents rules from creating or deleting graded uses of variables and is crucial for graded substitution lemmas and confluence arguments (Gavazzo et al., 2022).
The shift from non-expansive to graded rewriting is motivated by distance trivialization. In the non-expansive framework, allowing non-linear duplication under a constructor treated as non-expansive can force the induced convertibility distance to collapse to the degenerate values 5 or 6. Grading repairs this by making duplication explicit and quantitatively accountable: contexts no longer preserve degrees automatically, but transform them according to their declared sensitivities (Gavazzo et al., 2022).
3. Quantitative metatheory
Classical metatheorems of rewriting admit quantale-valued analogues. For quantitative abstract rewriting systems, confluence, local confluence, commutation, and Church–Rosser are stated as relational inequalities. For example, if 7, then 8 commutes with 9 when
0
and 1 is confluent when 2 has the diamond property. The quantitative Church–Rosser theorem states: 3 This says that convertibility distances can be computed through convergent valleys, not merely through arbitrary zig-zags (Gavazzo et al., 2022).
Termination is refined through strong normalization and induction over quantale-valued predicates. An element is a normal form if 4, and 5 is strongly normalising if every reduction sequence terminates. Quantitative induction is expressed by the condition
6
and one has
7
which is the quantitative form of Newman’s Lemma. Hindley–Rosen modularity also lifts: if 8 commutes with 9 and both subsystems are confluent, then 0 is confluent (Gavazzo et al., 2022).
For term rewriting, critical-pair analysis persists but requires linearity or graded balance hypotheses. In the non-expansive setting, the paper proves: if a linear 1-TRS is locally confluent on all critical pairs, then it is locally confluent; hence any linear, terminating 2-TRS that is locally confluent on critical pairs is confluent. In the graded setting, the corresponding statement is strengthened to left-linear, balanced systems that are strongly closed on critical pairs. Orthogonality—left-linearity plus absence of critical pairs—again implies confluence, now for the graded multi-step relation 3 (Gavazzo et al., 2022).
The graded substitution lemma is one of the technically decisive results: 4 It states that substitution scales argument distances by the variable grades of the term into which the substitution is performed. This is the exact graded replacement for the non-expansive substitution principle (Gavazzo et al., 2022).
A canonical example is the graded combinatory system 5, where a constructor 6 has grade “multiply by 7” and controlled duplication is implemented by rules such as
8
The system is orthogonal, and therefore confluent. This example exhibits the point of graded quantitative rewriting in concentrated form: non-linearity is admitted, but only through grades that record exactly how duplication affects quantitative structure (Gavazzo et al., 2022).
4. Narrowing and quantitative unification
Quantitative narrowing extends graded rewriting by replacing matching with unification. A narrowing step uses a fresh variant of a rewrite rule, a renaming making the rule variables fresh with respect to the subject term, and an mgu of the redex subterm with the left-hand side. Formally, the graded narrowing relation is generated by
9
where 0 is a renaming and 1 is an mgu of 2 and 3. Iterated narrowing composes substitutions by composition and degrees by tensor: 4 On ground terms, this reduces to graded rewriting, because unification collapses to matching (Ayala-Rincón et al., 25 Jul 2025).
The semantic target is a graded equational theory 5. Its rules include reflexivity, symmetry, transitivity,
6
and the graded amplification rule
7
The graded context lemma refines this to arbitrary positions: 8 Thus the same contextual sensitivity that governs rewriting also governs equational reasoning (Ayala-Rincón et al., 25 Jul 2025).
Operationally, narrowing is organized by the 9-calculus on configurations
0
where 1 is a term, 2 a set of constraints, 3 a substitution, and 4 the accumulated degree. The main inference rules are lazy paramodulation, syntactic unification, clash, and constrain. Successful derivations have the form
5
and yield quantitative unifiers 6 of degree 7 (Ayala-Rincón et al., 25 Jul 2025).
Soundness is straightforwardly aligned with the generated equational theory: if the 8-calculus derives
9
then 0 is an 1-unifier of 2 and 3. More generally, every successful narrowing derivation yields a derivation in the graded equational theory generated by the TRS (Ayala-Rincón et al., 25 Jul 2025).
Completeness is subtler than in the classical setting. Even a weak completeness property fails in general: there are examples over 4 in which a natural unifier exists at degree 5, but narrowing systematically finds only a degree-6 solution. The obstruction comes from repeated variables, non-linearity, and the fact that grading introduces an optimization dimension absent from ordinary narrowing. Positive results are recovered under structural restrictions. If 7 is right-linear, the problem term is linear, and 8, then there exists a narrowing derivation 9 with 00 and 01. If, additionally, the quantale order is total, 02 is confluent and right-linear, and the equation 03 is linear, then the 04-calculus is weakly complete in the sense of Corollary 5.7. For basic narrowing, completeness is established for right-ground TRSs and linear problems, while the right-linear balanced case is conjectured rather than proved (Ayala-Rincón et al., 25 Jul 2025).
5. Coalgebraic semantics, behavioural metrics, and modal logic
A coalgebraic account places graded quantitative rewriting inside the broader theory of graded semantics. A graded monad on a category 05, usually 06 or a quantale-enriched metric category, is a family
07
with unit 08 and multiplications 09 satisfying graded monad laws. Given a system functor 10 and a natural transformation
11
one obtains, for each 12-coalgebra 13, the depth-14 behaviour maps
15
The associated graded behavioural distance in the metric-space setting is
16
This supplies a depth-indexed quantitative semantics for rewrite systems viewed as coalgebras of one-step rewrites (Forster et al., 2023).
Trace-style examples are especially close to rewriting. With the finite powerset monad one gets
17
whose elements are sets of traces of length 18; with the distribution monad,
19
giving distributions over length-20 traces; with the fuzzy finite powerset,
21
giving fuzzy sets of traces. These constructions induce metric trace distance, probabilistic metric trace distance, and fuzzy trace distance, respectively. The graded-monad framework is designed to cover a spectrum of behavioural metrics analogous to the linear-time/branching-time spectrum of equivalences, including branching-depth semantics 22 and trace-style semantics from distributive laws (Forster et al., 2023).
This perspective is significant for graded quantitative rewriting because it makes precise the distinction between branching-style rewrite metrics, trace-style rewrite metrics, and intermediate semantics such as readiness or failures. A plausible implication is that graded rewrite systems can be organized by the same kind of semantic spectrum: rewrite trees up to depth 23, rewrite traces of length 24, or observational structures lying between those extremes (Forster et al., 2023).
Quantitative graded logics provide the logical counterpart. If 25 is a graded logic for 26, then every uniform-depth formula has nonexpansive evaluation with respect to the behavioural distance, so logical distance is bounded by behavioural distance. Under the abstract separation criterion of Theorem 5.3, one gets full expressiveness: 27 A notable positive case is fuzzy trace distance, for which the logic 28 is expressive. A notable negative case is probabilistic metric trace distance with non-discrete labels: no quantitative coalgebraic modal logic with unary modalities whose semantics is defined compositionally on the coalgebra can characterize that distance. This limitation transfers directly to probabilistic graded quantitative rewriting with non-discrete rule metrics: unary compositional modalities may be insufficient, and higher-arity or non-compositional devices may be necessary (Forster et al., 2023).
The Eilenberg–Moore variant of graded semantics broadens this picture from metric spaces to quantale-valued truth spaces. Given a monad 29, a functor 30, and an EM distributive law 31, one obtains a depth-1 graded monad
32
Its behavioural distance is quantale-valued: 33 and graded modal logics evaluated on the original state space are invariant, and expressive when depth-0 and depth-1 separation hold. This quantale-parametrized account covers both Boolean and quantitative settings uniformly, and it suggests a semantic discipline for rewrite transformations: rules may be required to preserve or decrease behavioural distance grade by grade (Forster et al., 2023).
6. Related graded calculi, examples, and open directions
Graded quantitative rewriting is closely connected to modal and coeffectful calculi. In graded modal dependent type theory, terms and types share a syntax, typing judgments carry grade vectors for subject and type usage,
34
and the operational semantics has a small-step reduction relation 35 with type preservation and strong normalization for a fragment. Function application, tensor elimination, and box elimination all propagate grades by semiring addition and scalar multiplication. This suggests a typed instance of graded quantitative rewriting in which rewrite steps are constrained by graded usage information rather than by quantale-valued rule degrees alone (Moon et al., 2020).
Examples across the literature show the range of the framework. The system 36 provides confluent graded combinatory logic with controlled duplication. Quantitative approximate arithmetic uses rules
37
to solve approximate equations by narrowing, with the cumulative degree measuring how far a solution is from exact algebraic equality. Security and information-flow interpretations arise when the grading algebra is a lattice rather than a numerical semiring. Coalgebraic examples include nondeterministic, probabilistic, and fuzzy trace semantics; these are not rewrite systems in the narrow syntactic sense, but they instantiate the same graded quantitative discipline at the level of observable behaviour (Gavazzo et al., 2022, Ayala-Rincón et al., 25 Jul 2025, Moon et al., 2020, Forster et al., 2023).
Several open directions recur across the papers. One is completeness of basic quantitative narrowing for right-linear balanced systems, which is conjectured but not proved. Another is the design of strategies and optimal strategy problems for metric word problems in graded systems. Completion procedures for quantitative and graded TRSs, and the effect of completion on distances, are also explicitly proposed. On the semantic side, richer grades than 38, such as cost-aware or resource-aware monoids, are a natural extension of the current depth-indexed coalgebraic theory. Infinite-depth semantics, game-based characterizations of graded metrics, and logics beyond unary modalities are likewise identified as important next steps. Taken together, these directions indicate that graded quantitative rewriting is not merely a weighted variant of rewriting theory; it is a general framework for quantitative operational semantics in which syntax, context sensitivity, metrics, and logical observability are treated in a single graded architecture (Ayala-Rincón et al., 25 Jul 2025, Gavazzo et al., 2022, Forster et al., 2023).