6

While doing some bibliography on term-rewriting, I often found these two properties to define a term rewrite rule (see for example here and this one):

A term rewrite rule is a pair $\langle l,r\rangle$ of terms, written $l \rightarrow r$, such that

1) $l$ is not a variable

2) all variables in $r$ occur also in $l$.

I fail to understand the reason of these properties, at least for the definition of a rule (I can see why they would matter for termination or confluence proofs). Why a term rewriting system could not contain a rule such as $x \rightarrow x + 1 - 1$ or $x \rightarrow x + y - y$ ? Just to provide some context, I'm trying to use TRS in the context of obfuscation, where such rewritings have meaning.

Can someone explain why rules composing a TRS would need these properties?

noutoff
  • 63
  • 5

1 Answers1

3

In general, there is no obstacle to define a rewrite system as above, and a few sources do indeed require rules 1. and 2. only as additional hypotheses.

However the hypotheses are almost always necessary (but not sufficient!) for both termination and confluence, which is indeed the main object of study of rewriting as a field.

Perhaps it's useful to remind why this is the case:

Termination:

  1. If $x\rightarrow t$ is allowed as a rule, then any term $u$ rewrites to $t[u/x]$. In particular, the system is non-terminating.
  2. If $l\rightarrow r$ and $r$ contains a fresh variable $y$ not in $l$, then for example, $l\rightarrow r[l/y]$, and so the system is non-terminating.

Confluence:

  1. Take $x \rightarrow f(x)$ and $g(a)\rightarrow b$. Then $$ g(f(a))\leftarrow g(a)\rightarrow b$$ for instance, breaking confluence. In particular, you can "insert" an $f$ around any term you like, which makes confluence very hard to satisfy.

  2. If there are constants $a$ and $b$, then given the rule $f(x)\rightarrow g(y)$, you get $$ g(a)\leftarrow f(x)\rightarrow g(b)$$ again, breaking confluence.


Now every theorem involving either termination or confluence could be prefaced with "assuming 1. and 2. holds, ..." but it makes sense to restrict your attention to systems where the theorems aren't trivially false. I don't think anyone would be shocked by a paper which lifts these restrictions though, at least condition 2. (condition 1. really creates anarchy). Condition 2. is mostly about non-determinism, for which rewriting is a nice framework in general.

There are some systems in which free variables can appear in the RHS, but usually not any fresh variable $y$ is allowed: there are additional constraints which need to be satisfied, e.g.

$$f(x) \rightarrow f(y)\ \mid\ 0\leq y < x $$

where $x$ and $y$ are allowed to be integers. These types of systems are called constraint rewriting systems and are extensively studied.

cody
  • 8,427
  • 33
  • 64