Nachklausur zur Vorlesung Vertiefung Theoretische Informatik Wintersemester

Similar documents
Klausur zur Vorlesung Vertiefung Theoretische Informatik Sommersemester 2016

Klausur zur Vorlesung Vertiefung Theoretische Informatik Sommersemester

Advanced Topics in Theoretical Computer Science

Theory of Computer Science. Theory of Computer Science. D8.1 Other Halting Problem Variants. D8.2 Rice s Theorem

Theory of Computer Science

Theory of Computer Science. Theory of Computer Science. D7.1 Introduction. D7.2 Turing Machines as Words. D7.3 Special Halting Problem

Limits of Computability

CSCE 551 Final Exam, April 28, 2016 Answer Key

6.045 Final Exam Solutions

Primitive recursive functions: decidability problems

6.045J/18.400J: Automata, Computability and Complexity. Quiz 2. March 30, Please write your name in the upper corner of each page.

Organische Chemie IV: Organische Photochemie

6.8 The Post Correspondence Problem

Exam Computability and Complexity

Undecidable Problems. Z. Sawa (TU Ostrava) Introd. to Theoretical Computer Science May 12, / 65

Theory of Computer Science. D5.1 Introduction. Theory of Computer Science. D5.2 Primitive Recursion vs. LOOP. D5.3 µ-recursion vs.

Complexity Theory VU , SS The Polynomial Hierarchy. Reinhard Pichler

Outline. Complexity Theory EXACT TSP. The Class DP. Definition. Problem EXACT TSP. Complexity of EXACT TSP. Proposition VU 181.

Organische Chemie IV: Organische Photochemie

Decision Problems with TM s. Lecture 31: Halting Problem. Universe of discourse. Semi-decidable. Look at following sets: CSCI 81 Spring, 2012

Theory of Computer Science

FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY

CS154, Lecture 17: conp, Oracles again, Space Complexity

Student#: CISC-462 Exam, December XY, 2017 Page 1 of 12

Lecture 22: PSPACE

1 Showing Recognizability

Solutions to Old Final Exams (For Fall 2007)

Introduction to Turing Machines

satisfiability (sat) Satisfiability unsatisfiability (unsat or sat complement) and validity Any Expression φ Can Be Converted into CNFs and DNFs

Lecture 14: Recursive Languages

16.1 Countability. CS125 Lecture 16 Fall 2014

Complexity Theory. Knowledge Representation and Reasoning. November 2, 2005

Principles of Knowledge Representation and Reasoning

CS154, Lecture 10: Rice s Theorem, Oracle Machines

(a) Definition of TMs. First Problem of URMs

Answers to the CSCE 551 Final Exam, April 30, 2008

The Turing Machine. Computability. The Church-Turing Thesis (1936) Theory Hall of Fame. Theory Hall of Fame. Undecidability

Automata Theory CS S-FR2 Final Review

452 FINAL- VERSION E Do not open this exam until you are told. Read these instructions:

Database Theory VU , SS Complexity of Query Evaluation. Reinhard Pichler

Organische Chemie IV: Organische Photochemie

Lecture 21: Algebraic Computation Models

COMPUTER SCIENCE TRIPOS

Q = Set of states, IE661: Scheduling Theory (Fall 2003) Primer to Complexity Theory Satyaki Ghosh Dastidar

Undecidability of the validity problem

Section 14.1 Computability then else

Complexity. Complexity Theory Lecture 3. Decidability and Complexity. Complexity Classes

COMPLEXITY THEORY. Lecture 17: The Polynomial Hierarchy. TU Dresden, 19th Dec Markus Krötzsch Knowledge-Based Systems

20.1 2SAT. CS125 Lecture 20 Fall 2016

COL 352 Introduction to Automata and Theory of Computation Major Exam, Sem II , Max 80, Time 2 hr. Name Entry No. Group

Predicate Logic - Undecidability

Undecibability. Hilbert's 10th Problem: Give an algorithm that given a polynomial decides if the polynomial has integer roots or not.

SS BMMM01 Basismodul Mathematics/Methods Block 1: Mathematics for Economists. Prüfer: Prof. Dr.

