Extended RE's. UNIX pioneered the use of additional operators. and notation for RE's: æ E? = 0 or 1 occurrences of E = æ + E.

Similar documents
Proving languages to be nonregular

FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY

The Pumping Lemma and Closure Properties

Before we show how languages can be proven not regular, first, how would we show a language is regular?

Fall 1999 Formal Language Theory Dr. R. Boyer. 1. There are other methods of nding a regular expression equivalent to a nite automaton in

Closure Properties of Regular Languages. Union, Intersection, Difference, Concatenation, Kleene Closure, Reversal, Homomorphism, Inverse Homomorphism

2.1 Solution. E T F a. E E + T T + T F + T a + T a + F a + a

CS 154, Lecture 4: Limitations on DFAs (I), Pumping Lemma, Minimizing DFAs

Sri vidya college of engineering and technology

Theory of Computation p.1/?? Theory of Computation p.2/?? Unknown: Implicitly a Boolean variable: true if a word is

CS 154. Finite Automata vs Regular Expressions, Non-Regular Languages

CS5371 Theory of Computation. Lecture 5: Automata Theory III (Non-regular Language, Pumping Lemma, Regular Expression)

Lecture 4: More on Regexps, Non-Regular Languages

FORMAL LANGUAGES, AUTOMATA AND COMPUTATION

Lecture 7 Properties of regular languages

Pumping Lemma: Let L be an inænite regular language. 9 a constant mé0 such that any w 2 L with jwj çmcan be decomposed into three parts as w = xyz wit

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

More Properties of Regular Languages

Computational Theory

Properties of Regular Languages (2015/10/15)

Properties of Context-Free Languages

Incorrect reasoning about RL. Equivalence of NFA, DFA. Epsilon Closure. Proving equivalence. One direction is easy:

CS154. Non-Regular Languages, Minimizing DFAs

CSE 105 THEORY OF COMPUTATION

Finite Automata Theory and Formal Languages TMV027/DIT321 LP4 2018

Regular Expressions. Definitions Equivalence to Finite Automata

Automata: a short introduction

UNIT-III REGULAR LANGUAGES

CS 154, Lecture 3: DFA NFA, Regular Expressions

Notes on Pumping Lemma

Formal Languages, Automata and Models of Computation

Computer Sciences Department

CS 455/555: Finite automata

CSE 105 THEORY OF COMPUTATION

THEORY OF COMPUTATION (AUBER) EXAM CRIB SHEET

CSci 311, Models of Computation Chapter 4 Properties of Regular Languages

Lecture Notes On THEORY OF COMPUTATION MODULE -1 UNIT - 2

What we have done so far

Finite Automata and Formal Languages TMV026/DIT321 LP4 2012

Finite Automata and Regular languages

TDDD65 Introduction to the Theory of Computation

Finite Automata and Formal Languages

Fall 1999 Formal Language Theory Dr. R. Boyer. Theorem. For any context free grammar G; if there is a derivation of w 2 from the

September 11, Second Part of Regular Expressions Equivalence with Finite Aut

CISC 4090: Theory of Computation Chapter 1 Regular Languages. Section 1.1: Finite Automata. What is a computer? Finite automata

acs-04: Regular Languages Regular Languages Andreas Karwath & Malte Helmert Informatik Theorie II (A) WS2009/10

Regular Expressions and Language Properties

ECS120 Fall Discussion Notes. October 25, The midterm is on Thursday, November 2nd during class. (That is next week!)

Closure under the Regular Operations

Great Theoretical Ideas in Computer Science. Lecture 4: Deterministic Finite Automaton (DFA), Part 2

UNIT II REGULAR LANGUAGES

CS154 Final Examination

Mathematics for linguists

More on Regular Languages and Non-Regular Languages

Theory of Computation (II) Yijia Chen Fudan University

Automata & languages. A primer on the Theory of Computation. Laurent Vanbever. ETH Zürich (D-ITET) September,

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

Chapter 6. Properties of Regular Languages

Properties of Regular Languages. BBM Automata Theory and Formal Languages 1

Theory Bridge Exam Example Questions

1 More finite deterministic automata

Automata Theory. Lecture on Discussion Course of CS120. Runzhe SJTU ACM CLASS

Fooling Sets and. Lecture 5

Closure Properties of Context-Free Languages. Foundations of Computer Science Theory

Chapter 2 The Pumping Lemma

Languages, regular languages, finite automata

FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY

Automata & languages. A primer on the Theory of Computation. Laurent Vanbever. ETH Zürich (D-ITET) October,

