Term rewriting in partial algebras Norbert Dojer 20.06.2014
Term rewriting – motivating example How to check whether two polynomial expressions are equal? ? ( x + 1) 2 − x ( x + 2)( x − 1) + 3 = = � � x 2 + 2 x + 1 − x x ( x − 1) + 2( x − 1) + 3 � � x 2 − x + 2 x − 2 + 3 x 2 + x − 1 − − − − → Generally: ◮ each class of equivalent expressions contains a unique normal form ◮ normal form is calculated by reducing expressions (rewriting) ◮ rewriting rules are derived from equational axioms
Abstract reduction system (ARS) →⊆ X 2 ARS is a pair ( X , − → ), where − ∗ ← → is an equivalence relation defined by − → , ◮ i.e. symmetric-reflexive-transitive closure of − → ∗ − → is a reflexive-transitive closure of − → ◮ ◮ x is reducible iff ∃ y x − → y ∗ ◮ y is a normal form of x ( y = x ↓ ) iff x − → y and y is irreducible ∗ ∗ ◮ x and y are joinable ( x ↓ y ) iff ∃ z x − → z ← − y
ARS – properties ARS is: ◮ terminating iff there is no infinite reduction sequence x 1 − → x 2 − → x 3 − → . . . ∗ ∗ ◮ confluent iff ∀ x , y , z x ← − z − → y = ⇒ x ↓ y ◮ locally confluent iff ∀ x , y , z x ← − z − → y = ⇒ x ↓ y Theorem Let ( X , − → ) be an ARS. Then: 1. If ( X , − → ) is terminating, each x ∈ X contains a normal form that is computable with a finite number of reductions. ∗ 2. If ( X , − → ) is confluent, each equivalence class of ← → contains at most one normal form. 3. If ( X , − → ) is terminating, it is confluent iff it is locally confluent.
Term rewriting system (TRS) TRS is a set R of rewriting rules l → r for l , r ∈ T F ( X ) TRS R defines an ARS ( T F ( X ) , − → R ), where − → R is a closure of R under substitutions and operation compatibility. TRS R is terminating, (locally) confluent iff ( T F ( X ) , − → R ) does, respectively. Theorem Let R be a (locally) confluent and terminating TRS. Then: 1. Every term t ∈ T F ( X ) has a unique normal form t ↓ R that is computable with a finite number of reductions. 2. For all t , s ∈ T F ( X ) ( t ≈ s ) ∈ Th ( Eq ( R )) ⇐ ⇒ t ↓ R = s ↓ R where Eq ( R ) = { ( l ≈ r ) | ( l → r ) ∈ R } .
TRS – criteria for termination Definition A well-founded order on the set of terms, closed under substitutions and compatible with operations is called reduction order. Theorem A TRS R is terminating iff R ⊆ > for some reduction order � .
TRS – criteria for confluence Definition Assume that two rules l → r and l ′ → r ′ have overlapping left-hand sides, i.e. terms l | ω and l ′ are unifiable for some non-variable position ω in l . The term σ ( l ), where σ is a most general unifier of l | ω and l ′ , may be reduced to: ◮ σ ( r ) with rule l → r ֓ r ′ ]) with rule l ′ → r ′ ◮ σ ( l [ ω ← ֓ r ′ ])) is called critical pair of rules The pair of terms ( σ ( r ) , σ ( l [ ω ← l → r and l ′ → r ′ . Critical Pair Lemma TRS is locally confluent iff all its critical pairs are joinable.
Equations in partial algebras Does an equation hold in an algebra when one or both sides are undefined for some valuations? existence equation: for all valuations both sides must be defined and equal Existential equational theories are ◮ partial equivalence relations on the set of terms, ◮ closed under substitutions of terms from their domains, ◮ compatible with operations (on their domains).
Existential equational theories Theorem (Burmeister ’86) A set of equations forms an existential equational theory if and only if it is closed under the following inference rules: ⊢ x ≈ x if x is a variable t ≈ t ′ ⊢ t ≈ t t ′ ≈ t t ≈ t ′ ⊢ t ≈ t ′ , t ′ ≈ t ′′ t ≈ t ′′ ⊢ f ( t 1 , . . . , t n ) ≈ f ( t 1 , . . . , t n ) ⊢ t i ≈ t i if i ∈ { 1 , . . . , n } � t i ≈ t ′ � f ( t 1 , . . . , t n ) ≈ f ( t ′ 1 , . . . , t ′ 1 � i � n , f ( t 1 , . . . , t n ) ≈ f ( t 1 , . . . , t n ) ⊢ n ) i t ≈ t ′ , σ ( t ) ≈ σ ( t ′ ) � σ ( x ) ≈ σ ( x ) � ⊢ x ∈ Var ( t , t ′ )
Partial reduction system (PRedS) PRedS is a triple ( X , − → , N ), where ( X , − → ) is an ARS and N ⊆ X . X N = � [ x ] – subset of X indicated by N ∗ ← → x ∈ N N ∗ → ∩ ( X N ) 2 – partial equivalence relation defined by ← → = ← PRedS ( X , − → , N ) PRedS ( X , − → , N ) is: ◮ terminating iff ( X , − → ) is terminating ◮ (locally) confluent iff ( X N , − → ) is (locally) confluent ∗ → x ′ then x ′ ∗ → x ′′ for some ◮ reduced iff for all x ∈ N if x − − x ′′ ∈ N
Partial reduction systems Definition N PRedS ( X , − → , N ) presents partial equivalence relation ← → iff the following conditions are satisfied: 1. Every x ∈ X has a normal form that is computable with a finite number of reductions. 2. Every x ∈ X N has a unique normal form. 3. For all x , y ∈ X N x ← → y ⇐ ⇒ x ↓ = y ↓∈ N Theorem Let ( X , − → , N ) be a terminating, (locally) confluent and reduced N PRedS. Then it presents ← → .
Partial rewriting system (PRS) PRS is a pair ( R , D ), where R is a set of rewriting rules and D is a set of terms. PRS ( R , D ) defines PRedS ( T F ( X ) , − → ( R , D ) , N D ), where: ◮ N D is a set of all terms ,,composed” of D -terms and variables ◮ − → ( R , D ) is the closure of R -rules under substitutions of N D -terms and compatibility with operations PRS ( R , D ) is terminating, (locally) confluent, reduced iff ( T F ( X ) , − → ( R , D ) , N D ) does, respectively. N D PRS ( R , D ) presents ← → ( R , D ) iff ( T F ( X ) , − → ( R , D ) , N D ) does.
PRSs and existential equational theories Definition PRS ( R , D ) is subterm-closed iff a subset of T F ( X ) indicated by N D is subterm-closed. Theorem N D A PRS ( R , D ) is subterm-closed iff ← → ( R , D ) is existential equational theory.
PRSs and existential equational theories Definition PRS ( R , D ) is existential iff a subset of T F ( X ) indicated by N D contains all terms from R -rules. Theorem A PRS ( R , D ) is subterm-closed and existential iff N D ← → ( R , D ) = Th E ( Eq ( R , D )) , where Eq ( R , D ) = { ( l ≈ r ) | ( l → r ) ∈ R } ∪ { ( d ≈ d ) | d ∈ D }
PRS – presenting equational theories Definition PRS ( R , D ) presents existential equational theory E iff the corresponding PRedS does. Corollary If PRS ( R , D ) is terminating, (locally) confluent, reduced, subterm-closed and existential, then it presents the existential equational theory Th E ( Eq ( R , D )) .
PRS – criteria for presenting equational theory Definition Assume that a term d overlaps with a left-hand side of a rule l → r , i.e. terms d | ω and l are unifiable for some non-variable position ω in d . Then the term σ ( d [ ω ← ֓ r ]), where σ is a most general unifier of d | ω and l , is called critical term of d and ( l → r ). Theorem A terminating ( R , D ) presents Th E ( Eq ( R , D )) iff the following conditions are satisfied: 1. ∀ ( p , q ) ∈ CP ( R ) p ↓ ( R , D ) = q ↓ ( R , D ) 2. ∀ ( l → r ) ∈ R r ↓ ( R , D ) ∈ N D 3. ∀ ( f ( l 1 ,..., l n ) → r ) ∈ R ∀ i ∈{ 1 ,..., n } l i ↓ ( R , D ) ∈ N D 4. ∀ f ( d 1 ,..., d n ) ∈ D ∀ i ∈{ 1 ,..., n } d i ↓ ( R , D ) ∈ N D 5. ∀ t ∈ CT ( R , D ) t ↓ ( R , D ) ∈ N D
Recommend
More recommend