Chapter 6 Properties of Regular Languages. 2 Regular Sets and Languages  Claim(1). The family of languages accepted by FSAs consists of precisely the.

Slides:



Advertisements
Similar presentations
The Pumping Lemma for CFL’s
Advertisements

Properties of Regular Languages
Theory Of Automata By Dr. MM Alam
CSCI 2670 Introduction to Theory of Computing September 13, 2005.
Nonregular languages Sipser 1.4 (pages 77-82). CS 311 Mount Holyoke College 2 Nonregular languages? We now know: –Regular languages may be specified either.
Nonregular languages Sipser 1.4 (pages 77-82). CS 311 Fall Nonregular languages? We now know: –Regular languages may be specified either by regular.
1 Regular Expressions Highlights: –A regular expression is used to specify a language, and it does so precisely. –Regular expressions are very intuitive.
CS 302: Discrete Math II A Review. An alphabet Σ is a finite set (e.g., Σ = {0,1}) A string over Σ is a finite-length sequence of elements of Σ For x.
1 Regular Expressions. 2 Regular expressions describe regular languages Example: describes the language.
Costas Busch - RPI1 Standard Representations of Regular Languages Regular Languages DFAs NFAs Regular Expressions Regular Grammars.
79 Regular Expression Regular expressions over an alphabet  are defined recursively as follows. (1) Ø, which denotes the empty set, is a regular expression.
Courtesy Costas Busch - RPI1 Non-regular languages.
Fall 2004COMP 3351 Standard Representations of Regular Languages Regular Languages DFAs NFAs Regular Expressions Regular Grammars.
Lecture 8 Sept 29, 2011 Regular expressions – examples Converting DFA to regular expression. (same works for NFA to r.e. conversion.) Converting R.E. to.
FSA Lecture 1 Finite State Machines. Creating a Automaton  Given a language L over an alphabet , design a deterministic finite automaton (DFA) M such.
1 Background Information for the Pumping Lemma for Context-Free Languages Definition: Let G = (V, T, P, S) be a CFL. If every production in P is of the.
Context-Free Grammars Chapter 3. 2 Context-Free Grammars and Languages n Defn A context-free grammar is a quadruple (V, , P, S), where  V is.
Cs466(Prasad)L14Equiv1 Equivalence of Regular Language Representations.
Prof. Busch - LSU1 Non-regular languages (Pumping Lemma)
INHERENT LIMITATIONS OF COMPUTER PROGAMS CSci 4011.
Regular Languages A language is regular over  if it can be built from ;, {  }, and { a } for every a 2 , using operators union ( [ ), concatenation.
Formal Language Finite set of alphabets Σ: e.g., {0, 1}, {a, b, c}, { ‘{‘, ‘}’ } Language L is a subset of strings on Σ, e.g., {00, 110, 01} a finite language,
Chapter 2 Languages.
Chapter 7 PDA and CFLs.
1 CDT314 FABER Formal Languages, Automata and Models of Computation Lecture 5 School of Innovation, Design and Engineering Mälardalen University 2012.
Tutorial CSC3130 : Formal Languages and Automata Theory Haifeng Wan ( )
1 Regular Expressions. 2 Regular expressions describe regular languages Example: describes the language.
Regular Grammars Chapter 7. Regular Grammars A regular grammar G is a quadruple (V, , R, S), where: ● V is the rule alphabet, which contains nonterminals.
Regular Grammars Chapter 7 1. Regular Grammars A regular grammar G is a quadruple (V, , R, S), where: ● V is the rule alphabet, which contains nonterminals.
TK PrasadPumping Lemma1 Nonregularity Proofs. TK PrasadPumping Lemma2 Grand Unification Regular Languages: Grand Unification (Parallel Simulation) (Rabin.
Regular Expressions and Languages A regular expression is a notation to represent languages, i.e. a set of strings, where the set is either finite or contains.
CHAPTER 1 Regular Languages
Chapter 4 Pumping Lemma Properties of Regular Languages Decidable questions on Regular Languages.
CS 3240 – Chapter 4.  Closure Properties  Algorithms for Elementary Questions:  Is a given word, w, in L?  Is L empty, finite or infinite?  Are L.
Class Discussion Can you draw a DFA that accepts the language {a k b k | k = 0,1,2,…} over the alphabet  ={a,b}?
1 A well-parenthesized string is a string with the same number of (‘s as )’s which has the property that every prefix of the string has at least as many.
Properties of Regular Languages
CS 3813: Introduction to Formal Languages and Automata
CSCI 2670 Introduction to Theory of Computing September 13.
CS 203: Introduction to Formal Languages and Automata
Chapter 3 Regular Expressions, Nondeterminism, and Kleene’s Theorem Copyright © 2011 The McGraw-Hill Companies, Inc. Permission required for reproduction.
Lecture 8 Context-Free Grammar- Cont.
Grammars A grammar is a 4-tuple G = (V, T, P, S) where 1)V is a set of nonterminal symbols (also called variables or syntactic categories) 2)T is a finite.
Chapter 8 Properties of Context-free Languages These class notes are based on material from our textbook, An Introduction to Formal Languages and Automata,
Transparency No. 2-1 Formal Language and Automata Theory Homework 2.
Algorithms for hard problems Automata and tree automata Juris Viksna, 2015.
CSCI 4325 / 6339 Theory of Computation Zhixiang Chen Department of Computer Science University of Texas-Pan American.
Chapter 5 Finite Automata Finite State Automata n Capable of recognizing numerous symbol patterns, the class of regular languages n Suitable for.
CSCI 4325 / 6339 Theory of Computation Zhixiang Chen.
1 A well-parenthesized string is a string with the same number of (‘s as )’s which has the property that every prefix of the string has at least as many.
1 Chapter 3 Regular Languages.  2 3.1: Regular Expressions (1)   Regular Expression (RE):   E is a regular expression over  if E is one of:
Regular Languages Chapter 1 Giorgi Japaridze Theory of Computability.
1 Advanced Theory of Computation Finite Automata with output Pumping Lemma Theorem.
Nonregular Languages Section 2.4 Wed, Oct 5, 2005.
Standard Representations of Regular Languages
PROPERTIES OF REGULAR LANGUAGES
Chapter 2 Finite Automata
CSE 3813 Introduction to Formal Languages and Automata
Nonregular Languages Section 2.4 Wed, Oct 5, 2005.
REGULAR LANGUAGES AND REGULAR GRAMMARS
Properties of Regular Languages
Infiniteness Test The Pumping Lemma Nonregular Languages
Chapter 7 Regular Grammars
Definition: Let G = (V, T, P, S) be a CFL
CHAPTER 2 Context-Free Languages
Properties of Regular Languages
Elementary Questions about Regular Languages
Properties of Context-Free Languages
Chapter 4 Properties of Regular Languages
The Pumping Lemma for CFL’s
Presentation transcript:

