Nondeterministic Finite Automata

Size: px
Start display at page:

Download "Nondeterministic Finite Automata"

Transcription

1 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 Automata

2 For a Deterministic Finite Automaton δ(s,a) is a unique state for all s S and for all a Σ. For a Nondeterministic Finite Automaton the transition function δ does not define a unique state, but defines a set of states. It may be the empty set be a singleton set (i.e. set with just one element) contain more than one element An NFA has the ability to be in several states at once. COMP 2600 Nondeterministic Finite Automata 2

3 Nondeterministic Finite State Automata s 0 0, start s s 2 0, COMP 2600 Nondeterministic Finite Automata 3

4 State diagram for 0 s 0 0, start s s 2 0, s 0 0 s 0 s s 2 stuck s s 2 accept! s 0 s s 0 s 0 COMP 2600 Nondeterministic Finite Automata 4

5 Informally, an NFA accepts a string if there exists at least one path in the state diagram that starts in the start state does not get stuck before the entire string has been read ends in the accepting state The fact that some choices of states using the input symbols of the string lead to a nonaccepting state, or do not lead to any state at all does not prevent the string from being accepted by the NFA. The NFA from the previous slide accepts strings that have as the second symbol from the end of the string. COMP 2600 Nondeterministic Finite Automata 5

6 A Nondeterministic Finite State Automaton (DFA) is a 5-tuple where (Σ,S,s 0,F,δ). Σ is a finite set of input symbols (the alphabet) 2. S is a finite state of states 3. s 0 is the start (or initial) state: s 0 S 4. F is a set of final (or accepting) states: F S 5. δ is a transition function such that δ : S Σ 2 S, i.e. δ takes a state in S and an input symbol in Σ as arguments and returns a subset of S. Notice that the only difference between DFA and NFA is the type of value that δ returns! COMP 2600 Nondeterministic Finite Automata 6

7 s 0 0, start s s 2 0, The NFA can be specified formally as ({0,},{s 0,s,s 2,},s 0,{s 2 },δ) where the transition function δ is given by the transition table 0 s 0 {s 0 } {s 0,s } s {s 2 } {s 2 } s 2 /0 /0 COMP 2600 Nondeterministic Finite Automata 7

8 Extended Transition Function s 0 0 s 0 s s 2 stuck s s 2 accept! s 0 s s 0 s 0 COMP 2600 Nondeterministic Finite Automata 8

9 The extended transition function of a NFA is the function δ : S Σ 2 S defined as follows: for all s S, for all a Σ, for all α Σ δ (s,ε) = {s} δ (s,αa) = p δ (s,α) δ(p, a) I.e. if δ (s,α) = {p, p 2,... p k } then δ (s,αa) = δ(p,a) δ(p 2,a) δ(p k,a) Informally: we first compute δ (s,α) and then follow any transition that is labeled with a from any of these states. COMP 2600 Nondeterministic Finite Automata 9

10 Input: 0 s 0 0, start s s 2 0,. δ (s 0,ε) = {s 0 } the basis rule! 2. δ (s 0,0) = δ(s 0,0) = {s 0 } 3. δ (s 0,0) = δ(s 0,) = {s 0,s } 4. δ (s 0,0) = δ(s 0,) δ(s,) = {s 0,s } {s 2 } = {s 0,s,s 2 } 5. δ (s 0,0) = δ(s 0,) δ(s,) δ(s 2,) = {s 0,s } {s 2 } /0 = {s 0,s,s 2 } COMP 2600 Nondeterministic Finite Automata 0

11 Different views of non-determinism The NFA always makes the right choice (of a successor state according to δ) to insure reaching the final state (if possible at all) The NFA simultaneously explores multiple paths At each nondeterministic choice point the NFA spawns off mutiple copies of itself Note: The various path/computations evolve completely independently from each other (this is different from parallel computations which may synchronise at a certain point) COMP 2600 Nondeterministic Finite Automata

12 Language accepted by an NFA If A N = (Σ,S,s 0,F,δ) is an NFA, then L(A N ) = {w δ (s 0,w) F /0} That is, L(A N ) is the set of strings w in Σ such that δ (s 0,w) contains at least one accepting state. COMP 2600 Nondeterministic Finite Automata 2

13 Equivalence of DFAs and NFAs It may be easier to construct an NFA than a DFA for a given language. However, every language that can be described by some NFA can also be described by some DFA (and vice versa)!!! If an NFA has n states, the equivalent DFA will have at most 2 n states. In most cases, the DFA has about as many states as the equivalent NFA, but more transitions. COMP 2600 Nondeterministic Finite Automata 3