Part 3 out of 5. Automata & languages. A primer on the Theory of Computation. Last week, we learned about closure and equivalence of regular languages

Theory of Computation

Computational Models: Class 3

COM364 Automata Theory Lecture Note 2 - Nondeterminism

(Refer Slide Time: 0:21)

GEETANJALI INSTITUTE OF TECHNICAL STUDIES, UDAIPUR I

Finite Automata Theory and Formal Languages TMV027/DIT321 LP4 2017

Computational Models - Lecture 3

Warshall s algorithm

COMP4141 Theory of Computation

T (s, xa) = T (T (s, x), a). The language recognized by M, denoted L(M), is the set of strings accepted by M. That is,

TAFL 1 (ECS-403) Unit- II. 2.1 Regular Expression: The Operators of Regular Expressions: Building Regular Expressions

Name: Student ID: Instructions:

10. The GNFA method is used to show that

CS243, Logic and Computation Nondeterministic finite automata

CSE 105 THEORY OF COMPUTATION

CS375 Midterm Exam Solution Set (Fall 2017)

CPSC 421: Tutorial #1

Intro to Theory of Computation

Concatenation. The concatenation of two languages L 1 and L 2

Applied Computer Science II Chapter 1 : Regular Languages

Formal Languages. We ll use the English language as a running example.

Regular Expression Unit 1 chapter 3. Unit 1: Chapter 3

Sample Midterm. Understanding the questions is part of the exam; you are not allowed to ask questions during the exam.

Regular Expressions [1] Regular Expressions. Regular expressions can be seen as a system of notations for denoting ɛ-nfa

Closure under the Regular Operations

Finite Automata Theory and Formal Languages TMV027/DIT321 LP4 2018

Computational Models - Lecture 3 1

Computational Models - Lecture 5 1

Ogden s Lemma for CFLs

Unit 6. Non Regular Languages The Pumping Lemma. Reading: Sipser, chapter 1

1 Alphabets and Languages

Transcription:

Extended RE's UNIX pioneered the use of additional operators and notation for RE's: E? = 0 or 1 occurrences of E = + E. E + = 1 or more occurrences of E = EE. Character classes ëa, zgxë = the union of all èasciiè characters from a to z, plus the characters G and X, for example. Algebraic Laws for RE's If two expressions E and F have no variables, then E = F means that LèEè =LèF è ènot that E and F are identical expressionsè. Example: 1 + = 11. If E and F are RE's with variables, then E = F èe is equivalent to F è means that whatever languages we substitute for the variables èprovided we substitute the same language everywhere the same variable appearsè, the resulting expressions denote the same language. Example: R + = RR. With two notable exceptions, we can think of union è+è as if it were addition with ; in place of the identity 0, and concatenation, with in place of the identity 1,as multiplication. + and concatenation are both associative. + is commutative. Laws of the identities hold for both. ; is the annihilator for concatenation. The exceptions: 1. Concatenation is not commutative: ab 6= ba. 2. +isidempotent: E + E = E for any expression E. Checking a Law Suppose we are told that the law èr + Sè = èr S è holds for RE's. How would we check that this claim is true? Think of R and S as if they were single symbols, rather than placeholders for languages, i.e., R = f0g and S = f1g. Then the left side is clearly ëany sequence of 0's and 1's. 1

The right side also denotes any string of 0's and 1's, since 0 and 1 are each in Lè0 1 è. That test is necessary èi.e., if the test fails, then the law does not hold. We have particular languages that serve as a counterexample. But is it sucient èif the test succeeds, the law holdsè? Proof of Suciency The book has a fairly simple argument for why, when the ëconcretized" expressions denote the same language, then the languages we get by substituting any languages for the variables are also the same. But if you think that's obvious, the book also has an example of ëre's with intersection" where the same statement is false. Also is it clear that we can tell whether two RE's without variables denote the same language? Algorithm to do so will be covered. Closure Properties Not every language is a regular language. However, there are some rules that say ëif these languages are regular, so is this one derived from them. There is also a powerful technique the pumping lemma that helps us prove a language not to be regular. Key tool: Since we know RE's, DFA's, NFA's, -NFA's all dene exactly the regular languages, we can use whichever representation suits us when proving something about a regular language. Pumping Lemma If L is a regular language, then there exists a constant n such that every string w in L, of length n or more, can we written as w = xyz, where: 1. 0 é jyj. 2. jxyj çn. 2

