1 Showing Languages are Non-Regular

Similar documents
Automata and Formal Languages

Formal Languages and Automata Theory - Regular Expressions and Finite Automata -

Regular Languages and Finite State Machines

Regular Languages and Finite Automata

Turing Machines: An Introduction

The Halting Problem is Undecidable

Automata and Computability. Solutions to Exercises

Pushdown Automata. place the input head on the leftmost input symbol. while symbol read = b and pile contains discs advance head remove disc from pile

Deterministic Finite Automata

CS103B Handout 17 Winter 2007 February 26, 2007 Languages and Regular Expressions

6.045: Automata, Computability, and Complexity Or, Great Ideas in Theoretical Computer Science Spring, Class 4 Nancy Lynch

Reading 13 : Finite State Automata and Regular Expressions

Regular Expressions and Automata using Haskell

CSC4510 AUTOMATA 2.1 Finite Automata: Examples and D efinitions Definitions

CS5236 Advanced Automata Theory

Introduction to Automata Theory. Reading: Chapter 1

CAs and Turing Machines. The Basis for Universal Computation

C H A P T E R Regular Expressions regular expression

CS154. Turing Machines. Turing Machine. Turing Machines versus DFAs FINITE STATE CONTROL AI N P U T INFINITE TAPE. read write move.

Automata on Infinite Words and Trees

(IALC, Chapters 8 and 9) Introduction to Turing s life, Turing machines, universal machines, unsolvable problems.

CS 3719 (Theory of Computation and Algorithms) Lecture 4

6.080 / Great Ideas in Theoretical Computer Science Spring 2008

INCIDENCE-BETWEENNESS GEOMETRY

Handout #1: Mathematical Reasoning

Lecture Note 1 Set and Probability Theory. MIT Spring 2006 Herman Bennett

Increasing Interaction and Support in the Formal Languages and Automata Theory Course

How To Compare A Markov Algorithm To A Turing Machine

Sequential lmove Games. Using Backward Induction (Rollback) to Find Equilibrium

Fundamentele Informatica II

Probabilistic Strategies: Solutions

Implementation of Recursively Enumerable Languages using Universal Turing Machine in JFLAP

SECTION 10-2 Mathematical Induction

Solutions for Practice problems on proofs

Finite Automata. Reading: Chapter 2

Notes on Complexity Theory Last updated: August, Lecture 1

3515ICT Theory of Computation Turing Machines

Introduction to Turing Machines

WHAT ARE MATHEMATICAL PROOFS AND WHY THEY ARE IMPORTANT?

CMPSCI 250: Introduction to Computation. Lecture #19: Regular Expressions and Their Languages David Mix Barrington 11 April 2013

Session 6 Number Theory

CHAPTER 3. Methods of Proofs. 1. Logical Arguments and Formal Proofs

Clock Arithmetic and Modular Systems Clock Arithmetic The introduction to Chapter 4 described a mathematical system

Automata Theory. Şubat 2006 Tuğrul Yılmaz Ankara Üniversitesi

24 Uses of Turing Machines

ASSIGNMENT ONE SOLUTIONS MATH 4805 / COMP 4805 / MATH 5605

AN ANALYSIS OF A WAR-LIKE CARD GAME. Introduction

Regular Expressions with Nested Levels of Back Referencing Form a Hierarchy

Computability Theory

Elementary Number Theory and Methods of Proof. CSE 215, Foundations of Computer Science Stony Brook University

Basics of Counting. The product rule. Product rule example. 22C:19, Chapter 6 Hantao Zhang. Sample question. Total is 18 * 325 = 5850

On Winning Conditions of High Borel Complexity in Pushdown Games

Pushdown automata. Informatics 2A: Lecture 9. Alex Simpson. 3 October, School of Informatics University of Edinburgh als@inf.ed.ac.

Turing Degrees and Definability of the Jump. Theodore A. Slaman. University of California, Berkeley. CJuly, 2005

Properties of Stabilizing Computations

Enforcing Security Policies. Rahul Gera

25 Integers: Addition and Subtraction

Mathematical Induction

6.080/6.089 GITCS Feb 12, Lecture 3

Finite Automata. Reading: Chapter 2

