Programming Languages Wrap-up. Your Toolkit Object-oriented Imperative Functional Logic.

Slides:



Advertisements
Similar presentations
Turing Machines Memory = an infinitely long tape Persistent storage A read/write tape head that can move around the tape Initially, the tape contains only.
Advertisements

Complexity Classes: P and NP
CS 345: Chapter 9 Algorithmic Universality and Its Robustness
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.
CSCI 4325 / 6339 Theory of Computation Zhixiang Chen Department of Computer Science University of Texas-Pan American.
The Big Picture Chapter 3. We want to examine a given computational problem and see how difficult it is. Then we need to compare problems Problems appear.
Recap CS605: The Mathematics and Theory of Computer Science.
Nathan Brunelle Department of Computer Science University of Virginia Theory of Computation CS3102 – Spring 2014 A tale.
Computability and Complexity 5-1 Classifying Problems Computability and Complexity Andrei Bulatov.
1 Introduction to Computability Theory Lecture12: Decidable Languages Prof. Amos Israeli.
Reducibility Sipser 5.1 (pages ). CS 311 Fall Reducibility.
Fall 2004COMP 3351 Undecidable problems for Recursively enumerable languages continued…
Theory of Computation What types of things are computable? How can we demonstrate what things are computable?
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.
Decidable and undecidable problems deciding regular languages and CFL’s Undecidable problems.
1 Uncountable Sets continued Theorem: Let be an infinite countable set. The powerset of is uncountable.
Fall 2004COMP 3351 The Chomsky Hierarchy. Fall 2004COMP 3352 Non-recursively enumerable Recursively-enumerable Recursive Context-sensitive Context-free.
Fall 2004COMP 3351 Reducibility. Fall 2004COMP 3352 Problem is reduced to problem If we can solve problem then we can solve problem.
Linear Bounded Automata LBAs
1 Decidability continued. 2 Undecidable Problems Halting Problem: Does machine halt on input ? State-entry Problem: Does machine enter state halt on input.
Courtesy Costas Busch - RPI1 Reducibility. Courtesy Costas Busch - RPI2 Problem is reduced to problem If we can solve problem then we can solve problem.
CS21 Decidability and Tractability
Fall 2003Costas Busch - RPI1 Turing Machines (TMs) Linear Bounded Automata (LBAs)
1 Reducibility. 2 Problem is reduced to problem If we can solve problem then we can solve problem.
Halting Problem. Background - Halting Problem Common error: Program goes into an infinite loop. Wouldn’t it be nice to have a tool that would warn us.
Final Exam Review Cummulative Chapters 0, 1, 2, 3, 4, 5 and 7.
Remaining Topics Decidability Concept 4.1 The Halting Problem 4.2
Complexity and Computability Theory I Lecture #13 Instructor: Rina Zviel-Girshin Lea Epstein Yael Moses.
Complexity theory and combinatorial optimization Class #2 – 17 th of March …. where we deal with decision problems, finite automata, Turing machines pink.
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.
Introduction to CS Theory Lecture 15 –Turing Machines Piotr Faliszewski
1 Turing Machines There are languages that are not context-free. What can we say about the most powerful automata and the limits of computation?. Alan.
CSCI 2670 Introduction to Theory of Computing November 29, 2005.
Complexity Non-determinism. NP complete problems. Does P=NP? Origami. Homework: continue on postings.
CSCI 3160 Design and Analysis of Algorithms Tutorial 10 Chengyu Lin.
Halting Problem Introduction to Computing Science and Programming I.
1Computer Sciences Department. Book: INTRODUCTION TO THE THEORY OF COMPUTATION, SECOND EDITION, by: MICHAEL SIPSER Reference 3Computer Sciences Department.
CS 3813: Introduction to Formal Languages and Automata Chapter 12 Limits of Algorithmic Computation These class notes are based on material from our textbook,
1 Turing’s Thesis. 2 Turing’s thesis: Any computation carried out by mechanical means can be performed by a Turing Machine (1930)
1Computer Sciences Department. Book: INTRODUCTION TO THE THEORY OF COMPUTATION, SECOND EDITION, by: MICHAEL SIPSER Reference 3Computer Sciences Department.
NP-Completeness (Nondeterministic Polynomial Completeness) Sushanth Sivaram Vallath & Z. Joseph.
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.
Recursively Enumerable Languages
CSCI 2670 Introduction to Theory of Computing October 13, 2005.
Recursively Enumerable and Recursive Languages
1 Section 13.1 Turing Machines A Turing machine (TM) is a simple computer that has an infinite amount of storage in the form of cells on an infinite tape.
1 Turing Machines and Equivalent Models Section 13.1 Turing Machines.
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.
Overview of the theory of computation Episode 3 0 Turing machines The traditional concepts of computability, decidability and recursive enumerability.
Donghyun (David) Kim Department of Mathematics and Computer Science North Carolina Central University 1 Chapter 4 Decidability Some slides are in courtesy.
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.
Undecidability and The Halting Problem
1 8.4 Extensions to the Basic TM Extended TM’s to be studied: Multitape Turing machine Nondeterministic Turing machine The above extensions make no increase.
CS 154 Formal Languages and Computability May 12 Class Meeting Department of Computer Science San Jose State University Spring 2016 Instructor: Ron Mak.
Turing Machines CS 130 Theory of Computation HMU Textbook: Chap 8.
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.
Computability. Turing Machines Read input letter & tape letter, write tape letter, move left or right.
Recursively Enumerable and Recursive Languages. Definition: A language is recursively enumerable if some Turing machine accepts it.
Recursively Enumerable and Recursive Languages
Linear Bounded Automata LBAs
Context Sensitive Languages and Linear Bounded Automata
LIMITS OF ALGORITHMIC COMPUTATION
Chapter 9 TURING MACHINES.
Decidable Languages Costas Busch - LSU.
Halting Problem.
Decidability continued….
Presentation transcript:

