CS 154 Formal Languages and Computability May 12 Class Meeting Department of Computer Science San Jose State University Spring 2016 Instructor: Ron Mak.

Slides:



Advertisements
Similar presentations
CS 461 – Nov. 9 Chomsky hierarchy of language classes –Review –Let’s find a language outside the TM world! –Hints: languages and TM are countable, but.
Advertisements

CSCI 4325 / 6339 Theory of Computation Zhixiang Chen Department of Computer Science University of Texas-Pan American.
Recap CS605: The Mathematics and Theory of Computer Science.
CS21 Decidability and Tractability
Computability and Complexity 5-1 Classifying Problems Computability and Complexity Andrei Bulatov.
1 Introduction to Computability Theory Lecture14: Recap Prof. Amos Israeli.
1 Introduction to Computability Theory Lecture12: Decidable Languages Prof. Amos Israeli.
CS 302: Discrete Math II A Review. An alphabet Σ is a finite set (e.g., Σ = {0,1}) A string over Σ is a finite-length sequence of elements of Σ For x.
1 The Chomsky Hierarchy. 2 Unrestricted Grammars: Rules have form String of variables and terminals String of variables and terminals.
1 Uncountable Sets continued Theorem: Let be an infinite countable set. The powerset of is uncountable.
Linear Bounded Automata LBAs
CS 490: Automata and Language Theory Daniel Firpo Spring 2003.
1 Decidability continued. 2 Undecidable Problems Halting Problem: Does machine halt on input ? State-entry Problem: Does machine enter state halt on input.
Normal forms for Context-Free Grammars
CS21 Decidability and Tractability
Grammars, Languages and Finite-state automata Languages are described by grammars We need an algorithm that takes as input grammar sentence And gives a.
Final Exam Review Cummulative Chapters 0, 1, 2, 3, 4, 5 and 7.
Complexity and Computability Theory I Lecture #13 Instructor: Rina Zviel-Girshin Lea Epstein Yael Moses.
CS490 Presentation: Automata & Language Theory Thong Lam Ran Shi.
Review Byron Gao. Overview Theory of computation: central areas: Automata, Computability, Complexity Computability: Is the problem solvable? –solvable.
TM Design Universal TM MA/CSSE 474 Theory of Computation.
1 Undecidability Reading: Chapter 8 & 9. 2 Decidability vs. Undecidability There are two types of TMs (based on halting): (Recursive) TMs that always.
1 1 CDT314 FABER Formal Languages, Automata and Models of Computation Lecture 15-1 Mälardalen University 2012.
CS 3240 – Chapter 11.  They may not halt on every possible input!  And not just because the creator of a specific TM was a doofus  This is related.
1 CD5560 FABER Formal Languages, Automata and Models of Computation Lecture 11 Midterm Exam 2 -Context-Free Languages Mälardalen University 2005.
1 Turing’s Thesis. 2 Turing’s thesis: Any computation carried out by mechanical means can be performed by a Turing Machine (1930)
 2005 SDU Lecture13 Reducibility — A methodology for proving un- decidability.
