Introduction to Term Rewriting - PowerPoint PPT Presentation

1 / 26
About This Presentation
Title:

Introduction to Term Rewriting

Description:

Newman's Lemma: CR&SN WCR&SN. Critical Pair lemma: R is WCR iff for all ... Bendix turned the critical pair lemma around, to construct a decision procedure ... – PowerPoint PPT presentation

Number of Views:124
Avg rating:3.0/5.0
Slides: 27
Provided by: SMK86
Category:

less

Transcript and Presenter's Notes

Title: Introduction to Term Rewriting


1
Introduction to Term Rewriting
  • Stefan Kahrs

2
Ancestry
3
Definition
  • A Term Rewriting System is a pair (?,R)
  • signature ?(S,), S set of symbols,
  • S?N (ranked alphabet)
  • set T? of first-order terms (with variables)
  • rules R? T? T?, t?s ? R such that
  • t?Var
  • vars(t)?vars(s)

4
Example
  • ?(add,succ,0,)
  • (add)2, (succ)1, (0)0
  • R add(succ(x),y)?succ(add(x,y)),
  • add(0,x)?x

5
Semantics
  • of a TRS is the abstract reduction system (T?,?R)
    (ARS same as transition system)
  • where ?R is the smallest rewrite relation
    containing R (the rewrite closure of R)
  • a relation S on terms is a rewrite relation iff
  • t S u implies ts S us for any substitution s
  • t S u implies Ct S Cu for any context C_

6
Basics
  • substitution f(t1,...,tn)s f(t1s,...,tns)
  • homomorphism on the term algebra
  • context C_ is a term with a hole ?
  • CtC_s where ?st, xsx

7
Notations useful of ARS
  • R binary relation on some set...
  • R equivalence closure of R
  • R-1, inverse of R
  • ?R, complement of R
  • R reflexive transitive closure
  • ?RR(R-1) joinability
  • ?R(R-1)R common source

8
Properties of ARS
  • Church-Rosser R ? ?R
  • equivalent terms have a common reduct
  • Confluence ?R ? ?R
  • diverting computations can be re-joined
  • Strong Normalisation of R ?S.S? RS ? S?
  • all R-chains must end
  • Weak Normalisation of R (RR ?) ?
  • all terms have normal forms

9
Properties of ARS, continued...
  • Weak Confluence, WCR R-1R ? ?R
  • one-step diverting computations can be re-joined
  • Uniqueness of Normal Forms (UN)
  • normal forms in the R relation are identical
  • ... w.r.t. reduction (UN?)
  • normal forms in the ?R relation are identical

10
TRSs and the word problem of Universal Algebra
  • CR SN if we have both then the TRS gives us a
    decision procedure for the equational theory
    (assuming finiteness)
  • Newmans Lemma CRSN ?WCRSN
  • Critical Pair lemma ?R is WCR iff for all
    critical pairs (x,y) of R x ?Ry

11
Critical Pair
  • suppose a?b, c?d are rules of the TRS
  • if there exist C_, t with Ctc, t?Var
  • and if there exist s,q such that tsaq then the
    terms ds, Csbq form a critical pair
  • explanation
  • ds?csCtsCstsCsaq ?Csbq
  • s,q mgu, C? ? if rules the same

12
Whats the big deal?
  • Knuth Bendix turned the critical pair lemma
    around, to construct a decision procedure for an
    equational theory
  • central ideas
  • turn equations into rewrite rules
  • maintain termination
  • maintain WCR by turning critical pairs into
    equations

13
KB algorithm, sketch
  • E equations ? R rules
  • remove ab from E and compute their normal forms
    a, b w.r.t. R (stop on ?)
  • if ab continue at 1, otherwise...
  • add a?b or b?a to R
  • add all critical pairs of the new rule with R
    (including itself) to E back to 1

14
Catches
  • quite a few things can go wrong
  • orienting into a rule (step 3) may not be
    possible without losing termination
  • termination check of R is tricky
  • the algorithm itself (in the described form) is
    quite likely to fail to terminate we need a few
    tweaks to give it a fighting chance

15
Example
  • The Theory of Free Groups
  • (xy)z x(yz)
  • -xx 0
  • 0x x
  • Orient into rules (from left to right). All three
    rules have a critical pair with the first rule,
    but only one is not joinable (-xx)zz

16
Eventually
  • 0x?x
  • -xx ?0
  • (xy)z ?x(yz)
  • -x(xz) ?z
  • x0 ?x

--x ? x -0 ? 0 x -x ? 0 x(-xy) ? y -(xy) ?
-y -x
17
Aside
  • I implemented a bit of KB in Sicstus prolog, put
    in the group example, and then proved
    inconsistency, i.e. that every group is trivial.
  • Problem the left-hand sides of the rules
  • -xx?0,
  • -x(xz)?z
  • are unifiable when we consider them to be regular
    trees, assigning x to xzw, with the critical
    pair (z,0).

18
Inductionless Induction
  • show that equation X is an inductive consequence
    of E
  • Run KB on E giving R
  • Run KB on EX (same ordering) giving R
  • Check that all left-hand sides of R are
    ground-reducible by R.

19
Example
  • App(Nil,x) x
  • App(Cons(x,y),z) Cons(x,App(y,z))
  • Rev(Nil) Nil
  • Rev(Cons(x,y)) App(Rev(y),Cons(x,Nil))
  • trying to prove Rev(Rev(x))x

20
Result
  • KB of the first 4 equations orients them from
    left to right.
  • Similar for KB of all 5, but we get in addition
  • Rev(App(x,Cons(y,Nil)))?Cons(y,Rev(x))
  • Rev(App(Rev(x),Cons(y,Nil)))?Cons(y,x)
  • The lhs of all additional three rules are
    ground-reducible by the first 4 rules, hence we
    found an inductive theorem.

21
Termination
  • Generally hard, traditional techniques are based
    on simplification ordering
  • A simplification ordering is a rewrite relation ?
    such that Ctgtt (where gt is ?-?)
  • By a theorem of Kruskal it is known that
    simplification orderings over finite signatures
    are well-founded.

22
Orthogonal TRS
  • no critical pairs (hence WCR)
  • left-linear
  • A ?C(A) C(x)?D(x,C(x)) D(x,x)?E not CR
  • weaker notions weakly/almost orthogonal
  • normalising strategy
  • OTRS parallel outermost,
  • left-normal OTRS leftmost outermost

23
Modularity (since late 1980s)
  • disjoint union A?B of two TRSs join the
    signatures and rules, provided the symbol sets
    are disjoint (if not rename)
  • a property j of TRSs is modular iff
  • j holds for A and j holds for B iff
  • j holds for A?B

24
Properties
  • CR is modular (Toyamas theorem, 1987 the second
    most exciting TRS paper)
  • SN is not
  • CR SN is not
  • CR SN LL is
  • simplifying is

Collapsed Tree Rewriting the first three
modularity results are exactly the opposite!
25
Extensions, modifications
  • CTRS, various flavours
  • Term graph rewriting
  • rewriting modulo E
  • transfinite rewriting, infinite terms
  • higher-order rewriting (rewrite modulo a
    substitution calculus)

26
More Information
  • handbooks
  • of TCS (Dershowitz, Jouannaud), Vol B
  • of Logic in Computer Science (Klop), Vol II
  • textbooks
  • Baader Nipkow, Ohlebusch, Bachmair
  • if you read German Bündgen, Drosten, Avenhaus
  • conference RTA
Write a Comment
User Comments (0)
About PowerShow.com