14 Proof idea of the equivalence of DFAs and NFAs We have to prove: L(DFA) L(NFA) Whenever we have a DFA A D, we can construct a NFA A N such that L(A D ) = L(A N ). This is easy to show! Why? L(NFA) L(DFA) For every NFA A N there is a DFA A D such that L(A D ) = L(A N ). The proof of this direction involves Subset Construction. COMP 2600 Nondeterministic Finite Automata 4

15 Subset Construction Intuition The NFA A N can perform more than one computation on a given input string. Construct a DFA A D that runs all these different computations simultaneously: the state that A D is in after having read an initial part of the input string corresponds exactly to the set of all states that A N can reach after having read the same part of the input string COMP 2600 Nondeterministic Finite Automata 5

16 Idea for the construction of A D from A N A subset of A N s states corresponds to a state in A D : s 0 0 s 0 s s 2 stuck s s 2 accept! s 0 s s 0 s 0 0 {s 0 } {s 0 } {s 0,s } {s 0,s 2 } {s 0,s } COMP 2600 Nondeterministic Finite Automata 6

17 s 0 0, start s s 2 0, The set of states of the DFA we have to construct is associated with the set of all subsets of the states of the given NFA. /0 {s 0 } {s } {s 2 } {s 0,s } {s 0,s 2 } {s,s 2 } {s 0,s,s 2 } 0 COMP 2600 Nondeterministic Finite Automata 7

18 s 0 0, start s s 2 0, When we are in no state in the initial NFA, regardless what the input symbol is, we continue to be in no state. 0 /0 /0 /0 {s 0 } {s } {s 2 } {s 0,s } {s 0,s 2 } {s,s 2 } {s 0,s,s 2 } COMP 2600 Nondeterministic Finite Automata 8

19 s 0 0, start s s 2 0, When we in s 0 in the NFA and the input is 0, the transition function of the NFA takes us to {s 0 }. When we in s 0 in the NFA and the input is, the transition function of the NFA takes us to {s 0,s }. 0 /0 /0 /0 {s 0 } {s 0 } {s 0,s } {s } {s 2 } {s 0,s } {s 0,s 2 } {s,s 2 } {s 0,s,s 2 } COMP 2600 Nondeterministic Finite Automata 9

20 s 0 0, start s s 2 0, When we in s in the NFA and the input is 0, the transition function of the NFA takes us to {s 2 }. When we in s in the NFA and the input is, the transition function of the NFA takes us to {s 2 }. 0 /0 /0 /0 {s 0 } {s 0 } {s 0,s } {s } {s 2 } {s 2 } {s 2 } {s 0,s } {s 0,s 2 } {s,s 2 } {s 0,s,s 2 } COMP 2600 Nondeterministic Finite Automata 20

21 s 0 0, start s s 2 0, When we in s 2 in the NFA and the input is 0, the transition function of the NFA takes us to /0 (i.e. it takes us to none of the states of the NFA). When we in s in the NFA and the input is, the transition function of the NFA takes us to /0. 0 /0 /0 /0 {s 0 } {s 0 } {s 0,s } {s } {s 2 } {s 2 } {s 2 } /0 /0 {s 0,s } {s 0,s 2 } {s,s 2 } {s 0,s,s 2 } COMP 2600 Nondeterministic Finite Automata 2

22 s 0 0, start s s 2 0, Mark the start state. Mark the accepting states. Accepting states are those in which appears at least one accepting state of our NFA. 0 /0 /0 /0 {s 0 } {s 0 } {s 0,s } {s } {s 2 } {s 2 } {s 2 } /0 /0 {s 0,s } {s 0,s 2 } {s 0,s,s 2 } {s 0,s 2 } {s 0 } {s 0,s } {s,s 2 } {s 2 } {s 2 } {s 0,s,s 2 } {s 0,s 2 } {s 0,s,s 2 } COMP 2600 Nondeterministic Finite Automata 22

23 s 0 0, start s s 2 0, This transition table determines the transition function of our DFA!!! It belongs to a Deterministic Automaton! Each of these sets is a state of our DFA! 0 /0 /0 /0 {s 0 } {s 0 } {s 0,s } {s } {s 2 } {s 2 } {s 2 } /0 /0 {s 0,s } {s 0,s 2 } {s 0,s,s 2 } {s 0,s 2 } {s 0 } {s 0,s } {s,s 2 } {s 2 } {s 2 } {s 0,s,s 2 } {s 0,s 2 } {s 0,s,s 2 } COMP 2600 Nondeterministic Finite Automata 23

