How to write proofs - II

Similar documents
Structural Induction

Problem Session 5 (CFGs) Talk about the building blocks of CFGs: S 0S 1S ε - everything. S 0S0 1S1 A - waw R. S 0S0 0S1 1S0 1S1 A - xay, where x = y.

Concordia University Department of Computer Science & Software Engineering

AC68 FINITE AUTOMATA & FORMULA LANGUAGES DEC 2013

Finite Automata Theory and Formal Languages TMV027/DIT321 LP4 2018

CPSC 313 Introduction to Computability

Grammars (part II) Prof. Dan A. Simovici UMB

UNIT II REGULAR LANGUAGES

Parikh s theorem. Håkan Lindqvist

CS481F01 Prelim 2 Solutions

Harvard CS 121 and CSCI E-207 Lecture 12: General Context-Free Recognition

5.A Examples of Context-Free Grammars 3.1 and 3.2 of Du & Ko s book(pp )

Einführung in die Computerlinguistik

Lecture 11 Context-Free Languages

REGular and Context-Free Grammars

Note: In any grammar here, the meaning and usage of P (productions) is equivalent to R (rules).

SFWR ENG 2FA3. Solution to the Assignment #4

Part 4 out of 5 DFA NFA REX. Automata & languages. A primer on the Theory of Computation. Last week, we showed the equivalence of DFA, NFA and REX

Chapter 6. Properties of Regular Languages

Theory of Computation - Module 3

COSE212: Programming Languages. Lecture 1 Inductive Definitions (1)

Recitation 4: Converting Grammars to Chomsky Normal Form, Simulation of Context Free Languages with Push-Down Automata, Semirings

Homework 4. Chapter 7. CS A Term 2009: Foundations of Computer Science. By Li Feng, Shweta Srivastava, and Carolina Ruiz

CSE 468, Fall 2006 Homework solutions 1

CS 373: Theory of Computation. Fall 2010

Lecture 12 Simplification of Context-Free Grammars and Normal Forms

Context-Free Grammars (and Languages) Lecture 7

Context Free Language Properties

Harvard CS 121 and CSCI E-207 Lecture 10: CFLs: PDAs, Closure Properties, and Non-CFLs

Fundamentele Informatica II

The Pumping Lemma for Context Free Grammars

Automata and Formal Languages - CM0081 Non-Deterministic Finite Automata

Theory of Computer Science

The Chomsky Hierarchy(review)

V Honors Theory of Computation

Set Theory. CSE 215, Foundations of Computer Science Stony Brook University

Pushdown automata. Twan van Laarhoven. Institute for Computing and Information Sciences Intelligent Systems Radboud University Nijmegen

Context-Free Grammars: Normal Forms

60-354, Theory of Computation Fall Asish Mukhopadhyay School of Computer Science University of Windsor

5/10/16. Grammar. Automata and Languages. Today s Topics. Grammars Definition A grammar G is defined as G = (V, T, P, S) where:

Chap. 7 Properties of Context-free Languages

Ogden s Lemma. and Formal Languages. Automata Theory CS 573. The proof is similar but more fussy. than the proof of the PL4CFL.

Part 1. For any A-module, let M[x] denote the set of all polynomials in x with coefficients in M, that is to say expressions of the form

Automata Theory - Quiz II (Solutions)

cse303 ELEMENTS OF THE THEORY OF COMPUTATION Professor Anita Wasilewska

Introduction to Formal Languages, Automata and Computability p.1/42

/ / MET Day 000 NC1^ INRTL MNVR I E E PRE SLEEP K PRE SLEEP R E

Solution to CS375 Homework Assignment 11 (40 points) Due date: 4/26/2017

Chomsky and Greibach Normal Forms

HW 3 Solutions. Tommy November 27, 2012

Theory of Computation

Linear conjunctive languages are closed under complement

cse303 ELEMENTS OF THE THEORY OF COMPUTATION Professor Anita Wasilewska

Homework #2 Solutions Due: September 5, for all n N n 3 = n2 (n + 1) 2 4

What is this course about?

BOUNDS ON ZIMIN WORD AVOIDANCE

Solutions to Problem Set 3

(pp ) PDAs and CFGs (Sec. 2.2)

