190 likes | 208 Views
Lecture 1-4 Recursive Functions. Initial Functions. Zero function ζ (n) = 0. Successor σ (n) = n+1, for n ε N. Projection π i (n 1 ,…,n k ) = n i. k. Composition. Let m, k be two integers. Given functions g: N → N and h i : N → N for I = 1, 2, …, m, define f: N → by
E N D
Initial Functions • Zero function ζ(n) = 0. • Successor σ(n) = n+1, for n ε N. • Projectionπi (n1,…,nk) = ni. k
Composition • Let m, k be two integers. • Given functions g: N → N and hi: N → N for I = 1, 2, …, m, define f: N → by f(n1,…,nk) = g(h1(n1,…,nk),…,hm(n1,…,nk) • f is called thecompositionof g and h1, …,hm. • f = go(h1,…,hm) m k k
Primitive Recursion k k+2 • Let k > 0. Given g: N → N and h: N → N, (when k=0, g is a constant), define f : N → N by f(n1,…nk,0) = g(n1,…,nk) f(n1,…,nk,m+1) = h(n1,…,nk,m,f(n1,…nk,m) k+1
Primitive Recursive Functions • All initial functions are primitive recursive. • If g and h1, …, hm are primitive recursive, so is go(h1, …, hk). • If g and h are primitive recursive, so is f obtained from g and h by primitive recursion. • Nothing else is primitive recursive.
Add(m, n) = m+n • Add(m,0) = π1 (m) • Add(m, n+1) = σ( π3 (m,n, add(m, n))) 1 3
mult(m, n) = mn • mult(m, 0) = ζ(m) • Mult(m, n+1) = add(π1(m,n,mult(m,n)), π3(m, n, mult(m,n)) 1 3
minus(m,n)= m-n if m > n; 0 if m<n • pred(m) = minus(m,1) pred(0) = ζ(0) pred(m+1) = m = π1 (m, pred(m)) • minus(m,0) = π1 (m) minus(m, n+1) = pred(π3(m,n,minus(m, n)) 2 1 3
Pairing Function • A function f: N → N is a pairing function if it satisfies the following conditions: (1) f is 1-to-1 and onto; (2) f is primitive recursive; (3) f(i, j) < f(i+1, j), f(i, j) < f(i, j+1). • For example,
Two “inverse” functions i = g(f(i,j)) and j = h(f(i, j)) are also primitive recursive. 14 13 9 8 5 12 2 4 7 11 0 1 3 6 10
Bounded minimization K+1 • Given g: N → N, define f by f(n1, …, nk, m) = min {i | g(n1, …, nk, i)=1} if there exists i < m such that g(n1, …, nk, i) =1; = 0, otherwise. • If g is primitive recursive, so is f.
Unbounded minimization K+1 • Given g: N → N, define f by f(n1, …, nk) = min {i | g(n1, …, nk, i)=1} if there exists i such that g(n1, …, nk, i) =1; = ↑, otherwise. • f may not be primitive recursive, even if g is.
Partial Recursive Functions • All initial functions are partial recursive. • If g is a total recursive function, then f obtained from g by unbounded minimization is partial recursive. • If g and h1,…, hk are partial recursive, so is go(h1,…,hk). • If g and h are partial recursive, so is f obtained from g and h by primitive recursion.
Over Σ* • Zero function ζ(x) = ε. • Successor σa(x) = xa for a in Σ. • Projection (no change) • Composition (no change) • Primitive recursion (need a change, m+1 is replaced by ma) • Unbounded minimization (need to give a linear ordering of Σ*)
From Σ* to Γ* for Σ* cΓ* • Zero function ζ(x) = ε. • Successor σa(x) = xa for a in Γ. • N can be considered as a subset of {0, 1}* if we represent n by 1…1 n
Theorem • A function is partial recursive iff it is Turing-computable.
Theorem The following are equivalent: • A is r.e. • A is Turing-acceptable. • A is the range of a primitive recursive function. • A is the domain of a partial recursive function.
Pairing function on Σ* • Let π(i, j) be a pairing function on N. • Let φ be a 1-to-1 onto mapping from N to Σ*. • Let μ be a 1-to-1 onto mapping from Σ* to N. • Then p(x, y) = φ(π(μ(x), μ(y)) is a pairing function on Σ*.