Non-Deterministic Finite Automata

Size: px
Start display at page:

Download "Non-Deterministic Finite Automata"

Transcription

1 Slides modified Yishay Mansour on modification by Benny Chor, based on original slides by Maurice Herlihy, Brown University. p. 8 Non-Deterministic Finite Automata 0,1 0,1 0 0,ε q q 1 q q 4 an NFA may have more than one transition labeled with the same symbol, an NFA may have no transitions labeled with a certain symbol, and an NFA may have transitions labeled with ε, theempty string. Comment: Every DFA is also a non-deterministic finite automata (NFA).

2 Slides modified Yishay Mansour on modification by Benny Chor, based on original slides by Maurice Herlihy, Brown University. p. 9 Non-Deterministic Computation 0,1 0,1 0 0,ε q q 1 q q 4 What happens when more than one transition is possible? the machine splits into multiple copies each branch follows one possibility together, branches follow all possibilities. If the input doesn t appear, that branch dies. Automaton accepts if some branch accepts. What does an ε transition do?

3 Slides modified Yishay Mansour on modification by Benny Chor, based on original slides by Maurice Herlihy, Brown University. p. 10 Non-Deterministic Computation 0,1 0,1 0 0,ε q q q q 4 What happens on string 1001?

4 Slides modified Yishay Mansour on modification by Benny Chor, based on original slides by Maurice Herlihy, Brown University. p. 11 The String ,1 0,1 symbol 1 q 1 0 0,ε q q q q 4 0 q 1 0 q 1 q 2 q 3 1 q q 1 q 2 3 q 3 q q q 1 4 4

5 Slides modified Yishay Mansour on modification by Benny Chor, based on original slides by Maurice Herlihy, Brown University. p. 12 Why Non-Determinism? Theorem (to be proved soon): Deterministic and non-deterministic finite automata accept exactly the same set of languages. Q.: Sowhy do we need them? A.: NFAs are often easier to design than equivalent DFAs. Example: Design a finite automaton that accepts all strings with a 1 in their third-to-the-last position? NFA? DFA?

6 Slides modified Yishay Mansour on modification by Benny Chor, based on original slides by Maurice Herlihy, Brown University. p. 13 Solving with NFA 0,1 1 0,1 q q 1 q 2 3 0,1 q 4 Guesses which symbol is third from the last, and checks that indeed it is a 1. If guess is premature, that branch dies, and no harm occurs.

7 Slides modified Yishay Mansour on modification by Benny Chor, based on original slides by Maurice Herlihy, Brown University. p. 15 Solving with DFA 0 1 0

8 Slides modified Yishay Mansour on modification by Benny Chor, based on original slides by Maurice Herlihy, Brown University. p. 14 Solving with DFA Have 8 states, encoding the last three letters. A state for each string in {0, 1} 3. add transitions on modifying the suffix, give the new letter. Mark as accepting, the strings 1

9 Slides modified Yishay Mansour on modification by Benny Chor, based on original slides by Maurice Herlihy, Brown University. p. 16 NFA Formal Definition Transition function δ is going to be different. Let P(Q) denote the powerset of Q. Let Σ ε denote Σ {ε}. A non-deterministic finite automaton is a 5-tuple (Q, Σ, δ,q 0,F), where Q is a finite set called the states, Σ is a finite set called the alphabet, δ : Q Σ ε P(Q) is the transition function, q 0 Q is the start state, and F Q is the set of accept states.

10 Slides modified Yishay Mansour on modification by Benny Chor, based on original slides by Maurice Herlihy, Brown University. p. 17 Example 0,1 0,1 0 0,ε 1 q q 1 q 2 3 where Q = {q 1,q 2,q 3,q 4 }, Σ = {0, 1}, q 4 N 1 =(Q, Σ, δ,q 1,F) δ is 0 1 ε q 1 {q 1,q 2 } {q 1 } q 2 {q 3 } {q 3 } q 3 {q 4 } q 4 {q 4 } {q 4 } q 1 is the start state, and F = {q 4 }.

11 Slides modified Yishay Mansour on modification by Benny Chor, based on original slides by Maurice Herlihy, Brown University. p. 18 Formal Model of Computation Let M =(Q, Σ, δ,q 0,F) be an NFA, and w be a string over Σ ε that has the form y 1 y 2 y m where y i Σ ε. u be the string over Σ obtained from w by omitting all occurances of ε. Suppose there is a sequence of states (in Q), r 0,...,r n,suchthat r 0 = q 0 r i+1 δ(r i,y i+1 ), 0 i<n r n F Then we say that M accepts u.

12 Slides modified Yishay Mansour on modification by Benny Chor, based on original slides by Maurice Herlihy, Brown University. p. 19 Equivalence of NFA s and DFA s Given an NFA, N, weconstructadfa, M, thataccepts the same language. To begin with, we make things easier by ignoring ε transitions. Make DFA simulate all possible NFA states. As consequence of the construction, if the NFA has k states, the DFA has 2 k states (an exponential blow up).

13 Slides modified Yishay Mansour on modification by Benny Chor, based on original slides by Maurice Herlihy, Brown University. p. 20 Equivalence of NFA s and DFA s Let N =(Q, Σ, δ,q 0,F) be the NFA accepting A. Construct a DFA M =(Q, Σ, δ,q 0,F ). Q = P(Q). For R Q and a Σ, let q 0 = {q 0} δ (R, a) = {q Q q δ(r, a) for some r R} F = {R Q R contains an accept state of N} Notice: F is a set whose elements are subsets of Q, so (as expected) F is a subset of P(Q).

14 Slides modified Yishay Mansour on modification by Benny Chor, based on original slides by Maurice Herlihy, Brown University. p. 21 Equivalence of NFA s and DFA s Extend the transition function to work on words: δ(q, w 1 w n )=δ(δ(q, w 1 w n 1 ),w n ). Define an equivalence between subset of states in the NFA and the states in DFA Inductive Claim: For any word y = y 1 y 2 y m Σ of length m, δ(q 0,y) is equivalent to δ (q 0,y). Proof by induction on m. Base of the induction. Inductive step. Example.

