Theory of Computation Lecture 17: Calculations on Strings II

Slides:



Advertisements
Similar presentations
Complexity 11-1 Complexity Andrei Bulatov Space Complexity.
Advertisements

Discrete Mathematics Lecture 4 Harper Langston New York University.
October 27, 2009Theory of Computation Lecture 12: A Universal Program IV 1Universality Then we append the following instruction: [C]IF K = Lt(Z) + 1 
November 10, 2009Theory of Computation Lecture 16: Computation on Strings I 1Diagonalization Another example: Let TOT be the set of all numbers p such.
October 8, 2009Theory of Computation Lecture 10: A Universal Program II 1 Pairing Functions and Gödel Numbers This way the equation  x, y  = z defines.
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, …,
October 1, 2009Theory of Computation Lecture 8: Primitive Recursive Functions IV 1 Primitive Recursive Predicates Theorem 6.1: Let C be a PRC class. If.
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.
Section 2.6 Representation of numbers. Decimal representation (base 10) Given a positive integer X, the decimal representation of X is a string of digits.
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.
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
Lecture 21 Reducibility. Many-one reducibility For two sets A c Σ* and B c Γ*, A ≤ m B if there exists a Turing-computable function f: Σ* → Γ* such that.
November 12, 2009Theory of Computation Lecture 17: Calculations on Strings II 1 Numerical Representation of Strings First, we define two primitive recursive.
December 3, 2009Theory of Computation Lecture 21: Turing Machines III 1 Simulation of T in L Now the MIDDLE section of Q can be generated by replacing.
ECE DIGITAL LOGIC LECTURE 2: DIGITAL COMPUTER AND NUMBER SYSTEMS Assistant Prof. Fareena Saqib Florida Institute of Technology Fall 2016, 01/14/2016.
Mathematics Medicine Sequences and series.
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.
Relations, Functions, and Matrices
Theory of Computation Lecture 10: A Universal Program I
Theory of Computation Lecture 12: A Universal Program III
2.7 Combining Functions.
Theory Of Computer Science
Copyright © Cengage Learning. All rights reserved.
Modeling Arithmetic, Computation, and Languages
Sullivan Algebra & Trigonometry: Section 3.1 Functions
Diagonalization and Reducibility
Theory of Computation Lecture 23: Turing Machines IV
Theory of Computation Lecture 14: A Universal Program V
Recursively Enumerable Sets
Numerical Representation of Strings
Theory of Computation Lecture 22: Turing Machines III
Functions Defined on General Sets
CS201: Data Structures and Discrete Mathematics I
Computation.
Theory of Computation Lecture 16: A Universal Program VII
Direct Proof and Counterexample V: Floor and Ceiling
Copyright © Cengage Learning. All rights reserved.
Copyright © Cengage Learning. All rights reserved.
The Satisfiability Problem
COUNTING AND PROBABILITY
Theory Of Computer Science
Section 1.1 Functions and Change
5.1 Power Series Method Section 5.1 p1.
Undecidable problems:
Graphs, Linear Equations, and Functions
The Programming Language L
Mathematical Background 1
Proposed in Turing’s 1936 paper
Theory of Computation Lecture 21: Turing Machines II
Numerical Representation of Strings
Diagonalization and Reducibility
Recursively Enumerable Sets
Primitive Recursive Predicates
Subject Name: FORMAL LANGUAGES AND AUTOMATA THEORY
The Programming Language L
Numerical Representation of Strings
Numerical Representation of Strings
Numerical Representation of Strings
Section 1 – Relations and Functions
More Undecidable Problems
Pairing Functions and Gödel Numbers
Theory of Computation Lecture 6: Primitive Recursive Functions I
Theory of Computation Lecture 22: Turing Machines II
Theory of Computation Lecture 13: A Universal Program V
Recursively Enumerable Sets
Numerical Representation of Strings
Lecture 4: Unsolvable Problems
Theory of Computation Lecture 23: Turing Machines III
Presentation transcript:

Theory of Computation Lecture 17: Calculations on Strings II The Parameter Theorem Let us say that you have a partially computable function f that takes m + n inputs: f (x1, …, xm, u1, …, un) This function is computed by a program with number y. Now it turns out that you always want to use the same last n inputs (u1, …, un) whenever you call f. So you would like to use a function g taking only the first m inputs and using fixed values for the last n ones: g(x1, …, xm) This function is supposed to give the same outputs as f for any input (x1, …, xm) if (u1, …, un) never changes. April 16, 2019 Theory of Computation Lecture 17: Calculations on Strings II

Theory of Computation Lecture 17: Calculations on Strings II The Parameter Theorem Now how can I obtain this function g? It is very easy! Since there is a program that computes f(x1, …, xm, u1, …, un), I can reuse the code for f and just prepend the following instructions to it: Xm+1  u1 Xm+2  u2 … Xm+n  un Obviously, this new program computes g(x1, …, xm) with fixed values for (u1, …, un). April 16, 2019 Theory of Computation Lecture 17: Calculations on Strings II

Theory of Computation Lecture 17: Calculations on Strings II The Parameter Theorem We said that f is computed by program number y. But what is the number z of the program that computes g? Clearly, the code for g depends on the fixed values we want to assign to (u1, …, un), and it also depends on the original program with the number y and the number n of inputs that g will still take, and the number m of inputs that will be kept constant. Computing z thus depends on all of these variables and is achieved by the function S: Smn(u1, …, un, y) The parameter theorem states that this function always exists and is primitive recursive. April 16, 2019 Theory of Computation Lecture 17: Calculations on Strings II

Theory of Computation Lecture 17: Calculations on Strings II The Recursion Theorem Let us say that we have a partially computable function g that takes (m + 1) inputs. Then the recursion theorem tells us that we can always find at least one number e, such that the program with number e takes the m last inputs of g and then computes the same output that g would produce for the same inputs and the first input being e: e(m)(x1, ..., xm) = g(e, x1, ..., xm). April 16, 2019 Theory of Computation Lecture 17: Calculations on Strings II

Theory of Computation Lecture 17: Calculations on Strings II The Recursion Theorem Now let us say that we have a function g like this: g(z, x) = z. With the help of the recursion theorem, we know that we can always find a number e such that e(x) = g(e, x) = e. Such programs generate copies of themselves. Thus the parameter theorem is the theoretical foundation of the existence of computer viruses. April 16, 2019 Theory of Computation Lecture 17: Calculations on Strings II

Theory of Computation Lecture 17: Calculations on Strings II Rice’s Theorem Let  be some collection of partially computable functions of one variable. We associate with  the following index set R: R = {t  N | t  }. R will be a recursive set if there is an algorithm which accepts as input the number t of a program and returns the value TRUE or FALSE depending on whether or not the function computed by this program belongs to . April 16, 2019 Theory of Computation Lecture 17: Calculations on Strings II

