Presentation is loading. Please wait.

Presentation is loading. Please wait.

INHERENT LIMITATIONS OF COMPUTER PROGRAMS CSci 4011.

Similar presentations


Presentation on theme: "INHERENT LIMITATIONS OF COMPUTER PROGRAMS CSci 4011."— Presentation transcript:

1 INHERENT LIMITATIONS OF COMPUTER PROGRAMS CSci 4011

2 TURING MACHINE FINITE STATE CONTROL INFINITE TAPE INPUT q0q0 q1q1 A

3 A TM decides a language if it accepts all strings in the language and rejects all strings not in the language A language is called decidable or recursive if some TM decides it A TM recognizes a language if it accepts all (and only) strings in the language.

4 Theorem: If L is decidable then so is its negation. Proof: Let M = (Q, , , ,q 0,q accept,q reject ) decide L. We construct M’ that decides ¬L. M’ = (Q, , , ,q 0,q reject,q accept ), i.e. M with q reject and q accept swapped. Suppose that w ∈ L. Then M’ rejects w, since M will go to q accept on w. Suppose that w  L. Then M’ accepts w, since M will go to q reject on w.

5 Theorem: If L 1 and L 2 are decidable then so is L 1 ∩ L 2 = { w | w ∈ L 1 and w ∈ L 2 }. Proof: Let M 1 decide L 1 and M 2 decide L 2. We build a two-tape TM M’ to decide L 1 ∩ L 2.

6 MULTITAPE TURING MACHINES  : Q  Γ k → Q  Γ k  {L,R,S} k FINITE STATE CONTROL

7 Theorem: If L 1 and L 2 are decidable then so is L 1 ∩ L 2 = { w | w ∈ L 1 and w ∈ L 2 }. Proof: Let M 1 decide L 1 and M 2 decide L 2. We build a two-tape TM M’ to decide L 1 ∩L 2. M’ works as follows: 1. Copy the input to tape 2 and move to left edge 2. Run M 1 on tape 1 and M 2 on tape 2. If either M 1 or M 2 reject, go to q reject If both M 1 and M 2 accept, go to q accept

8 Formally, let M i = (Q i, ,  i,  i,q s i,q a i,q r i ). Then M’ = (Q, , , ,q 0,q a,q r ), where: Q = Q 1 Q 2 ∪ Q cp,  =  1 ∪  2 ∪  cp,  ((q 1,q 2 ),s 1,s 2 ) = (q r,s 1,s 2,S,S), if q 1 = q 1 r or q 2 = q 2 r (q a,s 1,s 2,S,S), if q 1 = q 1 a and q 2 = q 2 a ((q 1 ’,q 2 ’),s 1 ’,s 2 ’,d 1,d 2 ), else ((q 1,q 2 ’),s 1,s 2 ’,S,d 2 ), if q 1 =q 1 a ((q 1 ’,q 2 ),s 1 ’,s 2,d 1,S), if q 2 =q 2 a where (q i ’,s i ’,d i ) =  i (q i,s i )

9 Theorem: Every Multitape Turing Machine can be transformed into a single tape Turing Machine FINITE STATE CONTROL 001 001 # # #

10 SIMULATING MULTIPLE TAPES 1. “Format” tape. 3. If a tape head goes off right end, insert blank. If tape head goes off left end, move back right. Scan left-to-right, finding current symbols Scan left-to-right, writing new symbols Scan left-to-right, moving each tape head. 2. For each move of the k-tape TM: L#100#□#□#R qiqi q i1 q i1□ q i1□□ q j101RSS L#100#0#□#R L#100#0#1#R ● q jRSS 100 ● ● ● qjqj

11 DOUBLE UNBOUNDED TURING MACHINE FINITE STATE CONTROL UNBOUNDED TAPE INPUT

12 Theorem: Double Unbounded Turing Machines are equivalent to ordinary Turing Machines Proof: To simulate ordinary machine: To simulate a double unbounded tape: On “L” in any state, go right. Go left, write“L”, go right. Insert “L” at left edge. Write “R” at right edge. On “L” or “R” insert □.

13 ENUMERATORS …Are TMs with “print” and “halt” states instead of “accept” and “reject” A string w is in L(E) if E eventually goes into “print” state with w on the tape.

14 Terminology A TM recognizes a language if it accepts all and only those strings in the language A TM decides L if it accepts all strings in L language and rejects all strings not in L A language is called decidable or recursive if some TM decides it A language is called Turing-recognizable if some TM recognizes it A language L is called recursively enumerable if for some enumerator E, L(E) = L.

15 Theorem: L is Turing-recognizable ⇔ L is recursively enumerable. ⇐ : Let L be enumerated by E. We write a 2-tape TM that recognizes L. INPUT: ENUM: 10110011… 01101001… Run E on tape 2; when E goes to “print” state, Check if tape 2 = tape 1 and accept if true.

16 Theorem: L is Turing-recognizable ⇔ L is recursively enumerable. ⇒ : Let L be recognized by M. We can enumerate L as follows: Run M for 1 step on all strings of length ≤ 1 Run M for 2 steps on all strings of length ≤ 2 Run M for k steps on all strings of length ≤ k   Whenever M accepts on string w, print w.

17 A language is called Turing-recognizable or recursively enumerable if some TM recognizes it A language is called decidable or recursive if some TM decides it recursive languages r.e. languages

18 Theorem: If A and  A are r.e. then A is recursive Given TM M 1 that recognizes A and TM M 2 that recognizes  A, we can build a new machine that decides A: Run M 1 on tape 1, and M 2 on tape 2. accept. If M 2 accepts, reject. If M 1 accepts,

19 SO… TMs are equivalent to 2-stack PDAs. TMs are equivalent to cellular automata. TMs are equivalent to multitape TMs TMs are equivalent to double unbounded TMs TMs are equivalent to IDTMs. TMs are equivalent to primitive recursive functions.

20 THE CHURCH-TURING THESIS L is recognized by a program for some computer* ⇔ L is recognized by a TM * The computer must be “reasonable”

21 The Church-Turing Thesis is consistent with all known “reasonable” computers. SCRATCH: R1: R2:  RAM: 1111… 1101001… 1011001… #1011#1101101#1011001#...# Programs for a computer have instructions like ADD R1, R2, R3; LOAD R1, R2; STORE R1,R2; MUL R1, R2, R2; BRANCH R1, X;…

22 Programming languages like Java, Python, Scheme, C, … are equivalent to TMs We call such languages Turing complete. Corollary. If two programming languages are Turing complete, then they can recognize exactly the same set of languages.

23 We can encode a TM as a string of 0s and 1s 0 n 10 m 10 k 10 s 10 t 10 r 10 u 1… n states m tape symbols (first k are input symbols) start state accept state reject state blank symbol 〈 (p,a), (q,b,L) 〉 = 0 p 10 a 10 q 10 b 10

24 Since TMs and other languages are equivalent we can also express TMs as programs. Since programs are strings, we can consider languages whose elements are programs. We let 〈 M 〉 denote the encoding of TM M. Theorem. We can make a Universal TM, a TM that takes any 〈 M 〉 and any string w as input and simulates the computation of M on w.


Download ppt "INHERENT LIMITATIONS OF COMPUTER PROGRAMS CSci 4011."

Similar presentations


Ads by Google