3. For all i ç 0, wy i z is also in L. Note y i = y repeated i times; y 0 =. The alternating quantiers in the logical statement of the PL makes it very complex: è8lèè9nèè8wèè9x; y; zèè8iè. Proof of Pumping Lemma Since we claim L is regular, there must be a DFA A such that L = LèAè. Let A have n states; choose this n for the pumping lemma. Let w be a string of length ç n in L, say w = a 1 a 2 a m, where m ç n. Let q i be the state A is in after reading the rst i symbols of w. q 0 = start state, q 1 = èq 0 ;a 1 è, q 2 = ^èq 0 ;a 1 a 2 è, etc. Since there are only n dierent states, two of q 0 ;q 1 ;:::;q n must be the same; say q i = q j, where 0 ç iéjç n. Let x = a 1 a i ; y = a i+1 a j ; z = a j+1 a m. Then by repeating the loop from q i to q i with label a i+1 a j zero times once, or more, we can show that xy i z is accepted by A. PL Use We use the PL to show a language L is not regular. Start by assuming L is regular. Then there must be some n that serves as the PL constant. We may no know what n is, but we can work the rest of the ëgame" with n as a parameter. We choose some w that is known to be in L. Typically, w depends on n. Applying the PL, we know w can be broken into xyz, satisfying the PL properties. Again, we may not know how to break w, so we use x; y; z as parameters. We derive a contradiction by picking i èwhich might depend on n, x, y, andèor zè such that xy i z is not in L. 3

Example Consider the set of strings of 0's whose length is a perfect square; formally L = f0 i j i is a squareg. We claim L is not regular. Suppose L is regular. Then there is a constant n satisfying the PL conditions. Consider w =0 n2, which is surely in L. Then w = xyz, where jxyj çn and y 6=. By PL, xyyz is in L. But the length of xyyz is greater than n 2 and no greater than n 2 + n. However, the next perfect square after n 2 is èn +1è 2 = n 2 +2n +1. Thus, xyyz is not of square length and is not in L. Since we have derived a contradiction, the only unproved assumption that L is regular must be at fault, and we have a ëproof by contradiction" that L is not regular. Closure Properties Certain operations on regular languages are guaranteed to produce regular languages. Example: the union of regular languages is regular; start with RE's, and apply + to get an RE for the union. Substitution Take a regular language L over some alphabet. For each a in, let L a be a regular language. Let s be the substitution dened by sèaè =L a for each a. Extend s to strings by sèa 1 a 2 a n è= sèa 1 èsèa 2 è sèa n è; i.e., concatenate the languages L a1 L a2 L a n. Extend s to languages by sèmè =ëw inm sèwè. Then sèlè is regular. Proof That Substitution of Regular Languages Into a Regular Language is Regular Let R be a regular expression for language L. 4

Let R a be a regular expression for language sèaè =L a, for all symbols a in. Construct a RE E for sèlè by starting with R and replacing each symbol a by the RE L a. Proof that LèEè =sèlè is an induction on the height of èthe expression tree forè RE R. Basis: R is a single symbol, a. Then E = R a, L = fag, and sèlè =sèfagè =LèR a è. Cases where R is or ; easy. Induction: There are three cases, depending on whether R = R 1 + R 2, R = R 1 R 2,orR = R 1. We'll do only R = R 1 R 2. L = L 1 L 2, where L 1 = LèR 1 è and L 2 = LèR 2 è. Let E 1 be R 1, with each a replaced by R a, and E 2 similarly. By the IH, LèE 1 è=sèl 1 è and LèE 2 è=sèl 2 è. Thus, LèEè =sèl 1 èsèl 2 è=sèlè. Applications of the Substitution Theorem If L 1 and L 2 are regular, so is L 1 L 2. Let sèaè =L 1 and sèbè =L 2. Substitute into the regular language fabg. So is L 1 ë L 2. Substitute into fa; bg. Ditto L. 1 Substitute into Lèa è. Closure under homomorphism = substitution of one string for each symbol. Special case of a substitution. Example: Homomorphism Let L = Lè0 1 è, and let h be a homomorphism dened by hè0è = aa and hè1è =. Then hèlè =L, aaè = all strings of an even number of a's. Closure Under Inverse Homomorphism h,1 èlè =fw j hèwè isinlg. 5

See argument in course reader. Briey: Given homomorphism h and regular language L, start with a DFA A for L. Construct DFA B for h,1 èlè, by having B go from state q to state p on input a if ^, q; hèaè = p. Closure Under Reversal The reverse of a string w = a 1 a 2 a n is a n a 2 a 1. Denoted w R. Note R =. The reverse of a language L is the set containing the reverse of each string in L. If L is regular, so is L R. Proof: use RE's, recursive reversal as in course reader. 6