Soundness and Completeness of Infinitary Term Graph Rewriting Patrick Bahr paba@diku.dk University of Copenhagen Department of Computer Science 17th Informal Workshop on Term Rewriting, Aachen, March 28, 2012
From Terms to Term Graphs f f g g h h g c c b f g c h g c f ( g ( a ) , h ( g ( a ) , a )) c a → b b → c 2
Infinitary Term Graph Rewriting – What is it for? A common formalism study correspondences between infinitary term rewriting and finitary term graph rewriting Lazy evaluation infinitary term rewriting only covers non-strictness however: lazy evaluation = non-strictness + sharing towards infinitary lambda calculi with letrec Ariola & Blom. Skew confluence and the lambda calculus with letrec. the calculus is non-confluent but there is a notion of infinite normal forms 3
Obstacles What is the an appropriate notion of convergence on term graph? generalise convergence on terms ◮ But: there are many quite different generalisations. ◮ Most important issue: how to deal with sharing? simulate infinitary term rewriting in a sound & complete manner Completeness w.r.t. term graph rewriting An issue even for finitary acyclic term graph reduction! ∗ ∗ s t ′ t U ( · ) U ( · ) ∗ g h 4
Outline Introduction 1 Goals Obstacles Modes of Convergence on Term Graphs 2 Metric Approach Partial Order Approach Metric vs. Partial Order Approach 5
Metric Infinitary Term Rewriting Complete metric on terms terms are endowed with a complete metric in order to formalise the convergence of infinite reductions. metric distance between terms: d ( s , t ) = 2 − sim ( s , t ) sim ( s , t ) = minimum depth d s.t. s and t differ at depth d Strong convergence via metric d and redex depth convergence in the metric space ( T ∞ (Σ) , d ) depth of the differences between the terms has to tend to infinity � depth of redexes has to tend to infinity 6
Example: Strongly Converging f f f f f f g g g g g a g g g g a g g g a g g a g a a → g ( a ) 7
A Metric on Term Graphs Depth of a node = length of a shortest path from the root to the node. Truncation of term graphs The truncation g † d is obtained from g by relabelling all nodes at depth d with ⊥ , and removing all nodes that thus become unreachable from the root. The simple metric on term graphs d † ( g , h ) = 2 − sim † ( g , h ) Where sim † ( g , h ) = maximum depth d s.t. g † d ∼ = h † d . Strong convergence via metric d † and redex depth convergence in the metric space ( G ∞ C (Σ) , d † ) depth of redexes has to tend to infinity 8
Soundness & Completeness Theorem (soundness of metric convergence) For every left-linear, left-finite GRS R we have m R h m U ( R ) U ( h ) . g ։ = ⇒ U ( g ) ։ Completeness property U ( R ) s t ′ t U ( · ) U ( · ) g R h 9
Completeness of Infinitary Term Graph Rewriting? We have a rule n ( x , y ) → n + 1 ( x , y ) for each n ∈ N . 0 0 0 1 1 1 ? 0 1 1 2 2 2 2 2 0 1 ? 2 [Kennaway et al., 1994] 10
Outline Introduction 1 Goals Obstacles Modes of Convergence on Term Graphs 2 Metric Approach Partial Order Approach Metric vs. Partial Order Approach 11
Partial Order Infinitary Term Rewriting Partial order on terms partial terms: terms with additional constant ⊥ (read as “undefined”) partial order ≤ ⊥ reads as: “is less defined than” ≤ ⊥ is a complete semilattice (= cpo + glbs of non-empty sets) Convergence formalised by the limit inferior: � � lim inf ι → α t ι = t ι β<α β ≤ ι<α intuition: eventual persistence of nodes of the terms weak convergence: limit inferior of the terms of the reduction strong convergence: limit inferior of the contexts of the reduction 12
Partial Order Convergence vs. Metric Convergence Intuition of partial order convergence subterms that would break m -convergence, converge to ⊥ every (continuous) reduction converges Theorem (total p -convergence = m -convergence) For every reduction S in a TRS the following equivalence holds: p t total m t S : s ։ iff S : s ։ Theorem (normalisation & confluence) Every orthogonal TRS is infinitarily normalising and infinitarily confluent w.r.t. strong p-convergence. 13
A Partial Order on Term Graphs – How? Specialise on terms Consider terms as term trees (i.e. term graphs with tree structure) How to define the partial order ≤ ⊥ on term trees? ⊥ -homomorphisms φ : g → ⊥ h homomorphism condition suspended on ⊥ -nodes allow mapping of ⊥ -nodes to arbitrary nodes same mechanism that formalises matching in term graph rewriting Proposition ( ⊥ -homomorphisms characterise ≤ ⊥ on terms) For all s , t ∈ T ∞ (Σ ⊥ ) : ∃ φ : s → ⊥ t s ≤ ⊥ t iff Definition (Simple partial order ≤ S ⊥ on term graphs) For all g , h ∈ G ∞ (Σ ⊥ ) , let g ≤ S ⊥ h iff there is some φ : g → ⊥ h . 14
Partial Order Convergence on Term Graphs Convergence Weak conv.: limit inferior of the term graphs along the reduction. Strong conv.: limit inferior of the contexts along the reduction. Context Term graph obtained by relabelling the root node of the redex with ⊥ (and removing all nodes that become unreachable). Example f f context f f f f ⊥ c c c c 15
Metric vs. Partial Order Approach Recall the situation on terms For every reduction S in a TRS p t total m t . S : s ։ ⇐ ⇒ S : s ։ On term graphs For every reduction S in a GRS p t total m t . S : s ։ ⇐ ⇒ S : s ։ Theorem (soundness of partial order convergence) For every left-linear, left-finite GRS R we have p R h p U ( R ) U ( h ) . g ։ = ⇒ U ( g ) ։ 16
Failure of Completeness for Metric Convergence We have a rule n ( x , y ) → n + 1 ( x , y ) for each n ∈ N . 0 0 0 1 1 1 ? 0 1 1 2 2 2 2 2 0 1 ? 2 17
Completeness for Partial Order Convergence Theorem (Infinitary normalisation) p h to a normal form h. For each term graph g, there is a reduction g ։ Theorem (Completeness) Strong p-convergence in an orthogonal, left-finite GRS R is complete w.r.t. strong p-convergence in U ( R ) . Proof. soundness confluence U ( R ) s t ′ t U ( · ) U ( · ) normalising g R h 18
Conclusions Infinitary term graph rewriting intuitive & simple generalisation however: weak convergence is wacky strong convergence is well-behaved Is it relevant? connection to lazy functional programming soundness & completeness Completeness of m -convergence for normalising reductions normalising U ( R ) s t U ( · ) U ( · ) g R h 19
Recommend
More recommend