Lecture 12 Non-Regular Languages

Slides:



Advertisements
Similar presentations
Properties of Regular Sets
Advertisements

Lexical Analysis IV : NFA to DFA DFA Minimization
CSE 311 Foundations of Computing I
LING/C SC/PSYC 438/538 Lecture 11 Sandiway Fong. Administrivia Homework 3 graded.
Regular Expressions and DFAs COP 3402 (Summer 2014)
LING/C SC/PSYC 438/538 Lecture 12 Sandiway Fong. Administrivia We'll postpone Homework 4 review until next week …
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.
The Unix File System. What are the three parts of every file on a Unix filesystem? And where is each stored? Filename - stored in directories Inode -
Lecture 3: Closure Properties & Regular Expressions Jim Hook Tim Sheard Portland State University.
Linux+ Guide to Linux Certification, Second Edition
1 FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY For next time: Read 2.1 & 2.2.
1 CDT314 FABER Formal Languages, Automata and Models of Computation Lecture 5 School of Innovation, Design and Engineering Mälardalen University 2012.
Linux+ Guide to Linux Certification, Third Edition
Week 3 Exploring Linux Filesystems. Objectives  Understand and navigate the Linux directory structure using relative and absolute pathnames  Describe.
Chapter Five Advanced File Processing. 2 Objectives Use the pipe operator to redirect the output of one command to another command Use the grep command.
Decidable Questions About Regular languages 1)Membership problem: “Given a specification of known type and a string w, is w in the language specified?”
Transition Diagrams Lecture 3 Wed, Jan 21, Building Transition Diagrams from Regular Expressions A regular expression consists of symbols a, b,
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.
1 Lecture 9 Shell Programming – Command substitution Regular expressions and grep Use of exit, for loop and expr commands COP 3353 Introduction to UNIX.
CS 203: Introduction to Formal Languages and Automata
Exercise 1 Consider a language with the following tokens and token classes: ID ::= letter (letter|digit)* LT ::= " " shiftL ::= " >" dot ::= "." LP ::=
CSCI 3130: Formal languages and automata theory Tutorial 3 Chin.
Lecture 8 NFA Subset Construction & Epsilon Transitions
1 Find as many examples as you can of w, x, y, z so that w is accepted by this DFA, w = x y z, y ≠ ε, | x y | ≤ 7, and x y n z is in L for all n ≥ 0.
Linux+ Guide to Linux Certification, Second Edition Chapter 4 Exploring Linux Filesystems.
Lecture 25 Undecidability Topics: Recursively Enumerable Languages Recursive languages The halting problem Post Correspondence Problem Problem reductions.
FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY TexPoint fonts used in EMF. Read the TexPoint manual before you delete this box.: AA.
CSE 311 Foundations of Computing I Lecture 24 FSM Limits, Pattern Matching Autumn 2011 CSE 3111.
Jianguo Lu : Lab 3 Jan 30, Winter 2004.
Lecture 10 Closure Properties of Regular Languages Topics: Extended RegExpr Thompson Construction Test 1 Post Mortem October 1, 2008 CSCE 355 Foundations.
CS 403: Programming Languages Lecture 20 Fall 2003 Department of Computer Science University of Alabama Joel Jones.
Lecture 11 Minimization Topics: Strings distinguishing states Equivalence relation October 6, 2008 CSCE 355 Foundations of Computation.
Deterministic Finite-State Machine (or Deterministic Finite Automaton) A DFA is a 5-tuple, (S, Σ, T, s, A), consisting of: S: a finite set of states Σ:
Nonregular Languages Section 2.4 Wed, Oct 5, 2005.
CSE322 PUMPING LEMMA FOR REGULAR SETS AND ITS APPLICATIONS
Properties of Regular Languages
CSCE 355 Foundations of Computation
Lecture 9 Shell Programming – Command substitution
Nonregular Languages Section 2.4 Wed, Oct 5, 2005.
CSE 303 Concepts and Tools for Software Development
Review: NFA Definition NFA is non-deterministic in what sense?
Lecture 10 Closure Properties of Regular Languages
Jaya Krishna, M.Tech, Assistant Professor
CSCE 355 Foundations of Computation
CSE 311 Foundations of Computing I
CS 154, Lecture 4: Limitations on DFAs (I),
Infiniteness Test The Pumping Lemma Nonregular Languages
CS 154, Lecture 3: DFANFA, Regular Expressions.
LING 408/508: Computational Techniques for Linguists
4. Properties of Regular Languages
Non-Deterministic Finite Automata
Transition Diagrams Lecture 3 Fri, Jan 21, 2005.
Minimizing DFA’s By Partitioning.
CSE322 Minimization of finite Automaton & REGULAR LANGUAGES
Closure Properties of Regular Languages
Lecture Closure Properties for Regular Languages
Chapter 1 Regular Language - 02
CSE 303 Concepts and Tools for Software Development
Lecture 6 NFA Subset Construction & Epsilon Transitions
Instructor: Aaron Roth
CSE 311 Foundations of Computing I
Regular Language Equivalence and DFA Minimization
Instructor: Aaron Roth
CSC 4630 Meeting 4 January 29, 2007.
CHAPTER 1 Regular Languages
Lecture 23 Turing Machines II
CSCE 355 Foundations of Computation
THEORY OF COMPUTATION 06 NUMBER OF STATES.
Presentation transcript:

