Implementing -Reduction by. Hypergraph Rewriting. Sabine Kuske 1. Fachbereich Mathematik und Informatik. Universitat Bremen. D{28334 Bremen, Germany

Similar documents
Skew and ω-skew Confluence and Infinite Normal Forms

Parallel Independence in Hierarchical Graph Transformation

An Outline of Rule-Based Renement for Petri Nets. Julia Padberg. Technical University of Berlin. Institute for Communication- and Software-Technique

Composition and Decomposition of DPO Transformations with Borrowed Context

Universal Boolean Systems

Embedding and Confluence of Graph Transformations with Negative Application Conditions

Unique Normal Forms and Confluence of Rewrite Systems: Persistence

Compositionality in SLD-derivations and their abstractions Marco Comini, Giorgio Levi and Maria Chiara Meo Dipartimento di Informatica, Universita di

Solvability of Word Equations Modulo Finite Special And. Conuent String-Rewriting Systems Is Undecidable In General.

EXTENDED ABSTRACT. 2;4 fax: , 3;5 fax: Abstract

Double-pushout graph transformation revisited

Proceedings of the 12th International Workshop on Graph Transformation and Visual Modeling Techniques (GTVMT 2013)

Introduction to lambda calculus Part 2

Ensuring Structural Constraints in Graph-Based Models with Type Inheritance

Inequational Deduction as Term Graph Rewriting 1

Abstract. We introduce a new technique for proving termination of. term rewriting systems. The technique, a specialization of Zantema's

Attribution of Graphs by Composition of M, N -adhesive Categories

c 2002 Published by Elsevier Science B. V. Open access under CC BY-NC-ND license.

A Static Analysis Technique for Graph Transformation Systems

Sharing in the weak lambda-calculus (2)

On Term Graphs as an Adhesive Category

A shrinking lemma for random forbidding context languages

Lazy Strong Normalization

SHARING IN THE WEAK LAMBDA-CALCULUS REVISITED

Modularity of Confluence: A Simplified Proof

Characterising FS domains by means of power domains

Transformation of Corecursive Graphs

A Graph Rewriting Semantics for the Polyadic π-calculus

Lecture Notes on Combinatory Modal Logic

3.2 Reduction 29. Truth. The constructor just forms the unit element,. Since there is no destructor, there is no reduction rule.

Proving Termination of Graph Transformation Systems using Weighted Type Graphs over Semirings

Array Insertion and Deletion P Systems

Pairing Transitive Closure and Reduction to Efficiently Reason about Partially Ordered Events

2 C. A. Gunter ackground asic Domain Theory. A poset is a set D together with a binary relation v which is reexive, transitive and anti-symmetric. A s

Introduction. Foundations of Computing Science. Pallab Dasgupta Professor, Dept. of Computer Sc & Engg INDIAN INSTITUTE OF TECHNOLOGY KHARAGPUR

Towards a Notion of Transaction in Graph Rewriting 1

Rewriting for Fitch style natural deductions

Computer Science at Kent

Origin in Mathematical Logic

International Electronic Journal of Pure and Applied Mathematics IEJPAM, Volume 2, No. 1 (2010)

Composition and Decomposition of DPO Transformations with Borrowed Context

HYPEREDGE REPLACEMENT GRAPH GRAMMARS

A Graph Based Parsing Algorithm for Context-free Languages

Lambda Calculus. Andrés Sicard-Ramírez. Semester Universidad EAFIT

A Polynomial Time Algorithm for Parsing with the Bounded Order Lambek Calculus

Relations on Hypergraphs

A Common Notation System for the Lambda-Calculus and Combinatory Logic

Acceptance of!-languages by Communicating Deterministic Turing Machines

Associative-commutative rewriting via flattening

Diagrams for Meaning Preservation

An Alternative To The Iteration Operator Of. Propositional Dynamic Logic. Marcos Alexandre Castilho 1. IRIT - Universite Paul Sabatier and

AN ALTERNATIVE NATURAL DEDUCTION FOR THE INTUITIONISTIC PROPOSITIONAL LOGIC

arxiv: v3 [cs.pl] 15 May 2011

Finite Induced Graph Ramsey Theory: On Partitions of Subgraphs

Adaptive Star Grammars and Their Languages

Another algorithm for nonnegative matrices

Functional Database Query Languages as. Typed Lambda Calculi of Fixed Order. Gerd G. Hillebrand and Paris C. Kanellakis

Understanding Sequentialization

The complexity of acyclic subhypergraph problems

Massimo Marchiori. Abstract. One of the key results in the eld of modularity for Term

615, rue du Jardin Botanique. Abstract. In contrast to the case of words, in context-free tree grammars projection rules cannot always be

arxiv:math/ v1 [math.co] 11 Oct 2002

This is a repository copy of Attributed Graph Transformation via Rule Schemata : Church-Rosser Theorem.

Extremal problems in logic programming and stable model computation Pawe l Cholewinski and Miros law Truszczynski Computer Science Department Universi

Concurrency for Graph Grammars in a Petri net shell

distinct models, still insists on a function always returning a particular value, given a particular list of arguments. In the case of nondeterministi

Tree Automata and Rewriting

Binary Decision Diagrams

Wojciech Penczek. Polish Academy of Sciences, Warsaw, Poland. and. Institute of Informatics, Siedlce, Poland.

LC Graphs for the Lambek calculus with product

Hierarchical Combination of Unification Algorithms (Extended Abstract)

A Heterogeneous Pushout Approach to Term-Graph Transformation

Decreasing Diagrams: Two Labels Suffice

arxiv: v1 [math.co] 2 Dec 2013

Consistency of a Programming Logic for a Version of PCF Using Domain Theory

Posets, homomorphisms and homogeneity

L A TEX Tutorial. A. Ahmadi. 1 Bahman 1391

Abstract In usual type theory, if a function f is of type! 0 and an argument a is of type, then the type of fa is immediately given to be 0 and no men

A Geometric Proof of Confluence by Decreasing Diagrams

Power and size of extended Watson Crick L systems

Computability via the Lambda Calculus with Patterns

Simply Typed λ-calculus

Introduction to Metalogic

THE EQUATIONAL THEORIES OF REPRESENTABLE RESIDUATED SEMIGROUPS

Finite Dimensional Hilbert Spaces are Complete for Dagger Compact Closed Categories (Extended Abstract)

Note On Parikh slender context-free languages

HENNING FERNAU Fachbereich IV, Abteilung Informatik, Universität Trier, D Trier, Germany

Hybrid Transition Modes in (Tissue) P Systems

A call-by-name lambda-calculus machine

Parikh s theorem. Håkan Lindqvist

On the Standardization Theorem for λβη-calculus

Chordal Graphs, Interval Graphs, and wqo

Complete Partial Orders, PCF, and Control

A Stochastic l-calculus

Clausal Presentation of Theories in Deduction Modulo

Binary Decision Diagrams

Compact Regions for Place/Transition Nets

T -choosability in graphs

arxiv: v1 [cs.lo] 29 May 2014

COMP6463: λ-calculus

Transcription:

URL: http://www.elsevier.nl/locate/entcs/volume2.html 8 pages Implementing -Reduction by Hypergraph Rewriting abine Fachbereich Mathematik und Informatik Universitat Bremen D{28334 Bremen, Germany email: kuske@informatik.uni-bremen.de bstract The aim of this paper is to implement the -reduction in the -calculus with a hypergraph rewriting mechanism called collapsed -tree rewriting. It turns out that collapsed -tree rewriting is sound with respect to -reduction and complete with respect to the Gross-Knuth strategy. s a consequence, there exists a normal form for a collapsed -tree if and only if there exists a normal form for the represented -term. Introduction The -calculus (see [3,3,4]) can be considered as the computational basis for functional programming. Graph reduction for the -calculus was studied rst in [20] and later in e.g. [7,6,0,] improving the performance of implementations of functional languages. One main advantage of representing -terms by graphs is that common subterms can be shared such that several redexes can be reduced in parallel. Within the well developed theory of graph rewriting (see [5,8,9,7,8] for a survey), hypergraph rewriting was shown to be a suitable formalism for the implementation of term rewriting systems and logic programming (see [2,4,9,6]). The aim of this paper is to show how to implement the -reduction in the -calculus with a hypergraph rewriting mechanism called collapsed -tree rewriting. It is assumed that the reader is familiar with the basic concepts of the -calculus. Due to the space restrictions proofs are omitted here; they will appear in the long version of this paper. This work has been supported by the Deutsche Forschungsgemeinschaft and the EPRIT Basic Research Working Group 783, COMPUGRPH II. c995 Elsevier cience B. V.

2 Representing -terms by collapsed -trees Collapsed -trees are acyclic directed hypergraphs with one root where each node represents a -term. Before introducing collapsed -trees, we recall some denitions concerning hypergraphs. Let be a set of labels. Then a hypergraph over is a system H = (V; E; s; t; l) where V is a nite set of nodes, E is a nite set of hyperedges, s: E! V, t: E! V and l: E! are three mappings assigning to each hyperedge a source 2, a sequence of targets, and a label, respectively. hyperedge with label X will be called an X-hyperedge. The components of H will also be referred to as V H ; E H ; s H ; t H, and l H. For V, outdegree H (v) denotes the number of hyperedges in H with source v. Given two nodes v; v 0 2 V, a path from v to v 0 is a nite sequence (he ; i i; : : : ; he n ; i n i) with e ; : : : ; e n 2 E, i ; : : : ; i n 2 IN, s(e ) = v, t(e n )j in = v 0 3, and t(e j )j ij = s(e j+ ) for j = ; : : : ; n?. By convention, each node V is connected to itself by the empty path (). H is called acyclic if for each V there is no non-empty path from v to v. hypergraph H 0 = (V 0 ; E 0 ; s 0 ; t 0 ; l 0 ) is a subhypergraph of H, denoted by H 0 H, if V 0 V, E 0 E, and s 0, t 0 and l 0 are restrictions of the mappings s,t, and l, respectively. Given two hypergraphs H, H 0 over, a hypergraph morphism f: H! H 0 consists of two mappings f V : V H! V H 0 and f E : E H! E H 0 that preserve sources, targets and labels, that is, s H 0 f E = f V s H and t H 0 f E = fv t H (where fv is the natural extension of f V to sequences), and l H 0 f E = l H. Collapsed -trees Let C be a set of constants with ; =2 C. Then an acyclic hypergraph H = (V; E; s; t; l) over f; g[c is a collapsed -tree if there is a unique node root H 2 V with no incoming hyperedge, and if for all V and all e 2 E, () outdegree H (v), (2) jt(e)j = 2 3 if l(e) 2 f; g and jt(e)j = 0 if l(e) 2 C, (3) outdegree H (t(e)j ) = 0 if l(e) =, and (4) s(e) is on every path from root H to t(e)j if l(e) =. Let H be a collapsed -tree. Then each V H represents a -term term H (v) over the variable set V H = f V H j outdegree H (v) = 0g and the set C as follows. If outdegree(v) = 0 then term H (v) = v. Otherwise, let e be the unique hyperedge with s H (e) = v. Then term H (v) = l H (e) if l H (e) 2 C, term H (v) = (term H (t H (e)j )term H (t H (e)j 2 )) if l H (e) =, and term H (v) = (t H (e)j :term H (t H (e)j 2 )) if l H (e) =. In the following, term(h) stands for term H (root H ). The two hypergraphs shown in Figure 2 are collapsed -trees, representing the -terms (((v :(v ))a)((v :(v )a))) and ((a )(a )). It can be shown that each -term can be represented by a collapsed -tree up to -conversion. In the following we do not distinguish between -terms that are equal up to -conversion. 2 Usually, each hyperedge has an arbitrary number of sources; but this is not needed here. 3 For a sequence w, wj i denotes its i th element and jwj its length. 2

3 Collapsed -tree rewriting Collapsed -tree rewriting consists of collapsed -tree reduction on the one hand and a copying mechanism on the other hand. Both kinds of manipulating collapsed -trees are based on hypergraph rewriting and can be executed in arbitrary order. Before introducing collapsed -tree rewriting, we briey recall hypergraph rewriting. (For a precise formal denition see, e.g. [9].) (hypergraph rewriting) rule is a tuple r = (L; b: K! R) where L, K, and R are hypergraphs, b is a hypergraph morphism and K L. Let H be a hypergraph and let f: L! H be a hypergraph morphism such that the following gluing condition holds. () No hyperedge in E H? E f (L) is incident to any node in V f (L)? V f (K) and (2) for all nodes x; y 2 V L, f(x) = f(y) implies x = y or x; y 2 V K ; analogously for all hyperedges x; y 2 E L. Then the application of r to H (via f) yields a hypergraph obtained by () removing f(l)? f(k) from H and (2) gluing the remaining graph with R in b(k). Collapsed -tree reduction Let H be a collapsed -tree. Then H reduces to the hypergraph H 0, denoted by H =) red H 0, if H 0 is obtained by () applying the following rule red to H and (2) deleting all nodes and hyperedges in the resulting hypergraph that do not lie on a path from root H. The rule red = (L; b: K! R) consists of a collapsed -tree L and two hypergraphs K and R and can be depicted as in Fig. where v = v 5 (v 3 = v 4 ) means that the nodes v and v 5 (v 3 and v 4 ) of K are mapped to the same node in R. For a collapsed -tree H and a hypergraph morphism f : L! H, the subhypergraph f(l) of H is called an L-occurrence in H. Fig. 2 shows a collapsed -tree reduction. v v v = v 5 2 v 3 2 v 3 = v 4 Fig.. The rule red Collapsed -tree reduction preserves collapsed -trees. Moreover, it performs the -reduction in the -calculus. Theorem 3. (oundness of =) ) red Let H be a collapsed -tree and let H =) H 0. Then term(h) + term(h 0 ). 4 red 4 and + are the -reduction relation in the -calculus and its transitive closure. 3

