Presentation is loading. Please wait.

Presentation is loading. Please wait.

PARTIAL RECURSIVE FUNCTION

Similar presentations


Presentation on theme: "PARTIAL RECURSIVE FUNCTION"— Presentation transcript:

1 PARTIAL RECURSIVE FUNCTION
A function is partial recursive if it can be obtained from the base functions (null, successor, projections) by finitely many applications of the operations of substitution, primitive recursion, and minimization. A partial recursive function which is total is called total recursive.

2

3 PARTIAL RECURSIVE FUNCTION
Every partial recursive function is computed by a LOOP program Every number-theoretic function computed by a LOOP program is partial recursive

4 PARTIAL RECURSIVE FUNCTION
Notation :We use , , ,... to denote (possible) partial functions. We use f, g, h,... to denote total functions. (x) means that (x) is defined (convergent), i.e., x dom  . (x) means that (x) is undefined (divergent), i.e., x dom  . = means that for all x either both (x) and (x) , or (x) and (x) and (x) = (x).

5 Why do we care about Turing Machines?
Universality! Universality: a universal computing machine can do any computation that can be done by any other machine.

6 Programmable Turing machines
Up until now, we constructed specific Turing machines to do specific things. For example Adding 2 to a natural number Adding 1 to a binary number But it is possible to do more…

7 The Universal Turing Machine
We can build a Turing Machine that can do the job of any other Turing Machine. That is, it can tell you what the output from the second TM would be for any input! This is known as a universal Turing machine (UTM). A UTM acts as a completely general-purpose computer, and basically it stores a program and data on the tape and then executes the program.

8 The Universal TM U Given a description M,w of a TM M and input w, can we simulate M on w? We can do so via a universal TM U (2-tape): Check if M is a proper TM Let M = (Q,,,,q0,qaccept,qreject) Write down the starting configuration  q0w  on the second tape Repeat until halting configuration is reached: Replace configuration on tape 2 by next configuration according to  “Accept” if qaccept is reached; “reject” if qreject

9 A three tape Turing machine
We can imaging the UTN as a three tape TM, where we have a separate tape to keep track of: 1) the program 2) the state 3) the input Is there anything that a Turing machine cannot do?

10 Decidability While we believe that Turing machines can compute anything which is computable in principle, they cannot do everything! One example is the halting problem, which has to do with whether a Turing machine will stop for a given input or will keep computing forever. For example, we cannot make a Turing machine that will be able to decide whether another Turing will halt on any given input.

11 Enumerating Languages
Thus far, the Turing machines were ‘recognizers’. When a TM E generates the words of a language, E is an enumerator (cf. “recursively enumerable”). A Turing machine E, enumerates the language L if it prints an (infinite) list of strings on the tape such that all elements of L will appear on the tape, and all strings on the tape are elements of L. (E starts on an empty input tape. The strings can appear in any order; repetition is allowed.)

12 Enumerating = Recognizing
Theorem 3.13: A language L is TM-recognizable if and only if L is enumerable. Proof: (“if”) Take the enumerator E and input w. Run E and check the strings it generates. If w is produced, then “accept” and stop, otherwise let E continue. (“only if”) Take the recognizer M. Let s1,s2,… be a listing of all strings *L. For j=1,2,… run M on s1,…,sj for j time-steps. If M accepts an s, print s. Keep increasing j.

13 Recognizability and m
Theorem 5.22: If AmB and B is TM-recognizable, then A is TM-recognizable. Proof: Let M be the TM that recognizes B and f the reducing function from A to B. Again the TM: On input w: 1) Compute f(w) 2) Simulate M on f(w) and give the same result. By definition of f: wA equivalent with f(w)B. M “accepts” f(w) if wA, and M “rejects” f(w)/does not halt on f(w) if wA.

14 Unrecognizability and m
Corollary 5.23: If AmB and A is not Turing- recognizable, then B is not recognizable as well. Proof: Language A not TM-recognizable and B recognizable contradicts the previous theorem. Extra: If AmB and A is not co-TM recognizable, then B is not co-Turing-recognizable as well. Proof: If A is not co-TM-recognizable, then the complement (*\A) is not TM recognizable. By AmB we also know that (*\A) m (*\B). Previous corollary: (*\B) not TM recognizable, hence B not co-Turing-recognizable .

15 Decidability What can computers do and what not?
We are now ready to tackle the question: What can computers do and what not? We do this by considering the question: Which languages are TM-decidable, Turing- recognizable, or neither? Assuming the Church-Turing thesis, these are fundamental properties of the languages.

16 Describing TM Programs
Three Levels of Describing algorithms: formal (state diagrams, CFGs, et cetera) implementation (pseudo-Pascal) high-level (coherent and clear English) Describing input/output format: TMs allow only strings * as input/output. If our X and Y are of another form (graph, Turing machine, polynomial), then we use X,Y to denote ‘some kind of encoding *’.

