Nondeterministic Finite Automata and Regular Expressions

Size: px
Start display at page:

Download "Nondeterministic Finite Automata and Regular Expressions"

Transcription

1 Nondeterministic Finite Automata and Regular Expressions CS 2800: Discrete Structures, Spring 2015 Sid Chaudhuri

2 Recap: Deterministic Finite Automaton A DFA is a 5-tuple M = (Q, Σ, δ, q 0, F) Q is a finite set of states Σ is a finite input alphabet (e.g. {0, 1}) δ is a transition function δ : Q Σ Q q 0 Q is the start/initial state F Q is the set of final/accepting states 0 Yes 1 1 No 0

3 csunplugged.com, clubpenguin.wikia.com

4 P = NP!!! csunplugged.com, clubpenguin.wikia.com

5 P = NP!!! csunplugged.com, clubpenguin.wikia.com

6 A NON-deterministic finite automaton lets you try all possible choices in parallel. If ANY choice leads you to the treasure, the pirate can't harm you! P = NP!!! csunplugged.com, clubpenguin.wikia.com

7 A non-deterministic finite automaton q 0 1 0,1 0,1 q 1 0,1 q 2

8 A non-deterministic finite automaton Different transitions from q 0 on input 1 q 0 1 0,1 0,1 q 1 0,1 q 2

9 A non-deterministic finite automaton Different transitions from q 0 on input 1 q 0 1 0,1 0,1 q 1 0,1 q 2 An NFA accepts a string x if it can get to an accepting state on input x

10 A non-deterministic finite automaton q 0 1 0,1 0,1 q 1 0,1 q 2 What language does this automaton accept?

11 A non-deterministic finite automaton q 0 1 0,1 0,1 q 1 0,1 q 2 Answer: All strings ending with 1

12 Another NFA 1 0,1 0,1 0,1 q 0 q q 0,1 1 2 q 3 What language does this automaton accept?

13 Another NFA 1 0,1 0,1 0,1 q 0 q q 0,1 1 2 q 3 Answer: All strings with 1 in the penultimate place

14 Non-deterministic Finite Automaton An NFA is a 5-tuple M = (Q, Σ, δ, q 0, F)

15 Non-deterministic Finite Automaton An NFA is a 5-tuple M = (Q, Σ, δ, q 0, F) Q is a finite set of states q 0 q 1 q 2 q 3

16 Non-deterministic Finite Automaton An NFA is a 5-tuple M = (Q, Σ, δ, q 0, F) Q is a finite set of states Σ is a finite input alphabet (e.g. {0, 1}) q 0 q 1 q 2 q 3

17 Non-deterministic Finite Automaton An NFA is a 5-tuple M = (Q, Σ, δ, q 0, F) Q is a finite set of states Σ is a finite input alphabet (e.g. {0, 1}) δ is a transition function δ : Q Σ 2 Q 1 0,1 0,1 0,1 q 2 0,1 q 0 q 1 q 3

18 Non-deterministic Finite Automaton An NFA is a 5-tuple M = (Q, Σ, δ, q 0, F) Q is a finite set of states Σ is a finite input alphabet (e.g. {0, 1}) δ is a transition function δ : Q Σ 2 Q Only change from DFAs 1 0,1 0,1 0,1 q 2 0,1 q 0 q 1 q 3

19 Non-deterministic Finite Automaton An NFA is a 5-tuple M = (Q, Σ, δ, q 0, F) Q is a finite set of states Σ is a finite input alphabet (e.g. {0, 1}) δ is a transition function δ : Q Σ 2 Q Only change from DFAs q 0 Q is the start/initial state 1 0,1 0,1 0,1 q 2 0,1 q 0 q 1 q 3

20 Non-deterministic Finite Automaton An NFA is a 5-tuple M = (Q, Σ, δ, q 0, F) Q is a finite set of states Σ is a finite input alphabet (e.g. {0, 1}) δ is a transition function δ : Q Σ 2 Q Only change from DFAs q 0 Q is the start/initial state F Q is the set of final/accepting states 1 0,1 0,1 0,1 q 2 0,1 q 0 q 1 q 3

