CS 208: Computing Theory Assoc. Prof. Dr. Brahim Hnich Faculty of Computer Sciences Izmir University of Economics.

Slides:



Advertisements
Similar presentations
Non-Deterministic Finite Automata
Advertisements

CS 208: Computing Theory Assoc. Prof. Dr. Brahim Hnich Faculty of Computer Sciences Izmir University of Economics.
Complexity and Computability Theory I Lecture #4 Rina Zviel-Girshin Leah Epstein Winter
Nondeterministic Finite Automata CS 130: Theory of Computation HMU textbook, Chapter 2 (Sec 2.3 & 2.5)
8/27/2009 Sofya Raskhodnikova Intro to Theory of Computation L ECTURE 2 Theory of Computation Finite Automata Operations on languages Nondeterminism L2.1.
CS21 Decidability and Tractability
Regular operations Sipser 1.2 (pages 47-63). First… a sample proof Latex files on ella.
Introduction to Computability Theory
NFAs Sipser 1.2 (pages 47–54). CS 311 Fall Recall… Last time we showed that the class of regular languages is closed under: –Complement –Union.
NFAs and DFAs Sipser 1.2 (pages 47-63). Last time…
1 Introduction to Computability Theory Lecture2: Non Deterministic Finite Automata Prof. Amos Israeli.
1 Introduction to Computability Theory Lecture3: Regular Expressions Prof. Amos Israeli.
NFAs Sipser 1.2 (pages 47–54). CS 311 Mount Holyoke College 2 Recall… Last time we showed that the class of regular languages is closed under: –Complement.
Introduction to Computability Theory
Regular operations Sipser 1.2 (pages 47-63). First… a sample proof
Lecture 3UofH - COSC Dr. Verma 1 COSC 3340: Introduction to Theory of Computation University of Houston Dr. Verma Lecture 3.
Finite Automata and Non Determinism
CS5371 Theory of Computation
CS 310 – Fall 2006 Pacific University CS310 Finite Automata Sections:1.1 page 44 September 8, 2006.
Courtesy Costas Busch - RPI1 Non Deterministic Automata.
1 Introduction to Computability Theory Lecture2: Non Deterministic Finite Automata (cont.) Prof. Amos Israeli.
Lecture 3 Goals: Formal definition of NFA, acceptance of a string by an NFA, computation tree associated with a string. Algorithm to convert an NFA to.
Introduction to the Theory of Computation John Paxton Montana State University Summer 2003.
Foundations of (Theoretical) Computer Science Chapter 2 Lecture Notes (Section 2.2: Pushdown Automata) Prof. Karen Daniels, Fall 2009 with acknowledgement.
CSC 3130: Automata theory and formal languages Andrej Bogdanov The Chinese University of Hong Kong Nondeterminism.
Lecture 3 Goals: Formal definition of NFA, acceptance of a string by an NFA, computation tree associated with a string. Algorithm to convert an NFA to.
Fall 2006Costas Busch - RPI1 Non-Deterministic Finite Automata.
CS5371 Theory of Computation Lecture 4: Automata Theory II (DFA = NFA, Regular Language)
Costas Busch - LSU1 Non-Deterministic Finite Automata.
FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY
1 Non-Deterministic Finite Automata. 2 Alphabet = Nondeterministic Finite Automaton (NFA)
Regular Expressions (RE) Empty set Φ A RE denotes the empty set Empty string λ A RE denotes the set {λ} Symbol a A RE denotes the set {a} Alternation M.
1Computer Sciences Department. Book: INTRODUCTION TO THE THEORY OF COMPUTATION, SECOND EDITION, by: MICHAEL SIPSER Reference 3Computer Sciences Department.
REGULAR LANGUAGES.
1 Unit 1: Automata Theory and Formal Languages Readings 1, 2.2, 2.3.
Theory of Languages and Automata
Athasit Surarerks THEORY OF COMPUTATION 07 NON-DETERMINISTIC FINITE AUTOMATA 1.
Formal Definition of Computation Let M = (Q, ∑, δ, q 0, F) be a finite automaton and let w = w 1 w w n be a string where each wi is a member of the.
NFA defined. NFA A Non-deterministic Finite-state Automata (NFA) is a language recognizing system similar to a DFA. It supports a level of non-determinism.
INHERENT LIMITATIONS OF COMPUTER PROGAMS CSci 4011.
CS 208: Computing Theory Assoc. Prof. Dr. Brahim Hnich Faculty of Computer Sciences Izmir University of Economics.
Foundations of (Theoretical) Computer Science Chapter 2 Lecture Notes (Section 2.2: Pushdown Automata) Prof. Karen Daniels, Fall 2010 with acknowledgement.
CS 208: Computing Theory Assoc. Prof. Dr. Brahim Hnich Faculty of Computer Sciences Izmir University of Economics.
Donghyun (David) Kim Department of Mathematics and Physics North Carolina Central University 1 Chapter 1 Regular Languages Some slides are in courtesy.
Lecture Notes 
INHERENT LIMITATIONS OF COMPUTER PROGRAMS CSci 4011.
CSCI 4325 / 6339 Theory of Computation Zhixiang Chen.
Complexity and Computability Theory I Lecture #5 Rina Zviel-Girshin Leah Epstein Winter
1/29/02CSE460 - MSU1 Nondeterminism-NFA Section 4.1 of Martin Textbook CSE460 – Computability & Formal Language Theory Comp. Science & Engineering Michigan.
Theory of Computation Automata Theory Dr. Ayman Srour.
Nondeterminism The Chinese University of Hong Kong Fall 2011
Non Deterministic Automata
Nondeterministic Finite Automata
Finite Automata & Regular Languages
CSC 4170 Theory of Computation Nondeterminism Section 1.2.
Lecture3 DFA vs. NFA, properties of RL
Non-Deterministic Finite Automata
COSC 3340: Introduction to Theory of Computation
Non-Deterministic Finite Automata
CSE322 Definition and description of finite Automata
Nondeterministic Finite Automata
Non Deterministic Automata
Chapter Five: Nondeterministic Finite Automata
CS21 Decidability and Tractability
CSC 4170 Theory of Computation Nondeterminism Section 1.2.
Chapter 1 Regular Language
CSCI 2670 Introduction to Theory of Computing
CHAPTER 1 Regular Languages
Non Deterministic Automata
Nondeterminism The Chinese University of Hong Kong Fall 2010
Presentation transcript:

CS 208: Computing Theory Assoc. Prof. Dr. Brahim Hnich Faculty of Computer Sciences Izmir University of Economics

Automata Theory Non-Deterministic Finite Sate Machines

What about concatenation? Theorem: The class of regular languages is closed under the concatenation operation If A1 and A2 are regular languages, so is A1 o A2

Proof Idea Simulate M1 for a while, then switch to M2 BUT: when to switch? … leads us into nondeterminism

Nondeterminisim

Nondeterminism What is nondeterminisim? Several choices may exists for the next choice at any point It cannot be deduced the next state until it triggers another transition.

Nondeterminism What is nondeterminisim? A generalization of determinisim Every deterministic finite automaton is also a nondeterministic one but not the other way around!

NFA: Informal definition q1q2q3 0,11 0, ε q4 1 0,1

NFA: Informal definition A NFA may have more than one transition labeled with a symbol q1q2q3 0,11 0, ε q4 1 0,1

NFA: Informal definition A NFA may have no transitions labeled with a symbol q1q2q3 0,11 0, ε q4 1 0,1 1?

NFA: Informal definition Transition may be labeled with ε, the empty string q1q2q3 0,11 0, ε q4 1 0,1

NFA: Informal definition What happens when more than one transition is possible? The machine “splits” into multiple copies Each copy follows one possibility Together, copies follow all possibilities If the input doesn’t appear, that branch “dies” Automaton accepts if any branch accepts q1q2q3 0,11 0, ε q4 1 0,1

NFA: Informal definition What does an ε transition do? The machine “splits” into multiple copies without reading any input q1q2q3 0,11 0, ε q4 1 0,1

NFA: Informal definition What happens on string 11? q1q2q3 0,11 0, ε q4 1 0,1 q1 1 1

NFA: Informal definition What happens on string 11? q1q2q3 0,11 0, ε q4 1 0,1 q1q2 1 q1 1 1 The second 1 does not take us anywhere

NFA: Informal definition What happens on string 11? q1q2q3 0,11 0, ε q4 1 0,1 q1q2q3 1 ε q4 1 q1 1 1