17 Deciding Regular Languages
The acceptance problem for deterministic finite automata is defined by: ADFA = { B,w | B is a DFA that accepts w } Note that this language deals with all possible DFAs and inputs w, not a specific instance. Of course, ADFA is a TM-decidable language.

18 ADFA is Decidable Proof: Let the input B,w be a DFA with B=(Q, , , qstart, F) and w*. The TM performs the following steps: Check if B and w are ‘proper’, if not: “reject” Simulate B on w with the help of two pointers: Pq  Q for the internal state of the DFA, and Pw  {0,1,…,|w|} for the position on the string. While we increase Pw from 0 to |w|, we change Pq according to the input letter wPw and the transition function value (Pq,wPw). If M accepts w: “accept”; otherwise “reject”

19 More Examples (1) Lforever = {(k, w) | Turing machine Tk runs
forever on input w} It’s shown in tutorial (Nov 23, 24) that Lforever is non-recursive. Actually, it’s also non-RE.

20 More Examples (1) Lforever is non-RE. Proof:
If Lforever is RE, the language Lu will be recursive. Why? Suppose you have a Turing machine M for Lforever, you can make use of M to construct a Turing machine Tu for Lu that is guaranteed to stop. How?

21 More Examples (1) yes k no M yes k,w no (Tk accepts w) (Tk does not
accept w)

22 More Examples (2) L1 = {(k, ) | Turing machine Tk will write symbol “” given a blank input} Is L1 RE? Is L1 recursive?

23 More Examples (2) L1 is RE. Proof:
Given k and , we can generate a new Turing machine Tk’ from Tk such that Tk’ will run exactly as Tk except that whenever Tk write an , Tk’ will go to and stop at a final state. (How, in details?) Then we can run Tk’ on a blank input and get the answer.

24 More Examples (2) yes yes Run Tk’ on a blank input k,  k’ no no
(Tk write ) yes Run Tk’ on a blank input k,  k’ no no Construct Tk’ (Tk does not write ) Turing machine for L1

25 More Examples (2) L1 is non-recursive. Proof:
If L1 is recursive, Lu will also be recursive. Why? Suppose you are given (k, w) for the Universal Language Problem, we can construct a Turing machine Tk’ from Tk such that Tk’ will first write w on the tape, then it will run exactly as Tk except that whenever Tk stops at a final state, Tk’ will write . (How, in details?) Then we can feed (k’, ) into the Turing machine for L1 to solve the corresponding ULP.

26 More Examples (2) yes yes Turing machine k, w k’,  Construct Tk’
(Tk accepts w) yes Turing machine M for L1 (Tk’ writes ) k, w k’,  Construct Tk’ no no (Tk’ does not write ) (Tk’ does not accept w) Tu Since Tu cannot exist, M does not exist.

27 Self-Reference What happens if a computer program M tries to answer questions about itself <M>? Sometimes this is perfectly okay: - How big is <M>? - Is <M> a proper TM? Other questions lead to paradoxes: - Does <M> halt or not? - Is there a smaller program M’ that is equivalent?

28 Undecidability To show that a problem P1 is undecidable, we will make use of another problem P2 which has already been proven to be undecidable. First of all, assume the contradiction, i.e., P1 is decidable. That means, there is a TM M solving P1, i.e., M will give a “yes” or “no” answer to P1 after a finite amount of time. Then, show how you can make use of M to answer P2. This is done by mapping an instance I2 in P2 to an instance I1 in P1 such that the answer to I1 is “yes” (“no”) iff the answer to I2 is “yes” (“no”).

29 Undecidability Recall how the followings are done:
Reduce Ld to Lu Reduce Lu to the Halting Problem Reductions from Lu to PCP is a little bit more complicated.

30 Undecidability Thus Far
Undecidability –thus far– used the undecidability of the accept problem ATM. We proved the undecidability of ATM by making explicit the self-reference paradox: S = { <M> | TMs M that do not accept <M> } Let P be a TM that recognizes S, then “P on <P>” leads to a contradiction. Crucial ingredient: Self-Reference: P accepts <P>.

31 The Halting Problem The existence of the universal TM U shows that ATM = {M,w | M is a TM that accepts w } is TM-recognizable, but can we also decide it? The problem lies with the cases when M does not halt on w. In short: the halting problem. We will see that this is an insurmountable problem: in general one cannot decide if a TM will halt on w or not, hence ATM is undecidable.

32 Proving Undecidability (1)
Consider –again– the acceptance language ATM = { M,w | M is a TM that accepts w }. Proof that ATM is not TM-decidable (Thm. 4.9) (Contradiction) Assume that TM G decides ATM: From G we construct a new TM D that will get us into trouble…