2 2 a 2 =) red 2 2 2 a Fig. 2. collapsed -tree reduction plitting L-occurrences Because of the gluing condition, the rule red cannot be applied to an L- occurrence X in a collapsed -tree H if the source of the -hyperedge in X occurs more than once as target of hyperedges in H. Hence, there may occur situations in which a -reduction may be applied to term(h) but no corresponding collapsed -tree reduction can be performed. In such cases, it is desirable to provide a splitting mechanism for L-occurrences (see also [20]). To achieve this aim, one can use a set of so-called split rules consisting of the three subsets begin split, main split and end split given in the ppendix. These make use of negative context conditions in the sense of []. 5 The split of an L-occurrence is obtained by applying at most one rule of begin split, then the rules of main split as long as possible, and nally the rules of end split as long as possible. Roughly speaking, splitting an L-occurrence X in a collapsed - tree H consists of performing a recursive operation split(e) on the -hyperedge e in X that copies each path p from s H (e) to t H (e)j (provided that it is not already copied), and applies split(e 0 ) to each -hyperedge e 0 on p. The resulting derivation relation is denoted by =) split and preserves collapsed -trees as well as the represented -terms. Collapsed -tree rewriting s indicated before, collapsed -tree rewriting, denoted by =), is the union of the relations =) and =). From the soundness of =) and the fact that red split red =) preserves collapsed -trees as well as the represented -terms follows that split collapsed -tree rewriting is sound. Theorem 3.2 (oundness of =) ) Let H be a collapsed -tree and let H =) H 0. Then term(h) term(h 0 ). 6 5 If one admits larger sets of rules one can renounce the negative context conditions. 6 denotes the reexive and transitive closure of. 4