Why non-determinisim? Theorem: Deterministic and non-deterministic finite automata accept exactly the same set of languages. Corollary: A language is regular if and only if some NFA accepts it Question: So why do we need them?

Why do we need NFA? NFA may be smaller than its DFA counterpart NFA are a good introduction to nondeterminism

Why do we need NFA? Challenge: Can we design a finite automaton that accepts all strings with a 1 in the third-to-the-last position? Positive examples: Negative examples:

Idea for DFA We need to remember the last 3 digits so far Why not have states representing the different configurations of the last three digits? q 000 q 001 q 100 q 101 q 010 q 011 q 110 q 111

Idea for DFA We need to remember the last 3 digits so far Which states are an accept state? q 000 q 001 q 100 q 101 q 010 q 011 q 110 q 111

Idea for DFA We need to remember the last 3 digits so far Transition function q 000 q 001 q 100 q 101 q 010 q 011 q 110 q

Idea for DFA We need to remember the last 3 digits so far Transition function q 000 q 001 q 100 q 101 q 010 q 011 q 110 q

Idea for DFA We need to remember the last 3 digits so far Transition function q 000 q 001 q 100 q 101 q 010 q 011 q 110 q

Idea for DFA It is quite a complex DFA! q 000 q 001 q 100 q 101 q 010 q 011 q 110 q

NFA How about a NFA? Because of nondeterminisim, we get a simpler automaton q1q2q3 0,11 q4 0,1

NFA How about a NFA? Because of nondeterminisim, we get a simpler automaton the automaton stays at q1 untill it “guesses” that it is three places from end, and checks it is a 1 q1q2q3 0,11 q4 0,1

NFA What happens now? q1q2q3 0,11 0, 1, ε q4 0,1, ε

NFA How many states would an equivalent DFA have? q1q2q3 0,11 0, 1, ε q4 0,1, ε

Formal Definition A non-deterministic finite automaton is a 5-tuple (Q,∑,ξ,q0,F), where Q is a finite set of states ∑ is a finite set of symbols called the alphabet ξ : Q x ∑U { ε }  P(Q) is the transition function q0 Є Q is the start state F ⊆ Q is the set of accept states or final states

Formal Definition A non-deterministic finite automaton is a 5-tuple (Q,∑,ξ,q0,F), where Q is a finite set of states ∑ is a finite set of symbols called the alphabet ξ : Q x ∑U { ε }  P(Q) is the transition function q0 Є Q is the start state F ⊆ Q is the set of accept states or final states

Example M is a NFA = (Q,∑,ξ,q1,F), where Q is a finite set of states {q1,q2,q3} ∑ is {0,1} ξ : Q x ∑U { ε }  P(Q) is the transition function q1 Є Q is the start state F ⊆ Q is {q2} q1 q2 q3 01,ε11,0 01ε01ε q1 q2 q3 {q1} {q2} {q2} {q3} {q2,q3} Ø Ø Ø Ø ξ

Formal model of computation Let M= (Q,∑,ξ,q 0,F) be a Nondeterministic Finite Automaton (NFA) Let w=w 1 w 2 …w n be a string over ∑U { ε } M accepts w if a sequence of states r 0,…,r n exist such that:  r 0 =q 0  ξ(r i,w i+1 )=r i+1, i<n  r n Є F

Closure under regular operations Let us now go back to the theorems which state that Regular languages are closed under Union Concatenation Star

Regular languages closed under union

q0 ε ε

Proof: formal details Let M1 = (Q 1,∑,ξ 1,q 1,F 1 ) accept A1 Let M2 = (Q 2,∑,ξ 2,q 2,F 2 ) accept A2 Define M = (Q,∑,ξ,q,F) as follows  Q = q0 U Q 1 U Q 2

Proof: formal details Let M1 = (Q 1,∑,ξ 1,q 1,F 1 ) accept A1 Let M2 = (Q 2,∑,ξ 2,q 2,F 2 ) accept A2 Define M = (Q,∑,ξ,q,F) as follows  …  ∑ is the same

Proof: formal details Let M1 = (Q 1,∑,ξ 1,q 1,F 1 ) accept A1 Let M2 = (Q 2,∑,ξ 2,q 2,F 2 ) accept A2 Define M = (Q,∑,ξ,q,F) as follows  …  …  ξ, the transition function is defined as follows ξ(q,a) = ξ 1 (q,a) q Є Q 1 ξ 2 (q,a) q Є Q 2 {q1, q2} q=q0 and a = ε Ø q=qo and a ≠ ε

