Copyright 1973, by the author(s). All rights reserved.

Similar documents
NOTES ON FIBONACCI TREES AND THEIR OPTIMALITY* YASUICHI HORIBE INTRODUCTION 1. FIBONACCI TREES

Introduction to Greedy Algorithms: Huffman Codes

Notes on Natural Logic

A relation on 132-avoiding permutation patterns

On the Optimality of a Family of Binary Trees

Single Machine Inserted Idle Time Scheduling with Release Times and Due Dates

On Packing Densities of Set Partitions

TABLEAU-BASED DECISION PROCEDURES FOR HYBRID LOGIC

Abstract stack machines for LL and LR parsing

Lecture l(x) 1. (1) x X

Lecture 5: Tuesday, January 27, Peterson s Algorithm satisfies the No Starvation property (Theorem 1)

CS 4110 Programming Languages and Logics Lecture #2: Introduction to Semantics. 1 Arithmetic Expressions

CS 4110 Programming Languages & Logics. Lecture 2 Introduction to Semantics

Semantics with Applications 2b. Structural Operational Semantics

2 all subsequent nodes. 252 all subsequent nodes. 401 all subsequent nodes. 398 all subsequent nodes. 330 all subsequent nodes

Homework #4. CMSC351 - Spring 2013 PRINT Name : Due: Thu Apr 16 th at the start of class

Supporting Information

TR : Knowledge-Based Rational Decisions and Nash Paths

On the Optimality of a Family of Binary Trees Techical Report TR

Structural Induction

6 -AL- ONE MACHINE SEQUENCING TO MINIMIZE MEAN FLOW TIME WITH MINIMUM NUMBER TARDY. Hamilton Emmons \,«* Technical Memorandum No. 2.

Harvard School of Engineering and Applied Sciences CS 152: Programming Languages

CSE 21 Winter 2016 Homework 6 Due: Wednesday, May 11, 2016 at 11:59pm. Instructions

Recitation 1. Solving Recurrences. 1.1 Announcements. Welcome to 15210!

DESCENDANTS IN HEAP ORDERED TREES OR A TRIUMPH OF COMPUTER ALGEBRA

On Packing Densities of Set Partitions

Generating all nite modular lattices of a given size

An effective perfect-set theorem

Essays on Some Combinatorial Optimization Problems with Interval Data

UNIT VI TREES. Marks - 14

CSE 417 Algorithms. Huffman Codes: An Optimal Data Compression Method

Course Information and Introduction

Strong normalisation and the typed lambda calculus

PRIORITY QUEUES. binary heaps d-ary heaps binomial heaps Fibonacci heaps. Lecture slides by Kevin Wayne Copyright 2005 Pearson-Addison Wesley

Sy D. Friedman. August 28, 2001

Harvard School of Engineering and Applied Sciences CS 152: Programming Languages

Finding Equilibria in Games of No Chance

Sublinear Time Algorithms Oct 19, Lecture 1

Algorithms PRIORITY QUEUES. binary heaps d-ary heaps binomial heaps Fibonacci heaps. binary heaps d-ary heaps binomial heaps Fibonacci heaps

arxiv: v2 [math.lo] 13 Feb 2014

VARN CODES AND GENERALIZED FIBONACCI TREES

Algorithmic Game Theory and Applications. Lecture 11: Games of Perfect Information

Forecast Horizons for Production Planning with Stochastic Demand

A DNC function that computes no effectively bi-immune set

Sequential allocation of indivisible goods

Properties of IRR Equation with Regard to Ambiguity of Calculating of Rate of Return and a Maximum Number of Solutions

Brief Notes on the Category Theoretic Semantics of Simply Typed Lambda Calculus

Analysis of Link Reversal Routing Algorithms for Mobile Ad Hoc Networks

2 Deduction in Sentential Logic

Harvard School of Engineering and Applied Sciences CS 152: Programming Languages

Best response cycles in perfect information games

SAT and DPLL. Introduction. Preliminaries. Normal forms DPLL. Complexity. Espen H. Lian. DPLL Implementation. Bibliography.

THE TRAVELING SALESMAN PROBLEM FOR MOVING POINTS ON A LINE

sample-bookchapter 2015/7/7 9:44 page 1 #1 THE BINOMIAL MODEL

R-automata. 1 Introduction. Parosh Aziz Abdulla, Pavel Krcal, and Wang Yi

Arborescent Architecture for Decentralized Supervisory Control of Discrete Event Systems

The Real Numbers. Here we show one way to explicitly construct the real numbers R. First we need a definition.

Heaps. Heap/Priority queue. Binomial heaps: Advanced Algorithmics (4AP) Heaps Binary heap. Binomial heap. Jaak Vilo 2009 Spring

1 Solutions to Tute09