1Computer Sciences Department. Book: INTRODUCTION TO THE THEORY OF COMPUTATION, SECOND EDITION, by: MICHAEL SIPSER Reference 3Computer Sciences Department.
D E C I D A B I L I T Y 1. 2 Objectives To investigate the power of algorithms to solve problems. To explore the limits of algorithmic solvability. To.
Computability Review homework. Video. Variations. Definitions. Enumerators. Hilbert's Problem. Algorithms. Summary Homework: Give formal definition of.
CSCI 2670 Introduction to Theory of Computing October 13, 2005.
Recursively Enumerable and Recursive Languages
CS 154 Formal Languages and Computability February 9 Class Meeting Department of Computer Science San Jose State University Spring 2016 Instructor: Ron.
1 Linear Bounded Automata LBAs. 2 Linear Bounded Automata (LBAs) are the same as Turing Machines with one difference: The input string tape space is the.
Donghyun (David) Kim Department of Mathematics and Computer Science North Carolina Central University 1 Chapter 4 Decidability Some slides are in courtesy.
Grammar Set of variables Set of terminal symbols Start variable Set of Production rules.
CS 154 Formal Languages and Computability February 11 Class Meeting Department of Computer Science San Jose State University Spring 2016 Instructor: Ron.
1 CD5560 FABER Formal Languages, Automata and Models of Computation Lecture 12 Mälardalen University 2007.
1 The Chomsky Hierarchy. 2 Unrestricted Grammars: Productions String of variables and terminals String of variables and terminals.
CS 154 Formal Languages and Computability March 17 Class Meeting Department of Computer Science San Jose State University Spring 2016 Instructor: Ron Mak.
CS 154 Formal Languages and Computability March 10 Class Meeting Department of Computer Science San Jose State University Spring 2016 Instructor: Ron Mak.
CS 154 Formal Languages and Computability March 15 Class Meeting Department of Computer Science San Jose State University Spring 2016 Instructor: Ron Mak.
CS 154 Formal Languages and Computability April 19 Class Meeting Department of Computer Science San Jose State University Spring 2016 Instructor: Ron Mak.
CS 154 Formal Languages and Computability April 28 Class Meeting Department of Computer Science San Jose State University Spring 2016 Instructor: Ron Mak.
The Church-Turing Thesis Chapter Are We Done? FSM  PDA  Turing machine Is this the end of the line? There are still problems we cannot solve:
Week 14 - Friday.  What did we talk about last time?  Simplifying FSAs  Quotient automata.
CS 154 Formal Languages and Computability March 22 Class Meeting Department of Computer Science San Jose State University Spring 2016 Instructor: Ron Mak.
Recursively Enumerable and Recursive Languages. Definition: A language is recursively enumerable if some Turing machine accepts it.
Theory of Computation. Introduction to The Course Lectures: Room ( Sun. & Tue.: 8 am – 9:30 am) Instructor: Dr. Ayman Srour (Ph.D. in Computer Science).
Review : Theory of Computation. Regular Language and Finite Automata Context-free Language and Pushdown Automata Turing Machine and Recursive Enumerable.
CSE 105 theory of computation
Review : Theory of Computation
Linear Bounded Automata LBAs
Pushdown automata Programming Language Design and Implementation (4th Edition) by T. Pratt and M. Zelkowitz Prentice Hall, 2001 Section
Turing Machines.
Natural Language Processing - Formal Language -
PDAs Accept Context-Free Languages
Summary.
Automata and Formal Languages (Final Review)
Deterministic PDAs - DPDAs
Closure Properties of Context-Free languages
Formal Languages, Automata and Models of Computation
Pushdown automata Programming Language Design and Implementation (4th Edition) by T. Pratt and M. Zelkowitz Prentice Hall, 2001 Section
Pushdown automata Programming Language Design and Implementation (4th Edition) by T. Pratt and M. Zelkowitz Prentice Hall, 2001 Section
Cpt S 317: Spring 2009 Reading: Chapter 8 & 9
Instructor: Aaron Roth
CSE 105 theory of computation
Pushdown automata Programming Language Design and Implementation (4th Edition) by T. Pratt and M. Zelkowitz Prentice Hall, 2001 Section
Pushdown automata Programming Language Design and Implementation (4th Edition) by T. Pratt and M. Zelkowitz Prentice Hall, 2001 Section
Pushdown automata Programming Language Design and Implementation (4th Edition) by T. Pratt and M. Zelkowitz Prentice Hall, 2001 Section
Presentation transcript:

CS 154 Formal Languages and Computability May 12 Class Meeting Department of Computer Science San Jose State University Spring 2016 Instructor: Ron Mak

Computer Science Dept. Spring 2016: May 12 CS 154: Formal Languages and Computability © R. Mak 2 Unofficial Field Trip  Computer History Museum in Mt. View Provide your own transportation to the museum.  Saturday, May 14, 11:30 – closing time Special free admission (for my students only). Experience a fully restored IBM 1401 mainframe computer from the early 1960s in operation. Do a self-guided tour of the Revolution exhibit.

Computer Science Dept. Spring 2016: May 12 CS 154: Formal Languages and Computability © R. Mak Language Families and Complexity Classes  Up until now, we classified languages based on the nature of their automata. regular: finite state automata context-free: pushdown automata context-sensitive: linear-bounded automata recursively-enumerable: Turing machines  Another way to classify languages is to use a Turing machine and consider time-complexity as a distinguishing factor. 3

