Chapter 6. Properties of Regular Languages

Similar documents
CS375 Midterm Exam Solution Set (Fall 2017)

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

Formal Languages, Automata and Models of Computation

Author: Vivek Kulkarni ( )

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

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

V Honors Theory of Computation

Introduction to Theory of Computing

CS375: Logic and Theory of Computing

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

Parsing Regular Expressions and Regular Grammars

HW6 Solutions. Micha l Dereziński. March 20, 2015

Chapter 5. Finite Automata

Sri vidya college of engineering and technology

Languages. Languages. An Example Grammar. Grammars. Suppose we have an alphabet V. Then we can write:

FORMAL LANGUAGES, AUTOMATA AND COMPUTATION

Computer Sciences Department

Theory of Computation

Non-context-Free Languages. CS215, Lecture 5 c

CPS 220 Theory of Computation

Closure under the Regular Operations

What we have done so far

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

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,

front pad rear pad door

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

Notes for Comp 497 (454) Week 10

CS 275 Automata and Formal Language Theory

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

Section Summary. Relations and Functions Properties of Relations. Combining Relations

The Pumping Lemma and Closure Properties

Notes for Comp 497 (Comp 454) Week 10 4/5/05

Computational Models: Class 3

Definition: A binary relation R from a set A to a set B is a subset R A B. Example:

UNIT II REGULAR LANGUAGES

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

Finite Automata and Regular languages

Computational Models - Lecture 3 1

Foundations of Informatics: a Bridging Course

Regular Expressions. Definitions Equivalence to Finite Automata

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

FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY

CSE 105 THEORY OF COMPUTATION

1. Induction on Strings

CSE 105 THEORY OF COMPUTATION

CISC4090: Theory of Computation

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

Mathematics for linguists

Context Free Language Properties

1 Alphabets and Languages

AC68 FINITE AUTOMATA & FORMULA LANGUAGES JUNE 2014

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

Automata: a short introduction

Warshall s algorithm

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

Properties of Context-Free Languages

CS500 Homework #2 Solutions

More Properties of Regular Languages

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

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

Computational Theory

Closure under the Regular Operations

Computational Models - Lecture 3

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

Computability Theory

THEORY OF COMPUTATION (AUBER) EXAM CRIB SHEET

5 Context-Free Languages

Computability and Complexity

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

3515ICT: Theory of Computation. Regular languages

Theory of Computation (II) Yijia Chen Fudan University

(b) If G=({S}, {a}, {S SS}, S) find the language generated by G. [8+8] 2. Convert the following grammar to Greibach Normal Form G = ({A1, A2, A3},

Chapter 8. Turing Machine (TMs)

Languages, regular languages, finite automata

Theory of Languages and Automata

Section 1 (closed-book) Total points 30

The Pumping Lemma for Context Free Grammars

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

VTU QUESTION BANK. Unit 1. Introduction to Finite Automata. 1. Obtain DFAs to accept strings of a s and b s having exactly one a.

Automata Theory. CS F-10 Non-Context-Free Langauges Closure Properties of Context-Free Languages. David Galles

Computational Models - Lecture 4

UNIT-III REGULAR LANGUAGES

Finite Automata Theory and Formal Languages TMV027/DIT321 LP4 2018

Context-Free Languages (Pre Lecture)

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

CS 530: Theory of Computation Based on Sipser (second edition): Notes on regular languages(version 1.1)

HW 3 Solutions. Tommy November 27, 2012

NODIA AND COMPANY. GATE SOLVED PAPER Computer Science Engineering Theory of Computation. Copyright By NODIA & COMPANY

Properties of Regular Languages. Wen-Guey Tzeng Department of Computer Science National Chiao Tung University

Exam 1 CSU 390 Theory of Computation Fall 2007

Properties of Context-Free Languages. Closure Properties Decision Properties

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

The View Over The Horizon

Equivalence of Regular Expressions and FSMs

Pushdown Automata. Reading: Chapter 6

Formal Definition of a Finite Automaton. August 26, 2013

Einführung in die Computerlinguistik

This lecture covers Chapter 7 of HMU: Properties of CFLs

Fundamentele Informatica II

Transcription:

Chapter 6 Properties of Regular Languages

Regular Sets and Languages Claim(1). The family of languages accepted by FSAs consists of precisely the regular sets over a given alphabet. Every regular set is accepted by some NFA-, a) : b) : q 0 q 0 q f q f or q 0 c) a : q 0 a q f Defn. 2.3.1 (on regular sets): Let be an alphabet. The regular sets over are defined recursively as follows: i) Basis:, { }, and { a }, a, are regular sets over ii) Recursion: Let X and Y be regular sets over. The sets X Y, XY, and X* are regular sets over. iii) Closure: Every regular set is obtained from (i) by a finite number of application of (ii) 2