The Traveling Salesman Problem. Time Complexity under Nondeterminism. A Nondeterministic Algorithm for tsp (d)

Heaps

SAT and DPLL. Espen H. Lian. May 4, Ifi, UiO. Espen H. Lian (Ifi, UiO) SAT and DPLL May 4, / 59

Alain Hertz 1 and Sacha Varone 2. Introduction A NOTE ON TREE REALIZATIONS OF MATRICES. RAIRO Operations Research Will be set by the publisher

On Finite Strategy Sets for Finitely Repeated Zero-Sum Games

FOR NONPARAMETRIC MULTICLASS CLASSIFICATION. S. Gelf'and. S.K. Mitter. Department of Electrical Engineering and Computer Science.

Lecture Notes on Type Checking

Inversion Formulae on Permutations Avoiding 321

On the Efficiency of Sequential Auctions for Spectrum Sharing

Design and Analysis of Algorithms 演算法設計與分析. Lecture 9 November 19, 2014 洪國寶

CSE 100: TREAPS AND RANDOMIZED SEARCH TREES

Yao s Minimax Principle

Computational Independence

Lecture 2: The Simple Story of 2-SAT

Proof Techniques for Operational Semantics

SET 1C Binary Trees. 2. (i) Define the height of a binary tree or subtree and also define a height balanced (AVL) tree. (2)

Chapter 5: Algorithms

Advanced Algorithmics (4AP) Heaps

,,, be any other strategy for selling items. It yields no more revenue than, based on the

Decision Trees with Minimum Average Depth for Sorting Eight Elements

Online Algorithms SS 2013

CSCE 750, Fall 2009 Quizzes with Answers

Math-Stat-491-Fall2014-Notes-V

Design and Analysis of Algorithms. Lecture 9 November 20, 2013 洪國寶

Quadrant marked mesh patterns in 123-avoiding permutations

COMPUTER SCIENCE 20, SPRING 2014 Homework Problems Recursive Definitions, Structural Induction, States and Invariants

Sequential Decision Making

1 The Exchange Economy...

6.854J / J Advanced Algorithms Fall 2008

Optimal Integer Delay Budget Assignment on Directed Acyclic Graphs

The Probabilistic Method - Probabilistic Techniques. Lecture 7: Martingales

IEOR E4004: Introduction to OR: Deterministic Models

Pension fund investment: Impact of the liability structure on equity allocation

2. This algorithm does not solve the problem of finding a maximum cardinality set of non-overlapping intervals. Consider the following intervals:

CONSTRUCTION OF CODES BY LATTICE VALUED FUZZY SETS. 1. Introduction. Novi Sad J. Math. Vol. 35, No. 2, 2005,

UPWARD STABILITY TRANSFER FOR TAME ABSTRACT ELEMENTARY CLASSES

THE LYING ORACLE GAME WITH A BIASED COIN

A Property Equivalent to n-permutability for Infinite Groups

TR : Knowledge-Based Rational Decisions

Periodic Resource Model for Compositional Real- Time Guarantees

Dynamic Programming: An overview. 1 Preliminaries: The basic principle underlying dynamic programming

Transcription:

Copyright 1973, by the author(s). All rights reserved. Permission to make digital or hard copies of all or part of this work for personal or classroom use is granted without fee provided that copies are not made or distributed for profit or commercial advantage and that copies bear this notice and the full citation on the first page. To copy otherwise, to republish, to post on servers or to redistribute to lists, requires prior specific permission.

ON THE SIZE OF DERIVATION TREE by Y. Eric Cho Memorandum No. ERL-M380 2 April 1973 ELECTRONICS RESEARCH LABORATORY College of Engineering University of California, Berkeley 94720

ON THE SIZE OF DERIVATION TREE by Y. Eric Cho Department of Electrical Engineering and Computer Sciences and the Electronics Research Laboratory University of California, Berkeley, California 94720 ABSTRACT The number of nodes in the derivation tree for a string w is shown to be linearly bounded by the length of w. This bound is also very convenient for proving the time bounds for deterministic parsing algorithms. Research sponsored by the National Science Foundation Grant GK-10656x2