I. GROUPS: BASIC DEFINITIONS AND EXAMPLES

Computer Architecture Syllabus of Qualifying Examination

ÖVNINGSUPPGIFTER I SAMMANHANGSFRIA SPRÅK. 15 april Master Edition

Near Optimal Solutions

SUBGROUPS OF CYCLIC GROUPS. 1. Introduction In a group G, we denote the (cyclic) group of powers of some g G by

Informatique Fondamentale IMA S8

Chapter 3. Cartesian Products and Relations. 3.1 Cartesian Products

1. Nondeterministically guess a solution (called a certificate) 2. Check whether the solution solves the problem (called verification)

Baltic Way Västerås (Sweden), November 12, Problems and solutions

Discrete Mathematics and Probability Theory Fall 2009 Satish Rao, David Tse Note 2

Turing Machines, Part I

Proseminar on Semantic Theory Fall 2013 Ling 720. Problem Set on the Formal Preliminaries : Answers and Notes

Omega Automata: Minimization and Learning 1

An example of a computable

COMPUTER SCIENCE STUDENTS NEED ADEQUATE MATHEMATICAL BACKGROUND

Minimax Strategies. Minimax Strategies. Zero Sum Games. Why Zero Sum Games? An Example. An Example

Regular Languages and Finite Automata

Degrees that are not degrees of categoricity

THE DIMENSION OF A VECTOR SPACE

SRM UNIVERSITY FACULTY OF ENGINEERING & TECHNOLOGY SCHOOL OF COMPUTING DEPARTMENT OF SOFTWARE ENGINEERING COURSE PLAN

LEARNING OBJECTIVES FOR THIS CHAPTER

6.207/14.15: Networks Lecture 15: Repeated Games and Cooperation

6.3 Conditional Probability and Independence

Mathematics for Computer Science/Software Engineering. Notes for the course MSM1F3 Dr. R. A. Wilson

Sample Induction Proofs

Factorizations: Searching for Factor Strings

One pile, two pile, three piles

Composability of Infinite-State Activity Automata*

Introduction to Theory of Computation

TAKE-AWAY GAMES. ALLEN J. SCHWENK California Institute of Technology, Pasadena, California INTRODUCTION

NIM with Cash. Abstract. loses. This game has been well studied. For example, it is known that for NIM(1, 2, 3; n)

THE TURING DEGREES AND THEIR LACK OF LINEAR ORDER

CONTINUED FRACTIONS AND PELL S EQUATION. Contents 1. Continued Fractions 1 2. Solution to Pell s Equation 9 References 12

CPSC 121: Models of Computation Assignment #4, due Wednesday, July 22nd, 2009 at 14:00

ω-automata Automata that accept (or reject) words of infinite length. Languages of infinite words appear:

Lights and Darks of the Star-Free Star

Honors Class (Foundations of) Informatics. Tom Verhoeff. Department of Mathematics & Computer Science Software Engineering & Technology

CSE 135: Introduction to Theory of Computation Decidability and Recognizability

Gambling and Data Compression

i/io as compared to 4/10 for players 2 and 3. A "correct" way to play Certainly many interesting games are not solvable by this definition.

Transcription:

1 Showing Languages are Non-Regular Question: How can one show that a language is not regular? We have no way to do this so far; constructing a finite automaton or a regular expression can only show a language is regular. To show a language is not regular, one would have to consider all possible finite automata or regular expressions. It could be helpful to show a language is non-regular to avoid wasting time looking for a finite automaton or a regular expression for it. One would then know that a finite amount of memory is not enough to recognize the language. This shows that more powerful techniques such as context-free languages or Turing machines are needed for the language. This material will help you to have intuition which kinds of languages can be described by finite automata and which cannot. This will help you to see, for example, that programming languages cannot be described by finite automata, in most cases. To show that a language is non-regular, we have to find some property P that all regular languages have, and then to show that a language is not regular, we have to show that it does not have property P. To obtain such a property P, consider again the interview automaton: 1

W i impressed W S n neutral W S u unimpressed S Consider the input W SSW W. The prefixes W S and W SSW both lead to the state n. WS SW W n n n i Thus the substring SW of W SSW W leads from n to n: SW n WS n W i 2

