Lecture 3: Closure Properties & Regular Expressions Jim Hook Tim Sheard Portland State University.

Slides:



Advertisements
Similar presentations
CS2303-THEORY OF COMPUTATION Closure Properties of Regular Languages
Advertisements

Nondeterministic Finite Automata CS 130: Theory of Computation HMU textbook, Chapter 2 (Sec 2.3 & 2.5)
FORMAL LANGUAGES, AUTOMATA, AND COMPUTABILITY
Introduction to Computability Theory
1 Introduction to Computability Theory Lecture3: Regular Expressions Prof. Amos Israeli.
1 Introduction to Computability Theory Lecture2: Non Deterministic Finite Automata Prof. Amos Israeli.
1 Introduction to Computability Theory Lecture4: Regular Expressions Prof. Amos Israeli.
1 Introduction to Computability Theory Lecture3: Regular Expressions Prof. Amos Israeli.
Lecture 3UofH - COSC Dr. Verma 1 COSC 3340: Introduction to Theory of Computation University of Houston Dr. Verma Lecture 3.
Automata and Formal Languages Tim Sheard 1 Lecture 8 Pumping Lemma & Distinguishability Jim Hook Tim Sheard Portland State University.
1 FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY (For next time: Read Chapter 1.3 of the book)
Costas Busch - RPI1 Single Final State for NFAs. Costas Busch - RPI2 Any NFA can be converted to an equivalent NFA with a single final state.
Fall 2006Costas Busch - RPI1 Regular Expressions.
1 Introduction to Computability Theory Lecture2: Non Deterministic Finite Automata (cont.) Prof. Amos Israeli.
CS 310 – Fall 2006 Pacific University CS310 Pumping Lemma Sections:1.4 page 77 September 27, 2006.
1 Regular Expressions. 2 Regular expressions describe regular languages Example: describes the language.
CSC 3130: Automata theory and formal languages Andrej Bogdanov The Chinese University of Hong Kong Regular.
Fall 2004COMP 3351 Single Final State for NFA. Fall 2004COMP 3352 Any NFA can be converted to an equivalent NFA with a single final state.
1 Single Final State for NFAs and DFAs. 2 Observation Any Finite Automaton (NFA or DFA) can be converted to an equivalent NFA with a single final state.
Lecture 7 Sept 22, 2011 Goals: closure properties regular expressions.
CS5371 Theory of Computation Lecture 6: Automata Theory IV (Regular Expression = NFA = DFA)
Courtesy Costas Busch - RPI1 Non-regular languages.
CS5371 Theory of Computation Lecture 4: Automata Theory II (DFA = NFA, Regular Language)
FSA Lecture 1 Finite State Machines. Creating a Automaton  Given a language L over an alphabet , design a deterministic finite automaton (DFA) M such.
Lecture 5UofH - COSC Dr. Verma 1 COSC 3340: Introduction to Theory of Computation University of Houston Dr. Verma Lecture 5.
Lecture 4UofH - COSC Dr. Verma 1 COSC 3340: Introduction to Theory of Computation University of Houston Dr. Verma Lecture 4.
Today Chapter 1: RE = Regular Languages, nonregular languages RL pumping lemma Chapter 2: Context-Free Languages (CFLs)
FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY
1 A Single Final State for Finite Accepters. 2 Observation Any Finite Accepter (NFA or DFA) can be converted to an equivalent NFA with a single final.
Fall 2004COMP 3351 Regular Expressions. Fall 2004COMP 3352 Regular Expressions Regular expressions describe regular languages Example: describes the language.
Regular Languages A language is regular over  if it can be built from ;, {  }, and { a } for every a 2 , using operators union ( [ ), concatenation.
CSC 3130: Automata theory and formal languages Andrej Bogdanov The Chinese University of Hong Kong DFA to regular.
Nondeterministic Finite Automata CS 130: Theory of Computation HMU textbook, Chapter 2 (Sec 2.3 & 2.5)
1Computer Sciences Department. Book: INTRODUCTION TO THE THEORY OF COMPUTATION, SECOND EDITION, by: MICHAEL SIPSER Reference 3Computer Sciences Department.
Theory of Languages and Automata
Theory of Computation, Feodor F. Dragan, Kent State University 1 Regular expressions: definition An algebraic equivalent to finite automata. We can build.
Kleene’s Theorem Group No. 3 Presented To Mam Amina Presented By Roll No Roll No Roll No Roll No Group No. 3 Presented To Mam.
CHAPTER 1 Regular Languages
January 9, 2015CS21 Lecture 31 CS21 Decidability and Tractability Lecture 3 January 9, 2015.
Lecture # 12. Nondeterministic Finite Automaton (NFA) Definition: An NFA is a TG with a unique start state and a property of having single letter as label.
CSCI 2670 Introduction to Theory of Computing September 13.
CS 203: Introduction to Formal Languages and Automata
Regular Expressions Costas Busch - LSU.
CSCI 3130: Formal languages and automata theory Tutorial 3 Chin.
Donghyun (David) Kim Department of Mathematics and Physics North Carolina Central University 1 Chapter 1 Regular Languages Some slides are in courtesy.
Recap: Transformation NFA  DFA  s s1s1... snsn p1p1 p2p2... pmpm >...  p1p1  p2p2  pipi s e s1s1 e s2s2 e sisi >
CSCI 4325 / 6339 Theory of Computation Zhixiang Chen.
Equivalence with FA * Any Regex can be converted to FA and vice versa, because: * Regex and FA are equivalent in their descriptive power ** Regular language.
Conversions Regular Expression to FA FA to Regular Expression.
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:
 2004 SDU Lecture4 Regular Expressions.  2004 SDU 2 Regular expressions A third way to view regular languages. Say that R is a regular expression if.
1 Introduction to the Theory of Computation Regular Expressions.
Regular Languages Chapter 1 Giorgi Japaridze Theory of Computability.
Lecture 09: Theory of Automata:2014 Asif NawazUIIT, PMAS-Arid Agriclture University Rawalpindi. Kleene’s Theorem and NFA.
Kleene’s Theorem and NFA
Foundations of Computing Science
PROPERTIES OF REGULAR LANGUAGES
Single Final State for NFA
REGULAR LANGUAGES AND REGULAR GRAMMARS
CS 154, Lecture 3: DFANFA, Regular Expressions.
COSC 3340: Introduction to Theory of Computation
CSE322 CONSTRUCTION OF FINITE AUTOMATA EQUIVALENT TO REGULAR EXPRESSION Lecture #9.
CS21 Decidability and Tractability
Closure Properties of Regular Languages
Chapter 1 Regular Language - 02
CS21 Decidability and Tractability
Chapter 1 Regular Language
CSC312 Automata Theory Kleene’s Theorem Lecture # 12
Presentation transcript:

Lecture 3: Closure Properties & Regular Expressions Jim Hook Tim Sheard Portland State University

Last Time Defined DFA, regular languages Defined NFA, showed equivalent to DFA Showed closure properties of Regular Languages

Why do we care about closure properties? One course objective is to “map the world” Closure properties tell us how to build new regular languages from old Regular Languages  

Can properties define a Class of Languages? What is the smallest class of languages: That contains the empty language the universal language every singleton character of the alphabet And is closed under union concatenation iteration (Kleene star)

Regular languages? Can the regular languages from last lecture be this smallest class? Since they meet the requirements they must at least contain this smallest class –Discuss How can we tell if there are regular languages not in this class?

Regular expressions Kleene introduced regular expressions (REGEXP) to name the languages in this “smallest class” –a is a REGEXP for every a in  –  is a REGEXP –  is a REGEXP –if R 1 and R 2 are REGEXPs then the following are REGEXPs R 1 + R 2 R 1 R 2 R 1 *

Regular expressions and Regular Languages Thm [1.54] A language is regular iff it is described by a regular expression Lemma [1.55] If a language is descried by a regular expression then it is regular Proof sketch: –For each REGEXP we must show that a corresponding NFA can be constructed –We’ve done the hard work by proving the closure properties –We just have to complete the base cases for {a}, {  }, and .

Regular expressions and Regular Languages More interesting: can we convert a DFA M into a regular expression? Lemma [1.60] If a language is regular then it is described by a regular expression –How do we prove this? –Can we calculate a REGEXP from a DFA?

DFA -> REGEXP One construction: –Draw a graph labeled essentially like the DFA –Find a way to remove states from the DFA systematically, replacing labels with regular expressions –Set things up so that when we are done the resulting regular expression describes the language accepted by the DFA

Generalized NFAs Generalize an NFA to have regular expressions labeling transitions Goal is to simplify an automaton to: Helpful to have single start and final state R

Simplification (remove q rip ) qiqi qjqj q rip R4R4 R1R1 R2R2 R3R3 qiqi qjqj R 1 (R 2 * )R 3 + R 4

Initial Construction start accept DFA    Complete the transition relation by adding 1.epsilon transitions from start to all initial DFA states, and from all DFA final states to accept. 2.null transitions between all unlabeled DFA states,

Example (DFA) 1 0 a,b

Example (GNFA) 1 0 a,b start accept        0 Complete the transition relation by adding epsilon transitions from start to all initial DFA states, and from all DFA final states to accept. null transitions between all unlabeled DFA states,

As Table 1 0 a,b start accept        0 01 start   0  a+b  1 

Cut 1 (w.r.t all pairs) 01accept start   0  a+b  1  0accept start  +   * (a+b)  +   *  0  +(a+b)  * (a+b)  +(a+b)  *  1 0 a,b start accept        0

Simplifying 0accept start  +   * (a+b)  +   *  0  +(a+b)  * (a+b)  +(a+b)  *  0accept start   0 (a+b)(a+b) 

Cut 0 and simplify 0accept start   0 (a+b)(a+b)  accept start  +  ( (a+b)(a+b)) *  accept start( (a+b)(a+b)) *

Example (conclusion) ( (a+b)(a+b)) * 1 0 a,b

Proof Sketch Formalize GNFA –adjust delta to give REGEXP –define acceptance for GNFA this will give a sequence of states visited on acceptance Show “ripping a state” preserves language accepted –Let G’ be obtained from G by ripping q rip –Show: w  L(G’) => w  L(G) –Show: w  L(G) => w  L(G’)

Proof Sketch (cont) Let G’ be obtained from G by ripping q rip Show: w  L(G’) => w  L(G) –w  L(G’) implies there is a sequence of states: q start, q 1, …, q accept and substrings w 1, w 2, …, w n satisfying the acceptance conditions –Look at each w i, either w i comes from an “R4” rule, or w i comes from an R1 R2* R3 rule –If w i comes from an R4 rule then G can make a corresponding step –If w i comes from an R1 R2* R3 rule, then w i is of the form y 1 … y m, where y 1  R1, y i  R2 (1<I<m) y m  R3 –In this case G transitions from q i -1 to q i with m-2 intermediate instances of q rip on input w i = y 1 … y m

Proof Sketch (cont) Let G’ be obtained from G by ripping q rip Show: w  L(G) => w  L(G’) w  L(G) impiles there are states q start, q 1, …, q accept and strings w 1, …, w n satisfying conditions of acceptance Cases: –q rip not used in computation: w clearly in L(G’) (use only R4 rules) –q rip is used: every occurrence of q rip is in a context of the form: –q i q rip q rip … q rip q j, in which there is one or more occurrences of q rip between non rip states i and j. –In this case »w i+1 will be an “R1” string »w I+2, …, w j-1 will be “R2” strings (there may be 0 of these) »w j will be an “R3” string

Proof Sketch (cont) Let G’ be obtained from G by ripping q_rip Show: w  L(G) => w  L(G’) Cases: –q rip is used: every occurrence of q rip is in a context of the form: –q i q rip q rip … q rip q j, in which there is one or more occurrences of q rip between non rip states i and j. –In this case »w i+1 will be an “R1” string »w I+2, …, w j-1 will be “R2” strings (there may be 0 of these) »w j will be an “R3” string –Consequently, G’ will transition from q i to q j on w i+1 … w j by an R1 R2* R3 transition

Next time Non-regular languages (pumping lemma)