Computer Science Dept. Spring 2016: May 12 CS 154: Formal Languages and Computability © R. Mak Deciding a Language  Let L be a language and w be any string in L with n = |w|.  A Turing machine M decides language L in time T(n) if it accepts w in T(n) moves.  If M is nondeterministic, it means that for every w in L, there is at least one sequence of moves of length ≤ T(n) that leads to acceptance. 4

Computer Science Dept. Spring 2016: May 12 CS 154: Formal Languages and Computability © R. Mak Classifying a Language  Language L is in class DTIME(T(n)) if there exists a deterministic multi-tape Turing machine that decides L in time O(T(n)).  Language L is in class NTIME(T(n)) if there exists a nondeterministic multi-tape Turing machine that decides L in time O(T(n)).  5

Computer Science Dept. Spring 2016: May 12 CS 154: Formal Languages and Computability © R. Mak Classifying a Language, cont’d  implies  For every integer k ≥ 1, Some languages can be decided in time O(n 2 ) for which there is no linear-time membership algorithm. There are languages in DTIME(n 3 ) that are not in DTIME(n 2 ), etc.  Therefore, there are an infinite number of nested complexity classes. 6

Computer Science Dept. Spring 2016: May 12 CS 154: Formal Languages and Computability © R. Mak Classifying a Language, cont’d  There is no total Turing computable function f (n) such that every recursive language can be decided in time f (n), where n is the input string length. Proof by contradiction using diagonalization (see the textbook).  Every regular language L REG can be recognized by a deterministic finite automaton in time proportional to the input length: 7

Computer Science Dept. Spring 2016: May 12 CS 154: Formal Languages and Computability © R. Mak Classifying a Language, cont’d  For every context-free language L CF, and 8

Computer Science Dept. Spring 2016: May 12 CS 154: Formal Languages and Computability © R. Mak Languages and Classes P and NP  The class of languages that are accepted by some deterministic Turing machine, without any regard to the degree of the polynomial:  The class of languages that are accepted by some nondeterministic Turing machine:  And: 9 P NP P NP

Computer Science Dept. Spring 2016: May 12 CS 154: Formal Languages and Computability © R. Mak Polynomial-Time Reduction  A language L 1 is polynomial-time reducible to another language L 2 if there exists a deterministic Turing machine M such that: M can transform any string w 1 in the alphabet of L 1 to a string w 2 in the alphabet of L 2. w 1 is in L 1 if and only if w 2 is in L 2. 10

Computer Science Dept. Spring 2016: May 12 CS 154: Formal Languages and Computability © R. Mak NP-Complete  A language L is NP-complete if L is in NP and every other language in NP is polynomial-time reducible to L.  If L is NP-complete and polynomial-time reducible to L 1, then L 1 is also NP-complete.  If you can find one deterministic polynomial-time algorithm for any NP-complete language, then every language in NP is also in P, so P = NP. If you can find this algorithm, you’ll win $1,000,000 from the Clay Institute and a turkey from Don Knuth. 11

Computer Science Dept. Spring 2016: May 12 CS 154: Formal Languages and Computability © R. Mak What the Heck … 12 … was this class all about?

Computer Science Dept. Spring 2016: May 12 CS 154: Formal Languages and Computability © R. Mak Theory of Computation  We wanted to study the theory of computation. The theory underlying all of computer science.  Guys like Gödel, Church, Kleene, Post, and Turing during the 1930s had deep thoughts about algorithms and how to compute them.  We studied automata, which were (imaginary) primitive machines. Control states, inputs, and transition functions. Increasingly more sophisticated memory. 13

Computer Science Dept. Spring 2016: May 12 CS 154: Formal Languages and Computability © R. Mak Automata  Finite state automata Internal control states only, no other memory DFA: deterministic NDFA: nondeterministic  Pushdown automata Control states + a stack PDA: deterministic NPDA: nondeterministic  Turing machine Control states + one or more infinite tapes 14

Computer Science Dept. Spring 2016: May 12 CS 154: Formal Languages and Computability © R. Mak Language Acceptors  An automaton processes an input string w and Halts in a final state: the automaton accepts w. Halts in a nonfinal state: the automaton rejects w. A Turing machine can also go into an infinite loop and never halt.  The strings accepted by an automaton constitute a language. DFA and NDFA: regular languages PDA and NPDA: context-free languages Turing machine: recursively enumerable languages 15