6.1 The Pumping Lemma for CFLs 6.2 Intersections and Complements of CFLs

NOTES ON SIMPLE NUMBER THEORY

Chapter 3. Regular grammars

Lesson 3.5 Exercises, pages

download instant at Assume that (w R ) R = w for all strings w Σ of length n or less.

Let P(n) be a statement about a non-negative integer n. Then the principle of mathematical induction is that P(n) follows from

CS154 Final Examination

ECS 120: Theory of Computation UC Davis Phillip Rogaway February 16, Midterm Exam

Introduction to Kleene Algebras

Comment: The induction is always on some parameter, and the basis case is always an integer or set of integers.

C1.1 Introduction. Theory of Computer Science. Theory of Computer Science. C1.1 Introduction. C1.2 Alphabets and Formal Languages. C1.

3.2 Subspace. Definition: If S is a non-empty subset of a vector space V, and S satisfies the following conditions: (i).

Ogden s Lemma for CFLs

Math 110 (S & E) Textbook: Calculus Early Transcendentals by James Stewart, 7 th Edition

CMSC 330: Organization of Programming Languages

10.4 The Kruskal Katona theorem

TAFL 1 (ECS-403) Unit- III. 3.1 Definition of CFG (Context Free Grammar) and problems. 3.2 Derivation. 3.3 Ambiguity in Grammar