Regular Sets and Languages Let M 1 and M 2 be two FSAs, and let S m1, F m1, S m2, and F m1, be the new start and accepting states of M 1 and M 2, respectively: a) L(M 1 ) L(M 2 ): a string can be processed by M 1 and M 2 in parallel S S m1 S m2 M 1 M 2 F m1 F m2 F b) L(M 1 ) L(M 2 ): a string is processed by the composite machine sequentially S m1 M F S 1 m1 m2 M 2 F m2 c) L(M 1 )* S S m1 M F 1 m1 F 3

3.3 Regular Grammars A grammar is defined as a quadruple (V,, P, S), where V is a finite set of nonterminals, or variables is a finite set of terminals S V, is a start symbol, and P is a finite set of rewrite/production rules of the form, where (V )*, (V )* Defn 3.3.1. A regular grammar is a grammar in which each rule has one of the following forms, where A, B V and a (i) A a (ii) A ab (iii) A A language is regular if it can be generated by a regular grammar Regular grammars generate precisely the languages defined by regular expressions Regular expressions are used to abbreviate the descriptions of regular sets 4

3.3 Regular Grammars Example. Given G = (V,, P, S), where P = { S xx X yy Y xx Y } (xy) + Example. Let G = (V,, P, S), where P = { S aa A aa bb B ab bc C ac } a + ba*ba* Other examples: Examples 3.29, 3.2.10, 3.2.11, 3.2.12 5

6.2 Expression Graphs Claim(2). Every language accepted by a FSA is regular by constructing a RE Defn. 6.2.1 An expression graph is a labeled digraph in which arcs are labeled by regular expressions. Paths in expression graphs generate regular expressions Algorithm 6.2.2 Construction of a regular expression from a FSA Produce an arbitrary expression graph by repeatedly removing nodes from the state diagram. Produce the language of the FSA by the union of the sets of strings whose processing successfully terminates in one of the accepting states Case 1.2.1 (i) j w j,i i w i,k k j w j,i w i,k k w i,i (ii) j w j,i w i,k w j,i (w i,i )*w i,k i k j k 6

6.2 Expression Graphs Note. If there are multiple final states in the given FSA M, then for each accepting state F, we produce an expression for the strings accepted by F. The language accepted by M is the union of the regular expressions. 7

6.2 Expression Graphs 6.2.2 cc cc j i k j i k 8

6.2 Expression Graphs j = k i There is no such i that is neither the start state nor a final state 9

6.3 Regular Grammars and FA Given a regular grammar G, there exists a NFA M such that L(G) = L(M) Theorem. 6.3.1 Let G = (V,, P, S) be a regular grammar. Define the NFA M = (Q,,, S, F) as follows: a) V { Z }, where Z V, if P contains a rule A a Q = V O.W. b) (A, a) = B whenever A ab P (A, a) = Z whenever A a P c) { A A P } { Z }, if Z Q F = { A A P } O.W. Then L(M) = L(G) 10

