Delia KESNER IRIF, CNRS et Universit ´e Paris [email protected] www.irif.fr/˜kesner
Abstract Rewriting
Delia KESNER IRIF, CNRS et Universit ´e Paris [email protected] www.irif.fr/˜kesner
Formal definition of rewriting
Given a set ofobjectsA, an (abstract) rewriting system is arelationR ⊆A×A.
Example
LetAbe the set of finite sequences over{◦,•,•}. LetRbe the rewriting system given by the three rules{◦•7→•◦,•• 7→••,•◦ 7→ ◦•}. We consider the rewriting predicate t→u(which reads“trewrites tou”), obtained by applying one of the rules ofRto some subsequence oft. Thus for example,
◦•• ◦ •• ◦ ••
↓
• ◦ • ◦ •• ◦ ••
↓
• ◦ •• ◦ • ◦ ••
↓
• ◦ •• ◦ • ◦ ••
↓∗
• • • ◦ ◦ ◦ • • •
Delia KESNER IRIF, CNRS et Universit ´e Paris [email protected] www.irif.fr/˜kesner
Closure notions
s→+Rtis the transitive closure of→R:
s→+Rtiffs=s0→R s1→R . . .→R sn=tforn≥1.
→=Ris the reflexive closure: s→=Rtiffs=tors→R t.
→∗Ris the reflexive transitive closure of→R:
s→∗Rtiffs=s0→R s1→R . . .→R sn=tforn≥0.
→nRmeansn-reductions steps:
s→nRtiffs=s0→R s1→R . . .→R sn=tforn≥0.
The objects=s0→R s1→R . . .→R sn=t(forn≥0) is called anR-rewrite sequence.
↔Ris the symmetrique closure:
s↔Rtiffs→R tort→R s.
↔∗Ris the reflexive, symetrique and transitive closure:
s↔∗Rtiffs=s0↔Rs1↔R. . .↔R sn=tforn≥0.
Delia KESNER IRIF, CNRS et Universit ´e Paris [email protected] www.irif.fr/˜kesner
More basic vocabulary
A termtisR-reducibleiff there existsss.t.t→R s. A termtisinR-normal formifftis noR-reducible.
A termsisaR-normal form oftifft→∗R sandsis inR-normal form.
The symbol7→is used to denote rewriting rules, while→denotes the rewriting predicate.
Delia KESNER IRIF, CNRS et Universit ´e Paris [email protected] www.irif.fr/˜kesner
Different meaning for equivalent terms
Given
R=
f(x,x) 7→ c
a 7→ b
f(x,b) 7→ d
we can compute from the same termf(a,a)two different normal-formscandd.
Delia KESNER IRIF, CNRS et Universit ´e Paris [email protected] www.irif.fr/˜kesner
Same meaning for equivalent terms
RisChurch-Rosser (CR)iff for allu,vsuch thatu↔∗Rv, there existsssuch that u→∗Rsandv→∗R s. Graphically,
u ↔
∗Rv
&
∗R ∗R.
s
Delia KESNER IRIF, CNRS et Universit ´e Paris [email protected] www.irif.fr/˜kesner
Confluence diagrams
A diagram like:
t R1 u
R2 R3
v R4 s
reads:
for allt,u,vsuch thattR1uandtR2v, there existssuch thatuR3sandvR4 s.
Delia KESNER IRIF, CNRS et Universit ´e Paris [email protected] www.irif.fr/˜kesner
Confluence notions
Risconfluent (C)iff
t →∗R u
↓∗R ↓∗R
v →∗R s
Rislocally confluent (LC)iff
t →R u
↓R ↓∗R
v →∗R s
Risstrongly confluent (SC)iff
t →R u
↓R ↓∗R
v →=R s
Rhas thediamond property (DP)iff
t →R u
↓R ↓R
v →R s
This is a particular case of strongly confluence.
Delia KESNER IRIF, CNRS et Universit ´e Paris [email protected] www.irif.fr/˜kesner
Equivalent notions
Theorem
RisChurch-RosseriffRisconfluent.
Proof.
On blackboard.
Delia KESNER IRIF, CNRS et Universit ´e Paris [email protected] www.irif.fr/˜kesner
Sufficient conditions
Theorem
Rhas thediamond propertyimpliesRisconfluent.
Proof.
On blackboard.
Delia KESNER IRIF, CNRS et Universit ´e Paris [email protected] www.irif.fr/˜kesner
Non-equivalent notions
The following system [Curry]:
R=
c 7→ a
c 7→ d
d 7→ c
d 7→ b
islocally confluentbut notconfluent:
a←c→∗b
Delia KESNER IRIF, CNRS et Universit ´e Paris [email protected] www.irif.fr/˜kesner
Termination notions
TheelementsisR-weakly normalising (WN)iffshas at least one normal form.
TheelementsisR- strongly normalising (SN)iff there is no infinite sequence
s=s0→R s1→R . . .iff everyR-reduction sequence starting atsis finite. We note
s∈S NS.
ThesystemRis weakly normalising (WN)iff every element is WN.
ThesystemRterminatesor isstrongly normalising (SN)ornoetherienor well-founded (WF)iff every elementsis SN.
Delia KESNER IRIF, CNRS et Universit ´e Paris [email protected] www.irif.fr/˜kesner
Weak vs strong normalisation
R=
( f(a) 7→ c f(x) 7→ f(a) The system is weakly normalising but not strongly normalising:
f(b)→ f(a)→c
f(b)→ f(a)→ f(a). . .
Delia KESNER IRIF, CNRS et Universit ´e Paris [email protected] www.irif.fr/˜kesner
Convergent Systems
Definition
ThesystemRisconvergentiff it is confluent and strongly normalising.
Remark
IfRis confluent, then every element hasat most a normal form.
IfRis convergent, then every element hasone and only one normal form. In this case, we use thefunctionalnotationR(t)to denote theR-normal form oft.
Delia KESNER IRIF, CNRS et Universit ´e Paris [email protected] www.irif.fr/˜kesner
Confluence from local confluence
Lemma
(Newmann)LetRbe aSNsystem. ThenRis locally confluent iffRis confluent.
Proof.
(By Huet) By well-founded induction ons∈S N.
s → t1 →∗ tn
↓ LC ↓∗ ↓∗
u1 →∗ v t1<s ↓∗
↓∗ u1<s ↓∗ ↓∗
um →∗ w →∗ p
Delia KESNER IRIF, CNRS et Universit ´e Paris [email protected] www.irif.fr/˜kesner
Important remark
The following (infinite) system on natural numbers:
R=
2.n 7→ 2.n+1
2.n 7→ a
2.m+1 7→ 2.m+2 2.m+1 7→ b islocally confluentbut notconfluent:a←0→∗b In fact it is not SN
0→ 1→ 2→ 3→ . . .