Universität Koblenz-Landau FB 4 Informatik
Prof. Dr. Viorica Sofronie-Stokkermans∗1 29.11.2017
M.Ed. Dennis Peuter∗2
Exercises for Advances in Theoretical Computer Science Exercise Sheet 6
Due at 04.12.2017, 10:00 s.t.
Remark: For the exercises where you have to dene primitive recursive functions, you are allowed to use all functions that were proved to be primitive recursice in the lecture or in a previous exercise.
Exercise 6.1
Prove that the following functions are primitive recursive:
1. cks :Nk →N, wheres∈N, dened for every n∈Nk by:cks(n) =s. 2. fac:N→N, dened for every n∈Nby:fac(n) =n!.
3. exp:N×N→N, dened for every (n, m)∈N×Nby:exp(n, m) =nm. 4. eq:N×N→N, dened for every (n, m)∈N×Nby: eq(n, m) =
(1 if n=m
0 otherwise. Exercise 6.2
Consider the following primitive recursive functions:
I) f1 = +◦(− ◦(π21, c25),∗ ◦(π22, π22)) II) f2 =PR[(+1)◦0,∗ ◦((+1)◦π12, π22)]
III) f3 =PR[c11,∗ ◦(π13, π33)]◦((−1)◦π12, π22)
a) Which is the arity of f1, off2 and off3? (i.e. how many arguments does each of these functions have?)
b) What do these functions compute if all arguments are equal to 2?
c) What do these functions compute in general?
Exercise 6.3
Express in the formh(n) = 0 withh primitive recursive the following conditions:
I) nis greater than 20 and is a perfect square, i.e.
n≥20 and∃k≤n:k∗k=n.
II) All prime divisors of n1 are smaller thann2:
∀k≤n1 (prime(k) = 0or |(k, n1) = 0 or k≤n2). Note: primeand |are the function dened in the lecture with:
prime(k) = 1 ifk is a prime number and prime(k) = 0 if k is not a prime number;
|(k, n) = 1 if k divides n and|(k, n) = 0 if k does not divide n.
Exercise 6.4
Prove that the following functions are primitive recursive:
I) max:N2 →Ndened bymax(x, y) =
(x if x≥y y otherwise. II) div:N2→N dened bydiv(x, y) =
(x+ 1 if y= 0 bxyc otherwise. III) mod:N2→N dened bymod(x, y) =
(x if y= 0 x mod y otherwise.
Note: Here bxc is the largest integer which is smaller than or equal to x (oorx).
∗1 B 225 sofronie@uni-koblenz.de https://userpages.uni-koblenz.de/~sofronie/
∗2 B 223 dpeuter@uni-koblenz.de https://userpages.uni-koblenz.de/~dpeuter/
If you want to submit solutions, please do so until 04.12.2017, 10:00 s.t. via the cardboard box in the shelf in room B 222 or via e-mail (with Homework ACTCS in the subject) to dpeuter@uni-koblenz.de.