15 Slides modified Yishay Mansour on modification by Benny Chor, based on original slides by Maurice Herlihy, Brown University. p. 22 Example: NFA DFA Non-Deterministic Automata:

16 Slides modified Yishay Mansour on modification by Benny Chor, based on original slides by Maurice Herlihy, Brown University. p. 23 Example: NFA DFA Deterministic Automata - set of states:

17 Slides modified Yishay Mansour on modification by Benny Chor, based on original slides by Maurice Herlihy, Brown University. p. 24 Example: NFA DFA Deterministic Automata - transitions from q 0 :

18 Slides modified Yishay Mansour on modification by Benny Chor, based on original slides by Maurice Herlihy, Brown University. p. 25 Example: NFA DFA Deterministic Automata:

19 Slides modified Yishay Mansour on modification by Benny Chor, based on original slides by Maurice Herlihy, Brown University. p. 26 Dealing with ε-transitions For any state R of M, definee(r) to be the collection of states reachable from R by ε transitions only. E(R) = {q Q q can be reached from some r R by 0 or more ε transitions} Define transition function: δ (R, a) = {q Q q E(δ(r, a)) for some r R} Change start state to Example. q 0 = E({q 0})

20 Slides modified Yishay Mansour on modification by Benny Chor, based on original slides by Maurice Herlihy, Brown University. p. 27 Example: Removing ε-transitions Non-Deterministic Automata with ε-tansitions

21 Slides modified Yishay Mansour on modification by Benny Chor, based on original slides by Maurice Herlihy, Brown University. p. 28 Example: Removing ε-transitions Non-Deterministic Automata without ε-tansitions

22 The Regular Operations Let A and B be languages. The union operation: A B = {x x A or x B} The concatenation operation: A B = {xy x A and y B} The star operation: A = {x 1 x 2...x k k 0 and each x i A}

23 The Regular Operations Examples Let A= {good, bad} and B = {boy, girl}. Union A B = {good, bad, boy, girl} Concatenation A B = {goodboy, goodgirl, badboy, badgirl} Star A = {ε, good, bad, goodgood, goodbad, badbad, badgood,...}

24 Regular Expressions Anotationforbuildinguplanguagesbydescribingthemas expressions, e.g. (0 1)0. 0 and 1 are shorthand for {0} and {1} so (0 1) = {0, 1}. 0 is shorthand for {0}. concatenation, like multiplication, is implicit, so 0 10 is shorthand for the set of all strings over Σ = {0, 1} having exactly a single 1. Q.: Whatdoes(0 1)0 stand for? Remark: Regularexpressionsareoftenusedintexteditors or shell scripts.

25 More Examples Let Σ be an alphabet. The regular expression Σ is the language of one-symbol strings. Σ is all strings. Σ 1 all strings ending in 1. 0Σ Σ 1 strings starting with 0 or ending in 1. Just like in arithmetic, operations have precedence: star first concatenation next union last parentheses used to change default order

26 Regular Expressions Formal Definition Syntax: R is a regular expression if R is of form a for some a Σ ε (R 1 R 2 ) for regular expressions R 1 and R 2 (R 1 R 2 ) for regular expressions R 1 and R 2 (R1 ) for regular expression R 1

27 Regular Expressions Formal Definition Let L(R) be the language denoted by regular expression R. R L(R) a {a} ε {ε} (R 1 R 2 ) L(R 1 ) L(R 2 ) (R 1 R 2 ) L(R 1 ) L(R 2 ) (R 1 ) L(R 1 ) Q.: What sthedifferencebetween and ε? Q.: Isn tthisdefinitioncircular?

28 Remarkable Fact Thm.: A language, L, is described by a regular expression, R, if and only if L is regular. = construct an NFA accepting R. = Given a regular language, L, constructan equivalent regular expression.

29 Regular Languages, Revisited By definition, a language is regular if it is accepted by some DFA. Corollary: Alanguageisregularifandonlyifitisaccepted by some NFA. This is an alternative way of characterizing regular languages. We will now use the equivalence to show that regular languages are closed under the regular operations (union, concatenation, star).

30 Claim: Closure Under Union If A 1 and A 2 are regular languages, so is A 1 A 2. Approach to Proof: some M 1 accepts A 1 some M 2 accepts A 2 construct M that accepts A 1 A 2. Attempted Proof Idea: first simulate M 1, and if M 1 doesn t accept, then simulate M 2.

31 Claim: Closure Under Union If A 1 and A 2 are regular languages, so is A 1 A 2. Approach to Proof: some M 1 accepts A 1 some M 2 accepts A 2 construct M that accepts A 1 A 2. Attempted Proof Idea: first simulate M 1, and if M 1 doesn t accept, then simulate M 2. What s wrong with this?

32 Claim: Closure Under Union (reminder) If A 1 and A 2 are regular languages, so is A 1 A 2. Approach to Proof: some M 1 accepts A 1 some M 2 accepts A 2 construct M that accepts A 1 A 2. in our construction, states of M were Cartesian product of M 1 and M 2 states.

33 Closure Under Union (alternative proof) N 1 N 2

34 Regular Languages Closed Under Union! N 1! N 2

35 Regular Languages Closed Under Union Suppose N 1 =(Q 1, Σ, δ 1,q 1,F 1 ) accept L 1,and N 2 =(Q 2, Σ, δ 2,q 2,F 2 ) accept L 2. Define N =(Q, Σ, δ,q 0,F): Q = q 0 Q 1 Q 2 Σ is the same, q 0 is the start state F = F 1 F 2 δ (q, a) = δ 1 (q, a) q Q 1 δ 2 (q, a) q Q 2 {q 1,q 2 } q = q 0 and a = ε q = q 0 and a ε

36 What About Concatenation? Thm: IfL 1, L 2 are regular languages, so is L 1 L 2. Example: L 1 = {good, bad} and L 2 = {boy, girl}. L 1 L 2 = {goodboy, goodgirl, badboy, badgirl} This is much harder to prove. Idea: SimulateM 1 for a while, then switch to M 2. Problem: Butwhen do you switch? Seems hard to do with DFAs. This leads us into non-determinism.

37 Regular Languages Closed UnderConcatenation N 1 N 2

38 Regular LanguagesClosed Under Concatenation N 1! N 2! Remark: Final states are exactly those of N 2.