ince collapsed -tree representation of -terms may involve sharing, the application of red corresponds to a (non-empty) sequence of reduction steps in the represented -term. Hence, for a collapsed -tree H and a -term t, term(h) t does not imply that there is a collapsed -tree H 0 such that H =) H 0 and term(h 0 ) = t. But the Gross-Knuth strategy gk (see [3]) that roughly speaking reduces all redexes in a -term in parallel, can be implemented by a sequence of collapsed -tree rewriting steps. From this fact, from the soundness of =) and from the normalizing property of, it follows that gk a collapsed -tree H has a normal form if and only if term(h) has a normal form. Theorem 3.3 (completeness w.r.t. ) gk Let H be a collapsed -tree and let term(h) gk -tree H 0 such that H =) H 0 and term(h 0 ) = t. t. Then there is a collapsed Corollary 3.4 (Normal forms) Let H be a collapsed -tree. Then H has a normal form with respect to =) if and only if term(h) has a normal form with respect to. 4 Work to be done There are several points of investigation that remain open. ome of them are given here. () The presented split procedure has to be compared with the copying mechanism proposed in [20]; (2) collapsed -tree rewriting should be compared with optimal -calculus reduction considered in [7,6,0,2] and with algebraic term graph rewriting presented by Kahl ([5]); (3) it should be studied which other properties of the -calculus (like the Church-Rosser property) carry over to collapsed -tree rewriting; and (4) reduction strategies for collapsed -tree rewriting could be considered. cknowledgement. I am grateful to Renate Klempien-Hinrichs, Detlef Plump, and to the referees for their helpful comments. References [] Z.M. riola and J.W. Klop. Cyclic lambda graph rewriting. In Proc. Ninth annual IEEE ymposium on Logic in Computer cience, pages 46{426. IEEE Computer ociety Press, 994. [2]. sperti. o! = : Optimizing optimal -calculus implementations. In Jieh Hsiang, editor, Rewriting Techniques and pplications, volume 94, pages 02{ 6, 995. [3] H.P. Barendregt. The Lambda Calculus, its yntax and emantics. North- Holland, msterdam, 984. 5

[4] H.P. Barendregt. Functional programming and lambda calculus. In J. van Leeuwen, editor, Handbook of Theoretical Computer cience, volume B, pages 32{364. Elsevier - The MIT Press, 992. [5] V. Claus, H. Ehrig, and G. Rozenberg, editors. Graph Grammars and Their pplication to Computer cience and Biology. LNC 73, 979. [6] ndrea Corradini and Francesca Rossi. Hyperedge replacement jungle rewriting for term-rewriting systems and logic programming. Theoretical Computer cience, 09:7{48, 993. [7] H. Ehrig, H.-J. Kreowski, and G. Rozenberg, editors. Graph Grammars and Their pplication to Computer cience. LNC 532, 99. [8] H. Ehrig, M. Nagl, and G. Rozenberg, editors. Graph-Grammars and Their pplication to Computer cience, volume 53, 983. [9] H. Ehrig, M. Nagl, G. Rozenberg, and. Rosenfeld, editors. Graph-Grammars and Their pplication to Computer cience. LNC 29, 987. [0] G. Gonthier, M. badi, and J.J. Levy. The geometry of optimal lambda reduction. In Proc. of the 9th ymposium on Principles of Programming Languages (POPL 92), 992. []. Habel, R. Heckel, and G. Taentzer. Graph grammars with negative application conditions. Fundamenta Informaticae, 995. To appear. [2]. Habel, H.-J. Kreowski, and D. Plump. Jungle evaluation. Fundamenta Informaticae, XV:37{60, 99. [3] J. Hindley and J. P. eldin. Introduction to Combinators and -calculus, volume of London Mathematical ociety tudent Texts. Cambridge University Press, 986. [4] B. Homann and D. Plump. Implementing term rewriting by jungle evaluation. RIRO Theoretical Informatics and pplications, 25 (5):445{472, 99. [5] W. Kahl. lgebraic term graph rewriting with bound variables, 994. Talk on the fth International Workshop on Graph Grammars and Their pplication to Computer cience, November 994, Williamsburg, U. [6] J. Lamping. n algorithm for optimal lambda calculus reduction. In Proc. 7th CM ymp. of Principles of Programming Languages, pages 6{30, an Francisco, 990. [7] J.J. Levy. Optimal reductions in the lambda-calculus. In J.P. eldin and J.R. Hindley, editors, To H.B. Curry: Essays on Combinatory Logic, Lambda- Calculus and Formalism, pages 59{9. New York: cademic Press, 980. [8] Graph Grammars and Their pplication to Computer cience. Lecture Notes in Computer cience, 995. To appear. [9] D. Plump. Evaluation of Functional Expressions by Hypergraph Rewriting. PhD thesis, University of Bremen, 993. [20] C.P. Wadsworth. emantics and pragmatics of the lambda-calculus. PhD thesis, University of Oxford, 97. 6

ppendix v v X i j 2 v 3 2 v 6 v 7 v v 3 v 6 v 7 X i j 2 2 v 3 2 2 v 7 v 6 2 v v v 2 2 2 2 2 v 4 2 v 3 v 4 v 3 v 4 v 3 2 Fig. 3. The rules of begin split where i; j 2 f; 2g; i 6= j and X 2 f; g v 2 v Fig. 4. The rule of end split 7

v i j 2 v k l v l k k v3 l 2 2 v v i j v 2 v 3 2 2 2 2 2 2 v v v 2 2 X X i j l k v 6 2 v 7 v 8 v 6 v 7 v 8 X X i k v 6 j l 2 v 7 v 8 Fig. 5. The rules of main split where dashed parts represent negative context, i; j; k; l 2 f; 2g i 6= j, k 6= l and X 2 f; g. 8