Recursive Functions. Recursive functions are built up from basic functions by some operations.

Similar documents
Section 13.2 The Church-Turing Thesis The Church-Turing Thesis: Anything that is intuitively computable can be be computed by a Turing machine.

Prim Rec, Decidable, Undecidable, and Beyond. William Gasarch-U of MD

Lecture 7: Primitive Recursion is Turing Computable. Michael Beeson

Computability Theory

Chapter 6 Recursive functions

CHAPTER 4. COMPUTABILITY AND DECIDABILITY

COMPUTABILITY THEORY AND RECURSIVELY ENUMERABLE SETS

Theory of Computer Science

Theory of Computer Science. Theory of Computer Science. D4.1 Introduction. D4.2 Basic Functions and Composition. D4.3 Primitive Recursion

Recursive Function Theory

Recursive Functions. 6.1 Primitive Recursive Functions

Lesson 24 - Exploring Graphical Transformations and Composite Functions

CDM Primitive Recursion

Solution Set 8 Date: 1 December, 1992

Recursive Function Theory

Functions. How is this definition written in symbolic logic notation?

Phil 320 Chapter 7: Recursive sets and relations Note: 0. Introduction Significance of and main objectives for chapter 7:

September 18, B Math Test Chapter 1 Name: x can be expressed as: {y y 0, y R}.

CDM Primitive Recursion

CDM Loop Programs. 05-loop-progs 2017/12/15 23:18. Program Equivalence 3. Program Transformations 4. Rudimentary Functions 5. Rudimentary Programs 6

Finite Math Linear Programming 1 May / 7

1 Introduction. Martin Böhme Bodo Manthey

Practice Final. Read all the problems first before start working on any of them, so you can manage your time wisely

Lecture 5: The Halting Problem. Michael Beeson

SEQUENCES, MATHEMATICAL INDUCTION, AND RECURSION

Midterm Practice Exam Sample Solutions