Automata & languages. A primer on the Theory of Computation. Laurent Vanbever. ETH Zürich (D-ITET) October,

Complexity Theory Part I

COMPLEXITY THEORY. PSPACE = SPACE(n k ) k N. NPSPACE = NSPACE(n k ) 10/30/2012. Space Complexity: Savitch's Theorem and PSPACE- Completeness

There are problems that cannot be solved by computer programs (i.e. algorithms) even assuming unlimited time and space.

CSE 200 Lecture Notes Turing machine vs. RAM machine vs. circuits

About the relationship between formal logic and complexity classes

CS5371 Theory of Computation. Lecture 10: Computability Theory I (Turing Machine)

CSE 105 THEORY OF COMPUTATION

CMPS 217 Logic in Computer Science. Lecture #17

1 PSPACE-Completeness

PROOFS IN PREDICATE LOGIC AND COMPLETENESS; WHAT DECIDABILITY MEANS HUTH AND RYAN 2.3, SUPPLEMENTARY NOTES 2

CSE 105 THEORY OF COMPUTATION

CS5371 Theory of Computation. Lecture 10: Computability Theory I (Turing Machine)

Technische Universität München Summer term 2010 Theoretische Informatik August 2, 2010 Dr. J. Kreiker / Dr. M. Luttenberger, J. Kretinsky SOLUTION

Theory Bridge Exam Example Questions

CSCE 551 Final Exam, Spring 2004 Answer Key

Turing Machine Recap

Midterm II : Formal Languages, Automata, and Computability

Finish K-Complexity, Start Time Complexity

Complexity Theory Final Exam

P vs. NP Classes. Prof. (Dr.) K.R. Chowdhary.

Computability and Complexity

Complexity: Some examples

Non-emptiness Testing for TMs

CS 311 Sample Final Examination

Expansions with P = NP. Christine Gaßner Greifswald

Lecture Notes: The Halting Problem; Reductions

DRAFT. Diagonalization. Chapter 4

258 Handbook of Discrete and Combinatorial Mathematics

Lecture 16: Time Complexity and P vs NP

Introduction to Turing Machines. Reading: Chapters 8 & 9

On NP-Completeness for Linear Machines

Lecture 12: Mapping Reductions

Informal Statement Calculus

Week 3: Reductions and Completeness

CS20a: Turing Machines (Oct 29, 2002)

CSE 105 THEORY OF COMPUTATION

Notes for Lecture Notes 2

SOLUTION: SOLUTION: SOLUTION:

THEORY OF COMPUTATION (AUBER) EXAM CRIB SHEET

Computability and Complexity CISC462, Fall 2018, Space complexity 1

Turing s thesis: (1930) Any computation carried out by mechanical means can be performed by a Turing Machine

1 Circuit Complexity. CS 6743 Lecture 15 1 Fall Definitions

De Morgan s a Laws. De Morgan s laws say that. (φ 1 φ 2 ) = φ 1 φ 2, (φ 1 φ 2 ) = φ 1 φ 2.

CS 125 Section #10 (Un)decidability and Probability November 1, 2016

Theory of Computation

Chapter 2 Algorithms and Computation

Transcription:

Prof. Dr. Viorica Sofronie-Stokkermans Dipl.-Inform. Markus Bender AG Formale Methoden und Theoretische Informatik Fachbereich Informatik Universität Koblenz-Landau Hinweise Nachklausur zur Vorlesung Vertiefung Theoretische Informatik Wintersemester 2014 13.04.2015 Name:................................................... Vorname:................................................... Matrikelnummer:................................................... Studiengang:................................................... Legen Sie Ihren Studentenausweis und ein Ausweisdokument mit Lichtbild (Personalausweis, Pass, Führerschein) auf den Tisch. Schalten Sie Ihr Handy aus. Prüfen Sie Ihr Exemplar der Klausur auf Vollständigkeit (9 Aufgaben). Schreiben Sie mit einem dokumentenechten, schwarzen oder blauen Stift. Es sind keine Hilfsmittel erlaubt. Weitere leere Blätter sind bei der Aufsicht erhältlich. Diese sind mit Namen und Matrikelnummer zu beschriften und müssen abgegeben werden. Heften Sie bei der Abgabe sämtliche Blätter zusammen. Blätter, die versehentlich nicht abgegeben wurden, können nicht nachträglich abgegeben werden. MUSTERLÖSUNG Viel Erfolg! Diese Musterlösung erhebt nicht den Anspruch absoluter Korrektheit. Aufgabe 1 2 3 4 5 6 7 8 9 Σ Punkte erreicht von möglichen 41 8 10 6 8 5 6 6 10 100 Note:.................... Unterschrift:..............................