39 Regular LanguagesClosed Under Concatenation Suppose N 1 =(Q 1, Σ, δ 1,q 1,F 1 ) accept L 1,and N 2 =(Q 2, Σ, δ 2,q 2,F 2 ) accept L 2. Define N =(Q, Σ, δ,q 1,F 2 ): Q = Q 1 Q 2 q 1 is the start state of N F 2 is the set of accept states of N δ 1 (q, a) q Q 1 and q/ F 1 δ δ 1 (q, a) q Q 1 and a ε (q, a) = δ 1 (q, a) {q 2 } q F 1 and a = ε δ 2 (q, a) q Q 2

40 Regular Languages Closed Under Star N 1 N 1!! Oops - bad construction (really? why?). How do we fix it?

41 Regular Languages Closed Under Star N 1 accepts R 1.WannabuildNFAforR =(R 1 ). q 0 ε ε Ahaa - abetterconstruction!

42 Regular Languages Closed Under Star Suppose N 1 =(Q 1, Σ, δ 1,q 1,F 1 ) accepts L 1. Define N =(Q, Σ, δ, q 0,F): Q = {q 0 } Q 1 q 0 is the new start state. F = {q 0 F 1 } δ 1 (q, a) q Q 1 and q/ F 1 δ 1 (q, a) q F 1 and a ε δ (q, a) = δ 1 (q, ε) {q 1 } q F 1 and a = ε {q 1 } q = q 0 and a = ε q = q 0 and a ε

43 Summary Regular languages are closed under union concatenation star Non-deterministic finite automata are equivalent to deterministic finite automata but much easier to use in some proofs and constructions.

44 Given R, Build NFA Accepting It (= ) a 1. R = a,for some a Σ 2. R = ε 3. R =

45 Given R, Build NFA Accepting It (= ) N 1!! N 2 N 1!! N 2 R =(R 1 R 2 ) R =(R 1 R 2 ) R =(R 1 ) q 0 ε ε