Theory of Computation Lecture 17: Calculations on Strings II Rice’s Theorem Some examples are: (1)  is the set of computable functions; (2)  is the set of primitive recursive functions; (3)  is the set of partially computable functions which are defined for all but a finite number of values of x. Theorem 7.1 (Rice's Theorem): Let  be a collection of partially computable functions of one variable. Let there be partially computable functions f(x) and g(x) such that f(x) belongs to  but g(x) does not. Then R is not recursive. April 16, 2019 Theory of Computation Lecture 17: Calculations on Strings II

Theory of Computation Lecture 17: Calculations on Strings II Rice’s Theorem Rice’s Theorem tells us that there is no way to algorithmically determine non-trivial properties of the function computed by another program. Trivial properties are those that apply to all partially computable functions or none of them. The theorem uses functions f(x) and g(x) - such that f(x) belongs to a collection  but g(x) does not - for the sole purpose of excluding such trivial cases. April 16, 2019 Theory of Computation Lecture 17: Calculations on Strings II

Numerical Representation of Strings For example, if we have the string w = 372, then k = 2, i2 = 3, i1 = 7, i0 = 2. To find the number associated with this string, we use exactly the following formula: x = iknk + ik-1nk-1 + … + i1n1 + i0n0 x = 3102 + 7101 + 2 = 372. If w = 372 is an octal representation of an integer, then we would have n = 8 and therefore: x = 382 + 781 + 2 = 192 + 56 + 2 = 250 April 16, 2019 Theory of Computation Lecture 17: Calculations on Strings II

Numerical Representation of Strings Now let us develop such a method for strings on an alphabet A. Remember that the set of all strings on an alphabet A, including the empty string, is called A*. Again, let us assume that there is a particular order of symbols in A. We write A = {s1, …, sn} and define that the sequence s1, …, sn corresponds to this order of symbols. Then any string w on A can be written as w = sik sik-1 … si1 , si0 , where 1  im  n and k = |w| - 1. The empty string is indicated by w = 0. April 16, 2019 Theory of Computation Lecture 17: Calculations on Strings II

Numerical Representation of Strings Then we use exactly the same formula as before to associate w with an integer x: x = iknk + ik-1nk-1 + … + i1n1 + i0n0 . With w = 0 we associate the number x = 0. For example, consider the alphabet A = {a, b, c} and the string w = caba. Then x = 333 + 132 + 231 + 1 = 81 + 9 + 6 + 1= 97. Now why is this representation unique? We can prove this by showing how to retrieve the subscripts i0, i1, …, ik from x for any x > 0. April 16, 2019 Theory of Computation Lecture 17: Calculations on Strings II

Numerical Representation of Strings First, we define two primitive recursive functions where R(x, y) and x / y are defined as in Section 3.7. Basically, R+ and Q+ are the “usual” remainder and quotient functions, except that remainders are now in the range between 1 and y instead of 0 and y –1. April 16, 2019 Theory of Computation Lecture 17: Calculations on Strings II

Numerical Representation of Strings So whenever y divides x, we do not have a remainder of 0 but a remainder of y, and accordingly the quotient is one number below the “actual” quotient. Therefore, like with the usual quotient and remainder, it is still true that: x/y = Q+(x, y) + R+(x, y)/y, only that now we have 1  R+(x, y)  y. We will use the functions Q+ and R+ to show how to obtain the subscripts i0, i1, …, ik from any integer x > 0. April 16, 2019 Theory of Computation Lecture 17: Calculations on Strings II

Numerical Representation of Strings Let us define: u0 = x um+1 = Q+(um, n) Then we have: u0 = iknk + ik-1nk-1 + … + i1n1 + i0 u1 = iknk-1 + ik-1nk-2 + … + i1 : uk = ik The “remainders” R+ are exactly the values of the im: im = R+(um, n), m = 0, …, k. April 16, 2019 Theory of Computation Lecture 17: Calculations on Strings II

Numerical Representation of Strings This is analogous to our usual base-n notation: u0 = x um+1 = Q(um, n) Then we have: u0 = iknk + ik-1nk-1 + … + i1n1 + i0 u1 = iknk-1 + ik-1nk-2 + … + i1 : uk = ik The remainders R are exactly the values of the im: im = R(um, n), m = 0, …, k. April 16, 2019 Theory of Computation Lecture 17: Calculations on Strings II

Numerical Representation of Strings Example: Find binary representation of number 13: Then u0 = x = 13; n = 2 u1 = Q(13, 2) = 6; i0 = R(13, 2) = 1 u2 = Q(6, 2) = 3; i1 = R(6, 2) = 0 u3 = Q(3, 2) = 1; i2 = R(3, 2) = 1 u4 = Q(1, 2) = 0; i3 = R(1, 2) = 1 Then w = 1101. Thus k = 3 and we have x = 123 + 122 + 021 + 120 April 16, 2019 Theory of Computation Lecture 17: Calculations on Strings II