CA320: COMPUTABILITY AND COMPLEXITY 1 1 Introduction CA320 Computability and Complexity Lecturer: Office: L2.55 Phone: 5017 Email: hamilton@computing.dcu.ie WWW: http://www.computing.dcu.ie/ hamilton Course Page: "/teaching/ca320 Books Recommended: Introduction to the Theory of Computation, Sipser, PWS, ISBN 053494728X, 1996 Haskell: The Craft of Functional Programming, Thompson, Addison-Wesley, ISBN 0-201-34275-8, 1999 Supplementary: Elements of the Theory of Computation, Lewis and Papadimitriou, Prentice Hall, ISBM 0-13-272741-2, 1998 Introduction to Languages and the Theory of Computation, Martin, McGraw- Hill, ISBN 0-07-115468-X, 1997 Programming in Haskell, Hutton, Cambridge University Press, ISBN 9780521692694, 2007 Assessment Continuous Assessment: 25% Programming lab exam 10% Programming assignment 15% Exam: 75% Ten short questions Answer all questions You must get a combined mark 40% to pass
CA320: COMPUTABILITY AND COMPLEXITY 2 Assessment If you fail this module then you will need to repeat some elements of the assessment. If you just failed the exam you can resit the exam in the Autumn. If you just failed the continuous assessment then you must complete a resit assignment. Contact me after the results are published for the resit assignment. If you failed both the exam and the continuous assessment, you must repeat both. If you fail the module after the resit examination and continuous assessment you must repeat all aspects of the module in the following year. What is the Point of This Course? Within this course, we will be attempting to answer the following questions: 1. What problems can be theoretically solved by a computer? 2. What problems can be efficiently solved by a computer? Computability theory is concerned with exploring the limitations of computing devices and the problems which can be computed by them. Complexity theory is concerned with classifying computable problems by their inherent difficulty. Languages and Automata In this course, we will see that computation can be regarded as a process of language recognition. The recognition of a word in a language corresponds to the acceptance of an input by a program. We will study a number of languages of increasing descriptive power. We will also study a number of automata (abstract machines) of increasing power, which can be used to recognise each of these languages. Some of the automata which we will study are as powerful as any real computer, while others are less powerful. We will see that these less powerful automata are nevertheless quite useful. General Models of Computation We will also study the following equivalent general models of computational devices: Turing machines Lambda calculus Unrestricted grammars Partial recursive functions
CA320: COMPUTABILITY AND COMPLEXITY 3 Computability Deals with the following questions: Do algorithmic solutions to problems always exist? What are the limitations of computational devices? Is there any insight to which problems are algorithmically solvable and which are not? Are the unsolvable problems somehow related? For example, will function f terminate for all positive values of n? int f(int n) { while (n!=1) if (n%2==0) n:=n/2; else n:=3*n+1; return n; } Complexity Deals with the following questions: How do we compare the efficiency of different algorithms? How do we measure time/memory requirements? What problems are efficiently solvable? Are there solvable problems which do not have efficient algorithms? For example, can we efficiently determine the factors p and q of a product p q? Problems Types of problems: Decision problems: Return either YES or NO (or, equivalently, true or false, or 0 or 1) Search Problems: Find an x that satisfies property P Enumeration Problems: Find all x that satisfy property P Counting Problems: Count the number of x s that satisfy property P Optimisation Problems: Find the x that best satisfies property P Structuring Problems: Transform x to satisfy property P
CA320: COMPUTABILITY AND COMPLEXITY 4 Problems A problem specification comprises: a characterisation of all legal inputs to the problem a characterisation of the desired outputs as a function of the legal inputs. Some example problems: Problem 1 Inputs: Two non-negative integers, x and y Outputs: The greatest common divisor of x and y Problem 2 Inputs: A positive integer n Outputs: YES if n is prime and NO if it isn t Algorithms Algorithms can be used to solve problems. An algorithm is: a finite sequence of operations for solving a problem each operation is chosen from a set of well-defined operations If the algorithm is executed by a suitable processor on any instance of the problem, it will give rise to a process that: halts in a finite time returns the answer for that problem instance Algorithms Problem 3 Inputs: A positive integer n Outputs: The sum of the integers from 1 to n Algorithm 1 sum:= 0; for i:= 1 to n sum:=sum+i; return sum; Algorithm 2 return (n*(n+1))/2;
CA320: COMPUTABILITY AND COMPLEXITY 5 Correctness How can we be sure that an algorithm or program solves a problem? How can we be sure that it terminates and produces the correct output for all of its legal inputs? For example, consider the following program: if (f(n)==1) printf("hello World!"); where f is defined as given previously. Is this equivalent to the following: printf("hello World!"); Course Outline Introduction Sets, relations and functions, graphs, strings and languages, logic, proofs, recursion and induction Introduction to Haskell Regular languages and finite automata Regular expressions, finite state automata, regular grammars Context-free languages and pushdown automata Context-free grammars, derivations, ambiguity, pushdown automata Context-sensitive languages and linear bounded automata Context-sensitive grammars, linear bounded automata General Models of Computation Turing machines, unrestricted grammars, partial recursive functions, lambda calculus, Church-Turing thesis Computability Countability, computability, halting problem, reducibility Complexity Asymptotic notation, polynomial and exponential time complexity and space complexity, P, NP, NP-completeness