This means that W S(SW ) 2 W, that is, W SSW SW W, is also accepted, and W SW is accepted, and in fact, W S(SW ) i W is accepted for any i. What has to be true of an input to be able to pump it like this? Note that the string W by itself is accepted, but it cannot be pumped by the same argument. For this automaton, such pumping can be done on any string of length three or more that is accepted. Why is this? In general, for a finite automaton with n states, the same argument can be done for any string of length greater than or equal to n. Theorem 1.1 (2.4.1) Let L be a regular language. Then there is an integer n 1 such that any string w L with w n can be written as w = xyz where x, y, and z are strings and y ϵ, xy n and x(y k )z L for all k 0. Proof: Because L is regular, there is a finite automaton M such that L is the language recognized by M. Let n be the number of states of M. Let a 1, a 2,..., a n be the first n symbols of w. Let q 0 be the start state of M, and let q i be the state M is in after reading the symbols a 1, a 2,..., a i. The sequence q 0, q 1, q 2,..., q n of states has n + 1 elements, but there are only n states in M. Thus there must be i and j with i j such that q i = q j. Let x be a 1, a 2,..., a i, let y be a i+1, a i+2,..., a j, and let z be the rest of w, that is, xyz = w. Then x causes M to go from q 0 to q i, y causes M to go from q i to q j, which is equal to q i, and z causes M to go from q j to some accepting state r of M. Then y k causes M to go from q i to q i for any k. Thus for any k, the string x(y k )z is accepted, because x causes M to go from q 0 to q i, y i causes M to go from q i to q i, and z causes M to go from q i to the accepting state r of M. 3

Therefore the string x(y k )z is in L. Diagram of the computation for the string w = xyz: (a(i+1)... aj) x q0 a0... ai qi z r y The computation for the pumped string xy k z: y k (a(i+1)... aj) k x q0 a0... ai qi z r Corollary 1.1 A language L is not regular if, for all integers N > 0, there exists a string w in L with w N, such that for all ways of expressing w as xyz with xy N, and y ϵ, there exists a k 0 such that x(y k )z L. 4

1.1 Showing a n b n non-regular We illustrate this result on the language L = {a n b n : n 0}. To show the property of the corollary, it is necessary to consider all integers N. This is an infinite number of cases, so the work has to be made finite by mathematics. To show that L is not regular, first, for all N > 0 it is necessary to choose a string w in L with w N. For this, we choose the string a N b N. Then, we have to show that for all ways of expressing a N b N as xyz with xy N, and y ϵ, there exists a k 0 such that x(y k )z L. For this, we consider two possibilities: 1. Suppose y has unequal numbers of a and b. Then x(y 2 )z L because x(y 2 )z has as many a s and b s as xyz, plus the a s and b s in y. xyz has equal numbers of a s and b s, but y does not. Therefore x(y 2 )z has unequal numbers of a s and b s. So x(y 2 )z L because all strings in L have equal numbers of a s and b s. Example: If xyz = aaaabbbb = (aaa)(abb)(bb), x = aaa, y = abb, z = bb, then y has unequal numbers of a and b. So xyyz is (aaa)(abb)(abb)(bb) and has 5 a and 6 b. 2. Suppose y has equal numbers of a and b. Then, because y ϵ, y has at least one a and one b. Now x(y 2 )z is xyyz, so y appears twice, so there is a b in the first y and an a in the second y. So at least one b appears before one a in x(y 2 )z. However, all strings in L have all a before all b. 5

Therefore x(y 2 )z L. Example: If xyz = aaaabbbb = (aa)(aabb)(bb), x = aa, y = aabb, z = bb, then y has both a and b. So xyyz is (aa)(aabb)(aabb)(bb) and has a b before an a. There is another way to do the proof. You can note that because xy N, y consists only of a s, so that it is only necessary to consider the first case in the above proof. 1.2 The pumping theorem as a game The pumping theorem can also be expressed as a game between two players. For this see handout 4. It doesn t matter who wins a particular game, but who has a winning strategy. If you have a winning strategy, the language is non-regular. If the opponent has a winning strategy, you don t know if the language is regular or not. Note that the game can only show that a language is non-regular; it cannot show that a language is regular. To show that a language is regular, you can find an automaton for the language. For L = {a n b n }, here is the winning strategy for you. 1. The opponent chooses N. 2. You choose the string a N b N. 3. The opponent chooses x, y, and z such that w = xyz, y ϵ, and xy n. 4. You choose i = 2. 6