Proof: formal details Let M1 = (Q 1,∑,ξ 1,q 1,F 1 ) accept A1 Let M2 = (Q 2,∑,ξ 2,q 2,F 2 ) accept A2 Define M = (Q,∑,ξ,q,F) as follows  …  …  …  q0 is the start state (q=q0)

Proof: formal details Let M1 = (Q 1,∑,ξ 1,q 1,F 1 ) accept A1 Let M2 = (Q 2,∑,ξ 2,q 2,F 2 ) accept A2 Define M = (Q,∑,ξ,q,F) as follows  …  …  …  …  F = F1 U F2

Regular languages closed under concatenation

ε ε

Proof: formal details Let M1 = (Q 1,∑,ξ 1,q 1,F 1 ) accept A1 Let M2 = (Q 2,∑,ξ 2,q 2,F 2 ) accept A2 Define M = (Q,∑,ξ,q,F) as follows  Q = Q 1 U Q 2

Proof: formal details Let M1 = (Q 1,∑,ξ 1,q 1,F 1 ) accept A1 Let M2 = (Q 2,∑,ξ 2,q 2,F 2 ) accept A2 Define M = (Q,∑,ξ,q,F) as follows  …  ∑ is the same

Proof: formal details Let M1 = (Q 1,∑,ξ 1,q 1,F 1 ) accept A1 Let M2 = (Q 2,∑,ξ 2,q 2,F 2 ) accept A2 Define M = (Q,∑,ξ,q,F) as follows  …  …  ξ, the transition function is defined as follows ξ(q,a) = ξ 1 (q,a) q Є Q 1 and q ∉ F1 ξ 1 (q,a) q Є F1 and a ≠ ε ξ 1 (q,a) U {q2} q Є F1 and a = ε ξ 2 (q,a) q Є Q 2

Proof: formal details Let M1 = (Q 1,∑,ξ 1,q 1,F 1 ) accept A1 Let M2 = (Q 2,∑,ξ 2,q 2,F 2 ) accept A2 Define M = (Q,∑,ξ,q,F) as follows  …  …  …  q1 is the start state (q=q1)

Proof: formal details Let M1 = (Q 1,∑,ξ 1,q 1,F 1 ) accept A1 Let M2 = (Q 2,∑,ξ 2,q 2,F 2 ) accept A2 Define M = (Q,∑,ξ,q,F) as follows  …  …  …  …  F = F2

Regular languages closed under star

ε ε ε

Proof: formal details Let M1 = (Q 1,∑,ξ 1,q 1,F 1 ) accept A1 Define M = (Q,∑,ξ,q,F) as follows  Q = {q 0 } U Q 1

Proof: formal details Let M1 = (Q 1,∑,ξ 1,q 1,F 1 ) accept A1 Let M2 = (Q 2,∑,ξ 2,q 2,F 2 ) accept A2 Define M = (Q,∑,ξ,q,F) as follows  …  ∑ is the same

Proof: formal details Let M1 = (Q 1,∑,ξ 1,q 1,F 1 ) accept A1 Define M = (Q,∑,ξ,q,F) as follows  …  …  ξ, the transition function is defined as follows ξ(q,a) = ξ 1 (q,a) q Є Q 1 and q ∉ F1 ξ 1 (q,a) q Є F1 and a ≠ ε ξ 1 (q,a) U {q1} q Є F1 and a = ε {q1} q =q 0 and a = ε Øq=q0 and a ≠ ε

Proof: formal details Let M1 = (Q 1,∑,ξ 1,q 1,F 1 ) accept A1 Define M = (Q,∑,ξ,q,F) as follows  …  …  …  q0 is the start state (q=q0)

Proof: formal details Let M1 = (Q 1,∑,ξ 1,q 1,F 1 ) accept A1 Define M = (Q,∑,ξ,q,F) as follows  …  …  …  …  F = {q0} U F1

Summary Regular languages are closed under Union Concatenation Star Non-deterministic finite automata Are equivalent to deterministic finite automata But are much easier to use in some proofs

Conclusions Nondetreministic Finite Automaton Regular Languages closed under union concatenation start Next: Regular expressions