21 Non-deterministic Finite Automaton An NFA accepts a string x if it can get to an accepting state on input x

22 Non-deterministic Finite Automaton An NFA accepts a string x if it can get to an accepting state on input x Think of it as trying many options in parallel, and hoping one path gets lucky

23 Non-deterministic Finite Automaton An NFA accepts a string x if it can get to an accepting state on input x Think of it as trying many options in parallel, and hoping one path gets lucky Transition f (state, symbol) is possible

24 Non-deterministic Finite Automaton An NFA accepts a string x if it can get to an accepting state on input x Think of it as trying many options in parallel, and hoping one path gets lucky Transition f (state, symbol) is possible the NFA treats this as a rejecting path (the string may still reach an accepting state by another path)

25 Non-deterministic Finite Automaton An NFA accepts a string x if it can get to an accepting state on input x Think of it as trying many options in parallel, and hoping one path gets lucky Transition f (state, symbol) is possible the NFA treats this as a rejecting path (the string may still reach an accepting state by another path) A convenient shortcut for our hell/black-hole state

26 Non-deterministic Finite Automaton An NFA accepts a string x if it can get to an accepting state on input x Think of it as trying many options in parallel, and hoping one path gets lucky Transition f (state, symbol) is possible the NFA treats this as a rejecting path (the string may still reach an accepting state by another path) A convenient shortcut for our hell/black-hole state Class convention: Draw all possible transitions for DFA. Not required for NFA (missing transitions lead to hell).

27 Non-deterministic Finite Automaton Every DFA is an NFA

28 Non-deterministic Finite Automaton Every DFA is an NFA If we're strict with our notation, we need to replace the transition f (state 1, symbol) state 2 with f (state 1, symbol) {state 2 }

29 Non-deterministic Finite Automaton Every DFA is an NFA If we're strict with our notation, we need to replace the transition f (state 1, symbol) state 2 with f (state 1, symbol) {state 2 } Every NFA can be simulated by a DFA

30 Non-deterministic Finite Automaton Every DFA is an NFA If we're strict with our notation, we need to replace the transition f (state 1, symbol) state 2 with f (state 1, symbol) {state 2 } Every NFA can be simulated by a DFA i.e. they accept exactly the same language

31 Non-deterministic Finite Automaton Every DFA is an NFA If we're strict with our notation, we need to replace the transition f (state 1, symbol) state 2 with f (state 1, symbol) {state 2 } Every NFA can be simulated by a DFA i.e. they accept exactly the same language Exponential blowup: if the NFA has n states, the DFA can require up to 2 n states

32 Thought for the Day #1 Find an NFA with n states that can't be simulated by a DFA with less than 2 n states

33 Every NFA can be simulated by a DFA

34 Every NFA can be simulated by a DFA p a a q r NFA (fragment)

35 Every NFA can be simulated by a DFA p a a q r NFA (fragment) DFA (fragment) a {p} {q, r}

36 Every NFA can be simulated by a DFA p a a q r Subset construction Main idea: ONE state of DFA tracks current states of ALL evolving paths of NFA NFA (fragment) DFA (fragment) a {p} {q, r} (This is merely illustrative formal construction on following slides)

37 Every NFA can be simulated by a DFA NFA Equivalent DFA Specification States Alphabet Transition Function Initial State Accepting States

