Lecture 5UofH - COSC 3340 - Dr. Verma 1 COSC 3340: Introduction to Theory of Computation University of Houston Dr. Verma Lecture 5.

Slides:



Advertisements
Similar presentations
Nondeterministic Finite Automata CS 130: Theory of Computation HMU textbook, Chapter 2 (Sec 2.3 & 2.5)
Advertisements

CSE 105 Theory of Computation Alexander Tsiatas Spring 2012 Theory of Computation Lecture Slides by Alexander Tsiatas is licensed under a Creative Commons.
Theory Of Automata By Dr. MM Alam
1 1 CDT314 FABER Formal Languages, Automata and Models of Computation Lecture 3 School of Innovation, Design and Engineering Mälardalen University 2012.
FORMAL LANGUAGES, AUTOMATA, AND COMPUTABILITY
1 Introduction to Computability Theory Lecture3: Regular Expressions 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.
Lecture 15UofH - COSC Dr. Verma 1 COSC 3340: Introduction to Theory of Computation University of Houston Dr. Verma Lecture 15.
1 FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY (For next time: Read Chapter 1.3 of the book)
1 Regular Expressions. 2 Regular expressions describe regular languages Example: describes the language.
Lecture 3: Closure Properties & Regular Expressions Jim Hook Tim Sheard Portland State University.
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.
Introduction to the Theory of Computation John Paxton Montana State University Summer 2003.
CS5371 Theory of Computation Lecture 6: Automata Theory IV (Regular Expression = NFA = DFA)
Lecture 3 Goals: Formal definition of NFA, acceptance of a string by an NFA, computation tree associated with a string. Algorithm to convert an NFA 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.
Lecture 7UofH - COSC Dr. Verma 1 COSC 3340: Introduction to Theory of Computation University of Houston Dr. Verma Lecture 7.
Lecture 9UofH - COSC Dr. Verma 1 COSC 3340: Introduction to Theory of Computation University of Houston Dr. Verma Lecture 9.
1.Defs. a)Finite Automaton: A Finite Automaton ( FA ) has finite set of ‘states’ ( Q={q 0, q 1, q 2, ….. ) and its ‘control’ moves from state to state.
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)
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.
Regular Languages A language is regular over  if it can be built from ;, {  }, and { a } for every a 2 , using operators union ( [ ), concatenation.
Regular Expressions (RE) Empty set Φ A RE denotes the empty set Empty string λ A RE denotes the set {λ} Symbol a A RE denotes the set {a} Alternation M.
UofH - COSC Dr. Verma COSC 3340: Introduction to Theory of Computation Rakesh Verma Computer Science Department University of Houston URL:
Basics of automata theory
Lecture 2UofH - COSC Dr. Verma 1 COSC 3340: Introduction to Theory of Computation University of Houston Dr. Verma Lecture 2.
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.
Introduction to CS Theory Lecture 3 – Regular Languages Piotr Faliszewski
Lecture 10UofH - COSC Dr. Verma 1 COSC 3340: Introduction to Theory of Computation University of Houston Dr. Verma Lecture 10.
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
January 9, 2015CS21 Lecture 31 CS21 Decidability and Tractability Lecture 3 January 9, 2015.
CSCI 2670 Introduction to Theory of Computing September 13.
Lecture 11UofH - COSC Dr. Verma 1 COSC 3340: Introduction to Theory of Computation University of Houston Dr. Verma Lecture 11.
Theory of Computing CSCI 356/541 Lab Session. Outline Lab 1: Finite Automata  Construct and Run Construct and Run  Manipulating Transitions Manipulating.
CS 154 Formal Languages and Computability February 11 Class Meeting Department of Computer Science San Jose State University Spring 2016 Instructor: Ron.
CSCI 4325 / 6339 Theory of Computation Zhixiang Chen.
CS 404Ahmed Ezzat 1 CS 404 Introduction to Compiler Design Lecture 1 Ahmed Ezzat.
 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.
Theory of Computation Automata Theory Dr. Ayman Srour.
Lecture 09: Theory of Automata:2014 Asif NawazUIIT, PMAS-Arid Agriclture University Rawalpindi. Kleene’s Theorem and NFA.
Lecture 8UofH - COSC Dr. Verma 1 COSC 3340: Introduction to Theory of Computation University of Houston Dr. Verma Lecture 8.
Kleene’s Theorem and NFA
Formal Language & Automata Theory
COSC 3340: Introduction to Theory of Computation
Single Final State for NFA
COSC 3340: Introduction to Theory of Computation
COSC 3340: Introduction to Theory of Computation
CS 154, Lecture 3: DFANFA, Regular Expressions.
COSC 3340: Introduction to Theory of Computation
COSC 3340: Introduction to Theory of Computation
CS 350 — Fall 2018 gilray.org/classes/fall2018/cs350/
CSCI 2670 Introduction to Theory of Computing
COSC 3340: Introduction to Theory of Computation
Chapter 1 Regular Language
COSC 3340: Introduction to Theory of Computation
COSC 3340: Introduction to Theory of Computation
COSC 3340: Introduction to Theory of Computation
Intro to Theory of Computation
COSC 3340: Introduction to Theory of Computation
COSC 3340: Introduction to Theory of Computation
Presentation transcript:

Lecture 5UofH - COSC Dr. Verma 1 COSC 3340: Introduction to Theory of Computation University of Houston Dr. Verma Lecture 5

UofH - COSC Dr. Verma 2 Regular expressions A third way to view regular languages. A language generator model instead of language acceptor. Definition of Regular expressions: The smallest class of strings over   {(, ), *, , ,  } that includes: 1.  (basic reg. exp.) 2.  for every  in . (basic reg. exp.) and is closed under , * and 

Lecture 5UofH - COSC Dr. Verma 3 Language generated by a regular expression r Notation: – L(r) denotes language generated by reg. exp. r. L(  ) =  L(  ) = {  } L(    ) = L(  )  L(  ) L(    ) = L(  )L(  ) L(  *) = (L(  ))*

Lecture 5UofH - COSC Dr. Verma 4 Examples of regular expressions Note: We drop parentheses when not required. – Example: (a  b) is written a  b Let  = {a,b} The following are regular expressions: – , a, b –  *, a*, b*, ab, a  b – (a  b)*, a*b*, (ab)* – (a  b)*ab, etc. Are the following regular expressions? –   a, * a, a*b, a *b

Lecture 5UofH - COSC Dr. Verma 5 Some exercises on regular expressions Example: What is L((a  b)*a(a  b)*)? – Ans: {w in {a, b}* | w contains at least one a} Write regular expressions for: 1. {w in {a,b}* | |w| is odd }. 2. {w in {a,b}* | w does not have ab as a substring}. 3. {w in {a,b,c}* | no b in w can come before any c in w}.

Lecture 5UofH - COSC Dr. Verma 6 Tips for Regular Expressions Regular expressions are harder to design for: Languages that have complementation in their definition. Example: Exercise 2 on previous slide. Languages that have intersection in their definition. The reason is that we need to express these operations in terms of ,  and *

Lecture 5UofH - COSC Dr. Verma 7 Regular expressions generate exactly the class of regular languages. Theorem: – (a) For every regular expression there is an equivalent NFA – (b) For every DFA there is an equivalent regular expression. Proof of (a): – For , the NFA is: – For , the NFA is: – For composite regular expressions: use closure under ,  and * Regular expressions versus FA's

Lecture 5UofH - COSC Dr. Verma 8 Parse Tree for (a U b)*  b  b * Uab

Lecture 5UofH - COSC Dr. Verma 9 Example: NFA for (a U b)*b ab aUb

Lecture 5UofH - COSC Dr. Verma 10 Example (contd.) : NFA for (a U b)*b (aUb)*

Lecture 5UofH - COSC Dr. Verma 11 Example (contd.) : NFA for (a U b)*b (a U b)*b

Lecture 5UofH - COSC Dr. Verma 12 DFA  regular expression Easier to do: – DFA  GNFA  regular expression. GNFA (Generalized NFA) – labels of transitions can be regular expressions. Need special GNFA that satisfies: (1) start state has no incoming transition (2) only one final state (3) final state has no outgoing transition.

Lecture 5UofH - COSC Dr. Verma 13 DFA  regular expression (contd.) Idea: – Convert DFA  special GNFA. – Eliminate all states, except start and final state, one state at a time. – Output the label on the single transition left at the end.

Lecture 5UofH - COSC Dr. Verma 14 Eliminating state q {rip} R4R4 R3R3 R1R1 (R 1 )(R 2 )* (R 3 )  (R 4 ) R2R2 qiqi q rip qjqj qiqi qjqj

Lecture 5UofH - COSC Dr. Verma 15 Constructing regular expression. DFA L = {w in {a, b}* | w has odd number of b's }

Lecture 5UofH - COSC Dr. Verma 16 Constructing regular expression (contd.) Added: a new start state and a new final state with empty transitions

Lecture 5UofH - COSC Dr. Verma 17 Constructing regular expression (contd.) q rip We take out the q rip state and it leaves us with a 3 state Finite Automata Before we take out q rip, we have to see all the paths to the q rip state and all possible transitions. Eliminate states one-by-one

Lecture 5UofH - COSC Dr. Verma 18 Constructing regular expression (contd.) q rip We take out the q rip state and we are left with the regular expression