Exercise 1 (7P + 6P + 5P + 20P + 3P = 41 Punkte) Remark: In Exercises 1.1 1.3 wrong crosses lead to loss of points. The minimum number of points for each of the exercises is 0 (one cannot carry negative points into the next exercise). /7 P 1.1 Register Machines, Recursive Functions Please indicate (by crossing the right box) whether the following statements are true or false. In the WHILE program while x 1 0 do P end the number of times P is executed is not influenced by the fact that P changes x 1. The loop instruction can be simulated with a WHILE program. For every WHILE program there exists an equivalent WHILE-IF program with one while instruction only. There exist primitive recursive functions which are not µ-recursive. Every LOOP computable function is µ-recursive. For every µ-recursive function there exists a Turing machine which computes it. Every primitive recursive function is LOOP computable. 1.2 Complexity Theory Please indicate (by crossing the right box) whether the following statements are true, false, or open (not known in the scientific community). true false true false open If f is a computable function then DSPACE(f(n)) NSPACE(f(n)). Every NP-hard problem is in NP. NP = co-np. P = NP. Let L 1, L 2 be languages with L 1 pol L 2 and L 2 P. Then L 1 P. /6 P /5 P QBF (the problem of checking whether a quantified Boolean formula is true) is PSPACE-complete. 1.3 Decidability Please indicate (by crossing the right box) whether the following statements are true or false. The set {n M n halts on input n} (where M n is the Turing machine with Gödel number n) is undecidable. The Post correspondence problem over an alphabet Σ ( Σ 2) is undecidable The set of all valid formulae in propositional logic is decidable. The set of all valid formulae in first-order logic is decidable. It is decidable whether two context-free languages are equal. true false 1

