Lecture 24 MAS 714 Hartmut Klauck

Slides:



Advertisements
Similar presentations
Recognising Languages We will tackle the problem of defining languages by considering how we could recognise them. Problem: Is there a method of recognising.
Advertisements

NP-Hard Nattee Niparnan.
Theory of Computing Lecture 23 MAS 714 Hartmut Klauck.
CSE 311 Foundations of Computing I
4b Lexical analysis Finite Automata
Finite Automata CPSC 388 Ellen Walker Hiram College.
1 1 CDT314 FABER Formal Languages, Automata and Models of Computation Lecture 3 School of Innovation, Design and Engineering Mälardalen University 2012.
Complexity 15-1 Complexity Andrei Bulatov Hierarchy Theorem.
Complexity 11-1 Complexity Andrei Bulatov Space Complexity.
1 Introduction to Computability Theory Lecture12: Decidable Languages Prof. Amos Israeli.
1 Introduction to Computability Theory Lecture12: Reductions 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 Lecture3: Regular Expressions Prof. Amos Israeli.
Costas Busch - RPI1 Single Final State for NFAs. Costas Busch - RPI2 Any NFA can be converted to an equivalent NFA with a single final state.
Fall 2006Costas Busch - RPI1 Regular Expressions.
1 Regular Expressions. 2 Regular expressions describe regular languages Example: describes the language.
Fall 2004COMP 3351 Single Final State for NFA. Fall 2004COMP 3352 Any NFA can be converted to an equivalent NFA with a single final state.
1 Single Final State for NFAs and DFAs. 2 Observation Any Finite Automaton (NFA or DFA) can be converted to an equivalent NFA with a single final state.
Fall 2006Costas Busch - RPI1 Non-Deterministic Finite Automata.
CS5371 Theory of Computation Lecture 4: Automata Theory II (DFA = NFA, Regular Language)
Theory of Computing Lecture 20 MAS 714 Hartmut Klauck.
Theory of Computing Lecture 22 MAS 714 Hartmut Klauck.
Costas Busch - LSU1 Non-Deterministic Finite Automata.
1 A Single Final State for Finite Accepters. 2 Observation Any Finite Accepter (NFA or DFA) can be converted to an equivalent NFA with a single final.
Fall 2004COMP 3351 Regular Expressions. Fall 2004COMP 3352 Regular Expressions Regular expressions describe regular languages Example: describes the language.
Final Exam Review Cummulative Chapters 0, 1, 2, 3, 4, 5 and 7.
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,
Nattee Niparnan. Easy & Hard Problem What is “difficulty” of problem? Difficult for computer scientist to derive algorithm for the problem? Difficult.
Theory of Computing Lecture 15 MAS 714 Hartmut Klauck.
Theory of Computing Lecture 17 MAS 714 Hartmut Klauck.
4b 4b Lexical analysis Finite Automata. Finite Automata (FA) FA also called Finite State Machine (FSM) –Abstract model of a computing entity. –Decides.
COMP3190: Principle of Programming Languages DFA and its equivalent, scanner.
Theory of Computing Lecture 21 MAS 714 Hartmut Klauck.
Lecture # 12. Nondeterministic Finite Automaton (NFA) Definition: An NFA is a TG with a unique start state and a property of having single letter as label.
CS 203: Introduction to Formal Languages and Automata
Strings Basic data type in computational biology A string is an ordered succession of characters or symbols from a finite set called an alphabet Sequence.
UNIT - I Formal Language and Regular Expressions: Languages Definition regular expressions Regular sets identity rules. Finite Automata: DFA NFA NFA with.
Transparency No. 4-1 Formal Language and Automata Theory Chapter 4 Patterns, Regular Expressions and Finite Automata (include lecture 7,8,9) Transparency.
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
The NP class. NP-completeness Lecture2. The NP-class The NP class is a class that contains all the problems that can be decided by a Non-Deterministic.
COMP3190: Principle of Programming Languages DFA and its equivalent, scanner.
CSCI 3130: Formal languages and automata theory Andrej Bogdanov The Chinese University of Hong Kong Decidable.
Lecture 15: Theory of Automata:2014 Finite Automata with Output.
Topic 3: Automata Theory 1. OutlineOutline Finite state machine, Regular expressions, DFA, NDFA, and their equivalence, Grammars and Chomsky hierarchy.
Lexical analysis Finite Automata
Non Deterministic Automata
PROPERTIES OF REGULAR LANGUAGES
Busch Complexity Lectures: Reductions
CSE 105 theory of computation
Single Final State for NFA
CSE 105 theory of computation
Non-Deterministic Finite Automata
CS 154, Lecture 3: DFANFA, Regular Expressions.
4. Properties of Regular Languages
Non-Deterministic Finite Automata
Decidable Languages Costas Busch - LSU.
Minimal DFA Among the many DFAs accepting the same regular language L, there is exactly one (up to renaming of states) which has the smallest possible.
Chapter Nine: Advanced Topics in Regular Languages
4b Lexical analysis Finite Automata
4b Lexical analysis Finite Automata
Instructor: Aaron Roth
Instructor: Aaron Roth
Chapter 1 Regular Language
CSE 105 theory of computation
Lexical Analysis Uses formalism of Regular Languages
CSE 105 theory of computation
Presentation transcript:

Lecture 24 MAS 714 Hartmut Klauck Theory of Computing Lecture 24 MAS 714 Hartmut Klauck

Size of Automata? We know L is regular, if there is a DFA with a finite number of states for L Minimum number of states is the Myhill-Nerode Index Questions: How can we find a minimal DFA for L? Is it unique (up to renaming states)? Are NFA smaller than DFA? Are two-way DFA smaller than DFA?

Question 4 Consider the language L={xi : x2{0,1}n and i2{0,1} log n and xi=1} n is fix, this is a finite language It is easy to see that there are 2n rows in the communication matrix Rows labeled x contain the string on columns i=1…n Hence any DFA for L has 2n states. Can give a 2-way DFA with O(n2) states: go to the right end of the input, read i into the state, move n-i steps left, accept if there is a 1

Question 3 Consider L={xy: x,y 2 {0,1}n, x  y} This is a FINITE language, n is fixed Exercise: there is an NFA with O(n2) states for L DFA-size: the matrix has more than 2n distinct rows DFA size is exponential Hence NFA can be exponentially smaller than DFA for some languages Example where they are not: complement of L

2) Uniqueness Uniqueness of the minimal DFA (up to vertex names) follows from the Myhill-Nerode characterization The optimal DFA has exactly one state for each set of equal rows of the comm. matrix Edges are also determined uniquely

1) Optimal DFA Theorem: For every regular L there is a unique DFA A that has minimum size. Given a DFA M for L we can find A in polynomial time. Corollary: Given DFA A,B we can decide in polynomial time whether they compute the same language Minimize DFA, compare graphs (note that this is not an instance of the (hard) graph isomorphism problem, since we know the starting state and edge labels) Corollary: Given DFA A, we can decide in polynomial time whether LA is empty

Note The corresponding questions for Turing machines are undecidable These properties (easy to find unique representation, easy to find small representation, easy to check for emptiness and easy to compare) make DFA a good data-structure for languages/Boolean functions

DFA Minimization All algorithms try to recover equivalence classes in the Myhill-Nerode characterization I.e., try to find the smallest partition of the rows of the communication matrix into equal rows Input: DFA with n states and alphabet size k Hopcroft: O(nk log n) Moore: O(n2k) Idea in both: Start from partition of states into accepting/rejecting Refine partition until no longer possible

Proof We are given a DFA M with n states and alphabet size k Want to find an optimal DFA A First: remove unreachable states unreachable means in the graph, cannot be reached from q0 on any input Identify them with DFS from the starting state Equivalent states: q,q’ are equivalent, if all strings y, starting from q or q’ lead to the same result (acc/rej) can assume |y|< n, otherwise y contains a loop in M equivalent states have the same row in the communication matrix

A simple algorithm Algorithm: Remove unreachable states Build a n£n matrix D that containing blank entries For all rows q, and columns q’, where q2 F and q’ is not, set D[q,q’]=D[q’,q]=² Iterate [until nothing to do, at most n times] Loop over all letters a and all pairs q,q’ with D[q,q’] blank If D[±(q,a),±(q’,a)] is not blank, set D[q,q’]=a Join states q,q’ that have D[q,q’] still blank