24 s 0 0, start s s 2 0, 0 /0 /0 /0 {s 0 } {s 0 } {s 0,s } {s } {s 2 } {s 2 } {s 2 } /0 /0 {s 0,s } {s 0,s 2 } {s 0,s,s 2 } {s 0,s 2 } {s 0 } {s 0,s } {s,s 2 } {s 2 } {s 2 } {s 0,s,s 2 } {s 0,s 2 } {s 0,s,s 2 } COMP 2600 Nondeterministic Finite Automata 24

25 s 0 0, start s s 2 0 A A A B B E C D D *D A A E F H *F B E *G D D *H F H 0, 0 A /0 A /0 A /0 B {s 0 } B {s 0 } E {s 0,s } C {s } D {s 2 } D {s 2 } *D {s 2 } A /0 A /0 E {s 0,s } F {s 0,s 2 } H {s 0,s,s 2 } *F {s 0,s 2 } B {s 0 } E {s 0,s } *G {s,s 2 } D {s 2 } D {s 2 } *H {s 0,s,s 2 } F {s 0,s 2 } H {s 0,s,s 2 } COMP 2600 Nondeterministic Finite Automata 25

26 s 0 0, start s s 2 0 0, A A A B B E C D D *D A A E F H *F B E *G D D *H F H COMP 2600 Nondeterministic Finite Automata 26

27 COMP 2600 Nondeterministic Finite Automata 27

28 0 0 A A A B B E 0 start B E F 0 0 C D D H *D A A E F H *F B E *G D D C 0, D 0, A 0, *H F H 0, G COMP 2600 Nondeterministic Finite Automata 28

29 COMP 2600 Nondeterministic Finite Automata 29

30 0 0 /0 /0 /0 {s 0 } {s 0 } {s 0,s } {s } {s 2 } {s 2 } {s 2 } /0 /0 {s 0,s } {s 0,s 2 } {s 0,s,s 2 } {s 0,s 2 } {s 0 } {s 0,s } {s,s 2 } {s 2 } {s 2 } {s 0,s,s 2 } {s 0,s 2 } {s 0,s,s 2 } start {s 0 } {s 0,s } {s 0,s } 0 0, {s 0,s,s 2 } {s } {s 2 } /0 0, 0 0 0, 0, {s,s 2 } COMP 2600 Nondeterministic Finite Automata 30

31 Formally Given A N = (Σ,S N,s 0,F N,δ N ) define A D = (Σ,S D,{s 0 },F D,δ D ) with S D = 2 S N That is S D is the set of all subsets of S N F D = {Q S N Q F N /0} That is F D is all sets of A N s states that include at least one accepting state of A N For each set Q S N and for each input symbol a in Σ δ D (Q,a) = p Qδ N (p,a) That is δ D (Q,a) is the set of states of A N reachable in A N from one of the states in Q via a COMP 2600 Nondeterministic Finite Automata 3

32 COMP 2600 Nondeterministic Finite Automata 32

33 0 start {s 0 } {s 0,s } {s 0,s } {s 0,s,s 2 } 0, 0, {s } {s 2 } /0 0, 0, {s,s 2 } COMP 2600 Nondeterministic Finite Automata 33

34 Lazy evaluation on subsets for constructing A D We eliminated states that cannot be accessed from the start state! Can we avoid constructing the inaccessible part of the DFA? Yes! As follows: start {s 0 } {s 0,s } {s 0,s } 0 0 {s 0,s,s 2 } 0 0 Basis: The singleton set consisting only of the start state of A N is accessible. Induction: Suppose we determined that the set Q of states is accessible. Then for each input symbol a, compute the set of states δ D (Q,a). These sets of states will also be accessible. COMP 2600 Nondeterministic Finite Automata 34

35 Comment on the comment during the lecture whether it is δ D or δ N. The point is that we are constructing δ D via δ N. Particularly, for each a Σ, we compute δ D (Q,a) as δ N (p,a). p Q COMP 2600 Nondeterministic Finite Automata 35