33 Proving Undecidability (2)
The TM D works as follows on input M (a TM): Run G on M,M Disagree with the answer of G (The TM D always halts because G always halts.) In short: Hence: Now run D on D (“on itself”)…

34 Proving Undecidability (3)
Result: This does not make sense: D only accepts if it rejects, and vice versa. (Note again that D always halts.) Contradiction: ATM is not TM-decidable. This proof used diagonalization implicitly…

35 Review of Proof (1) ‘Acceptance behavior’ of Mi on Mj

36 Review of Proof (2) ‘Deciding behavior’ of G on Mi,Mj

37 Review of Proof (3) Disagreeing D has to occur in list as well…

38 Review of Proof (4) Contradiction for D on input D.

39 Another View of the Problem
The “Self-referential paradox” occurs when we force the TM D to disagree with itself. On the one hand, D knows what it is going to do on input D, but then it decides to do something else instead. “You cannot know for sure what you will do in the future, because then you could decide to change your actions and create a paradox.”

40 Self-Reference in Math
The diagonalization method implements the self- reference paradox in a mathematical way. In logic this approach is often used to prove that certain things are impossible. Kurt Gödel gave a mathematical equivalent of “This sentence is not true.” See: “Gödel, Escher, Bach” by D.R. Hofstadter.

41 TM-Unrecognizable ATM is not TM-decidable, but it is TM-recognizable.
What about a language that is not recognizable? Theorem 4.16: If a language A is recognizable and its complement Ā is recognizable, then A is Turing machine decidable. Proof: Run the recognizing TMs for A and Ā in parallel on input x. Wait for one of the TMs to accept. If the TM for A accepted: “accept x”; if the TM for Ā accepted: “reject x”.

42 ĀTM is not TM-Recognizable
By the previous results it follows that ĀTM cannot be TM-recognizable, because this would imply that ATM is TM decidable (Corollary 4.17). We call languages like ĀTM co-TM recognizable. TM-recognizable TM decidable co-TM recognizable

43 Things that TMs Cannot Do:
The following languages are also unrecognizable: ETM = { G | G is a TM with L(G)= } EQTM = { G,H | G and H are TMs with L(G)=L(H) } To be precise: ETM is co-TM recognizable EQTM is not even co-Turing recognizable

44 The Recursion Theorem The recursion theorem in CS shows how we can deal with the self-reference effect for TMs. The key idea is to split the TM into two parts: 1) a string that describes 2nd part of program 2) a program that prints the string ‘smart’ How to construct a program <SELF> that prints itself…

45 A Simple Lemma Lemma 6.1: Let w be an input string, and let Pw be a TM that prints w. The function q(w) = <Pw> is TM computable. Proof: Consider the TM (on input w): 1) Construct TM Pw: 1) erase input 2) write w and halt 2) Output <Pw>

46 The Program <SELF> = <AB>
The SELF-program consists of two parts A and B: First part: A = P<B>, so we will wait with this one… B part (on input <M> with M a TM subroutine): 1) Read <M>, compute <P<M>> % see Lemma 6.1 2) Use <M> and <P<M>> to print <P<M> M> Now we know what P<B> looks like.

47 Working of SELF: A = B1 = B2 = P<1) Given … M>>
1) Given <M>, compute <P<M>> 2) Use <M> and <P<M>> to print <P<M> M> After A-part on the tape: 1) Given <M> M> B1 reads input on tape, computes <P<1) Given M>>> B2 prints: P<1) Given … M>> 1) Given M>

48 Recursion Theorem Instead of printing, a TM can do anything else with its own description. Recursion Theorem (6.2): Let t: *** be a TM-computable function. There is a Turing machine R that computes the function r: ** with r(w) = t(<R>,w) for every w*. (In the case of SELF, we had t(x,y) = x.)

49 Proof Recursion Theorem
Let t: *** be a TM-computable function. There is a TM R that computes the function r(w) = t(<R>,w) for every w*. Proof: Let T be the TM that computes t. The TM R consists of 3 parts: A,B,T (input w): A = P<BT> B = Read input <M>, print <P<M> M> T = Calculate t on (tape content,w).

50 Application Recursion
The recursion theorem makes it clear that self- reference is possible for TMs: is possible. It shows that programs like SELF are possible. Makes undecidability proofs more transparent as they can now be phrased for a single TM. 1) Bla-bla-bla; 2) Look at <M>; 3) More Bla-bla-bla; M =

51 ATM is Undecidable Theorem : The acceptance language ATM = { <M,w> | TM M accepts input w } is undecidable. Proof by contradiction: Assume that H decides ATM. Construct the following TM B (input w): 1) Print own description <B> 2) Run H on input <B,w> 3) Negate answer of H The answer of H on <B,w> and the reply of B on <w> will disagree. Contradiction.


Download ppt "PARTIAL RECURSIVE FUNCTION"

Similar presentations


Ads by Google