"Derivation tree" is a useful concept in formal language theory and the design of compilers [1],[2]. The problem that we are interested in is as follows. For a string w of length n, in the language of a contextfree grammar G, what is the bound on the number of nodes in wfs derivation tree with respect to G? If G is ambiguous, what is the bound for the smallest derivation tree for w? We prove that the bound is linear in n. As we shall see later, this bound is also very useful in proving the time and space bounds of deterministic parsers. An equivalent problem is the bound on the number of steps required to derive w. For the case that G is non-leftrecursive, it is proved in [3] that the bound is linear. The basic definitions used in [1] are also used here. In addition, we employ the following: ftg(a) is the length of the string a. The terminal nodes of a tree are those nodes that do not have descendants (The concept of immediate descendant, and descendant have been defined in [1]). The other nodes are internal nodes. A sequence of nodes {n-,..., n.} K>2 is a chain if n. is the only direct descendant of node n., for 2<i<K. A chain is a maximum chain if n^ is not the only direct descendant of another node and n, does not have exactly one direct descendant. A tree is chain-free if it does not contain any chains. For a tree T if all of its chains are shorter than K, then the K-contracted tree of T is obtained from T by replacing all the maximum chains of T by single nodes. More precisely, if {n_,..., n,} is a maximum chain, then the contraction of this chain is <Jone by deleting nodes {n2,..., nk> and connecting n- to all of n,'s descendants. -1-

Example: 4 - contraction For practical reasons, the bound will be derived for unambiguous grammars, since all the practical grammars are unambiguous. Later on, we will show that this bound is still true for the smallest derivation tree of w, if G is ambiguous. Lemma 1. For a string w e L(G), if G is unambiguous, then w's derivation tree has no chain longer than I where equals to the number of variables plus one. Proof. If there is a chain longer than, then part of this chain would look like..-a-b-d-... -A-.. There are infinitely many ways to derive A, then G is ambiguous which is a contradiction. Therefore, all the chains must be shorter than &. Lemma 2. For a tree T, if all the chains are shorter than &, then the number of nodes in T is not more than I times the number of nodes in T's ^-contracted tree T. Proof. This can be proved by expanding T1, replacing every node of T* by a chain of length l; then we get a new tree T". It is obvious that T" has at least as many nodes as T, and the number of nodes in T" is less than the number of nodes in TMultiplied by it. -2-

Lemma 3. If a tree is chain-free, then it has more terminal nodes than internal nodes. Proof. We are going to prove this by induction on the number of nodes in the tree -i. (i) i=l. The tree consists of only one single node only. By our definition, it is a terminal node so this is true for i=l. (ii) Suppose this lemma is true for trees with less than i nodes, we want to show that it is also true for trees with i nodes. It is worth mentioning that there is no chain-free tree or subtree with 2 nodes. For a tree with i nodes (i>2) we can partition the tree from the root as follows: The tree T is formed by adding the "ROOT" to the subtrees T-,T2,...,T (n>2). By induction, each subtree has at least one more terminal node than internal nodes, so after putting them together and n>2, we still have more terminal nodes than internal nodes. An interesting feature of context-free grammars is X-rules. As a convention, we will count each X in the derivation tree as one node. -3-

Although Theorem 1 is proved for the case that G is unambiguous, actually, the only requirement is that the chains be shorter than. Therefore, if the grammar is ambiguous, in the derivation trees for w there will be one which does not have chains longer than I, So we have: Corollary 2. If w l(g), then w has a derivation tree with less than K* g(w) nodes. In [2] it is proved that if G is nonleftrecursive, then for all w L(G), the number of steps in deriving w is less than K* g(w). Since the length of the derivation is not more than the number of nodes in the corresponding derivation tree, and by Corollary 2, we have the following more general result. Corollary 3. For a string w in L(G) % there exists a derivation whose length is less than K» g(w). ACKNOWLEDGEMENT The author wishes to thank his research supervisor, Professor L. A. Zadeh, for the encouragement and guidance throughout the preparation of this paper; he also thanks Professor M. A. Harrison for the stimulating lectures on Parsing Theory and discussions, ---r -.-."-.v ^ - -5-

REFERENCES 1. Hopcroft, J. E. and Ullman, J. D., "Formal Languages and Their Relation to Automata," Addison-Wesley, 1969. 2. Gries, D., "Compiler Construction for Digital Computers," Wiley, 1971. 3. Aho, A. V. and Ullman, J. D., "The Theory of Parsing, Translation and Compiling," Vol. I, Prentice Hall, 1972 4. Gray, J. N. and Harrison, M. A., "On the Covering and Reduction Problems for Context-Free Grammars," JACM, October 1972, pp. 675-698. 5. Knuth, D. E., "On the Translation of Languages from Left to Right," Information and Control. 1965, pp. 607-639. 6. Wirth, N. and Weber, H., "EULER: A Generalization of ALGOL and its Formal Definitions, Parts I, II," CACM, January, February 1966, pp. 11-23, 89-99. 7. Gray, J. N. and Harrison, M. A., "Canonical Precedence Schemes," JACM (to appear). 8. Lewis, P. M. II and Stearns, R. E., "Syntax-Directed Transductions," JACM, 1968, pp. 465-488. 9. Rosencrantz, D. J. and Stearns, R. E., "Properties of Deterministic Top-Down Grammars," Information and Control, 1970, pp. 226-256. 10. Y. E. Cho, "A Fast Left-Corner Parsing Algorithm," (under preparation), -6-