36 s 0 0, start s s 2 0, s 0 is the start state of A N. Therefore, {s 0 } is the start state of A D. Look at the transition diagram of A N. Observe that on 0 there is only one arrow from s 0, and it goes to s 0. Therefore, δ D ({s 0 },0) = {s 0 }. Observe that on there are two arrow from s 0 that go to s 0 and s. Therefore, δ D ({s 0 },) = {s 0,s }. One of the sets we constructed - the set {s 0 } has just been analysed! We only need to analyse {s 0,s } and compute its transitions! COMP 2600 Nondeterministic Finite Automata 36

37 s 0 0, start s s 2 0, What is δ D ({s 0,s },0)? δ D ({s 0,s },0) = δ N (s 0,0) δ N (s,0) = {s 0 } {s 2 } = {s 0,s 2 } What is δ D ({s 0,s },)? δ D ({s 0,s },) = δ N (s 0,) δ N (s,) = {s 0,s } {s 2 } = {s 0,s,s 2 } COMP 2600 Nondeterministic Finite Automata 37

38 s 0 0, start s s 2 0, What is δ D ({s 0,s 2 },0)? δ D ({s 0,s 2 },0) = δ N (s 0,0) δ N (s 2,0) = {s 0 } /0 = {s 0 } What is δ D ({s 0,s 2 },)? δ D ({s 0,s 2 },) = δ N (s 0,) δ N (s 2,) = {s 0,s } /0 = {s 0,s } Both sets {s 0 } and {s 0,s } have already be analysed. But we still have set {s 0,s,s 2 } that we accessed on the previous slide and that awaits analysis! COMP 2600 Nondeterministic Finite Automata 38

39 s 0 0, start s s 2 0, What is δ D ({s 0,s,s 2 },0)? δ D ({s 0,s,s 2 },0) = δ N (s 0,0) δ N (s,0) δ N (s,0) = {s 0 } {s 2 } /0 = {s 0,s 2 } What is δ D ({s 0,s,s 2 },)? δ D ({s 0,s,s 2 },) = δ N (s 0,) δ N (s,) δ N (s 2,) = {s 0,s } {s 2 } /0 = {s 0,s,s 2 } All accessible sets have been analysed! We can draw A D now! COMP 2600 Nondeterministic Finite Automata 39

Deterministic Finite Automata

Deterministic Finite Automata Deterministic Finite Automata COMP2600 Formal Methods for Software Engineering Katya Lebedeva Australian National University Semester 2, 2016 Slides by Ranald Clouston and Katya Lebedeva. COMP 2600 Deterministic

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Formal Language and Automata Theory (CS21004)

Formal Language and Automata Theory (CS21004) Theory (CS21004) Announcements The slide is just a short summary Follow the discussion and the boardwork Solve problems (apart from those we dish out in class) Table of Contents 1 2 3 Languages that are

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

Java II Finite Automata I

Java II Finite Automata I Java II Finite Automata I Bernd Kiefer Bernd.Kiefer@dfki.de Deutsches Forschungszentrum für künstliche Intelligenz November, 23 Processing Regular Expressions We already learned about Java s regular expression

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

Nondeterministic Finite Automata

Nondeterministic Finite Automata Nondeterministic Finite Automata Lecture 6 Section 2.2 Robb T. Koether Hampden-Sydney College Mon, Sep 5, 2016 Robb T. Koether (Hampden-Sydney College) Nondeterministic Finite Automata Mon, Sep 5, 2016

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

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

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

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

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

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

Nondeterministic Finite Automata and Regular Expressions

Nondeterministic Finite Automata and Regular Expressions Nondeterministic Finite Automata and Regular Expressions CS 2800: Discrete Structures, Spring 2015 Sid Chaudhuri Recap: Deterministic Finite Automaton A DFA is a 5-tuple M = (Q, Σ, δ, q 0, F) Q is a finite

More information

NFA and regex. the Boolean algebra of languages. regular expressions. Informatics 1 School of Informatics, University of Edinburgh

NFA and regex. the Boolean algebra of languages. regular expressions. Informatics 1 School of Informatics, University of Edinburgh NFA and regex cl the Boolean algebra of languages regular expressions Informatics The intersection of two regular languages is regular L = even numbers L = odd numbers L = mod L = mod Informatics The intersection

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

Nondeterminism and Epsilon Transitions

Nondeterminism and Epsilon Transitions Nondeterminism and Epsilon Transitions Mridul Aanjaneya Stanford University June 28, 22 Mridul Aanjaneya Automata Theory / 3 Challenge Problem Question Prove that any square with side length a power of