Computer Science Dept. Spring 2016: May 12 CS 154: Formal Languages and Computability © R. Mak Languages and Algorithms  So computation theory is tied to languages. A formal language is an abstraction of the general characteristics of programming languages.  We examined algorithms for determining whether or not a string is in a given language. We implemented these algorithms with automata. Studying languages also means studying algorithms. 16

Computer Science Dept. Spring 2016: May 12 CS 154: Formal Languages and Computability © R. Mak Grammars  A grammar is a way to specify a language. regular grammar context-free grammar context-sensitive grammar unrestricted grammar  A grammar has an alphabet, terminals, variables (non-terminals), a starting variable, and a set of production rules. Grammars for different classes of languages have different restrictions on the productions. 17

Computer Science Dept. Spring 2016: May 12 CS 154: Formal Languages and Computability © R. Mak Properties of Languages  Different classes of languages have different closure properties. union, intersection, concatenation, complementation, star-closure, homomorphism, right quotient, reversal  A regular language and a context-free language each has a pumping lemma that we can use to prove by contradiction that certain strings are not in the language. 18

Computer Science Dept. Spring 2016: May 12 CS 154: Formal Languages and Computability © R. Mak Uses of Languages  Regular expressions are used for string pattern matching.  Context-free grammars are used by compilers to parse programming languages. Compiler writers use BNF to express a context-free grammar. JavaCC is a compiler-writing tool that uses a form of BNF.  Parsers can be top-down or bottom-up. 19

Computer Science Dept. Spring 2016: May 12 CS 154: Formal Languages and Computability © R. Mak Turing Machines  Any computable function can be executed by a Turing machine.  A TM is an abstraction of all modern computers. If an algorithm can’t be computed by a TM, then no computer can compute it. No other computation model is more powerful. A TM can have one or many tapes. They’re all equivalent in computation power.  A universal Turing machine can simulate any other TM. 20

Computer Science Dept. Spring 2016: May 12 CS 154: Formal Languages and Computability © R. Mak Turing Machines and Languages  A nondeterministic TM accepts a language if it halts in a final state for any string in the language. If a string is not in the language, the TM can halt in a nonfinal state, or it can go into an infinite loop and never halt.  A nondeterministic TM decides a language if any string, it halts in a final state if the string is in the language, otherwise it halts in a nonfinal state. The TM always halts for any string. A membership algorithm always halts. 21

Computer Science Dept. Spring 2016: May 12 CS 154: Formal Languages and Computability © R. Mak Recursive and Recursively Enumerable  A language is recursively enumerable if a Turing machine exists that accepts it. The TM might not halt given a string that is not in the language.  A language is recursive if a Turing machine exists that accepts it and always halts. The TM halts in a nonfinal state given a string that is not in the language. 22

Computer Science Dept. Spring 2016: May 12 CS 154: Formal Languages and Computability © R. Mak Countable  Some sets are countable. You can list the elements of the set in order.  Other sets are uncountable. No matter in how you list the elements of the set, some elements cannot fit in the order. Cantor diagonalization is a way to show this.  The set of all Turing machines is countable. 23

Computer Science Dept. Spring 2016: May 12 CS 154: Formal Languages and Computability © R. Mak Decidable and Undecidable  A yes/no problem is decidable if a Turing machine exists that always halts and gives the correct “yes” or “no” answer.  Otherwise, the problem is undecidable.  The halting problem and the Post correspondence problem are undecidable.  You can reduce a known undecidable problem to another problem in order to prove that the latter problem is also undecidable. 24

Computer Science Dept. Spring 2016: May 12 CS 154: Formal Languages and Computability © R. Mak Primitive Recursive Functions  Primitive recursive functions are built from the zero, successor, and projector functions, and from composition and primitive recursion. Ackermann’s function is not primitive recursive. µ -recursive functions have more restrictions.  Primitive recursive functions are another model of computation. 25

Computer Science Dept. Spring 2016: May 12 CS 154: Formal Languages and Computability © R. Mak Complexity Classes  Classify a language according to how long it takes a Turing machine to decide the language.  Complexity classes P and NP NP-complete problems are the hardest of all.  Is P = NP? 26