1.4 Register Machines, Recursive Functions, Complexity Please indicate (by crossing the right box) whether the following statements are true or false and give a brief justification of your answer (this can for instance be an example or a counterexample). For each correct cross you get 1 point; for the correct justification you get 1 additional point. Every µ-recursive function is primitive recursive. f(n) = µi(n + i = 0) is µ recursive but not defined everywhere, hence not primitive recursive true false There exist total functions which are not LOOP computable. The Ackerman function is a total function but is not primitive recursive and therefore is not LOOP computable. Every WHILE computable function is total. { undefined if l = m or l = n f(l, m, n) = m l + n l otherwise is clearly WHILE computable, but not total. Every total function is WHILE computable. { 1 if the Turing machine M n halts on input n h(n) = 0 otherwise is clearly total, but not computable and thus not WHILE computable. For every primitive recursive function g : N 2 N, the function f : N N defined by f(n) = µi(g(n, i) = 0) is primitive recursive. For g(n, i) = 1, f(n) is always undefined and can thus not be primitive recursive as primitive recursive functions are total. { 0 if n 3 = m 2 + 1 The function f : N N N defined by: f(n, m) = 1 otherwise is primitive recursive. Case distinction is primitive recursive if all involved functions are primitive recursive. This is the case for f. g 1 (n, m) = 0 if h 1 (n, m) = (n 3 (m 2 + 1)) + f(n, m) = ((m 2 + 1) n 3 ) = 0 g 2 (n, m) = 1 if h 2 (n, m) = 1 h 1 (n, m) = 0 2

true false Let g 1, g 2 : N N N be a primitive { recursive function. Then the function ( i<m g1 (i, n) + g 2 (n, i) ) if m > 0 f : N N N defined by: f(n, m) = 0 if m = 0 is primitive recursive. If { g : N N N is primitive recursive then the function f(n, m) = i<m g(n, i) if m > 0 is primitive recursive. 0 if m = 0 In this case g(n, i) = g 1 (i, n) + g 2 (n, i)) is p.r. as g 1, g 2 are p.r.; the set of p.r. functions is closed under omitting and repeating arguments and under composition; and + is p.r. Let f : N N be defined by f(n) = n 5. Then every language in DTIME(f(n)) is decidable. A computable function f(n) that restricts the computation time can be used to force the termination of a TM. So we can use a TM to run the TM for the problem and keep track of the time. If the calculated limit is crossed, the overseeing TM terminates with output no as it knows that the simulated TM is in a loop. If there exists an NP-hard problem which is in P then P = NP. If an NP-hard problem is in P then all the problems in NP can be reduced to this NP-hard problem in polynomial time, and thus they all can be solved in polynomial time. Therefore all the problems in NP are in P. /20 P Let L be a language. If we give a polynomial-time reduction from 3-SAT to L we may conclude that L is NP-complete. From the fact that 3-SAT is reducible to L in polynomial time, we know that L is NP-hard. To be NP-complete, L has to be in NP. This can not be deduced from the given information. Example: There is a PTIME reduction from 3-SAT to FO-SAT, the language of satisfiable formulae in first-order logic. The latter language is undecidable and thus not NP-complete. 1.5 Indicate the relationships between the classes LOOP, WHILE part, GOTO part, TM part, P and F part µ. P = LOOP F part µ = WHILE part = GOTO part = TM part /3 P /41 P 3

LOOP/WHILE/GOTO code In the context of this exam, register machine instructions and register machine programs for the languages LOOP, WHILE and GOTO are defined as follows: LOOP prog ::= LOOP instr ; LOOP prog LOOP instr LOOP instr ::= ass loop reg do LOOP prog end if cond then LOOP prog else LOOP prog end if cond then LOOP prog end WHILE prog ::= WHILE instr ; WHILE prog WHILE instr WHILE instr ::= ass while reg = 0 do WHILE prog end if cond then WHILE prog else WHILE prog end if cond then WHILE prog end GOTO prog ::= nat num : GOTO instr ; GOTO prog nat num : GOTO instr GOTO instr ::= ass goto nat num if reg = 0 goto nat num ass ::= reg := nat num reg := reg reg := nat num op reg reg := reg op nat num reg := reg op reg reg ::= x 1 x 2 x 3... nat num ::= 0 1 2... cond ::= reg rel reg reg rel nat num op ::= + rel ::= = You are allowed to define and use auxiliary LOOP/WHILE/GOTO programs. You are not allowed to use any other LOOP/WHILE/GOTO instruction or LOOP/WHILE/GOTO programs. Summary In LOOP programs you can use the following instructions: x i := c P 1 ; P 2 if x i = c then P 1 end if x i = c then P 1 else P 2 end x i := x j loop x i do P 1 end if x i c then P 1 end if x i c then P 1 else P 2 end x i := c op x j if x i = x j then P 1 end if x i = x j then P 1 else P 2 end x i := x j op c if x i x j then P 1 end if x i x j then P 1 else P 2 end x i := x j op x k (where x i, x j are registers, c N, op {+,, }, and P 1, P 2 are LOOP programs) In WHILE and WHILE-IF programs you can use the following instructions: x i := c P 1 ; P 2 if x i = c then P 1 end if x i = c then P 1 else P 2 end x i := x j while x i 0 do P 1 end if x i c then P 1 end if x i c then P 1 else P 2 end x i := c op x j if x i = x j then P 1 end if x i = x j then P 1 else P 2 end x i := x j op c if x i x j then P 1 end if x i x j then P 1 else P 2 end x i := x j op x k (where x i, x j are registers, c N, op {+,, }, and P 1, P 2 are WHILE programs) In GOTO programs you can use the following instructions: x i := c x i := c op x j goto l x i := x j x i := x j op c if x i = 0 goto l x i := x j op x k (where x i, x j are registers, c N, op {+,, }, and l is a label) A GOTO program has the form l 1 : B 1,..., l k : B k (k 1) where B 1,..., B k are GOTO instructions and l 1,..., l k are labels. 4

Exercise 2 (3P + 3P + 2P = 8 Punkte) Let f : N N N be defined as follows: { 0 if m = 0 or n = 0 f(m, n) = (m + 4) n+1 4 n otherwise a) Write a WHILE program which computes f. If it is not possible to write a WHILE program for f say so and justify why it is not possible. x 3 := x 1 x 2 ; if x 3 = 0 then x 3 := 0 else x 3 := x 1 + 4; x 4 := x 2 ; x 5 := x 3 ; x 6 := 1; while x 4 0 do x 5 := x 5 x 3 ; x 6 := x 6 4; x 4 := x 4 1 end; x 3 := x 5 x 6 ; x 5 := 0; x 6 := 0 end /3 P 5

b) Write a GOTO program which computes f. If it is not possible to write a GOTO program for f say so and justify why it is not possible. 1 : x 3 := x 1 x 2 ; 2 : if x 3 = 0 goto 14; 3 : x 3 := x 1 + 4; 4 : x 4 := x 2 ; 5 : x 5 := x 3 ; 6 : x 6 := 1; 7 : if x 4 = 0 goto 12; 8 : x 5 := x 5 x 3 ; 9 : x 6 := x 6 4; 10 : x 4 := x 4 1; 11 : goto 7; 12 : x 3 := x 5 x 6 ; 13 : x 5 := 0; 14 : x 6 := 0 /3 P 6

c) Write a LOOP program which computes f. If it is not possible to write a LOOP program for f say so and justify why it is not possible. x 3 := x 1 x 2 ; if x 3 = 0 then x 3 := 0 else x 3 := x 1 + 4; x 5 := x 3 ; x 6 := 1; loop x 2 do x 5 := x 5 x 3 ; x 6 := x 6 4 end; x 3 := x 5 x 6 ; x 5 := 0; x 6 := 0 end /8 P 7

8

Exercise 3 (3P + 4P + 3P = 10 Punkte) Let P be the following WHILE program: x 5 := x 1 x 2 ; x 5 := x 5 + x 3 ; x 5 := 1 x 5 ; while x 5 0 do end; x 5 := x 5 + 1 x 4 := x 1 + x 2 ; x 6 := x 3 ; while x 6 0 do end x 7 := x 4 ; x 5 := x 1 + x 2 ; x 4 := 0; while x 5 0 do end; x 4 := x 4 + x 7 ; x 5 := x 5 1 x 6 := x 3 1; x 7 := 0 a) Enter the value that is calculated by P for the given inputs into the table I) II) III) x 1 0 1 2 x 2 2 0 0 x 3 1 2 1 Output 4 undef. 4 /3 P /4 P b) Determine the function f : N N N N computed by P. undefined if n 3 = 0 and (n 2 = 0 or n 3 = 0) (n 1 + n 2 ) if n 3 = 0 and n 2 > 0 and n 1 > 0 f(n 1, n 2, n 3 ) = (n 1 + n 2 ) 2 if n 3 = 1 undefined if n 3 > 1 9