Lecture 12 Non-Regular Languages CSCE 355 Foundations of Computation Lecture 12 Non-Regular Languages Topics: Strings distinguishing states Equivalence relation October 8, 2008

New: Last Time: Readings section 3.1,3.2(skip DFA RE), 3.3 Ruby: Matching in files (file.rb) Review Relations Again Strings distinguishing states Indistinguishable states Indistinguishable is an Equivalence relation Table of inequivalences Partitions New: If L is regular is the Reversal LR regular? Ruby: Matching in files (fileArgv.rb) Unix Shell “regular expressions”

Homework 1. Modify fileArgv.rb to substitute “xxx-xxxx” for every occurrence of phone number in every file in a directory 4.4.2

Unix Shell “regular expressions” Aren’t really regular expressions Examples ls *.rb // * is not the closure operator but wildcard ls [a-d]* grep “[a-d]*” *

Ruby Matching in Files II, fileARGV.rb ARGV.each do |arg| p arg f = File.open(p) f.each do |line| puts line if line =~ /Perl|Python/ puts "Scripting language mentioned:#{line}" end f.close

Command-Line Options -i [extension] Edits ARGV files in place. For each file named in ARGV, anything you write to standard output will be saved back as the contents of that file. A backup copy of the file will be made if extension is supplied. Builtin-Variable $< (or ARGF) - An object that provides access to the concatenation of the contents of all the files given as command-line arguments or $stdin (in the case where there are no arguments).

Strings distinguishing states A string x in Σ* distinguishes two states q1 and q2 if one of δ(q1, x) and δ(q2,x) is a final state and one if not. Examples What string distinguishes q1 and q2 in the DFA? What string distinguishes q3 and q2? Graphically

Indistinguishable states Two states are indistinguishable if there is no string that distinguishes them What if we change the DFA to δ (q1,0) = q3 δ (q1,1) = q1 Then q1 and q2 are not distinguished by any string

Indistinguishable is an Equivalence relation A relation is an Equivalence relation if . Prove Indistinguishable is an Equivalence relation Proof: Let

Figure 4.8 DFA page 156 Consider the DFA Now ε distinguishes C from everything else Table of state inequivalences 1 A B C D E F G H . X 1 A B C D 1 1 1 1 1 E F G H 1

Table of state inequivalences 1 Table of state inequivalences 1 A B C D 1 1 A B C D E F G H . X 1 1 1 E F G H 1 Consider the string “0” Find pairs of states (p,r) with δ(q, 0)is distinguished from δ(r, 0) since δ(D, 0) = C and δ(X, 0) !=C; D is disting. from X = A, B, E, G, H since δ(F, 0) = C and δ(X, 0) !=C; F is disting. from X = A, B, E, G, H Now consider the string “0”

Table of state inequivalences 1 Table of state inequivalences 1 A B C D 1 1 A B C D E F G H . X 1 1 1 E F G H 1 Consider the string “1” Find pairs of states (p,r) with δ(q, 1)is distinguished from δ(r, 1) Is δ(A, 1)=B distinguished from δ(B, 1)=C? Is δ(A, 1)=B distinguished from δ(E, 1)=F? Is δ(A, 1)=B distinguished from δ(F, 1)=G? Is δ(A, 1)=B distinguished from δ(G, 1)=E? … Now consider the string “0”

Table of state inequivalences 1 Table of state inequivalences 1 A B C D 1 1 A B C D E F G H . X 1 1 1 E F G H 1 Do iterations considering both 0 and 1. If for an iteration there is no change then there never will be. So stop. Now consider the string “0”

Partitions Equivalence class of x denoted [x] Π = {X1, X2, … Xn} is a partition of a set S if . If R is an equivalence relation on a set S then R induces a partition on S which means the equivalence classes form a partition

Minimization of DFA First eliminate states not reachable from the start state Partition the states into sets of indistinguishable states (equivalence classes) Figure 4.12 Minimum state DFA equivalent to DFA in figure 4.8 (slide 10)

Strings distinguishable for a Language Two strings y and z are distinguished by a language L if there is a string x such that exactly one of yx and zx is in L Example: L

Consequences for DFA Suppose a DFA D=(Q, Σ, δ, q0, F) has n states and that Language L has than n distinguished prefixes Then L cannot be the language accepted by D, (L(D). Why?

Applications

Not all Languages are regular

Pumping Lemma for regular languages