Theory of Computation Lecture 5: Programs and Computable Functions III

Slides:



Advertisements
Similar presentations
November 19, 2009Theory of Computation Lecture 19: Calculations on Strings IV 1 Numerical Representation of Strings Correspondingly, we define the following:
Advertisements

October 13, 2009Theory of Computation Lecture 11: A Universal Program III 1 Coding Programs by Numbers Gödel numbers are usually very large, even for small.
October 27, 2009Theory of Computation Lecture 12: A Universal Program IV 1Universality Then we append the following instruction: [C]IF K = Lt(Z) + 1 
December 8, 2009Theory of Computation Lecture 22: Turing Machines IV 1 Turing Machines Theorem 1.1: Any partial function that can be computed by a Post-
September 24, 2009Theory of Computation Lecture 6: Primitive Recursive Functions II 1 Homework Questions Question 1: Write a program P that computes 
September 17, 2009Theory of Computation Lecture 4: Programs and Computable Functions III 1 Macros Now we want to use macros of the form: W  f(V 1, …,
Programming Language Semantics Denotational Semantics Chapter 5 Part III Based on a lecture by Martin Abadi.
Chapter 4: A Universal Program 1. Coding programs Example : For our programs P we have variables that are arranged in a certain order: Y 1 X 1 Z 1 X 2.
December 1, 2009Theory of Computation Lecture 21: Turing Machines II 1 Simulation of L n in T We will now construct a Post-Turing program Q that simulates.
Lecture 1: A Formal Model of Computation 虞台文 大同大學資工所 智慧型多媒體研究室.
CSE 105 Theory of Computation Alexander Tsiatas Spring 2012 Theory of Computation Lecture Slides by Alexander Tsiatas is licensed under a Creative Commons.
Basic Definitions of Set Theory Lecture 24 Section 5.1 Fri, Mar 2, 2007.
September 29, 2009Theory of Computation Lecture 7: Primitive Recursive Functions III 1 Some Primitive Recursive Functions Example 3: h(x) = x! Here are.
Theory of Computation Lecture 5: Primitive Recursive Functions I
November 12, 2009Theory of Computation Lecture 17: Calculations on Strings II 1 Numerical Representation of Strings First, we define two primitive recursive.
Section 7.6 Functions Math in Our World. Learning Objectives  Identify functions.  Write functions in function notation.  Evaluate functions.  Find.
Functions 2 Copyright © Cengage Learning. All rights reserved.
October 4, 2016Theory of Computation Lecture 9: A Universal Program I 1Minimalization Example 15: R(x, y) R(x, y) is the remainder when x is divided by.
Applied Discrete Mathematics Week 2: Functions and Sequences
Another Word on PRC Classes
Theory of Computation Lecture 10: A Universal Program I
Theory of Computation Lecture 4: Programs and Computable Functions II
EQUATION IN TWO VARIABLES:
Theory of Computation Lecture 12: A Universal Program III
Theory Of Computer Science
Theory of Computation Lecture 23: Turing Machines IV
Theory of Computation Lecture 14: A Universal Program V
Recursively Enumerable Sets
Numerical Representation of Strings
Negations of Quantified Statements
Theory of Computation Lecture 22: Turing Machines III
Enough Mathematical Appetizers!
Computation.
Theory of Computation Lecture 16: A Universal Program VII
Copyright © Cengage Learning. All rights reserved.
Theory of Computation Lecture 6: Primitive Recursive Functions I
Exploring Exponential Growth and Decay Models
Copyright © Cengage Learning. All rights reserved.
Applied Discrete Mathematics Week 6: Computation
Theory Of Computer Science
Nested Quantifiers Nested quantifiers are often necessary to express the meaning of sentences in English as well as important concepts in computer science.
Copyright © Cengage Learning. All rights reserved.
Linear Algebra Lecture 37.
The Programming Language L
MA/CSSE 474 More Math Review Theory of Computation
Discrete Mathematics CMP-200 Propositional Equivalences, Predicates & Quantifiers, Negating Quantified Statements Abdul Hameed
Pairing Functions and Gödel Numbers
Copyright © Cengage Learning. All rights reserved.
Theory of Computation Lecture 21: Turing Machines II
Linear Algebra Lecture 6.
Copyright © Cengage Learning. All rights reserved.
Numerical Representation of Strings
Recursively Enumerable Sets
Primitive Recursive Predicates
Theory of Computation Lecture 5: Programs and Computable Functions III
The Programming Language L
Numerical Representation of Strings
Theory of Computation Lecture 4: Programs and Computable Functions II
Numerical Representation of Strings
Theory of Computation Lecture 9: A Universal Program I
Pairing Functions and Gödel Numbers
Theory of Computation Lecture 6: Primitive Recursive Functions I
Some Primitive Recursive Functions
Theory of Computation Lecture 22: Turing Machines II
Theory of Computation Lecture 13: A Universal Program V
Recursively Enumerable Sets
Theory of Computation Lecture 17: Calculations on Strings II
Theory of Computation Lecture 12: A Universal Program IV
Theory of Computation Lecture 11: A Universal Program III
Theory of Computation Lecture 23: Turing Machines III
Presentation transcript:

Theory of Computation Lecture 5: Programs and Computable Functions III In general, a partial function f on a set Sm is a function whose domain is a subset of Sm. If a partial function on Sm has the domain Sm, then it is called total. September 19, 2017 Theory of Computation Lecture 5: Programs and Computable Functions III

Theory of Computation Lecture 5: Programs and Computable Functions III A given partial function g (of one or more variables) is said to be partially computable if it is computed by some program. This is the case if there is a program P such that g(r1, r2, …, rm) = P(m)(r1, r2, …, rm) for all r1, r2, …, rm. This means not only that both sides have the same value when they are defined, but also that when either side of the equation is undefined, the other one is as well. A function is said to be computable if it is both partially computable and total. September 19, 2017 Theory of Computation Lecture 5: Programs and Computable Functions III

Theory of Computation Lecture 5: Programs and Computable Functions III Macros So far we have used macros in an informal way. Let us now develop a more precise definition of them. Let f(x1, x2, …, xn) be a partially computable function, and P be a program that computes f. Let us assume that the variables in P are named Y, X1, …, Xn, Z1, …, Zk, the labels in P are named E, A1, …, Al, and for each instruction of P of the form IF V0 GOTO Ai there is in P an instruction labeled Ai . September 19, 2017 Theory of Computation Lecture 5: Programs and Computable Functions III

Theory of Computation Lecture 5: Programs and Computable Functions III Macros We can modify any program of the language L to comply with these assumptions. We write: P = P (Y, X1, …, Xn, Z1, …, Zk; E, A1, …, Al) In particular, we will use: Qm = P (Zm, Zm+1, …, Zm+n, Zm+n+1, …, Zm+n+k; Em, Am+1, …, Am+l) for a given value m. September 19, 2017 Theory of Computation Lecture 5: Programs and Computable Functions III

Theory of Computation Lecture 5: Programs and Computable Functions III Macros Now we want to use macros of the form: W  f(V1, …, Vn) in our programs, where W, V1, …, Vn can be any variables; W could be among V1, …, Vn. We expand the macro as follows: Zm  0 Zm+1  V1 Zm+2  V2 : Zm+n  Vn Zm+n+1  0 Zm+n+2  0 Zm+n+k  0 Qm [Em] W  Zm September 19, 2017 Theory of Computation Lecture 5: Programs and Computable Functions III

Theory of Computation Lecture 5: Programs and Computable Functions III Macros Whenever we expand a macro, the number m has to be chosen large enough so that none of the variables or labels in Qm occur in the main program. Note that in the expansion the output and local variables are set to zero, although at the start of the main program they are set to zero anyway. This is necessary because the macro expansion may be part of a loop in the main program. September 19, 2017 Theory of Computation Lecture 5: Programs and Computable Functions III

Theory of Computation Lecture 5: Programs and Computable Functions III Macros Obviously, if f(V1, …, Vn) is undefined (), the program Qm will never terminate. So if f is not total, and the macro W  f(V1, …, Vn) is encountered when V1, …, Vn have values for which f is not defined, the main program will never terminate. Example: Z  X1 – X2 Y  Z + X3 This program computes f(x1 ,x2 ,x3), where f(x1 ,x2 ,x3) = (x1 - x2) + x3 , if x1  x2 =  , if x1 < x2 September 19, 2017 Theory of Computation Lecture 5: Programs and Computable Functions III

Theory of Computation Lecture 5: Programs and Computable Functions III Macros Now let us introduce macros of the form IF P(V1, …,Vn) GOTO L , where P(x1, …,xn) is a computable predicate. This will be based on the convention that TRUE = 1, FALSE = 0. According to this convention, predicates are just total functions whose values are always either 0 or 1. September 19, 2017 Theory of Computation Lecture 5: Programs and Computable Functions III

Theory of Computation Lecture 5: Programs and Computable Functions III Macros Let P(x1, …,xn) be a computable predicate. Then we expand the macro IF P(V1, …,Vn) GOTO L to Z  P(V1, …,Vn) IF Z0 GOTO L As usual, the variable Z has to be chosen to create no conflicts with the main program. September 19, 2017 Theory of Computation Lecture 5: Programs and Computable Functions III

Theory of Computation Lecture 5: Programs and Computable Functions III Macros Example: How can we expand the macro IF V=0 GOTO L ? V = 0 corresponds to the following predicate P(x): P(x) = TRUE , if x = 0 = FALSE, otherwise This can be computed by the following program: IF X0 GOTO E Y  Y+1 September 19, 2017 Theory of Computation Lecture 5: Programs and Computable Functions III