c) Use the transformation presented in the lecture to construct a GOTO program which has the same semantics as P. 1 : x 5 := x 1 x 2 ; 2 : x 5 := x 5 + x 3 ; 3 : x 5 := 1 x 5 ; 4 : if x 5 = 0 goto 7; 5 : x 5 := x 5 + 1; 6 : goto 4; 7 : x 4 := x 1 + x 2 ; 8 : x 6 := x 3 ; 9 : if x 6 = 0 goto 20; 10 : x 7 := x 4 ; 11 : x 5 := x 1 + x 2 ; 12 : x 4 := 0; 13 : if x 5 = 0 goto 17; 14 : x 4 := x 4 + x 7 ; 15 : x 5 := x 5 1; 16 : goto 13; 17 : x 6 := x 3 1; 18 : x 7 := 0; 19 : goto 9; 20 : x 7 := 0 /3 P /10 P 10

Recursive functions We use the following notation: is function composition. if j k, π k j is the projection function defined by π k j (n 1,..., n k ) = n j. (+1) : N N is defined by: (+1)(n) = n + 1. { 0 if n = 0 ( 1) : N N is defined by: ( 1)(n) = n 1 otherwise : N N N is defined for all n 1, n 2 N by: (n 1, n 2) = n 1 n 2. + : N N N is defined for all n 1, n 2 N by: +(n 1, n 2) = n 1 + n 2. : N N N is defined for all n 1, n 2 N by: (n 1, n 2) = n 1 n 2 = for all s, k N, c k s : N k N is defined for all n N k by: c k s(n) = s. { 0 if n 1 n 2 n 1 n 2 otherwise In what follows we will assume known that all the functions above are primitive recursive. We also assume known that definitions by case distinction and definitions using the bounded µ operator (as defined in the lecture, in which only primitive functions are used) define primitive recursive functions. Exercise 4 (2P + 2P + 2P = 6 Punkte) Determine the arity of the following recursive functions by drawing a circle around the corresponding number. Give a brief justification for your answer. I) f 1 = PR[c 1 3, (π3 2, (π3 1, π3 3 ))] arity of f 1 : 0 1 2 3 4 5 6 From fact that the constant function c 1 3 appears in g and that the projections π3 x appear in h, g has arity one and h has arity three. This implies that f 1 has arity two. 11

II) f 2 (n) = µ i<42 i (g 2 (n, i) = 0) with g 2 = (+ (c 3 42, π3 3 )) (c1 3, (π1 1, π1 1 ), c1 3 ) arity of g 2 : 0 1 2 3 4 5 6 arity of f 2 : 0 1 2 3 4 5 6 The functions c 1 3, (π1 1, π1 1 ) and c1 3 are evaluated first, and the usage of c1 3 and π1 1 indicates that these functions expect one argument. Thus the arity of g 2 is one. As g 2 has the additional argument i in comparison to f 2, the arity of f 2 is zero. III) f 3 = µg 3 with g 3 = (π 3 1, (π3 2, π3 3 )) arity of g 3 : 0 1 2 3 4 5 6 arity of f 3 : 0 1 2 3 4 5 6 From fact that the projections π 3 x in g 3 have arity three, it follows, that g 3 has arity three. As g 3 has the additional argument i in comparison to f 3, the arity of f 3 is two. /6 P 12