(a) Give inductive definitions of the relations M N and M N of single-step and many-step β-reduction between λ-terms M and N. (You may assume the

Semantics of COW. July Alex van Oostenrijk and Martijn van Beek

Computation Club: Gödel s theorem

Computability via Recursive Functions

Functions. Def. Let A and B be sets. A function f from A to B is an assignment of exactly one element of B to each element of A.

Final Exam Review Algebra Semester 1

MAT121: SECTION 2.7 ANALYZING GRAPHS AND PIECEWISE FUNCTIONS

MATH Iris Loeb.

SEQUENCES, MATHEMATICAL INDUCTION, AND RECURSION

CAS 701 Presentation. Ackermann's Function. Qinglei Zhang, Nov. 20, 2008.

05. Turing Machines and Spacetime. I. Turing Machines and Classical Computability.

Finite Automata Theory and Formal Languages TMV027/DIT321 LP4 2016

Convexity Theory and Gradient Methods

6.1 Evaluate Roots and Rational Exponents

Theory of Computer Science. D2.1 Introduction. Theory of Computer Science. D2.2 LOOP Programs. D2.3 Syntactic Sugar. D2.

CIS 500 Software Foundations Fall October 2

15.082J and 6.855J. Lagrangian Relaxation 2 Algorithms Application to LPs

CS422 - Programming Language Design

Diagonalization. The cardinality of a finite set is easy to grasp: {1,3,4} = 3. But what about infinite sets?

Homework 1. Due Date: Wednesday 11/26/07 - at the beginning of the lecture

p x i 1 i n x, y, z = 2 x 3 y 5 z

Compiler Construction Lecture 05 A Simple Stack Machine. Lent Term, Lecturer: Timothy G. Griffin. Computer Laboratory University of Cambridge

Integrated Mathematics I Performance Level Descriptors

CSE505, Fall 2012, Midterm Examination October 30, 2012

8 Matroid Intersection

Shiqian Ma, MAT-258A: Numerical Optimization 1. Chapter 2. Convex Optimization

CSE 20 DISCRETE MATH. Winter

1 Elementary number theory

Convexity I: Sets and Functions

Material from Recitation 1

Let A(x) be x is an element of A, and B(x) be x is an element of B.

11/6/17. Outline. FP Foundations, Scheme. Imperative Languages. Functional Programming. Mathematical Foundations. Mathematical Foundations

Using Arithmetic of Real Numbers to Explore Limits and Continuity

1 Probability Review. CS 124 Section #8 Hashing, Skip Lists 3/20/17. Expectation (weighted average): the expectation of a random quantity X is:

FP Foundations, Scheme

Convex sets and convex functions

Chapter 1 & 2. Homework Ch 1 & 2

1KOd17RMoURxjn2 CSE 20 DISCRETE MATH Fall

We can create PDAs with multiple stacks. At each step we look at the current state, the current input symbol, and the top of each stack.

PHIL 240, Introduction to Logic, Sections Fall 2011 FINAL EXAM 14 December Name (5 points): Section (5 points):

GSE Algebra 1 Name Date Block. Unit 3b Remediation Ticket

A catalogue of proofs that various sets, functions and relations are primitive recursive 26 February 2012 at 20:57

Nonstandard Models of True Arithmetic. other models of true arithmetic (the set of sentences true in the standard model) that aren t

Graphs and Network Flows IE411. Lecture 13. Dr. Ted Ralphs

In this chapter, we define limits of functions and describe some of their properties.

Jessica Su (some parts copied from CLRS / last quarter s notes)

Notions of Computability

Programming Languages Third Edition

Programming Languages Fall 2014

AMSC/CMSC 460 Final Exam, Fall 2007

Formal Predicate Calculus. Michael Meyling

CS 311: Computational Structures

Recursively Enumerable Languages, Turing Machines, and Decidability

. Tutorial Class V 3-10/10/2012 First Order Partial Derivatives;...

Introduction to optimization

Today s Lecture 4/13/ WFFs/ Free and Bound Variables 9.3 Proofs for Pred. Logic (4 new implicational rules)!

Chapter S:V. V. Formal Properties of A*

CSE 20 DISCRETE MATH WINTER

Skill 3 Relations and Functions

Hw 4 Due Feb 22. D(fg) x y z (

CSC Discrete Math I, Spring Sets

Denotational semantics

Lecture 1 Contracts. 1 A Mysterious Program : Principles of Imperative Computation (Spring 2018) Frank Pfenning

FINITELY GENERATED CLASSES OF SETS OF NATURAL NUMBERS

Natural Numbers. We will use natural numbers to illustrate several ideas that will apply to Haskell data types in general.

Source of Slides: Introduction to Automata Theory, Languages, and Computation By John E. Hopcroft, Rajeev Motwani and Jeffrey D.

HS Mathematics Item Specification C1 TK

Optimization of logical query plans Eliminating redundant joins

Section 2.2: Introduction to the Logic of Quantified Statements

Deductive Methods in Computer Science

RECITATION 5: INDUCTION, PRIMITIVE RECURSION, & MIDTERM REVIEW

Design and Analysis of Algorithms - - Assessment

Bidirectionalization Transformation Based on Automatic Derivation of View Complement Functions

Introduction to the Lambda Calculus

Transcription:

Recursive Functions Recursive functions are built up from basic functions by some operations.

The Successor Function Let s get very primitive. Suppose we have 0 defined, and want to build the nonnegative integers and our entire number system. We define the successor operator: the function S(x) that takes a number x to its successor x+1. This gives one the nonnegative integers N 0 = {0, 1, 2,...}. Goddard 16: 2

Defining Addition Addition must be defined in terms of the successor function, since initially that is all we have: add(x, 0) = x add(x, S(y)) = S(add(x, y)) For example, one can show that 2 + 2 = 4: add(2, 2) = S(add(2, 1)) = S(S(add(2, 0)) = S(S(2)) = S(3) = 4 Goddard 16: 3

The Three Basic Functions We formalize the above process. Primitive recursive functions are built up from three basic functions using two operations. The basic functions are: 1. Zero. Z(x) 0. 2. Successor. S(x) x + 1. 3. Projection. A projection function selects out one of the arguments. Specifically P 1 (x, y) x and P 2 (x, y) y Goddard 16: 4

The Composition Operation There are two operations that make new functions from old: composition and primitive recursion. Composition replaces the arguments of a function by another. For example, one can define a function f by f(x, y) = g(h 1 (x, y), h 2 (x, y)) where one supplies the functions g 1, g 2 and h. Goddard 16: 5

Primitive Recursion A typical use of primitive recursion has the following form: f(x, 0) = g 1 (x) f(x, S(y)) = h(g 2 (x, y), f(x, y)) where one supplies the functions g 1, g 2 and h. For example, in the case of addition, the h is the successor function of the projection of the 2nd argument. Goddard 16: 6

More Primitive Recursion A special case of primitive recursion is for some constant number k: f(0) = k f(s(y)) = h(y, f(y)) Primitive recursive functions. A function is primitive recursive if it can be built up using the base functions and the operations of composition and primitive recursion. Goddard 16: 7

Primitive Recursive Functions are T-computable Composition and primitive recursion preserve the property of being computable by a TM. Thus: Fact. A primitive recursive function is T- computable. Goddard 16: 8

Example: Multiplication mul(x, 0) = 0 mul(x, S(y)) = add(x, mul(x, y)) (Now that we have shown addition and multiplication are primitive recursive, we will use normal arithmetical notation for them.) Goddard 16: 9

Example: Subtraction and Monus Subtraction is harder, as one needs to stay within N 0. So define subtract as much as you can, called monus, written and defined by: { x y if x y, x y = 0 otherwise. To formulate monus as a primitive recursive function, one needs the concept of predecessor. Goddard 16: 10

Example: Predecessor pred(0) = 0 pred(s(y)) = y Goddard 16: 11

Practice Show that monus is primitive recursive. Goddard 16: 12

Solution to Practice monus(x, 0) = x monus(x, S(y)) = pred(monus(x, y)) Goddard 16: 13

Example: Predicates A function that takes on only values 0 and 1 can be thought of as a predicate, where 0 means false, and 1 means true. Example: A zero-recognizer function is 1 for argument 0, and 0 otherwise: sgn(0) = 1 sgn(s(y)) = 0 Goddard 16: 14

Example: Definition by Cases f(x) = { g(x) if p(x), h(x) otherwise. We claim that if g and h are primitive recursive functions, then f is primitive recursive too. One way to see this is to write some algebra: f(x) g(x) p(x) + (1 p(x)) h(x) Goddard 16: 15

Practice Show that if p(x) and q(x) are primitive recursive predicates, then so is p q (the and of them) defined to be true exactly when both p(x) and q(x) are true. Goddard 16: 16

Solution to Practice p q = p(x) q(x) Goddard 16: 17

Functions that are not Primitive Recursive Theorem. Not all T-computable functions are primitive recursive. Yes, it s a diagonalization argument. Each partial recursive function is given by a finite string. Therefore, one can number them f 1, f 2,.... Define a function g by g(x) = f x (x) + 1. This g is a perfectly computable function. But it cannot be primitive recursive: it is different from each primitive recursive function. Goddard 16: 18

Ackermann s Function Ackermann s function is a famous function that is not primitive recursive. It is defined by: A(0, y) = y + 1 A(x, 0) = A(x 1, 1) A(x, y + 1) = A(x 1, A(x, y)) Here are some tiny values of the function: A(1, 0) = A(0, 1) = 2 A(1, 1) = A(0, A(1, 0)) = A(0, 2) = 3 A(1, 2) = A(0, A(1, 1)) = A(0, 3) = 4 A(2, 0) = A(1, 1) = 3 A(2, 1) = A(1, A(2, 0)) = A(1, 3) = A(0, A(1, 2)) = A(0, 4) = 5 Goddard 16: 19

Practice Calculate A(2, 2). Goddard 16: 20

Solution to Practice A(2, 2) = A(1, A(2, 1)) = A(1, 5) = A(0, A(1, 4)). Now, A(1, 4) = A(0, A(1, 3)), and A(1, 3) = A(0, A(1, 2)) = A(0, 4) = 5. So A(1, 4) = 6, and A(2, 2) = 7. Goddard 16: 21

Bounded and Unbounded Minimization Suppose q(x, y) is some predicate. One operation is called bounded minimization. For some fixed k: f(x) = min{ y k : q(x, y) } Note that one has to deal with those x where there is no y. Actually, bounded minimization is just an extension of the case statement (equivalent to k 1 nested case statements), and so if f is formed by bounded minimization from a primitive recursive predicate, then f is primitive recursive. Goddard 16: 22

Unbounded Minimization We define f(x) = µ q(x, y) to mean that f(x) is the minimum y such that the predicate q(x, y) is true (and 0 if q(x, y) is always false). Definition. A function is µ-recursive if it can be built up using the base functions and the operations of composition, primitive recursion and unbounded minimization. Goddard 16: 23

µ-recursive Functions It is not hard to believe that all such functions can be computed by some TM. What is a much deeper result is that every TM function corresponds to some µ-recursive function: Theorem. A function is T-computable if and only if it is µ-recursive. We omit the proof. Goddard 16: 24

Summary A primitive recursive function is built up from the base functions zero, successor and projection using the two operations composition and primitive recursion. There are T-computable functions that are not primitive recursive, such as Ackermann s function. Goddard 16: 25