Programming Languages Wrap-up

Your Toolkit Object-oriented Imperative Functional Logic

Your problem… Make a GUI front end for a store inventory system Go through a file and count occurrences of certain words Given a graph, find all paths from node A to node B.

Making a new language Why? What do you need to decide?

Theory Component Provides mathematical models of –Programming languages (grammars) –Computers (automata) –And how they work together Gives foundation for studying what programming languages can and can’t do.

Turing Machines Read input letter & tape letter, write tape letter, move left or right.

Example: a n b n c n Read an a, Replace it with an x. Move right over the rest of the a’s. Read a b, replace it with a y. Move right over the rest of the b’s Read a c, replace it with a z. Move all the way left until you see an x (then you’re at the beginning again). Repeat until all a’s have been taken. Make one last pass over string to make sure only x,y, and z are remaining.

Turing’s Thesis Can Turing Machines do anything computers can do? Hmm - depends on the definition of “computer”! Turing’s thesis(mid-30’s): Any computation carried out by mechanical means can be carried out by a Turing Machine.

Turing’s thesis: true or false? Can’t prove it, because we can’t foresee what “mechanical means” people might come up with in the future. Could disprove it with one counterexample...

Evidence Supporting Turing’s thesis Anything that can be done on an existing digital computer can be done on a Turing Machine –We can prove this - just write a TM for each machine instruction. No one has been able to suggest a problem solvable by an algorithm but not a TM Many alternative models of digital computers have been proposed - but none are more powerful than TMs

Algorithm definition An algorithm for a function is a Turing Machine that halts with the correct answer on the tape for any input in the domain.

Other types of automata Given another type of automata, how do you know which is more powerful? Simulation - show how anything done with one type of automata can be done with the other Example: I can simulate with a PDA any FSA. Therefore PDAs as powerful (maybe more) than FSAs.

Example: Any FSA can be written as a PDA: So PDAs are at least as powerful.

Variations on TMs Add a stay-option Tape is only unbounded in one direction Separate read-only tape for input (off-line TM) Multiple storage tapes Multi-dimensional tape (extends infinitely in 2 dimensions) Non-deterministic TMs (not presently possible with today’s computers) All these are equivalent automata to Turing Machines!