6.3 Regular Grammars and FA Example 6.3.1 Given G = (V,, P, S), where V = { S, B }, = { a, b }, and P = { S as bb a, B bb }, the corresponding NFA M = (Q,,, S, F), where Q = { S, B, Z }, = { a, b }, (S, a) = S, (S, b) = B, (S, a) = Z, (B, b) = B, F = { B, Z } Theorem 6.3.2 Given an NFA M, there exists a regular grammar G.. L(M) = L(G). (i) V = Q (ii) The transition (A, a) = B yields the rule A ab in G (iii) For each accepting state C, create the rule C in G Example 6.3.4 P: S bb, S aa; A as, A bc; B bs, B ac, B ; C ba, C ab; 11

6.4 Regular Languages A language over an alphabet is regular if it can be i) specified as a regular set/expression over ii) accepted by DFA / NFA / NFA- iii) generated by a regular grammar Regular languages are closed under,, *,, and since applying any of these operations to regular languages produces a regular language. Theorems 6.4.1, 6.4.2, 6.4.3 Let L 1 and L 2 be two regular languages. Then L 1 L 2, L 1 L 2, L 1 *, L, and L 1 L 2 are regular languages. Example 6.4.1 (a b)*aa(a b)* (a b)*bb(a b)* is regular 12

6.5 A Nonregular Language The language { a i b i 0 i n } is regular, but the language { a i b i i 0 } is not. Proof. a a a a a > 0 1 a 2... a a a n-1 a n b b b b b 0 b b 1 b... b b n-2 b b n-1 However, this technique cannot be extended to accept the language { a i b i i 0 } since an infinite number of states are needed. Theorem 6.5.1 (P. 204). The language { a i b i i 0 } is not regular (see a sketched proof in Example 6.6.3). 13

6.5 A Nonregular Language Corollary 6.5.2 (Proof of Theorem 6.5.1) Let L be a language over. If U i * and V i *, i 0,.. U i V i L and U i V j L, i j, then L is not regular, i.e., a language that generates strings with equal length of two distinct substrings is not regular. Example 6.5.1 The set of palindromes over { a, b } is not regular. Example 6.5.2 Regular grammars are not a sufficiently powerful tool to define programming languages containing nesting of parentheses. Example 6.5.3 The language L = { a i b j i, j 0 and i j } is not regular; otherwise, L, i.e., { a i b i i 0 }, is regular. 14

6.6 The Pumping Lemma for Regular Languages The pumping lemma can be used to show a language is nonregular. Pumping a string refers to constructing new strings by repeating/pumping substrings in the original string. Processing a substring of a string in a DFA M correspond to generating a path in the state diagram of M. The proofs of nonregular languages using pumping lemma adopts a simple counting argument known as the pigeonhole principle. Lemma 6.6.1 Let G be the state diagram of a DFA with k states. Any path of length k in G contains a cycle. Proof: A path P of length k contains k+1 nodes (states). Since there are only k nodes in G, one of the nodes, q, must occurs in P at least twice. The subpath from the first q to the second q yields a cycle. 15

The portion of a transition that accepts both x k y k and x k+n y k a. The path traversed when accepting x k y k b. The path traversed when accepting x k+n y k, where n is the length of the cycle 16

6.6 The Pumping Lemma for Regular Languages Corollary 6.6.2. Let G be the state diagram of a DFA with k states, and let p be a path of length k or more. The path p can be decomposed into sub paths (some of them can be empty) q, r, & s, where p = qrs, qr k & r is a cycle. Theorem 6.6.3 (Pumping Lemma for Regular Languages) Let L be a regular language that is accepted by a DFA M with k states. Let Z L with Z k, and let Z = uvw such that uv k, v > 0, and uv i w L, i 0 Example 6.6.3. Show that L = {a i b i i 0} is nonregular. Assume that L is regular accepted by a DFA M with k states. Let Z L with Z k > 0 & Z = a k b k such that u = a i, v = a j, and w = a k-i-j b k Pumping v twice yields the string uv 2 w = a i a j a j a k-i-j b k = a k a j b k L, since k + j > k. 17