46 Approximately Correct Examples a a b b ab b! a! b! a ab U a only approximately?)! a (why

47 Automaton Expression L(q,S,r): expression for all paths (in A) from state q to state r passing through (intermediate) states S only Defined recursively L(q,,r) = sum (union) of all a for which there s an edge q to r labeled a, plus ε if q=r L(q,S {s},r) = [L(q,S,r)+L(q,S,s)L(s,S,s)*L(s,S,r)]

48 What We Just Completed Thm.: A language, L, is described by a regular expression, R, if and only if L is regular. = construct an NFA accepting R. = Given a regular language, L, constructan equivalent regular expression

49 Algorithmic Questions for NFAs Q.: GivenanNFA,N, andastrings, iss L(N)? Answer: ConstructtheDFAequivalenttoN and run it on w. Q.: IsL(N) =? Answer: This is a reachability question in graphs: Is there a path in the states graph of N from the start state to some accepting state. There are simple, efficient algorithms for this task.

50 More Algorithmic Questions for NFAs Q.: IsL(N) =Σ? Answer: CheckifL(N) =. Q.: GivenN 1 and N 2,isL(N 1 ) L(N 2 )? Answer: CheckifL(N 2 ) L(N 1 )=. Q.: GivenN 1 and N 2,isL(N 1 )=L(N 2 )? Answer: CheckifL(N 1 ) L(N 2 ) and L(N 2 ) L(N 1 ). In the future, we will see that for stronger models of computations, many of these problems cannot be solved by any algorithm.

Critical CS Questions

Critical CS Questions Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. p. 1 Critical CS Questions What is a computer? And What is a Computation? real computers too complex for any

More information

Computational Models - Lecture 1 1

Computational Models - Lecture 1 1 Computational Models - Lecture 1 1 Handout Mode Ronitt Rubinfeld and Iftach Haitner. Tel Aviv University. February 29/ March 02, 2016 1 Based on frames by Benny Chor, Tel Aviv University, modifying frames

More information

Computational Models Lecture 2 1

Computational Models Lecture 2 1 Computational Models Lecture 2 1 Handout Mode Ronitt Rubinfeld and Iftach Haitner. Tel Aviv University. March 16/18, 2015 1 Based on frames by Benny Chor, Tel Aviv University, modifying frames by Maurice

More information

Computational Models Lecture 2 1

Computational Models Lecture 2 1 Computational Models Lecture 2 1 Handout Mode Iftach Haitner. Tel Aviv University. October 30, 2017 1 Based on frames by Benny Chor, Tel Aviv University, modifying frames by Maurice Herlihy, Brown University.

More information

Computational Models #1

Computational Models #1 Computational Models #1 Handout Mode Nachum Dershowitz & Yishay Mansour March 13-15, 2017 Nachum Dershowitz & Yishay Mansour Computational Models #1 March 13-15, 2017 1 / 41 Lecture Outline I Motivation

More information

Time Magazine (1984)

Time Magazine (1984) Time Magazine (1984) Put the right kind of software into a computer, and it will do whatever you want it to. There may be limits on what you can do with the machines themselves, but there are no limits

More information

Computational Models: Class 1

Computational Models: Class 1 Computational Models: Class 1 Benny Chor School of Computer Science Tel Aviv University October 19, 2015 Based on slides by Maurice Herlihy, Brown University, and modifications by Iftach Haitner and Yishay

More information

UNIT-III REGULAR LANGUAGES

UNIT-III REGULAR LANGUAGES Syllabus R9 Regulation REGULAR EXPRESSIONS UNIT-III REGULAR LANGUAGES Regular expressions are useful for representing certain sets of strings in an algebraic fashion. In arithmetic we can use the operations

More information

CISC 4090: Theory of Computation Chapter 1 Regular Languages. Section 1.1: Finite Automata. What is a computer? Finite automata

CISC 4090: Theory of Computation Chapter 1 Regular Languages. Section 1.1: Finite Automata. What is a computer? Finite automata CISC 4090: Theory of Computation Chapter Regular Languages Xiaolan Zhang, adapted from slides by Prof. Werschulz Section.: Finite Automata Fordham University Department of Computer and Information Sciences

More information

CPS 220 Theory of Computation REGULAR LANGUAGES

CPS 220 Theory of Computation REGULAR LANGUAGES CPS 22 Theory of Computation REGULAR LANGUAGES Introduction Model (def) a miniature representation of a thing; sometimes a facsimile Iraq village mockup for the Marines Scientific modelling - the process

More information

Theory of Computation (I) Yijia Chen Fudan University

Theory of Computation (I) Yijia Chen Fudan University Theory of Computation (I) Yijia Chen Fudan University Instructor Yijia Chen Homepage: http://basics.sjtu.edu.cn/~chen Email: yijiachen@fudan.edu.cn Textbook Introduction to the Theory of Computation Michael

More information

CHAPTER 1 Regular Languages. Contents

CHAPTER 1 Regular Languages. Contents Finite Automata (FA or DFA) CHAPTER Regular Languages Contents definitions, examples, designing, regular operations Non-deterministic Finite Automata (NFA) definitions, euivalence of NFAs and DFAs, closure

More information

September 7, Formal Definition of a Nondeterministic Finite Automaton

September 7, Formal Definition of a Nondeterministic Finite Automaton Formal Definition of a Nondeterministic Finite Automaton September 7, 2014 A comment first The formal definition of an NFA is similar to that of a DFA. Both have states, an alphabet, transition function,

More information

What we have done so far

What we have done so far What we have done so far DFAs and regular languages NFAs and their equivalence to DFAs Regular expressions. Regular expressions capture exactly regular languages: Construct a NFA from a regular expression.

More information

acs-04: Regular Languages Regular Languages Andreas Karwath & Malte Helmert Informatik Theorie II (A) WS2009/10

acs-04: Regular Languages Regular Languages Andreas Karwath & Malte Helmert Informatik Theorie II (A) WS2009/10 Regular Languages Andreas Karwath & Malte Helmert 1 Overview Deterministic finite automata Regular languages Nondeterministic finite automata Closure operations Regular expressions Nonregular languages

More information

CS 154. Finite Automata, Nondeterminism, Regular Expressions

CS 154. Finite Automata, Nondeterminism, Regular Expressions CS 54 Finite Automata, Nondeterminism, Regular Expressions Read string left to right The DFA accepts a string if the process ends in a double circle A DFA is a 5-tuple M = (Q, Σ, δ, q, F) Q is the set

More information

Introduction to Languages and Computation

Introduction to Languages and Computation Introduction to Languages and Computation George Voutsadakis 1 1 Mathematics and Computer Science Lake Superior State University LSSU Math 400 George Voutsadakis (LSSU) Languages and Computation July 2014

More information

Computational Models: Class 3

Computational Models: Class 3 Computational Models: Class 3 Benny Chor School of Computer Science Tel Aviv University November 2, 2015 Based on slides by Maurice Herlihy, Brown University, and modifications by Iftach Haitner and Yishay

More information

Nondeterministic Finite Automata

Nondeterministic Finite Automata Nondeterministic Finite Automata Not A DFA Does not have exactly one transition from every state on every symbol: Two transitions from q 0 on a No transition from q 1 (on either a or b) Though not a DFA,

More information

CS21 Decidability and Tractability

CS21 Decidability and Tractability CS21 Decidability and Tractability Lecture 2 January 5, 2018 January 5, 2018 CS21 Lecture 2 1 Outline Finite Automata Nondeterministic Finite Automata Closure under regular operations NFA, FA equivalence

More information

Closure under the Regular Operations

Closure under the Regular Operations September 7, 2013 Application of NFA Now we use the NFA to show that collection of regular languages is closed under regular operations union, concatenation, and star Earlier we have shown this closure

More information

FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY

FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY 5-453 FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY NON-DETERMINISM and REGULAR OPERATIONS THURSDAY JAN 6 UNION THEOREM The union of two regular languages is also a regular language Regular Languages Are

More information

Lecture 3: Nondeterministic Finite Automata

Lecture 3: Nondeterministic Finite Automata Lecture 3: Nondeterministic Finite Automata September 5, 206 CS 00 Theory of Computation As a recap of last lecture, recall that a deterministic finite automaton (DFA) consists of (Q, Σ, δ, q 0, F ) where

More information

Computational Models - Lecture 5 1

Computational Models - Lecture 5 1 Computational Models - Lecture 5 1 Handout Mode Iftach Haitner and Yishay Mansour. Tel Aviv University. April 10/22, 2013 1 Based on frames by Benny Chor, Tel Aviv University, modifying frames by Maurice

More information

Recitation 2 - Non Deterministic Finite Automata (NFA) and Regular OctoberExpressions

Recitation 2 - Non Deterministic Finite Automata (NFA) and Regular OctoberExpressions Recitation 2 - Non Deterministic Finite Automata (NFA) and Regular Expressions Orit Moskovich Gal Rotem Tel Aviv University October 28, 2015 Recitation 2 - Non Deterministic Finite Automata (NFA) and Regular

More information

COM364 Automata Theory Lecture Note 2 - Nondeterminism

COM364 Automata Theory Lecture Note 2 - Nondeterminism COM364 Automata Theory Lecture Note 2 - Nondeterminism Kurtuluş Küllü March 2018 The FA we saw until now were deterministic FA (DFA) in the sense that for each state and input symbol there was exactly

More information

Computational Models - Lecture 3

Computational Models - Lecture 3 Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. p. 1 Computational Models - Lecture 3 Equivalence of regular expressions and regular languages (lukewarm leftover

More information

UNIT-II. NONDETERMINISTIC FINITE AUTOMATA WITH ε TRANSITIONS: SIGNIFICANCE. Use of ε-transitions. s t a r t. ε r. e g u l a r

UNIT-II. NONDETERMINISTIC FINITE AUTOMATA WITH ε TRANSITIONS: SIGNIFICANCE. Use of ε-transitions. s t a r t. ε r. e g u l a r Syllabus R9 Regulation UNIT-II NONDETERMINISTIC FINITE AUTOMATA WITH ε TRANSITIONS: In the automata theory, a nondeterministic finite automaton (NFA) or nondeterministic finite state machine is a finite

More information

Chapter Five: Nondeterministic Finite Automata

Chapter Five: Nondeterministic Finite Automata Chapter Five: Nondeterministic Finite Automata From DFA to NFA A DFA has exactly one transition from every state on every symbol in the alphabet. By relaxing this requirement we get a related but more

More information

CS 154, Lecture 3: DFA NFA, Regular Expressions

CS 154, Lecture 3: DFA NFA, Regular Expressions CS 154, Lecture 3: DFA NFA, Regular Expressions Homework 1 is coming out Deterministic Finite Automata Computation with finite memory Non-Deterministic Finite Automata Computation with finite memory and

More information

Finite Automata. BİL405 - Automata Theory and Formal Languages 1

Finite Automata. BİL405 - Automata Theory and Formal Languages 1 Finite Automata BİL405 - Automata Theory and Formal Languages 1 Deterministic Finite Automata (DFA) A Deterministic Finite Automata (DFA) is a quintuple A = (Q,,, q 0, F) 1. Q is a finite set of states

More information

Regular Expressions. Definitions Equivalence to Finite Automata

Regular Expressions. Definitions Equivalence to Finite Automata Regular Expressions Definitions Equivalence to Finite Automata 1 RE s: Introduction Regular expressions are an algebraic way to describe languages. They describe exactly the regular languages. If E is

More information

Chap. 1.2 NonDeterministic Finite Automata (NFA)

Chap. 1.2 NonDeterministic Finite Automata (NFA) Chap. 1.2 NonDeterministic Finite Automata (NFA) DFAs: exactly 1 new state for any state & next char NFA: machine may not work same each time More than 1 transition rule for same state & input Any one

More information

Computational Models - Lecture 4

Computational Models - Lecture 4 Computational Models - Lecture 4 Regular languages: The Myhill-Nerode Theorem Context-free Grammars Chomsky Normal Form Pumping Lemma for context free languages Non context-free languages: Examples Push

More information

Non-deterministic Finite Automata (NFAs)

Non-deterministic Finite Automata (NFAs) Algorithms & Models of Computation CS/ECE 374, Fall 27 Non-deterministic Finite Automata (NFAs) Part I NFA Introduction Lecture 4 Thursday, September 7, 27 Sariel Har-Peled (UIUC) CS374 Fall 27 / 39 Sariel

More information

Theory of Computation (II) Yijia Chen Fudan University

Theory of Computation (II) Yijia Chen Fudan University Theory of Computation (II) Yijia Chen Fudan University Review A language L is a subset of strings over an alphabet Σ. Our goal is to identify those languages that can be recognized by one of the simplest

More information

Theory of Languages and Automata

Theory of Languages and Automata Theory of Languages and Automata Chapter 1- Regular Languages & Finite State Automaton Sharif University of Technology Finite State Automaton We begin with the simplest model of Computation, called finite

More information

Computational Models - Lecture 3 1

Computational Models - Lecture 3 1 Computational Models - Lecture 3 1 Handout Mode Iftach Haitner and Yishay Mansour. Tel Aviv University. March 13/18, 2013 1 Based on frames by Benny Chor, Tel Aviv University, modifying frames by Maurice

More information

CS 154, Lecture 2: Finite Automata, Closure Properties Nondeterminism,

CS 154, Lecture 2: Finite Automata, Closure Properties Nondeterminism, CS 54, Lecture 2: Finite Automata, Closure Properties Nondeterminism, Why so Many Models? Streaming Algorithms 0 42 Deterministic Finite Automata Anatomy of Deterministic Finite Automata transition: for

More information

Computational Models: Class 5

Computational Models: Class 5 Computational Models: Class 5 Benny Chor School of Computer Science Tel Aviv University March 27, 2019 Based on slides by Maurice Herlihy, Brown University, and modifications by Iftach Haitner and Yishay

More information

CS243, Logic and Computation Nondeterministic finite automata

CS243, Logic and Computation Nondeterministic finite automata CS243, Prof. Alvarez NONDETERMINISTIC FINITE AUTOMATA (NFA) Prof. Sergio A. Alvarez http://www.cs.bc.edu/ alvarez/ Maloney Hall, room 569 alvarez@cs.bc.edu Computer Science Department voice: (67) 552-4333

More information

CS21 Decidability and Tractability

CS21 Decidability and Tractability CS21 Decidability and Tractability Lecture 3 January 9, 2017 January 9, 2017 CS21 Lecture 3 1 Outline NFA, FA equivalence Regular Expressions FA and Regular Expressions January 9, 2017 CS21 Lecture 3 2

More information

Intro to Theory of Computation

Intro to Theory of Computation Intro to Theory of Computation 1/19/2016 LECTURE 3 Last time: DFAs and NFAs Operations on languages Today: Nondeterminism Equivalence of NFAs and DFAs Closure properties of regular languages Sofya Raskhodnikova

More information

Nondeterministic finite automata

Nondeterministic finite automata Lecture 3 Nondeterministic finite automata This lecture is focused on the nondeterministic finite automata (NFA) model and its relationship to the DFA model. Nondeterminism is an important concept in the

More information

CSC173 Workshop: 13 Sept. Notes

CSC173 Workshop: 13 Sept. Notes CSC173 Workshop: 13 Sept. Notes Frank Ferraro Department of Computer Science University of Rochester September 14, 2010 1 Regular Languages and Equivalent Forms A language can be thought of a set L of

More information

CS 530: Theory of Computation Based on Sipser (second edition): Notes on regular languages(version 1.1)

CS 530: Theory of Computation Based on Sipser (second edition): Notes on regular languages(version 1.1) CS 530: Theory of Computation Based on Sipser (second edition): Notes on regular languages(version 1.1) Definition 1 (Alphabet) A alphabet is a finite set of objects called symbols. Definition 2 (String)

More information

Automata and Formal Languages - CM0081 Non-Deterministic Finite Automata

Automata and Formal Languages - CM0081 Non-Deterministic Finite Automata Automata and Formal Languages - CM81 Non-Deterministic Finite Automata Andrés Sicard-Ramírez Universidad EAFIT Semester 217-2 Non-Deterministic Finite Automata (NFA) Introduction q i a a q j a q k The

More information

Computational Models Lecture 8 1

Computational Models Lecture 8 1 Computational Models Lecture 8 1 Handout Mode Nachum Dershowitz & Yishay Mansour. Tel Aviv University. May 17 22, 2017 1 Based on frames by Benny Chor, Tel Aviv University, modifying frames by Maurice

More information

CMPSCI 250: Introduction to Computation. Lecture #22: From λ-nfa s to NFA s to DFA s David Mix Barrington 22 April 2013

CMPSCI 250: Introduction to Computation. Lecture #22: From λ-nfa s to NFA s to DFA s David Mix Barrington 22 April 2013 CMPSCI 250: Introduction to Computation Lecture #22: From λ-nfa s to NFA s to DFA s David Mix Barrington 22 April 2013 λ-nfa s to NFA s to DFA s Reviewing the Three Models and Kleene s Theorem The Subset

More information

Lecture 4 Nondeterministic Finite Accepters

Lecture 4 Nondeterministic Finite Accepters Lecture 4 Nondeterministic Finite Accepters COT 4420 Theory of Computation Section 2.2, 2.3 Nondeterminism A nondeterministic finite automaton can go to several states at once. Transitions from one state

More information

Decision, Computation and Language

Decision, Computation and Language Decision, Computation and Language Non-Deterministic Finite Automata (NFA) Dr. Muhammad S Khan (mskhan@liv.ac.uk) Ashton Building, Room G22 http://www.csc.liv.ac.uk/~khan/comp218 Finite State Automata

More information

Finite Automata and Regular languages

Finite Automata and Regular languages Finite Automata and Regular languages Huan Long Shanghai Jiao Tong University Acknowledgements Part of the slides comes from a similar course in Fudan University given by Prof. Yijia Chen. http://basics.sjtu.edu.cn/

More information

T (s, xa) = T (T (s, x), a). The language recognized by M, denoted L(M), is the set of strings accepted by M. That is,

T (s, xa) = T (T (s, x), a). The language recognized by M, denoted L(M), is the set of strings accepted by M. That is, Recall A deterministic finite automaton is a five-tuple where S is a finite set of states, M = (S, Σ, T, s 0, F ) Σ is an alphabet the input alphabet, T : S Σ S is the transition function, s 0 S is the

More information

Inf2A: Converting from NFAs to DFAs and Closure Properties

Inf2A: Converting from NFAs to DFAs and Closure Properties 1/43 Inf2A: Converting from NFAs to DFAs and Stuart Anderson School of Informatics University of Edinburgh October 13, 2009 Starter Questions 2/43 1 Can you devise a way of testing for any FSM M whether

More information

CS 455/555: Finite automata

CS 455/555: Finite automata CS 455/555: Finite automata Stefan D. Bruda Winter 2019 AUTOMATA (FINITE OR NOT) Generally any automaton Has a finite-state control Scans the input one symbol at a time Takes an action based on the currently

More information

Automata & languages. A primer on the Theory of Computation. Laurent Vanbever. ETH Zürich (D-ITET) September,

Automata & languages. A primer on the Theory of Computation. Laurent Vanbever.  ETH Zürich (D-ITET) September, Automata & languages A primer on the Theory of Computation Laurent Vanbever www.vanbever.eu ETH Zürich (D-ITET) September, 24 2015 Last week was all about Deterministic Finite Automaton We saw three main

More information

Lecture 1: Finite State Automaton

Lecture 1: Finite State Automaton Lecture 1: Finite State Automaton Instructor: Ketan Mulmuley Scriber: Yuan Li January 6, 2015 1 Deterministic Finite Automaton Informally, a deterministic finite automaton (DFA) has finite number of s-

More information

Extended transition function of a DFA

Extended transition function of a DFA Extended transition function of a DFA The next two pages describe the extended transition function of a DFA in a more detailed way than Handout 3.. p./43 Formal approach to accepted strings We define the

More information

Languages, regular languages, finite automata

Languages, regular languages, finite automata Notes on Computer Theory Last updated: January, 2018 Languages, regular languages, finite automata Content largely taken from Richards [1] and Sipser [2] 1 Languages An alphabet is a finite set of characters,

More information

CSE 135: Introduction to Theory of Computation Nondeterministic Finite Automata (cont )

CSE 135: Introduction to Theory of Computation Nondeterministic Finite Automata (cont ) CSE 135: Introduction to Theory of Computation Nondeterministic Finite Automata (cont ) Sungjin Im University of California, Merced 2-3-214 Example II A ɛ B ɛ D F C E Example II A ɛ B ɛ D F C E NFA accepting

More information

Computational Models Lecture 5

Computational Models Lecture 5 Computational Models Lecture 5 One More PDAs Example Equivalence of PDAs and CFLs Nondeterminism adds power to PDAs (not in book) Closure Properties of CFLs Algorithmic Aspects of PDAs and CFLs DFAs and

More information

Nondeterministic Finite Automata. Nondeterminism Subset Construction

Nondeterministic Finite Automata. Nondeterminism Subset Construction Nondeterministic Finite Automata Nondeterminism Subset Construction 1 Nondeterminism A nondeterministic finite automaton has the ability to be in several states at once. Transitions from a state on an

More information

INF Introduction and Regular Languages. Daniel Lupp. 18th January University of Oslo. Department of Informatics. Universitetet i Oslo

INF Introduction and Regular Languages. Daniel Lupp. 18th January University of Oslo. Department of Informatics. Universitetet i Oslo INF28 1. Introduction and Regular Languages Daniel Lupp Universitetet i Oslo 18th January 218 Department of Informatics University of Oslo INF28 Lecture :: 18th January 1 / 33 Details on the Course consists

More information

Closure Properties of Regular Languages. Union, Intersection, Difference, Concatenation, Kleene Closure, Reversal, Homomorphism, Inverse Homomorphism

Closure Properties of Regular Languages. Union, Intersection, Difference, Concatenation, Kleene Closure, Reversal, Homomorphism, Inverse Homomorphism Closure Properties of Regular Languages Union, Intersection, Difference, Concatenation, Kleene Closure, Reversal, Homomorphism, Inverse Homomorphism Closure Properties Recall a closure property is a statement

More information

Equivalence of DFAs and NFAs

Equivalence of DFAs and NFAs CS 172: Computability and Complexity Equivalence of DFAs and NFAs It s a tie! DFA NFA Sanjit A. Seshia EECS, UC Berkeley Acknowledgments: L.von Ahn, L. Blum, M. Blum What we ll do today Prove that DFAs

More information

September 11, Second Part of Regular Expressions Equivalence with Finite Aut

September 11, Second Part of Regular Expressions Equivalence with Finite Aut Second Part of Regular Expressions Equivalence with Finite Automata September 11, 2013 Lemma 1.60 If a language is regular then it is specified by a regular expression Proof idea: For a given regular language

More information

Theory of computation: initial remarks (Chapter 11)

Theory of computation: initial remarks (Chapter 11) Theory of computation: initial remarks (Chapter 11) For many purposes, computation is elegantly modeled with simple mathematical objects: Turing machines, finite automata, pushdown automata, and such.

More information

FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY

FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY 15-453 FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY REVIEW for MIDTERM 1 THURSDAY Feb 6 Midterm 1 will cover everything we have seen so far The PROBLEMS will be from Sipser, Chapters 1, 2, 3 It will be

More information

Languages. Non deterministic finite automata with ε transitions. First there was the DFA. Finite Automata. Non-Deterministic Finite Automata (NFA)

Languages. Non deterministic finite automata with ε transitions. First there was the DFA. Finite Automata. Non-Deterministic Finite Automata (NFA) Languages Non deterministic finite automata with ε transitions Recall What is a language? What is a class of languages? Finite Automata Consists of A set of states (Q) A start state (q o ) A set of accepting

More information

cse303 ELEMENTS OF THE THEORY OF COMPUTATION Professor Anita Wasilewska

cse303 ELEMENTS OF THE THEORY OF COMPUTATION Professor Anita Wasilewska cse303 ELEMENTS OF THE THEORY OF COMPUTATION Professor Anita Wasilewska LECTURE 6 CHAPTER 2 FINITE AUTOMATA 2. Nondeterministic Finite Automata NFA 3. Finite Automata and Regular Expressions 4. Languages

More information

The View Over The Horizon

The View Over The Horizon The View Over The Horizon enumerable decidable context free regular Context-Free Grammars An example of a context free grammar, G 1 : A 0A1 A B B # Terminology: Each line is a substitution rule or production.

More information

Computational Theory

Computational Theory Computational Theory Finite Automata and Regular Languages Curtis Larsen Dixie State University Computing and Design Fall 2018 Adapted from notes by Russ Ross Adapted from notes by Harry Lewis Curtis Larsen

More information

Theory of Computation p.1/?? Theory of Computation p.2/?? Unknown: Implicitly a Boolean variable: true if a word is

Theory of Computation p.1/?? Theory of Computation p.2/?? Unknown: Implicitly a Boolean variable: true if a word is Abstraction of Problems Data: abstracted as a word in a given alphabet. Σ: alphabet, a finite, non-empty set of symbols. Σ : all the words of finite length built up using Σ: Conditions: abstracted as a

More information

Automata and Languages

Automata and Languages Automata and Languages Prof. Mohamed Hamada Software Engineering Lab. The University of Aizu Japan Nondeterministic Finite Automata with empty moves (-NFA) Definition A nondeterministic finite automaton

More information

Sri vidya college of engineering and technology

Sri vidya college of engineering and technology Unit I FINITE AUTOMATA 1. Define hypothesis. The formal proof can be using deductive proof and inductive proof. The deductive proof consists of sequence of statements given with logical reasoning in order

More information

Incorrect reasoning about RL. Equivalence of NFA, DFA. Epsilon Closure. Proving equivalence. One direction is easy:

Incorrect reasoning about RL. Equivalence of NFA, DFA. Epsilon Closure. Proving equivalence. One direction is easy: Incorrect reasoning about RL Since L 1 = {w w=a n, n N}, L 2 = {w w = b n, n N} are regular, therefore L 1 L 2 = {w w=a n b n, n N} is regular If L 1 is a regular language, then L 2 = {w R w L 1 } is regular,

More information

Chapter 5. Finite Automata

Chapter 5. Finite Automata Chapter 5 Finite Automata 5.1 Finite State Automata Capable of recognizing numerous symbol patterns, the class of regular languages Suitable for pattern-recognition type applications, such as the lexical

More information

Deterministic Finite Automata. Non deterministic finite automata. Non-Deterministic Finite Automata (NFA) Non-Deterministic Finite Automata (NFA)

Deterministic Finite Automata. Non deterministic finite automata. Non-Deterministic Finite Automata (NFA) Non-Deterministic Finite Automata (NFA) Deterministic Finite Automata Non deterministic finite automata Automata we ve been dealing with have been deterministic For every state and every alphabet symbol there is exactly one move that the machine

More information

CISC 4090 Theory of Computation

CISC 4090 Theory of Computation 9/2/28 Stereotypical computer CISC 49 Theory of Computation Finite state machines & Regular languages Professor Daniel Leeds dleeds@fordham.edu JMH 332 Central processing unit (CPU) performs all the instructions

More information

Automata: a short introduction

Automata: a short introduction ILIAS, University of Luxembourg Discrete Mathematics II May 2012 What is a computer? Real computers are complicated; We abstract up to an essential model of computation; We begin with the simplest possible

More information

Nondeterministic Finite Automata

Nondeterministic Finite Automata Nondeterministic Finite Automata Mahesh Viswanathan Introducing Nondeterminism Consider the machine shown in Figure. Like a DFA it has finitely many states and transitions labeled by symbols from an input

More information

Nondeterminism. September 7, Nondeterminism

Nondeterminism. September 7, Nondeterminism September 7, 204 Introduction is a useful concept that has a great impact on the theory of computation Introduction is a useful concept that has a great impact on the theory of computation So far in our

More information

Computer Sciences Department

Computer Sciences Department 1 Reference Book: INTRODUCTION TO THE THEORY OF COMPUTATION, SECOND EDITION, by: MICHAEL SIPSER 3 objectives Finite automaton Infinite automaton Formal definition State diagram Regular and Non-regular

More information

CSE 105 Theory of Computation Professor Jeanne Ferrante

CSE 105 Theory of Computation  Professor Jeanne Ferrante CSE 105 Theory of Computation http://www.jflap.org/jflaptmp/ Professor Jeanne Ferrante 1 Today s agenda NFA Review and Design NFA s Equivalence to DFA s Another Closure Property proof for Regular Languages

More information

Computational Models - Lecture 4 1

Computational Models - Lecture 4 1 Computational Models - Lecture 4 1 Handout Mode Iftach Haitner and Yishay Mansour. Tel Aviv University. April 3/8, 2013 1 Based on frames by Benny Chor, Tel Aviv University, modifying frames by Maurice

More information

Examples of Regular Expressions. Finite Automata vs. Regular Expressions. Example of Using flex. Application

Examples of Regular Expressions. Finite Automata vs. Regular Expressions. Example of Using flex. Application Examples of Regular Expressions 1. 0 10, L(0 10 ) = {w w contains exactly a single 1} 2. Σ 1Σ, L(Σ 1Σ ) = {w w contains at least one 1} 3. Σ 001Σ, L(Σ 001Σ ) = {w w contains the string 001 as a substring}

More information

Regular Expressions and Language Properties

Regular Expressions and Language Properties Regular Expressions and Language Properties Mridul Aanjaneya Stanford University July 3, 2012 Mridul Aanjaneya Automata Theory 1/ 47 Tentative Schedule HW #1: Out (07/03), Due (07/11) HW #2: Out (07/10),

More information

CS 154. Finite Automata vs Regular Expressions, Non-Regular Languages

CS 154. Finite Automata vs Regular Expressions, Non-Regular Languages CS 154 Finite Automata vs Regular Expressions, Non-Regular Languages Deterministic Finite Automata Computation with finite memory Non-Deterministic Finite Automata Computation with finite memory and guessing

More information

Theory of Computation Lecture 1. Dr. Nahla Belal

Theory of Computation Lecture 1. Dr. Nahla Belal Theory of Computation Lecture 1 Dr. Nahla Belal Book The primary textbook is: Introduction to the Theory of Computation by Michael Sipser. Grading 10%: Weekly Homework. 30%: Two quizzes and one exam. 20%:

More information

Automata Theory. Lecture on Discussion Course of CS120. Runzhe SJTU ACM CLASS

Automata Theory. Lecture on Discussion Course of CS120. Runzhe SJTU ACM CLASS Automata Theory Lecture on Discussion Course of CS2 This Lecture is about Mathematical Models of Computation. Why Should I Care? - Ways of thinking. - Theory can drive practice. - Don t be an Instrumentalist.

More information

3515ICT: Theory of Computation. Regular languages

3515ICT: Theory of Computation. Regular languages 3515ICT: Theory of Computation Regular languages Notation and concepts concerning alphabets, strings and languages, and identification of languages with problems (H, 1.5). Regular expressions (H, 3.1,

More information

CS:4330 Theory of Computation Spring Regular Languages. Finite Automata and Regular Expressions. Haniel Barbosa

CS:4330 Theory of Computation Spring Regular Languages. Finite Automata and Regular Expressions. Haniel Barbosa CS:4330 Theory of Computation Spring 2018 Regular Languages Finite Automata and Regular Expressions Haniel Barbosa Readings for this lecture Chapter 1 of [Sipser 1996], 3rd edition. Sections 1.1 and 1.3.

More information

Introduction to the Theory of Computation. Automata 1VO + 1PS. Lecturer: Dr. Ana Sokolova.

Introduction to the Theory of Computation. Automata 1VO + 1PS. Lecturer: Dr. Ana Sokolova. Introduction to the Theory of Computation Automata 1VO + 1PS Lecturer: Dr. Ana Sokolova http://cs.uni-salzburg.at/~anas/ Setup and Dates Lectures and Instructions 23.10. 3.11. 17.11. 24.11. 1.12. 11.12.

More information

Regular expressions and Kleene s theorem

Regular expressions and Kleene s theorem Regular expressions and Kleene s theorem Informatics 2A: Lecture 5 Mary Cryan School of Informatics University of Edinburgh mcryan@inf.ed.ac.uk 26 September 2018 1 / 18 Finishing DFA minimization An algorithm

More information

Course 4 Finite Automata/Finite State Machines

Course 4 Finite Automata/Finite State Machines Course 4 Finite Automata/Finite State Machines The structure and the content of the lecture is based on (1) http://www.eecs.wsu.edu/~ananth/cpts317/lectures/index.htm, (2) W. Schreiner Computability and

More information

Foundations of

Foundations of 91.304 Foundations of (Theoretical) Computer Science Chapter 1 Lecture Notes (Section 1.3: Regular Expressions) David Martin dm@cs.uml.edu d with some modifications by Prof. Karen Daniels, Spring 2012

More information

CS 121, Section 2. Week of September 16, 2013

CS 121, Section 2. Week of September 16, 2013 CS 121, Section 2 Week of September 16, 2013 1 Concept Review 1.1 Overview In the past weeks, we have examined the finite automaton, a simple computational model with limited memory. We proved that DFAs,

More information

Finite Automata and Regular Languages (part III)

Finite Automata and Regular Languages (part III) Finite Automata and Regular Languages (part III) Prof. Dan A. Simovici UMB 1 / 1 Outline 2 / 1 Nondeterministic finite automata can be further generalized by allowing transitions between states without

More information

Introduction to the Theory of Computation. Automata 1VO + 1PS. Lecturer: Dr. Ana Sokolova.

Introduction to the Theory of Computation. Automata 1VO + 1PS. Lecturer: Dr. Ana Sokolova. Introduction to the Theory of Computation Automata 1VO + 1PS Lecturer: Dr. Ana Sokolova http://cs.uni-salzburg.at/~anas/ Setup and Dates Lectures Tuesday 10:45 pm - 12:15 pm Instructions Tuesday 12:30

More information

Recap DFA,NFA, DTM. Slides by Prof. Debasis Mitra, FIT.

Recap DFA,NFA, DTM. Slides by Prof. Debasis Mitra, FIT. Recap DFA,NFA, DTM Slides by Prof. Debasis Mitra, FIT. 1 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

More information