Chapter 6 Properties of Regular Languages

2 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) : c)  a   :  Defn (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) q0q0 qfqf q0q0 qfqf a q0q0 qfqf q0q0 or

3 Regular Sets and Languages  Let M 1 and M 2 be two FSAs, and let S m 1, F m 1, S m 2, and F m 1, 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 b) L(M 1 )  L(M 2 ): a string is processed by the composite machine sequentially c) L(M 1 )* Sm2Sm2 Fm2Fm2 M1M1 M2M2 SF Sm1Sm1 Fm1Fm1 M1M1 M2M2 Sm1Sm1 Sm2Sm2 Fm1Fm1 Fm2Fm2 M1M1 Sm1Sm1 Fm1Fm1 FS

4 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 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

5 3.3 Regular Grammars n Example. Given G = (V, , P, S), where P = { S  xX X  yY Y  xX Y  }  (xy) + n Example. Let G = (V, , P, S), where P = { S  aA A  aA | bB B  aB | bC C  aC | }  a + ba*ba* n Other examples: Examples 3.29, , ,

6 6.2 Expression Graphs  Claim(2 ). Every language accepted by a FSA is regular by constructing a RE  Defn An expression graph is a labeled digraph in which arcs are labeled by regular expressions.  Paths in expression graphs generate regular expressions  Algorithm Construction of 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 (i) (ii) wj,i wi,kwj,i wi,k k ij j k wj,iwj,i wi,kwi,k wi,iwi,i k j k j i wj,iwj,i wi,kwi,k w j,i (w i,i )*w i,k

7 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.

8 6.2 Expression Graphs j k i i cc

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

Regular Grammars and FA n Given a regular grammar G, there exists a NFA M such that L(G) = L(M) n Theorem 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 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 { A | A   P } O.W. Then L(M) = L(G) Q = F =F =

Regular Grammars and FA n Example 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 } n Theorem 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 n Example P: S  bB, S  aA; A  aS, A  bC; B  bS, B  aC, B  ; C  bA, C  aB;

Regular Languages n 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 n Regular languages are closed under , , *, ¯, and  since applying any of these operations to regular languages produces a regular language. n Theorems 6.4.1, 6.4.2,  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. n Example (a  b)*aa(a  b)*  (a  b)*bb(a  b)* is regular

A Nonregular Language n The language { a i b i | 0  i  n } is regular, but the language { a i b i | i  0 } is not. Proof. n Theorem (P. 204). The language { a i b i | i  0 } is not regular (see a sketched proof in Example 6.6.3). a1a1 > a2a2 a0a0 aaa... a a n-1 a anan b b1b1 bb b b b n-1 b n-2 bb... b0b0 b However, this technique cannot be extended to accept the language { a i b i | i  0 } since an infinite number of states are needed.

A Nonregular Language n Corollary (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. n Example The set of palindromes over { a, b } is not regular. n Example Regular grammars are not a sufficiently powerful tool to define programming languages containing nesting of parentheses. n Example 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.

The Pumping Lemma for Regular Languages n The pumping lemma can be used to show a language is nonregular. n Pumping a string refers to constructing new strings by repeating/pumping substrings in the original string. n Processing a substring of a string in a DFA M correspond to generating a path in the state diagram of M. n The proofs of nonregular languages using pumping lemma adopts a simple counting argument known as the pigeonhole principle. n Lemma 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.

16 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

The Pumping Lemma for Regular Languages n Corollary 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. n Theorem (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 n Example 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.