Exercise 5 (3P + 2P + 3P = 8 Punkte) Define which function is computed by the following recursive functions. Give a brief justification for your answer. I) f 1 = PR[ (π 1 1, π1 1 ), + ( (π3 1, c3 5 ), π3 3 )] f 1 (n, m) = n 5 m + (n n) Definition by primitive recursion: f 1 (n, 0) = g(n) = n n f 1 (n, m + 1) = h(n, m, f(n, m)) = (n 5) + f(n, m) f 1 (n, m) = n 5 m + n 2 /3 P II) f 2 : N N N defined by f 2 (n, m) = µ i<m i ((n + n) i = 0) f 2 (n, m) = { 2n if 2n < m 0 otherwise The bounded µ operator { is defined as follows: i 0 if g(n, i 0 ) = 0 and for all j < i 0 g(n, j) 0 µ i<m i(g(n, i) = 0) := 0 if g(n, j) 0 for all 0 < j < m or m = 0 This definition implies, that f 2 (n, m) is 2n if 2n < m. For 2n m we have to check under which circumstances (n + n) i = 0 holds. As i has to be strictly smaller than m by the definition of the bounded µ operator and as 2n m, there is no i such that (n + n) i = 0 holds. Thus f 2 (n, m) = 0 for 2n m. 13

III) f 3 : N N defined by f 3 (n) = µ i ( g(n, i) = 0 ) n 1 if i = 0 where g(n, i) = µj((n + i) (j + 1) = 0) if i = 1 n i if i 2 f 3 (n) = { 0 if n = 0 or n = 1 n if n 2 The µ operator is defined as follows: i 0 if g(n, i 0 ) = 0 and for all µi(g(n, i) = 0) := j < i 0 g(n, j) is defined and not 0 undefined otherwise The following cases need to be considered: (1) n = 0: Then g(0, 0) = 0, so f 3 (0) = 0. (2) n = 1: Then g(1, 0) = 0, so f 3 (1) = 0. (3) n 2: (a) i = 0: g(n, 0) = n 1 0 (but at least g(n, 0) is defined). (b) i = 1: Examine µj((n + i) (j + 1) = 0), i.e. check under which circumstances (n + i) (j + 1) becomes 0. As i = 1, (n + i) (j + 1) becomes 0, when j = n. As n > 0 it follows that µj((n + i) (j + 1) > 0 and thus g(n, 1) 0. (c) i 2: As n i = 0 if i = n, g(n, n) = 0. Since g(n, 0), g(n, 1),..., g(n, n 1) are defined but not 0, f 3 (n) = n for n 2. /3 P /8 P 14

Exercise 6 (5 Punkte) Let f : N N be defined as follows: 2 if n = 0 7 if n = 1 f(n) = 5 if n = 2 (2 + f(n 3)) (7 + f(n 1)) (5 + f(n 2)) if n 3 Is f primitive recursive? Justify your answer. We can use simultaneous recursion to show that f is primitive recursive: f 1 (0) = 2 f 2 (0) = 7 f 3 (0) = 5 f 1 (n + 1) = f 2 (n) f 2 (n + 1) = f 3 (n) f 3 (n + 1) = (2 + f 1 (n)) (7 + f 3 (n)) (5 + f 2 (n)) f(n) = f 1 (n) The functions used to define f 1, f 2, f 3, namely: g 1 = 2, g 2 = 7, g 3 = 5, h 1 (n, k 1, k 2, k 3 ) = k 2, h 2 (n, k 1, k 2, k 3 ) = k 3, h 3 (n, k 1, k 2, k 3 ) = (2 + k 1 ) (7 + k 3 ) (5 + k 2 ) are primitive recursive We know that functions defined by simultaneous recursion using primitive recursive functions are primitive recursive. Therefore, f 1, f 2, f 3 are primitive recursive, hence f is primitive recursive. /5 P /5 P 15

16

Exercise 7 (2P + 2P + 2P = 6 Punkte) a) State the theorem of Rice (the formal variant). Let P be a non-trivial property of languages of type 0, i.e. P L 0Σ. Then I(P ) = {n M n accepts a language L P } is undecidable b) In what follows, L(M n ) is the language accepted by the Turing machine M n. For each of the languages L below answer the following questions: (i) Can the theorem of Rice be used to prove that L is undecidable? Justify your answer. If the theorem of Rice can be used to prove undecidability give the proof. (ii) Is the language decidable? If yes, explain why. I) L = {n L(M n ) is in L 0 } (i): L = I(P ), where P = {L L L 0Σ } = L 0Σ. Hence P is trivial, and therefore, the theorem of Rice is not applicable. (ii): In fact, L is decidable as it is easy to construct a Turing machine that decides L as the Turing machine just needs to print yes for every input. 17

