COSC 3340: Introduction to Theory of Computation

Slides:



Advertisements
Similar presentations
CSC 361NFA vs. DFA1. CSC 361NFA vs. DFA2 NFAs vs. DFAs NFAs can be constructed from DFAs using transitions: Called NFA- Suppose M 1 accepts L 1, M 2 accepts.
Advertisements

Complexity and Computability Theory I Lecture #4 Rina Zviel-Girshin Leah Epstein Winter
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.
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.
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.
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.
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 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.
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:
Lecture 2UofH - COSC Dr. Verma 1 COSC 3340: Introduction to Theory of Computation University of Houston Dr. Verma Lecture 2.
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.
1 CD5560 FABER Formal Languages, Automata and Models of Computation Lecture 3 Mälardalen University 2010.
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
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.
Transparency No. 2-1 Formal Language and Automata Theory Homework 2.
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.
 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.
Lecture 09: Theory of Automata:2014 Asif NawazUIIT, PMAS-Arid Agriclture University Rawalpindi. Kleene’s Theorem and NFA.
Theory of Computation Automata Theory Dr. Ayman Srour.
Theory of Languages and Automata By: Mojtaba Khezrian.
Kleene’s Theorem and NFA
Regular Expressions.
Formal Language & Automata Theory
Chapter 2 Finite Automata
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
COT 4210 Lecture Notes - 3 By Njegos and Monika.
Non-Deterministic Finite Automata
CS 154, Lecture 3: DFANFA, Regular Expressions.
COSC 3340: Introduction to Theory of Computation
Non-Deterministic Finite Automata
COSC 3340: Introduction to Theory of Computation
CS 350 — Fall 2018 gilray.org/classes/fall2018/cs350/
Regular Expressions.
NFAs, DFAs, and regular expressions
CSCI 2670 Introduction to Theory of Computing
CS21 Decidability and Tractability
Chapter 1 Regular Language - 02
Regular Languages ภาษาปกติ.
COSC 3340: Introduction to Theory of Computation
CS21 Decidability and Tractability
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
COSC 3340: Introduction to Theory of Computation
Intro to Theory of Computation
COSC 3340: Introduction to Theory of Computation
Presentation transcript:

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

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 5 UofH - COSC 3340 - Dr. Verma

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 5 UofH - COSC 3340 - Dr. Verma

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 5 UofH - COSC 3340 - Dr. Verma

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 5 UofH - COSC 3340 - Dr. Verma

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 5 UofH - COSC 3340 - Dr. Verma

Regular expressions versus FA's 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 * Lecture 5 UofH - COSC 3340 - Dr. Verma

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

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

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

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

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 5 UofH - COSC 3340 - Dr. Verma

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 5 UofH - COSC 3340 - Dr. Verma

Eliminating state q{rip} qi qj R1 R3 qrip (R1 )(R2)* (R3)  (R4) R2 qi qj Lecture 5 UofH - COSC 3340 - Dr. Verma

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

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

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

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