As we argued above, this is a winning strategy for you. Note that it does not constrain what the opponent does; no matter what the opponent does, it gives you a response that leads to a win for you. For L = L(a b ), the opponent has a winning strategy. Note that this language can be recognized by a three state deterministic finite automaton. Here is the opponent s winning strategy: 1. The opponent chooses N = 3. 2. You choose a string of length 3 or more. 3. The opponent runs this string through his automaton for L and notes where it goes through the same state twice. The oppenent uses this to divide the string into x, y, and z such that xy i z L for all i. 4. You choose some i. Because xy i z L, you lose. Note that the opponent s winning strategy specifies his moves, but none of your moves. For any regular language L, the opponent has a winning strategy. Because L is regular, there is a deterministic finite automaton M recognizing L. Let n be the number of states of M. Then the opponent s winning strategy for L is this: 1. The opponent chooses N = n. 2. You choose a string of length n or more. 3. The opponent runs this string through his automaton for L and notes where it goes through the same state twice. The oppenent uses this to divide the string into x, y, and z such that xy i z L for all i. 4. You choose some i. Because xy i z L, you lose. If the opponent is foolish, he can choose N smaller than n, or he may choose x, y, and z foolishly, and then you may be able to win the game. But 7

the important thing is who has a winning strategy if they play perfectly, not who wins a particular game. There are some unusual non-regular languages for which the opponent may have a winning strategy. So if the opponent has a winning strategy, you don t know if L is regular or not. Here are two non-regular languages for which the pumping lemma fails to show that they are non-regular: 1. L 1 = {a i b j c k : i, j, k 0, if i = 1 then j = k}. http://www.cs.nthu.edu.tw/~wkhon/assignments/assign1ans.pdf 2. L 2 = {c m a n b n : m, n 1} {a, b} (Kamala and Rama text) How can the opponent win for language L 1, for example? If you choose a string containing at least one a then the opponent can choose a substring consisting entirely of a s, and you lose because no matter how you pump it, you get a string in L 1 and the opponent wins. If you choose a string containing only b and c then the opponent can choose a substring having only b in it or only c in it. No matter how you pump it, you get a string in L 1 and the opponent wins. Thus the opponent has a winning strategy even though L 1 is not regular. Exercise: Show that L 1 is non-regular using the fact that if L is regular and x is a string, then {y : xy L} is also regular, or else look at intersections with a regular language. 1.3 Finite languages If the language is finite, the opponent chooses N larger than the length of the longest string in L. Because you can t choose a string of length N or more, the opponent wins by default. 8

1.4 Intersecting with a regular language Sometimes it helps to intersect a language with a regular language to show non-regularity. For example, consider the language L consisting of all strings of a and b that contain the same number of a and b. Now, consider L 1 = L L(a b ). Then all strings in L 1 have the same number of a and b, because they are in L, and they also have all a before all b, because they are in L(a b ). So what do these strings look like? They are strings of the form a n b n, and any string of the form a n b n is in L 1. Thus L 1 = {a n b n : n 0}. We showed already that {a n b n : n 0} is non-regular. Thus L 1 is non-regular. If L were regular, L 1 would be regular, because the intersection of two regular languages is regular. Therefore L is not regular. This gives a way to show languages are non-regular without having to use the pumping theorem or the game each time. 1.5 An interesting fact If L is an arbitrary subset of L(a ), then L is a regular language. This is not easy to prove, by the way. Note that for L Σ where Σ has two or more letters, L need not be regular if L is not regular. Example: Suppose L = {a n : n is a perfect square}. Thus L = {a, a 4, a 9, a 16,...} = {a, aaaa, aaaaaaaaa,...}. Then L is not regular. What is L? Is it regular? Now suppose L = {a n : n is a perfect square, n > 1}. Thus L = {a 4, a 9, a 16,...} = {aaaa, aaaaaaaaa,...}. Then L is not regular. What is L? Is it regular? Problem: Find a language L such that L is not regular. 9