A simple algorithm D allows us to find a witness that q,q’ are not equivalent: D[q,q’]=a, then find recursively the witness y for ±(q,a) and ±(q’,a), witness for q,q’ is ay Follow ay from q and from q’, one leads to accept, the other to reject Witnesses need not be longer than n-1 If no witness exists, then q,q’ are equivalent by definition of equivalence

Time Each iteration takes time O(n2k) If q and q’ are not equivalent, a witness of length no more than n-1 can be found, i.e., number of iterations is at most n-1 typically much less: longest simple path in DFA

Correctness All q,q’ with D[q,q’] not blank are not equivalent Claim: algo will find a witness for non-equivalent q,q’ Induction over length of witness length 0: in first iteration Assume length k witnesses are found in k iterations If q,q’ are not equivalent, and there is a string ay of length k such that ±(q,ay) accepts, ±(q’,ay) rejects, then some witness y’ for ±(q,a) and ±(q’,a) of length k-1 is found earlier ay’ is a witness and found in iteration k Claim: all equivalent states will never be declared not equivalent Clear from the witness computed

Minimizing NFA? NFA are frequently smaller than DFA Can we minimize their size? Theorem: NFA-minimization is PSPACE-hard This remains true if the input is a DFA but we search the smallest NFA Even approximation is hard

Conclusion DFA can be transformed into unique minimal DFA in polynomial time Can then compare, decide emptiness etc. NFA and 2-way DFA/NFA can be exponentially smaller, but cannot be minimized efficiently Limits of DFA: Communication method

Regular Languages (Definition 2) Simple recursive description of languages Definition: Regular expression over alphabet § a2§ is a r.e. The empty word ² is a r.e. ; is a r.e. [empty set] R1[ R2 is regular [union] Notation: r1 | r2 R1R2 is regular [concatenation] R1* is regular [Kleene]

Examples 0*10*: strings with one 1 §* 1§*: strings with at least one 1 (§§)*: even length 1*(011*)*: every 0 followed by a 1 (0*10*10*)*: even number of 1’s 0*|1*: contains only 0’s or only 1’s

Regular vs. DFA Definition: a language describable by a regular expression is called regular Theorem: The set of regular languages is the same set as the set of languages decidable by DFA Proof: We show NFA can simulate regular expression Regular expression can be constructed from DFA

Regular to NFA Consider an NFA with ² transitions Edges can be labeled with ² (empty word) Exercise: NFA with ² transitions can be transformed into NFA, same number of states R a regular expression Inductively find an NFA for R Basis cases: R=², R=a2§, R=; NFA is trivial (at most 3 states) Induction: Find NFA for Union, Concatenation, Kleene Hull

Regular to NFA Union R1[ R2: Concatenation: Kleene: NFA M1 and M2, starting state ²-move to start in M1 and to start in M2 Concatenation: Kleene:

DFA to regular Generalized DFA: edges can carry regular expressions instead of letters Idea 1: start with a normal DFA, shrink to a generalized DFA with 1 edge Idea 2: dynamic programming type argument Ri,j,k regular expression for the set of strings that lead from qi to qj using q0,…, qk only

DFA to regular R0,0,0=(a|b|c)* if there are edges labeled a,b,c from q0 to q0 Ri,i,0 = ² otherwise Ri,j,0 = a|b etc., if there are edges labeled a and b from qi to qj Ri,j,k = Ri,j,k-1 | Ri,k,k-1 (Rk,k,k-1)* Rk,j,k-1 Finally take union over all R0,i,n, where qi is accepting Result: a reg. expr. for the DFA Works even for NFA

Conclusion Theoretical Computer Science Algorithms Computability Complexity Machine Models Formal Languages More: Cryptography, Information/Communication Theory …

Topics: Algorithms: Other theory: Basic Algorithms [Sorting/Searching] Graph Algorithms Paradigms [Greedy, Dynamic Programming] Linear Programming Algorithms for hard problems [Approximation] Other theory: Hardness and reductions [eg. NP-completeness] Computability [eg. Halting problem, Universality] Time-Hierarchy [etc.] Finite Automata