38 Every NFA can be simulated by a DFA NFA Equivalent DFA Specification (Q, Σ, δ, q 0, F) (2 Q, Σ, δ', q' 0, F') States Alphabet Transition Function Initial State Accepting States

39 Every NFA can be simulated by a DFA NFA Equivalent DFA Specification (Q, Σ, δ, q 0, F) (2 Q, Σ, δ', q' 0, F') States Q 2 Q Alphabet Transition Function Initial State Accepting States

40 Every NFA can be simulated by a DFA NFA Equivalent DFA Specification (Q, Σ, δ, q 0, F) (2 Q, Σ, δ', q' 0, F') States Q 2 Q Alphabet Σ Σ Transition Function Initial State Accepting States

41 Every NFA can be simulated by a DFA NFA Equivalent DFA Specification (Q, Σ, δ, q 0, F) (2 Q, Σ, δ', q' 0, F') States Q 2 Q Alphabet Σ Σ Transition Function δ δ'(s, a) = s S δ(s, a) Initial State Accepting States

42 Every NFA can be simulated by a DFA NFA Equivalent DFA Specification (Q, Σ, δ, q 0, F) (2 Q, Σ, δ', q' 0, F') States Q 2 Q Alphabet Σ Σ Transition Function δ δ'(s, a) = s S δ(s, a) Initial State q 0 q' 0 = {q 0 } Accepting States

43 Every NFA can be simulated by a DFA NFA Equivalent DFA Specification (Q, Σ, δ, q 0, F) (2 Q, Σ, δ', q' 0, F') States Q 2 Q Alphabet Σ Σ Transition Function δ δ'(s, a) = s S δ(s, a) Initial State q 0 q' 0 = {q 0 } Accepting States F F' = {S 2 Q S F }

44 Why NFAs?

45 Why NFAs? They can be way more compact than DFAs

46 Why NFAs? They can be way more compact than DFAs 0,1 1 q 0 q 1 0,1 q 3 q 2 0,1 NFA

47 Why NFAs? They can be way more compact than DFAs 1 1 q 0 q q 000 q 001 q 010 q ,1 0, q 3 q 2 0,1 0 q 100 q 101 q 110 q NFA Equivalent minimal DFA

48 Why NFAs? They can be way more compact than DFAs 1 1 q 0 q q 000 q 001 q 010 q ,1 0, q 3 q 2 0,1 0 q 100 q 101 q 110 q NFA Equivalent minimal DFA It's easier to directly convert regular expressions ( wildcard search on steroids) to NFAs

49 XKCD

50 Playing with regexes

51 Regular expressions ( regex -es) are defined by structural induction (start with simple base expressions, construct more complicated ones recursively)

52 Empty set L( ) =

53 Empty string L(ε) = {ε}

54 Literal character L(x) = {x} e.g. L(1) = {1}, L(2) = {2}, L(a) = {a}

55 Concatenation L(AB) = {ab a L(A), b L(B)} e.g. L(12) = {12}, L(aabb) = {aabb}

56 Concatenation L(AB) = {ab a L(A), b L(B)} e.g. L(12) = {12}, L(aabb) = {aabb}, L(aε) =?

57 Concatenation L(AB) = {ab a L(A), b L(B)} e.g. L(12) = {12}, L(aabb) = {aabb}, L(aε) = {a}

58 Concatenation L(AB) = {ab a L(A), b L(B)} e.g. L(12) = {12}, L(aabb) = {aabb}, L(aε) = {a}, L(a ) =?

59 Concatenation L(AB) = {ab a L(A), b L(B)} e.g. L(12) = {12}, L(aabb) = {aabb}, L(aε) = {a}, L(a ) =

60 Alternation L(A B) = L(A) L(B) e.g. L(1 2) = {1, 2}, L(aa bb) = {aa, bb}

61 Alternation L(A B) = L(A) L(B) e.g. L(1 2) = {1, 2}, L(aa bb) = {aa, bb}, L(a ε) =?

62 Alternation L(A B) = L(A) L(B) e.g. L(1 2) = {1, 2}, L(aa bb) = {aa, bb}, L(a ε) = {a, ε}

63 Alternation L(A B) = L(A) L(B) e.g. L(1 2) = {1, 2}, L(aa bb) = {aa, bb}, L(a ε) = {a, ε}, L(a ) =?

64 Alternation L(A B) = L(A) L(B) e.g. L(1 2) = {1, 2}, L(aa bb) = {aa, bb}, L(a ε) = {a, ε}, L(a ) = {a}

65 Kleene star L(A*) = {ε} { x 1 x 2...x n n N, x i L(A) } e.g. L(a*) = {ε, a, aa, aaa, aaaa,...}

66 Kleene star L(A*) = {ε} { x 1 x 2...x n n N, x i L(A) } e.g. L(a*) = {ε, a, aa, aaa, aaaa,...}, L((ab)*) =?

67 Kleene star L(A*) = {ε} { x 1 x 2...x n n N, x i L(A) } e.g. L(a*) = {ε, a, aa, aaa, aaaa,...}, L((ab)*) = {ε, ab, abab, ababab,...}

68 Kleene star L(A*) = {ε} { x 1 x 2...x n n N, x i L(A) } e.g. L(a*) = {ε, a, aa, aaa, aaaa,...}, L((ab)*) = {ε, ab, abab, ababab,...}, L((a b)*) =?

69 Kleene star L(A*) = {ε} { x 1 x 2...x n n N, x i L(A) } e.g. L(a*) = {ε, a, aa, aaa, aaaa,...}, L((ab)*) = {ε, ab, abab, ababab,...}, L((a b)*) = {ε, a, b, aa, ab, ba, bb, aaa, aab, aba,...}

70 Kleene star L(A*) = {ε} { x 1 x 2...x n n N, x i L(A) } e.g. L(a*) = {ε, a, aa, aaa, aaaa,...}, L((ab)*) = {ε, ab, abab, ababab,...}, L((a b)*) = {ε, a, b, aa, ab, ba, bb, aaa, aab, aba,...}, L(ε*) =?

71 Kleene star L(A*) = {ε} { x 1 x 2...x n n N, x i L(A) } e.g. L(a*) = {ε, a, aa, aaa, aaaa,...}, L((ab)*) = {ε, ab, abab, ababab,...}, L((a b)*) = {ε, a, b, aa, ab, ba, bb, aaa, aab, aba,...}, L(ε*) = {ε}

72 Kleene star L(A*) = {ε} { x 1 x 2...x n n N, x i L(A) } e.g. L(a*) = {ε, a, aa, aaa, aaaa,...}, L((ab)*) = {ε, ab, abab, ababab,...}, L((a b)*) = {ε, a, b, aa, ab, ba, bb, aaa, aab, aba,...}, L(ε*) = {ε}, L( *) =?

73 Kleene star L(A*) = {ε} { x 1 x 2...x n n N, x i L(A) } e.g. L(a*) = {ε, a, aa, aaa, aaaa,...}, L((ab)*) = {ε, ab, abab, ababab,...}, L((a b)*) = {ε, a, b, aa, ab, ba, bb, aaa, aab, aba,...}, L(ε*) = {ε}, L( *) = {ε}

Finite Automata (contd)

Finite Automata (contd) Finite Automata (contd) CS 2800: Discrete Structures, Fall 2014 Sid Chaudhuri Recap: Deterministic Finite Automaton A DFA is a 5-tuple M = (Q, Σ, δ, q 0, F) Q is a fnite set of states Σ is a fnite input

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

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

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

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

Clarifications from last time. This Lecture. Last Lecture. CMSC 330: Organization of Programming Languages. Finite Automata.

Clarifications from last time. This Lecture. Last Lecture. CMSC 330: Organization of Programming Languages. Finite Automata. CMSC 330: Organization of Programming Languages Last Lecture Languages Sets of strings Operations on languages Finite Automata Regular expressions Constants Operators Precedence CMSC 330 2 Clarifications

More information

CMSC 330: Organization of Programming Languages. Theory of Regular Expressions Finite Automata

CMSC 330: Organization of Programming Languages. Theory of Regular Expressions Finite Automata : Organization of Programming Languages Theory of Regular Expressions Finite Automata Previous Course Review {s s defined} means the set of string s such that s is chosen or defined as given s A means

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

CS 133 : Automata Theory and Computability

CS 133 : Automata Theory and Computability CS 133 : Automata Theory and Computability Lecture Slides 1 Regular Languages and Finite Automata Nestine Hope S. Hernandez Algorithms and Complexity Laboratory Department of Computer Science University

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

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

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

Outline. Nondetermistic Finite Automata. Transition diagrams. A finite automaton is a 5-tuple (Q, Σ,δ,q 0,F)

Outline. Nondetermistic Finite Automata. Transition diagrams. A finite automaton is a 5-tuple (Q, Σ,δ,q 0,F) Outline Nondeterminism Regular expressions Elementary reductions http://www.cs.caltech.edu/~cs20/a October 8, 2002 1 Determistic Finite Automata A finite automaton is a 5-tuple (Q, Σ,δ,q 0,F) Q is a finite

More information

CSC236 Week 11. Larry Zhang

CSC236 Week 11. Larry Zhang CSC236 Week 11 Larry Zhang 1 Announcements Next week s lecture: Final exam review This week s tutorial: Exercises with DFAs PS9 will be out later this week s. 2 Recap Last week we learned about Deterministic

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

FABER Formal Languages, Automata. Lecture 2. Mälardalen University

FABER Formal Languages, Automata. Lecture 2. Mälardalen University CD5560 FABER Formal Languages, Automata and Models of Computation Lecture 2 Mälardalen University 2010 1 Content Languages, g Alphabets and Strings Strings & String Operations Languages & Language Operations

More information

CMSC 330: Organization of Programming Languages

CMSC 330: Organization of Programming Languages CMSC 330: Organization of Programming Languages Theory of Regular Expressions DFAs and NFAs Reminders Project 1 due Sep. 24 Homework 1 posted Exam 1 on Sep. 25 Exam topics list posted Practice homework

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

Recap from Last Time

Recap from Last Time Regular Expressions Recap from Last Time Regular Languages A language L is a regular language if there is a DFA D such that L( D) = L. Theorem: The following are equivalent: L is a regular language. There

More information

HKN CS/ECE 374 Midterm 1 Review. Nathan Bleier and Mahir Morshed

HKN CS/ECE 374 Midterm 1 Review. Nathan Bleier and Mahir Morshed HKN CS/ECE 374 Midterm 1 Review Nathan Bleier and Mahir Morshed For the most part, all about strings! String induction (to some extent) Regular languages Regular expressions (regexps) Deterministic finite

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

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

GEETANJALI INSTITUTE OF TECHNICAL STUDIES, UDAIPUR I

GEETANJALI INSTITUTE OF TECHNICAL STUDIES, UDAIPUR I GEETANJALI INSTITUTE OF TECHNICAL STUDIES, UDAIPUR I Internal Examination 2017-18 B.Tech III Year VI Semester Sub: Theory of Computation (6CS3A) Time: 1 Hour 30 min. Max Marks: 40 Note: Attempt all three

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

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

Nondeterministic Finite Automata

Nondeterministic Finite Automata Nondeterministic Finite Automata COMP2600 Formal Methods for Software Engineering Katya Lebedeva Australian National University Semester 2, 206 Slides by Katya Lebedeva. COMP 2600 Nondeterministic Finite

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

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

Lecture Notes On THEORY OF COMPUTATION MODULE -1 UNIT - 2

Lecture Notes On THEORY OF COMPUTATION MODULE -1 UNIT - 2 BIJU PATNAIK UNIVERSITY OF TECHNOLOGY, ODISHA Lecture Notes On THEORY OF COMPUTATION MODULE -1 UNIT - 2 Prepared by, Dr. Subhendu Kumar Rath, BPUT, Odisha. UNIT 2 Structure NON-DETERMINISTIC FINITE AUTOMATA

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

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

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

Languages. A language is a set of strings. String: A sequence of letters. Examples: cat, dog, house, Defined over an alphabet:

Languages. A language is a set of strings. String: A sequence of letters. Examples: cat, dog, house, Defined over an alphabet: Languages 1 Languages A language is a set of strings String: A sequence of letters Examples: cat, dog, house, Defined over an alphaet: a,, c,, z 2 Alphaets and Strings We will use small alphaets: Strings

More information

Finite Automata Part Two

Finite Automata Part Two Finite Automata Part Two DFAs A DFA is a Deterministic Finite Automaton A DFA is defined relative to some alphabet Σ. For each state in the DFA, there must be exactly one transition defined for each symbol

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

CSC236 Week 10. Larry Zhang

CSC236 Week 10. Larry Zhang CSC236 Week 10 Larry Zhang 1 Today s Topic Deterministic Finite Automata (DFA) 2 Recap of last week We learned a lot of terminologies alphabet string length of string union concatenation Kleene star language

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

CSE 105 THEORY OF COMPUTATION

CSE 105 THEORY OF COMPUTATION CSE 105 THEORY OF COMPUTATION "Winter" 2018 http://cseweb.ucsd.edu/classes/wi18/cse105-ab/ Today's learning goals Sipser Section 1.1 Design an automaton that recognizes a given language. Specify each of

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

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

CS Automata, Computability and Formal Languages

CS Automata, Computability and Formal Languages Automata, Computability and Formal Languages Luc Longpré faculty.utep.edu/longpre 1 - Pg 1 Slides : version 3.1 version 1 A. Tapp version 2 P. McKenzie, L. Longpré version 2.1 D. Gehl version 2.2 M. Csűrös,

More information

CSE 105 Homework 1 Due: Monday October 9, Instructions. should be on each page of the submission.

CSE 105 Homework 1 Due: Monday October 9, Instructions. should be on each page of the submission. CSE 5 Homework Due: Monday October 9, 7 Instructions Upload a single file to Gradescope for each group. should be on each page of the submission. All group members names and PIDs Your assignments in this

More information

Theory of Computation

Theory of Computation Theory of Computation COMP363/COMP6363 Prerequisites: COMP4 and COMP 6 (Foundations of Computing) Textbook: Introduction to Automata Theory, Languages and Computation John E. Hopcroft, Rajeev Motwani,

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

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

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

Concatenation. The concatenation of two languages L 1 and L 2

Concatenation. The concatenation of two languages L 1 and L 2 Regular Expressions Problem Problem Set Set Four Four is is due due using using a late late period period in in the the box box up up front. front. Concatenation The concatenation of two languages L 1

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

Pushdown Automata. Reading: Chapter 6

Pushdown Automata. Reading: Chapter 6 Pushdown Automata Reading: Chapter 6 1 Pushdown Automata (PDA) Informally: A PDA is an NFA-ε with a infinite stack. Transitions are modified to accommodate stack operations. Questions: What is a stack?

More information

Finite Automata and Languages

Finite Automata and Languages CS62, IIT BOMBAY Finite Automata and Languages Ashutosh Trivedi Department of Computer Science and Engineering, IIT Bombay CS62: New Trends in IT: Modeling and Verification of Cyber-Physical Systems (2

More information

Fooling Sets and. Lecture 5

Fooling Sets and. Lecture 5 Fooling Sets and Introduction to Nondeterministic Finite Automata Lecture 5 Proving that a language is not regular Given a language, we saw how to prove it is regular (union, intersection, concatenation,

More information

CSCI 340: Computational Models. Regular Expressions. Department of Computer Science

CSCI 340: Computational Models. Regular Expressions. Department of Computer Science CSCI 340: Computational Models Regular Expressions Chapter 4 Department of Computer Science Yet Another New Method for Defining Languages Given the Language: L 1 = {x n for n = 1 2 3...} We could easily

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

Finite Automata Part Two

Finite Automata Part Two Finite Automata Part Two Recap from Last Time Old MacDonald Had a Symbol, Σ-eye-ε-ey, Oh! You may have noticed that we have several letter- E-ish symbols in CS103, which can get confusing! Here s a quick

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

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

Finite Automata. Finite Automata

Finite Automata. Finite Automata Finite Automata Finite Automata Formal Specification of Languages Generators Grammars Context-free Regular Regular Expressions Recognizers Parsers, Push-down Automata Context Free Grammar Finite State

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

Uses of finite automata

Uses of finite automata Chapter 2 :Finite Automata 2.1 Finite Automata Automata are computational devices to solve language recognition problems. Language recognition problem is to determine whether a word belongs to a language.

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

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

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

Formal Definition of a Finite Automaton. August 26, 2013

Formal Definition of a Finite Automaton. August 26, 2013 August 26, 2013 Why a formal definition? A formal definition is precise: - It resolves any uncertainties about what is allowed in a finite automaton such as the number of accept states and number of transitions

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

Classes and conversions

Classes and conversions Classes and conversions Regular expressions Syntax: r = ε a r r r + r r Semantics: The language L r of a regular expression r is inductively defined as follows: L =, L ε = {ε}, L a = a L r r = L r L r

More information

CS311 Computational Structures Regular Languages and Regular Expressions. Lecture 4. Andrew P. Black Andrew Tolmach

CS311 Computational Structures Regular Languages and Regular Expressions. Lecture 4. Andrew P. Black Andrew Tolmach CS311 Computational Structures Regular Languages and Regular Expressions Lecture 4 Andrew P. Black Andrew Tolmach 1 Expressions Weʼre used to using expressions to describe mathematical objects Example:

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 5 CHAPTER 2 FINITE AUTOMATA 1. Deterministic Finite Automata DFA 2. Nondeterministic Finite Automata NDFA 3. Finite Automata

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

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

Text Search and Closure Properties

Text Search and Closure Properties Text Search and Closure Properties CSCI 330 Formal Languages and Automata Theory Siu On CHAN Fall 208 Chinese University of Hong Kong /28 Text Search grep program grep -E regex file.txt Searches for an

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 14 SMALL REVIEW FOR FINAL SOME Y/N QUESTIONS Q1 Given Σ =, there is L over Σ Yes: = {e} and L = {e} Σ Q2 There are uncountably

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

Finite Automata Part One

Finite Automata Part One Finite Automata Part One Computability Theory What problems can we solve with a computer? What kind of computer? Computers are Messy http://en.wikipedia.org/wiki/file:eniac.jpg Computers are Messy That

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

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

MA/CSSE 474 Theory of Computation

MA/CSSE 474 Theory of Computation MA/CSSE 474 Theory of Computation CFL Hierarchy CFL Decision Problems Your Questions? Previous class days' material Reading Assignments HW 12 or 13 problems Anything else I have included some slides online

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

Text Search and Closure Properties

Text Search and Closure Properties Text Search and Closure Properties CSCI 3130 Formal Languages and Automata Theory Siu On CHAN Chinese University of Hong Kong Fall 2017 1/30 Text Search 2/30 grep program grep -E regexp file.txt Searches

More information

Formal Languages, Automata and Models of Computation

Formal Languages, Automata and Models of Computation CDT314 FABER Formal Languages, Automata and Models of Computation Lecture 5 School of Innovation, Design and Engineering Mälardalen University 2011 1 Content - More Properties of Regular Languages (RL)

More information

Regular languages, regular expressions, & finite automata (intro) CS 350 Fall 2018 gilray.org/classes/fall2018/cs350/

Regular languages, regular expressions, & finite automata (intro) CS 350 Fall 2018 gilray.org/classes/fall2018/cs350/ Regular languages, regular expressions, & finite automata (intro) CS 350 Fall 2018 gilray.org/classes/fall2018/cs350/ 1 L = {hello, bonjour, konnichiwa, } Σ = {a, b, c,, y, z}!2 Σ = {a, b, c,, y, z} Σ*

More information

1. Draw a parse tree for the following derivation: S C A C C A b b b b A b b b b B b b b b a A a a b b b b a b a a b b 2. Show on your parse tree u,

1. Draw a parse tree for the following derivation: S C A C C A b b b b A b b b b B b b b b a A a a b b b b a b a a b b 2. Show on your parse tree u, 1. Draw a parse tree for the following derivation: S C A C C A b b b b A b b b b B b b b b a A a a b b b b a b a a b b 2. Show on your parse tree u, v, x, y, z as per the pumping theorem. 3. Prove that

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

Formal Languages and Automata

Formal Languages and Automata Formal Languages and Automata 5 lectures for 2016-17 Computer Science Tripos Part IA Discrete Mathematics by Ian Leslie c 2014,2015 AM Pitts; 2016,2017 IM Leslie (minor tweaks) What is this course about?

More information

Theory of Computation Prof. Raghunath Tewari Department of Computer Science and Engineering Indian Institute of Technology, Kanpur

Theory of Computation Prof. Raghunath Tewari Department of Computer Science and Engineering Indian Institute of Technology, Kanpur Theory of Computation Prof. Raghunath Tewari Department of Computer Science and Engineering Indian Institute of Technology, Kanpur Lecture 10 GNFA to RE Conversion Welcome to the 10th lecture of this course.

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

Harvard CS 121 and CSCI E-207 Lecture 4: NFAs vs. DFAs, Closure Properties

Harvard CS 121 and CSCI E-207 Lecture 4: NFAs vs. DFAs, Closure Properties Harvard CS 121 and CSCI E-207 Lecture 4: NFAs vs. DFAs, Closure Properties Salil Vadhan September 13, 2012 Reading: Sipser, 1.2. How to simulate NFAs? NFA accepts w if there is at least one accepting computational

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

Automata Theory CS F-04 Non-Determinisitic Finite Automata

Automata Theory CS F-04 Non-Determinisitic Finite Automata Automata Theory CS411-2015F-04 Non-Determinisitic Finite Automata David Galles Department of Computer Science University of San Francisco 04-0: Non-Determinism A Deterministic Finite Automata s transition

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

Theory of Computation

Theory of Computation Fall 2002 (YEN) Theory of Computation Midterm Exam. Name:... I.D.#:... 1. (30 pts) True or false (mark O for true ; X for false ). (Score=Max{0, Right- 1 2 Wrong}.) (1) X... If L 1 is regular and L 2 L

More information

CMPSCI 250: Introduction to Computation. Lecture #23: Finishing Kleene s Theorem David Mix Barrington 25 April 2013

CMPSCI 250: Introduction to Computation. Lecture #23: Finishing Kleene s Theorem David Mix Barrington 25 April 2013 CMPSCI 250: Introduction to Computation Lecture #23: Finishing Kleene s Theorem David Mix Barrington 25 April 2013 Finishing Kleene s Theorem A Normal Form for λ-nfa s Building λ-nfa s by Induction Why

More information

Finite Automata and Regular Languages

Finite Automata and Regular Languages Finite Automata and Regular Languages Topics to be covered in Chapters 1-4 include: deterministic vs. nondeterministic FA, regular expressions, one-way vs. two-way FA, minimization, pumping lemma for regular

More information

Deterministic Finite Automaton (DFA)

Deterministic Finite Automaton (DFA) 1 Lecture Overview Deterministic Finite Automata (DFA) o accepting a string o defining a language Nondeterministic Finite Automata (NFA) o converting to DFA (subset construction) o constructed from a regular

More information

Compiler Design. Spring Lexical Analysis. Sample Exercises and Solutions. Prof. Pedro C. Diniz

Compiler Design. Spring Lexical Analysis. Sample Exercises and Solutions. Prof. Pedro C. Diniz Compiler Design Spring 2011 Lexical Analysis Sample Exercises and Solutions Prof. Pedro C. Diniz USC / Information Sciences Institute 4676 Admiralty Way, Suite 1001 Marina del Rey, California 90292 pedro@isi.edu

More information

AC68 FINITE AUTOMATA & FORMULA LANGUAGES DEC 2013

AC68 FINITE AUTOMATA & FORMULA LANGUAGES DEC 2013 Q.2 a. Prove by mathematical induction n 4 4n 2 is divisible by 3 for n 0. Basic step: For n = 0, n 3 n = 0 which is divisible by 3. Induction hypothesis: Let p(n) = n 3 n is divisible by 3. Induction

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

Constructions on Finite Automata

Constructions on Finite Automata Constructions on Finite Automata Informatics 2A: Lecture 4 Mary Cryan School of Informatics University of Edinburgh mcryan@inf.ed.ac.uk 24 September 2018 1 / 33 Determinization The subset construction

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

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

What is this course about?

What is this course about? What is this course about? Examining the power of an abstract machine What can this box of tricks do? What is this course about? Examining the power of an abstract machine Domains of discourse: automata

More information