Regular Expression (EXTRA)

Slides:



Advertisements
Similar presentations
Chapter 2 Revision of Mathematical Notations and Techniques
Advertisements

Properties of Regular Sets
Recognising Languages We will tackle the problem of defining languages by considering how we could recognise them. Problem: Is there a method of recognising.
Completeness and Expressiveness
Theory of Computing Lecture 23 MAS 714 Hartmut Klauck.
Equivalence Relations
Lecture 9,10 Theory of AUTOMATA
Summary Showing regular Showing non-regular construct DFA, NFA
3.2 Pumping Lemma for Regular Languages Given a language L, how do we know whether it is regular or not? If we can construct an FA to accept the language.
Relations.
Representing Relations Using Matrices
Applied Discrete Mathematics Week 11: Graphs
CS21 Decidability and Tractability
1 Introduction to Computability Theory Lecture3: Regular Expressions Prof. Amos Israeli.
Automata and Formal Languages Tim Sheard 1 Lecture 8 Pumping Lemma & Distinguishability Jim Hook Tim Sheard Portland State University.
1 Lecture 22 Myhill-Nerode Theorem –distinguishability –equivalence classes of strings –designing FSA’s –proving a language L is not regular.
Transparency No Formal Language and Automata Theory Chapter 10 The Myhill-Nerode Theorem (lecture 15,16 and B)
Transparency No. 4-1 Formal Language and Automata Theory Chapter 4 Patterns, Regular Expressions and Finite Automata (include lecture 7,8,9) Transparency.
1 Minimization; Pumping Lemma. October 2, Agenda Minimization Algorithm Guarantees smallest possible DFA for a given regular language Proof of.
Transparency No Formal Language and Automata Theory Chapter 10 The Myhill-Nerode Theorem (lecture 15,16 and B)
1 More Applications of the Pumping Lemma. 2 The Pumping Lemma: Given a infinite regular language there exists an integer for any string with length we.
Fall 2004COMP 3351 Standard Representations of Regular Languages Regular Languages DFAs NFAs Regular Expressions Regular Grammars.
CS5371 Theory of Computation Lecture 4: Automata Theory II (DFA = NFA, Regular Language)
Equivalence Relations: Selected Exercises
1 Non-regular languages. 2 Regular languages Non-regular languages.
1 FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY For next time: Read 2.1 & 2.2.
1 Module 24 Myhill-Nerode Theorem –distinguishability –equivalence classes of strings –designing FSA’s –proving a language L is not regular.
Transparency No. 8-1 Formal Language and Automata Theory Chapter 8 DFA state minimization (lecture 13, 14)
Relations Chapter 9.
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,
Extra on Regular Languages and Non-Regular Languages
CS 461 – Sept. 12 Simplifying FA’s. –Let’s explore the meaning of “state”. After all if we need to simplify, this means we have too many states. –Myhill-Nerode.
Introduction to CS Theory Lecture 3 – Regular Languages Piotr Faliszewski
Chapter 9. Chapter Summary Relations and Their Properties n-ary Relations and Their Applications (not currently included in overheads) Representing Relations.
MYHILL NERODE THEOREM By Anusha Tilkam. Myhill Nerode Theorem: The following three statements are equivalent 1.The set L є ∑* is accepted by a FSA 2.L.
Discrete Math for CS Binary Relation: A binary relation between sets A and B is a subset of the Cartesian Product A x B. If A = B we say that the relation.
2.6 Equivalence Relation §1.Equivalence relation §Definition 2.18: A relation R on a set A is called an equivalence relation if it is reflexive, symmetric,
Introduction to CS Theory
Decidable Questions About Regular languages 1)Membership problem: “Given a specification of known type and a string w, is w in the language specified?”
1 Recap lecture 27 Pumping lemma version II, proof, examples, Myhill Nerode theorem, examples.
Chapter 9. Chapter Summary Relations and Their Properties n-ary Relations and Their Applications (not currently included in overheads) Representing Relations.
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.
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.
MA/CSSE 474 Theory of Computation Minimizing DFSMs.
8.4 Closures of Relations Definition: The closure of a relation R with respect to property P is the relation obtained by adding the minimum number of.
Copyright © Cengage Learning. All rights reserved. CHAPTER 8 RELATIONS.
RelationsCSCE 235, Spring Introduction A relation between elements of two sets is a subset of their Cartesian products (set of all ordered pairs.
1 Equivalence relations Binary relations: –Let S1 and S2 be two sets, and R be a (binary relation) from S1 to S2 –Not every x in S1 and y in S2 have such.
Chap. 7 Relations: The Second Time Around
FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY TexPoint fonts used in EMF. Read the TexPoint manual before you delete this box.: AA.
Algorithms for hard problems Automata and tree automata Juris Viksna, 2015.
Binary Relations Definition: A binary relation R from a set A to a set B is a subset R ⊆ A × B. Example: Let A = { 0, 1,2 } and B = {a,b} {( 0, a), (
Regular Languages Chapter 1 Giorgi Japaridze Theory of Computability.
Chapter 2 1. Chapter Summary Sets (This Slide) The Language of Sets - Sec 2.1 – Lecture 8 Set Operations and Set Identities - Sec 2.2 – Lecture 9 Functions.
Section 9.1. Section Summary Relations and Functions Properties of Relations Reflexive Relations Symmetric and Antisymmetric Relations Transitive Relations.
Regular Expression (EXTRA)
Relations Chapter 9 Copyright © McGraw-Hill Education. All rights reserved. No reproduction or distribution without the prior written consent of McGraw-Hill.
Standard Representations of Regular Languages
CSE322 PUMPING LEMMA FOR REGULAR SETS AND ITS APPLICATIONS
CSE 3813 Introduction to Formal Languages and Automata
Chapter 2 Sets and Functions.
Hierarchy of languages
CS 154, Lecture 4: Limitations on DFAs (I),
8.5 Equivalence Relations
MA/CSSE 474 Theory of Computation Minimizing DFSMs.
Recap lecture 26 Example of nonregular language, pumping lemma version I, proof, examples,
9.5 Equivalence Relations
Recap lecture 18 NFA corresponding to union of FAs,example, NFA corresponding to concatenation of FAs,examples, NFA corresponding to closure of an FA,examples.
THEORY OF COMPUTATION 06 NUMBER OF STATES.
Presentation transcript:

Regular Expression (EXTRA) Chap 1 Regular Expression (EXTRA)

Equivalence Relation Def: Assume R is a relation on a set A, that is, R⊆AxA. We write aRb which means (a,b)∈R to indicate that a is related to b via the relation R: R is reflexive if for every a∈A, aRa R is symmetric if for every a and b in A, if aRb, then bRa R is transitive if for every a, b, and c in A, if aRb and bRc, then aRc R is an equivalence relation on A if R is reflexive, symmetric, and transitive

Equivalence Class Suppose R is any equivalence relation on A. For any element a of A, we denote by [a]R , or sometimes simply by [a], the equivalence class containing a, that is, [a]R = {x∈A | xRa}

Thm: For any partition C of a set A, the relation R on A, defined by xRy ⇔ x and y belong to the same element of C, is an equivalence relation on A. Conversely, if R is any equivalence relation on A, the set of equivalence classes is a partition of A, and two elements of A are equivalent ⇔ they are in the same equivalence class.

Distinguishing One String from Another Def: Let L be a language in * Two strings x and y in * are distinguishable with respect to L if there is a string z∈ * (which may depend on x and y) so that exactly one of the strings xz and yz is in L The string z is said to distinguish x and y with respect to L

We may say that x and y are indistinguishable with respect to L if there is no such string z; In other words, if for every z, both xz and yz have the same status---either both in L or both not in L Eg: L={x∈{0,1}* | x ends with 10} the strings 01011 and 100 are distinguishable with respect to L because for z=0, 01011z∈L and 100z∉L. The strings 0 and 100 are indistinguishable with respect to L

Lemma Suppose that L⊆* and M=(Q,  , q0, F,  ) is any FA recognizing L. If x and y are two strings in * for which *(q0,x)=*(q0,y), then x and y are indistinguishable with respect to L

Proof: Let z be any string in * , and consider the two strings xz and yz. *(q0,xz)= *(*(q0,x),z) *(q0,yz)= *(*(q0,y),z) and therefore, by our assumption, *(q0,xz)=*(q0,yz). Since M is assumed to recognize L, these two strings are either both in L or both not in L. Therefore, x and y are indistinguishable with respect to L. ■

Thm Suppose that L⊆* and, for some positive integer n, there are n strings in * , any two of which are distinguishable with respect to L. Then there can be no FA recognizing L with fewer than n states.

Proof: Suppose that x1, x2 , …, xn are n strings, any two of which are distinguishable with respect to L. If M=(Q,  , q0, A,  ) is any FA with fewer than n states, then by the pigeonhole principle, the states *(q0,x1), *(q0,x2), …,*(q0,xn) cannot all be distinct, and so for some i≠j, *(q0,xi) = *(q0,xj). Since xi and xj are distinguishable with respect to L, M cannot recognize L. ■

A Criterion for Regularity Def Let L be any language in * . The relation IL on * (the indistinguishability relation) is defined as follows: For any two strings x,y∈ * , x IL y ⇔ x and y are indistinguishable with respect to L. In other words, x IL y if , for any z ∈ * , either xz and yz are both in L, or xz and yz are both in L’

Lemma For any language L, IL is an equivalence relation on * Proof: It is obvious that IL is reflexive and symmetric. Suppose x IL y and y IL w. We must show that x IL w. Let z be any string in * . If xz ∈L, then yz ∈L, since x IL y, and therefore wz ∈L, since y IL w. Similarly, if xz∉ L, then wz∉ L. Therefore x IL w.

Assume L is a regular language, and FA M=(Q,  , q0, F,  ) recognizes L. If q∈ Q, we let Lq={x∈ *| *(q0,x)=q } If we start with an equivalence class q containing a string x, then (q,a) should be the equivalence class containing xa, that is ([x],a)=[xa]

Lemma: IL is right invariant with respect to concatenation. In other words, for any x,y∈* and any a∈ , if x IL y , then xa IL ya. Equivalently, if [x]=[y], then [xa]=[ya] Proof: Suppose that x IL y and a∈ . For any z’ ∈* , xz' and yz' are either both in L or both not in L. With z'=az, we complete our proof. ■

Thm Let L ⊆ * , and let QL be the set of equivalence classes of the relation IL on * . If QL is a finite set, then ML=(QL,  , q0, FL,  ) is a finite automaton accepting L, where q0=[], FL={q∈QL | q∩L≠∅} and  : QL ×  → QL is defined by the formula ([x],a)=[xa]. Furthermore, ML has the fewest states of any FA accepting L.

Proof: (1) By the previous lemma,  ([x],a)=[xa] is a meaningful definition. To verify that ML recognizes L, need to prove *([x], y)=[xy], for any x, y. By induction, it is clear for y= . Suppose it is true for some y. Consider *([x], ya)=  (*([x], y), a)= ([xy], a) = [xya]. Thus *(q0, x)= *([], x) =[x]. Since FL={q∈QL | q∩L≠∅}, ML accepts x iff [x]∩L≠∅. It is clear that if x∈L, then [x]∩L≠∅. On the other hand, if [x] contains y of L, then x must be in L; otherwise  will distinguish x and y. Therefore, ML accepts L. (2)If there are n equivalence classes of IL, then there are n pair-wise distinguishable strings. By a previous theorem, any FA accepting L has at least n states. ML has exactly n states, it has the fewest possible.

Corollary: (Myhill-Nerode theorem) L is a regular language ⇔ The set of equivalence classes of IL is finite Proof: Follow from the slide9 & 15 ■

Eg: Let L={0n1n|n≥0}. The intuitive reason L is not regular : we must remember how many 0’s we have seen S={0n|n≥0} : infinite set 0i , 0j ∈S, i≠j 0i1i∈L but 0j1i∉ L. ⇒ 1i distinguishes 0i and 0j ⇒ The relation IL has infinitely many distinct equivalence classes and that L is not regular.

Eg: S={0n|n≥0} :infinite set, and L={ww|w∈{0,1}*} is a language. z=1n0n1n is a string. ⇒ 0nz ∈ L , 0mz∉ L ⇒ z distinguishes 0n and 0m

Minimal Finite Automata Eg: Two FAs for {0,1}*{10} and the corresponding partitions of {0,1}* 4 1 2 5 1 1 1 1 1 1 A B C 3 6 1 1 1 7 L1={} L3={1} 1 L2={0} LA LB L5=*{01} L4=*{00} L7=*{11} L6=L=*{10} LC=L

Identifying those pairs (p,q) of states for which Lp and Lq are subsets of different equivalence classes , denote it as p≢q Lemma For p,q∈Q , p≢q ⇔there exists z∈* so that exactly one of the two states *(p,z) and *(q,z) is in F

Algorithm (for identifying the pairs (p,q) with p≢q) 1. List all (unordered) pairs of states (p,q) of which p≠q. 2. Make a sequence of passes through the pairs. 3. On the first pass, mark each pair of which exactly one element is in A. 4. On each subsequent pass, mark any pair (r,s) if there is an a ∈  for which (r,a)=p, (s,a)=q, and (p,q) is already marked 5. After a pass in which no new pairs are marked, stop. The marked pairs (p,q) are precisely those for which p≢q ■

Eg: (cf slide 19) 2 3 2 2 1 2 1 4 p1 p2 p3 1 5 2 2 2 6 1 1 1 1 1 7 2 2 2 1 1 2 3 4 5 6