II) L = {n L(M n ) is infinite or contains an odd number of words}. (i): L = I(P ), where P = {L L 0Σ L is infinite or contains an odd number of words}. Yes, the theorem of Rice can be used, as P is clearly in L 0Σ and it is non-trivial, i.e. that P L 0Σ. Indeed: {a} P, thus P {a, aa} P, thus P L 0Σ (ii): Since L = I(P ) = {n L(M n ) P }, from the theorem of Rice it follows that L is undecidable. /6 P 18

Exercise 8 (2P + 1P + 1P + 2P = 6 Punkte) a) State the Post correspondence problem. A correspondence system P is a finite rule set over an alphabet Σ. P = {(p 1, q 1 ),..., (p n, q n )} with p i, q i Σ An index sequence I = i 1... i m of P is a sequence with 1 i k n for all k {1,..., m}. A solution for P is a sequence of indices I = i 1...i m such that p i1... p im = q i1... q im. The Post correspondence problem is the question whether a given correspondence system has a solution. b) Let G = (Σ, R) be a semi-thue system with Σ = {a, b, c} and R = {ac bb, b c, bc abc}. 1) Show that abc G bbc by writing all the steps and underlining the occurrence of the left hand side of the rule in the current word at every step. abc acc bbc /1 P 2) Construct the correspondence system P G,w,w as explained in the lecture, where w = abc and w = bbc. Assume that rule 4 is (X, Xw X) and rule 5 is (w XX, X). P G,w,w = {(ac, bb), (b, c), (bc, abc), (X, XabcX), (bbcxx, X), (a, a), (b, b), (c, c), (X, X)} /1 P 19