Solution Scoring: SD Reg exp.: a(a

Context Sensitive Grammar

Department of Computer Science University at Albany, State University of New York Solutions to Sample Discrete Mathematics Examination II (Fall 2007)

What Is a Language? Grammars, Languages, and Machines. Strings: the Building Blocks of Languages

Definition: A grammar G = (V, T, P,S) is a context free grammar (cfg) if all productions in P have the form A x where

Please give details of your answer. A direct answer without explanation is not counted.

Pushdown Automata (2015/11/23)

Computational Models - Lecture 4 1

Properties of Context-Free Languages

FABER Formal Languages, Automata. Lecture 2. Mälardalen University

Homework 4 Solutions. 2. Find context-free grammars for the language L = {a n b m c k : k n + m}. (with n 0,

MATH 324 Summer 2011 Elementary Number Theory. Notes on Mathematical Induction. Recall the following axiom for the set of integers.

St.MARTIN S ENGINEERING COLLEGE Dhulapally, Secunderabad

Harvard CS 121 and CSCI E-207 Lecture 6: Regular Languages and Countability

Theory of Computation

Advanced Automata Theory 7 Automatic Functions

COSE212: Programming Languages. Lecture 1 Inductive Definitions (1)

Context Free Languages. Automata Theory and Formal Grammars: Lecture 6. Languages That Are Not Regular. Non-Regular Languages

Properties of Context-Free Languages. Closure Properties Decision Properties

Pushdown Automata. We have seen examples of context-free languages that are not regular, and hence can not be recognized by finite automata.

Solutions to Old Final Exams (For Fall 2007)

Recurrence Relations and Recursion: MATH 180

PS2 - Comments. University of Virginia - cs3102: Theory of Computation Spring 2010

Computational Models - Lecture 4 1

Section 1 (closed-book) Total points 30

Transcription:

How to write proofs - II Problem (Ullman and Hopcroft, Page 104, Exercise 4.8). Let G be the grammar Prove that S ab ba A a as baa B b bs abb L(G) = { x {a, b} x contains equal number of a s and b s }. Proof. To prove the statement above, we would prove the following lemma first. Lemma 1. If x is a non-empty string over {a, b}, then the following statements hold (a) If x contains equal number of a s and b s, then S x. (b) If x contains one more a than b, then A x. (c) If x contains one more b than a, then B x. Proof of lemma 1. We will prove the lemma by induction on the length of x. Possible non-empty strings over {a, b} of length less than or equal to 2 satisfying one of the above criteria are {a, b, ab, ba}. If x = a, then If x = b, then If x = ab, then If x = ba, then A a. B b. S ab ab. S ba ba. So, the statements hold when 1 x 2. Let us assume that the statements hold for all x such that x for some integer 1, and x satisfies one of the above three criteria. Then, consider a string y of length + 1. Depending on the composition of y, we have 3 cases 1

(I) y has equal number of a s and b s. Let the first character of y be a. So, (i) y =, and y = ay, (ii) number of b s in y is one more than the number of a s. By induction hypothesis, So, B y. S ab ay = y. On the other hand, if the first character of y is b, then y can be expressed as y = by (i) y =, and (ii) number of a s in y is one more than the number of b s. So, by induction hypothesis So, A y. S ba by = y. (II) y has one more a than b. Let the first character of y be a. So, y can be expressed as y = ay, (i) y =, and (ii) number of a s and b s in y are equal. So, by induction hypothesis Hence, S y. A as ay = y. On the other hand, let the first character of y be b. So, y can be expressed as y = by, (i) y =, and 2

(ii) number of a s in y is two more than the number of b s. Now, we can observe that the difference in the count of a s and b s in y at the start of the string is 0, and at the end is 2. So, there must be a prefix of y, say u, such that the number of a s in u is one more than the number of b s. So, y can be exressed as y = uv, u < y, v < y and the number of a s in u and in v is one more than the number of b s. We also note that u <, v <. So, by induction hypothesis A u, and A v. So, A baa bua buv = y. (III) y has one more b than a. This case can be handled in an analogous manner to the case above with one difference. In this case, we can show that B y. Finally, with the 3 cases established for y of length + 1 satisfying the criteria of the lemma, we have proved the statements of the lemma for all non-empty strings. We now prove a result that shows the other direction of lemma 1. Lemma 2. The following statements hold for non-empty strings over {a, b}. (a) If S x, then x contains equal number of a s and b s. (b) If A x, then x contains one more a than b. (c) If B x, then x contains one more b than a. Proof of lemma 2. We will prove the lemma by induction on the number of steps is taes to derive x. When the number of derivation steps is 2, S, A and B derive the following strings S ab ab S ba ba A a B b 3

So, the statements hold when the number of derivation steps are 2. Let us assume that the statements hold for all strings that can be derived from S, A and B in steps. Then, consider the strings that are derived in + 1 steps. (I) S x in + 1 steps. So, S +1 In the above derivation, consider the first derivation step. Based on the given grammar, there are two possibilites (a) The first derivation step uses the production S ab. In that case S ab So, the first symbol of x is a. Expressing x as Thus, S ab x = ax, B = ax.. By induction hypothesis, x has one more b than a. So, x, which has been expressed as ax has equal number of a s and b s. (b) The first derivation step uses the production S ba. In that case S ba So, the first symbol of x is b. Expressing x as Thus, S ba x = bx, A = bx.. By induction hypothesis, x has one more a than b. So, x, which has been expressed as bx has equal number of a s and b s. (II) A x in + 1 steps. So, A +1 In the above derivation, consider the first derivation step. Based on the given grammar, there are two possibilites 4

(a) The first derivation step uses the production A as. In that case A as So, the first symbol of x is a. Expressing x as Thus, A as x = ax, S = ax.. By induction hypothesis, x has equal number of a s and b s. So, x, which has been expressed as ax has one more a than b. (b) The first derivation step uses the production A baa. In that case A baa So, the first symbol of x is b. Expressing x as x = bx, A baa = bx. Let the first of the A s in baa derive the string u and the second of the A derive the string v. So, the derivation can be rewritten as A baa < = bua < = buv = bx. So, we have the following observations i. x = bx = buv, ii. A = < u, and iii. A = < v. Thus, by induction hypothesis, both u and v have the property that the number of a s in them is one more than the number of b s. So, in x = buv, the number of a s is one more than the number of b s. (III) B x in + 1 steps. This case can be handled in a manner analogous to the earlier case. Finally, with the three cases established for derivation steps of length + 1, we have proved the statements of the lemma for all non-emplty strings. 5

Combining lemmas 1 and 2, we have the following theorem. Theorem 1. The following statements hold for non-empty strings over {a, b}. (a) S x if and only if x contains equal number of a s and b s. (b) A x if and only if x contains one more a than b. (c) B x if and only if x contains one more b than a. Thus, we see that the start variable S of the given grammar G derives all strings with equal number of a s and b s and nothing else. 6