Non-deterministic TMs An interesting class of TMs... Equivalent in power to TMs (so everything computable by a ND-TM is computable by a TM) BUT, it takes more steps on a TM than a ND-TM. We think it takes exponentially more steps... This is where the classes P and NP come from... –P: set of all problems computable by a TM in polynomial time –NP: set of all problems computable by a ND-TM in polynomial time –P = NP? Unknown...

Detour into NP-Complete: set of all problems in NP that are polynomial-time reducible to ALL problems in NP. Meaning, if you can solve 1 NPC problem in polynomial time, you can solve ALL NP problems in polynomial time, and P = NP Cook’s Theorem: SAT is NP-Complete How did this work? He showed that every ND-TM has an equivalent SAT expression!! From that it is easy to reduce other NP-problems to SAT to prove that they too are NPC: –Hamiltonian paths (Traveling salesman) –Cliques

Recursively Enumerable Languages A language is recursively enumerable if there is a Turing Machine that accepts it. This allows the TM to go into an infinite loop if the string is not in the language.

Recursive Languages A language is Recursive if there is a TM that accepts the language and it halts on every string in Σ+. That is, a recursive language has to have a membership algorithm.

Recursively Enumerable, contd Not all languages are recursively enumerable. Some languages are recursively enumerable but not recursive. Unrestricted grammars produce recursively enumerable languages. These statements are proven, yet examples are hard to come by...

Context-Sensitive Grammars All productions are of the form x -> y, where x and y are elements of (VUT)+ and |x| <= |y| Example: S -> ABC AB -> aaab C -> DF DF -> cccab

Context-Sensitive Languages CSL example: a n b n c n Automata for CSLs are linear-bounded automata: TM’s where only the area of tape used by the input is allowed as storage. All CSL’s are recursive, but not all recursive languages are context-sensitive.

Chomsky’s Hierarchy Regular Det Context-Free Non-det Context-Free Context-Sensitive Recursive Recursively Enumerable

So can anything be computed? No! Computability – the study of which problems can and which cannot be solved by a Turing Machine.

The Halting Problem Given an algorithm decide will it halt? Assume it can be done: Halt(M,w) = yes if algorithm (TM) M halts on input w, and no if it doesn’t. That is: Halt(M,w) = yes if M(w) halts, else no. Create new algorithm: Strange(String s): if Halt(s,s)= “no” then return yes else while(true){ }

Halting Problem Strange(String s): if Halt(s,s)= “no” then return yes else while(true){ } So, for any program P, if P(P) halts then Strange(P) doesn’t halt. if P(P) doesn’t halt then Strange(P) does halt. But that means: if Strange(Strange) halts then Strange(Strange) doesn’t halt. if Strange(Strange) doesn’t halt then Strange(Strange) does halt. Contradiction!

Computability So, not all problems can be solved with a computer. The Halting Problem is said to be “undecidable”. DO NOT confuse this with an NP- complete problem! Remember, problems in NP are solvable by non-deterministic TMs and therefore also solvable by TMs, just not necessarily in polynomial time.

Reducing one problem to another... The state-entry problem: Given a TM and string w, tell whether or not a given state q is ever entered when processing w. Is it decidable? Why or why not?

Other Undecidable Problems Given a TM M, letter a, and string w, determine if the letter a ever gets written when processing M(w). Determine if two TMs are equal Determine if a CFG is ambiguous Given 2 CFGs, G1 and G2, determine if L(G1)  L(G2) = {}

Rice’s Theorem Any non-trivial property of a recursively enumerable language is undecidable. Particularly, the following are undecidable. –For language G, is L(G) = {}? –For language G, is string w in L(G)? –Is TM M finite? –Does TM M accept 2 different strings of the same length?

The moral of the story... Researchers first find the properties of the problem before trying to solve it. Know beforehand the possibilities of the best answer, or even that an answer is possible. Often leads to a definition of assumptions or concessions to make the problem solvable in a more practical way.