More information

Let us first give some intuitive idea about a state of a system and state transitions before describing finite automata.

Let us first give some intuitive idea about a state of a system and state transitions before describing finite automata. Finite Automata Automata (singular: automation) are a particularly simple, but useful, model of computation. They were initially proposed as a simple model for the behavior of neurons. The concept of a

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 (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

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

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

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

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

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

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

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

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

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

Deterministic Finite Automata

Deterministic Finite Automata Deterministic Finite Automata COMP2600 Formal Methods for Software Engineering Ranald Clouston Australian National University Semester 2, 2013 COMP 2600 Deterministic Finite Automata 1 Pop quiz What is

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

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

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

CS 208: Automata Theory and Logic

CS 208: Automata Theory and Logic CS 28: Automata Theory and Logic b a a start A x(la(x) y(x < y) L b (y)) B b Department of Computer Science and Engineering, Indian Institute of Technology Bombay of 32 Nondeterminism Alternation 2 of

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

C2.1 Regular Grammars

C2.1 Regular Grammars Theory of Computer Science March 22, 27 C2. Regular Languages: Finite Automata Theory of Computer Science C2. Regular Languages: Finite Automata Malte Helmert University of Basel March 22, 27 C2. Regular

More information

Algorithms for NLP

Algorithms for NLP Regular Expressions Chris Dyer Algorithms for NLP 11-711 Adapted from materials from Alon Lavie Goals of Today s Lecture Understand the properties of NFAs with epsilon transitions Understand concepts and

More information

C2.1 Regular Grammars

C2.1 Regular Grammars Theory of Computer Science March 6, 26 C2. Regular Languages: Finite Automata Theory of Computer Science C2. Regular Languages: Finite Automata Malte Helmert University of Basel March 6, 26 C2. Regular

More information

Finite Automata. Wen-Guey Tzeng Computer Science Department National Chiao Tung University

Finite Automata. Wen-Guey Tzeng Computer Science Department National Chiao Tung University Finite Automata Wen-Guey Tzeng Computer Science Department National Chiao Tung University Syllabus Deterministic finite acceptor Nondeterministic finite acceptor Equivalence of DFA and NFA Reduction of

More information

CSE 311: Foundations of Computing. Lecture 23: Finite State Machine Minimization & NFAs

CSE 311: Foundations of Computing. Lecture 23: Finite State Machine Minimization & NFAs CSE : Foundations of Computing Lecture : Finite State Machine Minimization & NFAs State Minimization Many different FSMs (DFAs) for the same problem Take a given FSM and try to reduce its state set by

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

Finite Automata. Seungjin Choi

Finite Automata. Seungjin Choi Finite Automata Seungjin Choi Department of Computer Science and Engineering Pohang University of Science and Technology 77 Cheongam-ro, Nam-gu, Pohang 37673, Korea seungjin@postech.ac.kr 1 / 28 Outline

More information

Chapter Two: Finite Automata

Chapter Two: Finite Automata Chapter Two: Finite Automata In theoretical computer science, automata theory is the study of abstract machines (or more appropriately, abstract 'mathematical' machines or systems) and the computational

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

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

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

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

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

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

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

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

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

CS 322 D: Formal languages and automata theory

CS 322 D: Formal languages and automata theory CS 322 D: Formal languages and automata theory Tutorial NFA DFA Regular Expression T. Najla Arfawi 2 nd Term - 26 Finite Automata Finite Automata. Q - States 2. S - Alphabets 3. d - Transitions 4. q -

More information

Finite Universes. L is a fixed-length language if it has length n for some

Finite Universes. L is a fixed-length language if it has length n for some Finite Universes Finite Universes When the universe is finite (e.g., the interval 0, 2 1 ), all objects can be encoded by words of the same length. A language L has length n 0 if L =, or every word of

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

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

Chapter 2: Finite Automata

Chapter 2: Finite Automata Chapter 2: Finite Automata Peter Cappello Department of Computer Science University of California, Santa Barbara Santa Barbara, CA 93106 cappello@cs.ucsb.edu Please read the corresponding chapter before

More information

CSE 311 Lecture 23: Finite State Machines. Emina Torlak and Kevin Zatloukal

CSE 311 Lecture 23: Finite State Machines. Emina Torlak and Kevin Zatloukal CSE 3 Lecture 3: Finite State Machines Emina Torlak and Kevin Zatloukal Topics Finite state machines (FSMs) Definition and examples. Finite state machines with output Definition and examples. Finite state

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

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

Lecture 2: Regular Expression

Lecture 2: Regular Expression Lecture 2: Regular Expression Instructor: Ketan Mulmuley Scriber: Yuan Li January 8, 2015 In the last lecture, we proved that DFA, NFA, and NFA with ϵ-moves are equivalent. Recall that a language L Σ is

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

Finite Automata. Mahesh Viswanathan

Finite Automata. Mahesh Viswanathan Finite Automata Mahesh Viswanathan In this lecture, we will consider different models of finite state machines and study their relative power. These notes assume that the reader is familiar with DFAs,

More information

(Refer Slide Time: 0:21)

(Refer Slide Time: 0:21) Theory of Computation Prof. Somenath Biswas Department of Computer Science and Engineering Indian Institute of Technology Kanpur Lecture 7 A generalisation of pumping lemma, Non-deterministic finite automata

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

Theory of Computation

Theory of Computation Thomas Zeugmann Hokkaido University Laboratory for Algorithmics http://www-alg.ist.hokudai.ac.jp/ thomas/toc/ Lecture 3: Finite State Automata Motivation In the previous lecture we learned how to formalize

More information

Finite Automata. Warren McCulloch ( ) and Walter Pitts ( )

Finite Automata. Warren McCulloch ( ) and Walter Pitts ( ) 2 C H A P T E R Finite Automata Warren McCulloch (898 968) and Walter Pitts (923 969) Warren S. McCulloch was an American psychiatrist and neurophysiologist who co-founded Cybernetics. His greatest contributions

More information

Deterministic (DFA) There is a fixed number of states and we can only be in one state at a time

Deterministic (DFA) There is a fixed number of states and we can only be in one state at a time CS35 - Finite utomata This handout will describe finite automata, a mechanism that can be used to construct regular languages. We ll describe regular languages in an upcoming set of lecture notes. We will

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

Pushdown automata. Twan van Laarhoven. Institute for Computing and Information Sciences Intelligent Systems Radboud University Nijmegen

Pushdown automata. Twan van Laarhoven. Institute for Computing and Information Sciences Intelligent Systems Radboud University Nijmegen Pushdown automata Twan van Laarhoven Institute for Computing and Information Sciences Intelligent Systems Version: fall 2014 T. van Laarhoven Version: fall 2014 Formal Languages, Grammars and Automata

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

Formal Models in NLP

Formal Models in NLP Formal Models in NLP Finite-State Automata Nina Seemann Universität Stuttgart Institut für Maschinelle Sprachverarbeitung Pfaffenwaldring 5b 70569 Stuttgart May 15, 2012 Nina Seemann (IMS) Formal Models

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

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

Constructions on Finite Automata

Constructions on Finite Automata Constructions on Finite Automata Informatics 2A: Lecture 4 Alex Simpson School of Informatics University of Edinburgh als@inf.ed.ac.uk 23rd September, 2014 1 / 29 1 Closure properties of regular languages

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

Regular Language Equivalence and DFA Minimization. Equivalence of Two Regular Languages DFA Minimization

Regular Language Equivalence and DFA Minimization. Equivalence of Two Regular Languages DFA Minimization Regular Language Equivalence and DFA Minimization Equivalence of Two Regular Languages DFA Minimization Decision Property: Equivalence Given regular languages L and M, is L = M? Algorithm involves constructing

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

Chapter 2. Finite Automata. (part A) (2015/10/20) Hokkaido, Japan

Chapter 2. Finite Automata. (part A) (2015/10/20) Hokkaido, Japan Chapter 2 Finite utomata (part ) (25//2) Hokkaido, Japan Outline 2 Introduction 2 n Informal Picture of Finite utomata 22 Deterministic Finite automata 23 Nondeterministic Finite utomata 24 n pplication:

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

Chapter 6: NFA Applications

Chapter 6: NFA Applications Chapter 6: NFA Applications Implementing NFAs The problem with implementing NFAs is that, being nondeterministic, they define a more complex computational procedure for testing language membership. To

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

Homomorphisms and Efficient State Minimization

Homomorphisms and Efficient State Minimization Homomorphisms and Efficient State Minimization Mridul Aanjaneya Stanford University July 10, 2012 Mridul Aanjaneya Automata Theory 1/ 23 Homomorphisms A homomorphism on an alphabet is a function that gives

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