3) Construct a solution for P G,w,w with start 4 using the derivation abc G bbc. Construct the solution: p 4 = X q 4 = XabcX p 46289 = XabcX q 46289 = XabcXaccX p 46289189 = XabcXaccX q 46289189 = XabcXaccXbbcX p 462891895 = XabcXaccXbbcXX q 462891895 = XabcXaccXbbcXX p 462891895 = q 462891895, thus the sequence 462891895 is a solution. /6 P 20

Exercise 9 (2P + 2P + 4P + 2P = 10 Punkte) A company has n employees P = {p 1,..., p n }. It is known which persons work well together. This can be specified using for instance a list L containing sets {p i, p j } describing pairs of employees that work well together. The goal is to build k teams. We are interested in the problem of deciding whether the employees can be organized in at most k teams such that every team consists only of employees which work well together. Consider the following language: TEAM = {(L, P, k) P is a finite set, L is a set consisting of sets {p i, p j } P, k N and the members of P can be organized in at most k teams such that if p i p j, and p i and p j are in the same team then {p i, p j } L (they work well together)} a) One of the two triples (L, P, k) below is an instance of TEAM. Which is this? ({{1, 4}, {2, 4}}, {1, 2, 3, 4}, 3) ({{2, 3}}, {1, 2, 3, 4}, 2) b) Is TEAM in NP? Justify your answer briefly (you do not need to construct a Turing machine). Yes it is. Given (L, P, k). One can guess a partition Q = {q 1,..., q r } of P with r k that contains at most k sets and then check in polynomial time, if those sets contain only employees that work well together. This can be done as follows: Iterate through Q and for every q Q check in L if q consists only of employees which work well together. Let n l = 2 L and n p = P. The size of the input is n l + n p + k. As Q = q 1... q k = P we know that q i k n p thus we know that we have to check less than k ( np(np+1) 2 ) < k n 2 p pairs. For each pair we need to check at most n l elements in L. The complexity is n l n 2 p k < (n l + n p + k) 2. 21

c) In the lecture we studied the k-colorability problem: k-colorability = {G G = (V, E) is an undirected graph which is colorable with at most k colors such that if v i, v j V have the same color and v i v j then {v i, v j } E} Let f be the map which associates with every undirected graph G = (V, E) where V = {v 1,..., v m } the tuple (L G, P G, k G ) where: L G = { {v i, v j } v i, v j V, {v i, v j } E}, P G = V, k G = 3 Prove that f defines a polynomial reduction of 3-colorability to TEAM. Proof: G = (V, E) 3-colorability G is colored with at most three colors in such way that if v i, v j V have the same color and v i v j then {v i, v j } E There exists a partition Q = {q 1, q 2, q 3 } of P G = V such that for every q Q, all the elements of q have the same color There exists a partition Q = {q 1, q 2, q 3 } of P G = V such that for every q Q, for all v i, v j q k with v i v j, {v i, v j } E f(g) = ({ {v i, v j } v i, v j V, {v i, v j } E}, V, 3) TEAM In addition, we can easily show that f can be computed in polynomial time as constructing the complement of E and copying of V can clearly be done in polynomial time. /4 P d) We know that the 3-colorability problem is an NP-complete problem. Prove or refute the following: TEAM is an NP-complete problem. Yes TEAM is NP complete. In (2) we have shown that TEAM is in NP. In (3) we have shown that TEAM is NP-hard by giving a polynomial reduction of the NP-hard problem 3-colorability to TEAM. As a problem is NP-complete iff it is NP-hard and in NP, TEAM is NP-complete. /10 P 22