Theory of Computing Lecture 22 MAS 714 Hartmut Klauck.

Slides:



Advertisements
Similar presentations
Theory of Computing Lecture 23 MAS 714 Hartmut Klauck.
Advertisements

CSE 311 Foundations of Computing I
4b Lexical analysis Finite Automata
Lecture 24 MAS 714 Hartmut Klauck
Lecture 6 Nondeterministic Finite Automata (NFA)
1 1 CDT314 FABER Formal Languages, Automata and Models of Computation Lecture 3 School of Innovation, Design and Engineering Mälardalen University 2012.
FORMAL LANGUAGES, AUTOMATA, AND COMPUTABILITY
1 Languages. 2 A language is a set of strings String: A sequence of letters Examples: “cat”, “dog”, “house”, … Defined over an alphabet: Languages.
CS21 Decidability and Tractability
Introduction to Computability Theory
1 Introduction to Computability Theory Lecture3: Regular Expressions Prof. Amos Israeli.
Finite Automata Great Theoretical Ideas In Computer Science Anupam Gupta Danny Sleator CS Fall 2010 Lecture 20Oct 28, 2010Carnegie Mellon University.
1 Introduction to Computability Theory Lecture2: Non Deterministic Finite Automata Prof. Amos Israeli.
1 Introduction to Computability Theory Lecture3: Regular Expressions Prof. Amos Israeli.
Introduction to Computability Theory
Introduction to Computability Theory
Lecture 3UofH - COSC Dr. Verma 1 COSC 3340: Introduction to Theory of Computation University of Houston Dr. Verma Lecture 3.
1 FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY (For next time: Read Chapter 1.3 of the book)
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.
CSC 3130: Automata theory and formal languages Andrej Bogdanov The Chinese University of Hong Kong Regular.
1 Languages and Finite Automata or how to talk to machines...
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
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 language,
1 Unit 1: Automata Theory and Formal Languages Readings 1, 2.2, 2.3.
Theory of Computation, Feodor F. Dragan, Kent State University 1 Regular expressions: definition An algebraic equivalent to finite automata. We can build.
4b 4b Lexical analysis Finite Automata. Finite Automata (FA) FA also called Finite State Machine (FSM) –Abstract model of a computing entity. –Decides.
Theory of Computing Lecture 21 MAS 714 Hartmut Klauck.
1 CD5560 FABER Formal Languages, Automata and Models of Computation Lecture 3 Mälardalen University 2010.
CHAPTER 1 Regular Languages
Foundations of (Theoretical) Computer Science Chapter 2 Lecture Notes (Section 2.2: Pushdown Automata) Prof. Karen Daniels, Fall 2010 with acknowledgement.
The decidability of Presburger Arithmetic By Guillermo Guillen 04/13/05 Dr. Smith COT 6421 FIU Spring 2005.
Lecture Notes 
Algorithms for hard problems Automata and tree automata Juris Viksna, 2015.
Finite Automata Great Theoretical Ideas In Computer Science Victor Adamchik Danny Sleator CS Spring 2010 Lecture 20Mar 30, 2010Carnegie Mellon.
CSCI 4325 / 6339 Theory of Computation Zhixiang Chen.
Complexity and Computability Theory I Lecture #5 Rina Zviel-Girshin Leah Epstein Winter
 2005 SDU Lecture11 Decidability.  2005 SDU 2 Topics Discuss the power of algorithms to solve problems. Demonstrate that some problems can be solved.
1/29/02CSE460 - MSU1 Nondeterminism-NFA Section 4.1 of Martin Textbook CSE460 – Computability & Formal Language Theory Comp. Science & Engineering Michigan.
Languages.
Lexical analysis Finite Automata
Non Deterministic Automata
PROPERTIES OF REGULAR LANGUAGES
CSE 105 theory of computation
Chapter 2 FINITE AUTOMATA.
Hierarchy of languages
Lecture3 DFA vs. NFA, properties of RL
Non-Deterministic Finite Automata
CS 154, Lecture 3: DFANFA, Regular Expressions.
COSC 3340: Introduction to Theory of Computation
4. Properties of Regular Languages
Non-Deterministic Finite Automata
Non Deterministic Automata
CSE 311: Foundations of Computing
Finite Automata.
4b Lexical analysis Finite Automata
Chapter Five: Nondeterministic Finite Automata
FORMAL LANGUAGES, AUTOMATA, AND COMPUTABILITY
CS21 Decidability and Tractability
4b Lexical analysis Finite Automata
CS21 Decidability and Tractability
CSE 311 Foundations of Computing I
Chapter 1 Regular Language
CSCI 2670 Introduction to Theory of Computing
CHAPTER 1 Regular Languages
Presentation transcript:

Theory of Computing Lecture 22 MAS 714 Hartmut Klauck

Nondeterministic Finite Automata Definition: – A nondeterministic finite automaton (NFA) is defined like a DFA, except that there are possibly several transitions from a pair (state, letter) [but at least one] – For the graph this means that there are several edges from state q labeled with letter a – Acceptance if there is a path to an accepting state Note: variants include: allow ² transitions (transition without reading) and incomplete edge sets (input gets stuck/leads to no state)

Example Language that contains all strings having a 1 in the third position from the end

A note There is no good `guess and check’ definition of NFA One can prove that NFA cannot do all the nondeterministic guesses at the beginning of the computation and then just proceed deterministically – Reason: can store only O(1) guesses in the internal state, which is not enough

DFA vs. NFA Theorem: The set of languages that can be decided by NFA is equal to the set of regular languages Proof: Take any NFA A. We have to find a DFA that decides the same language as A Idea: power-set construction: – use one state for every nonempty subset of states of A – After reading a string x the DFA will be in the state that the set of reachable states of A (on x)

Proof A has s states, simulating DFA M has 2 s -1 states Starting state: {q 0 } Accepting states of M: those that contain an accepting state of A Edges: Consider a state {q 1,…, q k } of M. There is an edge labeled with letter a to the state which is the union of the ± (q i,a) for i=1…k Claim: The computation in M on input x ends in the state s that is the set of states in A that can be reached on x – Proof by induction Then: M accepts x iff A accepts x

DFA vs. NFA Hence every language L decided by an NFA is regular, and there is a DFA for L that is at most exponentially larger than the smallest NFA This is also best possible Note that the size (number of states) of the NFA/DFA is a constant (independent of the input length)

Languages that are not regular Intuitively, DFA cannot count We will see that languages like {0 n 1 n :n is a natural number} are not regular To show this we simulate DFA by a communication game Game is equivalent to the Myhill-Nerode method Most common approach: pumping lemma – much less general

The game Two players, Alice and Bob Alice receives an input x 2 § * Bob receives y 2 § * Alice sends a message to Bob, who decides whether x ± y 2 L – ± : concatenation, we will also just write xy Cost of the game: number of messages used

Example L={0 n 1 n : n is natural} How many messages are needed? Alice has an input x If x contains a 1 before a 0, or x=0 n 1 n+k she sends the message `reject’ Otherwise 2 cases: – Alice has 0 k : she sends the message `0,k’ – Alice has 0 n 1 k : she sends the message `1,n-k’ Bob can decide if xy is in L from the message and y These are infinitely many different messages! We can still count the number of messages as a function of the input length m, number of different messages is O(m)

Example 2 Parity={w: w has odd number of 1’s} Alice sends the number of 1’s in her part of the input modulo 2 2 messages: 0/1 Bob accepts if the message bit is different from the number of 1’s in his input modulo2

Example 3 L={w: third last symbol of w is 1}, alphabet={0,1} Alice sends last 3 symbols of her input x (if possible) Otherwise: – If x=ab, she sends the message for 0ab – If x=a she sends message for 00a – If x is the empty string she sends 000 Total: 8 messages

Example 3 L={w: third last symbol of w is 1}, alphabet={0,1} Correctness of the protocol: – Given message abc Bob can append his input y and check if the third last symbol of abcy is 1 – If Alice’s input has length 1 or 2 then ab=00 resp. a=0 DFA with 8 states exists (see next theorem) – Will show later: no DFA for L has less than 8 states

DFA and the game Theorem [DFA vs. game]: – If L is regular, then the optimal number of messages in the game is equal to the smallest number of states in a DFA. – If L is not regular, then the smallest number of messages is infinite

Application How to show that we need many messages? Consider the infinite matrix M, rows labeled with all possible x and columns labeled with all possible y and M[x,y]=1 iff xy 2 L Call this matrix the communication matrix of L Lemma: The minimum number of messages in the game is equal to the number of distinct rows in the matrix

Proof Two rows labeled x, x’ are distinct if there is a column y where M[x,y]=1 and M[x’,y]=0 – or vice versa If Alice sends the same message on x and x’ then Bob cannot distinguish them, so there is an error either on xy or on x’y On the other hand it is enough for Alice to send the same message on x, x’ if they their rows are not distinct

Examples Parity: M has only two distinct rows {0 n 1 n }: – Consider the rows of M labeled 0 k for all k=1,…, 1 – The rows are all different [the row for 0 k has a 1 only in column 1 k ] Conclusion: {0 n 1 n : n natural} is not a regular language

Example {w: third last symbol of w is 1} Consider the rows labelled by all strings of length 3 over {0,1} – 8 such rows Easy to see that these rows are all distinct Hence no DFA for the language can have less than 8 states